lucid-extension-sdk 0.0.37 → 0.0.39
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 +9 -1
- package/sdk/core/data/fieldtypedefinition/semantickind.d.ts +14 -0
- package/sdk/core/data/fieldtypedefinition/semantickind.js +18 -0
- package/sdk/core/data/serializedfield/serializedfielddefinition.d.ts +2 -0
- package/sdk/editorclient.d.ts +32 -4
- package/sdk/editorclient.js +20 -36
package/package.json
CHANGED
package/sdk/commandtypes.d.ts
CHANGED
|
@@ -854,6 +854,7 @@ export declare type SendUIMessageQuery = {
|
|
|
854
854
|
'd'?: JsonSerializable;
|
|
855
855
|
};
|
|
856
856
|
export declare type SendUIMessageResult = undefined;
|
|
857
|
+
export declare type SendXHRResponseFormat = 'utf8' | 'binary';
|
|
857
858
|
export declare type SendXHRQuery = {
|
|
858
859
|
'url': string;
|
|
859
860
|
/** HTTP method, e.g. 'GET', 'FETCH', etc. Defaults to GET */
|
|
@@ -873,11 +874,18 @@ export declare type SendXHRQuery = {
|
|
|
873
874
|
};
|
|
874
875
|
/** Timeout in milliseconds, if specified */
|
|
875
876
|
'ms'?: number;
|
|
877
|
+
/**
|
|
878
|
+
* The desired format for the returned response body. Defaults to 'utf8'.
|
|
879
|
+
*
|
|
880
|
+
* - If 'utf8', the response body will be returned as a string.
|
|
881
|
+
* - If 'binary', the response body will be returned as a Uint8Array.
|
|
882
|
+
*/
|
|
883
|
+
'f'?: SendXHRResponseFormat;
|
|
876
884
|
};
|
|
877
885
|
export declare type RawSendXHRResponse = {
|
|
878
886
|
/** URL of the response after any redirects */
|
|
879
887
|
'url': string;
|
|
880
|
-
/** Plain-text response body */
|
|
888
|
+
/** Plain-text or base64-encoded response body */
|
|
881
889
|
't': string;
|
|
882
890
|
/** Status code of the response */
|
|
883
891
|
's': number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum SemanticKind {
|
|
2
|
+
Id = "id",
|
|
3
|
+
Title = "title",
|
|
4
|
+
Name = "name",
|
|
5
|
+
Image = "image",
|
|
6
|
+
Description = "description",
|
|
7
|
+
Assignee = "assignee",
|
|
8
|
+
Estimate = "estimate",
|
|
9
|
+
Status = "status",
|
|
10
|
+
StartTime = "starttime",
|
|
11
|
+
EndTime = "endtime",
|
|
12
|
+
GroupByHint = "groupbyhint",
|
|
13
|
+
PrimaryKeyReference = "primarykeyreference"
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SemanticKind = void 0;
|
|
4
|
+
var SemanticKind;
|
|
5
|
+
(function (SemanticKind) {
|
|
6
|
+
SemanticKind["Id"] = "id";
|
|
7
|
+
SemanticKind["Title"] = "title";
|
|
8
|
+
SemanticKind["Name"] = "name";
|
|
9
|
+
SemanticKind["Image"] = "image";
|
|
10
|
+
SemanticKind["Description"] = "description";
|
|
11
|
+
SemanticKind["Assignee"] = "assignee";
|
|
12
|
+
SemanticKind["Estimate"] = "estimate";
|
|
13
|
+
SemanticKind["Status"] = "status";
|
|
14
|
+
SemanticKind["StartTime"] = "starttime";
|
|
15
|
+
SemanticKind["EndTime"] = "endtime";
|
|
16
|
+
SemanticKind["GroupByHint"] = "groupbyhint";
|
|
17
|
+
SemanticKind["PrimaryKeyReference"] = "primarykeyreference";
|
|
18
|
+
})(SemanticKind = exports.SemanticKind || (exports.SemanticKind = {}));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { JsonSerializable } from '../../jsonserializable';
|
|
2
2
|
import { SerializedFieldTypeDefinition } from '../fieldtypedefinition/fieldtypedefinition';
|
|
3
|
+
import { SemanticKind } from '../fieldtypedefinition/semantickind';
|
|
3
4
|
export declare type SerializedFieldDefinition = {
|
|
4
5
|
'Name': string;
|
|
5
6
|
'Type': SerializedFieldTypeDefinition;
|
|
6
7
|
'Constraints'?: SerializedFieldConstraint[];
|
|
7
8
|
'SyncSchema'?: string;
|
|
9
|
+
'Mapping'?: SemanticKind[];
|
|
8
10
|
};
|
|
9
11
|
export declare enum FieldConstraintType {
|
|
10
12
|
REQUIRED = "required",
|
package/sdk/editorclient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandArgs, CommandName, UnionToIntersection } from './commandtypes';
|
|
1
|
+
import { CommandArgs, CommandName, SendXHRResponseFormat, UnionToIntersection } from './commandtypes';
|
|
2
2
|
import { JsonSerializable } from './core/jsonserializable';
|
|
3
3
|
import { UnfurlCallbacks } from './core/unfurl/unfurlcallbacks';
|
|
4
4
|
import { CollectionProxy } from './data/collectionproxy';
|
|
@@ -22,12 +22,17 @@ export interface XHRRequest {
|
|
|
22
22
|
};
|
|
23
23
|
/** If specified, this request should time out after the given number of milliseconds */
|
|
24
24
|
timeoutMs?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The desired format for the returned response body. Defaults to 'utf8'.
|
|
27
|
+
*
|
|
28
|
+
* - If 'utf8', the response body will be returned as a string.
|
|
29
|
+
* - If 'binary', the response body will be returned as a Uint8Array.
|
|
30
|
+
*/
|
|
31
|
+
responseFormat?: SendXHRResponseFormat;
|
|
25
32
|
}
|
|
26
|
-
export interface
|
|
33
|
+
export interface BaseXHRResponse {
|
|
27
34
|
/** URL of the final response, after any redirects */
|
|
28
35
|
url: string;
|
|
29
|
-
/** Plain text of the response body */
|
|
30
|
-
responseText: string;
|
|
31
36
|
/** HTTP status, e.g. 200 or 404 */
|
|
32
37
|
status: number;
|
|
33
38
|
/** Headers sent by the server in the response */
|
|
@@ -37,6 +42,17 @@ export interface XHRResponse {
|
|
|
37
42
|
/** True if this request failed due to a timeout */
|
|
38
43
|
timeout?: boolean;
|
|
39
44
|
}
|
|
45
|
+
export interface TextXHRResponse extends BaseXHRResponse {
|
|
46
|
+
responseFormat: 'utf8';
|
|
47
|
+
/** Plain text of the response body */
|
|
48
|
+
responseText: string;
|
|
49
|
+
}
|
|
50
|
+
export interface BinaryXHRResponse extends BaseXHRResponse {
|
|
51
|
+
responseFormat: 'binary';
|
|
52
|
+
/** Contents of the response body */
|
|
53
|
+
responseData: Uint8Array;
|
|
54
|
+
}
|
|
55
|
+
export declare type XHRResponse = TextXHRResponse | BinaryXHRResponse;
|
|
40
56
|
export declare type DataActionResult = {
|
|
41
57
|
/** The HTTP Status Code from the Extension Data Sync endpoint */
|
|
42
58
|
'status': number;
|
|
@@ -95,7 +111,19 @@ export declare class EditorClient {
|
|
|
95
111
|
* @returns A promise that will either resolve or reject with an XHRResponse. If the HTTP status
|
|
96
112
|
* code is not 2xx, the promise will reject.
|
|
97
113
|
*/
|
|
114
|
+
xhr(request: XHRRequest & {
|
|
115
|
+
responseFormat: 'utf8';
|
|
116
|
+
}): Promise<TextXHRResponse>;
|
|
117
|
+
xhr(request: XHRRequest & {
|
|
118
|
+
responseFormat: 'binary';
|
|
119
|
+
}): Promise<BinaryXHRResponse>;
|
|
98
120
|
xhr(request: XHRRequest): Promise<XHRResponse>;
|
|
121
|
+
oauthXhr(providerName: string, request: XHRRequest & {
|
|
122
|
+
responseFormat: 'utf8';
|
|
123
|
+
}): Promise<TextXHRResponse>;
|
|
124
|
+
oauthXhr(providerName: string, request: XHRRequest & {
|
|
125
|
+
responseFormat: 'binary';
|
|
126
|
+
}): Promise<BinaryXHRResponse>;
|
|
99
127
|
oauthXhr(providerName: string, request: XHRRequest): Promise<XHRResponse>;
|
|
100
128
|
/**
|
|
101
129
|
* Register a named action. These actions can be triggered from custom UI, for example as the action of a
|
package/sdk/editorclient.js
CHANGED
|
@@ -15,6 +15,18 @@ const groupproxy_1 = require("./document/groupproxy");
|
|
|
15
15
|
const lineproxy_1 = require("./document/lineproxy");
|
|
16
16
|
const pageproxy_1 = require("./document/pageproxy");
|
|
17
17
|
const registerunfurlmessage_1 = require("./message/registerunfurlmessage");
|
|
18
|
+
function parseRawXHRResponse(responseFormat, raw) {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
return Object.assign({ url: (_a = raw === null || raw === void 0 ? void 0 : raw['url']) !== null && _a !== void 0 ? _a : '', status: (_b = raw === null || raw === void 0 ? void 0 : raw['s']) !== null && _b !== void 0 ? _b : 0, headers: (_c = raw === null || raw === void 0 ? void 0 : raw['h']) !== null && _c !== void 0 ? _c : {}, timeout: raw === null || raw === void 0 ? void 0 : raw['to'] }, (responseFormat === 'utf8'
|
|
21
|
+
? {
|
|
22
|
+
responseFormat,
|
|
23
|
+
responseText: (_d = raw === null || raw === void 0 ? void 0 : raw['t']) !== null && _d !== void 0 ? _d : 'An unknown error occurred',
|
|
24
|
+
}
|
|
25
|
+
: {
|
|
26
|
+
responseFormat,
|
|
27
|
+
responseData: (raw === null || raw === void 0 ? void 0 : raw['t']) ? (0, base64_1.decodeBase64)(raw['t']) : new Uint8Array(0),
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
18
30
|
class EditorClient {
|
|
19
31
|
constructor() {
|
|
20
32
|
this.nextId = 0;
|
|
@@ -108,42 +120,26 @@ class EditorClient {
|
|
|
108
120
|
't': timeout,
|
|
109
121
|
}), this);
|
|
110
122
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Make a network request
|
|
113
|
-
* @param request Settings for the network request
|
|
114
|
-
* @returns A promise that will either resolve or reject with an XHRResponse. If the HTTP status
|
|
115
|
-
* code is not 2xx, the promise will reject.
|
|
116
|
-
*/
|
|
117
123
|
xhr(request) {
|
|
124
|
+
const responseFormat = request.responseFormat || 'utf8';
|
|
118
125
|
return this.sendCommand("xhr" /* SendXHR */, {
|
|
119
126
|
'url': request.url,
|
|
120
127
|
'm': request.method,
|
|
121
128
|
'd': request.data,
|
|
122
129
|
'h': request.headers,
|
|
123
130
|
'ms': request.timeoutMs,
|
|
131
|
+
'f': responseFormat,
|
|
124
132
|
})
|
|
125
133
|
.then((raw) => {
|
|
126
|
-
return
|
|
127
|
-
url: raw['url'],
|
|
128
|
-
responseText: raw['t'],
|
|
129
|
-
status: raw['s'],
|
|
130
|
-
headers: raw['h'],
|
|
131
|
-
timeout: raw['to'],
|
|
132
|
-
};
|
|
134
|
+
return parseRawXHRResponse(responseFormat, raw);
|
|
133
135
|
})
|
|
134
136
|
.catch((error) => {
|
|
135
|
-
var _a, _b, _c, _d;
|
|
136
137
|
const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
|
|
137
|
-
throw
|
|
138
|
-
url: (_a = raw === null || raw === void 0 ? void 0 : raw['url']) !== null && _a !== void 0 ? _a : '',
|
|
139
|
-
responseText: (_b = raw === null || raw === void 0 ? void 0 : raw['t']) !== null && _b !== void 0 ? _b : 'An unknown error occurred',
|
|
140
|
-
status: (_c = raw === null || raw === void 0 ? void 0 : raw['s']) !== null && _c !== void 0 ? _c : 0,
|
|
141
|
-
headers: (_d = raw === null || raw === void 0 ? void 0 : raw['h']) !== null && _d !== void 0 ? _d : {},
|
|
142
|
-
timeout: raw === null || raw === void 0 ? void 0 : raw['to'],
|
|
143
|
-
};
|
|
138
|
+
throw parseRawXHRResponse(responseFormat, raw);
|
|
144
139
|
});
|
|
145
140
|
}
|
|
146
141
|
oauthXhr(providerName, request) {
|
|
142
|
+
const responseFormat = request.responseFormat || 'utf8';
|
|
147
143
|
return this.sendCommand("oauth" /* SendOAuthRequest */, {
|
|
148
144
|
'url': request.url,
|
|
149
145
|
'm': request.method,
|
|
@@ -151,26 +147,14 @@ class EditorClient {
|
|
|
151
147
|
'h': request.headers,
|
|
152
148
|
'ms': request.timeoutMs,
|
|
153
149
|
'p': providerName,
|
|
150
|
+
'f': responseFormat,
|
|
154
151
|
})
|
|
155
152
|
.then((raw) => {
|
|
156
|
-
return
|
|
157
|
-
url: raw['url'],
|
|
158
|
-
responseText: raw['t'],
|
|
159
|
-
status: raw['s'],
|
|
160
|
-
headers: raw['h'],
|
|
161
|
-
timeout: raw['to'],
|
|
162
|
-
};
|
|
153
|
+
return parseRawXHRResponse(responseFormat, raw);
|
|
163
154
|
})
|
|
164
155
|
.catch((error) => {
|
|
165
|
-
var _a, _b, _c, _d;
|
|
166
156
|
const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
|
|
167
|
-
throw
|
|
168
|
-
url: (_a = raw === null || raw === void 0 ? void 0 : raw['url']) !== null && _a !== void 0 ? _a : '',
|
|
169
|
-
responseText: (_b = raw === null || raw === void 0 ? void 0 : raw['t']) !== null && _b !== void 0 ? _b : 'An unknown error occurred',
|
|
170
|
-
status: (_c = raw === null || raw === void 0 ? void 0 : raw['s']) !== null && _c !== void 0 ? _c : 0,
|
|
171
|
-
headers: (_d = raw === null || raw === void 0 ? void 0 : raw['h']) !== null && _d !== void 0 ? _d : {},
|
|
172
|
-
timeout: raw === null || raw === void 0 ? void 0 : raw['to'],
|
|
173
|
-
};
|
|
157
|
+
throw parseRawXHRResponse(responseFormat, raw);
|
|
174
158
|
});
|
|
175
159
|
}
|
|
176
160
|
/**
|