ddd-ts-kit 0.12.0 → 0.13.0
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/README.md +13 -2
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +4 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/explain/rule-docs.d.ts.map +1 -1
- package/dist/check/explain/rule-docs.js +2 -0
- package/dist/check/explain/rule-docs.js.map +1 -1
- package/dist/check/explain/schema-docs.d.ts +3 -0
- package/dist/check/explain/schema-docs.d.ts.map +1 -0
- package/dist/check/explain/schema-docs.js +28 -0
- package/dist/check/explain/schema-docs.js.map +1 -0
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +2 -0
- package/dist/check/fixtures/fixtures.js.map +1 -1
- package/dist/check/fixtures/schema-fixtures.d.ts +3 -0
- package/dist/check/fixtures/schema-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/schema-fixtures.js +129 -0
- package/dist/check/fixtures/schema-fixtures.js.map +1 -0
- package/dist/check/rules/schema-no-duplicate-shape.d.ts +3 -0
- package/dist/check/rules/schema-no-duplicate-shape.d.ts.map +1 -0
- package/dist/check/rules/schema-no-duplicate-shape.js +60 -0
- package/dist/check/rules/schema-no-duplicate-shape.js.map +1 -0
- package/dist/check/rules/schema-presentation-only.d.ts +3 -0
- package/dist/check/rules/schema-presentation-only.d.ts.map +1 -0
- package/dist/check/rules/schema-presentation-only.js +53 -0
- package/dist/check/rules/schema-presentation-only.js.map +1 -0
- package/dist/check/schemas/class-shapes.d.ts +9 -0
- package/dist/check/schemas/class-shapes.d.ts.map +1 -0
- package/dist/check/schemas/class-shapes.js +52 -0
- package/dist/check/schemas/class-shapes.js.map +1 -0
- package/dist/check/schemas/declared-shape.d.ts +9 -0
- package/dist/check/schemas/declared-shape.d.ts.map +1 -0
- package/dist/check/schemas/declared-shape.js +2 -0
- package/dist/check/schemas/declared-shape.js.map +1 -0
- package/dist/check/schemas/holds-schemas.d.ts +5 -0
- package/dist/check/schemas/holds-schemas.d.ts.map +1 -0
- package/dist/check/schemas/holds-schemas.js +12 -0
- package/dist/check/schemas/holds-schemas.js.map +1 -0
- package/dist/check/schemas/object-shapes.d.ts +8 -0
- package/dist/check/schemas/object-shapes.d.ts.map +1 -0
- package/dist/check/schemas/object-shapes.js +31 -0
- package/dist/check/schemas/object-shapes.js.map +1 -0
- package/dist/check/schemas/restored-code.d.ts +7 -0
- package/dist/check/schemas/restored-code.d.ts.map +1 -0
- package/dist/check/schemas/restored-code.js +17 -0
- package/dist/check/schemas/restored-code.js.map +1 -0
- package/dist/check/schemas/shared-presentation.d.ts +4 -0
- package/dist/check/schemas/shared-presentation.d.ts.map +1 -0
- package/dist/check/schemas/shared-presentation.js +5 -0
- package/dist/check/schemas/shared-presentation.js.map +1 -0
- package/dist/check/schemas/shares-schemas.d.ts +4 -0
- package/dist/check/schemas/shares-schemas.d.ts.map +1 -0
- package/dist/check/schemas/shares-schemas.js +5 -0
- package/dist/check/schemas/shares-schemas.js.map +1 -0
- package/dist/check/schemas/still-generated.d.ts +8 -0
- package/dist/check/schemas/still-generated.d.ts.map +1 -0
- package/dist/check/schemas/still-generated.js +11 -0
- package/dist/check/schemas/still-generated.js.map +1 -0
- package/dist/check/schemas/top-level-statements.d.ts +3 -0
- package/dist/check/schemas/top-level-statements.d.ts.map +1 -0
- package/dist/check/schemas/top-level-statements.js +21 -0
- package/dist/check/schemas/top-level-statements.js.map +1 -0
- package/dist/check/schemas/validation-packages.d.ts +3 -0
- package/dist/check/schemas/validation-packages.d.ts.map +1 -0
- package/dist/check/schemas/validation-packages.js +13 -0
- package/dist/check/schemas/validation-packages.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/config/default-allowed-packages.d.ts.map +1 -1
- package/dist/config/default-allowed-packages.js +1 -0
- package/dist/config/default-allowed-packages.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/parse-stack.d.ts.map +1 -1
- package/dist/config/parse-stack.js +2 -1
- package/dist/config/parse-stack.js.map +1 -1
- package/dist/config/stack.d.ts +11 -2
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +3 -2
- package/dist/config/stack.js.map +1 -1
- package/dist/generate/kinds/route/controller-imports.d.ts.map +1 -1
- package/dist/generate/kinds/route/controller-imports.js +2 -1
- package/dist/generate/kinds/route/controller-imports.js.map +1 -1
- package/dist/generate/kinds/route/controller-types.d.ts.map +1 -1
- package/dist/generate/kinds/route/controller-types.js +4 -2
- package/dist/generate/kinds/route/controller-types.js.map +1 -1
- package/dist/generate/kinds/route/controller-vars.d.ts.map +1 -1
- package/dist/generate/kinds/route/controller-vars.js +21 -9
- package/dist/generate/kinds/route/controller-vars.js.map +1 -1
- package/dist/generate/kinds/route/dto-classes.d.ts +5 -2
- package/dist/generate/kinds/route/dto-classes.d.ts.map +1 -1
- package/dist/generate/kinds/route/dto-classes.js +6 -3
- package/dist/generate/kinds/route/dto-classes.js.map +1 -1
- package/dist/generate/kinds/route/route-vars.d.ts.map +1 -1
- package/dist/generate/kinds/route/route-vars.js +17 -4
- package/dist/generate/kinds/route/route-vars.js.map +1 -1
- package/dist/generate/kinds/route/search-line-libraries.d.ts +3 -0
- package/dist/generate/kinds/route/search-line-libraries.d.ts.map +1 -0
- package/dist/generate/kinds/route/search-line-libraries.js +3 -0
- package/dist/generate/kinds/route/search-line-libraries.js.map +1 -0
- package/dist/generate/kinds/route/shares-schemas.d.ts +4 -0
- package/dist/generate/kinds/route/shares-schemas.d.ts.map +1 -0
- package/dist/generate/kinds/route/shares-schemas.js +5 -0
- package/dist/generate/kinds/route/shares-schemas.js.map +1 -0
- package/dist/generate/kinds/route/write-controller.d.ts.map +1 -1
- package/dist/generate/kinds/route/write-controller.js +4 -2
- package/dist/generate/kinds/route/write-controller.js.map +1 -1
- package/dist/generate/kinds/route-kind.d.ts.map +1 -1
- package/dist/generate/kinds/route-kind.js +4 -2
- package/dist/generate/kinds/route-kind.js.map +1 -1
- package/dist/generate/kinds/schema-kind.d.ts +3 -0
- package/dist/generate/kinds/schema-kind.d.ts.map +1 -0
- package/dist/generate/kinds/schema-kind.js +36 -0
- package/dist/generate/kinds/schema-kind.js.map +1 -0
- package/dist/generate/kinds.d.ts.map +1 -1
- package/dist/generate/kinds.js +2 -0
- package/dist/generate/kinds.js.map +1 -1
- package/dist/generate/shared-writes.d.ts.map +1 -1
- package/dist/generate/shared-writes.js +5 -0
- package/dist/generate/shared-writes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +3 -1
- package/dist/help/usage.js.map +1 -1
- package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
- package/dist/init/manifest/dependencies-for.js +2 -0
- package/dist/init/manifest/dependencies-for.js.map +1 -1
- package/dist/init/manifest/versions.d.ts.map +1 -1
- package/dist/init/manifest/versions.js +27 -24
- package/dist/init/manifest/versions.js.map +1 -1
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +4 -2
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +1 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/init/validation-dependencies.d.ts.map +1 -1
- package/dist/init/validation-dependencies.js +1 -0
- package/dist/init/validation-dependencies.js.map +1 -1
- package/dist/stack/stack-vars.js +6 -5
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/templates/controller/controller.class-validator.ts.tpl +2 -2
- package/templates/controller/controller.none.ts.tpl +2 -2
- package/templates/controller/controller.search.ts.tpl +14 -0
- package/templates/controller/controller.standard-schema.ts.tpl +2 -2
- package/templates/controller/controller.typebox.ts.tpl +98 -0
- package/templates/controller/controller.zod.ts.tpl +2 -2
- package/templates/init/platform/http/start-http-server.hono.ts.tpl +84 -0
- package/templates/init/rules/presentation.md.tpl +3 -0
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/route/route.class-validator.ts.tpl +3 -3
- package/templates/route/route.none.ts.tpl +3 -3
- package/templates/route/route.search.ts.tpl +14 -0
- package/templates/route/route.standard-schema.ts.tpl +3 -3
- package/templates/route/route.typebox.ts.tpl +79 -0
- package/templates/route/route.zod.ts.tpl +3 -3
- package/templates/schema/schema.class-validator.ts.tpl +3 -0
- package/templates/schema/schema.custom.ts.tpl +14 -0
- package/templates/schema/schema.typebox.ts.tpl +8 -0
- package/templates/schema/schema.zod.ts.tpl +7 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{{#if route.protected}}
|
|
2
2
|
import { actorOf } from '@ddd-ts-kit/auth';
|
|
3
3
|
{{/if}}
|
|
4
|
-
import { defineRoute, type Route } from '@ddd-ts-kit/http';
|
|
4
|
+
import { {{#if route.sharedAccepted}}acceptedSchema, {{/if}}defineRoute, type Route } from '@ddd-ts-kit/http';
|
|
5
5
|
{{#if route.usesSchema}}
|
|
6
6
|
import { err, ok, type {{route.busType}} } from '@ddd-ts-kit/kernel';
|
|
7
7
|
import { customSchema } from '@ddd-ts-kit/validation';
|
|
@@ -26,7 +26,7 @@ const anyObject = customSchema<Record<string, unknown>>(
|
|
|
26
26
|
const body = anyObject;
|
|
27
27
|
|
|
28
28
|
{{/if}}
|
|
29
|
-
{{#if route.
|
|
29
|
+
{{#if route.ownAccepted}}
|
|
30
30
|
const accepted = customSchema<{ readonly id: string }>(
|
|
31
31
|
(input) =>
|
|
32
32
|
typeof input === 'object' && input !== null && 'id' in input && typeof input.id === 'string'
|
|
@@ -53,7 +53,7 @@ export function {{name.camel}}Route({{route.bus}}: {{route.busType}}): Route {
|
|
|
53
53
|
request: { body },
|
|
54
54
|
{{/if}}
|
|
55
55
|
{{#if route.returnsId}}
|
|
56
|
-
responses: { {{route.status}}: { description: 'Done; the body carries the identifier.', body:
|
|
56
|
+
responses: { {{route.status}}: { description: 'Done; the body carries the identifier.', body: {{route.acceptedBody}} } },
|
|
57
57
|
{{/if}}
|
|
58
58
|
{{#if route.returnsNothing}}
|
|
59
59
|
responses: { {{route.status}}: { description: 'Done.' } },
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{{#if validation.zod}}
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
{{/if}}
|
|
4
|
+
{{#if validation.typebox}}
|
|
5
|
+
import Type from 'typebox';
|
|
6
|
+
{{/if}}
|
|
4
7
|
import { actorOf } from '@ddd-ts-kit/auth';
|
|
5
8
|
import { defineRoute, pageQuerySchema, pageResponse, pageSchemaOf, type Route } from '@ddd-ts-kit/http';
|
|
6
9
|
{{#if search.customSchema}}
|
|
@@ -16,6 +19,9 @@ import { zodSchema } from '@ddd-ts-kit/validation/zod';
|
|
|
16
19
|
{{#if validation.classValidator}}
|
|
17
20
|
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
18
21
|
{{/if}}
|
|
22
|
+
{{#if validation.typebox}}
|
|
23
|
+
import { typeboxSchema } from '@ddd-ts-kit/validation/typebox';
|
|
24
|
+
{{/if}}
|
|
19
25
|
{{route.useCaseImport}}
|
|
20
26
|
{{#if validation.classValidator}}
|
|
21
27
|
import { {{name.pascal}}Line } from '{{alias.context}}/presentation/http/{{name.kebab}}-line.dto{{alias.ext}}';
|
|
@@ -36,6 +42,14 @@ const line = zodSchema(
|
|
|
36
42
|
{{#if validation.classValidator}}
|
|
37
43
|
const line = classSchema({{name.pascal}}Line);
|
|
38
44
|
{{/if}}
|
|
45
|
+
{{#if validation.typebox}}
|
|
46
|
+
const line = typeboxSchema(
|
|
47
|
+
Type.Object({
|
|
48
|
+
id: Type.String(),
|
|
49
|
+
// TODO(domain): declare the fields of {{name.pascal}}Item that are part of the public contract.
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
{{/if}}
|
|
39
53
|
{{#if search.customSchema}}
|
|
40
54
|
interface {{name.pascal}}Line {
|
|
41
55
|
readonly id: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{{#if route.protected}}
|
|
2
2
|
import { actorOf } from '@ddd-ts-kit/auth';
|
|
3
3
|
{{/if}}
|
|
4
|
-
import { defineRoute, type Route } from '@ddd-ts-kit/http';
|
|
4
|
+
import { {{#if route.sharedAccepted}}acceptedSchema, {{/if}}defineRoute, type Route } from '@ddd-ts-kit/http';
|
|
5
5
|
import type { {{route.busType}} } from '@ddd-ts-kit/kernel';
|
|
6
6
|
{{#if route.usesSchema}}
|
|
7
7
|
import { standardSchema, type StandardSchemaV1 } from '@ddd-ts-kit/validation/standard-schema';
|
|
@@ -26,7 +26,7 @@ const anyObject: StandardSchemaV1<unknown, Record<string, unknown>> = {
|
|
|
26
26
|
const body = standardSchema(anyObject, { type: 'object' });
|
|
27
27
|
|
|
28
28
|
{{/if}}
|
|
29
|
-
{{#if route.
|
|
29
|
+
{{#if route.ownAccepted}}
|
|
30
30
|
const acceptedShape: StandardSchemaV1<unknown, { readonly id: string }> = {
|
|
31
31
|
'~standard': {
|
|
32
32
|
version: 1,
|
|
@@ -62,7 +62,7 @@ export function {{name.camel}}Route({{route.bus}}: {{route.busType}}): Route {
|
|
|
62
62
|
request: { body },
|
|
63
63
|
{{/if}}
|
|
64
64
|
{{#if route.returnsId}}
|
|
65
|
-
responses: { {{route.status}}: { description: 'Done; the body carries the identifier.', body:
|
|
65
|
+
responses: { {{route.status}}: { description: 'Done; the body carries the identifier.', body: {{route.acceptedBody}} } },
|
|
66
66
|
{{/if}}
|
|
67
67
|
{{#if route.returnsNothing}}
|
|
68
68
|
responses: { {{route.status}}: { description: 'Done.' } },
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import Type from 'typebox';
|
|
2
|
+
{{#if route.protected}}
|
|
3
|
+
import { actorOf } from '@ddd-ts-kit/auth';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { {{#if route.sharedAccepted}}acceptedSchema, {{/if}}defineRoute, type Route } from '@ddd-ts-kit/http';
|
|
6
|
+
import type { {{route.busType}} } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { typeboxSchema } from '@ddd-ts-kit/validation/typebox';
|
|
8
|
+
{{route.useCaseImport}}
|
|
9
|
+
|
|
10
|
+
{{#if route.hasParams}}
|
|
11
|
+
const params = typeboxSchema(Type.Object({ {{route.typeboxParams}} }));
|
|
12
|
+
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if route.hasBody}}
|
|
15
|
+
const body = typeboxSchema(
|
|
16
|
+
Type.Object({
|
|
17
|
+
// TODO(domain): declare the fields the client sends for "{{name.words}}", with shape constraints only (types, formats, lengths); business rules stay in the domain.
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if route.ownAccepted}}
|
|
23
|
+
const accepted = typeboxSchema(Type.Object({ id: Type.String() }));
|
|
24
|
+
|
|
25
|
+
{{/if}}
|
|
26
|
+
{{#if route.isQuery}}
|
|
27
|
+
const answer = typeboxSchema(
|
|
28
|
+
Type.Object({
|
|
29
|
+
// TODO(domain): declare the fields of {{name.pascal}}Result that are part of the public contract.
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
{{/if}}
|
|
34
|
+
export function {{name.camel}}Route({{route.bus}}: {{route.busType}}): Route {
|
|
35
|
+
return defineRoute(
|
|
36
|
+
{
|
|
37
|
+
method: '{{route.method}}',
|
|
38
|
+
path: '{{route.path}}',
|
|
39
|
+
operationId: '{{name.camel}}',
|
|
40
|
+
summary: '{{name.title}}',
|
|
41
|
+
tags: ['{{context.kebab}}'],
|
|
42
|
+
{{#if route.hasRequest}}
|
|
43
|
+
request: { {{route.requestParts}} },
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{#if route.returnsId}}
|
|
46
|
+
responses: { {{route.status}}: { description: 'Done; the body carries the identifier.', body: {{route.acceptedBody}} } },
|
|
47
|
+
{{/if}}
|
|
48
|
+
{{#if route.returnsNothing}}
|
|
49
|
+
responses: { {{route.status}}: { description: 'Done.' } },
|
|
50
|
+
{{/if}}
|
|
51
|
+
{{#if route.isQuery}}
|
|
52
|
+
responses: { {{route.status}}: { description: 'The answer.', body: answer } },
|
|
53
|
+
{{/if}}
|
|
54
|
+
// TODO(domain): list the codes of the refusals "{{name.words}}" can raise, as their factories set them, so that they appear in the contract with their status (`errors/known-code`).
|
|
55
|
+
errors: [{{route.errorCodes}}],
|
|
56
|
+
security: {{route.security}},
|
|
57
|
+
},
|
|
58
|
+
async (input) => {
|
|
59
|
+
{{#if route.isQuery}}
|
|
60
|
+
// TODO(domain): build the query from `input` (params, query string); the actor is already there and map its answer to the public fields.
|
|
61
|
+
await {{route.bus}}.execute(new {{route.input}}({{route.actor}}));
|
|
62
|
+
|
|
63
|
+
return { status: {{route.status}}, body: {} };
|
|
64
|
+
{{/if}}
|
|
65
|
+
{{#if route.returnsId}}
|
|
66
|
+
// TODO(domain): build the command from `input` (body, params); the actor is already there.
|
|
67
|
+
const id = await {{route.bus}}.execute(new {{route.input}}({{route.actor}}));
|
|
68
|
+
|
|
69
|
+
return { status: {{route.status}}, body: { id } };
|
|
70
|
+
{{/if}}
|
|
71
|
+
{{#if route.returnsNothing}}
|
|
72
|
+
// TODO(domain): build the command from `input` (body, params); the actor is already there.
|
|
73
|
+
await {{route.bus}}.execute(new {{route.input}}({{route.actor}}));
|
|
74
|
+
|
|
75
|
+
return { status: {{route.status}} };
|
|
76
|
+
{{/if}}
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
{{#if route.protected}}
|
|
3
3
|
import { actorOf } from '@ddd-ts-kit/auth';
|
|
4
4
|
{{/if}}
|
|
5
|
-
import { defineRoute, type Route } from '@ddd-ts-kit/http';
|
|
5
|
+
import { {{#if route.sharedAccepted}}acceptedSchema, {{/if}}defineRoute, type Route } from '@ddd-ts-kit/http';
|
|
6
6
|
import type { {{route.busType}} } from '@ddd-ts-kit/kernel';
|
|
7
7
|
import { zodSchema } from '@ddd-ts-kit/validation/zod';
|
|
8
8
|
{{route.useCaseImport}}
|
|
@@ -19,7 +19,7 @@ const body = zodSchema(
|
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
{{/if}}
|
|
22
|
-
{{#if route.
|
|
22
|
+
{{#if route.ownAccepted}}
|
|
23
23
|
const accepted = zodSchema(z.object({ id: z.string() }), { io: 'output' });
|
|
24
24
|
|
|
25
25
|
{{/if}}
|
|
@@ -44,7 +44,7 @@ export function {{name.camel}}Route({{route.bus}}: {{route.busType}}): Route {
|
|
|
44
44
|
request: { {{route.requestParts}} },
|
|
45
45
|
{{/if}}
|
|
46
46
|
{{#if route.returnsId}}
|
|
47
|
-
responses: { {{route.status}}: { description: 'Done; the body carries the identifier.', body:
|
|
47
|
+
responses: { {{route.status}}: { description: 'Done; the body carries the identifier.', body: {{route.acceptedBody}} } },
|
|
48
48
|
{{/if}}
|
|
49
49
|
{{#if route.returnsNothing}}
|
|
50
50
|
responses: { {{route.status}}: { description: 'Done.' } },
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export class {{name.pascal}} {
|
|
2
|
+
// TODO(domain): declare the fields of "{{name.words}}" as a client sees them, each with its class-validator decorators (shape constraints only). A route uses the class whole (`classSchema({{name.pascal}}, { shared: true })`), nested (`@ValidateNested()` and `@Type`) or in part (`class Body extends pickClass({{name.pascal}}, [...]) {}`, `omitClass`, `partialClass`); the contract documents it once, as {{name.pascal}}.
|
|
3
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { err, ok } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { customSchema, sharedSchema } from '@ddd-ts-kit/validation';
|
|
3
|
+
|
|
4
|
+
// TODO(domain): replace the object check by the schema of "{{name.words}}" written with the validation library of the project, wrapped as it is here, and describe its fields in the JSON Schema; the contract documents it once, as {{name.pascal}}.
|
|
5
|
+
export const {{name.camel}}Schema = sharedSchema(
|
|
6
|
+
'{{name.pascal}}',
|
|
7
|
+
customSchema<Record<string, unknown>>(
|
|
8
|
+
(input) =>
|
|
9
|
+
typeof input === 'object' && input !== null && !Array.isArray(input)
|
|
10
|
+
? ok({ ...input })
|
|
11
|
+
: err([{ path: '', code: 'invalid_type', message: 'An object is expected.' }]),
|
|
12
|
+
{ type: 'object' },
|
|
13
|
+
),
|
|
14
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Type from 'typebox';
|
|
2
|
+
|
|
3
|
+
export const {{name.camel}}Schema = Type.Object(
|
|
4
|
+
{
|
|
5
|
+
// TODO(domain): declare the fields of "{{name.words}}" as a client sees them, with shape constraints only (types, formats, lengths). A route uses the schema whole (`typeboxSchema({{name.camel}}Schema)`), inside another one, in part (`Type.Pick`, `Type.Omit`, `Type.Partial`) or extended (`Type.Intersect([{{name.camel}}Schema, Type.Object({...})])` keeps the reference); the contract documents it once, as {{name.pascal}}.
|
|
6
|
+
},
|
|
7
|
+
{ $id: '{{name.pascal}}' },
|
|
8
|
+
);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const {{name.camel}}Schema = z
|
|
4
|
+
.object({
|
|
5
|
+
// TODO(domain): declare the fields of "{{name.words}}" as a client sees them, with shape constraints only (types, formats, lengths). A route uses the schema whole (`zodSchema({{name.camel}}Schema)`), inside another one, or in part (`.pick`, `.omit`, `.partial`, `.extend`); the contract documents it once, as {{name.pascal}}.
|
|
6
|
+
})
|
|
7
|
+
.meta({ id: '{{name.pascal}}' });
|