@misterhomer1992/miit-bot-payment 1.0.3 → 1.0.4
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/payments/api.d.ts +26 -1
- package/dist/modules/payments/api.d.ts.map +1 -1
- package/dist/modules/payments/api.js +35 -5
- package/dist/modules/payments/api.js.map +1 -1
- package/dist/modules/payments/index.d.ts +1 -0
- package/dist/modules/payments/index.d.ts.map +1 -1
- package/dist/modules/payments/index.js +1 -0
- package/dist/modules/payments/index.js.map +1 -1
- package/dist/modules/payments/utils.d.ts +12 -1
- package/dist/modules/payments/utils.d.ts.map +1 -1
- package/dist/modules/payments/utils.js +24 -0
- package/dist/modules/payments/utils.js.map +1 -1
- package/dist/modules/user/index.d.ts +4 -0
- package/dist/modules/user/index.d.ts.map +1 -0
- package/dist/modules/user/index.js +20 -0
- package/dist/modules/user/index.js.map +1 -0
- package/dist/modules/user/types.d.ts +78 -0
- package/dist/modules/user/types.d.ts.map +1 -0
- package/dist/modules/user/types.js +3 -0
- package/dist/modules/user/types.js.map +1 -0
- package/dist/modules/user/userRepository.d.ts +61 -19
- package/dist/modules/user/userRepository.d.ts.map +1 -1
- package/dist/modules/user/userRepository.js +72 -35
- package/dist/modules/user/userRepository.js.map +1 -1
- package/dist/modules/user/userService.d.ts +54 -0
- package/dist/modules/user/userService.d.ts.map +1 -0
- package/dist/modules/user/userService.js +92 -0
- package/dist/modules/user/userService.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./modules/payments"), exports);
|
|
18
18
|
__exportStar(require("./modules/invoice"), exports);
|
|
19
19
|
__exportStar(require("./modules/subscription"), exports);
|
|
20
|
+
__exportStar(require("./modules/user"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,oDAAkC;AAClC,yDAAuC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,oDAAkC;AAClC,yDAAuC;AACvC,iDAA+B"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { AppNamespace } from '../app/types';
|
|
2
|
+
interface WayforpayResponse {
|
|
3
|
+
url?: string;
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Creates a payment API URL for regular purchases via Wayforpay.
|
|
4
8
|
* Generates a unique order reference and creates a payment URL with the provided parameters.
|
|
@@ -30,5 +34,26 @@ declare function createPaymentAPI({ userId, appNamespace, productName, productPr
|
|
|
30
34
|
url: string;
|
|
31
35
|
orderReference: string;
|
|
32
36
|
} | null>;
|
|
33
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Edits an existing regular purchase via Wayforpay.
|
|
39
|
+
* Updates the parameters of an existing recurring payment schedule.
|
|
40
|
+
*
|
|
41
|
+
* @param params - Parameters for editing the regular purchase
|
|
42
|
+
* @param params.orderReference - The unique reference of the order to edit
|
|
43
|
+
* @param params.amount - The new payment amount
|
|
44
|
+
* @param params.dateBegin - The start date for the regular purchase in DD.MM.YYYY format
|
|
45
|
+
* @param params.dateEnd - The end date for the regular purchase in DD.MM.YYYY format
|
|
46
|
+
* @param params.regularMode - The frequency mode for regular payments
|
|
47
|
+
* @returns Promise resolving to the Wayforpay API response
|
|
48
|
+
* @throws Error with code 'EDIT_REGULAR_PURCHASE_API' if the API response is invalid
|
|
49
|
+
*/
|
|
50
|
+
declare function editRegularPurchaseAPI({ orderReference, amount, dateBegin, dateEnd, regularMode, currency, }: {
|
|
51
|
+
orderReference: string;
|
|
52
|
+
amount: number;
|
|
53
|
+
dateBegin: string;
|
|
54
|
+
dateEnd: string;
|
|
55
|
+
regularMode: 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
56
|
+
currency: string;
|
|
57
|
+
}): Promise<WayforpayResponse>;
|
|
58
|
+
export { createPaymentAPI, editRegularPurchaseAPI };
|
|
34
59
|
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C,UAAU,iBAAiB;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAe,gBAAgB,CAAC,EAC5B,MAAM,EACN,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAgB,EAChB,WAAqB,EACrB,QAAe,GAClB,EAAE;IACC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAoC1D;AAED;;;;;;;;;;;;GAYG;AACH,iBAAe,sBAAsB,CAAC,EAClC,cAAc,EACd,MAAM,EACN,SAAS,EACT,OAAO,EACP,WAAW,EACX,QAAQ,GACX,EAAE;IACC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACvD,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAmB7B;AAED,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -4,9 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createPaymentAPI = createPaymentAPI;
|
|
7
|
+
exports.editRegularPurchaseAPI = editRegularPurchaseAPI;
|
|
7
8
|
const moment_1 = __importDefault(require("moment"));
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
|
-
// @ts-ignore - Package may not have type declarations
|
|
10
9
|
const wayforpay_api_1 = require("@misterhomer1992/wayforpay-api");
|
|
11
10
|
const utils_1 = require("../../utils");
|
|
12
11
|
const utils_2 = require("./utils");
|
|
@@ -35,7 +34,7 @@ async function createPaymentAPI({ userId, appNamespace, productName, productPric
|
|
|
35
34
|
planId,
|
|
36
35
|
utcDate: formattedUtc,
|
|
37
36
|
});
|
|
38
|
-
const response = (await (0, wayforpay_api_1.
|
|
37
|
+
const response = (await (0, wayforpay_api_1.generateRegularPurchase)({
|
|
39
38
|
merchantAccount: process.env.WAYFORPAY_MERCHANT_ACCOUNT,
|
|
40
39
|
merchantDomainName: process.env.WAYFORPAY_MERCHANT_DOMAIN,
|
|
41
40
|
merchantSecretKey: process.env.WAYFORPAY_MERCHANT_SECRET_KEY,
|
|
@@ -43,8 +42,8 @@ async function createPaymentAPI({ userId, appNamespace, productName, productPric
|
|
|
43
42
|
orderReference,
|
|
44
43
|
productName: [productName],
|
|
45
44
|
productPrice: [productPrice],
|
|
46
|
-
currency,
|
|
47
|
-
language,
|
|
45
|
+
currency: currency,
|
|
46
|
+
language: language,
|
|
48
47
|
serviceUrl: process.env.WAYFORPAY_SERVICE_URL,
|
|
49
48
|
regularMode,
|
|
50
49
|
regularCount,
|
|
@@ -60,4 +59,35 @@ async function createPaymentAPI({ userId, appNamespace, productName, productPric
|
|
|
60
59
|
orderReference,
|
|
61
60
|
};
|
|
62
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Edits an existing regular purchase via Wayforpay.
|
|
64
|
+
* Updates the parameters of an existing recurring payment schedule.
|
|
65
|
+
*
|
|
66
|
+
* @param params - Parameters for editing the regular purchase
|
|
67
|
+
* @param params.orderReference - The unique reference of the order to edit
|
|
68
|
+
* @param params.amount - The new payment amount
|
|
69
|
+
* @param params.dateBegin - The start date for the regular purchase in DD.MM.YYYY format
|
|
70
|
+
* @param params.dateEnd - The end date for the regular purchase in DD.MM.YYYY format
|
|
71
|
+
* @param params.regularMode - The frequency mode for regular payments
|
|
72
|
+
* @returns Promise resolving to the Wayforpay API response
|
|
73
|
+
* @throws Error with code 'EDIT_REGULAR_PURCHASE_API' if the API response is invalid
|
|
74
|
+
*/
|
|
75
|
+
async function editRegularPurchaseAPI({ orderReference, amount, dateBegin, dateEnd, regularMode, currency, }) {
|
|
76
|
+
const response = await (0, wayforpay_api_1.editRegularPurchase)({
|
|
77
|
+
merchantAccount: process.env.WAYFORPAY_MERCHANT_ACCOUNT,
|
|
78
|
+
merchantPassword: process.env.WAYFORPAY_MERCHANT_PASSWORD,
|
|
79
|
+
orderReference,
|
|
80
|
+
amount,
|
|
81
|
+
dateBegin,
|
|
82
|
+
dateEnd,
|
|
83
|
+
regularMode,
|
|
84
|
+
currency: currency,
|
|
85
|
+
});
|
|
86
|
+
if (!(0, utils_1.isObject)(response)) {
|
|
87
|
+
throw {
|
|
88
|
+
code: 'EDIT_REGULAR_PURCHASE_API',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return response;
|
|
92
|
+
}
|
|
63
93
|
//# sourceMappingURL=api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/modules/payments/api.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/modules/payments/api.ts"],"names":[],"mappings":";;;;;AAuIS,4CAAgB;AAAE,wDAAsB;AAvIjD,oDAA4B;AAC5B,kEAAkH;AAElH,uCAA2D;AAC3D,mCAA+C;AAO/C;;;;;;;;;;;;;;;GAeG;AACH,KAAK,UAAU,gBAAgB,CAAC,EAC5B,MAAM,EACN,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,GAAG,CAAC,EAChB,WAAW,GAAG,OAAO,EACrB,QAAQ,GAAG,IAAI,GAYlB;IACG,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAA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ACd,MAAM;QACN,SAAS;QACT,OAAO;QACP,WAAW;QACX,QAAQ,EAAE,QAAoB;KACjC,CAAC,CAAC;IAEH,IAAI,CAAC,IAAA,gBAAQ,EAAC,QAAQ,CAAC,EAAE,CAAC;QACtB,MAAM;YACF,IAAI,EAAE,2BAA2B;SACpC,CAAC;IACN,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/payments/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,wCAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/payments/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,wCAAsB;AACtB,0CAAwB"}
|
|
@@ -5,5 +5,16 @@ declare function createOrderReference({ userId, appNamespace, planId, utcDate, }
|
|
|
5
5
|
planId: string;
|
|
6
6
|
utcDate: string;
|
|
7
7
|
}): string;
|
|
8
|
-
export
|
|
8
|
+
export interface ParsedReferenceString {
|
|
9
|
+
appName: string;
|
|
10
|
+
appNamespace: AppNamespace;
|
|
11
|
+
serviceType: string;
|
|
12
|
+
userId: string;
|
|
13
|
+
planId: string;
|
|
14
|
+
version: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
chargeId?: string;
|
|
17
|
+
}
|
|
18
|
+
declare function parseOrderReference(referenceString: string): ParsedReferenceString | null;
|
|
19
|
+
export { createOrderReference, parseOrderReference };
|
|
9
20
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,iBAAS,oBAAoB,CAAC,EAC1B,MAAM,EACN,YAAY,EACZ,MAAM,EACN,OAAO,GACV,EAAE;IACC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAET;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,iBAAS,oBAAoB,CAAC,EAC1B,MAAM,EACN,YAAY,EACZ,MAAM,EACN,OAAO,GACV,EAAE;IACC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAET;AAED,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,iBAAS,mBAAmB,CAAC,eAAe,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CA2BlF;AAED,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOrderReference = createOrderReference;
|
|
4
|
+
exports.parseOrderReference = parseOrderReference;
|
|
4
5
|
function createOrderReference({ userId, appNamespace, planId, utcDate, }) {
|
|
5
6
|
return `miia_${appNamespace}_bot_${userId}_${planId}_v1_${utcDate}`;
|
|
6
7
|
}
|
|
8
|
+
function parseOrderReference(referenceString) {
|
|
9
|
+
// `miia_${appNamespace}_bot_${userId}_${planId}_v1_${formattedUtc}`;
|
|
10
|
+
const [appName, appNamespace, serviceType, userId, planId, version, timestamp, chargeId] = referenceString.split('_');
|
|
11
|
+
if (typeof appName !== 'string' ||
|
|
12
|
+
typeof appNamespace !== 'string' ||
|
|
13
|
+
typeof serviceType !== 'string' ||
|
|
14
|
+
typeof userId !== 'string' ||
|
|
15
|
+
typeof planId !== 'string' ||
|
|
16
|
+
typeof version !== 'string' ||
|
|
17
|
+
typeof timestamp !== 'string') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
appName,
|
|
22
|
+
appNamespace: appNamespace,
|
|
23
|
+
serviceType,
|
|
24
|
+
userId,
|
|
25
|
+
planId,
|
|
26
|
+
version,
|
|
27
|
+
timestamp,
|
|
28
|
+
chargeId,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
7
31
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/modules/payments/utils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/modules/payments/utils.ts"],"names":[],"mappings":";;AAwDS,oDAAoB;AAAE,kDAAmB;AAtDlD,SAAS,oBAAoB,CAAC,EAC1B,MAAM,EACN,YAAY,EACZ,MAAM,EACN,OAAO,GAMV;IACG,OAAO,QAAQ,YAAY,QAAQ,MAAM,IAAI,MAAM,OAAO,OAAO,EAAE,CAAC;AACxE,CAAC;AAaD,SAAS,mBAAmB,CAAC,eAAuB;IAChD,qEAAqE;IACrE,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,GACpF,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE/B,IACI,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,YAAY,KAAK,QAAQ;QAChC,OAAO,WAAW,KAAK,QAAQ;QAC/B,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,SAAS,KAAK,QAAQ,EAC/B,CAAC;QACC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO;QACH,OAAO;QACP,YAAY,EAAE,YAA4B;QAC1C,WAAW;QACX,MAAM;QACN,MAAM;QACN,OAAO;QACP,SAAS;QACT,QAAQ;KACX,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./userRepository"), exports);
|
|
18
|
+
__exportStar(require("./userService"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/user/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,gDAA8B;AAC9B,0CAAwB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { NestedPathsAccess } from '../../types/utilities';
|
|
2
|
+
import { AppNamespace } from '../app/types';
|
|
3
|
+
export interface User {
|
|
4
|
+
user: {
|
|
5
|
+
id: string;
|
|
6
|
+
lastUpdate: null | string;
|
|
7
|
+
name: null | string;
|
|
8
|
+
};
|
|
9
|
+
subscription: {
|
|
10
|
+
isActive: boolean;
|
|
11
|
+
isTrial: boolean;
|
|
12
|
+
payments?: {
|
|
13
|
+
planId: string;
|
|
14
|
+
orderReference: string;
|
|
15
|
+
url: string;
|
|
16
|
+
createdDate: string;
|
|
17
|
+
}[];
|
|
18
|
+
paymentUrlMessageId?: number;
|
|
19
|
+
};
|
|
20
|
+
personality?: string;
|
|
21
|
+
messages: Record<string, Record<string, unknown>>;
|
|
22
|
+
commands?: Record<string, unknown>;
|
|
23
|
+
keyboardContext?: Record<string, unknown>;
|
|
24
|
+
settings: {
|
|
25
|
+
voiceResponse: boolean;
|
|
26
|
+
languageCode: string;
|
|
27
|
+
activeMessageThread: string;
|
|
28
|
+
requestCount: number;
|
|
29
|
+
imageAutoDetection: boolean;
|
|
30
|
+
imageResolution: string;
|
|
31
|
+
activeKeyboardMessageId?: number;
|
|
32
|
+
hasFakeImage?: boolean;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface UserAnalytics {
|
|
36
|
+
id: string;
|
|
37
|
+
platform: AppNamespace;
|
|
38
|
+
createdDate: string;
|
|
39
|
+
chatGPT: {
|
|
40
|
+
completions: Partial<Record<number, {
|
|
41
|
+
requestTokensCount: number;
|
|
42
|
+
responseTokensCount: number;
|
|
43
|
+
}>>;
|
|
44
|
+
image: {
|
|
45
|
+
create?: {
|
|
46
|
+
'11': {
|
|
47
|
+
count: number;
|
|
48
|
+
inputImageTokens: number;
|
|
49
|
+
outputImageTokens: number;
|
|
50
|
+
inputTextTokens: number;
|
|
51
|
+
};
|
|
52
|
+
'12': {
|
|
53
|
+
count: number;
|
|
54
|
+
};
|
|
55
|
+
'18': {
|
|
56
|
+
count: number;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
vision: Partial<Record<number, {
|
|
60
|
+
requestTokensCount: number;
|
|
61
|
+
responseTokensCount: number;
|
|
62
|
+
}>>;
|
|
63
|
+
};
|
|
64
|
+
speechToText: {
|
|
65
|
+
'whisper-1': {
|
|
66
|
+
seconds: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
textToSpeech: {
|
|
70
|
+
'tts-1': {
|
|
71
|
+
charsCount: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export type UserFieldPath = NestedPathsAccess<User>;
|
|
77
|
+
export type UserFieldAnalyticsPath = NestedPathsAccess<UserAnalytics>;
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/user/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,WAAW,IAAI;IACjB,IAAI,EAAE;QACF,EAAE,EAAE,MAAM,CAAC;QACX,UAAU,EAAE,IAAI,GAAG,MAAM,CAAC;QAC1B,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,YAAY,EAAE;QACV,QAAQ,EAAE,OAAO,CAAC;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE;YACP,MAAM,EAAE,MAAM,CAAC;YACf,cAAc,EAAE,MAAM,CAAC;YACvB,GAAG,EAAE,MAAM,CAAC;YACZ,WAAW,EAAE,MAAM,CAAC;SACvB,EAAE,CAAC;QACJ,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAChC,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,EAAE;QACN,aAAa,EAAE,OAAO,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,YAAY,EAAE,MAAM,CAAC;QACrB,kBAAkB,EAAE,OAA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
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/user/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +1,64 @@
|
|
|
1
1
|
import { FieldValue } from 'firebase-admin/firestore';
|
|
2
|
-
import { User,
|
|
2
|
+
import { User, UserFieldPath } from './types';
|
|
3
3
|
import { AppNamespace } from '../app/types';
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
export type UpdateDBUserFields = [UserFieldPath, FieldValue | string | number | boolean | Date | [] | {}][];
|
|
5
|
+
/**
|
|
6
|
+
* UserRepository class handles all database operations related to users.
|
|
7
|
+
* Implements repository pattern for user data access.
|
|
8
|
+
*/
|
|
9
|
+
export declare class UserRepository {
|
|
10
|
+
private readonly db;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of UserRepository.
|
|
13
|
+
*/
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves a user by their ID.
|
|
17
|
+
* @param params - Query parameters
|
|
18
|
+
* @param params.userId - The user's unique identifier
|
|
19
|
+
* @param params.appNamespace - The application namespace/platform
|
|
20
|
+
* @returns Promise resolving to User or null if not found
|
|
21
|
+
*/
|
|
22
|
+
getByUserId(params: {
|
|
23
|
+
userId: string;
|
|
24
|
+
appNamespace: string;
|
|
25
|
+
}): Promise<User | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new user record in the database.
|
|
28
|
+
* @param params - User creation parameters
|
|
29
|
+
* @param params.user - The user data to create
|
|
30
|
+
* @param params.appNamespace - The application namespace/platform
|
|
31
|
+
* @returns Promise resolving when user is created
|
|
32
|
+
* @throws Error if user creation fails
|
|
33
|
+
*/
|
|
34
|
+
create(params: {
|
|
35
|
+
user: User;
|
|
36
|
+
appNamespace: string;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Updates specific fields of a user identified by userId.
|
|
40
|
+
* @param params - Update parameters
|
|
41
|
+
* @param params.userId - The user's unique identifier
|
|
42
|
+
* @param params.appNamespace - The application namespace/platform
|
|
43
|
+
* @param params.fields - Array of field paths and values to update
|
|
44
|
+
* @throws Error if user not found or update fails
|
|
45
|
+
*/
|
|
46
|
+
updateFieldsByUserId(params: {
|
|
47
|
+
appNamespace: AppNamespace;
|
|
48
|
+
userId: string;
|
|
49
|
+
fields: UpdateDBUserFields;
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Maps a Firestore document to a User entity.
|
|
53
|
+
* @param doc - Firestore document snapshot
|
|
54
|
+
* @returns User entity
|
|
55
|
+
*/
|
|
56
|
+
private mapDocumentToEntity;
|
|
57
|
+
/**
|
|
58
|
+
* Builds an update object from field tuples.
|
|
59
|
+
* @param fields - Array of field paths and values
|
|
60
|
+
* @returns Object with field paths as keys and values to update
|
|
61
|
+
*/
|
|
62
|
+
private buildUpdateObject;
|
|
63
|
+
}
|
|
22
64
|
//# sourceMappingURL=userRepository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userRepository.d.ts","sourceRoot":"","sources":["../../../src/modules/user/userRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"userRepository.d.ts","sourceRoot":"","sources":["../../../src/modules/user/userRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA6C,MAAM,0BAA0B,CAAC;AACjG,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,kBAAkB,GAAG,CAAC,aAAa,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAE5G;;;GAGG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAE/B;;OAEG;;IAKH;;;;;;OAMG;IACU,WAAW,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAYhG;;;;;;;OAOG;IACU,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhF;;;;;;;OAOG;IACU,oBAAoB,CAAC,MAAM,EAAE;QACtC,YAAY,EAAE,YAAY,CAAC;QAC3B,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,kBAAkB,CAAC;KAC9B,GAAG,OAAO,CAAC,IAAI,CAAC;IAcjB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;CAW5B"}
|
|
@@ -1,47 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.addDBUser = addDBUser;
|
|
5
|
-
exports.updateDBUser = updateDBUser;
|
|
3
|
+
exports.UserRepository = void 0;
|
|
6
4
|
const firestore_1 = require("firebase-admin/firestore");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
/**
|
|
6
|
+
* UserRepository class handles all database operations related to users.
|
|
7
|
+
* Implements repository pattern for user data access.
|
|
8
|
+
*/
|
|
9
|
+
class UserRepository {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of UserRepository.
|
|
12
|
+
*/
|
|
13
|
+
constructor() {
|
|
14
|
+
this.db = (0, firestore_1.getFirestore)();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a user by their ID.
|
|
18
|
+
* @param params - Query parameters
|
|
19
|
+
* @param params.userId - The user's unique identifier
|
|
20
|
+
* @param params.appNamespace - The application namespace/platform
|
|
21
|
+
* @returns Promise resolving to User or null if not found
|
|
22
|
+
*/
|
|
23
|
+
async getByUserId(params) {
|
|
24
|
+
const { userId, appNamespace } = params;
|
|
25
|
+
const docSnapshot = await this.db.collection(`platform/${appNamespace}/users`).doc(userId).get();
|
|
26
|
+
if (!docSnapshot.exists) {
|
|
12
27
|
return null;
|
|
13
28
|
}
|
|
14
|
-
return
|
|
29
|
+
return this.mapDocumentToEntity(docSnapshot);
|
|
15
30
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new user record in the database.
|
|
33
|
+
* @param params - User creation parameters
|
|
34
|
+
* @param params.user - The user data to create
|
|
35
|
+
* @param params.appNamespace - The application namespace/platform
|
|
36
|
+
* @returns Promise resolving when user is created
|
|
37
|
+
* @throws Error if user creation fails
|
|
38
|
+
*/
|
|
39
|
+
async create(params) {
|
|
40
|
+
const { user, appNamespace } = params;
|
|
41
|
+
await this.db.collection(`platform/${appNamespace}/users`).doc(user.user.id).set(user);
|
|
21
42
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Updates specific fields of a user identified by userId.
|
|
45
|
+
* @param params - Update parameters
|
|
46
|
+
* @param params.userId - The user's unique identifier
|
|
47
|
+
* @param params.appNamespace - The application namespace/platform
|
|
48
|
+
* @param params.fields - Array of field paths and values to update
|
|
49
|
+
* @throws Error if user not found or update fails
|
|
50
|
+
*/
|
|
51
|
+
async updateFieldsByUserId(params) {
|
|
52
|
+
const { userId, appNamespace, fields } = params;
|
|
53
|
+
const updateObject = this.buildUpdateObject(fields);
|
|
54
|
+
const snapshot = await this.db.collection(`platform/${appNamespace}/users`).doc(userId).get();
|
|
55
|
+
if (!snapshot.exists) {
|
|
56
|
+
throw new Error(`User not found: ${userId}`);
|
|
57
|
+
}
|
|
58
|
+
await snapshot.ref.update(updateObject);
|
|
28
59
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
updateObject[f[0]] = f[1];
|
|
37
|
-
});
|
|
38
|
-
const snapshot = await db.collection(`platform/${appNamespace}/users`).doc(userId).get();
|
|
39
|
-
if (!snapshot.exists) {
|
|
40
|
-
throw new Error('User not found');
|
|
60
|
+
/**
|
|
61
|
+
* Maps a Firestore document to a User entity.
|
|
62
|
+
* @param doc - Firestore document snapshot
|
|
63
|
+
* @returns User entity
|
|
64
|
+
*/
|
|
65
|
+
mapDocumentToEntity(doc) {
|
|
66
|
+
return doc.data();
|
|
41
67
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Builds an update object from field tuples.
|
|
70
|
+
* @param fields - Array of field paths and values
|
|
71
|
+
* @returns Object with field paths as keys and values to update
|
|
72
|
+
*/
|
|
73
|
+
buildUpdateObject(fields) {
|
|
74
|
+
const updateObject = {};
|
|
75
|
+
fields
|
|
76
|
+
.filter((f) => Array.isArray(f))
|
|
77
|
+
.forEach(([fieldPath, value]) => {
|
|
78
|
+
updateObject[fieldPath] = value;
|
|
79
|
+
});
|
|
80
|
+
return updateObject;
|
|
45
81
|
}
|
|
46
82
|
}
|
|
83
|
+
exports.UserRepository = UserRepository;
|
|
47
84
|
//# sourceMappingURL=userRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userRepository.js","sourceRoot":"","sources":["../../../src/modules/user/userRepository.ts"],"names":[],"mappings":"
|
|
1
|
+
{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,CAAC,GAAG,EAAE,CAAC;QAE9F,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACK,mBAAmB,CAAC,GAAqB;QAC7C,OAAO,GAAG,CAAC,IAAI,EAAU,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACK,iBAAiB,CAAC,MAA0B;QAChD,MAAM,YAAY,GAAwB,EAAE,CAAC;QAE7C,MAAM;aACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;aAC/B,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE;YAC5B,YAAY,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;QACpC,CAAC,CAAC,CAAC;QAEP,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ;AA9FD,wCA8FC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Logger } from '../logger/types';
|
|
2
|
+
import { UpdateDBUserFields } from './userRepository';
|
|
3
|
+
import { User } from './types';
|
|
4
|
+
import { AppNamespace } from '../app/types';
|
|
5
|
+
/**
|
|
6
|
+
* UserService class handles business logic related to users.
|
|
7
|
+
* Acts as an intermediary between controllers/handlers and the repository layer.
|
|
8
|
+
*/
|
|
9
|
+
export declare class UserService {
|
|
10
|
+
private readonly logger;
|
|
11
|
+
private readonly repository;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of UserService.
|
|
14
|
+
* @param logger - Application logger instance for logging operations
|
|
15
|
+
*/
|
|
16
|
+
constructor(logger: Logger);
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves a user by their ID.
|
|
19
|
+
* @param params - Query parameters
|
|
20
|
+
* @param params.userId - The user's unique identifier
|
|
21
|
+
* @param params.appNamespace - The application namespace/platform
|
|
22
|
+
* @returns Promise resolving to User or null if not found
|
|
23
|
+
*/
|
|
24
|
+
getByUserId(params: {
|
|
25
|
+
userId: string;
|
|
26
|
+
appNamespace: string;
|
|
27
|
+
}): Promise<User | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new user record in the database.
|
|
30
|
+
* @param params - User creation parameters
|
|
31
|
+
* @param params.user - The user data to create
|
|
32
|
+
* @param params.appNamespace - The application namespace/platform
|
|
33
|
+
* @returns Promise resolving when user is created
|
|
34
|
+
* @throws Error if user creation fails
|
|
35
|
+
*/
|
|
36
|
+
create(params: {
|
|
37
|
+
user: User;
|
|
38
|
+
appNamespace: string;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Updates specific fields of a user identified by userId.
|
|
42
|
+
* @param params - Update parameters
|
|
43
|
+
* @param params.userId - The user's unique identifier
|
|
44
|
+
* @param params.appNamespace - The application namespace/platform
|
|
45
|
+
* @param params.fields - Array of field paths and values to update
|
|
46
|
+
* @throws Error if user not found or update fails
|
|
47
|
+
*/
|
|
48
|
+
updateFieldsByUserId(params: {
|
|
49
|
+
appNamespace: AppNamespace;
|
|
50
|
+
userId: string;
|
|
51
|
+
fields: UpdateDBUserFields;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=userService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userService.d.ts","sourceRoot":"","sources":["../../../src/modules/user/userService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAkB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAE5C;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAK1B;;;;;;OAMG;IACU,WAAW,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAgBhG;;;;;;;OAOG;IACU,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBhF;;;;;;;OAOG;IACU,oBAAoB,CAAC,MAAM,EAAE;QACtC,YAAY,EAAE,YAAY,CAAC;QAC3B,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,kBAAkB,CAAC;KAC9B,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBpB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserService = void 0;
|
|
4
|
+
const userRepository_1 = require("./userRepository");
|
|
5
|
+
/**
|
|
6
|
+
* UserService class handles business logic related to users.
|
|
7
|
+
* Acts as an intermediary between controllers/handlers and the repository layer.
|
|
8
|
+
*/
|
|
9
|
+
class UserService {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of UserService.
|
|
12
|
+
* @param logger - Application logger instance for logging operations
|
|
13
|
+
*/
|
|
14
|
+
constructor(logger) {
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
this.repository = new userRepository_1.UserRepository();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves a user by their ID.
|
|
20
|
+
* @param params - Query parameters
|
|
21
|
+
* @param params.userId - The user's unique identifier
|
|
22
|
+
* @param params.appNamespace - The application namespace/platform
|
|
23
|
+
* @returns Promise resolving to User or null if not found
|
|
24
|
+
*/
|
|
25
|
+
async getByUserId(params) {
|
|
26
|
+
try {
|
|
27
|
+
return await this.repository.getByUserId(params);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
this.logger.error({
|
|
31
|
+
message: 'Error in user service getByUserId',
|
|
32
|
+
payload: {
|
|
33
|
+
userId: params.userId,
|
|
34
|
+
appNamespace: params.appNamespace,
|
|
35
|
+
error: JSON.stringify(error),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new user record in the database.
|
|
43
|
+
* @param params - User creation parameters
|
|
44
|
+
* @param params.user - The user data to create
|
|
45
|
+
* @param params.appNamespace - The application namespace/platform
|
|
46
|
+
* @returns Promise resolving when user is created
|
|
47
|
+
* @throws Error if user creation fails
|
|
48
|
+
*/
|
|
49
|
+
async create(params) {
|
|
50
|
+
try {
|
|
51
|
+
await this.repository.create(params);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this.logger.error({
|
|
55
|
+
message: 'Error in user service create',
|
|
56
|
+
payload: {
|
|
57
|
+
userId: params.user.user.id,
|
|
58
|
+
appNamespace: params.appNamespace,
|
|
59
|
+
error: JSON.stringify(error),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Updates specific fields of a user identified by userId.
|
|
67
|
+
* @param params - Update parameters
|
|
68
|
+
* @param params.userId - The user's unique identifier
|
|
69
|
+
* @param params.appNamespace - The application namespace/platform
|
|
70
|
+
* @param params.fields - Array of field paths and values to update
|
|
71
|
+
* @throws Error if user not found or update fails
|
|
72
|
+
*/
|
|
73
|
+
async updateFieldsByUserId(params) {
|
|
74
|
+
try {
|
|
75
|
+
await this.repository.updateFieldsByUserId(params);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
this.logger.error({
|
|
79
|
+
message: 'Error in user service updateFieldsByUserId',
|
|
80
|
+
payload: {
|
|
81
|
+
userId: params.userId,
|
|
82
|
+
appNamespace: params.appNamespace,
|
|
83
|
+
fields: JSON.stringify(params.fields),
|
|
84
|
+
error: JSON.stringify(error),
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.UserService = UserService;
|
|
92
|
+
//# sourceMappingURL=userService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userService.js","sourceRoot":"","sources":["../../../src/modules/user/userService.ts"],"names":[],"mappings":";;;AACA,qDAAsE;AAItE;;;GAGG;AACH,MAAa,WAAW;IAIpB;;;OAGG;IACH,YAAY,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,+BAAc,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,WAAW,CAAC,MAAgD;QACrE,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBACd,OAAO,EAAE,mCAAmC;gBAC5C,OAAO,EAAE;oBACL,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,YAAY,EAAE,MAAM,CAAC,YAAY;oBACjC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC/B;aACJ,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,MAAM,CAAC,MAA4C;QAC5D,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBACd,OAAO,EAAE,8BAA8B;gBACvC,OAAO,EAAE;oBACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;oBACjC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC/B;aACJ,CAAC,CAAC;YAEH,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,oBAAoB,CAAC,MAIjC;QACG,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBACd,OAAO,EAAE,4CAA4C;gBACrD,OAAO,EAAE;oBACL,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,YAAY,EAAE,MAAM,CAAC,YAAY;oBACjC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;oBACrC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC/B;aACJ,CAAC,CAAC;YAEH,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AA1FD,kCA0FC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@misterhomer1992/miit-bot-payment",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A TypeScript utility library for payment validation and formatting",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dotenv": "17.2.2",
|
|
30
30
|
"axios": "1.12.2",
|
|
31
31
|
"firebase-admin": "^11.6.0",
|
|
32
|
-
"@misterhomer1992/wayforpay-api": "
|
|
32
|
+
"@misterhomer1992/wayforpay-api": "3.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^20.10.0",
|