pg-proto-parser
Version:
The LaunchQL Proto parser
71 lines (70 loc) • 2.23 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOptionsWithDefaults = exports.defaultPgProtoParserOptions = void 0;
const deepmerge_1 = __importDefault(require("deepmerge"));
const path_1 = require("path");
// Define default options outside of the class
exports.defaultPgProtoParserOptions = {
outDir: (0, path_1.join)(process.cwd(), 'out'),
includeHeader: true,
exclude: [],
utils: {
enums: {
enabled: false,
filename: 'utils.ts',
unidirectional: false,
toIntFilename: 'enum-to-int.ts',
toStringFilename: 'enum-to-string.ts',
outputFormat: 'switchStatements'
},
astHelpers: {
enabled: false,
typesSource: './types',
inlineNestedObj: false,
nestedObjFile: 'nested-obj.ts',
filename: 'asts.ts',
},
wrappedAstHelpers: {
enabled: false,
filename: 'wrapped-asts.ts'
}
},
types: {
enabled: false,
filename: 'types.ts',
optionalFields: true,
enumsSource: './enums',
wrappedNodeTypeExport: true
},
enums: {
enabled: false,
filename: 'enums.ts',
enumsAsTypeUnion: true,
enumMap: {
enabled: false,
format: 'ts',
toIntOutFile: 'enums2int.ts',
toStrOutFile: 'enums2str.ts'
},
removeUndefinedAt0: true
},
runtimeSchema: {
enabled: false,
filename: 'runtime-schema',
format: 'json'
},
parser: {
keepCase: false,
alternateCommentMode: true,
preferTrailingComment: false
}
};
const getOptionsWithDefaults = (options) => {
// If an element at the same key is present for both x and y in deepmerge(x,y), the value from y will appear in the result.
options = (0, deepmerge_1.default)(exports.defaultPgProtoParserOptions, options ?? {});
return options;
};
exports.getOptionsWithDefaults = getOptionsWithDefaults;