inferred-types 0.33.1 → 0.33.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 (145) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/dist/index.d.ts +1209 -1152
  3. package/dist/index.js +73 -182
  4. package/dist/index.mjs +70 -175
  5. package/package.json +16 -15
  6. package/src/{utility/errors → errors}/ReadOnlyViolation.ts +0 -0
  7. package/src/{utility/errors → errors}/index.ts +0 -0
  8. package/src/index.ts +1 -3
  9. package/src/{utility → runtime}/README.md +0 -0
  10. package/src/{utility → runtime}/api/api.ts +0 -0
  11. package/src/{utility → runtime}/api/index.ts +0 -0
  12. package/src/{utility/modelling → runtime/builders}/Model.ts +0 -0
  13. package/src/runtime/builders/url.ts +15 -0
  14. package/src/{utility/boolean-logic → runtime/combinators}/and.ts +0 -0
  15. package/src/{utility/boolean-logic → runtime/combinators}/filter.ts +0 -0
  16. package/src/{utility/boolean-logic → runtime/combinators}/index.ts +0 -0
  17. package/src/{utility/boolean-logic → runtime/combinators}/not.ts +0 -0
  18. package/src/{utility/boolean-logic → runtime/combinators}/or.ts +0 -0
  19. package/src/{utility → runtime}/createFnWithProps.ts +0 -0
  20. package/src/{utility → runtime}/dictionary/arrayToKeyLookup.ts +0 -0
  21. package/src/{utility → runtime}/dictionary/defineProperties.ts +0 -0
  22. package/src/{utility → runtime}/dictionary/dictArr.ts +0 -0
  23. package/src/{utility → runtime}/dictionary/dictionaryTransform.ts +0 -0
  24. package/src/{utility → runtime}/dictionary/entries.ts +0 -0
  25. package/src/{utility → runtime}/dictionary/index.ts +0 -0
  26. package/src/{utility → runtime}/dictionary/kv/dictToKv.ts +1 -1
  27. package/src/{utility → runtime}/dictionary/kv/filterDictArray.ts +1 -1
  28. package/src/{utility → runtime}/dictionary/kv/index.ts +0 -0
  29. package/src/{utility → runtime}/dictionary/kv/kv.ts +0 -0
  30. package/src/{utility → runtime}/dictionary/kv/kvToDict.ts +0 -0
  31. package/src/{utility → runtime}/dictionary/mapTo.ts +0 -0
  32. package/src/{utility → runtime}/dictionary/mapValues.ts +0 -0
  33. package/src/{utility → runtime}/dictionary/merge.ts +0 -0
  34. package/src/{utility → runtime}/dictionary/strArrayToDict.ts +0 -0
  35. package/src/{utility → runtime}/index.ts +1 -3
  36. package/src/{utility → runtime}/keys.ts +0 -0
  37. package/src/{utility → runtime}/lists/asArray.ts +0 -0
  38. package/src/{utility → runtime}/lists/groupBy.ts +0 -0
  39. package/src/{utility → runtime}/lists/index.ts +0 -0
  40. package/src/{utility → runtime}/literals/ExplicitFunction.ts +0 -0
  41. package/src/runtime/literals/Suggest.ts +19 -0
  42. package/src/{utility → runtime}/literals/arrayToObject.ts +0 -0
  43. package/src/runtime/literals/box.ts +77 -0
  44. package/src/{utility → runtime}/literals/defineType.ts +0 -0
  45. package/src/{utility → runtime}/literals/identity.ts +0 -0
  46. package/src/{utility → runtime}/literals/index.ts +2 -0
  47. package/src/{utility → runtime}/literals/literal.ts +0 -0
  48. package/src/{utility → runtime}/ruleset.ts +0 -0
  49. package/src/{utility → runtime}/runtime/README.md +0 -0
  50. package/src/{utility → runtime}/runtime/condition.ts +0 -0
  51. package/src/{utility → runtime}/runtime/index.ts +1 -2
  52. package/src/{utility → runtime}/runtime/type.ts +1 -1
  53. package/src/{utility → runtime}/runtime/withValue.ts +0 -0
  54. package/src/{utility → runtime}/state/Configurator.ts +0 -0
  55. package/src/{utility → runtime}/state/FluentConfigurator.ts +0 -0
  56. package/src/{utility → runtime}/state/index.ts +0 -0
  57. package/src/{utility/runtime → runtime/type-checks}/ifTypeOf.ts +0 -0
  58. package/src/{utility/runtime/conditions → runtime/type-checks}/index.ts +0 -0
  59. package/src/{utility/runtime/conditions → runtime/type-checks}/isArray.ts +0 -0
  60. package/src/{utility/runtime/conditions → runtime/type-checks}/isBoolean.ts +0 -0
  61. package/src/{utility/runtime/conditions → runtime/type-checks}/isFalse.ts +0 -0
  62. package/src/{utility/runtime/conditions → runtime/type-checks}/isFunction.ts +11 -2
  63. package/src/{utility/runtime/conditions → runtime/type-checks}/isNull.ts +0 -0
  64. package/src/{utility/runtime/conditions → runtime/type-checks}/isNumber.ts +0 -0
  65. package/src/{utility/runtime/conditions → runtime/type-checks}/isObject.ts +1 -1
  66. package/src/{utility/runtime/conditions → runtime/type-checks}/isString.ts +13 -5
  67. package/src/{utility/runtime/conditions → runtime/type-checks}/isSymbol.ts +0 -0
  68. package/src/{utility/runtime/conditions → runtime/type-checks}/isTrue.ts +1 -1
  69. package/src/{utility/runtime/conditions → runtime/type-checks}/isUndefined.ts +1 -1
  70. package/src/runtime/type-checks/startsWith.ts +109 -0
  71. package/src/{shared → runtime}/valueTypes.ts +0 -0
  72. package/src/types/FunctionType.ts +12 -2
  73. package/src/types/Mutable.ts +1 -1
  74. package/src/types/alphabetic/Url.ts +29 -0
  75. package/src/types/alphabetic/alpha-characters.ts +8 -0
  76. package/src/types/alphabetic/index.ts +1 -0
  77. package/src/types/dictionary/MapTo.ts +2 -2
  78. package/src/types/index.ts +2 -2
  79. package/src/types/lists/AfterFirst.ts +10 -0
  80. package/src/types/lists/First.ts +8 -0
  81. package/src/types/lists/FirstString.ts +4 -0
  82. package/src/types/lists/Split.ts +21 -0
  83. package/src/types/lists/index.ts +4 -0
  84. package/src/types/ruleset-types.ts +1 -1
  85. package/src/types/type-checks/EndsWith.ts +22 -0
  86. package/src/types/{TypeInfo → type-checks}/Extends.ts +0 -0
  87. package/src/types/{TypeInfo → type-checks}/Includes.ts +0 -0
  88. package/src/types/{TypeInfo → type-checks}/IsBooleanLiteral.ts +0 -0
  89. package/src/types/{TypeInfo → type-checks}/IsLiteral.ts +0 -0
  90. package/src/types/{TypeInfo → type-checks}/IsNumericLiteral.ts +0 -0
  91. package/src/types/{TypeInfo → type-checks}/IsScalar.ts +0 -0
  92. package/src/types/{TypeInfo → type-checks}/IsStringLiteral.ts +2 -6
  93. package/src/types/{TypeInfo → type-checks}/IsUndefined.ts +0 -0
  94. package/src/types/type-checks/StartsWith.ts +43 -0
  95. package/src/types/{TypeInfo → type-checks}/TypeDefault.ts +1 -1
  96. package/src/types/{TypeInfo → type-checks}/index.ts +4 -1
  97. package/src/types/{TypeInfo/IsObject.ts → type-checks/object.ts} +0 -0
  98. package/src/types/type-checks/string.ts +21 -0
  99. package/src/types/type-conversion/TupleToUnion.ts +1 -3
  100. package/tests/ExplicitFunction-spec.ts +1 -1
  101. package/tests/arrayToKeyLookup-spec.ts +1 -1
  102. package/tests/arrayToObject-spec.ts +1 -1
  103. package/tests/boolean-logic/boolean.spec.ts +1 -1
  104. package/tests/boolean-logic/filter.spec.ts +1 -1
  105. package/tests/defineType-spec.ts +1 -1
  106. package/tests/dictionary/Get.spec.ts +1 -1
  107. package/tests/dictionary/TypeDefault.test.ts +2 -2
  108. package/tests/dictionary/mapTo.test.ts +1 -1
  109. package/tests/dictionary/merge.test.ts +1 -1
  110. package/tests/dictionaryTransform-spec.ts +1 -1
  111. package/tests/ifTypeOf-spec.ts +3 -2
  112. package/tests/kv/dict-to-kv-and-back.spec.ts +2 -2
  113. package/tests/kv/entries-spec.ts +1 -1
  114. package/tests/kv/keys.spec.ts +1 -1
  115. package/tests/kv/kv-spec.ts +1 -1
  116. package/tests/lists/First.test.ts +43 -0
  117. package/tests/lists/Split.test.ts +29 -0
  118. package/tests/lists/asArray.test.ts +1 -1
  119. package/tests/lists/dictArr.test.ts +1 -1
  120. package/tests/literal-spec.ts +1 -1
  121. package/tests/{string-literals → literals}/AllCaps.spec.ts +0 -0
  122. package/tests/{string-literals → literals}/CamelCase.spec.ts +0 -0
  123. package/tests/{string-literals → literals}/Dasherize.spec.ts +0 -0
  124. package/tests/{string-literals → literals}/HasUppercase.spec.ts +0 -0
  125. package/tests/{string-literals → literals}/PascalCase.spec.ts +0 -0
  126. package/tests/{string-literals → literals}/SnakeCase.spec.ts +0 -0
  127. package/tests/literals/box.test.ts +77 -0
  128. package/tests/{string-literals → literals}/whitespace-capture.spec.ts +0 -0
  129. package/tests/mapValues-spec.ts +1 -1
  130. package/tests/runtime/condition.spec.ts +1 -1
  131. package/tests/runtime/if-is.spec.ts +158 -2
  132. package/tests/runtime/type.spec.ts +1 -1
  133. package/tests/strArrayToDict-spec.ts +1 -1
  134. package/tests/withValue.spec.ts +1 -1
  135. package/vitest.config.ts +2 -5
  136. package/src/Mutation/MutationFunction.ts +0 -26
  137. package/src/Mutation/MutationIdentity.ts +0 -36
  138. package/src/Mutation/index.ts +0 -14
  139. package/src/shared/README.md +0 -3
  140. package/src/shared/index.ts +0 -15
  141. package/src/shared/randomString.ts +0 -5
  142. package/src/shared/uuid.ts +0 -5
  143. package/src/types/First.ts +0 -4
  144. package/src/utility/modelling/index.ts +0 -12
  145. package/tests/MutationIdentity-spec.ts +0 -25
package/dist/index.mjs CHANGED
@@ -1,46 +1,3 @@
1
- // src/Mutation/MutationFunction.ts
2
- function createMutationFunction(state) {
3
- return (mutationIdentity) => {
4
- return mutationIdentity(state);
5
- };
6
- }
7
-
8
- // src/Mutation/MutationIdentity.ts
9
- function MutationIdentity() {
10
- return function(m) {
11
- return m;
12
- };
13
- }
14
-
15
- // src/shared/randomString.ts
16
- function randomString() {
17
- return Math.trunc((1 + Math.random()) * 65536).toString(16).slice(1);
18
- }
19
-
20
- // src/shared/uuid.ts
21
- function uuid() {
22
- return `${randomString()}${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}${randomString()}${randomString()}`;
23
- }
24
-
25
- // src/shared/valueTypes.ts
26
- var valueTypes = {
27
- string: ["", false],
28
- boolean: [true, false],
29
- number: [0, false],
30
- function: [() => "", false],
31
- object: [{}, false],
32
- array: (arr = []) => [arr, false],
33
- null: [null, false],
34
- symbol: [Symbol("type"), false],
35
- undefined: [void 0, false],
36
- true: [true, true],
37
- false: [false, true],
38
- literal: (v) => {
39
- return [v, true];
40
- },
41
- literalArray: (arr) => [arr, true]
42
- };
43
-
44
1
  // src/types/dictionary/MapTo.ts
45
2
  var MapCardinality = /* @__PURE__ */ ((MapCardinality2) => {
46
3
  MapCardinality2["OneToMany"] = "I -> O[]";
@@ -49,13 +6,13 @@ var MapCardinality = /* @__PURE__ */ ((MapCardinality2) => {
49
6
  return MapCardinality2;
50
7
  })(MapCardinality || {});
51
8
 
52
- // src/utility/keys.ts
9
+ // src/runtime/keys.ts
53
10
  function keys(obj, ...without) {
54
11
  const v = without.length > 0 ? Object.keys(obj).filter((k) => !without.includes(k)) : Object.keys(obj);
55
12
  return v;
56
13
  }
57
14
 
58
- // src/utility/createFnWithProps.ts
15
+ // src/runtime/createFnWithProps.ts
59
16
  function createFnWithProps(fn, props) {
60
17
  return (() => {
61
18
  let combined = fn;
@@ -80,19 +37,19 @@ function readonlyFnWithProps(fn, props) {
80
37
  return combined;
81
38
  }
82
39
 
83
- // src/utility/ruleset.ts
40
+ // src/runtime/ruleset.ts
84
41
  function ruleSet(defn) {
85
42
  return defn;
86
43
  }
87
44
 
88
- // src/utility/api/api.ts
45
+ // src/runtime/api/api.ts
89
46
  var api = (priv) => (pub) => {
90
47
  const surface = () => pub;
91
48
  surface.prototype.priv = () => priv;
92
49
  return surface;
93
50
  };
94
51
 
95
- // src/utility/boolean-logic/and.ts
52
+ // src/runtime/combinators/and.ts
96
53
  var and = (...ops) => {
97
54
  const fn = (...args) => {
98
55
  return [...ops].every((i) => i(...args));
@@ -100,7 +57,7 @@ var and = (...ops) => {
100
57
  return fn;
101
58
  };
102
59
 
103
- // src/utility/boolean-logic/or.ts
60
+ // src/runtime/combinators/or.ts
104
61
  var or = (...ops) => {
105
62
  const fn = (...args) => {
106
63
  return [...ops].some((i) => i(...args));
@@ -108,7 +65,7 @@ var or = (...ops) => {
108
65
  return fn;
109
66
  };
110
67
 
111
- // src/utility/boolean-logic/not.ts
68
+ // src/runtime/combinators/not.ts
112
69
  var not = (op) => {
113
70
  const fn = (...args) => {
114
71
  return !op(...args);
@@ -116,73 +73,17 @@ var not = (op) => {
116
73
  return fn;
117
74
  };
118
75
 
119
- // src/utility/runtime/condition.ts
76
+ // src/runtime/runtime/condition.ts
120
77
  var condition = (c, input) => {
121
78
  return c(input);
122
79
  };
123
80
 
124
- // src/utility/runtime/ifTypeOf.ts
125
- function runtimeExtendsCheck(val, base, narrow = false) {
126
- if (typeof val !== typeof base) {
127
- return false;
128
- }
129
- switch (typeof val) {
130
- case "boolean":
131
- case "string":
132
- case "number":
133
- case "symbol":
134
- case "bigint":
135
- return narrow ? val === base : true;
136
- case "undefined":
137
- return true;
138
- case "function":
139
- if (narrow) {
140
- throw new Error(`Use of narrowlyExtends with a function is not possible!`);
141
- }
142
- return true;
143
- case "object":
144
- if (val === null && base === null) {
145
- return true;
146
- } else {
147
- return keys(base).every(
148
- (i) => runtimeExtendsCheck(val[i], base[i], narrow)
149
- );
150
- }
151
- }
152
- }
153
- var ifTypeOf = (val) => ({
154
- extends: (base) => {
155
- const valid = runtimeExtendsCheck(val, base, false);
156
- const trueFalse = valid ? true : false;
157
- return {
158
- then: (then) => ({
159
- else: (elseVal) => {
160
- return valid ? typeof then === "undefined" ? val : then : elseVal;
161
- }
162
- }),
163
- else: (elseVal) => valid ? val : elseVal
164
- } && trueFalse;
165
- },
166
- narrowlyExtends: (base) => {
167
- const valid = runtimeExtendsCheck(val, base, true);
168
- const trueFalse = valid ? true : false;
169
- return {
170
- then: (then) => ({
171
- else: (elseVal) => {
172
- return valid ? typeof then === "undefined" ? val : then : elseVal;
173
- }
174
- }),
175
- else: (elseVal) => valid ? val : elseVal
176
- } && trueFalse;
177
- }
178
- });
179
-
180
- // src/utility/runtime/conditions/isArray.ts
81
+ // src/runtime/type-checks/isArray.ts
181
82
  function isArray(i) {
182
83
  return Array.isArray(i) === true;
183
84
  }
184
85
 
185
- // src/utility/runtime/conditions/isBoolean.ts
86
+ // src/runtime/type-checks/isBoolean.ts
186
87
  function isBoolean(i) {
187
88
  return typeof i === "boolean";
188
89
  }
@@ -190,17 +91,17 @@ function ifBoolean(val, ifVal, elseVal) {
190
91
  return isBoolean(val) ? ifVal : elseVal;
191
92
  }
192
93
 
193
- // src/utility/runtime/conditions/isFalse.ts
94
+ // src/runtime/type-checks/isFalse.ts
194
95
  function isFalse(i) {
195
96
  return typeof i === "boolean" && !i;
196
97
  }
197
98
 
198
- // src/utility/runtime/conditions/isFunction.ts
99
+ // src/runtime/type-checks/isFunction.ts
199
100
  function isFunction(input) {
200
- return typeof input === "function";
101
+ return typeof input === "function" ? true : false;
201
102
  }
202
103
 
203
- // src/utility/runtime/conditions/isNull.ts
104
+ // src/runtime/type-checks/isNull.ts
204
105
  function isNull(i) {
205
106
  return i === null;
206
107
  }
@@ -208,7 +109,7 @@ function ifNull(val, ifVal, elseVal) {
208
109
  return isNull(val) ? ifVal : elseVal;
209
110
  }
210
111
 
211
- // src/utility/runtime/conditions/isNumber.ts
112
+ // src/runtime/type-checks/isNumber.ts
212
113
  function isNumber(i) {
213
114
  return typeof i === "number";
214
115
  }
@@ -216,12 +117,12 @@ function ifNumber(val, ifVal, elseVal) {
216
117
  return isNumber(val) ? ifVal : elseVal;
217
118
  }
218
119
 
219
- // src/utility/runtime/conditions/isObject.ts
120
+ // src/runtime/type-checks/isObject.ts
220
121
  function isObject(i) {
221
122
  return typeof i === "object" && i !== null && Array.isArray(i) === false;
222
123
  }
223
124
 
224
- // src/utility/runtime/conditions/isString.ts
125
+ // src/runtime/type-checks/isString.ts
225
126
  function isString(i) {
226
127
  return typeof i === "string";
227
128
  }
@@ -229,12 +130,12 @@ function ifString(val, ifVal, elseVal) {
229
130
  return isString(val) ? ifVal : elseVal;
230
131
  }
231
132
 
232
- // src/utility/runtime/conditions/isSymbol.ts
133
+ // src/runtime/type-checks/isSymbol.ts
233
134
  function isSymbol(i) {
234
135
  return typeof i === "symbol";
235
136
  }
236
137
 
237
- // src/utility/runtime/conditions/isTrue.ts
138
+ // src/runtime/type-checks/isTrue.ts
238
139
  function isTrue(i) {
239
140
  return typeof i === "boolean" && i === true;
240
141
  }
@@ -242,7 +143,7 @@ function ifTrue(val, ifVal, elseVal) {
242
143
  return isTrue(val) ? ifVal : elseVal;
243
144
  }
244
145
 
245
- // src/utility/runtime/conditions/isUndefined.ts
146
+ // src/runtime/type-checks/isUndefined.ts
246
147
  function isUndefined(i) {
247
148
  return typeof i === "undefined";
248
149
  }
@@ -250,7 +151,7 @@ function ifUndefined(val, ifVal, elseVal) {
250
151
  return isUndefined(val) ? ifVal : elseVal;
251
152
  }
252
153
 
253
- // src/utility/runtime/type.ts
154
+ // src/runtime/runtime/type.ts
254
155
  var typeApi = () => ({
255
156
  string: {
256
157
  name: "string",
@@ -332,7 +233,7 @@ function type(fn) {
332
233
  return result;
333
234
  }
334
235
 
335
- // src/utility/dictionary/entries.ts
236
+ // src/runtime/dictionary/entries.ts
336
237
  function entries(obj) {
337
238
  const iterable = {
338
239
  *[Symbol.iterator]() {
@@ -344,7 +245,7 @@ function entries(obj) {
344
245
  return iterable;
345
246
  }
346
247
 
347
- // src/utility/runtime/withValue.ts
248
+ // src/runtime/runtime/withValue.ts
348
249
  function withValue(td) {
349
250
  return (obj) => {
350
251
  const t = type(td);
@@ -356,12 +257,12 @@ function withValue(td) {
356
257
  };
357
258
  }
358
259
 
359
- // src/utility/lists/asArray.ts
260
+ // src/runtime/lists/asArray.ts
360
261
  var asArray = (thing, _widen) => {
361
262
  return isArray(thing) ? thing : typeof thing === "undefined" ? [] : [thing];
362
263
  };
363
264
 
364
- // src/utility/boolean-logic/filter.ts
265
+ // src/runtime/combinators/filter.ts
365
266
  function isNotFilter(f) {
366
267
  return typeof f === "object" && "not" in f;
367
268
  }
@@ -397,15 +298,15 @@ var numericOps = (config, boolLogic) => {
397
298
  var stringOps = (config, boolLogic) => {
398
299
  const startsWith = (n) => {
399
300
  const f = asArray(n);
400
- return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.startsWith(i))];
301
+ return f.length === 0 ? [] : [(input) => f.some((i) => input?.startsWith(i))];
401
302
  };
402
303
  const endsWith = (n) => {
403
304
  const f = asArray(n);
404
- return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.endsWith(i))];
305
+ return f.length === 0 ? [] : [(input) => f.some((i) => input?.endsWith(i))];
405
306
  };
406
307
  const contains = (n) => {
407
308
  const f = asArray(n);
408
- return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.includes(i))];
309
+ return f.length === 0 ? [] : [(input) => f.some((i) => input?.includes(i))];
409
310
  };
410
311
  const conditions = [
411
312
  ..."startsWith" in config ? startsWith(config.startsWith) : [],
@@ -437,7 +338,7 @@ var filter = (config, logicCombinator = "AND", ifUndefined2 = "no-impact") => {
437
338
  return filterFn(config, logicCombinator, ifUndefined2);
438
339
  };
439
340
 
440
- // src/utility/dictionary/arrayToKeyLookup.ts
341
+ // src/runtime/dictionary/arrayToKeyLookup.ts
441
342
  function arrayToKeyLookup(...keys2) {
442
343
  const obj = {};
443
344
  for (const key of keys2) {
@@ -446,7 +347,7 @@ function arrayToKeyLookup(...keys2) {
446
347
  return obj;
447
348
  }
448
349
 
449
- // src/utility/dictionary/defineProperties.ts
350
+ // src/runtime/dictionary/defineProperties.ts
450
351
  function defineProperties(obj) {
451
352
  return {
452
353
  ro(prop, errorMsg) {
@@ -466,7 +367,7 @@ function defineProperties(obj) {
466
367
  };
467
368
  }
468
369
 
469
- // src/utility/dictionary/dictionaryTransform.ts
370
+ // src/runtime/dictionary/dictionaryTransform.ts
470
371
  function dictionaryTransform(input, transform) {
471
372
  return keys(input).reduce((acc, i) => {
472
373
  const key = i;
@@ -474,7 +375,7 @@ function dictionaryTransform(input, transform) {
474
375
  }, {});
475
376
  }
476
377
 
477
- // src/utility/dictionary/dictArr.ts
378
+ // src/runtime/dictionary/dictArr.ts
478
379
  var dictArr = (...dicts) => {
479
380
  const api2 = {
480
381
  length: dicts.length,
@@ -512,14 +413,14 @@ var dictArr = (...dicts) => {
512
413
  return api2;
513
414
  };
514
415
 
515
- // src/utility/dictionary/mapValues.ts
416
+ // src/runtime/dictionary/mapValues.ts
516
417
  function mapValues(obj, valueMapper) {
517
418
  return Object.fromEntries(
518
419
  [...entries(obj)].map(([k, v]) => [k, valueMapper(v)])
519
420
  );
520
421
  }
521
422
 
522
- // src/utility/dictionary/mapTo.ts
423
+ // src/runtime/dictionary/mapTo.ts
523
424
  var toFinalizedConfig = (config) => {
524
425
  return { ...config, finalized: true };
525
426
  };
@@ -584,10 +485,10 @@ var setMapper = (config = { input: void 0, output: void 0, cardinality: void 0 }
584
485
  };
585
486
  return mapper(c)(source);
586
487
  },
587
- input: (config == null ? void 0 : config.input) || defaultValue.input,
588
- output: (config == null ? void 0 : config.output) || defaultValue.output,
589
- cardinality: (config == null ? void 0 : config.cardinality) || defaultValue.cardinality,
590
- debug: (config == null ? void 0 : config.debug) || false
488
+ input: config?.input || defaultValue.input,
489
+ output: config?.output || defaultValue.output,
490
+ cardinality: config?.cardinality || defaultValue.cardinality,
491
+ debug: config?.debug || false
591
492
  });
592
493
  var mapToFn = (map) => {
593
494
  return mapper(DEFAULT_ONE_TO_MANY_MAPPING)(map);
@@ -612,7 +513,7 @@ var mapToDict = {
612
513
  };
613
514
  var mapTo = createFnWithProps(mapToFn, mapToDict);
614
515
 
615
- // src/utility/dictionary/strArrayToDict.ts
516
+ // src/runtime/dictionary/strArrayToDict.ts
616
517
  function strArrayToDict(...strings) {
617
518
  return strings.reduce((acc, str) => {
618
519
  acc = { ...acc, [str]: true };
@@ -620,14 +521,14 @@ function strArrayToDict(...strings) {
620
521
  }, {});
621
522
  }
622
523
 
623
- // src/utility/dictionary/kv/dictToKv.ts
524
+ // src/runtime/dictionary/kv/dictToKv.ts
624
525
  function dictToKv(obj, _makeTuple = false) {
625
526
  return keys(obj).map((k) => {
626
527
  return { key: k, value: obj[k] };
627
528
  });
628
529
  }
629
530
 
630
- // src/utility/state/Configurator.ts
531
+ // src/runtime/state/Configurator.ts
631
532
  function omit(obj, ...removals) {
632
533
  const untyped = removals;
633
534
  return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
@@ -657,7 +558,7 @@ function Configurator() {
657
558
  return api2();
658
559
  }
659
560
 
660
- // src/utility/state/FluentConfigurator.ts
561
+ // src/runtime/state/FluentConfigurator.ts
661
562
  function FluentConfigurator(initial = {}) {
662
563
  const api2 = (current) => {
663
564
  return {
@@ -679,7 +580,7 @@ function FluentConfigurator(initial = {}) {
679
580
  return initial ? api2(initial) : api2({});
680
581
  }
681
582
 
682
- // src/utility/dictionary/kv/filterDictArray.ts
583
+ // src/runtime/dictionary/kv/filterDictArray.ts
683
584
  function filterDictArray(dictArr2, cb) {
684
585
  const state = Configurator();
685
586
  const updated = dictArr2.filter((i) => {
@@ -693,12 +594,12 @@ function filterDictArray(dictArr2, cb) {
693
594
  return updated;
694
595
  }
695
596
 
696
- // src/utility/dictionary/kv/kv.ts
597
+ // src/runtime/dictionary/kv/kv.ts
697
598
  function kv(key, value) {
698
599
  return { [key]: value };
699
600
  }
700
601
 
701
- // src/utility/dictionary/kv/kvToDict.ts
602
+ // src/runtime/dictionary/kv/kvToDict.ts
702
603
  function kvToDict(kvArr) {
703
604
  const out = {};
704
605
  for (const kv2 of kvArr) {
@@ -707,17 +608,17 @@ function kvToDict(kvArr) {
707
608
  return out;
708
609
  }
709
610
 
710
- // src/utility/lists/groupBy.ts
611
+ // src/runtime/lists/groupBy.ts
711
612
  function groupBy(_data) {
712
613
  throw new Error("not implemented");
713
614
  }
714
615
 
715
- // src/utility/literals/ExplicitFunction.ts
616
+ // src/runtime/literals/ExplicitFunction.ts
716
617
  function ExplicitFunction(fn) {
717
618
  return fn;
718
619
  }
719
620
 
720
- // src/utility/literals/arrayToObject.ts
621
+ // src/runtime/literals/arrayToObject.ts
721
622
  function arrayToObject(prop, unique) {
722
623
  const transform = (arr) => {
723
624
  const result = unique !== false ? arr.reduce((acc, v) => ({ ...acc, [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
@@ -729,17 +630,33 @@ function arrayToObject(prop, unique) {
729
630
  return transform;
730
631
  }
731
632
 
732
- // src/utility/literals/defineType.ts
633
+ // src/runtime/literals/box.ts
634
+ function box(value) {
635
+ const rtn = {
636
+ __kind: "box",
637
+ value,
638
+ unbox: () => value
639
+ };
640
+ return rtn;
641
+ }
642
+ function isBox(thing) {
643
+ return typeof thing === "object" && "__kind" in thing && thing.__kind === "box";
644
+ }
645
+ function unbox(thing) {
646
+ return isBox(thing) ? thing.unbox() : thing;
647
+ }
648
+
649
+ // src/runtime/literals/defineType.ts
733
650
  function defineType(literal2 = {}) {
734
651
  return (wide = {}) => {
735
652
  return literal2 ? { ...wide, ...literal2 } : wide;
736
653
  };
737
654
  }
738
655
 
739
- // src/utility/literals/identity.ts
656
+ // src/runtime/literals/identity.ts
740
657
  var identity = (v) => v;
741
658
 
742
- // src/utility/literals/literal.ts
659
+ // src/runtime/literals/literal.ts
743
660
  function idLiteral(o) {
744
661
  return { ...o, id: o.id };
745
662
  }
@@ -755,24 +672,6 @@ function idTypeGuard(_o) {
755
672
  function literal(obj) {
756
673
  return obj;
757
674
  }
758
-
759
- // src/utility/modelling/Model.ts
760
- function Model(name) {
761
- return {
762
- required(_prop) {
763
- return Model(name);
764
- },
765
- optional(_prop) {
766
- return Model(name);
767
- },
768
- done() {
769
- return {
770
- __model__: name,
771
- __kind__: "model"
772
- };
773
- }
774
- };
775
- }
776
675
  export {
777
676
  Configurator,
778
677
  DEFAULT_MANY_TO_ONE_MAPPING,
@@ -781,16 +680,14 @@ export {
781
680
  ExplicitFunction,
782
681
  FluentConfigurator,
783
682
  MapCardinality,
784
- Model,
785
- MutationIdentity,
786
683
  and,
787
684
  api,
788
685
  arrayToKeyLookup,
789
686
  arrayToObject,
790
687
  asArray,
688
+ box,
791
689
  condition,
792
690
  createFnWithProps,
793
- createMutationFunction,
794
691
  defineProperties,
795
692
  defineType,
796
693
  dictArr,
@@ -809,10 +706,10 @@ export {
809
706
  ifNumber,
810
707
  ifString,
811
708
  ifTrue,
812
- ifTypeOf,
813
709
  ifUndefined,
814
710
  isArray,
815
711
  isBoolean,
712
+ isBox,
816
713
  isFalse,
817
714
  isFunction,
818
715
  isNotFilter,
@@ -837,13 +734,11 @@ export {
837
734
  nameLiteral,
838
735
  not,
839
736
  or,
840
- randomString,
841
737
  readonlyFnWithProps,
842
738
  ruleSet,
843
739
  strArrayToDict,
844
740
  type,
845
741
  typeApi,
846
- uuid,
847
- valueTypes,
742
+ unbox,
848
743
  withValue
849
744
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inferred-types",
3
- "version": "0.33.1",
3
+ "version": "0.33.3",
4
4
  "description": "Functions which provide useful type inference on TS projects",
5
5
  "license": "MIT",
6
6
  "author": "Ken Snyder<ken@ken.net>",
@@ -32,31 +32,32 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@type-challenges/utils": "~0.1.1",
35
- "@types/node": "^16.18.0",
36
- "@typescript-eslint/eslint-plugin": "^5.41.0",
37
- "@typescript-eslint/parser": "^5.41.0",
35
+ "@types/node": "^16.18.3",
36
+ "@typescript-eslint/eslint-plugin": "^5.45.0",
37
+ "@typescript-eslint/parser": "^5.45.0",
38
+ "@vitest/ui": "^0.25.3",
38
39
  "bumpp": "^8.2.1",
39
- "common-types": "^1.31.1",
40
+ "common-types": "^1.33.2",
40
41
  "cross-env": "^7.0.3",
41
- "dd": "^0.24.0",
42
+ "dd": "^0.25.4",
42
43
  "dotenv": "^16.0.3",
43
- "eslint": "^8.26.0",
44
+ "eslint": "^8.28.0",
44
45
  "eslint-config-prettier": "^8.5.0",
45
46
  "eslint-plugin-import": "^2.26.0",
46
47
  "eslint-plugin-prettier": "^4.2.1",
47
48
  "eslint-plugin-promise": "^6.1.1",
48
49
  "npm-run-all": "~4.1.5",
49
- "pathe": "^0.3.9",
50
- "prettier": "~2.7.1",
50
+ "pathe": "^1.0.0",
51
+ "prettier": "~2.8.0",
51
52
  "rimraf": "^3.0.2",
52
- "sharp": "^0.31.1",
53
- "tsup": "^6.3.0",
54
- "typescript": "^4.8.4",
55
- "vite": "^3.1.8",
56
- "vitest": "^0.24.3"
53
+ "sharp": "^0.31.2",
54
+ "tsup": "^6.5.0",
55
+ "typescript": "^4.9.3",
56
+ "vite": "^3.2.4",
57
+ "vitest": "^0.25.3"
57
58
  },
58
59
  "dependencies": {
59
- "brilliant-errors": "^0.6.0"
60
+ "brilliant-errors": "^0.6.1"
60
61
  },
61
62
  "pnpm": {
62
63
  "overrides": {
File without changes
package/src/index.ts CHANGED
@@ -5,10 +5,8 @@
5
5
  // hash-code: 5ddbbf55
6
6
 
7
7
  // directory exports
8
- export * from "./Mutation/index";
9
- export * from "./shared/index";
10
8
  export * from "./types/index";
11
- export * from "./utility/index";
9
+ export * from "./runtime/index";
12
10
 
13
11
  // #endregion auto-indexed files
14
12
 
File without changes
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ import { DomainName, Ipv4, NetworkProtocol, RelativeUrl } from "src/types";
2
+
3
+ export const url = <
4
+ Proto extends NetworkProtocol,
5
+ Site extends DomainName | Ipv4,
6
+ Path extends RelativeUrl
7
+ >(
8
+ ...args: [Proto, Site, Path]
9
+ ) => {
10
+ if (args.length === 3) {
11
+ return `${args[0]}://${args[1]}/${args[2]}`;
12
+ } else {
13
+ return args[0];
14
+ }
15
+ };
File without changes
File without changes
File without changes
File without changes