stripe-experiment-sync 1.0.18 → 1.0.19

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/dist/index.d.ts CHANGED
@@ -157,12 +157,21 @@ declare class PostgresClient {
157
157
  status: string;
158
158
  processedCount: number;
159
159
  cursor: string | null;
160
+ pageCursor: string | null;
160
161
  } | null>;
161
162
  /**
162
163
  * Update progress for an object sync.
163
164
  * Also touches updated_at for stale detection.
164
165
  */
165
166
  incrementObjectProgress(accountId: string, runStartedAt: Date, object: string, count: number): Promise<void>;
167
+ /**
168
+ * Update the pagination page_cursor used for backfills using Stripe list calls.
169
+ */
170
+ updateObjectPageCursor(accountId: string, runStartedAt: Date, object: string, pageCursor: string | null): Promise<void>;
171
+ /**
172
+ * Clear the pagination page_cursor for an object sync.
173
+ */
174
+ clearObjectPageCursor(accountId: string, runStartedAt: Date, object: string): Promise<void>;
166
175
  /**
167
176
  * Update the cursor for an object sync.
168
177
  * Only updates if the new cursor is higher than the existing one (cursors should never decrease).
@@ -172,15 +181,20 @@ declare class PostgresClient {
172
181
  updateObjectCursor(accountId: string, runStartedAt: Date, object: string, cursor: string | null): Promise<void>;
173
182
  /**
174
183
  * Get the highest cursor from previous syncs for an object type.
175
- * This considers completed, error, AND running runs to ensure recovery syncs
176
- * don't re-process data that was already synced before a crash.
177
- * A 'running' status with a cursor means the process was killed mid-sync.
184
+ * Uses only completed object runs.
185
+ * - During the initial backfill we page through history, but we also update the cursor as we go.
186
+ * If we crash mid-backfill and reuse that cursor, we can accidentally switch into incremental mode
187
+ * too early and only ever fetch the newest page (breaking the historical backfill).
178
188
  *
179
189
  * Handles two cursor formats:
180
190
  * - Numeric: compared as bigint for correct ordering
181
191
  * - Composite cursors: compared as strings with COLLATE "C"
182
192
  */
183
193
  getLastCompletedCursor(accountId: string, object: string): Promise<string | null>;
194
+ /**
195
+ * Get the highest cursor from previous syncs for an object type, excluding the current run.
196
+ */
197
+ getLastCursorBeforeRun(accountId: string, object: string, runStartedAt: Date): Promise<string | null>;
184
198
  /**
185
199
  * Delete all sync runs and object runs for an account.
186
200
  * Useful for testing or resetting sync state.
@@ -587,6 +601,7 @@ declare class StripeSync {
587
601
  * ```
588
602
  */
589
603
  processNext(object: Exclude<SyncObject, 'all' | 'customer_with_entitlements'>, params?: ProcessNextParams): Promise<ProcessNextResult>;
604
+ private appendMigrationHint;
590
605
  /**
591
606
  * Get the database resource name for a SyncObject type
592
607
  */
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  createStripeWebSocketClient,
6
6
  hashApiKey,
7
7
  runMigrations
8
- } from "./chunk-K4JQHI7Y.js";
9
- import "./chunk-XO57OJUE.js";
8
+ } from "./chunk-XKBCLBFT.js";
9
+ import "./chunk-CMGFQCD7.js";
10
10
  export {
11
11
  PostgresClient,
12
12
  StripeSync,
@@ -0,0 +1,3 @@
1
+ -- Add page_cursor column for pagination state within a single sync run.
2
+ -- This is used to store the starting_after ID for backfills using Stripe list calls.
3
+ ALTER TABLE "stripe"."_sync_obj_runs" ADD COLUMN IF NOT EXISTS page_cursor text;
@@ -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.18",
57
+ version: "1.0.19",
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-M5TTM27L.js";
13
- import "../chunk-XO57OJUE.js";
12
+ } from "../chunk-4P6TAP7L.js";
13
+ import "../chunk-CMGFQCD7.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.18",
3
+ "version": "1.0.19",
4
4
  "private": false,
5
5
  "description": "Stripe Sync Engine to sync Stripe data to Postgres",
6
6
  "type": "module",