@cravery/core 0.0.2 → 0.0.3
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/config/ai.d.ts +3 -0
- package/dist/config/ai.d.ts.map +1 -0
- package/dist/config/ai.js +36 -0
- package/dist/config/ai.js.map +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/enums/cuisine.d.ts +1 -1
- package/dist/enums/difficulty.d.ts +1 -1
- package/dist/enums/moderation_status.d.ts +1 -1
- package/dist/enums/priority.d.ts +1 -1
- package/dist/enums/profile_status.d.ts +2 -2
- package/dist/enums/recipe_source.d.ts +2 -2
- package/dist/enums/recipe_status.d.ts +2 -2
- package/dist/enums/role.d.ts +1 -1
- package/dist/enums/severity.d.ts +1 -1
- package/dist/enums/spiciness.d.ts +1 -1
- package/dist/enums/status.d.ts +2 -2
- package/dist/enums/unit.d.ts +5 -5
- package/dist/enums/user_status.d.ts +2 -2
- package/dist/lib/api.d.ts +18 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +69 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/cost.d.ts +22 -0
- package/dist/lib/cost.d.ts.map +1 -0
- package/dist/lib/cost.js +45 -0
- package/dist/lib/cost.js.map +1 -0
- package/dist/lib/embedding.d.ts +4 -0
- package/dist/lib/embedding.d.ts.map +1 -0
- package/dist/lib/embedding.js +48 -0
- package/dist/lib/embedding.js.map +1 -0
- package/dist/lib/firebase.d.ts +3 -0
- package/dist/lib/firebase.d.ts.map +1 -0
- package/dist/lib/firebase.js +8 -0
- package/dist/lib/firebase.js.map +1 -0
- package/dist/lib/flow.d.ts +53 -0
- package/dist/lib/flow.d.ts.map +1 -0
- package/dist/lib/flow.js +60 -0
- package/dist/lib/flow.js.map +1 -0
- package/dist/lib/genkit.d.ts +4 -0
- package/dist/lib/genkit.d.ts.map +1 -0
- package/dist/lib/genkit.js +16 -0
- package/dist/lib/genkit.js.map +1 -0
- package/dist/lib/iam.d.ts +3 -0
- package/dist/lib/iam.d.ts.map +1 -0
- package/dist/lib/iam.js +57 -0
- package/dist/lib/iam.js.map +1 -0
- package/dist/lib/image.d.ts +7 -0
- package/dist/lib/image.d.ts.map +1 -0
- package/dist/lib/image.js +24 -0
- package/dist/lib/image.js.map +1 -0
- package/dist/lib/index.d.ts +9 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +23 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/storage.d.ts +6 -0
- package/dist/lib/storage.d.ts.map +1 -0
- package/dist/lib/storage.js +34 -0
- package/dist/lib/storage.js.map +1 -0
- package/dist/types/ai/config.d.ts +2 -2
- package/dist/types/ai/config.d.ts.map +1 -1
- package/dist/types/ai/filters.d.ts +3 -3
- package/dist/types/ai/recipe.d.ts +10 -10
- package/dist/types/equipment.d.ts +2 -2
- package/dist/types/equipment.js +1 -1
- package/dist/types/error.d.ts +14 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/error.js +40 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/ingredient.d.ts +24 -24
- package/dist/types/ingredient.js +1 -1
- package/dist/types/ingredient.js.map +1 -1
- package/dist/types/moderation.d.ts +5 -5
- package/dist/types/profile.d.ts +2 -2
- package/dist/types/recipe.d.ts +28 -28
- package/dist/types/user.d.ts +3 -3
- package/package.json +2 -2
- package/src/config/ai.ts +34 -0
- package/src/config/index.ts +1 -0
- package/src/lib/api.ts +90 -0
- package/src/lib/cost.ts +72 -0
- package/src/lib/embedding.ts +53 -0
- package/src/lib/firebase.ts +5 -0
- package/src/lib/flow.ts +88 -0
- package/src/lib/genkit.ts +18 -0
- package/src/lib/iam.ts +22 -0
- package/src/lib/image.ts +28 -0
- package/src/lib/index.ts +9 -0
- package/src/lib/storage.ts +42 -0
- package/src/types/ai/config.ts +3 -2
- package/src/types/equipment.ts +1 -1
- package/src/types/error.ts +43 -0
- package/src/types/index.ts +1 -0
- package/src/types/ingredient.ts +1 -1
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const IngredientMetaSchema: z.ZodObject<{
|
|
3
|
-
optional: z.ZodOptional<z.ZodBoolean>;
|
|
4
3
|
quantity: z.ZodOptional<z.ZodNumber>;
|
|
4
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
5
5
|
slug: z.ZodString;
|
|
6
6
|
unit: z.ZodOptional<z.ZodEnum<{
|
|
7
|
-
slice: "slice";
|
|
8
|
-
head: "head";
|
|
9
|
-
g: "g";
|
|
10
|
-
drop: "drop";
|
|
11
|
-
quarter: "quarter";
|
|
12
7
|
ml: "ml";
|
|
13
8
|
l: "l";
|
|
14
9
|
tsp: "tsp";
|
|
@@ -19,18 +14,22 @@ export declare const IngredientMetaSchema: z.ZodObject<{
|
|
|
19
14
|
quart: "quart";
|
|
20
15
|
gallon: "gallon";
|
|
21
16
|
mg: "mg";
|
|
17
|
+
g: "g";
|
|
22
18
|
kg: "kg";
|
|
23
19
|
oz: "oz";
|
|
24
20
|
lb: "lb";
|
|
25
21
|
piece: "piece";
|
|
26
22
|
whole: "whole";
|
|
27
23
|
half: "half";
|
|
24
|
+
quarter: "quarter";
|
|
25
|
+
slice: "slice";
|
|
28
26
|
serving: "serving";
|
|
29
27
|
clove: "clove";
|
|
30
28
|
stalk: "stalk";
|
|
31
29
|
sprig: "sprig";
|
|
32
30
|
leaf: "leaf";
|
|
33
31
|
bunch: "bunch";
|
|
32
|
+
head: "head";
|
|
34
33
|
fillet: "fillet";
|
|
35
34
|
stick: "stick";
|
|
36
35
|
sheet: "sheet";
|
|
@@ -41,6 +40,7 @@ export declare const IngredientMetaSchema: z.ZodObject<{
|
|
|
41
40
|
handful: "handful";
|
|
42
41
|
pinch: "pinch";
|
|
43
42
|
dash: "dash";
|
|
43
|
+
drop: "drop";
|
|
44
44
|
}>>;
|
|
45
45
|
}, z.core.$strip>;
|
|
46
46
|
export type IngredientMeta = z.infer<typeof IngredientMetaSchema>;
|
|
@@ -54,14 +54,9 @@ export declare const IngredientSchema: z.ZodObject<{
|
|
|
54
54
|
name: z.ZodString;
|
|
55
55
|
notes: z.ZodOptional<z.ZodString>;
|
|
56
56
|
slug: z.ZodString;
|
|
57
|
-
optional: z.ZodOptional<z.ZodBoolean>;
|
|
58
57
|
quantity: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
59
59
|
unit: z.ZodOptional<z.ZodEnum<{
|
|
60
|
-
slice: "slice";
|
|
61
|
-
head: "head";
|
|
62
|
-
g: "g";
|
|
63
|
-
drop: "drop";
|
|
64
|
-
quarter: "quarter";
|
|
65
60
|
ml: "ml";
|
|
66
61
|
l: "l";
|
|
67
62
|
tsp: "tsp";
|
|
@@ -72,18 +67,22 @@ export declare const IngredientSchema: z.ZodObject<{
|
|
|
72
67
|
quart: "quart";
|
|
73
68
|
gallon: "gallon";
|
|
74
69
|
mg: "mg";
|
|
70
|
+
g: "g";
|
|
75
71
|
kg: "kg";
|
|
76
72
|
oz: "oz";
|
|
77
73
|
lb: "lb";
|
|
78
74
|
piece: "piece";
|
|
79
75
|
whole: "whole";
|
|
80
76
|
half: "half";
|
|
77
|
+
quarter: "quarter";
|
|
78
|
+
slice: "slice";
|
|
81
79
|
serving: "serving";
|
|
82
80
|
clove: "clove";
|
|
83
81
|
stalk: "stalk";
|
|
84
82
|
sprig: "sprig";
|
|
85
83
|
leaf: "leaf";
|
|
86
84
|
bunch: "bunch";
|
|
85
|
+
head: "head";
|
|
87
86
|
fillet: "fillet";
|
|
88
87
|
stick: "stick";
|
|
89
88
|
sheet: "sheet";
|
|
@@ -94,20 +93,16 @@ export declare const IngredientSchema: z.ZodObject<{
|
|
|
94
93
|
handful: "handful";
|
|
95
94
|
pinch: "pinch";
|
|
96
95
|
dash: "dash";
|
|
96
|
+
drop: "drop";
|
|
97
97
|
}>>;
|
|
98
98
|
}, z.core.$strip>;
|
|
99
99
|
export type Ingredient = z.infer<typeof IngredientSchema>;
|
|
100
100
|
export declare const IngredientSectionMetaSchema: z.ZodObject<{
|
|
101
101
|
ingredients: z.ZodArray<z.ZodObject<{
|
|
102
|
-
optional: z.ZodOptional<z.ZodBoolean>;
|
|
103
102
|
quantity: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
104
104
|
slug: z.ZodString;
|
|
105
105
|
unit: z.ZodOptional<z.ZodEnum<{
|
|
106
|
-
slice: "slice";
|
|
107
|
-
head: "head";
|
|
108
|
-
g: "g";
|
|
109
|
-
drop: "drop";
|
|
110
|
-
quarter: "quarter";
|
|
111
106
|
ml: "ml";
|
|
112
107
|
l: "l";
|
|
113
108
|
tsp: "tsp";
|
|
@@ -118,18 +113,22 @@ export declare const IngredientSectionMetaSchema: z.ZodObject<{
|
|
|
118
113
|
quart: "quart";
|
|
119
114
|
gallon: "gallon";
|
|
120
115
|
mg: "mg";
|
|
116
|
+
g: "g";
|
|
121
117
|
kg: "kg";
|
|
122
118
|
oz: "oz";
|
|
123
119
|
lb: "lb";
|
|
124
120
|
piece: "piece";
|
|
125
121
|
whole: "whole";
|
|
126
122
|
half: "half";
|
|
123
|
+
quarter: "quarter";
|
|
124
|
+
slice: "slice";
|
|
127
125
|
serving: "serving";
|
|
128
126
|
clove: "clove";
|
|
129
127
|
stalk: "stalk";
|
|
130
128
|
sprig: "sprig";
|
|
131
129
|
leaf: "leaf";
|
|
132
130
|
bunch: "bunch";
|
|
131
|
+
head: "head";
|
|
133
132
|
fillet: "fillet";
|
|
134
133
|
stick: "stick";
|
|
135
134
|
sheet: "sheet";
|
|
@@ -140,6 +139,7 @@ export declare const IngredientSectionMetaSchema: z.ZodObject<{
|
|
|
140
139
|
handful: "handful";
|
|
141
140
|
pinch: "pinch";
|
|
142
141
|
dash: "dash";
|
|
142
|
+
drop: "drop";
|
|
143
143
|
}>>;
|
|
144
144
|
}, z.core.$strip>>;
|
|
145
145
|
slug: z.ZodString;
|
|
@@ -160,14 +160,9 @@ export declare const IngredientSectionSchema: z.ZodObject<{
|
|
|
160
160
|
name: z.ZodString;
|
|
161
161
|
notes: z.ZodOptional<z.ZodString>;
|
|
162
162
|
slug: z.ZodString;
|
|
163
|
-
optional: z.ZodOptional<z.ZodBoolean>;
|
|
164
163
|
quantity: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
165
165
|
unit: z.ZodOptional<z.ZodEnum<{
|
|
166
|
-
slice: "slice";
|
|
167
|
-
head: "head";
|
|
168
|
-
g: "g";
|
|
169
|
-
drop: "drop";
|
|
170
|
-
quarter: "quarter";
|
|
171
166
|
ml: "ml";
|
|
172
167
|
l: "l";
|
|
173
168
|
tsp: "tsp";
|
|
@@ -178,18 +173,22 @@ export declare const IngredientSectionSchema: z.ZodObject<{
|
|
|
178
173
|
quart: "quart";
|
|
179
174
|
gallon: "gallon";
|
|
180
175
|
mg: "mg";
|
|
176
|
+
g: "g";
|
|
181
177
|
kg: "kg";
|
|
182
178
|
oz: "oz";
|
|
183
179
|
lb: "lb";
|
|
184
180
|
piece: "piece";
|
|
185
181
|
whole: "whole";
|
|
186
182
|
half: "half";
|
|
183
|
+
quarter: "quarter";
|
|
184
|
+
slice: "slice";
|
|
187
185
|
serving: "serving";
|
|
188
186
|
clove: "clove";
|
|
189
187
|
stalk: "stalk";
|
|
190
188
|
sprig: "sprig";
|
|
191
189
|
leaf: "leaf";
|
|
192
190
|
bunch: "bunch";
|
|
191
|
+
head: "head";
|
|
193
192
|
fillet: "fillet";
|
|
194
193
|
stick: "stick";
|
|
195
194
|
sheet: "sheet";
|
|
@@ -200,6 +199,7 @@ export declare const IngredientSectionSchema: z.ZodObject<{
|
|
|
200
199
|
handful: "handful";
|
|
201
200
|
pinch: "pinch";
|
|
202
201
|
dash: "dash";
|
|
202
|
+
drop: "drop";
|
|
203
203
|
}>>;
|
|
204
204
|
}, z.core.$strip>>;
|
|
205
205
|
slug: z.ZodString;
|
package/dist/types/ingredient.js
CHANGED
|
@@ -5,8 +5,8 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const config_1 = require("../config");
|
|
6
6
|
const enums_1 = require("../enums");
|
|
7
7
|
exports.IngredientMetaSchema = zod_1.z.object({
|
|
8
|
-
optional: zod_1.z.boolean().optional(),
|
|
9
8
|
quantity: zod_1.z.number().positive().optional(),
|
|
9
|
+
required: zod_1.z.boolean().optional(),
|
|
10
10
|
slug: zod_1.z.string().regex(config_1.SlugRegex),
|
|
11
11
|
unit: enums_1.UnitSchema.optional(),
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingredient.js","sourceRoot":"","sources":["../../src/types/ingredient.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,sCAAsC;AACtC,oCAAsC;AAEzB,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,OAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"ingredient.js","sourceRoot":"","sources":["../../src/types/ingredient.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,sCAAsC;AACtC,oCAAsC;AAEzB,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC1C,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAS,CAAC;IACjC,IAAI,EAAE,kBAAU,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAGU,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IACrC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAS,CAAC;CAClC,CAAC,CAAC;AAGU,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,iCACnC,4BAAoB,CAAC,KAAK,GAC1B,+BAAuB,CAAC,KAAK,EAChC,CAAC;AAGU,QAAA,2BAA2B,GAAG,OAAC,CAAC,MAAM,CAAC;IAClD,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,4BAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAS,CAAC;CAClC,CAAC,CAAC;AAGU,QAAA,8BAA8B,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,+BAAuB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAS,CAAC;IACjC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC;AAKU,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,wBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAS,CAAC;IACjC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC"}
|
|
@@ -10,9 +10,9 @@ export declare const ModerationSuggestionSchema: z.ZodObject<{
|
|
|
10
10
|
}>;
|
|
11
11
|
field: z.ZodString;
|
|
12
12
|
severity: z.ZodEnum<{
|
|
13
|
-
high: "high";
|
|
14
13
|
low: "low";
|
|
15
14
|
medium: "medium";
|
|
15
|
+
high: "high";
|
|
16
16
|
}>;
|
|
17
17
|
suggestion: z.ZodString;
|
|
18
18
|
}, z.core.$strip>;
|
|
@@ -22,14 +22,14 @@ export declare const ModerationSchema: z.ZodObject<{
|
|
|
22
22
|
recipeId: z.ZodString;
|
|
23
23
|
userId: z.ZodString;
|
|
24
24
|
status: z.ZodEnum<{
|
|
25
|
+
approved: "approved";
|
|
25
26
|
pending: "pending";
|
|
26
27
|
rejected: "rejected";
|
|
27
|
-
approved: "approved";
|
|
28
28
|
}>;
|
|
29
29
|
priority: z.ZodEnum<{
|
|
30
|
-
high: "high";
|
|
31
30
|
low: "low";
|
|
32
31
|
medium: "medium";
|
|
32
|
+
high: "high";
|
|
33
33
|
}>;
|
|
34
34
|
qualityScore: z.ZodOptional<z.ZodNumber>;
|
|
35
35
|
aiSuggestions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -42,9 +42,9 @@ export declare const ModerationSchema: z.ZodObject<{
|
|
|
42
42
|
}>;
|
|
43
43
|
field: z.ZodString;
|
|
44
44
|
severity: z.ZodEnum<{
|
|
45
|
-
high: "high";
|
|
46
45
|
low: "low";
|
|
47
46
|
medium: "medium";
|
|
47
|
+
high: "high";
|
|
48
48
|
}>;
|
|
49
49
|
suggestion: z.ZodString;
|
|
50
50
|
}, z.core.$strip>>>;
|
|
@@ -73,9 +73,9 @@ export declare const ModerateRecipeOutputSchema: z.ZodObject<{
|
|
|
73
73
|
}>;
|
|
74
74
|
field: z.ZodString;
|
|
75
75
|
severity: z.ZodEnum<{
|
|
76
|
-
high: "high";
|
|
77
76
|
low: "low";
|
|
78
77
|
medium: "medium";
|
|
78
|
+
high: "high";
|
|
79
79
|
}>;
|
|
80
80
|
suggestion: z.ZodString;
|
|
81
81
|
}, z.core.$strip>>;
|
package/dist/types/profile.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export declare const ProfileSchema: z.ZodObject<{
|
|
|
9
9
|
name: z.ZodString;
|
|
10
10
|
public: z.ZodBoolean;
|
|
11
11
|
status: z.ZodEnum<{
|
|
12
|
-
|
|
12
|
+
pending: "pending";
|
|
13
13
|
active: "active";
|
|
14
|
+
deleted: "deleted";
|
|
14
15
|
suspended: "suspended";
|
|
15
|
-
pending: "pending";
|
|
16
16
|
}>;
|
|
17
17
|
updatedAt: z.ZodCustom<Timestamp, Timestamp>;
|
|
18
18
|
verified: z.ZodBoolean;
|
package/dist/types/recipe.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export declare const RecipeMetaSchema: z.ZodObject<{
|
|
|
20
20
|
createdAt: z.ZodCustom<Timestamp, Timestamp>;
|
|
21
21
|
createdBy: z.ZodString;
|
|
22
22
|
cuisine: z.ZodEnum<{
|
|
23
|
-
other: "other";
|
|
24
23
|
african: "african";
|
|
25
24
|
american: "american";
|
|
26
25
|
brazilian: "brazilian";
|
|
@@ -53,6 +52,7 @@ export declare const RecipeMetaSchema: z.ZodObject<{
|
|
|
53
52
|
thai: "thai";
|
|
54
53
|
turkish: "turkish";
|
|
55
54
|
vietnamese: "vietnamese";
|
|
55
|
+
other: "other";
|
|
56
56
|
}>;
|
|
57
57
|
deletedAt: z.ZodOptional<z.ZodCustom<Timestamp, Timestamp>>;
|
|
58
58
|
dietaryTags: z.ZodArray<z.ZodEnum<{
|
|
@@ -73,28 +73,23 @@ export declare const RecipeMetaSchema: z.ZodObject<{
|
|
|
73
73
|
vegetarian: "vegetarian";
|
|
74
74
|
}>>;
|
|
75
75
|
difficulty: z.ZodEnum<{
|
|
76
|
-
advanced: "advanced";
|
|
77
76
|
beginner: "beginner";
|
|
78
77
|
intermediate: "intermediate";
|
|
78
|
+
advanced: "advanced";
|
|
79
79
|
expert: "expert";
|
|
80
80
|
}>;
|
|
81
81
|
equipment: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
82
|
-
|
|
82
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
83
83
|
slug: z.ZodString;
|
|
84
84
|
}, z.core.$strip>>>;
|
|
85
85
|
id: z.ZodString;
|
|
86
86
|
imageUrl: z.ZodOptional<z.ZodString>;
|
|
87
87
|
ingredientSections: z.ZodArray<z.ZodObject<{
|
|
88
88
|
ingredients: z.ZodArray<z.ZodObject<{
|
|
89
|
-
optional: z.ZodOptional<z.ZodBoolean>;
|
|
90
89
|
quantity: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
91
91
|
slug: z.ZodString;
|
|
92
92
|
unit: z.ZodOptional<z.ZodEnum<{
|
|
93
|
-
slice: "slice";
|
|
94
|
-
head: "head";
|
|
95
|
-
g: "g";
|
|
96
|
-
drop: "drop";
|
|
97
|
-
quarter: "quarter";
|
|
98
93
|
ml: "ml";
|
|
99
94
|
l: "l";
|
|
100
95
|
tsp: "tsp";
|
|
@@ -105,18 +100,22 @@ export declare const RecipeMetaSchema: z.ZodObject<{
|
|
|
105
100
|
quart: "quart";
|
|
106
101
|
gallon: "gallon";
|
|
107
102
|
mg: "mg";
|
|
103
|
+
g: "g";
|
|
108
104
|
kg: "kg";
|
|
109
105
|
oz: "oz";
|
|
110
106
|
lb: "lb";
|
|
111
107
|
piece: "piece";
|
|
112
108
|
whole: "whole";
|
|
113
109
|
half: "half";
|
|
110
|
+
quarter: "quarter";
|
|
111
|
+
slice: "slice";
|
|
114
112
|
serving: "serving";
|
|
115
113
|
clove: "clove";
|
|
116
114
|
stalk: "stalk";
|
|
117
115
|
sprig: "sprig";
|
|
118
116
|
leaf: "leaf";
|
|
119
117
|
bunch: "bunch";
|
|
118
|
+
head: "head";
|
|
120
119
|
fillet: "fillet";
|
|
121
120
|
stick: "stick";
|
|
122
121
|
sheet: "sheet";
|
|
@@ -127,6 +126,7 @@ export declare const RecipeMetaSchema: z.ZodObject<{
|
|
|
127
126
|
handful: "handful";
|
|
128
127
|
pinch: "pinch";
|
|
129
128
|
dash: "dash";
|
|
129
|
+
drop: "drop";
|
|
130
130
|
}>>;
|
|
131
131
|
}, z.core.$strip>>;
|
|
132
132
|
slug: z.ZodString;
|
|
@@ -172,22 +172,22 @@ export declare const RecipeMetaSchema: z.ZodObject<{
|
|
|
172
172
|
}>;
|
|
173
173
|
servings: z.ZodNumber;
|
|
174
174
|
source: z.ZodEnum<{
|
|
175
|
-
url: "url";
|
|
176
|
-
video: "video";
|
|
177
175
|
image: "image";
|
|
178
176
|
text: "text";
|
|
177
|
+
url: "url";
|
|
178
|
+
video: "video";
|
|
179
179
|
}>;
|
|
180
180
|
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
181
181
|
spiciness: z.ZodEnum<{
|
|
182
|
-
none: "none";
|
|
183
182
|
medium: "medium";
|
|
183
|
+
none: "none";
|
|
184
184
|
mild: "mild";
|
|
185
185
|
hot: "hot";
|
|
186
186
|
}>;
|
|
187
187
|
status: z.ZodEnum<{
|
|
188
|
-
deleted: "deleted";
|
|
189
|
-
active: "active";
|
|
190
188
|
pending: "pending";
|
|
189
|
+
active: "active";
|
|
190
|
+
deleted: "deleted";
|
|
191
191
|
archived: "archived";
|
|
192
192
|
}>;
|
|
193
193
|
time: z.ZodNumber;
|
|
@@ -245,7 +245,6 @@ export declare const RecipeSchema: z.ZodObject<{
|
|
|
245
245
|
createdAt: z.ZodCustom<Timestamp, Timestamp>;
|
|
246
246
|
createdBy: z.ZodString;
|
|
247
247
|
cuisine: z.ZodEnum<{
|
|
248
|
-
other: "other";
|
|
249
248
|
african: "african";
|
|
250
249
|
american: "american";
|
|
251
250
|
brazilian: "brazilian";
|
|
@@ -278,6 +277,7 @@ export declare const RecipeSchema: z.ZodObject<{
|
|
|
278
277
|
thai: "thai";
|
|
279
278
|
turkish: "turkish";
|
|
280
279
|
vietnamese: "vietnamese";
|
|
280
|
+
other: "other";
|
|
281
281
|
}>;
|
|
282
282
|
deletedAt: z.ZodOptional<z.ZodCustom<Timestamp, Timestamp>>;
|
|
283
283
|
description: z.ZodString;
|
|
@@ -299,16 +299,16 @@ export declare const RecipeSchema: z.ZodObject<{
|
|
|
299
299
|
vegetarian: "vegetarian";
|
|
300
300
|
}>>;
|
|
301
301
|
difficulty: z.ZodEnum<{
|
|
302
|
-
advanced: "advanced";
|
|
303
302
|
beginner: "beginner";
|
|
304
303
|
intermediate: "intermediate";
|
|
304
|
+
advanced: "advanced";
|
|
305
305
|
expert: "expert";
|
|
306
306
|
}>;
|
|
307
307
|
equipment: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
308
308
|
name: z.ZodString;
|
|
309
309
|
notes: z.ZodOptional<z.ZodString>;
|
|
310
310
|
slug: z.ZodString;
|
|
311
|
-
|
|
311
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
312
312
|
}, z.core.$strip>>>;
|
|
313
313
|
id: z.ZodString;
|
|
314
314
|
imageUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -317,14 +317,9 @@ export declare const RecipeSchema: z.ZodObject<{
|
|
|
317
317
|
name: z.ZodString;
|
|
318
318
|
notes: z.ZodOptional<z.ZodString>;
|
|
319
319
|
slug: z.ZodString;
|
|
320
|
-
optional: z.ZodOptional<z.ZodBoolean>;
|
|
321
320
|
quantity: z.ZodOptional<z.ZodNumber>;
|
|
321
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
322
322
|
unit: z.ZodOptional<z.ZodEnum<{
|
|
323
|
-
slice: "slice";
|
|
324
|
-
head: "head";
|
|
325
|
-
g: "g";
|
|
326
|
-
drop: "drop";
|
|
327
|
-
quarter: "quarter";
|
|
328
323
|
ml: "ml";
|
|
329
324
|
l: "l";
|
|
330
325
|
tsp: "tsp";
|
|
@@ -335,18 +330,22 @@ export declare const RecipeSchema: z.ZodObject<{
|
|
|
335
330
|
quart: "quart";
|
|
336
331
|
gallon: "gallon";
|
|
337
332
|
mg: "mg";
|
|
333
|
+
g: "g";
|
|
338
334
|
kg: "kg";
|
|
339
335
|
oz: "oz";
|
|
340
336
|
lb: "lb";
|
|
341
337
|
piece: "piece";
|
|
342
338
|
whole: "whole";
|
|
343
339
|
half: "half";
|
|
340
|
+
quarter: "quarter";
|
|
341
|
+
slice: "slice";
|
|
344
342
|
serving: "serving";
|
|
345
343
|
clove: "clove";
|
|
346
344
|
stalk: "stalk";
|
|
347
345
|
sprig: "sprig";
|
|
348
346
|
leaf: "leaf";
|
|
349
347
|
bunch: "bunch";
|
|
348
|
+
head: "head";
|
|
350
349
|
fillet: "fillet";
|
|
351
350
|
stick: "stick";
|
|
352
351
|
sheet: "sheet";
|
|
@@ -357,6 +356,7 @@ export declare const RecipeSchema: z.ZodObject<{
|
|
|
357
356
|
handful: "handful";
|
|
358
357
|
pinch: "pinch";
|
|
359
358
|
dash: "dash";
|
|
359
|
+
drop: "drop";
|
|
360
360
|
}>>;
|
|
361
361
|
}, z.core.$strip>>;
|
|
362
362
|
slug: z.ZodString;
|
|
@@ -411,22 +411,22 @@ export declare const RecipeSchema: z.ZodObject<{
|
|
|
411
411
|
}>;
|
|
412
412
|
servings: z.ZodNumber;
|
|
413
413
|
source: z.ZodEnum<{
|
|
414
|
-
url: "url";
|
|
415
|
-
video: "video";
|
|
416
414
|
image: "image";
|
|
417
415
|
text: "text";
|
|
416
|
+
url: "url";
|
|
417
|
+
video: "video";
|
|
418
418
|
}>;
|
|
419
419
|
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
420
420
|
spiciness: z.ZodEnum<{
|
|
421
|
-
none: "none";
|
|
422
421
|
medium: "medium";
|
|
422
|
+
none: "none";
|
|
423
423
|
mild: "mild";
|
|
424
424
|
hot: "hot";
|
|
425
425
|
}>;
|
|
426
426
|
status: z.ZodEnum<{
|
|
427
|
-
deleted: "deleted";
|
|
428
|
-
active: "active";
|
|
429
427
|
pending: "pending";
|
|
428
|
+
active: "active";
|
|
429
|
+
deleted: "deleted";
|
|
430
430
|
archived: "archived";
|
|
431
431
|
}>;
|
|
432
432
|
time: z.ZodNumber;
|
package/dist/types/user.d.ts
CHANGED
|
@@ -7,17 +7,17 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
7
7
|
id: z.ZodString;
|
|
8
8
|
name: z.ZodString;
|
|
9
9
|
role: z.ZodEnum<{
|
|
10
|
-
user: "user";
|
|
11
10
|
admin: "admin";
|
|
12
11
|
moderator: "moderator";
|
|
13
12
|
translator: "translator";
|
|
13
|
+
user: "user";
|
|
14
14
|
guest: "guest";
|
|
15
15
|
}>;
|
|
16
16
|
status: z.ZodEnum<{
|
|
17
|
-
|
|
17
|
+
pending: "pending";
|
|
18
18
|
active: "active";
|
|
19
|
+
deleted: "deleted";
|
|
19
20
|
suspended: "suspended";
|
|
20
|
-
pending: "pending";
|
|
21
21
|
}>;
|
|
22
22
|
subscriptionId: z.ZodOptional<z.ZodString>;
|
|
23
23
|
updatedAt: z.ZodCustom<Timestamp, Timestamp>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cravery/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Clean architecture foundation for Cravery",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@genkit-ai/
|
|
18
|
+
"@genkit-ai/google-genai": "^1.27.0",
|
|
19
19
|
"genkit": "^1.27.0",
|
|
20
20
|
"zod": "^4.3.5"
|
|
21
21
|
},
|
package/src/config/ai.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AIConfig } from "../types";
|
|
2
|
+
|
|
3
|
+
export const AI_MODELS: AIConfig = {
|
|
4
|
+
Gemini25Flash: {
|
|
5
|
+
id: "vertexai/gemini-2.5-flash",
|
|
6
|
+
name: "Gemini 2.5 Flash",
|
|
7
|
+
type: "multimodal",
|
|
8
|
+
cost: { input: 0.3, output: 2.5 },
|
|
9
|
+
},
|
|
10
|
+
Gemini25Pro: {
|
|
11
|
+
id: "vertexai/gemini-2.5-pro",
|
|
12
|
+
name: "Gemini 2.5 Pro",
|
|
13
|
+
type: "multimodal",
|
|
14
|
+
cost: { input: 1.25, output: 10.0 },
|
|
15
|
+
},
|
|
16
|
+
Gemini3Flash: {
|
|
17
|
+
id: "vertexai/gemini-3.0-flash",
|
|
18
|
+
name: "Gemini 3 Flash",
|
|
19
|
+
type: "multimodal",
|
|
20
|
+
cost: { input: 0.5, output: 3.0 },
|
|
21
|
+
},
|
|
22
|
+
Imagen4Fast: {
|
|
23
|
+
id: "vertexai/imagen-4.0-fast-generate-001",
|
|
24
|
+
name: "Imagen 4 Fast",
|
|
25
|
+
type: "image",
|
|
26
|
+
cost: { input: 0, output: 0.02 },
|
|
27
|
+
},
|
|
28
|
+
GeminiEmbedding001: {
|
|
29
|
+
id: "vertexai/gemini-embedding-001",
|
|
30
|
+
name: "Gemini Embedding 001",
|
|
31
|
+
type: "embedding",
|
|
32
|
+
cost: { input: 0.00015, output: 0 },
|
|
33
|
+
},
|
|
34
|
+
};
|
package/src/config/index.ts
CHANGED
package/src/lib/api.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onCall,
|
|
3
|
+
HttpsError,
|
|
4
|
+
CallableRequest,
|
|
5
|
+
CallableOptions,
|
|
6
|
+
} from "firebase-functions/v2/https";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { isAdmin, isModerator } from "./iam";
|
|
9
|
+
|
|
10
|
+
const DEFAULT_OPTIONS: CallableOptions = { cors: true, enforceAppCheck: true };
|
|
11
|
+
|
|
12
|
+
const handleError = (error: unknown): never => {
|
|
13
|
+
if (error instanceof z.ZodError) {
|
|
14
|
+
throw new HttpsError(
|
|
15
|
+
"invalid-argument",
|
|
16
|
+
`Validation failed: ${error.message}`,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
if (error instanceof HttpsError) {
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
throw new HttpsError(
|
|
23
|
+
"internal",
|
|
24
|
+
error instanceof Error ? error.message : "Unknown error",
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
class CallableBuilder<T> {
|
|
29
|
+
private requiresAuth = false;
|
|
30
|
+
private requiresAdmin = false;
|
|
31
|
+
private requiresModerator = false;
|
|
32
|
+
private options: CallableOptions = DEFAULT_OPTIONS;
|
|
33
|
+
|
|
34
|
+
constructor(private schema: z.ZodSchema<T>) {}
|
|
35
|
+
|
|
36
|
+
withOptions(options: CallableOptions) {
|
|
37
|
+
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
requireUser() {
|
|
42
|
+
this.requiresAuth = true;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
requireAdmin() {
|
|
47
|
+
this.requiresAuth = true;
|
|
48
|
+
this.requiresAdmin = true;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
requireModerator() {
|
|
53
|
+
this.requiresAuth = true;
|
|
54
|
+
this.requiresModerator = true;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
handle<R>(handler: (data: T, request: CallableRequest) => Promise<R>) {
|
|
59
|
+
return onCall(this.options, async (request) => {
|
|
60
|
+
if (this.requiresAuth && !request.auth) {
|
|
61
|
+
throw new HttpsError("unauthenticated", "Authentication required");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (request.auth) {
|
|
65
|
+
const uid = request.auth.uid;
|
|
66
|
+
|
|
67
|
+
if (this.requiresAdmin && !(await isAdmin(uid))) {
|
|
68
|
+
throw new HttpsError("permission-denied", "Admin access required");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (this.requiresModerator && !(await isModerator(uid))) {
|
|
72
|
+
throw new HttpsError(
|
|
73
|
+
"permission-denied",
|
|
74
|
+
"Moderator access required",
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
const data = this.schema.parse(request.data);
|
|
81
|
+
return await handler(data, request);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
throw handleError(error);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const callable = <T>(schema: z.ZodSchema<T>) =>
|
|
90
|
+
new CallableBuilder(schema);
|