@contractspec/lib.utils-typescript 0.0.0-canary-20260113162409

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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -0
  3. package/dist/index.d.ts +32 -0
  4. package/dist/index.js +3 -0
  5. package/dist/lib/AwaitedResult.d.ts +5 -0
  6. package/dist/lib/AwaitedResult.d.ts.map +1 -0
  7. package/dist/lib/AwaitedResult.js +0 -0
  8. package/dist/lib/BrowserNativeObject.d.ts +5 -0
  9. package/dist/lib/BrowserNativeObject.d.ts.map +1 -0
  10. package/dist/lib/BrowserNativeObject.js +0 -0
  11. package/dist/lib/DeepInfiniteArray.d.ts +5 -0
  12. package/dist/lib/DeepInfiniteArray.d.ts.map +1 -0
  13. package/dist/lib/DeepInfiniteArray.js +0 -0
  14. package/dist/lib/DeepKeepOnly.d.ts +7 -0
  15. package/dist/lib/DeepKeepOnly.d.ts.map +1 -0
  16. package/dist/lib/DeepKeepOnly.js +0 -0
  17. package/dist/lib/DeepKey.d.ts +5 -0
  18. package/dist/lib/DeepKey.d.ts.map +1 -0
  19. package/dist/lib/DeepKey.js +0 -0
  20. package/dist/lib/DeepMap.d.ts +10 -0
  21. package/dist/lib/DeepMap.d.ts.map +1 -0
  22. package/dist/lib/DeepMap.js +0 -0
  23. package/dist/lib/DeepNullable.d.ts +7 -0
  24. package/dist/lib/DeepNullable.d.ts.map +1 -0
  25. package/dist/lib/DeepNullable.js +0 -0
  26. package/dist/lib/DeepOr.d.ts +5 -0
  27. package/dist/lib/DeepOr.d.ts.map +1 -0
  28. package/dist/lib/DeepOr.js +0 -0
  29. package/dist/lib/DeepPartial.d.ts +8 -0
  30. package/dist/lib/DeepPartial.d.ts.map +1 -0
  31. package/dist/lib/DeepPartial.js +0 -0
  32. package/dist/lib/DeepReplace.d.ts +5 -0
  33. package/dist/lib/DeepReplace.d.ts.map +1 -0
  34. package/dist/lib/DeepReplace.js +0 -0
  35. package/dist/lib/DeepReplaceNullByUndefined.d.ts +7 -0
  36. package/dist/lib/DeepReplaceNullByUndefined.d.ts.map +1 -0
  37. package/dist/lib/DeepReplaceNullByUndefined.js +0 -0
  38. package/dist/lib/DeepValue.d.ts +7 -0
  39. package/dist/lib/DeepValue.d.ts.map +1 -0
  40. package/dist/lib/DeepValue.js +0 -0
  41. package/dist/lib/DictionaryFromEnum.d.ts +5 -0
  42. package/dist/lib/DictionaryFromEnum.d.ts.map +1 -0
  43. package/dist/lib/DictionaryFromEnum.js +0 -0
  44. package/dist/lib/DictionaryFromEnumMapping.d.ts +5 -0
  45. package/dist/lib/DictionaryFromEnumMapping.d.ts.map +1 -0
  46. package/dist/lib/DictionaryFromEnumMapping.js +0 -0
  47. package/dist/lib/EmptyRecord.d.ts +7 -0
  48. package/dist/lib/EmptyRecord.d.ts.map +1 -0
  49. package/dist/lib/EmptyRecord.js +0 -0
  50. package/dist/lib/Identified.d.ts +7 -0
  51. package/dist/lib/Identified.d.ts.map +1 -0
  52. package/dist/lib/Identified.js +0 -0
  53. package/dist/lib/IdentifiedLabel.d.ts +9 -0
  54. package/dist/lib/IdentifiedLabel.d.ts.map +1 -0
  55. package/dist/lib/IdentifiedLabel.js +0 -0
  56. package/dist/lib/IsAny.d.ts +5 -0
  57. package/dist/lib/IsAny.d.ts.map +1 -0
  58. package/dist/lib/IsAny.js +0 -0
  59. package/dist/lib/Json.d.ts +16 -0
  60. package/dist/lib/Json.d.ts.map +1 -0
  61. package/dist/lib/Json.js +0 -0
  62. package/dist/lib/KeepOnly.d.ts +5 -0
  63. package/dist/lib/KeepOnly.d.ts.map +1 -0
  64. package/dist/lib/KeepOnly.js +0 -0
  65. package/dist/lib/Maybe.d.ts +5 -0
  66. package/dist/lib/Maybe.d.ts.map +1 -0
  67. package/dist/lib/Maybe.js +0 -0
  68. package/dist/lib/MaybeArray.d.ts +5 -0
  69. package/dist/lib/MaybeArray.d.ts.map +1 -0
  70. package/dist/lib/MaybeArray.js +0 -0
  71. package/dist/lib/NestedValue.d.ts +8 -0
  72. package/dist/lib/NestedValue.d.ts.map +1 -0
  73. package/dist/lib/NestedValue.js +0 -0
  74. package/dist/lib/NonUndefined.d.ts +5 -0
  75. package/dist/lib/NonUndefined.d.ts.map +1 -0
  76. package/dist/lib/NonUndefined.js +0 -0
  77. package/dist/lib/Primitive.d.ts +7 -0
  78. package/dist/lib/Primitive.d.ts.map +1 -0
  79. package/dist/lib/Primitive.js +0 -0
  80. package/dist/lib/Replaced.d.ts +7 -0
  81. package/dist/lib/Replaced.d.ts.map +1 -0
  82. package/dist/lib/Replaced.js +0 -0
  83. package/dist/lib/ReverseMap.d.ts +5 -0
  84. package/dist/lib/ReverseMap.d.ts.map +1 -0
  85. package/dist/lib/ReverseMap.js +0 -0
  86. package/dist/lib/Satisfies.d.ts +5 -0
  87. package/dist/lib/Satisfies.d.ts.map +1 -0
  88. package/dist/lib/Satisfies.js +0 -0
  89. package/dist/lib/StringKey.d.ts +5 -0
  90. package/dist/lib/StringKey.d.ts.map +1 -0
  91. package/dist/lib/StringKey.js +0 -0
  92. package/dist/lib/StringKeysOnly.d.ts +7 -0
  93. package/dist/lib/StringKeysOnly.d.ts.map +1 -0
  94. package/dist/lib/StringKeysOnly.js +0 -0
  95. package/dist/staticShouldNotHappen.d.ts +5 -0
  96. package/dist/staticShouldNotHappen.d.ts.map +1 -0
  97. package/dist/staticShouldNotHappen.js +8 -0
  98. package/dist/staticShouldNotHappen.js.map +1 -0
  99. package/package.json +115 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Chaman Ventures, SASU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @contractspec/lib.utils-typescript
2
+
3
+ Website: https://contractspec.io/
4
+
5
+
6
+ A collection of essential TypeScript utility types and helper functions.
7
+
8
+ ## Purpose
9
+
10
+ To provide a shared library of generic TypeScript types (e.g., `DeepPartial`, `Maybe`, `AwaitedResult`) to avoid redeclaring them in every package.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @contractspec/lib.utils-typescript
16
+ # or
17
+ bun add @contractspec/lib.utils-typescript
18
+ ```
19
+
20
+ ## Key Concepts
21
+
22
+ - **Utility Types**: Enhancements to standard TS library types.
23
+ - **Zero Dependencies**: Pure TS/JS helpers.
24
+
25
+ ## Exports
26
+
27
+ - `DeepPartial`, `DeepRequired`
28
+ - `Maybe`, `Nullable`
29
+ - `AwaitedResult`
30
+ - `Json`, `JsonObject`
31
+
32
+ ## Usage
33
+
34
+ ```ts
35
+ import type { DeepPartial } from '@contractspec/lib.utils-typescript';
36
+
37
+ type User = {
38
+ profile: {
39
+ name: string;
40
+ };
41
+ };
42
+
43
+ const update: DeepPartial<User> = {
44
+ profile: { name: 'Alice' }, // Valid
45
+ };
46
+ ```
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
@@ -0,0 +1,32 @@
1
+ import { AwaitedResult } from "./lib/AwaitedResult.js";
2
+ import { BrowserNativeObject } from "./lib/BrowserNativeObject.js";
3
+ import { DeepInfiniteArray } from "./lib/DeepInfiniteArray.js";
4
+ import { KeepOnly } from "./lib/KeepOnly.js";
5
+ import { DeepKeepOnly } from "./lib/DeepKeepOnly.js";
6
+ import { DeepKey } from "./lib/DeepKey.js";
7
+ import { IsAny } from "./lib/IsAny.js";
8
+ import { NestedValue } from "./lib/NestedValue.js";
9
+ import { NonUndefined } from "./lib/NonUndefined.js";
10
+ import { DeepMap } from "./lib/DeepMap.js";
11
+ import { DeepOr } from "./lib/DeepOr.js";
12
+ import { DeepNullable } from "./lib/DeepNullable.js";
13
+ import { DeepPartial } from "./lib/DeepPartial.js";
14
+ import { DeepReplace } from "./lib/DeepReplace.js";
15
+ import { DeepReplaceNullByUndefined } from "./lib/DeepReplaceNullByUndefined.js";
16
+ import { DeepValue } from "./lib/DeepValue.js";
17
+ import { DictionaryFromEnum } from "./lib/DictionaryFromEnum.js";
18
+ import { DictionaryFromEnumMapping } from "./lib/DictionaryFromEnumMapping.js";
19
+ import { AnyRecord, EmptyRecord, UnknownRecord } from "./lib/EmptyRecord.js";
20
+ import { Identified } from "./lib/Identified.js";
21
+ import { IdentifiedLabel } from "./lib/IdentifiedLabel.js";
22
+ import { ExtendedJsonObject, JSONArray, JSONObject, JSONValue, NonJsonArray, NonJsonObject, NonJsonValue, PrimitiveJSONValue } from "./lib/Json.js";
23
+ import { Maybe } from "./lib/Maybe.js";
24
+ import { MaybeArray } from "./lib/MaybeArray.js";
25
+ import { Primitive } from "./lib/Primitive.js";
26
+ import { Replaced } from "./lib/Replaced.js";
27
+ import { ReverseMap } from "./lib/ReverseMap.js";
28
+ import { Satisfies } from "./lib/Satisfies.js";
29
+ import { StringKey } from "./lib/StringKey.js";
30
+ import { StringKeysOnly } from "./lib/StringKeysOnly.js";
31
+ import { staticShouldNotHappen } from "./staticShouldNotHappen.js";
32
+ export { AnyRecord, AwaitedResult, BrowserNativeObject, DeepInfiniteArray, DeepKeepOnly, DeepKey, DeepMap, DeepNullable, DeepOr, DeepPartial, DeepReplace, DeepReplaceNullByUndefined, DeepValue, DictionaryFromEnum, DictionaryFromEnumMapping, EmptyRecord, ExtendedJsonObject, Identified, IdentifiedLabel, IsAny, JSONArray, JSONObject, JSONValue, KeepOnly, Maybe, MaybeArray, NestedValue, NonJsonArray, NonJsonObject, NonJsonValue, NonUndefined, Primitive, PrimitiveJSONValue, Replaced, ReverseMap, Satisfies, StringKey, StringKeysOnly, UnknownRecord, staticShouldNotHappen };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { staticShouldNotHappen } from "./staticShouldNotHappen.js";
2
+
3
+ export { staticShouldNotHappen };
@@ -0,0 +1,5 @@
1
+ //#region src/lib/AwaitedResult.d.ts
2
+ type AwaitedResult<T extends (...args: any) => any> = Awaited<ReturnType<T>>;
3
+ //#endregion
4
+ export { AwaitedResult };
5
+ //# sourceMappingURL=AwaitedResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AwaitedResult.d.ts","names":[],"sources":["../../src/lib/AwaitedResult.ts"],"sourcesContent":[],"mappings":";KACY,iDAAiD,QAC3D,WAAW"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/BrowserNativeObject.d.ts
2
+ declare type BrowserNativeObject = Date | FileList | File;
3
+ //#endregion
4
+ export { BrowserNativeObject };
5
+ //# sourceMappingURL=BrowserNativeObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserNativeObject.d.ts","names":[],"sources":["../../src/lib/BrowserNativeObject.ts"],"sourcesContent":[],"mappings":";aAAoB,mBAAA,GAAsB,OAAO,WAAW"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/DeepInfiniteArray.d.ts
2
+ declare type DeepInfiniteArray<T> = (T | DeepInfiniteArray<T>)[];
3
+ //#endregion
4
+ export { DeepInfiniteArray };
5
+ //# sourceMappingURL=DeepInfiniteArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepInfiniteArray.d.ts","names":[],"sources":["../../src/lib/DeepInfiniteArray.ts"],"sourcesContent":[],"mappings":";aAAoB,wBAAwB,IAAI,kBAAkB"}
File without changes
@@ -0,0 +1,7 @@
1
+ import { KeepOnly } from "./KeepOnly.js";
2
+
3
+ //#region src/lib/DeepKeepOnly.d.ts
4
+ type DeepKeepOnly<T, KeepType> = T | (T extends (infer U)[] ? KeepOnly<U, KeepType>[] : T extends Map<infer K, infer V> ? Map<KeepOnly<K, KeepType>, KeepOnly<V, KeepType>> : T extends Set<infer M> ? Set<KeepOnly<M, KeepType>> : KeepOnly<T, KeepType>);
5
+ //#endregion
6
+ export { DeepKeepOnly };
7
+ //# sourceMappingURL=DeepKeepOnly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepKeepOnly.d.ts","names":[],"sources":["../../src/lib/DeepKeepOnly.ts"],"sourcesContent":[],"mappings":";;;KAEY,4BACR,KACC,wBACG,SAAS,GAAG,cACZ,UAAU,wBACR,IAAI,SAAS,GAAG,WAAW,SAAS,GAAG,aACvC,UAAU,eACR,IAAI,SAAS,GAAG,aAChB,SAAS,GAAG"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/DeepKey.d.ts
2
+ type DeepKey<T, K extends keyof T = keyof T> = K extends string | number ? T[K] extends infer R ? `${K}` | (R extends Record<string, unknown> ? `${K}.${DeepKey<R>}` : never) : never : never;
3
+ //#endregion
4
+ export { DeepKey };
5
+ //# sourceMappingURL=DeepKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepKey.d.ts","names":[],"sources":["../../src/lib/DeepKey.ts"],"sourcesContent":[],"mappings":";KAAY,2BAA2B,UAAU,KAAK,4BAClD,EAAE,wBAEO,iBACQ,6BAA6B,KAAK,QAAQ"}
File without changes
@@ -0,0 +1,10 @@
1
+ import { BrowserNativeObject } from "./BrowserNativeObject.js";
2
+ import { IsAny } from "./IsAny.js";
3
+ import { NestedValue } from "./NestedValue.js";
4
+ import { NonUndefined } from "./NonUndefined.js";
5
+
6
+ //#region src/lib/DeepMap.d.ts
7
+ declare type DeepMap<T, TValue> = IsAny<T> extends true ? any : T extends BrowserNativeObject | NestedValue ? TValue : T extends object ? { [K in keyof T]: DeepMap<NonUndefined<T[K]>, TValue> } : TValue;
8
+ //#endregion
9
+ export { DeepMap };
10
+ //# sourceMappingURL=DeepMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepMap.d.ts","names":[],"sources":["../../src/lib/DeepMap.ts"],"sourcesContent":[],"mappings":";;;;;;aAKoB,qBAClB,MAAM,wBAGF,UAAU,sBAAsB,cAC9B,SACA,iCAEgB,IAAI,QAAQ,aAAa,EAAE,KAAK,SARxD,GAUU,MAVU"}
File without changes
@@ -0,0 +1,7 @@
1
+ import { DeepOr } from "./DeepOr.js";
2
+
3
+ //#region src/lib/DeepNullable.d.ts
4
+ type DeepNullable<T> = DeepOr<T, null>;
5
+ //#endregion
6
+ export { DeepNullable };
7
+ //# sourceMappingURL=DeepNullable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepNullable.d.ts","names":[],"sources":["../../src/lib/DeepNullable.ts"],"sourcesContent":[],"mappings":";;;KAEY,kBAAkB,OAAO"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/DeepOr.d.ts
2
+ type DeepOr<T, OrValue> = T | (T extends (infer U)[] ? DeepOr<U, OrValue>[] : T extends Map<infer K, infer V> ? Map<DeepOr<K, OrValue>, DeepOr<V, OrValue>> : T extends Set<infer M> ? Set<DeepOr<M, OrValue>> : T extends object ? { [K in keyof T]: DeepOr<T[K], OrValue> | OrValue } : T);
3
+ //#endregion
4
+ export { DeepOr };
5
+ //# sourceMappingURL=DeepOr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepOr.d.ts","names":[],"sources":["../../src/lib/DeepOr.ts"],"sourcesContent":[],"mappings":";KAAY,qBACR,KACC,wBACG,OAAO,GAAG,aACV,UAAU,wBACR,IAAI,OAAO,GAAG,UAAU,OAAO,GAAG,YAClC,UAAU,eACR,IAAI,OAAO,GAAG,YACd,2BARA,MAUgB,CAVV,GAUc,MAVd,CAUqB,CAVrB,CAUuB,CAVvB,CAAA,EAU2B,OAV3B,CAAA,GAUsC,OAVtC,EACd,GAWU,CAXV,CAAA"}
File without changes
@@ -0,0 +1,8 @@
1
+ //#region src/lib/DeepPartial.d.ts
2
+ /**
3
+ * Same as Partial<T> but goes deeper and makes Partial<T> all its properties and sub-properties.
4
+ */
5
+ type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] };
6
+ //#endregion
7
+ export { DeepPartial };
8
+ //# sourceMappingURL=DeepPartial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepPartial.d.ts","names":[],"sources":["../../src/lib/DeepPartial.ts"],"sourcesContent":[],"mappings":";;AAiBA;;AACmB,KADP,WACO,CAAA,CAAA,CAAA,GAAA,QAAE,MAAP,CAAO,IAAF,CAAE,CAAA,CAAA,CAAA,SAAA,MAAA,GAAoB,WAApB,CAAgC,CAAhC,CAAkC,CAAlC,CAAA,CAAA,GAAwC,CAAxC,CAA0C,CAA1C,CAAA,EAAgC"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/DeepReplace.d.ts
2
+ type DeepReplace<T, Search, Replace> = T extends (infer ArrayItemT)[] ? DeepReplace<ArrayItemT, Search, Replace>[] : T extends Map<infer MapKey, infer MapT> ? Map<DeepReplace<MapKey, Search, Replace>, DeepReplace<MapT, Search, Replace>> : T extends Set<infer SetT> ? Set<DeepReplace<SetT, Search, Replace>> : T extends object ? { [ObjKey in keyof T]: DeepReplace<T[ObjKey], Search, Replace> } : T extends Search ? Replace : T;
3
+ //#endregion
4
+ export { DeepReplace };
5
+ //# sourceMappingURL=DeepReplace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepReplace.d.ts","names":[],"sources":["../../src/lib/DeepReplace.ts"],"sourcesContent":[],"mappings":";KAAY,kCAAkC,iCAC1C,YAAY,YAAY,QAAQ,aAChC,UAAU,gCACR,IACE,YAAY,QAAQ,QAAQ,UAC5B,YAAY,MAAM,QAAQ,YAE5B,UAAU,kBACR,IAAI,YAAY,MAAM,QAAQ,YAC9B,gCATI,MAWiB,CAXN,GAWU,WAXV,CAWsB,CAXtB,CAWwB,MAXxB,CAAA,EAWiC,MAXjC,EAWyC,OAXzC,CAAA,EAAuB,GAapC,CAboC,SAa1B,MAb0B,GAclC,OAdkC,GAelC,CAfkC"}
File without changes
@@ -0,0 +1,7 @@
1
+ import { DeepReplace } from "./DeepReplace.js";
2
+
3
+ //#region src/lib/DeepReplaceNullByUndefined.d.ts
4
+ type DeepReplaceNullByUndefined<T> = DeepReplace<T, null, undefined>;
5
+ //#endregion
6
+ export { DeepReplaceNullByUndefined };
7
+ //# sourceMappingURL=DeepReplaceNullByUndefined.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepReplaceNullByUndefined.d.ts","names":[],"sources":["../../src/lib/DeepReplaceNullByUndefined.ts"],"sourcesContent":[],"mappings":";;;KAEY,gCAAgC,YAAY"}
File without changes
@@ -0,0 +1,7 @@
1
+ import { DeepKey } from "./DeepKey.js";
2
+
3
+ //#region src/lib/DeepValue.d.ts
4
+ type DeepValue<T, P extends DeepKey<T>> = P extends `${infer K}.${infer Rest}` ? T[(K extends `${infer R extends number}` ? R : K) & keyof T] extends infer S ? S extends never ? never : Rest extends DeepKey<S> ? DeepValue<S, Rest> : never : never : T[(P extends `${infer R extends number}` ? R : P) & keyof T];
5
+ //#endregion
6
+ export { DeepValue };
7
+ //# sourceMappingURL=DeepValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeepValue.d.ts","names":[],"sources":["../../src/lib/DeepValue.ts"],"sourcesContent":[],"mappings":";;;KAEY,uBAEA,QAAQ,MAChB,uCACA,0DAA0D,4DAGzC,QAAQ,KACnB,UAAU,GAAG,wBAGnB,GAAG,4CAA4C,WAAW"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/DictionaryFromEnum.d.ts
2
+ type DictionaryFromEnum<Enum, ObjMapping> = Record<keyof Enum, ObjMapping>;
3
+ //#endregion
4
+ export { DictionaryFromEnum };
5
+ //# sourceMappingURL=DictionaryFromEnum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DictionaryFromEnum.d.ts","names":[],"sources":["../../src/lib/DictionaryFromEnum.ts"],"sourcesContent":[],"mappings":";KAAY,uCAAuC,aAC3C,MACN"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/DictionaryFromEnumMapping.d.ts
2
+ type DictionaryFromEnumMapping<Enum, Mapped, Mapping extends Record<keyof Enum, Mapped>> = { [k in keyof Enum]: Mapping[k] };
3
+ //#endregion
4
+ export { DictionaryFromEnumMapping };
5
+ //# sourceMappingURL=DictionaryFromEnumMapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DictionaryFromEnumMapping.d.ts","names":[],"sources":["../../src/lib/DictionaryFromEnumMapping.ts"],"sourcesContent":[],"mappings":";KAAY,wDAGM,aAAa,MAAM,mBAHzB,MAKE,IALF,GAKS,OALT,CAKiB,CALQ,CAAA,EAGN"}
File without changes
@@ -0,0 +1,7 @@
1
+ //#region src/lib/EmptyRecord.d.ts
2
+ type EmptyRecord = Record<string, never>;
3
+ type UnknownRecord = Record<string, unknown>;
4
+ type AnyRecord = Record<string, any>;
5
+ //#endregion
6
+ export { AnyRecord, EmptyRecord, UnknownRecord };
7
+ //# sourceMappingURL=EmptyRecord.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyRecord.d.ts","names":[],"sources":["../../src/lib/EmptyRecord.ts"],"sourcesContent":[],"mappings":";KAAY,WAAA,GAAc;AAAd,KACA,aAAA,GAAgB,MADF,CAAA,MAAM,EAAA,OAAA,CAAA;AACpB,KAEA,SAAA,GAAY,MAFC,CAAA,MAAG,EAAM,GAAA,CAAA"}
File without changes
@@ -0,0 +1,7 @@
1
+ //#region src/lib/Identified.d.ts
2
+ interface Identified {
3
+ id: string;
4
+ }
5
+ //#endregion
6
+ export { Identified };
7
+ //# sourceMappingURL=Identified.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Identified.d.ts","names":[],"sources":["../../src/lib/Identified.ts"],"sourcesContent":[],"mappings":";UAAiB,UAAA;EAAA,EAAA,EAAA,MAAA"}
File without changes
@@ -0,0 +1,9 @@
1
+ import { Identified } from "./Identified.js";
2
+
3
+ //#region src/lib/IdentifiedLabel.d.ts
4
+ type IdentifiedLabel = Identified & {
5
+ label: string;
6
+ };
7
+ //#endregion
8
+ export { IdentifiedLabel };
9
+ //# sourceMappingURL=IdentifiedLabel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IdentifiedLabel.d.ts","names":[],"sources":["../../src/lib/IdentifiedLabel.ts"],"sourcesContent":[],"mappings":";;;KAEY,eAAA,GAAkB;;AAA9B,CAAA"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/IsAny.d.ts
2
+ declare type IsAny<T> = 0 extends 1 & T ? true : false;
3
+ //#endregion
4
+ export { IsAny };
5
+ //# sourceMappingURL=IsAny.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsAny.d.ts","names":[],"sources":["../../src/lib/IsAny.ts"],"sourcesContent":[],"mappings":";aAAoB,yBAAyB"}
File without changes
@@ -0,0 +1,16 @@
1
+ //#region src/lib/Json.d.ts
2
+ declare type PrimitiveJSONValue = string | number | boolean | undefined | null;
3
+ declare type JSONValue = PrimitiveJSONValue | JSONArray | JSONObject;
4
+ interface JSONArray extends Array<JSONValue> {}
5
+ interface JSONObject {
6
+ [key: string]: JSONValue;
7
+ }
8
+ declare type NonJsonValue<ExtraTypes> = PrimitiveJSONValue | NonJsonArray<ExtraTypes> | NonJsonObject<ExtraTypes> | ExtraTypes;
9
+ interface NonJsonArray<ExtraTypes> extends Array<NonJsonValue<ExtraTypes>> {}
10
+ interface NonJsonObject<ExtraTypes> {
11
+ [key: string]: NonJsonValue<ExtraTypes>;
12
+ }
13
+ type ExtendedJsonObject = NonJsonObject<bigint | Date>;
14
+ //#endregion
15
+ export { ExtendedJsonObject, JSONArray, JSONObject, JSONValue, NonJsonArray, NonJsonObject, NonJsonValue, PrimitiveJSONValue };
16
+ //# sourceMappingURL=Json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Json.d.ts","names":[],"sources":["../../src/lib/Json.ts"],"sourcesContent":[],"mappings":";aAAoB,kBAAA;AAAA,aAMA,SAAA,GAAY,kBANM,GAMe,SANf,GAM2B,UAN3B;AAMlB,UAGH,SAAA,SAAkB,KAHN,CAGY,SAHZ,CAAA,CAAA;AAAwB,UAKpC,UAAA,CALoC;EAAY,CAAA,GAAA,EAAA,MAAA,CAAA,EAMhD,SANgD;;AAGhD,aAMG,YANqB,CAAA,UAAN,CAAA,GAO/B,kBAPoC,GAQpC,YARoC,CAQvB,UARuB,CAAA,GASpC,aAToC,CAStB,UATsB,CAAA,GAUpC,UAVoC;AAEvB,UAWA,YAVA,CAAA,UAAS,CAAA,SAUwB,KAVxB,CAWxB,YAXwB,CAWX,UAXW,CAAA,CAAA,CAAA,CAG1B;AACI,UAUa,aAVb,CAAA,UAAA,CAAA,CAAA;EACa,CAAA,GAAA,EAAA,MAAA,CAAA,EAUA,YAVA,CAUa,UAVb,CAAA;;AACC,KAYN,kBAAA,GAAqB,aAZf,CAAA,MAAA,GAYsC,IAZtC,CAAA"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/KeepOnly.d.ts
2
+ type KeepOnly<T, KeepType> = T extends object ? { [K in keyof T]: KeepOnly<T[K], KeepType> } : T extends KeepType ? T : never;
3
+ //#endregion
4
+ export { KeepOnly };
5
+ //# sourceMappingURL=KeepOnly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeepOnly.d.ts","names":[],"sources":["../../src/lib/KeepOnly.ts"],"sourcesContent":[],"mappings":";KAAY,wBAAwB,2BAAxB,MAEM,CAFE,GAEE,QAFF,CAEW,CAFX,CAEa,CAFb,CAAA,EAEiB,QAFjB,CAAA,EAAgB,GAIhC,CAJgC,SAItB,QAJsB,GAK9B,CAL8B,GAAA,KAAA"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/Maybe.d.ts
2
+ type Maybe<T> = T | null;
3
+ //#endregion
4
+ export { Maybe };
5
+ //# sourceMappingURL=Maybe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Maybe.d.ts","names":[],"sources":["../../src/lib/Maybe.ts"],"sourcesContent":[],"mappings":";KAAY,WAAW"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/MaybeArray.d.ts
2
+ type MaybeArray<T> = T | T[];
3
+ //#endregion
4
+ export { MaybeArray };
5
+ //# sourceMappingURL=MaybeArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MaybeArray.d.ts","names":[],"sources":["../../src/lib/MaybeArray.ts"],"sourcesContent":[],"mappings":";KAAY,gBAAgB,IAAI"}
File without changes
@@ -0,0 +1,8 @@
1
+ //#region src/lib/NestedValue.d.ts
2
+ declare const $NestedValue: unique symbol;
3
+ declare type NestedValue<TValue extends object = object> = {
4
+ [$NestedValue]: never;
5
+ } & TValue;
6
+ //#endregion
7
+ export { NestedValue };
8
+ //# sourceMappingURL=NestedValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NestedValue.d.ts","names":[],"sources":["../../src/lib/NestedValue.ts"],"sourcesContent":[],"mappings":";cAAc;AAAA,aAEM,WAFqB,CAAA,eAAA,MAAA,GAAA,MAAA,CAAA,GAAA;EAErB,CACjB,YAAA,CAD4B,EAAA,KAAA;IAE3B"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/NonUndefined.d.ts
2
+ declare type NonUndefined<T> = T extends undefined ? never : T;
3
+ //#endregion
4
+ export { NonUndefined };
5
+ //# sourceMappingURL=NonUndefined.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NonUndefined.d.ts","names":[],"sources":["../../src/lib/NonUndefined.ts"],"sourcesContent":[],"mappings":";aAAoB,kBAAkB,8BAA8B"}
File without changes
@@ -0,0 +1,7 @@
1
+ import { PrimitiveJSONValue } from "./Json.js";
2
+
3
+ //#region src/lib/Primitive.d.ts
4
+ declare type Primitive = PrimitiveJSONValue | symbol | bigint;
5
+ //#endregion
6
+ export { Primitive };
7
+ //# sourceMappingURL=Primitive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Primitive.d.ts","names":[],"sources":["../../src/lib/Primitive.ts"],"sourcesContent":[],"mappings":";;;aAEoB,SAAA,GAAY"}
File without changes
@@ -0,0 +1,7 @@
1
+ import { Primitive } from "./Primitive.js";
2
+
3
+ //#region src/lib/Replaced.d.ts
4
+ type Replaced<T, TReplace, TWith, TKeep = Primitive> = T extends TReplace | TKeep ? T extends TReplace ? TWith | Exclude<T, TReplace> : T : { [P in keyof T]: Replaced<T[P], TReplace, TWith, TKeep> };
5
+ //#endregion
6
+ export { Replaced };
7
+ //# sourceMappingURL=Replaced.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Replaced.d.ts","names":[],"sources":["../../src/lib/Replaced.ts"],"sourcesContent":[],"mappings":";;;KAGY,qCAAqC,aAAa,UAC1D,WACA,QACA,UAAU,WACR,QAAQ,QAAQ,GAAG,YACnB,kBAEY,IAAI,SAAS,EAAE,IAAI,UAAU,OAAO,QAPtD"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/ReverseMap.d.ts
2
+ type ReverseMap<T extends Record<keyof T, keyof any>> = { [K in keyof T as T[K]]: K };
3
+ //#endregion
4
+ export { ReverseMap };
5
+ //# sourceMappingURL=ReverseMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReverseMap.d.ts","names":[],"sources":["../../src/lib/ReverseMap.ts"],"sourcesContent":[],"mappings":";KACY,qBAAqB,aAAa,yBAAlC,MACE,CADQ,IACH,CADG,CACD,CADC,CAAA,GACI,CADJ,EAAwB"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/Satisfies.d.ts
2
+ declare type Satisfies<ConstraintShape, ToValidate> = ConstraintShape extends ConstraintShape ? ToValidate : never;
3
+ //#endregion
4
+ export { Satisfies };
5
+ //# sourceMappingURL=Satisfies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Satisfies.d.ts","names":[],"sources":["../../src/lib/Satisfies.ts"],"sourcesContent":[],"mappings":";aAAoB,yCAClB,wBAAwB,kBAAkB"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/lib/StringKey.d.ts
2
+ type StringKey<T> = { [K in keyof T]: T[K] extends string ? K : never }[keyof T];
3
+ //#endregion
4
+ export { StringKey };
5
+ //# sourceMappingURL=StringKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StringKey.d.ts","names":[],"sources":["../../src/lib/StringKey.ts"],"sourcesContent":[],"mappings":";KAAY,uBAAA,MACE,CADO,GACH,CADG,CACD,CADC,CAAA,SAAA,MAAA,GACmB,CADnB,GAAA,KAAA,EACP,CAAA,MACN,CADM,CAAA"}
File without changes
@@ -0,0 +1,7 @@
1
+ import { StringKey } from "./StringKey.js";
2
+
3
+ //#region src/lib/StringKeysOnly.d.ts
4
+ type StringKeysOnly<T> = Pick<T, StringKey<T>>;
5
+ //#endregion
6
+ export { StringKeysOnly };
7
+ //# sourceMappingURL=StringKeysOnly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StringKeysOnly.d.ts","names":[],"sources":["../../src/lib/StringKeysOnly.ts"],"sourcesContent":[],"mappings":";;;KAEY,oBAAoB,KAAK,GAAG,UAAU"}
File without changes
@@ -0,0 +1,5 @@
1
+ //#region src/staticShouldNotHappen.d.ts
2
+ declare function staticShouldNotHappen(value: never): asserts value;
3
+ //#endregion
4
+ export { staticShouldNotHappen };
5
+ //# sourceMappingURL=staticShouldNotHappen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staticShouldNotHappen.d.ts","names":[],"sources":["../src/staticShouldNotHappen.ts"],"sourcesContent":[],"mappings":";iBAAgB,qBAAA"}
@@ -0,0 +1,8 @@
1
+ //#region src/staticShouldNotHappen.ts
2
+ function staticShouldNotHappen(value) {
3
+ throw new Error(`Missing switch value ${value?.toString?.()}`);
4
+ }
5
+
6
+ //#endregion
7
+ export { staticShouldNotHappen };
8
+ //# sourceMappingURL=staticShouldNotHappen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staticShouldNotHappen.js","names":[],"sources":["../src/staticShouldNotHappen.ts"],"sourcesContent":["export function staticShouldNotHappen(value: never): asserts value {\n throw new Error(\n `Missing switch value ${(value as null | { toString?: () => string })?.toString?.()}`\n );\n}\n"],"mappings":";AAAA,SAAgB,sBAAsB,OAA6B;AACjE,OAAM,IAAI,MACR,wBAAyB,OAA8C,YAAY,GACpF"}
package/package.json ADDED
@@ -0,0 +1,115 @@
1
+ {
2
+ "name": "@contractspec/lib.utils-typescript",
3
+ "version": "0.0.0-canary-20260113162409",
4
+ "description": "TypeScript utility types and helpers",
5
+ "keywords": [
6
+ "contractspec",
7
+ "typescript",
8
+ "utilities",
9
+ "types",
10
+ "helpers"
11
+ ],
12
+ "scripts": {
13
+ "clean": "rm -rf dist",
14
+ "lint": "bun run lint:fix",
15
+ "lint:fix": "eslint src --fix",
16
+ "lint:check": "eslint src",
17
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
18
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
19
+ "build": "bun build:types && bun build:bundle",
20
+ "build:bundle": "tsdown",
21
+ "build:types": "tsc --noEmit",
22
+ "dev": "bun build:bundle --watch"
23
+ },
24
+ "devDependencies": {
25
+ "@contractspec/tool.typescript": "0.0.0-canary-20260113162409",
26
+ "@contractspec/tool.tsdown": "0.0.0-canary-20260113162409",
27
+ "tsdown": "^0.19.0",
28
+ "typescript": "^5.9.3"
29
+ },
30
+ "type": "module",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": "./dist/index.js",
34
+ "./lib/AwaitedResult": "./dist/lib/AwaitedResult.js",
35
+ "./lib/BrowserNativeObject": "./dist/lib/BrowserNativeObject.js",
36
+ "./lib/DeepInfiniteArray": "./dist/lib/DeepInfiniteArray.js",
37
+ "./lib/DeepKeepOnly": "./dist/lib/DeepKeepOnly.js",
38
+ "./lib/DeepKey": "./dist/lib/DeepKey.js",
39
+ "./lib/DeepMap": "./dist/lib/DeepMap.js",
40
+ "./lib/DeepNullable": "./dist/lib/DeepNullable.js",
41
+ "./lib/DeepOr": "./dist/lib/DeepOr.js",
42
+ "./lib/DeepPartial": "./dist/lib/DeepPartial.js",
43
+ "./lib/DeepReplace": "./dist/lib/DeepReplace.js",
44
+ "./lib/DeepReplaceNullByUndefined": "./dist/lib/DeepReplaceNullByUndefined.js",
45
+ "./lib/DeepValue": "./dist/lib/DeepValue.js",
46
+ "./lib/DictionaryFromEnum": "./dist/lib/DictionaryFromEnum.js",
47
+ "./lib/DictionaryFromEnumMapping": "./dist/lib/DictionaryFromEnumMapping.js",
48
+ "./lib/EmptyRecord": "./dist/lib/EmptyRecord.js",
49
+ "./lib/Identified": "./dist/lib/Identified.js",
50
+ "./lib/IdentifiedLabel": "./dist/lib/IdentifiedLabel.js",
51
+ "./lib/IsAny": "./dist/lib/IsAny.js",
52
+ "./lib/Json": "./dist/lib/Json.js",
53
+ "./lib/KeepOnly": "./dist/lib/KeepOnly.js",
54
+ "./lib/Maybe": "./dist/lib/Maybe.js",
55
+ "./lib/MaybeArray": "./dist/lib/MaybeArray.js",
56
+ "./lib/NestedValue": "./dist/lib/NestedValue.js",
57
+ "./lib/NonUndefined": "./dist/lib/NonUndefined.js",
58
+ "./lib/Primitive": "./dist/lib/Primitive.js",
59
+ "./lib/Replaced": "./dist/lib/Replaced.js",
60
+ "./lib/ReverseMap": "./dist/lib/ReverseMap.js",
61
+ "./lib/Satisfies": "./dist/lib/Satisfies.js",
62
+ "./lib/StringKey": "./dist/lib/StringKey.js",
63
+ "./lib/StringKeysOnly": "./dist/lib/StringKeysOnly.js",
64
+ "./*": "./*"
65
+ },
66
+ "publishConfig": {
67
+ "exports": {
68
+ ".": "./dist/index.js",
69
+ "./lib/AwaitedResult": "./dist/lib/AwaitedResult.js",
70
+ "./lib/BrowserNativeObject": "./dist/lib/BrowserNativeObject.js",
71
+ "./lib/DeepInfiniteArray": "./dist/lib/DeepInfiniteArray.js",
72
+ "./lib/DeepKeepOnly": "./dist/lib/DeepKeepOnly.js",
73
+ "./lib/DeepKey": "./dist/lib/DeepKey.js",
74
+ "./lib/DeepMap": "./dist/lib/DeepMap.js",
75
+ "./lib/DeepNullable": "./dist/lib/DeepNullable.js",
76
+ "./lib/DeepOr": "./dist/lib/DeepOr.js",
77
+ "./lib/DeepPartial": "./dist/lib/DeepPartial.js",
78
+ "./lib/DeepReplace": "./dist/lib/DeepReplace.js",
79
+ "./lib/DeepReplaceNullByUndefined": "./dist/lib/DeepReplaceNullByUndefined.js",
80
+ "./lib/DeepValue": "./dist/lib/DeepValue.js",
81
+ "./lib/DictionaryFromEnum": "./dist/lib/DictionaryFromEnum.js",
82
+ "./lib/DictionaryFromEnumMapping": "./dist/lib/DictionaryFromEnumMapping.js",
83
+ "./lib/EmptyRecord": "./dist/lib/EmptyRecord.js",
84
+ "./lib/Identified": "./dist/lib/Identified.js",
85
+ "./lib/IdentifiedLabel": "./dist/lib/IdentifiedLabel.js",
86
+ "./lib/IsAny": "./dist/lib/IsAny.js",
87
+ "./lib/Json": "./dist/lib/Json.js",
88
+ "./lib/KeepOnly": "./dist/lib/KeepOnly.js",
89
+ "./lib/Maybe": "./dist/lib/Maybe.js",
90
+ "./lib/MaybeArray": "./dist/lib/MaybeArray.js",
91
+ "./lib/NestedValue": "./dist/lib/NestedValue.js",
92
+ "./lib/NonUndefined": "./dist/lib/NonUndefined.js",
93
+ "./lib/Primitive": "./dist/lib/Primitive.js",
94
+ "./lib/Replaced": "./dist/lib/Replaced.js",
95
+ "./lib/ReverseMap": "./dist/lib/ReverseMap.js",
96
+ "./lib/Satisfies": "./dist/lib/Satisfies.js",
97
+ "./lib/StringKey": "./dist/lib/StringKey.js",
98
+ "./lib/StringKeysOnly": "./dist/lib/StringKeysOnly.js",
99
+ "./*": "./*"
100
+ },
101
+ "access": "public",
102
+ "registry": "https://registry.npmjs.org/"
103
+ },
104
+ "files": [
105
+ "dist",
106
+ "README.md"
107
+ ],
108
+ "license": "MIT",
109
+ "repository": {
110
+ "type": "git",
111
+ "url": "https://github.com/lssm-tech/contractspec.git",
112
+ "directory": "packages/libs/utils-typescript"
113
+ },
114
+ "homepage": "https://contractspec.io"
115
+ }