@cravery/core 0.0.10 → 0.0.12

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 (402) hide show
  1. package/README.md +80 -0
  2. package/dist/config/ai.d.ts.map +1 -1
  3. package/dist/config/ai.js +5 -0
  4. package/dist/config/ai.js.map +1 -1
  5. package/dist/config/collections.d.ts +1 -1
  6. package/dist/config/collections.js +2 -2
  7. package/dist/config/common.d.ts +1 -1
  8. package/dist/config/common.d.ts.map +1 -1
  9. package/dist/config/common.js +2 -2
  10. package/dist/config/common.js.map +1 -1
  11. package/dist/config/limits.d.ts +3 -3
  12. package/dist/config/limits.d.ts.map +1 -1
  13. package/dist/config/limits.js +20 -14
  14. package/dist/config/limits.js.map +1 -1
  15. package/dist/config/subscription.d.ts +1 -1
  16. package/dist/config/subscription.d.ts.map +1 -1
  17. package/dist/config/subscription.js +2 -2
  18. package/dist/config/subscription.js.map +1 -1
  19. package/dist/index.d.ts +0 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +0 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/lib/ai/cost.d.ts.map +1 -1
  24. package/dist/lib/ai/cost.js +3 -2
  25. package/dist/lib/ai/cost.js.map +1 -1
  26. package/dist/lib/ai/embedding.js +2 -2
  27. package/dist/lib/ai/embedding.js.map +1 -1
  28. package/dist/lib/ai/errors.d.ts +1 -1
  29. package/dist/lib/ai/flow.d.ts +8 -8
  30. package/dist/lib/ai/flow.d.ts.map +1 -1
  31. package/dist/lib/ai/flow.js.map +1 -1
  32. package/dist/lib/iam.d.ts +3 -0
  33. package/dist/lib/iam.d.ts.map +1 -1
  34. package/dist/lib/iam.js +17 -2
  35. package/dist/lib/iam.js.map +1 -1
  36. package/dist/lib/index.d.ts +0 -2
  37. package/dist/lib/index.d.ts.map +1 -1
  38. package/dist/lib/index.js +0 -2
  39. package/dist/lib/index.js.map +1 -1
  40. package/dist/lib/repository/equipment.repository.js +1 -1
  41. package/dist/lib/repository/ingredient.repository.js +1 -1
  42. package/dist/lib/repository/profile.repository.js +1 -1
  43. package/dist/lib/repository/recipe-queue.repository.js +1 -1
  44. package/dist/lib/repository/recipe.repository.js +1 -1
  45. package/dist/lib/repository/report.repository.js +1 -1
  46. package/dist/lib/repository/settings.repository.js +1 -1
  47. package/dist/lib/repository/user.repository.js +1 -1
  48. package/dist/lib/storage.js +5 -5
  49. package/dist/lib/storage.js.map +1 -1
  50. package/dist/lib/usage/usage.service.d.ts +1 -2
  51. package/dist/lib/usage/usage.service.d.ts.map +1 -1
  52. package/dist/lib/usage/usage.service.js +4 -4
  53. package/dist/lib/usage/usage.service.js.map +1 -1
  54. package/dist/types/ai/config.d.ts +2 -1
  55. package/dist/types/ai/config.d.ts.map +1 -1
  56. package/dist/types/ai/index.d.ts +0 -2
  57. package/dist/types/ai/index.d.ts.map +1 -1
  58. package/dist/types/ai/index.js +0 -2
  59. package/dist/types/ai/index.js.map +1 -1
  60. package/dist/types/ai/recipe.d.ts +50 -50
  61. package/dist/types/ai/recipe.d.ts.map +1 -1
  62. package/dist/types/ai/recipe.js +11 -15
  63. package/dist/types/ai/recipe.js.map +1 -1
  64. package/dist/types/ai/translation.d.ts +14 -14
  65. package/dist/types/ai/translation.d.ts.map +1 -1
  66. package/dist/types/ai/translation.js +4 -6
  67. package/dist/types/ai/translation.js.map +1 -1
  68. package/dist/types/api.d.ts +14 -0
  69. package/dist/types/api.d.ts.map +1 -0
  70. package/dist/types/api.js +3 -0
  71. package/dist/types/api.js.map +1 -0
  72. package/dist/types/core/api.d.ts +14 -0
  73. package/dist/types/core/api.d.ts.map +1 -0
  74. package/dist/types/core/api.js +3 -0
  75. package/dist/types/core/api.js.map +1 -0
  76. package/dist/types/core/asset.d.ts +19 -0
  77. package/dist/types/core/asset.d.ts.map +1 -0
  78. package/dist/types/core/asset.js +12 -0
  79. package/dist/types/core/asset.js.map +1 -0
  80. package/dist/types/core/enums/image_type.d.ts +5 -0
  81. package/dist/types/core/enums/image_type.d.ts.map +1 -0
  82. package/dist/types/core/enums/image_type.js +7 -0
  83. package/dist/types/core/enums/image_type.js.map +1 -0
  84. package/dist/types/core/enums/index.d.ts +6 -0
  85. package/dist/types/core/enums/index.d.ts.map +1 -0
  86. package/dist/types/core/enums/index.js +22 -0
  87. package/dist/types/core/enums/index.js.map +1 -0
  88. package/dist/types/core/enums/locale.d.ts +5 -0
  89. package/dist/types/core/enums/locale.d.ts.map +1 -0
  90. package/dist/types/core/enums/locale.js +7 -0
  91. package/dist/types/core/enums/locale.js.map +1 -0
  92. package/dist/types/core/enums/measurement_system.d.ts +5 -0
  93. package/dist/types/core/enums/measurement_system.d.ts.map +1 -0
  94. package/dist/types/core/enums/measurement_system.js +7 -0
  95. package/dist/types/core/enums/measurement_system.js.map +1 -0
  96. package/dist/types/core/enums/theme.d.ts +5 -0
  97. package/dist/types/core/enums/theme.d.ts.map +1 -0
  98. package/dist/types/core/enums/theme.js +7 -0
  99. package/dist/types/core/enums/theme.js.map +1 -0
  100. package/dist/types/core/enums/url_type.d.ts +5 -0
  101. package/dist/types/core/enums/url_type.d.ts.map +1 -0
  102. package/dist/types/core/enums/url_type.js +15 -0
  103. package/dist/types/core/enums/url_type.js.map +1 -0
  104. package/dist/types/core/errors.d.ts +37 -0
  105. package/dist/types/core/errors.d.ts.map +1 -0
  106. package/dist/types/core/errors.js +89 -0
  107. package/dist/types/core/errors.js.map +1 -0
  108. package/dist/types/core/index.d.ts +6 -0
  109. package/dist/types/core/index.d.ts.map +1 -0
  110. package/dist/types/core/index.js +22 -0
  111. package/dist/types/core/index.js.map +1 -0
  112. package/dist/types/core/settings.d.ts +88 -0
  113. package/dist/types/core/settings.d.ts.map +1 -0
  114. package/dist/types/core/settings.js +28 -0
  115. package/dist/types/core/settings.js.map +1 -0
  116. package/dist/types/enums/index.d.ts +2 -0
  117. package/dist/types/enums/index.d.ts.map +1 -1
  118. package/dist/types/enums/index.js +2 -0
  119. package/dist/types/enums/index.js.map +1 -1
  120. package/dist/types/enums/recipe_source.d.ts +2 -2
  121. package/dist/types/enums/recipe_source.d.ts.map +1 -1
  122. package/dist/types/enums/recipe_source.js +1 -1
  123. package/dist/types/enums/recipe_source.js.map +1 -1
  124. package/dist/types/enums/recipe_status.d.ts +2 -2
  125. package/dist/types/enums/recipe_status.d.ts.map +1 -1
  126. package/dist/types/enums/recipe_status.js +0 -1
  127. package/dist/types/enums/recipe_status.js.map +1 -1
  128. package/dist/types/enums/subscription_role.d.ts +5 -0
  129. package/dist/types/enums/subscription_role.d.ts.map +1 -0
  130. package/dist/types/enums/subscription_role.js +13 -0
  131. package/dist/types/enums/subscription_role.js.map +1 -0
  132. package/dist/types/enums/subscription_status.d.ts +5 -0
  133. package/dist/types/enums/subscription_status.d.ts.map +1 -0
  134. package/dist/types/enums/subscription_status.js +14 -0
  135. package/dist/types/enums/subscription_status.js.map +1 -0
  136. package/dist/types/iam/enums/index.d.ts +7 -0
  137. package/dist/types/iam/enums/index.d.ts.map +1 -0
  138. package/dist/types/iam/enums/index.js +23 -0
  139. package/dist/types/iam/enums/index.js.map +1 -0
  140. package/dist/types/iam/enums/profile_status.d.ts +5 -0
  141. package/dist/types/iam/enums/profile_status.d.ts.map +1 -0
  142. package/dist/types/iam/enums/profile_status.js +12 -0
  143. package/dist/types/iam/enums/profile_status.js.map +1 -0
  144. package/dist/types/iam/enums/subscription_role.d.ts +5 -0
  145. package/dist/types/iam/enums/subscription_role.d.ts.map +1 -0
  146. package/dist/types/iam/enums/subscription_role.js +7 -0
  147. package/dist/types/iam/enums/subscription_role.js.map +1 -0
  148. package/dist/types/iam/enums/subscription_status.d.ts +5 -0
  149. package/dist/types/iam/enums/subscription_status.d.ts.map +1 -0
  150. package/dist/types/iam/enums/subscription_status.js +12 -0
  151. package/dist/types/iam/enums/subscription_status.js.map +1 -0
  152. package/dist/types/iam/enums/subscription_tier.d.ts +4 -0
  153. package/dist/types/iam/enums/subscription_tier.d.ts.map +1 -0
  154. package/dist/types/iam/enums/subscription_tier.js +6 -0
  155. package/dist/types/iam/enums/subscription_tier.js.map +1 -0
  156. package/dist/types/iam/enums/user_role.d.ts +5 -0
  157. package/dist/types/iam/enums/user_role.d.ts.map +1 -0
  158. package/dist/types/iam/enums/user_role.js +13 -0
  159. package/dist/types/iam/enums/user_role.js.map +1 -0
  160. package/dist/types/iam/enums/user_status.d.ts +5 -0
  161. package/dist/types/iam/enums/user_status.d.ts.map +1 -0
  162. package/dist/types/iam/enums/user_status.js +12 -0
  163. package/dist/types/iam/enums/user_status.js.map +1 -0
  164. package/dist/types/iam/index.d.ts +1 -0
  165. package/dist/types/iam/index.d.ts.map +1 -1
  166. package/dist/types/iam/index.js +1 -0
  167. package/dist/types/iam/index.js.map +1 -1
  168. package/dist/types/iam/profile.d.ts +9 -26
  169. package/dist/types/iam/profile.d.ts.map +1 -1
  170. package/dist/types/iam/profile.js +1 -2
  171. package/dist/types/iam/profile.js.map +1 -1
  172. package/dist/types/iam/settings.d.ts +96 -0
  173. package/dist/types/iam/settings.d.ts.map +1 -0
  174. package/dist/types/iam/settings.js +31 -0
  175. package/dist/types/iam/settings.js.map +1 -0
  176. package/dist/types/iam/subscription.d.ts +7 -7
  177. package/dist/types/iam/subscription.d.ts.map +1 -1
  178. package/dist/types/iam/subscription.js +5 -5
  179. package/dist/types/iam/subscription.js.map +1 -1
  180. package/dist/types/iam/user.d.ts +1 -15
  181. package/dist/types/iam/user.d.ts.map +1 -1
  182. package/dist/types/iam/user.js +2 -2
  183. package/dist/types/iam/user.js.map +1 -1
  184. package/dist/types/index.d.ts +1 -4
  185. package/dist/types/index.d.ts.map +1 -1
  186. package/dist/types/index.js +1 -4
  187. package/dist/types/index.js.map +1 -1
  188. package/dist/types/moderation/enums/index.d.ts +5 -0
  189. package/dist/types/moderation/enums/index.d.ts.map +1 -0
  190. package/dist/types/moderation/enums/index.js +21 -0
  191. package/dist/types/moderation/enums/index.js.map +1 -0
  192. package/dist/types/moderation/enums/moderation_status.d.ts +5 -0
  193. package/dist/types/moderation/enums/moderation_status.d.ts.map +1 -0
  194. package/dist/types/moderation/enums/moderation_status.js +11 -0
  195. package/dist/types/moderation/enums/moderation_status.js.map +1 -0
  196. package/dist/types/moderation/enums/priority.d.ts +5 -0
  197. package/dist/types/moderation/enums/priority.d.ts.map +1 -0
  198. package/dist/types/moderation/enums/priority.js +7 -0
  199. package/dist/types/moderation/enums/priority.js.map +1 -0
  200. package/dist/types/moderation/enums/severity.d.ts +5 -0
  201. package/dist/types/moderation/enums/severity.d.ts.map +1 -0
  202. package/dist/types/moderation/enums/severity.js +7 -0
  203. package/dist/types/moderation/enums/severity.js.map +1 -0
  204. package/dist/types/moderation/enums/suggestion_category.d.ts +5 -0
  205. package/dist/types/moderation/enums/suggestion_category.d.ts.map +1 -0
  206. package/dist/types/moderation/enums/suggestion_category.js +13 -0
  207. package/dist/types/moderation/enums/suggestion_category.js.map +1 -0
  208. package/dist/types/moderation/index.d.ts +3 -0
  209. package/dist/types/moderation/index.d.ts.map +1 -0
  210. package/dist/types/moderation/index.js +19 -0
  211. package/dist/types/moderation/index.js.map +1 -0
  212. package/dist/types/moderation/moderation.d.ts +139 -0
  213. package/dist/types/moderation/moderation.d.ts.map +1 -0
  214. package/dist/types/moderation/moderation.js +40 -0
  215. package/dist/types/moderation/moderation.js.map +1 -0
  216. package/dist/types/moderation.d.ts +36 -28
  217. package/dist/types/moderation.d.ts.map +1 -1
  218. package/dist/types/recipe/enums/allergen.d.ts +5 -0
  219. package/dist/types/recipe/enums/allergen.d.ts.map +1 -0
  220. package/dist/types/recipe/enums/allergen.js +21 -0
  221. package/dist/types/recipe/enums/allergen.js.map +1 -0
  222. package/dist/types/recipe/enums/cuisine.d.ts +5 -0
  223. package/dist/types/recipe/enums/cuisine.d.ts.map +1 -0
  224. package/dist/types/recipe/enums/cuisine.js +41 -0
  225. package/dist/types/recipe/enums/cuisine.js.map +1 -0
  226. package/dist/types/recipe/enums/dietary_tag.d.ts +5 -0
  227. package/dist/types/recipe/enums/dietary_tag.d.ts.map +1 -0
  228. package/dist/types/recipe/enums/dietary_tag.js +23 -0
  229. package/dist/types/recipe/enums/dietary_tag.js.map +1 -0
  230. package/dist/types/recipe/enums/difficulty.d.ts +5 -0
  231. package/dist/types/recipe/enums/difficulty.d.ts.map +1 -0
  232. package/dist/types/recipe/enums/difficulty.js +12 -0
  233. package/dist/types/recipe/enums/difficulty.js.map +1 -0
  234. package/dist/types/recipe/enums/index.d.ts +11 -0
  235. package/dist/types/recipe/enums/index.d.ts.map +1 -0
  236. package/dist/types/recipe/enums/index.js +27 -0
  237. package/dist/types/recipe/enums/index.js.map +1 -0
  238. package/dist/types/recipe/enums/meal_type.d.ts +5 -0
  239. package/dist/types/recipe/enums/meal_type.d.ts.map +1 -0
  240. package/dist/types/recipe/enums/meal_type.js +16 -0
  241. package/dist/types/recipe/enums/meal_type.js.map +1 -0
  242. package/dist/types/recipe/enums/recipe_source.d.ts +5 -0
  243. package/dist/types/recipe/enums/recipe_source.d.ts.map +1 -0
  244. package/dist/types/recipe/enums/recipe_source.js +7 -0
  245. package/dist/types/recipe/enums/recipe_source.js.map +1 -0
  246. package/dist/types/recipe/enums/recipe_status.d.ts +5 -0
  247. package/dist/types/recipe/enums/recipe_status.d.ts.map +1 -0
  248. package/dist/types/recipe/enums/recipe_status.js +14 -0
  249. package/dist/types/recipe/enums/recipe_status.js.map +1 -0
  250. package/dist/types/recipe/enums/spiciness.d.ts +5 -0
  251. package/dist/types/recipe/enums/spiciness.d.ts.map +1 -0
  252. package/dist/types/recipe/enums/spiciness.js +7 -0
  253. package/dist/types/recipe/enums/spiciness.js.map +1 -0
  254. package/dist/types/recipe/enums/temperature_unit.d.ts +5 -0
  255. package/dist/types/recipe/enums/temperature_unit.d.ts.map +1 -0
  256. package/dist/types/recipe/enums/temperature_unit.js +7 -0
  257. package/dist/types/recipe/enums/temperature_unit.js.map +1 -0
  258. package/dist/types/recipe/enums/unit.d.ts +5 -0
  259. package/dist/types/recipe/enums/unit.d.ts.map +1 -0
  260. package/dist/types/recipe/enums/unit.js +53 -0
  261. package/dist/types/recipe/enums/unit.js.map +1 -0
  262. package/dist/types/recipe/equipment.js +2 -2
  263. package/dist/types/recipe/equipment.js.map +1 -1
  264. package/dist/types/recipe/filters.d.ts +31 -0
  265. package/dist/types/recipe/filters.d.ts.map +1 -0
  266. package/dist/types/recipe/filters.js +16 -0
  267. package/dist/types/recipe/filters.js.map +1 -0
  268. package/dist/types/recipe/index.d.ts +2 -0
  269. package/dist/types/recipe/index.d.ts.map +1 -1
  270. package/dist/types/recipe/index.js +2 -0
  271. package/dist/types/recipe/index.js.map +1 -1
  272. package/dist/types/recipe/ingredient.d.ts +18 -18
  273. package/dist/types/recipe/ingredient.js +6 -6
  274. package/dist/types/recipe/ingredient.js.map +1 -1
  275. package/dist/types/recipe/recipe.d.ts +35 -65
  276. package/dist/types/recipe/recipe.d.ts.map +1 -1
  277. package/dist/types/recipe/recipe.js +6 -5
  278. package/dist/types/recipe/recipe.js.map +1 -1
  279. package/dist/types/recipe/temperature.js +2 -2
  280. package/dist/types/recipe/temperature.js.map +1 -1
  281. package/dist/types/report/enums/index.d.ts +5 -0
  282. package/dist/types/report/enums/index.d.ts.map +1 -0
  283. package/dist/types/report/enums/index.js +21 -0
  284. package/dist/types/report/enums/index.js.map +1 -0
  285. package/dist/types/report/enums/report_priority.d.ts +5 -0
  286. package/dist/types/report/enums/report_priority.d.ts.map +1 -0
  287. package/dist/types/report/enums/report_priority.js +12 -0
  288. package/dist/types/report/enums/report_priority.js.map +1 -0
  289. package/dist/types/report/enums/report_status.d.ts +5 -0
  290. package/dist/types/report/enums/report_status.d.ts.map +1 -0
  291. package/dist/types/report/enums/report_status.js +12 -0
  292. package/dist/types/report/enums/report_status.js.map +1 -0
  293. package/dist/types/report/enums/report_target_type.d.ts +5 -0
  294. package/dist/types/report/enums/report_target_type.d.ts.map +1 -0
  295. package/dist/types/report/enums/report_target_type.js +12 -0
  296. package/dist/types/report/enums/report_target_type.js.map +1 -0
  297. package/dist/types/report/enums/report_type.d.ts +5 -0
  298. package/dist/types/report/enums/report_type.d.ts.map +1 -0
  299. package/dist/types/report/enums/report_type.js +14 -0
  300. package/dist/types/report/enums/report_type.js.map +1 -0
  301. package/dist/types/report/index.d.ts +3 -0
  302. package/dist/types/report/index.d.ts.map +1 -0
  303. package/dist/types/report/index.js +19 -0
  304. package/dist/types/report/index.js.map +1 -0
  305. package/dist/types/report/report.d.ts +95 -0
  306. package/dist/types/report/report.d.ts.map +1 -0
  307. package/dist/types/report/report.js +32 -0
  308. package/dist/types/report/report.js.map +1 -0
  309. package/dist/types/report.d.ts +46 -38
  310. package/dist/types/report.d.ts.map +1 -1
  311. package/package.json +1 -1
  312. package/src/config/ai.ts +5 -0
  313. package/src/config/collections.ts +1 -1
  314. package/src/config/common.ts +1 -1
  315. package/src/config/limits.ts +21 -15
  316. package/src/config/subscription.ts +1 -1
  317. package/src/index.ts +0 -1
  318. package/src/lib/ai/cost.ts +3 -2
  319. package/src/lib/ai/embedding.ts +1 -1
  320. package/src/lib/ai/flow.ts +1 -0
  321. package/src/lib/iam.ts +18 -3
  322. package/src/lib/index.ts +0 -2
  323. package/src/lib/storage.ts +1 -1
  324. package/src/lib/usage/usage.service.ts +7 -4
  325. package/src/types/ai/config.ts +2 -1
  326. package/src/types/ai/index.ts +0 -2
  327. package/src/types/ai/recipe.ts +6 -5
  328. package/src/types/ai/translation.ts +5 -3
  329. package/src/types/core/api.ts +15 -0
  330. package/src/types/core/asset.ts +11 -0
  331. package/src/types/core/enums/index.ts +5 -0
  332. package/src/types/core/enums/measurement_system.ts +5 -0
  333. package/src/types/core/enums/theme.ts +5 -0
  334. package/src/{lib/errors/index.ts → types/core/errors.ts} +19 -27
  335. package/src/types/core/index.ts +5 -0
  336. package/src/types/{settings.ts → core/settings.ts} +8 -17
  337. package/src/types/iam/enums/index.ts +6 -0
  338. package/src/types/iam/enums/subscription_role.ts +5 -0
  339. package/src/types/iam/enums/subscription_status.ts +10 -0
  340. package/src/types/iam/enums/user_role.ts +11 -0
  341. package/src/types/iam/index.ts +1 -0
  342. package/src/types/iam/profile.ts +2 -17
  343. package/src/types/iam/subscription.ts +10 -6
  344. package/src/types/iam/user.ts +3 -25
  345. package/src/types/index.ts +1 -4
  346. package/src/types/moderation/enums/index.ts +4 -0
  347. package/src/types/moderation/index.ts +2 -0
  348. package/src/types/{moderation.ts → moderation/moderation.ts} +6 -32
  349. package/src/types/recipe/enums/index.ts +10 -0
  350. package/src/types/{enums → recipe/enums}/recipe_source.ts +1 -1
  351. package/src/types/{enums → recipe/enums}/recipe_status.ts +0 -1
  352. package/src/types/recipe/equipment.ts +3 -3
  353. package/src/types/{ai → recipe}/filters.ts +2 -2
  354. package/src/types/recipe/index.ts +2 -0
  355. package/src/types/recipe/ingredient.ts +7 -7
  356. package/src/types/recipe/recipe.ts +4 -40
  357. package/src/types/recipe/temperature.ts +2 -2
  358. package/src/types/report/enums/index.ts +4 -0
  359. package/src/types/report/enums/report_priority.ts +10 -0
  360. package/src/types/report/enums/report_status.ts +10 -0
  361. package/src/types/report/enums/report_target_type.ts +10 -0
  362. package/src/types/report/enums/report_type.ts +12 -0
  363. package/src/types/report/index.ts +2 -0
  364. package/src/types/report/report.ts +38 -0
  365. package/src/lib/repository/equipment.repository.ts +0 -93
  366. package/src/lib/repository/errors.ts +0 -37
  367. package/src/lib/repository/factory.ts +0 -29
  368. package/src/lib/repository/firestore.repository.ts +0 -633
  369. package/src/lib/repository/index.ts +0 -12
  370. package/src/lib/repository/ingredient.repository.ts +0 -93
  371. package/src/lib/repository/profile.repository.ts +0 -51
  372. package/src/lib/repository/recipe-queue.repository.ts +0 -49
  373. package/src/lib/repository/recipe.repository.ts +0 -51
  374. package/src/lib/repository/report.repository.ts +0 -85
  375. package/src/lib/repository/rtdb.repository.ts +0 -67
  376. package/src/lib/repository/settings.repository.ts +0 -57
  377. package/src/lib/repository/user.repository.ts +0 -44
  378. package/src/types/ai/flow.ts +0 -82
  379. package/src/types/asset.ts +0 -19
  380. package/src/types/enums/index.ts +0 -21
  381. package/src/types/enums/role.ts +0 -11
  382. package/src/types/report.ts +0 -90
  383. package/src/types/repository.ts +0 -140
  384. package/src/types/response.ts +0 -30
  385. /package/src/types/{enums → core/enums}/image_type.ts +0 -0
  386. /package/src/types/{enums → core/enums}/locale.ts +0 -0
  387. /package/src/types/{enums → core/enums}/url_type.ts +0 -0
  388. /package/src/types/{enums → iam/enums}/profile_status.ts +0 -0
  389. /package/src/types/{enums → iam/enums}/subscription_tier.ts +0 -0
  390. /package/src/types/{enums → iam/enums}/user_status.ts +0 -0
  391. /package/src/types/{enums → moderation/enums}/moderation_status.ts +0 -0
  392. /package/src/types/{enums → moderation/enums}/priority.ts +0 -0
  393. /package/src/types/{enums → moderation/enums}/severity.ts +0 -0
  394. /package/src/types/{enums → moderation/enums}/suggestion_category.ts +0 -0
  395. /package/src/types/{enums → recipe/enums}/allergen.ts +0 -0
  396. /package/src/types/{enums → recipe/enums}/cuisine.ts +0 -0
  397. /package/src/types/{enums → recipe/enums}/dietary_tag.ts +0 -0
  398. /package/src/types/{enums → recipe/enums}/difficulty.ts +0 -0
  399. /package/src/types/{enums → recipe/enums}/meal_type.ts +0 -0
  400. /package/src/types/{enums → recipe/enums}/spiciness.ts +0 -0
  401. /package/src/types/{enums → recipe/enums}/temperature_unit.ts +0 -0
  402. /package/src/types/{enums → recipe/enums}/unit.ts +0 -0
@@ -1,633 +0,0 @@
1
- import {
2
- Firestore,
3
- CollectionReference,
4
- DocumentData,
5
- Query,
6
- FieldValue,
7
- Transaction,
8
- WriteBatch,
9
- Timestamp,
10
- QueryDocumentSnapshot,
11
- } from "firebase-admin/firestore";
12
- import type {
13
- IRepository,
14
- QueryOptions,
15
- PaginatedResult,
16
- CursorPaginatedResult,
17
- WhereClause,
18
- TransactionCallback,
19
- RepositoryConfig,
20
- } from "../../types/repository";
21
- import { RepositoryError, RepositoryErrorCode } from "./errors";
22
-
23
- const FIRESTORE_IN_QUERY_LIMIT = 10;
24
- const FIRESTORE_BATCH_WRITE_LIMIT = 500;
25
-
26
- export abstract class FirestoreRepository<
27
- T extends { id: string },
28
- > implements IRepository<T> {
29
- protected readonly collection: CollectionReference<DocumentData>;
30
- protected readonly config: Required<RepositoryConfig>;
31
-
32
- constructor(
33
- protected readonly firestore: Firestore,
34
- protected readonly collectionName: string,
35
- config?: RepositoryConfig,
36
- ) {
37
- this.collection = firestore.collection(collectionName);
38
- this.config = {
39
- enableTimestamps: true,
40
- enableSoftDelete: false,
41
- validateOnWrite: false,
42
- ...config,
43
- };
44
- }
45
-
46
- protected toDocument(entity: Partial<T>): DocumentData {
47
- return { ...entity };
48
- }
49
-
50
- protected fromDocument(id: string, data: DocumentData): T {
51
- return { id, ...data } as T;
52
- }
53
-
54
- protected validate(_data: Partial<T>): void {}
55
-
56
- async findById(id: string): Promise<T | null> {
57
- const doc = await this.collection.doc(id).get();
58
- if (!doc.exists) return null;
59
-
60
- const data = doc.data()!;
61
- if (this.config.enableSoftDelete && data.deletedAt) {
62
- return null;
63
- }
64
-
65
- return this.fromDocument(doc.id, data);
66
- }
67
-
68
- async findByIds(ids: string[]): Promise<T[]> {
69
- if (ids.length === 0) return [];
70
-
71
- const results: T[] = [];
72
- const chunks = this.chunk(ids, FIRESTORE_IN_QUERY_LIMIT);
73
-
74
- for (const chunk of chunks) {
75
- const refs = chunk.map((id) => this.collection.doc(id));
76
- const docs = await this.firestore.getAll(...refs);
77
-
78
- for (const doc of docs) {
79
- if (doc.exists) {
80
- const data = doc.data()!;
81
- if (this.config.enableSoftDelete && data.deletedAt) {
82
- continue;
83
- }
84
- results.push(this.fromDocument(doc.id, data));
85
- }
86
- }
87
- }
88
-
89
- return results;
90
- }
91
-
92
- async findAll(options?: QueryOptions): Promise<T[]> {
93
- let query: Query = this.collection;
94
-
95
- if (this.config.enableSoftDelete) {
96
- query = query.where("deletedAt", "==", null);
97
- }
98
-
99
- query = this.applyQueryOptions(query, options);
100
- const snapshot = await query.get();
101
- return snapshot.docs.map((doc: QueryDocumentSnapshot<DocumentData>) =>
102
- this.fromDocument(doc.id, doc.data()),
103
- );
104
- }
105
-
106
- async findWhere(
107
- clauses: WhereClause[],
108
- options?: QueryOptions,
109
- ): Promise<T[]> {
110
- let query = this.applyWhereClauses(this.collection, clauses);
111
-
112
- if (this.config.enableSoftDelete) {
113
- query = query.where("deletedAt", "==", null);
114
- }
115
-
116
- query = this.applyQueryOptions(query, options);
117
- const snapshot = await query.get();
118
- return snapshot.docs.map((doc: QueryDocumentSnapshot<DocumentData>) =>
119
- this.fromDocument(doc.id, doc.data()),
120
- );
121
- }
122
-
123
- async findPaginated(
124
- clauses?: WhereClause[],
125
- options?: QueryOptions,
126
- ): Promise<PaginatedResult<T>> {
127
- let query: Query = clauses
128
- ? this.applyWhereClauses(this.collection, clauses)
129
- : this.collection;
130
-
131
- if (this.config.enableSoftDelete) {
132
- query = query.where("deletedAt", "==", null);
133
- }
134
-
135
- const countSnapshot = await query.count().get();
136
- const total = countSnapshot.data().count;
137
-
138
- query = this.applyQueryOptions(query, options);
139
- const snapshot = await query.get();
140
- const data = snapshot.docs.map((doc: QueryDocumentSnapshot<DocumentData>) =>
141
- this.fromDocument(doc.id, doc.data()),
142
- );
143
-
144
- const offset = options?.offset ?? 0;
145
- return {
146
- data,
147
- total,
148
- hasMore: offset + data.length < total,
149
- };
150
- }
151
-
152
- async findPaginatedCursor(
153
- clauses?: WhereClause[],
154
- options?: QueryOptions & { cursor?: string },
155
- ): Promise<CursorPaginatedResult<T>> {
156
- let query: Query = clauses
157
- ? this.applyWhereClauses(this.collection, clauses)
158
- : this.collection;
159
-
160
- if (this.config.enableSoftDelete) {
161
- query = query.where("deletedAt", "==", null);
162
- }
163
-
164
- if (options?.orderBy) {
165
- query = query.orderBy(options.orderBy.field, options.orderBy.direction);
166
- }
167
-
168
- if (options?.cursor) {
169
- const cursorDoc = await this.collection.doc(options.cursor).get();
170
- if (cursorDoc.exists) {
171
- query = query.startAfter(cursorDoc);
172
- }
173
- }
174
-
175
- const limit = options?.limit ?? 20;
176
- query = query.limit(limit + 1);
177
-
178
- const snapshot = await query.get();
179
- const docs = snapshot.docs;
180
- const hasMore = docs.length > limit;
181
-
182
- if (hasMore) docs.pop();
183
-
184
- const data = docs.map((doc: QueryDocumentSnapshot<DocumentData>) =>
185
- this.fromDocument(doc.id, doc.data()),
186
- );
187
- const nextCursor =
188
- hasMore && docs.length > 0 ? docs[docs.length - 1].id : null;
189
-
190
- return { data, nextCursor, hasMore };
191
- }
192
-
193
- async exists(id: string): Promise<boolean> {
194
- const doc = await this.collection.doc(id).get();
195
- if (!doc.exists) return false;
196
-
197
- if (this.config.enableSoftDelete) {
198
- const data = doc.data()!;
199
- return !data.deletedAt;
200
- }
201
-
202
- return true;
203
- }
204
-
205
- async count(clauses?: WhereClause[]): Promise<number> {
206
- let query: Query = clauses
207
- ? this.applyWhereClauses(this.collection, clauses)
208
- : this.collection;
209
-
210
- if (this.config.enableSoftDelete) {
211
- query = query.where("deletedAt", "==", null);
212
- }
213
-
214
- const snapshot = await query.count().get();
215
- return snapshot.data().count;
216
- }
217
-
218
- async create(
219
- data: Omit<T, "id" | "createdAt" | "updatedAt" | "deletedAt">,
220
- id?: string,
221
- ): Promise<T> {
222
- if (this.config.validateOnWrite) {
223
- this.validate(data as Partial<T>);
224
- }
225
-
226
- const docRef = id ? this.collection.doc(id) : this.collection.doc();
227
- const now = Timestamp.now();
228
-
229
- let docData = this.toDocument({
230
- ...data,
231
- id: docRef.id,
232
- } as Partial<T>);
233
-
234
- if (this.config.enableTimestamps) {
235
- docData = {
236
- ...docData,
237
- createdAt: now,
238
- updatedAt: now,
239
- };
240
- }
241
-
242
- if (this.config.enableSoftDelete) {
243
- docData = {
244
- ...docData,
245
- deletedAt: null,
246
- };
247
- }
248
-
249
- await docRef.set(docData);
250
- return this.fromDocument(docRef.id, docData);
251
- }
252
-
253
- async update(
254
- id: string,
255
- data: Partial<Omit<T, "id" | "createdAt" | "updatedAt" | "deletedAt">>,
256
- ): Promise<T> {
257
- if (this.config.validateOnWrite) {
258
- this.validate(data as Partial<T>);
259
- }
260
-
261
- const docRef = this.collection.doc(id);
262
- let updateData = this.toDocument(data as Partial<T>);
263
-
264
- if (this.config.enableTimestamps) {
265
- updateData = {
266
- ...updateData,
267
- updatedAt: Timestamp.now(),
268
- };
269
- }
270
-
271
- await docRef.update(updateData);
272
- const updated = await docRef.get();
273
-
274
- if (!updated.exists) {
275
- throw new RepositoryError(
276
- RepositoryErrorCode.NOT_FOUND,
277
- `Document ${id} not found after update`,
278
- { collection: this.collectionName, id },
279
- );
280
- }
281
-
282
- return this.fromDocument(updated.id, updated.data()!);
283
- }
284
-
285
- async delete(id: string): Promise<void> {
286
- if (this.config.enableSoftDelete) {
287
- await this.collection.doc(id).update({
288
- deletedAt: Timestamp.now(),
289
- updatedAt: Timestamp.now(),
290
- });
291
- } else {
292
- await this.collection.doc(id).delete();
293
- }
294
- }
295
-
296
- async createMany(
297
- items: Omit<T, "id" | "createdAt" | "updatedAt" | "deletedAt">[],
298
- ): Promise<T[]> {
299
- if (items.length === 0) return [];
300
-
301
- const results: T[] = [];
302
- const chunks = this.chunk(items, FIRESTORE_BATCH_WRITE_LIMIT);
303
-
304
- for (const chunk of chunks) {
305
- const batch = this.firestore.batch();
306
- const now = Timestamp.now();
307
- const chunkResults: T[] = [];
308
-
309
- for (const item of chunk) {
310
- if (this.config.validateOnWrite) {
311
- this.validate(item as Partial<T>);
312
- }
313
-
314
- const docRef = this.collection.doc();
315
- let docData = this.toDocument({
316
- ...item,
317
- id: docRef.id,
318
- } as Partial<T>);
319
-
320
- if (this.config.enableTimestamps) {
321
- docData = { ...docData, createdAt: now, updatedAt: now };
322
- }
323
-
324
- if (this.config.enableSoftDelete) {
325
- docData = { ...docData, deletedAt: null };
326
- }
327
-
328
- batch.set(docRef, docData);
329
- chunkResults.push(this.fromDocument(docRef.id, docData));
330
- }
331
-
332
- await batch.commit();
333
- results.push(...chunkResults);
334
- }
335
-
336
- return results;
337
- }
338
-
339
- async updateMany(
340
- updates: Array<{
341
- id: string;
342
- data: Partial<Omit<T, "id" | "createdAt" | "updatedAt" | "deletedAt">>;
343
- }>,
344
- ): Promise<void> {
345
- if (updates.length === 0) return;
346
-
347
- const chunks = this.chunk(updates, FIRESTORE_BATCH_WRITE_LIMIT);
348
-
349
- for (const chunk of chunks) {
350
- const batch = this.firestore.batch();
351
- const now = Timestamp.now();
352
-
353
- for (const { id, data } of chunk) {
354
- if (this.config.validateOnWrite) {
355
- this.validate(data as Partial<T>);
356
- }
357
-
358
- const docRef = this.collection.doc(id);
359
- let updateData = this.toDocument(data as Partial<T>);
360
-
361
- if (this.config.enableTimestamps) {
362
- updateData = { ...updateData, updatedAt: now };
363
- }
364
-
365
- batch.update(docRef, updateData);
366
- }
367
-
368
- await batch.commit();
369
- }
370
- }
371
-
372
- async deleteMany(ids: string[]): Promise<void> {
373
- if (ids.length === 0) return;
374
-
375
- const chunks = this.chunk(ids, FIRESTORE_BATCH_WRITE_LIMIT);
376
-
377
- for (const chunk of chunks) {
378
- const batch = this.firestore.batch();
379
- const now = Timestamp.now();
380
-
381
- for (const id of chunk) {
382
- const docRef = this.collection.doc(id);
383
-
384
- if (this.config.enableSoftDelete) {
385
- batch.update(docRef, {
386
- deletedAt: now,
387
- updatedAt: now,
388
- });
389
- } else {
390
- batch.delete(docRef);
391
- }
392
- }
393
-
394
- await batch.commit();
395
- }
396
- }
397
-
398
- async increment(
399
- id: string,
400
- field: keyof T,
401
- value: number = 1,
402
- ): Promise<void> {
403
- const updateData: DocumentData = {
404
- [field as string]: FieldValue.increment(value),
405
- };
406
-
407
- if (this.config.enableTimestamps) {
408
- updateData.updatedAt = Timestamp.now();
409
- }
410
-
411
- await this.collection.doc(id).update(updateData);
412
- }
413
-
414
- async decrement(
415
- id: string,
416
- field: keyof T,
417
- value: number = 1,
418
- ): Promise<void> {
419
- await this.increment(id, field, -value);
420
- }
421
-
422
- async runTransaction<R>(callback: TransactionCallback<R>): Promise<R> {
423
- return this.firestore.runTransaction(callback);
424
- }
425
-
426
- getFirestore(): Firestore {
427
- return this.firestore;
428
- }
429
-
430
- batch(): WriteBatch {
431
- return this.firestore.batch();
432
- }
433
-
434
- protected applyWhereClauses(query: Query, clauses: WhereClause[]): Query {
435
- let q = query;
436
-
437
- for (const clause of clauses) {
438
- if (
439
- (clause.op === "in" ||
440
- clause.op === "not-in" ||
441
- clause.op === "array-contains-any") &&
442
- Array.isArray(clause.value) &&
443
- clause.value.length > FIRESTORE_IN_QUERY_LIMIT
444
- ) {
445
- throw new RepositoryError(
446
- RepositoryErrorCode.QUERY_LIMIT_EXCEEDED,
447
- `${clause.op} queries support max ${FIRESTORE_IN_QUERY_LIMIT} values. ` +
448
- `Got ${clause.value.length}. Use multiple queries and merge results.`,
449
- {
450
- field: clause.field,
451
- op: clause.op,
452
- valueCount: clause.value.length,
453
- },
454
- );
455
- }
456
-
457
- q = q.where(clause.field, clause.op, clause.value);
458
- }
459
-
460
- return q;
461
- }
462
-
463
- protected applyQueryOptions(query: Query, options?: QueryOptions): Query {
464
- let q = query;
465
-
466
- if (options?.orderBy) {
467
- q = q.orderBy(options.orderBy.field, options.orderBy.direction);
468
- }
469
- if (options?.offset) {
470
- q = q.offset(options.offset);
471
- }
472
- if (options?.limit) {
473
- q = q.limit(options.limit);
474
- }
475
-
476
- return q;
477
- }
478
-
479
- protected chunk<U>(array: U[], size: number): U[][] {
480
- const chunks: U[][] = [];
481
- for (let i = 0; i < array.length; i += size) {
482
- chunks.push(array.slice(i, i + size));
483
- }
484
- return chunks;
485
- }
486
-
487
- protected async getInTransaction(
488
- transaction: Transaction,
489
- id: string,
490
- ): Promise<T | null> {
491
- const doc = await transaction.get(this.collection.doc(id));
492
- if (!doc.exists) return null;
493
-
494
- const data = doc.data()!;
495
- if (this.config.enableSoftDelete && data.deletedAt) {
496
- return null;
497
- }
498
-
499
- return this.fromDocument(doc.id, data);
500
- }
501
-
502
- protected setInTransaction(
503
- transaction: Transaction,
504
- id: string,
505
- data: Partial<T>,
506
- ): void {
507
- let docData = this.toDocument(data);
508
- const now = Timestamp.now();
509
-
510
- if (this.config.enableTimestamps) {
511
- docData = { ...docData, createdAt: now, updatedAt: now };
512
- }
513
-
514
- if (this.config.enableSoftDelete) {
515
- docData = { ...docData, deletedAt: null };
516
- }
517
-
518
- transaction.set(this.collection.doc(id), docData);
519
- }
520
-
521
- protected updateInTransaction(
522
- transaction: Transaction,
523
- id: string,
524
- data: Partial<T>,
525
- ): void {
526
- let docData = this.toDocument(data);
527
-
528
- if (this.config.enableTimestamps) {
529
- docData = { ...docData, updatedAt: Timestamp.now() };
530
- }
531
-
532
- transaction.update(this.collection.doc(id), docData);
533
- }
534
-
535
- protected deleteInTransaction(transaction: Transaction, id: string): void {
536
- if (this.config.enableSoftDelete) {
537
- const now = Timestamp.now();
538
- transaction.update(this.collection.doc(id), {
539
- deletedAt: now,
540
- updatedAt: now,
541
- });
542
- } else {
543
- transaction.delete(this.collection.doc(id));
544
- }
545
- }
546
-
547
- createInBatch(
548
- batch: WriteBatch,
549
- data: Omit<T, "id" | "createdAt" | "updatedAt" | "deletedAt">,
550
- id?: string,
551
- ): T {
552
- if (this.config.validateOnWrite) {
553
- this.validate(data as Partial<T>);
554
- }
555
-
556
- const docRef = id ? this.collection.doc(id) : this.collection.doc();
557
- const now = Timestamp.now();
558
-
559
- let docData = this.toDocument({
560
- ...data,
561
- id: docRef.id,
562
- } as Partial<T>);
563
-
564
- if (this.config.enableTimestamps) {
565
- docData = { ...docData, createdAt: now, updatedAt: now };
566
- }
567
-
568
- if (this.config.enableSoftDelete) {
569
- docData = { ...docData, deletedAt: null };
570
- }
571
-
572
- batch.set(docRef, docData);
573
- return this.fromDocument(docRef.id, docData);
574
- }
575
-
576
- setInBatch(
577
- batch: WriteBatch,
578
- id: string,
579
- data: Partial<Omit<T, "id" | "createdAt" | "updatedAt" | "deletedAt">>,
580
- ): void {
581
- if (this.config.validateOnWrite) {
582
- this.validate(data as Partial<T>);
583
- }
584
-
585
- const docRef = this.collection.doc(id);
586
- const now = Timestamp.now();
587
-
588
- let docData = this.toDocument(data as Partial<T>);
589
-
590
- if (this.config.enableTimestamps) {
591
- docData = { ...docData, createdAt: now, updatedAt: now };
592
- }
593
-
594
- if (this.config.enableSoftDelete) {
595
- docData = { ...docData, deletedAt: null };
596
- }
597
-
598
- batch.set(docRef, docData);
599
- }
600
-
601
- updateInBatch(
602
- batch: WriteBatch,
603
- id: string,
604
- data: Partial<Omit<T, "id" | "createdAt" | "updatedAt" | "deletedAt">>,
605
- ): void {
606
- if (this.config.validateOnWrite) {
607
- this.validate(data as Partial<T>);
608
- }
609
-
610
- const docRef = this.collection.doc(id);
611
- let updateData = this.toDocument(data as Partial<T>);
612
-
613
- if (this.config.enableTimestamps) {
614
- updateData = { ...updateData, updatedAt: Timestamp.now() };
615
- }
616
-
617
- batch.update(docRef, updateData);
618
- }
619
-
620
- deleteInBatch(batch: WriteBatch, id: string): void {
621
- const docRef = this.collection.doc(id);
622
-
623
- if (this.config.enableSoftDelete) {
624
- const now = Timestamp.now();
625
- batch.update(docRef, {
626
- deletedAt: now,
627
- updatedAt: now,
628
- });
629
- } else {
630
- batch.delete(docRef);
631
- }
632
- }
633
- }
@@ -1,12 +0,0 @@
1
- export * from "./errors";
2
- export * from "./factory";
3
- export * from "./firestore.repository";
4
- export * from "./rtdb.repository";
5
- export * from "./user.repository";
6
- export * from "./profile.repository";
7
- export * from "./settings.repository";
8
- export * from "./recipe.repository";
9
- export * from "./recipe-queue.repository";
10
- export * from "./ingredient.repository";
11
- export * from "./equipment.repository";
12
- export * from "./report.repository";