@beorchid-llc/thrivo-contracts 0.6.0 → 0.8.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/dist/admin-analytics.d.ts +488 -0
- package/dist/admin-analytics.d.ts.map +1 -0
- package/dist/admin-analytics.js +46 -0
- package/dist/admin-analytics.js.map +1 -0
- package/dist/admin-content.d.ts +92 -0
- package/dist/admin-content.d.ts.map +1 -0
- package/dist/admin-content.js +24 -0
- package/dist/admin-content.js.map +1 -0
- package/dist/admin-logs.d.ts +55 -0
- package/dist/admin-logs.d.ts.map +1 -0
- package/dist/admin-logs.js +24 -0
- package/dist/admin-logs.js.map +1 -0
- package/dist/admin-subscriptions.d.ts +40 -0
- package/dist/admin-subscriptions.d.ts.map +1 -0
- package/dist/admin-subscriptions.js +22 -0
- package/dist/admin-subscriptions.js.map +1 -0
- package/dist/admin.d.ts +86 -75
- package/dist/admin.d.ts.map +1 -1
- package/dist/checkins.d.ts +22 -22
- package/dist/foods.d.ts +60 -60
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/metrics.d.ts +6 -6
- package/dist/settings.d.ts +52 -52
- package/dist/subscriptions.d.ts +46 -46
- package/dist/uploads.d.ts +194 -0
- package/dist/uploads.d.ts.map +1 -0
- package/dist/uploads.js +54 -0
- package/dist/uploads.js.map +1 -0
- package/dist/users.d.ts +48 -32
- package/dist/users.d.ts.map +1 -1
- package/dist/users.js +4 -0
- package/dist/users.js.map +1 -1
- package/package.json +5 -1
package/dist/subscriptions.d.ts
CHANGED
|
@@ -11,14 +11,14 @@ export declare const subscriptionPlanInfoSchema: z.ZodObject<{
|
|
|
11
11
|
priceLabel: z.ZodString;
|
|
12
12
|
billingPeriodLabel: z.ZodString;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
priceLabel: string;
|
|
15
14
|
plan: "monthly" | "annual";
|
|
16
15
|
productId: string;
|
|
16
|
+
priceLabel: string;
|
|
17
17
|
billingPeriodLabel: string;
|
|
18
18
|
}, {
|
|
19
|
-
priceLabel: string;
|
|
20
19
|
plan: "monthly" | "annual";
|
|
21
20
|
productId: string;
|
|
21
|
+
priceLabel: string;
|
|
22
22
|
billingPeriodLabel: string;
|
|
23
23
|
}>;
|
|
24
24
|
export type SubscriptionPlanInfo = z.infer<typeof subscriptionPlanInfoSchema>;
|
|
@@ -39,48 +39,48 @@ export declare const subscriptionStateSchema: z.ZodObject<{
|
|
|
39
39
|
priceLabel: z.ZodString;
|
|
40
40
|
billingPeriodLabel: z.ZodString;
|
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
priceLabel: string;
|
|
43
42
|
plan: "monthly" | "annual";
|
|
44
43
|
productId: string;
|
|
44
|
+
priceLabel: string;
|
|
45
45
|
billingPeriodLabel: string;
|
|
46
46
|
}, {
|
|
47
|
-
priceLabel: string;
|
|
48
47
|
plan: "monthly" | "annual";
|
|
49
48
|
productId: string;
|
|
49
|
+
priceLabel: string;
|
|
50
50
|
billingPeriodLabel: string;
|
|
51
51
|
}>, "many">;
|
|
52
52
|
}, "strip", z.ZodTypeAny, {
|
|
53
53
|
status: "active" | "trialing" | "canceled" | "expired" | "none";
|
|
54
|
-
priceLabel: string | null;
|
|
55
|
-
renewsAt: string | null;
|
|
56
|
-
cancelAtPeriodEnd: boolean;
|
|
57
|
-
trialDays: number;
|
|
58
54
|
plan: "monthly" | "annual" | null;
|
|
59
55
|
productId: string | null;
|
|
56
|
+
priceLabel: string | null;
|
|
60
57
|
entitlement: "free" | "premium";
|
|
58
|
+
renewsAt: string | null;
|
|
61
59
|
accessEndsAt: string | null;
|
|
60
|
+
cancelAtPeriodEnd: boolean;
|
|
62
61
|
trialUsed: boolean;
|
|
62
|
+
trialDays: number;
|
|
63
63
|
plans: {
|
|
64
|
-
priceLabel: string;
|
|
65
64
|
plan: "monthly" | "annual";
|
|
66
65
|
productId: string;
|
|
66
|
+
priceLabel: string;
|
|
67
67
|
billingPeriodLabel: string;
|
|
68
68
|
}[];
|
|
69
69
|
}, {
|
|
70
70
|
status: "active" | "trialing" | "canceled" | "expired" | "none";
|
|
71
|
-
priceLabel: string | null;
|
|
72
|
-
renewsAt: string | null;
|
|
73
|
-
cancelAtPeriodEnd: boolean;
|
|
74
|
-
trialDays: number;
|
|
75
71
|
plan: "monthly" | "annual" | null;
|
|
76
72
|
productId: string | null;
|
|
73
|
+
priceLabel: string | null;
|
|
77
74
|
entitlement: "free" | "premium";
|
|
75
|
+
renewsAt: string | null;
|
|
78
76
|
accessEndsAt: string | null;
|
|
77
|
+
cancelAtPeriodEnd: boolean;
|
|
79
78
|
trialUsed: boolean;
|
|
79
|
+
trialDays: number;
|
|
80
80
|
plans: {
|
|
81
|
-
priceLabel: string;
|
|
82
81
|
plan: "monthly" | "annual";
|
|
83
82
|
productId: string;
|
|
83
|
+
priceLabel: string;
|
|
84
84
|
billingPeriodLabel: string;
|
|
85
85
|
}[];
|
|
86
86
|
}>;
|
|
@@ -105,86 +105,86 @@ export declare const subscriptionResponseSchema: z.ZodObject<{
|
|
|
105
105
|
priceLabel: z.ZodString;
|
|
106
106
|
billingPeriodLabel: z.ZodString;
|
|
107
107
|
}, "strip", z.ZodTypeAny, {
|
|
108
|
-
priceLabel: string;
|
|
109
108
|
plan: "monthly" | "annual";
|
|
110
109
|
productId: string;
|
|
110
|
+
priceLabel: string;
|
|
111
111
|
billingPeriodLabel: string;
|
|
112
112
|
}, {
|
|
113
|
-
priceLabel: string;
|
|
114
113
|
plan: "monthly" | "annual";
|
|
115
114
|
productId: string;
|
|
115
|
+
priceLabel: string;
|
|
116
116
|
billingPeriodLabel: string;
|
|
117
117
|
}>, "many">;
|
|
118
118
|
}, "strip", z.ZodTypeAny, {
|
|
119
119
|
status: "active" | "trialing" | "canceled" | "expired" | "none";
|
|
120
|
-
priceLabel: string | null;
|
|
121
|
-
renewsAt: string | null;
|
|
122
|
-
cancelAtPeriodEnd: boolean;
|
|
123
|
-
trialDays: number;
|
|
124
120
|
plan: "monthly" | "annual" | null;
|
|
125
121
|
productId: string | null;
|
|
122
|
+
priceLabel: string | null;
|
|
126
123
|
entitlement: "free" | "premium";
|
|
124
|
+
renewsAt: string | null;
|
|
127
125
|
accessEndsAt: string | null;
|
|
126
|
+
cancelAtPeriodEnd: boolean;
|
|
128
127
|
trialUsed: boolean;
|
|
128
|
+
trialDays: number;
|
|
129
129
|
plans: {
|
|
130
|
-
priceLabel: string;
|
|
131
130
|
plan: "monthly" | "annual";
|
|
132
131
|
productId: string;
|
|
132
|
+
priceLabel: string;
|
|
133
133
|
billingPeriodLabel: string;
|
|
134
134
|
}[];
|
|
135
135
|
}, {
|
|
136
136
|
status: "active" | "trialing" | "canceled" | "expired" | "none";
|
|
137
|
-
priceLabel: string | null;
|
|
138
|
-
renewsAt: string | null;
|
|
139
|
-
cancelAtPeriodEnd: boolean;
|
|
140
|
-
trialDays: number;
|
|
141
137
|
plan: "monthly" | "annual" | null;
|
|
142
138
|
productId: string | null;
|
|
139
|
+
priceLabel: string | null;
|
|
143
140
|
entitlement: "free" | "premium";
|
|
141
|
+
renewsAt: string | null;
|
|
144
142
|
accessEndsAt: string | null;
|
|
143
|
+
cancelAtPeriodEnd: boolean;
|
|
145
144
|
trialUsed: boolean;
|
|
145
|
+
trialDays: number;
|
|
146
146
|
plans: {
|
|
147
|
-
priceLabel: string;
|
|
148
147
|
plan: "monthly" | "annual";
|
|
149
148
|
productId: string;
|
|
149
|
+
priceLabel: string;
|
|
150
150
|
billingPeriodLabel: string;
|
|
151
151
|
}[];
|
|
152
152
|
}>;
|
|
153
153
|
}, "strip", z.ZodTypeAny, {
|
|
154
154
|
subscription: {
|
|
155
155
|
status: "active" | "trialing" | "canceled" | "expired" | "none";
|
|
156
|
-
priceLabel: string | null;
|
|
157
|
-
renewsAt: string | null;
|
|
158
|
-
cancelAtPeriodEnd: boolean;
|
|
159
|
-
trialDays: number;
|
|
160
156
|
plan: "monthly" | "annual" | null;
|
|
161
157
|
productId: string | null;
|
|
158
|
+
priceLabel: string | null;
|
|
162
159
|
entitlement: "free" | "premium";
|
|
160
|
+
renewsAt: string | null;
|
|
163
161
|
accessEndsAt: string | null;
|
|
162
|
+
cancelAtPeriodEnd: boolean;
|
|
164
163
|
trialUsed: boolean;
|
|
164
|
+
trialDays: number;
|
|
165
165
|
plans: {
|
|
166
|
-
priceLabel: string;
|
|
167
166
|
plan: "monthly" | "annual";
|
|
168
167
|
productId: string;
|
|
168
|
+
priceLabel: string;
|
|
169
169
|
billingPeriodLabel: string;
|
|
170
170
|
}[];
|
|
171
171
|
};
|
|
172
172
|
}, {
|
|
173
173
|
subscription: {
|
|
174
174
|
status: "active" | "trialing" | "canceled" | "expired" | "none";
|
|
175
|
-
priceLabel: string | null;
|
|
176
|
-
renewsAt: string | null;
|
|
177
|
-
cancelAtPeriodEnd: boolean;
|
|
178
|
-
trialDays: number;
|
|
179
175
|
plan: "monthly" | "annual" | null;
|
|
180
176
|
productId: string | null;
|
|
177
|
+
priceLabel: string | null;
|
|
181
178
|
entitlement: "free" | "premium";
|
|
179
|
+
renewsAt: string | null;
|
|
182
180
|
accessEndsAt: string | null;
|
|
181
|
+
cancelAtPeriodEnd: boolean;
|
|
183
182
|
trialUsed: boolean;
|
|
183
|
+
trialDays: number;
|
|
184
184
|
plans: {
|
|
185
|
-
priceLabel: string;
|
|
186
185
|
plan: "monthly" | "annual";
|
|
187
186
|
productId: string;
|
|
187
|
+
priceLabel: string;
|
|
188
188
|
billingPeriodLabel: string;
|
|
189
189
|
}[];
|
|
190
190
|
};
|
|
@@ -198,19 +198,19 @@ export declare const subscriptionResponseSchema: z.ZodObject<{
|
|
|
198
198
|
data: {
|
|
199
199
|
subscription: {
|
|
200
200
|
status: "active" | "trialing" | "canceled" | "expired" | "none";
|
|
201
|
-
priceLabel: string | null;
|
|
202
|
-
renewsAt: string | null;
|
|
203
|
-
cancelAtPeriodEnd: boolean;
|
|
204
|
-
trialDays: number;
|
|
205
201
|
plan: "monthly" | "annual" | null;
|
|
206
202
|
productId: string | null;
|
|
203
|
+
priceLabel: string | null;
|
|
207
204
|
entitlement: "free" | "premium";
|
|
205
|
+
renewsAt: string | null;
|
|
208
206
|
accessEndsAt: string | null;
|
|
207
|
+
cancelAtPeriodEnd: boolean;
|
|
209
208
|
trialUsed: boolean;
|
|
209
|
+
trialDays: number;
|
|
210
210
|
plans: {
|
|
211
|
-
priceLabel: string;
|
|
212
211
|
plan: "monthly" | "annual";
|
|
213
212
|
productId: string;
|
|
213
|
+
priceLabel: string;
|
|
214
214
|
billingPeriodLabel: string;
|
|
215
215
|
}[];
|
|
216
216
|
};
|
|
@@ -222,19 +222,19 @@ export declare const subscriptionResponseSchema: z.ZodObject<{
|
|
|
222
222
|
data: {
|
|
223
223
|
subscription: {
|
|
224
224
|
status: "active" | "trialing" | "canceled" | "expired" | "none";
|
|
225
|
-
priceLabel: string | null;
|
|
226
|
-
renewsAt: string | null;
|
|
227
|
-
cancelAtPeriodEnd: boolean;
|
|
228
|
-
trialDays: number;
|
|
229
225
|
plan: "monthly" | "annual" | null;
|
|
230
226
|
productId: string | null;
|
|
227
|
+
priceLabel: string | null;
|
|
231
228
|
entitlement: "free" | "premium";
|
|
229
|
+
renewsAt: string | null;
|
|
232
230
|
accessEndsAt: string | null;
|
|
231
|
+
cancelAtPeriodEnd: boolean;
|
|
233
232
|
trialUsed: boolean;
|
|
233
|
+
trialDays: number;
|
|
234
234
|
plans: {
|
|
235
|
-
priceLabel: string;
|
|
236
235
|
plan: "monthly" | "annual";
|
|
237
236
|
productId: string;
|
|
237
|
+
priceLabel: string;
|
|
238
238
|
billingPeriodLabel: string;
|
|
239
239
|
}[];
|
|
240
240
|
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Generic presigned-upload contract. Clients ask for a presigned PUT URL, upload
|
|
4
|
+
* the bytes straight to R2, then confirm. `intent` keeps one flow reusable across
|
|
5
|
+
* upload kinds — `avatar` ships now; `progress_photo`/`meal_photo` are reserved
|
|
6
|
+
* for the roadmap features and rejected by the service until wired up.
|
|
7
|
+
*/
|
|
8
|
+
export declare const uploadIntentSchema: z.ZodEnum<["avatar", "progress_photo", "meal_photo"]>;
|
|
9
|
+
export type UploadIntent = z.infer<typeof uploadIntentSchema>;
|
|
10
|
+
export declare const uploadStatusSchema: z.ZodEnum<["pending", "uploaded", "verified", "failed", "expired"]>;
|
|
11
|
+
export type UploadStatus = z.infer<typeof uploadStatusSchema>;
|
|
12
|
+
/** Image formats accepted for image intents (avatar/photos). */
|
|
13
|
+
export declare const imageExtensionSchema: z.ZodEnum<["jpg", "jpeg", "png", "webp", "heic"]>;
|
|
14
|
+
export type ImageExtension = z.infer<typeof imageExtensionSchema>;
|
|
15
|
+
export declare const requestUploadPayloadSchema: z.ZodObject<{
|
|
16
|
+
intent: z.ZodEnum<["avatar", "progress_photo", "meal_photo"]>;
|
|
17
|
+
fileExtension: z.ZodEnum<["jpg", "jpeg", "png", "webp", "heic"]>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
intent: "avatar" | "progress_photo" | "meal_photo";
|
|
20
|
+
fileExtension: "jpg" | "jpeg" | "png" | "webp" | "heic";
|
|
21
|
+
}, {
|
|
22
|
+
intent: "avatar" | "progress_photo" | "meal_photo";
|
|
23
|
+
fileExtension: "jpg" | "jpeg" | "png" | "webp" | "heic";
|
|
24
|
+
}>;
|
|
25
|
+
export type RequestUploadPayload = z.infer<typeof requestUploadPayloadSchema>;
|
|
26
|
+
export declare const requestUploadResultSchema: z.ZodObject<{
|
|
27
|
+
uploadId: z.ZodString;
|
|
28
|
+
/** Presigned PUT URL — the client uploads the file bytes here. */
|
|
29
|
+
uploadUrl: z.ZodString;
|
|
30
|
+
/** Content-Type the client MUST send on the PUT so the signature matches. */
|
|
31
|
+
contentType: z.ZodString;
|
|
32
|
+
key: z.ZodString;
|
|
33
|
+
/** Public read URL the object will live at once verified. */
|
|
34
|
+
publicUrl: z.ZodString;
|
|
35
|
+
/**
|
|
36
|
+
* Server-owned max upload size in bytes for this intent. The client SHOULD
|
|
37
|
+
* reject larger files before uploading; the server re-checks on verify, so a
|
|
38
|
+
* tampered client can't bypass it.
|
|
39
|
+
*/
|
|
40
|
+
maxBytes: z.ZodNumber;
|
|
41
|
+
expiresAt: z.ZodDate;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
key: string;
|
|
44
|
+
uploadId: string;
|
|
45
|
+
uploadUrl: string;
|
|
46
|
+
contentType: string;
|
|
47
|
+
publicUrl: string;
|
|
48
|
+
maxBytes: number;
|
|
49
|
+
expiresAt: Date;
|
|
50
|
+
}, {
|
|
51
|
+
key: string;
|
|
52
|
+
uploadId: string;
|
|
53
|
+
uploadUrl: string;
|
|
54
|
+
contentType: string;
|
|
55
|
+
publicUrl: string;
|
|
56
|
+
maxBytes: number;
|
|
57
|
+
expiresAt: Date;
|
|
58
|
+
}>;
|
|
59
|
+
export type RequestUploadResult = z.infer<typeof requestUploadResultSchema>;
|
|
60
|
+
export declare const requestUploadResponseSchema: z.ZodObject<{
|
|
61
|
+
success: z.ZodLiteral<true>;
|
|
62
|
+
data: z.ZodObject<{
|
|
63
|
+
uploadId: z.ZodString;
|
|
64
|
+
/** Presigned PUT URL — the client uploads the file bytes here. */
|
|
65
|
+
uploadUrl: z.ZodString;
|
|
66
|
+
/** Content-Type the client MUST send on the PUT so the signature matches. */
|
|
67
|
+
contentType: z.ZodString;
|
|
68
|
+
key: z.ZodString;
|
|
69
|
+
/** Public read URL the object will live at once verified. */
|
|
70
|
+
publicUrl: z.ZodString;
|
|
71
|
+
/**
|
|
72
|
+
* Server-owned max upload size in bytes for this intent. The client SHOULD
|
|
73
|
+
* reject larger files before uploading; the server re-checks on verify, so a
|
|
74
|
+
* tampered client can't bypass it.
|
|
75
|
+
*/
|
|
76
|
+
maxBytes: z.ZodNumber;
|
|
77
|
+
expiresAt: z.ZodDate;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
key: string;
|
|
80
|
+
uploadId: string;
|
|
81
|
+
uploadUrl: string;
|
|
82
|
+
contentType: string;
|
|
83
|
+
publicUrl: string;
|
|
84
|
+
maxBytes: number;
|
|
85
|
+
expiresAt: Date;
|
|
86
|
+
}, {
|
|
87
|
+
key: string;
|
|
88
|
+
uploadId: string;
|
|
89
|
+
uploadUrl: string;
|
|
90
|
+
contentType: string;
|
|
91
|
+
publicUrl: string;
|
|
92
|
+
maxBytes: number;
|
|
93
|
+
expiresAt: Date;
|
|
94
|
+
}>;
|
|
95
|
+
responseCode: z.ZodNumber;
|
|
96
|
+
message: z.ZodString;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
message: string;
|
|
99
|
+
success: true;
|
|
100
|
+
responseCode: number;
|
|
101
|
+
data: {
|
|
102
|
+
key: string;
|
|
103
|
+
uploadId: string;
|
|
104
|
+
uploadUrl: string;
|
|
105
|
+
contentType: string;
|
|
106
|
+
publicUrl: string;
|
|
107
|
+
maxBytes: number;
|
|
108
|
+
expiresAt: Date;
|
|
109
|
+
};
|
|
110
|
+
}, {
|
|
111
|
+
message: string;
|
|
112
|
+
success: true;
|
|
113
|
+
responseCode: number;
|
|
114
|
+
data: {
|
|
115
|
+
key: string;
|
|
116
|
+
uploadId: string;
|
|
117
|
+
uploadUrl: string;
|
|
118
|
+
contentType: string;
|
|
119
|
+
publicUrl: string;
|
|
120
|
+
maxBytes: number;
|
|
121
|
+
expiresAt: Date;
|
|
122
|
+
};
|
|
123
|
+
}>;
|
|
124
|
+
export declare const verifyUploadResultSchema: z.ZodObject<{
|
|
125
|
+
uploadId: z.ZodString;
|
|
126
|
+
status: z.ZodEnum<["pending", "uploaded", "verified", "failed", "expired"]>;
|
|
127
|
+
publicUrl: z.ZodString;
|
|
128
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
status: "failed" | "expired" | "pending" | "uploaded" | "verified";
|
|
131
|
+
uploadId: string;
|
|
132
|
+
publicUrl: string;
|
|
133
|
+
size: number | null;
|
|
134
|
+
}, {
|
|
135
|
+
status: "failed" | "expired" | "pending" | "uploaded" | "verified";
|
|
136
|
+
uploadId: string;
|
|
137
|
+
publicUrl: string;
|
|
138
|
+
size: number | null;
|
|
139
|
+
}>;
|
|
140
|
+
export type VerifyUploadResult = z.infer<typeof verifyUploadResultSchema>;
|
|
141
|
+
export declare const verifyUploadResponseSchema: z.ZodObject<{
|
|
142
|
+
success: z.ZodLiteral<true>;
|
|
143
|
+
data: z.ZodObject<{
|
|
144
|
+
uploadId: z.ZodString;
|
|
145
|
+
status: z.ZodEnum<["pending", "uploaded", "verified", "failed", "expired"]>;
|
|
146
|
+
publicUrl: z.ZodString;
|
|
147
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
status: "failed" | "expired" | "pending" | "uploaded" | "verified";
|
|
150
|
+
uploadId: string;
|
|
151
|
+
publicUrl: string;
|
|
152
|
+
size: number | null;
|
|
153
|
+
}, {
|
|
154
|
+
status: "failed" | "expired" | "pending" | "uploaded" | "verified";
|
|
155
|
+
uploadId: string;
|
|
156
|
+
publicUrl: string;
|
|
157
|
+
size: number | null;
|
|
158
|
+
}>;
|
|
159
|
+
responseCode: z.ZodNumber;
|
|
160
|
+
message: z.ZodString;
|
|
161
|
+
}, "strip", z.ZodTypeAny, {
|
|
162
|
+
message: string;
|
|
163
|
+
success: true;
|
|
164
|
+
responseCode: number;
|
|
165
|
+
data: {
|
|
166
|
+
status: "failed" | "expired" | "pending" | "uploaded" | "verified";
|
|
167
|
+
uploadId: string;
|
|
168
|
+
publicUrl: string;
|
|
169
|
+
size: number | null;
|
|
170
|
+
};
|
|
171
|
+
}, {
|
|
172
|
+
message: string;
|
|
173
|
+
success: true;
|
|
174
|
+
responseCode: number;
|
|
175
|
+
data: {
|
|
176
|
+
status: "failed" | "expired" | "pending" | "uploaded" | "verified";
|
|
177
|
+
uploadId: string;
|
|
178
|
+
publicUrl: string;
|
|
179
|
+
size: number | null;
|
|
180
|
+
};
|
|
181
|
+
}>;
|
|
182
|
+
export declare const uploadRoutes: {
|
|
183
|
+
requestUpload: {
|
|
184
|
+
method: "POST";
|
|
185
|
+
path: "/api/v1/uploads/presigned-url";
|
|
186
|
+
auth: "user";
|
|
187
|
+
};
|
|
188
|
+
verifyUpload: {
|
|
189
|
+
method: "POST";
|
|
190
|
+
path: "/api/v1/uploads/:id/verify";
|
|
191
|
+
auth: "user";
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
//# sourceMappingURL=uploads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../src/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,uDAAqD,CAAC;AACrF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,kBAAkB,qEAAmE,CAAC;AACnG,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,mDAAiD,CAAC;AACnF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,0BAA0B;;;;;;;;;EAGrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,yBAAyB;;IAEpC,kEAAkE;;IAElE,6EAA6E;;;IAG7E,6DAA6D;;IAE7D;;;;OAIG;;;;;;;;;;;;;;;;;;;EAGH,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,eAAO,MAAM,2BAA2B;;;;QAhBtC,kEAAkE;;QAElE,6EAA6E;;;QAG7E,6DAA6D;;QAE7D;;;;WAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKiF,CAAC;AAEvF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA6C,CAAC;AAErF,eAAO,MAAM,YAAY;;;;;;;;;;;CAWgB,CAAC"}
|
package/dist/uploads.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { apiSuccessSchema } from "./common";
|
|
3
|
+
/**
|
|
4
|
+
* Generic presigned-upload contract. Clients ask for a presigned PUT URL, upload
|
|
5
|
+
* the bytes straight to R2, then confirm. `intent` keeps one flow reusable across
|
|
6
|
+
* upload kinds — `avatar` ships now; `progress_photo`/`meal_photo` are reserved
|
|
7
|
+
* for the roadmap features and rejected by the service until wired up.
|
|
8
|
+
*/
|
|
9
|
+
export const uploadIntentSchema = z.enum(["avatar", "progress_photo", "meal_photo"]);
|
|
10
|
+
export const uploadStatusSchema = z.enum(["pending", "uploaded", "verified", "failed", "expired"]);
|
|
11
|
+
/** Image formats accepted for image intents (avatar/photos). */
|
|
12
|
+
export const imageExtensionSchema = z.enum(["jpg", "jpeg", "png", "webp", "heic"]);
|
|
13
|
+
export const requestUploadPayloadSchema = z.object({
|
|
14
|
+
intent: uploadIntentSchema,
|
|
15
|
+
fileExtension: imageExtensionSchema,
|
|
16
|
+
});
|
|
17
|
+
export const requestUploadResultSchema = z.object({
|
|
18
|
+
uploadId: z.string().uuid(),
|
|
19
|
+
/** Presigned PUT URL — the client uploads the file bytes here. */
|
|
20
|
+
uploadUrl: z.string().url(),
|
|
21
|
+
/** Content-Type the client MUST send on the PUT so the signature matches. */
|
|
22
|
+
contentType: z.string(),
|
|
23
|
+
key: z.string(),
|
|
24
|
+
/** Public read URL the object will live at once verified. */
|
|
25
|
+
publicUrl: z.string().url(),
|
|
26
|
+
/**
|
|
27
|
+
* Server-owned max upload size in bytes for this intent. The client SHOULD
|
|
28
|
+
* reject larger files before uploading; the server re-checks on verify, so a
|
|
29
|
+
* tampered client can't bypass it.
|
|
30
|
+
*/
|
|
31
|
+
maxBytes: z.number().int().positive(),
|
|
32
|
+
expiresAt: z.coerce.date(),
|
|
33
|
+
});
|
|
34
|
+
export const requestUploadResponseSchema = apiSuccessSchema(requestUploadResultSchema);
|
|
35
|
+
export const verifyUploadResultSchema = z.object({
|
|
36
|
+
uploadId: z.string().uuid(),
|
|
37
|
+
status: uploadStatusSchema,
|
|
38
|
+
publicUrl: z.string().url(),
|
|
39
|
+
size: z.number().int().nullable(),
|
|
40
|
+
});
|
|
41
|
+
export const verifyUploadResponseSchema = apiSuccessSchema(verifyUploadResultSchema);
|
|
42
|
+
export const uploadRoutes = {
|
|
43
|
+
requestUpload: {
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/api/v1/uploads/presigned-url",
|
|
46
|
+
auth: "user",
|
|
47
|
+
},
|
|
48
|
+
verifyUpload: {
|
|
49
|
+
method: "POST",
|
|
50
|
+
path: "/api/v1/uploads/:id/verify",
|
|
51
|
+
auth: "user",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=uploads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["../src/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM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