lucid-extension-sdk 0.0.68 → 0.0.71

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.68",
3
+ "version": "0.0.71",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -5,6 +5,7 @@ import { JsonObject, JsonSerializable } from './core/jsonserializable';
5
5
  import { LinearOffsetType } from './core/offsettype';
6
6
  import { SerializedDataError } from './core/serializeddataerror';
7
7
  import { ShapeDataInheritance } from './core/shapedatainheritance';
8
+ import { DocumentElementType } from './document/documentelement/documentelementtype';
8
9
  import { SerializedLineTextAreaPositioning } from './document/linetextareapositioning';
9
10
  import { Box, Point } from './math';
10
11
  import { MenuLocation, MenuType } from './ui/menu';
@@ -64,6 +65,7 @@ export declare const enum CommandName {
64
65
  ListCollections = "lc",
65
66
  ListDataItems = "ldi",
66
67
  ListDataSources = "lds",
68
+ ListDocumentElements = "lde",
67
69
  ListGroups = "lg",
68
70
  ListLines = "ll",
69
71
  ListPages = "lp",
@@ -292,6 +294,10 @@ export declare type CommandArgs = {
292
294
  query: ListDataSourcesQuery;
293
295
  result: ListDataSourcesResult;
294
296
  };
297
+ [CommandName.ListDocumentElements]: {
298
+ query: ListDocumentElementsQuery;
299
+ result: ListDocumentElementsResult;
300
+ };
295
301
  [CommandName.ListGroups]: {
296
302
  query: ListChildrenQuery;
297
303
  result: ListChildrenResult;
@@ -806,6 +812,10 @@ export declare type ListCollectionFieldsQuery = {
806
812
  export declare type ListCollectionFieldsResult = string[];
807
813
  export declare type ListDataSourcesQuery = undefined;
808
814
  export declare type ListDataSourcesResult = string[];
815
+ export declare type ListDocumentElementsQuery = {
816
+ 't': DocumentElementType;
817
+ };
818
+ export declare type ListDocumentElementsResult = string[];
809
819
  export declare type ListPagesQuery = void;
810
820
  export declare type ListPagesResult = string[];
811
821
  export declare type ListReferenceKeysQuery = {
@@ -49,6 +49,7 @@ exports.commandTitles = new Map([
49
49
  ["lc" /* CommandName.ListCollections */, 'ListCollections'],
50
50
  ["ldi" /* CommandName.ListDataItems */, 'ListDataItems'],
51
51
  ["lds" /* CommandName.ListDataSources */, 'ListDataSources'],
52
+ ["lde" /* CommandName.ListDocumentElements */, 'ListDocumentElements'],
52
53
  ["lg" /* CommandName.ListGroups */, 'ListGroups'],
53
54
  ["ll" /* CommandName.ListLines */, 'ListLines'],
54
55
  ["lp" /* CommandName.ListPages */, 'ListPages'],
@@ -111,17 +111,14 @@ export interface CardIntegration {
111
111
  dataConnectorName: string;
112
112
  fieldConfiguration: {
113
113
  /**
114
- * Callback to provide a list of all supported field definitions for the card integration.
115
- *
116
- * Any fields on the schema of the collection that you don't provide a ExtensionCardFieldDefinition
117
- * for will have a default definition generated based on the type specified in the schema.
114
+ * Callback to provide a list of all supported field names for the card integration.
118
115
  */
119
- getAllFields: (collection: CollectionProxy) => Promise<ExtensionCardFieldDefinition[]>;
116
+ getAllFields: (collection: CollectionProxy) => Promise<string[]>;
120
117
  /**
121
118
  * Callback that handled changes in the fields the user wants to be displayed in the card integration.
122
119
  * If this callback is not provided then the user will not be shown the modal to configure fields.
123
120
  */
124
- onSelectedFieldsChange?: (dataSource: DataSourceProxy, selectedFields: string[]) => void;
121
+ onSelectedFieldsChange?: (dataSource: DataSourceProxy, selectedFields: string[]) => Promise<void>;
125
122
  };
126
123
  /**
127
124
  * If specified, and the user hasn't yet authorized the data connector for this extension,
@@ -16,6 +16,7 @@ export declare enum FieldConstraintType {
16
16
  SINGLE_LINE_ONLY = "singleLineOnly",
17
17
  NO_WHITESPACE = "noWhitespace"
18
18
  }
19
+ export declare const isFieldConstraintType: (x: unknown) => x is FieldConstraintType;
19
20
  export declare type SerializedFieldConstraint = {
20
21
  'Type': FieldConstraintType;
21
22
  'Details'?: JsonSerializable;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FieldConstraintType = void 0;
3
+ exports.isFieldConstraintType = exports.FieldConstraintType = void 0;
4
+ const validators_1 = require("../../validators/validators");
4
5
  // The options here must match com.lucidchart.data.model.fielddefinition.FieldConstraintType on the backend
5
6
  var FieldConstraintType;
6
7
  (function (FieldConstraintType) {
@@ -11,3 +12,4 @@ var FieldConstraintType;
11
12
  FieldConstraintType["SINGLE_LINE_ONLY"] = "singleLineOnly";
12
13
  FieldConstraintType["NO_WHITESPACE"] = "noWhitespace";
13
14
  })(FieldConstraintType = exports.FieldConstraintType || (exports.FieldConstraintType = {}));
15
+ exports.isFieldConstraintType = (0, validators_1.enumValidator)(FieldConstraintType);
@@ -116,6 +116,10 @@ export declare function either<A, B>(validatorA: Validator<A>, validatorB: Valid
116
116
  * This is useful for validating properties that have been composed of a generic and more specific values.
117
117
  */
118
118
  export declare function both<A, B>(validatorA: Validator<A>, validatorB: Validator<B>): (x: unknown) => x is A & B;
119
+ /**
120
+ * Create a validator that allows types excluding those that satisfy an excludeValidator.
121
+ */
122
+ export declare function exclude<T extends U, U>(validator: (x: unknown) => x is U, excludeValidator: (x: U) => x is T): (x: unknown) => x is Exclude<U, T>;
119
123
  /**
120
124
  * Get a validator which returns whether the property calculation structure is
121
125
  * correct.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.recordValidator = exports.strictObjectValidator = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
3
+ exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.recordValidator = exports.strictObjectValidator = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
4
4
  const checks_1 = require("../checks");
5
5
  const object_1 = require("../object");
6
6
  /*********************************************************************************
@@ -243,6 +243,13 @@ function both(validatorA, validatorB) {
243
243
  };
244
244
  }
245
245
  exports.both = both;
246
+ /**
247
+ * Create a validator that allows types excluding those that satisfy an excludeValidator.
248
+ */
249
+ function exclude(validator, excludeValidator) {
250
+ return (x) => validator(x) && !excludeValidator(x);
251
+ }
252
+ exports.exclude = exclude;
246
253
  /**
247
254
  * Get a validator which returns whether the property calculation structure is
248
255
  * correct.
@@ -1,3 +1,4 @@
1
+ import { isNumber, isUndefined } from '../core/checks';
1
2
  import { FieldTypeDefinition } from '../core/data/fieldtypedefinition/fieldtypedefinition';
2
3
  import { FieldConstraintType, SerializedFieldConstraint, SerializedFieldDefinition } from '../core/data/serializedfield/serializedfielddefinition';
3
4
  import { SerializedSchema } from '../core/data/serializedfield/serializedschema';
@@ -26,6 +27,18 @@ export interface NoWhitespaceFieldConstraintDefinition {
26
27
  value?: undefined;
27
28
  }
28
29
  export declare type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition;
30
+ export declare function minMaxFieldConstraintValidator(val: unknown): val is FieldConstraintType.MIN_VALUE | FieldConstraintType.MAX_VALUE;
31
+ export declare const isFieldConstraintDefinition: (x: unknown) => x is {
32
+ type?: FieldConstraintType | undefined;
33
+ } & {
34
+ type: FieldConstraintType;
35
+ } & (import("..").DestructureGuardedTypeObj<{
36
+ type: typeof minMaxFieldConstraintValidator;
37
+ value: typeof isNumber;
38
+ }> | import("..").DestructureGuardedTypeObj<{
39
+ type: (x: unknown) => x is FieldConstraintType.REQUIRED | FieldConstraintType.LOCKED | FieldConstraintType.SINGLE_LINE_ONLY | FieldConstraintType.NO_WHITESPACE;
40
+ value: typeof isUndefined;
41
+ }>);
29
42
  /**
30
43
  * The definition for a field to be included in a [SchemaDefinition](#interfaces_data_schemadefinition-SchemaDefinition)
31
44
  */
@@ -1,9 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = exports.serializeFieldConstraintDefinition = void 0;
3
+ exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = exports.serializeFieldConstraintDefinition = exports.isFieldConstraintDefinition = exports.minMaxFieldConstraintValidator = void 0;
4
4
  const checks_1 = require("../core/checks");
5
5
  const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
6
6
  const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
7
+ const validators_1 = require("../core/validators/validators");
8
+ function minMaxFieldConstraintValidator(val) {
9
+ return val === serializedfielddefinition_1.FieldConstraintType.MIN_VALUE || val === serializedfielddefinition_1.FieldConstraintType.MAX_VALUE;
10
+ }
11
+ exports.minMaxFieldConstraintValidator = minMaxFieldConstraintValidator;
12
+ exports.isFieldConstraintDefinition = (0, validators_1.both)((0, validators_1.objectValidator)({
13
+ 'type': serializedfielddefinition_1.isFieldConstraintType,
14
+ }), (0, validators_1.either)((0, validators_1.objectValidator)({ 'type': minMaxFieldConstraintValidator, 'value': checks_1.isNumber }), (0, validators_1.objectValidator)({ 'type': (0, validators_1.exclude)(serializedfielddefinition_1.isFieldConstraintType, minMaxFieldConstraintValidator), 'value': checks_1.isUndefined })));
7
15
  /** @ignore */
8
16
  function serializeFieldConstraintDefinition(constraint) {
9
17
  return {
@@ -0,0 +1,10 @@
1
+ import { EditorClient } from '../../editorclient';
2
+ import { DocumentElementProxy } from './documentelementproxy';
3
+ export declare class CardConfigProxy extends DocumentElementProxy {
4
+ readonly id: string;
5
+ /**
6
+ * @param id The ID of this card config element
7
+ * @param client
8
+ */
9
+ constructor(id: string, client: EditorClient);
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CardConfigProxy = void 0;
4
+ const documentelementproxy_1 = require("./documentelementproxy");
5
+ class CardConfigProxy extends documentelementproxy_1.DocumentElementProxy {
6
+ /**
7
+ * @param id The ID of this card config element
8
+ * @param client
9
+ */
10
+ constructor(id, client) {
11
+ super(id, client);
12
+ this.id = id;
13
+ }
14
+ }
15
+ exports.CardConfigProxy = CardConfigProxy;
@@ -0,0 +1,10 @@
1
+ import { EditorClient } from '../../editorclient';
2
+ import { PropertyStoreProxy } from '../propertystoreproxy';
3
+ export declare class DocumentElementProxy extends PropertyStoreProxy {
4
+ readonly id: string;
5
+ /**
6
+ * @param id The ID of this document element
7
+ * @param client
8
+ */
9
+ constructor(id: string, client: EditorClient);
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentElementProxy = void 0;
4
+ const propertystoreproxy_1 = require("../propertystoreproxy");
5
+ class DocumentElementProxy extends propertystoreproxy_1.PropertyStoreProxy {
6
+ /**
7
+ * @param id The ID of this document element
8
+ * @param client
9
+ */
10
+ constructor(id, client) {
11
+ super(id, client);
12
+ this.id = id;
13
+ }
14
+ }
15
+ exports.DocumentElementProxy = DocumentElementProxy;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * An enumeration of document element types. A Document element represents a collection of data that is stored on a document.
3
+ */
4
+ export declare enum DocumentElementType {
5
+ DerivedStructure = "DerivedStructure",
6
+ Path = "Path",
7
+ Tag = "Tag",
8
+ CommentThreadMetadata = "ThreadMetadata",
9
+ FontStylePreset = "FontStylePreset",
10
+ IntraDocumentMutex = "Mutex",
11
+ Rule = "Rule",
12
+ RuleGroup = "RuleGroup",
13
+ DocumentFormula = "Formula",
14
+ TaskCardFieldsConfig = "TaskCardFieldsConfig"
15
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentElementType = void 0;
4
+ /**
5
+ * An enumeration of document element types. A Document element represents a collection of data that is stored on a document.
6
+ */
7
+ var DocumentElementType;
8
+ (function (DocumentElementType) {
9
+ DocumentElementType["DerivedStructure"] = "DerivedStructure";
10
+ DocumentElementType["Path"] = "Path";
11
+ DocumentElementType["Tag"] = "Tag";
12
+ DocumentElementType["CommentThreadMetadata"] = "ThreadMetadata";
13
+ DocumentElementType["FontStylePreset"] = "FontStylePreset";
14
+ DocumentElementType["IntraDocumentMutex"] = "Mutex";
15
+ DocumentElementType["Rule"] = "Rule";
16
+ DocumentElementType["RuleGroup"] = "RuleGroup";
17
+ DocumentElementType["DocumentFormula"] = "Formula";
18
+ DocumentElementType["TaskCardFieldsConfig"] = "TaskCardFieldsConfig";
19
+ })(DocumentElementType = exports.DocumentElementType || (exports.DocumentElementType = {}));
@@ -1,4 +1,5 @@
1
1
  import { EditorClient } from '../editorclient';
2
+ import { CardConfigProxy } from './documentelement/cardconfigproxy';
2
3
  import { ElementProxy } from './elementproxy';
3
4
  import { ItemProxy } from './itemproxy';
4
5
  import { MapProxy } from './mapproxy';
@@ -51,4 +52,5 @@ export declare class DocumentProxy extends ElementProxy {
51
52
  * @param handle Return value from `hookCreateItems`
52
53
  */
53
54
  unhookCreateItems(handle: string): void;
55
+ readonly cardIntegrationConfigs: MapProxy<string, CardConfigProxy>;
54
56
  }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocumentProxy = void 0;
4
+ const cardconfigproxy_1 = require("./documentelement/cardconfigproxy");
5
+ const documentelementtype_1 = require("./documentelement/documentelementtype");
4
6
  const elementproxy_1 = require("./elementproxy");
5
7
  const mapproxy_1 = require("./mapproxy");
6
8
  const pageproxy_1 = require("./pageproxy");
@@ -14,6 +16,7 @@ class DocumentProxy extends elementproxy_1.ElementProxy {
14
16
  * The set of pages on this document, organized by ID
15
17
  */
16
18
  this.pages = new mapproxy_1.MapProxy(() => this.client.sendCommand("lp" /* CommandName.ListPages */, undefined), (pageId) => new pageproxy_1.PageProxy(pageId, this.client));
19
+ this.cardIntegrationConfigs = new mapproxy_1.MapProxy(() => this.client.sendCommand("lde" /* CommandName.ListDocumentElements */, { 't': documentelementtype_1.DocumentElementType.TaskCardFieldsConfig }), (id) => new cardconfigproxy_1.CardConfigProxy(id, this.client));
17
20
  }
18
21
  static getNextHookName() {
19
22
  return '__documentproxy__hook' + DocumentProxy.nextHookId++;
@@ -38,16 +38,15 @@ class TaskManagementCardIntegration {
38
38
  this.client.registerAction(getFieldsActionName, async (param) => {
39
39
  const collection = new collectionproxy_1.CollectionProxy(param['c'], this.client);
40
40
  const fields = await card.fieldConfiguration.getAllFields(collection);
41
- const serializedFields = (0, cardintegration_1.serializeCardFieldArrayDefinition)(fields);
42
- return serializedFields;
41
+ return fields;
43
42
  });
44
43
  let onSelectedFieldsChangeActionName = undefined;
45
44
  const onSelectedFieldsChange = card.fieldConfiguration.onSelectedFieldsChange;
46
45
  if (onSelectedFieldsChange) {
47
46
  onSelectedFieldsChangeActionName = TaskManagementCardIntegration.nextHookName();
48
- this.client.registerAction(onSelectedFieldsChangeActionName, (param) => {
47
+ this.client.registerAction(onSelectedFieldsChangeActionName, async (param) => {
49
48
  const dataSource = new datasourceproxy_1.DataSourceProxy(param['ds'], this.client);
50
- onSelectedFieldsChange(dataSource, param['sf']);
49
+ await onSelectedFieldsChange(dataSource, param['sf']);
51
50
  });
52
51
  }
53
52
  const getDefaultConfigActionName = TaskManagementCardIntegration.nextHookName();