@beorchid-llc/thrivo-contracts 0.5.4 → 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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,gBAAgB,mCAAiC,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,qBAAqB,2FAQhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAIpE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAclC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU1C,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAuC,CAAC;AAC/E,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA4C,CAAC;AACzF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,cAAc;;;;;;;;;;;CAWc,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { z } from "zod";
2
+ import { apiSuccessSchema } from "./common";
3
+ export const unitSystemSchema = z.enum(["metric", "imperial"]);
4
+ export const reminderWeekdaySchema = z.enum([
5
+ "monday",
6
+ "tuesday",
7
+ "wednesday",
8
+ "thursday",
9
+ "friday",
10
+ "saturday",
11
+ "sunday",
12
+ ]);
13
+ const timeSchema = z.string().regex(/^\d{2}:\d{2}(:\d{2})?$/);
14
+ export const globalSettingsSchema = z.object({
15
+ key: z.literal("default"),
16
+ pushNotificationsEnabled: z.boolean(),
17
+ dailyFoodLogReminderEnabled: z.boolean(),
18
+ weightCheckReminderEnabled: z.boolean(),
19
+ hydrationReminderEnabled: z.boolean(),
20
+ subscriptionsEnabled: z.boolean(),
21
+ trialsEnabled: z.boolean(),
22
+ purchasesEnabled: z.boolean(),
23
+ cancellationsEnabled: z.boolean(),
24
+ trialDays: z.number().int().min(1).max(90),
25
+ createdAt: z.coerce.date(),
26
+ updatedAt: z.coerce.date(),
27
+ });
28
+ export const userSettingsSchema = z.object({
29
+ id: z.string().uuid(),
30
+ userId: z.string().uuid(),
31
+ unitSystem: unitSystemSchema,
32
+ pushNotificationsEnabled: z.boolean(),
33
+ dailyFoodLogReminderEnabled: z.boolean(),
34
+ dailyFoodLogReminderTime: timeSchema,
35
+ weightCheckReminderEnabled: z.boolean(),
36
+ weightCheckReminderDay: reminderWeekdaySchema,
37
+ weightCheckReminderTime: timeSchema,
38
+ hydrationReminderEnabled: z.boolean(),
39
+ hydrationReminderIntervalMinutes: z.number().int().min(5).max(240),
40
+ createdAt: z.coerce.date(),
41
+ updatedAt: z.coerce.date(),
42
+ });
43
+ export const effectiveSettingsSchema = z.object({
44
+ global: globalSettingsSchema,
45
+ user: userSettingsSchema,
46
+ effective: z.object({
47
+ pushNotificationsEnabled: z.boolean(),
48
+ dailyFoodLogReminderEnabled: z.boolean(),
49
+ weightCheckReminderEnabled: z.boolean(),
50
+ hydrationReminderEnabled: z.boolean(),
51
+ subscriptionsEnabled: z.boolean(),
52
+ trialsEnabled: z.boolean(),
53
+ purchasesEnabled: z.boolean(),
54
+ cancellationsEnabled: z.boolean(),
55
+ trialDays: z.number().int(),
56
+ }),
57
+ });
58
+ export const updateUserSettingsPayloadSchema = z.object({
59
+ unitSystem: unitSystemSchema.optional(),
60
+ pushNotificationsEnabled: z.boolean().optional(),
61
+ dailyFoodLogReminderEnabled: z.boolean().optional(),
62
+ dailyFoodLogReminderTime: timeSchema.optional(),
63
+ weightCheckReminderEnabled: z.boolean().optional(),
64
+ weightCheckReminderDay: reminderWeekdaySchema.optional(),
65
+ weightCheckReminderTime: timeSchema.optional(),
66
+ hydrationReminderEnabled: z.boolean().optional(),
67
+ hydrationReminderIntervalMinutes: z.number().int().min(5).max(240).optional(),
68
+ });
69
+ export const updateGlobalSettingsPayloadSchema = z.object({
70
+ pushNotificationsEnabled: z.boolean().optional(),
71
+ dailyFoodLogReminderEnabled: z.boolean().optional(),
72
+ weightCheckReminderEnabled: z.boolean().optional(),
73
+ hydrationReminderEnabled: z.boolean().optional(),
74
+ subscriptionsEnabled: z.boolean().optional(),
75
+ trialsEnabled: z.boolean().optional(),
76
+ purchasesEnabled: z.boolean().optional(),
77
+ cancellationsEnabled: z.boolean().optional(),
78
+ trialDays: z.number().int().min(1).max(90).optional(),
79
+ });
80
+ export const userSettingsResponseSchema = apiSuccessSchema(userSettingsSchema);
81
+ export const effectiveSettingsResponseSchema = apiSuccessSchema(effectiveSettingsSchema);
82
+ export const settingsRoutes = {
83
+ getUserSettings: {
84
+ method: "GET",
85
+ path: "/api/v1/users/me/settings",
86
+ auth: "user",
87
+ },
88
+ updateUserSettings: {
89
+ method: "PATCH",
90
+ path: "/api/v1/users/me/settings",
91
+ auth: "user",
92
+ },
93
+ };
94
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAsB,MAAM,UAAU,CAAC;AAEhE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAG/D,MAAM,CAAC,MAAM,qB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,0BAA0B,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;AAG/E,MAAM,CAAC,MAAM,+BAA+B,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;AAGzF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,eAAe,EAAE;QACf,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,MAAM;KACb;IACD,kBAAkB,EAAE;QAClB,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,MAAM;KACb;CACsC,CAAC"}
@@ -0,0 +1,290 @@
1
+ import { z } from "zod";
2
+ export declare const subscriptionPlanSchema: z.ZodEnum<["monthly", "annual"]>;
3
+ export type SubscriptionPlan = z.infer<typeof subscriptionPlanSchema>;
4
+ export declare const publicSubscriptionStatusSchema: z.ZodEnum<["active", "trialing", "canceled", "expired", "none"]>;
5
+ export type PublicSubscriptionStatus = z.infer<typeof publicSubscriptionStatusSchema>;
6
+ export declare const entitlementSchema: z.ZodEnum<["free", "premium"]>;
7
+ export type Entitlement = z.infer<typeof entitlementSchema>;
8
+ export declare const subscriptionPlanInfoSchema: z.ZodObject<{
9
+ plan: z.ZodEnum<["monthly", "annual"]>;
10
+ productId: z.ZodString;
11
+ priceLabel: z.ZodString;
12
+ billingPeriodLabel: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ priceLabel: string;
15
+ plan: "monthly" | "annual";
16
+ productId: string;
17
+ billingPeriodLabel: string;
18
+ }, {
19
+ priceLabel: string;
20
+ plan: "monthly" | "annual";
21
+ productId: string;
22
+ billingPeriodLabel: string;
23
+ }>;
24
+ export type SubscriptionPlanInfo = z.infer<typeof subscriptionPlanInfoSchema>;
25
+ export declare const subscriptionStateSchema: z.ZodObject<{
26
+ entitlement: z.ZodEnum<["free", "premium"]>;
27
+ status: z.ZodEnum<["active", "trialing", "canceled", "expired", "none"]>;
28
+ plan: z.ZodNullable<z.ZodEnum<["monthly", "annual"]>>;
29
+ productId: z.ZodNullable<z.ZodString>;
30
+ priceLabel: z.ZodNullable<z.ZodString>;
31
+ renewsAt: z.ZodNullable<z.ZodString>;
32
+ accessEndsAt: z.ZodNullable<z.ZodString>;
33
+ cancelAtPeriodEnd: z.ZodBoolean;
34
+ trialUsed: z.ZodBoolean;
35
+ trialDays: z.ZodNumber;
36
+ plans: z.ZodArray<z.ZodObject<{
37
+ plan: z.ZodEnum<["monthly", "annual"]>;
38
+ productId: z.ZodString;
39
+ priceLabel: z.ZodString;
40
+ billingPeriodLabel: z.ZodString;
41
+ }, "strip", z.ZodTypeAny, {
42
+ priceLabel: string;
43
+ plan: "monthly" | "annual";
44
+ productId: string;
45
+ billingPeriodLabel: string;
46
+ }, {
47
+ priceLabel: string;
48
+ plan: "monthly" | "annual";
49
+ productId: string;
50
+ billingPeriodLabel: string;
51
+ }>, "many">;
52
+ }, "strip", z.ZodTypeAny, {
53
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
54
+ priceLabel: string | null;
55
+ renewsAt: string | null;
56
+ cancelAtPeriodEnd: boolean;
57
+ trialDays: number;
58
+ plan: "monthly" | "annual" | null;
59
+ productId: string | null;
60
+ entitlement: "free" | "premium";
61
+ accessEndsAt: string | null;
62
+ trialUsed: boolean;
63
+ plans: {
64
+ priceLabel: string;
65
+ plan: "monthly" | "annual";
66
+ productId: string;
67
+ billingPeriodLabel: string;
68
+ }[];
69
+ }, {
70
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
71
+ priceLabel: string | null;
72
+ renewsAt: string | null;
73
+ cancelAtPeriodEnd: boolean;
74
+ trialDays: number;
75
+ plan: "monthly" | "annual" | null;
76
+ productId: string | null;
77
+ entitlement: "free" | "premium";
78
+ accessEndsAt: string | null;
79
+ trialUsed: boolean;
80
+ plans: {
81
+ priceLabel: string;
82
+ plan: "monthly" | "annual";
83
+ productId: string;
84
+ billingPeriodLabel: string;
85
+ }[];
86
+ }>;
87
+ export type SubscriptionState = z.infer<typeof subscriptionStateSchema>;
88
+ export declare const subscriptionResponseSchema: z.ZodObject<{
89
+ success: z.ZodLiteral<true>;
90
+ data: z.ZodObject<{
91
+ subscription: z.ZodObject<{
92
+ entitlement: z.ZodEnum<["free", "premium"]>;
93
+ status: z.ZodEnum<["active", "trialing", "canceled", "expired", "none"]>;
94
+ plan: z.ZodNullable<z.ZodEnum<["monthly", "annual"]>>;
95
+ productId: z.ZodNullable<z.ZodString>;
96
+ priceLabel: z.ZodNullable<z.ZodString>;
97
+ renewsAt: z.ZodNullable<z.ZodString>;
98
+ accessEndsAt: z.ZodNullable<z.ZodString>;
99
+ cancelAtPeriodEnd: z.ZodBoolean;
100
+ trialUsed: z.ZodBoolean;
101
+ trialDays: z.ZodNumber;
102
+ plans: z.ZodArray<z.ZodObject<{
103
+ plan: z.ZodEnum<["monthly", "annual"]>;
104
+ productId: z.ZodString;
105
+ priceLabel: z.ZodString;
106
+ billingPeriodLabel: z.ZodString;
107
+ }, "strip", z.ZodTypeAny, {
108
+ priceLabel: string;
109
+ plan: "monthly" | "annual";
110
+ productId: string;
111
+ billingPeriodLabel: string;
112
+ }, {
113
+ priceLabel: string;
114
+ plan: "monthly" | "annual";
115
+ productId: string;
116
+ billingPeriodLabel: string;
117
+ }>, "many">;
118
+ }, "strip", z.ZodTypeAny, {
119
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
120
+ priceLabel: string | null;
121
+ renewsAt: string | null;
122
+ cancelAtPeriodEnd: boolean;
123
+ trialDays: number;
124
+ plan: "monthly" | "annual" | null;
125
+ productId: string | null;
126
+ entitlement: "free" | "premium";
127
+ accessEndsAt: string | null;
128
+ trialUsed: boolean;
129
+ plans: {
130
+ priceLabel: string;
131
+ plan: "monthly" | "annual";
132
+ productId: string;
133
+ billingPeriodLabel: string;
134
+ }[];
135
+ }, {
136
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
137
+ priceLabel: string | null;
138
+ renewsAt: string | null;
139
+ cancelAtPeriodEnd: boolean;
140
+ trialDays: number;
141
+ plan: "monthly" | "annual" | null;
142
+ productId: string | null;
143
+ entitlement: "free" | "premium";
144
+ accessEndsAt: string | null;
145
+ trialUsed: boolean;
146
+ plans: {
147
+ priceLabel: string;
148
+ plan: "monthly" | "annual";
149
+ productId: string;
150
+ billingPeriodLabel: string;
151
+ }[];
152
+ }>;
153
+ }, "strip", z.ZodTypeAny, {
154
+ subscription: {
155
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
156
+ priceLabel: string | null;
157
+ renewsAt: string | null;
158
+ cancelAtPeriodEnd: boolean;
159
+ trialDays: number;
160
+ plan: "monthly" | "annual" | null;
161
+ productId: string | null;
162
+ entitlement: "free" | "premium";
163
+ accessEndsAt: string | null;
164
+ trialUsed: boolean;
165
+ plans: {
166
+ priceLabel: string;
167
+ plan: "monthly" | "annual";
168
+ productId: string;
169
+ billingPeriodLabel: string;
170
+ }[];
171
+ };
172
+ }, {
173
+ subscription: {
174
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
175
+ priceLabel: string | null;
176
+ renewsAt: string | null;
177
+ cancelAtPeriodEnd: boolean;
178
+ trialDays: number;
179
+ plan: "monthly" | "annual" | null;
180
+ productId: string | null;
181
+ entitlement: "free" | "premium";
182
+ accessEndsAt: string | null;
183
+ trialUsed: boolean;
184
+ plans: {
185
+ priceLabel: string;
186
+ plan: "monthly" | "annual";
187
+ productId: string;
188
+ billingPeriodLabel: string;
189
+ }[];
190
+ };
191
+ }>;
192
+ responseCode: z.ZodNumber;
193
+ message: z.ZodString;
194
+ }, "strip", z.ZodTypeAny, {
195
+ message: string;
196
+ success: true;
197
+ responseCode: number;
198
+ data: {
199
+ subscription: {
200
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
201
+ priceLabel: string | null;
202
+ renewsAt: string | null;
203
+ cancelAtPeriodEnd: boolean;
204
+ trialDays: number;
205
+ plan: "monthly" | "annual" | null;
206
+ productId: string | null;
207
+ entitlement: "free" | "premium";
208
+ accessEndsAt: string | null;
209
+ trialUsed: boolean;
210
+ plans: {
211
+ priceLabel: string;
212
+ plan: "monthly" | "annual";
213
+ productId: string;
214
+ billingPeriodLabel: string;
215
+ }[];
216
+ };
217
+ };
218
+ }, {
219
+ message: string;
220
+ success: true;
221
+ responseCode: number;
222
+ data: {
223
+ subscription: {
224
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
225
+ priceLabel: string | null;
226
+ renewsAt: string | null;
227
+ cancelAtPeriodEnd: boolean;
228
+ trialDays: number;
229
+ plan: "monthly" | "annual" | null;
230
+ productId: string | null;
231
+ entitlement: "free" | "premium";
232
+ accessEndsAt: string | null;
233
+ trialUsed: boolean;
234
+ plans: {
235
+ priceLabel: string;
236
+ plan: "monthly" | "annual";
237
+ productId: string;
238
+ billingPeriodLabel: string;
239
+ }[];
240
+ };
241
+ };
242
+ }>;
243
+ export type SubscriptionResponse = z.infer<typeof subscriptionResponseSchema>;
244
+ export declare const startTrialPayloadSchema: z.ZodObject<{
245
+ plan: z.ZodDefault<z.ZodEnum<["monthly", "annual"]>>;
246
+ }, "strip", z.ZodTypeAny, {
247
+ plan: "monthly" | "annual";
248
+ }, {
249
+ plan?: "monthly" | "annual" | undefined;
250
+ }>;
251
+ export type StartTrialPayload = z.infer<typeof startTrialPayloadSchema>;
252
+ export declare const purchaseSubscriptionPayloadSchema: z.ZodObject<{
253
+ plan: z.ZodEnum<["monthly", "annual"]>;
254
+ }, "strip", z.ZodTypeAny, {
255
+ plan: "monthly" | "annual";
256
+ }, {
257
+ plan: "monthly" | "annual";
258
+ }>;
259
+ export type PurchaseSubscriptionPayload = z.infer<typeof purchaseSubscriptionPayloadSchema>;
260
+ export declare const cancelSubscriptionPayloadSchema: z.ZodObject<{
261
+ reason: z.ZodOptional<z.ZodString>;
262
+ }, "strip", z.ZodTypeAny, {
263
+ reason?: string | undefined;
264
+ }, {
265
+ reason?: string | undefined;
266
+ }>;
267
+ export type CancelSubscriptionPayload = z.infer<typeof cancelSubscriptionPayloadSchema>;
268
+ export declare const subscriptionRoutes: {
269
+ getMine: {
270
+ method: "GET";
271
+ path: "/api/v1/subscriptions/me";
272
+ auth: "user";
273
+ };
274
+ startTrial: {
275
+ method: "POST";
276
+ path: "/api/v1/subscriptions/trial";
277
+ auth: "user";
278
+ };
279
+ purchase: {
280
+ method: "POST";
281
+ path: "/api/v1/subscriptions/purchase";
282
+ auth: "user";
283
+ };
284
+ cancel: {
285
+ method: "POST";
286
+ path: "/api/v1/subscriptions/cancel";
287
+ auth: "user";
288
+ };
289
+ };
290
+ //# sourceMappingURL=subscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../src/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,sBAAsB,kCAAgC,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,8BAA8B,kEAMzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,eAAO,MAAM,iBAAiB,gCAA8B,CAAC;AAC7D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;EAKrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEtC,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,iCAAiC;;;;;;EAE5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F,eAAO,MAAM,+BAA+B;;;;;;EAE1C,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;CAqBU,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { z } from "zod";
2
+ import { apiSuccessSchema } from "./common";
3
+ export const subscriptionPlanSchema = z.enum(["monthly", "annual"]);
4
+ export const publicSubscriptionStatusSchema = z.enum([
5
+ "active",
6
+ "trialing",
7
+ "canceled",
8
+ "expired",
9
+ "none",
10
+ ]);
11
+ export const entitlementSchema = z.enum(["free", "premium"]);
12
+ export const subscriptionPlanInfoSchema = z.object({
13
+ plan: subscriptionPlanSchema,
14
+ productId: z.string(),
15
+ priceLabel: z.string(),
16
+ billingPeriodLabel: z.string(),
17
+ });
18
+ export const subscriptionStateSchema = z.object({
19
+ entitlement: entitlementSchema,
20
+ status: publicSubscriptionStatusSchema,
21
+ plan: subscriptionPlanSchema.nullable(),
22
+ productId: z.string().nullable(),
23
+ priceLabel: z.string().nullable(),
24
+ renewsAt: z.string().nullable(),
25
+ accessEndsAt: z.string().nullable(),
26
+ cancelAtPeriodEnd: z.boolean(),
27
+ trialUsed: z.boolean(),
28
+ trialDays: z.number().int().positive(),
29
+ plans: z.array(subscriptionPlanInfoSchema),
30
+ });
31
+ export const subscriptionResponseSchema = apiSuccessSchema(z.object({ subscription: subscriptionStateSchema }));
32
+ export const startTrialPayloadSchema = z.object({
33
+ plan: subscriptionPlanSchema.default("monthly"),
34
+ });
35
+ export const purchaseSubscriptionPayloadSchema = z.object({
36
+ plan: subscriptionPlanSchema,
37
+ });
38
+ export const cancelSubscriptionPayloadSchema = z.object({
39
+ reason: z.string().trim().min(1).max(500).optional(),
40
+ });
41
+ export const subscriptionRoutes = {
42
+ getMine: {
43
+ method: "GET",
44
+ path: "/api/v1/subscriptions/me",
45
+ auth: "user",
46
+ },
47
+ startTrial: {
48
+ method: "POST",
49
+ path: "/api/v1/subscriptions/trial",
50
+ auth: "user",
51
+ },
52
+ purchase: {
53
+ method: "POST",
54
+ path: "/api/v1/subscriptions/purchase",
55
+ auth: "user",
56
+ },
57
+ cancel: {
58
+ method: "POST",
59
+ path: "/api/v1/subscriptions/cancel",
60
+ auth: "user",
61
+ },
62
+ };
63
+ //# sourceMappingURL=subscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../src/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAsB,MAAM,UAAU,CAAC;AAEhE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAGpE,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,IAAI,CAAC;IACnD,QAAQ;IACR,UAAU;IACV,UAAU;IACV,SAAS;IACT,MAAM;CACP,CAAC,CAAC;AAGH,MAAM,CAAC,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D,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,IAAI,EAAE,sBAAsB;CAC7B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IACtD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CACrD,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE;QACP,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,MAAM;KACb;IACD,UAAU,EAAE;QACV,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,6BAA6B;QACnC,IAAI,EAAE,MAAM;KACb;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,gCAAgC;QACtC,IAAI,EAAE,MAAM;KACb;IACD,MAAM,EAAE;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,8BAA8B;QACpC,IAAI,EAAE,MAAM;KACb;CACsC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beorchid-llc/thrivo-contracts",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "description": "Shared Thrivo API request and response contracts.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -27,6 +27,26 @@
27
27
  "./admin": {
28
28
  "types": "./dist/admin.d.ts",
29
29
  "import": "./dist/admin.js"
30
+ },
31
+ "./dashboard": {
32
+ "types": "./dist/dashboard.d.ts",
33
+ "import": "./dist/dashboard.js"
34
+ },
35
+ "./foods": {
36
+ "types": "./dist/foods.d.ts",
37
+ "import": "./dist/foods.js"
38
+ },
39
+ "./metrics": {
40
+ "types": "./dist/metrics.d.ts",
41
+ "import": "./dist/metrics.js"
42
+ },
43
+ "./settings": {
44
+ "types": "./dist/settings.d.ts",
45
+ "import": "./dist/settings.js"
46
+ },
47
+ "./subscriptions": {
48
+ "types": "./dist/subscriptions.d.ts",
49
+ "import": "./dist/subscriptions.js"
30
50
  }
31
51
  },
32
52
  "files": [
@@ -47,6 +67,7 @@
47
67
  "typescript": "^5.6.0"
48
68
  },
49
69
  "scripts": {
70
+ "prepack": "npm run build",
50
71
  "build": "tsc -p tsconfig.json",
51
72
  "typecheck": "tsc -p tsconfig.json --noEmit",
52
73
  "pack:dry": "npm pack --dry-run"