@updog/data-editor-wc 0.1.10 → 0.1.12
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/LICENSE +2 -2
- package/README.md +25 -3
- package/index.d.ts +251 -652
- package/index.js +5309 -5082
- package/package.json +11 -3
package/index.d.ts
CHANGED
|
@@ -370,37 +370,63 @@ declare var export_default = {
|
|
|
370
370
|
redo: "Redo",
|
|
371
371
|
},
|
|
372
372
|
validation: {
|
|
373
|
-
required: "This field is required",
|
|
374
|
-
invalidNumber: "Invalid number",
|
|
375
|
-
invalidEmail: "Invalid email address",
|
|
376
|
-
invalidDate: "Invalid date",
|
|
377
373
|
endDateBeforeStart: "End date must be after start date",
|
|
374
|
+
invalidDate: "Invalid date",
|
|
375
|
+
invalidEmail: "Invalid email address",
|
|
376
|
+
invalidFormat: "Invalid format",
|
|
377
|
+
invalidNumber: "Invalid number",
|
|
378
|
+
invalidOption: "Invalid option",
|
|
379
|
+
outOfRange: "Out of range",
|
|
380
|
+
required: "This field is required",
|
|
378
381
|
valueMustBeUnique: "Value must be unique",
|
|
379
382
|
},
|
|
380
383
|
license: {
|
|
381
384
|
loading: "Loading data editor",
|
|
382
|
-
|
|
383
|
-
|
|
385
|
+
},
|
|
386
|
+
connecting: {
|
|
387
|
+
label: "Connecting to server…",
|
|
388
|
+
},
|
|
389
|
+
errors: {
|
|
390
|
+
RENDER_ERROR: {
|
|
391
|
+
title: "Something went wrong",
|
|
392
|
+
text: "Please close this window and try again",
|
|
393
|
+
},
|
|
394
|
+
license: {
|
|
395
|
+
invalid: {
|
|
384
396
|
title: "Invalid license",
|
|
385
397
|
text: "Please contact support for assistance.",
|
|
386
398
|
},
|
|
387
|
-
|
|
399
|
+
missing: {
|
|
388
400
|
title: "Missing API key",
|
|
389
401
|
text: "No API key was provided. Please configure a valid API key.",
|
|
390
402
|
},
|
|
391
|
-
|
|
403
|
+
domain_not_allowed: {
|
|
392
404
|
title: "Domain not allowed",
|
|
393
405
|
text: "This domain is not authorized for this license. Please check your domain settings.",
|
|
394
406
|
},
|
|
395
|
-
|
|
407
|
+
subscription_inactive: {
|
|
396
408
|
title: "Subscription inactive",
|
|
397
409
|
text: "Your subscription is no longer active. Please renew to continue.",
|
|
398
410
|
},
|
|
399
411
|
},
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
412
|
+
scale: {
|
|
413
|
+
bootstrap_failed: {
|
|
414
|
+
title: "Couldn't connect to the server",
|
|
415
|
+
text: "The server returned an error. Please refresh the page or contact support.",
|
|
416
|
+
},
|
|
417
|
+
workspace_lost: {
|
|
418
|
+
title: "Connection lost",
|
|
419
|
+
text: "The session ended unexpectedly. Refresh the page to reconnect.",
|
|
420
|
+
},
|
|
421
|
+
unreachable: {
|
|
422
|
+
title: "Server unreachable",
|
|
423
|
+
text: "Check your connection and refresh the page.",
|
|
424
|
+
},
|
|
425
|
+
server_error: {
|
|
426
|
+
title: "Server error",
|
|
427
|
+
text: "The server returned an error. Please refresh the page or contact support.",
|
|
428
|
+
},
|
|
429
|
+
},
|
|
404
430
|
},
|
|
405
431
|
uploader: {
|
|
406
432
|
steps: {
|
|
@@ -516,43 +542,6 @@ type ExpandPluralKeys<T> = T extends Record<string, unknown>
|
|
|
516
542
|
*/
|
|
517
543
|
type DataEditorTranslations = DeepPartial<ExpandPluralKeys<typeof export_default>>;
|
|
518
544
|
|
|
519
|
-
/**
|
|
520
|
-
* Categories of internal errors surfaced through the `onError` callback.
|
|
521
|
-
*
|
|
522
|
-
* - `PARSE_ERROR` — file parsing failed (corrupt CSV, invalid XLSX, etc.).
|
|
523
|
-
* - `RENDER_ERROR` — component render failed (caught by error boundary).
|
|
524
|
-
* - `TRANSFORM_ERROR` — data transformation failed (column transform, value mapping).
|
|
525
|
-
* - `VALIDATION_ERROR` — validation execution failed (validator threw instead of returning).
|
|
526
|
-
* - `WORKER_ERROR` — Web Worker failed (filter worker, chat transform worker).
|
|
527
|
-
* - `COMMAND_ERROR` — undo/redo command failed.
|
|
528
|
-
* - `OPERATION_ERROR` — general operation failed (bulk mutations, imports).
|
|
529
|
-
*/
|
|
530
|
-
type UpdogErrorCode = "PARSE_ERROR" | "RENDER_ERROR" | "TRANSFORM_ERROR" | "VALIDATION_ERROR" | "WORKER_ERROR" | "COMMAND_ERROR" | "OPERATION_ERROR";
|
|
531
|
-
/**
|
|
532
|
-
* An internal error caught by the SDK and passed to `onError`. The SDK
|
|
533
|
-
* recovers gracefully where possible — `onError` is for your logging and
|
|
534
|
-
* monitoring (Sentry, Datadog, etc.).
|
|
535
|
-
*
|
|
536
|
-
* @example
|
|
537
|
-
* ```ts
|
|
538
|
-
* onError={(error) => {
|
|
539
|
-
* Sentry.captureException(error.originalError ?? error, {
|
|
540
|
-
* tags: { code: error.code, source: error.source },
|
|
541
|
-
* });
|
|
542
|
-
* }}
|
|
543
|
-
* ```
|
|
544
|
-
*/
|
|
545
|
-
type UpdogError = {
|
|
546
|
-
/** The error category. */
|
|
547
|
-
code: UpdogErrorCode;
|
|
548
|
-
/** Human-readable description. */
|
|
549
|
-
message: string;
|
|
550
|
-
/** Module or subsystem that raised the error. */
|
|
551
|
-
source: string;
|
|
552
|
-
/** The underlying thrown value, when available. */
|
|
553
|
-
originalError?: unknown;
|
|
554
|
-
};
|
|
555
|
-
|
|
556
545
|
/**
|
|
557
546
|
* Base row shape. Each key is a column ID, each value is the cell data.
|
|
558
547
|
* Extend this with your own type via the `<DataEditor<TRow>>` generic for
|
|
@@ -566,175 +555,66 @@ type UpdogError = {
|
|
|
566
555
|
* ```
|
|
567
556
|
*/
|
|
568
557
|
type DataEditorRow = Record<string, unknown>;
|
|
569
|
-
/** Sort direction. */
|
|
570
|
-
type SortDirection = "asc" | "desc";
|
|
571
|
-
/** Current sort state. `null` means no active sort. */
|
|
572
|
-
type SortState = {
|
|
573
|
-
columnId: string;
|
|
574
|
-
direction: SortDirection;
|
|
575
|
-
} | null;
|
|
576
|
-
type Filters = {
|
|
577
|
-
search: string;
|
|
578
|
-
matchCase: boolean;
|
|
579
|
-
matchEntireCell: boolean;
|
|
580
|
-
errorMessageFilters: string[];
|
|
581
|
-
showOnlyNewRows: boolean;
|
|
582
|
-
showOnlyEditedRows: boolean;
|
|
583
|
-
showOnlyEmptyCells: boolean;
|
|
584
|
-
/** When true, show only rows flagged for deletion (bin mode). All other filters are bypassed. */
|
|
585
|
-
showOnlyDeletedRows: boolean;
|
|
586
|
-
filterColumns: string[] | null;
|
|
587
|
-
/** Per-column value filters. Key = column ID, value = allowed display-formatted strings. */
|
|
588
|
-
columnValueFilters: Record<string, string[]>;
|
|
589
|
-
/** Per-column numeric range filters. Key = column ID. */
|
|
590
|
-
columnRangeFilters: Record<string, {
|
|
591
|
-
min?: number;
|
|
592
|
-
max?: number;
|
|
593
|
-
}>;
|
|
594
|
-
/** Per-column date range filters. Key = column ID, values are ISO date strings (YYYY-MM-DD). */
|
|
595
|
-
columnDateRangeFilters: Record<string, {
|
|
596
|
-
min?: string;
|
|
597
|
-
max?: string;
|
|
598
|
-
}>;
|
|
599
|
-
};
|
|
600
558
|
|
|
601
559
|
/**
|
|
602
|
-
* A
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
* become column deltas. Rows with no changes are no-ops.
|
|
606
|
-
* - `delete` — `fn` is `(r, ctx) => boolean`. Truthy means "flag this row for
|
|
607
|
-
* deletion". Soft delete via `DeleteRowCommand`.
|
|
560
|
+
* A built-in declarative validator. Mode-symmetric: the SDK ships a TS
|
|
561
|
+
* interpreter, the Updog Scale Go binary ships a Go interpreter, and both
|
|
562
|
+
* agree on pass/fail outcomes per `api/validators.json`.
|
|
608
563
|
*/
|
|
609
|
-
type
|
|
610
|
-
|
|
611
|
-
|
|
564
|
+
type BuiltInValidator = {
|
|
565
|
+
type: "required";
|
|
566
|
+
message?: string;
|
|
612
567
|
} | {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
* A single chunk in the stream returned from `DataEditorChat.onMessage`.
|
|
618
|
-
*
|
|
619
|
-
* - `status` — progress message shown while processing (e.g. "Analyzing 500 rows...").
|
|
620
|
-
* - `message` — chat reply shown to the user.
|
|
621
|
-
* - `rows` — updated rows to apply to the grid. Matched by `primaryKey`.
|
|
622
|
-
* - `ops` — array of per-row operations (edits and/or deletes) to apply in order.
|
|
623
|
-
*/
|
|
624
|
-
type ChatResponseChunk<TRow extends DataEditorRow = DataEditorRow> = {
|
|
625
|
-
type: "status";
|
|
626
|
-
content: string;
|
|
568
|
+
type: "regex";
|
|
569
|
+
pattern: string;
|
|
570
|
+
flags?: string;
|
|
571
|
+
message?: string;
|
|
627
572
|
} | {
|
|
628
|
-
type: "
|
|
629
|
-
|
|
573
|
+
type: "oneOf";
|
|
574
|
+
values: string[];
|
|
575
|
+
message?: string;
|
|
630
576
|
} | {
|
|
631
|
-
type: "
|
|
632
|
-
|
|
577
|
+
type: "range";
|
|
578
|
+
min?: number;
|
|
579
|
+
max?: number;
|
|
580
|
+
message?: string;
|
|
633
581
|
} | {
|
|
634
|
-
type: "
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
/** Whether the row was newly added, edited, or is unchanged. */
|
|
644
|
-
status: ChatRowStatus;
|
|
645
|
-
/** Validation errors keyed by column ID. */
|
|
646
|
-
errors: Record<string, string[]>;
|
|
647
|
-
/** The source this row belongs to. */
|
|
648
|
-
source: string;
|
|
649
|
-
};
|
|
650
|
-
/** Aggregated error count across the current view, grouped by field and message. */
|
|
651
|
-
type ChatErrorSummary = {
|
|
652
|
-
/** Column ID where the error occurred. */
|
|
653
|
-
field: string;
|
|
654
|
-
/** The validation message. */
|
|
655
|
-
message: string;
|
|
656
|
-
/** How many rows hit this error. */
|
|
657
|
-
count: number;
|
|
658
|
-
/** A few example values that triggered the error. */
|
|
659
|
-
examples: string[];
|
|
582
|
+
type: "email";
|
|
583
|
+
message?: string;
|
|
584
|
+
} | {
|
|
585
|
+
type: "date";
|
|
586
|
+
format?: "YYYY-MM-DD" | "DD/MM/YYYY";
|
|
587
|
+
message?: string;
|
|
588
|
+
} | {
|
|
589
|
+
type: "numeric";
|
|
590
|
+
message?: string;
|
|
660
591
|
};
|
|
661
592
|
/**
|
|
662
|
-
*
|
|
663
|
-
*
|
|
593
|
+
* Server-mode-only escape hatch: an expression evaluated by the Go binary
|
|
594
|
+
* via expr-lang. Skipped at runtime in client mode (warned at mount).
|
|
664
595
|
*/
|
|
665
|
-
type
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
primaryKey: keyof TRow;
|
|
670
|
-
/** Total rows in the dataset. */
|
|
671
|
-
totalRowCount: number;
|
|
672
|
-
/** Rows in the current filtered view. */
|
|
673
|
-
filteredRowCount: number;
|
|
674
|
-
/** Sample rows, with status and errors. Size controlled by `sampleSize`. */
|
|
675
|
-
sample: ChatRow<TRow>[];
|
|
676
|
-
/** Aggregated error counts by field and message. */
|
|
677
|
-
errorSummary: ChatErrorSummary[];
|
|
678
|
-
/** Access all rows. Use for full-dataset operations. */
|
|
679
|
-
getRows: () => ChatRow<TRow>[];
|
|
596
|
+
type ExpressionValidator = {
|
|
597
|
+
type: "expression";
|
|
598
|
+
expr: string;
|
|
599
|
+
message?: string;
|
|
680
600
|
};
|
|
681
601
|
/**
|
|
682
|
-
*
|
|
683
|
-
*
|
|
602
|
+
* Client-mode-only escape hatch: a JS predicate run inline. Dropped (with
|
|
603
|
+
* one warn per column) when the SDK serializes the schema for server mode.
|
|
684
604
|
*/
|
|
685
|
-
type
|
|
686
|
-
|
|
687
|
-
|
|
605
|
+
type FunctionValidator = {
|
|
606
|
+
type: "function";
|
|
607
|
+
fn: CellValidator;
|
|
688
608
|
};
|
|
689
609
|
/**
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
* response.
|
|
610
|
+
* The validator-rule union accepted by `DataEditorColumn.validators`.
|
|
611
|
+
* - Built-ins and `expression` are declarative objects (cross the wire).
|
|
612
|
+
* - `function` wraps a `CellValidator`; client-mode-only, dropped+warned in server mode.
|
|
694
613
|
*
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
* chat={{
|
|
698
|
-
* sampleSize: 50,
|
|
699
|
-
* onMessage: async function* (context) {
|
|
700
|
-
* yield { type: "status", content: "Thinking..." };
|
|
701
|
-
* const res = await fetch("/api/ai", {
|
|
702
|
-
* method: "POST",
|
|
703
|
-
* body: JSON.stringify({
|
|
704
|
-
* prompt: context.message,
|
|
705
|
-
* columns: context.columns,
|
|
706
|
-
* sample: context.sample.map(r => r.data),
|
|
707
|
-
* errors: context.errorSummary,
|
|
708
|
-
* }),
|
|
709
|
-
* }).then(r => r.json());
|
|
710
|
-
* yield { type: "rows", content: res.updatedRows };
|
|
711
|
-
* yield { type: "ops", content: res.ops };
|
|
712
|
-
* yield { type: "message", content: res.reply };
|
|
713
|
-
* },
|
|
714
|
-
* }}
|
|
715
|
-
* ```
|
|
614
|
+
* Named `ValidatorRule` (not `Validator`) so it doesn't clash with the
|
|
615
|
+
* runtime `Validator` class in `core/Validator.ts`.
|
|
716
616
|
*/
|
|
717
|
-
type
|
|
718
|
-
/**
|
|
719
|
-
* How many rows to include in the context sample. The SDK picks a
|
|
720
|
-
* representative slice including rows with errors. When omitted, the SDK decides.
|
|
721
|
-
*/
|
|
722
|
-
sampleSize?: number;
|
|
723
|
-
/** Title shown above the suggestion list when the chat is empty. */
|
|
724
|
-
emptyTitle?: string;
|
|
725
|
-
/** How many suggestions to request from `loadSuggestions`. */
|
|
726
|
-
suggestionsCount?: number;
|
|
727
|
-
/** Optional prompt generator for the empty-state suggestion chips. */
|
|
728
|
-
loadSuggestions?: (context: ChatDataContext<TRow>) => Promise<string[]>;
|
|
729
|
-
/**
|
|
730
|
-
* Called when the user sends a message. Receives full dataset context.
|
|
731
|
-
* Returns an async iterable of response chunks — the SDK streams them
|
|
732
|
-
* into the UI.
|
|
733
|
-
*/
|
|
734
|
-
onMessage: (context: ChatContext<TRow>) => AsyncIterable<ChatResponseChunk<TRow>>;
|
|
735
|
-
/** Called when the user cancels a pending request. Use to abort your API call. */
|
|
736
|
-
onCancel?: () => void;
|
|
737
|
-
};
|
|
617
|
+
type ValidatorRule = BuiltInValidator | ExpressionValidator | FunctionValidator;
|
|
738
618
|
|
|
739
619
|
/** Severity level for a validation message. */
|
|
740
620
|
type ValidationLevel = "error";
|
|
@@ -755,9 +635,10 @@ type ValidationError = {
|
|
|
755
635
|
* does not block submission — invalid rows are delivered to `onComplete`
|
|
756
636
|
* alongside valid ones, tagged via the `isValid` flag.
|
|
757
637
|
*
|
|
758
|
-
*
|
|
759
|
-
* `
|
|
760
|
-
*
|
|
638
|
+
* To use a `CellValidator` in the `validators` array, wrap it as
|
|
639
|
+
* `{ type: "function", fn: (value, row) => ... }`. For declarative rules,
|
|
640
|
+
* pass a built-in object literal — e.g. `{ type: "required" }`,
|
|
641
|
+
* `{ type: "email" }`. See `ValidatorRule` for the full union.
|
|
761
642
|
*
|
|
762
643
|
* @param value - The current cell value.
|
|
763
644
|
* @param row - The full row, useful for cross-field checks.
|
|
@@ -841,13 +722,11 @@ type ColumnLockMode = "all" | "default";
|
|
|
841
722
|
*
|
|
842
723
|
* @example
|
|
843
724
|
* ```ts
|
|
844
|
-
* import { required, email, numeric } from "@updog/data-editor";
|
|
845
|
-
*
|
|
846
725
|
* const columns: DataEditorColumn[] = [
|
|
847
|
-
* { id: "name", title: "Full Name", size: 200,
|
|
848
|
-
* { id: "email", title: "Email", size: 250,
|
|
726
|
+
* { id: "name", title: "Full Name", size: 200, validators: [{ type: "required", message: "Name is required" }] },
|
|
727
|
+
* { id: "email", title: "Email", size: 250, validators: [{ type: "required", message: "Email is required" }, { type: "email", message: "Invalid email" }], unique: true },
|
|
849
728
|
* { id: "role", title: "Role", editor: { type: "select", options: ["Admin", "Editor", "Viewer"] } },
|
|
850
|
-
* { id: "salary", title: "Salary",
|
|
729
|
+
* { id: "salary", title: "Salary", validators: [{ type: "numeric", message: "Must be a number" }], formatter: (v) => v ? `$${v}` : "" },
|
|
851
730
|
* ];
|
|
852
731
|
* ```
|
|
853
732
|
*/
|
|
@@ -857,11 +736,14 @@ type DataEditorColumn = {
|
|
|
857
736
|
/** Column header text shown to the user. */
|
|
858
737
|
title: string;
|
|
859
738
|
/**
|
|
860
|
-
* One or more validators run on every edit.
|
|
861
|
-
*
|
|
862
|
-
*
|
|
739
|
+
* One or more validators run on every edit. Accepts:
|
|
740
|
+
* - Built-in object literals: `{ type: "required" | "email" | "regex" | "range" | "oneOf" | "date" | "numeric", ... }`.
|
|
741
|
+
* - `{ type: "expression", expr }` — server-mode only. Warned in client mode.
|
|
742
|
+
* - `{ type: "function", fn }` — client-mode only. Dropped+warned in server mode.
|
|
743
|
+
*
|
|
744
|
+
* See `_specs/VALIDATIONS.md` §4.5 for the per-mode support matrix.
|
|
863
745
|
*/
|
|
864
|
-
|
|
746
|
+
validators?: ValidatorRule[];
|
|
865
747
|
/**
|
|
866
748
|
* When `true`, the editor flags duplicate values in this column as errors.
|
|
867
749
|
* The error message is localized via the `translations` prop
|
|
@@ -902,398 +784,179 @@ type DataEditorColumn = {
|
|
|
902
784
|
locked?: boolean | ColumnLockMode;
|
|
903
785
|
};
|
|
904
786
|
|
|
905
|
-
/** Params passed to `findAndReplace.onFind` when the user types a search query. */
|
|
906
|
-
type FindParams = {
|
|
907
|
-
/** The search string. */
|
|
908
|
-
search: string;
|
|
909
|
-
/** When `true`, matching is case-sensitive. */
|
|
910
|
-
matchCase?: boolean;
|
|
911
|
-
/** When `true`, the entire cell value must equal the search string. */
|
|
912
|
-
matchEntireCell?: boolean;
|
|
913
|
-
/** Restrict search to these columns. `null` or omitted = all columns. */
|
|
914
|
-
columnIds?: string[] | null;
|
|
915
|
-
/** Current view filters so the server can scope matches to the active filter set. */
|
|
916
|
-
filters?: QueryFilters;
|
|
917
|
-
/** Current sort state so match ordering follows the visual row order. */
|
|
918
|
-
sort?: SortState;
|
|
919
|
-
};
|
|
920
|
-
/** A single match location returned by the server. */
|
|
921
|
-
type FindMatch = {
|
|
922
|
-
/** Row position in the current filtered+sorted view (for grid scrolling). */
|
|
923
|
-
rowIndex: number;
|
|
924
|
-
/** Column ID where the match occurs. */
|
|
925
|
-
columnId: string;
|
|
926
|
-
/** Character offset within the cell value (for inline highlight). */
|
|
927
|
-
startIndex: number;
|
|
928
|
-
/** 0-based position in the ordered match list (for counter display). */
|
|
929
|
-
matchIndex: number;
|
|
930
|
-
};
|
|
931
|
-
/** Response from `findAndReplace.onFind`. */
|
|
932
|
-
type FindResponse = {
|
|
933
|
-
/** Total number of matches across all rows. */
|
|
934
|
-
totalCount: number;
|
|
935
|
-
/** The first match. Omit when `totalCount` is 0. */
|
|
936
|
-
current?: FindMatch;
|
|
937
|
-
};
|
|
938
|
-
/** Params passed to `findAndReplace.onNavigate` when the user clicks prev/next. */
|
|
939
|
-
type FindNavigateParams = FindParams & {
|
|
940
|
-
/** Navigation direction. */
|
|
941
|
-
direction: "next" | "prev";
|
|
942
|
-
/** Current match position so the server knows where to navigate from. */
|
|
943
|
-
currentMatchIndex: number;
|
|
944
|
-
};
|
|
945
|
-
/** Params passed to `findAndReplace.onReplace`. */
|
|
946
|
-
type ReplaceParams = FindParams & {
|
|
947
|
-
/** The replacement text. */
|
|
948
|
-
replacement: string;
|
|
949
|
-
/** When `true`, replace all matches. When omitted or `false`, replace only `target`. */
|
|
950
|
-
all?: boolean;
|
|
951
|
-
/** The specific match to replace. Required when `all` is not `true`. */
|
|
952
|
-
target?: FindMatch;
|
|
953
|
-
};
|
|
954
|
-
/** Response from `findAndReplace.onReplace`. */
|
|
955
|
-
type ReplaceResponse = {
|
|
956
|
-
/** Remaining match count after replacement. */
|
|
957
|
-
totalCount: number;
|
|
958
|
-
/** Next match to navigate to after replacement. Omit when none left. */
|
|
959
|
-
current?: FindMatch;
|
|
960
|
-
};
|
|
961
|
-
/** Server-side find and replace configuration. */
|
|
962
|
-
type FindAndReplaceConfig = {
|
|
963
|
-
/** Called when the user types a search query. Returns total count and first match. */
|
|
964
|
-
onFind: (params: FindParams) => Promise<FindResponse>;
|
|
965
|
-
/** Called when the user clicks prev/next arrows. Returns the target match. */
|
|
966
|
-
onNavigate: (params: FindNavigateParams) => Promise<FindMatch>;
|
|
967
|
-
/** Called when the user clicks Replace or Replace All. */
|
|
968
|
-
onReplace: (params: ReplaceParams) => Promise<ReplaceResponse>;
|
|
969
|
-
};
|
|
970
|
-
type ServerRowId = string | number;
|
|
971
|
-
/** Row-level status flags returned by the server. Drive row filters and sidebar counts. */
|
|
972
|
-
type ServerRowStatus = {
|
|
973
|
-
edited?: boolean;
|
|
974
|
-
new?: boolean;
|
|
975
|
-
deleted?: boolean;
|
|
976
|
-
hasErrors?: boolean;
|
|
977
|
-
hasEmptyCells?: boolean;
|
|
978
|
-
};
|
|
979
|
-
/** Server-reported change for a single cell. The current value lives in `fields`. */
|
|
980
|
-
type ServerCellChange = {
|
|
981
|
-
original: unknown;
|
|
982
|
-
};
|
|
983
|
-
/** Server-reported validation error for a single cell. */
|
|
984
|
-
type ServerCellError = {
|
|
985
|
-
message: string;
|
|
986
|
-
code?: number | string;
|
|
987
|
-
};
|
|
988
|
-
/** Per-row metadata returned by the server in server-delegated mode. */
|
|
989
|
-
type ServerRowMeta = {
|
|
990
|
-
/** Row-level status flags — drive row filters and sidebar counts. */
|
|
991
|
-
status?: ServerRowStatus;
|
|
992
|
-
/** Cell-level change tracking. Key = field name. */
|
|
993
|
-
changes?: Record<string, ServerCellChange>;
|
|
994
|
-
/** Cell-level validation errors. Key = field name. */
|
|
995
|
-
errors?: Record<string, ServerCellError[]>;
|
|
996
|
-
};
|
|
997
|
-
/** Per-source row count returned by the server. Drives the Data Sources sidebar. */
|
|
998
|
-
type ServerSourceCount = {
|
|
999
|
-
id: string;
|
|
1000
|
-
name: string;
|
|
1001
|
-
count: number;
|
|
1002
|
-
};
|
|
1003
|
-
/** Aggregate row counts returned alongside a query page. Drive sidebar indicators. */
|
|
1004
|
-
type ServerQueryCounts = {
|
|
1005
|
-
edited?: number;
|
|
1006
|
-
new?: number;
|
|
1007
|
-
deleted?: number;
|
|
1008
|
-
errors?: number;
|
|
1009
|
-
emptyCells?: number;
|
|
1010
|
-
sources?: ServerSourceCount[];
|
|
1011
|
-
};
|
|
1012
|
-
type ServerRow<T extends DataEditorRow = DataEditorRow> = {
|
|
1013
|
-
id: ServerRowId;
|
|
1014
|
-
fields: T;
|
|
1015
|
-
meta?: ServerRowMeta;
|
|
1016
|
-
};
|
|
1017
|
-
type ServerResponse<T> = {
|
|
1018
|
-
data: T;
|
|
1019
|
-
meta?: Record<string, unknown>;
|
|
1020
|
-
};
|
|
1021
|
-
type QueryFilters<F = Record<string, unknown>> = Partial<Filters> & F;
|
|
1022
|
-
type QueryParams<F = Record<string, unknown>> = {
|
|
1023
|
-
filters?: QueryFilters<F>;
|
|
1024
|
-
sort?: SortState;
|
|
1025
|
-
/** When present, only rows belonging to these source IDs are returned. Omit to include all sources. */
|
|
1026
|
-
sources?: string[];
|
|
1027
|
-
offset?: number;
|
|
1028
|
-
limit: number;
|
|
1029
|
-
signal?: AbortSignal;
|
|
1030
|
-
};
|
|
1031
|
-
type QueryResponse<T extends DataEditorRow = DataEditorRow> = ServerResponse<{
|
|
1032
|
-
rows: ServerRow<T>[];
|
|
1033
|
-
totalCount: number;
|
|
1034
|
-
filteredCount?: number;
|
|
1035
|
-
counts?: ServerQueryCounts;
|
|
1036
|
-
}>;
|
|
1037
787
|
/**
|
|
1038
|
-
*
|
|
1039
|
-
*
|
|
788
|
+
* Categories of internal errors surfaced through the `onError` callback.
|
|
789
|
+
*
|
|
790
|
+
* Existing categories cover client-side failures. `scale.*` codes cover
|
|
791
|
+
* server-mode (Updog Scale) failures. `license.*` codes cover license
|
|
792
|
+
* validation failures (previously a separate `LicenseErrorCode` enum).
|
|
1040
793
|
*/
|
|
1041
|
-
type
|
|
1042
|
-
[columnId: string]: {
|
|
1043
|
-
/** Values for `"select"` filters. Raw display strings — no formatter is applied. */
|
|
1044
|
-
options?: string[];
|
|
1045
|
-
/** Bounds for `"number-range"` filters. */
|
|
1046
|
-
range?: {
|
|
1047
|
-
min: number;
|
|
1048
|
-
max: number;
|
|
1049
|
-
};
|
|
1050
|
-
/** Bounds for `"date-range"` filters. Values are ISO date strings (YYYY-MM-DD). */
|
|
1051
|
-
dateRange?: {
|
|
1052
|
-
min: string;
|
|
1053
|
-
max: string;
|
|
1054
|
-
};
|
|
1055
|
-
};
|
|
1056
|
-
};
|
|
1057
|
-
type ServerCallOptions = {
|
|
1058
|
-
signal: AbortSignal;
|
|
1059
|
-
};
|
|
794
|
+
type UpdogErrorCode = "PARSE_ERROR" | "RENDER_ERROR" | "TRANSFORM_ERROR" | "VALIDATION_ERROR" | "WORKER_ERROR" | "COMMAND_ERROR" | "OPERATION_ERROR" | "license.invalid" | "license.missing" | "license.domain_not_allowed" | "license.subscription_inactive" | "license.trial_expired" | "scale.bootstrap_failed" | "scale.workspace_lost" | "scale.unreachable" | "scale.server_error";
|
|
1060
795
|
/**
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
1063
|
-
*
|
|
1064
|
-
* Convention:
|
|
1065
|
-
* - Both row fields omitted → all rows.
|
|
1066
|
-
* - Both column fields omitted → all columns.
|
|
1067
|
-
* - Single row: `fromRow` AND `toRow` both set, `toRow === fromRow`.
|
|
1068
|
-
* - Single column: `fromColumn` AND `toColumn` both set, `toColumn === fromColumn`.
|
|
1069
|
-
* - Range: both `from` and `to` set, `to !== from`.
|
|
1070
|
-
* - `allSelected: true` → all rows and all columns.
|
|
1071
|
-
* - Empty `{}` → used only for insert operations.
|
|
796
|
+
* An internal error caught by the SDK and passed to `onError`. The SDK
|
|
797
|
+
* recovers gracefully where possible — `onError` is for your logging and
|
|
798
|
+
* monitoring (Sentry, Datadog, etc.).
|
|
1072
799
|
*
|
|
1073
|
-
*
|
|
800
|
+
* @example
|
|
801
|
+
* ```ts
|
|
802
|
+
* onError={(error) => {
|
|
803
|
+
* Sentry.captureException(error.originalError ?? error, {
|
|
804
|
+
* tags: { code: error.code, source: error.source },
|
|
805
|
+
* });
|
|
806
|
+
* }}
|
|
807
|
+
* ```
|
|
1074
808
|
*/
|
|
1075
|
-
type
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
/**
|
|
1083
|
-
|
|
1084
|
-
/** Existing row to anchor the insert relative to. Omitted when appending to the end. */
|
|
1085
|
-
anchorRow?: ServerRowId;
|
|
1086
|
-
/** Insert before or after the anchor row. */
|
|
1087
|
-
position: "above" | "below";
|
|
1088
|
-
/** Column IDs matching the order of `values` entries. */
|
|
1089
|
-
columns: string[];
|
|
809
|
+
type UpdogError = {
|
|
810
|
+
/** The error category. */
|
|
811
|
+
code: UpdogErrorCode;
|
|
812
|
+
/** Human-readable description. */
|
|
813
|
+
message: string;
|
|
814
|
+
/** Module or subsystem that raised the error. */
|
|
815
|
+
source: string;
|
|
816
|
+
/** The underlying thrown value, when available. */
|
|
817
|
+
originalError?: unknown;
|
|
1090
818
|
};
|
|
819
|
+
|
|
1091
820
|
/**
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
* The combination of fields determines the operation:
|
|
1095
|
-
* - `target` + `values` → cell edit, clear, or external paste
|
|
1096
|
-
* - `target` + `source` → internal paste (+ `cut` for cut-paste)
|
|
1097
|
-
* - `target` + `source` (fill) → fill handle
|
|
1098
|
-
* - `target` + `transform` → transform / revert
|
|
1099
|
-
* - `target` + `delete: true` → mark rows for deletion
|
|
1100
|
-
* - `target` + `delete: false` → restore rows (unmark deletion)
|
|
1101
|
-
* - `insert` + `values` → create a new row
|
|
1102
|
-
*
|
|
1103
|
-
* `values` is always a 2D array. For a single cell edit: `[["newValue"]]`.
|
|
1104
|
-
* For clearing: `[[""]]`. The server interprets dimensions relative to `target`:
|
|
1105
|
-
* a 1×1 `values` applied to a multi-cell target means "fill all cells with this value".
|
|
821
|
+
* A single operation the LLM wants to apply to rows in the current filtered view.
|
|
1106
822
|
*
|
|
1107
|
-
* `
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
823
|
+
* - `edit` — `fn` is `(r, ctx) => void`. Mutates `r` in place. Changed fields
|
|
824
|
+
* become column deltas. Rows with no changes are no-ops.
|
|
825
|
+
* - `delete` — `fn` is `(r, ctx) => boolean`. Truthy means "flag this row for
|
|
826
|
+
* deletion". Soft delete via `DeleteRowCommand`.
|
|
1110
827
|
*/
|
|
1111
|
-
type
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
delete?: boolean;
|
|
1118
|
-
insert?: InsertParams;
|
|
1119
|
-
undo?: boolean;
|
|
1120
|
-
filters?: QueryFilters;
|
|
1121
|
-
sort?: SortState;
|
|
1122
|
-
lockedColumns?: Array<{
|
|
1123
|
-
columnId: string;
|
|
1124
|
-
mode: "all" | "default";
|
|
1125
|
-
}>;
|
|
1126
|
-
};
|
|
1127
|
-
type ExportParams<F = Record<string, unknown>> = {
|
|
1128
|
-
format: "csv" | "tsv" | "xlsx" | "json" | "xml";
|
|
1129
|
-
allRows: boolean;
|
|
1130
|
-
rtl?: boolean;
|
|
1131
|
-
filters?: QueryFilters<F>;
|
|
1132
|
-
sort?: SortState;
|
|
1133
|
-
signal?: AbortSignal;
|
|
1134
|
-
};
|
|
1135
|
-
/** Transform operation descriptor. `type` identifies the operation, optional fields carry parameters. */
|
|
1136
|
-
type TransformParams = {
|
|
1137
|
-
type: string;
|
|
1138
|
-
separator?: string;
|
|
1139
|
-
/** When `true`, the server should delete the dynamic source columns after applying the transform. */
|
|
1140
|
-
deleteSource?: boolean;
|
|
828
|
+
type ChatOp = {
|
|
829
|
+
action: "edit";
|
|
830
|
+
fn: string;
|
|
831
|
+
} | {
|
|
832
|
+
action: "delete";
|
|
833
|
+
fn: string;
|
|
1141
834
|
};
|
|
1142
|
-
/**
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
835
|
+
/**
|
|
836
|
+
* A single chunk in the stream returned from `DataEditorChat.onMessage`.
|
|
837
|
+
*
|
|
838
|
+
* - `status` — progress message shown while processing (e.g. "Analyzing 500 rows...").
|
|
839
|
+
* - `message` — chat reply shown to the user.
|
|
840
|
+
* - `rows` — updated rows to apply to the grid. Matched by `primaryKey`.
|
|
841
|
+
* - `ops` — array of per-row operations (edits and/or deletes) to apply in order.
|
|
842
|
+
*/
|
|
843
|
+
type ChatResponseChunk<TRow extends DataEditorRow = DataEditorRow> = {
|
|
844
|
+
type: "status";
|
|
845
|
+
content: string;
|
|
846
|
+
} | {
|
|
847
|
+
type: "message";
|
|
848
|
+
content: string;
|
|
849
|
+
} | {
|
|
850
|
+
type: "rows";
|
|
851
|
+
content: TRow[];
|
|
852
|
+
} | {
|
|
853
|
+
type: "ops";
|
|
854
|
+
content: ChatOp[];
|
|
1148
855
|
};
|
|
1149
|
-
/**
|
|
1150
|
-
type
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
/**
|
|
1154
|
-
|
|
1155
|
-
/**
|
|
1156
|
-
|
|
856
|
+
/** Status of a row in the chat sample, relative to its origin snapshot. */
|
|
857
|
+
type ChatRowStatus = "new" | "edited" | "original";
|
|
858
|
+
/** A sample row handed to the chat callback, with its current status and validation errors. */
|
|
859
|
+
type ChatRow<TRow extends DataEditorRow = DataEditorRow> = {
|
|
860
|
+
/** Row data keyed by column ID. */
|
|
861
|
+
data: TRow;
|
|
862
|
+
/** Whether the row was newly added, edited, or is unchanged. */
|
|
863
|
+
status: ChatRowStatus;
|
|
864
|
+
/** Validation errors keyed by column ID. */
|
|
865
|
+
errors: Record<string, string[]>;
|
|
866
|
+
/** The source this row belongs to. */
|
|
867
|
+
source: string;
|
|
1157
868
|
};
|
|
1158
|
-
/**
|
|
1159
|
-
type
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
columns?: Array<{
|
|
1169
|
-
id: string;
|
|
1170
|
-
title: string;
|
|
1171
|
-
}>;
|
|
869
|
+
/** Aggregated error count across the current view, grouped by field and message. */
|
|
870
|
+
type ChatErrorSummary = {
|
|
871
|
+
/** Column ID where the error occurred. */
|
|
872
|
+
field: string;
|
|
873
|
+
/** The validation message. */
|
|
874
|
+
message: string;
|
|
875
|
+
/** How many rows hit this error. */
|
|
876
|
+
count: number;
|
|
877
|
+
/** A few example values that triggered the error. */
|
|
878
|
+
examples: string[];
|
|
1172
879
|
};
|
|
1173
880
|
/**
|
|
1174
|
-
*
|
|
1175
|
-
*
|
|
1176
|
-
* stream it, bulk-load it, hand it to a background job. Your call.
|
|
881
|
+
* Context about the current dataset, passed to `loadSuggestions` and extended
|
|
882
|
+
* into `ChatContext` for `onMessage`.
|
|
1177
883
|
*/
|
|
1178
|
-
type
|
|
1179
|
-
/**
|
|
1180
|
-
|
|
1181
|
-
/**
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
|
|
1189
|
-
/**
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
|
|
1193
|
-
/** Number format detected from the file contents. Affects how `"1.234,56"` vs `"1,234.56"` is read. */
|
|
1194
|
-
numberFormat: "EU" | "US";
|
|
1195
|
-
/**
|
|
1196
|
-
* Per-column date disambiguation. Key = CSV header (not column ID).
|
|
1197
|
-
* `"EU"` = day-first, `"US"` = month-first.
|
|
1198
|
-
* Only includes columns where the format was ambiguous and had to be resolved.
|
|
1199
|
-
*/
|
|
1200
|
-
dateFormats: Record<string, "EU" | "US">;
|
|
1201
|
-
/**
|
|
1202
|
-
* Columns the user created during import for unmatched headers.
|
|
1203
|
-
* These don't exist in your schema yet — you decide whether to persist them.
|
|
1204
|
-
*/
|
|
1205
|
-
newColumns: DataEditorColumn[];
|
|
1206
|
-
};
|
|
1207
|
-
/** Params passed to `onFileImport`. The original file, unchanged, plus everything the wizard collected. */
|
|
1208
|
-
type FileImportParams = {
|
|
1209
|
-
/** The original file. Same bytes the user dropped into the browser. */
|
|
1210
|
-
file: File;
|
|
1211
|
-
/** All mapping decisions from the import wizard. */
|
|
1212
|
-
mappings: ImportMappings;
|
|
1213
|
-
/** Display name for this import source. Typically the file name. */
|
|
1214
|
-
sourceName: string;
|
|
1215
|
-
/** Fires when the user cancels the import. */
|
|
1216
|
-
signal?: AbortSignal;
|
|
884
|
+
type ChatDataContext<TRow extends DataEditorRow = DataEditorRow> = {
|
|
885
|
+
/** Full column definitions. */
|
|
886
|
+
columns: DataEditorColumn[];
|
|
887
|
+
/** Row identifier field. */
|
|
888
|
+
primaryKey: keyof TRow;
|
|
889
|
+
/** Total rows in the dataset. */
|
|
890
|
+
totalRowCount: number;
|
|
891
|
+
/** Rows in the current filtered view. */
|
|
892
|
+
filteredRowCount: number;
|
|
893
|
+
/** Sample rows, with status and errors. Size controlled by `sampleSize`. */
|
|
894
|
+
sample: ChatRow<TRow>[];
|
|
895
|
+
/** Aggregated error counts by field and message. */
|
|
896
|
+
errorSummary: ChatErrorSummary[];
|
|
897
|
+
/** Access all rows. Use for full-dataset operations. */
|
|
898
|
+
getRows: () => ChatRow<TRow>[];
|
|
1217
899
|
};
|
|
1218
900
|
/**
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
* and numbers, and resolved value mappings. You get clean, schema-conformant rows.
|
|
901
|
+
* The full context passed to `DataEditorChat.onMessage` when the user sends
|
|
902
|
+
* a prompt. Includes the prompt itself and all dataset context.
|
|
1222
903
|
*/
|
|
1223
|
-
type
|
|
1224
|
-
/**
|
|
1225
|
-
|
|
1226
|
-
/** Display name for this import source. Typically the file name. */
|
|
1227
|
-
sourceName: string;
|
|
1228
|
-
/** Zero-based chunk index. Together with `importId`, uniquely identifies each chunk. */
|
|
1229
|
-
chunkIndex: number;
|
|
1230
|
-
/** `true` on the last chunk. Safe to finalize, run post-import hooks, or trigger validation. */
|
|
1231
|
-
isLastChunk: boolean;
|
|
1232
|
-
/** Transformed rows, keyed by column ID. Ready to store. */
|
|
1233
|
-
rows: Record<string, unknown>[];
|
|
1234
|
-
/** Columns the user created during import. Only present on the first chunk (`chunkIndex === 0`). */
|
|
1235
|
-
newColumns?: DataEditorColumn[];
|
|
1236
|
-
/** Column ID used to match imported rows against existing data. */
|
|
1237
|
-
primaryKey: string;
|
|
1238
|
-
/** Fires when the user cancels mid-import. Clean up any partial state. */
|
|
1239
|
-
signal?: AbortSignal;
|
|
1240
|
-
};
|
|
1241
|
-
/** Your response after processing a chunk. */
|
|
1242
|
-
type RowsImportResponse = {
|
|
1243
|
-
/** How many rows you accepted from this chunk. Drives progress reporting. */
|
|
1244
|
-
accepted: number;
|
|
1245
|
-
/** Per-row errors. `rowIndex` is relative to the chunk (0-based). Surfaced in the UI after import. */
|
|
1246
|
-
errors?: Array<{
|
|
1247
|
-
rowIndex: number;
|
|
1248
|
-
message: string;
|
|
1249
|
-
}>;
|
|
1250
|
-
};
|
|
1251
|
-
/** Params passed to `onSourceRemove` when the user deletes a data source. */
|
|
1252
|
-
type SourceRemoveParams = {
|
|
1253
|
-
/** The source ID to remove. Matches the `id` from `ServerQueryCounts.sources`. */
|
|
1254
|
-
sourceId: string;
|
|
1255
|
-
/** Fires when the user cancels. */
|
|
1256
|
-
signal?: AbortSignal;
|
|
904
|
+
type ChatContext<TRow extends DataEditorRow = DataEditorRow> = ChatDataContext<TRow> & {
|
|
905
|
+
/** The user's chat prompt. */
|
|
906
|
+
message: string;
|
|
1257
907
|
};
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
908
|
+
/**
|
|
909
|
+
* Bring-your-own-AI chat configuration. When provided via the `chat` prop,
|
|
910
|
+
* the editor shows a chat panel alongside the grid. You own the AI
|
|
911
|
+
* integration; the SDK hands you dataset context and renders the streamed
|
|
912
|
+
* response.
|
|
913
|
+
*
|
|
914
|
+
* @example
|
|
915
|
+
* ```ts
|
|
916
|
+
* chat={{
|
|
917
|
+
* sampleSize: 50,
|
|
918
|
+
* onMessage: async function* (context) {
|
|
919
|
+
* yield { type: "status", content: "Thinking..." };
|
|
920
|
+
* const res = await fetch("/api/ai", {
|
|
921
|
+
* method: "POST",
|
|
922
|
+
* body: JSON.stringify({
|
|
923
|
+
* prompt: context.message,
|
|
924
|
+
* columns: context.columns,
|
|
925
|
+
* sample: context.sample.map(r => r.data),
|
|
926
|
+
* errors: context.errorSummary,
|
|
927
|
+
* }),
|
|
928
|
+
* }).then(r => r.json());
|
|
929
|
+
* yield { type: "rows", content: res.updatedRows };
|
|
930
|
+
* yield { type: "ops", content: res.ops };
|
|
931
|
+
* yield { type: "message", content: res.reply };
|
|
932
|
+
* },
|
|
933
|
+
* }}
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
type DataEditorChat<TRow extends DataEditorRow = DataEditorRow> = {
|
|
1272
937
|
/**
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1275
|
-
* Called once per chunk. Awaited before sending the next chunk.
|
|
1276
|
-
* Mutually exclusive with `onFileImport`.
|
|
938
|
+
* How many rows to include in the context sample. The SDK picks a
|
|
939
|
+
* representative slice including rows with errors. When omitted, the SDK decides.
|
|
1277
940
|
*/
|
|
1278
|
-
|
|
1279
|
-
/**
|
|
1280
|
-
|
|
1281
|
-
/**
|
|
1282
|
-
|
|
1283
|
-
/**
|
|
1284
|
-
|
|
1285
|
-
/** Called when the user edits a dynamic column (e.g. renames it). */
|
|
1286
|
-
onColumnEdit?: (params: ColumnEditParams) => Promise<EditResponse | void>;
|
|
941
|
+
sampleSize?: number;
|
|
942
|
+
/** Title shown above the suggestion list when the chat is empty. */
|
|
943
|
+
emptyTitle?: string;
|
|
944
|
+
/** How many suggestions to request from `loadSuggestions`. */
|
|
945
|
+
suggestionsCount?: number;
|
|
946
|
+
/** Optional prompt generator for the empty-state suggestion chips. */
|
|
947
|
+
loadSuggestions?: (context: ChatDataContext<TRow>) => Promise<string[]>;
|
|
1287
948
|
/**
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1290
|
-
*
|
|
949
|
+
* Called when the user sends a message. Receives full dataset context.
|
|
950
|
+
* Returns an async iterable of response chunks — the SDK streams them
|
|
951
|
+
* into the UI.
|
|
1291
952
|
*/
|
|
1292
|
-
|
|
1293
|
-
/**
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
953
|
+
onMessage: (context: ChatContext<TRow>) => AsyncIterable<ChatResponseChunk<TRow>>;
|
|
954
|
+
/** Called when the user cancels a pending request. Use to abort your API call. */
|
|
955
|
+
onCancel?: () => void;
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
type ScaleServerConfig = {
|
|
959
|
+
url: string;
|
|
1297
960
|
};
|
|
1298
961
|
|
|
1299
962
|
/**
|
|
@@ -1483,12 +1146,6 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
|
|
|
1483
1146
|
* ```
|
|
1484
1147
|
*/
|
|
1485
1148
|
loadData?: (onChunk: (rows: TRow[], options?: ChunkSourceOptions) => void) => Promise<void>;
|
|
1486
|
-
/**
|
|
1487
|
-
* Server-delegated mode. When provided, the SDK acts as a rendering head
|
|
1488
|
-
* and delegates data operations (fetching, filtering, sorting, mutations)
|
|
1489
|
-
* to the client's backend via callbacks.
|
|
1490
|
-
*/
|
|
1491
|
-
server?: DataEditorServer<TRow>;
|
|
1492
1149
|
/**
|
|
1493
1150
|
* Called when the user clicks "Submit". Receives the edited data grouped
|
|
1494
1151
|
* by source. Use `actions.reset()` to clear changes after a successful save.
|
|
@@ -1643,6 +1300,11 @@ type DataEditorLocalStorage = false | {
|
|
|
1643
1300
|
type DataEditorCommonProps<TRow extends DataEditorRow = DataEditorRow> = DataEditorBaseProps<TRow> & {
|
|
1644
1301
|
/** Your Updog license key. Validated on each open. */
|
|
1645
1302
|
apiKey: string;
|
|
1303
|
+
/**
|
|
1304
|
+
* @internal
|
|
1305
|
+
* Reserved for future server-delegated mode. Not part of the public API.
|
|
1306
|
+
*/
|
|
1307
|
+
__server?: ScaleServerConfig;
|
|
1646
1308
|
/**
|
|
1647
1309
|
* Controls what the editor stores in `localStorage`. Set to `false` to
|
|
1648
1310
|
* disable all local storage usage.
|
|
@@ -1722,67 +1384,6 @@ type DataEditorInlineProps<TRow extends DataEditorRow = DataEditorRow> = DataEdi
|
|
|
1722
1384
|
*/
|
|
1723
1385
|
type DataEditorProps<TRow extends DataEditorRow = DataEditorRow> = DataEditorModalProps<TRow> | DataEditorInlineProps<TRow>;
|
|
1724
1386
|
|
|
1725
|
-
/**
|
|
1726
|
-
* Creates a validator that rejects empty values.
|
|
1727
|
-
*
|
|
1728
|
-
* @param message - Error message shown when the cell is empty.
|
|
1729
|
-
*
|
|
1730
|
-
* @example
|
|
1731
|
-
* ```ts
|
|
1732
|
-
* const columns = [
|
|
1733
|
-
* { id: "name", title: "Name", validate: [required("Name is required")] },
|
|
1734
|
-
* ];
|
|
1735
|
-
* ```
|
|
1736
|
-
*/
|
|
1737
|
-
declare function required(message: string): CellValidator;
|
|
1738
|
-
/**
|
|
1739
|
-
* Creates a validator that rejects non-numeric values.
|
|
1740
|
-
*
|
|
1741
|
-
* @param message - Error message shown when the value is not a valid number.
|
|
1742
|
-
*/
|
|
1743
|
-
declare function numeric(message: string): CellValidator;
|
|
1744
|
-
/**
|
|
1745
|
-
* Creates a validator that rejects invalid email addresses.
|
|
1746
|
-
*
|
|
1747
|
-
* @param message - Error message shown when the value is not a valid email.
|
|
1748
|
-
*/
|
|
1749
|
-
declare function email(message: string): CellValidator;
|
|
1750
|
-
/**
|
|
1751
|
-
* Creates a validator that rejects values not matching `YYYY-MM-DD` or `DD/MM/YYYY`.
|
|
1752
|
-
*
|
|
1753
|
-
* @param message - Error message shown when the value is not a valid date.
|
|
1754
|
-
*/
|
|
1755
|
-
declare function date(message: string): CellValidator;
|
|
1756
|
-
/**
|
|
1757
|
-
* Creates a validator that ensures this date is on or after the date in another column.
|
|
1758
|
-
*
|
|
1759
|
-
* @param startDateField - Column ID of the start-date field to compare against.
|
|
1760
|
-
* @param message - Error message shown when the end date is before the start date.
|
|
1761
|
-
*
|
|
1762
|
-
* @example
|
|
1763
|
-
* ```ts
|
|
1764
|
-
* const columns = [
|
|
1765
|
-
* { id: "startDate", title: "Start", dependentFields: ["endDate"] },
|
|
1766
|
-
* { id: "endDate", title: "End", validate: [endDateAfterStart("startDate", "End must be after start")] },
|
|
1767
|
-
* ];
|
|
1768
|
-
* ```
|
|
1769
|
-
*/
|
|
1770
|
-
/**
|
|
1771
|
-
* Creates a validator that rejects values not in the allowed set.
|
|
1772
|
-
*
|
|
1773
|
-
* @param values - Array of allowed values (matched by strict equality).
|
|
1774
|
-
* @param message - Error message shown when the value is not in the set.
|
|
1775
|
-
*
|
|
1776
|
-
* @example
|
|
1777
|
-
* ```ts
|
|
1778
|
-
* const columns = [
|
|
1779
|
-
* { id: "status", title: "Status", validate: [oneOf(["active", "inactive"], "Invalid status")] },
|
|
1780
|
-
* ];
|
|
1781
|
-
* ```
|
|
1782
|
-
*/
|
|
1783
|
-
declare function oneOf(values: string[], message: string): CellValidator;
|
|
1784
|
-
declare function endDateAfterStart(startDateField: string, message: string): CellValidator;
|
|
1785
|
-
|
|
1786
1387
|
type Props = DataEditorProps;
|
|
1787
1388
|
/**
|
|
1788
1389
|
* All properties available on the `<updog-editor>` element.
|
|
@@ -1852,5 +1453,3 @@ declare global {
|
|
|
1852
1453
|
"updog-editor": UpdogEditorElement;
|
|
1853
1454
|
}
|
|
1854
1455
|
}
|
|
1855
|
-
|
|
1856
|
-
export { date, email, endDateAfterStart, numeric, oneOf, required };
|