lucid-extension-sdk 0.0.126 → 0.0.128
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
CHANGED
package/sdk/commandtypes.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export declare const enum CommandName {
|
|
|
92
92
|
RegisterUnfurl = "ru",
|
|
93
93
|
ReloadExtension = "r",
|
|
94
94
|
SendOAuthRequest = "oauth",
|
|
95
|
+
SendAsyncOAuthRequest = "aoauth",
|
|
95
96
|
SendPermanentTokenRequest = "perm",
|
|
96
97
|
SendUIMessage = "suim",
|
|
97
98
|
SendXHR = "xhr",
|
|
@@ -410,6 +411,10 @@ export declare type CommandArgs = {
|
|
|
410
411
|
query: SendOAuthRequestQuery;
|
|
411
412
|
result: SendOAuthRequestResponse;
|
|
412
413
|
};
|
|
414
|
+
[CommandName.SendAsyncOAuthRequest]: {
|
|
415
|
+
query: SendAsyncOAuthRequestQuery;
|
|
416
|
+
result: SendOAuthRequestResponse;
|
|
417
|
+
};
|
|
413
418
|
[CommandName.SendPermanentTokenRequest]: {
|
|
414
419
|
query: SendPermanentTokenRequestQuery;
|
|
415
420
|
result: SendOAuthRequestResponse;
|
|
@@ -1025,6 +1030,10 @@ export declare type SendOAuthRequestQuery = SendXHRQuery & {
|
|
|
1025
1030
|
/** Post Result To */
|
|
1026
1031
|
'prt'?: string | undefined;
|
|
1027
1032
|
};
|
|
1033
|
+
export declare type SendAsyncOAuthRequestQuery = SendXHRQuery & {
|
|
1034
|
+
/** OAuth provider name as specified in the package manifest */
|
|
1035
|
+
'p': string;
|
|
1036
|
+
};
|
|
1028
1037
|
export declare type SendPermanentTokenRequestQuery = SendXHRQuery & {
|
|
1029
1038
|
/** Permanent token provider name as specified in the package manifest */
|
|
1030
1039
|
'p': string;
|
package/sdk/commandtypes.js
CHANGED
|
@@ -74,6 +74,7 @@ exports.commandTitles = new Map([
|
|
|
74
74
|
["ru" /* CommandName.RegisterUnfurl */, 'RegisterUnfurl'],
|
|
75
75
|
["r" /* CommandName.ReloadExtension */, 'ReloadExtension'],
|
|
76
76
|
["oauth" /* CommandName.SendOAuthRequest */, 'SendOAuthRequest'],
|
|
77
|
+
["aoauth" /* CommandName.SendAsyncOAuthRequest */, 'SendAsyncOAuthRequest'],
|
|
77
78
|
["suim" /* CommandName.SendUIMessage */, 'SendUIMessage'],
|
|
78
79
|
["xhr" /* CommandName.SendXHR */, 'SendXHR'],
|
|
79
80
|
["scp" /* CommandName.SetCurrentPage */, 'SetCurrentPage'],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataConnector = exports.DataConnectorRequestError = exports.DataConnectorRunError = void 0;
|
|
4
|
+
const checks_1 = require("../core/checks");
|
|
4
5
|
const action_1 = require("./actions/action");
|
|
5
6
|
const dataconnectoractionkeys_1 = require("./actions/dataconnectoractionkeys");
|
|
6
7
|
const managewebhookresponsebody_1 = require("./actions/managewebhookresponsebody");
|
|
@@ -100,12 +101,11 @@ class DataConnector {
|
|
|
100
101
|
}
|
|
101
102
|
catch (e) {
|
|
102
103
|
const errorLogger = console.error ? console.error : console.log;
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
errorLogger(`Error running ${actionName} action`, e);
|
|
105
|
+
if (isDataConnectorRunError(e)) {
|
|
105
106
|
return { status: e.status, body: e.body };
|
|
106
107
|
}
|
|
107
108
|
else {
|
|
108
|
-
errorLogger(`Error running ${actionName} action`, e);
|
|
109
109
|
return { status: 500, body: { error: `error running ${actionName} action` } };
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -122,3 +122,7 @@ class DataConnector {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
exports.DataConnector = DataConnector;
|
|
125
|
+
// instanceof DataConnectorRunError will not work in some environments
|
|
126
|
+
function isDataConnectorRunError(e) {
|
|
127
|
+
return (0, checks_1.isObject)(e) && (0, checks_1.isNumber)(e.status) && e.hasOwnProperty('body');
|
|
128
|
+
}
|
package/sdk/editorclient.d.ts
CHANGED
|
@@ -107,6 +107,28 @@ export declare class EditorClient {
|
|
|
107
107
|
responseFormat: 'binary';
|
|
108
108
|
}): Promise<BinaryXHRResponse>;
|
|
109
109
|
xhr(request: XHRRequest): Promise<XHRResponse>;
|
|
110
|
+
/**
|
|
111
|
+
* Make an asyncronous OAuth network request. The request is enqueued to eventually execute. The request may be attempted multiple times with
|
|
112
|
+
* an overall timeout of 120 seconds.
|
|
113
|
+
* @param providerName Name of the OAuth provider
|
|
114
|
+
* @param request Settings for the request
|
|
115
|
+
* @returns A promise that will either resolve or reject with an XHRResponse. If the HTTP status
|
|
116
|
+
* code is not 2xx, the promise will reject.
|
|
117
|
+
*/
|
|
118
|
+
asyncOAuthXhr(providerName: string, request: OAuthXHRRequest & {
|
|
119
|
+
responseFormat: 'utf8';
|
|
120
|
+
}): Promise<TextXHRResponse>;
|
|
121
|
+
asyncOAuthXhr(providerName: string, request: OAuthXHRRequest & {
|
|
122
|
+
responseFormat: 'binary';
|
|
123
|
+
}): Promise<BinaryXHRResponse>;
|
|
124
|
+
asyncOAuthXhr(providerName: string, request: OAuthXHRRequest): Promise<XHRResponse>;
|
|
125
|
+
/**
|
|
126
|
+
* Make an OAuth network request. Make the request immediately and only once with a 10 second timeout.
|
|
127
|
+
* @param providerName Name of the OAuth provider
|
|
128
|
+
* @param request Settings for the request
|
|
129
|
+
* @returns A promise that will either resolve or reject with an XHRResponse. If the HTTP status
|
|
130
|
+
* code is not 2xx, the promise will reject.
|
|
131
|
+
*/
|
|
110
132
|
oauthXhr(providerName: string, request: OAuthXHRRequest & {
|
|
111
133
|
responseFormat: 'utf8';
|
|
112
134
|
}): Promise<TextXHRResponse>;
|
package/sdk/editorclient.js
CHANGED
|
@@ -183,6 +183,17 @@ class EditorClient {
|
|
|
183
183
|
throw parseRawXHRResponse(responseFormat, raw);
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
+
asyncOAuthXhr(providerName, request) {
|
|
187
|
+
const responseFormat = request.responseFormat || 'utf8';
|
|
188
|
+
return this.sendCommand("aoauth" /* CommandName.SendAsyncOAuthRequest */, Object.assign({ 'url': request.url, 'm': request.method, 'd': request.data, 'h': request.headers, 'ms': request.timeoutMs, 'p': providerName, 'f': responseFormat }, (request.postResultTo ? { 'prt': request.postResultTo } : {})))
|
|
189
|
+
.then((raw) => {
|
|
190
|
+
return parseRawXHRResponse(responseFormat, raw);
|
|
191
|
+
})
|
|
192
|
+
.catch((error) => {
|
|
193
|
+
const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
|
|
194
|
+
throw parseRawXHRResponse(responseFormat, raw);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
186
197
|
oauthXhr(providerName, request) {
|
|
187
198
|
const responseFormat = request.responseFormat || 'utf8';
|
|
188
199
|
return this.sendCommand("oauth" /* CommandName.SendOAuthRequest */, Object.assign({ 'url': request.url, 'm': request.method, 'd': request.data, 'h': request.headers, 'ms': request.timeoutMs, 'p': providerName, 'f': responseFormat }, (request.postResultTo ? { 'prt': request.postResultTo } : {})))
|