lucid-extension-sdk 0.0.3 → 0.0.4

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 (49) hide show
  1. package/package.json +2 -1
  2. package/sdk/commandtypes.d.ts +89 -2
  3. package/sdk/core/checks.d.ts +8 -0
  4. package/sdk/core/checks.js +14 -1
  5. package/sdk/core/data/fieldtypedefinition/basefieldtypedefinition.d.ts +13 -0
  6. package/sdk/core/data/fieldtypedefinition/basefieldtypedefinition.js +58 -0
  7. package/sdk/core/data/fieldtypedefinition/collectionenumfieldtype.d.ts +30 -0
  8. package/sdk/core/data/fieldtypedefinition/collectionenumfieldtype.js +45 -0
  9. package/sdk/core/data/fieldtypedefinition/fieldtypearray.d.ts +16 -0
  10. package/sdk/core/data/fieldtypedefinition/fieldtypearray.js +50 -0
  11. package/sdk/core/data/fieldtypedefinition/fieldtypedefinition.d.ts +13 -0
  12. package/sdk/core/data/fieldtypedefinition/fieldtypedefinition.js +156 -0
  13. package/sdk/core/data/fieldtypedefinition/literalfieldtype.d.ts +17 -0
  14. package/sdk/core/data/fieldtypedefinition/literalfieldtype.js +60 -0
  15. package/sdk/core/data/fieldtypedefinition/ndimensionalfieldtypearray.d.ts +17 -0
  16. package/sdk/core/data/fieldtypedefinition/ndimensionalfieldtypearray.js +51 -0
  17. package/sdk/core/data/fieldtypedefinition/scalarfieldtype.d.ts +14 -0
  18. package/sdk/core/data/fieldtypedefinition/scalarfieldtype.js +33 -0
  19. package/sdk/core/data/referencekeys/serializedreferencekey.d.ts +24 -0
  20. package/sdk/core/data/referencekeys/serializedreferencekey.js +5 -0
  21. package/sdk/core/data/serializedfield/serializeddataitems.d.ts +5 -0
  22. package/sdk/core/data/serializedfield/serializeddataitems.js +9 -0
  23. package/sdk/core/data/serializedfield/serializedfielddefinition.d.ts +19 -0
  24. package/sdk/core/data/serializedfield/serializedfielddefinition.js +12 -0
  25. package/sdk/core/{serializedfields.d.ts → data/serializedfield/serializedfields.d.ts} +0 -0
  26. package/sdk/core/{serializedfields.js → data/serializedfield/serializedfields.js} +1 -1
  27. package/sdk/core/data/serializedfield/serializedschema.d.ts +9 -0
  28. package/sdk/core/data/serializedfield/serializedschema.js +2 -0
  29. package/sdk/data/collectionproxy.d.ts +6 -0
  30. package/sdk/data/collectionproxy.js +15 -0
  31. package/sdk/data/dataproxy.d.ts +12 -0
  32. package/sdk/data/dataproxy.js +11 -0
  33. package/sdk/data/datasourceproxy.d.ts +9 -0
  34. package/sdk/data/datasourceproxy.js +20 -0
  35. package/sdk/data/referencekeydefinition.d.ts +17 -0
  36. package/sdk/data/referencekeydefinition.js +27 -0
  37. package/sdk/data/referencekeyproxy.d.ts +9 -0
  38. package/sdk/data/referencekeyproxy.js +12 -0
  39. package/sdk/data/schemadefinition.d.ts +11 -0
  40. package/sdk/data/schemadefinition.js +14 -0
  41. package/sdk/document/blockdefinition.d.ts +10 -0
  42. package/sdk/document/elementproxy.d.ts +5 -0
  43. package/sdk/document/elementproxy.js +13 -0
  44. package/sdk/document/pageproxy.js +4 -0
  45. package/sdk/document/shapedataproxy.d.ts +1 -1
  46. package/sdk/editorclient.d.ts +31 -0
  47. package/sdk/editorclient.js +42 -0
  48. package/sdk/index.d.ts +1 -1
  49. package/sdk/index.js +1 -1
@@ -0,0 +1,17 @@
1
+ import { ScalarFieldTypeEnum } from './scalarfieldtype';
2
+ export declare class LiteralFieldType {
3
+ static literalStringPrefix: string;
4
+ private readonly literal;
5
+ private scalarFieldType;
6
+ constructor(literal: boolean | number | string);
7
+ getLiteral(): string | number | boolean;
8
+ getScalarFieldType(): ScalarFieldTypeEnum;
9
+ serialize(): SerializedLiteralFieldType;
10
+ }
11
+ export declare function isLiteralFieldType(fieldType: any): fieldType is LiteralFieldType;
12
+ export declare type SerializedLiteralFieldType = string;
13
+ export declare function isSerializedLiteralFieldType(definition: any): definition is SerializedLiteralFieldType;
14
+ /**
15
+ * String literals without the literalStringPrefix will return the boolean literal false
16
+ */
17
+ export declare function deserializeLiteralFieldType(serializedLiteralFieldType: SerializedLiteralFieldType): LiteralFieldType;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeLiteralFieldType = exports.isSerializedLiteralFieldType = exports.isLiteralFieldType = exports.LiteralFieldType = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const scalarfieldtype_1 = require("./scalarfieldtype");
6
+ class LiteralFieldType {
7
+ constructor(literal) {
8
+ this.scalarFieldType = scalarfieldtype_1.ScalarFieldTypeEnum.ANY;
9
+ if ((0, checks_1.isString)(literal)) {
10
+ this.literal = literal.substring(LiteralFieldType.literalStringPrefix.length);
11
+ this.scalarFieldType = scalarfieldtype_1.ScalarFieldTypeEnum.STRING;
12
+ }
13
+ else if ((0, checks_1.isBoolean)(literal)) {
14
+ this.literal = literal;
15
+ this.scalarFieldType = scalarfieldtype_1.ScalarFieldTypeEnum.BOOLEAN;
16
+ }
17
+ else {
18
+ this.literal = literal;
19
+ this.scalarFieldType = scalarfieldtype_1.ScalarFieldTypeEnum.NUMBER;
20
+ }
21
+ }
22
+ getLiteral() {
23
+ return this.literal;
24
+ }
25
+ getScalarFieldType() {
26
+ return this.scalarFieldType;
27
+ }
28
+ serialize() {
29
+ if (this.scalarFieldType === scalarfieldtype_1.ScalarFieldTypeEnum.STRING) {
30
+ return LiteralFieldType.literalStringPrefix + this.literal;
31
+ }
32
+ return this.literal.toString();
33
+ }
34
+ }
35
+ exports.LiteralFieldType = LiteralFieldType;
36
+ LiteralFieldType.literalStringPrefix = '%';
37
+ function isLiteralFieldType(fieldType) {
38
+ return fieldType instanceof LiteralFieldType;
39
+ }
40
+ exports.isLiteralFieldType = isLiteralFieldType;
41
+ function isSerializedLiteralFieldType(definition) {
42
+ return (0, checks_1.isString)(definition);
43
+ }
44
+ exports.isSerializedLiteralFieldType = isSerializedLiteralFieldType;
45
+ /**
46
+ * String literals without the literalStringPrefix will return the boolean literal false
47
+ */
48
+ function deserializeLiteralFieldType(serializedLiteralFieldType) {
49
+ if (serializedLiteralFieldType.startsWith(LiteralFieldType.literalStringPrefix)) {
50
+ return new LiteralFieldType(serializedLiteralFieldType);
51
+ }
52
+ const numberLiteral = Number(serializedLiteralFieldType);
53
+ if (isNaN(numberLiteral) ||
54
+ numberLiteral === Number.POSITIVE_INFINITY ||
55
+ numberLiteral === Number.NEGATIVE_INFINITY) {
56
+ return new LiteralFieldType(serializedLiteralFieldType === 'true');
57
+ }
58
+ return new LiteralFieldType(numberLiteral);
59
+ }
60
+ exports.deserializeLiteralFieldType = deserializeLiteralFieldType;
@@ -0,0 +1,17 @@
1
+ import { LiteralFieldType, SerializedLiteralFieldType } from './literalfieldtype';
2
+ import { ScalarFieldTypeEnum } from './scalarfieldtype';
3
+ export declare class NDimensionalFieldTypeArray {
4
+ readonly validTypesArray: (ScalarFieldTypeEnum | LiteralFieldType)[];
5
+ constructor(validTypesArray: (ScalarFieldTypeEnum | LiteralFieldType)[]);
6
+ getInnerTypes(): (ScalarFieldTypeEnum | LiteralFieldType | this)[];
7
+ getInnerNonArrayTypes(): (ScalarFieldTypeEnum | LiteralFieldType)[];
8
+ serialize(): SerializedNDimensionalFieldTypeArray;
9
+ }
10
+ export declare function isValidTypeForNDimensionalFieldTypeArray(fieldType: any): fieldType is ScalarFieldTypeEnum | LiteralFieldType;
11
+ export declare function isNDimensionalFieldTypeArray(fieldType: any): fieldType is NDimensionalFieldTypeArray;
12
+ export declare type SerializedNDimensionalFieldTypeArray = {
13
+ 'ND': true;
14
+ 'validTypes': (ScalarFieldTypeEnum | SerializedLiteralFieldType)[];
15
+ };
16
+ export declare function isSerializedNDimensionalFieldTypeArray(fieldType: any): fieldType is SerializedNDimensionalFieldTypeArray;
17
+ export declare function deserializeNDimensionalFieldTypeArray(serializedNDimensionalFieldTypeArray: SerializedNDimensionalFieldTypeArray): NDimensionalFieldTypeArray;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeNDimensionalFieldTypeArray = exports.isSerializedNDimensionalFieldTypeArray = exports.isNDimensionalFieldTypeArray = exports.isValidTypeForNDimensionalFieldTypeArray = exports.NDimensionalFieldTypeArray = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const literalfieldtype_1 = require("./literalfieldtype");
6
+ const scalarfieldtype_1 = require("./scalarfieldtype");
7
+ class NDimensionalFieldTypeArray {
8
+ constructor(validTypesArray) {
9
+ this.validTypesArray = validTypesArray;
10
+ }
11
+ getInnerTypes() {
12
+ return [...this.validTypesArray, this];
13
+ }
14
+ getInnerNonArrayTypes() {
15
+ return this.validTypesArray.filter((innerType) => (0, scalarfieldtype_1.isScalarFieldTypeEnum)(innerType) || (0, literalfieldtype_1.isLiteralFieldType)(innerType));
16
+ }
17
+ serialize() {
18
+ return {
19
+ 'ND': true,
20
+ 'validTypes': this.validTypesArray.map((t) => ((0, scalarfieldtype_1.isScalarFieldTypeEnum)(t) ? t : t.serialize())),
21
+ };
22
+ }
23
+ }
24
+ exports.NDimensionalFieldTypeArray = NDimensionalFieldTypeArray;
25
+ function isValidTypeForNDimensionalFieldTypeArray(fieldType) {
26
+ return (0, scalarfieldtype_1.isScalarFieldTypeEnum)(fieldType) || (0, literalfieldtype_1.isLiteralFieldType)(fieldType);
27
+ }
28
+ exports.isValidTypeForNDimensionalFieldTypeArray = isValidTypeForNDimensionalFieldTypeArray;
29
+ function isNDimensionalFieldTypeArray(fieldType) {
30
+ return fieldType instanceof NDimensionalFieldTypeArray;
31
+ }
32
+ exports.isNDimensionalFieldTypeArray = isNDimensionalFieldTypeArray;
33
+ function isSerializedNDimensionalFieldTypeArray(fieldType) {
34
+ return ((0, checks_1.isObject)(fieldType) &&
35
+ (0, checks_1.isBoolean)(fieldType['ND']) &&
36
+ fieldType['ND'] === true &&
37
+ (0, checks_1.isTypedArray)(checks_1.isAny)(fieldType['validTypes']) &&
38
+ fieldType['validTypes'].every((validType) => {
39
+ return (0, checks_1.isDefAndNotNull)(scalarfieldtype_1.ScalarFieldTypeEnum[validType]) || (0, literalfieldtype_1.isSerializedLiteralFieldType)(validType);
40
+ }));
41
+ }
42
+ exports.isSerializedNDimensionalFieldTypeArray = isSerializedNDimensionalFieldTypeArray;
43
+ function deserializeNDimensionalFieldTypeArray(serializedNDimensionalFieldTypeArray) {
44
+ return new NDimensionalFieldTypeArray(serializedNDimensionalFieldTypeArray['validTypes'].map((t) => {
45
+ if ((0, literalfieldtype_1.isSerializedLiteralFieldType)(t)) {
46
+ return (0, literalfieldtype_1.deserializeLiteralFieldType)(t);
47
+ }
48
+ return t;
49
+ }));
50
+ }
51
+ exports.deserializeNDimensionalFieldTypeArray = deserializeNDimensionalFieldTypeArray;
@@ -0,0 +1,14 @@
1
+ export declare enum ScalarFieldTypeEnum {
2
+ ANY = 0,
3
+ NUMBER = 1,
4
+ BOOLEAN = 2,
5
+ STRING = 3,
6
+ COLOR = 4,
7
+ DATE = 5,
8
+ NULL = 6,
9
+ DICTIONARY = 7,
10
+ CURRENCY = 8,
11
+ DATEONLY = 9
12
+ }
13
+ export declare const AnyScalarFieldType: ScalarFieldTypeEnum[];
14
+ export declare const isScalarFieldTypeEnum: (fieldType: any) => fieldType is ScalarFieldTypeEnum;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isScalarFieldTypeEnum = exports.AnyScalarFieldType = exports.ScalarFieldTypeEnum = void 0;
4
+ var ScalarFieldTypeEnum;
5
+ (function (ScalarFieldTypeEnum) {
6
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["ANY"] = 0] = "ANY";
7
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["NUMBER"] = 1] = "NUMBER";
8
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["BOOLEAN"] = 2] = "BOOLEAN";
9
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["STRING"] = 3] = "STRING";
10
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["COLOR"] = 4] = "COLOR";
11
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["DATE"] = 5] = "DATE";
12
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["NULL"] = 6] = "NULL";
13
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["DICTIONARY"] = 7] = "DICTIONARY";
14
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["CURRENCY"] = 8] = "CURRENCY";
15
+ ScalarFieldTypeEnum[ScalarFieldTypeEnum["DATEONLY"] = 9] = "DATEONLY";
16
+ })(ScalarFieldTypeEnum = exports.ScalarFieldTypeEnum || (exports.ScalarFieldTypeEnum = {}));
17
+ exports.AnyScalarFieldType = [
18
+ ScalarFieldTypeEnum.ANY,
19
+ ScalarFieldTypeEnum.NUMBER,
20
+ ScalarFieldTypeEnum.STRING,
21
+ ScalarFieldTypeEnum.BOOLEAN,
22
+ ScalarFieldTypeEnum.COLOR,
23
+ ScalarFieldTypeEnum.DATE,
24
+ ScalarFieldTypeEnum.DATEONLY,
25
+ ScalarFieldTypeEnum.NULL,
26
+ ScalarFieldTypeEnum.DICTIONARY,
27
+ ScalarFieldTypeEnum.CURRENCY,
28
+ ];
29
+ const AnyScalarFieldTypeSet = new Set(exports.AnyScalarFieldType);
30
+ const isScalarFieldTypeEnum = (fieldType) => {
31
+ return AnyScalarFieldTypeSet.has(fieldType);
32
+ };
33
+ exports.isScalarFieldTypeEnum = isScalarFieldTypeEnum;
@@ -0,0 +1,24 @@
1
+ import { SerializedFieldType } from '../serializedfield/serializedfields';
2
+ import { SerializedSchema } from '../serializedfield/serializedschema';
3
+ export declare const FlattenedReferenceKeyId = "192d0e9f-2f5a-4032-9f03-59bbf1ea5891";
4
+ export declare const FlattenedReferenceKeyName = "192d0e9f-2f5a-4032-9f03-59bbf1ea5891_n";
5
+ export interface SerializedReferenceKey {
6
+ 'cid': string;
7
+ 'pk': string;
8
+ 'wl'?: string[];
9
+ 'ro'?: boolean;
10
+ }
11
+ export declare type TypedSerializedFlattenedReference = {
12
+ 'sc': SerializedSchema;
13
+ 'n'?: string;
14
+ 'd': {
15
+ [index: string]: SerializedFieldType;
16
+ };
17
+ };
18
+ export declare type UnTypedSerializedFlattenedReference = {
19
+ [FlattenedReferenceKeyId]: true;
20
+ [FlattenedReferenceKeyName]?: string;
21
+ [index: string]: SerializedFieldType;
22
+ };
23
+ export declare type SerializedFlattenedReference = TypedSerializedFlattenedReference | UnTypedSerializedFlattenedReference;
24
+ export declare type SerializedReferenceKeyType = SerializedReferenceKey | SerializedFlattenedReference;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlattenedReferenceKeyName = exports.FlattenedReferenceKeyId = void 0;
4
+ exports.FlattenedReferenceKeyId = '192d0e9f-2f5a-4032-9f03-59bbf1ea5891';
5
+ exports.FlattenedReferenceKeyName = '192d0e9f-2f5a-4032-9f03-59bbf1ea5891_n';
@@ -0,0 +1,5 @@
1
+ import { SerializedFields } from './serializedfields';
2
+ export interface SerializedDataItems {
3
+ [primaryKey: string]: SerializedFields;
4
+ }
5
+ export declare function isSerializedDataItems(x: unknown): x is SerializedDataItems;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedDataItems = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const serializedfields_1 = require("./serializedfields");
6
+ function isSerializedDataItems(x) {
7
+ return (0, checks_1.isObject)(x) && Object.values(x).every(serializedfields_1.isSerializedFields);
8
+ }
9
+ exports.isSerializedDataItems = isSerializedDataItems;
@@ -0,0 +1,19 @@
1
+ import { JsonSerializable } from '../../jsonserializable';
2
+ import { SerializedFieldTypeDefinition } from '../fieldtypedefinition/fieldtypedefinition';
3
+ export declare type SerializedFieldDefinition = {
4
+ 'Name': string;
5
+ 'Type': SerializedFieldTypeDefinition;
6
+ 'Constraints'?: SerializedFieldConstraint[];
7
+ 'SyncSchema'?: string;
8
+ };
9
+ export declare enum FieldConstraintType {
10
+ REQUIRED = "required",
11
+ LOCKED = "locked",
12
+ MIN_VALUE = "minValue",
13
+ MAX_VALUE = "maxValue",
14
+ SINGLE_LINE_ONLY = "singleLineOnly"
15
+ }
16
+ export declare type SerializedFieldConstraint = {
17
+ 'Type': FieldConstraintType;
18
+ 'Details'?: JsonSerializable;
19
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldConstraintType = void 0;
4
+ // The options here must match com.lucidchart.data.model.fielddefinition.FieldConstraintType on the backend
5
+ var FieldConstraintType;
6
+ (function (FieldConstraintType) {
7
+ FieldConstraintType["REQUIRED"] = "required";
8
+ FieldConstraintType["LOCKED"] = "locked";
9
+ FieldConstraintType["MIN_VALUE"] = "minValue";
10
+ FieldConstraintType["MAX_VALUE"] = "maxValue";
11
+ FieldConstraintType["SINGLE_LINE_ONLY"] = "singleLineOnly";
12
+ })(FieldConstraintType = exports.FieldConstraintType || (exports.FieldConstraintType = {}));
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isSerializedFields = exports.isSerializedFieldType = exports.isSerializedLucidDateObject = exports.isSerializedLucidCurrency = exports.isSerializedLucidDictionary = exports.isSerializedColorObjectFieldType = void 0;
4
- const checks_1 = require("./checks");
4
+ const checks_1 = require("../../checks");
5
5
  function isSerializedColorObjectFieldType(value) {
6
6
  return (0, checks_1.isObject)(value) && (0, checks_1.isObject)(value['color']);
7
7
  }
@@ -0,0 +1,9 @@
1
+ import { SerializedFieldDefinition } from './serializedfielddefinition';
2
+ export declare type SerializedLabelOverrides = {
3
+ [key: string]: string;
4
+ };
5
+ export declare type SerializedSchema = {
6
+ 'Fields': SerializedFieldDefinition[];
7
+ 'PrimaryKey': string[];
8
+ 'FieldLabelOverrides'?: SerializedLabelOverrides;
9
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
+ import { SerializedFieldType } from '../core/data/serializedfield/serializedfields';
1
2
  import { ElementProxy } from '../document/elementproxy';
2
3
  import { MapProxy } from '../document/mapproxy';
3
4
  import { EditorClient } from '../editorclient';
@@ -33,6 +34,11 @@ export declare class CollectionProxy extends ElementProxy {
33
34
  * there are two data items that would have the same primary key.
34
35
  */
35
36
  readonly items: MapProxy<string, DataItemProxy>;
37
+ patchItems(patch: {
38
+ added?: Record<string, SerializedFieldType>[];
39
+ changed?: Map<string, Record<string, SerializedFieldType>>;
40
+ deleted?: string[];
41
+ }): void;
36
42
  /**
37
43
  * @returns an array of field names that are accessible on the items in this collection
38
44
  */
@@ -42,6 +42,21 @@ class CollectionProxy extends elementproxy_1.ElementProxy {
42
42
  const id = this.properties.get('BranchedFrom');
43
43
  return id ? new CollectionProxy(id, this.client) : undefined;
44
44
  }
45
+ patchItems(patch) {
46
+ var _a, _b;
47
+ const changed = {};
48
+ if (patch.changed) {
49
+ for (const [primaryKey, record] of patch.changed) {
50
+ changed[primaryKey] = record;
51
+ }
52
+ }
53
+ this.client.sendCommand("pdi" /* PatchDataItems */, {
54
+ 'id': this.id,
55
+ 'a': (_a = patch.added) !== null && _a !== void 0 ? _a : [],
56
+ 'c': changed,
57
+ 'd': (_b = patch.deleted) !== null && _b !== void 0 ? _b : [],
58
+ });
59
+ }
45
60
  /**
46
61
  * @returns an array of field names that are accessible on the items in this collection
47
62
  */
@@ -1,3 +1,4 @@
1
+ import { JsonSerializable } from '../core/jsonserializable';
1
2
  import { MapProxy } from '../document/mapproxy';
2
3
  import { EditorClient } from '../editorclient';
3
4
  import { DataSourceProxy } from './datasourceproxy';
@@ -16,4 +17,15 @@ export declare class DataProxy {
16
17
  */
17
18
  readonly dataSources: MapProxy<string, DataSourceProxy>;
18
19
  constructor(client: EditorClient);
20
+ /**
21
+ * Creates a new empty data source, which you can then add collections of data to.
22
+ *
23
+ * @param name Human-readable name of the new data source
24
+ * @param sourceConfig Any configuration values that might be useful to reference later, such
25
+ * as the upstream origin of this data source
26
+ * @returns the newly created data source
27
+ */
28
+ addDataSource(name: string, sourceConfig: {
29
+ [key: string]: JsonSerializable;
30
+ }): DataSourceProxy;
19
31
  }
@@ -19,5 +19,16 @@ class DataProxy {
19
19
  */
20
20
  this.dataSources = new mapproxy_1.MapProxy(() => this.client.sendCommand("lds" /* ListDataSources */, undefined), (dataSourceId) => new datasourceproxy_1.DataSourceProxy(dataSourceId, this.client));
21
21
  }
22
+ /**
23
+ * Creates a new empty data source, which you can then add collections of data to.
24
+ *
25
+ * @param name Human-readable name of the new data source
26
+ * @param sourceConfig Any configuration values that might be useful to reference later, such
27
+ * as the upstream origin of this data source
28
+ * @returns the newly created data source
29
+ */
30
+ addDataSource(name, sourceConfig) {
31
+ return new datasourceproxy_1.DataSourceProxy(this.client.sendCommand("cds" /* CreateDataSource */, { 'n': name, 's': sourceConfig }), this.client);
32
+ }
22
33
  }
23
34
  exports.DataProxy = DataProxy;
@@ -1,7 +1,9 @@
1
+ import { JsonSerializable } from '../core/jsonserializable';
1
2
  import { ElementProxy } from '../document/elementproxy';
2
3
  import { MapProxy } from '../document/mapproxy';
3
4
  import { EditorClient } from '../editorclient';
4
5
  import { CollectionProxy } from './collectionproxy';
6
+ import { SchemaDefinition } from './schemadefinition';
5
7
  /**
6
8
  * A data source represents a set of related data collections on a document. Typically one data source
7
9
  * is produced for each data import.
@@ -19,8 +21,15 @@ export declare class DataSourceProxy extends ElementProxy {
19
21
  * the collection ID on other documents if the same data is imported there.
20
22
  */
21
23
  readonly collections: MapProxy<string, CollectionProxy>;
24
+ addCollection(name: string, schema: SchemaDefinition): CollectionProxy;
22
25
  /**
23
26
  * @returns a human-readable name for this data source
24
27
  */
25
28
  getName(): string;
29
+ /**
30
+ * @returns The source configuration values set when this data source was created
31
+ */
32
+ getSourceConfig(): {
33
+ [key: string]: JsonSerializable;
34
+ };
26
35
  }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataSourceProxy = void 0;
4
+ const checks_1 = require("../core/checks");
5
+ const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
4
6
  const elementproxy_1 = require("../document/elementproxy");
5
7
  const mapproxy_1 = require("../document/mapproxy");
6
8
  const collectionproxy_1 = require("./collectionproxy");
@@ -23,11 +25,29 @@ class DataSourceProxy extends elementproxy_1.ElementProxy {
23
25
  */
24
26
  this.collections = new mapproxy_1.MapProxy(() => this.client.sendCommand("lc" /* ListCollections */, { 'id': this.id }), (id) => new collectionproxy_1.CollectionProxy(id, this.client));
25
27
  }
28
+ addCollection(name, schema) {
29
+ return new collectionproxy_1.CollectionProxy(this.client.sendCommand("cc" /* CreateCollection */, {
30
+ 's': this.id,
31
+ 'n': name,
32
+ 'f': schema.fields.map((field) => ({ 'n': field.name, 't': (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.type) })),
33
+ 'p': schema.primaryKey,
34
+ }), this.client);
35
+ }
26
36
  /**
27
37
  * @returns a human-readable name for this data source
28
38
  */
29
39
  getName() {
30
40
  return this.properties.get('Name');
31
41
  }
42
+ /**
43
+ * @returns The source configuration values set when this data source was created
44
+ */
45
+ getSourceConfig() {
46
+ const upstream = this.properties.get('Upstream');
47
+ if ((0, checks_1.isObject)(upstream)) {
48
+ return upstream['SourceConfig'];
49
+ }
50
+ return {};
51
+ }
32
52
  }
33
53
  exports.DataSourceProxy = DataSourceProxy;
@@ -0,0 +1,17 @@
1
+ import { SerializedReferenceKeyType } from '../core/data/referencekeys/serializedreferencekey';
2
+ import { SerializedFieldType } from '../core/data/serializedfield/serializedfields';
3
+ import { SchemaDefinition } from './schemadefinition';
4
+ export interface CollectionReferenceKeyDefinition {
5
+ collectionId: string;
6
+ primaryKey: string;
7
+ fieldWhitelist?: string[];
8
+ readonly?: boolean;
9
+ }
10
+ export interface FlattenedReferenceDefinition {
11
+ name: string;
12
+ schema: SchemaDefinition;
13
+ data: Record<string, SerializedFieldType>;
14
+ }
15
+ export declare type ReferenceKeyDefinition = CollectionReferenceKeyDefinition | FlattenedReferenceDefinition;
16
+ export declare function isCollectionReferenceKeyDefinition(def: ReferenceKeyDefinition): def is CollectionReferenceKeyDefinition;
17
+ export declare function serializeReferenceKeyDefinition(def: ReferenceKeyDefinition): SerializedReferenceKeyType;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeReferenceKeyDefinition = exports.isCollectionReferenceKeyDefinition = void 0;
4
+ const checks_1 = require("../core/checks");
5
+ const schemadefinition_1 = require("./schemadefinition");
6
+ function isCollectionReferenceKeyDefinition(def) {
7
+ return (0, checks_1.isString)(def.collectionId);
8
+ }
9
+ exports.isCollectionReferenceKeyDefinition = isCollectionReferenceKeyDefinition;
10
+ function serializeReferenceKeyDefinition(def) {
11
+ if (isCollectionReferenceKeyDefinition(def)) {
12
+ return {
13
+ 'cid': def.collectionId,
14
+ 'pk': def.primaryKey,
15
+ 'wl': def.fieldWhitelist,
16
+ 'ro': def.readonly,
17
+ };
18
+ }
19
+ else {
20
+ return {
21
+ 'sc': (0, schemadefinition_1.serializeSchemaDefinition)(def.schema),
22
+ 'n': def.name,
23
+ 'd': def.data,
24
+ };
25
+ }
26
+ }
27
+ exports.serializeReferenceKeyDefinition = serializeReferenceKeyDefinition;
@@ -0,0 +1,9 @@
1
+ import { SerializedReferenceKeyType } from '../core/data/referencekeys/serializedreferencekey';
2
+ import { EditorClient } from '../editorclient';
3
+ export declare class ReferenceKeyProxy {
4
+ readonly elementId: string | undefined;
5
+ readonly key: string | number;
6
+ private readonly client;
7
+ private readonly settings;
8
+ constructor(elementId: string | undefined, key: string | number, client: EditorClient, settings: SerializedReferenceKeyType);
9
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReferenceKeyProxy = void 0;
4
+ class ReferenceKeyProxy {
5
+ constructor(elementId, key, client, settings) {
6
+ this.elementId = elementId;
7
+ this.key = key;
8
+ this.client = client;
9
+ this.settings = settings;
10
+ }
11
+ }
12
+ exports.ReferenceKeyProxy = ReferenceKeyProxy;
@@ -0,0 +1,11 @@
1
+ import { FieldTypeDefinition } from '../core/data/fieldtypedefinition/fieldtypedefinition';
2
+ import { SerializedSchema } from '../core/data/serializedfield/serializedschema';
3
+ export interface FieldDefinition {
4
+ name: string;
5
+ type: FieldTypeDefinition;
6
+ }
7
+ export interface SchemaDefinition {
8
+ fields: FieldDefinition[];
9
+ primaryKey: string[];
10
+ }
11
+ export declare function serializeSchemaDefinition(def: SchemaDefinition): SerializedSchema;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeSchemaDefinition = void 0;
4
+ const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
5
+ function serializeSchemaDefinition(def) {
6
+ return {
7
+ 'Fields': def.fields.map((field) => ({
8
+ 'Name': field.name,
9
+ 'Type': (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.type),
10
+ })),
11
+ 'PrimaryKey': def.primaryKey,
12
+ };
13
+ }
14
+ exports.serializeSchemaDefinition = serializeSchemaDefinition;
@@ -1,3 +1,4 @@
1
+ import { JsonObject, JsonSerializable } from '../../lucid-extension-sdk';
1
2
  import { Box } from '../math';
2
3
  /**
3
4
  * The information required to create a new block on the current document
@@ -11,4 +12,13 @@ export interface BlockDefinition {
11
12
  * The initial location and size of the block on the page.
12
13
  */
13
14
  boundingBox: Box;
15
+ /**
16
+ * Additional properties to set on the block immediately after creation
17
+ */
18
+ properties: JsonObject;
19
+ /**
20
+ * If specified, the stencil to use for a custom shape. This is not typically set directly; use
21
+ * PageProxy.getCustomShapeDefinition().
22
+ */
23
+ stencil?: JsonSerializable;
14
24
  }
@@ -1,3 +1,5 @@
1
+ import { ReferenceKeyDefinition } from '../data/referencekeydefinition';
2
+ import { ReferenceKeyProxy } from '../data/referencekeyproxy';
1
3
  import { EditorClient } from '../editorclient';
2
4
  import { MapProxy, WriteableMapProxy } from './mapproxy';
3
5
  import { ShapeDataProxy } from './shapedataproxy';
@@ -27,6 +29,9 @@ export declare class ElementProxy {
27
29
  * This collection is read-only.
28
30
  */
29
31
  readonly allShapeData: MapProxy<string, import("..").SerializedFieldType | import("..").DataError>;
32
+ readonly referenceKeys: MapProxy<string | number, ReferenceKeyProxy>;
33
+ setReferenceKey(key: number | string, settings: ReferenceKeyDefinition): void;
34
+ removeReferenceKey(key: number | string): void;
30
35
  /**
31
36
  *
32
37
  * @param id ID of this element, or undefined for the document itself
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ElementProxy = void 0;
4
+ const referencekeydefinition_1 = require("../data/referencekeydefinition");
5
+ const referencekeyproxy_1 = require("../data/referencekeyproxy");
4
6
  const mapproxy_1 = require("./mapproxy");
5
7
  const shapedataproxy_1 = require("./shapedataproxy");
6
8
  /**
@@ -50,6 +52,17 @@ class ElementProxy {
50
52
  'id': this.id,
51
53
  'n': name,
52
54
  })));
55
+ this.referenceKeys = new mapproxy_1.MapProxy(() => this.client.sendCommand("lrk" /* ListReferenceKeys */, { 'id': this.id }), (key) => new referencekeyproxy_1.ReferenceKeyProxy(this.id, key, this.client, this.client.sendCommand("grk" /* GetReferenceKey */, { 'id': this.id, 'k': key })));
56
+ }
57
+ setReferenceKey(key, settings) {
58
+ this.client.sendCommand("srk" /* SetReferenceKey */, {
59
+ 'id': this.id,
60
+ 'k': key,
61
+ 'v': (0, referencekeydefinition_1.serializeReferenceKeyDefinition)(settings),
62
+ });
63
+ }
64
+ removeReferenceKey(key) {
65
+ this.client.sendCommand("srk" /* SetReferenceKey */, { 'id': this.id, 'k': key });
53
66
  }
54
67
  /**
55
68
  * @returns true if this element still exists on the document, or false otherwise
@@ -55,9 +55,13 @@ class PageProxy extends elementproxy_1.ElementProxy {
55
55
  const id = this.client.sendCommand("cb" /* CreateBlock */, {
56
56
  'p': this.id,
57
57
  'c': def.className,
58
+ 's': def.stencil,
58
59
  });
59
60
  const block = this.client.getBlockProxy(id);
60
61
  block.setBoundingBox(def.boundingBox);
62
+ for (const key in def.properties) {
63
+ block.properties.set(key, def.properties[key]);
64
+ }
61
65
  return block;
62
66
  }
63
67
  /**
@@ -1,5 +1,5 @@
1
+ import { SerializedFieldType } from '../core/data/serializedfield/serializedfields';
1
2
  import { SerializedDataError } from '../core/serializeddataerror';
2
- import { SerializedFieldType } from '../core/serializedfields';
3
3
  import { DataError } from '../data/dataerror';
4
4
  import { EditorClient } from '../editorclient';
5
5
  import { WriteableMapProxy } from './mapproxy';