lucid-extension-sdk 0.0.405 → 0.0.406

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.
@@ -18,10 +18,12 @@ export declare const isFieldConstraintType: (x: unknown) => x is FieldConstraint
18
18
  export type SerializedFieldConstraint = {
19
19
  'Type': FieldConstraintType;
20
20
  'Details'?: UnsafeJsonSerializableOrUndefined;
21
+ 'Reason'?: string | undefined;
21
22
  };
22
23
  export declare const isSerializedFieldConstraint: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
23
24
  Type: (x: unknown) => x is FieldConstraintType;
24
25
  Details: (x: unknown) => x is any;
26
+ Reason: (x: unknown) => x is string | undefined;
25
27
  }>;
26
28
  export type SerializedFieldDefinition = {
27
29
  'Name': string;
@@ -36,6 +38,7 @@ export declare const isSerializedFieldDefinition: (subject: unknown) => subject
36
38
  Constraints: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
37
39
  Type: (x: unknown) => x is FieldConstraintType;
38
40
  Details: (x: unknown) => x is any;
41
+ Reason: (x: unknown) => x is string | undefined;
39
42
  }>[] | undefined;
40
43
  SyncSchema: (x: unknown) => x is string | undefined;
41
44
  Mapping: (x: unknown) => x is LucidFields[] | SemanticKind[] | undefined;
@@ -22,6 +22,7 @@ exports.isFieldConstraintType = (0, validators_1.enumValidator)(FieldConstraintT
22
22
  exports.isSerializedFieldConstraint = (0, validators_1.objectValidator)({
23
23
  'Type': (0, validators_1.enumValidator)(FieldConstraintType),
24
24
  'Details': (0, validators_1.option)(checks_1.isAny),
25
+ 'Reason': (0, validators_1.option)(checks_1.isString),
25
26
  });
26
27
  exports.isSerializedFieldDefinition = (0, validators_1.strictObjectValidator)({
27
28
  'Name': checks_1.isString,
@@ -105,8 +105,8 @@ export declare const isSerializedExtensionCardFieldDefinition: (subject: unknown
105
105
  Type: typeof isSerializedFieldTypeDefinition;
106
106
  Constraints: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
107
107
  Type: (x: unknown) => x is import("../data/serializedfield/serializedfielddefinition").FieldConstraintType;
108
- /** The label to display in the UI */
109
- Details: (x: unknown) => x is any;
108
+ Details: (x: unknown) => x is any; /** If defined, the default value for this field */
109
+ Reason: (x: unknown) => x is string | undefined;
110
110
  }>[] | undefined;
111
111
  l: typeof isString;
112
112
  d: (x: unknown) => x is string | undefined;
@@ -8,37 +8,45 @@ import { SerializedSchema } from '../core/data/serializedfield/serializedschema'
8
8
  export interface RequiredFieldConstraintDefinition {
9
9
  type: FieldConstraintType.REQUIRED;
10
10
  value?: undefined;
11
+ reason?: string | undefined;
11
12
  }
12
13
  export interface LockedFieldConstraintDefinition {
13
14
  type: FieldConstraintType.LOCKED;
14
15
  value?: undefined;
16
+ reason?: string | undefined;
15
17
  }
16
18
  export interface MinValueFieldConstraintDefinition {
17
19
  type: FieldConstraintType.MIN_VALUE;
18
20
  value: number;
21
+ reason?: string | undefined;
19
22
  }
20
23
  export interface MaxValueFieldConstraintDefinition {
21
24
  type: FieldConstraintType.MAX_VALUE;
22
25
  value: number;
26
+ reason?: string | undefined;
23
27
  }
24
28
  export interface SingleLineFieldConstraintDefinition {
25
29
  type: FieldConstraintType.SINGLE_LINE_ONLY;
26
30
  value?: undefined;
31
+ reason?: string | undefined;
27
32
  }
28
33
  export interface NoWhitespaceFieldConstraintDefinition {
29
34
  type: FieldConstraintType.NO_WHITESPACE;
30
35
  value?: undefined;
36
+ reason?: string | undefined;
31
37
  }
32
38
  export interface UniqueEditFieldConstraintDefinition {
33
39
  type: FieldConstraintType.UNIQUE_EDIT;
34
40
  value?: undefined;
41
+ reason?: string | undefined;
35
42
  }
36
43
  export interface MaxLengthConstraintDefinition {
37
44
  type: FieldConstraintType.MAX_LENGTH;
38
45
  value: number;
46
+ reason?: string | undefined;
39
47
  }
40
48
  export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition;
41
- export declare function createFieldConstraintDefinition(type: FieldConstraintType, value?: number): FieldConstraintDefinition;
49
+ export declare function createFieldConstraintDefinition(type: FieldConstraintType, value?: number, reason?: string): FieldConstraintDefinition;
42
50
  export declare function minMaxFieldConstraintValidator(val: unknown): val is FieldConstraintType.MIN_VALUE | FieldConstraintType.MAX_VALUE | FieldConstraintType.MAX_LENGTH;
43
51
  export declare const isFieldConstraintDefinition: (x: unknown) => x is {
44
52
  type?: FieldConstraintType | undefined;
@@ -6,25 +6,25 @@ const checks_1 = require("../core/checks");
6
6
  const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
7
7
  const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
8
8
  const validators_1 = require("../core/validators/validators");
9
- function createFieldConstraintDefinition(type, value) {
9
+ function createFieldConstraintDefinition(type, value, reason) {
10
10
  switch (type) {
11
11
  case serializedfielddefinition_1.FieldConstraintType.REQUIRED:
12
12
  case serializedfielddefinition_1.FieldConstraintType.LOCKED:
13
- return { type };
13
+ return Object.assign({ type }, (reason && { reason }));
14
14
  case serializedfielddefinition_1.FieldConstraintType.MIN_VALUE:
15
15
  case serializedfielddefinition_1.FieldConstraintType.MAX_VALUE:
16
16
  case serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH:
17
17
  if (value === undefined) {
18
18
  throw new Error('Invalid constraint value');
19
19
  }
20
- return { type, value };
20
+ return Object.assign({ type, value }, (reason && { reason }));
21
21
  case serializedfielddefinition_1.FieldConstraintType.SINGLE_LINE_ONLY:
22
22
  case serializedfielddefinition_1.FieldConstraintType.NO_WHITESPACE:
23
23
  case serializedfielddefinition_1.FieldConstraintType.UNIQUE_EDIT:
24
24
  if (value !== undefined) {
25
25
  throw new Error('Invalid constraint value');
26
26
  }
27
- return { type };
27
+ return Object.assign({ type }, (reason && { reason }));
28
28
  default:
29
29
  (0, assertnever_1.assertNever)(type);
30
30
  }
@@ -44,6 +44,7 @@ function serializeFieldConstraintDefinition(constraint) {
44
44
  return {
45
45
  'Type': constraint.type,
46
46
  'Details': constraint.value,
47
+ 'Reason': constraint.reason,
47
48
  };
48
49
  }
49
50
  exports.serializeFieldConstraintDefinition = serializeFieldConstraintDefinition;
@@ -78,6 +79,7 @@ function parseFieldDefinition(field) {
78
79
  name: field['Name'],
79
80
  type: (0, fieldtypedefinition_1.deserializeFieldTypeDefinition)(field['Type']),
80
81
  constraints: (_a = field['Constraints']) === null || _a === void 0 ? void 0 : _a.map((constraint) => {
82
+ var _a, _b;
81
83
  switch (constraint['Type']) {
82
84
  case serializedfielddefinition_1.FieldConstraintType.MIN_VALUE:
83
85
  case serializedfielddefinition_1.FieldConstraintType.MAX_VALUE:
@@ -85,13 +87,17 @@ function parseFieldDefinition(field) {
85
87
  if (!(0, checks_1.isNumber)(constraint['Details'])) {
86
88
  throw new Error('Invalid constraint format');
87
89
  }
88
- return { type: constraint['Type'], value: constraint['Details'] };
90
+ return {
91
+ type: constraint['Type'],
92
+ value: constraint['Details'],
93
+ reason: (_a = constraint['Reason']) !== null && _a !== void 0 ? _a : undefined,
94
+ };
89
95
  case serializedfielddefinition_1.FieldConstraintType.REQUIRED:
90
96
  case serializedfielddefinition_1.FieldConstraintType.LOCKED:
91
97
  case serializedfielddefinition_1.FieldConstraintType.SINGLE_LINE_ONLY:
92
98
  case serializedfielddefinition_1.FieldConstraintType.NO_WHITESPACE:
93
99
  case serializedfielddefinition_1.FieldConstraintType.UNIQUE_EDIT:
94
- return { type: constraint['Type'] };
100
+ return { type: constraint['Type'], reason: (_b = constraint['Reason']) !== null && _b !== void 0 ? _b : undefined };
95
101
  default:
96
102
  throw new Error('Invalid constraint format');
97
103
  }
@@ -35,6 +35,7 @@ export type DataSourceRequest = {
35
35
  export type SerializedFieldConstraintForApi = {
36
36
  'type': FieldConstraintType;
37
37
  'details'?: UnsafeJsonSerializableOrUndefined;
38
+ 'reason'?: string | undefined;
38
39
  };
39
40
  type SerializedFieldDefinitionForApi = {
40
41
  'name': string;
@@ -69,6 +69,7 @@ function serializeFieldConstraintForApi(constraint) {
69
69
  return {
70
70
  'type': constraint.type,
71
71
  'details': constraint.value,
72
+ 'reason': constraint.reason,
72
73
  };
73
74
  }
74
75
  /** @ignore */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.405",
3
+ "version": "0.0.406",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",