@restorecommerce/facade 1.3.9 → 1.3.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 (267) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +19 -0
  3. package/codegen/index.d.ts +12 -0
  4. package/codegen/index.js +43 -0
  5. package/dist/gql/index.d.ts +1 -0
  6. package/dist/gql/index.js +1 -0
  7. package/dist/gql/protos/federation.d.ts +6 -0
  8. package/dist/gql/protos/federation.js +46 -0
  9. package/dist/gql/protos/graphql.d.ts +11 -0
  10. package/dist/gql/protos/graphql.js +158 -0
  11. package/dist/gql/protos/index.d.ts +6 -0
  12. package/dist/gql/protos/index.js +6 -0
  13. package/dist/gql/protos/registry.d.ts +23 -0
  14. package/dist/gql/protos/registry.js +366 -0
  15. package/dist/gql/protos/resolvers.d.ts +9 -0
  16. package/dist/gql/protos/resolvers.js +487 -0
  17. package/dist/gql/protos/schema.d.ts +14 -0
  18. package/dist/gql/protos/schema.js +224 -0
  19. package/dist/gql/protos/stream-to-async-iterator.d.ts +50 -0
  20. package/dist/gql/protos/stream-to-async-iterator.js +190 -0
  21. package/dist/gql/protos/types.d.ts +96 -0
  22. package/dist/gql/protos/types.js +1 -0
  23. package/dist/gql/protos/utils.d.ts +18 -0
  24. package/dist/gql/protos/utils.js +133 -0
  25. package/dist/gql/types/AccessControlTypes.d.ts +6 -0
  26. package/dist/gql/types/AccessControlTypes.js +97 -0
  27. package/dist/gql/types/DateType.d.ts +2 -0
  28. package/dist/gql/types/DateType.js +29 -0
  29. package/dist/gql/types/FilterType.d.ts +2 -0
  30. package/dist/gql/types/FilterType.js +72 -0
  31. package/dist/gql/types/MetaType.d.ts +2 -0
  32. package/dist/gql/types/MetaType.js +25 -0
  33. package/dist/gql/types/ScopeType.d.ts +2 -0
  34. package/dist/gql/types/ScopeType.js +13 -0
  35. package/dist/gql/types/SortType.d.ts +3 -0
  36. package/dist/gql/types/SortType.js +30 -0
  37. package/dist/gql/types/StatusType.d.ts +2 -0
  38. package/dist/gql/types/StatusType.js +15 -0
  39. package/dist/gql/types/index.d.ts +7 -0
  40. package/dist/gql/types/index.js +7 -0
  41. package/dist/index.d.ts +66 -0
  42. package/dist/index.js +315 -0
  43. package/dist/interfaces.d.ts +54 -0
  44. package/dist/interfaces.js +6 -0
  45. package/dist/middlewares/index.d.ts +1 -0
  46. package/dist/middlewares/index.js +1 -0
  47. package/dist/middlewares/req-res-logger/index.d.ts +14 -0
  48. package/dist/middlewares/req-res-logger/index.js +90 -0
  49. package/dist/modules/access-control/gql/federation.d.ts +2 -0
  50. package/dist/modules/access-control/gql/federation.js +13 -0
  51. package/dist/modules/access-control/gql/schema.d.ts +2 -0
  52. package/dist/modules/access-control/gql/schema.generated.d.ts +1147 -0
  53. package/dist/modules/access-control/gql/schema.generated.js +80 -0
  54. package/dist/modules/access-control/gql/schema.js +5 -0
  55. package/dist/modules/access-control/gql/types.d.ts +3 -0
  56. package/dist/modules/access-control/gql/types.js +14 -0
  57. package/dist/modules/access-control/grpc/index.d.ts +13 -0
  58. package/dist/modules/access-control/grpc/index.js +14 -0
  59. package/dist/modules/access-control/index.d.ts +2 -0
  60. package/dist/modules/access-control/index.js +26 -0
  61. package/dist/modules/access-control/interfaces.d.ts +15 -0
  62. package/dist/modules/access-control/interfaces.js +1 -0
  63. package/dist/modules/catalog/gql/federation.d.ts +2 -0
  64. package/dist/modules/catalog/gql/federation.js +13 -0
  65. package/dist/modules/catalog/gql/schema.d.ts +2 -0
  66. package/dist/modules/catalog/gql/schema.generated.d.ts +1981 -0
  67. package/dist/modules/catalog/gql/schema.generated.js +74 -0
  68. package/dist/modules/catalog/gql/schema.js +5 -0
  69. package/dist/modules/catalog/gql/types.d.ts +3 -0
  70. package/dist/modules/catalog/gql/types.js +16 -0
  71. package/dist/modules/catalog/grpc/index.d.ts +15 -0
  72. package/dist/modules/catalog/grpc/index.js +16 -0
  73. package/dist/modules/catalog/index.d.ts +2 -0
  74. package/dist/modules/catalog/index.js +26 -0
  75. package/dist/modules/catalog/interfaces.d.ts +16 -0
  76. package/dist/modules/catalog/interfaces.js +1 -0
  77. package/dist/modules/facade-status/gql/index.d.ts +1 -0
  78. package/dist/modules/facade-status/gql/index.js +11 -0
  79. package/dist/modules/facade-status/gql/resolvers.d.ts +2 -0
  80. package/dist/modules/facade-status/gql/resolvers.js +18 -0
  81. package/dist/modules/facade-status/gql/schema.d.ts +3 -0
  82. package/dist/modules/facade-status/gql/schema.generated.d.ts +109 -0
  83. package/dist/modules/facade-status/gql/schema.generated.js +1 -0
  84. package/dist/modules/facade-status/gql/schema.js +14 -0
  85. package/dist/modules/facade-status/gql/types.d.ts +2 -0
  86. package/dist/modules/facade-status/gql/types.js +10 -0
  87. package/dist/modules/facade-status/index.d.ts +2 -0
  88. package/dist/modules/facade-status/index.js +8 -0
  89. package/dist/modules/facade-status/interfaces.d.ts +4 -0
  90. package/dist/modules/facade-status/interfaces.js +1 -0
  91. package/dist/modules/fulfillment/gql/federation.d.ts +2 -0
  92. package/dist/modules/fulfillment/gql/federation.js +13 -0
  93. package/dist/modules/fulfillment/gql/schema.d.ts +2 -0
  94. package/dist/modules/fulfillment/gql/schema.generated.d.ts +2729 -0
  95. package/dist/modules/fulfillment/gql/schema.generated.js +97 -0
  96. package/dist/modules/fulfillment/gql/schema.js +5 -0
  97. package/dist/modules/fulfillment/gql/types.d.ts +3 -0
  98. package/dist/modules/fulfillment/gql/types.js +12 -0
  99. package/dist/modules/fulfillment/grpc/index.d.ts +9 -0
  100. package/dist/modules/fulfillment/grpc/index.js +10 -0
  101. package/dist/modules/fulfillment/index.d.ts +2 -0
  102. package/dist/modules/fulfillment/index.js +26 -0
  103. package/dist/modules/fulfillment/interfaces.d.ts +16 -0
  104. package/dist/modules/fulfillment/interfaces.js +1 -0
  105. package/dist/modules/identity/api-key/api-key.d.ts +11 -0
  106. package/dist/modules/identity/api-key/api-key.js +137 -0
  107. package/dist/modules/identity/gql/federation.d.ts +2 -0
  108. package/dist/modules/identity/gql/federation.js +5 -0
  109. package/dist/modules/identity/gql/schema.d.ts +2 -0
  110. package/dist/modules/identity/gql/schema.generated.d.ts +1686 -0
  111. package/dist/modules/identity/gql/schema.generated.js +75 -0
  112. package/dist/modules/identity/gql/schema.js +5 -0
  113. package/dist/modules/identity/gql/types.d.ts +3 -0
  114. package/dist/modules/identity/gql/types.js +18 -0
  115. package/dist/modules/identity/grpc/index.d.ts +15 -0
  116. package/dist/modules/identity/grpc/index.js +16 -0
  117. package/dist/modules/identity/index.d.ts +4 -0
  118. package/dist/modules/identity/index.js +54 -0
  119. package/dist/modules/identity/interfaces.d.ts +22 -0
  120. package/dist/modules/identity/interfaces.js +1 -0
  121. package/dist/modules/identity/oauth/oauth.d.ts +11 -0
  122. package/dist/modules/identity/oauth/oauth.js +170 -0
  123. package/dist/modules/identity/oidc/adapter.d.ts +4 -0
  124. package/dist/modules/identity/oidc/adapter.js +135 -0
  125. package/dist/modules/identity/oidc/in-memory-adapter.d.ts +16 -0
  126. package/dist/modules/identity/oidc/in-memory-adapter.js +85 -0
  127. package/dist/modules/identity/oidc/index.d.ts +18 -0
  128. package/dist/modules/identity/oidc/index.js +147 -0
  129. package/dist/modules/identity/oidc/interfaces.d.ts +73 -0
  130. package/dist/modules/identity/oidc/interfaces.js +7 -0
  131. package/dist/modules/identity/oidc/password-grant.d.ts +2 -0
  132. package/dist/modules/identity/oidc/password-grant.js +163 -0
  133. package/dist/modules/identity/oidc/router.d.ts +13 -0
  134. package/dist/modules/identity/oidc/router.js +164 -0
  135. package/dist/modules/identity/oidc/templates.d.ts +36 -0
  136. package/dist/modules/identity/oidc/templates.js +60 -0
  137. package/dist/modules/identity/oidc/user.d.ts +6 -0
  138. package/dist/modules/identity/oidc/user.js +91 -0
  139. package/dist/modules/identity/oidc/utils.d.ts +6 -0
  140. package/dist/modules/identity/oidc/utils.js +15 -0
  141. package/dist/modules/index.d.ts +13 -0
  142. package/dist/modules/index.js +13 -0
  143. package/dist/modules/indexing/gql/federation.d.ts +2 -0
  144. package/dist/modules/indexing/gql/federation.js +13 -0
  145. package/dist/modules/indexing/gql/schema.d.ts +2 -0
  146. package/dist/modules/indexing/gql/schema.generated.d.ts +231 -0
  147. package/dist/modules/indexing/gql/schema.generated.js +6 -0
  148. package/dist/modules/indexing/gql/schema.js +5 -0
  149. package/dist/modules/indexing/gql/types.d.ts +3 -0
  150. package/dist/modules/indexing/gql/types.js +8 -0
  151. package/dist/modules/indexing/grpc/index.d.ts +7 -0
  152. package/dist/modules/indexing/grpc/index.js +8 -0
  153. package/dist/modules/indexing/index.d.ts +2 -0
  154. package/dist/modules/indexing/index.js +26 -0
  155. package/dist/modules/indexing/interfaces.d.ts +13 -0
  156. package/dist/modules/indexing/interfaces.js +1 -0
  157. package/dist/modules/invoicing/gql/federation.d.ts +2 -0
  158. package/dist/modules/invoicing/gql/federation.js +13 -0
  159. package/dist/modules/invoicing/gql/schema.d.ts +2 -0
  160. package/dist/modules/invoicing/gql/schema.generated.d.ts +2196 -0
  161. package/dist/modules/invoicing/gql/schema.generated.js +86 -0
  162. package/dist/modules/invoicing/gql/schema.js +5 -0
  163. package/dist/modules/invoicing/gql/types.d.ts +3 -0
  164. package/dist/modules/invoicing/gql/types.js +8 -0
  165. package/dist/modules/invoicing/grpc/index.d.ts +7 -0
  166. package/dist/modules/invoicing/grpc/index.js +8 -0
  167. package/dist/modules/invoicing/index.d.ts +2 -0
  168. package/dist/modules/invoicing/index.js +26 -0
  169. package/dist/modules/invoicing/interfaces.d.ts +16 -0
  170. package/dist/modules/invoicing/interfaces.js +1 -0
  171. package/dist/modules/master_data/gql/federation.d.ts +2 -0
  172. package/dist/modules/master_data/gql/federation.js +13 -0
  173. package/dist/modules/master_data/gql/schema.d.ts +2 -0
  174. package/dist/modules/master_data/gql/schema.generated.d.ts +2510 -0
  175. package/dist/modules/master_data/gql/schema.generated.js +109 -0
  176. package/dist/modules/master_data/gql/schema.js +5 -0
  177. package/dist/modules/master_data/gql/types.d.ts +3 -0
  178. package/dist/modules/master_data/gql/types.js +32 -0
  179. package/dist/modules/master_data/grpc/index.d.ts +30 -0
  180. package/dist/modules/master_data/grpc/index.js +32 -0
  181. package/dist/modules/master_data/index.d.ts +2 -0
  182. package/dist/modules/master_data/index.js +26 -0
  183. package/dist/modules/master_data/interfaces.d.ts +16 -0
  184. package/dist/modules/master_data/interfaces.js +1 -0
  185. package/dist/modules/notification/gql/federation.d.ts +2 -0
  186. package/dist/modules/notification/gql/federation.js +13 -0
  187. package/dist/modules/notification/gql/schema.d.ts +2 -0
  188. package/dist/modules/notification/gql/schema.generated.d.ts +655 -0
  189. package/dist/modules/notification/gql/schema.generated.js +68 -0
  190. package/dist/modules/notification/gql/schema.js +5 -0
  191. package/dist/modules/notification/gql/types.d.ts +3 -0
  192. package/dist/modules/notification/gql/types.js +8 -0
  193. package/dist/modules/notification/grpc/index.d.ts +7 -0
  194. package/dist/modules/notification/grpc/index.js +8 -0
  195. package/dist/modules/notification/index.d.ts +2 -0
  196. package/dist/modules/notification/index.js +26 -0
  197. package/dist/modules/notification/interfaces.d.ts +16 -0
  198. package/dist/modules/notification/interfaces.js +1 -0
  199. package/dist/modules/ordering/gql/federation.d.ts +2 -0
  200. package/dist/modules/ordering/gql/federation.js +13 -0
  201. package/dist/modules/ordering/gql/schema.d.ts +2 -0
  202. package/dist/modules/ordering/gql/schema.generated.d.ts +2599 -0
  203. package/dist/modules/ordering/gql/schema.generated.js +113 -0
  204. package/dist/modules/ordering/gql/schema.js +5 -0
  205. package/dist/modules/ordering/gql/types.d.ts +3 -0
  206. package/dist/modules/ordering/gql/types.js +8 -0
  207. package/dist/modules/ordering/grpc/index.d.ts +7 -0
  208. package/dist/modules/ordering/grpc/index.js +8 -0
  209. package/dist/modules/ordering/index.d.ts +2 -0
  210. package/dist/modules/ordering/index.js +26 -0
  211. package/dist/modules/ordering/interfaces.d.ts +16 -0
  212. package/dist/modules/ordering/interfaces.js +1 -0
  213. package/dist/modules/ostorage/gql/federation.d.ts +2 -0
  214. package/dist/modules/ostorage/gql/federation.js +13 -0
  215. package/dist/modules/ostorage/gql/schema.d.ts +2 -0
  216. package/dist/modules/ostorage/gql/schema.generated.d.ts +869 -0
  217. package/dist/modules/ostorage/gql/schema.generated.js +31 -0
  218. package/dist/modules/ostorage/gql/schema.js +5 -0
  219. package/dist/modules/ostorage/gql/types.d.ts +3 -0
  220. package/dist/modules/ostorage/gql/types.js +8 -0
  221. package/dist/modules/ostorage/grpc/index.d.ts +7 -0
  222. package/dist/modules/ostorage/grpc/index.js +8 -0
  223. package/dist/modules/ostorage/index.d.ts +2 -0
  224. package/dist/modules/ostorage/index.js +46 -0
  225. package/dist/modules/ostorage/interfaces.d.ts +16 -0
  226. package/dist/modules/ostorage/interfaces.js +1 -0
  227. package/dist/modules/ostorage/objectDownloadReqHandler.d.ts +1 -0
  228. package/dist/modules/ostorage/objectDownloadReqHandler.js +133 -0
  229. package/dist/modules/payment/gql/federation.d.ts +2 -0
  230. package/dist/modules/payment/gql/federation.js +13 -0
  231. package/dist/modules/payment/gql/schema.d.ts +2 -0
  232. package/dist/modules/payment/gql/schema.generated.d.ts +647 -0
  233. package/dist/modules/payment/gql/schema.generated.js +156 -0
  234. package/dist/modules/payment/gql/schema.js +5 -0
  235. package/dist/modules/payment/gql/types.d.ts +3 -0
  236. package/dist/modules/payment/gql/types.js +8 -0
  237. package/dist/modules/payment/grpc/index.d.ts +7 -0
  238. package/dist/modules/payment/grpc/index.js +8 -0
  239. package/dist/modules/payment/index.d.ts +2 -0
  240. package/dist/modules/payment/index.js +26 -0
  241. package/dist/modules/payment/interfaces.d.ts +16 -0
  242. package/dist/modules/payment/interfaces.js +1 -0
  243. package/dist/modules/scheduling/gql/federation.d.ts +2 -0
  244. package/dist/modules/scheduling/gql/federation.js +13 -0
  245. package/dist/modules/scheduling/gql/schema.d.ts +2 -0
  246. package/dist/modules/scheduling/gql/schema.generated.d.ts +651 -0
  247. package/dist/modules/scheduling/gql/schema.generated.js +31 -0
  248. package/dist/modules/scheduling/gql/schema.js +5 -0
  249. package/dist/modules/scheduling/gql/types.d.ts +3 -0
  250. package/dist/modules/scheduling/gql/types.js +8 -0
  251. package/dist/modules/scheduling/grpc/index.d.ts +7 -0
  252. package/dist/modules/scheduling/grpc/index.js +8 -0
  253. package/dist/modules/scheduling/index.d.ts +2 -0
  254. package/dist/modules/scheduling/index.js +26 -0
  255. package/dist/modules/scheduling/interfaces.d.ts +16 -0
  256. package/dist/modules/scheduling/interfaces.js +1 -0
  257. package/dist/utils.d.ts +5 -0
  258. package/dist/utils.js +14 -0
  259. package/package.json +9 -8
  260. package/tsconfig-base.json +19 -8
  261. package/tsconfig.codegen.json +1 -0
  262. package/tsconfig.debug.json +5 -1
  263. package/tsconfig.generate.json +3 -0
  264. package/tsconfig.lib.json +2 -1
  265. package/tsconfig.test.json +22 -1
  266. package/codegen/tsconfig.codegen.tsbuildinfo +0 -1
  267. package/dist/tsconfig.lib.tsbuildinfo +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.3.10](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@1.3.8...@restorecommerce/facade@1.3.10) (2023-07-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * enum conversion to int no longer necessary ([27dcac0](https://github.com/restorecommerce/libs/commit/27dcac03f71c3db92ecae838814dd961aa107ec3))
12
+ * facade grpc client resolution ([4ced730](https://github.com/restorecommerce/libs/commit/4ced730977714cf30bfe45728a7e1ead78f43eca))
13
+ * **facade:** client for renamed resource to master_data ([6929a9e](https://github.com/restorecommerce/libs/commit/6929a9e8cabbc3045047005da2c05ff44b88f2d1))
14
+ * **facade:** convert async iterable to readable stream for file download ([a3f5118](https://github.com/restorecommerce/libs/commit/a3f511865df262495f493547a3d1cbc37b260b42))
15
+ * nested filters for recursive field resolution ([1b6d180](https://github.com/restorecommerce/libs/commit/1b6d180b83e4efbedf54b42b20fb4b4c17996c6a))
16
+
17
+
18
+
19
+
20
+
6
21
  ## [1.3.8](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@1.3.7...@restorecommerce/facade@1.3.8) (2023-06-29)
7
22
 
8
23
  **Note:** Version bump only for package @restorecommerce/facade
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) n-fuse GmbH and other contributors.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ export interface GenerateSchemaTypingsArgs {
2
+ schema: any;
3
+ outputFile: string;
4
+ typescript?: {
5
+ [key: string]: any;
6
+ };
7
+ typescriptResolvers?: {
8
+ contextType?: string;
9
+ [key: string]: any;
10
+ };
11
+ }
12
+ export declare const generateSchemaTypings: ({ schema, outputFile, typescript, typescriptResolvers }: GenerateSchemaTypingsArgs) => Promise<void>;
@@ -0,0 +1,43 @@
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
+ });
9
+ };
10
+ import * as fs from 'node:fs';
11
+ import * as typescriptPlugin from '@graphql-codegen/typescript';
12
+ import * as typescriptResolversPlugin from '@graphql-codegen/typescript-resolvers';
13
+ import { codegen } from '@graphql-codegen/core';
14
+ export const generateSchemaTypings = ({ schema, outputFile, typescript, typescriptResolvers }) => __awaiter(void 0, void 0, void 0, function* () {
15
+ try {
16
+ const codegenConfig /* typings wrong? */ = {
17
+ // used by a plugin internally, although the 'typescript' plugin currently
18
+ // returns the string output, rather than writing to a file
19
+ filename: outputFile,
20
+ schemaAst: schema,
21
+ documents: [],
22
+ plugins: [
23
+ {
24
+ typescript: Object.assign({ maybeValue: 'T | null | undefined', inputMaybeValue: 'T | null | undefined' }, (typescript !== null && typescript !== void 0 ? typescript : {})),
25
+ },
26
+ {
27
+ typescriptResolvers: Object.assign({ noSchemaStitching: true, useIndexSignature: true, federation: true }, (typescriptResolvers !== null && typescriptResolvers !== void 0 ? typescriptResolvers : {})),
28
+ },
29
+ ],
30
+ pluginMap: {
31
+ typescript: typescriptPlugin,
32
+ typescriptResolvers: typescriptResolversPlugin,
33
+ },
34
+ emitLegacyCommonJSImports: false
35
+ };
36
+ const output = yield codegen(codegenConfig);
37
+ fs.writeFileSync(outputFile, output);
38
+ console.log('Schema typings generated in' + outputFile);
39
+ }
40
+ catch (ex) {
41
+ console.error(ex);
42
+ }
43
+ });
@@ -0,0 +1 @@
1
+ export * from './types/index.js';
@@ -0,0 +1 @@
1
+ export * from './types/index.js';
@@ -0,0 +1,6 @@
1
+ import { type FederatedSchemaWithResolvers, type GraphQLResolverMap, type ProtoMetadata, type ServiceClient, type SubSpaceServiceConfig } from './types.js';
2
+ import { type GraphQLSchema } from 'graphql/index.js';
3
+ import { GraphQLObjectType } from 'graphql';
4
+ import { GraphQLList } from 'graphql/type/definition.js';
5
+ export declare const buildFederatedSubscriptionSchema: <T, M extends Record<string, any>, CTX extends ServiceClient<CTX, keyof CTX, M>>(subServices: ProtoMetadata[], config: SubSpaceServiceConfig, namespace: string, schema: GraphQLSchema) => FederatedSchemaWithResolvers;
6
+ export declare const mergeSubscribeIntoSchema: (schema: GraphQLObjectType | GraphQLList<any> | null | undefined, resolvers: GraphQLResolverMap<any>[string]) => void;
@@ -0,0 +1,46 @@
1
+ import { buildSubgraphSchema } from '@apollo/federation';
2
+ import { gql } from 'graphql-tag';
3
+ import { printSchema } from 'graphql/index.js';
4
+ import { GraphQLObjectType } from 'graphql';
5
+ import { GraphQLList, GraphQLScalarType } from 'graphql/type/definition.js';
6
+ import { generateSubServiceResolvers } from './resolvers.js';
7
+ export const buildFederatedSubscriptionSchema = (subServices, config, namespace, schema) => {
8
+ const resolvers = generateSubServiceResolvers(subServices, config, namespace);
9
+ // TODO There is currently no way of building a federated schema from GraphQLSchema Object
10
+ // See https://github.com/apollographql/apollo-server/pull/4310
11
+ const federatedSchema = buildSubgraphSchema({
12
+ typeDefs: gql(printSchema(schema)),
13
+ resolvers
14
+ });
15
+ return {
16
+ federatedSchema,
17
+ resolvers
18
+ };
19
+ };
20
+ export const mergeSubscribeIntoSchema = (schema, resolvers) => {
21
+ if (!schema || !resolvers) {
22
+ return;
23
+ }
24
+ Object.entries(resolvers).forEach(([key, val]) => {
25
+ if (schema instanceof GraphQLList) {
26
+ mergeSubscribeIntoSchema(schema.ofType, val);
27
+ return;
28
+ }
29
+ const field = schema.getFields()[key];
30
+ if (!field) {
31
+ return;
32
+ }
33
+ if ('resolve' in val || 'subscribe' in val) {
34
+ field.subscribe = val['subscribe'] || field.subscribe;
35
+ field.resolve = val['resolve'] || field.resolve;
36
+ return;
37
+ }
38
+ const fieldType = field.type;
39
+ if (fieldType instanceof GraphQLScalarType) {
40
+ field.subscribe = val['subscribe'];
41
+ }
42
+ else if (fieldType instanceof GraphQLObjectType) {
43
+ mergeSubscribeIntoSchema(fieldType, val);
44
+ }
45
+ });
46
+ };
@@ -0,0 +1,11 @@
1
+ import { type GraphQLInputField, type GraphQLOutputType } from 'graphql';
2
+ import { GraphQLEnumType, GraphQLInputObjectType, type GraphQLInputType } from 'graphql/type/definition.js';
3
+ import { type ProtoMetadata, type ServiceConfig } from './types.js';
4
+ import { type ServiceDescriptorProto } from 'ts-proto-descriptors';
5
+ export declare const Mutate: string[];
6
+ export declare const preprocessGQLInput: (data: any, model: GraphQLInputObjectType | GraphQLEnumType | GraphQLInputField | GraphQLInputType) => Promise<any>;
7
+ export declare const postProcessGQLValue: (data: any, model: GraphQLOutputType) => any;
8
+ export declare const getWhitelistBlacklistConfig: (metaService: ServiceDescriptorProto, config: ServiceConfig, meta: ProtoMetadata, entity: string) => {
9
+ queries: Set<string>;
10
+ mutations: Set<string>;
11
+ };
@@ -0,0 +1,158 @@
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
+ });
9
+ };
10
+ import { GraphQLList, GraphQLNonNull, GraphQLObjectType, } from 'graphql';
11
+ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType, } from 'graphql/type/definition.js';
12
+ export const Mutate = ['Create', 'Update', 'Upsert'];
13
+ export const preprocessGQLInput = (data, model) => __awaiter(void 0, void 0, void 0, function* () {
14
+ if (model instanceof GraphQLEnumType) {
15
+ return data;
16
+ }
17
+ if (model instanceof GraphQLInputObjectType) {
18
+ if (model.name === 'IGoogleProtobufAny') {
19
+ // TODO Use encoded once resource base supports it
20
+ // const typing = getTyping(data.typeUrl);
21
+ // if (!typing) {
22
+ // throw Error(`GoogleProtobufAny could not find input type: ${data.typeUrl}`);
23
+ // }
24
+ //
25
+ // const encoded = typing.processor.encode(typing.processor.fromPartial(data.value)).finish();
26
+ const encoded = Buffer.from(JSON.stringify(data.value));
27
+ return Object.assign(Object.assign({}, data), { value: encoded });
28
+ }
29
+ else {
30
+ const fields = model.getFields();
31
+ for (let key of Object.keys(fields)) {
32
+ if (data && key in data) {
33
+ data[key] = yield preprocessGQLInput(data[key], fields[key].type);
34
+ }
35
+ }
36
+ }
37
+ }
38
+ if (model instanceof GraphQLScalarType) {
39
+ if (model.name === 'IDateTime') {
40
+ return new Date(data);
41
+ }
42
+ }
43
+ if (model instanceof GraphQLNonNull) {
44
+ return yield preprocessGQLInput(data, model.ofType);
45
+ }
46
+ if (model instanceof GraphQLList) {
47
+ for (let i = 0; i < data.length; i++) {
48
+ data[i] = yield preprocessGQLInput(data[i], model.ofType);
49
+ }
50
+ }
51
+ if (model instanceof GraphQLScalarType) {
52
+ switch (model.name) {
53
+ case 'Upload':
54
+ if (typeof data !== 'object') {
55
+ return Buffer.from(data.toString(), 'utf8');
56
+ }
57
+ let fileData = yield data;
58
+ const upload = yield fileData.promise;
59
+ const stream = upload.createReadStream();
60
+ return stream;
61
+ }
62
+ }
63
+ return data;
64
+ });
65
+ export const postProcessGQLValue = (data, model) => {
66
+ if (model instanceof GraphQLEnumType) {
67
+ return data;
68
+ }
69
+ if (model instanceof GraphQLObjectType) {
70
+ if (model.name === 'GoogleProtobufAny' && (data === null || data === void 0 ? void 0 : data.value)) {
71
+ // TODO Use encoded once resource base supports it
72
+ const decoded = JSON.parse(data.value.toString());
73
+ return Object.assign(Object.assign({}, data), { value: decoded });
74
+ }
75
+ else {
76
+ const fields = model.getFields();
77
+ for (let key of Object.keys(fields)) {
78
+ if (data && key in data) {
79
+ data[key] = postProcessGQLValue(data[key], fields[key].type);
80
+ }
81
+ }
82
+ }
83
+ }
84
+ if (model instanceof GraphQLNonNull) {
85
+ return postProcessGQLValue(data, model.ofType);
86
+ }
87
+ if (model instanceof GraphQLList) {
88
+ for (let i = 0; i < data.length; i++) {
89
+ data[i] = postProcessGQLValue(data[i], model.ofType);
90
+ }
91
+ }
92
+ return data;
93
+ };
94
+ export const getWhitelistBlacklistConfig = (metaService, config, meta, entity) => {
95
+ var _a, _b, _c, _d;
96
+ const queryList = [];
97
+ if (meta.options && meta.options.services && meta.options.services[metaService.name] && meta.options.services[metaService.name].methods) {
98
+ const methods = meta.options.services[metaService.name].methods;
99
+ for (const key of Object.keys(methods)) {
100
+ if ('is_query' in methods[key] && methods[key]['is_query']) {
101
+ queryList.push(key);
102
+ }
103
+ }
104
+ }
105
+ const mut = new Set(metaService.method.map(m => m.name).filter(key => queryList.indexOf(key) < 0));
106
+ const que = new Set(metaService.method.map(m => m.name).filter(key => queryList.indexOf(key) >= 0));
107
+ if (config[entity]) {
108
+ if ((_b = (_a = config[entity]) === null || _a === void 0 ? void 0 : _a.methods) === null || _b === void 0 ? void 0 : _b.whitelist) {
109
+ const whitelist = new Set(config[entity].methods.whitelist);
110
+ mut.forEach(key => {
111
+ if (whitelist.has(key)) {
112
+ whitelist.delete(key);
113
+ }
114
+ else {
115
+ mut.delete(key);
116
+ }
117
+ });
118
+ que.forEach(key => {
119
+ if (whitelist.has(key)) {
120
+ whitelist.delete(key);
121
+ }
122
+ else {
123
+ que.delete(key);
124
+ }
125
+ });
126
+ if (whitelist.size > 0) {
127
+ // TODO Log error that whitelist contains methods that don't exist
128
+ console.error('Whitelist contains undefined methods:', whitelist);
129
+ }
130
+ }
131
+ else if ((_d = (_c = config[entity]) === null || _c === void 0 ? void 0 : _c.methods) === null || _d === void 0 ? void 0 : _d.blacklist) {
132
+ const blacklist = new Set(config[entity].methods.blacklist);
133
+ mut.forEach(key => {
134
+ if (blacklist.has(key)) {
135
+ blacklist.delete(key);
136
+ mut.delete(key);
137
+ }
138
+ });
139
+ que.forEach(key => {
140
+ if (blacklist.has(key)) {
141
+ blacklist.delete(key);
142
+ que.delete(key);
143
+ }
144
+ });
145
+ if (blacklist.size > 0) {
146
+ // TODO Log error that blacklist contains methods that don't exist
147
+ console.error('Blacklist contains undefined methods:', blacklist);
148
+ }
149
+ }
150
+ }
151
+ if (Mutate.findIndex(val => mut.has(val)) > -1) {
152
+ mut.add('Mutate');
153
+ }
154
+ return {
155
+ mutations: mut,
156
+ queries: que
157
+ };
158
+ };
@@ -0,0 +1,6 @@
1
+ export * from './types.js';
2
+ export * from './registry.js';
3
+ export * from './graphql.js';
4
+ export * from './federation.js';
5
+ export * from './resolvers.js';
6
+ export * from './schema.js';
@@ -0,0 +1,6 @@
1
+ export * from './types.js';
2
+ export * from './registry.js';
3
+ export * from './graphql.js';
4
+ export * from './federation.js';
5
+ export * from './resolvers.js';
6
+ export * from './schema.js';
@@ -0,0 +1,23 @@
1
+ import { type GraphQLEnumTypeConfig, type GraphQLInputObjectTypeConfig, GraphQLObjectType, type GraphQLObjectTypeConfig } from 'graphql';
2
+ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLScalarType } from 'graphql/type/definition.js';
3
+ import { type ProtoMetadata, type ProtoMetaMessageOptions } from './types.js';
4
+ import { type DescriptorProto, type EnumDescriptorProto, type MethodDescriptorProto } from 'ts-proto-descriptors';
5
+ export interface TypingData {
6
+ output: GraphQLObjectType | GraphQLEnumType | GraphQLScalarType;
7
+ input: GraphQLInputObjectType | GraphQLEnumType | GraphQLScalarType;
8
+ meta: DescriptorProto | EnumDescriptorProto;
9
+ processor?: any;
10
+ }
11
+ export declare const registeredTypings: Map<string, TypingData>;
12
+ export declare const scalarTypes: string[];
13
+ export declare const IGoogleProtobufAny: GraphQLInputObjectType;
14
+ export declare const clearRegistry: () => void;
15
+ export declare const getRegisteredEnumTypings: () => string[];
16
+ export declare const getNameSpaceTypeName: (typeName: string) => string | undefined;
17
+ export declare const getTyping: (type: string) => TypingData | undefined;
18
+ export declare const recursiveEnumCheck: (typeName: string, enumMap: Map<string, string>, prevFieldName: string, traversedFields: string[]) => Map<string, string>;
19
+ export declare const registerTyping: (protoPackage: string, message: DescriptorProto, methodDef: MethodDescriptorProto[], opts?: Omit<Readonly<GraphQLObjectTypeConfig<any, any>>, 'fields'>, inputOpts?: Omit<Readonly<GraphQLInputObjectTypeConfig>, 'fields'>, messageOptions?: ProtoMetaMessageOptions) => void;
20
+ export declare const registerEnumTyping: <T = {
21
+ [key: string]: any;
22
+ }>(protoPackage: string, message: EnumDescriptorProto, opts?: Omit<Readonly<GraphQLEnumTypeConfig>, 'values'>) => void;
23
+ export declare const registerPackagesRecursive: (...protoMetadata: ProtoMetadata[]) => void;