@tsofist/schema-forge 1.0.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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -0
  3. package/lib/generator/schema-generator.d.ts +13 -0
  4. package/lib/generator/schema-generator.d.ts.map +1 -0
  5. package/lib/generator/schema-generator.js +39 -0
  6. package/lib/generator/schema-generator.js.map +1 -0
  7. package/lib/generator/types-generator.d.ts +13 -0
  8. package/lib/generator/types-generator.d.ts.map +1 -0
  9. package/lib/generator/types-generator.js +207 -0
  10. package/lib/generator/types-generator.js.map +1 -0
  11. package/lib/generator/types.d.ts +23 -0
  12. package/lib/generator/types.d.ts.map +1 -0
  13. package/lib/generator/types.js +18 -0
  14. package/lib/generator/types.js.map +1 -0
  15. package/lib/generator.d.ts +6 -0
  16. package/lib/generator.d.ts.map +1 -0
  17. package/lib/generator.js +96 -0
  18. package/lib/generator.js.map +1 -0
  19. package/lib/generator.spec.d.ts +2 -0
  20. package/lib/generator.spec.d.ts.map +1 -0
  21. package/lib/generator.spec.js +211 -0
  22. package/lib/generator.spec.js.map +1 -0
  23. package/lib/index.d.ts +6 -0
  24. package/lib/index.d.ts.map +1 -0
  25. package/lib/index.js +57 -0
  26. package/lib/index.js.map +1 -0
  27. package/lib/tmp/p1.d.ts +232 -0
  28. package/lib/tmp/p1.d.ts.map +1 -0
  29. package/lib/tmp/p1.js +9 -0
  30. package/lib/tmp/p1.js.map +1 -0
  31. package/lib/tsconfig.build.tsbuildinfo +1 -0
  32. package/lib/types.d.ts +103 -0
  33. package/lib/types.d.ts.map +1 -0
  34. package/lib/types.js +18 -0
  35. package/lib/types.js.map +1 -0
  36. package/lib/validator.d.ts +13 -0
  37. package/lib/validator.d.ts.map +1 -0
  38. package/lib/validator.js +86 -0
  39. package/lib/validator.js.map +1 -0
  40. package/package.json +82 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024-present, Andrew Berdnikov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # Schema Forge
2
+
3
+ This library is a set of utilities for generating JSON schemas from TypeScript types of your project, as well as for validating data according to these schemas.
4
+
5
+ ### Please note: _Instruction is under construction_
6
+ Use `./test-sources` directory and `*.spec`-files for examples.
7
+
8
+ ## Generator
9
+
10
+ You can organize your types and interfaces in such a way that it is they who generate the json-schema.
11
+ Thus, unnecessary types will not get into the result. You can also control the descriptions of types and the selectivity of interface members and individual types (be careful with these features, they can lead to the impossibility of full validation on the side that will use this data).
12
+
13
+ ### How it works?
14
+
15
+ Main idea is to create type descriptions by whose schemes in the future it will be possible to validate arbitrary data.
16
+
17
+
18
+ ## Validator
19
+
20
+ todo
@@ -0,0 +1,13 @@
1
+ import { SchemaObject } from 'ajv';
2
+ import { Config } from 'ts-json-schema-generator';
3
+ interface Options {
4
+ tsconfig: string;
5
+ sourcesDirectoryPattern: string;
6
+ sourcesTypesGeneratorConfig: Config;
7
+ outputSchemaFile: string;
8
+ definitions: string[];
9
+ schemaId?: string;
10
+ }
11
+ export declare function generateSchemaByDraftTypes(options: Options): Promise<SchemaObject>;
12
+ export {};
13
+ //# sourceMappingURL=schema-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-generator.d.ts","sourceRoot":"","sources":["../../src/generator/schema-generator.ts"],"names":[],"mappings":"AACA,OAAY,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EACH,MAAM,EAKT,MAAM,0BAA0B,CAAC;AAIlC,UAAU,OAAO;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,EAAE,MAAM,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAkCxF"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSchemaByDraftTypes = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const error_1 = require("@tsofist/stem/lib/error");
6
+ const ajv_1 = require("ajv");
7
+ const ts_json_schema_generator_1 = require("ts-json-schema-generator");
8
+ const types_1 = require("./types");
9
+ function generateSchemaByDraftTypes(options) {
10
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
+ {
12
+ const seen = new Set();
13
+ for (const name of options.definitions) {
14
+ if (seen.has(name))
15
+ (0, error_1.raise)(`Definition ${name} is duplicated`);
16
+ seen.add(name);
17
+ }
18
+ }
19
+ const generatorConfig = Object.assign(Object.assign(Object.assign({}, types_1.SG_CONFIG_DEFAULTS), { path: `${options.sourcesDirectoryPattern}/*${types_1.TMP_FILES_SUFFIX}.ts`, tsconfig: options.tsconfig }), types_1.SG_CONFIG_MANDATORY);
20
+ const generatorProgram = (0, ts_json_schema_generator_1.createProgram)(generatorConfig);
21
+ const parser = (0, ts_json_schema_generator_1.createParser)(generatorProgram, options.sourcesTypesGeneratorConfig);
22
+ const formatter = (0, ts_json_schema_generator_1.createFormatter)(options.sourcesTypesGeneratorConfig);
23
+ const generator = new ts_json_schema_generator_1.SchemaGenerator(generatorProgram, parser, formatter, generatorConfig);
24
+ const result = {
25
+ $schema: 'http://json-schema.org/draft-07/schema#',
26
+ $id: options.schemaId,
27
+ definitions: {},
28
+ };
29
+ for (const definitionName of options.definitions) {
30
+ const schema = generator.createSchema(definitionName);
31
+ Object.assign(result.definitions, schema.definitions);
32
+ }
33
+ result.definitions = Object.fromEntries(Object.entries(result.definitions || {}).sort());
34
+ void new ajv_1.default().validateSchema(result, true);
35
+ return result;
36
+ });
37
+ }
38
+ exports.generateSchemaByDraftTypes = generateSchemaByDraftTypes;
39
+ //# sourceMappingURL=schema-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-generator.js","sourceRoot":"","sources":["../../src/generator/schema-generator.ts"],"names":[],"mappings":";;;;AAAA,mDAAgD;AAChD,6BAAwC;AACxC,uEAMkC;AAElC,mCAAoF;AAWpF,SAAsB,0BAA0B,CAAC,OAAgB;;QAC7D,CAAC;YACG,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;YAC/B,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;gBACrC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;oBAAE,IAAA,aAAK,EAAC,cAAc,IAAI,gBAAgB,CAAC,CAAC;gBAC9D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;QACL,CAAC;QAED,MAAM,eAAe,iDACd,0BAAkB,KACrB,IAAI,EAAE,GAAG,OAAO,CAAC,uBAAuB,KAAK,wBAAgB,KAAK,EAClE,QAAQ,EAAE,OAAO,CAAC,QAAQ,KACvB,2BAAmB,CACzB,CAAC;QACF,MAAM,gBAAgB,GAAY,IAAA,wCAAa,EAAC,eAAe,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,IAAA,uCAAY,EAAC,gBAAgB,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;QACnF,MAAM,SAAS,GAAG,IAAA,0CAAe,EAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;QACvE,MAAM,SAAS,GAAG,IAAI,0CAAe,CAAC,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;QAE5F,MAAM,MAAM,GAAiB;YACzB,OAAO,EAAE,yCAAyC;YAClD,GAAG,EAAE,OAAO,CAAC,QAAQ;YACrB,WAAW,EAAE,EAAE;SAClB,CAAC;QACF,KAAK,MAAM,cAAc,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YAC/C,MAAM,MAAM,GAAG,SAAS,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;YACtD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAEzF,KAAK,IAAI,aAAG,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAE5C,OAAO,MAAM,CAAC;IAClB,CAAC;CAAA;AAlCD,gEAkCC"}
@@ -0,0 +1,13 @@
1
+ import { Config } from 'ts-json-schema-generator';
2
+ import { SchemaForgeBaseOptions } from './types';
3
+ interface Options extends SchemaForgeBaseOptions {
4
+ tsconfig: string;
5
+ sourcesPattern: string;
6
+ }
7
+ export declare function generateDraftTypeFiles(options: Options): Promise<{
8
+ sourcesTypesGeneratorConfig: Config;
9
+ files: string[];
10
+ definitions: string[];
11
+ }>;
12
+ export {};
13
+ //# sourceMappingURL=types-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-generator.d.ts","sourceRoot":"","sources":["../../src/generator/types-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAiB,MAAM,0BAA0B,CAAC;AAqBjE,OAAO,EACH,sBAAsB,EAIzB,MAAM,SAAS,CAAC;AAEjB,UAAU,OAAQ,SAAQ,sBAAsB;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAQD,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,OAAO;;;;GA2E5D"}
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateDraftTypeFiles = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const promises_1 = require("fs/promises");
6
+ const path_1 = require("path");
7
+ const as_bool_1 = require("@tsofist/stem/lib/as-bool");
8
+ const error_1 = require("@tsofist/stem/lib/error");
9
+ const text_builder_1 = require("@tsofist/stem/lib/string/text-builder");
10
+ const ts_json_schema_generator_1 = require("ts-json-schema-generator");
11
+ const typescript_1 = require("typescript");
12
+ const index_1 = require("../index");
13
+ const types_1 = require("../types");
14
+ const types_2 = require("./types");
15
+ function generateDraftTypeFiles(options) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ const explicitPublic = (0, as_bool_1.asBool)(options.explicitPublic, true);
18
+ const sourcesTypesGeneratorConfig = Object.assign(Object.assign(Object.assign({}, types_2.SG_CONFIG_DEFAULTS), { path: `${options.sourcesPattern}`, tsconfig: options.tsconfig }), types_2.SG_CONFIG_MANDATORY);
19
+ const files = [];
20
+ let definitions = [];
21
+ const program = (0, ts_json_schema_generator_1.createProgram)(sourcesTypesGeneratorConfig);
22
+ const fileNames = program.getRootFileNames();
23
+ for (const sourceFileName of fileNames) {
24
+ const context = {
25
+ options,
26
+ definitions,
27
+ fileContent: [],
28
+ };
29
+ const source = program.getSourceFile(sourceFileName);
30
+ if (!source)
31
+ continue;
32
+ for (const statement of source.statements) {
33
+ if (explicitPublic) {
34
+ const isPublic = (0, typescript_1.getJSDocPublicTag)(statement) != null;
35
+ if (!isPublic)
36
+ continue;
37
+ }
38
+ else {
39
+ const isPrivate = (0, typescript_1.getJSDocPrivateTag)(statement) != null;
40
+ if (isPrivate)
41
+ continue;
42
+ }
43
+ switch (statement.kind) {
44
+ case typescript_1.SyntaxKind.ImportDeclaration:
45
+ continue;
46
+ case typescript_1.SyntaxKind.TypeAliasDeclaration:
47
+ processTypeAliasDeclaration(statement, context);
48
+ break;
49
+ case typescript_1.SyntaxKind.InterfaceDeclaration:
50
+ processInterfaceDeclaration(statement, context);
51
+ break;
52
+ default:
53
+ console.error('[current statement]\n\t', statement.getText(), '\n');
54
+ (0, error_1.raise)(`Unsupported statement kind: ${statement.kind} (${typescript_1.SyntaxKind[statement.kind]}) in ${sourceFileName}`);
55
+ }
56
+ }
57
+ const outputFileName = `${(0, path_1.dirname)(sourceFileName)}/${(0, path_1.basename)(sourceFileName, (0, path_1.extname)(sourceFileName))}${types_2.TMP_FILES_SUFFIX}.ts`;
58
+ yield (0, promises_1.writeFile)(outputFileName, [source.getText(), context.fileContent.join('\n')].join('\n'), { encoding: 'utf8' });
59
+ files.push(outputFileName);
60
+ }
61
+ if (options.definitionsFilter) {
62
+ definitions = definitions.filter(options.definitionsFilter);
63
+ }
64
+ definitions.sort();
65
+ return {
66
+ sourcesTypesGeneratorConfig,
67
+ files,
68
+ definitions,
69
+ };
70
+ });
71
+ }
72
+ exports.generateDraftTypeFiles = generateDraftTypeFiles;
73
+ function processTypeAliasDeclaration(statement, context) {
74
+ context.definitions.push(statement.name.getText());
75
+ }
76
+ function processInterfaceDeclaration(statement, context) {
77
+ var _a, _b;
78
+ const definitionsMetaList = [];
79
+ const interfaceName = readNodeName(statement);
80
+ const interfaceDesc = readJSDocDescription(statement, context.options.allowUseFallbackDescription);
81
+ const interfaceDeprecated = (0, typescript_1.getTextOfJSDocComment)((_a = (0, typescript_1.getJSDocDeprecatedTag)(statement)) === null || _a === void 0 ? void 0 : _a.comment);
82
+ for (const member of statement.members) {
83
+ const isPrivate = (0, typescript_1.getJSDocPrivateTag)(member) != null;
84
+ if (isPrivate)
85
+ continue;
86
+ const memberName = readNodeName(member);
87
+ const memberDescription = readJSDocDescription(member, context.options.allowUseFallbackDescription);
88
+ const deprecated = (0, typescript_1.getTextOfJSDocComment)((_b = (0, typescript_1.getJSDocDeprecatedTag)(member)) === null || _b === void 0 ? void 0 : _b.comment);
89
+ if (member.kind === typescript_1.SyntaxKind.MethodSignature) {
90
+ const method = member;
91
+ const minArgsNum = method.parameters.filter((param) => !param.questionToken).length;
92
+ const maxArgsNum = method.parameters.length;
93
+ const argsTypesText = method.parameters
94
+ .map((parameter) => {
95
+ var _a;
96
+ return (((_a = parameter.type) === null || _a === void 0 ? void 0 : _a.getText()) ||
97
+ (0, error_1.raise)(`No type specified for ${method.name.getText()}`));
98
+ })
99
+ .join(',');
100
+ const resultTypeName = readMemberType(method);
101
+ const definitionNameArgs = (0, index_1.buildInterfaceSchemaSignature)(interfaceName, memberName, types_1.SchemaForgeSignatureSuffix.MethodArguments);
102
+ const definitionNameResult = (0, index_1.buildInterfaceSchemaSignature)(interfaceName, memberName, types_1.SchemaForgeSignatureSuffix.MethodResult);
103
+ const comment = `Method:${interfaceName}#${memberName}`;
104
+ definitionsMetaList.push({
105
+ name: memberName,
106
+ description: memberDescription,
107
+ deprecated,
108
+ desc: [definitionNameArgs, definitionNameResult],
109
+ });
110
+ context.definitions.push(definitionNameArgs, definitionNameResult);
111
+ context.fileContent.push(...[
112
+ // ARGUMENTS
113
+ `/**`,
114
+ ` * @description Arguments for ${comment}`,
115
+ ` * @comment ${comment}`,
116
+ ` *`,
117
+ minArgsNum > 0 ? ` * @minItems ${minArgsNum}` : ``,
118
+ ` * @maxItems ${maxArgsNum}`,
119
+ `*/`,
120
+ `export type ${definitionNameArgs} = [${argsTypesText}];`,
121
+ ` `,
122
+ // RESULT
123
+ `/**`,
124
+ ` * @description Result type for ${comment}`,
125
+ ` * @comment ${comment}`,
126
+ `*/`,
127
+ `export type ${definitionNameResult} = ${resultTypeName};`,
128
+ ` `,
129
+ ].filter((line) => line.length));
130
+ }
131
+ else {
132
+ definitionsMetaList.push({
133
+ name: memberName,
134
+ description: memberDescription,
135
+ deprecated,
136
+ desc: readMemberType(member),
137
+ });
138
+ }
139
+ }
140
+ if (definitionsMetaList.length) {
141
+ const membersText = new text_builder_1.TextBuilder();
142
+ for (const member of definitionsMetaList) {
143
+ const isMethod = Array.isArray(member.desc);
144
+ membersText.push([
145
+ `/**`,
146
+ member.description && ` * @description ${member.description}`,
147
+ member.deprecated && ` * @deprecated ${member.deprecated}`,
148
+ ` * @comment ${isMethod ? 'Method' : 'Property'}:${interfaceName}#${member.name}`,
149
+ ` */`,
150
+ isMethod
151
+ ? `${member.name}: [${member.desc[0]}, ${member.desc[1]}]`
152
+ : `${member.name}: ${member.desc}`,
153
+ ], 2);
154
+ }
155
+ const interfaceText = new text_builder_1.TextBuilder([
156
+ `/**`,
157
+ interfaceDesc && ` * @description ${interfaceDesc}`,
158
+ interfaceDeprecated && ` * @deprecated ${interfaceDeprecated}`,
159
+ ` * @comment Interface:${interfaceName}`,
160
+ ` */`,
161
+ `export interface ${(0, index_1.buildInterfaceSchemaSignature)(interfaceName)} {`,
162
+ membersText.stringify('\n'),
163
+ `}`,
164
+ ]);
165
+ context.definitions.push((0, index_1.buildInterfaceSchemaSignature)(interfaceName));
166
+ context.fileContent.push(interfaceText.stringify('\n'));
167
+ }
168
+ }
169
+ function readMemberType(member) {
170
+ var _a, _b;
171
+ if (((_a = member.type) === null || _a === void 0 ? void 0 : _a.kind) === typescript_1.SyntaxKind.TypeReference) {
172
+ const type = member.type;
173
+ if (type.typeName.getText() !== 'Promise') {
174
+ return type.getText();
175
+ }
176
+ else if (type.typeArguments) {
177
+ return type.typeArguments[0].getText();
178
+ }
179
+ return 'unknown';
180
+ }
181
+ return (_b = member.type) === null || _b === void 0 ? void 0 : _b.getText();
182
+ }
183
+ function readJSDocDescription(node, useFallbackDescription = false) {
184
+ let value = undefined;
185
+ let fallback = undefined;
186
+ const isTag = (tag) => {
187
+ if (tag.kind === typescript_1.SyntaxKind.JSDocTag && tag.tagName.escapedText === 'description') {
188
+ value = (0, typescript_1.getTextOfJSDocComment)(tag.comment);
189
+ }
190
+ if (useFallbackDescription &&
191
+ fallback === undefined &&
192
+ tag.parent.kind === typescript_1.SyntaxKind.JSDoc &&
193
+ tag.parent.comment) {
194
+ fallback = (0, typescript_1.getTextOfJSDocComment)(tag.parent.comment);
195
+ }
196
+ return false;
197
+ };
198
+ (0, typescript_1.getAllJSDocTags)(node, isTag);
199
+ if (value === undefined && useFallbackDescription && fallback !== undefined) {
200
+ value = fallback;
201
+ }
202
+ return value;
203
+ }
204
+ function readNodeName(node) {
205
+ return node.name.escapedText + '';
206
+ }
207
+ //# sourceMappingURL=types-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-generator.js","sourceRoot":"","sources":["../../src/generator/types-generator.ts"],"names":[],"mappings":";;;;AAAA,0CAAwC;AACxC,+BAAkD;AAClD,uDAAmD;AACnD,mDAAgD;AAChD,wEAAoE;AACpE,uEAAiE;AACjE,2CAiBoB;AACpB,oCAAyD;AACzD,oCAAsD;AACtD,mCAKiB;AAajB,SAAsB,sBAAsB,CAAC,OAAgB;;QACzD,MAAM,cAAc,GAAG,IAAA,gBAAM,EAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QAC5D,MAAM,2BAA2B,iDAC1B,0BAAkB,KACrB,IAAI,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,EACjC,QAAQ,EAAE,OAAO,CAAC,QAAQ,KACvB,2BAAmB,CACzB,CAAC;QAEF,MAAM,KAA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,KAAK,CAAC,CAAC;IAE7B,IAAI,KAAK,KAAK,SAAS,IAAI,sBAAsB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC1E,KAAK,GAAG,QAAQ,CAAC;IACrB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,YAAY,CAAC,IAAwC;IAC1D,OAAQ,IAAI,CAAC,IAAmB,CAAC,WAAW,GAAG,EAAE,CAAC;AACtD,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Config } from 'ts-json-schema-generator';
2
+ export declare const TMP_FILES_SUFFIX = ".schema-forge.temporary-generated.tmp";
3
+ export declare const SG_CONFIG_MANDATORY: Config;
4
+ export declare const SG_CONFIG_DEFAULTS: Config;
5
+ export interface SchemaForgeBaseOptions {
6
+ /**
7
+ * Generate schema definitions for public types only
8
+ * This option can help to protect leaked internal types
9
+ * @default true
10
+ */
11
+ readonly explicitPublic?: boolean;
12
+ /**
13
+ * By default, generator use description jsdoc-tag
14
+ * If this option is true, then generator will use fallback description from type comment
15
+ */
16
+ readonly allowUseFallbackDescription?: boolean;
17
+ /**
18
+ * Filter for definitions
19
+ * Important: dependencies will not be filtered
20
+ */
21
+ definitionsFilter?(name: string): boolean;
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/generator/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,eAAO,MAAM,gBAAgB,0CAA0C,CAAC;AAExE,eAAO,MAAM,mBAAmB,EAAE,MAIjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAOhC,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAE/C;;;OAGG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7C"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SG_CONFIG_DEFAULTS = exports.SG_CONFIG_MANDATORY = exports.TMP_FILES_SUFFIX = void 0;
4
+ exports.TMP_FILES_SUFFIX = '.schema-forge.temporary-generated.tmp';
5
+ exports.SG_CONFIG_MANDATORY = {
6
+ jsDoc: 'extended',
7
+ topRef: true,
8
+ skipTypeCheck: false,
9
+ };
10
+ exports.SG_CONFIG_DEFAULTS = {
11
+ sortProps: true,
12
+ additionalProperties: false,
13
+ expose: 'all',
14
+ strictTuples: true,
15
+ encodeRefs: false,
16
+ markdownDescription: false,
17
+ };
18
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/generator/types.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAG,uCAAuC,CAAC;AAE3D,QAAA,mBAAmB,GAAW;IACvC,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,IAAI;IACZ,aAAa,EAAE,KAAK;CACvB,CAAC;AAEW,QAAA,kBAAkB,GAAW;IACtC,SAAS,EAAE,IAAI;IACf,oBAAoB,EAAE,KAAK;IAC3B,MAAM,EAAE,KAAK;IACb,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,KAAK;IACjB,mBAAmB,EAAE,KAAK;CAC7B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { SchemaObject } from 'ajv';
2
+ import { SchemaForgeOptions, SchemaForgeResult } from './types';
3
+ export declare function forgeSchema(options: SchemaForgeOptions): Promise<SchemaForgeResult>;
4
+ export declare function loadJSONSchema(files: string[]): Promise<SchemaObject[]>;
5
+ export declare function loadJSONSchemaSync(files: string[]): SchemaObject[];
6
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAGnC,OAAO,EAA4B,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE1F,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsFzF;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAI7E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,CAKlE"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadJSONSchemaSync = exports.loadJSONSchema = exports.forgeSchema = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const promises_1 = require("fs/promises");
7
+ const promises_2 = require("node:fs/promises");
8
+ const error_1 = require("@tsofist/stem/lib/error");
9
+ const noop_1 = require("@tsofist/stem/lib/noop");
10
+ const random_1 = require("@tsofist/stem/lib/string/random");
11
+ const schema_generator_1 = require("./generator/schema-generator");
12
+ const types_generator_1 = require("./generator/types-generator");
13
+ function forgeSchema(options) {
14
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
+ const { schemaId, sourcesDirectoryPattern, outputSchemaFile } = options;
16
+ const sourcesPattern = `${sourcesDirectoryPattern}/${options.sourcesFilesPattern}`;
17
+ let tsconfig = options.tsconfig;
18
+ let tsconfigGenerated = false;
19
+ try {
20
+ if (options.tsconfigFrom) {
21
+ tsconfigGenerated = true;
22
+ const source = yield (0, promises_1.readFile)(options.tsconfigFrom, { encoding: 'utf8' });
23
+ const config = JSON.parse(source);
24
+ config.include = [sourcesPattern];
25
+ config.compilerOptions.noUnusedLocals = false;
26
+ tsconfig = `./tsconfig.schema-forge-generated.${(0, random_1.randomString)(5)}.tmp.json`;
27
+ yield (0, promises_1.writeFile)(tsconfig, JSON.stringify(config, null, 2), { encoding: 'utf8' });
28
+ }
29
+ if (!tsconfig)
30
+ (0, error_1.raise)('tsconfig is not specified');
31
+ const { sourcesTypesGeneratorConfig, files, definitions } = yield (0, types_generator_1.generateDraftTypeFiles)(Object.assign(Object.assign({}, options), { tsconfig,
32
+ sourcesPattern }));
33
+ const refs = definitions.map((item) => `${options.schemaId || ''}#/definitions/${item}`);
34
+ let schema;
35
+ try {
36
+ {
37
+ schema = yield (0, schema_generator_1.generateSchemaByDraftTypes)({
38
+ schemaId,
39
+ tsconfig,
40
+ definitions,
41
+ sourcesDirectoryPattern,
42
+ outputSchemaFile,
43
+ sourcesTypesGeneratorConfig,
44
+ });
45
+ const content = JSON.stringify(schema, null, 2);
46
+ yield (0, promises_1.writeFile)(options.outputSchemaFile, content, { encoding: 'utf8' });
47
+ }
48
+ if (options.outputDefinitionsFile) {
49
+ const defs = new Set(Object.keys(schema.definitions));
50
+ const map = { refs: {}, names: {}, serviceRefs: {} };
51
+ for (const name of definitions) {
52
+ const ref = `${options.schemaId || ''}#/definitions/${name}`;
53
+ map.names[name] = ref;
54
+ map.refs[ref] = name;
55
+ defs.delete(name);
56
+ }
57
+ for (const name of defs) {
58
+ map.serviceRefs[`${options.schemaId || ''}#/definitions/${name}`] = name;
59
+ }
60
+ const content = JSON.stringify(map, null, 2);
61
+ yield (0, promises_1.writeFile)(options.outputDefinitionsFile, content, {
62
+ encoding: 'utf8',
63
+ });
64
+ }
65
+ }
66
+ finally {
67
+ yield Promise.all(files.map((fileName) => (0, promises_2.unlink)(fileName).catch(noop_1.noop)));
68
+ }
69
+ return {
70
+ schema,
71
+ refs,
72
+ generatedFiles: files,
73
+ };
74
+ }
75
+ finally {
76
+ if (tsconfig && tsconfigGenerated) {
77
+ yield (0, promises_2.unlink)(tsconfig).catch(noop_1.noop);
78
+ }
79
+ }
80
+ });
81
+ }
82
+ exports.forgeSchema = forgeSchema;
83
+ function loadJSONSchema(files) {
84
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
85
+ return Promise.all(files.map((fn) => (0, promises_1.readFile)(fn, { encoding: 'utf8' }).then(JSON.parse)));
86
+ });
87
+ }
88
+ exports.loadJSONSchema = loadJSONSchema;
89
+ function loadJSONSchemaSync(files) {
90
+ return files.map((fn) => {
91
+ const content = (0, fs_1.readFileSync)(fn, { encoding: 'utf8' });
92
+ return JSON.parse(content);
93
+ });
94
+ }
95
+ exports.loadJSONSchemaSync = loadJSONSchemaSync;
96
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;AAAA,2BAAkC;AAClC,0CAAkD;AAClD,+CAA0C;AAE1C,mDAAgD;AAChD,iDAA8C;AAC9C,4DAA+D;AAE/D,mEAA0E;AAC1E,iEAAqE;AAGrE,SAAsB,WAAW,CAAC,OAA2B;;QACzD,MAAM,EAAE,QAAQ,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;QACxE,MAAM,cAAc,GAAG,GAAG,uBAAuB,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAEnF,IAAI,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAChC,IAAI,iBAAiB,GAAG,KAAK,CAAC;QAE9B,IAAI,CAAC;YACD,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;gBACvB,iBAAiB,GAAG,IAAI,CAAC;gBACzB,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC,OAAO,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAG/B,CAAC;gBAEF,MAAM,CAAC,OAAO,GAAG,CAAC,cAAc,CAAC,CAAC;gBAClC,MAAM,CAAC,eAAe,CAAC,cAAc,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L,CAAC;IACL,CAAC;CAAA;AAtFD,kCAsFC;AAED,SAAsB,cAAc,CAAC,KAAe;;QAChD,OAAO,OAAO,CAAC,GAAG,CACd,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAA,mBAAQ,EAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CACzE,CAAC;IACN,CAAC;CAAA;AAJD,wCAIC;AAED,SAAgB,kBAAkB,CAAC,KAAe;IAC9C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACpB,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiB,CAAC;IAC/C,CAAC,CAAC,CAAC;AACP,CAAC;AALD,gDAKC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generator.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.spec.d.ts","sourceRoot":"","sources":["../src/generator.spec.ts"],"names":[],"mappings":""}