inferred-types 0.20.0 → 0.22.5

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 (161) hide show
  1. package/.eslintrc +36 -20
  2. package/.github/workflows/main.yml +34 -0
  3. package/.github/workflows/other.yml +15 -0
  4. package/.vscode/settings.json +10 -2
  5. package/dist/index.d.ts +426 -8547
  6. package/dist/index.js +57 -76
  7. package/dist/index.mjs +47 -63
  8. package/package.json +38 -26
  9. package/src/Mutation/index.ts +6 -29
  10. package/src/index.ts +6 -29
  11. package/src/shared/index.ts +6 -29
  12. package/src/shared/valueTypes.ts +1 -1
  13. package/src/types/ExpandRecursively.ts +10 -1
  14. package/src/types/Keys.ts +10 -6
  15. package/src/types/SimplifyObject.ts +12 -0
  16. package/src/types/Transformer.ts +1 -1
  17. package/src/types/alphabetic/CamelCase.ts +2 -2
  18. package/src/types/alphabetic/CapFirstAlpha.ts +7 -3
  19. package/src/types/alphabetic/Dasherize.ts +8 -5
  20. package/src/types/alphabetic/KebabCase.ts +1 -1
  21. package/src/types/alphabetic/PascalCase.ts +3 -1
  22. package/src/types/alphabetic/SnakeCase.ts +8 -3
  23. package/src/types/alphabetic/alpha-characters.ts +33 -9
  24. package/src/types/alphabetic/index.ts +6 -29
  25. package/src/types/dictionary/DictChangeValue.ts +26 -0
  26. package/src/types/dictionary/DictPartialApplication.ts +30 -0
  27. package/src/types/dictionary/DictPrependWithFn.ts +23 -0
  28. package/src/types/dictionary/DictReturnValues.ts +27 -0
  29. package/src/types/dictionary/MutableProps.ts +19 -0
  30. package/src/types/dictionary/RequireProps.ts +15 -0
  31. package/src/types/{type-conversion → dictionary}/SameKeys.ts +0 -0
  32. package/src/types/dictionary/index.ts +13 -30
  33. package/src/types/{props.ts → dictionary/props.ts} +2 -2
  34. package/src/types/fluent/index.ts +6 -29
  35. package/src/types/functions/FinalReturn.ts +12 -0
  36. package/src/types/functions/index.ts +12 -0
  37. package/src/types/index.ts +8 -30
  38. package/src/types/kv/index.ts +6 -29
  39. package/src/types/lists/index.ts +6 -29
  40. package/src/types/ruleset-types.ts +3 -3
  41. package/src/types/runtime.ts +18 -18
  42. package/src/types/string-literals/LeftWhitespace.ts +5 -2
  43. package/src/types/string-literals/RightWhitespace.ts +5 -2
  44. package/src/types/string-literals/index.ts +6 -29
  45. package/src/types/tuples/FirstKey.ts +3 -3
  46. package/src/types/tuples/FromDictArray.ts +5 -4
  47. package/src/types/tuples/index.ts +6 -29
  48. package/src/types/type-conversion/index.ts +6 -32
  49. package/src/utility/api/api.ts +8 -7
  50. package/src/utility/api/index.ts +6 -29
  51. package/src/utility/dictionary/defineProperties.ts +35 -0
  52. package/src/utility/dictionary/dictionaryTransform.ts +5 -4
  53. package/src/utility/dictionary/entries.ts +9 -5
  54. package/src/utility/dictionary/index.ts +7 -30
  55. package/src/utility/dictionary/kv/dictToKv.ts +5 -3
  56. package/src/utility/dictionary/kv/filterDictArray.ts +5 -7
  57. package/src/utility/dictionary/kv/index.ts +6 -29
  58. package/src/utility/dictionary/kv/kv.ts +8 -3
  59. package/src/utility/dictionary/kv/kvToDict.ts +3 -2
  60. package/src/utility/dictionary/mapValues.ts +8 -5
  61. package/src/utility/dictionary/strArrayToDict.ts +1 -2
  62. package/src/utility/errors/ReadOnlyViolation.ts +3 -0
  63. package/src/utility/errors/index.ts +12 -0
  64. package/src/utility/index.ts +7 -29
  65. package/src/utility/keys.ts +8 -4
  66. package/src/utility/lists/groupBy.ts +2 -9
  67. package/src/utility/lists/index.ts +6 -29
  68. package/src/utility/literals/arrayToObject.ts +29 -29
  69. package/src/utility/literals/defineType.ts +6 -6
  70. package/src/utility/literals/identity.ts +5 -2
  71. package/src/utility/literals/index.ts +6 -29
  72. package/src/utility/literals/literal.ts +3 -3
  73. package/src/utility/map-reduce/index.ts +6 -29
  74. package/src/utility/modelling/index.ts +6 -29
  75. package/src/utility/ruleset.ts +11 -9
  76. package/src/utility/runtime/condition.ts +1 -1
  77. package/src/utility/runtime/conditions/index.ts +6 -30
  78. package/src/utility/runtime/conditions/isFalse.ts +2 -2
  79. package/src/utility/runtime/conditions/isFunction.ts +2 -2
  80. package/src/utility/runtime/conditions/isObject.ts +4 -1
  81. package/src/utility/runtime/conditions/isTrue.ts +1 -1
  82. package/src/utility/runtime/ifTypeOf.ts +5 -4
  83. package/src/utility/runtime/index.ts +6 -29
  84. package/src/utility/runtime/type.ts +3 -1
  85. package/src/utility/runtime/withValue.ts +5 -3
  86. package/src/utility/state/Configurator.ts +2 -2
  87. package/src/utility/state/FluentConfigurator.ts +2 -2
  88. package/src/utility/state/index.ts +6 -30
  89. package/tests/CamelCase-spec.ts +2 -0
  90. package/tests/ExplicitFunction-spec.ts +3 -2
  91. package/tests/IncludeAndRetain-spec.ts +7 -12
  92. package/tests/Includes-spec.ts +2 -0
  93. package/tests/KebabCase-spec.ts +2 -0
  94. package/tests/MutationIdentity-spec.ts +2 -1
  95. package/tests/PascalCase-spec.ts +2 -0
  96. package/tests/Pluralize-spec.ts +2 -0
  97. package/tests/SnakeCase-spec.ts +2 -0
  98. package/tests/Where.spec.ts +9 -10
  99. package/tests/arrayToKeyLookup-spec.ts +5 -5
  100. package/tests/arrayToObject-spec.ts +12 -8
  101. package/tests/constructor.spec.ts +2 -0
  102. package/tests/createFnWithProps.spec.ts +2 -2
  103. package/tests/data/index.ts +6 -29
  104. package/tests/defineType-spec.ts +17 -11
  105. package/tests/dictionary/DictChangeValue.test.ts +30 -0
  106. package/tests/dictionary/DictPartialApplication.test.ts +43 -0
  107. package/tests/dictionary/DictReturnValues.test.ts +36 -0
  108. package/tests/dictionary/Get.spec.ts +5 -3
  109. package/tests/dictionary/MutableProps.test.ts +30 -0
  110. package/tests/dictionary/PrependValuesWithFunction.ts +34 -0
  111. package/tests/dictionary/RequireProps.test.ts +21 -0
  112. package/tests/dictionaryTransform-spec.ts +3 -3
  113. package/tests/ifTypeOf-spec.ts +31 -20
  114. package/tests/kv/KeyValue-spec.ts +4 -4
  115. package/tests/kv/SameKeys-spec.ts +6 -9
  116. package/tests/kv/dict-to-kv-and-back.spec.ts +5 -4
  117. package/tests/kv/entries-spec.ts +8 -9
  118. package/tests/kv/keys.spec.ts +9 -19
  119. package/tests/kv/kv-spec.ts +4 -4
  120. package/tests/lists/UniqueForProp.spec.ts +3 -1
  121. package/tests/literal-spec.ts +5 -3
  122. package/tests/mapValues-spec.ts +5 -3
  123. package/tests/props-spec.ts +3 -2
  124. package/tests/runtime/condition.spec.ts +2 -1
  125. package/tests/runtime/type.spec.ts +4 -3
  126. package/tests/strArrayToDict-spec.ts +6 -6
  127. package/tests/string-literals/AllCaps.spec.ts +6 -15
  128. package/tests/string-literals/CamelCase.spec.ts +13 -32
  129. package/tests/string-literals/Dasherize.spec.ts +13 -31
  130. package/tests/string-literals/HasUppercase.spec.ts +6 -15
  131. package/tests/string-literals/PascalCase.spec.ts +13 -32
  132. package/tests/string-literals/SnakeCase.spec.ts +13 -32
  133. package/tests/string-literals/whitespace-capture.spec.ts +10 -28
  134. package/tests/tuples/TupleToUnion.spec.ts +3 -1
  135. package/tests/withValue.spec.ts +4 -3
  136. package/tsconfig.json +8 -19
  137. package/vitest.config.ts +13 -0
  138. package/jest.config.ts +0 -20
  139. package/on-hold/Builder/Builder.ts +0 -66
  140. package/on-hold/Builder/BuilderApi.ts +0 -21
  141. package/on-hold/Builder/IdentityToMutationApi.ts +0 -44
  142. package/on-hold/Builder/MutationToFluentApi.ts +0 -60
  143. package/on-hold/Builder/index.ts +0 -35
  144. package/on-hold/tests/Builder-spec.ts +0 -310
  145. package/on-hold/tests/RuleSet-spec.ts +0 -59
  146. package/on-hold/tests/ToFluent-spec.ts +0 -60
  147. package/on-hold/tests/api-spec.ts +0 -73
  148. package/on-hold/tests/data/builder-data.ts +0 -53
  149. package/on-hold/tests/filterDictArray-spec.ts +0 -50
  150. package/on-hold/tests/run-time-spec.ts +0 -44
  151. package/on-hold/type.ts +0 -20
  152. package/on-hold/types/index.ts +0 -34
  153. package/on-hold/types/object.ts +0 -19
  154. package/on-hold/types/prop.ts +0 -28
  155. package/on-hold/types/scalar.ts +0 -37
  156. package/src/types/dictionary/NotEmptyObject.ts +0 -9
  157. package/src/types/type-conversion/UnwrapValue.ts +0 -13
  158. package/src/types/type-conversion/WrapValue.ts +0 -15
  159. package/src/utility/dictionary/valuesOfProp.ts +0 -13
  160. package/src/utility/runtime/conditions/isLiteral.ts +0 -7
  161. package/src/utility/state/KeyStorage.ts +0 -23
package/dist/index.js CHANGED
@@ -1,42 +1,21 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
5
  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
6
  var __export = (target, all) => {
24
7
  for (var name in all)
25
8
  __defProp(target, name, { get: all[name], enumerable: true });
26
9
  };
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 });
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
15
  }
33
- return target;
16
+ return to;
34
17
  };
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);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
19
 
41
20
  // src/index.ts
42
21
  var src_exports = {};
@@ -44,7 +23,6 @@ __export(src_exports, {
44
23
  Configurator: () => Configurator,
45
24
  ExplicitFunction: () => ExplicitFunction,
46
25
  FluentConfigurator: () => FluentConfigurator,
47
- KeyStorage: () => KeyStorage,
48
26
  Model: () => Model,
49
27
  MutationIdentity: () => MutationIdentity,
50
28
  and: () => and,
@@ -54,6 +32,7 @@ __export(src_exports, {
54
32
  condition: () => condition,
55
33
  createFnWithProps: () => createFnWithProps,
56
34
  createMutationFunction: () => createMutationFunction,
35
+ defineProperties: () => defineProperties,
57
36
  defineType: () => defineType,
58
37
  dictToKv: () => dictToKv,
59
38
  dictionaryTransform: () => dictionaryTransform,
@@ -71,7 +50,6 @@ __export(src_exports, {
71
50
  isBoolean: () => isBoolean,
72
51
  isFalse: () => isFalse,
73
52
  isFunction: () => isFunction,
74
- isLiteral: () => isLiteral,
75
53
  isNull: () => isNull,
76
54
  isNumber: () => isNumber,
77
55
  isObject: () => isObject,
@@ -97,9 +75,9 @@ __export(src_exports, {
97
75
  typeApi: () => typeApi,
98
76
  uuid: () => uuid,
99
77
  valueTypes: () => valueTypes,
100
- valuesOfProp: () => valuesOfProp,
101
78
  withValue: () => withValue
102
79
  });
80
+ module.exports = __toCommonJS(src_exports);
103
81
 
104
82
  // src/Mutation/MutationFunction.ts
105
83
  function createMutationFunction(state) {
@@ -196,11 +174,31 @@ function arrayToKeyLookup(...keys2) {
196
174
  return obj;
197
175
  }
198
176
 
177
+ // src/utility/dictionary/defineProperties.ts
178
+ function defineProperties(obj) {
179
+ return {
180
+ ro(prop, errorMsg) {
181
+ Object.defineProperty(obj, prop, {
182
+ writable: false,
183
+ set(v) {
184
+ const message = errorMsg ? errorMsg(prop, v) : `The ${String(
185
+ prop
186
+ )} is readonly but an attempt was made to change it's value to "${JSON.stringify(
187
+ v
188
+ )}"!`;
189
+ throw new Error(message);
190
+ }
191
+ });
192
+ return obj;
193
+ }
194
+ };
195
+ }
196
+
199
197
  // src/utility/dictionary/dictionaryTransform.ts
200
198
  function dictionaryTransform(input, transform) {
201
199
  return keys(input).reduce((acc, i) => {
202
200
  const key = i;
203
- return __spreadProps(__spreadValues({}, acc), { [key]: transform(input, key) });
201
+ return { ...acc, [key]: transform(input, key) };
204
202
  }, {});
205
203
  }
206
204
 
@@ -218,21 +216,19 @@ function entries(obj) {
218
216
 
219
217
  // src/utility/dictionary/mapValues.ts
220
218
  function mapValues(obj, valueMapper) {
221
- return Object.fromEntries([...entries(obj)].map(([k, v]) => [k, valueMapper(v)]));
219
+ return Object.fromEntries(
220
+ [...entries(obj)].map(([k, v]) => [k, valueMapper(v)])
221
+ );
222
222
  }
223
223
 
224
224
  // src/utility/dictionary/strArrayToDict.ts
225
225
  function strArrayToDict(...strings) {
226
226
  return strings.reduce((acc, str) => {
227
- acc = __spreadProps(__spreadValues({}, acc), { [str]: true });
227
+ acc = { ...acc, [str]: true };
228
228
  return acc;
229
229
  }, {});
230
230
  }
231
231
 
232
- // src/utility/dictionary/valuesOfProp.ts
233
- function valuesOfProp() {
234
- }
235
-
236
232
  // src/utility/dictionary/kv/dictToKv.ts
237
233
  function dictToKv(obj, _makeTuple = false) {
238
234
  return keys(obj).map((k) => {
@@ -252,7 +248,7 @@ function Configurator() {
252
248
  set(key, value) {
253
249
  const keyValue = { [key]: value };
254
250
  const config = configuration();
255
- const updated = __spreadValues(__spreadValues({}, config), keyValue);
251
+ const updated = { ...config, ...keyValue };
256
252
  configuration = () => updated;
257
253
  return updated;
258
254
  },
@@ -276,7 +272,7 @@ function FluentConfigurator(initial = {}) {
276
272
  return {
277
273
  set(key, value) {
278
274
  const keyValue = { [key]: value };
279
- const updated = __spreadValues(__spreadValues({}, keyValue), current);
275
+ const updated = { ...keyValue, ...current };
280
276
  return api2(updated);
281
277
  },
282
278
  done() {
@@ -285,23 +281,13 @@ function FluentConfigurator(initial = {}) {
285
281
  };
286
282
  };
287
283
  if (initial && typeof initial !== "object") {
288
- throw new Error("The FluentConfigurator was passed a non-object based value as the initial value. This is not allowed.");
284
+ throw new Error(
285
+ "The FluentConfigurator was passed a non-object based value as the initial value. This is not allowed."
286
+ );
289
287
  }
290
288
  return initial ? api2(initial) : api2({});
291
289
  }
292
290
 
293
- // src/utility/state/KeyStorage.ts
294
- function KeyStorage() {
295
- const api2 = (state) => ({
296
- add: (...store) => {
297
- return api2([...state, ...store]);
298
- },
299
- remove: (key) => api2(state.filter((i) => i !== key)),
300
- done: () => state
301
- });
302
- return api2([]);
303
- }
304
-
305
291
  // src/utility/dictionary/kv/filterDictArray.ts
306
292
  function filterDictArray(dictArr, cb) {
307
293
  const state = Configurator();
@@ -333,8 +319,6 @@ function kvToDict(kvArr) {
333
319
  // src/utility/lists/groupBy.ts
334
320
  function groupBy(_data) {
335
321
  throw new Error("not implemented");
336
- return (_groupBy) => {
337
- };
338
322
  }
339
323
 
340
324
  // src/utility/literals/ExplicitFunction.ts
@@ -345,9 +329,9 @@ function ExplicitFunction(fn) {
345
329
  // src/utility/literals/arrayToObject.ts
346
330
  function arrayToObject(prop, unique) {
347
331
  const transform = (arr) => {
348
- const result = unique !== false ? arr.reduce((acc, v) => __spreadProps(__spreadValues({}, acc), { [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
332
+ const result = unique !== false ? arr.reduce((acc, v) => ({ ...acc, [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
349
333
  const existing = acc[v[prop]] || [];
350
- return __spreadProps(__spreadValues({}, acc), { [v[prop]]: [...existing, v] });
334
+ return { ...acc, [v[prop]]: [...existing, v] };
351
335
  }, {});
352
336
  return result;
353
337
  };
@@ -357,7 +341,7 @@ function arrayToObject(prop, unique) {
357
341
  // src/utility/literals/defineType.ts
358
342
  function defineType(literal2 = {}) {
359
343
  return (wide = {}) => {
360
- return literal2 ? __spreadValues(__spreadValues({}, wide), literal2) : wide;
344
+ return literal2 ? { ...wide, ...literal2 } : wide;
361
345
  };
362
346
  }
363
347
 
@@ -366,7 +350,7 @@ var identity = (v) => v;
366
350
 
367
351
  // src/utility/literals/literal.ts
368
352
  function idLiteral(o) {
369
- return __spreadProps(__spreadValues({}, o), { id: o.id });
353
+ return { ...o, id: o.id };
370
354
  }
371
355
  function nameLiteral(o) {
372
356
  return o;
@@ -453,8 +437,11 @@ function runtimeExtendsCheck(val, base, narrow = false) {
453
437
  case "object":
454
438
  if (val === null && base === null) {
455
439
  return true;
440
+ } else {
441
+ return keys(base).every(
442
+ (i) => runtimeExtendsCheck(val[i], base[i], narrow)
443
+ );
456
444
  }
457
- return keys(base).every((i) => runtimeExtendsCheck(val[i], base[i], narrow));
458
445
  }
459
446
  }
460
447
  var ifTypeOf = (val) => ({
@@ -504,13 +491,6 @@ function isFunction(input) {
504
491
  return typeof input === "function";
505
492
  }
506
493
 
507
- // src/utility/runtime/conditions/isLiteral.ts
508
- function isLiteral(...allowed) {
509
- return (i) => {
510
- return !allowed.every((v) => i !== v);
511
- };
512
- }
513
-
514
494
  // src/utility/runtime/conditions/isNull.ts
515
495
  function isNull(i) {
516
496
  return i === null;
@@ -621,7 +601,9 @@ function isType(t) {
621
601
  function type(fn) {
622
602
  const result = fn(typeApi());
623
603
  if (!isType(result)) {
624
- throw new Error(`When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`);
604
+ throw new Error(
605
+ `When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`
606
+ );
625
607
  }
626
608
  return result;
627
609
  }
@@ -630,18 +612,18 @@ function type(fn) {
630
612
  function withValue(td) {
631
613
  return (obj) => {
632
614
  const t = type(td);
633
- return Object.fromEntries([...entries(obj)].filter(([_key, value]) => {
634
- return t.typeGuard(value);
635
- }));
615
+ return Object.fromEntries(
616
+ [...entries(obj)].filter(([_key, value]) => {
617
+ return t.typeGuard(value);
618
+ })
619
+ );
636
620
  };
637
621
  }
638
- module.exports = __toCommonJS(src_exports);
639
622
  // Annotate the CommonJS export names for ESM import in node:
640
623
  0 && (module.exports = {
641
624
  Configurator,
642
625
  ExplicitFunction,
643
626
  FluentConfigurator,
644
- KeyStorage,
645
627
  Model,
646
628
  MutationIdentity,
647
629
  and,
@@ -651,6 +633,7 @@ module.exports = __toCommonJS(src_exports);
651
633
  condition,
652
634
  createFnWithProps,
653
635
  createMutationFunction,
636
+ defineProperties,
654
637
  defineType,
655
638
  dictToKv,
656
639
  dictionaryTransform,
@@ -668,7 +651,6 @@ module.exports = __toCommonJS(src_exports);
668
651
  isBoolean,
669
652
  isFalse,
670
653
  isFunction,
671
- isLiteral,
672
654
  isNull,
673
655
  isNumber,
674
656
  isObject,
@@ -694,6 +676,5 @@ module.exports = __toCommonJS(src_exports);
694
676
  typeApi,
695
677
  uuid,
696
678
  valueTypes,
697
- valuesOfProp,
698
679
  withValue
699
680
  });
package/dist/index.mjs CHANGED
@@ -1,23 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
-
21
1
  // src/Mutation/MutationFunction.ts
22
2
  function createMutationFunction(state) {
23
3
  return (mutationIdentity) => {
@@ -113,11 +93,31 @@ function arrayToKeyLookup(...keys2) {
113
93
  return obj;
114
94
  }
115
95
 
96
+ // src/utility/dictionary/defineProperties.ts
97
+ function defineProperties(obj) {
98
+ return {
99
+ ro(prop, errorMsg) {
100
+ Object.defineProperty(obj, prop, {
101
+ writable: false,
102
+ set(v) {
103
+ const message = errorMsg ? errorMsg(prop, v) : `The ${String(
104
+ prop
105
+ )} is readonly but an attempt was made to change it's value to "${JSON.stringify(
106
+ v
107
+ )}"!`;
108
+ throw new Error(message);
109
+ }
110
+ });
111
+ return obj;
112
+ }
113
+ };
114
+ }
115
+
116
116
  // src/utility/dictionary/dictionaryTransform.ts
117
117
  function dictionaryTransform(input, transform) {
118
118
  return keys(input).reduce((acc, i) => {
119
119
  const key = i;
120
- return __spreadProps(__spreadValues({}, acc), { [key]: transform(input, key) });
120
+ return { ...acc, [key]: transform(input, key) };
121
121
  }, {});
122
122
  }
123
123
 
@@ -135,21 +135,19 @@ function entries(obj) {
135
135
 
136
136
  // src/utility/dictionary/mapValues.ts
137
137
  function mapValues(obj, valueMapper) {
138
- return Object.fromEntries([...entries(obj)].map(([k, v]) => [k, valueMapper(v)]));
138
+ return Object.fromEntries(
139
+ [...entries(obj)].map(([k, v]) => [k, valueMapper(v)])
140
+ );
139
141
  }
140
142
 
141
143
  // src/utility/dictionary/strArrayToDict.ts
142
144
  function strArrayToDict(...strings) {
143
145
  return strings.reduce((acc, str) => {
144
- acc = __spreadProps(__spreadValues({}, acc), { [str]: true });
146
+ acc = { ...acc, [str]: true };
145
147
  return acc;
146
148
  }, {});
147
149
  }
148
150
 
149
- // src/utility/dictionary/valuesOfProp.ts
150
- function valuesOfProp() {
151
- }
152
-
153
151
  // src/utility/dictionary/kv/dictToKv.ts
154
152
  function dictToKv(obj, _makeTuple = false) {
155
153
  return keys(obj).map((k) => {
@@ -169,7 +167,7 @@ function Configurator() {
169
167
  set(key, value) {
170
168
  const keyValue = { [key]: value };
171
169
  const config = configuration();
172
- const updated = __spreadValues(__spreadValues({}, config), keyValue);
170
+ const updated = { ...config, ...keyValue };
173
171
  configuration = () => updated;
174
172
  return updated;
175
173
  },
@@ -193,7 +191,7 @@ function FluentConfigurator(initial = {}) {
193
191
  return {
194
192
  set(key, value) {
195
193
  const keyValue = { [key]: value };
196
- const updated = __spreadValues(__spreadValues({}, keyValue), current);
194
+ const updated = { ...keyValue, ...current };
197
195
  return api2(updated);
198
196
  },
199
197
  done() {
@@ -202,23 +200,13 @@ function FluentConfigurator(initial = {}) {
202
200
  };
203
201
  };
204
202
  if (initial && typeof initial !== "object") {
205
- throw new Error("The FluentConfigurator was passed a non-object based value as the initial value. This is not allowed.");
203
+ throw new Error(
204
+ "The FluentConfigurator was passed a non-object based value as the initial value. This is not allowed."
205
+ );
206
206
  }
207
207
  return initial ? api2(initial) : api2({});
208
208
  }
209
209
 
210
- // src/utility/state/KeyStorage.ts
211
- function KeyStorage() {
212
- const api2 = (state) => ({
213
- add: (...store) => {
214
- return api2([...state, ...store]);
215
- },
216
- remove: (key) => api2(state.filter((i) => i !== key)),
217
- done: () => state
218
- });
219
- return api2([]);
220
- }
221
-
222
210
  // src/utility/dictionary/kv/filterDictArray.ts
223
211
  function filterDictArray(dictArr, cb) {
224
212
  const state = Configurator();
@@ -250,8 +238,6 @@ function kvToDict(kvArr) {
250
238
  // src/utility/lists/groupBy.ts
251
239
  function groupBy(_data) {
252
240
  throw new Error("not implemented");
253
- return (_groupBy) => {
254
- };
255
241
  }
256
242
 
257
243
  // src/utility/literals/ExplicitFunction.ts
@@ -262,9 +248,9 @@ function ExplicitFunction(fn) {
262
248
  // src/utility/literals/arrayToObject.ts
263
249
  function arrayToObject(prop, unique) {
264
250
  const transform = (arr) => {
265
- const result = unique !== false ? arr.reduce((acc, v) => __spreadProps(__spreadValues({}, acc), { [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
251
+ const result = unique !== false ? arr.reduce((acc, v) => ({ ...acc, [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
266
252
  const existing = acc[v[prop]] || [];
267
- return __spreadProps(__spreadValues({}, acc), { [v[prop]]: [...existing, v] });
253
+ return { ...acc, [v[prop]]: [...existing, v] };
268
254
  }, {});
269
255
  return result;
270
256
  };
@@ -274,7 +260,7 @@ function arrayToObject(prop, unique) {
274
260
  // src/utility/literals/defineType.ts
275
261
  function defineType(literal2 = {}) {
276
262
  return (wide = {}) => {
277
- return literal2 ? __spreadValues(__spreadValues({}, wide), literal2) : wide;
263
+ return literal2 ? { ...wide, ...literal2 } : wide;
278
264
  };
279
265
  }
280
266
 
@@ -283,7 +269,7 @@ var identity = (v) => v;
283
269
 
284
270
  // src/utility/literals/literal.ts
285
271
  function idLiteral(o) {
286
- return __spreadProps(__spreadValues({}, o), { id: o.id });
272
+ return { ...o, id: o.id };
287
273
  }
288
274
  function nameLiteral(o) {
289
275
  return o;
@@ -370,8 +356,11 @@ function runtimeExtendsCheck(val, base, narrow = false) {
370
356
  case "object":
371
357
  if (val === null && base === null) {
372
358
  return true;
359
+ } else {
360
+ return keys(base).every(
361
+ (i) => runtimeExtendsCheck(val[i], base[i], narrow)
362
+ );
373
363
  }
374
- return keys(base).every((i) => runtimeExtendsCheck(val[i], base[i], narrow));
375
364
  }
376
365
  }
377
366
  var ifTypeOf = (val) => ({
@@ -421,13 +410,6 @@ function isFunction(input) {
421
410
  return typeof input === "function";
422
411
  }
423
412
 
424
- // src/utility/runtime/conditions/isLiteral.ts
425
- function isLiteral(...allowed) {
426
- return (i) => {
427
- return !allowed.every((v) => i !== v);
428
- };
429
- }
430
-
431
413
  // src/utility/runtime/conditions/isNull.ts
432
414
  function isNull(i) {
433
415
  return i === null;
@@ -538,7 +520,9 @@ function isType(t) {
538
520
  function type(fn) {
539
521
  const result = fn(typeApi());
540
522
  if (!isType(result)) {
541
- throw new Error(`When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`);
523
+ throw new Error(
524
+ `When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`
525
+ );
542
526
  }
543
527
  return result;
544
528
  }
@@ -547,16 +531,17 @@ function type(fn) {
547
531
  function withValue(td) {
548
532
  return (obj) => {
549
533
  const t = type(td);
550
- return Object.fromEntries([...entries(obj)].filter(([_key, value]) => {
551
- return t.typeGuard(value);
552
- }));
534
+ return Object.fromEntries(
535
+ [...entries(obj)].filter(([_key, value]) => {
536
+ return t.typeGuard(value);
537
+ })
538
+ );
553
539
  };
554
540
  }
555
541
  export {
556
542
  Configurator,
557
543
  ExplicitFunction,
558
544
  FluentConfigurator,
559
- KeyStorage,
560
545
  Model,
561
546
  MutationIdentity,
562
547
  and,
@@ -566,6 +551,7 @@ export {
566
551
  condition,
567
552
  createFnWithProps,
568
553
  createMutationFunction,
554
+ defineProperties,
569
555
  defineType,
570
556
  dictToKv,
571
557
  dictionaryTransform,
@@ -583,7 +569,6 @@ export {
583
569
  isBoolean,
584
570
  isFalse,
585
571
  isFunction,
586
- isLiteral,
587
572
  isNull,
588
573
  isNumber,
589
574
  isObject,
@@ -609,6 +594,5 @@ export {
609
594
  typeApi,
610
595
  uuid,
611
596
  valueTypes,
612
- valuesOfProp,
613
597
  withValue
614
598
  };
package/package.json CHANGED
@@ -1,54 +1,66 @@
1
1
  {
2
2
  "name": "inferred-types",
3
- "version": "0.20.0",
3
+ "version": "0.22.5",
4
4
  "description": "Functions which provide useful type inference on TS projects",
5
5
  "license": "MIT",
6
6
  "author": "Ken Snyder<ken@ken.net>",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.mjs",
9
9
  "typings": "dist/index.d.ts",
10
+ "repository": {
11
+ "url": "https://github.com/inocan-group/inferred-types"
12
+ },
10
13
  "sideEffects": false,
11
14
  "scripts": {
12
15
  "about": "tokei src",
13
16
  "autoindex": "npx dd autoindex",
14
17
  "build": "run-s clean autoindex lint build:bundle",
15
18
  "build:force": "run-s clean autoindex build:bundle",
16
- "build:bundle": "npx tsup src/index.ts --dts --format='esm,cjs'",
19
+ "build:bundle": "npx tsup src/index.ts --dts --format=esm,cjs --clean",
17
20
  "watch": "run-p watch:*",
18
21
  "watch:autoindex": "npx dd autoindex --watch",
19
- "watch:bundle": "npx tsup src/index.ts --dts --format='esm,cjs' --watch",
22
+ "watch:bundle": "npx tsup src/index.ts --dts --format=esm,cjs --watch",
20
23
  "clean": "rimraf dist/**/*",
21
24
  "lint": "eslint src/**/*.ts --fix && tsc --noEmit ",
22
25
  "lint:full": "eslint src/**/*.ts && eslint test/**/*.ts && tsc --noEmit",
23
- "test": "jest"
26
+ "test": "vitest",
27
+ "test:ci": "vitest run",
28
+ "audit:fix": "pnpm audit --fix",
29
+ "release": "run-s lint release:latest test:ci audit:fix release:bump",
30
+ "release:latest": "pnpm install",
31
+ "release:bump": "bumpp"
24
32
  },
25
33
  "devDependencies": {
26
34
  "@type-challenges/utils": "~0.1.1",
27
- "@types/jest": "^27.4.0",
28
- "@types/node": "^14.18.5",
29
- "@typescript-eslint/eslint-plugin": "^5.9.1",
30
- "@typescript-eslint/parser": "^5.9.1",
31
- "common-types": "^1.30.0",
35
+ "@types/node": "16",
36
+ "@typescript-eslint/eslint-plugin": "^5.40.1",
37
+ "@typescript-eslint/parser": "^5.40.1",
38
+ "bumpp": "^8.2.1",
39
+ "common-types": "^1.31.1",
32
40
  "cross-env": "^7.0.3",
33
- "dd": "^0.18.0",
34
- "dotenv": "^10.0.0",
35
- "eslint": "^8.6.0",
36
- "eslint-config-prettier": "^8.3.0",
37
- "eslint-plugin-import": "^2.25.4",
38
- "eslint-plugin-prettier": "^4.0.0",
39
- "eslint-plugin-promise": "^6.0.0",
40
- "eslint-plugin-unicorn": "^40.0.0",
41
- "jest": "^27.4.7",
42
- "jest-extended": "~1.2.0",
41
+ "dd": "^0.24.0",
42
+ "dotenv": "^16.0.3",
43
+ "eslint": "^8.25.0",
44
+ "eslint-config-prettier": "^8.5.0",
45
+ "eslint-plugin-import": "^2.26.0",
46
+ "eslint-plugin-prettier": "^4.2.1",
47
+ "eslint-plugin-promise": "^6.1.0",
43
48
  "npm-run-all": "~4.1.5",
44
- "prettier": "~2.5.1",
49
+ "prettier": "~2.7.1",
45
50
  "rimraf": "^3.0.2",
46
- "ts-jest": "^27.1.2",
47
- "ts-node": "^10.4.0",
48
- "tsup": "^5.11.11",
49
- "typescript": "^4.5.4"
51
+ "sharp": "^0.31.1",
52
+ "tsup": "^6.3.0",
53
+ "typescript": "^4.8.4",
54
+ "vite": "^3.1.8",
55
+ "vitest": "^0.24.3"
50
56
  },
51
57
  "dependencies": {
52
- "common-types": "^1.31.0"
58
+ "brilliant-errors": "^0.6.0"
59
+ },
60
+ "pnpm": {
61
+ "overrides": {
62
+ "simple-git@<3.3.0": ">=3.3.0",
63
+ "simple-git@<3.5.0": ">=3.5.0"
64
+ }
53
65
  }
54
- }
66
+ }
@@ -1,37 +1,14 @@
1
1
  // #autoindex
2
2
 
3
- // #region autoindexed files
4
- // index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
5
- // hash-code: f6badae2
3
+ // #region auto-indexed files
4
+ // index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
5
+ // hash-code: bd3a442e
6
6
 
7
7
  // file exports
8
8
  export * from "./MutationFunction";
9
9
  export * from "./MutationIdentity";
10
10
 
11
- // #endregion
11
+ // #endregion auto-indexed files
12
12
 
13
- // This file was created by running: "dd autoindex"; it assumes you have
14
- // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
15
- //
16
- // By default it assumes that exports are named exports but this can be changed by
17
- // adding a modifier to the '// #autoindex' syntax:
18
- //
19
- // - autoindex:named same as default, exports "named symbols"
20
- // - autoindex:default assumes each file is exporting a default export and
21
- // converts the default export to the name of the file
22
- // - autoindex:offset assumes files export "named symbols" but that each
23
- // file's symbols should be offset by the file's name
24
- //
25
- // You may also exclude certain files or directories by adding it to the
26
- // autoindex command. As an example:
27
- //
28
- // - autoindex:named, exclude: foo,bar,baz
29
- //
30
- // Inversely, if you state a file to be an "orphan" then autoindex files
31
- // below this file will not reference this autoindex file:
32
- //
33
- // - autoindex:named, orphan
34
- //
35
- // All content outside the "// #region" section in this file will be
36
- // preserved in situations where you need to do something paricularly awesome.
37
- // Keep on being awesome.
13
+ // see https://github.com/inocan-group/do-devops/docs/autoindex.md
14
+ // for more info