@6thbridge/utils 1.8.1 → 1.8.2-2
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/lib/actions/database-session.action.d.ts +13 -0
- package/lib/actions/database-session.action.js +74 -0
- package/lib/actions/database-session.action.js.map +1 -0
- package/lib/actions/database-session.action.test.d.ts +1 -0
- package/lib/actions/database-session.action.test.js +137 -0
- package/lib/actions/database-session.action.test.js.map +1 -0
- package/lib/actions/index.d.ts +2 -0
- package/lib/actions/index.js +2 -0
- package/lib/actions/index.js.map +1 -1
- package/lib/actions/lock.action.d.ts +16 -0
- package/lib/actions/lock.action.js +171 -0
- package/lib/actions/lock.action.js.map +1 -0
- package/lib/actions/lock.action.test.d.ts +1 -0
- package/lib/actions/lock.action.test.js +63 -0
- package/lib/actions/lock.action.test.js.map +1 -0
- package/lib/data/rabbitmq/index.d.ts +2 -2
- package/lib/database/MongoDBRepository.d.ts +0 -28
- package/lib/database/MongoDBTypeRepository.d.ts +0 -28
- package/lib/index.js +17 -7
- package/lib/index.js.map +1 -1
- package/lib/logger/redact.js +1 -1
- package/lib/logger/redact.js.map +1 -1
- package/lib/middlewares/common.js +3 -3
- package/lib/middlewares/common.js.map +1 -1
- package/lib/middlewares/error.middleware.js +18 -9
- package/lib/middlewares/error.middleware.js.map +1 -1
- package/lib/middlewares/express.js +19 -9
- package/lib/middlewares/express.js.map +1 -1
- package/lib/middlewares/index.js +17 -7
- package/lib/middlewares/index.js.map +1 -1
- package/lib/monitoring/index.js +3 -3
- package/lib/monitoring/index.js.map +1 -1
- package/lib/monitoring/rollbar.js +2 -2
- package/lib/monitoring/rollbar.js.map +1 -1
- package/lib/responses/express.js +3 -3
- package/lib/responses/index.js +17 -7
- package/lib/responses/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/context.entity.js +17 -7
- package/lib/types/context.entity.js.map +1 -1
- package/lib/utils/file.d.ts +3 -2
- package/lib/utils/file.js.map +1 -1
- package/lib/utils/phoneNumber.js +17 -7
- package/lib/utils/phoneNumber.js.map +1 -1
- package/lib/utils/validator.js +17 -7
- package/lib/utils/validator.js.map +1 -1
- package/lib/utils/validator.spec.js +17 -7
- package/lib/utils/validator.spec.js.map +1 -1
- package/package.json +3 -2
- package/readme.md +19 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContextEntity } from '../types';
|
|
2
|
+
import type { ClientSession, Model } from 'mongoose';
|
|
3
|
+
import type { Lock } from 'redlock';
|
|
4
|
+
export type DatabaseSessionActionOptions = {
|
|
5
|
+
lockKey?: string[];
|
|
6
|
+
lockTTLInSeconds?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class DatabaseSessionAction {
|
|
9
|
+
private static model;
|
|
10
|
+
static configure(model: Model<any>): void;
|
|
11
|
+
static withTransaction<T>(context: ContextEntity, action: (session: ClientSession | null, lock: Lock | null) => Promise<T>, options?: DatabaseSessionActionOptions): Promise<T>;
|
|
12
|
+
private static getModel;
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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.DatabaseSessionAction = void 0;
|
|
13
|
+
const lock_action_1 = require("./lock.action");
|
|
14
|
+
class DatabaseSessionAction {
|
|
15
|
+
static configure(model) {
|
|
16
|
+
this.model = model;
|
|
17
|
+
}
|
|
18
|
+
static withTransaction(context, action, options) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
let lock = null;
|
|
22
|
+
let session = null;
|
|
23
|
+
try {
|
|
24
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.lockKey) === null || _a === void 0 ? void 0 : _a.length) {
|
|
25
|
+
lock = yield lock_action_1.LockAction.acquireMultipleLocks(context, options.lockKey, options.lockTTLInSeconds || 10);
|
|
26
|
+
}
|
|
27
|
+
if (process.env.NODE_ENV !== 'production')
|
|
28
|
+
return yield action(null, lock);
|
|
29
|
+
session = yield this.getModel().startSession();
|
|
30
|
+
session.startTransaction();
|
|
31
|
+
const response = yield action(session, lock);
|
|
32
|
+
yield session.commitTransaction();
|
|
33
|
+
return response;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (session) {
|
|
37
|
+
try {
|
|
38
|
+
yield session.abortTransaction();
|
|
39
|
+
}
|
|
40
|
+
catch (cleanupError) {
|
|
41
|
+
context.logger.exception(cleanupError, { operation: 'endSession' });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
if (session) {
|
|
48
|
+
try {
|
|
49
|
+
yield session.endSession();
|
|
50
|
+
}
|
|
51
|
+
catch (cleanupError) {
|
|
52
|
+
context.logger.exception(cleanupError, { operation: 'endSession' });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (lock && ((_b = options === null || options === void 0 ? void 0 : options.lockKey) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
56
|
+
try {
|
|
57
|
+
yield lock_action_1.LockAction.releaseMultipleLock(context, lock, options.lockKey);
|
|
58
|
+
}
|
|
59
|
+
catch (cleanupError) {
|
|
60
|
+
context.logger.exception(cleanupError, { operation: 'releaseMultipleLock', keys: options.lockKey });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
static getModel() {
|
|
67
|
+
if (!this.model)
|
|
68
|
+
throw new Error('DatabaseSessionAction has not been configured');
|
|
69
|
+
return this.model;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.DatabaseSessionAction = DatabaseSessionAction;
|
|
73
|
+
DatabaseSessionAction.model = null;
|
|
74
|
+
//# sourceMappingURL=database-session.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-session.action.js","sourceRoot":"","sources":["../../src/actions/database-session.action.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,+CAA2C;AAO3C,MAAa,qBAAqB;IAGhC,MAAM,CAAC,SAAS,CAAC,KAAiB;QAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,CAAO,eAAe,CAC1B,OAAsB,EACtB,MAAwE,EACxE,OAAsC;;;YAEtC,IAAI,IAAI,GAAgB,IAAI,CAAC;YAC7B,IAAI,OAAO,GAAyB,IAAI,CAAC;YAEzC,IAAI,CAAC;gBACH,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,0CAAE,MAAM,EAAE,CAAC;oBAC7B,IAAI,GAAG,MAAM,wBAAU,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;gBACzG,CAAC;gBAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;oBAAE,OAAO,MAAM,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAE3E,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,CAAC;gBAC/C,OAAO,CAAC,gBAAgB,EAAE,CAAC;gBAE3B,MAAM,QAAQ,GAAG,MAAM,M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,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAElF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;;AA5DH,sDA6DC;AA5DgB,2BAAK,GAAsB,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const types_1 = require("../types");
|
|
16
|
+
const database_session_action_1 = require("./database-session.action");
|
|
17
|
+
const redlock_1 = __importDefault(require("redlock"));
|
|
18
|
+
const lock_action_1 = require("./lock.action");
|
|
19
|
+
const createLogger = () => ({
|
|
20
|
+
exception: jest.fn(),
|
|
21
|
+
});
|
|
22
|
+
const createContext = (logger) => {
|
|
23
|
+
const context = new types_1.ContextEntity();
|
|
24
|
+
context.logger = logger;
|
|
25
|
+
return context;
|
|
26
|
+
};
|
|
27
|
+
const createSession = (events) => ({
|
|
28
|
+
startTransaction: jest.fn(() => { events.push('start'); }),
|
|
29
|
+
commitTransaction: jest.fn(() => __awaiter(void 0, void 0, void 0, function* () { events.push('commit'); })),
|
|
30
|
+
abortTransaction: jest.fn(() => __awaiter(void 0, void 0, void 0, function* () { events.push('abort'); })),
|
|
31
|
+
endSession: jest.fn(() => __awaiter(void 0, void 0, void 0, function* () { events.push('end'); })),
|
|
32
|
+
});
|
|
33
|
+
const configureActions = (session, events) => {
|
|
34
|
+
const lock = { release: jest.fn(() => __awaiter(void 0, void 0, void 0, function* () { events.push('release'); })) };
|
|
35
|
+
const redisClient = { getRedisCommander: jest.fn().mockReturnValue({}) };
|
|
36
|
+
lock_action_1.LockAction.configure(redisClient);
|
|
37
|
+
jest.spyOn(redlock_1.default.prototype, 'acquire').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
events.push('acquire');
|
|
39
|
+
return lock;
|
|
40
|
+
}));
|
|
41
|
+
const model = {
|
|
42
|
+
startSession: jest.fn(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
events.push('session');
|
|
44
|
+
return session;
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
database_session_action_1.DatabaseSessionAction.configure(model);
|
|
48
|
+
return { redisClient };
|
|
49
|
+
};
|
|
50
|
+
describe('DatabaseSessionAction', () => {
|
|
51
|
+
const originalNodeEnv = process.env.NODE_ENV;
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
process.env.NODE_ENV = 'production';
|
|
54
|
+
});
|
|
55
|
+
afterEach(() => jest.restoreAllMocks());
|
|
56
|
+
afterAll(() => {
|
|
57
|
+
process.env.NODE_ENV = originalNodeEnv;
|
|
58
|
+
});
|
|
59
|
+
it('commits the callback result and cleans up its session and lock once', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
const events = [];
|
|
61
|
+
const session = createSession(events);
|
|
62
|
+
configureActions(session, events);
|
|
63
|
+
yield expect(database_session_action_1.DatabaseSessionAction.withTransaction(createContext(createLogger()), (activeSession) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
expect(activeSession).toBe(session);
|
|
65
|
+
events.push('action');
|
|
66
|
+
return 'done';
|
|
67
|
+
}), { lockKey: ['wallet:1'], lockTTLInSeconds: 5 })).resolves.toBe('done');
|
|
68
|
+
expect(events).toEqual(['acquire', 'session', 'start', 'action', 'commit', 'end', 'release']);
|
|
69
|
+
expect(session.abortTransaction).not.toHaveBeenCalled();
|
|
70
|
+
}));
|
|
71
|
+
it('skips sessions outside production while preserving the configured lock', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
+
process.env.NODE_ENV = 'development';
|
|
73
|
+
const events = [];
|
|
74
|
+
const session = createSession(events);
|
|
75
|
+
configureActions(session, events);
|
|
76
|
+
yield expect(database_session_action_1.DatabaseSessionAction.withTransaction(createContext(createLogger()), (activeSession) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
expect(activeSession).toBeNull();
|
|
78
|
+
events.push('action');
|
|
79
|
+
return 'done';
|
|
80
|
+
}), { lockKey: ['wallet:1'] })).resolves.toBe('done');
|
|
81
|
+
expect(events).toEqual(['acquire', 'action', 'release']);
|
|
82
|
+
expect(session.startTransaction).not.toHaveBeenCalled();
|
|
83
|
+
}));
|
|
84
|
+
it('aborts the transaction and still cleans up when the callback fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const events = [];
|
|
86
|
+
const session = createSession(events);
|
|
87
|
+
configureActions(session, events);
|
|
88
|
+
const error = new Error('write failed');
|
|
89
|
+
yield expect(database_session_action_1.DatabaseSessionAction.withTransaction(createContext(createLogger()), () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
events.push('action');
|
|
91
|
+
throw error;
|
|
92
|
+
}), { lockKey: ['wallet:1'] })).rejects.toThrow(error);
|
|
93
|
+
expect(events).toEqual(['acquire', 'session', 'start', 'action', 'abort', 'end', 'release']);
|
|
94
|
+
}));
|
|
95
|
+
it('aborts and cleans up when commit fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
const events = [];
|
|
97
|
+
const session = createSession(events);
|
|
98
|
+
const error = new Error('commit failed');
|
|
99
|
+
session.commitTransaction.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
events.push('commit');
|
|
101
|
+
throw error;
|
|
102
|
+
}));
|
|
103
|
+
configureActions(session, events);
|
|
104
|
+
yield expect(database_session_action_1.DatabaseSessionAction.withTransaction(createContext(createLogger()), () => __awaiter(void 0, void 0, void 0, function* () { return 'done'; }))).rejects.toThrow(error);
|
|
105
|
+
expect(events).toEqual(['session', 'start', 'commit', 'abort', 'end']);
|
|
106
|
+
}));
|
|
107
|
+
it('releases the lock when session creation fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
const events = [];
|
|
109
|
+
const session = createSession(events);
|
|
110
|
+
configureActions(session, events);
|
|
111
|
+
const error = new Error('session unavailable');
|
|
112
|
+
const model = { startSession: jest.fn().mockRejectedValue(error) };
|
|
113
|
+
database_session_action_1.DatabaseSessionAction.configure(model);
|
|
114
|
+
yield expect(database_session_action_1.DatabaseSessionAction.withTransaction(createContext(createLogger()), () => __awaiter(void 0, void 0, void 0, function* () { return 'done'; }), { lockKey: ['wallet:1'] })).rejects.toThrow(error);
|
|
115
|
+
expect(events).toEqual(['acquire', 'release']);
|
|
116
|
+
}));
|
|
117
|
+
it('logs cleanup failures with the caller context logger without replacing the callback result', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
+
const events = [];
|
|
119
|
+
const session = createSession(events);
|
|
120
|
+
const endError = new Error('end failed');
|
|
121
|
+
const releaseError = new Error('release failed');
|
|
122
|
+
session.endSession.mockRejectedValue(endError);
|
|
123
|
+
const logger = createLogger();
|
|
124
|
+
const lock = { release: jest.fn().mockRejectedValue(releaseError) };
|
|
125
|
+
const redisClient = { getRedisCommander: jest.fn().mockReturnValue({}) };
|
|
126
|
+
const model = { startSession: jest.fn().mockResolvedValue(session) };
|
|
127
|
+
lock_action_1.LockAction.configure(redisClient);
|
|
128
|
+
jest.spyOn(redlock_1.default.prototype, 'acquire').mockResolvedValue(lock);
|
|
129
|
+
database_session_action_1.DatabaseSessionAction.configure(model);
|
|
130
|
+
yield expect(database_session_action_1.DatabaseSessionAction.withTransaction(createContext(logger), () => __awaiter(void 0, void 0, void 0, function* () { return 'done'; }), { lockKey: ['wallet:1'] })).resolves.toBe('done');
|
|
131
|
+
expect(logger.exception).toHaveBeenCalledWith(endError, { operation: 'endSession' });
|
|
132
|
+
expect(logger.exception).toHaveBeenCalledWith(releaseError, expect.objectContaining({
|
|
133
|
+
errorCode: 'ResourceLockError',
|
|
134
|
+
}));
|
|
135
|
+
}));
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=database-session.action.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-session.action.test.js","sourceRoot":"","sources":["../../src/actions/database-session.action.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oCAAyC;AAIzC,uEAAkE;AAClE,sDAA8B;AAE9B,+CAA2C;AAK3C,MAAM,YAAY,GAAG,GAA4B,EAAE,CAAC,CAAC;IACnD,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;CACrB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,MAAkB,EAAiB,EAAE;IAC1D,MAAM,OAAO,GAAG,IAAI,qBAAa,EAAE,CAAC;IACpC,OAAO,CAAC,MAAM,GAAG,MAAyB,CAAC;IAC3C,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,MAAgB,EAA4B,EAAE,CAAC,CAAC;IACrE,gBAAgB,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,iBAAiB,EAAE,IAAI,CAAC,EAAE,CAAC,GAAS,EAAE,kDAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC;IAClE,gBAAgB,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C,iBAAiB,CAAC,OAAO,CAAC,EAA2B,CAAC;QAE9F,wBAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,iBAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACjE,+CAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEvC,MAAM,MAAM,CAAC,+CAAqB,CAAC,eAAe,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,GAAS,EAAE,kDAAC,OAAA,MAAM,CAAA,GAAA,EAAE,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhJ,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;QACrF,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,YAAY,EAAE,MAAM,CAAC,gBAAgB,CAAC;YAClF,SAAS,EAAE,mBAAmB;SAC/B,CAAC,CAAC,CAAC;IACN,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/actions/index.d.ts
CHANGED
package/lib/actions/index.js
CHANGED
|
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./database-session.action"), exports);
|
|
18
|
+
__exportStar(require("./lock.action"), exports);
|
|
17
19
|
__exportStar(require("./charge.action"), exports);
|
|
18
20
|
__exportStar(require("./charge.action"), exports);
|
|
19
21
|
__exportStar(require("./permission.action"), exports);
|
package/lib/actions/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,kDAAiC;AACjC,sDAAqC;AACrC,iDAAgC;AAEhC,uDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,gDAA8B;AAC9B,kDAAgC;AAChC,kDAAiC;AACjC,sDAAqC;AACrC,iDAAgC;AAEhC,uDAAqC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ContextEntity } from '../types';
|
|
2
|
+
import { RedisClient } from '../data/redis';
|
|
3
|
+
import Redlock from 'redlock';
|
|
4
|
+
import type { Lock } from 'redlock';
|
|
5
|
+
export type LockActionConfiguration = {
|
|
6
|
+
client: Redlock;
|
|
7
|
+
};
|
|
8
|
+
export declare class LockAction {
|
|
9
|
+
private static configuration;
|
|
10
|
+
static configure(redisClient: RedisClient): void;
|
|
11
|
+
static acquireMultipleLocks(context: ContextEntity, keys: string[], durationInSeconds: number): Promise<Lock>;
|
|
12
|
+
static getLock(context: ContextEntity, key: string, durationInSeconds: number): Promise<Lock>;
|
|
13
|
+
static releaseLock(context: ContextEntity, lock: Lock, key?: string): Promise<Lock>;
|
|
14
|
+
static releaseMultipleLock(context: ContextEntity, lock: Lock, keys: string[]): Promise<Lock>;
|
|
15
|
+
private static getConfiguration;
|
|
16
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.LockAction = void 0;
|
|
46
|
+
const types_1 = require("../types");
|
|
47
|
+
const logger_1 = require("../logger");
|
|
48
|
+
const redlock_1 = __importStar(require("redlock"));
|
|
49
|
+
class LockAction {
|
|
50
|
+
static configure(redisClient) {
|
|
51
|
+
const client = new redlock_1.default([redisClient.getRedisCommander()], {
|
|
52
|
+
driftFactor: 0.01,
|
|
53
|
+
retryCount: 20,
|
|
54
|
+
retryDelay: 2000,
|
|
55
|
+
retryJitter: 200,
|
|
56
|
+
automaticExtensionThreshold: 500,
|
|
57
|
+
});
|
|
58
|
+
client.on('error', (error) => {
|
|
59
|
+
if (error instanceof redlock_1.ResourceLockedError) {
|
|
60
|
+
logger_1.logger.error('ResourceLockedError', {
|
|
61
|
+
logType: 'resource-locked-error',
|
|
62
|
+
message: error.message,
|
|
63
|
+
stack: new Error('resource-locked-error').stack,
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
logger_1.logger.exception(error, {
|
|
68
|
+
tag: 'redlock-exception',
|
|
69
|
+
stack: new Error('redlock-exception').stack,
|
|
70
|
+
status: 400,
|
|
71
|
+
});
|
|
72
|
+
logger_1.logger.error('RedLockError', {
|
|
73
|
+
logType: 'red-lock-error',
|
|
74
|
+
message: error.message,
|
|
75
|
+
stack: new Error('red-lock-error').stack,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
this.configuration = { client };
|
|
79
|
+
}
|
|
80
|
+
static acquireMultipleLocks(context, keys, durationInSeconds) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const uniqueKeys = [...new Set(keys)];
|
|
83
|
+
const { client } = this.getConfiguration();
|
|
84
|
+
try {
|
|
85
|
+
return yield client.acquire(uniqueKeys, durationInSeconds * 1000);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
context.logger.exception(error, {
|
|
89
|
+
logType: 'RedlockSecurityException',
|
|
90
|
+
errorCode: 'ResourceLockError',
|
|
91
|
+
keys,
|
|
92
|
+
durationInSeconds,
|
|
93
|
+
});
|
|
94
|
+
throw new types_1.CustomException({
|
|
95
|
+
message: `Security Exception: Oops! We are unable to get resources lock on ${keys.join('|')}. Please try again`,
|
|
96
|
+
errorCode: 'ResourceLockError',
|
|
97
|
+
statusCode: 400,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
static getLock(context, key, durationInSeconds) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const { client } = this.getConfiguration();
|
|
105
|
+
try {
|
|
106
|
+
return yield client.acquire([key], durationInSeconds * 1000);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
context.logger.exception(error, {
|
|
110
|
+
logType: 'RedlockSecurityException',
|
|
111
|
+
errorCode: 'ResourceLockError',
|
|
112
|
+
message: `Security Exception: Oops! We are unable to release lock for resource ${key}. Please try again`,
|
|
113
|
+
key,
|
|
114
|
+
durationInSeconds,
|
|
115
|
+
status: 499,
|
|
116
|
+
});
|
|
117
|
+
throw new types_1.CustomException({
|
|
118
|
+
message: `Security Exception: Oops! We are unable to get resource lock on ${key}. Please try again`,
|
|
119
|
+
errorCode: 'ResourceLockError',
|
|
120
|
+
statusCode: 400,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
static releaseLock(context, lock, key) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
this.getConfiguration();
|
|
128
|
+
try {
|
|
129
|
+
yield lock.release();
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
context.logger.exception(error, {
|
|
133
|
+
logType: 'RedlockSecurityException',
|
|
134
|
+
key,
|
|
135
|
+
message: `Security Exception: Oops! We are unable to release lock for resource ${key}. Please try again`,
|
|
136
|
+
errorCode: 'ResourceLockError',
|
|
137
|
+
tag: 'releaseWalletLock',
|
|
138
|
+
status: 499,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return lock;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
static releaseMultipleLock(context, lock, keys) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
this.getConfiguration();
|
|
147
|
+
try {
|
|
148
|
+
yield lock.release();
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
context.logger.exception(error, {
|
|
152
|
+
logType: 'RedlockSecurityException',
|
|
153
|
+
keys,
|
|
154
|
+
message: `Security Exception: Oops! We are unable to release lock for resources ${keys.join('|')}. Please try again`,
|
|
155
|
+
errorCode: 'ResourceLockError',
|
|
156
|
+
tag: 'releaseWalletLock',
|
|
157
|
+
status: 499,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return lock;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
static getConfiguration() {
|
|
164
|
+
if (!this.configuration)
|
|
165
|
+
throw new Error('LockAction has not been configured');
|
|
166
|
+
return this.configuration;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.LockAction = LockAction;
|
|
170
|
+
LockAction.configuration = null;
|
|
171
|
+
//# sourceMappingURL=lock.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.action.js","sourceRoot":"","sources":["../../src/actions/lock.action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAA0D;AAE1D,sCAAmC;AACnC,mDAAuD;AAOvD,MAAa,UAAU;IAGrB,MAAM,CAAC,SAAS,CAAC,WAAwB;QACvC,MAAM,MAAM,GAAG,IAAI,iBAAO,CAAC,CAAC,WAAW,CAAC,iBAAiB,EAAS,CAAC,EAAE;YACnE,WAAW,EAAE,IAAI;YACjB,UAA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+
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const types_1 = require("../types");
|
|
16
|
+
const redlock_1 = __importDefault(require("redlock"));
|
|
17
|
+
const lock_action_1 = require("./lock.action");
|
|
18
|
+
const createLogger = () => ({
|
|
19
|
+
exception: jest.fn(),
|
|
20
|
+
});
|
|
21
|
+
const createContext = (logger) => {
|
|
22
|
+
const context = new types_1.ContextEntity();
|
|
23
|
+
context.logger = logger;
|
|
24
|
+
return context;
|
|
25
|
+
};
|
|
26
|
+
const configureLockAction = () => {
|
|
27
|
+
const redisClient = { getRedisCommander: jest.fn().mockReturnValue({}) };
|
|
28
|
+
lock_action_1.LockAction.configure(redisClient);
|
|
29
|
+
return jest.spyOn(redlock_1.default.prototype, 'acquire');
|
|
30
|
+
};
|
|
31
|
+
describe('LockAction', () => {
|
|
32
|
+
afterEach(() => jest.restoreAllMocks());
|
|
33
|
+
it('requires configuration before use', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
yield expect(lock_action_1.LockAction.getLock(createContext(createLogger()), 'wallet:1', 5)).rejects.toThrow('LockAction has not been configured');
|
|
35
|
+
}));
|
|
36
|
+
it('deduplicates keys and converts the TTL to milliseconds', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const lock = { release: jest.fn() };
|
|
38
|
+
const acquire = configureLockAction().mockResolvedValue(lock);
|
|
39
|
+
yield expect(lock_action_1.LockAction.acquireMultipleLocks(createContext(createLogger()), ['wallet:1', 'wallet:1', 'wallet:2'], 5)).resolves.toBe(lock);
|
|
40
|
+
expect(acquire).toHaveBeenCalledWith(['wallet:1', 'wallet:2'], 5000);
|
|
41
|
+
}));
|
|
42
|
+
it('logs acquisition failures with the caller context logger', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
const error = new Error('locked');
|
|
44
|
+
const logger = createLogger();
|
|
45
|
+
configureLockAction().mockRejectedValue(error);
|
|
46
|
+
yield expect(lock_action_1.LockAction.getLock(createContext(logger), 'wallet:1', 5)).rejects.toEqual(expect.any(types_1.CustomException));
|
|
47
|
+
expect(logger.exception).toHaveBeenCalledWith(error, expect.objectContaining({
|
|
48
|
+
errorCode: 'ResourceLockError',
|
|
49
|
+
key: 'wallet:1',
|
|
50
|
+
}));
|
|
51
|
+
}));
|
|
52
|
+
it('logs a release failure with the caller context logger and returns the lock', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const error = new Error('release failed');
|
|
54
|
+
const lock = { release: jest.fn().mockRejectedValue(error) };
|
|
55
|
+
const logger = createLogger();
|
|
56
|
+
configureLockAction();
|
|
57
|
+
yield expect(lock_action_1.LockAction.releaseMultipleLock(createContext(logger), lock, ['wallet:1', 'wallet:1'])).resolves.toBe(lock);
|
|
58
|
+
expect(logger.exception).toHaveBeenCalledWith(error, expect.objectContaining({
|
|
59
|
+
keys: ['wallet:1', 'wallet:1'],
|
|
60
|
+
}));
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=lock.action.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.action.test.js","sourceRoot":"","sources":["../../src/actions/lock.action.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oCAA0D;AAG1D,sDAA8B;A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a,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExH,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC;YAC3E,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;SAC/B,CAAC,CAAC,CAAC;IACN,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -50,8 +50,8 @@ export declare class RabbitMQClient {
|
|
|
50
50
|
publishToExchange(exchangeName: string, routeKey: string | undefined, payload: any, options?: PublishOptions): Promise<boolean>;
|
|
51
51
|
static publishToExchange(exchangeName: string, routeKey: string | undefined, payload: any, options?: PublishOptions): Promise<boolean>;
|
|
52
52
|
static sendToDeadLetter(deadLetterEntity: BrokerDeadLetterPayloadEntity): Promise<boolean>;
|
|
53
|
-
listen(queueName: string, options: any, callback: (payload: string, options: Record<string, any>) => void): Promise<void>;
|
|
54
|
-
static listen(queueName: string, options: any, callback: (payload: string, options: Record<string, any>) => void): Promise<void>;
|
|
53
|
+
listen(queueName: string, options: any | undefined, callback: (payload: string, options: Record<string, any>) => void): Promise<void>;
|
|
54
|
+
static listen(queueName: string, options: any | undefined, callback: (payload: string, options: Record<string, any>) => void): Promise<void>;
|
|
55
55
|
static requeueDeadLetter(deadLetterQueueName: string, queueOptions?: any): Promise<void>;
|
|
56
56
|
static sendToRetry(brokerPayload: BrokerRetryEntity): Promise<boolean>;
|
|
57
57
|
close(): void;
|
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
-
/// <reference types="mongoose/types/callback" />
|
|
3
|
-
/// <reference types="mongoose/types/collection" />
|
|
4
|
-
/// <reference types="mongoose/types/connection" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor" />
|
|
6
|
-
/// <reference types="mongoose/types/document" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/session" />
|
|
19
|
-
/// <reference types="mongoose/types/types" />
|
|
20
|
-
/// <reference types="mongoose/types/utility" />
|
|
21
|
-
/// <reference types="mongoose/types/validation" />
|
|
22
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
23
|
-
/// <reference types="mongoose/types/tracing" />
|
|
24
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
25
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
26
|
-
/// <reference types="mongoose/types/inferhydrateddoctype" />
|
|
27
|
-
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
28
|
-
/// <reference types="mongoose-paginate-v2" />
|
|
29
1
|
import { ClientSession, CreateOptions, InsertManyOptions, Model, PaginateModel, PaginateResult, ProjectionType, QueryOptions } from 'mongoose';
|
|
30
2
|
export declare class MongooseOptions {
|
|
31
3
|
session?: ClientSession | null;
|
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
-
/// <reference types="mongoose/types/callback" />
|
|
3
|
-
/// <reference types="mongoose/types/collection" />
|
|
4
|
-
/// <reference types="mongoose/types/connection" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor" />
|
|
6
|
-
/// <reference types="mongoose/types/document" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/session" />
|
|
19
|
-
/// <reference types="mongoose/types/types" />
|
|
20
|
-
/// <reference types="mongoose/types/utility" />
|
|
21
|
-
/// <reference types="mongoose/types/validation" />
|
|
22
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
23
|
-
/// <reference types="mongoose/types/tracing" />
|
|
24
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
25
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
26
|
-
/// <reference types="mongoose/types/inferhydrateddoctype" />
|
|
27
|
-
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
28
|
-
/// <reference types="mongoose-paginate-v2" />
|
|
29
1
|
import { ClientSession, CreateOptions, ProjectionType, QueryOptions, PaginateResult, PaginateModel, Document, Model, InsertManyOptions, QueryFilter, UpdateQuery, Query, SortOrder } from 'mongoose';
|
|
30
2
|
declare class MongooseOptions {
|
|
31
3
|
session?: ClientSession | null;
|