@misterhomer1992/miit-bot-payment 1.0.0 → 1.0.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.
Files changed (53) hide show
  1. package/dist/index.d.ts +1 -7
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -18
  4. package/dist/index.js.map +1 -1
  5. package/dist/modules/app/types.d.ts +2 -0
  6. package/dist/modules/app/types.d.ts.map +1 -0
  7. package/dist/modules/app/types.js +3 -0
  8. package/dist/modules/app/types.js.map +1 -0
  9. package/dist/modules/cancellableAPI/utils.d.ts +17 -0
  10. package/dist/modules/cancellableAPI/utils.d.ts.map +1 -0
  11. package/dist/modules/cancellableAPI/utils.js +43 -0
  12. package/dist/modules/cancellableAPI/utils.js.map +1 -0
  13. package/dist/modules/logger/types.d.ts +8 -0
  14. package/dist/modules/logger/types.d.ts.map +1 -0
  15. package/dist/modules/logger/types.js +3 -0
  16. package/dist/modules/logger/types.js.map +1 -0
  17. package/dist/modules/network/utils.d.ts +9 -0
  18. package/dist/modules/network/utils.d.ts.map +1 -0
  19. package/dist/modules/network/utils.js +20 -0
  20. package/dist/modules/network/utils.js.map +1 -0
  21. package/dist/modules/payments/const.d.ts +4 -0
  22. package/dist/modules/payments/const.d.ts.map +1 -0
  23. package/dist/modules/payments/const.js +11 -0
  24. package/dist/modules/payments/const.js.map +1 -0
  25. package/dist/modules/payments/repository.d.ts +85 -0
  26. package/dist/modules/payments/repository.d.ts.map +1 -0
  27. package/dist/modules/payments/repository.js +191 -0
  28. package/dist/modules/payments/repository.js.map +1 -0
  29. package/dist/modules/payments/types.d.ts +31 -0
  30. package/dist/modules/payments/types.d.ts.map +1 -0
  31. package/dist/modules/payments/types.js +3 -0
  32. package/dist/modules/payments/types.js.map +1 -0
  33. package/dist/modules/user/userModel.d.ts +78 -0
  34. package/dist/modules/user/userModel.d.ts.map +1 -0
  35. package/dist/modules/user/userModel.js +3 -0
  36. package/dist/modules/user/userModel.js.map +1 -0
  37. package/dist/modules/user/userRepository.d.ts +22 -0
  38. package/dist/modules/user/userRepository.d.ts.map +1 -0
  39. package/dist/modules/user/userRepository.js +47 -0
  40. package/dist/modules/user/userRepository.js.map +1 -0
  41. package/dist/types/function.d.ts +3 -0
  42. package/dist/types/function.d.ts.map +1 -0
  43. package/dist/types/function.js +3 -0
  44. package/dist/types/function.js.map +1 -0
  45. package/dist/types/utilities.d.ts +10 -0
  46. package/dist/types/utilities.d.ts.map +1 -0
  47. package/dist/types/utilities.js +3 -0
  48. package/dist/types/utilities.js.map +1 -0
  49. package/dist/utils.d.ts +10 -0
  50. package/dist/utils.d.ts.map +1 -0
  51. package/dist/utils.js +45 -0
  52. package/dist/utils.js.map +1 -0
  53. package/package.json +55 -45
package/dist/index.d.ts CHANGED
@@ -1,8 +1,2 @@
1
- /**
2
- * @miit-bot/payment-utils
3
- * A TypeScript utility library for payment validation and formatting
4
- */
5
- export * from './types';
6
- export { validateCardNumber, validateAmount, validateCVV } from './validators';
7
- export { formatCardNumber, formatCurrency, maskCardNumber, formatExpiryDate } from './formatters';
1
+ export * from './modules/payments/repository';
8
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG/E,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * @miit-bot/payment-utils
4
- * A TypeScript utility library for payment validation and formatting
5
- */
6
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
3
  if (k2 === undefined) k2 = k;
8
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -18,18 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
15
  };
20
16
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.formatExpiryDate = exports.maskCardNumber = exports.formatCurrency = exports.formatCardNumber = exports.validateCVV = exports.validateAmount = exports.validateCardNumber = void 0;
22
- // Export types
23
- __exportStar(require("./types"), exports);
24
- // Export validators
25
- var validators_1 = require("./validators");
26
- Object.defineProperty(exports, "validateCardNumber", { enumerable: true, get: function () { return validators_1.validateCardNumber; } });
27
- Object.defineProperty(exports, "validateAmount", { enumerable: true, get: function () { return validators_1.validateAmount; } });
28
- Object.defineProperty(exports, "validateCVV", { enumerable: true, get: function () { return validators_1.validateCVV; } });
29
- // Export formatters
30
- var formatters_1 = require("./formatters");
31
- Object.defineProperty(exports, "formatCardNumber", { enumerable: true, get: function () { return formatters_1.formatCardNumber; } });
32
- Object.defineProperty(exports, "formatCurrency", { enumerable: true, get: function () { return formatters_1.formatCurrency; } });
33
- Object.defineProperty(exports, "maskCardNumber", { enumerable: true, get: function () { return formatters_1.maskCardNumber; } });
34
- Object.defineProperty(exports, "formatExpiryDate", { enumerable: true, get: function () { return formatters_1.formatExpiryDate; } });
17
+ __exportStar(require("./modules/payments/repository"), exports);
35
18
  //# 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;;;GAGG;;;;;;;;;;;;;;;;;AAEH,eAAe;AACf,0CAAwB;AAExB,oBAAoB;AACpB,2CAA+E;AAAtE,gHAAA,kBAAkB,OAAA;AAAE,4GAAA,cAAc,OAAA;AAAE,yGAAA,WAAW,OAAA;AAExD,oBAAoB;AACpB,2CAAkG;AAAzF,8GAAA,gBAAgB,OAAA;AAAE,4GAAA,cAAc,OAAA;AAAE,4GAAA,cAAc,OAAA;AAAE,8GAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C"}
@@ -0,0 +1,2 @@
1
+ export type AppNamespace = 'app' | 'telegram';
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/app/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/app/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { SimpleFn } from '../../types/function';
2
+ import { AppNamespace } from '../app/types';
3
+ type DefaultParams = Record<string, unknown> & {
4
+ userId: string;
5
+ appNamespace: AppNamespace;
6
+ };
7
+ declare function wrapCancellableAPI<T extends SimpleFn, TParams extends any[] = Parameters<T> extends never[] ? [DefaultParams] : Parameters<T> & [DefaultParams]>(api: T, props?: {
8
+ timeout?: number;
9
+ }): (...args: TParams) => Promise<Awaited<ReturnType<T>> | never>;
10
+ declare function wrapTimeoutAPI<T extends SimpleFn, TParams extends any[] = Parameters<T> extends never[] ? [DefaultParams] : Parameters<T> & [DefaultParams]>(api: T, props?: {
11
+ timeout?: number;
12
+ }): (...args: TParams) => Promise<Awaited<ReturnType<T>> | never>;
13
+ declare function wrapRawTimeoutAPI<T extends SimpleFn, TParams extends any[] = Parameters<T>>(api: T, props?: {
14
+ timeout?: number;
15
+ }): (...args: TParams) => Promise<Awaited<ReturnType<T>> | never>;
16
+ export { wrapCancellableAPI, wrapTimeoutAPI, wrapRawTimeoutAPI };
17
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/cancellableAPI/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF,iBAAS,kBAAkB,CACvB,CAAC,SAAS,QAAQ,EAClB,OAAO,SAAS,GAAG,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAC3G,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,IACjB,GAAG,MAAM,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAW9E;AAED,iBAAS,cAAc,CACnB,CAAC,SAAS,QAAQ,EAClB,OAAO,SAAS,GAAG,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAC3G,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,IACjB,GAAG,MAAM,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAW9E;AAED,iBAAS,iBAAiB,CAAC,CAAC,SAAS,QAAQ,EAAE,OAAO,SAAS,GAAG,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAChF,GAAG,EAAE,CAAC,EACN,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,IAEX,GAAG,MAAM,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAW9E;AAED,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapCancellableAPI = wrapCancellableAPI;
4
+ exports.wrapTimeoutAPI = wrapTimeoutAPI;
5
+ exports.wrapRawTimeoutAPI = wrapRawTimeoutAPI;
6
+ const utils_1 = require("../network/utils");
7
+ function wrapCancellableAPI(api, props) {
8
+ return function (...args) {
9
+ const { promise: timeoutPromise, cleanUp } = (0, utils_1.mockTimeoutResponse)({
10
+ timeout: props?.timeout,
11
+ });
12
+ return Promise.race([api(...args), timeoutPromise])
13
+ .catch((e) => {
14
+ throw e;
15
+ })
16
+ .finally(cleanUp);
17
+ };
18
+ }
19
+ function wrapTimeoutAPI(api, props) {
20
+ return function (...args) {
21
+ const { promise: timeoutPromise, cleanUp } = (0, utils_1.mockTimeoutResponse)({
22
+ timeout: props?.timeout,
23
+ });
24
+ return Promise.race([api(...args), timeoutPromise])
25
+ .catch((e) => {
26
+ throw e;
27
+ })
28
+ .finally(cleanUp);
29
+ };
30
+ }
31
+ function wrapRawTimeoutAPI(api, props) {
32
+ return function (...args) {
33
+ const { promise: timeoutPromise, cleanUp } = (0, utils_1.mockTimeoutResponse)({
34
+ timeout: props?.timeout,
35
+ });
36
+ return Promise.race([api(...args), timeoutPromise])
37
+ .catch((e) => {
38
+ throw e;
39
+ })
40
+ .finally(cleanU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,EAAE,OAAO,EAAE,GAAG,IAAA,2BAAmB,EAAC;YAC7D,OAAO,EAAE,KAAK,EAAE,OAAO;SAC1B,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;aAC9C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,MAAM,CAAC,CAAC;QACZ,CAAC,CAAC;aACD,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,8 @@
1
+ interface Logger {
2
+ info: (message: string) => void;
3
+ warning: (message: string) => void;
4
+ error: (message: string) => void;
5
+ debug: (message: string) => void;
6
+ }
7
+ export { Logger };
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/logger/types.ts"],"names":[],"mappings":"AAAA,UAAU,MAAM;IACZ,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/logger/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ declare function mockTimeoutResponse({ timeout, rejectedCode, }?: {
2
+ timeout?: number;
3
+ rejectedCode?: string;
4
+ }): {
5
+ promise: Promise<never>;
6
+ cleanUp: () => void;
7
+ };
8
+ export { mockTimeoutResponse };
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/network/utils.ts"],"names":[],"mappings":"AAAA,iBAAS,mBAAmB,CAAC,EAEzB,OAAiB,EACjB,YAAiC,GACpC;;;CAAK,GAAG;IACL,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACxB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB,CAcA;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockTimeoutResponse = mockTimeoutResponse;
4
+ function mockTimeoutResponse({
5
+ // timeout = 12000,
6
+ timeout = 1002000, rejectedCode = 'RESPONSE_TIMEOUT', } = {}) {
7
+ let timeoutId;
8
+ const promise = new Promise(function (_, reject) {
9
+ timeoutId = setTimeout(() => {
10
+ reject({
11
+ code: rejectedCode,
12
+ });
13
+ }, timeout);
14
+ });
15
+ return {
16
+ promise,
17
+ cleanUp: () => clearTimeout(timeoutId),
18
+ };
19
+ }
20
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/modules/network/utils.ts"],"names":[],"mappings":";;AAuBS,kDAAmB;AAvB5B,SAAS,mBAAmB,CAAC;AACzB,mBAAmB;AACnB,OAAO,GAAG,OAAO,EACjB,YAAY,GAAG,kBAAkB,GACpC,GAAG,EAAE;IAIF,IAAI,SAAS,CAAC;IACd,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,UAAU,CAAC,EAAE,MAAM;QAClD,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,MAAM,CAAC;gBACH,IAAI,EAAE,YAAY;aACrB,CAAC,CAAC;QACP,CAAC,EAAE,OAAO,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO;QACH,OAAO;QACP,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC;KACzC,CAAC;AACN,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { PaymentEntity } from './types';
2
+ declare const DEFAULT_PAYMENT_ENTITY: Partial<PaymentEntity>;
3
+ export { DEFAULT_PAYMENT_ENTITY };
4
+ //# sourceMappingURL=const.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,QAAA,MAAM,sBAAsB,EAAE,OAAO,CAAC,aAAa,CAKlD,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_PAYMENT_ENTITY = void 0;
4
+ const DEFAULT_PAYMENT_ENTITY = {
5
+ status: 'pending',
6
+ provider: 'wayforpay',
7
+ platform: 'telegram',
8
+ currency: 'UAH',
9
+ };
10
+ exports.DEFAULT_PAYMENT_ENTITY = DEFAULT_PAYMENT_ENTITY;
11
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/modules/payments/const.ts"],"names":[],"mappings":";;;AAEA,MAAM,sBAAsB,GAA2B;IACnD,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,KAAK;CAClB,CAAC;AAEO,wDAAsB"}
@@ -0,0 +1,85 @@
1
+ import { FieldValue } from 'firebase-admin/firestore';
2
+ import { PaymentEntity, PaymentFieldPath } from './types';
3
+ import { AppNamespace } from '../app/types';
4
+ import { Logger } from '../logger/types';
5
+ export type UpdateDBPaymentFields = [PaymentFieldPath, FieldValue | string | number | boolean | Date | [] | {}][];
6
+ /**
7
+ * PaymentRepository class handles all database operations related to payments.
8
+ * Implements repository pattern for payment data access.
9
+ */
10
+ export declare class PaymentRepository {
11
+ private readonly logger;
12
+ private readonly db;
13
+ private readonly collectionName;
14
+ /**
15
+ * Creates an instance of PaymentRepository.
16
+ * @param logger - Application logger instance for logging operations
17
+ */
18
+ constructor(logger: Logger);
19
+ /**
20
+ * Retrieves a payment by its order reference.
21
+ * @param orderReference - The unique order reference identifier
22
+ * @returns Promise resolving to PaymentEntity or null if not found
23
+ */
24
+ getByOrderReference(orderReference: string): Promise<PaymentEntity | null>;
25
+ /**
26
+ * Retrieves all payments for a specific user.
27
+ * @param params - Query parameters
28
+ * @param params.userId - The user's unique identifier
29
+ * @param params.appNamespace - The application namespace/platform
30
+ * @param params.status - Optional payment status filter
31
+ * @returns Promise resolving to array of PaymentEntity
32
+ */
33
+ getByUserId(params: {
34
+ userId: string;
35
+ appNamespace: AppNamespace;
36
+ status?: PaymentEntity['status'];
37
+ }): Promise<PaymentEntity[]>;
38
+ /**
39
+ * Creates a new payment record in the database.
40
+ * @param paymentData - Payment data without ID (ID will be auto-generated)
41
+ * @returns Promise resolving to created PaymentEntity with ID
42
+ * @throws Error if payment creation fails
43
+ */
44
+ create(paymentData: Omit<PaymentEntity, 'id'>): Promise<PaymentEntity>;
45
+ /**
46
+ * Updates specific fields of a payment identified by order reference.
47
+ * @param params - Update parameters
48
+ * @param params.orderReference - The order reference to identify the payment
49
+ * @param params.fields - Array of field paths and values to update
50
+ * @throws Error if payment not found or update fails
51
+ */
52
+ updateFields(params: {
53
+ orderReference: string;
54
+ fields: UpdateDBPaymentFields;
55
+ }): Promise<void>;
56
+ /**
57
+ * Retrieves all pending payments that are older than specified hours.
58
+ * Used for cleaning up expired payment attempts.
59
+ * @param params - Query parameters
60
+ * @param params.hoursOld - Number of hours after which a pending payment is considered expired (default: 24)
61
+ * @returns Promise resolving to array of expired PaymentEntity
62
+ */
63
+ getExpiredPendingPayments(params?: {
64
+ hoursOld?: number;
65
+ }): Promise<PaymentEntity[]>;
66
+ /**
67
+ * Maps a Firestore document to a PaymentEntity.
68
+ * @param doc - Firestore document snapshot
69
+ * @returns PaymentEntity with document ID
70
+ */
71
+ private mapDocumentToEntity;
72
+ /**
73
+ * Builds an update object from field tuples.
74
+ * @param fields - Array of field paths and values
75
+ * @returns Object with field paths as keys and values to update
76
+ */
77
+ private buildUpdateObject;
78
+ /**
79
+ * Calculates the cutoff time for expired payments.
80
+ * @param hoursOld - Number of hours to subtract from current time
81
+ * @returns Date object representing the cutoff time
82
+ */
83
+ private calculateCutoffTime;
84
+ }
85
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAkD,MAAM,0BAA0B,CAAC;AACtG,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,MAAM,qBAAqB,GAAG,CAAC,gBAAgB,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAElH;;;GAGG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;IAE7C;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAK1B;;;;OAIG;IACU,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAuBvF;;;;;;;OAOG;IACU,WAAW,CAAC,MAAM,EAAE;QAC7B,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,YAAY,CAAC;QAC3B,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA2B5B;;;;;OAKG;IACU,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IA6BnF;;;;;;OAMG;IACU,YAAY,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,qBAAqB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B3G;;;;;;OAMG;IACU,yBAAyB,CAClC,MAAM,GAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;KAChB,GACP,OAAO,CAAC,aAAa,EAAE,CAAC;IA0B3B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;CAK9B"}
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentRepository = void 0;
4
+ const firestore_1 = require("firebase-admin/firestore");
5
+ const const_1 = require("./const");
6
+ /**
7
+ * PaymentRepository class handles all database operations related to payments.
8
+ * Implements repository pattern for payment data access.
9
+ */
10
+ class PaymentRepository {
11
+ /**
12
+ * Creates an instance of PaymentRepository.
13
+ * @param logger - Application logger instance for logging operations
14
+ */
15
+ constructor(logger) {
16
+ this.collectionName = 'payments';
17
+ this.logger = logger;
18
+ this.db = (0, firestore_1.getFirestore)();
19
+ }
20
+ /**
21
+ * Retrieves a payment by its order reference.
22
+ * @param orderReference - The unique order reference identifier
23
+ * @returns Promise resolving to PaymentEntity or null if not found
24
+ */
25
+ async getByOrderReference(orderReference) {
26
+ try {
27
+ const querySnapshot = await this.db
28
+ .collection(this.collectionName)
29
+ .where('orderReference', '==', orderReference)
30
+ .limit(1)
31
+ .get();
32
+ if (querySnapshot.empty) {
33
+ this.logger.info(`Payment not found for orderReference: ${orderReference}`);
34
+ return null;
35
+ }
36
+ const doc = querySnapshot.docs[0];
37
+ return this.mapDocumentToEntity(doc);
38
+ }
39
+ catch (error) {
40
+ this.logger.error(`Error getting payment by orderReference: ${orderReference}. Error: ${JSON.stringify(error)}`);
41
+ return null;
42
+ }
43
+ }
44
+ /**
45
+ * Retrieves all payments for a specific user.
46
+ * @param params - Query parameters
47
+ * @param params.userId - The user's unique identifier
48
+ * @param params.appNamespace - The application namespace/platform
49
+ * @param params.status - Optional payment status filter
50
+ * @returns Promise resolving to array of PaymentEntity
51
+ */
52
+ async getByUserId(params) {
53
+ const { userId, appNamespace, status } = params;
54
+ try {
55
+ let query = this.db
56
+ .collection(this.collectionName)
57
+ .where('platform', '==', appNamespace)
58
+ .where('userId', '==', userId);
59
+ if (status) {
60
+ query = query.where('status', '==', status);
61
+ }
62
+ const querySnapshot = await query.get();
63
+ if (querySnapshot.empty) {
64
+ this.logger.info(`No payments found for userId: ${userId}, appNamespace: ${appNamespace}`);
65
+ return [];
66
+ }
67
+ return querySnapshot.docs.map((doc) => this.mapDocumentToEntity(doc));
68
+ }
69
+ catch (error) {
70
+ this.logger.error(`Error getting payments by userId: ${userId}. Error: ${JSON.stringify(error)}`);
71
+ return [];
72
+ }
73
+ }
74
+ /**
75
+ * Creates a new payment record in the database.
76
+ * @param paymentData - Payment data without ID (ID will be auto-generated)
77
+ * @returns Promise resolving to created PaymentEntity with ID
78
+ * @throws Error if payment creation fails
79
+ */
80
+ async create(paymentData) {
81
+ try {
82
+ const paymentEntity = {
83
+ ...const_1.DEFAULT_PAYMENT_ENTITY,
84
+ ...paymentData,
85
+ };
86
+ const docRef = await this.db.collection(this.collectionName).add(paymentEntity);
87
+ if (!docRef.id) {
88
+ throw new Error(`Failed to create payment for orderReference: ${paymentData.orderReference}`);
89
+ }
90
+ this.logger.info(`Payment created successfully with ID: ${docRef.id}, orderReference: ${paymentData.orderReference}`);
91
+ return {
92
+ id: docRef.id,
93
+ ...paymentEntity,
94
+ };
95
+ }
96
+ catch (error) {
97
+ this.logger.error(`Error creating payment for orderReference: ${paymentData.orderReference}. Error: ${JSON.stringify(error)}`);
98
+ throw error;
99
+ }
100
+ }
101
+ /**
102
+ * Updates specific fields of a payment identified by order reference.
103
+ * @param params - Update parameters
104
+ * @param params.orderReference - The order reference to identify the payment
105
+ * @param params.fields - Array of field paths and values to update
106
+ * @throws Error if payment not found or update fails
107
+ */
108
+ async updateFields(params) {
109
+ const { orderReference, fields } = params;
110
+ try {
111
+ const updateObject = this.buildUpdateObject(fields);
112
+ const querySnapshot = await this.db
113
+ .collection(this.collectionName)
114
+ .where('orderReference', '==', orderReference)
115
+ .limit(1)
116
+ .get();
117
+ if (querySnapshot.empty) {
118
+ throw new Error(`Payment not found for orderReference: ${orderReference}`);
119
+ }
120
+ await querySnapshot.docs[0].ref.update(updateObject);
121
+ this.logger.info(`Payment updated successfully for orderReference: ${orderReference}`);
122
+ }
123
+ catch (error) {
124
+ this.logger.error(`Error updating payment for orderReference: ${orderReference}. Error: ${JSON.stringify(error)}`);
125
+ throw error;
126
+ }
127
+ }
128
+ /**
129
+ * Retrieves all pending payments that are older than specified hours.
130
+ * Used for cleaning up expired payment attempts.
131
+ * @param params - Query parameters
132
+ * @param params.hoursOld - Number of hours after which a pending payment is considered expired (default: 24)
133
+ * @returns Promise resolving to array of expired PaymentEntity
134
+ */
135
+ async getExpiredPendingPayments(params = {}) {
136
+ const { hoursOld = 24 } = params;
137
+ try {
138
+ const cutoffTime = this.calculateCutoffTime(hoursOld);
139
+ const querySnapshot = await this.db
140
+ .collection(this.collectionName)
141
+ .where('status', '==', 'pending')
142
+ .where('createdAt', '<', cutoffTime.toISOString())
143
+ .get();
144
+ if (querySnapshot.empty) {
145
+ this.logger.info(`No expired pending payments found (older than ${hoursOld} hours)`);
146
+ return [];
147
+ }
148
+ this.logger.info(`Found ${querySnapshot.docs.length} expired pending payments`);
149
+ return querySnapshot.docs.map((doc) => this.mapDocumentToEntity(doc));
150
+ }
151
+ catch (error) {
152
+ this.logger.error(`Error getting expired pending payments. Error: ${JSON.stringify(error)}`);
153
+ return [];
154
+ }
155
+ }
156
+ /**
157
+ * Maps a Firestore document to a PaymentEntity.
158
+ * @param doc - Firestore document snapshot
159
+ * @returns PaymentEntity with document ID
160
+ */
161
+ mapDocumentToEntity(doc) {
162
+ return {
163
+ id: doc.id,
164
+ ...doc.data(),
165
+ };
166
+ }
167
+ /**
168
+ * Builds an update object from field tuples.
169
+ * @param fields - Array of field paths and values
170
+ * @returns Object with field paths as keys and values to update
171
+ */
172
+ buildUpdateObject(fields) {
173
+ const updateObject = {};
174
+ fields.forEach(([fieldPath, value]) => {
175
+ updateObject[fieldPath] = value;
176
+ });
177
+ return updateObject;
178
+ }
179
+ /**
180
+ * Calculates the cutoff time for expired payments.
181
+ * @param hoursOld - Number of hours to subtract from current time
182
+ * @returns Date object representing the cutoff time
183
+ */
184
+ calculateCutoffTime(hoursOld) {
185
+ const cutoffTime = new Date();
186
+ cutoffTime.setHours(cutoffTime.getHours() - hoursOld);
187
+ return cutoffTime;
188
+ }
189
+ }
190
+ exports.PaymentRepository = PaymentRepository;
191
+ //# sourceMappingURL=repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/payments/repository.ts"],"names":[],"mappings":";;;AAAA,wDAAsG;AAEtG,mCAAiD;AAMjD;;;GAGG;AACH,MAAa,iBAAiB;IAK1B;;;OAGG;IACH,YAAY,MAAc;QANT,mBAAc,GAAG,UAAU,CAAC;QAOzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAY,GAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,mBAAmB,CAAC,cAAsB;QACnD,IAAI,CAAC;YAC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C,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC;QACtD,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAhOD,8CAgOC"}
@@ -0,0 +1,31 @@
1
+ import { NestedPathsAccess } from '../../types/utilities';
2
+ import { AppNamespace } from '../app/types';
3
+ type PaymentEntity = {
4
+ /** Auto-generated unique ID (document ID) */
5
+ id?: string;
6
+ /** The unique ID you generate and send to Wayforpay. This is the key to match incoming webhooks to a payment attempt. */
7
+ orderReference: string;
8
+ /** The ID of the user initiating the payment */
9
+ userId: string;
10
+ /** The state of this payment attempt */
11
+ status: 'pending' | 'completed' | 'failed' | 'expired';
12
+ /** The URL from Wayforpay that is sent to the user */
13
+ paymentLink: string;
14
+ /** The plan the user is attempting to purchase */
15
+ planId: string;
16
+ /** The amount to be charged */
17
+ amount: number;
18
+ /** Currency of the payment */
19
+ currency: 'UAH' | 'USD';
20
+ /** When this payment attempt was created */
21
+ createdAt: string;
22
+ /** Optional. The ID of the corresponding document in the invoices collection, added after the webhook is processed */
23
+ invoiceId?: string;
24
+ /** Platform/app namespace */
25
+ platform: AppNamespace;
26
+ /** Payment provider */
27
+ provider: 'wayforpay';
28
+ };
29
+ type PaymentFieldPath = NestedPathsAccess<PaymentEntity>;
30
+ export type { PaymentEntity, PaymentFieldPath };
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,KAAK,aAAa,GAAG;IACjB,6CAA6C;IAC7C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yHAAyH;IACzH,cAAc,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IACvD,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,QAAQ,EAAE,KAAK,GAAG,KAAK,CAAC;IACxB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,sHAAsH;IACtH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,uBAAuB;IACvB,QAAQ,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,KAAK,gBAAgB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAEzD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/payments/types.ts"],"names":[],"mappings":""}
@@ -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=userModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userModel.d.ts","sourceRoot":"","sources":["../../../src/modules/user/userModel.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,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,CAAC;gBACF,IAAI,EAAE;oBACF,KAAK,EAAE,MAAM,CAAC;iBACjB,CAAC;gBACF,IAAI,EAAE;oBACF,KAAK,EAAE,MAAM,CAAC;iBACjB,CAAC;aACL,CAAC;YACF,MAAM,EAAE,OAAO,CACX,MAAM,CACF,MAAM,EACN;gBACI,kBAAkB,EAAE,MAAM,CAAC;gBAC3B,mBAAmB,EAAE,MAAM,CAAC;aAC/B,CACJ,CACJ,CAAC;SACL,CAAC;QACF,YAAY,EAAE;YACV,WAAW,EAAE;gBACT,OAAO,EAAE,MAAM,CAAC;aACnB,CAAC;SACL,CAAC;QACF,YAAY,EAAE;YACV,OAAO,EAAE;gBACL,UAAU,EAAE,MAAM,CAAC;aACtB,CAAC;SACL,CAAC;KACL,CAAC;CACL;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAEpD,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=userModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userModel.js","sourceRoot":"","sources":["../../../src/modules/user/userModel.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { FieldValue } from 'firebase-admin/firestore';
2
+ import { User, UserFieldAnalyticsPath, UserFieldPath } from './userModel';
3
+ import { AppNamespace } from '../app/types';
4
+ export type PushDBUserAnalyticsFields = [
5
+ UserFieldAnalyticsPath,
6
+ FieldValue | string | number | boolean | Date | [] | object
7
+ ][];
8
+ declare function getDBUser({ userId, appNamespace }: {
9
+ userId: string;
10
+ appNamespace: string;
11
+ }): Promise<User | null>;
12
+ declare function addDBUser({ appNamespace, user }: {
13
+ user: User;
14
+ appNamespace: string;
15
+ }): Promise<void>;
16
+ declare function updateDBUser({ appNamespace, userId, fields, }: {
17
+ appNamespace: AppNamespace;
18
+ userId: string;
19
+ fields: [UserFieldPath, FieldValue | string | number | boolean | Date | [] | {}][];
20
+ }): Promise<void>;
21
+ export { getDBUser, addDBUser, updateDBUser };
22
+ //# sourceMappingURL=userRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userRepository.d.ts","sourceRoot":"","sources":["../../../src/modules/user/userRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,yBAAyB,GAAG;IACpC,sBAAsB;IACtB,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,MAAM;CAC9D,EAAE,CAAC;AAEJ,iBAAe,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAiBjH;AAED,iBAAe,SAAS,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,iBAQpF;AAED,iBAAe,YAAY,CAAC,EACxB,YAAY,EACZ,MAAM,EACN,MAAM,GACT,EAAE;IACC,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,aAAa,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;CACtF,iBAqBA;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDBUser = getDBUser;
4
+ exports.addDBUser = addDBUser;
5
+ exports.updateDBUser = updateDBUser;
6
+ const firestore_1 = require("firebase-admin/firestore");
7
+ async function getDBUser({ userId, appNamespace }) {
8
+ const db = (0, firestore_1.getFirestore)();
9
+ try {
10
+ const querySnapshot = await db.collection(`platform/${appNamespace}/users`).doc(userId).get();
11
+ if (!querySnapshot.exists) {
12
+ return null;
13
+ }
14
+ return querySnapshot.data();
15
+ }
16
+ catch (e) {
17
+ console.log({
18
+ gerUserError: e,
19
+ });
20
+ return null;
21
+ }
22
+ }
23
+ async function addDBUser({ appNamespace, user }) {
24
+ const db = (0, firestore_1.getFirestore)();
25
+ const result = await db.collection(`platform/${appNamespace}/users`).doc(user.user.id).set(user);
26
+ if (!result) {
27
+ throw new Error(`Failed to add user, ${JSON.stringify(user)}`);
28
+ }
29
+ }
30
+ async function updateDBUser({ appNamespace, userId, fields, }) {
31
+ const db = (0, firestore_1.getFirestore)();
32
+ let updateObject = {};
33
+ fields
34
+ .filter((f) => Array.isArray(f))
35
+ .forEach((f) => {
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');
41
+ }
42
+ const result = await snapshot.ref.update(updateObject);
43
+ if (!result) {
44
+ throw new Error(`Failed to update user, ${JSON.stringify(updateObject)}`);
45
+ }
46
+ }
47
+ //# sourceMappingURL=userRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userRepository.js","sourceRoot":"","sources":["../../../src/modules/user/userRepository.ts"],"names":[],"mappings":";;AAqES,8BAAS;AAAE,8BAAS;AAAE,oCAAY;AArE3C,wDAAoE;AASpE,KAAK,UAAU,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAA4C;IACvF,MAAM,EAAE,GAAG,IAAA,wBAAY,GAAE,CAAC;IAE1B,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CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEP,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,YAAY,YAAY,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;IAEzF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAEvD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type SimpleFn = (...args: any[]) => any;
2
+ export type ExtendFn<Fn extends SimpleFn = SimpleFn, K extends any[] = Parameters<Fn>> = (...args: [...K]) => ReturnType<Fn>;
3
+ //# sourceMappingURL=function.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/types/function.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAE/C,MAAM,MAAM,QAAQ,CAAC,EAAE,SAAS,QAAQ,GAAG,QAAQ,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,IAAI,CACrF,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,KACd,UAAU,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function.js","sourceRoot":"","sources":["../../src/types/function.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ type NonFunctionPropertyNames<T> = {
2
+ [K in keyof T]: T[K] extends Function ? never : K;
3
+ }[keyof T];
4
+ export type Primitive = string | number | boolean;
5
+ export type IsArray<T> = T extends Array<any> ? true : false;
6
+ export type NestedPathsAccess<T, Prev extends string = ''> = T extends Primitive ? never : T extends Array<infer U> ? U extends Primitive ? `${Prev}[${number}]` : `${Prev}[${number}]` | NestedPathsAccess<U, `${Prev}[${number}].`> : {
7
+ [K in NonFunctionPropertyNames<T> & string]: T[K] extends Primitive ? `${Prev}${K}` : IsArray<T[K]> extends true ? `${Prev}${K}` | NestedPathsAccess<T[K], `${Prev}${K}`> : `${Prev}${K}` | NestedPathsAccess<T[K], `${Prev}${K}.`>;
8
+ }[NonFunctionPropertyNames<T> & string];
9
+ export {};
10
+ //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/types/utilities.ts"],"names":[],"mappings":"AAAA,KAAK,wBAAwB,CAAC,CAAC,IAAI;KAE9B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC;CACpD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAElD,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAE7D,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,SAAS,GAC1E,KAAK,GACL,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACtB,CAAC,SAAS,SAAS,GACf,GAAG,IAAI,IAAI,MAAM,GAAG,GACpB,GAAG,IAAI,IAAI,MAAM,GAAG,GAAG,iBAAiB,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,MAAM,IAAI,CAAC,GACtE;KACK,CAAC,IAAI,wBAAwB,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,GAC7D,GAAG,IAAI,GAAG,CAAC,EAAE,GACb,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GACxB,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,GACtD,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC;CAClE,CAAC,wBAAwB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/types/utilities.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ declare function getGoogleServiceAccount(): any;
2
+ declare function isUndefined(val: unknown): val is undefined;
3
+ declare function isNull(val: unknown): val is null;
4
+ declare function isNullOrUndefined(val: unknown): val is null;
5
+ declare function isNumber(val: unknown): val is number;
6
+ declare function isObject(val: unknown): val is object;
7
+ declare function isError(val: unknown): val is Error;
8
+ declare function isBadOrEmptyString(val: unknown): boolean;
9
+ export { getGoogleServiceAccount, isUndefined, isNull, isNullOrUndefined, isNumber, isObject, isError, isBadOrEmptyString, };
10
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAOA,iBAAS,uBAAuB,QAE/B;AAED,iBAAS,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAEnD;AAED,iBAAS,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,IAAI,CAEzC;AAED,iBAAS,iBAAiB,CAAC,GAAG,EAAE,OAAO,eAEtC;AAED,iBAAS,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAE7C;AAED,iBAAS,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAE7C;AAED,iBAAS,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,KAAK,CAE3C;AAED,iBAAS,kBAAkB,CAAC,GAAG,EAAE,OAAO,WAMvC;AAED,OAAO,EACH,uBAAuB,EACvB,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,kBAAkB,GACrB,CAAC"}
package/dist/utils.js ADDED
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getGoogleServiceAccount = getGoogleServiceAccount;
7
+ exports.isUndefined = isUndefined;
8
+ exports.isNull = isNull;
9
+ exports.isNullOrUndefined = isNullOrUndefined;
10
+ exports.isNumber = isNumber;
11
+ exports.isObject = isObject;
12
+ exports.isError = isError;
13
+ exports.isBadOrEmptyString = isBadOrEmptyString;
14
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
15
+ require('dotenv').config();
16
+ const path_1 = __importDefault(require("path"));
17
+ const firebaseAdminServiceAccountName = 'miia-telegram-bot-e3993ff1611c.json';
18
+ function getGoogleServiceAccount() {
19
+ return require(path_1.default.resolve(process.cwd(), 'keys', firebaseAdminServiceAccountName));
20
+ }
21
+ function isUndefined(val) {
22
+ return typeof val === 'undefined';
23
+ }
24
+ function isNull(val) {
25
+ return val === null;
26
+ }
27
+ function isNullOrUndefined(val) {
28
+ return isNull(val) || isUndefined(val);
29
+ }
30
+ function isNumber(val) {
31
+ return typeof val === 'number' && Number.isFinite(Number(val));
32
+ }
33
+ function isObject(val) {
34
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase() === 'object';
35
+ }
36
+ function isError(val) {
37
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase() === 'error';
38
+ }
39
+ function isBadOrEmptyString(val) {
40
+ if (isNullOrUndefined(val) || typeof val !== 'string') {
41
+ return true;
42
+ }
43
+ return val.trim().length === 0;
44
+ }
45
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;AA4CI,0DAAuB;AACvB,kCAAW;AACX,wBAAM;AACN,8CAAiB;AACjB,4BAAQ;AACR,4BAAQ;AACR,0BAAO;AACP,gDAAkB;AAnDtB,8DAA8D;AAC9D,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;AAE3B,gDAAwB;AAExB,MAAM,+BAA+B,GAAG,qCAAqC,CAAC;AAE9E,SAAS,uBAAuB;IAC5B,OAAO,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,+BAA+B,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,WAAW,CAAC,GAAY;IAC7B,OAAO,OAAO,GAAG,KAAK,WAAW,CAAC;AACtC,CAAC;AAED,SAAS,MAAM,CAAC,GAAY;IACxB,OAAO,GAAG,KAAK,IAAI,CAAC;AACxB,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAY;IACnC,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,QAAQ,CAAC,GAAY;IAC1B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,QAAQ,CAAC,GAAY;IAC1B,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC;AACvF,CAAC;AAED,SAAS,OAAO,CAAC,GAAY;IACzB,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC;AACtF,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAY;IACpC,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;AACnC,CAAC"}
package/package.json CHANGED
@@ -1,47 +1,57 @@
1
1
  {
2
- "name": "@misterhomer1992/miit-bot-payment",
3
- "version": "1.0.0",
4
- "description": "A TypeScript utility library for payment validation and formatting",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc",
9
- "prepublishOnly": "npm run build",
10
- "test": "node --test dist/**/*.test.js",
11
- "lint": "eslint src --ext .ts",
12
- "format": "prettier --write \"src/**/*.ts\"",
13
- "watch": "tsc --watch",
14
- "example": "ts-node example.ts"
15
- },
16
- "keywords": [
17
- "payment",
18
- "validation",
19
- "formatting",
20
- "typescript",
21
- "utilities"
22
- ],
23
- "author": "",
24
- "license": "MIT",
25
- "devDependencies": {
26
- "@types/node": "^20.10.0",
27
- "@typescript-eslint/eslint-plugin": "^6.13.0",
28
- "@typescript-eslint/parser": "^6.13.0",
29
- "eslint": "^8.54.0",
30
- "prettier": "^3.1.0",
31
- "ts-node": "^10.9.2",
32
- "typescript": "^5.3.2"
33
- },
34
- "files": [
35
- "dist",
36
- "README.md",
37
- "LICENSE"
38
- ],
39
- "repository": {
40
- "type": "git",
41
- "url": "git+https://github.com/misterhomer1992/miit-bot-payment.git"
42
- },
43
- "bugs": {
44
- "url": "https://github.com/misterhomer1992/miit-bot-payment/issues"
45
- },
46
- "homepage": "https://github.com/misterhomer1992/miit-bot-payment#readme"
2
+ "name": "@misterhomer1992/miit-bot-payment",
3
+ "version": "1.0.1",
4
+ "description": "A TypeScript utility library for payment validation and formatting",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepublishOnly": "npm run build",
10
+ "test": "node --test dist/**/*.test.js",
11
+ "lint": "eslint src --ext .ts",
12
+ "format": "prettier --write \"src/**/*.ts\"",
13
+ "watch": "tsc --watch",
14
+ "example": "ts-node example.ts",
15
+ "type-checking": "tsc --noEmit --project tsconfig.json --watch"
16
+ },
17
+ "keywords": [
18
+ "payment",
19
+ "validation",
20
+ "formatting",
21
+ "typescript",
22
+ "utilities"
23
+ ],
24
+ "author": "",
25
+ "license": "MIT",
26
+ "dependencies": {
27
+ "cross-env": "10.0.0",
28
+ "moment": "2.30.1",
29
+ "dotenv": "17.2.2",
30
+ "axios": "1.12.2",
31
+ "firebase-admin": "^11.6.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^20.10.0",
35
+ "@typescript-eslint/eslint-plugin": "^6.13.0",
36
+ "@typescript-eslint/parser": "^6.13.0",
37
+ "ts-node": "^10.9.2",
38
+ "typescript": "^5.3.2",
39
+ "eslint": "^8.48.0",
40
+ "eslint-config-airbnb": "^19.0.4",
41
+ "eslint-config-prettier": "^9.0.0",
42
+ "prettier": "3.6.2"
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "README.md",
47
+ "LICENSE"
48
+ ],
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/misterhomer1992/miit-bot-payment.git"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/misterhomer1992/miit-bot-payment/issues"
55
+ },
56
+ "homepage": "https://github.com/misterhomer1992/miit-bot-payment#readme"
47
57
  }