gymmonk-schema 0.2.0 → 0.3.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/announcement.d.ts +56 -0
- package/dist/announcement.d.ts.map +1 -0
- package/dist/announcement.js +40 -0
- package/dist/announcement.js.map +1 -0
- package/dist/center.d.ts +381 -0
- package/dist/center.d.ts.map +1 -0
- package/dist/center.js +96 -0
- package/dist/center.js.map +1 -0
- package/dist/common.d.ts +28 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +37 -0
- package/dist/common.js.map +1 -1
- package/dist/equipment.d.ts +93 -0
- package/dist/equipment.d.ts.map +1 -0
- package/dist/equipment.js +54 -0
- package/dist/equipment.js.map +1 -0
- package/dist/exercise.d.ts +234 -0
- package/dist/exercise.d.ts.map +1 -0
- package/dist/exercise.js +93 -0
- package/dist/exercise.js.map +1 -0
- package/dist/feedback.d.ts +119 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +77 -0
- package/dist/feedback.js.map +1 -0
- package/dist/home.d.ts +74 -0
- package/dist/home.d.ts.map +1 -0
- package/dist/home.js +28 -0
- package/dist/home.js.map +1 -0
- package/dist/index.d.ts +27 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +143 -0
- package/dist/insights.d.ts.map +1 -0
- package/dist/insights.js +79 -0
- package/dist/insights.js.map +1 -0
- package/dist/member-profile.d.ts +312 -0
- package/dist/member-profile.d.ts.map +1 -0
- package/dist/member-profile.js +103 -0
- package/dist/member-profile.js.map +1 -0
- package/dist/member.d.ts +365 -0
- package/dist/member.d.ts.map +1 -0
- package/dist/member.js +169 -0
- package/dist/member.js.map +1 -0
- package/dist/membership-plan.d.ts +244 -0
- package/dist/membership-plan.d.ts.map +1 -0
- package/dist/membership-plan.js +80 -0
- package/dist/membership-plan.js.map +1 -0
- package/dist/membership.d.ts +154 -0
- package/dist/membership.d.ts.map +1 -0
- package/dist/membership.js +103 -0
- package/dist/membership.js.map +1 -0
- package/dist/notification.d.ts +59 -0
- package/dist/notification.d.ts.map +1 -0
- package/dist/notification.js +49 -0
- package/dist/notification.js.map +1 -0
- package/dist/onboarding.d.ts +361 -0
- package/dist/onboarding.d.ts.map +1 -0
- package/dist/onboarding.js +74 -0
- package/dist/onboarding.js.map +1 -0
- package/dist/organisation.d.ts +199 -0
- package/dist/organisation.d.ts.map +1 -0
- package/dist/organisation.js +51 -0
- package/dist/organisation.js.map +1 -0
- package/dist/owner-profile.d.ts +50 -0
- package/dist/owner-profile.d.ts.map +1 -0
- package/dist/owner-profile.js +34 -0
- package/dist/owner-profile.js.map +1 -0
- package/dist/pricing.d.ts +103 -0
- package/dist/pricing.d.ts.map +1 -0
- package/dist/pricing.js +73 -0
- package/dist/pricing.js.map +1 -0
- package/dist/session.d.ts +90 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +59 -0
- package/dist/session.js.map +1 -0
- package/dist/shared.d.ts +199 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +107 -0
- package/dist/shared.js.map +1 -0
- package/dist/staff.d.ts +288 -0
- package/dist/staff.d.ts.map +1 -0
- package/dist/staff.js +115 -0
- package/dist/staff.js.map +1 -0
- package/dist/subscription.d.ts +69 -0
- package/dist/subscription.d.ts.map +1 -0
- package/dist/subscription.js +47 -0
- package/dist/subscription.js.map +1 -0
- package/dist/user.d.ts +63 -0
- package/dist/user.d.ts.map +1 -0
- package/dist/user.js +44 -0
- package/dist/user.js.map +1 -0
- package/dist/workout-plan.d.ts +201 -0
- package/dist/workout-plan.d.ts.map +1 -0
- package/dist/workout-plan.js +71 -0
- package/dist/workout-plan.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gymmonk-schema — Membership plan (owner-defined catalog)
|
|
3
|
+
* ========================================================
|
|
4
|
+
* The plans a gym owner defines and sells to members, scoped to a center. A
|
|
5
|
+
* member's active `membership` references one of these by id + tenure.
|
|
6
|
+
*
|
|
7
|
+
* @module gymmonk-schema/membership-plan
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
export declare const planTierSchema: z.ZodEnum<{
|
|
11
|
+
free: "free";
|
|
12
|
+
basic: "basic";
|
|
13
|
+
standard: "standard";
|
|
14
|
+
premium: "premium";
|
|
15
|
+
}>;
|
|
16
|
+
export type PlanTier = z.infer<typeof planTierSchema>;
|
|
17
|
+
/** UI accent colour for the plan card. */
|
|
18
|
+
export declare const planAccentSchema: z.ZodEnum<{
|
|
19
|
+
neutral: "neutral";
|
|
20
|
+
teal: "teal";
|
|
21
|
+
purple: "purple";
|
|
22
|
+
gold: "gold";
|
|
23
|
+
}>;
|
|
24
|
+
export type PlanAccent = z.infer<typeof planAccentSchema>;
|
|
25
|
+
/** Billing durations offered on a membership plan. */
|
|
26
|
+
export declare const tenureIdSchema: z.ZodEnum<{
|
|
27
|
+
"1m": "1m";
|
|
28
|
+
"3m": "3m";
|
|
29
|
+
"6m": "6m";
|
|
30
|
+
"1y": "1y";
|
|
31
|
+
}>;
|
|
32
|
+
export type TenureId = z.infer<typeof tenureIdSchema>;
|
|
33
|
+
export declare const planTenureSchema: z.ZodObject<{
|
|
34
|
+
id: z.ZodEnum<{
|
|
35
|
+
"1m": "1m";
|
|
36
|
+
"3m": "3m";
|
|
37
|
+
"6m": "6m";
|
|
38
|
+
"1y": "1y";
|
|
39
|
+
}>;
|
|
40
|
+
label: z.ZodString;
|
|
41
|
+
price: z.ZodNumber;
|
|
42
|
+
popular: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type PlanTenure = z.infer<typeof planTenureSchema>;
|
|
45
|
+
/** The full vocabulary of membership-plan perk icons (superset of member perks). */
|
|
46
|
+
export declare const FEATURE_ICONS: readonly ["cardio", "locker", "classes", "health", "steam", "strength", "trainer", "diet", "yoga", "spa", "unlimited", "massage", "priority", "crossfit", "sauna", "pool"];
|
|
47
|
+
export declare const featureIconSchema: z.ZodEnum<{
|
|
48
|
+
crossfit: "crossfit";
|
|
49
|
+
yoga: "yoga";
|
|
50
|
+
cardio: "cardio";
|
|
51
|
+
strength: "strength";
|
|
52
|
+
locker: "locker";
|
|
53
|
+
classes: "classes";
|
|
54
|
+
health: "health";
|
|
55
|
+
steam: "steam";
|
|
56
|
+
trainer: "trainer";
|
|
57
|
+
diet: "diet";
|
|
58
|
+
spa: "spa";
|
|
59
|
+
unlimited: "unlimited";
|
|
60
|
+
massage: "massage";
|
|
61
|
+
priority: "priority";
|
|
62
|
+
sauna: "sauna";
|
|
63
|
+
pool: "pool";
|
|
64
|
+
}>;
|
|
65
|
+
export type FeatureIcon = z.infer<typeof featureIconSchema>;
|
|
66
|
+
export declare const planFeatureSchema: z.ZodObject<{
|
|
67
|
+
icon: z.ZodEnum<{
|
|
68
|
+
crossfit: "crossfit";
|
|
69
|
+
yoga: "yoga";
|
|
70
|
+
cardio: "cardio";
|
|
71
|
+
strength: "strength";
|
|
72
|
+
locker: "locker";
|
|
73
|
+
classes: "classes";
|
|
74
|
+
health: "health";
|
|
75
|
+
steam: "steam";
|
|
76
|
+
trainer: "trainer";
|
|
77
|
+
diet: "diet";
|
|
78
|
+
spa: "spa";
|
|
79
|
+
unlimited: "unlimited";
|
|
80
|
+
massage: "massage";
|
|
81
|
+
priority: "priority";
|
|
82
|
+
sauna: "sauna";
|
|
83
|
+
pool: "pool";
|
|
84
|
+
}>;
|
|
85
|
+
label: z.ZodString;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export type PlanFeature = z.infer<typeof planFeatureSchema>;
|
|
88
|
+
export declare const createMembershipPlanBodySchema: z.ZodObject<{
|
|
89
|
+
centerId: z.ZodString;
|
|
90
|
+
tier: z.ZodEnum<{
|
|
91
|
+
free: "free";
|
|
92
|
+
basic: "basic";
|
|
93
|
+
standard: "standard";
|
|
94
|
+
premium: "premium";
|
|
95
|
+
}>;
|
|
96
|
+
name: z.ZodString;
|
|
97
|
+
note: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
98
|
+
accent: z.ZodEnum<{
|
|
99
|
+
neutral: "neutral";
|
|
100
|
+
teal: "teal";
|
|
101
|
+
purple: "purple";
|
|
102
|
+
gold: "gold";
|
|
103
|
+
}>;
|
|
104
|
+
features: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
105
|
+
icon: z.ZodEnum<{
|
|
106
|
+
crossfit: "crossfit";
|
|
107
|
+
yoga: "yoga";
|
|
108
|
+
cardio: "cardio";
|
|
109
|
+
strength: "strength";
|
|
110
|
+
locker: "locker";
|
|
111
|
+
classes: "classes";
|
|
112
|
+
health: "health";
|
|
113
|
+
steam: "steam";
|
|
114
|
+
trainer: "trainer";
|
|
115
|
+
diet: "diet";
|
|
116
|
+
spa: "spa";
|
|
117
|
+
unlimited: "unlimited";
|
|
118
|
+
massage: "massage";
|
|
119
|
+
priority: "priority";
|
|
120
|
+
sauna: "sauna";
|
|
121
|
+
pool: "pool";
|
|
122
|
+
}>;
|
|
123
|
+
label: z.ZodString;
|
|
124
|
+
}, z.core.$strip>>>;
|
|
125
|
+
tenures: z.ZodArray<z.ZodObject<{
|
|
126
|
+
id: z.ZodEnum<{
|
|
127
|
+
"1m": "1m";
|
|
128
|
+
"3m": "3m";
|
|
129
|
+
"6m": "6m";
|
|
130
|
+
"1y": "1y";
|
|
131
|
+
}>;
|
|
132
|
+
label: z.ZodString;
|
|
133
|
+
price: z.ZodNumber;
|
|
134
|
+
popular: z.ZodOptional<z.ZodBoolean>;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
export type CreateMembershipPlanBody = z.infer<typeof createMembershipPlanBodySchema>;
|
|
138
|
+
export declare const updateMembershipPlanBodySchema: z.ZodObject<{
|
|
139
|
+
name: z.ZodOptional<z.ZodString>;
|
|
140
|
+
note: z.ZodOptional<z.ZodPreprocess<z.ZodOptional<z.ZodString>>>;
|
|
141
|
+
tier: z.ZodOptional<z.ZodEnum<{
|
|
142
|
+
free: "free";
|
|
143
|
+
basic: "basic";
|
|
144
|
+
standard: "standard";
|
|
145
|
+
premium: "premium";
|
|
146
|
+
}>>;
|
|
147
|
+
accent: z.ZodOptional<z.ZodEnum<{
|
|
148
|
+
neutral: "neutral";
|
|
149
|
+
teal: "teal";
|
|
150
|
+
purple: "purple";
|
|
151
|
+
gold: "gold";
|
|
152
|
+
}>>;
|
|
153
|
+
features: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
154
|
+
icon: z.ZodEnum<{
|
|
155
|
+
crossfit: "crossfit";
|
|
156
|
+
yoga: "yoga";
|
|
157
|
+
cardio: "cardio";
|
|
158
|
+
strength: "strength";
|
|
159
|
+
locker: "locker";
|
|
160
|
+
classes: "classes";
|
|
161
|
+
health: "health";
|
|
162
|
+
steam: "steam";
|
|
163
|
+
trainer: "trainer";
|
|
164
|
+
diet: "diet";
|
|
165
|
+
spa: "spa";
|
|
166
|
+
unlimited: "unlimited";
|
|
167
|
+
massage: "massage";
|
|
168
|
+
priority: "priority";
|
|
169
|
+
sauna: "sauna";
|
|
170
|
+
pool: "pool";
|
|
171
|
+
}>;
|
|
172
|
+
label: z.ZodString;
|
|
173
|
+
}, z.core.$strip>>>>;
|
|
174
|
+
tenures: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
175
|
+
id: z.ZodEnum<{
|
|
176
|
+
"1m": "1m";
|
|
177
|
+
"3m": "3m";
|
|
178
|
+
"6m": "6m";
|
|
179
|
+
"1y": "1y";
|
|
180
|
+
}>;
|
|
181
|
+
label: z.ZodString;
|
|
182
|
+
price: z.ZodNumber;
|
|
183
|
+
popular: z.ZodOptional<z.ZodBoolean>;
|
|
184
|
+
}, z.core.$strip>>>;
|
|
185
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
export type UpdateMembershipPlanBody = z.infer<typeof updateMembershipPlanBodySchema>;
|
|
188
|
+
export declare const membershipPlanSchema: z.ZodObject<{
|
|
189
|
+
id: z.ZodString;
|
|
190
|
+
centerId: z.ZodString;
|
|
191
|
+
tier: z.ZodEnum<{
|
|
192
|
+
free: "free";
|
|
193
|
+
basic: "basic";
|
|
194
|
+
standard: "standard";
|
|
195
|
+
premium: "premium";
|
|
196
|
+
}>;
|
|
197
|
+
name: z.ZodString;
|
|
198
|
+
note: z.ZodNullable<z.ZodString>;
|
|
199
|
+
accent: z.ZodEnum<{
|
|
200
|
+
neutral: "neutral";
|
|
201
|
+
teal: "teal";
|
|
202
|
+
purple: "purple";
|
|
203
|
+
gold: "gold";
|
|
204
|
+
}>;
|
|
205
|
+
features: z.ZodArray<z.ZodObject<{
|
|
206
|
+
icon: z.ZodEnum<{
|
|
207
|
+
crossfit: "crossfit";
|
|
208
|
+
yoga: "yoga";
|
|
209
|
+
cardio: "cardio";
|
|
210
|
+
strength: "strength";
|
|
211
|
+
locker: "locker";
|
|
212
|
+
classes: "classes";
|
|
213
|
+
health: "health";
|
|
214
|
+
steam: "steam";
|
|
215
|
+
trainer: "trainer";
|
|
216
|
+
diet: "diet";
|
|
217
|
+
spa: "spa";
|
|
218
|
+
unlimited: "unlimited";
|
|
219
|
+
massage: "massage";
|
|
220
|
+
priority: "priority";
|
|
221
|
+
sauna: "sauna";
|
|
222
|
+
pool: "pool";
|
|
223
|
+
}>;
|
|
224
|
+
label: z.ZodString;
|
|
225
|
+
}, z.core.$strip>>;
|
|
226
|
+
tenures: z.ZodArray<z.ZodObject<{
|
|
227
|
+
id: z.ZodEnum<{
|
|
228
|
+
"1m": "1m";
|
|
229
|
+
"3m": "3m";
|
|
230
|
+
"6m": "6m";
|
|
231
|
+
"1y": "1y";
|
|
232
|
+
}>;
|
|
233
|
+
label: z.ZodString;
|
|
234
|
+
price: z.ZodNumber;
|
|
235
|
+
popular: z.ZodOptional<z.ZodBoolean>;
|
|
236
|
+
}, z.core.$strip>>;
|
|
237
|
+
isActive: z.ZodBoolean;
|
|
238
|
+
sortOrder: z.ZodNumber;
|
|
239
|
+
memberCount: z.ZodNumber;
|
|
240
|
+
createdAt: z.ZodISODateTime;
|
|
241
|
+
updatedAt: z.ZodISODateTime;
|
|
242
|
+
}, z.core.$strip>;
|
|
243
|
+
export type MembershipPlan = z.infer<typeof membershipPlanSchema>;
|
|
244
|
+
//# sourceMappingURL=membership-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership-plan.d.ts","sourceRoot":"","sources":["../src/membership-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,cAAc;;;;;EAAmD,CAAC;AAC/E,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB;;;;;EAAgD,CAAC;AAC9E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAI1D,sDAAsD;AACtD,eAAO,MAAM,cAAc;;;;;EAAmC,CAAC;AAC/D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,gBAAgB;;;;;;;;;;iBAK3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAI1D,oFAAoF;AACpF,eAAO,MAAM,aAAa,4KAiBhB,CAAC;AACX,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;EAAwB,CAAC;AACvD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;iBAG5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAI5D,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGI,CAAC;AAChD,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAItF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAe/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gymmonk-schema — Membership plan (owner-defined catalog)
|
|
3
|
+
* ========================================================
|
|
4
|
+
* The plans a gym owner defines and sells to members, scoped to a center. A
|
|
5
|
+
* member's active `membership` references one of these by id + tenure.
|
|
6
|
+
*
|
|
7
|
+
* @module gymmonk-schema/membership-plan
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { isoDateTimeSchema, objectIdSchema, optionalTrimmedString, priceInrSchema, } from './common.js';
|
|
11
|
+
// ─── Tier & accent ───────────────────────────────────────────────────────────
|
|
12
|
+
export const planTierSchema = z.enum(['free', 'basic', 'standard', 'premium']);
|
|
13
|
+
/** UI accent colour for the plan card. */
|
|
14
|
+
export const planAccentSchema = z.enum(['neutral', 'teal', 'purple', 'gold']);
|
|
15
|
+
// ─── Tenure ──────────────────────────────────────────────────────────────────
|
|
16
|
+
/** Billing durations offered on a membership plan. */
|
|
17
|
+
export const tenureIdSchema = z.enum(['1m', '3m', '6m', '1y']);
|
|
18
|
+
export const planTenureSchema = z.object({
|
|
19
|
+
id: tenureIdSchema,
|
|
20
|
+
label: z.string().trim().min(1),
|
|
21
|
+
price: priceInrSchema,
|
|
22
|
+
popular: z.boolean().optional(),
|
|
23
|
+
});
|
|
24
|
+
// ─── Feature chips ───────────────────────────────────────────────────────────
|
|
25
|
+
/** The full vocabulary of membership-plan perk icons (superset of member perks). */
|
|
26
|
+
export const FEATURE_ICONS = [
|
|
27
|
+
'cardio',
|
|
28
|
+
'locker',
|
|
29
|
+
'classes',
|
|
30
|
+
'health',
|
|
31
|
+
'steam',
|
|
32
|
+
'strength',
|
|
33
|
+
'trainer',
|
|
34
|
+
'diet',
|
|
35
|
+
'yoga',
|
|
36
|
+
'spa',
|
|
37
|
+
'unlimited',
|
|
38
|
+
'massage',
|
|
39
|
+
'priority',
|
|
40
|
+
'crossfit',
|
|
41
|
+
'sauna',
|
|
42
|
+
'pool',
|
|
43
|
+
];
|
|
44
|
+
export const featureIconSchema = z.enum(FEATURE_ICONS);
|
|
45
|
+
export const planFeatureSchema = z.object({
|
|
46
|
+
icon: featureIconSchema,
|
|
47
|
+
label: z.string().trim().min(1).max(80),
|
|
48
|
+
});
|
|
49
|
+
// ─── Create / update body ────────────────────────────────────────────────────
|
|
50
|
+
export const createMembershipPlanBodySchema = z.object({
|
|
51
|
+
centerId: objectIdSchema,
|
|
52
|
+
tier: planTierSchema,
|
|
53
|
+
name: z.string().trim().min(1, 'Plan name is required').max(80),
|
|
54
|
+
note: optionalTrimmedString(60),
|
|
55
|
+
accent: planAccentSchema,
|
|
56
|
+
features: z.array(planFeatureSchema).max(20).default([]),
|
|
57
|
+
tenures: z.array(planTenureSchema).min(1, 'Add at least one tenure'),
|
|
58
|
+
});
|
|
59
|
+
export const updateMembershipPlanBodySchema = createMembershipPlanBodySchema
|
|
60
|
+
.omit({ centerId: true })
|
|
61
|
+
.partial()
|
|
62
|
+
.extend({ isActive: z.boolean().optional() });
|
|
63
|
+
// ─── Entity (API response) ───────────────────────────────────────────────────
|
|
64
|
+
export const membershipPlanSchema = z.object({
|
|
65
|
+
id: objectIdSchema,
|
|
66
|
+
centerId: objectIdSchema,
|
|
67
|
+
tier: planTierSchema,
|
|
68
|
+
name: z.string(),
|
|
69
|
+
note: z.string().nullable(),
|
|
70
|
+
accent: planAccentSchema,
|
|
71
|
+
features: z.array(planFeatureSchema),
|
|
72
|
+
tenures: z.array(planTenureSchema),
|
|
73
|
+
isActive: z.boolean(),
|
|
74
|
+
sortOrder: z.number().int(),
|
|
75
|
+
/** Denormalised count of active members on this plan (owner list view). */
|
|
76
|
+
memberCount: z.number().int().nonnegative(),
|
|
77
|
+
createdAt: isoDateTimeSchema,
|
|
78
|
+
updatedAt: isoDateTimeSchema,
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=membership-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership-plan.js","sourceRoot":"","sources":["../src/membership-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;AAG/E,0CAA0C;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAG9E,gFAAgF;AAEhF,sDAAsD;AACtD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CA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EAAE,gBAAgB;IACxB,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC;CACrE,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,8BAA8B,GAAG,8BAA8B;KACzE,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KACxB,OAAO,EAAE;KACT,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAGhD,gFAAgF;AAEhF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,EAAE,EAAE,cAAc;IAClB,QAAQ,EAAE,cAAc;IACxB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,MAAM,EAAE,gBAAgB;IACxB,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;IACpC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC;IAClC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC3B,2EAA2E;IAC3E,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC3C,SAAS,EAAE,iBAAiB;IAC5B,SAAS,EAAE,iBAAiB;CAC7B,CAAC,CAAC","sourcesContent":["/**\n * gymmonk-schema — Membership plan (owner-defined catalog)\n * ========================================================\n * The plans a gym owner defines and sells to members, scoped to a center. A\n * member's active `membership` references one of these by id + tenure.\n *\n * @module gymmonk-schema/membership-plan\n */\n\nimport { z } from 'zod';\nimport {\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n priceInrSchema,\n} from './common.js';\n\n// ─── Tier & accent ───────────────────────────────────────────────────────────\n\nexport const planTierSchema = z.enum(['free', 'basic', 'standard', 'premium']);\nexport type PlanTier = z.infer<typeof planTierSchema>;\n\n/** UI accent colour for the plan card. */\nexport const planAccentSchema = z.enum(['neutral', 'teal', 'purple', 'gold']);\nexport type PlanAccent = z.infer<typeof planAccentSchema>;\n\n// ─── Tenure ──────────────────────────────────────────────────────────────────\n\n/** Billing durations offered on a membership plan. */\nexport const tenureIdSchema = z.enum(['1m', '3m', '6m', '1y']);\nexport type TenureId = z.infer<typeof tenureIdSchema>;\n\nexport const planTenureSchema = z.object({\n id: tenureIdSchema,\n label: z.string().trim().min(1),\n price: priceInrSchema,\n popular: z.boolean().optional(),\n});\nexport type PlanTenure = z.infer<typeof planTenureSchema>;\n\n// ─── Feature chips ───────────────────────────────────────────────────────────\n\n/** The full vocabulary of membership-plan perk icons (superset of member perks). */\nexport const FEATURE_ICONS = [\n 'cardio',\n 'locker',\n 'classes',\n 'health',\n 'steam',\n 'strength',\n 'trainer',\n 'diet',\n 'yoga',\n 'spa',\n 'unlimited',\n 'massage',\n 'priority',\n 'crossfit',\n 'sauna',\n 'pool',\n] as const;\nexport const featureIconSchema = z.enum(FEATURE_ICONS);\nexport type FeatureIcon = z.infer<typeof featureIconSchema>;\n\nexport const planFeatureSchema = z.object({\n icon: featureIconSchema,\n label: z.string().trim().min(1).max(80),\n});\nexport type PlanFeature = z.infer<typeof planFeatureSchema>;\n\n// ─── Create / update body ────────────────────────────────────────────────────\n\nexport const createMembershipPlanBodySchema = z.object({\n centerId: objectIdSchema,\n tier: planTierSchema,\n name: z.string().trim().min(1, 'Plan name is required').max(80),\n note: optionalTrimmedString(60),\n accent: planAccentSchema,\n features: z.array(planFeatureSchema).max(20).default([]),\n tenures: z.array(planTenureSchema).min(1, 'Add at least one tenure'),\n});\nexport type CreateMembershipPlanBody = z.infer<typeof createMembershipPlanBodySchema>;\n\nexport const updateMembershipPlanBodySchema = createMembershipPlanBodySchema\n .omit({ centerId: true })\n .partial()\n .extend({ isActive: z.boolean().optional() });\nexport type UpdateMembershipPlanBody = z.infer<typeof updateMembershipPlanBodySchema>;\n\n// ─── Entity (API response) ───────────────────────────────────────────────────\n\nexport const membershipPlanSchema = z.object({\n id: objectIdSchema,\n centerId: objectIdSchema,\n tier: planTierSchema,\n name: z.string(),\n note: z.string().nullable(),\n accent: planAccentSchema,\n features: z.array(planFeatureSchema),\n tenures: z.array(planTenureSchema),\n isActive: z.boolean(),\n sortOrder: z.number().int(),\n /** Denormalised count of active members on this plan (owner list view). */\n memberCount: z.number().int().nonnegative(),\n createdAt: isoDateTimeSchema,\n updatedAt: isoDateTimeSchema,\n});\nexport type MembershipPlan = z.infer<typeof membershipPlanSchema>;\n"]}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gymmonk-schema — Membership & payments
|
|
3
|
+
* =======================================
|
|
4
|
+
* A member's live membership at a center: which plan/tenure, its lifecycle
|
|
5
|
+
* status and dates, pause windows, and the payment ledger. v1 is single-center,
|
|
6
|
+
* so one active membership per user.
|
|
7
|
+
*
|
|
8
|
+
* The "expiring" state the UI shows is DERIVED from `endDate` at the edge; the
|
|
9
|
+
* stored `status` is the true lifecycle state.
|
|
10
|
+
*
|
|
11
|
+
* @module gymmonk-schema/membership
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
/**
|
|
15
|
+
* Membership lifecycle. `invited` = owner created it, member hasn't activated;
|
|
16
|
+
* `expiring` is NOT stored (derived from `endDate`).
|
|
17
|
+
*/
|
|
18
|
+
export declare const membershipStatusSchema: z.ZodEnum<{
|
|
19
|
+
active: "active";
|
|
20
|
+
invited: "invited";
|
|
21
|
+
paused: "paused";
|
|
22
|
+
expired: "expired";
|
|
23
|
+
cancelled: "cancelled";
|
|
24
|
+
}>;
|
|
25
|
+
export type MembershipStatus = z.infer<typeof membershipStatusSchema>;
|
|
26
|
+
export declare const paymentMethodSchema: z.ZodEnum<{
|
|
27
|
+
upi: "upi";
|
|
28
|
+
cash: "cash";
|
|
29
|
+
card: "card";
|
|
30
|
+
}>;
|
|
31
|
+
export type PaymentMethod = z.infer<typeof paymentMethodSchema>;
|
|
32
|
+
export declare const paymentStatusSchema: z.ZodEnum<{
|
|
33
|
+
success: "success";
|
|
34
|
+
failed: "failed";
|
|
35
|
+
pending: "pending";
|
|
36
|
+
}>;
|
|
37
|
+
export type PaymentStatus = z.infer<typeof paymentStatusSchema>;
|
|
38
|
+
export declare const paymentSchema: z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
membershipId: z.ZodString;
|
|
41
|
+
amountInr: z.ZodNumber;
|
|
42
|
+
method: z.ZodEnum<{
|
|
43
|
+
upi: "upi";
|
|
44
|
+
cash: "cash";
|
|
45
|
+
card: "card";
|
|
46
|
+
}>;
|
|
47
|
+
status: z.ZodEnum<{
|
|
48
|
+
success: "success";
|
|
49
|
+
failed: "failed";
|
|
50
|
+
pending: "pending";
|
|
51
|
+
}>;
|
|
52
|
+
paidAt: z.ZodISODateTime;
|
|
53
|
+
note: z.ZodNullable<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export type Payment = z.infer<typeof paymentSchema>;
|
|
56
|
+
export declare const membershipSchema: z.ZodObject<{
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
userId: z.ZodString;
|
|
59
|
+
centerId: z.ZodString;
|
|
60
|
+
memberCode: z.ZodString;
|
|
61
|
+
planId: z.ZodString;
|
|
62
|
+
tier: z.ZodEnum<{
|
|
63
|
+
free: "free";
|
|
64
|
+
basic: "basic";
|
|
65
|
+
standard: "standard";
|
|
66
|
+
premium: "premium";
|
|
67
|
+
}>;
|
|
68
|
+
planName: z.ZodString;
|
|
69
|
+
tenureId: z.ZodEnum<{
|
|
70
|
+
"1m": "1m";
|
|
71
|
+
"3m": "3m";
|
|
72
|
+
"6m": "6m";
|
|
73
|
+
"1y": "1y";
|
|
74
|
+
}>;
|
|
75
|
+
tenureLabel: z.ZodString;
|
|
76
|
+
priceInr: z.ZodNumber;
|
|
77
|
+
status: z.ZodEnum<{
|
|
78
|
+
active: "active";
|
|
79
|
+
invited: "invited";
|
|
80
|
+
paused: "paused";
|
|
81
|
+
expired: "expired";
|
|
82
|
+
cancelled: "cancelled";
|
|
83
|
+
}>;
|
|
84
|
+
startDate: z.ZodString;
|
|
85
|
+
endDate: z.ZodString;
|
|
86
|
+
pausedFrom: z.ZodNullable<z.ZodString>;
|
|
87
|
+
pausedTo: z.ZodNullable<z.ZodString>;
|
|
88
|
+
createdAt: z.ZodISODateTime;
|
|
89
|
+
updatedAt: z.ZodISODateTime;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
export type Membership = z.infer<typeof membershipSchema>;
|
|
92
|
+
/**
|
|
93
|
+
* Assign a plan to a member (new membership, renewal, or upgrade). Records the
|
|
94
|
+
* charge in one shot; omit `payment` for an unpaid/invited assignment.
|
|
95
|
+
*/
|
|
96
|
+
export declare const assignMembershipBodySchema: z.ZodObject<{
|
|
97
|
+
planId: z.ZodString;
|
|
98
|
+
tenureId: z.ZodEnum<{
|
|
99
|
+
"1m": "1m";
|
|
100
|
+
"3m": "3m";
|
|
101
|
+
"6m": "6m";
|
|
102
|
+
"1y": "1y";
|
|
103
|
+
}>;
|
|
104
|
+
startDate: z.ZodOptional<z.ZodString>;
|
|
105
|
+
payment: z.ZodOptional<z.ZodObject<{
|
|
106
|
+
amountInr: z.ZodNumber;
|
|
107
|
+
method: z.ZodEnum<{
|
|
108
|
+
upi: "upi";
|
|
109
|
+
cash: "cash";
|
|
110
|
+
card: "card";
|
|
111
|
+
}>;
|
|
112
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
113
|
+
success: "success";
|
|
114
|
+
failed: "failed";
|
|
115
|
+
pending: "pending";
|
|
116
|
+
}>>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
export type AssignMembershipBody = z.infer<typeof assignMembershipBodySchema>;
|
|
120
|
+
export declare const pauseDurationSchema: z.ZodEnum<{
|
|
121
|
+
custom: "custom";
|
|
122
|
+
"1m": "1m";
|
|
123
|
+
"1w": "1w";
|
|
124
|
+
"2w": "2w";
|
|
125
|
+
}>;
|
|
126
|
+
export type PauseDuration = z.infer<typeof pauseDurationSchema>;
|
|
127
|
+
export declare const pauseMembershipBodySchema: z.ZodObject<{
|
|
128
|
+
duration: z.ZodEnum<{
|
|
129
|
+
custom: "custom";
|
|
130
|
+
"1m": "1m";
|
|
131
|
+
"1w": "1w";
|
|
132
|
+
"2w": "2w";
|
|
133
|
+
}>;
|
|
134
|
+
customFrom: z.ZodOptional<z.ZodString>;
|
|
135
|
+
customTo: z.ZodOptional<z.ZodString>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
export type PauseMembershipBody = z.infer<typeof pauseMembershipBodySchema>;
|
|
138
|
+
/** Cancellation requires echoing the member code as a safety confirmation. */
|
|
139
|
+
export declare const cancelMembershipBodySchema: z.ZodObject<{
|
|
140
|
+
confirmationCode: z.ZodString;
|
|
141
|
+
reason: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
export type CancelMembershipBody = z.infer<typeof cancelMembershipBodySchema>;
|
|
144
|
+
export declare const collectPaymentBodySchema: z.ZodObject<{
|
|
145
|
+
amountInr: z.ZodNumber;
|
|
146
|
+
method: z.ZodEnum<{
|
|
147
|
+
upi: "upi";
|
|
148
|
+
cash: "cash";
|
|
149
|
+
card: "card";
|
|
150
|
+
}>;
|
|
151
|
+
note: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
export type CollectPaymentBody = z.infer<typeof collectPaymentBodySchema>;
|
|
154
|
+
//# sourceMappingURL=membership.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership.d.ts","sourceRoot":"","sources":["../src/membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;EAMjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAItE,eAAO,MAAM,mBAAmB;;;;EAAkC,CAAC;AACnE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,mBAAmB;;;;EAA2C,CAAC;AAC5E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;iBAQxB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAIpD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmB3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAI1D;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;iBAYrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAI9E,eAAO,MAAM,mBAAmB;;;;;EAAuC,CAAC;AACxE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,yBAAyB;;;;;;;;;iBASlC,CAAC;AACL,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAI5E,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B;;;iBAGrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAI9E,eAAO,MAAM,wBAAwB;;;;;;;;iBAInC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gymmonk-schema — Membership & payments
|
|
3
|
+
* =======================================
|
|
4
|
+
* A member's live membership at a center: which plan/tenure, its lifecycle
|
|
5
|
+
* status and dates, pause windows, and the payment ledger. v1 is single-center,
|
|
6
|
+
* so one active membership per user.
|
|
7
|
+
*
|
|
8
|
+
* The "expiring" state the UI shows is DERIVED from `endDate` at the edge; the
|
|
9
|
+
* stored `status` is the true lifecycle state.
|
|
10
|
+
*
|
|
11
|
+
* @module gymmonk-schema/membership
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { isoDateSchema, isoDateTimeSchema, objectIdSchema, optionalTrimmedString, priceInrSchema, } from './common.js';
|
|
15
|
+
import { planTierSchema, tenureIdSchema } from './membership-plan.js';
|
|
16
|
+
// ─── Status ──────────────────────────────────────────────────────────────────
|
|
17
|
+
/**
|
|
18
|
+
* Membership lifecycle. `invited` = owner created it, member hasn't activated;
|
|
19
|
+
* `expiring` is NOT stored (derived from `endDate`).
|
|
20
|
+
*/
|
|
21
|
+
export const membershipStatusSchema = z.enum([
|
|
22
|
+
'invited',
|
|
23
|
+
'active',
|
|
24
|
+
'paused',
|
|
25
|
+
'expired',
|
|
26
|
+
'cancelled',
|
|
27
|
+
]);
|
|
28
|
+
// ─── Payments ────────────────────────────────────────────────────────────────
|
|
29
|
+
export const paymentMethodSchema = z.enum(['upi', 'cash', 'card']);
|
|
30
|
+
export const paymentStatusSchema = z.enum(['success', 'failed', 'pending']);
|
|
31
|
+
export const paymentSchema = z.object({
|
|
32
|
+
id: objectIdSchema,
|
|
33
|
+
membershipId: objectIdSchema,
|
|
34
|
+
amountInr: priceInrSchema,
|
|
35
|
+
method: paymentMethodSchema,
|
|
36
|
+
status: paymentStatusSchema,
|
|
37
|
+
paidAt: isoDateTimeSchema,
|
|
38
|
+
note: z.string().nullable(),
|
|
39
|
+
});
|
|
40
|
+
// ─── Entity (API response) ───────────────────────────────────────────────────
|
|
41
|
+
export const membershipSchema = z.object({
|
|
42
|
+
id: objectIdSchema,
|
|
43
|
+
userId: objectIdSchema,
|
|
44
|
+
centerId: objectIdSchema,
|
|
45
|
+
/** Public member code within the gym, `GYM-YYYY-NNN`. */
|
|
46
|
+
memberCode: z.string(),
|
|
47
|
+
planId: objectIdSchema,
|
|
48
|
+
tier: planTierSchema,
|
|
49
|
+
planName: z.string(),
|
|
50
|
+
tenureId: tenureIdSchema,
|
|
51
|
+
tenureLabel: z.string(),
|
|
52
|
+
priceInr: priceInrSchema,
|
|
53
|
+
status: membershipStatusSchema,
|
|
54
|
+
startDate: isoDateSchema,
|
|
55
|
+
endDate: isoDateSchema,
|
|
56
|
+
pausedFrom: isoDateSchema.nullable(),
|
|
57
|
+
pausedTo: isoDateSchema.nullable(),
|
|
58
|
+
createdAt: isoDateTimeSchema,
|
|
59
|
+
updatedAt: isoDateTimeSchema,
|
|
60
|
+
});
|
|
61
|
+
// ─── Assign / renew / upgrade ────────────────────────────────────────────────
|
|
62
|
+
/**
|
|
63
|
+
* Assign a plan to a member (new membership, renewal, or upgrade). Records the
|
|
64
|
+
* charge in one shot; omit `payment` for an unpaid/invited assignment.
|
|
65
|
+
*/
|
|
66
|
+
export const assignMembershipBodySchema = z.object({
|
|
67
|
+
planId: objectIdSchema,
|
|
68
|
+
tenureId: tenureIdSchema,
|
|
69
|
+
/** Explicit start; defaults to today server-side when omitted. */
|
|
70
|
+
startDate: isoDateSchema.optional(),
|
|
71
|
+
payment: z
|
|
72
|
+
.object({
|
|
73
|
+
amountInr: priceInrSchema,
|
|
74
|
+
method: paymentMethodSchema,
|
|
75
|
+
status: paymentStatusSchema.default('success'),
|
|
76
|
+
})
|
|
77
|
+
.optional(),
|
|
78
|
+
});
|
|
79
|
+
// ─── Pause ───────────────────────────────────────────────────────────────────
|
|
80
|
+
export const pauseDurationSchema = z.enum(['1w', '2w', '1m', 'custom']);
|
|
81
|
+
export const pauseMembershipBodySchema = z
|
|
82
|
+
.object({
|
|
83
|
+
duration: pauseDurationSchema,
|
|
84
|
+
customFrom: isoDateSchema.optional(),
|
|
85
|
+
customTo: isoDateSchema.optional(),
|
|
86
|
+
})
|
|
87
|
+
.refine((v) => v.duration !== 'custom' || (v.customFrom && v.customTo), {
|
|
88
|
+
message: 'Pick both pause dates',
|
|
89
|
+
path: ['customTo'],
|
|
90
|
+
});
|
|
91
|
+
// ─── Cancel ──────────────────────────────────────────────────────────────────
|
|
92
|
+
/** Cancellation requires echoing the member code as a safety confirmation. */
|
|
93
|
+
export const cancelMembershipBodySchema = z.object({
|
|
94
|
+
confirmationCode: z.string().trim().min(1),
|
|
95
|
+
reason: optionalTrimmedString(240),
|
|
96
|
+
});
|
|
97
|
+
// ─── Collect an offline payment ──────────────────────────────────────────────
|
|
98
|
+
export const collectPaymentBodySchema = z.object({
|
|
99
|
+
amountInr: priceInrSchema,
|
|
100
|
+
method: paymentMethodSchema,
|
|
101
|
+
note: optionalTrimmedString(240),
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=membership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership.js","sourceRoot":"","sources":["../src/membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAC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;AAEhF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,EAAE,qBAAqB,CAAC,GAAG,CAAC;CACnC,CAAC,CAAC;AAGH,gFAAgF;AAEhF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,SAAS,EAAE,cAAc;IACzB,MAAM,EAAE,mBAAmB;IAC3B,IAAI,EAAE,qBAAqB,CAAC,GAAG,CAAC;CACjC,CAAC,CAAC","sourcesContent":["/**\n * gymmonk-schema — Membership & payments\n * =======================================\n * A member's live membership at a center: which plan/tenure, its lifecycle\n * status and dates, pause windows, and the payment ledger. v1 is single-center,\n * so one active membership per user.\n *\n * The \"expiring\" state the UI shows is DERIVED from `endDate` at the edge; the\n * stored `status` is the true lifecycle state.\n *\n * @module gymmonk-schema/membership\n */\n\nimport { z } from 'zod';\nimport {\n isoDateSchema,\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n priceInrSchema,\n} from './common.js';\nimport { planTierSchema, tenureIdSchema } from './membership-plan.js';\n\n// ─── Status ──────────────────────────────────────────────────────────────────\n\n/**\n * Membership lifecycle. `invited` = owner created it, member hasn't activated;\n * `expiring` is NOT stored (derived from `endDate`).\n */\nexport const membershipStatusSchema = z.enum([\n 'invited',\n 'active',\n 'paused',\n 'expired',\n 'cancelled',\n]);\nexport type MembershipStatus = z.infer<typeof membershipStatusSchema>;\n\n// ─── Payments ────────────────────────────────────────────────────────────────\n\nexport const paymentMethodSchema = z.enum(['upi', 'cash', 'card']);\nexport type PaymentMethod = z.infer<typeof paymentMethodSchema>;\n\nexport const paymentStatusSchema = z.enum(['success', 'failed', 'pending']);\nexport type PaymentStatus = z.infer<typeof paymentStatusSchema>;\n\nexport const paymentSchema = z.object({\n id: objectIdSchema,\n membershipId: objectIdSchema,\n amountInr: priceInrSchema,\n method: paymentMethodSchema,\n status: paymentStatusSchema,\n paidAt: isoDateTimeSchema,\n note: z.string().nullable(),\n});\nexport type Payment = z.infer<typeof paymentSchema>;\n\n// ─── Entity (API response) ───────────────────────────────────────────────────\n\nexport const membershipSchema = z.object({\n id: objectIdSchema,\n userId: objectIdSchema,\n centerId: objectIdSchema,\n /** Public member code within the gym, `GYM-YYYY-NNN`. */\n memberCode: z.string(),\n planId: objectIdSchema,\n tier: planTierSchema,\n planName: z.string(),\n tenureId: tenureIdSchema,\n tenureLabel: z.string(),\n priceInr: priceInrSchema,\n status: membershipStatusSchema,\n startDate: isoDateSchema,\n endDate: isoDateSchema,\n pausedFrom: isoDateSchema.nullable(),\n pausedTo: isoDateSchema.nullable(),\n createdAt: isoDateTimeSchema,\n updatedAt: isoDateTimeSchema,\n});\nexport type Membership = z.infer<typeof membershipSchema>;\n\n// ─── Assign / renew / upgrade ────────────────────────────────────────────────\n\n/**\n * Assign a plan to a member (new membership, renewal, or upgrade). Records the\n * charge in one shot; omit `payment` for an unpaid/invited assignment.\n */\nexport const assignMembershipBodySchema = z.object({\n planId: objectIdSchema,\n tenureId: tenureIdSchema,\n /** Explicit start; defaults to today server-side when omitted. */\n startDate: isoDateSchema.optional(),\n payment: z\n .object({\n amountInr: priceInrSchema,\n method: paymentMethodSchema,\n status: paymentStatusSchema.default('success'),\n })\n .optional(),\n});\nexport type AssignMembershipBody = z.infer<typeof assignMembershipBodySchema>;\n\n// ─── Pause ───────────────────────────────────────────────────────────────────\n\nexport const pauseDurationSchema = z.enum(['1w', '2w', '1m', 'custom']);\nexport type PauseDuration = z.infer<typeof pauseDurationSchema>;\n\nexport const pauseMembershipBodySchema = z\n .object({\n duration: pauseDurationSchema,\n customFrom: isoDateSchema.optional(),\n customTo: isoDateSchema.optional(),\n })\n .refine((v) => v.duration !== 'custom' || (v.customFrom && v.customTo), {\n message: 'Pick both pause dates',\n path: ['customTo'],\n });\nexport type PauseMembershipBody = z.infer<typeof pauseMembershipBodySchema>;\n\n// ─── Cancel ──────────────────────────────────────────────────────────────────\n\n/** Cancellation requires echoing the member code as a safety confirmation. */\nexport const cancelMembershipBodySchema = z.object({\n confirmationCode: z.string().trim().min(1),\n reason: optionalTrimmedString(240),\n});\nexport type CancelMembershipBody = z.infer<typeof cancelMembershipBodySchema>;\n\n// ─── Collect an offline payment ──────────────────────────────────────────────\n\nexport const collectPaymentBodySchema = z.object({\n amountInr: priceInrSchema,\n method: paymentMethodSchema,\n note: optionalTrimmedString(240),\n});\nexport type CollectPaymentBody = z.infer<typeof collectPaymentBodySchema>;\n"]}
|