Skip to content

Commit 55d8d32

Browse files
committed
Release 0.13.24
1 parent a18b510 commit 55d8d32

12 files changed

+44
-39
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "pave",
33
"type": "module",
4-
"version": "0.13.23",
4+
"version": "0.13.24",
55
"author": "Casey Foster <[email protected]>",
66
"license": "MIT",
77
"repository": {

src/execute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const { isArray } = Array;
1717
* path?: string[];
1818
* query: Query;
1919
* schema: S;
20-
* type: Type<S>;
20+
* type: Type<S, any, any, any, any>;
2121
* value?: any;
2222
* }} options
2323
*/

src/execute.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @import {Type} from '#src/index.js' */
2-
31
import { strict as assert } from 'node:assert';
42

53
import { Context } from '#src/context.js';

src/get-query-cost.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @import {Query, Schema, SchemaContext, Type} from '#src/index.js'; */
1+
/** @import {Schema, Query, SchemaContext, Type} from '#src/index.js'; */
22

33
import { isObject } from '#src/is-object.js';
44

@@ -11,15 +11,15 @@ const { isArray } = Array;
1111
* path?: string[];
1212
* query: Query;
1313
* schema: S;
14-
* type: Type<S>;
14+
* type: Type<S, any, any, any, any>;
1515
* }} options
1616
*/
1717
export const getQueryCost = ({ context, path = [], query, schema, type }) => {
1818
let cost = 0;
1919
while (true) {
2020
if (!type) return cost;
2121

22-
if (isArray(type)) type = /** @type {Type<S>} */ ({ object: type });
22+
if (isArray(type)) type = { object: type };
2323

2424
let nextType;
2525
if (!isObject(type)) nextType = schema[type];

src/index.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
/**
18-
* @template {string} [TypeName=never] Default is `never`
18+
* @template {string} [TypeName=''] Default is `''`
1919
* @template [Context=unknown] Default is `unknown`
2020
* @template {{ [K: string]: any }} [Extensions={}] Default is `{}`
2121
* @typedef {{
@@ -53,17 +53,24 @@
5353
* @typedef {Recursive<
5454
* | SchemaTypeName<S>
5555
* | ((
56-
* | { optional: Type<S> }
57-
* | { nullable: Type<S> }
58-
* | { arrayOf: Type<S>; minLength?: number; maxLength?: number }
56+
* | { optional: Type<S, any, any, any, any> }
57+
* | { nullable: Type<S, any, any, any, any> }
5958
* | {
60-
* oneOf: { [K: string]: Type<S> };
59+
* arrayOf: Type<S, any, any, any, any>;
60+
* minLength?: number;
61+
* maxLength?: number;
62+
* }
63+
* | {
64+
* oneOf: { [K: string]: Type<S, any, any, any, any> };
6165
* resolveType: (value: {}) => string;
6266
* }
63-
* | { object: { [K: string]: Type<S> }; defaultType?: Type<S> }
6467
* | {
65-
* input?: Type<S>;
66-
* type?: Type<S>;
68+
* object: { [K: string]: Type<S, any, any, any, any> };
69+
* defaultType?: Type<S, any, any, any, any>;
70+
* }
71+
* | {
72+
* input?: Type<S, any, any, any, any>;
73+
* type?: Type<S, any, any, any, any>;
6774
* typeInput?: any;
6875
* resolve?:
6976
* | ((options: {
@@ -73,7 +80,7 @@
7380
* path: string[];
7481
* query: Query;
7582
* schema: S;
76-
* type: Type<S>;
83+
* type: Type<S, any, any, any, any>;
7784
* value: Value;
7885
* }) => any)
7986
* | {}
@@ -90,7 +97,7 @@
9097
* path: string[];
9198
* query: Query;
9299
* schema: S;
93-
* type: Type<S>;
100+
* type: Type<S, any, any, any, any>;
94101
* value: Value;
95102
* }) => number);
96103
* defaultValue?: any;
@@ -101,7 +108,7 @@
101108
* path: string[];
102109
* query: Query;
103110
* schema: S;
104-
* type: Type<S>;
111+
* type: Type<S, any, any, any, any>;
105112
* value: ResolvedValue;
106113
* }) => any;
107114
* } & SchemaExtensions<S>)

src/validate-query.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @import {Query, Schema, Type} from '#src/index.js'; */
1+
/** @import {Schema, Query, Type} from '#src/index.js'; */
22

33
import { isObject } from '#src/is-object.js';
44
import { throwPaveError } from '#src/throw-pave-error.js';
@@ -15,7 +15,7 @@ const skipInput = {};
1515
* path?: string[];
1616
* query: Query;
1717
* schema: S;
18-
* type: Type<S>;
18+
* type: Type<S, any, any, any, any>;
1919
* }} options
2020
* @returns {Query}
2121
*/

src/validate-value.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @import {Query, Schema, Type} from '#src/index.js'; */
1+
/** @import {Schema, Query, Type} from '#src/index.js'; */
22

33
import { Context } from '#src/context.js';
44
import { isObject } from '#src/is-object.js';
@@ -14,7 +14,7 @@ const { isArray } = Array;
1414
* path?: string[];
1515
* query?: Query;
1616
* schema: S;
17-
* type: Type<S>;
17+
* type: Type<S, any, any, any, any>;
1818
* value?: any;
1919
* }} options
2020
*/

types/execute.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function execute<S extends Schema<any, any, any>>({ context, object, path
44
path?: string[];
55
query: Query;
66
schema: S;
7-
type: Type<S>;
7+
type: Type<S, any, any, any, any>;
88
value?: any;
99
}): Promise<any>;
1010
import type { Schema } from '#types/index.js';

types/get-query-cost.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export function getQueryCost<S extends Schema<any, any, any>>({ context, path, q
33
path?: string[];
44
query: Query;
55
schema: S;
6-
type: Type<S>;
6+
type: Type<S, any, any, any, any>;
77
}): any;
88
import type { Schema } from '#types/index.js';
99
import type { SchemaContext } from '#types/index.js';

types/index.d.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@ export type Query<T = any> = {
1818
};
1919
export type Recursive<T> = T | RecursiveArray<T>;
2020
export type RecursiveArray<T> = Recursive<T>[];
21-
export type Schema<TypeName extends string = never, Context = unknown, Extensions extends {
21+
export type Schema<TypeName extends string = "", Context = unknown, Extensions extends {
2222
[K: string]: any;
2323
} = {}> = { [K in TypeName]: Type<Schema<TypeName, Context, Extensions>, any, any, any, any>; };
2424
export type SchemaTypeName<S extends Schema<any, any, any>> = S extends Schema<infer TypeName, infer _, infer __> ? TypeName : never;
2525
export type SchemaContext<S extends Schema<any, any, any>> = S extends Schema<infer _, infer Context, infer __> ? Context : never;
2626
export type SchemaExtensions<S extends Schema<any, any, any>> = S extends Schema<infer _, infer __, infer Extensions> ? Extensions : never;
27-
export type Type<S extends Schema<any, any, any> = Schema<never, unknown, {}>, Input = unknown, Object = unknown, Value = unknown, ResolvedValue = {}> = Recursive<SchemaTypeName<S> | (({
28-
optional: Type<S>;
27+
export type Type<S extends Schema<any, any, any> = Schema<"", unknown, {}>, Input = unknown, Object = unknown, Value = unknown, ResolvedValue = {}> = Recursive<SchemaTypeName<S> | (({
28+
optional: Type<S, any, any, any, any>;
2929
} | {
30-
nullable: Type<S>;
30+
nullable: Type<S, any, any, any, any>;
3131
} | {
32-
arrayOf: Type<S>;
32+
arrayOf: Type<S, any, any, any, any>;
3333
minLength?: number;
3434
maxLength?: number;
3535
} | {
3636
oneOf: {
37-
[K: string]: Type<S>;
37+
[K: string]: Type<S, any, any, any, any>;
3838
};
3939
resolveType: (value: {}) => string;
4040
} | {
4141
object: {
42-
[K: string]: Type<S>;
42+
[K: string]: Type<S, any, any, any, any>;
4343
};
44-
defaultType?: Type<S>;
44+
defaultType?: Type<S, any, any, any, any>;
4545
} | {
46-
input?: Type<S>;
47-
type?: Type<S>;
46+
input?: Type<S, any, any, any, any>;
47+
type?: Type<S, any, any, any, any>;
4848
typeInput?: any;
4949
resolve?: ((options: {
5050
context: SchemaContext<S>;
@@ -53,7 +53,7 @@ export type Type<S extends Schema<any, any, any> = Schema<never, unknown, {}>, I
5353
path: string[];
5454
query: Query;
5555
schema: S;
56-
type: Type<S>;
56+
type: Type<S, any, any, any, any>;
5757
value: Value;
5858
}) => any) | {} | null;
5959
}) & {
@@ -65,7 +65,7 @@ export type Type<S extends Schema<any, any, any> = Schema<never, unknown, {}>, I
6565
path: string[];
6666
query: Query;
6767
schema: S;
68-
type: Type<S>;
68+
type: Type<S, any, any, any, any>;
6969
value: Value;
7070
}) => number);
7171
defaultValue?: any;
@@ -76,7 +76,7 @@ export type Type<S extends Schema<any, any, any> = Schema<never, unknown, {}>, I
7676
path: string[];
7777
query: Query;
7878
schema: S;
79-
type: Type<S>;
79+
type: Type<S, any, any, any, any>;
8080
value: ResolvedValue;
8181
}) => any;
8282
} & SchemaExtensions<S>)>;

0 commit comments

Comments
 (0)