@paybuy/config-client 0.0.0-stage → 1.2.57
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/.eslintrc.js +52 -0
- package/.gitlab-ci.yml +29 -0
- package/.prettierrc +6 -0
- package/dist/decorator/index.d.ts +1 -0
- package/dist/decorator/index.js +18 -0
- package/dist/decorator/index.js.map +1 -0
- package/dist/decorator/inject-dynamic-config.decorator.d.ts +1 -0
- package/dist/decorator/inject-dynamic-config.decorator.js +10 -0
- package/dist/decorator/inject-dynamic-config.decorator.js.map +1 -0
- package/dist/dynamic-config/constants/dynamic-config-client-key.constants.d.ts +4 -0
- package/dist/dynamic-config/constants/dynamic-config-client-key.constants.js +8 -0
- package/dist/dynamic-config/constants/dynamic-config-client-key.constants.js.map +1 -0
- package/dist/dynamic-config/decorator/dynamic-config.decorator.d.ts +7 -0
- package/dist/dynamic-config/decorator/dynamic-config.decorator.js +16 -0
- package/dist/dynamic-config/decorator/dynamic-config.decorator.js.map +1 -0
- package/dist/dynamic-config/decorator/index.d.ts +1 -0
- package/dist/dynamic-config/decorator/index.js +18 -0
- package/dist/dynamic-config/decorator/index.js.map +1 -0
- package/dist/dynamic-config/dynamic-config.module.d.ts +7 -0
- package/dist/dynamic-config/dynamic-config.module.js +92 -0
- package/dist/dynamic-config/dynamic-config.module.js.map +1 -0
- package/dist/dynamic-config/enum/dynamic-config-meta-data.enum.d.ts +8 -0
- package/dist/dynamic-config/enum/dynamic-config-meta-data.enum.js +12 -0
- package/dist/dynamic-config/enum/dynamic-config-meta-data.enum.js.map +1 -0
- package/dist/dynamic-config/index.d.ts +3 -0
- package/dist/dynamic-config/index.js +20 -0
- package/dist/dynamic-config/index.js.map +1 -0
- package/dist/dynamic-config/model/dynamic-config-model.d.ts +11 -0
- package/dist/dynamic-config/model/dynamic-config-model.js +70 -0
- package/dist/dynamic-config/model/dynamic-config-model.js.map +1 -0
- package/dist/dynamic-config/model/index.d.ts +1 -0
- package/dist/dynamic-config/model/index.js +18 -0
- package/dist/dynamic-config/model/index.js.map +1 -0
- package/dist/dynamic-config/provider/dynamic-config.provider.d.ts +4 -0
- package/dist/dynamic-config/provider/dynamic-config.provider.js +37 -0
- package/dist/dynamic-config/provider/dynamic-config.provider.js.map +1 -0
- package/dist/dynamic-config/service/dynamic-config-cache.service.d.ts +16 -0
- package/dist/dynamic-config/service/dynamic-config-cache.service.js +50 -0
- package/dist/dynamic-config/service/dynamic-config-cache.service.js.map +1 -0
- package/dist/dynamic-config/service/dynamic-config.service.d.ts +8 -0
- package/dist/dynamic-config/service/dynamic-config.service.js +37 -0
- package/dist/dynamic-config/service/dynamic-config.service.js.map +1 -0
- package/dist/dynamic-config/types/dynamic-config.type.d.ts +3 -0
- package/dist/dynamic-config/types/dynamic-config.type.js +3 -0
- package/dist/dynamic-config/types/dynamic-config.type.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/crud_request.d.ts +18 -0
- package/dist/types/crud_request.js +6 -0
- package/dist/types/crud_request.js.map +1 -0
- package/dist/types/dynamic-config/dynamic-config.d.ts +44 -0
- package/dist/types/dynamic-config/dynamic-config.js +6 -0
- package/dist/types/dynamic-config/dynamic-config.js.map +1 -0
- package/dist/types/filter_option.d.ts +30 -0
- package/dist/types/filter_option.js +30 -0
- package/dist/types/filter_option.js.map +1 -0
- package/dist/types/google/protobuf/any.d.ts +6 -0
- package/dist/types/google/protobuf/any.js +6 -0
- package/dist/types/google/protobuf/any.js.map +1 -0
- package/dist/types/google/protobuf/struct.d.ts +28 -0
- package/dist/types/google/protobuf/struct.js +11 -0
- package/dist/types/google/protobuf/struct.js.map +1 -0
- package/dist/types/owner.d.ts +5 -0
- package/dist/types/owner.js +6 -0
- package/dist/types/owner.js.map +1 -0
- package/dist/types/paybuy-config.d.ts +26 -0
- package/dist/types/paybuy-config.js +31 -0
- package/dist/types/paybuy-config.js.map +1 -0
- package/dist/types/paybuy-health-check.d.ts +15 -0
- package/dist/types/paybuy-health-check.js +12 -0
- package/dist/types/paybuy-health-check.js.map +1 -0
- package/package.json +54 -4
- package/proto/dynamic-config/dynamic-config.proto +52 -0
- package/proto/paybuy-config.proto +17 -0
- package/proto/paybuy-health-check.proto +19 -0
- package/src/decorator/index.ts +1 -0
- package/src/decorator/inject-dynamic-config.decorator.ts +10 -0
- package/src/dynamic-config/constants/dynamic-config-client-key.constants.ts +5 -0
- package/src/dynamic-config/decorator/dynamic-config.decorator.ts +45 -0
- package/src/dynamic-config/decorator/index.ts +1 -0
- package/src/dynamic-config/dynamic-config.module.ts +109 -0
- package/src/dynamic-config/enum/dynamic-config-meta-data.enum.ts +8 -0
- package/src/dynamic-config/index.ts +3 -0
- package/src/dynamic-config/model/dynamic-config-model.ts +96 -0
- package/src/dynamic-config/model/index.ts +1 -0
- package/src/dynamic-config/provider/dynamic-config.provider.ts +53 -0
- package/src/dynamic-config/service/dynamic-config-cache.service.ts +64 -0
- package/src/dynamic-config/types/dynamic-config.type.ts +1 -0
- package/src/index.ts +2 -0
- package/src/types/crud_request.ts +24 -0
- package/src/types/dynamic-config/dynamic-config.ts +54 -0
- package/src/types/filter_option.ts +35 -0
- package/src/types/google/protobuf/any.ts +123 -0
- package/src/types/google/protobuf/struct.ts +70 -0
- package/src/types/owner.ts +9 -0
- package/src/types/paybuy-config.ts +119 -0
- package/src/types/paybuy-health-check.ts +22 -0
- package/test/dyanimc-config-client.unit.spec.ts +57 -0
- package/test/jest.json +32 -0
- package/test/mock/grpc-client-service.mock.ts +48 -0
- package/test/test-client.ts +27 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +17 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud_request.js","sourceRoot":"","sources":["../../src/types/crud_request.ts"],"names":[],"mappings":";;;AAIa,QAAA,eAAe,GAAG,eAAe,CAAC;AAmBlC,QAAA,0BAA0B,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Owner } from '../owner';
|
|
2
|
+
export declare const protobufPackage = "paybuy.config.dynamicConfig";
|
|
3
|
+
export interface DynamicConfig {
|
|
4
|
+
id: string;
|
|
5
|
+
owner: Owner | undefined;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
updatedAt: string;
|
|
8
|
+
deletedAt: string;
|
|
9
|
+
updatedBy: Owner | undefined;
|
|
10
|
+
deletedBy: Owner | undefined;
|
|
11
|
+
isDeleted: boolean;
|
|
12
|
+
type: string;
|
|
13
|
+
key: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
export interface DynamicConfigPaginationResponse {
|
|
17
|
+
limit: number;
|
|
18
|
+
page: number;
|
|
19
|
+
sortBy: string[];
|
|
20
|
+
items: DynamicConfig[];
|
|
21
|
+
itemCount: number;
|
|
22
|
+
pageCount?: number | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface GetRawDynamicConfigRequest {
|
|
25
|
+
key: string;
|
|
26
|
+
type: string;
|
|
27
|
+
}
|
|
28
|
+
export interface GetRawDynamicConfigResponse {
|
|
29
|
+
result: string;
|
|
30
|
+
}
|
|
31
|
+
export interface CreateDynamicConfigRequest {
|
|
32
|
+
owner: Owner | undefined;
|
|
33
|
+
type: string;
|
|
34
|
+
key: string;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
export interface UpdateDynamicConfigRequest {
|
|
38
|
+
id: string;
|
|
39
|
+
type?: string | undefined;
|
|
40
|
+
key?: string | undefined;
|
|
41
|
+
value?: string | undefined;
|
|
42
|
+
updatedBy: Owner | undefined;
|
|
43
|
+
}
|
|
44
|
+
export declare const PAYBUY_CONFIG_DYNAMIC_CONFIG_PACKAGE_NAME = "paybuy.config.dynamicConfig";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAYBUY_CONFIG_DYNAMIC_CONFIG_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
4
|
+
exports.protobufPackage = 'paybuy.config.dynamicConfig';
|
|
5
|
+
exports.PAYBUY_CONFIG_DYNAMIC_CONFIG_PACKAGE_NAME = 'paybuy.config.dynamicConfig';
|
|
6
|
+
//# sourceMappingURL=dynamic-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-config.js","sourceRoot":"","sources":["../../../src/types/dynamic-config/dynamic-config.ts"],"names":[],"mappings":";;;AAGa,QAAA,eAAe,GAAG,6BAA6B,CAAC;AAiDhD,QAAA,yCAAyC,GACpD,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const protobufPackage = "paybuy.common";
|
|
2
|
+
export declare enum FilterOperation {
|
|
3
|
+
FILTER_OPERATION_IN = "FILTER_OPERATION_IN",
|
|
4
|
+
FILTER_OPERATION_NOT_IN = "FILTER_OPERATION_NOT_IN",
|
|
5
|
+
FILTER_OPERATION_BETWEEN = "FILTER_OPERATION_BETWEEN",
|
|
6
|
+
FILTER_OPERATION_NOT_BETWEEN = "FILTER_OPERATION_NOT_BETWEEN",
|
|
7
|
+
FILTER_OPERATION_EQ = "FILTER_OPERATION_EQ",
|
|
8
|
+
FILTER_OPERATION_GT = "FILTER_OPERATION_GT",
|
|
9
|
+
FILTER_OPERATION_GTE = "FILTER_OPERATION_GTE",
|
|
10
|
+
FILTER_OPERATION_LT = "FILTER_OPERATION_LT",
|
|
11
|
+
FILTER_OPERATION_LTE = "FILTER_OPERATION_LTE",
|
|
12
|
+
FILTER_OPERATION_NE = "FILTER_OPERATION_NE",
|
|
13
|
+
FILTER_OPERATION_LIKE = "FILTER_OPERATION_LIKE",
|
|
14
|
+
FILTER_OPERATION_ILIKE = "FILTER_OPERATION_ILIKE",
|
|
15
|
+
FILTER_OPERATION_IREGEXP = "FILTER_OPERATION_IREGEXP",
|
|
16
|
+
FILTER_OPERATION_NOT_ILIKE = "FILTER_OPERATION_NOT_ILIKE",
|
|
17
|
+
FILTER_OPERATION_NOT_IREGEXP = "FILTER_OPERATION_NOT_IREGEXP",
|
|
18
|
+
FILTER_OPERATION_NOT_LIKE = "FILTER_OPERATION_NOT_LIKE",
|
|
19
|
+
FILTER_OPERATION_REGEXP = "FILTER_OPERATION_REGEXP",
|
|
20
|
+
FILTER_OPERATION_NOT_REGEXP = "FILTER_OPERATION_NOT_REGEXP",
|
|
21
|
+
FILTER_OPERATION_IS = "FILTER_OPERATION_IS",
|
|
22
|
+
FILTER_OPERATION_NOT = "FILTER_OPERATION_NOT",
|
|
23
|
+
FILTER_OPERATION_ELM_MTC = "FILTER_OPERATION_ELM_MTC"
|
|
24
|
+
}
|
|
25
|
+
export interface FilterOption {
|
|
26
|
+
field: string;
|
|
27
|
+
operation: FilterOperation;
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const PAYBUY_COMMON_PACKAGE_NAME = "paybuy.common";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAYBUY_COMMON_PACKAGE_NAME = exports.FilterOperation = exports.protobufPackage = void 0;
|
|
4
|
+
exports.protobufPackage = 'paybuy.common';
|
|
5
|
+
var FilterOperation;
|
|
6
|
+
(function (FilterOperation) {
|
|
7
|
+
FilterOperation["FILTER_OPERATION_IN"] = "FILTER_OPERATION_IN";
|
|
8
|
+
FilterOperation["FILTER_OPERATION_NOT_IN"] = "FILTER_OPERATION_NOT_IN";
|
|
9
|
+
FilterOperation["FILTER_OPERATION_BETWEEN"] = "FILTER_OPERATION_BETWEEN";
|
|
10
|
+
FilterOperation["FILTER_OPERATION_NOT_BETWEEN"] = "FILTER_OPERATION_NOT_BETWEEN";
|
|
11
|
+
FilterOperation["FILTER_OPERATION_EQ"] = "FILTER_OPERATION_EQ";
|
|
12
|
+
FilterOperation["FILTER_OPERATION_GT"] = "FILTER_OPERATION_GT";
|
|
13
|
+
FilterOperation["FILTER_OPERATION_GTE"] = "FILTER_OPERATION_GTE";
|
|
14
|
+
FilterOperation["FILTER_OPERATION_LT"] = "FILTER_OPERATION_LT";
|
|
15
|
+
FilterOperation["FILTER_OPERATION_LTE"] = "FILTER_OPERATION_LTE";
|
|
16
|
+
FilterOperation["FILTER_OPERATION_NE"] = "FILTER_OPERATION_NE";
|
|
17
|
+
FilterOperation["FILTER_OPERATION_LIKE"] = "FILTER_OPERATION_LIKE";
|
|
18
|
+
FilterOperation["FILTER_OPERATION_ILIKE"] = "FILTER_OPERATION_ILIKE";
|
|
19
|
+
FilterOperation["FILTER_OPERATION_IREGEXP"] = "FILTER_OPERATION_IREGEXP";
|
|
20
|
+
FilterOperation["FILTER_OPERATION_NOT_ILIKE"] = "FILTER_OPERATION_NOT_ILIKE";
|
|
21
|
+
FilterOperation["FILTER_OPERATION_NOT_IREGEXP"] = "FILTER_OPERATION_NOT_IREGEXP";
|
|
22
|
+
FilterOperation["FILTER_OPERATION_NOT_LIKE"] = "FILTER_OPERATION_NOT_LIKE";
|
|
23
|
+
FilterOperation["FILTER_OPERATION_REGEXP"] = "FILTER_OPERATION_REGEXP";
|
|
24
|
+
FilterOperation["FILTER_OPERATION_NOT_REGEXP"] = "FILTER_OPERATION_NOT_REGEXP";
|
|
25
|
+
FilterOperation["FILTER_OPERATION_IS"] = "FILTER_OPERATION_IS";
|
|
26
|
+
FilterOperation["FILTER_OPERATION_NOT"] = "FILTER_OPERATION_NOT";
|
|
27
|
+
FilterOperation["FILTER_OPERATION_ELM_MTC"] = "FILTER_OPERATION_ELM_MTC";
|
|
28
|
+
})(FilterOperation = exports.FilterOperation || (exports.FilterOperation = {}));
|
|
29
|
+
exports.PAYBUY_COMMON_PACKAGE_NAME = 'paybuy.common';
|
|
30
|
+
//# sourceMappingURL=filter_option.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter_option.js","sourceRoot":"","sources":["../../src/types/filter_option.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,eAAe,CAAC;AAE/C,IAAY,eAsBX;AAtBD,WAAY,eAAe;IACzB,8DAA2C,CAAA;IAC3C,sEAAmD,CAAA;IACnD,wEAAqD,CAAA;IACrD,gFAA6D,CAAA;IAC7D,8DAA2C,CAAA;IAC3C,8DAA2C,CAAA;IAC3C,gEAA6C,CAAA;IAC7C,8DAA2C,CAAA;IAC3C,gEAA6C,CAAA;IAC7C,8DAA2C,CAAA;IAC3C,kEAA+C,CAAA;IAC/C,oEAAiD,CAAA;IACjD,wEAAqD,CAAA;IACrD,4EAAyD,CAAA;IACzD,gFAA6D,CAAA;IAC7D,0EAAuD,CAAA;IACvD,sEAAmD,CAAA;IACnD,8EAA2D,CAAA;IAC3D,8DAA2C,CAAA;IAC3C,gEAA6C,CAAA;IAC7C,wEAAqD,CAAA;AACvD,CAAC,EAtBW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAsB1B;AAQY,QAAA,0BAA0B,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GOOGLE_PROTOBUF_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
4
|
+
exports.protobufPackage = 'google.protobuf';
|
|
5
|
+
exports.GOOGLE_PROTOBUF_PACKAGE_NAME = 'google.protobuf';
|
|
6
|
+
//# sourceMappingURL=any.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"any.js","sourceRoot":"","sources":["../../../../src/types/google/protobuf/any.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAwHpC,QAAA,4BAA4B,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const protobufPackage = "google.protobuf";
|
|
2
|
+
export declare enum NullValue {
|
|
3
|
+
NULL_VALUE = "NULL_VALUE",
|
|
4
|
+
UNRECOGNIZED = "UNRECOGNIZED"
|
|
5
|
+
}
|
|
6
|
+
export interface Struct {
|
|
7
|
+
fields: {
|
|
8
|
+
[key: string]: any | undefined;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface Struct_FieldsEntry {
|
|
12
|
+
key: string;
|
|
13
|
+
value: any | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface Value {
|
|
16
|
+
nullValue?: NullValue | undefined;
|
|
17
|
+
numberValue?: number | undefined;
|
|
18
|
+
stringValue?: string | undefined;
|
|
19
|
+
boolValue?: boolean | undefined;
|
|
20
|
+
structValue?: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
} | undefined;
|
|
23
|
+
listValue?: Array<any> | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface ListValue {
|
|
26
|
+
values: any[];
|
|
27
|
+
}
|
|
28
|
+
export declare const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GOOGLE_PROTOBUF_PACKAGE_NAME = exports.NullValue = exports.protobufPackage = void 0;
|
|
4
|
+
exports.protobufPackage = 'google.protobuf';
|
|
5
|
+
var NullValue;
|
|
6
|
+
(function (NullValue) {
|
|
7
|
+
NullValue["NULL_VALUE"] = "NULL_VALUE";
|
|
8
|
+
NullValue["UNRECOGNIZED"] = "UNRECOGNIZED";
|
|
9
|
+
})(NullValue = exports.NullValue || (exports.NullValue = {}));
|
|
10
|
+
exports.GOOGLE_PROTOBUF_PACKAGE_NAME = 'google.protobuf';
|
|
11
|
+
//# sourceMappingURL=struct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../../src/types/google/protobuf/struct.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAQjD,IAAY,SAIX;AAJD,WAAY,SAAS;IAEnB,sCAAyB,CAAA;IACzB,0CAA6B,CAAA;AAC/B,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB;AAuDY,QAAA,4BAA4B,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAYBUY_COMMON_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
4
|
+
exports.protobufPackage = 'paybuy.common';
|
|
5
|
+
exports.PAYBUY_COMMON_PACKAGE_NAME = 'paybuy.common';
|
|
6
|
+
//# sourceMappingURL=owner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner.js","sourceRoot":"","sources":["../../src/types/owner.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,eAAe,CAAC;AAMlC,QAAA,0BAA0B,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { DeleteEntityById, FindEntityById, FindEntityPagination } from './crud_request';
|
|
3
|
+
import { CreateDynamicConfigRequest, DynamicConfig, DynamicConfigPaginationResponse, GetRawDynamicConfigRequest, GetRawDynamicConfigResponse, UpdateDynamicConfigRequest } from './dynamic-config/dynamic-config';
|
|
4
|
+
import { HealthCheckEmpty, HealthCheckResponse } from './paybuy-health-check';
|
|
5
|
+
export declare const protobufPackage = "paybuy.config";
|
|
6
|
+
export declare const PAYBUY_CONFIG_PACKAGE_NAME = "paybuy.config";
|
|
7
|
+
export interface DynamicConfigServiceClient {
|
|
8
|
+
findPaginate(request: FindEntityPagination): Observable<DynamicConfigPaginationResponse>;
|
|
9
|
+
findById(request: FindEntityById): Observable<DynamicConfig>;
|
|
10
|
+
getRaw(request: GetRawDynamicConfigRequest): Observable<GetRawDynamicConfigResponse>;
|
|
11
|
+
create(request: CreateDynamicConfigRequest): Observable<DynamicConfig>;
|
|
12
|
+
delete(request: DeleteEntityById): Observable<DynamicConfig>;
|
|
13
|
+
update(request: UpdateDynamicConfigRequest): Observable<DynamicConfig>;
|
|
14
|
+
healthCheck(request: HealthCheckEmpty): Observable<HealthCheckResponse>;
|
|
15
|
+
}
|
|
16
|
+
export interface DynamicConfigServiceController {
|
|
17
|
+
findPaginate(request: FindEntityPagination): Promise<DynamicConfigPaginationResponse> | Observable<DynamicConfigPaginationResponse> | DynamicConfigPaginationResponse;
|
|
18
|
+
findById(request: FindEntityById): Promise<DynamicConfig> | Observable<DynamicConfig> | DynamicConfig;
|
|
19
|
+
getRaw(request: GetRawDynamicConfigRequest): Promise<GetRawDynamicConfigResponse> | Observable<GetRawDynamicConfigResponse> | GetRawDynamicConfigResponse;
|
|
20
|
+
create(request: CreateDynamicConfigRequest): Promise<DynamicConfig> | Observable<DynamicConfig> | DynamicConfig;
|
|
21
|
+
delete(request: DeleteEntityById): Promise<DynamicConfig> | Observable<DynamicConfig> | DynamicConfig;
|
|
22
|
+
update(request: UpdateDynamicConfigRequest): Promise<DynamicConfig> | Observable<DynamicConfig> | DynamicConfig;
|
|
23
|
+
healthCheck(request: HealthCheckEmpty): Promise<HealthCheckResponse> | Observable<HealthCheckResponse> | HealthCheckResponse;
|
|
24
|
+
}
|
|
25
|
+
export declare function DynamicConfigServiceControllerMethods(): (constructor: Function) => void;
|
|
26
|
+
export declare const DYNAMIC_CONFIG_SERVICE_NAME = "DynamicConfigService";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DYNAMIC_CONFIG_SERVICE_NAME = exports.DynamicConfigServiceControllerMethods = exports.PAYBUY_CONFIG_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
4
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
5
|
+
exports.protobufPackage = 'paybuy.config';
|
|
6
|
+
exports.PAYBUY_CONFIG_PACKAGE_NAME = 'paybuy.config';
|
|
7
|
+
function DynamicConfigServiceControllerMethods() {
|
|
8
|
+
return function (constructor) {
|
|
9
|
+
const grpcMethods = [
|
|
10
|
+
'findPaginate',
|
|
11
|
+
'findById',
|
|
12
|
+
'getRaw',
|
|
13
|
+
'create',
|
|
14
|
+
'delete',
|
|
15
|
+
'update',
|
|
16
|
+
'healthCheck',
|
|
17
|
+
];
|
|
18
|
+
for (const method of grpcMethods) {
|
|
19
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
20
|
+
(0, microservices_1.GrpcMethod)('DynamicConfigService', method)(constructor.prototype[method], method, descriptor);
|
|
21
|
+
}
|
|
22
|
+
const grpcStreamMethods = [];
|
|
23
|
+
for (const method of grpcStreamMethods) {
|
|
24
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
25
|
+
(0, microservices_1.GrpcStreamMethod)('DynamicConfigService', method)(constructor.prototype[method], method, descriptor);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.DynamicConfigServiceControllerMethods = DynamicConfigServiceControllerMethods;
|
|
30
|
+
exports.DYNAMIC_CONFIG_SERVICE_NAME = 'DynamicConfigService';
|
|
31
|
+
//# sourceMappingURL=paybuy-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paybuy-config.js","sourceRoot":"","sources":["../../src/types/paybuy-config.ts"],"names":[],"mappings":";;;AACA,yDAAqE;AAiBxD,QAAA,eAAe,GAAG,eAAe,CAAC;AAElC,QAAA,0BAA0B,GAAG,eAAe,CAAC;AA6D1D,SAAgB,qCAAqC;IACnD,OAAO,UAAU,WAAqB;QACpC,MAAM,WAAW,GAAa;YAC5B,cAAc;YACd,UAAU;YACV,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,aAAa;SACd,CAAC;QACF,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;YAChC,MAAM,UAAU,GAAQ,OAAO,CAAC,wBAAwB,CACtD,WAAW,CAAC,SAAS,EACrB,MAAM,CACP,CAAC;YACF,IAAA,0BAAU,EAAC,sBAAsB,EAAE,MAAM,CAAC,CACxC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAC7B,MAAM,EACN,UAAU,CACX,CAAC;SACH;QACD,MAAM,iBAAiB,GAAa,EAAE,CAAC;QACvC,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE;YACtC,MAAM,UAAU,GAAQ,OAAO,CAAC,wBAAwB,CACtD,WAAW,CAAC,SAAS,EACrB,MAAM,CACP,CAAC;YACF,IAAA,gCAAgB,EAAC,sBAAsB,EAAE,MAAM,CAAC,CAC9C,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAC7B,MAAM,EACN,UAAU,CACX,CAAC;SACH;IACH,CAAC,CAAC;AACJ,CAAC;AAnCD,sFAmCC;AAEY,QAAA,2BAA2B,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const protobufPackage = "paybuy.healthCheck";
|
|
2
|
+
export declare enum HealthCheckStatus {
|
|
3
|
+
HEALTH_CHECK_STATUS_ERROR = "HEALTH_CHECK_STATUS_ERROR",
|
|
4
|
+
HEALTH_CHECK_STATUS_OK = "HEALTH_CHECK_STATUS_OK",
|
|
5
|
+
HEALTH_CHECK_STATUS_SHUTTING_DOWN = "HEALTH_CHECK_STATUS_SHUTTING_DOWN"
|
|
6
|
+
}
|
|
7
|
+
export interface HealthCheckResponse {
|
|
8
|
+
status: HealthCheckStatus;
|
|
9
|
+
info: string;
|
|
10
|
+
error: string;
|
|
11
|
+
details: string;
|
|
12
|
+
}
|
|
13
|
+
export interface HealthCheckEmpty {
|
|
14
|
+
}
|
|
15
|
+
export declare const PAYBUY_HEALTH_CHECK_PACKAGE_NAME = "paybuy.healthCheck";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAYBUY_HEALTH_CHECK_PACKAGE_NAME = exports.HealthCheckStatus = exports.protobufPackage = void 0;
|
|
4
|
+
exports.protobufPackage = 'paybuy.healthCheck';
|
|
5
|
+
var HealthCheckStatus;
|
|
6
|
+
(function (HealthCheckStatus) {
|
|
7
|
+
HealthCheckStatus["HEALTH_CHECK_STATUS_ERROR"] = "HEALTH_CHECK_STATUS_ERROR";
|
|
8
|
+
HealthCheckStatus["HEALTH_CHECK_STATUS_OK"] = "HEALTH_CHECK_STATUS_OK";
|
|
9
|
+
HealthCheckStatus["HEALTH_CHECK_STATUS_SHUTTING_DOWN"] = "HEALTH_CHECK_STATUS_SHUTTING_DOWN";
|
|
10
|
+
})(HealthCheckStatus = exports.HealthCheckStatus || (exports.HealthCheckStatus = {}));
|
|
11
|
+
exports.PAYBUY_HEALTH_CHECK_PACKAGE_NAME = 'paybuy.healthCheck';
|
|
12
|
+
//# sourceMappingURL=paybuy-health-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paybuy-health-check.js","sourceRoot":"","sources":["../../src/types/paybuy-health-check.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,oBAAoB,CAAC;AAGpD,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,4FAAuE,CAAA;AACzE,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAYY,QAAA,gCAAgC,GAAG,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paybuy/config-client",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.2.57",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"author": "",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.build.json",
|
|
11
|
+
"version": "git add -A src",
|
|
12
|
+
"postversion": "git push && git push --tags",
|
|
13
|
+
"test": "jest --config ./test/jest.json --logHeapUsage",
|
|
14
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
15
|
+
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
16
|
+
"g:proto": "npx protoc --proto_path=proto --proto_path=node_modules/@paybuy/common/proto --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/types ./proto/paybuy-config.proto --ts_proto_opt=stringEnums=true --ts_proto_opt=nestJs=true --ts_proto_opt=useDate=string --ts_proto_opt=usePrototypeForDefaults=false --ts_proto_opt=unrecognizedEnum=false"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@nestjs/common": "^10.0.0",
|
|
20
|
+
"@nestjs/core": "^10.0.0",
|
|
21
|
+
"@nestjs/microservices": "^10.1.3",
|
|
22
|
+
"class-transformer": "0.5.1-prod",
|
|
23
|
+
"class-validator": "^0.13.2",
|
|
24
|
+
"memoizee": "^0.4.15",
|
|
25
|
+
"reflect-metadata": "^0.1.13",
|
|
26
|
+
"rxjs": "^7.8.1"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@nestjs/cli": "^10.0.0",
|
|
30
|
+
"@nestjs/platform-express": "^10.3.2",
|
|
31
|
+
"@nestjs/schematics": "^10.0.0",
|
|
32
|
+
"@nestjs/testing": "^10.0.0",
|
|
33
|
+
"@paybuy/common": "^1.1.13",
|
|
34
|
+
"@types/express": "^4.17.17",
|
|
35
|
+
"@types/jest": "^29.5.11",
|
|
36
|
+
"@types/js-yaml": "^4.0.5",
|
|
37
|
+
"@types/memoizee": "^0.4.8",
|
|
38
|
+
"@types/node": "^20.3.1",
|
|
39
|
+
"@types/supertest": "^2.0.12",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^6.2.1",
|
|
41
|
+
"@typescript-eslint/parser": "^6.2.1",
|
|
42
|
+
"eslint": "^8.42.0",
|
|
43
|
+
"eslint-config-prettier": "^8.8.0",
|
|
44
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
45
|
+
"jest": "^29.7.0",
|
|
46
|
+
"prettier": "^2.8.8",
|
|
47
|
+
"source-map-support": "^0.5.21",
|
|
48
|
+
"supertest": "^6.3.3",
|
|
49
|
+
"ts-jest": "^29.1.1",
|
|
50
|
+
"ts-loader": "^9.4.3",
|
|
51
|
+
"ts-node": "^10.9.1",
|
|
52
|
+
"ts-proto": "^1.166.2",
|
|
53
|
+
"tsconfig-paths": "^4.2.0",
|
|
54
|
+
"typescript": "^5.3.3"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package paybuy.config.dynamicConfig;
|
|
4
|
+
|
|
5
|
+
import "owner.proto";
|
|
6
|
+
|
|
7
|
+
message DynamicConfig {
|
|
8
|
+
string id = 1;
|
|
9
|
+
paybuy.common.Owner owner = 3;
|
|
10
|
+
string createdAt = 4;
|
|
11
|
+
string updatedAt = 5;
|
|
12
|
+
string deletedAt = 6;
|
|
13
|
+
paybuy.common.Owner updatedBy = 2;
|
|
14
|
+
paybuy.common.Owner deletedBy = 7;
|
|
15
|
+
bool isDeleted=9;
|
|
16
|
+
string type = 10;
|
|
17
|
+
string key = 11;
|
|
18
|
+
string value = 12;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
message DynamicConfigPaginationResponse {
|
|
22
|
+
int32 limit = 1;
|
|
23
|
+
int32 page = 2;
|
|
24
|
+
repeated string sortBy=3;
|
|
25
|
+
repeated DynamicConfig items=4;
|
|
26
|
+
int32 itemCount=5;
|
|
27
|
+
optional int32 pageCount=6;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
message GetRawDynamicConfigRequest {
|
|
31
|
+
string key = 3;
|
|
32
|
+
string type = 2;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
message GetRawDynamicConfigResponse {
|
|
36
|
+
string result = 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
message CreateDynamicConfigRequest {
|
|
40
|
+
paybuy.common.Owner owner = 1;
|
|
41
|
+
string type = 2;
|
|
42
|
+
string key = 3;
|
|
43
|
+
string value = 4;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
message UpdateDynamicConfigRequest {
|
|
47
|
+
string id = 1;
|
|
48
|
+
optional string type = 2;
|
|
49
|
+
optional string key = 3;
|
|
50
|
+
optional string value = 4;
|
|
51
|
+
paybuy.common.Owner updatedBy = 5;
|
|
52
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package paybuy.config;
|
|
4
|
+
|
|
5
|
+
import "dynamic-config/dynamic-config.proto";
|
|
6
|
+
import "crud_request.proto";
|
|
7
|
+
import "paybuy-health-check.proto";
|
|
8
|
+
|
|
9
|
+
service DynamicConfigService {
|
|
10
|
+
rpc findPaginate(paybuy.common.FindEntityPagination) returns (dynamicConfig.DynamicConfigPaginationResponse) {}
|
|
11
|
+
rpc findById(paybuy.common.FindEntityById) returns (dynamicConfig.DynamicConfig) {}
|
|
12
|
+
rpc getRaw(dynamicConfig.GetRawDynamicConfigRequest) returns (dynamicConfig.GetRawDynamicConfigResponse) {}
|
|
13
|
+
rpc create(dynamicConfig.CreateDynamicConfigRequest) returns (dynamicConfig.DynamicConfig) {}
|
|
14
|
+
rpc delete(paybuy.common.DeleteEntityById) returns (dynamicConfig.DynamicConfig) {}
|
|
15
|
+
rpc update(dynamicConfig.UpdateDynamicConfigRequest) returns (dynamicConfig.DynamicConfig) {}
|
|
16
|
+
rpc healthCheck(paybuy.healthCheck.HealthCheckEmpty) returns (paybuy.healthCheck.HealthCheckResponse) {}
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package paybuy.healthCheck;
|
|
4
|
+
|
|
5
|
+
// HealthCheck
|
|
6
|
+
message HealthCheckResponse {
|
|
7
|
+
HealthCheckStatus status = 1;
|
|
8
|
+
string info = 2;
|
|
9
|
+
string error = 3;
|
|
10
|
+
string details = 4;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
message HealthCheckEmpty {}
|
|
14
|
+
/* Enums */
|
|
15
|
+
enum HealthCheckStatus {
|
|
16
|
+
HEALTH_CHECK_STATUS_ERROR = 0;
|
|
17
|
+
HEALTH_CHECK_STATUS_OK = 1;
|
|
18
|
+
HEALTH_CHECK_STATUS_SHUTTING_DOWN = 2;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './inject-dynamic-config.decorator';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Inject } from '@nestjs/common';
|
|
2
|
+
import { DYNAMIC_CONFIG_SERVICE_KEY } from '../dynamic-config/constants/dynamic-config-client-key.constants';
|
|
3
|
+
|
|
4
|
+
export function InjectDynamicService(): (
|
|
5
|
+
target: object,
|
|
6
|
+
key: string | symbol,
|
|
7
|
+
index?: number,
|
|
8
|
+
) => void {
|
|
9
|
+
return Inject(DYNAMIC_CONFIG_SERVICE_KEY);
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const DYNAMIC_CONFIG_CLIENT_NAME = 'DYNAMIC_CONFIG_CLIENT';
|
|
2
|
+
export const DYNAMIC_CONFIG_SERVICE_KEY = 'DYNAMIC_CONFIG_SERVICE';
|
|
3
|
+
export const DYNAMIC_CONFIG_OPTIONS_KEY = 'DYNAMIC_CONFIG_OPTIONS';
|
|
4
|
+
export const DYNAMIC_CONFIG_CLIENT_SERVICE_NAME =
|
|
5
|
+
'DYNAMIC_CONFIG_CLIENT_SERVICE';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DYNAMIC_CONFIG_METADATA_KEYS } from '../enum/dynamic-config-meta-data.enum';
|
|
2
|
+
|
|
3
|
+
export function DynamicConfig({
|
|
4
|
+
dynamicConfigType,
|
|
5
|
+
fallBackValue,
|
|
6
|
+
key,
|
|
7
|
+
retry = 0,
|
|
8
|
+
cacheTTL = 0,
|
|
9
|
+
}: {
|
|
10
|
+
key: string;
|
|
11
|
+
dynamicConfigType: string;
|
|
12
|
+
fallBackValue?: Record<string, any>;
|
|
13
|
+
retry?: number;
|
|
14
|
+
cacheTTL?: number;
|
|
15
|
+
}) {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types
|
|
17
|
+
return function <T extends { new (...arguments_: any[]): {} }>(target: T) {
|
|
18
|
+
Reflect.defineMetadata(
|
|
19
|
+
`${DYNAMIC_CONFIG_METADATA_KEYS.prefix}:${DYNAMIC_CONFIG_METADATA_KEYS.key}`,
|
|
20
|
+
key,
|
|
21
|
+
target,
|
|
22
|
+
);
|
|
23
|
+
Reflect.defineMetadata(
|
|
24
|
+
`${DYNAMIC_CONFIG_METADATA_KEYS.prefix}:${DYNAMIC_CONFIG_METADATA_KEYS.dynamicConfigType}`,
|
|
25
|
+
dynamicConfigType,
|
|
26
|
+
target,
|
|
27
|
+
);
|
|
28
|
+
Reflect.defineMetadata(
|
|
29
|
+
`${DYNAMIC_CONFIG_METADATA_KEYS.prefix}:${DYNAMIC_CONFIG_METADATA_KEYS.fallBackValue}`,
|
|
30
|
+
fallBackValue,
|
|
31
|
+
target,
|
|
32
|
+
);
|
|
33
|
+
Reflect.defineMetadata(
|
|
34
|
+
`${DYNAMIC_CONFIG_METADATA_KEYS.prefix}:${DYNAMIC_CONFIG_METADATA_KEYS.retry}`,
|
|
35
|
+
retry,
|
|
36
|
+
target,
|
|
37
|
+
);
|
|
38
|
+
Reflect.defineMetadata(
|
|
39
|
+
`${DYNAMIC_CONFIG_METADATA_KEYS.prefix}:${DYNAMIC_CONFIG_METADATA_KEYS.cacheTTL}`,
|
|
40
|
+
cacheTTL,
|
|
41
|
+
target,
|
|
42
|
+
);
|
|
43
|
+
return target;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dynamic-config.decorator';
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* Import */
|
|
2
|
+
import {
|
|
3
|
+
ConfigurableModuleAsyncOptions,
|
|
4
|
+
ConfigurableModuleBuilder,
|
|
5
|
+
DynamicModule,
|
|
6
|
+
Module,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import { ClientsModule, Transport } from '@nestjs/microservices';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
// Constant
|
|
11
|
+
import { DYNAMIC_CONFIG_CLIENT_NAME } from './constants/dynamic-config-client-key.constants';
|
|
12
|
+
import {
|
|
13
|
+
createAsyncOptionsProvider,
|
|
14
|
+
CreateDynamicConfigServiceProvider,
|
|
15
|
+
} from './provider/dynamic-config.provider';
|
|
16
|
+
import { DYNAMIC_CONFIG_OPTIONS_KEY } from './constants/dynamic-config-client-key.constants';
|
|
17
|
+
// Type
|
|
18
|
+
import { DynamicConfigModuleOption } from './types/dynamic-config.type';
|
|
19
|
+
|
|
20
|
+
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } =
|
|
21
|
+
new ConfigurableModuleBuilder<DynamicConfigModuleOption>()
|
|
22
|
+
.setClassMethodName('forRoot')
|
|
23
|
+
.build();
|
|
24
|
+
|
|
25
|
+
@Module({})
|
|
26
|
+
export class DynamicConfigModule extends ConfigurableModuleClass {
|
|
27
|
+
static forRootAsync(
|
|
28
|
+
options: ConfigurableModuleAsyncOptions<DynamicConfigModuleOption>,
|
|
29
|
+
isGlobal = true,
|
|
30
|
+
): DynamicModule {
|
|
31
|
+
if (!options.useFactory && !options.useClass && !options.useExisting) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`The asynchronous configurations are missing. Expected one of: "useFactory", "useClass", "useExisting".`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const providers = CreateDynamicConfigServiceProvider();
|
|
37
|
+
return {
|
|
38
|
+
module: DynamicConfigModule,
|
|
39
|
+
global: isGlobal,
|
|
40
|
+
imports: [createGrpcClientModuleAsync(options)],
|
|
41
|
+
providers: [...providers],
|
|
42
|
+
exports: [...providers],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static forRoot(
|
|
47
|
+
option: DynamicConfigModuleOption,
|
|
48
|
+
isGlobal = true,
|
|
49
|
+
): DynamicModule {
|
|
50
|
+
const providers = CreateDynamicConfigServiceProvider();
|
|
51
|
+
return {
|
|
52
|
+
module: DynamicConfigModule,
|
|
53
|
+
global: isGlobal,
|
|
54
|
+
imports: [createGrpcClientModule(option)],
|
|
55
|
+
providers: [...providers],
|
|
56
|
+
exports: [...providers],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function createGrpcClientModule(
|
|
62
|
+
option: DynamicConfigModuleOption,
|
|
63
|
+
): DynamicModule {
|
|
64
|
+
return ClientsModule.register([
|
|
65
|
+
{
|
|
66
|
+
name: DYNAMIC_CONFIG_CLIENT_NAME,
|
|
67
|
+
|
|
68
|
+
transport: Transport.GRPC,
|
|
69
|
+
|
|
70
|
+
options: {
|
|
71
|
+
package: 'paybuy.config',
|
|
72
|
+
protoPath: join(__dirname, '../../proto/paybuy-config.proto'),
|
|
73
|
+
url: option.url,
|
|
74
|
+
loader: {
|
|
75
|
+
includeDirs: [
|
|
76
|
+
'node_modules/@paybuy/common/proto',
|
|
77
|
+
'node_modules/@paybuy/config-client/proto'
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function createGrpcClientModuleAsync(
|
|
86
|
+
options: ConfigurableModuleAsyncOptions<DynamicConfigModuleOption>,
|
|
87
|
+
): DynamicModule {
|
|
88
|
+
return ClientsModule.registerAsync([
|
|
89
|
+
{
|
|
90
|
+
name: DYNAMIC_CONFIG_CLIENT_NAME,
|
|
91
|
+
extraProviders: [createAsyncOptionsProvider(options)],
|
|
92
|
+
inject: [DYNAMIC_CONFIG_OPTIONS_KEY],
|
|
93
|
+
useFactory: (option: DynamicConfigModuleOption) => ({
|
|
94
|
+
transport: Transport.GRPC,
|
|
95
|
+
options: {
|
|
96
|
+
package: 'paybuy.config',
|
|
97
|
+
protoPath: join(__dirname, '../../proto/paybuy-config.proto'),
|
|
98
|
+
url: option.url,
|
|
99
|
+
loader: {
|
|
100
|
+
includeDirs: [
|
|
101
|
+
'node_modules/@paybuy/common/proto',
|
|
102
|
+
'node_modules/@paybuy/config-client/proto'
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
}
|