@esposter/shared 2.19.2 → 2.20.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.
- package/dist/index.d.ts +1211 -134
- package/dist/index.js +118 -216
- package/package.json +8 -6
package/dist/index.d.ts
CHANGED
|
@@ -64,7 +64,67 @@ declare const RoutePath: {
|
|
|
64
64
|
};
|
|
65
65
|
type RoutePath = typeof RoutePath;
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region
|
|
67
|
+
//#region src/util/types/GetProperties.d.ts
|
|
68
|
+
type GetProperties<T, P extends string = "", D extends unknown[] = [unknown, unknown, unknown, unknown, unknown], R extends boolean = true> = [T] extends [never] ? never : D extends [] ? never : NonNullable<T> extends infer O ? O extends unknown[] ? GetArrayProps<O, P, D, R> : O extends object ? GetObjectProps<O, P, D, R> : GetPrimitiveProps<O, P, D, R> : never;
|
|
69
|
+
type GetArrayProps<T extends unknown[], P extends string, D extends unknown[], R extends boolean> = (D extends [unknown, ...infer Rest] ? GetProperties<T[number], R extends true ? `${P}[number]` : `${P}.[number]`, Rest, false> : never) | {
|
|
70
|
+
path: R extends true ? "length" : `${P}.length`;
|
|
71
|
+
value: T["length"];
|
|
72
|
+
};
|
|
73
|
+
type GetObjectProps<T, P extends string, D extends unknown[], R extends boolean> = { [K in keyof KnownKeys<T> & (number | string)]: K extends `${number}` ? never : NonNullable<T[K]> extends Function ? never : (D extends [unknown, ...infer Rest] ? GetProperties<T[K], R extends true ? `${K}` : `${P}.${K}`, Rest, false> : never) | {
|
|
74
|
+
path: R extends true ? `${K}` : `${P}.${K}`;
|
|
75
|
+
value: T[K];
|
|
76
|
+
} }[keyof KnownKeys<T> & (number | string)];
|
|
77
|
+
type GetPrimitiveProps<T, P extends string, D extends unknown[], R extends boolean> = T extends string ? {
|
|
78
|
+
path: R extends true ? "length" : `${P}.length`;
|
|
79
|
+
value: number;
|
|
80
|
+
} : T extends symbol ? (D extends [unknown, ...infer Rest] ? GetProperties<string | undefined, R extends true ? "description" : `${P}.description`, Rest, false> : never) | {
|
|
81
|
+
path: R extends true ? "description" : `${P}.description`;
|
|
82
|
+
value: string | undefined;
|
|
83
|
+
} : never;
|
|
84
|
+
type KnownKeys<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/util/types/GetPaths.d.ts
|
|
87
|
+
type GetPaths<T> = GetProperties<T> extends infer U ? (U extends {
|
|
88
|
+
path: infer Path;
|
|
89
|
+
} ? Path : never) : never;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/util/types/PropertyNames.d.ts
|
|
92
|
+
type PropertyNames<T> = { [P in GetPaths<T>]: P };
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/models/shared/ItemEntityType.d.ts
|
|
95
|
+
interface ItemEntityType<T extends string> {
|
|
96
|
+
type: T;
|
|
97
|
+
}
|
|
98
|
+
declare const ItemEntityTypePropertyNames: PropertyNames<ItemEntityType<string>>;
|
|
99
|
+
declare const createItemEntityTypeSchema: <T extends z.ZodType<string>>(schema: T) => z.ZodObject<{
|
|
100
|
+
type: T;
|
|
101
|
+
}>;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/models/shared/ItemMetadata.d.ts
|
|
104
|
+
declare class ItemMetadata {
|
|
105
|
+
createdAt: Date;
|
|
106
|
+
deletedAt: Date | null;
|
|
107
|
+
updatedAt: Date;
|
|
108
|
+
}
|
|
109
|
+
declare const ItemMetadataPropertyNames: PropertyNames<ItemMetadata>;
|
|
110
|
+
declare const itemMetadataSchema: z.ZodObject<{
|
|
111
|
+
createdAt: z.ZodDate;
|
|
112
|
+
deletedAt: z.ZodNullable<z.ZodDate>;
|
|
113
|
+
updatedAt: z.ZodDate;
|
|
114
|
+
}>;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/models/shared/Serializable.d.ts
|
|
117
|
+
declare abstract class Serializable {
|
|
118
|
+
toJSON(): this;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/models/shared/TakeOne.d.ts
|
|
122
|
+
interface TakeOne {
|
|
123
|
+
<T extends readonly unknown[]>(values: T, index?: number): T[number];
|
|
124
|
+
<T extends Record<PropertyKey, unknown>>(values: T, index: keyof T): T[keyof T];
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/primitive.d.ts
|
|
68
128
|
/**
|
|
69
129
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
70
130
|
|
|
@@ -72,7 +132,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
72
132
|
*/
|
|
73
133
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
74
134
|
//#endregion
|
|
75
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
135
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/basic.d.ts
|
|
76
136
|
/**
|
|
77
137
|
Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
78
138
|
|
|
@@ -83,7 +143,7 @@ type Class<T, Arguments extends unknown[] = any[]> = {
|
|
|
83
143
|
new (...arguments_: Arguments): T;
|
|
84
144
|
};
|
|
85
145
|
//#endregion
|
|
86
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
146
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-any.d.ts
|
|
87
147
|
/**
|
|
88
148
|
Returns a boolean for whether the given type is `any`.
|
|
89
149
|
|
|
@@ -114,7 +174,7 @@ const anyA = get(anyObject, 'a');
|
|
|
114
174
|
*/
|
|
115
175
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
116
176
|
//#endregion
|
|
117
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
177
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
118
178
|
/**
|
|
119
179
|
Returns a boolean for whether the given key is an optional key of type.
|
|
120
180
|
|
|
@@ -157,7 +217,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
157
217
|
*/
|
|
158
218
|
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;
|
|
159
219
|
//#endregion
|
|
160
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
220
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
161
221
|
/**
|
|
162
222
|
Extract all optional keys from the given type.
|
|
163
223
|
|
|
@@ -195,7 +255,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
|
|
|
195
255
|
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
196
256
|
: never;
|
|
197
257
|
//#endregion
|
|
198
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
258
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
199
259
|
/**
|
|
200
260
|
Extract all required keys from the given type.
|
|
201
261
|
|
|
@@ -229,7 +289,7 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
|
229
289
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
230
290
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
231
291
|
//#endregion
|
|
232
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
292
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-never.d.ts
|
|
233
293
|
/**
|
|
234
294
|
Returns a boolean for whether the given type is `never`.
|
|
235
295
|
|
|
@@ -285,7 +345,7 @@ type B = IsTrueFixed<never>;
|
|
|
285
345
|
*/
|
|
286
346
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
287
347
|
//#endregion
|
|
288
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
348
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/if.d.ts
|
|
289
349
|
/**
|
|
290
350
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
291
351
|
|
|
@@ -380,25 +440,445 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
380
440
|
*/
|
|
381
441
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
382
442
|
//#endregion
|
|
383
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
443
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/unknown-array.d.ts
|
|
444
|
+
/**
|
|
445
|
+
Represents an array with `unknown` value.
|
|
446
|
+
|
|
447
|
+
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
|
|
448
|
+
|
|
449
|
+
@example
|
|
450
|
+
```
|
|
451
|
+
import type {UnknownArray} from 'type-fest';
|
|
452
|
+
|
|
453
|
+
type IsArray<T> = T extends UnknownArray ? true : false;
|
|
454
|
+
|
|
455
|
+
type A = IsArray<['foo']>;
|
|
456
|
+
//=> true
|
|
457
|
+
|
|
458
|
+
type B = IsArray<readonly number[]>;
|
|
459
|
+
//=> true
|
|
460
|
+
|
|
461
|
+
type C = IsArray<string>;
|
|
462
|
+
//=> false
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
@category Type
|
|
466
|
+
@category Array
|
|
467
|
+
*/
|
|
468
|
+
type UnknownArray = readonly unknown[];
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/type.d.ts
|
|
471
|
+
/**
|
|
472
|
+
Returns a boolean for whether A is false.
|
|
473
|
+
|
|
474
|
+
@example
|
|
475
|
+
```
|
|
476
|
+
type A = Not<true>;
|
|
477
|
+
//=> false
|
|
478
|
+
|
|
479
|
+
type B = Not<false>;
|
|
480
|
+
//=> true
|
|
481
|
+
```
|
|
482
|
+
*/
|
|
483
|
+
type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
|
|
484
|
+
/**
|
|
485
|
+
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
486
|
+
|
|
487
|
+
@example
|
|
488
|
+
```
|
|
489
|
+
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
490
|
+
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
491
|
+
//=> 'VALID'
|
|
492
|
+
|
|
493
|
+
// When `T` is `any` => Returns `IfAny` branch
|
|
494
|
+
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
495
|
+
//=> 'IS_ANY'
|
|
496
|
+
|
|
497
|
+
// When `T` is `never` => Returns `IfNever` branch
|
|
498
|
+
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
499
|
+
//=> 'IS_NEVER'
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
|
|
503
|
+
|
|
504
|
+
@example
|
|
505
|
+
```ts
|
|
506
|
+
import type {StringRepeat} from 'type-fest';
|
|
507
|
+
|
|
508
|
+
type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
|
|
509
|
+
|
|
510
|
+
// The following implementation is not tail recursive
|
|
511
|
+
type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
|
|
512
|
+
|
|
513
|
+
// Hence, instantiations with long strings will fail
|
|
514
|
+
// @ts-expect-error
|
|
515
|
+
type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
|
|
516
|
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
517
|
+
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
518
|
+
|
|
519
|
+
// To fix this, move the recursion into a helper type
|
|
520
|
+
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
|
|
521
|
+
|
|
522
|
+
type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
|
|
523
|
+
|
|
524
|
+
type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
|
|
525
|
+
//=> ''
|
|
526
|
+
```
|
|
527
|
+
*/
|
|
528
|
+
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
|
|
529
|
+
/**
|
|
530
|
+
Indicates the value of `exactOptionalPropertyTypes` compiler option.
|
|
531
|
+
*/
|
|
532
|
+
type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
|
|
533
|
+
//#endregion
|
|
534
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/array.d.ts
|
|
535
|
+
/**
|
|
536
|
+
Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
|
|
537
|
+
|
|
538
|
+
@example
|
|
539
|
+
```
|
|
540
|
+
type A = CollapseRestElement<[string, string, ...number[]]>;
|
|
541
|
+
//=> [string, string, number]
|
|
542
|
+
|
|
543
|
+
type B = CollapseRestElement<[...string[], number, number]>;
|
|
544
|
+
//=> [string, number, number]
|
|
545
|
+
|
|
546
|
+
type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
|
|
547
|
+
//=> [string, string, number | bigint]
|
|
548
|
+
|
|
549
|
+
type D = CollapseRestElement<[string, number]>;
|
|
550
|
+
//=> [string, number]
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
|
|
554
|
+
|
|
555
|
+
@example
|
|
556
|
+
```
|
|
557
|
+
// `exactOptionalPropertyTypes` enabled
|
|
558
|
+
type A = CollapseRestElement<[string?, string?, ...number[]]>;
|
|
559
|
+
//=> [string, string, number]
|
|
560
|
+
|
|
561
|
+
// `exactOptionalPropertyTypes` disabled
|
|
562
|
+
type B = CollapseRestElement<[string?, string?, ...number[]]>;
|
|
563
|
+
//=> [string | undefined, string | undefined, number]
|
|
564
|
+
```
|
|
565
|
+
*/
|
|
566
|
+
type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
|
|
567
|
+
type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
|
|
568
|
+
? keyof TArray & `${number}` extends never // Enters this branch, if `TArray` is empty (e.g., []),
|
|
569
|
+
// or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
|
|
570
|
+
? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
|
|
571
|
+
: TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
|
|
572
|
+
: TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
|
|
573
|
+
: First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
|
|
574
|
+
: never; // Should never happen
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/characters.d.ts
|
|
577
|
+
type Whitespace = '\u{9}' // '\t'
|
|
578
|
+
| '\u{A}' // '\n'
|
|
579
|
+
| '\u{B}' // '\v'
|
|
580
|
+
| '\u{C}' // '\f'
|
|
581
|
+
| '\u{D}' // '\r'
|
|
582
|
+
| '\u{20}' // ' '
|
|
583
|
+
| '\u{85}' | '\u{A0}' | '\u{1680}' | '\u{2000}' | '\u{2001}' | '\u{2002}' | '\u{2003}' | '\u{2004}' | '\u{2005}' | '\u{2006}' | '\u{2007}' | '\u{2008}' | '\u{2009}' | '\u{200A}' | '\u{2028}' | '\u{2029}' | '\u{202F}' | '\u{205F}' | '\u{3000}' | '\u{FEFF}';
|
|
584
|
+
type WordSeparators = '-' | '_' | Whitespace;
|
|
585
|
+
type AsciiPunctuation = '!' | '"' | '#' | '$' | '%' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~';
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region ../../node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
|
|
588
|
+
declare const tag: unique symbol;
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/tagged.d.ts
|
|
591
|
+
// eslint-disable-next-line type-fest/require-exported-types
|
|
592
|
+
type TagContainer<Token> = {
|
|
593
|
+
readonly [tag]: Token;
|
|
594
|
+
};
|
|
595
|
+
type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
|
|
596
|
+
/**
|
|
597
|
+
Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for distinct concepts in your program that should not be interchangeable, even if their runtime values have the same type. (See examples.)
|
|
598
|
+
|
|
599
|
+
A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
|
|
600
|
+
|
|
601
|
+
[Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
|
|
602
|
+
|
|
603
|
+
A tag's name is usually a string (and must be a string, number, or symbol), but each application of a tag can also contain an arbitrary type as its "metadata". See {@link GetTagMetadata} for examples and explanation.
|
|
604
|
+
|
|
605
|
+
A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
|
|
606
|
+
- the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
|
|
607
|
+
- `A` contains at least all the tags `B` has;
|
|
608
|
+
- and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
|
|
609
|
+
|
|
610
|
+
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
|
|
611
|
+
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
612
|
+
- [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
|
|
613
|
+
- [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
|
|
614
|
+
|
|
615
|
+
@example
|
|
616
|
+
```
|
|
617
|
+
import type {Tagged} from 'type-fest';
|
|
618
|
+
|
|
619
|
+
type AccountNumber = Tagged<number, 'AccountNumber'>;
|
|
620
|
+
type AccountBalance = Tagged<number, 'AccountBalance'>;
|
|
621
|
+
|
|
622
|
+
function createAccountNumber(): AccountNumber {
|
|
623
|
+
// As you can see, casting from a `number` (the underlying type being tagged) is allowed.
|
|
624
|
+
return 2 as AccountNumber;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
|
|
628
|
+
|
|
629
|
+
// This will compile successfully.
|
|
630
|
+
getMoneyForAccount(createAccountNumber());
|
|
631
|
+
|
|
632
|
+
// But this won't, because it has to be explicitly passed as an `AccountNumber` type!
|
|
633
|
+
// Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
|
|
634
|
+
// @ts-expect-error
|
|
635
|
+
getMoneyForAccount(2);
|
|
636
|
+
|
|
637
|
+
// You can also use tagged values like their underlying, untagged type.
|
|
638
|
+
// I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
|
|
639
|
+
// In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
|
|
640
|
+
const accountNumber = createAccountNumber() + 2;
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
@example
|
|
644
|
+
```
|
|
645
|
+
import type {Tagged} from 'type-fest';
|
|
646
|
+
|
|
647
|
+
// You can apply multiple tags to a type by using `Tagged` repeatedly.
|
|
648
|
+
type Url = Tagged<string, 'URL'>;
|
|
649
|
+
type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
|
|
650
|
+
|
|
651
|
+
// You can also pass a union of tag names, so this is equivalent to the above, although it doesn't give you the ability to assign distinct metadata to each tag.
|
|
652
|
+
type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
@category Type
|
|
656
|
+
*/
|
|
657
|
+
type Tagged<Type, TagName extends PropertyKey, TagMetadata = never> = Type & Tag<TagName, TagMetadata>;
|
|
658
|
+
/**
|
|
659
|
+
Revert a tagged type back to its original type by removing all tags.
|
|
660
|
+
|
|
661
|
+
Why is this necessary?
|
|
662
|
+
|
|
663
|
+
1. Use a `Tagged` type as object keys
|
|
664
|
+
2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
|
|
665
|
+
|
|
666
|
+
@example
|
|
667
|
+
```
|
|
668
|
+
import type {Tagged, UnwrapTagged} from 'type-fest';
|
|
669
|
+
|
|
670
|
+
type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
|
|
671
|
+
|
|
672
|
+
const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
|
|
673
|
+
SAVINGS: 99,
|
|
674
|
+
CHECKING: 0.1,
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
// Without UnwrapTagged, the following expression would throw a type error.
|
|
678
|
+
const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
|
|
679
|
+
|
|
680
|
+
// Attempting to pass a non-Tagged type to UnwrapTagged will raise a type error.
|
|
681
|
+
// @ts-expect-error
|
|
682
|
+
type WontWork = UnwrapTagged<string>;
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
@category Type
|
|
686
|
+
*/
|
|
687
|
+
type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
|
|
688
|
+
type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never }[keyof T[typeof tag]] : T;
|
|
689
|
+
/**
|
|
690
|
+
Note: The `Opaque` type is deprecated in favor of `Tagged`.
|
|
691
|
+
|
|
692
|
+
Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for runtime values that would otherwise have the same type. (See examples.)
|
|
693
|
+
|
|
694
|
+
The generic type parameters can be anything.
|
|
695
|
+
|
|
696
|
+
Note that `Opaque` is somewhat of a misnomer here, in that, unlike [some alternative implementations](https://github.com/microsoft/TypeScript/issues/4895#issuecomment-425132582), the original, untagged type is not actually hidden. (E.g., functions that accept the untagged type can still be called with the "opaque" version -- but not vice-versa.)
|
|
697
|
+
|
|
698
|
+
Also note that this implementation is limited to a single tag. If you want to allow multiple tags, use `Tagged` instead.
|
|
699
|
+
|
|
700
|
+
[Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
|
|
701
|
+
|
|
702
|
+
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
|
|
703
|
+
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
704
|
+
- [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
|
|
705
|
+
- [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
|
|
706
|
+
|
|
707
|
+
@example
|
|
708
|
+
```
|
|
709
|
+
import type {Opaque} from 'type-fest';
|
|
710
|
+
|
|
711
|
+
type AccountNumber = Opaque<number, 'AccountNumber'>;
|
|
712
|
+
type AccountBalance = Opaque<number, 'AccountBalance'>;
|
|
713
|
+
|
|
714
|
+
// The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
|
|
715
|
+
type ThingOne = Opaque<string>;
|
|
716
|
+
type ThingTwo = Opaque<string>;
|
|
717
|
+
|
|
718
|
+
// To the compiler, these types are allowed to be cast to each other as they have the same underlying type. They are both `string & { __opaque__: unknown }`.
|
|
719
|
+
// To avoid this behaviour, you would instead pass the "Token" parameter, like so.
|
|
720
|
+
type NewThingOne = Opaque<string, 'ThingOne'>;
|
|
721
|
+
type NewThingTwo = Opaque<string, 'ThingTwo'>;
|
|
722
|
+
|
|
723
|
+
// Now they're completely separate types, so the following will fail to compile.
|
|
724
|
+
function createNewThingOne(): NewThingOne {
|
|
725
|
+
// As you can see, casting from a string is still allowed. However, you may not cast NewThingOne to NewThingTwo, and vice versa.
|
|
726
|
+
return 'new thing one' as NewThingOne;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// This will fail to compile, as they are fundamentally different types.
|
|
730
|
+
// @ts-expect-error
|
|
731
|
+
const thingTwo = createNewThingOne() as NewThingTwo;
|
|
732
|
+
|
|
733
|
+
// Here's another example of opaque typing.
|
|
734
|
+
function createAccountNumber(): AccountNumber {
|
|
735
|
+
return 2 as AccountNumber;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
|
|
739
|
+
|
|
740
|
+
// This will compile successfully.
|
|
741
|
+
getMoneyForAccount(createAccountNumber());
|
|
742
|
+
|
|
743
|
+
// But this won't, because it has to be explicitly passed as an `AccountNumber` type.
|
|
744
|
+
// @ts-expect-error
|
|
745
|
+
getMoneyForAccount(2);
|
|
746
|
+
|
|
747
|
+
// You can use opaque values like they aren't opaque too.
|
|
748
|
+
const accountNumber = createAccountNumber();
|
|
749
|
+
|
|
750
|
+
// This will compile successfully.
|
|
751
|
+
const newAccountNumber = accountNumber + 2;
|
|
752
|
+
|
|
753
|
+
// As a side note, you can (and should) use recursive types for your opaque types to make them stronger and hopefully easier to type.
|
|
754
|
+
type Person = {
|
|
755
|
+
id: Opaque<number, Person>;
|
|
756
|
+
name: string;
|
|
757
|
+
};
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
@category Type
|
|
761
|
+
@deprecated Use {@link Tagged} instead
|
|
762
|
+
*/
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-literal.d.ts
|
|
765
|
+
/**
|
|
766
|
+
Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
767
|
+
|
|
768
|
+
Useful for:
|
|
769
|
+
- providing strongly-typed string manipulation functions
|
|
770
|
+
- constraining strings to be a string literal
|
|
771
|
+
- type utilities, such as when constructing parsers and ASTs
|
|
772
|
+
|
|
773
|
+
The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
774
|
+
|
|
775
|
+
@example
|
|
776
|
+
```
|
|
777
|
+
import type {IsStringLiteral} from 'type-fest';
|
|
778
|
+
|
|
779
|
+
type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
|
|
780
|
+
|
|
781
|
+
// https://github.com/yankeeinlondon/native-dash/blob/master/src/capitalize.ts
|
|
782
|
+
function capitalize<T extends Readonly<string>>(input: T): CapitalizedString<T> {
|
|
783
|
+
return (input.slice(0, 1).toUpperCase() + input.slice(1)) as CapitalizedString<T>;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const output = capitalize('hello, world!');
|
|
787
|
+
//=> 'Hello, world!'
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
@example
|
|
791
|
+
```
|
|
792
|
+
// String types with infinite set of possible values return `false`.
|
|
793
|
+
|
|
794
|
+
import type {IsStringLiteral} from 'type-fest';
|
|
795
|
+
|
|
796
|
+
type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
|
|
797
|
+
//=> false
|
|
798
|
+
|
|
799
|
+
type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
|
|
800
|
+
//=> false
|
|
801
|
+
|
|
802
|
+
// This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
|
|
803
|
+
|
|
804
|
+
type Length<S extends string, Counter extends never[] = []> =
|
|
805
|
+
IsStringLiteral<S> extends false
|
|
806
|
+
? number // return `number` for infinite string types
|
|
807
|
+
: S extends `${string}${infer Tail}`
|
|
808
|
+
? Length<Tail, [...Counter, never]>
|
|
809
|
+
: Counter['length'];
|
|
810
|
+
|
|
811
|
+
type L1 = Length<Lowercase<string>>;
|
|
812
|
+
//=> number
|
|
813
|
+
|
|
814
|
+
type L2 = Length<`${number}`>;
|
|
815
|
+
//=> number
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
@category Type Guard
|
|
819
|
+
@category Utilities
|
|
820
|
+
*/
|
|
821
|
+
type IsStringLiteral<S> = IfNotAnyOrNever<S, _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>, false, false>;
|
|
822
|
+
type _IsStringLiteral<S> = // If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
|
|
823
|
+
// and since `{}` extends index signatures, the result becomes `false`.
|
|
824
|
+
S extends string ? {} extends Record<S, never> ? false : true : false;
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/trim.d.ts
|
|
827
|
+
/**
|
|
828
|
+
Remove spaces from the left side.
|
|
829
|
+
*/
|
|
830
|
+
type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
|
|
831
|
+
/**
|
|
832
|
+
Remove spaces from the right side.
|
|
833
|
+
*/
|
|
834
|
+
type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
|
|
384
835
|
/**
|
|
385
|
-
|
|
836
|
+
Remove leading and trailing spaces from a string.
|
|
837
|
+
|
|
838
|
+
@example
|
|
839
|
+
```
|
|
840
|
+
import type {Trim} from 'type-fest';
|
|
841
|
+
|
|
842
|
+
type Example = Trim<' foo '>;
|
|
843
|
+
//=> 'foo'
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
@category String
|
|
847
|
+
@category Template literal
|
|
386
848
|
*/
|
|
387
|
-
type
|
|
849
|
+
type Trim<V extends string> = TrimLeft<TrimRight<V>>;
|
|
850
|
+
//#endregion
|
|
851
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/string.d.ts
|
|
388
852
|
/**
|
|
389
|
-
|
|
853
|
+
Returns a boolean for whether the given string `S` starts with the given string `SearchString`.
|
|
854
|
+
|
|
855
|
+
@example
|
|
856
|
+
```
|
|
857
|
+
type A = StartsWith<'abcde', 'abc'>;
|
|
858
|
+
//=> true
|
|
390
859
|
|
|
391
|
-
|
|
860
|
+
type B = StartsWith<'abcde', 'bc'>;
|
|
861
|
+
//=> false
|
|
862
|
+
|
|
863
|
+
type C = StartsWith<string, 'bc'>;
|
|
864
|
+
//=> never
|
|
865
|
+
|
|
866
|
+
type D = StartsWith<'abcde', string>;
|
|
867
|
+
//=> never
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
@category String
|
|
871
|
+
@category Template literal
|
|
872
|
+
*/
|
|
873
|
+
type StartsWith<S extends string, SearchString extends string> = string extends S | SearchString ? never : S extends `${SearchString}${infer T}` ? true : false;
|
|
874
|
+
/**
|
|
875
|
+
Returns a boolean for whether the string is numeric.
|
|
392
876
|
|
|
393
|
-
|
|
394
|
-
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
877
|
+
This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
|
|
395
878
|
*/
|
|
396
|
-
type
|
|
397
|
-
(...arguments_: infer A): unknown;
|
|
398
|
-
(...arguments_: infer B): unknown;
|
|
399
|
-
} ? B extends A ? A extends B ? false : true : true : false;
|
|
879
|
+
type IsNumeric<T extends string> = T extends `${number}` ? Trim<T> extends T ? true : false : false;
|
|
400
880
|
//#endregion
|
|
401
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
881
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/simplify.d.ts
|
|
402
882
|
/**
|
|
403
883
|
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
404
884
|
|
|
@@ -459,7 +939,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
459
939
|
*/
|
|
460
940
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
461
941
|
//#endregion
|
|
462
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
942
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-equal.d.ts
|
|
463
943
|
/**
|
|
464
944
|
Returns a boolean for whether the two given types are equal.
|
|
465
945
|
|
|
@@ -490,7 +970,7 @@ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false
|
|
|
490
970
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
491
971
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
492
972
|
//#endregion
|
|
493
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
973
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
494
974
|
/**
|
|
495
975
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
496
976
|
|
|
@@ -584,7 +1064,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
584
1064
|
*/
|
|
585
1065
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
586
1066
|
//#endregion
|
|
587
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1067
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
588
1068
|
/**
|
|
589
1069
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
590
1070
|
|
|
@@ -632,12 +1112,37 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
632
1112
|
*/
|
|
633
1113
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
634
1114
|
//#endregion
|
|
635
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1115
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/merge.d.ts
|
|
636
1116
|
// Merges two objects without worrying about index signatures.
|
|
637
1117
|
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
|
|
638
1118
|
/**
|
|
639
1119
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
640
1120
|
|
|
1121
|
+
This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`.
|
|
1122
|
+
|
|
1123
|
+
@example
|
|
1124
|
+
```
|
|
1125
|
+
import type {Merge} from 'type-fest';
|
|
1126
|
+
|
|
1127
|
+
type Foo = {
|
|
1128
|
+
a: string;
|
|
1129
|
+
b: number;
|
|
1130
|
+
};
|
|
1131
|
+
|
|
1132
|
+
type Bar = {
|
|
1133
|
+
a: number; // Conflicts with Foo['a']
|
|
1134
|
+
c: boolean;
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
// With `&`, `a` becomes `string & number` which is `never`. Not what you want.
|
|
1138
|
+
type WithIntersection = (Foo & Bar)['a'];
|
|
1139
|
+
//=> never
|
|
1140
|
+
|
|
1141
|
+
// With `Merge`, `a` is cleanly overridden to `number`.
|
|
1142
|
+
type WithMerge = Merge<Foo, Bar>['a'];
|
|
1143
|
+
//=> number
|
|
1144
|
+
```
|
|
1145
|
+
|
|
641
1146
|
@example
|
|
642
1147
|
```
|
|
643
1148
|
import type {Merge} from 'type-fest';
|
|
@@ -679,7 +1184,7 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
|
|
|
679
1184
|
// Should never happen
|
|
680
1185
|
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
681
1186
|
//#endregion
|
|
682
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1187
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/object.d.ts
|
|
683
1188
|
/**
|
|
684
1189
|
Merges user specified options with default options.
|
|
685
1190
|
|
|
@@ -733,19 +1238,367 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
733
1238
|
```
|
|
734
1239
|
*/
|
|
735
1240
|
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
736
|
-
|
|
737
|
-
//#region ../../node_modules/.pnpm/type-fest@5.4.3/node_modules/type-fest/source/except.d.ts
|
|
1241
|
+
// `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
738
1242
|
/**
|
|
739
|
-
|
|
1243
|
+
Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
|
|
740
1244
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
1245
|
+
Note: This doesn't collapse literals within tagged types. For example, `CollapseLiterals<Tagged<'foo' | (string & {}), 'Tag'>>` returns `("foo" & Tag<"Tag", never>) | (string & Tag<"Tag", never>)` and not `string & Tag<"Tag", never>`.
|
|
1246
|
+
|
|
1247
|
+
Use-case: For collapsing unions created using {@link LiteralUnion}.
|
|
744
1248
|
|
|
745
1249
|
@example
|
|
746
1250
|
```
|
|
747
|
-
type
|
|
748
|
-
|
|
1251
|
+
import type {LiteralUnion} from 'type-fest';
|
|
1252
|
+
|
|
1253
|
+
type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
|
|
1254
|
+
//=> string
|
|
1255
|
+
|
|
1256
|
+
type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
|
|
1257
|
+
//=> number
|
|
1258
|
+
|
|
1259
|
+
type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
|
|
1260
|
+
//=> `on${string}`
|
|
1261
|
+
|
|
1262
|
+
type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
|
|
1263
|
+
//=> 'click' | 'change' | `on${string}`
|
|
1264
|
+
|
|
1265
|
+
type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
|
|
1266
|
+
//=> string | null | undefined
|
|
1267
|
+
```
|
|
1268
|
+
*/
|
|
1269
|
+
type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
|
|
1270
|
+
//#endregion
|
|
1271
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/some-extend.d.ts
|
|
1272
|
+
/**
|
|
1273
|
+
@see {@link SomeExtend}
|
|
1274
|
+
*/
|
|
1275
|
+
type SomeExtendOptions = {
|
|
1276
|
+
/**
|
|
1277
|
+
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
1278
|
+
- When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
|
|
1279
|
+
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
1280
|
+
@default true
|
|
1281
|
+
@example
|
|
1282
|
+
```
|
|
1283
|
+
import type {SomeExtend} from 'type-fest';
|
|
1284
|
+
type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
|
|
1285
|
+
//=> false
|
|
1286
|
+
type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
|
|
1287
|
+
//=> true
|
|
1288
|
+
type C = SomeExtend<[1, never], never, {strictNever: true}>;
|
|
1289
|
+
//=> true
|
|
1290
|
+
type D = SomeExtend<[1, never], never, {strictNever: false}>;
|
|
1291
|
+
//=> true
|
|
1292
|
+
type E = SomeExtend<[never], any, {strictNever: true}>;
|
|
1293
|
+
//=> true
|
|
1294
|
+
type F = SomeExtend<[never], any, {strictNever: false}>;
|
|
1295
|
+
//=> true
|
|
1296
|
+
```
|
|
1297
|
+
*/
|
|
1298
|
+
strictNever?: boolean;
|
|
1299
|
+
};
|
|
1300
|
+
type DefaultSomeExtendOptions = {
|
|
1301
|
+
strictNever: true;
|
|
1302
|
+
};
|
|
1303
|
+
/**
|
|
1304
|
+
Returns a boolean for whether some element in an array type extends another type.
|
|
1305
|
+
|
|
1306
|
+
@example
|
|
1307
|
+
```
|
|
1308
|
+
import type {SomeExtend} from 'type-fest';
|
|
1309
|
+
|
|
1310
|
+
type A = SomeExtend<['1', '2', 3], number>;
|
|
1311
|
+
//=> true
|
|
1312
|
+
|
|
1313
|
+
type B = SomeExtend<[1, 2, 3], string>;
|
|
1314
|
+
//=> false
|
|
1315
|
+
|
|
1316
|
+
type C = SomeExtend<[string, number | string], number>;
|
|
1317
|
+
//=> boolean
|
|
1318
|
+
|
|
1319
|
+
type D = SomeExtend<[true, boolean, true], false>;
|
|
1320
|
+
//=> boolean
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
|
|
1324
|
+
|
|
1325
|
+
```
|
|
1326
|
+
// @exactOptionalPropertyTypes: true
|
|
1327
|
+
import type {SomeExtend} from 'type-fest';
|
|
1328
|
+
|
|
1329
|
+
type A = SomeExtend<[1?, 2?, '3'?], string>;
|
|
1330
|
+
//=> true
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
```
|
|
1334
|
+
// @exactOptionalPropertyTypes: false
|
|
1335
|
+
import type {SomeExtend} from 'type-fest';
|
|
1336
|
+
|
|
1337
|
+
type A = SomeExtend<[1?, 2?, '3'?], string>;
|
|
1338
|
+
//=> boolean
|
|
1339
|
+
|
|
1340
|
+
type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
|
|
1341
|
+
//=> true
|
|
1342
|
+
```
|
|
1343
|
+
|
|
1344
|
+
@see {@link SomeExtendOptions}
|
|
1345
|
+
|
|
1346
|
+
@category Utilities
|
|
1347
|
+
@category Array
|
|
1348
|
+
*/
|
|
1349
|
+
type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
|
|
1350
|
+
type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
|
|
1351
|
+
? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
|
|
1352
|
+
//#endregion
|
|
1353
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/or-all.d.ts
|
|
1354
|
+
/**
|
|
1355
|
+
Returns a boolean for whether any of the given elements is `true`.
|
|
1356
|
+
|
|
1357
|
+
Use-cases:
|
|
1358
|
+
- Check if at least one condition in a list of booleans is met.
|
|
1359
|
+
|
|
1360
|
+
@example
|
|
1361
|
+
```
|
|
1362
|
+
import type {OrAll} from 'type-fest';
|
|
1363
|
+
|
|
1364
|
+
type FFT = OrAll<[false, false, true]>;
|
|
1365
|
+
//=> true
|
|
1366
|
+
|
|
1367
|
+
type FFF = OrAll<[false, false, false]>;
|
|
1368
|
+
//=> false
|
|
1369
|
+
```
|
|
1370
|
+
|
|
1371
|
+
Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1372
|
+
For example, `OrAll<[false, boolean]>` expands to `OrAll<[false, true]> | OrAll<[false, false]>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1373
|
+
|
|
1374
|
+
@example
|
|
1375
|
+
```
|
|
1376
|
+
import type {OrAll} from 'type-fest';
|
|
1377
|
+
|
|
1378
|
+
type A = OrAll<[false, boolean]>;
|
|
1379
|
+
//=> boolean
|
|
1380
|
+
|
|
1381
|
+
type B = OrAll<[true, boolean]>;
|
|
1382
|
+
//=> true
|
|
1383
|
+
```
|
|
1384
|
+
|
|
1385
|
+
Note: If `never` is passed as an element, it is treated as `false` and the result is computed accordingly.
|
|
1386
|
+
|
|
1387
|
+
@example
|
|
1388
|
+
```
|
|
1389
|
+
import type {OrAll} from 'type-fest';
|
|
1390
|
+
|
|
1391
|
+
type A = OrAll<[never, never, true]>;
|
|
1392
|
+
//=> true
|
|
1393
|
+
|
|
1394
|
+
type B = OrAll<[never, never, false]>;
|
|
1395
|
+
//=> false
|
|
1396
|
+
|
|
1397
|
+
type C = OrAll<[never, never, never]>;
|
|
1398
|
+
//=> false
|
|
1399
|
+
|
|
1400
|
+
type D = OrAll<[never, never, boolean]>;
|
|
1401
|
+
//=> boolean
|
|
1402
|
+
```
|
|
1403
|
+
|
|
1404
|
+
Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
|
|
1405
|
+
|
|
1406
|
+
@example
|
|
1407
|
+
```
|
|
1408
|
+
import type {OrAll} from 'type-fest';
|
|
1409
|
+
|
|
1410
|
+
type A = OrAll<[false, any]>;
|
|
1411
|
+
//=> boolean
|
|
1412
|
+
|
|
1413
|
+
type B = OrAll<[true, any]>;
|
|
1414
|
+
//=> true
|
|
1415
|
+
```
|
|
1416
|
+
|
|
1417
|
+
Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in an empty tuple. See [Wikipedia: Clause (logic) > Empty clauses](https://en.wikipedia.org/wiki/Clause_(logic)#Empty_clauses:~:text=The%20truth%20evaluation%20of%20an%20empty%20disjunctive%20clause%20is%20always%20false.).
|
|
1418
|
+
|
|
1419
|
+
@see {@link Or}
|
|
1420
|
+
@see {@link AndAll}
|
|
1421
|
+
*/
|
|
1422
|
+
type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
|
|
1423
|
+
//#endregion
|
|
1424
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/or.d.ts
|
|
1425
|
+
/**
|
|
1426
|
+
Returns a boolean for whether either of two given types is true.
|
|
1427
|
+
|
|
1428
|
+
Use-case: Constructing complex conditional types where at least one condition must be satisfied.
|
|
1429
|
+
|
|
1430
|
+
@example
|
|
1431
|
+
```
|
|
1432
|
+
import type {Or} from 'type-fest';
|
|
1433
|
+
|
|
1434
|
+
type TT = Or<true, true>;
|
|
1435
|
+
//=> true
|
|
1436
|
+
|
|
1437
|
+
type TF = Or<true, false>;
|
|
1438
|
+
//=> true
|
|
1439
|
+
|
|
1440
|
+
type FT = Or<false, true>;
|
|
1441
|
+
//=> true
|
|
1442
|
+
|
|
1443
|
+
type FF = Or<false, false>;
|
|
1444
|
+
//=> false
|
|
1445
|
+
```
|
|
1446
|
+
|
|
1447
|
+
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1448
|
+
For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1449
|
+
|
|
1450
|
+
@example
|
|
1451
|
+
```
|
|
1452
|
+
import type {Or} from 'type-fest';
|
|
1453
|
+
|
|
1454
|
+
type A = Or<false, boolean>;
|
|
1455
|
+
//=> boolean
|
|
1456
|
+
|
|
1457
|
+
type B = Or<boolean, false>;
|
|
1458
|
+
//=> boolean
|
|
1459
|
+
|
|
1460
|
+
type C = Or<true, boolean>;
|
|
1461
|
+
//=> true
|
|
1462
|
+
|
|
1463
|
+
type D = Or<boolean, true>;
|
|
1464
|
+
//=> true
|
|
1465
|
+
|
|
1466
|
+
type E = Or<boolean, boolean>;
|
|
1467
|
+
//=> boolean
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
|
|
1471
|
+
|
|
1472
|
+
@example
|
|
1473
|
+
```
|
|
1474
|
+
import type {Or} from 'type-fest';
|
|
1475
|
+
|
|
1476
|
+
type A = Or<true, never>;
|
|
1477
|
+
//=> true
|
|
1478
|
+
|
|
1479
|
+
type B = Or<never, true>;
|
|
1480
|
+
//=> true
|
|
1481
|
+
|
|
1482
|
+
type C = Or<false, never>;
|
|
1483
|
+
//=> false
|
|
1484
|
+
|
|
1485
|
+
type D = Or<never, false>;
|
|
1486
|
+
//=> false
|
|
1487
|
+
|
|
1488
|
+
type E = Or<boolean, never>;
|
|
1489
|
+
//=> boolean
|
|
1490
|
+
|
|
1491
|
+
type F = Or<never, boolean>;
|
|
1492
|
+
//=> boolean
|
|
1493
|
+
|
|
1494
|
+
type G = Or<never, never>;
|
|
1495
|
+
//=> false
|
|
1496
|
+
```
|
|
1497
|
+
|
|
1498
|
+
@see {@link OrAll}
|
|
1499
|
+
@see {@link And}
|
|
1500
|
+
@see {@link Xor}
|
|
1501
|
+
*/
|
|
1502
|
+
type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
|
|
1503
|
+
//#endregion
|
|
1504
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/all-extend.d.ts
|
|
1505
|
+
/**
|
|
1506
|
+
@see {@link AllExtend}
|
|
1507
|
+
*/
|
|
1508
|
+
type AllExtendOptions = {
|
|
1509
|
+
/**
|
|
1510
|
+
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
1511
|
+
- When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
|
|
1512
|
+
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
1513
|
+
@default true
|
|
1514
|
+
@example
|
|
1515
|
+
```
|
|
1516
|
+
import type {AllExtend} from 'type-fest';
|
|
1517
|
+
type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
|
|
1518
|
+
//=> false
|
|
1519
|
+
type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
|
|
1520
|
+
//=> true
|
|
1521
|
+
type C = AllExtend<[never, never], never, {strictNever: true}>;
|
|
1522
|
+
//=> true
|
|
1523
|
+
type D = AllExtend<[never, never], never, {strictNever: false}>;
|
|
1524
|
+
//=> true
|
|
1525
|
+
type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
|
|
1526
|
+
//=> true
|
|
1527
|
+
type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
|
|
1528
|
+
//=> true
|
|
1529
|
+
type G = AllExtend<[never, 1], never, {strictNever: true}>;
|
|
1530
|
+
//=> false
|
|
1531
|
+
type H = AllExtend<[never, 1], never, {strictNever: false}>;
|
|
1532
|
+
//=> false
|
|
1533
|
+
```
|
|
1534
|
+
*/
|
|
1535
|
+
strictNever?: boolean;
|
|
1536
|
+
};
|
|
1537
|
+
type DefaultAllExtendOptions = {
|
|
1538
|
+
strictNever: true;
|
|
1539
|
+
};
|
|
1540
|
+
/**
|
|
1541
|
+
Returns a boolean for whether every element in an array type extends another type.
|
|
1542
|
+
|
|
1543
|
+
@example
|
|
1544
|
+
```
|
|
1545
|
+
import type {AllExtend} from 'type-fest';
|
|
1546
|
+
|
|
1547
|
+
type A = AllExtend<[1, 2, 3], number>;
|
|
1548
|
+
//=> true
|
|
1549
|
+
|
|
1550
|
+
type B = AllExtend<[1, 2, '3'], number>;
|
|
1551
|
+
//=> false
|
|
1552
|
+
|
|
1553
|
+
type C = AllExtend<[number, number | string], number>;
|
|
1554
|
+
//=> boolean
|
|
1555
|
+
|
|
1556
|
+
type D = AllExtend<[true, boolean, true], true>;
|
|
1557
|
+
//=> boolean
|
|
1558
|
+
```
|
|
1559
|
+
|
|
1560
|
+
Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
|
|
1561
|
+
|
|
1562
|
+
```
|
|
1563
|
+
// @exactOptionalPropertyTypes: true
|
|
1564
|
+
import type {AllExtend} from 'type-fest';
|
|
1565
|
+
|
|
1566
|
+
type A = AllExtend<[1?, 2?, 3?], number>;
|
|
1567
|
+
//=> true
|
|
1568
|
+
```
|
|
1569
|
+
|
|
1570
|
+
```
|
|
1571
|
+
// @exactOptionalPropertyTypes: false
|
|
1572
|
+
import type {AllExtend} from 'type-fest';
|
|
1573
|
+
|
|
1574
|
+
type A = AllExtend<[1?, 2?, 3?], number>;
|
|
1575
|
+
//=> boolean
|
|
1576
|
+
|
|
1577
|
+
type B = AllExtend<[1?, 2?, 3?], number | undefined>;
|
|
1578
|
+
//=> true
|
|
1579
|
+
```
|
|
1580
|
+
|
|
1581
|
+
@see {@link AllExtendOptions}
|
|
1582
|
+
|
|
1583
|
+
@category Utilities
|
|
1584
|
+
@category Array
|
|
1585
|
+
*/
|
|
1586
|
+
type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
|
|
1587
|
+
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
|
|
1588
|
+
? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
|
|
1589
|
+
//#endregion
|
|
1590
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/except.d.ts
|
|
1591
|
+
/**
|
|
1592
|
+
Filter out keys from an object.
|
|
1593
|
+
|
|
1594
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
1595
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
1596
|
+
Returns `Key` otherwise.
|
|
1597
|
+
|
|
1598
|
+
@example
|
|
1599
|
+
```
|
|
1600
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
1601
|
+
//=> never
|
|
749
1602
|
```
|
|
750
1603
|
|
|
751
1604
|
@example
|
|
@@ -832,105 +1685,324 @@ type PostPayloadFixed = Except<UserData, 'email'>;
|
|
|
832
1685
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
833
1686
|
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
|
|
834
1687
|
//#endregion
|
|
835
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1688
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-lowercase.d.ts
|
|
836
1689
|
/**
|
|
837
|
-
|
|
1690
|
+
Returns a boolean for whether the given string literal is lowercase.
|
|
838
1691
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
1692
|
+
@example
|
|
1693
|
+
```
|
|
1694
|
+
import type {IsLowercase} from 'type-fest';
|
|
1695
|
+
|
|
1696
|
+
type A = IsLowercase<'abc'>;
|
|
1697
|
+
//=> true
|
|
1698
|
+
|
|
1699
|
+
type B = IsLowercase<'Abc'>;
|
|
1700
|
+
//=> false
|
|
1701
|
+
|
|
1702
|
+
type C = IsLowercase<string>;
|
|
1703
|
+
//=> boolean
|
|
1704
|
+
```
|
|
1705
|
+
*/
|
|
1706
|
+
type IsLowercase<S extends string> = AllExtend<_IsLowercase<S>, true>;
|
|
1707
|
+
/**
|
|
1708
|
+
Loops through each part in the string and returns a boolean array indicating whether each part is lowercase.
|
|
1709
|
+
*/
|
|
1710
|
+
type _IsLowercase<S extends string, Accumulator extends boolean[] = []> = S extends `${infer First}${infer Rest}` ? _IsLowercase<Rest, [...Accumulator, IsLowercaseHelper<First>]> : [...Accumulator, IsLowercaseHelper<S>];
|
|
1711
|
+
/**
|
|
1712
|
+
Returns a boolean for whether an individual part of the string is lowercase.
|
|
1713
|
+
*/
|
|
1714
|
+
type IsLowercaseHelper<S extends string> = S extends Lowercase<string> ? true : S extends Uppercase<string> | Capitalize<string> | `${string}${Uppercase<string>}${string}` ? false : boolean;
|
|
1715
|
+
//#endregion
|
|
1716
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-uppercase.d.ts
|
|
1717
|
+
/**
|
|
1718
|
+
Returns a boolean for whether the given string literal is uppercase.
|
|
842
1719
|
|
|
843
1720
|
@example
|
|
844
1721
|
```
|
|
845
|
-
import type {
|
|
1722
|
+
import type {IsUppercase} from 'type-fest';
|
|
1723
|
+
|
|
1724
|
+
type A = IsUppercase<'ABC'>;
|
|
1725
|
+
//=> true
|
|
846
1726
|
|
|
847
|
-
type
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1727
|
+
type B = IsUppercase<'Abc'>;
|
|
1728
|
+
//=> false
|
|
1729
|
+
|
|
1730
|
+
type C = IsUppercase<string>;
|
|
1731
|
+
//=> boolean
|
|
1732
|
+
```
|
|
1733
|
+
*/
|
|
1734
|
+
type IsUppercase<S extends string> = AllExtend<_IsUppercase<S>, true>;
|
|
1735
|
+
/**
|
|
1736
|
+
Loops through each part in the string and returns a boolean array indicating whether each part is uppercase.
|
|
1737
|
+
*/
|
|
1738
|
+
type _IsUppercase<S extends string, Accumulator extends boolean[] = []> = S extends `${infer First}${infer Rest}` ? _IsUppercase<Rest, [...Accumulator, IsUppercaseHelper<First>]> : [...Accumulator, IsUppercaseHelper<S>];
|
|
1739
|
+
/**
|
|
1740
|
+
Returns a boolean for whether an individual part of the string is uppercase.
|
|
1741
|
+
*/
|
|
1742
|
+
type IsUppercaseHelper<S extends string> = S extends Uppercase<string> ? true : S extends Lowercase<string> | Uncapitalize<string> | `${string}${Lowercase<string>}${string}` ? false : boolean;
|
|
1743
|
+
//#endregion
|
|
1744
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/words.d.ts
|
|
1745
|
+
type SkipEmptyWord<Word extends string> = Word extends '' ? [] : [Word];
|
|
1746
|
+
type RemoveLastCharacter<Sentence extends string, Character extends string> = Sentence extends `${infer LeftSide}${Character}` ? SkipEmptyWord<LeftSide> : never;
|
|
1747
|
+
/**
|
|
1748
|
+
Words options.
|
|
1749
|
+
|
|
1750
|
+
@see {@link Words}
|
|
1751
|
+
*/
|
|
1752
|
+
type WordsOptions = {
|
|
1753
|
+
/**
|
|
1754
|
+
Split on numeric sequence.
|
|
1755
|
+
@default true
|
|
1756
|
+
@example
|
|
1757
|
+
```
|
|
1758
|
+
import type {Words} from 'type-fest';
|
|
1759
|
+
type Example1 = Words<'p2pNetwork', {splitOnNumbers: true}>;
|
|
1760
|
+
//=> ['p', '2', 'p', 'Network']
|
|
1761
|
+
type Example2 = Words<'p2pNetwork', {splitOnNumbers: false}>;
|
|
1762
|
+
//=> ['p2p', 'Network']
|
|
1763
|
+
```
|
|
1764
|
+
*/
|
|
1765
|
+
splitOnNumbers?: boolean;
|
|
1766
|
+
};
|
|
1767
|
+
type _DefaultWordsOptions = {
|
|
1768
|
+
splitOnNumbers: true;
|
|
855
1769
|
};
|
|
1770
|
+
/**
|
|
1771
|
+
Split a string (almost) like Lodash's `_.words()` function.
|
|
856
1772
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
// fontWeight: number | undefined;
|
|
863
|
-
// };
|
|
864
|
-
// autocomplete: boolean;
|
|
865
|
-
// autosave: boolean | undefined;
|
|
866
|
-
// }
|
|
1773
|
+
- Split on each word that begins with a capital letter.
|
|
1774
|
+
- Split on each {@link WordSeparators}.
|
|
1775
|
+
- Split on numeric sequence.
|
|
1776
|
+
|
|
1777
|
+
@example
|
|
867
1778
|
```
|
|
1779
|
+
import type {Words} from 'type-fest';
|
|
868
1780
|
|
|
869
|
-
|
|
1781
|
+
type Words0 = Words<'helloWorld'>;
|
|
1782
|
+
//=> ['hello', 'World']
|
|
870
1783
|
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
1784
|
+
type Words1 = Words<'helloWORLD'>;
|
|
1785
|
+
//=> ['hello', 'WORLD']
|
|
1786
|
+
|
|
1787
|
+
type Words2 = Words<'hello-world'>;
|
|
1788
|
+
//=> ['hello', 'world']
|
|
1789
|
+
|
|
1790
|
+
type Words3 = Words<'--hello the_world'>;
|
|
1791
|
+
//=> ['hello', 'the', 'world']
|
|
1792
|
+
|
|
1793
|
+
type Words4 = Words<'lifeIs42'>;
|
|
1794
|
+
//=> ['life', 'Is', '42']
|
|
1795
|
+
|
|
1796
|
+
type Words5 = Words<'p2pNetwork', {splitOnNumbers: false}>;
|
|
1797
|
+
//=> ['p2p', 'Network']
|
|
1798
|
+
```
|
|
1799
|
+
|
|
1800
|
+
@category Change case
|
|
1801
|
+
@category Template literal
|
|
876
1802
|
*/
|
|
877
|
-
type
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1803
|
+
type Words<Sentence extends string, Options extends WordsOptions = {}> = WordsImplementation<Sentence, ApplyDefaultOptions<WordsOptions, _DefaultWordsOptions, Options>>;
|
|
1804
|
+
type WordsImplementation<Sentence extends string, Options extends Required<WordsOptions>, LastCharacter extends string = '', CurrentWord extends string = ''> = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}` ? FirstCharacter extends WordSeparators // Skip word separator
|
|
1805
|
+
? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options>] : LastCharacter extends '' // Fist char of word
|
|
1806
|
+
? WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter> // Case change: non-numeric to numeric
|
|
1807
|
+
: [false, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? Options['splitOnNumbers'] extends true // Split on number: push word
|
|
1808
|
+
? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] // No split on number: concat word
|
|
1809
|
+
: WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> // Case change: numeric to non-numeric
|
|
1810
|
+
: [true, false] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? Options['splitOnNumbers'] extends true // Split on number: push word
|
|
1811
|
+
? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] // No split on number: concat word
|
|
1812
|
+
: WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> // No case change: concat word
|
|
1813
|
+
: [true, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> // Case change: lower to upper, push word
|
|
1814
|
+
: [true, true] extends [IsLowercase<LastCharacter>, IsUppercase<FirstCharacter>] ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] // Case change: upper to lower, brings back the last character, push word
|
|
1815
|
+
: [true, true] extends [IsUppercase<LastCharacter>, IsLowercase<FirstCharacter>] ? [...RemoveLastCharacter<CurrentWord, LastCharacter>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${LastCharacter}${FirstCharacter}`>] // No case change: concat word
|
|
1816
|
+
: WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> : [...SkipEmptyWord<CurrentWord>];
|
|
1817
|
+
//#endregion
|
|
1818
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/remove-prefix.d.ts
|
|
1819
|
+
/**
|
|
1820
|
+
@see {@link RemovePrefix}
|
|
1821
|
+
*/
|
|
1822
|
+
type RemovePrefixOptions = {
|
|
1823
|
+
/**
|
|
1824
|
+
When enabled, instantiations with non-literal prefixes (e.g., `string`, `Uppercase<string>`, `` `on${string}` ``) simply return `string`, since their precise structure cannot be statically determined.
|
|
1825
|
+
Note: Disabling this option can produce misleading results that might not reflect the actual runtime behavior.
|
|
1826
|
+
For example, ``RemovePrefix<'on-change', `${string}-`, {strict: false}>`` returns `'change'`, but at runtime, prefix could be `'handle-'` (which satisfies `` `${string}-` ``) and removing `'handle-'` from `'on-change'` would not result in `'change'`.
|
|
1827
|
+
So, it is recommended to not disable this option unless you are aware of the implications.
|
|
1828
|
+
@default true
|
|
1829
|
+
@example
|
|
1830
|
+
```
|
|
1831
|
+
import type {RemovePrefix} from 'type-fest';
|
|
1832
|
+
type A = RemovePrefix<'on-change', `${string}-`, {strict: true}>;
|
|
1833
|
+
//=> string
|
|
1834
|
+
type B = RemovePrefix<'on-change', `${string}-`, {strict: false}>;
|
|
1835
|
+
//=> 'change'
|
|
1836
|
+
type C = RemovePrefix<'on-change', string, {strict: true}>;
|
|
1837
|
+
//=> string
|
|
1838
|
+
type D = RemovePrefix<'on-change', string, {strict: false}>;
|
|
1839
|
+
//=> 'n-change'
|
|
1840
|
+
type E = RemovePrefix<`${string}/${number}`, `${string}/`, {strict: true}>;
|
|
1841
|
+
//=> string
|
|
1842
|
+
type F = RemovePrefix<`${string}/${number}`, `${string}/`, {strict: false}>;
|
|
1843
|
+
//=> `${number}`
|
|
1844
|
+
```
|
|
1845
|
+
Note: This option has no effect when only the input string type is non-literal. For example, ``RemovePrefix<`on-${string}`, 'on-'>`` will always return `string`.
|
|
1846
|
+
@example
|
|
1847
|
+
```
|
|
1848
|
+
import type {RemovePrefix} from 'type-fest';
|
|
1849
|
+
type A = RemovePrefix<`on-${string}`, 'on-', {strict: true}>;
|
|
1850
|
+
//=> string
|
|
1851
|
+
type B = RemovePrefix<`on-${string}`, 'on-', {strict: false}>;
|
|
1852
|
+
//=> string
|
|
1853
|
+
type C = RemovePrefix<`id-${number}`, 'id-', {strict: true}>;
|
|
1854
|
+
//=> `${number}`
|
|
1855
|
+
type D = RemovePrefix<`id-${number}`, 'id-', {strict: false}>;
|
|
1856
|
+
//=> `${number}`
|
|
1857
|
+
```
|
|
1858
|
+
Note: If it can be statically determined that the input string can never start with the specified non-literal prefix, then the input string is returned as-is, regardless of the value of this option.
|
|
1859
|
+
For example, ``RemovePrefix<`${string}/${number}`, `${string}:`>`` returns `` `${string}/${number}` ``, since a string of type `` `${string}/${number}` `` can never start with a prefix of type `` `${string}:` ``.
|
|
1860
|
+
```
|
|
1861
|
+
import type {RemovePrefix} from 'type-fest';
|
|
1862
|
+
type A = RemovePrefix<`${string}/${number}`, `${string}:`, {strict: true}>;
|
|
1863
|
+
//=> `${string}/${number}`
|
|
1864
|
+
type B = RemovePrefix<`${string}/${number}`, `${string}:`, {strict: false}>;
|
|
1865
|
+
//=> `${string}/${number}`
|
|
1866
|
+
type C = RemovePrefix<'on-change', `${number}-`, {strict: true}>;
|
|
1867
|
+
//=> 'on-change'
|
|
1868
|
+
type D = RemovePrefix<'on-change', `${number}-`, {strict: false}>;
|
|
1869
|
+
//=> 'on-change'
|
|
1870
|
+
```
|
|
1871
|
+
*/
|
|
1872
|
+
strict?: boolean;
|
|
1873
|
+
};
|
|
1874
|
+
type DefaultRemovePrefixOptions = {
|
|
1875
|
+
strict: true;
|
|
1876
|
+
};
|
|
1877
|
+
/**
|
|
1878
|
+
Remove the specified prefix from the start of a string.
|
|
1879
|
+
|
|
1880
|
+
@example
|
|
1881
|
+
```
|
|
1882
|
+
import type {RemovePrefix} from 'type-fest';
|
|
1883
|
+
|
|
1884
|
+
type A = RemovePrefix<'on-change', 'on-'>;
|
|
1885
|
+
//=> 'change'
|
|
1886
|
+
|
|
1887
|
+
type B = RemovePrefix<'sm:flex' | 'sm:p-4' | 'sm:gap-2', 'sm:'>;
|
|
1888
|
+
//=> 'flex' | 'p-4' | 'gap-2'
|
|
1889
|
+
|
|
1890
|
+
type C = RemovePrefix<'on-change', 'off-'>;
|
|
1891
|
+
//=> 'on-change'
|
|
1892
|
+
|
|
1893
|
+
type D = RemovePrefix<`handle${Capitalize<string>}`, 'handle'>;
|
|
1894
|
+
//=> Capitalize<string>
|
|
1895
|
+
```
|
|
1896
|
+
|
|
1897
|
+
@see {@link RemovePrefixOptions}
|
|
1898
|
+
|
|
1899
|
+
@category String
|
|
1900
|
+
@category Template literal
|
|
1901
|
+
*/
|
|
1902
|
+
type RemovePrefix<S extends string, Prefix extends string, Options extends RemovePrefixOptions = {}> = IfNotAnyOrNever<S, IfNotAnyOrNever<Prefix, _RemovePrefix<S, Prefix, ApplyDefaultOptions<RemovePrefixOptions, DefaultRemovePrefixOptions, Options>>, string, S>>;
|
|
1903
|
+
type _RemovePrefix<S extends string, Prefix extends string, Options extends Required<RemovePrefixOptions>> = Prefix extends string // For distributing `Prefix`
|
|
1904
|
+
? S extends `${Prefix}${infer Rest}` ? Or<IsStringLiteral<Prefix>, Not<Options['strict']>> extends true ? Rest : string // Fallback to `string` when `Prefix` is non-literal and `strict` is disabled
|
|
1905
|
+
: S // Return back `S` when `Prefix` is not present at the start of `S`
|
|
1906
|
+
: never;
|
|
892
1907
|
//#endregion
|
|
893
|
-
//#region
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
deletedAt: Date | null;
|
|
897
|
-
updatedAt: Date;
|
|
898
|
-
}
|
|
899
|
-
declare const ItemMetadataPropertyNames: PropertyNames<ItemMetadata>;
|
|
900
|
-
declare const itemMetadataSchema: z.ZodObject<{
|
|
901
|
-
createdAt: z.ZodDate;
|
|
902
|
-
deletedAt: z.ZodNullable<z.ZodDate>;
|
|
903
|
-
updatedAt: z.ZodDate;
|
|
1908
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/delimiter-case.d.ts
|
|
1909
|
+
type _DefaultDelimiterCaseOptions = Merge<_DefaultWordsOptions, {
|
|
1910
|
+
splitOnNumbers: false;
|
|
904
1911
|
}>;
|
|
1912
|
+
/**
|
|
1913
|
+
Convert an array of words to delimiter case starting with a delimiter with input capitalization.
|
|
1914
|
+
*/
|
|
1915
|
+
type DelimiterCaseFromArray<Words extends string[], Delimiter extends string, OutputString extends string = ''> = Words extends [infer FirstWord extends string, ...infer RemainingWords extends string[]] ? DelimiterCaseFromArray<RemainingWords, Delimiter, `${OutputString}${StartsWith<FirstWord, AsciiPunctuation> extends true ? '' : Delimiter}${FirstWord}`> : OutputString;
|
|
1916
|
+
/**
|
|
1917
|
+
Convert a string literal to a custom string delimiter casing.
|
|
1918
|
+
|
|
1919
|
+
This can be useful when, for example, converting a camel-cased object property to an oddly cased one.
|
|
1920
|
+
|
|
1921
|
+
@see {@link KebabCase}
|
|
1922
|
+
@see {@link SnakeCase}
|
|
1923
|
+
|
|
1924
|
+
@example
|
|
1925
|
+
```
|
|
1926
|
+
import type {DelimiterCase} from 'type-fest';
|
|
1927
|
+
|
|
1928
|
+
// Simple
|
|
1929
|
+
|
|
1930
|
+
const someVariable: DelimiterCase<'fooBar', '#'> = 'foo#bar';
|
|
1931
|
+
const someVariableNoSplitOnNumbers: DelimiterCase<'p2pNetwork', '#', {splitOnNumbers: false}> = 'p2p#network';
|
|
1932
|
+
|
|
1933
|
+
// Advanced
|
|
1934
|
+
|
|
1935
|
+
type OddlyCasedProperties<T> = {
|
|
1936
|
+
[K in keyof T as DelimiterCase<K, '#'>]: T[K]
|
|
1937
|
+
};
|
|
1938
|
+
|
|
1939
|
+
type SomeOptions = {
|
|
1940
|
+
dryRun: boolean;
|
|
1941
|
+
includeFile: string;
|
|
1942
|
+
foo: number;
|
|
1943
|
+
};
|
|
1944
|
+
|
|
1945
|
+
const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
|
|
1946
|
+
'dry#run': true,
|
|
1947
|
+
'include#file': 'bar.js',
|
|
1948
|
+
foo: 123,
|
|
1949
|
+
};
|
|
1950
|
+
```
|
|
1951
|
+
|
|
1952
|
+
@category Change case
|
|
1953
|
+
@category Template literal
|
|
1954
|
+
*/
|
|
1955
|
+
type DelimiterCase<Value, Delimiter extends string, Options extends WordsOptions = {}> = Value extends string ? IsStringLiteral<Value> extends false ? Value : Lowercase<RemovePrefix<DelimiterCaseFromArray<Words<Value, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>, Delimiter>, string, {
|
|
1956
|
+
strict: false;
|
|
1957
|
+
}>> : Value;
|
|
905
1958
|
//#endregion
|
|
906
|
-
//#region
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1959
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/kebab-case.d.ts
|
|
1960
|
+
/**
|
|
1961
|
+
Convert a string literal to kebab-case.
|
|
1962
|
+
|
|
1963
|
+
This can be useful when, for example, converting a camel-cased object property to a kebab-cased CSS class name or a command-line flag.
|
|
1964
|
+
|
|
1965
|
+
@example
|
|
1966
|
+
```
|
|
1967
|
+
import type {KebabCase} from 'type-fest';
|
|
1968
|
+
|
|
1969
|
+
// Simple
|
|
1970
|
+
|
|
1971
|
+
const someVariable: KebabCase<'fooBar'> = 'foo-bar';
|
|
1972
|
+
const someVariableNoSplitOnNumbers: KebabCase<'p2pNetwork', {splitOnNumbers: false}> = 'p2p-network';
|
|
1973
|
+
|
|
1974
|
+
// Advanced
|
|
1975
|
+
|
|
1976
|
+
type KebabCasedProperties<T> = {
|
|
1977
|
+
[K in keyof T as KebabCase<K>]: T[K]
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
type CliOptions = {
|
|
1981
|
+
dryRun: boolean;
|
|
1982
|
+
includeFile: string;
|
|
1983
|
+
foo: number;
|
|
1984
|
+
};
|
|
1985
|
+
|
|
1986
|
+
const rawCliOptions: KebabCasedProperties<CliOptions> = {
|
|
1987
|
+
'dry-run': true,
|
|
1988
|
+
'include-file': 'bar.js',
|
|
1989
|
+
foo: 123,
|
|
1990
|
+
};
|
|
1991
|
+
```
|
|
1992
|
+
|
|
1993
|
+
@category Change case
|
|
1994
|
+
@category Template literal
|
|
1995
|
+
*/
|
|
1996
|
+
type KebabCase<Value, Options extends WordsOptions = {}> = DelimiterCase<Value, '-', ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>;
|
|
919
1997
|
//#endregion
|
|
920
1998
|
//#region src/util/types/DeepOmit.d.ts
|
|
921
|
-
type DeepOmit<T, TKey> = T extends Primitive ? T :
|
|
922
|
-
//#endregion
|
|
923
|
-
//#region src/util/types/DeepOptionalProperties.d.ts
|
|
924
|
-
type DeepOptionalProperties<T> = { [K in keyof T as undefined extends T[K] ? K : never]?: DeepOptionalProperties<T[K]> };
|
|
925
|
-
//#endregion
|
|
926
|
-
//#region src/util/types/DeepRequiredProperties.d.ts
|
|
927
|
-
type DeepRequiredProperties<T> = { [K in keyof T as undefined extends T[K] ? never : K]: DeepRequiredProperties<T[K]> };
|
|
1999
|
+
type DeepOmit<T, TKey extends PropertyKey> = [T] extends [Date | Function | Primitive] ? T : [Record<string, unknown>] extends [T] ? T : T extends object ? T extends unknown[] ? T extends readonly unknown[] ? { [K in keyof T]: DeepOmit<T[K], TKey> } : DeepOmit<T[number], TKey>[] : { [P in keyof T as P extends TKey ? never : P]: DeepOmit<T[P], TKey> } : T;
|
|
928
2000
|
//#endregion
|
|
929
2001
|
//#region src/util/types/DeepOptionalUndefined.d.ts
|
|
930
|
-
type DeepOptionalUndefined<T> = T extends
|
|
2002
|
+
type DeepOptionalUndefined<T> = T extends Date | Function | Primitive ? T : T extends unknown[] ? { [K in keyof T]: DeepOptionalUndefined<T[K]> } : T extends object ? { [K in keyof T as undefined extends T[K] ? K : never]?: DeepOptionalUndefined<T[K]> } & { [K in keyof T as undefined extends T[K] ? never : K]: DeepOptionalUndefined<T[K]> } extends infer O ? { [K in keyof O]: O[K] } : never : T;
|
|
931
2003
|
//#endregion
|
|
932
2004
|
//#region src/models/shared/ToData.d.ts
|
|
933
|
-
type ToData<T
|
|
2005
|
+
type ToData<T> = DeepOptionalUndefined<DeepOmit<T, "toJSON">>;
|
|
934
2006
|
//#endregion
|
|
935
2007
|
//#region src/models/shared/WithMetadata.d.ts
|
|
936
2008
|
interface WithMetadata<TBase extends Class<NonNullable<unknown>>> {
|
|
@@ -947,7 +2019,7 @@ declare const MENTION_LABEL_ATTRIBUTE = "data-label";
|
|
|
947
2019
|
declare const MENTION_TYPE_ATTRIBUTE = "data-type";
|
|
948
2020
|
declare const MENTION_TYPE = "mention";
|
|
949
2021
|
//#endregion
|
|
950
|
-
//#region ../../node_modules/.pnpm/node-html-parser@7.0
|
|
2022
|
+
//#region ../../node_modules/.pnpm/node-html-parser@7.1.0/node_modules/node-html-parser/dist/void-tag.d.ts
|
|
951
2023
|
declare class VoidTag {
|
|
952
2024
|
addClosingSlash: boolean;
|
|
953
2025
|
private voidTags;
|
|
@@ -956,14 +2028,14 @@ declare class VoidTag {
|
|
|
956
2028
|
isVoidElement(tag: string): boolean;
|
|
957
2029
|
}
|
|
958
2030
|
//#endregion
|
|
959
|
-
//#region ../../node_modules/.pnpm/node-html-parser@7.0
|
|
2031
|
+
//#region ../../node_modules/.pnpm/node-html-parser@7.1.0/node_modules/node-html-parser/dist/nodes/type.d.ts
|
|
960
2032
|
declare enum NodeType {
|
|
961
2033
|
ELEMENT_NODE = 1,
|
|
962
2034
|
TEXT_NODE = 3,
|
|
963
2035
|
COMMENT_NODE = 8
|
|
964
2036
|
}
|
|
965
2037
|
//#endregion
|
|
966
|
-
//#region ../../node_modules/.pnpm/node-html-parser@7.0
|
|
2038
|
+
//#region ../../node_modules/.pnpm/node-html-parser@7.1.0/node_modules/node-html-parser/dist/nodes/node.d.ts
|
|
967
2039
|
/**
|
|
968
2040
|
* Node Class as base class for TextNode and HTMLElement.
|
|
969
2041
|
*/
|
|
@@ -987,7 +2059,7 @@ declare abstract class Node {
|
|
|
987
2059
|
set textContent(val: string);
|
|
988
2060
|
}
|
|
989
2061
|
//#endregion
|
|
990
|
-
//#region ../../node_modules/.pnpm/node-html-parser@7.0
|
|
2062
|
+
//#region ../../node_modules/.pnpm/node-html-parser@7.1.0/node_modules/node-html-parser/dist/nodes/html.d.ts
|
|
991
2063
|
interface KeyAttributes {
|
|
992
2064
|
id?: string;
|
|
993
2065
|
class?: string;
|
|
@@ -1119,6 +2191,12 @@ declare class HTMLElement extends Node {
|
|
|
1119
2191
|
* @return {(HTMLElement|null)} matching node
|
|
1120
2192
|
*/
|
|
1121
2193
|
querySelector(selector: string): HTMLElement | null;
|
|
2194
|
+
/**
|
|
2195
|
+
* Tests whether the node matches a given CSS selector.
|
|
2196
|
+
* @param {string} selector Simplified CSS selector
|
|
2197
|
+
* @return {boolean}
|
|
2198
|
+
*/
|
|
2199
|
+
matches(selector: string): boolean;
|
|
1122
2200
|
/**
|
|
1123
2201
|
* find elements by their tagName
|
|
1124
2202
|
* @param {string} tagName the tagName of the elements to select
|
|
@@ -1220,6 +2298,10 @@ interface Options {
|
|
|
1220
2298
|
*/
|
|
1221
2299
|
fixNestedATags?: boolean;
|
|
1222
2300
|
parseNoneClosedTags?: boolean;
|
|
2301
|
+
/**
|
|
2302
|
+
* When true, preserves invalid HTML nesting (e.g., <p><p>bar</p></p>) instead of auto-closing tags
|
|
2303
|
+
*/
|
|
2304
|
+
preserveTagNesting?: boolean;
|
|
1223
2305
|
blockTextElements: {
|
|
1224
2306
|
[tag: string]: boolean;
|
|
1225
2307
|
};
|
|
@@ -1233,6 +2315,7 @@ interface Options {
|
|
|
1233
2315
|
*/
|
|
1234
2316
|
closingSlash?: boolean;
|
|
1235
2317
|
};
|
|
2318
|
+
closeAllByClosing?: boolean;
|
|
1236
2319
|
}
|
|
1237
2320
|
//#endregion
|
|
1238
2321
|
//#region src/services/message/getMentions.d.ts
|
|
@@ -1289,11 +2372,8 @@ declare const capitalize: (string: string) => string;
|
|
|
1289
2372
|
//#region src/util/text/streamToText.d.ts
|
|
1290
2373
|
declare const streamToText: (readable: NodeJS.ReadableStream) => Promise<string>;
|
|
1291
2374
|
//#endregion
|
|
1292
|
-
//#region src/util/types/CamelToKebab.d.ts
|
|
1293
|
-
type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToKebab<U>}` : `${Uncapitalize<T>}-${CamelToKebab<U>}` : S;
|
|
1294
|
-
//#endregion
|
|
1295
2375
|
//#region src/util/text/toKebabCase.d.ts
|
|
1296
|
-
declare const toKebabCase: <T extends string>(string: T) =>
|
|
2376
|
+
declare const toKebabCase: <T extends string>(string: T) => KebabCase<T>;
|
|
1297
2377
|
//#endregion
|
|
1298
2378
|
//#region src/util/text/truncate.d.ts
|
|
1299
2379
|
declare const truncate: (string: string, length: number) => string;
|
|
@@ -1307,29 +2387,20 @@ declare const hrtime: (previousHrTime?: [number, number]) => [number, number];
|
|
|
1307
2387
|
//#region src/util/time/now.d.ts
|
|
1308
2388
|
declare const now: () => string;
|
|
1309
2389
|
//#endregion
|
|
2390
|
+
//#region src/util/types/BuildTuple.d.ts
|
|
2391
|
+
type BuildTuple<N extends number, T = unknown, R extends unknown[] = []> = R["length"] extends N ? R : BuildTuple<N, T, [...R, T]>;
|
|
2392
|
+
//#endregion
|
|
1310
2393
|
//#region src/util/types/FunctionProperties.d.ts
|
|
1311
2394
|
type FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? K : never };
|
|
1312
2395
|
//#endregion
|
|
1313
2396
|
//#region src/util/types/ExcludeFunctionProperties.d.ts
|
|
1314
2397
|
type ExcludeFunctionProperties<T> = Except<T, FunctionProperties<T>[keyof T]>;
|
|
1315
2398
|
//#endregion
|
|
1316
|
-
//#region src/util/types/KebabToCamel.d.ts
|
|
1317
|
-
type KebabToCamel<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamel<U>>}` : S;
|
|
1318
|
-
//#endregion
|
|
1319
2399
|
//#region src/util/types/MapValue.d.ts
|
|
1320
2400
|
type MapValue<BaseType> = BaseType extends Map<unknown, infer ValueType> ? ValueType : never;
|
|
1321
2401
|
//#endregion
|
|
1322
|
-
//#region src/util/types/PartialByKeys.d.ts
|
|
1323
|
-
type PartialByKeys<T, K extends keyof T = keyof T> = Except<T, K> & Partial<Pick<T, Extract<keyof T, K>>>;
|
|
1324
|
-
//#endregion
|
|
1325
|
-
//#region src/util/types/TupleSplitHead.d.ts
|
|
1326
|
-
type TupleSplitHead<T extends unknown[], N extends number> = T["length"] extends N ? T : T extends [...infer R, unknown] ? TupleSplitHead<R, N> : never;
|
|
1327
|
-
//#endregion
|
|
1328
|
-
//#region src/util/types/TupleSplitTail.d.ts
|
|
1329
|
-
type TupleSplitTail<T, N extends number, O extends unknown[] = []> = O["length"] extends N ? T : T extends [infer F, ...infer R] ? TupleSplitTail<[...R], N, [...O, F]> : never;
|
|
1330
|
-
//#endregion
|
|
1331
2402
|
//#region src/util/types/TupleSplit.d.ts
|
|
1332
|
-
type TupleSplit<T extends unknown[], N extends number> = [
|
|
2403
|
+
type TupleSplit<T extends unknown[], N extends number> = T extends [...BuildTuple<N>, ...infer R] ? [T extends [...infer H, ...R] ? H : BuildTuple<N, T[number]>, R] : [T, []];
|
|
1333
2404
|
//#endregion
|
|
1334
2405
|
//#region src/util/types/SkipFirst.d.ts
|
|
1335
2406
|
type SkipFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[1];
|
|
@@ -1338,7 +2409,13 @@ type SkipFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[1];
|
|
|
1338
2409
|
type TakeFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[0];
|
|
1339
2410
|
//#endregion
|
|
1340
2411
|
//#region src/util/types/TupleSlice.d.ts
|
|
1341
|
-
type TupleSlice<T extends unknown[], S extends number, E extends number = T["length"]> = SkipFirst<TakeFirst<T, E>, S>;
|
|
2412
|
+
type TupleSlice<T extends unknown[], S extends number, E extends number = T["length"]> = E extends T["length"] ? SkipFirst<T, S> : SkipFirst<TakeFirst<T, E>, S>;
|
|
2413
|
+
//#endregion
|
|
2414
|
+
//#region src/util/types/TupleSplitHead.d.ts
|
|
2415
|
+
type TupleSplitHead<T extends unknown[], N extends number> = TupleSplit<T, N>[0];
|
|
2416
|
+
//#endregion
|
|
2417
|
+
//#region src/util/types/TupleSplitTail.d.ts
|
|
2418
|
+
type TupleSplitTail<T extends unknown[], N extends number> = TupleSplit<T, N>[1];
|
|
1342
2419
|
//#endregion
|
|
1343
2420
|
//#region src/util/validation/exhaustiveGuard.d.ts
|
|
1344
2421
|
declare const exhaustiveGuard: (value: never) => never;
|
|
@@ -1350,4 +2427,4 @@ declare const UUIDV4_REGEX: RegExp;
|
|
|
1350
2427
|
//#region src/util/id/uuid/uuidValidateV4.d.ts
|
|
1351
2428
|
declare const uuidValidateV4: (uuid: string) => boolean;
|
|
1352
2429
|
//#endregion
|
|
1353
|
-
export { AllSpecialValues,
|
|
2430
|
+
export { AllSpecialValues, BuildTuple, DeepOmit, DeepOptionalUndefined, ExcludeFunctionProperties, FunctionProperties, GetPaths, GetProperties, ID_SEPARATOR, InvalidOperationError, ItemEntityType, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, MENTION_ID_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MapValue, MergeObjectsStrict, NIL, NotFoundError, NotInitializedError, Operation, PropertyNames, RoutePath, SITE_NAME, SURVEY_DISPLAY_NAME, Serializable, SkipFirst, TakeFirst, TakeOne, ToData, TupleSlice, TupleSplit, TupleSplitHead, TupleSplitTail, UUIDV4_REGEX, WithMetadata, applyItemMetadataMixin, capitalize, createItemEntityTypeSchema, css, escapeRegExp, exhaustiveGuard, getIsServer, getMentions, getPropertyNames, getRawData, hrtime, html, isPlainObject, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, now, streamToText, takeOne, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4 };
|