vovk-cli 0.0.1-draft.300 → 0.0.1-draft.302

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.
@@ -5,7 +5,7 @@ const { schema } = require('./schema.cjs');
5
5
  const { validateOnClient = null } = <%- t.imports.validateOnClient ? `require('${t.imports.validateOnClient}')` : '{}'%>;
6
6
  <% Object.values(t.schema.segments).filter((segment) => segment.emitSchema).forEach((segment) => { %>
7
7
  <% Object.entries(t.segmentMeta[segment.segmentName].reExports).forEach(([reExportWhatCommaDivisible, reExportFrom]) => {
8
- reExportWhatCommaDivisible.split(',').forEach((reExportWhat) => { %>
8
+ reExportWhatCommaDivisible.split(/\s*,\s*/).forEach((reExportWhat) => { %>
9
9
  exports['<%= reExportWhat.split(/\s+as\s+/)[1] ?? reExportWhat %>'] = require('<%= reExportFrom %>')['<%= reExportWhat.split(/\s+as\s+/)[0] %>'];
10
10
  <% })
11
11
  }) %>
@@ -1 +1 @@
1
- <%- JSON.stringify(t._.pickBy(t.schema.segments, (segment) => segment.segmentType === 'mixin'), null, 2) %>
1
+ <%- JSON.stringify(t._.pickBy(t.schema.segments, (segment) => segment.segmentType === 'mixin'), null, 2) %>
@@ -13,11 +13,10 @@ export async function bundle({ projectInfo, fullSchema, cliBundleOptions, }) {
13
13
  const tsFullClientOutAbsoluteDirInput = path.join(cwd, bundleConfig.tsClientOutDir);
14
14
  const tsClientOutDir = cliBundleOptions?.tsClientOutDir ?? bundleConfig.tsClientOutDir;
15
15
  const dontDeleteTsClientOutDirAfter = cliBundleOptions?.dontDeleteTsClientOutDirAfter ?? bundleConfig?.dontDeleteTsClientOutDirAfter ?? false;
16
- const sourcemap = cliBundleOptions?.sourcemap ?? bundleConfig?.sourcemap;
17
16
  if (!tsClientOutDir) {
18
17
  throw new Error('No output directory specified for composed client');
19
18
  }
20
- const outDir = cliBundleOptions?.outDir ?? bundleConfig.outDir;
19
+ const outDir = cliBundleOptions?.outDir ?? bundleConfig.tsdownBuildOptions.outDir;
21
20
  if (!outDir) {
22
21
  throw new Error('No output directory specified for bundling');
23
22
  }
@@ -39,7 +38,6 @@ export async function bundle({ projectInfo, fullSchema, cliBundleOptions, }) {
39
38
  composedOnly: true,
40
39
  composedIncludeSegments: cliBundleOptions.includeSegments ?? bundleConfig.includeSegments,
41
40
  composedExcludeSegments: cliBundleOptions.excludeSegments ?? bundleConfig.excludeSegments,
42
- forceTsStandalone: cliBundleOptions.forceTsStandalone,
43
41
  },
44
42
  });
45
43
  await build({
@@ -48,7 +46,7 @@ export async function bundle({ projectInfo, fullSchema, cliBundleOptions, }) {
48
46
  format: ['cjs', 'esm'],
49
47
  fixedExtension: true,
50
48
  outDir,
51
- sourcemap: bundleConfig.sourcemap,
49
+ ...bundleConfig.tsdownBuildOptions,
52
50
  });
53
51
  const outDirAbsolute = path.resolve(cwd, outDir);
54
52
  log.debug(`Bundled index.ts to ${chalkHighlightThing(outDirAbsolute)}`);
@@ -59,7 +57,6 @@ export async function bundle({ projectInfo, fullSchema, cliBundleOptions, }) {
59
57
  fixedExtension: true,
60
58
  outDir,
61
59
  clean: false,
62
- sourcemap,
63
60
  });
64
61
  log.debug(`Bundled schema.ts to ${chalkHighlightThing(outDirAbsolute)}`);
65
62
  const requiresGroup = groupBy(Object.entries(bundleConfig.requires), ([, relativePath]) => relativePath);
@@ -64,10 +64,12 @@ function logClientGenerationResults({ results, log, isEnsuringClient = false, fo
64
64
  logOrDebug(`${clientType} client${isEnsuringClient ? ' placeholder' : ''} is not generated because no files were written (${duration}ms)`);
65
65
  }
66
66
  }
67
- const cliOptionsToOpenAPIMixins = ({ openapiGetMethodName, openapiGetModuleName, openapiRootUrl, openapiSpec, openapiMixinName, }) => {
67
+ const cliOptionsToOpenAPIMixins = ({ openapiGetMethodName, openapiGetModuleName, openapiRootUrl, openapiSpec, openapiFallback, openapiMixinName, }) => {
68
68
  return Object.fromEntries((openapiSpec?.map((spec, i) => {
69
69
  return {
70
- source: spec.startsWith('http://') || spec.startsWith('https://') ? { url: spec } : { file: spec },
70
+ source: spec.startsWith('http://') || spec.startsWith('https://')
71
+ ? { url: spec, fallback: openapiFallback?.[i] }
72
+ : { file: spec },
71
73
  apiRoot: openapiRootUrl?.[i] ?? '/',
72
74
  getModuleName: openapiGetModuleName?.[i] ?? undefined,
73
75
  getMethodName: openapiGetMethodName?.[i] ?? 'auto',
@@ -10,7 +10,11 @@ export declare enum BuiltInTemplateName {
10
10
  readme = "readme",
11
11
  packageJson = "packageJson",
12
12
  mixins = "mixins",
13
+ rsSrc = "rsSrc",
14
+ rsPkg = "rsPkg",
13
15
  rs = "rs",
16
+ pySrc = "pySrc",
17
+ pyPkg = "pyPkg",
14
18
  py = "py"
15
19
  }
16
20
  export default function getTemplateDefs(userTemplateDefs?: VovkStrictConfig['clientTemplateDefs']): VovkStrictConfig['clientTemplateDefs'];
@@ -15,7 +15,11 @@ export var BuiltInTemplateName;
15
15
  BuiltInTemplateName["packageJson"] = "packageJson";
16
16
  BuiltInTemplateName["mixins"] = "mixins";
17
17
  // other languages (packages installed separately)
18
+ BuiltInTemplateName["rsSrc"] = "rsSrc";
19
+ BuiltInTemplateName["rsPkg"] = "rsPkg";
18
20
  BuiltInTemplateName["rs"] = "rs";
21
+ BuiltInTemplateName["pySrc"] = "pySrc";
22
+ BuiltInTemplateName["pyPkg"] = "pyPkg";
19
23
  BuiltInTemplateName["py"] = "py";
20
24
  })(BuiltInTemplateName || (BuiltInTemplateName = {}));
21
25
  export default function getTemplateDefs(userTemplateDefs = {}) {
@@ -45,10 +49,6 @@ export default function getTemplateDefs(userTemplateDefs = {}) {
45
49
  [BuiltInTemplateName.schemaJson]: {
46
50
  templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.schemaJson}/`,
47
51
  },
48
- [BuiltInTemplateName.standaloneTypesTs]: {
49
- templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.standaloneTypesTs}/`,
50
- requires: { [BuiltInTemplateName.schemaJson]: '.' },
51
- },
52
52
  [BuiltInTemplateName.readme]: {
53
53
  templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.readme}/`,
54
54
  },
@@ -58,22 +58,40 @@ export default function getTemplateDefs(userTemplateDefs = {}) {
58
58
  [BuiltInTemplateName.mixins]: {
59
59
  templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.mixins}/`,
60
60
  },
61
+ [BuiltInTemplateName.rsSrc]: {
62
+ templatePath: `vovk-rust/client-templates/${BuiltInTemplateName.rsSrc}/`,
63
+ requires: {
64
+ [BuiltInTemplateName.schemaJson]: './',
65
+ },
66
+ },
67
+ [BuiltInTemplateName.rsPkg]: {
68
+ templatePath: `vovk-rust/client-templates/${BuiltInTemplateName.rsPkg}/`,
69
+ },
61
70
  [BuiltInTemplateName.rs]: {
62
- templatePath: 'vovk-rust/template/',
63
71
  composedClient: {
64
72
  outDir: 'dist_rust',
65
73
  },
66
74
  requires: {
67
- [BuiltInTemplateName.schemaJson]: './data/',
75
+ [BuiltInTemplateName.rsSrc]: './src/',
76
+ [BuiltInTemplateName.rsPkg]: './',
68
77
  },
69
78
  },
79
+ [BuiltInTemplateName.pySrc]: {
80
+ templatePath: `vovk-python/client-templates/${BuiltInTemplateName.pySrc}/`,
81
+ requires: {
82
+ [BuiltInTemplateName.schemaJson]: '.',
83
+ },
84
+ },
85
+ [BuiltInTemplateName.pyPkg]: {
86
+ templatePath: `vovk-python/client-templates/${BuiltInTemplateName.pyPkg}/`,
87
+ },
70
88
  [BuiltInTemplateName.py]: {
71
- templatePath: 'vovk-python/template/',
72
89
  composedClient: {
73
90
  outDir: 'dist_python',
74
91
  },
75
92
  requires: {
76
- [BuiltInTemplateName.schemaJson]: './src/[package_name]/',
93
+ [BuiltInTemplateName.pySrc]: './src/[package_name]/',
94
+ [BuiltInTemplateName.pyPkg]: './',
77
95
  },
78
96
  },
79
97
  };
@@ -7,9 +7,19 @@ export default function getConfig({ configPath, cwd }: {
7
7
  srcRoot: string | null;
8
8
  configAbsolutePaths: string[];
9
9
  userConfig: {
10
- $schema?: typeof VovkSchemaIdEnum.CONFIG | string;
11
- emitConfig?: boolean | (keyof VovkStrictConfig | string)[];
10
+ $schema?: typeof VovkSchemaIdEnum.CONFIG | (string & {});
11
+ emitConfig?: boolean | (keyof VovkStrictConfig | (string & {}))[];
12
12
  schemaOutDir?: string;
13
+ modulesDir?: string;
14
+ rootEntry?: string;
15
+ origin?: string;
16
+ logLevel?: "error" | "trace" | "debug" | "info" | "warn";
17
+ prettifyClient?: boolean;
18
+ libs?: {
19
+ ajv: import("vovk").KnownAny;
20
+ [key: string]: import("vovk").KnownAny;
21
+ };
22
+ devHttps?: boolean;
13
23
  composedClient?: ({
14
24
  enabled?: boolean;
15
25
  outDir?: string;
@@ -43,15 +53,14 @@ export default function getConfig({ configPath, cwd }: {
43
53
  }>;
44
54
  };
45
55
  bundle?: {
46
- outDir?: string;
47
56
  requires?: Record<string, string>;
48
57
  tsClientOutDir?: string;
49
58
  dontDeleteTsClientOutDirAfter?: boolean;
50
- sourcemap?: boolean;
51
59
  package?: import("type-fest").PackageJson;
52
60
  readme?: {
53
61
  banner?: string;
54
62
  };
63
+ tsdownBuildOptions?: Parameters<typeof import("tsdown/config-9hj-APNF.mjs").build>[0];
55
64
  } & ({
56
65
  excludeSegments?: never;
57
66
  includeSegments?: string[];
@@ -59,28 +68,18 @@ export default function getConfig({ configPath, cwd }: {
59
68
  excludeSegments?: string[];
60
69
  includeSegments?: never;
61
70
  });
71
+ clientTemplateDefs?: Record<string, import("vovk/mjs/types").ClientTemplateDef>;
62
72
  imports?: {
63
73
  fetcher?: string | [string, string] | [string];
64
74
  validateOnClient?: string | [string, string] | [string];
65
75
  createRPC?: string | [string, string] | [string];
66
76
  };
67
- modulesDir?: string;
68
- rootEntry?: string;
69
- origin?: string;
70
77
  rootSegmentModulesDirName?: string;
71
- logLevel?: "error" | "trace" | "debug" | "info" | "warn";
72
- prettifyClient?: boolean;
73
- devHttps?: boolean;
74
- clientTemplateDefs?: Record<string, import("vovk/mjs/types").ClientTemplateDef>;
75
78
  moduleTemplates?: {
76
79
  service?: string;
77
80
  controller?: string;
78
81
  [key: string]: string | undefined;
79
82
  };
80
- libs?: {
81
- ajv: import("vovk").KnownAny;
82
- [key: string]: import("vovk").KnownAny;
83
- };
84
83
  segmentConfig?: false | {
85
84
  [x: string]: {
86
85
  origin?: string;
@@ -43,10 +43,8 @@ export default async function getConfig({ configPath, cwd }) {
43
43
  outDir: conf.segmentedClient?.outDir ?? path.join(srcRoot ?? '.', 'client'),
44
44
  },
45
45
  bundle: {
46
- outDir: conf.bundle?.outDir ?? 'dist',
47
- tsClientOutDir: conf.bundle?.tsClientOutDir ?? 'tmp_ts_rpc',
46
+ tsClientOutDir: conf.bundle?.tsClientOutDir ?? 'tmp_prebundle',
48
47
  dontDeleteTsClientOutDirAfter: conf.bundle?.dontDeleteTsClientOutDirAfter ?? false,
49
- sourcemap: conf.bundle?.sourcemap ?? false,
50
48
  requires: {
51
49
  [BuiltInTemplateName.readme]: '.',
52
50
  [BuiltInTemplateName.packageJson]: '.',
@@ -54,6 +52,10 @@ export default async function getConfig({ configPath, cwd }) {
54
52
  package: {},
55
53
  readme: {},
56
54
  ...conf.bundle,
55
+ tsdownBuildOptions: {
56
+ outDir: conf.bundle?.tsdownBuildOptions?.outDir ?? 'dist',
57
+ ...conf.bundle?.tsdownBuildOptions,
58
+ },
57
59
  },
58
60
  modulesDir: conf.modulesDir ?? path.join(srcRoot ?? '.', 'modules'),
59
61
  schemaOutDir: env.VOVK_SCHEMA_OUT_DIR ?? conf.schemaOutDir ?? './.vovk-schema',
package/dist/index.mjs CHANGED
@@ -75,11 +75,11 @@ program
75
75
  .command('generate')
76
76
  .alias('g')
77
77
  .description('generate RPC client from schema')
78
+ .option('--composed-only', 'generate only composed client even if segmented client is enabled')
78
79
  .option('--out, --composed-out <path>', 'path to output directory for composed client')
79
80
  .option('--from, --composed-from <templates...>', 'client template names for composed client')
80
81
  .option('--include, --composed-include-segments <segments...>', 'include segments in composed client')
81
82
  .option('--exclude, --composed-exclude-segments <segments...>', 'exclude segments in composed client')
82
- .option('--composed-only', 'generate only composed client even if segmented client is enabled')
83
83
  .option('--segmented-only', 'generate only segmented client even if composed client is enabled')
84
84
  .option('--segmented-out <path>', 'path to output directory for segmented client')
85
85
  .option('--segmented-from <templates...>', 'client template names for segmented client')
@@ -90,10 +90,12 @@ program
90
90
  .option('--config, --config-path <config>', 'path to config file')
91
91
  .option('--force-ts-standalone', 'force TypeScript standalone mode (Next.js environment will be ignored, by default it\'s "true" for non-Next.js directories)')
92
92
  .option('--watch <s>', 'watch for changes in schema or openapi spec and regenerate client; accepts a number in seconds to throttle the watcher or make an HTTP request to the OpenAPI spec URL')
93
- .option('--openapi, --openapi-spec <openapi_path_or_urls...>', 'use OpenAPI schema instead of Vovk schema')
93
+ .option('--openapi, --openapi-spec <openapi_path_or_urls...>', 'use OpenAPI schema for client generation')
94
94
  .option('--openapi-get-module-name <names...>', 'module names corresponding to the index of --openapi option')
95
95
  .option('--openapi-get-method-name <names...>', 'method names corresponding to the index of --openapi option')
96
96
  .option('--openapi-root-url <urls...>', 'root URLs corresponding to the index of --openapi option')
97
+ .option('--openapi-mixin-name <names...>', 'mixin names corresponding to the index of --openapi option')
98
+ .option('--openapi-fallback <paths...>', 'save OpenAPI spec and use it as a fallback if URL is not available')
97
99
  .action(async (cliGenerateOptions) => {
98
100
  const projectInfo = await getProjectInfo({ configPath: cliGenerateOptions.configPath, srcRootRequired: false });
99
101
  await new VovkGenerate({
@@ -113,8 +115,6 @@ program
113
115
  .option('--dont-delete-ts-client-out-dir-after', 'do not delete TypeScript client output directory after bundling')
114
116
  .option('--config <config>', 'path to config file')
115
117
  .option('--schema <path>', 'path to schema folder (default: .vovk-schema)')
116
- .option('--sourcemap', 'generate sourcemaps')
117
- .option('--force-ts-standalone', 'force TypeScript standalone mode (Next.js environment will be ignored, by default it\'s "true" for non-Next.js directories)')
118
118
  .option('--openapi, --openapi-spec <openapi_path_or_urls...>', 'use OpenAPI schema instead of Vovk schema')
119
119
  .option('--openapi-get-module-name <names...>', 'module names corresponding to the index of --openapi option')
120
120
  .option('--openapi-get-method-name <names...>', 'method names corresponding to the index of --openapi option')
package/dist/types.d.mts CHANGED
@@ -21,8 +21,8 @@ export interface GenerateOptions {
21
21
  openapiGetMethodName?: string[];
22
22
  openapiRootUrl?: string[];
23
23
  openapiMixinName?: string[];
24
+ openapiFallback?: string[];
24
25
  watch?: boolean | string;
25
- forceTsStandalone?: boolean;
26
26
  composedFrom?: string[];
27
27
  composedOut?: string;
28
28
  composedOnly?: boolean;
@@ -34,15 +34,15 @@ export interface GenerateOptions {
34
34
  segmentedIncludeSegments?: string[];
35
35
  segmentedExcludeSegments?: string[];
36
36
  }
37
- export interface BundleOptions extends Partial<Omit<VovkStrictConfig['bundle'], 'requires'>> {
37
+ export interface BundleOptions extends Partial<Pick<VovkStrictConfig['bundle'], 'tsClientOutDir' | 'dontDeleteTsClientOutDirAfter' | 'includeSegments' | 'excludeSegments'>> {
38
38
  config?: string;
39
39
  schema?: string;
40
+ outDir?: string;
40
41
  openapiSpec?: string[];
41
42
  openapiGetModuleName?: string[];
42
43
  openapiGetMethodName?: string[];
43
44
  openapiRootUrl?: string[];
44
45
  openapiMixinName?: string[];
45
- forceTsStandalone?: boolean;
46
46
  }
47
47
  export interface InitOptions {
48
48
  yes?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.300",
3
+ "version": "0.0.1-draft.302",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },
@@ -35,26 +35,22 @@
35
35
  },
36
36
  "homepage": "https://vovk.dev",
37
37
  "peerDependencies": {
38
- "vovk": "^3.0.0-draft.339"
38
+ "vovk": "^3.0.0-draft.348"
39
39
  },
40
40
  "optionalDependencies": {
41
- "vovk-python": "^0.0.1-draft.54"
41
+ "vovk-python": "^0.0.1-draft.55"
42
42
  },
43
43
  "dependencies": {
44
44
  "@iarna/toml": "^2.2.5",
45
- "@inquirer/prompts": "^7.6.0",
45
+ "@inquirer/prompts": "^7.7.1",
46
46
  "@npmcli/package-json": "^6.2.0",
47
- "@rollup/plugin-commonjs": "^28.0.6",
48
- "@rollup/plugin-json": "^6.1.0",
49
- "@rollup/plugin-node-resolve": "^16.0.1",
50
- "@rollup/plugin-typescript": "^12.1.4",
51
47
  "@types/json-schema": "^7.0.15",
52
48
  "chalk": "^5.4.1",
53
49
  "chokidar": "^4.0.3",
54
50
  "clone-deep": "^4.0.1",
55
51
  "commander": "^13.1.0",
56
52
  "concurrently": "^9.2.0",
57
- "dotenv": "^17.2.0",
53
+ "dotenv": "^17.2.1",
58
54
  "ejs": "^3.1.10",
59
55
  "get-tsconfig": "^4.10.1",
60
56
  "glob": "^11.0.3",
@@ -66,12 +62,11 @@
66
62
  "openapi3-ts": "^4.5.0",
67
63
  "pluralize": "^8.0.0",
68
64
  "prettier": "^3.6.2",
69
- "rollup": "^4.44.2",
70
65
  "tar-stream": "^3.1.7",
71
66
  "ts-morph": "^26.0.0",
72
- "tsdown": "^0.12.9",
67
+ "tsdown": "^0.13.0",
73
68
  "type-fest": "^4.41.0",
74
- "undici": "^7.11.0",
69
+ "undici": "^7.12.0",
75
70
  "vovk-openapi": "^0.0.1-draft.112",
76
71
  "yaml": "^2.8.0"
77
72
  },
@@ -83,8 +78,8 @@
83
78
  "@types/pluralize": "^0.0.33",
84
79
  "@types/tar-stream": "^3.1.4",
85
80
  "concat-stream": "^2.0.0",
86
- "create-next-app": "^15.3.5",
81
+ "create-next-app": "^15.4.4",
87
82
  "node-pty": "^1.0.0",
88
- "zod": "^4.0.5"
83
+ "zod": "^4.0.10"
89
84
  }
90
85
  }