1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.TypeDefinitionsGenerator = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const common_1 = require("@nestjs/common");
|
6 | const enum_definition_factory_1 = require("./factories/enum-definition.factory");
|
7 | const input_type_definition_factory_1 = require("./factories/input-type-definition.factory");
|
8 | const interface_definition_factory_1 = require("./factories/interface-definition.factory");
|
9 | const object_type_definition_factory_1 = require("./factories/object-type-definition.factory");
|
10 | const union_definition_factory_1 = require("./factories/union-definition.factory");
|
11 | const type_definitions_storage_1 = require("./storages/type-definitions.storage");
|
12 | const type_metadata_storage_1 = require("./storages/type-metadata.storage");
|
13 | let TypeDefinitionsGenerator = class TypeDefinitionsGenerator {
|
14 | constructor(typeDefinitionsStorage, enumDefinitionFactory, inputTypeDefinitionFactory, objectTypeDefinitionFactory, interfaceDefinitionFactory, unionDefinitionFactory) {
|
15 | this.typeDefinitionsStorage = typeDefinitionsStorage;
|
16 | this.enumDefinitionFactory = enumDefinitionFactory;
|
17 | this.inputTypeDefinitionFactory = inputTypeDefinitionFactory;
|
18 | this.objectTypeDefinitionFactory = objectTypeDefinitionFactory;
|
19 | this.interfaceDefinitionFactory = interfaceDefinitionFactory;
|
20 | this.unionDefinitionFactory = unionDefinitionFactory;
|
21 | }
|
22 | generate(options) {
|
23 | this.generateUnionDefs();
|
24 | this.generateEnumDefs();
|
25 | this.generateInterfaceDefs(options);
|
26 | this.generateObjectTypeDefs(options);
|
27 | this.generateInputTypeDefs(options);
|
28 | }
|
29 | generateInputTypeDefs(options) {
|
30 | const metadata = type_metadata_storage_1.TypeMetadataStorage.getInputTypesMetadata();
|
31 | const inputTypeDefs = metadata.map((metadata) => this.inputTypeDefinitionFactory.create(metadata, options));
|
32 | this.typeDefinitionsStorage.addInputTypes(inputTypeDefs);
|
33 | }
|
34 | generateObjectTypeDefs(options) {
|
35 | const metadata = type_metadata_storage_1.TypeMetadataStorage.getObjectTypesMetadata();
|
36 | const objectTypeDefs = metadata.map((metadata) => this.objectTypeDefinitionFactory.create(metadata, options));
|
37 | this.typeDefinitionsStorage.addObjectTypes(objectTypeDefs);
|
38 | }
|
39 | generateInterfaceDefs(options) {
|
40 | const metadata = type_metadata_storage_1.TypeMetadataStorage.getInterfacesMetadata();
|
41 | const interfaceDefs = metadata.map((metadata) => this.interfaceDefinitionFactory.create(metadata, options));
|
42 | this.typeDefinitionsStorage.addInterfaces(interfaceDefs);
|
43 | }
|
44 | generateEnumDefs() {
|
45 | const metadata = type_metadata_storage_1.TypeMetadataStorage.getEnumsMetadata();
|
46 | const enumDefs = metadata.map((metadata) => this.enumDefinitionFactory.create(metadata));
|
47 | this.typeDefinitionsStorage.addEnums(enumDefs);
|
48 | }
|
49 | generateUnionDefs() {
|
50 | const metadata = type_metadata_storage_1.TypeMetadataStorage.getUnionsMetadata();
|
51 | const unionDefs = metadata.map((metadata) => this.unionDefinitionFactory.create(metadata));
|
52 | this.typeDefinitionsStorage.addUnions(unionDefs);
|
53 | }
|
54 | };
|
55 | exports.TypeDefinitionsGenerator = TypeDefinitionsGenerator;
|
56 | exports.TypeDefinitionsGenerator = TypeDefinitionsGenerator = tslib_1.__decorate([
|
57 | (0, common_1.Injectable)(),
|
58 | tslib_1.__metadata("design:paramtypes", [type_definitions_storage_1.TypeDefinitionsStorage,
|
59 | enum_definition_factory_1.EnumDefinitionFactory,
|
60 | input_type_definition_factory_1.InputTypeDefinitionFactory,
|
61 | object_type_definition_factory_1.ObjectTypeDefinitionFactory,
|
62 | interface_definition_factory_1.InterfaceDefinitionFactory,
|
63 | union_definition_factory_1.UnionDefinitionFactory])
|
64 | ], TypeDefinitionsGenerator);
|