lucid-extension-sdk 0.0.118 → 0.0.120

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.118",
3
+ "version": "0.0.120",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -1,9 +1,18 @@
1
1
  export declare type SerializedFieldType = number | boolean | string | null | SerializedLucidDateObject | SerializedColorObjectFieldType | SerializedLucidDictionary | SerializedLucidCurrency | undefined | Array<SerializedFieldType>;
2
- export declare type SerializedLucidDictionary = {
2
+ export declare type SerializedJsonFieldType = number | boolean | string | null | undefined | Array<SerializedJsonFieldType> | {
3
+ [index: string]: SerializedJsonFieldType;
4
+ };
5
+ export declare type JSONSerializedLucidDictionary = {
6
+ 'js': {
7
+ [index: string]: SerializedJsonFieldType;
8
+ };
9
+ };
10
+ export declare type NestedSerializedLucidDictionary = {
3
11
  'dict': {
4
12
  [index: string]: SerializedFieldType;
5
13
  };
6
14
  };
15
+ export declare type SerializedLucidDictionary = NestedSerializedLucidDictionary | JSONSerializedLucidDictionary;
7
16
  export declare type SerializedLucidCurrency = {
8
17
  'a': number;
9
18
  't': string;
@@ -52,8 +61,21 @@ export declare type SerializedColorObjectFieldType = {
52
61
  'color': SerializedColorObject;
53
62
  };
54
63
  export declare function isSerializedColorObjectFieldType(value: any): value is SerializedColorObjectFieldType;
64
+ /** a dictionary type that has full type support */
65
+ export declare const isNestedSerializedLucidDictionary: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
66
+ dict: (x: unknown) => x is {
67
+ [key: string]: SerializedFieldType;
68
+ };
69
+ }>;
70
+ /** a dictionary type that only supports raw js, primarily used when external data could be arbritrary js */
71
+ export declare const isJsonSerializedLucidDictionary: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
72
+ js: (x: unknown) => x is {
73
+ [key: string]: SerializedJsonFieldType;
74
+ };
75
+ }>;
55
76
  export declare function isSerializedLucidDictionary(value: any): value is SerializedLucidDictionary;
56
77
  export declare function isSerializedLucidCurrency(value: any): value is SerializedLucidCurrency;
57
78
  export declare function isSerializedLucidDateObject(value: any): value is SerializedLucidDateObject;
58
79
  export declare function isSerializedFieldType(value: any): value is SerializedFieldType;
80
+ export declare function isSerializedJsonFieldType(value: any): value is SerializedJsonFieldType;
59
81
  export declare function isSerializedFields(value: unknown): value is SerializedFields;
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSerializedFields = exports.isSerializedFieldType = exports.isSerializedLucidDateObject = exports.isSerializedLucidCurrency = exports.isSerializedLucidDictionary = exports.isSerializedColorObjectFieldType = void 0;
3
+ exports.isSerializedFields = exports.isSerializedJsonFieldType = exports.isSerializedFieldType = exports.isSerializedLucidDateObject = exports.isSerializedLucidCurrency = exports.isSerializedLucidDictionary = exports.isJsonSerializedLucidDictionary = exports.isNestedSerializedLucidDictionary = exports.isSerializedColorObjectFieldType = void 0;
4
4
  const checks_1 = require("../../checks");
5
+ const validators_1 = require("../../validators/validators");
5
6
  function isSerializedColorObjectFieldType(value) {
6
7
  return (0, checks_1.isObject)(value) && (0, checks_1.isObject)(value['color']);
7
8
  }
8
9
  exports.isSerializedColorObjectFieldType = isSerializedColorObjectFieldType;
10
+ /** a dictionary type that has full type support */
11
+ exports.isNestedSerializedLucidDictionary = (0, validators_1.strictObjectValidator)({ 'dict': (0, validators_1.mapValidator)(isSerializedFieldType) });
12
+ /** a dictionary type that only supports raw js, primarily used when external data could be arbritrary js */
13
+ exports.isJsonSerializedLucidDictionary = (0, validators_1.strictObjectValidator)({ 'js': (0, validators_1.mapValidator)(isSerializedJsonFieldType) });
9
14
  function isSerializedLucidDictionary(value) {
10
- return (0, checks_1.isObject)(value) && (0, checks_1.isObject)(value['dict']) && Object.values(value['dict']).every(isSerializedFieldType);
15
+ return (0, exports.isNestedSerializedLucidDictionary)(value) || (0, exports.isJsonSerializedLucidDictionary)(value);
11
16
  }
12
17
  exports.isSerializedLucidDictionary = isSerializedLucidDictionary;
13
18
  function isSerializedLucidCurrency(value) {
@@ -33,6 +38,15 @@ function isSerializedFieldType(value) {
33
38
  isSerializedColorObjectFieldType(value));
34
39
  }
35
40
  exports.isSerializedFieldType = isSerializedFieldType;
41
+ function isSerializedJsonFieldType(value) {
42
+ return (value == null ||
43
+ (0, checks_1.isNumber)(value) ||
44
+ (0, checks_1.isString)(value) ||
45
+ (0, checks_1.isBoolean)(value) ||
46
+ ((0, checks_1.isArray)(value) && value.every(isSerializedJsonFieldType)) ||
47
+ ((0, checks_1.isObject)(value) && Object.values(value).every(isSerializedJsonFieldType)));
48
+ }
49
+ exports.isSerializedJsonFieldType = isSerializedJsonFieldType;
36
50
  function isSerializedFields(value) {
37
51
  return (0, checks_1.isObject)(value) && Object.values(value).every(isSerializedFieldType);
38
52
  }
@@ -27,8 +27,8 @@ export declare type SerializedPatchChange = {
27
27
  'collections': {
28
28
  'collectionId': string;
29
29
  'itemsPatch': {
30
- 'items'?: Record<string, object>;
31
- 'itemsDeleted'?: string[];
30
+ 'items': Record<string, object>;
31
+ 'itemsDeleted': string[];
32
32
  };
33
33
  }[];
34
34
  };
@@ -33,11 +33,12 @@ function serializePatchResponse(patchChange) {
33
33
  return {
34
34
  'syncId': patchChange.syncId,
35
35
  'collections': patchChange.collections.map((c) => {
36
+ var _a, _b;
36
37
  return {
37
38
  'collectionId': c.collectionId,
38
39
  'itemsPatch': {
39
- 'items': c.items,
40
- 'itemsDeleted': c.itemsDeleted,
40
+ 'items': (_a = c.items) !== null && _a !== void 0 ? _a : {},
41
+ 'itemsDeleted': (_b = c.itemsDeleted) !== null && _b !== void 0 ? _b : [],
41
42
  },
42
43
  };
43
44
  }),