@conduitplatform/grpc-sdk 0.16.0-alpha.0 → 0.16.0-alpha.10

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 (225) hide show
  1. package/README.mdx +1 -7
  2. package/dist/classes/ConduitModule.d.ts +9 -6
  3. package/dist/classes/ConduitModule.js +85 -48
  4. package/dist/classes/ConduitModule.js.map +1 -1
  5. package/dist/classes/ConduitSchema.js.map +1 -1
  6. package/dist/classes/HealthCheck.js +36 -9
  7. package/dist/classes/HealthCheck.js.map +1 -1
  8. package/dist/classes/index.d.ts +2 -6
  9. package/dist/classes/index.js +2 -6
  10. package/dist/classes/index.js.map +1 -1
  11. package/dist/index.d.ts +33 -31
  12. package/dist/index.js +155 -176
  13. package/dist/index.js.map +1 -1
  14. package/dist/interceptors/grpcSignedToken.d.ts +1 -1
  15. package/dist/interceptors/grpcSignedToken.js +2 -2
  16. package/dist/interceptors/moduleName.d.ts +1 -1
  17. package/dist/interceptors/moduleName.js +2 -2
  18. package/dist/interfaces/ConduitMiddleware.js.map +1 -0
  19. package/dist/{routing/interfaces → interfaces}/ConduitRoute.d.ts +2 -3
  20. package/dist/interfaces/ConduitRoute.js.map +1 -0
  21. package/dist/{routing → interfaces}/ConduitRouteReturn.d.ts +3 -3
  22. package/dist/interfaces/ConduitRouteReturn.js.map +1 -0
  23. package/dist/interfaces/ConduitSchemaExtension.d.ts +1 -1
  24. package/dist/interfaces/GrpcCallback.d.ts +1 -1
  25. package/dist/{utilities/Logger.d.ts → interfaces/IConduitLogger.d.ts} +4 -7
  26. package/dist/interfaces/{ConduitService.js → IConduitLogger.js} +1 -1
  27. package/dist/interfaces/IConduitLogger.js.map +1 -0
  28. package/dist/{metrics/index.d.ts → interfaces/IConduitMetrics.d.ts} +5 -11
  29. package/dist/interfaces/IConduitMetrics.js +3 -0
  30. package/dist/interfaces/IConduitMetrics.js.map +1 -0
  31. package/dist/interfaces/Indexable.d.ts +7 -8
  32. package/dist/interfaces/Model.d.ts +77 -12
  33. package/dist/interfaces/Model.js +15 -1
  34. package/dist/interfaces/Model.js.map +1 -1
  35. package/dist/interfaces/Params.d.ts +8 -0
  36. package/dist/interfaces/Params.js +3 -0
  37. package/dist/interfaces/Params.js.map +1 -0
  38. package/dist/interfaces/ProxyRoute.js.map +1 -0
  39. package/dist/interfaces/RawQuery.d.ts +2 -2
  40. package/dist/interfaces/Route.d.ts +61 -0
  41. package/dist/interfaces/Route.js +12 -0
  42. package/dist/interfaces/Route.js.map +1 -0
  43. package/dist/{routing/interfaces → interfaces}/Socket.d.ts +4 -5
  44. package/dist/interfaces/Socket.js.map +1 -0
  45. package/dist/interfaces/UntypedArray.d.ts +1 -0
  46. package/dist/interfaces/UntypedArray.js +3 -0
  47. package/dist/interfaces/UntypedArray.js.map +1 -0
  48. package/dist/interfaces/index.d.ts +11 -2
  49. package/dist/interfaces/index.js +11 -2
  50. package/dist/interfaces/index.js.map +1 -1
  51. package/dist/{routing/interfaces → interfaces}/types.d.ts +11 -9
  52. package/dist/{routing/interfaces → interfaces}/types.js.map +1 -1
  53. package/dist/module.proto +14 -0
  54. package/dist/modules/admin/index.d.ts +5 -4
  55. package/dist/modules/admin/index.js +12 -5
  56. package/dist/modules/admin/index.js.map +1 -1
  57. package/dist/modules/authorization/index.d.ts +3 -2
  58. package/dist/modules/authorization/index.js +4 -4
  59. package/dist/modules/authorization/index.js.map +1 -1
  60. package/dist/modules/config/index.d.ts +5 -5
  61. package/dist/modules/config/index.js +39 -29
  62. package/dist/modules/config/index.js.map +1 -1
  63. package/dist/modules/database/index.d.ts +8 -6
  64. package/dist/modules/database/index.js +18 -15
  65. package/dist/modules/database/index.js.map +1 -1
  66. package/dist/modules/index.d.ts +0 -2
  67. package/dist/modules/index.js +0 -2
  68. package/dist/modules/index.js.map +1 -1
  69. package/dist/modules/router/index.d.ts +4 -3
  70. package/dist/modules/router/index.js +9 -2
  71. package/dist/modules/router/index.js.map +1 -1
  72. package/dist/modules/storage/index.d.ts +6 -2
  73. package/dist/modules/storage/index.js +22 -2
  74. package/dist/modules/storage/index.js.map +1 -1
  75. package/dist/protoUtils/authentication.d.ts +3 -48
  76. package/dist/protoUtils/authentication.js +84 -142
  77. package/dist/protoUtils/authentication.js.map +1 -1
  78. package/dist/protoUtils/authorization.d.ts +33 -82
  79. package/dist/protoUtils/authorization.js +233 -219
  80. package/dist/protoUtils/authorization.js.map +1 -1
  81. package/dist/protoUtils/chat.d.ts +7 -61
  82. package/dist/protoUtils/chat.js +68 -170
  83. package/dist/protoUtils/chat.js.map +1 -1
  84. package/dist/protoUtils/core.d.ts +115 -90
  85. package/dist/protoUtils/core.js +485 -205
  86. package/dist/protoUtils/core.js.map +1 -1
  87. package/dist/protoUtils/database.d.ts +50 -15
  88. package/dist/protoUtils/database.js +455 -157
  89. package/dist/protoUtils/database.js.map +1 -1
  90. package/dist/protoUtils/email.d.ts +3 -48
  91. package/dist/protoUtils/email.js +82 -136
  92. package/dist/protoUtils/email.js.map +1 -1
  93. package/dist/protoUtils/google/protobuf/empty.d.ts +25 -0
  94. package/dist/protoUtils/google/protobuf/empty.js +47 -0
  95. package/dist/protoUtils/google/protobuf/empty.js.map +1 -0
  96. package/dist/protoUtils/grpc_health_check.d.ts +3 -4
  97. package/dist/protoUtils/grpc_health_check.js +19 -12
  98. package/dist/protoUtils/grpc_health_check.js.map +1 -1
  99. package/dist/protoUtils/index.d.ts +12 -0
  100. package/dist/{routing/interfaces → protoUtils}/index.js +12 -6
  101. package/dist/protoUtils/index.js.map +1 -0
  102. package/dist/protoUtils/{forms.d.ts → module.d.ts} +6 -7
  103. package/dist/protoUtils/{forms.js → module.js} +23 -16
  104. package/dist/protoUtils/module.js.map +1 -0
  105. package/dist/protoUtils/push-notifications.d.ts +3 -48
  106. package/dist/protoUtils/push-notifications.js +121 -154
  107. package/dist/protoUtils/push-notifications.js.map +1 -1
  108. package/dist/protoUtils/router.d.ts +45 -64
  109. package/dist/protoUtils/router.js +318 -221
  110. package/dist/protoUtils/router.js.map +1 -1
  111. package/dist/protoUtils/sms.d.ts +3 -48
  112. package/dist/protoUtils/sms.js +63 -134
  113. package/dist/protoUtils/sms.js.map +1 -1
  114. package/dist/protoUtils/storage.d.ts +134 -62
  115. package/dist/protoUtils/storage.js +521 -199
  116. package/dist/protoUtils/storage.js.map +1 -1
  117. package/dist/types/db.d.ts +11 -11
  118. package/dist/types/index.d.ts +3 -10
  119. package/dist/types/index.js +15 -0
  120. package/dist/types/index.js.map +1 -1
  121. package/dist/utilities/RedisManager.js.map +1 -1
  122. package/dist/utilities/env.d.ts +1 -0
  123. package/dist/utilities/env.js +37 -0
  124. package/dist/utilities/env.js.map +1 -0
  125. package/dist/utilities/index.d.ts +4 -2
  126. package/dist/utilities/index.js +4 -2
  127. package/dist/utilities/index.js.map +1 -1
  128. package/package.json +24 -25
  129. package/dist/classes/ConduitActiveSchema.d.ts +0 -19
  130. package/dist/classes/ConduitActiveSchema.js +0 -57
  131. package/dist/classes/ConduitActiveSchema.js.map +0 -1
  132. package/dist/classes/ConduitServiceModule.d.ts +0 -26
  133. package/dist/classes/ConduitServiceModule.js +0 -166
  134. package/dist/classes/ConduitServiceModule.js.map +0 -1
  135. package/dist/classes/ConfigController.d.ts +0 -7
  136. package/dist/classes/ConfigController.js +0 -27
  137. package/dist/classes/ConfigController.js.map +0 -1
  138. package/dist/classes/GrpcServer.d.ts +0 -22
  139. package/dist/classes/GrpcServer.js +0 -207
  140. package/dist/classes/GrpcServer.js.map +0 -1
  141. package/dist/classes/ManagedModule.d.ts +0 -74
  142. package/dist/classes/ManagedModule.js +0 -333
  143. package/dist/classes/ManagedModule.js.map +0 -1
  144. package/dist/classes/ModuleManager.d.ts +0 -11
  145. package/dist/classes/ModuleManager.js +0 -205
  146. package/dist/classes/ModuleManager.js.map +0 -1
  147. package/dist/helpers/GrpcHelper.d.ts +0 -8
  148. package/dist/helpers/GrpcHelper.js +0 -44
  149. package/dist/helpers/GrpcHelper.js.map +0 -1
  150. package/dist/helpers/TypeHelpers.d.ts +0 -44
  151. package/dist/helpers/TypeHelpers.js +0 -144
  152. package/dist/helpers/TypeHelpers.js.map +0 -1
  153. package/dist/helpers/index.d.ts +0 -3
  154. package/dist/helpers/index.js +0 -20
  155. package/dist/helpers/index.js.map +0 -1
  156. package/dist/helpers/wrapGrpcFunctions.d.ts +0 -5
  157. package/dist/helpers/wrapGrpcFunctions.js +0 -56
  158. package/dist/helpers/wrapGrpcFunctions.js.map +0 -1
  159. package/dist/interfaces/ConduitService.d.ts +0 -8
  160. package/dist/interfaces/ConduitService.js.map +0 -1
  161. package/dist/metrics/MetricsServer.d.ts +0 -9
  162. package/dist/metrics/MetricsServer.js +0 -94
  163. package/dist/metrics/MetricsServer.js.map +0 -1
  164. package/dist/metrics/clientMiddleware.d.ts +0 -2
  165. package/dist/metrics/clientMiddleware.js +0 -265
  166. package/dist/metrics/clientMiddleware.js.map +0 -1
  167. package/dist/metrics/config/defaults.d.ts +0 -61
  168. package/dist/metrics/config/defaults.js +0 -63
  169. package/dist/metrics/config/defaults.js.map +0 -1
  170. package/dist/metrics/index.js +0 -152
  171. package/dist/metrics/index.js.map +0 -1
  172. package/dist/modules/forms/index.d.ts +0 -6
  173. package/dist/modules/forms/index.js +0 -32
  174. package/dist/modules/forms/index.js.map +0 -1
  175. package/dist/modules/functions/index.d.ts +0 -6
  176. package/dist/modules/functions/index.js +0 -32
  177. package/dist/modules/functions/index.js.map +0 -1
  178. package/dist/protoUtils/forms.js.map +0 -1
  179. package/dist/protoUtils/functions.d.ts +0 -58
  180. package/dist/protoUtils/functions.js +0 -119
  181. package/dist/protoUtils/functions.js.map +0 -1
  182. package/dist/routing/ConduitRouteReturn.js.map +0 -1
  183. package/dist/routing/ProxyRouteBuilder.d.ts +0 -21
  184. package/dist/routing/ProxyRouteBuilder.js +0 -81
  185. package/dist/routing/ProxyRouteBuilder.js.map +0 -1
  186. package/dist/routing/RouteBuilder.d.ts +0 -24
  187. package/dist/routing/RouteBuilder.js +0 -107
  188. package/dist/routing/RouteBuilder.js.map +0 -1
  189. package/dist/routing/RoutingManager.d.ts +0 -33
  190. package/dist/routing/RoutingManager.js +0 -201
  191. package/dist/routing/RoutingManager.js.map +0 -1
  192. package/dist/routing/RoutingUtilities.d.ts +0 -7
  193. package/dist/routing/RoutingUtilities.js +0 -13
  194. package/dist/routing/RoutingUtilities.js.map +0 -1
  195. package/dist/routing/index.d.ts +0 -7
  196. package/dist/routing/index.js +0 -24
  197. package/dist/routing/index.js.map +0 -1
  198. package/dist/routing/interfaces/ConduitMiddleware.js.map +0 -1
  199. package/dist/routing/interfaces/ConduitRoute.js.map +0 -1
  200. package/dist/routing/interfaces/ProxyRoute.js.map +0 -1
  201. package/dist/routing/interfaces/Route.d.ts +0 -66
  202. package/dist/routing/interfaces/Route.js +0 -21
  203. package/dist/routing/interfaces/Route.js.map +0 -1
  204. package/dist/routing/interfaces/Socket.js.map +0 -1
  205. package/dist/routing/interfaces/index.d.ts +0 -6
  206. package/dist/routing/interfaces/index.js.map +0 -1
  207. package/dist/routing/wrapRouterFunctions.d.ts +0 -8
  208. package/dist/routing/wrapRouterFunctions.js +0 -131
  209. package/dist/routing/wrapRouterFunctions.js.map +0 -1
  210. package/dist/utilities/Logger.js +0 -255
  211. package/dist/utilities/Logger.js.map +0 -1
  212. package/dist/utilities/linearBackoffTimeout.d.ts +0 -10
  213. package/dist/utilities/linearBackoffTimeout.js +0 -119
  214. package/dist/utilities/linearBackoffTimeout.js.map +0 -1
  215. package/dist/utilities/merge.d.ts +0 -1
  216. package/dist/utilities/merge.js +0 -15
  217. package/dist/utilities/merge.js.map +0 -1
  218. /package/dist/{routing/interfaces → interfaces}/ConduitMiddleware.d.ts +0 -0
  219. /package/dist/{routing/interfaces → interfaces}/ConduitMiddleware.js +0 -0
  220. /package/dist/{routing/interfaces → interfaces}/ConduitRoute.js +0 -0
  221. /package/dist/{routing → interfaces}/ConduitRouteReturn.js +0 -0
  222. /package/dist/{routing/interfaces → interfaces}/ProxyRoute.d.ts +0 -0
  223. /package/dist/{routing/interfaces → interfaces}/ProxyRoute.js +0 -0
  224. /package/dist/{routing/interfaces → interfaces}/Socket.js +0 -0
  225. /package/dist/{routing/interfaces → interfaces}/types.js +0 -0
@@ -1,333 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
- return new (P || (P = Promise))(function (resolve, reject) {
43
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
- step((generator = generator.apply(thisArg, _arguments || [])).next());
47
- });
48
- };
49
- var __generator = (this && this.__generator) || function (thisArg, body) {
50
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
51
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
52
- function verb(n) { return function (v) { return step([n, v]); }; }
53
- function step(op) {
54
- if (f) throw new TypeError("Generator is already executing.");
55
- while (_) try {
56
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
57
- if (y = 0, t) op = [op[0] & 2, t.value];
58
- switch (op[0]) {
59
- case 0: case 1: t = op; break;
60
- case 4: _.label++; return { value: op[1], done: false };
61
- case 5: _.label++; y = op[1]; op = [0]; continue;
62
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
63
- default:
64
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
65
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
66
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
67
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
68
- if (t[2]) _.ops.pop();
69
- _.trys.pop(); continue;
70
- }
71
- op = body.call(thisArg, _);
72
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
73
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
74
- }
75
- };
76
- var __importDefault = (this && this.__importDefault) || function (mod) {
77
- return (mod && mod.__esModule) ? mod : { "default": mod };
78
- };
79
- Object.defineProperty(exports, "__esModule", { value: true });
80
- exports.ManagedModule = void 0;
81
- var __1 = __importStar(require(".."));
82
- var ConduitServiceModule_1 = require("./ConduitServiceModule");
83
- var ConfigController_1 = require("./ConfigController");
84
- var lodash_1 = require("lodash");
85
- var grpc_js_1 = require("@grpc/grpc-js");
86
- var convict_1 = __importDefault(require("convict"));
87
- var ManagedModule = /** @class */ (function (_super) {
88
- __extends(ManagedModule, _super);
89
- function ManagedModule(moduleName) {
90
- var _this = _super.call(this, moduleName) || this;
91
- _this.configOverride = false;
92
- return _this;
93
- }
94
- Object.defineProperty(ManagedModule.prototype, "name", {
95
- get: function () {
96
- return this._moduleName;
97
- },
98
- enumerable: false,
99
- configurable: true
100
- });
101
- Object.defineProperty(ManagedModule.prototype, "address", {
102
- get: function () {
103
- return this._address;
104
- },
105
- enumerable: false,
106
- configurable: true
107
- });
108
- /**
109
- * This is the first function triggered on module spin up.
110
- * @param grpcSdk {ConduitGrpcSdk}
111
- * @param address {string} external address:port of service (LoadBalancer)
112
- * @param port {string} port to bring up gRPC service
113
- */
114
- ManagedModule.prototype.initialize = function (grpcSdk, address, port) {
115
- this.grpcSdk = grpcSdk;
116
- this._address = address;
117
- this._port = port;
118
- if (this.configSchema) {
119
- this.config = (0, convict_1.default)(this.configSchema);
120
- }
121
- };
122
- /**
123
- * This is triggered before spinning up the Grpc Server
124
- * of the module. On this stage, the redis bus and state have
125
- * not yet been initialized, and only communications with Conduit core
126
- * have been established.
127
- */
128
- ManagedModule.prototype.preServerStart = function () {
129
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
130
- return [2 /*return*/];
131
- }); });
132
- };
133
- /**
134
- * This is triggered right after Grpc Server start.
135
- * At this stage the core module will communicate with your service
136
- * for health checks, and the Bus and State management mechanics
137
- * are online and available.
138
- */
139
- ManagedModule.prototype.onServerStart = function () {
140
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
141
- return [2 /*return*/];
142
- }); });
143
- };
144
- /**
145
- * Triggers right before registering the module with Conduit Core.
146
- */
147
- ManagedModule.prototype.preRegister = function () {
148
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
149
- return [2 /*return*/];
150
- }); });
151
- };
152
- /**
153
- * Triggers when module has been registered with Conduit Core
154
- * This is the step where you should initialize your
155
- * module's general routing (admin or client) and any other operation,
156
- * that would require other modules being able to reach you
157
- */
158
- ManagedModule.prototype.onRegister = function () {
159
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
160
- return [2 /*return*/];
161
- }); });
162
- };
163
- /**
164
- * This is triggered when the module receives new configuration.
165
- * At this step the configuration has not been checked yet,
166
- * and has only been parsed.
167
- * @param config
168
- */
169
- ManagedModule.prototype.preConfig = function (config) {
170
- return __awaiter(this, void 0, void 0, function () {
171
- return __generator(this, function (_a) {
172
- return [2 /*return*/, config];
173
- });
174
- });
175
- };
176
- /**
177
- * This is triggered when new configuration has been applied.
178
- * This happens either when changes are being made on the configuration,
179
- * or on module start up, where the config is recovered from the database.
180
- * In either case the configuration is now available through the
181
- * Config Controller of the sdk.
182
- */
183
- ManagedModule.prototype.onConfig = function () {
184
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
185
- return [2 /*return*/];
186
- }); });
187
- };
188
- /**
189
- * Registers common and module-specific metric types.
190
- */
191
- ManagedModule.prototype.registerMetrics = function () {
192
- return __awaiter(this, void 0, void 0, function () {
193
- return __generator(this, function (_a) {
194
- if (__1.default.Metrics) {
195
- __1.default.Metrics.initializeDefaultMetrics();
196
- if (this.metricsSchema) {
197
- Object.values(this.metricsSchema).forEach(function (metric) {
198
- __1.default.Metrics.registerMetric(metric.type, metric.config);
199
- });
200
- }
201
- }
202
- return [2 /*return*/];
203
- });
204
- });
205
- };
206
- /**
207
- * Initializes metric startup values.
208
- * Implemented by individual modules.
209
- */
210
- ManagedModule.prototype.initializeMetrics = function () {
211
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
212
- return [2 /*return*/];
213
- }); });
214
- };
215
- ManagedModule.prototype.createGrpcServer = function () {
216
- return __awaiter(this, void 0, void 0, function () {
217
- var _a;
218
- return __generator(this, function (_b) {
219
- switch (_b.label) {
220
- case 0:
221
- this.grpcServer = new __1.GrpcServer(this._port);
222
- _a = this;
223
- return [4 /*yield*/, this.grpcServer.createNewServer()];
224
- case 1:
225
- _a._port = (_b.sent()).toString();
226
- return [2 /*return*/];
227
- }
228
- });
229
- });
230
- };
231
- ManagedModule.prototype.startGrpcServer = function () {
232
- return __awaiter(this, void 0, void 0, function () {
233
- return __generator(this, function (_a) {
234
- switch (_a.label) {
235
- case 0:
236
- if (!this.service) return [3 /*break*/, 4];
237
- this._serviceName = this.service.protoDescription.substring(this.service.protoDescription.indexOf('.') + 1);
238
- return [4 /*yield*/, this.grpcServer.addService(this.service.protoPath, this.service.protoDescription, this.service.functions)];
239
- case 1:
240
- _a.sent();
241
- return [4 /*yield*/, this.addHealthCheckService()];
242
- case 2:
243
- _a.sent();
244
- return [4 /*yield*/, this.grpcServer.start()];
245
- case 3:
246
- _a.sent();
247
- __1.default.Logger.log('gRPC server listening on ' + this._port);
248
- _a.label = 4;
249
- case 4: return [2 /*return*/];
250
- }
251
- });
252
- });
253
- };
254
- ManagedModule.prototype.setConfig = function (call, callback) {
255
- var _a;
256
- return __awaiter(this, void 0, void 0, function () {
257
- var config, previousConfig, e_1;
258
- return __generator(this, function (_b) {
259
- switch (_b.label) {
260
- case 0:
261
- _b.trys.push([0, 3, , 4]);
262
- if (!this.config) {
263
- return [2 /*return*/, callback({
264
- code: grpc_js_1.status.INVALID_ARGUMENT,
265
- message: 'Module is not configurable',
266
- })];
267
- }
268
- config = JSON.parse(call.request.newConfig);
269
- config = (0, __1.merge)(this.config.getProperties(), config);
270
- return [4 /*yield*/, this.preConfig(config)];
271
- case 1:
272
- config = _b.sent();
273
- previousConfig = this.config.getProperties();
274
- try {
275
- this.config.load(config).validate({
276
- allowed: 'strict',
277
- });
278
- config = this.config.getProperties();
279
- callback(null, { updatedConfig: JSON.stringify(config) });
280
- }
281
- catch (e) {
282
- this.config = (0, convict_1.default)(this.configSchema);
283
- this.config.load(previousConfig);
284
- return [2 /*return*/, callback({
285
- code: grpc_js_1.status.INVALID_ARGUMENT,
286
- message: 'Invalid configuration values: ' + e.message,
287
- })];
288
- }
289
- ConfigController_1.ConfigController.getInstance().config = config;
290
- return [4 /*yield*/, this.onConfig()];
291
- case 2:
292
- _b.sent();
293
- (_a = this.grpcSdk.bus) === null || _a === void 0 ? void 0 : _a.publish((0, lodash_1.kebabCase)(this.name) + ':config:update', JSON.stringify(config));
294
- return [3 /*break*/, 4];
295
- case 3:
296
- e_1 = _b.sent();
297
- return [2 /*return*/, callback({ code: grpc_js_1.status.INTERNAL, message: e_1.message })];
298
- case 4: return [2 /*return*/];
299
- }
300
- });
301
- });
302
- };
303
- /** Used to update the module's configuration on initial Redis/DB reconciliation. */
304
- ManagedModule.prototype.handleConfigSyncUpdate = function () {
305
- return __awaiter(this, void 0, void 0, function () {
306
- var _this = this;
307
- return __generator(this, function (_a) {
308
- if (!this.config)
309
- return [2 /*return*/];
310
- this.grpcSdk.bus.subscribe("".concat(this.name, ":config:update"), function (message) { return __awaiter(_this, void 0, void 0, function () {
311
- var _a;
312
- return __generator(this, function (_b) {
313
- switch (_b.label) {
314
- case 0:
315
- _a = ConfigController_1.ConfigController.getInstance();
316
- return [4 /*yield*/, this.preConfig(JSON.parse(message))];
317
- case 1:
318
- _a.config = _b.sent();
319
- return [4 /*yield*/, this.onConfig()];
320
- case 2:
321
- _b.sent();
322
- return [2 /*return*/];
323
- }
324
- });
325
- }); });
326
- return [2 /*return*/];
327
- });
328
- });
329
- };
330
- return ManagedModule;
331
- }(ConduitServiceModule_1.ConduitServiceModule));
332
- exports.ManagedModule = ManagedModule;
333
- //# sourceMappingURL=ManagedModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ManagedModule.js","sourceRoot":"","sources":["../../src/classes/ManagedModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAMY;AACZ,+DAA8D;AAC9D,uDAAsD;AACtD,iCAAmC;AACnC,yCAAuC;AACvC,oDAA8B;AAE9B;IAA+C,iCAAoB;IAOjE,uBAAsB,UAAkB;QAAxC,YACE,kBAAM,UAAU,CAAC,SAClB;QALD,oBAAc,GAAY,KAAK,CAAC;;IAKhC,CAAC;IAED,sBAAI,+BAAI;aAAR;YACE,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;;;OAAA;IAED,sBAAI,kCAAO;aAAX;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;;;OAAA;IAED;;;;;OAKG;IACH,kCAAU,GAAV,UAAW,OAAuB,EAAE,OAAe,EAAE,IAAY;QAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,IAAI,CAAC,YAAY,EAAE;YACpB,IAAI,CAAC,MAAkB,GAAG,IAAA,iBAAO,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACvD;IACH,CAAC;IAED;;;;;OAKG;IACG,sCAAc,GAApB;;;;KAAyB;IAEzB;;;;;OAKG;IACG,qCAAa,GAAnB;;;;KAAwB;IAExB;;OAEG;IACG,mCAAW,GAAjB;;;;KAAsB;IAEtB;;;;;OAKG;IACG,kCAAU,GAAhB;;;;KAAqB;IAErB;;;;;OAKG;IACG,iCAAS,GAAf,UAAgB,MAAS;;;gBACvB,sBAAO,MAAM,EAAC;;;KACf;IAED;;;;;;OAMG;IACG,gCAA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IAAI,EAAE,gBAAM,CAAC,gBAAgB;oCAC7B,OAAO,EAAE,gCAAgC,GAAI,CAAW,CAAC,OAAO;iCACjE,CAAC,EAAC;yBACJ;wBACD,mCAAgB,CAAC,WAAW,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;wBAC/C,qBAAM,IAAI,CAAC,QAAQ,EAAE,EAAA;;wBAArB,SAAqB,CAAC;wBACtB,MAAA,IAAI,CAAC,OAAO,CAAC,GAAG,0CAAE,OAAO,CACvB,IAAA,kBAAS,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,EACvC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CACvB,CAAC;;;;wBAEF,sBAAO,QAAQ,CAAC,EAAE,IAAI,EAAE,gBAAM,CAAC,QAAQ,EAAE,OAAO,EAAG,GAAW,CAAC,OAAO,EAAE,CAAC,EAAC;;;;;KAE7E;IAED,oFAAoF;IAC9E,8CAAsB,GAA5B;;;;gBACE,IAAI,CAAC,IAAI,CAAC,MAAM;oBAAE,sBAAO;gBACzB,IAAI,CAAC,OAAO,CAAC,GAAI,CAAC,SAAS,CAAC,UAAG,IAAI,CAAC,IAAI,mBAAgB,EAAE,UAAM,OAAO;;;;;gCACrE,KAAA,mCAAgB,CAAC,WAAW,EAAE,CAAA;gCAAU,qBAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAA;;gCAAjF,GAA+B,MAAM,GAAG,SAAyC,CAAC;gCAClF,qBAAM,IAAI,CAAC,QAAQ,EAAE,EAAA;;gCAArB,SAAqB,CAAC;;;;qBACvB,CAAC,CAAC;;;;KACJ;IACH,oBAAC;AAAD,CAAC,AAxKD,CAA+C,2CAAoB,GAwKlE;AAxKqB,sCAAa"}
@@ -1,11 +0,0 @@
1
- import { ManagedModule } from '..';
2
- export declare class ModuleManager<T> {
3
- private readonly module;
4
- private readonly serviceAddress;
5
- private readonly servicePort;
6
- private readonly grpcSdk;
7
- constructor(module: ManagedModule<T>);
8
- start(): Promise<void>;
9
- private preRegisterLifecycle;
10
- private postRegisterLifecycle;
11
- }
@@ -1,205 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (_) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.ModuleManager = void 0;
63
- var __1 = __importStar(require(".."));
64
- var convictConfigParser = function (config) {
65
- if (typeof config === 'object') {
66
- Object.keys(config).forEach(function (key) {
67
- if (key === '_cvtProperties') {
68
- config = convictConfigParser(config._cvtProperties);
69
- }
70
- else {
71
- config[key] = convictConfigParser(config[key]);
72
- }
73
- });
74
- }
75
- return config;
76
- };
77
- var ModuleManager = /** @class */ (function () {
78
- function ModuleManager(module) {
79
- var _this = this;
80
- var _a;
81
- this.module = module;
82
- if (!process.env.CONDUIT_SERVER) {
83
- throw new Error('CONDUIT_SERVER is undefined, specify Conduit server URL');
84
- }
85
- this.servicePort = (_a = process.env.GRPC_PORT) !== null && _a !== void 0 ? _a : '5000';
86
- this.serviceAddress =
87
- // @compat (v0.15): SERVICE_IP -> SERVICE_URL
88
- process.env.SERVICE_URL || process.env.SERVICE_IP || '0.0.0.0:' + this.servicePort;
89
- var urlRemap = process.env.URL_REMAP;
90
- try {
91
- this.grpcSdk = new __1.default(process.env.CONDUIT_SERVER, function () {
92
- return _this.module.healthState;
93
- }, module.name, true, urlRemap);
94
- }
95
- catch (_b) {
96
- throw new Error('Failed to initialize grpcSdk');
97
- }
98
- }
99
- ModuleManager.prototype.start = function () {
100
- return __awaiter(this, void 0, void 0, function () {
101
- var err_1;
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0: return [4 /*yield*/, this.grpcSdk.initialize()];
105
- case 1:
106
- _a.sent();
107
- this.module.initialize(this.grpcSdk, this.serviceAddress, this.servicePort);
108
- _a.label = 2;
109
- case 2:
110
- _a.trys.push([2, 5, , 6]);
111
- return [4 /*yield*/, this.preRegisterLifecycle()];
112
- case 3:
113
- _a.sent();
114
- return [4 /*yield*/, this.grpcSdk.config.registerModule(this.module.name, this.module.address, this.module.healthState)];
115
- case 4:
116
- _a.sent();
117
- return [3 /*break*/, 6];
118
- case 5:
119
- err_1 = _a.sent();
120
- __1.default.Logger.error('Failed to initialize server');
121
- __1.default.Logger.error(err_1);
122
- process.exit(-1);
123
- return [3 /*break*/, 6];
124
- case 6: return [4 /*yield*/, this.postRegisterLifecycle().catch(function (err) {
125
- __1.default.Logger.error('Failed to activate module');
126
- __1.default.Logger.error(err);
127
- process.exit(-1);
128
- })];
129
- case 7:
130
- _a.sent();
131
- return [2 /*return*/];
132
- }
133
- });
134
- });
135
- };
136
- ModuleManager.prototype.preRegisterLifecycle = function () {
137
- return __awaiter(this, void 0, void 0, function () {
138
- return __generator(this, function (_a) {
139
- switch (_a.label) {
140
- case 0: return [4 /*yield*/, this.module.createGrpcServer()];
141
- case 1:
142
- _a.sent();
143
- return [4 /*yield*/, this.module.preServerStart()];
144
- case 2:
145
- _a.sent();
146
- return [4 /*yield*/, this.grpcSdk.initializeEventBus()];
147
- case 3:
148
- _a.sent();
149
- return [4 /*yield*/, this.module.handleConfigSyncUpdate()];
150
- case 4:
151
- _a.sent();
152
- return [4 /*yield*/, this.module.registerMetrics()];
153
- case 5:
154
- _a.sent();
155
- return [4 /*yield*/, this.module.startGrpcServer()];
156
- case 6:
157
- _a.sent();
158
- return [4 /*yield*/, this.module.onServerStart()];
159
- case 7:
160
- _a.sent();
161
- return [4 /*yield*/, this.module.initializeMetrics()];
162
- case 8:
163
- _a.sent();
164
- return [4 /*yield*/, this.module.preRegister()];
165
- case 9:
166
- _a.sent();
167
- return [2 /*return*/];
168
- }
169
- });
170
- });
171
- };
172
- ModuleManager.prototype.postRegisterLifecycle = function () {
173
- return __awaiter(this, void 0, void 0, function () {
174
- var configSchema, config;
175
- return __generator(this, function (_a) {
176
- switch (_a.label) {
177
- case 0: return [4 /*yield*/, this.module.onRegister()];
178
- case 1:
179
- _a.sent();
180
- if (!this.module.config) return [3 /*break*/, 5];
181
- configSchema = this.module.config.getSchema();
182
- config = this.module.config.getProperties();
183
- return [4 /*yield*/, this.module.preConfig(config)];
184
- case 2:
185
- config = _a.sent();
186
- return [4 /*yield*/, this.grpcSdk.config.configure(config, convictConfigParser(configSchema), this.module.configOverride)];
187
- case 3:
188
- config = _a.sent();
189
- __1.ConfigController.getInstance();
190
- if (config)
191
- __1.ConfigController.getInstance().config = config;
192
- if (!(!config || config.active || !config.hasOwnProperty('active'))) return [3 /*break*/, 5];
193
- return [4 /*yield*/, this.module.onConfig()];
194
- case 4:
195
- _a.sent();
196
- _a.label = 5;
197
- case 5: return [2 /*return*/];
198
- }
199
- });
200
- });
201
- };
202
- return ModuleManager;
203
- }());
204
- exports.ModuleManager = ModuleManager;
205
- //# sourceMappingURL=ModuleManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModuleManager.js","sourceRoot":"","sources":["../../src/class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,oBAAgB,CAAC,WAAW,EAAE,CAAC;wBAC/B,IAAI,MAAM;4BAAE,oBAAgB,CAAC,WAAW,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;6BACvD,CAAA,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAA,EAA5D,wBAA4D;wBAC9D,qBAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAA;;wBAA5B,SAA4B,CAAC;;;;;;KAElC;IACH,oBAAC;AAAD,CAAC,AAnFD,IAmFC;AAnFY,sCAAa"}
@@ -1,8 +0,0 @@
1
- import { Server } from '@grpc/grpc-js';
2
- export declare function createServer(port: string): Promise<{
3
- server: Server;
4
- port: number;
5
- }>;
6
- export declare function addServiceToServer(server: Server, protoPath: string, descriptorObject: string, functions: {
7
- [name: string]: Function;
8
- }): void;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addServiceToServer = exports.createServer = void 0;
4
- var grpc_js_1 = require("@grpc/grpc-js");
5
- var protoLoader = require('@grpc/proto-loader');
6
- function createServer(port) {
7
- var grpcServer = new grpc_js_1.Server({
8
- 'grpc.max_receive_message_length': 1024 * 1024 * 100,
9
- 'grpc.max_send_message_length': 1024 * 1024 * 100,
10
- });
11
- return new Promise(function (resolve, reject) {
12
- grpcServer.bindAsync(port, grpc_js_1.ServerCredentials.createInsecure(), function (err, port) {
13
- if (err) {
14
- reject(err);
15
- }
16
- else {
17
- resolve({
18
- server: grpcServer,
19
- port: port,
20
- });
21
- }
22
- });
23
- });
24
- }
25
- exports.createServer = createServer;
26
- function addServiceToServer(server, protoPath, descriptorObject, functions) {
27
- var packageDefinition = protoLoader.loadSync(protoPath, {
28
- keepCase: true,
29
- longs: String,
30
- enums: String,
31
- defaults: true,
32
- oneofs: true,
33
- });
34
- var protoDescriptor = (0, grpc_js_1.loadPackageDefinition)(packageDefinition);
35
- var objs = descriptorObject.split('.');
36
- var descObj = protoDescriptor;
37
- objs.forEach(function (r) {
38
- descObj = descObj[r];
39
- });
40
- // @ts-ignore
41
- server.addService(descObj.service, functions);
42
- }
43
- exports.addServiceToServer = addServiceToServer;
44
- //# sourceMappingURL=GrpcHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GrpcHelper.js","sourceRoot":"","sources":["../../src/helpers/GrpcHelper.ts"],"names":[],"mappings":";;;AAAA,yCAAiF;AAEjF,IAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,SAAgB,YAAY,CAAC,IAAY;IACvC,IAAM,UAAU,GAAW,IAAI,gBAAM,CAAC;QACpC,iCAAiC,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;QACpD,8BAA8B,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;KAClD,CAAC,CAAC;IACH,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QACjC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,2BAAiB,CAAC,cAAc,EAAE,EAAE,UAAC,GAAG,EAAE,IAAI;YACvE,IAAI,GAAG,EAAE;gBACP,MAAM,CAAC,GAAG,CAAC,CAAC;aACb;iBAAM;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,UAAU;oBAClB,IAAI,MAAA;iBACL,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,oCAiBC;AAED,SAAgB,kBAAkB,CAChC,MAAc,EACd,SAAiB,EACjB,gBAAwB,EACxB,SAAuC;IAEvC,IAAM,iBAAiB,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE;QACxD,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IACH,IAAM,eAAe,GAAG,IAAA,+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