@esposter/shared 4.1.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +3 -3
  2. package/dist/index.d.ts +0 -2387
  3. package/dist/index.js +0 -1918
package/dist/index.d.ts DELETED
@@ -1,2387 +0,0 @@
1
- import { z } from "zod";
2
- import { Result, ResultAsync } from "neverthrow";
3
- import { HTMLElement } from "node-html-parser";
4
- import { DefaultTreeAdapterTypes, html as html$1 } from "parse5";
5
- //#region src/models/error/ForbiddenError.d.ts
6
- export declare class ForbiddenError extends Error {
7
- constructor(message: string);
8
- }
9
- //#endregion
10
- //#region src/models/shared/Operation.d.ts
11
- export declare enum Operation {
12
- Create = "Create",
13
- Delete = "Delete",
14
- Push = "Push",
15
- Read = "Read",
16
- Unshift = "Unshift",
17
- Update = "Update"
18
- }
19
- //#endregion
20
- //#region src/models/error/InvalidOperationError.d.ts
21
- export declare class InvalidOperationError extends Error {
22
- constructor(operation: Operation, name: string, message: string);
23
- }
24
- //#endregion
25
- //#region src/models/error/NotFoundError.d.ts
26
- export declare class NotFoundError<T extends string = string> extends Error {
27
- constructor(name: T, id: string);
28
- }
29
- //#endregion
30
- //#region src/models/error/NotInitializedError.d.ts
31
- export declare class NotInitializedError<T extends string = string> extends Error {
32
- constructor(name: T);
33
- }
34
- //#endregion
35
- //#region src/models/error/WordFilteredError.d.ts
36
- export declare class WordFilteredError extends Error {
37
- constructor(message: string);
38
- }
39
- //#endregion
40
- //#region src/models/eventEmitter/EventListenerEntry.d.ts
41
- export interface EventListenerEntry<TEventMap> {
42
- isOnce: boolean;
43
- listener: TEventMap[keyof TEventMap];
44
- }
45
- //#endregion
46
- //#region src/models/eventEmitter/EventListenerMap.d.ts
47
- export type EventListenerMap<TEventMap> = { [TEvent in keyof TEventMap]: (...args: never[]) => void; };
48
- //#endregion
49
- //#region src/models/eventEmitter/TypedEventEmitter.d.ts
50
- export declare class TypedEventEmitter<TEventMap extends EventListenerMap<TEventMap>> {
51
- #private;
52
- emit<TEvent extends keyof TEventMap>(event: TEvent, ...args: Parameters<TEventMap[TEvent]>): boolean;
53
- off<TEvent extends keyof TEventMap>(event: TEvent, listener: TEventMap[TEvent]): void;
54
- on<TEvent extends keyof TEventMap>(event: TEvent, listener: TEventMap[TEvent]): void;
55
- once<TEvent extends keyof TEventMap>(event: TEvent, listener: TEventMap[TEvent]): void;
56
- removeAllListeners(event?: keyof TEventMap): void;
57
- }
58
- //#endregion
59
- //#region src/models/indexedDb/DatabaseStoreSchema.d.ts
60
- export interface DatabaseStoreSchema {
61
- indexes: Record<string, IDBValidKey>;
62
- key: IDBValidKey;
63
- value: unknown;
64
- }
65
- //#endregion
66
- //#region src/models/indexedDb/DatabaseSchema.d.ts
67
- export type DatabaseSchema = Record<string, DatabaseStoreSchema>;
68
- //#endregion
69
- //#region src/models/indexedDb/DatabaseStoreName.d.ts
70
- export type DatabaseStoreName<TSchema extends DatabaseSchema> = [LiteralKeys<TSchema>] extends [never] ? string : LiteralKeys<TSchema>;
71
- type LiteralKeys<TSchema> = keyof { [TKey in keyof TSchema as string extends TKey ? never : TKey]: TKey; } & string;
72
- //#endregion
73
- //#region src/models/indexedDb/DatabaseIndexName.d.ts
74
- export type DatabaseIndexName<TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>> = string extends keyof TSchema[TStoreName]["indexes"] ? string : keyof TSchema[TStoreName]["indexes"] & string;
75
- //#endregion
76
- //#region src/models/indexedDb/DatabaseIndexCreator.d.ts
77
- export interface DatabaseIndexCreator<TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>> {
78
- createIndex: (name: DatabaseIndexName<TSchema, TStoreName>, keyPath: string | string[], options?: IDBIndexParameters) => void;
79
- }
80
- //#endregion
81
- //#region src/models/indexedDb/DatabaseIndexKey.d.ts
82
- export type DatabaseIndexKey<TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>, TIndexName extends DatabaseIndexName<TSchema, TStoreName>> = TSchema[TStoreName]["indexes"][TIndexName];
83
- //#endregion
84
- //#region src/models/indexedDb/DatabaseIndex.d.ts
85
- export interface DatabaseIndex<TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>, TIndexName extends DatabaseIndexName<TSchema, TStoreName>> {
86
- getAll: (query?: DatabaseIndexKey<TSchema, TStoreName, TIndexName> | IDBKeyRange | null, count?: number) => Promise<TSchema[TStoreName]["value"][]>;
87
- getAllKeys: (query?: DatabaseIndexKey<TSchema, TStoreName, TIndexName> | IDBKeyRange | null, count?: number) => Promise<TSchema[TStoreName]["key"][]>;
88
- }
89
- //#endregion
90
- //#region src/models/indexedDb/DatabaseObjectStoreReader.d.ts
91
- export interface DatabaseObjectStoreReader<TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>> {
92
- get: (key: TSchema[TStoreName]["key"]) => Promise<TSchema[TStoreName]["value"] | undefined>;
93
- getAll: (query?: IDBKeyRange | null | TSchema[TStoreName]["key"], count?: number) => Promise<TSchema[TStoreName]["value"][]>;
94
- getAllKeys: (query?: IDBKeyRange | null | TSchema[TStoreName]["key"], count?: number) => Promise<TSchema[TStoreName]["key"][]>;
95
- index: <TIndexName extends DatabaseIndexName<TSchema, TStoreName>>(name: TIndexName) => DatabaseIndex<TSchema, TStoreName, TIndexName>;
96
- }
97
- //#endregion
98
- //#region src/models/indexedDb/DatabaseObjectStoreWriter.d.ts
99
- export interface DatabaseObjectStoreWriter<TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>> {
100
- delete: (query: IDBKeyRange | TSchema[TStoreName]["key"]) => Promise<void>;
101
- put: (value: TSchema[TStoreName]["value"], key?: TSchema[TStoreName]["key"]) => Promise<TSchema[TStoreName]["key"]>;
102
- }
103
- //#endregion
104
- //#region src/models/indexedDb/DatabaseObjectStore.d.ts
105
- export type DatabaseObjectStore<TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>, TMode extends IDBTransactionMode> = DatabaseObjectStoreReader<TSchema, TStoreName> & (TMode extends "readonly" ? unknown : DatabaseObjectStoreWriter<TSchema, TStoreName> & (TMode extends "versionchange" ? DatabaseIndexCreator<TSchema, TStoreName> : unknown));
106
- //#endregion
107
- //#region src/models/indexedDb/DatabaseTransaction.d.ts
108
- export interface DatabaseTransaction<TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>, TMode extends IDBTransactionMode> {
109
- done: Promise<void>;
110
- objectStore: <TName extends TStoreName>(name: TName) => DatabaseObjectStore<TSchema, TName, TMode>;
111
- }
112
- //#endregion
113
- //#region src/models/indexedDb/Database.d.ts
114
- export interface Database<TSchema extends DatabaseSchema = DatabaseSchema> {
115
- close: () => void;
116
- delete: <TStoreName extends DatabaseStoreName<TSchema>>(storeName: TStoreName, query: IDBKeyRange | TSchema[TStoreName]["key"]) => Promise<void>;
117
- get: <TStoreName extends DatabaseStoreName<TSchema>>(storeName: TStoreName, key: TSchema[TStoreName]["key"]) => Promise<TSchema[TStoreName]["value"] | undefined>;
118
- getAll: <TStoreName extends DatabaseStoreName<TSchema>>(storeName: TStoreName, query?: IDBKeyRange | null | TSchema[TStoreName]["key"], count?: number) => Promise<TSchema[TStoreName]["value"][]>;
119
- getAllKeys: <TStoreName extends DatabaseStoreName<TSchema>>(storeName: TStoreName, query?: IDBKeyRange | null | TSchema[TStoreName]["key"], count?: number) => Promise<TSchema[TStoreName]["key"][]>;
120
- readonly name: string;
121
- put: <TStoreName extends DatabaseStoreName<TSchema>>(storeName: TStoreName, value: TSchema[TStoreName]["value"], key?: TSchema[TStoreName]["key"]) => Promise<TSchema[TStoreName]["key"]>;
122
- transaction: <TStoreName extends DatabaseStoreName<TSchema>, TMode extends IDBTransactionMode = "readonly">(storeNames: readonly TStoreName[] | TStoreName, mode?: TMode, options?: IDBTransactionOptions) => DatabaseTransaction<TSchema, TStoreName, TMode>;
123
- }
124
- //#endregion
125
- //#region src/models/indexedDb/UpgradeDatabase.d.ts
126
- export interface UpgradeDatabase<TSchema extends DatabaseSchema = DatabaseSchema> extends Database<TSchema> {
127
- createObjectStore: <TStoreName extends DatabaseStoreName<TSchema>>(name: TStoreName, options?: IDBObjectStoreParameters) => DatabaseObjectStore<TSchema, TStoreName, "versionchange">;
128
- }
129
- //#endregion
130
- //#region src/models/indexedDb/DatabaseOpenOptions.d.ts
131
- export interface DatabaseOpenOptions<TSchema extends DatabaseSchema = DatabaseSchema> {
132
- blocked?: (currentVersion: number, blockedVersion: null | number) => void;
133
- blocking?: (currentVersion: number, blockedVersion: null | number) => void;
134
- terminated?: () => void;
135
- upgrade?: (database: UpgradeDatabase<TSchema>, oldVersion: number, newVersion: null | number, transaction: DatabaseTransaction<TSchema, DatabaseStoreName<TSchema>, "versionchange">) => void;
136
- }
137
- //#endregion
138
- //#region src/models/message/MentionType.d.ts
139
- export declare enum MentionType {
140
- Role = "role",
141
- User = "user"
142
- }
143
- //#endregion
144
- //#region src/models/mime/MimeDatabaseEntry.d.ts
145
- export interface MimeDatabaseEntry {
146
- charset?: string;
147
- compressible?: boolean;
148
- extensions?: string[];
149
- source?: string;
150
- }
151
- //#endregion
152
- //#region src/models/object/ObjectMethod.d.ts
153
- export declare enum ObjectMethod {
154
- ToString = "toString",
155
- ValueOf = "valueOf"
156
- }
157
- //#endregion
158
- //#region src/models/profanity/ProfanityOptions.d.ts
159
- export interface ProfanityOptions {
160
- isWholeWord: boolean;
161
- }
162
- //#endregion
163
- //#region src/models/reactivity/MaybeReactive.d.ts
164
- export interface MaybeReactive {
165
- __v_raw?: unknown;
166
- }
167
- //#endregion
168
- //#region src/models/router/RoutePath.d.ts
169
- export declare const RoutePath: {
170
- readonly About: "/about";
171
- readonly Achievements: "/achievements";
172
- readonly Anime: "/anime";
173
- readonly Calls: (id: string) => string;
174
- readonly CallsIndex: "/calls";
175
- readonly Clicker: "/clicker";
176
- readonly Docs: "/docs";
177
- readonly Dungeons: "/dungeons";
178
- readonly FluidSimulator: "/fluid-simulator";
179
- readonly Genshin: "/genshin";
180
- readonly Github: "https://github.com/Esposter/Esposter";
181
- readonly Index: "/";
182
- readonly Login: "/login";
183
- readonly Messages: (id: string) => string;
184
- readonly MessagesDraftsAndSent: "/messages/draftsandsent";
185
- readonly MessagesFriends: "/messages/friends";
186
- readonly MessagesIndex: "/messages";
187
- readonly MessagesInvite: (code: string) => string;
188
- readonly MessagesMessage: (id: string, rowKey: string) => string;
189
- readonly MessagesThread: (id: string, rowKey: string) => string;
190
- readonly Post: (id: string) => string;
191
- readonly PostCreate: "/post/create";
192
- readonly PostUpdate: (id: string) => string;
193
- readonly PrivacyPolicy: "/privacy-policy";
194
- readonly Resource: (id: string) => string;
195
- readonly ResourceExplorer: "/resource-explorer";
196
- readonly ResourceExplorerAll: "/resource-explorer/all";
197
- readonly ResourceExplorerCreate: "/resource-explorer/create";
198
- readonly ResourceExplorerCreateType: (type: string) => string;
199
- readonly ResourceExplorerFavorites: "/resource-explorer/favorites";
200
- readonly ResourceExplorerRecents: "/resource-explorer/recents";
201
- readonly ResourceExplorerRecycleBin: "/resource-explorer/recycle-bin";
202
- readonly ResourceExplorerTags: "/resource-explorer/tags";
203
- readonly ResourceItems: (id: string) => string;
204
- readonly User: (id: string) => string;
205
- readonly UserSettings: "/user/settings";
206
- readonly View: (type: string, id: string) => string;
207
- };
208
- export type RoutePath = typeof RoutePath;
209
- //#endregion
210
- //#region src/models/sanitizeHtml/AttributesTransformer.d.ts
211
- export type AttributesTransformer = (attributes: Record<string, string>) => Record<string, string>;
212
- //#endregion
213
- //#region src/models/sanitizeHtml/SanitizeHtmlOptions.d.ts
214
- export interface SanitizeHtmlOptions {
215
- allowedAttributes?: Record<string, string[]>;
216
- allowedClasses?: Record<string, string[]>;
217
- allowedStyles?: Record<string, Record<string, RegExp[]>>;
218
- allowedTags?: string[];
219
- transformAttributes?: Record<string, AttributesTransformer>;
220
- }
221
- //#endregion
222
- //#region src/models/sanitizeHtml/SanitizePolicy.d.ts
223
- export interface SanitizePolicy {
224
- allowedAttributes: Record<string, string[]>;
225
- allowedClasses: Record<string, string[]>;
226
- allowedSchemes: string[];
227
- allowedStyles: Record<string, Record<string, RegExp[]>>;
228
- allowedTags: string[];
229
- transformAttributes: Record<string, AttributesTransformer>;
230
- }
231
- //#endregion
232
- //#region src/models/shared/ItemEntityType.d.ts
233
- export interface ItemEntityType<T extends string> {
234
- type: T;
235
- }
236
- export declare const createItemEntityTypeSchema: <T extends z.ZodType<string>>(schema: T) => z.ZodObject<{
237
- type: T;
238
- }>;
239
- //#endregion
240
- //#region src/models/shared/ItemMetadata.d.ts
241
- export declare class ItemMetadata {
242
- createdAt: Date;
243
- deletedAt: Date | null;
244
- updatedAt: Date;
245
- }
246
- //#endregion
247
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/primitive.d.ts
248
- /**
249
- Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
250
-
251
- @category Type
252
- */
253
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
254
- //#endregion
255
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/basic.d.ts
256
- /**
257
- Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
258
-
259
- @category Class
260
- */
261
- type Class<T, Arguments extends unknown[] = any[]> = {
262
- prototype: Pick<T, keyof T>;
263
- new (...arguments_: Arguments): T;
264
- };
265
- //#endregion
266
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/union-to-intersection.d.ts
267
- /**
268
- Convert a union type to an intersection type.
269
-
270
- Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
271
-
272
- @example
273
- ```
274
- import type {UnionToIntersection} from 'type-fest';
275
-
276
- type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
277
-
278
- type Intersection = UnionToIntersection<Union>;
279
- //=> {the(): void} & {great(arg: string): void} & {escape: boolean}
280
- ```
281
-
282
- @category Type
283
- */
284
- type UnionToIntersection<Union> = (
285
- // `extends unknown` is always going to be the case and is used to convert the
286
- // `Union` into a [distributive conditional
287
- // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
288
- Union extends unknown ?
289
- // The union type is used as the only argument to a function since the union
290
- // of function arguments is an intersection.
291
- (distributedUnion: Union) => void :
292
- // This won't happen.
293
- never
294
- // Infer the `Intersection` type since TypeScript represents the positional
295
- // arguments of unions of functions as an intersection of the union.
296
- ) extends ((mergedIntersection: infer Intersection) => void) ?
297
- // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
298
- Intersection & Union : never;
299
- //#endregion
300
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/keys-of-union.d.ts
301
- /**
302
- Create a union of all keys from a given type, even those exclusive to specific union members.
303
-
304
- Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
305
-
306
- @link https://stackoverflow.com/a/49402091
307
-
308
- @example
309
- ```
310
- import type {KeysOfUnion} from 'type-fest';
311
-
312
- type A = {
313
- common: string;
314
- a: number;
315
- };
316
-
317
- type B = {
318
- common: string;
319
- b: string;
320
- };
321
-
322
- type C = {
323
- common: string;
324
- c: boolean;
325
- };
326
-
327
- type Union = A | B | C;
328
-
329
- type CommonKeys = keyof Union;
330
- //=> 'common'
331
-
332
- type AllKeys = KeysOfUnion<Union>;
333
- //=> 'common' | 'a' | 'b' | 'c'
334
- ```
335
-
336
- @category Object
337
- */
338
- type KeysOfUnion<ObjectType> =
339
- // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
340
- keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
341
- //#endregion
342
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-any.d.ts
343
- /**
344
- Returns a boolean for whether the given type is `any`.
345
-
346
- @link https://stackoverflow.com/a/49928360/1490091
347
-
348
- Useful in type utilities, such as disallowing `any`s to be passed to a function.
349
-
350
- @example
351
- ```
352
- import type {IsAny} from 'type-fest';
353
-
354
- const typedObject = {a: 1, b: 2} as const;
355
- const anyObject: any = {a: 1, b: 2};
356
-
357
- function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
358
- return object[key];
359
- }
360
-
361
- const typedA = get(typedObject, 'a');
362
- //=> 1
363
-
364
- const anyA = get(anyObject, 'a');
365
- //=> any
366
- ```
367
-
368
- @category Type Guard
369
- @category Utilities
370
- */
371
- type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
372
- //#endregion
373
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-optional-key-of.d.ts
374
- /**
375
- Returns a boolean for whether the given key is an optional key of type.
376
-
377
- This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
378
-
379
- @example
380
- ```
381
- import type {IsOptionalKeyOf} from 'type-fest';
382
-
383
- type User = {
384
- name: string;
385
- surname: string;
386
-
387
- luckyNumber?: number;
388
- };
389
-
390
- type Admin = {
391
- name: string;
392
- surname?: string;
393
- };
394
-
395
- type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
396
- //=> true
397
-
398
- type T2 = IsOptionalKeyOf<User, 'name'>;
399
- //=> false
400
-
401
- type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
402
- //=> boolean
403
-
404
- type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
405
- //=> false
406
-
407
- type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
408
- //=> boolean
409
- ```
410
-
411
- @category Type Guard
412
- @category Utilities
413
- */
414
- 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;
415
- //#endregion
416
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/optional-keys-of.d.ts
417
- /**
418
- Extract all optional keys from the given type.
419
-
420
- This is useful when you want to create a new type that contains different type values for the optional keys only.
421
-
422
- @example
423
- ```
424
- import type {OptionalKeysOf, Except} from 'type-fest';
425
-
426
- type User = {
427
- name: string;
428
- surname: string;
429
-
430
- luckyNumber?: number;
431
- };
432
-
433
- const REMOVE_FIELD = Symbol('remove field symbol');
434
- type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
435
- [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
436
- };
437
-
438
- const update1: UpdateOperation<User> = {
439
- name: 'Alice',
440
- };
441
-
442
- const update2: UpdateOperation<User> = {
443
- name: 'Bob',
444
- luckyNumber: REMOVE_FIELD,
445
- };
446
- ```
447
-
448
- @category Utilities
449
- */
450
- type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
451
- ? (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`
452
- : never; // Should never happen
453
- //#endregion
454
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/required-keys-of.d.ts
455
- /**
456
- Extract all required keys from the given type.
457
-
458
- This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
459
-
460
- @example
461
- ```
462
- import type {RequiredKeysOf} from 'type-fest';
463
-
464
- declare function createValidation<
465
- Entity extends object,
466
- Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
467
- >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
468
-
469
- type User = {
470
- name: string;
471
- surname: string;
472
- luckyNumber?: number;
473
- };
474
-
475
- const validator1 = createValidation<User>('name', value => value.length < 25);
476
- const validator2 = createValidation<User>('surname', value => value.length < 25);
477
-
478
- // @ts-expect-error
479
- const validator3 = createValidation<User>('luckyNumber', value => value > 0);
480
- // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
481
- ```
482
-
483
- @category Utilities
484
- */
485
- type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
486
- ? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
487
- //#endregion
488
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-never.d.ts
489
- /**
490
- Returns a boolean for whether the given type is `never`.
491
-
492
- @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
493
- @link https://stackoverflow.com/a/53984913/10292952
494
- @link https://www.zhenghao.io/posts/ts-never
495
-
496
- Useful in type utilities, such as checking if something does not occur.
497
-
498
- @example
499
- ```
500
- import type {IsNever, And} from 'type-fest';
501
-
502
- type A = IsNever<never>;
503
- //=> true
504
-
505
- type B = IsNever<any>;
506
- //=> false
507
-
508
- type C = IsNever<unknown>;
509
- //=> false
510
-
511
- type D = IsNever<never[]>;
512
- //=> false
513
-
514
- type E = IsNever<object>;
515
- //=> false
516
-
517
- type F = IsNever<string>;
518
- //=> false
519
- ```
520
-
521
- @example
522
- ```
523
- import type {IsNever} from 'type-fest';
524
-
525
- type IsTrue<T> = T extends true ? true : false;
526
-
527
- // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
528
- type A = IsTrue<never>;
529
- //=> never
530
-
531
- // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
532
- type IsTrueFixed<T> =
533
- IsNever<T> extends true ? false : T extends true ? true : false;
534
-
535
- type B = IsTrueFixed<never>;
536
- //=> false
537
- ```
538
-
539
- @category Type Guard
540
- @category Utilities
541
- */
542
- type IsNever<T> = [T] extends [never] ? true : false;
543
- //#endregion
544
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/if.d.ts
545
- /**
546
- An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
547
-
548
- Use-cases:
549
- - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
550
-
551
- Note:
552
- - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
553
- - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
554
-
555
- @example
556
- ```
557
- import type {If} from 'type-fest';
558
-
559
- type A = If<true, 'yes', 'no'>;
560
- //=> 'yes'
561
-
562
- type B = If<false, 'yes', 'no'>;
563
- //=> 'no'
564
-
565
- type C = If<boolean, 'yes', 'no'>;
566
- //=> 'yes' | 'no'
567
-
568
- type D = If<any, 'yes', 'no'>;
569
- //=> 'yes' | 'no'
570
-
571
- type E = If<never, 'yes', 'no'>;
572
- //=> 'no'
573
- ```
574
-
575
- @example
576
- ```
577
- import type {If, IsAny, IsNever} from 'type-fest';
578
-
579
- type A = If<IsAny<unknown>, 'is any', 'not any'>;
580
- //=> 'not any'
581
-
582
- type B = If<IsNever<never>, 'is never', 'not never'>;
583
- //=> 'is never'
584
- ```
585
-
586
- @example
587
- ```
588
- import type {If, IsEqual} from 'type-fest';
589
-
590
- type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
591
-
592
- type A = IfEqual<string, string, 'equal', 'not equal'>;
593
- //=> 'equal'
594
-
595
- type B = IfEqual<string, number, 'equal', 'not equal'>;
596
- //=> 'not equal'
597
- ```
598
-
599
- Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
600
-
601
- @example
602
- ```
603
- import type {If, IsEqual, StringRepeat} from 'type-fest';
604
-
605
- type HundredZeroes = StringRepeat<'0', 100>;
606
-
607
- // The following implementation is not tail recursive
608
- type Includes<S extends string, Char extends string> =
609
- S extends `${infer First}${infer Rest}`
610
- ? If<IsEqual<First, Char>,
611
- 'found',
612
- Includes<Rest, Char>>
613
- : 'not found';
614
-
615
- // Hence, instantiations with long strings will fail
616
- // @ts-expect-error
617
- type Fails = Includes<HundredZeroes, '1'>;
618
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
619
- // Error: Type instantiation is excessively deep and possibly infinite.
620
-
621
- // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
622
- type IncludesWithoutIf<S extends string, Char extends string> =
623
- S extends `${infer First}${infer Rest}`
624
- ? IsEqual<First, Char> extends true
625
- ? 'found'
626
- : IncludesWithoutIf<Rest, Char>
627
- : 'not found';
628
-
629
- // Now, instantiations with long strings will work
630
- type Works = IncludesWithoutIf<HundredZeroes, '1'>;
631
- //=> 'not found'
632
- ```
633
-
634
- @category Type Guard
635
- @category Utilities
636
- */
637
- type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
638
- //#endregion
639
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/unknown-array.d.ts
640
- /**
641
- Represents an array with `unknown` value.
642
-
643
- Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
644
-
645
- @example
646
- ```
647
- import type {UnknownArray} from 'type-fest';
648
-
649
- type IsArray<T> = T extends UnknownArray ? true : false;
650
-
651
- type A = IsArray<['foo']>;
652
- //=> true
653
-
654
- type B = IsArray<readonly number[]>;
655
- //=> true
656
-
657
- type C = IsArray<string>;
658
- //=> false
659
- ```
660
-
661
- @category Type
662
- @category Array
663
- */
664
- type UnknownArray = readonly unknown[];
665
- //#endregion
666
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/internal/type.d.ts
667
- /**
668
- Returns a boolean for whether A is false.
669
-
670
- @example
671
- ```
672
- type A = Not<true>;
673
- //=> false
674
-
675
- type B = Not<false>;
676
- //=> true
677
- ```
678
- */
679
- type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
680
- /**
681
- An if-else-like type that resolves depending on whether the given type is `any` or `never`.
682
-
683
- @example
684
- ```
685
- // When `T` is neither `any` nor `never` (like `string`) => Returns `IfNot` branch
686
- type A = IfNotAnyOrNever<string, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
687
- //=> 'VALID'
688
-
689
- // When `T` is `any` => Returns `IfAny` branch
690
- type B = IfNotAnyOrNever<any, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
691
- //=> 'IS_ANY'
692
-
693
- // When `T` is `never` => Returns `IfNever` branch
694
- type C = IfNotAnyOrNever<never, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
695
- //=> 'IS_NEVER'
696
- ```
697
-
698
- Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
699
-
700
- @example
701
- ```ts
702
- import type {StringRepeat} from 'type-fest';
703
-
704
- type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
705
-
706
- // The following implementation is not tail recursive
707
- type TrimLeft<S extends string> = IfNotAnyOrNever<S, {ifNot: S extends ` ${infer R}` ? TrimLeft<R> : S}>;
708
-
709
- // Hence, instantiations with long strings will fail
710
- // @ts-expect-error
711
- type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
712
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
713
- // Error: Type instantiation is excessively deep and possibly infinite.
714
-
715
- // To fix this, move the recursion into a helper type
716
- type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, {ifNot: _TrimLeftOptimised<S>}>;
717
-
718
- type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
719
-
720
- type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
721
- //=> ''
722
- ```
723
- */
724
- type IfNotAnyOrNever<T, Cases extends {
725
- ifNot: unknown;
726
- ifAny?: unknown;
727
- ifNever?: unknown;
728
- }> = IsAny<T> extends true ? 'ifAny' extends keyof Cases ? Cases['ifAny'] : any : IsNever<T> extends true ? 'ifNever' extends keyof Cases ? Cases['ifNever'] : never : Cases['ifNot'];
729
- /**
730
- Indicates the value of `exactOptionalPropertyTypes` compiler option.
731
- */
732
- type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
733
- //#endregion
734
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/internal/array.d.ts
735
- /**
736
- 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.
737
-
738
- @example
739
- ```
740
- type A = CollapseRestElement<[string, string, ...number[]]>;
741
- //=> [string, string, number]
742
-
743
- type B = CollapseRestElement<[...string[], number, number]>;
744
- //=> [string, number, number]
745
-
746
- type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
747
- //=> [string, string, number | bigint]
748
-
749
- type D = CollapseRestElement<[string, number]>;
750
- //=> [string, number]
751
- ```
752
-
753
- Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
754
-
755
- @example
756
- ```
757
- // `exactOptionalPropertyTypes` enabled
758
- type A = CollapseRestElement<[string?, string?, ...number[]]>;
759
- //=> [string, string, number]
760
-
761
- // `exactOptionalPropertyTypes` disabled
762
- type B = CollapseRestElement<[string?, string?, ...number[]]>;
763
- //=> [string | undefined, string | undefined, number]
764
- ```
765
- */
766
- type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, {
767
- ifNot: _CollapseRestElement<TArray>;
768
- }>;
769
- type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
770
- ? '0' extends keyof TArray ?
771
- // Enters this branch, if `TArray` starts with a non-rest element (e.g., `[string, number]` or `[string, ...number[]]`).
772
- TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator,
773
- // A tuple allows fewer than one element only when its first element is optional. Written in exactly this shape because equivalent ones, such as `[] extends TArray`, are several times slower.
774
- TArray extends readonly [unknown, ...unknown[]] ? First : If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
775
- ], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
776
- :
777
- // Enters this branch, if `TArray` is empty (e.g., []),
778
- // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
779
- TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
780
- : TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
781
- : never; // Should never happen
782
- //#endregion
783
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/internal/characters.d.ts
784
- type Whitespace = '\t' // '\t'
785
- | '\n' // '\n'
786
- | '\v' // '\v'
787
- | '\f' // '\f'
788
- | '\r' // '\r'
789
- | ' ' // ' '
790
- | '…' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | '
' | '
' | ' ' | ' ' | ' ' | '';
791
- type WordSeparators = '-' | '_' | Whitespace;
792
- type AsciiPunctuation = '!' | '"' | '#' | '$' | '%' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~';
793
- //#endregion
794
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/simplify.d.ts
795
- /**
796
- 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.
797
-
798
- @example
799
- ```
800
- import type {Simplify} from 'type-fest';
801
-
802
- type PositionProps = {
803
- top: number;
804
- left: number;
805
- };
806
-
807
- type SizeProps = {
808
- width: number;
809
- height: number;
810
- };
811
-
812
- // In your editor, hovering over `Props` will show a flattened object with all the properties.
813
- type Props = Simplify<PositionProps & SizeProps>;
814
- ```
815
-
816
- Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
817
-
818
- If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
819
-
820
- @example
821
- ```
822
- import type {Simplify} from 'type-fest';
823
-
824
- interface SomeInterface {
825
- foo: number;
826
- bar?: string;
827
- baz: number | undefined;
828
- }
829
-
830
- type SomeType = {
831
- foo: number;
832
- bar?: string;
833
- baz: number | undefined;
834
- };
835
-
836
- const literal = {foo: 123, bar: 'hello', baz: 456};
837
- const someType: SomeType = literal;
838
- const someInterface: SomeInterface = literal;
839
-
840
- declare function fn(object: Record<string, unknown>): void;
841
-
842
- fn(literal); // Good: literal object type is sealed
843
- fn(someType); // Good: type is sealed
844
- // @ts-expect-error
845
- fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
846
- fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
847
- ```
848
-
849
- @link https://github.com/microsoft/TypeScript/issues/15300
850
- @see {@link SimplifyDeep}
851
- @category Object
852
- */
853
- type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
854
- //#endregion
855
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-equal.d.ts
856
- /**
857
- Returns a boolean for whether the two given types are equal.
858
-
859
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
860
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
861
-
862
- Use-cases:
863
- - If you want to make a conditional branch based on the result of a comparison of two types.
864
-
865
- @example
866
- ```
867
- import type {IsEqual} from 'type-fest';
868
-
869
- // This type returns a boolean for whether the given array includes the given item.
870
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
871
- type Includes<Value extends readonly any[], Item> =
872
- Value extends readonly [Value[0], ...infer rest]
873
- ? IsEqual<Value[0], Item> extends true
874
- ? true
875
- : Includes<rest, Item>
876
- : false;
877
- ```
878
-
879
- @category Type Guard
880
- @category Utilities
881
- */
882
- type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
883
- // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
884
- type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
885
- //#endregion
886
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/omit-index-signature.d.ts
887
- /**
888
- Omit any index signatures from the given object type, leaving only explicitly defined properties.
889
-
890
- This is the counterpart of `PickIndexSignature`.
891
-
892
- Use-cases:
893
- - Remove overly permissive signatures from third-party types.
894
-
895
- This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
896
-
897
- It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
898
-
899
- (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
900
-
901
- ```
902
- const indexed: Record<string, unknown> = {}; // Allowed
903
-
904
- // @ts-expect-error
905
- const keyed: Record<'foo', unknown> = {}; // Error
906
- // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
907
- ```
908
-
909
- Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
910
-
911
- ```
912
- type Indexed = {} extends Record<string, unknown>
913
- ? '✅ `{}` is assignable to `Record<string, unknown>`'
914
- : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
915
-
916
- type IndexedResult = Indexed;
917
- //=> '✅ `{}` is assignable to `Record<string, unknown>`'
918
-
919
- type Keyed = {} extends Record<'foo' | 'bar', unknown>
920
- ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
921
- : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
922
-
923
- type KeyedResult = Keyed;
924
- //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
925
- ```
926
-
927
- Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
928
-
929
- ```
930
- type OmitIndexSignature<ObjectType> = {
931
- [KeyType in keyof ObjectType // Map each key of `ObjectType`...
932
- ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
933
- };
934
- ```
935
-
936
- ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
937
-
938
- ```
939
- type OmitIndexSignature<ObjectType> = {
940
- [KeyType in keyof ObjectType
941
- // Is `{}` assignable to `Record<KeyType, unknown>`?
942
- as {} extends Record<KeyType, unknown>
943
- ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
944
- : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
945
- ]: ObjectType[KeyType];
946
- };
947
- ```
948
-
949
- If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
950
-
951
- @example
952
- ```
953
- import type {OmitIndexSignature} from 'type-fest';
954
-
955
- type Example = {
956
- // These index signatures will be removed.
957
- [x: string]: any;
958
- [x: number]: any;
959
- [x: symbol]: any;
960
- [x: `head-${string}`]: string;
961
- [x: `${string}-tail`]: string;
962
- [x: `head-${string}-tail`]: string;
963
- [x: `${bigint}`]: string;
964
- [x: `embedded-${number}`]: string;
965
-
966
- // These explicitly defined keys will remain.
967
- foo: 'bar';
968
- qux?: 'baz';
969
- };
970
-
971
- type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
972
- //=> {foo: 'bar'; qux?: 'baz'}
973
- ```
974
-
975
- @see {@link PickIndexSignature}
976
- @category Object
977
- */
978
- type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
979
- //#endregion
980
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/pick-index-signature.d.ts
981
- /**
982
- Pick only index signatures from the given object type, leaving out all explicitly defined properties.
983
-
984
- This is the counterpart of `OmitIndexSignature`.
985
-
986
- @example
987
- ```
988
- import type {PickIndexSignature} from 'type-fest';
989
-
990
- declare const symbolKey: unique symbol;
991
-
992
- type Example = {
993
- // These index signatures will remain.
994
- [x: string]: unknown;
995
- [x: number]: unknown;
996
- [x: symbol]: unknown;
997
- [x: `head-${string}`]: string;
998
- [x: `${string}-tail`]: string;
999
- [x: `head-${string}-tail`]: string;
1000
- [x: `${bigint}`]: string;
1001
- [x: `embedded-${number}`]: string;
1002
-
1003
- // These explicitly defined keys will be removed.
1004
- ['kebab-case-key']: string;
1005
- [symbolKey]: string;
1006
- foo: 'bar';
1007
- qux?: 'baz';
1008
- };
1009
-
1010
- type ExampleIndexSignature = PickIndexSignature<Example>;
1011
- // {
1012
- // [x: string]: unknown;
1013
- // [x: number]: unknown;
1014
- // [x: symbol]: unknown;
1015
- // [x: `head-${string}`]: string;
1016
- // [x: `${string}-tail`]: string;
1017
- // [x: `head-${string}-tail`]: string;
1018
- // [x: `${bigint}`]: string;
1019
- // [x: `embedded-${number}`]: string;
1020
- // }
1021
- ```
1022
-
1023
- @see {@link OmitIndexSignature}
1024
- @category Object
1025
- */
1026
- type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
1027
- //#endregion
1028
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/merge.d.ts
1029
- // Merges two objects without worrying about index signatures.
1030
- type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
1031
- /**
1032
- Merge two types into a new type. Keys of the second type overrides keys of the first type.
1033
-
1034
- This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`.
1035
-
1036
- @example
1037
- ```
1038
- import type {Merge} from 'type-fest';
1039
-
1040
- type Foo = {
1041
- a: string;
1042
- b: number;
1043
- };
1044
-
1045
- type Bar = {
1046
- a: number; // Conflicts with Foo['a']
1047
- c: boolean;
1048
- };
1049
-
1050
- // With `&`, `a` becomes `string & number` which is `never`. Not what you want.
1051
- type WithIntersection = (Foo & Bar)['a'];
1052
- //=> never
1053
-
1054
- // With `Merge`, `a` is cleanly overridden to `number`.
1055
- type WithMerge = Merge<Foo, Bar>['a'];
1056
- //=> number
1057
- ```
1058
-
1059
- @example
1060
- ```
1061
- import type {Merge} from 'type-fest';
1062
-
1063
- type Foo = {
1064
- [x: string]: unknown;
1065
- [x: number]: unknown;
1066
- foo: string;
1067
- bar: symbol;
1068
- };
1069
-
1070
- type Bar = {
1071
- [x: number]: number;
1072
- [x: symbol]: unknown;
1073
- bar: Date;
1074
- baz: boolean;
1075
- };
1076
-
1077
- export type FooBar = Merge<Foo, Bar>;
1078
- //=> {
1079
- // [x: string]: unknown;
1080
- // [x: number]: number;
1081
- // [x: symbol]: unknown;
1082
- // foo: string;
1083
- // bar: Date;
1084
- // baz: boolean;
1085
- // }
1086
- ```
1087
-
1088
- Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
1089
-
1090
- @see {@link ObjectMerge}
1091
- @category Object
1092
- */
1093
- type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
1094
- ? Source extends unknown // For distributing `Source`
1095
- ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
1096
- : never; // Should never happen
1097
- type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
1098
- //#endregion
1099
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/trim.d.ts
1100
- /**
1101
- Remove spaces from the left side.
1102
- */
1103
- type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
1104
- /**
1105
- Remove spaces from the right side.
1106
- */
1107
- type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
1108
- /**
1109
- Remove leading and trailing spaces from a string.
1110
-
1111
- @example
1112
- ```
1113
- import type {Trim} from 'type-fest';
1114
-
1115
- type Example = Trim<' foo '>;
1116
- //=> 'foo'
1117
- ```
1118
-
1119
- @category String
1120
- @category Template literal
1121
- */
1122
- type Trim<V extends string> = TrimLeft<TrimRight<V>>;
1123
- //#endregion
1124
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/some-extend.d.ts
1125
- /**
1126
- @see {@link SomeExtend}
1127
- */
1128
- type SomeExtendOptions = {
1129
- /**
1130
- Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1131
-
1132
- - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1133
- - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1134
-
1135
- @default true
1136
-
1137
- @example
1138
- ```
1139
- import type {SomeExtend} from 'type-fest';
1140
-
1141
- type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
1142
- //=> false
1143
-
1144
- type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
1145
- //=> true
1146
-
1147
- type C = SomeExtend<[1, never], never, {strictNever: true}>;
1148
- //=> true
1149
-
1150
- type D = SomeExtend<[1, never], never, {strictNever: false}>;
1151
- //=> true
1152
-
1153
- type E = SomeExtend<[never], any, {strictNever: true}>;
1154
- //=> true
1155
-
1156
- type F = SomeExtend<[never], any, {strictNever: false}>;
1157
- //=> true
1158
- ```
1159
- */
1160
- strictNever?: boolean;
1161
- };
1162
- type DefaultSomeExtendOptions = {
1163
- strictNever: true;
1164
- };
1165
- /**
1166
- Returns a boolean for whether some element in an array type extends another type.
1167
-
1168
- @example
1169
- ```
1170
- import type {SomeExtend} from 'type-fest';
1171
-
1172
- type A = SomeExtend<['1', '2', 3], number>;
1173
- //=> true
1174
-
1175
- type B = SomeExtend<[1, 2, 3], string>;
1176
- //=> false
1177
-
1178
- type C = SomeExtend<[string, number | string], number>;
1179
- //=> boolean
1180
-
1181
- type D = SomeExtend<[true, boolean, true], false>;
1182
- //=> boolean
1183
- ```
1184
-
1185
- Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
1186
-
1187
- ```
1188
- // @exactOptionalPropertyTypes: true
1189
- import type {SomeExtend} from 'type-fest';
1190
-
1191
- type A = SomeExtend<[1?, 2?, '3'?], string>;
1192
- //=> true
1193
- ```
1194
-
1195
- ```
1196
- // @exactOptionalPropertyTypes: false
1197
- import type {SomeExtend} from 'type-fest';
1198
-
1199
- type A = SomeExtend<[1?, 2?, '3'?], string>;
1200
- //=> boolean
1201
-
1202
- type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
1203
- //=> true
1204
- ```
1205
-
1206
- @see {@link SomeExtendOptions}
1207
-
1208
- @category Utilities
1209
- @category Array
1210
- */
1211
- type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = IfNotAnyOrNever<CollapseRestElement<TArray>, {
1212
- ifNot: _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
1213
- ifAny: false;
1214
- ifNever: false;
1215
- }>;
1216
- // Kept free of `IfNotAnyOrNever` so that it stays tail-recursive, which allows it to handle long arrays.
1217
- type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true ?
1218
- // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
1219
- true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false;
1220
- //#endregion
1221
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/or-all.d.ts
1222
- /**
1223
- Returns a boolean for whether any of the given elements is `true`.
1224
-
1225
- Use-cases:
1226
- - Check if at least one condition in a list of booleans is met.
1227
-
1228
- @example
1229
- ```
1230
- import type {OrAll} from 'type-fest';
1231
-
1232
- type FFT = OrAll<[false, false, true]>;
1233
- //=> true
1234
-
1235
- type FFF = OrAll<[false, false, false]>;
1236
- //=> false
1237
- ```
1238
-
1239
- Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
1240
- For example, `OrAll<[false, boolean]>` expands to `OrAll<[false, true]> | OrAll<[false, false]>`, which simplifies to `true | false` (i.e., `boolean`).
1241
-
1242
- @example
1243
- ```
1244
- import type {OrAll} from 'type-fest';
1245
-
1246
- type A = OrAll<[false, boolean]>;
1247
- //=> boolean
1248
-
1249
- type B = OrAll<[true, boolean]>;
1250
- //=> true
1251
- ```
1252
-
1253
- Note: If `never` is passed as an element, it is treated as `false` and the result is computed accordingly.
1254
-
1255
- @example
1256
- ```
1257
- import type {OrAll} from 'type-fest';
1258
-
1259
- type A = OrAll<[never, never, true]>;
1260
- //=> true
1261
-
1262
- type B = OrAll<[never, never, false]>;
1263
- //=> false
1264
-
1265
- type C = OrAll<[never, never, never]>;
1266
- //=> false
1267
-
1268
- type D = OrAll<[never, never, boolean]>;
1269
- //=> boolean
1270
- ```
1271
-
1272
- Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
1273
-
1274
- @example
1275
- ```
1276
- import type {OrAll} from 'type-fest';
1277
-
1278
- type A = OrAll<[false, any]>;
1279
- //=> boolean
1280
-
1281
- type B = OrAll<[true, any]>;
1282
- //=> true
1283
- ```
1284
-
1285
- Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in an empty tuple. See [Wikipedia: Clause (logic) > Empty clauses](https://en.wikipedia.org/wiki/Clause_(logic)#Empty_clauses:~:text=The%20truth%20evaluation%20of%20an%20empty%20disjunctive%20clause%20is%20always%20false.).
1286
-
1287
- @see {@link Or}
1288
- @see {@link AndAll}
1289
- */
1290
- type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
1291
- //#endregion
1292
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/or.d.ts
1293
- /**
1294
- Returns a boolean for whether either of two given types is `true`.
1295
-
1296
- Use-case: Constructing complex conditional types where at least one condition must be satisfied.
1297
-
1298
- @example
1299
- ```
1300
- import type {Or} from 'type-fest';
1301
-
1302
- type TT = Or<true, true>;
1303
- //=> true
1304
-
1305
- type TF = Or<true, false>;
1306
- //=> true
1307
-
1308
- type FT = Or<false, true>;
1309
- //=> true
1310
-
1311
- type FF = Or<false, false>;
1312
- //=> false
1313
- ```
1314
-
1315
- Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
1316
- For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
1317
-
1318
- @example
1319
- ```
1320
- import type {Or} from 'type-fest';
1321
-
1322
- type A = Or<false, boolean>;
1323
- //=> boolean
1324
-
1325
- type B = Or<boolean, false>;
1326
- //=> boolean
1327
-
1328
- type C = Or<true, boolean>;
1329
- //=> true
1330
-
1331
- type D = Or<boolean, true>;
1332
- //=> true
1333
-
1334
- type E = Or<boolean, boolean>;
1335
- //=> boolean
1336
- ```
1337
-
1338
- Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
1339
-
1340
- @example
1341
- ```
1342
- import type {Or} from 'type-fest';
1343
-
1344
- type A = Or<true, never>;
1345
- //=> true
1346
-
1347
- type B = Or<never, true>;
1348
- //=> true
1349
-
1350
- type C = Or<false, never>;
1351
- //=> false
1352
-
1353
- type D = Or<never, false>;
1354
- //=> false
1355
-
1356
- type E = Or<boolean, never>;
1357
- //=> boolean
1358
-
1359
- type F = Or<never, boolean>;
1360
- //=> boolean
1361
-
1362
- type G = Or<never, never>;
1363
- //=> false
1364
- ```
1365
-
1366
- @see {@link OrAll}
1367
- @see {@link And}
1368
- @see {@link Xor}
1369
- */
1370
- type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
1371
- //#endregion
1372
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/internal/string.d.ts
1373
- /**
1374
- Returns a boolean for whether the given string `S` starts with the given string `SearchString`.
1375
-
1376
- @example
1377
- ```
1378
- type A = StartsWith<'abcde', 'abc'>;
1379
- //=> true
1380
-
1381
- type B = StartsWith<'abcde', 'bc'>;
1382
- //=> false
1383
-
1384
- type C = StartsWith<string, 'bc'>;
1385
- //=> never
1386
-
1387
- type D = StartsWith<'abcde', string>;
1388
- //=> never
1389
- ```
1390
-
1391
- @category String
1392
- @category Template literal
1393
- */
1394
- type StartsWith<S extends string, SearchString extends string> = string extends S | SearchString ? never : S extends `${SearchString}${infer T}` ? true : false;
1395
- /**
1396
- Returns a boolean for whether the string is numeric.
1397
-
1398
- This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
1399
- */
1400
- type IsNumeric<T extends string> = T extends `${number}` ? Trim<T> extends T ? true : false : false;
1401
- //#endregion
1402
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/internal/object.d.ts
1403
- /**
1404
- Merges user specified options with default options.
1405
-
1406
- @example
1407
- ```
1408
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1409
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1410
- type SpecifiedOptions = {leavesOnly: true};
1411
-
1412
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1413
- //=> {maxRecursionDepth: 10; leavesOnly: true}
1414
- ```
1415
-
1416
- @example
1417
- ```
1418
- // Complains if default values are not provided for optional options
1419
-
1420
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1421
- type DefaultPathsOptions = {maxRecursionDepth: 10};
1422
- type SpecifiedOptions = {};
1423
-
1424
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1425
- // ~~~~~~~~~~~~~~~~~~~
1426
- // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
1427
- ```
1428
-
1429
- @example
1430
- ```
1431
- // Complains if an option's default type does not conform to the expected type
1432
-
1433
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1434
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
1435
- type SpecifiedOptions = {};
1436
-
1437
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1438
- // ~~~~~~~~~~~~~~~~~~~
1439
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1440
- ```
1441
-
1442
- @example
1443
- ```
1444
- // Complains if an option's specified type does not conform to the expected type
1445
-
1446
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1447
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1448
- type SpecifiedOptions = {leavesOnly: 'yes'};
1449
-
1450
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1451
- // ~~~~~~~~~~~~~~~~
1452
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1453
- ```
1454
- */
1455
- 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>`
1456
- ) ? Result : never;
1457
- 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]; }>>>;
1458
- /**
1459
- Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
1460
-
1461
- 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>`.
1462
-
1463
- Use-case: For collapsing unions created using {@link LiteralUnion}.
1464
-
1465
- @example
1466
- ```
1467
- import type {LiteralUnion} from 'type-fest';
1468
-
1469
- type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
1470
- //=> string
1471
-
1472
- type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
1473
- //=> number
1474
-
1475
- type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
1476
- //=> `on${string}`
1477
-
1478
- type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
1479
- //=> 'click' | 'change' | `on${string}`
1480
-
1481
- type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
1482
- //=> string | null | undefined
1483
- ```
1484
- */
1485
- type CollapseLiterals<T> = {} extends T ? T : T extends (infer U) & {} ? U : T;
1486
- /**
1487
- Returns the base type of a branded type.
1488
-
1489
- @example
1490
- ```
1491
- type Brand = {readonly __brand: unique symbol};
1492
-
1493
- type A = UnwrapBrand<string & Brand>;
1494
- //=> string
1495
-
1496
- type B = UnwrapBrand<number & Brand>;
1497
- //=> number
1498
-
1499
- type C = UnwrapBrand<PropertyKey & Brand>;
1500
- //=> PropertyKey
1501
-
1502
- type D = UnwrapBrand<(1 | 200n | 'foo' | 'bar') & Brand>;
1503
- //=> 1 | 200n | 'foo' | 'bar'
1504
- ```
1505
- */
1506
- type UnwrapBrand<T> = IfNotAnyOrNever<T, {
1507
- ifNot: _UnwrapBrand<T, Primitive>;
1508
- }>;
1509
- type _UnwrapBrand<T, Base> = T extends Primitive ? T extends (infer U) & Pick<T, Exclude<keyof T, KeysOfUnion<Base>>> ? U : T : T;
1510
- //#endregion
1511
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-string-literal.d.ts
1512
- /**
1513
- 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).
1514
-
1515
- The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
1516
-
1517
- @example
1518
- ```
1519
- import type {IsStringLiteral} from 'type-fest';
1520
-
1521
- type A = IsStringLiteral<'foo'>;
1522
- //=> true
1523
-
1524
- type B = IsStringLiteral<string>;
1525
- //=> false
1526
-
1527
- // String types with infinite set of possible values return `false`
1528
- type C = IsStringLiteral<`on${string}`>;
1529
- //=> false
1530
-
1531
- type D = IsStringLiteral<Uppercase<string>>;
1532
- //=> false
1533
-
1534
- type E = IsStringLiteral<'foo' | 'bar' | 'baz'>;
1535
- //=> true
1536
-
1537
- type F = IsStringLiteral<'sm' | 'md' | 'lg' | `${number}px`>;
1538
- //=> boolean
1539
- ```
1540
-
1541
- @example
1542
- ```
1543
- import type {IsStringLiteral} from 'type-fest';
1544
-
1545
- type StringLength<S extends string, Counter extends never[] = []> =
1546
- IsStringLiteral<S> extends true
1547
- ? S extends `${string}${infer Tail}`
1548
- ? StringLength<Tail, [...Counter, never]>
1549
- : Counter['length']
1550
- : number; // return `number` for non-literal string types
1551
-
1552
- type L1 = StringLength<'foobar'>;
1553
- //=> 6
1554
-
1555
- type L2 = StringLength<Lowercase<string>>;
1556
- //=> number
1557
-
1558
- type L3 = StringLength<`${number}`>;
1559
- //=> number
1560
- ```
1561
-
1562
- @category Type Guard
1563
- @category Utilities
1564
- */
1565
- type IsStringLiteral<S> = IfNotAnyOrNever<S, {
1566
- ifNot: _IsStringLiteral<CollapseLiterals<UnwrapBrand<S>>>;
1567
- ifAny: false;
1568
- ifNever: false;
1569
- }>;
1570
- type _IsStringLiteral<S> =
1571
- // If `S` is an infinite string type (e.g., `on${string}`), `Record<S, never>` produces an index signature,
1572
- // and since `{}` extends index signatures, the result becomes `false`.
1573
- S extends string ? {} extends Record<S, never> ? false : true : false;
1574
- //#endregion
1575
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/all-extend.d.ts
1576
- /**
1577
- @see {@link AllExtend}
1578
- */
1579
- type AllExtendOptions = {
1580
- /**
1581
- Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1582
-
1583
- - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1584
- - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1585
-
1586
- @default true
1587
-
1588
- @example
1589
- ```
1590
- import type {AllExtend} from 'type-fest';
1591
-
1592
- type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
1593
- //=> false
1594
-
1595
- type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
1596
- //=> true
1597
-
1598
- type C = AllExtend<[never, never], never, {strictNever: true}>;
1599
- //=> true
1600
-
1601
- type D = AllExtend<[never, never], never, {strictNever: false}>;
1602
- //=> true
1603
-
1604
- type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
1605
- //=> true
1606
-
1607
- type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
1608
- //=> true
1609
-
1610
- type G = AllExtend<[never, 1], never, {strictNever: true}>;
1611
- //=> false
1612
-
1613
- type H = AllExtend<[never, 1], never, {strictNever: false}>;
1614
- //=> false
1615
- ```
1616
- */
1617
- strictNever?: boolean;
1618
- };
1619
- type DefaultAllExtendOptions = {
1620
- strictNever: true;
1621
- };
1622
- /**
1623
- Returns a boolean for whether every element in an array type extends another type.
1624
-
1625
- @example
1626
- ```
1627
- import type {AllExtend} from 'type-fest';
1628
-
1629
- type A = AllExtend<[1, 2, 3], number>;
1630
- //=> true
1631
-
1632
- type B = AllExtend<[1, 2, '3'], number>;
1633
- //=> false
1634
-
1635
- type C = AllExtend<[number, number | string], number>;
1636
- //=> boolean
1637
-
1638
- type D = AllExtend<[true, boolean, true], true>;
1639
- //=> boolean
1640
- ```
1641
-
1642
- Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
1643
-
1644
- ```
1645
- // @exactOptionalPropertyTypes: true
1646
- import type {AllExtend} from 'type-fest';
1647
-
1648
- type A = AllExtend<[1?, 2?, 3?], number>;
1649
- //=> true
1650
- ```
1651
-
1652
- ```
1653
- // @exactOptionalPropertyTypes: false
1654
- import type {AllExtend} from 'type-fest';
1655
-
1656
- type A = AllExtend<[1?, 2?, 3?], number>;
1657
- //=> boolean
1658
-
1659
- type B = AllExtend<[1?, 2?, 3?], number | undefined>;
1660
- //=> true
1661
- ```
1662
-
1663
- @see {@link AllExtendOptions}
1664
-
1665
- @category Utilities
1666
- @category Array
1667
- */
1668
- type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = IfNotAnyOrNever<CollapseRestElement<TArray>, {
1669
- ifNot: _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
1670
- ifAny: false;
1671
- ifNever: false;
1672
- }>;
1673
- // Kept free of `IfNotAnyOrNever` so that it stays tail-recursive, which allows it to handle long arrays.
1674
- type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true ?
1675
- // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
1676
- _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true;
1677
- //#endregion
1678
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/promisable.d.ts
1679
- /**
1680
- Create a type that represents either the value or the value wrapped in `PromiseLike`.
1681
-
1682
- Use-cases:
1683
- - A function accepts a callback that may either return a value synchronously or may return a promised value.
1684
- - This type could be the return type of `Promise#then()`, `Promise#catch()`, and `Promise#finally()` callbacks.
1685
-
1686
- Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31394) if you want to have this type as a built-in in TypeScript.
1687
-
1688
- @example
1689
- ```
1690
- import type {Promisable} from 'type-fest';
1691
-
1692
- async function logger(getLogEntry: () => Promisable<string>): Promise<void> {
1693
- const entry = await getLogEntry();
1694
- console.log(entry);
1695
- }
1696
-
1697
- await logger(() => 'foo');
1698
- await logger(() => Promise.resolve('bar'));
1699
- ```
1700
-
1701
- @category Async
1702
- */
1703
- type Promisable<T> = T | PromiseLike<T>;
1704
- //#endregion
1705
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-lowercase.d.ts
1706
- /**
1707
- Returns a boolean for whether the given string literal is lowercase.
1708
-
1709
- @example
1710
- ```
1711
- import type {IsLowercase} from 'type-fest';
1712
-
1713
- type A = IsLowercase<'abc'>;
1714
- //=> true
1715
-
1716
- type B = IsLowercase<'Abc'>;
1717
- //=> false
1718
-
1719
- type C = IsLowercase<string>;
1720
- //=> boolean
1721
- ```
1722
- */
1723
- type IsLowercase<S extends string> = AllExtend<_IsLowercase<S>, true>;
1724
- /**
1725
- Loops through each part in the string and returns a boolean array indicating whether each part is lowercase.
1726
- */
1727
- type _IsLowercase<S extends string, Accumulator extends boolean[] = []> = S extends `${infer First}${infer Rest}` ? _IsLowercase<Rest, [...Accumulator, IsLowercaseHelper<First>]> : [...Accumulator, IsLowercaseHelper<S>];
1728
- /**
1729
- Returns a boolean for whether an individual part of the string is lowercase.
1730
- */
1731
- type IsLowercaseHelper<S extends string> = S extends Lowercase<string> ? true : S extends Uppercase<string> | Capitalize<string> | `${string}${Uppercase<string>}${string}` ? false : boolean;
1732
- //#endregion
1733
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/is-uppercase.d.ts
1734
- /**
1735
- Returns a boolean for whether the given string literal is uppercase.
1736
-
1737
- @example
1738
- ```
1739
- import type {IsUppercase} from 'type-fest';
1740
-
1741
- type A = IsUppercase<'ABC'>;
1742
- //=> true
1743
-
1744
- type B = IsUppercase<'Abc'>;
1745
- //=> false
1746
-
1747
- type C = IsUppercase<string>;
1748
- //=> boolean
1749
- ```
1750
- */
1751
- type IsUppercase<S extends string> = AllExtend<_IsUppercase<S>, true>;
1752
- /**
1753
- Loops through each part in the string and returns a boolean array indicating whether each part is uppercase.
1754
- */
1755
- type _IsUppercase<S extends string, Accumulator extends boolean[] = []> = S extends `${infer First}${infer Rest}` ? _IsUppercase<Rest, [...Accumulator, IsUppercaseHelper<First>]> : [...Accumulator, IsUppercaseHelper<S>];
1756
- /**
1757
- Returns a boolean for whether an individual part of the string is uppercase.
1758
- */
1759
- type IsUppercaseHelper<S extends string> = S extends Uppercase<string> ? true : S extends Lowercase<string> | Uncapitalize<string> | `${string}${Lowercase<string>}${string}` ? false : boolean;
1760
- //#endregion
1761
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/words.d.ts
1762
- type SkipEmptyWord<Word extends string> = Word extends '' ? [] : [Word];
1763
- type RemoveLastCharacter<Sentence extends string, Character extends string> = Sentence extends `${infer LeftSide}${Character}` ? SkipEmptyWord<LeftSide> : never;
1764
- /**
1765
- Words options.
1766
-
1767
- @see {@link Words}
1768
- */
1769
- type WordsOptions = {
1770
- /**
1771
- Split on numeric sequence.
1772
-
1773
- @default true
1774
-
1775
- @example
1776
- ```
1777
- import type {Words} from 'type-fest';
1778
-
1779
- type Example1 = Words<'p2pNetwork', {splitOnNumbers: true}>;
1780
- //=> ['p', '2', 'p', 'Network']
1781
-
1782
- type Example2 = Words<'p2pNetwork', {splitOnNumbers: false}>;
1783
- //=> ['p2p', 'Network']
1784
- ```
1785
- */
1786
- splitOnNumbers?: boolean;
1787
- /**
1788
- Split on {@link AsciiPunctuation | punctuation characters} (e.g., `#`, `&`, `*`, `:`, `?`, `@`, `~`).
1789
-
1790
- @example
1791
- ```
1792
- import type {Words} from 'type-fest';
1793
-
1794
- type Example1 = Words<'hello:world', {splitOnPunctuation: true}>;
1795
- //=> ['hello', 'world']
1796
-
1797
- type Example2 = Words<'hello:world', {splitOnPunctuation: false}>;
1798
- //=> ['hello', ':world']
1799
- ```
1800
- */
1801
- splitOnPunctuation?: boolean;
1802
- };
1803
- type _DefaultWordsOptions = {
1804
- splitOnNumbers: true;
1805
- splitOnPunctuation: false;
1806
- };
1807
- /**
1808
- Split a string similar to Lodash's `_.words()` function.
1809
-
1810
- - Split on each word that begins with a capital letter.
1811
- - Split on each {@link WordSeparators}.
1812
- - Split on each {@link AsciiPunctuation} (if {@link WordsOptions.splitOnPunctuation} is enabled).
1813
- - Split on numeric sequence.
1814
-
1815
- @example
1816
- ```
1817
- import type {Words} from 'type-fest';
1818
-
1819
- type Words0 = Words<'helloWorld'>;
1820
- //=> ['hello', 'World']
1821
-
1822
- type Words1 = Words<'helloWORLD'>;
1823
- //=> ['hello', 'WORLD']
1824
-
1825
- type Words2 = Words<'hello-world'>;
1826
- //=> ['hello', 'world']
1827
-
1828
- type Words3 = Words<'--hello the_world'>;
1829
- //=> ['hello', 'the', 'world']
1830
-
1831
- type Words4 = Words<'lifeIs42'>;
1832
- //=> ['life', 'Is', '42']
1833
-
1834
- type Words5 = Words<'p2pNetwork', {splitOnNumbers: false}>;
1835
- //=> ['p2p', 'Network']
1836
-
1837
- type Words6 = Words<'hello:world', {splitOnPunctuation: true}>;
1838
- //=> ['hello', 'world']
1839
-
1840
- type Words7 = Words<'hello:world', {splitOnPunctuation: false}>;
1841
- //=> ['hello', ':world']
1842
-
1843
- type Words8 = Words<'hello::world', {splitOnPunctuation: true}>;
1844
- //=> ['hello', 'world']
1845
- ```
1846
-
1847
- @category Change case
1848
- @category Template literal
1849
- */
1850
- type Words<Sentence extends string, Options extends WordsOptions = {}> = WordsImplementation<Sentence, ApplyDefaultOptions<WordsOptions, _DefaultWordsOptions, Options>>;
1851
- type WordsImplementation<Sentence extends string, Options extends Required<WordsOptions>, LastCharacter extends string = '', CurrentWord extends string = ''> = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}` ? FirstCharacter extends WordSeparators | (Options['splitOnPunctuation'] extends true ? AsciiPunctuation : never) ?
1852
- // Skip word separator
1853
- [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options>] : LastCharacter extends '' ?
1854
- // Fist char of word
1855
- WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter> :
1856
- // Case change: non-numeric to numeric
1857
- [false, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? Options['splitOnNumbers'] extends true ?
1858
- // Split on number: push word
1859
- [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] :
1860
- // No split on number: concat word
1861
- WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> :
1862
- // Case change: numeric to non-numeric
1863
- [true, false] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? Options['splitOnNumbers'] extends true ?
1864
- // Split on number: push word
1865
- [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] :
1866
- // No split on number: concat word
1867
- WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> :
1868
- // No case change: concat word
1869
- [true, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> :
1870
- // Case change: lower to upper, push word
1871
- [true, true] extends [IsLowercase<LastCharacter>, IsUppercase<FirstCharacter>] ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] :
1872
- // Case change: upper to lower, brings back the last character, push word
1873
- [true, true] extends [IsUppercase<LastCharacter>, IsLowercase<FirstCharacter>] ? [...RemoveLastCharacter<CurrentWord, LastCharacter>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${LastCharacter}${FirstCharacter}`>] :
1874
- // No case change: concat word
1875
- WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> : [...SkipEmptyWord<CurrentWord>];
1876
- //#endregion
1877
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/delimiter-case.d.ts
1878
- type _DefaultDelimiterCaseOptions = Merge<_DefaultWordsOptions, {
1879
- splitOnNumbers: false;
1880
- }>;
1881
- /**
1882
- Convert an array of words to delimiter case starting with a delimiter with input capitalization.
1883
- */
1884
- type DelimiterCaseFromArray<Words extends string[], Delimiter extends string, OutputString extends string = ''> = Words extends [infer FirstWord extends string, ...infer RemainingWords extends string[]] ? DelimiterCaseFromArray<RemainingWords, Delimiter, OutputString extends '' ? FirstWord : `${OutputString}${StartsWith<FirstWord, AsciiPunctuation> extends true ? '' : Delimiter}${FirstWord}`> : OutputString;
1885
- /**
1886
- Convert a string literal to a custom string delimiter casing.
1887
-
1888
- This can be useful when, for example, converting a camel-cased object property to an oddly cased one.
1889
-
1890
- @see {@link KebabCase}
1891
- @see {@link SnakeCase}
1892
-
1893
- @example
1894
- ```
1895
- import type {DelimiterCase} from 'type-fest';
1896
-
1897
- // Simple
1898
-
1899
- const someVariable: DelimiterCase<'fooBar', '#'> = 'foo#bar';
1900
- const someVariableNoSplitOnNumbers: DelimiterCase<'p2pNetwork', '#', {splitOnNumbers: false}> = 'p2p#network';
1901
- const someVariableWithPunctuation: DelimiterCase<'div.card::after', '#', {splitOnPunctuation: true}> = 'div#card#after';
1902
-
1903
- // Advanced
1904
-
1905
- type OddlyCasedProperties<T> = {
1906
- [K in keyof T as DelimiterCase<K, '#'>]: T[K]
1907
- };
1908
-
1909
- type SomeOptions = {
1910
- dryRun: boolean;
1911
- includeFile: string;
1912
- foo: number;
1913
- };
1914
-
1915
- const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
1916
- 'dry#run': true,
1917
- 'include#file': 'bar.js',
1918
- foo: 123,
1919
- };
1920
- ```
1921
-
1922
- @category Change case
1923
- @category Template literal
1924
- */
1925
- type DelimiterCase<Value, Delimiter extends string, Options extends WordsOptions = {}> = Value extends string ? Delimiter extends string // For distributing `Delimiter`
1926
- ? IsStringLiteral<Value> extends false ? Value : Lowercase<DelimiterCaseFromArray<Words<Value, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>, Delimiter>> : never : Value;
1927
- //#endregion
1928
- //#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/kebab-case.d.ts
1929
- /**
1930
- Convert a string literal to kebab-case.
1931
-
1932
- This can be useful when, for example, converting a camel-cased object property to a kebab-cased CSS class name or a command-line flag.
1933
-
1934
- @example
1935
- ```
1936
- import type {KebabCase} from 'type-fest';
1937
-
1938
- // Simple
1939
-
1940
- const someVariable: KebabCase<'fooBar'> = 'foo-bar';
1941
- const someVariableNoSplitOnNumbers: KebabCase<'p2pNetwork', {splitOnNumbers: false}> = 'p2p-network';
1942
- const someVariableWithPunctuation: KebabCase<'div.card::after', {splitOnPunctuation: true}> = 'div-card-after';
1943
-
1944
- // Advanced
1945
-
1946
- type KebabCasedProperties<T> = {
1947
- [K in keyof T as KebabCase<K>]: T[K]
1948
- };
1949
-
1950
- type CliOptions = {
1951
- dryRun: boolean;
1952
- includeFile: string;
1953
- foo: number;
1954
- };
1955
-
1956
- const rawCliOptions: KebabCasedProperties<CliOptions> = {
1957
- 'dry-run': true,
1958
- 'include-file': 'bar.js',
1959
- foo: 123,
1960
- };
1961
- ```
1962
-
1963
- @category Change case
1964
- @category Template literal
1965
- */
1966
- type KebabCase<Value, Options extends WordsOptions = {}> = DelimiterCase<Value, '-', ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>;
1967
- //#endregion
1968
- //#region src/models/shared/ItemMetadataClass.d.ts
1969
- export interface ItemMetadataClass<TBase extends Class<object>> {
1970
- new (...args: ConstructorParameters<TBase>): InstanceType<TBase> & ItemMetadata;
1971
- prototype: InstanceType<TBase> & ItemMetadata;
1972
- }
1973
- //#endregion
1974
- //#region src/models/shared/Serializable.d.ts
1975
- export declare abstract class Serializable {
1976
- toJSON(): this;
1977
- }
1978
- //#endregion
1979
- //#region src/models/shared/TakeOne.d.ts
1980
- export interface TakeOne {
1981
- <T extends readonly unknown[]>(values: T, index?: number): T[number];
1982
- <T extends object>(values: T, index: keyof T): T[keyof T];
1983
- }
1984
- //#endregion
1985
- //#region src/util/types/FunctionLike.d.ts
1986
- export type FunctionLike = ((...args: never) => unknown) | (abstract new (...args: never) => unknown);
1987
- //#endregion
1988
- //#region src/util/types/DeepOmit.d.ts
1989
- export type DeepOmit<T, TKey extends PropertyKey> = T extends DeepOmitKeptValue ? T : T extends readonly unknown[] ? { [K in keyof T]: DeepOmit<T[K], TKey>; } : T extends object ? [keyof T] extends [never] ? T : { [P in keyof T as P extends symbol ? never : P extends TKey ? never : P]: DeepOmit<T[P], TKey>; } : T;
1990
- type DeepOmitKeptValue = ArrayBufferView | Blob | Date | FunctionLike | Map<unknown, unknown> | Primitive | Promise<unknown> | RegExp | Set<unknown>;
1991
- //#endregion
1992
- //#region src/util/types/DeepOptionalUndefined.d.ts
1993
- export type DeepOptionalUndefined<T> = T extends Date | FunctionLike | 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;
1994
- //#endregion
1995
- //#region src/models/shared/ToData.d.ts
1996
- export type ToData<T> = DeepOptionalUndefined<DeepOmit<T, "toJSON">>;
1997
- //#endregion
1998
- //#region src/models/text/DedentOptions.d.ts
1999
- export interface DedentOptions {
2000
- alignValues?: boolean;
2001
- escapeSpecialCharacters?: boolean;
2002
- trimWhitespace?: boolean;
2003
- }
2004
- //#endregion
2005
- //#region src/models/text/Dedent.d.ts
2006
- export interface Dedent {
2007
- (strings: string | TemplateStringsArray, ...values: unknown[]): string;
2008
- withOptions: (options: DedentOptions) => Dedent;
2009
- }
2010
- //#endregion
2011
- //#region src/models/zod/UniqueArraySchemaKey.d.ts
2012
- export type UniqueArraySchemaKey<TSchema extends z.ZodType> = TSchema extends z.ZodObject ? keyof TSchema["shape"] & string : keyof z.output<TSchema> & string;
2013
- //#endregion
2014
- //#region src/models/zod/CreateUniqueArraySchema.d.ts
2015
- 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>);
2016
- //#endregion
2017
- //#region src/services/app/constants.d.ts
2018
- export declare const MAX_READ_LIMIT = 1e3;
2019
- export declare const SITE_NAME = "Esposter";
2020
- export declare const KIBIBYTE: number;
2021
- export declare const GIBIBYTE: number;
2022
- //#endregion
2023
- //#region src/services/error/getResult.d.ts
2024
- export declare const getResult: <T>(callback: () => T) => Result<T, Error>;
2025
- //#endregion
2026
- //#region src/services/error/getResultAsync.d.ts
2027
- export declare const getResultAsync: <T>(callback: () => Promise<T>) => ResultAsync<T, Error>;
2028
- //#endregion
2029
- //#region src/services/error/reportFinalizerError.d.ts
2030
- export declare const reportFinalizerError: <T, E>(callbackResult: Result<T, E>, finalizerError: unknown) => void;
2031
- //#endregion
2032
- //#region src/services/error/toAppError.d.ts
2033
- export declare const toAppError: (error: unknown) => Error;
2034
- //#endregion
2035
- //#region src/services/error/withFinalizer.d.ts
2036
- export declare const withFinalizer: <T>(callback: () => T, finalizer?: () => void) => T;
2037
- //#endregion
2038
- //#region src/services/error/withFinalizerAsync.d.ts
2039
- export declare const withFinalizerAsync: <T>(callback: () => Promisable<T>, finalizer?: () => Promisable<void>) => Promise<T>;
2040
- //#endregion
2041
- //#region src/services/indexedDb/getRequestError.d.ts
2042
- export declare const getRequestError: (request: IDBRequest) => DOMException;
2043
- //#endregion
2044
- //#region src/services/indexedDb/getTransactionDone.d.ts
2045
- export declare const getTransactionDone: (transaction: IDBTransaction) => Promise<void>;
2046
- //#endregion
2047
- //#region src/services/indexedDb/getTransactionObjectStore.d.ts
2048
- export declare const getTransactionObjectStore: <TSchema extends DatabaseSchema, TMode extends IDBTransactionMode>(transaction: IDBTransaction) => <TStoreName extends DatabaseStoreName<TSchema>>(name: TStoreName) => DatabaseObjectStore<TSchema, TStoreName, TMode>;
2049
- //#endregion
2050
- //#region src/services/indexedDb/openDatabase.d.ts
2051
- export declare const openDatabase: <TSchema extends DatabaseSchema = DatabaseSchema>(name: string, version: number, options?: DatabaseOpenOptions<TSchema>) => Promise<Database<TSchema>>;
2052
- //#endregion
2053
- //#region src/services/indexedDb/requestToPromise.d.ts
2054
- export declare const requestToPromise: <TResult>(request: IDBRequest) => Promise<TResult>;
2055
- //#endregion
2056
- //#region src/services/indexedDb/wrapDatabase.d.ts
2057
- export declare const wrapDatabase: <TSchema extends DatabaseSchema = DatabaseSchema>(database: IDBDatabase) => Database<TSchema>;
2058
- //#endregion
2059
- //#region src/services/indexedDb/wrapIndex.d.ts
2060
- export declare const wrapIndex: <TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>, TIndexName extends DatabaseIndexName<TSchema, TStoreName>>(index: IDBIndex) => DatabaseIndex<TSchema, TStoreName, TIndexName>;
2061
- //#endregion
2062
- //#region src/services/indexedDb/wrapObjectStore.d.ts
2063
- export declare const wrapObjectStore: <TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>, TMode extends IDBTransactionMode>(objectStore: IDBObjectStore) => DatabaseObjectStore<TSchema, TStoreName, TMode>;
2064
- //#endregion
2065
- //#region src/services/indexedDb/wrapTransaction.d.ts
2066
- export declare const wrapTransaction: <TSchema extends DatabaseSchema, TStoreName extends DatabaseStoreName<TSchema>, TMode extends IDBTransactionMode>(transaction: IDBTransaction) => DatabaseTransaction<TSchema, TStoreName, TMode>;
2067
- //#endregion
2068
- //#region src/services/indexedDb/wrapUpgradeDatabase.d.ts
2069
- export declare const wrapUpgradeDatabase: <TSchema extends DatabaseSchema = DatabaseSchema>(database: IDBDatabase) => UpgradeDatabase<TSchema>;
2070
- //#endregion
2071
- //#region src/services/indexedDb/wrapUpgradeTransaction.d.ts
2072
- export declare const wrapUpgradeTransaction: <TSchema extends DatabaseSchema>(transaction: IDBTransaction) => DatabaseTransaction<TSchema, DatabaseStoreName<TSchema>, "versionchange">;
2073
- //#endregion
2074
- //#region src/services/message/constants.d.ts
2075
- export declare const MENTION_ID_ATTRIBUTE = "data-id";
2076
- export declare const MENTION_ITEM_TYPE_ATTRIBUTE = "data-mention-type";
2077
- export declare const MENTION_LABEL_ATTRIBUTE = "data-label";
2078
- export declare const MENTION_TYPE_ATTRIBUTE = "data-type";
2079
- export declare const MENTION_TYPE = "mention";
2080
- export declare const MENTION_SELECTOR: string;
2081
- export declare const MENTION_HERE_ID = "@here";
2082
- export declare const MENTION_EVERYONE_ID = "@everyone";
2083
- export declare const CUSTOM_EMOJI_ID_ATTRIBUTE = "data-custom-emoji-id";
2084
- export declare const CUSTOM_EMOJI_NAME_ATTRIBUTE = "data-custom-emoji-name";
2085
- export declare const SPOILER_ATTRIBUTE = "data-spoiler";
2086
- export declare const SPOILER_SELECTOR: string;
2087
- //#endregion
2088
- //#region src/services/message/getMentions.d.ts
2089
- export declare const getMentions: (message: string) => HTMLElement[];
2090
- //#endregion
2091
- //#region src/services/mime/charset.d.ts
2092
- export declare const charset: (type: string) => false | string;
2093
- //#endregion
2094
- //#region src/services/mime/constants.d.ts
2095
- export declare const MEDIA_TYPE_REGEX: RegExp;
2096
- export declare const PATH_SEPARATOR_REGEX: RegExp;
2097
- export declare const TEXT_MEDIA_TYPE_REGEX: RegExp;
2098
- export declare const CHARSET_PARAMETER_REGEX: RegExp;
2099
- export declare const DEFAULT_TEXT_CHARSET = "UTF-8";
2100
- export declare const FacetScoreMap: ReadonlyMap<string, number>;
2101
- export declare const DEFAULT_FACET_SCORE = 900;
2102
- export declare const SourceScoreMap: ReadonlyMap<string, number>;
2103
- export declare const DEFAULT_SOURCE_SCORE = 30;
2104
- export declare const TypeScoreMap: ReadonlyMap<string, number>;
2105
- export declare const DEFAULT_TYPE_SCORE = 0;
2106
- //#endregion
2107
- //#region src/services/mime/contentType.d.ts
2108
- export declare const contentType: (value: string) => false | string;
2109
- //#endregion
2110
- //#region src/services/mime/extension.d.ts
2111
- export declare const extension: (type: string) => false | string;
2112
- //#endregion
2113
- //#region src/services/mime/getExtensionMimeTypeMap.d.ts
2114
- export declare const getExtensionMimeTypeMap: () => ReadonlyMap<string, string>;
2115
- //#endregion
2116
- //#region src/services/mime/getMediaType.d.ts
2117
- export declare const getMediaType: (value: string) => string;
2118
- //#endregion
2119
- //#region src/services/mime/getMimeScore.d.ts
2120
- export declare const getMimeScore: (mimeType: string, source?: string) => number;
2121
- //#endregion
2122
- //#region src/services/mime/getMimeTypeEntryMap.d.ts
2123
- export declare const getMimeTypeEntryMap: () => ReadonlyMap<string, MimeDatabaseEntry>;
2124
- //#endregion
2125
- //#region src/services/mime/lookup.d.ts
2126
- export declare const lookup: (path: string) => false | string;
2127
- //#endregion
2128
- //#region src/services/prettier/css.d.ts
2129
- export declare const css: typeof String.raw;
2130
- //#endregion
2131
- //#region src/services/prettier/html.d.ts
2132
- export declare const html: typeof String.raw;
2133
- //#endregion
2134
- //#region src/services/profanity/checkContainsProfanity.d.ts
2135
- export declare const checkContainsProfanity: (text: unknown, { isWholeWord }?: Partial<ProfanityOptions>) => boolean;
2136
- //#endregion
2137
- //#region src/services/profanity/englishProfaneWords.d.ts
2138
- export declare const englishProfaneWords: readonly string[];
2139
- //#endregion
2140
- //#region src/services/sanitizeHtml/checkIsAllowedUrl.d.ts
2141
- export declare const checkIsAllowedUrl: (url: string, allowedSchemes: string[]) => boolean;
2142
- //#endregion
2143
- //#region src/services/sanitizeHtml/checkIsUnsafeUrlCharacter.d.ts
2144
- export declare const checkIsUnsafeUrlCharacter: (character: string) => boolean;
2145
- //#endregion
2146
- //#region src/services/sanitizeHtml/checkIsWhitespaceCharacter.d.ts
2147
- export declare const checkIsWhitespaceCharacter: (character: string) => boolean;
2148
- //#endregion
2149
- //#region src/services/sanitizeHtml/collectText.d.ts
2150
- export declare const collectText: (nodes: DefaultTreeAdapterTypes.ChildNode[], depth: number) => string;
2151
- //#endregion
2152
- //#region src/services/sanitizeHtml/constants.d.ts
2153
- export declare const HTML_NAMESPACE: html$1.NS;
2154
- export declare const DEFAULT_ALLOWED_TAGS: string[];
2155
- export declare const DEFAULT_LINK_ATTRIBUTES: string[];
2156
- export declare const DEFAULT_ALLOWED_ATTRIBUTES: Record<string, string[]>;
2157
- export declare const DEFAULT_ALLOWED_SCHEMES: string[];
2158
- export declare const NON_TEXT_TAGS: string[];
2159
- export declare const VOID_TAGS: string[];
2160
- export declare const URL_ATTRIBUTES: string[];
2161
- export declare const SRCSET_ATTRIBUTE = "srcset";
2162
- export declare const IMPORTANT_REGEX: RegExp;
2163
- export declare const MAX_NESTING_DEPTH = 256;
2164
- export declare const SRCSET_DESCRIPTOR_REGEX: RegExp;
2165
- export declare const ESCAPED_TEXT_CHARACTERS_REGEX: RegExp;
2166
- export declare const ESCAPED_ATTRIBUTE_CHARACTERS_REGEX: RegExp;
2167
- export declare const SANITIZER_ADVISORY_WATCH_SINCE = "2026-10-11";
2168
- //#endregion
2169
- //#region src/services/sanitizeHtml/escapeAttribute.d.ts
2170
- export declare const escapeAttribute: (value: string) => string;
2171
- //#endregion
2172
- //#region src/services/sanitizeHtml/escapeCharacters.d.ts
2173
- export declare const escapeCharacters: (value: string, charactersRegex: RegExp, entities: Record<string, string>) => string;
2174
- //#endregion
2175
- //#region src/services/sanitizeHtml/escapeText.d.ts
2176
- export declare const escapeText: (text: string) => string;
2177
- //#endregion
2178
- //#region src/services/sanitizeHtml/filterAttributes.d.ts
2179
- export declare const filterAttributes: (element: DefaultTreeAdapterTypes.Element, policy: SanitizePolicy) => Record<string, string>;
2180
- //#endregion
2181
- //#region src/services/sanitizeHtml/filterClasses.d.ts
2182
- export declare const filterClasses: (value: string, patterns: string[] | undefined) => string | undefined;
2183
- //#endregion
2184
- //#region src/services/sanitizeHtml/filterHtml.d.ts
2185
- export declare const filterHtml: (html: string, policy: SanitizePolicy) => string;
2186
- //#endregion
2187
- //#region src/services/sanitizeHtml/filterSrcset.d.ts
2188
- export declare const filterSrcset: (value: string, allowedSchemes: string[]) => string | undefined;
2189
- //#endregion
2190
- //#region src/services/sanitizeHtml/filterStyle.d.ts
2191
- export declare const filterStyle: (value: string, rules: Record<string, RegExp[]> | undefined) => string | undefined;
2192
- //#endregion
2193
- //#region src/services/sanitizeHtml/getChildNodes.d.ts
2194
- export declare const getChildNodes: (element: DefaultTreeAdapterTypes.Element) => DefaultTreeAdapterTypes.ChildNode[];
2195
- //#endregion
2196
- //#region src/services/sanitizeHtml/matchesClassPattern.d.ts
2197
- export declare const matchesClassPattern: (className: string, pattern: string) => boolean;
2198
- //#endregion
2199
- //#region src/services/sanitizeHtml/renderNode.d.ts
2200
- export declare const renderNode: (node: DefaultTreeAdapterTypes.ChildNode, policy: SanitizePolicy, depth: number) => string;
2201
- //#endregion
2202
- //#region src/services/sanitizeHtml/sanitizeHtml.d.ts
2203
- export declare const sanitizeHtml: (html: string, options?: SanitizeHtmlOptions) => string;
2204
- //#endregion
2205
- //#region src/services/sanitizeHtml/sanitizeTextHtml.d.ts
2206
- export declare const sanitizeTextHtml: (html: string) => string;
2207
- //#endregion
2208
- //#region src/services/shared/applyItemMetadataMixin.d.ts
2209
- export declare const applyItemMetadataMixin: <TBase extends Class<object>>(Base: TBase) => ItemMetadataClass<TBase>;
2210
- //#endregion
2211
- //#region src/services/zod/createNormalizedStringSchema.d.ts
2212
- export declare const createNormalizedStringSchema: (maxLength: number, schema?: z.ZodString) => z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
2213
- //#endregion
2214
- //#region src/services/zod/createUniqueArraySchema.d.ts
2215
- export declare const createUniqueArraySchema: CreateUniqueArraySchema;
2216
- //#endregion
2217
- //#region src/services/zstd/constants.d.ts
2218
- export declare const DEFAULT_COMPRESSION_LEVEL = 12;
2219
- export declare const MIN_WINDOW_LOG = 10;
2220
- export declare const MAX_WINDOW_LOG = 27;
2221
- //#endregion
2222
- //#region src/services/zstd/getWindowLog.d.ts
2223
- export declare const getWindowLog: (dictionaryByteCount: number, inputByteCount: number) => number;
2224
- //#endregion
2225
- //#region src/test/constants.d.ts
2226
- export declare const ALL_SPECIAL_VALUES: {
2227
- isPlainObject: boolean;
2228
- value: unknown;
2229
- }[];
2230
- //#endregion
2231
- //#region src/util/array/chunk.d.ts
2232
- export declare const chunk: <T>(array: T[], size: number) => T[][];
2233
- //#endregion
2234
- //#region src/util/array/chunkBySerializedSize.d.ts
2235
- export declare const chunkBySerializedSize: <T>(items: T[], maxBytes: number, maxCount: number) => T[][];
2236
- //#endregion
2237
- //#region src/util/array/takeOne.d.ts
2238
- export declare const takeOne: TakeOne;
2239
- //#endregion
2240
- //#region src/util/date/getEndOfDay.d.ts
2241
- export declare const getEndOfDay: (date: Date) => Date;
2242
- //#endregion
2243
- //#region src/util/date/getZonedDateTime.d.ts
2244
- export declare const getZonedDateTime: (date: Date) => Temporal.ZonedDateTime;
2245
- //#endregion
2246
- //#region src/util/dom/checkIsNestedInteraction.d.ts
2247
- export declare const checkIsNestedInteraction: (event: MouseEvent) => boolean;
2248
- //#endregion
2249
- //#region src/util/environment/checkIsServer.d.ts
2250
- export declare const checkIsServer: () => boolean;
2251
- //#endregion
2252
- //#region src/util/function/getSynchronizedFunction.d.ts
2253
- export declare const getSynchronizedFunction: <TArgs extends unknown[]>(asyncFunction: (...args: TArgs) => Promise<unknown>) => ((...args: TArgs) => void);
2254
- export declare const waitForSynchronizedFunctions: () => Promise<void>;
2255
- //#endregion
2256
- //#region src/util/function/noop.d.ts
2257
- export declare const noop: () => void;
2258
- //#endregion
2259
- //#region src/util/id/constants.d.ts
2260
- export declare const ID_SEPARATOR = "|";
2261
- //#endregion
2262
- //#region src/util/id/uuid/constants.d.ts
2263
- export declare const UUIDV4_REGEX: RegExp;
2264
- //#endregion
2265
- //#region src/util/map/getOrCreate.d.ts
2266
- export declare const getOrCreate: <TKey, TValue>(map: Map<TKey, TValue>, key: TKey, create: () => TValue) => TValue;
2267
- //#endregion
2268
- //#region src/util/object/checkIsCustomMethod.d.ts
2269
- export declare const checkIsCustomMethod: (value: object, methodName: ObjectMethod) => boolean;
2270
- //#endregion
2271
- //#region src/util/object/checkIsDeepEqual.d.ts
2272
- export declare const checkIsDeepEqual: (first: unknown, second: unknown) => boolean;
2273
- //#endregion
2274
- //#region src/util/object/checkIsPlainObject.d.ts
2275
- export declare const checkIsPlainObject: (data: unknown) => data is Record<string, unknown>;
2276
- //#endregion
2277
- //#region src/util/object/checkIsSameBytes.d.ts
2278
- export declare const checkIsSameBytes: (first: ArrayBuffer | ArrayBufferView | SharedArrayBuffer, second: ArrayBuffer | ArrayBufferView | SharedArrayBuffer) => boolean;
2279
- //#endregion
2280
- //#region src/util/object/checkIsSameValueZero.d.ts
2281
- export declare const checkIsSameValueZero: (first: unknown, second: unknown) => boolean;
2282
- //#endregion
2283
- //#region src/util/object/getEnumerableKeys.d.ts
2284
- export declare const getEnumerableKeys: (value: object) => PropertyKey[];
2285
- //#endregion
2286
- //#region src/util/types/GetArrayProps.d.ts
2287
- 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) | {
2288
- path: R extends true ? "length" : `${P}.length`;
2289
- value: T["length"];
2290
- };
2291
- //#endregion
2292
- //#region src/util/types/KnownKeys.d.ts
2293
- export type KnownKeys<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
2294
- //#endregion
2295
- //#region src/util/types/GetObjectProps.d.ts
2296
- 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 FunctionLike ? never : (D extends [unknown, ...infer Rest] ? GetProperties<T[K], R extends true ? `${K}` : `${P}.${K}`, Rest, false> : never) | {
2297
- path: R extends true ? `${K}` : `${P}.${K}`;
2298
- value: T[K];
2299
- }; }[keyof KnownKeys<T> & (number | string)];
2300
- //#endregion
2301
- //#region src/util/types/GetPrimitiveProps.d.ts
2302
- export type GetPrimitiveProps<T, P extends string, D extends unknown[], R extends boolean> = T extends string ? {
2303
- path: R extends true ? "length" : `${P}.length`;
2304
- value: number;
2305
- } : T extends symbol ? (D extends [unknown, ...infer Rest] ? GetProperties<string | undefined, R extends true ? "description" : `${P}.description`, Rest, false> : never) | {
2306
- path: R extends true ? "description" : `${P}.description`;
2307
- value: string | undefined;
2308
- } : never;
2309
- //#endregion
2310
- //#region src/util/types/GetProperties.d.ts
2311
- 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;
2312
- //#endregion
2313
- //#region src/util/types/GetPaths.d.ts
2314
- export type GetPaths<T> = GetProperties<T> extends (infer U) ? (U extends {
2315
- path: infer Path;
2316
- } ? Path : never) : never;
2317
- //#endregion
2318
- //#region src/util/types/PropertyNames.d.ts
2319
- export type PropertyNames<T> = { [P in GetPaths<T>]: P; };
2320
- //#endregion
2321
- //#region src/util/object/getPropertyNames.d.ts
2322
- export declare const getPropertyNames: <T>() => PropertyNames<T>;
2323
- //#endregion
2324
- //#region src/util/object/jsonDateParse.d.ts
2325
- export declare const jsonDateParse: <T = any>(text: string) => T;
2326
- //#endregion
2327
- //#region src/util/types/MergeObjectsStrict.d.ts
2328
- 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;
2329
- //#endregion
2330
- //#region src/util/object/mergeObjectsStrict.d.ts
2331
- export declare const mergeObjectsStrict: <T extends object[]>(...objects: T) => MergeObjectsStrict<T>;
2332
- //#endregion
2333
- //#region src/util/object/omitDeep.d.ts
2334
- export declare const omitDeep: <T, TKey extends string>(value: T, ...keys: TKey[]) => DeepOmit<T, TKey>;
2335
- //#endregion
2336
- //#region src/util/promise/createEvictingPromiseCache.d.ts
2337
- export declare const createEvictingPromiseCache: <TArguments extends unknown[], TValue>(getKey: (...args: TArguments) => string, load: (...args: TArguments) => Promise<TValue>) => ((...args: TArguments) => Promise<TValue>);
2338
- //#endregion
2339
- //#region src/util/promise/settleAll.d.ts
2340
- export declare const settleAll: <T>(tasks: (() => Promise<T>)[], concurrencyLimit?: number) => Promise<T[]>;
2341
- //#endregion
2342
- //#region src/util/reactivity/getRawData.d.ts
2343
- export declare const getRawData: <T>(data: T) => T;
2344
- //#endregion
2345
- //#region src/util/reactivity/toRawDeep.d.ts
2346
- export declare const toRawDeep: <T extends object>(data: T) => T;
2347
- //#endregion
2348
- //#region src/util/text/capitalize.d.ts
2349
- export declare const capitalize: (string: string) => string;
2350
- //#endregion
2351
- //#region src/util/text/dedent.d.ts
2352
- export declare const dedent: Dedent;
2353
- //#endregion
2354
- //#region src/util/text/encodeUrlSubDelimiters.d.ts
2355
- export declare const encodeUrlSubDelimiters: (value: string) => string;
2356
- //#endregion
2357
- //#region src/util/text/getDecodedUriComponent.d.ts
2358
- export declare const getDecodedUriComponent: (value: string, fallback: string) => string;
2359
- //#endregion
2360
- //#region src/util/text/normalizeString.d.ts
2361
- export declare const normalizeString: (value: null | string | undefined) => string;
2362
- //#endregion
2363
- //#region src/util/text/streamToText.d.ts
2364
- export declare const streamToText: (readable: NodeJS.ReadableStream) => Promise<string>;
2365
- //#endregion
2366
- //#region src/util/text/toKebabCase.d.ts
2367
- export declare const toKebabCase: <T extends string>(string: T) => KebabCase<T>;
2368
- //#endregion
2369
- //#region src/util/text/truncate.d.ts
2370
- export declare const truncate: (string: string, length: number) => string;
2371
- //#endregion
2372
- //#region src/util/text/uncapitalize.d.ts
2373
- export declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
2374
- //#endregion
2375
- //#region src/util/time/hrtime.d.ts
2376
- export declare const hrtime: (previousHrTime?: [number, number]) => [number, number];
2377
- //#endregion
2378
- //#region src/util/time/now.d.ts
2379
- export declare const now: () => string;
2380
- //#endregion
2381
- //#region src/util/time/sleep.d.ts
2382
- export declare const sleep: (durationMs: number) => Promise<void>;
2383
- //#endregion
2384
- //#region src/util/validation/exhaustiveGuard.d.ts
2385
- export declare const exhaustiveGuard: (value: never) => never;
2386
- //#endregion
2387
- export {};