grist-widget-sdk 0.3.26 → 0.4.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 +53 -0
- package/README.md +1 -1
- package/dist/app.cjs +1139 -4336
- package/dist/app.cjs.map +1 -1
- package/dist/app.d.cts +1 -3
- package/dist/app.d.ts +1 -3
- package/dist/app.js +9 -517
- package/dist/app.js.map +1 -1
- package/dist/chunk-4ZGVKGDF.js +204 -0
- package/dist/chunk-4ZGVKGDF.js.map +1 -0
- package/dist/{chunk-YQNMIL33.js → chunk-B5ZZNLVS.js} +528 -181
- package/dist/chunk-B5ZZNLVS.js.map +1 -0
- package/dist/chunk-O7NY46QY.js +1830 -0
- package/dist/chunk-O7NY46QY.js.map +1 -0
- package/dist/chunk-P6VTEKWO.js +618 -0
- package/dist/chunk-P6VTEKWO.js.map +1 -0
- package/dist/emulator/testing.cjs +2084 -391
- package/dist/emulator/testing.cjs.map +1 -1
- package/dist/emulator/testing.d.cts +55 -7
- package/dist/emulator/testing.d.ts +55 -7
- package/dist/emulator/testing.js +144 -19
- package/dist/emulator/testing.js.map +1 -1
- package/dist/emulator.cjs +59 -249
- package/dist/emulator.cjs.map +1 -1
- package/dist/emulator.d.cts +3 -5
- package/dist/emulator.d.ts +3 -5
- package/dist/emulator.js +5 -11
- package/dist/index.cjs +1373 -4859
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -260
- package/dist/index.d.ts +81 -260
- package/dist/index.js +8 -161
- package/dist/{inline-C7DkvuET.d.cts → templates-CGmRIQBV.d.cts} +89 -35
- package/dist/{inline-DpcT8tV9.d.ts → templates-Cq94qOcf.d.ts} +89 -35
- package/dist/{types-D3JxUCfL.d.cts → types-DBStn0Dk.d.cts} +2 -26
- package/dist/{types-D3JxUCfL.d.ts → types-DBStn0Dk.d.ts} +2 -26
- package/dist/use-grist-BK0eke9K.d.cts +358 -0
- package/dist/use-grist-C5DMZ3wU.d.ts +358 -0
- package/package.json +8 -37
- package/dist/advanced.cjs +0 -2799
- package/dist/advanced.cjs.map +0 -1
- package/dist/advanced.d.cts +0 -822
- package/dist/advanced.d.ts +0 -822
- package/dist/advanced.js +0 -875
- package/dist/advanced.js.map +0 -1
- package/dist/chunk-22U7WAY3.js +0 -463
- package/dist/chunk-22U7WAY3.js.map +0 -1
- package/dist/chunk-64SVRWW7.js +0 -758
- package/dist/chunk-64SVRWW7.js.map +0 -1
- package/dist/chunk-ELGVOHFD.js +0 -32
- package/dist/chunk-ELGVOHFD.js.map +0 -1
- package/dist/chunk-EPEBKXVN.js +0 -470
- package/dist/chunk-EPEBKXVN.js.map +0 -1
- package/dist/chunk-GTTD5HPO.js +0 -36
- package/dist/chunk-GTTD5HPO.js.map +0 -1
- package/dist/chunk-JASMM2YC.js +0 -243
- package/dist/chunk-JASMM2YC.js.map +0 -1
- package/dist/chunk-N3X46JW2.js +0 -37
- package/dist/chunk-N3X46JW2.js.map +0 -1
- package/dist/chunk-PDGEZ24B.js +0 -2366
- package/dist/chunk-PDGEZ24B.js.map +0 -1
- package/dist/chunk-PM3B4WYV.js +0 -12
- package/dist/chunk-PM3B4WYV.js.map +0 -1
- package/dist/chunk-REV5AUXD.js +0 -25
- package/dist/chunk-REV5AUXD.js.map +0 -1
- package/dist/chunk-TZB3OZA6.js +0 -1630
- package/dist/chunk-TZB3OZA6.js.map +0 -1
- package/dist/chunk-YQNMIL33.js.map +0 -1
- package/dist/create-grist-emulator-BCqp1BF9.d.ts +0 -81
- package/dist/create-grist-emulator-DBM8OSIR.d.cts +0 -81
- package/dist/emulator/devtools.cjs +0 -1404
- package/dist/emulator/devtools.cjs.map +0 -1
- package/dist/emulator/devtools.d.cts +0 -48
- package/dist/emulator/devtools.d.ts +0 -48
- package/dist/emulator/devtools.js +0 -508
- package/dist/emulator/devtools.js.map +0 -1
- package/dist/emulator/transports.cjs +0 -1132
- package/dist/emulator/transports.cjs.map +0 -1
- package/dist/emulator/transports.d.cts +0 -38
- package/dist/emulator/transports.d.ts +0 -38
- package/dist/emulator/transports.js +0 -12
- package/dist/emulator/transports.js.map +0 -1
- package/dist/templates-8k2LKoO-.d.cts +0 -24
- package/dist/templates-DIwi_mvI.d.ts +0 -24
- package/dist/use-grist-reads-DUMvJgV7.d.ts +0 -480
- package/dist/use-grist-reads-DpjVuI0H.d.cts +0 -480
- package/dist/use-grist-types-DdOLEJXN.d.cts +0 -499
- package/dist/use-grist-types-kwxoFeub.d.ts +0 -499
- package/dist/use-grist-widget-options-from-context-CGOlQ5Vc.d.cts +0 -43
- package/dist/use-grist-widget-options-from-context-CGOlQ5Vc.d.ts +0 -43
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as GristCursorPos, d as GristWidgetInteraction, b as GristWidgetColumnMap, e as GristReplicaColumn, f as GristRowRecord, g as GristReplicaSelection, h as GristWidgetConfiguration, i as GristReadyOptions, j as GristFetchSelectedOptions, k as GristTableOperations, G as GristReplicaDocument } from './types-DBStn0Dk.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Tiny pub-sub used to broadcast every emulator state change to:
|
|
@@ -108,7 +108,7 @@ type EmulatorDocumentState = {
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Type-only signatures of the Grist plugin interfaces that the emulator
|
|
111
|
-
* exposes to the widget
|
|
111
|
+
* exposes to the widget.
|
|
112
112
|
*
|
|
113
113
|
* These mirror the upstream `grist-plugin-api` contracts. We re-declare them
|
|
114
114
|
* here instead of `import`ing the upstream types because:
|
|
@@ -182,7 +182,7 @@ type CommandApiImpl = {
|
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
184
|
* Bundles the six host-side Grist API implementations into one record so
|
|
185
|
-
*
|
|
185
|
+
* inline transport can wire them up.
|
|
186
186
|
*/
|
|
187
187
|
|
|
188
188
|
type EmulatorApiBundle = {
|
|
@@ -208,26 +208,6 @@ type EmulatorTransport = {
|
|
|
208
208
|
/** Replays the post-ready bootstrap (options + cursor + data) as if the widget had just connected. */
|
|
209
209
|
emitInitialState: () => void;
|
|
210
210
|
};
|
|
211
|
-
type TransportContext = {
|
|
212
|
-
state: EmulatorDocumentState;
|
|
213
|
-
bus: EventBus;
|
|
214
|
-
api: EmulatorApiBundle;
|
|
215
|
-
/** Initial document theme replayed on widget ready (host message channel). */
|
|
216
|
-
initialTheme?: "light" | "dark";
|
|
217
|
-
/**
|
|
218
|
-
* Information piggybacked on `onOptions`. Same as `state.widgetInteraction`
|
|
219
|
-
* by default but transports may augment it (e.g. `access_level` derived
|
|
220
|
-
* from `state.configuration.requiredAccess`).
|
|
221
|
-
*/
|
|
222
|
-
buildInteraction?: () => GristWidgetInteraction;
|
|
223
|
-
/**
|
|
224
|
-
* Cursor sentinel sent on initial connection. Defaults to the current
|
|
225
|
-
* `state.selection.rowId` (which can be `null`, `"new"`, or a numeric id).
|
|
226
|
-
*/
|
|
227
|
-
initialCursor?: () => number | "new" | null;
|
|
228
|
-
/** Optional cursor sent alongside `onRecord` payloads. */
|
|
229
|
-
cursor?: () => GristCursorPos | undefined;
|
|
230
|
-
};
|
|
231
211
|
|
|
232
212
|
/**
|
|
233
213
|
* Inline transport — synthesises a `window.grist` global wired directly to
|
|
@@ -291,22 +271,96 @@ type InlineGristGlobal = {
|
|
|
291
271
|
};
|
|
292
272
|
on: (eventName: string, listener: (...args: unknown[]) => void) => () => void;
|
|
293
273
|
};
|
|
294
|
-
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Top-level emulator factory. Produces a fully-wired emulator instance:
|
|
277
|
+
*
|
|
278
|
+
* - typed in-memory document state,
|
|
279
|
+
* - shared event bus,
|
|
280
|
+
* - the six host API impls,
|
|
281
|
+
* - the inline transport, which installs `grist` on the page,
|
|
282
|
+
* - imperative helpers (`mutate`, `apply`, `selectRow`, `selectTable`)
|
|
283
|
+
* that drive the document via the action engine and emit corresponding
|
|
284
|
+
* events.
|
|
285
|
+
*
|
|
286
|
+
* The instance is multi-instance friendly: nothing is stored on `window`.
|
|
287
|
+
*/
|
|
288
|
+
|
|
289
|
+
type CreateGristEmulatorOptions = {
|
|
290
|
+
/** The starting document (must satisfy {@link parseDocument}). */
|
|
291
|
+
document: GristReplicaDocument;
|
|
292
|
+
/** Installs `grist` on `target` (default: the global object). */
|
|
293
|
+
transport?: {
|
|
294
|
+
kind: "inline";
|
|
295
|
+
target?: Window & typeof globalThis;
|
|
296
|
+
};
|
|
297
|
+
/** Initial widget options exposed via `WidgetAPI`. */
|
|
298
|
+
widgetOptions?: Record<string, unknown>;
|
|
299
|
+
/**
|
|
300
|
+
* Initial widget interaction info (`access_level` and friends) sent
|
|
301
|
+
* alongside `onOptions`. Without an `access_level`, Grist grants the access
|
|
302
|
+
* the widget requests in `grist.ready()`.
|
|
303
|
+
*/
|
|
304
|
+
widgetInteraction?: Record<string, unknown>;
|
|
305
|
+
/** Initial document theme replayed on widget ready (host `message` channel). */
|
|
306
|
+
initialTheme?: "light" | "dark";
|
|
307
|
+
};
|
|
308
|
+
type GristEmulator = {
|
|
309
|
+
/** Underlying mutable document. Treat as read-only outside of `mutate(...)`. */
|
|
310
|
+
state: EmulatorDocumentState;
|
|
311
|
+
bus: EventBus;
|
|
312
|
+
api: EmulatorApiBundle;
|
|
313
|
+
transport: EmulatorTransport;
|
|
314
|
+
/** Synthesised `grist` global (only for the inline transport). */
|
|
315
|
+
grist?: InlineGristGlobal;
|
|
316
|
+
/** Apply a list of Grist user actions; emits the matching events. */
|
|
317
|
+
apply: (actions: unknown[][]) => {
|
|
318
|
+
retValues: unknown[];
|
|
319
|
+
};
|
|
320
|
+
/** Convenience helpers for tests and demos. */
|
|
321
|
+
mutate: {
|
|
322
|
+
addRow: (tableId: string, fields: Record<string, unknown>) => number;
|
|
323
|
+
updateRow: (tableId: string, rowId: number, fields: Record<string, unknown>) => void;
|
|
324
|
+
removeRow: (tableId: string, rowId: number) => void;
|
|
325
|
+
};
|
|
326
|
+
selectRow: (rowId: number | "new" | null) => void;
|
|
327
|
+
selectTable: (tableId: string) => void;
|
|
295
328
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* `contentWindow`) to install it in another realm.
|
|
329
|
+
* Set logical→real column mappings, as a user mapping columns in Grist would.
|
|
330
|
+
* Pass `undefined` to clear — `mappings()` becomes `null` until set again.
|
|
299
331
|
*/
|
|
300
|
-
|
|
332
|
+
setColumnMappings: (mappings: GristWidgetColumnMap | undefined) => void;
|
|
333
|
+
setOptions: (options: Record<string, unknown>) => Promise<void>;
|
|
334
|
+
setInteraction: (interaction: Record<string, unknown>) => void;
|
|
335
|
+
/** Host theme controls (`grist.on("message")` / `msg.theme`). */
|
|
336
|
+
theme: {
|
|
337
|
+
set: (theme: "light" | "dark") => void;
|
|
338
|
+
};
|
|
339
|
+
/** Tear down the emulator. Idempotent. */
|
|
340
|
+
dispose: () => void;
|
|
301
341
|
};
|
|
342
|
+
declare function createGristEmulator(options: CreateGristEmulatorOptions): GristEmulator;
|
|
343
|
+
|
|
302
344
|
/**
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* the
|
|
345
|
+
* Document templates exposed at the top of the emulator API.
|
|
346
|
+
*
|
|
347
|
+
* Templates return plain data — they don't allocate state, the caller passes
|
|
348
|
+
* the returned value into `createGristEmulator(...)` which performs the allocation.
|
|
306
349
|
*/
|
|
307
|
-
|
|
308
|
-
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Useful templates for quick demos and tests.
|
|
353
|
+
*/
|
|
354
|
+
declare const presets: {
|
|
355
|
+
/**
|
|
356
|
+
* Default starter fixture for demos / sandboxes that need a neutral document
|
|
357
|
+
* without choosing a domain-specific preset.
|
|
358
|
+
*/
|
|
359
|
+
defaultTemplate(): GristReplicaDocument;
|
|
360
|
+
blank(): GristReplicaDocument;
|
|
361
|
+
todoList(): GristReplicaDocument;
|
|
362
|
+
contacts(): GristReplicaDocument;
|
|
309
363
|
};
|
|
310
364
|
|
|
311
|
-
export {
|
|
312
|
-
export type {
|
|
365
|
+
export { createGristEmulator as g, presets as p };
|
|
366
|
+
export type { CreateGristEmulatorOptions as C, EmulatorColumn as E, GristEmulator as G, InlineGristGlobal as I, EmulatorDocumentState as a, EmulatorApiBundle as b, EmulatorEvent as c, EmulatorRowId as d, EmulatorTable as e, EmulatorTransport as f };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as GristCursorPos, d as GristWidgetInteraction, b as GristWidgetColumnMap, e as GristReplicaColumn, f as GristRowRecord, g as GristReplicaSelection, h as GristWidgetConfiguration, i as GristReadyOptions, j as GristFetchSelectedOptions, k as GristTableOperations, G as GristReplicaDocument } from './types-DBStn0Dk.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Tiny pub-sub used to broadcast every emulator state change to:
|
|
@@ -108,7 +108,7 @@ type EmulatorDocumentState = {
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Type-only signatures of the Grist plugin interfaces that the emulator
|
|
111
|
-
* exposes to the widget
|
|
111
|
+
* exposes to the widget.
|
|
112
112
|
*
|
|
113
113
|
* These mirror the upstream `grist-plugin-api` contracts. We re-declare them
|
|
114
114
|
* here instead of `import`ing the upstream types because:
|
|
@@ -182,7 +182,7 @@ type CommandApiImpl = {
|
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
184
|
* Bundles the six host-side Grist API implementations into one record so
|
|
185
|
-
*
|
|
185
|
+
* inline transport can wire them up.
|
|
186
186
|
*/
|
|
187
187
|
|
|
188
188
|
type EmulatorApiBundle = {
|
|
@@ -208,26 +208,6 @@ type EmulatorTransport = {
|
|
|
208
208
|
/** Replays the post-ready bootstrap (options + cursor + data) as if the widget had just connected. */
|
|
209
209
|
emitInitialState: () => void;
|
|
210
210
|
};
|
|
211
|
-
type TransportContext = {
|
|
212
|
-
state: EmulatorDocumentState;
|
|
213
|
-
bus: EventBus;
|
|
214
|
-
api: EmulatorApiBundle;
|
|
215
|
-
/** Initial document theme replayed on widget ready (host message channel). */
|
|
216
|
-
initialTheme?: "light" | "dark";
|
|
217
|
-
/**
|
|
218
|
-
* Information piggybacked on `onOptions`. Same as `state.widgetInteraction`
|
|
219
|
-
* by default but transports may augment it (e.g. `access_level` derived
|
|
220
|
-
* from `state.configuration.requiredAccess`).
|
|
221
|
-
*/
|
|
222
|
-
buildInteraction?: () => GristWidgetInteraction;
|
|
223
|
-
/**
|
|
224
|
-
* Cursor sentinel sent on initial connection. Defaults to the current
|
|
225
|
-
* `state.selection.rowId` (which can be `null`, `"new"`, or a numeric id).
|
|
226
|
-
*/
|
|
227
|
-
initialCursor?: () => number | "new" | null;
|
|
228
|
-
/** Optional cursor sent alongside `onRecord` payloads. */
|
|
229
|
-
cursor?: () => GristCursorPos | undefined;
|
|
230
|
-
};
|
|
231
211
|
|
|
232
212
|
/**
|
|
233
213
|
* Inline transport — synthesises a `window.grist` global wired directly to
|
|
@@ -291,22 +271,96 @@ type InlineGristGlobal = {
|
|
|
291
271
|
};
|
|
292
272
|
on: (eventName: string, listener: (...args: unknown[]) => void) => () => void;
|
|
293
273
|
};
|
|
294
|
-
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Top-level emulator factory. Produces a fully-wired emulator instance:
|
|
277
|
+
*
|
|
278
|
+
* - typed in-memory document state,
|
|
279
|
+
* - shared event bus,
|
|
280
|
+
* - the six host API impls,
|
|
281
|
+
* - the inline transport, which installs `grist` on the page,
|
|
282
|
+
* - imperative helpers (`mutate`, `apply`, `selectRow`, `selectTable`)
|
|
283
|
+
* that drive the document via the action engine and emit corresponding
|
|
284
|
+
* events.
|
|
285
|
+
*
|
|
286
|
+
* The instance is multi-instance friendly: nothing is stored on `window`.
|
|
287
|
+
*/
|
|
288
|
+
|
|
289
|
+
type CreateGristEmulatorOptions = {
|
|
290
|
+
/** The starting document (must satisfy {@link parseDocument}). */
|
|
291
|
+
document: GristReplicaDocument;
|
|
292
|
+
/** Installs `grist` on `target` (default: the global object). */
|
|
293
|
+
transport?: {
|
|
294
|
+
kind: "inline";
|
|
295
|
+
target?: Window & typeof globalThis;
|
|
296
|
+
};
|
|
297
|
+
/** Initial widget options exposed via `WidgetAPI`. */
|
|
298
|
+
widgetOptions?: Record<string, unknown>;
|
|
299
|
+
/**
|
|
300
|
+
* Initial widget interaction info (`access_level` and friends) sent
|
|
301
|
+
* alongside `onOptions`. Without an `access_level`, Grist grants the access
|
|
302
|
+
* the widget requests in `grist.ready()`.
|
|
303
|
+
*/
|
|
304
|
+
widgetInteraction?: Record<string, unknown>;
|
|
305
|
+
/** Initial document theme replayed on widget ready (host `message` channel). */
|
|
306
|
+
initialTheme?: "light" | "dark";
|
|
307
|
+
};
|
|
308
|
+
type GristEmulator = {
|
|
309
|
+
/** Underlying mutable document. Treat as read-only outside of `mutate(...)`. */
|
|
310
|
+
state: EmulatorDocumentState;
|
|
311
|
+
bus: EventBus;
|
|
312
|
+
api: EmulatorApiBundle;
|
|
313
|
+
transport: EmulatorTransport;
|
|
314
|
+
/** Synthesised `grist` global (only for the inline transport). */
|
|
315
|
+
grist?: InlineGristGlobal;
|
|
316
|
+
/** Apply a list of Grist user actions; emits the matching events. */
|
|
317
|
+
apply: (actions: unknown[][]) => {
|
|
318
|
+
retValues: unknown[];
|
|
319
|
+
};
|
|
320
|
+
/** Convenience helpers for tests and demos. */
|
|
321
|
+
mutate: {
|
|
322
|
+
addRow: (tableId: string, fields: Record<string, unknown>) => number;
|
|
323
|
+
updateRow: (tableId: string, rowId: number, fields: Record<string, unknown>) => void;
|
|
324
|
+
removeRow: (tableId: string, rowId: number) => void;
|
|
325
|
+
};
|
|
326
|
+
selectRow: (rowId: number | "new" | null) => void;
|
|
327
|
+
selectTable: (tableId: string) => void;
|
|
295
328
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* `contentWindow`) to install it in another realm.
|
|
329
|
+
* Set logical→real column mappings, as a user mapping columns in Grist would.
|
|
330
|
+
* Pass `undefined` to clear — `mappings()` becomes `null` until set again.
|
|
299
331
|
*/
|
|
300
|
-
|
|
332
|
+
setColumnMappings: (mappings: GristWidgetColumnMap | undefined) => void;
|
|
333
|
+
setOptions: (options: Record<string, unknown>) => Promise<void>;
|
|
334
|
+
setInteraction: (interaction: Record<string, unknown>) => void;
|
|
335
|
+
/** Host theme controls (`grist.on("message")` / `msg.theme`). */
|
|
336
|
+
theme: {
|
|
337
|
+
set: (theme: "light" | "dark") => void;
|
|
338
|
+
};
|
|
339
|
+
/** Tear down the emulator. Idempotent. */
|
|
340
|
+
dispose: () => void;
|
|
301
341
|
};
|
|
342
|
+
declare function createGristEmulator(options: CreateGristEmulatorOptions): GristEmulator;
|
|
343
|
+
|
|
302
344
|
/**
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* the
|
|
345
|
+
* Document templates exposed at the top of the emulator API.
|
|
346
|
+
*
|
|
347
|
+
* Templates return plain data — they don't allocate state, the caller passes
|
|
348
|
+
* the returned value into `createGristEmulator(...)` which performs the allocation.
|
|
306
349
|
*/
|
|
307
|
-
|
|
308
|
-
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Useful templates for quick demos and tests.
|
|
353
|
+
*/
|
|
354
|
+
declare const presets: {
|
|
355
|
+
/**
|
|
356
|
+
* Default starter fixture for demos / sandboxes that need a neutral document
|
|
357
|
+
* without choosing a domain-specific preset.
|
|
358
|
+
*/
|
|
359
|
+
defaultTemplate(): GristReplicaDocument;
|
|
360
|
+
blank(): GristReplicaDocument;
|
|
361
|
+
todoList(): GristReplicaDocument;
|
|
362
|
+
contacts(): GristReplicaDocument;
|
|
309
363
|
};
|
|
310
364
|
|
|
311
|
-
export {
|
|
312
|
-
export type {
|
|
365
|
+
export { createGristEmulator as g, presets as p };
|
|
366
|
+
export type { CreateGristEmulatorOptions as C, EmulatorColumn as E, GristEmulator as G, InlineGristGlobal as I, EmulatorDocumentState as a, EmulatorApiBundle as b, EmulatorEvent as c, EmulatorRowId as d, EmulatorTable as e, EmulatorTransport as f };
|
|
@@ -86,7 +86,7 @@ type GristColumnToMap = {
|
|
|
86
86
|
strictType?: boolean;
|
|
87
87
|
};
|
|
88
88
|
/** Argument shape for `grist.ready({ columns })`. */
|
|
89
|
-
type GristColumnsToMap =
|
|
89
|
+
type GristColumnsToMap = ReadonlyArray<string | GristColumnToMap>;
|
|
90
90
|
/**
|
|
91
91
|
* Mapping returned by Grist between logical widget column names and real table column ids.
|
|
92
92
|
* Single mappings are `string`; `allowMultiple` columns are `string[]`.
|
|
@@ -103,12 +103,6 @@ type GristReadyOptions = {
|
|
|
103
103
|
allowSelectBy?: boolean;
|
|
104
104
|
hasCustomOptions?: boolean;
|
|
105
105
|
onEditOptions?: () => void | Promise<void>;
|
|
106
|
-
/** Passed to availability detection (default 10). */
|
|
107
|
-
availabilityMaxAttempts?: number;
|
|
108
|
-
/** Ms between availability polls (default 1000). */
|
|
109
|
-
availabilityIntervalMs?: number;
|
|
110
|
-
/** Log when the page is not iframe-embedded (default false). */
|
|
111
|
-
logWhenNotEmbedded?: boolean;
|
|
112
106
|
};
|
|
113
107
|
/** Optional second argument to `docApi.applyUserActions`. */
|
|
114
108
|
type GristApplyUserActionsOptions = {
|
|
@@ -206,23 +200,5 @@ type GristTableOperations = {
|
|
|
206
200
|
upsert: (records: GristTableUpsertRecord | GristTableUpsertRecord[], options?: GristTableUpsertOptions) => Promise<void>;
|
|
207
201
|
destroy: (recordIds: number | number[]) => Promise<void>;
|
|
208
202
|
};
|
|
209
|
-
/** Subset of `grist.docApi` from https://docs.getgrist.com/grist-plugin-api.js */
|
|
210
|
-
type GristDocApi = {
|
|
211
|
-
getDocName: () => Promise<string> | string;
|
|
212
|
-
listTables: () => Promise<string[]> | string[];
|
|
213
|
-
fetchTable: (tableId: string) => Promise<Record<string, unknown[]>>;
|
|
214
|
-
applyUserActions: (actions: unknown[][], options?: GristApplyUserActionsOptions) => Promise<unknown>;
|
|
215
|
-
/** Present when the widget requested sufficient access (e.g. full). */
|
|
216
|
-
getAccessToken?: (options?: {
|
|
217
|
-
readOnly?: boolean;
|
|
218
|
-
}) => Promise<{
|
|
219
|
-
token: string;
|
|
220
|
-
baseUrl: string;
|
|
221
|
-
}>;
|
|
222
|
-
/** Current section's table data (often smaller than {@link fetchTable} for the whole table). */
|
|
223
|
-
fetchSelectedTable?: (options?: GristFetchSelectedOptions) => Promise<Record<string, unknown[]>>;
|
|
224
|
-
/** Single row in the current section by numeric row id. */
|
|
225
|
-
fetchSelectedRecord?: (rowId: number, options?: GristFetchSelectedOptions) => Promise<Record<string, unknown>>;
|
|
226
|
-
};
|
|
227
203
|
|
|
228
|
-
export type {
|
|
204
|
+
export type { GristReplicaDocument as G, GristReplicaTable as a, GristWidgetColumnMap as b, GristCursorPos as c, GristWidgetInteraction as d, GristReplicaColumn as e, GristRowRecord as f, GristReplicaSelection as g, GristWidgetConfiguration as h, GristReadyOptions as i, GristFetchSelectedOptions as j, GristTableOperations as k, GristRequiredAccess as l, GristDocumentMode as m, GristFormulaKind as n, GristApplyUserActionsOptions as o, GristColumnToMap as p, GristColumnsToMap as q, GristReplicaRow as r };
|
|
@@ -86,7 +86,7 @@ type GristColumnToMap = {
|
|
|
86
86
|
strictType?: boolean;
|
|
87
87
|
};
|
|
88
88
|
/** Argument shape for `grist.ready({ columns })`. */
|
|
89
|
-
type GristColumnsToMap =
|
|
89
|
+
type GristColumnsToMap = ReadonlyArray<string | GristColumnToMap>;
|
|
90
90
|
/**
|
|
91
91
|
* Mapping returned by Grist between logical widget column names and real table column ids.
|
|
92
92
|
* Single mappings are `string`; `allowMultiple` columns are `string[]`.
|
|
@@ -103,12 +103,6 @@ type GristReadyOptions = {
|
|
|
103
103
|
allowSelectBy?: boolean;
|
|
104
104
|
hasCustomOptions?: boolean;
|
|
105
105
|
onEditOptions?: () => void | Promise<void>;
|
|
106
|
-
/** Passed to availability detection (default 10). */
|
|
107
|
-
availabilityMaxAttempts?: number;
|
|
108
|
-
/** Ms between availability polls (default 1000). */
|
|
109
|
-
availabilityIntervalMs?: number;
|
|
110
|
-
/** Log when the page is not iframe-embedded (default false). */
|
|
111
|
-
logWhenNotEmbedded?: boolean;
|
|
112
106
|
};
|
|
113
107
|
/** Optional second argument to `docApi.applyUserActions`. */
|
|
114
108
|
type GristApplyUserActionsOptions = {
|
|
@@ -206,23 +200,5 @@ type GristTableOperations = {
|
|
|
206
200
|
upsert: (records: GristTableUpsertRecord | GristTableUpsertRecord[], options?: GristTableUpsertOptions) => Promise<void>;
|
|
207
201
|
destroy: (recordIds: number | number[]) => Promise<void>;
|
|
208
202
|
};
|
|
209
|
-
/** Subset of `grist.docApi` from https://docs.getgrist.com/grist-plugin-api.js */
|
|
210
|
-
type GristDocApi = {
|
|
211
|
-
getDocName: () => Promise<string> | string;
|
|
212
|
-
listTables: () => Promise<string[]> | string[];
|
|
213
|
-
fetchTable: (tableId: string) => Promise<Record<string, unknown[]>>;
|
|
214
|
-
applyUserActions: (actions: unknown[][], options?: GristApplyUserActionsOptions) => Promise<unknown>;
|
|
215
|
-
/** Present when the widget requested sufficient access (e.g. full). */
|
|
216
|
-
getAccessToken?: (options?: {
|
|
217
|
-
readOnly?: boolean;
|
|
218
|
-
}) => Promise<{
|
|
219
|
-
token: string;
|
|
220
|
-
baseUrl: string;
|
|
221
|
-
}>;
|
|
222
|
-
/** Current section's table data (often smaller than {@link fetchTable} for the whole table). */
|
|
223
|
-
fetchSelectedTable?: (options?: GristFetchSelectedOptions) => Promise<Record<string, unknown[]>>;
|
|
224
|
-
/** Single row in the current section by numeric row id. */
|
|
225
|
-
fetchSelectedRecord?: (rowId: number, options?: GristFetchSelectedOptions) => Promise<Record<string, unknown>>;
|
|
226
|
-
};
|
|
227
203
|
|
|
228
|
-
export type {
|
|
204
|
+
export type { GristReplicaDocument as G, GristReplicaTable as a, GristWidgetColumnMap as b, GristCursorPos as c, GristWidgetInteraction as d, GristReplicaColumn as e, GristRowRecord as f, GristReplicaSelection as g, GristWidgetConfiguration as h, GristReadyOptions as i, GristFetchSelectedOptions as j, GristTableOperations as k, GristRequiredAccess as l, GristDocumentMode as m, GristFormulaKind as n, GristApplyUserActionsOptions as o, GristColumnToMap as p, GristColumnsToMap as q, GristReplicaRow as r };
|