@restorecommerce/facade 1.3.6 → 1.3.7

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 (268) hide show
  1. package/.eslintrc.cjs +1 -11
  2. package/CHANGELOG.md +12 -0
  3. package/codegen/tsconfig.codegen.tsbuildinfo +1 -0
  4. package/debug-run.ts +1 -1
  5. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  6. package/package.json +5 -4
  7. package/tsconfig-base.json +8 -19
  8. package/tsconfig.codegen.json +0 -1
  9. package/tsconfig.debug.json +1 -5
  10. package/tsconfig.generate.json +0 -3
  11. package/tsconfig.lib.json +1 -2
  12. package/tsconfig.test.json +1 -22
  13. package/codegen/index.d.ts +0 -12
  14. package/codegen/index.js +0 -43
  15. package/dist/gql/index.d.ts +0 -1
  16. package/dist/gql/index.js +0 -1
  17. package/dist/gql/protos/federation.d.ts +0 -6
  18. package/dist/gql/protos/federation.js +0 -46
  19. package/dist/gql/protos/graphql.d.ts +0 -11
  20. package/dist/gql/protos/graphql.js +0 -158
  21. package/dist/gql/protos/index.d.ts +0 -6
  22. package/dist/gql/protos/index.js +0 -6
  23. package/dist/gql/protos/registry.d.ts +0 -23
  24. package/dist/gql/protos/registry.js +0 -366
  25. package/dist/gql/protos/resolvers.d.ts +0 -9
  26. package/dist/gql/protos/resolvers.js +0 -479
  27. package/dist/gql/protos/schema.d.ts +0 -14
  28. package/dist/gql/protos/schema.js +0 -224
  29. package/dist/gql/protos/stream-to-async-iterator.d.ts +0 -50
  30. package/dist/gql/protos/stream-to-async-iterator.js +0 -190
  31. package/dist/gql/protos/types.d.ts +0 -96
  32. package/dist/gql/protos/types.js +0 -1
  33. package/dist/gql/protos/utils.d.ts +0 -18
  34. package/dist/gql/protos/utils.js +0 -133
  35. package/dist/gql/types/AccessControlTypes.d.ts +0 -6
  36. package/dist/gql/types/AccessControlTypes.js +0 -97
  37. package/dist/gql/types/DateType.d.ts +0 -2
  38. package/dist/gql/types/DateType.js +0 -29
  39. package/dist/gql/types/FilterType.d.ts +0 -2
  40. package/dist/gql/types/FilterType.js +0 -72
  41. package/dist/gql/types/MetaType.d.ts +0 -2
  42. package/dist/gql/types/MetaType.js +0 -25
  43. package/dist/gql/types/ScopeType.d.ts +0 -2
  44. package/dist/gql/types/ScopeType.js +0 -13
  45. package/dist/gql/types/SortType.d.ts +0 -3
  46. package/dist/gql/types/SortType.js +0 -30
  47. package/dist/gql/types/StatusType.d.ts +0 -2
  48. package/dist/gql/types/StatusType.js +0 -15
  49. package/dist/gql/types/index.d.ts +0 -7
  50. package/dist/gql/types/index.js +0 -7
  51. package/dist/index.d.ts +0 -66
  52. package/dist/index.js +0 -312
  53. package/dist/interfaces.d.ts +0 -54
  54. package/dist/interfaces.js +0 -6
  55. package/dist/middlewares/index.d.ts +0 -1
  56. package/dist/middlewares/index.js +0 -1
  57. package/dist/middlewares/req-res-logger/index.d.ts +0 -14
  58. package/dist/middlewares/req-res-logger/index.js +0 -90
  59. package/dist/modules/access-control/gql/federation.d.ts +0 -2
  60. package/dist/modules/access-control/gql/federation.js +0 -13
  61. package/dist/modules/access-control/gql/schema.d.ts +0 -2
  62. package/dist/modules/access-control/gql/schema.generated.d.ts +0 -1124
  63. package/dist/modules/access-control/gql/schema.generated.js +0 -80
  64. package/dist/modules/access-control/gql/schema.js +0 -5
  65. package/dist/modules/access-control/gql/types.d.ts +0 -3
  66. package/dist/modules/access-control/gql/types.js +0 -14
  67. package/dist/modules/access-control/grpc/index.d.ts +0 -13
  68. package/dist/modules/access-control/grpc/index.js +0 -14
  69. package/dist/modules/access-control/index.d.ts +0 -2
  70. package/dist/modules/access-control/index.js +0 -26
  71. package/dist/modules/access-control/interfaces.d.ts +0 -15
  72. package/dist/modules/access-control/interfaces.js +0 -1
  73. package/dist/modules/catalog/gql/federation.d.ts +0 -2
  74. package/dist/modules/catalog/gql/federation.js +0 -13
  75. package/dist/modules/catalog/gql/schema.d.ts +0 -2
  76. package/dist/modules/catalog/gql/schema.generated.d.ts +0 -1503
  77. package/dist/modules/catalog/gql/schema.generated.js +0 -74
  78. package/dist/modules/catalog/gql/schema.js +0 -5
  79. package/dist/modules/catalog/gql/types.d.ts +0 -3
  80. package/dist/modules/catalog/gql/types.js +0 -16
  81. package/dist/modules/catalog/grpc/index.d.ts +0 -15
  82. package/dist/modules/catalog/grpc/index.js +0 -16
  83. package/dist/modules/catalog/index.d.ts +0 -2
  84. package/dist/modules/catalog/index.js +0 -26
  85. package/dist/modules/catalog/interfaces.d.ts +0 -16
  86. package/dist/modules/catalog/interfaces.js +0 -1
  87. package/dist/modules/facade-status/gql/index.d.ts +0 -1
  88. package/dist/modules/facade-status/gql/index.js +0 -11
  89. package/dist/modules/facade-status/gql/resolvers.d.ts +0 -2
  90. package/dist/modules/facade-status/gql/resolvers.js +0 -18
  91. package/dist/modules/facade-status/gql/schema.d.ts +0 -3
  92. package/dist/modules/facade-status/gql/schema.generated.d.ts +0 -109
  93. package/dist/modules/facade-status/gql/schema.generated.js +0 -1
  94. package/dist/modules/facade-status/gql/schema.js +0 -14
  95. package/dist/modules/facade-status/gql/types.d.ts +0 -2
  96. package/dist/modules/facade-status/gql/types.js +0 -10
  97. package/dist/modules/facade-status/index.d.ts +0 -2
  98. package/dist/modules/facade-status/index.js +0 -8
  99. package/dist/modules/facade-status/interfaces.d.ts +0 -4
  100. package/dist/modules/facade-status/interfaces.js +0 -1
  101. package/dist/modules/fulfillment/gql/federation.d.ts +0 -2
  102. package/dist/modules/fulfillment/gql/federation.js +0 -13
  103. package/dist/modules/fulfillment/gql/schema.d.ts +0 -2
  104. package/dist/modules/fulfillment/gql/schema.generated.d.ts +0 -1539
  105. package/dist/modules/fulfillment/gql/schema.generated.js +0 -79
  106. package/dist/modules/fulfillment/gql/schema.js +0 -5
  107. package/dist/modules/fulfillment/gql/types.d.ts +0 -3
  108. package/dist/modules/fulfillment/gql/types.js +0 -12
  109. package/dist/modules/fulfillment/grpc/index.d.ts +0 -9
  110. package/dist/modules/fulfillment/grpc/index.js +0 -10
  111. package/dist/modules/fulfillment/index.d.ts +0 -2
  112. package/dist/modules/fulfillment/index.js +0 -26
  113. package/dist/modules/fulfillment/interfaces.d.ts +0 -16
  114. package/dist/modules/fulfillment/interfaces.js +0 -1
  115. package/dist/modules/identity/api-key/api-key.d.ts +0 -11
  116. package/dist/modules/identity/api-key/api-key.js +0 -137
  117. package/dist/modules/identity/gql/federation.d.ts +0 -2
  118. package/dist/modules/identity/gql/federation.js +0 -5
  119. package/dist/modules/identity/gql/schema.d.ts +0 -2
  120. package/dist/modules/identity/gql/schema.generated.d.ts +0 -1661
  121. package/dist/modules/identity/gql/schema.generated.js +0 -75
  122. package/dist/modules/identity/gql/schema.js +0 -5
  123. package/dist/modules/identity/gql/types.d.ts +0 -3
  124. package/dist/modules/identity/gql/types.js +0 -18
  125. package/dist/modules/identity/grpc/index.d.ts +0 -15
  126. package/dist/modules/identity/grpc/index.js +0 -16
  127. package/dist/modules/identity/index.d.ts +0 -4
  128. package/dist/modules/identity/index.js +0 -54
  129. package/dist/modules/identity/interfaces.d.ts +0 -22
  130. package/dist/modules/identity/interfaces.js +0 -1
  131. package/dist/modules/identity/oauth/oauth.d.ts +0 -11
  132. package/dist/modules/identity/oauth/oauth.js +0 -170
  133. package/dist/modules/identity/oidc/adapter.d.ts +0 -4
  134. package/dist/modules/identity/oidc/adapter.js +0 -135
  135. package/dist/modules/identity/oidc/in-memory-adapter.d.ts +0 -16
  136. package/dist/modules/identity/oidc/in-memory-adapter.js +0 -85
  137. package/dist/modules/identity/oidc/index.d.ts +0 -18
  138. package/dist/modules/identity/oidc/index.js +0 -147
  139. package/dist/modules/identity/oidc/interfaces.d.ts +0 -73
  140. package/dist/modules/identity/oidc/interfaces.js +0 -7
  141. package/dist/modules/identity/oidc/password-grant.d.ts +0 -2
  142. package/dist/modules/identity/oidc/password-grant.js +0 -163
  143. package/dist/modules/identity/oidc/router.d.ts +0 -13
  144. package/dist/modules/identity/oidc/router.js +0 -164
  145. package/dist/modules/identity/oidc/templates.d.ts +0 -36
  146. package/dist/modules/identity/oidc/templates.js +0 -60
  147. package/dist/modules/identity/oidc/user.d.ts +0 -6
  148. package/dist/modules/identity/oidc/user.js +0 -91
  149. package/dist/modules/identity/oidc/utils.d.ts +0 -6
  150. package/dist/modules/identity/oidc/utils.js +0 -15
  151. package/dist/modules/index.d.ts +0 -13
  152. package/dist/modules/index.js +0 -13
  153. package/dist/modules/indexing/gql/federation.d.ts +0 -2
  154. package/dist/modules/indexing/gql/federation.js +0 -13
  155. package/dist/modules/indexing/gql/schema.d.ts +0 -2
  156. package/dist/modules/indexing/gql/schema.generated.d.ts +0 -226
  157. package/dist/modules/indexing/gql/schema.generated.js +0 -6
  158. package/dist/modules/indexing/gql/schema.js +0 -5
  159. package/dist/modules/indexing/gql/types.d.ts +0 -3
  160. package/dist/modules/indexing/gql/types.js +0 -8
  161. package/dist/modules/indexing/grpc/index.d.ts +0 -7
  162. package/dist/modules/indexing/grpc/index.js +0 -8
  163. package/dist/modules/indexing/index.d.ts +0 -2
  164. package/dist/modules/indexing/index.js +0 -26
  165. package/dist/modules/indexing/interfaces.d.ts +0 -13
  166. package/dist/modules/indexing/interfaces.js +0 -1
  167. package/dist/modules/invoicing/gql/federation.d.ts +0 -2
  168. package/dist/modules/invoicing/gql/federation.js +0 -13
  169. package/dist/modules/invoicing/gql/schema.d.ts +0 -2
  170. package/dist/modules/invoicing/gql/schema.generated.d.ts +0 -1150
  171. package/dist/modules/invoicing/gql/schema.generated.js +0 -75
  172. package/dist/modules/invoicing/gql/schema.js +0 -5
  173. package/dist/modules/invoicing/gql/types.d.ts +0 -3
  174. package/dist/modules/invoicing/gql/types.js +0 -8
  175. package/dist/modules/invoicing/grpc/index.d.ts +0 -7
  176. package/dist/modules/invoicing/grpc/index.js +0 -8
  177. package/dist/modules/invoicing/index.d.ts +0 -2
  178. package/dist/modules/invoicing/index.js +0 -26
  179. package/dist/modules/invoicing/interfaces.d.ts +0 -16
  180. package/dist/modules/invoicing/interfaces.js +0 -1
  181. package/dist/modules/master_data/gql/federation.d.ts +0 -2
  182. package/dist/modules/master_data/gql/federation.js +0 -13
  183. package/dist/modules/master_data/gql/schema.d.ts +0 -2
  184. package/dist/modules/master_data/gql/schema.generated.d.ts +0 -2520
  185. package/dist/modules/master_data/gql/schema.generated.js +0 -114
  186. package/dist/modules/master_data/gql/schema.js +0 -5
  187. package/dist/modules/master_data/gql/types.d.ts +0 -3
  188. package/dist/modules/master_data/gql/types.js +0 -32
  189. package/dist/modules/master_data/grpc/index.d.ts +0 -30
  190. package/dist/modules/master_data/grpc/index.js +0 -32
  191. package/dist/modules/master_data/index.d.ts +0 -2
  192. package/dist/modules/master_data/index.js +0 -26
  193. package/dist/modules/master_data/interfaces.d.ts +0 -16
  194. package/dist/modules/master_data/interfaces.js +0 -1
  195. package/dist/modules/notification/gql/federation.d.ts +0 -2
  196. package/dist/modules/notification/gql/federation.js +0 -13
  197. package/dist/modules/notification/gql/schema.d.ts +0 -2
  198. package/dist/modules/notification/gql/schema.generated.d.ts +0 -632
  199. package/dist/modules/notification/gql/schema.generated.js +0 -68
  200. package/dist/modules/notification/gql/schema.js +0 -5
  201. package/dist/modules/notification/gql/types.d.ts +0 -3
  202. package/dist/modules/notification/gql/types.js +0 -8
  203. package/dist/modules/notification/grpc/index.d.ts +0 -7
  204. package/dist/modules/notification/grpc/index.js +0 -8
  205. package/dist/modules/notification/index.d.ts +0 -2
  206. package/dist/modules/notification/index.js +0 -26
  207. package/dist/modules/notification/interfaces.d.ts +0 -16
  208. package/dist/modules/notification/interfaces.js +0 -1
  209. package/dist/modules/ordering/gql/federation.d.ts +0 -2
  210. package/dist/modules/ordering/gql/federation.js +0 -13
  211. package/dist/modules/ordering/gql/schema.d.ts +0 -2
  212. package/dist/modules/ordering/gql/schema.generated.d.ts +0 -1407
  213. package/dist/modules/ordering/gql/schema.generated.js +0 -91
  214. package/dist/modules/ordering/gql/schema.js +0 -5
  215. package/dist/modules/ordering/gql/types.d.ts +0 -3
  216. package/dist/modules/ordering/gql/types.js +0 -8
  217. package/dist/modules/ordering/grpc/index.d.ts +0 -7
  218. package/dist/modules/ordering/grpc/index.js +0 -8
  219. package/dist/modules/ordering/index.d.ts +0 -2
  220. package/dist/modules/ordering/index.js +0 -26
  221. package/dist/modules/ordering/interfaces.d.ts +0 -16
  222. package/dist/modules/ordering/interfaces.js +0 -1
  223. package/dist/modules/ostorage/gql/federation.d.ts +0 -2
  224. package/dist/modules/ostorage/gql/federation.js +0 -13
  225. package/dist/modules/ostorage/gql/schema.d.ts +0 -2
  226. package/dist/modules/ostorage/gql/schema.generated.d.ts +0 -846
  227. package/dist/modules/ostorage/gql/schema.generated.js +0 -31
  228. package/dist/modules/ostorage/gql/schema.js +0 -5
  229. package/dist/modules/ostorage/gql/types.d.ts +0 -3
  230. package/dist/modules/ostorage/gql/types.js +0 -8
  231. package/dist/modules/ostorage/grpc/index.d.ts +0 -7
  232. package/dist/modules/ostorage/grpc/index.js +0 -8
  233. package/dist/modules/ostorage/index.d.ts +0 -2
  234. package/dist/modules/ostorage/index.js +0 -46
  235. package/dist/modules/ostorage/interfaces.d.ts +0 -16
  236. package/dist/modules/ostorage/interfaces.js +0 -1
  237. package/dist/modules/ostorage/objectDownloadReqHandler.d.ts +0 -1
  238. package/dist/modules/ostorage/objectDownloadReqHandler.js +0 -134
  239. package/dist/modules/payment/gql/federation.d.ts +0 -2
  240. package/dist/modules/payment/gql/federation.js +0 -13
  241. package/dist/modules/payment/gql/schema.d.ts +0 -2
  242. package/dist/modules/payment/gql/schema.generated.d.ts +0 -647
  243. package/dist/modules/payment/gql/schema.generated.js +0 -156
  244. package/dist/modules/payment/gql/schema.js +0 -5
  245. package/dist/modules/payment/gql/types.d.ts +0 -3
  246. package/dist/modules/payment/gql/types.js +0 -8
  247. package/dist/modules/payment/grpc/index.d.ts +0 -7
  248. package/dist/modules/payment/grpc/index.js +0 -8
  249. package/dist/modules/payment/index.d.ts +0 -2
  250. package/dist/modules/payment/index.js +0 -26
  251. package/dist/modules/payment/interfaces.d.ts +0 -16
  252. package/dist/modules/payment/interfaces.js +0 -1
  253. package/dist/modules/scheduling/gql/federation.d.ts +0 -2
  254. package/dist/modules/scheduling/gql/federation.js +0 -13
  255. package/dist/modules/scheduling/gql/schema.d.ts +0 -2
  256. package/dist/modules/scheduling/gql/schema.generated.d.ts +0 -626
  257. package/dist/modules/scheduling/gql/schema.generated.js +0 -31
  258. package/dist/modules/scheduling/gql/schema.js +0 -5
  259. package/dist/modules/scheduling/gql/types.d.ts +0 -3
  260. package/dist/modules/scheduling/gql/types.js +0 -8
  261. package/dist/modules/scheduling/grpc/index.d.ts +0 -7
  262. package/dist/modules/scheduling/grpc/index.js +0 -8
  263. package/dist/modules/scheduling/index.d.ts +0 -2
  264. package/dist/modules/scheduling/index.js +0 -26
  265. package/dist/modules/scheduling/interfaces.d.ts +0 -16
  266. package/dist/modules/scheduling/interfaces.js +0 -1
  267. package/dist/utils.d.ts +0 -5
  268. package/dist/utils.js +0 -14
@@ -1,224 +0,0 @@
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';
6
- const typeCache = new Map();
7
- const subscriptionAction = new GraphQLEnumType({
8
- name: 'SubscriptionAction',
9
- values: {
10
- CREATED: { value: 'CREATED' },
11
- UPDATED: { value: 'UPDATED' },
12
- DELETED: { value: 'DELETED' }
13
- }
14
- });
15
- const subscriptionInput = {
16
- action: {
17
- type: subscriptionAction
18
- }
19
- };
20
- const subscriptionOutput = new GraphQLObjectType({
21
- name: 'SubscriptionOutput',
22
- fields: {
23
- id: {
24
- type: GraphQLString
25
- }
26
- }
27
- });
28
- export const getGQLSchema = (method) => {
29
- const fields = {};
30
- const responseTyping = getTyping(method.outputType);
31
- if (!responseTyping) {
32
- throw Error('Method doesn\'t have registered typings: ' + method.outputType);
33
- }
34
- if (method.outputType !== '.google.protobuf.Empty') {
35
- fields['details'] = {
36
- type: responseTyping.output,
37
- };
38
- }
39
- const outName = 'Proto' + capitalizeProtoName(method.outputType);
40
- let out = typeCache.get(outName);
41
- if (!out) {
42
- out = new GraphQLObjectType({
43
- name: outName,
44
- fields,
45
- });
46
- typeCache.set(outName, out);
47
- }
48
- const typing = getTyping(method.inputType);
49
- if (!typing) {
50
- throw Error('Method doesn\'t have registered typings: ' + method.inputType);
51
- }
52
- return {
53
- type: out,
54
- args: method.inputType === '.google.protobuf.Empty' ? undefined : {
55
- input: {
56
- type: new GraphQLNonNull(typing.input)
57
- }
58
- }
59
- };
60
- };
61
- export const getGQLSchemas = (service) => {
62
- var _a;
63
- return (_a = service.method) === null || _a === void 0 ? void 0 : _a.reduce((obj, method) => {
64
- obj[method.name] = getGQLSchema(method);
65
- return obj;
66
- }, {});
67
- };
68
- const namespaceResolverSchemaRegistry = new Map();
69
- const subscriptionFields = {};
70
- export const registerResolverSchema = (namespace, name, schema, mutation = false, subspace = undefined, config) => {
71
- if (!namespaceResolverSchemaRegistry.has(namespace)) {
72
- namespaceResolverSchemaRegistry.set(namespace, new Map());
73
- }
74
- if (subspace && config[subspace]) {
75
- const blacklistMethods = config[subspace].methods.blacklist;
76
- if (blacklistMethods.includes(name)) {
77
- return;
78
- }
79
- }
80
- if (!namespaceResolverSchemaRegistry.get(namespace).has(mutation)) {
81
- namespaceResolverSchemaRegistry.get(namespace).set(mutation, new Map());
82
- }
83
- let space = namespaceResolverSchemaRegistry.get(namespace).get(mutation);
84
- if (subspace) {
85
- if (!space.has(subspace)) {
86
- space.set(subspace, new Map());
87
- }
88
- space = space.get(subspace);
89
- }
90
- if (space.has(name)) {
91
- if (subspace) {
92
- throw new Error(`Namespace "${namespace}"."${subspace}" already contains a schema: ${name} (mutation: ${mutation})`);
93
- }
94
- else {
95
- throw new Error(`Namespace "${namespace}" already contains a schema: ${name} (mutation: ${mutation})`);
96
- }
97
- }
98
- // register create, update and upsert with Mutate
99
- if (Mutate.indexOf(name) > -1) {
100
- name = 'Mutate';
101
- }
102
- space.set(name, schema);
103
- };
104
- export const generateSchema = (setup) => {
105
- const queryFields = {};
106
- const mutationFields = {};
107
- setup.forEach(s => {
108
- if (!namespaceResolverSchemaRegistry.has(s.namespace)) {
109
- throw new Error(`Namespace "${s.namespace}" has no registered schemas`);
110
- }
111
- if (namespaceResolverSchemaRegistry.get(s.namespace).has(false)) {
112
- const fields = {};
113
- namespaceResolverSchemaRegistry.get(s.namespace).get(false).forEach((value, key) => {
114
- if (value instanceof Map) {
115
- const capitalName = capitalizeProtoName(key);
116
- fields[key] = {
117
- type: new GraphQLNonNull(new GraphQLObjectType({
118
- name: s.prefix + capitalName + 'Query',
119
- fields: Object.fromEntries(value),
120
- }))
121
- };
122
- }
123
- else {
124
- fields[key] = value;
125
- }
126
- });
127
- queryFields[s.namespace] = {
128
- type: new GraphQLNonNull(new GraphQLObjectType({
129
- name: s.prefix + 'Query',
130
- fields
131
- }))
132
- };
133
- }
134
- if (namespaceResolverSchemaRegistry.get(s.namespace).has(true)) {
135
- const fields = {};
136
- namespaceResolverSchemaRegistry.get(s.namespace).get(true).forEach((value, key) => {
137
- if (value instanceof Map) {
138
- const capitalName = capitalizeProtoName(key);
139
- fields[key] = {
140
- type: new GraphQLNonNull(new GraphQLObjectType({
141
- name: s.prefix + capitalName + 'Mutation',
142
- fields: Object.fromEntries(value),
143
- }))
144
- };
145
- }
146
- else {
147
- fields[key] = value;
148
- }
149
- });
150
- mutationFields[s.namespace] = {
151
- type: new GraphQLNonNull(new GraphQLObjectType({
152
- name: s.prefix + 'Mutation',
153
- fields
154
- }))
155
- };
156
- }
157
- });
158
- const config = {};
159
- if (Object.keys(queryFields).length > 0) {
160
- config.query = new GraphQLObjectType({
161
- name: 'Query',
162
- fields: queryFields
163
- });
164
- }
165
- if (Object.keys(mutationFields).length > 0) {
166
- config.mutation = new GraphQLObjectType({
167
- name: 'Mutation',
168
- fields: mutationFields
169
- });
170
- }
171
- if (Object.keys(subscriptionFields).length > 0) {
172
- config.subscription = new GraphQLObjectType({
173
- name: 'Subscription',
174
- fields: subscriptionFields
175
- });
176
- }
177
- return new GraphQLSchema(Object.assign({}, config));
178
- };
179
- export const generateSubServiceSchemas = (subServices, config, namespace, prefix) => {
180
- subServices.forEach((meta) => {
181
- var _a;
182
- meta.fileDescriptor.service.forEach(service => {
183
- if (service.name) {
184
- const subName = getServiceName(service.name);
185
- const { mutations, queries } = getWhitelistBlacklistConfig(service, config, meta, subName);
186
- const schemas = getGQLSchemas(service);
187
- Object.keys(schemas).forEach(key => {
188
- registerResolverSchema(config.root ? subName : namespace, key, schemas[key], !queries.has(key) && mutations.has(key), config.root ? undefined : subName, config);
189
- });
190
- }
191
- });
192
- if (useSubscriptions) {
193
- Object.entries(((_a = meta.options) === null || _a === void 0 ? void 0 : _a.messages) || {}).forEach(([messageName, option]) => {
194
- if (option.options && 'kafka_subscriber' in option.options) {
195
- const fieldName = namespace + capitalize(option.options.kafka_subscriber.plural);
196
- const typing = getTyping('.' + meta.fileDescriptor.package + '.' + messageName);
197
- if (typing) {
198
- subscriptionFields[fieldName] = {
199
- // TODO Implement user lookup
200
- // type: typing?.output!,
201
- type: subscriptionOutput,
202
- args: subscriptionInput
203
- };
204
- }
205
- }
206
- });
207
- }
208
- });
209
- if (config.root) {
210
- return generateSchema(flat(subServices.map(meta => {
211
- return meta.fileDescriptor.service.map(service => {
212
- if (service.name) {
213
- const subName = getServiceName(service.name);
214
- return {
215
- prefix: prefix + subName.substring(0, 1).toUpperCase() + subName.substring(1).toLowerCase(),
216
- namespace: subName
217
- };
218
- }
219
- return null;
220
- }).filter(s => s !== null);
221
- })));
222
- }
223
- return generateSchema([{ prefix, namespace }]);
224
- };
@@ -1,50 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { Readable } from "stream";
3
- export type StreamToAsyncIteratorOptions = {
4
- /** The size of each read from the stream for each iteration */
5
- size?: number;
6
- };
7
- /**
8
- * Wraps a stream into an object that can be used as an async iterator.
9
- *
10
- * This will keep a stream in a paused state, and will only read from the stream on each
11
- * iteration. A size can be supplied to set an explicit call to `stream.read([size])` in
12
- * the options for each iteration.
13
- */
14
- export default class StreamToAsyncIterator<T = unknown> implements AsyncIterableIterator<T> {
15
- /** The underlying readable stream */
16
- private _stream;
17
- /** Contains stream's error when stream has error'ed out */
18
- private _error;
19
- /** The current state of the iterator (not readable, readable, ended, errored) */
20
- private _state;
21
- private _size;
22
- /** The rejections of promises to call when stream errors out */
23
- private _rejections;
24
- get closed(): boolean;
25
- constructor(stream: Readable, { size }?: StreamToAsyncIteratorOptions);
26
- [Symbol.asyncIterator](): this;
27
- /**
28
- * Returns the next iteration of data. Rejects if the stream errored out.
29
- */
30
- next(): Promise<IteratorResult<T, void>>;
31
- /**
32
- * Waits until the stream is readable. Rejects if the stream errored out.
33
- * @returns Promise when stream is readable
34
- */
35
- private _untilReadable;
36
- /**
37
- * Waits until the stream is ended. Rejects if the stream errored out.
38
- * @returns Promise when stream is finished
39
- */
40
- private _untilEnd;
41
- return(): Promise<IteratorResult<T, void>>;
42
- throw(err?: Error): Promise<IteratorResult<T, void>>;
43
- /**
44
- * Destroy the stream
45
- * @param err An optional error to pass to the stream for an error event
46
- */
47
- close(err?: Error): void;
48
- private _handleStreamError;
49
- private _handleStreamEnd;
50
- }
@@ -1,190 +0,0 @@
1
- // The MIT License (MIT)
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- const NOT_READABLE = Symbol("not readable");
12
- const READABLE = Symbol("readable");
13
- const ENDED = Symbol("ended");
14
- const ERRORED = Symbol("errored");
15
- const STATES = {
16
- notReadable: NOT_READABLE,
17
- readable: READABLE,
18
- ended: ENDED,
19
- errored: ERRORED,
20
- };
21
- /**
22
- * Wraps a stream into an object that can be used as an async iterator.
23
- *
24
- * This will keep a stream in a paused state, and will only read from the stream on each
25
- * iteration. A size can be supplied to set an explicit call to `stream.read([size])` in
26
- * the options for each iteration.
27
- */
28
- export default class StreamToAsyncIterator {
29
- get closed() {
30
- return this._state === STATES.ended;
31
- }
32
- constructor(stream, { size } = {}) {
33
- /** The current state of the iterator (not readable, readable, ended, errored) */
34
- this._state = STATES.notReadable;
35
- /** The rejections of promises to call when stream errors out */
36
- this._rejections = new Set();
37
- this._stream = stream;
38
- this._size = size;
39
- const bindMethods = ["_handleStreamEnd", "_handleStreamError"];
40
- for (const method of bindMethods) {
41
- Object.defineProperty(this, method, {
42
- configurable: true,
43
- writable: true,
44
- value: this[method].bind(this),
45
- });
46
- }
47
- // eslint-disable-next-line @typescript-eslint/unbound-method
48
- stream.once("error", this._handleStreamError);
49
- // eslint-disable-next-line @typescript-eslint/unbound-method
50
- stream.once("end", this._handleStreamEnd);
51
- }
52
- [Symbol.asyncIterator]() {
53
- return this;
54
- }
55
- /**
56
- * Returns the next iteration of data. Rejects if the stream errored out.
57
- */
58
- next() {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- switch (this._state) {
61
- case STATES.notReadable: {
62
- let untilReadable;
63
- let untilEnd;
64
- try {
65
- untilReadable = this._untilReadable();
66
- untilEnd = this._untilEnd();
67
- yield Promise.race([
68
- untilReadable.promise,
69
- untilEnd.promise,
70
- ]);
71
- }
72
- finally {
73
- // need to clean up any hanging event listeners
74
- if (untilReadable != null) {
75
- untilReadable.close();
76
- }
77
- if (untilEnd != null) {
78
- untilEnd.close();
79
- }
80
- }
81
- return this.next();
82
- }
83
- case STATES.ended: {
84
- this.close();
85
- return { done: true, value: undefined };
86
- }
87
- case STATES.errored: {
88
- this.close();
89
- throw this._error;
90
- }
91
- case STATES.readable: {
92
- // stream.read returns null if not readable or when stream has ended
93
- // todo: Could add a way to ensure data-type/shape of reads to make this type safe
94
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
95
- const data = this._size
96
- ? this._stream.read(this._size)
97
- : this._stream.read();
98
- if (data !== null) {
99
- return { done: false, value: data };
100
- }
101
- else {
102
- //we're no longer readable, need to find out what state we're in
103
- this._state = STATES.notReadable;
104
- // need to let event loop run to fill stream buffer
105
- yield new Promise(setImmediate);
106
- return this.next();
107
- }
108
- }
109
- }
110
- });
111
- }
112
- /**
113
- * Waits until the stream is readable. Rejects if the stream errored out.
114
- * @returns Promise when stream is readable
115
- */
116
- _untilReadable() {
117
- //let is used here instead of const because the exact reference is
118
- //required to remove it, this is why it is not a curried function that
119
- //accepts resolve & reject as parameters.
120
- let handleReadable = undefined;
121
- const promise = new Promise((resolve, reject) => {
122
- handleReadable = () => {
123
- this._state = STATES.readable;
124
- this._rejections.delete(reject);
125
- resolve();
126
- };
127
- this._stream.once("readable", handleReadable);
128
- this._rejections.add(reject);
129
- });
130
- const cleanup = () => {
131
- if (handleReadable != null) {
132
- this._stream.removeListener("readable", handleReadable);
133
- }
134
- };
135
- return { close: cleanup, promise };
136
- }
137
- /**
138
- * Waits until the stream is ended. Rejects if the stream errored out.
139
- * @returns Promise when stream is finished
140
- */
141
- _untilEnd() {
142
- let handleEnd = undefined;
143
- const promise = new Promise((resolve, reject) => {
144
- handleEnd = () => {
145
- this._state = STATES.ended;
146
- this._rejections.delete(reject);
147
- resolve();
148
- };
149
- this._stream.once("end", handleEnd);
150
- this._rejections.add(reject);
151
- });
152
- const cleanup = () => {
153
- if (handleEnd != null) {
154
- this._stream.removeListener("end", handleEnd);
155
- }
156
- };
157
- return { close: cleanup, promise };
158
- }
159
- return() {
160
- this._state = STATES.ended;
161
- return this.next();
162
- }
163
- throw(err) {
164
- this._error = err;
165
- this._state = STATES.errored;
166
- return this.next();
167
- }
168
- /**
169
- * Destroy the stream
170
- * @param err An optional error to pass to the stream for an error event
171
- */
172
- close(err) {
173
- // eslint-disable-next-line @typescript-eslint/unbound-method
174
- this._stream.removeListener("end", this._handleStreamEnd);
175
- // eslint-disable-next-line @typescript-eslint/unbound-method
176
- this._stream.removeListener("error", this._handleStreamError);
177
- this._state = STATES.ended;
178
- this._stream.destroy(err);
179
- }
180
- _handleStreamError(err) {
181
- this._error = err;
182
- this._state = STATES.errored;
183
- for (const reject of this._rejections) {
184
- reject(err);
185
- }
186
- }
187
- _handleStreamEnd() {
188
- this._state = STATES.ended;
189
- }
190
- }
@@ -1,96 +0,0 @@
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
- export interface GraphQLResolverMap<TContext = {}> {
5
- [typeName: string]: {
6
- [fieldName: string]: GraphQLFieldResolver<any, TContext, any> | {
7
- requires?: string;
8
- resolve: GraphQLFieldResolver<any, TContext, any>;
9
- };
10
- } | GraphQLScalarType | {
11
- [enumValue: string]: string | number;
12
- };
13
- }
14
- export declare const authSubjectType = ".io.restorecommerce.auth.Subject";
15
- export type ProtoMetaMessageOptions = {
16
- options?: {
17
- [key: string]: any;
18
- };
19
- fields?: {
20
- [key: string]: {
21
- [key: string]: any;
22
- };
23
- };
24
- oneof?: {
25
- [key: string]: {
26
- [key: string]: any;
27
- };
28
- };
29
- nested?: {
30
- [key: string]: ProtoMetaMessageOptions;
31
- };
32
- };
33
- export interface ProtoMetadata {
34
- fileDescriptor: FileDescriptorProto;
35
- references: {
36
- [key: string]: any;
37
- };
38
- dependencies?: ProtoMetadata[];
39
- options?: {
40
- options?: {
41
- [key: string]: any;
42
- };
43
- services?: {
44
- [key: string]: {
45
- options?: {
46
- [key: string]: any;
47
- };
48
- methods?: {
49
- [key: string]: {
50
- [key: string]: any;
51
- };
52
- };
53
- };
54
- };
55
- messages?: {
56
- [key: string]: ProtoMetaMessageOptions;
57
- };
58
- enums?: {
59
- [key: string]: {
60
- options?: {
61
- [key: string]: any;
62
- };
63
- values?: {
64
- [key: string]: {
65
- [key: string]: any;
66
- };
67
- };
68
- };
69
- };
70
- };
71
- }
72
- export interface BlackListWhiteListConfig {
73
- whitelist?: string[];
74
- blacklist?: string[];
75
- }
76
- export interface MethodConfig {
77
- methods?: BlackListWhiteListConfig;
78
- }
79
- export interface ServiceConfig {
80
- client: Omit<GrpcClientConfig, 'logger'> & {
81
- address: string;
82
- };
83
- [key: string]: any;
84
- }
85
- export interface SubSpaceServiceConfig extends ServiceConfig {
86
- root: boolean;
87
- }
88
- export type ServiceClient<Context extends Pick<Context, Key>, Key extends keyof Context, T extends Record<string, any>> = {
89
- [V in Key]: {
90
- client: T;
91
- };
92
- };
93
- export type FederatedSchemaWithResolvers = {
94
- federatedSchema: GraphQLSchema;
95
- resolvers: GraphQLResolverMap<any>;
96
- };
@@ -1 +0,0 @@
1
- export const authSubjectType = '.io.restorecommerce.auth.Subject';
@@ -1,18 +0,0 @@
1
- import { type TypingData } from './registry.js';
2
- export declare const capitalizeProtoName: (name: string) => string;
3
- export declare const convertyCamelToSnakeCase: (entity: string) => string;
4
- export declare const getKeys: (obj: any) => string[];
5
- export declare const decodeBufferFields: (items: any[], bufferFields: string[]) => any;
6
- /**
7
- * converts enum string values to integers reading from the inputTyping
8
- * @param TypingData input typing
9
- * @param req request object from which the enum strings to be replaced
10
- */
11
- export declare const convertEnumToInt: (inputTyping: TypingData, req: any) => any;
12
- export declare const capitalize: (s: string) => string;
13
- export declare const snakeToCamel: (s: string) => string;
14
- export declare const camelToSnake: (serviceName: string) => string;
15
- export declare const getServiceName: (serviceName: string) => string;
16
- export declare const camelCase: (s: string) => string;
17
- export declare let useSubscriptions: boolean;
18
- export declare const setUseSubscriptions: (value: boolean) => boolean;