vovk-cli 0.0.1-draft.301 → 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.
@@ -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 = {}) {
@@ -54,22 +58,40 @@ export default function getTemplateDefs(userTemplateDefs = {}) {
54
58
  [BuiltInTemplateName.mixins]: {
55
59
  templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.mixins}/`,
56
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
+ },
57
70
  [BuiltInTemplateName.rs]: {
58
- templatePath: 'vovk-rust/template/',
59
71
  composedClient: {
60
72
  outDir: 'dist_rust',
61
73
  },
62
74
  requires: {
63
- [BuiltInTemplateName.schemaJson]: './data/',
75
+ [BuiltInTemplateName.rsSrc]: './src/',
76
+ [BuiltInTemplateName.rsPkg]: './',
64
77
  },
65
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
+ },
66
88
  [BuiltInTemplateName.py]: {
67
- templatePath: 'vovk-python/template/',
68
89
  composedClient: {
69
90
  outDir: 'dist_python',
70
91
  },
71
92
  requires: {
72
- [BuiltInTemplateName.schemaJson]: './src/[package_name]/',
93
+ [BuiltInTemplateName.pySrc]: './src/[package_name]/',
94
+ [BuiltInTemplateName.pyPkg]: './',
73
95
  },
74
96
  },
75
97
  };
@@ -43,7 +43,7 @@ export default async function getConfig({ configPath, cwd }) {
43
43
  outDir: conf.segmentedClient?.outDir ?? path.join(srcRoot ?? '.', 'client'),
44
44
  },
45
45
  bundle: {
46
- tsClientOutDir: conf.bundle?.tsClientOutDir ?? 'tmp_ts_rpc',
46
+ tsClientOutDir: conf.bundle?.tsClientOutDir ?? 'tmp_prebundle',
47
47
  dontDeleteTsClientOutDirAfter: conf.bundle?.dontDeleteTsClientOutDirAfter ?? false,
48
48
  requires: {
49
49
  [BuiltInTemplateName.readme]: '.',
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({
package/dist/types.d.mts CHANGED
@@ -21,6 +21,7 @@ export interface GenerateOptions {
21
21
  openapiGetMethodName?: string[];
22
22
  openapiRootUrl?: string[];
23
23
  openapiMixinName?: string[];
24
+ openapiFallback?: string[];
24
25
  watch?: boolean | string;
25
26
  composedFrom?: string[];
26
27
  composedOut?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.301",
3
+ "version": "0.0.1-draft.302",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },
@@ -35,10 +35,10 @@
35
35
  },
36
36
  "homepage": "https://vovk.dev",
37
37
  "peerDependencies": {
38
- "vovk": "^3.0.0-draft.340"
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",