@misterhomer1992/miit-bot-payment 1.0.6 → 1.0.8

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/README.md +1 -359
  2. package/dist/modules/cancellableAPI/utils.d.ts +1 -2
  3. package/dist/modules/cancellableAPI/utils.d.ts.map +1 -1
  4. package/dist/modules/cancellableAPI/utils.js.map +1 -1
  5. package/dist/modules/invoice/repository.d.ts +6 -26
  6. package/dist/modules/invoice/repository.d.ts.map +1 -1
  7. package/dist/modules/invoice/repository.js +2 -25
  8. package/dist/modules/invoice/repository.js.map +1 -1
  9. package/dist/modules/invoice/service.d.ts +6 -22
  10. package/dist/modules/invoice/service.d.ts.map +1 -1
  11. package/dist/modules/invoice/service.js +2 -21
  12. package/dist/modules/invoice/service.js.map +1 -1
  13. package/dist/modules/invoice/types.d.ts +30 -1
  14. package/dist/modules/invoice/types.d.ts.map +1 -1
  15. package/dist/modules/payments/api.d.ts +3 -4
  16. package/dist/modules/payments/api.d.ts.map +1 -1
  17. package/dist/modules/payments/api.js +3 -3
  18. package/dist/modules/payments/api.js.map +1 -1
  19. package/dist/modules/payments/repository.d.ts +7 -61
  20. package/dist/modules/payments/repository.d.ts.map +1 -1
  21. package/dist/modules/payments/repository.js +4 -59
  22. package/dist/modules/payments/repository.js.map +1 -1
  23. package/dist/modules/payments/service.d.ts +8 -67
  24. package/dist/modules/payments/service.d.ts.map +1 -1
  25. package/dist/modules/payments/service.js +7 -68
  26. package/dist/modules/payments/service.js.map +1 -1
  27. package/dist/modules/payments/types.d.ts +100 -3
  28. package/dist/modules/payments/types.d.ts.map +1 -1
  29. package/dist/modules/payments/utils.d.ts +3 -4
  30. package/dist/modules/payments/utils.d.ts.map +1 -1
  31. package/dist/modules/payments/utils.js +6 -6
  32. package/dist/modules/payments/utils.js.map +1 -1
  33. package/dist/modules/subscription/repository.d.ts +10 -85
  34. package/dist/modules/subscription/repository.d.ts.map +1 -1
  35. package/dist/modules/subscription/repository.js +17 -109
  36. package/dist/modules/subscription/repository.js.map +1 -1
  37. package/dist/modules/subscription/service.d.ts +13 -89
  38. package/dist/modules/subscription/service.d.ts.map +1 -1
  39. package/dist/modules/subscription/service.js +10 -83
  40. package/dist/modules/subscription/service.js.map +1 -1
  41. package/dist/modules/subscription/types.d.ts +127 -3
  42. package/dist/modules/subscription/types.d.ts.map +1 -1
  43. package/dist/modules/user/types.d.ts +67 -2
  44. package/dist/modules/user/types.d.ts.map +1 -1
  45. package/dist/modules/user/userRepository.d.ts +9 -48
  46. package/dist/modules/user/userRepository.d.ts.map +1 -1
  47. package/dist/modules/user/userRepository.js +8 -48
  48. package/dist/modules/user/userRepository.js.map +1 -1
  49. package/dist/modules/user/userService.d.ts +9 -38
  50. package/dist/modules/user/userService.d.ts.map +1 -1
  51. package/dist/modules/user/userService.js +5 -36
  52. package/dist/modules/user/userService.js.map +1 -1
  53. package/package.json +1 -1
@@ -1,64 +1,25 @@
1
- import { FieldValue } from 'firebase-admin/firestore';
2
- import { User, UserFieldPath } from './types';
3
- import { AppNamespace } from '../app/types';
1
+ import { FieldValue, Firestore } from 'firebase-admin/firestore';
2
+ import { User, UserFieldPath, IUserRepository } from './types';
4
3
  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 {
4
+ export declare class UserRepository implements IUserRepository {
10
5
  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
- */
6
+ constructor({ db }?: {
7
+ db?: Firestore;
8
+ });
22
9
  getByUserId(params: {
23
10
  userId: string;
24
- appNamespace: string;
11
+ platform: string;
25
12
  }): 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
13
  create(params: {
35
14
  user: User;
36
- appNamespace: string;
15
+ platform: string;
37
16
  }): 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
17
  updateFieldsByUserId(params: {
47
- appNamespace: AppNamespace;
18
+ platform: string;
48
19
  userId: string;
49
20
  fields: UpdateDBUserFields;
50
21
  }): Promise<void>;
51
- /**
52
- * Maps a Firestore document to a User entity.
53
- * @param doc - Firestore document snapshot
54
- * @returns User entity
55
- */
56
22
  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
23
  private buildUpdateObject;
63
24
  }
64
25
  //# 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,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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AM,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/D,oBAAoB,CAAC,MAAM,EAAE;QACtC,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,kBAAkB,CAAC;KAC9B,GAAG,OAAO,CAAC,IAAI,CAAC;IAcjB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,iBAAiB;CAW5B"}
@@ -2,74 +2,34 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserRepository = void 0;
4
4
  const firestore_1 = require("firebase-admin/firestore");
5
- /**
6
- * UserRepository class handles all database operations related to users.
7
- * Implements repository pattern for user data access.
8
- */
9
5
  class UserRepository {
10
- /**
11
- * Creates an instance of UserRepository.
12
- */
13
- constructor() {
14
- this.db = (0, firestore_1.getFirestore)();
6
+ constructor({ db } = {}) {
7
+ this.db = db || (0, firestore_1.getFirestore)();
15
8
  }
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
9
  async getByUserId(params) {
24
- const { userId, appNamespace } = params;
25
- const docSnapshot = await this.db.collection(`platform/${appNamespace}/users`).doc(userId).get();
10
+ const { userId, platform } = params;
11
+ const docSnapshot = await this.db.collection(`platform/${platform}/users`).doc(userId).get();
26
12
  if (!docSnapshot.exists) {
27
13
  return null;
28
14
  }
29
15
  return this.mapDocumentToEntity(docSnapshot);
30
16
  }
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
17
  async create(params) {
40
- const { user, appNamespace } = params;
41
- await this.db.collection(`platform/${appNamespace}/users`).doc(user.user.id).set(user);
18
+ const { user, platform } = params;
19
+ await this.db.collection(`platform/${platform}/users`).doc(user.user.id).set(user);
42
20
  }
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
21
  async updateFieldsByUserId(params) {
52
- const { userId, appNamespace, fields } = params;
22
+ const { userId, platform, fields } = params;
53
23
  const updateObject = this.buildUpdateObject(fields);
54
- const snapshot = await this.db.collection(`platform/${appNamespace}/users`).doc(userId).get();
24
+ const snapshot = await this.db.collection(`platform/${platform}/users`).doc(userId).get();
55
25
  if (!snapshot.exists) {
56
26
  throw new Error(`User not found: ${userId}`);
57
27
  }
58
28
  await snapshot.ref.update(updateObject);
59
29
  }
60
- /**
61
- * Maps a Firestore document to a User entity.
62
- * @param doc - Firestore document snapshot
63
- * @returns User entity
64
- */
65
30
  mapDocumentToEntity(doc) {
66
31
  return doc.data();
67
32
  }
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
33
  buildUpdateObject(fields) {
74
34
  const updateObject = {};
75
35
  fields
@@ -1 +1 @@
1
- {"version":3,"file":"userRepository.js","sourceRoot":"","sources":["../../../src/modules/user/userRepository.ts"],"names":[],"mappings":";;;AAAA,wDAAiG;AAMjG;;;GAGG;AACH,MAAa,cAAc;IAGvB;;OAEG;IACH;QACI,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAY,GAAE,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,WAAW,CAAC,MAAgD;QACrE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;QAExC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,YAAY,QAAQ,CAAC,CAAC,GA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C;QACG,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAE5C,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAEpD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,QAAQ,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;QAE1F,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;IAEO,mBAAmB,CAAC,GAAqB;QAC7C,OAAO,GAAG,CAAC,IAAI,EAAU,CAAC;IAC9B,CAAC;IAEO,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;AA1DD,wCA0DC"}
@@ -1,52 +1,23 @@
1
1
  import { Logger } from '../logger/types';
2
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 {
3
+ import { User, IUserRepository, IUserService } from './types';
4
+ export declare class UserService implements IUserService {
10
5
  private readonly logger;
11
6
  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
- */
7
+ constructor({ logger, repository }: {
8
+ logger: Logger;
9
+ repository?: IUserRepository;
10
+ });
24
11
  getByUserId(params: {
25
12
  userId: string;
26
- appNamespace: string;
13
+ platform: string;
27
14
  }): 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
15
  create(params: {
37
16
  user: User;
38
- appNamespace: string;
17
+ platform: string;
39
18
  }): 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
19
  updateFieldsByUserId(params: {
49
- appNamespace: AppNamespace;
20
+ platform: string;
50
21
  userId: string;
51
22
  fields: UpdateDBUserFields;
52
23
  }): Promise<void>;
@@ -1 +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;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AAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB/D,oBAAoB,CAAC,MAAM,EAAE;QACtC,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,kBAAkB,CAAC;KAC9B,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBpB"}
@@ -2,26 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserService = void 0;
4
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
5
  class UserService {
10
- /**
11
- * Creates an instance of UserService.
12
- * @param logger - Application logger instance for logging operations
13
- */
14
- constructor(logger) {
6
+ constructor({ logger, repository }) {
15
7
  this.logger = logger;
16
- this.repository = new userRepository_1.UserRepository();
8
+ this.repository = repository || new userRepository_1.UserRepository();
17
9
  }
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
10
  async getByUserId(params) {
26
11
  try {
27
12
  return await this.repository.getByUserId(params);
@@ -31,21 +16,13 @@ class UserService {
31
16
  message: 'Error in user service getByUserId',
32
17
  payload: {
33
18
  userId: params.userId,
34
- appNamespace: params.appNamespace,
19
+ platform: params.platform,
35
20
  error: JSON.stringify(error),
36
21
  },
37
22
  });
38
23
  return null;
39
24
  }
40
25
  }
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
26
  async create(params) {
50
27
  try {
51
28
  await this.repository.create(params);
@@ -55,21 +32,13 @@ class UserService {
55
32
  message: 'Error in user service create',
56
33
  payload: {
57
34
  userId: params.user.user.id,
58
- appNamespace: params.appNamespace,
35
+ platform: params.platform,
59
36
  error: JSON.stringify(error),
60
37
  },
61
38
  });
62
39
  throw error;
63
40
  }
64
41
  }
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
42
  async updateFieldsByUserId(params) {
74
43
  try {
75
44
  await this.repository.updateFieldsByUserId(params);
@@ -79,7 +48,7 @@ class UserService {
79
48
  message: 'Error in user service updateFieldsByUserId',
80
49
  payload: {
81
50
  userId: params.userId,
82
- appNamespace: params.appNamespace,
51
+ platform: params.platform,
83
52
  fields: JSON.stringify(params.fields),
84
53
  error: JSON.stringify(error),
85
54
  },
@@ -1 +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"}
1
+ {"version":3,"file":"userService.js","sourceRoot":"","sources":["../../../src/modules/user/userService.ts"],"names":[],"mappings":";;;AACA,qDAAsE;AAGtE,MAAa,WAAW;IAIpB,YAAY,EAAE,MAAM,EAAE,UAAU,EAAoD;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AAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBACd,OAAO,EAAE,4CAA4C;gBACrD,OAAO,EAAE;oBACL,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,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;AA/DD,kCA+DC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misterhomer1992/miit-bot-payment",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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",