@tbs-fitness/contract 0.4.0 → 0.6.0
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/README.md +25 -0
- package/dist/cjs/auth/auth.dto.d.ts +4 -4
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +1 -0
- package/dist/cjs/auth/otp.dto.d.ts +45 -0
- package/dist/cjs/auth/otp.dto.js +39 -0
- package/dist/cjs/client/client-auth.dto.d.ts +81 -0
- package/dist/cjs/client/client-auth.dto.js +49 -0
- package/dist/cjs/client/index.d.ts +2 -0
- package/dist/cjs/client/index.js +18 -0
- package/dist/cjs/coach/coach-auth.dto.d.ts +0 -40
- package/dist/cjs/coach/coach-auth.dto.js +1 -30
- package/dist/cjs/coach/index.d.ts +1 -0
- package/dist/cjs/coach/index.js +1 -0
- package/dist/cjs/enums/index.d.ts +40 -2
- package/dist/cjs/enums/index.js +58 -3
- package/dist/cjs/feature-flags/feature-flag.dto.d.ts +4 -4
- package/dist/cjs/feature-flags/feature-flag.dto.js +1 -1
- package/dist/cjs/food/client-food.dto.d.ts +49 -0
- package/dist/cjs/food/client-food.dto.js +26 -0
- package/dist/cjs/food/food-import.dto.d.ts +160 -0
- package/dist/cjs/food/food-import.dto.js +110 -0
- package/dist/cjs/food/food-suggestion.dto.d.ts +374 -0
- package/dist/cjs/food/food-suggestion.dto.js +170 -0
- package/dist/cjs/food/food.dto.d.ts +339 -0
- package/dist/cjs/food/food.dto.js +256 -0
- package/dist/cjs/food/index.d.ts +5 -0
- package/dist/cjs/food/index.js +21 -0
- package/dist/cjs/food/nutrition.d.ts +75 -0
- package/dist/cjs/food/nutrition.js +158 -0
- package/dist/esm/auth/auth.dto.d.ts +4 -4
- package/dist/esm/auth/index.d.ts +1 -0
- package/dist/esm/auth/index.js +1 -0
- package/dist/esm/auth/otp.dto.d.ts +45 -0
- package/dist/esm/auth/otp.dto.js +36 -0
- package/dist/esm/client/client-auth.dto.d.ts +81 -0
- package/dist/esm/client/client-auth.dto.js +46 -0
- package/dist/esm/client/index.d.ts +2 -0
- package/dist/esm/client/index.js +2 -0
- package/dist/esm/coach/coach-auth.dto.d.ts +0 -40
- package/dist/esm/coach/coach-auth.dto.js +1 -30
- package/dist/esm/coach/index.d.ts +1 -0
- package/dist/esm/coach/index.js +1 -0
- package/dist/esm/enums/index.d.ts +40 -2
- package/dist/esm/enums/index.js +57 -2
- package/dist/esm/feature-flags/feature-flag.dto.d.ts +4 -4
- package/dist/esm/feature-flags/feature-flag.dto.js +1 -1
- package/dist/esm/food/client-food.dto.d.ts +49 -0
- package/dist/esm/food/client-food.dto.js +23 -0
- package/dist/esm/food/food-import.dto.d.ts +160 -0
- package/dist/esm/food/food-import.dto.js +107 -0
- package/dist/esm/food/food-suggestion.dto.d.ts +374 -0
- package/dist/esm/food/food-suggestion.dto.js +167 -0
- package/dist/esm/food/food.dto.d.ts +339 -0
- package/dist/esm/food/food.dto.js +253 -0
- package/dist/esm/food/index.d.ts +5 -0
- package/dist/esm/food/index.js +5 -0
- package/dist/esm/food/nutrition.d.ts +75 -0
- package/dist/esm/food/nutrition.js +144 -0
- package/package.json +21 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const MAX_FOOD_NAME_LENGTH = 120;
|
|
3
|
+
export declare const MAX_FOOD_NOTES_LENGTH = 1000;
|
|
4
|
+
export declare const MAX_FOOD_METADATA_VALUES = 50;
|
|
5
|
+
export declare const MAX_FOOD_SEARCH_LENGTH = 100;
|
|
6
|
+
export declare const foodIdParamSchema: z.ZodUUID;
|
|
7
|
+
export declare const metadataTypeIdParamSchema: z.ZodUUID;
|
|
8
|
+
export declare const metadataValueIdParamSchema: z.ZodUUID;
|
|
9
|
+
export declare const servingSchema: z.ZodObject<{
|
|
10
|
+
label: z.ZodString;
|
|
11
|
+
quantity: z.ZodNumber;
|
|
12
|
+
unit: z.ZodEnum<{
|
|
13
|
+
g: "g";
|
|
14
|
+
ml: "ml";
|
|
15
|
+
}>;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export type ServingInput = z.input<typeof servingSchema>;
|
|
18
|
+
/**
|
|
19
|
+
* Nutrient values as entered. `basis` says whether they are per 100 units of
|
|
20
|
+
* the serving unit or for one serving; the API stores them per 100.
|
|
21
|
+
*/
|
|
22
|
+
export declare const nutritionInputSchema: z.ZodObject<{
|
|
23
|
+
basis: z.ZodDefault<z.ZodEnum<{
|
|
24
|
+
PER_100: "PER_100";
|
|
25
|
+
PER_SERVING: "PER_SERVING";
|
|
26
|
+
}>>;
|
|
27
|
+
calories: z.ZodNumber;
|
|
28
|
+
protein: z.ZodNumber;
|
|
29
|
+
carbs: z.ZodNumber;
|
|
30
|
+
fat: z.ZodNumber;
|
|
31
|
+
sugar: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
32
|
+
fiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
33
|
+
solubleFiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
|
+
insolubleFiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
export type NutritionInput = z.input<typeof nutritionInputSchema>;
|
|
37
|
+
export type NutritionBody = z.output<typeof nutritionInputSchema>;
|
|
38
|
+
export declare const createFoodSchema: z.ZodObject<{
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
nameHi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
namePa: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
englishAlias: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
|
+
serving: z.ZodObject<{
|
|
44
|
+
label: z.ZodString;
|
|
45
|
+
quantity: z.ZodNumber;
|
|
46
|
+
unit: z.ZodEnum<{
|
|
47
|
+
g: "g";
|
|
48
|
+
ml: "ml";
|
|
49
|
+
}>;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
nutrition: z.ZodObject<{
|
|
52
|
+
basis: z.ZodDefault<z.ZodEnum<{
|
|
53
|
+
PER_100: "PER_100";
|
|
54
|
+
PER_SERVING: "PER_SERVING";
|
|
55
|
+
}>>;
|
|
56
|
+
calories: z.ZodNumber;
|
|
57
|
+
protein: z.ZodNumber;
|
|
58
|
+
carbs: z.ZodNumber;
|
|
59
|
+
fat: z.ZodNumber;
|
|
60
|
+
sugar: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
61
|
+
fiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
62
|
+
solubleFiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
63
|
+
insolubleFiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
metadataValueIds: z.ZodDefault<z.ZodArray<z.ZodUUID>>;
|
|
66
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
export type CreateFoodInput = z.input<typeof createFoodSchema>;
|
|
69
|
+
export type CreateFoodBody = z.output<typeof createFoodSchema>;
|
|
70
|
+
export declare const updateFoodSchema: z.ZodObject<{
|
|
71
|
+
version: z.ZodNumber;
|
|
72
|
+
name: z.ZodOptional<z.ZodString>;
|
|
73
|
+
nameHi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
74
|
+
namePa: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
75
|
+
englishAlias: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
76
|
+
serving: z.ZodOptional<z.ZodObject<{
|
|
77
|
+
label: z.ZodString;
|
|
78
|
+
quantity: z.ZodNumber;
|
|
79
|
+
unit: z.ZodEnum<{
|
|
80
|
+
g: "g";
|
|
81
|
+
ml: "ml";
|
|
82
|
+
}>;
|
|
83
|
+
}, z.core.$strict>>;
|
|
84
|
+
nutrition: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
basis: z.ZodDefault<z.ZodEnum<{
|
|
86
|
+
PER_100: "PER_100";
|
|
87
|
+
PER_SERVING: "PER_SERVING";
|
|
88
|
+
}>>;
|
|
89
|
+
calories: z.ZodNumber;
|
|
90
|
+
protein: z.ZodNumber;
|
|
91
|
+
carbs: z.ZodNumber;
|
|
92
|
+
fat: z.ZodNumber;
|
|
93
|
+
sugar: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
94
|
+
fiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
95
|
+
solubleFiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
96
|
+
insolubleFiber: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
97
|
+
}, z.core.$strict>>;
|
|
98
|
+
metadataValueIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
99
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
export type UpdateFoodInput = z.input<typeof updateFoodSchema>;
|
|
102
|
+
export type UpdateFoodBody = z.output<typeof updateFoodSchema>;
|
|
103
|
+
/**
|
|
104
|
+
* `metadata` filters by value ids: a food matches when it has at least one of
|
|
105
|
+
* the listed values of each type that appears in the list.
|
|
106
|
+
*/
|
|
107
|
+
export declare const foodListQuerySchema: z.ZodObject<{
|
|
108
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
109
|
+
pageSize: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
110
|
+
search: z.ZodOptional<z.ZodString>;
|
|
111
|
+
metadata: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodUUID>>, unknown>;
|
|
112
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
113
|
+
ADMIN: "ADMIN";
|
|
114
|
+
COACH: "COACH";
|
|
115
|
+
CLIENT_SUGGESTION: "CLIENT_SUGGESTION";
|
|
116
|
+
IMPORT: "IMPORT";
|
|
117
|
+
}>>;
|
|
118
|
+
sort: z.ZodDefault<z.ZodEnum<{
|
|
119
|
+
name: "name";
|
|
120
|
+
updatedAt: "updatedAt";
|
|
121
|
+
calories: "calories";
|
|
122
|
+
protein: "protein";
|
|
123
|
+
}>>;
|
|
124
|
+
order: z.ZodDefault<z.ZodEnum<{
|
|
125
|
+
asc: "asc";
|
|
126
|
+
desc: "desc";
|
|
127
|
+
}>>;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
export type FoodListQuery = z.output<typeof foodListQuerySchema>;
|
|
130
|
+
export declare const similarFoodQuerySchema: z.ZodObject<{
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
export type SimilarFoodQuery = z.output<typeof similarFoodQuerySchema>;
|
|
134
|
+
export declare const nutrientValuesResponseSchema: z.ZodObject<{
|
|
135
|
+
calories: z.ZodNumber;
|
|
136
|
+
protein: z.ZodNumber;
|
|
137
|
+
carbs: z.ZodNumber;
|
|
138
|
+
fat: z.ZodNumber;
|
|
139
|
+
sugar: z.ZodNullable<z.ZodNumber>;
|
|
140
|
+
fiber: z.ZodNullable<z.ZodNumber>;
|
|
141
|
+
solubleFiber: z.ZodNullable<z.ZodNumber>;
|
|
142
|
+
insolubleFiber: z.ZodNullable<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
export type NutrientValuesResponse = z.output<typeof nutrientValuesResponseSchema>;
|
|
145
|
+
export declare const servingResponseSchema: z.ZodObject<{
|
|
146
|
+
label: z.ZodString;
|
|
147
|
+
quantity: z.ZodNumber;
|
|
148
|
+
unit: z.ZodEnum<{
|
|
149
|
+
g: "g";
|
|
150
|
+
ml: "ml";
|
|
151
|
+
}>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
export type ServingResponse = z.output<typeof servingResponseSchema>;
|
|
154
|
+
/** A metadata value as attached to a food. */
|
|
155
|
+
export declare const foodMetadataRefSchema: z.ZodObject<{
|
|
156
|
+
id: z.ZodUUID;
|
|
157
|
+
typeKey: z.ZodString;
|
|
158
|
+
key: z.ZodString;
|
|
159
|
+
label: z.ZodString;
|
|
160
|
+
isActive: z.ZodBoolean;
|
|
161
|
+
}, z.core.$strip>;
|
|
162
|
+
export type FoodMetadataRef = z.output<typeof foodMetadataRefSchema>;
|
|
163
|
+
export declare const userRefSchema: z.ZodObject<{
|
|
164
|
+
id: z.ZodUUID;
|
|
165
|
+
fullName: z.ZodNullable<z.ZodString>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export type UserRef = z.output<typeof userRefSchema>;
|
|
168
|
+
export declare const foodResponseSchema: z.ZodObject<{
|
|
169
|
+
id: z.ZodUUID;
|
|
170
|
+
name: z.ZodString;
|
|
171
|
+
nameHi: z.ZodNullable<z.ZodString>;
|
|
172
|
+
namePa: z.ZodNullable<z.ZodString>;
|
|
173
|
+
englishAlias: z.ZodNullable<z.ZodString>;
|
|
174
|
+
serving: z.ZodObject<{
|
|
175
|
+
label: z.ZodString;
|
|
176
|
+
quantity: z.ZodNumber;
|
|
177
|
+
unit: z.ZodEnum<{
|
|
178
|
+
g: "g";
|
|
179
|
+
ml: "ml";
|
|
180
|
+
}>;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
per100: z.ZodObject<{
|
|
183
|
+
calories: z.ZodNumber;
|
|
184
|
+
protein: z.ZodNumber;
|
|
185
|
+
carbs: z.ZodNumber;
|
|
186
|
+
fat: z.ZodNumber;
|
|
187
|
+
sugar: z.ZodNullable<z.ZodNumber>;
|
|
188
|
+
fiber: z.ZodNullable<z.ZodNumber>;
|
|
189
|
+
solubleFiber: z.ZodNullable<z.ZodNumber>;
|
|
190
|
+
insolubleFiber: z.ZodNullable<z.ZodNumber>;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
perServing: z.ZodObject<{
|
|
193
|
+
calories: z.ZodNumber;
|
|
194
|
+
protein: z.ZodNumber;
|
|
195
|
+
carbs: z.ZodNumber;
|
|
196
|
+
fat: z.ZodNumber;
|
|
197
|
+
sugar: z.ZodNullable<z.ZodNumber>;
|
|
198
|
+
fiber: z.ZodNullable<z.ZodNumber>;
|
|
199
|
+
solubleFiber: z.ZodNullable<z.ZodNumber>;
|
|
200
|
+
insolubleFiber: z.ZodNullable<z.ZodNumber>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
formulaCalories: z.ZodNumber;
|
|
203
|
+
metadata: z.ZodArray<z.ZodObject<{
|
|
204
|
+
id: z.ZodUUID;
|
|
205
|
+
typeKey: z.ZodString;
|
|
206
|
+
key: z.ZodString;
|
|
207
|
+
label: z.ZodString;
|
|
208
|
+
isActive: z.ZodBoolean;
|
|
209
|
+
}, z.core.$strip>>;
|
|
210
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
211
|
+
source: z.ZodEnum<{
|
|
212
|
+
ADMIN: "ADMIN";
|
|
213
|
+
COACH: "COACH";
|
|
214
|
+
CLIENT_SUGGESTION: "CLIENT_SUGGESTION";
|
|
215
|
+
IMPORT: "IMPORT";
|
|
216
|
+
}>;
|
|
217
|
+
createdBy: z.ZodObject<{
|
|
218
|
+
id: z.ZodUUID;
|
|
219
|
+
fullName: z.ZodNullable<z.ZodString>;
|
|
220
|
+
}, z.core.$strip>;
|
|
221
|
+
suggestionId: z.ZodNullable<z.ZodUUID>;
|
|
222
|
+
importBatchId: z.ZodNullable<z.ZodUUID>;
|
|
223
|
+
version: z.ZodNumber;
|
|
224
|
+
createdAt: z.ZodISODateTime;
|
|
225
|
+
updatedAt: z.ZodISODateTime;
|
|
226
|
+
}, z.core.$strip>;
|
|
227
|
+
export type FoodResponse = z.output<typeof foodResponseSchema>;
|
|
228
|
+
export declare const similarFoodResponseSchema: z.ZodObject<{
|
|
229
|
+
id: z.ZodUUID;
|
|
230
|
+
name: z.ZodString;
|
|
231
|
+
serving: z.ZodObject<{
|
|
232
|
+
label: z.ZodString;
|
|
233
|
+
quantity: z.ZodNumber;
|
|
234
|
+
unit: z.ZodEnum<{
|
|
235
|
+
g: "g";
|
|
236
|
+
ml: "ml";
|
|
237
|
+
}>;
|
|
238
|
+
}, z.core.$strip>;
|
|
239
|
+
per100: z.ZodObject<{
|
|
240
|
+
calories: z.ZodNumber;
|
|
241
|
+
protein: z.ZodNumber;
|
|
242
|
+
carbs: z.ZodNumber;
|
|
243
|
+
fat: z.ZodNumber;
|
|
244
|
+
sugar: z.ZodNullable<z.ZodNumber>;
|
|
245
|
+
fiber: z.ZodNullable<z.ZodNumber>;
|
|
246
|
+
solubleFiber: z.ZodNullable<z.ZodNumber>;
|
|
247
|
+
insolubleFiber: z.ZodNullable<z.ZodNumber>;
|
|
248
|
+
}, z.core.$strip>;
|
|
249
|
+
similarity: z.ZodNumber;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
export type SimilarFoodResponse = z.output<typeof similarFoodResponseSchema>;
|
|
252
|
+
export declare const foodStatsResponseSchema: z.ZodObject<{
|
|
253
|
+
totalFoods: z.ZodNumber;
|
|
254
|
+
categories: z.ZodArray<z.ZodObject<{
|
|
255
|
+
valueId: z.ZodUUID;
|
|
256
|
+
key: z.ZodString;
|
|
257
|
+
label: z.ZodString;
|
|
258
|
+
count: z.ZodNumber;
|
|
259
|
+
}, z.core.$strip>>;
|
|
260
|
+
pendingSuggestions: z.ZodNumber;
|
|
261
|
+
}, z.core.$strip>;
|
|
262
|
+
export type FoodStatsResponse = z.output<typeof foodStatsResponseSchema>;
|
|
263
|
+
export declare const MAX_METADATA_LABEL_LENGTH = 60;
|
|
264
|
+
export declare const metadataTypeResponseSchema: z.ZodObject<{
|
|
265
|
+
id: z.ZodUUID;
|
|
266
|
+
key: z.ZodString;
|
|
267
|
+
label: z.ZodString;
|
|
268
|
+
selection: z.ZodEnum<{
|
|
269
|
+
single: "single";
|
|
270
|
+
multiple: "multiple";
|
|
271
|
+
}>;
|
|
272
|
+
parentTypeId: z.ZodNullable<z.ZodUUID>;
|
|
273
|
+
isRequired: z.ZodBoolean;
|
|
274
|
+
isSystem: z.ZodBoolean;
|
|
275
|
+
isActive: z.ZodBoolean;
|
|
276
|
+
sortOrder: z.ZodNumber;
|
|
277
|
+
}, z.core.$strip>;
|
|
278
|
+
export type MetadataTypeResponse = z.output<typeof metadataTypeResponseSchema>;
|
|
279
|
+
export declare const metadataTypeListResponseSchema: z.ZodArray<z.ZodObject<{
|
|
280
|
+
id: z.ZodUUID;
|
|
281
|
+
key: z.ZodString;
|
|
282
|
+
label: z.ZodString;
|
|
283
|
+
selection: z.ZodEnum<{
|
|
284
|
+
single: "single";
|
|
285
|
+
multiple: "multiple";
|
|
286
|
+
}>;
|
|
287
|
+
parentTypeId: z.ZodNullable<z.ZodUUID>;
|
|
288
|
+
isRequired: z.ZodBoolean;
|
|
289
|
+
isSystem: z.ZodBoolean;
|
|
290
|
+
isActive: z.ZodBoolean;
|
|
291
|
+
sortOrder: z.ZodNumber;
|
|
292
|
+
}, z.core.$strip>>;
|
|
293
|
+
export declare const metadataValueResponseSchema: z.ZodObject<{
|
|
294
|
+
id: z.ZodUUID;
|
|
295
|
+
typeId: z.ZodUUID;
|
|
296
|
+
key: z.ZodString;
|
|
297
|
+
label: z.ZodString;
|
|
298
|
+
parentValueId: z.ZodNullable<z.ZodUUID>;
|
|
299
|
+
isActive: z.ZodBoolean;
|
|
300
|
+
sortOrder: z.ZodNumber;
|
|
301
|
+
createdAt: z.ZodISODateTime;
|
|
302
|
+
updatedAt: z.ZodISODateTime;
|
|
303
|
+
}, z.core.$strip>;
|
|
304
|
+
export type MetadataValueResponse = z.output<typeof metadataValueResponseSchema>;
|
|
305
|
+
export declare const metadataValueListResponseSchema: z.ZodArray<z.ZodObject<{
|
|
306
|
+
id: z.ZodUUID;
|
|
307
|
+
typeId: z.ZodUUID;
|
|
308
|
+
key: z.ZodString;
|
|
309
|
+
label: z.ZodString;
|
|
310
|
+
parentValueId: z.ZodNullable<z.ZodUUID>;
|
|
311
|
+
isActive: z.ZodBoolean;
|
|
312
|
+
sortOrder: z.ZodNumber;
|
|
313
|
+
createdAt: z.ZodISODateTime;
|
|
314
|
+
updatedAt: z.ZodISODateTime;
|
|
315
|
+
}, z.core.$strip>>;
|
|
316
|
+
export declare const metadataValueListQuerySchema: z.ZodObject<{
|
|
317
|
+
includeInactive: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
318
|
+
true: "true";
|
|
319
|
+
false: "false";
|
|
320
|
+
}>, z.ZodTransform<boolean, "true" | "false">>>;
|
|
321
|
+
}, z.core.$strip>;
|
|
322
|
+
export type MetadataValueListQuery = z.output<typeof metadataValueListQuerySchema>;
|
|
323
|
+
/** The key is made from the label, so "High Protein" is stored as `high-protein`. */
|
|
324
|
+
export declare const createMetadataValueSchema: z.ZodObject<{
|
|
325
|
+
label: z.ZodString;
|
|
326
|
+
parentValueId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
|
|
327
|
+
sortOrder: z.ZodDefault<z.ZodNumber>;
|
|
328
|
+
}, z.core.$strict>;
|
|
329
|
+
export type CreateMetadataValueInput = z.input<typeof createMetadataValueSchema>;
|
|
330
|
+
export type CreateMetadataValueBody = z.output<typeof createMetadataValueSchema>;
|
|
331
|
+
/** The key never changes, so renaming a value keeps every link to it. */
|
|
332
|
+
export declare const updateMetadataValueSchema: z.ZodObject<{
|
|
333
|
+
label: z.ZodOptional<z.ZodString>;
|
|
334
|
+
parentValueId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
|
|
335
|
+
sortOrder: z.ZodOptional<z.ZodNumber>;
|
|
336
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
337
|
+
}, z.core.$strict>;
|
|
338
|
+
export type UpdateMetadataValueInput = z.input<typeof updateMetadataValueSchema>;
|
|
339
|
+
export type UpdateMetadataValueBody = z.output<typeof updateMetadataValueSchema>;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateMetadataValueSchema = exports.createMetadataValueSchema = exports.metadataValueListQuerySchema = exports.metadataValueListResponseSchema = exports.metadataValueResponseSchema = exports.metadataTypeListResponseSchema = exports.metadataTypeResponseSchema = exports.MAX_METADATA_LABEL_LENGTH = exports.foodStatsResponseSchema = exports.similarFoodResponseSchema = exports.foodResponseSchema = exports.userRefSchema = exports.foodMetadataRefSchema = exports.servingResponseSchema = exports.nutrientValuesResponseSchema = exports.similarFoodQuerySchema = exports.foodListQuerySchema = exports.updateFoodSchema = exports.createFoodSchema = exports.nutritionInputSchema = exports.servingSchema = exports.metadataValueIdParamSchema = exports.metadataTypeIdParamSchema = exports.foodIdParamSchema = exports.MAX_FOOD_SEARCH_LENGTH = exports.MAX_FOOD_METADATA_VALUES = exports.MAX_FOOD_NOTES_LENGTH = exports.MAX_FOOD_NAME_LENGTH = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const date_time_schema_js_1 = require("../common/date-time.schema.js");
|
|
6
|
+
const pagination_schema_js_1 = require("../common/pagination.schema.js");
|
|
7
|
+
const safe_text_schema_js_1 = require("../common/safe-text.schema.js");
|
|
8
|
+
const index_js_1 = require("../enums/index.js");
|
|
9
|
+
const nutrition_js_1 = require("./nutrition.js");
|
|
10
|
+
// Each request has two types. `*Input` is what a client sends, where fields with
|
|
11
|
+
// a default are optional. `*Body` is what the API receives after validation.
|
|
12
|
+
exports.MAX_FOOD_NAME_LENGTH = 120;
|
|
13
|
+
exports.MAX_FOOD_NOTES_LENGTH = 1000;
|
|
14
|
+
exports.MAX_FOOD_METADATA_VALUES = 50;
|
|
15
|
+
exports.MAX_FOOD_SEARCH_LENGTH = 100;
|
|
16
|
+
exports.foodIdParamSchema = zod_1.z.uuid();
|
|
17
|
+
exports.metadataTypeIdParamSchema = zod_1.z.uuid();
|
|
18
|
+
exports.metadataValueIdParamSchema = zod_1.z.uuid();
|
|
19
|
+
const foodNameSchema = (0, safe_text_schema_js_1.safeTextSchema)(exports.MAX_FOOD_NAME_LENGTH);
|
|
20
|
+
const optionalNameSchema = (0, safe_text_schema_js_1.safeTextSchema)(exports.MAX_FOOD_NAME_LENGTH)
|
|
21
|
+
.nullable()
|
|
22
|
+
.optional();
|
|
23
|
+
exports.servingSchema = zod_1.z.strictObject({
|
|
24
|
+
/** As people say it, e.g. "1 cup (200g)". */
|
|
25
|
+
label: (0, safe_text_schema_js_1.safeTextSchema)(exports.MAX_FOOD_NAME_LENGTH),
|
|
26
|
+
/** The weight or volume of one serving in `unit`, e.g. 200. */
|
|
27
|
+
quantity: (0, nutrition_js_1.quantitySchema)(),
|
|
28
|
+
unit: zod_1.z.enum(index_js_1.SERVING_UNITS),
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Nutrient values as entered. `basis` says whether they are per 100 units of
|
|
32
|
+
* the serving unit or for one serving; the API stores them per 100.
|
|
33
|
+
*/
|
|
34
|
+
exports.nutritionInputSchema = zod_1.z.strictObject({
|
|
35
|
+
basis: zod_1.z.enum(index_js_1.NUTRITION_BASES).default('PER_100'),
|
|
36
|
+
calories: (0, nutrition_js_1.nutrientAmountSchema)(),
|
|
37
|
+
protein: (0, nutrition_js_1.nutrientAmountSchema)(),
|
|
38
|
+
carbs: (0, nutrition_js_1.nutrientAmountSchema)(),
|
|
39
|
+
fat: (0, nutrition_js_1.nutrientAmountSchema)(),
|
|
40
|
+
sugar: (0, nutrition_js_1.nutrientAmountSchema)().nullable().optional(),
|
|
41
|
+
fiber: (0, nutrition_js_1.nutrientAmountSchema)().nullable().optional(),
|
|
42
|
+
solubleFiber: (0, nutrition_js_1.nutrientAmountSchema)().nullable().optional(),
|
|
43
|
+
insolubleFiber: (0, nutrition_js_1.nutrientAmountSchema)().nullable().optional(),
|
|
44
|
+
});
|
|
45
|
+
const uniqueIds = (ids) => new Set(ids).size === ids.length;
|
|
46
|
+
const metadataValueIdsSchema = zod_1.z
|
|
47
|
+
.array(zod_1.z.uuid())
|
|
48
|
+
.max(exports.MAX_FOOD_METADATA_VALUES)
|
|
49
|
+
.refine(uniqueIds, { error: 'Each value may be listed once' });
|
|
50
|
+
/** Adds an issue for every nutrition rule the values break, measured per 100. */
|
|
51
|
+
function checkNutrition(nutrition, servingQuantity, ctx) {
|
|
52
|
+
if (nutrition.basis === 'PER_SERVING' && servingQuantity === undefined) {
|
|
53
|
+
// An update that changes values per serving without a serving uses the
|
|
54
|
+
// stored serving, so the API checks it.
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const per100 = nutrition.basis === 'PER_SERVING' && servingQuantity !== undefined
|
|
58
|
+
? (0, nutrition_js_1.toPer100)(nutrition, servingQuantity)
|
|
59
|
+
: nutrition;
|
|
60
|
+
for (const issue of (0, nutrition_js_1.nutritionIssues)(per100)) {
|
|
61
|
+
ctx.addIssue({
|
|
62
|
+
code: 'custom',
|
|
63
|
+
message: issue.message,
|
|
64
|
+
path: ['nutrition', issue.path],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const foodFields = {
|
|
69
|
+
name: foodNameSchema,
|
|
70
|
+
nameHi: optionalNameSchema,
|
|
71
|
+
namePa: optionalNameSchema,
|
|
72
|
+
englishAlias: (0, safe_text_schema_js_1.safeTextSchema)(200).nullable().optional(),
|
|
73
|
+
serving: exports.servingSchema,
|
|
74
|
+
nutrition: exports.nutritionInputSchema,
|
|
75
|
+
/** Category, subcategory, tags and other labels, by value id. */
|
|
76
|
+
metadataValueIds: metadataValueIdsSchema.default([]),
|
|
77
|
+
notes: (0, safe_text_schema_js_1.safeTextSchema)(exports.MAX_FOOD_NOTES_LENGTH).nullable().optional(),
|
|
78
|
+
};
|
|
79
|
+
// Strict objects reject unknown fields, so an attempt to set `source` or
|
|
80
|
+
// `createdBy` through the API fails loudly.
|
|
81
|
+
exports.createFoodSchema = zod_1.z
|
|
82
|
+
.strictObject(foodFields)
|
|
83
|
+
.superRefine((food, ctx) => checkNutrition(food.nutrition, food.serving.quantity, ctx));
|
|
84
|
+
exports.updateFoodSchema = zod_1.z
|
|
85
|
+
.strictObject({
|
|
86
|
+
// The version last read, so that a stale edit is refused rather than lost.
|
|
87
|
+
version: zod_1.z.number().int().min(1),
|
|
88
|
+
name: foodNameSchema.optional(),
|
|
89
|
+
nameHi: optionalNameSchema,
|
|
90
|
+
namePa: optionalNameSchema,
|
|
91
|
+
englishAlias: (0, safe_text_schema_js_1.safeTextSchema)(200).nullable().optional(),
|
|
92
|
+
serving: exports.servingSchema.optional(),
|
|
93
|
+
/** Replaces every nutrient value; omitted nutrients become unknown. */
|
|
94
|
+
nutrition: exports.nutritionInputSchema.optional(),
|
|
95
|
+
/** Replaces every metadata value. */
|
|
96
|
+
metadataValueIds: metadataValueIdsSchema.optional(),
|
|
97
|
+
notes: (0, safe_text_schema_js_1.safeTextSchema)(exports.MAX_FOOD_NOTES_LENGTH).nullable().optional(),
|
|
98
|
+
})
|
|
99
|
+
.superRefine((food, ctx) => {
|
|
100
|
+
if (food.nutrition) {
|
|
101
|
+
checkNutrition(food.nutrition, food.serving?.quantity, ctx);
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.refine(({ version: _version, ...changes }) => Object.values(changes).some((value) => value !== undefined), { error: 'Provide at least one field to change' });
|
|
105
|
+
const MAX_FILTER_VALUES = 50;
|
|
106
|
+
/** Accepts `a,b` or a repeated parameter, as query strings carry either. */
|
|
107
|
+
const idListQuerySchema = zod_1.z.preprocess((value) => {
|
|
108
|
+
if (typeof value === 'string') {
|
|
109
|
+
return value === ''
|
|
110
|
+
? undefined
|
|
111
|
+
: value
|
|
112
|
+
.split(',')
|
|
113
|
+
.map((part) => part.trim())
|
|
114
|
+
.filter(Boolean);
|
|
115
|
+
}
|
|
116
|
+
// Anything other than a string or a list of strings is left for the schema
|
|
117
|
+
// to reject.
|
|
118
|
+
return value;
|
|
119
|
+
}, zod_1.z.array(zod_1.z.uuid()).max(MAX_FILTER_VALUES).optional());
|
|
120
|
+
const searchQuerySchema = zod_1.z
|
|
121
|
+
.string()
|
|
122
|
+
.trim()
|
|
123
|
+
.min(1)
|
|
124
|
+
.max(exports.MAX_FOOD_SEARCH_LENGTH)
|
|
125
|
+
.optional();
|
|
126
|
+
/**
|
|
127
|
+
* `metadata` filters by value ids: a food matches when it has at least one of
|
|
128
|
+
* the listed values of each type that appears in the list.
|
|
129
|
+
*/
|
|
130
|
+
exports.foodListQuerySchema = pagination_schema_js_1.paginationQuerySchema.extend({
|
|
131
|
+
search: searchQuerySchema,
|
|
132
|
+
metadata: idListQuerySchema,
|
|
133
|
+
source: zod_1.z.enum(index_js_1.FOOD_SOURCES).optional(),
|
|
134
|
+
sort: zod_1.z.enum(index_js_1.FOOD_SORT_FIELDS).default('name'),
|
|
135
|
+
order: zod_1.z.enum(index_js_1.SORT_ORDERS).default('asc'),
|
|
136
|
+
});
|
|
137
|
+
exports.similarFoodQuerySchema = zod_1.z.object({
|
|
138
|
+
name: (0, safe_text_schema_js_1.safeTextSchema)(exports.MAX_FOOD_NAME_LENGTH),
|
|
139
|
+
});
|
|
140
|
+
// Responses
|
|
141
|
+
exports.nutrientValuesResponseSchema = zod_1.z.object({
|
|
142
|
+
calories: zod_1.z.number(),
|
|
143
|
+
protein: zod_1.z.number(),
|
|
144
|
+
carbs: zod_1.z.number(),
|
|
145
|
+
fat: zod_1.z.number(),
|
|
146
|
+
sugar: zod_1.z.number().nullable(),
|
|
147
|
+
fiber: zod_1.z.number().nullable(),
|
|
148
|
+
solubleFiber: zod_1.z.number().nullable(),
|
|
149
|
+
insolubleFiber: zod_1.z.number().nullable(),
|
|
150
|
+
});
|
|
151
|
+
exports.servingResponseSchema = zod_1.z.object({
|
|
152
|
+
label: zod_1.z.string(),
|
|
153
|
+
quantity: zod_1.z.number(),
|
|
154
|
+
unit: zod_1.z.enum(index_js_1.SERVING_UNITS),
|
|
155
|
+
});
|
|
156
|
+
/** A metadata value as attached to a food. */
|
|
157
|
+
exports.foodMetadataRefSchema = zod_1.z.object({
|
|
158
|
+
id: zod_1.z.uuid(),
|
|
159
|
+
typeKey: zod_1.z.string(),
|
|
160
|
+
key: zod_1.z.string(),
|
|
161
|
+
label: zod_1.z.string(),
|
|
162
|
+
isActive: zod_1.z.boolean(),
|
|
163
|
+
});
|
|
164
|
+
exports.userRefSchema = zod_1.z.object({
|
|
165
|
+
id: zod_1.z.uuid(),
|
|
166
|
+
fullName: zod_1.z.string().nullable(),
|
|
167
|
+
});
|
|
168
|
+
exports.foodResponseSchema = zod_1.z.object({
|
|
169
|
+
id: zod_1.z.uuid(),
|
|
170
|
+
name: zod_1.z.string(),
|
|
171
|
+
nameHi: zod_1.z.string().nullable(),
|
|
172
|
+
namePa: zod_1.z.string().nullable(),
|
|
173
|
+
englishAlias: zod_1.z.string().nullable(),
|
|
174
|
+
serving: exports.servingResponseSchema,
|
|
175
|
+
/** Per 100 g, or per 100 ml for a serving in ml. */
|
|
176
|
+
per100: exports.nutrientValuesResponseSchema,
|
|
177
|
+
perServing: exports.nutrientValuesResponseSchema,
|
|
178
|
+
/** Calories from the macros per 100 units: (protein + carbs) × 4 + fat × 9. */
|
|
179
|
+
formulaCalories: zod_1.z.number(),
|
|
180
|
+
metadata: zod_1.z.array(exports.foodMetadataRefSchema),
|
|
181
|
+
notes: zod_1.z.string().nullable(),
|
|
182
|
+
source: zod_1.z.enum(index_js_1.FOOD_SOURCES),
|
|
183
|
+
createdBy: exports.userRefSchema,
|
|
184
|
+
suggestionId: zod_1.z.uuid().nullable(),
|
|
185
|
+
importBatchId: zod_1.z.uuid().nullable(),
|
|
186
|
+
version: zod_1.z.number().int(),
|
|
187
|
+
createdAt: date_time_schema_js_1.utcTimestampSchema,
|
|
188
|
+
updatedAt: date_time_schema_js_1.utcTimestampSchema,
|
|
189
|
+
});
|
|
190
|
+
exports.similarFoodResponseSchema = zod_1.z.object({
|
|
191
|
+
id: zod_1.z.uuid(),
|
|
192
|
+
name: zod_1.z.string(),
|
|
193
|
+
serving: exports.servingResponseSchema,
|
|
194
|
+
per100: exports.nutrientValuesResponseSchema,
|
|
195
|
+
/** 0 to 1; 1 is the same name. */
|
|
196
|
+
similarity: zod_1.z.number(),
|
|
197
|
+
});
|
|
198
|
+
exports.foodStatsResponseSchema = zod_1.z.object({
|
|
199
|
+
totalFoods: zod_1.z.number().int(),
|
|
200
|
+
categories: zod_1.z.array(zod_1.z.object({
|
|
201
|
+
valueId: zod_1.z.uuid(),
|
|
202
|
+
key: zod_1.z.string(),
|
|
203
|
+
label: zod_1.z.string(),
|
|
204
|
+
count: zod_1.z.number().int(),
|
|
205
|
+
})),
|
|
206
|
+
pendingSuggestions: zod_1.z.number().int(),
|
|
207
|
+
});
|
|
208
|
+
// Metadata
|
|
209
|
+
exports.MAX_METADATA_LABEL_LENGTH = 60;
|
|
210
|
+
exports.metadataTypeResponseSchema = zod_1.z.object({
|
|
211
|
+
id: zod_1.z.uuid(),
|
|
212
|
+
key: zod_1.z.string(),
|
|
213
|
+
label: zod_1.z.string(),
|
|
214
|
+
selection: zod_1.z.enum(index_js_1.FOOD_METADATA_SELECTIONS),
|
|
215
|
+
parentTypeId: zod_1.z.uuid().nullable(),
|
|
216
|
+
isRequired: zod_1.z.boolean(),
|
|
217
|
+
isSystem: zod_1.z.boolean(),
|
|
218
|
+
isActive: zod_1.z.boolean(),
|
|
219
|
+
sortOrder: zod_1.z.number().int(),
|
|
220
|
+
});
|
|
221
|
+
exports.metadataTypeListResponseSchema = zod_1.z.array(exports.metadataTypeResponseSchema);
|
|
222
|
+
exports.metadataValueResponseSchema = zod_1.z.object({
|
|
223
|
+
id: zod_1.z.uuid(),
|
|
224
|
+
typeId: zod_1.z.uuid(),
|
|
225
|
+
key: zod_1.z.string(),
|
|
226
|
+
label: zod_1.z.string(),
|
|
227
|
+
parentValueId: zod_1.z.uuid().nullable(),
|
|
228
|
+
isActive: zod_1.z.boolean(),
|
|
229
|
+
sortOrder: zod_1.z.number().int(),
|
|
230
|
+
createdAt: date_time_schema_js_1.utcTimestampSchema,
|
|
231
|
+
updatedAt: date_time_schema_js_1.utcTimestampSchema,
|
|
232
|
+
});
|
|
233
|
+
exports.metadataValueListResponseSchema = zod_1.z.array(exports.metadataValueResponseSchema);
|
|
234
|
+
exports.metadataValueListQuerySchema = zod_1.z.object({
|
|
235
|
+
includeInactive: zod_1.z
|
|
236
|
+
.enum(['true', 'false'])
|
|
237
|
+
.transform((value) => value === 'true')
|
|
238
|
+
.optional(),
|
|
239
|
+
});
|
|
240
|
+
const sortOrderSchema = zod_1.z.number().int().min(0).max(10000);
|
|
241
|
+
/** The key is made from the label, so "High Protein" is stored as `high-protein`. */
|
|
242
|
+
exports.createMetadataValueSchema = zod_1.z.strictObject({
|
|
243
|
+
label: (0, safe_text_schema_js_1.safeTextSchema)(exports.MAX_METADATA_LABEL_LENGTH),
|
|
244
|
+
/** Required for a type with a parent, such as a subcategory's category. */
|
|
245
|
+
parentValueId: zod_1.z.uuid().nullable().optional(),
|
|
246
|
+
sortOrder: sortOrderSchema.default(0),
|
|
247
|
+
});
|
|
248
|
+
/** The key never changes, so renaming a value keeps every link to it. */
|
|
249
|
+
exports.updateMetadataValueSchema = zod_1.z
|
|
250
|
+
.strictObject({
|
|
251
|
+
label: (0, safe_text_schema_js_1.safeTextSchema)(exports.MAX_METADATA_LABEL_LENGTH).optional(),
|
|
252
|
+
parentValueId: zod_1.z.uuid().nullable().optional(),
|
|
253
|
+
sortOrder: sortOrderSchema.optional(),
|
|
254
|
+
isActive: zod_1.z.boolean().optional(),
|
|
255
|
+
})
|
|
256
|
+
.refine((changes) => Object.values(changes).some((value) => value !== undefined), { error: 'Provide at least one field to change' });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client-food.dto.js"), exports);
|
|
18
|
+
__exportStar(require("./food.dto.js"), exports);
|
|
19
|
+
__exportStar(require("./food-import.dto.js"), exports);
|
|
20
|
+
__exportStar(require("./food-suggestion.dto.js"), exports);
|
|
21
|
+
__exportStar(require("./nutrition.js"), exports);
|