@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.
- package/dist/common/currency.d.ts +2 -1
- package/dist/common/currency.d.ts.map +1 -1
- package/dist/common/currency.js +9 -0
- package/dist/common/currency.js.map +1 -1
- package/dist/common/index.d.ts +1 -3
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +1 -3
- package/dist/common/index.js.map +1 -1
- package/dist/common/meal_type.d.ts +1 -1
- package/dist/common/meal_type.d.ts.map +1 -1
- package/dist/common/meal_type.js +3 -1
- package/dist/common/meal_type.js.map +1 -1
- package/dist/common/measurement.d.ts +3 -0
- package/dist/common/measurement.d.ts.map +1 -0
- package/dist/common/measurement.js +5 -0
- package/dist/common/measurement.js.map +1 -0
- package/dist/common/temperature.d.ts +2 -1
- package/dist/common/temperature.d.ts.map +1 -1
- package/dist/common/temperature.js +2 -0
- package/dist/common/temperature.js.map +1 -1
- package/dist/common/unit.d.ts +1 -1
- package/dist/common/unit.d.ts.map +1 -1
- package/dist/common/unit.js +1 -0
- package/dist/common/unit.js.map +1 -1
- package/dist/core/entity.d.ts +6 -4
- package/dist/core/entity.d.ts.map +1 -1
- package/dist/core/entity.js +8 -0
- package/dist/core/entity.js.map +1 -1
- package/dist/core/errors.d.ts +65 -25
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +114 -57
- package/dist/core/errors.js.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/locale.d.ts +3 -0
- package/dist/core/locale.d.ts.map +1 -1
- package/dist/core/timestamp.d.ts +1 -4
- package/dist/core/timestamp.d.ts.map +1 -1
- package/dist/equipment/entity.d.ts +4 -9
- package/dist/equipment/entity.d.ts.map +1 -1
- package/dist/equipment/user.d.ts +4 -5
- package/dist/equipment/user.d.ts.map +1 -1
- package/dist/feed/recipe.d.ts +3 -3
- package/dist/feed/recipe.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/ingredients/entity.d.ts +4 -9
- package/dist/ingredients/entity.d.ts.map +1 -1
- package/dist/ingredients/user.d.ts +4 -5
- package/dist/ingredients/user.d.ts.map +1 -1
- package/dist/limits/limits.d.ts +1 -1
- package/dist/limits/limits.d.ts.map +1 -1
- package/dist/limits/usage.d.ts +7 -2
- package/dist/limits/usage.d.ts.map +1 -1
- package/dist/recipes/index.d.ts +0 -1
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +0 -1
- package/dist/recipes/index.js.map +1 -1
- package/dist/recipes/meta.d.ts +0 -2
- package/dist/recipes/meta.d.ts.map +1 -1
- package/dist/recipes/recipe.d.ts +0 -2
- package/dist/recipes/recipe.d.ts.map +1 -1
- package/dist/recipes/request.d.ts +2 -2
- package/dist/recipes/request.d.ts.map +1 -1
- package/dist/recipes/stats.d.ts +2 -1
- package/dist/recipes/stats.d.ts.map +1 -1
- package/dist/recipes/user.d.ts +3 -3
- package/dist/recipes/user.d.ts.map +1 -1
- package/dist/reports/report.d.ts +0 -2
- package/dist/reports/report.d.ts.map +1 -1
- package/dist/settings/settings.d.ts +1 -0
- package/dist/settings/settings.d.ts.map +1 -1
- package/dist/shopping/equipment.d.ts +6 -1
- package/dist/shopping/equipment.d.ts.map +1 -1
- package/dist/shopping/ingredient.d.ts +10 -3
- package/dist/shopping/ingredient.d.ts.map +1 -1
- package/dist/subscription/billing.d.ts +3 -0
- package/dist/subscription/billing.d.ts.map +1 -0
- package/dist/subscription/billing.js +5 -0
- package/dist/subscription/billing.js.map +1 -0
- package/dist/subscription/index.d.ts +10 -0
- package/dist/subscription/index.d.ts.map +1 -0
- package/dist/subscription/index.js +26 -0
- package/dist/subscription/index.js.map +1 -0
- package/dist/subscription/member.d.ts +10 -0
- package/dist/subscription/member.d.ts.map +1 -0
- package/dist/subscription/member.js +3 -0
- package/dist/subscription/member.js.map +1 -0
- package/dist/subscription/member_status.d.ts +3 -0
- package/dist/subscription/member_status.d.ts.map +1 -0
- package/dist/subscription/member_status.js +10 -0
- package/dist/subscription/member_status.js.map +1 -0
- package/dist/subscription/role.d.ts +3 -0
- package/dist/subscription/role.d.ts.map +1 -0
- package/dist/subscription/role.js +5 -0
- package/dist/subscription/role.js.map +1 -0
- package/dist/subscription/sharing.d.ts +6 -0
- package/dist/subscription/sharing.d.ts.map +1 -0
- package/dist/subscription/sharing.js +3 -0
- package/dist/subscription/sharing.js.map +1 -0
- package/dist/subscription/status.d.ts +3 -0
- package/dist/subscription/status.d.ts.map +1 -0
- package/dist/subscription/status.js +14 -0
- package/dist/subscription/status.js.map +1 -0
- package/dist/subscription/store.d.ts +3 -0
- package/dist/subscription/store.d.ts.map +1 -0
- package/dist/subscription/store.js +10 -0
- package/dist/subscription/store.js.map +1 -0
- package/dist/subscription/subscription.d.ts +24 -0
- package/dist/subscription/subscription.d.ts.map +1 -0
- package/dist/subscription/subscription.js +3 -0
- package/dist/subscription/subscription.js.map +1 -0
- package/dist/subscription/tier.d.ts +3 -0
- package/dist/subscription/tier.d.ts.map +1 -0
- package/dist/subscription/tier.js +5 -0
- package/dist/subscription/tier.js.map +1 -0
- package/dist/users/index.d.ts +4 -0
- package/dist/users/index.d.ts.map +1 -0
- package/dist/users/index.js +20 -0
- package/dist/users/index.js.map +1 -0
- package/dist/users/role.d.ts +5 -0
- package/dist/users/role.d.ts.map +1 -0
- package/dist/users/role.js +18 -0
- package/dist/users/role.js.map +1 -0
- package/dist/users/status.d.ts +3 -0
- package/dist/users/status.d.ts.map +1 -0
- package/dist/users/status.js +12 -0
- package/dist/users/status.js.map +1 -0
- package/dist/users/user.d.ts +16 -0
- package/dist/users/user.d.ts.map +1 -0
- package/dist/users/user.js +3 -0
- package/dist/users/user.js.map +1 -0
- package/package.json +1 -1
- package/src/common/currency.ts +9 -1
- package/src/common/index.ts +1 -3
- package/src/common/meal_type.ts +3 -1
- package/src/common/temperature.ts +2 -1
- package/src/common/unit.ts +1 -0
- package/src/core/entity.ts +13 -4
- package/src/core/errors.ts +207 -52
- package/src/core/index.ts +0 -1
- package/src/core/locale.ts +4 -0
- package/src/core/timestamp.ts +1 -4
- package/src/equipment/entity.ts +4 -11
- package/src/equipment/user.ts +4 -6
- package/src/feed/recipe.ts +3 -3
- package/src/index.ts +2 -2
- package/src/ingredients/entity.ts +4 -11
- package/src/ingredients/user.ts +4 -6
- package/src/limits/limits.ts +1 -1
- package/src/limits/usage.ts +8 -2
- package/src/recipes/index.ts +0 -1
- package/src/recipes/meta.ts +0 -2
- package/src/recipes/recipe.ts +0 -2
- package/src/recipes/request.ts +2 -2
- package/src/recipes/stats.ts +3 -1
- package/src/recipes/user.ts +3 -3
- package/src/reports/report.ts +0 -3
- package/src/settings/settings.ts +1 -0
- package/src/shopping/equipment.ts +6 -1
- package/src/shopping/ingredient.ts +10 -3
- package/src/subscription/index.ts +9 -0
- package/src/{subscriptions → subscription}/member.ts +3 -3
- package/src/subscription/sharing.ts +5 -0
- package/src/subscription/subscription.ts +24 -0
- package/src/{iam → users}/role.ts +8 -0
- package/src/{iam → users}/user.ts +2 -0
- package/src/common/currency_code.ts +0 -10
- package/src/common/temperature_unit.ts +0 -2
- package/src/core/region.ts +0 -11
- package/src/interactions/collection.ts +0 -7
- package/src/interactions/cooked.ts +0 -6
- package/src/interactions/event.ts +0 -11
- package/src/interactions/event_type.ts +0 -9
- package/src/interactions/index.ts +0 -6
- package/src/interactions/rated.ts +0 -6
- package/src/interactions/saved.ts +0 -6
- package/src/recipes/status.ts +0 -8
- package/src/subscriptions/index.ts +0 -8
- package/src/subscriptions/subscription.ts +0 -22
- /package/src/common/{measurement_system.ts → measurement.ts} +0 -0
- /package/src/{subscriptions/billing_period.ts → subscription/billing.ts} +0 -0
- /package/src/{subscriptions → subscription}/member_status.ts +0 -0
- /package/src/{subscriptions/subscription_role.ts → subscription/role.ts} +0 -0
- /package/src/{subscriptions/subscription_status.ts → subscription/status.ts} +0 -0
- /package/src/{subscriptions → subscription}/store.ts +0 -0
- /package/src/{subscriptions/subscription_tier.ts → subscription/tier.ts} +0 -0
- /package/src/{iam → users}/index.ts +0 -0
- /package/src/{iam → users}/status.ts +0 -0
package/src/core/errors.ts
CHANGED
|
@@ -1,118 +1,273 @@
|
|
|
1
|
-
|
|
1
|
+
import { UnixTimestamp } from "./timestamp";
|
|
2
|
+
|
|
3
|
+
export const APP_ERROR_CODES = [
|
|
2
4
|
"bad-request",
|
|
3
|
-
"
|
|
4
|
-
"daily-limit-reached",
|
|
5
|
+
"unauthorized",
|
|
5
6
|
"forbidden",
|
|
6
|
-
"internal-error",
|
|
7
|
-
"low-confidence",
|
|
8
|
-
"monthly-limit-reached",
|
|
9
7
|
"not-found",
|
|
10
|
-
"
|
|
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
|
-
|
|
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
|
|
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
|
|
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,
|
|
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
|
-
|
|
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
|
|
47
|
-
|
|
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
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
103
|
-
constructor(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
|
114
|
-
constructor(
|
|
115
|
-
|
|
116
|
-
|
|
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
package/src/core/locale.ts
CHANGED
package/src/core/timestamp.ts
CHANGED
package/src/equipment/entity.ts
CHANGED
|
@@ -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
|
|
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 {}
|
package/src/equipment/user.ts
CHANGED
|
@@ -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
|
|
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
|
-
}
|
package/src/feed/recipe.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
MealType,
|
|
8
8
|
Spiciness,
|
|
9
9
|
} from "../common";
|
|
10
|
-
import { Entity,
|
|
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:
|
|
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:
|
|
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 "./
|
|
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
|
|
6
|
+
export interface IngredientEntity extends Entity {
|
|
7
7
|
category: IngredientCategory;
|
|
8
8
|
cost: Currency;
|
|
9
9
|
group: IngredientGroup;
|
|
10
|
-
|
|
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 {}
|
package/src/ingredients/user.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { Currency, Unit } from "../common";
|
|
2
|
-
import { Entity,
|
|
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:
|
|
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
|
-
}
|
package/src/limits/limits.ts
CHANGED
package/src/limits/usage.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
8
|
+
resetAt: UnixTimestamp;
|
|
9
|
+
updatedAt: UnixTimestamp;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UserQuotas {
|
|
13
|
+
daily: UsagePeriod;
|
|
14
|
+
monthly: UsagePeriod;
|
|
9
15
|
}
|
package/src/recipes/index.ts
CHANGED
package/src/recipes/meta.ts
CHANGED
|
@@ -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
|
}
|
package/src/recipes/recipe.ts
CHANGED
|
@@ -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;
|
package/src/recipes/request.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity,
|
|
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:
|
|
25
|
+
processedAt: UnixTimestamp | null;
|
|
26
26
|
}
|
package/src/recipes/stats.ts
CHANGED
|
@@ -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:
|
|
10
|
+
updatedAt: UnixTimestamp;
|
|
9
11
|
}
|
package/src/recipes/user.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Entity,
|
|
1
|
+
import { Entity, UnixTimestamp } from "../core";
|
|
2
2
|
|
|
3
3
|
export interface UserRecipe extends Entity {
|
|
4
4
|
recipeId: string;
|
|
5
|
-
cookedAt:
|
|
5
|
+
cookedAt: UnixTimestamp | null;
|
|
6
6
|
cookedCount: number;
|
|
7
7
|
notes?: string;
|
|
8
8
|
rating?: number;
|
|
9
|
-
savedAt:
|
|
9
|
+
savedAt: UnixTimestamp | null;
|
|
10
10
|
}
|
package/src/reports/report.ts
CHANGED
package/src/settings/settings.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
7
|
+
category: IngredientCategory;
|
|
8
|
+
cost: Currency;
|
|
9
|
+
group: IngredientGroup;
|
|
10
|
+
imagePath: string | null;
|
|
11
|
+
name: LocalizedString;
|
|
6
12
|
quantity: number;
|
|
7
|
-
|
|
13
|
+
slug: string;
|
|
8
14
|
status: ShoppingItemStatus;
|
|
15
|
+
unit: Unit;
|
|
9
16
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnixTimestamp } from "../core";
|
|
2
2
|
import { MemberStatus } from "./member_status";
|
|
3
|
-
import { SubscriptionRole } from "./
|
|
3
|
+
import { SubscriptionRole } from "./role";
|
|
4
4
|
|
|
5
5
|
export interface Member {
|
|
6
|
-
joinedAt:
|
|
6
|
+
joinedAt: UnixTimestamp | null;
|
|
7
7
|
role: SubscriptionRole;
|
|
8
8
|
status: MemberStatus;
|
|
9
9
|
userId: string;
|