@common-stack/server-stack 7.0.4-alpha.17 → 7.0.4-alpha.18

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 (167) hide show
  1. package/lib/MainStackServer.cjs +231 -0
  2. package/lib/MainStackServer.cjs.map +1 -0
  3. package/lib/MainStackServer.d.ts +28 -0
  4. package/lib/MainStackServer.mjs +231 -0
  5. package/lib/MainStackServer.mjs.map +1 -0
  6. package/lib/StackServer.cjs +92 -0
  7. package/lib/StackServer.cjs.map +1 -0
  8. package/lib/StackServer.d.ts +20 -0
  9. package/lib/StackServer.mjs +92 -0
  10. package/lib/StackServer.mjs.map +1 -0
  11. package/lib/api/remote-config.cjs +6 -0
  12. package/lib/api/remote-config.cjs.map +1 -0
  13. package/lib/api/remote-config.d.ts +6 -0
  14. package/lib/api/remote-config.mjs +6 -0
  15. package/lib/api/remote-config.mjs.map +1 -0
  16. package/lib/api/resolver.cjs +12 -0
  17. package/lib/api/resolver.cjs.map +1 -0
  18. package/lib/api/resolver.d.ts +10 -0
  19. package/lib/api/resolver.mjs +12 -0
  20. package/lib/api/resolver.mjs.map +1 -0
  21. package/lib/api/root-schema.graphqls.cjs +2 -0
  22. package/lib/api/root-schema.graphqls.cjs.map +1 -0
  23. package/lib/api/root-schema.graphqls.mjs +2 -0
  24. package/lib/api/root-schema.graphqls.mjs.map +1 -0
  25. package/lib/api/scalar.cjs +16 -0
  26. package/lib/api/scalar.cjs.map +1 -0
  27. package/lib/api/scalar.d.ts +2 -0
  28. package/lib/api/scalar.mjs +16 -0
  29. package/lib/api/scalar.mjs.map +1 -0
  30. package/lib/api/schema-builder.cjs +160 -0
  31. package/lib/api/schema-builder.cjs.map +1 -0
  32. package/lib/api/schema-builder.d.ts +24 -0
  33. package/lib/api/schema-builder.mjs +160 -0
  34. package/lib/api/schema-builder.mjs.map +1 -0
  35. package/lib/api/utils.cjs +27 -0
  36. package/lib/api/utils.cjs.map +1 -0
  37. package/lib/api/utils.d.ts +4 -0
  38. package/lib/api/utils.mjs +27 -0
  39. package/lib/api/utils.mjs.map +1 -0
  40. package/lib/config/env-config.cjs +38 -0
  41. package/lib/config/env-config.cjs.map +1 -0
  42. package/lib/config/env-config.d.ts +21 -0
  43. package/lib/config/env-config.mjs +38 -0
  44. package/lib/config/env-config.mjs.map +1 -0
  45. package/lib/config/index.d.ts +1 -0
  46. package/lib/config/moleculer.config.cjs +191 -0
  47. package/lib/config/moleculer.config.cjs.map +1 -0
  48. package/lib/config/moleculer.config.d.ts +20 -0
  49. package/lib/config/moleculer.config.mjs +191 -0
  50. package/lib/config/moleculer.config.mjs.map +1 -0
  51. package/lib/connectors/connection-broker.cjs +61 -0
  52. package/lib/connectors/connection-broker.cjs.map +1 -0
  53. package/lib/connectors/connection-broker.d.ts +26 -0
  54. package/lib/connectors/connection-broker.mjs +61 -0
  55. package/lib/connectors/connection-broker.mjs.map +1 -0
  56. package/lib/connectors/graphql-pubsub-connector.cjs +28 -0
  57. package/lib/connectors/graphql-pubsub-connector.cjs.map +1 -0
  58. package/lib/connectors/graphql-pubsub-connector.d.ts +22 -0
  59. package/lib/connectors/graphql-pubsub-connector.mjs +28 -0
  60. package/lib/connectors/graphql-pubsub-connector.mjs.map +1 -0
  61. package/lib/connectors/mongo-connector.cjs +57 -0
  62. package/lib/connectors/mongo-connector.cjs.map +1 -0
  63. package/lib/connectors/mongo-connector.d.ts +21 -0
  64. package/lib/connectors/mongo-connector.mjs +57 -0
  65. package/lib/connectors/mongo-connector.mjs.map +1 -0
  66. package/lib/connectors/nats-connector.cjs +63 -0
  67. package/lib/connectors/nats-connector.cjs.map +1 -0
  68. package/lib/connectors/nats-connector.d.ts +20 -0
  69. package/lib/connectors/nats-connector.mjs +63 -0
  70. package/lib/connectors/nats-connector.mjs.map +1 -0
  71. package/lib/connectors/redis-connector.cjs +79 -0
  72. package/lib/connectors/redis-connector.cjs.map +1 -0
  73. package/lib/connectors/redis-connector.d.ts +30 -0
  74. package/lib/connectors/redis-connector.mjs +79 -0
  75. package/lib/connectors/redis-connector.mjs.map +1 -0
  76. package/lib/graphql/directives/index.cjs +10 -0
  77. package/lib/graphql/directives/index.cjs.map +1 -0
  78. package/lib/graphql/directives/index.d.ts +7 -0
  79. package/lib/graphql/directives/index.mjs +10 -0
  80. package/lib/graphql/directives/index.mjs.map +1 -0
  81. package/lib/graphql/index.d.ts +2 -0
  82. package/lib/graphql/schema/directives.graphql.cjs +1 -0
  83. package/lib/graphql/schema/directives.graphql.cjs.map +1 -0
  84. package/lib/graphql/schema/directives.graphql.mjs +1 -0
  85. package/lib/graphql/schema/directives.graphql.mjs.map +1 -0
  86. package/lib/graphql/schema/index.cjs +1 -0
  87. package/lib/graphql/schema/index.cjs.map +1 -0
  88. package/lib/graphql/schema/index.d.ts +1 -0
  89. package/lib/graphql/schema/index.mjs +1 -0
  90. package/lib/graphql/schema/index.mjs.map +1 -0
  91. package/lib/index.cjs +1 -0
  92. package/lib/index.cjs.map +1 -0
  93. package/lib/index.d.ts +3 -0
  94. package/lib/index.mjs +1 -0
  95. package/lib/index.mjs.map +1 -0
  96. package/lib/interfaces/dbMigration.d.ts +8 -0
  97. package/lib/interfaces/graphql-request-context.d.ts +15 -0
  98. package/lib/interfaces/index.d.ts +4 -0
  99. package/lib/interfaces/module-interface.d.ts +13 -0
  100. package/lib/interfaces/moleculer.d.ts +7 -0
  101. package/lib/middleware/cors.cjs +26 -0
  102. package/lib/middleware/cors.cjs.map +1 -0
  103. package/lib/middleware/cors.d.ts +6 -0
  104. package/lib/middleware/cors.mjs +26 -0
  105. package/lib/middleware/cors.mjs.map +1 -0
  106. package/lib/middleware/error.cjs +18 -0
  107. package/lib/middleware/error.cjs.map +1 -0
  108. package/lib/middleware/error.d.ts +9 -0
  109. package/lib/middleware/error.mjs +18 -0
  110. package/lib/middleware/error.mjs.map +1 -0
  111. package/lib/middleware/moleculer-inter-namespace.cjs +44 -0
  112. package/lib/middleware/moleculer-inter-namespace.cjs.map +1 -0
  113. package/lib/middleware/moleculer-inter-namespace.d.ts +2 -0
  114. package/lib/middleware/moleculer-inter-namespace.mjs +44 -0
  115. package/lib/middleware/moleculer-inter-namespace.mjs.map +1 -0
  116. package/lib/middleware/sentry.cjs +3 -0
  117. package/lib/middleware/sentry.cjs.map +1 -0
  118. package/lib/middleware/sentry.d.ts +2 -0
  119. package/lib/middleware/sentry.mjs +3 -0
  120. package/lib/middleware/sentry.mjs.map +1 -0
  121. package/lib/middleware/services.cjs +12 -0
  122. package/lib/middleware/services.cjs.map +1 -0
  123. package/lib/middleware/services.d.ts +2 -0
  124. package/lib/middleware/services.mjs +12 -0
  125. package/lib/middleware/services.mjs.map +1 -0
  126. package/lib/plugins/index.d.ts +2 -0
  127. package/lib/plugins/invalidateCachePlugin.cjs +63 -0
  128. package/lib/plugins/invalidateCachePlugin.cjs.map +1 -0
  129. package/lib/plugins/invalidateCachePlugin.d.ts +8 -0
  130. package/lib/plugins/invalidateCachePlugin.mjs +63 -0
  131. package/lib/plugins/invalidateCachePlugin.mjs.map +1 -0
  132. package/lib/plugins/invalidateCachePlugin.test.d.ts +1 -0
  133. package/lib/plugins/response-cache-plugin.test.d.ts +1 -0
  134. package/lib/plugins/responseCachePlugin.cjs +63 -0
  135. package/lib/plugins/responseCachePlugin.cjs.map +1 -0
  136. package/lib/plugins/responseCachePlugin.d.ts +12 -0
  137. package/lib/plugins/responseCachePlugin.mjs +63 -0
  138. package/lib/plugins/responseCachePlugin.mjs.map +1 -0
  139. package/lib/servers/ExpressApp.cjs +37 -0
  140. package/lib/servers/ExpressApp.cjs.map +1 -0
  141. package/lib/servers/ExpressApp.d.ts +3 -0
  142. package/lib/servers/ExpressApp.mjs +37 -0
  143. package/lib/servers/ExpressApp.mjs.map +1 -0
  144. package/lib/servers/GraphqlServer.cjs +142 -0
  145. package/lib/servers/GraphqlServer.cjs.map +1 -0
  146. package/lib/servers/GraphqlServer.d.ts +23 -0
  147. package/lib/servers/GraphqlServer.mjs +142 -0
  148. package/lib/servers/GraphqlServer.mjs.map +1 -0
  149. package/lib/servers/GraphqlWs.cjs +97 -0
  150. package/lib/servers/GraphqlWs.cjs.map +1 -0
  151. package/lib/servers/GraphqlWs.d.ts +14 -0
  152. package/lib/servers/GraphqlWs.mjs +97 -0
  153. package/lib/servers/GraphqlWs.mjs.map +1 -0
  154. package/lib/servers/WebsocketMultipathUpdate.cjs +63 -0
  155. package/lib/servers/WebsocketMultipathUpdate.cjs.map +1 -0
  156. package/lib/servers/WebsocketMultipathUpdate.d.ts +18 -0
  157. package/lib/servers/WebsocketMultipathUpdate.mjs +63 -0
  158. package/lib/servers/WebsocketMultipathUpdate.mjs.map +1 -0
  159. package/lib/servers/mongodb-migration-update.d.ts +12 -0
  160. package/lib/servers/utils.d.ts +14 -0
  161. package/lib/utils/index.d.ts +1 -0
  162. package/lib/utils/migrations.cjs +26 -0
  163. package/lib/utils/migrations.cjs.map +1 -0
  164. package/lib/utils/migrations.d.ts +8 -0
  165. package/lib/utils/migrations.mjs +26 -0
  166. package/lib/utils/migrations.mjs.map +1 -0
  167. package/package.json +2 -2
@@ -0,0 +1,27 @@
1
+ 'use strict';var graphql=require('graphql'),utils=require('@graphql-tools/utils');function attachDirectiveResolvers(schema, directiveResolvers) {
2
+ // ... argument validation ...
3
+ return utils.mapSchema(schema, {
4
+ [utils.MapperKind.OBJECT_FIELD]: (fieldConfig) => {
5
+ const newFieldConfig = { ...fieldConfig };
6
+ const directives = utils.getDirectives(schema, fieldConfig);
7
+ for (const directive of directives) {
8
+ const directiveName = directive.name;
9
+ if (directiveResolvers[directiveName]) {
10
+ const resolver = directiveResolvers[directiveName];
11
+ const originalResolver = newFieldConfig.resolve != null ? newFieldConfig.resolve : graphql.defaultFieldResolver;
12
+ const directiveArgs = directive.args;
13
+ newFieldConfig.resolve = (source, originalArgs, context, info) => {
14
+ return resolver(() => new Promise((resolve, reject) => {
15
+ const result = originalResolver(source, originalArgs, context, info);
16
+ if (result instanceof Error) {
17
+ reject(result);
18
+ }
19
+ resolve(result);
20
+ }), source, directiveArgs, context, info);
21
+ };
22
+ }
23
+ }
24
+ return newFieldConfig;
25
+ },
26
+ });
27
+ }exports.attachDirectiveResolvers=attachDirectiveResolvers;//# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","sources":["../../src/api/utils.ts"],"sourcesContent":[null],"names":["mapSchema","MapperKind","getDirectives","defaultFieldResolver"],"mappings":"kFAGgB,SAAA,wBAAwB,CACpC,MAAqB,EACrB,kBAA6C,EAAA;;IAI7C,OAAOA,eAAS,CAAC,MAAM,EAAE;QACrB,CAACC,gBAAU,CAAC,YAAY,GAAG,CAAC,WAAW,KAAI;AACvC,YAAA,MAAM,cAAc,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;YAE1C,MAAM,UAAU,GAAGC,mBAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACtD,YAAA,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;AAChC,gBAAA,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC;AACrC,gBAAA,IAAI,kBAAkB,CAAC,aAAa,CAAC,EAAE;AACnC,oBAAA,MAAM,QAAQ,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;AACnD,oBAAA,MAAM,gBAAgB,GAClB,cAAc,CAAC,OAAO,IAAI,IAAI,GAAG,cAAc,CAAC,OAAO,GAAGC,4BAAoB,CAAC;AACnF,oBAAA,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC;AACrC,oBAAA,cAAc,CAAC,OAAO,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,KAAI;AAC7D,wBAAA,OAAO,QAAQ,CACX,MACI,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AAC5B,4BAAA,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrE,4BAAA,IAAI,MAAM,YAAY,KAAK,EAAE;gCACzB,MAAM,CAAC,MAAM,CAAC,CAAC;6BAClB;4BACD,OAAO,CAAC,MAAM,CAAC,CAAC;yBACnB,CAAC,EACN,MAAM,EACN,aAAa,EACb,OAAO,EACP,IAAI,CACP,CAAC;AACN,qBAAC,CAAC;iBACL;aACJ;AAED,YAAA,OAAO,cAAc,CAAC;SACzB;AACJ,KAAA,CAAC,CAAC;AACP"}
@@ -0,0 +1,4 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ export declare function attachDirectiveResolvers(schema: GraphQLSchema, directiveResolvers: {
3
+ [key: string]: Function;
4
+ }): GraphQLSchema;
@@ -0,0 +1,27 @@
1
+ import {defaultFieldResolver}from'graphql';import {mapSchema,MapperKind,getDirectives}from'@graphql-tools/utils';function attachDirectiveResolvers(schema, directiveResolvers) {
2
+ // ... argument validation ...
3
+ return mapSchema(schema, {
4
+ [MapperKind.OBJECT_FIELD]: (fieldConfig) => {
5
+ const newFieldConfig = { ...fieldConfig };
6
+ const directives = getDirectives(schema, fieldConfig);
7
+ for (const directive of directives) {
8
+ const directiveName = directive.name;
9
+ if (directiveResolvers[directiveName]) {
10
+ const resolver = directiveResolvers[directiveName];
11
+ const originalResolver = newFieldConfig.resolve != null ? newFieldConfig.resolve : defaultFieldResolver;
12
+ const directiveArgs = directive.args;
13
+ newFieldConfig.resolve = (source, originalArgs, context, info) => {
14
+ return resolver(() => new Promise((resolve, reject) => {
15
+ const result = originalResolver(source, originalArgs, context, info);
16
+ if (result instanceof Error) {
17
+ reject(result);
18
+ }
19
+ resolve(result);
20
+ }), source, directiveArgs, context, info);
21
+ };
22
+ }
23
+ }
24
+ return newFieldConfig;
25
+ },
26
+ });
27
+ }export{attachDirectiveResolvers};//# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","sources":["../../src/api/utils.ts"],"sourcesContent":[null],"names":[],"mappings":"iHAGgB,SAAA,wBAAwB,CAC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var envalid=require('envalid');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var envalid__namespace=/*#__PURE__*/_interopNamespaceDefault(envalid);const { str, bool, json, num } = envalid__namespace;
2
+ const config = envalid__namespace.cleanEnv(process.env,
3
+ /* start */
4
+ {
5
+ NODE_ENV: str({ default: 'production', choices: ['production', 'staging', 'development', 'test'] }),
6
+ NATS_URL: str(),
7
+ NATS_USER: str(),
8
+ NATS_PW: str(),
9
+ GRAPHQL_ENDPOINT: str({ default: '/graphql' }),
10
+ BACKEND_URL: str(),
11
+ GRAPHQL_URL: str(),
12
+ CLIENT_URL: str(),
13
+ MONGO_URL: str(),
14
+ APP_NAME: str({ default: 'CDMBASE' }),
15
+ REDIS_CLUSTER_URL: json({
16
+ devDefault: '[{"port":6379,"host":"localhost"}]',
17
+ example: '[{"port":6379,"host":"localhost"}]',
18
+ }),
19
+ REDIS_URL: str({ devDefault: 'localhost' }),
20
+ REDIS_CLUSTER_ENABLED: bool({ devDefault: false }),
21
+ REDIS_SENTINEL_ENABLED: bool({ devDefault: true }),
22
+ CONNECTION_ID: str({ devDefault: 'CONNECTION_ID' }),
23
+ NAMESPACE: str({ default: 'default' }),
24
+ LOG_LEVEL: str({ default: 'info', choices: ['info', 'debug', 'trace'] }),
25
+ METRICS_CONFIG: json({
26
+ default: JSON.stringify({
27
+ enabled: false,
28
+ port: 3030,
29
+ path: '/metrics',
30
+ }),
31
+ devDefault: JSON.stringify({
32
+ enabled: false,
33
+ port: 3031,
34
+ path: '/metrics',
35
+ }),
36
+ example: '{"enabled":true,"port":3030,"path":"/metrics"}',
37
+ }),
38
+ } /* end */);exports.config=config;//# sourceMappingURL=env-config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-config.cjs","sources":["../../src/config/env-config.ts"],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,EAAE,OAAO,CAAC,EAAE,CAAC;IACxE,cAAc,EAAE,IAAI,CAAC;AACjB,QAAA,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;AACpB,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,IAAI,EAAE,UAAU;SACnB,CAAC;AACF,QAAA,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;AACvB,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,IAAI,EAAE,UAAU;SACnB,CAAC;AACF,QAAA,OAAO,EAAE,gDAAgD;KAC5D,CAAC;CACL"}
@@ -0,0 +1,21 @@
1
+ import * as envalid from 'envalid';
2
+ export declare const config: Readonly<{
3
+ NODE_ENV: string;
4
+ NATS_URL: string;
5
+ NATS_USER: string;
6
+ NATS_PW: string;
7
+ GRAPHQL_ENDPOINT: string;
8
+ BACKEND_URL: string;
9
+ GRAPHQL_URL: string;
10
+ CLIENT_URL: string;
11
+ MONGO_URL: string;
12
+ APP_NAME: string;
13
+ REDIS_CLUSTER_URL: string;
14
+ REDIS_URL: string;
15
+ REDIS_CLUSTER_ENABLED: boolean;
16
+ REDIS_SENTINEL_ENABLED: boolean;
17
+ CONNECTION_ID: string;
18
+ NAMESPACE: string;
19
+ LOG_LEVEL: string;
20
+ METRICS_CONFIG: string;
21
+ } & envalid.CleanedEnvAccessors>;
@@ -0,0 +1,38 @@
1
+ import*as envalid from'envalid';const { str, bool, json, num } = envalid;
2
+ const config = envalid.cleanEnv(process.env,
3
+ /* start */
4
+ {
5
+ NODE_ENV: str({ default: 'production', choices: ['production', 'staging', 'development', 'test'] }),
6
+ NATS_URL: str(),
7
+ NATS_USER: str(),
8
+ NATS_PW: str(),
9
+ GRAPHQL_ENDPOINT: str({ default: '/graphql' }),
10
+ BACKEND_URL: str(),
11
+ GRAPHQL_URL: str(),
12
+ CLIENT_URL: str(),
13
+ MONGO_URL: str(),
14
+ APP_NAME: str({ default: 'CDMBASE' }),
15
+ REDIS_CLUSTER_URL: json({
16
+ devDefault: '[{"port":6379,"host":"localhost"}]',
17
+ example: '[{"port":6379,"host":"localhost"}]',
18
+ }),
19
+ REDIS_URL: str({ devDefault: 'localhost' }),
20
+ REDIS_CLUSTER_ENABLED: bool({ devDefault: false }),
21
+ REDIS_SENTINEL_ENABLED: bool({ devDefault: true }),
22
+ CONNECTION_ID: str({ devDefault: 'CONNECTION_ID' }),
23
+ NAMESPACE: str({ default: 'default' }),
24
+ LOG_LEVEL: str({ default: 'info', choices: ['info', 'debug', 'trace'] }),
25
+ METRICS_CONFIG: json({
26
+ default: JSON.stringify({
27
+ enabled: false,
28
+ port: 3030,
29
+ path: '/metrics',
30
+ }),
31
+ devDefault: JSON.stringify({
32
+ enabled: false,
33
+ port: 3031,
34
+ path: '/metrics',
35
+ }),
36
+ example: '{"enabled":true,"port":3030,"path":"/metrics"}',
37
+ }),
38
+ } /* end */);export{config};//# sourceMappingURL=env-config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-config.mjs","sources":["../../src/config/env-config.ts"],"sourcesContent":[null],"names":[],"mappings":"gCAEA,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAE5B,MAAA,MAAM,GAAG,OAAO,CAAC,QAAQ,CAClC,OAAO,CAAC,GAAG;AACX;AACA;IACI,QAAQ,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,CAAC;IACnG,QAAQ,EAAE,GAAG,EAAE;IACf,SAAS,EAAE,GAAG,EAAE;IAChB,OAAO,EAAE,GAAG,EAAE;IACd,gBAAgB,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAC9C,WAAW,EAAE,GAAG,EAAE;IAClB,WAAW,EAAE,GAAG,EAAE;IAClB,UAAU,EAAE,GAAG,EAAE;IACjB,SAAS,EAAE,GAAG,EAAE;IAChB,QAAQ,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IACrC,iBAAiB,EAAE,IAAI,CAAC;AACpB,QAAA,UAAU,EAAE,oCAAoC;AAChD,QAAA,OAAO,EAAE,oCAAoC;KAChD,CAAC;IACF,SAAS,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IAC3C,qBAAqB,EAAE,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAClD,sBAAsB,EAAE,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAClD,aAAa,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;IAEnD,SAAS,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACtC,IAAA,SAAS,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;IACxE,cAAc,EAAE,IAAI,CAAC;AACjB,QAAA,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;AACpB,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,IAAI,EAAE,UAAU;SACnB,CAAC;AACF,QAAA,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;AACvB,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,IAAI,EAAE,UAAU;SACnB,CAAC;AACF,QAAA,OAAO,EAAE,gDAAgD;KAC5D,CAAC;CACL"}
@@ -0,0 +1 @@
1
+ export * from './env-config';
@@ -0,0 +1,191 @@
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var envConfig=require('./env-config.cjs');/**
2
+ * Moleculer ServiceBroker configuration file
3
+ *
4
+ * More info about options:
5
+ * https://moleculer.services/docs/0.14/configuration.html
6
+ *
7
+ *
8
+ * Overwrite options in production:
9
+ * ================================
10
+ * You can overwrite any option with environment variables.
11
+ * For example to overwrite the 'logLevel', use `LOGLEVEL=warn` env var.
12
+ * To overwrite a nested parameter, e.g. retryPolicy.retries, use `RETRYPOLICY_RETRIES=10` env var.
13
+ *
14
+ * To overwrite broker’s deeply nested default options, which are not presented in 'moleculer.config.ts',
15
+ * via environment variables, use the `MOL_` prefix and double underscore `__` for nested properties in .env file.
16
+ * For example, to set the cacher prefix to `MYCACHE`, you should declare an env var as `MOL_CACHER__OPTIONS__PREFIX=MYCACHE`.
17
+ */
18
+ const brokerConfig = {
19
+ // Namespace of nodes to segment your nodes on the same network.
20
+ namespace: envConfig.config.NAMESPACE,
21
+ // namespace: null,
22
+ // Unique node identifier. Must be unique in a namespace.
23
+ // nodeID: config.CONNECTION_ID,
24
+ // Enable/disable logging or use custom logger. More info: https://moleculer.services/docs/0.14/logging.html
25
+ // Available logger types: 'Console', 'File', 'Pino', 'Winston', 'Bunyan', 'debug', 'Log4js', 'Datadog'
26
+ logger: {
27
+ type: 'Console',
28
+ options: {
29
+ // Using colors on the output
30
+ colors: true,
31
+ // Print module names with different colors (like docker-compose for containers)
32
+ moduleColors: false,
33
+ // Line formatter. It can be 'json', 'short',
34
+ // 'simple', 'full', a `Function` or a template string like '{timestamp} {level} {nodeID}/{mod}: {msg}'
35
+ formatter: 'full',
36
+ // Custom object printer. If not defined, it uses the `util.inspect` method.
37
+ objectPrinter: null,
38
+ // Auto-padding the module name in order to messages begin at the same column.
39
+ autoPadding: false,
40
+ },
41
+ },
42
+ // Default log level for built-in console logger. It can be overwritten in logger options above.
43
+ // Available values: trace, debug, info, warn, error, fatal
44
+ logLevel: envConfig.config.LOG_LEVEL,
45
+ // Define transporter.
46
+ // More info: https://moleculer.services/docs/0.14/networking.html
47
+ // Note: During the development, you don't need to define it because all services will be loaded locally.
48
+ // In production you can set it via `TRANSPORTER=nats://localhost:4222` environment variable.
49
+ transporter: envConfig.config.NODE_ENV === 'development'
50
+ ? 'TCP'
51
+ : {
52
+ type: 'NATS',
53
+ options: {
54
+ url: envConfig.config.NATS_URL,
55
+ user: envConfig.config.NATS_USER,
56
+ pass: envConfig.config.NATS_PW,
57
+ reconnectTimeWait: 1000,
58
+ },
59
+ },
60
+ // Define a cacher.
61
+ // More info: https://moleculer.services/docs/0.14/caching.html
62
+ // cacher: {
63
+ // type: 'Redis',
64
+ // enabled: false,
65
+ // options: {
66
+ // // Redis settings
67
+ // redis: {
68
+ // }
69
+ // }
70
+ // },
71
+ // Define a serializer.
72
+ // Available values: 'JSON', 'Avro', 'ProtoBuf', 'MsgPack', 'Notepack', 'Thrift'.
73
+ // More info: https://moleculer.services/docs/0.13/networking.html
74
+ serializer: 'JSON',
75
+ // Number of milliseconds to wait before reject a request with a RequestTimeout error. Disabled: 0
76
+ requestTimeout: 10 * 1000,
77
+ // Retry policy settings. More info: https://moleculer.services/docs/0.13/fault-tolerance.html#Retry
78
+ retryPolicy: {
79
+ // Enable feature
80
+ enabled: false,
81
+ // Count of retries
82
+ retries: 5,
83
+ // First delay in milliseconds.
84
+ delay: 100,
85
+ // Maximum delay in milliseconds.
86
+ maxDelay: 1000,
87
+ // Backoff factor for delay. 2 means exponential backoff.
88
+ factor: 2,
89
+ // A function to check failed requests.
90
+ check: (err) => err && !!err.retryable,
91
+ },
92
+ // Limit of calling level. If it reaches the limit, broker will throw an MaxCallLevelError error. (Infinite loop protection)
93
+ maxCallLevel: 100,
94
+ // Number of seconds to send heartbeat packet to other nodes.
95
+ heartbeatInterval: 5,
96
+ // Number of seconds to wait before setting node to unavailable status.
97
+ heartbeatTimeout: 15,
98
+ // tslint:disable-next-line:max-line-length
99
+ // Tracking requests and waiting for running requests before shutdowning. More info: https://moleculer.services/docs/0.13/fault-tolerance.html
100
+ tracking: {
101
+ // Enable feature
102
+ enabled: false,
103
+ // Number of milliseconds to wait before shutdowning the process
104
+ shutdownTimeout: 5000,
105
+ },
106
+ // Disable built-in request & emit balancer. (Transporter must support it, as well.)
107
+ disableBalancer: false,
108
+ // Settings of Service Registry. More info: https://moleculer.services/docs/0.14/registry.html
109
+ registry: {
110
+ // Define balancing strategy. More info: https://moleculer.services/docs/0.14/balancing.html
111
+ // Available values: 'RoundRobin', 'Random', 'CpuUsage', 'Latency'
112
+ strategy: 'RoundRobin',
113
+ // Enable local action call preferring.
114
+ preferLocal: true,
115
+ },
116
+ // Settings of Circuit Breaker. More info: https://moleculer.services/docs/0.14/fault-tolerance.html#Circuit-Breaker
117
+ circuitBreaker: {
118
+ // Enable feature
119
+ enabled: false,
120
+ // Threshold value. 0.5 means that 50% should be failed for tripping.
121
+ threshold: 0.5,
122
+ // Minimum request count. Below it, CB does not trip.
123
+ minRequestCount: 20,
124
+ // Number of seconds for time window.
125
+ windowTime: 60,
126
+ // Number of milliseconds to switch from open to half-open state
127
+ halfOpenTime: 10 * 1000,
128
+ // A function to check failed requests.
129
+ check: (err) => err && err.code >= 500,
130
+ },
131
+ // Settings of bulkhead feature. More info: https://moleculer.services/docs/0.14/fault-tolerance.html#Bulkhead
132
+ bulkhead: {
133
+ // Enable feature.
134
+ enabled: false,
135
+ // Maximum concurrent executions.
136
+ concurrency: 10,
137
+ // Maximum size of queue
138
+ maxQueueSize: 100,
139
+ },
140
+ // Enable action & event parameter validation. More info: https://moleculer.services/docs/0.14/validating.html
141
+ validator: true,
142
+ errorHandler: null,
143
+ // Enable/disable built-in metrics function. More info: https://moleculer.services/docs/0.14/metrics.html
144
+ metrics: {
145
+ enabled: envConfig.config.METRICS_CONFIG.enabled,
146
+ reporter: {
147
+ type: 'Prometheus',
148
+ options: {
149
+ port: envConfig.config.METRICS_CONFIG.port,
150
+ path: envConfig.config.METRICS_CONFIG.path,
151
+ defaultLabels: (registry) => ({
152
+ namespace: registry.broker.namespace,
153
+ nodeID: registry.broker.nodeID,
154
+ }),
155
+ },
156
+ },
157
+ },
158
+ // Enable built-in tracing function. More info: https://moleculer.services/docs/0.14/tracing.html
159
+ tracing: {
160
+ enabled: true,
161
+ // Available built-in exporters: 'Console', 'Datadog', 'Event', 'EventLegacy', 'Jaeger', 'Zipkin'
162
+ exporter: {
163
+ type: 'Console', // Console exporter is only for development!
164
+ options: {
165
+ // Custom logger
166
+ logger: null,
167
+ // Using colors
168
+ colors: true,
169
+ // Width of row
170
+ width: 100,
171
+ // Gauge width in the row
172
+ gaugeWidth: 40,
173
+ },
174
+ },
175
+ },
176
+ // Register internal services ('$node'). More info: https://moleculer.services/docs/0.13/services.html#Internal-services
177
+ internalServices: true,
178
+ // Register internal middlewares. More info: https://moleculer.services/docs/0.13/middlewares.html#Internal-middlewares
179
+ internalMiddlewares: true,
180
+ // Watch the loaded services and hot reload if they changed.
181
+ // You can also enable it in Moleculer Runner with `--hot` argument
182
+ hotReload: false,
183
+ // Register custom middlewares
184
+ middlewares: [],
185
+ // Called after broker created.
186
+ created(broker) { },
187
+ // Called after broker starte.
188
+ started(broker) { },
189
+ // Called after broker stopped.
190
+ stopped(broker) { },
191
+ };exports.default=brokerConfig;//# sourceMappingURL=moleculer.config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moleculer.config.cjs","sources":["../../src/config/moleculer.config.ts"],"sourcesContent":[null],"names":["config"],"mappings":"gHAIA;;;;;;;;;;;;;;;;AAgBG;AACH,MAAM,YAAY,GAAkB;;IAEhC,SAAS,EAAEA,gBAAM,CAAC,SAAS;;;;;;AAO3B,IAAA,MAAM,EAAE;AACJ,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,OAAO,EAAE;;AAEL,YAAA,MAAM,EAAE,IAAI;;AAEZ,YAAA,YAAY,EAAE,KAAK;;;AAGnB,YAAA,SAAS,EAAE,MAAM;;AAEjB,YAAA,aAAa,EAAE,IAAI;;AAEnB,YAAA,WAAW,EAAE,KAAK;AACrB,SAAA;AACJ,KAAA;;;IAGD,QAAQ,EAAEA,gBAAM,CAAC,SAAoE;;;;;AA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IAGlB,OAAO,CAAC,MAAM,EAAA,GAAI;;IAGlB,OAAO,CAAC,MAAM,EAAA,GAAI;"}
@@ -0,0 +1,20 @@
1
+ import { BrokerOptions } from 'moleculer';
2
+ /**
3
+ * Moleculer ServiceBroker configuration file
4
+ *
5
+ * More info about options:
6
+ * https://moleculer.services/docs/0.14/configuration.html
7
+ *
8
+ *
9
+ * Overwrite options in production:
10
+ * ================================
11
+ * You can overwrite any option with environment variables.
12
+ * For example to overwrite the 'logLevel', use `LOGLEVEL=warn` env var.
13
+ * To overwrite a nested parameter, e.g. retryPolicy.retries, use `RETRYPOLICY_RETRIES=10` env var.
14
+ *
15
+ * To overwrite broker’s deeply nested default options, which are not presented in 'moleculer.config.ts',
16
+ * via environment variables, use the `MOL_` prefix and double underscore `__` for nested properties in .env file.
17
+ * For example, to set the cacher prefix to `MYCACHE`, you should declare an env var as `MOL_CACHER__OPTIONS__PREFIX=MYCACHE`.
18
+ */
19
+ declare const brokerConfig: BrokerOptions;
20
+ export default brokerConfig;
@@ -0,0 +1,191 @@
1
+ import {config}from'./env-config.mjs';/**
2
+ * Moleculer ServiceBroker configuration file
3
+ *
4
+ * More info about options:
5
+ * https://moleculer.services/docs/0.14/configuration.html
6
+ *
7
+ *
8
+ * Overwrite options in production:
9
+ * ================================
10
+ * You can overwrite any option with environment variables.
11
+ * For example to overwrite the 'logLevel', use `LOGLEVEL=warn` env var.
12
+ * To overwrite a nested parameter, e.g. retryPolicy.retries, use `RETRYPOLICY_RETRIES=10` env var.
13
+ *
14
+ * To overwrite broker’s deeply nested default options, which are not presented in 'moleculer.config.ts',
15
+ * via environment variables, use the `MOL_` prefix and double underscore `__` for nested properties in .env file.
16
+ * For example, to set the cacher prefix to `MYCACHE`, you should declare an env var as `MOL_CACHER__OPTIONS__PREFIX=MYCACHE`.
17
+ */
18
+ const brokerConfig = {
19
+ // Namespace of nodes to segment your nodes on the same network.
20
+ namespace: config.NAMESPACE,
21
+ // namespace: null,
22
+ // Unique node identifier. Must be unique in a namespace.
23
+ // nodeID: config.CONNECTION_ID,
24
+ // Enable/disable logging or use custom logger. More info: https://moleculer.services/docs/0.14/logging.html
25
+ // Available logger types: 'Console', 'File', 'Pino', 'Winston', 'Bunyan', 'debug', 'Log4js', 'Datadog'
26
+ logger: {
27
+ type: 'Console',
28
+ options: {
29
+ // Using colors on the output
30
+ colors: true,
31
+ // Print module names with different colors (like docker-compose for containers)
32
+ moduleColors: false,
33
+ // Line formatter. It can be 'json', 'short',
34
+ // 'simple', 'full', a `Function` or a template string like '{timestamp} {level} {nodeID}/{mod}: {msg}'
35
+ formatter: 'full',
36
+ // Custom object printer. If not defined, it uses the `util.inspect` method.
37
+ objectPrinter: null,
38
+ // Auto-padding the module name in order to messages begin at the same column.
39
+ autoPadding: false,
40
+ },
41
+ },
42
+ // Default log level for built-in console logger. It can be overwritten in logger options above.
43
+ // Available values: trace, debug, info, warn, error, fatal
44
+ logLevel: config.LOG_LEVEL,
45
+ // Define transporter.
46
+ // More info: https://moleculer.services/docs/0.14/networking.html
47
+ // Note: During the development, you don't need to define it because all services will be loaded locally.
48
+ // In production you can set it via `TRANSPORTER=nats://localhost:4222` environment variable.
49
+ transporter: config.NODE_ENV === 'development'
50
+ ? 'TCP'
51
+ : {
52
+ type: 'NATS',
53
+ options: {
54
+ url: config.NATS_URL,
55
+ user: config.NATS_USER,
56
+ pass: config.NATS_PW,
57
+ reconnectTimeWait: 1000,
58
+ },
59
+ },
60
+ // Define a cacher.
61
+ // More info: https://moleculer.services/docs/0.14/caching.html
62
+ // cacher: {
63
+ // type: 'Redis',
64
+ // enabled: false,
65
+ // options: {
66
+ // // Redis settings
67
+ // redis: {
68
+ // }
69
+ // }
70
+ // },
71
+ // Define a serializer.
72
+ // Available values: 'JSON', 'Avro', 'ProtoBuf', 'MsgPack', 'Notepack', 'Thrift'.
73
+ // More info: https://moleculer.services/docs/0.13/networking.html
74
+ serializer: 'JSON',
75
+ // Number of milliseconds to wait before reject a request with a RequestTimeout error. Disabled: 0
76
+ requestTimeout: 10 * 1000,
77
+ // Retry policy settings. More info: https://moleculer.services/docs/0.13/fault-tolerance.html#Retry
78
+ retryPolicy: {
79
+ // Enable feature
80
+ enabled: false,
81
+ // Count of retries
82
+ retries: 5,
83
+ // First delay in milliseconds.
84
+ delay: 100,
85
+ // Maximum delay in milliseconds.
86
+ maxDelay: 1000,
87
+ // Backoff factor for delay. 2 means exponential backoff.
88
+ factor: 2,
89
+ // A function to check failed requests.
90
+ check: (err) => err && !!err.retryable,
91
+ },
92
+ // Limit of calling level. If it reaches the limit, broker will throw an MaxCallLevelError error. (Infinite loop protection)
93
+ maxCallLevel: 100,
94
+ // Number of seconds to send heartbeat packet to other nodes.
95
+ heartbeatInterval: 5,
96
+ // Number of seconds to wait before setting node to unavailable status.
97
+ heartbeatTimeout: 15,
98
+ // tslint:disable-next-line:max-line-length
99
+ // Tracking requests and waiting for running requests before shutdowning. More info: https://moleculer.services/docs/0.13/fault-tolerance.html
100
+ tracking: {
101
+ // Enable feature
102
+ enabled: false,
103
+ // Number of milliseconds to wait before shutdowning the process
104
+ shutdownTimeout: 5000,
105
+ },
106
+ // Disable built-in request & emit balancer. (Transporter must support it, as well.)
107
+ disableBalancer: false,
108
+ // Settings of Service Registry. More info: https://moleculer.services/docs/0.14/registry.html
109
+ registry: {
110
+ // Define balancing strategy. More info: https://moleculer.services/docs/0.14/balancing.html
111
+ // Available values: 'RoundRobin', 'Random', 'CpuUsage', 'Latency'
112
+ strategy: 'RoundRobin',
113
+ // Enable local action call preferring.
114
+ preferLocal: true,
115
+ },
116
+ // Settings of Circuit Breaker. More info: https://moleculer.services/docs/0.14/fault-tolerance.html#Circuit-Breaker
117
+ circuitBreaker: {
118
+ // Enable feature
119
+ enabled: false,
120
+ // Threshold value. 0.5 means that 50% should be failed for tripping.
121
+ threshold: 0.5,
122
+ // Minimum request count. Below it, CB does not trip.
123
+ minRequestCount: 20,
124
+ // Number of seconds for time window.
125
+ windowTime: 60,
126
+ // Number of milliseconds to switch from open to half-open state
127
+ halfOpenTime: 10 * 1000,
128
+ // A function to check failed requests.
129
+ check: (err) => err && err.code >= 500,
130
+ },
131
+ // Settings of bulkhead feature. More info: https://moleculer.services/docs/0.14/fault-tolerance.html#Bulkhead
132
+ bulkhead: {
133
+ // Enable feature.
134
+ enabled: false,
135
+ // Maximum concurrent executions.
136
+ concurrency: 10,
137
+ // Maximum size of queue
138
+ maxQueueSize: 100,
139
+ },
140
+ // Enable action & event parameter validation. More info: https://moleculer.services/docs/0.14/validating.html
141
+ validator: true,
142
+ errorHandler: null,
143
+ // Enable/disable built-in metrics function. More info: https://moleculer.services/docs/0.14/metrics.html
144
+ metrics: {
145
+ enabled: config.METRICS_CONFIG.enabled,
146
+ reporter: {
147
+ type: 'Prometheus',
148
+ options: {
149
+ port: config.METRICS_CONFIG.port,
150
+ path: config.METRICS_CONFIG.path,
151
+ defaultLabels: (registry) => ({
152
+ namespace: registry.broker.namespace,
153
+ nodeID: registry.broker.nodeID,
154
+ }),
155
+ },
156
+ },
157
+ },
158
+ // Enable built-in tracing function. More info: https://moleculer.services/docs/0.14/tracing.html
159
+ tracing: {
160
+ enabled: true,
161
+ // Available built-in exporters: 'Console', 'Datadog', 'Event', 'EventLegacy', 'Jaeger', 'Zipkin'
162
+ exporter: {
163
+ type: 'Console', // Console exporter is only for development!
164
+ options: {
165
+ // Custom logger
166
+ logger: null,
167
+ // Using colors
168
+ colors: true,
169
+ // Width of row
170
+ width: 100,
171
+ // Gauge width in the row
172
+ gaugeWidth: 40,
173
+ },
174
+ },
175
+ },
176
+ // Register internal services ('$node'). More info: https://moleculer.services/docs/0.13/services.html#Internal-services
177
+ internalServices: true,
178
+ // Register internal middlewares. More info: https://moleculer.services/docs/0.13/middlewares.html#Internal-middlewares
179
+ internalMiddlewares: true,
180
+ // Watch the loaded services and hot reload if they changed.
181
+ // You can also enable it in Moleculer Runner with `--hot` argument
182
+ hotReload: false,
183
+ // Register custom middlewares
184
+ middlewares: [],
185
+ // Called after broker created.
186
+ created(broker) { },
187
+ // Called after broker starte.
188
+ started(broker) { },
189
+ // Called after broker stopped.
190
+ stopped(broker) { },
191
+ };export{brokerConfig as default};//# sourceMappingURL=moleculer.config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moleculer.config.mjs","sources":["../../src/config/moleculer.config.ts"],"sourcesContent":[null],"names":[],"mappings":"sCAIA;;;;;;;;;;;;;;;;AAgBG;AACH,MAAM,YAAY,GAAkB;;IAEhC,SAAS,EAAE,MAAM,CAAC,SAAS;;;;;;AAO3B,IAAA,MAAM,EAAE;AACJ,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,OAAO,EAAE;;AAEL,YAAA,MAAM,EAAE,IAAI;;AAEZ,YAAA,YAAY,EAAE,KAAK;;;AAGnB,YAAA,SAAS,EAAE,MAAM;;AAEjB,YAAA,aAAa,EAAE,IAAI;;AAEnB,YAAA,WAAW,EAAE,KAAK;AACrB,SAAA;AACJ,KAAA;;;IAGD,QAAQ,EAAE,MAAM,CAAC,SAAoE;;;;;AAMrF,IAAA,WAAW,EACP,MAAM,CAAC,QAAQ,KAAK,aAAa;AAC7B,UAAE,KAAK;AACP,UAAG;AACG,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE;gBACL,GAAG,EAAE,MAAM,CAAC,QAAQ;gBACpB,IAAI,EAAE,MAAM,CAAC,SAAS;gBACtB,IAAI,EAAE,MAAM,CAAC,OAAO;AACpB,gBAAA,iBAAiB,EAAE,IAAI;AAC1B,aAAA;AACgB,SAAA;;;;;;;;;;;;;;;AAmB/B,IAAA,UAAU,EAAE,MAAM;;IAGlB,cAAc,EAAE,EAAE,GAAG,IAAI;;AAGzB,IAAA,WAAW,EAAE;;AAET,QAAA,OAAO,EAAE,KAAK;;AAEd,QAAA,OAAO,EAAE,CAAC;;AAEV,QAAA,KAAK,EAAE,GAAG;;AAEV,QAAA,QAAQ,EAAE,IAAI;;AAEd,QAAA,MAAM,EAAE,CAAC;;AAET,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