lucid-extension-sdk 0.0.36 → 0.0.38

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
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",
@@ -124,6 +126,10 @@ export declare type CommandArgs = {
124
126
  query: AnimateViewportQuery;
125
127
  result: AnimateViewportResult;
126
128
  };
129
+ [CommandName.AwaitImport]: {
130
+ query: AwaitImportQuery;
131
+ result: AwaitImportResult;
132
+ };
127
133
  [CommandName.Bootstrap]: {
128
134
  query: BootstrapQuery;
129
135
  result: BootstrapResult;
@@ -260,6 +266,10 @@ export declare type CommandArgs = {
260
266
  query: KillExtensionQuery;
261
267
  result: KillExtensionResult;
262
268
  };
269
+ [CommandName.ImportCards]: {
270
+ query: ImportCardsQuery;
271
+ result: ImportCardsResult;
272
+ };
263
273
  [CommandName.ListBlocks]: {
264
274
  query: ListChildrenQuery;
265
275
  result: ListChildrenResult;
@@ -406,6 +416,15 @@ export declare type AddCardIntegrationQuery = {
406
416
  'gf': string;
407
417
  /** Show intro if user has not yet authorized this integration */
408
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
+ };
409
428
  };
410
429
  export declare type AddCardIntegrationResult = undefined;
411
430
  export declare type AddLineTextAreaQuery = {
@@ -467,6 +486,20 @@ export declare type AlertQuery = {
467
486
  };
468
487
  /** True if they click OK, false otherwise */
469
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>;
470
503
  export declare type BootstrapQuery = {
471
504
  /**
472
505
  * Named action that accepts the bootstrap data, and which may return a Promise or void. After awaiting\
@@ -713,6 +746,10 @@ export declare type HookTextEditQuery = {
713
746
  'n': string;
714
747
  };
715
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>;
716
753
  export declare type KillExtensionQuery = void;
717
754
  export declare type KillExtensionResult = undefined;
718
755
  export declare type ListChildrenQuery = {
@@ -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'],
@@ -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,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",
@@ -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$/;
@@ -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,6 +1,7 @@
1
1
  import { CommandArgs, CommandName, UnionToIntersection } from './commandtypes';
2
2
  import { JsonSerializable } from './core/jsonserializable';
3
3
  import { UnfurlCallbacks } from './core/unfurl/unfurlcallbacks';
4
+ import { CollectionProxy } from './data/collectionproxy';
4
5
  import { BlockDefinition } from './document/blockdefinition';
5
6
  import { BlockProxy } from './document/blockproxy';
6
7
  import { ElementProxy } from './document/elementproxy';
@@ -87,6 +88,7 @@ export declare class EditorClient {
87
88
  * @throws A string with an error from the data sync server
88
89
  */
89
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>;
90
92
  /**
91
93
  * Make a network request
92
94
  * @param request Settings for the network request
@@ -6,6 +6,7 @@ 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 collectionproxy_1 = require("./data/collectionproxy");
9
10
  const blockproxyregistry_1 = require("./document/blockclasses/blockproxyregistry");
10
11
  const blockproxy_1 = require("./document/blockproxy");
11
12
  const documentproxy_1 = require("./document/documentproxy");
@@ -98,6 +99,15 @@ class EditorClient {
98
99
  'json': result['j'],
99
100
  };
100
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
+ }
101
111
  /**
102
112
  * Make a network request
103
113
  * @param request Settings for the network request
@@ -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
- }