@publinx/mihomo-st-api 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 publinx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,1028 @@
1
+ //#region src/resources/version.d.ts
2
+ type VersionInfo = {
3
+ name: string;
4
+ version: string;
5
+ };
6
+ //#endregion
7
+ //#region src/resources/digest.d.ts
8
+ type DigestRequest = Record<string, unknown>;
9
+ type DigestResponse = {
10
+ digest: string;
11
+ };
12
+ //#endregion
13
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/primitive.d.ts
14
+ /**
15
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
16
+
17
+ @category Type
18
+ */
19
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
20
+ //#endregion
21
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-any.d.ts
22
+ /**
23
+ Returns a boolean for whether the given type is `any`.
24
+
25
+ @link https://stackoverflow.com/a/49928360/1490091
26
+
27
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
28
+
29
+ @example
30
+ ```
31
+ import type {IsAny} from 'type-fest';
32
+
33
+ const typedObject = {a: 1, b: 2} as const;
34
+ const anyObject: any = {a: 1, b: 2};
35
+
36
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
37
+ return object[key];
38
+ }
39
+
40
+ const typedA = get(typedObject, 'a');
41
+ //=> 1
42
+
43
+ const anyA = get(anyObject, 'a');
44
+ //=> any
45
+ ```
46
+
47
+ @category Type Guard
48
+ @category Utilities
49
+ */
50
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
51
+ //#endregion
52
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-optional-key-of.d.ts
53
+ /**
54
+ Returns a boolean for whether the given key is an optional key of type.
55
+
56
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
57
+
58
+ @example
59
+ ```
60
+ import type {IsOptionalKeyOf} from 'type-fest';
61
+
62
+ type User = {
63
+ name: string;
64
+ surname: string;
65
+
66
+ luckyNumber?: number;
67
+ };
68
+
69
+ type Admin = {
70
+ name: string;
71
+ surname?: string;
72
+ };
73
+
74
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
75
+ //=> true
76
+
77
+ type T2 = IsOptionalKeyOf<User, 'name'>;
78
+ //=> false
79
+
80
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
81
+ //=> boolean
82
+
83
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
84
+ //=> false
85
+
86
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
87
+ //=> boolean
88
+ ```
89
+
90
+ @category Type Guard
91
+ @category Utilities
92
+ */
93
+ 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;
94
+ //#endregion
95
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/optional-keys-of.d.ts
96
+ /**
97
+ Extract all optional keys from the given type.
98
+
99
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
100
+
101
+ @example
102
+ ```
103
+ import type {OptionalKeysOf, Except} from 'type-fest';
104
+
105
+ type User = {
106
+ name: string;
107
+ surname: string;
108
+
109
+ luckyNumber?: number;
110
+ };
111
+
112
+ const REMOVE_FIELD = Symbol('remove field symbol');
113
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
114
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
115
+ };
116
+
117
+ const update1: UpdateOperation<User> = {
118
+ name: 'Alice',
119
+ };
120
+
121
+ const update2: UpdateOperation<User> = {
122
+ name: 'Bob',
123
+ luckyNumber: REMOVE_FIELD,
124
+ };
125
+ ```
126
+
127
+ @category Utilities
128
+ */
129
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
130
+ ? (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`
131
+ : never;
132
+ //#endregion
133
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/required-keys-of.d.ts
134
+ /**
135
+ Extract all required keys from the given type.
136
+
137
+ 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...
138
+
139
+ @example
140
+ ```
141
+ import type {RequiredKeysOf} from 'type-fest';
142
+
143
+ declare function createValidation<
144
+ Entity extends object,
145
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
146
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
147
+
148
+ type User = {
149
+ name: string;
150
+ surname: string;
151
+ luckyNumber?: number;
152
+ };
153
+
154
+ const validator1 = createValidation<User>('name', value => value.length < 25);
155
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
156
+
157
+ // @ts-expect-error
158
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
159
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
160
+ ```
161
+
162
+ @category Utilities
163
+ */
164
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
165
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
166
+ //#endregion
167
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-never.d.ts
168
+ /**
169
+ Returns a boolean for whether the given type is `never`.
170
+
171
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
172
+ @link https://stackoverflow.com/a/53984913/10292952
173
+ @link https://www.zhenghao.io/posts/ts-never
174
+
175
+ Useful in type utilities, such as checking if something does not occur.
176
+
177
+ @example
178
+ ```
179
+ import type {IsNever, And} from 'type-fest';
180
+
181
+ type A = IsNever<never>;
182
+ //=> true
183
+
184
+ type B = IsNever<any>;
185
+ //=> false
186
+
187
+ type C = IsNever<unknown>;
188
+ //=> false
189
+
190
+ type D = IsNever<never[]>;
191
+ //=> false
192
+
193
+ type E = IsNever<object>;
194
+ //=> false
195
+
196
+ type F = IsNever<string>;
197
+ //=> false
198
+ ```
199
+
200
+ @example
201
+ ```
202
+ import type {IsNever} from 'type-fest';
203
+
204
+ type IsTrue<T> = T extends true ? true : false;
205
+
206
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
207
+ type A = IsTrue<never>;
208
+ //=> never
209
+
210
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
211
+ type IsTrueFixed<T> =
212
+ IsNever<T> extends true ? false : T extends true ? true : false;
213
+
214
+ type B = IsTrueFixed<never>;
215
+ //=> false
216
+ ```
217
+
218
+ @category Type Guard
219
+ @category Utilities
220
+ */
221
+ type IsNever<T> = [T] extends [never] ? true : false;
222
+ //#endregion
223
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/if.d.ts
224
+ /**
225
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
226
+
227
+ Use-cases:
228
+ - 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'>`.
229
+
230
+ Note:
231
+ - 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'`.
232
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
233
+
234
+ @example
235
+ ```
236
+ import type {If} from 'type-fest';
237
+
238
+ type A = If<true, 'yes', 'no'>;
239
+ //=> 'yes'
240
+
241
+ type B = If<false, 'yes', 'no'>;
242
+ //=> 'no'
243
+
244
+ type C = If<boolean, 'yes', 'no'>;
245
+ //=> 'yes' | 'no'
246
+
247
+ type D = If<any, 'yes', 'no'>;
248
+ //=> 'yes' | 'no'
249
+
250
+ type E = If<never, 'yes', 'no'>;
251
+ //=> 'no'
252
+ ```
253
+
254
+ @example
255
+ ```
256
+ import type {If, IsAny, IsNever} from 'type-fest';
257
+
258
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
259
+ //=> 'not any'
260
+
261
+ type B = If<IsNever<never>, 'is never', 'not never'>;
262
+ //=> 'is never'
263
+ ```
264
+
265
+ @example
266
+ ```
267
+ import type {If, IsEqual} from 'type-fest';
268
+
269
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
270
+
271
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
272
+ //=> 'equal'
273
+
274
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
275
+ //=> 'not equal'
276
+ ```
277
+
278
+ 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:
279
+
280
+ @example
281
+ ```
282
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
283
+
284
+ type HundredZeroes = StringRepeat<'0', 100>;
285
+
286
+ // The following implementation is not tail recursive
287
+ type Includes<S extends string, Char extends string> =
288
+ S extends `${infer First}${infer Rest}`
289
+ ? If<IsEqual<First, Char>,
290
+ 'found',
291
+ Includes<Rest, Char>>
292
+ : 'not found';
293
+
294
+ // Hence, instantiations with long strings will fail
295
+ // @ts-expect-error
296
+ type Fails = Includes<HundredZeroes, '1'>;
297
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
298
+ // Error: Type instantiation is excessively deep and possibly infinite.
299
+
300
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
301
+ type IncludesWithoutIf<S extends string, Char extends string> =
302
+ S extends `${infer First}${infer Rest}`
303
+ ? IsEqual<First, Char> extends true
304
+ ? 'found'
305
+ : IncludesWithoutIf<Rest, Char>
306
+ : 'not found';
307
+
308
+ // Now, instantiations with long strings will work
309
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
310
+ //=> 'not found'
311
+ ```
312
+
313
+ @category Type Guard
314
+ @category Utilities
315
+ */
316
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
317
+ //#endregion
318
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/type.d.ts
319
+ /**
320
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
321
+ */
322
+ type BuiltIns = Primitive | void | Date | RegExp;
323
+ /**
324
+ Test if the given function has multiple call signatures.
325
+
326
+ Needed to handle the case of a single call signature with properties.
327
+
328
+ Multiple call signatures cannot currently be supported due to a TypeScript limitation.
329
+ @see https://github.com/microsoft/TypeScript/issues/29732
330
+ */
331
+ type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
332
+ (...arguments_: infer A): unknown;
333
+ (...arguments_: infer B): unknown;
334
+ } ? B extends A ? A extends B ? false : true : true : false;
335
+ //#endregion
336
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/simplify.d.ts
337
+ /**
338
+ 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.
339
+
340
+ @example
341
+ ```
342
+ import type {Simplify} from 'type-fest';
343
+
344
+ type PositionProps = {
345
+ top: number;
346
+ left: number;
347
+ };
348
+
349
+ type SizeProps = {
350
+ width: number;
351
+ height: number;
352
+ };
353
+
354
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
355
+ type Props = Simplify<PositionProps & SizeProps>;
356
+ ```
357
+
358
+ 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.
359
+
360
+ 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`.
361
+
362
+ @example
363
+ ```
364
+ import type {Simplify} from 'type-fest';
365
+
366
+ interface SomeInterface {
367
+ foo: number;
368
+ bar?: string;
369
+ baz: number | undefined;
370
+ }
371
+
372
+ type SomeType = {
373
+ foo: number;
374
+ bar?: string;
375
+ baz: number | undefined;
376
+ };
377
+
378
+ const literal = {foo: 123, bar: 'hello', baz: 456};
379
+ const someType: SomeType = literal;
380
+ const someInterface: SomeInterface = literal;
381
+
382
+ declare function fn(object: Record<string, unknown>): void;
383
+
384
+ fn(literal); // Good: literal object type is sealed
385
+ fn(someType); // Good: type is sealed
386
+ // @ts-expect-error
387
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
388
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
389
+ ```
390
+
391
+ @link https://github.com/microsoft/TypeScript/issues/15300
392
+ @see {@link SimplifyDeep}
393
+ @category Object
394
+ */
395
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
396
+ //#endregion
397
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-equal.d.ts
398
+ /**
399
+ Returns a boolean for whether the two given types are equal.
400
+
401
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
402
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
403
+
404
+ Use-cases:
405
+ - If you want to make a conditional branch based on the result of a comparison of two types.
406
+
407
+ @example
408
+ ```
409
+ import type {IsEqual} from 'type-fest';
410
+
411
+ // This type returns a boolean for whether the given array includes the given item.
412
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
413
+ type Includes<Value extends readonly any[], Item> =
414
+ Value extends readonly [Value[0], ...infer rest]
415
+ ? IsEqual<Value[0], Item> extends true
416
+ ? true
417
+ : Includes<rest, Item>
418
+ : false;
419
+ ```
420
+
421
+ @category Type Guard
422
+ @category Utilities
423
+ */
424
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
425
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
426
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
427
+ //#endregion
428
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/omit-index-signature.d.ts
429
+ /**
430
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
431
+
432
+ This is the counterpart of `PickIndexSignature`.
433
+
434
+ Use-cases:
435
+ - Remove overly permissive signatures from third-party types.
436
+
437
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
438
+
439
+ 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>`.
440
+
441
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
442
+
443
+ ```
444
+ const indexed: Record<string, unknown> = {}; // Allowed
445
+
446
+ // @ts-expect-error
447
+ const keyed: Record<'foo', unknown> = {}; // Error
448
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
449
+ ```
450
+
451
+ 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:
452
+
453
+ ```
454
+ type Indexed = {} extends Record<string, unknown>
455
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
456
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
457
+
458
+ type IndexedResult = Indexed;
459
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
460
+
461
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
462
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
463
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
464
+
465
+ type KeyedResult = Keyed;
466
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
467
+ ```
468
+
469
+ 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`...
470
+
471
+ ```
472
+ type OmitIndexSignature<ObjectType> = {
473
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
474
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
475
+ };
476
+ ```
477
+
478
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
479
+
480
+ ```
481
+ type OmitIndexSignature<ObjectType> = {
482
+ [KeyType in keyof ObjectType
483
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
484
+ as {} extends Record<KeyType, unknown>
485
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
486
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
487
+ ]: ObjectType[KeyType];
488
+ };
489
+ ```
490
+
491
+ 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.
492
+
493
+ @example
494
+ ```
495
+ import type {OmitIndexSignature} from 'type-fest';
496
+
497
+ type Example = {
498
+ // These index signatures will be removed.
499
+ [x: string]: any;
500
+ [x: number]: any;
501
+ [x: symbol]: any;
502
+ [x: `head-${string}`]: string;
503
+ [x: `${string}-tail`]: string;
504
+ [x: `head-${string}-tail`]: string;
505
+ [x: `${bigint}`]: string;
506
+ [x: `embedded-${number}`]: string;
507
+
508
+ // These explicitly defined keys will remain.
509
+ foo: 'bar';
510
+ qux?: 'baz';
511
+ };
512
+
513
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
514
+ //=> {foo: 'bar'; qux?: 'baz'}
515
+ ```
516
+
517
+ @see {@link PickIndexSignature}
518
+ @category Object
519
+ */
520
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
521
+ //#endregion
522
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/pick-index-signature.d.ts
523
+ /**
524
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
525
+
526
+ This is the counterpart of `OmitIndexSignature`.
527
+
528
+ @example
529
+ ```
530
+ import type {PickIndexSignature} from 'type-fest';
531
+
532
+ declare const symbolKey: unique symbol;
533
+
534
+ type Example = {
535
+ // These index signatures will remain.
536
+ [x: string]: unknown;
537
+ [x: number]: unknown;
538
+ [x: symbol]: unknown;
539
+ [x: `head-${string}`]: string;
540
+ [x: `${string}-tail`]: string;
541
+ [x: `head-${string}-tail`]: string;
542
+ [x: `${bigint}`]: string;
543
+ [x: `embedded-${number}`]: string;
544
+
545
+ // These explicitly defined keys will be removed.
546
+ ['kebab-case-key']: string;
547
+ [symbolKey]: string;
548
+ foo: 'bar';
549
+ qux?: 'baz';
550
+ };
551
+
552
+ type ExampleIndexSignature = PickIndexSignature<Example>;
553
+ // {
554
+ // [x: string]: unknown;
555
+ // [x: number]: unknown;
556
+ // [x: symbol]: unknown;
557
+ // [x: `head-${string}`]: string;
558
+ // [x: `${string}-tail`]: string;
559
+ // [x: `head-${string}-tail`]: string;
560
+ // [x: `${bigint}`]: string;
561
+ // [x: `embedded-${number}`]: string;
562
+ // }
563
+ ```
564
+
565
+ @see {@link OmitIndexSignature}
566
+ @category Object
567
+ */
568
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
569
+ //#endregion
570
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/merge.d.ts
571
+ // Merges two objects without worrying about index signatures.
572
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
573
+ /**
574
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
575
+
576
+ 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`.
577
+
578
+ @example
579
+ ```
580
+ import type {Merge} from 'type-fest';
581
+
582
+ type Foo = {
583
+ a: string;
584
+ b: number;
585
+ };
586
+
587
+ type Bar = {
588
+ a: number; // Conflicts with Foo['a']
589
+ c: boolean;
590
+ };
591
+
592
+ // With `&`, `a` becomes `string & number` which is `never`. Not what you want.
593
+ type WithIntersection = (Foo & Bar)['a'];
594
+ //=> never
595
+
596
+ // With `Merge`, `a` is cleanly overridden to `number`.
597
+ type WithMerge = Merge<Foo, Bar>['a'];
598
+ //=> number
599
+ ```
600
+
601
+ @example
602
+ ```
603
+ import type {Merge} from 'type-fest';
604
+
605
+ type Foo = {
606
+ [x: string]: unknown;
607
+ [x: number]: unknown;
608
+ foo: string;
609
+ bar: symbol;
610
+ };
611
+
612
+ type Bar = {
613
+ [x: number]: number;
614
+ [x: symbol]: unknown;
615
+ bar: Date;
616
+ baz: boolean;
617
+ };
618
+
619
+ export type FooBar = Merge<Foo, Bar>;
620
+ //=> {
621
+ // [x: string]: unknown;
622
+ // [x: number]: number;
623
+ // [x: symbol]: unknown;
624
+ // foo: string;
625
+ // bar: Date;
626
+ // baz: boolean;
627
+ // }
628
+ ```
629
+
630
+ 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.
631
+
632
+ @see {@link ObjectMerge}
633
+ @category Object
634
+ */
635
+ type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
636
+ ? Source extends unknown // For distributing `Source`
637
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
638
+ : never;
639
+ // Should never happen
640
+ type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
641
+ //#endregion
642
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/object.d.ts
643
+ /**
644
+ Merges user specified options with default options.
645
+
646
+ @example
647
+ ```
648
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
649
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
650
+ type SpecifiedOptions = {leavesOnly: true};
651
+
652
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
653
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
654
+ ```
655
+
656
+ @example
657
+ ```
658
+ // Complains if default values are not provided for optional options
659
+
660
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
661
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
662
+ type SpecifiedOptions = {};
663
+
664
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
665
+ // ~~~~~~~~~~~~~~~~~~~
666
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
667
+ ```
668
+
669
+ @example
670
+ ```
671
+ // Complains if an option's default type does not conform to the expected type
672
+
673
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
674
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
675
+ type SpecifiedOptions = {};
676
+
677
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
678
+ // ~~~~~~~~~~~~~~~~~~~
679
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
680
+ ```
681
+
682
+ @example
683
+ ```
684
+ // Complains if an option's specified type does not conform to the expected type
685
+
686
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
687
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
688
+ type SpecifiedOptions = {leavesOnly: 'yes'};
689
+
690
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
691
+ // ~~~~~~~~~~~~~~~~
692
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
693
+ ```
694
+ */
695
+ 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>`
696
+ ? Result : never;
697
+ 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] }>>>;
698
+ /**
699
+ Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
700
+
701
+ 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>`.
702
+
703
+ Use-case: For collapsing unions created using {@link LiteralUnion}.
704
+
705
+ @example
706
+ ```
707
+ import type {LiteralUnion} from 'type-fest';
708
+
709
+ type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
710
+ //=> string
711
+
712
+ type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
713
+ //=> number
714
+
715
+ type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
716
+ //=> `on${string}`
717
+
718
+ type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
719
+ //=> 'click' | 'change' | `on${string}`
720
+
721
+ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
722
+ //=> string | null | undefined
723
+ ```
724
+ */
725
+ //#endregion
726
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/partial-deep.d.ts
727
+ /**
728
+ @see {@link PartialDeep}
729
+ */
730
+ type PartialDeepOptions = {
731
+ /**
732
+ Whether to affect the individual elements of arrays and tuples.
733
+ @default false
734
+ */
735
+ readonly recurseIntoArrays?: boolean;
736
+ /**
737
+ Allows `undefined` values in non-tuple arrays.
738
+ - When set to `true`, elements of non-tuple arrays can be `undefined`.
739
+ - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
740
+ @default false
741
+ @example
742
+ You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
743
+ ```
744
+ import type {PartialDeep} from 'type-fest';
745
+ type Settings = {
746
+ languages: string[];
747
+ };
748
+ declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
749
+ partialSettings.languages = [undefined]; // OK
750
+ ```
751
+ */
752
+ readonly allowUndefinedInNonTupleArrays?: boolean;
753
+ };
754
+ type DefaultPartialDeepOptions = {
755
+ recurseIntoArrays: false;
756
+ allowUndefinedInNonTupleArrays: false;
757
+ };
758
+ /**
759
+ Create a deeply optional version of another type.
760
+
761
+ Use-cases:
762
+ - Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
763
+ - Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
764
+
765
+ Use [`Partial<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) if you only need one level deep.
766
+
767
+ @example
768
+ ```
769
+ import type {PartialDeep} from 'type-fest';
770
+
771
+ let settings = {
772
+ textEditor: {
773
+ fontSize: 14,
774
+ fontColor: '#000000',
775
+ fontWeight: 400,
776
+ },
777
+ autocomplete: false,
778
+ autosave: true,
779
+ };
780
+
781
+ const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
782
+ {...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
783
+ );
784
+
785
+ settings = applySavedSettings({textEditor: {fontWeight: 500}});
786
+ ```
787
+
788
+ By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
789
+
790
+ ```
791
+ import type {PartialDeep} from 'type-fest';
792
+
793
+ type Shape = {
794
+ dimensions: [number, number];
795
+ };
796
+
797
+ const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
798
+ dimensions: [], // OK
799
+ };
800
+
801
+ partialShape.dimensions = [15]; // OK
802
+ ```
803
+
804
+ @see {@link PartialDeepOptions}
805
+
806
+ @category Object
807
+ @category Array
808
+ @category Set
809
+ @category Map
810
+ */
811
+ type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
812
+ type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends ((...arguments_: any[]) => unknown) ? IsNever<keyof T> extends true ? T // For functions with no properties
813
+ : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep<T, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
814
+ ? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
815
+ ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
816
+ ? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : PartialObjectDeep<T, Options> // Tuples behave properly
817
+ : T // If they don't opt into array testing, just use the original type
818
+ : PartialObjectDeep<T, Options> : unknown;
819
+ /**
820
+ Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
821
+ */
822
+ type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
823
+ /**
824
+ Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
825
+ */
826
+ type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
827
+ /**
828
+ Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
829
+ */
830
+ type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
831
+ /**
832
+ Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
833
+ */
834
+ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
835
+ /**
836
+ Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
837
+ */
838
+ type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = { [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> };
839
+ //#endregion
840
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/required-deep.d.ts
841
+ /**
842
+ Create a deeply required version of another type.
843
+
844
+ Use-cases:
845
+ - Creating optional configuration interfaces where the underlying implementation still requires all options to be fully specified.
846
+ - Modeling the resulting type after a deep merge with a set of defaults.
847
+
848
+ Use [`Required<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#requiredtype) if you only need one level deep.
849
+
850
+ @example
851
+ ```
852
+ import type {RequiredDeep} from 'type-fest';
853
+
854
+ type Settings = {
855
+ textEditor?: {
856
+ fontSize?: number;
857
+ fontColor?: string;
858
+ fontWeight?: number | undefined;
859
+ };
860
+ autocomplete?: boolean;
861
+ autosave?: boolean | undefined;
862
+ };
863
+
864
+ type RequiredSettings = RequiredDeep<Settings>;
865
+ //=> {
866
+ // textEditor: {
867
+ // fontSize: number;
868
+ // fontColor: string;
869
+ // fontWeight: number | undefined;
870
+ // };
871
+ // autocomplete: boolean;
872
+ // autosave: boolean | undefined;
873
+ // }
874
+ ```
875
+
876
+ Note that types containing overloaded functions are not made deeply required due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
877
+
878
+ @category Utilities
879
+ @category Object
880
+ @category Array
881
+ @category Set
882
+ @category Map
883
+ */
884
+ type RequiredDeep<T> = T extends BuiltIns ? T : T extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : T extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : T extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : T extends ((...arguments_: any[]) => unknown) ? IsNever<keyof T> extends true ? T : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & RequiredObjectDeep<T> : T extends object ? Simplify<RequiredObjectDeep<T>> // `Simplify` to prevent `RequiredObjectDeep` from appearing in the resulting type
885
+ : unknown;
886
+ type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
887
+ //#endregion
888
+ //#region src/resources/proxies/delay.d.ts
889
+ type DelayItem = {
890
+ url: string;
891
+ timeout?: number;
892
+ headers?: Record<string, string>;
893
+ "follow-redirect"?: boolean;
894
+ expected?: string;
895
+ rounds?: number;
896
+ unified?: boolean;
897
+ };
898
+ type DelayRequest = Omit<DelayItem, "url"> & {
899
+ urls?: DelayItem[];
900
+ concurrency?: number;
901
+ };
902
+ type DelayResult = {
903
+ version: number;
904
+ digest: string;
905
+ "delay-min": number;
906
+ "delay-max": number;
907
+ "delay-avg": number;
908
+ "delay-cost": number;
909
+ success: number;
910
+ failed: number;
911
+ total: number;
912
+ error?: string;
913
+ };
914
+ type DelaysResult = {
915
+ version: number;
916
+ results: Omit<DelayResult, "version">[];
917
+ };
918
+ //#endregion
919
+ //#region src/resources/proxies/download.d.ts
920
+ type DownloadItem = {
921
+ url: string;
922
+ timeout?: number;
923
+ headers?: Record<string, string>;
924
+ "follow-redirect"?: boolean;
925
+ rounds?: number;
926
+ "max-bytes"?: number;
927
+ };
928
+ type DownloadRequest = Omit<DownloadItem, "url"> & {
929
+ urls?: DownloadItem[];
930
+ concurrency?: number;
931
+ };
932
+ type DownloadResult = {
933
+ digest: string;
934
+ "speed-min": number;
935
+ "speed-max": number;
936
+ "speed-avg": number;
937
+ "speed-score": number;
938
+ success: number;
939
+ failed: number;
940
+ total: number;
941
+ error?: string;
942
+ };
943
+ type DownloadsResult = {
944
+ version: number;
945
+ results: Omit<DownloadResult, "version">[];
946
+ };
947
+ //#endregion
948
+ //#region src/resources/config.d.ts
949
+ type ProxyServer = {
950
+ expand?: boolean;
951
+ nameservers?: string[];
952
+ timeout?: number;
953
+ };
954
+ type RuntimeConfig = {
955
+ "default-timeout": number;
956
+ "skip-cert-verify": boolean;
957
+ "proxy-server": RequiredDeep<ProxyServer>;
958
+ delay: RequiredDeep<DelayRequest>;
959
+ download: RequiredDeep<DownloadRequest>;
960
+ };
961
+ //#endregion
962
+ //#region src/resources/proxies/index.d.ts
963
+ type ProxyInfo = {
964
+ type: string;
965
+ name: string;
966
+ server: string;
967
+ port: number;
968
+ digest: string;
969
+ };
970
+ type ProxyListResult = {
971
+ version: number;
972
+ proxies: ProxyInfo[];
973
+ };
974
+ type ProxyImportRequest = {
975
+ type: "text" | "local" | "remote";
976
+ payload: string;
977
+ mode?: "replace" | "append";
978
+ headers?: Record<string, string>;
979
+ timeout?: number;
980
+ "follow-redirect"?: boolean;
981
+ "proxy-server"?: ProxyServer;
982
+ };
983
+ type ProxyImportResult = ProxyListResult & {
984
+ warnings?: Record<string, unknown>[];
985
+ };
986
+ type ProxyExportResult = {
987
+ proxies: Record<string, unknown>[];
988
+ };
989
+ type ProxyRequest = {
990
+ url: string;
991
+ method?: "GET" | "DELETE" | "HEAD" | "OPTIONS" | "POST" | "PUT" | "PATCH";
992
+ headers?: Record<string, string>;
993
+ timeout?: number;
994
+ "follow-redirect"?: boolean;
995
+ body?: string;
996
+ };
997
+ //#endregion
998
+ //#region src/http.d.ts
999
+ interface HttpOptions {
1000
+ baseURL?: string;
1001
+ timeout?: number;
1002
+ }
1003
+ //#endregion
1004
+ //#region src/client.d.ts
1005
+ declare const createApiClient: (options: HttpOptions) => {
1006
+ version: {
1007
+ get: () => Promise<import("axios").AxiosResponse<VersionInfo, any, {}>>;
1008
+ };
1009
+ digest: {
1010
+ create: (request: DigestRequest) => Promise<import("axios").AxiosResponse<DigestResponse, any, {}>>;
1011
+ };
1012
+ config: {
1013
+ get: () => Promise<import("axios").AxiosResponse<RuntimeConfig, any, {}>>;
1014
+ update: (config: PartialDeep<RuntimeConfig>) => Promise<import("axios").AxiosResponse<RuntimeConfig, any, {}>>;
1015
+ };
1016
+ proxies: {
1017
+ list: () => Promise<import("axios").AxiosResponse<ProxyListResult, any, {}>>;
1018
+ import: (request: ProxyImportRequest) => Promise<import("axios").AxiosResponse<ProxyImportResult, any, {}>>;
1019
+ export: () => Promise<import("axios").AxiosResponse<ProxyExportResult, any, {}>>;
1020
+ delay: (digest: string, request?: DelayRequest) => Promise<import("axios").AxiosResponse<DelayResult, any, {}>>;
1021
+ download: (digest: string, request?: DownloadRequest) => Promise<import("axios").AxiosResponse<DownloadResult, any, {}>>;
1022
+ delays: (request?: DelayRequest) => Promise<import("axios").AxiosResponse<DelaysResult, any, {}>>;
1023
+ downloads: (request?: DownloadRequest) => Promise<import("axios").AxiosResponse<DownloadsResult, any, {}>>;
1024
+ proxy: (digest: string, request: ProxyRequest) => Promise<import("axios").AxiosResponse<any, any, {}>>;
1025
+ };
1026
+ };
1027
+ //#endregion
1028
+ export { createApiClient };
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ import axios from "axios";
2
+ //#region src/http.ts
3
+ const createHttp = (options) => {
4
+ return axios.create({ baseURL: options.baseURL || "http://127.0.0.1:32198" });
5
+ };
6
+ //#endregion
7
+ //#region src/resources/config.ts
8
+ const createConfigApi = (instance) => {
9
+ return {
10
+ get: () => {
11
+ return instance.get("/config");
12
+ },
13
+ update: (config) => {
14
+ return instance.patch("/config", config);
15
+ }
16
+ };
17
+ };
18
+ //#endregion
19
+ //#region src/resources/version.ts
20
+ const createVersionApi = (instance) => {
21
+ return { get: () => {
22
+ return instance.get("/version");
23
+ } };
24
+ };
25
+ //#endregion
26
+ //#region src/resources/digest.ts
27
+ const createDigestApi = (instance) => {
28
+ return { create: (request) => {
29
+ return instance.post("/digest", request);
30
+ } };
31
+ };
32
+ //#endregion
33
+ //#region src/resources/proxies/index.ts
34
+ const createProxiesApi = (instance) => {
35
+ return {
36
+ list: () => {
37
+ return instance.get("/proxies");
38
+ },
39
+ import: (request) => {
40
+ return instance.post("/proxies/import", request);
41
+ },
42
+ export: () => {
43
+ return instance.get("/proxies/export");
44
+ },
45
+ delay: (digest, request) => {
46
+ const path = `/proxies/${digest}/delay`;
47
+ return instance.post(path, request);
48
+ },
49
+ download: (digest, request) => {
50
+ const path = `/proxies/${digest}/download`;
51
+ return instance.post(path, request);
52
+ },
53
+ delays: (request) => {
54
+ return instance.post("/proxies/delay", request);
55
+ },
56
+ downloads: (request) => {
57
+ return instance.post("/proxies/download", request);
58
+ },
59
+ proxy: (digest, request) => {
60
+ const path = `/proxies/${digest}/proxy`;
61
+ return instance.post(path, request);
62
+ }
63
+ };
64
+ };
65
+ //#endregion
66
+ //#region src/client.ts
67
+ const createApiClient = (options) => {
68
+ const http = createHttp(options);
69
+ return {
70
+ version: createVersionApi(http),
71
+ digest: createDigestApi(http),
72
+ config: createConfigApi(http),
73
+ proxies: createProxiesApi(http)
74
+ };
75
+ };
76
+ //#endregion
77
+ export { createApiClient };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@publinx/mihomo-st-api",
3
+ "version": "1.1.1",
4
+ "description": "A TypeScript API Library for mihomo-st",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/publinx/mihomo-st.git"
10
+ },
11
+ "homepage": "https://github.com/publinx/mihomo-st/tree/main/packages/api",
12
+ "scripts": {
13
+ "dev": "rolldown -c --watch",
14
+ "build": "rolldown -c"
15
+ },
16
+ "exports": {
17
+ ".": "./dist/index.js"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "dependencies": {
23
+ "axios": "^1.18.1"
24
+ },
25
+ "devDependencies": {
26
+ "rolldown": "^1.1.3",
27
+ "rolldown-plugin-dts": "^0.26.0",
28
+ "type-fest": "^5.7.0",
29
+ "typescript": "^6.0.3"
30
+ }
31
+ }