yedra 0.15.3 → 0.15.5
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/lib.d.ts +1 -0
- package/dist/lib.js +1 -0
- package/dist/routing/rest.js +2 -1
- package/dist/validation/modifiable.d.ts +0 -9
- package/dist/validation/modifiable.js +0 -8
- package/dist/validation/null.d.ts +10 -0
- package/dist/validation/null.js +21 -0
- package/package.json +3 -3
package/dist/lib.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { array } from './validation/array.js';
|
|
|
6
6
|
export { boolean } from './validation/boolean.js';
|
|
7
7
|
export { date } from './validation/date.js';
|
|
8
8
|
export { _enum as enum } from './validation/enum.js';
|
|
9
|
+
export { _null as null } from './validation/null.js';
|
|
9
10
|
export { ValidationError } from './validation/error.js';
|
|
10
11
|
export { number } from './validation/number.js';
|
|
11
12
|
export { integer } from './validation/integer.js';
|
package/dist/lib.js
CHANGED
|
@@ -11,6 +11,7 @@ export { array } from './validation/array.js';
|
|
|
11
11
|
export { boolean } from './validation/boolean.js';
|
|
12
12
|
export { date } from './validation/date.js';
|
|
13
13
|
export { _enum as enum } from './validation/enum.js';
|
|
14
|
+
export { _null as null } from './validation/null.js';
|
|
14
15
|
export { ValidationError } from './validation/error.js';
|
|
15
16
|
export { number } from './validation/number.js';
|
|
16
17
|
export { integer } from './validation/integer.js';
|
package/dist/routing/rest.js
CHANGED
|
@@ -11,7 +11,8 @@ class ConcreteRestEndpoint extends RestEndpoint {
|
|
|
11
11
|
this._method = method;
|
|
12
12
|
this.options = options;
|
|
13
13
|
this.paramsSchema = object(options.params);
|
|
14
|
-
|
|
14
|
+
// queries can sometimes include other elements for application-unrelated reasons
|
|
15
|
+
this.querySchema = laxObject(options.query);
|
|
15
16
|
// headers need to be lax, since there are lots of them
|
|
16
17
|
this.headersSchema = laxObject(options.headers);
|
|
17
18
|
}
|
|
@@ -6,15 +6,6 @@ export declare abstract class ModifiableSchema<T> extends Schema<T> {
|
|
|
6
6
|
* Mark this schema as optional.
|
|
7
7
|
*/
|
|
8
8
|
optional(): OptionalSchema<T>;
|
|
9
|
-
/**
|
|
10
|
-
* Add a description and example to the schema.
|
|
11
|
-
* @param doc - The documentation.
|
|
12
|
-
* @deprecated - Use .describe() instead.
|
|
13
|
-
*/
|
|
14
|
-
doc(doc: {
|
|
15
|
-
description: string;
|
|
16
|
-
example?: T;
|
|
17
|
-
}): DocSchema<T>;
|
|
18
9
|
describe(description: string, example?: T): DocSchema<T>;
|
|
19
10
|
array(): ArraySchema<Schema<T>>;
|
|
20
11
|
}
|
|
@@ -7,14 +7,6 @@ export class ModifiableSchema extends Schema {
|
|
|
7
7
|
optional() {
|
|
8
8
|
return new OptionalSchema(this);
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Add a description and example to the schema.
|
|
12
|
-
* @param doc - The documentation.
|
|
13
|
-
* @deprecated - Use .describe() instead.
|
|
14
|
-
*/
|
|
15
|
-
doc(doc) {
|
|
16
|
-
return new DocSchema(this, doc.description, doc.example);
|
|
17
|
-
}
|
|
18
10
|
describe(description, example) {
|
|
19
11
|
return new DocSchema(this, description, example);
|
|
20
12
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModifiableSchema } from './modifiable.js';
|
|
2
|
+
declare class NullSchema extends ModifiableSchema<null> {
|
|
3
|
+
parse(obj: unknown): null;
|
|
4
|
+
documentation(): object;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A schema that matches only null.
|
|
8
|
+
*/
|
|
9
|
+
export declare const _null: () => NullSchema;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Issue, ValidationError } from './error.js';
|
|
2
|
+
import { ModifiableSchema } from './modifiable.js';
|
|
3
|
+
class NullSchema extends ModifiableSchema {
|
|
4
|
+
parse(obj) {
|
|
5
|
+
if (obj !== null) {
|
|
6
|
+
throw new ValidationError([
|
|
7
|
+
new Issue([], `Expected null but got ${typeof obj}`),
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
documentation() {
|
|
13
|
+
return {
|
|
14
|
+
type: 'null',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A schema that matches only null.
|
|
20
|
+
*/
|
|
21
|
+
export const _null = () => new NullSchema();
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yedra",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5",
|
|
4
4
|
"repository": "github:0codekit/yedra",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@biomejs/biome": "^1.9.4",
|
|
8
|
-
"@types/bun": "^1.2.
|
|
9
|
-
"@types/node": "^
|
|
8
|
+
"@types/bun": "^1.2.16",
|
|
9
|
+
"@types/node": "^24.0.1",
|
|
10
10
|
"@types/uuid": "^10.0.0",
|
|
11
11
|
"@types/ws": "^8.18.1",
|
|
12
12
|
"typescript": "^5.8.3"
|