lucid-extension-sdk 0.0.69 → 0.0.71

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.69",
3
+ "version": "0.0.71",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -16,6 +16,7 @@ export declare enum FieldConstraintType {
16
16
  SINGLE_LINE_ONLY = "singleLineOnly",
17
17
  NO_WHITESPACE = "noWhitespace"
18
18
  }
19
+ export declare const isFieldConstraintType: (x: unknown) => x is FieldConstraintType;
19
20
  export declare type SerializedFieldConstraint = {
20
21
  'Type': FieldConstraintType;
21
22
  'Details'?: JsonSerializable;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FieldConstraintType = void 0;
3
+ exports.isFieldConstraintType = exports.FieldConstraintType = void 0;
4
+ const validators_1 = require("../../validators/validators");
4
5
  // The options here must match com.lucidchart.data.model.fielddefinition.FieldConstraintType on the backend
5
6
  var FieldConstraintType;
6
7
  (function (FieldConstraintType) {
@@ -11,3 +12,4 @@ var FieldConstraintType;
11
12
  FieldConstraintType["SINGLE_LINE_ONLY"] = "singleLineOnly";
12
13
  FieldConstraintType["NO_WHITESPACE"] = "noWhitespace";
13
14
  })(FieldConstraintType = exports.FieldConstraintType || (exports.FieldConstraintType = {}));
15
+ exports.isFieldConstraintType = (0, validators_1.enumValidator)(FieldConstraintType);
@@ -116,6 +116,10 @@ export declare function either<A, B>(validatorA: Validator<A>, validatorB: Valid
116
116
  * This is useful for validating properties that have been composed of a generic and more specific values.
117
117
  */
118
118
  export declare function both<A, B>(validatorA: Validator<A>, validatorB: Validator<B>): (x: unknown) => x is A & B;
119
+ /**
120
+ * Create a validator that allows types excluding those that satisfy an excludeValidator.
121
+ */
122
+ export declare function exclude<T extends U, U>(validator: (x: unknown) => x is U, excludeValidator: (x: U) => x is T): (x: unknown) => x is Exclude<U, T>;
119
123
  /**
120
124
  * Get a validator which returns whether the property calculation structure is
121
125
  * correct.
@@ -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.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.recordValidator = exports.strictObjectValidator = 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.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.recordValidator = exports.strictObjectValidator = 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
5
  const object_1 = require("../object");
6
6
  /*********************************************************************************
@@ -243,6 +243,13 @@ function both(validatorA, validatorB) {
243
243
  };
244
244
  }
245
245
  exports.both = both;
246
+ /**
247
+ * Create a validator that allows types excluding those that satisfy an excludeValidator.
248
+ */
249
+ function exclude(validator, excludeValidator) {
250
+ return (x) => validator(x) && !excludeValidator(x);
251
+ }
252
+ exports.exclude = exclude;
246
253
  /**
247
254
  * Get a validator which returns whether the property calculation structure is
248
255
  * correct.
@@ -1,3 +1,4 @@
1
+ import { isNumber, isUndefined } from '../core/checks';
1
2
  import { FieldTypeDefinition } from '../core/data/fieldtypedefinition/fieldtypedefinition';
2
3
  import { FieldConstraintType, SerializedFieldConstraint, SerializedFieldDefinition } from '../core/data/serializedfield/serializedfielddefinition';
3
4
  import { SerializedSchema } from '../core/data/serializedfield/serializedschema';
@@ -26,6 +27,18 @@ export interface NoWhitespaceFieldConstraintDefinition {
26
27
  value?: undefined;
27
28
  }
28
29
  export declare type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition;
30
+ export declare function minMaxFieldConstraintValidator(val: unknown): val is FieldConstraintType.MIN_VALUE | FieldConstraintType.MAX_VALUE;
31
+ export declare const isFieldConstraintDefinition: (x: unknown) => x is {
32
+ type?: FieldConstraintType | undefined;
33
+ } & {
34
+ type: FieldConstraintType;
35
+ } & (import("..").DestructureGuardedTypeObj<{
36
+ type: typeof minMaxFieldConstraintValidator;
37
+ value: typeof isNumber;
38
+ }> | import("..").DestructureGuardedTypeObj<{
39
+ type: (x: unknown) => x is FieldConstraintType.REQUIRED | FieldConstraintType.LOCKED | FieldConstraintType.SINGLE_LINE_ONLY | FieldConstraintType.NO_WHITESPACE;
40
+ value: typeof isUndefined;
41
+ }>);
29
42
  /**
30
43
  * The definition for a field to be included in a [SchemaDefinition](#interfaces_data_schemadefinition-SchemaDefinition)
31
44
  */
@@ -1,9 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = exports.serializeFieldConstraintDefinition = void 0;
3
+ exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = exports.serializeFieldConstraintDefinition = exports.isFieldConstraintDefinition = exports.minMaxFieldConstraintValidator = void 0;
4
4
  const checks_1 = require("../core/checks");
5
5
  const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
6
6
  const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
7
+ const validators_1 = require("../core/validators/validators");
8
+ function minMaxFieldConstraintValidator(val) {
9
+ return val === serializedfielddefinition_1.FieldConstraintType.MIN_VALUE || val === serializedfielddefinition_1.FieldConstraintType.MAX_VALUE;
10
+ }
11
+ exports.minMaxFieldConstraintValidator = minMaxFieldConstraintValidator;
12
+ exports.isFieldConstraintDefinition = (0, validators_1.both)((0, validators_1.objectValidator)({
13
+ 'type': serializedfielddefinition_1.isFieldConstraintType,
14
+ }), (0, validators_1.either)((0, validators_1.objectValidator)({ 'type': minMaxFieldConstraintValidator, 'value': checks_1.isNumber }), (0, validators_1.objectValidator)({ 'type': (0, validators_1.exclude)(serializedfielddefinition_1.isFieldConstraintType, minMaxFieldConstraintValidator), 'value': checks_1.isUndefined })));
7
15
  /** @ignore */
8
16
  function serializeFieldConstraintDefinition(constraint) {
9
17
  return {