@expresscsv/react 0.1.21 → 0.1.23

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
@@ -1878,6 +1878,13 @@ declare const CurrencyCodes: readonly [{
1878
1878
  readonly numeric: "932";
1879
1879
  }];
1880
1880
 
1881
+ export declare type CustomStorageOptions = {
1882
+ type: 'custom';
1883
+ get: (key: StorageKey) => Promise<StoredSession | null>;
1884
+ set: (key: StorageKey, value: StoredSession) => Promise<void>;
1885
+ remove: (key: StorageKey) => Promise<void>;
1886
+ };
1887
+
1881
1888
  declare interface DatetimeOptions {
1882
1889
  message?: string;
1883
1890
  }
@@ -1886,19 +1893,9 @@ export declare type DeepPartial<T> = {
1886
1893
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
1887
1894
  };
1888
1895
 
1889
- /**
1890
- * Delivery options - requires at least one of onData or webhook
1891
- */
1892
- export declare type DeliveryOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'>;
1893
-
1894
- /**
1895
- * Base delivery options - at least one must be provided
1896
- */
1897
- declare interface DeliveryOptionsBase<T> {
1898
- /** Local callback for processing chunks */
1899
- onData?: (chunk: RecordsChunk<T>, next: () => void) => void | Promise<void>;
1900
- /** Webhook configuration for remote delivery */
1901
- webhook?: WebhookConfig;
1896
+ export declare interface DeliveryOptions<T> {
1897
+ /** Callback for processing delivered chunks */
1898
+ onData: (chunk: RecordsChunk<T>, next: () => void) => void | Promise<void>;
1902
1899
  }
1903
1900
 
1904
1901
  /**
@@ -2754,7 +2751,7 @@ declare interface ExpressCSVLocale {
2754
2751
  nextDisabledReviewValidating: string;
2755
2752
  nextDisabledReviewInvalid: string;
2756
2753
  };
2757
- widget: {
2754
+ importer: {
2758
2755
  title: string;
2759
2756
  loading: string;
2760
2757
  closeConfirmTitle: string;
@@ -2763,7 +2760,6 @@ declare interface ExpressCSVLocale {
2763
2760
  closeConfirmContinue: string;
2764
2761
  errorTitle: string;
2765
2762
  startOver: string;
2766
- invalidPublishableKey: string;
2767
2763
  };
2768
2764
  sessionRecovery: {
2769
2765
  message: string;
@@ -3476,10 +3472,42 @@ export declare class ImportCancelledError extends Error {
3476
3472
  constructor(message?: string);
3477
3473
  }
3478
3474
 
3475
+ /**
3476
+ * Importer preload mode
3477
+ */
3478
+ export declare enum ImporterMode {
3479
+ NORMAL = "normal",
3480
+ PRELOAD = "preload"
3481
+ }
3482
+
3483
+ /**
3484
+ * Importer lifecycle state
3485
+ */
3486
+ export declare enum ImporterState {
3487
+ UNINITIALIZED = "uninitialized",
3488
+ INITIALIZING = "initializing",
3489
+ READY = "ready",
3490
+ OPENING = "opening",
3491
+ OPEN = "open",
3492
+ CLOSING = "closing",
3493
+ RESETTING = "resetting",
3494
+ ERROR = "error",
3495
+ DESTROYED = "destroyed"
3496
+ }
3497
+
3498
+ export declare interface ImportSessionContext {
3499
+ /** Generated session ID for the current import run */
3500
+ sessionId: string;
3501
+ }
3502
+
3479
3503
  export declare type Infer<T extends ExType<unknown, ExBaseDef, unknown>> = T extends ExType<infer Output, ExBaseDef, unknown> ? Output : never;
3480
3504
 
3481
3505
  declare type IPAddressVersion = 'v4' | 'v6' | 'all';
3482
3506
 
3507
+ export declare type LocalStorageOptions = {
3508
+ type: 'local';
3509
+ };
3510
+
3483
3511
  declare interface MultiselectOptions {
3484
3512
  enforceCaseSensitiveMatch?: boolean;
3485
3513
  message?: string;
@@ -3487,23 +3515,34 @@ declare interface MultiselectOptions {
3487
3515
 
3488
3516
  /**
3489
3517
  * Options for the open() method
3490
- * Requires at least one of onData or webhook for delivery
3518
+ * Requires an onData callback for delivery
3491
3519
  */
3492
- export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'> & {
3520
+ export declare type OpenOptions<T> = DeliveryOptions<T> & {
3493
3521
  /** Number of records per chunk (default: 1000) */
3494
3522
  chunkSize?: number;
3495
3523
  /** Called when all chunks have been processed */
3496
- onComplete?: () => void;
3524
+ onComplete?: (context: ImportSessionContext) => void;
3497
3525
  /** Called when the user cancels the import */
3498
- onCancel?: () => void;
3526
+ onCancel?: (context: ImportSessionContext) => void;
3499
3527
  /** Called when an error occurs */
3500
- onError?: (error: Error) => void;
3501
- /** Called when the widget opens */
3502
- onWidgetOpen?: () => void;
3528
+ onError?: (error: Error, context: ImportSessionContext) => void;
3529
+ /** Called when the importer opens */
3530
+ onImporterOpen?: () => void;
3531
+ /** Called when the importer closes */
3532
+ onImporterClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
3503
3533
  /** Called when the step changes in the wizard */
3504
3534
  onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
3505
- /** Called when the widget closes */
3506
- onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
3535
+ };
3536
+
3537
+ declare interface PersistedImportSessionData {
3538
+ data: PersistedImportSessionPayload;
3539
+ }
3540
+
3541
+ declare type PersistedImportSessionKey = string;
3542
+
3543
+ declare type PersistedImportSessionPayload = {
3544
+ rowData: Record<string, unknown>[];
3545
+ columnKeys: string[];
3507
3546
  };
3508
3547
 
3509
3548
  declare type PhoneNumberFormat = 'international' | 'national' | 'both';
@@ -3612,6 +3651,10 @@ export declare interface RecordsChunk<T> {
3612
3651
  currentChunkIndex: number;
3613
3652
  /** Total number of records across all chunks */
3614
3653
  totalRecords: number;
3654
+ /** Generated session ID for the current import run */
3655
+ sessionId: string;
3656
+ /** Stable per-chunk idempotency key */
3657
+ chunkIdempotencyKey: string;
3615
3658
  }
3616
3659
 
3617
3660
  declare type RefineBatchResultItem = {
@@ -3643,13 +3686,6 @@ declare type RefineResultItem = {
3643
3686
  };
3644
3687
  };
3645
3688
 
3646
- /**
3647
- * Type helper that requires at least one of the specified keys to be present
3648
- */
3649
- declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
3650
- [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
3651
- }[Keys];
3652
-
3653
3689
  declare interface SelectOption<TValue extends string | number = string | number> {
3654
3690
  label: string;
3655
3691
  value: TValue;
@@ -3662,6 +3698,14 @@ declare interface SelectOptions {
3662
3698
  message?: string;
3663
3699
  }
3664
3700
 
3701
+ export declare type StorageKey = PersistedImportSessionKey;
3702
+
3703
+ export declare type StorageOptions = LocalStorageOptions | CustomStorageOptions;
3704
+
3705
+ export declare type StoredSession = PersistedImportSessionData;
3706
+
3707
+ export declare type StoredSessionData = PersistedImportSessionPayload;
3708
+
3665
3709
  declare type StripBrand<T> = {
3666
3710
  [K in keyof T]: T[K] extends TemplateString<string> ? string : T[K] extends object ? StripBrand<T[K]> : T[K];
3667
3711
  };
@@ -3726,7 +3770,7 @@ export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBa
3726
3770
 
3727
3771
  /**
3728
3772
  * A branded string type for locale entries that require interpolation via `{variable}` syntax.
3729
- * Widget code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
3773
+ * Importer code cannot render a `TemplateString` directly in JSX — it must go through the `t()` function.
3730
3774
  * The generic `TVars` encodes the expected variable names so `t()` enforces the correct vars argument.
3731
3775
  */
3732
3776
  declare type TemplateString<TVars extends string = string> = string & {
@@ -3750,9 +3794,9 @@ declare interface URLOptions {
3750
3794
  message?: string;
3751
3795
  }
3752
3796
 
3753
- export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, publishableKey, debug, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, disableStatusStep, }: UseExpressCSVOptions<TSchema>): {
3797
+ export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, getSessionToken, debug, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, aiColumnMatching, aiTransform, templateDownload, storage, locale, disableStatusStep, }: UseExpressCSVOptions<TSchema>): {
3754
3798
  open: (options: OpenOptions<Infer<TSchema>>) => void;
3755
- widgetState: WidgetState;
3799
+ importerState: ImporterState;
3756
3800
  isInitialising: boolean;
3757
3801
  isOpen: boolean;
3758
3802
  };
@@ -3761,7 +3805,7 @@ export declare interface UseExpressCSVOptions<TSchema extends ExType<unknown, Ex
3761
3805
  schema: TSchema;
3762
3806
  title?: string;
3763
3807
  importIdentifier: string;
3764
- publishableKey: string;
3808
+ getSessionToken: () => Promise<string>;
3765
3809
  debug?: boolean;
3766
3810
  preload?: boolean;
3767
3811
  theme?: ECSVTheme;
@@ -3770,8 +3814,10 @@ export declare interface UseExpressCSVOptions<TSchema extends ExType<unknown, Ex
3770
3814
  fonts?: Record<string, ECSVFontSource>;
3771
3815
  stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
3772
3816
  previewSchemaBeforeUpload?: boolean;
3817
+ aiColumnMatching?: boolean;
3818
+ aiTransform?: boolean;
3773
3819
  templateDownload?: TemplateDownloadOptions<TSchema>;
3774
- saveSession?: boolean;
3820
+ storage?: StorageOptions;
3775
3821
  locale?: DeepPartial<ExpressCSVLocaleInput>;
3776
3822
  disableStatusStep?: boolean;
3777
3823
  }
@@ -3784,54 +3830,6 @@ declare interface ValidatorCheck {
3784
3830
  message?: string;
3785
3831
  }
3786
3832
 
3787
- /**
3788
- * Webhook configuration for remote delivery of results
3789
- */
3790
- export declare interface WebhookConfig {
3791
- /** The URL to send webhook requests to */
3792
- url: string;
3793
- /** Optional HTTP headers to include in the request */
3794
- headers?: Record<string, string>;
3795
- /** HTTP method to use (default: 'POST') */
3796
- method?: 'POST' | 'PUT' | 'PATCH';
3797
- /** Request timeout in milliseconds (default: 30000) */
3798
- timeout?: number;
3799
- /** Number of retry attempts on failure (default: 0) */
3800
- retries?: number;
3801
- /** Arbitrary developer-provided metadata */
3802
- metadata?: Record<string, unknown>;
3803
- /**
3804
- * Whether to wait for the delivery service to confirm the webhook was
3805
- * successfully received before considering the import complete.
3806
- * When false, the import completes as soon as all chunks are queued.
3807
- * Default: false
3808
- */
3809
- awaitWebhookArrival?: boolean;
3810
- }
3811
-
3812
- /**
3813
- * Widget mode enumeration
3814
- */
3815
- export declare enum WidgetMode {
3816
- NORMAL = "normal",
3817
- PRELOAD = "preload"
3818
- }
3819
-
3820
- /**
3821
- * Widget state enumeration for consistent state management
3822
- */
3823
- export declare enum WidgetState {
3824
- UNINITIALIZED = "uninitialized",
3825
- INITIALIZING = "initializing",
3826
- READY = "ready",
3827
- OPENING = "opening",
3828
- OPEN = "open",
3829
- CLOSING = "closing",
3830
- RESETTING = "resetting",
3831
- ERROR = "error",
3832
- DESTROYED = "destroyed"
3833
- }
3834
-
3835
3833
  export declare const x: {
3836
3834
  string: typeof ExString.create;
3837
3835
  number: typeof ExNumber.create;