inferred-types 0.37.0 → 0.37.2

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 (280) hide show
  1. package/dist/index.d.ts +2745 -0
  2. package/dist/index.js +854 -0
  3. package/package.json +8 -13
  4. package/.eslintrc +0 -77
  5. package/.github/workflows/main.yml +0 -34
  6. package/.github/workflows/other.yml +0 -15
  7. package/.nvmrc +0 -1
  8. package/.prettierrc.js +0 -3
  9. package/.vscode/launch.json +0 -27
  10. package/.vscode/settings.json +0 -19
  11. package/devops/build.js +0 -243
  12. package/docs/builder-overview.md +0 -45
  13. package/docs/builder.md +0 -94
  14. package/src/errors/ReadOnlyViolation.ts +0 -3
  15. package/src/errors/index.ts +0 -12
  16. package/src/index.ts +0 -14
  17. package/src/runtime/README.md +0 -3
  18. package/src/runtime/api/api.ts +0 -10
  19. package/src/runtime/api/index.ts +0 -12
  20. package/src/runtime/builders/Model.ts +0 -25
  21. package/src/runtime/builders/url.ts +0 -15
  22. package/src/runtime/combinators/and.ts +0 -15
  23. package/src/runtime/combinators/filter.ts +0 -267
  24. package/src/runtime/combinators/index.ts +0 -4
  25. package/src/runtime/combinators/not.ts +0 -15
  26. package/src/runtime/combinators/or.ts +0 -5
  27. package/src/runtime/createFnWithProps.ts +0 -37
  28. package/src/runtime/dictionary/arrayToKeyLookup.ts +0 -19
  29. package/src/runtime/dictionary/defineProperties.ts +0 -35
  30. package/src/runtime/dictionary/dictArr.ts +0 -69
  31. package/src/runtime/dictionary/dictionaryTransform.ts +0 -22
  32. package/src/runtime/dictionary/entries.ts +0 -33
  33. package/src/runtime/dictionary/index.ts +0 -21
  34. package/src/runtime/dictionary/kv/dictToKv.ts +0 -21
  35. package/src/runtime/dictionary/kv/filterDictArray.ts +0 -31
  36. package/src/runtime/dictionary/kv/index.ts +0 -15
  37. package/src/runtime/dictionary/kv/kv.ts +0 -18
  38. package/src/runtime/dictionary/kv/kvToDict.ts +0 -24
  39. package/src/runtime/dictionary/mapTo.ts +0 -206
  40. package/src/runtime/dictionary/mapValues.ts +0 -23
  41. package/src/runtime/dictionary/merge.ts +0 -36
  42. package/src/runtime/dictionary/strArrayToDict.ts +0 -12
  43. package/src/runtime/index.ts +0 -23
  44. package/src/runtime/keys.ts +0 -16
  45. package/src/runtime/lists/asArray.ts +0 -38
  46. package/src/runtime/lists/createConverter.ts +0 -62
  47. package/src/runtime/lists/groupBy.ts +0 -15
  48. package/src/runtime/lists/index.ts +0 -15
  49. package/src/runtime/literals/ExplicitFunction.ts +0 -10
  50. package/src/runtime/literals/Suggest.ts +0 -19
  51. package/src/runtime/literals/arrayToObject.ts +0 -78
  52. package/src/runtime/literals/box.ts +0 -98
  53. package/src/runtime/literals/defineType.ts +0 -20
  54. package/src/runtime/literals/ensureLeading.ts +0 -17
  55. package/src/runtime/literals/ensureTrailing.ts +0 -17
  56. package/src/runtime/literals/identity.ts +0 -12
  57. package/src/runtime/literals/index.ts +0 -23
  58. package/src/runtime/literals/literal.ts +0 -48
  59. package/src/runtime/literals/pathJoin.ts +0 -33
  60. package/src/runtime/literals/stripLeading.ts +0 -15
  61. package/src/runtime/literals/stripTrailing.ts +0 -15
  62. package/src/runtime/literals/wide.ts +0 -13
  63. package/src/runtime/ruleset.ts +0 -42
  64. package/src/runtime/runtime/README.md +0 -3
  65. package/src/runtime/runtime/condition.ts +0 -13
  66. package/src/runtime/runtime/index.ts +0 -16
  67. package/src/runtime/runtime/type.ts +0 -127
  68. package/src/runtime/runtime/withValue.ts +0 -39
  69. package/src/runtime/state/Configurator.ts +0 -76
  70. package/src/runtime/state/FluentConfigurator.ts +0 -49
  71. package/src/runtime/state/index.ts +0 -13
  72. package/src/runtime/type-checks/ifSameType.ts +0 -20
  73. package/src/runtime/type-checks/ifTypeOf.ts +0 -124
  74. package/src/runtime/type-checks/index.ts +0 -24
  75. package/src/runtime/type-checks/isArray.ts +0 -34
  76. package/src/runtime/type-checks/isBoolean.ts +0 -24
  77. package/src/runtime/type-checks/isFalse.ts +0 -29
  78. package/src/runtime/type-checks/isFunction.ts +0 -26
  79. package/src/runtime/type-checks/isNull.ts +0 -26
  80. package/src/runtime/type-checks/isNumber.ts +0 -20
  81. package/src/runtime/type-checks/isObject.ts +0 -22
  82. package/src/runtime/type-checks/isString.ts +0 -34
  83. package/src/runtime/type-checks/isSymbol.ts +0 -3
  84. package/src/runtime/type-checks/isTrue.ts +0 -31
  85. package/src/runtime/type-checks/isUndefined.ts +0 -33
  86. package/src/runtime/type-checks/startsWith.ts +0 -107
  87. package/src/runtime/valueTypes.ts +0 -48
  88. package/src/types/Api.ts +0 -16
  89. package/src/types/Constructor.ts +0 -5
  90. package/src/types/EnumValues.ts +0 -14
  91. package/src/types/ExpandRecursively.ts +0 -12
  92. package/src/types/FunctionType.ts +0 -19
  93. package/src/types/If.ts +0 -10
  94. package/src/types/Include.ts +0 -18
  95. package/src/types/KeyedRecord.ts +0 -21
  96. package/src/types/Keys.ts +0 -26
  97. package/src/types/Length.ts +0 -8
  98. package/src/types/Mutable.ts +0 -8
  99. package/src/types/Narrowable.ts +0 -5
  100. package/src/types/Not.ts +0 -13
  101. package/src/types/Numeric.ts +0 -20
  102. package/src/types/Opaque.ts +0 -11
  103. package/src/types/README.md +0 -3
  104. package/src/types/Retain.ts +0 -16
  105. package/src/types/SimplifyObject.ts +0 -12
  106. package/src/types/Transformer.ts +0 -15
  107. package/src/types/TypeGuard.ts +0 -7
  108. package/src/types/Where.ts +0 -40
  109. package/src/types/alphabetic/AllCaps.ts +0 -15
  110. package/src/types/alphabetic/CamelCase.ts +0 -3
  111. package/src/types/alphabetic/CapFirstAlpha.ts +0 -23
  112. package/src/types/alphabetic/CapitalizeWords.ts +0 -9
  113. package/src/types/alphabetic/Cardinality.ts +0 -80
  114. package/src/types/alphabetic/DashToSnake.ts +0 -3
  115. package/src/types/alphabetic/DashUppercase.ts +0 -19
  116. package/src/types/alphabetic/Dasherize.ts +0 -23
  117. package/src/types/alphabetic/EnsureLeading.ts +0 -24
  118. package/src/types/alphabetic/EnsureTrailing.ts +0 -24
  119. package/src/types/alphabetic/HasUppercase.ts +0 -16
  120. package/src/types/alphabetic/IsCapitalized.ts +0 -18
  121. package/src/types/alphabetic/KebabCase.ts +0 -13
  122. package/src/types/alphabetic/LowerAllCaps.ts +0 -5
  123. package/src/types/alphabetic/PascalCase.ts +0 -29
  124. package/src/types/alphabetic/PathJoin.ts +0 -54
  125. package/src/types/alphabetic/Pluralize.ts +0 -112
  126. package/src/types/alphabetic/SnakeCase.ts +0 -27
  127. package/src/types/alphabetic/StripLeading.ts +0 -23
  128. package/src/types/alphabetic/StripTrailing.ts +0 -23
  129. package/src/types/alphabetic/Url.ts +0 -29
  130. package/src/types/alphabetic/alpha-characters.ts +0 -81
  131. package/src/types/alphabetic/index.ts +0 -32
  132. package/src/types/append-types.ts +0 -10
  133. package/src/types/boolean-logic/EndsWith.ts +0 -40
  134. package/src/types/boolean-logic/Extends.ts +0 -22
  135. package/src/types/boolean-logic/HasParameters.ts +0 -21
  136. package/src/types/boolean-logic/Includes.ts +0 -33
  137. package/src/types/boolean-logic/IsLiteral.ts +0 -101
  138. package/src/types/boolean-logic/IsScalar.ts +0 -20
  139. package/src/types/boolean-logic/IsUndefined.ts +0 -20
  140. package/src/types/boolean-logic/Or.ts +0 -12
  141. package/src/types/boolean-logic/StartsWith.ts +0 -42
  142. package/src/types/boolean-logic/TypeDefault.ts +0 -58
  143. package/src/types/boolean-logic/array.ts +0 -57
  144. package/src/types/boolean-logic/boolean.ts +0 -84
  145. package/src/types/boolean-logic/equivalency.ts +0 -15
  146. package/src/types/boolean-logic/index.ts +0 -14
  147. package/src/types/boolean-logic/object.ts +0 -30
  148. package/src/types/boolean-logic/string.ts +0 -21
  149. package/src/types/dictionary/DictChangeValue.ts +0 -34
  150. package/src/types/dictionary/DictPartialApplication.ts +0 -30
  151. package/src/types/dictionary/DictPrependWithFn.ts +0 -23
  152. package/src/types/dictionary/DictReturnValues.ts +0 -27
  153. package/src/types/dictionary/Get.ts +0 -14
  154. package/src/types/dictionary/MapTo.ts +0 -428
  155. package/src/types/dictionary/MutableProps.ts +0 -19
  156. package/src/types/dictionary/RequireProps.ts +0 -15
  157. package/src/types/dictionary/SameKeys.ts +0 -11
  158. package/src/types/dictionary/index.ts +0 -21
  159. package/src/types/dictionary/props.ts +0 -145
  160. package/src/types/fluent/fluent.ts +0 -61
  161. package/src/types/fluent/index.ts +0 -12
  162. package/src/types/functions/FinalReturn.ts +0 -12
  163. package/src/types/functions/LogicFunction.ts +0 -4
  164. package/src/types/functions/index.ts +0 -13
  165. package/src/types/index.ts +0 -49
  166. package/src/types/kv/DictFromKv.ts +0 -3
  167. package/src/types/kv/KeyValue.ts +0 -12
  168. package/src/types/kv/KvFrom.ts +0 -8
  169. package/src/types/kv/KvTuple.ts +0 -14
  170. package/src/types/kv/index.ts +0 -15
  171. package/src/types/lists/AfterFirst.ts +0 -10
  172. package/src/types/lists/ConvertAndMap.ts +0 -152
  173. package/src/types/lists/FilterTuple.ts +0 -20
  174. package/src/types/lists/First.ts +0 -8
  175. package/src/types/lists/FirstString.ts +0 -4
  176. package/src/types/lists/Split.ts +0 -21
  177. package/src/types/lists/UniqueForProp.ts +0 -18
  178. package/src/types/lists/index.ts +0 -18
  179. package/src/types/literal-unions/OptRequired.ts +0 -4
  180. package/src/types/literal-unions/index.ts +0 -1
  181. package/src/types/maybe.ts +0 -9
  182. package/src/types/ruleset-types.ts +0 -76
  183. package/src/types/runtime.ts +0 -39
  184. package/src/types/string-literals/Break.ts +0 -22
  185. package/src/types/string-literals/Concat.ts +0 -9
  186. package/src/types/string-literals/LeftWhitespace.ts +0 -13
  187. package/src/types/string-literals/Replace.ts +0 -17
  188. package/src/types/string-literals/RightWhitespace.ts +0 -13
  189. package/src/types/string-literals/StringLength.ts +0 -34
  190. package/src/types/string-literals/Trim.ts +0 -15
  191. package/src/types/string-literals/TrimLeft.ts +0 -14
  192. package/src/types/string-literals/TrimRight.ts +0 -14
  193. package/src/types/string-literals/form-fields.ts +0 -15
  194. package/src/types/string-literals/index.ts +0 -21
  195. package/src/types/tuples/DictArray.ts +0 -21
  196. package/src/types/tuples/FirstKey.ts +0 -10
  197. package/src/types/tuples/FirstKeyValue.ts +0 -9
  198. package/src/types/tuples/FirstOfEach.ts +0 -13
  199. package/src/types/tuples/FromDictArray.ts +0 -14
  200. package/src/types/tuples/SecondOfEach.ts +0 -13
  201. package/src/types/tuples/index.ts +0 -17
  202. package/src/types/type-conversion/TupleToUnion.ts +0 -9
  203. package/src/types/type-conversion/UnionToIntersection.ts +0 -9
  204. package/src/types/type-conversion/UnionToTuple.ts +0 -20
  205. package/src/types/type-conversion/Widen.ts +0 -22
  206. package/src/types/type-conversion/index.ts +0 -16
  207. package/src/types/type-testing.ts +0 -14
  208. package/tests/CamelCase-spec.ts +0 -20
  209. package/tests/Configurator-spec.hold +0 -106
  210. package/tests/ExplicitFunction-spec.ts +0 -50
  211. package/tests/IncludeAndRetain-spec.ts +0 -67
  212. package/tests/Includes-spec.ts +0 -36
  213. package/tests/KebabCase-spec.ts +0 -21
  214. package/tests/PascalCase-spec.ts +0 -22
  215. package/tests/Pluralize-spec.ts +0 -23
  216. package/tests/SnakeCase-spec.ts +0 -21
  217. package/tests/Where.spec.ts +0 -38
  218. package/tests/arrayToKeyLookup-spec.ts +0 -17
  219. package/tests/arrayToObject-spec.ts +0 -115
  220. package/tests/boolean-logic/Contains.test.ts +0 -55
  221. package/tests/boolean-logic/HasParameters.ts +0 -29
  222. package/tests/boolean-logic/IsLiteral.spec.ts +0 -65
  223. package/tests/boolean-logic/boolean.spec.ts +0 -21
  224. package/tests/boolean-logic/filter.spec.ts +0 -52
  225. package/tests/constructor.spec.ts +0 -42
  226. package/tests/createFnWithProps.spec.ts +0 -14
  227. package/tests/data/SimpleTable.hold +0 -21
  228. package/tests/data/index.ts +0 -12
  229. package/tests/data/playlist.hold +0 -25
  230. package/tests/data/song.hold +0 -23
  231. package/tests/defineType-spec.ts +0 -57
  232. package/tests/dictionary/DictChangeValue.test.ts +0 -30
  233. package/tests/dictionary/DictPartialApplication.test.ts +0 -43
  234. package/tests/dictionary/DictReturnValues.test.ts +0 -36
  235. package/tests/dictionary/Get.spec.ts +0 -28
  236. package/tests/dictionary/IntersectingKeys.test.ts +0 -42
  237. package/tests/dictionary/MutableProps.test.ts +0 -30
  238. package/tests/dictionary/OptionalKeys.test.ts +0 -24
  239. package/tests/dictionary/PrependValuesWithFunction.test.ts +0 -34
  240. package/tests/dictionary/RequireProps.test.ts +0 -21
  241. package/tests/dictionary/RequiredKeys.test.ts +0 -53
  242. package/tests/dictionary/TypeDefault.test.ts +0 -76
  243. package/tests/dictionary/mapTo.test.ts +0 -388
  244. package/tests/dictionary/merge.test.ts +0 -41
  245. package/tests/dictionaryTransform-spec.ts +0 -280
  246. package/tests/ifTypeOf-spec.ts +0 -191
  247. package/tests/kv/KeyValue-spec.ts +0 -22
  248. package/tests/kv/SameKeys-spec.ts +0 -35
  249. package/tests/kv/dict-to-kv-and-back.spec.ts +0 -169
  250. package/tests/kv/entries-spec.ts +0 -65
  251. package/tests/kv/keys.spec.ts +0 -66
  252. package/tests/kv/kv-spec.ts +0 -20
  253. package/tests/lists/First.test.ts +0 -43
  254. package/tests/lists/Length.test.ts +0 -19
  255. package/tests/lists/Split.test.ts +0 -29
  256. package/tests/lists/UniqueForProp.spec.ts +0 -59
  257. package/tests/lists/asArray.test.ts +0 -109
  258. package/tests/lists/dictArr.test.ts +0 -110
  259. package/tests/literal-spec.ts +0 -82
  260. package/tests/literals/AllCaps.spec.ts +0 -33
  261. package/tests/literals/CamelCase.spec.ts +0 -109
  262. package/tests/literals/Dasherize.spec.ts +0 -107
  263. package/tests/literals/EnsureStripLeadingTrailing.test.ts +0 -79
  264. package/tests/literals/HasUppercase.spec.ts +0 -33
  265. package/tests/literals/PascalCase.spec.ts +0 -109
  266. package/tests/literals/PathJoin.test.ts +0 -111
  267. package/tests/literals/SnakeCase.spec.ts +0 -109
  268. package/tests/literals/box.test.ts +0 -85
  269. package/tests/literals/whitespace-capture.spec.ts +0 -60
  270. package/tests/mapValues-spec.ts +0 -50
  271. package/tests/props-spec.ts +0 -234
  272. package/tests/runtime/condition.spec.ts +0 -19
  273. package/tests/runtime/if-is.spec.ts +0 -390
  274. package/tests/runtime/map-and-convert.test.ts +0 -31
  275. package/tests/runtime/type.spec.ts +0 -190
  276. package/tests/strArrayToDict-spec.ts +0 -40
  277. package/tests/tuples/TupleToUnion.spec.ts +0 -20
  278. package/tests/withValue.spec.ts +0 -173
  279. package/tsconfig.json +0 -36
  280. package/vitest.config.ts +0 -17
package/dist/index.js ADDED
@@ -0,0 +1,854 @@
1
+ // src/types/dictionary/MapTo.ts
2
+ var MapCardinality = /* @__PURE__ */ ((MapCardinality2) => {
3
+ MapCardinality2["OneToMany"] = "I -> O[]";
4
+ MapCardinality2["OneToOne"] = "I -> O";
5
+ MapCardinality2["ManyToOne"] = "I[] -> O";
6
+ return MapCardinality2;
7
+ })(MapCardinality || {});
8
+
9
+ // src/runtime/keys.ts
10
+ function keys(obj, ...without) {
11
+ const v = without.length > 0 ? Object.keys(obj).filter((k) => !without.includes(k)) : Object.keys(obj);
12
+ return v;
13
+ }
14
+
15
+ // src/runtime/createFnWithProps.ts
16
+ function createFnWithProps(fn, props) {
17
+ return (() => {
18
+ let combined = fn;
19
+ for (const prop of keys(props)) {
20
+ combined[prop] = props[prop];
21
+ }
22
+ return combined;
23
+ })();
24
+ }
25
+ function fnWithProps(fn, props) {
26
+ let combined = fn;
27
+ for (const prop of keys(props)) {
28
+ combined[prop] = props[prop];
29
+ }
30
+ return combined;
31
+ }
32
+ function readonlyFnWithProps(fn, props) {
33
+ let combined = fn;
34
+ for (const prop of keys(props)) {
35
+ combined[prop] = props[prop];
36
+ }
37
+ return combined;
38
+ }
39
+
40
+ // src/runtime/ruleset.ts
41
+ function ruleSet(defn) {
42
+ return defn;
43
+ }
44
+
45
+ // src/runtime/api/api.ts
46
+ var api = (priv) => (pub) => {
47
+ const surface = () => pub;
48
+ surface.prototype.priv = () => priv;
49
+ return surface;
50
+ };
51
+
52
+ // src/runtime/combinators/and.ts
53
+ var and = (...ops) => {
54
+ const fn = (...args) => {
55
+ return [...ops].every((i) => i(...args));
56
+ };
57
+ return fn;
58
+ };
59
+
60
+ // src/runtime/combinators/or.ts
61
+ function or(...conditions) {
62
+ return conditions.some((v) => v === true) ? true : false;
63
+ }
64
+
65
+ // src/runtime/combinators/not.ts
66
+ var not = (op) => {
67
+ const fn = (...args) => {
68
+ return !op(...args);
69
+ };
70
+ return fn;
71
+ };
72
+
73
+ // src/runtime/runtime/condition.ts
74
+ var condition = (c, input) => {
75
+ return c(input);
76
+ };
77
+
78
+ // src/runtime/type-checks/ifSameType.ts
79
+ function ifSameType(value, comparisonType, ifExtends, doesNotExtend) {
80
+ return typeof value === typeof comparisonType ? ifExtends(value) : doesNotExtend(value);
81
+ }
82
+
83
+ // src/runtime/type-checks/isArray.ts
84
+ function isArray(i) {
85
+ return Array.isArray(i) === true;
86
+ }
87
+ function ifArray(val, isAnArray, isNotAnArray) {
88
+ return isArray(val) ? isAnArray(val) : isNotAnArray(val);
89
+ }
90
+ function ifArrayPartial() {
91
+ return (isAnArray, isNotAnArray) => {
92
+ return (val) => ifArray(val, isAnArray, isNotAnArray);
93
+ };
94
+ }
95
+
96
+ // src/runtime/type-checks/isBoolean.ts
97
+ function isBoolean(i) {
98
+ return typeof i === "boolean";
99
+ }
100
+ function ifBoolean(val, ifVal, elseVal) {
101
+ return isBoolean(val) ? ifVal : elseVal;
102
+ }
103
+
104
+ // src/runtime/type-checks/isFalse.ts
105
+ function isFalse(i) {
106
+ return typeof i === "boolean" && !i;
107
+ }
108
+ function ifFalse(val, ifVal, elseVal) {
109
+ return isFalse(val) ? ifVal : elseVal;
110
+ }
111
+
112
+ // src/runtime/type-checks/isFunction.ts
113
+ function isFunction(input) {
114
+ return typeof input === "function" ? true : false;
115
+ }
116
+
117
+ // src/runtime/type-checks/isNull.ts
118
+ function isNull(i) {
119
+ return i === null;
120
+ }
121
+ function ifNull(val, ifVal, elseVal) {
122
+ return isNull(val) ? ifVal : elseVal;
123
+ }
124
+
125
+ // src/runtime/type-checks/isNumber.ts
126
+ function isNumber(i) {
127
+ return typeof i === "number";
128
+ }
129
+ function ifNumber(val, ifVal, elseVal) {
130
+ return isNumber(val) ? ifVal : elseVal;
131
+ }
132
+
133
+ // src/runtime/type-checks/isObject.ts
134
+ function isObject(i) {
135
+ return typeof i === "object" && i !== null && Array.isArray(i) === false;
136
+ }
137
+ function ifObject(val, ifObj, notObj) {
138
+ return isObject(val) ? ifObj : notObj;
139
+ }
140
+
141
+ // src/runtime/type-checks/isString.ts
142
+ function isString(i) {
143
+ return typeof i === "string";
144
+ }
145
+ function ifString(val, ifVal, elseVal) {
146
+ return isString(val) ? ifVal : elseVal;
147
+ }
148
+
149
+ // src/runtime/type-checks/isSymbol.ts
150
+ function isSymbol(i) {
151
+ return typeof i === "symbol";
152
+ }
153
+
154
+ // src/runtime/type-checks/isTrue.ts
155
+ function isTrue(i) {
156
+ return typeof i === "boolean" && i === true;
157
+ }
158
+ function ifTrue(val, ifVal, elseVal) {
159
+ return isTrue(val) ? ifVal : elseVal;
160
+ }
161
+
162
+ // src/runtime/type-checks/isUndefined.ts
163
+ function isUndefined(i) {
164
+ return typeof i === "undefined";
165
+ }
166
+ function ifUndefined(val, ifVal, elseVal) {
167
+ return isUndefined(val) ? ifVal : elseVal;
168
+ }
169
+ function ifDefined(val, ifVal, elseVal) {
170
+ return isUndefined(val) ? ifVal : elseVal;
171
+ }
172
+
173
+ // src/runtime/runtime/type.ts
174
+ var typeApi = () => ({
175
+ string: {
176
+ name: "string",
177
+ type: "",
178
+ typeGuard: (v) => isString(v),
179
+ is: isString
180
+ },
181
+ boolean: {
182
+ name: "boolean",
183
+ type: true,
184
+ typeGuard: (v) => isBoolean(v),
185
+ is: isBoolean
186
+ },
187
+ number: {
188
+ name: "number",
189
+ type: 1,
190
+ typeGuard: (v) => isNumber(v),
191
+ is: isNumber
192
+ },
193
+ function: {
194
+ name: "function",
195
+ type: Function,
196
+ typeGuard: (v) => isFunction(v),
197
+ is: isFunction
198
+ },
199
+ null: {
200
+ name: "null",
201
+ type: null,
202
+ typeGuard: (v) => isNull(v),
203
+ is: isNull
204
+ },
205
+ symbol: {
206
+ name: "symbol",
207
+ type: Symbol(),
208
+ typeGuard: (v) => isSymbol(v),
209
+ is: isSymbol
210
+ },
211
+ undefined: {
212
+ name: "undefined",
213
+ type: void 0,
214
+ typeGuard: (v) => isUndefined(v),
215
+ is: isUndefined
216
+ },
217
+ true: {
218
+ name: "true",
219
+ type: true,
220
+ typeGuard: (v) => isTrue(v),
221
+ is: isTrue
222
+ },
223
+ false: {
224
+ name: "false",
225
+ type: false,
226
+ typeGuard: (v) => isFalse(v),
227
+ is: isFalse
228
+ },
229
+ object: {
230
+ name: "object",
231
+ type: {},
232
+ typeGuard: (v) => isObject(v),
233
+ is: isObject
234
+ },
235
+ array: {
236
+ name: "array",
237
+ type: {},
238
+ typeGuard: (v) => isArray(v),
239
+ is: isObject
240
+ }
241
+ });
242
+ function isType(t) {
243
+ return typeof t === "object" && ["name", "type", "is"].every((i) => Object.keys(t).includes(i));
244
+ }
245
+ function type(fn) {
246
+ const result = fn(typeApi());
247
+ if (!isType(result)) {
248
+ throw new Error(
249
+ `When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`
250
+ );
251
+ }
252
+ return result;
253
+ }
254
+
255
+ // src/runtime/dictionary/entries.ts
256
+ function entries(obj) {
257
+ const iterable = {
258
+ *[Symbol.iterator]() {
259
+ for (const k of keys(obj)) {
260
+ yield [k, obj[k]];
261
+ }
262
+ }
263
+ };
264
+ return iterable;
265
+ }
266
+
267
+ // src/runtime/runtime/withValue.ts
268
+ function withValue(td) {
269
+ return (obj) => {
270
+ const t = type(td);
271
+ return Object.fromEntries(
272
+ [...entries(obj)].filter(([_key, value]) => {
273
+ return t.typeGuard(value);
274
+ })
275
+ );
276
+ };
277
+ }
278
+
279
+ // src/runtime/lists/asArray.ts
280
+ var asArray = (thing, _widen) => {
281
+ return isArray(thing) ? thing : typeof thing === "undefined" ? [] : [thing];
282
+ };
283
+
284
+ // src/runtime/combinators/filter.ts
285
+ function isNotFilter(f) {
286
+ return typeof f === "object" && "not" in f;
287
+ }
288
+ function isNumericFilter(filter2) {
289
+ return "equals" in filter2 || "notEqual" in filter2 || "greaterThan" in filter2 || "lessThan" in filter2 ? true : false;
290
+ }
291
+ var numericOps = (config, boolLogic) => {
292
+ const equals = (n) => {
293
+ const f = asArray(n);
294
+ return f.length === 0 ? [] : [(input) => f.some((i) => i === input)];
295
+ };
296
+ const notEqual = (n) => {
297
+ const f = asArray(n);
298
+ return f.length === 0 ? [] : [(input) => f.every((i) => i !== input)];
299
+ };
300
+ const greaterThan = (n) => {
301
+ const val = [(input) => input !== void 0 && input > n];
302
+ return val;
303
+ };
304
+ const lessThan = (n) => {
305
+ const val = [(input) => input !== void 0 && input < n];
306
+ return val;
307
+ };
308
+ const conditions = [
309
+ ..."equals" in config ? equals(config.equals) : [],
310
+ ..."notEqual" in config ? notEqual(config.notEqual) : [],
311
+ ..."greaterThan" in config ? greaterThan(config.greaterThan) : [],
312
+ ..."lessThan" in config ? lessThan(config.lessThan) : []
313
+ ];
314
+ const combined = boolLogic === "AND" ? (input) => conditions.every((c) => c(input)) : (input) => conditions.some((c) => c(input));
315
+ return combined;
316
+ };
317
+ var stringOps = (config, boolLogic) => {
318
+ const startsWith = (n) => {
319
+ const f = asArray(n);
320
+ return f.length === 0 ? [] : [(input) => f.some((i) => input?.startsWith(i))];
321
+ };
322
+ const endsWith = (n) => {
323
+ const f = asArray(n);
324
+ return f.length === 0 ? [] : [(input) => f.some((i) => input?.endsWith(i))];
325
+ };
326
+ const contains = (n) => {
327
+ const f = asArray(n);
328
+ return f.length === 0 ? [] : [(input) => f.some((i) => input?.includes(i))];
329
+ };
330
+ const conditions = [
331
+ ..."startsWith" in config ? startsWith(config.startsWith) : [],
332
+ ..."endsWith" in config ? endsWith(config.endsWith) : [],
333
+ ..."contains" in config ? contains(config.contains) : []
334
+ ];
335
+ const combined = boolLogic === "AND" ? (input) => conditions.every((c) => c(input)) : (input) => conditions.some((c) => c(input));
336
+ return combined;
337
+ };
338
+ var filterFn = (defn, logicCombinator, ifUndefined2 = "no-impact") => {
339
+ const config = isNotFilter(defn) ? defn["not"] : defn;
340
+ const filter2 = (input) => {
341
+ const undefValue = ifUndefined2 === "no-impact" ? logicCombinator === "AND" ? true : false : ifUndefined2;
342
+ let flag;
343
+ if (typeof input === "undefined") {
344
+ flag = undefValue;
345
+ } else if (isNumericFilter(config)) {
346
+ const fn = numericOps(config, logicCombinator);
347
+ flag = isNotFilter(defn) ? !fn(input) : fn(input);
348
+ } else {
349
+ const fn = stringOps(config, logicCombinator);
350
+ flag = isNotFilter(defn) ? !fn(input) : fn(input);
351
+ }
352
+ return flag;
353
+ };
354
+ return filter2;
355
+ };
356
+ var filter = (config, logicCombinator = "AND", ifUndefined2 = "no-impact") => {
357
+ return filterFn(config, logicCombinator, ifUndefined2);
358
+ };
359
+
360
+ // src/runtime/dictionary/arrayToKeyLookup.ts
361
+ function arrayToKeyLookup(...keys2) {
362
+ const obj = {};
363
+ for (const key of keys2) {
364
+ obj[key] = true;
365
+ }
366
+ return obj;
367
+ }
368
+
369
+ // src/runtime/dictionary/defineProperties.ts
370
+ function defineProperties(obj) {
371
+ return {
372
+ ro(prop, errorMsg) {
373
+ Object.defineProperty(obj, prop, {
374
+ writable: false,
375
+ set(v) {
376
+ const message = errorMsg ? errorMsg(prop, v) : `The ${String(
377
+ prop
378
+ )} is readonly but an attempt was made to change it's value to "${JSON.stringify(
379
+ v
380
+ )}"!`;
381
+ throw new Error(message);
382
+ }
383
+ });
384
+ return obj;
385
+ }
386
+ };
387
+ }
388
+
389
+ // src/runtime/dictionary/dictionaryTransform.ts
390
+ function dictionaryTransform(input, transform) {
391
+ return keys(input).reduce((acc, i) => {
392
+ const key = i;
393
+ return { ...acc, [key]: transform(input, key) };
394
+ }, {});
395
+ }
396
+
397
+ // src/runtime/dictionary/dictArr.ts
398
+ var dictArr = (...dicts) => {
399
+ const api2 = {
400
+ length: dicts.length,
401
+ toLookup: (prop) => {
402
+ let dict = {};
403
+ for (const obj of dicts) {
404
+ const key = obj[prop];
405
+ dict = { ...dict, [key]: obj };
406
+ }
407
+ return dict;
408
+ },
409
+ unique: (prop) => {
410
+ const v = /* @__PURE__ */ new Set();
411
+ dicts.forEach((i) => v.add(i[prop]));
412
+ const size = dictArr(...dicts).count(prop);
413
+ const values = Array.from(v);
414
+ const u = {
415
+ isUnique: values.includes(void 0) ? size === v.size - 1 : size === v.size,
416
+ includedUndefined: values.includes(void 0) ? true : false,
417
+ size,
418
+ values
419
+ };
420
+ return u;
421
+ },
422
+ sum: (prop) => {
423
+ return dicts.reduce((acc, obj) => prop in obj ? acc + obj[prop] : acc, 0);
424
+ },
425
+ count: (prop) => {
426
+ return dicts.reduce(
427
+ (acc, obj) => prop in obj && typeof obj[prop] !== "undefined" ? acc + 1 : acc,
428
+ 0
429
+ );
430
+ }
431
+ };
432
+ return api2;
433
+ };
434
+
435
+ // src/runtime/dictionary/mapValues.ts
436
+ function mapValues(obj, valueMapper) {
437
+ return Object.fromEntries(
438
+ [...entries(obj)].map(([k, v]) => [k, valueMapper(v)])
439
+ );
440
+ }
441
+
442
+ // src/runtime/dictionary/mapTo.ts
443
+ var toFinalizedConfig = (config) => {
444
+ return { ...config, finalized: true };
445
+ };
446
+ var DEFAULT_ONE_TO_MANY_MAPPING = toFinalizedConfig({
447
+ input: "req",
448
+ output: "opt",
449
+ cardinality: "I -> O[]"
450
+ });
451
+ var DEFAULT_ONE_TO_ONE_MAPPING = toFinalizedConfig({
452
+ input: "req",
453
+ output: "req",
454
+ cardinality: "I -> O"
455
+ });
456
+ var DEFAULT_MANY_TO_ONE_MAPPING = toFinalizedConfig({
457
+ input: "req",
458
+ output: "req",
459
+ cardinality: "I[] -> O"
460
+ });
461
+ var debugMsg = (config, source, output) => {
462
+ if (config.debug) {
463
+ console.error(
464
+ `MapFn[${typeof config.output === "string" ? `${config.output}, ` : ""}${config.input}, ${config.cardinality}, ${config.output}] received:
465
+
466
+ ${JSON.stringify(source)}
467
+
468
+ And produced: ${JSON.stringify(
469
+ output
470
+ )}
471
+
472
+ `
473
+ );
474
+ }
475
+ };
476
+ var mapper = (config) => (map) => {
477
+ const fn = (source) => {
478
+ const isArray2 = config.cardinality === "I -> O[]" && Array.isArray(source) ? true : config.cardinality === "I[] -> O" && Array.isArray(source) && Array.isArray(source[0]) ? true : false;
479
+ if (isArray2) {
480
+ const output = source.flatMap(map);
481
+ debugMsg(config, source, output);
482
+ return output;
483
+ } else {
484
+ const output = map(source);
485
+ debugMsg(config, source, output);
486
+ return output;
487
+ }
488
+ };
489
+ return createFnWithProps(fn, {
490
+ input: config.input,
491
+ output: config.output,
492
+ cardinality: config.cardinality,
493
+ debug: config.debug,
494
+ inputType: {},
495
+ outputType: {},
496
+ fnSignature: null
497
+ });
498
+ };
499
+ var setMapper = (config = { input: void 0, output: void 0, cardinality: void 0 }, defaultValue) => ({
500
+ map: (source) => {
501
+ const c = {
502
+ ...defaultValue,
503
+ ...config
504
+ };
505
+ return mapper(c)(source);
506
+ },
507
+ input: config?.input || defaultValue.input,
508
+ output: config?.output || defaultValue.output,
509
+ cardinality: config?.cardinality || defaultValue.cardinality,
510
+ debug: config?.debug || false
511
+ });
512
+ var mapToFn = (map) => {
513
+ return mapper(DEFAULT_ONE_TO_MANY_MAPPING)(map);
514
+ };
515
+ var mapToDict = {
516
+ config(config) {
517
+ const c = { ...DEFAULT_ONE_TO_MANY_MAPPING, ...config };
518
+ return setMapper(c, DEFAULT_ONE_TO_MANY_MAPPING);
519
+ },
520
+ oneToOne(config) {
521
+ const c = { ...DEFAULT_ONE_TO_ONE_MAPPING, ...config };
522
+ return setMapper(c, DEFAULT_ONE_TO_ONE_MAPPING);
523
+ },
524
+ manyToOne(config) {
525
+ const c = { ...DEFAULT_MANY_TO_ONE_MAPPING, ...config };
526
+ return setMapper(c, DEFAULT_MANY_TO_ONE_MAPPING);
527
+ },
528
+ oneToMany(config) {
529
+ const c = { ...DEFAULT_ONE_TO_MANY_MAPPING, ...config };
530
+ return setMapper(c, DEFAULT_ONE_TO_MANY_MAPPING);
531
+ }
532
+ };
533
+ var mapTo = createFnWithProps(mapToFn, mapToDict);
534
+
535
+ // src/runtime/dictionary/strArrayToDict.ts
536
+ function strArrayToDict(...strings) {
537
+ return strings.reduce((acc, str) => {
538
+ acc = { ...acc, [str]: true };
539
+ return acc;
540
+ }, {});
541
+ }
542
+
543
+ // src/runtime/dictionary/kv/dictToKv.ts
544
+ function dictToKv(obj, _makeTuple = false) {
545
+ return keys(obj).map((k) => {
546
+ return { key: k, value: obj[k] };
547
+ });
548
+ }
549
+
550
+ // src/runtime/state/Configurator.ts
551
+ function omit(obj, ...removals) {
552
+ const untyped = removals;
553
+ return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
554
+ }
555
+ function Configurator() {
556
+ let configuration = () => ({});
557
+ const api2 = () => {
558
+ return {
559
+ set(key, value) {
560
+ const keyValue = { [key]: value };
561
+ const config = configuration();
562
+ const updated = { ...config, ...keyValue };
563
+ configuration = () => updated;
564
+ return updated;
565
+ },
566
+ remove(key) {
567
+ const config = configuration();
568
+ const updated = omit(config, key);
569
+ configuration = () => updated;
570
+ return updated;
571
+ },
572
+ done() {
573
+ return configuration();
574
+ }
575
+ };
576
+ };
577
+ return api2();
578
+ }
579
+
580
+ // src/runtime/state/FluentConfigurator.ts
581
+ function FluentConfigurator(initial = {}) {
582
+ const api2 = (current) => {
583
+ return {
584
+ set(key, value) {
585
+ const keyValue = { [key]: value };
586
+ const updated = { ...keyValue, ...current };
587
+ return api2(updated);
588
+ },
589
+ done() {
590
+ return current;
591
+ }
592
+ };
593
+ };
594
+ if (initial && typeof initial !== "object") {
595
+ throw new Error(
596
+ "The FluentConfigurator was passed a non-object based value as the initial value. This is not allowed."
597
+ );
598
+ }
599
+ return initial ? api2(initial) : api2({});
600
+ }
601
+
602
+ // src/runtime/dictionary/kv/filterDictArray.ts
603
+ function filterDictArray(dictArr2, cb) {
604
+ const state = Configurator();
605
+ const updated = dictArr2.filter((i) => {
606
+ const [k, v] = i;
607
+ const keep = cb(k, v);
608
+ if (!keep) {
609
+ state.set(k, true);
610
+ }
611
+ return keep;
612
+ });
613
+ return updated;
614
+ }
615
+
616
+ // src/runtime/dictionary/kv/kv.ts
617
+ function kv(key, value) {
618
+ return { [key]: value };
619
+ }
620
+
621
+ // src/runtime/dictionary/kv/kvToDict.ts
622
+ function kvToDict(kvArr) {
623
+ const out = {};
624
+ for (const kv2 of kvArr) {
625
+ out[kv2.key] = kv2.value;
626
+ }
627
+ return out;
628
+ }
629
+
630
+ // src/runtime/lists/groupBy.ts
631
+ function groupBy(_data) {
632
+ throw new Error("not implemented");
633
+ }
634
+
635
+ // src/runtime/literals/box.ts
636
+ function box(value) {
637
+ const rtn = {
638
+ __kind: "box",
639
+ value,
640
+ unbox: (...p) => {
641
+ return typeof value === "function" ? value(...p) : value;
642
+ }
643
+ };
644
+ return rtn;
645
+ }
646
+ function isBox(thing) {
647
+ return typeof thing === "object" && "__kind" in thing && thing.__kind === "box";
648
+ }
649
+ function boxDictionaryValues(dict) {
650
+ return keys(dict).reduce(
651
+ (acc, key) => ({ ...acc, [key]: box(dict[key]) }),
652
+ {}
653
+ );
654
+ }
655
+ function unbox(val) {
656
+ return isBox(val) ? val.value : val;
657
+ }
658
+
659
+ // src/runtime/literals/wide.ts
660
+ var wide = {
661
+ boolean: false,
662
+ string: "",
663
+ number: 0,
664
+ symbol: Symbol(),
665
+ null: null,
666
+ undefined: void 0
667
+ };
668
+
669
+ // src/runtime/lists/createConverter.ts
670
+ function createConverter(mapper2) {
671
+ const converter = boxDictionaryValues(mapper2);
672
+ return (input) => {
673
+ const v = ifSameType(
674
+ input,
675
+ wide.string,
676
+ (i) => converter.string.unbox(i),
677
+ (i) => ifSameType(
678
+ i,
679
+ wide.number,
680
+ (i2) => converter.number.unbox(i2),
681
+ (i2) => ifSameType(
682
+ i2,
683
+ wide.boolean,
684
+ (i3) => converter.boolean.unbox(i3),
685
+ (i3) => ifSameType(
686
+ i3,
687
+ {},
688
+ (i4) => converter.object.unbox(i4),
689
+ (i4) => i4
690
+ )
691
+ )
692
+ )
693
+ );
694
+ return v;
695
+ };
696
+ }
697
+
698
+ // src/runtime/literals/ExplicitFunction.ts
699
+ function ExplicitFunction(fn) {
700
+ return fn;
701
+ }
702
+
703
+ // src/runtime/literals/arrayToObject.ts
704
+ function arrayToObject(prop, unique) {
705
+ const transform = (arr) => {
706
+ const result = unique !== false ? arr.reduce((acc, v) => ({ ...acc, [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
707
+ const existing = acc[v[prop]] || [];
708
+ return { ...acc, [v[prop]]: [...existing, v] };
709
+ }, {});
710
+ return result;
711
+ };
712
+ return transform;
713
+ }
714
+
715
+ // src/runtime/literals/defineType.ts
716
+ function defineType(literal2 = {}) {
717
+ return (wide2 = {}) => {
718
+ return literal2 ? { ...wide2, ...literal2 } : wide2;
719
+ };
720
+ }
721
+
722
+ // src/runtime/literals/identity.ts
723
+ var identity = (v) => v;
724
+
725
+ // src/runtime/literals/literal.ts
726
+ function idLiteral(o) {
727
+ return { ...o, id: o.id };
728
+ }
729
+ function nameLiteral(o) {
730
+ return o;
731
+ }
732
+ function kindLiteral(o) {
733
+ return o;
734
+ }
735
+ function idTypeGuard(_o) {
736
+ return true;
737
+ }
738
+ function literal(obj) {
739
+ return obj;
740
+ }
741
+
742
+ // src/runtime/literals/stripTrailing.ts
743
+ function stripTrailing(content, strip) {
744
+ const re = new RegExp(`(.*)${strip}$`);
745
+ return content.endsWith(strip) ? content.replace(re, "$1") : content;
746
+ }
747
+
748
+ // src/runtime/literals/ensureTrailing.ts
749
+ function ensureTrailing(content, ensure) {
750
+ return content.endsWith(ensure) ? content : `${content}${ensure}`;
751
+ }
752
+
753
+ // src/runtime/literals/ensureLeading.ts
754
+ function ensureLeading(content, ensure) {
755
+ return content.startsWith(ensure) ? content : `${ensure}${content}`;
756
+ }
757
+
758
+ // src/runtime/literals/stripLeading.ts
759
+ function stripLeading(content, strip) {
760
+ const re = new RegExp(`^${strip}(.*)`);
761
+ return content.startsWith(strip) ? content.replace(re, "$1") : content;
762
+ }
763
+
764
+ // src/runtime/literals/pathJoin.ts
765
+ function pathJoin(begin, ...rest) {
766
+ const start = rest.length > 0 ? ensureTrailing(begin, "/") : begin;
767
+ const end = rest.length > 0 ? ensureLeading(rest.slice(-1)[0], "/") : "";
768
+ const middle = rest.length > 1 ? rest.slice(0, rest.length - 1).map((i) => stripLeading(stripTrailing(i, "/"), '"')) : [];
769
+ const midString = stripTrailing(stripLeading(middle.join("/"), "/"), "/");
770
+ return rest.length > 1 ? `${start}${midString}${end}` : `${start}${stripLeading(end, "/")}`;
771
+ }
772
+ export {
773
+ Configurator,
774
+ DEFAULT_MANY_TO_ONE_MAPPING,
775
+ DEFAULT_ONE_TO_MANY_MAPPING,
776
+ DEFAULT_ONE_TO_ONE_MAPPING,
777
+ ExplicitFunction,
778
+ FluentConfigurator,
779
+ MapCardinality,
780
+ and,
781
+ api,
782
+ arrayToKeyLookup,
783
+ arrayToObject,
784
+ asArray,
785
+ box,
786
+ boxDictionaryValues,
787
+ condition,
788
+ createConverter,
789
+ createFnWithProps,
790
+ defineProperties,
791
+ defineType,
792
+ dictArr,
793
+ dictToKv,
794
+ dictionaryTransform,
795
+ ensureLeading,
796
+ ensureTrailing,
797
+ entries,
798
+ filter,
799
+ filterDictArray,
800
+ fnWithProps,
801
+ groupBy,
802
+ idLiteral,
803
+ idTypeGuard,
804
+ identity,
805
+ ifArray,
806
+ ifArrayPartial,
807
+ ifBoolean,
808
+ ifDefined,
809
+ ifFalse,
810
+ ifNull,
811
+ ifNumber,
812
+ ifObject,
813
+ ifSameType,
814
+ ifString,
815
+ ifTrue,
816
+ ifUndefined,
817
+ isArray,
818
+ isBoolean,
819
+ isBox,
820
+ isFalse,
821
+ isFunction,
822
+ isNotFilter,
823
+ isNull,
824
+ isNumber,
825
+ isNumericFilter,
826
+ isObject,
827
+ isString,
828
+ isSymbol,
829
+ isTrue,
830
+ isType,
831
+ isUndefined,
832
+ keys,
833
+ kindLiteral,
834
+ kv,
835
+ kvToDict,
836
+ literal,
837
+ mapTo,
838
+ mapToDict,
839
+ mapToFn,
840
+ mapValues,
841
+ nameLiteral,
842
+ not,
843
+ or,
844
+ pathJoin,
845
+ readonlyFnWithProps,
846
+ ruleSet,
847
+ strArrayToDict,
848
+ stripTrailing,
849
+ type,
850
+ typeApi,
851
+ unbox,
852
+ wide,
853
+ withValue
854
+ };