@blueking/bkui-form 1.0.1-beta.1 → 1.0.1-beta.3

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.
Files changed (168) hide show
  1. package/esm/adapter/common/FieldGroupWrap.tsx.js +199 -0
  2. package/esm/adapter/field/ArrayField.tsx.js +55 -0
  3. package/esm/adapter/field/BooleanField.tsx.js +41 -0
  4. package/esm/adapter/field/CompositionField.tsx.js +113 -0
  5. package/esm/adapter/field/FieldProps.ts.js +85 -0
  6. package/esm/adapter/field/NumberField.tsx.js +19 -0
  7. package/esm/adapter/field/ObjectField.tsx.js +58 -0
  8. package/esm/adapter/field/SchemaField.tsx.js +28 -0
  9. package/esm/adapter/field/StringField.tsx.js +4 -0
  10. package/esm/adapter/widget/ArrayWidget.ts.js +196 -0
  11. package/esm/adapter/widget/ButtonWidget.ts.js +76 -0
  12. package/esm/adapter/widget/CheckboxWidget.ts.js +101 -0
  13. package/esm/adapter/widget/CollapseGroupWidget.ts.js +140 -0
  14. package/esm/adapter/widget/ColorPickerWidget.ts.js +71 -0
  15. package/esm/adapter/widget/InputWidget.ts.js +79 -0
  16. package/esm/adapter/widget/KeyValueArrayWidget.tsx.js +156 -0
  17. package/esm/adapter/widget/RadioWidget.ts.js +98 -0
  18. package/esm/adapter/widget/SelectWidget.ts.js +98 -0
  19. package/esm/adapter/widget/SwitchWidget.ts.js +73 -0
  20. package/esm/adapter/widget/TabGroupWidget.ts.js +145 -0
  21. package/esm/adapter/widget/TableWidget.ts.js +205 -0
  22. package/esm/adapter/widget/Widget.ts.js +497 -0
  23. package/esm/assets/fonts/iconcool.eot +0 -0
  24. package/esm/assets/fonts/iconcool.ttf +0 -0
  25. package/esm/assets/fonts/iconcool.woff +0 -0
  26. package/esm/assets/style.css +43 -0
  27. package/esm/controller/form.css +164 -0
  28. package/esm/controller/form.tsx.js +159 -0
  29. package/esm/controller/props.ts.js +75 -0
  30. package/esm/core/events.ts.js +74 -0
  31. package/esm/core/expression.ts.js +67 -0
  32. package/esm/core/lang.ts.js +25 -0
  33. package/esm/core/layout.ts.js +149 -0
  34. package/esm/core/path.ts.js +60 -0
  35. package/esm/core/proxy.ts.js +10 -0
  36. package/esm/core/reaction.ts.js +116 -0
  37. package/esm/core/register.ts.js +74 -0
  38. package/esm/core/schema.ts.js +302 -0
  39. package/esm/core/validator.ts.js +248 -0
  40. package/esm/core/widgetTree.ts.js +163 -0
  41. package/esm/index.ts.js +6 -0
  42. package/esm/node_modules/@blueking/cli-service/dist/lib/path.js +35 -0
  43. package/esm/node_modules/@blueking/cli-service/dist/lib/util.js +233 -0
  44. package/esm/node_modules/@blueking/cli-service/dist/tools/rust/helper/path.js +172 -0
  45. package/esm/node_modules/ajv/dist/ajv.js +50 -0
  46. package/esm/node_modules/ajv/dist/compile/codegen/code.js +156 -0
  47. package/esm/node_modules/ajv/dist/compile/codegen/index.js +697 -0
  48. package/esm/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
  49. package/esm/node_modules/ajv/dist/compile/errors.js +123 -0
  50. package/esm/node_modules/ajv/dist/compile/index.js +242 -0
  51. package/esm/node_modules/ajv/dist/compile/names.js +28 -0
  52. package/esm/node_modules/ajv/dist/compile/ref_error.js +12 -0
  53. package/esm/node_modules/ajv/dist/compile/resolve.js +155 -0
  54. package/esm/node_modules/ajv/dist/compile/rules.js +26 -0
  55. package/esm/node_modules/ajv/dist/compile/util.js +178 -0
  56. package/esm/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
  57. package/esm/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
  58. package/esm/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
  59. package/esm/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
  60. package/esm/node_modules/ajv/dist/compile/validate/index.js +520 -0
  61. package/esm/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
  62. package/esm/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
  63. package/esm/node_modules/ajv/dist/core.js +618 -0
  64. package/esm/node_modules/ajv/dist/refs/data.json +13 -0
  65. package/esm/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
  66. package/esm/node_modules/ajv/dist/runtime/equal.js +7 -0
  67. package/esm/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
  68. package/esm/node_modules/ajv/dist/runtime/uri.js +6 -0
  69. package/esm/node_modules/ajv/dist/runtime/validation_error.js +11 -0
  70. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
  71. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
  72. package/esm/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
  73. package/esm/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
  74. package/esm/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
  75. package/esm/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
  76. package/esm/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
  77. package/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
  78. package/esm/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
  79. package/esm/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
  80. package/esm/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
  81. package/esm/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
  82. package/esm/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
  83. package/esm/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
  84. package/esm/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
  85. package/esm/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
  86. package/esm/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
  87. package/esm/node_modules/ajv/dist/vocabularies/code.js +131 -0
  88. package/esm/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
  89. package/esm/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
  90. package/esm/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
  91. package/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
  92. package/esm/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
  93. package/esm/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
  94. package/esm/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
  95. package/esm/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
  96. package/esm/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
  97. package/esm/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
  98. package/esm/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
  99. package/esm/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
  100. package/esm/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
  101. package/esm/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
  102. package/esm/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
  103. package/esm/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
  104. package/esm/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
  105. package/esm/node_modules/ajv/dist/vocabularies/validation/pattern.js +24 -0
  106. package/esm/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
  107. package/esm/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
  108. package/esm/node_modules/ajv-formats/dist/formats.js +173 -0
  109. package/esm/node_modules/ajv-formats/dist/index.js +37 -0
  110. package/esm/node_modules/ajv-formats/dist/limit.js +69 -0
  111. package/esm/node_modules/ajv-i18n/localize/zh/index.js +154 -0
  112. package/esm/node_modules/fast-deep-equal/index.js +46 -0
  113. package/esm/node_modules/fast-uri/index.js +303 -0
  114. package/esm/node_modules/fast-uri/lib/schemes.js +188 -0
  115. package/esm/node_modules/fast-uri/lib/scopedChars.js +30 -0
  116. package/esm/node_modules/fast-uri/lib/utils.js +244 -0
  117. package/esm/node_modules/json-schema-traverse/index.js +89 -0
  118. package/esm/node_modules/semver/classes/comparator.js +143 -0
  119. package/esm/node_modules/semver/classes/range.js +557 -0
  120. package/esm/node_modules/semver/classes/semver.js +333 -0
  121. package/esm/node_modules/semver/functions/clean.js +8 -0
  122. package/esm/node_modules/semver/functions/cmp.js +54 -0
  123. package/esm/node_modules/semver/functions/coerce.js +62 -0
  124. package/esm/node_modules/semver/functions/compare-build.js +9 -0
  125. package/esm/node_modules/semver/functions/compare-loose.js +5 -0
  126. package/esm/node_modules/semver/functions/compare.js +7 -0
  127. package/esm/node_modules/semver/functions/diff.js +60 -0
  128. package/esm/node_modules/semver/functions/eq.js +5 -0
  129. package/esm/node_modules/semver/functions/gt.js +5 -0
  130. package/esm/node_modules/semver/functions/gte.js +5 -0
  131. package/esm/node_modules/semver/functions/inc.js +21 -0
  132. package/esm/node_modules/semver/functions/lt.js +5 -0
  133. package/esm/node_modules/semver/functions/lte.js +5 -0
  134. package/esm/node_modules/semver/functions/major.js +5 -0
  135. package/esm/node_modules/semver/functions/minor.js +5 -0
  136. package/esm/node_modules/semver/functions/neq.js +5 -0
  137. package/esm/node_modules/semver/functions/parse.js +18 -0
  138. package/esm/node_modules/semver/functions/patch.js +5 -0
  139. package/esm/node_modules/semver/functions/prerelease.js +8 -0
  140. package/esm/node_modules/semver/functions/rcompare.js +5 -0
  141. package/esm/node_modules/semver/functions/rsort.js +5 -0
  142. package/esm/node_modules/semver/functions/satisfies.js +12 -0
  143. package/esm/node_modules/semver/functions/sort.js +5 -0
  144. package/esm/node_modules/semver/functions/valid.js +8 -0
  145. package/esm/node_modules/semver/index.js +91 -0
  146. package/esm/node_modules/semver/internal/constants.js +37 -0
  147. package/esm/node_modules/semver/internal/debug.js +11 -0
  148. package/esm/node_modules/semver/internal/identifiers.js +29 -0
  149. package/esm/node_modules/semver/internal/lrucache.js +42 -0
  150. package/esm/node_modules/semver/internal/parse-options.js +17 -0
  151. package/esm/node_modules/semver/internal/re.js +223 -0
  152. package/esm/node_modules/semver/ranges/gtr.js +6 -0
  153. package/esm/node_modules/semver/ranges/intersects.js +9 -0
  154. package/esm/node_modules/semver/ranges/ltr.js +6 -0
  155. package/esm/node_modules/semver/ranges/max-satisfying.js +27 -0
  156. package/esm/node_modules/semver/ranges/min-satisfying.js +26 -0
  157. package/esm/node_modules/semver/ranges/min-version.js +63 -0
  158. package/esm/node_modules/semver/ranges/outside.js +82 -0
  159. package/esm/node_modules/semver/ranges/simplify.js +49 -0
  160. package/esm/node_modules/semver/ranges/subset.js +249 -0
  161. package/esm/node_modules/semver/ranges/to-comparators.js +10 -0
  162. package/esm/node_modules/semver/ranges/valid.js +13 -0
  163. package/esm/util/fetch.ts.js +190 -0
  164. package/esm/util/index.ts.js +276 -0
  165. package/package.json +3 -4
  166. package/dist/main.css +0 -208
  167. package/dist/main.js +0 -17353
  168. /package/{dist/svg/iconcool.eb237688.svg → esm/assets/fonts/iconcool.svg} +0 -0
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const additionalItems_1 = require('./additionalItems.js');
4
+ const prefixItems_1 = require('./prefixItems.js');
5
+ const items_1 = require('./items.js');
6
+ const items2020_1 = require('./items2020.js');
7
+ const contains_1 = require('./contains.js');
8
+ const dependencies_1 = require('./dependencies.js');
9
+ const propertyNames_1 = require('./propertyNames.js');
10
+ const additionalProperties_1 = require('./additionalProperties.js');
11
+ const properties_1 = require('./properties.js');
12
+ const patternProperties_1 = require('./patternProperties.js');
13
+ const not_1 = require('./not.js');
14
+ const anyOf_1 = require('./anyOf.js');
15
+ const oneOf_1 = require('./oneOf.js');
16
+ const allOf_1 = require('./allOf.js');
17
+ const if_1 = require('./if.js');
18
+ const thenElse_1 = require('./thenElse.js');
19
+ function getApplicator(draft2020 = false) {
20
+ const applicator = [
21
+ // any
22
+ not_1.default,
23
+ anyOf_1.default,
24
+ oneOf_1.default,
25
+ allOf_1.default,
26
+ if_1.default,
27
+ thenElse_1.default,
28
+ // object
29
+ propertyNames_1.default,
30
+ additionalProperties_1.default,
31
+ dependencies_1.default,
32
+ properties_1.default,
33
+ patternProperties_1.default,
34
+ ];
35
+ // array
36
+ if (draft2020)
37
+ applicator.push(prefixItems_1.default, items2020_1.default);
38
+ else
39
+ applicator.push(additionalItems_1.default, items_1.default);
40
+ applicator.push(contains_1.default);
41
+ return applicator;
42
+ }
43
+ exports.default = getApplicator;
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateTuple = void 0;
4
+ const codegen_1 = require('../../compile/codegen/index.js');
5
+ const util_1 = require('../../compile/util.js');
6
+ const code_1 = require('../code.js');
7
+ const def = {
8
+ keyword: "items",
9
+ type: "array",
10
+ schemaType: ["object", "array", "boolean"],
11
+ before: "uniqueItems",
12
+ code(cxt) {
13
+ const { schema, it } = cxt;
14
+ if (Array.isArray(schema))
15
+ return validateTuple(cxt, "additionalItems", schema);
16
+ it.items = true;
17
+ if ((0, util_1.alwaysValidSchema)(it, schema))
18
+ return;
19
+ cxt.ok((0, code_1.validateArray)(cxt));
20
+ },
21
+ };
22
+ function validateTuple(cxt, extraItems, schArr = cxt.schema) {
23
+ const { gen, parentSchema, data, keyword, it } = cxt;
24
+ checkStrictTuple(parentSchema);
25
+ if (it.opts.unevaluated && schArr.length && it.items !== true) {
26
+ it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items);
27
+ }
28
+ const valid = gen.name("valid");
29
+ const len = gen.const("len", (0, codegen_1._) `${data}.length`);
30
+ schArr.forEach((sch, i) => {
31
+ if ((0, util_1.alwaysValidSchema)(it, sch))
32
+ return;
33
+ gen.if((0, codegen_1._) `${len} > ${i}`, () => cxt.subschema({
34
+ keyword,
35
+ schemaProp: i,
36
+ dataProp: i,
37
+ }, valid));
38
+ cxt.ok(valid);
39
+ });
40
+ function checkStrictTuple(sch) {
41
+ const { opts, errSchemaPath } = it;
42
+ const l = schArr.length;
43
+ const fullTuple = l === sch.minItems && (l === sch.maxItems || sch[extraItems] === false);
44
+ if (opts.strictTuples && !fullTuple) {
45
+ const msg = `"${keyword}" is ${l}-tuple, but minItems or maxItems/${extraItems} are not specified or different at path "${errSchemaPath}"`;
46
+ (0, util_1.checkStrictMode)(it, msg, opts.strictTuples);
47
+ }
48
+ }
49
+ }
50
+ exports.validateTuple = validateTuple;
51
+ exports.default = def;
52
+ //# sourceMappingURL=items.js.map
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const codegen_1 = require('../../compile/codegen/index.js');
4
+ const util_1 = require('../../compile/util.js');
5
+ const code_1 = require('../code.js');
6
+ const additionalItems_1 = require('./additionalItems.js');
7
+ const error = {
8
+ message: ({ params: { len } }) => (0, codegen_1.str) `must NOT have more than ${len} items`,
9
+ params: ({ params: { len } }) => (0, codegen_1._) `{limit: ${len}}`,
10
+ };
11
+ const def = {
12
+ keyword: "items",
13
+ type: "array",
14
+ schemaType: ["object", "boolean"],
15
+ before: "uniqueItems",
16
+ error,
17
+ code(cxt) {
18
+ const { schema, parentSchema, it } = cxt;
19
+ const { prefixItems } = parentSchema;
20
+ it.items = true;
21
+ if ((0, util_1.alwaysValidSchema)(it, schema))
22
+ return;
23
+ if (prefixItems)
24
+ (0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems);
25
+ else
26
+ cxt.ok((0, code_1.validateArray)(cxt));
27
+ },
28
+ };
29
+ exports.default = def;
30
+ //# sourceMappingURL=items2020.js.map
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_1 = require('../../compile/util.js');
4
+ const def = {
5
+ keyword: "not",
6
+ schemaType: ["object", "boolean"],
7
+ trackErrors: true,
8
+ code(cxt) {
9
+ const { gen, schema, it } = cxt;
10
+ if ((0, util_1.alwaysValidSchema)(it, schema)) {
11
+ cxt.fail();
12
+ return;
13
+ }
14
+ const valid = gen.name("valid");
15
+ cxt.subschema({
16
+ keyword: "not",
17
+ compositeRule: true,
18
+ createErrors: false,
19
+ allErrors: false,
20
+ }, valid);
21
+ cxt.failResult(valid, () => cxt.reset(), () => cxt.error());
22
+ },
23
+ error: { message: "must NOT be valid" },
24
+ };
25
+ exports.default = def;
26
+ //# sourceMappingURL=not.js.map
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const codegen_1 = require('../../compile/codegen/index.js');
4
+ const util_1 = require('../../compile/util.js');
5
+ const error = {
6
+ message: "must match exactly one schema in oneOf",
7
+ params: ({ params }) => (0, codegen_1._) `{passingSchemas: ${params.passing}}`,
8
+ };
9
+ const def = {
10
+ keyword: "oneOf",
11
+ schemaType: "array",
12
+ trackErrors: true,
13
+ error,
14
+ code(cxt) {
15
+ const { gen, schema, parentSchema, it } = cxt;
16
+ /* istanbul ignore if */
17
+ if (!Array.isArray(schema))
18
+ throw new Error("ajv implementation error");
19
+ if (it.opts.discriminator && parentSchema.discriminator)
20
+ return;
21
+ const schArr = schema;
22
+ const valid = gen.let("valid", false);
23
+ const passing = gen.let("passing", null);
24
+ const schValid = gen.name("_valid");
25
+ cxt.setParams({ passing });
26
+ // TODO possibly fail straight away (with warning or exception) if there are two empty always valid schemas
27
+ gen.block(validateOneOf);
28
+ cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
29
+ function validateOneOf() {
30
+ schArr.forEach((sch, i) => {
31
+ let schCxt;
32
+ if ((0, util_1.alwaysValidSchema)(it, sch)) {
33
+ gen.var(schValid, true);
34
+ }
35
+ else {
36
+ schCxt = cxt.subschema({
37
+ keyword: "oneOf",
38
+ schemaProp: i,
39
+ compositeRule: true,
40
+ }, schValid);
41
+ }
42
+ if (i > 0) {
43
+ gen
44
+ .if((0, codegen_1._) `${schValid} && ${valid}`)
45
+ .assign(valid, false)
46
+ .assign(passing, (0, codegen_1._) `[${passing}, ${i}]`)
47
+ .else();
48
+ }
49
+ gen.if(schValid, () => {
50
+ gen.assign(valid, true);
51
+ gen.assign(passing, i);
52
+ if (schCxt)
53
+ cxt.mergeEvaluated(schCxt, codegen_1.Name);
54
+ });
55
+ });
56
+ }
57
+ },
58
+ };
59
+ exports.default = def;
60
+ //# sourceMappingURL=oneOf.js.map
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const code_1 = require('../code.js');
4
+ const codegen_1 = require('../../compile/codegen/index.js');
5
+ const util_1 = require('../../compile/util.js');
6
+ const util_2 = require('../../compile/util.js');
7
+ const def = {
8
+ keyword: "patternProperties",
9
+ type: "object",
10
+ schemaType: "object",
11
+ code(cxt) {
12
+ const { gen, schema, data, parentSchema, it } = cxt;
13
+ const { opts } = it;
14
+ const patterns = (0, code_1.allSchemaProperties)(schema);
15
+ const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p]));
16
+ if (patterns.length === 0 ||
17
+ (alwaysValidPatterns.length === patterns.length &&
18
+ (!it.opts.unevaluated || it.props === true))) {
19
+ return;
20
+ }
21
+ const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties;
22
+ const valid = gen.name("valid");
23
+ if (it.props !== true && !(it.props instanceof codegen_1.Name)) {
24
+ it.props = (0, util_2.evaluatedPropsToName)(gen, it.props);
25
+ }
26
+ const { props } = it;
27
+ validatePatternProperties();
28
+ function validatePatternProperties() {
29
+ for (const pat of patterns) {
30
+ if (checkProperties)
31
+ checkMatchingProperties(pat);
32
+ if (it.allErrors) {
33
+ validateProperties(pat);
34
+ }
35
+ else {
36
+ gen.var(valid, true); // TODO var
37
+ validateProperties(pat);
38
+ gen.if(valid);
39
+ }
40
+ }
41
+ }
42
+ function checkMatchingProperties(pat) {
43
+ for (const prop in checkProperties) {
44
+ if (new RegExp(pat).test(prop)) {
45
+ (0, util_1.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
46
+ }
47
+ }
48
+ }
49
+ function validateProperties(pat) {
50
+ gen.forIn("key", data, (key) => {
51
+ gen.if((0, codegen_1._) `${(0, code_1.usePattern)(cxt, pat)}.test(${key})`, () => {
52
+ const alwaysValid = alwaysValidPatterns.includes(pat);
53
+ if (!alwaysValid) {
54
+ cxt.subschema({
55
+ keyword: "patternProperties",
56
+ schemaProp: pat,
57
+ dataProp: key,
58
+ dataPropType: util_2.Type.Str,
59
+ }, valid);
60
+ }
61
+ if (it.opts.unevaluated && props !== true) {
62
+ gen.assign((0, codegen_1._) `${props}[${key}]`, true);
63
+ }
64
+ else if (!alwaysValid && !it.allErrors) {
65
+ // can short-circuit if `unevaluatedProperties` is not supported (opts.next === false)
66
+ // or if all properties were evaluated (props === true)
67
+ gen.if((0, codegen_1.not)(valid), () => gen.break());
68
+ }
69
+ });
70
+ });
71
+ }
72
+ },
73
+ };
74
+ exports.default = def;
75
+ //# sourceMappingURL=patternProperties.js.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const items_1 = require('./items.js');
4
+ const def = {
5
+ keyword: "prefixItems",
6
+ type: "array",
7
+ schemaType: ["array"],
8
+ before: "uniqueItems",
9
+ code: (cxt) => (0, items_1.validateTuple)(cxt, "items"),
10
+ };
11
+ exports.default = def;
12
+ //# sourceMappingURL=prefixItems.js.map
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const validate_1 = require('../../compile/validate/index.js');
4
+ const code_1 = require('../code.js');
5
+ const util_1 = require('../../compile/util.js');
6
+ const additionalProperties_1 = require('./additionalProperties.js');
7
+ const def = {
8
+ keyword: "properties",
9
+ type: "object",
10
+ schemaType: "object",
11
+ code(cxt) {
12
+ const { gen, schema, parentSchema, data, it } = cxt;
13
+ if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) {
14
+ additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties"));
15
+ }
16
+ const allProps = (0, code_1.allSchemaProperties)(schema);
17
+ for (const prop of allProps) {
18
+ it.definedProperties.add(prop);
19
+ }
20
+ if (it.opts.unevaluated && allProps.length && it.props !== true) {
21
+ it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props);
22
+ }
23
+ const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
24
+ if (properties.length === 0)
25
+ return;
26
+ const valid = gen.name("valid");
27
+ for (const prop of properties) {
28
+ if (hasDefault(prop)) {
29
+ applyPropertySchema(prop);
30
+ }
31
+ else {
32
+ gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties));
33
+ applyPropertySchema(prop);
34
+ if (!it.allErrors)
35
+ gen.else().var(valid, true);
36
+ gen.endIf();
37
+ }
38
+ cxt.it.definedProperties.add(prop);
39
+ cxt.ok(valid);
40
+ }
41
+ function hasDefault(prop) {
42
+ return it.opts.useDefaults && !it.compositeRule && schema[prop].default !== undefined;
43
+ }
44
+ function applyPropertySchema(prop) {
45
+ cxt.subschema({
46
+ keyword: "properties",
47
+ schemaProp: prop,
48
+ dataProp: prop,
49
+ }, valid);
50
+ }
51
+ },
52
+ };
53
+ exports.default = def;
54
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const codegen_1 = require('../../compile/codegen/index.js');
4
+ const util_1 = require('../../compile/util.js');
5
+ const error = {
6
+ message: "property name must be valid",
7
+ params: ({ params }) => (0, codegen_1._) `{propertyName: ${params.propertyName}}`,
8
+ };
9
+ const def = {
10
+ keyword: "propertyNames",
11
+ type: "object",
12
+ schemaType: ["object", "boolean"],
13
+ error,
14
+ code(cxt) {
15
+ const { gen, schema, data, it } = cxt;
16
+ if ((0, util_1.alwaysValidSchema)(it, schema))
17
+ return;
18
+ const valid = gen.name("valid");
19
+ gen.forIn("key", data, (key) => {
20
+ cxt.setParams({ propertyName: key });
21
+ cxt.subschema({
22
+ keyword: "propertyNames",
23
+ data: key,
24
+ dataTypes: ["string"],
25
+ propertyName: key,
26
+ compositeRule: true,
27
+ }, valid);
28
+ gen.if((0, codegen_1.not)(valid), () => {
29
+ cxt.error(true);
30
+ if (!it.allErrors)
31
+ gen.break();
32
+ });
33
+ });
34
+ cxt.ok(valid);
35
+ },
36
+ };
37
+ exports.default = def;
38
+ //# sourceMappingURL=propertyNames.js.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_1 = require('../../compile/util.js');
4
+ const def = {
5
+ keyword: ["then", "else"],
6
+ schemaType: ["object", "boolean"],
7
+ code({ keyword, parentSchema, it }) {
8
+ if (parentSchema.if === undefined)
9
+ (0, util_1.checkStrictMode)(it, `"${keyword}" without "if" is ignored`);
10
+ },
11
+ };
12
+ exports.default = def;
13
+ //# sourceMappingURL=thenElse.js.map
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0;
4
+ const codegen_1 = require('../compile/codegen/index.js');
5
+ const util_1 = require('../compile/util.js');
6
+ const names_1 = require('../compile/names.js');
7
+ const util_2 = require('../compile/util.js');
8
+ function checkReportMissingProp(cxt, prop) {
9
+ const { gen, data, it } = cxt;
10
+ gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
11
+ cxt.setParams({ missingProperty: (0, codegen_1._) `${prop}` }, true);
12
+ cxt.error();
13
+ });
14
+ }
15
+ exports.checkReportMissingProp = checkReportMissingProp;
16
+ function checkMissingProp({ gen, data, it: { opts } }, properties, missing) {
17
+ return (0, codegen_1.or)(...properties.map((prop) => (0, codegen_1.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1._) `${missing} = ${prop}`)));
18
+ }
19
+ exports.checkMissingProp = checkMissingProp;
20
+ function reportMissingProp(cxt, missing) {
21
+ cxt.setParams({ missingProperty: missing }, true);
22
+ cxt.error();
23
+ }
24
+ exports.reportMissingProp = reportMissingProp;
25
+ function hasPropFunc(gen) {
26
+ return gen.scopeValue("func", {
27
+ // eslint-disable-next-line @typescript-eslint/unbound-method
28
+ ref: Object.prototype.hasOwnProperty,
29
+ code: (0, codegen_1._) `Object.prototype.hasOwnProperty`,
30
+ });
31
+ }
32
+ exports.hasPropFunc = hasPropFunc;
33
+ function isOwnProperty(gen, data, property) {
34
+ return (0, codegen_1._) `${hasPropFunc(gen)}.call(${data}, ${property})`;
35
+ }
36
+ exports.isOwnProperty = isOwnProperty;
37
+ function propertyInData(gen, data, property, ownProperties) {
38
+ const cond = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(property)} !== undefined`;
39
+ return ownProperties ? (0, codegen_1._) `${cond} && ${isOwnProperty(gen, data, property)}` : cond;
40
+ }
41
+ exports.propertyInData = propertyInData;
42
+ function noPropertyInData(gen, data, property, ownProperties) {
43
+ const cond = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(property)} === undefined`;
44
+ return ownProperties ? (0, codegen_1.or)(cond, (0, codegen_1.not)(isOwnProperty(gen, data, property))) : cond;
45
+ }
46
+ exports.noPropertyInData = noPropertyInData;
47
+ function allSchemaProperties(schemaMap) {
48
+ return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
49
+ }
50
+ exports.allSchemaProperties = allSchemaProperties;
51
+ function schemaProperties(it, schemaMap) {
52
+ return allSchemaProperties(schemaMap).filter((p) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p]));
53
+ }
54
+ exports.schemaProperties = schemaProperties;
55
+ function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
56
+ const dataAndSchema = passSchema ? (0, codegen_1._) `${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
57
+ const valCxt = [
58
+ [names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, errorPath)],
59
+ [names_1.default.parentData, it.parentData],
60
+ [names_1.default.parentDataProperty, it.parentDataProperty],
61
+ [names_1.default.rootData, names_1.default.rootData],
62
+ ];
63
+ if (it.opts.dynamicRef)
64
+ valCxt.push([names_1.default.dynamicAnchors, names_1.default.dynamicAnchors]);
65
+ const args = (0, codegen_1._) `${dataAndSchema}, ${gen.object(...valCxt)}`;
66
+ return context !== codegen_1.nil ? (0, codegen_1._) `${func}.call(${context}, ${args})` : (0, codegen_1._) `${func}(${args})`;
67
+ }
68
+ exports.callValidateCode = callValidateCode;
69
+ const newRegExp = (0, codegen_1._) `new RegExp`;
70
+ function usePattern({ gen, it: { opts } }, pattern) {
71
+ const u = opts.unicodeRegExp ? "u" : "";
72
+ const { regExp } = opts.code;
73
+ const rx = regExp(pattern, u);
74
+ return gen.scopeValue("pattern", {
75
+ key: rx.toString(),
76
+ ref: rx,
77
+ code: (0, codegen_1._) `${regExp.code === "new RegExp" ? newRegExp : (0, util_2.useFunc)(gen, regExp)}(${pattern}, ${u})`,
78
+ });
79
+ }
80
+ exports.usePattern = usePattern;
81
+ function validateArray(cxt) {
82
+ const { gen, data, keyword, it } = cxt;
83
+ const valid = gen.name("valid");
84
+ if (it.allErrors) {
85
+ const validArr = gen.let("valid", true);
86
+ validateItems(() => gen.assign(validArr, false));
87
+ return validArr;
88
+ }
89
+ gen.var(valid, true);
90
+ validateItems(() => gen.break());
91
+ return valid;
92
+ function validateItems(notValid) {
93
+ const len = gen.const("len", (0, codegen_1._) `${data}.length`);
94
+ gen.forRange("i", 0, len, (i) => {
95
+ cxt.subschema({
96
+ keyword,
97
+ dataProp: i,
98
+ dataPropType: util_1.Type.Num,
99
+ }, valid);
100
+ gen.if((0, codegen_1.not)(valid), notValid);
101
+ });
102
+ }
103
+ }
104
+ exports.validateArray = validateArray;
105
+ function validateUnion(cxt) {
106
+ const { gen, schema, keyword, it } = cxt;
107
+ /* istanbul ignore if */
108
+ if (!Array.isArray(schema))
109
+ throw new Error("ajv implementation error");
110
+ const alwaysValid = schema.some((sch) => (0, util_1.alwaysValidSchema)(it, sch));
111
+ if (alwaysValid && !it.opts.unevaluated)
112
+ return;
113
+ const valid = gen.let("valid", false);
114
+ const schValid = gen.name("_valid");
115
+ gen.block(() => schema.forEach((_sch, i) => {
116
+ const schCxt = cxt.subschema({
117
+ keyword,
118
+ schemaProp: i,
119
+ compositeRule: true,
120
+ }, schValid);
121
+ gen.assign(valid, (0, codegen_1._) `${valid} || ${schValid}`);
122
+ const merged = cxt.mergeValidEvaluated(schCxt, schValid);
123
+ // can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true)
124
+ // or if all properties and items were evaluated (it.props === true && it.items === true)
125
+ if (!merged)
126
+ gen.if((0, codegen_1.not)(valid));
127
+ }));
128
+ cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
129
+ }
130
+ exports.validateUnion = validateUnion;
131
+ //# sourceMappingURL=code.js.map
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const def = {
4
+ keyword: "id",
5
+ code() {
6
+ throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID');
7
+ },
8
+ };
9
+ exports.default = def;
10
+ //# sourceMappingURL=id.js.map
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const id_1 = require('./id.js');
4
+ const ref_1 = require('./ref.js');
5
+ const core = [
6
+ "$schema",
7
+ "$id",
8
+ "$defs",
9
+ "$vocabulary",
10
+ { keyword: "$comment" },
11
+ "definitions",
12
+ id_1.default,
13
+ ref_1.default,
14
+ ];
15
+ exports.default = core;
16
+ //# sourceMappingURL=index.js.map