gymmonk-schema 0.66.0 → 0.67.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/index.d.ts CHANGED
@@ -27,6 +27,7 @@ export * from './food.js';
27
27
  export * from './gym-registration.js';
28
28
  export * from './home.js';
29
29
  export * from './insights.js';
30
+ export * from './late-fee-reminder.js';
30
31
  export * from './location.js';
31
32
  export * from './member.js';
32
33
  export * from './member-profile.js';
@@ -44,7 +45,6 @@ export * from './owner-profile.js';
44
45
  export * from './payment.js';
45
46
  export * from './plan-abilities.js';
46
47
  export * from './plan-features-data.js';
47
- export * from './late-fee-reminder.js';
48
48
  export * from './plan-limits.js';
49
49
  export * from './platform.js';
50
50
  export * from './pricing.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAElC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAE5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAE9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,WAAW,CAAC;AAE1B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAE9B,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cA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Ac,wBAAwB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAElC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,sBAAsB,CAAC;AAErC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,cAAc,CAAC;AAE7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAE7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAElC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ export * from './food.js';
34
34
  export * from './gym-registration.js';
35
35
  export * from './home.js';
36
36
  export * from './insights.js';
37
+ export * from './late-fee-reminder.js';
37
38
  // ─── Where a place physically is (Maps link, pin, check-in position) ─────────
38
39
  export * from './location.js';
39
40
  // ─── People ──────────────────────────────────────────────────────────────────
@@ -60,7 +61,6 @@ export * from './payment.js';
60
61
  // ─── Platform console (people + gyms directories, role keys) ─────────────────
61
62
  export * from './plan-abilities.js';
62
63
  export * from './plan-features-data.js';
63
- export * from './late-fee-reminder.js';
64
64
  export * from './plan-limits.js';
65
65
  export * from './platform.js';
66
66
  export * from './pricing.js';
package/dist/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AAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,gFAAgF;AAChF,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,iFAAiF;AACjF,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC","sourcesContent":["/**\n * gymmonk-schema — Public API\n * ===========================\n * Shared Zod schemas, enums and domain types for GymMonk (fitness SaaS).\n * Single source of truth (SSOT) for data shapes, TypeScript types and\n * validation, consumed by both gymmonk-backend and gymmonk-web-client.\n *\n * Every domain module is re-exported through this barrel. Import names are\n * globally unique across modules, so `export *` composes without collisions.\n */\n\n// ─── Owner desk-entry FORM validation (client-side working shapes) ───────────\nexport * from './add-person-form.js';\nexport * from './announcement.js';\n// ─── Location master data (the address picker's lookup API) ───────────────\nexport * from './area.js';\nexport * from './body-metrics.js';\nexport * from './center.js';\n// ─── Check-in QR (poster payload shared by owner, member and backend) ────────\nexport * from './chat.js';\nexport * from './check-in.js';\n// ─── Foundation ──────────────────────────────────────────────────────────────\nexport * from './codes.js';\nexport * from './common.js';\nexport * from './diet-chart.js';\nexport * from './enrolment.js';\nexport * from './equipment.js';\n// ─── Training ────────────────────────────────────────────────────────────────\nexport * from './exercise.js';\nexport * from './feedback.js';\n// ─── Uploads ─────────────────────────────────────────────────────────────────\nexport * from './file.js';\n// ─── \"List your gym\" — a member registers the business they run ──────────────\nexport * from './food.js';\nexport * from './gym-registration.js';\nexport * from './home.js';\nexport * from './insights.js';\n// ─── Where a place physically is (Maps link, pin, check-in position) ─────────\nexport * from './location.js';\n// ─── People ──────────────────────────────────────────────────────────────────\nexport * from './member.js';\nexport * from './member-profile.js';\nexport * from './membership.js';\n// ─── Membership ──────────────────────────────────────────────────────────────\nexport * from './membership-plan.js';\nexport * from './membership-request.js';\nexport * from './membership-status.js';\n// ─── API result messages + error codes ───────────────────────────────────────\nexport * from './messages.js';\nexport * from './notification.js';\n// ─── Engagement & analytics ──────────────────────────────────────────────────\nexport * from './nutrition.js';\nexport * from './onboarding.js';\n// ─── Onboarding wizard FORM validation (client-side working shapes) ──────────\nexport * from './onboarding-form.js';\n// ─── Gym structure & onboarding ──────────────────────────────────────────────\nexport * from './organisation.js';\nexport * from './owner-profile.js';\n// ─── Razorpay checkout wire shapes ───────────────────────────────────────────\nexport * from './payment.js';\n// ─── Platform console (people + gyms directories, role keys) ─────────────────\nexport * from './plan-abilities.js';\nexport * from './plan-features-data.js';\nexport * from './late-fee-reminder.js';\nexport * from './plan-limits.js';\nexport * from './platform.js';\nexport * from './pricing.js';\n// ─── Member \"edit my profile\" FORM validation ────────────────────────────────\nexport * from './profile-edit-form.js';\nexport * from './saas-catalog.js';\nexport * from './session.js';\nexport * from './shared.js';\nexport * from './social.js';\nexport * from './staff.js';\nexport * from './subscription.js';\n// ─── Member fee payment by UPI QR (the gym's own VPA, no gateway) ─────────────\nexport * from './upi.js';\nexport * from './user.js';\nexport * from './workout-plan.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gFAAgF;AAChF,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,6EAA6E;AAC7E,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,gFAAgF;AAChF,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iB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,cAAc,mBAAmB,CAAC","sourcesContent":["/**\n * gymmonk-schema — Public API\n * ===========================\n * Shared Zod schemas, enums and domain types for GymMonk (fitness SaaS).\n * Single source of truth (SSOT) for data shapes, TypeScript types and\n * validation, consumed by both gymmonk-backend and gymmonk-web-client.\n *\n * Every domain module is re-exported through this barrel. Import names are\n * globally unique across modules, so `export *` composes without collisions.\n */\n\n// ─── Owner desk-entry FORM validation (client-side working shapes) ───────────\nexport * from './add-person-form.js';\nexport * from './announcement.js';\n// ─── Location master data (the address picker's lookup API) ───────────────\nexport * from './area.js';\nexport * from './body-metrics.js';\nexport * from './center.js';\n// ─── Check-in QR (poster payload shared by owner, member and backend) ────────\nexport * from './chat.js';\nexport * from './check-in.js';\n// ─── Foundation ──────────────────────────────────────────────────────────────\nexport * from './codes.js';\nexport * from './common.js';\nexport * from './diet-chart.js';\nexport * from './enrolment.js';\nexport * from './equipment.js';\n// ─── Training ────────────────────────────────────────────────────────────────\nexport * from './exercise.js';\nexport * from './feedback.js';\n// ─── Uploads ─────────────────────────────────────────────────────────────────\nexport * from './file.js';\n// ─── \"List your gym\" — a member registers the business they run ──────────────\nexport * from './food.js';\nexport * from './gym-registration.js';\nexport * from './home.js';\nexport * from './insights.js';\nexport * from './late-fee-reminder.js';\n// ─── Where a place physically is (Maps link, pin, check-in position) ─────────\nexport * from './location.js';\n// ─── People ──────────────────────────────────────────────────────────────────\nexport * from './member.js';\nexport * from './member-profile.js';\nexport * from './membership.js';\n// ─── Membership ──────────────────────────────────────────────────────────────\nexport * from './membership-plan.js';\nexport * from './membership-request.js';\nexport * from './membership-status.js';\n// ─── API result messages + error codes ───────────────────────────────────────\nexport * from './messages.js';\nexport * from './notification.js';\n// ─── Engagement & analytics ──────────────────────────────────────────────────\nexport * from './nutrition.js';\nexport * from './onboarding.js';\n// ─── Onboarding wizard FORM validation (client-side working shapes) ──────────\nexport * from './onboarding-form.js';\n// ─── Gym structure & onboarding ──────────────────────────────────────────────\nexport * from './organisation.js';\nexport * from './owner-profile.js';\n// ─── Razorpay checkout wire shapes ───────────────────────────────────────────\nexport * from './payment.js';\n// ─── Platform console (people + gyms directories, role keys) ─────────────────\nexport * from './plan-abilities.js';\nexport * from './plan-features-data.js';\nexport * from './plan-limits.js';\nexport * from './platform.js';\nexport * from './pricing.js';\n// ─── Member \"edit my profile\" FORM validation ────────────────────────────────\nexport * from './profile-edit-form.js';\nexport * from './saas-catalog.js';\nexport * from './session.js';\nexport * from './shared.js';\nexport * from './social.js';\nexport * from './staff.js';\nexport * from './subscription.js';\n// ─── Member fee payment by UPI QR (the gym's own VPA, no gateway) ─────────────\nexport * from './upi.js';\nexport * from './user.js';\nexport * from './workout-plan.js';\n"]}
@@ -42,8 +42,8 @@ export type LateFeeNoticeStatus = z.infer<typeof lateFeeNoticeStatusSchema>;
42
42
  export declare const lateFeeDeliveryStatusSchema: z.ZodEnum<{
43
43
  failed: "failed";
44
44
  sent: "sent";
45
- read: "read";
46
45
  delivered: "delivered";
46
+ read: "read";
47
47
  }>;
48
48
  export type LateFeeDeliveryStatus = z.infer<typeof lateFeeDeliveryStatusSchema>;
49
49
  /**
@@ -64,8 +64,8 @@ export declare const lateFeeReminderEntrySchema: z.ZodObject<{
64
64
  deliveryStatus: z.ZodNullable<z.ZodEnum<{
65
65
  failed: "failed";
66
66
  sent: "sent";
67
- read: "read";
68
67
  delivered: "delivered";
68
+ read: "read";
69
69
  }>>;
70
70
  sentAt: z.ZodNullable<z.ZodString>;
71
71
  }, z.core.$strip>;
@@ -86,8 +86,8 @@ export declare const lateFeeReminderUsageSchema: z.ZodObject<{
86
86
  deliveryStatus: z.ZodNullable<z.ZodEnum<{
87
87
  failed: "failed";
88
88
  sent: "sent";
89
- read: "read";
90
89
  delivered: "delivered";
90
+ read: "read";
91
91
  }>>;
92
92
  sentAt: z.ZodNullable<z.ZodString>;
93
93
  }, z.core.$strip>>;
@@ -76,8 +76,8 @@ export type AppNotification = z.infer<typeof notificationSchema>;
76
76
  */
77
77
  export declare const notificationFilterSchema: z.ZodEnum<{
78
78
  all: "all";
79
- unread: "unread";
80
79
  read: "read";
80
+ unread: "unread";
81
81
  hidden: "hidden";
82
82
  }>;
83
83
  export type NotificationFilter = z.infer<typeof notificationFilterSchema>;
@@ -86,8 +86,8 @@ export declare const notificationListQuerySchema: z.ZodObject<{
86
86
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
87
87
  filter: z.ZodDefault<z.ZodEnum<{
88
88
  all: "all";
89
- unread: "unread";
90
89
  read: "read";
90
+ unread: "unread";
91
91
  hidden: "hidden";
92
92
  }>>;
93
93
  }, z.core.$strip>;
@@ -168,6 +168,97 @@ export declare const platformPeopleSummarySchema: z.ZodObject<{
168
168
  owners: z.ZodNumber;
169
169
  }, z.core.$strip>;
170
170
  export type PlatformPeopleSummary = z.infer<typeof platformPeopleSummarySchema>;
171
+ /**
172
+ * One member who owes a gym money, seen from the platform.
173
+ *
174
+ * ── WHY THIS IS NOT A `PlatformUser` ────────────────────────────────────────
175
+ * Two reasons, and the second is the load-bearing one.
176
+ *
177
+ * `PlatformUser` carries no money at all — no plan, no balance, no due date —
178
+ * and bolting those onto every row of a directory that is overwhelmingly NOT
179
+ * members would be null for almost everybody and cost a join per page.
180
+ *
181
+ * ⚠️ And `PlatformUser.organisation` is populated ONLY FOR OWNERS, by design.
182
+ * A member's gym is not on that row. This screen exists to say "chase this
183
+ * person about that gym", so the gym is mandatory here, not nullable.
184
+ *
185
+ * ── KEYED ON THE ENROLMENT, NOT THE USER ────────────────────────────────────
186
+ * `userId` is nullable and frequently null: a gym can sell a plan at the desk
187
+ * to somebody who never installs the app, and those are exactly the members
188
+ * most likely to be late. The enrolment is the thing that always exists, so it
189
+ * is the id. Anything keyed on the user would silently drop the population this
190
+ * screen is most useful for.
191
+ */
192
+ export declare const platformOverdueMemberSchema: z.ZodObject<{
193
+ id: z.ZodString;
194
+ membershipId: z.ZodString;
195
+ userId: z.ZodNullable<z.ZodString>;
196
+ name: z.ZodString;
197
+ email: z.ZodNullable<z.ZodString>;
198
+ phone: z.ZodNullable<z.ZodString>;
199
+ avatar: z.ZodNullable<z.ZodString>;
200
+ roles: z.ZodArray<z.ZodEnum<{
201
+ member: "member";
202
+ trainer: "trainer";
203
+ owner: "owner";
204
+ support_agent: "support_agent";
205
+ moderator: "moderator";
206
+ superadmin: "superadmin";
207
+ platform_manager: "platform_manager";
208
+ gym_manager: "gym_manager";
209
+ frontdesk: "frontdesk";
210
+ }>>;
211
+ status: z.ZodNullable<z.ZodEnum<{
212
+ active: "active";
213
+ inactive: "inactive";
214
+ deleted: "deleted";
215
+ suspended: "suspended";
216
+ }>>;
217
+ isDeleted: z.ZodBoolean;
218
+ gym: z.ZodObject<{
219
+ id: z.ZodString;
220
+ name: z.ZodString;
221
+ approvalStatus: z.ZodEnum<{
222
+ pending: "pending";
223
+ rejected: "rejected";
224
+ approved: "approved";
225
+ }>;
226
+ }, z.core.$strip>;
227
+ planName: z.ZodString;
228
+ dueDate: z.ZodString;
229
+ overdueDays: z.ZodNumber;
230
+ balanceInr: z.ZodNumber;
231
+ priceInr: z.ZodNumber;
232
+ }, z.core.$strip>;
233
+ export type PlatformOverdueMember = z.infer<typeof platformOverdueMemberSchema>;
234
+ /**
235
+ * The overdue-fee list filter.
236
+ *
237
+ * ⚠️ NO UPPER BOUND ON HOW LATE. The automated sweep caps its lookback so its
238
+ * first production run cannot message everybody who has ever been late; this
239
+ * screen sends nothing by itself, so it inherits no such risk. Capping here
240
+ * would silently hide the oldest debts — which are the ones actually worth a
241
+ * phone call.
242
+ */
243
+ export declare const platformOverdueQuerySchema: z.ZodObject<{
244
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
245
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
246
+ q: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
247
+ organisationId: z.ZodOptional<z.ZodString>;
248
+ minOverdueDays: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
249
+ sort: z.ZodDefault<z.ZodEnum<{
250
+ overdue: "overdue";
251
+ amount: "amount";
252
+ }>>;
253
+ }, z.core.$strip>;
254
+ export type PlatformOverdueQuery = z.infer<typeof platformOverdueQuerySchema>;
255
+ /** Header counts for the overdue list. */
256
+ export declare const platformOverdueSummarySchema: z.ZodObject<{
257
+ members: z.ZodNumber;
258
+ gyms: z.ZodNumber;
259
+ totalDueInr: z.ZodNumber;
260
+ }, z.core.$strip>;
261
+ export type PlatformOverdueSummary = z.infer<typeof platformOverdueSummarySchema>;
171
262
  /**
172
263
  * Suspend or reinstate an account.
173
264
  *
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;EAUxB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAIpD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;iBAIhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqB7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;iBASlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,8CAA8C;AAC9C,eAAO,MAAM,2BAA2B;;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GAMG;AACH,eAAO,MAAM,wBAAwB;;;;;;iBAOnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B;;iBAEtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
package/dist/platform.js CHANGED
@@ -128,6 +128,101 @@ export const platformPeopleSummarySchema = z.object({
128
128
  staff: z.number().int(),
129
129
  owners: z.number().int(),
130
130
  });
131
+ // ─── Overdue fees ────────────────────────────────────────────────────────────
132
+ /**
133
+ * One member who owes a gym money, seen from the platform.
134
+ *
135
+ * ── WHY THIS IS NOT A `PlatformUser` ────────────────────────────────────────
136
+ * Two reasons, and the second is the load-bearing one.
137
+ *
138
+ * `PlatformUser` carries no money at all — no plan, no balance, no due date —
139
+ * and bolting those onto every row of a directory that is overwhelmingly NOT
140
+ * members would be null for almost everybody and cost a join per page.
141
+ *
142
+ * ⚠️ And `PlatformUser.organisation` is populated ONLY FOR OWNERS, by design.
143
+ * A member's gym is not on that row. This screen exists to say "chase this
144
+ * person about that gym", so the gym is mandatory here, not nullable.
145
+ *
146
+ * ── KEYED ON THE ENROLMENT, NOT THE USER ────────────────────────────────────
147
+ * `userId` is nullable and frequently null: a gym can sell a plan at the desk
148
+ * to somebody who never installs the app, and those are exactly the members
149
+ * most likely to be late. The enrolment is the thing that always exists, so it
150
+ * is the id. Anything keyed on the user would silently drop the population this
151
+ * screen is most useful for.
152
+ */
153
+ export const platformOverdueMemberSchema = z.object({
154
+ /** The enrolment — the only id every overdue member is guaranteed to have. */
155
+ id: objectIdSchema,
156
+ /** The term being chased. Actions and dedupe key on this, never on the person. */
157
+ membershipId: objectIdSchema,
158
+ /** Null when the desk added this member and nobody ever claimed the record. */
159
+ userId: objectIdSchema.nullable(),
160
+ /**
161
+ * Resolved by the backend: the account's name, else the name typed at intake.
162
+ *
163
+ * ⚠️ MAY BE EMPTY, and consumers must handle that rather than assume a
164
+ * placeholder. It is empty only when the gym recorded no name at all, and it
165
+ * is deliberately NOT filled with something like "Unclaimed member" —
166
+ * this string is read aloud in the WhatsApp reminder, so a placeholder here
167
+ * greets a real person as "Hi Unclaimed,".
168
+ */
169
+ name: z.string(),
170
+ email: z.string().nullable(),
171
+ /** Raw 10 digits. Either the account's or the `invitePhone` the desk wrote down. */
172
+ phone: z.string().nullable(),
173
+ avatar: z.string().nullable(),
174
+ /**
175
+ * Every hat, so the operator can tell a plain member from a gym's own owner
176
+ * who is behind on their personal membership. Empty for an unclaimed record —
177
+ * there is no account to hold a role.
178
+ */
179
+ roles: z.array(roleKeySchema),
180
+ /** Account standing. Null for an unclaimed record: there is no account. */
181
+ status: userStatusSchema.nullable(),
182
+ /** Soft-deleted account. An unclaimed record is never deleted, so false. */
183
+ isDeleted: z.boolean(),
184
+ /** MANDATORY here — see the note above on why it is nullable on PlatformUser. */
185
+ gym: platformUserGymSchema,
186
+ planName: z.string(),
187
+ /**
188
+ * The gym day the term ended, as stored: `YYYY-MM-DD`.
189
+ *
190
+ * ⚠️ A calendar label, NOT an instant. Never hand it to `new Date()` for
191
+ * display — `new Date('2026-08-15')` is midnight UTC and renders as the 14th
192
+ * anywhere west of Greenwich.
193
+ */
194
+ dueDate: z.string(),
195
+ overdueDays: z.number().int(),
196
+ balanceInr: z.number(),
197
+ priceInr: z.number(),
198
+ });
199
+ /**
200
+ * The overdue-fee list filter.
201
+ *
202
+ * ⚠️ NO UPPER BOUND ON HOW LATE. The automated sweep caps its lookback so its
203
+ * first production run cannot message everybody who has ever been late; this
204
+ * screen sends nothing by itself, so it inherits no such risk. Capping here
205
+ * would silently hide the oldest debts — which are the ones actually worth a
206
+ * phone call.
207
+ */
208
+ export const platformOverdueQuerySchema = z.object({
209
+ page: z.coerce.number().int().min(1).default(1),
210
+ limit: z.coerce.number().int().min(1).max(100).default(20),
211
+ /** Member name, email or phone. */
212
+ q: optionalTrimmedString(120),
213
+ /** Narrow to one gym, for a support conversation about that gym. */
214
+ organisationId: objectIdSchema.optional(),
215
+ /** At least this many days late. 1 means a full day must have passed. */
216
+ minOverdueDays: z.coerce.number().int().min(1).max(3650).default(1),
217
+ /** Worst debt first, or longest overdue first. */
218
+ sort: z.enum(['overdue', 'amount']).default('overdue'),
219
+ });
220
+ /** Header counts for the overdue list. */
221
+ export const platformOverdueSummarySchema = z.object({
222
+ members: z.number().int(),
223
+ gyms: z.number().int(),
224
+ totalDueInr: z.number(),
225
+ });
131
226
  // ─── People mutations ────────────────────────────────────────────────────────
132
227
  /**
133
228
  * Suspend or reinstate an account.
@@ -1 +1 @@
1
- {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE5D,gFAAgF;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC;IAClC,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,kBAAkB;IAClB,WAAW;IACX,eAAe;IACf,aAAa;IACb,SAAS;IACT,WAAW;CACZ,CAAC,CAAC;AAGH,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,EAAE,EAAE,cAAc;IAClB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,cAAc,EAAE,gCAAgC;CACjD,CAAC,CAAC;AA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EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;QAC1B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;KAC3B,CAAC;IACF,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;IACtC;;;OAGG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;QAC7B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;QACnC,8EAA8E;QAC9E,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;KACrC,CAAC;CACH,CAAC,CAAC;AAGH,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACzB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC1B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC1B,yCAAyC;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;CAC1B,CAAC,CAAC;AAGH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC3C,CAAC,CAAC","sourcesContent":["/**\n * gymmonk-schema — Platform console (superadmin / platform manager)\n * ================================================================\n * The two directories the platform operates GymMonk from: every person with an\n * account, and every gym on the platform.\n *\n * ONE CONSOLE, TWO ROLES. Superadmin and platform manager see the same screens\n * and call the same endpoints. The single difference is DESTRUCTIVE ACTS:\n * `casl-ability#grantPlatformManager` states `cannot('delete', 'User')` and\n * `cannot('delete', 'Organisation')`, while superadmin holds `manage all`. That\n * is deliberately expressed as an ABILITY rather than as two contracts — a\n * second set of types for \"the manager's version of the people list\" would drift\n * from the first the moment either changed, and the client would be deciding\n * what it is allowed to do instead of being told.\n *\n * SCOPE. These are PLATFORM views: unscoped by gym, unscoped by center. No gym\n * role can reach them (see the `GymApproval` subject note in `casl-ability`), so\n * nothing here is filtered by organisation.\n *\n * @module gymmonk-schema/platform\n */\n\nimport { z } from 'zod';\nimport {\n deletedFilterSchema,\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n} from './common.js';\nimport { organisationApprovalStatusSchema } from './organisation.js';\nimport { appRoleSchema, userStatusSchema } from './user.js';\n\n// ─── Role keys ───────────────────────────────────────────────────────────────\n\n/**\n * Every role the tab-bar switcher understands — the wire contract for \"what\n * hats does this person wear\".\n *\n * The SSOT for a set that was previously written out three times: as a TypeScript\n * union in the backend's `casl-ability.ts`, again in the web client's\n * `shared/config/roles.ts`, and again as the values of the backend's role-snapshot\n * maps. Three copies of a closed set is three chances for one of them to miss a\n * role, and the people directory filters on exactly this set — a filter offering\n * a role the deriver never emits returns a permanently empty list with no error.\n *\n * Note `platform_manager` vs the `manager` APP ROLE (`appRoleSchema`): the app\n * role is what is stored on the user, the role key is what the product calls the\n * hat. `gym_manager` is a different job entirely, which is why neither can be\n * called plain \"manager\" on the wire.\n */\nexport const roleKeySchema = z.enum([\n 'member',\n 'owner',\n 'superadmin',\n 'platform_manager',\n 'moderator',\n 'support_agent',\n 'gym_manager',\n 'trainer',\n 'frontdesk',\n]);\nexport type RoleKey = z.infer<typeof roleKeySchema>;\n\n// ─── People directory ────────────────────────────────────────────────────────\n\n/**\n * The gym a person owns, summarised for a directory row.\n *\n * Present only for owners. It is on the row rather than behind a second request\n * because \"which gym is this?\" is the first question asked about any owner in a\n * support or vetting context, and a directory that makes you open each row to\n * find out is not a directory.\n */\nexport const platformUserGymSchema = z.object({\n id: objectIdSchema,\n name: z.string(),\n approvalStatus: organisationApprovalStatusSchema,\n});\nexport type PlatformUserGym = z.infer<typeof platformUserGymSchema>;\n\n/**\n * A row in the platform's people directory.\n *\n * `name` arrives RESOLVED — the backend has already applied the\n * `firstName lastName` → email fallback chain, so every client renders the same\n * thing and no screen invents its own version of \"what do we call this person\".\n *\n * `appRoles` and `roles` are BOTH here and they are not the same list.\n * `appRoles` is what is stored on the account and is what an admin can grant or\n * revoke. `roles` is the full derived set including the gym hats implied by\n * domain records — owning an organisation, holding a staff record, having a\n * member profile. An admin who is shown only `appRoles` cannot tell a plain\n * member from the owner of the platform's largest gym.\n */\nexport const platformUserSchema = z.object({\n id: objectIdSchema,\n name: z.string(),\n email: z.string(),\n /** Raw 10 digits, no `+91` — the country code is display-only. */\n phone: z.string().nullable(),\n avatar: z.string().nullable(),\n /** Granted platform roles. Empty for the overwhelming majority of accounts. */\n appRoles: z.array(appRoleSchema),\n /** Every hat, including the gym roles derived from domain records. */\n roles: z.array(roleKeySchema),\n status: userStatusSchema,\n organisation: platformUserGymSchema.nullable(),\n /**\n * Soft-deleted. The account is retained (deleting an owner would cascade into\n * an organisation, its centres, every member and the payment ledger) but is\n * excluded from every ordinary query. Only a superadmin can set this.\n */\n isDeleted: z.boolean(),\n lastActiveAt: isoDateTimeSchema.nullable(),\n createdAt: isoDateTimeSchema,\n});\nexport type PlatformUser = z.infer<typeof platformUserSchema>;\n\n/**\n * The people-list filter.\n *\n * `role` filters on the DERIVED set, not on `appRoles`, so \"show me every gym\n * owner\" works — owner is never an app role. The derivation is denormalised onto\n * the user (`User.roleSnapshot.roles`), which is what makes this an indexed\n * query rather than a fan-out per candidate row.\n */\nexport const platformUserQuerySchema = z.object({\n page: z.coerce.number().int().min(1).default(1),\n limit: z.coerce.number().int().min(1).max(100).default(20),\n /** Name, email or phone. */\n q: optionalTrimmedString(120),\n role: roleKeySchema.optional(),\n status: userStatusSchema.optional(),\n /** Soft-delete visibility. `only` is the superadmin's restore queue. */\n deleted: deletedFilterSchema.default('exclude'),\n});\nexport type PlatformUserQuery = z.infer<typeof platformUserQuerySchema>;\n\n/** Header counts for the people directory. */\nexport const platformPeopleSummarySchema = z.object({\n total: z.number().int(),\n active: z.number().int(),\n suspended: z.number().int(),\n /** Accounts holding at least one platform app-role. */\n staff: z.number().int(),\n owners: z.number().int(),\n});\nexport type PlatformPeopleSummary = z.infer<typeof platformPeopleSummarySchema>;\n\n// ─── People mutations ────────────────────────────────────────────────────────\n\n/**\n * Suspend or reinstate an account.\n *\n * Only these two values. `deleted` is reached through the delete endpoint (which\n * needs a stronger ability and a typed confirmation), and `inactive` is a\n * lifecycle state the product sets for itself — letting an admin write either\n * one here would put the account into a state no screen explains and no action\n * reverses.\n */\nexport const setUserStatusBodySchema = z.object({\n status: z.enum(['active', 'suspended']),\n});\nexport type SetUserStatusBody = z.infer<typeof setUserStatusBodySchema>;\n\n/**\n * Replace the account's platform roles.\n *\n * A whole-array PUT rather than add/remove deltas: the console shows all four\n * checkboxes at once, so the admin is always looking at the complete intended\n * state, and a delta API would let two admins editing the same person silently\n * merge into a set neither chose.\n */\nexport const setAppRolesBodySchema = z.object({\n appRoles: z.array(appRoleSchema).max(4),\n});\nexport type SetAppRolesBody = z.infer<typeof setAppRolesBodySchema>;\n\n/**\n * Soft-delete an account. Superadmin only.\n *\n * The caller must echo the account's EMAIL back. The same echo-to-confirm guard\n * the member and membership deletions use — it is the one pattern that survives\n * a mis-tap on a phone, where a destructive button sits a thumb's width from a\n * harmless one.\n */\nexport const deletePlatformUserBodySchema = z.object({\n confirmationEmail: z.string().trim().min(1),\n});\nexport type DeletePlatformUserBody = z.infer<typeof deletePlatformUserBodySchema>;\n\n// ─── Platform overview (the console's Dashboard tab) ─────────────────────────\n\n/**\n * One month of platform growth.\n *\n * `label` is rendered SERVER-SIDE, already in IST. Month bucketing is done with\n * an explicit `Asia/Kolkata` timezone in the aggregation, and the label is built\n * from the same bucket — so the client never derives a date. Letting it do so\n * would put a UTC container and an IST phone in different months for five and a\n * half hours every night, which is a hydration mismatch that only reproduces\n * after 18:30 IST.\n */\nexport const platformTrendPointSchema = z.object({\n /** Short month, e.g. `Mar`. Includes the year when the window crosses one. */\n label: z.string(),\n /** Accounts created that month. */\n people: z.number().int(),\n /** Gyms registered that month. */\n gyms: z.number().int(),\n});\nexport type PlatformTrendPoint = z.infer<typeof platformTrendPointSchema>;\n\n/** A gym in the \"biggest on the platform\" table. */\nexport const platformTopGymSchema = z.object({\n id: objectIdSchema,\n name: z.string(),\n memberCount: z.number().int(),\n centerCount: z.number().int(),\n approvalStatus: organisationApprovalStatusSchema,\n});\nexport type PlatformTopGym = z.infer<typeof platformTopGymSchema>;\n\n/**\n * Everything the Dashboard tab renders, in one request.\n *\n * One endpoint rather than six. This screen is the console's landing tab, so its\n * cost is paid on every visit — and six round trips would each carry their own\n * loading state, producing a dashboard that reflows four times before settling.\n * The aggregations run concurrently server-side, where they are cheap.\n */\nexport const platformOverviewSchema = z.object({\n totals: z.object({\n /** Registered gyms, whatever their approval state. */\n gyms: z.number().int(),\n centers: z.number().int(),\n /** People with a member record at a gym — NOT the same as `people`. */\n members: z.number().int(),\n /** Memberships currently live (active or paused, not expired). */\n activeMemberships: z.number().int(),\n /** Every account on GymMonk, members and staff alike. */\n people: z.number().int(),\n /** All money successfully collected across every gym, in whole rupees. */\n revenueInr: z.number().int(),\n }),\n /** Growth, oldest month first. */\n trend: z.array(platformTrendPointSchema),\n gymsByStatus: z.object({\n pending: z.number().int(),\n approved: z.number().int(),\n rejected: z.number().int(),\n }),\n topGyms: z.array(platformTopGymSchema),\n /**\n * What is waiting for a human. Every number here is a link on the dashboard,\n * so a count of zero is a good outcome rather than an empty section.\n */\n attention: z.object({\n pendingGyms: z.number().int(),\n suspendedAccounts: z.number().int(),\n /** Approved gyms that never created a centre, so members cannot join them. */\n gymsWithoutCenters: z.number().int(),\n }),\n});\nexport type PlatformOverview = z.infer<typeof platformOverviewSchema>;\n\n// ─── Gym directory ───────────────────────────────────────────────────────────\n\n/**\n * Header counts for the gyms directory, and the review-queue badge.\n *\n * `pending` was previously the only count returned, which was enough for a badge\n * and nothing else: the Gyms tab shows the whole estate, and a screen that can\n * say \"12 pending\" but not \"of how many\" tells an operator nothing about scale.\n */\nexport const platformGymSummarySchema = z.object({\n total: z.number().int(),\n pending: z.number().int(),\n approved: z.number().int(),\n rejected: z.number().int(),\n /** Centres across every approved gym. */\n centers: z.number().int(),\n});\nexport type PlatformGymSummary = z.infer<typeof platformGymSummarySchema>;\n\n/**\n * Soft-delete a gym. Superadmin only.\n *\n * Echoes the gym's NAME rather than an id — an operator reading a confirmation\n * dialog can verify a name against the row they meant to act on; an id they\n * would paste without reading.\n */\nexport const deletePlatformGymBodySchema = z.object({\n confirmationName: z.string().trim().min(1),\n});\nexport type DeletePlatformGymBody = z.infer<typeof deletePlatformGymBodySchema>;\n"]}
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE5D,gFAAgF;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC;IAClC,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,kBAAkB;IAClB,WAAW;IACX,eAAe;IACf,aAAa;IACb,SAAS;IACT,WAAW;CACZ,CAAC,CAAC;AAGH,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,C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AC,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;QAC7B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;QACnC,8EAA8E;QAC9E,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;KACrC,CAAC;CACH,CAAC,CAAC;AAGH,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACzB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC1B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC1B,yCAAyC;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;CAC1B,CAAC,CAAC;AAGH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC3C,CAAC,CAAC","sourcesContent":["/**\n * gymmonk-schema — Platform console (superadmin / platform manager)\n * ================================================================\n * The two directories the platform operates GymMonk from: every person with an\n * account, and every gym on the platform.\n *\n * ONE CONSOLE, TWO ROLES. Superadmin and platform manager see the same screens\n * and call the same endpoints. The single difference is DESTRUCTIVE ACTS:\n * `casl-ability#grantPlatformManager` states `cannot('delete', 'User')` and\n * `cannot('delete', 'Organisation')`, while superadmin holds `manage all`. That\n * is deliberately expressed as an ABILITY rather than as two contracts — a\n * second set of types for \"the manager's version of the people list\" would drift\n * from the first the moment either changed, and the client would be deciding\n * what it is allowed to do instead of being told.\n *\n * SCOPE. These are PLATFORM views: unscoped by gym, unscoped by center. No gym\n * role can reach them (see the `GymApproval` subject note in `casl-ability`), so\n * nothing here is filtered by organisation.\n *\n * @module gymmonk-schema/platform\n */\n\nimport { z } from 'zod';\nimport {\n deletedFilterSchema,\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n} from './common.js';\nimport { organisationApprovalStatusSchema } from './organisation.js';\nimport { appRoleSchema, userStatusSchema } from './user.js';\n\n// ─── Role keys ───────────────────────────────────────────────────────────────\n\n/**\n * Every role the tab-bar switcher understands — the wire contract for \"what\n * hats does this person wear\".\n *\n * The SSOT for a set that was previously written out three times: as a TypeScript\n * union in the backend's `casl-ability.ts`, again in the web client's\n * `shared/config/roles.ts`, and again as the values of the backend's role-snapshot\n * maps. Three copies of a closed set is three chances for one of them to miss a\n * role, and the people directory filters on exactly this set — a filter offering\n * a role the deriver never emits returns a permanently empty list with no error.\n *\n * Note `platform_manager` vs the `manager` APP ROLE (`appRoleSchema`): the app\n * role is what is stored on the user, the role key is what the product calls the\n * hat. `gym_manager` is a different job entirely, which is why neither can be\n * called plain \"manager\" on the wire.\n */\nexport const roleKeySchema = z.enum([\n 'member',\n 'owner',\n 'superadmin',\n 'platform_manager',\n 'moderator',\n 'support_agent',\n 'gym_manager',\n 'trainer',\n 'frontdesk',\n]);\nexport type RoleKey = z.infer<typeof roleKeySchema>;\n\n// ─── People directory ────────────────────────────────────────────────────────\n\n/**\n * The gym a person owns, summarised for a directory row.\n *\n * Present only for owners. It is on the row rather than behind a second request\n * because \"which gym is this?\" is the first question asked about any owner in a\n * support or vetting context, and a directory that makes you open each row to\n * find out is not a directory.\n */\nexport const platformUserGymSchema = z.object({\n id: objectIdSchema,\n name: z.string(),\n approvalStatus: organisationApprovalStatusSchema,\n});\nexport type PlatformUserGym = z.infer<typeof platformUserGymSchema>;\n\n/**\n * A row in the platform's people directory.\n *\n * `name` arrives RESOLVED — the backend has already applied the\n * `firstName lastName` → email fallback chain, so every client renders the same\n * thing and no screen invents its own version of \"what do we call this person\".\n *\n * `appRoles` and `roles` are BOTH here and they are not the same list.\n * `appRoles` is what is stored on the account and is what an admin can grant or\n * revoke. `roles` is the full derived set including the gym hats implied by\n * domain records — owning an organisation, holding a staff record, having a\n * member profile. An admin who is shown only `appRoles` cannot tell a plain\n * member from the owner of the platform's largest gym.\n */\nexport const platformUserSchema = z.object({\n id: objectIdSchema,\n name: z.string(),\n email: z.string(),\n /** Raw 10 digits, no `+91` — the country code is display-only. */\n phone: z.string().nullable(),\n avatar: z.string().nullable(),\n /** Granted platform roles. Empty for the overwhelming majority of accounts. */\n appRoles: z.array(appRoleSchema),\n /** Every hat, including the gym roles derived from domain records. */\n roles: z.array(roleKeySchema),\n status: userStatusSchema,\n organisation: platformUserGymSchema.nullable(),\n /**\n * Soft-deleted. The account is retained (deleting an owner would cascade into\n * an organisation, its centres, every member and the payment ledger) but is\n * excluded from every ordinary query. Only a superadmin can set this.\n */\n isDeleted: z.boolean(),\n lastActiveAt: isoDateTimeSchema.nullable(),\n createdAt: isoDateTimeSchema,\n});\nexport type PlatformUser = z.infer<typeof platformUserSchema>;\n\n/**\n * The people-list filter.\n *\n * `role` filters on the DERIVED set, not on `appRoles`, so \"show me every gym\n * owner\" works — owner is never an app role. The derivation is denormalised onto\n * the user (`User.roleSnapshot.roles`), which is what makes this an indexed\n * query rather than a fan-out per candidate row.\n */\nexport const platformUserQuerySchema = z.object({\n page: z.coerce.number().int().min(1).default(1),\n limit: z.coerce.number().int().min(1).max(100).default(20),\n /** Name, email or phone. */\n q: optionalTrimmedString(120),\n role: roleKeySchema.optional(),\n status: userStatusSchema.optional(),\n /** Soft-delete visibility. `only` is the superadmin's restore queue. */\n deleted: deletedFilterSchema.default('exclude'),\n});\nexport type PlatformUserQuery = z.infer<typeof platformUserQuerySchema>;\n\n/** Header counts for the people directory. */\nexport const platformPeopleSummarySchema = z.object({\n total: z.number().int(),\n active: z.number().int(),\n suspended: z.number().int(),\n /** Accounts holding at least one platform app-role. */\n staff: z.number().int(),\n owners: z.number().int(),\n});\nexport type PlatformPeopleSummary = z.infer<typeof platformPeopleSummarySchema>;\n\n// ─── Overdue fees ────────────────────────────────────────────────────────────\n\n/**\n * One member who owes a gym money, seen from the platform.\n *\n * ── WHY THIS IS NOT A `PlatformUser` ────────────────────────────────────────\n * Two reasons, and the second is the load-bearing one.\n *\n * `PlatformUser` carries no money at all — no plan, no balance, no due date —\n * and bolting those onto every row of a directory that is overwhelmingly NOT\n * members would be null for almost everybody and cost a join per page.\n *\n * ⚠️ And `PlatformUser.organisation` is populated ONLY FOR OWNERS, by design.\n * A member's gym is not on that row. This screen exists to say \"chase this\n * person about that gym\", so the gym is mandatory here, not nullable.\n *\n * ── KEYED ON THE ENROLMENT, NOT THE USER ────────────────────────────────────\n * `userId` is nullable and frequently null: a gym can sell a plan at the desk\n * to somebody who never installs the app, and those are exactly the members\n * most likely to be late. The enrolment is the thing that always exists, so it\n * is the id. Anything keyed on the user would silently drop the population this\n * screen is most useful for.\n */\nexport const platformOverdueMemberSchema = z.object({\n /** The enrolment — the only id every overdue member is guaranteed to have. */\n id: objectIdSchema,\n /** The term being chased. Actions and dedupe key on this, never on the person. */\n membershipId: objectIdSchema,\n /** Null when the desk added this member and nobody ever claimed the record. */\n userId: objectIdSchema.nullable(),\n /**\n * Resolved by the backend: the account's name, else the name typed at intake.\n *\n * ⚠️ MAY BE EMPTY, and consumers must handle that rather than assume a\n * placeholder. It is empty only when the gym recorded no name at all, and it\n * is deliberately NOT filled with something like \"Unclaimed member\" —\n * this string is read aloud in the WhatsApp reminder, so a placeholder here\n * greets a real person as \"Hi Unclaimed,\".\n */\n name: z.string(),\n email: z.string().nullable(),\n /** Raw 10 digits. Either the account's or the `invitePhone` the desk wrote down. */\n phone: z.string().nullable(),\n avatar: z.string().nullable(),\n /**\n * Every hat, so the operator can tell a plain member from a gym's own owner\n * who is behind on their personal membership. Empty for an unclaimed record —\n * there is no account to hold a role.\n */\n roles: z.array(roleKeySchema),\n /** Account standing. Null for an unclaimed record: there is no account. */\n status: userStatusSchema.nullable(),\n /** Soft-deleted account. An unclaimed record is never deleted, so false. */\n isDeleted: z.boolean(),\n /** MANDATORY here — see the note above on why it is nullable on PlatformUser. */\n gym: platformUserGymSchema,\n planName: z.string(),\n /**\n * The gym day the term ended, as stored: `YYYY-MM-DD`.\n *\n * ⚠️ A calendar label, NOT an instant. Never hand it to `new Date()` for\n * display — `new Date('2026-08-15')` is midnight UTC and renders as the 14th\n * anywhere west of Greenwich.\n */\n dueDate: z.string(),\n overdueDays: z.number().int(),\n balanceInr: z.number(),\n priceInr: z.number(),\n});\nexport type PlatformOverdueMember = z.infer<typeof platformOverdueMemberSchema>;\n\n/**\n * The overdue-fee list filter.\n *\n * ⚠️ NO UPPER BOUND ON HOW LATE. The automated sweep caps its lookback so its\n * first production run cannot message everybody who has ever been late; this\n * screen sends nothing by itself, so it inherits no such risk. Capping here\n * would silently hide the oldest debts — which are the ones actually worth a\n * phone call.\n */\nexport const platformOverdueQuerySchema = z.object({\n page: z.coerce.number().int().min(1).default(1),\n limit: z.coerce.number().int().min(1).max(100).default(20),\n /** Member name, email or phone. */\n q: optionalTrimmedString(120),\n /** Narrow to one gym, for a support conversation about that gym. */\n organisationId: objectIdSchema.optional(),\n /** At least this many days late. 1 means a full day must have passed. */\n minOverdueDays: z.coerce.number().int().min(1).max(3650).default(1),\n /** Worst debt first, or longest overdue first. */\n sort: z.enum(['overdue', 'amount']).default('overdue'),\n});\nexport type PlatformOverdueQuery = z.infer<typeof platformOverdueQuerySchema>;\n\n/** Header counts for the overdue list. */\nexport const platformOverdueSummarySchema = z.object({\n members: z.number().int(),\n gyms: z.number().int(),\n totalDueInr: z.number(),\n});\nexport type PlatformOverdueSummary = z.infer<typeof platformOverdueSummarySchema>;\n\n// ─── People mutations ────────────────────────────────────────────────────────\n\n/**\n * Suspend or reinstate an account.\n *\n * Only these two values. `deleted` is reached through the delete endpoint (which\n * needs a stronger ability and a typed confirmation), and `inactive` is a\n * lifecycle state the product sets for itself — letting an admin write either\n * one here would put the account into a state no screen explains and no action\n * reverses.\n */\nexport const setUserStatusBodySchema = z.object({\n status: z.enum(['active', 'suspended']),\n});\nexport type SetUserStatusBody = z.infer<typeof setUserStatusBodySchema>;\n\n/**\n * Replace the account's platform roles.\n *\n * A whole-array PUT rather than add/remove deltas: the console shows all four\n * checkboxes at once, so the admin is always looking at the complete intended\n * state, and a delta API would let two admins editing the same person silently\n * merge into a set neither chose.\n */\nexport const setAppRolesBodySchema = z.object({\n appRoles: z.array(appRoleSchema).max(4),\n});\nexport type SetAppRolesBody = z.infer<typeof setAppRolesBodySchema>;\n\n/**\n * Soft-delete an account. Superadmin only.\n *\n * The caller must echo the account's EMAIL back. The same echo-to-confirm guard\n * the member and membership deletions use — it is the one pattern that survives\n * a mis-tap on a phone, where a destructive button sits a thumb's width from a\n * harmless one.\n */\nexport const deletePlatformUserBodySchema = z.object({\n confirmationEmail: z.string().trim().min(1),\n});\nexport type DeletePlatformUserBody = z.infer<typeof deletePlatformUserBodySchema>;\n\n// ─── Platform overview (the console's Dashboard tab) ─────────────────────────\n\n/**\n * One month of platform growth.\n *\n * `label` is rendered SERVER-SIDE, already in IST. Month bucketing is done with\n * an explicit `Asia/Kolkata` timezone in the aggregation, and the label is built\n * from the same bucket — so the client never derives a date. Letting it do so\n * would put a UTC container and an IST phone in different months for five and a\n * half hours every night, which is a hydration mismatch that only reproduces\n * after 18:30 IST.\n */\nexport const platformTrendPointSchema = z.object({\n /** Short month, e.g. `Mar`. Includes the year when the window crosses one. */\n label: z.string(),\n /** Accounts created that month. */\n people: z.number().int(),\n /** Gyms registered that month. */\n gyms: z.number().int(),\n});\nexport type PlatformTrendPoint = z.infer<typeof platformTrendPointSchema>;\n\n/** A gym in the \"biggest on the platform\" table. */\nexport const platformTopGymSchema = z.object({\n id: objectIdSchema,\n name: z.string(),\n memberCount: z.number().int(),\n centerCount: z.number().int(),\n approvalStatus: organisationApprovalStatusSchema,\n});\nexport type PlatformTopGym = z.infer<typeof platformTopGymSchema>;\n\n/**\n * Everything the Dashboard tab renders, in one request.\n *\n * One endpoint rather than six. This screen is the console's landing tab, so its\n * cost is paid on every visit — and six round trips would each carry their own\n * loading state, producing a dashboard that reflows four times before settling.\n * The aggregations run concurrently server-side, where they are cheap.\n */\nexport const platformOverviewSchema = z.object({\n totals: z.object({\n /** Registered gyms, whatever their approval state. */\n gyms: z.number().int(),\n centers: z.number().int(),\n /** People with a member record at a gym — NOT the same as `people`. */\n members: z.number().int(),\n /** Memberships currently live (active or paused, not expired). */\n activeMemberships: z.number().int(),\n /** Every account on GymMonk, members and staff alike. */\n people: z.number().int(),\n /** All money successfully collected across every gym, in whole rupees. */\n revenueInr: z.number().int(),\n }),\n /** Growth, oldest month first. */\n trend: z.array(platformTrendPointSchema),\n gymsByStatus: z.object({\n pending: z.number().int(),\n approved: z.number().int(),\n rejected: z.number().int(),\n }),\n topGyms: z.array(platformTopGymSchema),\n /**\n * What is waiting for a human. Every number here is a link on the dashboard,\n * so a count of zero is a good outcome rather than an empty section.\n */\n attention: z.object({\n pendingGyms: z.number().int(),\n suspendedAccounts: z.number().int(),\n /** Approved gyms that never created a centre, so members cannot join them. */\n gymsWithoutCenters: z.number().int(),\n }),\n});\nexport type PlatformOverview = z.infer<typeof platformOverviewSchema>;\n\n// ─── Gym directory ───────────────────────────────────────────────────────────\n\n/**\n * Header counts for the gyms directory, and the review-queue badge.\n *\n * `pending` was previously the only count returned, which was enough for a badge\n * and nothing else: the Gyms tab shows the whole estate, and a screen that can\n * say \"12 pending\" but not \"of how many\" tells an operator nothing about scale.\n */\nexport const platformGymSummarySchema = z.object({\n total: z.number().int(),\n pending: z.number().int(),\n approved: z.number().int(),\n rejected: z.number().int(),\n /** Centres across every approved gym. */\n centers: z.number().int(),\n});\nexport type PlatformGymSummary = z.infer<typeof platformGymSummarySchema>;\n\n/**\n * Soft-delete a gym. Superadmin only.\n *\n * Echoes the gym's NAME rather than an id — an operator reading a confirmation\n * dialog can verify a name against the row they meant to act on; an id they\n * would paste without reading.\n */\nexport const deletePlatformGymBodySchema = z.object({\n confirmationName: z.string().trim().min(1),\n});\nexport type DeletePlatformGymBody = z.infer<typeof deletePlatformGymBodySchema>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gymmonk-schema",
3
- "version": "0.66.0",
3
+ "version": "0.67.0",
4
4
  "description": "Shared Zod schemas, enums and domain types for GymMonk (fitness SaaS) — single source of truth (SSOT) consumed by gymmonk-backend and gymmonk-web-client.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",