@expresscsv/react 0.1.22 → 0.1.24

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
@@ -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
  /**
@@ -3498,10 +3495,19 @@ export declare enum ImporterState {
3498
3495
  DESTROYED = "destroyed"
3499
3496
  }
3500
3497
 
3498
+ export declare interface ImportSessionContext {
3499
+ /** Generated session ID for the current import run */
3500
+ sessionId: string;
3501
+ }
3502
+
3501
3503
  export declare type Infer<T extends ExType<unknown, ExBaseDef, unknown>> = T extends ExType<infer Output, ExBaseDef, unknown> ? Output : never;
3502
3504
 
3503
3505
  declare type IPAddressVersion = 'v4' | 'v6' | 'all';
3504
3506
 
3507
+ export declare type LocalStorageOptions = {
3508
+ type: 'local';
3509
+ };
3510
+
3505
3511
  declare interface MultiselectOptions {
3506
3512
  enforceCaseSensitiveMatch?: boolean;
3507
3513
  message?: string;
@@ -3509,17 +3515,17 @@ declare interface MultiselectOptions {
3509
3515
 
3510
3516
  /**
3511
3517
  * Options for the open() method
3512
- * Requires at least one of onData or webhook for delivery
3518
+ * Requires an onData callback for delivery
3513
3519
  */
3514
- export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'> & {
3520
+ export declare type OpenOptions<T> = DeliveryOptions<T> & {
3515
3521
  /** Number of records per chunk (default: 1000) */
3516
3522
  chunkSize?: number;
3517
3523
  /** Called when all chunks have been processed */
3518
- onComplete?: () => void;
3524
+ onComplete?: (context: ImportSessionContext) => void;
3519
3525
  /** Called when the user cancels the import */
3520
- onCancel?: () => void;
3526
+ onCancel?: (context: ImportSessionContext) => void;
3521
3527
  /** Called when an error occurs */
3522
- onError?: (error: Error) => void;
3528
+ onError?: (error: Error, context: ImportSessionContext) => void;
3523
3529
  /** Called when the importer opens */
3524
3530
  onImporterOpen?: () => void;
3525
3531
  /** Called when the importer closes */
@@ -3528,6 +3534,17 @@ export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, '
3528
3534
  onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
3529
3535
  };
3530
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[];
3546
+ };
3547
+
3531
3548
  declare type PhoneNumberFormat = 'international' | 'national' | 'both';
3532
3549
 
3533
3550
  declare type PhoneNumberOutput = 'e164' | 'formatted' | 'digits';
@@ -3634,6 +3651,10 @@ export declare interface RecordsChunk<T> {
3634
3651
  currentChunkIndex: number;
3635
3652
  /** Total number of records across all chunks */
3636
3653
  totalRecords: number;
3654
+ /** Generated session ID for the current import run */
3655
+ sessionId: string;
3656
+ /** Stable per-chunk idempotency key */
3657
+ chunkIdempotencyKey: string;
3637
3658
  }
3638
3659
 
3639
3660
  declare type RefineBatchResultItem = {
@@ -3665,13 +3686,6 @@ declare type RefineResultItem = {
3665
3686
  };
3666
3687
  };
3667
3688
 
3668
- /**
3669
- * Type helper that requires at least one of the specified keys to be present
3670
- */
3671
- declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
3672
- [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
3673
- }[Keys];
3674
-
3675
3689
  declare interface SelectOption<TValue extends string | number = string | number> {
3676
3690
  label: string;
3677
3691
  value: TValue;
@@ -3684,6 +3698,14 @@ declare interface SelectOptions {
3684
3698
  message?: string;
3685
3699
  }
3686
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
+
3687
3709
  declare type StripBrand<T> = {
3688
3710
  [K in keyof T]: T[K] extends TemplateString<string> ? string : T[K] extends object ? StripBrand<T[K]> : T[K];
3689
3711
  };
@@ -3772,7 +3794,7 @@ declare interface URLOptions {
3772
3794
  message?: string;
3773
3795
  }
3774
3796
 
3775
- export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, getSessionToken, 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>): {
3776
3798
  open: (options: OpenOptions<Infer<TSchema>>) => void;
3777
3799
  importerState: ImporterState;
3778
3800
  isInitialising: boolean;
@@ -3792,8 +3814,10 @@ export declare interface UseExpressCSVOptions<TSchema extends ExType<unknown, Ex
3792
3814
  fonts?: Record<string, ECSVFontSource>;
3793
3815
  stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
3794
3816
  previewSchemaBeforeUpload?: boolean;
3817
+ aiColumnMatching?: boolean;
3818
+ aiTransform?: boolean;
3795
3819
  templateDownload?: TemplateDownloadOptions<TSchema>;
3796
- saveSession?: boolean;
3820
+ storage?: StorageOptions;
3797
3821
  locale?: DeepPartial<ExpressCSVLocaleInput>;
3798
3822
  disableStatusStep?: boolean;
3799
3823
  }
@@ -3806,31 +3830,6 @@ declare interface ValidatorCheck {
3806
3830
  message?: string;
3807
3831
  }
3808
3832
 
3809
- /**
3810
- * Webhook configuration for remote delivery of results
3811
- */
3812
- export declare interface WebhookConfig {
3813
- /** The URL to send webhook requests to */
3814
- url: string;
3815
- /** Optional HTTP headers to include in the request */
3816
- headers?: Record<string, string>;
3817
- /** HTTP method to use (default: 'POST') */
3818
- method?: 'POST' | 'PUT' | 'PATCH';
3819
- /** Request timeout in milliseconds (default: 30000) */
3820
- timeout?: number;
3821
- /** Number of retry attempts on failure (default: 0) */
3822
- retries?: number;
3823
- /** Arbitrary developer-provided metadata */
3824
- metadata?: Record<string, unknown>;
3825
- /**
3826
- * Whether to wait for the delivery service to confirm the webhook was
3827
- * successfully received before considering the import complete.
3828
- * When false, the import completes as soon as all chunks are queued.
3829
- * Default: false
3830
- */
3831
- awaitWebhookArrival?: boolean;
3832
- }
3833
-
3834
3833
  export declare const x: {
3835
3834
  string: typeof ExString.create;
3836
3835
  number: typeof ExNumber.create;
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
  /**
@@ -3498,10 +3495,19 @@ export declare enum ImporterState {
3498
3495
  DESTROYED = "destroyed"
3499
3496
  }
3500
3497
 
3498
+ export declare interface ImportSessionContext {
3499
+ /** Generated session ID for the current import run */
3500
+ sessionId: string;
3501
+ }
3502
+
3501
3503
  export declare type Infer<T extends ExType<unknown, ExBaseDef, unknown>> = T extends ExType<infer Output, ExBaseDef, unknown> ? Output : never;
3502
3504
 
3503
3505
  declare type IPAddressVersion = 'v4' | 'v6' | 'all';
3504
3506
 
3507
+ export declare type LocalStorageOptions = {
3508
+ type: 'local';
3509
+ };
3510
+
3505
3511
  declare interface MultiselectOptions {
3506
3512
  enforceCaseSensitiveMatch?: boolean;
3507
3513
  message?: string;
@@ -3509,17 +3515,17 @@ declare interface MultiselectOptions {
3509
3515
 
3510
3516
  /**
3511
3517
  * Options for the open() method
3512
- * Requires at least one of onData or webhook for delivery
3518
+ * Requires an onData callback for delivery
3513
3519
  */
3514
- export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'> & {
3520
+ export declare type OpenOptions<T> = DeliveryOptions<T> & {
3515
3521
  /** Number of records per chunk (default: 1000) */
3516
3522
  chunkSize?: number;
3517
3523
  /** Called when all chunks have been processed */
3518
- onComplete?: () => void;
3524
+ onComplete?: (context: ImportSessionContext) => void;
3519
3525
  /** Called when the user cancels the import */
3520
- onCancel?: () => void;
3526
+ onCancel?: (context: ImportSessionContext) => void;
3521
3527
  /** Called when an error occurs */
3522
- onError?: (error: Error) => void;
3528
+ onError?: (error: Error, context: ImportSessionContext) => void;
3523
3529
  /** Called when the importer opens */
3524
3530
  onImporterOpen?: () => void;
3525
3531
  /** Called when the importer closes */
@@ -3528,6 +3534,17 @@ export declare type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, '
3528
3534
  onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
3529
3535
  };
3530
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[];
3546
+ };
3547
+
3531
3548
  declare type PhoneNumberFormat = 'international' | 'national' | 'both';
3532
3549
 
3533
3550
  declare type PhoneNumberOutput = 'e164' | 'formatted' | 'digits';
@@ -3634,6 +3651,10 @@ export declare interface RecordsChunk<T> {
3634
3651
  currentChunkIndex: number;
3635
3652
  /** Total number of records across all chunks */
3636
3653
  totalRecords: number;
3654
+ /** Generated session ID for the current import run */
3655
+ sessionId: string;
3656
+ /** Stable per-chunk idempotency key */
3657
+ chunkIdempotencyKey: string;
3637
3658
  }
3638
3659
 
3639
3660
  declare type RefineBatchResultItem = {
@@ -3665,13 +3686,6 @@ declare type RefineResultItem = {
3665
3686
  };
3666
3687
  };
3667
3688
 
3668
- /**
3669
- * Type helper that requires at least one of the specified keys to be present
3670
- */
3671
- declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
3672
- [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
3673
- }[Keys];
3674
-
3675
3689
  declare interface SelectOption<TValue extends string | number = string | number> {
3676
3690
  label: string;
3677
3691
  value: TValue;
@@ -3684,6 +3698,14 @@ declare interface SelectOptions {
3684
3698
  message?: string;
3685
3699
  }
3686
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
+
3687
3709
  declare type StripBrand<T> = {
3688
3710
  [K in keyof T]: T[K] extends TemplateString<string> ? string : T[K] extends object ? StripBrand<T[K]> : T[K];
3689
3711
  };
@@ -3772,7 +3794,7 @@ declare interface URLOptions {
3772
3794
  message?: string;
3773
3795
  }
3774
3796
 
3775
- export declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, getSessionToken, 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>): {
3776
3798
  open: (options: OpenOptions<Infer<TSchema>>) => void;
3777
3799
  importerState: ImporterState;
3778
3800
  isInitialising: boolean;
@@ -3792,8 +3814,10 @@ export declare interface UseExpressCSVOptions<TSchema extends ExType<unknown, Ex
3792
3814
  fonts?: Record<string, ECSVFontSource>;
3793
3815
  stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
3794
3816
  previewSchemaBeforeUpload?: boolean;
3817
+ aiColumnMatching?: boolean;
3818
+ aiTransform?: boolean;
3795
3819
  templateDownload?: TemplateDownloadOptions<TSchema>;
3796
- saveSession?: boolean;
3820
+ storage?: StorageOptions;
3797
3821
  locale?: DeepPartial<ExpressCSVLocaleInput>;
3798
3822
  disableStatusStep?: boolean;
3799
3823
  }
@@ -3806,31 +3830,6 @@ declare interface ValidatorCheck {
3806
3830
  message?: string;
3807
3831
  }
3808
3832
 
3809
- /**
3810
- * Webhook configuration for remote delivery of results
3811
- */
3812
- export declare interface WebhookConfig {
3813
- /** The URL to send webhook requests to */
3814
- url: string;
3815
- /** Optional HTTP headers to include in the request */
3816
- headers?: Record<string, string>;
3817
- /** HTTP method to use (default: 'POST') */
3818
- method?: 'POST' | 'PUT' | 'PATCH';
3819
- /** Request timeout in milliseconds (default: 30000) */
3820
- timeout?: number;
3821
- /** Number of retry attempts on failure (default: 0) */
3822
- retries?: number;
3823
- /** Arbitrary developer-provided metadata */
3824
- metadata?: Record<string, unknown>;
3825
- /**
3826
- * Whether to wait for the delivery service to confirm the webhook was
3827
- * successfully received before considering the import complete.
3828
- * When false, the import completes as soon as all chunks are queued.
3829
- * Default: false
3830
- */
3831
- awaitWebhookArrival?: boolean;
3832
- }
3833
-
3834
3833
  export declare const x: {
3835
3834
  string: typeof ExString.create;
3836
3835
  number: typeof ExNumber.create;