-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathsync-types.ts
More file actions
106 lines (95 loc) · 2.82 KB
/
Copy pathsync-types.ts
File metadata and controls
106 lines (95 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// MARK: - Secrets vault
export type CredentialConfig =
| {
type: 'postgres'
host: string
port: number
user: string
password: string
database: string
}
| {
type: 'google'
client_id: string
client_secret: string
refresh_token?: string
}
| {
type: 'stripe'
api_key: string
}
export type Credential = { id: `cred_${string}`; account_id: `acct_${string}` } & CredentialConfig
// MARK: - Config database
export type StripeApiVersion =
| '2025-04-30.basil'
| '2025-03-31.basil'
| '2024-12-18.acacia'
| '2024-11-20.acacia'
| '2024-10-28.acacia'
| '2024-09-30.acacia'
export type SourceConfig =
/** Pull via Stripe's core REST API. Requires a credential with a Stripe API key. */
| {
type: 'stripe-api-core'
livemode: boolean
api_version: StripeApiVersion
credential_id: string
}
/** Pull via Stripe's Reporting API. Requires a credential with a Stripe API key. */
| {
type: 'stripe-api-reporting'
livemode: boolean
api_version: StripeApiVersion
credential_id: string
}
/** Receive events via Stripe EventBridge. No credential needed — uses account-level access. */
| { type: 'stripe-event-bridge'; livemode: boolean; account_id: `acct_${string}` }
export type DestinationConfig =
| {
type: 'postgres'
schema_name: string
/** Credential type: `postgres` */
credential_id: string
}
| {
type: 'google_sheets'
google_sheet_id: string
/** Credential type: `google` */
credential_id: string
}
export type SyncStatus = 'backfilling' | 'syncing' | 'paused' | 'error'
export interface StreamConfig {
/** Stream name (e.g. "customer", "invoice"). */
name: string
/** 'incremental' (default) or 'full_refresh'. */
sync_mode?: 'incremental' | 'full_refresh'
/** Skip historical backfill, only sync new events going forward. */
skip_backfill?: boolean
}
/**
* A Sync is the full resource — configuration + runtime state.
* The user sets source, destination, and streams.
* The orchestrator manages status and state.
*
* Analogous to Airbyte's Connection (config + configured catalog + state).
*/
export type Sync = {
id: `sync_${string}`
account_id: `acct_${string}`
// Runtime (orchestrator-managed)
status: SyncStatus
// Configuration (user-provided)
source: SourceConfig
destination: DestinationConfig
/**
* Which streams to sync and per-stream options.
* If omitted, sync all streams discovered by the source.
*/
streams?: StreamConfig[]
/**
* Per-stream checkpoint map. Managed by the orchestrator.
* Keyed by stream name, values are opaque to everything except the source.
* e.g. { "customer": { "after": "cus_999" }, "invoice": { "after": "inv_500" } }
*/
state?: Record<string, unknown>
}