lucid-extension-sdk 0.0.426 → 0.0.428

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/commandtypes.d.ts CHANGED
@@ -764,6 +764,8 @@ export type AddCardIntegrationQuery = {
764
764
  'ts'?: Partial<TextStyle> | undefined;
765
765
  /** Field configuration */
766
766
  'fc': SerializedFieldConfiguration;
767
+ /** Import from serialized fields callback */
768
+ 'ifs'?: string | undefined;
767
769
  /** If we can only search for user by their name (and not email) in the card integration. */
768
770
  'subn'?: boolean | undefined;
769
771
  /** Callback to search for a user in the card integration */
@@ -1,4 +1,4 @@
1
- import { SerializedFieldType } from '../data/serializedfield/serializedfields';
1
+ import { SerializedFieldType, SerializedFields } from '../data/serializedfield/serializedfields';
2
2
  import { UnsafeJsonSerializableOrUndefined } from '../jsonserializable';
3
3
  /** @ignore */
4
4
  export interface GetFieldsParam {
@@ -86,4 +86,8 @@ export interface FieldLabelIconsCallbackParam {
86
86
  'c': string;
87
87
  'p': string;
88
88
  }
89
+ /** @ignore */
90
+ export interface ImportFromSerializedFieldsCallbackParam {
91
+ 'sf': SerializedFields[];
92
+ }
89
93
  export {};
@@ -3,7 +3,8 @@ import { DataSourceProxy } from '../../data/datasourceproxy';
3
3
  import { TextStyle } from '../../document/text/textstyle';
4
4
  import { EditorClient } from '../../editorclient';
5
5
  import { isString } from '../checks';
6
- import { SerializedFieldType } from '../data/serializedfield/serializedfields';
6
+ import { SerializedFieldType, SerializedFields } from '../data/serializedfield/serializedfields';
7
+ import { ImportCardFromDetails } from '../importcardfromdetails/importcardfromdetails';
7
8
  import { ImportCardFromPastedLinkCallback } from '../importcardfrompastedlink/importcardfrompastedlinkcallback';
8
9
  import { DependenciesForItems, ExtensionCardFieldDefinition, ExtensionFieldConfiguration, ImportResult } from '../sharedcardintegration/cardintegrationdefinitions';
9
10
  import { CardIntegrationConfig } from './cardintegrationconfig';
@@ -136,4 +137,10 @@ export declare abstract class LucidCardIntegration {
136
137
  domain: string;
137
138
  callback: ImportCardFromPastedLinkCallback;
138
139
  };
140
+ /**
141
+ * If specified, allows users to import cards by copying a card on one board and pasting it to another board.
142
+ * This function should interface with `SerializedFields` to get the data from the copied card necessary to trigger
143
+ * the import.
144
+ */
145
+ importFromSerializedFields?: (data: SerializedFields[]) => Promise<ImportCardFromDetails>;
139
146
  }
@@ -7,7 +7,7 @@ const dataitemproxy_1 = require("../../data/dataitemproxy");
7
7
  const datasourceproxy_1 = require("../../data/datasourceproxy");
8
8
  const importcardfrompastedlinkeventmessage_1 = require("../../message/importcardfrompastedlinkeventmessage");
9
9
  const checks_1 = require("../checks");
10
- const importcardfrompastedlinkdetails_1 = require("../importcardfrompastedlink/importcardfrompastedlinkdetails");
10
+ const importcardfromdetails_1 = require("../importcardfromdetails/importcardfromdetails");
11
11
  const cardintegrationdefinitions_1 = require("../sharedcardintegration/cardintegrationdefinitions");
12
12
  const cardintegrationconfig_1 = require("./cardintegrationconfig");
13
13
  const lucidcardintegrationcustomimportmodal_1 = require("./lucidcardintegrationcustomimportmodal");
@@ -189,7 +189,7 @@ class LucidCardIntegrationRegistry {
189
189
  const msg = (0, importcardfrompastedlinkeventmessage_1.deserializeImportCardFromPastedLinkEventMessage)(rawMsg);
190
190
  const result = await callback(msg.url);
191
191
  if (result) {
192
- return (0, importcardfrompastedlinkdetails_1.serializeImportCardFromPastedLinkDetails)(result);
192
+ return (0, importcardfromdetails_1.serializeImportCardFromDetails)(result);
193
193
  }
194
194
  return undefined;
195
195
  }
@@ -350,6 +350,14 @@ class LucidCardIntegrationRegistry {
350
350
  }
351
351
  this.registerDependencyMapping(client, cardIntegration, serialized);
352
352
  this.registerImportCardFromPastedLinkHandler(client, cardIntegration, serialized);
353
+ if (cardIntegration.importFromSerializedFields) {
354
+ const importFromSerializedFields = cardIntegration.importFromSerializedFields;
355
+ serialized['ifs'] = LucidCardIntegrationRegistry.nextHookName();
356
+ client.registerAction(serialized['ifs'], async ({ 'sf': serializedFields }) => {
357
+ const result = await importFromSerializedFields(serializedFields);
358
+ return (0, importcardfromdetails_1.serializeImportCardFromDetails)(result);
359
+ });
360
+ }
353
361
  client.sendCommand("aci" /* CommandName.AddCardIntegration */, serialized);
354
362
  }
355
363
  }
@@ -0,0 +1,50 @@
1
+ import { isString } from '../checks';
2
+ import { SerializedFieldType } from '../data/serializedfield/serializedfields';
3
+ import { PlaceholderImportMetadata, SerializedPlaceholderImportMetadata } from '../sharedcardintegration/cardintegrationdefinitions';
4
+ /**
5
+ * A definition of the details required to import a card into the editor from a pasted url or pasted card clipboard data.
6
+ */
7
+ export interface ImportCardFromDetails {
8
+ /**
9
+ * A list of primary keys to import onto the canvas via your extension's import action.
10
+ *
11
+ * These should be formatted the same as primary keys on the document's collection. For example, numeric keys would
12
+ * be formatted as `['123']`, and string keys would be formatted inside double quotes `['"my-item"']`
13
+ */
14
+ primaryKeys: string[];
15
+ /**
16
+ * If `placeholderImportMetadataList` is provided, it is used to quickly splat a card on the canvas while waiting
17
+ * for the import action to finish, identical to how modal-based imports use search results to splat cards. Ensure
18
+ * that the schema of the `collectionDefinition` field in each placeholder import metadata is a subset of the
19
+ * collection that the imported cards will be added to.
20
+ */
21
+ placeholderImportMetadataList?: PlaceholderImportMetadata[] | undefined;
22
+ /**
23
+ * `importActionData` can be used to pass key-value pairs to your action. This data will be sent to your import
24
+ * modal's `import` method as the `searchFields: Map<string, SerializedFieldType>` parameter.
25
+ */
26
+ importActionData?: Map<string, SerializedFieldType> | undefined;
27
+ }
28
+ /** @ignore */
29
+ export interface SerializedImportCardFromDetails {
30
+ 'pk': string[];
31
+ 'piml'?: SerializedPlaceholderImportMetadata[] | undefined;
32
+ 'iad'?: [string, SerializedFieldType][] | undefined;
33
+ }
34
+ /** @ignore */
35
+ export declare const isValidImportCardFromDetails: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
36
+ pk: (val: unknown) => val is string[];
37
+ piml: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
38
+ cid: typeof isString;
39
+ sid: (x: unknown) => x is string | undefined;
40
+ cd: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
41
+ Schema: typeof import("../..").isSerializedSchema;
42
+ Items: (val: unknown) => val is [string, Record<string | number, SerializedFieldType>][];
43
+ }>;
44
+ }>[] | undefined;
45
+ iad: (x: unknown) => x is [string, SerializedFieldType][] | undefined;
46
+ }>;
47
+ /** @ignore */
48
+ export declare function serializeImportCardFromDetails(concrete: ImportCardFromDetails): SerializedImportCardFromDetails;
49
+ /** @ignore */
50
+ export declare function deserializeImportCardFromDetails(serialized: SerializedImportCardFromDetails): ImportCardFromDetails;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeImportCardFromDetails = exports.serializeImportCardFromDetails = exports.isValidImportCardFromDetails = void 0;
4
+ const checks_1 = require("../checks");
5
+ const serializedfields_1 = require("../data/serializedfield/serializedfields");
6
+ const cardintegrationdefinitions_1 = require("../sharedcardintegration/cardintegrationdefinitions");
7
+ const validators_1 = require("../validators/validators");
8
+ /** @ignore */
9
+ exports.isValidImportCardFromDetails = (0, validators_1.objectValidator)({
10
+ 'pk': (0, checks_1.isTypedArray)(checks_1.isString),
11
+ 'piml': (0, validators_1.option)((0, checks_1.isTypedArray)(cardintegrationdefinitions_1.isSerializedPlaceholderImportMetadata)),
12
+ 'iad': (0, validators_1.option)((0, checks_1.isTypedArray)((0, checks_1.isPair)(checks_1.isString, serializedfields_1.isSerializedFieldType))),
13
+ });
14
+ /** @ignore */
15
+ function serializeImportCardFromDetails(concrete) {
16
+ var _a, _b;
17
+ return {
18
+ 'pk': concrete.primaryKeys,
19
+ 'piml': (_a = concrete.placeholderImportMetadataList) === null || _a === void 0 ? void 0 : _a.map((data) => (0, cardintegrationdefinitions_1.serializePlaceholderImportMetadata)(data)),
20
+ 'iad': concrete.importActionData ? [...(_b = concrete.importActionData) === null || _b === void 0 ? void 0 : _b.entries()] : undefined,
21
+ };
22
+ }
23
+ exports.serializeImportCardFromDetails = serializeImportCardFromDetails;
24
+ /** @ignore */
25
+ function deserializeImportCardFromDetails(serialized) {
26
+ var _a;
27
+ const placeholderImportMetadataList = serialized['piml']
28
+ ? {
29
+ placeholderImportMetadataList: (_a = serialized['piml']) === null || _a === void 0 ? void 0 : _a.map((data) => (0, cardintegrationdefinitions_1.deserializePlaceholderImportMetadata)(data)),
30
+ }
31
+ : {};
32
+ const importActionData = serialized['iad'] ? { importActionData: new Map(serialized['iad']) } : {};
33
+ return Object.assign(Object.assign({ primaryKeys: serialized['pk'] }, placeholderImportMetadataList), importActionData);
34
+ }
35
+ exports.deserializeImportCardFromDetails = deserializeImportCardFromDetails;
@@ -1,8 +1,8 @@
1
- import { ImportCardFromPastedLinkDetails } from './importcardfrompastedlinkdetails';
1
+ import { ImportCardFromDetails } from '../importcardfromdetails/importcardfromdetails';
2
2
  /**
3
3
  * Callback to attempt to extract primary keys from a pasted url to be imported as cards onto the canvas.
4
4
  *
5
5
  * @param url The url to be interpreted into primary keys for the extension to import.
6
6
  * @return The details of the cards, or `undefined` if the url couldn't be interpreted.
7
7
  */
8
- export type ImportCardFromPastedLinkCallback = (url: string) => Promise<ImportCardFromPastedLinkDetails | undefined>;
8
+ export type ImportCardFromPastedLinkCallback = (url: string) => Promise<ImportCardFromDetails | undefined>;
@@ -1,50 +1,32 @@
1
- import { isString } from '../checks';
2
- import { SerializedFieldType } from '../data/serializedfield/serializedfields';
3
- import { PlaceholderImportMetadata, SerializedPlaceholderImportMetadata } from '../sharedcardintegration/cardintegrationdefinitions';
1
+ import { ImportCardFromDetails, SerializedImportCardFromDetails, deserializeImportCardFromDetails, serializeImportCardFromDetails } from '../importcardfromdetails/importcardfromdetails';
4
2
  /**
5
- * A definition of the details required to import a card into the editor from a pasted url.
3
+ * @deprecated Use {@link ImportCardFromDetails} instead.
4
+ */
5
+ export type ImportCardFromPastedLinkDetails = ImportCardFromDetails;
6
+ /**
7
+ * @deprecated Use {@link SerializedImportCardFromDetails} instead.
8
+ */
9
+ export type SerializedImportCardFromPastedLinkDetails = SerializedImportCardFromDetails;
10
+ /**
11
+ * @deprecated Use {@link isValidImportCardFromDetails} instead.
6
12
  */
7
- export interface ImportCardFromPastedLinkDetails {
8
- /**
9
- * A list of primary keys to import onto the canvas via your extension's import action.
10
- *
11
- * These should be formatted the same as primary keys on the document's collection. For example, numeric keys would
12
- * be formatted as `['123']`, and string keys would be formatted inside double quotes `['"my-item"']`
13
- */
14
- primaryKeys: string[];
15
- /**
16
- * If `placeholderImportMetadataList` is provided, it is used to quickly splat a card on the canvas while waiting
17
- * for the import action to finish, identical to how modal-based imports use search results to splat cards. Ensure
18
- * that the schema of the `collectionDefinition` field in each placeholder import metadata is a subset of the
19
- * collection that the imported cards will be added to.
20
- */
21
- placeholderImportMetadataList?: PlaceholderImportMetadata[] | undefined;
22
- /**
23
- * `importActionData` can be used to pass key-value pairs to your action. This data will be sent to your import
24
- * modal's `import` method as the `searchFields: Map<string, SerializedFieldType>` parameter.
25
- */
26
- importActionData?: Map<string, SerializedFieldType> | undefined;
27
- }
28
- /** @ignore */
29
- export interface SerializedImportCardFromPastedLinkDetails {
30
- 'pk': string[];
31
- 'piml'?: SerializedPlaceholderImportMetadata[] | undefined;
32
- 'iad'?: [string, SerializedFieldType][] | undefined;
33
- }
34
- /** @ignore */
35
13
  export declare const isValidImportCardFromPastedLinkDetails: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
36
14
  pk: (val: unknown) => val is string[];
37
15
  piml: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
38
- cid: typeof isString;
16
+ cid: typeof import("../checks").isString;
39
17
  sid: (x: unknown) => x is string | undefined;
40
18
  cd: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
41
19
  Schema: typeof import("../..").isSerializedSchema;
42
- Items: (val: unknown) => val is [string, Record<string | number, SerializedFieldType>][];
20
+ Items: (val: unknown) => val is [string, Record<string | number, import("../..").SerializedFieldType>][];
43
21
  }>;
44
22
  }>[] | undefined;
45
- iad: (x: unknown) => x is [string, SerializedFieldType][] | undefined;
23
+ iad: (x: unknown) => x is [string, import("../..").SerializedFieldType][] | undefined;
46
24
  }>;
47
- /** @ignore */
48
- export declare function serializeImportCardFromPastedLinkDetails(concrete: ImportCardFromPastedLinkDetails): SerializedImportCardFromPastedLinkDetails;
49
- /** @ignore */
50
- export declare function deserializeImportCardFromPastedLinkDetails(serialized: SerializedImportCardFromPastedLinkDetails): ImportCardFromPastedLinkDetails;
25
+ /**
26
+ * @deprecated Use {@link serializeImportCardFromDetails} instead.
27
+ */
28
+ export declare const serializeImportCardFromPastedLinkDetails: typeof serializeImportCardFromDetails;
29
+ /**
30
+ * @deprecated Use {@link deserializeImportCardFromDetails} instead.
31
+ */
32
+ export declare const deserializeImportCardFromPastedLinkDetails: typeof deserializeImportCardFromDetails;
@@ -1,35 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deserializeImportCardFromPastedLinkDetails = exports.serializeImportCardFromPastedLinkDetails = exports.isValidImportCardFromPastedLinkDetails = void 0;
4
- const checks_1 = require("../checks");
5
- const serializedfields_1 = require("../data/serializedfield/serializedfields");
6
- const cardintegrationdefinitions_1 = require("../sharedcardintegration/cardintegrationdefinitions");
7
- const validators_1 = require("../validators/validators");
8
- /** @ignore */
9
- exports.isValidImportCardFromPastedLinkDetails = (0, validators_1.objectValidator)({
10
- 'pk': (0, checks_1.isTypedArray)(checks_1.isString),
11
- 'piml': (0, validators_1.option)((0, checks_1.isTypedArray)(cardintegrationdefinitions_1.isSerializedPlaceholderImportMetadata)),
12
- 'iad': (0, validators_1.option)((0, checks_1.isTypedArray)((0, checks_1.isPair)(checks_1.isString, serializedfields_1.isSerializedFieldType))),
13
- });
14
- /** @ignore */
15
- function serializeImportCardFromPastedLinkDetails(concrete) {
16
- var _a, _b;
17
- return {
18
- 'pk': concrete.primaryKeys,
19
- 'piml': (_a = concrete.placeholderImportMetadataList) === null || _a === void 0 ? void 0 : _a.map((data) => (0, cardintegrationdefinitions_1.serializePlaceholderImportMetadata)(data)),
20
- 'iad': concrete.importActionData ? [...(_b = concrete.importActionData) === null || _b === void 0 ? void 0 : _b.entries()] : undefined,
21
- };
22
- }
23
- exports.serializeImportCardFromPastedLinkDetails = serializeImportCardFromPastedLinkDetails;
24
- /** @ignore */
25
- function deserializeImportCardFromPastedLinkDetails(serialized) {
26
- var _a;
27
- const placeholderImportMetadataList = serialized['piml']
28
- ? {
29
- placeholderImportMetadataList: (_a = serialized['piml']) === null || _a === void 0 ? void 0 : _a.map((data) => (0, cardintegrationdefinitions_1.deserializePlaceholderImportMetadata)(data)),
30
- }
31
- : {};
32
- const importActionData = serialized['iad'] ? { importActionData: new Map(serialized['iad']) } : {};
33
- return Object.assign(Object.assign({ primaryKeys: serialized['pk'] }, placeholderImportMetadataList), importActionData);
34
- }
35
- exports.deserializeImportCardFromPastedLinkDetails = deserializeImportCardFromPastedLinkDetails;
4
+ const importcardfromdetails_1 = require("../importcardfromdetails/importcardfromdetails");
5
+ /**
6
+ * @deprecated Use {@link isValidImportCardFromDetails} instead.
7
+ */
8
+ exports.isValidImportCardFromPastedLinkDetails = importcardfromdetails_1.isValidImportCardFromDetails;
9
+ /**
10
+ * @deprecated Use {@link serializeImportCardFromDetails} instead.
11
+ */
12
+ exports.serializeImportCardFromPastedLinkDetails = importcardfromdetails_1.serializeImportCardFromDetails;
13
+ /**
14
+ * @deprecated Use {@link deserializeImportCardFromDetails} instead.
15
+ */
16
+ exports.deserializeImportCardFromPastedLinkDetails = importcardfromdetails_1.deserializeImportCardFromDetails;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LucidSpreadsheetIntegrationRegistry = void 0;
4
+ const datasourceproxy_1 = require("../../data/datasourceproxy");
4
5
  const checks_1 = require("../checks");
5
6
  const cardintegrationdefinitions_1 = require("../sharedcardintegration/cardintegrationdefinitions");
6
7
  const lucidspreadsheetintegration_1 = require("./lucidspreadsheetintegration");
@@ -13,7 +14,7 @@ class LucidSpreadsheetIntegrationRegistry {
13
14
  * Register a spreadsheet integration.
14
15
  */
15
16
  static addSpreadsheetIntegration(client, spreadsheetIntegration) {
16
- var _a, _b, _c, _d, _e, _f;
17
+ var _a, _b, _c, _d, _e, _f, _g;
17
18
  let configChooserActions;
18
19
  const configChooser = spreadsheetIntegration.configChooser;
19
20
  if (configChooser instanceof lucidspreadsheetintegration_1.CustomDetailsChooser) {
@@ -60,6 +61,16 @@ class LucidSpreadsheetIntegrationRegistry {
60
61
  catch (error) { }
61
62
  return lucidspreadsheetintegration_1.LucidSpreadsheetIntegrationFailureType.GenericFailure;
62
63
  });
64
+ let getFieldsActionName = undefined;
65
+ const getAllFields = (_a = spreadsheetIntegration.fieldConfiguration) === null || _a === void 0 ? void 0 : _a.getAllFields;
66
+ if (getAllFields) {
67
+ getFieldsActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
68
+ client.registerAction(getFieldsActionName, async (param) => {
69
+ const dataSource = new datasourceproxy_1.DataSourceProxy(param['d'], client);
70
+ const fields = await getAllFields(dataSource);
71
+ return fields;
72
+ });
73
+ }
63
74
  const serialized = {
64
75
  'ld': spreadsheetIntegration.labelDescription,
65
76
  'li': spreadsheetIntegration.labelIconUrl,
@@ -68,10 +79,11 @@ class LucidSpreadsheetIntegrationRegistry {
68
79
  'gs': configChooserActions,
69
80
  'gm': getMultipleSheetsForSpreadsheetDetailsActionName,
70
81
  'fc': {
82
+ 'gf': getFieldsActionName,
71
83
  'cfds': {
72
- 'd': (_b = (_a = spreadsheetIntegration.fieldConfiguration) === null || _a === void 0 ? void 0 : _a.customFieldDisplaySettings) === null || _b === void 0 ? void 0 : _b.defaultToMultilineText,
73
- 'uri': (_d = (_c = spreadsheetIntegration.fieldConfiguration) === null || _c === void 0 ? void 0 : _c.customFieldDisplaySettings) === null || _d === void 0 ? void 0 : _d.useRoundIcons,
74
- 'dadr': (_f = (_e = spreadsheetIntegration.fieldConfiguration) === null || _e === void 0 ? void 0 : _e.customFieldDisplaySettings) === null || _f === void 0 ? void 0 : _f.displayMappedDatesAsDateRange,
84
+ 'd': (_c = (_b = spreadsheetIntegration.fieldConfiguration) === null || _b === void 0 ? void 0 : _b.customFieldDisplaySettings) === null || _c === void 0 ? void 0 : _c.defaultToMultilineText,
85
+ 'uri': (_e = (_d = spreadsheetIntegration.fieldConfiguration) === null || _d === void 0 ? void 0 : _d.customFieldDisplaySettings) === null || _e === void 0 ? void 0 : _e.useRoundIcons,
86
+ 'dadr': (_g = (_f = spreadsheetIntegration.fieldConfiguration) === null || _f === void 0 ? void 0 : _f.customFieldDisplaySettings) === null || _g === void 0 ? void 0 : _g.displayMappedDatesAsDateRange,
75
87
  },
76
88
  },
77
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.426",
3
+ "version": "0.0.428",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",