@restorecommerce/facade 1.1.4 → 1.1.6
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.
- package/CHANGELOG.md +39 -0
- package/codegen/index.js +28 -4
- package/dist/gql/protos/federation.js +5 -2
- package/dist/gql/protos/registry.js +2 -2
- package/dist/gql/protos/resolvers.d.ts +2 -2
- package/dist/gql/protos/resolvers.js +36 -9
- package/dist/gql/protos/schema.d.ts +1 -1
- package/dist/gql/protos/schema.js +8 -5
- package/dist/gql/protos/types.d.ts +3 -3
- package/dist/gql/protos/utils.d.ts +2 -0
- package/dist/gql/protos/utils.js +35 -2
- package/dist/index.d.ts +1 -3
- package/dist/index.js +37 -21
- package/dist/interfaces.d.ts +4 -5
- package/dist/middlewares/req-res-logger/index.js +4 -1
- package/dist/modules/access-control/gql/federation.js +5 -2
- package/dist/modules/access-control/gql/schema.generated.d.ts +196 -191
- package/dist/modules/access-control/grpc/index.d.ts +8 -8
- package/dist/modules/access-control/grpc/index.js +4 -4
- package/dist/modules/access-control/interfaces.d.ts +1 -1
- package/dist/modules/catalog/gql/federation.js +5 -2
- package/dist/modules/catalog/gql/schema.generated.d.ts +584 -348
- package/dist/modules/catalog/gql/schema.generated.js +7 -1
- package/dist/modules/catalog/grpc/index.d.ts +10 -10
- package/dist/modules/catalog/grpc/index.js +5 -5
- package/dist/modules/catalog/interfaces.d.ts +1 -1
- package/dist/modules/facade-status/gql/index.js +5 -2
- package/dist/modules/facade-status/gql/schema.generated.d.ts +27 -27
- package/dist/modules/facade-status/interfaces.d.ts +1 -1
- package/dist/modules/fulfillment/gql/federation.js +5 -2
- package/dist/modules/fulfillment/gql/schema.generated.d.ts +578 -522
- package/dist/modules/fulfillment/gql/schema.generated.js +6 -6
- package/dist/modules/fulfillment/grpc/index.d.ts +4 -4
- package/dist/modules/fulfillment/grpc/index.js +2 -2
- package/dist/modules/fulfillment/interfaces.d.ts +1 -1
- package/dist/modules/identity/api-key/api-key.js +32 -3
- package/dist/modules/identity/gql/schema.generated.d.ts +381 -233
- package/dist/modules/identity/grpc/index.d.ts +10 -10
- package/dist/modules/identity/grpc/index.js +5 -5
- package/dist/modules/identity/interfaces.d.ts +1 -1
- package/dist/modules/identity/oauth/oauth.js +29 -3
- package/dist/modules/identity/oidc/adapter.d.ts +1 -1
- package/dist/modules/identity/oidc/in-memory-adapter.js +4 -1
- package/dist/modules/identity/oidc/index.d.ts +1 -1
- package/dist/modules/identity/oidc/index.js +5 -2
- package/dist/modules/identity/oidc/interfaces.d.ts +11 -10
- package/dist/modules/identity/oidc/password-grant.js +26 -3
- package/dist/modules/identity/oidc/router.d.ts +1 -1
- package/dist/modules/identity/oidc/router.js +2 -2
- package/dist/modules/identity/oidc/templates.js +6 -3
- package/dist/modules/identity/oidc/user.d.ts +1 -1
- package/dist/modules/indexing/gql/federation.js +5 -2
- package/dist/modules/indexing/gql/schema.generated.d.ts +56 -51
- package/dist/modules/indexing/grpc/index.d.ts +2 -2
- package/dist/modules/indexing/grpc/index.js +1 -1
- package/dist/modules/indexing/interfaces.d.ts +1 -1
- package/dist/modules/invoicing/gql/federation.js +5 -2
- package/dist/modules/invoicing/gql/schema.generated.d.ts +166 -157
- package/dist/modules/invoicing/grpc/index.d.ts +2 -2
- package/dist/modules/invoicing/grpc/index.js +1 -1
- package/dist/modules/invoicing/interfaces.d.ts +1 -1
- package/dist/modules/notification/gql/federation.js +5 -2
- package/dist/modules/notification/gql/schema.generated.d.ts +118 -113
- package/dist/modules/notification/grpc/index.d.ts +2 -2
- package/dist/modules/notification/grpc/index.js +1 -1
- package/dist/modules/notification/interfaces.d.ts +1 -1
- package/dist/modules/ordering/gql/federation.js +5 -2
- package/dist/modules/ordering/gql/schema.generated.d.ts +707 -290
- package/dist/modules/ordering/gql/schema.generated.js +24 -12
- package/dist/modules/ordering/grpc/index.d.ts +2 -2
- package/dist/modules/ordering/grpc/index.js +1 -1
- package/dist/modules/ordering/interfaces.d.ts +1 -1
- package/dist/modules/ostorage/gql/federation.js +5 -2
- package/dist/modules/ostorage/gql/schema.generated.d.ts +154 -149
- package/dist/modules/ostorage/grpc/index.d.ts +2 -2
- package/dist/modules/ostorage/grpc/index.js +1 -1
- package/dist/modules/ostorage/interfaces.d.ts +1 -1
- package/dist/modules/payment/gql/federation.js +5 -2
- package/dist/modules/payment/gql/schema.generated.d.ts +65 -65
- package/dist/modules/payment/grpc/index.d.ts +2 -2
- package/dist/modules/payment/grpc/index.js +1 -1
- package/dist/modules/payment/interfaces.d.ts +1 -1
- package/dist/modules/resource/gql/federation.js +5 -2
- package/dist/modules/resource/gql/schema.generated.d.ts +349 -332
- package/dist/modules/resource/gql/schema.generated.js +6 -1
- package/dist/modules/resource/grpc/index.d.ts +22 -22
- package/dist/modules/resource/grpc/index.js +12 -12
- package/dist/modules/resource/interfaces.d.ts +1 -1
- package/dist/modules/scheduling/gql/federation.js +5 -2
- package/dist/modules/scheduling/gql/schema.generated.d.ts +120 -115
- package/dist/modules/scheduling/grpc/index.d.ts +2 -2
- package/dist/modules/scheduling/grpc/index.js +1 -1
- package/dist/modules/scheduling/interfaces.d.ts +1 -1
- package/dist/utils.d.ts +2 -2
- package/package.json +46 -45
- package/tsconfig-base.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,45 @@
|
|
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.1.6](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@1.1.5...@restorecommerce/facade@1.1.6) (2023-05-29)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **acs-client:** fixed acs-client typings for pluralized proto changes ([d20f14a](https://github.com/restorecommerce/libs/commit/d20f14af72e5f9ea7b3fce9b2b619b2c13fa2744))
|
12
|
+
* **facade:** up facade module for regenerated typings (Pluralized proto fields) ([3866585](https://github.com/restorecommerce/libs/commit/38665855742e7aea6baf574d12f723c99ec16cff))
|
13
|
+
* **rc-grpc-client:** updated typings for pluralized proto changes ([2929b11](https://github.com/restorecommerce/libs/commit/2929b11034fc18f247a3267108a28fb6e4500cfe))
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
## [1.1.5](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@1.1.4...@restorecommerce/facade@1.1.5) (2023-05-22)
|
20
|
+
|
21
|
+
|
22
|
+
### Bug Fixes
|
23
|
+
|
24
|
+
* **acs-client:** fix test imports ([3a092ef](https://github.com/restorecommerce/libs/commit/3a092ef3e34b45df0c121c3fef3f8a51d99acb96))
|
25
|
+
* **facade:** build error for null field ([aa7f405](https://github.com/restorecommerce/libs/commit/aa7f405aa3940be8d75abd3e10c6f29a19688d09))
|
26
|
+
* **facade:** downgrade nanoid, import koa-body, match test to object ([d05cee1](https://github.com/restorecommerce/libs/commit/d05cee10c7d631d54b5466e6122fee769505a6da))
|
27
|
+
* **facade:** fixed sub service name space ([f3266e7](https://github.com/restorecommerce/libs/commit/f3266e7461c7bb2db0a7be05fb79ff132f062ec5))
|
28
|
+
* **facade:** regenerated schema for changes in protos ([0da0851](https://github.com/restorecommerce/libs/commit/0da08515e4e1d05482d5881cbfe55523fc7fa368))
|
29
|
+
* **facade:** renamed service in protos and removed service names options from proto files, fixed typing issues. ([25a24f0](https://github.com/restorecommerce/libs/commit/25a24f063e2499c06c171f1265297500816879f2))
|
30
|
+
* **facade:** restore facade code-gen to previous working version ([294a55f](https://github.com/restorecommerce/libs/commit/294a55f7135aa4b072fdecefbd33baed9efeb4ca))
|
31
|
+
* **facade:** unit test ([748ab00](https://github.com/restorecommerce/libs/commit/748ab00483fa1893aa50006795c654834a7ffb57))
|
32
|
+
* failed unit tests ([0f06228](https://github.com/restorecommerce/libs/commit/0f062288ad929303a9544a3d30357b666dec555c))
|
33
|
+
* **protos:** restore nested attribute as its referenced in obligation masked properties in ACS ([d6536f9](https://github.com/restorecommerce/libs/commit/d6536f96dfc30eb1905c899af519d50778e2edee))
|
34
|
+
* **rc-grpc-clients, facade:** WIP optional fields ([98f0977](https://github.com/restorecommerce/libs/commit/98f097730503bd0fa021bc886ba55d477dafb89f))
|
35
|
+
|
36
|
+
|
37
|
+
### Reverts
|
38
|
+
|
39
|
+
* Revert "chore: upgrade Apollo Server 4" ([90464f2](https://github.com/restorecommerce/libs/commit/90464f2ba77261406718a76d4a854ff7cbcfedf2))
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
6
45
|
## [1.1.4](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@1.1.3...@restorecommerce/facade@1.1.4) (2022-11-16)
|
7
46
|
|
8
47
|
|
package/codegen/index.js
CHANGED
@@ -1,9 +1,32 @@
|
|
1
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
|
+
};
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
26
|
exports.generateSchemaTypings = void 0;
|
4
|
-
const fs = require("fs");
|
5
|
-
const typescriptPlugin = require("@graphql-codegen/typescript");
|
6
|
-
const typescriptResolversPlugin = require("@graphql-codegen/typescript-resolvers");
|
27
|
+
const fs = __importStar(require("fs"));
|
28
|
+
const typescriptPlugin = __importStar(require("@graphql-codegen/typescript"));
|
29
|
+
const typescriptResolversPlugin = __importStar(require("@graphql-codegen/typescript-resolvers"));
|
7
30
|
const core_1 = require("@graphql-codegen/core");
|
8
31
|
async function generateSchemaTypings({ schema, outputFile, typescript, typescriptResolvers }) {
|
9
32
|
try {
|
@@ -15,7 +38,8 @@ async function generateSchemaTypings({ schema, outputFile, typescript, typescrip
|
|
15
38
|
plugins: [
|
16
39
|
{
|
17
40
|
typescript: {
|
18
|
-
maybeValue: 'T | undefined',
|
41
|
+
maybeValue: 'T | null | undefined',
|
42
|
+
inputMaybeValue: 'T | null | undefined',
|
19
43
|
...(typescript !== null && typescript !== void 0 ? typescript : {})
|
20
44
|
},
|
21
45
|
},
|
@@ -1,8 +1,11 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.mergeSubscribeIntoSchema = exports.buildFederatedSubscriptionSchema = void 0;
|
4
7
|
const federation_1 = require("@apollo/federation");
|
5
|
-
const
|
8
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
6
9
|
const index_1 = require("graphql/index");
|
7
10
|
const graphql_1 = require("graphql");
|
8
11
|
const definition_1 = require("graphql/type/definition");
|
@@ -12,7 +15,7 @@ const buildFederatedSubscriptionSchema = (subServices, config, namespace, schema
|
|
12
15
|
// TODO There is currently no way of building a federated schema from GraphQLSchema Object
|
13
16
|
// See https://github.com/apollographql/apollo-server/pull/4310
|
14
17
|
const federatedSchema = (0, federation_1.buildSubgraphSchema)({
|
15
|
-
typeDefs: (0,
|
18
|
+
typeDefs: (0, graphql_tag_1.default)((0, index_1.printSchema)(schema)),
|
16
19
|
resolvers
|
17
20
|
});
|
18
21
|
return {
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTyping = exports.registerEnumTyping = exports.registerTyping = exports.recursiveEnumCheck = exports.getNameSpaceTypeName = exports.getRegisteredEnumTypings = exports.registerPackagesRecursive = exports.clearRegistry = exports.IGoogleProtobufAny = exports.scalarTypes = exports.registeredTypings = void 0;
|
4
4
|
const graphql_1 = require("graphql");
|
5
5
|
const definition_1 = require("graphql/type/definition");
|
6
|
-
const
|
6
|
+
const GraphQLUpload = require('graphql-upload/GraphQLUpload.js');
|
7
7
|
const utils_1 = require("./utils");
|
8
8
|
const types_1 = require("./types");
|
9
9
|
const ts_proto_descriptors_1 = require("ts-proto-descriptors");
|
@@ -349,7 +349,7 @@ const resolveMeta = (key, field, rootObjType, objName, input) => {
|
|
349
349
|
break;
|
350
350
|
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_BYTES:
|
351
351
|
if (input) {
|
352
|
-
result =
|
352
|
+
result = GraphQLUpload;
|
353
353
|
break;
|
354
354
|
}
|
355
355
|
// TODO Output Buffer
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { ProtoMetadata, ServiceClient, ServiceConfig, SubSpaceServiceConfig } from './types';
|
2
2
|
import { ServiceDescriptorProto } from 'ts-proto-descriptors';
|
3
3
|
import { GraphQLResolveInfo } from 'graphql';
|
4
|
-
export
|
5
|
-
export
|
4
|
+
export type ResolverFn<TResult, TParent, TContext, TArgs> = (parent: TParent, args: TArgs, context: TContext, info: GraphQLResolveInfo) => Promise<TResult> | TResult;
|
5
|
+
export type SubscribeResolverFn<TResult, TParent, TContext, TArgs> = (parent: TParent, args: TArgs, context: TContext, info: GraphQLResolveInfo) => AsyncGenerator<TResult>;
|
6
6
|
export declare const getGQLResolverFunctions: <T extends Record<string, any>, CTX extends ServiceClient<CTX, keyof CTX, T>, SRV = any, R = ResolverFn<any, any, ServiceClient<CTX, keyof CTX, T>, any>, B extends keyof T = any, NS extends keyof CTX = any>(service: ServiceDescriptorProto, key: NS, serviceKey: B, cfg: ServiceConfig) => { [key in keyof SRV]: R; };
|
7
7
|
export declare const registerResolverFunction: <T extends Record<string, any>, CTX extends ServiceClient<CTX, keyof CTX, T>>(namespace: string, name: string, func: ResolverFn<any, any, ServiceClient<CTX, keyof CTX, T>, any>, mutation?: boolean, subspace?: string | undefined, service?: ServiceDescriptorProto) => void;
|
8
8
|
export declare const generateResolver: (...namespaces: string[]) => any;
|
@@ -1,15 +1,41 @@
|
|
1
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 };
|
27
|
+
};
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
29
|
exports.generateSubServiceResolvers = exports.generateResolver = exports.registerResolverFunction = exports.getGQLResolverFunctions = void 0;
|
4
30
|
const types_1 = require("./types");
|
5
|
-
const array_prototype_flat_1 = require("array.prototype.flat");
|
31
|
+
const array_prototype_flat_1 = __importDefault(require("array.prototype.flat"));
|
6
32
|
const registry_1 = require("./registry");
|
7
33
|
const graphql_1 = require("./graphql");
|
8
34
|
const utils_1 = require("./utils");
|
9
35
|
const rc_grpc_clients_1 = require("@restorecommerce/rc-grpc-clients");
|
10
36
|
const resource_base_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/resource_base");
|
11
|
-
const stream = require("stream");
|
12
|
-
const _ = require("lodash");
|
37
|
+
const stream = __importStar(require("stream"));
|
38
|
+
const _ = __importStar(require("lodash"));
|
13
39
|
const kafka_client_1 = require("@restorecommerce/kafka-client");
|
14
40
|
const inputMethodType = new Map();
|
15
41
|
const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
|
@@ -261,8 +287,9 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
|
|
261
287
|
subServices.forEach((meta) => {
|
262
288
|
var _a;
|
263
289
|
meta.fileDescriptor.service.forEach(service => {
|
264
|
-
if (
|
265
|
-
|
290
|
+
if (service.name) {
|
291
|
+
// strip Service from end of String for sub service name
|
292
|
+
const subName = (0, utils_1.getServiceName)(service.name);
|
266
293
|
const { mutations, queries } = (0, graphql_1.getWhitelistBlacklistConfig)(service, config, meta, subName);
|
267
294
|
const func = (0, exports.getGQLResolverFunctions)(service, namespace, subName || namespace, config);
|
268
295
|
Object.keys(func).forEach(k => {
|
@@ -354,11 +381,11 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
|
|
354
381
|
if (config.root) {
|
355
382
|
return (0, exports.generateResolver)(...(0, array_prototype_flat_1.default)(subServices.map(meta => {
|
356
383
|
return meta.fileDescriptor.service.map(service => {
|
357
|
-
if (
|
358
|
-
return
|
384
|
+
if (service.name) {
|
385
|
+
return (0, utils_1.getServiceName)(service.name);
|
359
386
|
}
|
360
|
-
return
|
361
|
-
}).filter(s => s !==
|
387
|
+
return '';
|
388
|
+
}).filter(s => s !== '');
|
362
389
|
})));
|
363
390
|
}
|
364
391
|
const finalResolver = (0, exports.generateResolver)(namespace);
|
@@ -4,7 +4,7 @@ import { GraphQLSchema, ThunkObjMap } from 'graphql';
|
|
4
4
|
import { GraphQLFieldConfig, GraphQLFieldConfigMap } from 'graphql/type/definition';
|
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>>>;
|
8
8
|
export declare const registerResolverSchema: (namespace: string, name: string, schema: SchemaBaseOrSub, mutation: boolean | undefined, subspace: string | undefined, config: ServiceConfig) => void;
|
9
9
|
export declare const generateSchema: (setup: {
|
10
10
|
prefix: string;
|
@@ -1,8 +1,11 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.generateSubServiceSchemas = exports.generateSchema = exports.registerResolverSchema = exports.getGQLSchemas = exports.getGQLSchema = void 0;
|
4
7
|
const graphql_1 = require("graphql");
|
5
|
-
const array_prototype_flat_1 = require("array.prototype.flat");
|
8
|
+
const array_prototype_flat_1 = __importDefault(require("array.prototype.flat"));
|
6
9
|
const graphql_2 = require("./graphql");
|
7
10
|
const utils_1 = require("./utils");
|
8
11
|
const registry_1 = require("./registry");
|
@@ -189,8 +192,8 @@ const generateSubServiceSchemas = (subServices, config, namespace, prefix) => {
|
|
189
192
|
subServices.forEach((meta) => {
|
190
193
|
var _a;
|
191
194
|
meta.fileDescriptor.service.forEach(service => {
|
192
|
-
if (
|
193
|
-
const subName =
|
195
|
+
if (service.name) {
|
196
|
+
const subName = (0, utils_1.getServiceName)(service.name);
|
194
197
|
const { mutations, queries } = (0, graphql_2.getWhitelistBlacklistConfig)(service, config, meta, subName);
|
195
198
|
const schemas = (0, exports.getGQLSchemas)(service);
|
196
199
|
Object.keys(schemas).forEach(key => {
|
@@ -218,8 +221,8 @@ const generateSubServiceSchemas = (subServices, config, namespace, prefix) => {
|
|
218
221
|
if (config.root) {
|
219
222
|
return (0, exports.generateSchema)((0, array_prototype_flat_1.default)(subServices.map(meta => {
|
220
223
|
return meta.fileDescriptor.service.map(service => {
|
221
|
-
if (
|
222
|
-
const subName =
|
224
|
+
if (service.name) {
|
225
|
+
const subName = (0, utils_1.getServiceName)(service.name);
|
223
226
|
return {
|
224
227
|
prefix: prefix + subName.substring(0, 1).toUpperCase() + subName.substring(1).toLowerCase(),
|
225
228
|
namespace: subName
|
@@ -12,7 +12,7 @@ export interface GraphQLResolverMap<TContext = {}> {
|
|
12
12
|
};
|
13
13
|
}
|
14
14
|
export declare const authSubjectType = ".io.restorecommerce.auth.Subject";
|
15
|
-
export
|
15
|
+
export type ProtoMetaMessageOptions = {
|
16
16
|
options?: {
|
17
17
|
[key: string]: any;
|
18
18
|
};
|
@@ -85,12 +85,12 @@ export interface ServiceConfig {
|
|
85
85
|
export interface SubSpaceServiceConfig extends ServiceConfig {
|
86
86
|
root: boolean;
|
87
87
|
}
|
88
|
-
export
|
88
|
+
export type ServiceClient<Context extends Pick<Context, Key>, Key extends keyof Context, T extends Record<string, any>> = {
|
89
89
|
[V in Key]: {
|
90
90
|
client: T;
|
91
91
|
};
|
92
92
|
};
|
93
|
-
export
|
93
|
+
export type FederatedSchemaWithResolvers = {
|
94
94
|
federatedSchema: GraphQLSchema;
|
95
95
|
resolvers: GraphQLResolverMap<any>;
|
96
96
|
};
|
@@ -10,6 +10,8 @@ export declare const decodeBufferFields: (items: any[], bufferFields: string[])
|
|
10
10
|
*/
|
11
11
|
export declare const convertEnumToInt: (inputTyping: TypingData, req: any) => any;
|
12
12
|
export declare const snakeToCamel: (s: string) => string;
|
13
|
+
export declare const camelToSnake: (serviceName: string) => string;
|
14
|
+
export declare const getServiceName: (serviceName: string) => string;
|
13
15
|
export declare const capitalize: (s: string) => string;
|
14
16
|
export declare function camelCase(s: string): string;
|
15
17
|
export declare let useSubscriptions: boolean;
|
package/dist/gql/protos/utils.js
CHANGED
@@ -1,7 +1,30 @@
|
|
1
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
|
+
};
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.setUseSubscriptions = exports.useSubscriptions = exports.camelCase = exports.capitalize = exports.snakeToCamel = exports.convertEnumToInt = exports.decodeBufferFields = exports.getKeys = exports.convertyCamelToSnakeCase = exports.capitalizeProtoName = void 0;
|
4
|
-
const _ = require("lodash");
|
26
|
+
exports.setUseSubscriptions = exports.useSubscriptions = exports.camelCase = exports.capitalize = exports.getServiceName = exports.camelToSnake = exports.snakeToCamel = exports.convertEnumToInt = exports.decodeBufferFields = exports.getKeys = exports.convertyCamelToSnakeCase = exports.capitalizeProtoName = void 0;
|
27
|
+
const _ = __importStar(require("lodash"));
|
5
28
|
const registry_1 = require("./registry");
|
6
29
|
const capitalizeProtoName = (name) => {
|
7
30
|
return name.replace(/(?:\.|^|_)(\w)/g, v => v.toUpperCase()).replace(/[._]/g, '');
|
@@ -126,6 +149,16 @@ const snakeToCamel = (s) => {
|
|
126
149
|
.join('');
|
127
150
|
};
|
128
151
|
exports.snakeToCamel = snakeToCamel;
|
152
|
+
const camelToSnake = (serviceName) => {
|
153
|
+
// convert camel case to snake case
|
154
|
+
serviceName = serviceName.replace(/(?:^|\.?)([A-Z])/g, (x, y) => { return '_' + y.toLowerCase(); }).replace(/^_/, '');
|
155
|
+
return serviceName;
|
156
|
+
};
|
157
|
+
exports.camelToSnake = camelToSnake;
|
158
|
+
const getServiceName = (serviceName) => {
|
159
|
+
return serviceName.endsWith('Service') ? (0, exports.camelToSnake)(serviceName.substr(0, serviceName.length - 7)) : (0, exports.camelToSnake)(serviceName);
|
160
|
+
};
|
161
|
+
exports.getServiceName = getServiceName;
|
129
162
|
const capitalize = (s) => {
|
130
163
|
return s.substring(0, 1).toUpperCase() + s.substring(1);
|
131
164
|
};
|
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
/// <reference types="koa-bodyparser" />
|
2
|
-
/// <reference types="koa-websocket" />
|
3
1
|
/// <reference types="node" />
|
4
2
|
/// <reference types="node" />
|
5
|
-
import Koa from 'koa';
|
6
3
|
import { Logger } from 'winston';
|
7
4
|
import { Server, ServerResponse } from 'http';
|
5
|
+
import Koa from "koa";
|
8
6
|
import { AddressInfo } from 'net';
|
9
7
|
import { Facade, FacadeBaseContext, FacadeModule, FacadeModuleBase, FacadeModulesContext } from './interfaces';
|
10
8
|
import { KafkaProviderConfig } from '@restorecommerce/kafka-client';
|
package/dist/index.js
CHANGED
@@ -10,27 +10,46 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
11
11
|
o[k2] = m[k];
|
12
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
|
+
};
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
27
|
};
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30
|
+
};
|
16
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
32
|
exports.createFacade = exports.RestoreCommerceFacade = void 0;
|
18
|
-
const koa_1 = require("koa");
|
19
33
|
const logger_1 = require("@restorecommerce/logger");
|
20
34
|
const http_1 = require("http");
|
21
|
-
const
|
35
|
+
const koa_1 = __importDefault(require("koa"));
|
36
|
+
const bodyParser = require('koa-bodyparser');
|
37
|
+
const cors = require('@koa/cors');
|
38
|
+
const server_1 = require("@apollo/server");
|
39
|
+
const koa_2 = require("@as-integrations/koa");
|
22
40
|
const graphql_1 = require("graphql");
|
23
41
|
const gateway_1 = require("@apollo/gateway");
|
24
42
|
const modules_1 = require("./modules");
|
25
|
-
const
|
43
|
+
const drainHttpServer_1 = require("@apollo/server/plugin/drainHttpServer");
|
44
|
+
const default_1 = require("@apollo/server/plugin/landingPage/default");
|
26
45
|
const http_2 = require("http");
|
27
46
|
const ws_1 = require("ws");
|
28
47
|
const ws_2 = require("graphql-ws/lib/use/ws");
|
29
|
-
const _ = require("lodash");
|
48
|
+
const _ = __importStar(require("lodash"));
|
30
49
|
const graphql_tools_1 = require("graphql-tools");
|
31
|
-
const graphql_tag_1 = require("graphql-tag");
|
50
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
32
51
|
const protos_1 = require("./gql/protos");
|
33
|
-
const koa_compose_1 = require("koa-compose");
|
52
|
+
const koa_compose_1 = __importDefault(require("koa-compose"));
|
34
53
|
const utils_1 = require("./gql/protos/utils");
|
35
54
|
__exportStar(require("./modules/index"), exports);
|
36
55
|
__exportStar(require("./middlewares/index"), exports);
|
@@ -201,7 +220,7 @@ class RestoreCommerceFacade {
|
|
201
220
|
subscription: schemaContext.apiSchema.getSubscriptionType()
|
202
221
|
}));
|
203
222
|
let schema = (0, graphql_tools_1.makeExecutableSchema)({
|
204
|
-
typeDefs: (0, graphql_tag_1.
|
223
|
+
typeDefs: (0, graphql_tag_1.default)(typeDefs + `
|
205
224
|
type Query { sample: String }
|
206
225
|
`),
|
207
226
|
resolvers: {
|
@@ -225,12 +244,13 @@ class RestoreCommerceFacade {
|
|
225
244
|
},
|
226
245
|
}, wsServer);
|
227
246
|
});
|
228
|
-
const gqlServer = new
|
247
|
+
const gqlServer = new server_1.ApolloServer({
|
229
248
|
gateway,
|
230
249
|
introspection: true,
|
250
|
+
allowBatchedHttpRequests: true,
|
231
251
|
plugins: [
|
232
|
-
(0,
|
233
|
-
(0,
|
252
|
+
(0, drainHttpServer_1.ApolloServerPluginDrainHttpServer)({ httpServer: this._server }),
|
253
|
+
(0, default_1.ApolloServerPluginLandingPageLocalDefault)({
|
234
254
|
embed: true
|
235
255
|
}),
|
236
256
|
{
|
@@ -243,27 +263,23 @@ class RestoreCommerceFacade {
|
|
243
263
|
},
|
244
264
|
},
|
245
265
|
],
|
246
|
-
|
266
|
+
includeStacktraceInErrorResponses: true,
|
247
267
|
formatError: (error) => {
|
248
268
|
this.logger.error('Error while processing request', { message: error.message });
|
249
269
|
this.logger.debug('Error while processing request', { error });
|
250
270
|
return {
|
251
271
|
message: error.message,
|
252
272
|
locations: error.locations,
|
253
|
-
stack: error
|
273
|
+
stack: error
|
254
274
|
};
|
255
275
|
},
|
256
|
-
context: ({ ctx }) => ctx
|
257
276
|
});
|
258
277
|
await gqlServer.start();
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
},
|
265
|
-
});
|
266
|
-
this.koa.use(middleware);
|
278
|
+
this.koa.use(cors());
|
279
|
+
this.koa.use(bodyParser());
|
280
|
+
this.koa.use((0, koa_2.koaMiddleware)(gqlServer, {
|
281
|
+
context: async ({ ctx }) => ctx,
|
282
|
+
}));
|
267
283
|
}
|
268
284
|
}
|
269
285
|
exports.RestoreCommerceFacade = RestoreCommerceFacade;
|
package/dist/interfaces.d.ts
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
/// <reference types="koa-websocket" />
|
2
|
-
/// <reference types="koa-bodyparser" />
|
3
2
|
/// <reference types="node" />
|
4
3
|
/// <reference types="node" />
|
5
4
|
import Koa from 'koa';
|
6
5
|
import { Logger } from 'winston';
|
7
6
|
import { Server } from 'http';
|
8
7
|
import { AddressInfo } from 'net';
|
9
|
-
|
8
|
+
type RequireAtLeastOne<T, Keys extends keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
10
9
|
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
11
10
|
}[Keys];
|
12
11
|
export interface FacadeBaseContext extends Koa.Context {
|
@@ -22,9 +21,9 @@ export interface FacadeModule<TContext extends FacadeBaseContext = FacadeBaseCon
|
|
22
21
|
export interface FacadeModuleFactory<TConfig = any, TContext extends FacadeBaseContext = FacadeBaseContext> extends FacadeModuleBase<TContext> {
|
23
22
|
(config: TConfig): FacadeModule<TContext>;
|
24
23
|
}
|
25
|
-
export
|
26
|
-
export
|
27
|
-
export
|
24
|
+
export type ExtractModuleContext<TModule> = TModule extends FacadeModuleFactory<infer TConfig, infer TContext> ? TContext : TModule extends FacadeModule<infer TContext> ? TContext : never;
|
25
|
+
export type FacadeModulesContext<T extends FacadeModuleBase[]> = (T[0] extends FacadeModuleBase ? ExtractModuleContext<T[0]> : FacadeBaseContext) & (T[1] extends FacadeModuleBase ? ExtractModuleContext<T[1]> : FacadeBaseContext) & (T[2] extends FacadeModuleBase ? ExtractModuleContext<T[2]> : FacadeBaseContext) & (T[3] extends FacadeModuleBase ? ExtractModuleContext<T[3]> : FacadeBaseContext) & (T[4] extends FacadeModuleBase ? ExtractModuleContext<T[4]> : FacadeBaseContext) & (T[5] extends FacadeModuleBase ? ExtractModuleContext<T[5]> : FacadeBaseContext) & (T[6] extends FacadeModuleBase ? ExtractModuleContext<T[6]> : FacadeBaseContext) & (T[7] extends FacadeModuleBase ? ExtractModuleContext<T[7]> : FacadeBaseContext) & (T[8] extends FacadeModuleBase ? ExtractModuleContext<T[8]> : FacadeBaseContext) & (T[9] extends FacadeModuleBase ? ExtractModuleContext<T[9]> : FacadeBaseContext);
|
26
|
+
export type FacadeContext<T extends FacadeModuleBase[] | Facade<any> = []> = T extends FacadeModuleBase[] ? FacadeModulesContext<T> : T extends Facade<infer TFacadeModules> ? FacadeModulesContext<TFacadeModules> : FacadeBaseContext;
|
28
27
|
export interface Facade<TModules extends FacadeModuleBase[] = []> {
|
29
28
|
readonly logger: Logger;
|
30
29
|
readonly koa: Koa<any, FacadeModulesContext<TModules>>;
|
@@ -1,7 +1,10 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.reqResLogger = void 0;
|
4
|
-
const debug_1 = require("debug");
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
5
8
|
const logger_1 = require("@restorecommerce/logger");
|
6
9
|
const debug = (0, debug_1.default)('@restorecommerce/koa-req-res-logger');
|
7
10
|
/**
|
@@ -1,7 +1,10 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.FederatedAccessControlSchema = void 0;
|
4
|
-
const
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
5
8
|
const federation_1 = require("@apollo/federation");
|
6
9
|
const schema_1 = require("./schema");
|
7
10
|
const interfaces_1 = require("../interfaces");
|
@@ -11,7 +14,7 @@ const graphql_1 = require("graphql");
|
|
11
14
|
// TODO There is currently no way of building a federated schema from GraphQLSchema Object
|
12
15
|
// See https://github.com/apollographql/apollo-server/pull/4310
|
13
16
|
const FederatedAccessControlSchema = (cfg) => (0, federation_1.buildSubgraphSchema)({
|
14
|
-
typeDefs: (0,
|
17
|
+
typeDefs: (0, graphql_tag_1.default)((0, graphql_1.printSchema)((0, schema_1.schema)(cfg))),
|
15
18
|
resolvers: (0, protos_1.generateSubServiceResolvers)(types_1.subServices, cfg, interfaces_1.namespace)
|
16
19
|
});
|
17
20
|
exports.FederatedAccessControlSchema = FederatedAccessControlSchema;
|