@cravery/core 0.0.22 → 0.0.24
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.
- package/dist/lib/ai/flow.d.ts +3 -23
- package/dist/lib/ai/flow.d.ts.map +1 -1
- package/dist/lib/ai/flow.js +74 -37
- package/dist/lib/ai/flow.js.map +1 -1
- package/dist/types/ai/recipe.d.ts.map +1 -1
- package/dist/types/ai/recipe.js +17 -10
- package/dist/types/ai/recipe.js.map +1 -1
- package/dist/types/recipe/equipment.d.ts.map +1 -1
- package/dist/types/recipe/equipment.js +4 -5
- package/dist/types/recipe/equipment.js.map +1 -1
- package/dist/types/recipe/ingredient.d.ts.map +1 -1
- package/dist/types/recipe/ingredient.js +13 -14
- package/dist/types/recipe/ingredient.js.map +1 -1
- package/dist/types/recipe/instruction.js +4 -4
- package/dist/types/recipe/instruction.js.map +1 -1
- package/dist/types/recipe/nutrition.js +9 -9
- package/dist/types/recipe/nutrition.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/ai/flow.ts +94 -49
- package/src/types/ai/recipe.ts +17 -10
- package/src/types/recipe/equipment.ts +4 -5
- package/src/types/recipe/ingredient.ts +13 -14
- package/src/types/recipe/instruction.ts +4 -4
- package/src/types/recipe/nutrition.ts +9 -9
package/dist/lib/ai/flow.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "genkit";
|
|
2
|
+
import { ai } from "./genkit";
|
|
2
3
|
import { AIModelConfig } from "../../types";
|
|
3
4
|
export declare const ImagenOutputSchema: z.ZodObject<{
|
|
4
5
|
images: z.ZodArray<z.ZodObject<{
|
|
@@ -27,27 +28,6 @@ export type ImageFlowHandler<T> = (input: T, prompt: string) => Promise<{
|
|
|
27
28
|
base64Data: string;
|
|
28
29
|
storagePath: string;
|
|
29
30
|
}[]>;
|
|
30
|
-
export declare const createGeminiFlow: <T, R>(name: string, inputSchema: z.ZodSchema<T>, outputSchema: z.ZodSchema<R>, handler: FlowHandler<T, R>, model?: AIModelConfig) =>
|
|
31
|
-
export declare const createImagenFlow: <T>(name: string, inputSchema: z.ZodSchema<T>, handler: ImageFlowHandler<T>, model?: AIModelConfig) =>
|
|
32
|
-
images: z.ZodArray<z.ZodObject<{
|
|
33
|
-
url: z.ZodString;
|
|
34
|
-
path: z.ZodString;
|
|
35
|
-
}, "strip", z.ZodTypeAny, {
|
|
36
|
-
url: string;
|
|
37
|
-
path: string;
|
|
38
|
-
}, {
|
|
39
|
-
url: string;
|
|
40
|
-
path: string;
|
|
41
|
-
}>, "many">;
|
|
42
|
-
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
images: {
|
|
44
|
-
url: string;
|
|
45
|
-
path: string;
|
|
46
|
-
}[];
|
|
47
|
-
}, {
|
|
48
|
-
images: {
|
|
49
|
-
url: string;
|
|
50
|
-
path: string;
|
|
51
|
-
}[];
|
|
52
|
-
}>, z.ZodTypeAny>;
|
|
31
|
+
export declare const createGeminiFlow: <T, R>(name: string, inputSchema: z.ZodSchema<T>, outputSchema: z.ZodSchema<R>, handler: FlowHandler<T, R>, model?: AIModelConfig) => ReturnType<typeof ai.defineFlow>;
|
|
32
|
+
export declare const createImagenFlow: <T>(name: string, inputSchema: z.ZodSchema<T>, handler: ImageFlowHandler<T>, model?: AIModelConfig) => ReturnType<typeof ai.defineFlow>;
|
|
53
33
|
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;EAO7B,CAAC;AAEH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3E,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAChC,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,MAAM,KACX,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAAC;AAE5D,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAE,CAAC,EACnC,MAAM,MAAM,EACZ,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC3B,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC5B,SAAS,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,QAAO,aAAuC,KAmDxC,UAAU,CAAC,OAAO,EAAE,CAAC,UAAU,CACtC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAChC,MAAM,MAAM,EACZ,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC3B,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAC5B,QAAO,aAAqC,KA+CtC,UAAU,CAAC,OAAO,EAAE,CAAC,UAAU,CACtC,CAAC"}
|
package/dist/lib/ai/flow.js
CHANGED
|
@@ -13,47 +13,84 @@ exports.ImagenOutputSchema = genkit_1.z.object({
|
|
|
13
13
|
})),
|
|
14
14
|
});
|
|
15
15
|
const createGeminiFlow = (name, inputSchema, outputSchema, handler, model = ai_1.AI_MODELS.Gemini25Flash) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
// Lazy initialization - don't access ai until the flow is actually called
|
|
17
|
+
let initialized = false;
|
|
18
|
+
let FlowInputSchema;
|
|
19
|
+
let FlowOutputSchema;
|
|
20
|
+
let prompt;
|
|
21
|
+
let flow;
|
|
22
|
+
const initializeFlow = () => {
|
|
23
|
+
if (!initialized) {
|
|
24
|
+
if (!genkit_2.ai) {
|
|
25
|
+
throw new Error("Genkit AI not initialized. Make sure Firebase Functions onInit has been called.");
|
|
26
|
+
}
|
|
27
|
+
FlowInputSchema = genkit_2.ai.defineSchema(`${name}InputSchema`, inputSchema);
|
|
28
|
+
FlowOutputSchema = genkit_2.ai.defineSchema(`${name}OutputSchema`, outputSchema);
|
|
29
|
+
prompt = genkit_2.ai.prompt(name);
|
|
30
|
+
flow = genkit_2.ai.defineFlow({
|
|
31
|
+
name: name,
|
|
32
|
+
inputSchema: inputSchema,
|
|
33
|
+
outputSchema: outputSchema,
|
|
34
|
+
}, async (input) => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const response = await prompt(input);
|
|
37
|
+
(0, cost_1.logAIUsage)({
|
|
38
|
+
type: "multimodal",
|
|
39
|
+
flowName: name,
|
|
40
|
+
model,
|
|
41
|
+
inputTokens: ((_a = response.usage) === null || _a === void 0 ? void 0 : _a.inputTokens) || 0,
|
|
42
|
+
outputTokens: ((_b = response.usage) === null || _b === void 0 ? void 0 : _b.outputTokens) || 0,
|
|
43
|
+
});
|
|
44
|
+
return handler(input, response.output);
|
|
45
|
+
});
|
|
46
|
+
initialized = true;
|
|
47
|
+
}
|
|
48
|
+
return flow;
|
|
49
|
+
};
|
|
50
|
+
// Return a proxy function that initializes on first call
|
|
51
|
+
return (async (input) => {
|
|
52
|
+
const actualFlow = initializeFlow();
|
|
53
|
+
return actualFlow(input);
|
|
34
54
|
});
|
|
35
55
|
};
|
|
36
56
|
exports.createGeminiFlow = createGeminiFlow;
|
|
37
57
|
const createImagenFlow = (name, inputSchema, handler, model = ai_1.AI_MODELS.Imagen4Fast) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
// Lazy initialization - don't access ai until the flow is actually called
|
|
59
|
+
let initialized = false;
|
|
60
|
+
let flow;
|
|
61
|
+
const initializeFlow = () => {
|
|
62
|
+
if (!initialized) {
|
|
63
|
+
if (!genkit_2.ai) {
|
|
64
|
+
throw new Error("Genkit AI not initialized. Make sure Firebase Functions onInit has been called.");
|
|
65
|
+
}
|
|
66
|
+
flow = genkit_2.ai.defineFlow({
|
|
67
|
+
name: name,
|
|
68
|
+
inputSchema: inputSchema,
|
|
69
|
+
outputSchema: exports.ImagenOutputSchema,
|
|
70
|
+
}, async (input) => {
|
|
71
|
+
const imageData = await handler(input, name);
|
|
72
|
+
const uploadPromises = imageData.map(({ base64Data, storagePath }) => (0, storage_1.uploadImageToStorage)(base64Data, storagePath).catch((err) => {
|
|
73
|
+
throw err;
|
|
74
|
+
}));
|
|
75
|
+
const uploadedImages = await Promise.all(uploadPromises);
|
|
76
|
+
(0, cost_1.logAIUsage)({
|
|
77
|
+
type: "image",
|
|
78
|
+
flowName: name,
|
|
79
|
+
model,
|
|
80
|
+
imageCount: imageData.length,
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
images: uploadedImages,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
initialized = true;
|
|
87
|
+
}
|
|
88
|
+
return flow;
|
|
89
|
+
};
|
|
90
|
+
// Return a proxy function that initializes on first call
|
|
91
|
+
return (async (input) => {
|
|
92
|
+
const actualFlow = initializeFlow();
|
|
93
|
+
return actualFlow(input);
|
|
57
94
|
});
|
|
58
95
|
};
|
|
59
96
|
exports.createImagenFlow = createImagenFlow;
|
package/dist/lib/ai/flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../../../src/lib/ai/flow.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,wCAA4C;AAC5C,iCAAoC;AACpC,qCAA8B;AAC9B,wCAAkD;AAGrC,QAAA,kBAAkB,GAAG,UAAC,CAAC,MAAM,CAAC;IACzC,MAAM,EAAE,UAAC,CAAC,KAAK,CACb,UAAC,CAAC,MAAM,CAAC;QACP,GAAG,EAAE,UAAC,CAAC,MAAM,EAAE;QACf,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;KACjB,CAAC,CACH;CACF,CAAC,CAAC;AAQI,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,WAA2B,EAC3B,YAA4B,EAC5B,OAA0B,EAC1B,QAAuB,cAAS,CAAC,aAAa,EAC9C,EAAE;IACF,MAAM,eAAe,GAAG,WAAE,CAAC,YAAY,CAAC,GAAG,IAAI,aAAa,EAAE,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../../../src/lib/ai/flow.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,wCAA4C;AAC5C,iCAAoC;AACpC,qCAA8B;AAC9B,wCAAkD;AAGrC,QAAA,kBAAkB,GAAG,UAAC,CAAC,MAAM,CAAC;IACzC,MAAM,EAAE,UAAC,CAAC,KAAK,CACb,UAAC,CAAC,MAAM,CAAC;QACP,GAAG,EAAE,UAAC,CAAC,MAAM,EAAE;QACf,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;KACjB,CAAC,CACH;CACF,CAAC,CAAC;AAQI,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,WAA2B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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBK,CAAC"}
|
package/dist/types/ai/recipe.js
CHANGED
|
@@ -3,22 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AIRecipeSchema = void 0;
|
|
4
4
|
const genkit_1 = require("genkit");
|
|
5
5
|
const recipe_1 = require("../recipe");
|
|
6
|
+
// Simplified schema for Gemini structured output
|
|
7
|
+
// Removed complex constraints that cause "too many states" errors:
|
|
8
|
+
// - Regex patterns on slugs (removed from nested schemas)
|
|
9
|
+
// - High array max limits (instructions max 50, equipment max 20, etc)
|
|
10
|
+
// - Numeric min/max bounds (confidence 0-1, servings 1-100, time 1-1440, etc)
|
|
11
|
+
// - String length constraints (description 10-2000, title 3-200, etc)
|
|
12
|
+
// These validations should be done in application logic if needed
|
|
6
13
|
exports.AIRecipeSchema = genkit_1.z.object({
|
|
7
14
|
allergens: genkit_1.z.array(recipe_1.AllergenSchema),
|
|
8
|
-
confidence: genkit_1.z.number()
|
|
15
|
+
confidence: genkit_1.z.number(),
|
|
9
16
|
cuisine: recipe_1.CuisineSchema,
|
|
10
|
-
description: genkit_1.z.string()
|
|
17
|
+
description: genkit_1.z.string(),
|
|
11
18
|
dietaryTags: genkit_1.z.array(recipe_1.DietaryTagSchema),
|
|
12
19
|
difficulty: recipe_1.DifficultySchema,
|
|
13
|
-
equipment: genkit_1.z.array(recipe_1.EquipmentSchema).
|
|
14
|
-
ingredientSections: genkit_1.z.array(recipe_1.IngredientSectionSchema)
|
|
15
|
-
instructions: genkit_1.z.array(recipe_1.InstructionSchema)
|
|
16
|
-
mealTypes: genkit_1.z.array(recipe_1.MealTypeSchema)
|
|
20
|
+
equipment: genkit_1.z.array(recipe_1.EquipmentSchema).optional(),
|
|
21
|
+
ingredientSections: genkit_1.z.array(recipe_1.IngredientSectionSchema),
|
|
22
|
+
instructions: genkit_1.z.array(recipe_1.InstructionSchema),
|
|
23
|
+
mealTypes: genkit_1.z.array(recipe_1.MealTypeSchema),
|
|
17
24
|
nutrition: recipe_1.NutritionSchema.optional(),
|
|
18
|
-
servings: genkit_1.z.number()
|
|
25
|
+
servings: genkit_1.z.number(),
|
|
19
26
|
spiciness: recipe_1.SpicinessSchema,
|
|
20
|
-
time: genkit_1.z.number()
|
|
21
|
-
tips: genkit_1.z.array(genkit_1.z.string()
|
|
22
|
-
title: genkit_1.z.string()
|
|
27
|
+
time: genkit_1.z.number(),
|
|
28
|
+
tips: genkit_1.z.array(genkit_1.z.string()).optional(),
|
|
29
|
+
title: genkit_1.z.string(),
|
|
23
30
|
});
|
|
24
31
|
//# sourceMappingURL=recipe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipe.js","sourceRoot":"","sources":["../../../src/types/ai/recipe.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,sCAqBmB;
|
|
1
|
+
{"version":3,"file":"recipe.js","sourceRoot":"","sources":["../../../src/types/ai/recipe.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,sCAqBmB;AAqBnB,iDAAiD;AACjD,mEAAmE;AACnE,0DAA0D;AAC1D,uEAAuE;AACvE,8EAA8E;AAC9E,sEAAsE;AACtE,kEAAkE;AACrD,QAAA,cAAc,GAAG,UAAC,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE,UAAC,CAAC,KAAK,CAAC,uBAAc,CAAC;IAClC,UAAU,EAAE,UAAC,CAAC,MAAM,EAAE;IACtB,OAAO,EAAE,sBAAa;IACtB,WAAW,EAAE,UAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,UAAC,CAAC,KAAK,CAAC,yBAAgB,CAAC;IACtC,UAAU,EAAE,yBAAgB;IAC5B,SAAS,EAAE,UAAC,CAAC,KAAK,CAAC,wBAAe,CAAC,CAAC,QAAQ,EAAE;IAC9C,kBAAkB,EAAE,UAAC,CAAC,KAAK,CAAC,gCAAuB,CAAC;IACpD,YAAY,EAAE,UAAC,CAAC,KAAK,CAAC,0BAAiB,CAAC;IACxC,SAAS,EAAE,UAAC,CAAC,KAAK,CAAC,uBAAc,CAAC;IAClC,SAAS,EAAE,wBAAe,CAAC,QAAQ,EAAE;IACrC,QAAQ,EAAE,UAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,wBAAe;IAC1B,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,UAAC,CAAC,KAAK,CAAC,UAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpC,KAAK,EAAE,UAAC,CAAC,MAAM,EAAE;CAClB,CAA+B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equipment.d.ts","sourceRoot":"","sources":["../../../src/types/recipe/equipment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"equipment.d.ts","sourceRoot":"","sources":["../../../src/types/recipe/equipment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;EAGK,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAIK,CAAC;AAEzC,MAAM,WAAW,SAAU,SAAQ,aAAa,EAAE,gBAAgB;CAAG;AAErE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAGK,CAAC"}
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EquipmentSchema = exports.EquipmentContentSchema = exports.EquipmentMetaSchema = void 0;
|
|
4
4
|
const genkit_1 = require("genkit");
|
|
5
|
-
const config_1 = require("../../config");
|
|
6
5
|
exports.EquipmentMetaSchema = genkit_1.z.object({
|
|
7
6
|
required: genkit_1.z.boolean().optional(),
|
|
8
|
-
slug: genkit_1.z.string()
|
|
7
|
+
slug: genkit_1.z.string(),
|
|
9
8
|
});
|
|
10
9
|
exports.EquipmentContentSchema = genkit_1.z.object({
|
|
11
|
-
name: genkit_1.z.string()
|
|
12
|
-
notes: genkit_1.z.string().
|
|
13
|
-
slug: genkit_1.z.string()
|
|
10
|
+
name: genkit_1.z.string(),
|
|
11
|
+
notes: genkit_1.z.string().optional(),
|
|
12
|
+
slug: genkit_1.z.string(),
|
|
14
13
|
});
|
|
15
14
|
exports.EquipmentSchema = genkit_1.z.object(Object.assign(Object.assign({}, exports.EquipmentMetaSchema.shape), exports.EquipmentContentSchema.shape));
|
|
16
15
|
//# sourceMappingURL=equipment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equipment.js","sourceRoot":"","sources":["../../../src/types/recipe/equipment.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;
|
|
1
|
+
{"version":3,"file":"equipment.js","sourceRoot":"","sources":["../../../src/types/recipe/equipment.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAOd,QAAA,mBAAmB,GAAG,UAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,UAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;CACjB,CAAoC,CAAC;AAQzB,QAAA,sBAAsB,GAAG,UAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;CACjB,CAAuC,CAAC;AAI5B,QAAA,eAAe,GAAG,UAAC,CAAC,MAAM,iCAClC,2BAAmB,CAAC,KAAK,GACzB,8BAAsB,CAAC,KAAK,EACA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingredient.d.ts","sourceRoot":"","sources":["../../../src/types/recipe/ingredient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"ingredient.d.ts","sourceRoot":"","sources":["../../../src/types/recipe/ingredient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAKK,CAAC;AAEvC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;;EAIK,CAAC;AAE1C,MAAM,WAAW,UAAW,SAAQ,cAAc,EAAE,iBAAiB;CAAG;AAExE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAGK,CAAC;AAEnC,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGK,CAAC;AAE9C,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIK,CAAC;AAEjD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIK,CAAC"}
|
|
@@ -2,32 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IngredientSectionSchema = exports.IngredientSectionContentSchema = exports.IngredientSectionMetaSchema = exports.IngredientSchema = exports.IngredientContentSchema = exports.IngredientMetaSchema = void 0;
|
|
4
4
|
const genkit_1 = require("genkit");
|
|
5
|
-
const config_1 = require("../../config");
|
|
6
5
|
const enums_1 = require("./enums");
|
|
7
6
|
exports.IngredientMetaSchema = genkit_1.z.object({
|
|
8
|
-
quantity: genkit_1.z.number().
|
|
7
|
+
quantity: genkit_1.z.number().optional(),
|
|
9
8
|
required: genkit_1.z.boolean().optional(),
|
|
10
|
-
slug: genkit_1.z.string()
|
|
9
|
+
slug: genkit_1.z.string(),
|
|
11
10
|
unit: enums_1.UnitSchema.optional(),
|
|
12
11
|
});
|
|
13
12
|
exports.IngredientContentSchema = genkit_1.z.object({
|
|
14
|
-
name: genkit_1.z.string()
|
|
15
|
-
notes: genkit_1.z.string().
|
|
16
|
-
slug: genkit_1.z.string()
|
|
13
|
+
name: genkit_1.z.string(),
|
|
14
|
+
notes: genkit_1.z.string().optional(),
|
|
15
|
+
slug: genkit_1.z.string(),
|
|
17
16
|
});
|
|
18
17
|
exports.IngredientSchema = genkit_1.z.object(Object.assign(Object.assign({}, exports.IngredientMetaSchema.shape), exports.IngredientContentSchema.shape));
|
|
19
18
|
exports.IngredientSectionMetaSchema = genkit_1.z.object({
|
|
20
|
-
ingredients: genkit_1.z.array(exports.IngredientMetaSchema)
|
|
21
|
-
slug: genkit_1.z.string()
|
|
19
|
+
ingredients: genkit_1.z.array(exports.IngredientMetaSchema),
|
|
20
|
+
slug: genkit_1.z.string(),
|
|
22
21
|
});
|
|
23
22
|
exports.IngredientSectionContentSchema = genkit_1.z.object({
|
|
24
|
-
ingredients: genkit_1.z.array(exports.IngredientContentSchema)
|
|
25
|
-
slug: genkit_1.z.string()
|
|
26
|
-
title: genkit_1.z.string().
|
|
23
|
+
ingredients: genkit_1.z.array(exports.IngredientContentSchema),
|
|
24
|
+
slug: genkit_1.z.string(),
|
|
25
|
+
title: genkit_1.z.string().optional(),
|
|
27
26
|
});
|
|
28
27
|
exports.IngredientSectionSchema = genkit_1.z.object({
|
|
29
|
-
ingredients: genkit_1.z.array(exports.IngredientSchema)
|
|
30
|
-
slug: genkit_1.z.string()
|
|
31
|
-
title: genkit_1.z.string().
|
|
28
|
+
ingredients: genkit_1.z.array(exports.IngredientSchema),
|
|
29
|
+
slug: genkit_1.z.string(),
|
|
30
|
+
title: genkit_1.z.string().optional(),
|
|
32
31
|
});
|
|
33
32
|
//# sourceMappingURL=ingredient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingredient.js","sourceRoot":"","sources":["../../../src/types/recipe/ingredient.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"ingredient.js","sourceRoot":"","sources":["../../../src/types/recipe/ingredient.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,mCAAgD;AASnC,QAAA,oBAAoB,GAAG,UAAC,CAAC,MA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4,13 @@ exports.InstructionSchema = exports.InstructionContentSchema = exports.Instructi
|
|
|
4
4
|
const genkit_1 = require("genkit");
|
|
5
5
|
const temperature_1 = require("./temperature");
|
|
6
6
|
exports.InstructionMetaSchema = genkit_1.z.object({
|
|
7
|
-
duration: genkit_1.z.number().
|
|
8
|
-
step: genkit_1.z.number()
|
|
7
|
+
duration: genkit_1.z.number().optional(),
|
|
8
|
+
step: genkit_1.z.number(),
|
|
9
9
|
temperature: temperature_1.TemperatureSchema.optional(),
|
|
10
10
|
});
|
|
11
11
|
exports.InstructionContentSchema = genkit_1.z.object({
|
|
12
|
-
step: genkit_1.z.number()
|
|
13
|
-
text: genkit_1.z.string()
|
|
12
|
+
step: genkit_1.z.number(),
|
|
13
|
+
text: genkit_1.z.string(),
|
|
14
14
|
});
|
|
15
15
|
exports.InstructionSchema = genkit_1.z.object(Object.assign(Object.assign({}, exports.InstructionMetaSchema.shape), exports.InstructionContentSchema.shape));
|
|
16
16
|
//# sourceMappingURL=instruction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction.js","sourceRoot":"","sources":["../../../src/types/recipe/instruction.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,+CAAoE;AAQvD,QAAA,qBAAqB,GAAG,UAAC,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"instruction.js","sourceRoot":"","sources":["../../../src/types/recipe/instruction.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,+CAAoE;AAQvD,QAAA,qBAAqB,GAAG,UAAC,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,+BAAiB,CAAC,QAAQ,EAAE;CAC1C,CAAsC,CAAC;AAO3B,QAAA,wBAAwB,GAAG,UAAC,CAAC,MAAM,CAAC;IAC/C,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;CACjB,CAAyC,CAAC;AAI9B,QAAA,iBAAiB,GAAG,UAAC,CAAC,MAAM,iCACpC,6BAAqB,CAAC,KAAK,GAC3B,gCAAwB,CAAC,KAAK,EACA,CAAC"}
|
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NutritionSchema = void 0;
|
|
4
4
|
const genkit_1 = require("genkit");
|
|
5
5
|
exports.NutritionSchema = genkit_1.z.object({
|
|
6
|
-
calories: genkit_1.z.number()
|
|
7
|
-
carbs: genkit_1.z.number().
|
|
8
|
-
cholesterol: genkit_1.z.number().
|
|
9
|
-
fat: genkit_1.z.number().
|
|
10
|
-
fiber: genkit_1.z.number().
|
|
11
|
-
protein: genkit_1.z.number().
|
|
12
|
-
saturatedFat: genkit_1.z.number().
|
|
13
|
-
sodium: genkit_1.z.number().
|
|
14
|
-
sugar: genkit_1.z.number().
|
|
6
|
+
calories: genkit_1.z.number(),
|
|
7
|
+
carbs: genkit_1.z.number().optional(),
|
|
8
|
+
cholesterol: genkit_1.z.number().optional(),
|
|
9
|
+
fat: genkit_1.z.number().optional(),
|
|
10
|
+
fiber: genkit_1.z.number().optional(),
|
|
11
|
+
protein: genkit_1.z.number().optional(),
|
|
12
|
+
saturatedFat: genkit_1.z.number().optional(),
|
|
13
|
+
sodium: genkit_1.z.number().optional(),
|
|
14
|
+
sugar: genkit_1.z.number().optional(),
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=nutrition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nutrition.js","sourceRoot":"","sources":["../../../src/types/recipe/nutrition.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAkBd,QAAA,eAAe,GAAG,UAAC,CAAC,MAAM,CAAC;IACtC,QAAQ,EAAE,UAAC,CAAC,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"nutrition.js","sourceRoot":"","sources":["../../../src/types/recipe/nutrition.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAkBd,QAAA,eAAe,GAAG,UAAC,CAAC,MAAM,CAAC;IACtC,QAAQ,EAAE,UAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,WAAW,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,GAAG,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,KAAK,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,OAAO,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,YAAY,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,MAAM,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,UAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAgC,CAAC"}
|
package/package.json
CHANGED
package/src/lib/ai/flow.ts
CHANGED
|
@@ -27,32 +27,56 @@ export const createGeminiFlow = <T, R>(
|
|
|
27
27
|
handler: FlowHandler<T, R>,
|
|
28
28
|
model: AIModelConfig = AI_MODELS.Gemini25Flash,
|
|
29
29
|
) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
>(name);
|
|
30
|
+
// Lazy initialization - don't access ai until the flow is actually called
|
|
31
|
+
let initialized = false;
|
|
32
|
+
let FlowInputSchema: any;
|
|
33
|
+
let FlowOutputSchema: any;
|
|
34
|
+
let prompt: any;
|
|
35
|
+
let flow: any;
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
const initializeFlow = () => {
|
|
38
|
+
if (!initialized) {
|
|
39
|
+
if (!ai) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
"Genkit AI not initialized. Make sure Firebase Functions onInit has been called.",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
FlowInputSchema = ai.defineSchema(`${name}InputSchema`, inputSchema);
|
|
45
|
+
FlowOutputSchema = ai.defineSchema(`${name}OutputSchema`, outputSchema);
|
|
46
|
+
prompt = ai.prompt<
|
|
47
|
+
typeof FlowInputSchema,
|
|
48
|
+
typeof FlowOutputSchema,
|
|
49
|
+
z.ZodTypeAny
|
|
50
|
+
>(name);
|
|
51
|
+
|
|
52
|
+
flow = ai.defineFlow(
|
|
53
|
+
{
|
|
54
|
+
name: name,
|
|
55
|
+
inputSchema: inputSchema,
|
|
56
|
+
outputSchema: outputSchema,
|
|
57
|
+
},
|
|
58
|
+
async (input: T) => {
|
|
59
|
+
const response = await prompt(input);
|
|
60
|
+
logAIUsage({
|
|
61
|
+
type: "multimodal",
|
|
62
|
+
flowName: name,
|
|
63
|
+
model,
|
|
64
|
+
inputTokens: response.usage?.inputTokens || 0,
|
|
65
|
+
outputTokens: response.usage?.outputTokens || 0,
|
|
66
|
+
});
|
|
67
|
+
return handler(input, response.output);
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
initialized = true;
|
|
71
|
+
}
|
|
72
|
+
return flow;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Return a proxy function that initializes on first call
|
|
76
|
+
return (async (input: T) => {
|
|
77
|
+
const actualFlow = initializeFlow();
|
|
78
|
+
return actualFlow(input);
|
|
79
|
+
}) as ReturnType<typeof ai.defineFlow>;
|
|
56
80
|
};
|
|
57
81
|
|
|
58
82
|
export const createImagenFlow = <T>(
|
|
@@ -61,29 +85,50 @@ export const createImagenFlow = <T>(
|
|
|
61
85
|
handler: ImageFlowHandler<T>,
|
|
62
86
|
model: AIModelConfig = AI_MODELS.Imagen4Fast,
|
|
63
87
|
) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
88
|
+
// Lazy initialization - don't access ai until the flow is actually called
|
|
89
|
+
let initialized = false;
|
|
90
|
+
let flow: any;
|
|
91
|
+
|
|
92
|
+
const initializeFlow = () => {
|
|
93
|
+
if (!initialized) {
|
|
94
|
+
if (!ai) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
"Genkit AI not initialized. Make sure Firebase Functions onInit has been called.",
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
flow = ai.defineFlow(
|
|
100
|
+
{
|
|
101
|
+
name: name,
|
|
102
|
+
inputSchema: inputSchema,
|
|
103
|
+
outputSchema: ImagenOutputSchema,
|
|
104
|
+
},
|
|
105
|
+
async (input: T) => {
|
|
106
|
+
const imageData = await handler(input, name);
|
|
107
|
+
const uploadPromises = imageData.map(({ base64Data, storagePath }) =>
|
|
108
|
+
uploadImageToStorage(base64Data, storagePath).catch((err) => {
|
|
109
|
+
throw err;
|
|
110
|
+
}),
|
|
111
|
+
);
|
|
112
|
+
const uploadedImages = await Promise.all(uploadPromises);
|
|
113
|
+
logAIUsage({
|
|
114
|
+
type: "image",
|
|
115
|
+
flowName: name,
|
|
116
|
+
model,
|
|
117
|
+
imageCount: imageData.length,
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
images: uploadedImages,
|
|
121
|
+
};
|
|
122
|
+
},
|
|
76
123
|
);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
);
|
|
124
|
+
initialized = true;
|
|
125
|
+
}
|
|
126
|
+
return flow;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Return a proxy function that initializes on first call
|
|
130
|
+
return (async (input: T) => {
|
|
131
|
+
const actualFlow = initializeFlow();
|
|
132
|
+
return actualFlow(input);
|
|
133
|
+
}) as ReturnType<typeof ai.defineFlow>;
|
|
89
134
|
};
|
package/src/types/ai/recipe.ts
CHANGED
|
@@ -41,21 +41,28 @@ export interface AIRecipe {
|
|
|
41
41
|
title: string;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Simplified schema for Gemini structured output
|
|
45
|
+
// Removed complex constraints that cause "too many states" errors:
|
|
46
|
+
// - Regex patterns on slugs (removed from nested schemas)
|
|
47
|
+
// - High array max limits (instructions max 50, equipment max 20, etc)
|
|
48
|
+
// - Numeric min/max bounds (confidence 0-1, servings 1-100, time 1-1440, etc)
|
|
49
|
+
// - String length constraints (description 10-2000, title 3-200, etc)
|
|
50
|
+
// These validations should be done in application logic if needed
|
|
44
51
|
export const AIRecipeSchema = z.object({
|
|
45
52
|
allergens: z.array(AllergenSchema),
|
|
46
|
-
confidence: z.number()
|
|
53
|
+
confidence: z.number(),
|
|
47
54
|
cuisine: CuisineSchema,
|
|
48
|
-
description: z.string()
|
|
55
|
+
description: z.string(),
|
|
49
56
|
dietaryTags: z.array(DietaryTagSchema),
|
|
50
57
|
difficulty: DifficultySchema,
|
|
51
|
-
equipment: z.array(EquipmentSchema).
|
|
52
|
-
ingredientSections: z.array(IngredientSectionSchema)
|
|
53
|
-
instructions: z.array(InstructionSchema)
|
|
54
|
-
mealTypes: z.array(MealTypeSchema)
|
|
58
|
+
equipment: z.array(EquipmentSchema).optional(),
|
|
59
|
+
ingredientSections: z.array(IngredientSectionSchema),
|
|
60
|
+
instructions: z.array(InstructionSchema),
|
|
61
|
+
mealTypes: z.array(MealTypeSchema),
|
|
55
62
|
nutrition: NutritionSchema.optional(),
|
|
56
|
-
servings: z.number()
|
|
63
|
+
servings: z.number(),
|
|
57
64
|
spiciness: SpicinessSchema,
|
|
58
|
-
time: z.number()
|
|
59
|
-
tips: z.array(z.string()
|
|
60
|
-
title: z.string()
|
|
65
|
+
time: z.number(),
|
|
66
|
+
tips: z.array(z.string()).optional(),
|
|
67
|
+
title: z.string(),
|
|
61
68
|
}) satisfies z.ZodType<AIRecipe>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "genkit";
|
|
2
|
-
import { SLUG_REGEX } from "../../config";
|
|
3
2
|
|
|
4
3
|
export interface EquipmentMeta {
|
|
5
4
|
required?: boolean;
|
|
@@ -8,7 +7,7 @@ export interface EquipmentMeta {
|
|
|
8
7
|
|
|
9
8
|
export const EquipmentMetaSchema = z.object({
|
|
10
9
|
required: z.boolean().optional(),
|
|
11
|
-
slug: z.string()
|
|
10
|
+
slug: z.string(),
|
|
12
11
|
}) satisfies z.ZodType<EquipmentMeta>;
|
|
13
12
|
|
|
14
13
|
export interface EquipmentContent {
|
|
@@ -18,9 +17,9 @@ export interface EquipmentContent {
|
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
export const EquipmentContentSchema = z.object({
|
|
21
|
-
name: z.string()
|
|
22
|
-
notes: z.string().
|
|
23
|
-
slug: z.string()
|
|
20
|
+
name: z.string(),
|
|
21
|
+
notes: z.string().optional(),
|
|
22
|
+
slug: z.string(),
|
|
24
23
|
}) satisfies z.ZodType<EquipmentContent>;
|
|
25
24
|
|
|
26
25
|
export interface Equipment extends EquipmentMeta, EquipmentContent {}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "genkit";
|
|
2
|
-
import { SLUG_REGEX } from "../../config";
|
|
3
2
|
import { UnitSchema, type Unit } from "./enums";
|
|
4
3
|
|
|
5
4
|
export interface IngredientMeta {
|
|
@@ -10,9 +9,9 @@ export interface IngredientMeta {
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export const IngredientMetaSchema = z.object({
|
|
13
|
-
quantity: z.number().
|
|
12
|
+
quantity: z.number().optional(),
|
|
14
13
|
required: z.boolean().optional(),
|
|
15
|
-
slug: z.string()
|
|
14
|
+
slug: z.string(),
|
|
16
15
|
unit: UnitSchema.optional(),
|
|
17
16
|
}) satisfies z.ZodType<IngredientMeta>;
|
|
18
17
|
|
|
@@ -23,9 +22,9 @@ export interface IngredientContent {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export const IngredientContentSchema = z.object({
|
|
26
|
-
name: z.string()
|
|
27
|
-
notes: z.string().
|
|
28
|
-
slug: z.string()
|
|
25
|
+
name: z.string(),
|
|
26
|
+
notes: z.string().optional(),
|
|
27
|
+
slug: z.string(),
|
|
29
28
|
}) satisfies z.ZodType<IngredientContent>;
|
|
30
29
|
|
|
31
30
|
export interface Ingredient extends IngredientMeta, IngredientContent {}
|
|
@@ -41,8 +40,8 @@ export interface IngredientSectionMeta {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
export const IngredientSectionMetaSchema = z.object({
|
|
44
|
-
ingredients: z.array(IngredientMetaSchema)
|
|
45
|
-
slug: z.string()
|
|
43
|
+
ingredients: z.array(IngredientMetaSchema),
|
|
44
|
+
slug: z.string(),
|
|
46
45
|
}) satisfies z.ZodType<IngredientSectionMeta>;
|
|
47
46
|
|
|
48
47
|
export interface IngredientSectionContent {
|
|
@@ -52,9 +51,9 @@ export interface IngredientSectionContent {
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
export const IngredientSectionContentSchema = z.object({
|
|
55
|
-
ingredients: z.array(IngredientContentSchema)
|
|
56
|
-
slug: z.string()
|
|
57
|
-
title: z.string().
|
|
54
|
+
ingredients: z.array(IngredientContentSchema),
|
|
55
|
+
slug: z.string(),
|
|
56
|
+
title: z.string().optional(),
|
|
58
57
|
}) satisfies z.ZodType<IngredientSectionContent>;
|
|
59
58
|
|
|
60
59
|
export interface IngredientSection {
|
|
@@ -64,7 +63,7 @@ export interface IngredientSection {
|
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
export const IngredientSectionSchema = z.object({
|
|
67
|
-
ingredients: z.array(IngredientSchema)
|
|
68
|
-
slug: z.string()
|
|
69
|
-
title: z.string().
|
|
66
|
+
ingredients: z.array(IngredientSchema),
|
|
67
|
+
slug: z.string(),
|
|
68
|
+
title: z.string().optional(),
|
|
70
69
|
}) satisfies z.ZodType<IngredientSection>;
|
|
@@ -8,8 +8,8 @@ export interface InstructionMeta {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const InstructionMetaSchema = z.object({
|
|
11
|
-
duration: z.number().
|
|
12
|
-
step: z.number()
|
|
11
|
+
duration: z.number().optional(),
|
|
12
|
+
step: z.number(),
|
|
13
13
|
temperature: TemperatureSchema.optional(),
|
|
14
14
|
}) satisfies z.ZodType<InstructionMeta>;
|
|
15
15
|
|
|
@@ -19,8 +19,8 @@ export interface InstructionContent {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export const InstructionContentSchema = z.object({
|
|
22
|
-
step: z.number()
|
|
23
|
-
text: z.string()
|
|
22
|
+
step: z.number(),
|
|
23
|
+
text: z.string(),
|
|
24
24
|
}) satisfies z.ZodType<InstructionContent>;
|
|
25
25
|
|
|
26
26
|
export interface Instruction extends InstructionMeta, InstructionContent {}
|
|
@@ -17,13 +17,13 @@ export interface Nutrition {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const NutritionSchema = z.object({
|
|
20
|
-
calories: z.number()
|
|
21
|
-
carbs: z.number().
|
|
22
|
-
cholesterol: z.number().
|
|
23
|
-
fat: z.number().
|
|
24
|
-
fiber: z.number().
|
|
25
|
-
protein: z.number().
|
|
26
|
-
saturatedFat: z.number().
|
|
27
|
-
sodium: z.number().
|
|
28
|
-
sugar: z.number().
|
|
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
29
|
}) satisfies z.ZodType<Nutrition>;
|