lucid-extension-sdk 0.0.15 → 0.0.20
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 +1 -1
- package/sdk/commandtypes.d.ts +41 -0
- package/sdk/commandtypes.js +71 -1
- package/sdk/core/data/serializedfield/serializedfielddefinition.d.ts +2 -1
- package/sdk/core/data/serializedfield/serializedfielddefinition.js +1 -0
- package/sdk/editorclient.d.ts +27 -1
- package/sdk/editorclient.js +36 -2
package/package.json
CHANGED
package/sdk/commandtypes.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare const enum CommandName {
|
|
|
29
29
|
CreateDataSource = "cds",
|
|
30
30
|
CreateLine = "cl",
|
|
31
31
|
CreatePage = "cp",
|
|
32
|
+
DataAction = "da",
|
|
32
33
|
DeleteItem = "di",
|
|
33
34
|
DeletePage = "dp",
|
|
34
35
|
DeleteShapeData = "dsd",
|
|
@@ -80,10 +81,13 @@ export declare const enum CommandName {
|
|
|
80
81
|
ShowModal = "sm",
|
|
81
82
|
ShowPanel = "spn",
|
|
82
83
|
SleepForTestCase = "sleep",
|
|
84
|
+
ThrowForTestCase = "throw",
|
|
83
85
|
UnhookCreateItems = "uci",
|
|
84
86
|
UnhookSelection = "us",
|
|
85
87
|
UnhookTextEdit = "ute"
|
|
86
88
|
}
|
|
89
|
+
/** @ignore */
|
|
90
|
+
export declare const commandTitles: Map<CommandName, string>;
|
|
87
91
|
/**
|
|
88
92
|
* This is a type declaration whose purpose is to allow TypeScript to enforce the correct parameter and
|
|
89
93
|
* return types from [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand) based on
|
|
@@ -138,6 +142,10 @@ export declare type CommandArgs = {
|
|
|
138
142
|
query: CreatePageQuery;
|
|
139
143
|
result: CreatePageResult;
|
|
140
144
|
};
|
|
145
|
+
[CommandName.DataAction]: {
|
|
146
|
+
query: DataActionQuery;
|
|
147
|
+
result: DataActionResult;
|
|
148
|
+
};
|
|
141
149
|
[CommandName.DeleteItem]: {
|
|
142
150
|
query: DeleteItemQuery;
|
|
143
151
|
result: DeleteItemResult;
|
|
@@ -342,6 +350,10 @@ export declare type CommandArgs = {
|
|
|
342
350
|
query: SleepForTestCaseQuery;
|
|
343
351
|
result: SleepForTestCaseResult;
|
|
344
352
|
};
|
|
353
|
+
[CommandName.ThrowForTestCase]: {
|
|
354
|
+
query: ThrowForTestCaseQuery;
|
|
355
|
+
result: ThrowForTestCaseResult;
|
|
356
|
+
};
|
|
345
357
|
[CommandName.UnhookCreateItems]: {
|
|
346
358
|
query: UnhookCreateItemsQuery;
|
|
347
359
|
result: UnhookCreateItemsResult;
|
|
@@ -420,6 +432,10 @@ export declare type BootstrapQuery = {
|
|
|
420
432
|
* the result of the callback, the bootstrap data is cleared.
|
|
421
433
|
*/
|
|
422
434
|
'c': string;
|
|
435
|
+
/**
|
|
436
|
+
* Marks a document as requiring the editor extension.
|
|
437
|
+
*/
|
|
438
|
+
'm'?: boolean;
|
|
423
439
|
};
|
|
424
440
|
export declare type BootstrapResult = Promise<void>;
|
|
425
441
|
export declare type ConfirmQuery = {
|
|
@@ -482,6 +498,29 @@ export declare type CreateLineQuery = {
|
|
|
482
498
|
export declare type CreateLineResult = string;
|
|
483
499
|
export declare type CreatePageQuery = void;
|
|
484
500
|
export declare type CreatePageResult = string;
|
|
501
|
+
export declare type DataActionQuery = {
|
|
502
|
+
/** Flow Name */
|
|
503
|
+
'fn': string;
|
|
504
|
+
/** Is Async */
|
|
505
|
+
'a': boolean;
|
|
506
|
+
/** Flow Data */
|
|
507
|
+
'fd'?: unknown;
|
|
508
|
+
/** Sync data source ID Nonce */
|
|
509
|
+
's'?: string;
|
|
510
|
+
/** Data Connector Name */
|
|
511
|
+
'n': string;
|
|
512
|
+
};
|
|
513
|
+
export declare type RawDataActionResult = {
|
|
514
|
+
/** The external service responded with this code */
|
|
515
|
+
'c': number;
|
|
516
|
+
} & ({
|
|
517
|
+
/** And this text */
|
|
518
|
+
't': string;
|
|
519
|
+
} | {
|
|
520
|
+
/** Or this JSON */
|
|
521
|
+
'j': unknown;
|
|
522
|
+
});
|
|
523
|
+
export declare type DataActionResult = Promise<RawDataActionResult>;
|
|
485
524
|
export declare type DeleteItemQuery = string;
|
|
486
525
|
export declare type DeleteItemResult = boolean;
|
|
487
526
|
export declare type DeletePageQuery = string;
|
|
@@ -795,6 +834,8 @@ export declare type ShowPanelQuery = {
|
|
|
795
834
|
export declare type ShowPanelResult = undefined;
|
|
796
835
|
export declare type SleepForTestCaseQuery = number;
|
|
797
836
|
export declare type SleepForTestCaseResult = Promise<void>;
|
|
837
|
+
export declare type ThrowForTestCaseQuery = number;
|
|
838
|
+
export declare type ThrowForTestCaseResult = undefined | Promise<void>;
|
|
798
839
|
export declare type UnhookCreateItemsQuery = {
|
|
799
840
|
/** Name of the action passed to HookCreateItems */
|
|
800
841
|
'n': string;
|
package/sdk/commandtypes.js
CHANGED
|
@@ -1,7 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRawSendXHRResponse = void 0;
|
|
3
|
+
exports.isRawSendXHRResponse = exports.commandTitles = void 0;
|
|
4
4
|
const checks_1 = require("./core/checks");
|
|
5
|
+
/** @ignore */
|
|
6
|
+
exports.commandTitles = new Map([
|
|
7
|
+
["alta" /* AddLineTextArea */, 'AddLineTextArea'],
|
|
8
|
+
["ami" /* AddMenuItem */, 'AddMenuItem'],
|
|
9
|
+
["asd" /* AddShapeData */, 'AddShapeData'],
|
|
10
|
+
["a" /* Alert */, 'Alert'],
|
|
11
|
+
["av" /* AnimateViewport */, 'AnimateViewport'],
|
|
12
|
+
["b" /* Bootstrap */, 'Bootstrap'],
|
|
13
|
+
["c" /* Confirm */, 'Confirm'],
|
|
14
|
+
["cb" /* CreateBlock */, 'CreateBlock'],
|
|
15
|
+
["cc" /* CreateCollection */, 'CreateCollection'],
|
|
16
|
+
["cds" /* CreateDataSource */, 'CreateDataSource'],
|
|
17
|
+
["cl" /* CreateLine */, 'CreateLine'],
|
|
18
|
+
["cp" /* CreatePage */, 'CreatePage'],
|
|
19
|
+
["di" /* DeleteItem */, 'DeleteItem'],
|
|
20
|
+
["dp" /* DeletePage */, 'DeletePage'],
|
|
21
|
+
["dsd" /* DeleteShapeData */, 'DeleteShapeData'],
|
|
22
|
+
["d" /* Download */, 'Download'],
|
|
23
|
+
["ee" /* ElementExists */, 'ElementExists'],
|
|
24
|
+
["ef" /* ExecuteFormula */, 'ExecuteFormula'],
|
|
25
|
+
["gcl" /* GetConnectedLines */, 'GetConnectedLines'],
|
|
26
|
+
["gcp" /* GetCurrentPage */, 'GetCurrentPage'],
|
|
27
|
+
["gcs" /* GetCustomShape */, 'GetCustomShape'],
|
|
28
|
+
["gdif" /* GetDataItemField */, 'GetDataItemField'],
|
|
29
|
+
["get" /* GetElementType */, 'GetElementType'],
|
|
30
|
+
["gip" /* GetItemPageId */, 'GetItemPageId'],
|
|
31
|
+
["gp" /* GetProperty */, 'GetProperty'],
|
|
32
|
+
["grk" /* GetReferenceKey */, 'GetReferenceKey'],
|
|
33
|
+
["grlp" /* GetRelativeLinePosition */, 'GetRelativeLinePosition'],
|
|
34
|
+
["gs" /* GetSelection */, 'GetSelection'],
|
|
35
|
+
["gsd" /* GetShapeData */, 'GetShapeData'],
|
|
36
|
+
["hm" /* HideModal */, 'HideModal'],
|
|
37
|
+
["hp" /* HidePanel */, 'HidePanel'],
|
|
38
|
+
["hci" /* HookCreateItems */, 'HookCreateItems'],
|
|
39
|
+
["hs" /* HookSelection */, 'HookSelection'],
|
|
40
|
+
["hte" /* HookTextEdit */, 'HookTextEdit'],
|
|
41
|
+
["k" /* KillExtension */, 'KillExtension'],
|
|
42
|
+
["lb" /* ListBlocks */, 'ListBlocks'],
|
|
43
|
+
["lcf" /* ListCollectionFields */, 'ListCollectionFields'],
|
|
44
|
+
["lc" /* ListCollections */, 'ListCollections'],
|
|
45
|
+
["ldi" /* ListDataItems */, 'ListDataItems'],
|
|
46
|
+
["lds" /* ListDataSources */, 'ListDataSources'],
|
|
47
|
+
["lg" /* ListGroups */, 'ListGroups'],
|
|
48
|
+
["ll" /* ListLines */, 'ListLines'],
|
|
49
|
+
["lp" /* ListPages */, 'ListPages'],
|
|
50
|
+
["lpr" /* ListProperties */, 'ListProperties'],
|
|
51
|
+
["lrk" /* ListReferenceKeys */, 'ListReferenceKeys'],
|
|
52
|
+
["lsd" /* ListShapeData */, 'ListShapeData'],
|
|
53
|
+
["lta" /* ListTextAreas */, 'ListTextAreas'],
|
|
54
|
+
["lbc" /* LoadBlockClasses */, 'LoadBlockClasses'],
|
|
55
|
+
["log" /* LogForTestCase */, 'LogForTestCase'],
|
|
56
|
+
["oi" /* OffsetItems */, 'OffsetItems'],
|
|
57
|
+
["pdi" /* PatchDataItems */, 'PatchDataItems'],
|
|
58
|
+
["rp" /* RegisterPanel */, 'RegisterPanel'],
|
|
59
|
+
["r" /* ReloadExtension */, 'ReloadExtension'],
|
|
60
|
+
["oauth" /* SendOAuthRequest */, 'SendOAuthRequest'],
|
|
61
|
+
["suim" /* SendUIMessage */, 'SendUIMessage'],
|
|
62
|
+
["xhr" /* SendXHR */, 'SendXHR'],
|
|
63
|
+
["scp" /* SetCurrentPage */, 'SetCurrentPage'],
|
|
64
|
+
["sp" /* SetProperty */, 'SetProperty'],
|
|
65
|
+
["srk" /* SetReferenceKey */, 'SetReferenceKey'],
|
|
66
|
+
["ssd" /* SetShapeData */, 'SetShapeData'],
|
|
67
|
+
["sm" /* ShowModal */, 'ShowModal'],
|
|
68
|
+
["spn" /* ShowPanel */, 'ShowPanel'],
|
|
69
|
+
["sleep" /* SleepForTestCase */, 'SleepForTestCase'],
|
|
70
|
+
["throw" /* ThrowForTestCase */, 'ThrowForTestCase'],
|
|
71
|
+
["uci" /* UnhookCreateItems */, 'UnhookCreateItems'],
|
|
72
|
+
["us" /* UnhookSelection */, 'UnhookSelection'],
|
|
73
|
+
["ute" /* UnhookTextEdit */, 'UnhookTextEdit'],
|
|
74
|
+
]);
|
|
5
75
|
function isRawSendXHRResponse(val) {
|
|
6
76
|
return (0, checks_1.isString)(val['url']) && (0, checks_1.isString)(val['t']) && (0, checks_1.isNumber)(val['s']) && (0, checks_1.isObject)(val['h']);
|
|
7
77
|
}
|
|
@@ -11,7 +11,8 @@ export declare enum FieldConstraintType {
|
|
|
11
11
|
LOCKED = "locked",
|
|
12
12
|
MIN_VALUE = "minValue",
|
|
13
13
|
MAX_VALUE = "maxValue",
|
|
14
|
-
SINGLE_LINE_ONLY = "singleLineOnly"
|
|
14
|
+
SINGLE_LINE_ONLY = "singleLineOnly",
|
|
15
|
+
NO_WHITESPACE = "noWhitespace"
|
|
15
16
|
}
|
|
16
17
|
export declare type SerializedFieldConstraint = {
|
|
17
18
|
'Type': FieldConstraintType;
|
|
@@ -9,4 +9,5 @@ var FieldConstraintType;
|
|
|
9
9
|
FieldConstraintType["MIN_VALUE"] = "minValue";
|
|
10
10
|
FieldConstraintType["MAX_VALUE"] = "maxValue";
|
|
11
11
|
FieldConstraintType["SINGLE_LINE_ONLY"] = "singleLineOnly";
|
|
12
|
+
FieldConstraintType["NO_WHITESPACE"] = "noWhitespace";
|
|
12
13
|
})(FieldConstraintType = exports.FieldConstraintType || (exports.FieldConstraintType = {}));
|
package/sdk/editorclient.d.ts
CHANGED
|
@@ -35,6 +35,16 @@ export interface XHRResponse {
|
|
|
35
35
|
/** True if this request failed due to a timeout */
|
|
36
36
|
timeout?: boolean;
|
|
37
37
|
}
|
|
38
|
+
export declare type DataActionResult = {
|
|
39
|
+
/** The HTTP Status Code from the Extension Data Sync endpoint */
|
|
40
|
+
'status': number;
|
|
41
|
+
} & ({
|
|
42
|
+
/** The body of the HTTP Response (if Content-Type: application/json) */
|
|
43
|
+
'json': unknown;
|
|
44
|
+
} | {
|
|
45
|
+
/** The body of the HTTP Response (otherwise) */
|
|
46
|
+
'text': string;
|
|
47
|
+
});
|
|
38
48
|
export declare class EditorClient {
|
|
39
49
|
private nextId;
|
|
40
50
|
private readonly callbacks;
|
|
@@ -55,6 +65,17 @@ export declare class EditorClient {
|
|
|
55
65
|
* @param base64 If true, base64 decode the data before downloading it
|
|
56
66
|
*/
|
|
57
67
|
download(filename: string, data: string, mime: string, base64: boolean): void;
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param flowName
|
|
71
|
+
* @param dataConnectorName
|
|
72
|
+
* @param syncDataSourceId
|
|
73
|
+
* @param flowData
|
|
74
|
+
* @param async
|
|
75
|
+
* @returns
|
|
76
|
+
* @throws A string with an error from the data sync server
|
|
77
|
+
*/
|
|
78
|
+
performDataAction(flowName: string, dataConnectorName: string, syncDataSourceId?: undefined | string, flowData?: unknown, async?: boolean): Promise<DataActionResult>;
|
|
58
79
|
/**
|
|
59
80
|
* Make a network request
|
|
60
81
|
* @param request Settings for the network request
|
|
@@ -157,12 +178,17 @@ export declare class EditorClient {
|
|
|
157
178
|
* associated with this editor extension. If this callback is async (returns a promise), then the
|
|
158
179
|
* bootstrap data is not cleared off of the document until that promise resolves.
|
|
159
180
|
*
|
|
181
|
+
* @param markExtensionAsRequired If bootstrap data is available for this editor extension, this will mark the
|
|
182
|
+
* document as requiring the extension. Once marked, if the extension is not installed the user will be
|
|
183
|
+
* notified about the extension being required on document load. The minimum extension version required by the
|
|
184
|
+
* document is the version provided in the request body when creating the document.
|
|
185
|
+
*
|
|
160
186
|
* @return a promise that resolves immediately if there is no available bootstrap data, or else after
|
|
161
187
|
* the callback successfully completes. This promise will reject/throw if the callback throws or
|
|
162
188
|
* returns a promise that rejects, or if there is another editor session processing the same bootstrap
|
|
163
189
|
* data at the same time.
|
|
164
190
|
*/
|
|
165
|
-
processAndClearBootstrapData(callback: (data: JsonSerializable) => void | Promise<void
|
|
191
|
+
processAndClearBootstrapData(callback: (data: JsonSerializable) => void | Promise<void>, markExtensionAsRequired?: boolean): Promise<void>;
|
|
166
192
|
/**
|
|
167
193
|
* @param id ID of the line to create a proxy for
|
|
168
194
|
* @returns the given line
|
package/sdk/editorclient.js
CHANGED
|
@@ -49,6 +49,35 @@ class EditorClient {
|
|
|
49
49
|
'b64': base64,
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param flowName
|
|
55
|
+
* @param dataConnectorName
|
|
56
|
+
* @param syncDataSourceId
|
|
57
|
+
* @param flowData
|
|
58
|
+
* @param async
|
|
59
|
+
* @returns
|
|
60
|
+
* @throws A string with an error from the data sync server
|
|
61
|
+
*/
|
|
62
|
+
async performDataAction(flowName, dataConnectorName, syncDataSourceId = undefined, flowData = undefined, async = true) {
|
|
63
|
+
const result = await this.sendCommand("da" /* DataAction */, {
|
|
64
|
+
'fn': flowName,
|
|
65
|
+
'a': async,
|
|
66
|
+
's': syncDataSourceId,
|
|
67
|
+
'fd': flowData,
|
|
68
|
+
'n': dataConnectorName,
|
|
69
|
+
});
|
|
70
|
+
if ('t' in result) {
|
|
71
|
+
return {
|
|
72
|
+
'status': result['c'],
|
|
73
|
+
'text': result['t'],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
'status': result['c'],
|
|
78
|
+
'json': result['j'],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
52
81
|
/**
|
|
53
82
|
* Make a network request
|
|
54
83
|
* @param request Settings for the network request
|
|
@@ -255,17 +284,22 @@ class EditorClient {
|
|
|
255
284
|
* associated with this editor extension. If this callback is async (returns a promise), then the
|
|
256
285
|
* bootstrap data is not cleared off of the document until that promise resolves.
|
|
257
286
|
*
|
|
287
|
+
* @param markExtensionAsRequired If bootstrap data is available for this editor extension, this will mark the
|
|
288
|
+
* document as requiring the extension. Once marked, if the extension is not installed the user will be
|
|
289
|
+
* notified about the extension being required on document load. The minimum extension version required by the
|
|
290
|
+
* document is the version provided in the request body when creating the document.
|
|
291
|
+
*
|
|
258
292
|
* @return a promise that resolves immediately if there is no available bootstrap data, or else after
|
|
259
293
|
* the callback successfully completes. This promise will reject/throw if the callback throws or
|
|
260
294
|
* returns a promise that rejects, or if there is another editor session processing the same bootstrap
|
|
261
295
|
* data at the same time.
|
|
262
296
|
*/
|
|
263
|
-
async processAndClearBootstrapData(callback) {
|
|
297
|
+
async processAndClearBootstrapData(callback, markExtensionAsRequired) {
|
|
264
298
|
const name = this.getUniqueActionName();
|
|
265
299
|
this.registerAction(name, (msg) => {
|
|
266
300
|
return callback(msg['d']);
|
|
267
301
|
});
|
|
268
|
-
await this.sendCommand("b" /* Bootstrap */, { 'c': name });
|
|
302
|
+
await this.sendCommand("b" /* Bootstrap */, { 'c': name, 'm': markExtensionAsRequired });
|
|
269
303
|
this.deleteAction(name);
|
|
270
304
|
}
|
|
271
305
|
/**
|