@ferreirasw/yoke-common 0.1.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 +20 -0
- package/README.md +393 -0
- package/dist/dto/index.d.ts +2 -0
- package/dist/dto/index.js +19 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/paginated-result.interface.d.ts +23 -0
- package/dist/dto/paginated-result.interface.js +30 -0
- package/dist/dto/paginated-result.interface.js.map +1 -0
- package/dist/dto/pagination.dto.d.ts +12 -0
- package/dist/dto/pagination.dto.js +82 -0
- package/dist/dto/pagination.dto.js.map +1 -0
- package/dist/enums/action.enum.d.ts +10 -0
- package/dist/enums/action.enum.js +15 -0
- package/dist/enums/action.enum.js.map +1 -0
- package/dist/enums/benchmark.enum.d.ts +8 -0
- package/dist/enums/benchmark.enum.js +13 -0
- package/dist/enums/benchmark.enum.js.map +1 -0
- package/dist/enums/coverage-type.enum.d.ts +7 -0
- package/dist/enums/coverage-type.enum.js +12 -0
- package/dist/enums/coverage-type.enum.js.map +1 -0
- package/dist/enums/fund-status.enum.d.ts +4 -0
- package/dist/enums/fund-status.enum.js +9 -0
- package/dist/enums/fund-status.enum.js.map +1 -0
- package/dist/enums/index.d.ts +10 -0
- package/dist/enums/index.js +24 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/insurer-status.enum.d.ts +5 -0
- package/dist/enums/insurer-status.enum.js +10 -0
- package/dist/enums/insurer-status.enum.js.map +1 -0
- package/dist/enums/modality.enum.d.ts +5 -0
- package/dist/enums/modality.enum.js +10 -0
- package/dist/enums/modality.enum.js.map +1 -0
- package/dist/enums/product-status.enum.d.ts +5 -0
- package/dist/enums/product-status.enum.js +10 -0
- package/dist/enums/product-status.enum.js.map +1 -0
- package/dist/enums/quotation-status.enum.d.ts +6 -0
- package/dist/enums/quotation-status.enum.js +11 -0
- package/dist/enums/quotation-status.enum.js.map +1 -0
- package/dist/enums/risk-profile.enum.d.ts +6 -0
- package/dist/enums/risk-profile.enum.js +11 -0
- package/dist/enums/risk-profile.enum.js.map +1 -0
- package/dist/enums/tax-regime.enum.d.ts +5 -0
- package/dist/enums/tax-regime.enum.js +10 -0
- package/dist/enums/tax-regime.enum.js.map +1 -0
- package/dist/filters/http-exception.filter.d.ts +11 -0
- package/dist/filters/http-exception.filter.js +105 -0
- package/dist/filters/http-exception.filter.js.map +1 -0
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +18 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/index.d.ts +1 -0
- package/dist/interceptors/index.js +18 -0
- package/dist/interceptors/index.js.map +1 -0
- package/dist/interceptors/logging.interceptor.d.ts +18 -0
- package/dist/interceptors/logging.interceptor.js +74 -0
- package/dist/interceptors/logging.interceptor.js.map +1 -0
- package/dist/interfaces/api-response.interface.d.ts +22 -0
- package/dist/interfaces/api-response.interface.js +35 -0
- package/dist/interfaces/api-response.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js +18 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/messaging/constants/exchanges.d.ts +11 -0
- package/dist/messaging/constants/exchanges.js +14 -0
- package/dist/messaging/constants/exchanges.js.map +1 -0
- package/dist/messaging/constants/index.d.ts +2 -0
- package/dist/messaging/constants/index.js +19 -0
- package/dist/messaging/constants/index.js.map +1 -0
- package/dist/messaging/constants/routing-keys.d.ts +28 -0
- package/dist/messaging/constants/routing-keys.js +31 -0
- package/dist/messaging/constants/routing-keys.js.map +1 -0
- package/dist/messaging/index.d.ts +3 -0
- package/dist/messaging/index.js +20 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/messaging/services/base-events.service.d.ts +24 -0
- package/dist/messaging/services/base-events.service.js +116 -0
- package/dist/messaging/services/base-events.service.js.map +1 -0
- package/dist/messaging/services/index.d.ts +1 -0
- package/dist/messaging/services/index.js +18 -0
- package/dist/messaging/services/index.js.map +1 -0
- package/dist/messaging/types/account-messages.d.ts +18 -0
- package/dist/messaging/types/account-messages.js +3 -0
- package/dist/messaging/types/account-messages.js.map +1 -0
- package/dist/messaging/types/base-message.d.ts +6 -0
- package/dist/messaging/types/base-message.js +3 -0
- package/dist/messaging/types/base-message.js.map +1 -0
- package/dist/messaging/types/index.d.ts +5 -0
- package/dist/messaging/types/index.js +22 -0
- package/dist/messaging/types/index.js.map +1 -0
- package/dist/messaging/types/product-messages.d.ts +71 -0
- package/dist/messaging/types/product-messages.js +3 -0
- package/dist/messaging/types/product-messages.js.map +1 -0
- package/dist/messaging/types/quotation-messages.d.ts +35 -0
- package/dist/messaging/types/quotation-messages.js +3 -0
- package/dist/messaging/types/quotation-messages.js.map +1 -0
- package/dist/messaging/types/user-messages.d.ts +42 -0
- package/dist/messaging/types/user-messages.js +3 -0
- package/dist/messaging/types/user-messages.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validation.utils.d.ts +8 -0
- package/dist/utils/validation.utils.js +101 -0
- package/dist/utils/validation.utils.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FundStatus = void 0;
|
|
4
|
+
var FundStatus;
|
|
5
|
+
(function (FundStatus) {
|
|
6
|
+
FundStatus["ACTIVE"] = "active";
|
|
7
|
+
FundStatus["INACTIVE"] = "inactive";
|
|
8
|
+
})(FundStatus || (exports.FundStatus = FundStatus = {}));
|
|
9
|
+
//# sourceMappingURL=fund-status.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fund-status.enum.js","sourceRoot":"","sources":["../../src/enums/fund-status.enum.ts"],"names":[],"mappings":";;;AAQA,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;AACvB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Action } from './action.enum';
|
|
2
|
+
export { Benchmark } from './benchmark.enum';
|
|
3
|
+
export { CoverageType } from './coverage-type.enum';
|
|
4
|
+
export { FundStatus } from './fund-status.enum';
|
|
5
|
+
export { InsurerStatus } from './insurer-status.enum';
|
|
6
|
+
export { Modality } from './modality.enum';
|
|
7
|
+
export { ProductStatus } from './product-status.enum';
|
|
8
|
+
export { QuotationStatus } from './quotation-status.enum';
|
|
9
|
+
export { RiskProfile } from './risk-profile.enum';
|
|
10
|
+
export { TaxRegime } from './tax-regime.enum';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaxRegime = exports.RiskProfile = exports.QuotationStatus = exports.ProductStatus = exports.Modality = exports.InsurerStatus = exports.FundStatus = exports.CoverageType = exports.Benchmark = exports.Action = void 0;
|
|
4
|
+
var action_enum_1 = require("./action.enum");
|
|
5
|
+
Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return action_enum_1.Action; } });
|
|
6
|
+
var benchmark_enum_1 = require("./benchmark.enum");
|
|
7
|
+
Object.defineProperty(exports, "Benchmark", { enumerable: true, get: function () { return benchmark_enum_1.Benchmark; } });
|
|
8
|
+
var coverage_type_enum_1 = require("./coverage-type.enum");
|
|
9
|
+
Object.defineProperty(exports, "CoverageType", { enumerable: true, get: function () { return coverage_type_enum_1.CoverageType; } });
|
|
10
|
+
var fund_status_enum_1 = require("./fund-status.enum");
|
|
11
|
+
Object.defineProperty(exports, "FundStatus", { enumerable: true, get: function () { return fund_status_enum_1.FundStatus; } });
|
|
12
|
+
var insurer_status_enum_1 = require("./insurer-status.enum");
|
|
13
|
+
Object.defineProperty(exports, "InsurerStatus", { enumerable: true, get: function () { return insurer_status_enum_1.InsurerStatus; } });
|
|
14
|
+
var modality_enum_1 = require("./modality.enum");
|
|
15
|
+
Object.defineProperty(exports, "Modality", { enumerable: true, get: function () { return modality_enum_1.Modality; } });
|
|
16
|
+
var product_status_enum_1 = require("./product-status.enum");
|
|
17
|
+
Object.defineProperty(exports, "ProductStatus", { enumerable: true, get: function () { return product_status_enum_1.ProductStatus; } });
|
|
18
|
+
var quotation_status_enum_1 = require("./quotation-status.enum");
|
|
19
|
+
Object.defineProperty(exports, "QuotationStatus", { enumerable: true, get: function () { return quotation_status_enum_1.QuotationStatus; } });
|
|
20
|
+
var risk_profile_enum_1 = require("./risk-profile.enum");
|
|
21
|
+
Object.defineProperty(exports, "RiskProfile", { enumerable: true, get: function () { return risk_profile_enum_1.RiskProfile; } });
|
|
22
|
+
var tax_regime_enum_1 = require("./tax-regime.enum");
|
|
23
|
+
Object.defineProperty(exports, "TaxRegime", { enumerable: true, get: function () { return tax_regime_enum_1.TaxRegime; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":";;;AAMA,6CAAuC;AAA9B,qGAAA,MAAM,OAAA;AACf,mDAA6C;AAApC,2GAAA,SAAS,OAAA;AAClB,2DAAoD;AAA3C,kHAAA,YAAY,OAAA;AACrB,uDAAgD;AAAvC,8GAAA,UAAU,OAAA;AACnB,6DAAsD;AAA7C,oHAAA,aAAa,OAAA;AACtB,iDAA2C;AAAlC,yGAAA,QAAQ,OAAA;AACjB,6DAAsD;AAA7C,oHAAA,aAAa,OAAA;AACtB,iEAA0D;AAAjD,wHAAA,eAAe,OAAA;AACxB,yDAAkD;AAAzC,gHAAA,WAAW,OAAA;AACpB,qDAA8C;AAArC,4GAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsurerStatus = void 0;
|
|
4
|
+
var InsurerStatus;
|
|
5
|
+
(function (InsurerStatus) {
|
|
6
|
+
InsurerStatus["ACTIVE"] = "active";
|
|
7
|
+
InsurerStatus["INACTIVE"] = "inactive";
|
|
8
|
+
InsurerStatus["SUSPENDED"] = "suspended";
|
|
9
|
+
})(InsurerStatus || (exports.InsurerStatus = InsurerStatus = {}));
|
|
10
|
+
//# sourceMappingURL=insurer-status.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insurer-status.enum.js","sourceRoot":"","sources":["../../src/enums/insurer-status.enum.ts"],"names":[],"mappings":";;;AASA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;IACrB,wCAAuB,CAAA;AACzB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Modality = void 0;
|
|
4
|
+
var Modality;
|
|
5
|
+
(function (Modality) {
|
|
6
|
+
Modality["PGBL"] = "PGBL";
|
|
7
|
+
Modality["VGBL"] = "VGBL";
|
|
8
|
+
Modality["ANY"] = "ANY";
|
|
9
|
+
})(Modality || (exports.Modality = Modality = {}));
|
|
10
|
+
//# sourceMappingURL=modality.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modality.enum.js","sourceRoot":"","sources":["../../src/enums/modality.enum.ts"],"names":[],"mappings":";;;AASA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,uBAAW,CAAA;AACb,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductStatus = void 0;
|
|
4
|
+
var ProductStatus;
|
|
5
|
+
(function (ProductStatus) {
|
|
6
|
+
ProductStatus["ACTIVE"] = "active";
|
|
7
|
+
ProductStatus["INACTIVE"] = "inactive";
|
|
8
|
+
ProductStatus["SUSPENDED"] = "suspended";
|
|
9
|
+
})(ProductStatus || (exports.ProductStatus = ProductStatus = {}));
|
|
10
|
+
//# sourceMappingURL=product-status.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-status.enum.js","sourceRoot":"","sources":["../../src/enums/product-status.enum.ts"],"names":[],"mappings":";;;AASA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;IACrB,wCAAuB,CAAA;AACzB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuotationStatus = void 0;
|
|
4
|
+
var QuotationStatus;
|
|
5
|
+
(function (QuotationStatus) {
|
|
6
|
+
QuotationStatus["PENDING"] = "pending";
|
|
7
|
+
QuotationStatus["COMPLETED"] = "completed";
|
|
8
|
+
QuotationStatus["EXPIRED"] = "expired";
|
|
9
|
+
QuotationStatus["CANCELLED"] = "cancelled";
|
|
10
|
+
})(QuotationStatus || (exports.QuotationStatus = QuotationStatus = {}));
|
|
11
|
+
//# sourceMappingURL=quotation-status.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotation-status.enum.js","sourceRoot":"","sources":["../../src/enums/quotation-status.enum.ts"],"names":[],"mappings":";;;AAUA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,0CAAuB,CAAA;IACvB,sCAAmB,CAAA;IACnB,0CAAuB,CAAA;AACzB,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RiskProfile = void 0;
|
|
4
|
+
var RiskProfile;
|
|
5
|
+
(function (RiskProfile) {
|
|
6
|
+
RiskProfile["CONSERVATIVE"] = "conservador";
|
|
7
|
+
RiskProfile["MODERATE"] = "moderado";
|
|
8
|
+
RiskProfile["BOLD"] = "arrojado";
|
|
9
|
+
RiskProfile["AGGRESSIVE"] = "agressivo";
|
|
10
|
+
})(RiskProfile || (exports.RiskProfile = RiskProfile = {}));
|
|
11
|
+
//# sourceMappingURL=risk-profile.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-profile.enum.js","sourceRoot":"","sources":["../../src/enums/risk-profile.enum.ts"],"names":[],"mappings":";;;AAUA,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,2CAA4B,CAAA;IAC5B,oCAAqB,CAAA;IACrB,gCAAiB,CAAA;IACjB,uCAAwB,CAAA;AAC1B,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaxRegime = void 0;
|
|
4
|
+
var TaxRegime;
|
|
5
|
+
(function (TaxRegime) {
|
|
6
|
+
TaxRegime["PROGRESSIVE"] = "progressivo";
|
|
7
|
+
TaxRegime["REGRESSIVE"] = "regressivo";
|
|
8
|
+
TaxRegime["ANY"] = "ANY";
|
|
9
|
+
})(TaxRegime || (exports.TaxRegime = TaxRegime = {}));
|
|
10
|
+
//# sourceMappingURL=tax-regime.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tax-regime.enum.js","sourceRoot":"","sources":["../../src/enums/tax-regime.enum.ts"],"names":[],"mappings":";;;AASA,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,sCAAyB,CAAA;IACzB,wBAAW,CAAA;AACb,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExceptionFilter, ArgumentsHost, HttpException } from '@nestjs/common';
|
|
2
|
+
export declare class AllExceptionsFilter implements ExceptionFilter {
|
|
3
|
+
private readonly logger;
|
|
4
|
+
constructor(loggerContext?: string);
|
|
5
|
+
catch(exception: unknown, host: ArgumentsHost): void;
|
|
6
|
+
private formatValidationErrors;
|
|
7
|
+
}
|
|
8
|
+
export declare class HttpExceptionFilter implements ExceptionFilter {
|
|
9
|
+
private readonly logger;
|
|
10
|
+
catch(exception: HttpException, host: ArgumentsHost): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
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 AllExceptionsFilter_1, HttpExceptionFilter_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.HttpExceptionFilter = exports.AllExceptionsFilter = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
let AllExceptionsFilter = AllExceptionsFilter_1 = class AllExceptionsFilter {
|
|
16
|
+
constructor(loggerContext) {
|
|
17
|
+
this.logger = new common_1.Logger(loggerContext || AllExceptionsFilter_1.name);
|
|
18
|
+
}
|
|
19
|
+
catch(exception, host) {
|
|
20
|
+
const ctx = host.switchToHttp();
|
|
21
|
+
const response = ctx.getResponse();
|
|
22
|
+
const request = ctx.getRequest();
|
|
23
|
+
let status = common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
24
|
+
let message = 'Internal server error';
|
|
25
|
+
let error = 'INTERNAL_SERVER_ERROR';
|
|
26
|
+
let validationErrors;
|
|
27
|
+
if (exception instanceof common_1.HttpException) {
|
|
28
|
+
status = exception.getStatus();
|
|
29
|
+
const exceptionResponse = exception.getResponse();
|
|
30
|
+
if (typeof exceptionResponse === 'string') {
|
|
31
|
+
message = exceptionResponse;
|
|
32
|
+
}
|
|
33
|
+
else if (typeof exceptionResponse === 'object') {
|
|
34
|
+
const responseObj = exceptionResponse;
|
|
35
|
+
message = responseObj.message || message;
|
|
36
|
+
error = responseObj.error || error;
|
|
37
|
+
if (Array.isArray(responseObj.message)) {
|
|
38
|
+
message = 'Validation failed';
|
|
39
|
+
validationErrors = this.formatValidationErrors(responseObj.message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (exception instanceof Error) {
|
|
44
|
+
message = exception.message;
|
|
45
|
+
error = exception.name;
|
|
46
|
+
}
|
|
47
|
+
this.logger.error(`${request.method} ${request.url} - Status: ${status} - Error: ${message}`, exception instanceof Error ? exception.stack : undefined);
|
|
48
|
+
const errorResponse = {
|
|
49
|
+
success: false,
|
|
50
|
+
message,
|
|
51
|
+
error,
|
|
52
|
+
statusCode: status,
|
|
53
|
+
timestamp: new Date().toISOString(),
|
|
54
|
+
path: request.url,
|
|
55
|
+
validationErrors,
|
|
56
|
+
};
|
|
57
|
+
if (process.env.NODE_ENV === 'development' && exception instanceof Error) {
|
|
58
|
+
errorResponse.stack = exception.stack;
|
|
59
|
+
}
|
|
60
|
+
response.status(status).json(errorResponse);
|
|
61
|
+
}
|
|
62
|
+
formatValidationErrors(errors) {
|
|
63
|
+
const formatted = {};
|
|
64
|
+
errors.forEach((error) => {
|
|
65
|
+
if (error.constraints) {
|
|
66
|
+
formatted[error.property] = Object.values(error.constraints);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return formatted;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.AllExceptionsFilter = AllExceptionsFilter;
|
|
73
|
+
exports.AllExceptionsFilter = AllExceptionsFilter = AllExceptionsFilter_1 = __decorate([
|
|
74
|
+
(0, common_1.Catch)(),
|
|
75
|
+
__metadata("design:paramtypes", [String])
|
|
76
|
+
], AllExceptionsFilter);
|
|
77
|
+
let HttpExceptionFilter = HttpExceptionFilter_1 = class HttpExceptionFilter {
|
|
78
|
+
constructor() {
|
|
79
|
+
this.logger = new common_1.Logger(HttpExceptionFilter_1.name);
|
|
80
|
+
}
|
|
81
|
+
catch(exception, host) {
|
|
82
|
+
const ctx = host.switchToHttp();
|
|
83
|
+
const response = ctx.getResponse();
|
|
84
|
+
const request = ctx.getRequest();
|
|
85
|
+
const status = exception.getStatus();
|
|
86
|
+
const exceptionResponse = exception.getResponse();
|
|
87
|
+
const message = typeof exceptionResponse === 'string'
|
|
88
|
+
? exceptionResponse
|
|
89
|
+
: exceptionResponse.message || 'An error occurred';
|
|
90
|
+
this.logger.error(`${request.method} ${request.url} - Status: ${status} - Error: ${message}`);
|
|
91
|
+
response.status(status).json({
|
|
92
|
+
success: false,
|
|
93
|
+
statusCode: status,
|
|
94
|
+
timestamp: new Date().toISOString(),
|
|
95
|
+
message,
|
|
96
|
+
error: typeof exceptionResponse === 'object' ? exceptionResponse : undefined,
|
|
97
|
+
path: request.url,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.HttpExceptionFilter = HttpExceptionFilter;
|
|
102
|
+
exports.HttpExceptionFilter = HttpExceptionFilter = HttpExceptionFilter_1 = __decorate([
|
|
103
|
+
(0, common_1.Catch)(common_1.HttpException)
|
|
104
|
+
], HttpExceptionFilter);
|
|
105
|
+
//# sourceMappingURL=http-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-exception.filter.js","sourceRoot":"","sources":["../../src/filters/http-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAOwB;AAuBjB,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAG9B,YAAY,aAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,aAAa,IAAI,qBAAmB,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,SAAkB,EAAE,IAAmB;QAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAE1C,IAAI,MAAM,GAAG,mBAAU,CAAC,qBAAqB,CAAC;QAC9C,IAAI,OAAO,GAAG,uBAAuB,CAAC;QACtC,IAAI,KAAK,GAAG,uBAAuB,CAAC;QACpC,IAAI,gBAAsD,CAAC;QAE3D,IAAI,SAAS,YAAY,sBAAa,EAAE,CAAC;YACvC,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,iBAAiB,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YAElD,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;gBAC1C,OAAO,GAAG,iBAAiB,CAAC;YAC9B,CAAC;iBAAM,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;gBACjD,MAAM,WAAW,GAAG,iBAAwB,CAAC;gBAC7C,OAAO,GAAG,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC;gBACzC,KAAK,G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AC,iBAAiB,CAAC,CAAC,CAAC,SAAS;YAC5E,IAAI,EAAE,OAAO,CAAC,GAAG;SAClB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA3BY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,EAAC,sBAAa,CAAC;GACR,mBAAmB,CA2B/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './http-exception.filter';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./http-exception.filter"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,0DAAwC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./enums"), exports);
|
|
18
|
+
__exportStar(require("./messaging"), exports);
|
|
19
|
+
__exportStar(require("./dto"), exports);
|
|
20
|
+
__exportStar(require("./interfaces"), exports);
|
|
21
|
+
__exportStar(require("./filters"), exports);
|
|
22
|
+
__exportStar(require("./interceptors"), exports);
|
|
23
|
+
__exportStar(require("./utils"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AASA,0CAAwB;AAGxB,8CAA4B;AAG5B,wCAAsB;AACtB,+CAA6B;AAG7B,4CAA0B;AAC1B,iDAA+B;AAG/B,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './logging.interceptor';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./logging.interceptor"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interceptors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,wDAAsC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
export interface LoggingInterceptorConfig {
|
|
4
|
+
logRequestBody?: boolean;
|
|
5
|
+
logResponseData?: boolean;
|
|
6
|
+
logQueryParams?: boolean;
|
|
7
|
+
loggerContext?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class LoggingInterceptor implements NestInterceptor {
|
|
10
|
+
private readonly logger;
|
|
11
|
+
private readonly config;
|
|
12
|
+
constructor(config?: LoggingInterceptorConfig);
|
|
13
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
14
|
+
}
|
|
15
|
+
export declare class SimpleLoggingInterceptor implements NestInterceptor {
|
|
16
|
+
private readonly logger;
|
|
17
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 LoggingInterceptor_1, SimpleLoggingInterceptor_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.SimpleLoggingInterceptor = exports.LoggingInterceptor = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const operators_1 = require("rxjs/operators");
|
|
16
|
+
let LoggingInterceptor = LoggingInterceptor_1 = class LoggingInterceptor {
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.config = {
|
|
19
|
+
logRequestBody: false,
|
|
20
|
+
logResponseData: false,
|
|
21
|
+
logQueryParams: false,
|
|
22
|
+
loggerContext: LoggingInterceptor_1.name,
|
|
23
|
+
...config,
|
|
24
|
+
};
|
|
25
|
+
this.logger = new common_1.Logger(this.config.loggerContext);
|
|
26
|
+
}
|
|
27
|
+
intercept(context, next) {
|
|
28
|
+
const request = context.switchToHttp().getRequest();
|
|
29
|
+
const { method, url, body, query } = request;
|
|
30
|
+
const startTime = Date.now();
|
|
31
|
+
this.logger.log(`→ Incoming Request: ${method} ${url}`);
|
|
32
|
+
if (this.config.logRequestBody && body && Object.keys(body).length > 0) {
|
|
33
|
+
this.logger.debug(`Request Body: ${JSON.stringify(body)}`);
|
|
34
|
+
}
|
|
35
|
+
if (this.config.logQueryParams && query && Object.keys(query).length > 0) {
|
|
36
|
+
this.logger.debug(`Query Params: ${JSON.stringify(query)}`);
|
|
37
|
+
}
|
|
38
|
+
return next.handle().pipe((0, operators_1.tap)({
|
|
39
|
+
next: (data) => {
|
|
40
|
+
const responseTime = Date.now() - startTime;
|
|
41
|
+
this.logger.log(`← Response: ${method} ${url} - ${responseTime}ms - ✓ Success`);
|
|
42
|
+
if (this.config.logResponseData && data) {
|
|
43
|
+
this.logger.debug(`Response Data: ${JSON.stringify(data)}`);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
error: (error) => {
|
|
47
|
+
const responseTime = Date.now() - startTime;
|
|
48
|
+
this.logger.error(`← Response: ${method} ${url} - ${responseTime}ms - ✗ Error: ${error.message}`, error.stack);
|
|
49
|
+
},
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.LoggingInterceptor = LoggingInterceptor;
|
|
54
|
+
exports.LoggingInterceptor = LoggingInterceptor = LoggingInterceptor_1 = __decorate([
|
|
55
|
+
(0, common_1.Injectable)(),
|
|
56
|
+
__metadata("design:paramtypes", [Object])
|
|
57
|
+
], LoggingInterceptor);
|
|
58
|
+
let SimpleLoggingInterceptor = SimpleLoggingInterceptor_1 = class SimpleLoggingInterceptor {
|
|
59
|
+
constructor() {
|
|
60
|
+
this.logger = new common_1.Logger(SimpleLoggingInterceptor_1.name);
|
|
61
|
+
}
|
|
62
|
+
intercept(context, next) {
|
|
63
|
+
const req = context.switchToHttp().getRequest();
|
|
64
|
+
const method = req.method;
|
|
65
|
+
const url = req.url;
|
|
66
|
+
const startTime = Date.now();
|
|
67
|
+
return next.handle().pipe((0, operators_1.tap)(() => this.logger.log(`${method} ${url} - ${Date.now() - startTime}ms`)));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.SimpleLoggingInterceptor = SimpleLoggingInterceptor;
|
|
71
|
+
exports.SimpleLoggingInterceptor = SimpleLoggingInterceptor = SimpleLoggingInterceptor_1 = __decorate([
|
|
72
|
+
(0, common_1.Injectable)()
|
|
73
|
+
], SimpleLoggingInterceptor);
|
|
74
|
+
//# sourceMappingURL=logging.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.interceptor.js","sourceRoot":"","sources":["../../src/interceptors/logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAMwB;AAExB,8CAAqC;AAyD9B,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAI7B,YAAY,MAAiC;QAC3C,IAAI,CAAC,MAAM,GAAG;YACZ,cAAc,EAAE,KAAK;YACrB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,oBAAkB,CAAC,IAAI;YACtC,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC;IAED,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAG7B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;QAGxD,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,IAAI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AI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAUtE,CAAC;IARC,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QAC1B,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;QACpB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,eAAG,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1G,CAAC;CACF,CAAA;AAXY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;GACA,wBAAwB,CAWpC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ApiResponse<T = any> {
|
|
2
|
+
success: boolean;
|
|
3
|
+
message?: string;
|
|
4
|
+
data?: T;
|
|
5
|
+
error?: string;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ApiErrorResponse {
|
|
9
|
+
success: false;
|
|
10
|
+
message: string;
|
|
11
|
+
error: string;
|
|
12
|
+
statusCode: number;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
path?: string;
|
|
15
|
+
stack?: string;
|
|
16
|
+
validationErrors?: Record<string, string[]>;
|
|
17
|
+
}
|
|
18
|
+
export declare class ResponseBuilder {
|
|
19
|
+
static success<T>(data: T, message?: string): ApiResponse<T>;
|
|
20
|
+
static error(error: string, message?: string): ApiResponse;
|
|
21
|
+
static detailedError(error: string, statusCode: number, message: string, path?: string, stack?: string, validationErrors?: Record<string, string[]>): ApiErrorResponse;
|
|
22
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseBuilder = void 0;
|
|
4
|
+
class ResponseBuilder {
|
|
5
|
+
static success(data, message) {
|
|
6
|
+
return {
|
|
7
|
+
success: true,
|
|
8
|
+
message,
|
|
9
|
+
data,
|
|
10
|
+
timestamp: new Date().toISOString(),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
static error(error, message) {
|
|
14
|
+
return {
|
|
15
|
+
success: false,
|
|
16
|
+
message,
|
|
17
|
+
error,
|
|
18
|
+
timestamp: new Date().toISOString(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static detailedError(error, statusCode, message, path, stack, validationErrors) {
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
message,
|
|
25
|
+
error,
|
|
26
|
+
statusCode,
|
|
27
|
+
timestamp: new Date().toISOString(),
|
|
28
|
+
path,
|
|
29
|
+
stack,
|
|
30
|
+
validationErrors,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ResponseBuilder = ResponseBuilder;
|
|
35
|
+
//# sourceMappingURL=api-response.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.interface.js","sourceRoot":"","sources":["../../src/interfaces/api-response.interface.ts"],"names":[],"mappings":";;;AAsFA,MAAa,eAAe;IAa1B,MAAM,CAAC,OAAO,CAAI,IAAO,EAAE,OAAgB;QACzC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO;YACP,IAAI;YACJ,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC;IACJ,CAAC;IAcD,MAAM,CAAC,KAAK,CAAC,KAAa,EAAE,OAAgB;QAC1C,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO;YACP,KAAK;YACL,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC;IACJ,CAAC;IAaD,MAAM,CAAC,aAAa,CAClB,KAAa,EACb,UAAkB,EAClB,OAAe,EACf,IAAa,EACb,KAAc,EACd,gBAA2C;QAE3C,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO;YACP,KAAK;YACL,UAAU;YACV,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI;YACJ,KAAK;YACL,gBAAgB;SACjB,CAAC;IACJ,CAAC;CACF;AAzED,0CAyEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './api-response.interface';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api-response.interface"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,2DAAyC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const EXCHANGES: {
|
|
2
|
+
readonly ACCOUNT: "account.exchange";
|
|
3
|
+
readonly USER: "user.exchange";
|
|
4
|
+
readonly AUTH: "auth.exchange";
|
|
5
|
+
readonly PRODUCT: "product.exchange";
|
|
6
|
+
readonly FUND: "fund.exchange";
|
|
7
|
+
readonly COVERAGE: "coverage.exchange";
|
|
8
|
+
readonly INSURER: "insurer.exchange";
|
|
9
|
+
readonly QUOTATION: "quotation.exchange";
|
|
10
|
+
};
|
|
11
|
+
export type ExchangeName = (typeof EXCHANGES)[keyof typeof EXCHANGES];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EXCHANGES = void 0;
|
|
4
|
+
exports.EXCHANGES = {
|
|
5
|
+
ACCOUNT: 'account.exchange',
|
|
6
|
+
USER: 'user.exchange',
|
|
7
|
+
AUTH: 'auth.exchange',
|
|
8
|
+
PRODUCT: 'product.exchange',
|
|
9
|
+
FUND: 'fund.exchange',
|
|
10
|
+
COVERAGE: 'coverage.exchange',
|
|
11
|
+
INSURER: 'insurer.exchange',
|
|
12
|
+
QUOTATION: 'quotation.exchange',
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=exchanges.js.map
|