@expresscsv/sdk 0.1.20 → 0.1.22

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.mts CHANGED
@@ -1244,12 +1244,16 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1244
1244
  private debug;
1245
1245
  private importIdentifier;
1246
1246
  private sessionId;
1247
+ private currentSessionToken;
1248
+ private currentSessionTokenExpiresAt;
1249
+ private sessionTokenRefreshTimer;
1250
+ private sessionTokenRefreshPromise;
1247
1251
  private _destroyTimer;
1248
1252
  private _beforeUnloadHandler;
1249
- private widgetUrl;
1253
+ private importerUrl;
1250
1254
  private appUrl;
1251
- private widgetState;
1252
- private widgetMode;
1255
+ private importerState;
1256
+ private importerMode;
1253
1257
  private canRestart;
1254
1258
  private lastError;
1255
1259
  private openOptions;
@@ -1257,6 +1261,7 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1257
1261
  private initCompletePromise;
1258
1262
  private resolveInitComplete;
1259
1263
  private resolvedTemplateDownload;
1264
+ private importerStartupGeneration;
1260
1265
  constructor(options: SDKOptions<TSchema>);
1261
1266
  /**
1262
1267
  * Enhanced state management
@@ -1264,10 +1269,24 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1264
1269
  private setState;
1265
1270
  private updateDerivedState;
1266
1271
  private handleError;
1272
+ private sendImportProgress;
1267
1273
  private waitForEvent;
1274
+ private fetchImporterSessionToken;
1275
+ private updateSessionToken;
1276
+ private clearSessionTokenRefreshTimer;
1277
+ private scheduleSessionTokenRefresh;
1278
+ private ensureActiveSessionToken;
1279
+ private refreshSessionBoundToken;
1280
+ private beginImporterStartup;
1281
+ private cancelImporterStartup;
1282
+ private assertActiveImporterStartup;
1283
+ private withTimeout;
1284
+ private sendSessionDetailsToImporter;
1285
+ private sendStartupErrorToImporter;
1286
+ private bootstrapImporterSession;
1268
1287
  /**
1269
1288
  * Open the import flow with chunk-based data processing.
1270
- * Automatically opens the widget if not already open.
1289
+ * Automatically opens the importer if not already open.
1271
1290
  *
1272
1291
  * @param options Configuration including onData callback for processing chunks
1273
1292
  */
@@ -1282,11 +1301,6 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1282
1301
  * Chunks data using SDK-determined chunk size (independent of customer's chunkSize)
1283
1302
  */
1284
1303
  private deliverToWebhook;
1285
- /**
1286
- * Poll the delivery status endpoint until the delivery reaches a terminal state
1287
- * ('success' or 'failed'), or until the timeout is exceeded.
1288
- */
1289
- private pollDeliveryStatus;
1290
1304
  /**
1291
1305
  * Send a single chunk to backend webhook API with retry logic
1292
1306
  */
@@ -1312,7 +1326,7 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1312
1326
  private removeBeforeUnloadListener;
1313
1327
  private waitForIframeLoad;
1314
1328
  private setupConnectionAndInit;
1315
- openWidget(options?: {
1329
+ openImporter(options?: {
1316
1330
  reset?: boolean;
1317
1331
  }): Promise<void>;
1318
1332
  /**
@@ -1323,20 +1337,20 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1323
1337
  private createAndAppendIframe;
1324
1338
  private destroy;
1325
1339
  close(reason?: 'user_close' | 'cancel' | 'complete' | 'error'): Promise<void>;
1326
- private resetWidget;
1340
+ private resetImporter;
1327
1341
  restart(newOptions?: Partial<SDKOptions<TSchema>>): Promise<void>;
1328
- private handleWidgetClosed;
1342
+ private handleImporterClosed;
1329
1343
  private hideContainer;
1330
1344
  getConnectionStatus(): boolean;
1331
- getState(): WidgetState;
1332
- getMode(): WidgetMode;
1345
+ getState(): ImporterState;
1346
+ getMode(): ImporterMode;
1333
1347
  getIsReady(): boolean;
1334
1348
  getIsOpen(): boolean;
1335
1349
  getCanRestart(): boolean;
1336
1350
  getLastError(): Error | null;
1337
1351
  getStatus(): {
1338
- state: WidgetState;
1339
- mode: WidgetMode;
1352
+ state: ImporterState;
1353
+ mode: ImporterMode;
1340
1354
  isReady: boolean;
1341
1355
  isOpen: boolean;
1342
1356
  canRestart: boolean;
@@ -2866,7 +2880,7 @@ declare interface ExpressCSVLocale {
2866
2880
  nextDisabledReviewValidating: string;
2867
2881
  nextDisabledReviewInvalid: string;
2868
2882
  };
2869
- widget: {
2883
+ importer: {
2870
2884
  title: string;
2871
2885
  loading: string;
2872
2886
  closeConfirmTitle: string;
@@ -2875,7 +2889,6 @@ declare interface ExpressCSVLocale {
2875
2889
  closeConfirmContinue: string;
2876
2890
  errorTitle: string;
2877
2891
  startOver: string;
2878
- invalidPublishableKey: string;
2879
2892
  };
2880
2893
  sessionRecovery: {
2881
2894
  message: string;
@@ -2995,6 +3008,7 @@ declare interface ExpressCSVLocale {
2995
3008
  };
2996
3009
  review: {
2997
3010
  completing: string;
3011
+ processing: string;
2998
3012
  loading: string;
2999
3013
  title: string;
3000
3014
  subtitle: string;
@@ -3587,6 +3601,29 @@ export declare class ImportCancelledError extends Error {
3587
3601
  constructor(message?: string);
3588
3602
  }
3589
3603
 
3604
+ /**
3605
+ * Importer preload mode
3606
+ */
3607
+ export declare enum ImporterMode {
3608
+ NORMAL = "normal",
3609
+ PRELOAD = "preload"
3610
+ }
3611
+
3612
+ /**
3613
+ * Importer lifecycle state
3614
+ */
3615
+ export declare enum ImporterState {
3616
+ UNINITIALIZED = "uninitialized",
3617
+ INITIALIZING = "initializing",
3618
+ READY = "ready",
3619
+ OPENING = "opening",
3620
+ OPEN = "open",
3621
+ CLOSING = "closing",
3622
+ RESETTING = "resetting",
3623
+ ERROR = "error",
3624
+ DESTROYED = "destroyed"
3625
+ }
3626
+
3590
3627
  export declare type Infer<T extends ExType<unknown, ExBaseDef, unknown>> = T extends ExType<infer Output, ExBaseDef, unknown> ? Output : never;
3591
3628
 
3592
3629
  export declare type InferCSVImporter<TSchema extends ExType<unknown, ExBaseDef, unknown>> = CSVImporter<TSchema>;
@@ -3611,12 +3648,12 @@ export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, '
3611
3648
  onCancel?: () => void;
3612
3649
  /** Called when an error occurs */
3613
3650
  onError?: (error: Error) => void;
3614
- /** Called when the widget opens */
3615
- onWidgetOpen?: () => void;
3651
+ /** Called when the importer opens */
3652
+ onImporterOpen?: () => void;
3653
+ /** Called when the importer closes */
3654
+ onImporterClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
3616
3655
  /** Called when the step changes in the wizard */
3617
3656
  onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
3618
- /** Called when the widget closes */
3619
- onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
3620
3657
  };
3621
3658
 
3622
3659
  declare type PhoneNumberFormat = 'international' | 'national' | 'both';
@@ -3765,7 +3802,7 @@ declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Excl
3765
3802
 
3766
3803
  export declare interface SDKOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
3767
3804
  schema: TSchema;
3768
- publishableKey: string;
3805
+ getSessionToken: () => Promise<string>;
3769
3806
  importIdentifier: string;
3770
3807
  title?: string;
3771
3808
  debug?: boolean;
@@ -3858,7 +3895,7 @@ export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBa
3858
3895
 
3859
3896
  /**
3860
3897
  * A branded string type for locale entries that require interpolation via `{variable}` syntax.
3861
- * Widget code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
3898
+ * Importer code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
3862
3899
  * The generic `TVars` encodes the expected variable names so `t()` enforces the correct vars argument.
3863
3900
  */
3864
3901
  declare type TemplateString<TVars extends string = string> = string & {
@@ -3910,34 +3947,11 @@ export declare interface WebhookConfig {
3910
3947
  * Whether to wait for the delivery service to confirm the webhook was
3911
3948
  * successfully received before considering the import complete.
3912
3949
  * When false, the import completes as soon as all chunks are queued.
3913
- * Default: true
3950
+ * Default: false
3914
3951
  */
3915
3952
  awaitWebhookArrival?: boolean;
3916
3953
  }
3917
3954
 
3918
- /**
3919
- * Widget mode enumeration
3920
- */
3921
- export declare enum WidgetMode {
3922
- NORMAL = "normal",
3923
- PRELOAD = "preload"
3924
- }
3925
-
3926
- /**
3927
- * Widget state enumeration for consistent state management
3928
- */
3929
- export declare enum WidgetState {
3930
- UNINITIALIZED = "uninitialized",
3931
- INITIALIZING = "initializing",
3932
- READY = "ready",
3933
- OPENING = "opening",
3934
- OPEN = "open",
3935
- CLOSING = "closing",
3936
- RESETTING = "resetting",
3937
- ERROR = "error",
3938
- DESTROYED = "destroyed"
3939
- }
3940
-
3941
3955
  export declare const x: {
3942
3956
  string: typeof ExString.create;
3943
3957
  number: typeof ExNumber.create;
package/dist/index.d.ts CHANGED
@@ -1244,12 +1244,16 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1244
1244
  private debug;
1245
1245
  private importIdentifier;
1246
1246
  private sessionId;
1247
+ private currentSessionToken;
1248
+ private currentSessionTokenExpiresAt;
1249
+ private sessionTokenRefreshTimer;
1250
+ private sessionTokenRefreshPromise;
1247
1251
  private _destroyTimer;
1248
1252
  private _beforeUnloadHandler;
1249
- private widgetUrl;
1253
+ private importerUrl;
1250
1254
  private appUrl;
1251
- private widgetState;
1252
- private widgetMode;
1255
+ private importerState;
1256
+ private importerMode;
1253
1257
  private canRestart;
1254
1258
  private lastError;
1255
1259
  private openOptions;
@@ -1257,6 +1261,7 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1257
1261
  private initCompletePromise;
1258
1262
  private resolveInitComplete;
1259
1263
  private resolvedTemplateDownload;
1264
+ private importerStartupGeneration;
1260
1265
  constructor(options: SDKOptions<TSchema>);
1261
1266
  /**
1262
1267
  * Enhanced state management
@@ -1264,10 +1269,24 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1264
1269
  private setState;
1265
1270
  private updateDerivedState;
1266
1271
  private handleError;
1272
+ private sendImportProgress;
1267
1273
  private waitForEvent;
1274
+ private fetchImporterSessionToken;
1275
+ private updateSessionToken;
1276
+ private clearSessionTokenRefreshTimer;
1277
+ private scheduleSessionTokenRefresh;
1278
+ private ensureActiveSessionToken;
1279
+ private refreshSessionBoundToken;
1280
+ private beginImporterStartup;
1281
+ private cancelImporterStartup;
1282
+ private assertActiveImporterStartup;
1283
+ private withTimeout;
1284
+ private sendSessionDetailsToImporter;
1285
+ private sendStartupErrorToImporter;
1286
+ private bootstrapImporterSession;
1268
1287
  /**
1269
1288
  * Open the import flow with chunk-based data processing.
1270
- * Automatically opens the widget if not already open.
1289
+ * Automatically opens the importer if not already open.
1271
1290
  *
1272
1291
  * @param options Configuration including onData callback for processing chunks
1273
1292
  */
@@ -1282,11 +1301,6 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1282
1301
  * Chunks data using SDK-determined chunk size (independent of customer's chunkSize)
1283
1302
  */
1284
1303
  private deliverToWebhook;
1285
- /**
1286
- * Poll the delivery status endpoint until the delivery reaches a terminal state
1287
- * ('success' or 'failed'), or until the timeout is exceeded.
1288
- */
1289
- private pollDeliveryStatus;
1290
1304
  /**
1291
1305
  * Send a single chunk to backend webhook API with retry logic
1292
1306
  */
@@ -1312,7 +1326,7 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1312
1326
  private removeBeforeUnloadListener;
1313
1327
  private waitForIframeLoad;
1314
1328
  private setupConnectionAndInit;
1315
- openWidget(options?: {
1329
+ openImporter(options?: {
1316
1330
  reset?: boolean;
1317
1331
  }): Promise<void>;
1318
1332
  /**
@@ -1323,20 +1337,20 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
1323
1337
  private createAndAppendIframe;
1324
1338
  private destroy;
1325
1339
  close(reason?: 'user_close' | 'cancel' | 'complete' | 'error'): Promise<void>;
1326
- private resetWidget;
1340
+ private resetImporter;
1327
1341
  restart(newOptions?: Partial<SDKOptions<TSchema>>): Promise<void>;
1328
- private handleWidgetClosed;
1342
+ private handleImporterClosed;
1329
1343
  private hideContainer;
1330
1344
  getConnectionStatus(): boolean;
1331
- getState(): WidgetState;
1332
- getMode(): WidgetMode;
1345
+ getState(): ImporterState;
1346
+ getMode(): ImporterMode;
1333
1347
  getIsReady(): boolean;
1334
1348
  getIsOpen(): boolean;
1335
1349
  getCanRestart(): boolean;
1336
1350
  getLastError(): Error | null;
1337
1351
  getStatus(): {
1338
- state: WidgetState;
1339
- mode: WidgetMode;
1352
+ state: ImporterState;
1353
+ mode: ImporterMode;
1340
1354
  isReady: boolean;
1341
1355
  isOpen: boolean;
1342
1356
  canRestart: boolean;
@@ -2866,7 +2880,7 @@ declare interface ExpressCSVLocale {
2866
2880
  nextDisabledReviewValidating: string;
2867
2881
  nextDisabledReviewInvalid: string;
2868
2882
  };
2869
- widget: {
2883
+ importer: {
2870
2884
  title: string;
2871
2885
  loading: string;
2872
2886
  closeConfirmTitle: string;
@@ -2875,7 +2889,6 @@ declare interface ExpressCSVLocale {
2875
2889
  closeConfirmContinue: string;
2876
2890
  errorTitle: string;
2877
2891
  startOver: string;
2878
- invalidPublishableKey: string;
2879
2892
  };
2880
2893
  sessionRecovery: {
2881
2894
  message: string;
@@ -2995,6 +3008,7 @@ declare interface ExpressCSVLocale {
2995
3008
  };
2996
3009
  review: {
2997
3010
  completing: string;
3011
+ processing: string;
2998
3012
  loading: string;
2999
3013
  title: string;
3000
3014
  subtitle: string;
@@ -3587,6 +3601,29 @@ export declare class ImportCancelledError extends Error {
3587
3601
  constructor(message?: string);
3588
3602
  }
3589
3603
 
3604
+ /**
3605
+ * Importer preload mode
3606
+ */
3607
+ export declare enum ImporterMode {
3608
+ NORMAL = "normal",
3609
+ PRELOAD = "preload"
3610
+ }
3611
+
3612
+ /**
3613
+ * Importer lifecycle state
3614
+ */
3615
+ export declare enum ImporterState {
3616
+ UNINITIALIZED = "uninitialized",
3617
+ INITIALIZING = "initializing",
3618
+ READY = "ready",
3619
+ OPENING = "opening",
3620
+ OPEN = "open",
3621
+ CLOSING = "closing",
3622
+ RESETTING = "resetting",
3623
+ ERROR = "error",
3624
+ DESTROYED = "destroyed"
3625
+ }
3626
+
3590
3627
  export declare type Infer<T extends ExType<unknown, ExBaseDef, unknown>> = T extends ExType<infer Output, ExBaseDef, unknown> ? Output : never;
3591
3628
 
3592
3629
  export declare type InferCSVImporter<TSchema extends ExType<unknown, ExBaseDef, unknown>> = CSVImporter<TSchema>;
@@ -3611,12 +3648,12 @@ export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, '
3611
3648
  onCancel?: () => void;
3612
3649
  /** Called when an error occurs */
3613
3650
  onError?: (error: Error) => void;
3614
- /** Called when the widget opens */
3615
- onWidgetOpen?: () => void;
3651
+ /** Called when the importer opens */
3652
+ onImporterOpen?: () => void;
3653
+ /** Called when the importer closes */
3654
+ onImporterClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
3616
3655
  /** Called when the step changes in the wizard */
3617
3656
  onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
3618
- /** Called when the widget closes */
3619
- onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
3620
3657
  };
3621
3658
 
3622
3659
  declare type PhoneNumberFormat = 'international' | 'national' | 'both';
@@ -3765,7 +3802,7 @@ declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Excl
3765
3802
 
3766
3803
  export declare interface SDKOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
3767
3804
  schema: TSchema;
3768
- publishableKey: string;
3805
+ getSessionToken: () => Promise<string>;
3769
3806
  importIdentifier: string;
3770
3807
  title?: string;
3771
3808
  debug?: boolean;
@@ -3858,7 +3895,7 @@ export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBa
3858
3895
 
3859
3896
  /**
3860
3897
  * A branded string type for locale entries that require interpolation via `{variable}` syntax.
3861
- * Widget code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
3898
+ * Importer code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
3862
3899
  * The generic `TVars` encodes the expected variable names so `t()` enforces the correct vars argument.
3863
3900
  */
3864
3901
  declare type TemplateString<TVars extends string = string> = string & {
@@ -3910,34 +3947,11 @@ export declare interface WebhookConfig {
3910
3947
  * Whether to wait for the delivery service to confirm the webhook was
3911
3948
  * successfully received before considering the import complete.
3912
3949
  * When false, the import completes as soon as all chunks are queued.
3913
- * Default: true
3950
+ * Default: false
3914
3951
  */
3915
3952
  awaitWebhookArrival?: boolean;
3916
3953
  }
3917
3954
 
3918
- /**
3919
- * Widget mode enumeration
3920
- */
3921
- export declare enum WidgetMode {
3922
- NORMAL = "normal",
3923
- PRELOAD = "preload"
3924
- }
3925
-
3926
- /**
3927
- * Widget state enumeration for consistent state management
3928
- */
3929
- export declare enum WidgetState {
3930
- UNINITIALIZED = "uninitialized",
3931
- INITIALIZING = "initializing",
3932
- READY = "ready",
3933
- OPENING = "opening",
3934
- OPEN = "open",
3935
- CLOSING = "closing",
3936
- RESETTING = "resetting",
3937
- ERROR = "error",
3938
- DESTROYED = "destroyed"
3939
- }
3940
-
3941
3955
  export declare const x: {
3942
3956
  string: typeof ExString.create;
3943
3957
  number: typeof ExNumber.create;