@augment-vir/core 32.0.0 → 32.2.0

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 (85) hide show
  1. package/dist/augments/error/ensure-error.d.ts +1 -1
  2. package/dist/augments/json/json-compatible.d.ts +2 -1
  3. package/dist/augments/json/json-value.d.ts +46 -0
  4. package/dist/augments/json/json-value.js +1 -0
  5. package/dist/augments/json/jsonify.d.ts +41 -0
  6. package/dist/augments/json/jsonify.js +1 -0
  7. package/dist/augments/number/infinity.d.ts +22 -0
  8. package/dist/augments/number/infinity.js +1 -0
  9. package/dist/augments/object/object-keys.d.ts +1 -1
  10. package/dist/augments/object/required-keys.d.ts +5 -5
  11. package/dist/augments/type/built-in-type.d.ts +28 -0
  12. package/dist/augments/type/built-in-type.js +1 -0
  13. package/dist/augments/type/conditional-type.d.ts +13 -0
  14. package/dist/augments/type/conditional-type.js +1 -0
  15. package/dist/augments/type/constructor-type.d.ts +51 -0
  16. package/dist/augments/type/constructor-type.js +1 -0
  17. package/dist/augments/type/distributed-omit.d.ts +13 -0
  18. package/dist/augments/type/distributed-omit.js +1 -0
  19. package/dist/augments/type/empty-object.d.ts +27 -0
  20. package/dist/augments/type/empty-object.js +1 -0
  21. package/dist/augments/type/exact.d.ts +23 -0
  22. package/dist/augments/type/exact.js +1 -0
  23. package/dist/augments/type/except.d.ts +37 -0
  24. package/dist/augments/type/except.js +1 -0
  25. package/dist/augments/type/is-unknown.d.ts +22 -0
  26. package/dist/augments/type/is-unknown.js +1 -0
  27. package/dist/augments/type/keys-of-union.d.ts +14 -0
  28. package/dist/augments/type/keys-of-union.js +1 -0
  29. package/dist/augments/type/literal-union.d.ts +13 -0
  30. package/dist/augments/type/literal-union.js +1 -0
  31. package/dist/augments/type/non-empty-string.d.ts +9 -0
  32. package/dist/augments/type/non-empty-string.js +1 -0
  33. package/dist/augments/type/omit-deep.d.ts +290 -0
  34. package/dist/augments/type/omit-deep.js +1 -0
  35. package/dist/augments/type/omit-index-signature.d.ts +14 -0
  36. package/dist/augments/type/omit-index-signature.js +2 -0
  37. package/dist/augments/type/optional-keys-of.d.ts +25 -0
  38. package/dist/augments/type/optional-keys-of.js +1 -0
  39. package/dist/augments/type/package-json.d.ts +176 -0
  40. package/dist/augments/type/package-json.js +1 -0
  41. package/dist/augments/type/partial-deep.d.ts +52 -0
  42. package/dist/augments/type/partial-deep.js +1 -0
  43. package/dist/augments/type/primitive-type.d.ts +11 -0
  44. package/dist/augments/type/primitive-type.js +1 -0
  45. package/dist/augments/type/promisable.d.ts +11 -0
  46. package/dist/augments/type/promisable.js +1 -0
  47. package/dist/augments/type/readonly-deep.d.ts +30 -0
  48. package/dist/augments/type/readonly-deep.js +1 -0
  49. package/dist/augments/type/readonly-keys-of.d.ts +20 -0
  50. package/dist/augments/type/readonly-keys-of.js +1 -0
  51. package/dist/augments/type/require-keys.d.ts +43 -0
  52. package/dist/augments/type/require-keys.js +1 -0
  53. package/dist/augments/type/require-one-or-none.d.ts +16 -0
  54. package/dist/augments/type/require-one-or-none.js +1 -0
  55. package/dist/augments/type/set-optional.d.ts +19 -0
  56. package/dist/augments/type/set-optional.js +1 -0
  57. package/dist/augments/type/set-required.d.ts +47 -0
  58. package/dist/augments/type/set-required.js +1 -0
  59. package/dist/augments/type/simplify.d.ts +14 -0
  60. package/dist/augments/type/simplify.js +1 -0
  61. package/dist/augments/type/subtract.d.ts +177 -0
  62. package/dist/augments/type/subtract.js +1 -0
  63. package/dist/augments/type/tagged.d.ts +30 -0
  64. package/dist/augments/type/tagged.js +1 -0
  65. package/dist/augments/type/type-checks.d.ts +32 -0
  66. package/dist/augments/type/type-checks.js +9 -0
  67. package/dist/augments/type/typed-array.d.ts +13 -0
  68. package/dist/augments/type/typed-array.js +1 -0
  69. package/dist/augments/type/undefined-to-optional.d.ts +27 -0
  70. package/dist/augments/type/undefined-to-optional.js +1 -0
  71. package/dist/augments/type/union-to-intersection.d.ts +11 -0
  72. package/dist/augments/type/union-to-intersection.js +1 -0
  73. package/dist/augments/type/union-to-tuple.d.ts +18 -0
  74. package/dist/augments/type/union-to-tuple.js +1 -0
  75. package/dist/augments/type/unknown-array.d.ts +11 -0
  76. package/dist/augments/type/unknown-array.js +1 -0
  77. package/dist/augments/type/writable-deep.d.ts +32 -0
  78. package/dist/augments/type/writable-deep.js +1 -0
  79. package/dist/augments/type/writable-keys-of.d.ts +12 -0
  80. package/dist/augments/type/writable-keys-of.js +1 -0
  81. package/dist/augments/type/writable.d.ts +29 -0
  82. package/dist/augments/type/writable.js +1 -0
  83. package/dist/index.d.ts +39 -0
  84. package/dist/index.js +39 -0
  85. package/package.json +2 -3
@@ -0,0 +1,290 @@
1
+ import { type BuiltIns } from './built-in-type.js';
2
+ import { type If } from './conditional-type.js';
3
+ import { type LiteralUnion } from './literal-union.js';
4
+ import { type IsAny, type IsEqual, type IsNever } from './type-checks.js';
5
+ import { type UnknownArray } from './unknown-array.js';
6
+ type IfNotAnyOrNever<T, IfNotAny, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAny>>;
7
+ type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown) | Promise<unknown>;
8
+ type MapsSetsOrArrays = ReadonlyMap<unknown, unknown> | WeakMap<WeakKey, unknown> | ReadonlySet<unknown> | WeakSet<WeakKey> | UnknownArray;
9
+ type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
10
+ type PositiveInfinity = 1e999;
11
+ type NegativeInfinity = -1e999;
12
+ type Zero = 0 | 0n;
13
+ type Negative<T extends number | bigint> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
14
+ type IsNegative<T extends number | bigint> = T extends Negative<T> ? true : false;
15
+ type ReverseSign<N extends number> = N extends 0 ? 0 : N extends PositiveInfinity ? NegativeInfinity : N extends NegativeInfinity ? PositiveInfinity : `${N}` extends `-${infer P extends number}` ? P : `-${N}` extends `${infer R extends number}` ? R : never;
16
+ type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : S extends 'Infinity' ? PositiveInfinity : S extends '-Infinity' ? NegativeInfinity : never;
17
+ type Absolute<N extends number | bigint> = N extends bigint ? `${N}` extends `-${infer Magnitude extends bigint}` ? Magnitude : N : `${N}` extends `-${infer Magnitude}` ? StringToNumber<Magnitude> : N;
18
+ type StringToArray<S extends string, Result extends string[] = []> = string extends S ? never : S extends `${infer First}${infer Rest}` ? StringToArray<Rest, [
19
+ ...Result,
20
+ First
21
+ ]> : Result;
22
+ type StringLength<S extends string> = string extends S ? never : StringToArray<S>['length'];
23
+ type NumericString = '0123456789';
24
+ type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer _TailA}` ? NumericString extends `${infer HeadB}${B}${infer _TailB}` ? HeadA extends `${HeadB}${infer _Middle}${infer _Rest}` ? true : false : never : never;
25
+ type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}` ? B extends `${infer FirstB}${infer RestB}` ? FirstA extends FirstB ? SameLengthPositiveNumericStringGt<RestA, RestB> : PositiveNumericCharacterGt<FirstA, FirstB> : never : false;
26
+ type PositiveNumericStringGt<A extends string, B extends string> = A extends B ? false : [
27
+ TupleOf<StringLength<A>, 0>,
28
+ TupleOf<StringLength<B>, 0>
29
+ ] extends infer Lengths extends [
30
+ readonly unknown[],
31
+ readonly unknown[]
32
+ ] ? Lengths[0] extends [
33
+ ...Lengths[1],
34
+ ...infer Remaining extends readonly unknown[]
35
+ ] ? 0 extends Remaining['length'] ? SameLengthPositiveNumericStringGt<A, B> : true : false : never;
36
+ /**
37
+ * Simplified 2-input logical `and`. `type-fest` routes `And` through `AndAll`/`AllExtend`, but the
38
+ * only consumer here (`GreaterThan`) always passes concrete `true`/`false` values, for which this
39
+ * definition is behaviorally identical.
40
+ */
41
+ type And<A extends boolean, B extends boolean> = A extends true ? B extends true ? true : false : false;
42
+ /** Simplified 2-input logical `or`. See the note on {@link And}. */
43
+ type Or<A extends boolean, B extends boolean> = A extends true ? true : B extends true ? true : false;
44
+ type GreaterThan<A extends number, B extends number> = A extends number ? B extends number ? number extends A | B ? boolean : [
45
+ IsEqual<A, PositiveInfinity>,
46
+ IsEqual<A, NegativeInfinity>,
47
+ IsEqual<B, PositiveInfinity>,
48
+ IsEqual<B, NegativeInfinity>
49
+ ] extends infer R extends [
50
+ boolean,
51
+ boolean,
52
+ boolean,
53
+ boolean
54
+ ] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? true : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? false : true extends R[number] ? false : [
55
+ IsNegative<A>,
56
+ IsNegative<B>
57
+ ] extends infer Signs extends [
58
+ boolean,
59
+ boolean
60
+ ] ? [
61
+ true,
62
+ false
63
+ ] extends Signs ? false : [
64
+ false,
65
+ true
66
+ ] extends Signs ? true : [
67
+ false,
68
+ false
69
+ ] extends Signs ? PositiveNumericStringGt<`${A}`, `${B}`> : PositiveNumericStringGt<`${Absolute<B>}`, `${Absolute<A>}`> : never : never : never : never;
70
+ type GreaterThanOrEqual<A extends number, B extends number> = number extends A | B ? boolean : A extends number ? B extends number ? A extends B ? true : GreaterThan<A, B> : never : never;
71
+ type LessThan<A extends number, B extends number> = GreaterThanOrEqual<A, B> extends infer Result ? (Result extends true ? false : true) : never;
72
+ type _TupleOf<Length extends number, Fill> = number extends Length ? Fill[] : BuildTupleDigitByDigit<`${Length}`, Fill>;
73
+ type BuildTupleDigitByDigit<Length extends string, Fill, Accumulator extends UnknownArray = []> = Length extends `${infer First extends DigitCharacter}${infer Rest}` ? BuildTupleDigitByDigit<Rest, Fill, [
74
+ ...RepeatTupleTenTimes<Accumulator>,
75
+ ...DigitTupleOf<First, Fill>
76
+ ]> : Accumulator;
77
+ type RepeatTupleTenTimes<Tuple extends UnknownArray> = [
78
+ ...Tuple,
79
+ ...Tuple,
80
+ ...Tuple,
81
+ ...Tuple,
82
+ ...Tuple,
83
+ ...Tuple,
84
+ ...Tuple,
85
+ ...Tuple,
86
+ ...Tuple,
87
+ ...Tuple
88
+ ];
89
+ type DigitTupleOf<Digit extends DigitCharacter, Fill> = [
90
+ [
91
+ ],
92
+ [
93
+ Fill
94
+ ],
95
+ [
96
+ Fill,
97
+ Fill
98
+ ],
99
+ [
100
+ Fill,
101
+ Fill,
102
+ Fill
103
+ ],
104
+ [
105
+ Fill,
106
+ Fill,
107
+ Fill,
108
+ Fill
109
+ ],
110
+ [
111
+ Fill,
112
+ Fill,
113
+ Fill,
114
+ Fill,
115
+ Fill
116
+ ],
117
+ [
118
+ Fill,
119
+ Fill,
120
+ Fill,
121
+ Fill,
122
+ Fill,
123
+ Fill
124
+ ],
125
+ [
126
+ Fill,
127
+ Fill,
128
+ Fill,
129
+ Fill,
130
+ Fill,
131
+ Fill,
132
+ Fill
133
+ ],
134
+ [
135
+ Fill,
136
+ Fill,
137
+ Fill,
138
+ Fill,
139
+ Fill,
140
+ Fill,
141
+ Fill,
142
+ Fill
143
+ ],
144
+ [
145
+ Fill,
146
+ Fill,
147
+ Fill,
148
+ Fill,
149
+ Fill,
150
+ Fill,
151
+ Fill,
152
+ Fill,
153
+ Fill
154
+ ]
155
+ ][Digit];
156
+ type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill>, Fill[], [
157
+ ]>;
158
+ type SubtractIfAGreaterThanB<A extends number, B extends number> = TupleOf<A> extends [
159
+ ...TupleOf<B>,
160
+ ...infer R
161
+ ] ? R['length'] : never;
162
+ type SubtractPositives<A extends number, B extends number> = LessThan<A, B> extends true ? ReverseSign<SubtractIfAGreaterThanB<B, A>> : SubtractIfAGreaterThanB<A, B>;
163
+ type SubtractPostChecks<A extends number, B extends number, AreNegative = [
164
+ IsNegative<A>,
165
+ IsNegative<B>
166
+ ]> = AreNegative extends [
167
+ false,
168
+ false
169
+ ] ? SubtractPositives<A, B> : AreNegative extends [
170
+ true,
171
+ true
172
+ ] ? ReverseSign<SubtractPositives<Absolute<A>, Absolute<B>>> : [
173
+ ...TupleOf<Absolute<A>>,
174
+ ...TupleOf<Absolute<B>>
175
+ ] extends infer R extends unknown[] ? LessThan<A, B> extends true ? ReverseSign<R['length']> : R['length'] : never;
176
+ type Subtract<A extends number, B extends number> = number extends A | B ? number : A extends B & (PositiveInfinity | NegativeInfinity) ? number : A extends NegativeInfinity ? NegativeInfinity : B extends PositiveInfinity ? NegativeInfinity : A extends PositiveInfinity ? PositiveInfinity : B extends NegativeInfinity ? PositiveInfinity : A extends B ? 0 : A extends 0 ? ReverseSign<B> : B extends 0 ? A : SubtractPostChecks<A, B>;
177
+ type StaticPartOfArray<T extends UnknownArray, Result extends UnknownArray = []> = T extends unknown ? number extends T['length'] ? T extends readonly [
178
+ infer U,
179
+ ...infer V
180
+ ] ? StaticPartOfArray<V, [
181
+ ...Result,
182
+ U
183
+ ]> : Result : T : never;
184
+ type VariablePartOfArray<T extends UnknownArray> = T extends unknown ? T extends readonly [
185
+ ...StaticPartOfArray<T>,
186
+ ...infer U
187
+ ] ? U : [] : never;
188
+ type SetArrayAccess<T extends UnknownArray, IsReadonly extends boolean> = T extends readonly [
189
+ ...infer U
190
+ ] ? IsReadonly extends true ? readonly [...U] : [...U] : T;
191
+ type IsArrayReadonly<T extends UnknownArray> = If<IsNever<T>, false, T extends unknown[] ? false : true>;
192
+ type SplitFixedArrayByIndex<T extends UnknownArray, SplitIndex extends number> = SplitIndex extends 0 ? [
193
+ [
194
+ ],
195
+ T
196
+ ] : T extends readonly [
197
+ ...TupleOf<SplitIndex>,
198
+ ...infer V
199
+ ] ? T extends readonly [
200
+ ...infer U,
201
+ ...V
202
+ ] ? [
203
+ U,
204
+ V
205
+ ] : [
206
+ never,
207
+ never
208
+ ] : [
209
+ never,
210
+ never
211
+ ];
212
+ type SplitVariableArrayByIndex<T extends UnknownArray, SplitIndex extends number, T1 = Subtract<SplitIndex, StaticPartOfArray<T>['length']>, T2 = T1 extends number ? TupleOf<GreaterThanOrEqual<T1, 0> extends true ? T1 : number, VariablePartOfArray<T>[number]> : []> = SplitIndex extends 0 ? [
213
+ [
214
+ ],
215
+ T
216
+ ] : GreaterThanOrEqual<StaticPartOfArray<T>['length'], SplitIndex> extends true ? [
217
+ SplitFixedArrayByIndex<StaticPartOfArray<T>, SplitIndex>[0],
218
+ [
219
+ ...SplitFixedArrayByIndex<StaticPartOfArray<T>, SplitIndex>[1],
220
+ ...VariablePartOfArray<T>
221
+ ]
222
+ ] : [
223
+ [
224
+ ...StaticPartOfArray<T>,
225
+ ...(T2 extends UnknownArray ? T2 : [])
226
+ ],
227
+ VariablePartOfArray<T>
228
+ ];
229
+ type SplitArrayByIndex<T extends UnknownArray, SplitIndex extends number> = SplitIndex extends 0 ? [
230
+ [
231
+ ],
232
+ T
233
+ ] : number extends T['length'] ? SplitVariableArrayByIndex<T, SplitIndex> : SplitFixedArrayByIndex<T, SplitIndex>;
234
+ type ArraySplice<T extends UnknownArray, Start extends number, DeleteCount extends number, Items extends UnknownArray = []> = SplitArrayByIndex<T, Start> extends [
235
+ infer U extends UnknownArray,
236
+ infer V extends UnknownArray
237
+ ] ? SplitArrayByIndex<V, DeleteCount> extends [
238
+ infer _Deleted extends UnknownArray,
239
+ infer X extends UnknownArray
240
+ ] ? [
241
+ ...U,
242
+ ...Items,
243
+ ...X
244
+ ] : never : never;
245
+ type ToString<T> = T extends string | number ? `${T}` : never;
246
+ type ExactKey<T extends object, Key extends PropertyKey> = Key extends keyof T ? Key : ToString<Key> extends keyof T ? ToString<Key> : Key extends `${infer NumberKey extends number}` ? NumberKey extends keyof T ? NumberKey : never : never;
247
+ type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never;
248
+ type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
249
+ type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, Union extends unknown ? [
250
+ Delete extends unknown ? If<IsEqual<Union, Delete>, true, never> : never
251
+ ] extends [never] ? Union : never : never, Union, Union>;
252
+ type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union, _ExcludeExactly<Union, Delete>, If<IsAny<Delete>, never, Union>, If<IsNever<Delete>, never, Union>>;
253
+ type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [
254
+ Member,
255
+ ...Accumulator
256
+ ]>;
257
+ type UnionToTuple<Union> = _UnionToTuple<Union> extends infer Result extends UnknownArray ? Result : never;
258
+ type ConditionalSimplifyDeep<Type, ExcludeType = never, IncludeType = unknown> = Type extends ExcludeType ? Type : Type extends IncludeType ? {
259
+ [TypeKey in keyof Type]: ConditionalSimplifyDeep<Type[TypeKey], ExcludeType, IncludeType>;
260
+ } : Type;
261
+ type SimplifyDeep<Type, ExcludeType = never> = ConditionalSimplifyDeep<Type, ExcludeType | NonRecursiveType | Exclude<MapsSetsOrArrays, UnknownArray>, object>;
262
+ type OmitDeepArrayWithOnePath<ArrayType extends UnknownArray, P extends string | number> = P extends `${infer ArrayIndex extends number}.${infer SubPath}` ? number extends ArrayIndex ? Array<OmitDeepWithOnePath<NonNullable<ArrayType[number]>, SubPath>> : ArraySplice<ArrayType, ArrayIndex, 1, [
263
+ OmitDeepWithOnePath<NonNullable<ArrayType[ArrayIndex]>, SubPath>
264
+ ]> : P extends `${infer ArrayIndex extends number}` ? number extends ArrayIndex ? [] : ArraySplice<ArrayType, ArrayIndex, 1, [unknown]> : ArrayType;
265
+ type OmitDeepObjectWithOnePath<ObjectT extends object, P extends string | number> = P extends `${infer RecordKeyInPath}.${infer SubPath}` ? {
266
+ [Key in keyof ObjectT]: IsEqual<RecordKeyInPath, ToString<Key>> extends true ? ExactKey<ObjectT, Key> extends infer RealKey ? RealKey extends keyof ObjectT ? OmitDeepWithOnePath<ObjectT[RealKey], SubPath> : ObjectT[Key] : ObjectT[Key] : ObjectT[Key];
267
+ } : ExactKey<ObjectT, P> extends infer Key ? IsNever<Key> extends true ? ObjectT : Key extends PropertyKey ? Omit<ObjectT, Key> : ObjectT : ObjectT;
268
+ type OmitDeepWithOnePath<T, Path extends string | number> = T extends NonRecursiveType ? T : T extends UnknownArray ? SetArrayAccess<OmitDeepArrayWithOnePath<T, Path>, IsArrayReadonly<T>> : T extends object ? OmitDeepObjectWithOnePath<T, Path> : T;
269
+ type OmitDeepHelper<T, PathTuple extends UnknownArray> = PathTuple extends [
270
+ infer Path,
271
+ ...infer RestPaths
272
+ ] ? OmitDeepHelper<OmitDeepWithOnePath<T, Path & (string | number)>, RestPaths> : T;
273
+ /**
274
+ * Omit properties from a deeply-nested object, supporting recursion into arrays (each removed array
275
+ * item is replaced with `unknown` at its index).
276
+ *
277
+ * Copied from the `OmitDeep` type in the `type-fest` package so that this package's public types do
278
+ * not depend on `type-fest` (see the note in `type-checks.ts`).
279
+ *
280
+ * Note: `type-fest` constrains `PathUnion` to `LiteralUnion<Paths<T>, string>`. That `Paths<T>`
281
+ * portion is only an autocomplete/validation aid on the path argument and is not used by the
282
+ * omission logic, so it is relaxed here to `LiteralUnion<string, string>` (effectively `string`) to
283
+ * avoid vendoring type-fest's enormous `Paths` type.
284
+ *
285
+ * @category Object
286
+ * @category Package : @augment-vir/common
287
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
288
+ */
289
+ export type OmitDeep<T, PathUnion extends LiteralUnion<string, string>> = SimplifyDeep<OmitDeepHelper<T, UnionToTuple<PathUnion>>, UnknownArray>;
290
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Omit any index signatures from the given object type, leaving only explicitly defined properties.
3
+ * This is the counterpart of `PickIndexSignature`.
4
+ *
5
+ * Copied from the `OmitIndexSignature` type in the `type-fest` package so that this package's
6
+ * public types do not depend on `type-fest` (see the note in `type-checks.ts`).
7
+ *
8
+ * @category Object
9
+ * @category Package : @augment-vir/common
10
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
11
+ */
12
+ export type OmitIndexSignature<ObjectType> = {
13
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
14
+ };
@@ -0,0 +1,2 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-object-type -- faithful copy of type-fest, which intentionally uses the `{}` identity type. */
2
+ export {};
@@ -0,0 +1,25 @@
1
+ import { type IsAny } from './type-checks.js';
2
+ /**
3
+ * Returns a boolean for whether the given key is an optional key of the given type.
4
+ *
5
+ * Copied from the `IsOptionalKeyOf` type in the `type-fest` package so that this package's public
6
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
7
+ *
8
+ * @category Object
9
+ * @category Package : @augment-vir/common
10
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
11
+ */
12
+ export type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
13
+ /**
14
+ * Extract all optional keys from the given type.
15
+ *
16
+ * Copied from the `OptionalKeysOf` type in the `type-fest` package so that this package's public
17
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
18
+ *
19
+ * @category Object
20
+ * @category Package : @augment-vir/common
21
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
22
+ */
23
+ export type OptionalKeysOf<Type extends object> = Type extends unknown ? keyof {
24
+ [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never;
25
+ } & keyof Type : never;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,176 @@
1
+ import { type JsonObject, type JsonValue } from '../json/json-value.js';
2
+ import { type LiteralUnion } from './literal-union.js';
3
+ type Person = string | {
4
+ name: string;
5
+ url?: string;
6
+ email?: string;
7
+ };
8
+ type BugsLocation = string | {
9
+ url?: string;
10
+ email?: string;
11
+ };
12
+ type DirectoryLocations = {
13
+ [directoryType: string]: JsonValue | undefined;
14
+ bin?: string;
15
+ doc?: string;
16
+ example?: string;
17
+ lib?: string;
18
+ man?: string;
19
+ test?: string;
20
+ };
21
+ type Scripts = {
22
+ prepublish?: string;
23
+ prepare?: string;
24
+ prepublishOnly?: string;
25
+ prepack?: string;
26
+ postpack?: string;
27
+ publish?: string;
28
+ postpublish?: string;
29
+ preinstall?: string;
30
+ install?: string;
31
+ postinstall?: string;
32
+ preuninstall?: string;
33
+ uninstall?: string;
34
+ postuninstall?: string;
35
+ preversion?: string;
36
+ version?: string;
37
+ postversion?: string;
38
+ pretest?: string;
39
+ test?: string;
40
+ posttest?: string;
41
+ prestop?: string;
42
+ stop?: string;
43
+ poststop?: string;
44
+ prestart?: string;
45
+ start?: string;
46
+ poststart?: string;
47
+ prerestart?: string;
48
+ restart?: string;
49
+ postrestart?: string;
50
+ } & Partial<Record<string, string>>;
51
+ type Dependency = Partial<Record<string, string>>;
52
+ type DependencyOverrides = {
53
+ [packageName in string]: string | undefined | DependencyOverrides;
54
+ };
55
+ type DevEngineDependency = {
56
+ name: string;
57
+ version?: string;
58
+ onFail?: 'ignore' | 'warn' | 'error' | 'download';
59
+ };
60
+ type ExportConditions = {
61
+ [condition: string]: Exports;
62
+ };
63
+ type Exports = null | string | Array<string | ExportConditions> | ExportConditions;
64
+ type Imports = {
65
+ [key: `#${string}`]: Exports;
66
+ };
67
+ type NonStandardEntryPoints = {
68
+ module?: string;
69
+ esnext?: string | {
70
+ [moduleName: string]: string | undefined;
71
+ main?: string;
72
+ browser?: string;
73
+ };
74
+ browser?: string | Partial<Record<string, string | false>>;
75
+ sideEffects?: boolean | string[];
76
+ };
77
+ type TypeScriptConfiguration = {
78
+ types?: string;
79
+ typesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>;
80
+ typings?: string;
81
+ };
82
+ type WorkspaceConfig = {
83
+ packages?: string[];
84
+ nohoist?: string[];
85
+ };
86
+ type YarnConfiguration = {
87
+ flat?: boolean;
88
+ resolutions?: Dependency;
89
+ };
90
+ type JSPMConfiguration = {
91
+ jspm?: PackageJson;
92
+ };
93
+ type PublishConfig = {
94
+ [additionalProperties: string]: JsonValue | undefined;
95
+ access?: 'public' | 'restricted';
96
+ registry?: string;
97
+ tag?: string;
98
+ };
99
+ type NodeJsStandard = {
100
+ packageManager?: string;
101
+ };
102
+ type PackageJsonStandard = {
103
+ name?: string;
104
+ version?: string;
105
+ description?: string;
106
+ keywords?: string[];
107
+ homepage?: LiteralUnion<'.', string>;
108
+ bugs?: BugsLocation;
109
+ license?: string;
110
+ licenses?: Array<{
111
+ type?: string;
112
+ url?: string;
113
+ }>;
114
+ author?: Person;
115
+ contributors?: Person[];
116
+ maintainers?: Person[];
117
+ files?: string[];
118
+ type?: 'module' | 'commonjs';
119
+ main?: string;
120
+ exports?: Exports;
121
+ imports?: Imports;
122
+ bin?: string | Partial<Record<string, string>>;
123
+ man?: string | string[];
124
+ directories?: DirectoryLocations;
125
+ repository?: string | {
126
+ type: string;
127
+ url: string;
128
+ directory?: string;
129
+ };
130
+ scripts?: Scripts;
131
+ config?: JsonObject;
132
+ dependencies?: Dependency;
133
+ devDependencies?: Dependency;
134
+ optionalDependencies?: Dependency;
135
+ peerDependencies?: Dependency;
136
+ peerDependenciesMeta?: Partial<Record<string, {
137
+ optional: true;
138
+ }>>;
139
+ bundledDependencies?: string[];
140
+ bundleDependencies?: string[];
141
+ overrides?: DependencyOverrides;
142
+ engines?: {
143
+ [EngineName in LiteralUnion<'npm' | 'node', string>]?: string;
144
+ };
145
+ engineStrict?: boolean;
146
+ os?: Array<LiteralUnion<'aix' | 'darwin' | 'freebsd' | 'linux' | 'openbsd' | 'sunos' | 'win32' | '!aix' | '!darwin' | '!freebsd' | '!linux' | '!openbsd' | '!sunos' | '!win32', string>>;
147
+ cpu?: Array<LiteralUnion<'arm' | 'arm64' | 'ia32' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 's390' | 's390x' | 'x32' | 'x64' | '!arm' | '!arm64' | '!ia32' | '!mips' | '!mipsel' | '!ppc' | '!ppc64' | '!s390' | '!s390x' | '!x32' | '!x64', string>>;
148
+ devEngines?: {
149
+ os?: DevEngineDependency | DevEngineDependency[];
150
+ cpu?: DevEngineDependency | DevEngineDependency[];
151
+ libc?: DevEngineDependency | DevEngineDependency[];
152
+ runtime?: DevEngineDependency | DevEngineDependency[];
153
+ packageManager?: DevEngineDependency | DevEngineDependency[];
154
+ };
155
+ preferGlobal?: boolean;
156
+ private?: boolean;
157
+ publishConfig?: PublishConfig;
158
+ funding?: string | {
159
+ type?: LiteralUnion<'github' | 'opencollective' | 'patreon' | 'individual' | 'foundation' | 'corporation', string>;
160
+ url: string;
161
+ };
162
+ workspaces?: string[] | WorkspaceConfig;
163
+ };
164
+ /**
165
+ * Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also
166
+ * includes types for fields used by other popular projects, like TypeScript and Yarn.
167
+ *
168
+ * Copied from the `PackageJson` type in the `type-fest` package so that this package's public types
169
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
170
+ *
171
+ * @category File
172
+ * @category Package : @augment-vir/common
173
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
174
+ */
175
+ export type PackageJson = JsonObject & NodeJsStandard & PackageJsonStandard & NonStandardEntryPoints & TypeScriptConfiguration & YarnConfiguration & JSPMConfiguration;
176
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ import { type BuiltIns, type HasMultipleCallSignatures } from './built-in-type.js';
2
+ import { type IsNever } from './type-checks.js';
3
+ /**
4
+ * Options for {@link PartialDeep}.
5
+ *
6
+ * Copied from the `PartialDeepOptions` type in the `type-fest` package so that this package's
7
+ * public types do not depend on `type-fest` (see the note in `type-checks.ts`).
8
+ *
9
+ * @category Object
10
+ * @category Package : @augment-vir/common
11
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
12
+ */
13
+ export type PartialDeepOptions = {
14
+ /**
15
+ * Whether to affect the individual elements of arrays and tuples.
16
+ *
17
+ * @default false
18
+ */
19
+ readonly recurseIntoArrays?: boolean;
20
+ /**
21
+ * Allows `undefined` values in non-tuple arrays.
22
+ *
23
+ * @default false
24
+ */
25
+ readonly allowUndefinedInNonTupleArrays?: boolean;
26
+ };
27
+ type PartialMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & Map<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
28
+ type PartialSetDeep<T, Options extends PartialDeepOptions> = {} & Set<PartialDeep<T, Options>>;
29
+ type PartialReadonlyMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & ReadonlyMap<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
30
+ type PartialReadonlySetDeep<T, Options extends PartialDeepOptions> = {} & ReadonlySet<PartialDeep<T, Options>>;
31
+ type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOptions> = {
32
+ [KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>;
33
+ };
34
+ /**
35
+ * Create a deeply optional version of another type. Use `Partial<T>` if you only need one level
36
+ * deep.
37
+ *
38
+ * Copied from the `PartialDeep` type in the `type-fest` package so that this package's public types
39
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
40
+ *
41
+ * @category Object
42
+ * @category Package : @augment-vir/common
43
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
44
+ */
45
+ export type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIns | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends (...arguments_: any[]) => unknown ? IsNever<keyof T> extends true ? T : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep<T, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> ? Options extends {
46
+ recurseIntoArrays: true;
47
+ } ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<PartialDeep<Options extends {
48
+ allowUndefinedInNonTupleArrays: true;
49
+ } ? ItemType | undefined : ItemType, Options>> : Array<PartialDeep<Options extends {
50
+ allowUndefinedInNonTupleArrays: true;
51
+ } ? ItemType | undefined : ItemType, Options>> : PartialObjectDeep<T, Options> : T : PartialObjectDeep<T, Options> : unknown;
52
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
3
+ *
4
+ * Copied from the `Primitive` type in the `type-fest` package so that this package's public types
5
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
6
+ *
7
+ * @category Type
8
+ * @category Package : @augment-vir/common
9
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
10
+ */
11
+ export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Create a type that represents either the value or the value wrapped in `PromiseLike`.
3
+ *
4
+ * Copied from the `Promisable` type in the `type-fest` package so that this package's public types
5
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
6
+ *
7
+ * @category Async
8
+ * @category Package : @augment-vir/common
9
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
10
+ */
11
+ export type Promisable<T> = T | PromiseLike<T>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import { type BuiltIns, type HasMultipleCallSignatures } from './built-in-type.js';
2
+ type ReadonlyMapDeep<KeyType, ValueType> = {} & Readonly<ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>>>;
3
+ type ReadonlySetDeep<ItemType> = {} & Readonly<ReadonlySet<ReadonlyDeep<ItemType>>>;
4
+ type ReadonlyObjectDeep<ObjectType extends object> = {
5
+ readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>;
6
+ };
7
+ /**
8
+ * Create a deeply immutable version of another type.
9
+ *
10
+ * Copied from the `ReadonlyDeep` type in the `type-fest` package so that this package's public
11
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
12
+ *
13
+ * @category Object
14
+ * @category Package : @augment-vir/common
15
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
16
+ */
17
+ export type ReadonlyDeep<T> = T extends BuiltIns ? T : T extends new (...arguments_: any[]) => unknown ? T : T extends (...arguments_: any[]) => unknown ? {} extends ReadonlyObjectDeep<T> ? T : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & ReadonlyObjectDeep<T> : T extends Readonly<ReadonlyMap<infer KeyType, infer ValueType>> ? ReadonlyMapDeep<KeyType, ValueType> : T extends Readonly<ReadonlySet<infer ItemType>> ? ReadonlySetDeep<ItemType> : T extends readonly [] | readonly [...never[]] ? readonly [] : T extends readonly [
18
+ infer U,
19
+ ...infer V
20
+ ] ? readonly [
21
+ ReadonlyDeep<U>,
22
+ ...ReadonlyDeep<V>
23
+ ] : T extends readonly [
24
+ ...infer U,
25
+ infer V
26
+ ] ? readonly [
27
+ ...ReadonlyDeep<U>,
28
+ ReadonlyDeep<V>
29
+ ] : T extends ReadonlyArray<infer ItemType> ? ReadonlyArray<ReadonlyDeep<ItemType>> : T extends object ? ReadonlyObjectDeep<T> : unknown;
30
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { type IsAny, type IsEqual } from './type-checks.js';
2
+ type IsReadonlyKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends unknown ? Type extends unknown ? IsEqual<{
3
+ [K in Key]: Type[Key];
4
+ }, {
5
+ readonly [K in Key]: Type[Key];
6
+ }> : never : never;
7
+ /**
8
+ * Extract all readonly keys from the given type.
9
+ *
10
+ * Copied from the `ReadonlyKeysOf` type in the `type-fest` package so that this package's public
11
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
12
+ *
13
+ * @category Object
14
+ * @category Package : @augment-vir/common
15
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
16
+ */
17
+ export type ReadonlyKeysOf<Type extends object> = Type extends unknown ? keyof {
18
+ [Key in keyof Type as IsReadonlyKeyOf<Type, Key> extends false ? never : Key]: never;
19
+ } & keyof Type : never;
20
+ export {};
@@ -0,0 +1 @@
1
+ export {};