lucid-extension-sdk 0.0.3 → 0.0.6
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/package.json +2 -1
- package/sdk/commandtypes.d.ts +110 -3
- package/sdk/core/checks.d.ts +8 -0
- package/sdk/core/checks.js +14 -1
- package/sdk/core/data/fieldtypedefinition/basefieldtypedefinition.d.ts +13 -0
- package/sdk/core/data/fieldtypedefinition/basefieldtypedefinition.js +58 -0
- package/sdk/core/data/fieldtypedefinition/collectionenumfieldtype.d.ts +30 -0
- package/sdk/core/data/fieldtypedefinition/collectionenumfieldtype.js +45 -0
- package/sdk/core/data/fieldtypedefinition/fieldtypearray.d.ts +16 -0
- package/sdk/core/data/fieldtypedefinition/fieldtypearray.js +50 -0
- package/sdk/core/data/fieldtypedefinition/fieldtypedefinition.d.ts +13 -0
- package/sdk/core/data/fieldtypedefinition/fieldtypedefinition.js +156 -0
- package/sdk/core/data/fieldtypedefinition/literalfieldtype.d.ts +17 -0
- package/sdk/core/data/fieldtypedefinition/literalfieldtype.js +60 -0
- package/sdk/core/data/fieldtypedefinition/ndimensionalfieldtypearray.d.ts +17 -0
- package/sdk/core/data/fieldtypedefinition/ndimensionalfieldtypearray.js +51 -0
- package/sdk/core/data/fieldtypedefinition/scalarfieldtype.d.ts +14 -0
- package/sdk/core/data/fieldtypedefinition/scalarfieldtype.js +33 -0
- package/sdk/core/data/referencekeys/serializedreferencekey.d.ts +24 -0
- package/sdk/core/data/referencekeys/serializedreferencekey.js +5 -0
- package/sdk/core/data/serializedfield/serializeddataitems.d.ts +5 -0
- package/sdk/core/data/serializedfield/serializeddataitems.js +9 -0
- package/sdk/core/data/serializedfield/serializedfielddefinition.d.ts +19 -0
- package/sdk/core/data/serializedfield/serializedfielddefinition.js +12 -0
- package/sdk/core/{serializedfields.d.ts → data/serializedfield/serializedfields.d.ts} +0 -0
- package/sdk/core/{serializedfields.js → data/serializedfield/serializedfields.js} +1 -1
- package/sdk/core/data/serializedfield/serializedschema.d.ts +9 -0
- package/sdk/core/data/serializedfield/serializedschema.js +2 -0
- package/sdk/data/collectionproxy.d.ts +6 -0
- package/sdk/data/collectionproxy.js +15 -0
- package/sdk/data/dataproxy.d.ts +12 -0
- package/sdk/data/dataproxy.js +11 -0
- package/sdk/data/datasourceproxy.d.ts +9 -0
- package/sdk/data/datasourceproxy.js +20 -0
- package/sdk/data/referencekeydefinition.d.ts +17 -0
- package/sdk/data/referencekeydefinition.js +27 -0
- package/sdk/data/referencekeyproxy.d.ts +9 -0
- package/sdk/data/referencekeyproxy.js +12 -0
- package/sdk/data/schemadefinition.d.ts +11 -0
- package/sdk/data/schemadefinition.js +14 -0
- package/sdk/document/blockdefinition.d.ts +10 -0
- package/sdk/document/documentproxy.d.ts +9 -0
- package/sdk/document/documentproxy.js +13 -0
- package/sdk/document/elementproxy.d.ts +5 -0
- package/sdk/document/elementproxy.js +13 -0
- package/sdk/document/pageproxy.js +6 -0
- package/sdk/document/shapedataproxy.d.ts +1 -1
- package/sdk/editorclient.d.ts +43 -0
- package/sdk/editorclient.js +66 -0
- package/sdk/index.d.ts +1 -1
- package/sdk/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lucid-extension-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Utility classes for writing Lucid Software editor extensions",
|
|
5
5
|
"main": "sdk/index.js",
|
|
6
6
|
"types": "sdk/index.d.ts",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"declaration": true,
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@bazel/typescript": "2.0.1",
|
|
12
|
+
"@types/jasmine": "^3.10.3",
|
|
12
13
|
"@types/node": "^16.11.11",
|
|
13
14
|
"typedoc": "^0.22.11",
|
|
14
15
|
"typescript": "4.3.5"
|
package/sdk/commandtypes.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SerializedFieldTypeDefinition } from './core/data/fieldtypedefinition/fieldtypedefinition';
|
|
2
|
+
import { SerializedReferenceKeyType } from './core/data/referencekeys/serializedreferencekey';
|
|
3
|
+
import { SerializedFieldType } from './core/data/serializedfield/serializedfields';
|
|
4
|
+
import { JsonObject, JsonSerializable } from './core/jsonserializable';
|
|
2
5
|
import { LinearOffsetType } from './core/offsettype';
|
|
3
6
|
import { SerializedDataError } from './core/serializeddataerror';
|
|
4
|
-
import { SerializedFieldType } from './core/serializedfields';
|
|
5
7
|
import { ShapeDataInheritance } from './core/shapedatainheritance';
|
|
6
8
|
import { Box, Point } from './math';
|
|
7
9
|
import { MenuLocation, MenuType } from './ui/menu';
|
|
@@ -9,7 +11,10 @@ export declare const enum CommandName {
|
|
|
9
11
|
AddMenuItem = "ami",
|
|
10
12
|
AddShapeData = "asd",
|
|
11
13
|
AnimateViewport = "av",
|
|
14
|
+
Bootstrap = "b",
|
|
12
15
|
CreateBlock = "cb",
|
|
16
|
+
CreateCollection = "cc",
|
|
17
|
+
CreateDataSource = "cds",
|
|
13
18
|
CreateLine = "cl",
|
|
14
19
|
CreatePage = "cp",
|
|
15
20
|
DeleteItem = "di",
|
|
@@ -20,10 +25,12 @@ export declare const enum CommandName {
|
|
|
20
25
|
ExecuteFormula = "ef",
|
|
21
26
|
GetConnectedLines = "gcl",
|
|
22
27
|
GetCurrentPage = "gcp",
|
|
28
|
+
GetCustomShape = "gcs",
|
|
23
29
|
GetDataItemField = "gdif",
|
|
24
30
|
GetElementType = "get",
|
|
25
31
|
GetItemPageId = "gip",
|
|
26
32
|
GetProperty = "gp",
|
|
33
|
+
GetReferenceKey = "grk",
|
|
27
34
|
GetRelativeLinePosition = "grlp",
|
|
28
35
|
GetSelection = "gs",
|
|
29
36
|
GetShapeData = "gsd",
|
|
@@ -38,18 +45,22 @@ export declare const enum CommandName {
|
|
|
38
45
|
ListLines = "ll",
|
|
39
46
|
ListPages = "lp",
|
|
40
47
|
ListProperties = "lpr",
|
|
48
|
+
ListReferenceKeys = "lrk",
|
|
41
49
|
ListShapeData = "lsd",
|
|
42
50
|
ListTextAreas = "lta",
|
|
43
51
|
LoadBlockClasses = "lbc",
|
|
44
52
|
LogForTestCase = "log",
|
|
45
53
|
OffsetItems = "oi",
|
|
54
|
+
PatchDataItems = "pdi",
|
|
46
55
|
ReloadExtension = "r",
|
|
47
56
|
SendUIMessage = "suim",
|
|
48
57
|
SendXHR = "xhr",
|
|
49
58
|
SetCurrentPage = "scp",
|
|
50
59
|
SetProperty = "sp",
|
|
60
|
+
SetReferenceKey = "srk",
|
|
51
61
|
SetShapeData = "ssd",
|
|
52
|
-
ShowModal = "sm"
|
|
62
|
+
ShowModal = "sm",
|
|
63
|
+
SleepForTestCase = "sleep"
|
|
53
64
|
}
|
|
54
65
|
export declare type CommandArgs = {
|
|
55
66
|
[CommandName.AnimateViewport]: {
|
|
@@ -64,10 +75,22 @@ export declare type CommandArgs = {
|
|
|
64
75
|
query: AddShapeDataQuery;
|
|
65
76
|
result: AddShapeDataResult;
|
|
66
77
|
};
|
|
78
|
+
[CommandName.Bootstrap]: {
|
|
79
|
+
query: BootstrapQuery;
|
|
80
|
+
result: BootstrapResult;
|
|
81
|
+
};
|
|
67
82
|
[CommandName.CreateBlock]: {
|
|
68
83
|
query: CreateBlockQuery;
|
|
69
84
|
result: CreateBlockResult;
|
|
70
85
|
};
|
|
86
|
+
[CommandName.CreateCollection]: {
|
|
87
|
+
query: CreateCollectionQuery;
|
|
88
|
+
result: CreateCollectionResult;
|
|
89
|
+
};
|
|
90
|
+
[CommandName.CreateDataSource]: {
|
|
91
|
+
query: CreateDataSourceQuery;
|
|
92
|
+
result: CreateDataSourceResult;
|
|
93
|
+
};
|
|
71
94
|
[CommandName.CreateLine]: {
|
|
72
95
|
query: CreateLineQuery;
|
|
73
96
|
result: CreateLineResult;
|
|
@@ -108,6 +131,10 @@ export declare type CommandArgs = {
|
|
|
108
131
|
query: GetCurrentPageQuery;
|
|
109
132
|
result: GetCurrentPageResult;
|
|
110
133
|
};
|
|
134
|
+
[CommandName.GetCustomShape]: {
|
|
135
|
+
query: GetCustomShapeQuery;
|
|
136
|
+
result: GetCustomShapeResult;
|
|
137
|
+
};
|
|
111
138
|
[CommandName.GetDataItemField]: {
|
|
112
139
|
query: GetDataItemFieldQuery;
|
|
113
140
|
result: GetDataItemFieldResult;
|
|
@@ -124,6 +151,10 @@ export declare type CommandArgs = {
|
|
|
124
151
|
query: GetPropertyQuery;
|
|
125
152
|
result: GetPropertyResult;
|
|
126
153
|
};
|
|
154
|
+
[CommandName.GetReferenceKey]: {
|
|
155
|
+
query: GetReferenceKeyQuery;
|
|
156
|
+
result: GetReferenceKeyResult;
|
|
157
|
+
};
|
|
127
158
|
[CommandName.GetRelativeLinePosition]: {
|
|
128
159
|
query: GetRelativeLinePositionQuery;
|
|
129
160
|
result: GetRelativeLinePositionResult;
|
|
@@ -180,6 +211,10 @@ export declare type CommandArgs = {
|
|
|
180
211
|
query: ListPropertiesQuery;
|
|
181
212
|
result: ListPropertiesResult;
|
|
182
213
|
};
|
|
214
|
+
[CommandName.ListReferenceKeys]: {
|
|
215
|
+
query: ListReferenceKeysQuery;
|
|
216
|
+
result: ListReferenceKeysResult;
|
|
217
|
+
};
|
|
183
218
|
[CommandName.ListShapeData]: {
|
|
184
219
|
query: ListShapeDataQuery;
|
|
185
220
|
result: ListShapeDataResult;
|
|
@@ -200,6 +235,10 @@ export declare type CommandArgs = {
|
|
|
200
235
|
query: OffsetItemsQuery;
|
|
201
236
|
result: OffsetItemsResult;
|
|
202
237
|
};
|
|
238
|
+
[CommandName.PatchDataItems]: {
|
|
239
|
+
query: PatchDataItemsQuery;
|
|
240
|
+
result: PatchDataItemsResult;
|
|
241
|
+
};
|
|
203
242
|
[CommandName.ReloadExtension]: {
|
|
204
243
|
query: ReloadExtensionQuery;
|
|
205
244
|
result: ReloadExtensionResult;
|
|
@@ -220,6 +259,10 @@ export declare type CommandArgs = {
|
|
|
220
259
|
query: SetPropertyQuery;
|
|
221
260
|
result: SetPropertyResult;
|
|
222
261
|
};
|
|
262
|
+
[CommandName.SetReferenceKey]: {
|
|
263
|
+
query: SetReferenceKeyQuery;
|
|
264
|
+
result: SetReferenceKeyResult;
|
|
265
|
+
};
|
|
223
266
|
[CommandName.SetShapeData]: {
|
|
224
267
|
query: SetShapeDataQuery;
|
|
225
268
|
result: SetShapeDataResult;
|
|
@@ -228,6 +271,10 @@ export declare type CommandArgs = {
|
|
|
228
271
|
query: ShowModalQuery;
|
|
229
272
|
result: ShowModalResult;
|
|
230
273
|
};
|
|
274
|
+
[CommandName.SleepForTestCase]: {
|
|
275
|
+
query: SleepForTestCaseQuery;
|
|
276
|
+
result: SleepForTestCaseResult;
|
|
277
|
+
};
|
|
231
278
|
};
|
|
232
279
|
export declare type UnionToIntersection<T> = (T extends any ? (x: T) => unknown : never) extends (x: infer R) => unknown ? R : never;
|
|
233
280
|
export declare type AddMenuItemQuery = {
|
|
@@ -246,11 +293,38 @@ export declare type AddShapeDataQuery = {
|
|
|
246
293
|
'v'?: SerializedFieldType;
|
|
247
294
|
};
|
|
248
295
|
export declare type AddShapeDataResult = undefined;
|
|
296
|
+
export declare type BootstrapQuery = {
|
|
297
|
+
/**
|
|
298
|
+
* Named action that accepts the bootstrap data, and which may return a Promise or void. After awaiting\
|
|
299
|
+
* the result of the callback, the bootstrap data is cleared.
|
|
300
|
+
*/
|
|
301
|
+
'c': string;
|
|
302
|
+
};
|
|
303
|
+
export declare type BootstrapResult = Promise<void>;
|
|
249
304
|
export declare type CreateBlockQuery = {
|
|
250
305
|
'p'?: string;
|
|
251
306
|
'c': string;
|
|
307
|
+
's'?: JsonSerializable | undefined;
|
|
252
308
|
};
|
|
253
309
|
export declare type CreateBlockResult = string;
|
|
310
|
+
export declare type CreateCollectionFieldDefinition = {
|
|
311
|
+
'n': string;
|
|
312
|
+
't': SerializedFieldTypeDefinition;
|
|
313
|
+
};
|
|
314
|
+
export declare type CreateCollectionQuery = {
|
|
315
|
+
's': string;
|
|
316
|
+
'n': string;
|
|
317
|
+
'f': CreateCollectionFieldDefinition[];
|
|
318
|
+
'p': string[];
|
|
319
|
+
};
|
|
320
|
+
export declare type CreateCollectionResult = string;
|
|
321
|
+
export declare type CreateDataSourceQuery = {
|
|
322
|
+
'n': string;
|
|
323
|
+
's': {
|
|
324
|
+
[key: string]: JsonSerializable;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
export declare type CreateDataSourceResult = string;
|
|
254
328
|
export declare type CreateLineQuery = {
|
|
255
329
|
'p'?: string;
|
|
256
330
|
};
|
|
@@ -295,6 +369,15 @@ export declare type GetConnectedLinesQuery = string;
|
|
|
295
369
|
export declare type GetConnectedLinesResult = string[];
|
|
296
370
|
export declare type GetCurrentPageQuery = void;
|
|
297
371
|
export declare type GetCurrentPageResult = string | undefined;
|
|
372
|
+
export declare type GetCustomShapeQuery = {
|
|
373
|
+
'l': string;
|
|
374
|
+
's': string;
|
|
375
|
+
};
|
|
376
|
+
export declare type GetCustomShapeResult = Promise<{
|
|
377
|
+
's': JsonSerializable;
|
|
378
|
+
'bb': Box;
|
|
379
|
+
'p': JsonObject;
|
|
380
|
+
} | undefined>;
|
|
298
381
|
export declare type GetDataItemFieldQuery = {
|
|
299
382
|
'c': string;
|
|
300
383
|
'pk': string;
|
|
@@ -303,6 +386,11 @@ export declare type GetDataItemFieldQuery = {
|
|
|
303
386
|
export declare type GetDataItemFieldResult = SerializedFieldType;
|
|
304
387
|
export declare type GetItemPageIdQuery = string;
|
|
305
388
|
export declare type GetItemPageIdResult = string;
|
|
389
|
+
export declare type GetReferenceKeyQuery = {
|
|
390
|
+
'id'?: string;
|
|
391
|
+
'k': number | string;
|
|
392
|
+
};
|
|
393
|
+
export declare type GetReferenceKeyResult = SerializedReferenceKeyType;
|
|
306
394
|
export declare type GetPropertyQuery = {
|
|
307
395
|
'id'?: string | undefined;
|
|
308
396
|
'p': string;
|
|
@@ -349,6 +437,10 @@ export declare type ListDataSourcesQuery = undefined;
|
|
|
349
437
|
export declare type ListDataSourcesResult = string[];
|
|
350
438
|
export declare type ListPagesQuery = void;
|
|
351
439
|
export declare type ListPagesResult = string[];
|
|
440
|
+
export declare type ListReferenceKeysQuery = {
|
|
441
|
+
'id'?: string | undefined;
|
|
442
|
+
};
|
|
443
|
+
export declare type ListReferenceKeysResult = (string | number)[];
|
|
352
444
|
export declare type ListPropertiesQuery = {
|
|
353
445
|
'id'?: string | undefined;
|
|
354
446
|
};
|
|
@@ -368,6 +460,13 @@ export declare type OffsetItemsQuery = {
|
|
|
368
460
|
'o': Point;
|
|
369
461
|
};
|
|
370
462
|
export declare type OffsetItemsResult = undefined;
|
|
463
|
+
export declare type PatchDataItemsQuery = {
|
|
464
|
+
'id': string;
|
|
465
|
+
'a': Record<string, SerializedFieldType>[];
|
|
466
|
+
'c': Record<string, Record<string, SerializedFieldType>>;
|
|
467
|
+
'd': string[];
|
|
468
|
+
};
|
|
469
|
+
export declare type PatchDataItemsResult = undefined;
|
|
371
470
|
export declare type ReloadExtensionQuery = void;
|
|
372
471
|
export declare type ReloadExtensionResult = undefined;
|
|
373
472
|
export declare type SendUIMessageQuery = {
|
|
@@ -410,6 +509,12 @@ export declare type SetPropertyQuery = {
|
|
|
410
509
|
'v'?: JsonSerializable;
|
|
411
510
|
};
|
|
412
511
|
export declare type SetPropertyResult = undefined;
|
|
512
|
+
export declare type SetReferenceKeyQuery = {
|
|
513
|
+
'id'?: string | undefined;
|
|
514
|
+
'k': string | number;
|
|
515
|
+
'v'?: SerializedReferenceKeyType;
|
|
516
|
+
};
|
|
517
|
+
export declare type SetReferenceKeyResult = undefined;
|
|
413
518
|
export declare type SetShapeDataQuery = {
|
|
414
519
|
'id'?: string | undefined;
|
|
415
520
|
'n': string;
|
|
@@ -424,3 +529,5 @@ export declare type ShowModalQuery = {
|
|
|
424
529
|
'c': string;
|
|
425
530
|
};
|
|
426
531
|
export declare type ShowModalResult = undefined;
|
|
532
|
+
export declare type SleepForTestCaseQuery = number;
|
|
533
|
+
export declare type SleepForTestCaseResult = Promise<void>;
|
package/sdk/core/checks.d.ts
CHANGED
|
@@ -62,6 +62,14 @@ export declare function isFunction(val: unknown): val is (...unknownArgs: any[])
|
|
|
62
62
|
* @return Whether variable is an object.
|
|
63
63
|
*/
|
|
64
64
|
export declare function isObject(val: unknown): val is Record<string, unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* Returns true if the specified value is an object (i.e. it's safe to do property accesses on it).
|
|
67
|
+
*
|
|
68
|
+
* This is safer than using goog.isObject directly (this is its code inlined) because it doesn't introduce an `any`.
|
|
69
|
+
* @param val Variable to test.
|
|
70
|
+
* @return Whether variable is an object.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isRecord<T>(typeGuard: (a: unknown) => a is T): (val: unknown) => val is Record<string, T>;
|
|
65
73
|
/**
|
|
66
74
|
* Returns true if the specified value is an array.
|
|
67
75
|
*
|
package/sdk/core/checks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isTypedArray = exports.isArray = exports.isObject = exports.isFunction = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isUndefined = exports.isNull = exports.isDef = void 0;
|
|
3
|
+
exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObject = exports.isFunction = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isUndefined = exports.isNull = exports.isDef = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Returns true if the specified value is not undefined.
|
|
6
6
|
*
|
|
@@ -99,6 +99,19 @@ function isObject(val) {
|
|
|
99
99
|
return (type == 'object' && val != null) || type == 'function';
|
|
100
100
|
}
|
|
101
101
|
exports.isObject = isObject;
|
|
102
|
+
/**
|
|
103
|
+
* Returns true if the specified value is an object (i.e. it's safe to do property accesses on it).
|
|
104
|
+
*
|
|
105
|
+
* This is safer than using goog.isObject directly (this is its code inlined) because it doesn't introduce an `any`.
|
|
106
|
+
* @param val Variable to test.
|
|
107
|
+
* @return Whether variable is an object.
|
|
108
|
+
*/
|
|
109
|
+
function isRecord(typeGuard) {
|
|
110
|
+
return function (val) {
|
|
111
|
+
return isObject(val) && Object.values(val).every(typeGuard);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
exports.isRecord = isRecord;
|
|
102
115
|
/**
|
|
103
116
|
* Returns true if the specified value is an array.
|
|
104
117
|
*
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CollectionEnumFieldType, SerializedCollectionEnumFieldType } from './collectionenumfieldtype';
|
|
2
|
+
import { FieldTypeArray, SerializedFieldTypeArray } from './fieldtypearray';
|
|
3
|
+
import { LiteralFieldType, SerializedLiteralFieldType } from './literalfieldtype';
|
|
4
|
+
import { NDimensionalFieldTypeArray, SerializedNDimensionalFieldTypeArray } from './ndimensionalfieldtypearray';
|
|
5
|
+
import { ScalarFieldTypeEnum } from './scalarfieldtype';
|
|
6
|
+
export declare type AnyFieldTypeArrayDefinition = FieldTypeArray | NDimensionalFieldTypeArray;
|
|
7
|
+
export declare function isAnyFieldTypeArray(fieldType: BaseFieldTypeDefinition): fieldType is AnyFieldTypeArrayDefinition;
|
|
8
|
+
export declare type BaseFieldTypeDefinition = ScalarFieldTypeEnum | LiteralFieldType | AnyFieldTypeArrayDefinition | CollectionEnumFieldType;
|
|
9
|
+
export declare type SerializedBaseFieldTypeDefinition = ScalarFieldTypeEnum | SerializedLiteralFieldType | SerializedFieldTypeArray | SerializedNDimensionalFieldTypeArray | SerializedCollectionEnumFieldType;
|
|
10
|
+
export declare function isBaseFieldTypeDefinition(fieldType: any): fieldType is BaseFieldTypeDefinition;
|
|
11
|
+
export declare function serializeBaseFieldTypeDefinition(baseFieldType: BaseFieldTypeDefinition): SerializedBaseFieldTypeDefinition;
|
|
12
|
+
export declare function deserializeBaseFieldTypeDefinition(baseFieldType: SerializedBaseFieldTypeDefinition): BaseFieldTypeDefinition;
|
|
13
|
+
export declare function isSerializedBaseFieldTypeDefinition(definition: any): definition is SerializedBaseFieldTypeDefinition;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSerializedBaseFieldTypeDefinition = exports.deserializeBaseFieldTypeDefinition = exports.serializeBaseFieldTypeDefinition = exports.isBaseFieldTypeDefinition = exports.isAnyFieldTypeArray = void 0;
|
|
4
|
+
const checks_1 = require("../../checks");
|
|
5
|
+
const collectionenumfieldtype_1 = require("./collectionenumfieldtype");
|
|
6
|
+
const fieldtypearray_1 = require("./fieldtypearray");
|
|
7
|
+
const literalfieldtype_1 = require("./literalfieldtype");
|
|
8
|
+
const ndimensionalfieldtypearray_1 = require("./ndimensionalfieldtypearray");
|
|
9
|
+
const scalarfieldtype_1 = require("./scalarfieldtype");
|
|
10
|
+
function isAnyFieldTypeArray(fieldType) {
|
|
11
|
+
return fieldType instanceof fieldtypearray_1.FieldTypeArray || fieldType instanceof ndimensionalfieldtypearray_1.NDimensionalFieldTypeArray;
|
|
12
|
+
}
|
|
13
|
+
exports.isAnyFieldTypeArray = isAnyFieldTypeArray;
|
|
14
|
+
function isBaseFieldTypeDefinition(fieldType) {
|
|
15
|
+
return ((0, scalarfieldtype_1.isScalarFieldTypeEnum)(fieldType) ||
|
|
16
|
+
(0, literalfieldtype_1.isLiteralFieldType)(fieldType) ||
|
|
17
|
+
isAnyFieldTypeArray(fieldType) ||
|
|
18
|
+
(0, collectionenumfieldtype_1.isCollectionEnumFieldType)(fieldType));
|
|
19
|
+
}
|
|
20
|
+
exports.isBaseFieldTypeDefinition = isBaseFieldTypeDefinition;
|
|
21
|
+
function serializeBaseFieldTypeDefinition(baseFieldType) {
|
|
22
|
+
// Unfortunately there's no easy way to do goog.DEBUG checks inside lucid-extension-sdk right now.
|
|
23
|
+
// if (goog.DEBUG && !isBaseFieldTypeDefinition(baseFieldType)) {
|
|
24
|
+
// throw new Error(`Passed non-BaseFieldTypeDefinition into serializeBaseFieldTypeDefinition()!`);
|
|
25
|
+
// }
|
|
26
|
+
if (baseFieldType instanceof literalfieldtype_1.LiteralFieldType ||
|
|
27
|
+
baseFieldType instanceof fieldtypearray_1.FieldTypeArray ||
|
|
28
|
+
baseFieldType instanceof ndimensionalfieldtypearray_1.NDimensionalFieldTypeArray ||
|
|
29
|
+
baseFieldType instanceof collectionenumfieldtype_1.CollectionEnumFieldType) {
|
|
30
|
+
return baseFieldType.serialize();
|
|
31
|
+
}
|
|
32
|
+
return baseFieldType;
|
|
33
|
+
}
|
|
34
|
+
exports.serializeBaseFieldTypeDefinition = serializeBaseFieldTypeDefinition;
|
|
35
|
+
function deserializeBaseFieldTypeDefinition(baseFieldType) {
|
|
36
|
+
if ((0, literalfieldtype_1.isSerializedLiteralFieldType)(baseFieldType)) {
|
|
37
|
+
return (0, literalfieldtype_1.deserializeLiteralFieldType)(baseFieldType);
|
|
38
|
+
}
|
|
39
|
+
if ((0, collectionenumfieldtype_1.isSerializedCollectionEnumFieldType)(baseFieldType)) {
|
|
40
|
+
return (0, collectionenumfieldtype_1.deserializeCollectionEnumFieldType)(baseFieldType);
|
|
41
|
+
}
|
|
42
|
+
if ((0, fieldtypearray_1.isSerializedFieldTypeArray)(baseFieldType, isSerializedBaseFieldTypeDefinition)) {
|
|
43
|
+
return (0, fieldtypearray_1.deserializeFieldTypeArray)(baseFieldType);
|
|
44
|
+
}
|
|
45
|
+
if ((0, ndimensionalfieldtypearray_1.isSerializedNDimensionalFieldTypeArray)(baseFieldType)) {
|
|
46
|
+
return (0, ndimensionalfieldtypearray_1.deserializeNDimensionalFieldTypeArray)(baseFieldType);
|
|
47
|
+
}
|
|
48
|
+
return baseFieldType;
|
|
49
|
+
}
|
|
50
|
+
exports.deserializeBaseFieldTypeDefinition = deserializeBaseFieldTypeDefinition;
|
|
51
|
+
function isSerializedBaseFieldTypeDefinition(definition) {
|
|
52
|
+
return ((0, checks_1.isDefAndNotNull)(scalarfieldtype_1.ScalarFieldTypeEnum[definition]) ||
|
|
53
|
+
(0, literalfieldtype_1.isSerializedLiteralFieldType)(definition) ||
|
|
54
|
+
(0, collectionenumfieldtype_1.isSerializedCollectionEnumFieldType)(definition) ||
|
|
55
|
+
(0, fieldtypearray_1.isSerializedFieldTypeArray)(definition, isSerializedBaseFieldTypeDefinition) ||
|
|
56
|
+
(0, ndimensionalfieldtypearray_1.isSerializedNDimensionalFieldTypeArray)(definition));
|
|
57
|
+
}
|
|
58
|
+
exports.isSerializedBaseFieldTypeDefinition = isSerializedBaseFieldTypeDefinition;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const CollectionEnumFieldTypeKey = "COLLECTION_ENUM";
|
|
2
|
+
/**
|
|
3
|
+
* Contains the field names of all valid fields for a groovy metadata collection.
|
|
4
|
+
*
|
|
5
|
+
* This should be kept in sync with GroovyFieldNames in FieldType.scala
|
|
6
|
+
*/
|
|
7
|
+
export declare enum CollectionEnumFieldNames {
|
|
8
|
+
Name = "name",
|
|
9
|
+
Id = "id",
|
|
10
|
+
Description = "description",
|
|
11
|
+
Color = "color",
|
|
12
|
+
IconUrl = "iconUrl"
|
|
13
|
+
}
|
|
14
|
+
export declare class CollectionEnumFieldType {
|
|
15
|
+
readonly collectionId: string;
|
|
16
|
+
/**
|
|
17
|
+
* Specifies which groovy field name is used as the primary key.
|
|
18
|
+
*
|
|
19
|
+
* This should be kept in sync with GroovyFieldNames in FieldType.scala
|
|
20
|
+
*/
|
|
21
|
+
static readonly PRIMARY_KEY = CollectionEnumFieldNames.Id;
|
|
22
|
+
constructor(collectionId: string);
|
|
23
|
+
serialize(): SerializedCollectionEnumFieldType;
|
|
24
|
+
}
|
|
25
|
+
export declare const isCollectionEnumFieldType: (fieldType: any) => fieldType is CollectionEnumFieldType;
|
|
26
|
+
export declare type SerializedCollectionEnumFieldType = {
|
|
27
|
+
[CollectionEnumFieldTypeKey]: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function deserializeCollectionEnumFieldType(serializedCollectionEnumFieldType: SerializedCollectionEnumFieldType): CollectionEnumFieldType;
|
|
30
|
+
export declare function isSerializedCollectionEnumFieldType(fieldType: any): fieldType is SerializedCollectionEnumFieldType;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSerializedCollectionEnumFieldType = exports.deserializeCollectionEnumFieldType = exports.isCollectionEnumFieldType = exports.CollectionEnumFieldType = exports.CollectionEnumFieldNames = exports.CollectionEnumFieldTypeKey = void 0;
|
|
4
|
+
const checks_1 = require("../../checks");
|
|
5
|
+
exports.CollectionEnumFieldTypeKey = 'COLLECTION_ENUM';
|
|
6
|
+
/**
|
|
7
|
+
* Contains the field names of all valid fields for a groovy metadata collection.
|
|
8
|
+
*
|
|
9
|
+
* This should be kept in sync with GroovyFieldNames in FieldType.scala
|
|
10
|
+
*/
|
|
11
|
+
var CollectionEnumFieldNames;
|
|
12
|
+
(function (CollectionEnumFieldNames) {
|
|
13
|
+
CollectionEnumFieldNames["Name"] = "name";
|
|
14
|
+
CollectionEnumFieldNames["Id"] = "id";
|
|
15
|
+
CollectionEnumFieldNames["Description"] = "description";
|
|
16
|
+
CollectionEnumFieldNames["Color"] = "color";
|
|
17
|
+
CollectionEnumFieldNames["IconUrl"] = "iconUrl";
|
|
18
|
+
})(CollectionEnumFieldNames = exports.CollectionEnumFieldNames || (exports.CollectionEnumFieldNames = {}));
|
|
19
|
+
class CollectionEnumFieldType {
|
|
20
|
+
constructor(collectionId) {
|
|
21
|
+
this.collectionId = collectionId;
|
|
22
|
+
}
|
|
23
|
+
serialize() {
|
|
24
|
+
return { [exports.CollectionEnumFieldTypeKey]: this.collectionId };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.CollectionEnumFieldType = CollectionEnumFieldType;
|
|
28
|
+
/**
|
|
29
|
+
* Specifies which groovy field name is used as the primary key.
|
|
30
|
+
*
|
|
31
|
+
* This should be kept in sync with GroovyFieldNames in FieldType.scala
|
|
32
|
+
*/
|
|
33
|
+
CollectionEnumFieldType.PRIMARY_KEY = CollectionEnumFieldNames.Id;
|
|
34
|
+
const isCollectionEnumFieldType = (fieldType) => {
|
|
35
|
+
return fieldType instanceof CollectionEnumFieldType;
|
|
36
|
+
};
|
|
37
|
+
exports.isCollectionEnumFieldType = isCollectionEnumFieldType;
|
|
38
|
+
function deserializeCollectionEnumFieldType(serializedCollectionEnumFieldType) {
|
|
39
|
+
return new CollectionEnumFieldType(serializedCollectionEnumFieldType[exports.CollectionEnumFieldTypeKey]);
|
|
40
|
+
}
|
|
41
|
+
exports.deserializeCollectionEnumFieldType = deserializeCollectionEnumFieldType;
|
|
42
|
+
function isSerializedCollectionEnumFieldType(fieldType) {
|
|
43
|
+
return (0, checks_1.isObject)(fieldType) && (0, checks_1.isString)(fieldType[exports.CollectionEnumFieldTypeKey]);
|
|
44
|
+
}
|
|
45
|
+
exports.isSerializedCollectionEnumFieldType = isSerializedCollectionEnumFieldType;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LiteralFieldType, SerializedLiteralFieldType } from './literalfieldtype';
|
|
2
|
+
import { ScalarFieldTypeEnum } from './scalarfieldtype';
|
|
3
|
+
export declare class FieldTypeArray {
|
|
4
|
+
readonly validTypesArray: (ScalarFieldTypeEnum | LiteralFieldType | FieldTypeArray)[];
|
|
5
|
+
constructor(validTypesArray: (ScalarFieldTypeEnum | LiteralFieldType | FieldTypeArray)[]);
|
|
6
|
+
getInnerTypes(): (ScalarFieldTypeEnum | LiteralFieldType | FieldTypeArray)[];
|
|
7
|
+
getInnerNonArrayTypes(): (ScalarFieldTypeEnum | LiteralFieldType | FieldTypeArray)[];
|
|
8
|
+
serialize(): SerializedFieldTypeArray;
|
|
9
|
+
}
|
|
10
|
+
export declare function isValidTypeForFieldTypeArray(fieldType: any): fieldType is ScalarFieldTypeEnum | LiteralFieldType | FieldTypeArray;
|
|
11
|
+
export declare type SerializedFieldTypeArray = {
|
|
12
|
+
'ND': false;
|
|
13
|
+
'validTypes': (ScalarFieldTypeEnum | SerializedLiteralFieldType | SerializedFieldTypeArray)[];
|
|
14
|
+
};
|
|
15
|
+
export declare function isSerializedFieldTypeArray(fieldType: any, validateTypeCheck: (t: unknown) => boolean): fieldType is SerializedFieldTypeArray;
|
|
16
|
+
export declare function deserializeFieldTypeArray(serializedFieldTypeArray: SerializedFieldTypeArray): FieldTypeArray;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeFieldTypeArray = exports.isSerializedFieldTypeArray = exports.isValidTypeForFieldTypeArray = exports.FieldTypeArray = void 0;
|
|
4
|
+
const checks_1 = require("../../checks");
|
|
5
|
+
const literalfieldtype_1 = require("./literalfieldtype");
|
|
6
|
+
const scalarfieldtype_1 = require("./scalarfieldtype");
|
|
7
|
+
class FieldTypeArray {
|
|
8
|
+
constructor(validTypesArray) {
|
|
9
|
+
this.validTypesArray = validTypesArray;
|
|
10
|
+
}
|
|
11
|
+
getInnerTypes() {
|
|
12
|
+
return this.validTypesArray;
|
|
13
|
+
}
|
|
14
|
+
getInnerNonArrayTypes() {
|
|
15
|
+
return this.validTypesArray.filter((innerType) => (0, scalarfieldtype_1.isScalarFieldTypeEnum)(innerType) || (0, literalfieldtype_1.isLiteralFieldType)(innerType));
|
|
16
|
+
}
|
|
17
|
+
serialize() {
|
|
18
|
+
return {
|
|
19
|
+
'ND': false,
|
|
20
|
+
'validTypes': this.validTypesArray.map((t) => ((0, scalarfieldtype_1.isScalarFieldTypeEnum)(t) ? t : t.serialize())),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.FieldTypeArray = FieldTypeArray;
|
|
25
|
+
function isValidTypeForFieldTypeArray(fieldType) {
|
|
26
|
+
return (0, scalarfieldtype_1.isScalarFieldTypeEnum)(fieldType) || (0, literalfieldtype_1.isLiteralFieldType)(fieldType) || fieldType instanceof FieldTypeArray;
|
|
27
|
+
}
|
|
28
|
+
exports.isValidTypeForFieldTypeArray = isValidTypeForFieldTypeArray;
|
|
29
|
+
function isSerializedFieldTypeArray(fieldType, validateTypeCheck) {
|
|
30
|
+
return ((0, checks_1.isObject)(fieldType) &&
|
|
31
|
+
(0, checks_1.isBoolean)(fieldType['ND']) &&
|
|
32
|
+
fieldType['ND'] === false &&
|
|
33
|
+
(0, checks_1.isArray)(fieldType['validTypes']) &&
|
|
34
|
+
fieldType['validTypes'].every((validType) => {
|
|
35
|
+
return validateTypeCheck(validType);
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
exports.isSerializedFieldTypeArray = isSerializedFieldTypeArray;
|
|
39
|
+
function deserializeFieldTypeArray(serializedFieldTypeArray) {
|
|
40
|
+
return new FieldTypeArray(serializedFieldTypeArray['validTypes'].map((t) => {
|
|
41
|
+
if ((0, literalfieldtype_1.isSerializedLiteralFieldType)(t)) {
|
|
42
|
+
return (0, literalfieldtype_1.deserializeLiteralFieldType)(t);
|
|
43
|
+
}
|
|
44
|
+
else if ((0, checks_1.isObject)(t)) {
|
|
45
|
+
return deserializeFieldTypeArray(t);
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
exports.deserializeFieldTypeArray = deserializeFieldTypeArray;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseFieldTypeDefinition, SerializedBaseFieldTypeDefinition } from './basefieldtypedefinition';
|
|
2
|
+
import { NDimensionalFieldTypeArray } from './ndimensionalfieldtypearray';
|
|
3
|
+
import { ScalarFieldTypeEnum } from './scalarfieldtype';
|
|
4
|
+
export declare type FieldTypeDefinition = BaseFieldTypeDefinition | BaseFieldTypeDefinition[];
|
|
5
|
+
export declare function fieldTypesEqual(a: FieldTypeDefinition, b: FieldTypeDefinition, checkEnumCollectionId?: boolean): boolean;
|
|
6
|
+
export declare function isSubtypeOfFieldType(subType: FieldTypeDefinition, superTypes: FieldTypeDefinition): boolean;
|
|
7
|
+
export declare const AnyFieldType: (ScalarFieldTypeEnum | NDimensionalFieldTypeArray)[];
|
|
8
|
+
export declare function isAnyFieldType(type: FieldTypeDefinition): boolean;
|
|
9
|
+
export declare const serializeFieldTypeDefinition: (fieldType: FieldTypeDefinition) => SerializedFieldTypeDefinition;
|
|
10
|
+
export declare const deserializeFieldTypeDefinition: (serializedFieldType: SerializedFieldTypeDefinition) => FieldTypeDefinition;
|
|
11
|
+
export declare const SerializedAnyFieldType: SerializedFieldTypeDefinition;
|
|
12
|
+
export declare type SerializedFieldTypeDefinition = SerializedBaseFieldTypeDefinition | SerializedBaseFieldTypeDefinition[];
|
|
13
|
+
export declare function isSerializedFieldTypeDefinition(definition: any): definition is SerializedFieldTypeDefinition;
|