@achinet/nestjs-async 0.0.1 → 0.1.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 (248) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/decorators/asyncapi-operation-for-meta-key.decorator.js +1 -2
  3. package/dist/decorators/asyncapi-operation-for-meta-key.decorator.js.map +1 -1
  4. package/dist/decorators/asyncapi-operation.decorator.js +1 -2
  5. package/dist/decorators/asyncapi-operation.decorator.js.map +1 -1
  6. package/dist/decorators/asyncapi-pub.decorator.js +1 -2
  7. package/dist/decorators/asyncapi-pub.decorator.js.map +1 -1
  8. package/dist/decorators/asyncapi-service.decorator.js +1 -2
  9. package/dist/decorators/asyncapi-service.decorator.js.map +1 -1
  10. package/dist/decorators/asyncapi-sub.decorator.js +1 -2
  11. package/dist/decorators/asyncapi-sub.decorator.js.map +1 -1
  12. package/dist/explorers/asyncapi-operation.explorer.d.ts +8 -8
  13. package/dist/sample/app.module.d.ts +2 -0
  14. package/dist/sample/app.module.js +20 -0
  15. package/dist/sample/app.module.js.map +1 -0
  16. package/dist/sample/common.d.ts +3 -0
  17. package/dist/sample/common.js +40 -0
  18. package/dist/sample/common.js.map +1 -0
  19. package/dist/sample/constants.d.ts +12 -0
  20. package/dist/sample/constants.js +16 -0
  21. package/dist/sample/constants.js.map +1 -0
  22. package/dist/sample/felines/class/cat.class.d.ts +4 -0
  23. package/dist/sample/felines/class/cat.class.js +24 -0
  24. package/dist/sample/felines/class/cat.class.js.map +1 -0
  25. package/dist/sample/felines/class/feline.class.d.ts +19 -0
  26. package/dist/sample/felines/class/feline.class.js +20 -0
  27. package/dist/sample/felines/class/feline.class.js.map +1 -0
  28. package/dist/sample/felines/class/index.d.ts +5 -0
  29. package/dist/sample/felines/class/index.js +22 -0
  30. package/dist/sample/felines/class/index.js.map +1 -0
  31. package/dist/sample/felines/class/lion.class.d.ts +4 -0
  32. package/dist/sample/felines/class/lion.class.js +8 -0
  33. package/dist/sample/felines/class/lion.class.js.map +1 -0
  34. package/dist/sample/felines/class/message.class.d.ts +7 -0
  35. package/dist/sample/felines/class/message.class.js +28 -0
  36. package/dist/sample/felines/class/message.class.js.map +1 -0
  37. package/dist/sample/felines/class/tiger.class.d.ts +4 -0
  38. package/dist/sample/felines/class/tiger.class.js +8 -0
  39. package/dist/sample/felines/class/tiger.class.js.map +1 -0
  40. package/dist/sample/felines/dto/create-feline.dto.d.ts +4 -0
  41. package/dist/sample/felines/dto/create-feline.dto.js +28 -0
  42. package/dist/sample/felines/dto/create-feline.dto.js.map +1 -0
  43. package/dist/sample/felines/dto/index.d.ts +2 -0
  44. package/dist/sample/felines/dto/index.js +19 -0
  45. package/dist/sample/felines/dto/index.js.map +1 -0
  46. package/dist/sample/felines/dto/journaling-data.dto.d.ts +4 -0
  47. package/dist/sample/felines/dto/journaling-data.dto.js +8 -0
  48. package/dist/sample/felines/dto/journaling-data.dto.js.map +1 -0
  49. package/dist/sample/felines/felines.constants.d.ts +1 -0
  50. package/dist/sample/felines/felines.constants.js +5 -0
  51. package/dist/sample/felines/felines.constants.js.map +1 -0
  52. package/dist/sample/felines/felines.controller.d.ts +15 -0
  53. package/dist/sample/felines/felines.controller.js +101 -0
  54. package/dist/sample/felines/felines.controller.js.map +1 -0
  55. package/dist/sample/felines/felines.gateway.d.ts +16 -0
  56. package/dist/sample/felines/felines.gateway.js +90 -0
  57. package/dist/sample/felines/felines.gateway.js.map +1 -0
  58. package/dist/sample/felines/felines.module.d.ts +2 -0
  59. package/dist/sample/felines/felines.module.js +28 -0
  60. package/dist/sample/felines/felines.module.js.map +1 -0
  61. package/dist/sample/felines/felines.service.d.ts +8 -0
  62. package/dist/sample/felines/felines.service.js +33 -0
  63. package/dist/sample/felines/felines.service.js.map +1 -0
  64. package/dist/sample/felines/rto/feline.rto.d.ts +7 -0
  65. package/dist/sample/felines/rto/feline.rto.js +31 -0
  66. package/dist/sample/felines/rto/feline.rto.js.map +1 -0
  67. package/dist/sample/felines/rto/index.d.ts +1 -0
  68. package/dist/sample/felines/rto/index.js +18 -0
  69. package/dist/sample/felines/rto/index.js.map +1 -0
  70. package/dist/sample/index.d.ts +3 -0
  71. package/dist/sample/index.js +20 -0
  72. package/dist/sample/index.js.map +1 -0
  73. package/dist/sample/main.d.ts +1 -0
  74. package/dist/sample/main.js +30 -0
  75. package/dist/sample/main.js.map +1 -0
  76. package/dist/src/asyncapi-document.builder.d.ts +27 -0
  77. package/dist/src/asyncapi-document.builder.js +110 -0
  78. package/dist/src/asyncapi-document.builder.js.map +1 -0
  79. package/dist/src/asyncapi.constants.d.ts +6 -0
  80. package/dist/src/asyncapi.constants.js +11 -0
  81. package/dist/src/asyncapi.constants.js.map +1 -0
  82. package/dist/src/asyncapi.module.d.ts +8 -0
  83. package/dist/src/asyncapi.module.js +47 -0
  84. package/dist/src/asyncapi.module.js.map +1 -0
  85. package/dist/src/binding/asyncapi.amqp.interfaces.d.ts +38 -0
  86. package/dist/src/binding/asyncapi.amqp.interfaces.js +3 -0
  87. package/dist/src/binding/asyncapi.amqp.interfaces.js.map +1 -0
  88. package/dist/src/binding/asyncapi.kafka.interfaces.d.ts +21 -0
  89. package/dist/src/binding/asyncapi.kafka.interfaces.js +3 -0
  90. package/dist/src/binding/asyncapi.kafka.interfaces.js.map +1 -0
  91. package/dist/src/binding/index.d.ts +2 -0
  92. package/dist/src/binding/index.js +19 -0
  93. package/dist/src/binding/index.js.map +1 -0
  94. package/dist/src/decorators/asyncapi-operation-for-meta-key.decorator.d.ts +2 -0
  95. package/dist/src/decorators/asyncapi-operation-for-meta-key.decorator.js +37 -0
  96. package/dist/src/decorators/asyncapi-operation-for-meta-key.decorator.js.map +1 -0
  97. package/dist/src/decorators/asyncapi-operation.decorator.d.ts +2 -0
  98. package/dist/src/decorators/asyncapi-operation.decorator.js +9 -0
  99. package/dist/src/decorators/asyncapi-operation.decorator.js.map +1 -0
  100. package/dist/src/decorators/asyncapi-pub.decorator.d.ts +2 -0
  101. package/dist/src/decorators/asyncapi-pub.decorator.js +10 -0
  102. package/dist/src/decorators/asyncapi-pub.decorator.js.map +1 -0
  103. package/dist/src/decorators/asyncapi-service.decorator.d.ts +1 -0
  104. package/dist/src/decorators/asyncapi-service.decorator.js +9 -0
  105. package/dist/src/decorators/asyncapi-service.decorator.js.map +1 -0
  106. package/dist/src/decorators/asyncapi-sub.decorator.d.ts +2 -0
  107. package/dist/src/decorators/asyncapi-sub.decorator.js +10 -0
  108. package/dist/src/decorators/asyncapi-sub.decorator.js.map +1 -0
  109. package/dist/src/decorators/index.d.ts +4 -0
  110. package/dist/src/decorators/index.js +21 -0
  111. package/dist/src/decorators/index.js.map +1 -0
  112. package/dist/src/explorers/asyncapi-class.explorer.d.ts +5 -0
  113. package/dist/src/explorers/asyncapi-class.explorer.js +27 -0
  114. package/dist/src/explorers/asyncapi-class.explorer.js.map +1 -0
  115. package/dist/src/explorers/asyncapi-operation.explorer.d.ts +17 -0
  116. package/dist/src/explorers/asyncapi-operation.explorer.js +26 -0
  117. package/dist/src/explorers/asyncapi-operation.explorer.js.map +1 -0
  118. package/dist/src/explorers/index.d.ts +2 -0
  119. package/dist/src/explorers/index.js +19 -0
  120. package/dist/src/explorers/index.js.map +1 -0
  121. package/dist/src/index.d.ts +4 -0
  122. package/dist/src/index.js +21 -0
  123. package/dist/src/index.js.map +1 -0
  124. package/dist/src/interface/asyncapi-common.interfaces.d.ts +126 -0
  125. package/dist/src/interface/asyncapi-common.interfaces.js +3 -0
  126. package/dist/src/interface/asyncapi-common.interfaces.js.map +1 -0
  127. package/dist/src/interface/asyncapi-document-options.interface.d.ts +3 -0
  128. package/dist/src/interface/asyncapi-document-options.interface.js +3 -0
  129. package/dist/src/interface/asyncapi-document-options.interface.js.map +1 -0
  130. package/dist/src/interface/asyncapi-message.interface.d.ts +8 -0
  131. package/dist/src/interface/asyncapi-message.interface.js +3 -0
  132. package/dist/src/interface/asyncapi-message.interface.js.map +1 -0
  133. package/dist/src/interface/asyncapi-operation-headers.interface.d.ts +6 -0
  134. package/dist/src/interface/asyncapi-operation-headers.interface.js +3 -0
  135. package/dist/src/interface/asyncapi-operation-headers.interface.js.map +1 -0
  136. package/dist/src/interface/asyncapi-operation-options-raw.interface.d.ts +21 -0
  137. package/dist/src/interface/asyncapi-operation-options-raw.interface.js +3 -0
  138. package/dist/src/interface/asyncapi-operation-options-raw.interface.js.map +1 -0
  139. package/dist/src/interface/asyncapi-operation-options.interface.d.ts +8 -0
  140. package/dist/src/interface/asyncapi-operation-options.interface.js +3 -0
  141. package/dist/src/interface/asyncapi-operation-options.interface.js.map +1 -0
  142. package/dist/src/interface/asyncapi-operation-payload.interface.d.ts +2 -0
  143. package/dist/src/interface/asyncapi-operation-payload.interface.js +3 -0
  144. package/dist/src/interface/asyncapi-operation-payload.interface.js.map +1 -0
  145. package/dist/src/interface/asyncapi-server.interface.d.ts +10 -0
  146. package/dist/src/interface/asyncapi-server.interface.js +3 -0
  147. package/dist/src/interface/asyncapi-server.interface.js.map +1 -0
  148. package/dist/src/interface/asyncapi-template-options.interface.d.ts +7 -0
  149. package/dist/src/interface/asyncapi-template-options.interface.js +3 -0
  150. package/dist/src/interface/asyncapi-template-options.interface.js.map +1 -0
  151. package/dist/src/interface/denormalized-doc-resolvers.interface.d.ts +6 -0
  152. package/dist/src/interface/denormalized-doc-resolvers.interface.js +3 -0
  153. package/dist/src/interface/denormalized-doc-resolvers.interface.js.map +1 -0
  154. package/dist/src/interface/denormalized-doc.interface.d.ts +10 -0
  155. package/dist/src/interface/denormalized-doc.interface.js +3 -0
  156. package/dist/src/interface/denormalized-doc.interface.js.map +1 -0
  157. package/dist/src/interface/generator-options.interface.d.ts +22 -0
  158. package/dist/src/interface/generator-options.interface.js +3 -0
  159. package/dist/src/interface/generator-options.interface.js.map +1 -0
  160. package/dist/src/interface/index.d.ts +11 -0
  161. package/dist/src/interface/index.js +28 -0
  162. package/dist/src/interface/index.js.map +1 -0
  163. package/dist/src/services/asyncapi.explorer.d.ts +12 -0
  164. package/dist/src/services/asyncapi.explorer.js +69 -0
  165. package/dist/src/services/asyncapi.explorer.js.map +1 -0
  166. package/dist/src/services/asyncapi.generator.d.ts +6 -0
  167. package/dist/src/services/asyncapi.generator.js +68 -0
  168. package/dist/src/services/asyncapi.generator.js.map +1 -0
  169. package/dist/src/services/asyncapi.scanner.d.ts +14 -0
  170. package/dist/src/services/asyncapi.scanner.js +71 -0
  171. package/dist/src/services/asyncapi.scanner.js.map +1 -0
  172. package/dist/src/services/asyncapi.transformer.d.ts +4 -0
  173. package/dist/src/services/asyncapi.transformer.js +33 -0
  174. package/dist/src/services/asyncapi.transformer.js.map +1 -0
  175. package/dist/src/services/index.d.ts +4 -0
  176. package/dist/src/services/index.js +21 -0
  177. package/dist/src/services/index.js.map +1 -0
  178. package/dist/src/services/operation-object.factory.d.ts +9 -0
  179. package/dist/src/services/operation-object.factory.js +37 -0
  180. package/dist/src/services/operation-object.factory.js.map +1 -0
  181. package/dist/test/configs/jest-base.config.d.ts +3 -0
  182. package/dist/test/configs/jest-base.config.js +20 -0
  183. package/dist/test/configs/jest-base.config.js.map +1 -0
  184. package/dist/test/configs/jest-e2e.config.d.ts +3 -0
  185. package/dist/test/configs/jest-e2e.config.js +16 -0
  186. package/dist/test/configs/jest-e2e.config.js.map +1 -0
  187. package/dist/test/express.e2e-spec.d.ts +1 -0
  188. package/dist/test/express.e2e-spec.js +89 -0
  189. package/dist/test/express.e2e-spec.js.map +1 -0
  190. package/dist/test/fastify.e2e-spec.d.ts +1 -0
  191. package/dist/test/fastify.e2e-spec.js +57 -0
  192. package/dist/test/fastify.e2e-spec.js.map +1 -0
  193. package/dist/tsconfig.tsbuildinfo +1 -1
  194. package/eslint.config.mjs +21 -0
  195. package/misc/references/ref.html +303 -0
  196. package/misc/references/ref.json +1 -0
  197. package/misc/references/ref.yaml +292 -0
  198. package/misc/take-snaphots.sh +8 -0
  199. package/package.json +48 -41
  200. package/sample/app.module.ts +7 -0
  201. package/sample/common.ts +49 -0
  202. package/sample/constants.ts +12 -0
  203. package/sample/felines/class/cat.class.ts +9 -0
  204. package/sample/felines/class/feline.class.ts +29 -0
  205. package/sample/felines/class/index.ts +5 -0
  206. package/sample/felines/class/lion.class.ts +5 -0
  207. package/sample/felines/class/message.class.ts +17 -0
  208. package/sample/felines/class/tiger.class.ts +5 -0
  209. package/sample/felines/dto/create-feline.dto.ts +13 -0
  210. package/sample/felines/dto/index.ts +2 -0
  211. package/sample/felines/dto/journaling-data.dto.ts +5 -0
  212. package/sample/felines/felines.constants.ts +1 -0
  213. package/sample/felines/felines.controller.ts +76 -0
  214. package/sample/felines/felines.gateway.ts +76 -0
  215. package/sample/felines/felines.module.ts +15 -0
  216. package/sample/felines/felines.service.ts +24 -0
  217. package/sample/felines/rto/feline.rto.ts +17 -0
  218. package/sample/felines/rto/index.ts +1 -0
  219. package/sample/index.ts +3 -0
  220. package/sample/main.ts +34 -0
  221. package/src/asyncapi-document.builder.ts +5 -19
  222. package/src/asyncapi.module.ts +5 -16
  223. package/src/decorators/asyncapi-operation-for-meta-key.decorator.ts +4 -16
  224. package/src/decorators/asyncapi-operation.decorator.ts +1 -3
  225. package/src/decorators/asyncapi-pub.decorator.ts +6 -13
  226. package/src/decorators/asyncapi-sub.decorator.ts +6 -13
  227. package/src/explorers/asyncapi-class.explorer.ts +2 -6
  228. package/src/explorers/asyncapi-operation.explorer.ts +3 -12
  229. package/src/interface/asyncapi-common.interfaces.ts +1 -4
  230. package/src/interface/asyncapi-operation-options.interface.ts +2 -4
  231. package/src/interface/asyncapi-operation-payload.interface.ts +1 -5
  232. package/src/interface/asyncapi-server.interface.ts +1 -4
  233. package/src/interface/asyncapi-template-options.interface.ts +5 -5
  234. package/src/interface/denormalized-doc.interface.ts +1 -5
  235. package/src/services/asyncapi.explorer.ts +25 -34
  236. package/src/services/asyncapi.generator.ts +28 -16
  237. package/src/services/asyncapi.scanner.ts +39 -89
  238. package/src/services/asyncapi.transformer.ts +2 -8
  239. package/src/services/index.ts +0 -1
  240. package/src/services/operation-object.factory.ts +0 -1
  241. package/test/__mocks__/@asyncapi/generator.js +41 -0
  242. package/test/configs/jest-base.config.ts +19 -0
  243. package/test/configs/jest-e2e.config.js +7 -0
  244. package/test/configs/jest-e2e.config.ts +19 -0
  245. package/test/configs/jest-swagger-plugin.js +16 -0
  246. package/test/express.e2e-spec.ts +64 -0
  247. package/test/fastify.e2e-spec.ts +65 -0
  248. package/.eslintrc.js +0 -9
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-message.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-message.interface.js","sourceRoot":"","sources":["../../../src/interface/asyncapi-message.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export interface AsyncApiOperationHeaders {
2
+ [key: string]: {
3
+ description: string;
4
+ [key: string]: unknown;
5
+ };
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-operation-headers.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-operation-headers.interface.js","sourceRoot":"","sources":["../../../src/interface/asyncapi-operation-headers.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { AsyncOperationObject } from './asyncapi-common.interfaces';
2
+ import { AsyncOperationPayload } from './asyncapi-operation-payload.interface';
3
+ export interface RawAsyncApiMessage {
4
+ name?: string;
5
+ payload: {
6
+ type: AsyncOperationPayload;
7
+ };
8
+ headers?: {
9
+ type: 'object';
10
+ properties: {
11
+ [key: string]: {
12
+ description: string;
13
+ type: 'string';
14
+ [key: string]: unknown;
15
+ };
16
+ };
17
+ };
18
+ }
19
+ export interface AsyncApiOperationOptionsRaw extends AsyncOperationObject {
20
+ type: 'sub' | 'pub';
21
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-operation-options-raw.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-operation-options-raw.interface.js","sourceRoot":"","sources":["../../../src/interface/asyncapi-operation-options-raw.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { AsyncOperationObject } from './asyncapi-common.interfaces';
2
+ import { AsyncApiMessage } from './asyncapi-message.interface';
3
+ export interface AsyncApiSpecificOperationOptions extends Omit<AsyncOperationObject, 'message'> {
4
+ message: AsyncApiMessage;
5
+ }
6
+ export interface AsyncApiOperationOptions extends AsyncApiSpecificOperationOptions {
7
+ type: 'pub' | 'sub';
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-operation-options.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-operation-options.interface.js","sourceRoot":"","sources":["../../../src/interface/asyncapi-operation-options.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { Type } from '@nestjs/common';
2
+ export type AsyncOperationPayload = Type<unknown> | Function | [Function] | string;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-operation-payload.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-operation-payload.interface.js","sourceRoot":"","sources":["../../../src/interface/asyncapi-operation-payload.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { ServerObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
2
+ import { AmqpServerBinding, KafkaServerBinding } from '../binding';
3
+ import { AsyncServerVariableObject, SecurityObject } from './asyncapi-common.interfaces';
4
+ export interface AsyncServerObject extends Omit<ServerObject, 'variables'> {
5
+ variables?: Record<string, AsyncServerVariableObject>;
6
+ protocol: string;
7
+ protocolVersion?: string;
8
+ security?: SecurityObject[];
9
+ bindings?: Record<string, KafkaServerBinding | AmqpServerBinding>;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-server.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-server.interface.js","sourceRoot":"","sources":["../../../src/interface/asyncapi-server.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface AsyncApiTemplateOptions {
2
+ sidebarOrganization?: 'byTags' | 'byTagsNoRoot';
3
+ baseHref?: string;
4
+ singleFile?: boolean;
5
+ outFilename?: string;
6
+ pdf?: boolean;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-template-options.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-template-options.interface.js","sourceRoot":"","sources":["../../../src/interface/asyncapi-template-options.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export interface DenormalizedDocResolvers {
2
+ root: Function[];
3
+ security: Function[];
4
+ tags: Function[];
5
+ operations: Function[];
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=denormalized-doc-resolvers.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"denormalized-doc-resolvers.interface.js","sourceRoot":"","sources":["../../../src/interface/denormalized-doc-resolvers.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { AsyncApiDocument, AsyncChannelObject, AsyncOperationObject } from './asyncapi-common.interfaces';
2
+ export interface DenormalizedDoc extends Partial<AsyncApiDocument> {
3
+ root?: {
4
+ name: string;
5
+ } & AsyncChannelObject;
6
+ operations?: {
7
+ pub: AsyncOperationObject;
8
+ sub: AsyncOperationObject;
9
+ };
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=denormalized-doc.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"denormalized-doc.interface.js","sourceRoot":"","sources":["../../../src/interface/denormalized-doc.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { AsyncApiDocument } from './asyncapi-common.interfaces';
2
+ import { AsyncApiTemplateOptions } from './asyncapi-template-options.interface';
3
+ export interface GeneratorOptions {
4
+ templateName: string;
5
+ targetDir: string;
6
+ entrypoint?: string;
7
+ noOverwriteGlobs: string[];
8
+ disabledHooks: {
9
+ [key: string]: string | boolean | string[];
10
+ };
11
+ output: 'string' | 'fs';
12
+ forceWrite: boolean;
13
+ debug: boolean;
14
+ install: boolean;
15
+ templateConfig: Record<string, unknown>;
16
+ hooks: Record<string, unknown>;
17
+ templateParams: AsyncApiTemplateOptions;
18
+ generate: (document: AsyncApiDocument) => Promise<void>;
19
+ generateFromURL: (url: string) => Promise<void>;
20
+ generateFromFile: (path: string) => Promise<void>;
21
+ generateFromString: (yaml: string, args?: unknown) => Promise<string>;
22
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generator-options.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-options.interface.js","sourceRoot":"","sources":["../../../src/interface/generator-options.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export * from './asyncapi-common.interfaces';
2
+ export * from './asyncapi-template-options.interface';
3
+ export * from './asyncapi-operation-headers.interface';
4
+ export * from './asyncapi-operation-payload.interface';
5
+ export * from './asyncapi-operation-options.interface';
6
+ export * from './asyncapi-document-options.interface';
7
+ export * from './asyncapi-server.interface';
8
+ export * from './denormalized-doc.interface';
9
+ export * from './denormalized-doc-resolvers.interface';
10
+ export * from './generator-options.interface';
11
+ export * from './asyncapi-operation-options-raw.interface';
@@ -0,0 +1,28 @@
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-common.interfaces"), exports);
18
+ __exportStar(require("./asyncapi-template-options.interface"), exports);
19
+ __exportStar(require("./asyncapi-operation-headers.interface"), exports);
20
+ __exportStar(require("./asyncapi-operation-payload.interface"), exports);
21
+ __exportStar(require("./asyncapi-operation-options.interface"), exports);
22
+ __exportStar(require("./asyncapi-document-options.interface"), exports);
23
+ __exportStar(require("./asyncapi-server.interface"), exports);
24
+ __exportStar(require("./denormalized-doc.interface"), exports);
25
+ __exportStar(require("./denormalized-doc-resolvers.interface"), exports);
26
+ __exportStar(require("./generator-options.interface"), exports);
27
+ __exportStar(require("./asyncapi-operation-options-raw.interface"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,wEAAsD;AACtD,yEAAuD;AACvD,yEAAuD;AACvD,yEAAuD;AACvD,wEAAsD;AACtD,8DAA4C;AAC5C,+DAA6C;AAC7C,yEAAuD;AACvD,gEAA8C;AAE9C,6EAA2D"}
@@ -0,0 +1,12 @@
1
+ import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
2
+ import { SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
3
+ import { DenormalizedDoc } from '../interface';
4
+ export declare class AsyncApiExplorer {
5
+ private readonly metadataScanner;
6
+ private readonly schemas;
7
+ private readonly schemaRefsStack;
8
+ private operationIdFactory;
9
+ explorerAsyncapiServices(wrapper: InstanceWrapper, modulePath?: string, globalPrefix?: string, operationIdFactory?: (controllerKey: string, methodKey: string) => string): DenormalizedDoc[];
10
+ getSchemas(): Record<string, SchemaObject>;
11
+ private generateDenormalizedDocument;
12
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncApiExplorer = void 0;
4
+ const core_1 = require("@nestjs/core");
5
+ const lodash_1 = require("lodash");
6
+ const explorers_1 = require("../explorers");
7
+ class AsyncApiExplorer {
8
+ constructor() {
9
+ this.metadataScanner = new core_1.MetadataScanner();
10
+ this.schemas = [];
11
+ this.schemaRefsStack = [];
12
+ this.operationIdFactory = (controllerKey, methodKey) => controllerKey ? `${controllerKey}_${methodKey}` : methodKey;
13
+ }
14
+ explorerAsyncapiServices(wrapper, modulePath, globalPrefix, operationIdFactory) {
15
+ if (operationIdFactory) {
16
+ this.operationIdFactory = operationIdFactory;
17
+ }
18
+ const { instance, metatype } = wrapper;
19
+ if (!instance ||
20
+ !metatype ||
21
+ !Reflect.getMetadataKeys(metatype).find((label) => explorers_1.asyncApiClassAnnotationLabels.includes(label))) {
22
+ return [];
23
+ }
24
+ const prototype = Object.getPrototypeOf(instance);
25
+ const documentResolvers = {
26
+ root: [explorers_1.exploreAsyncapiClassMetadata, explorers_1.exploreControllerMetadata, explorers_1.exploreGatewayMetadata],
27
+ security: [],
28
+ tags: [],
29
+ operations: [explorers_1.exploreAsyncApiOperationMetadata],
30
+ };
31
+ return this.generateDenormalizedDocument(metatype, prototype, instance, documentResolvers, modulePath, globalPrefix);
32
+ }
33
+ getSchemas() {
34
+ const ret = Object.assign({}, this.schemas);
35
+ return ret;
36
+ }
37
+ generateDenormalizedDocument(metatype, prototype, instance, documentResolvers, _modulePath, _globalPrefix) {
38
+ const denormalizedAsyncapiServices = this.metadataScanner.scanFromPrototype(instance, prototype, (name) => {
39
+ const targetCallback = prototype[name];
40
+ const methodMetadata = documentResolvers.root.reduce((_metadata, fn) => {
41
+ const serviceMetadata = fn(metatype);
42
+ const channels = documentResolvers.operations.reduce((operationsParam, exploreOperationsMeta) => {
43
+ const operations = operationsParam;
44
+ const meta = exploreOperationsMeta(this.schemas, instance, prototype, targetCallback);
45
+ if (!meta) {
46
+ return operations;
47
+ }
48
+ meta.forEach((op) => {
49
+ if (Object.prototype.hasOwnProperty.call(operations, op.channel)) {
50
+ operations[op.channel] = Object.assign(Object.assign({}, operations[op.channel]), op);
51
+ }
52
+ else {
53
+ operations[op.channel] = op;
54
+ }
55
+ });
56
+ return operations;
57
+ }, {});
58
+ return Object.keys(channels).map((channel) => ({
59
+ root: Object.assign(Object.assign({}, serviceMetadata), { name: channel }),
60
+ operations: channels[channel],
61
+ }));
62
+ }, []);
63
+ return methodMetadata;
64
+ });
65
+ return (0, lodash_1.flatten)(denormalizedAsyncapiServices);
66
+ }
67
+ }
68
+ exports.AsyncApiExplorer = AsyncApiExplorer;
69
+ //# sourceMappingURL=asyncapi.explorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi.explorer.js","sourceRoot":"","sources":["../../../src/services/asyncapi.explorer.ts"],"names":[],"mappings":";;;AACA,uCAA+C;AAG/C,mCAAiC;AACjC,4CAMsB;AAGtB,MAAa,gBAAgB;IAA7B;QACmB,oBAAe,GAAG,IAAI,sBAAe,EAAE,CAAC;QAExC,YAAO,GAAmB,EAAE,CAAC;QAE7B,oBAAe,GAAa,EAAE,CAAC;QAExC,uBAAkB,GAAG,CAAC,aAAqB,EAAE,SAAiB,EAAE,EAAE,CACxE,aAAa,CAAC,CAAC,CAAC,G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AAC;YACN,CAAC,EAAE,EAAE,CAAC,CAAC;YACP,OAAO,cAAc,CAAC;QACxB,CAAC,CACF,CAAC;QAEF,OAAO,IAAA,gBAAO,EAAC,4BAA4B,CAAC,CAAC;IAC/C,CAAC;CACF;AAjGD,4CAiGC"}
@@ -0,0 +1,6 @@
1
+ import { AsyncApiDocument, AsyncApiTemplateOptions } from '../interface';
2
+ export declare class AsyncapiGenerator {
3
+ private readonly templateOptions?;
4
+ constructor(templateOptions?: AsyncApiTemplateOptions);
5
+ generate(contract: AsyncApiDocument): Promise<string>;
6
+ }
@@ -0,0 +1,68 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AsyncapiGenerator = void 0;
40
+ const promises_1 = __importDefault(require("fs/promises"));
41
+ const js_yaml_1 = __importDefault(require("js-yaml"));
42
+ const os_1 = __importDefault(require("os"));
43
+ const path_1 = __importDefault(require("path"));
44
+ class AsyncapiGenerator {
45
+ constructor(templateOptions) {
46
+ this.templateOptions = templateOptions;
47
+ }
48
+ async generate(contract) {
49
+ const { default: Generator } = await Promise.resolve().then(() => __importStar(require('@asyncapi/generator')));
50
+ const yaml = js_yaml_1.default.dump(contract);
51
+ const tmpDir = path_1.default.join(os_1.default.tmpdir(), `asyncapi-${Date.now()}-${Math.random().toString(36).slice(2)}`);
52
+ const generator = new Generator('@asyncapi/html-template', tmpDir, {
53
+ forceWrite: true,
54
+ templateParams: Object.assign({ singleFile: true }, this.templateOptions),
55
+ });
56
+ await generator.generateFromString(yaml, {
57
+ resolve: {
58
+ file: false,
59
+ },
60
+ });
61
+ const htmlPath = path_1.default.join(tmpDir, 'index.html');
62
+ const html = await promises_1.default.readFile(htmlPath, 'utf-8');
63
+ await promises_1.default.rm(tmpDir, { recursive: true, force: true }).catch(() => { });
64
+ return html;
65
+ }
66
+ }
67
+ exports.AsyncapiGenerator = AsyncapiGenerator;
68
+ //# sourceMappingURL=asyncapi.generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi.generator.js","sourceRoot":"","sources":["../../../src/services/asyncapi.generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6B;AAC7B,sDAA6B;AAC7B,4CAAoB;AACpB,gDAAwB;AAGxB,MAAa,iBAAiB;IAG5B,YAAY,eAAyC;QACnD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,QAA0B;QAI9C,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,wDAAa,qBAAqB,GAAC,CAAC;QAEnE,MAAM,IAAI,GAAG,iBAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,YAAY,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAEvG,MAAM,SAAS,GAAqB,IAAI,SAAS,CAAC,yBAAyB,EAAE,MAAM,EAAE;YACnF,UAAU,EAAE,IAAI;YAChB,cAAc,kBACZ,UAAU,EAAE,IAAI,IACb,IAAI,CAAC,eAAe,CACxB;SACF,CAAC,CAAC;QAEH,MAAM,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE;YACvC,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK;aACZ;SACF,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAGlD,MAAM,kBAAE,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtCD,8CAsCC"}
@@ -0,0 +1,14 @@
1
+ import { INestApplicationContext } from '@nestjs/common';
2
+ import { AsyncApiDocument, AsyncApiDocumentOptions } from '../interface';
3
+ export declare class AsyncapiScanner {
4
+ private readonly transformer;
5
+ private readonly explorer;
6
+ private readonly modelPropertiesAccessor;
7
+ private readonly swaggerTypesMapper;
8
+ private readonly schemaObjectFactory;
9
+ scanApplication(app: INestApplicationContext, options: AsyncApiDocumentOptions): Omit<AsyncApiDocument, 'asyncapi' | 'info'>;
10
+ private scanModuleProviders;
11
+ private getModules;
12
+ private getGlobalPrefix;
13
+ private addExtraModels;
14
+ }
@@ -0,0 +1,71 @@
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;
23
+ const modules = this.getModules(container.getModules(), includedModules);
24
+ const globalPrefix = !ignoreGlobalPrefix ? (0, strip_last_slash_util_1.stripLastSlash)(this.getGlobalPrefix(app)) : '';
25
+ const denormalizedChannels = modules.reduce((channels, { providers, metatype, imports, controllers }) => {
26
+ let allProviders = new Map([...providers, ...controllers]);
27
+ if (deepScanRoutes) {
28
+ const isGlobal = (module) => !container.isGlobalModule(module);
29
+ Array.from(imports.values())
30
+ .filter(isGlobal)
31
+ .map(({ providers: relatedProviders, controllers: relatedControllers }) => ({
32
+ relatedProviders,
33
+ relatedControllers,
34
+ }))
35
+ .forEach(({ relatedProviders, relatedControllers }) => {
36
+ allProviders = new Map([...allProviders, ...relatedProviders, ...relatedControllers]);
37
+ });
38
+ }
39
+ const path = metatype ? Reflect.getMetadata(constants_1.MODULE_PATH, metatype) : undefined;
40
+ return [...channels, ...this.scanModuleProviders(allProviders, path, globalPrefix, operationIdFactory)];
41
+ }, []);
42
+ const schemas = this.explorer.getSchemas();
43
+ this.addExtraModels(schemas, extraModels);
44
+ const normalizedChannels = this.transformer.normalizeChannels((0, lodash_1.flatten)(denormalizedChannels));
45
+ return Object.assign(Object.assign({}, normalizedChannels), { components: { schemas } });
46
+ }
47
+ scanModuleProviders(providers, modulePath, globalPrefix, operationIdFactory) {
48
+ const denormalizedArray = [...providers.values()].reduce((denormalized, prov) => {
49
+ const object = this.explorer.explorerAsyncapiServices(prov, modulePath, globalPrefix, operationIdFactory);
50
+ return [...denormalized, ...object];
51
+ }, []);
52
+ return (0, lodash_1.flatten)(denormalizedArray);
53
+ }
54
+ getModules(modulesContainer, include) {
55
+ if (!include || (0, lodash_1.isEmpty)(include)) {
56
+ return [...modulesContainer.values()];
57
+ }
58
+ return [...modulesContainer.values()].filter(({ metatype }) => include.some((item) => item === metatype));
59
+ }
60
+ getGlobalPrefix(app) {
61
+ const internalConfigRef = app.config;
62
+ return (internalConfigRef === null || internalConfigRef === void 0 ? void 0 : internalConfigRef.getGlobalPrefix()) || '';
63
+ }
64
+ addExtraModels(schemas, extraModels) {
65
+ extraModels.forEach((item) => {
66
+ this.schemaObjectFactory.exploreModelSchema(item, schemas);
67
+ });
68
+ }
69
+ }
70
+ exports.AsyncapiScanner = AsyncapiScanner;
71
+ //# sourceMappingURL=asyncapi.scanner.js.map
@@ -0,0 +1 @@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AC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAzFD,0CAyFC"}
@@ -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":[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;CACF;AA9BD,kDA8BC"}
@@ -0,0 +1,4 @@
1
+ export * from './asyncapi.generator';
2
+ export * from './operation-object.factory';
3
+ export * from './asyncapi.explorer';
4
+ export * from './asyncapi.scanner';
@@ -0,0 +1,21 @@
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
+ //# 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"}
@@ -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
+ }