fets 0.8.9 → 0.8.10
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/package.json +1 -1
- package/typings/types.d.cts +70 -18
- package/typings/types.d.ts +70 -18
package/package.json
CHANGED
package/typings/types.d.cts
CHANGED
|
@@ -111,23 +111,61 @@ export type ArrayItemValue<TJSONSchema extends JSONSchema> = TJSONSchema extends
|
|
|
111
111
|
} ? TItems : never;
|
|
112
112
|
type HasCircularAnyOfRef<T extends JSONSchema> = T extends {
|
|
113
113
|
properties: Record<string, JSONSchema>;
|
|
114
|
-
} ? {
|
|
115
|
-
[K in keyof T['properties']]:
|
|
116
|
-
}[keyof T['properties']]
|
|
117
|
-
type
|
|
114
|
+
} ? true extends {
|
|
115
|
+
[K in keyof T['properties']]: PropIntroducesCycle<T['properties'][K], T>;
|
|
116
|
+
}[keyof T['properties']] ? true : false : false;
|
|
117
|
+
type PropIntroducesCycle<S, Root> = S extends {
|
|
118
118
|
anyOf: infer Items extends readonly JSONSchema[];
|
|
119
|
-
} ?
|
|
119
|
+
} ? TupleIntroducesCycle<Items, Root> : S extends {
|
|
120
120
|
oneOf: infer Items extends readonly JSONSchema[];
|
|
121
|
-
} ?
|
|
121
|
+
} ? TupleIntroducesCycle<Items, Root> : S extends {
|
|
122
122
|
items: infer I extends JSONSchema;
|
|
123
|
-
} ?
|
|
124
|
-
|
|
123
|
+
} ? PropIntroducesCycle<I, Root> : S extends {
|
|
124
|
+
$id: string;
|
|
125
|
+
} ? false : S extends {
|
|
126
|
+
properties: infer P extends Record<string, JSONSchema>;
|
|
127
|
+
} ? true extends {
|
|
128
|
+
[K in keyof P]: PropIntroducesCycle<P[K], Root>;
|
|
129
|
+
}[keyof P] ? true : AdditionalPropertiesCycle<S, Root> : AdditionalPropertiesCycle<S, Root>;
|
|
130
|
+
type AdditionalPropertiesCycle<S, Root> = S extends {
|
|
131
|
+
additionalProperties: infer AP extends JSONSchema;
|
|
132
|
+
} ? PropIntroducesCycle<AP, Root> : false;
|
|
133
|
+
type TupleIntroducesCycle<Items extends readonly JSONSchema[], Root> = Items extends readonly [
|
|
125
134
|
infer Head extends JSONSchema,
|
|
126
135
|
...infer Tail extends readonly JSONSchema[]
|
|
127
|
-
] ? Head extends
|
|
136
|
+
] ? MemberIntroducesCycle<Head, Root> extends true ? true : TupleIntroducesCycle<Tail, Root> : false;
|
|
137
|
+
type MemberIntroducesCycle<Item, Root> = Item extends {
|
|
138
|
+
$id: string;
|
|
139
|
+
} ? [Item] extends [Root] ? true : HasSelfCircularAnyOf<Item> : false;
|
|
140
|
+
type HasSelfCircularAnyOf<T> = T extends {
|
|
141
|
+
properties: Record<string, JSONSchema>;
|
|
142
|
+
} ? true extends {
|
|
143
|
+
[K in keyof T['properties']]: DirectSelfAnyOf<T['properties'][K], T>;
|
|
144
|
+
}[keyof T['properties']] ? true : false : false;
|
|
145
|
+
type DirectSelfAnyOf<S, Root> = S extends {
|
|
146
|
+
anyOf: infer Items extends readonly JSONSchema[];
|
|
147
|
+
} ? TupleHasSelf<Items, Root> : S extends {
|
|
148
|
+
oneOf: infer Items extends readonly JSONSchema[];
|
|
149
|
+
} ? TupleHasSelf<Items, Root> : S extends {
|
|
150
|
+
items: infer I extends JSONSchema;
|
|
151
|
+
} ? DirectSelfAnyOf<I, Root> : S extends {
|
|
128
152
|
$id: string;
|
|
129
|
-
} ?
|
|
153
|
+
} ? false : S extends {
|
|
154
|
+
properties: infer P extends Record<string, JSONSchema>;
|
|
155
|
+
} ? true extends {
|
|
156
|
+
[K in keyof P]: DirectSelfAnyOf<P[K], Root>;
|
|
157
|
+
}[keyof P] ? true : AdditionalPropertiesSelf<S, Root> : AdditionalPropertiesSelf<S, Root>;
|
|
158
|
+
type AdditionalPropertiesSelf<S, Root> = S extends {
|
|
159
|
+
additionalProperties: infer AP extends JSONSchema;
|
|
160
|
+
} ? DirectSelfAnyOf<AP, Root> : false;
|
|
161
|
+
type TupleHasSelf<Items extends readonly JSONSchema[], Root> = Items extends readonly [
|
|
162
|
+
infer Head extends JSONSchema,
|
|
163
|
+
...infer Tail extends readonly JSONSchema[]
|
|
164
|
+
] ? [Head] extends [Root] ? true : TupleHasSelf<Tail, Root> : false;
|
|
130
165
|
export type DirectType<T extends JSONSchema> = T extends {
|
|
166
|
+
nullable: true;
|
|
167
|
+
} ? DirectTypeValue<T> | null : DirectTypeValue<T>;
|
|
168
|
+
type DirectTypeValue<T extends JSONSchema> = T extends {
|
|
131
169
|
static: infer U;
|
|
132
170
|
} ? U : T extends {
|
|
133
171
|
anyOf: infer Items extends readonly JSONSchema[];
|
|
@@ -159,18 +197,32 @@ export type DirectType<T extends JSONSchema> = T extends {
|
|
|
159
197
|
type: 'object';
|
|
160
198
|
properties: infer Props extends Record<string, JSONSchema>;
|
|
161
199
|
required: infer Req extends readonly string[];
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} & {
|
|
165
|
-
[K in Exclude<keyof Props, Req[number]>]?: DirectType<Props[K]>;
|
|
166
|
-
} : T extends {
|
|
200
|
+
additionalProperties: infer AP;
|
|
201
|
+
} ? DirectNamedProps<Props, Req> & DirectIndexSignature<AP> : T extends {
|
|
167
202
|
type: 'object';
|
|
168
203
|
properties: infer Props extends Record<string, JSONSchema>;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
204
|
+
additionalProperties: infer AP;
|
|
205
|
+
} ? DirectNamedProps<Props> & DirectIndexSignature<AP> : T extends {
|
|
206
|
+
type: 'object';
|
|
207
|
+
properties: infer Props extends Record<string, JSONSchema>;
|
|
208
|
+
required: infer Req extends readonly string[];
|
|
209
|
+
} ? DirectNamedProps<Props, Req> : T extends {
|
|
210
|
+
type: 'object';
|
|
211
|
+
properties: infer Props extends Record<string, JSONSchema>;
|
|
212
|
+
} ? DirectNamedProps<Props> : T extends {
|
|
213
|
+
type: 'object';
|
|
214
|
+
additionalProperties: infer AP;
|
|
215
|
+
} ? AP extends false ? Record<string, never> : DirectIndexSignature<AP> : T extends {
|
|
172
216
|
type: 'object';
|
|
173
217
|
} ? Record<string, unknown> : unknown;
|
|
218
|
+
type DirectNamedProps<Props extends Record<string, JSONSchema>, Req extends readonly string[] | undefined = undefined> = [Req] extends [readonly string[]] ? {
|
|
219
|
+
[K in Extract<keyof Props, Req[number]>]: DirectType<Props[K]>;
|
|
220
|
+
} & {
|
|
221
|
+
[K in Exclude<keyof Props, Req[number]>]?: DirectType<Props[K]>;
|
|
222
|
+
} : {
|
|
223
|
+
[K in keyof Props]?: DirectType<Props[K]>;
|
|
224
|
+
};
|
|
225
|
+
type DirectIndexSignature<AP> = AP extends false ? unknown : AP extends true ? Record<string, unknown> : AP extends JSONSchema ? Record<string, DirectType<AP>> : Record<string, unknown>;
|
|
174
226
|
type DirectUnionType<Items extends readonly JSONSchema[]> = Items extends readonly [
|
|
175
227
|
infer Head extends JSONSchema,
|
|
176
228
|
...infer Tail extends readonly JSONSchema[]
|
package/typings/types.d.ts
CHANGED
|
@@ -111,23 +111,61 @@ export type ArrayItemValue<TJSONSchema extends JSONSchema> = TJSONSchema extends
|
|
|
111
111
|
} ? TItems : never;
|
|
112
112
|
type HasCircularAnyOfRef<T extends JSONSchema> = T extends {
|
|
113
113
|
properties: Record<string, JSONSchema>;
|
|
114
|
-
} ? {
|
|
115
|
-
[K in keyof T['properties']]:
|
|
116
|
-
}[keyof T['properties']]
|
|
117
|
-
type
|
|
114
|
+
} ? true extends {
|
|
115
|
+
[K in keyof T['properties']]: PropIntroducesCycle<T['properties'][K], T>;
|
|
116
|
+
}[keyof T['properties']] ? true : false : false;
|
|
117
|
+
type PropIntroducesCycle<S, Root> = S extends {
|
|
118
118
|
anyOf: infer Items extends readonly JSONSchema[];
|
|
119
|
-
} ?
|
|
119
|
+
} ? TupleIntroducesCycle<Items, Root> : S extends {
|
|
120
120
|
oneOf: infer Items extends readonly JSONSchema[];
|
|
121
|
-
} ?
|
|
121
|
+
} ? TupleIntroducesCycle<Items, Root> : S extends {
|
|
122
122
|
items: infer I extends JSONSchema;
|
|
123
|
-
} ?
|
|
124
|
-
|
|
123
|
+
} ? PropIntroducesCycle<I, Root> : S extends {
|
|
124
|
+
$id: string;
|
|
125
|
+
} ? false : S extends {
|
|
126
|
+
properties: infer P extends Record<string, JSONSchema>;
|
|
127
|
+
} ? true extends {
|
|
128
|
+
[K in keyof P]: PropIntroducesCycle<P[K], Root>;
|
|
129
|
+
}[keyof P] ? true : AdditionalPropertiesCycle<S, Root> : AdditionalPropertiesCycle<S, Root>;
|
|
130
|
+
type AdditionalPropertiesCycle<S, Root> = S extends {
|
|
131
|
+
additionalProperties: infer AP extends JSONSchema;
|
|
132
|
+
} ? PropIntroducesCycle<AP, Root> : false;
|
|
133
|
+
type TupleIntroducesCycle<Items extends readonly JSONSchema[], Root> = Items extends readonly [
|
|
125
134
|
infer Head extends JSONSchema,
|
|
126
135
|
...infer Tail extends readonly JSONSchema[]
|
|
127
|
-
] ? Head extends
|
|
136
|
+
] ? MemberIntroducesCycle<Head, Root> extends true ? true : TupleIntroducesCycle<Tail, Root> : false;
|
|
137
|
+
type MemberIntroducesCycle<Item, Root> = Item extends {
|
|
138
|
+
$id: string;
|
|
139
|
+
} ? [Item] extends [Root] ? true : HasSelfCircularAnyOf<Item> : false;
|
|
140
|
+
type HasSelfCircularAnyOf<T> = T extends {
|
|
141
|
+
properties: Record<string, JSONSchema>;
|
|
142
|
+
} ? true extends {
|
|
143
|
+
[K in keyof T['properties']]: DirectSelfAnyOf<T['properties'][K], T>;
|
|
144
|
+
}[keyof T['properties']] ? true : false : false;
|
|
145
|
+
type DirectSelfAnyOf<S, Root> = S extends {
|
|
146
|
+
anyOf: infer Items extends readonly JSONSchema[];
|
|
147
|
+
} ? TupleHasSelf<Items, Root> : S extends {
|
|
148
|
+
oneOf: infer Items extends readonly JSONSchema[];
|
|
149
|
+
} ? TupleHasSelf<Items, Root> : S extends {
|
|
150
|
+
items: infer I extends JSONSchema;
|
|
151
|
+
} ? DirectSelfAnyOf<I, Root> : S extends {
|
|
128
152
|
$id: string;
|
|
129
|
-
} ?
|
|
153
|
+
} ? false : S extends {
|
|
154
|
+
properties: infer P extends Record<string, JSONSchema>;
|
|
155
|
+
} ? true extends {
|
|
156
|
+
[K in keyof P]: DirectSelfAnyOf<P[K], Root>;
|
|
157
|
+
}[keyof P] ? true : AdditionalPropertiesSelf<S, Root> : AdditionalPropertiesSelf<S, Root>;
|
|
158
|
+
type AdditionalPropertiesSelf<S, Root> = S extends {
|
|
159
|
+
additionalProperties: infer AP extends JSONSchema;
|
|
160
|
+
} ? DirectSelfAnyOf<AP, Root> : false;
|
|
161
|
+
type TupleHasSelf<Items extends readonly JSONSchema[], Root> = Items extends readonly [
|
|
162
|
+
infer Head extends JSONSchema,
|
|
163
|
+
...infer Tail extends readonly JSONSchema[]
|
|
164
|
+
] ? [Head] extends [Root] ? true : TupleHasSelf<Tail, Root> : false;
|
|
130
165
|
export type DirectType<T extends JSONSchema> = T extends {
|
|
166
|
+
nullable: true;
|
|
167
|
+
} ? DirectTypeValue<T> | null : DirectTypeValue<T>;
|
|
168
|
+
type DirectTypeValue<T extends JSONSchema> = T extends {
|
|
131
169
|
static: infer U;
|
|
132
170
|
} ? U : T extends {
|
|
133
171
|
anyOf: infer Items extends readonly JSONSchema[];
|
|
@@ -159,18 +197,32 @@ export type DirectType<T extends JSONSchema> = T extends {
|
|
|
159
197
|
type: 'object';
|
|
160
198
|
properties: infer Props extends Record<string, JSONSchema>;
|
|
161
199
|
required: infer Req extends readonly string[];
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} & {
|
|
165
|
-
[K in Exclude<keyof Props, Req[number]>]?: DirectType<Props[K]>;
|
|
166
|
-
} : T extends {
|
|
200
|
+
additionalProperties: infer AP;
|
|
201
|
+
} ? DirectNamedProps<Props, Req> & DirectIndexSignature<AP> : T extends {
|
|
167
202
|
type: 'object';
|
|
168
203
|
properties: infer Props extends Record<string, JSONSchema>;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
204
|
+
additionalProperties: infer AP;
|
|
205
|
+
} ? DirectNamedProps<Props> & DirectIndexSignature<AP> : T extends {
|
|
206
|
+
type: 'object';
|
|
207
|
+
properties: infer Props extends Record<string, JSONSchema>;
|
|
208
|
+
required: infer Req extends readonly string[];
|
|
209
|
+
} ? DirectNamedProps<Props, Req> : T extends {
|
|
210
|
+
type: 'object';
|
|
211
|
+
properties: infer Props extends Record<string, JSONSchema>;
|
|
212
|
+
} ? DirectNamedProps<Props> : T extends {
|
|
213
|
+
type: 'object';
|
|
214
|
+
additionalProperties: infer AP;
|
|
215
|
+
} ? AP extends false ? Record<string, never> : DirectIndexSignature<AP> : T extends {
|
|
172
216
|
type: 'object';
|
|
173
217
|
} ? Record<string, unknown> : unknown;
|
|
218
|
+
type DirectNamedProps<Props extends Record<string, JSONSchema>, Req extends readonly string[] | undefined = undefined> = [Req] extends [readonly string[]] ? {
|
|
219
|
+
[K in Extract<keyof Props, Req[number]>]: DirectType<Props[K]>;
|
|
220
|
+
} & {
|
|
221
|
+
[K in Exclude<keyof Props, Req[number]>]?: DirectType<Props[K]>;
|
|
222
|
+
} : {
|
|
223
|
+
[K in keyof Props]?: DirectType<Props[K]>;
|
|
224
|
+
};
|
|
225
|
+
type DirectIndexSignature<AP> = AP extends false ? unknown : AP extends true ? Record<string, unknown> : AP extends JSONSchema ? Record<string, DirectType<AP>> : Record<string, unknown>;
|
|
174
226
|
type DirectUnionType<Items extends readonly JSONSchema[]> = Items extends readonly [
|
|
175
227
|
infer Head extends JSONSchema,
|
|
176
228
|
...infer Tail extends readonly JSONSchema[]
|