@restorecommerce/facade 1.2.0 → 1.3.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 (254) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.cjs +13 -0
  3. package/CHANGELOG.md +22 -0
  4. package/codegen/index.d.ts +1 -1
  5. package/codegen/index.js +18 -44
  6. package/debug-run.ts +7 -6
  7. package/dist/gql/index.d.ts +1 -1
  8. package/dist/gql/index.js +1 -17
  9. package/dist/gql/protos/federation.d.ts +3 -3
  10. package/dist/gql/protos/federation.js +16 -24
  11. package/dist/gql/protos/graphql.d.ts +4 -4
  12. package/dist/gql/protos/graphql.js +64 -42
  13. package/dist/gql/protos/index.d.ts +6 -6
  14. package/dist/gql/protos/index.js +6 -22
  15. package/dist/gql/protos/registry.d.ts +6 -6
  16. package/dist/gql/protos/registry.js +157 -176
  17. package/dist/gql/protos/resolvers.d.ts +3 -3
  18. package/dist/gql/protos/resolvers.js +78 -104
  19. package/dist/gql/protos/schema.d.ts +4 -4
  20. package/dist/gql/protos/schema.js +40 -53
  21. package/dist/gql/protos/types.d.ts +3 -3
  22. package/dist/gql/protos/types.js +1 -4
  23. package/dist/gql/protos/utils.d.ts +3 -3
  24. package/dist/gql/protos/utils.js +23 -62
  25. package/dist/gql/types/AccessControlTypes.js +13 -16
  26. package/dist/gql/types/DateType.js +4 -7
  27. package/dist/gql/types/FilterType.js +7 -10
  28. package/dist/gql/types/MetaType.js +8 -11
  29. package/dist/gql/types/ScopeType.js +4 -7
  30. package/dist/gql/types/SortType.js +5 -8
  31. package/dist/gql/types/StatusType.js +4 -7
  32. package/dist/gql/types/index.d.ts +7 -7
  33. package/dist/gql/types/index.js +7 -23
  34. package/dist/index.d.ts +14 -14
  35. package/dist/index.js +195 -207
  36. package/dist/interfaces.d.ts +8 -8
  37. package/dist/interfaces.js +1 -2
  38. package/dist/middlewares/index.d.ts +1 -1
  39. package/dist/middlewares/index.js +1 -17
  40. package/dist/middlewares/req-res-logger/index.d.ts +2 -2
  41. package/dist/middlewares/req-res-logger/index.js +33 -31
  42. package/dist/modules/access-control/gql/federation.d.ts +1 -1
  43. package/dist/modules/access-control/gql/federation.js +10 -17
  44. package/dist/modules/access-control/gql/schema.d.ts +1 -1
  45. package/dist/modules/access-control/gql/schema.generated.d.ts +136 -110
  46. package/dist/modules/access-control/gql/schema.generated.js +22 -25
  47. package/dist/modules/access-control/gql/schema.js +5 -9
  48. package/dist/modules/access-control/gql/types.d.ts +2 -2
  49. package/dist/modules/access-control/gql/types.js +13 -17
  50. package/dist/modules/access-control/grpc/index.d.ts +5 -5
  51. package/dist/modules/access-control/grpc/index.js +10 -14
  52. package/dist/modules/access-control/index.d.ts +2 -2
  53. package/dist/modules/access-control/index.js +20 -17
  54. package/dist/modules/access-control/interfaces.d.ts +3 -3
  55. package/dist/modules/access-control/interfaces.js +1 -4
  56. package/dist/modules/catalog/gql/federation.d.ts +1 -1
  57. package/dist/modules/catalog/gql/federation.js +10 -17
  58. package/dist/modules/catalog/gql/schema.d.ts +1 -1
  59. package/dist/modules/catalog/gql/schema.generated.d.ts +252 -226
  60. package/dist/modules/catalog/gql/schema.generated.js +20 -23
  61. package/dist/modules/catalog/gql/schema.js +5 -9
  62. package/dist/modules/catalog/gql/types.d.ts +2 -2
  63. package/dist/modules/catalog/gql/types.js +15 -19
  64. package/dist/modules/catalog/grpc/index.d.ts +6 -6
  65. package/dist/modules/catalog/grpc/index.js +12 -16
  66. package/dist/modules/catalog/index.d.ts +2 -2
  67. package/dist/modules/catalog/index.js +20 -17
  68. package/dist/modules/catalog/interfaces.d.ts +3 -3
  69. package/dist/modules/catalog/interfaces.js +1 -4
  70. package/dist/modules/facade-status/gql/index.js +8 -14
  71. package/dist/modules/facade-status/gql/resolvers.d.ts +1 -1
  72. package/dist/modules/facade-status/gql/resolvers.js +14 -8
  73. package/dist/modules/facade-status/gql/schema.d.ts +1 -1
  74. package/dist/modules/facade-status/gql/schema.generated.d.ts +34 -11
  75. package/dist/modules/facade-status/gql/schema.generated.js +1 -2
  76. package/dist/modules/facade-status/gql/schema.js +6 -9
  77. package/dist/modules/facade-status/gql/types.js +3 -6
  78. package/dist/modules/facade-status/index.d.ts +1 -1
  79. package/dist/modules/facade-status/index.js +4 -7
  80. package/dist/modules/facade-status/interfaces.d.ts +1 -1
  81. package/dist/modules/facade-status/interfaces.js +1 -2
  82. package/dist/modules/fulfillment/gql/federation.d.ts +1 -1
  83. package/dist/modules/fulfillment/gql/federation.js +10 -17
  84. package/dist/modules/fulfillment/gql/schema.d.ts +1 -1
  85. package/dist/modules/fulfillment/gql/schema.generated.d.ts +249 -223
  86. package/dist/modules/fulfillment/gql/schema.generated.js +20 -23
  87. package/dist/modules/fulfillment/gql/schema.js +5 -9
  88. package/dist/modules/fulfillment/gql/types.d.ts +2 -2
  89. package/dist/modules/fulfillment/gql/types.js +11 -15
  90. package/dist/modules/fulfillment/grpc/index.d.ts +3 -3
  91. package/dist/modules/fulfillment/grpc/index.js +6 -10
  92. package/dist/modules/fulfillment/index.d.ts +2 -2
  93. package/dist/modules/fulfillment/index.js +20 -17
  94. package/dist/modules/fulfillment/interfaces.d.ts +3 -3
  95. package/dist/modules/fulfillment/interfaces.js +1 -4
  96. package/dist/modules/identity/api-key/api-key.d.ts +2 -2
  97. package/dist/modules/identity/api-key/api-key.js +45 -65
  98. package/dist/modules/identity/gql/federation.d.ts +2 -2
  99. package/dist/modules/identity/gql/federation.js +5 -9
  100. package/dist/modules/identity/gql/schema.d.ts +1 -1
  101. package/dist/modules/identity/gql/schema.generated.d.ts +284 -255
  102. package/dist/modules/identity/gql/schema.generated.js +20 -23
  103. package/dist/modules/identity/gql/schema.js +5 -9
  104. package/dist/modules/identity/gql/types.d.ts +2 -2
  105. package/dist/modules/identity/gql/types.js +17 -21
  106. package/dist/modules/identity/grpc/index.d.ts +6 -6
  107. package/dist/modules/identity/grpc/index.js +12 -16
  108. package/dist/modules/identity/index.d.ts +4 -4
  109. package/dist/modules/identity/index.js +24 -21
  110. package/dist/modules/identity/interfaces.d.ts +5 -5
  111. package/dist/modules/identity/interfaces.js +1 -4
  112. package/dist/modules/identity/oauth/oauth.d.ts +4 -4
  113. package/dist/modules/identity/oauth/oauth.js +109 -135
  114. package/dist/modules/identity/oidc/adapter.d.ts +3 -3
  115. package/dist/modules/identity/oidc/adapter.js +111 -92
  116. package/dist/modules/identity/oidc/in-memory-adapter.d.ts +1 -1
  117. package/dist/modules/identity/oidc/in-memory-adapter.js +64 -50
  118. package/dist/modules/identity/oidc/index.d.ts +6 -6
  119. package/dist/modules/identity/oidc/index.js +29 -30
  120. package/dist/modules/identity/oidc/interfaces.d.ts +6 -6
  121. package/dist/modules/identity/oidc/interfaces.js +2 -6
  122. package/dist/modules/identity/oidc/password-grant.d.ts +1 -1
  123. package/dist/modules/identity/oidc/password-grant.js +43 -66
  124. package/dist/modules/identity/oidc/router.d.ts +6 -6
  125. package/dist/modules/identity/oidc/router.js +31 -26
  126. package/dist/modules/identity/oidc/templates.d.ts +1 -1
  127. package/dist/modules/identity/oidc/templates.js +45 -41
  128. package/dist/modules/identity/oidc/user.d.ts +4 -4
  129. package/dist/modules/identity/oidc/user.js +31 -29
  130. package/dist/modules/identity/oidc/utils.d.ts +2 -2
  131. package/dist/modules/identity/oidc/utils.js +6 -13
  132. package/dist/modules/index.d.ts +13 -13
  133. package/dist/modules/index.js +13 -29
  134. package/dist/modules/indexing/gql/federation.d.ts +1 -1
  135. package/dist/modules/indexing/gql/federation.js +10 -17
  136. package/dist/modules/indexing/gql/schema.d.ts +1 -1
  137. package/dist/modules/indexing/gql/schema.generated.d.ts +45 -19
  138. package/dist/modules/indexing/gql/schema.generated.js +2 -5
  139. package/dist/modules/indexing/gql/schema.js +5 -9
  140. package/dist/modules/indexing/gql/types.d.ts +2 -2
  141. package/dist/modules/indexing/gql/types.js +7 -11
  142. package/dist/modules/indexing/grpc/index.d.ts +2 -2
  143. package/dist/modules/indexing/grpc/index.js +4 -8
  144. package/dist/modules/indexing/index.d.ts +2 -2
  145. package/dist/modules/indexing/index.js +20 -17
  146. package/dist/modules/indexing/interfaces.d.ts +3 -3
  147. package/dist/modules/indexing/interfaces.js +1 -4
  148. package/dist/modules/invoicing/gql/federation.d.ts +1 -1
  149. package/dist/modules/invoicing/gql/federation.js +10 -17
  150. package/dist/modules/invoicing/gql/schema.d.ts +1 -1
  151. package/dist/modules/invoicing/gql/schema.generated.d.ts +209 -183
  152. package/dist/modules/invoicing/gql/schema.generated.js +20 -23
  153. package/dist/modules/invoicing/gql/schema.js +5 -9
  154. package/dist/modules/invoicing/gql/types.d.ts +2 -2
  155. package/dist/modules/invoicing/gql/types.js +7 -11
  156. package/dist/modules/invoicing/grpc/index.d.ts +2 -2
  157. package/dist/modules/invoicing/grpc/index.js +4 -8
  158. package/dist/modules/invoicing/index.d.ts +2 -2
  159. package/dist/modules/invoicing/index.js +20 -17
  160. package/dist/modules/invoicing/interfaces.d.ts +3 -3
  161. package/dist/modules/invoicing/interfaces.js +1 -4
  162. package/dist/modules/notification/gql/federation.d.ts +1 -1
  163. package/dist/modules/notification/gql/federation.js +10 -17
  164. package/dist/modules/notification/gql/schema.d.ts +1 -1
  165. package/dist/modules/notification/gql/schema.generated.d.ts +100 -74
  166. package/dist/modules/notification/gql/schema.generated.js +18 -21
  167. package/dist/modules/notification/gql/schema.js +5 -9
  168. package/dist/modules/notification/gql/types.d.ts +2 -2
  169. package/dist/modules/notification/gql/types.js +7 -11
  170. package/dist/modules/notification/grpc/index.d.ts +2 -2
  171. package/dist/modules/notification/grpc/index.js +4 -8
  172. package/dist/modules/notification/index.d.ts +2 -2
  173. package/dist/modules/notification/index.js +20 -17
  174. package/dist/modules/notification/interfaces.d.ts +3 -3
  175. package/dist/modules/notification/interfaces.js +1 -4
  176. package/dist/modules/ordering/gql/federation.d.ts +1 -1
  177. package/dist/modules/ordering/gql/federation.js +10 -17
  178. package/dist/modules/ordering/gql/schema.d.ts +1 -1
  179. package/dist/modules/ordering/gql/schema.generated.d.ts +221 -195
  180. package/dist/modules/ordering/gql/schema.generated.js +22 -25
  181. package/dist/modules/ordering/gql/schema.js +5 -9
  182. package/dist/modules/ordering/gql/types.d.ts +2 -2
  183. package/dist/modules/ordering/gql/types.js +7 -11
  184. package/dist/modules/ordering/grpc/index.d.ts +2 -2
  185. package/dist/modules/ordering/grpc/index.js +4 -8
  186. package/dist/modules/ordering/index.d.ts +2 -2
  187. package/dist/modules/ordering/index.js +20 -17
  188. package/dist/modules/ordering/interfaces.d.ts +3 -3
  189. package/dist/modules/ordering/interfaces.js +1 -4
  190. package/dist/modules/ostorage/gql/federation.d.ts +1 -1
  191. package/dist/modules/ostorage/gql/federation.js +10 -17
  192. package/dist/modules/ostorage/gql/schema.d.ts +1 -1
  193. package/dist/modules/ostorage/gql/schema.generated.d.ts +126 -94
  194. package/dist/modules/ostorage/gql/schema.generated.js +8 -11
  195. package/dist/modules/ostorage/gql/schema.js +5 -9
  196. package/dist/modules/ostorage/gql/types.d.ts +2 -2
  197. package/dist/modules/ostorage/gql/types.js +7 -11
  198. package/dist/modules/ostorage/grpc/index.d.ts +2 -2
  199. package/dist/modules/ostorage/grpc/index.js +4 -8
  200. package/dist/modules/ostorage/index.d.ts +2 -2
  201. package/dist/modules/ostorage/index.js +20 -17
  202. package/dist/modules/ostorage/interfaces.d.ts +3 -3
  203. package/dist/modules/ostorage/interfaces.js +1 -4
  204. package/dist/modules/payment/gql/federation.d.ts +1 -1
  205. package/dist/modules/payment/gql/federation.js +10 -17
  206. package/dist/modules/payment/gql/schema.d.ts +1 -1
  207. package/dist/modules/payment/gql/schema.generated.d.ts +67 -44
  208. package/dist/modules/payment/gql/schema.generated.js +4 -7
  209. package/dist/modules/payment/gql/schema.js +5 -9
  210. package/dist/modules/payment/gql/types.d.ts +2 -2
  211. package/dist/modules/payment/gql/types.js +7 -11
  212. package/dist/modules/payment/grpc/index.d.ts +2 -2
  213. package/dist/modules/payment/grpc/index.js +4 -8
  214. package/dist/modules/payment/index.d.ts +2 -2
  215. package/dist/modules/payment/index.js +20 -17
  216. package/dist/modules/payment/interfaces.d.ts +3 -3
  217. package/dist/modules/payment/interfaces.js +1 -4
  218. package/dist/modules/resource/gql/federation.d.ts +1 -1
  219. package/dist/modules/resource/gql/federation.js +10 -17
  220. package/dist/modules/resource/gql/schema.d.ts +1 -1
  221. package/dist/modules/resource/gql/schema.generated.d.ts +348 -322
  222. package/dist/modules/resource/gql/schema.generated.js +28 -31
  223. package/dist/modules/resource/gql/schema.js +5 -9
  224. package/dist/modules/resource/gql/types.d.ts +2 -2
  225. package/dist/modules/resource/gql/types.js +31 -35
  226. package/dist/modules/resource/grpc/index.d.ts +13 -13
  227. package/dist/modules/resource/grpc/index.js +28 -32
  228. package/dist/modules/resource/index.d.ts +2 -2
  229. package/dist/modules/resource/index.js +20 -17
  230. package/dist/modules/resource/interfaces.d.ts +3 -3
  231. package/dist/modules/resource/interfaces.js +1 -4
  232. package/dist/modules/scheduling/gql/federation.d.ts +1 -1
  233. package/dist/modules/scheduling/gql/federation.js +10 -17
  234. package/dist/modules/scheduling/gql/schema.d.ts +1 -1
  235. package/dist/modules/scheduling/gql/schema.generated.d.ts +109 -83
  236. package/dist/modules/scheduling/gql/schema.generated.js +10 -13
  237. package/dist/modules/scheduling/gql/schema.js +5 -9
  238. package/dist/modules/scheduling/gql/types.d.ts +2 -2
  239. package/dist/modules/scheduling/gql/types.js +7 -11
  240. package/dist/modules/scheduling/grpc/index.d.ts +2 -2
  241. package/dist/modules/scheduling/grpc/index.js +4 -8
  242. package/dist/modules/scheduling/index.d.ts +2 -2
  243. package/dist/modules/scheduling/index.js +20 -17
  244. package/dist/modules/scheduling/interfaces.d.ts +3 -3
  245. package/dist/modules/scheduling/interfaces.js +1 -4
  246. package/dist/utils.d.ts +3 -3
  247. package/dist/utils.js +4 -9
  248. package/generate.ts +42 -42
  249. package/jest.config.cjs +23 -0
  250. package/package.json +18 -13
  251. package/tsconfig-base.json +8 -0
  252. package/tsconfig.debug.json +5 -1
  253. package/tsconfig.test.json +17 -2
  254. package/jest.config.js +0 -14
@@ -1,44 +1,24 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
27
9
  };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.generateSubServiceResolvers = exports.generateResolver = exports.registerResolverFunction = exports.getGQLResolverFunctions = void 0;
30
- const types_1 = require("./types");
31
- const array_prototype_flat_1 = __importDefault(require("array.prototype.flat"));
32
- const registry_1 = require("./registry");
33
- const graphql_1 = require("./graphql");
34
- const utils_1 = require("./utils");
35
- const rc_grpc_clients_1 = require("@restorecommerce/rc-grpc-clients");
36
- const resource_base_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/resource_base");
37
- const stream = __importStar(require("stream"));
38
- const _ = __importStar(require("lodash"));
39
- const kafka_client_1 = require("@restorecommerce/kafka-client");
10
+ import { authSubjectType } from './types.js';
11
+ import flat from 'array.prototype.flat';
12
+ import { getTyping } from './registry.js';
13
+ import { getWhitelistBlacklistConfig, Mutate, postProcessGQLValue, preprocessGQLInput, } from './graphql.js';
14
+ import { camelCase, capitalize, convertEnumToInt, decodeBufferFields, getKeys, snakeToCamel, useSubscriptions, getServiceName } from './utils.js';
15
+ import { ReadRequest } from '@restorecommerce/rc-grpc-clients';
16
+ import { Filter_Operation, Filter_ValueType, FilterOp_Operator } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/resource_base.js';
17
+ import * as stream from 'node:stream';
18
+ import _ from 'lodash';
19
+ import { Events } from '@restorecommerce/kafka-client';
40
20
  const inputMethodType = new Map();
41
- const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
21
+ export const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
42
22
  if (!service.method) {
43
23
  return {};
44
24
  }
@@ -50,8 +30,8 @@ const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
50
30
  return {};
51
31
  }
52
32
  }
53
- const typing = (0, registry_1.getTyping)(method.inputType);
54
- const outputTyping = (0, registry_1.getTyping)(method.outputType);
33
+ const typing = getTyping(method.inputType);
34
+ const outputTyping = getTyping(method.outputType);
55
35
  if (!typing) {
56
36
  throw Error(`Method '${method.name}' could not find input type: ${method.inputType}`);
57
37
  }
@@ -64,31 +44,31 @@ const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
64
44
  let subjectField = null;
65
45
  if (typing) {
66
46
  for (let field of typing.meta.field) {
67
- if (field.typeName === types_1.authSubjectType) {
47
+ if (field.typeName === authSubjectType) {
68
48
  subjectField = field.name;
69
49
  break;
70
50
  }
71
51
  }
72
52
  }
73
53
  let methodName = method.name;
74
- if (graphql_1.Mutate.indexOf(method.name) > -1) {
54
+ if (Mutate.indexOf(method.name) > -1) {
75
55
  methodName = 'Mutate';
76
56
  }
77
57
  if (methodName in obj) {
78
58
  return obj;
79
59
  }
80
- obj[methodName] = async (args, context) => {
81
- var _a, _b;
60
+ obj[methodName] = (args, context) => __awaiter(void 0, void 0, void 0, function* () {
61
+ var _e, _f;
82
62
  const client = context[key].client;
83
63
  const service = client[serviceKey];
84
64
  try {
85
- const converted = await (0, graphql_1.preprocessGQLInput)(args.input, typing.input);
86
- const scope = (_a = args === null || args === void 0 ? void 0 : args.input) === null || _a === void 0 ? void 0 : _a.scope;
65
+ const converted = yield preprocessGQLInput(args.input, typing.input);
66
+ const scope = (_e = args === null || args === void 0 ? void 0 : args.input) === null || _e === void 0 ? void 0 : _e.scope;
87
67
  let req = typing.processor.fromPartial(converted);
88
68
  // convert enum strings to integers
89
- req = (0, utils_1.convertEnumToInt)(typing, req);
69
+ req = convertEnumToInt(typing, req);
90
70
  if (subjectField !== null) {
91
- req.subject = (0, registry_1.getTyping)(types_1.authSubjectType).processor.fromPartial({});
71
+ req.subject = getTyping(authSubjectType).processor.fromPartial({});
92
72
  const authToken = context.request.req.headers['authorization'];
93
73
  if (authToken && authToken.startsWith('Bearer ')) {
94
74
  req.subject.token = authToken.split(' ')[1];
@@ -98,8 +78,8 @@ const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
98
78
  }
99
79
  }
100
80
  let realMethod = method.name;
101
- if (graphql_1.Mutate.indexOf(method.name) > -1) {
102
- const mode = (_b = args === null || args === void 0 ? void 0 : args.input) === null || _b === void 0 ? void 0 : _b.mode;
81
+ if (Mutate.indexOf(method.name) > -1) {
82
+ const mode = (_f = args === null || args === void 0 ? void 0 : args.input) === null || _f === void 0 ? void 0 : _f.mode;
103
83
  if (!mode) {
104
84
  throw new Error('Please specify mode');
105
85
  }
@@ -113,14 +93,14 @@ const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
113
93
  realMethod = 'Upsert';
114
94
  }
115
95
  }
116
- const methodFunc = service[(0, utils_1.camelCase)(realMethod)] || service[realMethod];
117
- const rawResult = await methodFunc(req);
118
- const result = (0, graphql_1.postProcessGQLValue)(rawResult, outputTyping.output);
96
+ const methodFunc = service[camelCase(realMethod)] || service[realMethod];
97
+ const rawResult = yield methodFunc(req);
98
+ const result = postProcessGQLValue(rawResult, outputTyping.output);
119
99
  const grpcClientConfig = cfg.client;
120
- const bufferFields = (0, utils_1.getKeys)(grpcClientConfig === null || grpcClientConfig === void 0 ? void 0 : grpcClientConfig.bufferFields);
100
+ const bufferFields = getKeys(grpcClientConfig === null || grpcClientConfig === void 0 ? void 0 : grpcClientConfig.bufferFields);
121
101
  if (result instanceof stream.Readable) {
122
102
  let operationStatus = { code: 0, message: '' };
123
- let aggregatedResponse = await new Promise((resolve, reject) => {
103
+ let aggregatedResponse = yield new Promise((resolve, reject) => {
124
104
  let response = {};
125
105
  let combinedChunks = {};
126
106
  result.on('data', (chunk) => {
@@ -173,17 +153,17 @@ const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
173
153
  return { details: aggregatedResponse, operationStatus };
174
154
  }
175
155
  if ('items' in result) {
176
- let items = (0, utils_1.decodeBufferFields)(result.items, bufferFields);
156
+ let items = decodeBufferFields(result.items, bufferFields);
177
157
  return {
178
158
  details: {
179
- items: items,
159
+ items,
180
160
  operationStatus: result.operationStatus // overall status
181
161
  },
182
162
  };
183
163
  }
184
164
  else {
185
165
  return {
186
- details: (0, utils_1.decodeBufferFields)([result], bufferFields)[0]
166
+ details: decodeBufferFields([result], bufferFields)[0]
187
167
  };
188
168
  }
189
169
  }
@@ -199,14 +179,13 @@ const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
199
179
  }
200
180
  };
201
181
  }
202
- };
182
+ });
203
183
  return obj;
204
184
  }, {});
205
185
  };
206
- exports.getGQLResolverFunctions = getGQLResolverFunctions;
207
186
  const namespaceResolverRegistry = new Map();
208
187
  const subscriptionResolvers = {};
209
- const registerResolverFunction = (namespace, name, func, mutation = false, subspace = undefined, service) => {
188
+ export const registerResolverFunction = (namespace, name, func, mutation = false, subspace = undefined, service) => {
210
189
  if (!namespaceResolverRegistry.has(namespace)) {
211
190
  namespaceResolverRegistry.set(namespace, new Map());
212
191
  }
@@ -237,8 +216,7 @@ const registerResolverFunction = (namespace, name, func, mutation = false, subsp
237
216
  }
238
217
  space.set(name, func);
239
218
  };
240
- exports.registerResolverFunction = registerResolverFunction;
241
- const generateResolver = (...namespaces) => {
219
+ export const generateResolver = (...namespaces) => {
242
220
  const queryResolvers = {};
243
221
  const mutationResolvers = {};
244
222
  namespaces.forEach(ns => {
@@ -282,30 +260,29 @@ const generateResolver = (...namespaces) => {
282
260
  }
283
261
  return resolvers;
284
262
  };
285
- exports.generateResolver = generateResolver;
286
- const generateSubServiceResolvers = (subServices, config, namespace) => {
263
+ export const generateSubServiceResolvers = (subServices, config, namespace) => {
287
264
  subServices.forEach((meta) => {
288
265
  var _a;
289
266
  meta.fileDescriptor.service.forEach(service => {
290
267
  if (service.name) {
291
268
  // strip Service from end of String for sub service name
292
- const subName = (0, utils_1.getServiceName)(service.name);
293
- const { mutations, queries } = (0, graphql_1.getWhitelistBlacklistConfig)(service, config, meta, subName);
294
- const func = (0, exports.getGQLResolverFunctions)(service, namespace, subName || namespace, config);
269
+ const subName = getServiceName(service.name);
270
+ const { mutations, queries } = getWhitelistBlacklistConfig(service, config, meta, subName);
271
+ const func = getGQLResolverFunctions(service, namespace, subName || namespace, config);
295
272
  Object.keys(func).forEach(k => {
296
273
  const regNamespace = config.root ? subName : namespace;
297
274
  const regSubspace = config.root ? undefined : subName;
298
- (0, exports.registerResolverFunction)(regNamespace, k, func[k], !queries.has(k) && mutations.has(k), regSubspace, service);
275
+ registerResolverFunction(regNamespace, k, func[k], !queries.has(k) && mutations.has(k), regSubspace, service);
299
276
  });
300
277
  }
301
278
  });
302
- if (utils_1.useSubscriptions) {
279
+ if (useSubscriptions) {
303
280
  Object.entries(((_a = meta.options) === null || _a === void 0 ? void 0 : _a.messages) || {}).forEach(([messageName, option]) => {
304
281
  if (option.options && 'kafka_subscriber' in option.options) {
305
282
  const kafkaSubscriber = option.options.kafka_subscriber;
306
- const fieldName = namespace + (0, utils_1.capitalize)(kafkaSubscriber.plural);
283
+ const fieldName = namespace + capitalize(kafkaSubscriber.plural);
307
284
  const baseMessageName = meta.fileDescriptor.package + '.' + messageName;
308
- const typing = (0, registry_1.getTyping)('.' + baseMessageName);
285
+ const typing = getTyping('.' + baseMessageName);
309
286
  if (typing) {
310
287
  subscriptionResolvers[fieldName] = {
311
288
  // resolve: (parent, args, context, info) => {
@@ -323,7 +300,7 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
323
300
  // // TODO Implement user lookup
324
301
  // return obj;
325
302
  // },
326
- subscribe: async (parent, args, context, info) => {
303
+ subscribe: (parent, args, context, info) => __awaiter(void 0, void 0, void 0, function* () {
327
304
  const action = args.action || 'CREATED';
328
305
  let event = kafkaSubscriber.created;
329
306
  switch (action) {
@@ -334,17 +311,15 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
334
311
  event = kafkaSubscriber.deleted;
335
312
  break;
336
313
  }
337
- const events = new kafka_client_1.Events({
314
+ const events = new Events({
338
315
  provider: 'kafka',
339
- kafka: {
340
- ...context.kafkaConfig
341
- },
316
+ kafka: Object.assign({}, context.kafkaConfig),
342
317
  [event]: {
343
318
  messageObject: baseMessageName
344
319
  }
345
320
  }, context.logger);
346
- await events.start();
347
- const commandTopic = await events.topic(kafkaSubscriber.topic);
321
+ yield events.start();
322
+ const commandTopic = yield events.topic(kafkaSubscriber.topic);
348
323
  let deferred = null;
349
324
  const pending = [];
350
325
  commandTopic.on(event, (message) => {
@@ -355,23 +330,23 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
355
330
  [Symbol.asyncIterator]() {
356
331
  return this;
357
332
  },
358
- async next() {
333
+ next: () => __awaiter(void 0, void 0, void 0, function* () {
359
334
  if (pending.length) {
360
335
  return { value: { [fieldName]: pending.shift() } };
361
336
  }
362
- return (await new Promise((resolve, reject) => (deferred = { resolve, reject })))
337
+ return (yield new Promise((resolve, reject) => (deferred = { resolve, reject })))
363
338
  ? { done: true, value: undefined }
364
339
  : { value: { [fieldName]: pending.shift() } };
365
- },
366
- async throw(err) {
340
+ }),
341
+ throw: (err) => __awaiter(void 0, void 0, void 0, function* () {
367
342
  throw err;
368
- },
369
- async return() {
370
- await events.stop();
343
+ }),
344
+ return: () => __awaiter(void 0, void 0, void 0, function* () {
345
+ yield events.stop();
371
346
  return { done: true, value: undefined };
372
- },
347
+ }),
373
348
  };
374
- }
349
+ })
375
350
  };
376
351
  }
377
352
  }
@@ -379,32 +354,32 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
379
354
  }
380
355
  });
381
356
  if (config.root) {
382
- return (0, exports.generateResolver)(...(0, array_prototype_flat_1.default)(subServices.map(meta => {
357
+ return generateResolver(...flat(subServices.map(meta => {
383
358
  return meta.fileDescriptor.service.map(service => {
384
359
  if (service.name) {
385
- return (0, utils_1.getServiceName)(service.name);
360
+ return getServiceName(service.name);
386
361
  }
387
362
  return '';
388
363
  }).filter(s => s !== '');
389
364
  })));
390
365
  }
391
- const finalResolver = (0, exports.generateResolver)(namespace);
366
+ const finalResolver = generateResolver(namespace);
392
367
  subServices.forEach((meta) => {
393
368
  meta.fileDescriptor.service.forEach(service => {
394
369
  if (meta.options && meta.options.messages) {
395
370
  for (const key of Object.keys(meta.options.messages)) {
396
371
  const message = meta.options.messages[key];
397
372
  if (message.fields) {
398
- const typing = (0, registry_1.getTyping)('.' + meta.fileDescriptor.package + '.' + key);
373
+ const typing = getTyping('.' + meta.fileDescriptor.package + '.' + key);
399
374
  if (typing) {
400
375
  const result = {};
401
376
  for (const fieldName of Object.keys(message.fields)) {
402
377
  const field = message.fields[fieldName];
403
378
  if ('resolver' in field) {
404
- const fieldJsonName = (0, utils_1.snakeToCamel)(fieldName);
379
+ const fieldJsonName = snakeToCamel(fieldName);
405
380
  const resolver = field['resolver'];
406
381
  // TODO This creates an N+1 problem!
407
- result[resolver.fieldName] = async (parent, _, ctx) => {
382
+ result[resolver.fieldName] = (parent, _, ctx) => __awaiter(void 0, void 0, void 0, function* () {
408
383
  if (!parent || !(fieldJsonName in parent) || parent[fieldJsonName] === undefined) {
409
384
  return undefined;
410
385
  }
@@ -412,24 +387,24 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
412
387
  const service = client[resolver.targetSubService];
413
388
  const idList = Array.isArray(parent[fieldJsonName]) ? parent[fieldJsonName] : [parent[fieldJsonName]];
414
389
  // TODO Support custom input messages
415
- const req = rc_grpc_clients_1.ReadRequest.fromPartial({
390
+ const req = ReadRequest.fromPartial({
416
391
  filters: [{
417
392
  filter: idList.map(id => ({
418
393
  field: 'id',
419
- operation: resource_base_1.Filter_Operation.eq,
394
+ operation: Filter_Operation.eq,
420
395
  value: id,
421
- type: resource_base_1.Filter_ValueType.STRING
396
+ type: Filter_ValueType.STRING
422
397
  })),
423
- operator: resource_base_1.FilterOp_Operator.or
398
+ operator: FilterOp_Operator.or
424
399
  }]
425
400
  });
426
- req.subject = (0, registry_1.getTyping)(types_1.authSubjectType).processor.fromPartial({});
401
+ req.subject = getTyping(authSubjectType).processor.fromPartial({});
427
402
  const authToken = ctx.request.req.headers['authorization'];
428
403
  if (authToken && authToken.startsWith('Bearer ')) {
429
404
  req.subject.token = authToken.split(' ')[1];
430
405
  }
431
- const methodFunc = service[(0, utils_1.camelCase)(resolver.targetMethod)] || service[resolver.targetMethod];
432
- const result = await methodFunc(req);
406
+ const methodFunc = service[camelCase(resolver.targetMethod)] || service[resolver.targetMethod];
407
+ const result = yield methodFunc(req);
433
408
  if (result && result.items && result.items.length) {
434
409
  if (Array.isArray(parent[fieldJsonName])) {
435
410
  return result.items.map((item) => item.payload);
@@ -439,7 +414,7 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
439
414
  }
440
415
  }
441
416
  return undefined;
442
- };
417
+ });
443
418
  }
444
419
  }
445
420
  finalResolver[typing.output.name] = result;
@@ -451,4 +426,3 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
451
426
  });
452
427
  return finalResolver;
453
428
  };
454
- exports.generateSubServiceResolvers = generateSubServiceResolvers;
@@ -1,7 +1,7 @@
1
- import { MethodDescriptorProto, ServiceDescriptorProto } from 'ts-proto-descriptors';
2
- import { ProtoMetadata, ServiceConfig, SubSpaceServiceConfig } from './types';
3
- import { GraphQLSchema, ThunkObjMap } from 'graphql';
4
- import { GraphQLFieldConfig, GraphQLFieldConfigMap } from 'graphql/type/definition';
1
+ import { type MethodDescriptorProto, type ServiceDescriptorProto } from 'ts-proto-descriptors';
2
+ import { type ProtoMetadata, type ServiceConfig, type SubSpaceServiceConfig } from './types.js';
3
+ import { GraphQLSchema, type ThunkObjMap } from 'graphql';
4
+ import { type GraphQLFieldConfig, type GraphQLFieldConfigMap } from 'graphql/type/definition.js';
5
5
  export declare const getGQLSchema: <TSource, TContext>(method: MethodDescriptorProto) => GraphQLFieldConfig<TSource, TContext, any>;
6
6
  export declare const getGQLSchemas: <TSource, TContext>(service: ServiceDescriptorProto) => GraphQLFieldConfigMap<TSource, TContext>;
7
7
  type SchemaBaseOrSub = ThunkObjMap<GraphQLFieldConfig<any, any>> | Map<string, ThunkObjMap<GraphQLFieldConfig<any, any>>>;
@@ -1,16 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateSubServiceSchemas = exports.generateSchema = exports.registerResolverSchema = exports.getGQLSchemas = exports.getGQLSchema = void 0;
7
- const graphql_1 = require("graphql");
8
- const array_prototype_flat_1 = __importDefault(require("array.prototype.flat"));
9
- const graphql_2 = require("./graphql");
10
- const utils_1 = require("./utils");
11
- const registry_1 = require("./registry");
1
+ import { GraphQLSchema, GraphQLNonNull, GraphQLObjectType, GraphQLString, GraphQLEnumType } from 'graphql';
2
+ import flat from 'array.prototype.flat';
3
+ import { getWhitelistBlacklistConfig, Mutate } from './graphql.js';
4
+ import { capitalize, capitalizeProtoName, useSubscriptions, getServiceName } from './utils.js';
5
+ import { getTyping } from './registry.js';
12
6
  const typeCache = new Map();
13
- const subscriptionAction = new graphql_1.GraphQLEnumType({
7
+ const subscriptionAction = new GraphQLEnumType({
14
8
  name: 'SubscriptionAction',
15
9
  values: {
16
10
  CREATED: { value: 'CREATED' },
@@ -23,17 +17,17 @@ const subscriptionInput = {
23
17
  type: subscriptionAction
24
18
  }
25
19
  };
26
- const subscriptionOutput = new graphql_1.GraphQLObjectType({
20
+ const subscriptionOutput = new GraphQLObjectType({
27
21
  name: 'SubscriptionOutput',
28
22
  fields: {
29
23
  id: {
30
- type: graphql_1.GraphQLString
24
+ type: GraphQLString
31
25
  }
32
26
  }
33
27
  });
34
- const getGQLSchema = (method) => {
28
+ export const getGQLSchema = (method) => {
35
29
  const fields = {};
36
- const responseTyping = (0, registry_1.getTyping)(method.outputType);
30
+ const responseTyping = getTyping(method.outputType);
37
31
  if (!responseTyping) {
38
32
  throw Error('Method doesn\'t have registered typings: ' + method.outputType);
39
33
  }
@@ -42,16 +36,16 @@ const getGQLSchema = (method) => {
42
36
  type: responseTyping.output,
43
37
  };
44
38
  }
45
- const outName = 'Proto' + (0, utils_1.capitalizeProtoName)(method.outputType);
39
+ const outName = 'Proto' + capitalizeProtoName(method.outputType);
46
40
  let out = typeCache.get(outName);
47
41
  if (!out) {
48
- out = new graphql_1.GraphQLObjectType({
42
+ out = new GraphQLObjectType({
49
43
  name: outName,
50
44
  fields,
51
45
  });
52
46
  typeCache.set(outName, out);
53
47
  }
54
- const typing = (0, registry_1.getTyping)(method.inputType);
48
+ const typing = getTyping(method.inputType);
55
49
  if (!typing) {
56
50
  throw Error('Method doesn\'t have registered typings: ' + method.inputType);
57
51
  }
@@ -59,23 +53,21 @@ const getGQLSchema = (method) => {
59
53
  type: out,
60
54
  args: method.inputType === '.google.protobuf.Empty' ? undefined : {
61
55
  input: {
62
- type: new graphql_1.GraphQLNonNull(typing.input)
56
+ type: new GraphQLNonNull(typing.input)
63
57
  }
64
58
  }
65
59
  };
66
60
  };
67
- exports.getGQLSchema = getGQLSchema;
68
- const getGQLSchemas = (service) => {
61
+ export const getGQLSchemas = (service) => {
69
62
  var _a;
70
63
  return (_a = service.method) === null || _a === void 0 ? void 0 : _a.reduce((obj, method) => {
71
- obj[method.name] = (0, exports.getGQLSchema)(method);
64
+ obj[method.name] = getGQLSchema(method);
72
65
  return obj;
73
66
  }, {});
74
67
  };
75
- exports.getGQLSchemas = getGQLSchemas;
76
68
  const namespaceResolverSchemaRegistry = new Map();
77
69
  const subscriptionFields = {};
78
- const registerResolverSchema = (namespace, name, schema, mutation = false, subspace = undefined, config) => {
70
+ export const registerResolverSchema = (namespace, name, schema, mutation = false, subspace = undefined, config) => {
79
71
  if (!namespaceResolverSchemaRegistry.has(namespace)) {
80
72
  namespaceResolverSchemaRegistry.set(namespace, new Map());
81
73
  }
@@ -104,13 +96,12 @@ const registerResolverSchema = (namespace, name, schema, mutation = false, subsp
104
96
  }
105
97
  }
106
98
  // register create, update and upsert with Mutate
107
- if (graphql_2.Mutate.indexOf(name) > -1) {
99
+ if (Mutate.indexOf(name) > -1) {
108
100
  name = 'Mutate';
109
101
  }
110
102
  space.set(name, schema);
111
103
  };
112
- exports.registerResolverSchema = registerResolverSchema;
113
- const generateSchema = (setup) => {
104
+ export const generateSchema = (setup) => {
114
105
  const queryFields = {};
115
106
  const mutationFields = {};
116
107
  setup.forEach(s => {
@@ -121,9 +112,9 @@ const generateSchema = (setup) => {
121
112
  const fields = {};
122
113
  namespaceResolverSchemaRegistry.get(s.namespace).get(false).forEach((value, key) => {
123
114
  if (value instanceof Map) {
124
- const capitalName = (0, utils_1.capitalizeProtoName)(key);
115
+ const capitalName = capitalizeProtoName(key);
125
116
  fields[key] = {
126
- type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLObjectType({
117
+ type: new GraphQLNonNull(new GraphQLObjectType({
127
118
  name: s.prefix + capitalName + 'Query',
128
119
  fields: Object.fromEntries(value),
129
120
  }))
@@ -134,7 +125,7 @@ const generateSchema = (setup) => {
134
125
  }
135
126
  });
136
127
  queryFields[s.namespace] = {
137
- type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLObjectType({
128
+ type: new GraphQLNonNull(new GraphQLObjectType({
138
129
  name: s.prefix + 'Query',
139
130
  fields
140
131
  }))
@@ -144,9 +135,9 @@ const generateSchema = (setup) => {
144
135
  const fields = {};
145
136
  namespaceResolverSchemaRegistry.get(s.namespace).get(true).forEach((value, key) => {
146
137
  if (value instanceof Map) {
147
- const capitalName = (0, utils_1.capitalizeProtoName)(key);
138
+ const capitalName = capitalizeProtoName(key);
148
139
  fields[key] = {
149
- type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLObjectType({
140
+ type: new GraphQLNonNull(new GraphQLObjectType({
150
141
  name: s.prefix + capitalName + 'Mutation',
151
142
  fields: Object.fromEntries(value),
152
143
  }))
@@ -157,7 +148,7 @@ const generateSchema = (setup) => {
157
148
  }
158
149
  });
159
150
  mutationFields[s.namespace] = {
160
- type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLObjectType({
151
+ type: new GraphQLNonNull(new GraphQLObjectType({
161
152
  name: s.prefix + 'Mutation',
162
153
  fields
163
154
  }))
@@ -166,46 +157,43 @@ const generateSchema = (setup) => {
166
157
  });
167
158
  const config = {};
168
159
  if (Object.keys(queryFields).length > 0) {
169
- config.query = new graphql_1.GraphQLObjectType({
160
+ config.query = new GraphQLObjectType({
170
161
  name: 'Query',
171
162
  fields: queryFields
172
163
  });
173
164
  }
174
165
  if (Object.keys(mutationFields).length > 0) {
175
- config.mutation = new graphql_1.GraphQLObjectType({
166
+ config.mutation = new GraphQLObjectType({
176
167
  name: 'Mutation',
177
168
  fields: mutationFields
178
169
  });
179
170
  }
180
171
  if (Object.keys(subscriptionFields).length > 0) {
181
- config.subscription = new graphql_1.GraphQLObjectType({
172
+ config.subscription = new GraphQLObjectType({
182
173
  name: 'Subscription',
183
174
  fields: subscriptionFields
184
175
  });
185
176
  }
186
- return new graphql_1.GraphQLSchema({
187
- ...config,
188
- });
177
+ return new GraphQLSchema(Object.assign({}, config));
189
178
  };
190
- exports.generateSchema = generateSchema;
191
- const generateSubServiceSchemas = (subServices, config, namespace, prefix) => {
179
+ export const generateSubServiceSchemas = (subServices, config, namespace, prefix) => {
192
180
  subServices.forEach((meta) => {
193
181
  var _a;
194
182
  meta.fileDescriptor.service.forEach(service => {
195
183
  if (service.name) {
196
- const subName = (0, utils_1.getServiceName)(service.name);
197
- const { mutations, queries } = (0, graphql_2.getWhitelistBlacklistConfig)(service, config, meta, subName);
198
- const schemas = (0, exports.getGQLSchemas)(service);
184
+ const subName = getServiceName(service.name);
185
+ const { mutations, queries } = getWhitelistBlacklistConfig(service, config, meta, subName);
186
+ const schemas = getGQLSchemas(service);
199
187
  Object.keys(schemas).forEach(key => {
200
- (0, exports.registerResolverSchema)(config.root ? subName : namespace, key, schemas[key], !queries.has(key) && mutations.has(key), config.root ? undefined : subName, config);
188
+ registerResolverSchema(config.root ? subName : namespace, key, schemas[key], !queries.has(key) && mutations.has(key), config.root ? undefined : subName, config);
201
189
  });
202
190
  }
203
191
  });
204
- if (utils_1.useSubscriptions) {
192
+ if (useSubscriptions) {
205
193
  Object.entries(((_a = meta.options) === null || _a === void 0 ? void 0 : _a.messages) || {}).forEach(([messageName, option]) => {
206
194
  if (option.options && 'kafka_subscriber' in option.options) {
207
- const fieldName = namespace + (0, utils_1.capitalize)(option.options.kafka_subscriber.plural);
208
- const typing = (0, registry_1.getTyping)('.' + meta.fileDescriptor.package + '.' + messageName);
195
+ const fieldName = namespace + capitalize(option.options.kafka_subscriber.plural);
196
+ const typing = getTyping('.' + meta.fileDescriptor.package + '.' + messageName);
209
197
  if (typing) {
210
198
  subscriptionFields[fieldName] = {
211
199
  // TODO Implement user lookup
@@ -219,10 +207,10 @@ const generateSubServiceSchemas = (subServices, config, namespace, prefix) => {
219
207
  }
220
208
  });
221
209
  if (config.root) {
222
- return (0, exports.generateSchema)((0, array_prototype_flat_1.default)(subServices.map(meta => {
210
+ return generateSchema(flat(subServices.map(meta => {
223
211
  return meta.fileDescriptor.service.map(service => {
224
212
  if (service.name) {
225
- const subName = (0, utils_1.getServiceName)(service.name);
213
+ const subName = getServiceName(service.name);
226
214
  return {
227
215
  prefix: prefix + subName.substring(0, 1).toUpperCase() + subName.substring(1).toLowerCase(),
228
216
  namespace: subName
@@ -232,6 +220,5 @@ const generateSubServiceSchemas = (subServices, config, namespace, prefix) => {
232
220
  }).filter(s => s !== null);
233
221
  })));
234
222
  }
235
- return (0, exports.generateSchema)([{ prefix, namespace }]);
223
+ return generateSchema([{ prefix, namespace }]);
236
224
  };
237
- exports.generateSubServiceSchemas = generateSubServiceSchemas;
@@ -1,6 +1,6 @@
1
- import { GrpcClientConfig } from "@restorecommerce/grpc-client";
2
- import { FileDescriptorProto } from "ts-proto-descriptors";
3
- import { GraphQLSchema, GraphQLFieldResolver, GraphQLScalarType } from 'graphql';
1
+ import { type GrpcClientConfig } from '@restorecommerce/grpc-client';
2
+ import { type FileDescriptorProto } from 'ts-proto-descriptors';
3
+ import { type GraphQLSchema, type GraphQLFieldResolver, type GraphQLScalarType } from 'graphql';
4
4
  export interface GraphQLResolverMap<TContext = {}> {
5
5
  [typeName: string]: {
6
6
  [fieldName: string]: GraphQLFieldResolver<any, TContext, any> | {
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.authSubjectType = void 0;
4
- exports.authSubjectType = '.io.restorecommerce.auth.Subject';
1
+ export const authSubjectType = '.io.restorecommerce.auth.Subject';