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