@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,57 @@
|
|
|
1
|
+
/* Import */
|
|
2
|
+
// Type
|
|
3
|
+
import { DynamicConfigCacheService } from '../src/dynamic-config/service/dynamic-config-cache.service';
|
|
4
|
+
import MockedGrpcClientService from './mock/grpc-client-service.mock';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
6
|
+
import { DynamicConfig, DynamicConfigModel } from '../src';
|
|
7
|
+
import { createClientServer } from './test-client';
|
|
8
|
+
import { INestApplication } from '@nestjs/common';
|
|
9
|
+
import {
|
|
10
|
+
DYNAMIC_CONFIG_CLIENT_SERVICE_NAME,
|
|
11
|
+
DYNAMIC_CONFIG_SERVICE_KEY,
|
|
12
|
+
} from '../src/dynamic-config/constants/dynamic-config-client-key.constants';
|
|
13
|
+
|
|
14
|
+
@DynamicConfig({
|
|
15
|
+
dynamicConfigType: 'test',
|
|
16
|
+
fallBackValue: {},
|
|
17
|
+
key: 'test',
|
|
18
|
+
cacheTTL: 5000,
|
|
19
|
+
})
|
|
20
|
+
export class TestConfig extends DynamicConfigModel {}
|
|
21
|
+
|
|
22
|
+
describe('Dynamic Config Client (unit)', () => {
|
|
23
|
+
let clientServer: INestApplication;
|
|
24
|
+
let clientService: MockedGrpcClientService;
|
|
25
|
+
let dynamicConfigService: DynamicConfigCacheService;
|
|
26
|
+
|
|
27
|
+
beforeAll(async () => {
|
|
28
|
+
clientServer = await createClientServer();
|
|
29
|
+
clientService = clientServer.get<MockedGrpcClientService>(
|
|
30
|
+
DYNAMIC_CONFIG_CLIENT_SERVICE_NAME,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
jest
|
|
34
|
+
.spyOn(clientService, clientService.getRaw.name as any)
|
|
35
|
+
.mockImplementation(() => {
|
|
36
|
+
console.log('MockedGrpcClientService.getRaw');
|
|
37
|
+
|
|
38
|
+
return new Observable((subscriber) => {
|
|
39
|
+
subscriber.next({ result: '{"ga":"ASDF"}' });
|
|
40
|
+
subscriber.complete();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
dynamicConfigService = clientServer.get<DynamicConfigCacheService>(
|
|
45
|
+
DYNAMIC_CONFIG_SERVICE_KEY,
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('getRaw', async () => {
|
|
50
|
+
const configClass = new TestConfig();
|
|
51
|
+
for (let i = 0; i < 6; i++) {
|
|
52
|
+
await configClass.get(dynamicConfigService);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
expect(clientService.getRaw).toHaveBeenCalledTimes(1);
|
|
56
|
+
});
|
|
57
|
+
});
|
package/test/jest.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"moduleFileExtensions": [
|
|
3
|
+
"js",
|
|
4
|
+
"json",
|
|
5
|
+
"ts"
|
|
6
|
+
],
|
|
7
|
+
"verbose": true,
|
|
8
|
+
"silent": false,
|
|
9
|
+
"rootDir": "..",
|
|
10
|
+
"testEnvironment": "node",
|
|
11
|
+
"testRegex": "(.*).spec.ts$",
|
|
12
|
+
"testTimeout": 190000,
|
|
13
|
+
"maxWorkers": 1,
|
|
14
|
+
"modulePaths": [
|
|
15
|
+
"./"
|
|
16
|
+
],
|
|
17
|
+
"transform": {
|
|
18
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
19
|
+
},
|
|
20
|
+
"moduleDirectories": [
|
|
21
|
+
"node_modules"
|
|
22
|
+
],
|
|
23
|
+
"collectCoverage": false,
|
|
24
|
+
"coverageProvider": "v8",
|
|
25
|
+
"collectCoverageFrom": [
|
|
26
|
+
"src/**/*.ts",
|
|
27
|
+
"!**/node_modules/**",
|
|
28
|
+
"!**/dist/**",
|
|
29
|
+
"!**/*.interface.ts",
|
|
30
|
+
"!**/*.type.ts"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* Import */
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import {
|
|
4
|
+
FindEntityPagination,
|
|
5
|
+
FindEntityById,
|
|
6
|
+
DeleteEntityById,
|
|
7
|
+
} from '../../src/types/crud_request';
|
|
8
|
+
// Type
|
|
9
|
+
import {
|
|
10
|
+
CreateDynamicConfigRequest,
|
|
11
|
+
DynamicConfig,
|
|
12
|
+
DynamicConfigPaginationResponse,
|
|
13
|
+
GetRawDynamicConfigRequest,
|
|
14
|
+
GetRawDynamicConfigResponse,
|
|
15
|
+
UpdateDynamicConfigRequest,
|
|
16
|
+
} from '../../src/types/dynamic-config/dynamic-config';
|
|
17
|
+
import { DynamicConfigServiceClient } from '../../src/types/paybuy-config';
|
|
18
|
+
import { HealthCheckEmpty, HealthCheckResponse } from '../../src/types/paybuy-health-check';
|
|
19
|
+
|
|
20
|
+
export default class MockedGrpcClientService
|
|
21
|
+
implements DynamicConfigServiceClient
|
|
22
|
+
{
|
|
23
|
+
getRaw(
|
|
24
|
+
request: GetRawDynamicConfigRequest,
|
|
25
|
+
): Observable<GetRawDynamicConfigResponse> {
|
|
26
|
+
throw new Error('Method not implemented.');
|
|
27
|
+
}
|
|
28
|
+
findPaginate(
|
|
29
|
+
request: FindEntityPagination,
|
|
30
|
+
): Observable<DynamicConfigPaginationResponse> {
|
|
31
|
+
throw new Error('Method not implemented.');
|
|
32
|
+
}
|
|
33
|
+
findById(request: FindEntityById): Observable<DynamicConfig> {
|
|
34
|
+
throw new Error('Method not implemented.');
|
|
35
|
+
}
|
|
36
|
+
create(request: CreateDynamicConfigRequest): Observable<DynamicConfig> {
|
|
37
|
+
throw new Error('Method not implemented.');
|
|
38
|
+
}
|
|
39
|
+
delete(request: DeleteEntityById): Observable<DynamicConfig> {
|
|
40
|
+
throw new Error('Method not implemented.');
|
|
41
|
+
}
|
|
42
|
+
update(request: UpdateDynamicConfigRequest): Observable<DynamicConfig> {
|
|
43
|
+
throw new Error('Method not implemented.');
|
|
44
|
+
}
|
|
45
|
+
healthCheck(request: HealthCheckEmpty): Observable<HealthCheckResponse> {
|
|
46
|
+
throw new Error('Method not implemented.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Import */
|
|
2
|
+
import { INestApplication } from '@nestjs/common';
|
|
3
|
+
import { Test, TestingModule } from '@nestjs/testing';
|
|
4
|
+
import MockedGrpcClientService from './mock/grpc-client-service.mock';
|
|
5
|
+
import { DYNAMIC_CONFIG_CLIENT_SERVICE_NAME } from '../src/dynamic-config/constants/dynamic-config-client-key.constants';
|
|
6
|
+
import { DynamicConfigModule } from 'src';
|
|
7
|
+
|
|
8
|
+
export async function createClientServer(): Promise<INestApplication> {
|
|
9
|
+
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
10
|
+
imports: [
|
|
11
|
+
DynamicConfigModule.forRoot({
|
|
12
|
+
url: '',
|
|
13
|
+
}),
|
|
14
|
+
],
|
|
15
|
+
})
|
|
16
|
+
.overrideProvider(DYNAMIC_CONFIG_CLIENT_SERVICE_NAME)
|
|
17
|
+
.useFactory({
|
|
18
|
+
factory: async (): Promise<MockedGrpcClientService> => {
|
|
19
|
+
return new MockedGrpcClientService();
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
.compile();
|
|
23
|
+
|
|
24
|
+
const clientServer = moduleFixture.createNestApplication();
|
|
25
|
+
await clientServer.init();
|
|
26
|
+
return clientServer;
|
|
27
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "CommonJS",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"target": "ES2021",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"incremental": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"strict": true
|
|
16
|
+
}
|
|
17
|
+
}
|
package/README.md
DELETED