lucid-extension-sdk 0.0.15 → 0.0.16
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 +28 -0
- package/sdk/editorclient.d.ts +21 -0
- package/sdk/editorclient.js +29 -0
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",
|
|
@@ -138,6 +139,10 @@ export declare type CommandArgs = {
|
|
|
138
139
|
query: CreatePageQuery;
|
|
139
140
|
result: CreatePageResult;
|
|
140
141
|
};
|
|
142
|
+
[CommandName.DataAction]: {
|
|
143
|
+
query: DataActionQuery;
|
|
144
|
+
result: DataActionResult;
|
|
145
|
+
};
|
|
141
146
|
[CommandName.DeleteItem]: {
|
|
142
147
|
query: DeleteItemQuery;
|
|
143
148
|
result: DeleteItemResult;
|
|
@@ -482,6 +487,29 @@ export declare type CreateLineQuery = {
|
|
|
482
487
|
export declare type CreateLineResult = string;
|
|
483
488
|
export declare type CreatePageQuery = void;
|
|
484
489
|
export declare type CreatePageResult = string;
|
|
490
|
+
export declare type DataActionQuery = {
|
|
491
|
+
/** Flow Name */
|
|
492
|
+
'fn': string;
|
|
493
|
+
/** Is Async */
|
|
494
|
+
'a': boolean;
|
|
495
|
+
/** Flow Data */
|
|
496
|
+
'fd'?: unknown;
|
|
497
|
+
/** Sync data source ID */
|
|
498
|
+
's': string;
|
|
499
|
+
/** Data Connector Name */
|
|
500
|
+
'n': string;
|
|
501
|
+
};
|
|
502
|
+
export declare type RawDataActionResult = {
|
|
503
|
+
/** The external service responded with this code */
|
|
504
|
+
'c': number;
|
|
505
|
+
} & ({
|
|
506
|
+
/** And this text */
|
|
507
|
+
't': string;
|
|
508
|
+
} | {
|
|
509
|
+
/** Or this JSON */
|
|
510
|
+
'j': unknown;
|
|
511
|
+
});
|
|
512
|
+
export declare type DataActionResult = Promise<RawDataActionResult>;
|
|
485
513
|
export declare type DeleteItemQuery = string;
|
|
486
514
|
export declare type DeleteItemResult = boolean;
|
|
487
515
|
export declare type DeletePageQuery = string;
|
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: string, flowData?: unknown, async?: boolean): Promise<DataActionResult>;
|
|
58
79
|
/**
|
|
59
80
|
* Make a network request
|
|
60
81
|
* @param request Settings for the network request
|
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, 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
|