@linxiraos/pi-omptype 1.1.12 → 1.1.13
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/CHANGELOG.md +4 -0
- package/package.json +5 -2
- package/src/infer.ts +52 -36
- package/src/type.ts +2 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@linxiraos/pi-omptype",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.13",
|
|
5
5
|
"description": "ArkType-compatible runtime schema validation with lazy JIT compilation",
|
|
6
6
|
"homepage": "https://linxira-os.github.io/zeta/",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -23,8 +23,11 @@
|
|
|
23
23
|
"main": "./dist/js/index.js",
|
|
24
24
|
"types": "./dist/types/index.d.ts",
|
|
25
25
|
"scripts": {
|
|
26
|
-
"check": "
|
|
26
|
+
"check": "oxlint . && oxfmt --check --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts' && bun run check:types",
|
|
27
27
|
"check:types": "tsgo -p tsconfig.json --noEmit",
|
|
28
|
+
"lint": "oxlint .",
|
|
29
|
+
"fix": "oxlint --fix --fix-suggestions . && bun run fmt",
|
|
30
|
+
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'",
|
|
28
31
|
"test": "bun test --parallel",
|
|
29
32
|
"bench": "bun bench/bench.ts"
|
|
30
33
|
},
|
package/src/infer.ts
CHANGED
|
@@ -214,35 +214,43 @@ type UnwrapProperty<def> = def extends readonly [infer value, "?" | "=", ...unkn
|
|
|
214
214
|
type Simplify<t> = { [key in keyof t]: t[key] };
|
|
215
215
|
|
|
216
216
|
type OutputRequired<def extends object> = {
|
|
217
|
-
-readonly [
|
|
218
|
-
|
|
219
|
-
?
|
|
220
|
-
|
|
221
|
-
|
|
217
|
+
-readonly [
|
|
218
|
+
key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true
|
|
219
|
+
? HasDefault<def[key]> extends true
|
|
220
|
+
? PropName<key>
|
|
221
|
+
: never
|
|
222
|
+
: PropName<key>
|
|
223
|
+
]-?: InferDef<UnwrapProperty<def[key]>>;
|
|
222
224
|
};
|
|
223
225
|
|
|
224
226
|
type OutputOptional<def extends object> = {
|
|
225
|
-
-readonly [
|
|
226
|
-
|
|
227
|
-
?
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
-readonly [
|
|
228
|
+
key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true
|
|
229
|
+
? HasDefault<def[key]> extends true
|
|
230
|
+
? never
|
|
231
|
+
: PropName<key>
|
|
232
|
+
: never
|
|
233
|
+
]?: InferDef<UnwrapProperty<def[key]>>;
|
|
230
234
|
};
|
|
231
235
|
|
|
232
236
|
type InputRequired<def extends object> = {
|
|
233
|
-
-readonly [
|
|
234
|
-
|
|
235
|
-
: HasDefault<def[key]> extends true
|
|
237
|
+
-readonly [
|
|
238
|
+
key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true
|
|
236
239
|
? never
|
|
237
|
-
:
|
|
240
|
+
: HasDefault<def[key]> extends true
|
|
241
|
+
? never
|
|
242
|
+
: PropName<key>
|
|
243
|
+
]-?: InferDefIn<UnwrapProperty<def[key]>>;
|
|
238
244
|
};
|
|
239
245
|
|
|
240
246
|
type InputOptional<def extends object> = {
|
|
241
|
-
-readonly [
|
|
242
|
-
|
|
243
|
-
: HasDefault<def[key]> extends true
|
|
247
|
+
-readonly [
|
|
248
|
+
key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true
|
|
244
249
|
? PropName<key>
|
|
245
|
-
:
|
|
250
|
+
: HasDefault<def[key]> extends true
|
|
251
|
+
? PropName<key>
|
|
252
|
+
: never
|
|
253
|
+
]?: InferDefIn<UnwrapProperty<def[key]>>;
|
|
246
254
|
};
|
|
247
255
|
|
|
248
256
|
/**
|
|
@@ -302,35 +310,43 @@ type InferLiteralDefIn<def> = def extends { readonly inferIn: infer input }
|
|
|
302
310
|
: unknown;
|
|
303
311
|
|
|
304
312
|
type LiteralRequired<def extends object> = {
|
|
305
|
-
-readonly [
|
|
306
|
-
|
|
307
|
-
?
|
|
308
|
-
|
|
309
|
-
|
|
313
|
+
-readonly [
|
|
314
|
+
key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true
|
|
315
|
+
? HasDefault<def[key]> extends true
|
|
316
|
+
? PropName<key>
|
|
317
|
+
: never
|
|
318
|
+
: PropName<key>
|
|
319
|
+
]-?: InferLiteralDef<UnwrapProperty<def[key]>>;
|
|
310
320
|
};
|
|
311
321
|
|
|
312
322
|
type LiteralOptional<def extends object> = {
|
|
313
|
-
-readonly [
|
|
314
|
-
|
|
315
|
-
?
|
|
316
|
-
|
|
317
|
-
|
|
323
|
+
-readonly [
|
|
324
|
+
key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true
|
|
325
|
+
? HasDefault<def[key]> extends true
|
|
326
|
+
? never
|
|
327
|
+
: PropName<key>
|
|
328
|
+
: never
|
|
329
|
+
]?: InferLiteralDef<UnwrapProperty<def[key]>>;
|
|
318
330
|
};
|
|
319
331
|
|
|
320
332
|
type LiteralRequiredIn<def extends object> = {
|
|
321
|
-
-readonly [
|
|
322
|
-
|
|
323
|
-
: HasDefault<def[key]> extends true
|
|
333
|
+
-readonly [
|
|
334
|
+
key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true
|
|
324
335
|
? never
|
|
325
|
-
:
|
|
336
|
+
: HasDefault<def[key]> extends true
|
|
337
|
+
? never
|
|
338
|
+
: PropName<key>
|
|
339
|
+
]-?: InferLiteralDefIn<UnwrapProperty<def[key]>>;
|
|
326
340
|
};
|
|
327
341
|
|
|
328
342
|
type LiteralOptionalIn<def extends object> = {
|
|
329
|
-
-readonly [
|
|
330
|
-
|
|
331
|
-
: HasDefault<def[key]> extends true
|
|
343
|
+
-readonly [
|
|
344
|
+
key in DefinitionKeys<def> as IsOptionalProp<key, def[key]> extends true
|
|
332
345
|
? PropName<key>
|
|
333
|
-
:
|
|
346
|
+
: HasDefault<def[key]> extends true
|
|
347
|
+
? PropName<key>
|
|
348
|
+
: never
|
|
349
|
+
]?: InferLiteralDefIn<UnwrapProperty<def[key]>>;
|
|
334
350
|
};
|
|
335
351
|
|
|
336
352
|
/** Object-literal inference that unwraps embedded schema values one level deep. */
|
package/src/type.ts
CHANGED
|
@@ -560,7 +560,8 @@ const EMPTY_META: TypeMeta = {};
|
|
|
560
560
|
const ARK_COMPAT_SCOPE = Object.freeze({ internal: Object.freeze({ name: "ark" as const }) });
|
|
561
561
|
|
|
562
562
|
interface InternalType
|
|
563
|
-
extends
|
|
563
|
+
extends
|
|
564
|
+
Type<unknown, unknown>,
|
|
564
565
|
FluentMethods<unknown, unknown>,
|
|
565
566
|
ObjectMethods<Record<PropertyKey, unknown>, unknown> {
|
|
566
567
|
(data: unknown): unknown;
|