lucid-extension-sdk 0.0.39 → 0.0.41
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/core/unfurl/unfurlcallbacks.d.ts +20 -3
- package/sdk/core/unfurl/unfurlcallbacks.js +0 -1
- package/sdk/core/unfurl/unfurlrefresherrortype.d.ts +5 -0
- package/sdk/core/unfurl/unfurlrefresherrortype.js +10 -0
- package/sdk/document/blockclasses/linkunfurlblockproxy.d.ts +37 -0
- package/sdk/document/blockclasses/linkunfurlblockproxy.js +9 -0
- package/sdk/editorclient.js +10 -5
- package/sdk/message/registerunfurlmessage.d.ts +4 -0
- package/sdk/message/registerunfurlmessage.js +3 -0
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { ExperimentalLinkUnfurlBlockProxy } from '../../document/blockclasses/linkunfurlblockproxy';
|
|
1
2
|
import { UnfurlDetails } from './unfurldetails';
|
|
3
|
+
import { UnfurlRefreshErrorType } from './unfurlrefresherrortype';
|
|
2
4
|
export declare enum UnfurlCallbackType {
|
|
3
5
|
Unfurl = "u",
|
|
4
|
-
AfterUnfurl = "a"
|
|
5
|
-
Refresh = "r"
|
|
6
|
+
AfterUnfurl = "a"
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* The callbacks that handle unfurls and refreshing.
|
|
@@ -14,9 +15,25 @@ export interface UnfurlCallbacks {
|
|
|
14
15
|
*
|
|
15
16
|
* This should return with minimal delay to get a partial unfurl shown to the user as quick as possible.
|
|
16
17
|
* Final configuration of the unfurl should be done in afterUnfurlCallback.
|
|
18
|
+
*
|
|
19
|
+
* This callback is also used for refresh to re-fetch the information
|
|
20
|
+
*
|
|
17
21
|
* @param url The url to unfurl
|
|
18
22
|
* @return The details of the unfurl or undefined
|
|
19
23
|
* @ignore
|
|
20
24
|
*/
|
|
21
|
-
unfurlCallback: (url: string) => Promise<UnfurlDetails | undefined>;
|
|
25
|
+
unfurlCallback: (url: string) => Promise<UnfurlDetails | undefined | UnfurlRefreshErrorType>;
|
|
26
|
+
/**
|
|
27
|
+
* Callback after initial unfurl
|
|
28
|
+
* The purpose is to allow unfurlCallback to happen quickly, while afterUnfurlCallback handles longer running process
|
|
29
|
+
*
|
|
30
|
+
* For example, preview image could be added in unfurlCallback,
|
|
31
|
+
* but multiple thumbnails (or PDF conversion etc.) could be added in afterUnfurlCallback -
|
|
32
|
+
*
|
|
33
|
+
* This callback is also used for refresh to re-fetch the information
|
|
34
|
+
*
|
|
35
|
+
* @param blockProxy The block proxy of the unfurl block
|
|
36
|
+
* @ignore
|
|
37
|
+
*/
|
|
38
|
+
afterUnfurlCallback?: (blockProxy: ExperimentalLinkUnfurlBlockProxy) => Promise<void>;
|
|
22
39
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unfurlRefreshErrorTypeValidator = exports.UnfurlRefreshErrorType = void 0;
|
|
4
|
+
const validators_1 = require("../validators/validators");
|
|
5
|
+
var UnfurlRefreshErrorType;
|
|
6
|
+
(function (UnfurlRefreshErrorType) {
|
|
7
|
+
UnfurlRefreshErrorType["AuthorizationFailure"] = "Authorization failure";
|
|
8
|
+
UnfurlRefreshErrorType["GenericFailure"] = "Generic failure";
|
|
9
|
+
})(UnfurlRefreshErrorType = exports.UnfurlRefreshErrorType || (exports.UnfurlRefreshErrorType = {}));
|
|
10
|
+
exports.unfurlRefreshErrorTypeValidator = (0, validators_1.stringEnumValidator)(UnfurlRefreshErrorType);
|
|
@@ -37,4 +37,41 @@ export declare class ExperimentalLinkUnfurlBlockProxy extends BlockProxy {
|
|
|
37
37
|
* @ignore
|
|
38
38
|
*/
|
|
39
39
|
setThumbnailUrls(thumbnails: string[]): void;
|
|
40
|
+
/**
|
|
41
|
+
* @ignore
|
|
42
|
+
* Initiates the PDF upload for this block. The result includes an uploadUrl which you can use to upload the PDF.
|
|
43
|
+
* The PDF uploaded at that url will be assocaite with this block (and any copy of it) in the editor until it is refreshed.
|
|
44
|
+
* @param options The options for the upload
|
|
45
|
+
*/
|
|
46
|
+
experimentalStartPDFUpload(options: LinkUnfurlPDFOptions): Promise<LinkUnfurlPDFResult>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @ignore
|
|
50
|
+
* Options for starting the PDF upload process for a link unfurl
|
|
51
|
+
*/
|
|
52
|
+
export interface LinkUnfurlPDFOptions {
|
|
53
|
+
/**
|
|
54
|
+
* @ignore
|
|
55
|
+
* The anticipated number of pages. If this is defined, this is the number of pages that will show up while the PDF
|
|
56
|
+
* is being processed and converted into images. Once converted, the actual number will take precedence.
|
|
57
|
+
*/
|
|
58
|
+
expectedNumberOfPages: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @ignore
|
|
62
|
+
* The result of initiating the PDF upload process.
|
|
63
|
+
*/
|
|
64
|
+
export interface LinkUnfurlPDFResult {
|
|
65
|
+
/**
|
|
66
|
+
* @ignore
|
|
67
|
+
* A signed URL you can upload the pdf to. You can do this manually (via the client, your own service) or via the
|
|
68
|
+
* oauth proxy.
|
|
69
|
+
*/
|
|
70
|
+
uploadUrl: string;
|
|
71
|
+
/**
|
|
72
|
+
* @ignore
|
|
73
|
+
* The internal identifier to the PDF upload which is associated with the block.
|
|
74
|
+
* TODO: Determine if we show this to the extension, or keep internal
|
|
75
|
+
*/
|
|
76
|
+
blobId: string;
|
|
40
77
|
}
|
|
@@ -49,6 +49,15 @@ class ExperimentalLinkUnfurlBlockProxy extends blockproxy_1.BlockProxy {
|
|
|
49
49
|
setThumbnailUrls(thumbnails) {
|
|
50
50
|
this.properties.set('LinkUnfurlThumbnailUrls', thumbnails);
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @ignore
|
|
54
|
+
* Initiates the PDF upload for this block. The result includes an uploadUrl which you can use to upload the PDF.
|
|
55
|
+
* The PDF uploaded at that url will be assocaite with this block (and any copy of it) in the editor until it is refreshed.
|
|
56
|
+
* @param options The options for the upload
|
|
57
|
+
*/
|
|
58
|
+
experimentalStartPDFUpload(options) {
|
|
59
|
+
throw new Error('Not yet implemented');
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
exports.ExperimentalLinkUnfurlBlockProxy = ExperimentalLinkUnfurlBlockProxy;
|
|
54
63
|
ExperimentalLinkUnfurlBlockProxy.classNameRegex = /^LinkUnfurlBlock$/;
|
package/sdk/editorclient.js
CHANGED
|
@@ -6,8 +6,10 @@ const base64_1 = require("./core/base64");
|
|
|
6
6
|
const checks_1 = require("./core/checks");
|
|
7
7
|
const unfurlcallbacks_1 = require("./core/unfurl/unfurlcallbacks");
|
|
8
8
|
const unfurldetails_1 = require("./core/unfurl/unfurldetails");
|
|
9
|
+
const unfurlrefresherrortype_1 = require("./core/unfurl/unfurlrefresherrortype");
|
|
9
10
|
const collectionproxy_1 = require("./data/collectionproxy");
|
|
10
11
|
const blockproxyregistry_1 = require("./document/blockclasses/blockproxyregistry");
|
|
12
|
+
const linkunfurlblockproxy_1 = require("./document/blockclasses/linkunfurlblockproxy");
|
|
11
13
|
const blockproxy_1 = require("./document/blockproxy");
|
|
12
14
|
const documentproxy_1 = require("./document/documentproxy");
|
|
13
15
|
const elementproxy_1 = require("./document/elementproxy");
|
|
@@ -204,20 +206,23 @@ class EditorClient {
|
|
|
204
206
|
experimentalRegisterUnfurlHandler(domain, callbacks) {
|
|
205
207
|
const action = this.getUniqueActionName();
|
|
206
208
|
this.registerAction(action, async (rawMsg) => {
|
|
209
|
+
var _a;
|
|
207
210
|
const msg = (0, registerunfurlmessage_1.deserializeRegisterUnfurlMessage)(rawMsg);
|
|
208
211
|
switch (msg.unfurlCallbackType) {
|
|
209
212
|
case unfurlcallbacks_1.UnfurlCallbackType.Unfurl: {
|
|
210
213
|
const result = await callbacks.unfurlCallback(msg.url);
|
|
211
|
-
if (result) {
|
|
214
|
+
if (result && !(0, unfurlrefresherrortype_1.unfurlRefreshErrorTypeValidator)(result)) {
|
|
212
215
|
return (0, unfurldetails_1.serializeUnfurlDetails)(result);
|
|
213
216
|
}
|
|
214
217
|
break;
|
|
215
218
|
}
|
|
216
219
|
case unfurlcallbacks_1.UnfurlCallbackType.AfterUnfurl: {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
220
|
+
if (msg.blockId) {
|
|
221
|
+
const proxy = this.getBlockProxy(msg.blockId);
|
|
222
|
+
if (proxy instanceof linkunfurlblockproxy_1.ExperimentalLinkUnfurlBlockProxy) {
|
|
223
|
+
await ((_a = callbacks.afterUnfurlCallback) === null || _a === void 0 ? void 0 : _a.call(callbacks, proxy));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
221
226
|
}
|
|
222
227
|
default:
|
|
223
228
|
break;
|
|
@@ -9,18 +9,22 @@ export interface RegisterUnfurlMessage {
|
|
|
9
9
|
url: string;
|
|
10
10
|
/** @ignore */
|
|
11
11
|
unfurlCallbackType: UnfurlCallbackType;
|
|
12
|
+
/** @ignore */
|
|
13
|
+
blockId?: string;
|
|
12
14
|
}
|
|
13
15
|
/** @ignore */
|
|
14
16
|
export interface SerializedRegisterUnfurlMessage extends JsonObject {
|
|
15
17
|
'id': string;
|
|
16
18
|
'u': string;
|
|
17
19
|
't': UnfurlCallbackType;
|
|
20
|
+
'b'?: string;
|
|
18
21
|
}
|
|
19
22
|
/** @ignore */
|
|
20
23
|
export declare const isValidRegisterUnfurlMessage: (subject: unknown) => subject is import("../core/guards").DestructureGuardedTypeObj<{
|
|
21
24
|
id: typeof isString;
|
|
22
25
|
u: typeof isString;
|
|
23
26
|
t: (x: unknown) => x is UnfurlCallbackType;
|
|
27
|
+
b: (x: unknown) => x is string | undefined;
|
|
24
28
|
}>;
|
|
25
29
|
/** @ignore */
|
|
26
30
|
export declare function deserializeRegisterUnfurlMessage(raw: SerializedRegisterUnfurlMessage): RegisterUnfurlMessage;
|
|
@@ -9,6 +9,7 @@ exports.isValidRegisterUnfurlMessage = (0, validators_1.objectValidator)({
|
|
|
9
9
|
'id': checks_1.isString,
|
|
10
10
|
'u': checks_1.isString,
|
|
11
11
|
't': (0, validators_1.stringEnumValidator)(unfurlcallbacks_1.UnfurlCallbackType),
|
|
12
|
+
'b': (0, validators_1.option)(checks_1.isString),
|
|
12
13
|
});
|
|
13
14
|
/** @ignore */
|
|
14
15
|
function deserializeRegisterUnfurlMessage(raw) {
|
|
@@ -16,6 +17,7 @@ function deserializeRegisterUnfurlMessage(raw) {
|
|
|
16
17
|
id: raw['id'],
|
|
17
18
|
url: raw['u'],
|
|
18
19
|
unfurlCallbackType: raw['t'],
|
|
20
|
+
blockId: raw['b'],
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
exports.deserializeRegisterUnfurlMessage = deserializeRegisterUnfurlMessage;
|
|
@@ -25,6 +27,7 @@ function serializeRegisterUnfurlMessage(concrete) {
|
|
|
25
27
|
'id': concrete.id,
|
|
26
28
|
'u': concrete.url,
|
|
27
29
|
't': concrete.unfurlCallbackType,
|
|
30
|
+
'b': concrete.blockId,
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
exports.serializeRegisterUnfurlMessage = serializeRegisterUnfurlMessage;
|