lucid-extension-sdk 0.0.34 → 0.0.37

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/sdk/commandtypes.d.ts +49 -0
  3. package/sdk/commandtypes.js +3 -0
  4. package/sdk/core/cardintegration/cardintegration.d.ts +142 -0
  5. package/sdk/core/{properties → cardintegration}/cardintegration.js +31 -14
  6. package/sdk/core/unfurl/unfurlcallbacks.d.ts +22 -0
  7. package/sdk/core/unfurl/unfurlcallbacks.js +9 -0
  8. package/sdk/core/unfurl/unfurldetails.d.ts +67 -0
  9. package/sdk/core/unfurl/unfurldetails.js +42 -0
  10. package/sdk/core/unfurl/unfurliframe.d.ts +37 -0
  11. package/sdk/core/unfurl/unfurliframe.js +36 -0
  12. package/sdk/core/unfurl/unfurlthumbnail.d.ts +34 -0
  13. package/sdk/core/unfurl/unfurlthumbnail.js +30 -0
  14. package/sdk/data/collectiondefinition.d.ts +16 -0
  15. package/sdk/data/collectiondefinition.js +20 -0
  16. package/sdk/data/schemadefinition.d.ts +5 -0
  17. package/sdk/data/schemadefinition.js +2 -0
  18. package/sdk/document/blockclasses/blockproxyregistry.js +7 -1
  19. package/sdk/document/blockclasses/cardblockproxy.d.ts +4 -0
  20. package/sdk/document/blockclasses/cardblockproxy.js +8 -0
  21. package/sdk/document/blockclasses/linkunfurlblockproxy.js +2 -2
  22. package/sdk/document/mapproxy.d.ts +1 -0
  23. package/sdk/document/mapproxy.js +8 -0
  24. package/sdk/document/taskmanagementcardintegration.d.ts +2 -1
  25. package/sdk/document/taskmanagementcardintegration.js +35 -3
  26. package/sdk/editorclient.d.ts +10 -0
  27. package/sdk/editorclient.js +44 -0
  28. package/sdk/index.d.ts +1 -0
  29. package/sdk/index.js +1 -0
  30. package/sdk/message/registerunfurlmessage.d.ts +28 -0
  31. package/sdk/message/registerunfurlmessage.js +30 -0
  32. package/sdk/core/properties/cardintegration.d.ts +0 -85
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.34",
3
+ "version": "0.0.37",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -23,6 +23,7 @@ export declare const enum CommandName {
23
23
  AddShapeData = "asd",
24
24
  Alert = "a",
25
25
  AnimateViewport = "av",
26
+ AwaitImport = "ai",
26
27
  Bootstrap = "b",
27
28
  CancelDragBlockToCanvas = "cdc",
28
29
  Confirm = "c",
@@ -56,6 +57,7 @@ export declare const enum CommandName {
56
57
  HookCreateItems = "hci",
57
58
  HookSelection = "hs",
58
59
  HookTextEdit = "hte",
60
+ ImportCards = "ic",
59
61
  KillExtension = "k",
60
62
  ListBlocks = "lb",
61
63
  ListCollectionFields = "lcf",
@@ -74,6 +76,7 @@ export declare const enum CommandName {
74
76
  OffsetItems = "oi",
75
77
  PatchDataItems = "pdi",
76
78
  RegisterPanel = "rp",
79
+ RegisterUnfurl = "ru",
77
80
  ReloadExtension = "r",
78
81
  SendOAuthRequest = "oauth",
79
82
  SendUIMessage = "suim",
@@ -123,6 +126,10 @@ export declare type CommandArgs = {
123
126
  query: AnimateViewportQuery;
124
127
  result: AnimateViewportResult;
125
128
  };
129
+ [CommandName.AwaitImport]: {
130
+ query: AwaitImportQuery;
131
+ result: AwaitImportResult;
132
+ };
126
133
  [CommandName.Bootstrap]: {
127
134
  query: BootstrapQuery;
128
135
  result: BootstrapResult;
@@ -259,6 +266,10 @@ export declare type CommandArgs = {
259
266
  query: KillExtensionQuery;
260
267
  result: KillExtensionResult;
261
268
  };
269
+ [CommandName.ImportCards]: {
270
+ query: ImportCardsQuery;
271
+ result: ImportCardsResult;
272
+ };
262
273
  [CommandName.ListBlocks]: {
263
274
  query: ListChildrenQuery;
264
275
  result: ListChildrenResult;
@@ -327,6 +338,10 @@ export declare type CommandArgs = {
327
338
  query: RegisterPanelQuery;
328
339
  result: RegisterPanelResult;
329
340
  };
341
+ [CommandName.RegisterUnfurl]: {
342
+ query: RegisterUnfurlQuery;
343
+ result: RegisterUnfurlResult;
344
+ };
330
345
  [CommandName.ReloadExtension]: {
331
346
  query: ReloadExtensionQuery;
332
347
  result: ReloadExtensionResult;
@@ -401,6 +416,15 @@ export declare type AddCardIntegrationQuery = {
401
416
  'gf': string;
402
417
  /** Show intro if user has not yet authorized this integration */
403
418
  'i'?: string;
419
+ /** If specified, import modal settings */
420
+ 'im'?: {
421
+ /** Get search fields action */
422
+ 'gsf': string;
423
+ /** Search action */
424
+ 's': string;
425
+ /** Import action */
426
+ 'i': string;
427
+ };
404
428
  };
405
429
  export declare type AddCardIntegrationResult = undefined;
406
430
  export declare type AddLineTextAreaQuery = {
@@ -462,6 +486,20 @@ export declare type AlertQuery = {
462
486
  };
463
487
  /** True if they click OK, false otherwise */
464
488
  export declare type AlertResult = Promise<boolean>;
489
+ export declare type AwaitImportQuery = {
490
+ /** Data Connector Name */
491
+ 'n': string;
492
+ /** Sync data source ID Nonce */
493
+ 's'?: string;
494
+ /** Sync collection ID */
495
+ 'c': string;
496
+ /** Keys to await */
497
+ 'pk': string[];
498
+ /** Timeout in milliseconds; reject returned promise if no data appears in time */
499
+ 't': number;
500
+ };
501
+ /** Promise resolving to the collection ID where the data arrived */
502
+ export declare type AwaitImportResult = Promise<string>;
465
503
  export declare type BootstrapQuery = {
466
504
  /**
467
505
  * Named action that accepts the bootstrap data, and which may return a Promise or void. After awaiting\
@@ -708,6 +746,10 @@ export declare type HookTextEditQuery = {
708
746
  'n': string;
709
747
  };
710
748
  export declare type HookTextEditResult = undefined;
749
+ /** Name of the card integration registered by this extension to show the import dialog for */
750
+ export declare type ImportCardsQuery = string;
751
+ /** Resolves when the import dialog is closed */
752
+ export declare type ImportCardsResult = Promise<void>;
711
753
  export declare type KillExtensionQuery = void;
712
754
  export declare type KillExtensionResult = undefined;
713
755
  export declare type ListChildrenQuery = {
@@ -791,6 +833,13 @@ export declare type RegisterPanelQuery = {
791
833
  'i': string;
792
834
  };
793
835
  export declare type RegisterPanelResult = undefined;
836
+ export declare type RegisterUnfurlQuery = {
837
+ /** Domain to unfurl, e.g. www.google.com */
838
+ 'd': string;
839
+ /** Action to call to configure the unfurl */
840
+ 'a': string;
841
+ };
842
+ export declare type RegisterUnfurlResult = boolean;
794
843
  export declare type ReloadExtensionQuery = void;
795
844
  export declare type ReloadExtensionResult = undefined;
796
845
  export declare type SendOAuthRequestQuery = SendXHRQuery & {
@@ -10,6 +10,7 @@ exports.commandTitles = new Map([
10
10
  ["asd" /* AddShapeData */, 'AddShapeData'],
11
11
  ["a" /* Alert */, 'Alert'],
12
12
  ["av" /* AnimateViewport */, 'AnimateViewport'],
13
+ ["ai" /* AwaitImport */, 'AwaitImport'],
13
14
  ["b" /* Bootstrap */, 'Bootstrap'],
14
15
  ["cdc" /* CancelDragBlockToCanvas */, 'CancelDragBlockToCanvas'],
15
16
  ["c" /* Confirm */, 'Confirm'],
@@ -41,6 +42,7 @@ exports.commandTitles = new Map([
41
42
  ["hci" /* HookCreateItems */, 'HookCreateItems'],
42
43
  ["hs" /* HookSelection */, 'HookSelection'],
43
44
  ["hte" /* HookTextEdit */, 'HookTextEdit'],
45
+ ["ic" /* ImportCards */, 'ImportCards'],
44
46
  ["k" /* KillExtension */, 'KillExtension'],
45
47
  ["lb" /* ListBlocks */, 'ListBlocks'],
46
48
  ["lcf" /* ListCollectionFields */, 'ListCollectionFields'],
@@ -59,6 +61,7 @@ exports.commandTitles = new Map([
59
61
  ["oi" /* OffsetItems */, 'OffsetItems'],
60
62
  ["pdi" /* PatchDataItems */, 'PatchDataItems'],
61
63
  ["rp" /* RegisterPanel */, 'RegisterPanel'],
64
+ ["ru" /* RegisterUnfurl */, 'RegisterUnfurl'],
62
65
  ["r" /* ReloadExtension */, 'ReloadExtension'],
63
66
  ["oauth" /* SendOAuthRequest */, 'SendOAuthRequest'],
64
67
  ["suim" /* SendUIMessage */, 'SendUIMessage'],
@@ -0,0 +1,142 @@
1
+ import { CollectionDefinition } from '../../data/collectiondefinition';
2
+ import { CollectionProxy } from '../../data/collectionproxy';
3
+ import { isString } from '../checks';
4
+ import { FieldTypeDefinition, SerializedFieldTypeDefinition } from '../data/fieldtypedefinition/fieldtypedefinition';
5
+ import { isSerializedFieldType, SerializedFieldType } from '../data/serializedfield/serializedfields';
6
+ /**
7
+ * When this field is displayed on a card shape, how should it be displayed?
8
+ */
9
+ export declare enum CardFieldDisplayType {
10
+ Text = 1,
11
+ TextBadge = 2,
12
+ ImageBadge = 3
13
+ }
14
+ /** For fields with Option or ApiOption type, the label and value for each available option */
15
+ export interface ExtensionCardFieldOption {
16
+ label: string;
17
+ value: SerializedFieldType;
18
+ }
19
+ export interface ExtensionCardFieldDefinition {
20
+ /** Data identifier */
21
+ fieldName: string;
22
+ /** The text to display on the menu item */
23
+ label: string;
24
+ /** Additional information we can provide to users */
25
+ description?: string;
26
+ /** Override how a field is displayed */
27
+ displayType?: CardFieldDisplayType;
28
+ /**
29
+ * Override what kind of input to allow the user to edit the value.
30
+ * e.g. ScalarFieldTypeEnum.STRING for a text input
31
+ **/
32
+ inputType?: FieldTypeDefinition;
33
+ /** If dataType is Option, the list of options available to choose from */
34
+ options?: ExtensionCardFieldOption[];
35
+ }
36
+ /** @ignore */
37
+ export declare type SerializedCardFieldOption = {
38
+ 'l': string;
39
+ 'v'?: SerializedFieldType;
40
+ };
41
+ /** @ignore */
42
+ export declare function serializeCardFieldOption(option: ExtensionCardFieldOption): SerializedCardFieldOption;
43
+ /** @ignore */
44
+ export declare type SerializedExtensionCardFieldDefinition = {
45
+ 'n': string;
46
+ 't': string;
47
+ 'd'?: string;
48
+ 'diT'?: CardFieldDisplayType;
49
+ 'daT'?: SerializedFieldTypeDefinition;
50
+ 'op'?: SerializedCardFieldOption[];
51
+ };
52
+ /** @ignore */
53
+ export declare function serializeCardFieldDefinition(field: ExtensionCardFieldDefinition): SerializedExtensionCardFieldDefinition;
54
+ /** @ignore */
55
+ export declare function serializeCardFieldArrayDefinition(fields: ExtensionCardFieldDefinition[]): SerializedExtensionCardFieldDefinition[];
56
+ /** @ignore */
57
+ export declare function deserializeFieldOption(option: SerializedCardFieldOption): ExtensionCardFieldOption;
58
+ export declare const isSerializedFieldOption: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
59
+ l: typeof isString;
60
+ v: typeof isSerializedFieldType;
61
+ }>;
62
+ export declare const isSerializedFieldOptions: (p1: unknown) => p1 is import("../guards").DestructureGuardedTypeObj<{
63
+ l: typeof isString;
64
+ v: typeof isSerializedFieldType;
65
+ }>[];
66
+ /** @ignore */
67
+ export declare function deserializeCardFieldDefinition(field: SerializedExtensionCardFieldDefinition): ExtensionCardFieldDefinition;
68
+ /** @ignore */
69
+ export declare function deserializeCardFieldArrayDefinition(fields: SerializedExtensionCardFieldDefinition[]): ExtensionCardFieldDefinition[];
70
+ export interface CardIntegrationConfig {
71
+ /**
72
+ * The data fields to be displayed on cards, as data-linked text fields
73
+ */
74
+ fieldNames: string[];
75
+ /**
76
+ * The field name to use as the displayed ID of the card, if any
77
+ */
78
+ idFieldName?: string;
79
+ }
80
+ /** @ignore */
81
+ export declare type SerializedCardIntegrationConfig = {
82
+ 'f': string[];
83
+ 'id'?: string;
84
+ };
85
+ /** @ignore */
86
+ export declare function serializeCardIntegrationConfig(config: CardIntegrationConfig): SerializedCardIntegrationConfig;
87
+ /** @ignore */
88
+ export declare function deserializeCardIntegrationConfig(raw: SerializedCardIntegrationConfig): CardIntegrationConfig;
89
+ export interface CardIntegration {
90
+ /**
91
+ * Label used to identify the integration, e.g. "Jira", which will be used in menu items, etc.
92
+ * Should be unique within any given extension.
93
+ */
94
+ label: string;
95
+ /**
96
+ * URL for an icon to display in toolbars, etc. Should be at least 24x24.
97
+ */
98
+ iconUrl: string;
99
+ /**
100
+ * Callback to provide a list of field definitions for the given collection, if that collection
101
+ * was imported as part of this card integration.
102
+ *
103
+ * Any fields on the schema of the collection that you don't provide a ExtensionCardFieldDefinition
104
+ * for will have a default definition generated based on the type specified in the schema.
105
+ */
106
+ getAllFields: (collection: CollectionProxy) => Promise<ExtensionCardFieldDefinition[]>;
107
+ /**
108
+ * If specified, and the user hasn't yet authorized the data connector for this extension,
109
+ * this should show the user an intro dialog or take some other action.
110
+ */
111
+ showIntro?: () => void;
112
+ /**
113
+ * If specified, allow the user to import cards using the standard card-import modal.
114
+ */
115
+ importModal?: {
116
+ /**
117
+ * Given the values entered by the user so far into search fields, return the list of all search fields
118
+ * to display in the search form.
119
+ */
120
+ getSearchFields: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
121
+ /**
122
+ * Given values entered by the user into the search fields so far, return a collection of data to
123
+ * display in the results table.
124
+ */
125
+ search: (fields: Map<string, SerializedFieldType>) => Promise<{
126
+ data: CollectionDefinition;
127
+ fields: ExtensionCardFieldDefinition[];
128
+ }>;
129
+ /**
130
+ * The user checked the boxes beside the given list of items in the collection returned from search().
131
+ * Import them, and return the collection and primary keys in that final collection that were imported.
132
+ *
133
+ * The config provided here is only used on the first import from a given source; on subsequent imports,
134
+ * the existing config will remain unchanged to preserve any customizations by the user.
135
+ */
136
+ import: (primaryKeys: string[]) => Promise<{
137
+ collection: CollectionProxy;
138
+ primaryKeys: string[];
139
+ config: CardIntegrationConfig;
140
+ }>;
141
+ };
142
+ }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.deseializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption = exports.CardFieldDataType = exports.CardFieldDisplayType = void 0;
3
+ exports.deserializeCardIntegrationConfig = exports.serializeCardIntegrationConfig = exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.isSerializedFieldOptions = exports.isSerializedFieldOption = exports.deserializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption = exports.CardFieldDisplayType = void 0;
4
+ const checks_1 = require("../checks");
5
+ const fieldtypedefinition_1 = require("../data/fieldtypedefinition/fieldtypedefinition");
6
+ const serializedfields_1 = require("../data/serializedfield/serializedfields");
7
+ const validators_1 = require("../validators/validators");
4
8
  /**
5
9
  * When this field is displayed on a card shape, how should it be displayed?
6
10
  */
@@ -10,14 +14,6 @@ var CardFieldDisplayType;
10
14
  CardFieldDisplayType[CardFieldDisplayType["TextBadge"] = 2] = "TextBadge";
11
15
  CardFieldDisplayType[CardFieldDisplayType["ImageBadge"] = 3] = "ImageBadge";
12
16
  })(CardFieldDisplayType = exports.CardFieldDisplayType || (exports.CardFieldDisplayType = {}));
13
- var CardFieldDataType;
14
- (function (CardFieldDataType) {
15
- CardFieldDataType[CardFieldDataType["Text"] = 1] = "Text";
16
- CardFieldDataType[CardFieldDataType["Number"] = 2] = "Number";
17
- /** An enumerated list of options, stored as a string */
18
- CardFieldDataType[CardFieldDataType["Option"] = 3] = "Option";
19
- CardFieldDataType[CardFieldDataType["Checkbox"] = 4] = "Checkbox";
20
- })(CardFieldDataType = exports.CardFieldDataType || (exports.CardFieldDataType = {}));
21
17
  /** @ignore */
22
18
  function serializeCardFieldOption(option) {
23
19
  return {
@@ -34,7 +30,7 @@ function serializeCardFieldDefinition(field) {
34
30
  't': field.label,
35
31
  'd': field.description,
36
32
  'diT': field.displayType,
37
- 'daT': field.dataType,
33
+ 'daT': field.inputType === undefined ? undefined : (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.inputType),
38
34
  'op': (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption),
39
35
  };
40
36
  }
@@ -45,13 +41,18 @@ function serializeCardFieldArrayDefinition(fields) {
45
41
  }
46
42
  exports.serializeCardFieldArrayDefinition = serializeCardFieldArrayDefinition;
47
43
  /** @ignore */
48
- function deseializeFieldOption(option) {
44
+ function deserializeFieldOption(option) {
49
45
  return {
50
46
  label: option['l'],
51
47
  value: option['v'],
52
48
  };
53
49
  }
54
- exports.deseializeFieldOption = deseializeFieldOption;
50
+ exports.deserializeFieldOption = deserializeFieldOption;
51
+ exports.isSerializedFieldOption = (0, validators_1.objectValidator)({
52
+ 'l': checks_1.isString,
53
+ 'v': serializedfields_1.isSerializedFieldType,
54
+ });
55
+ exports.isSerializedFieldOptions = (0, validators_1.arrayValidator)(exports.isSerializedFieldOption);
55
56
  /** @ignore */
56
57
  function deserializeCardFieldDefinition(field) {
57
58
  var _a;
@@ -60,8 +61,8 @@ function deserializeCardFieldDefinition(field) {
60
61
  label: field['t'],
61
62
  description: field['d'],
62
63
  displayType: field['diT'],
63
- dataType: field['daT'],
64
- options: (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deseializeFieldOption),
64
+ inputType: field['daT'] === undefined ? undefined : (0, fieldtypedefinition_1.deserializeFieldTypeDefinition)(field['daT']),
65
+ options: (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption),
65
66
  };
66
67
  }
67
68
  exports.deserializeCardFieldDefinition = deserializeCardFieldDefinition;
@@ -70,3 +71,19 @@ function deserializeCardFieldArrayDefinition(fields) {
70
71
  return fields.map(deserializeCardFieldDefinition);
71
72
  }
72
73
  exports.deserializeCardFieldArrayDefinition = deserializeCardFieldArrayDefinition;
74
+ /** @ignore */
75
+ function serializeCardIntegrationConfig(config) {
76
+ return {
77
+ 'f': config.fieldNames,
78
+ 'id': config.idFieldName,
79
+ };
80
+ }
81
+ exports.serializeCardIntegrationConfig = serializeCardIntegrationConfig;
82
+ /** @ignore */
83
+ function deserializeCardIntegrationConfig(raw) {
84
+ return {
85
+ fieldNames: raw['f'],
86
+ idFieldName: raw['id'],
87
+ };
88
+ }
89
+ exports.deserializeCardIntegrationConfig = deserializeCardIntegrationConfig;
@@ -0,0 +1,22 @@
1
+ import { UnfurlDetails } from './unfurldetails';
2
+ export declare enum UnfurlCallbackType {
3
+ Unfurl = "u",
4
+ AfterUnfurl = "a",
5
+ Refresh = "r"
6
+ }
7
+ /**
8
+ * The callbacks that handle unfurls and refreshing.
9
+ * @ignore
10
+ */
11
+ export interface UnfurlCallbacks {
12
+ /**
13
+ * Callback upon initial unfurl.
14
+ *
15
+ * This should return with minimal delay to get a partial unfurl shown to the user as quick as possible.
16
+ * Final configuration of the unfurl should be done in afterUnfurlCallback.
17
+ * @param url The url to unfurl
18
+ * @return The details of the unfurl or undefined
19
+ * @ignore
20
+ */
21
+ unfurlCallback: (url: string) => Promise<UnfurlDetails | undefined>;
22
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnfurlCallbackType = void 0;
4
+ var UnfurlCallbackType;
5
+ (function (UnfurlCallbackType) {
6
+ UnfurlCallbackType["Unfurl"] = "u";
7
+ UnfurlCallbackType["AfterUnfurl"] = "a";
8
+ UnfurlCallbackType["Refresh"] = "r";
9
+ })(UnfurlCallbackType = exports.UnfurlCallbackType || (exports.UnfurlCallbackType = {}));
@@ -0,0 +1,67 @@
1
+ import { isString } from '../checks';
2
+ import { SerializedUnfurlIframe, UnfurlIframe } from './unfurliframe';
3
+ import { SerializedUnfurlThumbnail, UnfurlThumbnail } from './unfurlthumbnail';
4
+ /**
5
+ * A definition of the details required to show an unfurl block in the editor.
6
+ */
7
+ export interface UnfurlDetails {
8
+ /**
9
+ * The name of the extension attributed to the unfurl. This is a user facing name that is used to attribute the
10
+ * unfurl to a specific third party.
11
+ */
12
+ providerName: string;
13
+ /**
14
+ * The favicon of the provider of this unfurl.
15
+ */
16
+ providerFaviconUrl: string;
17
+ /**
18
+ * The title associated with the link being unfurled. For example, the document or web page title.
19
+ */
20
+ unfurlTitle?: string;
21
+ /**
22
+ * If the unfurl supports an expandable iframe, this configuration defines its properties.
23
+ */
24
+ iframe?: UnfurlIframe;
25
+ /**
26
+ * If the unfurl contains one or more images, this configuration defines those properties.
27
+ */
28
+ thumbnails?: UnfurlThumbnail[];
29
+ /**
30
+ * The url to show if there are no thumbnails.
31
+ *
32
+ * This can be useful to show an initial image while using other mechanisms to add all thumbnails after the unfurl is created.
33
+ */
34
+ previewImageUrl?: string;
35
+ }
36
+ /** @ignore */
37
+ export interface SerializedUnfurlDetails {
38
+ 'ProviderName': string;
39
+ 'ProviderFaviconUrl': string;
40
+ 'UnfurlTitle'?: string;
41
+ 'Iframe'?: SerializedUnfurlIframe;
42
+ 'Thumbnails'?: SerializedUnfurlThumbnail[];
43
+ 'PreviewImageUrl'?: string;
44
+ }
45
+ /** @ignore */
46
+ export declare const isValidUnfurlDetails: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
47
+ ProviderName: typeof isString;
48
+ ProviderFaviconUrl: typeof isString;
49
+ UnfurlTitle: (x: unknown) => x is string | undefined;
50
+ Iframe: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
51
+ IframeUrl: typeof isString;
52
+ Size: (x: unknown) => x is import("./unfurliframe").UnfurlIframeSize.Standard | undefined;
53
+ }> | undefined;
54
+ Thumbnails: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
55
+ url: typeof isString;
56
+ width: (x: unknown) => x is number | null | undefined;
57
+ /**
58
+ * The title associated with the link being unfurled. For example, the document or web page title.
59
+ */
60
+ height: (x: unknown) => x is number | null | undefined;
61
+ }>[] | undefined;
62
+ PreviewImageUrl: (x: unknown) => x is string | undefined;
63
+ }>;
64
+ /** @ignore */
65
+ export declare function deserializeUnfurlDetails(raw: SerializedUnfurlDetails): UnfurlDetails;
66
+ /** @ignore */
67
+ export declare function serializeUnfurlDetails(concrete: UnfurlDetails): SerializedUnfurlDetails;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeUnfurlDetails = exports.deserializeUnfurlDetails = exports.isValidUnfurlDetails = void 0;
4
+ const checks_1 = require("../checks");
5
+ const validators_1 = require("../validators/validators");
6
+ const unfurliframe_1 = require("./unfurliframe");
7
+ const unfurlthumbnail_1 = require("./unfurlthumbnail");
8
+ /** @ignore */
9
+ exports.isValidUnfurlDetails = (0, validators_1.objectValidator)({
10
+ 'ProviderName': checks_1.isString,
11
+ 'ProviderFaviconUrl': checks_1.isString,
12
+ 'UnfurlTitle': (0, validators_1.option)(checks_1.isString),
13
+ 'Iframe': (0, validators_1.option)(unfurliframe_1.isValidUnfurlIframe),
14
+ 'Thumbnails': (0, validators_1.option)((0, validators_1.arrayValidator)(unfurlthumbnail_1.isValidUnfurlThumbnail)),
15
+ 'PreviewImageUrl': (0, validators_1.option)(checks_1.isString),
16
+ });
17
+ /** @ignore */
18
+ function deserializeUnfurlDetails(raw) {
19
+ var _a;
20
+ return {
21
+ providerName: raw['ProviderName'],
22
+ providerFaviconUrl: raw['ProviderFaviconUrl'],
23
+ unfurlTitle: raw['UnfurlTitle'],
24
+ iframe: raw['Iframe'] && (0, unfurliframe_1.deserializeUnfurlIframe)(raw['Iframe']),
25
+ thumbnails: (_a = raw['Thumbnails']) === null || _a === void 0 ? void 0 : _a.map((raw) => (0, unfurlthumbnail_1.deserializeUnfurlThumbnail)(raw)),
26
+ previewImageUrl: raw['PreviewImageUrl'],
27
+ };
28
+ }
29
+ exports.deserializeUnfurlDetails = deserializeUnfurlDetails;
30
+ /** @ignore */
31
+ function serializeUnfurlDetails(concrete) {
32
+ var _a;
33
+ return {
34
+ 'ProviderName': concrete.providerName,
35
+ 'ProviderFaviconUrl': concrete.providerFaviconUrl,
36
+ 'UnfurlTitle': concrete.unfurlTitle,
37
+ 'Iframe': concrete.iframe && (0, unfurliframe_1.serializeUnfurlIframe)(concrete.iframe),
38
+ 'Thumbnails': (_a = concrete.thumbnails) === null || _a === void 0 ? void 0 : _a.map((raw) => (0, unfurlthumbnail_1.serializeUnfurlThumbnail)(raw)),
39
+ 'PreviewImageUrl': concrete.previewImageUrl,
40
+ };
41
+ }
42
+ exports.serializeUnfurlDetails = serializeUnfurlDetails;
@@ -0,0 +1,37 @@
1
+ import { isString } from '../checks';
2
+ /**
3
+ * An enumeration of of the supported unfurl Iframe sizes.
4
+ */
5
+ export declare enum UnfurlIframeSize {
6
+ /**
7
+ * The standard iframe size.
8
+ */
9
+ Standard = "standard"
10
+ }
11
+ /**
12
+ * A definition of the properties needed to expand an iframe for an unfurl
13
+ */
14
+ export interface UnfurlIframe {
15
+ /**
16
+ * The iframe url
17
+ */
18
+ iframeUrl: string;
19
+ /**
20
+ * The size of the iframe requested
21
+ */
22
+ size?: UnfurlIframeSize;
23
+ }
24
+ /** @ignore */
25
+ export interface SerializedUnfurlIframe {
26
+ 'IframeUrl': string;
27
+ 'Size'?: UnfurlIframeSize;
28
+ }
29
+ /** @ignore */
30
+ export declare const isValidUnfurlIframe: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
31
+ IframeUrl: typeof isString;
32
+ Size: (x: unknown) => x is UnfurlIframeSize.Standard | undefined;
33
+ }>;
34
+ /** @ignore */
35
+ export declare function deserializeUnfurlIframe(raw: SerializedUnfurlIframe): UnfurlIframe;
36
+ /** @ignore */
37
+ export declare function serializeUnfurlIframe(concrete: UnfurlIframe): SerializedUnfurlIframe;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeUnfurlIframe = exports.deserializeUnfurlIframe = exports.isValidUnfurlIframe = exports.UnfurlIframeSize = void 0;
4
+ const checks_1 = require("../checks");
5
+ const validators_1 = require("../validators/validators");
6
+ /**
7
+ * An enumeration of of the supported unfurl Iframe sizes.
8
+ */
9
+ var UnfurlIframeSize;
10
+ (function (UnfurlIframeSize) {
11
+ /**
12
+ * The standard iframe size.
13
+ */
14
+ UnfurlIframeSize["Standard"] = "standard";
15
+ })(UnfurlIframeSize = exports.UnfurlIframeSize || (exports.UnfurlIframeSize = {}));
16
+ /** @ignore */
17
+ exports.isValidUnfurlIframe = (0, validators_1.objectValidator)({
18
+ 'IframeUrl': checks_1.isString,
19
+ 'Size': (0, validators_1.option)((0, validators_1.stringEnumValidator)(UnfurlIframeSize)),
20
+ });
21
+ /** @ignore */
22
+ function deserializeUnfurlIframe(raw) {
23
+ return {
24
+ iframeUrl: raw['IframeUrl'],
25
+ size: raw['Size'],
26
+ };
27
+ }
28
+ exports.deserializeUnfurlIframe = deserializeUnfurlIframe;
29
+ /** @ignore */
30
+ function serializeUnfurlIframe(concrete) {
31
+ return {
32
+ 'IframeUrl': concrete.iframeUrl,
33
+ 'Size': concrete.size,
34
+ };
35
+ }
36
+ exports.serializeUnfurlIframe = serializeUnfurlIframe;
@@ -0,0 +1,34 @@
1
+ import { isString } from '../checks';
2
+ /**
3
+ * A definition of a single unfurl thumbnail
4
+ */
5
+ export interface UnfurlThumbnail {
6
+ /**
7
+ * The URL to fetch the image from
8
+ */
9
+ url: string;
10
+ /**
11
+ * The width of the image. This is not the height it will be displayed at, but rather the width the image actually is.
12
+ */
13
+ width?: number;
14
+ /**
15
+ * The height of the image. This is not the height it will be displayed at, but rather the height the image actually is.
16
+ */
17
+ height?: number;
18
+ }
19
+ /** @ignore */
20
+ export interface SerializedUnfurlThumbnail {
21
+ 'url': string;
22
+ 'width'?: number | null;
23
+ 'height'?: number | null;
24
+ }
25
+ /** @ignore */
26
+ export declare const isValidUnfurlThumbnail: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
27
+ url: typeof isString;
28
+ width: (x: unknown) => x is number | null | undefined;
29
+ height: (x: unknown) => x is number | null | undefined;
30
+ }>;
31
+ /** @ignore */
32
+ export declare function deserializeUnfurlThumbnail(raw: SerializedUnfurlThumbnail): UnfurlThumbnail;
33
+ /** @ignore */
34
+ export declare function serializeUnfurlThumbnail(concrete: UnfurlThumbnail): SerializedUnfurlThumbnail;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeUnfurlThumbnail = exports.deserializeUnfurlThumbnail = exports.isValidUnfurlThumbnail = void 0;
4
+ const checks_1 = require("../checks");
5
+ const validators_1 = require("../validators/validators");
6
+ /** @ignore */
7
+ exports.isValidUnfurlThumbnail = (0, validators_1.objectValidator)({
8
+ 'url': checks_1.isString,
9
+ 'width': (0, validators_1.nullableOption)(checks_1.isNumber),
10
+ 'height': (0, validators_1.nullableOption)(checks_1.isNumber),
11
+ });
12
+ /** @ignore */
13
+ function deserializeUnfurlThumbnail(raw) {
14
+ var _a, _b;
15
+ return {
16
+ url: raw['url'],
17
+ width: (_a = raw['width']) !== null && _a !== void 0 ? _a : undefined,
18
+ height: (_b = raw['height']) !== null && _b !== void 0 ? _b : undefined,
19
+ };
20
+ }
21
+ exports.deserializeUnfurlThumbnail = deserializeUnfurlThumbnail;
22
+ /** @ignore */
23
+ function serializeUnfurlThumbnail(concrete) {
24
+ return {
25
+ 'url': concrete.url,
26
+ 'width': concrete.width,
27
+ 'height': concrete.height,
28
+ };
29
+ }
30
+ exports.serializeUnfurlThumbnail = serializeUnfurlThumbnail;
@@ -0,0 +1,16 @@
1
+ import { SerializedFields } from '../core/data/serializedfield/serializedfields';
2
+ import { SerializedSchema } from '../core/data/serializedfield/serializedschema';
3
+ import { SchemaDefinition } from './schemadefinition';
4
+ export interface CollectionDefinition {
5
+ schema: SchemaDefinition;
6
+ items: Map<string, SerializedFields>;
7
+ }
8
+ /** @ignore */
9
+ export declare function serializeCollectionDefinition(def: CollectionDefinition): SerializedCollectionDefinition;
10
+ /** @ignore */
11
+ export declare function deserializeCollectionDefinition(raw: SerializedCollectionDefinition): CollectionDefinition;
12
+ /** @ignore */
13
+ export interface SerializedCollectionDefinition {
14
+ 'Schema': SerializedSchema;
15
+ 'Items': [string, SerializedFields][];
16
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeCollectionDefinition = exports.serializeCollectionDefinition = void 0;
4
+ const schemadefinition_1 = require("./schemadefinition");
5
+ /** @ignore */
6
+ function serializeCollectionDefinition(def) {
7
+ return {
8
+ 'Schema': (0, schemadefinition_1.serializeSchemaDefinition)(def.schema),
9
+ 'Items': [...def.items.entries()],
10
+ };
11
+ }
12
+ exports.serializeCollectionDefinition = serializeCollectionDefinition;
13
+ /** @ignore */
14
+ function deserializeCollectionDefinition(raw) {
15
+ return {
16
+ schema: (0, schemadefinition_1.parseSchemaDefinition)(raw['Schema']),
17
+ items: new Map(raw['Items']),
18
+ };
19
+ }
20
+ exports.deserializeCollectionDefinition = deserializeCollectionDefinition;
@@ -17,6 +17,11 @@ export interface SchemaDefinition {
17
17
  * Typically this contains only one field name, and that field is usually unique.
18
18
  */
19
19
  primaryKey: string[];
20
+ /**
21
+ * Maps field names to labels to display in the UI when necessary. If any field name
22
+ * is not present as a key in this label map, the field name itself will be the label.
23
+ */
24
+ fieldLabels?: Record<string, string>;
20
25
  }
21
26
  /** @ignore */
22
27
  export declare function serializeSchemaDefinition(def: SchemaDefinition): SerializedSchema;
@@ -12,6 +12,7 @@ function serializeSchemaDefinition(def) {
12
12
  };
13
13
  }),
14
14
  'PrimaryKey': def.primaryKey,
15
+ 'FieldLabelOverrides': def.fieldLabels,
15
16
  };
16
17
  }
17
18
  exports.serializeSchemaDefinition = serializeSchemaDefinition;
@@ -25,6 +26,7 @@ function parseSchemaDefinition(def) {
25
26
  };
26
27
  }),
27
28
  primaryKey: def['PrimaryKey'],
29
+ fieldLabels: def['FieldLabelOverrides'],
28
30
  };
29
31
  }
30
32
  exports.parseSchemaDefinition = parseSchemaDefinition;
@@ -1,10 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findProxyClass = void 0;
4
+ const cardblockproxy_1 = require("./cardblockproxy");
4
5
  const customblockproxy_1 = require("./customblockproxy");
5
6
  const erdblockproxy_1 = require("./erdblockproxy");
6
7
  const linkunfurlblockproxy_1 = require("./linkunfurlblockproxy");
7
- const allProxyClasses = [erdblockproxy_1.ERDBlockProxy, customblockproxy_1.CustomBlockProxy, linkunfurlblockproxy_1.ExperimentalLinkUnfurlBlockProxy];
8
+ const allProxyClasses = [
9
+ erdblockproxy_1.ERDBlockProxy,
10
+ customblockproxy_1.CustomBlockProxy,
11
+ linkunfurlblockproxy_1.ExperimentalLinkUnfurlBlockProxy,
12
+ cardblockproxy_1.CardBlockProxy,
13
+ ];
8
14
  function findProxyClass(className) {
9
15
  return allProxyClasses.find((proxy) => proxy.classNameRegex.test(className));
10
16
  }
@@ -0,0 +1,4 @@
1
+ import { BlockProxy } from '../blockproxy';
2
+ export declare class CardBlockProxy extends BlockProxy {
3
+ static classNameRegex: RegExp;
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CardBlockProxy = void 0;
4
+ const blockproxy_1 = require("../blockproxy");
5
+ class CardBlockProxy extends blockproxy_1.BlockProxy {
6
+ }
7
+ exports.CardBlockProxy = CardBlockProxy;
8
+ CardBlockProxy.classNameRegex = /^LucidCardBlock$/;
@@ -39,7 +39,7 @@ class ExperimentalLinkUnfurlBlockProxy extends blockproxy_1.BlockProxy {
39
39
  * @ignore
40
40
  */
41
41
  setPreviewThumbnailUrl(thumbnailUrl) {
42
- throw new Error('Not yet implemented');
42
+ this.properties.set('LinkUnfurlThumbnailUrl', thumbnailUrl);
43
43
  }
44
44
  /**
45
45
  * Sets additional thumbnails on the block
@@ -47,7 +47,7 @@ class ExperimentalLinkUnfurlBlockProxy extends blockproxy_1.BlockProxy {
47
47
  * @ignore
48
48
  */
49
49
  setThumbnailUrls(thumbnails) {
50
- throw new Error('Not yet implemented');
50
+ this.properties.set('LinkUnfurlThumbnailUrls', thumbnails);
51
51
  }
52
52
  }
53
53
  exports.ExperimentalLinkUnfurlBlockProxy = ExperimentalLinkUnfurlBlockProxy;
@@ -9,6 +9,7 @@ export declare class MapProxy<KEY, VALUE> {
9
9
  /** @ignore */
10
10
  [Symbol.iterator](): Iterator<[KEY, VALUE]>;
11
11
  values(): Generator<VALUE, void, unknown>;
12
+ find(filter: (item: VALUE, key: KEY) => boolean): VALUE | undefined;
12
13
  keys(): KEY[];
13
14
  get size(): number;
14
15
  get(key: KEY): VALUE;
@@ -27,6 +27,14 @@ class MapProxy {
27
27
  }
28
28
  }
29
29
  }
30
+ find(filter) {
31
+ for (const [key, value] of this) {
32
+ if (filter(value, key)) {
33
+ return value;
34
+ }
35
+ }
36
+ return undefined;
37
+ }
30
38
  keys() {
31
39
  return this.getKeys();
32
40
  }
@@ -1,4 +1,4 @@
1
- import { CardIntegration } from '../core/properties/cardintegration';
1
+ import { CardIntegration } from '../core/cardintegration/cardintegration';
2
2
  import { EditorClient } from '../editorclient';
3
3
  export declare class TaskManagementCardIntegration {
4
4
  private readonly client;
@@ -10,4 +10,5 @@ export declare class TaskManagementCardIntegration {
10
10
  * @param card The definition of the new card integration
11
11
  */
12
12
  addCardIntegration(card: CardIntegration): void;
13
+ showCardImport(name: string): import("../commandtypes").ImportCardsResult;
13
14
  }
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskManagementCardIntegration = void 0;
4
- const cardintegration_1 = require("../core/properties/cardintegration");
4
+ const cardintegration_1 = require("../core/cardintegration/cardintegration");
5
+ const collectiondefinition_1 = require("../data/collectiondefinition");
5
6
  const collectionproxy_1 = require("../data/collectionproxy");
6
7
  class TaskManagementCardIntegration {
7
8
  constructor(client) {
@@ -27,12 +28,43 @@ class TaskManagementCardIntegration {
27
28
  showIntroActionName = TaskManagementCardIntegration.nextHookName();
28
29
  this.client.registerAction(showIntroActionName, card.showIntro);
29
30
  }
30
- this.client.sendCommand("aci" /* AddCardIntegration */, {
31
+ const serialized = {
31
32
  'n': card.label,
32
33
  'u': card.iconUrl,
33
34
  'gf': getFieldsActionName,
34
35
  'i': showIntroActionName,
35
- });
36
+ };
37
+ if (card.importModal) {
38
+ const importModal = card.importModal;
39
+ serialized['im'] = {
40
+ 'gsf': TaskManagementCardIntegration.nextHookName(),
41
+ 's': TaskManagementCardIntegration.nextHookName(),
42
+ 'i': TaskManagementCardIntegration.nextHookName(),
43
+ };
44
+ this.client.registerAction(serialized['im']['gsf'], async ({ 's': searchSoFar }) => {
45
+ const result = await importModal.getSearchFields(new Map(searchSoFar));
46
+ return (0, cardintegration_1.serializeCardFieldArrayDefinition)(result);
47
+ });
48
+ this.client.registerAction(serialized['im']['s'], async ({ 's': search }) => {
49
+ const result = await importModal.search(new Map(search));
50
+ return {
51
+ 'd': (0, collectiondefinition_1.serializeCollectionDefinition)(result.data),
52
+ 'f': (0, cardintegration_1.serializeCardFieldArrayDefinition)(result.fields),
53
+ };
54
+ });
55
+ this.client.registerAction(serialized['im']['i'], async ({ 'pks': primaryKeys }) => {
56
+ const result = await importModal.import(primaryKeys);
57
+ return {
58
+ 'c': result.collection.id,
59
+ 'pks': result.primaryKeys,
60
+ 'cfg': (0, cardintegration_1.serializeCardIntegrationConfig)(result.config),
61
+ };
62
+ });
63
+ }
64
+ this.client.sendCommand("aci" /* AddCardIntegration */, serialized);
65
+ }
66
+ showCardImport(name) {
67
+ return this.client.sendCommand("ic" /* ImportCards */, name);
36
68
  }
37
69
  }
38
70
  exports.TaskManagementCardIntegration = TaskManagementCardIntegration;
@@ -1,5 +1,7 @@
1
1
  import { CommandArgs, CommandName, UnionToIntersection } from './commandtypes';
2
2
  import { JsonSerializable } from './core/jsonserializable';
3
+ import { UnfurlCallbacks } from './core/unfurl/unfurlcallbacks';
4
+ import { CollectionProxy } from './data/collectionproxy';
3
5
  import { BlockDefinition } from './document/blockdefinition';
4
6
  import { BlockProxy } from './document/blockproxy';
5
7
  import { ElementProxy } from './document/elementproxy';
@@ -86,6 +88,7 @@ export declare class EditorClient {
86
88
  * @throws A string with an error from the data sync server
87
89
  */
88
90
  performDataAction(flowName: string, dataConnectorName: string, syncDataSourceId?: undefined | string, flowData?: unknown, async?: boolean): Promise<DataActionResult>;
91
+ awaitDataImport(dataConnectorName: string, syncDataSourceId: undefined | string, syncCollectionId: string, primaryKeys: string[], timeout?: number): Promise<CollectionProxy>;
89
92
  /**
90
93
  * Make a network request
91
94
  * @param request Settings for the network request
@@ -116,6 +119,13 @@ export declare class EditorClient {
116
119
  * @param callback Function to execute when this action is invoked
117
120
  */
118
121
  registerFileUploadAction(name: string, callback: (files: FileUploadData[]) => void): void;
122
+ /**
123
+ * @ignore
124
+ * Registers an handler for link unfurling.
125
+ * @param domain The domain
126
+ * @param callbacks The callbacks to call when a link matching the domain is pasted.
127
+ */
128
+ experimentalRegisterUnfurlHandler(domain: string, callbacks: UnfurlCallbacks): void;
119
129
  /**
120
130
  * Remove the callback for a given action. If the action is later invoked, nothing will happen.
121
131
  * @param name name of the action to unregister
@@ -4,6 +4,9 @@ exports.EditorClient = void 0;
4
4
  const commandtypes_1 = require("./commandtypes");
5
5
  const base64_1 = require("./core/base64");
6
6
  const checks_1 = require("./core/checks");
7
+ const unfurlcallbacks_1 = require("./core/unfurl/unfurlcallbacks");
8
+ const unfurldetails_1 = require("./core/unfurl/unfurldetails");
9
+ const collectionproxy_1 = require("./data/collectionproxy");
7
10
  const blockproxyregistry_1 = require("./document/blockclasses/blockproxyregistry");
8
11
  const blockproxy_1 = require("./document/blockproxy");
9
12
  const documentproxy_1 = require("./document/documentproxy");
@@ -11,6 +14,7 @@ const elementproxy_1 = require("./document/elementproxy");
11
14
  const groupproxy_1 = require("./document/groupproxy");
12
15
  const lineproxy_1 = require("./document/lineproxy");
13
16
  const pageproxy_1 = require("./document/pageproxy");
17
+ const registerunfurlmessage_1 = require("./message/registerunfurlmessage");
14
18
  class EditorClient {
15
19
  constructor() {
16
20
  this.nextId = 0;
@@ -95,6 +99,15 @@ class EditorClient {
95
99
  'json': result['j'],
96
100
  };
97
101
  }
102
+ async awaitDataImport(dataConnectorName, syncDataSourceId, syncCollectionId, primaryKeys, timeout = 30000) {
103
+ return new collectionproxy_1.CollectionProxy(await this.sendCommand("ai" /* AwaitImport */, {
104
+ 'n': dataConnectorName,
105
+ 's': syncDataSourceId,
106
+ 'c': syncCollectionId,
107
+ 'pk': primaryKeys,
108
+ 't': timeout,
109
+ }), this);
110
+ }
98
111
  /**
99
112
  * Make a network request
100
113
  * @param request Settings for the network request
@@ -198,6 +211,37 @@ class EditorClient {
198
211
  }));
199
212
  });
200
213
  }
214
+ /**
215
+ * @ignore
216
+ * Registers an handler for link unfurling.
217
+ * @param domain The domain
218
+ * @param callbacks The callbacks to call when a link matching the domain is pasted.
219
+ */
220
+ experimentalRegisterUnfurlHandler(domain, callbacks) {
221
+ const action = this.getUniqueActionName();
222
+ this.registerAction(action, async (rawMsg) => {
223
+ const msg = (0, registerunfurlmessage_1.deserializeRegisterUnfurlMessage)(rawMsg);
224
+ switch (msg.unfurlCallbackType) {
225
+ case unfurlcallbacks_1.UnfurlCallbackType.Unfurl: {
226
+ const result = await callbacks.unfurlCallback(msg.url);
227
+ if (result) {
228
+ return (0, unfurldetails_1.serializeUnfurlDetails)(result);
229
+ }
230
+ break;
231
+ }
232
+ case unfurlcallbacks_1.UnfurlCallbackType.AfterUnfurl: {
233
+ throw new Error('UnfurlCallbackType afterUnfurl not implmeneted');
234
+ }
235
+ case unfurlcallbacks_1.UnfurlCallbackType.Refresh: {
236
+ throw new Error('UnfurlCallbackType refresh not implmeneted');
237
+ }
238
+ default:
239
+ break;
240
+ }
241
+ return undefined;
242
+ });
243
+ this.sendCommand("ru" /* RegisterUnfurl */, { 'd': domain, 'a': action });
244
+ }
201
245
  /**
202
246
  * Remove the callback for a given action. If the action is later invoked, nothing will happen.
203
247
  * @param name name of the action to unregister
package/sdk/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './core/jsonserializable';
4
4
  export * from './core/offsettype';
5
5
  export * from './core/serializeddataerror';
6
6
  export * from './core/shapedatainheritance';
7
+ export * from './core/unfurl/unfurldetails';
7
8
  export * from './data/collectionproxy';
8
9
  export * from './data/dataerror';
9
10
  export * from './data/dataitemproxy';
package/sdk/index.js CHANGED
@@ -16,6 +16,7 @@ __exportStar(require("./core/jsonserializable"), exports);
16
16
  __exportStar(require("./core/offsettype"), exports);
17
17
  __exportStar(require("./core/serializeddataerror"), exports);
18
18
  __exportStar(require("./core/shapedatainheritance"), exports);
19
+ __exportStar(require("./core/unfurl/unfurldetails"), exports);
19
20
  __exportStar(require("./data/collectionproxy"), exports);
20
21
  __exportStar(require("./data/dataerror"), exports);
21
22
  __exportStar(require("./data/dataitemproxy"), exports);
@@ -0,0 +1,28 @@
1
+ import { JsonObject } from '../../lucid-extension-sdk';
2
+ import { isString } from '../core/checks';
3
+ import { UnfurlCallbackType } from '../core/unfurl/unfurlcallbacks';
4
+ /** @ignore */
5
+ export interface RegisterUnfurlMessage {
6
+ /** @ignore */
7
+ id: string;
8
+ /** @ignore */
9
+ url: string;
10
+ /** @ignore */
11
+ unfurlCallbackType: UnfurlCallbackType;
12
+ }
13
+ /** @ignore */
14
+ export interface SerializedRegisterUnfurlMessage extends JsonObject {
15
+ 'id': string;
16
+ 'u': string;
17
+ 't': UnfurlCallbackType;
18
+ }
19
+ /** @ignore */
20
+ export declare const isValidRegisterUnfurlMessage: (subject: unknown) => subject is import("../core/guards").DestructureGuardedTypeObj<{
21
+ id: typeof isString;
22
+ u: typeof isString;
23
+ t: (x: unknown) => x is UnfurlCallbackType;
24
+ }>;
25
+ /** @ignore */
26
+ export declare function deserializeRegisterUnfurlMessage(raw: SerializedRegisterUnfurlMessage): RegisterUnfurlMessage;
27
+ /** @ignore */
28
+ export declare function serializeRegisterUnfurlMessage(concrete: RegisterUnfurlMessage): SerializedRegisterUnfurlMessage;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeRegisterUnfurlMessage = exports.deserializeRegisterUnfurlMessage = exports.isValidRegisterUnfurlMessage = void 0;
4
+ const checks_1 = require("../core/checks");
5
+ const unfurlcallbacks_1 = require("../core/unfurl/unfurlcallbacks");
6
+ const validators_1 = require("../core/validators/validators");
7
+ /** @ignore */
8
+ exports.isValidRegisterUnfurlMessage = (0, validators_1.objectValidator)({
9
+ 'id': checks_1.isString,
10
+ 'u': checks_1.isString,
11
+ 't': (0, validators_1.stringEnumValidator)(unfurlcallbacks_1.UnfurlCallbackType),
12
+ });
13
+ /** @ignore */
14
+ function deserializeRegisterUnfurlMessage(raw) {
15
+ return {
16
+ id: raw['id'],
17
+ url: raw['u'],
18
+ unfurlCallbackType: raw['t'],
19
+ };
20
+ }
21
+ exports.deserializeRegisterUnfurlMessage = deserializeRegisterUnfurlMessage;
22
+ /** @ignore */
23
+ function serializeRegisterUnfurlMessage(concrete) {
24
+ return {
25
+ 'id': concrete.id,
26
+ 'u': concrete.url,
27
+ 't': concrete.unfurlCallbackType,
28
+ };
29
+ }
30
+ exports.serializeRegisterUnfurlMessage = serializeRegisterUnfurlMessage;
@@ -1,85 +0,0 @@
1
- import { CollectionProxy } from '../../data/collectionproxy';
2
- /**
3
- * When this field is displayed on a card shape, how should it be displayed?
4
- */
5
- export declare enum CardFieldDisplayType {
6
- Text = 1,
7
- TextBadge = 2,
8
- ImageBadge = 3
9
- }
10
- export declare enum CardFieldDataType {
11
- Text = 1,
12
- Number = 2,
13
- /** An enumerated list of options, stored as a string */
14
- Option = 3,
15
- Checkbox = 4
16
- }
17
- /** For fields with Option or ApiOption type, the label and value for each available option */
18
- export interface ExtensionCardFieldOption {
19
- label: string;
20
- value: string;
21
- }
22
- export interface ExtensionCardFieldDefinition {
23
- /** Data identifier */
24
- fieldName: string;
25
- /** The text to display on the menu item */
26
- label: string;
27
- /** Additional information we can provide to users */
28
- description?: string;
29
- /** How a field is displayed */
30
- displayType: CardFieldDisplayType;
31
- /** Data type backing the field */
32
- dataType: CardFieldDataType;
33
- /** If dataType is Option, the list of options available to choose from */
34
- options?: ExtensionCardFieldOption[];
35
- }
36
- /** @ignore */
37
- export declare type SerializedCardFieldOption = {
38
- 'l': string;
39
- 'v': string;
40
- };
41
- /** @ignore */
42
- export declare function serializeCardFieldOption(option: ExtensionCardFieldOption): SerializedCardFieldOption;
43
- /** @ignore */
44
- export declare type SerializedExtensionCardFieldDefinition = {
45
- 'n': string;
46
- 't': string;
47
- 'd'?: string;
48
- 'diT': number;
49
- 'daT': number;
50
- 'op'?: SerializedCardFieldOption[];
51
- };
52
- /** @ignore */
53
- export declare function serializeCardFieldDefinition(field: ExtensionCardFieldDefinition): SerializedExtensionCardFieldDefinition;
54
- /** @ignore */
55
- export declare function serializeCardFieldArrayDefinition(fields: ExtensionCardFieldDefinition[]): SerializedExtensionCardFieldDefinition[];
56
- /** @ignore */
57
- export declare function deseializeFieldOption(option: SerializedCardFieldOption): ExtensionCardFieldOption;
58
- /** @ignore */
59
- export declare function deserializeCardFieldDefinition(field: SerializedExtensionCardFieldDefinition): ExtensionCardFieldDefinition;
60
- /** @ignore */
61
- export declare function deserializeCardFieldArrayDefinition(fields: SerializedExtensionCardFieldDefinition[]): ExtensionCardFieldDefinition[];
62
- export interface CardIntegration {
63
- /**
64
- * Label used to identify the integration, e.g. "Jira", which will be used in menu items, etc.
65
- * Should be unique within any given extension.
66
- */
67
- label: string;
68
- /**
69
- * URL for an icon to display in toolbars, etc. Should be at least 24x24.
70
- */
71
- iconUrl: string;
72
- /**
73
- * Callback to provide a list of field definitions for the given collection, if that collection
74
- * was imported as part of this card integration.
75
- *
76
- * Any fields on the schema of the collection that you don't provide a ExtensionCardFieldDefinition
77
- * for will have a default definition generated based on the type specified in the schema.
78
- */
79
- getAllFields: (collection: CollectionProxy) => Promise<ExtensionCardFieldDefinition[]>;
80
- /**
81
- * If specified, and the user hasn't yet authorized the data connector for this extension,
82
- * this should show the user an intro dialog or take some other action.
83
- */
84
- showIntro?: () => void;
85
- }