@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,19 @@
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-operation.explorer"), exports);
18
+ __exportStar(require("./asyncapi-class.explorer"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/explorers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,4DAA0C"}
@@ -0,0 +1,4 @@
1
+ export * from './asyncapi-document.builder';
2
+ export * from './interface';
3
+ export * from './asyncapi.module';
4
+ export * from './decorators';
package/dist/index.js ADDED
@@ -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-document.builder"), exports);
18
+ __exportStar(require("./interface"), exports);
19
+ __exportStar(require("./asyncapi.module"), exports);
20
+ __exportStar(require("./decorators"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,8CAA4B;AAC5B,oDAAkC;AAClC,+CAA6B"}
@@ -0,0 +1,126 @@
1
+ import { InfoObject, ReferenceObject, SchemaObject, ServerVariableObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
2
+ import { AmqpChannelBinding, AmqpMessageBinding, AmqpOperationBinding, AmqpServerBinding, KafkaChannelBinding, KafkaMessageBinding, KafkaOperationBinding, KafkaServerBinding } from '../binding';
3
+ import { AsyncOperationPayload } from './asyncapi-operation-payload.interface';
4
+ import { AsyncServerObject } from './asyncapi-server.interface';
5
+ export interface AsyncApiDocument {
6
+ asyncapi: string;
7
+ id?: string;
8
+ info: InfoObject;
9
+ servers?: Record<string, AsyncServerObject>;
10
+ channels: AsyncChannelsObject;
11
+ components?: AsyncComponentsObject;
12
+ tags?: AsyncTagObject[];
13
+ externalDocs?: ExternalDocumentationObject;
14
+ defaultContentType?: string;
15
+ }
16
+ export type AsyncChannelsObject = Record<string, AsyncChannelObject>;
17
+ export interface AsyncChannelObject {
18
+ description?: string;
19
+ subscribe?: AsyncOperationObject;
20
+ publish?: AsyncOperationObject;
21
+ parameters?: Record<string, ParameterObject>;
22
+ bindings?: Record<string, KafkaChannelBinding | AmqpChannelBinding>;
23
+ }
24
+ export interface AsyncServerVariableObject extends ServerVariableObject {
25
+ examples?: string[];
26
+ }
27
+ export type SecurityObject = Record<string, string[]>;
28
+ export interface AsyncComponentsObject {
29
+ schemas?: Record<string, SchemaObject>;
30
+ messages?: Record<string, AsyncMessageObject>;
31
+ securitySchemes?: Record<string, AsyncSecuritySchemeObject>;
32
+ parameters?: Record<string, ParameterObject>;
33
+ correlationIds?: Record<string, AsyncCorrelationObject>;
34
+ operationTraits?: Record<string, AsyncOperationTraitObject>;
35
+ messageTraits?: Record<string, AsyncMessageTraitObject>;
36
+ serverBindings?: Record<string, KafkaServerBinding | AmqpServerBinding>;
37
+ channelBindings?: Record<string, KafkaChannelBinding | AmqpChannelBinding>;
38
+ operationBindings?: Record<string, KafkaOperationBinding | AmqpOperationBinding>;
39
+ messageBindings?: Record<string, KafkaMessageBinding | AmqpMessageBinding>;
40
+ }
41
+ export interface AsyncMessageObject extends AsyncMessageTraitObject {
42
+ payload?: {
43
+ type?: AsyncOperationPayload;
44
+ $ref?: AsyncOperationPayload;
45
+ };
46
+ }
47
+ export type MessageType = AsyncMessageObject | ReferenceObject;
48
+ export interface OneOfMessageType {
49
+ oneOf: MessageType[];
50
+ }
51
+ export type AsyncOperationMessage = OneOfMessageType | MessageType;
52
+ export interface AsyncOperationObject {
53
+ channel: string;
54
+ operationId?: string;
55
+ summary?: string;
56
+ description?: string;
57
+ tags?: AsyncTagObject[];
58
+ externalDocs?: ExternalDocumentationObject;
59
+ bindings?: Record<string, KafkaOperationBinding | AmqpOperationBinding>;
60
+ traits?: Record<string, AsyncOperationTraitObject>;
61
+ message?: AsyncOperationMessage;
62
+ }
63
+ export interface AsyncOperationTraitObject {
64
+ operationId?: string;
65
+ summary?: string;
66
+ description?: string;
67
+ tags?: AsyncTagObject[];
68
+ externalDocs?: ExternalDocumentationObject;
69
+ bindings?: Record<string, KafkaOperationBinding | AmqpOperationBinding>;
70
+ }
71
+ export interface AsyncMessageTraitObject {
72
+ headers?: SchemaObject;
73
+ correlationId?: AsyncCorrelationObject;
74
+ schemaFormat?: string;
75
+ contentType?: string;
76
+ name?: string;
77
+ title?: string;
78
+ summary?: string;
79
+ description?: string;
80
+ tags?: AsyncTagObject[];
81
+ externalDocs?: ExternalDocumentationObject;
82
+ bindings?: Record<string, KafkaMessageBinding | AmqpMessageBinding>;
83
+ }
84
+ export interface AsyncCorrelationObject {
85
+ description?: string;
86
+ location: string;
87
+ }
88
+ export interface AsyncTagObject {
89
+ name: string;
90
+ description?: string;
91
+ externalDocs?: ExternalDocumentationObject;
92
+ }
93
+ export interface AsyncSecuritySchemeObject {
94
+ type: SecuritySchemeType;
95
+ description?: string;
96
+ name?: string;
97
+ in?: string;
98
+ scheme?: string;
99
+ bearerFormat?: string;
100
+ flows?: OAuthFlowsObject;
101
+ openIdConnectUrl?: string;
102
+ }
103
+ export declare type SecuritySchemeType = 'userPassword' | 'apiKey' | 'X509' | 'symmetricEncryption' | 'asymmetricEncryption' | 'http' | 'oauth2' | 'openIdConnect';
104
+ export interface OAuthFlowsObject {
105
+ implicit?: OAuthFlowObject;
106
+ password?: OAuthFlowObject;
107
+ clientCredentials?: OAuthFlowObject;
108
+ authorizationCode?: OAuthFlowObject;
109
+ }
110
+ export interface OAuthFlowObject {
111
+ authorizationUrl?: string;
112
+ tokenUrl?: string;
113
+ refreshUrl?: string;
114
+ scopes: ScopesObject;
115
+ }
116
+ export type ScopesObject = Record<string, unknown>;
117
+ export type ParameterObject = BaseParameterObject;
118
+ export interface BaseParameterObject {
119
+ description?: string;
120
+ schema?: SchemaObject | ReferenceObject;
121
+ location?: string;
122
+ }
123
+ export interface ExternalDocumentationObject {
124
+ description?: string;
125
+ url: string;
126
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-common.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-common.interfaces.js","sourceRoot":"","sources":["../../src/interface/asyncapi-common.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { SwaggerDocumentOptions } from '@nestjs/swagger';
2
+ export interface AsyncApiDocumentOptions extends SwaggerDocumentOptions {
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=asyncapi-document-options.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi-document-options.interface.js","sourceRoot":"","sources":["../../src/interface/asyncapi-document-options.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { AsyncApiOperationHeaders } from './asyncapi-operation-headers.interface';
2
+ import { AsyncOperationPayload } from './asyncapi-operation-payload.interface';
3
+ export interface OneAsyncApiMessage {
4
+ name?: string;
5
+ payload: AsyncOperationPayload;
6
+ headers?: AsyncApiOperationHeaders;
7
+ }
8
+ export type AsyncApiMessage = OneAsyncApiMessage | OneAsyncApiMessage[];
@@ -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,72 @@
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: [
27
+ explorers_1.exploreAsyncapiClassMetadata,
28
+ explorers_1.exploreControllerMetadata,
29
+ explorers_1.exploreGatewayMetadata,
30
+ ],
31
+ security: [],
32
+ tags: [],
33
+ operations: [explorers_1.exploreAsyncApiOperationMetadata],
34
+ };
35
+ return this.generateDenormalizedDocument(metatype, prototype, instance, documentResolvers, modulePath, globalPrefix);
36
+ }
37
+ getSchemas() {
38
+ const ret = Object.assign({}, this.schemas);
39
+ return ret;
40
+ }
41
+ generateDenormalizedDocument(metatype, prototype, instance, documentResolvers, _modulePath, _globalPrefix) {
42
+ const denormalizedAsyncapiServices = this.metadataScanner.scanFromPrototype(instance, prototype, (name) => {
43
+ const targetCallback = prototype[name];
44
+ const methodMetadata = documentResolvers.root.reduce((_metadata, fn) => {
45
+ const serviceMetadata = fn(metatype);
46
+ const channels = documentResolvers.operations.reduce((operations, exploreOperationsMeta) => {
47
+ const meta = exploreOperationsMeta(this.schemas, instance, prototype, targetCallback);
48
+ if (!meta) {
49
+ return operations;
50
+ }
51
+ meta.forEach((op) => {
52
+ if (operations.hasOwnProperty(op.channel)) {
53
+ operations[op.channel] = Object.assign(Object.assign({}, operations[op.channel]), op);
54
+ }
55
+ else {
56
+ operations[op.channel] = op;
57
+ }
58
+ });
59
+ return operations;
60
+ }, {});
61
+ return Object.keys(channels).map((channel) => ({
62
+ root: Object.assign(Object.assign({}, serviceMetadata), { name: channel }),
63
+ operations: channels[channel],
64
+ }));
65
+ }, []);
66
+ return methodMetadata;
67
+ });
68
+ return (0, lodash_1.flatten)(denormalizedAsyncapiServices);
69
+ }
70
+ }
71
+ exports.AsyncApiExplorer = AsyncApiExplorer;
72
+ //# sourceMappingURL=asyncapi.explorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncapi.explorer.js","sourceRoot":"","sources":["../../src/services/asyncapi.explorer.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ import { AsyncApiDocument, AsyncApiTemplateOptions } from '../interface';
2
+ export declare class AsyncapiGenerator {
3
+ readonly templateOptions?: AsyncApiTemplateOptions | undefined;
4
+ private readonly generator;
5
+ constructor(templateOptions?: AsyncApiTemplateOptions | undefined);
6
+ generate(contract: AsyncApiDocument): Promise<string>;
7
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncapiGenerator = void 0;
4
+ const generator_1 = require("@asyncapi/generator");
5
+ const js_yaml_1 = require("js-yaml");
6
+ const os_1 = require("os");
7
+ class AsyncapiGenerator {
8
+ constructor(templateOptions) {
9
+ this.templateOptions = templateOptions;
10
+ this.generator = new generator_1.default('@asyncapi/html-template', os_1.default.tmpdir(), {
11
+ forceWrite: true,
12
+ entrypoint: 'index.html',
13
+ output: 'string',
14
+ templateParams: Object.assign({ singleFile: true }, templateOptions),
15
+ });
16
+ }
17
+ async generate(contract) {
18
+ const yaml = js_yaml_1.default.dump(contract);
19
+ return this.generator.generateFromString(yaml, {
20
+ resolve: {
21
+ file: false,
22
+ },
23
+ });
24
+ }
25
+ }
26
+ exports.AsyncapiGenerator = AsyncapiGenerator;
27
+ //# 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,mDAA4C;AAC5C,qCAA6B;AAC7B,2BAAoB;AAOpB,MAAa,iBAAiB;IAG5B,YAAqB,eAAyC;QAAzC,oBAAe,GAAf,eAAe,CAA0B;QAC5D,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAS,CAAC,yBAAyB,EAAE,YAAE,CAAC,MAAM,EAAE,EAAE;YACrE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,YAAY;YACxB,MAAM,EAAE,QAAQ;YAChB,cAAc,kBACZ,UAAU,EAAE,IAAI,IACb,eAAe,CACnB;SACF,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,QAA0B;QAC9C,MAAM,IAAI,GAAG,iBAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE;YAC7C,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK;aACZ;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAvBD,8CAuBC"}
@@ -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
+ }