lucid-extension-sdk 0.0.328 → 0.0.329

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.
@@ -28,6 +28,12 @@ export declare function rangeValidator(min: number, max: number): (x: unknown) =
28
28
  * @return A validator for the array type
29
29
  */
30
30
  export declare function arrayValidator<T>(subValidator: (p1: unknown) => p1 is T): (p1: unknown) => p1 is T[];
31
+ /**
32
+ * valid if at least one item in the array is valid.
33
+ * @param subValidator
34
+ * @returns
35
+ */
36
+ export declare function arrayValidatorWithList<T>(subValidator: (p1: unknown) => p1 is T): (p1: unknown, invalidItems?: unknown[]) => p1 is T[];
31
37
  /**
32
38
  * Creates a validator for a fixed width array where each entry
33
39
  * in the array can have a separate validator
@@ -74,7 +80,7 @@ export declare function objectValidator<T extends {
74
80
  * which will return all of the fields that were found to be invalid.
75
81
  */
76
82
  export declare function objectValidatorWithList<T extends {
77
- [key: string]: (p1: unknown) => p1 is unknown;
83
+ [key: string]: (p1: unknown, invalidFields?: unknown[]) => p1 is unknown;
78
84
  }>(validatorStructure: T): (subject: unknown, invalidFields?: unknown[]) => subject is DestructureGuardedTypeObj<T>;
79
85
  /**
80
86
  * Creates a validator which tests if the target is an object
@@ -1,6 +1,6 @@
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.objectValidatorWithList = 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.arrayValidatorWithList = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
4
4
  const checks_1 = require("../checks");
5
5
  /*********************************************************************************
6
6
  * Validator generators: These functions construct new composite validators
@@ -64,6 +64,25 @@ function arrayValidator(subValidator) {
64
64
  };
65
65
  }
66
66
  exports.arrayValidator = arrayValidator;
67
+ /**
68
+ * valid if at least one item in the array is valid.
69
+ * @param subValidator
70
+ * @returns
71
+ */
72
+ function arrayValidatorWithList(subValidator) {
73
+ return (x, invalidItems) => {
74
+ if (!(0, checks_1.isArray)(x)) {
75
+ return false;
76
+ }
77
+ for (const element of x) {
78
+ if (!subValidator(element)) {
79
+ invalidItems === null || invalidItems === void 0 ? void 0 : invalidItems.push(element);
80
+ }
81
+ }
82
+ return x.some(subValidator);
83
+ };
84
+ }
85
+ exports.arrayValidatorWithList = arrayValidatorWithList;
67
86
  /**
68
87
  * Creates a validator for a fixed width array where each entry
69
88
  * in the array can have a separate validator
@@ -157,7 +176,7 @@ function objectValidatorWithList(validatorStructure) {
157
176
  else {
158
177
  let valid = true;
159
178
  Object.entries(validatorStructure).forEach(([key, validator]) => {
160
- if (!validator(subject[key])) {
179
+ if (!validator(subject[key], invalidFields)) {
161
180
  if (invalidFields && Array.isArray(invalidFields)) {
162
181
  invalidFields.push(key);
163
182
  }
package/editorclient.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CommandArgs, CommandName, HashAlgorithmEnum, TriggerAuthFlowResult, UnionToIntersection } from './commandtypes';
2
- import { JsonSerializable } from './core/jsonserializable';
2
+ import { JsonObject, JsonSerializable } from './core/jsonserializable';
3
3
  import { UnfurlCallbacks } from './core/unfurl/unfurlcallbacks';
4
4
  import { BinaryXHRResponse, OAuthXHRRequest, TextXHRResponse, XHRRequest, XHRResponse } from './core/xhr';
5
5
  import { CollectionProxy } from './data/collectionproxy';
@@ -20,6 +20,7 @@ export type DataActionResponse = {
20
20
  /** The body of the HTTP Response (otherwise) */
21
21
  'text': string;
22
22
  });
23
+ export declare function getResponseBody(response: DataActionResponse): string | JsonObject;
23
24
  export type DataActionOptions = {
24
25
  dataConnectorName: string;
25
26
  actionName: string;
package/editorclient.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EditorClient = void 0;
3
+ exports.EditorClient = exports.getResponseBody = void 0;
4
4
  const commandtypes_1 = require("./commandtypes");
5
5
  const base64_1 = require("./core/base64");
6
6
  const checks_1 = require("./core/checks");
@@ -29,6 +29,18 @@ function parseRawXHRResponse(responseFormat, raw) {
29
29
  responseData: (raw === null || raw === void 0 ? void 0 : raw['t']) ? (0, base64_1.decodeBase64)(raw['t']) : new Uint8Array(0),
30
30
  }));
31
31
  }
32
+ function getResponseBody(response) {
33
+ if ('json' in response) {
34
+ return response['json'];
35
+ }
36
+ else if ('text' in response) {
37
+ return response['text'];
38
+ }
39
+ else {
40
+ return '';
41
+ }
42
+ }
43
+ exports.getResponseBody = getResponseBody;
32
44
  class EditorClient {
33
45
  getUniqueActionName() {
34
46
  while (this.actionExists('a' + this.nextId)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.328",
3
+ "version": "0.0.329",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",