@nlabs/reaktor 0.10.0 → 0.10.2

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 (448) hide show
  1. package/.env +1 -0
  2. package/.env.example +1 -0
  3. package/DATABASE_I18N_GUIDE.md +434 -0
  4. package/TEST_UTILITIES_GUIDE.md +360 -0
  5. package/coverage/actions/index.html +21 -36
  6. package/coverage/actions/notifications.ts.html +223 -0
  7. package/coverage/actions/posts.ts.html +2356 -0
  8. package/coverage/adapters/arangoAdapter.ts.html +170 -20
  9. package/coverage/adapters/fileAdapter.ts.html +445 -0
  10. package/coverage/adapters/index.html +72 -42
  11. package/coverage/adapters/postAdapter.ts.html +436 -0
  12. package/coverage/adapters/reaktorAdapter.ts.html +201 -18
  13. package/coverage/adapters/tagAdapter.ts.html +274 -25
  14. package/coverage/adapters/userAdapter.ts.html +829 -0
  15. package/coverage/analyticsUtils.ts.html +286 -0
  16. package/coverage/config.ts.html +766 -0
  17. package/coverage/index.html +77 -77
  18. package/coverage/mocks/group.ts.html +5 -5
  19. package/coverage/mocks/image.ts.html +18 -12
  20. package/coverage/mocks/index.html +37 -7
  21. package/coverage/mocks/post.ts.html +8 -8
  22. package/coverage/mocks/tag.ts.html +2 -2
  23. package/coverage/mocks/user.ts.html +18 -15
  24. package/coverage/testUtils.ts.html +1309 -0
  25. package/coverage/translationQueue.ts.html +592 -0
  26. package/coverage/types/error.types.ts.html +148 -0
  27. package/coverage/types/index.html +2 -2
  28. package/coverage/utils/adapterUtils.ts.html +39 -27
  29. package/coverage/utils/analyticsUtils.ts.html +35 -41
  30. package/coverage/utils/authUtils.ts.html +328 -0
  31. package/coverage/utils/dbI18n.ts.html +280 -0
  32. package/coverage/utils/googleTranslate.ts.html +385 -0
  33. package/coverage/utils/index.html +29 -44
  34. package/coverage/utils/localeUtils.ts.html +193 -0
  35. package/coverage/utils/sessionUtils.ts.html +211 -0
  36. package/coverage/utils/testUtils.ts.html +1309 -0
  37. package/index.js +1 -1
  38. package/lex.config.mjs +34 -0
  39. package/lib/actions/apps.d.ts +4 -4
  40. package/lib/actions/apps.js +17 -239
  41. package/lib/actions/connections.d.ts +2 -1
  42. package/lib/actions/connections.js +6 -89
  43. package/lib/actions/content.d.ts +13 -0
  44. package/lib/actions/content.js +17 -0
  45. package/lib/actions/conversations.d.ts +4 -2
  46. package/lib/actions/conversations.js +19 -336
  47. package/lib/actions/dynamodb.d.ts +4 -0
  48. package/lib/actions/dynamodb.js +2 -150
  49. package/lib/actions/email.d.ts +5 -2
  50. package/lib/actions/email.js +2 -152
  51. package/lib/actions/files.d.ts +3 -3
  52. package/lib/actions/files.js +5 -283
  53. package/lib/actions/groups.d.ts +4 -5
  54. package/lib/actions/groups.js +19 -259
  55. package/lib/actions/images.d.ts +8 -1
  56. package/lib/actions/images.js +31 -700
  57. package/lib/actions/index.d.ts +27 -23
  58. package/lib/actions/index.js +2 -66
  59. package/lib/actions/ios.d.ts +3 -3
  60. package/lib/actions/ios.js +9 -162
  61. package/lib/actions/locations.d.ts +3 -3
  62. package/lib/actions/locations.js +7 -122
  63. package/lib/actions/messages.d.ts +3 -4
  64. package/lib/actions/messages.js +21 -196
  65. package/lib/actions/notifications.d.ts +5 -1
  66. package/lib/actions/notifications.js +2 -59
  67. package/lib/actions/payments.d.ts +3 -1
  68. package/lib/actions/payments.js +11 -464
  69. package/lib/actions/posts.d.ts +7 -4
  70. package/lib/actions/posts.js +75 -527
  71. package/lib/actions/profiles.d.ts +4 -0
  72. package/lib/actions/profiles.js +8 -0
  73. package/lib/actions/reactions.d.ts +3 -1
  74. package/lib/actions/reactions.js +25 -312
  75. package/lib/actions/s3.d.ts +4 -0
  76. package/lib/actions/s3.js +2 -133
  77. package/lib/actions/search.d.ts +2 -2
  78. package/lib/actions/search.js +5 -90
  79. package/lib/actions/sms.d.ts +2 -9
  80. package/lib/actions/sms.js +2 -108
  81. package/lib/actions/statistics.d.ts +2 -1
  82. package/lib/actions/statistics.js +6 -60
  83. package/lib/actions/{subscription.d.ts → subscriptions.d.ts} +2 -2
  84. package/lib/actions/subscriptions.js +12 -0
  85. package/lib/actions/tags.d.ts +3 -3
  86. package/lib/actions/tags.js +19 -287
  87. package/lib/actions/users.d.ts +13 -12
  88. package/lib/actions/users.js +66 -763
  89. package/lib/actions/websockets.d.ts +2 -2
  90. package/lib/actions/websockets.js +14 -158
  91. package/lib/adapters/arangoAdapter.d.ts +7 -1
  92. package/lib/adapters/arangoAdapter.js +2 -46
  93. package/lib/adapters/contentAdapter.d.ts +8 -0
  94. package/lib/adapters/contentAdapter.js +2 -0
  95. package/lib/adapters/fileAdapter.d.ts +8 -2
  96. package/lib/adapters/fileAdapter.js +2 -76
  97. package/lib/adapters/imageAdapter.d.ts +7 -1
  98. package/lib/adapters/imageAdapter.js +2 -40
  99. package/lib/adapters/index.d.ts +9 -0
  100. package/lib/adapters/index.js +2 -0
  101. package/lib/adapters/messageAdapter.d.ts +7 -1
  102. package/lib/adapters/messageAdapter.js +2 -49
  103. package/lib/adapters/postAdapter.d.ts +7 -1
  104. package/lib/adapters/postAdapter.js +2 -70
  105. package/lib/adapters/reaktorAdapter.d.ts +16 -6
  106. package/lib/adapters/reaktorAdapter.js +2 -44
  107. package/lib/adapters/tagAdapter.d.ts +8 -1
  108. package/lib/adapters/tagAdapter.js +2 -50
  109. package/lib/adapters/userAdapter.d.ts +12 -1
  110. package/lib/adapters/userAdapter.js +2 -115
  111. package/lib/config.d.ts +43 -6
  112. package/lib/config.js +2 -125
  113. package/lib/handlers/graphqlHandler.d.ts +4 -0
  114. package/lib/handlers/graphqlHandler.js +2 -0
  115. package/lib/index.d.ts +17 -10
  116. package/lib/index.js +2 -66
  117. package/lib/lambdas/actions/websockets.d.ts +3 -3
  118. package/lib/lambdas/actions/websockets.js +14 -116
  119. package/lib/lambdas/authorizer.js +2 -67
  120. package/lib/lambdas/connection.js +2 -91
  121. package/lib/lambdas/utils/message.js +2 -42
  122. package/lib/lambdas/utils/websocket.js +2 -105
  123. package/lib/mocks/conversation.js +2 -35
  124. package/lib/mocks/file.js +2 -38
  125. package/lib/mocks/group.js +2 -47
  126. package/lib/mocks/image.d.ts +1 -1
  127. package/lib/mocks/image.js +2 -44
  128. package/lib/mocks/post.js +2 -55
  129. package/lib/mocks/tag.d.ts +1 -1
  130. package/lib/mocks/tag.js +2 -37
  131. package/lib/mocks/user.d.ts +1 -1
  132. package/lib/mocks/user.js +2 -88
  133. package/lib/mutations/content.d.ts +2 -0
  134. package/lib/mutations/content.js +2 -0
  135. package/lib/mutations/index.d.ts +11 -3
  136. package/lib/mutations/index.js +2 -26
  137. package/lib/mutations/locations.d.ts +1 -1
  138. package/lib/mutations/locations.js +2 -44
  139. package/lib/mutations/messages.d.ts +1 -1
  140. package/lib/mutations/messages.js +2 -86
  141. package/lib/mutations/posts.d.ts +1 -1
  142. package/lib/mutations/posts.js +2 -53
  143. package/lib/mutations/profiles.d.ts +2 -0
  144. package/lib/mutations/profiles.js +2 -0
  145. package/lib/mutations/reactions.d.ts +1 -1
  146. package/lib/mutations/reactions.js +2 -51
  147. package/lib/mutations/statistics.d.ts +1 -1
  148. package/lib/mutations/statistics.js +2 -39
  149. package/lib/mutations/subscriptions.d.ts +1 -1
  150. package/lib/mutations/subscriptions.js +2 -56
  151. package/lib/mutations/tags.d.ts +1 -1
  152. package/lib/mutations/tags.js +2 -120
  153. package/lib/mutations/users.js +2 -116
  154. package/lib/objectTypes/app.js +2 -173
  155. package/lib/objectTypes/bankAccount.js +2 -76
  156. package/lib/objectTypes/connection.js +2 -48
  157. package/lib/objectTypes/content.d.ts +2 -0
  158. package/lib/objectTypes/content.js +2 -0
  159. package/lib/objectTypes/conversation.js +2 -77
  160. package/lib/objectTypes/creditCard.js +2 -86
  161. package/lib/objectTypes/document.js +2 -46
  162. package/lib/objectTypes/error.js +2 -46
  163. package/lib/objectTypes/external.js +2 -74
  164. package/lib/objectTypes/file.js +2 -100
  165. package/lib/objectTypes/filter.js +2 -43
  166. package/lib/objectTypes/group.js +2 -123
  167. package/lib/objectTypes/iapSubscription.js +2 -40
  168. package/lib/objectTypes/image.d.ts +4 -0
  169. package/lib/objectTypes/image.js +2 -129
  170. package/lib/objectTypes/index.d.ts +26 -24
  171. package/lib/objectTypes/index.js +2 -68
  172. package/lib/objectTypes/location.js +2 -109
  173. package/lib/objectTypes/message.js +2 -96
  174. package/lib/objectTypes/passcode.js +2 -42
  175. package/lib/objectTypes/plan.js +2 -95
  176. package/lib/objectTypes/post.js +2 -125
  177. package/lib/objectTypes/profile.d.ts +3 -0
  178. package/lib/objectTypes/profile.js +2 -0
  179. package/lib/objectTypes/reaction.js +2 -61
  180. package/lib/objectTypes/relation.js +2 -49
  181. package/lib/objectTypes/search.js +2 -72
  182. package/lib/objectTypes/statistics.js +2 -39
  183. package/lib/objectTypes/subscription.js +2 -117
  184. package/lib/objectTypes/tag.js +2 -65
  185. package/lib/objectTypes/user.js +2 -144
  186. package/lib/queries/content.d.ts +2 -0
  187. package/lib/queries/content.js +2 -0
  188. package/lib/queries/index.d.ts +10 -3
  189. package/lib/queries/index.js +2 -33
  190. package/lib/queries/locations.d.ts +1 -1
  191. package/lib/queries/locations.js +2 -45
  192. package/lib/queries/messages.d.ts +1 -1
  193. package/lib/queries/messages.js +2 -52
  194. package/lib/queries/posts.d.ts +1 -1
  195. package/lib/queries/posts.js +2 -154
  196. package/lib/queries/reactions.d.ts +1 -1
  197. package/lib/queries/reactions.js +2 -56
  198. package/lib/queries/statistics.d.ts +1 -1
  199. package/lib/queries/statistics.js +2 -39
  200. package/lib/queries/subscriptions.d.ts +1 -1
  201. package/lib/queries/subscriptions.js +2 -44
  202. package/lib/queries/tags.d.ts +1 -1
  203. package/lib/queries/tags.js +2 -75
  204. package/lib/queries/users.js +2 -64
  205. package/lib/templates/email/layout.js +3 -25
  206. package/lib/templates/email/passwordForgot.js +3 -25
  207. package/lib/templates/email/passwordRecovery.js +3 -25
  208. package/lib/templates/email/verifyEmail.js +3 -25
  209. package/lib/templates/email/welcome.js +3 -25
  210. package/lib/templates/sms/passwordForgot.js +2 -24
  211. package/lib/templates/sms/passwordRecovery.js +2 -24
  212. package/lib/templates/sms/verifyEmail.js +2 -24
  213. package/lib/templates/sms/verifyPhone.js +2 -24
  214. package/lib/templates/sms/welcome.js +2 -24
  215. package/lib/types/apps.types.d.ts +6 -2
  216. package/lib/types/apps.types.js +2 -32
  217. package/lib/types/arangodb.types.d.ts +8 -4
  218. package/lib/types/arangodb.types.js +1 -16
  219. package/lib/types/auth.types.d.ts +11 -5
  220. package/lib/types/auth.types.js +1 -16
  221. package/lib/types/connections.types.d.ts +5 -1
  222. package/lib/types/connections.types.js +1 -16
  223. package/lib/types/content.types.d.ts +31 -0
  224. package/lib/types/content.types.js +1 -0
  225. package/lib/types/conversations.types.d.ts +6 -2
  226. package/lib/types/conversations.types.js +1 -16
  227. package/lib/types/email.types.d.ts +9 -5
  228. package/lib/types/email.types.js +1 -16
  229. package/lib/types/error.types.d.ts +1 -0
  230. package/lib/types/error.types.js +2 -44
  231. package/lib/types/files.types.d.ts +5 -1
  232. package/lib/types/files.types.js +1 -16
  233. package/lib/types/google.types.d.ts +4 -0
  234. package/lib/types/google.types.js +1 -16
  235. package/lib/types/groups.types.d.ts +5 -1
  236. package/lib/types/groups.types.js +1 -16
  237. package/lib/types/images.types.d.ts +6 -2
  238. package/lib/types/images.types.js +1 -16
  239. package/lib/types/index.d.ts +26 -20
  240. package/lib/types/index.js +2 -60
  241. package/lib/types/locations.types.d.ts +5 -1
  242. package/lib/types/locations.types.js +1 -16
  243. package/lib/types/messages.types.d.ts +7 -3
  244. package/lib/types/messages.types.js +1 -16
  245. package/lib/types/notifications.types.d.ts +9 -5
  246. package/lib/types/notifications.types.js +1 -16
  247. package/lib/types/payments.types.d.ts +5 -1
  248. package/lib/types/payments.types.js +1 -16
  249. package/lib/types/posts.types.d.ts +7 -3
  250. package/lib/types/posts.types.js +1 -16
  251. package/lib/types/{personas.types.d.ts → profiles.types.d.ts} +3 -15
  252. package/lib/types/profiles.types.js +1 -0
  253. package/lib/types/statistics.types.js +1 -16
  254. package/lib/types/tags.types.d.ts +5 -1
  255. package/lib/types/tags.types.js +1 -16
  256. package/lib/types/users.types.d.ts +41 -10
  257. package/lib/types/users.types.js +1 -16
  258. package/lib/types/websockets.types.d.ts +5 -1
  259. package/lib/types/websockets.types.js +1 -16
  260. package/lib/utils/adapterUtils.d.ts +4 -0
  261. package/lib/utils/adapterUtils.js +2 -45
  262. package/lib/utils/analyticsUtils.d.ts +5 -1
  263. package/lib/utils/analyticsUtils.js +2 -72
  264. package/lib/utils/arangodbUtils.d.ts +6 -2
  265. package/lib/utils/arangodbUtils.js +5 -163
  266. package/lib/utils/{auth.d.ts → authUtils.d.ts} +3 -1
  267. package/lib/utils/authUtils.js +2 -0
  268. package/lib/utils/contextUtils.d.ts +3 -0
  269. package/lib/utils/contextUtils.js +2 -0
  270. package/lib/utils/dbI18n.d.ts +10 -0
  271. package/lib/utils/dbI18n.example.d.ts +20 -0
  272. package/lib/utils/dbI18n.example.js +6 -0
  273. package/lib/utils/dbI18n.js +2 -0
  274. package/lib/utils/googleTranslate.d.ts +6 -0
  275. package/lib/utils/googleTranslate.js +2 -0
  276. package/lib/utils/graphqlUtils.d.ts +10 -0
  277. package/lib/utils/graphqlUtils.js +2 -0
  278. package/lib/utils/index.d.ts +18 -5
  279. package/lib/utils/index.js +2 -30
  280. package/lib/utils/languageDetection.d.ts +8 -0
  281. package/lib/utils/languageDetection.js +2 -0
  282. package/lib/utils/localeUtils.d.ts +11 -0
  283. package/lib/utils/localeUtils.example.d.ts +5 -0
  284. package/lib/utils/localeUtils.example.js +2 -0
  285. package/lib/utils/localeUtils.js +2 -0
  286. package/lib/utils/middlewareUtils.d.ts +2 -0
  287. package/lib/utils/middlewareUtils.js +2 -0
  288. package/lib/utils/{session.d.ts → sessionUtils.d.ts} +1 -1
  289. package/lib/utils/sessionUtils.js +2 -0
  290. package/lib/utils/stripeUtils.d.ts +7 -3
  291. package/lib/utils/stripeUtils.js +2 -43
  292. package/lib/utils/templateUtils.d.ts +3 -0
  293. package/lib/utils/templateUtils.js +2 -0
  294. package/lib/utils/testUtils.d.ts +95 -0
  295. package/lib/utils/testUtils.js +2 -0
  296. package/lib/utils/translationQueue.d.ts +29 -0
  297. package/lib/utils/translationQueue.example.d.ts +33 -0
  298. package/lib/utils/translationQueue.example.js +2 -0
  299. package/lib/utils/translationQueue.js +2 -0
  300. package/package.json +32 -28
  301. package/tsconfig.build.json +21 -0
  302. package/tsconfig.lint.json +33 -0
  303. package/tsconfig.test.json +31 -0
  304. package/.prettierrc.js +0 -4
  305. package/dist/actions/apps.js +0 -242
  306. package/dist/actions/connections.js +0 -90
  307. package/dist/actions/conversations.js +0 -350
  308. package/dist/actions/dynamodb.js +0 -150
  309. package/dist/actions/email.js +0 -152
  310. package/dist/actions/files.js +0 -283
  311. package/dist/actions/groups.js +0 -292
  312. package/dist/actions/images.js +0 -735
  313. package/dist/actions/index.js +0 -66
  314. package/dist/actions/ios.js +0 -164
  315. package/dist/actions/locations.js +0 -122
  316. package/dist/actions/messages.js +0 -208
  317. package/dist/actions/notifications.js +0 -59
  318. package/dist/actions/payments.js +0 -497
  319. package/dist/actions/personas.js +0 -110
  320. package/dist/actions/posts.js +0 -595
  321. package/dist/actions/reactions.js +0 -322
  322. package/dist/actions/s3.js +0 -133
  323. package/dist/actions/search.js +0 -90
  324. package/dist/actions/sms.js +0 -108
  325. package/dist/actions/statistics.js +0 -62
  326. package/dist/actions/subscription.js +0 -220
  327. package/dist/actions/tags.js +0 -292
  328. package/dist/actions/users.js +0 -784
  329. package/dist/actions/websockets.js +0 -174
  330. package/dist/adapters/arangoAdapter.js +0 -46
  331. package/dist/adapters/fileAdapter.js +0 -76
  332. package/dist/adapters/imageAdapter.js +0 -40
  333. package/dist/adapters/messageAdapter.js +0 -49
  334. package/dist/adapters/postAdapter.js +0 -70
  335. package/dist/adapters/reaktorAdapter.js +0 -44
  336. package/dist/adapters/tagAdapter.js +0 -50
  337. package/dist/adapters/userAdapter.js +0 -115
  338. package/dist/config.js +0 -125
  339. package/dist/index.js +0 -66
  340. package/dist/lambdas/actions/websockets.js +0 -132
  341. package/dist/lambdas/authorizer.js +0 -67
  342. package/dist/lambdas/connection.js +0 -91
  343. package/dist/lambdas/utils/message.js +0 -42
  344. package/dist/lambdas/utils/websocket.js +0 -105
  345. package/dist/mocks/conversation.js +0 -35
  346. package/dist/mocks/file.js +0 -38
  347. package/dist/mocks/group.js +0 -47
  348. package/dist/mocks/image.js +0 -44
  349. package/dist/mocks/nlabs.png +0 -0
  350. package/dist/mocks/post.js +0 -55
  351. package/dist/mocks/tag.js +0 -37
  352. package/dist/mocks/user.js +0 -88
  353. package/dist/mutations/index.js +0 -26
  354. package/dist/mutations/locations.js +0 -44
  355. package/dist/mutations/messages.js +0 -86
  356. package/dist/mutations/personas.js +0 -100
  357. package/dist/mutations/posts.js +0 -53
  358. package/dist/mutations/reactions.js +0 -51
  359. package/dist/mutations/statistics.js +0 -39
  360. package/dist/mutations/subscriptions.js +0 -56
  361. package/dist/mutations/tags.js +0 -120
  362. package/dist/mutations/users.js +0 -116
  363. package/dist/objectTypes/app.js +0 -173
  364. package/dist/objectTypes/bankAccount.js +0 -76
  365. package/dist/objectTypes/connection.js +0 -48
  366. package/dist/objectTypes/conversation.js +0 -77
  367. package/dist/objectTypes/creditCard.js +0 -86
  368. package/dist/objectTypes/document.js +0 -46
  369. package/dist/objectTypes/error.js +0 -46
  370. package/dist/objectTypes/external.js +0 -74
  371. package/dist/objectTypes/file.js +0 -100
  372. package/dist/objectTypes/filter.js +0 -43
  373. package/dist/objectTypes/group.js +0 -123
  374. package/dist/objectTypes/iapSubscription.js +0 -40
  375. package/dist/objectTypes/image.js +0 -129
  376. package/dist/objectTypes/index.js +0 -68
  377. package/dist/objectTypes/location.js +0 -109
  378. package/dist/objectTypes/message.js +0 -96
  379. package/dist/objectTypes/passcode.js +0 -42
  380. package/dist/objectTypes/persona.js +0 -87
  381. package/dist/objectTypes/plan.js +0 -95
  382. package/dist/objectTypes/post.js +0 -125
  383. package/dist/objectTypes/reaction.js +0 -61
  384. package/dist/objectTypes/relation.js +0 -49
  385. package/dist/objectTypes/search.js +0 -72
  386. package/dist/objectTypes/statistics.js +0 -39
  387. package/dist/objectTypes/subscription.js +0 -117
  388. package/dist/objectTypes/tag.js +0 -65
  389. package/dist/objectTypes/user.js +0 -144
  390. package/dist/queries/index.js +0 -33
  391. package/dist/queries/locations.js +0 -45
  392. package/dist/queries/messages.js +0 -52
  393. package/dist/queries/posts.js +0 -154
  394. package/dist/queries/reactions.js +0 -56
  395. package/dist/queries/statistics.js +0 -39
  396. package/dist/queries/subscriptions.js +0 -44
  397. package/dist/queries/tags.js +0 -75
  398. package/dist/queries/users.js +0 -64
  399. package/dist/templates/email/layout.js +0 -302
  400. package/dist/templates/email/passwordForgot.js +0 -38
  401. package/dist/templates/email/passwordRecovery.js +0 -35
  402. package/dist/templates/email/verifyEmail.js +0 -38
  403. package/dist/templates/email/welcome.js +0 -38
  404. package/dist/templates/sms/passwordForgot.js +0 -24
  405. package/dist/templates/sms/passwordRecovery.js +0 -24
  406. package/dist/templates/sms/verifyEmail.js +0 -24
  407. package/dist/templates/sms/verifyPhone.js +0 -24
  408. package/dist/templates/sms/welcome.js +0 -24
  409. package/dist/types/apps.js +0 -32
  410. package/dist/types/arangodb.js +0 -16
  411. package/dist/types/auth.js +0 -16
  412. package/dist/types/connections.js +0 -16
  413. package/dist/types/conversations.js +0 -16
  414. package/dist/types/email.js +0 -16
  415. package/dist/types/error.js +0 -44
  416. package/dist/types/files.js +0 -16
  417. package/dist/types/google.js +0 -16
  418. package/dist/types/groups.js +0 -16
  419. package/dist/types/images.js +0 -16
  420. package/dist/types/index.js +0 -60
  421. package/dist/types/locations.js +0 -16
  422. package/dist/types/messages.js +0 -16
  423. package/dist/types/notifications.js +0 -16
  424. package/dist/types/payments.js +0 -16
  425. package/dist/types/personas.js +0 -16
  426. package/dist/types/posts.js +0 -16
  427. package/dist/types/statistics.js +0 -16
  428. package/dist/types/tags.js +0 -16
  429. package/dist/types/users.js +0 -16
  430. package/dist/types/websockets.js +0 -16
  431. package/dist/utils/adapterUtils.js +0 -45
  432. package/dist/utils/analyticsUtils.js +0 -72
  433. package/dist/utils/arangodbUtils.js +0 -165
  434. package/dist/utils/auth.js +0 -57
  435. package/dist/utils/index.js +0 -30
  436. package/dist/utils/session.js +0 -60
  437. package/jest.setup.js +0 -0
  438. package/lex.config.cjs +0 -13
  439. package/lib/actions/personas.d.ts +0 -3
  440. package/lib/actions/personas.js +0 -110
  441. package/lib/actions/subscription.js +0 -208
  442. package/lib/mutations/personas.d.ts +0 -2
  443. package/lib/mutations/personas.js +0 -100
  444. package/lib/objectTypes/persona.d.ts +0 -3
  445. package/lib/objectTypes/persona.js +0 -87
  446. package/lib/types/personas.types.js +0 -16
  447. package/lib/utils/auth.js +0 -57
  448. package/lib/utils/session.js +0 -60
package/.env ADDED
@@ -0,0 +1 @@
1
+ GOOGLE_API_KEY="AIzaSyB5gXFPS7bkEtqr48yS66C79HZUf1g6sEM"
package/.env.example ADDED
@@ -0,0 +1 @@
1
+ GOOGLE_API_KEY=""
@@ -0,0 +1,434 @@
1
+ # Database-Driven I18N System
2
+
3
+ This guide explains how to use the new database-driven internationalization (i18n) system for TorchOne API.
4
+
5
+ ## Overview
6
+
7
+ The database-driven i18n system allows you to:
8
+ - Store translations in the database for dynamic content management
9
+ - Provide fallback content when translations are not found
10
+ - Support interpolation for dynamic values
11
+ - Batch fetch translations for better performance
12
+ - Manage translations through the database without code changes
13
+
14
+ ## Database Schema
15
+
16
+ ### Content Collection
17
+
18
+ The system uses a `content` collection with the following structure:
19
+
20
+ ```typescript
21
+ interface ContentType {
22
+ _id?: string;
23
+ _key?: string;
24
+ contentId?: string;
25
+ key: string; // Translation key (e.g., 'sms.welcome')
26
+ locale: Locale; // Language code ('en', 'es', 'fr', 'de', 'pt', 'it')
27
+ content: string; // Translated content
28
+ description?: string; // Optional description
29
+ category?: string; // Optional category for organization
30
+ isActive?: boolean; // Whether this translation is active
31
+ userId?: string; // User who created the content
32
+ added?: number; // Timestamp when created
33
+ modified?: number; // Timestamp when last modified
34
+ }
35
+ ```
36
+
37
+ ## Locale Support
38
+
39
+ The system supports both primary languages and regional variants for comprehensive internationalization:
40
+
41
+ ### **Primary Languages**
42
+ - `en` - English
43
+ - `es` - Spanish
44
+ - `fr` - French
45
+ - `de` - German
46
+ - `pt` - Portuguese
47
+ - `it` - Italian
48
+
49
+ ### **Regional Variants**
50
+ - `en-us`, `en-gb`, `en-ca`, `en-au` - English variants
51
+ - `es-mx`, `es-es`, `es-ar` - Spanish variants
52
+ - `fr-fr`, `fr-ca` - French variants
53
+ - `de-de`, `de-at` - German variants
54
+ - `pt-br`, `pt-pt` - Portuguese variants
55
+ - `it-it` - Italian variants
56
+
57
+ ### **Locale Strategy**
58
+ - **Storage**: Full locale with region (e.g., "en-us") for regional formatting
59
+ - **Translation**: Language extraction (e.g., "en-us" → "en") for API calls
60
+ - **Fallback**: Regional → Language → App default hierarchy
61
+
62
+ ### **Locale Utilities**
63
+
64
+ ```typescript
65
+ import {
66
+ extractLanguage,
67
+ isRegionalLocale,
68
+ getFallbackChain,
69
+ isValidLocale
70
+ } from './src/utils/localeUtils';
71
+
72
+ // Extract language for translation APIs
73
+ const language = extractLanguage('en-us'); // 'en'
74
+
75
+ // Check if locale includes region
76
+ const isRegional = isRegionalLocale('es-mx'); // true
77
+
78
+ // Get fallback chain
79
+ const fallbacks = getFallbackChain('fr-ca'); // ['fr-ca', 'fr']
80
+
81
+ // Validate locale
82
+ const isValid = isValidLocale('en-us'); // true
83
+ ```
84
+
85
+ ## Core Functions
86
+
87
+ ### 1. Basic Translation with Fallback
88
+
89
+ ```typescript
90
+ import { dbI18n } from './src/utils/dbI18n';
91
+
92
+ const message = await dbI18n(
93
+ context,
94
+ 'sms.welcome',
95
+ 'Welcome to TorchOne, {{username}}! Thank you for joining our platform.',
96
+ 'en'
97
+ );
98
+ ```
99
+
100
+ **Parameters:**
101
+ - `context`: API context with database connection
102
+ - `key`: Content key to look up in database
103
+ - `fallbackContent`: Content to return if not found in database
104
+ - `locale`: Optional locale (defaults to 'en')
105
+
106
+ **Returns:** Promise<string> - The translated content or fallback
107
+
108
+ ### 2. Translation with Interpolation
109
+
110
+ ```typescript
111
+ import { dbI18nWithInterpolation } from './src/utils/dbI18n';
112
+
113
+ const message = await dbI18nWithInterpolation(
114
+ context,
115
+ 'sms.verificationCode',
116
+ 'Your verification code is: {{code}}',
117
+ { code: '123456' },
118
+ 'es'
119
+ );
120
+ ```
121
+
122
+ **Parameters:**
123
+ - `context`: API context with database connection
124
+ - `key`: Content key to look up
125
+ - `fallbackContent`: Content to return if not found
126
+ - `interpolation`: Object with values to interpolate
127
+ - `locale`: Optional locale (defaults to 'en')
128
+
129
+ **Returns:** Promise<string> - The translated content with interpolated values
130
+
131
+ ### 3. Multiple Translations
132
+
133
+ ```typescript
134
+ import { dbI18nMultiple } from './src/utils/dbI18n';
135
+
136
+ const [welcome, getStarted, signature] = await dbI18nMultiple(context, [
137
+ {
138
+ key: 'email.welcome',
139
+ fallback: 'Welcome to TorchOne!',
140
+ locale: 'en'
141
+ },
142
+ {
143
+ key: 'email.getStarted',
144
+ fallback: 'To get started, complete your profile.',
145
+ locale: 'en'
146
+ },
147
+ {
148
+ key: 'email.teamSignature',
149
+ fallback: 'The TorchOne Team',
150
+ locale: 'en'
151
+ }
152
+ ]);
153
+ ```
154
+
155
+ ### 4. Batch Translation
156
+
157
+ ```typescript
158
+ import { dbI18nBatch } from './src/utils/dbI18n';
159
+
160
+ const keys = ['welcome', 'verification', 'passwordReset'];
161
+ const fallbackMap = {
162
+ 'welcome': 'Welcome!',
163
+ 'verification': 'Please verify your account.',
164
+ 'passwordReset': 'Your password has been reset.'
165
+ };
166
+
167
+ const translations = await dbI18nBatch(context, keys, fallbackMap, 'fr');
168
+ // Returns: { welcome: '...', verification: '...', passwordReset: '...' }
169
+ ```
170
+
171
+ ## Database Operations
172
+
173
+ ### Adding Content
174
+
175
+ ```typescript
176
+ import { addContent } from './src/actions/content';
177
+
178
+ const newContent = await addContent(context, {
179
+ key: 'sms.welcome',
180
+ locale: 'es',
181
+ content: '¡Bienvenido a TorchOne, {{username}}!',
182
+ description: 'Welcome SMS message in Spanish',
183
+ category: 'sms',
184
+ isActive: true
185
+ });
186
+ ```
187
+
188
+ ### Updating Content
189
+
190
+ ```typescript
191
+ import { updateContent } from './src/actions/content';
192
+
193
+ const updatedContent = await updateContent(context, {
194
+ contentId: 'content-abc123',
195
+ content: 'Updated welcome message',
196
+ description: 'Updated description'
197
+ });
198
+ ```
199
+
200
+ ### Searching Content
201
+
202
+ ```typescript
203
+ import { searchContent } from './src/actions/content';
204
+
205
+ // Search by category
206
+ const smsContent = await searchContent(context, { category: 'sms' });
207
+
208
+ // Search by locale
209
+ const spanishContent = await searchContent(context, { locale: 'es' });
210
+
211
+ // Search by key
212
+ const welcomeContent = await searchContent(context, { key: 'sms.welcome' });
213
+ ```
214
+
215
+ ## Usage Examples
216
+
217
+ ### SMS Notifications
218
+
219
+ ```typescript
220
+ export async function sendWelcomeSMS(context: ApiContext, username: string, phoneNumber: string) {
221
+ const message = await dbI18nWithInterpolation(
222
+ context,
223
+ 'sms.welcome',
224
+ 'Welcome to TorchOne, {{username}}! Thank you for joining our platform.',
225
+ { username },
226
+ 'en'
227
+ );
228
+
229
+ // Send SMS logic here
230
+ console.log(`Sending SMS to ${phoneNumber}: ${message}`);
231
+ return message;
232
+ }
233
+ ```
234
+
235
+ ### Email Templates
236
+
237
+ ```typescript
238
+ export async function generateWelcomeEmail(context: ApiContext, username: string, locale: Locale = 'en') {
239
+ const [welcomeMessage, getStartedMessage, teamSignature] = await dbI18nMultiple(context, [
240
+ {
241
+ key: 'email.welcome',
242
+ fallback: 'Welcome to TorchOne, {{username}}!',
243
+ locale
244
+ },
245
+ {
246
+ key: 'email.getStarted',
247
+ fallback: 'To get started, please complete your profile and explore our features.',
248
+ locale
249
+ },
250
+ {
251
+ key: 'email.teamSignature',
252
+ fallback: 'The TorchOne Team',
253
+ locale
254
+ }
255
+ ]);
256
+
257
+ // Apply interpolation
258
+ const interpolatedWelcome = welcomeMessage.replace(/\{\{username\}\}/g, username);
259
+
260
+ return {
261
+ subject: interpolatedWelcome,
262
+ body: `${interpolatedWelcome}\n\n${getStartedMessage}\n\n${teamSignature}`
263
+ };
264
+ }
265
+ ```
266
+
267
+ ### Error Messages
268
+
269
+ ```typescript
270
+ export async function getErrorMessage(context: ApiContext, errorCode: string, locale: Locale = 'en') {
271
+ try {
272
+ const message = await dbI18n(
273
+ context,
274
+ `error.${errorCode}`,
275
+ `An error occurred: ${errorCode}`,
276
+ locale
277
+ );
278
+ return message;
279
+ } catch (error) {
280
+ // If database is unavailable, return fallback
281
+ console.error('Database error, using fallback:', error);
282
+ return `An error occurred: ${errorCode}`;
283
+ }
284
+ }
285
+ ```
286
+
287
+ ## Best Practices
288
+
289
+ ### 1. Key Naming Convention
290
+
291
+ Use hierarchical keys for better organization:
292
+ - `sms.welcome`
293
+ - `email.verification.subject`
294
+ - `error.invalid_email`
295
+ - `notification.profile_updated`
296
+
297
+ ### 2. Fallback Content
298
+
299
+ Always provide meaningful fallback content:
300
+ ```typescript
301
+ // Good
302
+ await dbI18n(context, 'welcome', 'Welcome to our platform!', 'en');
303
+
304
+ // Bad
305
+ await dbI18n(context, 'welcome', '', 'en');
306
+ ```
307
+
308
+ ### 3. Error Handling
309
+
310
+ Handle database errors gracefully:
311
+ ```typescript
312
+ try {
313
+ const message = await dbI18n(context, key, fallback, locale);
314
+ return message;
315
+ } catch (error) {
316
+ console.error('Translation error:', error);
317
+ return fallback; // Always return fallback on error
318
+ }
319
+ ```
320
+
321
+ ### 4. Performance
322
+
323
+ Use batch operations for multiple translations:
324
+ ```typescript
325
+ // Good - Single database query
326
+ const translations = await dbI18nBatch(context, keys, fallbackMap, locale);
327
+
328
+ // Bad - Multiple database queries
329
+ const translations = await Promise.all(
330
+ keys.map(key => dbI18n(context, key, fallbackMap[key], locale))
331
+ );
332
+ ```
333
+
334
+ ### 5. Caching
335
+
336
+ Consider implementing caching for frequently accessed translations:
337
+ ```typescript
338
+ // Example with simple in-memory cache
339
+ const translationCache = new Map<string, string>();
340
+
341
+ export async function cachedI18n(context: ApiContext, key: string, fallback: string, locale: Locale = 'en') {
342
+ const cacheKey = `${key}:${locale}`;
343
+
344
+ if (translationCache.has(cacheKey)) {
345
+ return translationCache.get(cacheKey)!;
346
+ }
347
+
348
+ const content = await dbI18n(context, key, fallback, locale);
349
+ translationCache.set(cacheKey, content);
350
+
351
+ return content;
352
+ }
353
+ ```
354
+
355
+ ## Migration from Static Translations
356
+
357
+ To migrate from the static translation system:
358
+
359
+ 1. **Export existing translations:**
360
+ ```typescript
361
+ import { torchoneResources } from './src/translations';
362
+
363
+ // Convert static translations to database format
364
+ const translations = Object.entries(torchoneResources).flatMap(([locale, data]) =>
365
+ Object.entries(data.translation).map(([key, content]) => ({
366
+ key,
367
+ locale,
368
+ content: typeof content === 'string' ? content : JSON.stringify(content),
369
+ category: key.split('.')[0], // Extract category from key
370
+ isActive: true
371
+ }))
372
+ );
373
+ ```
374
+
375
+ 2. **Bulk insert into database:**
376
+ ```typescript
377
+ for (const translation of translations) {
378
+ await addContent(context, translation);
379
+ }
380
+ ```
381
+
382
+ 3. **Update code to use database-driven functions:**
383
+ ```typescript
384
+ // Before
385
+ const message = dbI18n('sms.welcome', { username: 'John' });
386
+
387
+ // After
388
+ const message = await dbI18nWithInterpolation(
389
+ context,
390
+ 'sms.welcome',
391
+ 'Welcome to TorchOne, {{username}}!',
392
+ { username: 'John' }
393
+ );
394
+ ```
395
+
396
+ ## Benefits
397
+
398
+ 1. **Dynamic Content Management**: Update translations without code changes
399
+ 2. **Fallback Support**: Always provide content even if database is unavailable
400
+ 3. **Interpolation**: Support for dynamic values in translations
401
+ 4. **Performance**: Batch operations for multiple translations
402
+ 5. **Organization**: Categorize and manage translations effectively
403
+ 6. **Audit Trail**: Track who created/modified translations
404
+ 7. **Active/Inactive**: Control which translations are available
405
+
406
+ ## Troubleshooting
407
+
408
+ ### Common Issues
409
+
410
+ 1. **Database Connection Errors**: Always provide fallback content
411
+ 2. **Missing Translations**: Check if content exists in database
412
+ 3. **Type Errors**: Ensure locale parameter is of type `Locale`
413
+ 4. **Performance Issues**: Use batch operations for multiple translations
414
+
415
+ ### Debugging
416
+
417
+ ```typescript
418
+ // Enable debug logging
419
+ const DEBUG_I18N = process.env.DEBUG_I18N === 'true';
420
+
421
+ export async function debugI18n(context: ApiContext, key: string, fallback: string, locale: Locale = 'en') {
422
+ if (DEBUG_I18N) {
423
+ console.log(`[I18N] Looking up key: ${key}, locale: ${locale}`);
424
+ }
425
+
426
+ const content = await dbI18n(context, key, fallback, locale);
427
+
428
+ if (DEBUG_I18N) {
429
+ console.log(`[I18N] Result: ${content}`);
430
+ }
431
+
432
+ return content;
433
+ }
434
+ ```