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/dist/index.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ declare class PostgresClient {
|
|
|
105
105
|
} | null>;
|
|
106
106
|
/**
|
|
107
107
|
* Get sync run config (for concurrency control).
|
|
108
|
-
* Status is derived from
|
|
108
|
+
* Status is derived from sync_runs view.
|
|
109
109
|
*/
|
|
110
110
|
getSyncRun(accountId: string, runStartedAt: Date): Promise<{
|
|
111
111
|
accountId: string;
|
|
@@ -335,6 +335,13 @@ interface ProcessNextParams extends SyncParams {
|
|
|
335
335
|
triggeredBy?: string;
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Identifies a specific sync run.
|
|
340
|
+
*/
|
|
341
|
+
type RunKey = {
|
|
342
|
+
accountId: string;
|
|
343
|
+
runStartedAt: Date;
|
|
344
|
+
};
|
|
338
345
|
declare class StripeSync {
|
|
339
346
|
private config;
|
|
340
347
|
stripe: Stripe;
|
|
@@ -470,6 +477,20 @@ declare class StripeSync {
|
|
|
470
477
|
* @returns Sync result with count of synced items
|
|
471
478
|
*/
|
|
472
479
|
private processObjectUntilDone;
|
|
480
|
+
/**
|
|
481
|
+
* Join existing sync run or create a new one.
|
|
482
|
+
* Returns sync run key and list of supported objects to sync.
|
|
483
|
+
*
|
|
484
|
+
* Cooperative behavior: If a sync run already exists, joins it instead of failing.
|
|
485
|
+
* This is used by workers and background processes that should cooperate.
|
|
486
|
+
*
|
|
487
|
+
* @param triggeredBy - What triggered this sync (for observability)
|
|
488
|
+
* @returns Run key and list of objects to sync
|
|
489
|
+
*/
|
|
490
|
+
joinOrCreateSyncRun(triggeredBy?: string): Promise<{
|
|
491
|
+
runKey: RunKey;
|
|
492
|
+
objects: Exclude<SyncObject, 'all' | 'customer_with_entitlements'>[];
|
|
493
|
+
}>;
|
|
473
494
|
processUntilDone(params?: SyncParams): Promise<SyncBackfill>;
|
|
474
495
|
/**
|
|
475
496
|
* Internal implementation of processUntilDone with an existing run.
|
|
@@ -600,6 +621,37 @@ declare function runMigrations(config: MigrationConfig): Promise<void>;
|
|
|
600
621
|
*/
|
|
601
622
|
declare function hashApiKey(apiKey: string): string;
|
|
602
623
|
|
|
624
|
+
interface WebhookProcessingResult {
|
|
625
|
+
status: number;
|
|
626
|
+
databaseUrl: string;
|
|
627
|
+
event_type?: string;
|
|
628
|
+
event_id?: string;
|
|
629
|
+
error?: string;
|
|
630
|
+
}
|
|
631
|
+
interface StripeWebSocketOptions {
|
|
632
|
+
stripeApiKey: string;
|
|
633
|
+
onEvent: (event: StripeWebhookEvent) => Promise<WebhookProcessingResult | void> | WebhookProcessingResult | void;
|
|
634
|
+
onReady?: (secret: string) => void;
|
|
635
|
+
onError?: (error: Error) => void;
|
|
636
|
+
onClose?: (code: number, reason: string) => void;
|
|
637
|
+
}
|
|
638
|
+
interface StripeWebSocketClient {
|
|
639
|
+
close: () => void;
|
|
640
|
+
isConnected: () => boolean;
|
|
641
|
+
}
|
|
642
|
+
interface StripeWebhookEvent {
|
|
643
|
+
type: string;
|
|
644
|
+
webhook_id: string;
|
|
645
|
+
webhook_conversation_id: string;
|
|
646
|
+
event_payload: string;
|
|
647
|
+
http_headers: Record<string, string>;
|
|
648
|
+
endpoint: {
|
|
649
|
+
url: string;
|
|
650
|
+
status: string;
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
declare function createStripeWebSocketClient(options: StripeWebSocketOptions): Promise<StripeWebSocketClient>;
|
|
654
|
+
|
|
603
655
|
declare const VERSION: string;
|
|
604
656
|
|
|
605
|
-
export { type Logger, PostgresClient, type ProcessNextParams, type ProcessNextResult, type RevalidateEntity, StripeSync, type StripeSyncConfig, type Sync, type SyncBackfill, type SyncEntitlementsParams, type SyncFeaturesParams, type SyncObject, type SyncParams, VERSION, hashApiKey, runMigrations };
|
|
657
|
+
export { type Logger, PostgresClient, type ProcessNextParams, type ProcessNextResult, type RevalidateEntity, StripeSync, type StripeSyncConfig, type StripeWebSocketClient, type StripeWebSocketOptions, type StripeWebhookEvent, type Sync, type SyncBackfill, type SyncEntitlementsParams, type SyncFeaturesParams, type SyncObject, type SyncParams, VERSION, type WebhookProcessingResult, createStripeWebSocketClient, hashApiKey, runMigrations };
|