@coast/service-common 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/models/Constants.d.ts +4 -0
- package/dist/lib/models/Constants.js +7 -0
- package/dist/lib/models/coast-api/CoastApiModuleAsyncOptions.d.ts +7 -0
- package/dist/lib/models/coast-api/CoastApiOptions.d.ts +4 -0
- package/dist/lib/models/logger/LogLevel.d.ts +8 -0
- package/dist/lib/models/logger/LogLevel.js +12 -0
- package/dist/lib/models/logger/LoggerModuleAsyncOptions.d.ts +7 -0
- package/dist/lib/models/logger/LoggerOptions.d.ts +5 -0
- package/dist/{modules → lib/modules}/coast-api/CoastApiClient.d.ts +3 -3
- package/dist/{modules → lib/modules}/coast-api/CoastApiClient.js +23 -6
- package/dist/lib/modules/coast-api/CoastApiModule.d.ts +6 -0
- package/dist/lib/modules/coast-api/CoastApiModule.js +42 -0
- package/dist/lib/modules/logger/LoggerModule.d.ts +7 -0
- package/dist/{modules → lib/modules}/logger/LoggerModule.js +14 -7
- package/dist/{modules → lib/modules}/logger/PinoLogger.d.ts +2 -2
- package/dist/{modules → lib/modules}/logger/PinoLogger.js +10 -5
- package/dist/lib/modules/trace/Trace.js +2 -0
- package/dist/lib/modules/trace/Traceable.js +2 -0
- package/dist/lib/modules/utils/graphql/GqlRequestBody.js +2 -0
- package/dist/lib/modules/utils/graphql/GqlResponse.js +2 -0
- package/dist/test/ModuleTest.d.ts +1 -0
- package/dist/test/ModuleTest.js +14 -0
- package/dist/test/TestApp.d.ts +2 -0
- package/dist/test/TestApp.js +14 -0
- package/dist/test/TestModule.d.ts +2 -0
- package/dist/test/TestModule.js +41 -0
- package/package.json +7 -3
- package/dist/modules/coast-api/CoastApiModule.d.ts +0 -2
- package/dist/modules/coast-api/CoastApiModule.js +0 -28
- package/dist/modules/coast-api/coastApiClientFactory.d.ts +0 -4
- package/dist/modules/coast-api/coastApiClientFactory.js +0 -8
- package/dist/modules/logger/LoggerModule.d.ts +0 -5
- /package/dist/{modules/trace/Trace.js → lib/models/coast-api/CoastApiModuleAsyncOptions.js} +0 -0
- /package/dist/{modules/trace/Traceable.js → lib/models/coast-api/CoastApiOptions.js} +0 -0
- /package/dist/{models → lib/models}/coast-api/CoastApiRequests.d.ts +0 -0
- /package/dist/{models → lib/models}/coast-api/CoastApiRequests.js +0 -0
- /package/dist/{models → lib/models}/coast-api/WorkflowEntityGqlFields.d.ts +0 -0
- /package/dist/{models → lib/models}/coast-api/WorkflowEntityGqlFields.js +0 -0
- /package/dist/{models → lib/models}/coast-api/WorkflowTemplateGqlFields.d.ts +0 -0
- /package/dist/{models → lib/models}/coast-api/WorkflowTemplateGqlFields.js +0 -0
- /package/dist/{modules/utils/graphql/GqlRequestBody.js → lib/models/logger/LoggerModuleAsyncOptions.js} +0 -0
- /package/dist/{modules/utils/graphql/GqlResponse.js → lib/models/logger/LoggerOptions.js} +0 -0
- /package/dist/{modules → lib/modules}/coast-api/CoastApiClientGqlError.d.ts +0 -0
- /package/dist/{modules → lib/modules}/coast-api/CoastApiClientGqlError.js +0 -0
- /package/dist/{modules → lib/modules}/logger/CoastLogger.d.ts +0 -0
- /package/dist/{modules → lib/modules}/logger/CoastLogger.js +0 -0
- /package/dist/{modules → lib/modules}/logger/SilentLogger.d.ts +0 -0
- /package/dist/{modules → lib/modules}/logger/SilentLogger.js +0 -0
- /package/dist/{modules → lib/modules}/trace/Trace.d.ts +0 -0
- /package/dist/{modules → lib/modules}/trace/TraceId.d.ts +0 -0
- /package/dist/{modules → lib/modules}/trace/TraceId.js +0 -0
- /package/dist/{modules → lib/modules}/trace/TraceInterceptor.d.ts +0 -0
- /package/dist/{modules → lib/modules}/trace/TraceInterceptor.js +0 -0
- /package/dist/{modules → lib/modules}/trace/TraceManager.d.ts +0 -0
- /package/dist/{modules → lib/modules}/trace/TraceManager.js +0 -0
- /package/dist/{modules → lib/modules}/trace/TraceModule.d.ts +0 -0
- /package/dist/{modules → lib/modules}/trace/TraceModule.js +0 -0
- /package/dist/{modules → lib/modules}/trace/Traceable.d.ts +0 -0
- /package/dist/{modules → lib/modules}/utils/graphql/GqlRequestBody.d.ts +0 -0
- /package/dist/{modules → lib/modules}/utils/graphql/GqlResponse.d.ts +0 -0
- /package/dist/{modules → lib/modules}/utils/streams/Generators.d.ts +0 -0
- /package/dist/{modules → lib/modules}/utils/streams/Generators.js +0 -0
- /package/dist/{modules → lib/modules}/utils/streams/test/GeneratorsTest.d.ts +0 -0
- /package/dist/{modules → lib/modules}/utils/streams/test/GeneratorsTest.js +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InjectionToken, ModuleMetadata, OptionalFactoryDependency } from '@nestjs/common';
|
|
2
|
+
import { CoastApiOptions } from './CoastApiOptions';
|
|
3
|
+
export interface CoastApiModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
4
|
+
name?: string;
|
|
5
|
+
useFactory: (...args: any[]) => CoastApiOptions | Promise<CoastApiOptions>;
|
|
6
|
+
inject?: Array<InjectionToken | OptionalFactoryDependency>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevel = void 0;
|
|
4
|
+
var LogLevel;
|
|
5
|
+
(function (LogLevel) {
|
|
6
|
+
LogLevel["DEBUG"] = "debug";
|
|
7
|
+
LogLevel["ERROR"] = "error";
|
|
8
|
+
LogLevel["FATAL"] = "fatal";
|
|
9
|
+
LogLevel["INFO"] = "info";
|
|
10
|
+
LogLevel["SILENT"] = "silent";
|
|
11
|
+
LogLevel["WARN"] = "warn";
|
|
12
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InjectionToken, ModuleMetadata, OptionalFactoryDependency } from '@nestjs/common';
|
|
2
|
+
import { LoggerOptions } from './LoggerOptions';
|
|
3
|
+
export interface LoggerModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
4
|
+
name?: string;
|
|
5
|
+
useFactory: (...args: any[]) => LoggerOptions | Promise<LoggerOptions>;
|
|
6
|
+
inject?: Array<InjectionToken | OptionalFactoryDependency>;
|
|
7
|
+
}
|
|
@@ -20,12 +20,12 @@ import { GetWorkflowEntityResult } from '@coast/core-api-types/workflow-template
|
|
|
20
20
|
import { UpdateWorkflowEntity } from '@coast/core-api-types/workflow-template/entities/UpdateWorkflowEntity';
|
|
21
21
|
import { UpdateWorkflowTemplate } from '@coast/core-api-types/workflow-template/UpdateWorkflowTemplate';
|
|
22
22
|
import { WorkflowTemplate } from '@coast/core-api-types/workflow-template/WorkflowTemplate';
|
|
23
|
+
import { CoastApiOptions } from '../../models/coast-api/CoastApiOptions';
|
|
23
24
|
import { CoastLogger } from '../logger/CoastLogger';
|
|
24
25
|
export declare class CoastApiClient {
|
|
25
|
-
private readonly coastApiEndpoint;
|
|
26
|
-
private readonly coastApiAuthToken;
|
|
27
26
|
private readonly logger;
|
|
28
|
-
|
|
27
|
+
private readonly options;
|
|
28
|
+
constructor(logger: CoastLogger, options: CoastApiOptions);
|
|
29
29
|
aggregateRelatedCardQuantityStats(businessId: BusinessId, aggregate: AggregateRelatedCardQuantity): Promise<AggregateNumberStats>;
|
|
30
30
|
createEntityAuditTrailEvent(businessId: BusinessId, createEntityAuditTrailEvent: CreateEntityAuditTrailEvent): Promise<EntityAuditTrailEvent>;
|
|
31
31
|
createUsers(createUsers: CreateUserV2[], businessId: BusinessId): Promise<User[] | undefined>;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
2
14
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
16
|
};
|
|
@@ -9,12 +21,13 @@ const common_1 = require("@nestjs/common");
|
|
|
9
21
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
22
|
const superagent_1 = __importDefault(require("superagent"));
|
|
11
23
|
const CoastApiRequests_1 = require("../../models/coast-api/CoastApiRequests");
|
|
24
|
+
const Constants_1 = require("../../models/Constants");
|
|
25
|
+
const CoastLogger_1 = require("../logger/CoastLogger");
|
|
12
26
|
const CoastApiClientGqlError_1 = require("./CoastApiClientGqlError");
|
|
13
|
-
class CoastApiClient {
|
|
14
|
-
constructor(
|
|
15
|
-
this.coastApiEndpoint = coastApiEndpoint;
|
|
16
|
-
this.coastApiAuthToken = coastApiAuthToken;
|
|
27
|
+
let CoastApiClient = class CoastApiClient {
|
|
28
|
+
constructor(logger, options) {
|
|
17
29
|
this.logger = logger;
|
|
30
|
+
this.options = options;
|
|
18
31
|
}
|
|
19
32
|
async aggregateRelatedCardQuantityStats(businessId, aggregate) {
|
|
20
33
|
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.aggregateRelatedCardQuantityStats(aggregate));
|
|
@@ -91,7 +104,7 @@ class CoastApiClient {
|
|
|
91
104
|
return response.body.data.updateWorkflowTemplate;
|
|
92
105
|
}
|
|
93
106
|
async execute(businessId, query, options = {}) {
|
|
94
|
-
const request = superagent_1.default.post(this.
|
|
107
|
+
const request = superagent_1.default.post(this.options.endpoint).set(HeaderKeys_1.HeaderKeys.AUTHORIZATION, this.options.authToken);
|
|
95
108
|
request.set(HeaderKeys_1.HeaderKeys.BUSINESS_ID, businessId.toString());
|
|
96
109
|
if (!lodash_1.default.isNil(options?.sourceAutomationId)) {
|
|
97
110
|
request.set(HeaderKeys_1.HeaderKeys.SOURCE_AUTOMATION_ID, options.sourceAutomationId);
|
|
@@ -103,5 +116,9 @@ class CoastApiClient {
|
|
|
103
116
|
}
|
|
104
117
|
return response;
|
|
105
118
|
}
|
|
106
|
-
}
|
|
119
|
+
};
|
|
107
120
|
exports.CoastApiClient = CoastApiClient;
|
|
121
|
+
exports.CoastApiClient = CoastApiClient = __decorate([
|
|
122
|
+
__param(1, (0, common_1.Inject)(Constants_1.Constants.COAST_API_OPTIONS)),
|
|
123
|
+
__metadata("design:paramtypes", [CoastLogger_1.CoastLogger, Object])
|
|
124
|
+
], CoastApiClient);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { CoastApiModuleAsyncOptions } from '../../models/coast-api/CoastApiModuleAsyncOptions';
|
|
3
|
+
export declare class CoastApiModule {
|
|
4
|
+
static forRootAsync(options: CoastApiModuleAsyncOptions): DynamicModule;
|
|
5
|
+
private static createAsyncOptionsProvider;
|
|
6
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var CoastApiModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CoastApiModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const Constants_1 = require("../../models/Constants");
|
|
13
|
+
const CoastLogger_1 = require("../logger/CoastLogger");
|
|
14
|
+
const LoggerModule_1 = require("../logger/LoggerModule");
|
|
15
|
+
const CoastApiClient_1 = require("./CoastApiClient");
|
|
16
|
+
let CoastApiModule = CoastApiModule_1 = class CoastApiModule {
|
|
17
|
+
static forRootAsync(options) {
|
|
18
|
+
const asyncProvider = CoastApiModule_1.createAsyncOptionsProvider(options);
|
|
19
|
+
const coastClient = {
|
|
20
|
+
inject: [Constants_1.Constants.COAST_API_OPTIONS, CoastLogger_1.CoastLogger],
|
|
21
|
+
provide: CoastApiClient_1.CoastApiClient,
|
|
22
|
+
useFactory: (logger, options) => new CoastApiClient_1.CoastApiClient(logger, options),
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
exports: [coastClient],
|
|
26
|
+
imports: [LoggerModule_1.LoggerModule, ...(options.imports ?? [])],
|
|
27
|
+
module: CoastApiModule_1,
|
|
28
|
+
providers: [coastClient, asyncProvider],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static createAsyncOptionsProvider(options) {
|
|
32
|
+
return {
|
|
33
|
+
provide: Constants_1.Constants.COAST_API_OPTIONS,
|
|
34
|
+
useFactory: options.useFactory,
|
|
35
|
+
inject: options.inject ?? [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.CoastApiModule = CoastApiModule;
|
|
40
|
+
exports.CoastApiModule = CoastApiModule = CoastApiModule_1 = __decorate([
|
|
41
|
+
(0, common_1.Module)({})
|
|
42
|
+
], CoastApiModule);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { LoggerModuleAsyncOptions } from '../../models/logger/LoggerModuleAsyncOptions';
|
|
3
|
+
export declare class LoggerModule {
|
|
4
|
+
static disabled(): DynamicModule;
|
|
5
|
+
static forRootAsync(options: LoggerModuleAsyncOptions): DynamicModule;
|
|
6
|
+
private static createAsyncOptionsProvider;
|
|
7
|
+
}
|
|
@@ -9,7 +9,7 @@ var LoggerModule_1;
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.LoggerModule = void 0;
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
|
-
const
|
|
12
|
+
const Constants_1 = require("../../models/Constants");
|
|
13
13
|
const TraceManager_1 = require("../trace/TraceManager");
|
|
14
14
|
const TraceModule_1 = require("../trace/TraceModule");
|
|
15
15
|
const CoastLogger_1 = require("./CoastLogger");
|
|
@@ -23,22 +23,29 @@ let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
|
23
23
|
};
|
|
24
24
|
return {
|
|
25
25
|
exports: [coastLogger],
|
|
26
|
-
imports: [config_1.ConfigModule],
|
|
27
26
|
module: LoggerModule_1,
|
|
28
27
|
providers: [coastLogger],
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
|
-
static forRootAsync() {
|
|
30
|
+
static forRootAsync(options) {
|
|
31
|
+
const asyncProvider = LoggerModule_1.createAsyncOptionsProvider(options);
|
|
32
32
|
const coastLogger = {
|
|
33
|
-
inject: [
|
|
33
|
+
inject: [Constants_1.Constants.LOGGER_OPTIONS, TraceManager_1.TraceManager],
|
|
34
34
|
provide: CoastLogger_1.CoastLogger,
|
|
35
|
-
useFactory: (
|
|
35
|
+
useFactory: (traceManager, options) => new PinoLogger_1.PinoLogger(traceManager, options),
|
|
36
36
|
};
|
|
37
37
|
return {
|
|
38
38
|
exports: [coastLogger],
|
|
39
|
-
imports: [
|
|
39
|
+
imports: [TraceModule_1.TraceModule, ...(options.imports ?? [])],
|
|
40
40
|
module: LoggerModule_1,
|
|
41
|
-
providers: [coastLogger],
|
|
41
|
+
providers: [coastLogger, asyncProvider],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
static createAsyncOptionsProvider(options) {
|
|
45
|
+
return {
|
|
46
|
+
provide: Constants_1.Constants.LOGGER_OPTIONS,
|
|
47
|
+
useFactory: options.useFactory,
|
|
48
|
+
inject: options.inject ?? [],
|
|
42
49
|
};
|
|
43
50
|
}
|
|
44
51
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LoggerOptions } from '../../models/logger/LoggerOptions';
|
|
2
2
|
import { TraceManager } from '../trace/TraceManager';
|
|
3
3
|
import { CoastLogger } from './CoastLogger';
|
|
4
4
|
export declare class PinoLogger extends CoastLogger {
|
|
5
5
|
private readonly instance;
|
|
6
6
|
private readonly traceManager?;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(traceManager: TraceManager, options: LoggerOptions);
|
|
8
8
|
debug(message: unknown): void;
|
|
9
9
|
error(message: unknown, trace?: string): void;
|
|
10
10
|
log(message: unknown): void;
|
|
@@ -8,20 +8,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
16
|
};
|
|
14
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
18
|
exports.PinoLogger = void 0;
|
|
16
19
|
const common_1 = require("@nestjs/common");
|
|
17
|
-
const config_1 = require("@nestjs/config");
|
|
18
20
|
const pino_1 = __importDefault(require("pino"));
|
|
21
|
+
const Constants_1 = require("../../models/Constants");
|
|
22
|
+
const LogLevel_1 = require("../../models/logger/LogLevel");
|
|
19
23
|
const TraceManager_1 = require("../trace/TraceManager");
|
|
20
24
|
const CoastLogger_1 = require("./CoastLogger");
|
|
21
25
|
let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
22
|
-
constructor(
|
|
26
|
+
constructor(traceManager, options) {
|
|
23
27
|
super();
|
|
24
|
-
const level =
|
|
28
|
+
const level = options.level ?? LogLevel_1.LogLevel.INFO;
|
|
25
29
|
const redact = [
|
|
26
30
|
'MYSQL_PASSWORD',
|
|
27
31
|
'STRIPE_SECRETKEY',
|
|
@@ -32,7 +36,7 @@ let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
|
32
36
|
'user.phoneNumber',
|
|
33
37
|
'user.email',
|
|
34
38
|
];
|
|
35
|
-
const pino =
|
|
39
|
+
const pino = options.pretty
|
|
36
40
|
? (0, pino_1.default)({
|
|
37
41
|
level,
|
|
38
42
|
mixin: () => this.traceManager?.getTrace() ?? {},
|
|
@@ -72,5 +76,6 @@ let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
|
72
76
|
exports.PinoLogger = PinoLogger;
|
|
73
77
|
exports.PinoLogger = PinoLogger = __decorate([
|
|
74
78
|
(0, common_1.Injectable)(),
|
|
75
|
-
|
|
79
|
+
__param(1, (0, common_1.Inject)(Constants_1.Constants.LOGGER_OPTIONS)),
|
|
80
|
+
__metadata("design:paramtypes", [TraceManager_1.TraceManager, Object])
|
|
76
81
|
], PinoLogger);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_test_1 = require("@paradoxical-io/common-test");
|
|
4
|
+
const CoastApiClient_1 = require("../lib/modules/coast-api/CoastApiClient");
|
|
5
|
+
const CoastLogger_1 = require("../lib/modules/logger/CoastLogger");
|
|
6
|
+
const TestApp_1 = require("./TestApp");
|
|
7
|
+
test('TestModule', async () => {
|
|
8
|
+
const app = await (0, TestApp_1.initTestApp)();
|
|
9
|
+
(0, common_test_1.safeExpect)(app).toBeDefined();
|
|
10
|
+
const logger = app.get(CoastLogger_1.CoastLogger);
|
|
11
|
+
(0, common_test_1.safeExpect)(logger).toBeDefined();
|
|
12
|
+
const apiClient = app.get(CoastApiClient_1.CoastApiClient);
|
|
13
|
+
(0, common_test_1.safeExpect)(apiClient).toBeDefined();
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initTestApp = initTestApp;
|
|
4
|
+
const testing_1 = require("@nestjs/testing");
|
|
5
|
+
const TestModule_1 = require("./TestModule");
|
|
6
|
+
let app;
|
|
7
|
+
async function initTestApp() {
|
|
8
|
+
const moduleFixture = await testing_1.Test.createTestingModule({
|
|
9
|
+
imports: [TestModule_1.TestModule],
|
|
10
|
+
}).compile();
|
|
11
|
+
app = moduleFixture.createNestApplication({});
|
|
12
|
+
await app.init();
|
|
13
|
+
return app;
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TestModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const config_1 = require("@nestjs/config");
|
|
12
|
+
const CoastApiModule_1 = require("../lib/modules/coast-api/CoastApiModule");
|
|
13
|
+
const LoggerModule_1 = require("../lib/modules/logger/LoggerModule");
|
|
14
|
+
let TestModule = class TestModule {
|
|
15
|
+
};
|
|
16
|
+
exports.TestModule = TestModule;
|
|
17
|
+
exports.TestModule = TestModule = __decorate([
|
|
18
|
+
(0, common_1.Module)({
|
|
19
|
+
imports: [
|
|
20
|
+
config_1.ConfigModule.forRoot({
|
|
21
|
+
isGlobal: true,
|
|
22
|
+
}),
|
|
23
|
+
LoggerModule_1.LoggerModule.forRootAsync({
|
|
24
|
+
imports: [config_1.ConfigModule],
|
|
25
|
+
inject: [config_1.ConfigService],
|
|
26
|
+
useFactory: async (configService) => ({
|
|
27
|
+
level: configService.get('LOG_LEVEL'),
|
|
28
|
+
pretty: configService.get('LOG_PRETTY'),
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
CoastApiModule_1.CoastApiModule.forRootAsync({
|
|
32
|
+
imports: [config_1.ConfigModule],
|
|
33
|
+
inject: [config_1.ConfigService],
|
|
34
|
+
useFactory: async (configService) => ({
|
|
35
|
+
endpoint: configService.getOrThrow('COAST_API_ENDPOINT'),
|
|
36
|
+
authToken: configService.getOrThrow('COAST_API_AUTH_TOKEN'),
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
})
|
|
41
|
+
], TestModule);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coast/service-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Common service package",
|
|
5
5
|
"main": "./modules",
|
|
6
6
|
"types": "./modules",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"prebuild": "rimraf dist",
|
|
27
27
|
"build": "yarn prebuild && yarn dlx @nestjs/cli build",
|
|
28
28
|
"lint": "eslint",
|
|
29
|
-
"lint:fix": "eslint --fix"
|
|
29
|
+
"lint:fix": "eslint --fix",
|
|
30
|
+
"test": "jest --config jest.config.js"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@paradoxical-io/types": "^1.0.7",
|
|
33
33
|
"lodash": "^4.17.21",
|
|
34
34
|
"pino": "^9.6.0",
|
|
35
35
|
"superagent": "^10.1.1",
|
|
@@ -41,8 +41,12 @@
|
|
|
41
41
|
"@nestjs/cli": "^10.4.4",
|
|
42
42
|
"@nestjs/common": "^10.4.1",
|
|
43
43
|
"@nestjs/config": "^3.2.3",
|
|
44
|
+
"@nestjs/core": "^11.0.7",
|
|
45
|
+
"@nestjs/platform-express": "^11.0.7",
|
|
44
46
|
"@nestjs/schematics": "^10.1.4",
|
|
47
|
+
"@nestjs/testing": "^11.0.7",
|
|
45
48
|
"@paradoxical-io/common-test": "^1.0.7",
|
|
49
|
+
"@paradoxical-io/types": "^1.0.7",
|
|
46
50
|
"@types/jest": "^29.5.12",
|
|
47
51
|
"@types/lodash": "^4",
|
|
48
52
|
"@types/node": "^22.5.0",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.CoastApiModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const config_1 = require("@nestjs/config");
|
|
12
|
-
const CoastLogger_1 = require("../logger/CoastLogger");
|
|
13
|
-
const CoastApiClient_1 = require("./CoastApiClient");
|
|
14
|
-
const coastApiClientFactory_1 = require("./coastApiClientFactory");
|
|
15
|
-
const coastApiProvider = {
|
|
16
|
-
inject: [config_1.ConfigService, CoastLogger_1.CoastLogger],
|
|
17
|
-
provide: CoastApiClient_1.CoastApiClient,
|
|
18
|
-
useFactory: coastApiClientFactory_1.coastApiClientFactory,
|
|
19
|
-
};
|
|
20
|
-
let CoastApiModule = class CoastApiModule {
|
|
21
|
-
};
|
|
22
|
-
exports.CoastApiModule = CoastApiModule;
|
|
23
|
-
exports.CoastApiModule = CoastApiModule = __decorate([
|
|
24
|
-
(0, common_1.Module)({
|
|
25
|
-
exports: [CoastApiClient_1.CoastApiClient],
|
|
26
|
-
providers: [coastApiProvider],
|
|
27
|
-
})
|
|
28
|
-
], CoastApiModule);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coastApiClientFactory = void 0;
|
|
4
|
-
const CoastApiClient_1 = require("./CoastApiClient");
|
|
5
|
-
const coastApiClientFactory = (configService, logger) => {
|
|
6
|
-
return new CoastApiClient_1.CoastApiClient(configService.getOrThrow('COAST_API_ENDPOINT'), configService.getOrThrow('COAST_API_AUTH_TOKEN'), logger);
|
|
7
|
-
};
|
|
8
|
-
exports.coastApiClientFactory = coastApiClientFactory;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|