@expresscsv/sdk 0.1.18 → 0.1.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/README.md +40 -4
- package/dist/index.d.cts +21 -13
- package/dist/index.d.mts +21 -13
- package/dist/index.d.ts +21 -13
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ importer.open({
|
|
|
57
57
|
});
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
If your schema is assembled dynamically at runtime, use `x.
|
|
60
|
+
If your schema is assembled dynamically at runtime, still use `x.row(...)`. Just note that dynamic schema assembly can widen TypeScript inference, so use it intentionally when you need runtime-driven columns.
|
|
61
61
|
|
|
62
62
|
Your `publishableKey` is available from the [ExpressCSV dashboard](https://expresscsv.com). Two key types are available: **production** keys for live usage, and **dev/testing** keys that provide unlimited test imports.
|
|
63
63
|
|
|
@@ -266,6 +266,40 @@ const importer = new CSVImporter({
|
|
|
266
266
|
});
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
+
## Template Downloads
|
|
270
|
+
|
|
271
|
+
Generated templates can include example rows that match your schema.
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import { CSVImporter, x, type Infer } from "@expresscsv/sdk";
|
|
275
|
+
|
|
276
|
+
const candidateSchema = x.row({
|
|
277
|
+
firstName: x.string().label("First Name"),
|
|
278
|
+
email: x.string().email().label("Email"),
|
|
279
|
+
role: x.select([
|
|
280
|
+
{ label: "Admin", value: "admin" },
|
|
281
|
+
{ label: "Editor", value: "editor" },
|
|
282
|
+
]).label("Role"),
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
const importer = new CSVImporter({
|
|
286
|
+
schema: candidateSchema,
|
|
287
|
+
publishableKey: "your-publishable-key",
|
|
288
|
+
importIdentifier: "candidate-import",
|
|
289
|
+
templateDownload: {
|
|
290
|
+
source: "generate",
|
|
291
|
+
formats: ["csv", "xlsx"],
|
|
292
|
+
exampleRows: () => [
|
|
293
|
+
{
|
|
294
|
+
firstName: "Alice",
|
|
295
|
+
email: "alice@example.com",
|
|
296
|
+
role: "admin",
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
269
303
|
## Theming and Styling
|
|
270
304
|
|
|
271
305
|
Customize the widget's appearance with the `theme`, `colorMode`, `customCSS`, and `fonts` options.
|
|
@@ -459,7 +493,7 @@ const schema = x.row({
|
|
|
459
493
|
});
|
|
460
494
|
```
|
|
461
495
|
|
|
462
|
-
`x.
|
|
496
|
+
`x.row(...)` also works for runtime-built schemas, which is useful when the shape depends on account data, user preferences, or enabled custom fields.
|
|
463
497
|
|
|
464
498
|
```typescript
|
|
465
499
|
import { x } from "@expresscsv/sdk";
|
|
@@ -469,7 +503,7 @@ function buildCustomerSchema(options: {
|
|
|
469
503
|
collectHealthScore: boolean;
|
|
470
504
|
collectSegment: boolean;
|
|
471
505
|
}) {
|
|
472
|
-
return x.
|
|
506
|
+
return x.row({
|
|
473
507
|
email: x.string().email().label("Email"),
|
|
474
508
|
companyName: x.string().label("Company Name"),
|
|
475
509
|
...(options.collectCrmId ? { crmId: x.string().label("CRM ID") } : {}),
|
|
@@ -497,6 +531,8 @@ const schema = buildCustomerSchema({
|
|
|
497
531
|
});
|
|
498
532
|
```
|
|
499
533
|
|
|
534
|
+
Dynamic schema assembly preserves the same runtime parsing behavior, but it can widen `Infer<typeof schema>` because the exact keys are no longer fully known to TypeScript. Use it intentionally.
|
|
535
|
+
|
|
500
536
|
### Common Modifiers
|
|
501
537
|
|
|
502
538
|
All field types support:
|
|
@@ -655,7 +691,7 @@ new CSVImporter(options: SDKOptions)
|
|
|
655
691
|
| `fonts` | `Record<string, ECSVFontSource>` | No | - | Custom font sources |
|
|
656
692
|
| `stepDisplay` | `'progressBar' \| 'segmented' \| 'numbered'` | No | `'progressBar'` | Step indicator style |
|
|
657
693
|
| `previewSchemaBeforeUpload` | `boolean` | No | `true` | Show schema preview before upload |
|
|
658
|
-
| `templateDownload` | `
|
|
694
|
+
| `templateDownload` | `TemplateDownloadOptions<TSchema>` | No | - | Template download configuration with optional schema-typed example rows |
|
|
659
695
|
| `saveSession` | `boolean` | No | - | Persist session state |
|
|
660
696
|
| `locale` | `DeepPartial<ExpressCSVLocaleInput>` | No | - | Localization overrides |
|
|
661
697
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1256,6 +1256,7 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
|
|
|
1256
1256
|
private cachedSchemaJson;
|
|
1257
1257
|
private initCompletePromise;
|
|
1258
1258
|
private resolveInitComplete;
|
|
1259
|
+
private resolvedTemplateDownload;
|
|
1259
1260
|
constructor(options: SDKOptions<TSchema>);
|
|
1260
1261
|
/**
|
|
1261
1262
|
* Enhanced state management
|
|
@@ -3126,16 +3127,14 @@ declare class ExRow<T extends ExRowShape> extends ExType<{
|
|
|
3126
3127
|
* Factory method to create an ExRow validator for a row of data
|
|
3127
3128
|
*
|
|
3128
3129
|
* @param shape - Object defining the structure of fields in the row
|
|
3130
|
+
*
|
|
3131
|
+
* Object literals preserve exact key inference. If callers build the shape
|
|
3132
|
+
* through a widened variable or conditional assembly, TypeScript may widen
|
|
3133
|
+
* the resulting row type as well.
|
|
3134
|
+
*
|
|
3129
3135
|
* @returns A new ExRow instance
|
|
3130
3136
|
*/
|
|
3131
3137
|
static create<T extends ExRowShape>(shape: T): ExRow<T>;
|
|
3132
|
-
/**
|
|
3133
|
-
* Factory method for runtime-built row shapes.
|
|
3134
|
-
*
|
|
3135
|
-
* This intentionally widens the returned type to ExRow<ExRowShape> so callers
|
|
3136
|
-
* can assemble fields conditionally without relying on exact key inference.
|
|
3137
|
-
*/
|
|
3138
|
-
static createDynamic(shape: ExRowShape): ExRow<ExRowShape>;
|
|
3139
3138
|
/**
|
|
3140
3139
|
* Specifies columns that can be null/optional with conditional logic
|
|
3141
3140
|
*
|
|
@@ -3777,7 +3776,7 @@ export declare interface SDKOptions<TSchema extends ExType<unknown, ExBaseDef, u
|
|
|
3777
3776
|
fonts?: Record<string, ECSVFontSource>;
|
|
3778
3777
|
stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
|
|
3779
3778
|
previewSchemaBeforeUpload?: boolean;
|
|
3780
|
-
templateDownload?:
|
|
3779
|
+
templateDownload?: TemplateDownloadOptions<TSchema>;
|
|
3781
3780
|
saveSession?: boolean;
|
|
3782
3781
|
locale?: DeepPartial<ExpressCSVLocaleInput>;
|
|
3783
3782
|
disableStatusStep?: boolean;
|
|
@@ -3834,18 +3833,28 @@ export declare interface TailwindThemeVars {
|
|
|
3834
3833
|
|
|
3835
3834
|
/**
|
|
3836
3835
|
* Configuration for template download in the upload step.
|
|
3837
|
-
* When `source` is `"generate"`, a
|
|
3838
|
-
*
|
|
3836
|
+
* When `source` is `"generate"`, a template file is created client-side
|
|
3837
|
+
* from the schema column names and optional example rows.
|
|
3839
3838
|
*/
|
|
3840
|
-
declare interface TemplateDownloadConfig {
|
|
3839
|
+
export declare interface TemplateDownloadConfig {
|
|
3841
3840
|
source: 'generate';
|
|
3842
3841
|
formats?: TemplateDownloadFormat[];
|
|
3842
|
+
exampleRows?: TemplateDownloadExampleRow[];
|
|
3843
3843
|
}
|
|
3844
3844
|
|
|
3845
|
+
/**
|
|
3846
|
+
* A serializable example row used to populate generated templates.
|
|
3847
|
+
*/
|
|
3848
|
+
export declare type TemplateDownloadExampleRow = Record<string, unknown>;
|
|
3849
|
+
|
|
3845
3850
|
/**
|
|
3846
3851
|
* Template download format
|
|
3847
3852
|
*/
|
|
3848
|
-
declare type TemplateDownloadFormat = 'csv' | 'xlsx';
|
|
3853
|
+
export declare type TemplateDownloadFormat = 'csv' | 'xlsx';
|
|
3854
|
+
|
|
3855
|
+
export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> = Omit<TemplateDownloadConfig, 'exampleRows'> & {
|
|
3856
|
+
exampleRows?: Infer<TSchema>[] | (() => Infer<TSchema>[]);
|
|
3857
|
+
};
|
|
3849
3858
|
|
|
3850
3859
|
/**
|
|
3851
3860
|
* A branded string type for locale entries that require interpolation via `{variable}` syntax.
|
|
@@ -3937,7 +3946,6 @@ export declare const x: {
|
|
|
3937
3946
|
time: typeof ExTime.create;
|
|
3938
3947
|
datetime: typeof ExDatetime.create;
|
|
3939
3948
|
row: typeof ExRow.create;
|
|
3940
|
-
dynamicRow: typeof ExRow.createDynamic;
|
|
3941
3949
|
select: typeof ExSelect.create;
|
|
3942
3950
|
multiselect: typeof ExMultiselect.create;
|
|
3943
3951
|
infer: <T extends ExType<unknown, ExBaseDef, unknown>>(_schema: T) => Infer<T>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1256,6 +1256,7 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
|
|
|
1256
1256
|
private cachedSchemaJson;
|
|
1257
1257
|
private initCompletePromise;
|
|
1258
1258
|
private resolveInitComplete;
|
|
1259
|
+
private resolvedTemplateDownload;
|
|
1259
1260
|
constructor(options: SDKOptions<TSchema>);
|
|
1260
1261
|
/**
|
|
1261
1262
|
* Enhanced state management
|
|
@@ -3126,16 +3127,14 @@ declare class ExRow<T extends ExRowShape> extends ExType<{
|
|
|
3126
3127
|
* Factory method to create an ExRow validator for a row of data
|
|
3127
3128
|
*
|
|
3128
3129
|
* @param shape - Object defining the structure of fields in the row
|
|
3130
|
+
*
|
|
3131
|
+
* Object literals preserve exact key inference. If callers build the shape
|
|
3132
|
+
* through a widened variable or conditional assembly, TypeScript may widen
|
|
3133
|
+
* the resulting row type as well.
|
|
3134
|
+
*
|
|
3129
3135
|
* @returns A new ExRow instance
|
|
3130
3136
|
*/
|
|
3131
3137
|
static create<T extends ExRowShape>(shape: T): ExRow<T>;
|
|
3132
|
-
/**
|
|
3133
|
-
* Factory method for runtime-built row shapes.
|
|
3134
|
-
*
|
|
3135
|
-
* This intentionally widens the returned type to ExRow<ExRowShape> so callers
|
|
3136
|
-
* can assemble fields conditionally without relying on exact key inference.
|
|
3137
|
-
*/
|
|
3138
|
-
static createDynamic(shape: ExRowShape): ExRow<ExRowShape>;
|
|
3139
3138
|
/**
|
|
3140
3139
|
* Specifies columns that can be null/optional with conditional logic
|
|
3141
3140
|
*
|
|
@@ -3777,7 +3776,7 @@ export declare interface SDKOptions<TSchema extends ExType<unknown, ExBaseDef, u
|
|
|
3777
3776
|
fonts?: Record<string, ECSVFontSource>;
|
|
3778
3777
|
stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
|
|
3779
3778
|
previewSchemaBeforeUpload?: boolean;
|
|
3780
|
-
templateDownload?:
|
|
3779
|
+
templateDownload?: TemplateDownloadOptions<TSchema>;
|
|
3781
3780
|
saveSession?: boolean;
|
|
3782
3781
|
locale?: DeepPartial<ExpressCSVLocaleInput>;
|
|
3783
3782
|
disableStatusStep?: boolean;
|
|
@@ -3834,18 +3833,28 @@ export declare interface TailwindThemeVars {
|
|
|
3834
3833
|
|
|
3835
3834
|
/**
|
|
3836
3835
|
* Configuration for template download in the upload step.
|
|
3837
|
-
* When `source` is `"generate"`, a
|
|
3838
|
-
*
|
|
3836
|
+
* When `source` is `"generate"`, a template file is created client-side
|
|
3837
|
+
* from the schema column names and optional example rows.
|
|
3839
3838
|
*/
|
|
3840
|
-
declare interface TemplateDownloadConfig {
|
|
3839
|
+
export declare interface TemplateDownloadConfig {
|
|
3841
3840
|
source: 'generate';
|
|
3842
3841
|
formats?: TemplateDownloadFormat[];
|
|
3842
|
+
exampleRows?: TemplateDownloadExampleRow[];
|
|
3843
3843
|
}
|
|
3844
3844
|
|
|
3845
|
+
/**
|
|
3846
|
+
* A serializable example row used to populate generated templates.
|
|
3847
|
+
*/
|
|
3848
|
+
export declare type TemplateDownloadExampleRow = Record<string, unknown>;
|
|
3849
|
+
|
|
3845
3850
|
/**
|
|
3846
3851
|
* Template download format
|
|
3847
3852
|
*/
|
|
3848
|
-
declare type TemplateDownloadFormat = 'csv' | 'xlsx';
|
|
3853
|
+
export declare type TemplateDownloadFormat = 'csv' | 'xlsx';
|
|
3854
|
+
|
|
3855
|
+
export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> = Omit<TemplateDownloadConfig, 'exampleRows'> & {
|
|
3856
|
+
exampleRows?: Infer<TSchema>[] | (() => Infer<TSchema>[]);
|
|
3857
|
+
};
|
|
3849
3858
|
|
|
3850
3859
|
/**
|
|
3851
3860
|
* A branded string type for locale entries that require interpolation via `{variable}` syntax.
|
|
@@ -3937,7 +3946,6 @@ export declare const x: {
|
|
|
3937
3946
|
time: typeof ExTime.create;
|
|
3938
3947
|
datetime: typeof ExDatetime.create;
|
|
3939
3948
|
row: typeof ExRow.create;
|
|
3940
|
-
dynamicRow: typeof ExRow.createDynamic;
|
|
3941
3949
|
select: typeof ExSelect.create;
|
|
3942
3950
|
multiselect: typeof ExMultiselect.create;
|
|
3943
3951
|
infer: <T extends ExType<unknown, ExBaseDef, unknown>>(_schema: T) => Infer<T>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1256,6 +1256,7 @@ export declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unkn
|
|
|
1256
1256
|
private cachedSchemaJson;
|
|
1257
1257
|
private initCompletePromise;
|
|
1258
1258
|
private resolveInitComplete;
|
|
1259
|
+
private resolvedTemplateDownload;
|
|
1259
1260
|
constructor(options: SDKOptions<TSchema>);
|
|
1260
1261
|
/**
|
|
1261
1262
|
* Enhanced state management
|
|
@@ -3126,16 +3127,14 @@ declare class ExRow<T extends ExRowShape> extends ExType<{
|
|
|
3126
3127
|
* Factory method to create an ExRow validator for a row of data
|
|
3127
3128
|
*
|
|
3128
3129
|
* @param shape - Object defining the structure of fields in the row
|
|
3130
|
+
*
|
|
3131
|
+
* Object literals preserve exact key inference. If callers build the shape
|
|
3132
|
+
* through a widened variable or conditional assembly, TypeScript may widen
|
|
3133
|
+
* the resulting row type as well.
|
|
3134
|
+
*
|
|
3129
3135
|
* @returns A new ExRow instance
|
|
3130
3136
|
*/
|
|
3131
3137
|
static create<T extends ExRowShape>(shape: T): ExRow<T>;
|
|
3132
|
-
/**
|
|
3133
|
-
* Factory method for runtime-built row shapes.
|
|
3134
|
-
*
|
|
3135
|
-
* This intentionally widens the returned type to ExRow<ExRowShape> so callers
|
|
3136
|
-
* can assemble fields conditionally without relying on exact key inference.
|
|
3137
|
-
*/
|
|
3138
|
-
static createDynamic(shape: ExRowShape): ExRow<ExRowShape>;
|
|
3139
3138
|
/**
|
|
3140
3139
|
* Specifies columns that can be null/optional with conditional logic
|
|
3141
3140
|
*
|
|
@@ -3777,7 +3776,7 @@ export declare interface SDKOptions<TSchema extends ExType<unknown, ExBaseDef, u
|
|
|
3777
3776
|
fonts?: Record<string, ECSVFontSource>;
|
|
3778
3777
|
stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
|
|
3779
3778
|
previewSchemaBeforeUpload?: boolean;
|
|
3780
|
-
templateDownload?:
|
|
3779
|
+
templateDownload?: TemplateDownloadOptions<TSchema>;
|
|
3781
3780
|
saveSession?: boolean;
|
|
3782
3781
|
locale?: DeepPartial<ExpressCSVLocaleInput>;
|
|
3783
3782
|
disableStatusStep?: boolean;
|
|
@@ -3834,18 +3833,28 @@ export declare interface TailwindThemeVars {
|
|
|
3834
3833
|
|
|
3835
3834
|
/**
|
|
3836
3835
|
* Configuration for template download in the upload step.
|
|
3837
|
-
* When `source` is `"generate"`, a
|
|
3838
|
-
*
|
|
3836
|
+
* When `source` is `"generate"`, a template file is created client-side
|
|
3837
|
+
* from the schema column names and optional example rows.
|
|
3839
3838
|
*/
|
|
3840
|
-
declare interface TemplateDownloadConfig {
|
|
3839
|
+
export declare interface TemplateDownloadConfig {
|
|
3841
3840
|
source: 'generate';
|
|
3842
3841
|
formats?: TemplateDownloadFormat[];
|
|
3842
|
+
exampleRows?: TemplateDownloadExampleRow[];
|
|
3843
3843
|
}
|
|
3844
3844
|
|
|
3845
|
+
/**
|
|
3846
|
+
* A serializable example row used to populate generated templates.
|
|
3847
|
+
*/
|
|
3848
|
+
export declare type TemplateDownloadExampleRow = Record<string, unknown>;
|
|
3849
|
+
|
|
3845
3850
|
/**
|
|
3846
3851
|
* Template download format
|
|
3847
3852
|
*/
|
|
3848
|
-
declare type TemplateDownloadFormat = 'csv' | 'xlsx';
|
|
3853
|
+
export declare type TemplateDownloadFormat = 'csv' | 'xlsx';
|
|
3854
|
+
|
|
3855
|
+
export declare type TemplateDownloadOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> = Omit<TemplateDownloadConfig, 'exampleRows'> & {
|
|
3856
|
+
exampleRows?: Infer<TSchema>[] | (() => Infer<TSchema>[]);
|
|
3857
|
+
};
|
|
3849
3858
|
|
|
3850
3859
|
/**
|
|
3851
3860
|
* A branded string type for locale entries that require interpolation via `{variable}` syntax.
|
|
@@ -3937,7 +3946,6 @@ export declare const x: {
|
|
|
3937
3946
|
time: typeof ExTime.create;
|
|
3938
3947
|
datetime: typeof ExDatetime.create;
|
|
3939
3948
|
row: typeof ExRow.create;
|
|
3940
|
-
dynamicRow: typeof ExRow.createDynamic;
|
|
3941
3949
|
select: typeof ExSelect.create;
|
|
3942
3950
|
multiselect: typeof ExMultiselect.create;
|
|
3943
3951
|
infer: <T extends ExType<unknown, ExBaseDef, unknown>>(_schema: T) => Infer<T>;
|