@duplojs/utils 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/array/types/createTuple.d.ts +1 -1
  2. package/dist/clean/constraint/base.cjs +7 -0
  3. package/dist/clean/constraint/base.d.ts +26 -6
  4. package/dist/clean/constraint/base.mjs +7 -0
  5. package/dist/clean/constraint/cast.cjs +18 -0
  6. package/dist/clean/constraint/cast.d.ts +29 -0
  7. package/dist/clean/constraint/cast.mjs +16 -0
  8. package/dist/clean/constraint/defaultConstraint/number.cjs +2 -10
  9. package/dist/clean/constraint/defaultConstraint/number.d.ts +12 -37
  10. package/dist/clean/constraint/defaultConstraint/number.mjs +3 -10
  11. package/dist/clean/constraint/defaultConstraint/string.d.ts +9 -5
  12. package/dist/clean/constraint/index.d.ts +1 -0
  13. package/dist/clean/constraint/set.cjs +7 -1
  14. package/dist/clean/constraint/set.d.ts +25 -5
  15. package/dist/clean/constraint/set.mjs +7 -1
  16. package/dist/clean/entity/index.cjs +14 -4
  17. package/dist/clean/entity/index.d.ts +11 -1
  18. package/dist/clean/entity/index.mjs +15 -6
  19. package/dist/clean/index.cjs +5 -1
  20. package/dist/clean/index.d.ts +1 -0
  21. package/dist/clean/index.mjs +4 -2
  22. package/dist/clean/newType.cjs +6 -1
  23. package/dist/clean/newType.d.ts +20 -5
  24. package/dist/clean/newType.mjs +6 -1
  25. package/dist/clean/primitive/operations/equal.cjs +3 -0
  26. package/dist/clean/primitive/operations/equal.d.ts +2 -2
  27. package/dist/clean/primitive/operations/equal.mjs +3 -0
  28. package/dist/clean/toMapDataParser.cjs +52 -0
  29. package/dist/clean/toMapDataParser.d.ts +53 -0
  30. package/dist/clean/toMapDataParser.mjs +50 -0
  31. package/dist/common/asserts.cjs +12 -0
  32. package/dist/common/asserts.d.ts +26 -0
  33. package/dist/common/asserts.mjs +12 -1
  34. package/dist/common/callThen.cjs +14 -0
  35. package/dist/common/callThen.d.ts +35 -0
  36. package/dist/common/callThen.mjs +12 -0
  37. package/dist/common/index.d.ts +3 -0
  38. package/dist/common/printer.cjs +73 -0
  39. package/dist/common/printer.d.ts +139 -0
  40. package/dist/common/printer.mjs +73 -0
  41. package/dist/common/queue.cjs +90 -0
  42. package/dist/common/queue.d.ts +46 -0
  43. package/dist/common/queue.mjs +87 -0
  44. package/dist/common/types/and.d.ts +1 -2
  45. package/dist/common/types/or.d.ts +1 -2
  46. package/dist/dataParser/base.cjs +12 -35
  47. package/dist/dataParser/base.d.ts +6 -9
  48. package/dist/dataParser/base.mjs +8 -30
  49. package/dist/dataParser/error.cjs +39 -21
  50. package/dist/dataParser/error.d.ts +19 -19
  51. package/dist/dataParser/error.mjs +37 -18
  52. package/dist/dataParser/extended/index.cjs +3 -4
  53. package/dist/dataParser/extended/index.mjs +1 -1
  54. package/dist/dataParser/identifier.d.ts +6 -6
  55. package/dist/dataParser/index.cjs +3 -6
  56. package/dist/dataParser/index.mjs +2 -2
  57. package/dist/dataParser/parsers/array/checkers/max.cjs +3 -6
  58. package/dist/dataParser/parsers/array/checkers/max.mjs +4 -7
  59. package/dist/dataParser/parsers/array/checkers/min.cjs +3 -6
  60. package/dist/dataParser/parsers/array/checkers/min.mjs +4 -7
  61. package/dist/dataParser/parsers/array/index.cjs +8 -8
  62. package/dist/dataParser/parsers/array/index.mjs +4 -4
  63. package/dist/dataParser/parsers/bigint/checkers/max.cjs +2 -2
  64. package/dist/dataParser/parsers/bigint/checkers/max.mjs +3 -3
  65. package/dist/dataParser/parsers/bigint/checkers/min.cjs +2 -2
  66. package/dist/dataParser/parsers/bigint/checkers/min.mjs +3 -3
  67. package/dist/dataParser/parsers/bigint/index.cjs +2 -2
  68. package/dist/dataParser/parsers/bigint/index.mjs +3 -3
  69. package/dist/dataParser/parsers/boolean.cjs +3 -3
  70. package/dist/dataParser/parsers/boolean.mjs +4 -4
  71. package/dist/dataParser/parsers/date.cjs +4 -4
  72. package/dist/dataParser/parsers/date.mjs +5 -5
  73. package/dist/dataParser/parsers/empty.cjs +2 -2
  74. package/dist/dataParser/parsers/empty.mjs +3 -3
  75. package/dist/dataParser/parsers/literal.cjs +2 -2
  76. package/dist/dataParser/parsers/literal.mjs +3 -3
  77. package/dist/dataParser/parsers/nil.cjs +2 -2
  78. package/dist/dataParser/parsers/nil.mjs +3 -3
  79. package/dist/dataParser/parsers/number/checkers/int.cjs +2 -2
  80. package/dist/dataParser/parsers/number/checkers/int.mjs +3 -3
  81. package/dist/dataParser/parsers/number/checkers/max.cjs +3 -1
  82. package/dist/dataParser/parsers/number/checkers/max.mjs +4 -2
  83. package/dist/dataParser/parsers/number/checkers/min.cjs +3 -1
  84. package/dist/dataParser/parsers/number/checkers/min.mjs +4 -2
  85. package/dist/dataParser/parsers/number/index.cjs +2 -2
  86. package/dist/dataParser/parsers/number/index.mjs +3 -3
  87. package/dist/dataParser/parsers/object/index.cjs +8 -8
  88. package/dist/dataParser/parsers/object/index.mjs +4 -4
  89. package/dist/dataParser/parsers/pipe.cjs +25 -10
  90. package/dist/dataParser/parsers/pipe.mjs +22 -7
  91. package/dist/dataParser/parsers/record/index.cjs +18 -16
  92. package/dist/dataParser/parsers/record/index.mjs +8 -6
  93. package/dist/dataParser/parsers/recover.cjs +7 -6
  94. package/dist/dataParser/parsers/recover.mjs +2 -1
  95. package/dist/dataParser/parsers/refine.cjs +3 -1
  96. package/dist/dataParser/parsers/refine.mjs +4 -2
  97. package/dist/dataParser/parsers/string/checkers/email.cjs +2 -2
  98. package/dist/dataParser/parsers/string/checkers/email.mjs +3 -3
  99. package/dist/dataParser/parsers/string/checkers/max.cjs +3 -1
  100. package/dist/dataParser/parsers/string/checkers/max.mjs +4 -2
  101. package/dist/dataParser/parsers/string/checkers/min.cjs +3 -1
  102. package/dist/dataParser/parsers/string/checkers/min.mjs +4 -2
  103. package/dist/dataParser/parsers/string/checkers/regex.cjs +2 -2
  104. package/dist/dataParser/parsers/string/checkers/regex.mjs +3 -3
  105. package/dist/dataParser/parsers/string/checkers/url.cjs +4 -4
  106. package/dist/dataParser/parsers/string/checkers/url.mjs +5 -5
  107. package/dist/dataParser/parsers/string/index.cjs +2 -2
  108. package/dist/dataParser/parsers/string/index.mjs +3 -3
  109. package/dist/dataParser/parsers/templateLiteral/index.cjs +2 -2
  110. package/dist/dataParser/parsers/templateLiteral/index.mjs +3 -3
  111. package/dist/dataParser/parsers/time/checkers/max.cjs +3 -1
  112. package/dist/dataParser/parsers/time/checkers/max.mjs +4 -2
  113. package/dist/dataParser/parsers/time/checkers/min.cjs +3 -1
  114. package/dist/dataParser/parsers/time/checkers/min.mjs +4 -2
  115. package/dist/dataParser/parsers/time/index.cjs +4 -4
  116. package/dist/dataParser/parsers/time/index.mjs +5 -5
  117. package/dist/dataParser/parsers/transform.cjs +6 -6
  118. package/dist/dataParser/parsers/transform.d.ts +2 -2
  119. package/dist/dataParser/parsers/transform.mjs +4 -4
  120. package/dist/dataParser/parsers/tuple.cjs +14 -14
  121. package/dist/dataParser/parsers/tuple.mjs +4 -4
  122. package/dist/dataParser/parsers/union.cjs +26 -8
  123. package/dist/dataParser/parsers/union.mjs +26 -8
  124. package/dist/flow/calledByNext.cjs +13 -0
  125. package/dist/flow/calledByNext.d.ts +47 -0
  126. package/dist/flow/calledByNext.mjs +11 -0
  127. package/dist/flow/debounce.cjs +16 -0
  128. package/dist/flow/debounce.d.ts +63 -0
  129. package/dist/flow/debounce.mjs +14 -0
  130. package/dist/flow/exec.cjs +101 -0
  131. package/dist/flow/exec.d.ts +4 -3
  132. package/dist/flow/exec.mjs +101 -0
  133. package/dist/flow/index.cjs +28 -0
  134. package/dist/flow/index.d.ts +5 -0
  135. package/dist/flow/index.mjs +10 -1
  136. package/dist/flow/queue.cjs +19 -0
  137. package/dist/flow/queue.d.ts +47 -0
  138. package/dist/flow/queue.mjs +17 -0
  139. package/dist/flow/run.cjs +118 -0
  140. package/dist/flow/run.d.ts +6 -4
  141. package/dist/flow/run.mjs +113 -1
  142. package/dist/flow/theFlow/calledByNext.cjs +11 -0
  143. package/dist/flow/theFlow/calledByNext.d.ts +5 -0
  144. package/dist/flow/theFlow/calledByNext.mjs +8 -0
  145. package/dist/flow/theFlow/debounce.cjs +11 -0
  146. package/dist/flow/theFlow/debounce.d.ts +9 -0
  147. package/dist/flow/theFlow/debounce.mjs +8 -0
  148. package/dist/flow/theFlow/index.d.ts +11 -3
  149. package/dist/flow/theFlow/queue.cjs +11 -0
  150. package/dist/flow/theFlow/queue.d.ts +9 -0
  151. package/dist/flow/theFlow/queue.mjs +8 -0
  152. package/dist/flow/theFlow/throttling.cjs +11 -0
  153. package/dist/flow/theFlow/throttling.d.ts +10 -0
  154. package/dist/flow/theFlow/throttling.mjs +8 -0
  155. package/dist/flow/throttling.cjs +27 -0
  156. package/dist/flow/throttling.d.ts +60 -0
  157. package/dist/flow/throttling.mjs +25 -0
  158. package/dist/flow/toFunction.cjs +15 -0
  159. package/dist/flow/toFunction.d.ts +56 -0
  160. package/dist/flow/toFunction.mjs +13 -0
  161. package/dist/index.cjs +11 -0
  162. package/dist/index.mjs +4 -1
  163. package/dist/metadata.json +126 -0
  164. package/dist/number/types/isGreater.d.ts +26 -3
  165. package/dist/object/types/getPropsWithValue.d.ts +1 -1
  166. package/dist/object/types/getPropsWithValueExtends.d.ts +1 -1
  167. package/dist/string/length.d.ts +2 -2
  168. package/dist/string/types/split.d.ts +6 -5
  169. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { dataParserInit } from '../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../error.mjs';
2
+ import { addIssue } from '../error.mjs';
3
3
  import { createDataParserKind } from '../kind.mjs';
4
4
  import { createOverride } from '../../common/override.mjs';
5
5
 
@@ -12,14 +12,14 @@ function empty(definition) {
12
12
  errorMessage: definition?.errorMessage,
13
13
  checkers: definition?.checkers ?? [],
14
14
  coerce: definition?.coerce ?? false,
15
- }, (data, _error, self) => {
15
+ }, (data, error, self) => {
16
16
  if (data === undefined) {
17
17
  return data;
18
18
  }
19
19
  else if (self.definition.coerce && data === "undefined") {
20
20
  return undefined;
21
21
  }
22
- return SymbolDataParserErrorIssue;
22
+ return addIssue(error, "undefined", data, self.definition.errorMessage);
23
23
  }, empty.overrideHandler);
24
24
  return self;
25
25
  }
@@ -15,11 +15,11 @@ function literal(value, definition) {
15
15
  errorMessage: definition?.errorMessage,
16
16
  checkers: definition?.checkers ?? [],
17
17
  value: coalescing.coalescing(value),
18
- }, (data, _error, self) => {
18
+ }, (data, error$1, self) => {
19
19
  if (self.definition.value.includes(data)) {
20
20
  return data;
21
21
  }
22
- return error.SymbolDataParserErrorIssue;
22
+ return error.addIssue(error$1, `one of ${self.definition.value.map((value) => String(value)).join(", ")}`, data, self.definition.errorMessage);
23
23
  }, literal.overrideHandler);
24
24
  return self;
25
25
  }
@@ -1,5 +1,5 @@
1
1
  import { dataParserInit } from '../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../error.mjs';
2
+ import { addIssue } from '../error.mjs';
3
3
  import { createDataParserKind } from '../kind.mjs';
4
4
  import { coalescing } from '../../array/coalescing.mjs';
5
5
  import { createOverride } from '../../common/override.mjs';
@@ -13,11 +13,11 @@ function literal(value, definition) {
13
13
  errorMessage: definition?.errorMessage,
14
14
  checkers: definition?.checkers ?? [],
15
15
  value: coalescing(value),
16
- }, (data, _error, self) => {
16
+ }, (data, error, self) => {
17
17
  if (self.definition.value.includes(data)) {
18
18
  return data;
19
19
  }
20
- return SymbolDataParserErrorIssue;
20
+ return addIssue(error, `one of ${self.definition.value.map((value) => String(value)).join(", ")}`, data, self.definition.errorMessage);
21
21
  }, literal.overrideHandler);
22
22
  return self;
23
23
  }
@@ -14,14 +14,14 @@ function nil(definition) {
14
14
  errorMessage: definition?.errorMessage,
15
15
  checkers: definition?.checkers ?? [],
16
16
  coerce: definition?.coerce ?? false,
17
- }, (data, _error, self) => {
17
+ }, (data, error$1, self) => {
18
18
  if (data === null) {
19
19
  return data;
20
20
  }
21
21
  else if (self.definition.coerce && data === "null") {
22
22
  return null;
23
23
  }
24
- return error.SymbolDataParserErrorIssue;
24
+ return error.addIssue(error$1, "null", data, self.definition.errorMessage);
25
25
  }, nil.overrideHandler);
26
26
  return self;
27
27
  }
@@ -1,5 +1,5 @@
1
1
  import { dataParserInit } from '../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../error.mjs';
2
+ import { addIssue } from '../error.mjs';
3
3
  import { createDataParserKind } from '../kind.mjs';
4
4
  import { createOverride } from '../../common/override.mjs';
5
5
 
@@ -12,14 +12,14 @@ function nil(definition) {
12
12
  errorMessage: definition?.errorMessage,
13
13
  checkers: definition?.checkers ?? [],
14
14
  coerce: definition?.coerce ?? false,
15
- }, (data, _error, self) => {
15
+ }, (data, error, self) => {
16
16
  if (data === null) {
17
17
  return data;
18
18
  }
19
19
  else if (self.definition.coerce && data === "null") {
20
20
  return null;
21
21
  }
22
- return SymbolDataParserErrorIssue;
22
+ return addIssue(error, "null", data, self.definition.errorMessage);
23
23
  }, nil.overrideHandler);
24
24
  return self;
25
25
  }
@@ -9,11 +9,11 @@ const checkerIntKind = kind.createDataParserKind("checker-number-int");
9
9
  function checkerInt(definition = {}) {
10
10
  return base.dataParserCheckerInit(checkerIntKind, {
11
11
  definition,
12
- }, (data) => {
12
+ }, (data, error$1, self) => {
13
13
  if (Number.isInteger(data)) {
14
14
  return data;
15
15
  }
16
- return error.SymbolDataParserErrorIssue;
16
+ return error.addIssue(error$1, "integer", data, self.definition.errorMessage);
17
17
  });
18
18
  }
19
19
  function int(definition) {
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../../error.mjs';
2
+ import { addIssue } from '../../../error.mjs';
3
3
  import { number } from '../index.mjs';
4
4
  import { createDataParserKind } from '../../../kind.mjs';
5
5
 
@@ -7,11 +7,11 @@ const checkerIntKind = createDataParserKind("checker-number-int");
7
7
  function checkerInt(definition = {}) {
8
8
  return dataParserCheckerInit(checkerIntKind, {
9
9
  definition,
10
- }, (data) => {
10
+ }, (data, error, self) => {
11
11
  if (Number.isInteger(data)) {
12
12
  return data;
13
13
  }
14
- return SymbolDataParserErrorIssue;
14
+ return addIssue(error, "integer", data, self.definition.errorMessage);
15
15
  });
16
16
  }
17
17
  function int(definition) {
@@ -11,7 +11,9 @@ function checkerNumberMax(max, definition = {}) {
11
11
  ...definition,
12
12
  max,
13
13
  },
14
- }, (value, self) => value <= self.definition.max ? value : error.SymbolDataParserErrorIssue);
14
+ }, (value, error$1, self) => value <= self.definition.max
15
+ ? value
16
+ : error.addIssue(error$1, `number <= ${self.definition.max}`, value, self.definition.errorMessage));
15
17
  }
16
18
 
17
19
  exports.checkerNumberMax = checkerNumberMax;
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../../error.mjs';
2
+ import { addIssue } from '../../../error.mjs';
3
3
  import { createDataParserKind } from '../../../kind.mjs';
4
4
 
5
5
  const checkerNumberMaxKind = createDataParserKind("checker-number-max");
@@ -9,7 +9,9 @@ function checkerNumberMax(max, definition = {}) {
9
9
  ...definition,
10
10
  max,
11
11
  },
12
- }, (value, self) => value <= self.definition.max ? value : SymbolDataParserErrorIssue);
12
+ }, (value, error, self) => value <= self.definition.max
13
+ ? value
14
+ : addIssue(error, `number <= ${self.definition.max}`, value, self.definition.errorMessage));
13
15
  }
14
16
 
15
17
  export { checkerNumberMax, checkerNumberMaxKind };
@@ -11,7 +11,9 @@ function checkerNumberMin(min, definition = {}) {
11
11
  ...definition,
12
12
  min,
13
13
  },
14
- }, (value, self) => value >= self.definition.min ? value : error.SymbolDataParserErrorIssue);
14
+ }, (value, error$1, self) => value >= self.definition.min
15
+ ? value
16
+ : error.addIssue(error$1, `number >= ${self.definition.min}`, value, self.definition.errorMessage));
15
17
  }
16
18
 
17
19
  exports.checkerNumberMin = checkerNumberMin;
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../../error.mjs';
2
+ import { addIssue } from '../../../error.mjs';
3
3
  import { createDataParserKind } from '../../../kind.mjs';
4
4
 
5
5
  const checkerNumberMinKind = createDataParserKind("checker-number-min");
@@ -9,7 +9,9 @@ function checkerNumberMin(min, definition = {}) {
9
9
  ...definition,
10
10
  min,
11
11
  },
12
- }, (value, self) => value >= self.definition.min ? value : SymbolDataParserErrorIssue);
12
+ }, (value, error, self) => value >= self.definition.min
13
+ ? value
14
+ : addIssue(error, `number >= ${self.definition.min}`, value, self.definition.errorMessage));
13
15
  }
14
16
 
15
17
  export { checkerNumberMin, checkerNumberMinKind };
@@ -14,7 +14,7 @@ function number(definition) {
14
14
  errorMessage: definition?.errorMessage,
15
15
  checkers: definition?.checkers ?? [],
16
16
  coerce: definition?.coerce ?? false,
17
- }, (data, _error, self) => {
17
+ }, (data, error$1, self) => {
18
18
  if (self.definition.coerce) {
19
19
  try {
20
20
  // eslint-disable-next-line no-param-reassign
@@ -25,7 +25,7 @@ function number(definition) {
25
25
  if (typeof data === "number" && !Number.isNaN(data)) {
26
26
  return data;
27
27
  }
28
- return error.SymbolDataParserErrorIssue;
28
+ return error.addIssue(error$1, "number", data, self.definition.errorMessage);
29
29
  }, number.overrideHandler);
30
30
  return self;
31
31
  }
@@ -1,5 +1,5 @@
1
1
  import { dataParserInit } from '../../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../../error.mjs';
2
+ import { addIssue } from '../../error.mjs';
3
3
  import { createDataParserKind } from '../../kind.mjs';
4
4
  import { createOverride } from '../../../common/override.mjs';
5
5
 
@@ -12,7 +12,7 @@ function number(definition) {
12
12
  errorMessage: definition?.errorMessage,
13
13
  checkers: definition?.checkers ?? [],
14
14
  coerce: definition?.coerce ?? false,
15
- }, (data, _error, self) => {
15
+ }, (data, error, self) => {
16
16
  if (self.definition.coerce) {
17
17
  try {
18
18
  // eslint-disable-next-line no-param-reassign
@@ -23,7 +23,7 @@ function number(definition) {
23
23
  if (typeof data === "number" && !Number.isNaN(data)) {
24
24
  return data;
25
25
  }
26
- return SymbolDataParserErrorIssue;
26
+ return addIssue(error, "number", data, self.definition.errorMessage);
27
27
  }, number.overrideHandler);
28
28
  return self;
29
29
  }
@@ -30,17 +30,17 @@ function object(shape, definition) {
30
30
  if (!data
31
31
  || typeof data !== "object"
32
32
  || data instanceof Array) {
33
- return error.SymbolDataParserErrorIssue;
33
+ return error.addIssue(error$1, "object", data, self.definition.errorMessage);
34
34
  }
35
35
  let output = {};
36
36
  const currentIndexPath = error$1.currentPath.length;
37
37
  for (const entry of self.definition.optimizedShape.value) {
38
38
  error.setErrorPath(error$1, entry.key, currentIndexPath);
39
39
  const result = entry.value.exec(data[entry.key], error$1);
40
- if (result === base.SymbolDataParserError) {
41
- output = base.SymbolDataParserError;
40
+ if (result === error.SymbolDataParserError) {
41
+ output = error.SymbolDataParserError;
42
42
  }
43
- else if (output !== base.SymbolDataParserError
43
+ else if (output !== error.SymbolDataParserError
44
44
  && result !== undefined) {
45
45
  output[entry.key] = result;
46
46
  }
@@ -52,17 +52,17 @@ function object(shape, definition) {
52
52
  if (!data
53
53
  || typeof data !== "object"
54
54
  || data instanceof Array) {
55
- return error.SymbolDataParserErrorIssue;
55
+ return error.addIssue(error$1, "object", data, self.definition.errorMessage);
56
56
  }
57
57
  let output = {};
58
58
  const currentIndexPath = error$1.currentPath.length;
59
59
  for (const entry of self.definition.optimizedShape.value) {
60
60
  error.setErrorPath(error$1, entry.key, currentIndexPath);
61
61
  const result = await entry.value.asyncExec(data[entry.key], error$1);
62
- if (result === base.SymbolDataParserError) {
63
- output = base.SymbolDataParserError;
62
+ if (result === error.SymbolDataParserError) {
63
+ output = error.SymbolDataParserError;
64
64
  }
65
- else if (output !== base.SymbolDataParserError
65
+ else if (output !== error.SymbolDataParserError
66
66
  && result !== undefined) {
67
67
  output[entry.key] = result;
68
68
  }
@@ -1,5 +1,5 @@
1
- import { dataParserInit, SymbolDataParserError, dataParserKind } from '../../base.mjs';
2
- import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../../error.mjs';
1
+ import { dataParserInit, dataParserKind } from '../../base.mjs';
2
+ import { addIssue, setErrorPath, SymbolDataParserError, popErrorPath } from '../../error.mjs';
3
3
  import { createDataParserKind } from '../../kind.mjs';
4
4
  import { memo } from '../../../common/memo.mjs';
5
5
  import { some } from '../../../array/some.mjs';
@@ -28,7 +28,7 @@ function object(shape, definition) {
28
28
  if (!data
29
29
  || typeof data !== "object"
30
30
  || data instanceof Array) {
31
- return SymbolDataParserErrorIssue;
31
+ return addIssue(error, "object", data, self.definition.errorMessage);
32
32
  }
33
33
  let output = {};
34
34
  const currentIndexPath = error.currentPath.length;
@@ -50,7 +50,7 @@ function object(shape, definition) {
50
50
  if (!data
51
51
  || typeof data !== "object"
52
52
  || data instanceof Array) {
53
- return SymbolDataParserErrorIssue;
53
+ return addIssue(error, "object", data, self.definition.errorMessage);
54
54
  }
55
55
  let output = {};
56
56
  const currentIndexPath = error.currentPath.length;
@@ -2,6 +2,7 @@
2
2
 
3
3
  var base = require('../base.cjs');
4
4
  var kind = require('../kind.cjs');
5
+ var error = require('../error.cjs');
5
6
  var override = require('../../common/override.cjs');
6
7
 
7
8
  const pipeKind = kind.createDataParserKind("pipe");
@@ -15,19 +16,33 @@ function pipe(input, output, definition) {
15
16
  input,
16
17
  output,
17
18
  }, {
18
- sync: (data, error, self) => {
19
- const result = self.definition.input.exec(data, error);
20
- if (result === base.SymbolDataParserError) {
21
- return base.SymbolDataParserError;
19
+ sync: (data, error$1, self) => {
20
+ const currentIndexPath = error$1.currentPath.length;
21
+ error.setErrorPath(error$1, "(pipeIn)", currentIndexPath);
22
+ const resultIn = self.definition.input.exec(data, error$1);
23
+ if (resultIn === error.SymbolDataParserError) {
24
+ error.popErrorPath(error$1);
25
+ return error.SymbolDataParserError;
22
26
  }
23
- return self.definition.output.exec(result, error);
27
+ error.setErrorPath(error$1, "(pipeOut)", currentIndexPath);
28
+ const resultOut = self.definition.output.exec(resultIn, error$1);
29
+ error.popErrorPath(error$1);
30
+ return resultOut;
24
31
  },
25
- async: async (data, error, self) => {
26
- const result = await self.definition.input.asyncExec(data, error);
27
- if (result === base.SymbolDataParserError) {
28
- return base.SymbolDataParserError;
32
+ async: async (data, error$1, self) => {
33
+ const currentIndexPath = error$1.currentPath.length;
34
+ error.setErrorPath(error$1, "(pipeIn)", currentIndexPath);
35
+ const resultIn = await self.definition.input.asyncExec(data, error$1);
36
+ if (resultIn === error.SymbolDataParserError) {
37
+ error.popErrorPath(error$1);
38
+ return error.SymbolDataParserError;
29
39
  }
30
- return self.definition.output.asyncExec(result, error);
40
+ error.setErrorPath(error$1, "(pipeOut)", currentIndexPath);
41
+ return self.definition.output.asyncExec(resultIn, error$1)
42
+ .then((resultOut) => {
43
+ error.popErrorPath(error$1);
44
+ return resultOut;
45
+ });
31
46
  },
32
47
  isAsynchronous: (self) => self.definition.input.isAsynchronous() || self.definition.output.isAsynchronous(),
33
48
  }, pipe.overrideHandler);
@@ -1,5 +1,6 @@
1
- import { dataParserInit, SymbolDataParserError } from '../base.mjs';
1
+ import { dataParserInit } from '../base.mjs';
2
2
  import { createDataParserKind } from '../kind.mjs';
3
+ import { setErrorPath, SymbolDataParserError, popErrorPath } from '../error.mjs';
3
4
  import { createOverride } from '../../common/override.mjs';
4
5
 
5
6
  const pipeKind = createDataParserKind("pipe");
@@ -14,18 +15,32 @@ function pipe(input, output, definition) {
14
15
  output,
15
16
  }, {
16
17
  sync: (data, error, self) => {
17
- const result = self.definition.input.exec(data, error);
18
- if (result === SymbolDataParserError) {
18
+ const currentIndexPath = error.currentPath.length;
19
+ setErrorPath(error, "(pipeIn)", currentIndexPath);
20
+ const resultIn = self.definition.input.exec(data, error);
21
+ if (resultIn === SymbolDataParserError) {
22
+ popErrorPath(error);
19
23
  return SymbolDataParserError;
20
24
  }
21
- return self.definition.output.exec(result, error);
25
+ setErrorPath(error, "(pipeOut)", currentIndexPath);
26
+ const resultOut = self.definition.output.exec(resultIn, error);
27
+ popErrorPath(error);
28
+ return resultOut;
22
29
  },
23
30
  async: async (data, error, self) => {
24
- const result = await self.definition.input.asyncExec(data, error);
25
- if (result === SymbolDataParserError) {
31
+ const currentIndexPath = error.currentPath.length;
32
+ setErrorPath(error, "(pipeIn)", currentIndexPath);
33
+ const resultIn = await self.definition.input.asyncExec(data, error);
34
+ if (resultIn === SymbolDataParserError) {
35
+ popErrorPath(error);
26
36
  return SymbolDataParserError;
27
37
  }
28
- return self.definition.output.asyncExec(result, error);
38
+ setErrorPath(error, "(pipeOut)", currentIndexPath);
39
+ return self.definition.output.asyncExec(resultIn, error)
40
+ .then((resultOut) => {
41
+ popErrorPath(error);
42
+ return resultOut;
43
+ });
29
44
  },
30
45
  isAsynchronous: (self) => self.definition.input.isAsynchronous() || self.definition.output.isAsynchronous(),
31
46
  }, pipe.overrideHandler);
@@ -28,7 +28,7 @@ function record(key, value, definition) {
28
28
  if (!data
29
29
  || typeof data !== "object"
30
30
  || data instanceof Array) {
31
- return error.SymbolDataParserErrorIssue;
31
+ return error.addIssue(error$1, "record object", data, self.definition.errorMessage);
32
32
  }
33
33
  let output = {};
34
34
  const fromData = {
@@ -37,27 +37,28 @@ function record(key, value, definition) {
37
37
  };
38
38
  const currentIndexPath = error$1.currentPath.length;
39
39
  for (const key in fromData) {
40
- error.setErrorPath(error$1, key, currentIndexPath);
40
+ error.setErrorPath(error$1, `(recordKey: ${key})`, currentIndexPath);
41
41
  const resultKey = self
42
42
  .definition
43
43
  .key
44
44
  .exec(key, error$1);
45
- if (resultKey === base.SymbolDataParserError) {
46
- output = base.SymbolDataParserError;
45
+ if (resultKey === error.SymbolDataParserError) {
46
+ output = error.SymbolDataParserError;
47
47
  }
48
+ error.setErrorPath(error$1, key, currentIndexPath);
48
49
  const resultValue = self
49
50
  .definition
50
51
  .value
51
52
  .exec(fromData[key], error$1);
52
- if (resultValue === base.SymbolDataParserError) {
53
- output = base.SymbolDataParserError;
53
+ if (resultValue === error.SymbolDataParserError) {
54
+ output = error.SymbolDataParserError;
54
55
  }
55
- if (output !== base.SymbolDataParserError) {
56
+ if (output !== error.SymbolDataParserError) {
56
57
  output[resultKey] = resultValue;
57
58
  }
58
59
  }
59
60
  void (currentIndexPath !== error$1.currentPath.length && error.popErrorPath(error$1));
60
- if (output === base.SymbolDataParserError) {
61
+ if (output === error.SymbolDataParserError) {
61
62
  return output;
62
63
  }
63
64
  return output;
@@ -66,7 +67,7 @@ function record(key, value, definition) {
66
67
  if (!data
67
68
  || typeof data !== "object"
68
69
  || data instanceof Array) {
69
- return error.SymbolDataParserErrorIssue;
70
+ return error.addIssue(error$1, "record object", data, self.definition.errorMessage);
70
71
  }
71
72
  let output = {};
72
73
  const fromData = {
@@ -75,27 +76,28 @@ function record(key, value, definition) {
75
76
  };
76
77
  const currentIndexPath = error$1.currentPath.length;
77
78
  for (const key in fromData) {
78
- error.setErrorPath(error$1, key, currentIndexPath);
79
+ error.setErrorPath(error$1, `(recordKey: ${key})`, currentIndexPath);
79
80
  const resultKey = await self
80
81
  .definition
81
82
  .key
82
83
  .asyncExec(key, error$1);
83
- if (resultKey === base.SymbolDataParserError) {
84
- output = base.SymbolDataParserError;
84
+ if (resultKey === error.SymbolDataParserError) {
85
+ output = error.SymbolDataParserError;
85
86
  }
87
+ error.setErrorPath(error$1, key, currentIndexPath);
86
88
  const resultValue = await self
87
89
  .definition
88
90
  .value
89
91
  .asyncExec(fromData[key], error$1);
90
- if (resultValue === base.SymbolDataParserError) {
91
- output = base.SymbolDataParserError;
92
+ if (resultValue === error.SymbolDataParserError) {
93
+ output = error.SymbolDataParserError;
92
94
  }
93
- if (output !== base.SymbolDataParserError) {
95
+ if (output !== error.SymbolDataParserError) {
94
96
  output[resultKey] = resultValue;
95
97
  }
96
98
  }
97
99
  void (currentIndexPath !== error$1.currentPath.length && error.popErrorPath(error$1));
98
- if (output === base.SymbolDataParserError) {
100
+ if (output === error.SymbolDataParserError) {
99
101
  return output;
100
102
  }
101
103
  return output;
@@ -1,5 +1,5 @@
1
- import { dataParserInit, SymbolDataParserError } from '../../base.mjs';
2
- import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../../error.mjs';
1
+ import { dataParserInit } from '../../base.mjs';
2
+ import { addIssue, setErrorPath, SymbolDataParserError, popErrorPath } from '../../error.mjs';
3
3
  import { createDataParserKind } from '../../kind.mjs';
4
4
  import { findRecordRequiredKey } from './findRecordRequiredKey.mjs';
5
5
  export { findRecordRequiredKeyOnTemplateLiteralPart } from './findRecordRequiredKey.mjs';
@@ -27,7 +27,7 @@ function record(key, value, definition) {
27
27
  if (!data
28
28
  || typeof data !== "object"
29
29
  || data instanceof Array) {
30
- return SymbolDataParserErrorIssue;
30
+ return addIssue(error, "record object", data, self.definition.errorMessage);
31
31
  }
32
32
  let output = {};
33
33
  const fromData = {
@@ -36,7 +36,7 @@ function record(key, value, definition) {
36
36
  };
37
37
  const currentIndexPath = error.currentPath.length;
38
38
  for (const key in fromData) {
39
- setErrorPath(error, key, currentIndexPath);
39
+ setErrorPath(error, `(recordKey: ${key})`, currentIndexPath);
40
40
  const resultKey = self
41
41
  .definition
42
42
  .key
@@ -44,6 +44,7 @@ function record(key, value, definition) {
44
44
  if (resultKey === SymbolDataParserError) {
45
45
  output = SymbolDataParserError;
46
46
  }
47
+ setErrorPath(error, key, currentIndexPath);
47
48
  const resultValue = self
48
49
  .definition
49
50
  .value
@@ -65,7 +66,7 @@ function record(key, value, definition) {
65
66
  if (!data
66
67
  || typeof data !== "object"
67
68
  || data instanceof Array) {
68
- return SymbolDataParserErrorIssue;
69
+ return addIssue(error, "record object", data, self.definition.errorMessage);
69
70
  }
70
71
  let output = {};
71
72
  const fromData = {
@@ -74,7 +75,7 @@ function record(key, value, definition) {
74
75
  };
75
76
  const currentIndexPath = error.currentPath.length;
76
77
  for (const key in fromData) {
77
- setErrorPath(error, key, currentIndexPath);
78
+ setErrorPath(error, `(recordKey: ${key})`, currentIndexPath);
78
79
  const resultKey = await self
79
80
  .definition
80
81
  .key
@@ -82,6 +83,7 @@ function record(key, value, definition) {
82
83
  if (resultKey === SymbolDataParserError) {
83
84
  output = SymbolDataParserError;
84
85
  }
86
+ setErrorPath(error, key, currentIndexPath);
85
87
  const resultValue = await self
86
88
  .definition
87
89
  .value
@@ -2,6 +2,7 @@
2
2
 
3
3
  var base = require('../base.cjs');
4
4
  var kind = require('../kind.cjs');
5
+ var error = require('../error.cjs');
5
6
  var override = require('../../common/override.cjs');
6
7
 
7
8
  const recoverKind = kind.createDataParserKind("recover");
@@ -15,15 +16,15 @@ function recover(inner, recoveredValue, definition) {
15
16
  inner,
16
17
  recoveredValue,
17
18
  }, {
18
- sync: (data, error, self) => {
19
- const result = self.definition.inner.exec(data, error);
20
- return result === base.SymbolDataParserError
19
+ sync: (data, error$1, self) => {
20
+ const result = self.definition.inner.exec(data, error$1);
21
+ return result === error.SymbolDataParserError
21
22
  ? self.definition.recoveredValue
22
23
  : result;
23
24
  },
24
- async: async (data, error, self) => {
25
- const result = await self.definition.inner.asyncExec(data, error);
26
- return result === base.SymbolDataParserError
25
+ async: async (data, error$1, self) => {
26
+ const result = await self.definition.inner.asyncExec(data, error$1);
27
+ return result === error.SymbolDataParserError
27
28
  ? self.definition.recoveredValue
28
29
  : result;
29
30
  },
@@ -1,5 +1,6 @@
1
- import { dataParserInit, SymbolDataParserError } from '../base.mjs';
1
+ import { dataParserInit } from '../base.mjs';
2
2
  import { createDataParserKind } from '../kind.mjs';
3
+ import { SymbolDataParserError } from '../error.mjs';
3
4
  import { createOverride } from '../../common/override.mjs';
4
5
 
5
6
  const recoverKind = createDataParserKind("recover");
@@ -11,7 +11,9 @@ function checkerRefine(theFunction, definition) {
11
11
  ...definition,
12
12
  theFunction,
13
13
  },
14
- }, (value, self) => self.definition.theFunction(value) ? value : error.SymbolDataParserErrorIssue);
14
+ }, (value, error$1, self) => self.definition.theFunction(value)
15
+ ? value
16
+ : error.addIssue(error$1, "value matching refine predicate", value, self.definition.errorMessage));
15
17
  }
16
18
 
17
19
  exports.checkerRefine = checkerRefine;
@@ -1,5 +1,5 @@
1
1
  import { dataParserCheckerInit } from '../base.mjs';
2
- import { SymbolDataParserErrorIssue } from '../error.mjs';
2
+ import { addIssue } from '../error.mjs';
3
3
  import { createDataParserKind } from '../kind.mjs';
4
4
 
5
5
  const dataParserCheckerRefineKind = createDataParserKind("refine");
@@ -9,7 +9,9 @@ function checkerRefine(theFunction, definition) {
9
9
  ...definition,
10
10
  theFunction,
11
11
  },
12
- }, (value, self) => self.definition.theFunction(value) ? value : SymbolDataParserErrorIssue);
12
+ }, (value, error, self) => self.definition.theFunction(value)
13
+ ? value
14
+ : addIssue(error, "value matching refine predicate", value, self.definition.errorMessage));
13
15
  }
14
16
 
15
17
  export { checkerRefine, dataParserCheckerRefineKind };
@@ -13,9 +13,9 @@ function checkerEmail(definition = {}) {
13
13
  ...definition,
14
14
  pattern: emailPattern,
15
15
  },
16
- }, (input, self) => {
16
+ }, (input, error$1, self) => {
17
17
  if (!self.definition.pattern.test(input)) {
18
- return error.SymbolDataParserErrorIssue;
18
+ return error.addIssue(error$1, "email", input, self.definition.errorMessage);
19
19
  }
20
20
  return self.definition.normalize ? input.toLowerCase() : input;
21
21
  });