vovk-cli 0.0.1-beta.50 → 0.0.1-beta.51
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/init/index.mjs +0 -7
- package/module-templates/arktype/controller.ts.ejs +6 -6
- package/module-templates/valibot/controller.ts.ejs +6 -6
- package/module-templates/zod/controller.ts.ejs +6 -6
- package/package.json +2 -2
- package/dist/init/createStandardSchemaValidatorFile.d.mts +0 -10
- package/dist/init/createStandardSchemaValidatorFile.mjs +0 -56
package/dist/init/index.mjs
CHANGED
|
@@ -14,7 +14,6 @@ import { updateTypeScriptConfig } from './updateTypeScriptConfig.mjs';
|
|
|
14
14
|
import { updateDependenciesWithoutInstalling } from './updateDependenciesWithoutInstalling.mjs';
|
|
15
15
|
import { logUpdateDependenciesError } from './logUpdateDependenciesError.mjs';
|
|
16
16
|
import { chalkHighlightThing } from '../utils/chalkHighlightThing.mjs';
|
|
17
|
-
import { createStandardSchemaValidatorFile } from './createStandardSchemaValidatorFile.mjs';
|
|
18
17
|
export class Init {
|
|
19
18
|
root;
|
|
20
19
|
log;
|
|
@@ -111,12 +110,6 @@ export class Init {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
|
-
if (validationLibrary === 'valibot' || validationLibrary === 'arktype' || validationLibrary === 'zod') {
|
|
115
|
-
createStandardSchemaValidatorFile({
|
|
116
|
-
root,
|
|
117
|
-
validationLibrary,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
113
|
try {
|
|
121
114
|
const { configAbsolutePath } = await createConfig({
|
|
122
115
|
root,
|
|
@@ -9,7 +9,7 @@ sourceName: <%= vars.ModuleName %>
|
|
|
9
9
|
compiledName: <%= t.TheThing + 'RPC' %>
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { procedure, prefix, get, put, post, del, operation } from 'vovk';
|
|
13
13
|
import { type } from 'arktype';
|
|
14
14
|
<% if(t.withService) { %>
|
|
15
15
|
import <%= vars.ServiceName %> from './<%= vars.ServiceName %><%= t.nodeNextResolutionExt.ts %>';
|
|
@@ -21,7 +21,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
21
21
|
summary: 'Get <%= t.theThings %>',
|
|
22
22
|
})
|
|
23
23
|
@get()
|
|
24
|
-
static get<%= t.TheThings %> =
|
|
24
|
+
static get<%= t.TheThings %> = procedure({
|
|
25
25
|
handle() {
|
|
26
26
|
<% if(t.withService) { %>
|
|
27
27
|
return <%= vars.ServiceName %>.get<%= t.TheThings %>();
|
|
@@ -35,7 +35,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
35
35
|
summary: 'Get single <%= t.theThing %>',
|
|
36
36
|
})
|
|
37
37
|
@get('{id}')
|
|
38
|
-
static getSingle<%= t.TheThing %> =
|
|
38
|
+
static getSingle<%= t.TheThing %> = procedure({
|
|
39
39
|
params: type({ id: type('string') }),
|
|
40
40
|
handle(_req, { id }) {
|
|
41
41
|
<% if(t.withService) { %>
|
|
@@ -50,7 +50,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
50
50
|
summary: 'Update <%= t.theThing %>',
|
|
51
51
|
})
|
|
52
52
|
@put('{id}')
|
|
53
|
-
static update<%= t.TheThing %> =
|
|
53
|
+
static update<%= t.TheThing %> = procedure({
|
|
54
54
|
body: type({ todo: type('true') }),
|
|
55
55
|
params: type({ id: type('string') }),
|
|
56
56
|
async handle(req, { id }) {
|
|
@@ -67,7 +67,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
67
67
|
summary: 'Create <%= t.theThing %>',
|
|
68
68
|
})
|
|
69
69
|
@post()
|
|
70
|
-
static create<%= t.TheThing %> =
|
|
70
|
+
static create<%= t.TheThing %> = procedure({
|
|
71
71
|
body: type({ todo: type('true') }),
|
|
72
72
|
async handle(req) {
|
|
73
73
|
const body = await req.json();
|
|
@@ -83,7 +83,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
83
83
|
summary: 'Delete <%= t.theThing %>',
|
|
84
84
|
})
|
|
85
85
|
@del('{id}')
|
|
86
|
-
static delete<%= t.TheThing %> =
|
|
86
|
+
static delete<%= t.TheThing %> = procedure({
|
|
87
87
|
params: type({ id: type('string') }),
|
|
88
88
|
handle(_req, params) {
|
|
89
89
|
const { id } = params;
|
|
@@ -9,7 +9,7 @@ sourceName: <%= vars.ModuleName %>
|
|
|
9
9
|
compiledName: <%= t.TheThing + 'RPC' %>
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { procedure, prefix, get, put, post, del, operation } from 'vovk';
|
|
13
13
|
import * as v from 'valibot';
|
|
14
14
|
import { toStandardJsonSchema } from '@valibot/to-json-schema';
|
|
15
15
|
<% if(t.withService) { %>
|
|
@@ -22,7 +22,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
22
22
|
summary: 'Get <%= t.theThings %>',
|
|
23
23
|
})
|
|
24
24
|
@get()
|
|
25
|
-
static get<%= t.TheThings %> =
|
|
25
|
+
static get<%= t.TheThings %> = procedure({
|
|
26
26
|
handle() {
|
|
27
27
|
<% if(t.withService) { %>
|
|
28
28
|
return <%= vars.ServiceName %>.get<%= t.TheThings %>();
|
|
@@ -36,7 +36,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
36
36
|
summary: 'Get single <%= t.theThing %>',
|
|
37
37
|
})
|
|
38
38
|
@get('{id}')
|
|
39
|
-
static getSingle<%= t.TheThing %> =
|
|
39
|
+
static getSingle<%= t.TheThing %> = procedure({
|
|
40
40
|
params: toStandardJsonSchema(v.object({ id: v.string() })),
|
|
41
41
|
handle(_req, { id }) {
|
|
42
42
|
<% if(t.withService) { %>
|
|
@@ -51,7 +51,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
51
51
|
summary: 'Update <%= t.theThing %>',
|
|
52
52
|
})
|
|
53
53
|
@put('{id}')
|
|
54
|
-
static update<%= t.TheThing %> =
|
|
54
|
+
static update<%= t.TheThing %> = procedure({
|
|
55
55
|
body: toStandardJsonSchema(v.object({ todo: v.literal(true) })),
|
|
56
56
|
params: toStandardJsonSchema(v.object({ id: v.string() })),
|
|
57
57
|
async handle(req, { id }) {
|
|
@@ -68,7 +68,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
68
68
|
summary: 'Create <%= t.theThing %>',
|
|
69
69
|
})
|
|
70
70
|
@post()
|
|
71
|
-
static create<%= t.TheThing %> =
|
|
71
|
+
static create<%= t.TheThing %> = procedure({
|
|
72
72
|
body: toStandardJsonSchema(v.object({ todo: v.literal(true) })),
|
|
73
73
|
async handle(req) {
|
|
74
74
|
const body = await req.json();
|
|
@@ -84,7 +84,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
84
84
|
summary: 'Delete <%= t.theThing %>',
|
|
85
85
|
})
|
|
86
86
|
@del('{id}')
|
|
87
|
-
static delete<%= t.TheThing %> =
|
|
87
|
+
static delete<%= t.TheThing %> = procedure({
|
|
88
88
|
params: toStandardJsonSchema(v.object({ id: v.string() })),
|
|
89
89
|
handle(_req, { id }) {
|
|
90
90
|
<% if(t.withService) { %>
|
|
@@ -9,7 +9,7 @@ sourceName: <%= vars.ModuleName %>
|
|
|
9
9
|
compiledName: <%= t.TheThing + 'RPC' %>
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { procedure, prefix, get, put, post, del, operation } from 'vovk';
|
|
13
13
|
import { z } from 'zod';
|
|
14
14
|
<% if(t.withService) { %>
|
|
15
15
|
import <%= vars.ServiceName %> from './<%= vars.ServiceName %><%= t.nodeNextResolutionExt.ts %>';
|
|
@@ -21,7 +21,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
21
21
|
summary: 'Get <%= t.theThings %>',
|
|
22
22
|
})
|
|
23
23
|
@get()
|
|
24
|
-
static get<%= t.TheThings %> =
|
|
24
|
+
static get<%= t.TheThings %> = procedure({
|
|
25
25
|
handle() {
|
|
26
26
|
<% if(t.withService) { %>
|
|
27
27
|
return <%= vars.ServiceName %>.get<%= t.TheThings %>();
|
|
@@ -35,7 +35,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
35
35
|
summary: 'Get single <%= t.theThing %>',
|
|
36
36
|
})
|
|
37
37
|
@get('{id}')
|
|
38
|
-
static getSingle<%= t.TheThing %> =
|
|
38
|
+
static getSingle<%= t.TheThing %> = procedure({
|
|
39
39
|
params: z.object({
|
|
40
40
|
id: z.string(),
|
|
41
41
|
}),
|
|
@@ -52,7 +52,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
52
52
|
summary: 'Update <%= t.theThing %>',
|
|
53
53
|
})
|
|
54
54
|
@put('{id}')
|
|
55
|
-
static update<%= t.TheThing %> =
|
|
55
|
+
static update<%= t.TheThing %> = procedure({
|
|
56
56
|
body: z.object({
|
|
57
57
|
todo: z.literal(true),
|
|
58
58
|
}),
|
|
@@ -71,7 +71,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
71
71
|
summary: 'Create <%= t.theThing %>',
|
|
72
72
|
})
|
|
73
73
|
@post()
|
|
74
|
-
static create<%= t.TheThing %> =
|
|
74
|
+
static create<%= t.TheThing %> = procedure({
|
|
75
75
|
body: z.object({
|
|
76
76
|
todo: z.literal(true),
|
|
77
77
|
}),
|
|
@@ -89,7 +89,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
89
89
|
summary: 'Delete <%= t.theThing %>',
|
|
90
90
|
})
|
|
91
91
|
@del('{id}')
|
|
92
|
-
static delete<%= t.TheThing %> =
|
|
92
|
+
static delete<%= t.TheThing %> = procedure({
|
|
93
93
|
params: z.object({
|
|
94
94
|
id: z.string(),
|
|
95
95
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk-cli",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.51",
|
|
4
4
|
"bin": {
|
|
5
5
|
"vovk": "./dist/index.mjs"
|
|
6
6
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://vovk.dev",
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"vovk": "^3.0.0-beta.
|
|
38
|
+
"vovk": "^3.0.0-beta.59",
|
|
39
39
|
"vovk-ajv": "^0.0.0-beta.4",
|
|
40
40
|
"vovk-client": "^0.0.4-beta.4",
|
|
41
41
|
"vovk-python": "^0.0.1-beta.4",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const CODE_BY_LIBRARY: {
|
|
2
|
-
zod: string;
|
|
3
|
-
valibot: string;
|
|
4
|
-
arktype: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function createStandardSchemaValidatorFile({ root, validationLibrary, }: {
|
|
7
|
-
root: string;
|
|
8
|
-
validationLibrary: keyof typeof CODE_BY_LIBRARY;
|
|
9
|
-
}): Promise<void>;
|
|
10
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { getRelativeSrcRoot } from '../getProjectInfo/getConfig/getRelativeSrcRoot.mjs';
|
|
4
|
-
const CODE_BY_LIBRARY = {
|
|
5
|
-
zod: `import { z } from 'zod/v4';
|
|
6
|
-
import { createStandardValidation } from 'vovk';
|
|
7
|
-
|
|
8
|
-
export const withZod = createStandardValidation({
|
|
9
|
-
toJSONSchema: (model: z.core.$ZodType) => z.toJSONSchema(model),
|
|
10
|
-
});`,
|
|
11
|
-
valibot: `import { createStandardValidation } from 'vovk';
|
|
12
|
-
import { toJsonSchema } from '@valibot/to-json-schema';
|
|
13
|
-
|
|
14
|
-
export const withValibot = createStandardValidation({
|
|
15
|
-
toJSONSchema: (model) => toJsonSchema(model, {
|
|
16
|
-
overrideSchema(context) {
|
|
17
|
-
if (context.valibotSchema.type === 'file') {
|
|
18
|
-
return { type: 'string', format: 'binary' };
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
}),
|
|
22
|
-
});`,
|
|
23
|
-
arktype: `import { createStandardValidation } from 'vovk';
|
|
24
|
-
import type { type } from 'arktype';
|
|
25
|
-
|
|
26
|
-
export const withArk = createStandardValidation({
|
|
27
|
-
toJSONSchema: (model: type) => model.toJsonSchema({
|
|
28
|
-
fallback: {
|
|
29
|
-
proto: (ctx) => ctx.proto === File ? {
|
|
30
|
-
type: "string",
|
|
31
|
-
format: "binary",
|
|
32
|
-
} : ctx.base,
|
|
33
|
-
default: (ctx) => ctx.base
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
});`,
|
|
37
|
-
};
|
|
38
|
-
function getCode(validationLibrary) {
|
|
39
|
-
const code = CODE_BY_LIBRARY[validationLibrary];
|
|
40
|
-
if (!code)
|
|
41
|
-
throw new Error(`Unknown validation library: ${validationLibrary}`);
|
|
42
|
-
return code;
|
|
43
|
-
}
|
|
44
|
-
export async function createStandardSchemaValidatorFile({ root, validationLibrary, }) {
|
|
45
|
-
const code = getCode(validationLibrary);
|
|
46
|
-
const srcRoot = (await getRelativeSrcRoot({ cwd: root })) ?? '.';
|
|
47
|
-
const libDir = path.resolve(root, srcRoot, 'lib');
|
|
48
|
-
const filenameByLibrary = {
|
|
49
|
-
arktype: 'withArk.ts',
|
|
50
|
-
valibot: 'withValibot.ts',
|
|
51
|
-
zod: 'withZod.ts',
|
|
52
|
-
};
|
|
53
|
-
const filePath = path.join(libDir, filenameByLibrary[validationLibrary]);
|
|
54
|
-
await fs.mkdir(libDir, { recursive: true });
|
|
55
|
-
await fs.writeFile(filePath, code);
|
|
56
|
-
}
|