@achinet/nestjs-async 0.0.1

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 (148) hide show
  1. package/.eslintrc.js +9 -0
  2. package/.prettierrc +5 -0
  3. package/CHANGELOG.md +7 -0
  4. package/README.md +1 -0
  5. package/dist/asyncapi-document.builder.d.ts +27 -0
  6. package/dist/asyncapi-document.builder.js +110 -0
  7. package/dist/asyncapi-document.builder.js.map +1 -0
  8. package/dist/asyncapi.constants.d.ts +6 -0
  9. package/dist/asyncapi.constants.js +11 -0
  10. package/dist/asyncapi.constants.js.map +1 -0
  11. package/dist/asyncapi.module.d.ts +8 -0
  12. package/dist/asyncapi.module.js +44 -0
  13. package/dist/asyncapi.module.js.map +1 -0
  14. package/dist/binding/asyncapi.amqp.interfaces.d.ts +38 -0
  15. package/dist/binding/asyncapi.amqp.interfaces.js +3 -0
  16. package/dist/binding/asyncapi.amqp.interfaces.js.map +1 -0
  17. package/dist/binding/asyncapi.kafka.interfaces.d.ts +21 -0
  18. package/dist/binding/asyncapi.kafka.interfaces.js +3 -0
  19. package/dist/binding/asyncapi.kafka.interfaces.js.map +1 -0
  20. package/dist/binding/index.d.ts +2 -0
  21. package/dist/binding/index.js +19 -0
  22. package/dist/binding/index.js.map +1 -0
  23. package/dist/decorators/asyncapi-operation-for-meta-key.decorator.d.ts +2 -0
  24. package/dist/decorators/asyncapi-operation-for-meta-key.decorator.js +38 -0
  25. package/dist/decorators/asyncapi-operation-for-meta-key.decorator.js.map +1 -0
  26. package/dist/decorators/asyncapi-operation.decorator.d.ts +2 -0
  27. package/dist/decorators/asyncapi-operation.decorator.js +10 -0
  28. package/dist/decorators/asyncapi-operation.decorator.js.map +1 -0
  29. package/dist/decorators/asyncapi-pub.decorator.d.ts +2 -0
  30. package/dist/decorators/asyncapi-pub.decorator.js +11 -0
  31. package/dist/decorators/asyncapi-pub.decorator.js.map +1 -0
  32. package/dist/decorators/asyncapi-service.decorator.d.ts +1 -0
  33. package/dist/decorators/asyncapi-service.decorator.js +10 -0
  34. package/dist/decorators/asyncapi-service.decorator.js.map +1 -0
  35. package/dist/decorators/asyncapi-sub.decorator.d.ts +2 -0
  36. package/dist/decorators/asyncapi-sub.decorator.js +11 -0
  37. package/dist/decorators/asyncapi-sub.decorator.js.map +1 -0
  38. package/dist/decorators/index.d.ts +4 -0
  39. package/dist/decorators/index.js +21 -0
  40. package/dist/decorators/index.js.map +1 -0
  41. package/dist/explorers/asyncapi-class.explorer.d.ts +5 -0
  42. package/dist/explorers/asyncapi-class.explorer.js +31 -0
  43. package/dist/explorers/asyncapi-class.explorer.js.map +1 -0
  44. package/dist/explorers/asyncapi-operation.explorer.d.ts +17 -0
  45. package/dist/explorers/asyncapi-operation.explorer.js +26 -0
  46. package/dist/explorers/asyncapi-operation.explorer.js.map +1 -0
  47. package/dist/explorers/index.d.ts +2 -0
  48. package/dist/explorers/index.js +19 -0
  49. package/dist/explorers/index.js.map +1 -0
  50. package/dist/index.d.ts +4 -0
  51. package/dist/index.js +21 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/interface/asyncapi-common.interfaces.d.ts +126 -0
  54. package/dist/interface/asyncapi-common.interfaces.js +3 -0
  55. package/dist/interface/asyncapi-common.interfaces.js.map +1 -0
  56. package/dist/interface/asyncapi-document-options.interface.d.ts +3 -0
  57. package/dist/interface/asyncapi-document-options.interface.js +3 -0
  58. package/dist/interface/asyncapi-document-options.interface.js.map +1 -0
  59. package/dist/interface/asyncapi-message.interface.d.ts +8 -0
  60. package/dist/interface/asyncapi-message.interface.js +3 -0
  61. package/dist/interface/asyncapi-message.interface.js.map +1 -0
  62. package/dist/interface/asyncapi-operation-headers.interface.d.ts +6 -0
  63. package/dist/interface/asyncapi-operation-headers.interface.js +3 -0
  64. package/dist/interface/asyncapi-operation-headers.interface.js.map +1 -0
  65. package/dist/interface/asyncapi-operation-options-raw.interface.d.ts +21 -0
  66. package/dist/interface/asyncapi-operation-options-raw.interface.js +3 -0
  67. package/dist/interface/asyncapi-operation-options-raw.interface.js.map +1 -0
  68. package/dist/interface/asyncapi-operation-options.interface.d.ts +8 -0
  69. package/dist/interface/asyncapi-operation-options.interface.js +3 -0
  70. package/dist/interface/asyncapi-operation-options.interface.js.map +1 -0
  71. package/dist/interface/asyncapi-operation-payload.interface.d.ts +2 -0
  72. package/dist/interface/asyncapi-operation-payload.interface.js +3 -0
  73. package/dist/interface/asyncapi-operation-payload.interface.js.map +1 -0
  74. package/dist/interface/asyncapi-server.interface.d.ts +10 -0
  75. package/dist/interface/asyncapi-server.interface.js +3 -0
  76. package/dist/interface/asyncapi-server.interface.js.map +1 -0
  77. package/dist/interface/asyncapi-template-options.interface.d.ts +7 -0
  78. package/dist/interface/asyncapi-template-options.interface.js +3 -0
  79. package/dist/interface/asyncapi-template-options.interface.js.map +1 -0
  80. package/dist/interface/denormalized-doc-resolvers.interface.d.ts +6 -0
  81. package/dist/interface/denormalized-doc-resolvers.interface.js +3 -0
  82. package/dist/interface/denormalized-doc-resolvers.interface.js.map +1 -0
  83. package/dist/interface/denormalized-doc.interface.d.ts +10 -0
  84. package/dist/interface/denormalized-doc.interface.js +3 -0
  85. package/dist/interface/denormalized-doc.interface.js.map +1 -0
  86. package/dist/interface/generator-options.interface.d.ts +22 -0
  87. package/dist/interface/generator-options.interface.js +3 -0
  88. package/dist/interface/generator-options.interface.js.map +1 -0
  89. package/dist/interface/index.d.ts +11 -0
  90. package/dist/interface/index.js +28 -0
  91. package/dist/interface/index.js.map +1 -0
  92. package/dist/services/asyncapi.explorer.d.ts +12 -0
  93. package/dist/services/asyncapi.explorer.js +72 -0
  94. package/dist/services/asyncapi.explorer.js.map +1 -0
  95. package/dist/services/asyncapi.generator.d.ts +7 -0
  96. package/dist/services/asyncapi.generator.js +27 -0
  97. package/dist/services/asyncapi.generator.js.map +1 -0
  98. package/dist/services/asyncapi.scanner.d.ts +14 -0
  99. package/dist/services/asyncapi.scanner.js +82 -0
  100. package/dist/services/asyncapi.scanner.js.map +1 -0
  101. package/dist/services/asyncapi.transformer.d.ts +4 -0
  102. package/dist/services/asyncapi.transformer.js +33 -0
  103. package/dist/services/asyncapi.transformer.js.map +1 -0
  104. package/dist/services/index.d.ts +5 -0
  105. package/dist/services/index.js +22 -0
  106. package/dist/services/index.js.map +1 -0
  107. package/dist/services/operation-object.factory.d.ts +9 -0
  108. package/dist/services/operation-object.factory.js +37 -0
  109. package/dist/services/operation-object.factory.js.map +1 -0
  110. package/dist/tsconfig.tsbuildinfo +1 -0
  111. package/package.json +94 -0
  112. package/src/asyncapi-document.builder.ts +186 -0
  113. package/src/asyncapi.constants.ts +8 -0
  114. package/src/asyncapi.module.ts +76 -0
  115. package/src/binding/asyncapi.amqp.interfaces.ts +48 -0
  116. package/src/binding/asyncapi.kafka.interfaces.ts +35 -0
  117. package/src/binding/index.ts +2 -0
  118. package/src/decorators/asyncapi-operation-for-meta-key.decorator.ts +70 -0
  119. package/src/decorators/asyncapi-operation.decorator.ts +9 -0
  120. package/src/decorators/asyncapi-pub.decorator.ts +18 -0
  121. package/src/decorators/asyncapi-service.decorator.ts +9 -0
  122. package/src/decorators/asyncapi-sub.decorator.ts +18 -0
  123. package/src/decorators/index.ts +4 -0
  124. package/src/explorers/asyncapi-class.explorer.ts +30 -0
  125. package/src/explorers/asyncapi-operation.explorer.ts +49 -0
  126. package/src/explorers/index.ts +2 -0
  127. package/src/index.ts +4 -0
  128. package/src/interface/asyncapi-common.interfaces.ts +172 -0
  129. package/src/interface/asyncapi-document-options.interface.ts +3 -0
  130. package/src/interface/asyncapi-message.interface.ts +10 -0
  131. package/src/interface/asyncapi-operation-headers.interface.ts +6 -0
  132. package/src/interface/asyncapi-operation-options-raw.interface.ts +23 -0
  133. package/src/interface/asyncapi-operation-options.interface.ts +12 -0
  134. package/src/interface/asyncapi-operation-payload.interface.ts +7 -0
  135. package/src/interface/asyncapi-server.interface.ts +14 -0
  136. package/src/interface/asyncapi-template-options.interface.ts +20 -0
  137. package/src/interface/denormalized-doc-resolvers.interface.ts +6 -0
  138. package/src/interface/denormalized-doc.interface.ts +10 -0
  139. package/src/interface/generator-options.interface.ts +21 -0
  140. package/src/interface/index.ts +12 -0
  141. package/src/services/asyncapi.explorer.ts +121 -0
  142. package/src/services/asyncapi.generator.ts +33 -0
  143. package/src/services/asyncapi.scanner.ts +155 -0
  144. package/src/services/asyncapi.transformer.ts +39 -0
  145. package/src/services/index.ts +5 -0
  146. package/src/services/operation-object.factory.ts +56 -0
  147. package/tsconfig.build.json +4 -0
  148. package/tsconfig.json +8 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncapiScanner = void 0;
4
+ const constants_1 = require("@nestjs/common/constants");
5
+ const model_properties_accessor_1 = require("@nestjs/swagger/dist/services/model-properties-accessor");
6
+ const schema_object_factory_1 = require("@nestjs/swagger/dist/services/schema-object-factory");
7
+ const swagger_types_mapper_1 = require("@nestjs/swagger/dist/services/swagger-types-mapper");
8
+ const strip_last_slash_util_1 = require("@nestjs/swagger/dist/utils/strip-last-slash.util");
9
+ const lodash_1 = require("lodash");
10
+ const asyncapi_explorer_1 = require("./asyncapi.explorer");
11
+ const asyncapi_transformer_1 = require("./asyncapi.transformer");
12
+ class AsyncapiScanner {
13
+ constructor() {
14
+ this.transformer = new asyncapi_transformer_1.AsyncapiTransformer();
15
+ this.explorer = new asyncapi_explorer_1.AsyncApiExplorer();
16
+ this.modelPropertiesAccessor = new model_properties_accessor_1.ModelPropertiesAccessor();
17
+ this.swaggerTypesMapper = new swagger_types_mapper_1.SwaggerTypesMapper();
18
+ this.schemaObjectFactory = new schema_object_factory_1.SchemaObjectFactory(this.modelPropertiesAccessor, this.swaggerTypesMapper);
19
+ }
20
+ scanApplication(app, options) {
21
+ const { deepScanRoutes, include: includedModules = [], extraModels = [], ignoreGlobalPrefix = false, operationIdFactory, } = options;
22
+ const container = app.container;
23
+ const modules = this.getModules(container.getModules(), includedModules);
24
+ const globalPrefix = !ignoreGlobalPrefix
25
+ ? (0, strip_last_slash_util_1.stripLastSlash)(this.getGlobalPrefix(app))
26
+ : '';
27
+ const denormalizedChannels = modules.reduce((channels, { providers, metatype, imports, controllers }) => {
28
+ let allProviders = new Map([...providers, ...controllers]);
29
+ if (deepScanRoutes) {
30
+ const isGlobal = (module) => !container.isGlobalModule(module);
31
+ Array.from(imports.values())
32
+ .filter(isGlobal)
33
+ .map(({ providers: relatedProviders, controllers: relatedControllers, }) => ({
34
+ relatedProviders,
35
+ relatedControllers,
36
+ }))
37
+ .forEach(({ relatedProviders, relatedControllers }) => {
38
+ allProviders = new Map([
39
+ ...allProviders,
40
+ ...relatedProviders,
41
+ ...relatedControllers,
42
+ ]);
43
+ });
44
+ }
45
+ const path = metatype
46
+ ? Reflect.getMetadata(constants_1.MODULE_PATH, metatype)
47
+ : undefined;
48
+ return [
49
+ ...channels,
50
+ ...this.scanModuleProviders(allProviders, path, globalPrefix, operationIdFactory),
51
+ ];
52
+ }, []);
53
+ const schemas = this.explorer.getSchemas();
54
+ this.addExtraModels(schemas, extraModels);
55
+ const normalizedChannels = this.transformer.normalizeChannels((0, lodash_1.flatten)(denormalizedChannels));
56
+ return Object.assign(Object.assign({}, normalizedChannels), { components: { schemas } });
57
+ }
58
+ scanModuleProviders(providers, modulePath, globalPrefix, operationIdFactory) {
59
+ const denormalizedArray = [...providers.values()].reduce((denormalized, prov) => {
60
+ const object = this.explorer.explorerAsyncapiServices(prov, modulePath, globalPrefix, operationIdFactory);
61
+ return [...denormalized, ...object];
62
+ }, []);
63
+ return (0, lodash_1.flatten)(denormalizedArray);
64
+ }
65
+ getModules(modulesContainer, include) {
66
+ if (!include || (0, lodash_1.isEmpty)(include)) {
67
+ return [...modulesContainer.values()];
68
+ }
69
+ return [...modulesContainer.values()].filter(({ metatype }) => include.some((item) => item === metatype));
70
+ }
71
+ getGlobalPrefix(app) {
72
+ const internalConfigRef = app.config;
73
+ return (internalConfigRef === null || internalConfigRef === void 0 ? void 0 : internalConfigRef.getGlobalPrefix()) || '';
74
+ }
75
+ addExtraModels(schemas, extraModels) {
76
+ extraModels.forEach((item) => {
77
+ this.schemaObjectFactory.exploreModelSchema(item, schemas);
78
+ });
79
+ }
80
+ }
81
+ exports.AsyncapiScanner = AsyncapiScanner;
82
+ //# sourceMappingURL=asyncapi.scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi.scanner.js","sourceRoot":"","sources":["../../src/services/asyncapi.scanner.ts"],"names":[],"mappings":";;;AACA,wDAAuD;AAMvD,uGAAkG;AAClG,+FAA0F;AAC1F,6FAAwF;AACxF,4FAAkF;AAClF,mCAA0C;AAM1C,2DAAuD;AACvD,iEAA6D;AAE7D,MAAa,eAAe;IAA5B;QACmB,gBAAW,GAAG,IAAI,0CAAmB,EAAE,CAAC;QACxC,aAAQ,GAAG,IAAI,oCAAgB,EAAE,CAAC;QAClC,4BAAuB,GAAG,IAAI,mDAAuB,EAAE,CAAC;QACxD,uBAAkB,GAAG,IAAI,yCAAkB,EAAE,CAAC;QAC9C,wBAAmB,GAAG,IAAI,2CAAmB,CAC5D,IAAI,CAAC,uBAAuB,EAC5B,IAAI,CAAC,kBAAkB,CACxB,CAAC;IA8HJ,CAAC;IA5HQ,eAAe,CACpB,GAA4B,EAC5B,OAAgC;QAEhC,MAAM,EACJ,cAAc,EACd,OAAO,EAAE,eAAe,GAAG,EAAE,EAC7B,WAAW,GAAG,EAAE,EAChB,kBAAkB,GAAG,KAAK,EAC1B,kBAAkB,GACnB,GAAG,OAAO,CAAC;QAEZ,MAAM,SAAS,GAAmB,GAAW,CAAC,SAAS,CAAC;QACxD,MAAM,OAAO,GAAa,IAAI,CAAC,UAAU,CACvC,SAAS,CAAC,UAAU,EAAE,EACtB,eAAe,CAChB,CAAC;QACF,MAAM,YAAY,GAAG,CAAC,kBAAkB;YACtC,CAAC,CAAC,IAAA,sCAAc,EAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAA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,CAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,eAAe,EAAE,KAAI,EAAE,CAAC;IACpD,CAAC;IAEO,cAAc,CACpB,OAAqC,EACrC,WAAuB;QAEvB,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAtID,0CAsIC"}
@@ -0,0 +1,4 @@
1
+ import { AsyncChannelsObject, DenormalizedDoc } from '../interface';
2
+ export declare class AsyncapiTransformer {
3
+ normalizeChannels(denormalizedDocs: DenormalizedDoc[]): Record<'channels', AsyncChannelsObject>;
4
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncapiTransformer = void 0;
4
+ class AsyncapiTransformer {
5
+ normalizeChannels(denormalizedDocs) {
6
+ const flatChannels = denormalizedDocs.map((doc) => {
7
+ var _a, _b, _c, _d, _e, _f;
8
+ const key = (_a = doc.root) === null || _a === void 0 ? void 0 : _a.name;
9
+ const value = {
10
+ description: (_b = doc.root) === null || _b === void 0 ? void 0 : _b.description,
11
+ bindings: (_c = doc.root) === null || _c === void 0 ? void 0 : _c.bindings,
12
+ parameters: (_d = doc.root) === null || _d === void 0 ? void 0 : _d.parameters,
13
+ subscribe: (_e = doc.operations) === null || _e === void 0 ? void 0 : _e.sub,
14
+ publish: (_f = doc.operations) === null || _f === void 0 ? void 0 : _f.pub,
15
+ };
16
+ return { key, value };
17
+ });
18
+ const channels = flatChannels.reduce((acc, { key, value }) => {
19
+ var _a, _b;
20
+ if (!key)
21
+ return acc;
22
+ if (!acc[key]) {
23
+ acc[key] = value;
24
+ }
25
+ acc[key].publish = (_a = acc[key].publish) !== null && _a !== void 0 ? _a : value.publish;
26
+ acc[key].subscribe = (_b = acc[key].subscribe) !== null && _b !== void 0 ? _b : value.subscribe;
27
+ return acc;
28
+ }, {});
29
+ return { channels };
30
+ }
31
+ }
32
+ exports.AsyncapiTransformer = AsyncapiTransformer;
33
+ //# sourceMappingURL=asyncapi.transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi.transformer.js","sourceRoot":"","sources":["../../src/services/asyncapi.transformer.ts"],"names":[],"mappings":";;;AAMA,MAAa,mBAAmB;IACvB,iBAAiB,CACtB,gBAAmC;QAEnC,MAAM,YAAY,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAoB,EAAE,EAAE;;YACjE,MAAM,GAAG,GAAG,MAAA,GAAG,CAAC,IAAI,0CAAE,IAAI,CAAC;YAC3B,MAAM,KAAK,GAAuB;gBAChC,WAAW,EAAE,MAAA,GAAG,CAAC,IAAI,0CAAE,WAAW;gBAClC,QAAQ,EAAE,MAAA,GAAG,CAAC,IAAI,0CAAE,QAAQ;gBAC5B,UAAU,EAAE,MAAA,GAAG,CAAC,IAAI,0CAAE,UAAU;gBAChC,SAAS,EAAE,MAAA,GAAG,CAAC,UAAU,0CAAE,GAAG;gBAC9B,OAAO,EAAE,MAAA,GAAG,CAAC,UAAU,0CAAE,GAAG;aAC7B,CAAC;YACF,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;;YAE3D,IAAI,CAAC,GAAG;gBAAE,OAAO,GAAG,CAAC;YAErB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACd,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACnB,CAAC;YAED,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,GAAG,MAAA,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,mCAAI,KAAK,CAAC,OAAO,CAAC;YACrD,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,GAAG,MAAA,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,mCAAI,KAAK,CAAC,SAAS,CAAC;YAE3D,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAyB,CAAC,CAAC;QAE9B,OAAO,EAAE,QAAQ,EAAE,CAAC;IACtB,CAAC;CACF;AAhCD,kDAgCC"}
@@ -0,0 +1,5 @@
1
+ export * from './asyncapi.generator';
2
+ export * from './operation-object.factory';
3
+ export * from './asyncapi.explorer';
4
+ export * from './asyncapi.scanner';
5
+ export * from './asyncapi.scanner';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./asyncapi.generator"), exports);
18
+ __exportStar(require("./operation-object.factory"), exports);
19
+ __exportStar(require("./asyncapi.explorer"), exports);
20
+ __exportStar(require("./asyncapi.scanner"), exports);
21
+ __exportStar(require("./asyncapi.scanner"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,6DAA2C;AAC3C,sDAAoC;AACpC,qDAAmC;AACnC,qDAAmC"}
@@ -0,0 +1,9 @@
1
+ import { SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
2
+ import { AsyncApiOperationOptionsRaw, AsyncOperationObject } from '../interface';
3
+ export declare class OperationObjectFactory {
4
+ private readonly modelPropertiesAccessor;
5
+ private readonly swaggerTypesMapper;
6
+ private readonly schemaObjectFactory;
7
+ create(operation: AsyncApiOperationOptionsRaw, produces: string[], schemas: Record<string, SchemaObject>): AsyncOperationObject;
8
+ private getDtoName;
9
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OperationObjectFactory = void 0;
4
+ const model_properties_accessor_1 = require("@nestjs/swagger/dist/services/model-properties-accessor");
5
+ const schema_object_factory_1 = require("@nestjs/swagger/dist/services/schema-object-factory");
6
+ const swagger_types_mapper_1 = require("@nestjs/swagger/dist/services/swagger-types-mapper");
7
+ const utils_1 = require("@nestjs/swagger/dist/utils");
8
+ class OperationObjectFactory {
9
+ constructor() {
10
+ this.modelPropertiesAccessor = new model_properties_accessor_1.ModelPropertiesAccessor();
11
+ this.swaggerTypesMapper = new swagger_types_mapper_1.SwaggerTypesMapper();
12
+ this.schemaObjectFactory = new schema_object_factory_1.SchemaObjectFactory(this.modelPropertiesAccessor, this.swaggerTypesMapper);
13
+ }
14
+ create(operation, produces, schemas) {
15
+ const { message } = operation;
16
+ const { oneOf } = message;
17
+ if (oneOf) {
18
+ return Object.assign(Object.assign({}, operation), { message: {
19
+ oneOf: oneOf.map((i) => (Object.assign(Object.assign({}, i), { payload: {
20
+ $ref: (0, utils_1.getSchemaPath)(this.getDtoName(i, schemas)),
21
+ } }))),
22
+ } });
23
+ }
24
+ return Object.assign(Object.assign({}, operation), { message: Object.assign(Object.assign({}, operation.message), { payload: {
25
+ $ref: (0, utils_1.getSchemaPath)(this.getDtoName(message, schemas)),
26
+ } }) });
27
+ }
28
+ getDtoName(message, schemas) {
29
+ if (!message.payload || !message.payload.type) {
30
+ throw new Error('Async message payload or payload.type is undefined; ensure message.payload is provided.');
31
+ }
32
+ const messagePayloadType = message.payload.type;
33
+ return this.schemaObjectFactory.exploreModelSchema(messagePayloadType, schemas);
34
+ }
35
+ }
36
+ exports.OperationObjectFactory = OperationObjectFactory;
37
+ //# sourceMappingURL=operation-object.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-object.factory.js","sourceRoot":"","sources":["../../src/services/operation-object.factory.ts"],"names":[],"mappings":";;;AACA,uGAAkG;AAClG,+FAA0F;AAC1F,6FAAwF;AACxF,sDAA2D;AAG3D,MAAa,sBAAsB;IAAnC;QACmB,4BAAuB,GAAG,IAAI,mDAAuB,EAAE,CAAC;QAExD,uBAAkB,GAAG,IAAI,yCAAkB,EAAE,CAAC;QAE9C,wBAAmB,GAAG,IAAI,2CAAmB,CAAC,IAAI,CAAC,uBAAuB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IA2CxH,CAAC;IAzCC,MAAM,CACJ,SAAsC,EACtC,QAAkB,EAClB,OAAqC;QAErC,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;QAC9B,MAAM,EAAE,KAAK,EAAE,GAAG,OAA2B,CAAC;QAE9C,IAAI,KAAK,EAAE,CAAC;YACV,uCACK,SAAS,KACZ,OAAO,EAAE;oBACP,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCACnB,CAAC,KACJ,OAAO,EAAE;4BACP,IAAI,EAAE,IAAA,qBAAa,EAAC,IAAI,CAAC,UAAU,CAAC,CAAuB,EAAE,OAAO,CAAC,CAAC;yBACvE,IACD,CAAC;iBACJ,IACD;QACJ,CAAC;QAED,uCACK,SAAS,KACZ,OAAO,kCACF,SAAS,CAAC,OAAO,KACpB,OAAO,EAAE;oBACP,IAAI,EAAE,IAAA,qBAAa,EAAC,IAAI,CAAC,UAAU,CAAC,OAA6B,EAAE,OAAO,CAAC,CAAC;iBAC7E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