stripe-experiment-sync 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -4
- package/dist/{chunk-3UERGK2O.js → chunk-CKWVW2JK.js} +18 -6
- package/dist/chunk-J7BH3XD6.js +3436 -0
- package/dist/chunk-X2OQQCC2.js +409 -0
- package/dist/chunk-YH6KRZDQ.js +634 -0
- package/dist/cli/index.cjs +4592 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +59 -0
- package/dist/cli/lib.cjs +4571 -0
- package/dist/cli/lib.d.cts +69 -0
- package/dist/cli/lib.d.ts +69 -0
- package/dist/cli/lib.js +21 -0
- package/dist/index.cjs +243 -58
- package/dist/index.d.cts +54 -2
- package/dist/index.d.ts +54 -2
- package/dist/index.js +9 -3255
- package/dist/migrations/0057_rename_sync_tables.sql +57 -0
- package/dist/migrations/0058_improve_sync_runs_status.sql +36 -0
- package/dist/supabase/index.cjs +46 -21
- package/dist/supabase/index.d.cts +6 -1
- package/dist/supabase/index.d.ts +6 -1
- package/dist/supabase/index.js +12 -382
- package/package.json +18 -6
package/README.md
CHANGED
|
@@ -120,11 +120,32 @@ The library will create and manage a `stripe` schema in your PostgreSQL database
|
|
|
120
120
|
|
|
121
121
|
> **Important:** The library uses a fixed schema name of `stripe`. This cannot be configured as the SQL migrations hardcode this schema name.
|
|
122
122
|
|
|
123
|
-
> **Note:** Fields and tables prefixed with an underscore (`_`) are reserved for internal metadata managed by the sync engine and should not be modified directly. These include fields like `
|
|
123
|
+
> **Note:** Fields and tables prefixed with an underscore (`_`) are reserved for internal metadata managed by the sync engine and should not be modified directly. These include fields like `_account_id`, `_last_synced_at`, `_updated_at`, and tables like `_migrations`, `_managed_webhooks`, `_sync_runs`, and `_sync_obj_runs`.
|
|
124
|
+
|
|
125
|
+
### Observability
|
|
126
|
+
|
|
127
|
+
The sync engine tracks sync operations in the `sync_runs` view, which provides aggregated metrics for each sync session:
|
|
128
|
+
|
|
129
|
+
```sql
|
|
130
|
+
SELECT
|
|
131
|
+
account_id,
|
|
132
|
+
started_at,
|
|
133
|
+
closed_at,
|
|
134
|
+
status, -- 'running', 'complete', or 'error'
|
|
135
|
+
total_processed, -- Total records synced across all objects
|
|
136
|
+
complete_count, -- Number of object types completed
|
|
137
|
+
error_count, -- Number of object types with errors
|
|
138
|
+
running_count, -- Number of object types currently syncing
|
|
139
|
+
pending_count -- Number of object types not yet started
|
|
140
|
+
FROM stripe.sync_runs
|
|
141
|
+
ORDER BY started_at DESC;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
For detailed per-object status, you can query the internal `_sync_obj_runs` table (though this is not recommended for production use).
|
|
124
145
|
|
|
125
146
|
### Migrations
|
|
126
147
|
|
|
127
|
-
Migrations are included in the `
|
|
148
|
+
Migrations are automatically included with the package and bundled in the `dist/migrations` directory when built. You can run them using the provided `runMigrations` function:
|
|
128
149
|
|
|
129
150
|
```ts
|
|
130
151
|
import { runMigrations } from 'stripe-experiment-sync'
|
|
@@ -205,10 +226,10 @@ await sync.processUntilDone({
|
|
|
205
226
|
})
|
|
206
227
|
```
|
|
207
228
|
|
|
208
|
-
- `object` can be one of: `all`, `charge`, `customer`, `dispute`, `
|
|
229
|
+
- `object` can be one of: `all`, `charge`, `checkout_sessions`, `credit_note`, `customer`, `customer_with_entitlements`, `dispute`, `early_fraud_warning`, `invoice`, `payment_intent`, `payment_method`, `plan`, `price`, `product`, `refund`, `setup_intent`, `subscription`, `subscription_schedules`, `tax_id`.
|
|
209
230
|
- `created` is a Stripe RangeQueryParam and supports `gt`, `gte`, `lt`, `lte`.
|
|
210
231
|
|
|
211
|
-
The sync engine automatically tracks per-account cursors in the `
|
|
232
|
+
The sync engine automatically tracks per-account cursors in the `_sync_runs` and `_sync_obj_runs` tables. When you call sync methods without an explicit `created` filter, they will automatically resume from the last synced position for that account and resource. This enables incremental syncing that can resume after interruptions.
|
|
212
233
|
|
|
213
234
|
> **Note:**
|
|
214
235
|
> For large Stripe accounts (more than 10,000 objects), it is recommended to write a script that loops through each day and sets the `created` date filters to the start and end of day. This avoids timeouts and memory issues when syncing large datasets.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "stripe-experiment-sync",
|
|
4
|
-
version: "1.0.
|
|
4
|
+
version: "1.0.8-beta.1765856228",
|
|
5
5
|
private: false,
|
|
6
6
|
description: "Stripe Sync Engine to sync Stripe data to Postgres",
|
|
7
7
|
type: "module",
|
|
8
8
|
main: "./dist/index.cjs",
|
|
9
|
-
bin: "./dist/cli/index.
|
|
9
|
+
bin: "./dist/cli/index.js",
|
|
10
10
|
exports: {
|
|
11
11
|
".": {
|
|
12
12
|
types: "./dist/index.d.ts",
|
|
@@ -17,12 +17,17 @@ var package_default = {
|
|
|
17
17
|
types: "./dist/supabase/index.d.ts",
|
|
18
18
|
import: "./dist/supabase/index.js",
|
|
19
19
|
require: "./dist/supabase/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./cli": {
|
|
22
|
+
types: "./dist/cli/lib.d.ts",
|
|
23
|
+
import: "./dist/cli/lib.js",
|
|
24
|
+
require: "./dist/cli/lib.cjs"
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
scripts: {
|
|
23
28
|
clean: "rimraf dist",
|
|
24
29
|
prebuild: "npm run clean",
|
|
25
|
-
build: "tsup src/index.ts src/supabase/index.ts --format esm,cjs --dts --shims && cp -r src/database/migrations dist/migrations",
|
|
30
|
+
build: "tsup src/index.ts src/supabase/index.ts src/cli/index.ts src/cli/lib.ts --format esm,cjs --dts --shims && cp -r src/database/migrations dist/migrations",
|
|
26
31
|
lint: "eslint src --ext .ts",
|
|
27
32
|
test: "vitest"
|
|
28
33
|
},
|
|
@@ -30,21 +35,28 @@ var package_default = {
|
|
|
30
35
|
"dist"
|
|
31
36
|
],
|
|
32
37
|
dependencies: {
|
|
38
|
+
"@ngrok/ngrok": "^1.4.1",
|
|
39
|
+
chalk: "^5.3.0",
|
|
40
|
+
commander: "^12.1.0",
|
|
41
|
+
dotenv: "^16.4.7",
|
|
42
|
+
express: "^4.18.2",
|
|
43
|
+
inquirer: "^12.3.0",
|
|
33
44
|
pg: "^8.16.3",
|
|
34
45
|
"pg-node-migrations": "0.0.8",
|
|
46
|
+
stripe: "^17.7.0",
|
|
35
47
|
"supabase-management-js": "^0.1.6",
|
|
36
48
|
ws: "^8.18.0",
|
|
37
49
|
yesql: "^7.0.0"
|
|
38
50
|
},
|
|
39
|
-
peerDependencies: {
|
|
40
|
-
stripe: "> 11"
|
|
41
|
-
},
|
|
42
51
|
devDependencies: {
|
|
52
|
+
"@types/express": "^4.17.21",
|
|
53
|
+
"@types/inquirer": "^9.0.7",
|
|
43
54
|
"@types/node": "^24.10.1",
|
|
44
55
|
"@types/pg": "^8.15.5",
|
|
45
56
|
"@types/ws": "^8.5.13",
|
|
46
57
|
"@types/yesql": "^4.1.4",
|
|
47
58
|
"@vitest/ui": "^4.0.9",
|
|
59
|
+
tsx: "^4.19.2",
|
|
48
60
|
vitest: "^3.2.4"
|
|
49
61
|
},
|
|
50
62
|
repository: {
|