lucid-extension-sdk 0.0.300 → 0.0.302

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/commandtypes.d.ts CHANGED
@@ -715,6 +715,10 @@ export type AddCardIntegrationQuery = {
715
715
  'gdc': string;
716
716
  /** If specified, import modal settings */
717
717
  'im'?: {
718
+ /** Import Modal Heading */
719
+ 'imh'?: string;
720
+ /** Use Isolated Search Bar */
721
+ 'uisbui'?: boolean;
718
722
  /** Get search fields action */
719
723
  'gsf': string;
720
724
  /** Search action */
@@ -87,6 +87,12 @@ class LucidCardIntegrationRegistry {
87
87
  'i': LucidCardIntegrationRegistry.nextHookName(),
88
88
  'os': importModal.onSetup ? LucidCardIntegrationRegistry.nextHookName() : undefined,
89
89
  };
90
+ if (importModal.importModalHeading) {
91
+ serialized['im']['imh'] = importModal.importModalHeading;
92
+ }
93
+ if (importModal.useIsolatedSearchBarUI) {
94
+ serialized['im']['uisbui'] = importModal.useIsolatedSearchBarUI;
95
+ }
90
96
  client.registerAction(serialized['im']['gsf'], async ({ 's': searchSoFar }) => {
91
97
  const result = await importModal.getSearchFields(new Map(searchSoFar));
92
98
  return (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result);
@@ -33,6 +33,11 @@ import { ExtensionCardFieldDefinition } from './cardintegrationdefinitions';
33
33
  *
34
34
  */
35
35
  export interface LucidCardIntegrationStandardImportModal {
36
+ /**
37
+ * Heading used in the import modal.
38
+ */
39
+ importModalHeading?: string;
40
+ useIsolatedSearchBarUI?: boolean;
36
41
  getSearchFields: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
37
42
  search: (fields: Map<string, SerializedFieldType>) => Promise<SearchResult>;
38
43
  import: (primaryKeys: string[], searchFields: Map<string, SerializedFieldType>) => Promise<ImportResult>;
package/core/guards.d.ts CHANGED
@@ -6,3 +6,4 @@ export type DestructureGuardedTypeObj<Obj extends {
6
6
  [key in keyof Obj]: GuardToType<Obj[key]>;
7
7
  }>;
8
8
  export type Validator<TO extends FROM, FROM = unknown> = (p1: FROM) => p1 is TO;
9
+ export type ValidatorWithList<TO extends FROM, FROM = unknown> = (p1: FROM, p2: unknown[]) => p1 is TO;
package/core/object.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- export declare function objectEvery<T, O extends {
2
- [key: string]: any;
3
- }>(obj: O, f: (this: T | undefined, _0: O[typeof _1], _1: string & keyof O, _2: O) => any, opt_this?: T): boolean;
4
1
  export declare function flatten<T>(a: T[][]): T[];
5
2
  export declare function fromEntries<K extends PropertyKey, T>(entries: Iterable<readonly [K, T]>): {
6
3
  [key in K]: T;
package/core/object.js CHANGED
@@ -1,15 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromEntries = exports.flatten = exports.objectEvery = void 0;
4
- function objectEvery(obj, f, opt_this) {
5
- for (const key in obj) {
6
- if (!f.call(opt_this, obj[key], key, obj)) {
7
- return false;
8
- }
9
- }
10
- return true;
11
- }
12
- exports.objectEvery = objectEvery;
3
+ exports.fromEntries = exports.flatten = void 0;
13
4
  function flatten(a) {
14
5
  const result = [];
15
6
  for (const item of a) {
@@ -69,6 +69,13 @@ export declare function mapValidator<T>(subValidator: (p1: unknown) => p1 is T):
69
69
  export declare function objectValidator<T extends {
70
70
  [key: string]: (p1: unknown) => p1 is unknown;
71
71
  }>(validatorStructure: T): (subject: unknown) => subject is DestructureGuardedTypeObj<T>;
72
+ /**
73
+ * This validator functions the same as {@link objectValidator}, with the option of passing in a list
74
+ * which will return all of the fields that were found to be invalid.
75
+ */
76
+ export declare function objectValidatorWithList<T extends {
77
+ [key: string]: (p1: unknown) => p1 is unknown;
78
+ }>(validatorStructure: T): (subject: unknown, invalidFields?: unknown[]) => subject is DestructureGuardedTypeObj<T>;
72
79
  /**
73
80
  * Creates a validator which tests if the target is an object
74
81
  * and if the structure of the object matches the structure of the passed-in
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isFalse = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.typedRecordValidator = exports.recordValidator = exports.strictObjectValidator = exports.partialObjectValidator = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
3
+ exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isFalse = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.typedRecordValidator = exports.recordValidator = exports.strictObjectValidator = exports.partialObjectValidator = exports.objectValidatorWithList = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
4
4
  const checks_1 = require("../checks");
5
- const object_1 = require("../object");
6
5
  /*********************************************************************************
7
6
  * Validator generators: These functions construct new composite validators
8
7
  *from elemental validators.
@@ -117,7 +116,7 @@ exports.someValidator = someValidator;
117
116
  */
118
117
  function mapValidator(subValidator) {
119
118
  return (x) => {
120
- return (0, checks_1.isObject)(x) && !(0, checks_1.isArray)(x) && (0, object_1.objectEvery)(x, subValidator);
119
+ return (0, checks_1.isObject)(x) && !(0, checks_1.isArray)(x) && Object.entries(x).every(([key, value]) => subValidator(value));
121
120
  };
122
121
  }
123
122
  exports.mapValidator = mapValidator;
@@ -139,13 +138,35 @@ function objectValidator(validatorStructure) {
139
138
  return false;
140
139
  }
141
140
  else {
142
- return (0, object_1.objectEvery)(validatorStructure, (validator, key) => {
141
+ return Object.entries(validatorStructure).every(([key, validator]) => {
143
142
  return validator(subject[key]);
144
143
  });
145
144
  }
146
145
  };
147
146
  }
148
147
  exports.objectValidator = objectValidator;
148
+ /**
149
+ * This validator functions the same as {@link objectValidator}, with the option of passing in a list
150
+ * which will return all of the fields that were found to be invalid.
151
+ */
152
+ function objectValidatorWithList(validatorStructure) {
153
+ return (subject, invalidFields) => {
154
+ if ((0, checks_1.isArray)(subject) || !(0, checks_1.isObjectUnsafe)(subject)) {
155
+ return false;
156
+ }
157
+ else {
158
+ let valid = true;
159
+ Object.entries(validatorStructure).forEach(([key, validator]) => {
160
+ if (!validator(subject[key])) {
161
+ invalidFields === null || invalidFields === void 0 ? void 0 : invalidFields.push(key);
162
+ valid = false;
163
+ }
164
+ });
165
+ return valid;
166
+ }
167
+ };
168
+ }
169
+ exports.objectValidatorWithList = objectValidatorWithList;
149
170
  /**
150
171
  * Creates a validator which tests if the target is an object
151
172
  * and if the structure of the object matches the structure of the passed-in
@@ -157,7 +178,7 @@ function partialObjectValidator(validatorStructure) {
157
178
  return false;
158
179
  }
159
180
  else {
160
- return (0, object_1.objectEvery)(validatorStructure, (validator, key) => {
181
+ return Object.entries(validatorStructure).every(([key, validator]) => {
161
182
  return subject[key] === undefined || validator(subject[key]);
162
183
  });
163
184
  }
@@ -177,7 +198,7 @@ function strictObjectValidator(validatorStructure) {
177
198
  const looseValidator = objectValidator(validatorStructure);
178
199
  return (subject) => {
179
200
  return (looseValidator(subject) &&
180
- (0, object_1.objectEvery)(subject, (subx, key) => subx === undefined || validatorStructure.hasOwnProperty(key)));
201
+ Object.entries(subject).every(([key, subx]) => subx === undefined || validatorStructure.hasOwnProperty(key)));
181
202
  };
182
203
  }
183
204
  exports.strictObjectValidator = strictObjectValidator;
@@ -186,7 +207,7 @@ function recordValidator(keyList, valueValidator) {
186
207
  return ((0, checks_1.isObject)(x) &&
187
208
  !(0, checks_1.isArray)(x) &&
188
209
  keyList.every((k) => k in x) &&
189
- (0, object_1.objectEvery)(x, (val, key) => {
210
+ Object.entries(x).every(([key, val]) => {
190
211
  return valueValidator(val);
191
212
  }));
192
213
  };
@@ -299,7 +320,7 @@ exports.propertyValidator = propertyValidator;
299
320
  * @return A validator for the map
300
321
  */
301
322
  function isSet(x) {
302
- return (0, checks_1.isObject)(x) && !(0, checks_1.isArray)(x) && (0, object_1.objectEvery)(x, (val) => (0, checks_1.isBoolean)(val) && !!val);
323
+ return (0, checks_1.isObject)(x) && !(0, checks_1.isArray)(x) && Object.entries(x).every(([key, value]) => (0, checks_1.isBoolean)(value) && !!value);
303
324
  }
304
325
  exports.isSet = isSet;
305
326
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.300",
3
+ "version": "0.0.302",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",