@tachybase/schema 0.23.41 → 0.23.48

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 (273) hide show
  1. package/lib/core/effects/index.d.ts +2 -0
  2. package/lib/core/effects/index.js +23 -0
  3. package/lib/core/effects/onFieldEffects.d.ts +27 -0
  4. package/lib/core/effects/onFieldEffects.js +158 -0
  5. package/lib/core/effects/onFormEffects.d.ts +24 -0
  6. package/lib/core/effects/onFormEffects.js +117 -0
  7. package/lib/core/global.d.js +0 -0
  8. package/lib/core/index.d.ts +4 -0
  9. package/lib/core/index.js +27 -0
  10. package/lib/core/models/ArrayField.d.ts +17 -0
  11. package/lib/core/models/ArrayField.js +145 -0
  12. package/lib/core/models/BaseField.d.ts +72 -0
  13. package/lib/core/models/BaseField.js +285 -0
  14. package/lib/core/models/Field.d.ts +70 -0
  15. package/lib/core/models/Field.js +426 -0
  16. package/lib/core/models/Form.d.ts +102 -0
  17. package/lib/core/models/Form.js +483 -0
  18. package/lib/core/models/Graph.d.ts +8 -0
  19. package/lib/core/models/Graph.js +77 -0
  20. package/lib/core/models/Heart.d.ts +16 -0
  21. package/lib/core/models/Heart.js +91 -0
  22. package/lib/core/models/LifeCycle.d.ts +14 -0
  23. package/lib/core/models/LifeCycle.js +64 -0
  24. package/lib/core/models/ObjectField.d.ts +12 -0
  25. package/lib/core/models/ObjectField.js +64 -0
  26. package/lib/core/models/Query.d.ts +18 -0
  27. package/lib/core/models/Query.js +105 -0
  28. package/lib/core/models/VoidField.d.ts +14 -0
  29. package/lib/core/models/VoidField.js +117 -0
  30. package/lib/core/models/index.d.ts +9 -0
  31. package/lib/core/models/index.js +37 -0
  32. package/lib/core/models/types.d.ts +9 -0
  33. package/lib/core/models/types.js +15 -0
  34. package/lib/core/shared/checkers.d.ts +117 -0
  35. package/lib/core/shared/checkers.js +109 -0
  36. package/lib/core/shared/constants.d.ts +48 -0
  37. package/lib/core/shared/constants.js +86 -0
  38. package/lib/core/shared/effective.d.ts +9 -0
  39. package/lib/core/shared/effective.js +91 -0
  40. package/lib/core/shared/externals.d.ts +8 -0
  41. package/lib/core/shared/externals.js +87 -0
  42. package/lib/core/shared/internals.d.ts +54 -0
  43. package/lib/core/shared/internals.js +956 -0
  44. package/lib/core/types.d.ts +275 -0
  45. package/lib/core/types.js +76 -0
  46. package/lib/grid/index.d.ts +67 -0
  47. package/lib/grid/index.js +378 -0
  48. package/lib/grid/observer.d.ts +19 -0
  49. package/lib/grid/observer.js +107 -0
  50. package/lib/index.d.ts +12 -24
  51. package/lib/index.js +27 -244
  52. package/lib/json-schema/compiler.d.ts +8 -0
  53. package/lib/json-schema/compiler.js +129 -0
  54. package/lib/json-schema/global.d.js +0 -0
  55. package/lib/json-schema/index.d.ts +2 -0
  56. package/lib/json-schema/index.js +23 -0
  57. package/lib/json-schema/patches.d.ts +5 -0
  58. package/lib/json-schema/patches.js +68 -0
  59. package/lib/json-schema/polyfills/SPECIFICATION_1_0.d.ts +2 -0
  60. package/lib/json-schema/polyfills/SPECIFICATION_1_0.js +132 -0
  61. package/lib/json-schema/polyfills/index.d.ts +1 -0
  62. package/lib/json-schema/polyfills/index.js +21 -0
  63. package/lib/json-schema/schema.d.ts +88 -0
  64. package/lib/json-schema/schema.js +231 -0
  65. package/lib/json-schema/shared.d.ts +62 -0
  66. package/lib/json-schema/shared.js +232 -0
  67. package/lib/json-schema/transformer.d.ts +4 -0
  68. package/lib/json-schema/transformer.js +238 -0
  69. package/lib/json-schema/types.d.ts +119 -0
  70. package/lib/json-schema/types.js +15 -0
  71. package/lib/path/contexts.d.ts +10 -0
  72. package/lib/path/contexts.js +49 -0
  73. package/lib/path/destructor.d.ts +15 -0
  74. package/lib/path/destructor.js +151 -0
  75. package/lib/path/index.d.ts +51 -0
  76. package/lib/path/index.js +513 -0
  77. package/lib/path/matcher.d.ts +33 -0
  78. package/lib/path/matcher.js +197 -0
  79. package/lib/path/parser.d.ts +33 -0
  80. package/lib/path/parser.js +379 -0
  81. package/lib/path/shared.d.ts +13 -0
  82. package/lib/path/shared.js +121 -0
  83. package/lib/path/tokenizer.d.ts +27 -0
  84. package/lib/path/tokenizer.js +269 -0
  85. package/lib/path/tokens.d.ts +27 -0
  86. package/lib/path/tokens.js +216 -0
  87. package/lib/path/types.d.ts +88 -0
  88. package/lib/path/types.js +63 -0
  89. package/lib/react/components/ArrayField.d.ts +6 -0
  90. package/lib/react/components/ArrayField.js +44 -0
  91. package/lib/react/components/ExpressionScope.d.ts +2 -0
  92. package/lib/react/components/ExpressionScope.js +35 -0
  93. package/lib/react/components/Field.d.ts +5 -0
  94. package/lib/react/components/Field.js +45 -0
  95. package/lib/react/components/FormConsumer.d.ts +2 -0
  96. package/lib/react/components/FormConsumer.js +36 -0
  97. package/lib/react/components/FormProvider.d.ts +2 -0
  98. package/lib/react/components/FormProvider.js +35 -0
  99. package/lib/react/components/ObjectField.d.ts +6 -0
  100. package/lib/react/components/ObjectField.js +39 -0
  101. package/lib/react/components/ReactiveField.d.ts +11 -0
  102. package/lib/react/components/ReactiveField.js +115 -0
  103. package/lib/react/components/RecordScope.d.ts +2 -0
  104. package/lib/react/components/RecordScope.js +65 -0
  105. package/lib/react/components/RecordsScope.d.ts +2 -0
  106. package/lib/react/components/RecordsScope.js +43 -0
  107. package/lib/react/components/RecursionField.d.ts +2 -0
  108. package/lib/react/components/RecursionField.js +105 -0
  109. package/lib/react/components/SchemaField.d.ts +41 -0
  110. package/lib/react/components/SchemaField.js +154 -0
  111. package/lib/react/components/VoidField.d.ts +5 -0
  112. package/lib/react/components/VoidField.js +39 -0
  113. package/lib/react/components/index.d.ts +11 -0
  114. package/lib/react/components/index.js +41 -0
  115. package/lib/react/global.d.js +0 -0
  116. package/lib/react/hooks/index.d.ts +6 -0
  117. package/lib/react/hooks/index.js +31 -0
  118. package/lib/react/hooks/useAttach.d.ts +6 -0
  119. package/lib/react/hooks/useAttach.js +35 -0
  120. package/lib/react/hooks/useExpressionScope.d.ts +1 -0
  121. package/lib/react/hooks/useExpressionScope.js +30 -0
  122. package/lib/react/hooks/useField.d.ts +2 -0
  123. package/lib/react/hooks/useField.js +32 -0
  124. package/lib/react/hooks/useFieldSchema.d.ts +2 -0
  125. package/lib/react/hooks/useFieldSchema.js +32 -0
  126. package/lib/react/hooks/useForm.d.ts +2 -0
  127. package/lib/react/hooks/useForm.js +32 -0
  128. package/lib/react/hooks/useFormEffects.d.ts +2 -0
  129. package/lib/react/hooks/useFormEffects.js +42 -0
  130. package/lib/react/hooks/useParentForm.d.ts +2 -0
  131. package/lib/react/hooks/useParentForm.js +40 -0
  132. package/lib/react/index.d.ts +5 -0
  133. package/lib/react/index.js +29 -0
  134. package/lib/react/shared/connect.d.ts +9 -0
  135. package/lib/react/shared/connect.js +118 -0
  136. package/lib/react/shared/context.d.ts +14 -0
  137. package/lib/react/shared/context.js +74 -0
  138. package/lib/react/shared/index.d.ts +2 -0
  139. package/lib/react/shared/index.js +23 -0
  140. package/lib/react/shared/render.d.ts +2 -0
  141. package/lib/react/shared/render.js +69 -0
  142. package/lib/react/types.d.ts +84 -0
  143. package/lib/react/types.js +15 -0
  144. package/lib/reactive/action.d.ts +2 -0
  145. package/lib/reactive/action.js +48 -0
  146. package/lib/reactive/annotations/box.d.ts +7 -0
  147. package/lib/reactive/annotations/box.js +76 -0
  148. package/lib/reactive/annotations/computed.d.ts +12 -0
  149. package/lib/reactive/annotations/computed.js +154 -0
  150. package/lib/reactive/annotations/index.d.ts +5 -0
  151. package/lib/reactive/annotations/index.js +29 -0
  152. package/lib/reactive/annotations/observable.d.ts +4 -0
  153. package/lib/reactive/annotations/observable.js +67 -0
  154. package/lib/reactive/annotations/ref.d.ts +6 -0
  155. package/lib/reactive/annotations/ref.js +78 -0
  156. package/lib/reactive/annotations/shallow.d.ts +2 -0
  157. package/lib/reactive/annotations/shallow.js +67 -0
  158. package/lib/reactive/array.d.ts +12 -0
  159. package/lib/reactive/array.js +83 -0
  160. package/lib/reactive/autorun.d.ts +7 -0
  161. package/lib/reactive/autorun.js +155 -0
  162. package/lib/reactive/batch.d.ts +2 -0
  163. package/lib/reactive/batch.js +40 -0
  164. package/lib/reactive/checkers.d.ts +10 -0
  165. package/lib/reactive/checkers.js +60 -0
  166. package/lib/reactive/environment.d.ts +28 -0
  167. package/lib/reactive/environment.js +76 -0
  168. package/lib/reactive/externals.d.ts +10 -0
  169. package/lib/reactive/externals.js +156 -0
  170. package/lib/reactive/global.d.js +0 -0
  171. package/lib/reactive/handlers.d.ts +4 -0
  172. package/lib/reactive/handlers.js +246 -0
  173. package/lib/reactive/index.d.ts +10 -0
  174. package/lib/reactive/index.js +39 -0
  175. package/lib/reactive/internals.d.ts +17 -0
  176. package/lib/reactive/internals.js +139 -0
  177. package/lib/reactive/model.d.ts +3 -0
  178. package/lib/reactive/model.js +68 -0
  179. package/lib/reactive/observable.d.ts +9 -0
  180. package/lib/reactive/observable.js +50 -0
  181. package/lib/reactive/observe.d.ts +2 -0
  182. package/lib/reactive/observe.js +58 -0
  183. package/lib/reactive/reaction.d.ts +21 -0
  184. package/lib/reactive/reaction.js +278 -0
  185. package/lib/reactive/tracker.d.ts +7 -0
  186. package/lib/reactive/tracker.js +63 -0
  187. package/lib/reactive/tree.d.ts +25 -0
  188. package/lib/reactive/tree.js +106 -0
  189. package/lib/reactive/types.d.ts +79 -0
  190. package/lib/reactive/types.js +21 -0
  191. package/lib/reactive/untracked.d.ts +4 -0
  192. package/lib/reactive/untracked.js +29 -0
  193. package/lib/reactive-react/hooks/index.d.ts +9 -0
  194. package/lib/reactive-react/hooks/index.js +48 -0
  195. package/lib/reactive-react/hooks/useCompatEffect.d.ts +2 -0
  196. package/lib/reactive-react/hooks/useCompatEffect.js +60 -0
  197. package/lib/reactive-react/hooks/useCompatFactory.d.ts +3 -0
  198. package/lib/reactive-react/hooks/useCompatFactory.js +74 -0
  199. package/lib/reactive-react/hooks/useDidUpdate.d.ts +1 -0
  200. package/lib/reactive-react/hooks/useDidUpdate.js +38 -0
  201. package/lib/reactive-react/hooks/useForceUpdate.d.ts +1 -0
  202. package/lib/reactive-react/hooks/useForceUpdate.js +76 -0
  203. package/lib/reactive-react/hooks/useLayoutEffect.d.ts +2 -0
  204. package/lib/reactive-react/hooks/useLayoutEffect.js +28 -0
  205. package/lib/reactive-react/hooks/useObserver.d.ts +2 -0
  206. package/lib/reactive-react/hooks/useObserver.js +43 -0
  207. package/lib/reactive-react/index.d.ts +3 -0
  208. package/lib/reactive-react/index.js +25 -0
  209. package/lib/reactive-react/observer.d.ts +8 -0
  210. package/lib/reactive-react/observer.js +64 -0
  211. package/lib/reactive-react/shared/gc.d.ts +8 -0
  212. package/lib/reactive-react/shared/gc.js +59 -0
  213. package/lib/reactive-react/shared/global.d.ts +1 -0
  214. package/lib/reactive-react/shared/global.js +50 -0
  215. package/lib/reactive-react/shared/immediate.d.ts +1 -0
  216. package/lib/reactive-react/shared/immediate.js +40 -0
  217. package/lib/reactive-react/shared/index.d.ts +2 -0
  218. package/lib/reactive-react/shared/index.js +23 -0
  219. package/lib/reactive-react/types.d.ts +14 -0
  220. package/lib/reactive-react/types.js +15 -0
  221. package/lib/shared/array.d.ts +35 -0
  222. package/lib/shared/array.js +189 -0
  223. package/lib/shared/case.d.ts +6 -0
  224. package/lib/shared/case.js +39 -0
  225. package/lib/shared/checkers.d.ts +21 -0
  226. package/lib/shared/checkers.js +77 -0
  227. package/lib/shared/clone.d.ts +2 -0
  228. package/lib/shared/clone.js +97 -0
  229. package/lib/shared/compare.d.ts +1 -0
  230. package/lib/shared/compare.js +129 -0
  231. package/lib/shared/defaults.d.ts +6 -0
  232. package/lib/shared/defaults.js +63 -0
  233. package/lib/shared/deprecate.d.ts +1 -0
  234. package/lib/shared/deprecate.js +42 -0
  235. package/lib/shared/global.d.ts +1 -0
  236. package/lib/shared/global.js +50 -0
  237. package/lib/shared/index.d.ts +16 -0
  238. package/lib/shared/index.js +51 -0
  239. package/lib/shared/instanceof.d.ts +1 -0
  240. package/lib/shared/instanceof.js +36 -0
  241. package/lib/shared/isEmpty.d.ts +3 -0
  242. package/lib/shared/isEmpty.js +94 -0
  243. package/lib/shared/merge.d.ts +12 -0
  244. package/lib/shared/merge.js +214 -0
  245. package/lib/shared/middleware.d.ts +4 -0
  246. package/lib/shared/middleware.js +41 -0
  247. package/lib/shared/path.d.ts +3 -0
  248. package/lib/shared/path.js +27 -0
  249. package/lib/shared/string.d.ts +1 -0
  250. package/lib/shared/string.js +38 -0
  251. package/lib/shared/subscribable.d.ts +11 -0
  252. package/lib/shared/subscribable.js +74 -0
  253. package/lib/shared/uid.d.ts +1 -0
  254. package/lib/shared/uid.js +35 -0
  255. package/lib/validator/formats.d.ts +16 -0
  256. package/lib/validator/formats.js +40 -0
  257. package/lib/validator/index.d.ts +4 -0
  258. package/lib/validator/index.js +27 -0
  259. package/lib/validator/locale.d.ts +219 -0
  260. package/lib/validator/locale.js +240 -0
  261. package/lib/validator/parser.d.ts +5 -0
  262. package/lib/validator/parser.js +153 -0
  263. package/lib/validator/registry.d.ts +15 -0
  264. package/lib/validator/registry.js +116 -0
  265. package/lib/validator/rules.d.ts +3 -0
  266. package/lib/validator/rules.js +154 -0
  267. package/lib/validator/template.d.ts +2 -0
  268. package/lib/validator/template.js +42 -0
  269. package/lib/validator/types.d.ts +62 -0
  270. package/lib/validator/types.js +28 -0
  271. package/lib/validator/validator.d.ts +2 -0
  272. package/lib/validator/validator.js +63 -0
  273. package/package.json +16 -10
@@ -0,0 +1,132 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var SPECIFICATION_1_0_exports = {};
20
+ __export(SPECIFICATION_1_0_exports, {
21
+ registerTypeDefaultComponents: () => registerTypeDefaultComponents,
22
+ registerVoidComponents: () => registerVoidComponents
23
+ });
24
+ module.exports = __toCommonJS(SPECIFICATION_1_0_exports);
25
+ var import_shared = require("../../shared");
26
+ var import_patches = require("../patches");
27
+ const VOID_COMPONENTS = ["card", "block", "grid-col", "grid-row", "grid", "layout", "step", "tab", "text-box"];
28
+ const TYPE_DEFAULT_COMPONENTS = {};
29
+ const transformCondition = /* @__PURE__ */ __name((condition) => {
30
+ if ((0, import_shared.isStr)(condition)) {
31
+ return condition.replace(/\$value/, "$self.value");
32
+ }
33
+ }, "transformCondition");
34
+ const transformXLinkage = /* @__PURE__ */ __name((linkages) => {
35
+ if ((0, import_shared.isArr)(linkages)) {
36
+ return linkages.reduce((buf, item) => {
37
+ if (!item) return buf;
38
+ if (item.type === "value:visible") {
39
+ return buf.concat({
40
+ target: item.target,
41
+ when: transformCondition(item.condition),
42
+ fulfill: {
43
+ state: {
44
+ visible: true
45
+ }
46
+ },
47
+ otherwise: {
48
+ state: {
49
+ visible: false
50
+ }
51
+ }
52
+ });
53
+ } else if (item.type === "value:schema") {
54
+ return buf.concat({
55
+ target: item.target,
56
+ when: transformCondition(item.condition),
57
+ fulfill: {
58
+ schema: SpecificationV1Polyfill({ version: "1.0", ...item.schema })
59
+ },
60
+ otherwise: {
61
+ schema: SpecificationV1Polyfill({
62
+ version: "1.0",
63
+ ...item.otherwise
64
+ })
65
+ }
66
+ });
67
+ } else if (item.type === "value:state") {
68
+ return buf.concat({
69
+ target: item.target,
70
+ when: transformCondition(item.condition),
71
+ fulfill: {
72
+ state: item.state
73
+ },
74
+ otherwise: {
75
+ state: item.otherwise
76
+ }
77
+ });
78
+ }
79
+ }, []);
80
+ }
81
+ return [];
82
+ }, "transformXLinkage");
83
+ const SpecificationV1Polyfill = /* @__PURE__ */ __name((schema) => {
84
+ if ((0, import_shared.isValid)(schema["editable"])) {
85
+ schema["x-editable"] = schema["x-editable"] || schema["editable"];
86
+ delete schema["editable"];
87
+ }
88
+ if ((0, import_shared.isValid)(schema["visible"])) {
89
+ schema["x-visible"] = schema["x-visible"] || schema["visible"];
90
+ delete schema["visible"];
91
+ }
92
+ if ((0, import_shared.isValid)(schema["display"])) {
93
+ schema["x-display"] = schema["x-display"] || (schema["display"] ? "visible" : "hidden");
94
+ delete schema["display"];
95
+ }
96
+ if ((0, import_shared.isValid)(schema["x-props"])) {
97
+ schema["x-decorator-props"] = schema["x-decorator-props"] || schema["x-props"];
98
+ delete schema["display"];
99
+ }
100
+ if (schema["x-linkages"]) {
101
+ schema["x-reactions"] = (0, import_shared.toArr)(schema["x-reactions"]).concat(transformXLinkage(schema["x-linkages"]));
102
+ delete schema["x-linkages"];
103
+ }
104
+ if (schema["x-component"]) {
105
+ if (VOID_COMPONENTS.some((component) => (0, import_shared.lowerCase)(component) === (0, import_shared.lowerCase)(schema["x-component"]))) {
106
+ schema["type"] = "void";
107
+ }
108
+ } else {
109
+ if (TYPE_DEFAULT_COMPONENTS[schema["type"]]) {
110
+ schema["x-component"] = TYPE_DEFAULT_COMPONENTS[schema["type"]];
111
+ }
112
+ }
113
+ if (!schema["x-decorator"] && schema["type"] !== "void" && schema["type"] !== "object") {
114
+ schema["x-decorator"] = schema["x-decorator"] || "FormItem";
115
+ }
116
+ if (schema["x-rules"]) {
117
+ schema["x-validator"] = [].concat(schema["x-validator"] || []).concat(schema["x-rules"]);
118
+ }
119
+ return schema;
120
+ }, "SpecificationV1Polyfill");
121
+ (0, import_patches.registerPolyfills)("1.0", SpecificationV1Polyfill);
122
+ const registerVoidComponents = /* @__PURE__ */ __name((components) => {
123
+ VOID_COMPONENTS.push(...components);
124
+ }, "registerVoidComponents");
125
+ const registerTypeDefaultComponents = /* @__PURE__ */ __name((maps) => {
126
+ Object.assign(TYPE_DEFAULT_COMPONENTS, maps);
127
+ }, "registerTypeDefaultComponents");
128
+ // Annotate the CommonJS export names for ESM import in node:
129
+ 0 && (module.exports = {
130
+ registerTypeDefaultComponents,
131
+ registerVoidComponents
132
+ });
@@ -0,0 +1 @@
1
+ export * from './SPECIFICATION_1_0';
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var polyfills_exports = {};
16
+ module.exports = __toCommonJS(polyfills_exports);
17
+ __reExport(polyfills_exports, require("./SPECIFICATION_1_0"), module.exports);
18
+ // Annotate the CommonJS export names for ESM import in node:
19
+ 0 && (module.exports = {
20
+ ...require("./SPECIFICATION_1_0")
21
+ });
@@ -0,0 +1,88 @@
1
+ import { IFieldFactoryProps } from '../core';
2
+ import { ISchema, ISchemaTransformerOptions, SchemaEnum, SchemaKey, SchemaProperties, SchemaReaction, SchemaTypes } from './types';
3
+ export declare class Schema<Decorator = any, Component = any, DecoratorProps = any, ComponentProps = any, Pattern = any, Display = any, Validator = any, Message = any, ReactionField = any> implements ISchema {
4
+ parent?: Schema;
5
+ root?: Schema;
6
+ name?: SchemaKey;
7
+ title?: Message;
8
+ description?: Message;
9
+ default?: any;
10
+ readOnly?: boolean;
11
+ writeOnly?: boolean;
12
+ type?: SchemaTypes;
13
+ enum?: SchemaEnum<Message>;
14
+ const?: any;
15
+ multipleOf?: number;
16
+ maximum?: number;
17
+ exclusiveMaximum?: number;
18
+ minimum?: number;
19
+ exclusiveMinimum?: number;
20
+ maxLength?: number;
21
+ minLength?: number;
22
+ pattern?: string | RegExp;
23
+ maxItems?: number;
24
+ minItems?: number;
25
+ uniqueItems?: boolean;
26
+ maxProperties?: number;
27
+ minProperties?: number;
28
+ required?: string[] | boolean | string;
29
+ format?: string;
30
+ /** nested json schema spec **/
31
+ definitions?: Record<string, Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>>;
32
+ properties?: Record<string, Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>>;
33
+ items?: Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message> | Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>[];
34
+ additionalItems?: Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>;
35
+ patternProperties?: Record<string, Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>>;
36
+ additionalProperties?: Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>;
37
+ ['x-index']?: number;
38
+ ['x-pattern']?: Pattern;
39
+ ['x-display']?: Display;
40
+ ['x-validator']?: Validator;
41
+ ['x-decorator']?: Decorator;
42
+ ['x-decorator-props']?: DecoratorProps;
43
+ ['x-component']?: Component;
44
+ ['x-component-props']?: ComponentProps;
45
+ ['x-reactions']?: SchemaReaction<ReactionField>[];
46
+ ['x-content']?: any;
47
+ ['x-data']?: any;
48
+ ['x-visible']?: boolean;
49
+ ['x-hidden']?: boolean;
50
+ ['x-disabled']?: boolean;
51
+ ['x-editable']?: boolean;
52
+ ['x-read-only']?: boolean;
53
+ ['x-read-pretty']?: boolean;
54
+ ['x-compile-omitted']?: string[];
55
+ [key: `x-${string | number}` | symbol]: any;
56
+ _isJSONSchemaObject: boolean;
57
+ version: string;
58
+ constructor(json: ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>, parent?: Schema);
59
+ addProperty: (key: SchemaKey, schema: ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>) => Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message, any>;
60
+ removeProperty: (key: SchemaKey) => Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message, any>;
61
+ setProperties: (properties: SchemaProperties<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>) => this;
62
+ addPatternProperty: (key: SchemaKey, schema: ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>) => Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message, any>;
63
+ removePatternProperty: (key: SchemaKey) => Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message, any>;
64
+ setPatternProperties: (properties: SchemaProperties<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>) => this;
65
+ setAdditionalProperties: (properties: ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>) => Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message, any>;
66
+ setItems: (schema: ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message> | ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>[]) => Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message, any> | Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message, any>[];
67
+ setAdditionalItems: (items: ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>) => Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message, any>;
68
+ findDefinitions: (ref: string) => any;
69
+ mapProperties: <T>(callback?: (schema: Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>, key: SchemaKey, index: number) => T) => T[];
70
+ mapPatternProperties: <T>(callback?: (schema: Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>, key: SchemaKey, index: number) => T) => T[];
71
+ reduceProperties: <P, R>(callback?: (buffer: P, schema: Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>, key: SchemaKey, index: number) => R, predicate?: P) => R;
72
+ reducePatternProperties: <P, R>(callback?: (buffer: P, schema: Schema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>, key: SchemaKey, index: number) => R, predicate?: P) => R;
73
+ compile: (scope?: any) => Schema<any, any, any, any, any, any, any, any, any>;
74
+ fromJSON: (json: ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>) => Schema<any, any, any, any, any, any, any, any, any>;
75
+ toJSON: (recursion?: boolean) => ISchema<Decorator, Component, DecoratorProps, ComponentProps, Pattern, Display, Validator, Message>;
76
+ toFieldProps: (options?: ISchemaTransformerOptions) => IFieldFactoryProps<any, any>;
77
+ static getOrderProperties: (schema?: ISchema, propertiesName?: keyof ISchema) => any[];
78
+ static compile: (expression: any, scope?: any) => any;
79
+ static shallowCompile: (expression: any, scope?: any) => any;
80
+ static isSchemaInstance: (value: any) => value is Schema;
81
+ static registerCompiler: (compiler: (expression: string, scope: any) => any) => void;
82
+ static registerPatches: (...args: import("./types").SchemaPatch[]) => void;
83
+ static registerVoidComponents: (components: string[]) => void;
84
+ static registerTypeDefaultComponents: (maps: Record<string, string>) => void;
85
+ static registerPolyfills: (version: string, patch: import("./types").SchemaPatch) => void;
86
+ static enablePolyfills: (versions?: string[]) => void;
87
+ static silent: (value?: boolean) => void;
88
+ }
@@ -0,0 +1,231 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var schema_exports = {};
20
+ __export(schema_exports, {
21
+ Schema: () => Schema
22
+ });
23
+ module.exports = __toCommonJS(schema_exports);
24
+ var import_shared = require("../shared");
25
+ var import_compiler = require("./compiler");
26
+ var import_patches = require("./patches");
27
+ var import_polyfills = require("./polyfills");
28
+ var import_shared2 = require("./shared");
29
+ var import_transformer = require("./transformer");
30
+ const _Schema = class _Schema {
31
+ constructor(json, parent) {
32
+ this._isJSONSchemaObject = true;
33
+ this.version = "2.0";
34
+ this.addProperty = /* @__PURE__ */ __name((key, schema) => {
35
+ this.properties = this.properties || {};
36
+ this.properties[key] = new _Schema(schema, this);
37
+ this.properties[key].name = key;
38
+ return this.properties[key];
39
+ }, "addProperty");
40
+ this.removeProperty = /* @__PURE__ */ __name((key) => {
41
+ const schema = this.properties[key];
42
+ delete this.properties[key];
43
+ return schema;
44
+ }, "removeProperty");
45
+ this.setProperties = /* @__PURE__ */ __name((properties) => {
46
+ for (const key in properties) {
47
+ this.addProperty(key, properties[key]);
48
+ }
49
+ return this;
50
+ }, "setProperties");
51
+ this.addPatternProperty = /* @__PURE__ */ __name((key, schema) => {
52
+ if (!schema) return;
53
+ this.patternProperties = this.patternProperties || {};
54
+ this.patternProperties[key] = new _Schema(schema, this);
55
+ this.patternProperties[key].name = key;
56
+ return this.patternProperties[key];
57
+ }, "addPatternProperty");
58
+ this.removePatternProperty = /* @__PURE__ */ __name((key) => {
59
+ const schema = this.patternProperties[key];
60
+ delete this.patternProperties[key];
61
+ return schema;
62
+ }, "removePatternProperty");
63
+ this.setPatternProperties = /* @__PURE__ */ __name((properties) => {
64
+ if (!properties) return this;
65
+ for (const key in properties) {
66
+ this.addPatternProperty(key, properties[key]);
67
+ }
68
+ return this;
69
+ }, "setPatternProperties");
70
+ this.setAdditionalProperties = /* @__PURE__ */ __name((properties) => {
71
+ if (!properties) return;
72
+ this.additionalProperties = new _Schema(properties);
73
+ return this.additionalProperties;
74
+ }, "setAdditionalProperties");
75
+ this.setItems = /* @__PURE__ */ __name((schema) => {
76
+ if (!schema) return;
77
+ if (Array.isArray(schema)) {
78
+ this.items = schema.map((item) => new _Schema(item, this));
79
+ } else {
80
+ this.items = new _Schema(schema, this);
81
+ }
82
+ return this.items;
83
+ }, "setItems");
84
+ this.setAdditionalItems = /* @__PURE__ */ __name((items) => {
85
+ if (!items) return;
86
+ this.additionalItems = new _Schema(items, this);
87
+ return this.additionalItems;
88
+ }, "setAdditionalItems");
89
+ this.findDefinitions = /* @__PURE__ */ __name((ref) => {
90
+ if (!ref || !this.root || !(0, import_shared.isStr)(ref)) return;
91
+ if (ref.indexOf("#/") !== 0) return;
92
+ return import_shared.FormPath.getIn(this.root, ref.substring(2).split("/"));
93
+ }, "findDefinitions");
94
+ this.mapProperties = /* @__PURE__ */ __name((callback) => {
95
+ return _Schema.getOrderProperties(this).map(({ schema, key }, index) => {
96
+ return callback(schema, key, index);
97
+ });
98
+ }, "mapProperties");
99
+ this.mapPatternProperties = /* @__PURE__ */ __name((callback) => {
100
+ return _Schema.getOrderProperties(this, "patternProperties").map(({ schema, key }, index) => {
101
+ return callback(schema, key, index);
102
+ });
103
+ }, "mapPatternProperties");
104
+ this.reduceProperties = /* @__PURE__ */ __name((callback, predicate) => {
105
+ let results = predicate;
106
+ _Schema.getOrderProperties(this, "properties").forEach(({ schema, key }, index) => {
107
+ results = callback(results, schema, key, index);
108
+ });
109
+ return results;
110
+ }, "reduceProperties");
111
+ this.reducePatternProperties = /* @__PURE__ */ __name((callback, predicate) => {
112
+ let results = predicate;
113
+ _Schema.getOrderProperties(this, "patternProperties").forEach(({ schema, key }, index) => {
114
+ results = callback(results, schema, key, index);
115
+ });
116
+ return results;
117
+ }, "reducePatternProperties");
118
+ this.compile = /* @__PURE__ */ __name((scope) => {
119
+ const schema = new _Schema({}, this.parent);
120
+ (0, import_shared.each)(this, (value, key) => {
121
+ if ((0, import_shared.isFn)(value) && !key.includes("x-")) return;
122
+ if (key === "parent" || key === "root") return;
123
+ if (!import_shared2.SchemaNestedMap[key]) {
124
+ schema[key] = value ? (0, import_compiler.compile)(value, scope) : value;
125
+ } else {
126
+ schema[key] = value ? (0, import_compiler.shallowCompile)(value, scope) : value;
127
+ }
128
+ });
129
+ return schema;
130
+ }, "compile");
131
+ this.fromJSON = /* @__PURE__ */ __name((json) => {
132
+ if (!json) return this;
133
+ if (_Schema.isSchemaInstance(json)) return json;
134
+ (0, import_shared.each)((0, import_patches.reducePatches)(json), (value, key) => {
135
+ if ((0, import_shared.isFn)(value) && !key.includes("x-")) return;
136
+ if (key === "properties") {
137
+ this.setProperties(value);
138
+ } else if (key === "patternProperties") {
139
+ this.setPatternProperties(value);
140
+ } else if (key === "additionalProperties") {
141
+ this.setAdditionalProperties(value);
142
+ } else if (key === "items") {
143
+ this.setItems(value);
144
+ } else if (key === "additionalItems") {
145
+ this.setAdditionalItems(value);
146
+ } else if (key === "$ref") {
147
+ this.fromJSON(this.findDefinitions(value));
148
+ } else {
149
+ this[key] = value;
150
+ }
151
+ });
152
+ return this;
153
+ }, "fromJSON");
154
+ this.toJSON = /* @__PURE__ */ __name((recursion = true) => {
155
+ const results = {};
156
+ (0, import_shared.each)(this, (value, key) => {
157
+ var _a, _b;
158
+ if ((0, import_shared.isFn)(value) && !key.includes("x-") || key === "parent" || key === "root") return;
159
+ if (key === "properties" || key === "patternProperties") {
160
+ if (!recursion) return;
161
+ results[key] = (0, import_shared.map)(value, (item) => {
162
+ var _a2;
163
+ return (_a2 = item == null ? void 0 : item.toJSON) == null ? void 0 : _a2.call(item);
164
+ });
165
+ } else if (key === "additionalProperties" || key === "additionalItems") {
166
+ if (!recursion) return;
167
+ results[key] = (_a = value == null ? void 0 : value.toJSON) == null ? void 0 : _a.call(value);
168
+ } else if (key === "items") {
169
+ if (!recursion) return;
170
+ if (Array.isArray(value)) {
171
+ results[key] = value.map((item) => {
172
+ var _a2;
173
+ return (_a2 = item == null ? void 0 : item.toJSON) == null ? void 0 : _a2.call(item);
174
+ });
175
+ } else {
176
+ results[key] = (_b = value == null ? void 0 : value.toJSON) == null ? void 0 : _b.call(value);
177
+ }
178
+ } else {
179
+ results[key] = value;
180
+ }
181
+ });
182
+ return results;
183
+ }, "toJSON");
184
+ this.toFieldProps = /* @__PURE__ */ __name((options) => {
185
+ return (0, import_transformer.transformFieldProps)(this, options);
186
+ }, "toFieldProps");
187
+ if (parent) {
188
+ this.parent = parent;
189
+ this.root = parent.root;
190
+ } else {
191
+ this.root = this;
192
+ }
193
+ return this.fromJSON(json);
194
+ }
195
+ };
196
+ __name(_Schema, "Schema");
197
+ _Schema.getOrderProperties = /* @__PURE__ */ __name((schema = {}, propertiesName = "properties") => {
198
+ const orderProperties = [];
199
+ const unorderProperties = [];
200
+ for (const key in schema[propertiesName]) {
201
+ const item = schema[propertiesName][key];
202
+ const index = item["x-index"];
203
+ if (!isNaN(index)) {
204
+ orderProperties[index] = { schema: item, key };
205
+ } else {
206
+ unorderProperties.push({ schema: item, key });
207
+ }
208
+ }
209
+ return orderProperties.concat(unorderProperties).filter((item) => !!item);
210
+ }, "getOrderProperties");
211
+ _Schema.compile = /* @__PURE__ */ __name((expression, scope) => {
212
+ return (0, import_compiler.compile)(expression, scope);
213
+ }, "compile");
214
+ _Schema.shallowCompile = /* @__PURE__ */ __name((expression, scope) => {
215
+ return (0, import_compiler.shallowCompile)(expression, scope);
216
+ }, "shallowCompile");
217
+ _Schema.isSchemaInstance = /* @__PURE__ */ __name((value) => {
218
+ return (0, import_shared.instOf)(value, _Schema);
219
+ }, "isSchemaInstance");
220
+ _Schema.registerCompiler = import_compiler.registerCompiler;
221
+ _Schema.registerPatches = import_patches.registerPatches;
222
+ _Schema.registerVoidComponents = import_polyfills.registerVoidComponents;
223
+ _Schema.registerTypeDefaultComponents = import_polyfills.registerTypeDefaultComponents;
224
+ _Schema.registerPolyfills = import_patches.registerPolyfills;
225
+ _Schema.enablePolyfills = import_patches.enablePolyfills;
226
+ _Schema.silent = import_compiler.silent;
227
+ let Schema = _Schema;
228
+ // Annotate the CommonJS export names for ESM import in node:
229
+ 0 && (module.exports = {
230
+ Schema
231
+ });
@@ -0,0 +1,62 @@
1
+ import { ISchema } from './types';
2
+ export declare const SchemaNestedMap: {
3
+ parent: boolean;
4
+ root: boolean;
5
+ properties: boolean;
6
+ patternProperties: boolean;
7
+ additionalProperties: boolean;
8
+ items: boolean;
9
+ additionalItems: boolean;
10
+ 'x-linkages': boolean;
11
+ 'x-reactions': boolean;
12
+ };
13
+ export declare const SchemaStateMap: {
14
+ title: string;
15
+ description: string;
16
+ default: string;
17
+ enum: string;
18
+ readOnly: string;
19
+ writeOnly: string;
20
+ 'x-content': string;
21
+ 'x-data': string;
22
+ 'x-value': string;
23
+ 'x-editable': string;
24
+ 'x-disabled': string;
25
+ 'x-read-pretty': string;
26
+ 'x-read-only': string;
27
+ 'x-visible': string;
28
+ 'x-hidden': string;
29
+ 'x-display': string;
30
+ 'x-pattern': string;
31
+ 'x-validator': string;
32
+ 'x-decorator': string;
33
+ 'x-component': string;
34
+ 'x-decorator-props': string;
35
+ 'x-component-props': string;
36
+ };
37
+ export declare const SchemaValidatorMap: {
38
+ required: boolean;
39
+ format: boolean;
40
+ maxItems: boolean;
41
+ minItems: boolean;
42
+ maxLength: boolean;
43
+ minLength: boolean;
44
+ maximum: boolean;
45
+ minimum: boolean;
46
+ exclusiveMaximum: boolean;
47
+ exclusiveMinimum: boolean;
48
+ pattern: boolean;
49
+ const: boolean;
50
+ multipleOf: boolean;
51
+ maxProperties: boolean;
52
+ minProperties: boolean;
53
+ uniqueItems: boolean;
54
+ };
55
+ export declare const SchemaNormalKeys: string[];
56
+ export declare const SchemaValidatorKeys: string[];
57
+ export declare const hasOwnProperty: (v: PropertyKey) => boolean;
58
+ export declare const traverse: (target: any, visitor: (value: any, path: Array<string | number>) => void) => void;
59
+ export declare const traverseSchema: (schema: ISchema, visitor: (value: any, path: any[], omitCompile?: boolean) => void) => void;
60
+ export declare const isNoNeedCompileObject: (source: any) => boolean;
61
+ export declare const createDataSource: (source: any[]) => any[];
62
+ export declare const patchStateFormSchema: (targetState: any, pattern: any[], compiled: any) => void;