stripe-experiment-sync 1.0.17 → 1.0.18

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.
@@ -2,11 +2,11 @@ import {
2
2
  StripeSync,
3
3
  createStripeWebSocketClient,
4
4
  runMigrations
5
- } from "./chunk-TV67ZOCK.js";
5
+ } from "./chunk-K4JQHI7Y.js";
6
6
  import {
7
7
  install,
8
8
  uninstall
9
- } from "./chunk-I7IFXSAU.js";
9
+ } from "./chunk-M5TTM27L.js";
10
10
 
11
11
  // src/cli/config.ts
12
12
  import dotenv from "dotenv";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-57SXDCMH.js";
3
+ } from "./chunk-XO57OJUE.js";
4
4
 
5
5
  // src/stripeSync.ts
6
6
  import Stripe3 from "stripe";
@@ -505,15 +505,17 @@ var PostgresClient = class {
505
505
  /**
506
506
  * Create object run entries for a sync run.
507
507
  * All objects start as 'pending'.
508
+ *
509
+ * @param resourceNames - Database resource names (e.g. 'products', 'customers', NOT 'product', 'customer')
508
510
  */
509
- async createObjectRuns(accountId, runStartedAt, objects) {
510
- if (objects.length === 0) return;
511
- const values = objects.map((_, i) => `($1, $2, $${i + 3})`).join(", ");
511
+ async createObjectRuns(accountId, runStartedAt, resourceNames) {
512
+ if (resourceNames.length === 0) return;
513
+ const values = resourceNames.map((_, i) => `($1, $2, $${i + 3})`).join(", ");
512
514
  await this.query(
513
515
  `INSERT INTO "${this.config.schema}"."_sync_obj_runs" ("_account_id", run_started_at, object)
514
516
  VALUES ${values}
515
517
  ON CONFLICT ("_account_id", run_started_at, object) DO NOTHING`,
516
- [accountId, runStartedAt, ...objects]
518
+ [accountId, runStartedAt, ...resourceNames]
517
519
  );
518
520
  }
519
521
  /**
@@ -2238,31 +2240,43 @@ var StripeSync = class {
2238
2240
  * This is used by workers and background processes that should cooperate.
2239
2241
  *
2240
2242
  * @param triggeredBy - What triggered this sync (for observability)
2243
+ * @param objectFilter - Optional specific object to sync (e.g. 'payment_intent'). If 'all' or undefined, syncs all objects.
2241
2244
  * @returns Run key and list of objects to sync
2242
2245
  */
2243
- async joinOrCreateSyncRun(triggeredBy = "worker") {
2246
+ async joinOrCreateSyncRun(triggeredBy = "worker", objectFilter) {
2244
2247
  await this.getCurrentAccount();
2245
2248
  const accountId = await this.getAccountId();
2246
2249
  const result = await this.postgresClient.getOrCreateSyncRun(accountId, triggeredBy);
2250
+ const objects = objectFilter === "all" || objectFilter === void 0 ? this.getSupportedSyncObjects() : [objectFilter];
2247
2251
  if (!result) {
2248
2252
  const activeRun = await this.postgresClient.getActiveSyncRun(accountId);
2249
2253
  if (!activeRun) {
2250
2254
  throw new Error("Failed to get or create sync run");
2251
2255
  }
2256
+ await this.postgresClient.createObjectRuns(
2257
+ activeRun.accountId,
2258
+ activeRun.runStartedAt,
2259
+ objects.map((obj) => this.getResourceName(obj))
2260
+ );
2252
2261
  return {
2253
2262
  runKey: { accountId: activeRun.accountId, runStartedAt: activeRun.runStartedAt },
2254
- objects: this.getSupportedSyncObjects()
2263
+ objects
2255
2264
  };
2256
2265
  }
2257
2266
  const { accountId: runAccountId, runStartedAt } = result;
2267
+ await this.postgresClient.createObjectRuns(
2268
+ runAccountId,
2269
+ runStartedAt,
2270
+ objects.map((obj) => this.getResourceName(obj))
2271
+ );
2258
2272
  return {
2259
2273
  runKey: { accountId: runAccountId, runStartedAt },
2260
- objects: this.getSupportedSyncObjects()
2274
+ objects
2261
2275
  };
2262
2276
  }
2263
2277
  async processUntilDone(params) {
2264
2278
  const { object } = params ?? { object: "all" };
2265
- const { runKey } = await this.joinOrCreateSyncRun("processUntilDone");
2279
+ const { runKey } = await this.joinOrCreateSyncRun("processUntilDone", object);
2266
2280
  return this.processUntilDoneWithRun(runKey.runStartedAt, object, params);
2267
2281
  }
2268
2282
  /**
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-57SXDCMH.js";
3
+ } from "./chunk-XO57OJUE.js";
4
4
 
5
5
  // src/supabase/supabase.ts
6
6
  import { SupabaseManagementAPI } from "supabase-management-js";
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "stripe-experiment-sync",
4
- version: "1.0.17",
4
+ version: "1.0.18",
5
5
  private: false,
6
6
  description: "Stripe Sync Engine to sync Stripe data to Postgres",
7
7
  type: "module",
@@ -33,7 +33,7 @@ var import_commander = require("commander");
33
33
  // package.json
34
34
  var package_default = {
35
35
  name: "stripe-experiment-sync",
36
- version: "1.0.17",
36
+ version: "1.0.18",
37
37
  private: false,
38
38
  description: "Stripe Sync Engine to sync Stripe data to Postgres",
39
39
  type: "module",
@@ -687,15 +687,17 @@ var PostgresClient = class {
687
687
  /**
688
688
  * Create object run entries for a sync run.
689
689
  * All objects start as 'pending'.
690
+ *
691
+ * @param resourceNames - Database resource names (e.g. 'products', 'customers', NOT 'product', 'customer')
690
692
  */
691
- async createObjectRuns(accountId, runStartedAt, objects) {
692
- if (objects.length === 0) return;
693
- const values = objects.map((_, i) => `($1, $2, $${i + 3})`).join(", ");
693
+ async createObjectRuns(accountId, runStartedAt, resourceNames) {
694
+ if (resourceNames.length === 0) return;
695
+ const values = resourceNames.map((_, i) => `($1, $2, $${i + 3})`).join(", ");
694
696
  await this.query(
695
697
  `INSERT INTO "${this.config.schema}"."_sync_obj_runs" ("_account_id", run_started_at, object)
696
698
  VALUES ${values}
697
699
  ON CONFLICT ("_account_id", run_started_at, object) DO NOTHING`,
698
- [accountId, runStartedAt, ...objects]
700
+ [accountId, runStartedAt, ...resourceNames]
699
701
  );
700
702
  }
701
703
  /**
@@ -2420,31 +2422,43 @@ var StripeSync = class {
2420
2422
  * This is used by workers and background processes that should cooperate.
2421
2423
  *
2422
2424
  * @param triggeredBy - What triggered this sync (for observability)
2425
+ * @param objectFilter - Optional specific object to sync (e.g. 'payment_intent'). If 'all' or undefined, syncs all objects.
2423
2426
  * @returns Run key and list of objects to sync
2424
2427
  */
2425
- async joinOrCreateSyncRun(triggeredBy = "worker") {
2428
+ async joinOrCreateSyncRun(triggeredBy = "worker", objectFilter) {
2426
2429
  await this.getCurrentAccount();
2427
2430
  const accountId = await this.getAccountId();
2428
2431
  const result = await this.postgresClient.getOrCreateSyncRun(accountId, triggeredBy);
2432
+ const objects = objectFilter === "all" || objectFilter === void 0 ? this.getSupportedSyncObjects() : [objectFilter];
2429
2433
  if (!result) {
2430
2434
  const activeRun = await this.postgresClient.getActiveSyncRun(accountId);
2431
2435
  if (!activeRun) {
2432
2436
  throw new Error("Failed to get or create sync run");
2433
2437
  }
2438
+ await this.postgresClient.createObjectRuns(
2439
+ activeRun.accountId,
2440
+ activeRun.runStartedAt,
2441
+ objects.map((obj) => this.getResourceName(obj))
2442
+ );
2434
2443
  return {
2435
2444
  runKey: { accountId: activeRun.accountId, runStartedAt: activeRun.runStartedAt },
2436
- objects: this.getSupportedSyncObjects()
2445
+ objects
2437
2446
  };
2438
2447
  }
2439
2448
  const { accountId: runAccountId, runStartedAt } = result;
2449
+ await this.postgresClient.createObjectRuns(
2450
+ runAccountId,
2451
+ runStartedAt,
2452
+ objects.map((obj) => this.getResourceName(obj))
2453
+ );
2440
2454
  return {
2441
2455
  runKey: { accountId: runAccountId, runStartedAt },
2442
- objects: this.getSupportedSyncObjects()
2456
+ objects
2443
2457
  };
2444
2458
  }
2445
2459
  async processUntilDone(params) {
2446
2460
  const { object } = params ?? { object: "all" };
2447
- const { runKey } = await this.joinOrCreateSyncRun("processUntilDone");
2461
+ const { runKey } = await this.joinOrCreateSyncRun("processUntilDone", object);
2448
2462
  return this.processUntilDoneWithRun(runKey.runStartedAt, object, params);
2449
2463
  }
2450
2464
  /**
package/dist/cli/index.js CHANGED
@@ -5,12 +5,12 @@ import {
5
5
  migrateCommand,
6
6
  syncCommand,
7
7
  uninstallCommand
8
- } from "../chunk-YXRCT3RK.js";
9
- import "../chunk-TV67ZOCK.js";
10
- import "../chunk-I7IFXSAU.js";
8
+ } from "../chunk-HV64EIZU.js";
9
+ import "../chunk-K4JQHI7Y.js";
10
+ import "../chunk-M5TTM27L.js";
11
11
  import {
12
12
  package_default
13
- } from "../chunk-57SXDCMH.js";
13
+ } from "../chunk-XO57OJUE.js";
14
14
 
15
15
  // src/cli/index.ts
16
16
  import { Command } from "commander";
package/dist/cli/lib.cjs CHANGED
@@ -117,7 +117,7 @@ async function loadConfig(options) {
117
117
  // package.json
118
118
  var package_default = {
119
119
  name: "stripe-experiment-sync",
120
- version: "1.0.17",
120
+ version: "1.0.18",
121
121
  private: false,
122
122
  description: "Stripe Sync Engine to sync Stripe data to Postgres",
123
123
  type: "module",
@@ -701,15 +701,17 @@ var PostgresClient = class {
701
701
  /**
702
702
  * Create object run entries for a sync run.
703
703
  * All objects start as 'pending'.
704
+ *
705
+ * @param resourceNames - Database resource names (e.g. 'products', 'customers', NOT 'product', 'customer')
704
706
  */
705
- async createObjectRuns(accountId, runStartedAt, objects) {
706
- if (objects.length === 0) return;
707
- const values = objects.map((_, i) => `($1, $2, $${i + 3})`).join(", ");
707
+ async createObjectRuns(accountId, runStartedAt, resourceNames) {
708
+ if (resourceNames.length === 0) return;
709
+ const values = resourceNames.map((_, i) => `($1, $2, $${i + 3})`).join(", ");
708
710
  await this.query(
709
711
  `INSERT INTO "${this.config.schema}"."_sync_obj_runs" ("_account_id", run_started_at, object)
710
712
  VALUES ${values}
711
713
  ON CONFLICT ("_account_id", run_started_at, object) DO NOTHING`,
712
- [accountId, runStartedAt, ...objects]
714
+ [accountId, runStartedAt, ...resourceNames]
713
715
  );
714
716
  }
715
717
  /**
@@ -2434,31 +2436,43 @@ var StripeSync = class {
2434
2436
  * This is used by workers and background processes that should cooperate.
2435
2437
  *
2436
2438
  * @param triggeredBy - What triggered this sync (for observability)
2439
+ * @param objectFilter - Optional specific object to sync (e.g. 'payment_intent'). If 'all' or undefined, syncs all objects.
2437
2440
  * @returns Run key and list of objects to sync
2438
2441
  */
2439
- async joinOrCreateSyncRun(triggeredBy = "worker") {
2442
+ async joinOrCreateSyncRun(triggeredBy = "worker", objectFilter) {
2440
2443
  await this.getCurrentAccount();
2441
2444
  const accountId = await this.getAccountId();
2442
2445
  const result = await this.postgresClient.getOrCreateSyncRun(accountId, triggeredBy);
2446
+ const objects = objectFilter === "all" || objectFilter === void 0 ? this.getSupportedSyncObjects() : [objectFilter];
2443
2447
  if (!result) {
2444
2448
  const activeRun = await this.postgresClient.getActiveSyncRun(accountId);
2445
2449
  if (!activeRun) {
2446
2450
  throw new Error("Failed to get or create sync run");
2447
2451
  }
2452
+ await this.postgresClient.createObjectRuns(
2453
+ activeRun.accountId,
2454
+ activeRun.runStartedAt,
2455
+ objects.map((obj) => this.getResourceName(obj))
2456
+ );
2448
2457
  return {
2449
2458
  runKey: { accountId: activeRun.accountId, runStartedAt: activeRun.runStartedAt },
2450
- objects: this.getSupportedSyncObjects()
2459
+ objects
2451
2460
  };
2452
2461
  }
2453
2462
  const { accountId: runAccountId, runStartedAt } = result;
2463
+ await this.postgresClient.createObjectRuns(
2464
+ runAccountId,
2465
+ runStartedAt,
2466
+ objects.map((obj) => this.getResourceName(obj))
2467
+ );
2454
2468
  return {
2455
2469
  runKey: { accountId: runAccountId, runStartedAt },
2456
- objects: this.getSupportedSyncObjects()
2470
+ objects
2457
2471
  };
2458
2472
  }
2459
2473
  async processUntilDone(params) {
2460
2474
  const { object } = params ?? { object: "all" };
2461
- const { runKey } = await this.joinOrCreateSyncRun("processUntilDone");
2475
+ const { runKey } = await this.joinOrCreateSyncRun("processUntilDone", object);
2462
2476
  return this.processUntilDoneWithRun(runKey.runStartedAt, object, params);
2463
2477
  }
2464
2478
  /**
package/dist/cli/lib.js CHANGED
@@ -6,10 +6,10 @@ import {
6
6
  migrateCommand,
7
7
  syncCommand,
8
8
  uninstallCommand
9
- } from "../chunk-YXRCT3RK.js";
10
- import "../chunk-TV67ZOCK.js";
11
- import "../chunk-I7IFXSAU.js";
12
- import "../chunk-57SXDCMH.js";
9
+ } from "../chunk-HV64EIZU.js";
10
+ import "../chunk-K4JQHI7Y.js";
11
+ import "../chunk-M5TTM27L.js";
12
+ import "../chunk-XO57OJUE.js";
13
13
  export {
14
14
  backfillCommand,
15
15
  createTunnel,
package/dist/index.cjs CHANGED
@@ -46,7 +46,7 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
46
46
  // package.json
47
47
  var package_default = {
48
48
  name: "stripe-experiment-sync",
49
- version: "1.0.17",
49
+ version: "1.0.18",
50
50
  private: false,
51
51
  description: "Stripe Sync Engine to sync Stripe data to Postgres",
52
52
  type: "module",
@@ -630,15 +630,17 @@ var PostgresClient = class {
630
630
  /**
631
631
  * Create object run entries for a sync run.
632
632
  * All objects start as 'pending'.
633
+ *
634
+ * @param resourceNames - Database resource names (e.g. 'products', 'customers', NOT 'product', 'customer')
633
635
  */
634
- async createObjectRuns(accountId, runStartedAt, objects) {
635
- if (objects.length === 0) return;
636
- const values = objects.map((_, i) => `($1, $2, $${i + 3})`).join(", ");
636
+ async createObjectRuns(accountId, runStartedAt, resourceNames) {
637
+ if (resourceNames.length === 0) return;
638
+ const values = resourceNames.map((_, i) => `($1, $2, $${i + 3})`).join(", ");
637
639
  await this.query(
638
640
  `INSERT INTO "${this.config.schema}"."_sync_obj_runs" ("_account_id", run_started_at, object)
639
641
  VALUES ${values}
640
642
  ON CONFLICT ("_account_id", run_started_at, object) DO NOTHING`,
641
- [accountId, runStartedAt, ...objects]
643
+ [accountId, runStartedAt, ...resourceNames]
642
644
  );
643
645
  }
644
646
  /**
@@ -2363,31 +2365,43 @@ var StripeSync = class {
2363
2365
  * This is used by workers and background processes that should cooperate.
2364
2366
  *
2365
2367
  * @param triggeredBy - What triggered this sync (for observability)
2368
+ * @param objectFilter - Optional specific object to sync (e.g. 'payment_intent'). If 'all' or undefined, syncs all objects.
2366
2369
  * @returns Run key and list of objects to sync
2367
2370
  */
2368
- async joinOrCreateSyncRun(triggeredBy = "worker") {
2371
+ async joinOrCreateSyncRun(triggeredBy = "worker", objectFilter) {
2369
2372
  await this.getCurrentAccount();
2370
2373
  const accountId = await this.getAccountId();
2371
2374
  const result = await this.postgresClient.getOrCreateSyncRun(accountId, triggeredBy);
2375
+ const objects = objectFilter === "all" || objectFilter === void 0 ? this.getSupportedSyncObjects() : [objectFilter];
2372
2376
  if (!result) {
2373
2377
  const activeRun = await this.postgresClient.getActiveSyncRun(accountId);
2374
2378
  if (!activeRun) {
2375
2379
  throw new Error("Failed to get or create sync run");
2376
2380
  }
2381
+ await this.postgresClient.createObjectRuns(
2382
+ activeRun.accountId,
2383
+ activeRun.runStartedAt,
2384
+ objects.map((obj) => this.getResourceName(obj))
2385
+ );
2377
2386
  return {
2378
2387
  runKey: { accountId: activeRun.accountId, runStartedAt: activeRun.runStartedAt },
2379
- objects: this.getSupportedSyncObjects()
2388
+ objects
2380
2389
  };
2381
2390
  }
2382
2391
  const { accountId: runAccountId, runStartedAt } = result;
2392
+ await this.postgresClient.createObjectRuns(
2393
+ runAccountId,
2394
+ runStartedAt,
2395
+ objects.map((obj) => this.getResourceName(obj))
2396
+ );
2383
2397
  return {
2384
2398
  runKey: { accountId: runAccountId, runStartedAt },
2385
- objects: this.getSupportedSyncObjects()
2399
+ objects
2386
2400
  };
2387
2401
  }
2388
2402
  async processUntilDone(params) {
2389
2403
  const { object } = params ?? { object: "all" };
2390
- const { runKey } = await this.joinOrCreateSyncRun("processUntilDone");
2404
+ const { runKey } = await this.joinOrCreateSyncRun("processUntilDone", object);
2391
2405
  return this.processUntilDoneWithRun(runKey.runStartedAt, object, params);
2392
2406
  }
2393
2407
  /**
package/dist/index.d.cts CHANGED
@@ -137,8 +137,10 @@ declare class PostgresClient {
137
137
  /**
138
138
  * Create object run entries for a sync run.
139
139
  * All objects start as 'pending'.
140
+ *
141
+ * @param resourceNames - Database resource names (e.g. 'products', 'customers', NOT 'product', 'customer')
140
142
  */
141
- createObjectRuns(accountId: string, runStartedAt: Date, objects: string[]): Promise<void>;
143
+ createObjectRuns(accountId: string, runStartedAt: Date, resourceNames: string[]): Promise<void>;
142
144
  /**
143
145
  * Try to start an object sync (respects max_concurrent).
144
146
  * Returns true if claimed, false if already running or at concurrency limit.
@@ -621,9 +623,10 @@ declare class StripeSync {
621
623
  * This is used by workers and background processes that should cooperate.
622
624
  *
623
625
  * @param triggeredBy - What triggered this sync (for observability)
626
+ * @param objectFilter - Optional specific object to sync (e.g. 'payment_intent'). If 'all' or undefined, syncs all objects.
624
627
  * @returns Run key and list of objects to sync
625
628
  */
626
- joinOrCreateSyncRun(triggeredBy?: string): Promise<{
629
+ joinOrCreateSyncRun(triggeredBy?: string, objectFilter?: SyncObject): Promise<{
627
630
  runKey: RunKey;
628
631
  objects: Exclude<SyncObject, 'all' | 'customer_with_entitlements'>[];
629
632
  }>;
package/dist/index.d.ts CHANGED
@@ -137,8 +137,10 @@ declare class PostgresClient {
137
137
  /**
138
138
  * Create object run entries for a sync run.
139
139
  * All objects start as 'pending'.
140
+ *
141
+ * @param resourceNames - Database resource names (e.g. 'products', 'customers', NOT 'product', 'customer')
140
142
  */
141
- createObjectRuns(accountId: string, runStartedAt: Date, objects: string[]): Promise<void>;
143
+ createObjectRuns(accountId: string, runStartedAt: Date, resourceNames: string[]): Promise<void>;
142
144
  /**
143
145
  * Try to start an object sync (respects max_concurrent).
144
146
  * Returns true if claimed, false if already running or at concurrency limit.
@@ -621,9 +623,10 @@ declare class StripeSync {
621
623
  * This is used by workers and background processes that should cooperate.
622
624
  *
623
625
  * @param triggeredBy - What triggered this sync (for observability)
626
+ * @param objectFilter - Optional specific object to sync (e.g. 'payment_intent'). If 'all' or undefined, syncs all objects.
624
627
  * @returns Run key and list of objects to sync
625
628
  */
626
- joinOrCreateSyncRun(triggeredBy?: string): Promise<{
629
+ joinOrCreateSyncRun(triggeredBy?: string, objectFilter?: SyncObject): Promise<{
627
630
  runKey: RunKey;
628
631
  objects: Exclude<SyncObject, 'all' | 'customer_with_entitlements'>[];
629
632
  }>;
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  createStripeWebSocketClient,
6
6
  hashApiKey,
7
7
  runMigrations
8
- } from "./chunk-TV67ZOCK.js";
9
- import "./chunk-57SXDCMH.js";
8
+ } from "./chunk-K4JQHI7Y.js";
9
+ import "./chunk-XO57OJUE.js";
10
10
  export {
11
11
  PostgresClient,
12
12
  StripeSync,
@@ -54,7 +54,7 @@ var workerFunctionCode = stripe_worker_default;
54
54
  // package.json
55
55
  var package_default = {
56
56
  name: "stripe-experiment-sync",
57
- version: "1.0.17",
57
+ version: "1.0.18",
58
58
  private: false,
59
59
  description: "Stripe Sync Engine to sync Stripe data to Postgres",
60
60
  type: "module",
@@ -9,8 +9,8 @@ import {
9
9
  uninstall,
10
10
  webhookFunctionCode,
11
11
  workerFunctionCode
12
- } from "../chunk-I7IFXSAU.js";
13
- import "../chunk-57SXDCMH.js";
12
+ } from "../chunk-M5TTM27L.js";
13
+ import "../chunk-XO57OJUE.js";
14
14
  export {
15
15
  INSTALLATION_ERROR_SUFFIX,
16
16
  INSTALLATION_INSTALLED_SUFFIX,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stripe-experiment-sync",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "private": false,
5
5
  "description": "Stripe Sync Engine to sync Stripe data to Postgres",
6
6
  "type": "module",