lucid-extension-sdk 0.0.433 → 0.0.435

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.
@@ -1,4 +1,5 @@
1
- import { FieldConstraintDefinition } from '../../data/schemadefinition';
1
+ import { DisplayOptionDefinition } from '../../data/displayoptiondefinition';
2
+ import { FieldConstraintDefinition } from '../../data/fieldconstraintdefinition';
2
3
  import { CollectionEnumFieldType } from './fieldtypedefinition/collectionenumfieldtype';
3
4
  import { DeserializedMapEnumFieldType } from './fieldtypedefinition/deserializedmapenumfieldtype';
4
5
  import { FieldTypeArray } from './fieldtypedefinition/fieldtypearray';
@@ -25,11 +26,12 @@ type TsTypeOf<X> = X extends ScalarFieldTypeEnum.ANY ? unknown : X extends Scala
25
26
  * additional (and valuable) user functionality. This includes better support in the edit panel, and better user facing
26
27
  * descriptions of your fields.
27
28
  */
28
- export declare function declareSchema<Names extends string, Types extends Readonly<FieldTypeDefinition>, Constraint extends FieldConstraintDefinition, Fields extends {
29
+ export declare function declareSchema<Names extends string, Types extends Readonly<FieldTypeDefinition>, Constraint extends FieldConstraintDefinition, DisplayOption extends DisplayOptionDefinition, Fields extends {
29
30
  [Name in Names]: {
30
31
  type: Types;
31
32
  constraints?: readonly Constraint[];
32
33
  mapping?: readonly SemanticKind[] | readonly SemanticFields[] | readonly LucidFields[] | undefined;
34
+ displayOptions?: readonly DisplayOption[] | undefined;
33
35
  };
34
36
  }, PrimaryKey extends keyof Fields>({ primaryKey, fields }: {
35
37
  primaryKey: PrimaryKey[];
@@ -41,6 +43,7 @@ export declare function declareSchema<Names extends string, Types extends Readon
41
43
  type: FieldTypeDefinition;
42
44
  constraints: FieldConstraintDefinition[];
43
45
  mapping: readonly SemanticKind[] | readonly SemanticFields[] | readonly LucidFields[];
46
+ displayOptions: readonly DisplayOption[];
44
47
  }[];
45
48
  primaryKey: FormattedPrimaryKey<Fields, PrimaryKey>;
46
49
  fromItemsSparse: (items: PartialItemType<typeof fields, PrimaryKey>[]) => Map<string, PartialItemType<Fields, PrimaryKey>>;
@@ -22,12 +22,13 @@ function declareSchema({ primaryKey, fields }) {
22
22
  const primaryKeyObj = new FormattedPrimaryKey(...primaryKey);
23
23
  return {
24
24
  example: fields,
25
- array: Object.entries(fields).map(([name, { type, constraints, mapping }]) => {
25
+ array: Object.entries(fields).map(([name, { type, constraints, mapping, displayOptions: displayOptions }]) => {
26
26
  return {
27
27
  'name': name,
28
28
  'type': isArrayAndAssertReadonly(type) ? type.slice() : type,
29
29
  'constraints': constraints,
30
30
  'mapping': mapping,
31
+ 'displayOptions': displayOptions,
31
32
  };
32
33
  }),
33
34
  primaryKey: primaryKeyObj,
@@ -0,0 +1,17 @@
1
+ import { UnsafeJsonSerializableOrUndefined } from '../../jsonserializable';
2
+ /**
3
+ * @experimental
4
+ * The options here must match com.lucidchart.data.model.fielddefinition.DisplayOptionType on the backend
5
+ */
6
+ export declare enum DisplayOptionType {
7
+ DisplayMultiUserSelect = "displayMultiUserSelect"
8
+ }
9
+ export declare const isDisplayOptionType: (x: unknown) => x is DisplayOptionType.DisplayMultiUserSelect;
10
+ export type SerializedDisplayOption = {
11
+ 'Type': DisplayOptionType;
12
+ 'Details'?: UnsafeJsonSerializableOrUndefined;
13
+ };
14
+ export declare const isSerializedDisplayOption: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
15
+ Type: (x: unknown) => x is DisplayOptionType.DisplayMultiUserSelect;
16
+ Details: (x: unknown) => x is UnsafeJsonSerializableOrUndefined;
17
+ }>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedDisplayOption = exports.isDisplayOptionType = exports.DisplayOptionType = void 0;
4
+ const jsonserializable_1 = require("../../jsonserializable");
5
+ const validators_1 = require("../../validators/validators");
6
+ /**
7
+ * @experimental
8
+ * The options here must match com.lucidchart.data.model.fielddefinition.DisplayOptionType on the backend
9
+ */
10
+ var DisplayOptionType;
11
+ (function (DisplayOptionType) {
12
+ DisplayOptionType["DisplayMultiUserSelect"] = "displayMultiUserSelect";
13
+ })(DisplayOptionType || (exports.DisplayOptionType = DisplayOptionType = {}));
14
+ exports.isDisplayOptionType = (0, validators_1.enumValidator)(DisplayOptionType);
15
+ exports.isSerializedDisplayOption = (0, validators_1.objectValidator)({
16
+ 'Type': (0, validators_1.enumValidator)(DisplayOptionType),
17
+ 'Details': (0, validators_1.option)(jsonserializable_1.isJsonSerializableOrUndefined),
18
+ });
@@ -4,6 +4,7 @@ import { SerializedFieldTypeDefinition, isSerializedFieldTypeDefinition } from '
4
4
  import { LucidFields } from '../fieldtypedefinition/lucidfields';
5
5
  import { SemanticFields } from '../fieldtypedefinition/semanticfields';
6
6
  import { SemanticKind } from '../fieldtypedefinition/semantickind';
7
+ import { SerializedDisplayOption } from './serializeddisplayoption';
7
8
  export declare enum FieldConstraintType {
8
9
  REQUIRED = "required",
9
10
  LOCKED = "locked",
@@ -31,6 +32,7 @@ export type SerializedFieldDefinition = {
31
32
  'Constraints'?: SerializedFieldConstraint[] | undefined;
32
33
  'SyncSchema'?: string | undefined;
33
34
  'Mapping'?: readonly LucidFields[] | readonly SemanticFields[] | readonly SemanticKind[] | undefined;
35
+ 'DisplayOptions'?: SerializedDisplayOption[] | undefined;
34
36
  };
35
37
  export declare const isSerializedFieldDefinition: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
36
38
  Name: typeof isString;
@@ -42,4 +44,8 @@ export declare const isSerializedFieldDefinition: (subject: unknown) => subject
42
44
  }>[] | undefined;
43
45
  SyncSchema: (x: unknown) => x is string | undefined;
44
46
  Mapping: (x: unknown) => x is LucidFields[] | SemanticKind[] | undefined;
47
+ DisplayOptions: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
48
+ Type: (x: unknown) => x is import("./serializeddisplayoption").DisplayOptionType.DisplayMultiUserSelect;
49
+ Details: (x: unknown) => x is UnsafeJsonSerializableOrUndefined;
50
+ }>[] | undefined;
45
51
  }>;
@@ -6,6 +6,7 @@ const validators_1 = require("../../validators/validators");
6
6
  const fieldtypedefinition_1 = require("../fieldtypedefinition/fieldtypedefinition");
7
7
  const lucidfields_1 = require("../fieldtypedefinition/lucidfields");
8
8
  const semantickind_1 = require("../fieldtypedefinition/semantickind");
9
+ const serializeddisplayoption_1 = require("./serializeddisplayoption");
9
10
  // The options here must match com.lucidchart.data.model.fielddefinition.FieldConstraintType on the backend
10
11
  var FieldConstraintType;
11
12
  (function (FieldConstraintType) {
@@ -30,4 +31,5 @@ exports.isSerializedFieldDefinition = (0, validators_1.strictObjectValidator)({
30
31
  'Constraints': (0, validators_1.option)((0, validators_1.arrayValidator)(exports.isSerializedFieldConstraint)),
31
32
  'SyncSchema': (0, validators_1.option)(checks_1.isString),
32
33
  'Mapping': (0, validators_1.option)((0, validators_1.either)((0, validators_1.arrayValidator)(lucidfields_1.isLucidFields), (0, validators_1.arrayValidator)(semantickind_1.isSemanticKind))),
34
+ 'DisplayOptions': (0, validators_1.option)((0, validators_1.arrayValidator)(serializeddisplayoption_1.isSerializedDisplayOption)),
33
35
  });
@@ -0,0 +1,14 @@
1
+ import { isUndefined } from '../core/checks';
2
+ import { DisplayOptionType, SerializedDisplayOption } from '../core/data/serializedfield/serializeddisplayoption';
3
+ export interface DisplayMultiUserEditDisplayOptionDefinition {
4
+ type: DisplayOptionType.DisplayMultiUserSelect;
5
+ value?: undefined;
6
+ }
7
+ export type DisplayOptionDefinition = DisplayMultiUserEditDisplayOptionDefinition;
8
+ export declare function createDisplayOptionDefinition(type: DisplayOptionType, value?: number): DisplayOptionDefinition;
9
+ export declare const isDisplayOptionDefinition: (subject: unknown) => subject is import("..").DestructureGuardedTypeObj<{
10
+ type: (x: unknown) => x is DisplayOptionType.DisplayMultiUserSelect;
11
+ value: typeof isUndefined;
12
+ }>;
13
+ /** @ignore */
14
+ export declare function serializeDisplayOptionDefinition(option: DisplayOptionDefinition): SerializedDisplayOption;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeDisplayOptionDefinition = exports.isDisplayOptionDefinition = exports.createDisplayOptionDefinition = void 0;
4
+ const assertnever_1 = require("../core/assertnever");
5
+ const checks_1 = require("../core/checks");
6
+ const serializeddisplayoption_1 = require("../core/data/serializedfield/serializeddisplayoption");
7
+ const validators_1 = require("../core/validators/validators");
8
+ function createDisplayOptionDefinition(type, value) {
9
+ switch (type) {
10
+ case serializeddisplayoption_1.DisplayOptionType.DisplayMultiUserSelect:
11
+ if (value !== undefined) {
12
+ throw new Error('Invalid display option value');
13
+ }
14
+ return { type };
15
+ default:
16
+ (0, assertnever_1.assertNever)(type);
17
+ }
18
+ }
19
+ exports.createDisplayOptionDefinition = createDisplayOptionDefinition;
20
+ exports.isDisplayOptionDefinition = (0, validators_1.objectValidator)({
21
+ 'type': serializeddisplayoption_1.isDisplayOptionType,
22
+ 'value': checks_1.isUndefined, // value is always undefined for now, update as more complex options are added
23
+ });
24
+ /** @ignore */
25
+ function serializeDisplayOptionDefinition(option) {
26
+ return {
27
+ 'Type': option.type,
28
+ 'Details': option.value,
29
+ };
30
+ }
31
+ exports.serializeDisplayOptionDefinition = serializeDisplayOptionDefinition;
@@ -0,0 +1,58 @@
1
+ import { isNumber, isUndefined } from '../core/checks';
2
+ import { FieldConstraintType, SerializedFieldConstraint } from '../core/data/serializedfield/serializedfielddefinition';
3
+ export interface RequiredFieldConstraintDefinition {
4
+ type: FieldConstraintType.REQUIRED;
5
+ value?: undefined;
6
+ reason?: string | undefined;
7
+ }
8
+ export interface LockedFieldConstraintDefinition {
9
+ type: FieldConstraintType.LOCKED;
10
+ value?: undefined;
11
+ reason?: string | undefined;
12
+ }
13
+ export interface MinValueFieldConstraintDefinition {
14
+ type: FieldConstraintType.MIN_VALUE;
15
+ value: number;
16
+ reason?: string | undefined;
17
+ }
18
+ export interface MaxValueFieldConstraintDefinition {
19
+ type: FieldConstraintType.MAX_VALUE;
20
+ value: number;
21
+ reason?: string | undefined;
22
+ }
23
+ export interface SingleLineFieldConstraintDefinition {
24
+ type: FieldConstraintType.SINGLE_LINE_ONLY;
25
+ value?: undefined;
26
+ reason?: string | undefined;
27
+ }
28
+ export interface NoWhitespaceFieldConstraintDefinition {
29
+ type: FieldConstraintType.NO_WHITESPACE;
30
+ value?: undefined;
31
+ reason?: string | undefined;
32
+ }
33
+ export interface UniqueEditFieldConstraintDefinition {
34
+ type: FieldConstraintType.UNIQUE_EDIT;
35
+ value?: undefined;
36
+ reason?: string | undefined;
37
+ }
38
+ export interface MaxLengthConstraintDefinition {
39
+ type: FieldConstraintType.MAX_LENGTH;
40
+ value: number;
41
+ reason?: string | undefined;
42
+ }
43
+ export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition;
44
+ export declare function createFieldConstraintDefinition(type: FieldConstraintType, value?: number, reason?: string): FieldConstraintDefinition;
45
+ export declare function minMaxFieldConstraintValidator(val: unknown): val is FieldConstraintType.MIN_VALUE | FieldConstraintType.MAX_VALUE | FieldConstraintType.MAX_LENGTH;
46
+ export declare const isFieldConstraintDefinition: (x: unknown) => x is {
47
+ type?: FieldConstraintType | undefined;
48
+ } & {
49
+ type: FieldConstraintType;
50
+ } & (import("..").DestructureGuardedTypeObj<{
51
+ type: typeof minMaxFieldConstraintValidator;
52
+ value: typeof isNumber;
53
+ }> | import("..").DestructureGuardedTypeObj<{
54
+ type: (x: unknown) => x is FieldConstraintType.REQUIRED | FieldConstraintType.LOCKED | FieldConstraintType.SINGLE_LINE_ONLY | FieldConstraintType.NO_WHITESPACE | FieldConstraintType.UNIQUE_EDIT;
55
+ value: typeof isUndefined;
56
+ }>);
57
+ /** @ignore */
58
+ export declare function serializeFieldConstraintDefinition(constraint: FieldConstraintDefinition): SerializedFieldConstraint;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeFieldConstraintDefinition = exports.isFieldConstraintDefinition = exports.minMaxFieldConstraintValidator = exports.createFieldConstraintDefinition = void 0;
4
+ const assertnever_1 = require("../core/assertnever");
5
+ const checks_1 = require("../core/checks");
6
+ const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
7
+ const validators_1 = require("../core/validators/validators");
8
+ function createFieldConstraintDefinition(type, value, reason) {
9
+ switch (type) {
10
+ case serializedfielddefinition_1.FieldConstraintType.REQUIRED:
11
+ case serializedfielddefinition_1.FieldConstraintType.LOCKED:
12
+ return Object.assign({ type }, (reason && { reason }));
13
+ case serializedfielddefinition_1.FieldConstraintType.MIN_VALUE:
14
+ case serializedfielddefinition_1.FieldConstraintType.MAX_VALUE:
15
+ case serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH:
16
+ if (value === undefined) {
17
+ throw new Error('Invalid constraint value');
18
+ }
19
+ return Object.assign({ type, value }, (reason && { reason }));
20
+ case serializedfielddefinition_1.FieldConstraintType.SINGLE_LINE_ONLY:
21
+ case serializedfielddefinition_1.FieldConstraintType.NO_WHITESPACE:
22
+ case serializedfielddefinition_1.FieldConstraintType.UNIQUE_EDIT:
23
+ if (value !== undefined) {
24
+ throw new Error('Invalid constraint value');
25
+ }
26
+ return Object.assign({ type }, (reason && { reason }));
27
+ default:
28
+ (0, assertnever_1.assertNever)(type);
29
+ }
30
+ }
31
+ exports.createFieldConstraintDefinition = createFieldConstraintDefinition;
32
+ function minMaxFieldConstraintValidator(val) {
33
+ return (val === serializedfielddefinition_1.FieldConstraintType.MIN_VALUE ||
34
+ val === serializedfielddefinition_1.FieldConstraintType.MAX_VALUE ||
35
+ val === serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH);
36
+ }
37
+ exports.minMaxFieldConstraintValidator = minMaxFieldConstraintValidator;
38
+ exports.isFieldConstraintDefinition = (0, validators_1.both)((0, validators_1.objectValidator)({
39
+ 'type': serializedfielddefinition_1.isFieldConstraintType,
40
+ }), (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 })));
41
+ /** @ignore */
42
+ function serializeFieldConstraintDefinition(constraint) {
43
+ return {
44
+ 'Type': constraint.type,
45
+ 'Details': constraint.value,
46
+ 'Reason': constraint.reason,
47
+ };
48
+ }
49
+ exports.serializeFieldConstraintDefinition = serializeFieldConstraintDefinition;
@@ -1,64 +1,11 @@
1
- import { isNumber, isUndefined } from '../core/checks';
2
1
  import { FieldTypeDefinition } from '../core/data/fieldtypedefinition/fieldtypedefinition';
3
2
  import { LucidFields } from '../core/data/fieldtypedefinition/lucidfields';
4
3
  import { SemanticFields } from '../core/data/fieldtypedefinition/semanticfields';
5
4
  import { SemanticKind } from '../core/data/fieldtypedefinition/semantickind';
6
- import { FieldConstraintType, SerializedFieldConstraint, SerializedFieldDefinition } from '../core/data/serializedfield/serializedfielddefinition';
5
+ import { SerializedFieldDefinition } from '../core/data/serializedfield/serializedfielddefinition';
7
6
  import { SerializedSchema } from '../core/data/serializedfield/serializedschema';
8
- export interface RequiredFieldConstraintDefinition {
9
- type: FieldConstraintType.REQUIRED;
10
- value?: undefined;
11
- reason?: string | undefined;
12
- }
13
- export interface LockedFieldConstraintDefinition {
14
- type: FieldConstraintType.LOCKED;
15
- value?: undefined;
16
- reason?: string | undefined;
17
- }
18
- export interface MinValueFieldConstraintDefinition {
19
- type: FieldConstraintType.MIN_VALUE;
20
- value: number;
21
- reason?: string | undefined;
22
- }
23
- export interface MaxValueFieldConstraintDefinition {
24
- type: FieldConstraintType.MAX_VALUE;
25
- value: number;
26
- reason?: string | undefined;
27
- }
28
- export interface SingleLineFieldConstraintDefinition {
29
- type: FieldConstraintType.SINGLE_LINE_ONLY;
30
- value?: undefined;
31
- reason?: string | undefined;
32
- }
33
- export interface NoWhitespaceFieldConstraintDefinition {
34
- type: FieldConstraintType.NO_WHITESPACE;
35
- value?: undefined;
36
- reason?: string | undefined;
37
- }
38
- export interface UniqueEditFieldConstraintDefinition {
39
- type: FieldConstraintType.UNIQUE_EDIT;
40
- value?: undefined;
41
- reason?: string | undefined;
42
- }
43
- export interface MaxLengthConstraintDefinition {
44
- type: FieldConstraintType.MAX_LENGTH;
45
- value: number;
46
- reason?: string | undefined;
47
- }
48
- export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition;
49
- export declare function createFieldConstraintDefinition(type: FieldConstraintType, value?: number, reason?: string): FieldConstraintDefinition;
50
- export declare function minMaxFieldConstraintValidator(val: unknown): val is FieldConstraintType.MIN_VALUE | FieldConstraintType.MAX_VALUE | FieldConstraintType.MAX_LENGTH;
51
- export declare const isFieldConstraintDefinition: (x: unknown) => x is {
52
- type?: FieldConstraintType | undefined;
53
- } & {
54
- type: FieldConstraintType;
55
- } & (import("..").DestructureGuardedTypeObj<{
56
- type: typeof minMaxFieldConstraintValidator;
57
- value: typeof isNumber;
58
- }> | import("..").DestructureGuardedTypeObj<{
59
- type: (x: unknown) => x is FieldConstraintType.REQUIRED | FieldConstraintType.LOCKED | FieldConstraintType.SINGLE_LINE_ONLY | FieldConstraintType.NO_WHITESPACE | FieldConstraintType.UNIQUE_EDIT;
60
- value: typeof isUndefined;
61
- }>);
7
+ import { DisplayOptionDefinition } from './displayoptiondefinition';
8
+ import { FieldConstraintDefinition } from './fieldconstraintdefinition';
62
9
  /**
63
10
  * The definition for a field to be included in a [SchemaDefinition](#interfaces_data_schemadefinition-SchemaDefinition)
64
11
  */
@@ -67,6 +14,13 @@ export interface FieldDefinition {
67
14
  type: FieldTypeDefinition;
68
15
  constraints?: FieldConstraintDefinition[] | undefined;
69
16
  mapping?: readonly LucidFields[] | readonly SemanticFields[] | readonly SemanticKind[] | undefined;
17
+ /**
18
+ * @experimental
19
+ * If specified, a list of options indicating how the field should be displayed
20
+ * in the UI. This is particularly useful when collection enums are of a certain
21
+ * data type that should be rendered differently.
22
+ */
23
+ displayOptions?: readonly DisplayOptionDefinition[] | undefined;
70
24
  }
71
25
  /**
72
26
  * Definition of a schema for creating a [Collection](#classes_data_collectionproxy-CollectionProxy)
@@ -85,8 +39,6 @@ export interface SchemaDefinition {
85
39
  fieldLabels?: Record<string, string>;
86
40
  }
87
41
  /** @ignore */
88
- export declare function serializeFieldConstraintDefinition(constraint: FieldConstraintDefinition): SerializedFieldConstraint;
89
- /** @ignore */
90
42
  export declare function serializeFieldDefinition(field: FieldDefinition): SerializedFieldDefinition;
91
43
  /** @ignore */
92
44
  export declare function serializeSchemaDefinition(def: SchemaDefinition): SerializedSchema;
@@ -1,53 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = exports.serializeFieldConstraintDefinition = exports.isFieldConstraintDefinition = exports.minMaxFieldConstraintValidator = exports.createFieldConstraintDefinition = void 0;
4
- const assertnever_1 = require("../core/assertnever");
3
+ exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = void 0;
5
4
  const checks_1 = require("../core/checks");
6
5
  const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
6
+ const serializeddisplayoption_1 = require("../core/data/serializedfield/serializeddisplayoption");
7
7
  const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
8
- const validators_1 = require("../core/validators/validators");
9
- function createFieldConstraintDefinition(type, value, reason) {
10
- switch (type) {
11
- case serializedfielddefinition_1.FieldConstraintType.REQUIRED:
12
- case serializedfielddefinition_1.FieldConstraintType.LOCKED:
13
- return Object.assign({ type }, (reason && { reason }));
14
- case serializedfielddefinition_1.FieldConstraintType.MIN_VALUE:
15
- case serializedfielddefinition_1.FieldConstraintType.MAX_VALUE:
16
- case serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH:
17
- if (value === undefined) {
18
- throw new Error('Invalid constraint value');
19
- }
20
- return Object.assign({ type, value }, (reason && { reason }));
21
- case serializedfielddefinition_1.FieldConstraintType.SINGLE_LINE_ONLY:
22
- case serializedfielddefinition_1.FieldConstraintType.NO_WHITESPACE:
23
- case serializedfielddefinition_1.FieldConstraintType.UNIQUE_EDIT:
24
- if (value !== undefined) {
25
- throw new Error('Invalid constraint value');
26
- }
27
- return Object.assign({ type }, (reason && { reason }));
28
- default:
29
- (0, assertnever_1.assertNever)(type);
30
- }
31
- }
32
- exports.createFieldConstraintDefinition = createFieldConstraintDefinition;
33
- function minMaxFieldConstraintValidator(val) {
34
- return (val === serializedfielddefinition_1.FieldConstraintType.MIN_VALUE ||
35
- val === serializedfielddefinition_1.FieldConstraintType.MAX_VALUE ||
36
- val === serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH);
37
- }
38
- exports.minMaxFieldConstraintValidator = minMaxFieldConstraintValidator;
39
- exports.isFieldConstraintDefinition = (0, validators_1.both)((0, validators_1.objectValidator)({
40
- 'type': serializedfielddefinition_1.isFieldConstraintType,
41
- }), (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 })));
42
- /** @ignore */
43
- function serializeFieldConstraintDefinition(constraint) {
44
- return {
45
- 'Type': constraint.type,
46
- 'Details': constraint.value,
47
- 'Reason': constraint.reason,
48
- };
49
- }
50
- exports.serializeFieldConstraintDefinition = serializeFieldConstraintDefinition;
8
+ const displayoptiondefinition_1 = require("./displayoptiondefinition");
9
+ const fieldconstraintdefinition_1 = require("./fieldconstraintdefinition");
51
10
  /** @ignore */
52
11
  function serializeFieldDefinition(field) {
53
12
  const serialized = {
@@ -55,7 +14,10 @@ function serializeFieldDefinition(field) {
55
14
  'Type': (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.type),
56
15
  };
57
16
  if (field.constraints) {
58
- serialized['Constraints'] = field.constraints.map(serializeFieldConstraintDefinition);
17
+ serialized['Constraints'] = field.constraints.map(fieldconstraintdefinition_1.serializeFieldConstraintDefinition);
18
+ }
19
+ if (field.displayOptions) {
20
+ serialized['DisplayOptions'] = field.displayOptions.map(displayoptiondefinition_1.serializeDisplayOptionDefinition);
59
21
  }
60
22
  if (field.mapping) {
61
23
  serialized['Mapping'] = field.mapping;
@@ -74,7 +36,7 @@ function serializeSchemaDefinition(def) {
74
36
  exports.serializeSchemaDefinition = serializeSchemaDefinition;
75
37
  /** @ignore */
76
38
  function parseFieldDefinition(field) {
77
- var _a;
39
+ var _a, _b;
78
40
  return {
79
41
  name: field['Name'],
80
42
  type: (0, fieldtypedefinition_1.deserializeFieldTypeDefinition)(field['Type']),
@@ -103,6 +65,14 @@ function parseFieldDefinition(field) {
103
65
  }
104
66
  }),
105
67
  mapping: field['Mapping'],
68
+ displayOptions: (_b = field['DisplayOptions']) === null || _b === void 0 ? void 0 : _b.map((option) => {
69
+ switch (option['Type']) {
70
+ case serializeddisplayoption_1.DisplayOptionType.DisplayMultiUserSelect:
71
+ return { type: option['Type'] };
72
+ default:
73
+ throw new Error('Invalid display option format');
74
+ }
75
+ }),
106
76
  };
107
77
  }
108
78
  exports.parseFieldDefinition = parseFieldDefinition;
@@ -45,11 +45,11 @@ export declare class DataConnectorResponseError extends Error {
45
45
  constructor(message: string, response: string);
46
46
  }
47
47
  /** Used to track user collection access when EditorExtensionScope is PERSISTENT_SYNC. */
48
- export interface DocumentCollectionsBody {
48
+ export interface AffectedDocumentCollectionsBody {
49
49
  /** A mapping from collection IDs to item IDs indicating what was affected (e.g. imported, refreshed, updated) by the action. */
50
- documentCollections?: DocumentCollections;
50
+ affectedDocumentCollections?: DocumentCollections;
51
51
  }
52
- type ActionTypeForName<P extends Patch, Name extends string, Asynchronous = boolean> = Name extends `${DataConnectorActionKeys.Patch}` ? ActionRequest<DataConnectorPatchAction<P>, PatchChange[]> : Name extends `${DataConnectorActionKeys.UnbatchedPatch}` ? ActionRequest<DataConnectorPatchAction<P>, PatchChange[]> : Name extends `${DataConnectorActionKeys.ManageWebhook}` ? ActionRequest<DataConnectorManageWebhookAction, Webhook> : ActionRequest<Asynchronous extends true ? DataConnectorAsynchronousAction : DataConnectorAction, unknown | DocumentCollectionsBody>;
52
+ type ActionTypeForName<P extends Patch, Name extends string, Asynchronous = boolean> = Name extends `${DataConnectorActionKeys.Patch}` ? ActionRequest<DataConnectorPatchAction<P>, PatchChange[]> : Name extends `${DataConnectorActionKeys.UnbatchedPatch}` ? ActionRequest<DataConnectorPatchAction<P>, PatchChange[]> : Name extends `${DataConnectorActionKeys.ManageWebhook}` ? ActionRequest<DataConnectorManageWebhookAction, Webhook> : ActionRequest<Asynchronous extends true ? DataConnectorAsynchronousAction : DataConnectorAction, unknown | AffectedDocumentCollectionsBody>;
53
53
  /** Factory class to define a bunch of action handlers. */
54
54
  export declare class DataConnector<P extends Patch = ItemPatch> {
55
55
  private client;
@@ -6,12 +6,14 @@ import { SerializedFieldTypeDefinition } from '../core/data/fieldtypedefinition/
6
6
  import { LucidFields } from '../core/data/fieldtypedefinition/lucidfields';
7
7
  import { SemanticFields } from '../core/data/fieldtypedefinition/semanticfields';
8
8
  import { SemanticKind } from '../core/data/fieldtypedefinition/semantickind';
9
+ import { DisplayOptionType } from '../core/data/serializedfield/serializeddisplayoption';
9
10
  import { FieldConstraintType } from '../core/data/serializedfield/serializedfielddefinition';
10
11
  import { SerializedFields, SerializedLucidDictionary } from '../core/data/serializedfield/serializedfields';
11
12
  import { SerializedLabelOverrides } from '../core/data/serializedfield/serializedschema';
12
13
  import { UnsafeJsonSerializableOrUndefined } from '../core/jsonserializable';
13
14
  import { DataUpdateFilterType } from '../data/dataupdatefiltertype';
14
- import { FieldConstraintDefinition, FieldDefinition, SchemaDefinition } from '../data/schemadefinition';
15
+ import { FieldConstraintDefinition } from '../data/fieldconstraintdefinition';
16
+ import { FieldDefinition, SchemaDefinition } from '../data/schemadefinition';
15
17
  /**
16
18
  * Container for an update to a data source
17
19
  */
@@ -37,12 +39,17 @@ export type SerializedFieldConstraintForApi = {
37
39
  'details'?: UnsafeJsonSerializableOrUndefined;
38
40
  'reason'?: string | undefined;
39
41
  };
42
+ export type SerializedDisplayOptionForApi = {
43
+ 'type': DisplayOptionType;
44
+ 'details'?: UnsafeJsonSerializableOrUndefined;
45
+ };
40
46
  type SerializedFieldDefinitionForApi = {
41
47
  'name': string;
42
48
  'type': SerializedFieldTypeDefinition;
43
49
  'constraints': SerializedFieldConstraintForApi[];
44
50
  'syncSchema'?: string;
45
51
  'mapping'?: readonly SemanticKind[] | readonly LucidFields[] | readonly SemanticFields[];
52
+ 'displayOptions'?: SerializedDisplayOptionForApi[];
46
53
  };
47
54
  export type SerializedSchemaForApi = {
48
55
  'fields': SerializedFieldDefinitionForApi[];
@@ -74,20 +74,27 @@ function serializeFieldConstraintForApi(constraint) {
74
74
  'reason': constraint.reason,
75
75
  };
76
76
  }
77
+ function serializeDisplayOptionForApi(option) {
78
+ return {
79
+ 'type': option.type,
80
+ 'details': option.value,
81
+ };
82
+ }
77
83
  /** @ignore */
78
84
  function serializeFieldDefinitionForApi(field) {
79
- var _a;
85
+ var _a, _b, _c;
80
86
  return {
81
87
  'name': field.name,
82
88
  'type': (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.type),
83
- 'constraints': ((_a = field.constraints) !== null && _a !== void 0 ? _a : []).map((x) => serializeFieldConstraintForApi(x)),
89
+ 'constraints': (_b = (_a = field.constraints) === null || _a === void 0 ? void 0 : _a.map(serializeFieldConstraintForApi)) !== null && _b !== void 0 ? _b : [],
84
90
  'mapping': field.mapping,
91
+ 'displayOptions': (_c = field.displayOptions) === null || _c === void 0 ? void 0 : _c.map(serializeDisplayOptionForApi),
85
92
  };
86
93
  }
87
94
  exports.serializeFieldDefinitionForApi = serializeFieldDefinitionForApi;
88
95
  function serializeSchemaForApi(schema) {
89
96
  return {
90
- 'fields': schema.fields.map((x) => serializeFieldDefinitionForApi(x)),
97
+ 'fields': schema.fields.map(serializeFieldDefinitionForApi),
91
98
  'primaryKey': schema.primaryKey,
92
99
  'fieldLabelOverrides': schema.fieldLabels,
93
100
  };
@@ -174,3 +181,4 @@ const assertIsJustRenamed = () => undefined;
174
181
  assertIsJustRenamed();
175
182
  assertIsJustRenamed();
176
183
  assertIsJustRenamed();
184
+ assertIsJustRenamed();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.433",
3
+ "version": "0.0.435",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",