lucid-extension-sdk 0.0.210 → 0.0.213

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,7 +1,7 @@
1
+ import { ItemsPatch } from '../datasourceupdatetypes';
1
2
  export type PatchChangeCollection = {
2
3
  collectionId: string;
3
- items?: Record<string, object>;
4
- itemsDeleted?: string[];
4
+ itemsPatch: ItemsPatch;
5
5
  };
6
6
  /**
7
7
  * Reports a completed change back to Lucid
@@ -29,6 +29,8 @@ export type SerializedPatchChange = {
29
29
  'itemsPatch': {
30
30
  'items': Record<string, object>;
31
31
  'itemsDeleted': string[];
32
+ } | {
33
+ 'exhaustiveItems': Record<string, object>;
32
34
  };
33
35
  }[];
34
36
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serializePatchChanges = exports.serializePatchResponse = exports.PatchErrorTooltipField = exports.PatchChange = void 0;
4
4
  const object_1 = require("../../core/object");
5
+ const datasourceupdatetypes_1 = require("../datasourceupdatetypes");
5
6
  /**
6
7
  * Reports a completed change back to Lucid
7
8
  */
@@ -33,13 +34,9 @@ function serializePatchResponse(patchChange) {
33
34
  return {
34
35
  'syncId': patchChange.syncId,
35
36
  'collections': patchChange.collections.map((c) => {
36
- var _a, _b;
37
37
  return {
38
38
  'collectionId': c.collectionId,
39
- 'itemsPatch': {
40
- 'items': (_a = c.items) !== null && _a !== void 0 ? _a : {},
41
- 'itemsDeleted': (_b = c.itemsDeleted) !== null && _b !== void 0 ? _b : [],
42
- },
39
+ 'itemsPatch': (0, datasourceupdatetypes_1.serializeItemsPatch)(c.itemsPatch),
43
40
  };
44
41
  }),
45
42
  };
@@ -4,6 +4,7 @@ exports.MockDataSourceClient = exports.DataSourceClient = void 0;
4
4
  const checks_1 = require("../core/checks");
5
5
  const datasourcetype_1 = require("../core/data/datasource/datasourcetype");
6
6
  const upstreamconfig_1 = require("../core/data/datasource/upstreamconfig");
7
+ const upstreampatchtype_1 = require("../core/data/datasource/upstreampatchtype");
7
8
  const upstreamupdatetype_1 = require("../core/data/datasource/upstreamupdatetype");
8
9
  const result_1 = require("../core/result");
9
10
  const validators_1 = require("../core/validators/validators");
@@ -25,6 +26,7 @@ class DataSourceClient {
25
26
  this.metadataUrl = (0, checks_1.isString)(dataSyncUrl) ? `${dataSyncUrl}dataSource/metadata` : undefined;
26
27
  }
27
28
  formatBody({ dataSourceName, collections, dataSourceConfiguration }) {
29
+ var _a;
28
30
  const updateData = {};
29
31
  for (const collectionId in collections) {
30
32
  updateData[collectionId] = (0, datasourceupdatetypes_1.serializeCollectionPatch)(collections[collectionId]);
@@ -32,7 +34,7 @@ class DataSourceClient {
32
34
  const upstreamConfig = {
33
35
  dataSourceType: datasourcetype_1.DataSourceType.DataService,
34
36
  updateType: upstreamupdatetype_1.UpstreamUpdateType.EVENTPULL,
35
- patchType: dataSourceConfiguration === null || dataSourceConfiguration === void 0 ? void 0 : dataSourceConfiguration.patchType,
37
+ patchType: (_a = dataSourceConfiguration === null || dataSourceConfiguration === void 0 ? void 0 : dataSourceConfiguration.patchType) !== null && _a !== void 0 ? _a : upstreampatchtype_1.UpstreamPatchType.AUTO,
36
38
  sourceConfig: {},
37
39
  };
38
40
  return {
@@ -41,11 +41,45 @@ type SerializedSchemaForApi = {
41
41
  };
42
42
  export interface SerializedCollectionPatch {
43
43
  'schema'?: SerializedSchemaForApi;
44
- 'itemsPatch': {
45
- 'items': Record<string, SerializedFields>;
46
- 'itemsDeleted': string[];
47
- };
44
+ 'itemsPatch': SerializedItemsPatch;
45
+ }
46
+ export declare class ItemsPatchInexhaustive {
47
+ /**
48
+ * Items to be added or changed in the collection. Mapping from item serialized primary key to
49
+ * the sparse patch of the item. See FormattedPrimaryKey.forItem.
50
+ **/
51
+ items: Map<string, SerializedFields>;
52
+ /** Items to remove from the collection, based on the same primary key algorithm. */
53
+ itemsDeleted?: string[] | undefined;
54
+ constructor(
55
+ /**
56
+ * Items to be added or changed in the collection. Mapping from item serialized primary key to
57
+ * the sparse patch of the item. See FormattedPrimaryKey.forItem.
58
+ **/
59
+ items: Map<string, SerializedFields>,
60
+ /** Items to remove from the collection, based on the same primary key algorithm. */
61
+ itemsDeleted?: string[] | undefined);
48
62
  }
63
+ export declare class ItemsPatchExhaustive {
64
+ items: Map<string, SerializedFields>;
65
+ constructor(items: Map<string, SerializedFields>);
66
+ }
67
+ export type ItemsPatch = {
68
+ /**
69
+ * Items to be added or changed in the collection. Mapping from item serialized primary key to
70
+ * the sparse patch of the item. See FormattedPrimaryKey.forItem.
71
+ **/
72
+ items: Map<string, SerializedFields>;
73
+ /** Items to remove from the collection, based on the same primary key algorithm. */
74
+ itemsDeleted?: string[];
75
+ } | ItemsPatchInexhaustive | ItemsPatchExhaustive;
76
+ export type SerializedItemsPatch = {
77
+ 'items': Record<string, SerializedFields>;
78
+ 'itemsDeleted': string[];
79
+ } | {
80
+ 'exhaustiveItems': Record<string, SerializedFields>;
81
+ };
82
+ export declare function serializeItemsPatch(patch: ItemsPatch): SerializedItemsPatch;
49
83
  /**
50
84
  * A patch to a collection or the definition of a new collection to be added. If adding a new collection, a schema must
51
85
  * be provided. If modifying an existing collection, a schema may be omitted.
@@ -63,15 +97,7 @@ export interface CollectionPatch {
63
97
  */
64
98
  schema?: SchemaDefinition;
65
99
  /** The patch to apply to the collection */
66
- patch: {
67
- /**
68
- * Items to be added or changed in the collection. Mapping from item serialized primary key to
69
- * the sparse patch of the item. See FormattedPrimaryKey.forItem.
70
- **/
71
- items: Map<string, SerializedFields>;
72
- /** Items to remove from the collection, based on the same primary key algorithm. */
73
- itemsDeleted?: string[];
74
- };
100
+ patch: ItemsPatch;
75
101
  }
76
102
  /** @ignore */
77
103
  export declare function serializeFieldDefinitionForApi(field: FieldDefinition): SerializedFieldDefinitionForApi;
@@ -1,8 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeCollectionPatch = exports.serializeFieldDefinitionForApi = void 0;
3
+ exports.serializeCollectionPatch = exports.serializeFieldDefinitionForApi = exports.serializeItemsPatch = exports.ItemsPatchExhaustive = exports.ItemsPatchInexhaustive = void 0;
4
4
  const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
5
5
  const object_1 = require("../core/object");
6
+ class ItemsPatchInexhaustive {
7
+ constructor(
8
+ /**
9
+ * Items to be added or changed in the collection. Mapping from item serialized primary key to
10
+ * the sparse patch of the item. See FormattedPrimaryKey.forItem.
11
+ **/
12
+ items,
13
+ /** Items to remove from the collection, based on the same primary key algorithm. */
14
+ itemsDeleted) {
15
+ this.items = items;
16
+ this.itemsDeleted = itemsDeleted;
17
+ }
18
+ }
19
+ exports.ItemsPatchInexhaustive = ItemsPatchInexhaustive;
20
+ class ItemsPatchExhaustive {
21
+ constructor(items) {
22
+ this.items = items;
23
+ }
24
+ }
25
+ exports.ItemsPatchExhaustive = ItemsPatchExhaustive;
26
+ function serializeItemsPatch(patch) {
27
+ var _a;
28
+ if (patch instanceof ItemsPatchExhaustive) {
29
+ return { 'exhaustiveItems': (0, object_1.fromEntries)(patch.items.entries()) };
30
+ }
31
+ else {
32
+ return {
33
+ 'items': (0, object_1.fromEntries)(patch.items.entries()),
34
+ 'itemsDeleted': (_a = patch.itemsDeleted) !== null && _a !== void 0 ? _a : [],
35
+ };
36
+ }
37
+ }
38
+ exports.serializeItemsPatch = serializeItemsPatch;
6
39
  function serializeFieldConstraintForApi(constraint) {
7
40
  return {
8
41
  'type': constraint.type,
@@ -28,13 +61,9 @@ function serializeSchemaForApi(schema) {
28
61
  };
29
62
  }
30
63
  function serializeCollectionPatch(patch) {
31
- var _a;
32
64
  return {
33
65
  'schema': patch.schema && serializeSchemaForApi(patch.schema),
34
- 'itemsPatch': {
35
- 'items': (0, object_1.fromEntries)(patch.patch.items.entries()),
36
- 'itemsDeleted': (_a = patch.patch.itemsDeleted) !== null && _a !== void 0 ? _a : [],
37
- },
66
+ 'itemsPatch': serializeItemsPatch(patch.patch),
38
67
  };
39
68
  }
40
69
  exports.serializeCollectionPatch = serializeCollectionPatch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.210",
3
+ "version": "0.0.213",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",