@regle/core 1.10.1 → 1.11.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/regle-core.d.ts +14 -1335
- package/dist/regle-core.js +741 -176
- package/dist/regle-core.min.js +1 -1
- package/package.json +10 -12
package/dist/regle-core.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as vue0 from "vue";
|
|
2
|
-
import { MaybeRef, MaybeRefOrGetter, Raw, Ref, UnwrapNestedRefs, UnwrapRef } from "vue";
|
|
2
|
+
import { MaybeRef, MaybeRefOrGetter, Plugin, Raw, Ref, UnwrapNestedRefs, UnwrapRef } from "vue";
|
|
3
|
+
import { EmptyObject, IsAny, IsEmptyObject, IsUnion, IsUnknown, Merge, Or, PartialDeep, RequireOneOrNone, RequiredDeep, UnionToIntersection, UnionToTuple } from "type-fest";
|
|
3
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
-
|
|
5
|
-
//#region src/types/utils/misc.types.d.ts
|
|
6
5
|
type Prettify<T> = T extends infer R ? { [K in keyof R]: R[K] } & {} : never;
|
|
7
6
|
type Maybe<T = any> = T | null | undefined;
|
|
8
7
|
type MaybeInput<T = any> = T | null | undefined;
|
|
@@ -21,1232 +20,8 @@ type ExcludeByType<T, U$1> = { [K in keyof T as T[K] extends U$1 ? never : K]: T
|
|
|
21
20
|
type PrimitiveTypes = string | number | boolean | bigint | Date | File;
|
|
22
21
|
type isRecordLiteral<T extends unknown> = NonNullable<T> extends Date | File ? false : NonNullable<T> extends Record<string, any> ? true : false;
|
|
23
22
|
type NoInferLegacy<A$1 extends any> = [A$1][A$1 extends any ? 0 : never];
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/types/utils/Array.types.d.ts
|
|
26
23
|
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
27
24
|
type NonEmptyTuple<T> = [T, ...T[]] | T[];
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/primitive.d.ts
|
|
30
|
-
/**
|
|
31
|
-
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
32
|
-
|
|
33
|
-
@category Type
|
|
34
|
-
*/
|
|
35
|
-
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
38
|
-
/**
|
|
39
|
-
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
40
|
-
|
|
41
|
-
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
42
|
-
|
|
43
|
-
@example
|
|
44
|
-
```
|
|
45
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
46
|
-
|
|
47
|
-
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
48
|
-
|
|
49
|
-
type Intersection = UnionToIntersection<Union>;
|
|
50
|
-
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
A more applicable example which could make its way into your library code follows.
|
|
54
|
-
|
|
55
|
-
@example
|
|
56
|
-
```
|
|
57
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
58
|
-
|
|
59
|
-
class CommandOne {
|
|
60
|
-
commands: {
|
|
61
|
-
a1: () => undefined,
|
|
62
|
-
b1: () => undefined,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
class CommandTwo {
|
|
67
|
-
commands: {
|
|
68
|
-
a2: (argA: string) => undefined,
|
|
69
|
-
b2: (argB: string) => undefined,
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
74
|
-
type Union = typeof union;
|
|
75
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
76
|
-
|
|
77
|
-
type Intersection = UnionToIntersection<Union>;
|
|
78
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
@category Type
|
|
82
|
-
*/
|
|
83
|
-
type UnionToIntersection<Union> = (
|
|
84
|
-
// `extends unknown` is always going to be the case and is used to convert the
|
|
85
|
-
// `Union` into a [distributive conditional
|
|
86
|
-
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
87
|
-
Union extends unknown
|
|
88
|
-
// The union type is used as the only argument to a function since the union
|
|
89
|
-
// of function arguments is an intersection.
|
|
90
|
-
? (distributedUnion: Union) => void
|
|
91
|
-
// This won't happen.
|
|
92
|
-
: never
|
|
93
|
-
// Infer the `Intersection` type since TypeScript represents the positional
|
|
94
|
-
// arguments of unions of functions as an intersection of the union.
|
|
95
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
96
|
-
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
97
|
-
? Intersection & Union : never;
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/empty-object.d.ts
|
|
100
|
-
declare const emptyObjectSymbol: unique symbol;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
Represents a strictly empty plain object, the `{}` value.
|
|
104
|
-
|
|
105
|
-
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
|
|
106
|
-
|
|
107
|
-
@example
|
|
108
|
-
```
|
|
109
|
-
import type {EmptyObject} from 'type-fest';
|
|
110
|
-
|
|
111
|
-
// The following illustrates the problem with `{}`.
|
|
112
|
-
const foo1: {} = {}; // Pass
|
|
113
|
-
const foo2: {} = []; // Pass
|
|
114
|
-
const foo3: {} = 42; // Pass
|
|
115
|
-
const foo4: {} = {a: 1}; // Pass
|
|
116
|
-
|
|
117
|
-
// With `EmptyObject` only the first case is valid.
|
|
118
|
-
const bar1: EmptyObject = {}; // Pass
|
|
119
|
-
const bar2: EmptyObject = 42; // Fail
|
|
120
|
-
const bar3: EmptyObject = []; // Fail
|
|
121
|
-
const bar4: EmptyObject = {a: 1}; // Fail
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
|
|
125
|
-
|
|
126
|
-
@category Object
|
|
127
|
-
*/
|
|
128
|
-
type EmptyObject = {
|
|
129
|
-
[emptyObjectSymbol]?: never;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
Returns a `boolean` for whether the type is strictly equal to an empty plain object, the `{}` value.
|
|
133
|
-
|
|
134
|
-
@example
|
|
135
|
-
```
|
|
136
|
-
import type {IsEmptyObject} from 'type-fest';
|
|
137
|
-
|
|
138
|
-
type Pass = IsEmptyObject<{}>; //=> true
|
|
139
|
-
type Fail = IsEmptyObject<[]>; //=> false
|
|
140
|
-
type Fail = IsEmptyObject<null>; //=> false
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
@see {@link EmptyObject}
|
|
144
|
-
@category Object
|
|
145
|
-
*/
|
|
146
|
-
type IsEmptyObject<T> = T extends EmptyObject ? true : false;
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/is-any.d.ts
|
|
149
|
-
/**
|
|
150
|
-
Returns a boolean for whether the given type is `any`.
|
|
151
|
-
|
|
152
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
153
|
-
|
|
154
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
155
|
-
|
|
156
|
-
@example
|
|
157
|
-
```
|
|
158
|
-
import type {IsAny} from 'type-fest';
|
|
159
|
-
|
|
160
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
161
|
-
const anyObject: any = {a: 1, b: 2};
|
|
162
|
-
|
|
163
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
164
|
-
return obj[key];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const typedA = get(typedObject, 'a');
|
|
168
|
-
//=> 1
|
|
169
|
-
|
|
170
|
-
const anyA = get(anyObject, 'a');
|
|
171
|
-
//=> any
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
@category Type Guard
|
|
175
|
-
@category Utilities
|
|
176
|
-
*/
|
|
177
|
-
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
180
|
-
/**
|
|
181
|
-
Returns a boolean for whether the given key is an optional key of type.
|
|
182
|
-
|
|
183
|
-
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
184
|
-
|
|
185
|
-
@example
|
|
186
|
-
```
|
|
187
|
-
import type {IsOptionalKeyOf} from 'type-fest';
|
|
188
|
-
|
|
189
|
-
interface User {
|
|
190
|
-
name: string;
|
|
191
|
-
surname: string;
|
|
192
|
-
|
|
193
|
-
luckyNumber?: number;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
interface Admin {
|
|
197
|
-
name: string;
|
|
198
|
-
surname?: string;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
202
|
-
//=> true
|
|
203
|
-
|
|
204
|
-
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
205
|
-
//=> false
|
|
206
|
-
|
|
207
|
-
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
208
|
-
//=> boolean
|
|
209
|
-
|
|
210
|
-
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
211
|
-
//=> false
|
|
212
|
-
|
|
213
|
-
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
214
|
-
//=> boolean
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
@category Type Guard
|
|
218
|
-
@category Utilities
|
|
219
|
-
*/
|
|
220
|
-
type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
223
|
-
/**
|
|
224
|
-
Extract all optional keys from the given type.
|
|
225
|
-
|
|
226
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
227
|
-
|
|
228
|
-
@example
|
|
229
|
-
```
|
|
230
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
231
|
-
|
|
232
|
-
interface User {
|
|
233
|
-
name: string;
|
|
234
|
-
surname: string;
|
|
235
|
-
|
|
236
|
-
luckyNumber?: number;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
240
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
241
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
const update1: UpdateOperation<User> = {
|
|
245
|
-
name: 'Alice'
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const update2: UpdateOperation<User> = {
|
|
249
|
-
name: 'Bob',
|
|
250
|
-
luckyNumber: REMOVE_FIELD
|
|
251
|
-
};
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
@category Utilities
|
|
255
|
-
*/
|
|
256
|
-
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
257
|
-
? (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`
|
|
258
|
-
: never;
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
261
|
-
/**
|
|
262
|
-
Extract all required keys from the given type.
|
|
263
|
-
|
|
264
|
-
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...
|
|
265
|
-
|
|
266
|
-
@example
|
|
267
|
-
```
|
|
268
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
269
|
-
|
|
270
|
-
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
271
|
-
|
|
272
|
-
interface User {
|
|
273
|
-
name: string;
|
|
274
|
-
surname: string;
|
|
275
|
-
|
|
276
|
-
luckyNumber?: number;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
280
|
-
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
@category Utilities
|
|
284
|
-
*/
|
|
285
|
-
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
286
|
-
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/is-never.d.ts
|
|
289
|
-
/**
|
|
290
|
-
Returns a boolean for whether the given type is `never`.
|
|
291
|
-
|
|
292
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
293
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
294
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
295
|
-
|
|
296
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
297
|
-
|
|
298
|
-
@example
|
|
299
|
-
```
|
|
300
|
-
import type {IsNever, And} from 'type-fest';
|
|
301
|
-
|
|
302
|
-
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
303
|
-
type AreStringsEqual<A extends string, B extends string> =
|
|
304
|
-
And<
|
|
305
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
306
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
307
|
-
>;
|
|
308
|
-
|
|
309
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
310
|
-
AreStringsEqual<I, O> extends true
|
|
311
|
-
? never
|
|
312
|
-
: void;
|
|
313
|
-
|
|
314
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
315
|
-
if (input === output) {
|
|
316
|
-
process.exit(0);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
endIfEqual('abc', 'abc');
|
|
321
|
-
//=> never
|
|
322
|
-
|
|
323
|
-
endIfEqual('abc', '123');
|
|
324
|
-
//=> void
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
@category Type Guard
|
|
328
|
-
@category Utilities
|
|
329
|
-
*/
|
|
330
|
-
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/if.d.ts
|
|
333
|
-
/**
|
|
334
|
-
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
335
|
-
|
|
336
|
-
Use-cases:
|
|
337
|
-
- 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'>`.
|
|
338
|
-
|
|
339
|
-
Note:
|
|
340
|
-
- 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'`.
|
|
341
|
-
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
342
|
-
|
|
343
|
-
@example
|
|
344
|
-
```
|
|
345
|
-
import {If} from 'type-fest';
|
|
346
|
-
|
|
347
|
-
type A = If<true, 'yes', 'no'>;
|
|
348
|
-
//=> 'yes'
|
|
349
|
-
|
|
350
|
-
type B = If<false, 'yes', 'no'>;
|
|
351
|
-
//=> 'no'
|
|
352
|
-
|
|
353
|
-
type C = If<boolean, 'yes', 'no'>;
|
|
354
|
-
//=> 'yes' | 'no'
|
|
355
|
-
|
|
356
|
-
type D = If<any, 'yes', 'no'>;
|
|
357
|
-
//=> 'yes' | 'no'
|
|
358
|
-
|
|
359
|
-
type E = If<never, 'yes', 'no'>;
|
|
360
|
-
//=> 'no'
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
@example
|
|
364
|
-
```
|
|
365
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
366
|
-
|
|
367
|
-
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
368
|
-
//=> 'not any'
|
|
369
|
-
|
|
370
|
-
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
371
|
-
//=> 'is never'
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
@example
|
|
375
|
-
```
|
|
376
|
-
import {If, IsEqual} from 'type-fest';
|
|
377
|
-
|
|
378
|
-
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
379
|
-
|
|
380
|
-
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
381
|
-
//=> 'equal'
|
|
382
|
-
|
|
383
|
-
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
384
|
-
//=> 'not equal'
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
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:
|
|
388
|
-
|
|
389
|
-
@example
|
|
390
|
-
```
|
|
391
|
-
import type {If, IsEqual, StringRepeat} from 'type-fest';
|
|
392
|
-
|
|
393
|
-
type HundredZeroes = StringRepeat<'0', 100>;
|
|
394
|
-
|
|
395
|
-
// The following implementation is not tail recursive
|
|
396
|
-
type Includes<S extends string, Char extends string> =
|
|
397
|
-
S extends `${infer First}${infer Rest}`
|
|
398
|
-
? If<IsEqual<First, Char>,
|
|
399
|
-
'found',
|
|
400
|
-
Includes<Rest, Char>>
|
|
401
|
-
: 'not found';
|
|
402
|
-
|
|
403
|
-
// Hence, instantiations with long strings will fail
|
|
404
|
-
// @ts-expect-error
|
|
405
|
-
type Fails = Includes<HundredZeroes, '1'>;
|
|
406
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
407
|
-
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
408
|
-
|
|
409
|
-
// However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
|
|
410
|
-
type IncludesWithoutIf<S extends string, Char extends string> =
|
|
411
|
-
S extends `${infer First}${infer Rest}`
|
|
412
|
-
? IsEqual<First, Char> extends true
|
|
413
|
-
? 'found'
|
|
414
|
-
: IncludesWithoutIf<Rest, Char>
|
|
415
|
-
: 'not found';
|
|
416
|
-
|
|
417
|
-
// Now, instantiations with long strings will work
|
|
418
|
-
type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
419
|
-
//=> 'not found'
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
@category Type Guard
|
|
423
|
-
@category Utilities
|
|
424
|
-
*/
|
|
425
|
-
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever$1<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/internal/type.d.ts
|
|
428
|
-
/**
|
|
429
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
430
|
-
*/
|
|
431
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
432
|
-
/**
|
|
433
|
-
Test if the given function has multiple call signatures.
|
|
434
|
-
|
|
435
|
-
Needed to handle the case of a single call signature with properties.
|
|
436
|
-
|
|
437
|
-
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
438
|
-
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
439
|
-
*/
|
|
440
|
-
type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
441
|
-
(...arguments_: infer A): unknown;
|
|
442
|
-
(...arguments_: infer B): unknown;
|
|
443
|
-
} ? B extends A ? A extends B ? false : true : true : false;
|
|
444
|
-
/**
|
|
445
|
-
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
446
|
-
|
|
447
|
-
@example
|
|
448
|
-
```
|
|
449
|
-
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
450
|
-
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
451
|
-
//=> 'VALID'
|
|
452
|
-
|
|
453
|
-
// When `T` is `any` => Returns `IfAny` branch
|
|
454
|
-
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
455
|
-
//=> 'IS_ANY'
|
|
456
|
-
|
|
457
|
-
// When `T` is `never` => Returns `IfNever` branch
|
|
458
|
-
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
459
|
-
//=> 'IS_NEVER'
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
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:
|
|
463
|
-
|
|
464
|
-
@example
|
|
465
|
-
```ts
|
|
466
|
-
import type {StringRepeat} from 'type-fest';
|
|
467
|
-
|
|
468
|
-
type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
|
|
469
|
-
|
|
470
|
-
// The following implementation is not tail recursive
|
|
471
|
-
type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
|
|
472
|
-
|
|
473
|
-
// Hence, instantiations with long strings will fail
|
|
474
|
-
// @ts-expect-error
|
|
475
|
-
type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
|
|
476
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
477
|
-
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
478
|
-
|
|
479
|
-
// To fix this, move the recursion into a helper type
|
|
480
|
-
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
|
|
481
|
-
|
|
482
|
-
type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
|
|
483
|
-
|
|
484
|
-
type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
|
|
485
|
-
//=> ''
|
|
486
|
-
```
|
|
487
|
-
*/
|
|
488
|
-
type IfNotAnyOrNever<T, IfNotAnyOrNever$1, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever$1<T>, IfNever, IfNotAnyOrNever$1>>;
|
|
489
|
-
//#endregion
|
|
490
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/is-null.d.ts
|
|
491
|
-
/**
|
|
492
|
-
Returns a boolean for whether the given type is `null`.
|
|
493
|
-
|
|
494
|
-
@example
|
|
495
|
-
```
|
|
496
|
-
import type {IsNull} from 'type-fest';
|
|
497
|
-
|
|
498
|
-
type NonNullFallback<T, Fallback> = IsNull<T> extends true ? Fallback : T;
|
|
499
|
-
|
|
500
|
-
type Example1 = NonNullFallback<null, string>;
|
|
501
|
-
//=> string
|
|
502
|
-
|
|
503
|
-
type Example2 = NonNullFallback<number, string>;
|
|
504
|
-
//=? number
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
@category Type Guard
|
|
508
|
-
@category Utilities
|
|
509
|
-
*/
|
|
510
|
-
type IsNull<T> = [T] extends [null] ? true : false;
|
|
511
|
-
//#endregion
|
|
512
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/is-unknown.d.ts
|
|
513
|
-
/**
|
|
514
|
-
Returns a boolean for whether the given type is `unknown`.
|
|
515
|
-
|
|
516
|
-
@link https://github.com/dsherret/conditional-type-checks/pull/16
|
|
517
|
-
|
|
518
|
-
Useful in type utilities, such as when dealing with unknown data from API calls.
|
|
519
|
-
|
|
520
|
-
@example
|
|
521
|
-
```
|
|
522
|
-
import type {IsUnknown} from 'type-fest';
|
|
523
|
-
|
|
524
|
-
// https://github.com/pajecawav/tiny-global-store/blob/master/src/index.ts
|
|
525
|
-
type Action<TState, TPayload = void> =
|
|
526
|
-
IsUnknown<TPayload> extends true
|
|
527
|
-
? (state: TState) => TState,
|
|
528
|
-
: (state: TState, payload: TPayload) => TState;
|
|
529
|
-
|
|
530
|
-
class Store<TState> {
|
|
531
|
-
constructor(private state: TState) {}
|
|
532
|
-
|
|
533
|
-
execute<TPayload = void>(action: Action<TState, TPayload>, payload?: TPayload): TState {
|
|
534
|
-
this.state = action(this.state, payload);
|
|
535
|
-
return this.state;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// ... other methods
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
const store = new Store({value: 1});
|
|
542
|
-
declare const someExternalData: unknown;
|
|
543
|
-
|
|
544
|
-
store.execute(state => ({value: state.value + 1}));
|
|
545
|
-
//=> `TPayload` is `void`
|
|
546
|
-
|
|
547
|
-
store.execute((state, payload) => ({value: state.value + payload}), 5);
|
|
548
|
-
//=> `TPayload` is `5`
|
|
549
|
-
|
|
550
|
-
store.execute((state, payload) => ({value: state.value + payload}), someExternalData);
|
|
551
|
-
//=> Errors: `action` is `(state: TState) => TState`
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
@category Utilities
|
|
555
|
-
*/
|
|
556
|
-
type IsUnknown<T> = (unknown extends T // `T` can be `unknown` or `any`
|
|
557
|
-
? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
|
|
558
|
-
? true : false : false);
|
|
559
|
-
//#endregion
|
|
560
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/internal/keys.d.ts
|
|
561
|
-
/**
|
|
562
|
-
Disallows any of the given keys.
|
|
563
|
-
*/
|
|
564
|
-
type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
|
|
565
|
-
//#endregion
|
|
566
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/simplify.d.ts
|
|
567
|
-
/**
|
|
568
|
-
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.
|
|
569
|
-
|
|
570
|
-
@example
|
|
571
|
-
```
|
|
572
|
-
import type {Simplify} from 'type-fest';
|
|
573
|
-
|
|
574
|
-
type PositionProps = {
|
|
575
|
-
top: number;
|
|
576
|
-
left: number;
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
type SizeProps = {
|
|
580
|
-
width: number;
|
|
581
|
-
height: number;
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
585
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
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.
|
|
589
|
-
|
|
590
|
-
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`.
|
|
591
|
-
|
|
592
|
-
@example
|
|
593
|
-
```
|
|
594
|
-
import type {Simplify} from 'type-fest';
|
|
595
|
-
|
|
596
|
-
interface SomeInterface {
|
|
597
|
-
foo: number;
|
|
598
|
-
bar?: string;
|
|
599
|
-
baz: number | undefined;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
type SomeType = {
|
|
603
|
-
foo: number;
|
|
604
|
-
bar?: string;
|
|
605
|
-
baz: number | undefined;
|
|
606
|
-
};
|
|
607
|
-
|
|
608
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
609
|
-
const someType: SomeType = literal;
|
|
610
|
-
const someInterface: SomeInterface = literal;
|
|
611
|
-
|
|
612
|
-
function fn(object: Record<string, unknown>): void {}
|
|
613
|
-
|
|
614
|
-
fn(literal); // Good: literal object type is sealed
|
|
615
|
-
fn(someType); // Good: type is sealed
|
|
616
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
617
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
621
|
-
@see {@link SimplifyDeep}
|
|
622
|
-
@category Object
|
|
623
|
-
*/
|
|
624
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
625
|
-
//#endregion
|
|
626
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
627
|
-
/**
|
|
628
|
-
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
629
|
-
|
|
630
|
-
This is the counterpart of `PickIndexSignature`.
|
|
631
|
-
|
|
632
|
-
Use-cases:
|
|
633
|
-
- Remove overly permissive signatures from third-party types.
|
|
634
|
-
|
|
635
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
636
|
-
|
|
637
|
-
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>`.
|
|
638
|
-
|
|
639
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
640
|
-
|
|
641
|
-
```
|
|
642
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
643
|
-
|
|
644
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
645
|
-
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
646
|
-
```
|
|
647
|
-
|
|
648
|
-
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:
|
|
649
|
-
|
|
650
|
-
```
|
|
651
|
-
type Indexed = {} extends Record<string, unknown>
|
|
652
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
653
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
654
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
655
|
-
|
|
656
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
657
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
658
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
659
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
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`...
|
|
663
|
-
|
|
664
|
-
```
|
|
665
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
666
|
-
|
|
667
|
-
type OmitIndexSignature<ObjectType> = {
|
|
668
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
669
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
670
|
-
};
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
674
|
-
|
|
675
|
-
```
|
|
676
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
677
|
-
|
|
678
|
-
type OmitIndexSignature<ObjectType> = {
|
|
679
|
-
[KeyType in keyof ObjectType
|
|
680
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
681
|
-
as {} extends Record<KeyType, unknown>
|
|
682
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
683
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
684
|
-
]: ObjectType[KeyType];
|
|
685
|
-
};
|
|
686
|
-
```
|
|
687
|
-
|
|
688
|
-
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.
|
|
689
|
-
|
|
690
|
-
@example
|
|
691
|
-
```
|
|
692
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
693
|
-
|
|
694
|
-
interface Example {
|
|
695
|
-
// These index signatures will be removed.
|
|
696
|
-
[x: string]: any
|
|
697
|
-
[x: number]: any
|
|
698
|
-
[x: symbol]: any
|
|
699
|
-
[x: `head-${string}`]: string
|
|
700
|
-
[x: `${string}-tail`]: string
|
|
701
|
-
[x: `head-${string}-tail`]: string
|
|
702
|
-
[x: `${bigint}`]: string
|
|
703
|
-
[x: `embedded-${number}`]: string
|
|
704
|
-
|
|
705
|
-
// These explicitly defined keys will remain.
|
|
706
|
-
foo: 'bar';
|
|
707
|
-
qux?: 'baz';
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
711
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
712
|
-
```
|
|
713
|
-
|
|
714
|
-
@see {@link PickIndexSignature}
|
|
715
|
-
@category Object
|
|
716
|
-
*/
|
|
717
|
-
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
718
|
-
//#endregion
|
|
719
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
720
|
-
/**
|
|
721
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
722
|
-
|
|
723
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
724
|
-
|
|
725
|
-
@example
|
|
726
|
-
```
|
|
727
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
728
|
-
|
|
729
|
-
declare const symbolKey: unique symbol;
|
|
730
|
-
|
|
731
|
-
type Example = {
|
|
732
|
-
// These index signatures will remain.
|
|
733
|
-
[x: string]: unknown;
|
|
734
|
-
[x: number]: unknown;
|
|
735
|
-
[x: symbol]: unknown;
|
|
736
|
-
[x: `head-${string}`]: string;
|
|
737
|
-
[x: `${string}-tail`]: string;
|
|
738
|
-
[x: `head-${string}-tail`]: string;
|
|
739
|
-
[x: `${bigint}`]: string;
|
|
740
|
-
[x: `embedded-${number}`]: string;
|
|
741
|
-
|
|
742
|
-
// These explicitly defined keys will be removed.
|
|
743
|
-
['kebab-case-key']: string;
|
|
744
|
-
[symbolKey]: string;
|
|
745
|
-
foo: 'bar';
|
|
746
|
-
qux?: 'baz';
|
|
747
|
-
};
|
|
748
|
-
|
|
749
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
750
|
-
// {
|
|
751
|
-
// [x: string]: unknown;
|
|
752
|
-
// [x: number]: unknown;
|
|
753
|
-
// [x: symbol]: unknown;
|
|
754
|
-
// [x: `head-${string}`]: string;
|
|
755
|
-
// [x: `${string}-tail`]: string;
|
|
756
|
-
// [x: `head-${string}-tail`]: string;
|
|
757
|
-
// [x: `${bigint}`]: string;
|
|
758
|
-
// [x: `embedded-${number}`]: string;
|
|
759
|
-
// }
|
|
760
|
-
```
|
|
761
|
-
|
|
762
|
-
@see {@link OmitIndexSignature}
|
|
763
|
-
@category Object
|
|
764
|
-
*/
|
|
765
|
-
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
766
|
-
//#endregion
|
|
767
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/merge.d.ts
|
|
768
|
-
// Merges two objects without worrying about index signatures.
|
|
769
|
-
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
773
|
-
|
|
774
|
-
@example
|
|
775
|
-
```
|
|
776
|
-
import type {Merge} from 'type-fest';
|
|
777
|
-
|
|
778
|
-
interface Foo {
|
|
779
|
-
[x: string]: unknown;
|
|
780
|
-
[x: number]: unknown;
|
|
781
|
-
foo: string;
|
|
782
|
-
bar: symbol;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
type Bar = {
|
|
786
|
-
[x: number]: number;
|
|
787
|
-
[x: symbol]: unknown;
|
|
788
|
-
bar: Date;
|
|
789
|
-
baz: boolean;
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
793
|
-
// => {
|
|
794
|
-
// [x: string]: unknown;
|
|
795
|
-
// [x: number]: number;
|
|
796
|
-
// [x: symbol]: unknown;
|
|
797
|
-
// foo: string;
|
|
798
|
-
// bar: Date;
|
|
799
|
-
// baz: boolean;
|
|
800
|
-
// }
|
|
801
|
-
```
|
|
802
|
-
|
|
803
|
-
@category Object
|
|
804
|
-
*/
|
|
805
|
-
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
806
|
-
//#endregion
|
|
807
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/internal/object.d.ts
|
|
808
|
-
/**
|
|
809
|
-
Merges user specified options with default options.
|
|
810
|
-
|
|
811
|
-
@example
|
|
812
|
-
```
|
|
813
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
814
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
815
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
816
|
-
|
|
817
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
818
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
819
|
-
```
|
|
820
|
-
|
|
821
|
-
@example
|
|
822
|
-
```
|
|
823
|
-
// Complains if default values are not provided for optional options
|
|
824
|
-
|
|
825
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
826
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
827
|
-
type SpecifiedOptions = {};
|
|
828
|
-
|
|
829
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
830
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
831
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
@example
|
|
835
|
-
```
|
|
836
|
-
// Complains if an option's default type does not conform to the expected type
|
|
837
|
-
|
|
838
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
839
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
840
|
-
type SpecifiedOptions = {};
|
|
841
|
-
|
|
842
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
843
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
844
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
845
|
-
```
|
|
846
|
-
|
|
847
|
-
@example
|
|
848
|
-
```
|
|
849
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
850
|
-
|
|
851
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
852
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
853
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
854
|
-
|
|
855
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
856
|
-
// ~~~~~~~~~~~~~~~~
|
|
857
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
858
|
-
```
|
|
859
|
-
*/
|
|
860
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever$1<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
861
|
-
//#endregion
|
|
862
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/or.d.ts
|
|
863
|
-
/**
|
|
864
|
-
Returns a boolean for whether either of two given types is true.
|
|
865
|
-
|
|
866
|
-
Use-case: Constructing complex conditional types where at least one condition must be satisfied.
|
|
867
|
-
|
|
868
|
-
@example
|
|
869
|
-
```
|
|
870
|
-
import type {Or} from 'type-fest';
|
|
871
|
-
|
|
872
|
-
type TT = Or<true, true>;
|
|
873
|
-
//=> true
|
|
874
|
-
|
|
875
|
-
type TF = Or<true, false>;
|
|
876
|
-
//=> true
|
|
877
|
-
|
|
878
|
-
type FT = Or<false, true>;
|
|
879
|
-
//=> true
|
|
880
|
-
|
|
881
|
-
type FF = Or<false, false>;
|
|
882
|
-
//=> false
|
|
883
|
-
```
|
|
884
|
-
|
|
885
|
-
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
886
|
-
For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
887
|
-
|
|
888
|
-
@example
|
|
889
|
-
```
|
|
890
|
-
import type {Or} from 'type-fest';
|
|
891
|
-
|
|
892
|
-
type A = Or<false, boolean>;
|
|
893
|
-
//=> boolean
|
|
894
|
-
|
|
895
|
-
type B = Or<boolean, false>;
|
|
896
|
-
//=> boolean
|
|
897
|
-
|
|
898
|
-
type C = Or<true, boolean>;
|
|
899
|
-
//=> true
|
|
900
|
-
|
|
901
|
-
type D = Or<boolean, true>;
|
|
902
|
-
//=> true
|
|
903
|
-
|
|
904
|
-
type E = Or<boolean, boolean>;
|
|
905
|
-
//=> boolean
|
|
906
|
-
```
|
|
907
|
-
|
|
908
|
-
Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
|
|
909
|
-
|
|
910
|
-
@example
|
|
911
|
-
```
|
|
912
|
-
import type {Or} from 'type-fest';
|
|
913
|
-
|
|
914
|
-
type A = Or<true, never>;
|
|
915
|
-
//=> true
|
|
916
|
-
|
|
917
|
-
type B = Or<never, true>;
|
|
918
|
-
//=> true
|
|
919
|
-
|
|
920
|
-
type C = Or<false, never>;
|
|
921
|
-
//=> false
|
|
922
|
-
|
|
923
|
-
type D = Or<never, false>;
|
|
924
|
-
//=> false
|
|
925
|
-
|
|
926
|
-
type E = Or<boolean, never>;
|
|
927
|
-
//=> boolean
|
|
928
|
-
|
|
929
|
-
type F = Or<never, boolean>;
|
|
930
|
-
//=> boolean
|
|
931
|
-
|
|
932
|
-
type G = Or<never, never>;
|
|
933
|
-
//=> false
|
|
934
|
-
```
|
|
935
|
-
|
|
936
|
-
@see {@link And}
|
|
937
|
-
@see {@link Xor}
|
|
938
|
-
*/
|
|
939
|
-
type Or<A$1 extends boolean, B$1 extends boolean> = _Or<If<IsNever$1<A$1>, false, A$1>, If<IsNever$1<B$1>, false, B$1>>;
|
|
940
|
-
// `never` is treated as `false`
|
|
941
|
-
|
|
942
|
-
type _Or<A$1 extends boolean, B$1 extends boolean> = A$1 extends true ? true : B$1 extends true ? true : false;
|
|
943
|
-
//#endregion
|
|
944
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/require-exactly-one.d.ts
|
|
945
|
-
/**
|
|
946
|
-
Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
|
|
947
|
-
|
|
948
|
-
Use-cases:
|
|
949
|
-
- Creating interfaces for components that only need one of the keys to display properly.
|
|
950
|
-
- Declaring generic keys in a single place for a single use-case that gets narrowed down via `RequireExactlyOne`.
|
|
951
|
-
|
|
952
|
-
The caveat with `RequireExactlyOne` is that TypeScript doesn't always know at compile time every key that will exist at runtime. Therefore `RequireExactlyOne` can't do anything to prevent extra keys it doesn't know about.
|
|
953
|
-
|
|
954
|
-
@example
|
|
955
|
-
```
|
|
956
|
-
import type {RequireExactlyOne} from 'type-fest';
|
|
957
|
-
|
|
958
|
-
type Responder = {
|
|
959
|
-
text: () => string;
|
|
960
|
-
json: () => string;
|
|
961
|
-
secure: boolean;
|
|
962
|
-
};
|
|
963
|
-
|
|
964
|
-
const responder: RequireExactlyOne<Responder, 'text' | 'json'> = {
|
|
965
|
-
// Adding a `text` key here would cause a compile error.
|
|
966
|
-
|
|
967
|
-
json: () => '{"message": "ok"}',
|
|
968
|
-
secure: true
|
|
969
|
-
};
|
|
970
|
-
```
|
|
971
|
-
|
|
972
|
-
@category Object
|
|
973
|
-
*/
|
|
974
|
-
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever$1<KeysType>, never, _RequireExactlyOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
975
|
-
type _RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]: (Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>) }[KeysType] & Omit<ObjectType, KeysType>;
|
|
976
|
-
//#endregion
|
|
977
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/require-one-or-none.d.ts
|
|
978
|
-
/**
|
|
979
|
-
Create a type that requires exactly one of the given keys and disallows more, or none of the given keys. The remaining keys are kept as is.
|
|
980
|
-
|
|
981
|
-
@example
|
|
982
|
-
```
|
|
983
|
-
import type {RequireOneOrNone} from 'type-fest';
|
|
984
|
-
|
|
985
|
-
type Responder = RequireOneOrNone<{
|
|
986
|
-
text: () => string;
|
|
987
|
-
json: () => string;
|
|
988
|
-
secure: boolean;
|
|
989
|
-
}, 'text' | 'json'>;
|
|
990
|
-
|
|
991
|
-
const responder1: Responder = {
|
|
992
|
-
secure: true
|
|
993
|
-
};
|
|
994
|
-
|
|
995
|
-
const responder2: Responder = {
|
|
996
|
-
text: () => '{"message": "hi"}',
|
|
997
|
-
secure: true
|
|
998
|
-
};
|
|
999
|
-
|
|
1000
|
-
const responder3: Responder = {
|
|
1001
|
-
json: () => '{"message": "ok"}',
|
|
1002
|
-
secure: true
|
|
1003
|
-
};
|
|
1004
|
-
```
|
|
1005
|
-
|
|
1006
|
-
@category Object
|
|
1007
|
-
*/
|
|
1008
|
-
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever$1<KeysType>, ObjectType, _RequireOneOrNone<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
1009
|
-
type _RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType> = (RequireExactlyOne<ObjectType, KeysType> | RequireNone<KeysType>) & Omit<ObjectType, KeysType>; // Ignore unspecified keys.
|
|
1010
|
-
//#endregion
|
|
1011
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/is-union.d.ts
|
|
1012
|
-
/**
|
|
1013
|
-
Returns a boolean for whether the given type is a union.
|
|
1014
|
-
|
|
1015
|
-
@example
|
|
1016
|
-
```
|
|
1017
|
-
import type {IsUnion} from 'type-fest';
|
|
1018
|
-
|
|
1019
|
-
type A = IsUnion<string | number>;
|
|
1020
|
-
//=> true
|
|
1021
|
-
|
|
1022
|
-
type B = IsUnion<string>;
|
|
1023
|
-
//=> false
|
|
1024
|
-
```
|
|
1025
|
-
*/
|
|
1026
|
-
type IsUnion$1<T> = InternalIsUnion<T>;
|
|
1027
|
-
/**
|
|
1028
|
-
The actual implementation of `IsUnion`.
|
|
1029
|
-
*/
|
|
1030
|
-
type InternalIsUnion<T, U$1 = T> = (IsNever$1<T> extends true ? false : T extends any ? [U$1] extends [T] ? false : true : never) extends infer Result
|
|
1031
|
-
// In some cases `Result` will return `false | true` which is `boolean`,
|
|
1032
|
-
// that means `T` has at least two types and it's a union type,
|
|
1033
|
-
// so we will return `true` instead of `boolean`.
|
|
1034
|
-
? boolean extends Result ? true : Result : never; // Should never happen
|
|
1035
|
-
//#endregion
|
|
1036
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
1037
|
-
/**
|
|
1038
|
-
@see {@link PartialDeep}
|
|
1039
|
-
*/
|
|
1040
|
-
type PartialDeepOptions = {
|
|
1041
|
-
/**
|
|
1042
|
-
Whether to affect the individual elements of arrays and tuples.
|
|
1043
|
-
@default false
|
|
1044
|
-
*/
|
|
1045
|
-
readonly recurseIntoArrays?: boolean;
|
|
1046
|
-
|
|
1047
|
-
/**
|
|
1048
|
-
Allows `undefined` values in non-tuple arrays.
|
|
1049
|
-
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
1050
|
-
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
1051
|
-
@default false
|
|
1052
|
-
@example
|
|
1053
|
-
You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
|
|
1054
|
-
```
|
|
1055
|
-
import type {PartialDeep} from 'type-fest';
|
|
1056
|
-
type Settings = {
|
|
1057
|
-
languages: string[];
|
|
1058
|
-
};
|
|
1059
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
|
|
1060
|
-
partialSettings.languages = [undefined]; // OK
|
|
1061
|
-
```
|
|
1062
|
-
*/
|
|
1063
|
-
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
1064
|
-
};
|
|
1065
|
-
type DefaultPartialDeepOptions = {
|
|
1066
|
-
recurseIntoArrays: false;
|
|
1067
|
-
allowUndefinedInNonTupleArrays: false;
|
|
1068
|
-
};
|
|
1069
|
-
|
|
1070
|
-
/**
|
|
1071
|
-
Create a type from another type with all keys and nested keys set to optional.
|
|
1072
|
-
|
|
1073
|
-
Use-cases:
|
|
1074
|
-
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
1075
|
-
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
1076
|
-
|
|
1077
|
-
@example
|
|
1078
|
-
```
|
|
1079
|
-
import type {PartialDeep} from 'type-fest';
|
|
1080
|
-
|
|
1081
|
-
let settings = {
|
|
1082
|
-
textEditor: {
|
|
1083
|
-
fontSize: 14,
|
|
1084
|
-
fontColor: '#000000',
|
|
1085
|
-
fontWeight: 400,
|
|
1086
|
-
},
|
|
1087
|
-
autocomplete: false,
|
|
1088
|
-
autosave: true,
|
|
1089
|
-
};
|
|
1090
|
-
|
|
1091
|
-
const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
|
|
1092
|
-
{...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
|
|
1093
|
-
);
|
|
1094
|
-
|
|
1095
|
-
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
1096
|
-
```
|
|
1097
|
-
|
|
1098
|
-
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:
|
|
1099
|
-
|
|
1100
|
-
```
|
|
1101
|
-
import type {PartialDeep} from 'type-fest';
|
|
1102
|
-
|
|
1103
|
-
type Shape = {
|
|
1104
|
-
dimensions: [number, number];
|
|
1105
|
-
};
|
|
1106
|
-
|
|
1107
|
-
const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
|
|
1108
|
-
dimensions: [], // OK
|
|
1109
|
-
};
|
|
1110
|
-
|
|
1111
|
-
partialShape.dimensions = [15]; // OK
|
|
1112
|
-
```
|
|
1113
|
-
|
|
1114
|
-
@see {@link PartialDeepOptions}
|
|
1115
|
-
|
|
1116
|
-
@category Object
|
|
1117
|
-
@category Array
|
|
1118
|
-
@category Set
|
|
1119
|
-
@category Map
|
|
1120
|
-
*/
|
|
1121
|
-
type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
1122
|
-
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$1<keyof T> extends true ? T // For functions with no properties
|
|
1123
|
-
: 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
|
|
1124
|
-
? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
1125
|
-
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
1126
|
-
? 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
|
|
1127
|
-
: T // If they don't opt into array testing, just use the original type
|
|
1128
|
-
: PartialObjectDeep<T, Options> : unknown;
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
1132
|
-
*/
|
|
1133
|
-
type PartialMapDeep<KeyType$1, ValueType$1, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType$1, Options>, _PartialDeep<ValueType$1, Options>>;
|
|
1134
|
-
|
|
1135
|
-
/**
|
|
1136
|
-
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
1137
|
-
*/
|
|
1138
|
-
type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
|
|
1139
|
-
|
|
1140
|
-
/**
|
|
1141
|
-
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
1142
|
-
*/
|
|
1143
|
-
type PartialReadonlyMapDeep<KeyType$1, ValueType$1, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType$1, Options>, _PartialDeep<ValueType$1, Options>>;
|
|
1144
|
-
|
|
1145
|
-
/**
|
|
1146
|
-
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
1147
|
-
*/
|
|
1148
|
-
type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
|
|
1149
|
-
|
|
1150
|
-
/**
|
|
1151
|
-
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
1152
|
-
*/
|
|
1153
|
-
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = { [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> };
|
|
1154
|
-
//#endregion
|
|
1155
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/required-deep.d.ts
|
|
1156
|
-
/**
|
|
1157
|
-
Create a type from another type with all keys and nested keys set to required.
|
|
1158
|
-
|
|
1159
|
-
Use-cases:
|
|
1160
|
-
- Creating optional configuration interfaces where the underlying implementation still requires all options to be fully specified.
|
|
1161
|
-
- Modeling the resulting type after a deep merge with a set of defaults.
|
|
1162
|
-
|
|
1163
|
-
@example
|
|
1164
|
-
```
|
|
1165
|
-
import type {RequiredDeep} from 'type-fest';
|
|
1166
|
-
|
|
1167
|
-
type Settings = {
|
|
1168
|
-
textEditor?: {
|
|
1169
|
-
fontSize?: number;
|
|
1170
|
-
fontColor?: string;
|
|
1171
|
-
fontWeight?: number | undefined;
|
|
1172
|
-
};
|
|
1173
|
-
autocomplete?: boolean;
|
|
1174
|
-
autosave?: boolean | undefined;
|
|
1175
|
-
};
|
|
1176
|
-
|
|
1177
|
-
type RequiredSettings = RequiredDeep<Settings>;
|
|
1178
|
-
//=> {
|
|
1179
|
-
// textEditor: {
|
|
1180
|
-
// fontSize: number;
|
|
1181
|
-
// fontColor: string;
|
|
1182
|
-
// fontWeight: number | undefined;
|
|
1183
|
-
// };
|
|
1184
|
-
// autocomplete: boolean;
|
|
1185
|
-
// autosave: boolean | undefined;
|
|
1186
|
-
// }
|
|
1187
|
-
```
|
|
1188
|
-
|
|
1189
|
-
Note that types containing overloaded functions are not made deeply required due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
|
|
1190
|
-
|
|
1191
|
-
@category Utilities
|
|
1192
|
-
@category Object
|
|
1193
|
-
@category Array
|
|
1194
|
-
@category Set
|
|
1195
|
-
@category Map
|
|
1196
|
-
*/
|
|
1197
|
-
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$1<keyof T> extends true ? T : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & RequiredObjectDeep<T> : T extends object ? RequiredObjectDeep<T> : unknown;
|
|
1198
|
-
type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
|
|
1199
|
-
//#endregion
|
|
1200
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
1201
|
-
/**
|
|
1202
|
-
Returns the last element of a union type.
|
|
1203
|
-
|
|
1204
|
-
@example
|
|
1205
|
-
```
|
|
1206
|
-
type Last = LastOfUnion<1 | 2 | 3>;
|
|
1207
|
-
//=> 3
|
|
1208
|
-
```
|
|
1209
|
-
*/
|
|
1210
|
-
type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
Convert a union type into an unordered tuple type of its elements.
|
|
1214
|
-
|
|
1215
|
-
"Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
|
|
1216
|
-
|
|
1217
|
-
This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
|
|
1218
|
-
|
|
1219
|
-
@example
|
|
1220
|
-
```
|
|
1221
|
-
import type {UnionToTuple} from 'type-fest';
|
|
1222
|
-
|
|
1223
|
-
type Numbers = 1 | 2 | 3;
|
|
1224
|
-
type NumbersTuple = UnionToTuple<Numbers>;
|
|
1225
|
-
//=> [1, 2, 3]
|
|
1226
|
-
```
|
|
1227
|
-
|
|
1228
|
-
@example
|
|
1229
|
-
```
|
|
1230
|
-
import type {UnionToTuple} from 'type-fest';
|
|
1231
|
-
|
|
1232
|
-
const pets = {
|
|
1233
|
-
dog: '🐶',
|
|
1234
|
-
cat: '🐱',
|
|
1235
|
-
snake: '🐍',
|
|
1236
|
-
};
|
|
1237
|
-
|
|
1238
|
-
type Pet = keyof typeof pets;
|
|
1239
|
-
//=> 'dog' | 'cat' | 'snake'
|
|
1240
|
-
|
|
1241
|
-
const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
1242
|
-
//=> ['dog', 'cat', 'snake']
|
|
1243
|
-
```
|
|
1244
|
-
|
|
1245
|
-
@category Array
|
|
1246
|
-
*/
|
|
1247
|
-
type UnionToTuple<T, L = LastOfUnion<T>> = IsNever$1<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
|
|
1248
|
-
//#endregion
|
|
1249
|
-
//#region src/types/core/modifiers.types.d.ts
|
|
1250
25
|
interface RegleBehaviourOptions {
|
|
1251
26
|
/**
|
|
1252
27
|
* Only display error when calling `r$.$validate()`
|
|
@@ -1282,6 +57,11 @@ interface RegleBehaviourOptions {
|
|
|
1282
57
|
*
|
|
1283
58
|
*/
|
|
1284
59
|
clearExternalErrorsOnChange?: boolean | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* A unique identifier for the Regle instance in the devtools.
|
|
62
|
+
* @default undefined
|
|
63
|
+
*/
|
|
64
|
+
id?: string | undefined;
|
|
1285
65
|
}
|
|
1286
66
|
interface LocalRegleBehaviourOptions<TState$1 extends Record<string, any>, TRules$1 extends ReglePartialRuleTree<TState$1, CustomRulesDeclarationTree>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}> {
|
|
1287
67
|
externalErrors?: Ref<RegleExternalErrorTree<Unwrap<TState$1>> | Record<string, string[]>>;
|
|
@@ -1332,8 +112,6 @@ type RegleShortcutDefinition<TCustomRules extends Record<string, any> = {}> = {
|
|
|
1332
112
|
collections?: ShortcutCommonFn<RegleCollectionStatus<any[], Partial<TCustomRules> & Partial<DefaultValidators>>>;
|
|
1333
113
|
};
|
|
1334
114
|
type AddDollarToOptions<T extends Record<string, any>> = { [K in keyof T as `$${string & K}`]: T[K] };
|
|
1335
|
-
//#endregion
|
|
1336
|
-
//#region src/types/core/useRegle.types.d.ts
|
|
1337
115
|
/**
|
|
1338
116
|
* The main Regle type that represents a complete validation instance.
|
|
1339
117
|
*
|
|
@@ -1370,8 +148,6 @@ type RegleSingleField<TState$1 extends Maybe<PrimitiveTypes> = any, TRules$1 ext
|
|
|
1370
148
|
} & TAdditionalReturnProperties;
|
|
1371
149
|
type DeepReactiveState<T extends Record<string, any> | unknown | undefined> = ExtendOnlyRealRecord<T> extends true ? { [K in keyof T]: InferDeepReactiveState<T[K]> } : never;
|
|
1372
150
|
type InferDeepReactiveState<TState$1> = NonNullable<TState$1> extends Array<infer U extends Record<string, any>> ? DeepReactiveState<U[]> : NonNullable<TState$1> extends Date | File ? MaybeRef<TState$1> : NonNullable<TState$1> extends Record<string, any> ? DeepReactiveState<TState$1> : MaybeRef<TState$1>;
|
|
1373
|
-
//#endregion
|
|
1374
|
-
//#region src/types/core/reset.types.d.ts
|
|
1375
151
|
type ResetOptions<TState$1 extends unknown> = RequireOneOrNone<{
|
|
1376
152
|
/**
|
|
1377
153
|
* Reset validation status and reset form state to its initial state.
|
|
@@ -1408,14 +184,10 @@ type ResetOptions<TState$1 extends unknown> = RequireOneOrNone<{
|
|
|
1408
184
|
*/
|
|
1409
185
|
keepValidationState?: boolean;
|
|
1410
186
|
}, 'toInitialState' | 'toState'>;
|
|
1411
|
-
//#endregion
|
|
1412
|
-
//#region src/types/core/scopedRegle.types.d.ts
|
|
1413
187
|
type ScopedInstancesRecord = Record<string, Record<string, SuperCompatibleRegleRoot>> & {
|
|
1414
188
|
'~~global': Record<string, SuperCompatibleRegleRoot>;
|
|
1415
189
|
};
|
|
1416
190
|
type ScopedInstancesRecordLike = Partial<ScopedInstancesRecord>;
|
|
1417
|
-
//#endregion
|
|
1418
|
-
//#region src/types/core/results.types.d.ts
|
|
1419
191
|
type PartialFormState<TState$1 extends Record<string, any>> = [unknown] extends [TState$1] ? {} : Prettify<{ [K in keyof TState$1 as ExtendOnlyRealRecord<TState$1[K]> extends true ? never : TState$1[K] extends Array<any> ? never : K]?: MaybeOutput<TState$1[K]> } & { [K in keyof TState$1 as ExtendOnlyRealRecord<TState$1[K]> extends true ? K : TState$1[K] extends Array<any> ? K : never]: NonNullable<TState$1[K]> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : PartialFormState<TState$1[K]> }>;
|
|
1420
192
|
type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules$1 extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = {
|
|
1421
193
|
valid: false;
|
|
@@ -1467,46 +239,6 @@ type ArrayHaveAtLeastOneRequiredField<TState$1 extends Maybe<any[]>, TRule exten
|
|
|
1467
239
|
type SafeProperty<TState$1, TRule extends RegleFormPropertyType<any, any> | undefined> = unknown extends TState$1 ? unknown : TRule extends RegleCollectionRuleDecl<any, any> ? TState$1 extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, ExtractFromGetter<TRule['$each']>>[] : TState$1 : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState$1> extends true ? DeepSafeFormState<NonNullable<TState$1> extends Record<string, any> ? JoinDiscriminatedUnions<NonNullable<TState$1>> : {}, TRule> : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? FieldHaveRequiredRule<UnwrapRef<TRule>> extends true ? TState$1 : MaybeOutput<TState$1> : TState$1 : TState$1;
|
|
1468
240
|
type IsPropertyOutputRequired<TState$1, TRule extends RegleFormPropertyType<any, any> | undefined> = [unknown] extends [TState$1] ? unknown : NonNullable<TState$1> extends Array<any> ? TRule extends RegleCollectionRuleDecl<any, any> ? ArrayHaveAtLeastOneRequiredField<NonNullable<TState$1>, TRule> extends false ? false : true : false : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState$1> extends true ? ObjectHaveAtLeastOneRequiredField<NonNullable<TState$1> extends Record<string, any> ? NonNullable<TState$1> : {}, TRule> extends false ? false : true : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? FieldHaveRequiredRule<UnwrapRef<TRule>> extends false ? false : true : false : false;
|
|
1469
241
|
type SafeFieldProperty<TState$1, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState$1> : MaybeOutput<TState$1>;
|
|
1470
|
-
//#endregion
|
|
1471
|
-
//#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/utils.d.ts
|
|
1472
|
-
/**
|
|
1473
|
-
* Negates a boolean type.
|
|
1474
|
-
*/
|
|
1475
|
-
type Not<T extends boolean> = T extends true ? false : true;
|
|
1476
|
-
/**
|
|
1477
|
-
* Checks if the given type is `never`.
|
|
1478
|
-
*/
|
|
1479
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
1480
|
-
/**
|
|
1481
|
-
* Checks if one type extends another. Note: this is not quite the same as `Left extends Right` because:
|
|
1482
|
-
* 1. If either type is `never`, the result is `true` iff the other type is also `never`.
|
|
1483
|
-
* 2. Types are wrapped in a 1-tuple so that union types are not distributed - instead we consider `string | number` to _not_ extend `number`. If we used `Left extends Right` directly you would get `Extends<string | number, number>` => `false | true` => `boolean`.
|
|
1484
|
-
*/
|
|
1485
|
-
type Extends<Left, Right> = IsNever<Left> extends true ? IsNever<Right> : [Left] extends [Right] ? true : false;
|
|
1486
|
-
/**
|
|
1487
|
-
* Convert a union to an intersection.
|
|
1488
|
-
* `A | B | C` -\> `A & B & C`
|
|
1489
|
-
*/
|
|
1490
|
-
type UnionToIntersection$1<Union> = (Union extends any ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection : never;
|
|
1491
|
-
/**
|
|
1492
|
-
* Get the last element of a union.
|
|
1493
|
-
* First, converts to a union of `() => T` functions,
|
|
1494
|
-
* then uses {@linkcode UnionToIntersection} to get the last one.
|
|
1495
|
-
*/
|
|
1496
|
-
type LastOf<Union> = UnionToIntersection$1<Union extends any ? () => Union : never> extends (() => infer R) ? R : never;
|
|
1497
|
-
/**
|
|
1498
|
-
* Intermediate type for {@linkcode UnionToTuple} which pushes the
|
|
1499
|
-
* "last" union member to the end of a tuple, and recursively prepends
|
|
1500
|
-
* the remainder of the union.
|
|
1501
|
-
*/
|
|
1502
|
-
type TuplifyUnion<Union, LastElement = LastOf<Union>> = IsNever<Union> extends true ? [] : [...TuplifyUnion<Exclude<Union, LastElement>>, LastElement];
|
|
1503
|
-
/**
|
|
1504
|
-
* Convert a union like `1 | 2 | 3` to a tuple like `[1, 2, 3]`.
|
|
1505
|
-
*/
|
|
1506
|
-
type UnionToTuple$1<Union> = TuplifyUnion<Union>;
|
|
1507
|
-
type IsUnion<T> = Not<Extends<UnionToTuple$1<T>['length'], 1>>;
|
|
1508
|
-
//#endregion
|
|
1509
|
-
//#region src/types/core/variants.types.d.ts
|
|
1510
242
|
type NarrowVariant<TRoot extends {
|
|
1511
243
|
[x: string]: unknown;
|
|
1512
244
|
$fields: {
|
|
@@ -1531,8 +263,6 @@ type PossibleLiteralTypes<T extends Record<string, any>, TKey$1 extends keyof T>
|
|
|
1531
263
|
} } };
|
|
1532
264
|
type RequiredForm<T extends Record<string, any>, TKey$1 extends keyof T> = Omit<ReglePartialRuleTree<T>, TKey$1> & PossibleLiteralTypes<T, TKey$1>[keyof PossibleLiteralTypes<T, TKey$1>];
|
|
1533
265
|
type VariantTuple<T extends Record<string, any>, TKey$1 extends keyof T> = [RequiredForm<T, TKey$1>, ...RequiredForm<T, TKey$1>[]];
|
|
1534
|
-
//#endregion
|
|
1535
|
-
//#region src/core/useRegle/useRegle.d.ts
|
|
1536
266
|
type useRegleFnOptions<TState$1 extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules$1 extends DeepExact<TRules$1, ReglePartialRuleTree<Unwrap<TState$1 extends Record<string, any> ? TState$1 : {}>, Partial<AllRulesDeclarations>>>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState$1 extends MaybeInput<PrimitiveTypes> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState$1 extends Record<string, any> ? Unwrap<TState$1> : {}>, TState$1 extends Record<string, any> ? (TRules$1 extends Record<string, any> ? TRules$1 : {}) : {}, TValidationGroups> & TAdditionalOptions;
|
|
1537
267
|
interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
|
|
1538
268
|
<TState$1 extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules$1 extends DeepExact<TRules$1, ReglePartialRuleTree<Unwrap<TState$1 extends Record<string, any> ? TState$1 : {}>, Partial<AllRulesDeclarations> & TCustomRules>>, TDecl extends RegleRuleDecl<NonNullable<TState$1>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>>(...params: [state: Maybe<MaybeRef<TState$1> | DeepReactiveState<TState$1>>, rulesFactory: TState$1 extends MaybeInput<PrimitiveTypes> ? MaybeRefOrGetter<TDecl> : TState$1 extends Record<string, any> ? MaybeRef<TRules$1> | ((...args: any[]) => TRules$1) : {}, ...(HaveAnyRequiredProps<useRegleFnOptions<TState$1, TRules$1, TAdditionalOptions, TValidationGroups>> extends true ? [options: useRegleFnOptions<TState$1, TRules$1, TAdditionalOptions, TValidationGroups>] : [options?: useRegleFnOptions<TState$1, TRules$1, TAdditionalOptions, TValidationGroups>])]): NonNullable<TState$1> extends PrimitiveTypes ? RegleSingleField<NonNullable<TState$1>, TDecl, TShortcuts, TAdditionalReturnProperties> : Regle<TState$1 extends Record<string, any> ? Unwrap<TState$1> : {}, TRules$1 extends Record<string, any> ? TRules$1 : {}, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
|
|
@@ -1562,8 +292,6 @@ interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortc
|
|
|
1562
292
|
* Docs: {@link https://reglejs.dev/core-concepts/}
|
|
1563
293
|
*/
|
|
1564
294
|
declare const useRegle: useRegleFn<Partial<AllRulesDeclarations>, RegleShortcutDefinition<any>, {}, {}>;
|
|
1565
|
-
//#endregion
|
|
1566
|
-
//#region src/core/useRegle/inferRules.d.ts
|
|
1567
295
|
interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
|
|
1568
296
|
<TState$1 extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules$1 extends DeepExact<TRules$1, ReglePartialRuleTree<Unwrap<TState$1 extends Record<string, any> ? TState$1 : {}>, Partial<AllRulesDeclarations> & TCustomRules>>, TDecl extends RegleRuleDecl<NonNullable<TState$1>, Partial<AllRulesDeclarations> & TCustomRules>>(state: MaybeRef<TState$1> | DeepReactiveState<TState$1>, rulesFactory: TState$1 extends MaybeInput<PrimitiveTypes> ? TDecl : TState$1 extends Record<string, any> ? TRules$1 : {}): NonNullable<TState$1> extends PrimitiveTypes ? TDecl : TRules$1;
|
|
1569
297
|
}
|
|
@@ -1575,8 +303,6 @@ interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
|
|
|
1575
303
|
* @param rules - Your rule tree
|
|
1576
304
|
*/
|
|
1577
305
|
declare const inferRules: inferRulesFn<Partial<AllRulesDeclarations>>;
|
|
1578
|
-
//#endregion
|
|
1579
|
-
//#region src/core/useRegle/root/useRootStorage.d.ts
|
|
1580
306
|
declare function useRootStorage({
|
|
1581
307
|
initialState,
|
|
1582
308
|
originalState,
|
|
@@ -1602,8 +328,6 @@ declare function useRootStorage({
|
|
|
1602
328
|
}): {
|
|
1603
329
|
regle: $InternalRegleStatusType | undefined;
|
|
1604
330
|
};
|
|
1605
|
-
//#endregion
|
|
1606
|
-
//#region src/core/useRegle/useErrors.d.ts
|
|
1607
331
|
/**
|
|
1608
332
|
* Converts a nested $errors object to a flat array of string errors
|
|
1609
333
|
*
|
|
@@ -1615,8 +339,6 @@ declare function flatErrors(errors: $InternalRegleErrors, options: {
|
|
|
1615
339
|
declare function flatErrors(errors: $InternalRegleErrors, options?: {
|
|
1616
340
|
includePath?: false;
|
|
1617
341
|
}): string[];
|
|
1618
|
-
//#endregion
|
|
1619
|
-
//#region src/core/useRegle/useRules.d.ts
|
|
1620
342
|
type useRulesFnOptions<TRules$1 extends RegleUnknownRulesTree | RegleRuleDecl, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState$1 = InferInput<TRules$1>> = Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState$1 extends Record<string, any> ? Unwrap<TState$1> : {}>, TState$1 extends Record<string, any> ? (TRules$1 extends Record<string, any> ? TRules$1 : {}) : {}, TValidationGroups>;
|
|
1621
343
|
interface useRulesFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortcuts extends RegleShortcutDefinition<any> = never> {
|
|
1622
344
|
<TRules$1 extends RegleUnknownRulesTree | RegleRuleDecl, TDecl extends RegleRuleDecl<NonNullable<TState$1>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState$1 extends Record<string, any> = InferInput<TRules$1>>(rulesFactory: TState$1 extends Record<string, any> ? MaybeRef<TRules$1> | ((...args: any[]) => TRules$1) : {}, options?: useRulesFnOptions<TRules$1, TValidationGroups, TState$1>): NonNullable<TState$1> extends PrimitiveTypes ? Raw<RegleFieldStatus<NonNullable<TState$1>, TDecl, TShortcuts>> & StandardSchemaV1<TState$1> : Raw<RegleRoot<TState$1 extends Record<string, any> ? Unwrap<TState$1> : {}, TRules$1 extends Record<string, any> ? TRules$1 : {}, TValidationGroups, TShortcuts>> & StandardSchemaV1<TState$1>;
|
|
@@ -1644,8 +366,6 @@ interface useRulesFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortc
|
|
|
1644
366
|
* ```
|
|
1645
367
|
*/
|
|
1646
368
|
declare const useRules: useRulesFn<Partial<AllRulesDeclarations>, RegleShortcutDefinition<any>>;
|
|
1647
|
-
//#endregion
|
|
1648
|
-
//#region src/types/utils/props.types.d.ts
|
|
1649
369
|
/**
|
|
1650
370
|
* Infer type of the `r$` of any function returning a regle instance
|
|
1651
371
|
*/
|
|
@@ -1671,8 +391,6 @@ type RegleEnforceCustomRequiredRules<T extends useRegleFn<any, any>, TRules$1 ex
|
|
|
1671
391
|
* Extract custom rules and custom shortcuts and apply them to a RegleFieldStatus type
|
|
1672
392
|
*/
|
|
1673
393
|
type RegleCustomFieldStatus<T extends useRegleFn<any, any>, TState$1 extends unknown = any, TRules$1 extends keyof InferRegleRules<T> = never> = RegleFieldStatus<TState$1, [TRules$1] extends [never] ? Partial<InferRegleRules<T>> : RegleEnforceCustomRequiredRules<T, TRules$1>, InferRegleShortcuts<T>>;
|
|
1674
|
-
//#endregion
|
|
1675
|
-
//#region src/types/utils/mismatch.types.d.ts
|
|
1676
394
|
/**
|
|
1677
395
|
/**
|
|
1678
396
|
* DeepExact<T, S> is a TypeScript utility type that recursively checks whether the structure of type S
|
|
@@ -1686,8 +404,6 @@ type TypeError<Msg> = {
|
|
|
1686
404
|
[' TypeError']: Msg;
|
|
1687
405
|
};
|
|
1688
406
|
type Coerce<T> = `${T & string}`;
|
|
1689
|
-
//#endregion
|
|
1690
|
-
//#region src/types/utils/object.types.d.ts
|
|
1691
407
|
type RemoveCommonKey<T extends readonly any[], K$1 extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K$1>>, ...RemoveCommonKey<R, K$1>] : [];
|
|
1692
408
|
/**
|
|
1693
409
|
* Restore the optional properties (with ?) of a generated mapped object type
|
|
@@ -1728,9 +444,7 @@ type UnwrapMaybeRef<T extends MaybeRef<any> | DeepReactiveState<any>> = T extend
|
|
|
1728
444
|
type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
|
|
1729
445
|
type HasNamedKeys<T> = IsUnion<T> extends true ? ProcessHasNamedKeys<LazyJoinDiscriminatedUnions<T>> : ProcessHasNamedKeys<T>;
|
|
1730
446
|
type ProcessHasNamedKeys<T> = { [K in keyof NonNullable<T>]: K extends string ? (string extends K ? never : K) : never }[keyof NonNullable<T>] extends never ? false : true;
|
|
1731
|
-
|
|
1732
|
-
//#region src/types/utils/infer.types.d.ts
|
|
1733
|
-
type InferInput<TRules$1 extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>) | MaybeRef<StandardSchemaV1<any>>, TMarkMaybe extends boolean = true> = TRules$1 extends MaybeRef<StandardSchemaV1<infer State>> ? State : IsUnion$1<UnwrapSimple<TRules$1>> extends true ? InferTupleUnionInput<UnionToTuple<UnwrapSimple<TRules$1>>>[number] : TMarkMaybe extends true ? Prettify<{ [K in keyof UnwrapSimple<TRules$1> as UnwrapSimple<TRules$1>[K] extends MaybeRef<RegleRuleDecl<any, any>> ? K : never]?: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> } & { [K in keyof UnwrapSimple<TRules$1> as UnwrapSimple<TRules$1>[K] extends MaybeRef<RegleRuleDecl<any, any>> ? never : K]: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> }> : Prettify<{ [K in keyof UnwrapSimple<TRules$1>]: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> }>;
|
|
447
|
+
type InferInput<TRules$1 extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>) | MaybeRef<StandardSchemaV1<any>>, TMarkMaybe extends boolean = true> = TRules$1 extends MaybeRef<StandardSchemaV1<infer State>> ? State : IsUnion<UnwrapSimple<TRules$1>> extends true ? InferTupleUnionInput<UnionToTuple<UnwrapSimple<TRules$1>>>[number] : TMarkMaybe extends true ? Prettify<{ [K in keyof UnwrapSimple<TRules$1> as UnwrapSimple<TRules$1>[K] extends MaybeRef<RegleRuleDecl<any, any>> ? K : never]?: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> } & { [K in keyof UnwrapSimple<TRules$1> as UnwrapSimple<TRules$1>[K] extends MaybeRef<RegleRuleDecl<any, any>> ? never : K]: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> }> : Prettify<{ [K in keyof UnwrapSimple<TRules$1>]: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> }>;
|
|
1734
448
|
type ProcessInputChildren<TRule extends unknown, TMarkMaybe extends boolean> = TRule extends {
|
|
1735
449
|
$each: RegleCollectionEachRules<any, any>;
|
|
1736
450
|
} ? ExtractFromGetter<TRule['$each']> extends ReglePartialRuleTree<any, any> ? InferInput<ExtractFromGetter<TRule['$each']>, TMarkMaybe>[] : any[] : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? [ExtractTypeFromRules<UnwrapRef<TRule>>] extends [never] ? unknown : ExtractTypeFromRules<UnwrapRef<TRule>> : TRule extends ReglePartialRuleTree<any, any> ? InferInput<TRule, TMarkMaybe> : string;
|
|
@@ -1738,10 +452,8 @@ type ExtractTypeFromRules<TRules$1 extends RegleRuleDecl<any, any>> = FilterRule
|
|
|
1738
452
|
type: infer Input;
|
|
1739
453
|
} ? Input : [FilterRulesWithSingleType<TRules$1>[keyof FilterRulesWithSingleType<TRules$1>]] extends [never] ? FilterRulesWithInput<TRules$1>[keyof FilterRulesWithInput<TRules$1>] : FilterRulesWithSingleType<TRules$1>[keyof FilterRulesWithSingleType<TRules$1>];
|
|
1740
454
|
type FilterRulesWithInput<TRules$1 extends RegleRuleDecl<any, any>> = { [K in keyof TRules$1 as TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : K : never]: TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? Input : unknown };
|
|
1741
|
-
type FilterRulesWithSingleType<TRules$1 extends RegleRuleDecl<any, any>> = { [K in keyof TRules$1 as TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : IsUnion
|
|
455
|
+
type FilterRulesWithSingleType<TRules$1 extends RegleRuleDecl<any, any>> = { [K in keyof TRules$1 as TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : IsUnion<NonNullable<Input>> extends true ? never : K : never]: TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? IsUnion<NonNullable<Input>> extends true ? unknown : Input : unknown };
|
|
1742
456
|
type InferTupleUnionInput<T extends any[]> = T extends [infer F extends ReglePartialRuleTree, ...infer R] ? [InferInput<F, true>, ...InferTupleUnionInput<R>] : [];
|
|
1743
|
-
//#endregion
|
|
1744
|
-
//#region src/types/rules/rule.params.types.d.ts
|
|
1745
457
|
type CreateFn<T extends any[]> = (...args: T) => any;
|
|
1746
458
|
/**
|
|
1747
459
|
* Transform normal parameters tuple declaration to a rich tuple declaration
|
|
@@ -1750,8 +462,6 @@ type CreateFn<T extends any[]> = (...args: T) => any;
|
|
|
1750
462
|
*/
|
|
1751
463
|
type RegleUniversalParams<T extends any[] = [], F$1 = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F$1 extends ((...args: infer Args) => any) ? (...args: { [K in keyof Args]: MaybeRefOrGetter<Maybe<Args[K]>> }) => any : never>;
|
|
1752
464
|
type UnwrapRegleUniversalParams<T extends MaybeRefOrGetter[] = [], F$1 = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F$1 extends ((...args: infer Args) => any) ? (...args: { [K in keyof Args]: Args[K] extends MaybeRefOrGetter<Maybe<infer U>> ? U : Args[K] }) => any : never>;
|
|
1753
|
-
//#endregion
|
|
1754
|
-
//#region src/types/rules/rule.internal.types.d.ts
|
|
1755
465
|
/**
|
|
1756
466
|
* Internal definition of the rule, this can be used to reset or patch the rule
|
|
1757
467
|
*/
|
|
@@ -1772,8 +482,6 @@ declare const InternalRuleType: {
|
|
|
1772
482
|
readonly Async: "__async";
|
|
1773
483
|
};
|
|
1774
484
|
type InternalRuleType = enumType<typeof InternalRuleType>;
|
|
1775
|
-
//#endregion
|
|
1776
|
-
//#region src/types/rules/rule.definition.type.d.ts
|
|
1777
485
|
type IsLiteral<T> = string extends T ? false : true;
|
|
1778
486
|
/**
|
|
1779
487
|
* Returned typed of rules created with `createRule`
|
|
@@ -1852,8 +560,6 @@ type RegleCollectionRuleDefinition<TValue$1 = any[], TCustomRules extends Partia
|
|
|
1852
560
|
}) | ({
|
|
1853
561
|
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue$1>>, TCustomRules>, ArrayElement<TValue$1>>;
|
|
1854
562
|
} & CollectionRegleBehaviourOptions);
|
|
1855
|
-
//#endregion
|
|
1856
|
-
//#region src/types/rules/rule.init.types.d.ts
|
|
1857
563
|
type RegleInitPropertyGetter<TValue$1, TReturn, TParams$1 extends [...any[]], TMetadata$1 extends RegleRuleMetadataDefinition> = TReturn | ((metadata: RegleRuleMetadataConsumer<TValue$1, TParams$1, TMetadata$1>) => TReturn);
|
|
1858
564
|
/**
|
|
1859
565
|
* @argument
|
|
@@ -1883,8 +589,6 @@ type RegleRuleTypeReturn<TValue$1, TParams$1 extends [...any[]]> = {
|
|
|
1883
589
|
value: TValue$1;
|
|
1884
590
|
params: [...TParams$1];
|
|
1885
591
|
};
|
|
1886
|
-
//#endregion
|
|
1887
|
-
//#region src/core/defaultValidators.d.ts
|
|
1888
592
|
interface CommonComparisonOptions {
|
|
1889
593
|
/**
|
|
1890
594
|
* Change the behaviour of the rule to check only if the value is equal in addition to be strictly superior or inferior
|
|
@@ -1948,15 +652,11 @@ type DefaultValidators = {
|
|
|
1948
652
|
startsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
|
|
1949
653
|
url: RegleRuleDefinition<string, [], false, boolean, string>;
|
|
1950
654
|
};
|
|
1951
|
-
//#endregion
|
|
1952
|
-
//#region src/types/rules/rule.custom.types.d.ts
|
|
1953
655
|
type CustomRulesDeclarationTree = {
|
|
1954
656
|
[x: string]: RegleRuleRawInput<any, any[], boolean, any> | undefined;
|
|
1955
657
|
};
|
|
1956
658
|
type DefaultValidatorsTree = { [K in keyof DefaultValidators]: RegleRuleRawInput<any, any[], boolean, any> | undefined };
|
|
1957
659
|
type AllRulesDeclarations = CustomRulesDeclarationTree & DefaultValidatorsTree;
|
|
1958
|
-
//#endregion
|
|
1959
|
-
//#region src/types/rules/rule.declaration.types.d.ts
|
|
1960
660
|
/**
|
|
1961
661
|
* @public
|
|
1962
662
|
*/
|
|
@@ -2033,8 +733,6 @@ type InlineRuleDeclaration<TValue$1 extends any = any, TParams$1 extends any[] =
|
|
|
2033
733
|
* Regroup inline and registered rules
|
|
2034
734
|
* */
|
|
2035
735
|
type FormRuleDeclaration<TValue$1 extends any = unknown, TParams$1 extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata$1 extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync$1 extends boolean = boolean> = InlineRuleDeclaration<TValue$1, TParams$1, TReturn> | RegleRuleDefinition<TValue$1, TParams$1, TAsync$1, TMetadata$1> | RegleRuleWithParamsDefinitionInput<TValue$1, [param?: any], TAsync$1, TMetadata$1> | RegleRuleWithParamsDefinitionInput<TValue$1, [param?: any, ...any[]], TAsync$1, TMetadata$1>;
|
|
2036
|
-
//#endregion
|
|
2037
|
-
//#region src/types/rules/rule.status.types.d.ts
|
|
2038
736
|
/**
|
|
2039
737
|
* @public
|
|
2040
738
|
*/
|
|
@@ -2083,6 +781,7 @@ interface $InternalRegleStatus extends $InternalRegleCommonStatus {
|
|
|
2083
781
|
readonly $silentErrors: Record<string, $InternalRegleErrors>;
|
|
2084
782
|
$extractDirtyFields: (filterNullishValues?: boolean) => Record<string, any>;
|
|
2085
783
|
$validate: (forceValues?: any) => Promise<$InternalRegleResult>;
|
|
784
|
+
'~modifiers'?: RegleBehaviourOptions;
|
|
2086
785
|
}
|
|
2087
786
|
/**
|
|
2088
787
|
* @public
|
|
@@ -2341,8 +1040,6 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
|
|
|
2341
1040
|
$extractDirtyFields: (filterNullishValues?: boolean) => any[];
|
|
2342
1041
|
$validate: (forceValues?: any) => Promise<$InternalRegleResult>;
|
|
2343
1042
|
}
|
|
2344
|
-
//#endregion
|
|
2345
|
-
//#region src/types/rules/rule.errors.types.d.ts
|
|
2346
1043
|
type RegleErrorTree<TState$1 = MaybeRef<Record<string, any> | any[]>, TIssue extends boolean = false> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>[K], false, TIssue> };
|
|
2347
1044
|
type RegleIssuesTree<TState$1 = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>[K], false, true> };
|
|
2348
1045
|
type RegleExternalErrorTree<TState$1 = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>[K], true> };
|
|
@@ -2374,8 +1071,6 @@ type $InternalRegleCollectionIssues = {
|
|
|
2374
1071
|
readonly $self?: RegleFieldIssue[];
|
|
2375
1072
|
readonly $each?: $InternalRegleIssues[];
|
|
2376
1073
|
};
|
|
2377
|
-
//#endregion
|
|
2378
|
-
//#region src/types/rules/compatibility.rules.d.ts
|
|
2379
1074
|
interface SuperCompatibleRegle {
|
|
2380
1075
|
r$: SuperCompatibleRegleRoot;
|
|
2381
1076
|
}
|
|
@@ -2385,6 +1080,7 @@ type SuperCompatibleRegleRoot = SuperCompatibleRegleStatus & {
|
|
|
2385
1080
|
[x: string]: RegleValidationGroupOutput;
|
|
2386
1081
|
};
|
|
2387
1082
|
$validate: (...args: any[]) => Promise<SuperCompatibleRegleResult>;
|
|
1083
|
+
'~modifiers'?: RegleBehaviourOptions;
|
|
2388
1084
|
};
|
|
2389
1085
|
type SuperCompatibleRegleResult = $InternalRegleResult;
|
|
2390
1086
|
type SuperCompatibleRegleStatus = {
|
|
@@ -2396,6 +1092,7 @@ type SuperCompatibleRegleStatus = {
|
|
|
2396
1092
|
readonly $silentErrors: Record<string, RegleValidationErrors<any, false>>;
|
|
2397
1093
|
$extractDirtyFields: (filterNullishValues?: boolean) => Record<string, any>;
|
|
2398
1094
|
$validate?: () => Promise<SuperCompatibleRegleResult>;
|
|
1095
|
+
$reset: (options?: ResetOptions<unknown>) => void;
|
|
2399
1096
|
[x: string]: any;
|
|
2400
1097
|
};
|
|
2401
1098
|
type SuperCompatibleRegleRuleStatus = Omit<$InternalRegleRuleStatus, '$haveAsync' | '$validating' | '$fieldDirty' | '$fieldInvalid' | '$fieldPending' | '$fieldCorrect' | '$fieldError' | '$unwatch' | '$watch' | '$maybePending'>;
|
|
@@ -2427,8 +1124,6 @@ interface SuperCompatibleRegleCollectionStatus extends Omit<SuperCompatibleRegle
|
|
|
2427
1124
|
}
|
|
2428
1125
|
type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
|
|
2429
1126
|
type SuperCompatibleRegleCollectionIssues = $InternalRegleCollectionIssues;
|
|
2430
|
-
//#endregion
|
|
2431
|
-
//#region src/core/createRule/createRule.d.ts
|
|
2432
1127
|
/**
|
|
2433
1128
|
* Create a typed custom rule that can be used like default rules.
|
|
2434
1129
|
* It can also be declared in the global options
|
|
@@ -2461,15 +1156,11 @@ type SuperCompatibleRegleCollectionIssues = $InternalRegleCollectionIssues;
|
|
|
2461
1156
|
* Docs: {@link https://reglejs.dev/core-concepts/rules/reusable-rules}
|
|
2462
1157
|
*/
|
|
2463
1158
|
declare function createRule<TValue$1 extends any, TParams$1 extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata$1 extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync$1 extends boolean = (TReturn extends Promise<any> ? true : false)>(definition: RegleRuleInit<TValue$1, TParams$1, TReturn, TMetadata$1, TAsync$1>): InferRegleRule<TValue$1, TParams$1, TAsync$1, TMetadata$1>;
|
|
2464
|
-
//#endregion
|
|
2465
|
-
//#region src/core/createRule/unwrapRuleParameters.d.ts
|
|
2466
1159
|
/**
|
|
2467
1160
|
* Returns a clean list of parameters
|
|
2468
1161
|
* Removing Ref and executing function to return the unwrapped value
|
|
2469
1162
|
*/
|
|
2470
1163
|
declare function unwrapRuleParameters<TParams$1 extends any[]>(params: MaybeRefOrGetter[]): TParams$1;
|
|
2471
|
-
//#endregion
|
|
2472
|
-
//#region src/core/defineRegleConfig.d.ts
|
|
2473
1164
|
/**
|
|
2474
1165
|
* Define a global regle configuration, where you can:
|
|
2475
1166
|
* - Customize built-in rules messages
|
|
@@ -2515,8 +1206,6 @@ declare function extendRegleConfig<TRootCustomRules extends Partial<AllRulesDecl
|
|
|
2515
1206
|
useRegle: useRegleFn<Merge<TRootCustomRules, TCustomRules>, TRootShortcuts & TShortcuts>;
|
|
2516
1207
|
inferRules: inferRulesFn<Merge<TRootCustomRules, TCustomRules>>;
|
|
2517
1208
|
};
|
|
2518
|
-
//#endregion
|
|
2519
|
-
//#region src/core/mergeRegles.d.ts
|
|
2520
1209
|
type MergedRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TValue$1 = { [K in keyof TRegles]: TRegles[K]['$value'] }> = Omit<RegleCommonStatus, '$value' | '$silentValue' | '$errors' | '$silentErrors' | '$name' | '$unwatch' | '$watch'> & {
|
|
2521
1210
|
/** Map of merged Regle instances and their properties */
|
|
2522
1211
|
readonly $instances: { [K in keyof TRegles]: TRegles[K] };
|
|
@@ -2574,22 +1263,16 @@ type MergedReglesResult<TRegles extends Record<string, SuperCompatibleRegleRoot>
|
|
|
2574
1263
|
issues: EmptyObject;
|
|
2575
1264
|
};
|
|
2576
1265
|
declare function mergeRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TScoped extends boolean = false>(regles: TRegles, _scoped?: TScoped): TScoped extends false ? MergedRegles<TRegles> : MergedScopedRegles;
|
|
2577
|
-
//#endregion
|
|
2578
|
-
//#region src/core/createScopedUseRegle/useCollectScope.d.ts
|
|
2579
1266
|
type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped extends true ? <const TValue$1 extends Record<string, Record<string, any>>>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2580
1267
|
r$: MergedRegles<{ [K in keyof TValue$1]: RegleRoot<TValue$1[K]> & SuperCompatibleRegleRoot }>;
|
|
2581
1268
|
} : <TValue$1 extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2582
1269
|
r$: MergedScopedRegles<TValue$1>;
|
|
2583
1270
|
};
|
|
2584
|
-
//#endregion
|
|
2585
|
-
//#region src/core/createScopedUseRegle/useScopedRegle.d.ts
|
|
2586
1271
|
type UseScopedRegleOptions<TAsRecord extends boolean> = {
|
|
2587
1272
|
namespace?: MaybeRefOrGetter<string>;
|
|
2588
1273
|
} & (TAsRecord extends true ? {
|
|
2589
1274
|
scopeKey: string;
|
|
2590
1275
|
} : {});
|
|
2591
|
-
//#endregion
|
|
2592
|
-
//#region src/core/createScopedUseRegle/createScopedUseRegle.d.ts
|
|
2593
1276
|
type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsRecord extends boolean> = {
|
|
2594
1277
|
/**
|
|
2595
1278
|
* Inject a global configuration to the exported composables to keep your translations and typings
|
|
@@ -2624,8 +1307,6 @@ declare const useCollectScope: <TValue$1 extends Record<string, unknown>[] = Rec
|
|
|
2624
1307
|
}, {
|
|
2625
1308
|
namespace?: vue0.MaybeRefOrGetter<string>;
|
|
2626
1309
|
}>;
|
|
2627
|
-
//#endregion
|
|
2628
|
-
//#region src/core/variants/createVariant.d.ts
|
|
2629
1310
|
/**
|
|
2630
1311
|
* Declare variations of state that depends on one value
|
|
2631
1312
|
*
|
|
@@ -2684,8 +1365,6 @@ declare function variantToRef<TRoot extends RegleStatus<{}, any, any>, const TKe
|
|
|
2684
1365
|
declare function variantToRef<TRoot extends RegleStatus<{}, any, any>, const TKey$1 extends keyof TRoot['$fields'], const TValue$1 extends (LazyJoinDiscriminatedUnions<Exclude<TRoot['$fields'][TKey$1], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
2685
1366
|
$value: infer V;
|
|
2686
1367
|
} ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey$1, discriminantValue: TValue$1): Ref<NarrowVariant<TRoot, TKey$1, TValue$1> | undefined>;
|
|
2687
|
-
//#endregion
|
|
2688
|
-
//#region src/core/refineRules.d.ts
|
|
2689
1368
|
/**
|
|
2690
1369
|
* Helper method to wrap an raw rules object
|
|
2691
1370
|
*
|
|
@@ -2712,5 +1391,5 @@ declare function defineRules<TRules$1 extends RegleUnknownRulesTree>(rules: TRul
|
|
|
2712
1391
|
* ```
|
|
2713
1392
|
*/
|
|
2714
1393
|
declare function refineRules<TRules$1 extends RegleUnknownRulesTree, TRefinement extends ReglePartialRuleTree<InferInput<TRules$1>> & RegleUnknownRulesTree>(rules: TRules$1, refinement: (state: Ref<InferInput<TRules$1>>) => TRefinement): (state: Ref<InferInput<TRules$1>>) => Merge<TRules$1, TRefinement>;
|
|
2715
|
-
|
|
2716
|
-
export { type $InternalRegleStatus, type AllRulesDeclarations, type ArrayElement, type CommonAlphaOptions, type CommonComparisonOptions, type CreateScopedUseRegleOptions, type DeepMaybeRef, type DeepReactiveState, type DefaultValidatorsTree, type FormRuleDeclaration, type HasNamedKeys, type HaveAnyRequiredProps, type InferInput, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleShortcuts, type InferRegleStatusType, type InferSafeOutput, type InlineRuleDeclaration, InternalRuleType, type JoinDiscriminatedUnions, type LocalRegleBehaviourOptions, type Maybe, type MaybeInput, type MaybeOutput, type MaybeReadonly, type MaybeVariantStatus, type MergedRegles, type MergedScopedRegles, type NarrowVariant, type NoInferLegacy, type NonEmptyTuple, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleCustomFieldStatus, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleExternalSchemaErrorTree, type RegleFieldIssue, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, type RegleIssuesTree, type ReglePartialRuleTree, type RegleResult, type RegleRoot, type RegleRuleCore, type RegleRuleDecl, type RegleRuleDefinition, type RegleRuleDefinitionProcessor, type RegleRuleDefinitionWithMetadataProcessor, type RegleRuleInit, type RegleRuleMetadataConsumer, type RegleRuleMetadataDefinition, type RegleRuleMetadataExtended, type RegleRuleRaw, type RegleRuleStatus, type RegleRuleTypeReturn, type RegleRuleWithParamsDefinition, type RegleShortcutDefinition, type RegleSingleField, type RegleStatus, type RegleUniversalParams, type RegleUnknownRulesTree, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, type ResolvedRegleBehaviourOptions, type ScopedInstancesRecord, type ScopedInstancesRecordLike, type SuperCompatibleRegle, type SuperCompatibleRegleCollectionErrors, type SuperCompatibleRegleCollectionStatus, type SuperCompatibleRegleFieldStatus, type SuperCompatibleRegleResult, type SuperCompatibleRegleRoot, type SuperCompatibleRegleRuleStatus, type SuperCompatibleRegleStatus, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, type UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRules, extendRegleConfig, flatErrors, inferRules, type inferRulesFn, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, type useCollectScopeFn, useRegle, type useRegleFn, useRootStorage, useRules, type useRulesFn, useScopedRegle, variantToRef };
|
|
1394
|
+
declare const RegleVuePlugin: Plugin;
|
|
1395
|
+
export { type $InternalRegleStatus, type AllRulesDeclarations, type ArrayElement, type CommonAlphaOptions, type CommonComparisonOptions, type CreateScopedUseRegleOptions, type DeepMaybeRef, type DeepReactiveState, type DefaultValidatorsTree, type FormRuleDeclaration, type HasNamedKeys, type HaveAnyRequiredProps, type InferInput, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleShortcuts, type InferRegleStatusType, type InferSafeOutput, type InlineRuleDeclaration, InternalRuleType, type JoinDiscriminatedUnions, type LocalRegleBehaviourOptions, type Maybe, type MaybeInput, type MaybeOutput, type MaybeReadonly, type MaybeVariantStatus, type MergedRegles, type MergedScopedRegles, type NarrowVariant, type NoInferLegacy, type NonEmptyTuple, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleCustomFieldStatus, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleExternalSchemaErrorTree, type RegleFieldIssue, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, type RegleIssuesTree, type ReglePartialRuleTree, type RegleResult, type RegleRoot, type RegleRuleCore, type RegleRuleDecl, type RegleRuleDefinition, type RegleRuleDefinitionProcessor, type RegleRuleDefinitionWithMetadataProcessor, type RegleRuleInit, type RegleRuleMetadataConsumer, type RegleRuleMetadataDefinition, type RegleRuleMetadataExtended, type RegleRuleRaw, type RegleRuleStatus, type RegleRuleTypeReturn, type RegleRuleWithParamsDefinition, type RegleShortcutDefinition, type RegleSingleField, type RegleStatus, type RegleUniversalParams, type RegleUnknownRulesTree, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, RegleVuePlugin, type ResolvedRegleBehaviourOptions, type ScopedInstancesRecord, type ScopedInstancesRecordLike, type SuperCompatibleRegle, type SuperCompatibleRegleCollectionErrors, type SuperCompatibleRegleCollectionStatus, type SuperCompatibleRegleFieldStatus, type SuperCompatibleRegleResult, type SuperCompatibleRegleRoot, type SuperCompatibleRegleRuleStatus, type SuperCompatibleRegleStatus, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, type UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRules, extendRegleConfig, flatErrors, inferRules, type inferRulesFn, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, type useCollectScopeFn, useRegle, type useRegleFn, useRootStorage, useRules, type useRulesFn, useScopedRegle, variantToRef };
|