@restorecommerce/facade 0.5.5 → 1.0.0
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 +38 -0
- package/dist/gql/index.d.ts +0 -3
- package/dist/gql/index.js +0 -3
- package/dist/gql/protos/graphql.d.ts +1 -0
- package/dist/gql/protos/graphql.js +9 -3
- package/dist/gql/protos/index.d.ts +0 -1
- package/dist/gql/protos/index.js +0 -1
- package/dist/gql/protos/types.d.ts +3 -1
- package/dist/modules/access-control/grpc/index.d.ts +11 -12
- package/dist/modules/access-control/grpc/index.js +6 -7
- package/dist/modules/access-control/index.js +4 -1
- package/dist/modules/catalog/grpc/index.d.ts +13 -14
- package/dist/modules/catalog/grpc/index.js +7 -8
- package/dist/modules/catalog/index.js +4 -1
- package/dist/modules/fulfillment/grpc/index.d.ts +7 -8
- package/dist/modules/fulfillment/grpc/index.js +4 -5
- package/dist/modules/fulfillment/index.js +4 -1
- package/dist/modules/identity/grpc/index.d.ts +13 -14
- package/dist/modules/identity/grpc/index.js +7 -8
- package/dist/modules/identity/index.js +4 -1
- package/dist/modules/identity/oauth/oauth.js +3 -3
- package/dist/modules/identity/oidc/adapter.d.ts +1 -1
- package/dist/modules/identity/oidc/interfaces.d.ts +2 -2
- package/dist/modules/identity/oidc/password-grant.js +1 -1
- package/dist/modules/identity/oidc/user.d.ts +1 -1
- package/dist/modules/identity/oidc/user.js +1 -1
- package/dist/modules/indexing/grpc/index.d.ts +5 -6
- package/dist/modules/indexing/grpc/index.js +3 -4
- package/dist/modules/indexing/index.js +4 -1
- package/dist/modules/invoicing/grpc/index.d.ts +5 -6
- package/dist/modules/invoicing/grpc/index.js +3 -4
- package/dist/modules/invoicing/index.js +4 -1
- package/dist/modules/notification/grpc/index.d.ts +5 -6
- package/dist/modules/notification/grpc/index.js +3 -4
- package/dist/modules/notification/index.js +4 -1
- package/dist/modules/ordering/grpc/index.d.ts +5 -6
- package/dist/modules/ordering/grpc/index.js +3 -4
- package/dist/modules/ordering/index.js +4 -1
- package/dist/modules/ostorage/grpc/index.d.ts +5 -6
- package/dist/modules/ostorage/grpc/index.js +3 -4
- package/dist/modules/ostorage/index.js +4 -1
- package/dist/modules/payment/grpc/index.d.ts +5 -6
- package/dist/modules/payment/grpc/index.js +3 -4
- package/dist/modules/payment/index.js +4 -1
- package/dist/modules/resource/grpc/index.d.ts +25 -27
- package/dist/modules/resource/grpc/index.js +13 -16
- package/dist/modules/resource/index.js +4 -1
- package/dist/modules/scheduling/grpc/index.d.ts +5 -6
- package/dist/modules/scheduling/grpc/index.js +3 -4
- package/dist/modules/scheduling/index.js +4 -1
- package/package.json +7 -7
- package/dist/gql/helpers/index.d.ts +0 -1
- package/dist/gql/helpers/index.js +0 -2
- package/dist/gql/helpers/resolver.d.ts +0 -122
- package/dist/gql/helpers/resolver.js +0 -290
- package/dist/gql/helpers/schema.d.ts +0 -56
- package/dist/gql/helpers/schema.js +0 -126
- package/dist/gql/protos/protos.d.ts +0 -6
- package/dist/gql/protos/protos.js +0 -55
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,44 @@
|
|
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.0.0](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@0.5.7...@restorecommerce/facade@1.0.0) (2022-08-25)
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* move to fully typed grpc client and server ([ec9be2d](https://github.com/restorecommerce/libs/commit/ec9be2daff0823e9ba440a2845b7b1a7f2d74b50))
|
12
|
+
* move to fully typed grpc client and server ([aeee2f2](https://github.com/restorecommerce/libs/commit/aeee2f2b7ca470223d7bc42fd7cafd4bb8387796))
|
13
|
+
|
14
|
+
|
15
|
+
### Reverts
|
16
|
+
|
17
|
+
* Revert "BREAKING CHANGE: move to fully typed grpc client and server" ([2d584a7](https://github.com/restorecommerce/libs/commit/2d584a709632ae608f595a2c836deabd34f671d9))
|
18
|
+
|
19
|
+
|
20
|
+
### BREAKING CHANGES
|
21
|
+
|
22
|
+
* move to fully typed grpc client and server
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
## [0.5.7](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@0.5.6...@restorecommerce/facade@0.5.7) (2022-08-10)
|
29
|
+
|
30
|
+
**Note:** Version bump only for package @restorecommerce/facade
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
## [0.5.6](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@0.5.5...@restorecommerce/facade@0.5.6) (2022-07-07)
|
37
|
+
|
38
|
+
**Note:** Version bump only for package @restorecommerce/facade
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
6
44
|
## [0.5.5](https://github.com/restorecommerce/libs/compare/@restorecommerce/facade@0.5.4...@restorecommerce/facade@0.5.5) (2022-06-28)
|
7
45
|
|
8
46
|
**Note:** Version bump only for package @restorecommerce/facade
|
package/dist/gql/index.d.ts
CHANGED
package/dist/gql/index.js
CHANGED
@@ -15,6 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./types/index"), exports);
|
18
|
-
__exportStar(require("./helpers/index"), exports);
|
19
|
-
__exportStar(require("./helpers/resolver"), exports);
|
20
|
-
__exportStar(require("./helpers/schema"), exports);
|
@@ -29,4 +29,5 @@ export declare const getAndGenerateSchema: <TSource, TContext>(service: ServiceD
|
|
29
29
|
export declare const getAndGenerateResolvers: <T extends Record<string, any>, CTX extends ServiceClient<CTX, keyof CTX, T>, SRV = any, R = ResolverFn<any, any, ServiceClient<CTX, keyof CTX, T>, any>, NS extends keyof CTX = any>(service: ServiceDescriptorProto, namespace: NS, cfg: ServiceConfig, meta: ProtoMetadata, subspace?: string | undefined, serviceKey?: string | undefined) => { [key in keyof SRV]: R; };
|
30
30
|
export declare const generateSubServiceSchemas: (subServices: ProtoMetadata[], config: SubSpaceServiceConfig, namespace: string, prefix: string) => GraphQLSchema;
|
31
31
|
export declare const generateSubServiceResolvers: <T, M extends Record<string, any>, CTX extends ServiceClient<CTX, keyof CTX, M>>(subServices: ProtoMetadata[], config: SubSpaceServiceConfig, namespace: string) => T;
|
32
|
+
export declare function camelCase(s: string): string;
|
32
33
|
export {};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.generateSubServiceResolvers = exports.generateSubServiceSchemas = exports.getAndGenerateResolvers = exports.getAndGenerateSchema = exports.getWhitelistBlacklistConfig = exports.generateSchema = exports.registerResolverSchema = exports.generateResolver = exports.registerResolverFunction = exports.getGQLResolverFunctions = exports.postProcessGQLValue = exports.preprocessGQLInput = exports.getGQLSchemas = exports.getGQLSchema = void 0;
|
3
|
+
exports.camelCase = exports.generateSubServiceResolvers = exports.generateSubServiceSchemas = exports.getAndGenerateResolvers = exports.getAndGenerateSchema = exports.getWhitelistBlacklistConfig = exports.generateSchema = exports.registerResolverSchema = exports.generateResolver = exports.registerResolverFunction = exports.getGQLResolverFunctions = exports.postProcessGQLValue = exports.preprocessGQLInput = exports.getGQLSchemas = exports.getGQLSchema = void 0;
|
4
4
|
const graphql_1 = require("graphql");
|
5
5
|
const definition_1 = require("graphql/type/definition");
|
6
6
|
const types_1 = require("./types");
|
@@ -228,7 +228,8 @@ const getGQLResolverFunctions = (service, key, serviceKey, cfg) => {
|
|
228
228
|
realMethod = 'Upsert';
|
229
229
|
}
|
230
230
|
}
|
231
|
-
const
|
231
|
+
const methodFunc = service[camelCase(realMethod)] || service[realMethod];
|
232
|
+
const rawResult = await methodFunc(req);
|
232
233
|
const result = (0, exports.postProcessGQLValue)(rawResult, outputTyping.output);
|
233
234
|
const grpcClientConfig = cfg.client;
|
234
235
|
const bufferFields = (0, utils_1.getKeys)(grpcClientConfig === null || grpcClientConfig === void 0 ? void 0 : grpcClientConfig.bufferFields);
|
@@ -678,7 +679,8 @@ const generateSubServiceResolvers = (subServices, config, namespace) => {
|
|
678
679
|
if (authToken && authToken.startsWith('Bearer ')) {
|
679
680
|
req.subject.token = authToken.split(' ')[1];
|
680
681
|
}
|
681
|
-
const
|
682
|
+
const methodFunc = service[camelCase(resolver.targetMethod)] || service[resolver.targetMethod];
|
683
|
+
const result = await methodFunc(req);
|
682
684
|
if (result && result.items && result.items.length) {
|
683
685
|
if (Array.isArray(parent[fieldJsonName])) {
|
684
686
|
return result.items.map((item) => item.payload);
|
@@ -718,3 +720,7 @@ const snakeToCamel = (s) => {
|
|
718
720
|
const capitalize = (s) => {
|
719
721
|
return s.substring(0, 1).toUpperCase() + s.substring(1);
|
720
722
|
};
|
723
|
+
function camelCase(s) {
|
724
|
+
return s.substring(0, 1).toLowerCase() + s.substring(1);
|
725
|
+
}
|
726
|
+
exports.camelCase = camelCase;
|
package/dist/gql/protos/index.js
CHANGED
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./types"), exports);
|
18
18
|
__exportStar(require("./registry"), exports);
|
19
|
-
__exportStar(require("./protos"), exports);
|
20
19
|
__exportStar(require("./graphql"), exports);
|
@@ -66,7 +66,9 @@ export interface MethodConfig {
|
|
66
66
|
methods?: BlackListWhiteListConfig;
|
67
67
|
}
|
68
68
|
export interface ServiceConfig {
|
69
|
-
client: GrpcClientConfig
|
69
|
+
client: Omit<GrpcClientConfig, 'logger'> & {
|
70
|
+
address: string;
|
71
|
+
};
|
70
72
|
[key: string]: any;
|
71
73
|
}
|
72
74
|
export interface SubSpaceServiceConfig extends ServiceConfig {
|
@@ -1,14 +1,13 @@
|
|
1
|
-
import { RestoreCommerceGrpcClient } from
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { GrpcClientConfig } from
|
7
|
-
import { Logger } from "winston";
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { ServiceClient as access_controlClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/access_control';
|
3
|
+
import { ServiceClient as policyClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/policy';
|
4
|
+
import { ServiceClient as ruleClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/rule';
|
5
|
+
import { ServiceClient as policy_setClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/policy_set';
|
6
|
+
import { GrpcClientConfig } from '@restorecommerce/grpc-client';
|
8
7
|
export declare class AccessControlSrvGrpcClient extends RestoreCommerceGrpcClient {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
readonly access_control: access_controlClient;
|
9
|
+
readonly policy: policyClient;
|
10
|
+
readonly rule: ruleClient;
|
11
|
+
readonly policy_set: policy_setClient;
|
12
|
+
constructor(address: string, cfg: GrpcClientConfig);
|
14
13
|
}
|
@@ -6,14 +6,13 @@ const access_control_1 = require("@restorecommerce/rc-grpc-clients/dist/generate
|
|
6
6
|
const policy_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/policy");
|
7
7
|
const rule_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/rule");
|
8
8
|
const policy_set_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/policy_set");
|
9
|
-
const protos_1 = require("../../../gql/protos");
|
10
9
|
class AccessControlSrvGrpcClient extends rc_grpc_clients_1.RestoreCommerceGrpcClient {
|
11
|
-
constructor(
|
12
|
-
super(
|
13
|
-
this.access_control =
|
14
|
-
this.policy =
|
15
|
-
this.rule =
|
16
|
-
this.policy_set =
|
10
|
+
constructor(address, cfg) {
|
11
|
+
super(address, cfg);
|
12
|
+
this.access_control = this.createClient(cfg, access_control_1.ServiceDefinition, this.channel);
|
13
|
+
this.policy = this.createClient(cfg, policy_1.ServiceDefinition, this.channel);
|
14
|
+
this.rule = this.createClient(cfg, rule_1.ServiceDefinition, this.channel);
|
15
|
+
this.policy_set = this.createClient(cfg, policy_set_1.ServiceDefinition, this.channel);
|
17
16
|
}
|
18
17
|
}
|
19
18
|
exports.AccessControlSrvGrpcClient = AccessControlSrvGrpcClient;
|
@@ -7,7 +7,10 @@ const grpc_1 = require("./grpc");
|
|
7
7
|
const utils_1 = require("../../utils");
|
8
8
|
exports.accessControlModule = (0, utils_1.createFacadeModuleFactory)(interfaces_1.namespace, (facade, config) => {
|
9
9
|
const accessControl = {
|
10
|
-
client: new grpc_1.AccessControlSrvGrpcClient(config.config.client,
|
10
|
+
client: new grpc_1.AccessControlSrvGrpcClient(config.config.client.address, {
|
11
|
+
...config.config.client,
|
12
|
+
logger: facade.logger,
|
13
|
+
})
|
11
14
|
};
|
12
15
|
facade.addApolloService({
|
13
16
|
name: interfaces_1.namespace,
|
@@ -1,16 +1,15 @@
|
|
1
|
-
import { RestoreCommerceGrpcClient } from
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { GrpcClientConfig } from
|
8
|
-
import { Logger } from "winston";
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { ServiceClient as productClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/product';
|
3
|
+
import { ServiceClient as product_prototypeClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/product_prototype';
|
4
|
+
import { ServiceClient as product_categoryClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/product_category';
|
5
|
+
import { ServiceClient as price_groupClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/price_group';
|
6
|
+
import { ServiceClient as manufacturerClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/manufacturer';
|
7
|
+
import { GrpcClientConfig } from '@restorecommerce/grpc-client';
|
9
8
|
export declare class CatalogSrvGrpcClient extends RestoreCommerceGrpcClient {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
readonly product: productClient;
|
10
|
+
readonly product_prototype: product_prototypeClient;
|
11
|
+
readonly product_category: product_categoryClient;
|
12
|
+
readonly price_group: price_groupClient;
|
13
|
+
readonly manufacturer: manufacturerClient;
|
14
|
+
constructor(address: string, cfg: GrpcClientConfig);
|
16
15
|
}
|
@@ -7,15 +7,14 @@ const product_prototype_1 = require("@restorecommerce/rc-grpc-clients/dist/gener
|
|
7
7
|
const product_category_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/product_category");
|
8
8
|
const price_group_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/price_group");
|
9
9
|
const manufacturer_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/manufacturer");
|
10
|
-
const protos_1 = require("../../../gql/protos");
|
11
10
|
class CatalogSrvGrpcClient extends rc_grpc_clients_1.RestoreCommerceGrpcClient {
|
12
|
-
constructor(
|
13
|
-
super(
|
14
|
-
this.product =
|
15
|
-
this.product_prototype =
|
16
|
-
this.product_category =
|
17
|
-
this.price_group =
|
18
|
-
this.manufacturer =
|
11
|
+
constructor(address, cfg) {
|
12
|
+
super(address, cfg);
|
13
|
+
this.product = this.createClient(cfg, product_1.ServiceDefinition, this.channel);
|
14
|
+
this.product_prototype = this.createClient(cfg, product_prototype_1.ServiceDefinition, this.channel);
|
15
|
+
this.product_category = this.createClient(cfg, product_category_1.ServiceDefinition, this.channel);
|
16
|
+
this.price_group = this.createClient(cfg, price_group_1.ServiceDefinition, this.channel);
|
17
|
+
this.manufacturer = this.createClient(cfg, manufacturer_1.ServiceDefinition, this.channel);
|
19
18
|
}
|
20
19
|
}
|
21
20
|
exports.CatalogSrvGrpcClient = CatalogSrvGrpcClient;
|
@@ -7,7 +7,10 @@ const grpc_1 = require("./grpc");
|
|
7
7
|
const utils_1 = require("../../utils");
|
8
8
|
exports.catalogModule = (0, utils_1.createFacadeModuleFactory)(interfaces_1.namespace, (facade, config) => {
|
9
9
|
const catalog = {
|
10
|
-
client: new grpc_1.CatalogSrvGrpcClient(config.config.client,
|
10
|
+
client: new grpc_1.CatalogSrvGrpcClient(config.config.client.address, {
|
11
|
+
...config.config.client,
|
12
|
+
logger: facade.logger,
|
13
|
+
})
|
11
14
|
};
|
12
15
|
facade.addApolloService({
|
13
16
|
name: interfaces_1.namespace,
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import { RestoreCommerceGrpcClient } from
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { GrpcClientConfig } from
|
5
|
-
import { Logger } from "winston";
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { ServiceClient as fulfillmentClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/fulfillment';
|
3
|
+
import { ServiceClient as fulfillment_courierClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/fulfillment_courier';
|
4
|
+
import { GrpcClientConfig } from '@restorecommerce/grpc-client';
|
6
5
|
export declare class FulfillmentSrvGrpcClient extends RestoreCommerceGrpcClient {
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
readonly fulfillment: fulfillmentClient;
|
7
|
+
readonly fulfillment_courier: fulfillment_courierClient;
|
8
|
+
constructor(address: string, cfg: GrpcClientConfig);
|
10
9
|
}
|
@@ -4,12 +4,11 @@ exports.FulfillmentSrvGrpcClient = void 0;
|
|
4
4
|
const rc_grpc_clients_1 = require("@restorecommerce/rc-grpc-clients");
|
5
5
|
const fulfillment_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/fulfillment");
|
6
6
|
const fulfillment_courier_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/fulfillment_courier");
|
7
|
-
const protos_1 = require("../../../gql/protos");
|
8
7
|
class FulfillmentSrvGrpcClient extends rc_grpc_clients_1.RestoreCommerceGrpcClient {
|
9
|
-
constructor(
|
10
|
-
super(
|
11
|
-
this.fulfillment =
|
12
|
-
this.fulfillment_courier =
|
8
|
+
constructor(address, cfg) {
|
9
|
+
super(address, cfg);
|
10
|
+
this.fulfillment = this.createClient(cfg, fulfillment_1.ServiceDefinition, this.channel);
|
11
|
+
this.fulfillment_courier = this.createClient(cfg, fulfillment_courier_1.ServiceDefinition, this.channel);
|
13
12
|
}
|
14
13
|
}
|
15
14
|
exports.FulfillmentSrvGrpcClient = FulfillmentSrvGrpcClient;
|
@@ -7,7 +7,10 @@ const grpc_1 = require("./grpc");
|
|
7
7
|
const utils_1 = require("../../utils");
|
8
8
|
exports.fulfillmentModule = (0, utils_1.createFacadeModuleFactory)(interfaces_1.namespace, (facade, config) => {
|
9
9
|
const fulfillment = {
|
10
|
-
client: new grpc_1.FulfillmentSrvGrpcClient(config.config.client,
|
10
|
+
client: new grpc_1.FulfillmentSrvGrpcClient(config.config.client.address, {
|
11
|
+
...config.config.client,
|
12
|
+
logger: facade.logger,
|
13
|
+
})
|
11
14
|
};
|
12
15
|
facade.addApolloService({
|
13
16
|
name: interfaces_1.namespace,
|
@@ -1,16 +1,15 @@
|
|
1
|
-
import { RestoreCommerceGrpcClient } from
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { GrpcClientConfig } from
|
8
|
-
import { Logger } from "winston";
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { ServiceClient as userClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/user';
|
3
|
+
import { ServiceClient as roleClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/role';
|
4
|
+
import { ServiceClient as authentication_logClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/authentication_log';
|
5
|
+
import { ServiceClient as tokenClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/token';
|
6
|
+
import { ServiceClient as oauthClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/oauth';
|
7
|
+
import { GrpcClientConfig } from '@restorecommerce/grpc-client';
|
9
8
|
export declare class IdentitySrvGrpcClient extends RestoreCommerceGrpcClient {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
readonly user: userClient;
|
10
|
+
readonly role: roleClient;
|
11
|
+
readonly authentication_log: authentication_logClient;
|
12
|
+
readonly token: tokenClient;
|
13
|
+
readonly oauth: oauthClient;
|
14
|
+
constructor(address: string, cfg: GrpcClientConfig);
|
16
15
|
}
|
@@ -7,15 +7,14 @@ const role_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/resto
|
|
7
7
|
const authentication_log_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/authentication_log");
|
8
8
|
const token_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/token");
|
9
9
|
const oauth_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/oauth");
|
10
|
-
const protos_1 = require("../../../gql/protos");
|
11
10
|
class IdentitySrvGrpcClient extends rc_grpc_clients_1.RestoreCommerceGrpcClient {
|
12
|
-
constructor(
|
13
|
-
super(
|
14
|
-
this.user =
|
15
|
-
this.role =
|
16
|
-
this.authentication_log =
|
17
|
-
this.token =
|
18
|
-
this.oauth =
|
11
|
+
constructor(address, cfg) {
|
12
|
+
super(address, cfg);
|
13
|
+
this.user = this.createClient(cfg, user_1.ServiceDefinition, this.channel);
|
14
|
+
this.role = this.createClient(cfg, role_1.ServiceDefinition, this.channel);
|
15
|
+
this.authentication_log = this.createClient(cfg, authentication_log_1.ServiceDefinition, this.channel);
|
16
|
+
this.token = this.createClient(cfg, token_1.ServiceDefinition, this.channel);
|
17
|
+
this.oauth = this.createClient(cfg, oauth_1.ServiceDefinition, this.channel);
|
19
18
|
}
|
20
19
|
}
|
21
20
|
exports.IdentitySrvGrpcClient = IdentitySrvGrpcClient;
|
@@ -9,7 +9,10 @@ const grpc_1 = require("./grpc");
|
|
9
9
|
const oauth_1 = require("./oauth/oauth");
|
10
10
|
const mount = eval('require("koa-mount")');
|
11
11
|
exports.identityModule = (0, utils_1.createFacadeModuleFactory)('identity', (facade, config) => {
|
12
|
-
const identitySrvClient = new grpc_1.IdentitySrvGrpcClient(config.
|
12
|
+
const identitySrvClient = new grpc_1.IdentitySrvGrpcClient(config.config.client.address, {
|
13
|
+
...config.config.client,
|
14
|
+
logger: facade.logger,
|
15
|
+
});
|
13
16
|
if (!!config.apiKey) {
|
14
17
|
const apiKey = (0, api_key_1.setupApiKey)({
|
15
18
|
logger: facade.logger,
|
@@ -36,7 +36,7 @@ const createOAuth = () => {
|
|
36
36
|
return next();
|
37
37
|
}
|
38
38
|
const ids = ctx.identitySrvClient;
|
39
|
-
const user = await ids.user.
|
39
|
+
const user = await ids.user.findByToken({
|
40
40
|
token: token
|
41
41
|
});
|
42
42
|
if (!user || !user.payload) {
|
@@ -50,7 +50,7 @@ const createOAuth = () => {
|
|
50
50
|
router.post('/oauth2-register', async (ctx, next) => {
|
51
51
|
const ids = ctx.identitySrvClient;
|
52
52
|
const body = ctx.request.body;
|
53
|
-
const user = await ids.user.
|
53
|
+
const user = await ids.user.register(user_1.RegisterRequest.fromPartial({
|
54
54
|
email: body.email,
|
55
55
|
name: body.username,
|
56
56
|
firstName: body.first_name,
|
@@ -74,7 +74,7 @@ const createOAuth = () => {
|
|
74
74
|
});
|
75
75
|
router.get('/oauth2/:service', async (ctx, next) => {
|
76
76
|
const ids = ctx.identitySrvClient;
|
77
|
-
const user = await ids.oauth.
|
77
|
+
const user = await ids.oauth.exchangeCode({
|
78
78
|
service: ctx.params.service,
|
79
79
|
code: ctx.request.query['code'],
|
80
80
|
state: ctx.request.query['state']
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { Logger } from 'winston';
|
2
2
|
import { Adapter, AdapterConstructor } from 'oidc-provider';
|
3
|
-
import {
|
3
|
+
import { ServiceClient as tokenService } from "@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/token";
|
4
4
|
export declare function createIdentityServiceAdapterClass(remoteTokenService: tokenService, logger: Logger, localTokenServiceFactory?: (type: string) => Adapter): AdapterConstructor;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Adapter, errors, Provider } from 'oidc-provider';
|
2
2
|
import { IdentityContext } from '../interfaces';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { ServiceClient as authLogService } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/authentication_log';
|
4
|
+
import { ServiceClient as tokenService } from "@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/token";
|
5
5
|
import { User } from "@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/user";
|
6
6
|
export interface OIDCHbsTemplates {
|
7
7
|
login?: string;
|
@@ -135,7 +135,7 @@ const registerPasswordGrantType = (config) => {
|
|
135
135
|
activity: 'login',
|
136
136
|
tokenName: token_name
|
137
137
|
});
|
138
|
-
await config.authLogService.
|
138
|
+
await config.authLogService.create(authentication_log_1.AuthenticationLogList.fromPartial({
|
139
139
|
items: [authLogItem],
|
140
140
|
subject: auth_1.Subject.fromPartial({ token, scope })
|
141
141
|
}));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { OIDCBodyLoginFn, AuthUser, OIDCLoginFn, OIDCBodyLoginCredentials } from './interfaces';
|
2
|
-
import {
|
2
|
+
import { ServiceClient as userService } from "@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/user";
|
3
3
|
export declare const loginUserBody: OIDCBodyLoginFn;
|
4
4
|
export declare const loginUserCredentials: OIDCBodyLoginCredentials;
|
5
5
|
export declare const loginUser: OIDCLoginFn;
|
@@ -67,7 +67,7 @@ const loginUser = async (ctx, identifier, password, remember) => {
|
|
67
67
|
};
|
68
68
|
exports.loginUser = loginUser;
|
69
69
|
async function findUserById(service, id) {
|
70
|
-
const result = await service.
|
70
|
+
const result = await service.find(user_1.FindRequest.fromPartial({
|
71
71
|
id,
|
72
72
|
}));
|
73
73
|
if (!(result === null || result === void 0 ? void 0 : result.items) || result.items.length === 0) {
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import { RestoreCommerceGrpcClient } from
|
2
|
-
import {
|
3
|
-
import { GrpcClientConfig } from
|
4
|
-
import { Logger } from "winston";
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { ServiceClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/search';
|
3
|
+
import { GrpcClientConfig } from '@restorecommerce/grpc-client';
|
5
4
|
export declare class IndexingSrvGrpcClient extends RestoreCommerceGrpcClient {
|
6
|
-
|
7
|
-
|
5
|
+
readonly search: ServiceClient;
|
6
|
+
constructor(address: string, cfg: GrpcClientConfig);
|
8
7
|
}
|
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IndexingSrvGrpcClient = void 0;
|
4
4
|
const rc_grpc_clients_1 = require("@restorecommerce/rc-grpc-clients");
|
5
5
|
const search_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/search");
|
6
|
-
const protos_1 = require("../../../gql/protos");
|
7
6
|
class IndexingSrvGrpcClient extends rc_grpc_clients_1.RestoreCommerceGrpcClient {
|
8
|
-
constructor(
|
9
|
-
super(
|
10
|
-
this.search =
|
7
|
+
constructor(address, cfg) {
|
8
|
+
super(address, cfg);
|
9
|
+
this.search = this.createClient(cfg, search_1.ServiceDefinition, this.channel);
|
11
10
|
}
|
12
11
|
}
|
13
12
|
exports.IndexingSrvGrpcClient = IndexingSrvGrpcClient;
|
@@ -7,7 +7,10 @@ const grpc_1 = require("./grpc");
|
|
7
7
|
const utils_1 = require("../../utils");
|
8
8
|
exports.indexingModule = (0, utils_1.createFacadeModuleFactory)(interfaces_1.namespace, (facade, config) => {
|
9
9
|
const indexing = {
|
10
|
-
client: new grpc_1.IndexingSrvGrpcClient(config.config.client,
|
10
|
+
client: new grpc_1.IndexingSrvGrpcClient(config.config.client.address, {
|
11
|
+
...config.config.client,
|
12
|
+
logger: facade.logger,
|
13
|
+
})
|
11
14
|
};
|
12
15
|
facade.addApolloService({
|
13
16
|
name: interfaces_1.namespace,
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import { RestoreCommerceGrpcClient } from
|
2
|
-
import {
|
3
|
-
import { GrpcClientConfig } from
|
4
|
-
import { Logger } from "winston";
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { ServiceClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/invoice';
|
3
|
+
import { GrpcClientConfig } from '@restorecommerce/grpc-client';
|
5
4
|
export declare class InvoicingSrvGrpcClient extends RestoreCommerceGrpcClient {
|
6
|
-
|
7
|
-
|
5
|
+
readonly invoice: ServiceClient;
|
6
|
+
constructor(address: string, cfg: GrpcClientConfig);
|
8
7
|
}
|
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InvoicingSrvGrpcClient = void 0;
|
4
4
|
const rc_grpc_clients_1 = require("@restorecommerce/rc-grpc-clients");
|
5
5
|
const invoice_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/invoice");
|
6
|
-
const protos_1 = require("../../../gql/protos");
|
7
6
|
class InvoicingSrvGrpcClient extends rc_grpc_clients_1.RestoreCommerceGrpcClient {
|
8
|
-
constructor(
|
9
|
-
super(
|
10
|
-
this.invoice =
|
7
|
+
constructor(address, cfg) {
|
8
|
+
super(address, cfg);
|
9
|
+
this.invoice = this.createClient(cfg, invoice_1.ServiceDefinition, this.channel);
|
11
10
|
}
|
12
11
|
}
|
13
12
|
exports.InvoicingSrvGrpcClient = InvoicingSrvGrpcClient;
|
@@ -7,7 +7,10 @@ const grpc_1 = require("./grpc");
|
|
7
7
|
const utils_1 = require("../../utils");
|
8
8
|
exports.invoicingModule = (0, utils_1.createFacadeModuleFactory)(interfaces_1.namespace, (facade, config) => {
|
9
9
|
const invoicing = {
|
10
|
-
client: new grpc_1.InvoicingSrvGrpcClient(config.config.client,
|
10
|
+
client: new grpc_1.InvoicingSrvGrpcClient(config.config.client.address, {
|
11
|
+
...config.config.client,
|
12
|
+
logger: facade.logger,
|
13
|
+
})
|
11
14
|
};
|
12
15
|
facade.addApolloService({
|
13
16
|
name: interfaces_1.namespace,
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import { RestoreCommerceGrpcClient } from
|
2
|
-
import {
|
3
|
-
import { GrpcClientConfig } from
|
4
|
-
import { Logger } from "winston";
|
1
|
+
import { RestoreCommerceGrpcClient } from '@restorecommerce/rc-grpc-clients';
|
2
|
+
import { ServiceClient } from '@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/notification';
|
3
|
+
import { GrpcClientConfig } from '@restorecommerce/grpc-client';
|
5
4
|
export declare class NotificationSrvGrpcClient extends RestoreCommerceGrpcClient {
|
6
|
-
|
7
|
-
|
5
|
+
readonly service: ServiceClient;
|
6
|
+
constructor(address: string, cfg: GrpcClientConfig);
|
8
7
|
}
|
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationSrvGrpcClient = void 0;
|
4
4
|
const rc_grpc_clients_1 = require("@restorecommerce/rc-grpc-clients");
|
5
5
|
const notification_1 = require("@restorecommerce/rc-grpc-clients/dist/generated/io/restorecommerce/notification");
|
6
|
-
const protos_1 = require("../../../gql/protos");
|
7
6
|
class NotificationSrvGrpcClient extends rc_grpc_clients_1.RestoreCommerceGrpcClient {
|
8
|
-
constructor(
|
9
|
-
super(
|
10
|
-
this.service =
|
7
|
+
constructor(address, cfg) {
|
8
|
+
super(address, cfg);
|
9
|
+
this.service = this.createClient(cfg, notification_1.ServiceDefinition, this.channel);
|
11
10
|
}
|
12
11
|
}
|
13
12
|
exports.NotificationSrvGrpcClient = NotificationSrvGrpcClient;
|
@@ -7,7 +7,10 @@ const grpc_1 = require("./grpc");
|
|
7
7
|
const utils_1 = require("../../utils");
|
8
8
|
exports.notificationModule = (0, utils_1.createFacadeModuleFactory)(interfaces_1.namespace, (facade, config) => {
|
9
9
|
const notification = {
|
10
|
-
client: new grpc_1.NotificationSrvGrpcClient(config.config.client,
|
10
|
+
client: new grpc_1.NotificationSrvGrpcClient(config.config.client.address, {
|
11
|
+
...config.config.client,
|
12
|
+
logger: facade.logger,
|
13
|
+
})
|
11
14
|
};
|
12
15
|
facade.addApolloService({
|
13
16
|
name: interfaces_1.namespace,
|