lucid-extension-sdk 0.0.375 → 0.0.376

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.
@@ -11,7 +11,7 @@ import { SerializedFields, SerializedLucidDictionary } from '../core/data/serial
11
11
  import { SerializedLabelOverrides } from '../core/data/serializedfield/serializedschema';
12
12
  import { JsonSerializable } from '../core/jsonserializable';
13
13
  import { DataUpdateFilterType } from '../data/dataupdatefiltertype';
14
- import { FieldDefinition, SchemaDefinition } from '../data/schemadefinition';
14
+ import { FieldConstraintDefinition, FieldDefinition, SchemaDefinition } from '../data/schemadefinition';
15
15
  /**
16
16
  * Container for an update to a data source
17
17
  */
@@ -32,7 +32,7 @@ export type DataSourceRequest = {
32
32
  /** The level of permission the request has to create data */
33
33
  creationPermission?: UpdateCreationPermission;
34
34
  };
35
- type SerializedFieldConstraintForApi = {
35
+ export type SerializedFieldConstraintForApi = {
36
36
  'type': FieldConstraintType;
37
37
  'details'?: JsonSerializable;
38
38
  };
@@ -66,6 +66,7 @@ export declare class ItemsPatchInexhaustive {
66
66
  /** Items to remove from the collection, based on the same primary key algorithm. */
67
67
  itemsDeleted?: string[] | undefined;
68
68
  errors?: Map<string, SerializedLucidDictionary> | undefined;
69
+ fieldConstraintsPerItem?: Map<string, Map<string, FieldConstraintDefinition[]>> | undefined;
69
70
  private readonly _brand;
70
71
  constructor(
71
72
  /**
@@ -74,15 +75,16 @@ export declare class ItemsPatchInexhaustive {
74
75
  **/
75
76
  items: Map<string, SerializedFields>,
76
77
  /** Items to remove from the collection, based on the same primary key algorithm. */
77
- itemsDeleted?: string[] | undefined, errors?: Map<string, SerializedLucidDictionary> | undefined);
78
+ itemsDeleted?: string[] | undefined, errors?: Map<string, SerializedLucidDictionary> | undefined, fieldConstraintsPerItem?: Map<string, Map<string, FieldConstraintDefinition[]>> | undefined);
78
79
  }
79
80
  export declare class ItemsPatchExhaustive {
80
81
  items: Map<string, SerializedFields>;
81
82
  rekeyingMap?: Map<string, string | null> | undefined;
82
83
  fieldNamesChanged?: Map<string, string | null> | undefined;
83
84
  errors?: Map<string, SerializedLucidDictionary> | undefined;
85
+ fieldConstraintsPerItem?: Map<string, Map<string, FieldConstraintDefinition[]>> | undefined;
84
86
  private readonly _brand;
85
- constructor(items: Map<string, SerializedFields>, rekeyingMap?: Map<string, string | null> | undefined, fieldNamesChanged?: Map<string, string | null> | undefined, errors?: Map<string, SerializedLucidDictionary> | undefined);
87
+ constructor(items: Map<string, SerializedFields>, rekeyingMap?: Map<string, string | null> | undefined, fieldNamesChanged?: Map<string, string | null> | undefined, errors?: Map<string, SerializedLucidDictionary> | undefined, fieldConstraintsPerItem?: Map<string, Map<string, FieldConstraintDefinition[]>> | undefined);
86
88
  }
87
89
  export type ItemsPatch = {
88
90
  /**
@@ -94,16 +96,23 @@ export type ItemsPatch = {
94
96
  itemsDeleted?: string[];
95
97
  /** Errors found while patching the items */
96
98
  errors?: Map<string, SerializedLucidDictionary>;
99
+ /**
100
+ *Constraints that can be defined on a per-item basis to conditionally lock fields for a specific item.
101
+ *The key for this map is the primary key of an item, and the value is a map from the name a field on that item to the constraints that should be applied to that field.
102
+ */
103
+ fieldConstraintsPerItem?: Map<string, Map<string, FieldConstraintDefinition[]>>;
97
104
  } | ItemsPatchInexhaustive | ItemsPatchExhaustive;
98
105
  export type SerializedItemsPatch = {
99
106
  'items': Record<string, SerializedFields>;
100
107
  'itemsDeleted': string[];
101
108
  'errors'?: Record<string, SerializedLucidDictionary>;
109
+ 'fieldConstraintsPerItem'?: Record<string, Record<string, SerializedFieldConstraintForApi[]>>;
102
110
  } | {
103
111
  'exhaustiveItems': Record<string, SerializedFields>;
104
112
  'rekeyingMap'?: Record<string, string | null>;
105
113
  'fieldNamesChanged'?: Record<string, string | null>;
106
114
  'errors'?: Record<string, SerializedLucidDictionary>;
115
+ 'fieldConstraintsPerItem'?: Record<string, Record<string, SerializedFieldConstraintForApi[]>>;
107
116
  };
108
117
  export declare function serializeItemsPatch(patch: ItemsPatch): SerializedItemsPatch;
109
118
  /**
@@ -13,40 +13,55 @@ class ItemsPatchInexhaustive {
13
13
  **/
14
14
  items,
15
15
  /** Items to remove from the collection, based on the same primary key algorithm. */
16
- itemsDeleted, errors) {
16
+ itemsDeleted, errors, fieldConstraintsPerItem) {
17
17
  this.items = items;
18
18
  this.itemsDeleted = itemsDeleted;
19
19
  this.errors = errors;
20
+ this.fieldConstraintsPerItem = fieldConstraintsPerItem;
20
21
  this._brand = ItemsPatchInexhaustive;
21
22
  }
22
23
  }
23
24
  exports.ItemsPatchInexhaustive = ItemsPatchInexhaustive;
24
25
  class ItemsPatchExhaustive {
25
- constructor(items, rekeyingMap, fieldNamesChanged, errors) {
26
+ constructor(items, rekeyingMap, fieldNamesChanged, errors, fieldConstraintsPerItem) {
26
27
  this.items = items;
27
28
  this.rekeyingMap = rekeyingMap;
28
29
  this.fieldNamesChanged = fieldNamesChanged;
29
30
  this.errors = errors;
31
+ this.fieldConstraintsPerItem = fieldConstraintsPerItem;
30
32
  this._brand = ItemsPatchExhaustive;
31
33
  }
32
34
  }
33
35
  exports.ItemsPatchExhaustive = ItemsPatchExhaustive;
34
- function serializeErrors(errors) {
35
- return errors && { 'errors': (0, object_1.fromEntries)(errors) };
36
- }
37
36
  function serializeRekeyingMap(rekeyingMap) {
38
37
  return rekeyingMap && { 'rekeyingMap': (0, object_1.fromEntries)(rekeyingMap) };
39
38
  }
40
39
  function serializeFieldNamesChanged(fieldNamesChanged) {
41
40
  return fieldNamesChanged && { 'fieldNamesChanged': (0, object_1.fromEntries)(fieldNamesChanged) };
42
41
  }
42
+ function serializeErrors(errors) {
43
+ return errors && { 'errors': (0, object_1.fromEntries)(errors) };
44
+ }
45
+ function serializeFieldConstraintsPerItem(fieldConstraintsPerItem) {
46
+ if (!fieldConstraintsPerItem) {
47
+ return undefined;
48
+ }
49
+ const result = {};
50
+ fieldConstraintsPerItem.forEach((fieldNameToConstraints, key) => {
51
+ result[key] = {};
52
+ fieldNameToConstraints.forEach((constraints, fieldName) => {
53
+ result[key][fieldName] = constraints.map(serializeFieldConstraintForApi);
54
+ });
55
+ });
56
+ return { fieldConstraintsPerItem: result };
57
+ }
43
58
  function serializeItemsPatch(patch) {
44
59
  var _a;
45
60
  if (patch instanceof ItemsPatchExhaustive) {
46
- return Object.assign(Object.assign(Object.assign({ 'exhaustiveItems': (0, object_1.fromEntries)(patch.items.entries()) }, serializeRekeyingMap(patch.rekeyingMap)), serializeFieldNamesChanged(patch.fieldNamesChanged)), serializeErrors(patch.errors));
61
+ return Object.assign(Object.assign(Object.assign(Object.assign({ 'exhaustiveItems': (0, object_1.fromEntries)(patch.items.entries()) }, serializeRekeyingMap(patch.rekeyingMap)), serializeFieldNamesChanged(patch.fieldNamesChanged)), serializeErrors(patch.errors)), serializeFieldConstraintsPerItem(patch.fieldConstraintsPerItem));
47
62
  }
48
63
  else {
49
- return Object.assign({ 'items': (0, object_1.fromEntries)(patch.items.entries()), 'itemsDeleted': (_a = patch.itemsDeleted) !== null && _a !== void 0 ? _a : [] }, serializeErrors(patch.errors));
64
+ return Object.assign(Object.assign({ 'items': (0, object_1.fromEntries)(patch.items.entries()), 'itemsDeleted': (_a = patch.itemsDeleted) !== null && _a !== void 0 ? _a : [] }, serializeErrors(patch.errors)), serializeFieldConstraintsPerItem(patch.fieldConstraintsPerItem));
50
65
  }
51
66
  }
52
67
  exports.serializeItemsPatch = serializeItemsPatch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.375",
3
+ "version": "0.0.376",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",