@conduit-client/tools-core 3.8.0 → 3.9.0
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/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
6
|
import * as url from "url";
|
|
7
|
-
import { amfAPIService,
|
|
7
|
+
import { swaggerAPIService, amfAPIService, parseSwaggerDocument, getSwaggerAnnotationVersion, V1_VERSION, parseAmfDocument, getAmfAnnotationVersion } from "@conduit-client/model/v1";
|
|
8
8
|
import { loggerService, DefaultFileParserLogger, satisfies } from "@conduit-client/utils";
|
|
9
9
|
import * as fs from "fs";
|
|
10
10
|
import path from "path";
|
|
@@ -33,15 +33,19 @@ function buildServiceDescriptor() {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
async function runV1Pipeline(inputFile, outputDir, logger, options = {}) {
|
|
36
|
+
return runPipeline$1(inputFile, outputDir, logger, { ...options, parser: "amf" });
|
|
37
|
+
}
|
|
38
|
+
async function runPipeline$1(inputFile, outputDir, logger, options = {}) {
|
|
36
39
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
40
|
+
const parser = options.parser || "amf";
|
|
37
41
|
const filePerType = options.filePerType || false;
|
|
38
42
|
if (fs.existsSync(outputDir)) {
|
|
39
43
|
await fs.promises.rm(outputDir, { recursive: true });
|
|
40
44
|
}
|
|
41
45
|
logger.trace("Instantiating Feature flags service");
|
|
42
46
|
const featureFlags = buildServiceDescriptor().service;
|
|
43
|
-
logger.trace(
|
|
44
|
-
const api = ((_a = options.serviceOverrides) == null ? void 0 : _a.api) ?? amfAPIService({ logger, featureFlags });
|
|
47
|
+
logger.trace(`Instantiating API service (using ${parser} parser)`);
|
|
48
|
+
const api = ((_a = options.serviceOverrides) == null ? void 0 : _a.api) ?? (parser === "swagger" ? swaggerAPIService({ logger, featureFlags }) : amfAPIService({ logger, featureFlags }));
|
|
45
49
|
logger.trace("Instantiating File service");
|
|
46
50
|
const file = ((_b = options.serviceOverrides) == null ? void 0 : _b.file) ?? fileService();
|
|
47
51
|
const { fileForType, fileForNormalizedType } = typeFileGrouping(filePerType);
|
|
@@ -102,19 +106,37 @@ function typeFileGrouping(filePerType) {
|
|
|
102
106
|
fileForNormalizedType: SINGLE_FILE_NORMALIZED
|
|
103
107
|
};
|
|
104
108
|
}
|
|
109
|
+
async function runV2Pipeline(inputFile, outputDir, logger, options = {}) {
|
|
110
|
+
await runPipeline$1(inputFile, outputDir, logger, { ...options, parser: "swagger" });
|
|
111
|
+
}
|
|
105
112
|
async function runPipeline(inputFilePath, outputDir, options = {}) {
|
|
106
|
-
var _a;
|
|
113
|
+
var _a, _b;
|
|
107
114
|
const logger = options.loggerService || loggerService();
|
|
108
115
|
const fileParserLogger = new DefaultFileParserLogger({ logger }, inputFilePath);
|
|
109
116
|
const inputUrl = url.pathToFileURL(inputFilePath);
|
|
117
|
+
if (options.parser === "swagger") {
|
|
118
|
+
const { document: document2 } = await parseSwaggerDocument(inputUrl, fileParserLogger);
|
|
119
|
+
const version2 = getSwaggerAnnotationVersion(document2);
|
|
120
|
+
if (satisfies(V1_VERSION, version2)) {
|
|
121
|
+
return runV2Pipeline(inputFilePath, outputDir, logger, {
|
|
122
|
+
filePerType: options.filePerType,
|
|
123
|
+
includeExclude: options.includeExclude,
|
|
124
|
+
serviceOverrides: (_a = options.serviceOverrides) == null ? void 0 : _a.v1
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Unsupported value for x-onestore.version: ${version2}. Supported versions are: [${V1_VERSION}]`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
110
131
|
const document = await parseAmfDocument(inputUrl, fileParserLogger);
|
|
111
132
|
const webApi = document.encodes;
|
|
112
133
|
const version = getAmfAnnotationVersion(webApi);
|
|
113
134
|
if (satisfies(V1_VERSION, version)) {
|
|
114
135
|
return runV1Pipeline(inputFilePath, outputDir, logger, {
|
|
136
|
+
parser: "amf",
|
|
115
137
|
filePerType: options.filePerType,
|
|
116
138
|
includeExclude: options.includeExclude,
|
|
117
|
-
serviceOverrides: (
|
|
139
|
+
serviceOverrides: (_b = options.serviceOverrides) == null ? void 0 : _b.v1
|
|
118
140
|
});
|
|
119
141
|
}
|
|
120
142
|
throw new Error(
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../services/feature-flags/dist/v1/index.js","../src/pipeline/v1.ts","../src/pipeline/index.ts","../src/generate.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nclass FeatureFlagsService {\n constructor() {\n this.flags = /* @__PURE__ */ new Map();\n }\n set(flagName, value) {\n this.flags.set(flagName, value);\n }\n get(flagName, defaultValue = false) {\n return this.flags.get(flagName) || defaultValue;\n }\n}\nfunction buildServiceDescriptor() {\n return {\n version: \"1.0\",\n service: new FeatureFlagsService(),\n type: \"featureFlags\"\n };\n}\nexport {\n FeatureFlagsService,\n buildServiceDescriptor\n};\n//# sourceMappingURL=index.js.map\n","import * as fs from 'fs';\nimport path from 'path';\nimport { type LoggerService, type IncludeExclude } from '@conduit-client/utils';\nimport {\n fileService,\n FILE_PER_TYPE,\n SINGLE_FILE,\n typeDefinitions,\n apiFamilyModuleGeneratorService,\n writeFiles,\n jsonSchemaDeclarationService,\n typeRegistryGeneratorService,\n graphqlTypeRegistryGeneratorService,\n normalizedTypeDefinitions,\n FILE_PER_NORMALIZED_TYPE,\n SINGLE_FILE_NORMALIZED,\n} from '@conduit-client/generator-ts/v1';\nimport { amfAPIService } from '@conduit-client/model/v1';\nimport { buildServiceDescriptor as buildFeatureFlagsServiceDescriptor } from '@conduit-client/service-feature-flags/v1';\n\nexport async function runV1Pipeline(\n inputFile: string,\n outputDir: string,\n logger: LoggerService,\n options: {\n filePerType?: boolean;\n includeExclude?: IncludeExclude;\n serviceOverrides?: {\n api?: ReturnType<typeof amfAPIService>;\n file?: ReturnType<typeof fileService>;\n typeDefinition?: ReturnType<typeof typeDefinitions>;\n normalizedTypeDefinition?: ReturnType<typeof normalizedTypeDefinitions>;\n jsonSchema?: ReturnType<typeof jsonSchemaDeclarationService>;\n typeRegistryGenerator?: ReturnType<typeof typeRegistryGeneratorService>;\n graphqlTypeRegistryGenerator?: ReturnType<typeof graphqlTypeRegistryGeneratorService>;\n apiFamilyModuleGenerator?: ReturnType<typeof apiFamilyModuleGeneratorService>;\n };\n } = {}\n) {\n const filePerType = options.filePerType || false;\n\n if (fs.existsSync(outputDir)) {\n await fs.promises.rm(outputDir, { recursive: true });\n }\n\n logger.trace('Instantiating Feature flags service');\n const featureFlags = buildFeatureFlagsServiceDescriptor().service;\n\n logger.trace('Instantiating API service');\n const api = options.serviceOverrides?.api ?? amfAPIService({ logger, featureFlags });\n\n logger.trace('Instantiating File service');\n const file = options.serviceOverrides?.file ?? fileService();\n\n const { fileForType, fileForNormalizedType } = typeFileGrouping(filePerType);\n\n logger.trace('Instantiating Type Declaration service');\n const typeDefinition =\n options.serviceOverrides?.typeDefinition ??\n typeDefinitions({ file, api }, { fileFor: fileForType });\n\n logger.trace('Instantiating Normalized Type Declaration service');\n const normalizedTypeDefinition =\n options.serviceOverrides?.normalizedTypeDefinition ??\n normalizedTypeDefinitions({ file, api }, { fileFor: fileForNormalizedType });\n\n logger.trace('Instantiating JSON Schema Declaration service');\n const jsonSchema =\n options.serviceOverrides?.jsonSchema ?? jsonSchemaDeclarationService({ file, api });\n\n logger.trace('Instantiating Type Registry Generator service');\n const typeRegistryGenerator =\n options.serviceOverrides?.typeRegistryGenerator ??\n typeRegistryGeneratorService({\n api,\n file,\n typeDefinition,\n normalizedTypeDefinition,\n jsonSchema,\n });\n\n logger.trace('Instantiating GraphQL Type Registry Generator service');\n const graphqlTypeRegistryGenerator =\n options.serviceOverrides?.graphqlTypeRegistryGenerator ??\n graphqlTypeRegistryGeneratorService({ file, api });\n\n logger.trace('Instantiating LWC Bindings Generator service');\n\n const apiFamilyModuleGenerator =\n options.serviceOverrides?.apiFamilyModuleGenerator ??\n apiFamilyModuleGeneratorService({\n api,\n file,\n logger,\n typeDefinition,\n jsonSchema,\n typeRegistryGenerator,\n graphqlTypeRegistryGenerator,\n });\n\n const services = {\n api,\n file,\n logger,\n typeDefinition,\n normalizedTypeDefinition,\n jsonSchema,\n featureFlags,\n typeRegistryGenerator,\n graphqlTypeRegistryGenerator,\n apiFamilyModuleGenerator,\n };\n\n logger.debug(`Building API for ${inputFile}`);\n await services.api.build({ filename: path.resolve(inputFile) });\n\n logger.debug('Building module');\n apiFamilyModuleGenerator.build();\n\n logger.debug('Writing files to disk');\n await writeFiles(services, outputDir, { prettified: true });\n}\n\n/**\n * Selects which type definition grouping method to use based\n * on the value of the --filePerType flag\n *\n * @param filePerType value of --filePerType flag\n * @returns {fileForType: (typename: string) => string, fileForNormalizedType: (typename: string) => string}\n */\nexport function typeFileGrouping(filePerType: boolean) {\n if (filePerType) {\n return {\n fileForType: FILE_PER_TYPE,\n fileForNormalizedType: FILE_PER_NORMALIZED_TYPE,\n };\n }\n return {\n fileForType: SINGLE_FILE,\n fileForNormalizedType: SINGLE_FILE_NORMALIZED,\n };\n}\n","import * as url from 'url';\nimport { V1_VERSION, getAmfAnnotationVersion, parseAmfDocument } from '@conduit-client/model/v1';\nimport {\n type LoggerService,\n DefaultFileParserLogger,\n satisfies,\n loggerService as loggerServiceFactory,\n type IncludeExclude,\n} from '@conduit-client/utils';\nimport { runV1Pipeline } from './v1';\nimport type amf from 'amf-client-js';\n\ntype V1ServiceOverrides = NonNullable<Parameters<typeof runV1Pipeline>[3]>['serviceOverrides'];\n\n/**\n * Programmatic interface to call the code generator with version mapping.\n * @param inputFile spec file to parse\n * @param outputDir output directory to generate code in\n * @param options code generator configuration\n */\n\nexport async function runPipeline(\n inputFilePath: string,\n outputDir: string,\n options: {\n loggerService?: LoggerService;\n filePerType?: boolean;\n includeExclude?: IncludeExclude;\n serviceOverrides?: {\n v1?: V1ServiceOverrides;\n };\n } = {}\n) {\n const logger = options.loggerService || loggerServiceFactory();\n const fileParserLogger = new DefaultFileParserLogger({ logger }, inputFilePath);\n const inputUrl = url.pathToFileURL(inputFilePath) as URL;\n const document = await parseAmfDocument(inputUrl, fileParserLogger);\n const webApi = document.encodes as amf.WebApi;\n const version = getAmfAnnotationVersion(webApi);\n\n if (satisfies(V1_VERSION, version)) {\n return runV1Pipeline(inputFilePath, outputDir, logger, {\n filePerType: options.filePerType,\n includeExclude: options.includeExclude,\n serviceOverrides: options.serviceOverrides?.v1,\n });\n }\n\n throw new Error(\n `Unsupported value for x-onestore.version: ${version}. Supported versions are: [${V1_VERSION}]`\n );\n}\n","import { runPipeline } from './pipeline';\n\ntype RunPipelineOptions = Parameters<typeof runPipeline>[2];\n\n/**\n * Programmatic interface to call the code generator without the oclif layer.\n * @param inputFile spec file to parse\n * @param outputDir output directory to generate code in\n * @param options code generator configuration\n */\nexport async function generate(\n inputFile: string,\n outputDir: string,\n options: RunPipelineOptions = {}\n) {\n await runPipeline(inputFile, outputDir, options);\n}\n"],"names":["buildFeatureFlagsServiceDescriptor","loggerServiceFactory"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,MAAM,oBAAoB;AAAA,EACxB,cAAc;AACZ,SAAK,QAAwB,oBAAI,IAAG;AAAA,EACtC;AAAA,EACA,IAAI,UAAU,OAAO;AACnB,SAAK,MAAM,IAAI,UAAU,KAAK;AAAA,EAChC;AAAA,EACA,IAAI,UAAU,eAAe,OAAO;AAClC,WAAO,KAAK,MAAM,IAAI,QAAQ,KAAK;AAAA,EACrC;AACF;AACA,SAAS,yBAAyB;AAChC,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS,IAAI,oBAAmB;AAAA,IAChC,MAAM;AAAA,EACV;AACA;ACFA,eAAsB,cAClB,WACA,WACA,QACA,UAaI,CAAA,G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|
+
{"version":3,"file":"index.js","sources":["../../../services/feature-flags/dist/v1/index.js","../src/pipeline/v1.ts","../src/pipeline/v2.ts","../src/pipeline/index.ts","../src/generate.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nclass FeatureFlagsService {\n constructor() {\n this.flags = /* @__PURE__ */ new Map();\n }\n set(flagName, value) {\n this.flags.set(flagName, value);\n }\n get(flagName, defaultValue = false) {\n return this.flags.get(flagName) || defaultValue;\n }\n}\nfunction buildServiceDescriptor() {\n return {\n version: \"1.0\",\n service: new FeatureFlagsService(),\n type: \"featureFlags\"\n };\n}\nexport {\n FeatureFlagsService,\n buildServiceDescriptor\n};\n//# sourceMappingURL=index.js.map\n","import * as fs from 'fs';\nimport path from 'path';\nimport { type LoggerService, type IncludeExclude } from '@conduit-client/utils';\nimport {\n fileService,\n FILE_PER_TYPE,\n SINGLE_FILE,\n typeDefinitions,\n apiFamilyModuleGeneratorService,\n writeFiles,\n jsonSchemaDeclarationService,\n typeRegistryGeneratorService,\n graphqlTypeRegistryGeneratorService,\n normalizedTypeDefinitions,\n FILE_PER_NORMALIZED_TYPE,\n SINGLE_FILE_NORMALIZED,\n} from '@conduit-client/generator-ts/v1';\nimport { amfAPIService, swaggerAPIService } from '@conduit-client/model/v1';\nimport { buildServiceDescriptor as buildFeatureFlagsServiceDescriptor } from '@conduit-client/service-feature-flags/v1';\nimport type { ParserType } from './index';\n\nexport type PipelineOptions = {\n parser?: ParserType;\n filePerType?: boolean;\n includeExclude?: IncludeExclude;\n serviceOverrides?: {\n api?: ReturnType<typeof amfAPIService>;\n file?: ReturnType<typeof fileService>;\n typeDefinition?: ReturnType<typeof typeDefinitions>;\n normalizedTypeDefinition?: ReturnType<typeof normalizedTypeDefinitions>;\n jsonSchema?: ReturnType<typeof jsonSchemaDeclarationService>;\n typeRegistryGenerator?: ReturnType<typeof typeRegistryGeneratorService>;\n graphqlTypeRegistryGenerator?: ReturnType<typeof graphqlTypeRegistryGeneratorService>;\n apiFamilyModuleGenerator?: ReturnType<typeof apiFamilyModuleGeneratorService>;\n };\n};\n\nexport async function runV1Pipeline(\n inputFile: string,\n outputDir: string,\n logger: LoggerService,\n options: PipelineOptions = {}\n) {\n return runPipeline(inputFile, outputDir, logger, { ...options, parser: 'amf' });\n}\n\nexport async function runPipeline(\n inputFile: string,\n outputDir: string,\n logger: LoggerService,\n options: PipelineOptions = {}\n) {\n const parser = options.parser || 'amf';\n const filePerType = options.filePerType || false;\n\n if (fs.existsSync(outputDir)) {\n await fs.promises.rm(outputDir, { recursive: true });\n }\n\n logger.trace('Instantiating Feature flags service');\n const featureFlags = buildFeatureFlagsServiceDescriptor().service;\n\n logger.trace(`Instantiating API service (using ${parser} parser)`);\n const api =\n options.serviceOverrides?.api ??\n (parser === 'swagger'\n ? swaggerAPIService({ logger, featureFlags })\n : amfAPIService({ logger, featureFlags }));\n\n logger.trace('Instantiating File service');\n const file = options.serviceOverrides?.file ?? fileService();\n\n const { fileForType, fileForNormalizedType } = typeFileGrouping(filePerType);\n\n logger.trace('Instantiating Type Declaration service');\n const typeDefinition =\n options.serviceOverrides?.typeDefinition ??\n typeDefinitions({ file, api }, { fileFor: fileForType });\n\n logger.trace('Instantiating Normalized Type Declaration service');\n const normalizedTypeDefinition =\n options.serviceOverrides?.normalizedTypeDefinition ??\n normalizedTypeDefinitions({ file, api }, { fileFor: fileForNormalizedType });\n\n logger.trace('Instantiating JSON Schema Declaration service');\n const jsonSchema =\n options.serviceOverrides?.jsonSchema ?? jsonSchemaDeclarationService({ file, api });\n\n logger.trace('Instantiating Type Registry Generator service');\n const typeRegistryGenerator =\n options.serviceOverrides?.typeRegistryGenerator ??\n typeRegistryGeneratorService({\n api,\n file,\n typeDefinition,\n normalizedTypeDefinition,\n jsonSchema,\n });\n\n logger.trace('Instantiating GraphQL Type Registry Generator service');\n const graphqlTypeRegistryGenerator =\n options.serviceOverrides?.graphqlTypeRegistryGenerator ??\n graphqlTypeRegistryGeneratorService({ file, api });\n\n logger.trace('Instantiating LWC Bindings Generator service');\n\n const apiFamilyModuleGenerator =\n options.serviceOverrides?.apiFamilyModuleGenerator ??\n apiFamilyModuleGeneratorService({\n api,\n file,\n logger,\n typeDefinition,\n jsonSchema,\n typeRegistryGenerator,\n graphqlTypeRegistryGenerator,\n });\n\n const services = {\n api,\n file,\n logger,\n typeDefinition,\n normalizedTypeDefinition,\n jsonSchema,\n featureFlags,\n typeRegistryGenerator,\n graphqlTypeRegistryGenerator,\n apiFamilyModuleGenerator,\n };\n\n logger.debug(`Building API for ${inputFile}`);\n await services.api.build({ filename: path.resolve(inputFile) });\n\n logger.debug('Building module');\n apiFamilyModuleGenerator.build();\n\n logger.debug('Writing files to disk');\n await writeFiles(services, outputDir, { prettified: true });\n}\n\n/**\n * Selects which type definition grouping method to use based\n * on the value of the --filePerType flag\n *\n * @param filePerType value of --filePerType flag\n * @returns {fileForType: (typename: string) => string, fileForNormalizedType: (typename: string) => string}\n */\nexport function typeFileGrouping(filePerType: boolean) {\n if (filePerType) {\n return {\n fileForType: FILE_PER_TYPE,\n fileForNormalizedType: FILE_PER_NORMALIZED_TYPE,\n };\n }\n return {\n fileForType: SINGLE_FILE,\n fileForNormalizedType: SINGLE_FILE_NORMALIZED,\n };\n}\n","import { LoggerService } from '@conduit-client/utils';\nimport { runPipeline, type PipelineOptions } from './v1';\n\nexport async function runV2Pipeline(\n inputFile: string,\n outputDir: string,\n logger: LoggerService,\n options: PipelineOptions = {}\n) {\n await runPipeline(inputFile, outputDir, logger, { ...options, parser: 'swagger' });\n}\n","import * as url from 'url';\nimport {\n V1_VERSION,\n getAmfAnnotationVersion,\n parseAmfDocument,\n getSwaggerAnnotationVersion,\n parseSwaggerDocument,\n} from '@conduit-client/model/v1';\nimport {\n type LoggerService,\n DefaultFileParserLogger,\n satisfies,\n loggerService as loggerServiceFactory,\n type IncludeExclude,\n} from '@conduit-client/utils';\nimport { runV1Pipeline } from './v1';\nimport { runV2Pipeline } from './v2';\nimport type amf from 'amf-client-js';\n\ntype V1ServiceOverrides = NonNullable<Parameters<typeof runV1Pipeline>[3]>['serviceOverrides'];\n\n/**\n * Parser type: 'amf' uses AMF parser, 'swagger' uses swagger-parser\n */\nexport type ParserType = 'amf' | 'swagger';\n\n/**\n * Programmatic interface to call the code generator with version mapping.\n * @param inputFile spec file to parse\n * @param outputDir output directory to generate code in\n * @param options code generator configuration\n */\n\nexport async function runPipeline(\n inputFilePath: string,\n outputDir: string,\n options: {\n parser?: ParserType;\n loggerService?: LoggerService;\n filePerType?: boolean;\n includeExclude?: IncludeExclude;\n serviceOverrides?: {\n v1?: V1ServiceOverrides;\n };\n } = {}\n) {\n const logger = options.loggerService || loggerServiceFactory();\n const fileParserLogger = new DefaultFileParserLogger({ logger }, inputFilePath);\n const inputUrl = url.pathToFileURL(inputFilePath) as URL;\n\n if (options.parser === 'swagger') {\n // Use swagger-parser\n const { document } = await parseSwaggerDocument(inputUrl, fileParserLogger);\n const version = getSwaggerAnnotationVersion(document);\n\n if (satisfies(V1_VERSION, version)) {\n return runV2Pipeline(inputFilePath, outputDir, logger, {\n filePerType: options.filePerType,\n includeExclude: options.includeExclude,\n serviceOverrides: options.serviceOverrides?.v1,\n });\n }\n\n throw new Error(\n `Unsupported value for x-onestore.version: ${version}. Supported versions are: [${V1_VERSION}]`\n );\n }\n\n // Default: use AMF parser\n const document = await parseAmfDocument(inputUrl, fileParserLogger);\n const webApi = document.encodes as amf.WebApi;\n const version = getAmfAnnotationVersion(webApi);\n\n if (satisfies(V1_VERSION, version)) {\n return runV1Pipeline(inputFilePath, outputDir, logger, {\n parser: 'amf',\n filePerType: options.filePerType,\n includeExclude: options.includeExclude,\n serviceOverrides: options.serviceOverrides?.v1,\n });\n }\n\n throw new Error(\n `Unsupported value for x-onestore.version: ${version}. Supported versions are: [${V1_VERSION}]`\n );\n}\n","import { runPipeline } from './pipeline';\n\ntype RunPipelineOptions = Parameters<typeof runPipeline>[2];\n\n/**\n * Programmatic interface to call the code generator without the oclif layer.\n * @param inputFile spec file to parse\n * @param outputDir output directory to generate code in\n * @param options code generator configuration\n */\nexport async function generate(\n inputFile: string,\n outputDir: string,\n options: RunPipelineOptions = {}\n) {\n await runPipeline(inputFile, outputDir, options);\n}\n"],"names":["runPipeline","buildFeatureFlagsServiceDescriptor","loggerServiceFactory","document","version"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,MAAM,oBAAoB;AAAA,EACxB,cAAc;AACZ,SAAK,QAAwB,oBAAI,IAAG;AAAA,EACtC;AAAA,EACA,IAAI,UAAU,OAAO;AACnB,SAAK,MAAM,IAAI,UAAU,KAAK;AAAA,EAChC;AAAA,EACA,IAAI,UAAU,eAAe,OAAO;AAClC,WAAO,KAAK,MAAM,IAAI,QAAQ,KAAK;AAAA,EACrC;AACF;AACA,SAAS,yBAAyB;AAChC,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS,IAAI,oBAAmB;AAAA,IAChC,MAAM;AAAA,EACV;AACA;ACeA,eAAsB,cAClB,WACA,WACA,QACA,UAA2B,CAAA,GAC7B;AACE,SAAOA,cAAY,WAAW,WAAW,QAAQ,EAAE,GAAG,SAAS,QAAQ,OAAO;AAClF;AAEA,eAAsBA,cAClB,WACA,WACA,QACA,UAA2B,CAAA,GAC7B;;AACE,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,cAAc,QAAQ,eAAe;AAE3C,MAAI,GAAG,WAAW,SAAS,GAAG;AAC1B,UAAM,GAAG,SAAS,GAAG,WAAW,EAAE,WAAW,MAAM;AAAA,EACvD;AAEA,SAAO,MAAM,qCAAqC;AAClD,QAAM,eAAeC,yBAAqC;AAE1D,SAAO,MAAM,oCAAoC,MAAM,UAAU;AACjE,QAAM,QACF,aAAQ,qBAAR,mBAA0B,SACzB,WAAW,YACN,kBAAkB,EAAE,QAAQ,aAAA,CAAc,IAC1C,cAAc,EAAE,QAAQ,cAAc;AAEhD,SA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B,gBAAgB,QAAQ;AAAA,MACxB,mBAAkB,aAAQ,qBAAR,mBAA0B;AAAA,IAAA,CAC/C;AAAA,EACL;AAEA,QAAM,IAAI;AAAA,IACN,6CAA6C,OAAO,8BAA8B,UAAU;AAAA,EAAA;AAEpG;AC3EA,eAAsB,SAClB,WACA,WACA,UAA8B,CAAA,GAChC;AACE,QAAM,YAAY,WAAW,WAAW,OAAO;AACnD;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type LoggerService, type IncludeExclude } from '@conduit-client/utils';
|
|
2
2
|
import { runV1Pipeline } from './v1';
|
|
3
3
|
type V1ServiceOverrides = NonNullable<Parameters<typeof runV1Pipeline>[3]>['serviceOverrides'];
|
|
4
|
+
/**
|
|
5
|
+
* Parser type: 'amf' uses AMF parser, 'swagger' uses swagger-parser
|
|
6
|
+
*/
|
|
7
|
+
export type ParserType = 'amf' | 'swagger';
|
|
4
8
|
/**
|
|
5
9
|
* Programmatic interface to call the code generator with version mapping.
|
|
6
10
|
* @param inputFile spec file to parse
|
|
@@ -8,6 +12,7 @@ type V1ServiceOverrides = NonNullable<Parameters<typeof runV1Pipeline>[3]>['serv
|
|
|
8
12
|
* @param options code generator configuration
|
|
9
13
|
*/
|
|
10
14
|
export declare function runPipeline(inputFilePath: string, outputDir: string, options?: {
|
|
15
|
+
parser?: ParserType;
|
|
11
16
|
loggerService?: LoggerService;
|
|
12
17
|
filePerType?: boolean;
|
|
13
18
|
includeExclude?: IncludeExclude;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type LoggerService, type IncludeExclude } from '@conduit-client/utils';
|
|
2
2
|
import { fileService, typeDefinitions, apiFamilyModuleGeneratorService, jsonSchemaDeclarationService, typeRegistryGeneratorService, graphqlTypeRegistryGeneratorService, normalizedTypeDefinitions } from '@conduit-client/generator-ts/v1';
|
|
3
3
|
import { amfAPIService } from '@conduit-client/model/v1';
|
|
4
|
-
|
|
4
|
+
import type { ParserType } from './index';
|
|
5
|
+
export type PipelineOptions = {
|
|
6
|
+
parser?: ParserType;
|
|
5
7
|
filePerType?: boolean;
|
|
6
8
|
includeExclude?: IncludeExclude;
|
|
7
9
|
serviceOverrides?: {
|
|
@@ -14,7 +16,9 @@ export declare function runV1Pipeline(inputFile: string, outputDir: string, logg
|
|
|
14
16
|
graphqlTypeRegistryGenerator?: ReturnType<typeof graphqlTypeRegistryGeneratorService>;
|
|
15
17
|
apiFamilyModuleGenerator?: ReturnType<typeof apiFamilyModuleGeneratorService>;
|
|
16
18
|
};
|
|
17
|
-
}
|
|
19
|
+
};
|
|
20
|
+
export declare function runV1Pipeline(inputFile: string, outputDir: string, logger: LoggerService, options?: PipelineOptions): Promise<void>;
|
|
21
|
+
export declare function runPipeline(inputFile: string, outputDir: string, logger: LoggerService, options?: PipelineOptions): Promise<void>;
|
|
18
22
|
/**
|
|
19
23
|
* Selects which type definition grouping method to use based
|
|
20
24
|
* on the value of the --filePerType flag
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conduit-client/tools-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "CLI for Luvio Code Generation",
|
|
5
5
|
"homepage": "https://github.com/salesforce-experience-platform-emu/luvio-next",
|
|
6
6
|
"repository": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"test": "vitest run"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@conduit-client/generator-ts": "3.
|
|
25
|
-
"@conduit-client/model": "3.
|
|
26
|
-
"@conduit-client/service-feature-flags": "3.
|
|
27
|
-
"@conduit-client/utils": "3.
|
|
24
|
+
"@conduit-client/generator-ts": "3.9.0",
|
|
25
|
+
"@conduit-client/model": "3.9.0",
|
|
26
|
+
"@conduit-client/service-feature-flags": "3.9.0",
|
|
27
|
+
"@conduit-client/utils": "3.9.0"
|
|
28
28
|
},
|
|
29
29
|
"volta": {
|
|
30
30
|
"extends": "../../../../package.json"
|