@esposter/shared 2.38.0 → 2.39.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 +514 -852
- package/dist/index.js +252 -14033
- package/package.json +25 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { Result, ResultAsync } from "neverthrow";
|
|
3
|
+
import { HTMLElement } from "node-html-parser";
|
|
2
4
|
import baseSanitizeHtml from "sanitize-html";
|
|
5
|
+
//#region src/test/constants.d.ts
|
|
3
6
|
export declare const AllSpecialValues: {
|
|
4
7
|
isPlainObject: boolean;
|
|
5
8
|
value: unknown;
|
|
6
9
|
}[];
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/models/error/ForbiddenError.d.ts
|
|
7
12
|
export declare class ForbiddenError extends Error {
|
|
8
13
|
constructor(message: string);
|
|
9
14
|
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/models/shared/Operation.d.ts
|
|
10
17
|
export declare enum Operation {
|
|
11
18
|
Create = "Create",
|
|
12
19
|
Delete = "Delete",
|
|
@@ -15,27 +22,41 @@ export declare enum Operation {
|
|
|
15
22
|
Unshift = "Unshift",
|
|
16
23
|
Update = "Update"
|
|
17
24
|
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/models/error/InvalidOperationError.d.ts
|
|
18
27
|
export declare class InvalidOperationError extends Error {
|
|
19
28
|
constructor(operation: Operation, name: string, message: string);
|
|
20
29
|
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/models/error/NotFoundError.d.ts
|
|
21
32
|
export declare class NotFoundError<T extends string = string> extends Error {
|
|
22
33
|
constructor(name: T, id: string);
|
|
23
34
|
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/models/error/NotInitializedError.d.ts
|
|
24
37
|
export declare class NotInitializedError<T extends string = string> extends Error {
|
|
25
38
|
constructor(name: T);
|
|
26
39
|
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/models/error/WordFilteredError.d.ts
|
|
27
42
|
export declare class WordFilteredError extends Error {
|
|
28
43
|
constructor(message: string);
|
|
29
44
|
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/models/message/ClassifiedMentions.d.ts
|
|
30
47
|
export interface ClassifiedMentions {
|
|
31
48
|
broadcastIds: string[];
|
|
32
49
|
regularUserIds: string[];
|
|
33
50
|
roleIds: string[];
|
|
34
51
|
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/models/message/MentionType.d.ts
|
|
35
54
|
export declare enum MentionType {
|
|
36
55
|
Role = "role",
|
|
37
56
|
User = "user"
|
|
38
57
|
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/models/router/RoutePath.d.ts
|
|
39
60
|
export declare const RoutePath: {
|
|
40
61
|
readonly About: "/about";
|
|
41
62
|
readonly Achievements: "/achievements";
|
|
@@ -75,15 +96,23 @@ export declare const RoutePath: {
|
|
|
75
96
|
readonly View: (type: string, id: string) => string;
|
|
76
97
|
};
|
|
77
98
|
export type RoutePath = typeof RoutePath;
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/util/types/GetArrayProps.d.ts
|
|
78
101
|
export 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) | {
|
|
79
102
|
path: R extends true ? "length" : `${P}.length`;
|
|
80
103
|
value: T["length"];
|
|
81
104
|
};
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/util/types/KnownKeys.d.ts
|
|
82
107
|
export type KnownKeys<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/util/types/GetObjectProps.d.ts
|
|
83
110
|
export 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) | {
|
|
84
111
|
path: R extends true ? `${K}` : `${P}.${K}`;
|
|
85
112
|
value: T[K];
|
|
86
113
|
}; }[keyof KnownKeys<T> & (number | string)];
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/util/types/GetPrimitiveProps.d.ts
|
|
87
116
|
export type GetPrimitiveProps<T, P extends string, D extends unknown[], R extends boolean> = T extends string ? {
|
|
88
117
|
path: R extends true ? "length" : `${P}.length`;
|
|
89
118
|
value: number;
|
|
@@ -91,11 +120,19 @@ export type GetPrimitiveProps<T, P extends string, D extends unknown[], R extend
|
|
|
91
120
|
path: R extends true ? "description" : `${P}.description`;
|
|
92
121
|
value: string | undefined;
|
|
93
122
|
} : never;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/util/types/GetProperties.d.ts
|
|
94
125
|
export 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;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/util/types/GetPaths.d.ts
|
|
95
128
|
export type GetPaths<T> = GetProperties<T> extends (infer U) ? (U extends {
|
|
96
129
|
path: infer Path;
|
|
97
130
|
} ? Path : never) : never;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/util/types/PropertyNames.d.ts
|
|
98
133
|
export type PropertyNames<T> = { [P in GetPaths<T>]: P; };
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/models/shared/ItemEntityType.d.ts
|
|
99
136
|
export interface ItemEntityType<T extends string> {
|
|
100
137
|
type: T;
|
|
101
138
|
}
|
|
@@ -103,6 +140,8 @@ export declare const ItemEntityTypePropertyNames: PropertyNames<ItemEntityType<s
|
|
|
103
140
|
export declare const createItemEntityTypeSchema: <T extends z.ZodType<string>>(schema: T) => z.ZodObject<{
|
|
104
141
|
type: T;
|
|
105
142
|
}>;
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/models/shared/ItemMetadata.d.ts
|
|
106
145
|
export declare class ItemMetadata {
|
|
107
146
|
createdAt: Date;
|
|
108
147
|
deletedAt: Date | null;
|
|
@@ -114,19 +153,27 @@ export declare const itemMetadataSchema: z.ZodObject<{
|
|
|
114
153
|
deletedAt: z.ZodNullable<z.ZodDate>;
|
|
115
154
|
updatedAt: z.ZodDate;
|
|
116
155
|
}>;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/models/shared/Serializable.d.ts
|
|
117
158
|
export declare abstract class Serializable {
|
|
118
159
|
toJSON(): this;
|
|
119
160
|
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/models/shared/TakeOne.d.ts
|
|
120
163
|
export interface TakeOne {
|
|
121
164
|
<T extends readonly unknown[]>(values: T, index?: number): T[number];
|
|
122
165
|
<T extends object | Record<PropertyKey, unknown>>(values: T, index: keyof T): T[keyof T];
|
|
123
166
|
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/primitive.d.ts
|
|
124
169
|
/**
|
|
125
170
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
126
171
|
|
|
127
172
|
@category Type
|
|
128
173
|
*/
|
|
129
174
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/basic.d.ts
|
|
130
177
|
/**
|
|
131
178
|
Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
132
179
|
|
|
@@ -136,6 +183,84 @@ type Class<T, Arguments extends unknown[] = any[]> = {
|
|
|
136
183
|
prototype: Pick<T, keyof T>;
|
|
137
184
|
new (...arguments_: Arguments): T;
|
|
138
185
|
};
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
188
|
+
/**
|
|
189
|
+
Convert a union type to an intersection type.
|
|
190
|
+
|
|
191
|
+
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
192
|
+
|
|
193
|
+
@example
|
|
194
|
+
```
|
|
195
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
196
|
+
|
|
197
|
+
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
198
|
+
|
|
199
|
+
type Intersection = UnionToIntersection<Union>;
|
|
200
|
+
//=> {the(): void} & {great(arg: string): void} & {escape: boolean}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
@category Type
|
|
204
|
+
*/
|
|
205
|
+
type UnionToIntersection<Union> = (
|
|
206
|
+
// `extends unknown` is always going to be the case and is used to convert the
|
|
207
|
+
// `Union` into a [distributive conditional
|
|
208
|
+
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
209
|
+
Union extends unknown ?
|
|
210
|
+
// The union type is used as the only argument to a function since the union
|
|
211
|
+
// of function arguments is an intersection.
|
|
212
|
+
(distributedUnion: Union) => void :
|
|
213
|
+
// This won't happen.
|
|
214
|
+
never
|
|
215
|
+
// Infer the `Intersection` type since TypeScript represents the positional
|
|
216
|
+
// arguments of unions of functions as an intersection of the union.
|
|
217
|
+
) extends ((mergedIntersection: infer Intersection) => void) ?
|
|
218
|
+
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
219
|
+
Intersection & Union : never;
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/keys-of-union.d.ts
|
|
222
|
+
/**
|
|
223
|
+
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
224
|
+
|
|
225
|
+
Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
|
|
226
|
+
|
|
227
|
+
@link https://stackoverflow.com/a/49402091
|
|
228
|
+
|
|
229
|
+
@example
|
|
230
|
+
```
|
|
231
|
+
import type {KeysOfUnion} from 'type-fest';
|
|
232
|
+
|
|
233
|
+
type A = {
|
|
234
|
+
common: string;
|
|
235
|
+
a: number;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
type B = {
|
|
239
|
+
common: string;
|
|
240
|
+
b: string;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
type C = {
|
|
244
|
+
common: string;
|
|
245
|
+
c: boolean;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
type Union = A | B | C;
|
|
249
|
+
|
|
250
|
+
type CommonKeys = keyof Union;
|
|
251
|
+
//=> 'common'
|
|
252
|
+
|
|
253
|
+
type AllKeys = KeysOfUnion<Union>;
|
|
254
|
+
//=> 'common' | 'a' | 'b' | 'c'
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
@category Object
|
|
258
|
+
*/
|
|
259
|
+
type KeysOfUnion<ObjectType> =
|
|
260
|
+
// Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
|
|
261
|
+
keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-any.d.ts
|
|
139
264
|
/**
|
|
140
265
|
Returns a boolean for whether the given type is `any`.
|
|
141
266
|
|
|
@@ -165,6 +290,8 @@ const anyA = get(anyObject, 'a');
|
|
|
165
290
|
@category Utilities
|
|
166
291
|
*/
|
|
167
292
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
168
295
|
/**
|
|
169
296
|
Returns a boolean for whether the given key is an optional key of type.
|
|
170
297
|
|
|
@@ -206,6 +333,8 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
206
333
|
@category Utilities
|
|
207
334
|
*/
|
|
208
335
|
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;
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
209
338
|
/**
|
|
210
339
|
Extract all optional keys from the given type.
|
|
211
340
|
|
|
@@ -242,6 +371,8 @@ const update2: UpdateOperation<User> = {
|
|
|
242
371
|
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
243
372
|
? (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`
|
|
244
373
|
: never; // Should never happen
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
245
376
|
/**
|
|
246
377
|
Extract all required keys from the given type.
|
|
247
378
|
|
|
@@ -274,6 +405,8 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
|
274
405
|
*/
|
|
275
406
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
276
407
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-never.d.ts
|
|
277
410
|
/**
|
|
278
411
|
Returns a boolean for whether the given type is `never`.
|
|
279
412
|
|
|
@@ -328,6 +461,8 @@ type B = IsTrueFixed<never>;
|
|
|
328
461
|
@category Utilities
|
|
329
462
|
*/
|
|
330
463
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/if.d.ts
|
|
331
466
|
/**
|
|
332
467
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
333
468
|
|
|
@@ -421,6 +556,8 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
421
556
|
@category Utilities
|
|
422
557
|
*/
|
|
423
558
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/unknown-array.d.ts
|
|
424
561
|
/**
|
|
425
562
|
Represents an array with `unknown` value.
|
|
426
563
|
|
|
@@ -446,6 +583,8 @@ type C = IsArray<string>;
|
|
|
446
583
|
@category Array
|
|
447
584
|
*/
|
|
448
585
|
type UnknownArray = readonly unknown[];
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/internal/type.d.ts
|
|
449
588
|
/**
|
|
450
589
|
Returns a boolean for whether A is false.
|
|
451
590
|
|
|
@@ -512,6 +651,8 @@ type IfNotAnyOrNever<T, Cases extends {
|
|
|
512
651
|
Indicates the value of `exactOptionalPropertyTypes` compiler option.
|
|
513
652
|
*/
|
|
514
653
|
type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/internal/array.d.ts
|
|
515
656
|
/**
|
|
516
657
|
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.
|
|
517
658
|
|
|
@@ -555,6 +696,8 @@ TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest,
|
|
|
555
696
|
: 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.
|
|
556
697
|
: First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
|
|
557
698
|
: never; // Should never happen
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/internal/characters.d.ts
|
|
558
701
|
type Whitespace = '\t' // '\t'
|
|
559
702
|
| '\n' // '\n'
|
|
560
703
|
| '\v' // '\v'
|
|
@@ -564,191 +707,8 @@ type Whitespace = '\t' // '\t'
|
|
|
564
707
|
| '
' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | '
' | '
' | ' ' | ' ' | ' ' | '';
|
|
565
708
|
type WordSeparators = '-' | '_' | Whitespace;
|
|
566
709
|
type AsciiPunctuation = '!' | '"' | '#' | '$' | '%' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~';
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
type TagContainer<Token> = {
|
|
570
|
-
readonly [tag]: Token;
|
|
571
|
-
};
|
|
572
|
-
type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata; }>;
|
|
573
|
-
/**
|
|
574
|
-
Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf).
|
|
575
|
-
|
|
576
|
-
A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
|
|
577
|
-
|
|
578
|
-
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.
|
|
579
|
-
|
|
580
|
-
A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
|
|
581
|
-
- the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
|
|
582
|
-
- `A` contains at least all the tags `B` has;
|
|
583
|
-
- and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
|
|
584
|
-
|
|
585
|
-
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
|
|
586
|
-
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
587
|
-
- [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
|
|
588
|
-
- [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
|
|
589
|
-
|
|
590
|
-
@example
|
|
591
|
-
```
|
|
592
|
-
import type {Tagged} from 'type-fest';
|
|
593
|
-
|
|
594
|
-
type AccountNumber = Tagged<number, 'AccountNumber'>;
|
|
595
|
-
type AccountBalance = Tagged<number, 'AccountBalance'>;
|
|
596
|
-
|
|
597
|
-
function createAccountNumber(): AccountNumber {
|
|
598
|
-
// As you can see, casting from a `number` (the underlying type being tagged) is allowed.
|
|
599
|
-
return 2 as AccountNumber;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
|
|
603
|
-
|
|
604
|
-
// This will compile successfully.
|
|
605
|
-
getMoneyForAccount(createAccountNumber());
|
|
606
|
-
|
|
607
|
-
// But this won't, because it has to be explicitly passed as an `AccountNumber` type!
|
|
608
|
-
// Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
|
|
609
|
-
// @ts-expect-error
|
|
610
|
-
getMoneyForAccount(2);
|
|
611
|
-
|
|
612
|
-
// You can also use tagged values like their underlying, untagged type.
|
|
613
|
-
// I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
|
|
614
|
-
// In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
|
|
615
|
-
const accountNumber = createAccountNumber() + 2;
|
|
616
|
-
```
|
|
617
|
-
|
|
618
|
-
@example
|
|
619
|
-
```
|
|
620
|
-
import type {Tagged} from 'type-fest';
|
|
621
|
-
|
|
622
|
-
// You can apply multiple tags to a type by using `Tagged` repeatedly.
|
|
623
|
-
type Url = Tagged<string, 'URL'>;
|
|
624
|
-
type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
|
|
625
|
-
|
|
626
|
-
// 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.
|
|
627
|
-
type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
@category Type
|
|
631
|
-
*/
|
|
632
|
-
type Tagged<Type, TagName extends PropertyKey, TagMetadata = never> = Type & Tag<TagName, TagMetadata>;
|
|
633
|
-
/**
|
|
634
|
-
Get the untagged portion of a tagged type created with `Tagged`.
|
|
635
|
-
|
|
636
|
-
Why is this necessary?
|
|
637
|
-
|
|
638
|
-
1. Use a `Tagged` type as object keys
|
|
639
|
-
2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
|
|
640
|
-
|
|
641
|
-
@example
|
|
642
|
-
```
|
|
643
|
-
import type {Tagged, UnwrapTagged} from 'type-fest';
|
|
644
|
-
|
|
645
|
-
type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
|
|
646
|
-
|
|
647
|
-
const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
|
|
648
|
-
SAVINGS: 99,
|
|
649
|
-
CHECKING: 0.1,
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
// Without UnwrapTagged, the following expression would throw a type error.
|
|
653
|
-
const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
|
|
654
|
-
|
|
655
|
-
// Attempting to pass a non-Tagged type to UnwrapTagged will raise a type error.
|
|
656
|
-
// @ts-expect-error
|
|
657
|
-
type WontWork = UnwrapTagged<string>;
|
|
658
|
-
```
|
|
659
|
-
|
|
660
|
-
@category Type
|
|
661
|
-
*/
|
|
662
|
-
type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
|
|
663
|
-
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;
|
|
664
|
-
/**
|
|
665
|
-
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).
|
|
666
|
-
|
|
667
|
-
Useful for:
|
|
668
|
-
- providing strongly-typed string manipulation functions
|
|
669
|
-
- constraining strings to be a string literal
|
|
670
|
-
- type utilities, such as when constructing parsers and ASTs
|
|
671
|
-
|
|
672
|
-
The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
673
|
-
|
|
674
|
-
@example
|
|
675
|
-
```
|
|
676
|
-
import type {IsStringLiteral} from 'type-fest';
|
|
677
|
-
|
|
678
|
-
type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
|
|
679
|
-
|
|
680
|
-
// https://github.com/yankeeinlondon/native-dash/blob/master/src/capitalize.ts
|
|
681
|
-
function capitalize<T extends Readonly<string>>(input: T): CapitalizedString<T> {
|
|
682
|
-
return (input.slice(0, 1).toUpperCase() + input.slice(1)) as CapitalizedString<T>;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
const output = capitalize('hello, world!');
|
|
686
|
-
//=> 'Hello, world!'
|
|
687
|
-
```
|
|
688
|
-
|
|
689
|
-
@example
|
|
690
|
-
```
|
|
691
|
-
// String types with infinite set of possible values return `false`.
|
|
692
|
-
|
|
693
|
-
import type {IsStringLiteral} from 'type-fest';
|
|
694
|
-
|
|
695
|
-
type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
|
|
696
|
-
//=> false
|
|
697
|
-
|
|
698
|
-
type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
|
|
699
|
-
//=> false
|
|
700
|
-
|
|
701
|
-
// This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
|
|
702
|
-
|
|
703
|
-
type Length<S extends string, Counter extends never[] = []> =
|
|
704
|
-
IsStringLiteral<S> extends false
|
|
705
|
-
? number // return `number` for infinite string types
|
|
706
|
-
: S extends `${string}${infer Tail}`
|
|
707
|
-
? Length<Tail, [...Counter, never]>
|
|
708
|
-
: Counter['length'];
|
|
709
|
-
|
|
710
|
-
type L1 = Length<Lowercase<string>>;
|
|
711
|
-
//=> number
|
|
712
|
-
|
|
713
|
-
type L2 = Length<`${number}`>;
|
|
714
|
-
//=> number
|
|
715
|
-
```
|
|
716
|
-
|
|
717
|
-
@category Type Guard
|
|
718
|
-
@category Utilities
|
|
719
|
-
*/
|
|
720
|
-
type IsStringLiteral<S> = IfNotAnyOrNever<S, {
|
|
721
|
-
ifNot: _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>;
|
|
722
|
-
ifAny: false;
|
|
723
|
-
ifNever: false;
|
|
724
|
-
}>;
|
|
725
|
-
type _IsStringLiteral<S> =
|
|
726
|
-
// If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
|
|
727
|
-
// and since `{}` extends index signatures, the result becomes `false`.
|
|
728
|
-
S extends string ? {} extends Record<S, never> ? false : true : false;
|
|
729
|
-
/**
|
|
730
|
-
Remove spaces from the left side.
|
|
731
|
-
*/
|
|
732
|
-
type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
|
|
733
|
-
/**
|
|
734
|
-
Remove spaces from the right side.
|
|
735
|
-
*/
|
|
736
|
-
type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
|
|
737
|
-
/**
|
|
738
|
-
Remove leading and trailing spaces from a string.
|
|
739
|
-
|
|
740
|
-
@example
|
|
741
|
-
```
|
|
742
|
-
import type {Trim} from 'type-fest';
|
|
743
|
-
|
|
744
|
-
type Example = Trim<' foo '>;
|
|
745
|
-
//=> 'foo'
|
|
746
|
-
```
|
|
747
|
-
|
|
748
|
-
@category String
|
|
749
|
-
@category Template literal
|
|
750
|
-
*/
|
|
751
|
-
type Trim<V extends string> = TrimLeft<TrimRight<V>>;
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/simplify.d.ts
|
|
752
712
|
/**
|
|
753
713
|
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.
|
|
754
714
|
|
|
@@ -808,6 +768,8 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
808
768
|
@category Object
|
|
809
769
|
*/
|
|
810
770
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-equal.d.ts
|
|
811
773
|
/**
|
|
812
774
|
Returns a boolean for whether the two given types are equal.
|
|
813
775
|
|
|
@@ -837,6 +799,8 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
837
799
|
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
838
800
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
839
801
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
840
804
|
/**
|
|
841
805
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
842
806
|
|
|
@@ -929,6 +893,8 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
929
893
|
@category Object
|
|
930
894
|
*/
|
|
931
895
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
932
898
|
/**
|
|
933
899
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
934
900
|
|
|
@@ -975,6 +941,8 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
975
941
|
@category Object
|
|
976
942
|
*/
|
|
977
943
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/merge.d.ts
|
|
978
946
|
// Merges two objects without worrying about index signatures.
|
|
979
947
|
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
|
|
980
948
|
/**
|
|
@@ -1044,89 +1012,33 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
|
|
|
1044
1012
|
? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
|
|
1045
1013
|
: never; // Should never happen
|
|
1046
1014
|
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
1015
|
+
//#endregion
|
|
1016
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/trim.d.ts
|
|
1047
1017
|
/**
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
@example
|
|
1051
|
-
```
|
|
1052
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1053
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
1054
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
1055
|
-
|
|
1056
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1057
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
1058
|
-
```
|
|
1059
|
-
|
|
1060
|
-
@example
|
|
1061
|
-
```
|
|
1062
|
-
// Complains if default values are not provided for optional options
|
|
1063
|
-
|
|
1064
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1065
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
1066
|
-
type SpecifiedOptions = {};
|
|
1067
|
-
|
|
1068
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1069
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
1070
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
1071
|
-
```
|
|
1072
|
-
|
|
1073
|
-
@example
|
|
1074
|
-
```
|
|
1075
|
-
// Complains if an option's default type does not conform to the expected type
|
|
1076
|
-
|
|
1077
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1078
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
1079
|
-
type SpecifiedOptions = {};
|
|
1080
|
-
|
|
1081
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1082
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
1083
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1084
|
-
```
|
|
1085
|
-
|
|
1086
|
-
@example
|
|
1087
|
-
```
|
|
1088
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
1089
|
-
|
|
1090
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1091
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
1092
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
1093
|
-
|
|
1094
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1095
|
-
// ~~~~~~~~~~~~~~~~
|
|
1096
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1097
|
-
```
|
|
1018
|
+
Remove spaces from the left side.
|
|
1098
1019
|
*/
|
|
1099
|
-
type
|
|
1100
|
-
) ? Result : never;
|
|
1101
|
-
type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key]; }>>>;
|
|
1020
|
+
type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
|
|
1102
1021
|
/**
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1022
|
+
Remove spaces from the right side.
|
|
1023
|
+
*/
|
|
1024
|
+
type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
|
|
1025
|
+
/**
|
|
1026
|
+
Remove leading and trailing spaces from a string.
|
|
1108
1027
|
|
|
1109
1028
|
@example
|
|
1110
1029
|
```
|
|
1111
|
-
import type {
|
|
1112
|
-
|
|
1113
|
-
type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
|
|
1114
|
-
//=> string
|
|
1115
|
-
|
|
1116
|
-
type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
|
|
1117
|
-
//=> number
|
|
1118
|
-
|
|
1119
|
-
type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
|
|
1120
|
-
//=> `on${string}`
|
|
1121
|
-
|
|
1122
|
-
type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
|
|
1123
|
-
//=> 'click' | 'change' | `on${string}`
|
|
1030
|
+
import type {Trim} from 'type-fest';
|
|
1124
1031
|
|
|
1125
|
-
type
|
|
1126
|
-
//=>
|
|
1032
|
+
type Example = Trim<' foo '>;
|
|
1033
|
+
//=> 'foo'
|
|
1127
1034
|
```
|
|
1035
|
+
|
|
1036
|
+
@category String
|
|
1037
|
+
@category Template literal
|
|
1128
1038
|
*/
|
|
1129
|
-
type
|
|
1039
|
+
type Trim<V extends string> = TrimLeft<TrimRight<V>>;
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/some-extend.d.ts
|
|
1130
1042
|
/**
|
|
1131
1043
|
@see {@link SomeExtend}
|
|
1132
1044
|
*/
|
|
@@ -1221,6 +1133,8 @@ type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<Som
|
|
|
1221
1133
|
ifAny: false;
|
|
1222
1134
|
ifNever: false;
|
|
1223
1135
|
}>;
|
|
1136
|
+
//#endregion
|
|
1137
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/or-all.d.ts
|
|
1224
1138
|
/**
|
|
1225
1139
|
Returns a boolean for whether any of the given elements is `true`.
|
|
1226
1140
|
|
|
@@ -1290,6 +1204,8 @@ Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in a
|
|
|
1290
1204
|
@see {@link AndAll}
|
|
1291
1205
|
*/
|
|
1292
1206
|
type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
|
|
1207
|
+
//#endregion
|
|
1208
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/or.d.ts
|
|
1293
1209
|
/**
|
|
1294
1210
|
Returns a boolean for whether either of two given types is `true`.
|
|
1295
1211
|
|
|
@@ -1368,6 +1284,8 @@ type G = Or<never, never>;
|
|
|
1368
1284
|
@see {@link Xor}
|
|
1369
1285
|
*/
|
|
1370
1286
|
type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
|
|
1287
|
+
//#endregion
|
|
1288
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/internal/string.d.ts
|
|
1371
1289
|
/**
|
|
1372
1290
|
Returns a boolean for whether the given string `S` starts with the given string `SearchString`.
|
|
1373
1291
|
|
|
@@ -1396,6 +1314,181 @@ Returns a boolean for whether the string is numeric.
|
|
|
1396
1314
|
This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
|
|
1397
1315
|
*/
|
|
1398
1316
|
type IsNumeric<T extends string> = T extends `${number}` ? Trim<T> extends T ? true : false : false;
|
|
1317
|
+
//#endregion
|
|
1318
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/internal/object.d.ts
|
|
1319
|
+
/**
|
|
1320
|
+
Merges user specified options with default options.
|
|
1321
|
+
|
|
1322
|
+
@example
|
|
1323
|
+
```
|
|
1324
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1325
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
1326
|
+
type SpecifiedOptions = {leavesOnly: true};
|
|
1327
|
+
|
|
1328
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1329
|
+
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
@example
|
|
1333
|
+
```
|
|
1334
|
+
// Complains if default values are not provided for optional options
|
|
1335
|
+
|
|
1336
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1337
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
1338
|
+
type SpecifiedOptions = {};
|
|
1339
|
+
|
|
1340
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1341
|
+
// ~~~~~~~~~~~~~~~~~~~
|
|
1342
|
+
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
1343
|
+
```
|
|
1344
|
+
|
|
1345
|
+
@example
|
|
1346
|
+
```
|
|
1347
|
+
// Complains if an option's default type does not conform to the expected type
|
|
1348
|
+
|
|
1349
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1350
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
1351
|
+
type SpecifiedOptions = {};
|
|
1352
|
+
|
|
1353
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1354
|
+
// ~~~~~~~~~~~~~~~~~~~
|
|
1355
|
+
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1356
|
+
```
|
|
1357
|
+
|
|
1358
|
+
@example
|
|
1359
|
+
```
|
|
1360
|
+
// Complains if an option's specified type does not conform to the expected type
|
|
1361
|
+
|
|
1362
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1363
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
1364
|
+
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
1365
|
+
|
|
1366
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1367
|
+
// ~~~~~~~~~~~~~~~~
|
|
1368
|
+
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1369
|
+
```
|
|
1370
|
+
*/
|
|
1371
|
+
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends (infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
1372
|
+
) ? Result : never;
|
|
1373
|
+
type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key]; }>>>;
|
|
1374
|
+
/**
|
|
1375
|
+
Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
|
|
1376
|
+
|
|
1377
|
+
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>`.
|
|
1378
|
+
|
|
1379
|
+
Use-case: For collapsing unions created using {@link LiteralUnion}.
|
|
1380
|
+
|
|
1381
|
+
@example
|
|
1382
|
+
```
|
|
1383
|
+
import type {LiteralUnion} from 'type-fest';
|
|
1384
|
+
|
|
1385
|
+
type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
|
|
1386
|
+
//=> string
|
|
1387
|
+
|
|
1388
|
+
type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
|
|
1389
|
+
//=> number
|
|
1390
|
+
|
|
1391
|
+
type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
|
|
1392
|
+
//=> `on${string}`
|
|
1393
|
+
|
|
1394
|
+
type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
|
|
1395
|
+
//=> 'click' | 'change' | `on${string}`
|
|
1396
|
+
|
|
1397
|
+
type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
|
|
1398
|
+
//=> string | null | undefined
|
|
1399
|
+
```
|
|
1400
|
+
*/
|
|
1401
|
+
type CollapseLiterals<T> = {} extends T ? T : T extends (infer U) & {} ? U : T;
|
|
1402
|
+
/**
|
|
1403
|
+
Returns the base type of a branded type.
|
|
1404
|
+
|
|
1405
|
+
@example
|
|
1406
|
+
```
|
|
1407
|
+
type Brand = {readonly __brand: unique symbol};
|
|
1408
|
+
|
|
1409
|
+
type A = UnwrapBrand<string & Brand>;
|
|
1410
|
+
//=> string
|
|
1411
|
+
|
|
1412
|
+
type B = UnwrapBrand<number & Brand>;
|
|
1413
|
+
//=> number
|
|
1414
|
+
|
|
1415
|
+
type C = UnwrapBrand<PropertyKey & Brand>;
|
|
1416
|
+
//=> PropertyKey
|
|
1417
|
+
|
|
1418
|
+
type D = UnwrapBrand<(1 | 200n | 'foo' | 'bar') & Brand>;
|
|
1419
|
+
//=> 1 | 200n | 'foo' | 'bar'
|
|
1420
|
+
```
|
|
1421
|
+
*/
|
|
1422
|
+
type UnwrapBrand<T> = IfNotAnyOrNever<T, {
|
|
1423
|
+
ifNot: _UnwrapBrand<T, Primitive>;
|
|
1424
|
+
}>;
|
|
1425
|
+
type _UnwrapBrand<T, Base> = T extends Primitive ? T extends (infer U) & Pick<T, Exclude<keyof T, KeysOfUnion<Base>>> ? U : T : T;
|
|
1426
|
+
//#endregion
|
|
1427
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-string-literal.d.ts
|
|
1428
|
+
/**
|
|
1429
|
+
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).
|
|
1430
|
+
|
|
1431
|
+
The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
1432
|
+
|
|
1433
|
+
@example
|
|
1434
|
+
```
|
|
1435
|
+
import type {IsStringLiteral} from 'type-fest';
|
|
1436
|
+
|
|
1437
|
+
type A = IsStringLiteral<'foo'>;
|
|
1438
|
+
//=> true
|
|
1439
|
+
|
|
1440
|
+
type B = IsStringLiteral<string>;
|
|
1441
|
+
//=> false
|
|
1442
|
+
|
|
1443
|
+
// String types with infinite set of possible values return `false`
|
|
1444
|
+
type C = IsStringLiteral<`on${string}`>;
|
|
1445
|
+
//=> false
|
|
1446
|
+
|
|
1447
|
+
type D = IsStringLiteral<Uppercase<string>>;
|
|
1448
|
+
//=> false
|
|
1449
|
+
|
|
1450
|
+
type E = IsStringLiteral<'foo' | 'bar' | 'baz'>;
|
|
1451
|
+
//=> true
|
|
1452
|
+
|
|
1453
|
+
type F = IsStringLiteral<'sm' | 'md' | 'lg' | `${number}px`>;
|
|
1454
|
+
//=> boolean
|
|
1455
|
+
```
|
|
1456
|
+
|
|
1457
|
+
@example
|
|
1458
|
+
```
|
|
1459
|
+
import type {IsStringLiteral} from 'type-fest';
|
|
1460
|
+
|
|
1461
|
+
type StringLength<S extends string, Counter extends never[] = []> =
|
|
1462
|
+
IsStringLiteral<S> extends true
|
|
1463
|
+
? S extends `${string}${infer Tail}`
|
|
1464
|
+
? StringLength<Tail, [...Counter, never]>
|
|
1465
|
+
: Counter['length']
|
|
1466
|
+
: number; // return `number` for non-literal string types
|
|
1467
|
+
|
|
1468
|
+
type L1 = StringLength<'foobar'>;
|
|
1469
|
+
//=> 6
|
|
1470
|
+
|
|
1471
|
+
type L2 = StringLength<Lowercase<string>>;
|
|
1472
|
+
//=> number
|
|
1473
|
+
|
|
1474
|
+
type L3 = StringLength<`${number}`>;
|
|
1475
|
+
//=> number
|
|
1476
|
+
```
|
|
1477
|
+
|
|
1478
|
+
@category Type Guard
|
|
1479
|
+
@category Utilities
|
|
1480
|
+
*/
|
|
1481
|
+
type IsStringLiteral<S> = IfNotAnyOrNever<S, {
|
|
1482
|
+
ifNot: _IsStringLiteral<CollapseLiterals<UnwrapBrand<S>>>;
|
|
1483
|
+
ifAny: false;
|
|
1484
|
+
ifNever: false;
|
|
1485
|
+
}>;
|
|
1486
|
+
type _IsStringLiteral<S> =
|
|
1487
|
+
// If `S` is an infinite string type (e.g., `on${string}`), `Record<S, never>` produces an index signature,
|
|
1488
|
+
// and since `{}` extends index signatures, the result becomes `false`.
|
|
1489
|
+
S extends string ? {} extends Record<S, never> ? false : true : false;
|
|
1490
|
+
//#endregion
|
|
1491
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/all-extend.d.ts
|
|
1399
1492
|
/**
|
|
1400
1493
|
@see {@link AllExtend}
|
|
1401
1494
|
*/
|
|
@@ -1496,6 +1589,8 @@ type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllE
|
|
|
1496
1589
|
ifAny: false;
|
|
1497
1590
|
ifNever: false;
|
|
1498
1591
|
}>;
|
|
1592
|
+
//#endregion
|
|
1593
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/except.d.ts
|
|
1499
1594
|
/**
|
|
1500
1595
|
Filter out keys from an object.
|
|
1501
1596
|
|
|
@@ -1594,6 +1689,8 @@ type PostPayloadFixed = Except<UserData, 'email'>;
|
|
|
1594
1689
|
*/
|
|
1595
1690
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
1596
1691
|
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>> : {});
|
|
1692
|
+
//#endregion
|
|
1693
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/promisable.d.ts
|
|
1597
1694
|
/**
|
|
1598
1695
|
Create a type that represents either the value or the value wrapped in `PromiseLike`.
|
|
1599
1696
|
|
|
@@ -1619,6 +1716,8 @@ await logger(() => Promise.resolve('bar'));
|
|
|
1619
1716
|
@category Async
|
|
1620
1717
|
*/
|
|
1621
1718
|
type Promisable<T> = T | PromiseLike<T>;
|
|
1719
|
+
//#endregion
|
|
1720
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-lowercase.d.ts
|
|
1622
1721
|
/**
|
|
1623
1722
|
Returns a boolean for whether the given string literal is lowercase.
|
|
1624
1723
|
|
|
@@ -1645,6 +1744,8 @@ type _IsLowercase<S extends string, Accumulator extends boolean[] = []> = S exte
|
|
|
1645
1744
|
Returns a boolean for whether an individual part of the string is lowercase.
|
|
1646
1745
|
*/
|
|
1647
1746
|
type IsLowercaseHelper<S extends string> = S extends Lowercase<string> ? true : S extends Uppercase<string> | Capitalize<string> | `${string}${Uppercase<string>}${string}` ? false : boolean;
|
|
1747
|
+
//#endregion
|
|
1748
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/is-uppercase.d.ts
|
|
1648
1749
|
/**
|
|
1649
1750
|
Returns a boolean for whether the given string literal is uppercase.
|
|
1650
1751
|
|
|
@@ -1671,6 +1772,8 @@ type _IsUppercase<S extends string, Accumulator extends boolean[] = []> = S exte
|
|
|
1671
1772
|
Returns a boolean for whether an individual part of the string is uppercase.
|
|
1672
1773
|
*/
|
|
1673
1774
|
type IsUppercaseHelper<S extends string> = S extends Uppercase<string> ? true : S extends Lowercase<string> | Uncapitalize<string> | `${string}${Lowercase<string>}${string}` ? false : boolean;
|
|
1775
|
+
//#endregion
|
|
1776
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/words.d.ts
|
|
1674
1777
|
type SkipEmptyWord<Word extends string> = Word extends '' ? [] : [Word];
|
|
1675
1778
|
type RemoveLastCharacter<Sentence extends string, Character extends string> = Sentence extends `${infer LeftSide}${Character}` ? SkipEmptyWord<LeftSide> : never;
|
|
1676
1779
|
/**
|
|
@@ -1785,6 +1888,8 @@ WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord
|
|
|
1785
1888
|
[true, true] extends [IsUppercase<LastCharacter>, IsLowercase<FirstCharacter>] ? [...RemoveLastCharacter<CurrentWord, LastCharacter>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${LastCharacter}${FirstCharacter}`>] :
|
|
1786
1889
|
// No case change: concat word
|
|
1787
1890
|
WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> : [...SkipEmptyWord<CurrentWord>];
|
|
1891
|
+
//#endregion
|
|
1892
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/delimiter-case.d.ts
|
|
1788
1893
|
type _DefaultDelimiterCaseOptions = Merge<_DefaultWordsOptions, {
|
|
1789
1894
|
splitOnNumbers: false;
|
|
1790
1895
|
}>;
|
|
@@ -1834,6 +1939,8 @@ const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
|
|
|
1834
1939
|
*/
|
|
1835
1940
|
type DelimiterCase<Value, Delimiter extends string, Options extends WordsOptions = {}> = Value extends string ? Delimiter extends string // For distributing `Delimiter`
|
|
1836
1941
|
? IsStringLiteral<Value> extends false ? Value : Lowercase<DelimiterCaseFromArray<Words<Value, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>, Delimiter>> : never : Value;
|
|
1942
|
+
//#endregion
|
|
1943
|
+
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/kebab-case.d.ts
|
|
1837
1944
|
/**
|
|
1838
1945
|
Convert a string literal to kebab-case.
|
|
1839
1946
|
|
|
@@ -1872,320 +1979,56 @@ const rawCliOptions: KebabCasedProperties<CliOptions> = {
|
|
|
1872
1979
|
@category Template literal
|
|
1873
1980
|
*/
|
|
1874
1981
|
type KebabCase<Value, Options extends WordsOptions = {}> = DelimiterCase<Value, '-', ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>;
|
|
1982
|
+
//#endregion
|
|
1983
|
+
//#region src/util/types/DeepOmit.d.ts
|
|
1875
1984
|
export 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;
|
|
1985
|
+
//#endregion
|
|
1986
|
+
//#region src/util/types/DeepOptionalUndefined.d.ts
|
|
1876
1987
|
export 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;
|
|
1988
|
+
//#endregion
|
|
1989
|
+
//#region src/models/shared/ToData.d.ts
|
|
1877
1990
|
export type ToData<T> = DeepOptionalUndefined<DeepOmit<T, "toJSON">>;
|
|
1991
|
+
//#endregion
|
|
1992
|
+
//#region src/models/shared/WithMetadata.d.ts
|
|
1878
1993
|
export interface WithMetadata<TBase extends Class<NonNullable<unknown>>> {
|
|
1879
1994
|
new (...args: ConstructorParameters<TBase>): InstanceType<TBase> & ItemMetadata;
|
|
1880
1995
|
prototype: InstanceType<TBase> & ItemMetadata;
|
|
1881
1996
|
}
|
|
1997
|
+
//#endregion
|
|
1998
|
+
//#region src/models/zod/UniqueArraySchemaKey.d.ts
|
|
1999
|
+
export type UniqueArraySchemaKey<TSchema extends z.ZodType> = TSchema extends z.ZodObject ? keyof TSchema["shape"] & string : keyof z.output<TSchema> & string;
|
|
2000
|
+
//#endregion
|
|
2001
|
+
//#region src/models/zod/CreateUniqueArraySchema.d.ts
|
|
2002
|
+
export type CreateUniqueArraySchema = (<TOutput extends object, TInput, TSchema extends z.ZodType<TOutput, TInput>>(schema: TSchema, key: UniqueArraySchemaKey<TSchema>) => z.ZodArray<TSchema>) & (<TOutput extends Primitive, TInput, TSchema extends z.ZodType<TOutput, TInput>>(schema: TSchema) => z.ZodArray<TSchema>);
|
|
2003
|
+
//#endregion
|
|
2004
|
+
//#region src/services/app/constants.d.ts
|
|
1882
2005
|
export declare const MAX_READ_LIMIT = 1e3;
|
|
1883
2006
|
export declare const SITE_NAME = "Esposter";
|
|
1884
2007
|
export declare const KIBIBYTE: number;
|
|
1885
|
-
export declare const MEGABYTE: number;
|
|
1886
2008
|
export declare const GIBIBYTE: number;
|
|
2009
|
+
//#endregion
|
|
2010
|
+
//#region src/services/error/createExponentialBackoff.d.ts
|
|
1887
2011
|
export declare const createExponentialBackoff: (baseDelayMs: number, maxDelayMs: number) => (<T>(operation: () => Promise<T>) => Promise<T>);
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
}
|
|
1891
|
-
declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
|
|
1892
|
-
private _promise;
|
|
1893
|
-
constructor(res: Promise<Result<T, E>>);
|
|
1894
|
-
static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
|
|
1895
|
-
static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
|
|
1896
|
-
static fromThrowable<A extends readonly any[], R, E>(fn: (...args: A) => Promise<R>, errorFn?: (err: unknown) => E): (...args: A) => ResultAsync<R, E>;
|
|
1897
|
-
static combine<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultAsyncs<T>;
|
|
1898
|
-
static combine<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultAsyncs<T>;
|
|
1899
|
-
static combineWithAllErrors<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
|
|
1900
|
-
static combineWithAllErrors<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
|
|
1901
|
-
map<A>(f: (t: T) => A | Promise<A>): ResultAsync<A, E>;
|
|
1902
|
-
andThrough<F>(f: (t: T) => Result<unknown, F> | ResultAsync<unknown, F>): ResultAsync<T, E | F>;
|
|
1903
|
-
andTee(f: (t: T) => unknown): ResultAsync<T, E>;
|
|
1904
|
-
orTee(f: (t: E) => unknown): ResultAsync<T, E>;
|
|
1905
|
-
mapErr<U>(f: (e: E) => U | Promise<U>): ResultAsync<T, U>;
|
|
1906
|
-
andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
1907
|
-
andThen<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferAsyncOkTypes<R>, InferAsyncErrTypes<R> | E>;
|
|
1908
|
-
andThen<U, F>(f: (t: T) => Result<U, F> | ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
1909
|
-
orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
1910
|
-
orElse<R extends ResultAsync<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferAsyncOkTypes<R> | T, InferAsyncErrTypes<R>>;
|
|
1911
|
-
orElse<U, A>(f: (e: E) => Result<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>;
|
|
1912
|
-
match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): Promise<A | B>;
|
|
1913
|
-
unwrapOr<A>(t: A): Promise<T | A>;
|
|
1914
|
-
/**
|
|
1915
|
-
* @deprecated will be removed in 9.0.0.
|
|
1916
|
-
*
|
|
1917
|
-
* You can use `safeTry` without this method.
|
|
1918
|
-
* @example
|
|
1919
|
-
* ```typescript
|
|
1920
|
-
* safeTry(async function* () {
|
|
1921
|
-
* const okValue = yield* yourResult
|
|
1922
|
-
* })
|
|
1923
|
-
* ```
|
|
1924
|
-
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
1925
|
-
*/
|
|
1926
|
-
safeUnwrap(): AsyncGenerator<Err<never, E>, T>;
|
|
1927
|
-
then<A, B>(successCallback?: (res: Result<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
|
|
1928
|
-
[Symbol.asyncIterator](): AsyncGenerator<Err<never, E>, T>;
|
|
1929
|
-
}
|
|
1930
|
-
declare type CombineResultAsyncs<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number]>;
|
|
1931
|
-
declare type CombineResultsWithAllErrorsArrayAsync<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrorsAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number][]>;
|
|
1932
|
-
declare type UnwrapAsync<T> = IsLiteralArray<T> extends 1 ? Writable<T> extends [infer H, ...infer Rest] ? H extends PromiseLike<infer HI> ? HI extends Result<unknown, unknown> ? [Dedup<HI>, ...UnwrapAsync<Rest>] : never : never : [] : T extends Array<infer A> ? A extends PromiseLike<infer HI> ? HI extends Result<infer L, infer R> ? Ok<L, R>[] : never : never : never;
|
|
1933
|
-
declare type TraverseAsync<T, Depth extends number = 5> = IsLiteralArray<T> extends 1 ? Combine<T, Depth> extends [infer Oks, infer Errs] ? ResultAsync<EmptyArrayToNever<Oks>, MembersToUnion<Errs>> : never : T extends Array<infer I> ? Combine<MemberListOf<I>, Depth> extends [infer Oks, infer Errs] ? Oks extends unknown[] ? Errs extends unknown[] ? ResultAsync<EmptyArrayToNever<Oks[number][]>, MembersToUnion<Errs[number][]>> : ResultAsync<EmptyArrayToNever<Oks[number][]>, Errs> : Errs extends unknown[] ? ResultAsync<Oks, MembersToUnion<Errs[number][]>> : ResultAsync<Oks, Errs> : never : never;
|
|
1934
|
-
declare type TraverseWithAllErrorsAsync<T, Depth extends number = 5> = TraverseAsync<T, Depth> extends ResultAsync<infer Oks, infer Errs> ? ResultAsync<Oks, Errs[]> : never;
|
|
1935
|
-
declare type Writable<T> = T extends ReadonlyArray<unknown> ? [...T] : T;
|
|
1936
|
-
declare type ExtractOkTypes<T extends readonly Result<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result<infer U, unknown> ? U : never; };
|
|
1937
|
-
declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never; };
|
|
1938
|
-
declare type ExtractErrTypes<T extends readonly Result<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result<unknown, infer E> ? E : never; };
|
|
1939
|
-
declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never; };
|
|
1940
|
-
declare type InferOkTypes<R> = R extends Result<infer T, unknown> ? T : never;
|
|
1941
|
-
declare type InferErrTypes<R> = R extends Result<unknown, infer E> ? E : never;
|
|
1942
|
-
declare type InferAsyncOkTypes<R> = R extends ResultAsync<infer T, unknown> ? T : never;
|
|
1943
|
-
declare type InferAsyncErrTypes<R> = R extends ResultAsync<unknown, infer E> ? E : never;
|
|
1944
|
-
declare namespace Result {
|
|
1945
|
-
/**
|
|
1946
|
-
* Wraps a function with a try catch, creating a new function with the same
|
|
1947
|
-
* arguments but returning `Ok` if successful, `Err` if the function throws
|
|
1948
|
-
*
|
|
1949
|
-
* @param fn function to wrap with ok on success or err on failure
|
|
1950
|
-
* @param errorFn when an error is thrown, this will wrap the error result if provided
|
|
1951
|
-
*/
|
|
1952
|
-
function fromThrowable<Fn extends (...args: readonly any[]) => any, E>(fn: Fn, errorFn?: (e: unknown) => E): (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E>;
|
|
1953
|
-
function combine<T extends readonly [Result<unknown, unknown>, ...Result<unknown, unknown>[]]>(resultList: T): CombineResults<T>;
|
|
1954
|
-
function combine<T extends readonly Result<unknown, unknown>[]>(resultList: T): CombineResults<T>;
|
|
1955
|
-
function combineWithAllErrors<T extends readonly [Result<unknown, unknown>, ...Result<unknown, unknown>[]]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
|
|
1956
|
-
function combineWithAllErrors<T extends readonly Result<unknown, unknown>[]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
|
|
1957
|
-
}
|
|
1958
|
-
declare type Result<T, E> = Ok<T, E> | Err<T, E>;
|
|
1959
|
-
interface IResult<T, E> {
|
|
1960
|
-
/**
|
|
1961
|
-
* Used to check if a `Result` is an `OK`
|
|
1962
|
-
*
|
|
1963
|
-
* @returns `true` if the result is an `OK` variant of Result
|
|
1964
|
-
*/
|
|
1965
|
-
isOk(): this is Ok<T, E>;
|
|
1966
|
-
/**
|
|
1967
|
-
* Used to check if a `Result` is an `Err`
|
|
1968
|
-
*
|
|
1969
|
-
* @returns `true` if the result is an `Err` variant of Result
|
|
1970
|
-
*/
|
|
1971
|
-
isErr(): this is Err<T, E>;
|
|
1972
|
-
/**
|
|
1973
|
-
* Maps a `Result<T, E>` to `Result<U, E>`
|
|
1974
|
-
* by applying a function to a contained `Ok` value, leaving an `Err` value
|
|
1975
|
-
* untouched.
|
|
1976
|
-
*
|
|
1977
|
-
* @param f The function to apply an `OK` value
|
|
1978
|
-
* @returns the result of applying `f` or an `Err` untouched
|
|
1979
|
-
*/
|
|
1980
|
-
map<A>(f: (t: T) => A): Result<A, E>;
|
|
1981
|
-
/**
|
|
1982
|
-
* Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
|
|
1983
|
-
* contained `Err` value, leaving an `Ok` value untouched.
|
|
1984
|
-
*
|
|
1985
|
-
* This function can be used to pass through a successful result while
|
|
1986
|
-
* handling an error.
|
|
1987
|
-
*
|
|
1988
|
-
* @param f a function to apply to the error `Err` value
|
|
1989
|
-
*/
|
|
1990
|
-
mapErr<U>(f: (e: E) => U): Result<T, U>;
|
|
1991
|
-
/**
|
|
1992
|
-
* Similar to `map` Except you must return a new `Result`.
|
|
1993
|
-
*
|
|
1994
|
-
* This is useful for when you need to do a subsequent computation using the
|
|
1995
|
-
* inner `T` value, but that computation might fail.
|
|
1996
|
-
* Additionally, `andThen` is really useful as a tool to flatten a
|
|
1997
|
-
* `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).
|
|
1998
|
-
*
|
|
1999
|
-
* @param f The function to apply to the current value
|
|
2000
|
-
*/
|
|
2001
|
-
andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
2002
|
-
andThen<U, F>(f: (t: T) => Result<U, F>): Result<U, E | F>;
|
|
2003
|
-
/**
|
|
2004
|
-
* This "tee"s the current value to an passed-in computation such as side
|
|
2005
|
-
* effect functions but still returns the same current value as the result.
|
|
2006
|
-
*
|
|
2007
|
-
* This is useful when you want to pass the current result to your side-track
|
|
2008
|
-
* work such as logging but want to continue main-track work after that.
|
|
2009
|
-
* This method does not care about the result of the passed in computation.
|
|
2010
|
-
*
|
|
2011
|
-
* @param f The function to apply to the current value
|
|
2012
|
-
*/
|
|
2013
|
-
andTee(f: (t: T) => unknown): Result<T, E>;
|
|
2014
|
-
/**
|
|
2015
|
-
* This "tee"s the current `Err` value to an passed-in computation such as side
|
|
2016
|
-
* effect functions but still returns the same `Err` value as the result.
|
|
2017
|
-
*
|
|
2018
|
-
* This is useful when you want to pass the current `Err` value to your side-track
|
|
2019
|
-
* work such as logging but want to continue error-track work after that.
|
|
2020
|
-
* This method does not care about the result of the passed in computation.
|
|
2021
|
-
*
|
|
2022
|
-
* @param f The function to apply to the current `Err` value
|
|
2023
|
-
*/
|
|
2024
|
-
orTee(f: (t: E) => unknown): Result<T, E>;
|
|
2025
|
-
/**
|
|
2026
|
-
* Similar to `andTee` except error result of the computation will be passed
|
|
2027
|
-
* to the downstream in case of an error.
|
|
2028
|
-
*
|
|
2029
|
-
* This version is useful when you want to make side-effects but in case of an
|
|
2030
|
-
* error, you want to pass the error to the downstream.
|
|
2031
|
-
*
|
|
2032
|
-
* @param f The function to apply to the current value
|
|
2033
|
-
*/
|
|
2034
|
-
andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>;
|
|
2035
|
-
andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>;
|
|
2036
|
-
/**
|
|
2037
|
-
* Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.
|
|
2038
|
-
*
|
|
2039
|
-
* This is useful for error recovery.
|
|
2040
|
-
*
|
|
2041
|
-
*
|
|
2042
|
-
* @param f A function to apply to an `Err` value, leaving `Ok` values
|
|
2043
|
-
* untouched.
|
|
2044
|
-
*/
|
|
2045
|
-
orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
2046
|
-
orElse<U, A>(f: (e: E) => Result<U, A>): Result<U | T, A>;
|
|
2047
|
-
/**
|
|
2048
|
-
* Similar to `map` Except you must return a new `Result`.
|
|
2049
|
-
*
|
|
2050
|
-
* This is useful for when you need to do a subsequent async computation using
|
|
2051
|
-
* the inner `T` value, but that computation might fail. Must return a ResultAsync
|
|
2052
|
-
*
|
|
2053
|
-
* @param f The function that returns a `ResultAsync` to apply to the current
|
|
2054
|
-
* value
|
|
2055
|
-
*/
|
|
2056
|
-
asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
2057
|
-
/**
|
|
2058
|
-
* Maps a `Result<T, E>` to `ResultAsync<U, E>`
|
|
2059
|
-
* by applying an async function to a contained `Ok` value, leaving an `Err`
|
|
2060
|
-
* value untouched.
|
|
2061
|
-
*
|
|
2062
|
-
* @param f An async function to apply an `OK` value
|
|
2063
|
-
*/
|
|
2064
|
-
asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
|
|
2065
|
-
/**
|
|
2066
|
-
* Unwrap the `Ok` value, or return the default if there is an `Err`
|
|
2067
|
-
*
|
|
2068
|
-
* @param v the default value to return if there is an `Err`
|
|
2069
|
-
*/
|
|
2070
|
-
unwrapOr<A>(v: A): T | A;
|
|
2071
|
-
/**
|
|
2072
|
-
*
|
|
2073
|
-
* Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
|
|
2074
|
-
* execute the function that matches the `Result` variant.
|
|
2075
|
-
*
|
|
2076
|
-
* Match callbacks do not necessitate to return a `Result`, however you can
|
|
2077
|
-
* return a `Result` if you want to.
|
|
2078
|
-
*
|
|
2079
|
-
* `match` is like chaining `map` and `mapErr`, with the distinction that
|
|
2080
|
-
* with `match` both functions must have the same return type.
|
|
2081
|
-
*
|
|
2082
|
-
* @param ok
|
|
2083
|
-
* @param err
|
|
2084
|
-
*/
|
|
2085
|
-
match<A, B = A>(ok: (t: T) => A, err: (e: E) => B): A | B;
|
|
2086
|
-
/**
|
|
2087
|
-
* @deprecated will be removed in 9.0.0.
|
|
2088
|
-
*
|
|
2089
|
-
* You can use `safeTry` without this method.
|
|
2090
|
-
* @example
|
|
2091
|
-
* ```typescript
|
|
2092
|
-
* safeTry(function* () {
|
|
2093
|
-
* const okValue = yield* yourResult
|
|
2094
|
-
* })
|
|
2095
|
-
* ```
|
|
2096
|
-
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
2097
|
-
*/
|
|
2098
|
-
safeUnwrap(): Generator<Err<never, E>, T>;
|
|
2099
|
-
/**
|
|
2100
|
-
* **This method is unsafe, and should only be used in a test environments**
|
|
2101
|
-
*
|
|
2102
|
-
* Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
|
|
2103
|
-
*
|
|
2104
|
-
* @param config
|
|
2105
|
-
*/
|
|
2106
|
-
_unsafeUnwrap(config?: ErrorConfig): T;
|
|
2107
|
-
/**
|
|
2108
|
-
* **This method is unsafe, and should only be used in a test environments**
|
|
2109
|
-
*
|
|
2110
|
-
* takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
|
|
2111
|
-
* otherwise it throws a custom object.
|
|
2112
|
-
*
|
|
2113
|
-
* @param config
|
|
2114
|
-
*/
|
|
2115
|
-
_unsafeUnwrapErr(config?: ErrorConfig): E;
|
|
2116
|
-
}
|
|
2117
|
-
declare class Ok<T, E> implements IResult<T, E> {
|
|
2118
|
-
readonly value: T;
|
|
2119
|
-
constructor(value: T);
|
|
2120
|
-
isOk(): this is Ok<T, E>;
|
|
2121
|
-
isErr(): this is Err<T, E>;
|
|
2122
|
-
map<A>(f: (t: T) => A): Result<A, E>;
|
|
2123
|
-
mapErr<U>(_f: (e: E) => U): Result<T, U>;
|
|
2124
|
-
andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
2125
|
-
andThen<U, F>(f: (t: T) => Result<U, F>): Result<U, E | F>;
|
|
2126
|
-
andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>;
|
|
2127
|
-
andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>;
|
|
2128
|
-
andTee(f: (t: T) => unknown): Result<T, E>;
|
|
2129
|
-
orTee(_f: (t: E) => unknown): Result<T, E>;
|
|
2130
|
-
orElse<R extends Result<unknown, unknown>>(_f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
2131
|
-
orElse<U, A>(_f: (e: E) => Result<U, A>): Result<U | T, A>;
|
|
2132
|
-
asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
2133
|
-
asyncAndThrough<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<T, InferAsyncErrTypes<R> | E>;
|
|
2134
|
-
asyncAndThrough<F>(f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
|
|
2135
|
-
asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
|
|
2136
|
-
unwrapOr<A>(_v: A): T | A;
|
|
2137
|
-
match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): A | B;
|
|
2138
|
-
safeUnwrap(): Generator<Err<never, E>, T>;
|
|
2139
|
-
_unsafeUnwrap(_?: ErrorConfig): T;
|
|
2140
|
-
_unsafeUnwrapErr(config?: ErrorConfig): E;
|
|
2141
|
-
[Symbol.iterator](): Generator<Err<never, E>, T>;
|
|
2142
|
-
}
|
|
2143
|
-
declare class Err<T, E> implements IResult<T, E> {
|
|
2144
|
-
readonly error: E;
|
|
2145
|
-
constructor(error: E);
|
|
2146
|
-
isOk(): this is Ok<T, E>;
|
|
2147
|
-
isErr(): this is Err<T, E>;
|
|
2148
|
-
map<A>(_f: (t: T) => A): Result<A, E>;
|
|
2149
|
-
mapErr<U>(f: (e: E) => U): Result<T, U>;
|
|
2150
|
-
andThrough<F>(_f: (t: T) => Result<unknown, F>): Result<T, E | F>;
|
|
2151
|
-
andTee(_f: (t: T) => unknown): Result<T, E>;
|
|
2152
|
-
orTee(f: (t: E) => unknown): Result<T, E>;
|
|
2153
|
-
andThen<R extends Result<unknown, unknown>>(_f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
2154
|
-
andThen<U, F>(_f: (t: T) => Result<U, F>): Result<U, E | F>;
|
|
2155
|
-
orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
2156
|
-
orElse<U, A>(f: (e: E) => Result<U, A>): Result<U | T, A>;
|
|
2157
|
-
asyncAndThen<U, F>(_f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
2158
|
-
asyncAndThrough<F>(_f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
|
|
2159
|
-
asyncMap<U>(_f: (t: T) => Promise<U>): ResultAsync<U, E>;
|
|
2160
|
-
unwrapOr<A>(v: A): T | A;
|
|
2161
|
-
match<A, B = A>(_ok: (t: T) => A, err: (e: E) => B): A | B;
|
|
2162
|
-
safeUnwrap(): Generator<Err<never, E>, T>;
|
|
2163
|
-
_unsafeUnwrap(config?: ErrorConfig): T;
|
|
2164
|
-
_unsafeUnwrapErr(_?: ErrorConfig): E;
|
|
2165
|
-
[Symbol.iterator](): Generator<Err<never, E>, T>;
|
|
2166
|
-
}
|
|
2167
|
-
declare type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, ...0[]];
|
|
2168
|
-
declare type CollectResults<T, Collected extends unknown[] = [], Depth extends number = 50> = [Depth] extends [never] ? [] : T extends [infer H, ...infer Rest] ? H extends Result<infer L, infer R> ? CollectResults<Rest, [...Collected, [L, R]], Prev[Depth]> : never : Collected;
|
|
2169
|
-
declare type Transpose<A, Transposed extends unknown[][] = [], Depth extends number = 10> = A extends [infer T, ...infer Rest] ? T extends [infer L, infer R] ? Transposed extends [infer PL, infer PR] ? PL extends unknown[] ? PR extends unknown[] ? Transpose<Rest, [[...PL, L], [...PR, R]], Prev[Depth]> : never : never : Transpose<Rest, [[L], [R]], Prev[Depth]> : Transposed : Transposed;
|
|
2170
|
-
declare type Combine<T, Depth extends number = 5> = Transpose<CollectResults<T>, [], Depth> extends [infer L, infer R] ? [UnknownMembersToNever<L>, UnknownMembersToNever<R>] : Transpose<CollectResults<T>, [], Depth> extends [] ? [[], []] : never;
|
|
2171
|
-
declare type Dedup<T> = T extends Result<infer RL, infer RR> ? [unknown] extends [RL] ? Err<RL, RR> : Ok<RL, RR> : T;
|
|
2172
|
-
declare type MemberListOf<T> = ((T extends unknown ? (t: T) => T : never) extends (infer U) ? (U extends unknown ? (u: U) => unknown : never) extends ((v: infer V) => unknown) ? V : never : never) extends ((_: unknown) => infer W) ? [...MemberListOf<Exclude<T, W>>, W] : [];
|
|
2173
|
-
declare type EmptyArrayToNever<T, NeverArrayToNever extends number = 0> = T extends [] ? never : NeverArrayToNever extends 1 ? T extends [never, ...infer Rest] ? [EmptyArrayToNever<Rest>] extends [never] ? never : T : T : T;
|
|
2174
|
-
declare type UnknownMembersToNever<T> = T extends [infer H, ...infer R] ? [[unknown] extends [H] ? never : H, ...UnknownMembersToNever<R>] : T;
|
|
2175
|
-
declare type MembersToUnion<T> = T extends unknown[] ? T[number] : never;
|
|
2176
|
-
declare type IsLiteralArray<T> = T extends {
|
|
2177
|
-
length: infer L;
|
|
2178
|
-
} ? L extends number ? number extends L ? 0 : 1 : 0 : 0;
|
|
2179
|
-
declare type Traverse<T, Depth extends number = 5> = Combine<T, Depth> extends [infer Oks, infer Errs] ? Result<EmptyArrayToNever<Oks, 1>, MembersToUnion<Errs>> : never;
|
|
2180
|
-
declare type TraverseWithAllErrors<T, Depth extends number = 5> = Traverse<T, Depth> extends Result<infer Oks, infer Errs> ? Result<Oks, Errs[]> : never;
|
|
2181
|
-
declare type CombineResults<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
|
|
2182
|
-
declare type CombineResultsWithAllErrorsArray<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
|
|
2012
|
+
//#endregion
|
|
2013
|
+
//#region src/services/error/getResult.d.ts
|
|
2183
2014
|
export declare const getResult: <T>(fn: () => T) => Result<T, Error>;
|
|
2015
|
+
//#endregion
|
|
2016
|
+
//#region src/services/error/getResultAsync.d.ts
|
|
2184
2017
|
export declare const getResultAsync: <T>(fn: () => Promise<T>) => ResultAsync<T, Error>;
|
|
2018
|
+
//#endregion
|
|
2019
|
+
//#region src/services/error/toAppError.d.ts
|
|
2185
2020
|
export declare const toAppError: (error: unknown) => Error;
|
|
2021
|
+
//#endregion
|
|
2022
|
+
//#region src/services/error/withFinalizer.d.ts
|
|
2186
2023
|
export declare const withFinalizer: <T>(fn: () => T, finalizer?: () => void) => T;
|
|
2024
|
+
//#endregion
|
|
2025
|
+
//#region src/services/error/withFinalizerAsync.d.ts
|
|
2187
2026
|
export declare const withFinalizerAsync: <T>(fn: () => Promisable<T>, finalizer?: () => Promisable<void>) => Promise<T>;
|
|
2027
|
+
//#endregion
|
|
2028
|
+
//#region src/services/message/classifyMentions.d.ts
|
|
2188
2029
|
export declare const classifyMentions: (message: string) => ClassifiedMentions;
|
|
2030
|
+
//#endregion
|
|
2031
|
+
//#region src/services/message/constants.d.ts
|
|
2189
2032
|
export declare const MENTION_ID_ATTRIBUTE = "data-id";
|
|
2190
2033
|
export declare const MENTION_ITEM_TYPE_ATTRIBUTE = "data-mention-type";
|
|
2191
2034
|
export declare const MENTION_LABEL_ATTRIBUTE = "data-label";
|
|
@@ -2197,342 +2040,161 @@ export declare const MENTION_EVERYONE_ID = "@everyone";
|
|
|
2197
2040
|
export declare const CUSTOM_EMOJI_ID_ATTRIBUTE = "data-custom-emoji-id";
|
|
2198
2041
|
export declare const CUSTOM_EMOJI_NAME_ATTRIBUTE = "data-custom-emoji-name";
|
|
2199
2042
|
export declare const CUSTOM_EMOJI_TYPE = "customEmoji";
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
private voidTags;
|
|
2203
|
-
constructor(addClosingSlash?: boolean, tags?: string[]);
|
|
2204
|
-
formatNode(tag: string, attrs: string, innerHTML: string): string;
|
|
2205
|
-
isVoidElement(tag: string): boolean;
|
|
2206
|
-
}
|
|
2207
|
-
declare enum NodeType {
|
|
2208
|
-
ELEMENT_NODE = 1,
|
|
2209
|
-
TEXT_NODE = 3,
|
|
2210
|
-
COMMENT_NODE = 8
|
|
2211
|
-
}
|
|
2212
|
-
/**
|
|
2213
|
-
* Node Class as base class for TextNode and HTMLElement.
|
|
2214
|
-
*/
|
|
2215
|
-
declare abstract class Node {
|
|
2216
|
-
parentNode: HTMLElement | null;
|
|
2217
|
-
abstract rawTagName: string;
|
|
2218
|
-
abstract nodeType: NodeType;
|
|
2219
|
-
childNodes: Node[];
|
|
2220
|
-
range: readonly [number, number];
|
|
2221
|
-
abstract text: string;
|
|
2222
|
-
abstract rawText: string;
|
|
2223
|
-
abstract toString(): string;
|
|
2224
|
-
abstract clone(): Node;
|
|
2225
|
-
constructor(parentNode?: HTMLElement | null, range?: [number, number]);
|
|
2226
|
-
/**
|
|
2227
|
-
* Remove current node
|
|
2228
|
-
*/
|
|
2229
|
-
remove(): this;
|
|
2230
|
-
get innerText(): string;
|
|
2231
|
-
get textContent(): string;
|
|
2232
|
-
set textContent(val: string);
|
|
2233
|
-
}
|
|
2234
|
-
interface KeyAttributes {
|
|
2235
|
-
id?: string;
|
|
2236
|
-
class?: string;
|
|
2237
|
-
}
|
|
2238
|
-
interface Attributes {
|
|
2239
|
-
[key: string]: string;
|
|
2240
|
-
}
|
|
2241
|
-
interface RawAttributes {
|
|
2242
|
-
[key: string]: string;
|
|
2243
|
-
}
|
|
2244
|
-
type InsertPosition = 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend';
|
|
2245
|
-
type NodeInsertable = Node | string;
|
|
2246
|
-
declare class DOMTokenList {
|
|
2247
|
-
private _set;
|
|
2248
|
-
private _afterUpdate;
|
|
2249
|
-
private _validate;
|
|
2250
|
-
constructor(valuesInit?: string[], afterUpdate?: (t: DOMTokenList) => void);
|
|
2251
|
-
add(c: string): void;
|
|
2252
|
-
replace(c1: string, c2: string): void;
|
|
2253
|
-
remove(c: string): void;
|
|
2254
|
-
toggle(c: string): void;
|
|
2255
|
-
contains(c: string): boolean;
|
|
2256
|
-
get length(): number;
|
|
2257
|
-
values(): SetIterator<string>;
|
|
2258
|
-
get value(): string[];
|
|
2259
|
-
toString(): string;
|
|
2260
|
-
}
|
|
2261
|
-
/**
|
|
2262
|
-
* HTMLElement, which contains a set of children.
|
|
2263
|
-
*
|
|
2264
|
-
* Note: this is a minimalist implementation, no complete tree
|
|
2265
|
-
* structure provided (no parentNode, nextSibling,
|
|
2266
|
-
* previousSibling etc).
|
|
2267
|
-
* @class HTMLElement
|
|
2268
|
-
* @extends {Node}
|
|
2269
|
-
*/
|
|
2270
|
-
declare class HTMLElement extends Node {
|
|
2271
|
-
rawAttrs: string;
|
|
2272
|
-
private voidTag;
|
|
2273
|
-
private _attrs;
|
|
2274
|
-
private _rawAttrs;
|
|
2275
|
-
private _parseOptions;
|
|
2276
|
-
private _id;
|
|
2277
|
-
rawTagName: string;
|
|
2278
|
-
classList: DOMTokenList;
|
|
2279
|
-
/**
|
|
2280
|
-
* Node Type declaration.
|
|
2281
|
-
*/
|
|
2282
|
-
nodeType: NodeType;
|
|
2283
|
-
/**
|
|
2284
|
-
* Quote attribute values
|
|
2285
|
-
* @param attr attribute value
|
|
2286
|
-
* @returns {string} quoted value
|
|
2287
|
-
*/
|
|
2288
|
-
private quoteAttribute;
|
|
2289
|
-
/**
|
|
2290
|
-
* Creates an instance of HTMLElement.
|
|
2291
|
-
* @param keyAttrs id and class attribute
|
|
2292
|
-
* @param [rawAttrs] attributes in string
|
|
2293
|
-
*
|
|
2294
|
-
* @memberof HTMLElement
|
|
2295
|
-
*/
|
|
2296
|
-
constructor(tagName: string, keyAttrs: KeyAttributes, rawAttrs?: string, parentNode?: HTMLElement | null, range?: [number, number], voidTag?: VoidTag, _parseOptions?: Partial<Options>);
|
|
2297
|
-
/**
|
|
2298
|
-
* Remove Child element from childNodes array
|
|
2299
|
-
* @param {HTMLElement} node node to remove
|
|
2300
|
-
*/
|
|
2301
|
-
removeChild(node: Node): this;
|
|
2302
|
-
/**
|
|
2303
|
-
* Exchanges given child with new child
|
|
2304
|
-
* @param {HTMLElement} oldNode node to exchange
|
|
2305
|
-
* @param {HTMLElement} newNode new node
|
|
2306
|
-
*/
|
|
2307
|
-
exchangeChild(oldNode: Node, newNode: Node): this;
|
|
2308
|
-
get tagName(): string;
|
|
2309
|
-
set tagName(newname: string);
|
|
2310
|
-
get localName(): string;
|
|
2311
|
-
get isVoidElement(): boolean;
|
|
2312
|
-
get id(): string;
|
|
2313
|
-
set id(newid: string);
|
|
2314
|
-
/**
|
|
2315
|
-
* Get escpaed (as-it) text value of current node and its children.
|
|
2316
|
-
* @return {string} text content
|
|
2317
|
-
*/
|
|
2318
|
-
get rawText(): string;
|
|
2319
|
-
get textContent(): string;
|
|
2320
|
-
set textContent(val: string);
|
|
2321
|
-
/**
|
|
2322
|
-
* Get unescaped text value of current node and its children.
|
|
2323
|
-
* @return {string} text content
|
|
2324
|
-
*/
|
|
2325
|
-
get text(): string;
|
|
2326
|
-
/**
|
|
2327
|
-
* Get structured Text (with '\n' etc.)
|
|
2328
|
-
* @return {string} structured text
|
|
2329
|
-
*/
|
|
2330
|
-
get structuredText(): string;
|
|
2331
|
-
toString(): string;
|
|
2332
|
-
get innerHTML(): string;
|
|
2333
|
-
set innerHTML(content: string);
|
|
2334
|
-
set_content(content: string | Node | Node[], options?: Partial<Options>): this;
|
|
2335
|
-
replaceWith(...nodes: (string | Node)[]): this;
|
|
2336
|
-
get outerHTML(): string;
|
|
2337
|
-
/**
|
|
2338
|
-
* Trim element from right (in block) after seeing pattern in a TextNode.
|
|
2339
|
-
* @param {RegExp} pattern pattern to find
|
|
2340
|
-
* @return {HTMLElement} reference to current node
|
|
2341
|
-
*/
|
|
2342
|
-
trimRight(pattern: RegExp): this;
|
|
2343
|
-
/**
|
|
2344
|
-
* Get DOM structure
|
|
2345
|
-
* @return {string} structure
|
|
2346
|
-
*/
|
|
2347
|
-
get structure(): string;
|
|
2348
|
-
/**
|
|
2349
|
-
* Remove whitespaces in this sub tree.
|
|
2350
|
-
* @return {HTMLElement} pointer to this
|
|
2351
|
-
*/
|
|
2352
|
-
removeWhitespace(): this;
|
|
2353
|
-
/**
|
|
2354
|
-
* Query CSS selector to find matching nodes.
|
|
2355
|
-
* @param {string} selector Simplified CSS selector
|
|
2356
|
-
* @return {HTMLElement[]} matching elements
|
|
2357
|
-
*/
|
|
2358
|
-
querySelectorAll(selector: string): HTMLElement[];
|
|
2359
|
-
/**
|
|
2360
|
-
* Query CSS Selector to find matching node.
|
|
2361
|
-
* @param {string} selector Simplified CSS selector
|
|
2362
|
-
* @return {(HTMLElement|null)} matching node
|
|
2363
|
-
*/
|
|
2364
|
-
querySelector(selector: string): HTMLElement | null;
|
|
2365
|
-
/**
|
|
2366
|
-
* Tests whether the node matches a given CSS selector.
|
|
2367
|
-
* @param {string} selector Simplified CSS selector
|
|
2368
|
-
* @return {boolean}
|
|
2369
|
-
*/
|
|
2370
|
-
matches(selector: string): boolean;
|
|
2371
|
-
/**
|
|
2372
|
-
* find elements by their tagName
|
|
2373
|
-
* @param {string} tagName the tagName of the elements to select
|
|
2374
|
-
*/
|
|
2375
|
-
getElementsByTagName(tagName: string): Array<HTMLElement>;
|
|
2376
|
-
/**
|
|
2377
|
-
* find element by it's id
|
|
2378
|
-
* @param {string} id the id of the element to select
|
|
2379
|
-
* @returns {HTMLElement | null} the element with the given id or null if not found
|
|
2380
|
-
*/
|
|
2381
|
-
getElementById(id: string): HTMLElement | null;
|
|
2382
|
-
/**
|
|
2383
|
-
* traverses the Element and its parents (heading toward the document root) until it finds a node that matches the provided selector string. Will return itself or the matching ancestor. If no such element exists, it returns null.
|
|
2384
|
-
* @param selector a DOMString containing a selector list
|
|
2385
|
-
* @returns {HTMLElement | null} the element with the given id or null if not found
|
|
2386
|
-
*/
|
|
2387
|
-
closest(selector: string): HTMLElement | null;
|
|
2388
|
-
/**
|
|
2389
|
-
* Append a child node to childNodes
|
|
2390
|
-
* @param {Node} node node to append
|
|
2391
|
-
* @return {Node} node appended
|
|
2392
|
-
*/
|
|
2393
|
-
appendChild<T extends Node = Node>(node: T): T;
|
|
2394
|
-
/**
|
|
2395
|
-
* Get attributes
|
|
2396
|
-
* @access private
|
|
2397
|
-
* @return {Object} parsed and unescaped attributes
|
|
2398
|
-
*/
|
|
2399
|
-
get attrs(): Attributes;
|
|
2400
|
-
get attributes(): Record<string, string>;
|
|
2401
|
-
/**
|
|
2402
|
-
* Get escaped (as-is) attributes
|
|
2403
|
-
* @return {Object} parsed attributes
|
|
2404
|
-
*/
|
|
2405
|
-
get rawAttributes(): RawAttributes;
|
|
2406
|
-
removeAttribute(key: string): this;
|
|
2407
|
-
hasAttribute(key: string): boolean;
|
|
2408
|
-
/**
|
|
2409
|
-
* Get an attribute
|
|
2410
|
-
* @return {string | undefined} value of the attribute; or undefined if not exist
|
|
2411
|
-
*/
|
|
2412
|
-
getAttribute(key: string): string | undefined;
|
|
2413
|
-
/**
|
|
2414
|
-
* Set an attribute value to the HTMLElement
|
|
2415
|
-
* @param {string} key The attribute name
|
|
2416
|
-
* @param {string} value The value to set, or null / undefined to remove an attribute
|
|
2417
|
-
*/
|
|
2418
|
-
setAttribute(key: string, value: string): this;
|
|
2419
|
-
/**
|
|
2420
|
-
* Replace all the attributes of the HTMLElement by the provided attributes
|
|
2421
|
-
* @param {Attributes} attributes the new attribute set
|
|
2422
|
-
*/
|
|
2423
|
-
setAttributes(attributes: Attributes): this;
|
|
2424
|
-
insertAdjacentHTML(where: InsertPosition, html: string): this;
|
|
2425
|
-
/** Prepend nodes or strings to this node's children. */
|
|
2426
|
-
prepend(...insertable: NodeInsertable[]): void;
|
|
2427
|
-
/** Append nodes or strings to this node's children. */
|
|
2428
|
-
append(...insertable: NodeInsertable[]): void;
|
|
2429
|
-
/** Insert nodes or strings before this node. */
|
|
2430
|
-
before(...insertable: NodeInsertable[]): void;
|
|
2431
|
-
/** Insert nodes or strings after this node. */
|
|
2432
|
-
after(...insertable: NodeInsertable[]): void;
|
|
2433
|
-
get nextSibling(): Node | null;
|
|
2434
|
-
get nextElementSibling(): HTMLElement | null;
|
|
2435
|
-
get previousSibling(): Node | null;
|
|
2436
|
-
get previousElementSibling(): HTMLElement | null;
|
|
2437
|
-
/** Get all childNodes of type {@link HTMLElement}. */
|
|
2438
|
-
get children(): HTMLElement[];
|
|
2439
|
-
/**
|
|
2440
|
-
* Get the first child node.
|
|
2441
|
-
* @return The first child or undefined if none exists.
|
|
2442
|
-
*/
|
|
2443
|
-
get firstChild(): Node | undefined;
|
|
2444
|
-
/**
|
|
2445
|
-
* Get the first child node of type {@link HTMLElement}.
|
|
2446
|
-
* @return The first child element or undefined if none exists.
|
|
2447
|
-
*/
|
|
2448
|
-
get firstElementChild(): HTMLElement | undefined;
|
|
2449
|
-
/**
|
|
2450
|
-
* Get the last child node.
|
|
2451
|
-
* @return The last child or undefined if none exists.
|
|
2452
|
-
*/
|
|
2453
|
-
get lastChild(): Node | undefined;
|
|
2454
|
-
/**
|
|
2455
|
-
* Get the last child node of type {@link HTMLElement}.
|
|
2456
|
-
* @return The last child element or undefined if none exists.
|
|
2457
|
-
*/
|
|
2458
|
-
get lastElementChild(): HTMLElement | undefined;
|
|
2459
|
-
get childElementCount(): number;
|
|
2460
|
-
get classNames(): string;
|
|
2461
|
-
/** Clone this Node */
|
|
2462
|
-
clone(): Node;
|
|
2463
|
-
}
|
|
2464
|
-
interface Options {
|
|
2465
|
-
lowerCaseTagName?: boolean;
|
|
2466
|
-
comment?: boolean;
|
|
2467
|
-
/**
|
|
2468
|
-
* @see PR #215 for explanation
|
|
2469
|
-
*/
|
|
2470
|
-
fixNestedATags?: boolean;
|
|
2471
|
-
parseNoneClosedTags?: boolean;
|
|
2472
|
-
/**
|
|
2473
|
-
* When true, preserves invalid HTML nesting (e.g., <p><p>bar</p></p>) instead of auto-closing tags
|
|
2474
|
-
*/
|
|
2475
|
-
preserveTagNesting?: boolean;
|
|
2476
|
-
blockTextElements: {
|
|
2477
|
-
[tag: string]: boolean;
|
|
2478
|
-
};
|
|
2479
|
-
voidTag?: {
|
|
2480
|
-
/**
|
|
2481
|
-
* options, default value is ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']
|
|
2482
|
-
*/
|
|
2483
|
-
tags?: string[];
|
|
2484
|
-
/**
|
|
2485
|
-
* void tag serialisation, add a final slash <br/>
|
|
2486
|
-
*/
|
|
2487
|
-
closingSlash?: boolean;
|
|
2488
|
-
};
|
|
2489
|
-
closeAllByClosing?: boolean;
|
|
2490
|
-
}
|
|
2043
|
+
//#endregion
|
|
2044
|
+
//#region src/services/message/getMentions.d.ts
|
|
2491
2045
|
export declare const getMentions: (message: string) => HTMLElement[];
|
|
2046
|
+
//#endregion
|
|
2047
|
+
//#region src/services/prettier/css.d.ts
|
|
2492
2048
|
export declare const css: typeof String.raw;
|
|
2049
|
+
//#endregion
|
|
2050
|
+
//#region src/services/prettier/html.d.ts
|
|
2493
2051
|
export declare const html: typeof String.raw;
|
|
2052
|
+
//#endregion
|
|
2053
|
+
//#region src/services/sanitizeHtml/sanitizeHtml.d.ts
|
|
2494
2054
|
export declare const sanitizeHtml: (...[html, options]: Parameters<typeof baseSanitizeHtml>) => string;
|
|
2055
|
+
//#endregion
|
|
2056
|
+
//#region src/services/sanitizeHtml/sanitizeTextHtml.d.ts
|
|
2495
2057
|
export declare const sanitizeTextHtml: (html: string) => string;
|
|
2058
|
+
//#endregion
|
|
2059
|
+
//#region src/services/shared/applyItemMetadataMixin.d.ts
|
|
2496
2060
|
export declare const applyItemMetadataMixin: <TBase extends Class<NonNullable<unknown>>>(Base: TBase) => WithMetadata<TBase>;
|
|
2061
|
+
//#endregion
|
|
2062
|
+
//#region src/services/zod/createNormalizedStringSchema.d.ts
|
|
2063
|
+
export declare const createNormalizedStringSchema: (maxLength: number, schema?: z.ZodString) => z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
2064
|
+
//#endregion
|
|
2065
|
+
//#region src/services/zod/createUniqueArraySchema.d.ts
|
|
2066
|
+
export declare const createUniqueArraySchema: CreateUniqueArraySchema;
|
|
2067
|
+
//#endregion
|
|
2068
|
+
//#region src/util/array/chunk.d.ts
|
|
2497
2069
|
export declare const chunk: <T>(array: T[], size: number) => T[][];
|
|
2070
|
+
//#endregion
|
|
2071
|
+
//#region src/util/array/chunkBySerializedSize.d.ts
|
|
2498
2072
|
export declare const chunkBySerializedSize: <T>(items: T[], maxBytes: number, maxCount: number) => T[][];
|
|
2073
|
+
//#endregion
|
|
2074
|
+
//#region src/util/array/takeOne.d.ts
|
|
2499
2075
|
export declare const takeOne: TakeOne;
|
|
2500
|
-
|
|
2076
|
+
//#endregion
|
|
2077
|
+
//#region src/util/date/checkIsSameDay.d.ts
|
|
2078
|
+
export declare const checkIsSameDay: (date: Date, otherDate: Date) => boolean;
|
|
2079
|
+
//#endregion
|
|
2080
|
+
//#region src/util/date/checkIsToday.d.ts
|
|
2081
|
+
export declare const checkIsToday: (date: Date) => boolean;
|
|
2082
|
+
//#endregion
|
|
2083
|
+
//#region src/util/date/checkIsYesterday.d.ts
|
|
2084
|
+
export declare const checkIsYesterday: (date: Date) => boolean;
|
|
2085
|
+
//#endregion
|
|
2086
|
+
//#region src/util/date/getEndOfDay.d.ts
|
|
2087
|
+
export declare const getEndOfDay: (date: Date) => Date;
|
|
2088
|
+
//#endregion
|
|
2089
|
+
//#region src/util/date/getPlainDate.d.ts
|
|
2090
|
+
export declare const getPlainDate: (date: Date) => Temporal.PlainDate;
|
|
2091
|
+
//#endregion
|
|
2092
|
+
//#region src/util/date/getStartOfDay.d.ts
|
|
2093
|
+
export declare const getStartOfDay: (date: Date) => Date;
|
|
2094
|
+
//#endregion
|
|
2095
|
+
//#region src/util/date/getZonedDateTime.d.ts
|
|
2096
|
+
export declare const getZonedDateTime: (date: Date) => Temporal.ZonedDateTime;
|
|
2097
|
+
//#endregion
|
|
2098
|
+
//#region src/util/environment/checkIsServer.d.ts
|
|
2099
|
+
export declare const checkIsServer: () => boolean;
|
|
2100
|
+
//#endregion
|
|
2101
|
+
//#region src/util/function/noop.d.ts
|
|
2501
2102
|
export declare const noop: () => void;
|
|
2103
|
+
//#endregion
|
|
2104
|
+
//#region src/util/id/constants.d.ts
|
|
2502
2105
|
export declare const ID_SEPARATOR = "|";
|
|
2503
2106
|
export declare const UUID_LENGTH = 36;
|
|
2107
|
+
//#endregion
|
|
2108
|
+
//#region src/util/map/getOrCreate.d.ts
|
|
2504
2109
|
export declare const getOrCreate: <TKey, TValue>(map: Map<TKey, TValue>, key: TKey, create: () => TValue) => TValue;
|
|
2110
|
+
//#endregion
|
|
2111
|
+
//#region src/util/object/checkIsPlainObject.d.ts
|
|
2505
2112
|
export declare const checkIsPlainObject: (data: unknown) => data is object;
|
|
2113
|
+
//#endregion
|
|
2114
|
+
//#region src/util/object/getPropertyNames.d.ts
|
|
2506
2115
|
export declare const getPropertyNames: <T>() => PropertyNames<T>;
|
|
2116
|
+
//#endregion
|
|
2117
|
+
//#region src/util/object/jsonDateParse.d.ts
|
|
2507
2118
|
export declare const jsonDateParse: <T = any>(text: string) => T;
|
|
2119
|
+
//#endregion
|
|
2120
|
+
//#region src/util/types/MergeObjectsStrict.d.ts
|
|
2508
2121
|
export type MergeObjectsStrict<T extends object[]> = T extends [infer TFirst, infer TSecond, ...infer TRemaining] ? TSecond extends { [K in keyof TSecond]: K extends keyof TFirst ? never : TSecond[K]; } ? TRemaining extends object[] ? MergeObjectsStrict<[TSecond, ...TRemaining]> & TFirst : TFirst & TSecond : never : T extends [infer TFirst] ? TFirst : never;
|
|
2122
|
+
//#endregion
|
|
2123
|
+
//#region src/util/object/mergeObjectsStrict.d.ts
|
|
2509
2124
|
export declare const mergeObjectsStrict: <T extends object[]>(...objects: T) => MergeObjectsStrict<T>;
|
|
2125
|
+
//#endregion
|
|
2126
|
+
//#region src/util/promise/settleAll.d.ts
|
|
2510
2127
|
export declare const settleAll: <T>(tasks: (() => Promise<T>)[], concurrencyLimit?: number) => Promise<T[]>;
|
|
2128
|
+
//#endregion
|
|
2129
|
+
//#region src/util/reactivity/getRawData.d.ts
|
|
2511
2130
|
export declare const getRawData: <T>(data: T) => T;
|
|
2131
|
+
//#endregion
|
|
2132
|
+
//#region src/util/reactivity/toRawDeep.d.ts
|
|
2512
2133
|
export declare const toRawDeep: <T extends object>(data: T) => T;
|
|
2134
|
+
//#endregion
|
|
2135
|
+
//#region src/util/text/capitalize.d.ts
|
|
2513
2136
|
export declare const capitalize: (string: string) => string;
|
|
2137
|
+
//#endregion
|
|
2138
|
+
//#region src/util/text/encodeUrlSubDelimiters.d.ts
|
|
2514
2139
|
export declare const encodeUrlSubDelimiters: (value: string) => string;
|
|
2140
|
+
//#endregion
|
|
2141
|
+
//#region src/util/text/getDecodedUriComponent.d.ts
|
|
2515
2142
|
export declare const getDecodedUriComponent: (value: string, fallback: string) => string;
|
|
2143
|
+
//#endregion
|
|
2144
|
+
//#region src/util/text/normalizeString.d.ts
|
|
2516
2145
|
export declare const normalizeString: (value: null | string | undefined) => string;
|
|
2517
|
-
|
|
2146
|
+
//#endregion
|
|
2147
|
+
//#region src/util/text/streamToText.d.ts
|
|
2518
2148
|
export declare const streamToText: (readable: NodeJS.ReadableStream) => Promise<string>;
|
|
2149
|
+
//#endregion
|
|
2150
|
+
//#region src/util/text/toKebabCase.d.ts
|
|
2519
2151
|
export declare const toKebabCase: <T extends string>(string: T) => KebabCase<T>;
|
|
2152
|
+
//#endregion
|
|
2153
|
+
//#region src/util/text/truncate.d.ts
|
|
2520
2154
|
export declare const truncate: (string: string, length: number) => string;
|
|
2155
|
+
//#endregion
|
|
2156
|
+
//#region src/util/text/uncapitalize.d.ts
|
|
2521
2157
|
export declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
|
|
2158
|
+
//#endregion
|
|
2159
|
+
//#region src/util/time/hrtime.d.ts
|
|
2522
2160
|
export declare const hrtime: (previousHrTime?: [number, number]) => [number, number];
|
|
2161
|
+
//#endregion
|
|
2162
|
+
//#region src/util/time/now.d.ts
|
|
2523
2163
|
export declare const now: () => string;
|
|
2164
|
+
//#endregion
|
|
2165
|
+
//#region src/util/time/sleep.d.ts
|
|
2524
2166
|
export declare const sleep: (durationMs: number) => Promise<void>;
|
|
2167
|
+
//#endregion
|
|
2168
|
+
//#region src/util/types/BuildTuple.d.ts
|
|
2525
2169
|
export type BuildTuple<N extends number, T = unknown, R extends unknown[] = []> = R["length"] extends N ? R : BuildTuple<N, T, [...R, T]>;
|
|
2170
|
+
//#endregion
|
|
2171
|
+
//#region src/util/types/FunctionProperties.d.ts
|
|
2526
2172
|
export type FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? K : never; };
|
|
2173
|
+
//#endregion
|
|
2174
|
+
//#region src/util/types/ExcludeFunctionProperties.d.ts
|
|
2527
2175
|
export type ExcludeFunctionProperties<T> = Except<T, FunctionProperties<T>[keyof T]>;
|
|
2176
|
+
//#endregion
|
|
2177
|
+
//#region src/util/types/MapValue.d.ts
|
|
2528
2178
|
export type MapValue<BaseType> = BaseType extends Map<unknown, infer ValueType> ? ValueType : never;
|
|
2179
|
+
//#endregion
|
|
2180
|
+
//#region src/util/types/TupleSplit.d.ts
|
|
2529
2181
|
export 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, []];
|
|
2182
|
+
//#endregion
|
|
2183
|
+
//#region src/util/types/SkipFirst.d.ts
|
|
2530
2184
|
export type SkipFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[1];
|
|
2185
|
+
//#endregion
|
|
2186
|
+
//#region src/util/types/TakeFirst.d.ts
|
|
2531
2187
|
export type TakeFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[0];
|
|
2188
|
+
//#endregion
|
|
2189
|
+
//#region src/util/types/TupleSlice.d.ts
|
|
2532
2190
|
export 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>;
|
|
2191
|
+
//#endregion
|
|
2192
|
+
//#region src/util/validation/exhaustiveGuard.d.ts
|
|
2533
2193
|
export declare const exhaustiveGuard: (value: never) => never;
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
export declare const
|
|
2194
|
+
//#endregion
|
|
2195
|
+
//#region src/util/id/uuid/checkIsUuidV4.d.ts
|
|
2196
|
+
export declare const checkIsUuidV4: (uuid: string) => boolean;
|
|
2197
|
+
//#endregion
|
|
2198
|
+
//#region src/util/id/uuid/constants.d.ts
|
|
2537
2199
|
export declare const UUIDV4_REGEX: RegExp;
|
|
2538
|
-
|
|
2200
|
+
//#endregion
|