vovk-cli 0.0.1-draft.396 → 0.0.1-draft.398

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.
@@ -1,7 +1,6 @@
1
1
  <%- t.getFirstLineBanner() %>
2
2
  const { createRPC } = require('<%= t.commonImports.createRPC %>');
3
3
  const { schema } = require('./schema.cjs');
4
- const { openapi } = require('./openapi.cjs');
5
4
  <% Object.entries(t.reExports).forEach(([reExportWhatCommaDivisible, reExportFrom]) => {
6
5
  reExportWhatCommaDivisible.split(/\s*,\s*/).forEach((reExportWhat) => { %>
7
6
  exports['<%= reExportWhat.split(/\s+as\s+/)[1] ?? reExportWhat %>'] = require('<%= reExportFrom %>')['<%= reExportWhat.split(/\s+as\s+/)[0] %>'];
@@ -17,4 +16,3 @@ exports.<%= rpcModuleName %> = createRPC(
17
16
  <% })
18
17
  }) %>
19
18
  exports.schema = schema;
20
- exports.openapi = openapi;
@@ -16,7 +16,6 @@ export const <%= rpcModuleName %>: ReturnType<typeof createRPC<<%= segment.segme
16
16
  <% })
17
17
  }) %>
18
18
  export { schema } from './schema.cjs';
19
- export { openapi } from './openapi.cjs';
20
19
  <% if (t.hasMixins) { %>
21
20
  export { Mixins };
22
21
  <% } %>
@@ -16,7 +16,6 @@ export const <%= rpcModuleName %>: ReturnType<typeof createRPC<<%= segment.segme
16
16
  <% })
17
17
  }) %>
18
18
  export { schema } from './schema.cjs';
19
- export { openapi } from './openapi.cjs';
20
19
  <% if (t.hasMixins) { %>
21
20
  export { Mixins };
22
21
  <% } %>
@@ -1,7 +1,6 @@
1
1
  <%- t.getFirstLineBanner() %>
2
2
  import { createRPC } from '<%= t.commonImports.module.createRPC %>';
3
3
  import { schema } from './schema.cjs';
4
- import { openapi } from './openapi.cjs';
5
4
  <% Object.entries(t.reExports).forEach(([reExportWhat, reExportFrom]) => { %>
6
5
  export { <%= reExportWhat %> } from '<%= reExportFrom %>';
7
6
  <% }) %>
@@ -16,4 +15,4 @@ export const <%= rpcModuleName %> = createRPC(
16
15
  });
17
16
  });
18
17
  %>
19
- export { schema, openapi };
18
+ export { schema };
@@ -2,7 +2,7 @@
2
2
  <% if(t.isVovkProject) { %>
3
3
  const meta = require('./<%= t.schemaOutDir %>/_meta.json');
4
4
  <% } else { %>
5
- const meta = <%- JSON.stringify(t.publicMeta, null, 2) %>;
5
+ const meta = <%- JSON.stringify(t.schema.meta, null, 2) %>;
6
6
  <% } %>
7
7
 
8
8
  <% if(t.hasMixins) { %>
@@ -2,13 +2,6 @@
2
2
  import type { VovkFetcher } from 'vovk';
3
3
  import { createRPC } from '<%= t.commonImports.module.createRPC %>';
4
4
  import { schema } from './schema<%= t.nodeNextResolutionExt.ts %>';
5
- <% if(t.isBundle) { %>
6
- import { openapi } from './openapi<%= t.nodeNextResolutionExt.ts %>';
7
- <% } else { %>
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
10
- import openapi from './openapi.json' with { type: "json" };
11
- <% } %>
12
5
  <% Object.values(t.schema.segments).filter((segment) => segment.emitSchema).forEach((segment, i) => { if(segment.segmentType !== 'mixin') { %>
13
6
  import type { Controllers as Controllers<%= i %> } from "<%= t.segmentMeta[segment.segmentName].segmentImportPath %>";
14
7
  <% }
@@ -28,7 +21,7 @@ export const <%= rpcModuleName %> = createRPC<<%= segment.segmentType === 'mixin
28
21
  );
29
22
  <% })
30
23
  }) %>
31
- export { schema, openapi };
24
+ export { schema };
32
25
  <% if (t.hasMixins) { %>
33
26
  export { Mixins };
34
27
  <% } %>
@@ -33,7 +33,7 @@ export async function bundle({ projectInfo, fullSchema, cliBundleOptions, }) {
33
33
  openapiRootUrl: cliBundleOptions?.openapiRootUrl,
34
34
  openapiMixinName: cliBundleOptions?.openapiMixinName,
35
35
  openapiFallback: cliBundleOptions?.openapiFallback,
36
- composedFrom: [BuiltInTemplateName.ts],
36
+ composedFrom: [BuiltInTemplateName.tsBase],
37
37
  composedOut: prebundleOutDirAbsolute,
38
38
  composedOnly: true,
39
39
  composedIncludeSegments: cliBundleOptions.includeSegments ?? bundleConfig.includeSegments,
@@ -146,7 +146,11 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
146
146
  config: projectInfo.config,
147
147
  rootEntry: config.rootEntry,
148
148
  schema: fullSchema,
149
- outputConfigs: [templateDef.outputConfig ?? {}, { origin: cliGenerateOptions?.origin }],
149
+ outputConfigs: [
150
+ config.composedClient.outputConfig ?? {},
151
+ templateDef.outputConfig ?? {},
152
+ { origin: cliGenerateOptions?.origin },
153
+ ],
150
154
  projectPackageJson,
151
155
  isBundle,
152
156
  segmentName: null,
@@ -234,7 +238,11 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
234
238
  schema: fullSchema,
235
239
  rootEntry: config.rootEntry,
236
240
  segmentName,
237
- outputConfigs: [templateDef.outputConfig ?? {}, { origin: cliGenerateOptions?.origin }],
241
+ outputConfigs: [
242
+ config.segmentedClient.outputConfig ?? {},
243
+ templateDef.outputConfig ?? {},
244
+ { origin: cliGenerateOptions?.origin },
245
+ ],
238
246
  isBundle,
239
247
  projectPackageJson,
240
248
  });
@@ -84,7 +84,7 @@ templateContent, matterResult: { data, content }, openAPIObject, package: packag
84
84
  segmentName: sName,
85
85
  isBundle,
86
86
  outCwdRelativeDir,
87
- outputConfigs: [templateDef.outputConfig ?? {}],
87
+ outputConfigs: [projectConfig[configKey].outputConfig ?? {}, templateDef.outputConfig ?? {}],
88
88
  });
89
89
  const imports = configKey === 'composedClient' ? clientImports['composedClient'] : clientImports['segmentedClient'][sName];
90
90
  return [sName, imports];
@@ -1,5 +1,8 @@
1
1
  import type { VovkStrictConfig } from 'vovk';
2
2
  export declare enum BuiltInTemplateName {
3
+ tsBase = "tsBase",
4
+ cjsBase = "cjsBase",
5
+ mjsBase = "mjsBase",
3
6
  ts = "ts",
4
7
  cjs = "cjs",
5
8
  mjs = "mjs",
@@ -1,6 +1,9 @@
1
1
  export var BuiltInTemplateName;
2
2
  (function (BuiltInTemplateName) {
3
3
  // ts/js
4
+ BuiltInTemplateName["tsBase"] = "tsBase";
5
+ BuiltInTemplateName["cjsBase"] = "cjsBase";
6
+ BuiltInTemplateName["mjsBase"] = "mjsBase";
4
7
  BuiltInTemplateName["ts"] = "ts";
5
8
  BuiltInTemplateName["cjs"] = "cjs";
6
9
  BuiltInTemplateName["mjs"] = "mjs";
@@ -44,30 +47,45 @@ export default function getTemplateDefs(userTemplateDefs = {}) {
44
47
  [BuiltInTemplateName.openapiJson]: {
45
48
  templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.openapiJson}/`,
46
49
  },
47
- [BuiltInTemplateName.ts]: {
48
- templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.ts}/`,
50
+ [BuiltInTemplateName.tsBase]: {
51
+ templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.tsBase}/`,
49
52
  requires: {
50
53
  [BuiltInTemplateName.schemaTs]: './',
51
- [BuiltInTemplateName.openapiTs]: './',
52
54
  [BuiltInTemplateName.mixins]: './', // used conditionally if OpenAPI mixins are used
53
55
  },
54
56
  },
55
- [BuiltInTemplateName.cjs]: {
56
- templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.cjs}/`,
57
+ [BuiltInTemplateName.cjsBase]: {
58
+ templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.cjsBase}/`,
57
59
  requires: {
58
60
  [BuiltInTemplateName.schemaCjs]: './',
59
- [BuiltInTemplateName.openapiCjs]: './',
60
61
  [BuiltInTemplateName.mixins]: './', // used conditionally if OpenAPI mixins are used
61
62
  },
62
63
  },
63
- [BuiltInTemplateName.mjs]: {
64
- templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.mjs}/`,
64
+ [BuiltInTemplateName.mjsBase]: {
65
+ templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.mjsBase}/`,
65
66
  requires: {
66
67
  [BuiltInTemplateName.schemaCjs]: './',
67
- [BuiltInTemplateName.openapiCjs]: './',
68
68
  [BuiltInTemplateName.mixins]: './', // used conditionally if OpenAPI mixins are used
69
69
  },
70
70
  },
71
+ [BuiltInTemplateName.ts]: {
72
+ requires: {
73
+ [BuiltInTemplateName.tsBase]: './',
74
+ [BuiltInTemplateName.openapiTs]: './',
75
+ },
76
+ },
77
+ [BuiltInTemplateName.cjs]: {
78
+ requires: {
79
+ [BuiltInTemplateName.cjsBase]: './',
80
+ [BuiltInTemplateName.openapiCjs]: './',
81
+ },
82
+ },
83
+ [BuiltInTemplateName.mjs]: {
84
+ requires: {
85
+ [BuiltInTemplateName.mjsBase]: './',
86
+ [BuiltInTemplateName.openapiCjs]: './',
87
+ },
88
+ },
71
89
  [BuiltInTemplateName.schemaTs]: {
72
90
  templatePath: `vovk-cli/client-templates/${BuiltInTemplateName.schemaTs}/`,
73
91
  },
@@ -25,6 +25,11 @@ export default function getConfig({ configPath, cwd, logLevel, }: {
25
25
  outDir?: string;
26
26
  fromTemplates?: string[];
27
27
  prettifyClient?: boolean;
28
+ outputConfig?: import("vovk").VovkOutputConfig<{
29
+ fetcher?: string | [string, string] | [string];
30
+ validateOnClient?: string | [string, string] | [string] | null;
31
+ createRPC?: string | [string, string] | [string];
32
+ }>;
28
33
  } & ({
29
34
  excludeSegments?: never;
30
35
  includeSegments?: string[];
@@ -37,6 +42,11 @@ export default function getConfig({ configPath, cwd, logLevel, }: {
37
42
  outDir?: string;
38
43
  fromTemplates?: string[];
39
44
  prettifyClient?: boolean;
45
+ outputConfig?: import("vovk").VovkOutputConfig<{
46
+ fetcher?: string | [string, string] | [string];
47
+ validateOnClient?: string | [string, string] | [string] | null;
48
+ createRPC?: string | [string, string] | [string];
49
+ }>;
40
50
  } & ({
41
51
  excludeSegments?: never;
42
52
  includeSegments?: string[];
@@ -2,6 +2,90 @@ import { VovkSchemaIdEnum, type VovkStrictConfig } from 'vovk';
2
2
  export default function getMetaSchema({ config }: {
3
3
  config: VovkStrictConfig;
4
4
  }): {
5
- config: VovkStrictConfig;
6
5
  $schema: VovkSchemaIdEnum;
6
+ config: Pick<VovkStrictConfig, keyof {
7
+ $schema?: typeof VovkSchemaIdEnum.CONFIG | (string & {});
8
+ exposeConfigKeys?: boolean | (keyof VovkStrictConfig | (string & {}))[];
9
+ schemaOutDir?: string;
10
+ modulesDir?: string;
11
+ rootEntry?: string;
12
+ logLevel?: "error" | "trace" | "debug" | "info" | "warn" | (string & {});
13
+ libs?: {
14
+ ajv?: import("vovk").KnownAny;
15
+ [key: string]: import("vovk").KnownAny;
16
+ };
17
+ devHttps?: boolean;
18
+ composedClient?: {
19
+ enabled?: boolean;
20
+ outDir?: string;
21
+ fromTemplates?: string[];
22
+ prettifyClient?: boolean;
23
+ outputConfig?: import("vovk").VovkOutputConfig<{
24
+ fetcher?: string | [string, string] | [string];
25
+ validateOnClient?: string | [string, string] | [string] | null;
26
+ createRPC?: string | [string, string] | [string];
27
+ }>;
28
+ } & ({
29
+ excludeSegments?: never;
30
+ includeSegments?: string[];
31
+ } | {
32
+ excludeSegments?: string[];
33
+ includeSegments?: never;
34
+ });
35
+ segmentedClient?: {
36
+ enabled?: boolean;
37
+ outDir?: string;
38
+ fromTemplates?: string[];
39
+ prettifyClient?: boolean;
40
+ outputConfig?: import("vovk").VovkOutputConfig<{
41
+ fetcher?: string | [string, string] | [string];
42
+ validateOnClient?: string | [string, string] | [string] | null;
43
+ createRPC?: string | [string, string] | [string];
44
+ }>;
45
+ } & ({
46
+ excludeSegments?: never;
47
+ includeSegments?: string[];
48
+ } | {
49
+ excludeSegments?: string[];
50
+ includeSegments?: never;
51
+ });
52
+ bundle?: {
53
+ requires?: Record<string, string>;
54
+ prebundleOutDir?: string;
55
+ keepPrebundleDir?: boolean;
56
+ outDir?: string;
57
+ build: (options: {
58
+ outDir: string;
59
+ prebundleDir: string;
60
+ entry: string;
61
+ }) => Promise<void>;
62
+ outputConfig?: import("vovk").VovkOutputConfig<{
63
+ fetcher?: string | [string, string] | [string];
64
+ validateOnClient?: string | [string, string] | [string] | null;
65
+ createRPC?: string | [string, string] | [string];
66
+ }>;
67
+ } & ({
68
+ excludeSegments?: never;
69
+ includeSegments?: string[];
70
+ } | {
71
+ excludeSegments?: string[];
72
+ includeSegments?: never;
73
+ });
74
+ clientTemplateDefs?: Record<string, import("vovk/types").ClientTemplateDef>;
75
+ rootSegmentModulesDirName?: string;
76
+ moduleTemplates?: {
77
+ service?: string;
78
+ controller?: string;
79
+ [key: string]: string | undefined;
80
+ };
81
+ outputConfig?: import("vovk").VovkOutputConfig<{
82
+ fetcher?: string | [string, string] | [string];
83
+ validateOnClient?: string | [string, string] | [string] | null;
84
+ createRPC?: string | [string, string] | [string];
85
+ }> & {
86
+ segments?: Record<string, import("vovk/types").VovkSegmentConfig>;
87
+ };
88
+ }> | {
89
+ $schema: VovkSchemaIdEnum;
90
+ };
7
91
  };
@@ -1,25 +1,12 @@
1
1
  import { VovkSchemaIdEnum } from 'vovk';
2
2
  import pick from 'lodash/pick.js';
3
- import mapValues from 'lodash/mapValues.js';
4
- import omit from 'lodash/omit.js';
5
3
  export default function getMetaSchema({ config }) {
6
4
  return {
7
5
  $schema: VovkSchemaIdEnum.META,
8
- ...{
9
- config: (config
10
- ? pick({
11
- ...config,
12
- outputConfig: config.outputConfig
13
- ? {
14
- ...config.outputConfig,
15
- // TODO: Dirty fix! Need to think of a better way to avoid emission of mixins.
16
- segments: config.outputConfig.segments
17
- ? mapValues(config.outputConfig.segments, (segment) => omit(segment, ['openAPIMixin']))
18
- : undefined,
19
- }
20
- : undefined,
21
- }, [...config.exposeConfigKeys, '$schema'])
22
- : {}),
23
- },
6
+ config: config
7
+ ? pick(config, [...config.exposeConfigKeys, '$schema'])
8
+ : {
9
+ $schema: VovkSchemaIdEnum.CONFIG,
10
+ },
24
11
  };
25
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.396",
3
+ "version": "0.0.1-draft.398",
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.472",
38
+ "vovk": "^3.0.0-draft.474",
39
39
  "vovk-ajv": "^0.0.0-draft.113",
40
40
  "vovk-client": "^0.0.4-draft.140",
41
41
  "vovk-python": "^0.0.1-draft.82",