grist-widget-sdk 0.2.0
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/CHANGELOG.md +730 -0
- package/LICENSE +15 -0
- package/README.md +249 -0
- package/dist/advanced.cjs +2749 -0
- package/dist/advanced.cjs.map +1 -0
- package/dist/advanced.d.cts +790 -0
- package/dist/advanced.d.ts +790 -0
- package/dist/advanced.js +825 -0
- package/dist/advanced.js.map +1 -0
- package/dist/chunk-64SVRWW7.js +758 -0
- package/dist/chunk-64SVRWW7.js.map +1 -0
- package/dist/chunk-BNBV24WM.js +479 -0
- package/dist/chunk-BNBV24WM.js.map +1 -0
- package/dist/chunk-ELGVOHFD.js +32 -0
- package/dist/chunk-ELGVOHFD.js.map +1 -0
- package/dist/chunk-GTTD5HPO.js +36 -0
- package/dist/chunk-GTTD5HPO.js.map +1 -0
- package/dist/chunk-JASMM2YC.js +243 -0
- package/dist/chunk-JASMM2YC.js.map +1 -0
- package/dist/chunk-PM3B4WYV.js +12 -0
- package/dist/chunk-PM3B4WYV.js.map +1 -0
- package/dist/chunk-QKXKZ27D.js +1189 -0
- package/dist/chunk-QKXKZ27D.js.map +1 -0
- package/dist/chunk-QZG7SNUG.js +463 -0
- package/dist/chunk-QZG7SNUG.js.map +1 -0
- package/dist/chunk-REV5AUXD.js +25 -0
- package/dist/chunk-REV5AUXD.js.map +1 -0
- package/dist/chunk-XE2SKNLH.js +1641 -0
- package/dist/chunk-XE2SKNLH.js.map +1 -0
- package/dist/create-grist-emulator-C_0I4wax.d.ts +80 -0
- package/dist/create-grist-emulator-DBS6gmiI.d.cts +80 -0
- package/dist/emulator/devtools.cjs +1367 -0
- package/dist/emulator/devtools.cjs.map +1 -0
- package/dist/emulator/devtools.d.cts +46 -0
- package/dist/emulator/devtools.d.ts +46 -0
- package/dist/emulator/devtools.js +480 -0
- package/dist/emulator/devtools.js.map +1 -0
- package/dist/emulator/testing.cjs +2061 -0
- package/dist/emulator/testing.cjs.map +1 -0
- package/dist/emulator/testing.d.cts +50 -0
- package/dist/emulator/testing.d.ts +50 -0
- package/dist/emulator/testing.js +124 -0
- package/dist/emulator/testing.js.map +1 -0
- package/dist/emulator/transports.cjs +1132 -0
- package/dist/emulator/transports.cjs.map +1 -0
- package/dist/emulator/transports.d.cts +37 -0
- package/dist/emulator/transports.d.ts +37 -0
- package/dist/emulator/transports.js +12 -0
- package/dist/emulator/transports.js.map +1 -0
- package/dist/emulator.cjs +1796 -0
- package/dist/emulator.cjs.map +1 -0
- package/dist/emulator.d.cts +107 -0
- package/dist/emulator.d.ts +107 -0
- package/dist/emulator.js +26 -0
- package/dist/emulator.js.map +1 -0
- package/dist/index.cjs +5511 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +825 -0
- package/dist/index.d.ts +825 -0
- package/dist/index.js +2447 -0
- package/dist/index.js.map +1 -0
- package/dist/inline-CRwQQ-GW.d.cts +311 -0
- package/dist/inline-QitZwXKP.d.ts +311 -0
- package/dist/templates-BC7FoSdW.d.ts +24 -0
- package/dist/templates-DBq719O_.d.cts +24 -0
- package/dist/types-Fb2wplkv.d.cts +228 -0
- package/dist/types-Fb2wplkv.d.ts +228 -0
- package/dist/use-grist-widget-options-from-context-BFhQBGRY.d.ts +522 -0
- package/dist/use-grist-widget-options-from-context-qpFMdoBJ.d.cts +522 -0
- package/package.json +131 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { k as GristReplicaDocument, n as GristReplicaTable, w as GristWidgetColumnMap } from './types-Fb2wplkv.js';
|
|
2
|
+
export { C as CreateGristEmulatorOptions, G as GristEmulator, c as createGristEmulator } from './create-grist-emulator-C_0I4wax.js';
|
|
3
|
+
export { p as presets } from './templates-BC7FoSdW.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { a as EmulatorColumn, b as EmulatorDocumentState } from './inline-QitZwXKP.js';
|
|
6
|
+
export { E as EmulatorApiBundle, c as EmulatorEvent, d as EmulatorRowId, e as EmulatorTable, f as EmulatorTransport, I as InlineGristGlobal } from './inline-QitZwXKP.js';
|
|
7
|
+
|
|
8
|
+
declare function safeParseDocument(input: unknown): z.ZodSafeParseResult<{
|
|
9
|
+
generatedAt: string;
|
|
10
|
+
tables: Record<string, {
|
|
11
|
+
label?: string | undefined;
|
|
12
|
+
columns?: Record<string, {
|
|
13
|
+
colRef?: number | undefined;
|
|
14
|
+
type?: string | undefined;
|
|
15
|
+
label?: string | undefined;
|
|
16
|
+
parentPos?: number | undefined;
|
|
17
|
+
isFormula?: boolean | undefined;
|
|
18
|
+
formulaKind?: "none" | "computed" | "trigger" | "empty_slot" | undefined;
|
|
19
|
+
formula?: string | undefined;
|
|
20
|
+
description?: string | undefined;
|
|
21
|
+
widgetOptions?: Record<string, unknown> | undefined;
|
|
22
|
+
displayColRef?: number | undefined;
|
|
23
|
+
visibleColRef?: number | undefined;
|
|
24
|
+
}> | undefined;
|
|
25
|
+
rows?: {
|
|
26
|
+
[x: string]: unknown;
|
|
27
|
+
id: number;
|
|
28
|
+
}[] | undefined;
|
|
29
|
+
rowCount?: number | undefined;
|
|
30
|
+
dataOmitted?: boolean | undefined;
|
|
31
|
+
dataOmittedReason?: string | undefined;
|
|
32
|
+
error?: string | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
source?: string | undefined;
|
|
35
|
+
docName?: string | undefined;
|
|
36
|
+
mode?: "schema-only" | "schema+samples" | "schema+data" | undefined;
|
|
37
|
+
selection?: {
|
|
38
|
+
tableId?: string | undefined;
|
|
39
|
+
rowId?: number | "new" | null | undefined;
|
|
40
|
+
mappings?: unknown;
|
|
41
|
+
cursor?: unknown;
|
|
42
|
+
} | undefined;
|
|
43
|
+
widgetOptions?: Record<string, unknown> | undefined;
|
|
44
|
+
widgetInteraction?: unknown;
|
|
45
|
+
configuration?: {
|
|
46
|
+
requiredAccess?: string | undefined;
|
|
47
|
+
columns?: unknown;
|
|
48
|
+
allowSelectBy?: boolean | undefined;
|
|
49
|
+
hasCustomOptions?: boolean | undefined;
|
|
50
|
+
} | undefined;
|
|
51
|
+
accessToken?: {
|
|
52
|
+
token: string;
|
|
53
|
+
baseUrl: string;
|
|
54
|
+
ttlMsecs: number;
|
|
55
|
+
} | null | undefined;
|
|
56
|
+
}>;
|
|
57
|
+
declare function parseDocument(input: unknown): GristReplicaDocument;
|
|
58
|
+
|
|
59
|
+
/** Replica table for {@link createDocument}; columns may include `formulaFn` / `inferredFormula` (emulator-only). */
|
|
60
|
+
type CreateDocumentTableInput = Omit<GristReplicaTable, "columns"> & {
|
|
61
|
+
columns?: Record<string, EmulatorColumn>;
|
|
62
|
+
};
|
|
63
|
+
/** Replica document for {@link createDocument}; widens table columns to {@link EmulatorColumn}. */
|
|
64
|
+
type CreateDocumentInput = Omit<GristReplicaDocument, "tables"> & {
|
|
65
|
+
tables: Record<string, CreateDocumentTableInput>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Ensure `formula` (original) and `inferredFormula` strings exist alongside optional `formulaFn`.
|
|
69
|
+
*/
|
|
70
|
+
declare function enrichEmulatorColumnMetadata(col: EmulatorColumn): EmulatorColumn;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Pure action engine: applies Grist user actions to an
|
|
74
|
+
* {@link EmulatorDocumentState} and emits the resulting events on the bus.
|
|
75
|
+
*
|
|
76
|
+
* This is the single place where state mutates. Every API impl ultimately
|
|
77
|
+
* routes through `applyUserActions` so behaviour is consistent regardless of
|
|
78
|
+
* the surface (`grist.docApi.applyUserActions`, `selectedTable.create`,
|
|
79
|
+
* `setCursorPos`, etc.).
|
|
80
|
+
*
|
|
81
|
+
* Supported user actions:
|
|
82
|
+
* - AddRecord, BulkAddRecord
|
|
83
|
+
* - UpdateRecord, BulkUpdateRecord
|
|
84
|
+
* - RemoveRecord, BulkRemoveRecord
|
|
85
|
+
* - AddColumn, RemoveColumn, RenameColumn, ModifyColumn
|
|
86
|
+
* - AddTable, RemoveTable, RenameTable
|
|
87
|
+
*
|
|
88
|
+
* Unknown actions throw a structured error instead of silently succeeding,
|
|
89
|
+
* which surfaces protocol gaps loudly during widget development.
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
declare class EmulatorActionError extends Error {
|
|
93
|
+
readonly action: unknown;
|
|
94
|
+
constructor(action: unknown, message: string);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Resolves the `mappings` payload that `CustomSectionAPI.mappings()` returns.
|
|
99
|
+
*
|
|
100
|
+
* The playground emulator does **not** infer logical → real columns from
|
|
101
|
+
* names. Mappings come only from `state.selection.mappings` (playground
|
|
102
|
+
* document inspector or tests). When unset, returns `null`.
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
declare function resolveMappings(state: EmulatorDocumentState): GristWidgetColumnMap | null;
|
|
106
|
+
|
|
107
|
+
export { type CreateDocumentInput, type CreateDocumentTableInput, EmulatorActionError, EmulatorColumn, EmulatorDocumentState, GristReplicaDocument, enrichEmulatorColumnMetadata, parseDocument, resolveMappings, safeParseDocument };
|
package/dist/emulator.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGristEmulator,
|
|
3
|
+
parseDocument,
|
|
4
|
+
presets,
|
|
5
|
+
safeParseDocument
|
|
6
|
+
} from "./chunk-QZG7SNUG.js";
|
|
7
|
+
import {
|
|
8
|
+
EmulatorActionError,
|
|
9
|
+
enrichEmulatorColumnMetadata
|
|
10
|
+
} from "./chunk-QKXKZ27D.js";
|
|
11
|
+
import "./chunk-GTTD5HPO.js";
|
|
12
|
+
import "./chunk-ELGVOHFD.js";
|
|
13
|
+
import {
|
|
14
|
+
resolveMappings
|
|
15
|
+
} from "./chunk-PM3B4WYV.js";
|
|
16
|
+
import "./chunk-64SVRWW7.js";
|
|
17
|
+
export {
|
|
18
|
+
EmulatorActionError,
|
|
19
|
+
createGristEmulator,
|
|
20
|
+
enrichEmulatorColumnMetadata,
|
|
21
|
+
parseDocument,
|
|
22
|
+
presets,
|
|
23
|
+
resolveMappings,
|
|
24
|
+
safeParseDocument
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=emulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|