vovk-cli 0.0.1-draft.393 → 0.0.1-draft.394
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 +1 -1
- package/client-templates/ts/index.ts.ejs +3 -2
- package/dist/dev/index.mjs +1 -1
- package/dist/dev/writeMetaJson.mjs +1 -1
- package/dist/generate/ensureClient.mjs +1 -1
- package/dist/generate/getProjectFullSchema.mjs +1 -1
- package/dist/generate/getTemplateClientImports.mjs +0 -1
- package/dist/generate/writeOneClientFile.mjs +1 -1
- package/dist/getProjectInfo/getConfig/index.d.mts +2 -2
- package/dist/getProjectInfo/getConfig/index.mjs +8 -8
- package/dist/getProjectInfo/getMetaSchema.d.mts +2 -2
- package/dist/getProjectInfo/getMetaSchema.mjs +3 -3
- package/dist/index.mjs +1 -1
- package/dist/init/index.mjs +3 -11
- package/dist/init/installDependencies.d.mts +7 -5
- package/dist/init/installDependencies.mjs +3 -3
- package/dist/init/logUpdateDependenciesError.d.mts +3 -5
- package/dist/init/logUpdateDependenciesError.mjs +1 -3
- package/dist/new/newModule.mjs +2 -1
- package/dist/new/render.d.mts +2 -1
- package/dist/new/render.mjs +6 -3
- package/dist/types.d.mts +0 -1
- package/module-templates/arktype/controller.ts.ejs +17 -3
- package/module-templates/type/controller.ts.ejs +13 -1
- package/module-templates/type/service.ts.ejs +6 -0
- package/module-templates/valibot/controller.ts.ejs +18 -5
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -5,7 +5,8 @@ import { schema } from './schema<%= t.nodeNextResolutionExt.ts %>';
|
|
|
5
5
|
<% if(t.isBundle) { %>
|
|
6
6
|
import { openapi } from './openapi<%= t.nodeNextResolutionExt.ts %>';
|
|
7
7
|
<% } else { %>
|
|
8
|
-
//
|
|
8
|
+
// import { openapi } from './openapi<%= t.nodeNextResolutionExt.ts %>';
|
|
9
|
+
// TODO: This is a temporary fix for https://github.com/rolldown/tsdown/issues/528#issuecomment-3476284358
|
|
9
10
|
import openapi from './openapi.json' with { type: "json" };
|
|
10
11
|
<% } %>
|
|
11
12
|
<% Object.values(t.schema.segments).filter((segment) => segment.emitSchema).forEach((segment, i) => { if(segment.segmentType !== 'mixin') { %>
|
|
@@ -17,7 +18,7 @@ import type { Controllers as MixinControllers, Mixins } from "./mixins.d.ts";
|
|
|
17
18
|
<% } %>
|
|
18
19
|
<% Object.entries(t.reExports).forEach(([reExportWhat, reExportFrom]) => { %>
|
|
19
20
|
export { <%= reExportWhat %> } from '<%= reExportFrom %>';
|
|
20
|
-
<% }) %>
|
|
21
|
+
<% }) %>
|
|
21
22
|
<% Object.values(t.schema.segments).filter((segment) => segment.emitSchema).forEach((segment, i) => {
|
|
22
23
|
Object.keys(segment.controllers).forEach((rpcModuleName) => {
|
|
23
24
|
const apiRoot = t.segmentMeta[segment.segmentName].forceApiRoot ?? t.apiRoot; %>
|
package/dist/dev/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ export default async function writeMetaJson(schemaOutAbsolutePath, projectInfo)
|
|
|
7
7
|
const metaJsonPath = path.join(schemaOutAbsolutePath, META_FILE_NAME + '.json');
|
|
8
8
|
const metaStr = JSON.stringify(getMetaSchema({
|
|
9
9
|
config: projectInfo.config,
|
|
10
|
-
|
|
10
|
+
useexposeConfigKeys: true,
|
|
11
11
|
}), null, 2);
|
|
12
12
|
const existingStr = await fs.readFile(metaJsonPath, 'utf-8').catch(() => null);
|
|
13
13
|
if (existingStr !== metaStr) {
|
|
@@ -21,7 +21,7 @@ export default async function ensureClient(projectInfo, locatedSegments) {
|
|
|
21
21
|
fullSchema: {
|
|
22
22
|
$schema: VovkSchemaIdEnum.SCHEMA,
|
|
23
23
|
segments: getEmptySegmentRecordSchema(locatedSegments.map(({ segmentName }) => segmentName)),
|
|
24
|
-
meta: getMetaSchema({ config: projectInfo.config,
|
|
24
|
+
meta: getMetaSchema({ config: projectInfo.config, useexposeConfigKeys: false }),
|
|
25
25
|
},
|
|
26
26
|
locatedSegments,
|
|
27
27
|
});
|
|
@@ -11,7 +11,7 @@ export async function getProjectFullSchema({ schemaOutAbsolutePath, isNextInstal
|
|
|
11
11
|
segments: {},
|
|
12
12
|
meta: getMetaSchema({
|
|
13
13
|
config,
|
|
14
|
-
|
|
14
|
+
useexposeConfigKeys: false,
|
|
15
15
|
}),
|
|
16
16
|
};
|
|
17
17
|
const isEmptyLogOrWarn = isNextInstalled ? log.warn : log.debug;
|
|
@@ -4,7 +4,6 @@ import { ROOT_SEGMENT_FILE_NAME } from '../dev/writeOneSegmentSchemaFile.mjs';
|
|
|
4
4
|
export default function getTemplateClientImports({ config, fullSchema, outCwdRelativeDir, segmentName, isBundle, outputConfigs, }) {
|
|
5
5
|
const { imports: configImports } = resolveGeneratorConfigValues({
|
|
6
6
|
config,
|
|
7
|
-
schema: fullSchema,
|
|
8
7
|
segmentName,
|
|
9
8
|
isBundle,
|
|
10
9
|
projectPackageJson: undefined,
|
|
@@ -61,7 +61,7 @@ templateContent, matterResult: { data, content }, openAPIObject, package: packag
|
|
|
61
61
|
YAML,
|
|
62
62
|
TOML,
|
|
63
63
|
getFirstLineBanner,
|
|
64
|
-
publicMeta: getMetaSchema({ config: projectConfig,
|
|
64
|
+
publicMeta: getMetaSchema({ config: projectConfig, useexposeConfigKeys: true }),
|
|
65
65
|
nodeNextResolutionExt: {
|
|
66
66
|
ts: isNodeNextResolution ? '.ts' : '',
|
|
67
67
|
js: isNodeNextResolution ? '.js' : '',
|
|
@@ -10,13 +10,13 @@ export default function getConfig({ configPath, cwd, logLevel, }: {
|
|
|
10
10
|
configAbsolutePaths: string[];
|
|
11
11
|
userConfig: {
|
|
12
12
|
$schema?: typeof VovkSchemaIdEnum.CONFIG | (string & {});
|
|
13
|
-
|
|
13
|
+
exposeConfigKeys?: boolean | (keyof VovkStrictConfig | (string & {}))[];
|
|
14
14
|
schemaOutDir?: string;
|
|
15
15
|
modulesDir?: string;
|
|
16
16
|
rootEntry?: string;
|
|
17
17
|
logLevel?: "error" | "trace" | "debug" | "info" | "warn" | (string & {});
|
|
18
18
|
libs?: {
|
|
19
|
-
ajv
|
|
19
|
+
ajv?: import("vovk").KnownAny;
|
|
20
20
|
[key: string]: import("vovk").KnownAny;
|
|
21
21
|
};
|
|
22
22
|
devHttps?: boolean;
|
|
@@ -20,7 +20,7 @@ export default async function getConfig({ configPath, cwd, logLevel, }) {
|
|
|
20
20
|
const config = {
|
|
21
21
|
$schema: VovkSchemaIdEnum.CONFIG,
|
|
22
22
|
clientTemplateDefs,
|
|
23
|
-
|
|
23
|
+
exposeConfigKeys: [],
|
|
24
24
|
composedClient: {
|
|
25
25
|
...conf.composedClient,
|
|
26
26
|
enabled: conf.composedClient?.enabled ?? true,
|
|
@@ -76,15 +76,15 @@ export default async function getConfig({ configPath, cwd, logLevel, }) {
|
|
|
76
76
|
]))),
|
|
77
77
|
},
|
|
78
78
|
};
|
|
79
|
-
if (typeof conf.
|
|
80
|
-
config.
|
|
79
|
+
if (typeof conf.exposeConfigKeys === 'undefined') {
|
|
80
|
+
config.exposeConfigKeys = ['libs'];
|
|
81
81
|
}
|
|
82
|
-
else if (conf.
|
|
83
|
-
config.
|
|
82
|
+
else if (conf.exposeConfigKeys === true) {
|
|
83
|
+
config.exposeConfigKeys = Object.keys(config);
|
|
84
84
|
}
|
|
85
|
-
else if (Array.isArray(conf.
|
|
86
|
-
config.
|
|
87
|
-
} // else it's false and
|
|
85
|
+
else if (Array.isArray(conf.exposeConfigKeys)) {
|
|
86
|
+
config.exposeConfigKeys = conf.exposeConfigKeys;
|
|
87
|
+
} // else it's false and exposeConfigKeys already is []
|
|
88
88
|
if (!userConfig) {
|
|
89
89
|
log.warn(`Unable to load config at ${chalkHighlightThing(cwd)}. Using default values. ${error ?? ''}`);
|
|
90
90
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VovkSchemaIdEnum, type VovkStrictConfig } from 'vovk';
|
|
2
|
-
export default function getMetaSchema({ config,
|
|
2
|
+
export default function getMetaSchema({ config, useexposeConfigKeys, }: {
|
|
3
3
|
config: VovkStrictConfig;
|
|
4
|
-
|
|
4
|
+
useexposeConfigKeys: boolean;
|
|
5
5
|
}): {
|
|
6
6
|
config: VovkStrictConfig;
|
|
7
7
|
$schema: VovkSchemaIdEnum;
|
|
@@ -2,11 +2,11 @@ import { VovkSchemaIdEnum } from 'vovk';
|
|
|
2
2
|
import pick from 'lodash/pick.js';
|
|
3
3
|
import mapValues from 'lodash/mapValues.js';
|
|
4
4
|
import omit from 'lodash/omit.js';
|
|
5
|
-
export default function getMetaSchema({ config,
|
|
5
|
+
export default function getMetaSchema({ config, useexposeConfigKeys, }) {
|
|
6
6
|
return {
|
|
7
7
|
$schema: VovkSchemaIdEnum.META,
|
|
8
8
|
...{
|
|
9
|
-
config:
|
|
9
|
+
config: useexposeConfigKeys
|
|
10
10
|
? (config
|
|
11
11
|
? pick({
|
|
12
12
|
...config,
|
|
@@ -19,7 +19,7 @@ export default function getMetaSchema({ config, useEmitConfig }) {
|
|
|
19
19
|
: undefined,
|
|
20
20
|
}
|
|
21
21
|
: undefined,
|
|
22
|
-
}, [...config.
|
|
22
|
+
}, [...config.exposeConfigKeys, '$schema'])
|
|
23
23
|
: {})
|
|
24
24
|
: config,
|
|
25
25
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -139,7 +139,7 @@ program
|
|
|
139
139
|
});
|
|
140
140
|
const { cwd, config, log, isNextInstalled } = projectInfo;
|
|
141
141
|
const fullSchema = await getProjectFullSchema({
|
|
142
|
-
schemaOutAbsolutePath: path.resolve(cwd, cliBundleOptions?.
|
|
142
|
+
schemaOutAbsolutePath: path.resolve(cwd, cliBundleOptions?.schemaPath ?? config.schemaOutDir),
|
|
143
143
|
log,
|
|
144
144
|
isNextInstalled,
|
|
145
145
|
config,
|
package/dist/init/index.mjs
CHANGED
|
@@ -81,6 +81,7 @@ export class Init {
|
|
|
81
81
|
}
|
|
82
82
|
if (!dryRun && pkgJson) {
|
|
83
83
|
let depsUpdated = false;
|
|
84
|
+
const packageManager = getPackageManager({ useNpm, useYarn, usePnpm, useBun, pkgJson });
|
|
84
85
|
try {
|
|
85
86
|
await updateDependenciesWithoutInstalling({
|
|
86
87
|
log,
|
|
@@ -96,17 +97,13 @@ export class Init {
|
|
|
96
97
|
logUpdateDependenciesError({
|
|
97
98
|
log,
|
|
98
99
|
error,
|
|
99
|
-
|
|
100
|
-
useYarn,
|
|
101
|
-
usePnpm,
|
|
102
|
-
useBun,
|
|
100
|
+
packageManager,
|
|
103
101
|
dependencies,
|
|
104
102
|
devDependencies,
|
|
105
103
|
channel,
|
|
106
104
|
});
|
|
107
105
|
}
|
|
108
106
|
if (depsUpdated) {
|
|
109
|
-
const packageManager = getPackageManager({ useNpm, useYarn, usePnpm, useBun });
|
|
110
107
|
if (skipInstall) {
|
|
111
108
|
log.info(`Installation skipped. Please, install them manually with ${chalkHighlightThing(packageManager + ' install')}`);
|
|
112
109
|
}
|
|
@@ -115,12 +112,7 @@ export class Init {
|
|
|
115
112
|
await installDependencies({
|
|
116
113
|
log,
|
|
117
114
|
cwd: root,
|
|
118
|
-
|
|
119
|
-
useNpm,
|
|
120
|
-
useYarn,
|
|
121
|
-
usePnpm,
|
|
122
|
-
useBun,
|
|
123
|
-
},
|
|
115
|
+
packageManager,
|
|
124
116
|
});
|
|
125
117
|
log.info('Dependencies installed successfully');
|
|
126
118
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import NPMCliPackageJson from '@npmcli/package-json';
|
|
1
2
|
import getLogger from '../utils/getLogger.mjs';
|
|
2
3
|
import type { InitOptions } from '../types.mjs';
|
|
3
|
-
type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';
|
|
4
|
-
export declare function getPackageManager(options: Pick<InitOptions, 'useNpm' | 'useYarn' | 'usePnpm' | 'useBun'>
|
|
5
|
-
|
|
4
|
+
export type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';
|
|
5
|
+
export declare function getPackageManager(options: Pick<InitOptions, 'useNpm' | 'useYarn' | 'usePnpm' | 'useBun'> & {
|
|
6
|
+
pkgJson: NPMCliPackageJson;
|
|
7
|
+
}): PackageManager;
|
|
8
|
+
export default function installDependencies({ log, cwd, packageManager, }: {
|
|
6
9
|
log: ReturnType<typeof getLogger>;
|
|
7
10
|
cwd: string;
|
|
8
|
-
|
|
11
|
+
packageManager: PackageManager;
|
|
9
12
|
}): Promise<void>;
|
|
10
|
-
export {};
|
|
@@ -9,10 +9,10 @@ export function getPackageManager(options) {
|
|
|
9
9
|
return 'pnpm';
|
|
10
10
|
if (options.useBun)
|
|
11
11
|
return 'bun';
|
|
12
|
-
|
|
12
|
+
const packageManager = options.pkgJson.content?.['packageManager'];
|
|
13
|
+
return packageManager ? packageManager.split('@')[0] : 'npm'; // Default to npm if no options are true
|
|
13
14
|
}
|
|
14
|
-
export default async function installDependencies({ log, cwd,
|
|
15
|
-
const packageManager = getPackageManager(options);
|
|
15
|
+
export default async function installDependencies({ log, cwd, packageManager, }) {
|
|
16
16
|
log.info(`Installing dependencies at ${chalkHighlightThing(cwd)} using ${chalkHighlightThing(packageManager)}...`);
|
|
17
17
|
await new Promise((resolve, reject) => {
|
|
18
18
|
const args = packageManager === 'yarn' ? ['install', '--non-interactive'] : ['install'];
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { InitOptions } from '../types.mjs';
|
|
2
2
|
import type getLogger from '../utils/getLogger.mjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
usePnpm?: boolean;
|
|
7
|
-
useBun?: boolean;
|
|
3
|
+
import type { PackageManager } from './installDependencies.mjs';
|
|
4
|
+
export default function logUpdateDependenciesError({ packageManager, log, dependencies, devDependencies, error, channel, }: {
|
|
5
|
+
packageManager: PackageManager;
|
|
8
6
|
log: ReturnType<typeof getLogger>;
|
|
9
7
|
dependencies: string[];
|
|
10
8
|
devDependencies: string[];
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import chalkHighlightThing from '../utils/chalkHighlightThing.mjs';
|
|
2
|
-
|
|
3
|
-
export default function logUpdateDependenciesError({ useNpm, useYarn, usePnpm, useBun, log, dependencies, devDependencies, error, channel, }) {
|
|
4
|
-
const packageManager = getPackageManager({ useNpm, useYarn, usePnpm, useBun });
|
|
2
|
+
export default function logUpdateDependenciesError({ packageManager, log, dependencies, devDependencies, error, channel, }) {
|
|
5
3
|
const installCommands = [];
|
|
6
4
|
const addChannel = (packageName) => {
|
|
7
5
|
const isVovk = packageName.startsWith('vovk') && packageName !== 'dto-mapped-types';
|
package/dist/new/newModule.mjs
CHANGED
|
@@ -21,7 +21,7 @@ function splitByLast(str, delimiter = '/') {
|
|
|
21
21
|
return [before, after];
|
|
22
22
|
}
|
|
23
23
|
export default async function newModule({ projectInfo, what, moduleNameWithOptionalSegment, dryRun, outDir: outDirFlag, templates: templatesFlag, noSegmentUpdate, overwrite, empty, }) {
|
|
24
|
-
const { config, log, cwd, apiDirAbsolutePath } = projectInfo;
|
|
24
|
+
const { config, log, cwd, apiDirAbsolutePath, srcRoot } = projectInfo;
|
|
25
25
|
const segments = await locateSegments({ dir: apiDirAbsolutePath, config, log });
|
|
26
26
|
const isNodeNextResolution = ['node16', 'nodenext'].includes((await getTsconfig(cwd)?.config?.compilerOptions?.moduleResolution?.toLowerCase()) ?? '');
|
|
27
27
|
let templates = config.moduleTemplates;
|
|
@@ -61,6 +61,7 @@ export default async function newModule({ projectInfo, what, moduleNameWithOptio
|
|
|
61
61
|
const templateCode = await fs.readFile(templateAbsolutePath, 'utf-8');
|
|
62
62
|
const { outDir: renderedOutDir, fileName, sourceName, compiledName, code, } = await render(templateCode, {
|
|
63
63
|
cwd,
|
|
64
|
+
srcRoot,
|
|
64
65
|
config,
|
|
65
66
|
withService: what.includes('service'),
|
|
66
67
|
segmentName,
|
package/dist/new/render.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VovkStrictConfig } from 'vovk';
|
|
2
2
|
import type { VovkModuleRenderResult } from '../types.mjs';
|
|
3
|
-
export default function render(codeTemplate: string, { config, withService, segmentName, moduleName, empty, templateFileName, isNodeNextResolution, }: {
|
|
3
|
+
export default function render(codeTemplate: string, { cwd, config, withService, segmentName, moduleName, empty, templateFileName, isNodeNextResolution, srcRoot, }: {
|
|
4
4
|
cwd: string;
|
|
5
5
|
config: VovkStrictConfig;
|
|
6
6
|
withService: boolean;
|
|
@@ -9,4 +9,5 @@ export default function render(codeTemplate: string, { config, withService, segm
|
|
|
9
9
|
empty?: boolean;
|
|
10
10
|
templateFileName: string;
|
|
11
11
|
isNodeNextResolution: boolean;
|
|
12
|
+
srcRoot: string | null;
|
|
12
13
|
}): Promise<VovkModuleRenderResult>;
|
package/dist/new/render.mjs
CHANGED
|
@@ -3,11 +3,13 @@ import matter from 'gray-matter';
|
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import pluralize from 'pluralize';
|
|
5
5
|
import addCommonTerms from './addCommonTerms.mjs';
|
|
6
|
+
import path from 'node:path';
|
|
6
7
|
addCommonTerms();
|
|
7
|
-
export default async function render(codeTemplate, { config, withService, segmentName, moduleName, empty, templateFileName, isNodeNextResolution, }) {
|
|
8
|
-
const
|
|
8
|
+
export default async function render(codeTemplate, { cwd, config, withService, segmentName, moduleName, empty, templateFileName, isNodeNextResolution, srcRoot, }) {
|
|
9
|
+
const defaultOutDir = [config.modulesDir, segmentName || config.rootSegmentModulesDirName, _.camelCase(moduleName)]
|
|
9
10
|
.filter(Boolean)
|
|
10
11
|
.join('/');
|
|
12
|
+
const relativePathToSourceRoot = path.relative(path.resolve(cwd, defaultOutDir), path.join(cwd, srcRoot ?? '.')) || '.';
|
|
11
13
|
const theThing = _.camelCase(moduleName);
|
|
12
14
|
const TheThing = _.upperFirst(theThing);
|
|
13
15
|
const the_thing = _.snakeCase(moduleName);
|
|
@@ -36,7 +38,8 @@ export default async function render(codeTemplate, { config, withService, segmen
|
|
|
36
38
|
cjs: isNodeNextResolution ? '.cjs' : '',
|
|
37
39
|
mjs: isNodeNextResolution ? '.mjs' : '',
|
|
38
40
|
},
|
|
39
|
-
defaultOutDir
|
|
41
|
+
defaultOutDir,
|
|
42
|
+
relativePathToSourceRoot,
|
|
40
43
|
// libraries
|
|
41
44
|
_, // lodash
|
|
42
45
|
pluralize,
|
package/dist/types.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ compiledName: <%= t.TheThing + 'RPC' %>
|
|
|
11
11
|
|
|
12
12
|
import { prefix, get, put, post, del, operation } from 'vovk';
|
|
13
13
|
import { type } from 'arktype';
|
|
14
|
-
import withArk from '
|
|
14
|
+
import withArk from '<%= t.relativePathToSourceRoot %>/lib/withArk<%= t.nodeNextResolutionExt.ts %>';
|
|
15
15
|
<% if(t.withService) { %>
|
|
16
16
|
import <%= vars.ServiceName %> from './<%= vars.ServiceName %><%= t.nodeNextResolutionExt.ts %>';
|
|
17
17
|
<% } %>
|
|
@@ -32,6 +32,21 @@ export default class <%= vars.ModuleName %> {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
@operation({
|
|
36
|
+
summary: 'Get single <%= t.TheThing %>',
|
|
37
|
+
})
|
|
38
|
+
@get('{id}')
|
|
39
|
+
static getSingle<%= t.TheThing %> = withArk({
|
|
40
|
+
params: type({ id: type('string') }),
|
|
41
|
+
handle(_req, { id }) {
|
|
42
|
+
<% if(t.withService) { %>
|
|
43
|
+
return <%= vars.ServiceName %>.getSingle<%= t.TheThing %>(id);
|
|
44
|
+
<% } else { %>
|
|
45
|
+
return { message: 'TODO: get single <%= t.theThing %>', id };
|
|
46
|
+
<% } %>
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
35
50
|
@operation({
|
|
36
51
|
summary: 'Update <%= t.TheThing %>',
|
|
37
52
|
})
|
|
@@ -39,8 +54,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
39
54
|
static update<%= t.TheThing %> = withArk({
|
|
40
55
|
body: type({ todo: type('true') }),
|
|
41
56
|
params: type({ id: type('string') }),
|
|
42
|
-
async handle(req,
|
|
43
|
-
const { id } = params;
|
|
57
|
+
async handle(req, { id }) {
|
|
44
58
|
const body = await req.json();
|
|
45
59
|
<% if(t.withService) { %>
|
|
46
60
|
return <%= vars.ServiceName %>.update<%= t.TheThing %>(id, body);
|
|
@@ -26,7 +26,19 @@ export default class <%= vars.ControllerName %> {
|
|
|
26
26
|
<% } else { %>
|
|
27
27
|
return { message: 'TODO: get <%= t.theThings %>' };
|
|
28
28
|
<% } %>
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
@operation({
|
|
32
|
+
summary: 'Get single <%= t.TheThing %>',
|
|
33
|
+
})
|
|
34
|
+
@get('{id}')
|
|
35
|
+
static getSingle<%= t.TheThing %> = (_req: VovkRequest, { id }: { id: string }) => {
|
|
36
|
+
<% if(t.withService) { %>
|
|
37
|
+
return <%= vars.ServiceName %>.getSingle<%= t.TheThing %>(id);
|
|
38
|
+
<% } else { %>
|
|
39
|
+
return { message: 'TODO: get single <%= t.theThing %>', id };
|
|
40
|
+
<% } %>
|
|
41
|
+
};
|
|
30
42
|
|
|
31
43
|
@operation({
|
|
32
44
|
summary: 'Update <%= t.TheThing %>',
|
|
@@ -16,6 +16,12 @@ export default class <%= vars.ServiceName %> {
|
|
|
16
16
|
return { message: 'TODO: get <%= t.theThings %>' };
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
static getSingle<%= t.TheThing %> = (
|
|
20
|
+
id: VovkParams<typeof <%= vars.ControllerName %>.getSingle<%= t.TheThing %>>['id']
|
|
21
|
+
) => {
|
|
22
|
+
return { message: 'TODO: get single <%= t.theThing %>', id };
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
static update<%= t.TheThing %> = (
|
|
20
26
|
id: VovkParams<typeof <%= vars.ControllerName %>.update<%= t.TheThing %>>['id'],
|
|
21
27
|
body: VovkBody<typeof <%= vars.ControllerName %>.update<%= t.TheThing %>>
|
|
@@ -11,7 +11,7 @@ compiledName: <%= t.TheThing + 'RPC' %>
|
|
|
11
11
|
|
|
12
12
|
import { prefix, get, put, post, del, operation } from 'vovk';
|
|
13
13
|
import * as v from 'valibot';
|
|
14
|
-
import withValibot from '
|
|
14
|
+
import withValibot from '<%= t.relativePathToSourceRoot %>/lib/withValibot<%= t.nodeNextResolutionExt.ts %>';
|
|
15
15
|
<% if(t.withService) { %>
|
|
16
16
|
import <%= vars.ServiceName %> from './<%= vars.ServiceName %><%= t.nodeNextResolutionExt.ts %>';
|
|
17
17
|
<% } %>
|
|
@@ -32,6 +32,21 @@ export default class <%= vars.ModuleName %> {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
@operation({
|
|
36
|
+
summary: 'Get single <%= t.TheThing %>',
|
|
37
|
+
})
|
|
38
|
+
@get('{id}')
|
|
39
|
+
static getSingle<%= t.TheThing %> = withValibot({
|
|
40
|
+
params: v.object({ id: v.string() }),
|
|
41
|
+
handle(_req, { id }) {
|
|
42
|
+
<% if(t.withService) { %>
|
|
43
|
+
return <%= vars.ServiceName %>.getSingle<%= t.TheThing %>(id);
|
|
44
|
+
<% } else { %>
|
|
45
|
+
return { message: `TODO: get single <%= t.theThing %>`, id };
|
|
46
|
+
<% } %>
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
35
50
|
@operation({
|
|
36
51
|
summary: 'Update <%= t.TheThing %>',
|
|
37
52
|
})
|
|
@@ -39,8 +54,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
39
54
|
static update<%= t.TheThing %> = withValibot({
|
|
40
55
|
body: v.object({ todo: v.literal(true) }),
|
|
41
56
|
params: v.object({ id: v.string() }),
|
|
42
|
-
async handle(req,
|
|
43
|
-
const { id } = params;
|
|
57
|
+
async handle(req, { id }) {
|
|
44
58
|
const body = await req.json();
|
|
45
59
|
<% if(t.withService) { %>
|
|
46
60
|
return <%= vars.ServiceName %>.update<%= t.TheThing %>(id, body);
|
|
@@ -66,8 +80,7 @@ export default class <%= vars.ModuleName %> {
|
|
|
66
80
|
@del('{id}')
|
|
67
81
|
static delete<%= t.TheThing %> = withValibot({
|
|
68
82
|
params: v.object({ id: v.string() }),
|
|
69
|
-
handle(_req,
|
|
70
|
-
const { id } = params;
|
|
83
|
+
handle(_req, { id }) {
|
|
71
84
|
<% if(t.withService) { %>
|
|
72
85
|
return <%= vars.ServiceName %>.delete<%= t.TheThing %>(id);
|
|
73
86
|
<% } else { %>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk-cli",
|
|
3
|
-
"version": "0.0.1-draft.
|
|
3
|
+
"version": "0.0.1-draft.394",
|
|
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-draft.
|
|
38
|
+
"vovk": "^3.0.0-draft.470",
|
|
39
39
|
"vovk-ajv": "^0.0.0-draft.112",
|
|
40
40
|
"vovk-client": "^0.0.4-draft.139",
|
|
41
41
|
"vovk-python": "^0.0.1-draft.81",
|
|
@@ -83,7 +83,10 @@
|
|
|
83
83
|
"create-next-app": "^15.5.4",
|
|
84
84
|
"http-server": "^14.1.1",
|
|
85
85
|
"node-pty": "^1.0.0",
|
|
86
|
-
"tsdown": "^0.15.
|
|
86
|
+
"tsdown": "^0.15.12",
|
|
87
87
|
"zod": "^4.1.11"
|
|
88
|
+
},
|
|
89
|
+
"overrides": {
|
|
90
|
+
"rolldown-plugin-dts": "0.17.3"
|
|
88
91
|
}
|
|
89
92
|
}
|