vovk-cli 0.0.1-draft.1 → 0.0.1-draft.100
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 +29 -1
- package/client-templates/main/main.cjs.ejs +15 -0
- package/client-templates/main/main.d.cts.ejs +14 -0
- package/client-templates/module/module.d.mts.ejs +14 -0
- package/client-templates/module/module.mjs.ejs +24 -0
- package/client-templates/python/__init__.py +276 -0
- package/client-templates/ts/index.ts.ejs +25 -0
- package/dist/dev/diffSchema.d.mts +36 -0
- package/dist/{watcher → dev}/diffSchema.mjs +3 -11
- package/dist/{watcher → dev}/ensureSchemaFiles.d.mts +3 -0
- package/dist/{watcher → dev}/ensureSchemaFiles.mjs +43 -16
- package/dist/dev/index.d.mts +6 -0
- package/dist/{watcher → dev}/index.mjs +138 -69
- package/dist/{watcher/isMetadataEmpty.mjs → dev/isSchemaEmpty.mjs} +1 -1
- package/dist/{watcher → dev}/logDiffResult.d.mts +2 -2
- package/dist/dev/logDiffResult.mjs +57 -0
- package/dist/{watcher → dev}/writeOneSchemaFile.d.mts +2 -1
- package/dist/{watcher → dev}/writeOneSchemaFile.mjs +6 -4
- package/dist/generate/ensureClient.d.mts +5 -0
- package/dist/generate/ensureClient.mjs +30 -0
- package/dist/generate/getClientTemplates.d.mts +16 -0
- package/dist/generate/getClientTemplates.mjs +42 -0
- package/dist/generate/index.d.mts +13 -0
- package/dist/generate/index.mjs +94 -0
- package/dist/getProjectInfo/getConfig.d.mts +3 -3
- package/dist/getProjectInfo/getConfig.mjs +11 -5
- package/dist/getProjectInfo/getConfigAbsolutePaths.mjs +2 -2
- package/dist/getProjectInfo/getRelativeSrcRoot.mjs +4 -4
- package/dist/getProjectInfo/getUserConfig.mjs +4 -2
- package/dist/getProjectInfo/importUncachedModule.mjs +0 -1
- package/dist/getProjectInfo/importUncachedModuleWorker.mjs +0 -1
- package/dist/getProjectInfo/index.d.mts +14 -5
- package/dist/getProjectInfo/index.mjs +21 -13
- package/dist/index.d.mts +1 -23
- package/dist/index.mjs +58 -60
- package/dist/init/checkTSConfigForExperimentalDecorators.mjs +2 -2
- package/dist/init/createConfig.d.mts +3 -4
- package/dist/init/createConfig.mjs +9 -8
- package/dist/init/getTemplateFilesFromPackage.d.mts +2 -1
- package/dist/init/getTemplateFilesFromPackage.mjs +4 -5
- package/dist/init/index.d.mts +2 -3
- package/dist/init/index.mjs +61 -97
- package/dist/init/installDependencies.d.mts +4 -1
- package/dist/init/installDependencies.mjs +2 -2
- package/dist/init/logUpdateDependenciesError.d.mts +11 -0
- package/dist/init/logUpdateDependenciesError.mjs +45 -0
- package/dist/init/updateDependenciesWithoutInstalling.d.mts +3 -2
- package/dist/init/updateDependenciesWithoutInstalling.mjs +13 -8
- package/dist/init/updateNPMScripts.d.mts +3 -1
- package/dist/init/updateNPMScripts.mjs +10 -6
- package/dist/init/updateTypeScriptConfig.mjs +2 -2
- package/dist/initProgram.d.mts +2 -0
- package/dist/initProgram.mjs +22 -0
- package/dist/locateSegments.d.mts +7 -1
- package/dist/locateSegments.mjs +9 -6
- package/dist/new/addClassToSegmentCode.d.mts +1 -2
- package/dist/new/addClassToSegmentCode.mjs +9 -5
- package/dist/new/addCommonTerms.mjs +1 -0
- package/dist/new/index.d.mts +2 -2
- package/dist/new/index.mjs +14 -3
- package/dist/new/newModule.d.mts +7 -2
- package/dist/new/newModule.mjs +54 -31
- package/dist/new/newSegment.d.mts +3 -2
- package/dist/new/newSegment.mjs +10 -8
- package/dist/new/render.d.mts +6 -8
- package/dist/new/render.mjs +40 -13
- package/dist/postinstall.mjs +16 -17
- package/dist/types.d.mts +63 -8
- package/dist/utils/debounceWithArgs.d.mts +1 -1
- package/dist/utils/debounceWithArgs.mjs +24 -9
- package/dist/utils/formatLoggedSegmentName.mjs +1 -1
- package/dist/utils/getAvailablePort.mjs +3 -2
- package/dist/utils/getFileSystemEntryType.mjs +1 -1
- package/package.json +21 -18
- package/templates/controller.ejs +23 -23
- package/templates/service.ejs +24 -4
- package/dist/generateClient.d.mts +0 -7
- package/dist/generateClient.mjs +0 -97
- package/dist/getProjectInfo/directoryExists.d.mts +0 -1
- package/dist/getProjectInfo/directoryExists.mjs +0 -10
- package/dist/watcher/diffSchema.d.mts +0 -43
- package/dist/watcher/index.d.mts +0 -6
- package/dist/watcher/logDiffResult.mjs +0 -90
- package/templates/worker.ejs +0 -1
- package/templates_old/MyThingController.c.only.template.ts +0 -32
- package/templates_old/MyThingController.c.template.ts +0 -34
- package/templates_old/MyThingService.s.template.ts +0 -18
- package/templates_old/controller.ejs +0 -85
- package/templates_old/service.ejs +0 -9
- package/templates_old/worker.ejs +0 -9
- package/templates_old/zod/MyThingController.c.only.template.ts +0 -32
- package/templates_old/zod/MyThingController.c.template.ts +0 -39
- package/templates_old/zod/MyThingService.s.template.ts +0 -18
- /package/dist/{watcher/isMetadataEmpty.d.mts → dev/isSchemaEmpty.d.mts} +0 -0
package/templates/service.ejs
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
<%
|
|
2
|
-
|
|
1
|
+
<% const vars = {
|
|
2
|
+
ControllerName: t.TheThing + 'Controller',
|
|
3
|
+
ServiceName: t.TheThing + 'Service',
|
|
4
|
+
}; %>
|
|
3
5
|
---
|
|
4
|
-
|
|
6
|
+
dir: <%= t.defaultDir %>
|
|
7
|
+
fileName: <%= vars.ServiceName + '.ts' %>
|
|
5
8
|
---
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
import type { VovkControllerBody, VovkControllerQuery } from 'vovk';
|
|
11
|
+
import type <%= vars.ControllerName %> from './<%= vars.ControllerName %>';
|
|
12
|
+
|
|
13
|
+
export default class <%= vars.ServiceName %> {
|
|
14
|
+
static get<%= t.TheThings %> = (search: VovkControllerQuery<typeof <%= vars.ControllerName %>.get<%= t.TheThings %>>['search']) => {
|
|
15
|
+
return { results: [], search };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
static update<%= t.TheThing %> = (
|
|
19
|
+
id: string,
|
|
20
|
+
q: VovkControllerQuery<typeof <%= vars.ControllerName %>.update<%= t.TheThing %>>['q'],
|
|
21
|
+
body: VovkControllerBody<typeof <%= vars.ControllerName %>.update<%= t.TheThing %>>
|
|
22
|
+
) => {
|
|
23
|
+
return { id, q, body };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// ...
|
|
27
|
+
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ProjectInfo } from './getProjectInfo/index.mjs';
|
|
2
|
-
import type { Segment } from './locateSegments.mjs';
|
|
3
|
-
import type { VovkSchema } from 'vovk';
|
|
4
|
-
export default function generateClient(projectInfo: ProjectInfo, segments: Segment[], segmentsSchema: Record<string, VovkSchema>): Promise<{
|
|
5
|
-
written: boolean;
|
|
6
|
-
path: string;
|
|
7
|
-
}>;
|
package/dist/generateClient.mjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs/promises';
|
|
3
|
-
import formatLoggedSegmentName from './utils/formatLoggedSegmentName.mjs';
|
|
4
|
-
import prettify from './utils/prettify.mjs';
|
|
5
|
-
export default async function generateClient(projectInfo, segments, segmentsSchema) {
|
|
6
|
-
const { config, cwd, log, validateOnClientImportPath, apiEntryPoint, fetcherClientImportPath, schemaOutImportPath } = projectInfo;
|
|
7
|
-
const now = Date.now();
|
|
8
|
-
const clientoOutDirAbsolutePath = path.join(cwd, config.clientOutDir);
|
|
9
|
-
let dts = `// auto-generated
|
|
10
|
-
/* eslint-disable */
|
|
11
|
-
import type { clientizeController } from 'vovk/client';
|
|
12
|
-
import type { promisifyWorker } from 'vovk/worker';
|
|
13
|
-
import type { VovkClientFetcher } from 'vovk/client';
|
|
14
|
-
import type fetcher from '${fetcherClientImportPath}';
|
|
15
|
-
|
|
16
|
-
`;
|
|
17
|
-
let js = `// auto-generated
|
|
18
|
-
/* eslint-disable */
|
|
19
|
-
const { clientizeController } = require('vovk/client');
|
|
20
|
-
const { promisifyWorker } = require('vovk/worker');
|
|
21
|
-
const { default: fetcher } = require('${fetcherClientImportPath}');
|
|
22
|
-
const schema = require('${schemaOutImportPath}');
|
|
23
|
-
`;
|
|
24
|
-
let ts = `// auto-generated
|
|
25
|
-
/* eslint-disable */
|
|
26
|
-
import { clientizeController } from 'vovk/client';
|
|
27
|
-
import { promisifyWorker } from 'vovk/worker';
|
|
28
|
-
import type { VovkClientFetcher } from 'vovk/client';
|
|
29
|
-
import fetcher from '${fetcherClientImportPath}';
|
|
30
|
-
import schema from '${schemaOutImportPath}';
|
|
31
|
-
|
|
32
|
-
`;
|
|
33
|
-
for (let i = 0; i < segments.length; i++) {
|
|
34
|
-
const { routeFilePath, segmentName } = segments[i];
|
|
35
|
-
const schema = segmentsSchema[segmentName];
|
|
36
|
-
if (!schema) {
|
|
37
|
-
throw new Error(`Unable to generate client. No schema found for ${formatLoggedSegmentName(segmentName)}`);
|
|
38
|
-
}
|
|
39
|
-
if (!schema.emitSchema)
|
|
40
|
-
continue;
|
|
41
|
-
const importRouteFilePath = path.relative(config.clientOutDir, routeFilePath);
|
|
42
|
-
dts += `import type { Controllers as Controllers${i}, Workers as Workers${i} } from "${importRouteFilePath}";\n`;
|
|
43
|
-
ts += `import type { Controllers as Controllers${i}, Workers as Workers${i} } from "${importRouteFilePath}";\n`;
|
|
44
|
-
}
|
|
45
|
-
dts += `
|
|
46
|
-
type Options = typeof fetcher extends VovkClientFetcher<infer U> ? U : never;
|
|
47
|
-
`;
|
|
48
|
-
ts += `
|
|
49
|
-
${validateOnClientImportPath ? `import validateOnClient from '${validateOnClientImportPath}';\n` : '\nconst validateOnClient = undefined;'}
|
|
50
|
-
type Options = typeof fetcher extends VovkClientFetcher<infer U> ? U : never;
|
|
51
|
-
const prefix = '${apiEntryPoint}';
|
|
52
|
-
`;
|
|
53
|
-
js += `
|
|
54
|
-
const { default: validateOnClient = null } = ${validateOnClientImportPath ? `require('${validateOnClientImportPath}')` : '{}'};
|
|
55
|
-
const prefix = '${apiEntryPoint}';
|
|
56
|
-
`;
|
|
57
|
-
for (let i = 0; i < segments.length; i++) {
|
|
58
|
-
const { segmentName } = segments[i];
|
|
59
|
-
const schema = segmentsSchema[segmentName];
|
|
60
|
-
if (!schema) {
|
|
61
|
-
throw new Error(`Unable to generate client. No schema found for ${formatLoggedSegmentName(segmentName)}`);
|
|
62
|
-
}
|
|
63
|
-
if (!schema.emitSchema)
|
|
64
|
-
continue;
|
|
65
|
-
for (const key of Object.keys(schema.controllers)) {
|
|
66
|
-
dts += `export const ${key}: ReturnType<typeof clientizeController<Controllers${i}["${key}"], Options>>;\n`;
|
|
67
|
-
js += `exports.${key} = clientizeController(schema['${segmentName}'].controllers.${key}, '${segmentName}', { fetcher, validateOnClient, defaultOptions: { prefix } });\n`;
|
|
68
|
-
ts += `export const ${key} = clientizeController<Controllers${i}["${key}"], Options>(schema['${segmentName}'].controllers.${key}, '${segmentName}', { fetcher, validateOnClient, defaultOptions: { prefix } });\n`;
|
|
69
|
-
}
|
|
70
|
-
for (const key of Object.keys(schema.workers)) {
|
|
71
|
-
dts += `export const ${key}: ReturnType<typeof promisifyWorker<Workers${i}["${key}"]>>;\n`;
|
|
72
|
-
js += `exports.${key} = promisifyWorker(null, schema['${segmentName}'].workers.${key});\n`;
|
|
73
|
-
ts += `export const ${key} = promisifyWorker<Workers${i}["${key}"]>(null, schema['${segmentName}'].workers.${key});\n`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const localJsAbsolutePath = path.join(clientoOutDirAbsolutePath, 'client.js');
|
|
77
|
-
const localDtsAbsolutePath = path.join(clientoOutDirAbsolutePath, 'client.d.ts');
|
|
78
|
-
const localTsAbsolutePath = path.join(clientoOutDirAbsolutePath, 'index.ts');
|
|
79
|
-
const existingJs = await fs.readFile(localJsAbsolutePath, 'utf-8').catch(() => '');
|
|
80
|
-
const existingDts = await fs.readFile(localDtsAbsolutePath, 'utf-8').catch(() => '');
|
|
81
|
-
const existingTs = await fs.readFile(localTsAbsolutePath, 'utf-8').catch(() => '');
|
|
82
|
-
if (config.prettifyClient) {
|
|
83
|
-
js = await prettify(js, localJsAbsolutePath);
|
|
84
|
-
dts = await prettify(dts, localDtsAbsolutePath);
|
|
85
|
-
ts = await prettify(ts, localTsAbsolutePath);
|
|
86
|
-
}
|
|
87
|
-
if (existingJs === js && existingDts === dts && existingTs === ts) {
|
|
88
|
-
log.debug(`Client is up to date and doesn't need to be regenerated (${Date.now() - now}ms)`);
|
|
89
|
-
return { written: false, path: clientoOutDirAbsolutePath };
|
|
90
|
-
}
|
|
91
|
-
await fs.mkdir(clientoOutDirAbsolutePath, { recursive: true });
|
|
92
|
-
await fs.writeFile(localJsAbsolutePath, js);
|
|
93
|
-
await fs.writeFile(localDtsAbsolutePath, dts);
|
|
94
|
-
await fs.writeFile(localTsAbsolutePath, ts);
|
|
95
|
-
log.info(`Client generated in ${Date.now() - now}ms`);
|
|
96
|
-
return { written: true, path: clientoOutDirAbsolutePath };
|
|
97
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function directoryExists(dir: string): Promise<boolean>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { VovkSchema } from 'vovk';
|
|
2
|
-
import { _VovkControllerSchema, _VovkWorkerSchema } from 'vovk/types';
|
|
3
|
-
interface HandlersDiff {
|
|
4
|
-
nameOfClass: string;
|
|
5
|
-
added: string[];
|
|
6
|
-
removed: string[];
|
|
7
|
-
changed: string[];
|
|
8
|
-
}
|
|
9
|
-
interface WorkersOrControllersDiff {
|
|
10
|
-
added: string[];
|
|
11
|
-
removed: string[];
|
|
12
|
-
handlers: HandlersDiff[];
|
|
13
|
-
}
|
|
14
|
-
export interface DiffResult {
|
|
15
|
-
workers: WorkersOrControllersDiff;
|
|
16
|
-
controllers: WorkersOrControllersDiff;
|
|
17
|
-
}
|
|
18
|
-
export declare function diffHandlers<T extends _VovkWorkerSchema['_handlers'] | _VovkControllerSchema['_handlers']>(oldHandlers: T, newHandlers: T, nameOfClass: string): HandlersDiff;
|
|
19
|
-
export declare function diffWorkersOrControllers<T extends VovkSchema['controllers'] | VovkSchema['workers']>(oldItems: T, newItems: T): WorkersOrControllersDiff;
|
|
20
|
-
/**
|
|
21
|
-
example output:
|
|
22
|
-
{
|
|
23
|
-
workers: {
|
|
24
|
-
added: ["WorkerC"],
|
|
25
|
-
removed: ["WorkerA"],
|
|
26
|
-
handlers: []
|
|
27
|
-
},
|
|
28
|
-
controllers: {
|
|
29
|
-
added: ["ControllerC"],
|
|
30
|
-
removed: ["ControllerB"],
|
|
31
|
-
handlers: [
|
|
32
|
-
{
|
|
33
|
-
nameOfClass: "ControllerA",
|
|
34
|
-
added: ["handlerF"],
|
|
35
|
-
removed: [],
|
|
36
|
-
changed: ["handlerD"]
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
*/
|
|
42
|
-
export default function diffSchema(oldJson: VovkSchema, newJson: VovkSchema): DiffResult;
|
|
43
|
-
export {};
|
package/dist/watcher/index.d.mts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
|
|
2
|
-
import chalkHighlightThing from '../utils/chalkHighlightThing.mjs';
|
|
3
|
-
export default function logDiffResult(segmentName, diffResult, projectInfo) {
|
|
4
|
-
const diffNormalized = [];
|
|
5
|
-
diffResult.workers.added.forEach((name) => {
|
|
6
|
-
diffNormalized.push({ what: 'worker', type: 'added', name });
|
|
7
|
-
});
|
|
8
|
-
diffResult.workers.removed.forEach((name) => {
|
|
9
|
-
diffNormalized.push({ what: 'worker', type: 'removed', name });
|
|
10
|
-
});
|
|
11
|
-
diffResult.workers.handlers.forEach((handler) => {
|
|
12
|
-
handler.added.forEach((name) => {
|
|
13
|
-
diffNormalized.push({ what: 'workerHandler', type: 'added', name: `${handler.nameOfClass}.${name}` });
|
|
14
|
-
});
|
|
15
|
-
handler.removed.forEach((name) => {
|
|
16
|
-
diffNormalized.push({ what: 'workerHandler', type: 'removed', name: `${handler.nameOfClass}.${name}` });
|
|
17
|
-
});
|
|
18
|
-
handler.changed.forEach((name) => {
|
|
19
|
-
diffNormalized.push({ what: 'workerHandler', type: 'changed', name: `${handler.nameOfClass}.${name}` });
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
diffResult.controllers.added.forEach((name) => {
|
|
23
|
-
diffNormalized.push({ what: 'controller', type: 'added', name });
|
|
24
|
-
});
|
|
25
|
-
diffResult.controllers.removed.forEach((name) => {
|
|
26
|
-
diffNormalized.push({ what: 'controller', type: 'removed', name });
|
|
27
|
-
});
|
|
28
|
-
diffResult.controllers.handlers.forEach((handler) => {
|
|
29
|
-
handler.added.forEach((name) => {
|
|
30
|
-
diffNormalized.push({ what: 'controllerHandler', type: 'added', name: `${handler.nameOfClass}.${name}` });
|
|
31
|
-
});
|
|
32
|
-
handler.removed.forEach((name) => {
|
|
33
|
-
diffNormalized.push({ what: 'controllerHandler', type: 'removed', name: `${handler.nameOfClass}.${name}` });
|
|
34
|
-
});
|
|
35
|
-
handler.changed.forEach((name) => {
|
|
36
|
-
diffNormalized.push({ what: 'controllerHandler', type: 'changed', name: `${handler.nameOfClass}.${name}` });
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
const LIMIT = diffNormalized.length < 12 ? diffNormalized.length : 10;
|
|
40
|
-
for (const diffNormalizedItem of diffNormalized.slice(0, LIMIT)) {
|
|
41
|
-
switch (diffNormalizedItem.what) {
|
|
42
|
-
case 'worker':
|
|
43
|
-
switch (diffNormalizedItem.type) {
|
|
44
|
-
case 'added':
|
|
45
|
-
projectInfo.log.info(`Schema for worker ${chalkHighlightThing(diffNormalizedItem.name)} has been added at ${formatLoggedSegmentName(segmentName)}`);
|
|
46
|
-
break;
|
|
47
|
-
case 'removed':
|
|
48
|
-
projectInfo.log.info(`Schema for worker ${chalkHighlightThing(diffNormalizedItem.name)} has been removed from ${formatLoggedSegmentName(segmentName)}`);
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
break;
|
|
52
|
-
case 'controller':
|
|
53
|
-
switch (diffNormalizedItem.type) {
|
|
54
|
-
case 'added':
|
|
55
|
-
projectInfo.log.info(`Schema for controller ${chalkHighlightThing(diffNormalizedItem.name)} has been added at ${formatLoggedSegmentName(segmentName)}`);
|
|
56
|
-
break;
|
|
57
|
-
case 'removed':
|
|
58
|
-
projectInfo.log.info(`Schema for controller ${chalkHighlightThing(diffNormalizedItem.name)} has been removed from ${formatLoggedSegmentName(segmentName)}`);
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
case 'workerHandler':
|
|
63
|
-
switch (diffNormalizedItem.type) {
|
|
64
|
-
case 'added':
|
|
65
|
-
projectInfo.log.info(`Schema for worker method ${chalkHighlightThing(diffNormalizedItem.name)} has been added at ${formatLoggedSegmentName(segmentName)}`);
|
|
66
|
-
break;
|
|
67
|
-
case 'removed':
|
|
68
|
-
projectInfo.log.info(`Schema for worker method ${chalkHighlightThing(diffNormalizedItem.name)} has been removed from ${formatLoggedSegmentName(segmentName)}`);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
case 'controllerHandler':
|
|
73
|
-
switch (diffNormalizedItem.type) {
|
|
74
|
-
case 'added':
|
|
75
|
-
projectInfo.log.info(`Schema for controller method ${chalkHighlightThing(diffNormalizedItem.name)} has been added at ${formatLoggedSegmentName(segmentName)}`);
|
|
76
|
-
break;
|
|
77
|
-
case 'removed':
|
|
78
|
-
projectInfo.log.info(`Schema for controller method ${chalkHighlightThing(diffNormalizedItem.name)} has been removed from ${formatLoggedSegmentName(segmentName)}`);
|
|
79
|
-
break;
|
|
80
|
-
case 'changed':
|
|
81
|
-
projectInfo.log.info(`Schema for controller method ${chalkHighlightThing(diffNormalizedItem.name)} has been changed at ${formatLoggedSegmentName(segmentName)}`);
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (diffNormalized.length > LIMIT) {
|
|
88
|
-
projectInfo.log.info(`... and ${diffNormalized.length - LIMIT} more changes`);
|
|
89
|
-
}
|
|
90
|
-
}
|
package/templates/worker.ejs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// TODO
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { prefix, get, put, post, del, type VovkRequest } from 'vovk';
|
|
2
|
-
|
|
3
|
-
@prefix('my-things')
|
|
4
|
-
export default class MyThingController {
|
|
5
|
-
@get()
|
|
6
|
-
static getMyThingsExample = (req: VovkRequest<null, { q: string }>) => {
|
|
7
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
8
|
-
return { q };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
@put(':id')
|
|
12
|
-
static updateMyThingExample = async (
|
|
13
|
-
req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>,
|
|
14
|
-
params: { id: string }
|
|
15
|
-
) => {
|
|
16
|
-
const { id } = params;
|
|
17
|
-
const body = await req.json();
|
|
18
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
19
|
-
|
|
20
|
-
return { id, q, body };
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
@post()
|
|
24
|
-
static createMyThingExample = () => {
|
|
25
|
-
// ...
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
@del(':id')
|
|
29
|
-
static deleteMyThingExample = () => {
|
|
30
|
-
// ...
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { prefix, get, put, post, del, type VovkRequest } from 'vovk';
|
|
2
|
-
import MyThingService from './MyThingService.s.template';
|
|
3
|
-
|
|
4
|
-
@prefix('my-things')
|
|
5
|
-
export default class MyThingController {
|
|
6
|
-
@get()
|
|
7
|
-
static getMyThingsExample(req: VovkRequest<null, { q: string }>) {
|
|
8
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
9
|
-
|
|
10
|
-
return MyThingService.getMyThingsExample(q);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@put(':id')
|
|
14
|
-
static updateMyThingExample = async (
|
|
15
|
-
req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>,
|
|
16
|
-
params: { id: string }
|
|
17
|
-
) => {
|
|
18
|
-
const { id } = params;
|
|
19
|
-
const body = await req.json();
|
|
20
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
21
|
-
|
|
22
|
-
return MyThingService.updateMyThingExample(id, q, body);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
@post()
|
|
26
|
-
static createMyThingExample = () => {
|
|
27
|
-
// ...
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
@del(':id')
|
|
31
|
-
static deleteMyThingExample = () => {
|
|
32
|
-
// ...
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { VovkControllerBody, VovkControllerQuery } from 'vovk';
|
|
2
|
-
import type MyThingController from './MyThingController.c.template';
|
|
3
|
-
|
|
4
|
-
export default class MyThingService {
|
|
5
|
-
static getMyThingsExample = (q: VovkControllerQuery<typeof MyThingController.getMyThingsExample>['q']) => {
|
|
6
|
-
return { q };
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
static updateMyThingExample = (
|
|
10
|
-
id: string,
|
|
11
|
-
q: VovkControllerQuery<typeof MyThingController.updateMyThingExample>['q'],
|
|
12
|
-
body: VovkControllerBody<typeof MyThingController.updateMyThingExample>
|
|
13
|
-
) => {
|
|
14
|
-
return { id, q, body };
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// ...
|
|
18
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
<% var modulePascalName = _.upperFirst(_.camelCase(moduleName)); %>
|
|
2
|
-
<% var modulePascalNamePlural = pluralize(modulePascalName); %>
|
|
3
|
-
<% var ControllerName = modulePascalName + 'Controller'; %>
|
|
4
|
-
<% var RPCName = modulePascalName + 'RPC'; %>
|
|
5
|
-
<% var ServiceName = modulePascalName + 'Service'; %>
|
|
6
|
-
---
|
|
7
|
-
# Relative to modules dir
|
|
8
|
-
fileName: <%= getFileDir(segmentName, moduleName) + ControllerName + '.ts' %>
|
|
9
|
-
className: <%= ControllerName %> # Used to define a controller in a segment
|
|
10
|
-
rpcName: <%= RPCName %> # Used to define an exported RPC class in a segment
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
import { prefix, get, put, post, del<%= !config.validationLibrary ? ', type VovkRequest' : '' %> } from 'vovk';
|
|
14
|
-
<% if(withService) { %>
|
|
15
|
-
import <%= ServiceName %> from './<%= ServiceName %>';
|
|
16
|
-
<% } %>
|
|
17
|
-
<% if(config.validationLibrary === 'vovk-zod') { %>
|
|
18
|
-
import { withZod } from 'vovk-zod';
|
|
19
|
-
import { z } from 'zod';
|
|
20
|
-
<% } %>
|
|
21
|
-
|
|
22
|
-
@prefix('<%= _.kebabCase(moduleName).toLowerCase() %>')
|
|
23
|
-
export default class <%= ControllerName %> {
|
|
24
|
-
@get()
|
|
25
|
-
<% if(config.validationLibrary === 'vovk-zod') { %>
|
|
26
|
-
async get<%= modulePascalNamePlural %> = withZod(null, z.object({ q: z.string() }), (req) => {
|
|
27
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
28
|
-
<% if(withService) { %>
|
|
29
|
-
return <%= ServiceName %>.getMyThingsExample(q);
|
|
30
|
-
<% } else { %>
|
|
31
|
-
return { q };
|
|
32
|
-
<% } %>
|
|
33
|
-
});
|
|
34
|
-
<% } else { %>
|
|
35
|
-
static get<%= modulePascalNamePlural %> = async (req: VovkRequest<null, { q: string }>) => {
|
|
36
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
37
|
-
<% if(withService) { %>
|
|
38
|
-
return <%= ServiceName %>.getMyThingsExample(q);
|
|
39
|
-
<% } else { %>
|
|
40
|
-
return { q };
|
|
41
|
-
<% } %>
|
|
42
|
-
}
|
|
43
|
-
<% } %>
|
|
44
|
-
|
|
45
|
-
@put(':id')
|
|
46
|
-
<% if(config.validationLibrary === 'vovk-zod') { %>
|
|
47
|
-
static update<%= modulePascalNamePlural %> = withZod(
|
|
48
|
-
z.object({
|
|
49
|
-
foo: z.union([z.literal('bar'), z.literal('baz')]),
|
|
50
|
-
}),
|
|
51
|
-
z.object({ q: z.string() }),
|
|
52
|
-
async (req, params: { id: string }) => {
|
|
53
|
-
const { id } = params;
|
|
54
|
-
const body = await req.json();
|
|
55
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
56
|
-
<% if(withService) { %>
|
|
57
|
-
return MyThingService.updateMyThingExample(id, q, body);
|
|
58
|
-
<% } else { %>
|
|
59
|
-
return { id, body, q };
|
|
60
|
-
<% } %>
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
<% } else { %>
|
|
64
|
-
static update<%= modulePascalNamePlural %> = async (req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>, params: { id: string }) => {
|
|
65
|
-
const { id } = params;
|
|
66
|
-
const body = await req.json();
|
|
67
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
68
|
-
<% if(withService) { %>
|
|
69
|
-
return MyThingService.updateMyThingExample(id, q, body);
|
|
70
|
-
<% } else { %>
|
|
71
|
-
return { id, body, q };
|
|
72
|
-
<% } %>
|
|
73
|
-
};
|
|
74
|
-
<% } %>
|
|
75
|
-
|
|
76
|
-
@post()
|
|
77
|
-
static create<%= modulePascalNamePlural %> = () => {
|
|
78
|
-
// ...
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
@del(':id')
|
|
82
|
-
static delete<%= modulePascalNamePlural %> = () => {
|
|
83
|
-
// ...
|
|
84
|
-
};
|
|
85
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<% var modulePascalName = _.upperFirst(_.camelCase(moduleName); %>
|
|
2
|
-
<% var ServiceName = modulePascalName + 'Service'; %>
|
|
3
|
-
|
|
4
|
-
---
|
|
5
|
-
# Relative to modules dir
|
|
6
|
-
fileName: <%= getFileDir(segmentName, moduleName) + ServiceName + '.ts' %>
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
// TO DO: Implement <%= ServiceName %>
|
package/templates_old/worker.ejs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<% var modulePascalName = _.upperFirst(_.camelCase(moduleName); %>
|
|
2
|
-
<% var WorkerName = modulePascalName + 'Worker'; %>
|
|
3
|
-
|
|
4
|
-
---
|
|
5
|
-
# Relative to modules dir
|
|
6
|
-
fileName: <%= getFileDir(segmentName, moduleName) + WorkerName + '.ts' %>
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
// TO DO: Implement <%= WorkerName %>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { prefix, get, put, post, del, type VovkRequest } from 'vovk';
|
|
2
|
-
|
|
3
|
-
@prefix('my-thing')
|
|
4
|
-
export default class MyThingController {
|
|
5
|
-
@get()
|
|
6
|
-
static getMyThingsExample = (req: VovkRequest<null, { q: string }>) => {
|
|
7
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
8
|
-
return { q };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
@put(':id')
|
|
12
|
-
static updateMyThingExample = async (
|
|
13
|
-
req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>,
|
|
14
|
-
params: { id: string }
|
|
15
|
-
) => {
|
|
16
|
-
const { id } = params;
|
|
17
|
-
const body = await req.json();
|
|
18
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
19
|
-
|
|
20
|
-
return { id, q, body };
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
@post()
|
|
24
|
-
static createMyThingExample = () => {
|
|
25
|
-
// ...
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
@del(':id')
|
|
29
|
-
static deleteMyThingExample = () => {
|
|
30
|
-
// ...
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { prefix, get, put, post, del } from 'vovk';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { withZod } from 'vovk-zod';
|
|
4
|
-
import MyThingService from './MyThingService.s.template';
|
|
5
|
-
|
|
6
|
-
@prefix('my-thing')
|
|
7
|
-
export default class MyThingController {
|
|
8
|
-
@get()
|
|
9
|
-
static getMyThingsExample = withZod(null, z.object({ q: z.string() }), (req) => {
|
|
10
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
11
|
-
|
|
12
|
-
return MyThingService.getMyThingsExample(q);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
@put(':id')
|
|
16
|
-
static updateMyThingExample = withZod(
|
|
17
|
-
z.object({
|
|
18
|
-
foo: z.union([z.literal('bar'), z.literal('baz')]),
|
|
19
|
-
}),
|
|
20
|
-
z.object({ q: z.string() }),
|
|
21
|
-
async (req, params: { id: string }) => {
|
|
22
|
-
const { id } = params;
|
|
23
|
-
const body = await req.json();
|
|
24
|
-
const q = req.nextUrl.searchParams.get('q');
|
|
25
|
-
|
|
26
|
-
return MyThingService.updateMyThingExample(id, q, body);
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
@post()
|
|
31
|
-
static async createMyThingExample() {
|
|
32
|
-
// ...
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@del(':id')
|
|
36
|
-
static deleteMyThingExample() {
|
|
37
|
-
// ...
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { VovkControllerBody, VovkControllerQuery } from 'vovk';
|
|
2
|
-
import type MyThingController from './MyThingController.c.template';
|
|
3
|
-
|
|
4
|
-
export default class MyThingService {
|
|
5
|
-
static getMyThingsExample = (q: VovkControllerQuery<typeof MyThingController.getMyThingsExample>['q']) => {
|
|
6
|
-
return { q };
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
static updateMyThingExample = (
|
|
10
|
-
id: string,
|
|
11
|
-
q: VovkControllerQuery<typeof MyThingController.updateMyThingExample>['q'],
|
|
12
|
-
body: VovkControllerBody<typeof MyThingController.updateMyThingExample>
|
|
13
|
-
) => {
|
|
14
|
-
return { id, q, body };
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// ...
|
|
18
|
-
}
|
|
File without changes
|