sidekick-server-2 0.1.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 (218) hide show
  1. package/README.md +223 -0
  2. package/dist/ai/index.d.ts +2 -0
  3. package/dist/ai/index.d.ts.map +1 -0
  4. package/dist/ai/index.js +2 -0
  5. package/dist/ai/index.js.map +1 -0
  6. package/dist/ai/perplexity-ai.d.ts +3 -0
  7. package/dist/ai/perplexity-ai.d.ts.map +1 -0
  8. package/dist/ai/perplexity-ai.js +28 -0
  9. package/dist/ai/perplexity-ai.js.map +1 -0
  10. package/dist/app-config.d.ts +13 -0
  11. package/dist/app-config.d.ts.map +1 -0
  12. package/dist/app-config.js +33 -0
  13. package/dist/app-config.js.map +1 -0
  14. package/dist/cors-config.d.ts +9 -0
  15. package/dist/cors-config.d.ts.map +1 -0
  16. package/dist/cors-config.js +24 -0
  17. package/dist/cors-config.js.map +1 -0
  18. package/dist/db-connection.d.ts +13 -0
  19. package/dist/db-connection.d.ts.map +1 -0
  20. package/dist/db-connection.js +22 -0
  21. package/dist/db-connection.js.map +1 -0
  22. package/dist/error-handler.d.ts +3 -0
  23. package/dist/error-handler.d.ts.map +1 -0
  24. package/dist/error-handler.js +15 -0
  25. package/dist/error-handler.js.map +1 -0
  26. package/dist/index.d.ts +19 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +87 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/local-cache.d.ts +14 -0
  31. package/dist/local-cache.d.ts.map +1 -0
  32. package/dist/local-cache.js +44 -0
  33. package/dist/local-cache.js.map +1 -0
  34. package/dist/r2-buckets/get-signed-url.d.ts +2 -0
  35. package/dist/r2-buckets/get-signed-url.d.ts.map +1 -0
  36. package/dist/r2-buckets/get-signed-url.js +22 -0
  37. package/dist/r2-buckets/get-signed-url.js.map +1 -0
  38. package/dist/r2-buckets/index.d.ts +3 -0
  39. package/dist/r2-buckets/index.d.ts.map +1 -0
  40. package/dist/r2-buckets/index.js +3 -0
  41. package/dist/r2-buckets/index.js.map +1 -0
  42. package/dist/r2-buckets/r2-client.d.ts +3 -0
  43. package/dist/r2-buckets/r2-client.d.ts.map +1 -0
  44. package/dist/r2-buckets/r2-client.js +18 -0
  45. package/dist/r2-buckets/r2-client.js.map +1 -0
  46. package/dist/r2-buckets/upload-r2.d.ts +11 -0
  47. package/dist/r2-buckets/upload-r2.d.ts.map +1 -0
  48. package/dist/r2-buckets/upload-r2.js +49 -0
  49. package/dist/r2-buckets/upload-r2.js.map +1 -0
  50. package/dist/routes/authentication/check-session.d.ts +4 -0
  51. package/dist/routes/authentication/check-session.d.ts.map +1 -0
  52. package/dist/routes/authentication/check-session.js +79 -0
  53. package/dist/routes/authentication/check-session.js.map +1 -0
  54. package/dist/routes/authentication/login-router.d.ts +3 -0
  55. package/dist/routes/authentication/login-router.d.ts.map +1 -0
  56. package/dist/routes/authentication/login-router.js +83 -0
  57. package/dist/routes/authentication/login-router.js.map +1 -0
  58. package/dist/routes/authentication/reset-password.d.ts +3 -0
  59. package/dist/routes/authentication/reset-password.d.ts.map +1 -0
  60. package/dist/routes/authentication/reset-password.js +92 -0
  61. package/dist/routes/authentication/reset-password.js.map +1 -0
  62. package/dist/routes/authentication/send-otp-router.d.ts +3 -0
  63. package/dist/routes/authentication/send-otp-router.d.ts.map +1 -0
  64. package/dist/routes/authentication/send-otp-router.js +89 -0
  65. package/dist/routes/authentication/send-otp-router.js.map +1 -0
  66. package/dist/routes/authentication/user-profile.d.ts +3 -0
  67. package/dist/routes/authentication/user-profile.d.ts.map +1 -0
  68. package/dist/routes/authentication/user-profile.js +44 -0
  69. package/dist/routes/authentication/user-profile.js.map +1 -0
  70. package/dist/routes/authentication/user-registration-router.d.ts +3 -0
  71. package/dist/routes/authentication/user-registration-router.d.ts.map +1 -0
  72. package/dist/routes/authentication/user-registration-router.js +120 -0
  73. package/dist/routes/authentication/user-registration-router.js.map +1 -0
  74. package/dist/routes/authentication/validator.d.ts +14 -0
  75. package/dist/routes/authentication/validator.d.ts.map +1 -0
  76. package/dist/routes/authentication/validator.js +69 -0
  77. package/dist/routes/authentication/validator.js.map +1 -0
  78. package/dist/routes/countries/countries-router.d.ts +3 -0
  79. package/dist/routes/countries/countries-router.d.ts.map +1 -0
  80. package/dist/routes/countries/countries-router.js +23 -0
  81. package/dist/routes/countries/countries-router.js.map +1 -0
  82. package/dist/routes/feature-flags/feature-flags.d.ts +5 -0
  83. package/dist/routes/feature-flags/feature-flags.d.ts.map +1 -0
  84. package/dist/routes/feature-flags/feature-flags.js +28 -0
  85. package/dist/routes/feature-flags/feature-flags.js.map +1 -0
  86. package/dist/routes/index.d.ts +9 -0
  87. package/dist/routes/index.d.ts.map +1 -0
  88. package/dist/routes/index.js +92 -0
  89. package/dist/routes/index.js.map +1 -0
  90. package/dist/routes/link-metadata.d.ts +3 -0
  91. package/dist/routes/link-metadata.d.ts.map +1 -0
  92. package/dist/routes/link-metadata.js +34 -0
  93. package/dist/routes/link-metadata.js.map +1 -0
  94. package/dist/routes/orgs/index.d.ts +2 -0
  95. package/dist/routes/orgs/index.d.ts.map +1 -0
  96. package/dist/routes/orgs/index.js +2 -0
  97. package/dist/routes/orgs/index.js.map +1 -0
  98. package/dist/routes/orgs/invitation.d.ts +3 -0
  99. package/dist/routes/orgs/invitation.d.ts.map +1 -0
  100. package/dist/routes/orgs/invitation.js +103 -0
  101. package/dist/routes/orgs/invitation.js.map +1 -0
  102. package/dist/routes/orgs/org-delete.d.ts +3 -0
  103. package/dist/routes/orgs/org-delete.d.ts.map +1 -0
  104. package/dist/routes/orgs/org-delete.js +53 -0
  105. package/dist/routes/orgs/org-delete.js.map +1 -0
  106. package/dist/routes/orgs/org-get.d.ts +3 -0
  107. package/dist/routes/orgs/org-get.d.ts.map +1 -0
  108. package/dist/routes/orgs/org-get.js +45 -0
  109. package/dist/routes/orgs/org-get.js.map +1 -0
  110. package/dist/routes/orgs/org-members.d.ts +12 -0
  111. package/dist/routes/orgs/org-members.d.ts.map +1 -0
  112. package/dist/routes/orgs/org-members.js +560 -0
  113. package/dist/routes/orgs/org-members.js.map +1 -0
  114. package/dist/routes/orgs/org-post.d.ts +3 -0
  115. package/dist/routes/orgs/org-post.d.ts.map +1 -0
  116. package/dist/routes/orgs/org-post.js +89 -0
  117. package/dist/routes/orgs/org-post.js.map +1 -0
  118. package/dist/routes/orgs/org-put.d.ts +3 -0
  119. package/dist/routes/orgs/org-put.d.ts.map +1 -0
  120. package/dist/routes/orgs/org-put.js +87 -0
  121. package/dist/routes/orgs/org-put.js.map +1 -0
  122. package/dist/routes/orgs/org-registration-router.d.ts +3 -0
  123. package/dist/routes/orgs/org-registration-router.d.ts.map +1 -0
  124. package/dist/routes/orgs/org-registration-router.js +12 -0
  125. package/dist/routes/orgs/org-registration-router.js.map +1 -0
  126. package/dist/routes/orgs/org-utils.d.ts +14 -0
  127. package/dist/routes/orgs/org-utils.d.ts.map +1 -0
  128. package/dist/routes/orgs/org-utils.js +234 -0
  129. package/dist/routes/orgs/org-utils.js.map +1 -0
  130. package/dist/routes/orgs/premium-org-utils.d.ts +3 -0
  131. package/dist/routes/orgs/premium-org-utils.d.ts.map +1 -0
  132. package/dist/routes/orgs/premium-org-utils.js +61 -0
  133. package/dist/routes/orgs/premium-org-utils.js.map +1 -0
  134. package/dist/routes/paid-plans/billingsdk-config.d.ts +36 -0
  135. package/dist/routes/paid-plans/billingsdk-config.d.ts.map +1 -0
  136. package/dist/routes/paid-plans/billingsdk-config.js +2 -0
  137. package/dist/routes/paid-plans/billingsdk-config.js.map +1 -0
  138. package/dist/routes/paid-plans/get-subscription-config.d.ts +3 -0
  139. package/dist/routes/paid-plans/get-subscription-config.d.ts.map +1 -0
  140. package/dist/routes/paid-plans/get-subscription-config.js +25 -0
  141. package/dist/routes/paid-plans/get-subscription-config.js.map +1 -0
  142. package/dist/routes/paid-plans/payment-gateway.d.ts +3 -0
  143. package/dist/routes/paid-plans/payment-gateway.d.ts.map +1 -0
  144. package/dist/routes/paid-plans/payment-gateway.js +324 -0
  145. package/dist/routes/paid-plans/payment-gateway.js.map +1 -0
  146. package/dist/routes/paid-plans/purchased-plans.d.ts +8 -0
  147. package/dist/routes/paid-plans/purchased-plans.d.ts.map +1 -0
  148. package/dist/routes/paid-plans/purchased-plans.js +191 -0
  149. package/dist/routes/paid-plans/purchased-plans.js.map +1 -0
  150. package/dist/routes/paid-plans/subscription-utils.d.ts +25 -0
  151. package/dist/routes/paid-plans/subscription-utils.d.ts.map +1 -0
  152. package/dist/routes/paid-plans/subscription-utils.js +156 -0
  153. package/dist/routes/paid-plans/subscription-utils.js.map +1 -0
  154. package/dist/s3-buckets/get-signed-url.d.ts +2 -0
  155. package/dist/s3-buckets/get-signed-url.d.ts.map +1 -0
  156. package/dist/s3-buckets/get-signed-url.js +22 -0
  157. package/dist/s3-buckets/get-signed-url.js.map +1 -0
  158. package/dist/s3-buckets/index.d.ts +3 -0
  159. package/dist/s3-buckets/index.d.ts.map +1 -0
  160. package/dist/s3-buckets/index.js +3 -0
  161. package/dist/s3-buckets/index.js.map +1 -0
  162. package/dist/s3-buckets/s3-client.d.ts +3 -0
  163. package/dist/s3-buckets/s3-client.d.ts.map +1 -0
  164. package/dist/s3-buckets/s3-client.js +17 -0
  165. package/dist/s3-buckets/s3-client.js.map +1 -0
  166. package/dist/s3-buckets/upload-s3.d.ts +11 -0
  167. package/dist/s3-buckets/upload-s3.d.ts.map +1 -0
  168. package/dist/s3-buckets/upload-s3.js +51 -0
  169. package/dist/s3-buckets/upload-s3.js.map +1 -0
  170. package/dist/secret.d.ts +4 -0
  171. package/dist/secret.d.ts.map +1 -0
  172. package/dist/secret.js +11 -0
  173. package/dist/secret.js.map +1 -0
  174. package/dist/socket-config.d.ts +4 -0
  175. package/dist/socket-config.d.ts.map +1 -0
  176. package/dist/socket-config.js +23 -0
  177. package/dist/socket-config.js.map +1 -0
  178. package/dist/types.d.ts +141 -0
  179. package/dist/types.d.ts.map +1 -0
  180. package/dist/types.js +2 -0
  181. package/dist/types.js.map +1 -0
  182. package/dist/utils/common-utils.d.ts +61 -0
  183. package/dist/utils/common-utils.d.ts.map +1 -0
  184. package/dist/utils/common-utils.js +99 -0
  185. package/dist/utils/common-utils.js.map +1 -0
  186. package/dist/utils/email-helper.d.ts +6 -0
  187. package/dist/utils/email-helper.d.ts.map +1 -0
  188. package/dist/utils/email-helper.js +33 -0
  189. package/dist/utils/email-helper.js.map +1 -0
  190. package/dist/utils/enums.d.ts +17 -0
  191. package/dist/utils/enums.d.ts.map +1 -0
  192. package/dist/utils/enums.js +27 -0
  193. package/dist/utils/enums.js.map +1 -0
  194. package/dist/utils/error-logger.d.ts +4 -0
  195. package/dist/utils/error-logger.d.ts.map +1 -0
  196. package/dist/utils/error-logger.js +30 -0
  197. package/dist/utils/error-logger.js.map +1 -0
  198. package/dist/utils/index.d.ts +9 -0
  199. package/dist/utils/index.d.ts.map +1 -0
  200. package/dist/utils/index.js +9 -0
  201. package/dist/utils/index.js.map +1 -0
  202. package/dist/utils/otp-helper.d.ts +5 -0
  203. package/dist/utils/otp-helper.d.ts.map +1 -0
  204. package/dist/utils/otp-helper.js +89 -0
  205. package/dist/utils/otp-helper.js.map +1 -0
  206. package/dist/utils/response-utils.d.ts +8 -0
  207. package/dist/utils/response-utils.d.ts.map +1 -0
  208. package/dist/utils/response-utils.js +37 -0
  209. package/dist/utils/response-utils.js.map +1 -0
  210. package/dist/utils/sql-helper.d.ts +27 -0
  211. package/dist/utils/sql-helper.d.ts.map +1 -0
  212. package/dist/utils/sql-helper.js +97 -0
  213. package/dist/utils/sql-helper.js.map +1 -0
  214. package/dist/utils/type.d.ts +81 -0
  215. package/dist/utils/type.d.ts.map +1 -0
  216. package/dist/utils/type.js +2 -0
  217. package/dist/utils/type.js.map +1 -0
  218. package/package.json +70 -0
@@ -0,0 +1,156 @@
1
+ export const getCurrencySymbol = (currency) => {
2
+ if (currency === 'INR')
3
+ return '₹';
4
+ if (currency === 'USD')
5
+ return '$';
6
+ if (currency === 'EUR')
7
+ return '€';
8
+ if (currency === 'GBP')
9
+ return '£';
10
+ if (currency === 'AUD')
11
+ return '$';
12
+ if (currency === 'CAD')
13
+ return '$';
14
+ if (currency === 'CHF')
15
+ return '₣';
16
+ if (currency === 'CNY')
17
+ return '¥';
18
+ if (currency === 'DKK')
19
+ return 'kr';
20
+ if (currency === 'HKD')
21
+ return '$';
22
+ if (currency === 'NZD')
23
+ return '$';
24
+ if (currency === 'SEK')
25
+ return 'kr';
26
+ if (currency === 'SGD')
27
+ return '$';
28
+ if (currency === 'ZAR')
29
+ return 'R';
30
+ return '';
31
+ };
32
+ export const getDisplayPaymentMethod = (paymentMethod) => {
33
+ if (paymentMethod === 'netbanking')
34
+ return 'Net Banking';
35
+ if (paymentMethod === 'wallet')
36
+ return 'Wallet';
37
+ if (paymentMethod === 'upi')
38
+ return 'UPI';
39
+ if (paymentMethod === 'card')
40
+ return 'Card';
41
+ return paymentMethod;
42
+ };
43
+ export const isFreePlan = (plan) => !plan || plan.plan_id === 'starter';
44
+ // -----------------------------------------------
45
+ export let CURRENCY = 'INR';
46
+ export let CURRENCY_SYMBOL = getCurrencySymbol(CURRENCY);
47
+ export const freePurchasedPlan = {
48
+ plan_id: 'starter',
49
+ purchased_at: '',
50
+ status: 'free',
51
+ amount: 'Free',
52
+ z_order_id: '123',
53
+ };
54
+ export const plans = [
55
+ {
56
+ id: 'starter',
57
+ title: 'Starter',
58
+ description: 'Free plan',
59
+ monthlyPrice: '0',
60
+ yearlyPrice: '0',
61
+ buttonText: 'Get Started',
62
+ minUserRequired: 1,
63
+ maxUserRequired: 5,
64
+ features: [
65
+ {
66
+ name: `Free Feature 1`,
67
+ icon: 'CheckCircle',
68
+ },
69
+ {
70
+ name: `Free Feature 2`,
71
+ icon: 'CheckCircle',
72
+ },
73
+ ],
74
+ planDisplayCost: {
75
+ monthly: `Continue with ${CURRENCY_SYMBOL}0/month`,
76
+ yearly: `Continue with ${CURRENCY_SYMBOL}0/year`,
77
+ },
78
+ currency: CURRENCY_SYMBOL,
79
+ type: 'monthly',
80
+ },
81
+ {
82
+ id: 'premium-team',
83
+ title: 'Premium Team',
84
+ description: `Get started at just ${CURRENCY_SYMBOL}25/month for 5 users`,
85
+ planDisplayCost: {
86
+ monthly: `Continue at ${CURRENCY_SYMBOL}25/month - min 5 users`,
87
+ yearly: `Continue at ${CURRENCY_SYMBOL}250/year - min 5 users`,
88
+ },
89
+ minUserRequired: 5,
90
+ maxUserRequired: Number.POSITIVE_INFINITY,
91
+ monthlyPrice: '90',
92
+ yearlyPrice: '900',
93
+ highlight: true,
94
+ buttonText: 'Get Started',
95
+ badge: 'Top Deal',
96
+ features: [
97
+ {
98
+ name: `Premium Feature 1`,
99
+ icon: 'CheckCircle',
100
+ },
101
+ {
102
+ name: `Premium Feature 2`,
103
+ icon: 'CheckCircle',
104
+ },
105
+ ],
106
+ currency: CURRENCY_SYMBOL,
107
+ type: 'monthly',
108
+ },
109
+ {
110
+ id: 'premium-individual',
111
+ title: 'Premium Individual',
112
+ description: 'Perfect for solo professionals',
113
+ planDisplayCost: {
114
+ monthly: `Continue with ${CURRENCY_SYMBOL}8/month`,
115
+ yearly: `Continue with ${CURRENCY_SYMBOL}80/year`,
116
+ },
117
+ minUserRequired: 1,
118
+ maxUserRequired: 1,
119
+ monthlyPrice: '70',
120
+ yearlyPrice: '700',
121
+ buttonText: 'Get Started',
122
+ features: [
123
+ {
124
+ name: `Premium Feature 1`,
125
+ icon: 'CheckCircle',
126
+ },
127
+ {
128
+ name: `Premium Feature 2`,
129
+ icon: 'CheckCircle',
130
+ },
131
+ ],
132
+ currency: CURRENCY_SYMBOL,
133
+ type: 'monthly',
134
+ },
135
+ ];
136
+ export let faqs = [
137
+ {
138
+ question: 'Sample Question?',
139
+ answer: `This is an answer to the sample question`,
140
+ },
141
+ ];
142
+ const setCurrency = (currency, currencySymbol) => {
143
+ CURRENCY = currency;
144
+ CURRENCY_SYMBOL = currencySymbol;
145
+ };
146
+ const setFreePlan = (freePlan) => {
147
+ Object.assign(freePurchasedPlan, freePlan);
148
+ };
149
+ const setPremiumPlans = (premiumPlans) => {
150
+ Object.assign(plans, premiumPlans);
151
+ };
152
+ const setFaqs = (faqItems) => {
153
+ faqs = faqItems;
154
+ };
155
+ export { setCurrency, setFreePlan, setPremiumPlans, setFaqs };
156
+ //# sourceMappingURL=subscription-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-utils.js","sourceRoot":"","sources":["../../../src/routes/paid-plans/subscription-utils.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACpD,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IACnC,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,CA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0CAA0C;KACnD;CACF,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,QAAa,EAAE,cAAsB,EAAE,EAAE;IAC5D,QAAQ,GAAG,QAAQ,CAAC;IACpB,eAAe,GAAG,cAAc,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,QAAkC,EAAE,EAAE;IACzD,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,YAAoB,EAAE,EAAE;IAC/C,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,QAAmB,EAAE,EAAE;IACtC,IAAI,GAAG,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getS3SignedFileUrl(key: string): Promise<any>;
2
+ //# sourceMappingURL=get-signed-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-signed-url.d.ts","sourceRoot":"","sources":["../../src/s3-buckets/get-signed-url.ts"],"names":[],"mappings":"AAQA,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,gBAiBnD"}
@@ -0,0 +1,22 @@
1
+ import { GetObjectCommand } from '@aws-sdk/client-s3';
2
+ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
3
+ import { getSingletonCacheInstance } from '../local-cache.js';
4
+ import { getSecretValue } from '../secret.js';
5
+ import { getS3Client } from './s3-client.js';
6
+ const urlLocalCache = await getSingletonCacheInstance('s3-signed-get-urls', 20);
7
+ export async function getS3SignedFileUrl(key) {
8
+ const cachedUrl = await urlLocalCache.get(key);
9
+ if (cachedUrl) {
10
+ return cachedUrl;
11
+ }
12
+ const command = new GetObjectCommand({
13
+ Bucket: getSecretValue('awsS3Bucket'),
14
+ Key: key,
15
+ });
16
+ const signedUrl = await getSignedUrl(getS3Client(), command, {
17
+ expiresIn: 300, // 5 minutes
18
+ });
19
+ await urlLocalCache.set(key, signedUrl, 300000); // Cache for 5 minutes
20
+ return signedUrl;
21
+ }
22
+ //# sourceMappingURL=get-signed-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-signed-url.js","sourceRoot":"","sources":["../../src/s3-buckets/get-signed-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,aAAa,GAAG,MAAM,yBAAyB,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;AAEhF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAClD,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;QACnC,MAAM,EAAE,cAAc,CAAC,aAAa,CAAE;QACtC,GAAG,EAAE,GAAG;KACT,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE;QAC3D,SAAS,EAAE,GAAG,EAAE,YAAY;KAC7B,CAAC,CAAC;IAEH,MAAM,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,sBAAsB;IACvE,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { uploadToS3, getSignedUploadUrl } from './upload-s3.js';
2
+ export { getS3SignedFileUrl } from './get-signed-url.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/s3-buckets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { uploadToS3, getSignedUploadUrl } from './upload-s3.js';
2
+ export { getS3SignedFileUrl } from './get-signed-url.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/s3-buckets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { S3Client } from '@aws-sdk/client-s3';
2
+ export declare const getS3Client: () => S3Client;
3
+ //# sourceMappingURL=s3-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-client.d.ts","sourceRoot":"","sources":["../../src/s3-buckets/s3-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK9C,eAAO,MAAM,WAAW,QAAO,QAc9B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { S3Client } from '@aws-sdk/client-s3';
2
+ import { getSecretValue } from '../secret.js';
3
+ let s3Client;
4
+ export const getS3Client = () => {
5
+ if (s3Client) {
6
+ return s3Client;
7
+ }
8
+ s3Client = new S3Client({
9
+ region: getSecretValue('awsRegion'),
10
+ credentials: {
11
+ accessKeyId: getSecretValue('awsS3AccessKey'),
12
+ secretAccessKey: getSecretValue('awsS3SecretKey'),
13
+ },
14
+ });
15
+ return s3Client;
16
+ };
17
+ //# sourceMappingURL=s3-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-client.js","sourceRoot":"","sources":["../../src/s3-buckets/s3-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,IAAI,QAAkB,CAAC;AAEvB,MAAM,CAAC,MAAM,WAAW,GAAG,GAAa,EAAE;IACxC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,QAAQ,GAAG,IAAI,QAAQ,CAAC;QACtB,MAAM,EAAE,cAAc,CAAC,WAAW,CAAC;QACnC,WAAW,EAAE;YACX,WAAW,EAAE,cAAc,CAAC,gBAAgB,CAAE;YAC9C,eAAe,EAAE,cAAc,CAAC,gBAAgB,CAAE;SACnD;KACF,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare function uploadToS3(key: string, fileBuffer: Buffer): Promise<void>;
2
+ interface ISignedUploadUrlParams {
3
+ key: string;
4
+ contentType: string;
5
+ contentLength: number;
6
+ allowedTypes?: string[];
7
+ maxSizeMb?: number;
8
+ }
9
+ export declare function getSignedUploadUrl({ key, contentType, contentLength, allowedTypes, maxSizeMb, }: ISignedUploadUrlParams): Promise<string>;
10
+ export {};
11
+ //# sourceMappingURL=upload-s3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-s3.d.ts","sourceRoot":"","sources":["../../src/s3-buckets/upload-s3.ts"],"names":[],"mappings":"AAMA,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBA2B/D;AAKD,UAAU,sBAAsB;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,kBAAkB,CAAC,EACvC,GAAG,EACH,WAAW,EACX,aAAa,EACb,YAA4B,EAC5B,SAAuB,GACxB,EAAE,sBAAsB,mBAmBxB"}
@@ -0,0 +1,51 @@
1
+ import { PutObjectCommand, S3ServiceException } from '@aws-sdk/client-s3';
2
+ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
3
+ import { getSecretValue } from '../secret.js';
4
+ import logger from '../utils/error-logger.js';
5
+ import { getS3Client } from './s3-client.js';
6
+ export async function uploadToS3(key, fileBuffer) {
7
+ const bucketName = getSecretValue('awsS3Bucket');
8
+ const command = new PutObjectCommand({
9
+ Bucket: bucketName,
10
+ Key: key,
11
+ Body: fileBuffer,
12
+ });
13
+ try {
14
+ const response = await getS3Client().send(command);
15
+ console.log(response);
16
+ }
17
+ catch (caught) {
18
+ if (caught instanceof S3ServiceException && caught.name === 'EntityTooLarge') {
19
+ logger.error(`Error from S3 while uploading object to ${bucketName}. \
20
+ The object was too large. To upload objects larger than 5GB, use the S3 console (160GB max) \
21
+ or the multipart upload API (5TB max).`);
22
+ }
23
+ else if (caught instanceof S3ServiceException) {
24
+ logger.error(`Error from S3 while uploading object to ${bucketName}. ${caught.name}: ${caught.message}`);
25
+ }
26
+ else {
27
+ logger.error(`S3: Unknown error while uploading object to ${bucketName}. ${caught}`);
28
+ }
29
+ throw caught;
30
+ }
31
+ }
32
+ const ALLOWED_TYPES = ['image/jpeg', 'image/png', 'image/webp'];
33
+ const MAX_SIZE_MB = 5;
34
+ export async function getSignedUploadUrl({ key, contentType, contentLength, allowedTypes = ALLOWED_TYPES, maxSizeMb = MAX_SIZE_MB, }) {
35
+ // Server-side validation
36
+ if (!allowedTypes.includes(contentType)) {
37
+ throw new Error('Invalid image type');
38
+ }
39
+ if (contentLength > maxSizeMb * 1024 * 1024) {
40
+ throw new Error('File too large');
41
+ }
42
+ const command = new PutObjectCommand({
43
+ Bucket: getSecretValue('awsS3Bucket'),
44
+ Key: key,
45
+ ContentType: contentType,
46
+ });
47
+ return await getSignedUrl(getS3Client(), command, {
48
+ expiresIn: 300, // 5 minutes
49
+ });
50
+ }
51
+ //# sourceMappingURL=upload-s3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-s3.js","sourceRoot":"","sources":["../../src/s3-buckets/upload-s3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,UAAkB;IAC9D,MAAM,UAAU,GAAG,cAAc,CAAC,aAAa,CAAE,CAAC;IAElD,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU;QAClB,GAAG,EAAE,GAAG;QACR,IAAI,EAAE,UAAU;KACjB,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,IAAI,MAAM,YAAY,kBAAkB,IAAI,MAAM,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC7E,MAAM,CAAC,KAAK,CACV,2CAA2C,UAAU;;gDAEb,CACzC,CAAC;QACJ,CAAC;aAAM,IAAI,MAAM,YAAY,kBAAkB,EAAE,CAAC;YAChD,MAAM,CAAC,KAAK,CAAC,2CAA2C,UAAU,MAAM,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5G,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,+CAA+C,UAAU,KAAK,MAAM,EAAE,CAAC,CAAC;QACvF,CAAC;QAED,MAAM,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AAChE,MAAM,WAAW,GAAG,CAAC,CAAC;AAUtB,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,EACvC,GAAG,EACH,WAAW,EACX,aAAa,EACb,YAAY,GAAG,aAAa,EAC5B,SAAS,GAAG,WAAW,GACA;IACvB,yBAAyB;IACzB,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,aAAa,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;QACnC,MAAM,EAAE,cAAc,CAAC,aAAa,CAAE;QACtC,GAAG,EAAE,GAAG;QACR,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC;IAEH,OAAO,MAAM,YAAY,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE;QAChD,SAAS,EAAE,GAAG,EAAE,YAAY;KAC7B,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ISecret } from './types.js';
2
+ export declare const setSecret: (secret: ISecret) => void;
3
+ export declare const getSecretValue: (key: keyof ISecret) => string;
4
+ //# sourceMappingURL=secret.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../src/secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,eAAO,MAAM,SAAS,GAAI,QAAQ,OAAO,KAAG,IAE3C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,OAAO,KAAG,MAMnD,CAAC"}
package/dist/secret.js ADDED
@@ -0,0 +1,11 @@
1
+ let secretConfig;
2
+ export const setSecret = (secret) => {
3
+ secretConfig = secret;
4
+ };
5
+ export const getSecretValue = (key) => {
6
+ if (!secretConfig) {
7
+ throw new Error('Secret configuration not set. Please set it using setSecret() before accessing.');
8
+ }
9
+ return secretConfig[key] || '';
10
+ };
11
+ //# sourceMappingURL=secret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret.js","sourceRoot":"","sources":["../src/secret.ts"],"names":[],"mappings":"AAEA,IAAI,YAAiC,CAAC;AAEtC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAe,EAAQ,EAAE;IACjD,YAAY,GAAG,MAAM,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAkB,EAAU,EAAE;IAC3D,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IAED,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Server as HTTPServer } from 'http';
2
+ declare const initSocketIO: (httpServer: HTTPServer, corsConfiguration: object) => void;
3
+ export default initSocketIO;
4
+ //# sourceMappingURL=socket-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket-config.d.ts","sourceRoot":"","sources":["../src/socket-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAC;AAI5C,QAAA,MAAM,YAAY,GAAI,YAAY,UAAU,EAAE,mBAAmB,MAAM,KAAG,IAsBzE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Server as SocketIOServer } from 'socket.io';
2
+ const initSocketIO = (httpServer, corsConfiguration) => {
3
+ // Setup Socket.IO with the same HTTP server
4
+ const io = new SocketIOServer(httpServer, {
5
+ cors: corsConfiguration,
6
+ });
7
+ // Handle socket connections
8
+ io.on('connection', (socket) => {
9
+ console.log('New socket connection:', socket.id);
10
+ socket.on('disconnect', () => {
11
+ console.log('Socket disconnected:', socket.id);
12
+ });
13
+ // You can listen for custom events here
14
+ socket.on('message', (data) => {
15
+ console.log('Received message:', data);
16
+ // Echo the message back
17
+ socket.emit('message', `Event sent from Server: ${data}`);
18
+ console.log('Event emitted');
19
+ });
20
+ });
21
+ };
22
+ export default initSocketIO;
23
+ //# sourceMappingURL=socket-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket-config.js","sourceRoot":"","sources":["../src/socket-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAU,MAAM,WAAW,CAAC;AAE7D,MAAM,YAAY,GAAG,CAAC,UAAsB,EAAE,iBAAyB,EAAQ,EAAE;IAC/E,4CAA4C;IAC5C,MAAM,EAAE,GAAG,IAAI,cAAc,CAAC,UAAU,EAAE;QACxC,IAAI,EAAE,iBAAiB;KACxB,CAAC,CAAC;IAEH,4BAA4B;IAC5B,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,MAAc,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAEjD,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,wCAAwC;QACxC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,IAAY,EAAE,EAAE;YACpC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;YACvC,wBAAwB;YACxB,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,2BAA2B,IAAI,EAAE,CAAC,CAAC;YAC1D,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,141 @@
1
+ import { Application, Router } from 'express';
2
+ import { Pool } from 'mysql2/promise';
3
+ import { APP_INFO_ACCOUNT_TYPE } from './app-config.js';
4
+ import { Plan } from './routes/paid-plans/billingsdk-config.js';
5
+ import { freePurchasedPlan } from './routes/paid-plans/subscription-utils.js';
6
+ /**
7
+ * Database connection type - users must provide a MySQL2 Pool or compatible connection
8
+ */
9
+ export type DatabaseConnection = Pool;
10
+ /**
11
+ * Application information configuration
12
+ */
13
+ export interface AppInfo {
14
+ appId: string;
15
+ appName: string;
16
+ appDescription: string;
17
+ version: string;
18
+ logo?: string;
19
+ primaryThemeColor?: string;
20
+ CLIENT_URL: string;
21
+ supportEmail: string;
22
+ account_type_txt: {
23
+ singular: string;
24
+ plural: string;
25
+ value: typeof APP_INFO_ACCOUNT_TYPE.TEAM;
26
+ };
27
+ }
28
+ /**
29
+ * CORS configuration
30
+ */
31
+ export interface CorsConfig {
32
+ allowedOrigins: string[];
33
+ }
34
+ /**
35
+ * JWT configuration
36
+ */
37
+ export interface JwtConfig {
38
+ secret: string;
39
+ expiresIn?: string;
40
+ }
41
+ /**
42
+ * Custom routes handler - allows users to register additional routes
43
+ */
44
+ export type CustomRoutesHandler = (app: Application) => void;
45
+ export type CustomPublicRoutesHandler = (router: Router) => void;
46
+ export interface purchasedPlansInf {
47
+ plan_id: string;
48
+ purchased_id: number;
49
+ purchased_at: string;
50
+ for_months: number;
51
+ for_no_users: number;
52
+ status: string;
53
+ amount: number;
54
+ transaction_id: string;
55
+ old_purchased_for_no_users: number;
56
+ z_currency: string;
57
+ z_order_id: string;
58
+ z_payment_method: string;
59
+ startAt: Date;
60
+ endAt: Date;
61
+ updatedRecords?: IUpdatedPurchasedPlan[];
62
+ }
63
+ export interface IUpdatedPurchasedPlan {
64
+ purchased_id: number;
65
+ updated_at: string;
66
+ for_no_users: string;
67
+ status: string;
68
+ amount: number;
69
+ z_order_id: string;
70
+ z_payment_method: string;
71
+ z_payment_at: string;
72
+ z_currency: string;
73
+ z_payment_id: string;
74
+ }
75
+ export interface FAQItem {
76
+ question: string;
77
+ answer: string;
78
+ }
79
+ export interface IEmailConfig {
80
+ host: string;
81
+ port: number;
82
+ secure: boolean;
83
+ auth: {
84
+ user: string;
85
+ pass: string;
86
+ };
87
+ }
88
+ export interface ISecret {
89
+ perplexityApiKey?: string;
90
+ cloudFlareApiKey?: string;
91
+ razorpayKeyId?: string;
92
+ razorpayKeySecret?: string;
93
+ awsRegion?: string;
94
+ awsS3AccessKey?: string;
95
+ awsS3SecretKey?: string;
96
+ awsS3Bucket?: string;
97
+ linkPreviewApiKey?: string;
98
+ r2AccountId?: string;
99
+ r2AccessKey?: string;
100
+ r2SecretKey?: string;
101
+ r2Bucket?: string;
102
+ }
103
+ /**
104
+ * Main SideKick configuration interface
105
+ */
106
+ export interface SideKickConfig {
107
+ /**
108
+ * Database connection pool (MySQL2)
109
+ */
110
+ database: DatabaseConnection;
111
+ /**
112
+ * Application information
113
+ */
114
+ appInfo: AppInfo;
115
+ /**
116
+ * CORS configuration
117
+ */
118
+ cors: CorsConfig;
119
+ /**
120
+ * Optional: Custom routes handler to add additional routes
121
+ */
122
+ customRoutes?: CustomRoutesHandler;
123
+ customRoutesPublic?: CustomRoutesHandler;
124
+ /**
125
+ * Optional: Port number (defaults to 3000)
126
+ */
127
+ port?: number;
128
+ accountType?: typeof APP_INFO_ACCOUNT_TYPE;
129
+ subscriptions: {
130
+ currency: string;
131
+ currencySymbol: string;
132
+ freePlan: typeof freePurchasedPlan;
133
+ premiumPlans: Plan[];
134
+ faqs: FAQItem[];
135
+ };
136
+ emailConfig?: IEmailConfig | null;
137
+ secretConfig: ISecret;
138
+ featureFlags?: Record<string, boolean>;
139
+ rolesEnum?: Record<string, number>;
140
+ }
141
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,OAAO,qBAAqB,CAAC,IAAI,CAAC;KAC1C,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,C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O,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Check weather the email is valid or not.
3
+ *
4
+ * @param email - An email id
5
+ * @returns Boolean
6
+ */
7
+ export declare const isEmailValid: (email: string) => boolean;
8
+ /**
9
+ * This method returns the object which only contains fields which needed for operation.
10
+ *
11
+ * @param request - Whole Object
12
+ * @param fields - an array of required fields
13
+ * @returns - The object contains only required field
14
+ */
15
+ export declare const getRequestFromRoute: (request: Record<string, any>, fields: Array<string>) => Record<string, any>;
16
+ /**
17
+ * Hashes a plain password using bcrypt.
18
+ *
19
+ * @param plainPassword - The raw password to hash.
20
+ * @returns A promise that resolves to the hashed password.
21
+ */
22
+ export declare const hashPassword: (plainPassword: string) => Promise<string>;
23
+ /**
24
+ * Compares a plain password to a hashed one.
25
+ *
26
+ * @param plainPassword - The raw password input.
27
+ * @param hashedPassword - The stored hash to verify against.
28
+ * @returns A promise that resolves to true if match, false otherwise.
29
+ */
30
+ export declare const verifyPassword: (plainPassword: string, hashedPassword: string) => Promise<boolean>;
31
+ /**
32
+ * Generates a JWT token for the user.
33
+ *
34
+ * @param user - The user object to encode in the token.
35
+ * @returns The generated JWT token.
36
+ */
37
+ export declare const generateToken: (user: any) => string;
38
+ /**
39
+ * Verifies the provided JWT token and returns the decoded payload.
40
+ *
41
+ * @param token - The JWT token to verify.
42
+ * @returns The decoded payload if the token is valid, otherwise throws an error.
43
+ */
44
+ export declare const verifyToken: (token: string) => any;
45
+ /**
46
+ * Generates a 4-digit numeric OTP as a string.
47
+ *
48
+ * @returns A 4-digit OTP.
49
+ */
50
+ export declare const generateOTP: () => string;
51
+ /**
52
+ * Checks if the provided object is empty (has no own enumerable properties).
53
+ *
54
+ * @param obj - The object to check.
55
+ * @returns True if the object is empty, false otherwise.
56
+ */
57
+ export declare const isObjectEmpty: (obj: Record<string, any>) => boolean;
58
+ export declare const isCustomError: (obj: Record<string, any>) => boolean;
59
+ export declare const isValidId: (id: string | number) => boolean;
60
+ export declare const convertServerDateToJS: (serverDateStr: string) => Date;
61
+ //# sourceMappingURL=common-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-utils.d.ts","sourceRoot":"","sources":["../../src/utils/common-utils.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,YAWzC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,KAAK,CAAC,MAAM,CAAC,wBAQtF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,eAAe,MAAM,KAAG,OAAO,CAAC,MAAM,CAExE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAU,eAAe,MAAM,EAAE,gBAAgB,MAAM,KAAG,OAAO,CAAC,OAAO,CAEnG,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,GAAG,KAAG,MAIzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,GAE3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,MAE9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,OAExD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,OAExD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,IAAI,MAAM,GAAG,MAAM,YAG5C,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,SAA4B,CAAC"}