@cravery/types 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/common/currency.d.ts +2 -1
  2. package/dist/common/currency.d.ts.map +1 -1
  3. package/dist/common/currency.js +9 -0
  4. package/dist/common/currency.js.map +1 -1
  5. package/dist/common/index.d.ts +1 -3
  6. package/dist/common/index.d.ts.map +1 -1
  7. package/dist/common/index.js +1 -3
  8. package/dist/common/index.js.map +1 -1
  9. package/dist/common/meal_type.d.ts +1 -1
  10. package/dist/common/meal_type.d.ts.map +1 -1
  11. package/dist/common/meal_type.js +3 -1
  12. package/dist/common/meal_type.js.map +1 -1
  13. package/dist/common/measurement.d.ts +3 -0
  14. package/dist/common/measurement.d.ts.map +1 -0
  15. package/dist/common/measurement.js +5 -0
  16. package/dist/common/measurement.js.map +1 -0
  17. package/dist/common/temperature.d.ts +2 -1
  18. package/dist/common/temperature.d.ts.map +1 -1
  19. package/dist/common/temperature.js +2 -0
  20. package/dist/common/temperature.js.map +1 -1
  21. package/dist/common/unit.d.ts +1 -1
  22. package/dist/common/unit.d.ts.map +1 -1
  23. package/dist/common/unit.js +1 -0
  24. package/dist/common/unit.js.map +1 -1
  25. package/dist/core/entity.d.ts +6 -4
  26. package/dist/core/entity.d.ts.map +1 -1
  27. package/dist/core/entity.js +8 -0
  28. package/dist/core/entity.js.map +1 -1
  29. package/dist/core/errors.d.ts +65 -25
  30. package/dist/core/errors.d.ts.map +1 -1
  31. package/dist/core/errors.js +114 -57
  32. package/dist/core/errors.js.map +1 -1
  33. package/dist/core/index.d.ts +0 -1
  34. package/dist/core/index.d.ts.map +1 -1
  35. package/dist/core/index.js +0 -1
  36. package/dist/core/index.js.map +1 -1
  37. package/dist/core/locale.d.ts +3 -0
  38. package/dist/core/locale.d.ts.map +1 -1
  39. package/dist/core/timestamp.d.ts +1 -4
  40. package/dist/core/timestamp.d.ts.map +1 -1
  41. package/dist/equipment/entity.d.ts +4 -9
  42. package/dist/equipment/entity.d.ts.map +1 -1
  43. package/dist/equipment/user.d.ts +4 -5
  44. package/dist/equipment/user.d.ts.map +1 -1
  45. package/dist/feed/recipe.d.ts +3 -3
  46. package/dist/feed/recipe.d.ts.map +1 -1
  47. package/dist/index.d.ts +2 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +2 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/ingredients/entity.d.ts +4 -9
  52. package/dist/ingredients/entity.d.ts.map +1 -1
  53. package/dist/ingredients/user.d.ts +4 -5
  54. package/dist/ingredients/user.d.ts.map +1 -1
  55. package/dist/limits/limits.d.ts +1 -1
  56. package/dist/limits/limits.d.ts.map +1 -1
  57. package/dist/limits/usage.d.ts +7 -2
  58. package/dist/limits/usage.d.ts.map +1 -1
  59. package/dist/recipes/index.d.ts +0 -1
  60. package/dist/recipes/index.d.ts.map +1 -1
  61. package/dist/recipes/index.js +0 -1
  62. package/dist/recipes/index.js.map +1 -1
  63. package/dist/recipes/meta.d.ts +0 -2
  64. package/dist/recipes/meta.d.ts.map +1 -1
  65. package/dist/recipes/recipe.d.ts +0 -2
  66. package/dist/recipes/recipe.d.ts.map +1 -1
  67. package/dist/recipes/request.d.ts +2 -2
  68. package/dist/recipes/request.d.ts.map +1 -1
  69. package/dist/recipes/stats.d.ts +2 -1
  70. package/dist/recipes/stats.d.ts.map +1 -1
  71. package/dist/recipes/user.d.ts +3 -3
  72. package/dist/recipes/user.d.ts.map +1 -1
  73. package/dist/reports/report.d.ts +0 -2
  74. package/dist/reports/report.d.ts.map +1 -1
  75. package/dist/settings/settings.d.ts +1 -0
  76. package/dist/settings/settings.d.ts.map +1 -1
  77. package/dist/shopping/equipment.d.ts +6 -1
  78. package/dist/shopping/equipment.d.ts.map +1 -1
  79. package/dist/shopping/ingredient.d.ts +10 -3
  80. package/dist/shopping/ingredient.d.ts.map +1 -1
  81. package/dist/subscription/billing.d.ts +3 -0
  82. package/dist/subscription/billing.d.ts.map +1 -0
  83. package/dist/subscription/billing.js +5 -0
  84. package/dist/subscription/billing.js.map +1 -0
  85. package/dist/subscription/index.d.ts +10 -0
  86. package/dist/subscription/index.d.ts.map +1 -0
  87. package/dist/subscription/index.js +26 -0
  88. package/dist/subscription/index.js.map +1 -0
  89. package/dist/subscription/member.d.ts +10 -0
  90. package/dist/subscription/member.d.ts.map +1 -0
  91. package/dist/subscription/member.js +3 -0
  92. package/dist/subscription/member.js.map +1 -0
  93. package/dist/subscription/member_status.d.ts +3 -0
  94. package/dist/subscription/member_status.d.ts.map +1 -0
  95. package/dist/subscription/member_status.js +10 -0
  96. package/dist/subscription/member_status.js.map +1 -0
  97. package/dist/subscription/role.d.ts +3 -0
  98. package/dist/subscription/role.d.ts.map +1 -0
  99. package/dist/subscription/role.js +5 -0
  100. package/dist/subscription/role.js.map +1 -0
  101. package/dist/subscription/sharing.d.ts +6 -0
  102. package/dist/subscription/sharing.d.ts.map +1 -0
  103. package/dist/subscription/sharing.js +3 -0
  104. package/dist/subscription/sharing.js.map +1 -0
  105. package/dist/subscription/status.d.ts +3 -0
  106. package/dist/subscription/status.d.ts.map +1 -0
  107. package/dist/subscription/status.js +14 -0
  108. package/dist/subscription/status.js.map +1 -0
  109. package/dist/subscription/store.d.ts +3 -0
  110. package/dist/subscription/store.d.ts.map +1 -0
  111. package/dist/subscription/store.js +10 -0
  112. package/dist/subscription/store.js.map +1 -0
  113. package/dist/subscription/subscription.d.ts +24 -0
  114. package/dist/subscription/subscription.d.ts.map +1 -0
  115. package/dist/subscription/subscription.js +3 -0
  116. package/dist/subscription/subscription.js.map +1 -0
  117. package/dist/subscription/tier.d.ts +3 -0
  118. package/dist/subscription/tier.d.ts.map +1 -0
  119. package/dist/subscription/tier.js +5 -0
  120. package/dist/subscription/tier.js.map +1 -0
  121. package/dist/users/index.d.ts +4 -0
  122. package/dist/users/index.d.ts.map +1 -0
  123. package/dist/users/index.js +20 -0
  124. package/dist/users/index.js.map +1 -0
  125. package/dist/users/role.d.ts +5 -0
  126. package/dist/users/role.d.ts.map +1 -0
  127. package/dist/users/role.js +18 -0
  128. package/dist/users/role.js.map +1 -0
  129. package/dist/users/status.d.ts +3 -0
  130. package/dist/users/status.d.ts.map +1 -0
  131. package/dist/users/status.js +12 -0
  132. package/dist/users/status.js.map +1 -0
  133. package/dist/users/user.d.ts +16 -0
  134. package/dist/users/user.d.ts.map +1 -0
  135. package/dist/users/user.js +3 -0
  136. package/dist/users/user.js.map +1 -0
  137. package/package.json +1 -1
  138. package/src/common/currency.ts +9 -1
  139. package/src/common/index.ts +1 -3
  140. package/src/common/meal_type.ts +3 -1
  141. package/src/common/temperature.ts +2 -1
  142. package/src/common/unit.ts +1 -0
  143. package/src/core/entity.ts +13 -4
  144. package/src/core/errors.ts +207 -52
  145. package/src/core/index.ts +0 -1
  146. package/src/core/locale.ts +4 -0
  147. package/src/core/timestamp.ts +1 -4
  148. package/src/equipment/entity.ts +4 -11
  149. package/src/equipment/user.ts +4 -6
  150. package/src/feed/recipe.ts +3 -3
  151. package/src/index.ts +2 -2
  152. package/src/ingredients/entity.ts +4 -11
  153. package/src/ingredients/user.ts +4 -6
  154. package/src/limits/limits.ts +1 -1
  155. package/src/limits/usage.ts +8 -2
  156. package/src/recipes/index.ts +0 -1
  157. package/src/recipes/meta.ts +0 -2
  158. package/src/recipes/recipe.ts +0 -2
  159. package/src/recipes/request.ts +2 -2
  160. package/src/recipes/stats.ts +3 -1
  161. package/src/recipes/user.ts +3 -3
  162. package/src/reports/report.ts +0 -3
  163. package/src/settings/settings.ts +1 -0
  164. package/src/shopping/equipment.ts +6 -1
  165. package/src/shopping/ingredient.ts +10 -3
  166. package/src/subscription/index.ts +9 -0
  167. package/src/{subscriptions → subscription}/member.ts +3 -3
  168. package/src/subscription/sharing.ts +5 -0
  169. package/src/subscription/subscription.ts +24 -0
  170. package/src/{iam → users}/role.ts +8 -0
  171. package/src/{iam → users}/user.ts +2 -0
  172. package/src/common/currency_code.ts +0 -10
  173. package/src/common/temperature_unit.ts +0 -2
  174. package/src/core/region.ts +0 -11
  175. package/src/interactions/collection.ts +0 -7
  176. package/src/interactions/cooked.ts +0 -6
  177. package/src/interactions/event.ts +0 -11
  178. package/src/interactions/event_type.ts +0 -9
  179. package/src/interactions/index.ts +0 -6
  180. package/src/interactions/rated.ts +0 -6
  181. package/src/interactions/saved.ts +0 -6
  182. package/src/recipes/status.ts +0 -8
  183. package/src/subscriptions/index.ts +0 -8
  184. package/src/subscriptions/subscription.ts +0 -22
  185. /package/src/common/{measurement_system.ts → measurement.ts} +0 -0
  186. /package/src/{subscriptions/billing_period.ts → subscription/billing.ts} +0 -0
  187. /package/src/{subscriptions → subscription}/member_status.ts +0 -0
  188. /package/src/{subscriptions/subscription_role.ts → subscription/role.ts} +0 -0
  189. /package/src/{subscriptions/subscription_status.ts → subscription/status.ts} +0 -0
  190. /package/src/{subscriptions → subscription}/store.ts +0 -0
  191. /package/src/{subscriptions/subscription_tier.ts → subscription/tier.ts} +0 -0
  192. /package/src/{iam → users}/index.ts +0 -0
  193. /package/src/{iam → users}/status.ts +0 -0
@@ -1,118 +1,273 @@
1
- export const APP_ERROR_CODE_VALUES = [
1
+ import { UnixTimestamp } from "./timestamp";
2
+
3
+ export const APP_ERROR_CODES = [
2
4
  "bad-request",
3
- "conflict",
4
- "daily-limit-reached",
5
+ "unauthorized",
5
6
  "forbidden",
6
- "internal-error",
7
- "low-confidence",
8
- "monthly-limit-reached",
9
7
  "not-found",
10
- "no-recipe-found",
11
- "unauthorized",
12
- "unsafe-content",
8
+ "conflict",
13
9
  "validation-error",
10
+ "quota-exceeded",
11
+ "rate-limited",
12
+ "internal-error",
13
+ "service-unavailable",
14
14
  ] as const;
15
- export type AppErrorCode = (typeof APP_ERROR_CODE_VALUES)[number];
15
+
16
+ export type AppErrorCode = (typeof APP_ERROR_CODES)[number];
17
+
18
+ export const HTTP_STATUS_MAP: Record<AppErrorCode, number> = {
19
+ "bad-request": 400,
20
+ unauthorized: 401,
21
+ forbidden: 403,
22
+ "not-found": 404,
23
+ conflict: 409,
24
+ "validation-error": 422,
25
+ "quota-exceeded": 429,
26
+ "rate-limited": 429,
27
+ "internal-error": 500,
28
+ "service-unavailable": 503,
29
+ };
30
+
31
+ export interface BaseErrorContext {
32
+ requestId?: string;
33
+ [key: string]: unknown;
34
+ }
35
+
36
+ export interface ValidationErrorContext extends BaseErrorContext {
37
+ fields: Array<{
38
+ path: string;
39
+ message: string;
40
+ code?: string;
41
+ }>;
42
+ }
43
+
44
+ export interface QuotaErrorContext extends BaseErrorContext {
45
+ quotaType: "daily" | "monthly";
46
+ resource: string;
47
+ limit: number;
48
+ used: number;
49
+ resetsAt?: UnixTimestamp;
50
+ }
51
+
52
+ export interface RateLimitErrorContext extends BaseErrorContext {
53
+ retryAfterSeconds?: number;
54
+ }
55
+
56
+ export interface NotFoundErrorContext extends BaseErrorContext {
57
+ resourceType: string;
58
+ resourceId?: string;
59
+ }
16
60
 
17
61
  export class AppError extends Error {
18
62
  public readonly code: AppErrorCode;
19
- public readonly context?: Record<string, unknown>;
63
+ public readonly context: BaseErrorContext;
64
+ public readonly statusCode: number;
20
65
 
21
66
  constructor(
22
67
  code: AppErrorCode,
23
68
  message: string,
24
- context?: Record<string, unknown>,
69
+ context: BaseErrorContext = {},
25
70
  ) {
26
71
  super(message);
27
72
  this.name = "AppError";
28
73
  this.code = code;
29
74
  this.context = context;
75
+ this.statusCode = HTTP_STATUS_MAP[code];
30
76
 
31
77
  if (Error.captureStackTrace) {
32
- Error.captureStackTrace(this, AppError);
78
+ Error.captureStackTrace(this, this.constructor);
33
79
  }
80
+ Object.setPrototypeOf(this, new.target.prototype);
34
81
  }
82
+ toJSON(): {
83
+ code: AppErrorCode;
84
+ message: string;
85
+ details?: Record<string, unknown>;
86
+ requestId?: string;
87
+ } {
88
+ const { requestId, ...details } = this.context;
35
89
 
36
- toJSON() {
37
90
  return {
38
- name: this.name,
39
91
  code: this.code,
40
92
  message: this.message,
41
- context: this.context,
93
+ ...(Object.keys(details).length > 0 && { details }),
94
+ ...(requestId && { requestId }),
42
95
  };
43
96
  }
97
+ withRequestId(requestId: string): AppError {
98
+ return new (this.constructor as typeof AppError)(this.code, this.message, {
99
+ ...this.context,
100
+ requestId,
101
+ });
102
+ }
44
103
  }
45
104
 
46
- export class ValidationError extends AppError {
47
- constructor(message: string, context?: Record<string, unknown>) {
48
- super("validation-error", message, context);
49
- this.name = "ValidationError";
50
- }
105
+ export function isAppError(error: unknown): error is AppError {
106
+ return error instanceof AppError;
51
107
  }
52
108
 
53
- export class NotFoundError extends AppError {
54
- constructor(message: string, context?: Record<string, unknown>) {
55
- super("not-found", message, context);
56
- this.name = "NotFoundError";
109
+ export function isAppErrorCode(code: unknown): code is AppErrorCode {
110
+ return (
111
+ typeof code === "string" && APP_ERROR_CODES.includes(code as AppErrorCode)
112
+ );
113
+ }
114
+
115
+ export class BadRequestError extends AppError {
116
+ constructor(message: string, context: BaseErrorContext = {}) {
117
+ super("bad-request", message, context);
118
+ this.name = "BadRequestError";
57
119
  }
58
120
  }
59
121
 
60
122
  export class UnauthorizedError extends AppError {
61
- constructor(message: string, context?: Record<string, unknown>) {
123
+ constructor(
124
+ message: string = "Authentication required",
125
+ context: BaseErrorContext = {},
126
+ ) {
62
127
  super("unauthorized", message, context);
63
128
  this.name = "UnauthorizedError";
64
129
  }
65
130
  }
66
131
 
67
132
  export class ForbiddenError extends AppError {
68
- constructor(message: string, context?: Record<string, unknown>) {
133
+ constructor(
134
+ message: string = "You do not have permission to perform this action",
135
+ context: BaseErrorContext = {},
136
+ ) {
69
137
  super("forbidden", message, context);
70
138
  this.name = "ForbiddenError";
71
139
  }
72
140
  }
73
141
 
142
+ export class NotFoundError extends AppError {
143
+ constructor(
144
+ resourceType: string,
145
+ resourceId?: string,
146
+ context: Omit<NotFoundErrorContext, "resourceType" | "resourceId"> = {},
147
+ ) {
148
+ const message = resourceId
149
+ ? `${resourceType} not found: ${resourceId}`
150
+ : `${resourceType} not found`;
151
+ super("not-found", message, { ...context, resourceType, resourceId });
152
+ this.name = "NotFoundError";
153
+ }
154
+ }
155
+
74
156
  export class ConflictError extends AppError {
75
- constructor(message: string, context?: Record<string, unknown>) {
157
+ constructor(message: string, context: BaseErrorContext = {}) {
76
158
  super("conflict", message, context);
77
159
  this.name = "ConflictError";
78
160
  }
79
161
  }
80
162
 
81
- export class DailyLimitError extends AppError {
82
- constructor(message: string, context?: Record<string, unknown>) {
83
- super("daily-limit-reached", message, context);
84
- this.name = "DailyLimitError";
163
+ export class ValidationError extends AppError {
164
+ public readonly fields: ValidationErrorContext["fields"];
165
+
166
+ constructor(
167
+ message: string,
168
+ fields: ValidationErrorContext["fields"] = [],
169
+ context: Omit<ValidationErrorContext, "fields"> = {},
170
+ ) {
171
+ super("validation-error", message, { ...context, fields });
172
+ this.name = "ValidationError";
173
+ this.fields = fields;
174
+ }
175
+
176
+ static fromFieldErrors(
177
+ fields: ValidationErrorContext["fields"],
178
+ context: Omit<ValidationErrorContext, "fields"> = {},
179
+ ): ValidationError {
180
+ const message =
181
+ fields.length === 1
182
+ ? fields[0].message
183
+ : `Validation failed: ${fields.length} errors`;
184
+ return new ValidationError(message, fields, context);
85
185
  }
86
186
  }
87
187
 
88
- export class MonthlyLimitError extends AppError {
89
- constructor(message: string, context?: Record<string, unknown>) {
90
- super("monthly-limit-reached", message, context);
91
- this.name = "MonthlyLimitError";
188
+ export class QuotaExceededError extends AppError {
189
+ public readonly quotaType: "daily" | "monthly";
190
+ public readonly resource: string;
191
+ public readonly limit: number;
192
+ public readonly used: number;
193
+ public readonly resetsAt?: string;
194
+
195
+ constructor(
196
+ quotaType: "daily" | "monthly",
197
+ resource: string,
198
+ limit: number,
199
+ used: number,
200
+ resetsAt?: string,
201
+ context: Omit<
202
+ QuotaErrorContext,
203
+ "quotaType" | "resource" | "limit" | "used" | "resetsAt"
204
+ > = {},
205
+ ) {
206
+ const message = `${quotaType.charAt(0).toUpperCase() + quotaType.slice(1)} ${resource} limit reached (${used}/${limit})`;
207
+ super("quota-exceeded", message, {
208
+ ...context,
209
+ quotaType,
210
+ resource,
211
+ limit,
212
+ used,
213
+ resetsAt,
214
+ });
215
+ this.name = "QuotaExceededError";
216
+ this.quotaType = quotaType;
217
+ this.resource = resource;
218
+ this.limit = limit;
219
+ this.used = used;
220
+ this.resetsAt = resetsAt;
92
221
  }
93
222
  }
94
223
 
95
- export class NoRecipeFoundError extends AppError {
96
- constructor(reason: string, context?: Record<string, unknown>) {
97
- super("no-recipe-found", reason, context);
98
- this.name = "NoRecipeFoundError";
224
+ export class RateLimitedError extends AppError {
225
+ public readonly retryAfterSeconds?: number;
226
+
227
+ constructor(
228
+ message: string = "Too many requests. Please try again later.",
229
+ retryAfterSeconds?: number,
230
+ context: Omit<RateLimitErrorContext, "retryAfterSeconds"> = {},
231
+ ) {
232
+ super("rate-limited", message, { ...context, retryAfterSeconds });
233
+ this.name = "RateLimitedError";
234
+ this.retryAfterSeconds = retryAfterSeconds;
99
235
  }
100
236
  }
101
237
 
102
- export class LowConfidenceError extends AppError {
103
- constructor(confidence: number, context?: Record<string, unknown>) {
104
- super(
105
- "low-confidence",
106
- "We couldn't extract a complete recipe. Try a clearer image or more detailed text.",
107
- { ...context, confidence },
108
- );
109
- this.name = "LowConfidenceError";
238
+ export class InternalError extends AppError {
239
+ constructor(
240
+ message: string = "An unexpected error occurred",
241
+ context: BaseErrorContext = {},
242
+ ) {
243
+ super("internal-error", message, context);
244
+ this.name = "InternalError";
245
+ }
246
+
247
+ static wrap(error: unknown, context: BaseErrorContext = {}): InternalError {
248
+ const message =
249
+ error instanceof Error ? error.message : "An unexpected error occurred";
250
+ return new InternalError(message, {
251
+ ...context,
252
+ originalError:
253
+ error instanceof Error
254
+ ? { name: error.name, message: error.message }
255
+ : String(error),
256
+ });
110
257
  }
111
258
  }
112
259
 
113
- export class UnsafeContentError extends AppError {
114
- constructor(context?: Record<string, unknown>) {
115
- super("unsafe-content", "This content cannot be processed.", context);
116
- this.name = "UnsafeContentError";
260
+ export class ServiceUnavailableError extends AppError {
261
+ constructor(
262
+ service: string,
263
+ message?: string,
264
+ context: BaseErrorContext = {},
265
+ ) {
266
+ super(
267
+ "service-unavailable",
268
+ message ?? `${service} is temporarily unavailable`,
269
+ { ...context, service },
270
+ );
271
+ this.name = "ServiceUnavailableError";
117
272
  }
118
273
  }
package/src/core/index.ts CHANGED
@@ -2,6 +2,5 @@ export * from "./entity";
2
2
  export * from "./errors";
3
3
  export * from "./locale";
4
4
  export * from "./pagination";
5
- export * from "./region";
6
5
  export * from "./theme";
7
6
  export * from "./timestamp";
@@ -1,2 +1,6 @@
1
1
  export const LOCALE_VALUES = ["en", "ar", "es"] as const;
2
2
  export type Locale = (typeof LOCALE_VALUES)[number];
3
+
4
+ export type LocalizedString = { en: string } & Partial<
5
+ Record<Exclude<Locale, "en">, string>
6
+ >;
@@ -1,4 +1 @@
1
- export interface Timestamp {
2
- seconds: number;
3
- nanoseconds: number;
4
- }
1
+ export type UnixTimestamp = number;
@@ -1,18 +1,11 @@
1
1
  import { Currency } from "../common";
2
- import { Entity } from "../core";
2
+ import { Entity, LocalizedString } from "../core";
3
3
  import { EquipmentCategory } from "./category";
4
4
 
5
- export interface EquipmentEntityMeta extends Entity {
5
+ export interface EquipmentEntity extends Entity {
6
6
  category: EquipmentCategory;
7
7
  cost: Currency;
8
+ imagePath: string | null;
9
+ name: LocalizedString;
8
10
  slug: string;
9
- imageUrl: string | null;
10
11
  }
11
-
12
- export interface EquipmentEntityContent {
13
- name: string;
14
- slug: string;
15
- }
16
-
17
- export interface EquipmentEntity
18
- extends EquipmentEntityMeta, EquipmentEntityContent {}
@@ -1,14 +1,12 @@
1
1
  import { Currency } from "../common";
2
- import { Entity } from "../core";
2
+ import { Entity, LocalizedString } from "../core";
3
3
  import { EquipmentCategory } from "./category";
4
4
 
5
- export interface UserEquipment extends Entity {
5
+ export interface UserEquipmentEntity extends Entity {
6
6
  category: EquipmentCategory;
7
7
  cost: Currency;
8
+ imagePath: string | null;
9
+ name: LocalizedString;
8
10
  quantity: number;
9
11
  slug: string;
10
12
  }
11
-
12
- export interface LocalizedUserEquipment extends UserEquipment {
13
- name: string;
14
- }
@@ -7,7 +7,7 @@ import {
7
7
  MealType,
8
8
  Spiciness,
9
9
  } from "../common";
10
- import { Entity, Locale } from "../core";
10
+ import { Entity, LocalizedString } from "../core";
11
11
  import { RecipeStats } from "../recipes";
12
12
  import { FeedCategory } from "./category";
13
13
 
@@ -21,7 +21,7 @@ export interface RecipeFeedItem extends Entity {
21
21
  images: string[];
22
22
  mealTypes: MealType[];
23
23
  spiciness: Spiciness;
24
- titles: Record<Locale, string>;
24
+ titles: LocalizedString;
25
25
  }
26
26
 
27
27
  export interface FeedRecipe extends RecipeFeedItem {
@@ -30,6 +30,6 @@ export interface FeedRecipe extends RecipeFeedItem {
30
30
 
31
31
  export interface FeedGroup {
32
32
  category: FeedCategory;
33
- titles: Record<Locale, string>;
33
+ titles: LocalizedString;
34
34
  recipes: FeedRecipe[];
35
35
  }
package/src/index.ts CHANGED
@@ -2,7 +2,6 @@ export * from "./common";
2
2
  export * from "./core";
3
3
  export * from "./equipment";
4
4
  export * from "./feed";
5
- export * from "./iam";
6
5
  export * from "./ingredients";
7
6
  export * from "./limits";
8
7
  export * from "./mealplan";
@@ -10,4 +9,5 @@ export * from "./recipes";
10
9
  export * from "./reports";
11
10
  export * from "./settings";
12
11
  export * from "./shopping";
13
- export * from "./subscriptions";
12
+ export * from "./subscription";
13
+ export * from "./users";
@@ -1,21 +1,14 @@
1
1
  import { Currency, Unit } from "../common";
2
- import { Entity } from "../core";
2
+ import { Entity, LocalizedString } from "../core";
3
3
  import { IngredientCategory } from "./category";
4
4
  import { IngredientGroup } from "./group";
5
5
 
6
- export interface IngredientEntityMeta extends Entity {
6
+ export interface IngredientEntity extends Entity {
7
7
  category: IngredientCategory;
8
8
  cost: Currency;
9
9
  group: IngredientGroup;
10
- imageUrl: string | null;
10
+ imagePath: string | null;
11
+ name: LocalizedString;
11
12
  slug: string;
12
13
  standardUnit: Unit;
13
14
  }
14
-
15
- export interface IngredientEntityContent {
16
- name: string;
17
- slug: string;
18
- }
19
-
20
- export interface IngredientEntity
21
- extends IngredientEntityMeta, IngredientEntityContent {}
@@ -1,18 +1,16 @@
1
1
  import { Currency, Unit } from "../common";
2
- import { Entity, Timestamp } from "../core";
2
+ import { Entity, LocalizedString, UnixTimestamp } from "../core";
3
3
  import { IngredientCategory } from "./category";
4
4
  import { IngredientGroup } from "./group";
5
5
 
6
6
  export interface UserIngredient extends Entity {
7
7
  category: IngredientCategory;
8
8
  cost: Currency;
9
- expiresAt: Timestamp | null;
9
+ expiresAt: UnixTimestamp | null;
10
10
  group: IngredientGroup;
11
+ imagePath: string | null;
12
+ name: LocalizedString;
11
13
  slug: string;
12
14
  quantity: number;
13
15
  unit: Unit;
14
16
  }
15
-
16
- export interface LocalizedUserIngredient extends UserIngredient {
17
- name: string;
18
- }
@@ -1,4 +1,4 @@
1
- import { SubscriptionTier } from "../subscriptions";
1
+ import { SubscriptionTier } from "../subscription";
2
2
  import { Operation } from "./operation";
3
3
 
4
4
  export type TierLimits = Record<SubscriptionTier, number>;
@@ -1,9 +1,15 @@
1
- import { Timestamp } from "../core";
1
+ import { UnixTimestamp } from "../core";
2
2
  import { Operation } from "./operation";
3
3
 
4
4
  export type UsageCounts = Partial<Record<Operation, number>>;
5
5
 
6
6
  export interface UsagePeriod {
7
7
  counts: UsageCounts;
8
- updatedAt: Timestamp;
8
+ resetAt: UnixTimestamp;
9
+ updatedAt: UnixTimestamp;
10
+ }
11
+
12
+ export interface UserQuotas {
13
+ daily: UsagePeriod;
14
+ monthly: UsagePeriod;
9
15
  }
@@ -6,5 +6,4 @@ export * from "./recipe";
6
6
  export * from "./request";
7
7
  export * from "./source";
8
8
  export * from "./stats";
9
- export * from "./status";
10
9
  export * from "./user";
@@ -14,7 +14,6 @@ import { RecipeEquipmentMeta } from "../equipment";
14
14
  import { IngredientSectionMeta } from "../ingredients";
15
15
  import { InstructionMeta } from "./instruction";
16
16
  import { RecipeSource } from "./source";
17
- import { RecipeStatus } from "./status";
18
17
 
19
18
  export interface RecipeMeta extends Entity {
20
19
  allergens: Allergen[];
@@ -37,6 +36,5 @@ export interface RecipeMeta extends Entity {
37
36
  source: RecipeSource;
38
37
  sourceRef: string;
39
38
  spiciness: Spiciness;
40
- status: RecipeStatus;
41
39
  videoUrl?: string;
42
40
  }
@@ -13,7 +13,6 @@ import {
13
13
  import { RecipeEquipment } from "../equipment";
14
14
  import { IngredientSection } from "../ingredients";
15
15
  import { Instruction } from "./instruction";
16
- import { RecipeStatus } from "./status";
17
16
 
18
17
  export interface Recipe extends Entity {
19
18
  allergens: Allergen[];
@@ -32,7 +31,6 @@ export interface Recipe extends Entity {
32
31
  nutrition: Nutrition;
33
32
  servings: number;
34
33
  spiciness: Spiciness;
35
- status: RecipeStatus;
36
34
  tips: string[];
37
35
  title: string;
38
36
  videoUrl?: string;
@@ -1,4 +1,4 @@
1
- import { Entity, Timestamp } from "../core";
1
+ import { Entity, UnixTimestamp } from "../core";
2
2
  import { Locale } from "../core/locale";
3
3
  import { RecipeSource } from "./source";
4
4
 
@@ -22,5 +22,5 @@ export interface RecipeRequest extends Entity {
22
22
  status: RequestStatus;
23
23
  userId: string;
24
24
  error?: string;
25
- processedAt: Timestamp | null;
25
+ processedAt: UnixTimestamp | null;
26
26
  }
@@ -1,3 +1,5 @@
1
+ import { UnixTimestamp } from "../core";
2
+
1
3
  export interface RecipeStats {
2
4
  cooks: number;
3
5
  ratingCount: number;
@@ -5,5 +7,5 @@ export interface RecipeStats {
5
7
  saves: number;
6
8
  shares: number;
7
9
  score: number;
8
- updatedAt: number;
10
+ updatedAt: UnixTimestamp;
9
11
  }
@@ -1,10 +1,10 @@
1
- import { Entity, Timestamp } from "../core";
1
+ import { Entity, UnixTimestamp } from "../core";
2
2
 
3
3
  export interface UserRecipe extends Entity {
4
4
  recipeId: string;
5
- cookedAt: Timestamp | null;
5
+ cookedAt: UnixTimestamp | null;
6
6
  cookedCount: number;
7
7
  notes?: string;
8
8
  rating?: number;
9
- savedAt: Timestamp | null;
9
+ savedAt: UnixTimestamp | null;
10
10
  }
@@ -11,8 +11,5 @@ export interface Report extends Entity {
11
11
  reporterId: string;
12
12
  submission: ReportSubmission;
13
13
  target: ReportTarget;
14
- }
15
-
16
- export interface UpdatedReport extends Report {
17
14
  updates: ReportUpdate[];
18
15
  }
@@ -23,5 +23,6 @@ export interface Settings extends Entity {
23
23
  spiciness: Spiciness;
24
24
  temperatureUnit: TemperatureUnit;
25
25
  textScale: number;
26
+ timezone: string;
26
27
  theme: Theme;
27
28
  }
@@ -1,7 +1,12 @@
1
+ import { Currency } from "../common";
2
+ import { LocalizedString } from "../core";
1
3
  import { ShoppingItemStatus } from "./item_status";
2
4
 
3
5
  export interface ShoppingEquipment {
4
- slug: string;
6
+ cost: Currency;
7
+ imagePath: string | null;
8
+ name: LocalizedString;
5
9
  quantity: number;
10
+ slug: string;
6
11
  status: ShoppingItemStatus;
7
12
  }
@@ -1,9 +1,16 @@
1
- import { Unit } from "../common";
1
+ import { Currency, Unit } from "../common";
2
+ import { LocalizedString } from "../core";
3
+ import { IngredientCategory, IngredientGroup } from "../ingredients";
2
4
  import { ShoppingItemStatus } from "./item_status";
3
5
 
4
6
  export interface ShoppingIngredient {
5
- slug: string;
7
+ category: IngredientCategory;
8
+ cost: Currency;
9
+ group: IngredientGroup;
10
+ imagePath: string | null;
11
+ name: LocalizedString;
6
12
  quantity: number;
7
- unit: Unit;
13
+ slug: string;
8
14
  status: ShoppingItemStatus;
15
+ unit: Unit;
9
16
  }
@@ -0,0 +1,9 @@
1
+ export * from "./billing";
2
+ export * from "./member_status";
3
+ export * from "./member";
4
+ export * from "./role";
5
+ export * from "./sharing";
6
+ export * from "./store";
7
+ export * from "./status";
8
+ export * from "./tier";
9
+ export * from "./subscription";
@@ -1,9 +1,9 @@
1
- import { Timestamp } from "../core";
1
+ import { UnixTimestamp } from "../core";
2
2
  import { MemberStatus } from "./member_status";
3
- import { SubscriptionRole } from "./subscription_role";
3
+ import { SubscriptionRole } from "./role";
4
4
 
5
5
  export interface Member {
6
- joinedAt: Timestamp | null;
6
+ joinedAt: UnixTimestamp | null;
7
7
  role: SubscriptionRole;
8
8
  status: MemberStatus;
9
9
  userId: string;