@cravery/core 0.0.25 → 0.0.26

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 (286) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/types/ai/recipe.d.ts +1 -244
  6. package/dist/types/ai/recipe.d.ts.map +1 -1
  7. package/dist/types/ai/recipe.js +0 -28
  8. package/dist/types/ai/recipe.js.map +1 -1
  9. package/dist/types/ai/translation.d.ts +1 -107
  10. package/dist/types/ai/translation.d.ts.map +1 -1
  11. package/dist/types/ai/translation.js +0 -11
  12. package/dist/types/ai/translation.js.map +1 -1
  13. package/dist/types/core/api.d.ts +4 -4
  14. package/dist/types/core/api.d.ts.map +1 -1
  15. package/dist/types/core/asset.d.ts +2 -22
  16. package/dist/types/core/asset.d.ts.map +1 -1
  17. package/dist/types/core/asset.js +0 -9
  18. package/dist/types/core/asset.js.map +1 -1
  19. package/dist/types/core/entity.d.ts +7 -0
  20. package/dist/types/core/entity.d.ts.map +1 -0
  21. package/dist/types/core/entity.js +3 -0
  22. package/dist/types/core/entity.js.map +1 -0
  23. package/dist/types/core/index.d.ts +5 -1
  24. package/dist/types/core/index.d.ts.map +1 -1
  25. package/dist/types/core/index.js +5 -1
  26. package/dist/types/core/index.js.map +1 -1
  27. package/dist/types/core/locale.d.ts +3 -0
  28. package/dist/types/core/locale.d.ts.map +1 -0
  29. package/dist/types/core/locale.js +5 -0
  30. package/dist/types/core/locale.js.map +1 -0
  31. package/dist/types/core/measurement_system.d.ts +3 -0
  32. package/dist/types/core/measurement_system.d.ts.map +1 -0
  33. package/dist/types/core/measurement_system.js +5 -0
  34. package/dist/types/core/measurement_system.js.map +1 -0
  35. package/dist/types/core/settings.d.ts +5 -88
  36. package/dist/types/core/settings.d.ts.map +1 -1
  37. package/dist/types/core/settings.js +0 -25
  38. package/dist/types/core/settings.js.map +1 -1
  39. package/dist/types/core/theme.d.ts +3 -0
  40. package/dist/types/core/theme.d.ts.map +1 -0
  41. package/dist/types/core/theme.js +5 -0
  42. package/dist/types/core/theme.js.map +1 -0
  43. package/dist/types/core/timestamp.d.ts +5 -0
  44. package/dist/types/core/timestamp.d.ts.map +1 -0
  45. package/dist/types/core/timestamp.js +3 -0
  46. package/dist/types/core/timestamp.js.map +1 -0
  47. package/dist/types/iam/index.d.ts +6 -1
  48. package/dist/types/iam/index.d.ts.map +1 -1
  49. package/dist/types/iam/index.js +6 -1
  50. package/dist/types/iam/index.js.map +1 -1
  51. package/dist/types/iam/profile.d.ts +2 -56
  52. package/dist/types/iam/profile.d.ts.map +1 -1
  53. package/dist/types/iam/profile.js +0 -22
  54. package/dist/types/iam/profile.js.map +1 -1
  55. package/dist/types/iam/profile_status.d.ts +3 -0
  56. package/dist/types/iam/profile_status.d.ts.map +1 -0
  57. package/dist/types/iam/profile_status.js +10 -0
  58. package/dist/types/iam/profile_status.js.map +1 -0
  59. package/dist/types/iam/subscription.d.ts +4 -80
  60. package/dist/types/iam/subscription.d.ts.map +1 -1
  61. package/dist/types/iam/subscription.js +0 -19
  62. package/dist/types/iam/subscription.js.map +1 -1
  63. package/dist/types/iam/subscription_role.d.ts +3 -0
  64. package/dist/types/iam/subscription_role.d.ts.map +1 -0
  65. package/dist/types/iam/subscription_role.js +5 -0
  66. package/dist/types/iam/subscription_role.js.map +1 -0
  67. package/dist/types/iam/subscription_status.d.ts +3 -0
  68. package/dist/types/iam/subscription_status.d.ts.map +1 -0
  69. package/dist/types/iam/subscription_status.js +10 -0
  70. package/dist/types/iam/subscription_status.js.map +1 -0
  71. package/dist/types/iam/subscription_tier.d.ts +3 -0
  72. package/dist/types/iam/subscription_tier.d.ts.map +1 -0
  73. package/dist/types/iam/subscription_tier.js +5 -0
  74. package/dist/types/iam/subscription_tier.js.map +1 -0
  75. package/dist/types/iam/user.d.ts +3 -42
  76. package/dist/types/iam/user.d.ts.map +1 -1
  77. package/dist/types/iam/user.js +0 -16
  78. package/dist/types/iam/user.js.map +1 -1
  79. package/dist/types/iam/user_role.d.ts +5 -0
  80. package/dist/types/iam/user_role.d.ts.map +1 -0
  81. package/dist/types/iam/user_role.js +16 -0
  82. package/dist/types/iam/user_role.js.map +1 -0
  83. package/dist/types/iam/user_status.d.ts +3 -0
  84. package/dist/types/iam/user_status.d.ts.map +1 -0
  85. package/dist/types/iam/user_status.js +10 -0
  86. package/dist/types/iam/user_status.js.map +1 -0
  87. package/dist/types/moderation/index.d.ts +4 -1
  88. package/dist/types/moderation/index.d.ts.map +1 -1
  89. package/dist/types/moderation/index.js +4 -1
  90. package/dist/types/moderation/index.js.map +1 -1
  91. package/dist/types/moderation/moderation.d.ts +5 -137
  92. package/dist/types/moderation/moderation.d.ts.map +1 -1
  93. package/dist/types/moderation/moderation.js +0 -37
  94. package/dist/types/moderation/moderation.js.map +1 -1
  95. package/dist/types/moderation/moderation_status.d.ts +3 -0
  96. package/dist/types/moderation/moderation_status.d.ts.map +1 -0
  97. package/dist/types/moderation/moderation_status.js +9 -0
  98. package/dist/types/moderation/moderation_status.js.map +1 -0
  99. package/dist/types/moderation/priority.d.ts +3 -0
  100. package/dist/types/moderation/priority.d.ts.map +1 -0
  101. package/dist/types/moderation/priority.js +5 -0
  102. package/dist/types/moderation/priority.js.map +1 -0
  103. package/dist/types/moderation/severity.d.ts +3 -0
  104. package/dist/types/moderation/severity.d.ts.map +1 -0
  105. package/dist/types/moderation/severity.js +5 -0
  106. package/dist/types/moderation/severity.js.map +1 -0
  107. package/dist/types/moderation/suggestion_category.d.ts +3 -0
  108. package/dist/types/moderation/suggestion_category.d.ts.map +1 -0
  109. package/dist/types/moderation/suggestion_category.js +11 -0
  110. package/dist/types/moderation/suggestion_category.js.map +1 -0
  111. package/dist/types/recipe/allergen.d.ts +3 -0
  112. package/dist/types/recipe/allergen.d.ts.map +1 -0
  113. package/dist/types/recipe/allergen.js +19 -0
  114. package/dist/types/recipe/allergen.js.map +1 -0
  115. package/dist/types/recipe/cuisine.d.ts +3 -0
  116. package/dist/types/recipe/cuisine.d.ts.map +1 -0
  117. package/dist/types/recipe/cuisine.js +39 -0
  118. package/dist/types/recipe/cuisine.js.map +1 -0
  119. package/dist/types/recipe/dietary_tag.d.ts +3 -0
  120. package/dist/types/recipe/dietary_tag.d.ts.map +1 -0
  121. package/dist/types/recipe/dietary_tag.js +21 -0
  122. package/dist/types/recipe/dietary_tag.js.map +1 -0
  123. package/dist/types/recipe/difficulty.d.ts +3 -0
  124. package/dist/types/recipe/difficulty.d.ts.map +1 -0
  125. package/dist/types/recipe/difficulty.js +10 -0
  126. package/dist/types/recipe/difficulty.js.map +1 -0
  127. package/dist/types/recipe/equipment.d.ts +0 -40
  128. package/dist/types/recipe/equipment.d.ts.map +1 -1
  129. package/dist/types/recipe/equipment.js +0 -12
  130. package/dist/types/recipe/equipment.js.map +1 -1
  131. package/dist/types/recipe/filters.d.ts +5 -30
  132. package/dist/types/recipe/filters.d.ts.map +1 -1
  133. package/dist/types/recipe/filters.js +0 -13
  134. package/dist/types/recipe/filters.js.map +1 -1
  135. package/dist/types/recipe/index.d.ts +10 -1
  136. package/dist/types/recipe/index.d.ts.map +1 -1
  137. package/dist/types/recipe/index.js +10 -1
  138. package/dist/types/recipe/index.js.map +1 -1
  139. package/dist/types/recipe/ingredient.d.ts +1 -169
  140. package/dist/types/recipe/ingredient.d.ts.map +1 -1
  141. package/dist/types/recipe/ingredient.js +0 -29
  142. package/dist/types/recipe/ingredient.js.map +1 -1
  143. package/dist/types/recipe/instruction.d.ts +2 -72
  144. package/dist/types/recipe/instruction.d.ts.map +1 -1
  145. package/dist/types/recipe/instruction.js +0 -13
  146. package/dist/types/recipe/instruction.js.map +1 -1
  147. package/dist/types/recipe/meal_type.d.ts +3 -0
  148. package/dist/types/recipe/meal_type.d.ts.map +1 -0
  149. package/dist/types/recipe/meal_type.js +14 -0
  150. package/dist/types/recipe/meal_type.js.map +1 -0
  151. package/dist/types/recipe/nutrition.d.ts +0 -36
  152. package/dist/types/recipe/nutrition.d.ts.map +1 -1
  153. package/dist/types/recipe/nutrition.js +0 -13
  154. package/dist/types/recipe/nutrition.js.map +1 -1
  155. package/dist/types/recipe/recipe.d.ts +14 -525
  156. package/dist/types/recipe/recipe.d.ts.map +1 -1
  157. package/dist/types/recipe/recipe.js +0 -80
  158. package/dist/types/recipe/recipe.js.map +1 -1
  159. package/dist/types/recipe/recipe_source.d.ts +3 -0
  160. package/dist/types/recipe/recipe_source.d.ts.map +1 -0
  161. package/dist/types/recipe/recipe_source.js +5 -0
  162. package/dist/types/recipe/recipe_source.js.map +1 -0
  163. package/dist/types/recipe/recipe_status.d.ts +3 -0
  164. package/dist/types/recipe/recipe_status.d.ts.map +1 -0
  165. package/dist/types/recipe/recipe_status.js +12 -0
  166. package/dist/types/recipe/recipe_status.js.map +1 -0
  167. package/dist/types/recipe/spiciness.d.ts +3 -0
  168. package/dist/types/recipe/spiciness.d.ts.map +1 -0
  169. package/dist/types/recipe/spiciness.js +5 -0
  170. package/dist/types/recipe/spiciness.js.map +1 -0
  171. package/dist/types/recipe/temperature.d.ts +1 -12
  172. package/dist/types/recipe/temperature.d.ts.map +1 -1
  173. package/dist/types/recipe/temperature.js +0 -7
  174. package/dist/types/recipe/temperature.js.map +1 -1
  175. package/dist/types/recipe/temperature_unit.d.ts +3 -0
  176. package/dist/types/recipe/temperature_unit.d.ts.map +1 -0
  177. package/dist/types/recipe/temperature_unit.js +5 -0
  178. package/dist/types/recipe/temperature_unit.js.map +1 -0
  179. package/dist/types/recipe/unit.d.ts +3 -0
  180. package/dist/types/recipe/unit.d.ts.map +1 -0
  181. package/dist/types/recipe/unit.js +51 -0
  182. package/dist/types/recipe/unit.js.map +1 -0
  183. package/dist/types/report/index.d.ts +4 -1
  184. package/dist/types/report/index.d.ts.map +1 -1
  185. package/dist/types/report/index.js +4 -1
  186. package/dist/types/report/index.js.map +1 -1
  187. package/dist/types/report/report.d.ts +5 -94
  188. package/dist/types/report/report.d.ts.map +1 -1
  189. package/dist/types/report/report.js +0 -29
  190. package/dist/types/report/report.js.map +1 -1
  191. package/dist/types/report/report_priority.d.ts +3 -0
  192. package/dist/types/report/report_priority.d.ts.map +1 -0
  193. package/dist/types/report/report_priority.js +10 -0
  194. package/dist/types/report/report_priority.js.map +1 -0
  195. package/dist/types/report/report_status.d.ts +3 -0
  196. package/dist/types/report/report_status.d.ts.map +1 -0
  197. package/dist/types/report/report_status.js +10 -0
  198. package/dist/types/report/report_status.js.map +1 -0
  199. package/dist/types/report/report_target_type.d.ts +3 -0
  200. package/dist/types/report/report_target_type.d.ts.map +1 -0
  201. package/dist/types/report/report_target_type.js +10 -0
  202. package/dist/types/report/report_target_type.js.map +1 -0
  203. package/dist/types/report/report_type.d.ts +3 -0
  204. package/dist/types/report/report_type.d.ts.map +1 -0
  205. package/dist/types/report/report_type.js +12 -0
  206. package/dist/types/report/report_type.js.map +1 -0
  207. package/package.json +3 -14
  208. package/src/index.ts +0 -1
  209. package/src/types/ai/recipe.ts +10 -47
  210. package/src/types/ai/translation.ts +1 -18
  211. package/src/types/core/api.ts +4 -4
  212. package/src/types/core/asset.ts +2 -14
  213. package/src/types/core/entity.ts +7 -0
  214. package/src/types/core/index.ts +5 -1
  215. package/src/types/core/{enums/locale.ts → locale.ts} +0 -3
  216. package/src/types/core/{enums/measurement_system.ts → measurement_system.ts} +0 -3
  217. package/src/types/core/settings.ts +9 -43
  218. package/src/types/core/{enums/theme.ts → theme.ts} +0 -3
  219. package/src/types/core/timestamp.ts +4 -0
  220. package/src/types/iam/index.ts +6 -1
  221. package/src/types/iam/profile.ts +2 -24
  222. package/src/types/iam/{enums/profile_status.ts → profile_status.ts} +0 -3
  223. package/src/types/iam/subscription.ts +4 -28
  224. package/src/types/iam/{enums/subscription_role.ts → subscription_role.ts} +0 -3
  225. package/src/types/iam/{enums/subscription_status.ts → subscription_status.ts} +0 -3
  226. package/src/types/iam/subscription_tier.ts +2 -0
  227. package/src/types/iam/user.ts +3 -22
  228. package/src/types/iam/user_role.ts +15 -0
  229. package/src/types/iam/{enums/user_status.ts → user_status.ts} +0 -3
  230. package/src/types/moderation/index.ts +4 -1
  231. package/src/types/moderation/moderation.ts +5 -50
  232. package/src/types/moderation/{enums/moderation_status.ts → moderation_status.ts} +0 -3
  233. package/src/types/moderation/{enums/priority.ts → priority.ts} +0 -3
  234. package/src/types/moderation/{enums/severity.ts → severity.ts} +0 -3
  235. package/src/types/moderation/suggestion_category.ts +8 -0
  236. package/src/types/recipe/{enums/allergen.ts → allergen.ts} +0 -3
  237. package/src/types/recipe/{enums/cuisine.ts → cuisine.ts} +0 -3
  238. package/src/types/recipe/{enums/dietary_tag.ts → dietary_tag.ts} +0 -3
  239. package/src/types/recipe/{enums/difficulty.ts → difficulty.ts} +0 -3
  240. package/src/types/recipe/equipment.ts +0 -18
  241. package/src/types/recipe/filters.ts +5 -24
  242. package/src/types/recipe/index.ts +10 -1
  243. package/src/types/recipe/ingredient.ts +1 -37
  244. package/src/types/recipe/instruction.ts +2 -19
  245. package/src/types/recipe/{enums/meal_type.ts → meal_type.ts} +0 -3
  246. package/src/types/recipe/nutrition.ts +0 -18
  247. package/src/types/recipe/recipe.ts +18 -118
  248. package/src/types/recipe/{enums/recipe_source.ts → recipe_source.ts} +0 -3
  249. package/src/types/recipe/{enums/recipe_status.ts → recipe_status.ts} +0 -3
  250. package/src/types/recipe/{enums/spiciness.ts → spiciness.ts} +0 -3
  251. package/src/types/recipe/temperature.ts +1 -7
  252. package/src/types/recipe/{enums/temperature_unit.ts → temperature_unit.ts} +0 -3
  253. package/src/types/recipe/{enums/unit.ts → unit.ts} +0 -3
  254. package/src/types/report/index.ts +4 -1
  255. package/src/types/report/report.ts +5 -40
  256. package/src/types/report/{enums/report_priority.ts → report_priority.ts} +0 -3
  257. package/src/types/report/{enums/report_status.ts → report_status.ts} +0 -3
  258. package/src/types/report/{enums/report_target_type.ts → report_target_type.ts} +0 -3
  259. package/src/types/report/{enums/report_type.ts → report_type.ts} +0 -3
  260. package/src/lib/ai/cost.ts +0 -82
  261. package/src/lib/ai/embedding.ts +0 -49
  262. package/src/lib/ai/errors.ts +0 -43
  263. package/src/lib/ai/flow.ts +0 -134
  264. package/src/lib/ai/genkit.ts +0 -39
  265. package/src/lib/ai/image.ts +0 -27
  266. package/src/lib/ai/index.ts +0 -6
  267. package/src/lib/api.ts +0 -103
  268. package/src/lib/firebase.ts +0 -5
  269. package/src/lib/iam.ts +0 -37
  270. package/src/lib/index.ts +0 -7
  271. package/src/lib/storage.ts +0 -60
  272. package/src/lib/usage/index.ts +0 -1
  273. package/src/lib/usage/usage.service.ts +0 -192
  274. package/src/lib/utils/index.ts +0 -2
  275. package/src/lib/utils/sanitize.ts +0 -38
  276. package/src/lib/utils/slug.ts +0 -33
  277. package/src/types/core/enums/image_type.ts +0 -5
  278. package/src/types/core/enums/index.ts +0 -5
  279. package/src/types/core/enums/url_type.ts +0 -13
  280. package/src/types/iam/enums/index.ts +0 -6
  281. package/src/types/iam/enums/subscription_tier.ts +0 -4
  282. package/src/types/iam/enums/user_role.ts +0 -11
  283. package/src/types/moderation/enums/index.ts +0 -4
  284. package/src/types/moderation/enums/suggestion_category.ts +0 -11
  285. package/src/types/recipe/enums/index.ts +0 -10
  286. package/src/types/report/enums/index.ts +0 -4
@@ -1,16 +1,8 @@
1
- import { z } from "genkit";
2
- import {
3
- CuisineSchema,
4
- DietaryTagSchema,
5
- DifficultySchema,
6
- MealTypeSchema,
7
- SpicinessSchema,
8
- type Cuisine,
9
- type DietaryTag,
10
- type Difficulty,
11
- type MealType,
12
- type Spiciness,
13
- } from "./enums";
1
+ import { Cuisine } from "./cuisine";
2
+ import { DietaryTag } from "./dietary_tag";
3
+ import { Difficulty } from "./difficulty";
4
+ import { MealType } from "./meal_type";
5
+ import { Spiciness } from "./spiciness";
14
6
 
15
7
  export interface RecipeFilters {
16
8
  cuisines?: Cuisine[];
@@ -22,14 +14,3 @@ export interface RecipeFilters {
22
14
  spiciness?: Spiciness;
23
15
  timeLimit?: number;
24
16
  }
25
-
26
- export const RecipeFiltersSchema = z.object({
27
- cuisines: z.array(CuisineSchema).optional(),
28
- dietaryTags: z.array(DietaryTagSchema).optional(),
29
- difficulty: DifficultySchema.optional(),
30
- excludeIngredients: z.array(z.string()).optional(),
31
- includeIngredients: z.array(z.string()).optional(),
32
- mealTypes: z.array(MealTypeSchema).optional(),
33
- spiciness: SpicinessSchema.optional(),
34
- timeLimit: z.number().int().min(5).max(300).optional(),
35
- }) satisfies z.ZodType<RecipeFilters>;
@@ -1,8 +1,17 @@
1
- export * from "./enums";
1
+ export * from "./allergen";
2
+ export * from "./cuisine";
3
+ export * from "./dietary_tag";
4
+ export * from "./difficulty";
2
5
  export * from "./equipment";
3
6
  export * from "./filters";
4
7
  export * from "./ingredient";
5
8
  export * from "./instruction";
9
+ export * from "./meal_type";
6
10
  export * from "./nutrition";
11
+ export * from "./recipe_source";
12
+ export * from "./recipe_status";
7
13
  export * from "./recipe";
14
+ export * from "./spiciness";
15
+ export * from "./temperature_unit";
8
16
  export * from "./temperature";
17
+ export * from "./unit";
@@ -1,5 +1,4 @@
1
- import { z } from "genkit";
2
- import { UnitSchema, type Unit } from "./enums";
1
+ import { Unit } from "./unit";
3
2
 
4
3
  export interface IngredientMeta {
5
4
  quantity?: number;
@@ -8,62 +7,27 @@ export interface IngredientMeta {
8
7
  unit?: Unit;
9
8
  }
10
9
 
11
- export const IngredientMetaSchema = z.object({
12
- quantity: z.number().optional(),
13
- required: z.boolean().optional(),
14
- slug: z.string(),
15
- unit: UnitSchema.optional(),
16
- }) satisfies z.ZodType<IngredientMeta>;
17
-
18
10
  export interface IngredientContent {
19
11
  name: string;
20
12
  notes?: string;
21
13
  slug: string;
22
14
  }
23
15
 
24
- export const IngredientContentSchema = z.object({
25
- name: z.string(),
26
- notes: z.string().optional(),
27
- slug: z.string(),
28
- }) satisfies z.ZodType<IngredientContent>;
29
-
30
16
  export interface Ingredient extends IngredientMeta, IngredientContent {}
31
17
 
32
- export const IngredientSchema = z.object({
33
- ...IngredientMetaSchema.shape,
34
- ...IngredientContentSchema.shape,
35
- }) satisfies z.ZodType<Ingredient>;
36
-
37
18
  export interface IngredientSectionMeta {
38
19
  ingredients: IngredientMeta[];
39
20
  slug: string;
40
21
  }
41
22
 
42
- export const IngredientSectionMetaSchema = z.object({
43
- ingredients: z.array(IngredientMetaSchema),
44
- slug: z.string(),
45
- }) satisfies z.ZodType<IngredientSectionMeta>;
46
-
47
23
  export interface IngredientSectionContent {
48
24
  ingredients: IngredientContent[];
49
25
  slug: string;
50
26
  title?: string;
51
27
  }
52
28
 
53
- export const IngredientSectionContentSchema = z.object({
54
- ingredients: z.array(IngredientContentSchema),
55
- slug: z.string(),
56
- title: z.string().optional(),
57
- }) satisfies z.ZodType<IngredientSectionContent>;
58
-
59
29
  export interface IngredientSection {
60
30
  ingredients: Ingredient[];
61
31
  slug: string;
62
32
  title?: string;
63
33
  }
64
-
65
- export const IngredientSectionSchema = z.object({
66
- ingredients: z.array(IngredientSchema),
67
- slug: z.string(),
68
- title: z.string().optional(),
69
- }) satisfies z.ZodType<IngredientSection>;
@@ -1,31 +1,14 @@
1
- import { z } from "genkit";
2
- import { TemperatureSchema, type Temperature } from "./temperature";
1
+ import { TemperatureUnit } from "./temperature_unit";
3
2
 
4
3
  export interface InstructionMeta {
5
4
  duration?: number;
6
5
  step: number;
7
- temperature?: Temperature;
6
+ temperature?: TemperatureUnit;
8
7
  }
9
8
 
10
- export const InstructionMetaSchema = z.object({
11
- duration: z.number().optional(),
12
- step: z.number(),
13
- temperature: TemperatureSchema.optional(),
14
- }) satisfies z.ZodType<InstructionMeta>;
15
-
16
9
  export interface InstructionContent {
17
10
  step: number;
18
11
  text: string;
19
12
  }
20
13
 
21
- export const InstructionContentSchema = z.object({
22
- step: z.number(),
23
- text: z.string(),
24
- }) satisfies z.ZodType<InstructionContent>;
25
-
26
14
  export interface Instruction extends InstructionMeta, InstructionContent {}
27
-
28
- export const InstructionSchema = z.object({
29
- ...InstructionMetaSchema.shape,
30
- ...InstructionContentSchema.shape,
31
- }) satisfies z.ZodType<Instruction>;
@@ -1,5 +1,3 @@
1
- import { z } from "genkit";
2
-
3
1
  export const MEAL_TYPE_VALUES = [
4
2
  "appetizer",
5
3
  "breakfast",
@@ -10,5 +8,4 @@ export const MEAL_TYPE_VALUES = [
10
8
  "lunch",
11
9
  "snack",
12
10
  ] as const;
13
- export const MealTypeSchema = z.enum(MEAL_TYPE_VALUES);
14
11
  export type MealType = (typeof MEAL_TYPE_VALUES)[number];
@@ -1,9 +1,3 @@
1
- import { z } from "genkit";
2
-
3
- /**
4
- * Nutrition data per serving.
5
- * Units: calories (kcal), fat/carbs/protein/fiber/sugar (g), cholesterol/sodium (mg)
6
- */
7
1
  export interface Nutrition {
8
2
  calories: number;
9
3
  carbs?: number;
@@ -15,15 +9,3 @@ export interface Nutrition {
15
9
  sodium?: number;
16
10
  sugar?: number;
17
11
  }
18
-
19
- export const NutritionSchema = z.object({
20
- calories: z.number(),
21
- carbs: z.number().optional(),
22
- cholesterol: z.number().optional(),
23
- fat: z.number().optional(),
24
- fiber: z.number().optional(),
25
- protein: z.number().optional(),
26
- saturatedFat: z.number().optional(),
27
- sodium: z.number().optional(),
28
- sugar: z.number().optional(),
29
- }) satisfies z.ZodType<Nutrition>;
@@ -1,49 +1,25 @@
1
- import { z } from "genkit";
2
- import type { Timestamp } from "firebase-admin/firestore";
3
- import { LocaleSchema, type Locale } from "../core";
1
+ import { Timestamp } from "../core";
2
+ import { Locale } from "../core/locale";
3
+ import { Allergen } from "./allergen";
4
+ import { Cuisine } from "./cuisine";
5
+ import { DietaryTag } from "./dietary_tag";
6
+ import { Difficulty } from "./difficulty";
7
+ import { Equipment, EquipmentContent, EquipmentMeta } from "./equipment";
4
8
  import {
5
- AllergenSchema,
6
- CuisineSchema,
7
- DietaryTagSchema,
8
- DifficultySchema,
9
- MealTypeSchema,
10
- RecipeSourceSchema,
11
- RecipeStatusSchema,
12
- SpicinessSchema,
13
- type Allergen,
14
- type Cuisine,
15
- type DietaryTag,
16
- type Difficulty,
17
- type MealType,
18
- type RecipeSource,
19
- type RecipeStatus,
20
- type Spiciness,
21
- } from "./enums";
22
- import {
23
- EquipmentContentSchema,
24
- EquipmentMetaSchema,
25
- EquipmentSchema,
26
- type Equipment,
27
- type EquipmentContent,
28
- type EquipmentMeta,
29
- } from "./equipment";
30
- import {
31
- IngredientSectionContentSchema,
32
- IngredientSectionMetaSchema,
33
- IngredientSectionSchema,
34
- type IngredientSection,
35
- type IngredientSectionContent,
36
- type IngredientSectionMeta,
9
+ IngredientSection,
10
+ IngredientSectionContent,
11
+ IngredientSectionMeta,
37
12
  } from "./ingredient";
38
13
  import {
39
- InstructionContentSchema,
40
- InstructionMetaSchema,
41
- InstructionSchema,
42
- type Instruction,
43
- type InstructionContent,
44
- type InstructionMeta,
14
+ Instruction,
15
+ InstructionContent,
16
+ InstructionMeta,
45
17
  } from "./instruction";
46
- import { NutritionSchema, type Nutrition } from "./nutrition";
18
+ import { MealType } from "./meal_type";
19
+ import { Nutrition } from "./nutrition";
20
+ import { RecipeSource } from "./recipe_source";
21
+ import { RecipeStatus } from "./recipe_status";
22
+ import { Spiciness } from "./spiciness";
47
23
 
48
24
  export interface RecipeMeta {
49
25
  allergens: Allergen[];
@@ -71,32 +47,6 @@ export interface RecipeMeta {
71
47
  updatedAt: Timestamp;
72
48
  }
73
49
 
74
- export const RecipeMetaSchema = z.object({
75
- allergens: z.array(AllergenSchema),
76
- confidence: z.number().min(0).max(1),
77
- createdAt: z.custom<Timestamp>(),
78
- createdBy: z.string(),
79
- cuisine: CuisineSchema,
80
- deletedAt: z.custom<Timestamp>().optional(),
81
- dietaryTags: z.array(DietaryTagSchema),
82
- difficulty: DifficultySchema,
83
- equipment: z.array(EquipmentMetaSchema).max(30).optional(),
84
- id: z.string(),
85
- imageUrl: z.string().optional(),
86
- ingredientSections: z.array(IngredientSectionMetaSchema).min(1).max(20),
87
- instructions: z.array(InstructionMetaSchema).min(1).max(100),
88
- mealTypes: z.array(MealTypeSchema).min(1),
89
- nutrition: NutritionSchema.optional(),
90
- originalLocale: LocaleSchema,
91
- servings: z.number().int().min(1).max(100),
92
- source: RecipeSourceSchema,
93
- sourceUrl: z.string().optional(),
94
- spiciness: SpicinessSchema,
95
- status: RecipeStatusSchema,
96
- time: z.number().int().min(1).max(1440),
97
- updatedAt: z.custom<Timestamp>(),
98
- });
99
-
100
50
  export interface RecipeContent {
101
51
  description: string;
102
52
  equipment?: EquipmentContent[];
@@ -107,16 +57,6 @@ export interface RecipeContent {
107
57
  title: string;
108
58
  }
109
59
 
110
- export const RecipeContentSchema = z.object({
111
- description: z.string().min(10).max(2000),
112
- equipment: z.array(EquipmentContentSchema).optional(),
113
- ingredientSections: z.array(IngredientSectionContentSchema).min(1).max(20),
114
- instructions: z.array(InstructionContentSchema).min(1).max(100),
115
- locale: LocaleSchema,
116
- tips: z.array(z.string().max(500)).max(20).optional(),
117
- title: z.string().min(3).max(200),
118
- }) satisfies z.ZodType<RecipeContent>;
119
-
120
60
  export interface Recipe {
121
61
  allergens: Allergen[];
122
62
  confidence: number;
@@ -147,36 +87,6 @@ export interface Recipe {
147
87
  updatedAt: Timestamp;
148
88
  }
149
89
 
150
- export const RecipeSchema = z.object({
151
- allergens: z.array(AllergenSchema),
152
- confidence: z.number().min(0).max(1),
153
- createdAt: z.custom<Timestamp>(),
154
- createdBy: z.string(),
155
- cuisine: CuisineSchema,
156
- deletedAt: z.custom<Timestamp>().optional(),
157
- description: z.string().min(10).max(2000),
158
- dietaryTags: z.array(DietaryTagSchema),
159
- difficulty: DifficultySchema,
160
- equipment: z.array(EquipmentSchema).optional(),
161
- id: z.string(),
162
- imageUrl: z.string().optional(),
163
- ingredientSections: z.array(IngredientSectionSchema).min(1),
164
- instructions: z.array(InstructionSchema).min(1),
165
- locale: LocaleSchema,
166
- mealTypes: z.array(MealTypeSchema).min(1),
167
- nutrition: NutritionSchema.optional(),
168
- originalLocale: LocaleSchema,
169
- servings: z.number().int().min(1).max(100),
170
- source: RecipeSourceSchema,
171
- sourceUrl: z.string().optional(),
172
- spiciness: SpicinessSchema,
173
- status: RecipeStatusSchema,
174
- time: z.number().int().min(1).max(1440),
175
- tips: z.array(z.string().max(500)).optional(),
176
- title: z.string().min(3).max(200),
177
- updatedAt: z.custom<Timestamp>(),
178
- });
179
-
180
90
  export interface RecipeStats {
181
91
  comments: number;
182
92
  likes: number;
@@ -186,13 +96,3 @@ export interface RecipeStats {
186
96
  updatedAt: number;
187
97
  views: number;
188
98
  }
189
-
190
- export const RecipeStatsSchema = z.object({
191
- comments: z.number().int().nonnegative(),
192
- likes: z.number().int().nonnegative(),
193
- rating: z.number().min(0).max(5),
194
- ratingCount: z.number().int().nonnegative(),
195
- saves: z.number().int().nonnegative(),
196
- updatedAt: z.number().int(),
197
- views: z.number().int().nonnegative(),
198
- }) satisfies z.ZodType<RecipeStats>;
@@ -1,5 +1,2 @@
1
- import { z } from "genkit";
2
-
3
1
  export const RECIPE_SOURCE_VALUES = ["image", "text", "url"] as const;
4
- export const RecipeSourceSchema = z.enum(RECIPE_SOURCE_VALUES);
5
2
  export type RecipeSource = (typeof RECIPE_SOURCE_VALUES)[number];
@@ -1,5 +1,3 @@
1
- import { z } from "genkit";
2
-
3
1
  export const RECIPE_STATUS_VALUES = [
4
2
  "active",
5
3
  "archived",
@@ -8,5 +6,4 @@ export const RECIPE_STATUS_VALUES = [
8
6
  "pending",
9
7
  "rejected",
10
8
  ] as const;
11
- export const RecipeStatusSchema = z.enum(RECIPE_STATUS_VALUES);
12
9
  export type RecipeStatus = (typeof RECIPE_STATUS_VALUES)[number];
@@ -1,5 +1,2 @@
1
- import { z } from "genkit";
2
-
3
1
  export const SPICINESS_VALUES = ["none", "mild", "medium", "hot"] as const;
4
- export const SpicinessSchema = z.enum(SPICINESS_VALUES);
5
2
  export type Spiciness = (typeof SPICINESS_VALUES)[number];
@@ -1,12 +1,6 @@
1
- import { z } from "genkit";
2
- import { TemperatureUnitSchema, type TemperatureUnit } from "./enums";
1
+ import { TemperatureUnit } from "./temperature_unit";
3
2
 
4
3
  export interface Temperature {
5
4
  unit: TemperatureUnit;
6
5
  value: number;
7
6
  }
8
-
9
- export const TemperatureSchema = z.object({
10
- unit: TemperatureUnitSchema,
11
- value: z.number().min(-50).max(1000),
12
- }) satisfies z.ZodType<Temperature>;
@@ -1,5 +1,2 @@
1
- import { z } from "genkit";
2
-
3
1
  export const TEMPERATURE_UNIT_VALUES = ["celsius", "fahrenheit"] as const;
4
- export const TemperatureUnitSchema = z.enum(TEMPERATURE_UNIT_VALUES);
5
2
  export type TemperatureUnit = (typeof TEMPERATURE_UNIT_VALUES)[number];
@@ -1,5 +1,3 @@
1
- import { z } from "genkit";
2
-
3
1
  export const UNIT_VALUES = [
4
2
  // Volume (metric)
5
3
  "ml",
@@ -47,5 +45,4 @@ export const UNIT_VALUES = [
47
45
  "dash",
48
46
  "drop",
49
47
  ] as const;
50
- export const UnitSchema = z.enum(UNIT_VALUES);
51
48
  export type Unit = (typeof UNIT_VALUES)[number];
@@ -1,2 +1,5 @@
1
- export * from "./enums";
1
+ export * from "./report_priority";
2
+ export * from "./report_status";
3
+ export * from "./report_target_type";
4
+ export * from "./report_type";
2
5
  export * from "./report";
@@ -1,15 +1,8 @@
1
- import { z } from "genkit";
2
- import type { Timestamp } from "firebase-admin/firestore";
3
- import {
4
- ReportPrioritySchema,
5
- ReportStatusSchema,
6
- ReportTargetTypeSchema,
7
- ReportTypeSchema,
8
- type ReportPriority,
9
- type ReportStatus,
10
- type ReportTargetType,
11
- type ReportType,
12
- } from "./enums";
1
+ import { Timestamp } from "../core";
2
+ import { ReportPriority } from "./report_priority";
3
+ import { ReportStatus } from "./report_status";
4
+ import { ReportTargetType } from "./report_target_type";
5
+ import { ReportType } from "./report_type";
13
6
 
14
7
  export interface ReportEvidence {
15
8
  aiScore?: number;
@@ -18,13 +11,6 @@ export interface ReportEvidence {
18
11
  imageHashes?: string[];
19
12
  }
20
13
 
21
- export const ReportEvidenceSchema = z.object({
22
- aiScore: z.number().min(0).max(1).optional(),
23
- aiSuggestions: z.array(z.record(z.string(), z.unknown())).optional(),
24
- contentSnapshot: z.string().optional(),
25
- imageHashes: z.array(z.string()).optional(),
26
- }) satisfies z.ZodType<ReportEvidence>;
27
-
28
14
  export interface Report {
29
15
  categories: string[];
30
16
  createdAt: Timestamp;
@@ -45,24 +31,3 @@ export interface Report {
45
31
  updatedAt: Timestamp;
46
32
  userId: string;
47
33
  }
48
-
49
- export const ReportSchema = z.object({
50
- categories: z.array(z.string()),
51
- createdAt: z.custom<Timestamp>(),
52
- description: z.string(),
53
- evidence: ReportEvidenceSchema.optional(),
54
- id: z.string(),
55
- notes: z.string().optional(),
56
- priority: ReportPrioritySchema,
57
- reason: z.string(),
58
- reportedBy: z.string().optional(),
59
- resolution: z.string().optional(),
60
- reviewedAt: z.custom<Timestamp>().optional(),
61
- reviewedBy: z.string().optional(),
62
- status: ReportStatusSchema,
63
- targetId: z.string(),
64
- targetType: ReportTargetTypeSchema,
65
- type: ReportTypeSchema,
66
- updatedAt: z.custom<Timestamp>(),
67
- userId: z.string(),
68
- });
@@ -1,10 +1,7 @@
1
- import { z } from "genkit";
2
-
3
1
  export const REPORT_PRIORITY_VALUES = [
4
2
  "critical",
5
3
  "high",
6
4
  "low",
7
5
  "medium",
8
6
  ] as const;
9
- export const ReportPrioritySchema = z.enum(REPORT_PRIORITY_VALUES);
10
7
  export type ReportPriority = (typeof REPORT_PRIORITY_VALUES)[number];
@@ -1,10 +1,7 @@
1
- import { z } from "genkit";
2
-
3
1
  export const REPORT_STATUS_VALUES = [
4
2
  "escalated",
5
3
  "pending",
6
4
  "resolved",
7
5
  "reviewed",
8
6
  ] as const;
9
- export const ReportStatusSchema = z.enum(REPORT_STATUS_VALUES);
10
7
  export type ReportStatus = (typeof REPORT_STATUS_VALUES)[number];
@@ -1,10 +1,7 @@
1
- import { z } from "genkit";
2
-
3
1
  export const REPORT_TARGET_TYPE_VALUES = [
4
2
  "image",
5
3
  "profile",
6
4
  "recipe",
7
5
  "user",
8
6
  ] as const;
9
- export const ReportTargetTypeSchema = z.enum(REPORT_TARGET_TYPE_VALUES);
10
7
  export type ReportTargetType = (typeof REPORT_TARGET_TYPE_VALUES)[number];
@@ -1,5 +1,3 @@
1
- import { z } from "genkit";
2
-
3
1
  export const REPORT_TYPE_VALUES = [
4
2
  "auto_rejected",
5
3
  "manual_rejected",
@@ -8,5 +6,4 @@ export const REPORT_TYPE_VALUES = [
8
6
  "unsafe_upload",
9
7
  "user_report",
10
8
  ] as const;
11
- export const ReportTypeSchema = z.enum(REPORT_TYPE_VALUES);
12
9
  export type ReportType = (typeof REPORT_TYPE_VALUES)[number];
@@ -1,82 +0,0 @@
1
- import { getDatabase, ServerValue } from "firebase-admin/database";
2
- import { AIModelConfig } from "../../types";
3
-
4
- interface BaseUsage {
5
- flowName: string;
6
- model: AIModelConfig;
7
- }
8
-
9
- interface MultimodalUsage extends BaseUsage {
10
- type: "multimodal";
11
- inputTokens: number;
12
- outputTokens: number;
13
- }
14
-
15
- interface ImageUsage extends BaseUsage {
16
- type: "image";
17
- imageCount: number;
18
- }
19
-
20
- interface EmbeddingUsage extends BaseUsage {
21
- type: "embedding";
22
- tokenCount: number;
23
- }
24
-
25
- export type AIUsage = MultimodalUsage | ImageUsage | EmbeddingUsage;
26
-
27
- export const logAIUsage = (usage: AIUsage): number => {
28
- const { flowName, model } = usage;
29
-
30
- let cost: number;
31
- let metrics: Record<string, number>;
32
-
33
- switch (usage.type) {
34
- case "multimodal":
35
- cost =
36
- (usage.inputTokens / 1_000_000) * model.cost.input +
37
- (usage.outputTokens / 1_000_000) * model.cost.output;
38
- metrics = {
39
- inputTokens: usage.inputTokens,
40
- outputTokens: usage.outputTokens,
41
- };
42
- break;
43
- case "image":
44
- cost = usage.imageCount * model.cost.output;
45
- metrics = { images: usage.imageCount };
46
- break;
47
- case "embedding":
48
- cost = (usage.tokenCount / 1_000) * model.cost.input;
49
- metrics = { tokens: usage.tokenCount };
50
- break;
51
- }
52
-
53
- const db = getDatabase();
54
- const date = new Date().toISOString().split("T")[0];
55
- const base = `ai_usage/live/${date}`;
56
-
57
- const updates: Record<string, unknown> = {
58
- [`${base}/total`]: ServerValue.increment(cost),
59
- [`${base}/count`]: ServerValue.increment(1),
60
- [`${base}/flows/${flowName}/cost`]: ServerValue.increment(cost),
61
- [`${base}/flows/${flowName}/count`]: ServerValue.increment(1),
62
- [`${base}/models/${model.alias}/cost`]: ServerValue.increment(cost),
63
- };
64
-
65
- for (const [key, value] of Object.entries(metrics)) {
66
- updates[`${base}/models/${model.alias}/${key}`] =
67
- ServerValue.increment(value);
68
- }
69
-
70
- db.ref()
71
- .update(updates)
72
- .catch((error) => {
73
- console.error("[AI Usage] Failed to log usage:", {
74
- flowName,
75
- model: model.id,
76
- cost,
77
- error: error instanceof Error ? error.message : String(error),
78
- });
79
- });
80
-
81
- return cost;
82
- };
@@ -1,49 +0,0 @@
1
- import { FieldValue } from "firebase-admin/firestore";
2
- import { firestore } from "../firebase";
3
- import { ai, geminiEmbedding001, recipesRetriever } from "./genkit";
4
- import { logAIUsage } from "./cost";
5
- import { AI_MODELS } from "../../config/ai";
6
- import { ValidationError } from "../../types";
7
-
8
- // Re-export retriever from genkit for convenience
9
- export { recipesRetriever };
10
-
11
- export const generateEmbedding = async (text: string, flowName: string) => {
12
- if (text.length < 1 || text.length > 7500) {
13
- throw new ValidationError("Text must be between 1 and 7500 characters", {
14
- length: text.length,
15
- minLength: 1,
16
- maxLength: 7500,
17
- });
18
- }
19
- const response = await ai.embed({
20
- embedder: geminiEmbedding001,
21
- content: text,
22
- });
23
- logAIUsage({
24
- type: "embedding",
25
- flowName,
26
- model: AI_MODELS.GeminiEmbedding001,
27
- tokenCount: text.length,
28
- });
29
- return response[0]?.embedding;
30
- };
31
-
32
- export const storeEmbedding = async (
33
- collection: string,
34
- docId: string,
35
- text: string,
36
- flowName?: string,
37
- vectorField: string = "embedding",
38
- ) => {
39
- const embedding = await generateEmbedding(
40
- text,
41
- flowName || `${collection}:embedding`,
42
- );
43
- await firestore
44
- .collection(collection)
45
- .doc(docId)
46
- .update({
47
- [vectorField]: FieldValue.vector(embedding),
48
- });
49
- };