-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-deps.js
1645 lines (1611 loc) · 67 KB
/
api-deps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// THIS FILE WAS AUTOGENERATED BY ./generate.js
const definition = `
// Generated by dts-bundle v0.7.3
// Dependencies for this module:
// ../../../../grist-widget/inspect/grain-rpc
// ../../../../grist-widget/inspect/ts-interface-checker
declare module 'grist' {
import { ColumnsToMap, CustomSectionAPI, InteractionOptions, InteractionOptionsRequest, WidgetColumnMap } from 'grist/CustomSectionAPI';
import { AccessTokenOptions, AccessTokenResult, GristAPI, GristDocAPI, GristView } from 'grist/GristAPI';
import { RowRecord } from 'grist/GristData';
import { RenderOptions } from 'grist/RenderOptions';
import { TableOperations } from 'grist/TableOperations';
import { WidgetAPI } from 'grist/WidgetAPI';
export * from 'grist/TypeCheckers';
export * from 'grist/FileParserAPI';
export * from 'grist/GristAPI';
export * from 'grist/GristData';
export * from 'grist/GristTable';
export * from 'grist/ImportSourceAPI';
export * from 'grist/StorageAPI';
export * from 'grist/RenderOptions';
export * from 'grist/WidgetAPI';
export * from 'grist/CustomSectionAPI';
import { Rpc } from 'grain-rpc';
export const rpc: Rpc;
export const api: GristAPI;
export const coreDocApi: GristDocAPI;
/**
* Interface for the records backing a custom widget.
*/
export const viewApi: GristView;
/**
* Interface for the state of a custom widget.
*/
export const widgetApi: WidgetAPI;
/**
* Interface for the mapping of a custom widget.
*/
export const sectionApi: CustomSectionAPI;
/**
* Shortcut for [[GristView.allowSelectBy]].
*/
export const allowSelectBy: () => Promise<void>;
/**
* Shortcut for [[GristView.setSelectedRows]].
*/
export const setSelectedRows: (rowIds: number[]) => Promise<void>;
/**
* Fetches data backing the widget as for [[GristView.fetchSelectedTable]],
* but decoding data by default, replacing e.g. ['D', timestamp] with
* a moment date. Option 'keepEncoded' skips the decoding step.
*/
export function fetchSelectedTable(options?: {
keepEncoded?: boolean;
}): Promise<any>;
/**
* Fetches current selected record as for [[GristView.fetchSelectedRecord]],
* but decoding data by default, replacing e.g. ['D', timestamp] with
* a moment date. Option 'keepEncoded' skips the decoding step.
*/
export function fetchSelectedRecord(rowId: number, options?: {
keepEncoded?: boolean;
}): Promise<any>;
/**
* A collection of methods for fetching document data. The
* fetchSelectedTable and fetchSelectedRecord methods are
* overridden to decode data by default.
*/
export const docApi: GristDocAPI & GristView;
export const on: (event: string | symbol, listener: (...args: any[]) => void) => Rpc;
/**
* Shortcut for [[WidgetAPI.getOption]]
*/
export const getOption: (key: string) => Promise<any>;
/**
* Shortcut for [[WidgetAPI.setOption]]
*/
export const setOption: (key: string, value: any) => Promise<void>;
/**
* Shortcut for [[WidgetAPI.setOptions]]
*/
export const setOptions: (options: {
[key: string]: any;
}) => Promise<void>;
/**
* Shortcut for [[WidgetAPI.getOptions]]
*/
export const getOptions: () => Promise<object | null>;
/**
* Shortcut for [[WidgetAPI.clearOptions]]
*/
export const clearOptions: () => Promise<void>;
/**
* Get access to a table in the document. If no tableId specified, this
* will use the current selected table (for custom widgets).
* If a table does not exist, there will be no error until an operation
* on the table is attempted.
*/
export function getTable(tableId?: string): TableOperations;
/**
* Get an access token, for making API calls outside of the custom widget
* API. There is no caching of tokens. The returned token can
* be used to authorize regular REST API calls that access the content of the
* document. For example, in a custom widget for a table with a 'Photos' column
* containing attachments, the following code will update the 'src' of an
* image with id 'the_image' to show the attachment:
* '''js
* grist.onRecord(async (record) => {
* const tokenInfo = await grist.docApi.getAccessToken({readOnly: true});
* const img = document.getElementById('the_image');
* const id = record.Photos[0]; // get an id of an attachment - there could be several
* // in a cell, for this example we just take the first.
* const src = '\${tokenInfo.baseUrl}/attachments/\${id}/download?auth=\${tokenInfo.token}';
* img.setAttribute('src', src);
* });
* '''
*/
export function getAccessToken(options?: AccessTokenOptions): Promise<AccessTokenResult>;
/**
* Get the current selected table (for custom widgets).
*/
export const selectedTable: TableOperations;
export function getSelectedTableId(): Promise<string>;
export function getSelectedTableIdSync(): string | undefined;
/**
* Renames columns in the result using columns mapping configuration passed in ready method.
* Returns null if not all required columns were mapped or not widget doesn't support
* custom column mapping.
*/
export function mapColumnNames(data: any, options?: {
columns?: ColumnsToMap;
mappings?: WidgetColumnMap | null;
reverse?: boolean;
}): any;
/**
* Offer a convenient way to map data with renamed columns back into the
* form used in the original table. This is useful for making edits to the
* original table in a widget with column mappings. As for mapColumnNames(),
* we don't attempt to do these transformations automatically.
*/
export function mapColumnNamesBack(data: any, options?: {
columns?: ColumnsToMap;
mappings?: WidgetColumnMap | null;
}): any;
/**
* For custom widgets, add a handler that will be called whenever the
* row with the cursor changes - either by switching to a different row, or
* by some value within the row potentially changing. Handler may
* in the future be called with null if the cursor moves away from
* any row.
*/
export function onRecord(callback: (data: RowRecord | null, mappings: WidgetColumnMap | null) => unknown): void;
/**
* For custom widgets, add a handler that will be called whenever the
* new (blank) row is selected.
*/
export function onNewRecord(callback: (mappings: WidgetColumnMap | null) => unknown): void;
/**
* For custom widgets, add a handler that will be called whenever the
* selected records change. Handler will be called with a list of records.
*/
export function onRecords(callback: (data: RowRecord[], mappings: WidgetColumnMap | null) => unknown): void;
/**
* For custom widgets, add a handler that will be called whenever the
* widget options change (and on initial ready message). Handler will be
* called with an object containing saved json options, or null if no options were saved.
* The second parameter has information about the widgets relationship with
* the document that contains it.
*/
export function onOptions(callback: (options: any, settings: InteractionOptions) => unknown): void;
/**
* Calling 'addImporter(...)' adds a safeBrowser importer. It is a short-hand for forwarding calls
* to an 'ImportSourceAPI' implementation registered in the file at 'path'. It takes care of
* creating the stub, registering an implementation that renders the file, forward the call and
* dispose the view properly. If 'mode' is ''inline'' embeds the view in the import modal, otherwise
* renders fullscreen.
*
* Notes: it assumes that file at 'path' registers an 'ImportSourceAPI' implementation under
* 'name'. Calling 'addImporter(...)' from another component than a 'safeBrowser' component is not
* currently supported.
*
* @internal
*/
export function addImporter(name: string, path: string, mode: 'fullscreen' | 'inline', options?: RenderOptions): Promise<void>;
/**
* Options when initializing connection to Grist.
*/
export interface ReadyPayload extends Omit<InteractionOptionsRequest, "hasCustomOptions"> {
/**
* Handler that will be called by Grist to open additional configuration panel inside the Custom Widget.
*/
onEditOptions?: () => unknown;
}
/**
* Declare that a component is prepared to receive messages from the outside world.
* Grist will not attempt to communicate with it until this method is called.
*/
export function ready(settings?: ReadyPayload): void;
}
declare module 'grist/CustomSectionAPI' {
/**
* API definitions for CustomSection plugins.
*/
export interface ColumnToMap {
/**
* Column name that Widget expects. Must be a valid JSON property name.
*/
name: string;
/**
* Title or short description of a column (used as a label in section mapping).
*/
title?: string | null;
/**
* Optional long description of a column (used as a help text in section mapping).
*/
description?: string | null;
/**
* Column type, by default ANY.
*/
type?: string;
/**
* Mark column as optional all columns are required by default.
*/
optional?: boolean;
/**
* Allow multiple column assignment, the result will be list of mapped table column names.
*/
allowMultiple?: boolean;
}
export type ColumnsToMap = (string | ColumnToMap)[];
/**
* Initial message sent by the CustomWidget with initial requirements.
*/
export interface InteractionOptionsRequest {
/**
* Required access level. If it wasn't granted already, Grist will prompt user to change the current access
* level.
*/
requiredAccess?: string;
/**
* Instructs Grist to show additional menu options that will trigger onEditOptions callback, that Widget
* can use to show custom options screen.
*/
hasCustomOptions?: boolean;
/**
* Tells Grist what columns Custom Widget expects and allows user to map between existing column names
* and those requested by Custom Widget.
*/
columns?: ColumnsToMap;
}
/**
* Widget configuration set and approved by Grist, sent as part of ready message.
*/
export interface InteractionOptions {
/**
* Granted access level.
*/
accessLevel: string;
}
/**
* Current columns mapping between viewFields in section and Custom widget.
*/
export interface WidgetColumnMap {
[key: string]: string | string[] | null;
}
export interface CustomSectionAPI {
/**
* Initial request from a Custom Widget that wants to declare its requirements.
*/
configure(customOptions: InteractionOptionsRequest): Promise<void>;
/**
* Returns current widget configuration (if requested through configuration method).
*/
mappings(): Promise<WidgetColumnMap | null>;
}
}
declare module 'grist/GristAPI' {
/**
* This file defines the interface for the grist api exposed to SafeBrowser plugins. Grist supports
* various ways to require it to cover various scenarios. If writing the main safeBrowser module
* (the one referenced by the components.safeBrowser key of the manifest) use
* 'self.importScript('grist');', if writing a view include the script in the html '<script src="grist"></script>'
*
*
* Example usage (let's assume that Grist let's plugin contributes to a Foo API defined as follow ):
*
* interface Foo {
* foo(name: string): Promise<string>;
* }
*
* > main.ts:
* class MyFoo {
* public foo(name: string): Promise<string> {
* return new Promise<string>( async resolve => {
* grist.rpc.onMessage( e => {
* resolve(e.data + name);
* });
* grist.ready();
* await grist.api.render('view1.html', 'fullscreen');
* });
* }
* }
* grist.rpc.registerImpl<Foo>('grist', new MyFoo()); // can add 3rd arg with type information
*
* > view1.html includes:
* grist.api.render('static/view2.html', 'fullscreen').then( view => {
* grist.rpc.onMessage(e => grist.rpc.postMessageForward("main.ts", e.data));
* });
*
* > view2.html includes:
* grist.rpc.postMessage('view1.html', 'foo ');
*
*/
import { RenderOptions, RenderTarget } from 'grist/RenderOptions';
export type ComponentKind = "safeBrowser" | "safePython" | "unsafeNode";
export const RPC_GRISTAPI_INTERFACE = "_grist_api";
export interface GristAPI {
/**
* Render the file at 'path' into the 'target' location in Grist. 'path' must be relative to the
* root of the plugin's directory and point to an html that is contained within the plugin's
* directory. 'target' is a predefined location of the Grist UI, it could be 'fullscreen' or
* identifier for an inline target. Grist provides inline target identifiers in certain call
* plugins. E.g. ImportSourceAPI.getImportSource is given a target identifier to allow rende UI
* inline in the import dialog. Returns the procId which can be used to dispose the view.
*/
render(path: string, target: RenderTarget, options?: RenderOptions): Promise<number>;
/**
* Dispose the process with id procId. If the process was embedded into the UI, removes the
* corresponding element from the view.
*/
dispose(procId: number): Promise<void>;
subscribe(tableId: string): Promise<void>;
unsubscribe(tableId: string): Promise<void>;
}
/**
* Allows getting information from and interacting with the Grist document to which a plugin or widget is attached.
*/
export interface GristDocAPI {
/**
* Returns an identifier for the document.
*/
getDocName(): Promise<string>;
/**
* Returns a sorted list of table IDs.
*/
listTables(): Promise<string[]>;
/**
* Returns a complete table of data as [[RowRecords]], including the
* 'id' column. Do not modify the returned arrays in-place, especially if used
* directly (not over RPC).
*/
fetchTable(tableId: string): Promise<any>;
/**
* Applies an array of user actions.
*/
applyUserActions(actions: any[][], options?: any): Promise<any>;
/**
* Get a token for out-of-band access to the document.
*/
getAccessToken(options: AccessTokenOptions): Promise<AccessTokenResult>;
}
/**
* Interface for the data backing a single widget.
*/
export interface GristView {
/**
* Like [[GristDocAPI.fetchTable]], but gets data for the custom section specifically, if there is any.
*/
fetchSelectedTable(): Promise<any>;
/**
* Fetches selected record by its 'rowId'.
*/
fetchSelectedRecord(rowId: number): Promise<any>;
/**
* Allow custom widget to be listed as a possible source for linking with SELECT BY.
*/
allowSelectBy(): Promise<void>;
/**
* Set the list of selected rows to be used against any linked widget. Requires 'allowSelectBy()'.
*/
setSelectedRows(rowIds: number[]): Promise<void>;
}
/**
* Options when creating access tokens.
*/
export interface AccessTokenOptions {
/** Restrict use of token to reading only */
readOnly?: boolean;
}
/**
* Access token information, including the token string itself, a base URL for
* API calls for which the access token can be used, and the time-to-live the
* token was created with.
*/
export interface AccessTokenResult {
/**
* The token string, which can currently be provided in an api call as a
* query parameter called "auth"
*/
token: string;
/**
* The base url of the API for which the token can be used. Currently tokens
* are associated with a single document, so the base url will be something
* like 'https://..../api/docs/DOCID'
*
* Access tokens currently only grant access to endpoints dealing with the
* internal content of a document (such as tables and cells) and not its
* metadata (such as the document name or who it is shared with).
*/
baseUrl: string;
/**
* Number of milliseconds the access token will remain valid for
* after creation. This will be several minutes.
*/
ttlMsecs: number;
}
}
declare module 'grist/GristData' {
/**
* Letter codes for CellValue types encoded as [code, args...] tuples.
*/
export enum GristObjCode {
List = "L",
LookUp = "l",
Dict = "O",
DateTime = "D",
Date = "d",
Skip = "S",
Censored = "C",
Reference = "R",
ReferenceList = "r",
Exception = "E",
Pending = "P",
Unmarshallable = "U",
Versions = "V"
}
/**
* Possible types of cell content.
*/
export type CellValue = number | string | boolean | null | [GristObjCode, ...unknown[]];
export interface BulkColValues {
[colId: string]: CellValue[];
}
/**
* Map of column ids to 'CellValue's.
*
* ### CellValue
*
* Each 'CellValue' may either be a primitive (e.g. 'true', '123', '"hello"', 'null')
* or a tuple (JavaScript Array) representing a Grist object. The first element of the tuple
* is a string character representing the object code. For example, '["L", "foo", "bar"]'
* is a 'CellValue' of a Choice List column, where '"L"' is the type, and '"foo"' and
* '"bar"' are the choices.
*
* ### Grist Object Types
*
* | Code | Type |
* | ---- | -------------- |
* | L | List |
* | l | LookUp |
* | O | Dict |
* | D | DateTime |
* | d | Date |
* | C | Censored |
* | R | Reference |
* | r | ReferenceList |
* | E | Exception |
* | P | Pending |
* | U | Unmarshallable |
* | V | Version |
*/
export interface RowRecord {
id: number;
[colId: string]: CellValue;
}
/**
* Map of column ids to 'CellValue' arrays, where array indexes correspond to
* rows.
*
* ### CellValue
*
* Each 'CellValue' may either be a primitive (e.g. 'true', '123', '"hello"', 'null')
* or a tuple (JavaScript Array) representing a Grist object. The first element of the tuple
* is a string character representing the object code. For example, '["L", "foo", "bar"]'
* is a 'CellValue' of a Choice List column, where '"L"' is the type, and '"foo"' and
* '"bar"' are the choices.
*
* ### Grist Object Types
*
* | Code | Type |
* | ---- | -------------- |
* | L | List |
* | l | LookUp |
* | O | Dict |
* | D | DateTime |
* | d | Date |
* | C | Censored |
* | R | Reference |
* | r | ReferenceList |
* | E | Exception |
* | P | Pending |
* | U | Unmarshallable |
* | V | Version |
*/
export interface RowRecords {
id: number[];
[colId: string]: CellValue[];
}
export type GristType = 'Any' | 'Attachments' | 'Blob' | 'Bool' | 'Choice' | 'ChoiceList' | 'Date' | 'DateTime' | 'Id' | 'Int' | 'ManualSortPos' | 'Numeric' | 'PositionNumber' | 'Ref' | 'RefList' | 'Text';
}
declare module 'grist/RenderOptions' {
/**
* Where to append the content that a plugin renders.
*
* @internal
*/
export type RenderTarget = "fullscreen" | number;
/**
* Options for the 'grist.render' function.
*/
export interface RenderOptions {
height?: string;
}
}
declare module 'grist/TableOperations' {
import * as Types from 'grist/DocApiTypes';
/**
* Offer CRUD-style operations on a table.
*/
export interface TableOperations {
/**
* Create a record or records.
*/
create(records: Types.NewRecord, options?: OpOptions): Promise<Types.MinimalRecord>;
create(records: Types.NewRecord[], options?: OpOptions): Promise<Types.MinimalRecord[]>;
/**
* Update a record or records.
*/
update(records: Types.Record | Types.Record[], options?: OpOptions): Promise<void>;
/**
* Delete a record or records.
*/
destroy(recordIds: Types.RecordId | Types.RecordId[]): Promise<void>;
/**
* Add or update a record or records.
*/
upsert(records: Types.AddOrUpdateRecord | Types.AddOrUpdateRecord[], options?: UpsertOptions): Promise<void>;
/**
* Determine the tableId of the table.
*/
getTableId(): Promise<string>;
}
/**
* General options for table operations.
*/
export interface OpOptions {
/** Whether to parse strings based on the column type. Defaults to true. */
parseStrings?: boolean;
}
/**
* Extra options for upserts.
*/
export interface UpsertOptions extends OpOptions {
/** Permit inserting a record. Defaults to true. */
add?: boolean;
/** Permit updating a record. Defaults to true. */
update?: boolean;
/** Whether to update none, one, or all matching records. Defaults to "first". */
onMany?: 'none' | 'first' | 'all';
/** Allow "wildcard" operation. Defaults to false. */
allowEmptyRequire?: boolean;
}
}
declare module 'grist/WidgetAPI' {
/**
* API to manage Custom Widget state.
*/
export interface WidgetAPI {
/**
* Gets all options stored by the widget. Options are stored as plain JSON object.
*/
getOptions(): Promise<object | null>;
/**
* Replaces all options stored by the widget.
*/
setOptions(options: {
[key: string]: any;
}): Promise<void>;
/**
* Clears all the options.
*/
clearOptions(): Promise<void>;
/**
* Store single value in the Widget options object (and create it if necessary).
*/
setOption(key: string, value: any): Promise<void>;
/**
* Get single value from Widget options object.
*/
getOption(key: string): Promise<any>;
}
}
declare module 'grist/TypeCheckers' {
import { ICheckerSuite } from 'ts-interface-checker';
import CustomSectionAPITI from 'grist/CustomSectionAPI-ti';
import FileParserAPITI from 'grist/FileParserAPI-ti';
import GristAPITI from 'grist/GristAPI-ti';
import GristTableTI from 'grist/GristTable-ti';
import ImportSourceAPITI from 'grist/ImportSourceAPI-ti';
import InternalImportSourceAPITI from 'grist/InternalImportSourceAPI-ti';
import RenderOptionsTI from 'grist/RenderOptions-ti';
import StorageAPITI from 'grist/StorageAPI-ti';
import WidgetAPITI from 'grist/WidgetAPI-ti';
/**
* The ts-interface-checker type suites are all exported with the "TI" suffix.
*/
export { CustomSectionAPITI, FileParserAPITI, GristAPITI, GristTableTI, ImportSourceAPITI, InternalImportSourceAPITI, RenderOptionsTI, StorageAPITI, WidgetAPITI };
/**
* We also create and export a global checker object that includes all of the types above.
*/
export const checkers: Pick<ICheckerSuite, "CustomSectionAPI" | "ParseOptions" | "ParseFileResult" | "FileSource" | "ParseOptionSchema" | "GristTables" | "EditOptionsAPI" | "ParseFileAPI" | "RenderTarget" | "RenderOptions" | "ComponentKind" | "GristAPI" | "GristDocAPI" | "GristView" | "GristColumn" | "GristTable" | "ImportSourceAPI" | "ImportProcessorAPI" | "ImportSource" | "FileContent" | "FileListItem" | "URL" | "InternalImportSourceAPI" | "Storage" | "WidgetAPI">;
}
declare module 'grist/FileParserAPI' {
/**
* API definitions for FileParser plugins.
*/
import { GristTables } from 'grist/GristTable';
export interface EditOptionsAPI {
getParseOptions(parseOptions?: ParseOptions): Promise<ParseOptions>;
}
export interface ParseFileAPI {
parseFile(file: FileSource, parseOptions?: ParseOptions): Promise<ParseFileResult>;
}
/**
* ParseOptions contains parse options depending on plugin,
* number of rows, which is special option that can be used for any plugin
* and schema for generating parse options UI
*/
export interface ParseOptions {
NUM_ROWS?: number;
SCHEMA?: ParseOptionSchema[];
}
/**
* ParseOptionSchema contains information for generaing parse options UI
*/
export interface ParseOptionSchema {
name: string;
label: string;
type: string;
visible: boolean;
}
export interface FileSource {
/**
* The path is often a temporary file, so its name is meaningless. Access to the file depends on
* the type of plugin. For instance, for 'safePython' plugins file is directly available at
* '/importDir/path'.
*/
path: string;
/**
* Plugins that want to know the original filename should use origName. Depending on the source
* of the data, it may or may not be meaningful.
*/
origName: string;
}
export interface ParseFileResult extends GristTables {
parseOptions: ParseOptions;
}
}
declare module 'grist/GristTable' {
/**
* Metadata and data for a table.
*/
export interface GristTable {
table_name: string | null;
column_metadata: GristColumn[];
table_data: any[][];
}
export interface GristTables {
tables: GristTable[];
}
/**
* Metadata about a single column.
*/
export interface GristColumn {
id: string;
type: string;
}
export enum APIType {
ImportSourceAPI = 0,
ImportProcessorAPI = 1,
ParseOptionsAPI = 2,
ParseFileAPI = 3
}
}
declare module 'grist/ImportSourceAPI' {
/**
* API definitions for ImportSource plugins.
*/
import { GristTable } from 'grist/GristTable';
export interface ImportSourceAPI {
/**
* Returns a promise that resolves to an 'ImportSource' which is then passed for import to the
* import modal dialog. 'undefined' interrupts the workflow and prevent the modal from showing up,
* but not an empty list of 'ImportSourceItem'. Which is a valid import source and is used in
* cases where only options are to be sent to an 'ImportProcessAPI' implementation.
*/
getImportSource(): Promise<ImportSource | undefined>;
}
export interface ImportProcessorAPI {
processImport(source: ImportSource): Promise<GristTable[]>;
}
export interface FileContent {
content: any;
name: string;
}
export interface FileListItem {
kind: "fileList";
files: FileContent[];
}
export interface URL {
kind: "url";
url: string;
}
export interface ImportSource {
item: FileListItem | URL;
/**
* The options are only passed within this plugin, nothing else needs to know how they are
* serialized. Using JSON.stringify/JSON.parse is a simple approach.
*/
options?: string | Buffer;
/**
* The short description that shows in the import dialog after source have been selected.
*/
description?: string;
}
}
declare module 'grist/StorageAPI' {
export interface Storage {
getItem(key: string): any;
hasItem(key: string): boolean;
setItem(key: string, value: any): void;
removeItem(key: string): void;
clear(): void;
}
}
declare module 'grist/DocApiTypes' {
import { CellValue } from "grist/GristData";
/**
* JSON schema for api /record endpoint. Used in POST method for adding new records.
*/
export interface NewRecord {
/**
* Initial values of cells in record. Optional, if not set cells are left
* blank.
*/
fields?: {
[coldId: string]: CellValue;
};
}
export interface NewRecordWithStringId {
id?: string;
/**
* Initial values of cells in record. Optional, if not set cells are left
* blank.
*/
fields?: {
[coldId: string]: CellValue;
};
}
/**
* JSON schema for api /record endpoint. Used in PATCH method for updating existing records.
*/
export interface Record {
id: number;
fields: {
[coldId: string]: CellValue;
};
}
export interface RecordWithStringId {
id: string;
fields: {
[coldId: string]: CellValue;
};
}
/**
* JSON schema for api /record endpoint. Used in PUT method for adding or updating records.
*/
export interface AddOrUpdateRecord {
/**
* The values we expect to have in particular columns, either by matching with
* an existing record, or creating a new record.
*/
require: {
[coldId: string]: CellValue;
} & {
id?: number;
};
/**
* The values we will place in particular columns, either overwriting values in
* an existing record, or setting initial values in a new record.
*/
fields?: {
[coldId: string]: CellValue;
};
}
/**
* JSON schema for the body of api /record PATCH endpoint
*/
export interface RecordsPatch {
records: [Record, ...Record[]];
}
/**
* JSON schema for the body of api /record POST endpoint
*/
export interface RecordsPost {
records: [NewRecord, ...NewRecord[]];
}
/**
* JSON schema for the body of api /record PUT endpoint
*/
export interface RecordsPut {
records: [AddOrUpdateRecord, ...AddOrUpdateRecord[]];
}
export type RecordId = number;
/**
* The row id of a record, without any of its content.
*/
export interface MinimalRecord {
id: number;
}
export interface ColumnsPost {
columns: [NewRecordWithStringId, ...NewRecordWithStringId[]];
}
export interface ColumnsPatch {
columns: [RecordWithStringId, ...RecordWithStringId[]];
}
/**
* Creating tables requires a list of columns.
* 'fields' is not accepted because it's not generally sensible to set the metadata fields on new tables.
*/
export interface TablePost extends ColumnsPost {
id?: string;
}
export interface TablesPost {
tables: [TablePost, ...TablePost[]];
}
export interface TablesPatch {
tables: [RecordWithStringId, ...RecordWithStringId[]];
}
}
declare module 'grist/CustomSectionAPI-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const ColumnToMap: t.TIface;
export const ColumnsToMap: t.TArray;
export const InteractionOptionsRequest: t.TIface;
export const InteractionOptions: t.TIface;
export const WidgetColumnMap: t.TIface;
export const CustomSectionAPI: t.TIface;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
declare module 'grist/FileParserAPI-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const EditOptionsAPI: t.TIface;
export const ParseFileAPI: t.TIface;
export const ParseOptions: t.TIface;
export const ParseOptionSchema: t.TIface;
export const FileSource: t.TIface;
export const ParseFileResult: t.TIface;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
declare module 'grist/GristAPI-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const ComponentKind: t.TUnion;
export const GristAPI: t.TIface;
export const GristDocAPI: t.TIface;
export const GristView: t.TIface;
export const AccessTokenOptions: t.TIface;
export const AccessTokenResult: t.TIface;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
declare module 'grist/GristTable-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const GristTable: t.TIface;
export const GristTables: t.TIface;
export const GristColumn: t.TIface;
export const APIType: t.TEnumType;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
declare module 'grist/ImportSourceAPI-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const ImportSourceAPI: t.TIface;
export const ImportProcessorAPI: t.TIface;
export const FileContent: t.TIface;
export const FileListItem: t.TIface;
export const URL: t.TIface;
export const ImportSource: t.TIface;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
declare module 'grist/InternalImportSourceAPI-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const InternalImportSourceAPI: t.TIface;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
declare module 'grist/RenderOptions-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const RenderTarget: t.TUnion;
export const RenderOptions: t.TIface;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
declare module 'grist/StorageAPI-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const Storage: t.TIface;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
declare module 'grist/WidgetAPI-ti' {
/**
* This module was automatically generated by 'ts-interface-builder'
*/
import * as t from "ts-interface-checker";
export const WidgetAPI: t.TIface;
const exportedTypeSuite: t.ITypeSuite;
export default exportedTypeSuite;
}
// Generated by dts-bundle v0.7.3
// Dependencies for this module:
// ../../../../../grist-widget/inspect/events
// ../../../../../grist-widget/inspect/ts-interface-checker
declare module 'grain-rpc' {
export * from 'grain-rpc/message';
export * from 'grain-rpc/rpc';
}
declare module 'grain-rpc/message' {
/**
* This defines the message types sent over an RpcChannel.
*
* WARNING: Any changes to these must be backward-compatible, since Rpc may be used across
* different versions of this library. Specifically, enums must not be renumbered, fields renamed,
* or their types changed. Really, the only reasonable enhancement is adding a new optional field.
*/
export enum MsgType {
RpcCall = 1,
RpcRespData = 2,