@managesome/knotr-toolkit 0.1.1 → 0.8.5

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 (300) hide show
  1. package/dist/backend/config.d.ts +43 -0
  2. package/dist/backend/config.d.ts.map +1 -0
  3. package/dist/backend/config.js +82 -0
  4. package/dist/backend/config.js.map +1 -0
  5. package/dist/backend/database.d.ts +28 -0
  6. package/dist/backend/database.d.ts.map +1 -0
  7. package/dist/backend/database.js +112 -0
  8. package/dist/backend/database.js.map +1 -0
  9. package/dist/backend/firebase.d.ts +68 -0
  10. package/dist/backend/firebase.d.ts.map +1 -0
  11. package/dist/backend/firebase.js +233 -0
  12. package/dist/backend/firebase.js.map +1 -0
  13. package/dist/backend/index.d.ts +8 -0
  14. package/dist/backend/index.d.ts.map +1 -0
  15. package/dist/backend/index.js +19 -0
  16. package/dist/backend/index.js.map +1 -0
  17. package/dist/backend/logger.d.ts +23 -0
  18. package/dist/backend/logger.d.ts.map +1 -0
  19. package/dist/backend/logger.js +107 -0
  20. package/dist/backend/logger.js.map +1 -0
  21. package/dist/backend/redis.d.ts +59 -0
  22. package/dist/backend/redis.d.ts.map +1 -0
  23. package/dist/backend/redis.js +169 -0
  24. package/dist/backend/redis.js.map +1 -0
  25. package/dist/backend/socket.d.ts +81 -0
  26. package/dist/backend/socket.d.ts.map +1 -0
  27. package/dist/backend/socket.js +132 -0
  28. package/dist/backend/socket.js.map +1 -0
  29. package/dist/backend/worker-queue.d.ts +40 -0
  30. package/dist/backend/worker-queue.d.ts.map +1 -0
  31. package/dist/backend/worker-queue.js +140 -0
  32. package/dist/backend/worker-queue.js.map +1 -0
  33. package/dist/client/api-client.d.ts +101 -0
  34. package/dist/client/api-client.d.ts.map +1 -0
  35. package/dist/client/api-client.js +261 -0
  36. package/dist/client/api-client.js.map +1 -0
  37. package/dist/client/api-error.d.ts +100 -0
  38. package/dist/client/api-error.d.ts.map +1 -0
  39. package/dist/client/api-error.js +111 -0
  40. package/dist/client/api-error.js.map +1 -0
  41. package/dist/client/endpoints.d.ts +510 -0
  42. package/dist/client/endpoints.d.ts.map +1 -0
  43. package/dist/client/endpoints.js +306 -0
  44. package/dist/client/endpoints.js.map +1 -0
  45. package/dist/client/index.d.ts +4 -0
  46. package/dist/client/index.d.ts.map +1 -0
  47. package/dist/client/index.js +7 -0
  48. package/dist/client/index.js.map +1 -0
  49. package/dist/constants/index.d.ts +2 -1
  50. package/dist/constants/index.d.ts.map +1 -1
  51. package/dist/constants/index.js +2 -1
  52. package/dist/constants/index.js.map +1 -1
  53. package/dist/constants/socket.d.ts +165 -0
  54. package/dist/constants/socket.d.ts.map +1 -0
  55. package/dist/constants/socket.js +204 -0
  56. package/dist/constants/socket.js.map +1 -0
  57. package/dist/helpers/ApiError.d.ts +74 -0
  58. package/dist/helpers/ApiError.d.ts.map +1 -0
  59. package/dist/helpers/ApiError.js +105 -0
  60. package/dist/helpers/ApiError.js.map +1 -0
  61. package/dist/helpers/asyncHandler.d.ts +42 -0
  62. package/dist/helpers/asyncHandler.d.ts.map +1 -0
  63. package/dist/helpers/asyncHandler.js +47 -0
  64. package/dist/helpers/asyncHandler.js.map +1 -0
  65. package/dist/helpers/id-generator.d.ts +98 -0
  66. package/dist/helpers/id-generator.d.ts.map +1 -0
  67. package/dist/helpers/id-generator.js +128 -0
  68. package/dist/helpers/id-generator.js.map +1 -0
  69. package/dist/helpers/index.d.ts +5 -0
  70. package/dist/helpers/index.d.ts.map +1 -0
  71. package/dist/helpers/index.js +8 -0
  72. package/dist/helpers/index.js.map +1 -0
  73. package/dist/helpers/response-timing.d.ts +91 -0
  74. package/dist/helpers/response-timing.d.ts.map +1 -0
  75. package/dist/helpers/response-timing.js +176 -0
  76. package/dist/helpers/response-timing.js.map +1 -0
  77. package/dist/index.d.ts +7 -3
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +21 -3
  80. package/dist/index.js.map +1 -1
  81. package/dist/schemas/account.schema.d.ts +4500 -0
  82. package/dist/schemas/account.schema.d.ts.map +1 -0
  83. package/dist/schemas/account.schema.js +123 -0
  84. package/dist/schemas/account.schema.js.map +1 -0
  85. package/dist/schemas/chat.schema.d.ts +4796 -0
  86. package/dist/schemas/chat.schema.d.ts.map +1 -0
  87. package/dist/schemas/chat.schema.js +107 -0
  88. package/dist/schemas/chat.schema.js.map +1 -0
  89. package/dist/schemas/collaboration-request.schema.d.ts +3960 -0
  90. package/dist/schemas/collaboration-request.schema.d.ts.map +1 -0
  91. package/dist/schemas/collaboration-request.schema.js +92 -0
  92. package/dist/schemas/collaboration-request.schema.js.map +1 -0
  93. package/dist/schemas/company-review.schema.d.ts +3465 -0
  94. package/dist/schemas/company-review.schema.d.ts.map +1 -0
  95. package/dist/schemas/company-review.schema.js +73 -0
  96. package/dist/schemas/company-review.schema.js.map +1 -0
  97. package/dist/schemas/company.schema.d.ts +6152 -0
  98. package/dist/schemas/company.schema.d.ts.map +1 -0
  99. package/dist/schemas/company.schema.js +192 -0
  100. package/dist/schemas/company.schema.js.map +1 -0
  101. package/dist/schemas/contract.schema.d.ts +5286 -0
  102. package/dist/schemas/contract.schema.d.ts.map +1 -0
  103. package/dist/schemas/contract.schema.js +115 -0
  104. package/dist/schemas/contract.schema.js.map +1 -0
  105. package/dist/schemas/dispute-evidence.schema.d.ts +3788 -0
  106. package/dist/schemas/dispute-evidence.schema.d.ts.map +1 -0
  107. package/dist/schemas/dispute-evidence.schema.js +71 -0
  108. package/dist/schemas/dispute-evidence.schema.js.map +1 -0
  109. package/dist/schemas/dispute.schema.d.ts +4970 -0
  110. package/dist/schemas/dispute.schema.d.ts.map +1 -0
  111. package/dist/schemas/dispute.schema.js +152 -0
  112. package/dist/schemas/dispute.schema.js.map +1 -0
  113. package/dist/schemas/donation.schema.d.ts +3594 -0
  114. package/dist/schemas/donation.schema.d.ts.map +1 -0
  115. package/dist/schemas/donation.schema.js +95 -0
  116. package/dist/schemas/donation.schema.js.map +1 -0
  117. package/dist/schemas/escrow.schema.d.ts +4322 -0
  118. package/dist/schemas/escrow.schema.d.ts.map +1 -0
  119. package/dist/schemas/escrow.schema.js +93 -0
  120. package/dist/schemas/escrow.schema.js.map +1 -0
  121. package/dist/schemas/flag.schema.d.ts +4375 -0
  122. package/dist/schemas/flag.schema.d.ts.map +1 -0
  123. package/dist/schemas/flag.schema.js +133 -0
  124. package/dist/schemas/flag.schema.js.map +1 -0
  125. package/dist/schemas/index.d.ts +33 -0
  126. package/dist/schemas/index.d.ts.map +1 -0
  127. package/dist/schemas/index.js +39 -0
  128. package/dist/schemas/index.js.map +1 -0
  129. package/dist/schemas/interest.schema.d.ts +3804 -0
  130. package/dist/schemas/interest.schema.d.ts.map +1 -0
  131. package/dist/schemas/interest.schema.js +107 -0
  132. package/dist/schemas/interest.schema.js.map +1 -0
  133. package/dist/schemas/match.schema.d.ts +4013 -0
  134. package/dist/schemas/match.schema.d.ts.map +1 -0
  135. package/dist/schemas/match.schema.js +118 -0
  136. package/dist/schemas/match.schema.js.map +1 -0
  137. package/dist/schemas/message.schema.d.ts +4213 -0
  138. package/dist/schemas/message.schema.d.ts.map +1 -0
  139. package/dist/schemas/message.schema.js +134 -0
  140. package/dist/schemas/message.schema.js.map +1 -0
  141. package/dist/schemas/milestone.schema.d.ts +4310 -0
  142. package/dist/schemas/milestone.schema.d.ts.map +1 -0
  143. package/dist/schemas/milestone.schema.js +99 -0
  144. package/dist/schemas/milestone.schema.js.map +1 -0
  145. package/dist/schemas/notification.schema.d.ts +4641 -0
  146. package/dist/schemas/notification.schema.d.ts.map +1 -0
  147. package/dist/schemas/notification.schema.js +139 -0
  148. package/dist/schemas/notification.schema.js.map +1 -0
  149. package/dist/schemas/profile.schema.d.ts +9589 -0
  150. package/dist/schemas/profile.schema.d.ts.map +1 -0
  151. package/dist/schemas/profile.schema.js +360 -0
  152. package/dist/schemas/profile.schema.js.map +1 -0
  153. package/dist/schemas/profit-share-agreement.schema.d.ts +3789 -0
  154. package/dist/schemas/profit-share-agreement.schema.d.ts.map +1 -0
  155. package/dist/schemas/profit-share-agreement.schema.js +76 -0
  156. package/dist/schemas/profit-share-agreement.schema.js.map +1 -0
  157. package/dist/schemas/profit-share.schema.d.ts +4051 -0
  158. package/dist/schemas/profit-share.schema.d.ts.map +1 -0
  159. package/dist/schemas/profit-share.schema.js +96 -0
  160. package/dist/schemas/profit-share.schema.js.map +1 -0
  161. package/dist/schemas/promo-code.schema.d.ts +3924 -0
  162. package/dist/schemas/promo-code.schema.d.ts.map +1 -0
  163. package/dist/schemas/promo-code.schema.js +112 -0
  164. package/dist/schemas/promo-code.schema.js.map +1 -0
  165. package/dist/schemas/proposal.schema.d.ts +5182 -0
  166. package/dist/schemas/proposal.schema.d.ts.map +1 -0
  167. package/dist/schemas/proposal.schema.js +114 -0
  168. package/dist/schemas/proposal.schema.js.map +1 -0
  169. package/dist/schemas/purchase.schema.d.ts +3724 -0
  170. package/dist/schemas/purchase.schema.d.ts.map +1 -0
  171. package/dist/schemas/purchase.schema.js +89 -0
  172. package/dist/schemas/purchase.schema.js.map +1 -0
  173. package/dist/schemas/requirement-post.schema.d.ts +6315 -0
  174. package/dist/schemas/requirement-post.schema.d.ts.map +1 -0
  175. package/dist/schemas/requirement-post.schema.js +153 -0
  176. package/dist/schemas/requirement-post.schema.js.map +1 -0
  177. package/dist/schemas/review.schema.d.ts +4512 -0
  178. package/dist/schemas/review.schema.d.ts.map +1 -0
  179. package/dist/schemas/review.schema.js +121 -0
  180. package/dist/schemas/review.schema.js.map +1 -0
  181. package/dist/schemas/service-listing.schema.d.ts +5152 -0
  182. package/dist/schemas/service-listing.schema.d.ts.map +1 -0
  183. package/dist/schemas/service-listing.schema.js +137 -0
  184. package/dist/schemas/service-listing.schema.js.map +1 -0
  185. package/dist/schemas/subscription.schema.d.ts +3985 -0
  186. package/dist/schemas/subscription.schema.d.ts.map +1 -0
  187. package/dist/schemas/subscription.schema.js +94 -0
  188. package/dist/schemas/subscription.schema.js.map +1 -0
  189. package/dist/schemas/tmc-application.schema.d.ts +4357 -0
  190. package/dist/schemas/tmc-application.schema.d.ts.map +1 -0
  191. package/dist/schemas/tmc-application.schema.js +96 -0
  192. package/dist/schemas/tmc-application.schema.js.map +1 -0
  193. package/dist/schemas/tmc-membership.schema.d.ts +3985 -0
  194. package/dist/schemas/tmc-membership.schema.d.ts.map +1 -0
  195. package/dist/schemas/tmc-membership.schema.js +84 -0
  196. package/dist/schemas/tmc-membership.schema.js.map +1 -0
  197. package/dist/schemas/trust-badge.schema.d.ts +3919 -0
  198. package/dist/schemas/trust-badge.schema.d.ts.map +1 -0
  199. package/dist/schemas/trust-badge.schema.js +83 -0
  200. package/dist/schemas/trust-badge.schema.js.map +1 -0
  201. package/dist/schemas/verification.schema.d.ts +4606 -0
  202. package/dist/schemas/verification.schema.d.ts.map +1 -0
  203. package/dist/schemas/verification.schema.js +114 -0
  204. package/dist/schemas/verification.schema.js.map +1 -0
  205. package/dist/schemas/webhook-event.schema.d.ts +3534 -0
  206. package/dist/schemas/webhook-event.schema.d.ts.map +1 -0
  207. package/dist/schemas/webhook-event.schema.js +83 -0
  208. package/dist/schemas/webhook-event.schema.js.map +1 -0
  209. package/dist/types/account.d.ts +36 -7
  210. package/dist/types/account.d.ts.map +1 -1
  211. package/dist/types/account.js +3 -1
  212. package/dist/types/account.js.map +1 -1
  213. package/dist/types/admin.d.ts +20 -10
  214. package/dist/types/admin.d.ts.map +1 -1
  215. package/dist/types/admin.js +3 -1
  216. package/dist/types/admin.js.map +1 -1
  217. package/dist/types/api.d.ts +184 -109
  218. package/dist/types/api.d.ts.map +1 -1
  219. package/dist/types/api.js +2 -1
  220. package/dist/types/api.js.map +1 -1
  221. package/dist/types/chat.d.ts +38 -20
  222. package/dist/types/chat.d.ts.map +1 -1
  223. package/dist/types/chat.js +3 -1
  224. package/dist/types/chat.js.map +1 -1
  225. package/dist/types/common.d.ts +39 -12
  226. package/dist/types/common.d.ts.map +1 -1
  227. package/dist/types/common.js +4 -1
  228. package/dist/types/common.js.map +1 -1
  229. package/dist/types/company.d.ts +61 -44
  230. package/dist/types/company.d.ts.map +1 -1
  231. package/dist/types/company.js +3 -1
  232. package/dist/types/company.js.map +1 -1
  233. package/dist/types/flag.d.ts +19 -8
  234. package/dist/types/flag.d.ts.map +1 -1
  235. package/dist/types/flag.js +3 -1
  236. package/dist/types/flag.js.map +1 -1
  237. package/dist/types/forms.d.ts +334 -0
  238. package/dist/types/forms.d.ts.map +1 -0
  239. package/dist/types/forms.js +5 -0
  240. package/dist/types/forms.js.map +1 -0
  241. package/dist/types/index.d.ts +18 -13
  242. package/dist/types/index.d.ts.map +1 -1
  243. package/dist/types/index.js +18 -13
  244. package/dist/types/index.js.map +1 -1
  245. package/dist/types/marketplace.d.ts +174 -104
  246. package/dist/types/marketplace.d.ts.map +1 -1
  247. package/dist/types/marketplace.js +2 -0
  248. package/dist/types/marketplace.js.map +1 -1
  249. package/dist/types/match.d.ts +36 -19
  250. package/dist/types/match.d.ts.map +1 -1
  251. package/dist/types/match.js +3 -1
  252. package/dist/types/match.js.map +1 -1
  253. package/dist/types/navigation.d.ts +305 -0
  254. package/dist/types/navigation.d.ts.map +1 -0
  255. package/dist/types/navigation.js +18 -0
  256. package/dist/types/navigation.js.map +1 -0
  257. package/dist/types/notification.d.ts +92 -0
  258. package/dist/types/notification.d.ts.map +1 -0
  259. package/dist/types/notification.js +5 -0
  260. package/dist/types/notification.js.map +1 -0
  261. package/dist/types/payment.d.ts +70 -38
  262. package/dist/types/payment.d.ts.map +1 -1
  263. package/dist/types/payment.js +3 -1
  264. package/dist/types/payment.js.map +1 -1
  265. package/dist/types/policy.d.ts +174 -81
  266. package/dist/types/policy.d.ts.map +1 -1
  267. package/dist/types/policy.js.map +1 -1
  268. package/dist/types/profile.d.ts +48 -37
  269. package/dist/types/profile.d.ts.map +1 -1
  270. package/dist/types/profile.js +3 -1
  271. package/dist/types/profile.js.map +1 -1
  272. package/dist/types/socket.d.ts +431 -0
  273. package/dist/types/socket.d.ts.map +1 -0
  274. package/dist/types/socket.js +5 -0
  275. package/dist/types/socket.js.map +1 -0
  276. package/dist/types/verification.d.ts +18 -9
  277. package/dist/types/verification.d.ts.map +1 -1
  278. package/dist/types/verification.js +3 -1
  279. package/dist/types/verification.js.map +1 -1
  280. package/dist/types/worker.d.ts +452 -0
  281. package/dist/types/worker.d.ts.map +1 -0
  282. package/dist/types/worker.js +5 -0
  283. package/dist/types/worker.js.map +1 -0
  284. package/dist/validation/index.d.ts +5 -0
  285. package/dist/validation/index.d.ts.map +1 -0
  286. package/dist/validation/index.js +9 -0
  287. package/dist/validation/index.js.map +1 -0
  288. package/dist/validation/messages.d.ts +124 -0
  289. package/dist/validation/messages.d.ts.map +1 -0
  290. package/dist/validation/messages.js +160 -0
  291. package/dist/validation/messages.js.map +1 -0
  292. package/dist/validation/schemas.d.ts +1127 -0
  293. package/dist/validation/schemas.d.ts.map +1 -0
  294. package/dist/validation/schemas.js +376 -0
  295. package/dist/validation/schemas.js.map +1 -0
  296. package/dist/validation/validators.d.ts +229 -0
  297. package/dist/validation/validators.d.ts.map +1 -0
  298. package/dist/validation/validators.js +307 -0
  299. package/dist/validation/validators.js.map +1 -0
  300. package/package.json +37 -3
@@ -0,0 +1,204 @@
1
+ // ============================================
2
+ // Socket Constants - Event names and room helpers
3
+ // ============================================
4
+ /**
5
+ * Server-to-Client Socket.IO events
6
+ * Events emitted from server to clients
7
+ */
8
+ export const SOCKET_EVENTS = {
9
+ // Connection events
10
+ CONNECTED: 'connected',
11
+ DISCONNECTED: 'disconnected',
12
+ ERROR: 'error',
13
+ // Account events
14
+ ACCOUNT_UPDATED: 'account:updated',
15
+ ACCOUNT_SUSPENDED: 'account:suspended',
16
+ ACCOUNT_DELETED: 'account:deleted',
17
+ // Profile events
18
+ PROFILE_UPDATED: 'profile:updated',
19
+ PROFILE_APPROVED: 'profile:approved',
20
+ PROFILE_REJECTED: 'profile:rejected',
21
+ PROFILE_HOLD: 'profile:hold',
22
+ PROFILE_VIEW: 'profile:view',
23
+ // Match events
24
+ INTEREST_RECEIVED: 'interest:received',
25
+ INTEREST_ACCEPTED: 'interest:accepted',
26
+ INTEREST_DECLINED: 'interest:declined',
27
+ INTEREST_EXPIRED: 'interest:expired',
28
+ INTEREST_WITHDRAWN: 'interest:withdrawn',
29
+ MATCH_CREATED: 'match:created',
30
+ MATCH_ENDED: 'match:ended',
31
+ MATCH_SUCCESS: 'match:success',
32
+ // Chat events
33
+ CHAT_CREATED: 'chat:created',
34
+ CHAT_UPDATED: 'chat:updated',
35
+ CHAT_CLOSED: 'chat:closed',
36
+ MESSAGE_RECEIVED: 'message:received',
37
+ MESSAGE_READ: 'message:read',
38
+ MESSAGE_DELETED: 'message:deleted',
39
+ TYPING_START: 'typing:start',
40
+ TYPING_STOP: 'typing:stop',
41
+ // Notification events
42
+ NOTIFICATION_NEW: 'notification:new',
43
+ NOTIFICATION_READ: 'notification:read',
44
+ // Verification events
45
+ VERIFICATION_SUBMITTED: 'verification:submitted',
46
+ VERIFICATION_APPROVED: 'verification:approved',
47
+ VERIFICATION_REJECTED: 'verification:rejected',
48
+ // Subscription events
49
+ SUBSCRIPTION_CREATED: 'subscription:created',
50
+ SUBSCRIPTION_RENEWED: 'subscription:renewed',
51
+ SUBSCRIPTION_CANCELLED: 'subscription:cancelled',
52
+ SUBSCRIPTION_EXPIRED: 'subscription:expired',
53
+ // Moderation events
54
+ FLAG_RECEIVED: 'flag:received',
55
+ ACTION_TAKEN: 'action:taken',
56
+ WARNING_ISSUED: 'warning:issued',
57
+ // Company/TMC events
58
+ COMPANY_UPDATED: 'company:updated',
59
+ COMPANY_APPROVED: 'company:approved',
60
+ MEMBER_ADDED: 'member:added',
61
+ MEMBER_REMOVED: 'member:removed',
62
+ // Marketplace events
63
+ PROPOSAL_RECEIVED: 'proposal:received',
64
+ PROPOSAL_ACCEPTED: 'proposal:accepted',
65
+ PROPOSAL_DECLINED: 'proposal:declined',
66
+ CONTRACT_CREATED: 'contract:created',
67
+ CONTRACT_UPDATED: 'contract:updated',
68
+ MILESTONE_COMPLETED: 'milestone:completed',
69
+ MILESTONE_APPROVED: 'milestone:approved',
70
+ DISPUTE_OPENED: 'dispute:opened',
71
+ DISPUTE_RESOLVED: 'dispute:resolved',
72
+ PAYMENT_RECEIVED: 'payment:received',
73
+ PAYOUT_SENT: 'payout:sent',
74
+ };
75
+ /**
76
+ * Client-to-Server Socket.IO events
77
+ * Events sent from clients to server
78
+ */
79
+ export const CLIENT_EVENTS = {
80
+ // Connection
81
+ AUTHENTICATE: 'authenticate',
82
+ PING: 'ping',
83
+ // Presence
84
+ JOIN_ROOM: 'room:join',
85
+ LEAVE_ROOM: 'room:leave',
86
+ SET_STATUS: 'status:set',
87
+ SET_PRESENCE: 'presence:set',
88
+ GET_PRESENCE: 'presence:get',
89
+ // Chat
90
+ SEND_MESSAGE: 'message:send',
91
+ MARK_READ: 'message:read',
92
+ START_TYPING: 'typing:start',
93
+ STOP_TYPING: 'typing:stop',
94
+ DELETE_MESSAGE: 'message:delete',
95
+ JOIN_CHAT: 'chat:join',
96
+ LEAVE_CHAT: 'chat:leave',
97
+ // Account
98
+ JOIN_ACCOUNT: 'account:join',
99
+ LEAVE_ACCOUNT: 'account:leave',
100
+ // Notifications
101
+ MARK_NOTIFICATION_READ: 'notification:read',
102
+ MARK_ALL_NOTIFICATIONS_READ: 'notification:readAll',
103
+ };
104
+ // ============================================
105
+ // Room Helpers - Generate room names for Socket.IO
106
+ // ============================================
107
+ /**
108
+ * Get the room name for a specific user.
109
+ * Used for sending events to a specific user across all their devices.
110
+ *
111
+ * @param userId - User's account ID
112
+ * @returns Room name
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const room = getUserRoom("usr_abc123");
117
+ * io.to(room).emit("notification:new", payload);
118
+ * ```
119
+ */
120
+ export function getUserRoom(userId) {
121
+ return `user:${userId}`;
122
+ }
123
+ /**
124
+ * Get the room name for all users of an account.
125
+ * Useful for family accounts with multiple profiles.
126
+ *
127
+ * @param accountId - Account ID
128
+ * @returns Room name
129
+ */
130
+ export function getAccountRoom(accountId) {
131
+ return `account:${accountId}`;
132
+ }
133
+ /**
134
+ * Get the room name for a chat.
135
+ * Both participants join this room for real-time messaging.
136
+ *
137
+ * @param chatId - Chat ID
138
+ * @returns Room name
139
+ */
140
+ export function getChatRoom(chatId) {
141
+ return `chat:${chatId}`;
142
+ }
143
+ /**
144
+ * Get the room name for a match.
145
+ * Both matched users join for match-related events.
146
+ *
147
+ * @param matchId - Match ID
148
+ * @returns Room name
149
+ */
150
+ export function getMatchRoom(matchId) {
151
+ return `match:${matchId}`;
152
+ }
153
+ /**
154
+ * Get the room name for a company.
155
+ * All team members join for company events.
156
+ *
157
+ * @param companyId - Company ID
158
+ * @returns Room name
159
+ */
160
+ export function getCompanyRoom(companyId) {
161
+ return `company:${companyId}`;
162
+ }
163
+ /**
164
+ * Get the room name for marketplace contract.
165
+ * All parties join for contract updates.
166
+ *
167
+ * @param contractId - Contract ID
168
+ * @returns Room name
169
+ */
170
+ export function getContractRoom(contractId) {
171
+ return `contract:${contractId}`;
172
+ }
173
+ /**
174
+ * Get the room name for admins.
175
+ * Used for internal dashboard real-time updates.
176
+ *
177
+ * @param scope - Admin scope (e.g., "moderation", "support", "all")
178
+ * @returns Room name
179
+ */
180
+ export function getAdminRoom(scope = 'all') {
181
+ return `admin:${scope}`;
182
+ }
183
+ /**
184
+ * Get the room name for a dispute.
185
+ * All parties and assigned admins join.
186
+ *
187
+ * @param disputeId - Dispute ID
188
+ * @returns Room name
189
+ */
190
+ export function getDisputeRoom(disputeId) {
191
+ return `dispute:${disputeId}`;
192
+ }
193
+ // ============================================
194
+ // Room function aliases for backward compatibility
195
+ // ============================================
196
+ /** @deprecated Use getUserRoom instead */
197
+ export const userRoom = getUserRoom;
198
+ /** @deprecated Use getAccountRoom instead */
199
+ export const accountRoom = getAccountRoom;
200
+ /** @deprecated Use getChatRoom instead */
201
+ export const chatRoom = getChatRoom;
202
+ /** @deprecated Use getMatchRoom instead */
203
+ export const matchRoom = getMatchRoom;
204
+ //# sourceMappingURL=socket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/constants/socket.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,kDAAkD;AAClD,+CAA+C;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oBAAoB;IACpB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,KAAK,EAAE,OAAO;IAEd,iBAAiB;IACjB,eAAe,EAAE,iBAAiB;IAClC,iBAAiB,EAAE,mBAAmB;IACtC,eAAe,EAAE,iBAAiB;IAElC,iBAAiB;IACjB,eAAe,EAAE,iBAAiB;IAClC,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;IACpC,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAE5B,eAAe;IACf,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,gBAAgB,EAAE,kBAAkB;IACpC,kBAAkB,EAAE,oBAAoB;IACxC,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,eAAe;IAE9B,cAAc;IACd,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,YAAY,EAAE,cAAc;IAC5B,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAE1B,sBAAsB;IACtB,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IAEtC,sBAAsB;IACtB,sBAAsB,EAAE,wBAAwB;IAChD,qBAAqB,EAAE,uBAAuB;IAC9C,qBAAqB,EAAE,uBAAuB;IAE9C,sBAAsB;IACtB,oBAAoB,EAAE,sBAAsB;IA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 export type ApiErrorCode = 'BAD_REQUEST' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'CONFLICT' | 'VALIDATION_ERROR' | 'RATE_LIMIT_EXCEEDED' | 'INTERNAL_ERROR' | 'SERVICE_UNAVAILABLE' | 'TIMEOUT' | 'PAYMENT_REQUIRED' | 'UNPROCESSABLE_ENTITY';
5
+ /**
6
+ * Error details for validation errors
7
+ */
8
+ export interface ValidationErrorDetail {
9
+ field: string;
10
+ message: string;
11
+ code?: string;
12
+ }
13
+ /**
14
+ * Custom error class for API errors with status codes and error codes.
15
+ * Extends the native Error class with additional properties for HTTP responses.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * throw new ApiError(404, "User not found", "NOT_FOUND");
20
+ *
21
+ * throw new ApiError(400, "Validation failed", "VALIDATION_ERROR", [
22
+ * { field: "email", message: "Invalid email format" }
23
+ * ]);
24
+ * ```
25
+ */
26
+ export declare class ApiError extends Error {
27
+ /**
28
+ * HTTP status code (e.g., 400, 401, 404, 500)
29
+ */
30
+ readonly statusCode: number;
31
+ /**
32
+ * Machine-readable error code for client handling
33
+ */
34
+ readonly code: ApiErrorCode;
35
+ /**
36
+ * Whether this error is operational (expected) vs programming error
37
+ * Operational errors are safe to expose to clients
38
+ */
39
+ readonly isOperational: boolean;
40
+ /**
41
+ * Additional error details (e.g., validation errors)
42
+ */
43
+ readonly details?: ValidationErrorDetail[];
44
+ /**
45
+ * Timestamp when the error occurred
46
+ */
47
+ readonly timestamp: Date;
48
+ constructor(statusCode: number, message: string, code?: ApiErrorCode, details?: ValidationErrorDetail[], isOperational?: boolean);
49
+ /**
50
+ * Convert error to JSON for API responses
51
+ */
52
+ toJSON(): {
53
+ success: boolean;
54
+ error: {
55
+ code: ApiErrorCode;
56
+ message: string;
57
+ details: ValidationErrorDetail[] | undefined;
58
+ timestamp: string;
59
+ };
60
+ };
61
+ static badRequest(message: string, details?: ValidationErrorDetail[]): ApiError;
62
+ static unauthorized(message?: string): ApiError;
63
+ static forbidden(message?: string): ApiError;
64
+ static notFound(resource?: string): ApiError;
65
+ static conflict(message: string): ApiError;
66
+ static validationError(details: ValidationErrorDetail[]): ApiError;
67
+ static rateLimitExceeded(message?: string): ApiError;
68
+ static internalError(message?: string): ApiError;
69
+ static serviceUnavailable(message?: string): ApiError;
70
+ static timeout(message?: string): ApiError;
71
+ static paymentRequired(message?: string): ApiError;
72
+ static unprocessableEntity(message: string, details?: ValidationErrorDetail[]): ApiError;
73
+ }
74
+ //# sourceMappingURL=ApiError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiError.d.ts","sourceRoot":"","sources":["../../src/helpers/ApiError.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,cAAc,GACd,WAAW,GACX,WAAW,GACX,UAAU,GACV,kBAAkB,GAClB,qBAAqB,GACrB,gBAAgB,GAChB,qBAAqB,GACrB,SAAS,GACT,kBAAkB,GAClB,sBAAsB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC;;OAEG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;OAEG;IACH,SAAgB,IAAI,EAAE,YAAY,CAAC;IAEnC;;;OAGG;IACH,SAAgB,aAAa,EAAE,OAAO,CAAC;IAEvC;;OAEG;IACH,SAAgB,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAElD;;OAEG;IACH,SAAgB,SAAS,EAAE,IAAI,CAAC;gBAG9B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,YAA+B,EACrC,OAAO,CAAC,EAAE,qBAAqB,EAAE,EACjC,aAAa,GAAE,OAAc;IAgB/B;;OAEG;IACH,MAAM;;;;;;;;;IAgBN,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,EAAE,GAAG,QAAQ;IAI/E,MAAM,CAAC,YAAY,CAAC,OAAO,GAAE,MAAuB,GAAG,QAAQ;IAI/D,MAAM,CAAC,SAAS,CAAC,OAAO,GAAE,MAAoB,GAAG,QAAQ;IAIzD,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAE,MAAmB,GAAG,QAAQ;IAIxD,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;IAI1C,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,QAAQ;IAIlE,MAAM,CAAC,iBAAiB,CAAC,OAAO,GAAE,MAA8B,GAAG,QAAQ;IAI3E,MAAM,CAAC,aAAa,CAAC,OAAO,GAAE,MAAgC,GAAG,QAAQ;IAIzE,MAAM,CAAC,kBAAkB,CAAC,OAAO,GAAE,MAA0C,GAAG,QAAQ;IAIxF,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,MAA0B,GAAG,QAAQ;IAI7D,MAAM,CAAC,eAAe,CAAC,OAAO,GAAE,MAA2B,GAAG,QAAQ;IAItE,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,EAAE,GAAG,QAAQ;CAGzF"}
@@ -0,0 +1,105 @@
1
+ // ============================================
2
+ // ApiError - Custom error class for API errors
3
+ // ============================================
4
+ /**
5
+ * Custom error class for API errors with status codes and error codes.
6
+ * Extends the native Error class with additional properties for HTTP responses.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * throw new ApiError(404, "User not found", "NOT_FOUND");
11
+ *
12
+ * throw new ApiError(400, "Validation failed", "VALIDATION_ERROR", [
13
+ * { field: "email", message: "Invalid email format" }
14
+ * ]);
15
+ * ```
16
+ */
17
+ export class ApiError extends Error {
18
+ /**
19
+ * HTTP status code (e.g., 400, 401, 404, 500)
20
+ */
21
+ statusCode;
22
+ /**
23
+ * Machine-readable error code for client handling
24
+ */
25
+ code;
26
+ /**
27
+ * Whether this error is operational (expected) vs programming error
28
+ * Operational errors are safe to expose to clients
29
+ */
30
+ isOperational;
31
+ /**
32
+ * Additional error details (e.g., validation errors)
33
+ */
34
+ details;
35
+ /**
36
+ * Timestamp when the error occurred
37
+ */
38
+ timestamp;
39
+ constructor(statusCode, message, code = 'INTERNAL_ERROR', details, isOperational = true) {
40
+ super(message);
41
+ this.statusCode = statusCode;
42
+ this.code = code;
43
+ this.isOperational = isOperational;
44
+ this.details = details;
45
+ this.timestamp = new Date();
46
+ // Maintains proper stack trace for where error was thrown
47
+ Error.captureStackTrace(this, this.constructor);
48
+ // Set the prototype explicitly for instanceof checks
49
+ Object.setPrototypeOf(this, ApiError.prototype);
50
+ }
51
+ /**
52
+ * Convert error to JSON for API responses
53
+ */
54
+ toJSON() {
55
+ return {
56
+ success: false,
57
+ error: {
58
+ code: this.code,
59
+ message: this.message,
60
+ details: this.details,
61
+ timestamp: this.timestamp.toISOString(),
62
+ },
63
+ };
64
+ }
65
+ // ============================================
66
+ // Static factory methods for common errors
67
+ // ============================================
68
+ static badRequest(message, details) {
69
+ return new ApiError(400, message, 'BAD_REQUEST', details);
70
+ }
71
+ static unauthorized(message = 'Unauthorized') {
72
+ return new ApiError(401, message, 'UNAUTHORIZED');
73
+ }
74
+ static forbidden(message = 'Forbidden') {
75
+ return new ApiError(403, message, 'FORBIDDEN');
76
+ }
77
+ static notFound(resource = 'Resource') {
78
+ return new ApiError(404, `${resource} not found`, 'NOT_FOUND');
79
+ }
80
+ static conflict(message) {
81
+ return new ApiError(409, message, 'CONFLICT');
82
+ }
83
+ static validationError(details) {
84
+ return new ApiError(400, 'Validation failed', 'VALIDATION_ERROR', details);
85
+ }
86
+ static rateLimitExceeded(message = 'Rate limit exceeded') {
87
+ return new ApiError(429, message, 'RATE_LIMIT_EXCEEDED');
88
+ }
89
+ static internalError(message = 'Internal server error') {
90
+ return new ApiError(500, message, 'INTERNAL_ERROR', undefined, false);
91
+ }
92
+ static serviceUnavailable(message = 'Service temporarily unavailable') {
93
+ return new ApiError(503, message, 'SERVICE_UNAVAILABLE');
94
+ }
95
+ static timeout(message = 'Request timeout') {
96
+ return new ApiError(504, message, 'TIMEOUT');
97
+ }
98
+ static paymentRequired(message = 'Payment required') {
99
+ return new ApiError(402, message, 'PAYMENT_REQUIRED');
100
+ }
101
+ static unprocessableEntity(message, details) {
102
+ return new ApiError(422, message, 'UNPROCESSABLE_ENTITY', details);
103
+ }
104
+ }
105
+ //# sourceMappingURL=ApiError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiError.js","sourceRoot":"","sources":["../../src/helpers/ApiError.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,+CAA+C;AAC/C,+CAA+C;AA4B/C;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC;;OAEG;IACa,UAAU,CAAS;IAEnC;;OAEG;IACa,IAAI,CAAe;IAEnC;;;OAGG;IACa,aAAa,CAAU;IAEvC;;OAEG;IACa,OAAO,CAA2B;IAElD;;OAEG;IACa,SAAS,CAAO;IAEhC,YACE,UAAkB,EAClB,OAAe,EACf,OAAqB,gBAAgB,EACrC,OAAiC,EACjC,gBAAyB,IAAI;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAE5B,0DAA0D;QAC1D,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAEhD,qDAAqD;QAC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CAAC,UAAkB,qBAAqB;QAC9D,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,UAAkB,uBAAuB;QAC5D,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,UAAkB,iCAAiC;QAC3E,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,UAAkB,iBAAiB;QAChD,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,UAAkB,kBAAkB;QACzD,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,OAAe,EAAE,OAAiC;QAC3E,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ import type { NextFunction, Request, RequestHandler, Response } from 'express';
2
+ /**
3
+ * Async handler function type
4
+ */
5
+ type AsyncRequestHandler = (req: Request, res: Response, next: NextFunction) => Promise<unknown>;
6
+ /**
7
+ * Wraps an async Express route handler to automatically catch errors
8
+ * and pass them to the next() error handler.
9
+ *
10
+ * This eliminates the need for try-catch blocks in every route handler.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * router.get('/users/:id', asyncHandler(async (req, res) => {
15
+ * const user = await User.findById(req.params.id);
16
+ * if (!user) throw ApiError.notFound('User');
17
+ * res.json(user);
18
+ * }));
19
+ * ```
20
+ *
21
+ * @param fn - Async function to wrap
22
+ * @returns Express RequestHandler that catches errors
23
+ */
24
+ export declare function asyncHandler(fn: AsyncRequestHandler): RequestHandler;
25
+ /**
26
+ * Type-safe async handler with typed request body/params/query
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * interface CreateUserBody { name: string; email: string; }
31
+ *
32
+ * router.post('/users', typedAsyncHandler<{}, CreateUserBody>(async (req, res) => {
33
+ * const { name, email } = req.body;
34
+ * // TypeScript knows body has name and email
35
+ * const user = await User.create({ name, email });
36
+ * res.json(user);
37
+ * }));
38
+ * ```
39
+ */
40
+ export declare function typedAsyncHandler<TParams = Record<string, string>, TBody = unknown, TQuery = Record<string, string>>(fn: (req: Request<TParams, unknown, TBody, TQuery>, res: Response, next: NextFunction) => Promise<unknown>): RequestHandler<TParams, unknown, TBody, TQuery>;
41
+ export {};
42
+ //# sourceMappingURL=asyncHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncHandler.d.ts","sourceRoot":"","sources":["../../src/helpers/asyncHandler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/E;;GAEG;AACH,KAAK,mBAAmB,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEjG;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,mBAAmB,GAAG,cAAc,CAIpE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClH,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,GACzG,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAIjD"}
@@ -0,0 +1,47 @@
1
+ // ============================================
2
+ // asyncHandler - Express async wrapper
3
+ // ============================================
4
+ /**
5
+ * Wraps an async Express route handler to automatically catch errors
6
+ * and pass them to the next() error handler.
7
+ *
8
+ * This eliminates the need for try-catch blocks in every route handler.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * router.get('/users/:id', asyncHandler(async (req, res) => {
13
+ * const user = await User.findById(req.params.id);
14
+ * if (!user) throw ApiError.notFound('User');
15
+ * res.json(user);
16
+ * }));
17
+ * ```
18
+ *
19
+ * @param fn - Async function to wrap
20
+ * @returns Express RequestHandler that catches errors
21
+ */
22
+ export function asyncHandler(fn) {
23
+ return (req, res, next) => {
24
+ Promise.resolve(fn(req, res, next)).catch(next);
25
+ };
26
+ }
27
+ /**
28
+ * Type-safe async handler with typed request body/params/query
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * interface CreateUserBody { name: string; email: string; }
33
+ *
34
+ * router.post('/users', typedAsyncHandler<{}, CreateUserBody>(async (req, res) => {
35
+ * const { name, email } = req.body;
36
+ * // TypeScript knows body has name and email
37
+ * const user = await User.create({ name, email });
38
+ * res.json(user);
39
+ * }));
40
+ * ```
41
+ */
42
+ export function typedAsyncHandler(fn) {
43
+ return (req, res, next) => {
44
+ Promise.resolve(fn(req, res, next)).catch(next);
45
+ };
46
+ }
47
+ //# sourceMappingURL=asyncHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncHandler.js","sourceRoot":"","sources":["../../src/helpers/asyncHandler.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,uCAAuC;AACvC,+CAA+C;AAS/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAAC,EAAuB;IAClD,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;QAC/D,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAA0G;IAE1G,OAAO,CAAC,GAA6C,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;QAChG,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Generate a unique ID suitable for database primary keys.
3
+ * Uses nanoid with 21 characters (default) for high collision resistance.
4
+ *
5
+ * Collision probability: 1 in 10^18 after generating 1 billion IDs
6
+ *
7
+ * @param size - Length of the ID (default: 21)
8
+ * @returns Unique URL-safe ID
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const userId = generateId(); // "V1StGXR8_Z5jdHi6B-myT"
13
+ * const shorterId = generateId(16); // "V1StGXR8_Z5jdHi6"
14
+ * ```
15
+ */
16
+ export declare function generateId(size?: number): string;
17
+ /**
18
+ * Generate a shorter, more readable ID.
19
+ * Uses a reduced alphabet (no ambiguous characters) for better readability.
20
+ *
21
+ * Best for: display IDs, reference numbers, shareable links
22
+ *
23
+ * @param size - Length of the ID (default: 12)
24
+ * @returns Short readable ID
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const refId = generateShortId(); // "Xk9Qm2ZpNrTv"
29
+ * const tinyId = generateShortId(8); // "Xk9Qm2Zp"
30
+ * ```
31
+ */
32
+ export declare function generateShortId(size?: number): string;
33
+ /**
34
+ * Generate a numeric code (OTP, verification codes).
35
+ *
36
+ * @param length - Length of the code (default: 6)
37
+ * @returns Numeric string
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const otp = generateNumericCode(); // "847291"
42
+ * const pin = generateNumericCode(4); // "8472"
43
+ * ```
44
+ */
45
+ export declare function generateNumericCode(length?: number): string;
46
+ /**
47
+ * Generate an alphanumeric code (promo codes, invite codes).
48
+ * Uses uppercase letters and numbers, no ambiguous characters.
49
+ *
50
+ * @param length - Length of the code (default: 8)
51
+ * @returns Alphanumeric string
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const promoCode = generateAlphanumericCode(); // "XKQM2ZPN"
56
+ * const inviteCode = generateAlphanumericCode(6); // "XKQM2Z"
57
+ * ```
58
+ */
59
+ export declare function generateAlphanumericCode(length?: number): string;
60
+ /**
61
+ * Generate a prefixed ID for better identification.
62
+ *
63
+ * @param prefix - Prefix to add (e.g., "usr", "prf", "mtc")
64
+ * @param size - Length of the random part (default: 16)
65
+ * @returns Prefixed ID
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const userId = generatePrefixedId("usr"); // "usr_V1StGXR8_Z5jdHi6"
70
+ * const profileId = generatePrefixedId("prf", 12); // "prf_V1StGXR8_Z5j"
71
+ * ```
72
+ */
73
+ export declare function generatePrefixedId(prefix: string, size?: number): string;
74
+ /**
75
+ * ID prefixes for different entity types
76
+ */
77
+ export declare const ID_PREFIXES: {
78
+ readonly ACCOUNT: "acc";
79
+ readonly PROFILE: "prf";
80
+ readonly MATCH: "mtc";
81
+ readonly INTEREST: "int";
82
+ readonly CHAT: "cht";
83
+ readonly MESSAGE: "msg";
84
+ readonly COMPANY: "cmp";
85
+ readonly SUBSCRIPTION: "sub";
86
+ readonly PAYMENT: "pay";
87
+ readonly VERIFICATION: "vrf";
88
+ readonly FLAG: "flg";
89
+ readonly ADMIN: "adm";
90
+ readonly LISTING: "lst";
91
+ readonly PROPOSAL: "prp";
92
+ readonly CONTRACT: "ctr";
93
+ readonly MILESTONE: "mls";
94
+ readonly DISPUTE: "dsp";
95
+ readonly NOTIFICATION: "ntf";
96
+ };
97
+ export type IdPrefix = (typeof ID_PREFIXES)[keyof typeof ID_PREFIXES];
98
+ //# sourceMappingURL=id-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-generator.d.ts","sourceRoot":"","sources":["../../src/helpers/id-generator.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAE,MAAW,GAAG,MAAM,CAEpD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,IAAI,GAAE,MAAW,GAAG,MAAM,CAEzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,MAAU,GAAG,MAAM,CAE9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,MAAU,GAAG,MAAM,CAEnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAW,GAAG,MAAM,CAE5E;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;CAmBd,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC"}