UNPKG

ts-to-mongo-schema

Version:

Using the Typescript Compiler API, this program parses through Typescript, to generate a JSON Schema that conforms to MongoDB's bson format. Useful when generating large schemas, and being unable to use a javascript or typescript library like Moongoose.

35 lines (34 loc) 1.38 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateSchema = void 0; var extractProperties_1 = __importDefault(require("./extractProperties")); var initializeNewFile_1 = __importDefault(require("./utilityFuncs/initializeNewFile")); var generateSchema = function (_a) { var configPath = _a.configPath, filePath = _a.filePath, identifier = _a.identifier, resolveCustomGenerics = _a.resolveCustomGenerics, extension = _a.extension; var _b = (0, initializeNewFile_1.default)({ configPath: configPath, filePath: filePath, identifier: identifier, extension: extension }), idParent = _b.idParent, imports = _b.imports, identifiers = _b.identifiers; if (!idParent) return {}; var properties = (0, extractProperties_1.default)({ imports: imports, ids: identifiers, node: idParent, paths: { configPath: configPath, filePath: filePath, identifier: identifier, }, props: {}, resolveCustomGenerics: resolveCustomGenerics, extension: extension }); return properties; }; exports.generateSchema = generateSchema;