vovk-cli 0.0.1-draft.147 → 0.0.1-draft.148
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/client-templates/{main/main.cjs.ejs → cjs/index.cjs.ejs} +3 -3
- package/client-templates/{main/main.d.cts.ejs → cjs/index.d.cts.ejs} +2 -2
- package/client-templates/{module → mjs}/module.d.mts.ejs +2 -2
- package/client-templates/{module → mjs}/module.mjs.ejs +3 -3
- package/client-templates/readme/README.md.ejs +28 -0
- package/client-templates/ts/index.ts.ejs +3 -3
- package/dist/generate/getClientTemplateFiles.d.mts +1 -2
- package/dist/generate/getClientTemplateFiles.mjs +17 -13
- package/dist/generate/getTemplateClientImports.d.mts +1 -1
- package/dist/generate/mergePackages.d.mts +1 -1
- package/dist/generate/writeOneClientFile.d.mts +2 -1
- package/dist/getProjectInfo/getConfig/getTemplateDefs.d.mts +6 -4
- package/dist/getProjectInfo/getConfig/getTemplateDefs.mjs +25 -9
- package/dist/getProjectInfo/getConfig/index.d.mts +2 -3
- package/dist/getProjectInfo/getConfig/index.mjs +1 -1
- package/dist/getProjectInfo/getUserConfig.d.mts +1 -1
- package/dist/getProjectInfo/index.d.mts +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/init/createConfig.mjs +2 -5
- package/dist/init/getTemplateFilesFromPackage.mjs +0 -1
- package/dist/locateSegments.d.mts +1 -1
- package/dist/new/render.d.mts +1 -2
- package/dist/types.d.mts +90 -0
- package/module-templates/controller.ts.ejs +4 -4
- package/module-templates/service.ts.ejs +5 -5
- package/package.json +3 -2
- /package/client-templates/{package → packageJson}/package.json.ejs +0 -0
|
@@ -4,9 +4,9 @@ const { createRPC } = require('<%= t.imports.createRPC %>');
|
|
|
4
4
|
const { fullSchema } = require('./fullSchema.cjs');
|
|
5
5
|
const { validateOnClient = null } = <%- t.imports.validateOnClient ? `require('${t.imports.validateOnClient}')` : '{}'%>;
|
|
6
6
|
<% Object.values(t.fullSchema.segments).forEach((segment) => {
|
|
7
|
-
Object.keys(segment.controllers).forEach((
|
|
8
|
-
exports.<%=
|
|
9
|
-
fullSchema, '<%= segment.segmentName %>', '<%=
|
|
7
|
+
Object.keys(segment.controllers).forEach((rpcModuleName) => { %>
|
|
8
|
+
exports.<%= rpcModuleName %> = createRPC(
|
|
9
|
+
fullSchema, '<%= segment.segmentName %>', '<%= rpcModuleName %>',
|
|
10
10
|
{ fetcher, validateOnClient, defaultOptions: { apiRoot: '<%= segment.segmentApiRoot ?? t.apiRoot %>' } }
|
|
11
11
|
);
|
|
12
12
|
<% })
|
|
@@ -8,8 +8,8 @@ import type { Controllers as Controllers<%= i %> } from "<%= t.segmentMeta[segme
|
|
|
8
8
|
<% }}) %>
|
|
9
9
|
type Options = typeof fetcher extends VovkClientFetcher<infer U> ? U : never;
|
|
10
10
|
<% Object.values(t.fullSchema.segments).forEach((segment, i) => {
|
|
11
|
-
Object.keys(segment.controllers).forEach((
|
|
12
|
-
export const <%=
|
|
11
|
+
Object.keys(segment.controllers).forEach((rpcModuleName) => { %>
|
|
12
|
+
export const <%= rpcModuleName %>: ReturnType<typeof createRPC<Controllers<%= i %>["<%= rpcModuleName %>"], Options>>;
|
|
13
13
|
<% })
|
|
14
14
|
}) %>
|
|
15
15
|
export { fullSchema } from './fullSchema.cjs';
|
|
@@ -8,8 +8,8 @@ import type { Controllers as Controllers<%= i %> } from "<%= t.segmentMeta[segme
|
|
|
8
8
|
<% }}) %>
|
|
9
9
|
type Options = typeof fetcher extends VovkClientFetcher<infer U> ? U : never;
|
|
10
10
|
<% Object.values(t.fullSchema.segments).forEach((segment, i) => {
|
|
11
|
-
Object.keys(segment.controllers).forEach((
|
|
12
|
-
export const <%=
|
|
11
|
+
Object.keys(segment.controllers).forEach((rpcModuleName) => { %>
|
|
12
|
+
export const <%= rpcModuleName %>: ReturnType<typeof createRPC<Controllers<%= i %>["<%= rpcModuleName %>"], Options>>;
|
|
13
13
|
<% })
|
|
14
14
|
}) %>
|
|
15
15
|
export { fullSchema } from './fullSchema.cjs';
|
|
@@ -8,9 +8,9 @@ import { validateOnClient } from '<%= t.imports.module.validateOnClient %>';
|
|
|
8
8
|
const validateOnClient = undefined;
|
|
9
9
|
<% } %>
|
|
10
10
|
<% Object.values(t.fullSchema.segments).forEach((segment, i) => {
|
|
11
|
-
Object.keys(segment.controllers).forEach((
|
|
12
|
-
export const <%=
|
|
13
|
-
fullSchema, '<%= segment.segmentName %>', '<%=
|
|
11
|
+
Object.keys(segment.controllers).forEach((rpcModuleName) => { %>
|
|
12
|
+
export const <%= rpcModuleName %> = createRPC(
|
|
13
|
+
fullSchema, '<%= segment.segmentName %>', '<%= rpcModuleName %>',
|
|
14
14
|
{ fetcher, validateOnClient, defaultOptions: { apiRoot: '<%= segment.segmentApiRoot ?? t.apiRoot %>' } }
|
|
15
15
|
);
|
|
16
16
|
<%
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
imports: ['vovk-openapi']
|
|
3
|
+
---
|
|
4
|
+
<% const vars = {
|
|
5
|
+
createCodeExamples: t.imports['vovk-openapi'].createCodeExamples,
|
|
6
|
+
}; %>
|
|
7
|
+
|
|
8
|
+
# <%= t.package.name %>
|
|
9
|
+
|
|
10
|
+
<%= t.package.description ? `> ${t.package.description}` : '' %>
|
|
11
|
+
|
|
12
|
+
<%= t.package.license ? `> License: ${t.package.license}` : '' %>
|
|
13
|
+
|
|
14
|
+
<% Object.entries(t.fullSchema.segments).forEach(([segmentName, segment]) => {
|
|
15
|
+
Object.values(segment.controllers).forEach((controllerSchema) => { %>
|
|
16
|
+
|
|
17
|
+
## <%= controllerSchema.rpcModuleName %>
|
|
18
|
+
<% Object.entries(handlers).forEach((handlerName, [handlerSchema]) => { %>
|
|
19
|
+
```ts
|
|
20
|
+
<%- createCodeExamples({
|
|
21
|
+
handlerSchema,
|
|
22
|
+
handlerName,
|
|
23
|
+
controllerSchema,
|
|
24
|
+
}).ts %>
|
|
25
|
+
```
|
|
26
|
+
<% }) %>
|
|
27
|
+
<% }) %>
|
|
28
|
+
<% }) %>
|
|
@@ -13,9 +13,9 @@ const validateOnClient = undefined;
|
|
|
13
13
|
<% } %>
|
|
14
14
|
type Options = typeof fetcher extends VovkClientFetcher<infer U> ? U : never;
|
|
15
15
|
<% Object.values(t.fullSchema.segments).forEach((segment, i) => { %>
|
|
16
|
-
<% Object.keys(segment.controllers).forEach((
|
|
17
|
-
export const <%=
|
|
18
|
-
fullSchema, '<%= segment.segmentName %>', '<%=
|
|
16
|
+
<% Object.keys(segment.controllers).forEach((rpcModuleName) => { %>
|
|
17
|
+
export const <%= rpcModuleName %> = createRPC<Controllers<%= i %>["<%= rpcModuleName %>"], Options>(
|
|
18
|
+
fullSchema, '<%= segment.segmentName %>', '<%= rpcModuleName %>',
|
|
19
19
|
{ fetcher, validateOnClient, defaultOptions: { apiRoot: '<%= segment.segmentApiRoot ?? t.apiRoot %>' } }
|
|
20
20
|
);
|
|
21
21
|
<% }) %>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { VovkStrictConfig } from 'vovk';
|
|
2
1
|
import type { ProjectInfo } from '../getProjectInfo/index.mjs';
|
|
3
|
-
import {
|
|
2
|
+
import type { GenerateOptions, VovkStrictConfig } from '../types.mjs';
|
|
4
3
|
export interface ClientTemplateFile {
|
|
5
4
|
templateName: string;
|
|
6
5
|
templateFilePath: string;
|
|
@@ -20,22 +20,26 @@ export default async function getClientTemplateFiles({ config, cwd, log, configK
|
|
|
20
20
|
const entries = Object.entries(usedTemplateDefs);
|
|
21
21
|
for (let i = 0; i < entries.length; i++) {
|
|
22
22
|
const [templateName, templateDef, forceOutCwdRelativeDir] = entries[i];
|
|
23
|
-
const templateAbsolutePath =
|
|
24
|
-
|
|
23
|
+
const templateAbsolutePath = templateDef.templatePath
|
|
24
|
+
? resolveAbsoluteModulePath(templateDef.templatePath, cwd)
|
|
25
|
+
: null;
|
|
26
|
+
const entryType = templateDef.templatePath ? await getFileSystemEntryType(templateDef.templatePath) : null;
|
|
25
27
|
if (!entryType)
|
|
26
28
|
throw new Error(`Unable to locate template path ${templateDef.templatePath}`);
|
|
27
29
|
const defOutDir = configKey === 'fullClient' ? templateDef.fullClient?.outDir : templateDef.segmentedClient?.outDir;
|
|
28
|
-
let files;
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
let files = [];
|
|
31
|
+
if (templateAbsolutePath) {
|
|
32
|
+
if (entryType === FileSystemEntryType.FILE) {
|
|
33
|
+
files = [templateAbsolutePath];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const globPath = path.join(templateAbsolutePath, '**/*.*');
|
|
37
|
+
files = await glob(globPath);
|
|
38
|
+
}
|
|
39
|
+
if (files.length === 0) {
|
|
40
|
+
log.error(`Template "${templateAbsolutePath}" not found`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
const outCwdRelativeDir = forceOutCwdRelativeDir ?? defOutDir ?? outDir;
|
|
41
45
|
for (const filePath of files) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { VovkFullSchema
|
|
1
|
+
import type { VovkFullSchema } from 'vovk';
|
|
2
2
|
import type { ProjectInfo } from '../getProjectInfo/index.mjs';
|
|
3
3
|
import type { ClientTemplateFile } from './getClientTemplateFiles.mjs';
|
|
4
4
|
import type { ClientImports } from './getTemplateClientImports.mjs';
|
|
5
5
|
import type { PackageJson } from 'type-fest';
|
|
6
|
+
import type { VovkStrictConfig } from '../types.mjs';
|
|
6
7
|
export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, isEnsuringClient, outCwdRelativeDir, origin, templateDef, }: {
|
|
7
8
|
cwd: string;
|
|
8
9
|
projectInfo: ProjectInfo;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { VovkStrictConfig } from '
|
|
1
|
+
import type { VovkStrictConfig } from '../../types.mjs';
|
|
2
2
|
export declare enum BuiltInTemplateName {
|
|
3
3
|
ts = "ts",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
cjs = "cjs",
|
|
5
|
+
mjs = "mjs",
|
|
6
|
+
npm = "npm",
|
|
7
|
+
readme = "readme",
|
|
8
|
+
packageJson = "packageJson",
|
|
7
9
|
fullSchemaTs = "fullSchemaTs",
|
|
8
10
|
fullSchemaCjs = "fullSchemaCjs",
|
|
9
11
|
fullSchemaJson = "fullSchemaJson"
|
|
@@ -2,9 +2,11 @@ import path from 'node:path';
|
|
|
2
2
|
export var BuiltInTemplateName;
|
|
3
3
|
(function (BuiltInTemplateName) {
|
|
4
4
|
BuiltInTemplateName["ts"] = "ts";
|
|
5
|
-
BuiltInTemplateName["
|
|
6
|
-
BuiltInTemplateName["
|
|
7
|
-
BuiltInTemplateName["
|
|
5
|
+
BuiltInTemplateName["cjs"] = "cjs";
|
|
6
|
+
BuiltInTemplateName["mjs"] = "mjs";
|
|
7
|
+
BuiltInTemplateName["npm"] = "npm";
|
|
8
|
+
BuiltInTemplateName["readme"] = "readme";
|
|
9
|
+
BuiltInTemplateName["packageJson"] = "packageJson";
|
|
8
10
|
BuiltInTemplateName["fullSchemaTs"] = "fullSchemaTs";
|
|
9
11
|
BuiltInTemplateName["fullSchemaCjs"] = "fullSchemaCjs";
|
|
10
12
|
BuiltInTemplateName["fullSchemaJson"] = "fullSchemaJson";
|
|
@@ -18,18 +20,32 @@ export default function getTemplateDefs(userTemplateDefs = {}) {
|
|
|
18
20
|
origin: null,
|
|
19
21
|
requires: { [BuiltInTemplateName.fullSchemaTs]: '.' },
|
|
20
22
|
},
|
|
21
|
-
[BuiltInTemplateName.
|
|
22
|
-
templatePath: path.resolve(templatesDir, '
|
|
23
|
+
[BuiltInTemplateName.cjs]: {
|
|
24
|
+
templatePath: path.resolve(templatesDir, 'cjs/'),
|
|
23
25
|
origin: null,
|
|
24
26
|
requires: { [BuiltInTemplateName.fullSchemaCjs]: '.' },
|
|
25
27
|
},
|
|
26
|
-
[BuiltInTemplateName.
|
|
27
|
-
templatePath: path.resolve(templatesDir, '
|
|
28
|
+
[BuiltInTemplateName.mjs]: {
|
|
29
|
+
templatePath: path.resolve(templatesDir, 'mjs/'),
|
|
28
30
|
origin: null,
|
|
29
31
|
requires: { [BuiltInTemplateName.fullSchemaCjs]: '.' },
|
|
30
32
|
},
|
|
31
|
-
[BuiltInTemplateName.
|
|
32
|
-
templatePath:
|
|
33
|
+
[BuiltInTemplateName.npm]: {
|
|
34
|
+
templatePath: null,
|
|
35
|
+
origin: null,
|
|
36
|
+
requires: {
|
|
37
|
+
[BuiltInTemplateName.cjs]: '.',
|
|
38
|
+
[BuiltInTemplateName.mjs]: '.',
|
|
39
|
+
[BuiltInTemplateName.packageJson]: '.',
|
|
40
|
+
[BuiltInTemplateName.readme]: '.',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
[BuiltInTemplateName.readme]: {
|
|
44
|
+
templatePath: path.resolve(templatesDir, 'readme/'),
|
|
45
|
+
origin: null,
|
|
46
|
+
},
|
|
47
|
+
[BuiltInTemplateName.packageJson]: {
|
|
48
|
+
templatePath: path.resolve(templatesDir, 'packageJson/'),
|
|
33
49
|
origin: null,
|
|
34
50
|
},
|
|
35
51
|
[BuiltInTemplateName.fullSchemaTs]: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { VovkStrictConfig } from '
|
|
2
|
-
import type { GenerateOptions } from '../../types.mjs';
|
|
1
|
+
import type { GenerateOptions, VovkStrictConfig } from '../../types.mjs';
|
|
3
2
|
export default function getConfig({ cliOptions, cwd }: {
|
|
4
3
|
cliOptions?: GenerateOptions;
|
|
5
4
|
cwd: string;
|
|
@@ -7,6 +6,6 @@ export default function getConfig({ cliOptions, cwd }: {
|
|
|
7
6
|
config: VovkStrictConfig;
|
|
8
7
|
srcRoot: string;
|
|
9
8
|
configAbsolutePaths: string[];
|
|
10
|
-
userConfig: import("
|
|
9
|
+
userConfig: import("../../types.mjs").VovkConfig | null;
|
|
11
10
|
error: Error | undefined;
|
|
12
11
|
}>;
|
|
@@ -25,7 +25,7 @@ export default async function getConfig({ cliOptions, cwd }) {
|
|
|
25
25
|
fullClient: {
|
|
26
26
|
enabled: true,
|
|
27
27
|
...conf.fullClient,
|
|
28
|
-
fromTemplates: cliOptions?.fullClientFrom ?? conf.fullClient?.fromTemplates ?? ['
|
|
28
|
+
fromTemplates: cliOptions?.fullClientFrom ?? conf.fullClient?.fromTemplates ?? ['mjs', 'cjs'],
|
|
29
29
|
outDir: cliOptions?.fullClientOut ?? conf.fullClient?.outDir ?? './node_modules/.vovk-client',
|
|
30
30
|
},
|
|
31
31
|
segmentedClient: {
|
|
@@ -10,7 +10,7 @@ export default function getProjectInfo({ port: givenPort, cwd, cliOptions, }?: {
|
|
|
10
10
|
apiRoot: string;
|
|
11
11
|
apiDir: string;
|
|
12
12
|
srcRoot: string;
|
|
13
|
-
config: import("
|
|
13
|
+
config: import("../types.mjs").VovkStrictConfig;
|
|
14
14
|
log: {
|
|
15
15
|
info: (msg: string) => void;
|
|
16
16
|
warn: (msg: string) => void;
|
package/dist/index.d.mts
CHANGED
|
@@ -17,10 +17,7 @@ export default async function createConfig({ root, log, options: { validationLib
|
|
|
17
17
|
};
|
|
18
18
|
if (validationLibrary) {
|
|
19
19
|
config.imports ??= {};
|
|
20
|
-
config.imports.validateOnClient =
|
|
21
|
-
{
|
|
22
|
-
'vovk-dto': `vovk-dto/validateOnClient.js`,
|
|
23
|
-
}[validationLibrary] ?? 'vovk-ajv';
|
|
20
|
+
config.imports.validateOnClient = 'vovk-ajv';
|
|
24
21
|
try {
|
|
25
22
|
const validationTemplates = await getTemplateFilesFromPackage(validationLibrary, channel);
|
|
26
23
|
Object.assign(moduleTemplates, validationTemplates);
|
|
@@ -35,7 +32,7 @@ export default async function createConfig({ root, log, options: { validationLib
|
|
|
35
32
|
}
|
|
36
33
|
config.moduleTemplates = moduleTemplates;
|
|
37
34
|
const configStr = await prettify(`// @ts-check
|
|
38
|
-
/** @type {import('vovk
|
|
35
|
+
/** @type {import('vovk').VovkConfig} */
|
|
39
36
|
const config = ${JSON.stringify(config, null, 2)};
|
|
40
37
|
${isModule ? '\nexport default config;' : 'module.exports = config;'}`, configAbsolutePath);
|
|
41
38
|
if (!dryRun)
|
|
@@ -2,7 +2,6 @@ import { Readable } from 'node:stream';
|
|
|
2
2
|
import { createGunzip } from 'node:zlib';
|
|
3
3
|
import tar from 'tar-stream';
|
|
4
4
|
import getNPMPackageMetadata from '../utils/getNPMPackageMetadata.mjs';
|
|
5
|
-
// Crereated with AI
|
|
6
5
|
/**
|
|
7
6
|
* Retrieves a list of files in the 'templates' folder of an NPM package.
|
|
8
7
|
* @param packageName - The name of the NPM package.
|
package/dist/new/render.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { VovkStrictConfig } from '
|
|
2
|
-
import type { VovkModuleRenderResult } from '../types.mjs';
|
|
1
|
+
import type { VovkModuleRenderResult, VovkStrictConfig } from '../types.mjs';
|
|
3
2
|
export default function render(codeTemplate: string, { config, withService, segmentName, moduleName, empty, templateFileName, }: {
|
|
4
3
|
cwd: string;
|
|
5
4
|
config: VovkStrictConfig;
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { LogLevelNames } from 'loglevel';
|
|
2
|
+
import type { PackageJson } from 'type-fest';
|
|
3
|
+
import type { KnownAny } from 'vovk';
|
|
2
4
|
export type VovkModuleRenderResult = {
|
|
3
5
|
fileName: string;
|
|
4
6
|
dir: string;
|
|
@@ -41,3 +43,91 @@ export interface NewOptions {
|
|
|
41
43
|
noSegmentUpdate?: boolean;
|
|
42
44
|
empty?: boolean;
|
|
43
45
|
}
|
|
46
|
+
export type VovkEnv = {
|
|
47
|
+
PORT?: string;
|
|
48
|
+
VOVK_SCHEMA_OUT_DIR?: string;
|
|
49
|
+
VOVK_IMPORTS_FETCHER?: string;
|
|
50
|
+
VOVK_IMPORTS_VALIDATE_ON_CLIENT?: string;
|
|
51
|
+
VOVK_IMPORTS_CREATE_RPC?: string;
|
|
52
|
+
VOVK_MODULES_DIR?: string;
|
|
53
|
+
VOVK_ORIGIN?: string;
|
|
54
|
+
VOVK_ROOT_ENTRY?: string;
|
|
55
|
+
VOVK_API_ENTRY_POINT?: string;
|
|
56
|
+
VOVK_ROOT_SEGMENT_MODULES_DIR_NAME?: string;
|
|
57
|
+
VOVK_LOG_LEVEL?: LogLevelNames;
|
|
58
|
+
VOVK_PRETTIFY_CLIENT?: string;
|
|
59
|
+
VOVK_DEV_HTTPS?: string;
|
|
60
|
+
__VOVK_START_WATCHER_IN_STANDALONE_MODE__?: 'true';
|
|
61
|
+
__VOVK_EXIT__?: 'true' | 'false';
|
|
62
|
+
};
|
|
63
|
+
type ClientConfigCommon = {
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
outDir?: string;
|
|
66
|
+
fromTemplates?: string[];
|
|
67
|
+
} & ({
|
|
68
|
+
excludeSegments?: never;
|
|
69
|
+
includeSegments?: string[];
|
|
70
|
+
} | {
|
|
71
|
+
excludeSegments?: string[];
|
|
72
|
+
includeSegments?: never;
|
|
73
|
+
});
|
|
74
|
+
type ClientConfigFull = ClientConfigCommon & {
|
|
75
|
+
package?: PackageJson;
|
|
76
|
+
};
|
|
77
|
+
type ClientConfigSegmented = ClientConfigCommon & {
|
|
78
|
+
packages?: Record<string, PackageJson>;
|
|
79
|
+
};
|
|
80
|
+
export type ClientTemplateDef = {
|
|
81
|
+
extends?: string;
|
|
82
|
+
templatePath: string | null;
|
|
83
|
+
origin?: string | null;
|
|
84
|
+
fullClient?: Omit<ClientConfigFull, 'fromTemplates' | 'enabled'>;
|
|
85
|
+
segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
|
|
86
|
+
segmentConfig?: false | Record<string, {
|
|
87
|
+
origin?: string;
|
|
88
|
+
rootEntry?: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
requires?: Record<string, string>;
|
|
91
|
+
};
|
|
92
|
+
export type VovkConfig = {
|
|
93
|
+
emitConfig?: boolean | (keyof VovkStrictConfig)[];
|
|
94
|
+
schemaOutDir?: string;
|
|
95
|
+
fullClient?: ClientConfigFull;
|
|
96
|
+
segmentedClient?: ClientConfigSegmented;
|
|
97
|
+
imports?: {
|
|
98
|
+
fetcher?: string | [string, string] | [string];
|
|
99
|
+
validateOnClient?: string | [string, string] | [string];
|
|
100
|
+
createRPC?: string | [string, string] | [string];
|
|
101
|
+
};
|
|
102
|
+
modulesDir?: string;
|
|
103
|
+
rootEntry?: string;
|
|
104
|
+
origin?: string;
|
|
105
|
+
rootSegmentModulesDirName?: string;
|
|
106
|
+
logLevel?: LogLevelNames;
|
|
107
|
+
prettifyClient?: boolean;
|
|
108
|
+
devHttps?: boolean;
|
|
109
|
+
clientTemplateDefs?: Record<string, ClientTemplateDef>;
|
|
110
|
+
moduleTemplates?: {
|
|
111
|
+
service?: string;
|
|
112
|
+
controller?: string;
|
|
113
|
+
[key: string]: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
libs?: Record<string, KnownAny>;
|
|
116
|
+
segmentConfig?: false | Record<string, {
|
|
117
|
+
origin?: string;
|
|
118
|
+
rootEntry?: boolean;
|
|
119
|
+
}>;
|
|
120
|
+
};
|
|
121
|
+
export type VovkStrictConfig = Required<Omit<VovkConfig, 'emitConfig' | 'libs' | 'imports' | 'fullClient' | 'segmentedClient'>> & {
|
|
122
|
+
emitConfig: (keyof VovkStrictConfig)[];
|
|
123
|
+
imports: {
|
|
124
|
+
fetcher: [string, string] | [string];
|
|
125
|
+
validateOnClient: [string, string] | [string] | null;
|
|
126
|
+
createRPC: [string, string] | [string];
|
|
127
|
+
};
|
|
128
|
+
libs: Record<string, KnownAny>;
|
|
129
|
+
fullClient: RequireFields<ClientConfigFull, 'enabled' | 'fromTemplates' | 'outDir'>;
|
|
130
|
+
segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir'>;
|
|
131
|
+
};
|
|
132
|
+
type RequireFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
133
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const vars = {
|
|
2
|
-
|
|
2
|
+
rpcModuleName: t.TheThing + 'Controller',
|
|
3
3
|
ServiceName: t.TheThing + 'Service',
|
|
4
4
|
}; %>
|
|
5
5
|
---
|
|
6
6
|
dir: <%= t.defaultDir %>
|
|
7
|
-
fileName: <%= vars.
|
|
8
|
-
sourceName: <%= vars.
|
|
7
|
+
fileName: <%= vars.rpcModuleName + '.ts' %>
|
|
8
|
+
sourceName: <%= vars.rpcModuleName %>
|
|
9
9
|
compiledName: <%= t.TheThing + 'RPC' %>
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ import <%= vars.ServiceName %> from './<%= vars.ServiceName %>';
|
|
|
15
15
|
<% } %>
|
|
16
16
|
|
|
17
17
|
@prefix('<%= t['the-things'] %>')
|
|
18
|
-
export default class <%= vars.
|
|
18
|
+
export default class <%= vars.rpcModuleName %> {
|
|
19
19
|
@get()
|
|
20
20
|
static get<%= t.TheThings %> = async (req: VovkRequest<null, { search: string }>) => {
|
|
21
21
|
const search = req.nextUrl.searchParams.get('search');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% const vars = {
|
|
2
|
-
|
|
2
|
+
rpcModuleName: t.TheThing + 'Controller',
|
|
3
3
|
ServiceName: t.TheThing + 'Service',
|
|
4
4
|
}; %>
|
|
5
5
|
---
|
|
@@ -9,17 +9,17 @@ sourceName: <%= vars.ServiceName %>
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
import type { VovkControllerBody, VovkControllerQuery } from 'vovk';
|
|
12
|
-
import type <%= vars.
|
|
12
|
+
import type <%= vars.rpcModuleName %> from './<%= vars.rpcModuleName %>';
|
|
13
13
|
|
|
14
14
|
export default class <%= vars.ServiceName %> {
|
|
15
|
-
static get<%= t.TheThings %> = (search: VovkControllerQuery<typeof <%= vars.
|
|
15
|
+
static get<%= t.TheThings %> = (search: VovkControllerQuery<typeof <%= vars.rpcModuleName %>.get<%= t.TheThings %>>['search']) => {
|
|
16
16
|
return { results: [], search };
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
static update<%= t.TheThing %> = (
|
|
20
20
|
id: string,
|
|
21
|
-
q: VovkControllerQuery<typeof <%= vars.
|
|
22
|
-
body: VovkControllerBody<typeof <%= vars.
|
|
21
|
+
q: VovkControllerQuery<typeof <%= vars.rpcModuleName %>.update<%= t.TheThing %>>['q'],
|
|
22
|
+
body: VovkControllerBody<typeof <%= vars.rpcModuleName %>.update<%= t.TheThing %>>
|
|
23
23
|
) => {
|
|
24
24
|
return { id, q, body };
|
|
25
25
|
};
|
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.148",
|
|
4
4
|
"bin": {
|
|
5
5
|
"vovk": "./dist/index.mjs"
|
|
6
6
|
},
|
|
@@ -60,7 +60,8 @@
|
|
|
60
60
|
"tar-stream": "^3.1.7",
|
|
61
61
|
"ts-morph": "^25.0.1",
|
|
62
62
|
"undici": "^7.8.0",
|
|
63
|
-
"type-fest": "^4.40.1"
|
|
63
|
+
"type-fest": "^4.40.1",
|
|
64
|
+
"vovk-openapi": "*"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@types/concat-stream": "^2.0.3",
|
|
File without changes
|