@konplit-services/common 1.14.0 → 1.15.1

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.
@@ -19,6 +19,6 @@ export interface RefundBankPaymentStatusCheckEvent {
19
19
  responseData?: Record<string, any>;
20
20
  totalAmount: number;
21
21
  transactionDate: Date;
22
- fees: string;
22
+ fees: number;
23
23
  };
24
24
  }
@@ -151,4 +151,8 @@ export declare const error_codes: {
151
151
  error_code: string;
152
152
  code: number;
153
153
  };
154
+ DATABASE_ERROR: {
155
+ error_code: string;
156
+ code: number;
157
+ };
154
158
  };
@@ -159,4 +159,8 @@ exports.error_codes = {
159
159
  error_code: "GATEWAY_ERROR",
160
160
  code: 500002,
161
161
  },
162
+ DATABASE_ERROR: {
163
+ error_code: "DATABASE_ERROR",
164
+ code: 500005,
165
+ },
162
166
  };
@@ -0,0 +1,5 @@
1
+ export declare abstract class BaseRepository<T> {
2
+ protected Model: any;
3
+ constructor(model: any);
4
+ protected exec<R>(operation: () => Promise<R>): Promise<R>;
5
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BaseRepository = void 0;
13
+ const errors_1 = require("../../errors");
14
+ const helper_1 = require("../../helper");
15
+ class BaseRepository {
16
+ constructor(model) {
17
+ this.Model = model;
18
+ }
19
+ exec(operation) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ try {
22
+ return yield operation();
23
+ }
24
+ catch (err) {
25
+ throw new errors_1.DatabaseConnectionError("Database unavailable. Please retry.", helper_1.error_codes.DATABASE_ERROR);
26
+ }
27
+ });
28
+ }
29
+ }
30
+ exports.BaseRepository = BaseRepository;
@@ -1,2 +1,3 @@
1
1
  export * from "./interface/baseRepository";
2
2
  export * from "./interface/based";
3
+ export * from "./abstract/base-repository";
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./interface/baseRepository"), exports);
18
18
  __exportStar(require("./interface/based"), exports);
19
+ __exportStar(require("./abstract/base-repository"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.14.0",
3
+ "version": "1.15.1",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",