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

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 (209) hide show
  1. package/dist/adapter/common/FieldGroupWrap.d.ts +209 -0
  2. package/dist/adapter/field/ArrayField.d.ts +147 -0
  3. package/dist/adapter/field/BooleanField.d.ts +145 -0
  4. package/dist/adapter/field/CompositionField.d.ts +151 -0
  5. package/dist/adapter/field/FieldProps.d.ts +70 -0
  6. package/dist/adapter/field/NumberField.d.ts +145 -0
  7. package/dist/adapter/field/ObjectField.d.ts +147 -0
  8. package/dist/adapter/field/SchemaField.d.ts +145 -0
  9. package/dist/adapter/field/StringField.d.ts +4 -0
  10. package/dist/adapter/widget/ArrayWidget.d.ts +154 -0
  11. package/dist/adapter/widget/ButtonWidget.d.ts +16 -0
  12. package/dist/adapter/widget/CheckboxWidget.d.ts +34 -0
  13. package/dist/adapter/widget/CollapseGroupWidget.d.ts +196 -0
  14. package/dist/adapter/widget/ColorPickerWidget.d.ts +8 -0
  15. package/dist/adapter/widget/InputWidget.d.ts +30 -0
  16. package/dist/adapter/widget/KeyValueArrayWidget.d.ts +157 -0
  17. package/dist/adapter/widget/RadioWidget.d.ts +37 -0
  18. package/dist/adapter/widget/SelectWidget.d.ts +37 -0
  19. package/dist/adapter/widget/SwitchWidget.d.ts +10 -0
  20. package/dist/adapter/widget/TabGroupWidget.d.ts +187 -0
  21. package/dist/adapter/widget/TableWidget.d.ts +154 -0
  22. package/dist/adapter/widget/Widget.d.ts +182 -0
  23. package/dist/controller/form.d.ts +141 -0
  24. package/dist/controller/props.d.ts +62 -0
  25. package/dist/core/events.d.ts +10 -0
  26. package/dist/core/expression.d.ts +13 -0
  27. package/dist/core/form.d.ts +5 -0
  28. package/dist/core/lang.d.ts +1 -0
  29. package/dist/core/layout.d.ts +20 -0
  30. package/dist/core/lifecycle.d.ts +0 -0
  31. package/dist/core/path.d.ts +9 -0
  32. package/dist/core/proxy.d.ts +3 -0
  33. package/dist/core/reaction.d.ts +5 -0
  34. package/dist/core/register.d.ts +19 -0
  35. package/dist/core/schema.d.ts +26 -0
  36. package/dist/core/validator.d.ts +35 -0
  37. package/dist/core/widgetTree.d.ts +40 -0
  38. package/dist/index.d.ts +6 -0
  39. package/dist/index.es.js +7443 -0
  40. package/dist/index.umd.js +12 -0
  41. package/dist/style.css +1 -0
  42. package/dist/util/fetch.d.ts +10 -0
  43. package/dist/util/index.d.ts +23 -0
  44. package/package.json +24 -12
  45. package/esm/adapter/common/FieldGroupWrap.tsx.js +0 -199
  46. package/esm/adapter/field/ArrayField.tsx.js +0 -55
  47. package/esm/adapter/field/BooleanField.tsx.js +0 -41
  48. package/esm/adapter/field/CompositionField.tsx.js +0 -113
  49. package/esm/adapter/field/FieldProps.ts.js +0 -85
  50. package/esm/adapter/field/NumberField.tsx.js +0 -19
  51. package/esm/adapter/field/ObjectField.tsx.js +0 -58
  52. package/esm/adapter/field/SchemaField.tsx.js +0 -28
  53. package/esm/adapter/field/StringField.tsx.js +0 -4
  54. package/esm/adapter/widget/ArrayWidget.ts.js +0 -196
  55. package/esm/adapter/widget/ButtonWidget.ts.js +0 -76
  56. package/esm/adapter/widget/CheckboxWidget.ts.js +0 -101
  57. package/esm/adapter/widget/CollapseGroupWidget.ts.js +0 -140
  58. package/esm/adapter/widget/ColorPickerWidget.ts.js +0 -71
  59. package/esm/adapter/widget/InputWidget.ts.js +0 -79
  60. package/esm/adapter/widget/KeyValueArrayWidget.tsx.js +0 -156
  61. package/esm/adapter/widget/RadioWidget.ts.js +0 -98
  62. package/esm/adapter/widget/SelectWidget.ts.js +0 -98
  63. package/esm/adapter/widget/SwitchWidget.ts.js +0 -73
  64. package/esm/adapter/widget/TabGroupWidget.ts.js +0 -145
  65. package/esm/adapter/widget/TableWidget.ts.js +0 -205
  66. package/esm/adapter/widget/Widget.ts.js +0 -497
  67. package/esm/assets/fonts/iconcool.eot +0 -0
  68. package/esm/assets/fonts/iconcool.svg +0 -53
  69. package/esm/assets/fonts/iconcool.ttf +0 -0
  70. package/esm/assets/fonts/iconcool.woff +0 -0
  71. package/esm/assets/style.css +0 -43
  72. package/esm/controller/form.css +0 -164
  73. package/esm/controller/form.tsx.js +0 -159
  74. package/esm/controller/props.ts.js +0 -75
  75. package/esm/core/events.ts.js +0 -74
  76. package/esm/core/expression.ts.js +0 -67
  77. package/esm/core/lang.ts.js +0 -25
  78. package/esm/core/layout.ts.js +0 -149
  79. package/esm/core/path.ts.js +0 -60
  80. package/esm/core/proxy.ts.js +0 -10
  81. package/esm/core/reaction.ts.js +0 -116
  82. package/esm/core/register.ts.js +0 -74
  83. package/esm/core/schema.ts.js +0 -302
  84. package/esm/core/validator.ts.js +0 -248
  85. package/esm/core/widgetTree.ts.js +0 -163
  86. package/esm/index.ts.js +0 -6
  87. package/esm/node_modules/@blueking/cli-service/dist/lib/path.js +0 -35
  88. package/esm/node_modules/@blueking/cli-service/dist/lib/util.js +0 -233
  89. package/esm/node_modules/@blueking/cli-service/dist/tools/rust/helper/path.js +0 -172
  90. package/esm/node_modules/ajv/dist/ajv.js +0 -50
  91. package/esm/node_modules/ajv/dist/compile/codegen/code.js +0 -156
  92. package/esm/node_modules/ajv/dist/compile/codegen/index.js +0 -697
  93. package/esm/node_modules/ajv/dist/compile/codegen/scope.js +0 -143
  94. package/esm/node_modules/ajv/dist/compile/errors.js +0 -123
  95. package/esm/node_modules/ajv/dist/compile/index.js +0 -242
  96. package/esm/node_modules/ajv/dist/compile/names.js +0 -28
  97. package/esm/node_modules/ajv/dist/compile/ref_error.js +0 -12
  98. package/esm/node_modules/ajv/dist/compile/resolve.js +0 -155
  99. package/esm/node_modules/ajv/dist/compile/rules.js +0 -26
  100. package/esm/node_modules/ajv/dist/compile/util.js +0 -178
  101. package/esm/node_modules/ajv/dist/compile/validate/applicability.js +0 -19
  102. package/esm/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -50
  103. package/esm/node_modules/ajv/dist/compile/validate/dataType.js +0 -203
  104. package/esm/node_modules/ajv/dist/compile/validate/defaults.js +0 -35
  105. package/esm/node_modules/ajv/dist/compile/validate/index.js +0 -520
  106. package/esm/node_modules/ajv/dist/compile/validate/keyword.js +0 -124
  107. package/esm/node_modules/ajv/dist/compile/validate/subschema.js +0 -81
  108. package/esm/node_modules/ajv/dist/core.js +0 -618
  109. package/esm/node_modules/ajv/dist/refs/data.json +0 -13
  110. package/esm/node_modules/ajv/dist/refs/json-schema-draft-07.json +0 -151
  111. package/esm/node_modules/ajv/dist/runtime/equal.js +0 -7
  112. package/esm/node_modules/ajv/dist/runtime/ucs2length.js +0 -24
  113. package/esm/node_modules/ajv/dist/runtime/uri.js +0 -6
  114. package/esm/node_modules/ajv/dist/runtime/validation_error.js +0 -11
  115. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -49
  116. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -106
  117. package/esm/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -23
  118. package/esm/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -12
  119. package/esm/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -95
  120. package/esm/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -85
  121. package/esm/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -66
  122. package/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -44
  123. package/esm/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -52
  124. package/esm/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -30
  125. package/esm/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -26
  126. package/esm/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -60
  127. package/esm/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -75
  128. package/esm/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -12
  129. package/esm/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -54
  130. package/esm/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -38
  131. package/esm/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -13
  132. package/esm/node_modules/ajv/dist/vocabularies/code.js +0 -131
  133. package/esm/node_modules/ajv/dist/vocabularies/core/id.js +0 -10
  134. package/esm/node_modules/ajv/dist/vocabularies/core/index.js +0 -16
  135. package/esm/node_modules/ajv/dist/vocabularies/core/ref.js +0 -122
  136. package/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -104
  137. package/esm/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -9
  138. package/esm/node_modules/ajv/dist/vocabularies/draft7.js +0 -17
  139. package/esm/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
  140. package/esm/node_modules/ajv/dist/vocabularies/format/index.js +0 -6
  141. package/esm/node_modules/ajv/dist/vocabularies/metadata.js +0 -18
  142. package/esm/node_modules/ajv/dist/vocabularies/validation/const.js +0 -25
  143. package/esm/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -48
  144. package/esm/node_modules/ajv/dist/vocabularies/validation/index.js +0 -33
  145. package/esm/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -24
  146. package/esm/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -27
  147. package/esm/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -27
  148. package/esm/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -24
  149. package/esm/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -26
  150. package/esm/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -24
  151. package/esm/node_modules/ajv/dist/vocabularies/validation/required.js +0 -79
  152. package/esm/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -64
  153. package/esm/node_modules/ajv-formats/dist/formats.js +0 -173
  154. package/esm/node_modules/ajv-formats/dist/index.js +0 -37
  155. package/esm/node_modules/ajv-formats/dist/limit.js +0 -69
  156. package/esm/node_modules/ajv-i18n/localize/zh/index.js +0 -154
  157. package/esm/node_modules/fast-deep-equal/index.js +0 -46
  158. package/esm/node_modules/fast-uri/index.js +0 -303
  159. package/esm/node_modules/fast-uri/lib/schemes.js +0 -188
  160. package/esm/node_modules/fast-uri/lib/scopedChars.js +0 -30
  161. package/esm/node_modules/fast-uri/lib/utils.js +0 -244
  162. package/esm/node_modules/json-schema-traverse/index.js +0 -89
  163. package/esm/node_modules/semver/classes/comparator.js +0 -143
  164. package/esm/node_modules/semver/classes/range.js +0 -557
  165. package/esm/node_modules/semver/classes/semver.js +0 -333
  166. package/esm/node_modules/semver/functions/clean.js +0 -8
  167. package/esm/node_modules/semver/functions/cmp.js +0 -54
  168. package/esm/node_modules/semver/functions/coerce.js +0 -62
  169. package/esm/node_modules/semver/functions/compare-build.js +0 -9
  170. package/esm/node_modules/semver/functions/compare-loose.js +0 -5
  171. package/esm/node_modules/semver/functions/compare.js +0 -7
  172. package/esm/node_modules/semver/functions/diff.js +0 -60
  173. package/esm/node_modules/semver/functions/eq.js +0 -5
  174. package/esm/node_modules/semver/functions/gt.js +0 -5
  175. package/esm/node_modules/semver/functions/gte.js +0 -5
  176. package/esm/node_modules/semver/functions/inc.js +0 -21
  177. package/esm/node_modules/semver/functions/lt.js +0 -5
  178. package/esm/node_modules/semver/functions/lte.js +0 -5
  179. package/esm/node_modules/semver/functions/major.js +0 -5
  180. package/esm/node_modules/semver/functions/minor.js +0 -5
  181. package/esm/node_modules/semver/functions/neq.js +0 -5
  182. package/esm/node_modules/semver/functions/parse.js +0 -18
  183. package/esm/node_modules/semver/functions/patch.js +0 -5
  184. package/esm/node_modules/semver/functions/prerelease.js +0 -8
  185. package/esm/node_modules/semver/functions/rcompare.js +0 -5
  186. package/esm/node_modules/semver/functions/rsort.js +0 -5
  187. package/esm/node_modules/semver/functions/satisfies.js +0 -12
  188. package/esm/node_modules/semver/functions/sort.js +0 -5
  189. package/esm/node_modules/semver/functions/valid.js +0 -8
  190. package/esm/node_modules/semver/index.js +0 -91
  191. package/esm/node_modules/semver/internal/constants.js +0 -37
  192. package/esm/node_modules/semver/internal/debug.js +0 -11
  193. package/esm/node_modules/semver/internal/identifiers.js +0 -29
  194. package/esm/node_modules/semver/internal/lrucache.js +0 -42
  195. package/esm/node_modules/semver/internal/parse-options.js +0 -17
  196. package/esm/node_modules/semver/internal/re.js +0 -223
  197. package/esm/node_modules/semver/ranges/gtr.js +0 -6
  198. package/esm/node_modules/semver/ranges/intersects.js +0 -9
  199. package/esm/node_modules/semver/ranges/ltr.js +0 -6
  200. package/esm/node_modules/semver/ranges/max-satisfying.js +0 -27
  201. package/esm/node_modules/semver/ranges/min-satisfying.js +0 -26
  202. package/esm/node_modules/semver/ranges/min-version.js +0 -63
  203. package/esm/node_modules/semver/ranges/outside.js +0 -82
  204. package/esm/node_modules/semver/ranges/simplify.js +0 -49
  205. package/esm/node_modules/semver/ranges/subset.js +0 -249
  206. package/esm/node_modules/semver/ranges/to-comparators.js +0 -10
  207. package/esm/node_modules/semver/ranges/valid.js +0 -13
  208. package/esm/util/fetch.ts.js +0 -190
  209. package/esm/util/index.ts.js +0 -276
@@ -1,151 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "http://json-schema.org/draft-07/schema#",
4
- "title": "Core schema meta-schema",
5
- "definitions": {
6
- "schemaArray": {
7
- "type": "array",
8
- "minItems": 1,
9
- "items": {"$ref": "#"}
10
- },
11
- "nonNegativeInteger": {
12
- "type": "integer",
13
- "minimum": 0
14
- },
15
- "nonNegativeIntegerDefault0": {
16
- "allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
17
- },
18
- "simpleTypes": {
19
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
20
- },
21
- "stringArray": {
22
- "type": "array",
23
- "items": {"type": "string"},
24
- "uniqueItems": true,
25
- "default": []
26
- }
27
- },
28
- "type": ["object", "boolean"],
29
- "properties": {
30
- "$id": {
31
- "type": "string",
32
- "format": "uri-reference"
33
- },
34
- "$schema": {
35
- "type": "string",
36
- "format": "uri"
37
- },
38
- "$ref": {
39
- "type": "string",
40
- "format": "uri-reference"
41
- },
42
- "$comment": {
43
- "type": "string"
44
- },
45
- "title": {
46
- "type": "string"
47
- },
48
- "description": {
49
- "type": "string"
50
- },
51
- "default": true,
52
- "readOnly": {
53
- "type": "boolean",
54
- "default": false
55
- },
56
- "examples": {
57
- "type": "array",
58
- "items": true
59
- },
60
- "multipleOf": {
61
- "type": "number",
62
- "exclusiveMinimum": 0
63
- },
64
- "maximum": {
65
- "type": "number"
66
- },
67
- "exclusiveMaximum": {
68
- "type": "number"
69
- },
70
- "minimum": {
71
- "type": "number"
72
- },
73
- "exclusiveMinimum": {
74
- "type": "number"
75
- },
76
- "maxLength": {"$ref": "#/definitions/nonNegativeInteger"},
77
- "minLength": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
78
- "pattern": {
79
- "type": "string",
80
- "format": "regex"
81
- },
82
- "additionalItems": {"$ref": "#"},
83
- "items": {
84
- "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}],
85
- "default": true
86
- },
87
- "maxItems": {"$ref": "#/definitions/nonNegativeInteger"},
88
- "minItems": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
89
- "uniqueItems": {
90
- "type": "boolean",
91
- "default": false
92
- },
93
- "contains": {"$ref": "#"},
94
- "maxProperties": {"$ref": "#/definitions/nonNegativeInteger"},
95
- "minProperties": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
96
- "required": {"$ref": "#/definitions/stringArray"},
97
- "additionalProperties": {"$ref": "#"},
98
- "definitions": {
99
- "type": "object",
100
- "additionalProperties": {"$ref": "#"},
101
- "default": {}
102
- },
103
- "properties": {
104
- "type": "object",
105
- "additionalProperties": {"$ref": "#"},
106
- "default": {}
107
- },
108
- "patternProperties": {
109
- "type": "object",
110
- "additionalProperties": {"$ref": "#"},
111
- "propertyNames": {"format": "regex"},
112
- "default": {}
113
- },
114
- "dependencies": {
115
- "type": "object",
116
- "additionalProperties": {
117
- "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}]
118
- }
119
- },
120
- "propertyNames": {"$ref": "#"},
121
- "const": true,
122
- "enum": {
123
- "type": "array",
124
- "items": true,
125
- "minItems": 1,
126
- "uniqueItems": true
127
- },
128
- "type": {
129
- "anyOf": [
130
- {"$ref": "#/definitions/simpleTypes"},
131
- {
132
- "type": "array",
133
- "items": {"$ref": "#/definitions/simpleTypes"},
134
- "minItems": 1,
135
- "uniqueItems": true
136
- }
137
- ]
138
- },
139
- "format": {"type": "string"},
140
- "contentMediaType": {"type": "string"},
141
- "contentEncoding": {"type": "string"},
142
- "if": {"$ref": "#"},
143
- "then": {"$ref": "#"},
144
- "else": {"$ref": "#"},
145
- "allOf": {"$ref": "#/definitions/schemaArray"},
146
- "anyOf": {"$ref": "#/definitions/schemaArray"},
147
- "oneOf": {"$ref": "#/definitions/schemaArray"},
148
- "not": {"$ref": "#"}
149
- },
150
- "default": true
151
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // https://github.com/ajv-validator/ajv/issues/889
4
- const equal = require('../../../fast-deep-equal/index.js');
5
- equal.code = 'require("ajv/dist/runtime/equal").default';
6
- exports.default = equal;
7
- //# sourceMappingURL=equal.js.map
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // https://mathiasbynens.be/notes/javascript-encoding
4
- // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
5
- function ucs2length(str) {
6
- const len = str.length;
7
- let length = 0;
8
- let pos = 0;
9
- let value;
10
- while (pos < len) {
11
- length++;
12
- value = str.charCodeAt(pos++);
13
- if (value >= 0xd800 && value <= 0xdbff && pos < len) {
14
- // high surrogate, and there is a next character
15
- value = str.charCodeAt(pos);
16
- if ((value & 0xfc00) === 0xdc00)
17
- pos++; // low surrogate
18
- }
19
- }
20
- return length;
21
- }
22
- exports.default = ucs2length;
23
- ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default';
24
- //# sourceMappingURL=ucs2length.js.map
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const uri = require('../../../fast-uri/index.js');
4
- uri.code = 'require("ajv/dist/runtime/uri").default';
5
- exports.default = uri;
6
- //# sourceMappingURL=uri.js.map
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ValidationError extends Error {
4
- constructor(errors) {
5
- super("validation failed");
6
- this.errors = errors;
7
- this.ajv = this.validation = true;
8
- }
9
- }
10
- exports.default = ValidationError;
11
- //# sourceMappingURL=validation_error.js.map
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateAdditionalItems = void 0;
4
- const codegen_1 = require('../../compile/codegen/index.js');
5
- const util_1 = require('../../compile/util.js');
6
- const error = {
7
- message: ({ params: { len } }) => (0, codegen_1.str) `must NOT have more than ${len} items`,
8
- params: ({ params: { len } }) => (0, codegen_1._) `{limit: ${len}}`,
9
- };
10
- const def = {
11
- keyword: "additionalItems",
12
- type: "array",
13
- schemaType: ["boolean", "object"],
14
- before: "uniqueItems",
15
- error,
16
- code(cxt) {
17
- const { parentSchema, it } = cxt;
18
- const { items } = parentSchema;
19
- if (!Array.isArray(items)) {
20
- (0, util_1.checkStrictMode)(it, '"additionalItems" is ignored when "items" is not an array of schemas');
21
- return;
22
- }
23
- validateAdditionalItems(cxt, items);
24
- },
25
- };
26
- function validateAdditionalItems(cxt, items) {
27
- const { gen, schema, data, keyword, it } = cxt;
28
- it.items = true;
29
- const len = gen.const("len", (0, codegen_1._) `${data}.length`);
30
- if (schema === false) {
31
- cxt.setParams({ len: items.length });
32
- cxt.pass((0, codegen_1._) `${len} <= ${items.length}`);
33
- }
34
- else if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
35
- const valid = gen.var("valid", (0, codegen_1._) `${len} <= ${items.length}`); // TODO var
36
- gen.if((0, codegen_1.not)(valid), () => validateItems(valid));
37
- cxt.ok(valid);
38
- }
39
- function validateItems(valid) {
40
- gen.forRange("i", items.length, len, (i) => {
41
- cxt.subschema({ keyword, dataProp: i, dataPropType: util_1.Type.Num }, valid);
42
- if (!it.allErrors)
43
- gen.if((0, codegen_1.not)(valid), () => gen.break());
44
- });
45
- }
46
- }
47
- exports.validateAdditionalItems = validateAdditionalItems;
48
- exports.default = def;
49
- //# sourceMappingURL=additionalItems.js.map
@@ -1,106 +0,0 @@
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 names_1 = require('../../compile/names.js');
6
- const util_1 = require('../../compile/util.js');
7
- const error = {
8
- message: "must NOT have additional properties",
9
- params: ({ params }) => (0, codegen_1._) `{additionalProperty: ${params.additionalProperty}}`,
10
- };
11
- const def = {
12
- keyword: "additionalProperties",
13
- type: ["object"],
14
- schemaType: ["boolean", "object"],
15
- allowUndefined: true,
16
- trackErrors: true,
17
- error,
18
- code(cxt) {
19
- const { gen, schema, parentSchema, data, errsCount, it } = cxt;
20
- /* istanbul ignore if */
21
- if (!errsCount)
22
- throw new Error("ajv implementation error");
23
- const { allErrors, opts } = it;
24
- it.props = true;
25
- if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema))
26
- return;
27
- const props = (0, code_1.allSchemaProperties)(parentSchema.properties);
28
- const patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties);
29
- checkAdditionalProperties();
30
- cxt.ok((0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
31
- function checkAdditionalProperties() {
32
- gen.forIn("key", data, (key) => {
33
- if (!props.length && !patProps.length)
34
- additionalPropertyCode(key);
35
- else
36
- gen.if(isAdditional(key), () => additionalPropertyCode(key));
37
- });
38
- }
39
- function isAdditional(key) {
40
- let definedProp;
41
- if (props.length > 8) {
42
- // TODO maybe an option instead of hard-coded 8?
43
- const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
44
- definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key);
45
- }
46
- else if (props.length) {
47
- definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._) `${key} === ${p}`));
48
- }
49
- else {
50
- definedProp = codegen_1.nil;
51
- }
52
- if (patProps.length) {
53
- definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._) `${(0, code_1.usePattern)(cxt, p)}.test(${key})`));
54
- }
55
- return (0, codegen_1.not)(definedProp);
56
- }
57
- function deleteAdditional(key) {
58
- gen.code((0, codegen_1._) `delete ${data}[${key}]`);
59
- }
60
- function additionalPropertyCode(key) {
61
- if (opts.removeAdditional === "all" || (opts.removeAdditional && schema === false)) {
62
- deleteAdditional(key);
63
- return;
64
- }
65
- if (schema === false) {
66
- cxt.setParams({ additionalProperty: key });
67
- cxt.error();
68
- if (!allErrors)
69
- gen.break();
70
- return;
71
- }
72
- if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
73
- const valid = gen.name("valid");
74
- if (opts.removeAdditional === "failing") {
75
- applyAdditionalSchema(key, valid, false);
76
- gen.if((0, codegen_1.not)(valid), () => {
77
- cxt.reset();
78
- deleteAdditional(key);
79
- });
80
- }
81
- else {
82
- applyAdditionalSchema(key, valid);
83
- if (!allErrors)
84
- gen.if((0, codegen_1.not)(valid), () => gen.break());
85
- }
86
- }
87
- }
88
- function applyAdditionalSchema(key, valid, errors) {
89
- const subschema = {
90
- keyword: "additionalProperties",
91
- dataProp: key,
92
- dataPropType: util_1.Type.Str,
93
- };
94
- if (errors === false) {
95
- Object.assign(subschema, {
96
- compositeRule: true,
97
- createErrors: false,
98
- allErrors: false,
99
- });
100
- }
101
- cxt.subschema(subschema, valid);
102
- }
103
- },
104
- };
105
- exports.default = def;
106
- //# sourceMappingURL=additionalProperties.js.map
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const util_1 = require('../../compile/util.js');
4
- const def = {
5
- keyword: "allOf",
6
- schemaType: "array",
7
- code(cxt) {
8
- const { gen, schema, it } = cxt;
9
- /* istanbul ignore if */
10
- if (!Array.isArray(schema))
11
- throw new Error("ajv implementation error");
12
- const valid = gen.name("valid");
13
- schema.forEach((sch, i) => {
14
- if ((0, util_1.alwaysValidSchema)(it, sch))
15
- return;
16
- const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid);
17
- cxt.ok(valid);
18
- cxt.mergeEvaluated(schCxt);
19
- });
20
- },
21
- };
22
- exports.default = def;
23
- //# sourceMappingURL=allOf.js.map
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const code_1 = require('../code.js');
4
- const def = {
5
- keyword: "anyOf",
6
- schemaType: "array",
7
- trackErrors: true,
8
- code: code_1.validateUnion,
9
- error: { message: "must match a schema in anyOf" },
10
- };
11
- exports.default = def;
12
- //# sourceMappingURL=anyOf.js.map
@@ -1,95 +0,0 @@
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: ({ params: { min, max } }) => max === undefined
7
- ? (0, codegen_1.str) `must contain at least ${min} valid item(s)`
8
- : (0, codegen_1.str) `must contain at least ${min} and no more than ${max} valid item(s)`,
9
- params: ({ params: { min, max } }) => max === undefined ? (0, codegen_1._) `{minContains: ${min}}` : (0, codegen_1._) `{minContains: ${min}, maxContains: ${max}}`,
10
- };
11
- const def = {
12
- keyword: "contains",
13
- type: "array",
14
- schemaType: ["object", "boolean"],
15
- before: "uniqueItems",
16
- trackErrors: true,
17
- error,
18
- code(cxt) {
19
- const { gen, schema, parentSchema, data, it } = cxt;
20
- let min;
21
- let max;
22
- const { minContains, maxContains } = parentSchema;
23
- if (it.opts.next) {
24
- min = minContains === undefined ? 1 : minContains;
25
- max = maxContains;
26
- }
27
- else {
28
- min = 1;
29
- }
30
- const len = gen.const("len", (0, codegen_1._) `${data}.length`);
31
- cxt.setParams({ min, max });
32
- if (max === undefined && min === 0) {
33
- (0, util_1.checkStrictMode)(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`);
34
- return;
35
- }
36
- if (max !== undefined && min > max) {
37
- (0, util_1.checkStrictMode)(it, `"minContains" > "maxContains" is always invalid`);
38
- cxt.fail();
39
- return;
40
- }
41
- if ((0, util_1.alwaysValidSchema)(it, schema)) {
42
- let cond = (0, codegen_1._) `${len} >= ${min}`;
43
- if (max !== undefined)
44
- cond = (0, codegen_1._) `${cond} && ${len} <= ${max}`;
45
- cxt.pass(cond);
46
- return;
47
- }
48
- it.items = true;
49
- const valid = gen.name("valid");
50
- if (max === undefined && min === 1) {
51
- validateItems(valid, () => gen.if(valid, () => gen.break()));
52
- }
53
- else if (min === 0) {
54
- gen.let(valid, true);
55
- if (max !== undefined)
56
- gen.if((0, codegen_1._) `${data}.length > 0`, validateItemsWithCount);
57
- }
58
- else {
59
- gen.let(valid, false);
60
- validateItemsWithCount();
61
- }
62
- cxt.result(valid, () => cxt.reset());
63
- function validateItemsWithCount() {
64
- const schValid = gen.name("_valid");
65
- const count = gen.let("count", 0);
66
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
67
- }
68
- function validateItems(_valid, block) {
69
- gen.forRange("i", 0, len, (i) => {
70
- cxt.subschema({
71
- keyword: "contains",
72
- dataProp: i,
73
- dataPropType: util_1.Type.Num,
74
- compositeRule: true,
75
- }, _valid);
76
- block();
77
- });
78
- }
79
- function checkLimits(count) {
80
- gen.code((0, codegen_1._) `${count}++`);
81
- if (max === undefined) {
82
- gen.if((0, codegen_1._) `${count} >= ${min}`, () => gen.assign(valid, true).break());
83
- }
84
- else {
85
- gen.if((0, codegen_1._) `${count} > ${max}`, () => gen.assign(valid, false).break());
86
- if (min === 1)
87
- gen.assign(valid, true);
88
- else
89
- gen.if((0, codegen_1._) `${count} >= ${min}`, () => gen.assign(valid, true));
90
- }
91
- }
92
- },
93
- };
94
- exports.default = def;
95
- //# sourceMappingURL=contains.js.map
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = 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
- exports.error = {
8
- message: ({ params: { property, depsCount, deps } }) => {
9
- const property_ies = depsCount === 1 ? "property" : "properties";
10
- return (0, codegen_1.str) `must have ${property_ies} ${deps} when property ${property} is present`;
11
- },
12
- params: ({ params: { property, depsCount, deps, missingProperty } }) => (0, codegen_1._) `{property: ${property},
13
- missingProperty: ${missingProperty},
14
- depsCount: ${depsCount},
15
- deps: ${deps}}`, // TODO change to reference
16
- };
17
- const def = {
18
- keyword: "dependencies",
19
- type: "object",
20
- schemaType: "object",
21
- error: exports.error,
22
- code(cxt) {
23
- const [propDeps, schDeps] = splitDependencies(cxt);
24
- validatePropertyDeps(cxt, propDeps);
25
- validateSchemaDeps(cxt, schDeps);
26
- },
27
- };
28
- function splitDependencies({ schema }) {
29
- const propertyDeps = {};
30
- const schemaDeps = {};
31
- for (const key in schema) {
32
- if (key === "__proto__")
33
- continue;
34
- const deps = Array.isArray(schema[key]) ? propertyDeps : schemaDeps;
35
- deps[key] = schema[key];
36
- }
37
- return [propertyDeps, schemaDeps];
38
- }
39
- function validatePropertyDeps(cxt, propertyDeps = cxt.schema) {
40
- const { gen, data, it } = cxt;
41
- if (Object.keys(propertyDeps).length === 0)
42
- return;
43
- const missing = gen.let("missing");
44
- for (const prop in propertyDeps) {
45
- const deps = propertyDeps[prop];
46
- if (deps.length === 0)
47
- continue;
48
- const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties);
49
- cxt.setParams({
50
- property: prop,
51
- depsCount: deps.length,
52
- deps: deps.join(", "),
53
- });
54
- if (it.allErrors) {
55
- gen.if(hasProperty, () => {
56
- for (const depProp of deps) {
57
- (0, code_1.checkReportMissingProp)(cxt, depProp);
58
- }
59
- });
60
- }
61
- else {
62
- gen.if((0, codegen_1._) `${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`);
63
- (0, code_1.reportMissingProp)(cxt, missing);
64
- gen.else();
65
- }
66
- }
67
- }
68
- exports.validatePropertyDeps = validatePropertyDeps;
69
- function validateSchemaDeps(cxt, schemaDeps = cxt.schema) {
70
- const { gen, data, keyword, it } = cxt;
71
- const valid = gen.name("valid");
72
- for (const prop in schemaDeps) {
73
- if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop]))
74
- continue;
75
- gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), () => {
76
- const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid);
77
- cxt.mergeValidEvaluated(schCxt, valid);
78
- }, () => gen.var(valid, true) // TODO var
79
- );
80
- cxt.ok(valid);
81
- }
82
- }
83
- exports.validateSchemaDeps = validateSchemaDeps;
84
- exports.default = def;
85
- //# sourceMappingURL=dependencies.js.map
@@ -1,66 +0,0 @@
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: ({ params }) => (0, codegen_1.str) `must match "${params.ifClause}" schema`,
7
- params: ({ params }) => (0, codegen_1._) `{failingKeyword: ${params.ifClause}}`,
8
- };
9
- const def = {
10
- keyword: "if",
11
- schemaType: ["object", "boolean"],
12
- trackErrors: true,
13
- error,
14
- code(cxt) {
15
- const { gen, parentSchema, it } = cxt;
16
- if (parentSchema.then === undefined && parentSchema.else === undefined) {
17
- (0, util_1.checkStrictMode)(it, '"if" without "then" and "else" is ignored');
18
- }
19
- const hasThen = hasSchema(it, "then");
20
- const hasElse = hasSchema(it, "else");
21
- if (!hasThen && !hasElse)
22
- return;
23
- const valid = gen.let("valid", true);
24
- const schValid = gen.name("_valid");
25
- validateIf();
26
- cxt.reset();
27
- if (hasThen && hasElse) {
28
- const ifClause = gen.let("ifClause");
29
- cxt.setParams({ ifClause });
30
- gen.if(schValid, validateClause("then", ifClause), validateClause("else", ifClause));
31
- }
32
- else if (hasThen) {
33
- gen.if(schValid, validateClause("then"));
34
- }
35
- else {
36
- gen.if((0, codegen_1.not)(schValid), validateClause("else"));
37
- }
38
- cxt.pass(valid, () => cxt.error(true));
39
- function validateIf() {
40
- const schCxt = cxt.subschema({
41
- keyword: "if",
42
- compositeRule: true,
43
- createErrors: false,
44
- allErrors: false,
45
- }, schValid);
46
- cxt.mergeEvaluated(schCxt);
47
- }
48
- function validateClause(keyword, ifClause) {
49
- return () => {
50
- const schCxt = cxt.subschema({ keyword }, schValid);
51
- gen.assign(valid, schValid);
52
- cxt.mergeValidEvaluated(schCxt, valid);
53
- if (ifClause)
54
- gen.assign(ifClause, (0, codegen_1._) `${keyword}`);
55
- else
56
- cxt.setParams({ ifClause: keyword });
57
- };
58
- }
59
- },
60
- };
61
- function hasSchema(it, keyword) {
62
- const schema = it.schema[keyword];
63
- return schema !== undefined && !(0, util_1.alwaysValidSchema)(it, schema);
64
- }
65
- exports.default = def;
66
- //# sourceMappingURL=if.js.map