vovk 3.0.0-draft.466 → 3.0.0-draft.468
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.d.ts +16 -5
- package/cjs/openapi/vovkSchemaToOpenAPI.js +50 -38
- package/cjs/utils/resolveGeneratorConfigValues.d.ts +7 -6
- package/cjs/utils/resolveGeneratorConfigValues.js +13 -19
- package/mjs/openapi/vovkSchemaToOpenAPI.d.ts +16 -5
- package/mjs/openapi/vovkSchemaToOpenAPI.js +50 -38
- package/mjs/utils/resolveGeneratorConfigValues.d.ts +7 -6
- package/mjs/utils/resolveGeneratorConfigValues.js +13 -19
- package/package.json +1 -1
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { type VovkSchema, type VovkOutputConfig } from '../types';
|
|
3
|
-
export declare function vovkSchemaToOpenAPI({ rootEntry, schema: fullSchema,
|
|
2
|
+
import { type VovkSchema, type VovkOutputConfig, VovkStrictConfig, VovkReadmeConfig, VovkSamplesConfig, VovkPackageJson } from '../types';
|
|
3
|
+
export declare function vovkSchemaToOpenAPI({ config, rootEntry, schema: fullSchema, outputConfigs, isBundle, segmentName: givenSegmentName, projectPackageJson, }: {
|
|
4
|
+
config: VovkStrictConfig | undefined;
|
|
4
5
|
rootEntry?: string;
|
|
5
6
|
schema: VovkSchema;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
outputConfigs: VovkOutputConfig[];
|
|
8
|
+
isBundle: boolean;
|
|
9
|
+
segmentName: string | null;
|
|
10
|
+
projectPackageJson: VovkPackageJson | undefined;
|
|
11
|
+
}): {
|
|
12
|
+
readme: VovkReadmeConfig;
|
|
13
|
+
openAPIObject: OpenAPIObject;
|
|
14
|
+
samples: VovkSamplesConfig;
|
|
15
|
+
origin: string;
|
|
16
|
+
package: VovkPackageJson;
|
|
17
|
+
imports: VovkOutputConfig['imports'];
|
|
18
|
+
reExports: VovkOutputConfig['reExports'];
|
|
19
|
+
};
|
|
@@ -44,13 +44,17 @@ function extractComponents(schema) {
|
|
|
44
44
|
const processedSchema = process(schema);
|
|
45
45
|
return [processedSchema, components];
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// returns OpenAPIObject along with resolved configs
|
|
48
|
+
function vovkSchemaToOpenAPI({ config, rootEntry = 'api', schema: fullSchema, outputConfigs, isBundle, segmentName: givenSegmentName, projectPackageJson, }) {
|
|
48
49
|
const paths = {};
|
|
49
50
|
const components = {};
|
|
50
|
-
const { openAPIObject, samples: samplesConfig, package: packageJson, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
|
|
51
|
+
const { openAPIObject, samples: samplesConfig, package: packageJson, readme: readmeConfig, origin, imports, reExports, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
|
|
52
|
+
config,
|
|
51
53
|
schema: fullSchema,
|
|
52
|
-
|
|
54
|
+
outputConfigs,
|
|
55
|
+
isBundle,
|
|
53
56
|
segmentName: givenSegmentName ?? null,
|
|
57
|
+
projectPackageJson,
|
|
54
58
|
});
|
|
55
59
|
for (const [segmentName, segmentSchema] of givenSegmentName
|
|
56
60
|
? [[givenSegmentName, fullSchema.segments[givenSegmentName]]]
|
|
@@ -194,45 +198,53 @@ function vovkSchemaToOpenAPI({ rootEntry = 'api', schema: fullSchema, configs, s
|
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
return {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
201
|
+
readme: readmeConfig,
|
|
202
|
+
samples: samplesConfig,
|
|
203
|
+
package: packageJson,
|
|
204
|
+
imports,
|
|
205
|
+
reExports,
|
|
206
|
+
origin,
|
|
207
|
+
openAPIObject: {
|
|
208
|
+
...openAPIObject,
|
|
209
|
+
components: {
|
|
210
|
+
...openAPIObject?.components,
|
|
211
|
+
schemas: {
|
|
212
|
+
...(openAPIObject?.components?.schemas ?? components),
|
|
213
|
+
HttpStatus: {
|
|
214
|
+
type: 'integer',
|
|
215
|
+
description: 'HTTP status code',
|
|
216
|
+
enum: Object.keys(types_1.HttpStatus)
|
|
217
|
+
.map((k) => types_1.HttpStatus[k])
|
|
218
|
+
.filter(Boolean)
|
|
219
|
+
.filter((v) => typeof v === 'number'),
|
|
220
|
+
},
|
|
221
|
+
VovkErrorResponse: {
|
|
222
|
+
type: 'object',
|
|
223
|
+
description: 'Vovk error response',
|
|
224
|
+
properties: {
|
|
225
|
+
cause: {
|
|
226
|
+
description: 'Error cause of any shape',
|
|
227
|
+
},
|
|
228
|
+
statusCode: {
|
|
229
|
+
$ref: '#/components/schemas/HttpStatus',
|
|
230
|
+
},
|
|
231
|
+
message: {
|
|
232
|
+
type: 'string',
|
|
233
|
+
description: 'Error message',
|
|
234
|
+
},
|
|
235
|
+
isError: {
|
|
236
|
+
type: 'boolean',
|
|
237
|
+
const: true,
|
|
238
|
+
description: 'Indicates that this object represents an error',
|
|
239
|
+
},
|
|
228
240
|
},
|
|
241
|
+
required: ['statusCode', 'message', 'isError'],
|
|
242
|
+
additionalProperties: false,
|
|
229
243
|
},
|
|
230
|
-
|
|
231
|
-
additionalProperties: false,
|
|
244
|
+
...openAPIObject?.components?.schemas,
|
|
232
245
|
},
|
|
233
|
-
...openAPIObject?.components?.schemas,
|
|
234
246
|
},
|
|
247
|
+
paths,
|
|
235
248
|
},
|
|
236
|
-
paths,
|
|
237
249
|
};
|
|
238
250
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { PackageJson } from 'type-fest';
|
|
2
|
-
import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema } from '../types';
|
|
2
|
+
import type { VovkOutputConfig, VovkPackageJson, 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 | undefined;
|
|
5
6
|
schema: VovkSchema;
|
|
6
|
-
|
|
7
|
+
outputConfigs: VovkOutputConfig[];
|
|
7
8
|
segmentName: string | null;
|
|
8
|
-
isBundle
|
|
9
|
-
projectPackageJson
|
|
9
|
+
isBundle: boolean;
|
|
10
|
+
projectPackageJson: PackageJson | undefined;
|
|
10
11
|
}): {
|
|
11
12
|
readme: VovkReadmeConfig;
|
|
12
13
|
openAPIObject: OpenAPIObject;
|
|
13
14
|
samples: VovkSamplesConfig;
|
|
14
15
|
origin: string;
|
|
15
|
-
package:
|
|
16
|
+
package: VovkPackageJson;
|
|
16
17
|
imports: VovkOutputConfig['imports'];
|
|
17
18
|
reExports: VovkOutputConfig['reExports'];
|
|
18
19
|
};
|
|
@@ -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
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { type VovkSchema, type VovkOutputConfig } from '../types';
|
|
3
|
-
export declare function vovkSchemaToOpenAPI({ rootEntry, schema: fullSchema,
|
|
2
|
+
import { type VovkSchema, type VovkOutputConfig, VovkStrictConfig, VovkReadmeConfig, VovkSamplesConfig, VovkPackageJson } from '../types';
|
|
3
|
+
export declare function vovkSchemaToOpenAPI({ config, rootEntry, schema: fullSchema, outputConfigs, isBundle, segmentName: givenSegmentName, projectPackageJson, }: {
|
|
4
|
+
config: VovkStrictConfig | undefined;
|
|
4
5
|
rootEntry?: string;
|
|
5
6
|
schema: VovkSchema;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
outputConfigs: VovkOutputConfig[];
|
|
8
|
+
isBundle: boolean;
|
|
9
|
+
segmentName: string | null;
|
|
10
|
+
projectPackageJson: VovkPackageJson | undefined;
|
|
11
|
+
}): {
|
|
12
|
+
readme: VovkReadmeConfig;
|
|
13
|
+
openAPIObject: OpenAPIObject;
|
|
14
|
+
samples: VovkSamplesConfig;
|
|
15
|
+
origin: string;
|
|
16
|
+
package: VovkPackageJson;
|
|
17
|
+
imports: VovkOutputConfig['imports'];
|
|
18
|
+
reExports: VovkOutputConfig['reExports'];
|
|
19
|
+
};
|
|
@@ -44,13 +44,17 @@ function extractComponents(schema) {
|
|
|
44
44
|
const processedSchema = process(schema);
|
|
45
45
|
return [processedSchema, components];
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// returns OpenAPIObject along with resolved configs
|
|
48
|
+
function vovkSchemaToOpenAPI({ config, rootEntry = 'api', schema: fullSchema, outputConfigs, isBundle, segmentName: givenSegmentName, projectPackageJson, }) {
|
|
48
49
|
const paths = {};
|
|
49
50
|
const components = {};
|
|
50
|
-
const { openAPIObject, samples: samplesConfig, package: packageJson, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
|
|
51
|
+
const { openAPIObject, samples: samplesConfig, package: packageJson, readme: readmeConfig, origin, imports, reExports, } = (0, resolveGeneratorConfigValues_1.resolveGeneratorConfigValues)({
|
|
52
|
+
config,
|
|
51
53
|
schema: fullSchema,
|
|
52
|
-
|
|
54
|
+
outputConfigs,
|
|
55
|
+
isBundle,
|
|
53
56
|
segmentName: givenSegmentName ?? null,
|
|
57
|
+
projectPackageJson,
|
|
54
58
|
});
|
|
55
59
|
for (const [segmentName, segmentSchema] of givenSegmentName
|
|
56
60
|
? [[givenSegmentName, fullSchema.segments[givenSegmentName]]]
|
|
@@ -194,45 +198,53 @@ function vovkSchemaToOpenAPI({ rootEntry = 'api', schema: fullSchema, configs, s
|
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
return {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
201
|
+
readme: readmeConfig,
|
|
202
|
+
samples: samplesConfig,
|
|
203
|
+
package: packageJson,
|
|
204
|
+
imports,
|
|
205
|
+
reExports,
|
|
206
|
+
origin,
|
|
207
|
+
openAPIObject: {
|
|
208
|
+
...openAPIObject,
|
|
209
|
+
components: {
|
|
210
|
+
...openAPIObject?.components,
|
|
211
|
+
schemas: {
|
|
212
|
+
...(openAPIObject?.components?.schemas ?? components),
|
|
213
|
+
HttpStatus: {
|
|
214
|
+
type: 'integer',
|
|
215
|
+
description: 'HTTP status code',
|
|
216
|
+
enum: Object.keys(types_1.HttpStatus)
|
|
217
|
+
.map((k) => types_1.HttpStatus[k])
|
|
218
|
+
.filter(Boolean)
|
|
219
|
+
.filter((v) => typeof v === 'number'),
|
|
220
|
+
},
|
|
221
|
+
VovkErrorResponse: {
|
|
222
|
+
type: 'object',
|
|
223
|
+
description: 'Vovk error response',
|
|
224
|
+
properties: {
|
|
225
|
+
cause: {
|
|
226
|
+
description: 'Error cause of any shape',
|
|
227
|
+
},
|
|
228
|
+
statusCode: {
|
|
229
|
+
$ref: '#/components/schemas/HttpStatus',
|
|
230
|
+
},
|
|
231
|
+
message: {
|
|
232
|
+
type: 'string',
|
|
233
|
+
description: 'Error message',
|
|
234
|
+
},
|
|
235
|
+
isError: {
|
|
236
|
+
type: 'boolean',
|
|
237
|
+
const: true,
|
|
238
|
+
description: 'Indicates that this object represents an error',
|
|
239
|
+
},
|
|
228
240
|
},
|
|
241
|
+
required: ['statusCode', 'message', 'isError'],
|
|
242
|
+
additionalProperties: false,
|
|
229
243
|
},
|
|
230
|
-
|
|
231
|
-
additionalProperties: false,
|
|
244
|
+
...openAPIObject?.components?.schemas,
|
|
232
245
|
},
|
|
233
|
-
...openAPIObject?.components?.schemas,
|
|
234
246
|
},
|
|
247
|
+
paths,
|
|
235
248
|
},
|
|
236
|
-
paths,
|
|
237
249
|
};
|
|
238
250
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { PackageJson } from 'type-fest';
|
|
2
|
-
import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema } from '../types';
|
|
2
|
+
import type { VovkOutputConfig, VovkPackageJson, 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 | undefined;
|
|
5
6
|
schema: VovkSchema;
|
|
6
|
-
|
|
7
|
+
outputConfigs: VovkOutputConfig[];
|
|
7
8
|
segmentName: string | null;
|
|
8
|
-
isBundle
|
|
9
|
-
projectPackageJson
|
|
9
|
+
isBundle: boolean;
|
|
10
|
+
projectPackageJson: PackageJson | undefined;
|
|
10
11
|
}): {
|
|
11
12
|
readme: VovkReadmeConfig;
|
|
12
13
|
openAPIObject: OpenAPIObject;
|
|
13
14
|
samples: VovkSamplesConfig;
|
|
14
15
|
origin: string;
|
|
15
|
-
package:
|
|
16
|
+
package: VovkPackageJson;
|
|
16
17
|
imports: VovkOutputConfig['imports'];
|
|
17
18
|
reExports: VovkOutputConfig['reExports'];
|
|
18
19
|
};
|
|
@@ -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
|
}
|