lucid-extension-sdk 0.0.220 → 0.0.223

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,3 +1,4 @@
1
+ import { DataUpdateFilterType } from '../../../data/dataupdatefiltertype';
1
2
  import { SerializedFields } from '../serializedfield/serializedfields';
2
3
  import { DataSourceType } from './datasourcetype';
3
4
  import { SerializedImportedCollection } from './serializedimporteddatasource';
@@ -28,6 +29,7 @@ export declare function makeSerializedImportedDataSource(id: string, name: strin
28
29
  UpdateType: UpstreamUpdateType;
29
30
  SourceConfig: {
30
31
  spreadsheetId: string;
32
+ UpdateFilterType: DataUpdateFilterType;
31
33
  };
32
34
  };
33
35
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeSerializedImportedDataSource = exports.makeSerializedImportedCollection = exports.MetadataPK = exports.makeNameReadablyUnique = exports.normalizeName = exports.alphabetize = void 0;
4
+ const dataupdatefiltertype_1 = require("../../../data/dataupdatefiltertype");
4
5
  const checks_1 = require("../../checks");
5
6
  const scalarfieldtype_1 = require("../fieldtypedefinition/scalarfieldtype");
6
7
  const alphabet_1 = require("./alphabet");
@@ -223,7 +224,10 @@ function makeSerializedImportedDataSource(id, name, collections) {
223
224
  'UpstreamConfig': {
224
225
  'SourceType': datasourcetype_1.DataSourceType.DataService,
225
226
  'UpdateType': upstreamupdatetype_1.UpstreamUpdateType.EVENTPULL,
226
- 'SourceConfig': { 'spreadsheetId': id },
227
+ 'SourceConfig': {
228
+ 'spreadsheetId': id,
229
+ 'UpdateFilterType': dataupdatefiltertype_1.DataUpdateFilterType.CurrentCollectionUpdates,
230
+ },
227
231
  },
228
232
  },
229
233
  'Collections': collections,
@@ -87,6 +87,10 @@ export declare const isSerializedLucidCurrency: (subject: unknown) => subject is
87
87
  a: typeof isNumber;
88
88
  t: typeof isString;
89
89
  }>;
90
+ export declare const isSerializedMillisecondsDateObject: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
91
+ ms: typeof isNumber;
92
+ isDateOnly: (x: unknown) => x is boolean | undefined;
93
+ }>;
90
94
  export declare const isSerializedLucidDateObject: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
91
95
  ms: typeof isNumber;
92
96
  isDateOnly: (x: unknown) => x is boolean | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSerializedFields = exports.isSerializedJsonFieldType = exports.isSerializedFieldType = exports.isSerializedLucidDateObject = exports.isSerializedLucidCurrency = exports.isSerializedLucidDictionary = exports.isJsonSerializedLucidDictionary = exports.isNestedSerializedLucidDictionary = exports.isSerializedColorObjectFieldType = void 0;
3
+ exports.isSerializedFields = exports.isSerializedJsonFieldType = exports.isSerializedFieldType = exports.isSerializedLucidDateObject = exports.isSerializedMillisecondsDateObject = exports.isSerializedLucidCurrency = exports.isSerializedLucidDictionary = exports.isJsonSerializedLucidDictionary = exports.isNestedSerializedLucidDictionary = exports.isSerializedColorObjectFieldType = void 0;
4
4
  const checks_1 = require("../../checks");
5
5
  const validators_1 = require("../../validators/validators");
6
6
  function isSerializedColorObjectFieldType(value) {
@@ -20,7 +20,7 @@ exports.isSerializedLucidCurrency = (0, validators_1.objectValidator)({
20
20
  'a': checks_1.isNumber,
21
21
  't': checks_1.isString,
22
22
  });
23
- const isSerializedMillisecondsDateObject = (0, validators_1.objectValidator)({
23
+ exports.isSerializedMillisecondsDateObject = (0, validators_1.objectValidator)({
24
24
  'ms': checks_1.isNumber,
25
25
  'isDateOnly': (0, validators_1.option)(checks_1.isBoolean),
26
26
  });
@@ -28,7 +28,7 @@ const isSerializedIsoDateObject = (0, validators_1.objectValidator)({
28
28
  'isoDate': checks_1.isString,
29
29
  'displayTimezone': (0, validators_1.option)(checks_1.isString),
30
30
  });
31
- exports.isSerializedLucidDateObject = (0, validators_1.either)(isSerializedMillisecondsDateObject, isSerializedIsoDateObject);
31
+ exports.isSerializedLucidDateObject = (0, validators_1.either)(exports.isSerializedMillisecondsDateObject, isSerializedIsoDateObject);
32
32
  function isSerializedFieldType(value) {
33
33
  return (value == null ||
34
34
  (0, checks_1.isNumber)(value) ||
@@ -1,8 +1,8 @@
1
1
  /** Allows Lucid documents to determine what updates they will receive when changes happen in the data source */
2
2
  export declare enum DataUpdateFilterType {
3
- /** All updates relevant to the data source will be sent to the document, new items created in the data source will be added to the document */
3
+ /** All updates relevant to the data source will be sent to the document, new items created in the data source will be added to the document. Note that the in the `documentCollections` mapping in the `DataConnectorActionContext` will not have a list of all items in it with the DataUpdateFilterType selected */
4
4
  'AllUpdates' = "AllUpdates",
5
- /** All updates relevant to collections already present on the document will be sent to that document, new items added to those collections in the data source will be added to the document */
5
+ /** All updates relevant to collections already present on the document will be sent to that document, new items added to those collections in the data source will be added to the document. Note that the `documentCollections` mapping in the `DataConnectorActionContext` will not have a list of all items in it with the DataUpdateFilterType selected */
6
6
  'CurrentCollectionUpdates' = "CurrentCollectionUpdates",
7
7
  /** All updates to items already present on the document will be sent to the document. New items created in the data source will not be created on the document. */
8
8
  'CurrentItemUpdates' = "CurrentItemUpdates"
@@ -4,9 +4,9 @@ exports.DataUpdateFilterType = void 0;
4
4
  /** Allows Lucid documents to determine what updates they will receive when changes happen in the data source */
5
5
  var DataUpdateFilterType;
6
6
  (function (DataUpdateFilterType) {
7
- /** All updates relevant to the data source will be sent to the document, new items created in the data source will be added to the document */
7
+ /** All updates relevant to the data source will be sent to the document, new items created in the data source will be added to the document. Note that the in the `documentCollections` mapping in the `DataConnectorActionContext` will not have a list of all items in it with the DataUpdateFilterType selected */
8
8
  DataUpdateFilterType["AllUpdates"] = "AllUpdates";
9
- /** All updates relevant to collections already present on the document will be sent to that document, new items added to those collections in the data source will be added to the document */
9
+ /** All updates relevant to collections already present on the document will be sent to that document, new items added to those collections in the data source will be added to the document. Note that the `documentCollections` mapping in the `DataConnectorActionContext` will not have a list of all items in it with the DataUpdateFilterType selected */
10
10
  DataUpdateFilterType["CurrentCollectionUpdates"] = "CurrentCollectionUpdates";
11
11
  /** All updates to items already present on the document will be sent to the document. New items created in the data source will not be created on the document. */
12
12
  DataUpdateFilterType["CurrentItemUpdates"] = "CurrentItemUpdates";
@@ -78,6 +78,8 @@ export declare class Patch {
78
78
  itemsChanged: PatchItems;
79
79
  /** List of item primary keys deleted by Lucid */
80
80
  itemsDeleted: string[];
81
+ /** */
82
+ itemOrderChanged: [string, string | null][] | undefined;
81
83
  /** The syncSourceId of the changed data source */
82
84
  syncSourceId: string;
83
85
  /** The syncCollectionId of the changed collection */
@@ -91,6 +93,8 @@ export declare class Patch {
91
93
  itemsChanged: PatchItems,
92
94
  /** List of item primary keys deleted by Lucid */
93
95
  itemsDeleted: string[],
96
+ /** */
97
+ itemOrderChanged: [string, string | null][] | undefined,
94
98
  /** The syncSourceId of the changed data source */
95
99
  syncSourceId: string,
96
100
  /** The syncCollectionId of the changed collection */
@@ -73,6 +73,8 @@ class Patch {
73
73
  itemsChanged,
74
74
  /** List of item primary keys deleted by Lucid */
75
75
  itemsDeleted,
76
+ /** */
77
+ itemOrderChanged,
76
78
  /** The syncSourceId of the changed data source */
77
79
  syncSourceId,
78
80
  /** The syncCollectionId of the changed collection */
@@ -81,6 +83,7 @@ class Patch {
81
83
  this.itemsAdded = itemsAdded;
82
84
  this.itemsChanged = itemsChanged;
83
85
  this.itemsDeleted = itemsDeleted;
86
+ this.itemOrderChanged = itemOrderChanged;
84
87
  this.syncSourceId = syncSourceId;
85
88
  this.syncCollectionId = syncCollectionId;
86
89
  }
@@ -6,47 +6,52 @@ const checks_1 = require("../../core/checks");
6
6
  const validators_1 = require("../../core/validators/validators");
7
7
  const action_1 = require("./action");
8
8
  const dataconnectoractionkeys_1 = require("./dataconnectoractionkeys");
9
- exports.actionsHeaderValidator = (0, validators_1.objectValidator)({ 'x-lucid-rsa-nonce': checks_1.isString, 'x-lucid-signature': checks_1.isString });
9
+ exports.actionsHeaderValidator = (0, validators_1.objectValidator)({
10
+ 'x-lucid-rsa-nonce': checks_1.isString,
11
+ 'x-lucid-signature': checks_1.isString,
12
+ });
10
13
  const serializedActionsBaseValidator = (0, validators_1.objectValidator)({
11
- 'action': (0, validators_1.objectValidator)({ 'name': checks_1.isString, 'data': checks_1.isUnknown }),
12
- 'packageId': checks_1.isString,
13
- 'packageVersion': (0, validators_1.nullableOption)(checks_1.isString),
14
- 'dataConnectorName': checks_1.isString,
15
- 'installationId': (0, validators_1.nullableOption)(checks_1.isString),
16
- 'userCredential': (0, validators_1.nullableOption)(checks_1.isString),
17
- 'documentUpdateToken': (0, validators_1.nullableOption)(checks_1.isString),
18
- 'documentCollections': (0, validators_1.objectOfValidator)((0, validators_1.arrayValidator)(checks_1.isString)),
19
- 'updateFilterType': (0, validators_1.enumValidator)(dataupdatefiltertype_1.DataUpdateFilterType),
14
+ action: (0, validators_1.objectValidator)({ name: checks_1.isString, data: checks_1.isUnknown }),
15
+ packageId: checks_1.isString,
16
+ packageVersion: (0, validators_1.nullableOption)(checks_1.isString),
17
+ dataConnectorName: checks_1.isString,
18
+ installationId: (0, validators_1.nullableOption)(checks_1.isString),
19
+ userCredential: (0, validators_1.nullableOption)(checks_1.isString),
20
+ documentUpdateToken: (0, validators_1.nullableOption)(checks_1.isString),
21
+ documentCollections: (0, validators_1.objectOfValidator)((0, validators_1.arrayValidator)(checks_1.isString)),
22
+ updateFilterType: (0, validators_1.enumValidator)(dataupdatefiltertype_1.DataUpdateFilterType),
20
23
  });
21
24
  const serializedPatchDataValidator = (0, validators_1.objectValidator)({
22
- 'packageVersion': checks_1.isString,
23
- 'patches': (0, validators_1.arrayValidator)((0, validators_1.objectValidator)({
24
- 'patch': (0, validators_1.objectValidator)({
25
- 'itemsAdded': (0, validators_1.objectOfValidator)(checks_1.isObjectUnsafe),
26
- 'itemsChanged': (0, validators_1.objectOfValidator)(checks_1.isObjectUnsafe),
27
- 'itemsDeleted': (0, validators_1.arrayValidator)(checks_1.isString),
28
- 'syncSourceId': checks_1.isString,
29
- 'syncCollectionId': checks_1.isString,
30
- 'adapterType': (0, checks_1.isLiteral)('EXTENSION_API'),
31
- 'syncSchema': checks_1.isUnknown,
25
+ packageVersion: checks_1.isString,
26
+ patches: (0, validators_1.arrayValidator)((0, validators_1.objectValidator)({
27
+ patch: (0, validators_1.objectValidator)({
28
+ itemsAdded: (0, validators_1.objectOfValidator)(checks_1.isObjectUnsafe),
29
+ itemsChanged: (0, validators_1.objectOfValidator)(checks_1.isObjectUnsafe),
30
+ itemsDeleted: (0, validators_1.arrayValidator)(checks_1.isString),
31
+ itemOrderChanged: (0, validators_1.nullableOption)((0, validators_1.arrayValidator)((0, validators_1.tupleValidator)(checks_1.isString, (0, validators_1.nullable)(checks_1.isString)))),
32
+ syncSourceId: checks_1.isString,
33
+ syncCollectionId: checks_1.isString,
34
+ adapterType: (0, checks_1.isLiteral)('EXTENSION_API'),
35
+ syncSchema: checks_1.isUnknown,
32
36
  }),
33
- 'id': checks_1.isString,
37
+ id: checks_1.isString,
34
38
  })),
35
- 'userCredential': checks_1.isString,
36
- 'documentUpdateToken': checks_1.isString,
39
+ userCredential: checks_1.isString,
40
+ documentUpdateToken: checks_1.isString,
37
41
  });
38
42
  const parseSerializedPatches = (patches) => {
39
43
  return patches.map((patch) => {
44
+ var _a;
40
45
  const p = patch['patch'];
41
- return new action_1.Patch(patch['id'], p['itemsAdded'], p['itemsChanged'], p['itemsDeleted'], p['syncSourceId'], p['syncCollectionId']);
46
+ return new action_1.Patch(patch['id'], p['itemsAdded'], p['itemsChanged'], p['itemsDeleted'], (_a = p['itemOrderChanged']) !== null && _a !== void 0 ? _a : undefined, p['syncSourceId'], p['syncCollectionId']);
42
47
  });
43
48
  };
44
49
  const serializedManageWebhookDataValidator = (0, validators_1.objectValidator)({
45
- 'webhooks': (0, validators_1.arrayValidator)((0, validators_1.objectValidator)({
46
- 'documentCollections': (0, validators_1.objectOfValidator)((0, validators_1.arrayValidator)(checks_1.isString)),
47
- 'webhookData': (0, validators_1.option)(checks_1.isUnknown),
50
+ webhooks: (0, validators_1.arrayValidator)((0, validators_1.objectValidator)({
51
+ documentCollections: (0, validators_1.objectOfValidator)((0, validators_1.arrayValidator)(checks_1.isString)),
52
+ webhookData: (0, validators_1.option)(checks_1.isUnknown),
48
53
  })),
49
- 'webhookToken': checks_1.isString,
54
+ webhookToken: checks_1.isString,
50
55
  });
51
56
  /** Function to convert the lucid action wire format into a clean list of actions */
52
57
  function deserializeActions(client, actions) {
@@ -57,6 +62,7 @@ function deserializeActions(client, actions) {
57
62
  const data = actions['action']['data'];
58
63
  if (name === dataconnectoractionkeys_1.DataConnectorActionKeys.Patch) {
59
64
  if (!(0, validators_1.arrayValidator)(serializedPatchDataValidator)(data)) {
65
+ console.log(`Failing validation step`);
60
66
  return;
61
67
  }
62
68
  return data.map((item) => {
@@ -25,17 +25,18 @@ class DataSourceClient {
25
25
  const dataSyncUrl = urls.dataSync;
26
26
  this.metadataUrl = (0, checks_1.isString)(dataSyncUrl) ? `${dataSyncUrl}dataSource/metadata` : undefined;
27
27
  }
28
- formatBody({ dataSourceName, collections, dataSourceConfiguration }) {
28
+ formatBody({ dataSourceName, collections, updateFilterType, dataSourceConfiguration }) {
29
29
  var _a;
30
30
  const updateData = {};
31
31
  for (const collectionId in collections) {
32
32
  updateData[collectionId] = (0, datasourceupdatetypes_1.serializeCollectionPatch)(collections[collectionId]);
33
33
  }
34
+ const updateFilterTypeObj = updateFilterType ? { 'UpdateFilterType': updateFilterType } : {};
34
35
  const upstreamConfig = {
35
36
  dataSourceType: datasourcetype_1.DataSourceType.DataService,
36
37
  updateType: upstreamupdatetype_1.UpstreamUpdateType.EVENTPULL,
37
38
  patchType: (_a = dataSourceConfiguration === null || dataSourceConfiguration === void 0 ? void 0 : dataSourceConfiguration.patchType) !== null && _a !== void 0 ? _a : upstreampatchtype_1.UpstreamPatchType.AUTO,
38
- sourceConfig: {},
39
+ sourceConfig: Object.assign({}, updateFilterTypeObj),
39
40
  };
40
41
  return {
41
42
  'updateData': updateData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.220",
3
+ "version": "0.0.223",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",