vovk 3.0.0-draft.465 → 3.0.0-draft.467

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.
@@ -49,7 +49,7 @@ function vovkSchemaToOpenAPI({ rootEntry = 'api', schema: fullSchema, configs, s
49
49
  const components = {};
50
50
  const { openAPIObject, samples: samplesConfig, package: packageJson, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
51
51
  schema: fullSchema,
52
- configs,
52
+ outputConfigs: configs,
53
53
  segmentName: givenSegmentName ?? null,
54
54
  });
55
55
  for (const [segmentName, segmentSchema] of givenSegmentName
@@ -1,9 +1,10 @@
1
1
  import type { PackageJson } from 'type-fest';
2
- import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema } from '../types';
2
+ import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema, VovkStrictConfig } from '../types';
3
3
  import type { OpenAPIObject } from 'openapi3-ts/oas31';
4
- export declare function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle, projectPackageJson, }: {
4
+ export declare function resolveGeneratorConfigValues({ config, schema, outputConfigs, segmentName, isBundle, projectPackageJson, }: {
5
+ config?: VovkStrictConfig;
5
6
  schema: VovkSchema;
6
- configs?: VovkOutputConfig[];
7
+ outputConfigs?: VovkOutputConfig[];
7
8
  segmentName: string | null;
8
9
  isBundle?: boolean;
9
10
  projectPackageJson?: PackageJson;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolveGeneratorConfigValues = resolveGeneratorConfigValues;
7
7
  const deepExtend_1 = __importDefault(require("./deepExtend"));
8
- function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle, projectPackageJson, }) {
8
+ function resolveGeneratorConfigValues({ config, schema, outputConfigs, segmentName, isBundle, projectPackageJson, }) {
9
9
  const packageJson = (0, deepExtend_1.default)({}, {
10
10
  main: './index.cjs',
11
11
  module: './index.mjs',
@@ -16,22 +16,10 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
16
16
  require: './index.cjs',
17
17
  types: './index.d.mts',
18
18
  },
19
- './schema': {
20
- import: './schema.cjs',
21
- require: './schema.cjs',
22
- types: './schema.d.cts',
23
- },
24
- './openapi': {
25
- import: './openapi.cjs',
26
- require: './openapi.cjs',
27
- types: './openapi.d.cts',
28
- },
29
19
  },
30
- }, projectPackageJson, schema.meta?.config?.outputConfig?.package, isBundle ? schema.meta?.config?.bundle?.outputConfig?.package : undefined, typeof segmentName === 'string' ? schema.segments?.[segmentName]?.meta?.package : undefined, typeof segmentName === 'string'
31
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.package
32
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.package), {}));
20
+ }, Object.fromEntries(Object.entries(projectPackageJson ?? {}).filter(([key]) => ['name', 'version', 'description', 'license', 'authors', 'repository', 'homepage', 'bugs', 'keywords'].includes(key))), config?.outputConfig?.package, isBundle ? config?.bundle?.outputConfig?.package : undefined, typeof segmentName === 'string' ? schema.segments?.[segmentName]?.meta?.package : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.package : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.package), {}));
33
21
  return {
34
- package: Object.fromEntries(Object.entries(packageJson).filter(([key]) => ['name', 'version', 'description', 'license', 'authors', 'repository', 'homepage', 'bugs', 'keywords'].includes(key))),
22
+ package: packageJson,
35
23
  openAPIObject: (0, deepExtend_1.default)({}, {
36
24
  openapi: '3.1.0',
37
25
  info: {
@@ -39,22 +27,14 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
39
27
  version: packageJson.version,
40
28
  description: packageJson.description,
41
29
  },
42
- }, schema.meta?.config?.outputConfig?.openAPIObject, isBundle ? schema.meta?.config?.bundle?.outputConfig?.openAPIObject : undefined, typeof segmentName === 'string' ? schema?.segments?.[segmentName]?.meta?.openAPIObject : undefined, typeof segmentName === 'string'
43
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.openAPIObject
44
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.openAPIObject), {})),
45
- samples: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.samples, isBundle ? schema.meta?.config?.bundle?.outputConfig?.samples : undefined, typeof segmentName === 'string'
46
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.samples
47
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.samples), {})),
48
- readme: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.readme, isBundle ? schema.meta?.config?.bundle?.outputConfig?.readme : undefined, typeof segmentName === 'string'
49
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.readme
50
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.readme), {})),
30
+ }, config?.outputConfig?.openAPIObject, isBundle ? config?.bundle?.outputConfig?.openAPIObject : undefined, typeof segmentName === 'string' ? schema?.segments?.[segmentName]?.meta?.openAPIObject : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.openAPIObject : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.openAPIObject), {})),
31
+ samples: (0, deepExtend_1.default)({}, config?.outputConfig?.samples, isBundle ? config?.bundle?.outputConfig?.samples : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.samples : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.samples), {})),
32
+ readme: (0, deepExtend_1.default)({}, config?.outputConfig?.readme, isBundle ? config?.bundle?.outputConfig?.readme : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.readme : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.readme), {})),
51
33
  origin: [
52
- isBundle ? schema.meta?.config?.bundle?.outputConfig?.origin : undefined,
53
- typeof segmentName === 'string'
54
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.origin
55
- : undefined,
56
- schema.meta?.config?.outputConfig?.origin,
57
- ...(configs?.map((config) => config.origin) ?? []),
34
+ isBundle ? config?.bundle?.outputConfig?.origin : undefined,
35
+ typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.origin : undefined,
36
+ config?.outputConfig?.origin,
37
+ ...(outputConfigs?.map((config) => config.origin) ?? []),
58
38
  ]
59
39
  .filter(Boolean)
60
40
  .at(-1)
@@ -64,19 +44,15 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
64
44
  fetcher: ['vovk'],
65
45
  validateOnClient: null,
66
46
  createRPC: ['vovk'],
67
- }, schema.meta?.config?.outputConfig?.imports, isBundle ? schema.meta?.config?.bundle?.outputConfig?.imports : undefined, typeof segmentName === 'string'
68
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.imports
69
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.imports), {})),
47
+ }, config?.outputConfig?.imports, isBundle ? config?.bundle?.outputConfig?.imports : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.imports : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.imports), {})),
70
48
  reExports: (0, deepExtend_1.default)(
71
49
  // segmentName can be an empty string (for the root segment) and null (for composed clients)
72
50
  // therefore, !segmentName indicates that this either a composed client or a root segment of a segmented client
73
- {}, !segmentName && schema.meta?.config?.outputConfig?.reExports, !segmentName && isBundle ? schema.meta?.config?.bundle?.outputConfig?.reExports : undefined,
51
+ {}, !segmentName && config?.outputConfig?.reExports, !segmentName && isBundle ? config?.bundle?.outputConfig?.reExports : undefined,
74
52
  // for segmented client, apply all reExports from all segments
75
53
  typeof segmentName !== 'string' &&
76
- Object.values(schema.meta?.config?.outputConfig?.segments ?? {}).reduce((acc, segmentConfig) => (0, deepExtend_1.default)(acc, segmentConfig.reExports ?? {}), {}),
54
+ Object.values(config?.outputConfig?.segments ?? {}).reduce((acc, segmentConfig) => (0, deepExtend_1.default)(acc, segmentConfig.reExports ?? {}), {}),
77
55
  // for a specific segment, apply reExports from that segment
78
- typeof segmentName === 'string'
79
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.reExports
80
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.reExports), {})),
56
+ typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.reExports : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.reExports), {})),
81
57
  };
82
58
  }
@@ -49,7 +49,7 @@ function vovkSchemaToOpenAPI({ rootEntry = 'api', schema: fullSchema, configs, s
49
49
  const components = {};
50
50
  const { openAPIObject, samples: samplesConfig, package: packageJson, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
51
51
  schema: fullSchema,
52
- configs,
52
+ outputConfigs: configs,
53
53
  segmentName: givenSegmentName ?? null,
54
54
  });
55
55
  for (const [segmentName, segmentSchema] of givenSegmentName
@@ -1,9 +1,10 @@
1
1
  import type { PackageJson } from 'type-fest';
2
- import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema } from '../types';
2
+ import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema, VovkStrictConfig } from '../types';
3
3
  import type { OpenAPIObject } from 'openapi3-ts/oas31';
4
- export declare function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle, projectPackageJson, }: {
4
+ export declare function resolveGeneratorConfigValues({ config, schema, outputConfigs, segmentName, isBundle, projectPackageJson, }: {
5
+ config?: VovkStrictConfig;
5
6
  schema: VovkSchema;
6
- configs?: VovkOutputConfig[];
7
+ outputConfigs?: VovkOutputConfig[];
7
8
  segmentName: string | null;
8
9
  isBundle?: boolean;
9
10
  projectPackageJson?: PackageJson;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolveGeneratorConfigValues = resolveGeneratorConfigValues;
7
7
  const deepExtend_1 = __importDefault(require("./deepExtend"));
8
- function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle, projectPackageJson, }) {
8
+ function resolveGeneratorConfigValues({ config, schema, outputConfigs, segmentName, isBundle, projectPackageJson, }) {
9
9
  const packageJson = (0, deepExtend_1.default)({}, {
10
10
  main: './index.cjs',
11
11
  module: './index.mjs',
@@ -16,22 +16,10 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
16
16
  require: './index.cjs',
17
17
  types: './index.d.mts',
18
18
  },
19
- './schema': {
20
- import: './schema.cjs',
21
- require: './schema.cjs',
22
- types: './schema.d.cts',
23
- },
24
- './openapi': {
25
- import: './openapi.cjs',
26
- require: './openapi.cjs',
27
- types: './openapi.d.cts',
28
- },
29
19
  },
30
- }, projectPackageJson, schema.meta?.config?.outputConfig?.package, isBundle ? schema.meta?.config?.bundle?.outputConfig?.package : undefined, typeof segmentName === 'string' ? schema.segments?.[segmentName]?.meta?.package : undefined, typeof segmentName === 'string'
31
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.package
32
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.package), {}));
20
+ }, Object.fromEntries(Object.entries(projectPackageJson ?? {}).filter(([key]) => ['name', 'version', 'description', 'license', 'authors', 'repository', 'homepage', 'bugs', 'keywords'].includes(key))), config?.outputConfig?.package, isBundle ? config?.bundle?.outputConfig?.package : undefined, typeof segmentName === 'string' ? schema.segments?.[segmentName]?.meta?.package : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.package : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.package), {}));
33
21
  return {
34
- package: Object.fromEntries(Object.entries(packageJson).filter(([key]) => ['name', 'version', 'description', 'license', 'authors', 'repository', 'homepage', 'bugs', 'keywords'].includes(key))),
22
+ package: packageJson,
35
23
  openAPIObject: (0, deepExtend_1.default)({}, {
36
24
  openapi: '3.1.0',
37
25
  info: {
@@ -39,22 +27,14 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
39
27
  version: packageJson.version,
40
28
  description: packageJson.description,
41
29
  },
42
- }, schema.meta?.config?.outputConfig?.openAPIObject, isBundle ? schema.meta?.config?.bundle?.outputConfig?.openAPIObject : undefined, typeof segmentName === 'string' ? schema?.segments?.[segmentName]?.meta?.openAPIObject : undefined, typeof segmentName === 'string'
43
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.openAPIObject
44
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.openAPIObject), {})),
45
- samples: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.samples, isBundle ? schema.meta?.config?.bundle?.outputConfig?.samples : undefined, typeof segmentName === 'string'
46
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.samples
47
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.samples), {})),
48
- readme: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.readme, isBundle ? schema.meta?.config?.bundle?.outputConfig?.readme : undefined, typeof segmentName === 'string'
49
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.readme
50
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.readme), {})),
30
+ }, config?.outputConfig?.openAPIObject, isBundle ? config?.bundle?.outputConfig?.openAPIObject : undefined, typeof segmentName === 'string' ? schema?.segments?.[segmentName]?.meta?.openAPIObject : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.openAPIObject : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.openAPIObject), {})),
31
+ samples: (0, deepExtend_1.default)({}, config?.outputConfig?.samples, isBundle ? config?.bundle?.outputConfig?.samples : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.samples : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.samples), {})),
32
+ readme: (0, deepExtend_1.default)({}, config?.outputConfig?.readme, isBundle ? config?.bundle?.outputConfig?.readme : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.readme : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.readme), {})),
51
33
  origin: [
52
- isBundle ? schema.meta?.config?.bundle?.outputConfig?.origin : undefined,
53
- typeof segmentName === 'string'
54
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.origin
55
- : undefined,
56
- schema.meta?.config?.outputConfig?.origin,
57
- ...(configs?.map((config) => config.origin) ?? []),
34
+ isBundle ? config?.bundle?.outputConfig?.origin : undefined,
35
+ typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.origin : undefined,
36
+ config?.outputConfig?.origin,
37
+ ...(outputConfigs?.map((config) => config.origin) ?? []),
58
38
  ]
59
39
  .filter(Boolean)
60
40
  .at(-1)
@@ -64,19 +44,15 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
64
44
  fetcher: ['vovk'],
65
45
  validateOnClient: null,
66
46
  createRPC: ['vovk'],
67
- }, schema.meta?.config?.outputConfig?.imports, isBundle ? schema.meta?.config?.bundle?.outputConfig?.imports : undefined, typeof segmentName === 'string'
68
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.imports
69
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.imports), {})),
47
+ }, config?.outputConfig?.imports, isBundle ? config?.bundle?.outputConfig?.imports : undefined, typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.imports : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.imports), {})),
70
48
  reExports: (0, deepExtend_1.default)(
71
49
  // segmentName can be an empty string (for the root segment) and null (for composed clients)
72
50
  // therefore, !segmentName indicates that this either a composed client or a root segment of a segmented client
73
- {}, !segmentName && schema.meta?.config?.outputConfig?.reExports, !segmentName && isBundle ? schema.meta?.config?.bundle?.outputConfig?.reExports : undefined,
51
+ {}, !segmentName && config?.outputConfig?.reExports, !segmentName && isBundle ? config?.bundle?.outputConfig?.reExports : undefined,
74
52
  // for segmented client, apply all reExports from all segments
75
53
  typeof segmentName !== 'string' &&
76
- Object.values(schema.meta?.config?.outputConfig?.segments ?? {}).reduce((acc, segmentConfig) => (0, deepExtend_1.default)(acc, segmentConfig.reExports ?? {}), {}),
54
+ Object.values(config?.outputConfig?.segments ?? {}).reduce((acc, segmentConfig) => (0, deepExtend_1.default)(acc, segmentConfig.reExports ?? {}), {}),
77
55
  // for a specific segment, apply reExports from that segment
78
- typeof segmentName === 'string'
79
- ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.reExports
80
- : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.reExports), {})),
56
+ typeof segmentName === 'string' ? config?.outputConfig?.segments?.[segmentName]?.reExports : undefined, outputConfigs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.reExports), {})),
81
57
  };
82
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.465",
3
+ "version": "3.0.0-draft.467",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",