@duplojs/lang 0.0.1-beta.8 → 0.1.0-beta.1

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 (267) hide show
  1. package/dist/array/concat.d.ts +2 -2
  2. package/dist/array/flat.d.ts +1 -1
  3. package/dist/array/flatMap.d.ts +2 -2
  4. package/dist/array/from.d.ts +1 -1
  5. package/dist/array/length.d.ts +3 -2
  6. package/dist/array/push.d.ts +4 -2
  7. package/dist/chrono/operators/addTime.d.ts +2 -4
  8. package/dist/common/constraint/cast/index.d.ts +5 -5
  9. package/dist/common/constraint/cast/string.d.ts +4 -0
  10. package/dist/common/constraint/infer/index.d.ts +2 -1
  11. package/dist/common/constraint/infer/string.d.ts +1 -0
  12. package/dist/common/constraint/types/index.d.ts +1 -0
  13. package/dist/common/constraint/types/maybe.d.ts +2 -0
  14. package/dist/common/formData.d.ts +2 -1
  15. package/dist/common/memo.cjs +3 -2
  16. package/dist/common/memo.mjs +3 -2
  17. package/dist/common/memoPromise.cjs +3 -2
  18. package/dist/common/memoPromise.mjs +3 -2
  19. package/dist/common/timeout.cjs +2 -2
  20. package/dist/common/timeout.d.ts +1 -1
  21. package/dist/common/timeout.mjs +2 -2
  22. package/dist/common/types/applyPromiseIf.d.ts +1 -0
  23. package/dist/common/types/index.d.ts +2 -0
  24. package/dist/common/types/isObject.d.ts +8 -0
  25. package/dist/common/types/json.d.ts +12 -1
  26. package/dist/dataStructure/common/codec/base.cjs +2 -2
  27. package/dist/dataStructure/common/codec/base.mjs +2 -2
  28. package/dist/dataStructure/common/codec/defaults/string.cjs +1 -1
  29. package/dist/dataStructure/common/codec/defaults/string.d.ts +1 -1
  30. package/dist/dataStructure/common/codec/defaults/string.mjs +1 -1
  31. package/dist/dataStructure/common/{error.cjs → error/base.cjs} +22 -5
  32. package/dist/dataStructure/common/{error.d.ts → error/base.d.ts} +18 -9
  33. package/dist/dataStructure/common/{error.mjs → error/base.mjs} +21 -6
  34. package/dist/dataStructure/common/error/defaultInterpreter.cjs +87 -0
  35. package/dist/dataStructure/common/error/defaultInterpreter.d.ts +60 -0
  36. package/dist/dataStructure/common/error/defaultInterpreter.mjs +86 -0
  37. package/dist/dataStructure/common/error/index.d.ts +3 -0
  38. package/dist/dataStructure/common/error/interpreter.cjs +44 -0
  39. package/dist/dataStructure/common/error/interpreter.d.ts +32 -0
  40. package/dist/dataStructure/common/error/interpreter.mjs +44 -0
  41. package/dist/dataStructure/common/index.d.ts +0 -1
  42. package/dist/dataStructure/constraint/defaults/allowedCharacters.d.ts +1 -3
  43. package/dist/dataStructure/constraint/types/constraints.d.ts +1 -0
  44. package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +1 -0
  45. package/dist/dataStructure/helpers/extend.cjs +1 -1
  46. package/dist/dataStructure/helpers/extend.d.ts +1 -1
  47. package/dist/dataStructure/helpers/extend.mjs +1 -1
  48. package/dist/dataStructure/helpers/index.d.ts +6 -2
  49. package/dist/dataStructure/helpers/isNullable.cjs +12 -0
  50. package/dist/dataStructure/helpers/isNullable.d.ts +2 -0
  51. package/dist/dataStructure/helpers/isNullable.mjs +12 -0
  52. package/dist/dataStructure/helpers/isOptional.cjs +12 -0
  53. package/dist/dataStructure/helpers/isOptional.d.ts +2 -0
  54. package/dist/dataStructure/helpers/isOptional.mjs +12 -0
  55. package/dist/dataStructure/helpers/partial.cjs +1 -1
  56. package/dist/dataStructure/helpers/partial.mjs +1 -1
  57. package/dist/dataStructure/helpers/required.cjs +1 -1
  58. package/dist/dataStructure/helpers/required.mjs +1 -1
  59. package/dist/dataStructure/helpers/typeStructureIdentifier.cjs +14 -0
  60. package/dist/dataStructure/helpers/typeStructureIdentifier.d.ts +6 -0
  61. package/dist/dataStructure/helpers/typeStructureIdentifier.mjs +14 -0
  62. package/dist/dataStructure/helpers/unwrapLazy.cjs +9 -0
  63. package/dist/dataStructure/helpers/unwrapLazy.d.ts +2 -0
  64. package/dist/dataStructure/helpers/unwrapLazy.mjs +9 -0
  65. package/dist/dataStructure/index.cjs +56 -35
  66. package/dist/dataStructure/index.mjs +18 -5
  67. package/dist/dataStructure/structure/base.cjs +31 -19
  68. package/dist/dataStructure/structure/base.d.ts +16 -16
  69. package/dist/dataStructure/structure/base.mjs +25 -13
  70. package/dist/dataStructure/structure/defaults/array.cjs +10 -0
  71. package/dist/dataStructure/structure/defaults/array.d.ts +1 -1
  72. package/dist/dataStructure/structure/defaults/array.mjs +10 -0
  73. package/dist/dataStructure/structure/defaults/lazy.cjs +1 -0
  74. package/dist/dataStructure/structure/defaults/lazy.d.ts +1 -1
  75. package/dist/dataStructure/structure/defaults/lazy.mjs +1 -0
  76. package/dist/dataStructure/structure/defaults/nonEncodableString.cjs +1 -0
  77. package/dist/dataStructure/structure/defaults/nonEncodableString.mjs +1 -0
  78. package/dist/dataStructure/structure/defaults/object.cjs +18 -7
  79. package/dist/dataStructure/structure/defaults/object.d.ts +3 -2
  80. package/dist/dataStructure/structure/defaults/object.mjs +18 -7
  81. package/dist/dataStructure/structure/defaults/record.cjs +20 -7
  82. package/dist/dataStructure/structure/defaults/record.d.ts +1 -1
  83. package/dist/dataStructure/structure/defaults/record.mjs +20 -7
  84. package/dist/dataStructure/structure/defaults/type.cjs +1 -0
  85. package/dist/dataStructure/structure/defaults/type.d.ts +1 -1
  86. package/dist/dataStructure/structure/defaults/type.mjs +1 -0
  87. package/dist/dataStructure/structure/defaults/union.cjs +26 -6
  88. package/dist/dataStructure/structure/defaults/union.d.ts +1 -1
  89. package/dist/dataStructure/structure/defaults/union.mjs +21 -1
  90. package/dist/dataStructure/structure/types/value.d.ts +2 -0
  91. package/dist/dataStructure/type/types/types.d.ts +1 -0
  92. package/dist/either/index.cjs +29 -7
  93. package/dist/either/index.d.ts +4 -0
  94. package/dist/either/index.mjs +22 -8
  95. package/dist/either/left/create.d.ts +2 -1
  96. package/dist/either/left/index.d.ts +3 -2
  97. package/dist/either/left/none.cjs +15 -0
  98. package/dist/either/left/none.d.ts +7 -0
  99. package/dist/either/left/none.mjs +14 -0
  100. package/dist/either/matchInformationOtherwise.d.ts +1 -1
  101. package/dist/either/rewriteInformation.cjs +22 -0
  102. package/dist/either/rewriteInformation.d.ts +14 -0
  103. package/dist/either/rewriteInformation.mjs +22 -0
  104. package/dist/either/right/asyncGroup.cjs +2 -2
  105. package/dist/either/right/asyncGroup.mjs +2 -2
  106. package/dist/either/right/create.d.ts +2 -1
  107. package/dist/either/right/group.cjs +1 -1
  108. package/dist/either/right/group.mjs +1 -1
  109. package/dist/either/right/index.d.ts +6 -5
  110. package/dist/either/right/some.cjs +15 -0
  111. package/dist/either/right/some.d.ts +7 -0
  112. package/dist/either/right/some.mjs +14 -0
  113. package/dist/either/toMaybe.cjs +12 -0
  114. package/dist/either/toMaybe.d.ts +5 -0
  115. package/dist/either/toMaybe.mjs +12 -0
  116. package/dist/either/types/index.d.ts +1 -0
  117. package/dist/either/types/mayBe.d.ts +3 -0
  118. package/dist/either/unwrapOr.cjs +14 -0
  119. package/dist/either/unwrapOr.d.ts +8 -0
  120. package/dist/either/unwrapOr.mjs +14 -0
  121. package/dist/either/unwrapOtherwise.cjs +14 -0
  122. package/dist/either/unwrapOtherwise.d.ts +8 -0
  123. package/dist/either/unwrapOtherwise.mjs +14 -0
  124. package/dist/generator/reduce.cjs +2 -1
  125. package/dist/generator/reduce.mjs +1 -1
  126. package/dist/invocation/evidence.d.ts +1 -1
  127. package/dist/invocation/flow/base.cjs +4 -4
  128. package/dist/invocation/flow/base.d.ts +1 -1
  129. package/dist/invocation/flow/base.mjs +4 -4
  130. package/dist/invocation/flow/controller/defaults/debounce.cjs +1 -1
  131. package/dist/invocation/flow/controller/defaults/debounce.mjs +1 -1
  132. package/dist/invocation/flow/controller/defaults/throttling.cjs +1 -1
  133. package/dist/invocation/flow/controller/defaults/throttling.mjs +1 -1
  134. package/dist/invocation/index.cjs +18 -8
  135. package/dist/invocation/index.d.ts +3 -1
  136. package/dist/invocation/index.mjs +12 -6
  137. package/dist/invocation/reader.cjs +30 -0
  138. package/dist/invocation/reader.d.ts +30 -0
  139. package/dist/invocation/reader.mjs +29 -0
  140. package/dist/invocation/resolver.cjs +31 -0
  141. package/dist/invocation/resolver.d.ts +14 -0
  142. package/dist/invocation/resolver.mjs +31 -0
  143. package/dist/invocation/signature.cjs +8 -0
  144. package/dist/invocation/signature.d.ts +7 -0
  145. package/dist/invocation/signature.mjs +8 -0
  146. package/dist/modeling/entity/base.cjs +22 -11
  147. package/dist/modeling/entity/base.d.ts +16 -8
  148. package/dist/modeling/entity/base.mjs +16 -5
  149. package/dist/modeling/entity/helper.d.ts +6 -8
  150. package/dist/modeling/entity/namespace.cjs +0 -2
  151. package/dist/modeling/entity/namespace.d.ts +0 -2
  152. package/dist/modeling/entity/namespace.mjs +0 -2
  153. package/dist/modeling/fact/base.cjs +36 -0
  154. package/dist/modeling/fact/base.d.ts +29 -0
  155. package/dist/modeling/fact/base.mjs +35 -0
  156. package/dist/modeling/fact/index.d.ts +1 -0
  157. package/dist/modeling/flag/base.cjs +2 -6
  158. package/dist/modeling/flag/base.d.ts +10 -11
  159. package/dist/modeling/flag/base.mjs +2 -6
  160. package/dist/modeling/index.cjs +17 -12
  161. package/dist/modeling/index.d.ts +1 -0
  162. package/dist/modeling/index.mjs +5 -2
  163. package/dist/modeling/newType/base.cjs +12 -11
  164. package/dist/modeling/newType/base.d.ts +8 -8
  165. package/dist/modeling/newType/base.mjs +6 -5
  166. package/dist/modeling/taggedObject/base.cjs +22 -11
  167. package/dist/modeling/taggedObject/base.d.ts +12 -7
  168. package/dist/modeling/taggedObject/base.mjs +16 -5
  169. package/dist/object/assign.d.ts +3 -3
  170. package/dist/object/deepOverride.cjs +33 -0
  171. package/dist/object/deepOverride.d.ts +20 -0
  172. package/dist/object/deepOverride.mjs +33 -0
  173. package/dist/object/entries.d.ts +3 -3
  174. package/dist/object/index.cjs +4 -1
  175. package/dist/object/index.d.ts +1 -0
  176. package/dist/object/index.mjs +4 -2
  177. package/dist/object/isSimple.cjs +1 -1
  178. package/dist/object/isSimple.mjs +1 -1
  179. package/dist/object/keys.d.ts +1 -1
  180. package/dist/object/override.cjs +1 -1
  181. package/dist/object/override.d.ts +5 -2
  182. package/dist/object/override.mjs +1 -1
  183. package/dist/object/types/assign.d.ts +2 -0
  184. package/dist/object/types/forbiddenKey.d.ts +1 -1
  185. package/dist/object/types/forbiddenUndefinedProps.d.ts +3 -0
  186. package/dist/object/types/hasKeySignature.d.ts +1 -0
  187. package/dist/object/types/index.d.ts +6 -2
  188. package/dist/object/types/keyofWithoutSignature.d.ts +3 -0
  189. package/dist/object/types/override.d.ts +4 -0
  190. package/dist/object/types/split.d.ts +2 -2
  191. package/dist/object/values.d.ts +1 -1
  192. package/dist/path/create.cjs +11 -0
  193. package/dist/path/create.d.ts +3 -0
  194. package/dist/path/create.mjs +11 -0
  195. package/dist/path/createAbsolute.cjs +12 -0
  196. package/dist/path/createAbsolute.d.ts +3 -0
  197. package/dist/path/createAbsolute.mjs +12 -0
  198. package/dist/path/createAbsoluteOrThrow.cjs +22 -0
  199. package/dist/path/createAbsoluteOrThrow.d.ts +9 -0
  200. package/dist/path/createAbsoluteOrThrow.mjs +21 -0
  201. package/dist/path/createOrThrow.cjs +22 -0
  202. package/dist/path/createOrThrow.d.ts +9 -0
  203. package/dist/path/createOrThrow.mjs +21 -0
  204. package/dist/path/createSegment.cjs +12 -0
  205. package/dist/path/createSegment.d.ts +3 -0
  206. package/dist/path/createSegment.mjs +12 -0
  207. package/dist/path/createSegmentOrThrow.cjs +22 -0
  208. package/dist/path/createSegmentOrThrow.d.ts +9 -0
  209. package/dist/path/createSegmentOrThrow.mjs +21 -0
  210. package/dist/path/declareAbsolutePath.cjs +6 -0
  211. package/dist/path/declareAbsolutePath.d.ts +3 -0
  212. package/dist/path/declareAbsolutePath.mjs +6 -0
  213. package/dist/path/declarePath.cjs +6 -0
  214. package/dist/path/declarePath.d.ts +3 -0
  215. package/dist/path/declarePath.mjs +6 -0
  216. package/dist/path/declareSegment.cjs +6 -0
  217. package/dist/path/declareSegment.d.ts +3 -0
  218. package/dist/path/declareSegment.mjs +6 -0
  219. package/dist/path/index.cjs +39 -3
  220. package/dist/path/index.d.ts +10 -0
  221. package/dist/path/index.mjs +27 -4
  222. package/dist/path/kind.cjs +4 -0
  223. package/dist/path/kind.d.ts +2 -0
  224. package/dist/path/kind.mjs +5 -0
  225. package/dist/pattern/index.cjs +6 -0
  226. package/dist/pattern/index.d.ts +2 -0
  227. package/dist/pattern/index.mjs +5 -1
  228. package/dist/pattern/match/builder.cjs +1 -1
  229. package/dist/pattern/match/builder.mjs +1 -1
  230. package/dist/pattern/matchWithEntityOtherwise.d.ts +2 -2
  231. package/dist/pattern/matchWithFact.cjs +12 -0
  232. package/dist/pattern/matchWithFact.d.ts +12 -0
  233. package/dist/pattern/matchWithFact.mjs +12 -0
  234. package/dist/pattern/matchWithFactOtherwise.cjs +13 -0
  235. package/dist/pattern/matchWithFactOtherwise.d.ts +14 -0
  236. package/dist/pattern/matchWithFactOtherwise.mjs +13 -0
  237. package/dist/pattern/matchWithNumber.d.ts +4 -4
  238. package/dist/pattern/matchWithNumberOtherwise.d.ts +4 -4
  239. package/dist/pattern/matchWithString.d.ts +4 -4
  240. package/dist/pattern/matchWithStringOtherwise.d.ts +4 -4
  241. package/dist/pattern/matchWithTaggedObjectOtherwise.d.ts +2 -2
  242. package/dist/pattern/types/complexUnMatchedValue/getIncompleteUnion.d.ts +8 -8
  243. package/dist/string/capitalize.d.ts +1 -1
  244. package/dist/string/concat.d.ts +2 -2
  245. package/dist/string/constraints/allowedCharacters.d.ts +3 -3
  246. package/dist/string/isComposedOf.cjs +0 -1
  247. package/dist/string/isComposedOf.d.ts +5 -8
  248. package/dist/string/isComposedOf.mjs +0 -1
  249. package/dist/string/prepend.d.ts +2 -2
  250. package/dist/string/split.cjs +1 -0
  251. package/dist/string/split.d.ts +3 -3
  252. package/dist/string/split.mjs +1 -0
  253. package/dist/string/toLowerCase.d.ts +1 -1
  254. package/dist/string/toUpperCase.d.ts +1 -1
  255. package/dist/string/types/IsAllowedString.d.ts +5 -0
  256. package/dist/string/types/index.d.ts +1 -0
  257. package/dist/string/uncapitalize.d.ts +1 -1
  258. package/dist/tuple/types/map.d.ts +1 -1
  259. package/package.json +16 -30
  260. package/dist/dataStructure/common/errorInterpreter.cjs +0 -45
  261. package/dist/dataStructure/common/errorInterpreter.d.ts +0 -32
  262. package/dist/dataStructure/common/errorInterpreter.mjs +0 -45
  263. package/dist/invocation/useCase.cjs +0 -26
  264. package/dist/invocation/useCase.d.ts +0 -28
  265. package/dist/invocation/useCase.mjs +0 -25
  266. package/dist/object/types/assignObjects.d.ts +0 -2
  267. /package/{README.md → README} +0 -0
@@ -0,0 +1,87 @@
1
+ const require_coalescing = require("../../../array/coalescing.cjs");
2
+ const require_join = require("../../../string/join.cjs");
3
+ const require_stringify = require("../../../string/stringify.cjs");
4
+ const require_to = require("../../../string/to.cjs");
5
+ const require_json = require("../codec/defaults/json.cjs");
6
+ const require_string = require("../codec/defaults/string.cjs");
7
+ const require_base = require("./base.cjs");
8
+ //#region scripts/dataStructure/common/error/defaultInterpreter.ts
9
+ const defaultErrorInterpreterDataStructureDictionary = {
10
+ "@DuplojsLangDataStructure/array-structure": () => "Expected an array.",
11
+ "@DuplojsLangDataStructure/lazy-structure": () => "Expected a value matching the resolved structure.",
12
+ "@DuplojsLangDataStructure/non-encodable-string-structure": (source) => `Expected ${require_stringify.stringify(source.definition.value)}.`,
13
+ "@DuplojsLangDataStructure/object-structure": () => "Expected a plain object containing only the defined properties.",
14
+ "@DuplojsLangDataStructure/record-structure": () => "Expected a plain object matching the record definition.",
15
+ "@DuplojsLangDataStructure/type-structure": () => "Expected a value matching the configured type.",
16
+ "@DuplojsLangDataStructure/union-structure": () => "Expected a value matching at least one union member.",
17
+ "@DuplojsLangDataStructure/bigint-type": () => "Expected a bigint.",
18
+ "@DuplojsLangDataStructure/bigint-literal-type": (source) => `Expected ${require_to.to(source.definition.value)}n.`,
19
+ "@DuplojsLangDataStructure/boolean-type": () => "Expected a boolean.",
20
+ "@DuplojsLangDataStructure/boolean-literal-type": (source) => `Expected ${source.definition.value}.`,
21
+ "@DuplojsLangDataStructure/date-type": () => "Expected a DuploJS date.",
22
+ "@DuplojsLangDataStructure/null-type": () => "Expected null.",
23
+ "@DuplojsLangDataStructure/number-type": () => "Expected a finite number.",
24
+ "@DuplojsLangDataStructure/number-literal-type": (source) => `Expected ${source.definition.value}.`,
25
+ "@DuplojsLangDataStructure/string-type": () => "Expected a string.",
26
+ "@DuplojsLangDataStructure/string-literal-type": (source) => `Expected ${require_stringify.stringify(source.definition.value)}.`,
27
+ "@DuplojsLangDataStructure/time-type": () => "Expected a DuploJS time.",
28
+ "@DuplojsLangDataStructure/undefined-type": () => "Expected undefined.",
29
+ "@DuplojsLangDataStructure/absolute-path-constraint": () => "Expected an absolute path.",
30
+ "@DuplojsLangDataStructure/allowed-characters-constraint": (source) => `Expected a string containing only characters from ${require_join.join(require_coalescing.coalescing(source.definition.charactersRange), ", ")}.`,
31
+ "@DuplojsLangDataStructure/array-length-equal-constraint": (source) => `Expected an array containing exactly ${source.definition.length} elements.`,
32
+ "@DuplojsLangDataStructure/between-than-constraint": (source) => `Expected a number greater than ${source.definition.greater} and less than ${source.definition.less}.`,
33
+ "@DuplojsLangDataStructure/between-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.greater} and less than or equal to ${source.definition.less}.`,
34
+ "@DuplojsLangDataStructure/email-constraint": () => "Expected a valid email address.",
35
+ "@DuplojsLangDataStructure/even-constraint": () => "Expected an even number.",
36
+ "@DuplojsLangDataStructure/greater-than-constraint": (source) => `Expected a number greater than ${source.definition.threshold}.`,
37
+ "@DuplojsLangDataStructure/greater-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.threshold}.`,
38
+ "@DuplojsLangDataStructure/integer-constraint": () => "Expected an integer.",
39
+ "@DuplojsLangDataStructure/less-than-constraint": (source) => `Expected a number less than ${source.definition.threshold}.`,
40
+ "@DuplojsLangDataStructure/less-than-or-equal-constraint": (source) => `Expected a number less than or equal to ${source.definition.threshold}.`,
41
+ "@DuplojsLangDataStructure/max-characters-constraint": (source) => `Expected a string containing at most ${source.definition.max} characters.`,
42
+ "@DuplojsLangDataStructure/max-elements-constraint": (source) => `Expected an array containing at most ${source.definition.max} elements.`,
43
+ "@DuplojsLangDataStructure/min-characters-constraint": (source) => `Expected a string containing at least ${source.definition.min} characters.`,
44
+ "@DuplojsLangDataStructure/min-elements-constraint": (source) => `Expected an array containing at least ${source.definition.min} elements.`,
45
+ "@DuplojsLangDataStructure/multiple-of-constraint": (source) => `Expected a multiple of ${source.definition.multiple}.`,
46
+ "@DuplojsLangDataStructure/negative-constraint": () => "Expected a number less than or equal to zero.",
47
+ "@DuplojsLangDataStructure/not-empty-constraint": () => "Expected a non-empty string.",
48
+ "@DuplojsLangDataStructure/not-zero-constraint": () => "Expected a non-zero number.",
49
+ "@DuplojsLangDataStructure/number-in-string-constraint": () => "Expected a string representing a number.",
50
+ "@DuplojsLangDataStructure/odd-constraint": () => "Expected an odd number.",
51
+ "@DuplojsLangDataStructure/path-constraint": () => "Expected a valid path.",
52
+ "@DuplojsLangDataStructure/positive-constraint": () => "Expected a number greater than or equal to zero.",
53
+ "@DuplojsLangDataStructure/refine-constraint": () => "Expected a value satisfying the custom refinement.",
54
+ "@DuplojsLangDataStructure/regex-constraint": (source) => `Expected a string matching ${source.definition.regex.toString()}.`,
55
+ "@DuplojsLangDataStructure/safe-constraint": () => "Expected a number strictly between Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER.",
56
+ "@DuplojsLangDataStructure/segment-path-constraint": () => "Expected a valid path segment.",
57
+ "@DuplojsLangDataStructure/strict-negative-constraint": () => "Expected a number less than zero.",
58
+ "@DuplojsLangDataStructure/strict-positive-constraint": () => "Expected a number greater than zero.",
59
+ "@DuplojsLangDataStructure/string-length-equal-constraint": (source) => `Expected a string containing exactly ${source.definition.length} characters.`,
60
+ "@DuplojsLangDataStructure/trimmed-constraint": () => "Expected a string without leading or trailing whitespace.",
61
+ "@DuplojsLangDataStructure/url-constraint": () => "Expected a valid URL.",
62
+ "@DuplojsLangDataStructure/uuid-constraint": () => "Expected a valid UUID.",
63
+ "@DuplojsLangModeling/entity-structure": () => "Expected a valid entity object.",
64
+ "@DuplojsLangModeling/new-type-structure": () => "Expected a value matching the branded type.",
65
+ "@DuplojsLangModeling/tagged-object-structure": (source) => `Expected a plain object matching one of the tagged variants of ${source.name}.`
66
+ };
67
+ const createDefaultCodecErrorMessage = (codecName, encodedValueDescription, decodedValueDescription) => (_codec, issue) => {
68
+ if (issue.from === "predicate") return require_base.encodeIssueKind.has(issue) ? `The ${codecName} codec must produce ${encodedValueDescription}.` : `Expected ${encodedValueDescription} for the ${codecName} codec.`;
69
+ if (issue.from === "encoding") return `The ${codecName} codec could not encode ${decodedValueDescription}.`;
70
+ if (issue.from === "decoding") return `The ${codecName} codec could not decode the value as ${decodedValueDescription}.`;
71
+ return `The ${codecName} codec encountered an external error while ${require_base.encodeIssueKind.has(issue) ? "encoding" : "decoding"}.`;
72
+ };
73
+ const defaultErrorInterpreterCodecDictionary = [
74
+ [require_json.codecsJson.definition.bigint, createDefaultCodecErrorMessage("JSON bigint", "a string", "a bigint")],
75
+ [require_json.codecsJson.definition.date, createDefaultCodecErrorMessage("JSON date", "a string", "a DuploJS date")],
76
+ [require_json.codecsJson.definition.time, createDefaultCodecErrorMessage("JSON time", "a string", "a DuploJS time")],
77
+ [require_string.codecsString.definition.bigint, createDefaultCodecErrorMessage("string bigint", "a string", "a bigint")],
78
+ [require_string.codecsString.definition.boolean, createDefaultCodecErrorMessage("string boolean", "the string \"true\" or \"false\"", "a boolean")],
79
+ [require_string.codecsString.definition.date, createDefaultCodecErrorMessage("string date", "a string", "a DuploJS date")],
80
+ [require_string.codecsString.definition.null, createDefaultCodecErrorMessage("string null", "the string \"null\"", "null")],
81
+ [require_string.codecsString.definition.number, createDefaultCodecErrorMessage("string number", "a string representing a number", "a finite number")],
82
+ [require_string.codecsString.definition.time, createDefaultCodecErrorMessage("string time", "a string", "a DuploJS time")],
83
+ [require_string.codecsString.definition.undefined, createDefaultCodecErrorMessage("string undefined", "the string \"undefined\"", "undefined")]
84
+ ];
85
+ //#endregion
86
+ exports.defaultErrorInterpreterCodecDictionary = defaultErrorInterpreterCodecDictionary;
87
+ exports.defaultErrorInterpreterDataStructureDictionary = defaultErrorInterpreterDataStructureDictionary;
@@ -0,0 +1,60 @@
1
+ import * as DString from '../../../string';
2
+ export declare const defaultErrorInterpreterDataStructureDictionary: {
3
+ readonly "@DuplojsLangDataStructure/array-structure": () => string;
4
+ readonly "@DuplojsLangDataStructure/lazy-structure": () => string;
5
+ readonly "@DuplojsLangDataStructure/non-encodable-string-structure": (source: import('../..').NonEncodableStringStructure) => string;
6
+ readonly "@DuplojsLangDataStructure/object-structure": () => string;
7
+ readonly "@DuplojsLangDataStructure/record-structure": () => string;
8
+ readonly "@DuplojsLangDataStructure/type-structure": () => string;
9
+ readonly "@DuplojsLangDataStructure/union-structure": () => string;
10
+ readonly "@DuplojsLangDataStructure/bigint-type": () => string;
11
+ readonly "@DuplojsLangDataStructure/bigint-literal-type": (source: import('../..').BigintLiteralType<bigint>) => string;
12
+ readonly "@DuplojsLangDataStructure/boolean-type": () => string;
13
+ readonly "@DuplojsLangDataStructure/boolean-literal-type": (source: import('../..').BooleanLiteralType<boolean>) => string;
14
+ readonly "@DuplojsLangDataStructure/date-type": () => string;
15
+ readonly "@DuplojsLangDataStructure/null-type": () => string;
16
+ readonly "@DuplojsLangDataStructure/number-type": () => string;
17
+ readonly "@DuplojsLangDataStructure/number-literal-type": (source: import('../..').NumberLiteralType<number>) => string;
18
+ readonly "@DuplojsLangDataStructure/string-type": () => string;
19
+ readonly "@DuplojsLangDataStructure/string-literal-type": (source: import('../..').StringLiteralType<string>) => string;
20
+ readonly "@DuplojsLangDataStructure/time-type": () => string;
21
+ readonly "@DuplojsLangDataStructure/undefined-type": () => string;
22
+ readonly "@DuplojsLangDataStructure/absolute-path-constraint": () => string;
23
+ readonly "@DuplojsLangDataStructure/allowed-characters-constraint": (source: import('../..').AllowedCharactersConstraint<DString.CharactersRange>) => string;
24
+ readonly "@DuplojsLangDataStructure/array-length-equal-constraint": (source: import('../..').ArrayLengthEqualConstraint<number>) => string;
25
+ readonly "@DuplojsLangDataStructure/between-than-constraint": (source: import('../..').BetweenThanConstraint<number, number>) => string;
26
+ readonly "@DuplojsLangDataStructure/between-than-or-equal-constraint": (source: import('../..').BetweenThanOrEqualConstraint<number, number>) => string;
27
+ readonly "@DuplojsLangDataStructure/email-constraint": () => string;
28
+ readonly "@DuplojsLangDataStructure/even-constraint": () => string;
29
+ readonly "@DuplojsLangDataStructure/greater-than-constraint": (source: import('../..').GreaterThanConstraint<number>) => string;
30
+ readonly "@DuplojsLangDataStructure/greater-than-or-equal-constraint": (source: import('../..').GreaterThanOrEqualConstraint<number>) => string;
31
+ readonly "@DuplojsLangDataStructure/integer-constraint": () => string;
32
+ readonly "@DuplojsLangDataStructure/less-than-constraint": (source: import('../..').LessThanConstraint<number>) => string;
33
+ readonly "@DuplojsLangDataStructure/less-than-or-equal-constraint": (source: import('../..').LessThanOrEqualConstraint<number>) => string;
34
+ readonly "@DuplojsLangDataStructure/max-characters-constraint": (source: import('../..').MaxCharactersConstraint<number>) => string;
35
+ readonly "@DuplojsLangDataStructure/max-elements-constraint": (source: import('../..').MaxElementsConstraint<number>) => string;
36
+ readonly "@DuplojsLangDataStructure/min-characters-constraint": (source: import('../..').MinCharactersConstraint<number>) => string;
37
+ readonly "@DuplojsLangDataStructure/min-elements-constraint": (source: import('../..').MinElementsConstraint<number>) => string;
38
+ readonly "@DuplojsLangDataStructure/multiple-of-constraint": (source: import('../..').MultipleOfConstraint<number>) => string;
39
+ readonly "@DuplojsLangDataStructure/negative-constraint": () => string;
40
+ readonly "@DuplojsLangDataStructure/not-empty-constraint": () => string;
41
+ readonly "@DuplojsLangDataStructure/not-zero-constraint": () => string;
42
+ readonly "@DuplojsLangDataStructure/number-in-string-constraint": () => string;
43
+ readonly "@DuplojsLangDataStructure/odd-constraint": () => string;
44
+ readonly "@DuplojsLangDataStructure/path-constraint": () => string;
45
+ readonly "@DuplojsLangDataStructure/positive-constraint": () => string;
46
+ readonly "@DuplojsLangDataStructure/refine-constraint": () => string;
47
+ readonly "@DuplojsLangDataStructure/regex-constraint": (source: import('../..').RegexConstraint) => string;
48
+ readonly "@DuplojsLangDataStructure/safe-constraint": () => string;
49
+ readonly "@DuplojsLangDataStructure/segment-path-constraint": () => string;
50
+ readonly "@DuplojsLangDataStructure/strict-negative-constraint": () => string;
51
+ readonly "@DuplojsLangDataStructure/strict-positive-constraint": () => string;
52
+ readonly "@DuplojsLangDataStructure/string-length-equal-constraint": (source: import('../..').StringLengthEqualConstraint<number>) => string;
53
+ readonly "@DuplojsLangDataStructure/trimmed-constraint": () => string;
54
+ readonly "@DuplojsLangDataStructure/url-constraint": () => string;
55
+ readonly "@DuplojsLangDataStructure/uuid-constraint": () => string;
56
+ readonly "@DuplojsLangModeling/entity-structure": () => string;
57
+ readonly "@DuplojsLangModeling/new-type-structure": () => string;
58
+ readonly "@DuplojsLangModeling/tagged-object-structure": (source: import('../../../modeling').TaggedObjectStructure<import('../../../modeling').ObjectTag<string>>) => string;
59
+ };
60
+ export declare const defaultErrorInterpreterCodecDictionary: [[import('../..').Codec<import('../..').TheBigint, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheDate, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheTime, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheBigint, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheBoolean, "true" | "false">, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheDate, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheNull, "null">, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheNumber, string & DString.Number>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheTime, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheUndefined, "undefined" | undefined>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string]];
@@ -0,0 +1,86 @@
1
+ import { coalescing } from "../../../array/coalescing.mjs";
2
+ import { join } from "../../../string/join.mjs";
3
+ import { stringify } from "../../../string/stringify.mjs";
4
+ import { to } from "../../../string/to.mjs";
5
+ import { codecsJson } from "../codec/defaults/json.mjs";
6
+ import { codecsString } from "../codec/defaults/string.mjs";
7
+ import { encodeIssueKind } from "./base.mjs";
8
+ //#region scripts/dataStructure/common/error/defaultInterpreter.ts
9
+ const defaultErrorInterpreterDataStructureDictionary = {
10
+ "@DuplojsLangDataStructure/array-structure": () => "Expected an array.",
11
+ "@DuplojsLangDataStructure/lazy-structure": () => "Expected a value matching the resolved structure.",
12
+ "@DuplojsLangDataStructure/non-encodable-string-structure": (source) => `Expected ${stringify(source.definition.value)}.`,
13
+ "@DuplojsLangDataStructure/object-structure": () => "Expected a plain object containing only the defined properties.",
14
+ "@DuplojsLangDataStructure/record-structure": () => "Expected a plain object matching the record definition.",
15
+ "@DuplojsLangDataStructure/type-structure": () => "Expected a value matching the configured type.",
16
+ "@DuplojsLangDataStructure/union-structure": () => "Expected a value matching at least one union member.",
17
+ "@DuplojsLangDataStructure/bigint-type": () => "Expected a bigint.",
18
+ "@DuplojsLangDataStructure/bigint-literal-type": (source) => `Expected ${to(source.definition.value)}n.`,
19
+ "@DuplojsLangDataStructure/boolean-type": () => "Expected a boolean.",
20
+ "@DuplojsLangDataStructure/boolean-literal-type": (source) => `Expected ${source.definition.value}.`,
21
+ "@DuplojsLangDataStructure/date-type": () => "Expected a DuploJS date.",
22
+ "@DuplojsLangDataStructure/null-type": () => "Expected null.",
23
+ "@DuplojsLangDataStructure/number-type": () => "Expected a finite number.",
24
+ "@DuplojsLangDataStructure/number-literal-type": (source) => `Expected ${source.definition.value}.`,
25
+ "@DuplojsLangDataStructure/string-type": () => "Expected a string.",
26
+ "@DuplojsLangDataStructure/string-literal-type": (source) => `Expected ${stringify(source.definition.value)}.`,
27
+ "@DuplojsLangDataStructure/time-type": () => "Expected a DuploJS time.",
28
+ "@DuplojsLangDataStructure/undefined-type": () => "Expected undefined.",
29
+ "@DuplojsLangDataStructure/absolute-path-constraint": () => "Expected an absolute path.",
30
+ "@DuplojsLangDataStructure/allowed-characters-constraint": (source) => `Expected a string containing only characters from ${join(coalescing(source.definition.charactersRange), ", ")}.`,
31
+ "@DuplojsLangDataStructure/array-length-equal-constraint": (source) => `Expected an array containing exactly ${source.definition.length} elements.`,
32
+ "@DuplojsLangDataStructure/between-than-constraint": (source) => `Expected a number greater than ${source.definition.greater} and less than ${source.definition.less}.`,
33
+ "@DuplojsLangDataStructure/between-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.greater} and less than or equal to ${source.definition.less}.`,
34
+ "@DuplojsLangDataStructure/email-constraint": () => "Expected a valid email address.",
35
+ "@DuplojsLangDataStructure/even-constraint": () => "Expected an even number.",
36
+ "@DuplojsLangDataStructure/greater-than-constraint": (source) => `Expected a number greater than ${source.definition.threshold}.`,
37
+ "@DuplojsLangDataStructure/greater-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.threshold}.`,
38
+ "@DuplojsLangDataStructure/integer-constraint": () => "Expected an integer.",
39
+ "@DuplojsLangDataStructure/less-than-constraint": (source) => `Expected a number less than ${source.definition.threshold}.`,
40
+ "@DuplojsLangDataStructure/less-than-or-equal-constraint": (source) => `Expected a number less than or equal to ${source.definition.threshold}.`,
41
+ "@DuplojsLangDataStructure/max-characters-constraint": (source) => `Expected a string containing at most ${source.definition.max} characters.`,
42
+ "@DuplojsLangDataStructure/max-elements-constraint": (source) => `Expected an array containing at most ${source.definition.max} elements.`,
43
+ "@DuplojsLangDataStructure/min-characters-constraint": (source) => `Expected a string containing at least ${source.definition.min} characters.`,
44
+ "@DuplojsLangDataStructure/min-elements-constraint": (source) => `Expected an array containing at least ${source.definition.min} elements.`,
45
+ "@DuplojsLangDataStructure/multiple-of-constraint": (source) => `Expected a multiple of ${source.definition.multiple}.`,
46
+ "@DuplojsLangDataStructure/negative-constraint": () => "Expected a number less than or equal to zero.",
47
+ "@DuplojsLangDataStructure/not-empty-constraint": () => "Expected a non-empty string.",
48
+ "@DuplojsLangDataStructure/not-zero-constraint": () => "Expected a non-zero number.",
49
+ "@DuplojsLangDataStructure/number-in-string-constraint": () => "Expected a string representing a number.",
50
+ "@DuplojsLangDataStructure/odd-constraint": () => "Expected an odd number.",
51
+ "@DuplojsLangDataStructure/path-constraint": () => "Expected a valid path.",
52
+ "@DuplojsLangDataStructure/positive-constraint": () => "Expected a number greater than or equal to zero.",
53
+ "@DuplojsLangDataStructure/refine-constraint": () => "Expected a value satisfying the custom refinement.",
54
+ "@DuplojsLangDataStructure/regex-constraint": (source) => `Expected a string matching ${source.definition.regex.toString()}.`,
55
+ "@DuplojsLangDataStructure/safe-constraint": () => "Expected a number strictly between Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER.",
56
+ "@DuplojsLangDataStructure/segment-path-constraint": () => "Expected a valid path segment.",
57
+ "@DuplojsLangDataStructure/strict-negative-constraint": () => "Expected a number less than zero.",
58
+ "@DuplojsLangDataStructure/strict-positive-constraint": () => "Expected a number greater than zero.",
59
+ "@DuplojsLangDataStructure/string-length-equal-constraint": (source) => `Expected a string containing exactly ${source.definition.length} characters.`,
60
+ "@DuplojsLangDataStructure/trimmed-constraint": () => "Expected a string without leading or trailing whitespace.",
61
+ "@DuplojsLangDataStructure/url-constraint": () => "Expected a valid URL.",
62
+ "@DuplojsLangDataStructure/uuid-constraint": () => "Expected a valid UUID.",
63
+ "@DuplojsLangModeling/entity-structure": () => "Expected a valid entity object.",
64
+ "@DuplojsLangModeling/new-type-structure": () => "Expected a value matching the branded type.",
65
+ "@DuplojsLangModeling/tagged-object-structure": (source) => `Expected a plain object matching one of the tagged variants of ${source.name}.`
66
+ };
67
+ const createDefaultCodecErrorMessage = (codecName, encodedValueDescription, decodedValueDescription) => (_codec, issue) => {
68
+ if (issue.from === "predicate") return encodeIssueKind.has(issue) ? `The ${codecName} codec must produce ${encodedValueDescription}.` : `Expected ${encodedValueDescription} for the ${codecName} codec.`;
69
+ if (issue.from === "encoding") return `The ${codecName} codec could not encode ${decodedValueDescription}.`;
70
+ if (issue.from === "decoding") return `The ${codecName} codec could not decode the value as ${decodedValueDescription}.`;
71
+ return `The ${codecName} codec encountered an external error while ${encodeIssueKind.has(issue) ? "encoding" : "decoding"}.`;
72
+ };
73
+ const defaultErrorInterpreterCodecDictionary = [
74
+ [codecsJson.definition.bigint, createDefaultCodecErrorMessage("JSON bigint", "a string", "a bigint")],
75
+ [codecsJson.definition.date, createDefaultCodecErrorMessage("JSON date", "a string", "a DuploJS date")],
76
+ [codecsJson.definition.time, createDefaultCodecErrorMessage("JSON time", "a string", "a DuploJS time")],
77
+ [codecsString.definition.bigint, createDefaultCodecErrorMessage("string bigint", "a string", "a bigint")],
78
+ [codecsString.definition.boolean, createDefaultCodecErrorMessage("string boolean", "the string \"true\" or \"false\"", "a boolean")],
79
+ [codecsString.definition.date, createDefaultCodecErrorMessage("string date", "a string", "a DuploJS date")],
80
+ [codecsString.definition.null, createDefaultCodecErrorMessage("string null", "the string \"null\"", "null")],
81
+ [codecsString.definition.number, createDefaultCodecErrorMessage("string number", "a string representing a number", "a finite number")],
82
+ [codecsString.definition.time, createDefaultCodecErrorMessage("string time", "a string", "a DuploJS time")],
83
+ [codecsString.definition.undefined, createDefaultCodecErrorMessage("string undefined", "the string \"undefined\"", "undefined")]
84
+ ];
85
+ //#endregion
86
+ export { defaultErrorInterpreterCodecDictionary, defaultErrorInterpreterDataStructureDictionary };
@@ -0,0 +1,3 @@
1
+ export * from './base';
2
+ export * from './interpreter';
3
+ export * from './defaultInterpreter';
@@ -0,0 +1,44 @@
1
+ const require_base = require("../../../kind/base.cjs");
2
+ const require_entries = require("../../../object/entries.cjs");
3
+ const require_entry = require("../../../object/entry.cjs");
4
+ const require_map = require("../../../array/map.cjs");
5
+ const require_reduce = require("../../../array/reduce.cjs");
6
+ const require_pipe = require("../../../common/pipe.cjs");
7
+ const require_base$1 = require("./base.cjs");
8
+ //#region scripts/dataStructure/common/error/interpreter.ts
9
+ function createErrorInterpreter(structureDictionary = {}, codecDictionary = []) {
10
+ const formattedStructureDictionary = require_pipe.pipe(structureDictionary, require_entries.entries, require_map.map(([key, value]) => require_entry.entry(`${require_base.keyKindPrefix}${key}`, value)));
11
+ const getInterpretedMessageStructure = (structure, issue) => require_reduce.reduce(formattedStructureDictionary, require_reduce.reduceFrom(void 0), ({ element: [key, getMessage], next, exit }) => getMessage && key in structure ? exit(getMessage(structure, issue)) : next(void 0));
12
+ const getInterpretedMessageCodec = (codec, issue) => require_reduce.reduce(codecDictionary, require_reduce.reduceFrom(void 0), ({ element: [currentCodec, message], next, exit }) => currentCodec === codec ? exit(message(codec, issue)) : next(void 0));
13
+ return (error) => require_map.map(error.issues, (issue) => {
14
+ if (require_base$1.issueKind.has(issue)) {
15
+ const source = issue.getSource();
16
+ const subSource = issue.getSubSource?.();
17
+ return {
18
+ ...issue,
19
+ interpretedMessage: {
20
+ source: source.definition.message,
21
+ subSource: subSource?.definition.message,
22
+ interpretedSource: getInterpretedMessageStructure(source, issue),
23
+ interpretedSubSource: subSource && getInterpretedMessageStructure(subSource, issue)
24
+ }
25
+ };
26
+ }
27
+ if (require_base$1.encodeIssueKind.has(issue)) return {
28
+ ...issue,
29
+ interpretedMessage: {
30
+ source: issue.message,
31
+ interpretedSource: getInterpretedMessageCodec(issue.getSource(), issue)
32
+ }
33
+ };
34
+ return {
35
+ ...issue,
36
+ interpretedMessage: {
37
+ source: issue.message,
38
+ interpretedSource: getInterpretedMessageCodec(issue.getSource(), issue)
39
+ }
40
+ };
41
+ });
42
+ }
43
+ //#endregion
44
+ exports.createErrorInterpreter = createErrorInterpreter;
@@ -0,0 +1,32 @@
1
+ import { Structure, Structures } from '../../structure';
2
+ import { Type, Types } from '../../type';
3
+ import { Constraint, Constraints } from '../../constraint';
4
+ import { Error, DecodeIssue, EncodeIssue, Issue } from './base';
5
+ import { Codec } from '../codec';
6
+ import * as DKind from '../../../kind';
7
+ import * as DCommon from '../../../common';
8
+ export interface InterpretedMessage {
9
+ source?: string;
10
+ interpretedSource?: string;
11
+ subSource?: string;
12
+ interpretedSubSource?: string;
13
+ }
14
+ export interface InterpretedIssue extends Issue {
15
+ interpretedMessage: InterpretedMessage;
16
+ }
17
+ export interface InterpretedEncodedIssue extends EncodeIssue {
18
+ interpretedMessage: InterpretedMessage;
19
+ }
20
+ export interface InterpretedDecodedIssue extends DecodeIssue {
21
+ interpretedMessage: InterpretedMessage;
22
+ }
23
+ export type InterpretedIssues = (InterpretedIssue | InterpretedEncodedIssue | InterpretedDecodedIssue);
24
+ export type StructureDictionaryParams = DCommon.SimplifyTopLevel<Omit<{
25
+ [DataStructure in (Types | Structures | Constraints) as DKind.GetName<DataStructure>]?: (structure: DataStructure, issue: Issue) => string;
26
+ }, DKind.GetName<Type> | DKind.GetName<Structure> | DKind.GetName<Constraint>>>;
27
+ export type CodecDictionaryParams = [
28
+ Codec,
29
+ (codec: Codec, issue: EncodeIssue | DecodeIssue) => string
30
+ ][];
31
+ export declare function createErrorInterpreter(structureDictionary?: StructureDictionaryParams, codecDictionary?: CodecDictionaryParams): (error: Error) => readonly InterpretedIssues[];
32
+ export type ErrorInterpreter = ReturnType<typeof createErrorInterpreter>;
@@ -0,0 +1,44 @@
1
+ import { keyKindPrefix } from "../../../kind/base.mjs";
2
+ import { entries } from "../../../object/entries.mjs";
3
+ import { entry } from "../../../object/entry.mjs";
4
+ import { map } from "../../../array/map.mjs";
5
+ import { reduce, reduceFrom } from "../../../array/reduce.mjs";
6
+ import { pipe } from "../../../common/pipe.mjs";
7
+ import { encodeIssueKind, issueKind } from "./base.mjs";
8
+ //#region scripts/dataStructure/common/error/interpreter.ts
9
+ function createErrorInterpreter(structureDictionary = {}, codecDictionary = []) {
10
+ const formattedStructureDictionary = pipe(structureDictionary, entries, map(([key, value]) => entry(`${keyKindPrefix}${key}`, value)));
11
+ const getInterpretedMessageStructure = (structure, issue) => reduce(formattedStructureDictionary, reduceFrom(void 0), ({ element: [key, getMessage], next, exit }) => getMessage && key in structure ? exit(getMessage(structure, issue)) : next(void 0));
12
+ const getInterpretedMessageCodec = (codec, issue) => reduce(codecDictionary, reduceFrom(void 0), ({ element: [currentCodec, message], next, exit }) => currentCodec === codec ? exit(message(codec, issue)) : next(void 0));
13
+ return (error) => map(error.issues, (issue) => {
14
+ if (issueKind.has(issue)) {
15
+ const source = issue.getSource();
16
+ const subSource = issue.getSubSource?.();
17
+ return {
18
+ ...issue,
19
+ interpretedMessage: {
20
+ source: source.definition.message,
21
+ subSource: subSource?.definition.message,
22
+ interpretedSource: getInterpretedMessageStructure(source, issue),
23
+ interpretedSubSource: subSource && getInterpretedMessageStructure(subSource, issue)
24
+ }
25
+ };
26
+ }
27
+ if (encodeIssueKind.has(issue)) return {
28
+ ...issue,
29
+ interpretedMessage: {
30
+ source: issue.message,
31
+ interpretedSource: getInterpretedMessageCodec(issue.getSource(), issue)
32
+ }
33
+ };
34
+ return {
35
+ ...issue,
36
+ interpretedMessage: {
37
+ source: issue.message,
38
+ interpretedSource: getInterpretedMessageCodec(issue.getSource(), issue)
39
+ }
40
+ };
41
+ });
42
+ }
43
+ //#endregion
44
+ export { createErrorInterpreter };
@@ -1,4 +1,3 @@
1
1
  export * from './codec';
2
2
  export * from './error';
3
- export * from './errorInterpreter';
4
3
  export * from './resultSymbol';
@@ -3,11 +3,9 @@ import type * as DCommon from '../../../common';
3
3
  import type * as DKind from '../../../kind';
4
4
  import * as DString from '../../../string';
5
5
  export declare const allowedCharactersConstraintKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/allowed-characters-constraint", unknown>>;
6
- type AllowedCharactersConstraintValue<GenericCharactersRange extends DString.CharactersRange> = string & DCommon.UnionToIntersection<GenericCharactersRange extends any ? DString.AllowedCharacters<GenericCharactersRange> : never>;
7
6
  export interface AllowedCharactersConstraintDefinition<GenericCharactersRange extends DString.CharactersRange = DString.CharactersRange> extends ConstraintDefinition {
8
7
  readonly charactersRange: DCommon.MaybeArray<GenericCharactersRange>;
9
8
  }
10
- export interface AllowedCharactersConstraint<GenericCharactersRange extends DString.CharactersRange = DString.CharactersRange> extends DCommon.Forward<Constraint<string, AllowedCharactersConstraintValue<GenericCharactersRange>, AllowedCharactersConstraintDefinition<GenericCharactersRange>> & DKind.Kind<typeof allowedCharactersConstraintKind>> {
9
+ export interface AllowedCharactersConstraint<GenericCharactersRange extends DString.CharactersRange = DString.CharactersRange> extends DCommon.Forward<Constraint<string, string & DString.AllowedCharacters<GenericCharactersRange>, AllowedCharactersConstraintDefinition<GenericCharactersRange>> & DKind.Kind<typeof allowedCharactersConstraintKind>> {
11
10
  }
12
11
  export declare const AllowedCharactersConstraint: <GenericCharactersRange extends DString.CharactersRange>(charactersRange: DCommon.MaybeArray<GenericCharactersRange>) => AllowedCharactersConstraint<GenericCharactersRange>;
13
- export {};
@@ -1,6 +1,7 @@
1
1
  import { Constraint } from '../base';
2
2
  import type * as DDefaults from "../defaults";
3
3
  export interface ConstraintsStore {
4
+ base: Constraint;
4
5
  allowedCharacters: DDefaults.AllowedCharactersConstraint;
5
6
  email: DDefaults.EmailConstraint;
6
7
  url: DDefaults.UrlConstraint;
@@ -1,6 +1,7 @@
1
1
  import { FundamentalType } from '../base';
2
2
  import { TheBigint, TheBoolean, TheDate, TheNull, TheNumber, TheString, TheTime, TheUndefined } from '../defaults';
3
3
  export interface FundamentalTypesStore {
4
+ base: FundamentalType;
4
5
  bigint: TheBigint;
5
6
  boolean: TheBoolean;
6
7
  date: TheDate;
@@ -2,7 +2,7 @@ const require_object = require("../structure/defaults/object.cjs");
2
2
  //#region scripts/dataStructure/helpers/extend.ts
3
3
  function extend(structure, shape) {
4
4
  return require_object.ObjectStructure({
5
- ...Object.fromEntries(structure.definition.shape.value.map((entry) => [entry.key, entry.value])),
5
+ ...Object.fromEntries(structure.definition.optimizedShape.value.map((entry) => [entry.key, entry.value])),
6
6
  ...shape
7
7
  }, []);
8
8
  }
@@ -1,3 +1,3 @@
1
1
  import { ObjectStructure, ShapeObjectStructureValue, ShapeObjectStructure, StructureInitialValue } from '../structure';
2
2
  import type * as DObject from '../../object';
3
- export declare function extend<GenericObjectStructure extends ObjectStructure, GenericShape extends ShapeObjectStructure>(structure: GenericObjectStructure, shape: GenericShape): ObjectStructure<DObject.AssignObjects<Extract<StructureInitialValue<GenericObjectStructure>, object>, ShapeObjectStructureValue<GenericShape>>, readonly []>;
3
+ export declare function extend<GenericObjectStructure extends ObjectStructure, GenericShape extends ShapeObjectStructure>(structure: GenericObjectStructure, shape: GenericShape): ObjectStructure<DObject.Assign<Extract<StructureInitialValue<GenericObjectStructure>, object>, ShapeObjectStructureValue<GenericShape>>, readonly []>;
@@ -2,7 +2,7 @@ import { ObjectStructure } from "../structure/defaults/object.mjs";
2
2
  //#region scripts/dataStructure/helpers/extend.ts
3
3
  function extend(structure, shape) {
4
4
  return ObjectStructure({
5
- ...Object.fromEntries(structure.definition.shape.value.map((entry) => [entry.key, entry.value])),
5
+ ...Object.fromEntries(structure.definition.optimizedShape.value.map((entry) => [entry.key, entry.value])),
6
6
  ...shape
7
7
  }, []);
8
8
  }
@@ -14,6 +14,8 @@ export * from './greaterThan';
14
14
  export * from './greaterThanOrEqual';
15
15
  export * from './integer';
16
16
  export * from './isNullStructure';
17
+ export * from './isNullable';
18
+ export * from './isOptional';
17
19
  export * from './isUndefinedStructure';
18
20
  export * from './lazy';
19
21
  export * from './lessThan';
@@ -39,17 +41,19 @@ export * from './path';
39
41
  export * from './positive';
40
42
  export * from './record';
41
43
  export * from './refine';
44
+ export * from './regex';
42
45
  export * from './required';
43
46
  export * from './safe';
44
47
  export * from './segmentPath';
45
- export * from './string';
46
48
  export * from './strictNegative';
47
49
  export * from './strictPositive';
50
+ export * from './string';
48
51
  export * from './stringLengthEqual';
49
52
  export * from './time';
50
53
  export * from './trimmed';
54
+ export * from './typeStructureIdentifier';
51
55
  export * from './undefined';
52
56
  export * from './union';
57
+ export * from './unwrapLazy';
53
58
  export * from './url';
54
59
  export * from './uuid';
55
- export * from './regex';
@@ -0,0 +1,12 @@
1
+ const require_identifier = require("../structure/identifier.cjs");
2
+ const require_lazy = require("../structure/defaults/lazy.cjs");
3
+ const require_union = require("../structure/defaults/union.cjs");
4
+ const require_isNullStructure = require("./isNullStructure.cjs");
5
+ //#region scripts/dataStructure/helpers/isNullable.ts
6
+ function isNullable(structure) {
7
+ if (require_identifier.structureIdentifier(structure, require_lazy.lazyStructureKind)) return isNullable(structure.definition.getter.value);
8
+ if (!require_identifier.structureIdentifier(structure, require_union.unionStructureKind)) return require_isNullStructure.isNullStructure(structure);
9
+ return structure.definition.values.value.some(require_isNullStructure.isNullStructure);
10
+ }
11
+ //#endregion
12
+ exports.isNullable = isNullable;
@@ -0,0 +1,2 @@
1
+ import { Structure } from '../structure';
2
+ export declare function isNullable(structure: Structure): boolean;
@@ -0,0 +1,12 @@
1
+ import { structureIdentifier } from "../structure/identifier.mjs";
2
+ import { lazyStructureKind } from "../structure/defaults/lazy.mjs";
3
+ import { unionStructureKind } from "../structure/defaults/union.mjs";
4
+ import { isNullStructure } from "./isNullStructure.mjs";
5
+ //#region scripts/dataStructure/helpers/isNullable.ts
6
+ function isNullable(structure) {
7
+ if (structureIdentifier(structure, lazyStructureKind)) return isNullable(structure.definition.getter.value);
8
+ if (!structureIdentifier(structure, unionStructureKind)) return isNullStructure(structure);
9
+ return structure.definition.values.value.some(isNullStructure);
10
+ }
11
+ //#endregion
12
+ export { isNullable };
@@ -0,0 +1,12 @@
1
+ const require_identifier = require("../structure/identifier.cjs");
2
+ const require_lazy = require("../structure/defaults/lazy.cjs");
3
+ const require_union = require("../structure/defaults/union.cjs");
4
+ const require_isUndefinedStructure = require("./isUndefinedStructure.cjs");
5
+ //#region scripts/dataStructure/helpers/isOptional.ts
6
+ function isOptional(structure) {
7
+ if (require_identifier.structureIdentifier(structure, require_lazy.lazyStructureKind)) return isOptional(structure.definition.getter.value);
8
+ if (!require_identifier.structureIdentifier(structure, require_union.unionStructureKind)) return require_isUndefinedStructure.isUndefinedStructure(structure);
9
+ return structure.definition.values.value.some(require_isUndefinedStructure.isUndefinedStructure);
10
+ }
11
+ //#endregion
12
+ exports.isOptional = isOptional;
@@ -0,0 +1,2 @@
1
+ import { Structure } from '../structure';
2
+ export declare function isOptional(structure: Structure): boolean;
@@ -0,0 +1,12 @@
1
+ import { structureIdentifier } from "../structure/identifier.mjs";
2
+ import { lazyStructureKind } from "../structure/defaults/lazy.mjs";
3
+ import { unionStructureKind } from "../structure/defaults/union.mjs";
4
+ import { isUndefinedStructure } from "./isUndefinedStructure.mjs";
5
+ //#region scripts/dataStructure/helpers/isOptional.ts
6
+ function isOptional(structure) {
7
+ if (structureIdentifier(structure, lazyStructureKind)) return isOptional(structure.definition.getter.value);
8
+ if (!structureIdentifier(structure, unionStructureKind)) return isUndefinedStructure(structure);
9
+ return structure.definition.values.value.some(isUndefinedStructure);
10
+ }
11
+ //#endregion
12
+ export { isOptional };
@@ -14,7 +14,7 @@ function partialStructure(structure) {
14
14
  return require_union$1.union([require_undefined.undefined(), structure]);
15
15
  }
16
16
  function partial(structure) {
17
- return require_object.object(Object.fromEntries(structure.definition.shape.value.map((entry) => [entry.key, require_lazy$1.lazy(() => partialStructure(entry.value))])));
17
+ return require_object.object(Object.fromEntries(structure.definition.optimizedShape.value.map((entry) => [entry.key, require_lazy$1.lazy(() => partialStructure(entry.value))])));
18
18
  }
19
19
  //#endregion
20
20
  exports.partial = partial;
@@ -14,7 +14,7 @@ function partialStructure(structure) {
14
14
  return union([undefinedHelper(), structure]);
15
15
  }
16
16
  function partial(structure) {
17
- return object(Object.fromEntries(structure.definition.shape.value.map((entry) => [entry.key, lazy(() => partialStructure(entry.value))])));
17
+ return object(Object.fromEntries(structure.definition.optimizedShape.value.map((entry) => [entry.key, lazy(() => partialStructure(entry.value))])));
18
18
  }
19
19
  //#endregion
20
20
  export { partial };
@@ -15,7 +15,7 @@ function requiredStructure(structure) {
15
15
  return require_union$1.union(values);
16
16
  }
17
17
  function required(structure) {
18
- return require_object.object(Object.fromEntries(structure.definition.shape.value.map((entry) => [entry.key, require_lazy$1.lazy(() => requiredStructure(entry.value))])));
18
+ return require_object.object(Object.fromEntries(structure.definition.optimizedShape.value.map((entry) => [entry.key, require_lazy$1.lazy(() => requiredStructure(entry.value))])));
19
19
  }
20
20
  //#endregion
21
21
  exports.required = required;
@@ -15,7 +15,7 @@ function requiredStructure(structure) {
15
15
  return union(values);
16
16
  }
17
17
  function required(structure) {
18
- return object(Object.fromEntries(structure.definition.shape.value.map((entry) => [entry.key, lazy(() => requiredStructure(entry.value))])));
18
+ return object(Object.fromEntries(structure.definition.optimizedShape.value.map((entry) => [entry.key, lazy(() => requiredStructure(entry.value))])));
19
19
  }
20
20
  //#endregion
21
21
  export { required };
@@ -0,0 +1,14 @@
1
+ const require_identifier = require("../structure/identifier.cjs");
2
+ const require_type = require("../structure/defaults/type.cjs");
3
+ const require_identifier$1 = require("../type/identifier.cjs");
4
+ //#region scripts/dataStructure/helpers/typeStructureIdentifier.ts
5
+ function typeStructureIdentifier(...args) {
6
+ if (args.length === 1) {
7
+ const [typeKind] = args;
8
+ return (structure) => typeStructureIdentifier(structure, typeKind);
9
+ }
10
+ const [structure, typeKind] = args;
11
+ return require_identifier.structureIdentifier(structure, require_type.typeStructureKind) && require_identifier$1.typeIdentifier(structure.definition.type, typeKind);
12
+ }
13
+ //#endregion
14
+ exports.typeStructureIdentifier = typeStructureIdentifier;
@@ -0,0 +1,6 @@
1
+ import { TypeStructure, Structure } from '../structure';
2
+ import { TypeValue, typeIdentifier, Types } from '../type';
3
+ import type * as DKind from '../../kind';
4
+ import type * as DArray from '../../array';
5
+ export declare function typeStructureIdentifier<GenericTypeKindHandler extends DArray.Unwrap<Parameters<typeof typeIdentifier>[1]>>(typeKind: GenericTypeKindHandler | GenericTypeKindHandler[]): (structure: Structure) => structure is TypeStructure<TypeValue<Extract<Types, DKind.Kind<GenericTypeKindHandler>>>>;
6
+ export declare function typeStructureIdentifier<GenericTypeKindHandler extends DArray.Unwrap<Parameters<typeof typeIdentifier>[1]>>(structure: Structure, typeKind: GenericTypeKindHandler | GenericTypeKindHandler[]): structure is TypeStructure<TypeValue<Extract<Types, DKind.Kind<GenericTypeKindHandler>>>>;