lucid-extension-sdk 0.0.227 → 0.0.228

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.
@@ -0,0 +1 @@
1
+ export declare const CollectionUpstreamSchemaStatus = "__CollectionUpstreamSchemaStatus__";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CollectionUpstreamSchemaStatus = void 0;
4
+ exports.CollectionUpstreamSchemaStatus = '__CollectionUpstreamSchemaStatus__';
@@ -2,7 +2,7 @@ import { UpstreamPatchType } from '../core/data/datasource/upstreampatchtype';
2
2
  import { SerializedFieldTypeDefinition } from '../core/data/fieldtypedefinition/fieldtypedefinition';
3
3
  import { SemanticKind } from '../core/data/fieldtypedefinition/semantickind';
4
4
  import { FieldConstraintType } from '../core/data/serializedfield/serializedfielddefinition';
5
- import { SerializedFields } from '../core/data/serializedfield/serializedfields';
5
+ import { SerializedFields, SerializedLucidDictionary } from '../core/data/serializedfield/serializedfields';
6
6
  import { SerializedLabelOverrides } from '../core/data/serializedfield/serializedschema';
7
7
  import { JsonSerializable } from '../core/jsonserializable';
8
8
  import { DataUpdateFilterType } from '../data/dataupdatefiltertype';
@@ -51,6 +51,7 @@ export declare class ItemsPatchInexhaustive {
51
51
  items: Map<string, SerializedFields>;
52
52
  /** Items to remove from the collection, based on the same primary key algorithm. */
53
53
  itemsDeleted?: string[] | undefined;
54
+ errors?: Map<string, SerializedLucidDictionary> | undefined;
54
55
  constructor(
55
56
  /**
56
57
  * Items to be added or changed in the collection. Mapping from item serialized primary key to
@@ -58,11 +59,12 @@ export declare class ItemsPatchInexhaustive {
58
59
  **/
59
60
  items: Map<string, SerializedFields>,
60
61
  /** Items to remove from the collection, based on the same primary key algorithm. */
61
- itemsDeleted?: string[] | undefined);
62
+ itemsDeleted?: string[] | undefined, errors?: Map<string, SerializedLucidDictionary> | undefined);
62
63
  }
63
64
  export declare class ItemsPatchExhaustive {
64
65
  items: Map<string, SerializedFields>;
65
- constructor(items: Map<string, SerializedFields>);
66
+ errors?: Map<string, SerializedLucidDictionary> | undefined;
67
+ constructor(items: Map<string, SerializedFields>, errors?: Map<string, SerializedLucidDictionary> | undefined);
66
68
  }
67
69
  export type ItemsPatch = {
68
70
  /**
@@ -72,12 +74,16 @@ export type ItemsPatch = {
72
74
  items: Map<string, SerializedFields>;
73
75
  /** Items to remove from the collection, based on the same primary key algorithm. */
74
76
  itemsDeleted?: string[];
77
+ /** Errors found while patching the items */
78
+ errors?: Map<string, SerializedLucidDictionary>;
75
79
  } | ItemsPatchInexhaustive | ItemsPatchExhaustive;
76
80
  export type SerializedItemsPatch = {
77
81
  'items': Record<string, SerializedFields>;
78
82
  'itemsDeleted': string[];
83
+ 'errors'?: Record<string, SerializedLucidDictionary>;
79
84
  } | {
80
85
  'exhaustiveItems': Record<string, SerializedFields>;
86
+ 'errors'?: Record<string, SerializedLucidDictionary>;
81
87
  };
82
88
  export declare function serializeItemsPatch(patch: ItemsPatch): SerializedItemsPatch;
83
89
  /**
@@ -102,4 +108,28 @@ export interface CollectionPatch {
102
108
  /** @ignore */
103
109
  export declare function serializeFieldDefinitionForApi(field: FieldDefinition): SerializedFieldDefinitionForApi;
104
110
  export declare function serializeCollectionPatch(patch: CollectionPatch): SerializedCollectionPatch;
111
+ /**
112
+ * For the moment, when the upstream Google Sheet is changed in such a way that the schema has changed, we simply
113
+ * stop updates from happening. We do need to alert the user that this has happened, though. This is a utility function
114
+ * for creating the appropriate entry in the errors map so that the user can be alerted that updates have stopped
115
+ * and what they need to do to fix it.
116
+ *
117
+ * The eventual, proposed fix is to allow schemas to have version numbers so that changes to the schema from Google
118
+ * can simply be folded in to the on-document copies of the data and all following edits.
119
+ *
120
+ * @param oldPrimaryKey The primary key stored in the data sync service and which currently is used to interpret
121
+ * patches.
122
+ * @param newPrimaryKey The primary key as it has been changed in the real Google Sheets.
123
+ * @returns The error map entry which alerts the document that this problem has happened.
124
+ */
125
+ export declare function schemaOutOfSyncStatus(oldPrimaryKey: string[], newPrimaryKey: string[]): [string, SerializedLucidDictionary];
126
+ /**
127
+ * For the moment, when the upstream Google Sheet is changed in such a way that the schema has changed, we simply
128
+ * stop updates from happening. We do need to alert the user that this has happened, though. We also need to know when
129
+ * the updates are happening properly so we can clear the error once the user has resolved the problem. Since the
130
+ * only way to delete errors is to overwrite them, we simply overwrite the error to be OK on every successful
131
+ * import.
132
+ * @returns The error map entry which alerts the document that this problem has been resolved.
133
+ */
134
+ export declare function schemaOKStatus(): [string, SerializedLucidDictionary];
105
135
  export {};
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeCollectionPatch = exports.serializeFieldDefinitionForApi = exports.serializeItemsPatch = exports.ItemsPatchExhaustive = exports.ItemsPatchInexhaustive = void 0;
3
+ exports.schemaOKStatus = exports.schemaOutOfSyncStatus = 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
+ const collectionerrortypes_1 = require("../data/collectionerrortypes");
6
7
  class ItemsPatchInexhaustive {
7
8
  constructor(
8
9
  /**
@@ -11,28 +12,35 @@ class ItemsPatchInexhaustive {
11
12
  **/
12
13
  items,
13
14
  /** Items to remove from the collection, based on the same primary key algorithm. */
14
- itemsDeleted) {
15
+ itemsDeleted, errors) {
15
16
  this.items = items;
16
17
  this.itemsDeleted = itemsDeleted;
18
+ this.errors = errors;
17
19
  }
18
20
  }
19
21
  exports.ItemsPatchInexhaustive = ItemsPatchInexhaustive;
20
22
  class ItemsPatchExhaustive {
21
- constructor(items) {
23
+ constructor(items, errors) {
22
24
  this.items = items;
25
+ this.errors = errors;
23
26
  }
24
27
  }
25
28
  exports.ItemsPatchExhaustive = ItemsPatchExhaustive;
29
+ function serializeErrors(errors) {
30
+ if (!errors) {
31
+ return undefined;
32
+ }
33
+ const serializedErrors = {};
34
+ errors.forEach((dictionary, key) => (serializedErrors[key] = dictionary));
35
+ return { 'errors': serializedErrors };
36
+ }
26
37
  function serializeItemsPatch(patch) {
27
38
  var _a;
28
39
  if (patch instanceof ItemsPatchExhaustive) {
29
- return { 'exhaustiveItems': (0, object_1.fromEntries)(patch.items.entries()) };
40
+ return Object.assign({ 'exhaustiveItems': (0, object_1.fromEntries)(patch.items.entries()) }, serializeErrors(patch.errors));
30
41
  }
31
42
  else {
32
- return {
33
- 'items': (0, object_1.fromEntries)(patch.items.entries()),
34
- 'itemsDeleted': (_a = patch.itemsDeleted) !== null && _a !== void 0 ? _a : [],
35
- };
43
+ return Object.assign({ 'items': (0, object_1.fromEntries)(patch.items.entries()), 'itemsDeleted': (_a = patch.itemsDeleted) !== null && _a !== void 0 ? _a : [] }, serializeErrors(patch.errors));
36
44
  }
37
45
  }
38
46
  exports.serializeItemsPatch = serializeItemsPatch;
@@ -67,6 +75,54 @@ function serializeCollectionPatch(patch) {
67
75
  };
68
76
  }
69
77
  exports.serializeCollectionPatch = serializeCollectionPatch;
78
+ /**
79
+ * For the moment, when the upstream Google Sheet is changed in such a way that the schema has changed, we simply
80
+ * stop updates from happening. We do need to alert the user that this has happened, though. This is a utility function
81
+ * for creating the appropriate entry in the errors map so that the user can be alerted that updates have stopped
82
+ * and what they need to do to fix it.
83
+ *
84
+ * The eventual, proposed fix is to allow schemas to have version numbers so that changes to the schema from Google
85
+ * can simply be folded in to the on-document copies of the data and all following edits.
86
+ *
87
+ * @param oldPrimaryKey The primary key stored in the data sync service and which currently is used to interpret
88
+ * patches.
89
+ * @param newPrimaryKey The primary key as it has been changed in the real Google Sheets.
90
+ * @returns The error map entry which alerts the document that this problem has happened.
91
+ */
92
+ function schemaOutOfSyncStatus(oldPrimaryKey, newPrimaryKey) {
93
+ return [
94
+ collectionerrortypes_1.CollectionUpstreamSchemaStatus,
95
+ {
96
+ 'dict': {
97
+ 'status': 'broken',
98
+ 'onDocumentKey': JSON.stringify(oldPrimaryKey),
99
+ 'upstreamKey': JSON.stringify(newPrimaryKey),
100
+ },
101
+ },
102
+ ];
103
+ }
104
+ exports.schemaOutOfSyncStatus = schemaOutOfSyncStatus;
105
+ /**
106
+ * For the moment, when the upstream Google Sheet is changed in such a way that the schema has changed, we simply
107
+ * stop updates from happening. We do need to alert the user that this has happened, though. We also need to know when
108
+ * the updates are happening properly so we can clear the error once the user has resolved the problem. Since the
109
+ * only way to delete errors is to overwrite them, we simply overwrite the error to be OK on every successful
110
+ * import.
111
+ * @returns The error map entry which alerts the document that this problem has been resolved.
112
+ */
113
+ function schemaOKStatus() {
114
+ return [
115
+ collectionerrortypes_1.CollectionUpstreamSchemaStatus,
116
+ {
117
+ 'dict': {
118
+ 'status': 'ok',
119
+ 'onDocumentKey': null,
120
+ 'upstreamKey': null,
121
+ },
122
+ },
123
+ ];
124
+ }
125
+ exports.schemaOKStatus = schemaOKStatus;
70
126
  const assertIsJustRenamed = () => undefined;
71
127
  assertIsJustRenamed();
72
128
  assertIsJustRenamed();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.227",
3
+ "version": "0.0.228",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",