vovk 3.0.0-draft.466 → 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.
- package/cjs/openapi/vovkSchemaToOpenAPI.js +1 -1
- package/cjs/utils/resolveGeneratorConfigValues.d.ts +4 -3
- package/cjs/utils/resolveGeneratorConfigValues.js +13 -19
- package/mjs/openapi/vovkSchemaToOpenAPI.js +1 -1
- package/mjs/utils/resolveGeneratorConfigValues.d.ts +4 -3
- package/mjs/utils/resolveGeneratorConfigValues.js +13 -19
- package/package.json +1 -1
|
@@ -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,
|
|
4
|
+
export declare function resolveGeneratorConfigValues({ config, schema, outputConfigs, segmentName, isBundle, projectPackageJson, }: {
|
|
5
|
+
config?: VovkStrictConfig;
|
|
5
6
|
schema: VovkSchema;
|
|
6
|
-
|
|
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,
|
|
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',
|
|
@@ -17,7 +17,7 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
17
17
|
types: './index.d.mts',
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
-
}, Object.fromEntries(Object.entries(projectPackageJson ?? {}).filter(([key]) => ['name', 'version', 'description', 'license', 'authors', 'repository', 'homepage', 'bugs', 'keywords'].includes(key))),
|
|
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), {}));
|
|
21
21
|
return {
|
|
22
22
|
package: packageJson,
|
|
23
23
|
openAPIObject: (0, deepExtend_1.default)({}, {
|
|
@@ -27,18 +27,14 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
27
27
|
version: packageJson.version,
|
|
28
28
|
description: packageJson.description,
|
|
29
29
|
},
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
samples: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.samples, isBundle ? schema.meta?.config?.bundle?.outputConfig?.samples : undefined, typeof segmentName === 'string' ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.samples : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.samples), {})),
|
|
34
|
-
readme: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.readme, isBundle ? schema.meta?.config?.bundle?.outputConfig?.readme : undefined, typeof segmentName === 'string' ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.readme : 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), {})),
|
|
35
33
|
origin: [
|
|
36
|
-
isBundle ?
|
|
37
|
-
typeof segmentName === 'string'
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
schema.meta?.config?.outputConfig?.origin,
|
|
41
|
-
...(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) ?? []),
|
|
42
38
|
]
|
|
43
39
|
.filter(Boolean)
|
|
44
40
|
.at(-1)
|
|
@@ -48,17 +44,15 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
48
44
|
fetcher: ['vovk'],
|
|
49
45
|
validateOnClient: null,
|
|
50
46
|
createRPC: ['vovk'],
|
|
51
|
-
},
|
|
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), {})),
|
|
52
48
|
reExports: (0, deepExtend_1.default)(
|
|
53
49
|
// segmentName can be an empty string (for the root segment) and null (for composed clients)
|
|
54
50
|
// therefore, !segmentName indicates that this either a composed client or a root segment of a segmented client
|
|
55
|
-
{}, !segmentName &&
|
|
51
|
+
{}, !segmentName && config?.outputConfig?.reExports, !segmentName && isBundle ? config?.bundle?.outputConfig?.reExports : undefined,
|
|
56
52
|
// for segmented client, apply all reExports from all segments
|
|
57
53
|
typeof segmentName !== 'string' &&
|
|
58
|
-
Object.values(
|
|
54
|
+
Object.values(config?.outputConfig?.segments ?? {}).reduce((acc, segmentConfig) => (0, deepExtend_1.default)(acc, segmentConfig.reExports ?? {}), {}),
|
|
59
55
|
// for a specific segment, apply reExports from that segment
|
|
60
|
-
typeof segmentName === 'string'
|
|
61
|
-
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.reExports
|
|
62
|
-
: 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), {})),
|
|
63
57
|
};
|
|
64
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,
|
|
4
|
+
export declare function resolveGeneratorConfigValues({ config, schema, outputConfigs, segmentName, isBundle, projectPackageJson, }: {
|
|
5
|
+
config?: VovkStrictConfig;
|
|
5
6
|
schema: VovkSchema;
|
|
6
|
-
|
|
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,
|
|
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',
|
|
@@ -17,7 +17,7 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
17
17
|
types: './index.d.mts',
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
-
}, Object.fromEntries(Object.entries(projectPackageJson ?? {}).filter(([key]) => ['name', 'version', 'description', 'license', 'authors', 'repository', 'homepage', 'bugs', 'keywords'].includes(key))),
|
|
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), {}));
|
|
21
21
|
return {
|
|
22
22
|
package: packageJson,
|
|
23
23
|
openAPIObject: (0, deepExtend_1.default)({}, {
|
|
@@ -27,18 +27,14 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
27
27
|
version: packageJson.version,
|
|
28
28
|
description: packageJson.description,
|
|
29
29
|
},
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
samples: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.samples, isBundle ? schema.meta?.config?.bundle?.outputConfig?.samples : undefined, typeof segmentName === 'string' ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.samples : undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.samples), {})),
|
|
34
|
-
readme: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.readme, isBundle ? schema.meta?.config?.bundle?.outputConfig?.readme : undefined, typeof segmentName === 'string' ? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.readme : 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), {})),
|
|
35
33
|
origin: [
|
|
36
|
-
isBundle ?
|
|
37
|
-
typeof segmentName === 'string'
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
schema.meta?.config?.outputConfig?.origin,
|
|
41
|
-
...(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) ?? []),
|
|
42
38
|
]
|
|
43
39
|
.filter(Boolean)
|
|
44
40
|
.at(-1)
|
|
@@ -48,17 +44,15 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
48
44
|
fetcher: ['vovk'],
|
|
49
45
|
validateOnClient: null,
|
|
50
46
|
createRPC: ['vovk'],
|
|
51
|
-
},
|
|
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), {})),
|
|
52
48
|
reExports: (0, deepExtend_1.default)(
|
|
53
49
|
// segmentName can be an empty string (for the root segment) and null (for composed clients)
|
|
54
50
|
// therefore, !segmentName indicates that this either a composed client or a root segment of a segmented client
|
|
55
|
-
{}, !segmentName &&
|
|
51
|
+
{}, !segmentName && config?.outputConfig?.reExports, !segmentName && isBundle ? config?.bundle?.outputConfig?.reExports : undefined,
|
|
56
52
|
// for segmented client, apply all reExports from all segments
|
|
57
53
|
typeof segmentName !== 'string' &&
|
|
58
|
-
Object.values(
|
|
54
|
+
Object.values(config?.outputConfig?.segments ?? {}).reduce((acc, segmentConfig) => (0, deepExtend_1.default)(acc, segmentConfig.reExports ?? {}), {}),
|
|
59
55
|
// for a specific segment, apply reExports from that segment
|
|
60
|
-
typeof segmentName === 'string'
|
|
61
|
-
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.reExports
|
|
62
|
-
: 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), {})),
|
|
63
57
|
};
|
|
64
58
|
}
|