@atomic-ehr/codegen 0.0.1-canary.20251110140511.b3e2283 → 0.0.1-canary.20251112172458.7608c8c
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/README.md +39 -210
- package/dist/cli/index.js +28 -28
- package/dist/index.d.ts +1 -24
- package/dist/index.js +101 -126
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -883,10 +883,6 @@ declare class APIBuilder {
|
|
|
883
883
|
writeTypeTree(filename: string): this;
|
|
884
884
|
treeShake(tree: TreeShake): this;
|
|
885
885
|
writeTypeSchemas(target: string): this;
|
|
886
|
-
private writeTypeSchemasToSeparateFiles;
|
|
887
|
-
private writeTypeSchemasToSingleFile;
|
|
888
|
-
private tryWriteTypeSchema;
|
|
889
|
-
cleanup(): Promise<void>;
|
|
890
886
|
generate(): Promise<GenerationResult>;
|
|
891
887
|
/**
|
|
892
888
|
* Generate and return the results without writing to files
|
|
@@ -912,29 +908,10 @@ declare class APIBuilder {
|
|
|
912
908
|
private loadFromFiles;
|
|
913
909
|
private executeGenerators;
|
|
914
910
|
}
|
|
915
|
-
/**
|
|
916
|
-
* Create a new API builder instance
|
|
917
|
-
*/
|
|
918
|
-
declare function createAPI(options?: APIBuilderOptions): APIBuilder;
|
|
919
911
|
/**
|
|
920
912
|
* Create an API builder instance from a configuration object
|
|
921
913
|
*/
|
|
922
914
|
declare function createAPIFromConfig(config: Config): APIBuilder;
|
|
923
|
-
/**
|
|
924
|
-
* Convenience function for quick TypeScript generation from a package
|
|
925
|
-
*/
|
|
926
|
-
declare function generateTypesFromPackage(packageName: string, outputDir: string, options?: {
|
|
927
|
-
version?: string;
|
|
928
|
-
verbose?: boolean;
|
|
929
|
-
validate?: boolean;
|
|
930
|
-
}): Promise<GenerationResult>;
|
|
931
|
-
/**
|
|
932
|
-
* Convenience function for quick TypeScript generation from files
|
|
933
|
-
*/
|
|
934
|
-
declare function generateTypesFromFiles(inputFiles: string[], outputDir: string, options?: {
|
|
935
|
-
verbose?: boolean;
|
|
936
|
-
validate?: boolean;
|
|
937
|
-
}): Promise<GenerationResult>;
|
|
938
915
|
|
|
939
916
|
/**
|
|
940
917
|
* Core types and interfaces for the base generator system
|
|
@@ -2220,4 +2197,4 @@ declare class TypeScriptGenerator extends BaseGenerator<TypeScriptGeneratorOptio
|
|
|
2220
2197
|
private generateMainIndexFile;
|
|
2221
2198
|
}
|
|
2222
2199
|
|
|
2223
|
-
export { APIBuilder, type APIBuilderOptions, CONFIG_FILE_NAMES, type Config, ConfigLoader, type ConfigValidationError, type ConfigValidationResult, ConfigValidator, DEFAULT_CONFIG, type GeneratedFile, type GenerationResult, type PackageMeta as PackageInfo, type ProgressCallback$1 as ProgressCallback, type TypeSchema, TypeSchemaCache, type TypeSchemaConfig, type Field as TypeSchemaField, TypeSchemaGenerator, type Identifier as TypeSchemaIdentifier, TypeSchemaParser, TypeScriptGenerator, type TypeScriptGeneratorConfig, type TypeScriptGeneratorOptions, configLoader,
|
|
2200
|
+
export { APIBuilder, type APIBuilderOptions, CONFIG_FILE_NAMES, type Config, ConfigLoader, type ConfigValidationError, type ConfigValidationResult, ConfigValidator, DEFAULT_CONFIG, type GeneratedFile, type GenerationResult, type PackageMeta as PackageInfo, type ProgressCallback$1 as ProgressCallback, type TypeSchema, TypeSchemaCache, type TypeSchemaConfig, type Field as TypeSchemaField, TypeSchemaGenerator, type Identifier as TypeSchemaIdentifier, TypeSchemaParser, TypeScriptGenerator, type TypeScriptGeneratorConfig, type TypeScriptGeneratorOptions, configLoader, createAPIFromConfig, defineConfig, isConfig, loadConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import fs__default, { existsSync, mkdirSync } from 'fs';
|
|
3
|
-
import * as
|
|
3
|
+
import * as afs2 from 'fs/promises';
|
|
4
4
|
import { readdir, stat, unlink, readFile, writeFile, access, mkdir, rm } from 'fs/promises';
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
5
|
+
import * as Path3 from 'path';
|
|
6
|
+
import Path3__default, { join, resolve, dirname, relative } from 'path';
|
|
7
7
|
import { CanonicalManager } from '@atomic-ehr/fhir-canonical-manager';
|
|
8
8
|
import * as fhirschema from '@atomic-ehr/fhirschema';
|
|
9
9
|
import { isStructureDefinition } from '@atomic-ehr/fhirschema';
|
|
@@ -2327,13 +2327,8 @@ new CodegenLogger();
|
|
|
2327
2327
|
function createLogger(options = {}) {
|
|
2328
2328
|
return new CodegenLogger(options);
|
|
2329
2329
|
}
|
|
2330
|
-
var
|
|
2331
|
-
const
|
|
2332
|
-
const packageJSON = JSON.parse(await afs3.readFile(packageJSONFileName, "utf8"));
|
|
2333
|
-
return packageJSON;
|
|
2334
|
-
};
|
|
2335
|
-
var readPackageDependencies = async (workDir, packageMeta) => {
|
|
2336
|
-
const packageJSON = await readPackageJSON(workDir, packageMeta);
|
|
2330
|
+
var readPackageDependencies = async (manager, packageMeta) => {
|
|
2331
|
+
const packageJSON = await manager.packageJson(packageMeta.name);
|
|
2337
2332
|
const dependencies = packageJSON.dependencies;
|
|
2338
2333
|
if (dependencies !== void 0) {
|
|
2339
2334
|
return Object.entries(dependencies).map(([name, version]) => {
|
|
@@ -2363,7 +2358,7 @@ var mkPackageAwareResolver = async (manager, pkg, deep, acc, logger) => {
|
|
|
2363
2358
|
if (index.canonicalResolution[url]) logger?.dry_warn(`Duplicate canonical URL: ${url} at ${pkgId}.`);
|
|
2364
2359
|
index.canonicalResolution[url] = [{ deep, pkg, pkgId, resource }];
|
|
2365
2360
|
}
|
|
2366
|
-
const deps = await readPackageDependencies(
|
|
2361
|
+
const deps = await readPackageDependencies(manager, pkg);
|
|
2367
2362
|
for (const depPkg of deps) {
|
|
2368
2363
|
const { canonicalResolution } = await mkPackageAwareResolver(manager, depPkg, deep + 1, acc, logger);
|
|
2369
2364
|
for (const [surl, resolutions] of Object.entries(canonicalResolution)) {
|
|
@@ -3042,7 +3037,7 @@ var FileSystemWriter = class {
|
|
|
3042
3037
|
}
|
|
3043
3038
|
cd(path, gen) {
|
|
3044
3039
|
const prev = this.currentDir;
|
|
3045
|
-
this.currentDir = path.startsWith("/") ?
|
|
3040
|
+
this.currentDir = path.startsWith("/") ? Path3.join(this.opts.outputDir, path) : Path3.join(this.currentDir, path);
|
|
3046
3041
|
if (!fs.existsSync(this.currentDir)) {
|
|
3047
3042
|
fs.mkdirSync(this.currentDir, { recursive: true });
|
|
3048
3043
|
}
|
|
@@ -3467,12 +3462,12 @@ var CSharp = class extends Writer {
|
|
|
3467
3462
|
}
|
|
3468
3463
|
copyStaticFiles() {
|
|
3469
3464
|
if (!this.staticSourceDir) return;
|
|
3470
|
-
const sourcePath =
|
|
3465
|
+
const sourcePath = Path3__default.resolve(this.staticSourceDir);
|
|
3471
3466
|
fs__default.cpSync(sourcePath, this.opts.outputDir, { recursive: true });
|
|
3472
3467
|
}
|
|
3473
3468
|
generateHelperFile() {
|
|
3474
3469
|
const sourceFile = "src/api/writer-generator/csharp/Helper.cs";
|
|
3475
|
-
const destFile =
|
|
3470
|
+
const destFile = Path3__default.join(this.opts.outputDir, "Helper.cs");
|
|
3476
3471
|
fs__default.copyFileSync(sourceFile, destFile);
|
|
3477
3472
|
}
|
|
3478
3473
|
};
|
|
@@ -3691,7 +3686,7 @@ var mkTypeSchemaIndex = (schemas, logger) => {
|
|
|
3691
3686
|
}
|
|
3692
3687
|
}
|
|
3693
3688
|
const raw = filename.endsWith(".yaml") ? YAML.stringify(tree) : JSON.stringify(tree, void 0, 2);
|
|
3694
|
-
await
|
|
3689
|
+
await afs2.writeFile(filename, raw);
|
|
3695
3690
|
};
|
|
3696
3691
|
return {
|
|
3697
3692
|
_schemaIndex: index,
|
|
@@ -6132,7 +6127,7 @@ var writerToGenerator = (writerGen) => {
|
|
|
6132
6127
|
const getGeneratedFiles = () => {
|
|
6133
6128
|
return writerGen.writtenFiles().map((fn) => {
|
|
6134
6129
|
return {
|
|
6135
|
-
path:
|
|
6130
|
+
path: Path3.normalize(Path3.join(writerGen.opts.outputDir, fn)),
|
|
6136
6131
|
filename: fn.replace(/^.*[\\/]/, ""),
|
|
6137
6132
|
content: "",
|
|
6138
6133
|
exports: [],
|
|
@@ -6155,6 +6150,86 @@ var normalizeFileName = (str) => {
|
|
|
6155
6150
|
if (res.length === 0) return "unknown";
|
|
6156
6151
|
return res;
|
|
6157
6152
|
};
|
|
6153
|
+
var cleanup = async (opts, logger) => {
|
|
6154
|
+
logger.info(`Cleaning outputs...`);
|
|
6155
|
+
try {
|
|
6156
|
+
logger.info(`Clean ${opts.outputDir}`);
|
|
6157
|
+
fs.rmSync(opts.outputDir, { recursive: true, force: true });
|
|
6158
|
+
if (opts.typeSchemaOutputDir) {
|
|
6159
|
+
logger.info(`Clean ${opts.typeSchemaOutputDir}`);
|
|
6160
|
+
fs.rmSync(opts.typeSchemaOutputDir, {
|
|
6161
|
+
recursive: true,
|
|
6162
|
+
force: true
|
|
6163
|
+
});
|
|
6164
|
+
}
|
|
6165
|
+
if (opts.exportTypeTree) {
|
|
6166
|
+
logger.info(`Clean ${opts.exportTypeTree}`);
|
|
6167
|
+
fs.rmSync(opts.exportTypeTree, {
|
|
6168
|
+
recursive: true,
|
|
6169
|
+
force: true
|
|
6170
|
+
});
|
|
6171
|
+
}
|
|
6172
|
+
} catch (error) {
|
|
6173
|
+
logger.warn(`Error cleaning output directory: ${error instanceof Error ? error.message : String(error)}`);
|
|
6174
|
+
}
|
|
6175
|
+
};
|
|
6176
|
+
var writeTypeSchemasToSeparateFiles = async (typeSchemas, outputDir, logger) => {
|
|
6177
|
+
await afs2.mkdir(outputDir, { recursive: true });
|
|
6178
|
+
logger.info(`Writing TypeSchema files to ${outputDir}/...`);
|
|
6179
|
+
const files = {};
|
|
6180
|
+
for (const ts of typeSchemas) {
|
|
6181
|
+
const pkg = {
|
|
6182
|
+
name: ts.identifier.package,
|
|
6183
|
+
version: ts.identifier.version
|
|
6184
|
+
};
|
|
6185
|
+
const pkgPath = normalizeFileName(packageMetaToFhir(pkg));
|
|
6186
|
+
const name = normalizeFileName(`${ts.identifier.name}(${extractNameFromCanonical(ts.identifier.url)})`);
|
|
6187
|
+
const json = JSON.stringify(ts, null, 2);
|
|
6188
|
+
const baseName = Path3.join(outputDir, pkgPath, name);
|
|
6189
|
+
if (!files[baseName]) files[baseName] = [];
|
|
6190
|
+
if (!files[baseName]?.some((e) => e === json)) {
|
|
6191
|
+
files[baseName].push(json);
|
|
6192
|
+
}
|
|
6193
|
+
}
|
|
6194
|
+
for (const [baseName, jsons] of Object.entries(files)) {
|
|
6195
|
+
await Promise.all(
|
|
6196
|
+
jsons.map(async (json, index) => {
|
|
6197
|
+
let fullName;
|
|
6198
|
+
if (index === 0) {
|
|
6199
|
+
fullName = `${baseName}.typeschema.json`;
|
|
6200
|
+
} else {
|
|
6201
|
+
fullName = `${baseName}-${index}.typeschema.json`;
|
|
6202
|
+
}
|
|
6203
|
+
await afs2.mkdir(Path3.dirname(fullName), { recursive: true });
|
|
6204
|
+
await afs2.writeFile(fullName, json);
|
|
6205
|
+
})
|
|
6206
|
+
);
|
|
6207
|
+
}
|
|
6208
|
+
};
|
|
6209
|
+
var writeTypeSchemasToSingleFile = async (typeSchemas, outputFile, logger) => {
|
|
6210
|
+
logger.info(`Writing TypeSchema files to: ${outputFile}`);
|
|
6211
|
+
await afs2.mkdir(Path3.dirname(outputFile), { recursive: true });
|
|
6212
|
+
logger.info(`Writing TypeSchemas to one file ${outputFile}...`);
|
|
6213
|
+
for (const ts of typeSchemas) {
|
|
6214
|
+
const json = JSON.stringify(ts, null, 2);
|
|
6215
|
+
await afs2.appendFile(outputFile, `${json}
|
|
6216
|
+
`);
|
|
6217
|
+
}
|
|
6218
|
+
};
|
|
6219
|
+
var tryWriteTypeSchema = async (typeSchemas, opts, logger) => {
|
|
6220
|
+
if (!opts.typeSchemaOutputDir) return;
|
|
6221
|
+
try {
|
|
6222
|
+
if (Path3.extname(opts.typeSchemaOutputDir) === ".ndjson") {
|
|
6223
|
+
await writeTypeSchemasToSingleFile(typeSchemas, opts.typeSchemaOutputDir, logger);
|
|
6224
|
+
} else {
|
|
6225
|
+
await writeTypeSchemasToSeparateFiles(typeSchemas, opts.typeSchemaOutputDir, logger);
|
|
6226
|
+
}
|
|
6227
|
+
logger.info(`Writing TypeSchema - DONE`);
|
|
6228
|
+
} catch (error) {
|
|
6229
|
+
logger.error("Failed to write TypeSchema output", error instanceof Error ? error : new Error(String(error)));
|
|
6230
|
+
if (opts.throwException) throw error;
|
|
6231
|
+
}
|
|
6232
|
+
};
|
|
6158
6233
|
var APIBuilder = class {
|
|
6159
6234
|
schemas = [];
|
|
6160
6235
|
options;
|
|
@@ -6190,7 +6265,8 @@ var APIBuilder = class {
|
|
|
6190
6265
|
}
|
|
6191
6266
|
}
|
|
6192
6267
|
fromPackage(packageName, version) {
|
|
6193
|
-
|
|
6268
|
+
const pkg = packageMetaToNpm({ name: packageName, version: version || "latest" });
|
|
6269
|
+
this.packages.push(pkg);
|
|
6194
6270
|
return this;
|
|
6195
6271
|
}
|
|
6196
6272
|
fromFiles(...filePaths) {
|
|
@@ -6231,7 +6307,7 @@ var APIBuilder = class {
|
|
|
6231
6307
|
}
|
|
6232
6308
|
typescript(opts) {
|
|
6233
6309
|
const writerOpts = {
|
|
6234
|
-
outputDir:
|
|
6310
|
+
outputDir: Path3.join(this.options.outputDir, "/types"),
|
|
6235
6311
|
tabSize: 4,
|
|
6236
6312
|
withDebugComment: false,
|
|
6237
6313
|
commentLinePrefix: "//",
|
|
@@ -6239,14 +6315,14 @@ var APIBuilder = class {
|
|
|
6239
6315
|
};
|
|
6240
6316
|
const effectiveOpts = { logger: this.logger, ...writerOpts, ...opts };
|
|
6241
6317
|
const generator = writerToGenerator(new TypeScript(effectiveOpts));
|
|
6242
|
-
this.generators.set("
|
|
6243
|
-
this.logger.debug(`Configured
|
|
6318
|
+
this.generators.set("typescript", generator);
|
|
6319
|
+
this.logger.debug(`Configured TypeScript generator (${JSON.stringify(effectiveOpts, void 0, 2)})`);
|
|
6244
6320
|
return this;
|
|
6245
6321
|
}
|
|
6246
6322
|
csharp(namespace, staticSourceDir) {
|
|
6247
6323
|
const generator = writerToGenerator(
|
|
6248
6324
|
new CSharp({
|
|
6249
|
-
outputDir:
|
|
6325
|
+
outputDir: Path3.join(this.options.outputDir, "/types"),
|
|
6250
6326
|
staticSourceDir: staticSourceDir ?? void 0,
|
|
6251
6327
|
targetNamespace: namespace,
|
|
6252
6328
|
logger: new CodegenLogger({
|
|
@@ -6306,92 +6382,6 @@ var APIBuilder = class {
|
|
|
6306
6382
|
this.options.typeSchemaOutputDir = target;
|
|
6307
6383
|
return this;
|
|
6308
6384
|
}
|
|
6309
|
-
async writeTypeSchemasToSeparateFiles(typeSchemas, outputDir) {
|
|
6310
|
-
await afs3.mkdir(outputDir, { recursive: true });
|
|
6311
|
-
this.logger.info(`Writing TypeSchema files to ${outputDir}/...`);
|
|
6312
|
-
const files = {};
|
|
6313
|
-
for (const ts of typeSchemas) {
|
|
6314
|
-
const pkg = {
|
|
6315
|
-
name: ts.identifier.package,
|
|
6316
|
-
version: ts.identifier.version
|
|
6317
|
-
};
|
|
6318
|
-
const pkgPath = normalizeFileName(packageMetaToFhir(pkg));
|
|
6319
|
-
const name = normalizeFileName(`${ts.identifier.name}(${extractNameFromCanonical(ts.identifier.url)})`);
|
|
6320
|
-
const json = JSON.stringify(ts, null, 2);
|
|
6321
|
-
const baseName = Path4.join(outputDir, pkgPath, name);
|
|
6322
|
-
if (!files[baseName]) files[baseName] = [];
|
|
6323
|
-
if (!files[baseName]?.some((e) => e === json)) {
|
|
6324
|
-
files[baseName].push(json);
|
|
6325
|
-
}
|
|
6326
|
-
}
|
|
6327
|
-
for (const [baseName, jsons] of Object.entries(files)) {
|
|
6328
|
-
await Promise.all(
|
|
6329
|
-
jsons.map(async (json, index) => {
|
|
6330
|
-
let fullName;
|
|
6331
|
-
if (index === 0) {
|
|
6332
|
-
fullName = `${baseName}.typeschema.json`;
|
|
6333
|
-
} else {
|
|
6334
|
-
fullName = `${baseName}-${index}.typeschema.json`;
|
|
6335
|
-
}
|
|
6336
|
-
await afs3.mkdir(Path4.dirname(fullName), { recursive: true });
|
|
6337
|
-
await afs3.writeFile(fullName, json);
|
|
6338
|
-
})
|
|
6339
|
-
);
|
|
6340
|
-
}
|
|
6341
|
-
}
|
|
6342
|
-
async writeTypeSchemasToSingleFile(typeSchemas, outputFile) {
|
|
6343
|
-
this.logger.info(`Writing TypeSchema files to: ${outputFile}`);
|
|
6344
|
-
if (this.options.cleanOutput && fs.existsSync(outputFile)) fs.rmSync(outputFile);
|
|
6345
|
-
await afs3.mkdir(Path4.dirname(outputFile), { recursive: true });
|
|
6346
|
-
this.logger.info(`Writing TypeSchemas to one file ${outputFile}...`);
|
|
6347
|
-
for (const ts of typeSchemas) {
|
|
6348
|
-
const json = JSON.stringify(ts, null, 2);
|
|
6349
|
-
await afs3.appendFile(outputFile, `${json}
|
|
6350
|
-
`);
|
|
6351
|
-
}
|
|
6352
|
-
}
|
|
6353
|
-
async tryWriteTypeSchema(typeSchemas) {
|
|
6354
|
-
if (!this.options.typeSchemaOutputDir) return;
|
|
6355
|
-
try {
|
|
6356
|
-
if (Path4.extname(this.options.typeSchemaOutputDir) === ".ndjson") {
|
|
6357
|
-
await this.writeTypeSchemasToSingleFile(typeSchemas, this.options.typeSchemaOutputDir);
|
|
6358
|
-
} else {
|
|
6359
|
-
await this.writeTypeSchemasToSeparateFiles(typeSchemas, this.options.typeSchemaOutputDir);
|
|
6360
|
-
}
|
|
6361
|
-
this.logger.info(`Writing TypeSchema - DONE`);
|
|
6362
|
-
} catch (error) {
|
|
6363
|
-
this.logger.error(
|
|
6364
|
-
"Failed to write TypeSchema output",
|
|
6365
|
-
error instanceof Error ? error : new Error(String(error))
|
|
6366
|
-
);
|
|
6367
|
-
if (this.options.throwException) throw error;
|
|
6368
|
-
}
|
|
6369
|
-
}
|
|
6370
|
-
async cleanup() {
|
|
6371
|
-
this.logger.info(`Cleaning outputs...`);
|
|
6372
|
-
try {
|
|
6373
|
-
this.logger.info(`Clean ${this.options.outputDir}`);
|
|
6374
|
-
fs.rmSync(this.options.outputDir, { recursive: true, force: true });
|
|
6375
|
-
if (this.options.typeSchemaOutputDir) {
|
|
6376
|
-
this.logger.info(`Clean ${this.options.typeSchemaOutputDir}`);
|
|
6377
|
-
fs.rmSync(this.options.typeSchemaOutputDir, {
|
|
6378
|
-
recursive: true,
|
|
6379
|
-
force: true
|
|
6380
|
-
});
|
|
6381
|
-
}
|
|
6382
|
-
if (this.options.exportTypeTree) {
|
|
6383
|
-
this.logger.info(`Clean ${this.options.exportTypeTree}`);
|
|
6384
|
-
fs.rmSync(this.options.exportTypeTree, {
|
|
6385
|
-
recursive: true,
|
|
6386
|
-
force: true
|
|
6387
|
-
});
|
|
6388
|
-
}
|
|
6389
|
-
} catch (error) {
|
|
6390
|
-
this.logger.warn(
|
|
6391
|
-
`Error cleaning output directory: ${error instanceof Error ? error.message : String(error)}`
|
|
6392
|
-
);
|
|
6393
|
-
}
|
|
6394
|
-
}
|
|
6395
6385
|
async generate() {
|
|
6396
6386
|
const startTime = performance.now();
|
|
6397
6387
|
const result = {
|
|
@@ -6404,11 +6394,11 @@ var APIBuilder = class {
|
|
|
6404
6394
|
};
|
|
6405
6395
|
this.logger.debug(`Starting generation with ${this.generators.size} generators`);
|
|
6406
6396
|
try {
|
|
6407
|
-
if (this.options.cleanOutput) this.
|
|
6397
|
+
if (this.options.cleanOutput) cleanup(this.options, this.logger);
|
|
6408
6398
|
this.logger.info("Initialize Canonical Manager");
|
|
6409
6399
|
const manager = CanonicalManager({
|
|
6410
6400
|
packages: this.packages,
|
|
6411
|
-
workingDir: "
|
|
6401
|
+
workingDir: ".codegen-cache/canonical-manager-cache"
|
|
6412
6402
|
});
|
|
6413
6403
|
await manager.init();
|
|
6414
6404
|
const register = await registerFromManager(manager, {
|
|
@@ -6416,7 +6406,7 @@ var APIBuilder = class {
|
|
|
6416
6406
|
focusedPackages: this.packages.map(npmToPackageMeta)
|
|
6417
6407
|
});
|
|
6418
6408
|
const typeSchemas = await generateTypeSchemas(register, this.logger);
|
|
6419
|
-
await
|
|
6409
|
+
await tryWriteTypeSchema(typeSchemas, this.options, this.logger);
|
|
6420
6410
|
let tsIndex = mkTypeSchemaIndex(typeSchemas, this.logger);
|
|
6421
6411
|
if (this.options.treeShake) tsIndex = treeShake(tsIndex, this.options.treeShake, this.logger);
|
|
6422
6412
|
if (this.options.exportTypeTree) await tsIndex.exportTree(this.options.exportTypeTree);
|
|
@@ -6508,9 +6498,6 @@ var APIBuilder = class {
|
|
|
6508
6498
|
}
|
|
6509
6499
|
}
|
|
6510
6500
|
};
|
|
6511
|
-
function createAPI(options) {
|
|
6512
|
-
return new APIBuilder(options);
|
|
6513
|
-
}
|
|
6514
6501
|
function createAPIFromConfig(config) {
|
|
6515
6502
|
const builder = new APIBuilder({
|
|
6516
6503
|
outputDir: config.outputDir,
|
|
@@ -6533,18 +6520,6 @@ function createAPIFromConfig(config) {
|
|
|
6533
6520
|
}
|
|
6534
6521
|
return builder;
|
|
6535
6522
|
}
|
|
6536
|
-
async function generateTypesFromPackage(packageName, outputDir, options = {}) {
|
|
6537
|
-
return createAPI({
|
|
6538
|
-
outputDir,
|
|
6539
|
-
verbose: options.verbose
|
|
6540
|
-
}).fromPackage(packageName, options.version).typescriptDepricated().generate();
|
|
6541
|
-
}
|
|
6542
|
-
async function generateTypesFromFiles(inputFiles, outputDir, options = {}) {
|
|
6543
|
-
return createAPI({
|
|
6544
|
-
outputDir,
|
|
6545
|
-
verbose: options.verbose
|
|
6546
|
-
}).fromFiles(...inputFiles).typescriptDepricated().generate();
|
|
6547
|
-
}
|
|
6548
6523
|
var DEFAULT_CONFIG = {
|
|
6549
6524
|
outputDir: "./generated",
|
|
6550
6525
|
verbose: false,
|
|
@@ -7057,6 +7032,6 @@ function defineConfig(config) {
|
|
|
7057
7032
|
return config;
|
|
7058
7033
|
}
|
|
7059
7034
|
|
|
7060
|
-
export { APIBuilder, CONFIG_FILE_NAMES, ConfigLoader, ConfigValidator, DEFAULT_CONFIG, TypeSchemaCache, TypeSchemaGenerator, TypeSchemaParser, TypeScriptGenerator, configLoader,
|
|
7035
|
+
export { APIBuilder, CONFIG_FILE_NAMES, ConfigLoader, ConfigValidator, DEFAULT_CONFIG, TypeSchemaCache, TypeSchemaGenerator, TypeSchemaParser, TypeScriptGenerator, configLoader, createAPIFromConfig, defineConfig, isConfig, loadConfig };
|
|
7061
7036
|
//# sourceMappingURL=index.js.map
|
|
7062
7037
|
//# sourceMappingURL=index.js.map
|