inferred-types 0.17.0 → 0.18.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 (192) hide show
  1. package/dist/{types/utility/state/KeyStorage.d.ts → index.d.ts} +9773 -8195
  2. package/dist/index.js +681 -0
  3. package/dist/index.mjs +598 -0
  4. package/on-hold/Builder/index.ts +15 -21
  5. package/on-hold/types/index.ts +15 -20
  6. package/package.json +23 -36
  7. package/pnpm-lock.yaml +1679 -3232
  8. package/src/Mutation/index.ts +16 -18
  9. package/src/index.ts +15 -19
  10. package/src/shared/index.ts +16 -18
  11. package/src/types/Transformer.ts +1 -2
  12. package/src/types/Where.ts +19 -15
  13. package/src/types/alphabetic/PascalCase.ts +5 -4
  14. package/src/types/alphabetic/index.ts +16 -20
  15. package/src/types/dictionary/index.ts +16 -18
  16. package/src/types/{fluent.ts → fluent/fluent.ts} +8 -9
  17. package/src/types/fluent/index.ts +35 -0
  18. package/src/types/index.ts +11 -21
  19. package/src/types/kv/index.ts +16 -18
  20. package/src/types/lists/index.ts +16 -18
  21. package/src/types/ruleset-types.ts +1 -1
  22. package/src/types/string-literals/index.ts +16 -18
  23. package/src/types/tuples/index.ts +16 -18
  24. package/src/types/{SameKeys.ts → type-conversion/SameKeys.ts} +0 -0
  25. package/src/types/type-conversion/WrapValue.ts +15 -0
  26. package/src/types/type-conversion/index.ts +18 -18
  27. package/src/utility/api/index.ts +16 -18
  28. package/src/utility/dictionary/index.ts +16 -21
  29. package/src/utility/dictionary/kv/index.ts +16 -18
  30. package/src/utility/index.ts +16 -20
  31. package/src/utility/lists/index.ts +16 -18
  32. package/src/utility/literals/index.ts +16 -18
  33. package/src/utility/map-reduce/index.ts +16 -18
  34. package/src/utility/modelling/index.ts +16 -18
  35. package/src/utility/runtime/conditions/index.ts +16 -18
  36. package/src/utility/runtime/ifTypeOf.ts +1 -5
  37. package/src/utility/runtime/index.ts +16 -20
  38. package/src/utility/state/Configurator.ts +12 -3
  39. package/src/utility/state/index.ts +16 -18
  40. package/tests/data/index.ts +9 -14
  41. package/tests/kv/dict-to-kv-and-back.spec.ts +24 -18
  42. package/tsconfig.json +4 -3
  43. package/dist/cjs/index.js +0 -1
  44. package/dist/es/index.js +0 -1
  45. package/dist/tsconfig.tsbuildinfo +0 -1
  46. package/dist/types/Mutation/MutationFunction.d.ts +0 -16
  47. package/dist/types/Mutation/MutationIdentity.d.ts +0 -30
  48. package/dist/types/Mutation/index.d.ts +0 -2
  49. package/dist/types/errors/InferenceError.d.ts +0 -1
  50. package/dist/types/errors/index.d.ts +0 -1
  51. package/dist/types/index.d.ts +0 -4
  52. package/dist/types/shared/index.d.ts +0 -3
  53. package/dist/types/shared/randomString.d.ts +0 -1
  54. package/dist/types/shared/uuid.d.ts +0 -1
  55. package/dist/types/shared/valueTypes.d.ts +0 -27
  56. package/dist/types/types/Api.d.ts +0 -10
  57. package/dist/types/types/Constructor.d.ts +0 -5
  58. package/dist/types/types/EnumValues.d.ts +0 -14
  59. package/dist/types/types/ExpandRecursively.d.ts +0 -3
  60. package/dist/types/types/First.d.ts +0 -4
  61. package/dist/types/types/FunctionType.d.ts +0 -9
  62. package/dist/types/types/If.d.ts +0 -10
  63. package/dist/types/types/Include.d.ts +0 -16
  64. package/dist/types/types/Includes.d.ts +0 -5
  65. package/dist/types/types/KeyedRecord.d.ts +0 -22
  66. package/dist/types/types/Keys.d.ts +0 -17
  67. package/dist/types/types/Length.d.ts +0 -8
  68. package/dist/types/types/Mutable.d.ts +0 -6
  69. package/dist/types/types/Narrowable.d.ts +0 -5
  70. package/dist/types/types/Not.d.ts +0 -13
  71. package/dist/types/types/Numeric.d.ts +0 -14
  72. package/dist/types/types/Opaque.d.ts +0 -12
  73. package/dist/types/types/Retain.d.ts +0 -16
  74. package/dist/types/types/SameKeys.d.ts +0 -11
  75. package/dist/types/types/Transformer.d.ts +0 -11
  76. package/dist/types/types/TypeGuard.d.ts +0 -7
  77. package/dist/types/types/Where.d.ts +0 -29
  78. package/dist/types/types/alphabetic/AllCaps.d.ts +0 -12
  79. package/dist/types/types/alphabetic/CamelCase.d.ts +0 -2
  80. package/dist/types/types/alphabetic/CapFirstAlpha.d.ts +0 -13
  81. package/dist/types/types/alphabetic/CapitalizeWords.d.ts +0 -4
  82. package/dist/types/types/alphabetic/DashToSnake.d.ts +0 -1
  83. package/dist/types/types/alphabetic/DashUppercase.d.ts +0 -14
  84. package/dist/types/types/alphabetic/Dasherize.d.ts +0 -15
  85. package/dist/types/types/alphabetic/HasUppercase.d.ts +0 -13
  86. package/dist/types/types/alphabetic/Intrinsic.d.ts +0 -4
  87. package/dist/types/types/alphabetic/IsCapitalized.d.ts +0 -15
  88. package/dist/types/types/alphabetic/KebabCase.d.ts +0 -12
  89. package/dist/types/types/alphabetic/LowerAllCaps.d.ts +0 -4
  90. package/dist/types/types/alphabetic/PascalCase.d.ts +0 -16
  91. package/dist/types/types/alphabetic/Pluralize.d.ts +0 -36
  92. package/dist/types/types/alphabetic/SnakeCase.d.ts +0 -14
  93. package/dist/types/types/alphabetic/alpha-characters.d.ts +0 -36
  94. package/dist/types/types/alphabetic/index.d.ts +0 -16
  95. package/dist/types/types/append-types.d.ts +0 -9
  96. package/dist/types/types/dictionary/Get.d.ts +0 -7
  97. package/dist/types/types/dictionary/index.d.ts +0 -1
  98. package/dist/types/types/fluent.d.ts +0 -51
  99. package/dist/types/types/index.d.ts +0 -36
  100. package/dist/types/types/kv/DictFromKv.d.ts +0 -6
  101. package/dist/types/types/kv/KeyValue.d.ts +0 -11
  102. package/dist/types/types/kv/KvFrom.d.ts +0 -13
  103. package/dist/types/types/kv/KvTuple.d.ts +0 -14
  104. package/dist/types/types/kv/index.d.ts +0 -4
  105. package/dist/types/types/lists/UniqueForProp.d.ts +0 -14
  106. package/dist/types/types/lists/index.d.ts +0 -1
  107. package/dist/types/types/maybe.d.ts +0 -8
  108. package/dist/types/types/props.d.ts +0 -100
  109. package/dist/types/types/ruleset-types.d.ts +0 -59
  110. package/dist/types/types/runtime.d.ts +0 -33
  111. package/dist/types/types/string-literals/Break.d.ts +0 -12
  112. package/dist/types/types/string-literals/Concat.d.ts +0 -8
  113. package/dist/types/types/string-literals/LeftWhitespace.d.ts +0 -9
  114. package/dist/types/types/string-literals/Replace.d.ts +0 -11
  115. package/dist/types/types/string-literals/RightWhitespace.d.ts +0 -9
  116. package/dist/types/types/string-literals/StringLength.d.ts +0 -10
  117. package/dist/types/types/string-literals/Trim.d.ts +0 -11
  118. package/dist/types/types/string-literals/TrimLeft.d.ts +0 -11
  119. package/dist/types/types/string-literals/TrimRight.d.ts +0 -11
  120. package/dist/types/types/string-literals/form-fields.d.ts +0 -12
  121. package/dist/types/types/string-literals/index.d.ts +0 -10
  122. package/dist/types/types/tuples/DictArray.d.ts +0 -19
  123. package/dist/types/types/tuples/FirstKey.d.ts +0 -8
  124. package/dist/types/types/tuples/FirstKeyValue.d.ts +0 -8
  125. package/dist/types/types/tuples/FirstOfEach.d.ts +0 -11
  126. package/dist/types/types/tuples/FromDictArray.d.ts +0 -10
  127. package/dist/types/types/tuples/SecondOfEach.d.ts +0 -10
  128. package/dist/types/types/tuples/index.d.ts +0 -6
  129. package/dist/types/types/type-conversion/TupleToUnion.d.ts +0 -10
  130. package/dist/types/types/type-conversion/UnionToIntersection.d.ts +0 -5
  131. package/dist/types/types/type-conversion/UnionToTuple.d.ts +0 -9
  132. package/dist/types/types/type-conversion/index.d.ts +0 -3
  133. package/dist/types/types/type-testing.d.ts +0 -13
  134. package/dist/types/utility/api/api.d.ts +0 -2
  135. package/dist/types/utility/api/index.d.ts +0 -1
  136. package/dist/types/utility/createFnWithProps.d.ts +0 -1
  137. package/dist/types/utility/dictionary/arrayToKeyLookup.d.ts +0 -9
  138. package/dist/types/utility/dictionary/dictFilter.d.ts +0 -8
  139. package/dist/types/utility/dictionary/dictionaryTransform.d.ts +0 -9
  140. package/dist/types/utility/dictionary/entries.d.ts +0 -17
  141. package/dist/types/utility/dictionary/index.d.ts +0 -8
  142. package/dist/types/utility/dictionary/kv/dictToKv.d.ts +0 -16
  143. package/dist/types/utility/dictionary/kv/filterDictArray.d.ts +0 -9
  144. package/dist/types/utility/dictionary/kv/index.d.ts +0 -4
  145. package/dist/types/utility/dictionary/kv/kv.d.ts +0 -10
  146. package/dist/types/utility/dictionary/kv/kvToDict.d.ts +0 -15
  147. package/dist/types/utility/dictionary/mapValues.d.ts +0 -13
  148. package/dist/types/utility/dictionary/strArrayToDict.d.ts +0 -6
  149. package/dist/types/utility/dictionary/valuesOfProp.d.ts +0 -1
  150. package/dist/types/utility/index.d.ts +0 -11
  151. package/dist/types/utility/keys.d.ts +0 -5
  152. package/dist/types/utility/lists/groupBy.d.ts +0 -12
  153. package/dist/types/utility/lists/index.d.ts +0 -1
  154. package/dist/types/utility/literals/ExplicitFunction.d.ts +0 -6
  155. package/dist/types/utility/literals/arrayToObject.d.ts +0 -41
  156. package/dist/types/utility/literals/defineType.d.ts +0 -8
  157. package/dist/types/utility/literals/identity.d.ts +0 -6
  158. package/dist/types/utility/literals/index.d.ts +0 -5
  159. package/dist/types/utility/literals/literal.d.ts +0 -41
  160. package/dist/types/utility/map-reduce/filter.d.ts +0 -26
  161. package/dist/types/utility/map-reduce/index.d.ts +0 -1
  162. package/dist/types/utility/modelling/Model.d.ts +0 -22
  163. package/dist/types/utility/modelling/index.d.ts +0 -1
  164. package/dist/types/utility/ruleset.d.ts +0 -18
  165. package/dist/types/utility/runtime/condition.d.ts +0 -3
  166. package/dist/types/utility/runtime/conditions/index.d.ts +0 -12
  167. package/dist/types/utility/runtime/conditions/isArray.d.ts +0 -2
  168. package/dist/types/utility/runtime/conditions/isBoolean.d.ts +0 -5
  169. package/dist/types/utility/runtime/conditions/isFalse.d.ts +0 -4
  170. package/dist/types/utility/runtime/conditions/isFunction.d.ts +0 -15
  171. package/dist/types/utility/runtime/conditions/isLiteral.d.ts +0 -2
  172. package/dist/types/utility/runtime/conditions/isNull.d.ts +0 -1
  173. package/dist/types/utility/runtime/conditions/isNumber.d.ts +0 -1
  174. package/dist/types/utility/runtime/conditions/isObject.d.ts +0 -10
  175. package/dist/types/utility/runtime/conditions/isString.d.ts +0 -2
  176. package/dist/types/utility/runtime/conditions/isSymbol.d.ts +0 -1
  177. package/dist/types/utility/runtime/conditions/isTrue.d.ts +0 -20
  178. package/dist/types/utility/runtime/conditions/isUndefined.d.ts +0 -1
  179. package/dist/types/utility/runtime/ifTypeOf.d.ts +0 -23
  180. package/dist/types/utility/runtime/index.d.ts +0 -5
  181. package/dist/types/utility/runtime/type.d.ts +0 -27
  182. package/dist/types/utility/runtime/withValue.d.ts +0 -19
  183. package/dist/types/utility/state/Configurator.d.ts +0 -36
  184. package/dist/types/utility/state/FluentConfigurator.d.ts +0 -27
  185. package/dist/types/utility/state/index.d.ts +0 -3
  186. package/src/errors/InferenceError.ts +0 -3
  187. package/src/errors/index.ts +0 -37
  188. package/src/types/alphabetic/Intrinsic.ts +0 -6
  189. package/src/utility/dictionary/dictFilter.ts +0 -19
  190. package/tests/FluentApi-spec.ts +0 -90
  191. package/tests/FluentConfigurator-spec.hold +0 -88
  192. package/tests/kv/dictFilter.ts +0 -8
package/dist/index.js ADDED
@@ -0,0 +1,681 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __reExport = (target, module2, copyDefault, desc) => {
28
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
29
+ for (let key of __getOwnPropNames(module2))
30
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
31
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
32
+ }
33
+ return target;
34
+ };
35
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
36
+ return (module2, temp) => {
37
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
38
+ };
39
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
40
+
41
+ // src/index.ts
42
+ var src_exports = {};
43
+ __export(src_exports, {
44
+ Configurator: () => Configurator,
45
+ ExplicitFunction: () => ExplicitFunction,
46
+ FluentConfigurator: () => FluentConfigurator,
47
+ KeyStorage: () => KeyStorage,
48
+ Model: () => Model,
49
+ MutationIdentity: () => MutationIdentity,
50
+ and: () => and,
51
+ api: () => api,
52
+ arrayToKeyLookup: () => arrayToKeyLookup,
53
+ arrayToObject: () => arrayToObject,
54
+ condition: () => condition,
55
+ createFnWithProps: () => createFnWithProps,
56
+ createMutationFunction: () => createMutationFunction,
57
+ defineType: () => defineType,
58
+ dictToKv: () => dictToKv,
59
+ dictionaryTransform: () => dictionaryTransform,
60
+ entries: () => entries,
61
+ equals: () => equals,
62
+ filterDictArray: () => filterDictArray,
63
+ greater: () => greater,
64
+ groupBy: () => groupBy,
65
+ idLiteral: () => idLiteral,
66
+ idTypeGuard: () => idTypeGuard,
67
+ identity: () => identity,
68
+ ifTypeOf: () => ifTypeOf,
69
+ isArray: () => isArray,
70
+ isBoolean: () => isBoolean,
71
+ isFalse: () => isFalse,
72
+ isFunction: () => isFunction,
73
+ isLiteral: () => isLiteral,
74
+ isNull: () => isNull,
75
+ isNumber: () => isNumber,
76
+ isObject: () => isObject,
77
+ isString: () => isString,
78
+ isSymbol: () => isSymbol,
79
+ isTrue: () => isTrue,
80
+ isType: () => isType,
81
+ isUndefined: () => isUndefined,
82
+ keys: () => keys,
83
+ kindLiteral: () => kindLiteral,
84
+ kv: () => kv,
85
+ kvToDict: () => kvToDict,
86
+ less: () => less,
87
+ literal: () => literal,
88
+ mapValues: () => mapValues,
89
+ nameLiteral: () => nameLiteral,
90
+ or: () => or,
91
+ randomString: () => randomString,
92
+ ruleSet: () => ruleSet,
93
+ strArrayToDict: () => strArrayToDict,
94
+ type: () => type,
95
+ typeApi: () => typeApi,
96
+ uuid: () => uuid,
97
+ valueTypes: () => valueTypes,
98
+ valuesOfProp: () => valuesOfProp,
99
+ withValue: () => withValue
100
+ });
101
+
102
+ // src/Mutation/MutationFunction.ts
103
+ function createMutationFunction(state) {
104
+ return (mutationIdentity) => {
105
+ return mutationIdentity(state);
106
+ };
107
+ }
108
+
109
+ // src/Mutation/MutationIdentity.ts
110
+ function MutationIdentity() {
111
+ return function(m) {
112
+ return m;
113
+ };
114
+ }
115
+
116
+ // src/shared/randomString.ts
117
+ function randomString() {
118
+ return Math.trunc((1 + Math.random()) * 65536).toString(16).slice(1);
119
+ }
120
+
121
+ // src/shared/uuid.ts
122
+ function uuid() {
123
+ return `${randomString()}${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}${randomString()}${randomString()}`;
124
+ }
125
+
126
+ // src/shared/valueTypes.ts
127
+ var valueTypes = {
128
+ string: ["", false],
129
+ boolean: [true, false],
130
+ number: [0, false],
131
+ function: [() => "", false],
132
+ object: [{}, false],
133
+ array: (arr = []) => [arr, false],
134
+ null: [null, false],
135
+ symbol: [Symbol("type"), false],
136
+ undefined: [void 0, false],
137
+ true: [true, true],
138
+ false: [false, true],
139
+ literal: (v) => {
140
+ return [v, true];
141
+ },
142
+ literalArray: (arr) => [arr, true]
143
+ };
144
+
145
+ // src/utility/keys.ts
146
+ function keys(obj, ...without) {
147
+ const v = without.length > 0 ? Object.keys(obj).filter((k) => !without.includes(k)) : Object.keys(obj);
148
+ return v;
149
+ }
150
+
151
+ // src/utility/createFnWithProps.ts
152
+ function createFnWithProps(fn, props) {
153
+ return (() => {
154
+ let combined = fn;
155
+ for (const prop of keys(props)) {
156
+ combined[prop] = props[prop];
157
+ }
158
+ return combined;
159
+ })();
160
+ }
161
+
162
+ // src/utility/ruleset.ts
163
+ function ruleSet(defn) {
164
+ return defn;
165
+ }
166
+
167
+ // src/utility/api/api.ts
168
+ var api = (priv) => (pub) => {
169
+ const surface = () => pub;
170
+ surface.prototype.priv = () => priv;
171
+ return surface;
172
+ };
173
+
174
+ // src/utility/dictionary/arrayToKeyLookup.ts
175
+ function arrayToKeyLookup(...keys2) {
176
+ const obj = {};
177
+ for (const key of keys2) {
178
+ obj[key] = true;
179
+ }
180
+ return obj;
181
+ }
182
+
183
+ // src/utility/dictionary/dictionaryTransform.ts
184
+ function dictionaryTransform(input, transform) {
185
+ return keys(input).reduce((acc, i) => {
186
+ const key = i;
187
+ return __spreadProps(__spreadValues({}, acc), { [key]: transform(input, key) });
188
+ }, {});
189
+ }
190
+
191
+ // src/utility/dictionary/entries.ts
192
+ function entries(obj) {
193
+ const iterable = {
194
+ *[Symbol.iterator]() {
195
+ for (const k of keys(obj)) {
196
+ yield [k, obj[k]];
197
+ }
198
+ }
199
+ };
200
+ return iterable;
201
+ }
202
+
203
+ // src/utility/dictionary/mapValues.ts
204
+ function mapValues(obj, valueMapper) {
205
+ return Object.fromEntries([...entries(obj)].map(([k, v]) => [k, valueMapper(v)]));
206
+ }
207
+
208
+ // src/utility/dictionary/strArrayToDict.ts
209
+ function strArrayToDict(...strings) {
210
+ return strings.reduce((acc, str) => {
211
+ acc = __spreadProps(__spreadValues({}, acc), { [str]: true });
212
+ return acc;
213
+ }, {});
214
+ }
215
+
216
+ // src/utility/dictionary/valuesOfProp.ts
217
+ function valuesOfProp() {
218
+ }
219
+
220
+ // src/utility/dictionary/kv/dictToKv.ts
221
+ function dictToKv(obj, _makeTuple = false) {
222
+ return keys(obj).map((k) => {
223
+ return { key: k, value: obj[k] };
224
+ });
225
+ }
226
+
227
+ // src/utility/state/Configurator.ts
228
+ function omit(obj, ...removals) {
229
+ const untyped = removals;
230
+ return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
231
+ }
232
+ function Configurator() {
233
+ let configuration = () => ({});
234
+ const api2 = () => {
235
+ return {
236
+ set(key, value) {
237
+ const keyValue = { [key]: value };
238
+ const config = configuration();
239
+ const updated = __spreadValues(__spreadValues({}, config), keyValue);
240
+ configuration = () => updated;
241
+ return updated;
242
+ },
243
+ remove(key) {
244
+ const config = configuration();
245
+ const updated = omit(config, key);
246
+ configuration = () => updated;
247
+ return updated;
248
+ },
249
+ done() {
250
+ return configuration();
251
+ }
252
+ };
253
+ };
254
+ return api2();
255
+ }
256
+
257
+ // src/utility/state/FluentConfigurator.ts
258
+ function FluentConfigurator(initial = {}) {
259
+ const api2 = (current) => {
260
+ return {
261
+ set(key, value) {
262
+ const keyValue = { [key]: value };
263
+ const updated = __spreadValues(__spreadValues({}, keyValue), current);
264
+ return api2(updated);
265
+ },
266
+ done() {
267
+ return current;
268
+ }
269
+ };
270
+ };
271
+ if (initial && typeof initial !== "object") {
272
+ throw new Error("The FluentConfigurator was passed a non-object based value as the initial value. This is not allowed.");
273
+ }
274
+ return initial ? api2(initial) : api2({});
275
+ }
276
+
277
+ // src/utility/state/KeyStorage.ts
278
+ function KeyStorage() {
279
+ const api2 = (state) => ({
280
+ add: (...store) => {
281
+ return api2([...state, ...store]);
282
+ },
283
+ remove: (key) => api2(state.filter((i) => i !== key)),
284
+ done: () => state
285
+ });
286
+ return api2([]);
287
+ }
288
+
289
+ // src/utility/dictionary/kv/filterDictArray.ts
290
+ function filterDictArray(dictArr, cb) {
291
+ const state = Configurator();
292
+ const updated = dictArr.filter((i) => {
293
+ const [k, v] = i;
294
+ const keep = cb(k, v);
295
+ if (!keep) {
296
+ state.set(k, true);
297
+ }
298
+ return keep;
299
+ });
300
+ return updated;
301
+ }
302
+
303
+ // src/utility/dictionary/kv/kv.ts
304
+ function kv(key, value) {
305
+ return { [key]: value };
306
+ }
307
+
308
+ // src/utility/dictionary/kv/kvToDict.ts
309
+ function kvToDict(kvArr) {
310
+ const out = {};
311
+ for (const kv2 of kvArr) {
312
+ out[kv2.key] = kv2.value;
313
+ }
314
+ return out;
315
+ }
316
+
317
+ // src/utility/lists/groupBy.ts
318
+ function groupBy(_data) {
319
+ throw new Error("not implemented");
320
+ return (_groupBy) => {
321
+ };
322
+ }
323
+
324
+ // src/utility/literals/ExplicitFunction.ts
325
+ function ExplicitFunction(fn) {
326
+ return fn;
327
+ }
328
+
329
+ // src/utility/literals/arrayToObject.ts
330
+ function arrayToObject(prop, unique) {
331
+ const transform = (arr) => {
332
+ const result = unique !== false ? arr.reduce((acc, v) => __spreadProps(__spreadValues({}, acc), { [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
333
+ const existing = acc[v[prop]] || [];
334
+ return __spreadProps(__spreadValues({}, acc), { [v[prop]]: [...existing, v] });
335
+ }, {});
336
+ return result;
337
+ };
338
+ return transform;
339
+ }
340
+
341
+ // src/utility/literals/defineType.ts
342
+ function defineType(literal2 = {}) {
343
+ return (wide = {}) => {
344
+ return literal2 ? __spreadValues(__spreadValues({}, wide), literal2) : wide;
345
+ };
346
+ }
347
+
348
+ // src/utility/literals/identity.ts
349
+ var identity = (v) => v;
350
+
351
+ // src/utility/literals/literal.ts
352
+ function idLiteral(o) {
353
+ return __spreadProps(__spreadValues({}, o), { id: o.id });
354
+ }
355
+ function nameLiteral(o) {
356
+ return o;
357
+ }
358
+ function kindLiteral(o) {
359
+ return o;
360
+ }
361
+ function idTypeGuard(_o) {
362
+ return true;
363
+ }
364
+ function literal(obj) {
365
+ return obj;
366
+ }
367
+
368
+ // src/utility/map-reduce/filter.ts
369
+ var equals = (field, val) => ({
370
+ kind: "Equals",
371
+ field,
372
+ val
373
+ });
374
+ var greater = (field, val) => ({
375
+ kind: "Greater",
376
+ field,
377
+ val
378
+ });
379
+ var less = (field, val) => ({
380
+ kind: "Less",
381
+ field,
382
+ val
383
+ });
384
+ var and = (a, b) => ({
385
+ kind: "And",
386
+ a,
387
+ b
388
+ });
389
+ var or = (a, b) => ({
390
+ kind: "Or",
391
+ a,
392
+ b
393
+ });
394
+
395
+ // src/utility/modelling/Model.ts
396
+ function Model(name) {
397
+ return {
398
+ required(_prop) {
399
+ return Model(name);
400
+ },
401
+ optional(_prop) {
402
+ return Model(name);
403
+ },
404
+ done() {
405
+ return {
406
+ __model__: name,
407
+ __kind__: "model"
408
+ };
409
+ }
410
+ };
411
+ }
412
+
413
+ // src/utility/runtime/condition.ts
414
+ var condition = (c, input) => {
415
+ return c(input);
416
+ };
417
+
418
+ // src/utility/runtime/ifTypeOf.ts
419
+ function runtimeExtendsCheck(val, base, narrow = false) {
420
+ if (typeof val !== typeof base) {
421
+ return false;
422
+ }
423
+ switch (typeof val) {
424
+ case "boolean":
425
+ case "string":
426
+ case "number":
427
+ case "symbol":
428
+ case "bigint":
429
+ return narrow ? val === base : true;
430
+ case "undefined":
431
+ return true;
432
+ case "function":
433
+ if (narrow) {
434
+ throw new Error(`Use of narrowlyExtends with a function is not possible!`);
435
+ }
436
+ return true;
437
+ case "object":
438
+ if (val === null && base === null) {
439
+ return true;
440
+ }
441
+ return keys(base).every((i) => runtimeExtendsCheck(val[i], base[i], narrow));
442
+ }
443
+ }
444
+ var ifTypeOf = (val) => ({
445
+ extends: (base) => {
446
+ const valid = runtimeExtendsCheck(val, base, false);
447
+ const trueFalse = valid ? true : false;
448
+ return {
449
+ then: (then) => ({
450
+ else: (elseVal) => {
451
+ return valid ? typeof then === "undefined" ? val : then : elseVal;
452
+ }
453
+ }),
454
+ else: (elseVal) => valid ? val : elseVal
455
+ } && trueFalse;
456
+ },
457
+ narrowlyExtends: (base) => {
458
+ const valid = runtimeExtendsCheck(val, base, true);
459
+ const trueFalse = valid ? true : false;
460
+ return {
461
+ then: (then) => ({
462
+ else: (elseVal) => {
463
+ return valid ? typeof then === "undefined" ? val : then : elseVal;
464
+ }
465
+ }),
466
+ else: (elseVal) => valid ? val : elseVal
467
+ } && trueFalse;
468
+ }
469
+ });
470
+
471
+ // src/utility/runtime/conditions/isArray.ts
472
+ function isArray(i) {
473
+ return Array.isArray(i) === true;
474
+ }
475
+
476
+ // src/utility/runtime/conditions/isBoolean.ts
477
+ function isBoolean(i) {
478
+ return typeof i === "boolean";
479
+ }
480
+
481
+ // src/utility/runtime/conditions/isFalse.ts
482
+ function isFalse(i) {
483
+ return typeof i === "boolean" && !i;
484
+ }
485
+
486
+ // src/utility/runtime/conditions/isFunction.ts
487
+ function isFunction(input) {
488
+ return typeof input === "function";
489
+ }
490
+
491
+ // src/utility/runtime/conditions/isLiteral.ts
492
+ function isLiteral(...allowed) {
493
+ return (i) => {
494
+ return !allowed.every((v) => i !== v);
495
+ };
496
+ }
497
+
498
+ // src/utility/runtime/conditions/isNull.ts
499
+ function isNull(i) {
500
+ return i === null;
501
+ }
502
+
503
+ // src/utility/runtime/conditions/isNumber.ts
504
+ function isNumber(i) {
505
+ return typeof i === "number";
506
+ }
507
+
508
+ // src/utility/runtime/conditions/isObject.ts
509
+ function isObject(i) {
510
+ return typeof i === "object" && i !== null && Array.isArray(i) === false;
511
+ }
512
+
513
+ // src/utility/runtime/conditions/isString.ts
514
+ function isString(i) {
515
+ return typeof i === "string";
516
+ }
517
+
518
+ // src/utility/runtime/conditions/isSymbol.ts
519
+ function isSymbol(i) {
520
+ return typeof i === "symbol";
521
+ }
522
+
523
+ // src/utility/runtime/conditions/isTrue.ts
524
+ function isTrue(i) {
525
+ return typeof i === "boolean" && i;
526
+ }
527
+
528
+ // src/utility/runtime/conditions/isUndefined.ts
529
+ function isUndefined(i) {
530
+ return typeof i === "undefined";
531
+ }
532
+
533
+ // src/utility/runtime/type.ts
534
+ var typeApi = () => ({
535
+ string: {
536
+ name: "string",
537
+ type: "",
538
+ typeGuard: (v) => isString(v),
539
+ is: isString
540
+ },
541
+ boolean: {
542
+ name: "boolean",
543
+ type: true,
544
+ typeGuard: (v) => isBoolean(v),
545
+ is: isBoolean
546
+ },
547
+ number: {
548
+ name: "number",
549
+ type: 1,
550
+ typeGuard: (v) => isNumber(v),
551
+ is: isNumber
552
+ },
553
+ function: {
554
+ name: "function",
555
+ type: Function,
556
+ typeGuard: (v) => isFunction(v),
557
+ is: isFunction
558
+ },
559
+ null: {
560
+ name: "null",
561
+ type: null,
562
+ typeGuard: (v) => isNull(v),
563
+ is: isNull
564
+ },
565
+ symbol: {
566
+ name: "symbol",
567
+ type: Symbol(),
568
+ typeGuard: (v) => isSymbol(v),
569
+ is: isSymbol
570
+ },
571
+ undefined: {
572
+ name: "undefined",
573
+ type: void 0,
574
+ typeGuard: (v) => isUndefined(v),
575
+ is: isUndefined
576
+ },
577
+ true: {
578
+ name: "true",
579
+ type: true,
580
+ typeGuard: (v) => isTrue(v),
581
+ is: isTrue
582
+ },
583
+ false: {
584
+ name: "false",
585
+ type: false,
586
+ typeGuard: (v) => isFalse(v),
587
+ is: isFalse
588
+ },
589
+ object: {
590
+ name: "object",
591
+ type: {},
592
+ typeGuard: (v) => isObject(v),
593
+ is: isObject
594
+ },
595
+ array: {
596
+ name: "array",
597
+ type: {},
598
+ typeGuard: (v) => isArray(v),
599
+ is: isObject
600
+ }
601
+ });
602
+ function isType(t) {
603
+ return typeof t === "object" && ["name", "type", "is"].every((i) => Object.keys(t).includes(i));
604
+ }
605
+ function type(fn) {
606
+ const result = fn(typeApi());
607
+ if (!isType(result)) {
608
+ throw new Error(`When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`);
609
+ }
610
+ return result;
611
+ }
612
+
613
+ // src/utility/runtime/withValue.ts
614
+ function withValue(td) {
615
+ return (obj) => {
616
+ const t = type(td);
617
+ return Object.fromEntries([...entries(obj)].filter(([_key, value]) => {
618
+ return t.typeGuard(value);
619
+ }));
620
+ };
621
+ }
622
+ module.exports = __toCommonJS(src_exports);
623
+ // Annotate the CommonJS export names for ESM import in node:
624
+ 0 && (module.exports = {
625
+ Configurator,
626
+ ExplicitFunction,
627
+ FluentConfigurator,
628
+ KeyStorage,
629
+ Model,
630
+ MutationIdentity,
631
+ and,
632
+ api,
633
+ arrayToKeyLookup,
634
+ arrayToObject,
635
+ condition,
636
+ createFnWithProps,
637
+ createMutationFunction,
638
+ defineType,
639
+ dictToKv,
640
+ dictionaryTransform,
641
+ entries,
642
+ equals,
643
+ filterDictArray,
644
+ greater,
645
+ groupBy,
646
+ idLiteral,
647
+ idTypeGuard,
648
+ identity,
649
+ ifTypeOf,
650
+ isArray,
651
+ isBoolean,
652
+ isFalse,
653
+ isFunction,
654
+ isLiteral,
655
+ isNull,
656
+ isNumber,
657
+ isObject,
658
+ isString,
659
+ isSymbol,
660
+ isTrue,
661
+ isType,
662
+ isUndefined,
663
+ keys,
664
+ kindLiteral,
665
+ kv,
666
+ kvToDict,
667
+ less,
668
+ literal,
669
+ mapValues,
670
+ nameLiteral,
671
+ or,
672
+ randomString,
673
+ ruleSet,
674
+ strArrayToDict,
675
+ type,
676
+ typeApi,
677
+ uuid,
678
+ valueTypes,
679
+ valuesOfProp,
680
+ withValue
681
+ });