feat: improve monorepo dev experience

This commit is contained in:
2023-10-27 22:45:44 +02:00
parent f618725598
commit c6ab4ae48b
124 changed files with 2647 additions and 2857 deletions

View File

@@ -0,0 +1,27 @@
import {createGenerator, SchemaGenerator} from 'ts-json-schema-generator';
import {getValidatableTypes} from './get-validatable-types.js';
/**
* Compile the JSON schema for a path
*/
export function compileSchema(path: string, tsconfig: string): ReturnType<SchemaGenerator['createSchema']> {
const generator = createGenerator({
path,
tsconfig,
extraTags: ['elasticsearch'],
skipTypeCheck: true,
});
// @ts-expect-error private access
const program = generator.program;
const schemaNames = getValidatableTypes(program);
const fullSchema = {
$schema: 'http://json-schema.org/draft-07/schema#',
definitions: {},
};
for (const schema of schemaNames) {
Object.assign(fullSchema.definitions, generator.createSchema(schema).definitions);
}
return fullSchema;
}