gymmonk-schema 0.53.0 → 0.55.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 +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/member.d.ts +1 -0
- package/dist/member.d.ts.map +1 -1
- package/dist/member.js +2 -0
- package/dist/member.js.map +1 -1
- package/dist/membership.d.ts +44 -0
- package/dist/membership.d.ts.map +1 -1
- package/dist/membership.js +44 -0
- package/dist/membership.js.map +1 -1
- package/dist/messages.d.ts +38 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +27 -0
- package/dist/messages.js.map +1 -1
- package/dist/nutrition.d.ts.map +1 -1
- package/dist/nutrition.js +8 -1
- package/dist/nutrition.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,12 +12,12 @@ export * from './add-person-form.js';
|
|
|
12
12
|
export * from './announcement.js';
|
|
13
13
|
export * from './area.js';
|
|
14
14
|
export * from './body-metrics.js';
|
|
15
|
-
export * from './diet-chart.js';
|
|
16
15
|
export * from './center.js';
|
|
17
16
|
export * from './chat.js';
|
|
18
17
|
export * from './check-in.js';
|
|
19
18
|
export * from './codes.js';
|
|
20
19
|
export * from './common.js';
|
|
20
|
+
export * from './diet-chart.js';
|
|
21
21
|
export * from './enrolment.js';
|
|
22
22
|
export * from './equipment.js';
|
|
23
23
|
export * from './exercise.js';
|
|
@@ -35,8 +35,8 @@ export * from './membership-plan.js';
|
|
|
35
35
|
export * from './membership-request.js';
|
|
36
36
|
export * from './membership-status.js';
|
|
37
37
|
export * from './messages.js';
|
|
38
|
-
export * from './nutrition.js';
|
|
39
38
|
export * from './notification.js';
|
|
39
|
+
export * from './nutrition.js';
|
|
40
40
|
export * from './onboarding.js';
|
|
41
41
|
export * from './onboarding-form.js';
|
|
42
42
|
export * from './organisation.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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,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,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;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ export * from './announcement.js';
|
|
|
14
14
|
// ─── Location master data (the address picker's lookup API) ───────────────
|
|
15
15
|
export * from './area.js';
|
|
16
16
|
export * from './body-metrics.js';
|
|
17
|
-
export * from './diet-chart.js';
|
|
18
17
|
export * from './center.js';
|
|
19
18
|
// ─── Check-in QR (poster payload shared by owner, member and backend) ────────
|
|
20
19
|
export * from './chat.js';
|
|
@@ -22,6 +21,7 @@ export * from './check-in.js';
|
|
|
22
21
|
// ─── Foundation ──────────────────────────────────────────────────────────────
|
|
23
22
|
export * from './codes.js';
|
|
24
23
|
export * from './common.js';
|
|
24
|
+
export * from './diet-chart.js';
|
|
25
25
|
export * from './enrolment.js';
|
|
26
26
|
export * from './equipment.js';
|
|
27
27
|
// ─── Training ────────────────────────────────────────────────────────────────
|
|
@@ -46,9 +46,9 @@ export * from './membership-request.js';
|
|
|
46
46
|
export * from './membership-status.js';
|
|
47
47
|
// ─── API result messages + error codes ───────────────────────────────────────
|
|
48
48
|
export * from './messages.js';
|
|
49
|
+
export * from './notification.js';
|
|
49
50
|
// ─── Engagement & analytics ──────────────────────────────────────────────────
|
|
50
51
|
export * from './nutrition.js';
|
|
51
|
-
export * from './notification.js';
|
|
52
52
|
export * from './onboarding.js';
|
|
53
53
|
// ─── Onboarding wizard FORM validation (client-side working shapes) ──────────
|
|
54
54
|
export * from './onboarding-form.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,WAAW,CAAC;AAC1B,gFAAgF;AAChF,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,gFAAgF;AAChF,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,gFAAgF;AAChF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,gFAAgF;AAChF,cAAc,sBAAsB,CAAC;AACrC,gFAAgF;AAChF,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,gFAAgF;AAChF,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,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,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// ─── 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';\nexport * from './user.js';\nexport * from './workout-plan.js';\n"]}
|
package/dist/member.d.ts
CHANGED
|
@@ -152,6 +152,7 @@ export declare const memberDetailSchema: z.ZodObject<{
|
|
|
152
152
|
joinedAt: z.ZodISODateTime;
|
|
153
153
|
lastVisitAt: z.ZodNullable<z.ZodISODateTime>;
|
|
154
154
|
assignedWorkoutPlanId: z.ZodNullable<z.ZodString>;
|
|
155
|
+
assignedDietChartId: z.ZodNullable<z.ZodString>;
|
|
155
156
|
assignedTrainerId: z.ZodNullable<z.ZodString>;
|
|
156
157
|
membership: z.ZodNullable<z.ZodObject<{
|
|
157
158
|
id: z.ZodString;
|
package/dist/member.d.ts.map
CHANGED
|
@@ -1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CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,2BAA2B;;iBAEtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,wEAAwE;AACxE,eAAO,MAAM,sBAAsB;;iBAEjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
package/dist/member.js
CHANGED
|
@@ -129,6 +129,8 @@ export const memberDetailSchema = z.object({
|
|
|
129
129
|
joinedAt: isoDateTimeSchema,
|
|
130
130
|
lastVisitAt: isoDateTimeSchema.nullable(),
|
|
131
131
|
assignedWorkoutPlanId: objectIdSchema.nullable(),
|
|
132
|
+
/** The diet chart this gym has them on. Same scoping as the plan above. */
|
|
133
|
+
assignedDietChartId: objectIdSchema.nullable(),
|
|
132
134
|
assignedTrainerId: objectIdSchema.nullable(),
|
|
133
135
|
/**
|
|
134
136
|
* The member's current membership, in FULL rather than by id.
|
package/dist/member.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member.js","sourceRoot":"","sources":["../src/member.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EA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IG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC/B,CAAC,CAAC;AAGH,gFAAgF;AAEhF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAG3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,SAAS,EAAE,cAAc,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC;AAGH,wEAAwE;AACxE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC3C,CAAC,CAAC","sourcesContent":["/**\n * gymmonk-schema — Member management (owner console)\n * ==================================================\n * Owner-facing roster + detail projections (User × MemberProfile × Membership)\n * and the \"add member\" provisioning payload. Adding a member provisions a real\n * central-auth account, so the result carries the login email + temp password.\n *\n * @module gymmonk-schema/member\n */\n\nimport { z } from 'zod';\nimport { gymMemberCodeSchema } from './codes.js';\nimport {\n isoDateSchema,\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n paginationSchema,\n phoneSchema,\n priceInrSchema,\n} from './common.js';\nimport { enrolmentStatusSchema } from './enrolment.js';\nimport { emergencyContactSchema, MAX_EMERGENCY_CONTACTS } from './member-profile.js';\nimport {\n assignMembershipBodySchema,\n membershipSchema,\n membershipStatusSchema,\n membershipTermSchema,\n} from './membership.js';\nimport { bloodGroupSchema, genderSchema } from './shared.js';\n\n// ─── Segments ────────────────────────────────────────────────────────────────\n\n/** Attention buckets surfaced on roster cards. */\nexport const memberSegmentSchema = z.enum(['expiring', 'new', 'at-risk']);\nexport type MemberSegment = z.infer<typeof memberSegmentSchema>;\n\n// ─── Roster item (list projection) ───────────────────────────────────────────\n\nexport const memberRosterItemSchema = z.object({\n /** The gym record id — always present, even before the member claims. */\n enrolmentId: objectIdSchema,\n /** Null until claimed; the roster shows an \"Invited\" pill in that state. */\n userId: objectIdSchema.nullable(),\n recordStatus: enrolmentStatusSchema,\n membershipId: objectIdSchema.nullable(),\n gymMemberCode: gymMemberCodeSchema,\n name: z.string(),\n avatarUrl: z.string().nullable(),\n verified: z.boolean(),\n /**\n * Contact details, on the ROSTER row rather than only the detail record.\n *\n * The card's whole job when someone is overdue is to let the owner chase it\n * without leaving the list — call, WhatsApp, email. Those are `tel:` /\n * `wa.me` / `mailto:` links, so the row cannot build them without the raw\n * values, and fetching the full member just to dial them would be one\n * request per card.\n *\n * Nullable because an invited record may have only one of the two: the gym\n * creates it with whatever it has, and the member fills in the rest on claim.\n * Phone is RAW 10 digits — `+91` is display-only, never stored.\n */\n phone: z.string().nullable(),\n email: z.email().nullable(),\n planName: z.string().nullable(),\n status: membershipStatusSchema.nullable(),\n endDate: isoDateSchema.nullable(),\n\n /**\n * The pause window, carried on the ROW rather than looked up per member.\n *\n * A pause is a window that ends by itself — nothing resumes it — so\n * `status: 'paused'` stays written in the database long after the member is\n * back. Without these two dates the roster can only see the stale column,\n * and it showed exactly that: a \"Paused\" pill and exclusion from\n * `?filter=active` on somebody the door had already started letting in, while\n * the header count beside them — which reads the same window in Mongo — said\n * they were active. Two numbers on one screen that could not both be true.\n */\n pausedFrom: isoDateSchema.nullable(),\n pausedTo: isoDateSchema.nullable(),\n\n lastVisitAt: isoDateTimeSchema.nullable(),\n balanceDueInr: priceInrSchema,\n overdueDays: z.number().int().nullable(),\n segments: z.array(memberSegmentSchema),\n\n /**\n * When the gym record was created — NOT when the person claimed it. The\n * roster's \"Joined Date\" filter groups by how long someone has been a member\n * of the gym, which starts at the desk, not at the login.\n */\n joinedAt: isoDateTimeSchema,\n\n /**\n * Check-ins in the trailing 14 days, used by the roster's attendance filters\n * to separate a no-show from an irregular from a regular.\n *\n * Counted rather than derived from `lastVisitAt`, because the two answer\n * different questions: someone who came once yesterday and someone who comes\n * daily share a last visit but are not the same member to chase.\n */\n visits14d: z.number().int().nonnegative(),\n\n /** Assigned trainer, so the roster can be filtered down to one trainer's people. */\n trainerId: objectIdSchema.nullable(),\n trainerName: z.string().nullable(),\n});\n\n/** Trailing window the roster's attendance filters and `visits14d` are measured over. */\nexport const ATTENDANCE_WINDOW_DAYS = 14;\nexport type MemberRosterItem = z.infer<typeof memberRosterItemSchema>;\n\n/** Header counts for the roster. */\nexport const memberListSummarySchema = z.object({\n total: z.number().int().nonnegative(),\n active: z.number().int().nonnegative(),\n expiring: z.number().int().nonnegative(),\n inactive: z.number().int().nonnegative(),\n});\nexport type MemberListSummary = z.infer<typeof memberListSummarySchema>;\n\n// ─── List query ──────────────────────────────────────────────────────────────\n\nexport const memberFilterSchema = z.enum(['all', 'active', 'inactive', 'verified']);\nexport type MemberFilter = z.infer<typeof memberFilterSchema>;\n\nexport const memberSortSchema = z.enum(['recent', 'az', 'expiry', 'dues']);\nexport type MemberSort = z.infer<typeof memberSortSchema>;\n\nexport const memberListQuerySchema = paginationSchema.extend({\n centerId: objectIdSchema.optional(),\n filter: memberFilterSchema.default('all'),\n sort: memberSortSchema.default('recent'),\n q: optionalTrimmedString(120),\n});\nexport type MemberListQuery = z.infer<typeof memberListQuerySchema>;\n\n// ─── Detail projection ───────────────────────────────────────────────────────\n\n/** The identity slice a projection pulls from the auth `User`. */\nexport const memberUserRefSchema = z.object({\n /** Null while the record is still `invited` (no central-auth account linked). */\n id: objectIdSchema.nullable(),\n name: z.string(),\n email: z.string(),\n phone: z.string().nullable(),\n avatarUrl: z.string().nullable(),\n verified: z.boolean(),\n});\nexport type MemberUserRef = z.infer<typeof memberUserRefSchema>;\n\nexport const memberDetailSchema = z.object({\n enrolmentId: objectIdSchema,\n recordStatus: enrolmentStatusSchema,\n /**\n * Identity from central auth once claimed. Before that the gym still knows the\n * person (name / contact captured at the desk), so this carries the invited\n * details with `id: null`.\n */\n user: memberUserRefSchema,\n gymMemberCode: gymMemberCodeSchema,\n gender: genderSchema.nullable(),\n dob: isoDateSchema.nullable(),\n bloodGroup: bloodGroupSchema.nullable(),\n emergencyContacts: z.array(emergencyContactSchema),\n joinedAt: isoDateTimeSchema,\n lastVisitAt: isoDateTimeSchema.nullable(),\n assignedWorkoutPlanId: objectIdSchema.nullable(),\n assignedTrainerId: objectIdSchema.nullable(),\n /**\n * The member's current membership, in FULL rather than by id.\n *\n * The profile screen shows the plan name, its billing cycle, the lifecycle\n * status pill and the expiry date all at once, and every one of those lives\n * here. Sending only the id forced the owner console to re-query the roster\n * for the same member just to read the plan columns back, and to match the\n * plan by NAME to find its perk icons — both of which this removes.\n */\n membership: membershipSchema.nullable(),\n /**\n * Still owed on the current term: its price less what has been recorded as\n * collected. Zero when settled, when the membership was cancelled, or when\n * there is no membership at all. Same definition as the roster's column, so\n * the profile and the list can never disagree about who owes money.\n */\n balanceDueInr: z.number().int().nonnegative(),\n /**\n * The term the NEXT confirmed payment will cover, so the owner reads it\n * before deciding rather than discovering it afterwards.\n *\n * Null when the answer is not yet knowable: no membership has ever been\n * assigned, so there is no variant duration to measure a term with. It is\n * deliberately computed here rather than in the client — the cycle depends\n * on the joining date, the enrolment's creation month and the terms already\n * sold, and a client that recomputed it from a partial view would show a\n * different month than the one the server is about to write.\n */\n nextTerm: membershipTermSchema.nullable(),\n});\nexport type MemberDetail = z.infer<typeof memberDetailSchema>;\n\n// ─── Add member (provisioning) ───────────────────────────────────────────────\n\nexport const createMemberBodySchema = z.object({\n firstName: z.string().trim().min(1, 'First name is required').max(80),\n lastName: optionalTrimmedString(80),\n email: z.email('A valid email is required'),\n phone: phoneSchema,\n gender: genderSchema,\n dob: isoDateSchema.optional(),\n bloodGroup: bloodGroupSchema.optional(),\n emergencyContacts: z.array(emergencyContactSchema).max(MAX_EMERGENCY_CONTACTS).default([]),\n avatarUrl: optionalTrimmedString(2000),\n assignedTrainerId: objectIdSchema.optional(),\n /** Optionally assign a plan in the same step. */\n initialPlan: assignMembershipBodySchema.optional(),\n});\nexport type CreateMemberBody = z.infer<typeof createMemberBodySchema>;\n\n/**\n * Edit a member's record from the owner console.\n *\n * Every field is optional — the console sends what the form holds, and a field\n * left out is left alone.\n *\n * ## What the gym may and may not change\n * `firstName` / `lastName` / `email` / `phone` are the INVITE details, and the\n * server accepts them only while the record is unclaimed. Once the member has\n * linked their central-auth account, that account is the source of truth for\n * their identity and is shared with the other products — a gym must not be able\n * to rewrite someone's name or email out from under them. The server ignores\n * those four on a claimed record rather than failing the whole request, so an\n * owner correcting a blood group is never blocked by a name they cannot change.\n *\n * Nullable fields (`dob`, `bloodGroup`, `assignedTrainerId`) accept `null` to\n * CLEAR a value, which `undefined` cannot express.\n */\nexport const updateMemberBodySchema = createMemberBodySchema\n .omit({\n initialPlan: true,\n dob: true,\n bloodGroup: true,\n assignedTrainerId: true,\n })\n .partial()\n .extend({\n dob: isoDateSchema.nullish(),\n bloodGroup: bloodGroupSchema.nullish(),\n assignedTrainerId: objectIdSchema.nullish(),\n /**\n * The date the GYM says this person started training there.\n *\n * Editable because the app's record and the gym's record are different\n * facts and routinely disagree: somebody who has trained since March is\n * added to GymMonk in July, and until now their joining date was silently\n * the day the desk got round to typing them in. That date is not a\n * cosmetic label — it anchors the billing cycle, so a wrong one bills the\n * member on the wrong day of every month for as long as they stay.\n *\n * Deliberately unbounded in the past: it records something that already\n * happened, and a gym may well be older than this app. The BILLING floor\n * is a separate rule and is enforced where terms are derived, so an\n * honest March joining date can never be turned into a March invoice.\n */\n joinedAt: isoDateSchema.optional(),\n });\nexport type UpdateMemberBody = z.infer<typeof updateMemberBodySchema>;\n\n// ─── Invite & claim ──────────────────────────────────────────────────────────\n\n/**\n * The invite a gym hands to a new member.\n *\n * GymMonk never mints credentials for anyone: central auth is the SSOT for\n * identity, and an account there is shared across products. So adding a member\n * creates a gym record only, plus an unguessable invite code. The member\n * registers/logs in themselves through central auth (exactly as in jansathi) and\n * then CLAIMS the record. The owner shares `url` over WhatsApp or shows the QR.\n */\nexport const memberInviteSchema = z.object({\n /** Single-use, unguessable. Regenerating an invite invalidates the old one. */\n code: z.string(),\n /** Absolute claim URL the owner shares (also encoded into the QR). */\n url: z.string(),\n /** The address the member MUST register with for the claim to succeed. */\n email: z.string(),\n /** WhatsApp number to share on, when the gym recorded one. */\n phone: z.string().nullable(),\n expiresAt: isoDateTimeSchema,\n});\nexport type MemberInvite = z.infer<typeof memberInviteSchema>;\n\n/** Result of adding a member: the gym record + the invite to hand over. */\nexport const provisionResultSchema = z.object({\n /** The new member record (NOT a central-auth user — none is created). */\n enrolmentId: objectIdSchema,\n code: z.string(),\n invite: memberInviteSchema,\n /**\n * The membership created from `initialPlan`, or `null`.\n *\n * Null means one of two DIFFERENT things, and the caller can tell them apart\n * because it knows whether it sent `initialPlan`: no plan was chosen, or the\n * chosen plan could not be assigned. Adding a member never fails over the\n * second case — the person is on the roster either way — so this is how the\n * owner finds out the plan still needs assigning rather than assuming it took.\n */\n membership: membershipSchema.nullable(),\n});\nexport type ProvisionResult = z.infer<typeof provisionResultSchema>;\n\n/**\n * What the claim screen shows BEFORE the member authenticates, so they know\n * which address to register with. Public (the code is the bearer secret), and\n * deliberately minimal — gym name, member code, and the expected email.\n */\nexport const invitePreviewSchema = z.object({\n gymName: z.string(),\n gymMemberCode: gymMemberCodeSchema,\n /** Shown verbatim: the member must know exactly which address to use. */\n email: z.string(),\n expiresAt: isoDateTimeSchema,\n /** True once claimed / expired, so the screen can explain why it failed. */\n claimed: z.boolean(),\n expired: z.boolean(),\n});\nexport type InvitePreview = z.infer<typeof invitePreviewSchema>;\n\n/**\n * Claim an invite as the authenticated caller. The server links the record only\n * when the code is valid AND the caller's central-auth email matches the address\n * the invite was issued to.\n */\nexport const claimInviteBodySchema = z.object({\n code: z.string().trim().min(1),\n});\nexport type ClaimInviteBody = z.infer<typeof claimInviteBodySchema>;\n\n// ─── Mutations ───────────────────────────────────────────────────────────────\n\nexport const setMemberStatusBodySchema = z.object({ active: z.boolean() });\nexport type SetMemberStatusBody = z.infer<typeof setMemberStatusBodySchema>;\n\nexport const assignTrainerBodySchema = z.object({\n trainerId: objectIdSchema.nullable(),\n});\nexport type AssignTrainerBody = z.infer<typeof assignTrainerBodySchema>;\n\nexport const assignWorkoutPlanBodySchema = z.object({\n planId: objectIdSchema.nullable(),\n});\nexport type AssignWorkoutPlanBody = z.infer<typeof assignWorkoutPlanBodySchema>;\n\n/** Remove a member from the gym — echoes the member code to confirm. */\nexport const deleteMemberBodySchema = z.object({\n confirmationCode: z.string().trim().min(1),\n});\nexport type DeleteMemberBody = z.infer<typeof deleteMemberBodySchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"member.js","sourceRoot":"","sources":["../src/member.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,gFAAgF;AAEhF,kDAAk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CAAC,CAAC;AAGH,gFAAgF;AAEhF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAG3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,SAAS,EAAE,cAAc,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC;AAGH,wEAAwE;AACxE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC3C,CAAC,CAAC","sourcesContent":["/**\n * gymmonk-schema — Member management (owner console)\n * ==================================================\n * Owner-facing roster + detail projections (User × MemberProfile × Membership)\n * and the \"add member\" provisioning payload. Adding a member provisions a real\n * central-auth account, so the result carries the login email + temp password.\n *\n * @module gymmonk-schema/member\n */\n\nimport { z } from 'zod';\nimport { gymMemberCodeSchema } from './codes.js';\nimport {\n isoDateSchema,\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n paginationSchema,\n phoneSchema,\n priceInrSchema,\n} from './common.js';\nimport { enrolmentStatusSchema } from './enrolment.js';\nimport { emergencyContactSchema, MAX_EMERGENCY_CONTACTS } from './member-profile.js';\nimport {\n assignMembershipBodySchema,\n membershipSchema,\n membershipStatusSchema,\n membershipTermSchema,\n} from './membership.js';\nimport { bloodGroupSchema, genderSchema } from './shared.js';\n\n// ─── Segments ────────────────────────────────────────────────────────────────\n\n/** Attention buckets surfaced on roster cards. */\nexport const memberSegmentSchema = z.enum(['expiring', 'new', 'at-risk']);\nexport type MemberSegment = z.infer<typeof memberSegmentSchema>;\n\n// ─── Roster item (list projection) ───────────────────────────────────────────\n\nexport const memberRosterItemSchema = z.object({\n /** The gym record id — always present, even before the member claims. */\n enrolmentId: objectIdSchema,\n /** Null until claimed; the roster shows an \"Invited\" pill in that state. */\n userId: objectIdSchema.nullable(),\n recordStatus: enrolmentStatusSchema,\n membershipId: objectIdSchema.nullable(),\n gymMemberCode: gymMemberCodeSchema,\n name: z.string(),\n avatarUrl: z.string().nullable(),\n verified: z.boolean(),\n /**\n * Contact details, on the ROSTER row rather than only the detail record.\n *\n * The card's whole job when someone is overdue is to let the owner chase it\n * without leaving the list — call, WhatsApp, email. Those are `tel:` /\n * `wa.me` / `mailto:` links, so the row cannot build them without the raw\n * values, and fetching the full member just to dial them would be one\n * request per card.\n *\n * Nullable because an invited record may have only one of the two: the gym\n * creates it with whatever it has, and the member fills in the rest on claim.\n * Phone is RAW 10 digits — `+91` is display-only, never stored.\n */\n phone: z.string().nullable(),\n email: z.email().nullable(),\n planName: z.string().nullable(),\n status: membershipStatusSchema.nullable(),\n endDate: isoDateSchema.nullable(),\n\n /**\n * The pause window, carried on the ROW rather than looked up per member.\n *\n * A pause is a window that ends by itself — nothing resumes it — so\n * `status: 'paused'` stays written in the database long after the member is\n * back. Without these two dates the roster can only see the stale column,\n * and it showed exactly that: a \"Paused\" pill and exclusion from\n * `?filter=active` on somebody the door had already started letting in, while\n * the header count beside them — which reads the same window in Mongo — said\n * they were active. Two numbers on one screen that could not both be true.\n */\n pausedFrom: isoDateSchema.nullable(),\n pausedTo: isoDateSchema.nullable(),\n\n lastVisitAt: isoDateTimeSchema.nullable(),\n balanceDueInr: priceInrSchema,\n overdueDays: z.number().int().nullable(),\n segments: z.array(memberSegmentSchema),\n\n /**\n * When the gym record was created — NOT when the person claimed it. The\n * roster's \"Joined Date\" filter groups by how long someone has been a member\n * of the gym, which starts at the desk, not at the login.\n */\n joinedAt: isoDateTimeSchema,\n\n /**\n * Check-ins in the trailing 14 days, used by the roster's attendance filters\n * to separate a no-show from an irregular from a regular.\n *\n * Counted rather than derived from `lastVisitAt`, because the two answer\n * different questions: someone who came once yesterday and someone who comes\n * daily share a last visit but are not the same member to chase.\n */\n visits14d: z.number().int().nonnegative(),\n\n /** Assigned trainer, so the roster can be filtered down to one trainer's people. */\n trainerId: objectIdSchema.nullable(),\n trainerName: z.string().nullable(),\n});\n\n/** Trailing window the roster's attendance filters and `visits14d` are measured over. */\nexport const ATTENDANCE_WINDOW_DAYS = 14;\nexport type MemberRosterItem = z.infer<typeof memberRosterItemSchema>;\n\n/** Header counts for the roster. */\nexport const memberListSummarySchema = z.object({\n total: z.number().int().nonnegative(),\n active: z.number().int().nonnegative(),\n expiring: z.number().int().nonnegative(),\n inactive: z.number().int().nonnegative(),\n});\nexport type MemberListSummary = z.infer<typeof memberListSummarySchema>;\n\n// ─── List query ──────────────────────────────────────────────────────────────\n\nexport const memberFilterSchema = z.enum(['all', 'active', 'inactive', 'verified']);\nexport type MemberFilter = z.infer<typeof memberFilterSchema>;\n\nexport const memberSortSchema = z.enum(['recent', 'az', 'expiry', 'dues']);\nexport type MemberSort = z.infer<typeof memberSortSchema>;\n\nexport const memberListQuerySchema = paginationSchema.extend({\n centerId: objectIdSchema.optional(),\n filter: memberFilterSchema.default('all'),\n sort: memberSortSchema.default('recent'),\n q: optionalTrimmedString(120),\n});\nexport type MemberListQuery = z.infer<typeof memberListQuerySchema>;\n\n// ─── Detail projection ───────────────────────────────────────────────────────\n\n/** The identity slice a projection pulls from the auth `User`. */\nexport const memberUserRefSchema = z.object({\n /** Null while the record is still `invited` (no central-auth account linked). */\n id: objectIdSchema.nullable(),\n name: z.string(),\n email: z.string(),\n phone: z.string().nullable(),\n avatarUrl: z.string().nullable(),\n verified: z.boolean(),\n});\nexport type MemberUserRef = z.infer<typeof memberUserRefSchema>;\n\nexport const memberDetailSchema = z.object({\n enrolmentId: objectIdSchema,\n recordStatus: enrolmentStatusSchema,\n /**\n * Identity from central auth once claimed. Before that the gym still knows the\n * person (name / contact captured at the desk), so this carries the invited\n * details with `id: null`.\n */\n user: memberUserRefSchema,\n gymMemberCode: gymMemberCodeSchema,\n gender: genderSchema.nullable(),\n dob: isoDateSchema.nullable(),\n bloodGroup: bloodGroupSchema.nullable(),\n emergencyContacts: z.array(emergencyContactSchema),\n joinedAt: isoDateTimeSchema,\n lastVisitAt: isoDateTimeSchema.nullable(),\n assignedWorkoutPlanId: objectIdSchema.nullable(),\n /** The diet chart this gym has them on. Same scoping as the plan above. */\n assignedDietChartId: objectIdSchema.nullable(),\n assignedTrainerId: objectIdSchema.nullable(),\n /**\n * The member's current membership, in FULL rather than by id.\n *\n * The profile screen shows the plan name, its billing cycle, the lifecycle\n * status pill and the expiry date all at once, and every one of those lives\n * here. Sending only the id forced the owner console to re-query the roster\n * for the same member just to read the plan columns back, and to match the\n * plan by NAME to find its perk icons — both of which this removes.\n */\n membership: membershipSchema.nullable(),\n /**\n * Still owed on the current term: its price less what has been recorded as\n * collected. Zero when settled, when the membership was cancelled, or when\n * there is no membership at all. Same definition as the roster's column, so\n * the profile and the list can never disagree about who owes money.\n */\n balanceDueInr: z.number().int().nonnegative(),\n /**\n * The term the NEXT confirmed payment will cover, so the owner reads it\n * before deciding rather than discovering it afterwards.\n *\n * Null when the answer is not yet knowable: no membership has ever been\n * assigned, so there is no variant duration to measure a term with. It is\n * deliberately computed here rather than in the client — the cycle depends\n * on the joining date, the enrolment's creation month and the terms already\n * sold, and a client that recomputed it from a partial view would show a\n * different month than the one the server is about to write.\n */\n nextTerm: membershipTermSchema.nullable(),\n});\nexport type MemberDetail = z.infer<typeof memberDetailSchema>;\n\n// ─── Add member (provisioning) ───────────────────────────────────────────────\n\nexport const createMemberBodySchema = z.object({\n firstName: z.string().trim().min(1, 'First name is required').max(80),\n lastName: optionalTrimmedString(80),\n email: z.email('A valid email is required'),\n phone: phoneSchema,\n gender: genderSchema,\n dob: isoDateSchema.optional(),\n bloodGroup: bloodGroupSchema.optional(),\n emergencyContacts: z.array(emergencyContactSchema).max(MAX_EMERGENCY_CONTACTS).default([]),\n avatarUrl: optionalTrimmedString(2000),\n assignedTrainerId: objectIdSchema.optional(),\n /** Optionally assign a plan in the same step. */\n initialPlan: assignMembershipBodySchema.optional(),\n});\nexport type CreateMemberBody = z.infer<typeof createMemberBodySchema>;\n\n/**\n * Edit a member's record from the owner console.\n *\n * Every field is optional — the console sends what the form holds, and a field\n * left out is left alone.\n *\n * ## What the gym may and may not change\n * `firstName` / `lastName` / `email` / `phone` are the INVITE details, and the\n * server accepts them only while the record is unclaimed. Once the member has\n * linked their central-auth account, that account is the source of truth for\n * their identity and is shared with the other products — a gym must not be able\n * to rewrite someone's name or email out from under them. The server ignores\n * those four on a claimed record rather than failing the whole request, so an\n * owner correcting a blood group is never blocked by a name they cannot change.\n *\n * Nullable fields (`dob`, `bloodGroup`, `assignedTrainerId`) accept `null` to\n * CLEAR a value, which `undefined` cannot express.\n */\nexport const updateMemberBodySchema = createMemberBodySchema\n .omit({\n initialPlan: true,\n dob: true,\n bloodGroup: true,\n assignedTrainerId: true,\n })\n .partial()\n .extend({\n dob: isoDateSchema.nullish(),\n bloodGroup: bloodGroupSchema.nullish(),\n assignedTrainerId: objectIdSchema.nullish(),\n /**\n * The date the GYM says this person started training there.\n *\n * Editable because the app's record and the gym's record are different\n * facts and routinely disagree: somebody who has trained since March is\n * added to GymMonk in July, and until now their joining date was silently\n * the day the desk got round to typing them in. That date is not a\n * cosmetic label — it anchors the billing cycle, so a wrong one bills the\n * member on the wrong day of every month for as long as they stay.\n *\n * Deliberately unbounded in the past: it records something that already\n * happened, and a gym may well be older than this app. The BILLING floor\n * is a separate rule and is enforced where terms are derived, so an\n * honest March joining date can never be turned into a March invoice.\n */\n joinedAt: isoDateSchema.optional(),\n });\nexport type UpdateMemberBody = z.infer<typeof updateMemberBodySchema>;\n\n// ─── Invite & claim ──────────────────────────────────────────────────────────\n\n/**\n * The invite a gym hands to a new member.\n *\n * GymMonk never mints credentials for anyone: central auth is the SSOT for\n * identity, and an account there is shared across products. So adding a member\n * creates a gym record only, plus an unguessable invite code. The member\n * registers/logs in themselves through central auth (exactly as in jansathi) and\n * then CLAIMS the record. The owner shares `url` over WhatsApp or shows the QR.\n */\nexport const memberInviteSchema = z.object({\n /** Single-use, unguessable. Regenerating an invite invalidates the old one. */\n code: z.string(),\n /** Absolute claim URL the owner shares (also encoded into the QR). */\n url: z.string(),\n /** The address the member MUST register with for the claim to succeed. */\n email: z.string(),\n /** WhatsApp number to share on, when the gym recorded one. */\n phone: z.string().nullable(),\n expiresAt: isoDateTimeSchema,\n});\nexport type MemberInvite = z.infer<typeof memberInviteSchema>;\n\n/** Result of adding a member: the gym record + the invite to hand over. */\nexport const provisionResultSchema = z.object({\n /** The new member record (NOT a central-auth user — none is created). */\n enrolmentId: objectIdSchema,\n code: z.string(),\n invite: memberInviteSchema,\n /**\n * The membership created from `initialPlan`, or `null`.\n *\n * Null means one of two DIFFERENT things, and the caller can tell them apart\n * because it knows whether it sent `initialPlan`: no plan was chosen, or the\n * chosen plan could not be assigned. Adding a member never fails over the\n * second case — the person is on the roster either way — so this is how the\n * owner finds out the plan still needs assigning rather than assuming it took.\n */\n membership: membershipSchema.nullable(),\n});\nexport type ProvisionResult = z.infer<typeof provisionResultSchema>;\n\n/**\n * What the claim screen shows BEFORE the member authenticates, so they know\n * which address to register with. Public (the code is the bearer secret), and\n * deliberately minimal — gym name, member code, and the expected email.\n */\nexport const invitePreviewSchema = z.object({\n gymName: z.string(),\n gymMemberCode: gymMemberCodeSchema,\n /** Shown verbatim: the member must know exactly which address to use. */\n email: z.string(),\n expiresAt: isoDateTimeSchema,\n /** True once claimed / expired, so the screen can explain why it failed. */\n claimed: z.boolean(),\n expired: z.boolean(),\n});\nexport type InvitePreview = z.infer<typeof invitePreviewSchema>;\n\n/**\n * Claim an invite as the authenticated caller. The server links the record only\n * when the code is valid AND the caller's central-auth email matches the address\n * the invite was issued to.\n */\nexport const claimInviteBodySchema = z.object({\n code: z.string().trim().min(1),\n});\nexport type ClaimInviteBody = z.infer<typeof claimInviteBodySchema>;\n\n// ─── Mutations ───────────────────────────────────────────────────────────────\n\nexport const setMemberStatusBodySchema = z.object({ active: z.boolean() });\nexport type SetMemberStatusBody = z.infer<typeof setMemberStatusBodySchema>;\n\nexport const assignTrainerBodySchema = z.object({\n trainerId: objectIdSchema.nullable(),\n});\nexport type AssignTrainerBody = z.infer<typeof assignTrainerBodySchema>;\n\nexport const assignWorkoutPlanBodySchema = z.object({\n planId: objectIdSchema.nullable(),\n});\nexport type AssignWorkoutPlanBody = z.infer<typeof assignWorkoutPlanBodySchema>;\n\n/** Remove a member from the gym — echoes the member code to confirm. */\nexport const deleteMemberBodySchema = z.object({\n confirmationCode: z.string().trim().min(1),\n});\nexport type DeleteMemberBody = z.infer<typeof deleteMemberBodySchema>;\n"]}
|
package/dist/membership.d.ts
CHANGED
|
@@ -98,6 +98,50 @@ export declare const assignMembershipBodySchema: z.ZodObject<{
|
|
|
98
98
|
}, z.core.$strip>>;
|
|
99
99
|
}, z.core.$strip>;
|
|
100
100
|
export type AssignMembershipBody = z.infer<typeof assignMembershipBodySchema>;
|
|
101
|
+
/**
|
|
102
|
+
* The member attaching their transfer screenshot to a request already open.
|
|
103
|
+
*
|
|
104
|
+
* Separate from `assignMembershipBodySchema.paymentProofUrl`, which attaches
|
|
105
|
+
* one AT request time, because the two answer different moments and only one of
|
|
106
|
+
* them is the common case. A member almost never has the screenshot at the
|
|
107
|
+
* instant they pick a plan: they choose the plan, go and pay, and come back.
|
|
108
|
+
* Worse, a plan can be requested by somebody who cannot attach anything at all
|
|
109
|
+
* — the owner accepting a join request opens a pending membership on the
|
|
110
|
+
* member's behalf, and that member's first sight of it is a fee they are asked
|
|
111
|
+
* to prove they have paid.
|
|
112
|
+
*
|
|
113
|
+
* So the proof is a follow-up act on an existing request rather than a field on
|
|
114
|
+
* the request itself, and it is the only way the member's own screens offer it.
|
|
115
|
+
*
|
|
116
|
+
* URL, not bytes: the file goes straight to storage from the browser and only
|
|
117
|
+
* its address is sent here. The server still refuses any address that is not
|
|
118
|
+
* ours — see `ERROR_MESSAGE.paymentProofInvalid`.
|
|
119
|
+
*/
|
|
120
|
+
export declare const attachPaymentProofBodySchema: z.ZodObject<{
|
|
121
|
+
paymentProofUrl: z.ZodString;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
export type AttachPaymentProofBody = z.infer<typeof attachPaymentProofBodySchema>;
|
|
124
|
+
/**
|
|
125
|
+
* What the member is told about their screenshot while the gym has not yet
|
|
126
|
+
* marked the payment done.
|
|
127
|
+
*
|
|
128
|
+
* Here rather than in the web client because these two sentences ARE the rule,
|
|
129
|
+
* not decoration on it: which one shows is decided purely by whether
|
|
130
|
+
* `paymentProofUrl` is set on a pending membership, and every surface that asks
|
|
131
|
+
* that question has to answer it with the same words. Two of them already do
|
|
132
|
+
* (Manage Membership and the request-sent screen), and they had drifted before
|
|
133
|
+
* — one said "No screenshot attached. Show your gym the payment when you next
|
|
134
|
+
* visit." while the other offered an upload box.
|
|
135
|
+
*
|
|
136
|
+
* There is deliberately NO third entry for "the gym marked it done". That state
|
|
137
|
+
* shows nothing at all, and a string here would invite somebody to render it.
|
|
138
|
+
*/
|
|
139
|
+
export declare const PAYMENT_PROOF_PROMPT: {
|
|
140
|
+
/** Nothing attached yet, and the gym is still waiting on the money. */
|
|
141
|
+
readonly none: "Have you paid the membership fees? If yes, please upload the screenshot. Your fees are not marked as paid by the gym owner yet.";
|
|
142
|
+
/** Attached, and still not confirmed. The next move belongs to the gym. */
|
|
143
|
+
readonly attached: "You have already uploaded the fees screenshot, but it is not marked as paid yet. Please ask your gym owner.";
|
|
144
|
+
};
|
|
101
145
|
/**
|
|
102
146
|
* The gym marking a pending membership's payment as done, which is the single
|
|
103
147
|
* act that activates it.
|
package/dist/membership.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"membership.d.ts","sourceRoot":"","sources":["../src/membership.ts"],"names":[],"mappings":"AAA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C,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,6DAA6D;AAC7D,eAAO,MAAM,iCAAiC;;iBAE5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAI5F,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"}
|
package/dist/membership.js
CHANGED
|
@@ -125,6 +125,50 @@ export const assignMembershipBodySchema = z.object({
|
|
|
125
125
|
})
|
|
126
126
|
.optional(),
|
|
127
127
|
});
|
|
128
|
+
// ——— Attach the screenshot AFTER the request ——————————————
|
|
129
|
+
/**
|
|
130
|
+
* The member attaching their transfer screenshot to a request already open.
|
|
131
|
+
*
|
|
132
|
+
* Separate from `assignMembershipBodySchema.paymentProofUrl`, which attaches
|
|
133
|
+
* one AT request time, because the two answer different moments and only one of
|
|
134
|
+
* them is the common case. A member almost never has the screenshot at the
|
|
135
|
+
* instant they pick a plan: they choose the plan, go and pay, and come back.
|
|
136
|
+
* Worse, a plan can be requested by somebody who cannot attach anything at all
|
|
137
|
+
* — the owner accepting a join request opens a pending membership on the
|
|
138
|
+
* member's behalf, and that member's first sight of it is a fee they are asked
|
|
139
|
+
* to prove they have paid.
|
|
140
|
+
*
|
|
141
|
+
* So the proof is a follow-up act on an existing request rather than a field on
|
|
142
|
+
* the request itself, and it is the only way the member's own screens offer it.
|
|
143
|
+
*
|
|
144
|
+
* URL, not bytes: the file goes straight to storage from the browser and only
|
|
145
|
+
* its address is sent here. The server still refuses any address that is not
|
|
146
|
+
* ours — see `ERROR_MESSAGE.paymentProofInvalid`.
|
|
147
|
+
*/
|
|
148
|
+
export const attachPaymentProofBodySchema = z.object({
|
|
149
|
+
paymentProofUrl: z.string().trim().min(1).max(2000),
|
|
150
|
+
});
|
|
151
|
+
/**
|
|
152
|
+
* What the member is told about their screenshot while the gym has not yet
|
|
153
|
+
* marked the payment done.
|
|
154
|
+
*
|
|
155
|
+
* Here rather than in the web client because these two sentences ARE the rule,
|
|
156
|
+
* not decoration on it: which one shows is decided purely by whether
|
|
157
|
+
* `paymentProofUrl` is set on a pending membership, and every surface that asks
|
|
158
|
+
* that question has to answer it with the same words. Two of them already do
|
|
159
|
+
* (Manage Membership and the request-sent screen), and they had drifted before
|
|
160
|
+
* — one said "No screenshot attached. Show your gym the payment when you next
|
|
161
|
+
* visit." while the other offered an upload box.
|
|
162
|
+
*
|
|
163
|
+
* There is deliberately NO third entry for "the gym marked it done". That state
|
|
164
|
+
* shows nothing at all, and a string here would invite somebody to render it.
|
|
165
|
+
*/
|
|
166
|
+
export const PAYMENT_PROOF_PROMPT = {
|
|
167
|
+
/** Nothing attached yet, and the gym is still waiting on the money. */
|
|
168
|
+
none: 'Have you paid the membership fees? If yes, please upload the screenshot. Your fees are not marked as paid by the gym owner yet.',
|
|
169
|
+
/** Attached, and still not confirmed. The next move belongs to the gym. */
|
|
170
|
+
attached: 'You have already uploaded the fees screenshot, but it is not marked as paid yet. Please ask your gym owner.',
|
|
171
|
+
};
|
|
128
172
|
// ——— Confirm / reject the payment ————————————————————————
|
|
129
173
|
/**
|
|
130
174
|
* The gym marking a pending membership's payment as done, which is the single
|
package/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CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,QAAQ,EAAE,mBAAmB;IAC7B,UAAU,EAAE,aAAa,CAAC,QAAQ,EAAE;IACpC,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE;CACnC,CAAC;KACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE;IACtE,OAAO,EAAE,uBAAuB;IAChC,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC,CAAC;AAGL,gFAAgF;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';\n\n/*\n * Membership STATUS moved to its own module — see `membership-status.ts` for\n * why. Re-exported here so the many call sites that reach for the stored enum\n * alongside the membership DTO do not all have to change import paths, and so\n * there is still exactly one definition behind both spellings.\n */\nexport {\n effectiveMembershipStatus,\n isMembershipLive,\n type MembershipStatus,\n membershipStatusSchema,\n} from './membership-status.js';\n\nimport {\n isoDateSchema,\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n priceInrSchema,\n} from './common.js';\nimport { membershipStatusSchema } from './membership-status.js';\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 /**\n * The enrolment this plan was sold against.\n *\n * The link that makes a plan belong to a stint at a gym rather than to a\n * person. It replaces a `(centerId, memberCode)` pair that had to be matched\n * by hand in three places, and it is what lets a plan be sold to somebody the\n * desk has only just written down — an enrolment exists from that moment,\n * whereas an account may not exist for weeks.\n */\n enrolmentId: objectIdSchema,\n /**\n * The account, denormalised from the enrolment for member-facing queries.\n * NULL until they claim, for the same reason it is null on the enrolment.\n */\n userId: objectIdSchema.nullable(),\n centerId: objectIdSchema,\n planId: objectIdSchema,\n planName: z.string(),\n /**\n * Which variant of the plan was bought, and how it read at the time.\n *\n * A plain string, not a fixed tenure enum: variant ids are minted per plan\n * now, so a gym can sell a 10-day pass. The LABEL is a snapshot for the same\n * reason a payment records what it was for — the owner may rename or delete\n * the variant later, and a membership must still be able to say what was\n * sold.\n */\n variantId: z.string(),\n variantLabel: z.string(),\n priceInr: priceInrSchema,\n status: membershipStatusSchema,\n /**\n * The term, PROVISIONAL while the membership is pending.\n *\n * Dated from the member's JOINING DATE, not from the day either party\n * pressed a button. Terms are a cycle — somebody who joined on the 4th runs\n * 4 Jul→4 Aug, 4 Aug→4 Sep — so a gym confirming a week late records the\n * month that was owed rather than starting a fresh one from today. Dating\n * them from the confirmation, which is what this used to do, walked every\n * member's renewal day forward by however long the desk took to look.\n *\n * Written at request time so every screen that reads them keeps working, and\n * recomputed on confirmation in case the cycle moved in between.\n */\n startDate: isoDateSchema,\n endDate: isoDateSchema,\n pausedFrom: isoDateSchema.nullable(),\n pausedTo: isoDateSchema.nullable(),\n /**\n * The screenshot the member attached, if they attached one.\n *\n * Optional on purpose. A member paying cash at the desk has nothing to\n * screenshot, and refusing to accept their request until they produce one\n * would lock the commonest case out of the flow entirely.\n */\n paymentProofUrl: z.string().nullable(),\n /** When the plan was chosen. Distinct from `createdAt` only in intent. */\n requestedAt: isoDateTimeSchema,\n /** When the gym marked the payment done or turned it down. */\n decidedAt: isoDateTimeSchema.nullable(),\n /** Who decided. Null while pending. */\n decidedBy: objectIdSchema.nullable(),\n /** Why it was turned down, in the gym's words. */\n decisionNote: z.string().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 variantId: z.string().trim().min(1),\n /** Explicit start; defaults to today server-side when omitted. */\n startDate: isoDateSchema.optional(),\n /**\n * A screenshot of the transfer, uploaded to storage first and passed as its\n * URL. Optional — see `paymentProofUrl` on the entity.\n */\n paymentProofUrl: z.string().trim().max(2000).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// ——— Confirm / reject the payment ————————————————————————\n\n/**\n * The gym marking a pending membership's payment as done, which is the single\n * act that activates it.\n *\n * It carries the LEDGER entry rather than being a bare approval, because those\n * are the same event: the owner is asserting that this much money arrived by\n * this route. Splitting them would let a membership go live with nothing\n * written down, which is exactly the hole this feature exists to close.\n *\n * The amount is not forced to equal the plan price. A gym that takes half now\n * and half on Friday still wants the member training, and the balance is\n * already tracked against the term.\n */\nexport const confirmMembershipPaymentBodySchema = z.object({\n amountInr: priceInrSchema,\n method: paymentMethodSchema,\n note: optionalTrimmedString(240),\n /**\n * The term the owner BELIEVES they are paying for, echoed back from what the\n * screen showed them.\n *\n * The server derives the term itself and never trusts this as input — it is\n * a guard, not a parameter. The owner is told \"this covers 3 Jul to 3 Aug\"\n * and then presses a button; if a second manager confirms a term in the\n * seconds between, the derived term moves on and this one no longer matches.\n * Without the echo that owner silently pays for a DIFFERENT month than the\n * one they read, and the gym's ledger disagrees with the conversation that\n * produced it. Optional so a client that shows no term still works.\n */\n expectedTermStart: isoDateSchema.optional(),\n});\nexport type ConfirmMembershipPaymentBody = z.infer<typeof confirmMembershipPaymentBodySchema>;\n\n/**\n * One billing term, dated from the member's JOINING DATE.\n *\n * Terms are a derived cycle, not free-form dates the desk types in: a member\n * who joined on the 4th is billed 4 Jul→4 Aug, 4 Aug→4 Sep, and so on, each\n * one the length of the variant they bought. Nobody picks a start date,\n * because every gym already answers \"which month is this for?\" the same way,\n * and letting two people type it produces two answers.\n *\n * `isOverdue` is the term having already ended — the owner marking a month\n * they forgot at the time. That is a normal, expected act rather than an\n * error, so it is surfaced as a fact about the term rather than a warning.\n */\nexport const membershipTermSchema = z.object({\n startDate: isoDateSchema,\n endDate: isoDateSchema,\n isOverdue: z.boolean(),\n});\nexport type MembershipTerm = z.infer<typeof membershipTermSchema>;\n\n/**\n * One row of the gym's confirmation queue.\n *\n * The membership plus just enough of the person to act on it. The owner is\n * deciding about a HUMAN — \"did Ravi's transfer land\" — and a list of plan\n * names and amounts with no names attached is not something anybody can\n * answer. Kept to four fields rather than embedding the whole roster row,\n * because this list is read on every visit to the members screen.\n */\nexport const pendingMembershipRowSchema = z.object({\n membership: membershipSchema,\n member: z.object({\n enrolmentId: objectIdSchema,\n gymMemberCode: z.string(),\n name: z.string(),\n avatarUrl: z.string().nullable(),\n }),\n});\nexport type PendingMembershipRow = z.infer<typeof pendingMembershipRowSchema>;\n\n/** Turning a request down. The reason reaches the member. */\nexport const rejectMembershipPaymentBodySchema = z.object({\n reason: optionalTrimmedString(240),\n});\nexport type RejectMembershipPaymentBody = z.infer<typeof rejectMembershipPaymentBodySchema>;\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"]}
|
|
1
|
+
{"version":3,"file":"membership.js","sourceRoot":"","sources":["../src/membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;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,MAAM,EAAE,qBAAqB,CAAC,GAAG,CAAC;CACnC,CAAC,CAAC;AAGH,gFAAgF;AAEhF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;AAGxE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,QAAQ,EAAE,mBAAmB;IAC7B,UAAU,EAAE,aAAa,CAAC,QAAQ,EAAE;IACpC,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE;CACnC,CAAC;KACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE;IACtE,OAAO,EAAE,uBAAuB;IAChC,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC,CAAC;AAGL,gFAAgF;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';\n\n/*\n * Membership STATUS moved to its own module — see `membership-status.ts` for\n * why. Re-exported here so the many call sites that reach for the stored enum\n * alongside the membership DTO do not all have to change import paths, and so\n * there is still exactly one definition behind both spellings.\n */\nexport {\n effectiveMembershipStatus,\n isMembershipLive,\n type MembershipStatus,\n membershipStatusSchema,\n} from './membership-status.js';\n\nimport {\n isoDateSchema,\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n priceInrSchema,\n} from './common.js';\nimport { membershipStatusSchema } from './membership-status.js';\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 /**\n * The enrolment this plan was sold against.\n *\n * The link that makes a plan belong to a stint at a gym rather than to a\n * person. It replaces a `(centerId, memberCode)` pair that had to be matched\n * by hand in three places, and it is what lets a plan be sold to somebody the\n * desk has only just written down — an enrolment exists from that moment,\n * whereas an account may not exist for weeks.\n */\n enrolmentId: objectIdSchema,\n /**\n * The account, denormalised from the enrolment for member-facing queries.\n * NULL until they claim, for the same reason it is null on the enrolment.\n */\n userId: objectIdSchema.nullable(),\n centerId: objectIdSchema,\n planId: objectIdSchema,\n planName: z.string(),\n /**\n * Which variant of the plan was bought, and how it read at the time.\n *\n * A plain string, not a fixed tenure enum: variant ids are minted per plan\n * now, so a gym can sell a 10-day pass. The LABEL is a snapshot for the same\n * reason a payment records what it was for — the owner may rename or delete\n * the variant later, and a membership must still be able to say what was\n * sold.\n */\n variantId: z.string(),\n variantLabel: z.string(),\n priceInr: priceInrSchema,\n status: membershipStatusSchema,\n /**\n * The term, PROVISIONAL while the membership is pending.\n *\n * Dated from the member's JOINING DATE, not from the day either party\n * pressed a button. Terms are a cycle — somebody who joined on the 4th runs\n * 4 Jul→4 Aug, 4 Aug→4 Sep — so a gym confirming a week late records the\n * month that was owed rather than starting a fresh one from today. Dating\n * them from the confirmation, which is what this used to do, walked every\n * member's renewal day forward by however long the desk took to look.\n *\n * Written at request time so every screen that reads them keeps working, and\n * recomputed on confirmation in case the cycle moved in between.\n */\n startDate: isoDateSchema,\n endDate: isoDateSchema,\n pausedFrom: isoDateSchema.nullable(),\n pausedTo: isoDateSchema.nullable(),\n /**\n * The screenshot the member attached, if they attached one.\n *\n * Optional on purpose. A member paying cash at the desk has nothing to\n * screenshot, and refusing to accept their request until they produce one\n * would lock the commonest case out of the flow entirely.\n */\n paymentProofUrl: z.string().nullable(),\n /** When the plan was chosen. Distinct from `createdAt` only in intent. */\n requestedAt: isoDateTimeSchema,\n /** When the gym marked the payment done or turned it down. */\n decidedAt: isoDateTimeSchema.nullable(),\n /** Who decided. Null while pending. */\n decidedBy: objectIdSchema.nullable(),\n /** Why it was turned down, in the gym's words. */\n decisionNote: z.string().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 variantId: z.string().trim().min(1),\n /** Explicit start; defaults to today server-side when omitted. */\n startDate: isoDateSchema.optional(),\n /**\n * A screenshot of the transfer, uploaded to storage first and passed as its\n * URL. Optional — see `paymentProofUrl` on the entity.\n */\n paymentProofUrl: z.string().trim().max(2000).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// ——— Attach the screenshot AFTER the request ——————————————\n\n/**\n * The member attaching their transfer screenshot to a request already open.\n *\n * Separate from `assignMembershipBodySchema.paymentProofUrl`, which attaches\n * one AT request time, because the two answer different moments and only one of\n * them is the common case. A member almost never has the screenshot at the\n * instant they pick a plan: they choose the plan, go and pay, and come back.\n * Worse, a plan can be requested by somebody who cannot attach anything at all\n * — the owner accepting a join request opens a pending membership on the\n * member's behalf, and that member's first sight of it is a fee they are asked\n * to prove they have paid.\n *\n * So the proof is a follow-up act on an existing request rather than a field on\n * the request itself, and it is the only way the member's own screens offer it.\n *\n * URL, not bytes: the file goes straight to storage from the browser and only\n * its address is sent here. The server still refuses any address that is not\n * ours — see `ERROR_MESSAGE.paymentProofInvalid`.\n */\nexport const attachPaymentProofBodySchema = z.object({\n paymentProofUrl: z.string().trim().min(1).max(2000),\n});\nexport type AttachPaymentProofBody = z.infer<typeof attachPaymentProofBodySchema>;\n\n/**\n * What the member is told about their screenshot while the gym has not yet\n * marked the payment done.\n *\n * Here rather than in the web client because these two sentences ARE the rule,\n * not decoration on it: which one shows is decided purely by whether\n * `paymentProofUrl` is set on a pending membership, and every surface that asks\n * that question has to answer it with the same words. Two of them already do\n * (Manage Membership and the request-sent screen), and they had drifted before\n * — one said \"No screenshot attached. Show your gym the payment when you next\n * visit.\" while the other offered an upload box.\n *\n * There is deliberately NO third entry for \"the gym marked it done\". That state\n * shows nothing at all, and a string here would invite somebody to render it.\n */\nexport const PAYMENT_PROOF_PROMPT = {\n /** Nothing attached yet, and the gym is still waiting on the money. */\n none: 'Have you paid the membership fees? If yes, please upload the screenshot. Your fees are not marked as paid by the gym owner yet.',\n /** Attached, and still not confirmed. The next move belongs to the gym. */\n attached:\n 'You have already uploaded the fees screenshot, but it is not marked as paid yet. Please ask your gym owner.',\n} as const;\n\n// ——— Confirm / reject the payment ————————————————————————\n\n/**\n * The gym marking a pending membership's payment as done, which is the single\n * act that activates it.\n *\n * It carries the LEDGER entry rather than being a bare approval, because those\n * are the same event: the owner is asserting that this much money arrived by\n * this route. Splitting them would let a membership go live with nothing\n * written down, which is exactly the hole this feature exists to close.\n *\n * The amount is not forced to equal the plan price. A gym that takes half now\n * and half on Friday still wants the member training, and the balance is\n * already tracked against the term.\n */\nexport const confirmMembershipPaymentBodySchema = z.object({\n amountInr: priceInrSchema,\n method: paymentMethodSchema,\n note: optionalTrimmedString(240),\n /**\n * The term the owner BELIEVES they are paying for, echoed back from what the\n * screen showed them.\n *\n * The server derives the term itself and never trusts this as input — it is\n * a guard, not a parameter. The owner is told \"this covers 3 Jul to 3 Aug\"\n * and then presses a button; if a second manager confirms a term in the\n * seconds between, the derived term moves on and this one no longer matches.\n * Without the echo that owner silently pays for a DIFFERENT month than the\n * one they read, and the gym's ledger disagrees with the conversation that\n * produced it. Optional so a client that shows no term still works.\n */\n expectedTermStart: isoDateSchema.optional(),\n});\nexport type ConfirmMembershipPaymentBody = z.infer<typeof confirmMembershipPaymentBodySchema>;\n\n/**\n * One billing term, dated from the member's JOINING DATE.\n *\n * Terms are a derived cycle, not free-form dates the desk types in: a member\n * who joined on the 4th is billed 4 Jul→4 Aug, 4 Aug→4 Sep, and so on, each\n * one the length of the variant they bought. Nobody picks a start date,\n * because every gym already answers \"which month is this for?\" the same way,\n * and letting two people type it produces two answers.\n *\n * `isOverdue` is the term having already ended — the owner marking a month\n * they forgot at the time. That is a normal, expected act rather than an\n * error, so it is surfaced as a fact about the term rather than a warning.\n */\nexport const membershipTermSchema = z.object({\n startDate: isoDateSchema,\n endDate: isoDateSchema,\n isOverdue: z.boolean(),\n});\nexport type MembershipTerm = z.infer<typeof membershipTermSchema>;\n\n/**\n * One row of the gym's confirmation queue.\n *\n * The membership plus just enough of the person to act on it. The owner is\n * deciding about a HUMAN — \"did Ravi's transfer land\" — and a list of plan\n * names and amounts with no names attached is not something anybody can\n * answer. Kept to four fields rather than embedding the whole roster row,\n * because this list is read on every visit to the members screen.\n */\nexport const pendingMembershipRowSchema = z.object({\n membership: membershipSchema,\n member: z.object({\n enrolmentId: objectIdSchema,\n gymMemberCode: z.string(),\n name: z.string(),\n avatarUrl: z.string().nullable(),\n }),\n});\nexport type PendingMembershipRow = z.infer<typeof pendingMembershipRowSchema>;\n\n/** Turning a request down. The reason reaches the member. */\nexport const rejectMembershipPaymentBodySchema = z.object({\n reason: optionalTrimmedString(240),\n});\nexport type RejectMembershipPaymentBody = z.infer<typeof rejectMembershipPaymentBodySchema>;\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"]}
|
package/dist/messages.d.ts
CHANGED
|
@@ -134,6 +134,32 @@ export declare const SUCCESS_MESSAGE: {
|
|
|
134
134
|
readonly workoutPlanAssigned: {
|
|
135
135
|
readonly title: "Workout plan assigned";
|
|
136
136
|
};
|
|
137
|
+
readonly dietChartCreated: {
|
|
138
|
+
readonly title: "Diet chart created";
|
|
139
|
+
};
|
|
140
|
+
readonly dietChartUpdated: {
|
|
141
|
+
readonly title: "Diet chart saved";
|
|
142
|
+
};
|
|
143
|
+
readonly dietChartDeleted: {
|
|
144
|
+
readonly title: "Diet chart deleted";
|
|
145
|
+
readonly description: "Members on this chart no longer have one.";
|
|
146
|
+
};
|
|
147
|
+
readonly dietChartAssigned: {
|
|
148
|
+
readonly title: "Diet chart assigned";
|
|
149
|
+
};
|
|
150
|
+
readonly dietChartCleared: {
|
|
151
|
+
readonly title: "Diet chart removed";
|
|
152
|
+
};
|
|
153
|
+
readonly foodCreated: {
|
|
154
|
+
readonly title: "Food added";
|
|
155
|
+
};
|
|
156
|
+
readonly foodUpdated: {
|
|
157
|
+
readonly title: "Food saved";
|
|
158
|
+
};
|
|
159
|
+
readonly foodDeleted: {
|
|
160
|
+
readonly title: "Food removed";
|
|
161
|
+
readonly description: "It no longer appears in any chart that used it.";
|
|
162
|
+
};
|
|
137
163
|
readonly attendanceMarked: {
|
|
138
164
|
readonly title: "Attendance saved";
|
|
139
165
|
};
|
|
@@ -197,6 +223,16 @@ export declare const SUCCESS_MESSAGE: {
|
|
|
197
223
|
readonly title: "Request withdrawn";
|
|
198
224
|
readonly description: "Pick another plan whenever you are ready.";
|
|
199
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* Says the gym can SEE it, not that the plan has started. The member has just
|
|
228
|
+
* done the only thing left to them and the temptation is to congratulate them
|
|
229
|
+
* with something that sounds like confirmation; the next move is still the
|
|
230
|
+
* gym's, and the screen they are looking at says so.
|
|
231
|
+
*/
|
|
232
|
+
readonly membershipProofAttached: {
|
|
233
|
+
readonly title: "Screenshot sent";
|
|
234
|
+
readonly description: "Your gym can see it now.";
|
|
235
|
+
};
|
|
200
236
|
readonly membershipPaymentConfirmed: {
|
|
201
237
|
readonly title: "Payment confirmed";
|
|
202
238
|
readonly description: "The plan is now active for this member.";
|
|
@@ -420,6 +456,8 @@ export declare const ERROR_MESSAGE: {
|
|
|
420
456
|
readonly membershipWithdrawFailed: "Could not withdraw that request. Please try again.";
|
|
421
457
|
/** The URL did not come from our own storage — a broken or hostile client. */
|
|
422
458
|
readonly paymentProofInvalid: "That payment screenshot could not be attached. Upload it again.";
|
|
459
|
+
/** The upload itself worked; saving it against the request did not. */
|
|
460
|
+
readonly paymentProofAttachFailed: "Could not send that screenshot. Please try again.";
|
|
423
461
|
readonly workoutPlanRequired: "Choose a plan to assign";
|
|
424
462
|
readonly attendanceMarkFailed: "Could not save that attendance. Please try again.";
|
|
425
463
|
readonly memberStatusFailed: "Could not change that member's status. Please try again.";
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;IAsBrB;;;;;;;;;;;;;OAaG;;;CAKK,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAIrE,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAID;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;IAU1B,sEAAsE
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;IAsBrB;;;;;;;;;;;;;OAaG;;;CAK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AIG;;IAGH;;;;OAIG;;IAEH;;;;;OAKG;;IAGH;;;OAGG;;IAGH,mEAAmE;;;;;IAKnE,8EAA8E;;IAE9E,uEAAuE;;;;;;;;;;;;;IAgBvE;;;OAGG;;;;IAMH,wEAAwE;;IAExE,uEAAuE;;IAEvE,yEAAyE;;IAEzE,8EAA8E;;IAE9E,0DAA0D;;;IAG1D;;;;OAIG;;IAIH,4EAA4E;;IAG5E,6DAA6D;;IAE7D,kDAAkD;;IAElD,+DAA+D;;IAE/D,sEAAsE;;;IAItE,kEAAkE;;;;IAIlE,uEAAuE;;IAEvE,8EAA8E;;;IAI9E;;;;;;;;;;;;;OAaG;;;;;IAMH;;;;;;OAMG;;;;;;;;;;;;CAkBsC,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,aAAa,CAAC;AAEzD,iDAAiD;AACjD,eAAO,MAAM,iBAAiB;8BACX,MAAM,KAAG,MAAM;IAChC;;;;;;;;OAQG;gDACgC,MAAM,KAAG,MAAM;IAElD,2DAA2D;sCAClC,MAAM,KAAG,MAAM;CAEhC,CAAC"}
|
package/dist/messages.js
CHANGED
|
@@ -105,6 +105,21 @@ export const SUCCESS_MESSAGE = {
|
|
|
105
105
|
workoutUpdated: { title: 'Workout saved' },
|
|
106
106
|
workoutDeleted: { title: 'Workout removed' },
|
|
107
107
|
workoutPlanAssigned: { title: 'Workout plan assigned' },
|
|
108
|
+
// Diet — the counterparts of the training messages above.
|
|
109
|
+
dietChartCreated: { title: 'Diet chart created' },
|
|
110
|
+
dietChartUpdated: { title: 'Diet chart saved' },
|
|
111
|
+
dietChartDeleted: {
|
|
112
|
+
title: 'Diet chart deleted',
|
|
113
|
+
description: 'Members on this chart no longer have one.',
|
|
114
|
+
},
|
|
115
|
+
dietChartAssigned: { title: 'Diet chart assigned' },
|
|
116
|
+
dietChartCleared: { title: 'Diet chart removed' },
|
|
117
|
+
foodCreated: { title: 'Food added' },
|
|
118
|
+
foodUpdated: { title: 'Food saved' },
|
|
119
|
+
foodDeleted: {
|
|
120
|
+
title: 'Food removed',
|
|
121
|
+
description: 'It no longer appears in any chart that used it.',
|
|
122
|
+
},
|
|
108
123
|
// Roster (owner console)
|
|
109
124
|
attendanceMarked: { title: 'Attendance saved' },
|
|
110
125
|
memberMarkedInactive: {
|
|
@@ -154,6 +169,16 @@ export const SUCCESS_MESSAGE = {
|
|
|
154
169
|
title: 'Request withdrawn',
|
|
155
170
|
description: 'Pick another plan whenever you are ready.',
|
|
156
171
|
},
|
|
172
|
+
/**
|
|
173
|
+
* Says the gym can SEE it, not that the plan has started. The member has just
|
|
174
|
+
* done the only thing left to them and the temptation is to congratulate them
|
|
175
|
+
* with something that sounds like confirmation; the next move is still the
|
|
176
|
+
* gym's, and the screen they are looking at says so.
|
|
177
|
+
*/
|
|
178
|
+
membershipProofAttached: {
|
|
179
|
+
title: 'Screenshot sent',
|
|
180
|
+
description: 'Your gym can see it now.',
|
|
181
|
+
},
|
|
157
182
|
membershipPaymentConfirmed: {
|
|
158
183
|
title: 'Payment confirmed',
|
|
159
184
|
description: 'The plan is now active for this member.',
|
|
@@ -383,6 +408,8 @@ export const ERROR_MESSAGE = {
|
|
|
383
408
|
membershipWithdrawFailed: 'Could not withdraw that request. Please try again.',
|
|
384
409
|
/** The URL did not come from our own storage — a broken or hostile client. */
|
|
385
410
|
paymentProofInvalid: 'That payment screenshot could not be attached. Upload it again.',
|
|
411
|
+
/** The upload itself worked; saving it against the request did not. */
|
|
412
|
+
paymentProofAttachFailed: 'Could not send that screenshot. Please try again.',
|
|
386
413
|
// Training
|
|
387
414
|
workoutPlanRequired: 'Choose a plan to assign',
|
|
388
415
|
// Roster (owner console)
|
package/dist/messages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,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IAC/E,yBAAyB,EAAE,qCAAqC;IAChE,kEAAkE;IAClE,+BAA+B,EAAE,4CAA4C;IAC7E,uBAAuB,EAAE,gDAAgD;IACzE,cAAc,EAAE,oDAAoD;IACpE,uEAAuE;IACvE,WAAW,EAAE,sDAAsD;IACnE,8EAA8E;IAC9E,sBAAsB,EAAE,sCAAsC;IAC9D,kBAAkB,EAAE,6DAA6D;IAEjF;;;;;;;;;;;;;OAaG;IACH,YAAY,EACV,4FAA4F;IAC9F,iBAAiB,EAAE,oEAAoE;IACvF,cAAc,EAAE,6CAA6C;IAC7D,YAAY,EAAE,gEAAgE;IAC9E;;;;;;OAMG;IACH,cAAc,EAAE,sEAAsE;IAEtF,aAAa;IACb,sBAAsB,EAAE,yCAAyC;IACjE,sBAAsB,EAAE,oCAAoC;IAE5D,6BAA6B;IAC7B,aAAa,EAAE,gBAAgB;IAC/B,gBAAgB,EAAE,6BAA6B;IAC/C,aAAa,EAAE,mCAAmC;IAClD,YAAY,EAAE,gCAAgC;IAC9C,mBAAmB,EAAE,0CAA0C;IAC/D,eAAe,EAAE,qCAAqC;IAEtD,UAAU;IACV,iBAAiB,EAAE,gDAAgD;IACnE,kBAAkB,EAAE,iDAAiD;CAC5B,CAAC;AAI5C,iDAAiD;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,CAAC,GAAW,EAAU,EAAE,CAAC,qBAAqB,GAAG,SAAS;IACrE;;;;;;;;OAQG;IACH,qBAAqB,EAAE,CAAC,SAAiB,EAAU,EAAE,CACnD,mCAAmC,SAAS,yCAAyC;IACvF,2DAA2D;IAC3D,aAAa,EAAE,CAAC,OAAe,EAAU,EAAE,CACzC,mCAAmC,OAAO,UAAU,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG;CACvE,CAAC","sourcesContent":["/**\n * gymmonk-schema — API result messages\n * ====================================\n * Single source of truth for every user-facing SUCCESS and ERROR message the\n * product shows, plus the API error codes both sides key off.\n *\n * Why it lives here: the schema package is already the SSOT for data shapes,\n * types and validation. Result copy is part of that contract — the backend\n * raises a message, the client shows it, and neither should invent its own\n * wording. Both repos import from here, so copy changes land in one place and\n * can never drift between server and client.\n *\n * Usage:\n * backend → `throw new BadRequestError(ERROR_MESSAGE.centerAddressRequired)`\n * frontend → `showSuccess(...toast(SUCCESS_MESSAGE.profileUpdated))`\n *\n * @module gymmonk-schema/messages\n */\n\n// ─── API error codes ─────────────────────────────────────────────────────────\n\n/**\n * Machine-readable error codes returned in the API envelope\n * (`{ success: false, error: { code, message } }`). The client can branch on a\n * code; the message is what a human reads.\n */\nexport const ERROR_CODE = {\n // General\n INTERNAL_ERROR: 'INTERNAL_ERROR',\n VALIDATION_ERROR: 'VALIDATION_ERROR',\n NOT_FOUND: 'NOT_FOUND',\n\n // Auth\n INVALID_TOKEN: 'INVALID_TOKEN',\n TOKEN_EXPIRED: 'TOKEN_EXPIRED',\n UNAUTHORIZED: 'UNAUTHORIZED',\n FORBIDDEN: 'FORBIDDEN',\n SESSION_INVALIDATED: 'SESSION_INVALIDATED',\n\n // User\n USER_NOT_FOUND: 'USER_NOT_FOUND',\n USER_ALREADY_EXISTS: 'USER_ALREADY_EXISTS',\n INVALID_ROLE: 'INVALID_ROLE',\n\n // Rate limiting\n RATE_LIMITED: 'RATE_LIMITED',\n RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',\n\n /**\n * The caller MAY do this — their subscription simply does not stretch to it.\n *\n * Deliberately NOT `FORBIDDEN`, and the distinction is load-bearing on the\n * client. A role denial means \"this is not yours\"; the answer is to go away.\n * A plan denial means \"this costs money\"; the answer is an upgrade prompt with\n * the price on it. A client that cannot tell them apart either shows an\n * upgrade sheet to a trainer who will never be allowed to buy one, or shows a\n * bare 403 to an owner who would happily have paid.\n *\n * Always accompanied by `details`: `{ feature, currentPlan, requiredPlan,\n * current?, limit? }` — enough for the prompt to name the feature, the tier\n * that unlocks it, and how full the current allowance is.\n */\n PLAN_LIMIT_EXCEEDED: 'PLAN_LIMIT_EXCEEDED',\n\n // Upstream / dependency unavailable\n SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE',\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODE)[keyof typeof ERROR_CODE];\n\n// ─── Message shape ───────────────────────────────────────────────────────────\n\n/** A result message: a headline and an optional quieter second line. */\nexport interface ResultMessage {\n title: string;\n description?: string;\n}\n\n// ─── Success messages ────────────────────────────────────────────────────────\n\n/**\n * Confirmation shown after a write succeeds, keyed by action. Interpolating\n * entries are functions so the caller supplies the value without re-wording.\n */\nexport const SUCCESS_MESSAGE = {\n // Onboarding\n memberOnboardingComplete: {\n title: \"You're all set\",\n description: 'Welcome to GymMonk.',\n },\n ownerOnboardingComplete: {\n title: 'Your gym is ready',\n description: 'Welcome to GymMonk.',\n },\n /** Each wizard step is persisted on its own, so each one confirms. */\n onboardingStepSaved: { title: 'Saved' },\n\n // Identity & profile\n profileUpdated: { title: 'Profile updated' },\n organisationUpdated: { title: 'Organisation updated' },\n\n // Gym structure\n centerAdded: { title: 'Center added' },\n centerUpdated: { title: 'Center updated' },\n membershipPlanCreated: { title: 'Membership plan created' },\n membershipPlanUpdated: { title: 'Membership plan updated' },\n equipmentSaved: { title: 'Equipment updated' },\n\n // Membership (member-side)\n membershipUpdated: { title: 'Membership updated' },\n membershipRenewed: { title: 'Membership renewed' },\n membershipCancelled: { title: 'Membership cancelled' },\n membershipPauseRequested: {\n title: 'Pause request sent',\n description: 'Your gym will confirm the pause.',\n },\n\n // Owner SaaS subscription\n subscriptionUpdated: { title: 'Subscription updated' },\n\n // Training\n workoutPlanCreated: { title: 'Workout plan created' },\n workoutPlanUpdated: { title: 'Workout plan saved' },\n workoutPlanDeleted: {\n title: 'Workout plan deleted',\n description: 'Members on this plan no longer have one.',\n },\n workoutCreated: { title: 'Workout created' },\n workoutUpdated: { title: 'Workout saved' },\n workoutDeleted: { title: 'Workout removed' },\n workoutPlanAssigned: { title: 'Workout plan assigned' },\n\n // Roster (owner console)\n attendanceMarked: { title: 'Attendance saved' },\n memberMarkedInactive: {\n title: 'Member marked inactive',\n description: 'They can no longer check in.',\n },\n memberMarkedActive: { title: 'Member reactivated' },\n memberDeleted: { title: 'Member removed' },\n /**\n * Says what actually happened. Assigning a plan no longer starts it —\n * nothing does until the payment is marked done — so a bare \"Plan\n * updated\" would send the owner away believing the member could train.\n */\n memberPlanAssigned: {\n title: 'Plan assigned',\n description: 'It starts once you mark the payment done.',\n },\n memberMembershipPaused: { title: 'Membership paused' },\n memberMembershipCancelled: { title: 'Membership cancelled' },\n paymentCollected: { title: 'Payment recorded' },\n\n // Sessions\n checkedIn: { title: 'Checked in', description: 'Your session has started.' },\n checkedOut: { title: 'Checked out', description: 'Session saved.' },\n checkInQrRotated: {\n title: 'New QR generated',\n description: 'Print it and replace the old poster.',\n },\n\n // Membership join requests\n membershipRequestSent: {\n title: 'Request sent',\n description: 'The gym will review it shortly.',\n },\n membershipRequestApproved: {\n title: 'Member approved',\n description: 'They can now check in at your gym.',\n },\n membershipRequestRejected: {\n title: 'Request declined',\n description: 'The member has been told.',\n },\n\n // Membership payment confirmation\n membershipRequested: {\n title: 'Plan requested',\n description: 'It starts once your gym confirms the payment.',\n },\n membershipRequestWithdrawn: {\n title: 'Request withdrawn',\n description: 'Pick another plan whenever you are ready.',\n },\n membershipPaymentConfirmed: {\n title: 'Payment confirmed',\n description: 'The plan is now active for this member.',\n },\n membershipPaymentRejected: {\n title: 'Payment turned down',\n description: 'The member has been told and can send it again.',\n },\n\n // Gym registration + platform review\n gymRegistered: {\n title: 'Gym submitted',\n description: 'Our team will review it and let you know.',\n },\n gymApproved: {\n title: 'Gym approved',\n description: 'It is now listed for members to find.',\n },\n gymRejected: {\n title: 'Gym rejected',\n description: 'The owner has been told.',\n },\n\n // Engagement\n feedbackSubmitted: {\n title: 'Feedback sent',\n description: 'Thank you for helping us improve.',\n },\n complaintSubmitted: {\n title: 'Complaint submitted',\n description: 'Your gym will look into it.',\n },\n announcementSent: { title: 'Announcement sent' },\n announcementScheduled: { title: 'Announcement scheduled' },\n announcementDraftSaved: { title: 'Draft saved' },\n announcementDeleted: { title: 'Announcement deleted' },\n announcementCancelled: {\n title: 'Announcement cancelled',\n description: 'It will not be sent.',\n },\n\n // Notification feed\n notificationHidden: { title: 'Notification hidden' },\n notificationRestored: { title: 'Notification restored' },\n allNotificationsRead: { title: 'All caught up' },\n\n // Security (role-switch PIN)\n mpinSet: { title: 'PIN set' },\n mpinReset: { title: 'Your PIN has been reset.' },\n mpinResetLinkSent: {\n title: \"We've emailed you a reset link\",\n description: 'Check your inbox.',\n },\n\n // ── Platform console (superadmin / platform manager) ────────────────────────\n platformRolesUpdated: { title: 'Platform roles updated' },\n platformUserSuspended: {\n title: 'Account suspended',\n description: 'They can no longer sign in.',\n },\n platformUserReinstated: { title: 'Account reinstated' },\n platformUserDeleted: {\n title: 'Account deleted',\n description: 'It is hidden everywhere but can still be restored.',\n },\n platformUserRestored: { title: 'Account restored' },\n platformGymDeleted: {\n title: 'Gym deleted',\n description: 'It is hidden everywhere but can still be restored.',\n },\n platformGymRestored: {\n title: 'Gym restored',\n description: 'It is back in the directory and its owner has the console again.',\n },\n} as const satisfies Record<string, ResultMessage>;\n\nexport type SuccessMessageKey = keyof typeof SUCCESS_MESSAGE;\n\n/** Success messages that name the thing they acted on. */\nexport const SUCCESS_MESSAGE_FOR = {\n memberAdded: (name: string): ResultMessage => ({\n title: 'Member added',\n description: `Share the invite with ${name}.`,\n }),\n staffAdded: (name: string): ResultMessage => ({\n title: 'Staff added',\n description: `Share the invite with ${name}.`,\n }),\n inviteClaimed: (gymName: string): ResultMessage => ({\n title: \"You're all set\",\n description: `Your account is linked to ${gymName}.`,\n }),\n roleSwitched: (roleLabel: string): ResultMessage => ({\n title: `Switched to ${roleLabel}`,\n }),\n gymApprovedFor: (gymName: string): ResultMessage => ({\n title: 'Gym approved',\n description: `${gymName} is now live on GymMonk.`,\n }),\n gymRejectedFor: (gymName: string): ResultMessage => ({\n title: 'Gym rejected',\n description: `The owner of ${gymName} has been told why.`,\n }),\n} as const;\n\n// ─── Error messages ──────────────────────────────────────────────────────────\n\n/**\n * Failure copy. Transport entries describe a request that never reached the\n * API; the rest are domain rules the backend enforces and the client can also\n * check up-front — same wording either way.\n */\nexport const ERROR_MESSAGE = {\n // Transport / generic\n generic: 'Something went wrong. Please try again.',\n network: 'Network error. Check your connection and try again.',\n timeout: 'That took too long. Please try again.',\n sessionExpired: 'Your session expired. Please sign in again.',\n\n // Client-side validation\n formInvalid: 'Please check the highlighted fields.',\n\n // Onboarding\n roleRequired: 'Choose a role to continue',\n ownerOnboardingFailed: 'We could not create your gym. Please try again.',\n memberOnboardingFailed: 'We could not save your details. Please try again.',\n\n // ── Gym registration (\"list your gym\") ─────────────────────────────────────\n gymRegistrationFailed: 'We could not register your gym. Please try again.',\n /**\n * The wizard could not read what the owner had already saved.\n *\n * It refuses to open on a blank form rather than risk the next Continue\n * overwriting a real draft, so this is the whole screen, not a toast.\n */\n gymRegistrationDraftLoadFailed:\n 'We could not open your saved gym details. Check your connection and try again.',\n /**\n * The step the wizard tried to save is implausibly large.\n *\n * A guard against a client sending something absurd rather than a limit the\n * real form approaches, but it is raised by the SERVER and shown verbatim in\n * the step-save toast — so the wording lives here with the rest of the copy,\n * not as a hand-written string at the throw site.\n */\n gymRegistrationDraftTooLarge:\n 'Those gym details are too large to save. Please shorten the descriptions and try again.',\n /**\n * \"Near me\" found nothing inside the radius.\n *\n * Deliberately not the same as `gymSearchNoResults`: this member searched\n * nowhere in particular, so telling them to refine their search would be\n * advice they cannot act on. What helps is a different place or a gym id.\n */\n gymSearchNoneNearby:\n 'No gyms within 50 km of you yet. Try a different location, or enter a gym id if you have one.',\n /** One organisation per account — registering a second is not supported. */\n gymAlreadyRegistered: 'You have already registered a gym on this account.',\n /** Registering a gym is something a MEMBER does, so the profile must exist. */\n gymRegistrationNeedsProfile: 'Finish setting up your profile before registering a gym.',\n /** Every owner action other than editing their own details, before approval. */\n gymAwaitingApproval:\n 'Your gym is waiting for approval. You can manage it once our team has reviewed it.',\n /** The reviewer turned the registration down. */\n gymRegistrationRejected: 'Your gym registration was not approved.',\n organisationNotFound: 'That gym could not be found.',\n\n // ── Platform console ────────────────────────────────────────────────────────\n /** The account is gone, or was already erased. */\n platformUserNotFound: 'That account could not be found.',\n /**\n * An admin acting on their OWN row. Suspending or deleting yourself takes away\n * the access needed to undo it, so the console refuses rather than letting one\n * mis-tap lock the platform's last superadmin out of it.\n */\n platformCannotActOnSelf: 'You cannot do that to your own account.',\n /**\n * Removing the last superadmin. `manage GymApproval` is held by nobody else,\n * so the gym review queue would become unreachable with no way back in short\n * of a database edit.\n */\n platformLastSuperadmin: 'The platform must keep at least one superadmin.',\n /** The typed confirmation did not match the record being deleted. */\n platformConfirmationMismatch: 'That did not match. Nothing was changed.',\n /** Two reviewers acting on the same registration; the second one loses. */\n organisationAlreadyDecided: 'Someone has already reviewed this gym.',\n /** A step failed to persist — the user stays put so nothing is lost. */\n onboardingStepSaveFailed: 'We could not save this step. Please try again.',\n\n // Gym structure prerequisites\n centerRequiredForPlan: 'Pick the center this plan belongs to.',\n planVariantRequired: 'Add at least one pricing variant before saving the plan.',\n planNameTaken: 'This center already has a plan with that name. Pick another name.',\n planVariantDurationRequired: 'Enter how long this variant runs for',\n planVariantPriceRequired: 'Enter the price for this variant',\n /** A \"discount\" that raises the price is a typo, every time. */\n planFinalPriceAboveOriginal: 'The final price cannot be more than the original price',\n centerAddressRequired: 'Add the center address before creating it.',\n noCenterForPlans: 'No gym center found. Add a center before creating plans.',\n noCenterForWorkouts: 'No gym center found. Add a center before creating workouts.',\n noCenterForAnnouncements: 'No gym center found. Add a center before sending announcements.',\n announcementAlreadySent: 'That announcement has already gone out, so it cannot be cancelled.',\n\n // Notification feed\n notificationHideFailed: 'Could not hide that notification.',\n notificationRestoreFailed: 'Could not restore that notification.',\n\n // Membership\n planUnavailable: 'That plan is not available right now.',\n membershipPlanRequired: 'Choose a membership plan to continue',\n /** The member was created, but the plan the owner picked did not stick. */\n initialPlanNotAssigned:\n 'Member added, but the plan could not be assigned. Assign it from their profile.',\n noPlansToAssign: 'No membership plans yet. Create one to assign it while adding a member.',\n /**\n * Not an error the member can act on by trying harder — it is the whole\n * point of the flow, so it reads as a status rather than a refusal.\n */\n membershipAwaitingPayment:\n 'Your gym is checking your payment. The plan starts as soon as they confirm it.',\n membershipNoPendingRequest: 'There is no plan waiting for confirmation.',\n /**\n * Pausing extends the term by the paused days, so pausing something that is\n * not running would push out a date nobody is training against — and pausing\n * an already-paused membership would extend it twice for one absence.\n */\n membershipNotPausable:\n 'Only a running membership can be paused. This one has already ended or is paused.',\n /**\n * The joining date records something that has already happened, so a future\n * one is not a preference to honour — it would date the member's whole\n * billing cycle from a day that has not arrived.\n */\n joiningDateInFuture: 'A joining date cannot be in the future.',\n /**\n * The term moved between the screen being drawn and the button being\n * pressed, which in practice means a second manager confirmed one first.\n * Says which month it now covers rather than a bare \"try again\", because the\n * owner's next question is always \"then what am I paying for?\".\n */\n membershipTermMoved:\n 'Someone just confirmed a payment for this member, so the period has moved on. Reopen their profile to see the current one.',\n /**\n * The owner reached for the roster toggle on a plan that has not been paid\n * for. Points at the action that WOULD start it rather than just refusing.\n */\n membershipPendingUseConfirm:\n 'This plan is waiting for payment confirmation. Mark the payment done to start it.',\n /** Two managers opening the same request; the second one loses. */\n membershipAlreadyDecided: 'Someone has already answered this payment.',\n membershipConfirmFailed: 'Could not confirm that payment. Please try again.',\n membershipRejectFailed: 'Could not turn down that payment. Please try again.',\n membershipWithdrawFailed: 'Could not withdraw that request. Please try again.',\n /** The URL did not come from our own storage — a broken or hostile client. */\n paymentProofInvalid: 'That payment screenshot could not be attached. Upload it again.',\n\n // Training\n workoutPlanRequired: 'Choose a plan to assign',\n // Roster (owner console)\n attendanceMarkFailed: 'Could not save that attendance. Please try again.',\n memberStatusFailed: \"Could not change that member's status. Please try again.\",\n memberDeleteFailed: 'Could not remove that member. Please try again.',\n memberPlanAssignFailed: 'Could not update that plan. Please try again.',\n memberPauseFailed: 'Could not pause that membership. Please try again.',\n memberCancelFailed: 'Could not cancel that membership. Please try again.',\n paymentCollectFailed: 'Could not record that payment. Please try again.',\n paymentAmountRequired: 'Enter the amount collected',\n pauseDatesRequired: 'Pick both pause dates',\n pauseDatesOrder: 'The end date has to be after the start date',\n /**\n * Attendance, workout plans and payments are all keyed on the central-auth\n * user, which an invited record does not have until the person claims it.\n */\n memberNotClaimed: 'This member has not claimed their invite yet.',\n\n // Sessions\n checkInFailed: 'Could not check you in. Please try again.',\n checkOutFailed: 'Could not check you out. Please try again.',\n /** The camera decoded a QR, but it is not a gymmonk check-in poster. */\n qrNotRecognised: 'That is not a gym check-in QR. Point at the poster at the gym.',\n /** A valid gymmonk QR, but for a gym the member does not belong to. */\n qrWrongGym: 'That QR belongs to a different gym.',\n /** The scanned code matches no center — a retired or mistyped poster. */\n qrUnknown: 'This QR is no longer valid. Ask the gym for the current poster.',\n /** Checking out with a poster from somewhere other than where you started. */\n qrWrongGymForCheckOut: 'Scan the QR at the gym where you checked in.',\n /** Manual entry only accepts a full, well-formed code. */\n checkInCodeInvalid: 'Enter the 16-character code printed under the QR.',\n checkInQrRotateFailed: 'Could not generate a new QR. Please try again.',\n /**\n * Ticking an exercise off records it against a live session, so there has to\n * be one. Shown when a member opens an exercise outside a workout and taps\n * Mark As Done.\n */\n noSessionToTrack: 'Check in at your gym to track this workout.',\n\n // ── Membership join requests ───────────────────────────────────────────────\n /** Scanned a valid poster, but the gym has not accepted this member yet. */\n membershipNotApproved:\n 'Your gym has not accepted your join request yet. You can check in once they do.',\n /** Accepted, but with no live plan — check-in needs both. */\n membershipNotActive: 'Your membership plan is not active. Renew it to start checking in again.',\n /** A second request while one is already open. */\n membershipRequestPending: 'You already have a request waiting with this gym.',\n /** Requesting a gym they are already an accepted member of. */\n membershipRequestAlreadyMember: 'You are already a member of this gym.',\n /** v1 memberships are single-center — leave the current gym first. */\n membershipRequestAlreadyAtAnotherGym:\n 'You already belong to a gym. Cancel that membership before joining another.',\n membershipRequestNotFound: 'That join request no longer exists.',\n /** Two staff acting on the same request; the second one loses. */\n membershipRequestAlreadyDecided: 'Someone has already answered this request.',\n membershipRequestFailed: 'Could not send your request. Please try again.',\n gymCodeUnknown: 'No gym found with that id. Check it with your gym.',\n /** Actions that only make sense once a gym has taken the member on. */\n noGymJoined: 'Join a gym first. You can find one from your Me tab.',\n /** Searching by name needs somewhere to look — see `gymSearchQuerySchema`. */\n gymSearchStateRequired: 'Pick a state to search gyms by name.',\n gymSearchNoResults: 'No gyms matched. Try a different area, or enter the gym id.',\n\n /**\n * Camera (QR scanning)\n *\n * ── THESE USED TO POINT AT A BOX THAT DOES NOT EXIST ──────────────────────\n * Two of them ended \"Enter the code printed under the QR\", and both halves of\n * that sentence were wrong: the scanner has no field to type a code into, and\n * the poster does not print the check-in code at all — it prints the gym's\n * PUBLIC join code, which cannot check anybody in. So a member whose camera\n * failed was sent looking for a box that is not there, to type a number that\n * is not printed.\n *\n * They now point at the thing that IS there: the check-in button under the\n * viewfinder, which needs no code at all.\n */\n cameraDenied:\n 'Camera access is blocked. Allow it in your browser settings, or check in without scanning.',\n cameraUnavailable: 'No camera found on this device. Check in without scanning instead.',\n cameraInsecure: 'Scanning needs a secure (https) connection.',\n cameraFailed: 'Could not start the camera. Check in without scanning instead.',\n /**\n * The member is not attached to a gym, on the codeless path.\n *\n * Its own sentence because that path reached for `qrUnknown` before it had\n * one, and that string opens \"This QR is no longer valid\" — advice about a\n * poster, given to somebody who never scanned one.\n */\n gymUnavailable: 'You are not checked in to a gym yet. Join one from the Me tab first.',\n\n // Engagement\n feedbackRatingRequired: 'Choose a rating to submit your feedback',\n complaintIssueRequired: 'Choose the issue you are reporting',\n\n // Security (role-switch PIN)\n mpinIncorrect: 'Incorrect PIN.',\n mpinVerifyFailed: \"Couldn't verify. Try again.\",\n mpinSetFailed: \"Couldn't set your PIN. Try again.\",\n mpinMismatch: \"Those didn't match. Try again.\",\n mpinResetLinkFailed: \"Couldn't send the reset link. Try again.\",\n mpinResetFailed: \"Couldn't reset your PIN. Try again.\",\n\n // Uploads\n imageUploadFailed: 'Could not upload that image. Please try again.',\n imageProcessFailed: 'Could not process that image. Please try again.',\n} as const satisfies Record<string, string>;\n\nexport type ErrorMessageKey = keyof typeof ERROR_MESSAGE;\n\n/** Error messages that name a limit or value. */\nexport const ERROR_MESSAGE_FOR = {\n maxPhotos: (max: number): string => `You can add up to ${max} photos`,\n /**\n * Refused at the door because the membership is paused and still inside its\n * window.\n *\n * Its own sentence because \"renew your plan\" is wrong advice here twice\n * over: nothing has lapsed, and paying again would not open the door a day\n * sooner. The resume date is the only thing this member wants to know, and\n * it is the reason this one takes a parameter at all.\n */\n membershipPausedUntil: (resumesOn: string): string =>\n `Your membership is paused until ${resumesOn}. You can check in again from that day.`,\n /** Role-switch PIN lockout, in whole minutes remaining. */\n mpinLockedOut: (minutes: number): string =>\n `Too many attempts. Try again in ${minutes} minute${minutes > 1 ? 's' : ''}.`,\n} as const;\n"]}
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU;IACV,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IACpC,SAAS,EAAE,WAAW;IAEtB,OAAO;IACP,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;IAC9B,YAAY,EAAE,cAAc;IAC5B,SAAS,EAAE,WAAW;IACtB,mBAAmB,EAAE,qBAAqB;IAE1C,OAAO;IACP,cAAc,EAAE,gBAAgB;IAChC,mBAAmB,EAAE,qBAAqB;IAC1C,YAAY,EAAE,cAAc;IAE5B,gBAAgB;IAChB,YAAY,EAAE,cAAc;IAC5B,mBAAmB,EAA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AC,OAAe,EAAU,EAAE,CACzC,mCAAmC,OAAO,UAAU,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG;CACvE,CAAC","sourcesContent":["/**\n * gymmonk-schema — API result messages\n * ====================================\n * Single source of truth for every user-facing SUCCESS and ERROR message the\n * product shows, plus the API error codes both sides key off.\n *\n * Why it lives here: the schema package is already the SSOT for data shapes,\n * types and validation. Result copy is part of that contract — the backend\n * raises a message, the client shows it, and neither should invent its own\n * wording. Both repos import from here, so copy changes land in one place and\n * can never drift between server and client.\n *\n * Usage:\n * backend → `throw new BadRequestError(ERROR_MESSAGE.centerAddressRequired)`\n * frontend → `showSuccess(...toast(SUCCESS_MESSAGE.profileUpdated))`\n *\n * @module gymmonk-schema/messages\n */\n\n// ─── API error codes ─────────────────────────────────────────────────────────\n\n/**\n * Machine-readable error codes returned in the API envelope\n * (`{ success: false, error: { code, message } }`). The client can branch on a\n * code; the message is what a human reads.\n */\nexport const ERROR_CODE = {\n // General\n INTERNAL_ERROR: 'INTERNAL_ERROR',\n VALIDATION_ERROR: 'VALIDATION_ERROR',\n NOT_FOUND: 'NOT_FOUND',\n\n // Auth\n INVALID_TOKEN: 'INVALID_TOKEN',\n TOKEN_EXPIRED: 'TOKEN_EXPIRED',\n UNAUTHORIZED: 'UNAUTHORIZED',\n FORBIDDEN: 'FORBIDDEN',\n SESSION_INVALIDATED: 'SESSION_INVALIDATED',\n\n // User\n USER_NOT_FOUND: 'USER_NOT_FOUND',\n USER_ALREADY_EXISTS: 'USER_ALREADY_EXISTS',\n INVALID_ROLE: 'INVALID_ROLE',\n\n // Rate limiting\n RATE_LIMITED: 'RATE_LIMITED',\n RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',\n\n /**\n * The caller MAY do this — their subscription simply does not stretch to it.\n *\n * Deliberately NOT `FORBIDDEN`, and the distinction is load-bearing on the\n * client. A role denial means \"this is not yours\"; the answer is to go away.\n * A plan denial means \"this costs money\"; the answer is an upgrade prompt with\n * the price on it. A client that cannot tell them apart either shows an\n * upgrade sheet to a trainer who will never be allowed to buy one, or shows a\n * bare 403 to an owner who would happily have paid.\n *\n * Always accompanied by `details`: `{ feature, currentPlan, requiredPlan,\n * current?, limit? }` — enough for the prompt to name the feature, the tier\n * that unlocks it, and how full the current allowance is.\n */\n PLAN_LIMIT_EXCEEDED: 'PLAN_LIMIT_EXCEEDED',\n\n // Upstream / dependency unavailable\n SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE',\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODE)[keyof typeof ERROR_CODE];\n\n// ─── Message shape ───────────────────────────────────────────────────────────\n\n/** A result message: a headline and an optional quieter second line. */\nexport interface ResultMessage {\n title: string;\n description?: string;\n}\n\n// ─── Success messages ────────────────────────────────────────────────────────\n\n/**\n * Confirmation shown after a write succeeds, keyed by action. Interpolating\n * entries are functions so the caller supplies the value without re-wording.\n */\nexport const SUCCESS_MESSAGE = {\n // Onboarding\n memberOnboardingComplete: {\n title: \"You're all set\",\n description: 'Welcome to GymMonk.',\n },\n ownerOnboardingComplete: {\n title: 'Your gym is ready',\n description: 'Welcome to GymMonk.',\n },\n /** Each wizard step is persisted on its own, so each one confirms. */\n onboardingStepSaved: { title: 'Saved' },\n\n // Identity & profile\n profileUpdated: { title: 'Profile updated' },\n organisationUpdated: { title: 'Organisation updated' },\n\n // Gym structure\n centerAdded: { title: 'Center added' },\n centerUpdated: { title: 'Center updated' },\n membershipPlanCreated: { title: 'Membership plan created' },\n membershipPlanUpdated: { title: 'Membership plan updated' },\n equipmentSaved: { title: 'Equipment updated' },\n\n // Membership (member-side)\n membershipUpdated: { title: 'Membership updated' },\n membershipRenewed: { title: 'Membership renewed' },\n membershipCancelled: { title: 'Membership cancelled' },\n membershipPauseRequested: {\n title: 'Pause request sent',\n description: 'Your gym will confirm the pause.',\n },\n\n // Owner SaaS subscription\n subscriptionUpdated: { title: 'Subscription updated' },\n\n // Training\n workoutPlanCreated: { title: 'Workout plan created' },\n workoutPlanUpdated: { title: 'Workout plan saved' },\n workoutPlanDeleted: {\n title: 'Workout plan deleted',\n description: 'Members on this plan no longer have one.',\n },\n workoutCreated: { title: 'Workout created' },\n workoutUpdated: { title: 'Workout saved' },\n workoutDeleted: { title: 'Workout removed' },\n workoutPlanAssigned: { title: 'Workout plan assigned' },\n\n // Diet — the counterparts of the training messages above.\n dietChartCreated: { title: 'Diet chart created' },\n dietChartUpdated: { title: 'Diet chart saved' },\n dietChartDeleted: {\n title: 'Diet chart deleted',\n description: 'Members on this chart no longer have one.',\n },\n dietChartAssigned: { title: 'Diet chart assigned' },\n dietChartCleared: { title: 'Diet chart removed' },\n foodCreated: { title: 'Food added' },\n foodUpdated: { title: 'Food saved' },\n foodDeleted: {\n title: 'Food removed',\n description: 'It no longer appears in any chart that used it.',\n },\n\n // Roster (owner console)\n attendanceMarked: { title: 'Attendance saved' },\n memberMarkedInactive: {\n title: 'Member marked inactive',\n description: 'They can no longer check in.',\n },\n memberMarkedActive: { title: 'Member reactivated' },\n memberDeleted: { title: 'Member removed' },\n /**\n * Says what actually happened. Assigning a plan no longer starts it —\n * nothing does until the payment is marked done — so a bare \"Plan\n * updated\" would send the owner away believing the member could train.\n */\n memberPlanAssigned: {\n title: 'Plan assigned',\n description: 'It starts once you mark the payment done.',\n },\n memberMembershipPaused: { title: 'Membership paused' },\n memberMembershipCancelled: { title: 'Membership cancelled' },\n paymentCollected: { title: 'Payment recorded' },\n\n // Sessions\n checkedIn: { title: 'Checked in', description: 'Your session has started.' },\n checkedOut: { title: 'Checked out', description: 'Session saved.' },\n checkInQrRotated: {\n title: 'New QR generated',\n description: 'Print it and replace the old poster.',\n },\n\n // Membership join requests\n membershipRequestSent: {\n title: 'Request sent',\n description: 'The gym will review it shortly.',\n },\n membershipRequestApproved: {\n title: 'Member approved',\n description: 'They can now check in at your gym.',\n },\n membershipRequestRejected: {\n title: 'Request declined',\n description: 'The member has been told.',\n },\n\n // Membership payment confirmation\n membershipRequested: {\n title: 'Plan requested',\n description: 'It starts once your gym confirms the payment.',\n },\n membershipRequestWithdrawn: {\n title: 'Request withdrawn',\n description: 'Pick another plan whenever you are ready.',\n },\n /**\n * Says the gym can SEE it, not that the plan has started. The member has just\n * done the only thing left to them and the temptation is to congratulate them\n * with something that sounds like confirmation; the next move is still the\n * gym's, and the screen they are looking at says so.\n */\n membershipProofAttached: {\n title: 'Screenshot sent',\n description: 'Your gym can see it now.',\n },\n membershipPaymentConfirmed: {\n title: 'Payment confirmed',\n description: 'The plan is now active for this member.',\n },\n membershipPaymentRejected: {\n title: 'Payment turned down',\n description: 'The member has been told and can send it again.',\n },\n\n // Gym registration + platform review\n gymRegistered: {\n title: 'Gym submitted',\n description: 'Our team will review it and let you know.',\n },\n gymApproved: {\n title: 'Gym approved',\n description: 'It is now listed for members to find.',\n },\n gymRejected: {\n title: 'Gym rejected',\n description: 'The owner has been told.',\n },\n\n // Engagement\n feedbackSubmitted: {\n title: 'Feedback sent',\n description: 'Thank you for helping us improve.',\n },\n complaintSubmitted: {\n title: 'Complaint submitted',\n description: 'Your gym will look into it.',\n },\n announcementSent: { title: 'Announcement sent' },\n announcementScheduled: { title: 'Announcement scheduled' },\n announcementDraftSaved: { title: 'Draft saved' },\n announcementDeleted: { title: 'Announcement deleted' },\n announcementCancelled: {\n title: 'Announcement cancelled',\n description: 'It will not be sent.',\n },\n\n // Notification feed\n notificationHidden: { title: 'Notification hidden' },\n notificationRestored: { title: 'Notification restored' },\n allNotificationsRead: { title: 'All caught up' },\n\n // Security (role-switch PIN)\n mpinSet: { title: 'PIN set' },\n mpinReset: { title: 'Your PIN has been reset.' },\n mpinResetLinkSent: {\n title: \"We've emailed you a reset link\",\n description: 'Check your inbox.',\n },\n\n // ── Platform console (superadmin / platform manager) ────────────────────────\n platformRolesUpdated: { title: 'Platform roles updated' },\n platformUserSuspended: {\n title: 'Account suspended',\n description: 'They can no longer sign in.',\n },\n platformUserReinstated: { title: 'Account reinstated' },\n platformUserDeleted: {\n title: 'Account deleted',\n description: 'It is hidden everywhere but can still be restored.',\n },\n platformUserRestored: { title: 'Account restored' },\n platformGymDeleted: {\n title: 'Gym deleted',\n description: 'It is hidden everywhere but can still be restored.',\n },\n platformGymRestored: {\n title: 'Gym restored',\n description: 'It is back in the directory and its owner has the console again.',\n },\n} as const satisfies Record<string, ResultMessage>;\n\nexport type SuccessMessageKey = keyof typeof SUCCESS_MESSAGE;\n\n/** Success messages that name the thing they acted on. */\nexport const SUCCESS_MESSAGE_FOR = {\n memberAdded: (name: string): ResultMessage => ({\n title: 'Member added',\n description: `Share the invite with ${name}.`,\n }),\n staffAdded: (name: string): ResultMessage => ({\n title: 'Staff added',\n description: `Share the invite with ${name}.`,\n }),\n inviteClaimed: (gymName: string): ResultMessage => ({\n title: \"You're all set\",\n description: `Your account is linked to ${gymName}.`,\n }),\n roleSwitched: (roleLabel: string): ResultMessage => ({\n title: `Switched to ${roleLabel}`,\n }),\n gymApprovedFor: (gymName: string): ResultMessage => ({\n title: 'Gym approved',\n description: `${gymName} is now live on GymMonk.`,\n }),\n gymRejectedFor: (gymName: string): ResultMessage => ({\n title: 'Gym rejected',\n description: `The owner of ${gymName} has been told why.`,\n }),\n} as const;\n\n// ─── Error messages ──────────────────────────────────────────────────────────\n\n/**\n * Failure copy. Transport entries describe a request that never reached the\n * API; the rest are domain rules the backend enforces and the client can also\n * check up-front — same wording either way.\n */\nexport const ERROR_MESSAGE = {\n // Transport / generic\n generic: 'Something went wrong. Please try again.',\n network: 'Network error. Check your connection and try again.',\n timeout: 'That took too long. Please try again.',\n sessionExpired: 'Your session expired. Please sign in again.',\n\n // Client-side validation\n formInvalid: 'Please check the highlighted fields.',\n\n // Onboarding\n roleRequired: 'Choose a role to continue',\n ownerOnboardingFailed: 'We could not create your gym. Please try again.',\n memberOnboardingFailed: 'We could not save your details. Please try again.',\n\n // ── Gym registration (\"list your gym\") ─────────────────────────────────────\n gymRegistrationFailed: 'We could not register your gym. Please try again.',\n /**\n * The wizard could not read what the owner had already saved.\n *\n * It refuses to open on a blank form rather than risk the next Continue\n * overwriting a real draft, so this is the whole screen, not a toast.\n */\n gymRegistrationDraftLoadFailed:\n 'We could not open your saved gym details. Check your connection and try again.',\n /**\n * The step the wizard tried to save is implausibly large.\n *\n * A guard against a client sending something absurd rather than a limit the\n * real form approaches, but it is raised by the SERVER and shown verbatim in\n * the step-save toast — so the wording lives here with the rest of the copy,\n * not as a hand-written string at the throw site.\n */\n gymRegistrationDraftTooLarge:\n 'Those gym details are too large to save. Please shorten the descriptions and try again.',\n /**\n * \"Near me\" found nothing inside the radius.\n *\n * Deliberately not the same as `gymSearchNoResults`: this member searched\n * nowhere in particular, so telling them to refine their search would be\n * advice they cannot act on. What helps is a different place or a gym id.\n */\n gymSearchNoneNearby:\n 'No gyms within 50 km of you yet. Try a different location, or enter a gym id if you have one.',\n /** One organisation per account — registering a second is not supported. */\n gymAlreadyRegistered: 'You have already registered a gym on this account.',\n /** Registering a gym is something a MEMBER does, so the profile must exist. */\n gymRegistrationNeedsProfile: 'Finish setting up your profile before registering a gym.',\n /** Every owner action other than editing their own details, before approval. */\n gymAwaitingApproval:\n 'Your gym is waiting for approval. You can manage it once our team has reviewed it.',\n /** The reviewer turned the registration down. */\n gymRegistrationRejected: 'Your gym registration was not approved.',\n organisationNotFound: 'That gym could not be found.',\n\n // ── Platform console ────────────────────────────────────────────────────────\n /** The account is gone, or was already erased. */\n platformUserNotFound: 'That account could not be found.',\n /**\n * An admin acting on their OWN row. Suspending or deleting yourself takes away\n * the access needed to undo it, so the console refuses rather than letting one\n * mis-tap lock the platform's last superadmin out of it.\n */\n platformCannotActOnSelf: 'You cannot do that to your own account.',\n /**\n * Removing the last superadmin. `manage GymApproval` is held by nobody else,\n * so the gym review queue would become unreachable with no way back in short\n * of a database edit.\n */\n platformLastSuperadmin: 'The platform must keep at least one superadmin.',\n /** The typed confirmation did not match the record being deleted. */\n platformConfirmationMismatch: 'That did not match. Nothing was changed.',\n /** Two reviewers acting on the same registration; the second one loses. */\n organisationAlreadyDecided: 'Someone has already reviewed this gym.',\n /** A step failed to persist — the user stays put so nothing is lost. */\n onboardingStepSaveFailed: 'We could not save this step. Please try again.',\n\n // Gym structure prerequisites\n centerRequiredForPlan: 'Pick the center this plan belongs to.',\n planVariantRequired: 'Add at least one pricing variant before saving the plan.',\n planNameTaken: 'This center already has a plan with that name. Pick another name.',\n planVariantDurationRequired: 'Enter how long this variant runs for',\n planVariantPriceRequired: 'Enter the price for this variant',\n /** A \"discount\" that raises the price is a typo, every time. */\n planFinalPriceAboveOriginal: 'The final price cannot be more than the original price',\n centerAddressRequired: 'Add the center address before creating it.',\n noCenterForPlans: 'No gym center found. Add a center before creating plans.',\n noCenterForWorkouts: 'No gym center found. Add a center before creating workouts.',\n noCenterForAnnouncements: 'No gym center found. Add a center before sending announcements.',\n announcementAlreadySent: 'That announcement has already gone out, so it cannot be cancelled.',\n\n // Notification feed\n notificationHideFailed: 'Could not hide that notification.',\n notificationRestoreFailed: 'Could not restore that notification.',\n\n // Membership\n planUnavailable: 'That plan is not available right now.',\n membershipPlanRequired: 'Choose a membership plan to continue',\n /** The member was created, but the plan the owner picked did not stick. */\n initialPlanNotAssigned:\n 'Member added, but the plan could not be assigned. Assign it from their profile.',\n noPlansToAssign: 'No membership plans yet. Create one to assign it while adding a member.',\n /**\n * Not an error the member can act on by trying harder — it is the whole\n * point of the flow, so it reads as a status rather than a refusal.\n */\n membershipAwaitingPayment:\n 'Your gym is checking your payment. The plan starts as soon as they confirm it.',\n membershipNoPendingRequest: 'There is no plan waiting for confirmation.',\n /**\n * Pausing extends the term by the paused days, so pausing something that is\n * not running would push out a date nobody is training against — and pausing\n * an already-paused membership would extend it twice for one absence.\n */\n membershipNotPausable:\n 'Only a running membership can be paused. This one has already ended or is paused.',\n /**\n * The joining date records something that has already happened, so a future\n * one is not a preference to honour — it would date the member's whole\n * billing cycle from a day that has not arrived.\n */\n joiningDateInFuture: 'A joining date cannot be in the future.',\n /**\n * The term moved between the screen being drawn and the button being\n * pressed, which in practice means a second manager confirmed one first.\n * Says which month it now covers rather than a bare \"try again\", because the\n * owner's next question is always \"then what am I paying for?\".\n */\n membershipTermMoved:\n 'Someone just confirmed a payment for this member, so the period has moved on. Reopen their profile to see the current one.',\n /**\n * The owner reached for the roster toggle on a plan that has not been paid\n * for. Points at the action that WOULD start it rather than just refusing.\n */\n membershipPendingUseConfirm:\n 'This plan is waiting for payment confirmation. Mark the payment done to start it.',\n /** Two managers opening the same request; the second one loses. */\n membershipAlreadyDecided: 'Someone has already answered this payment.',\n membershipConfirmFailed: 'Could not confirm that payment. Please try again.',\n membershipRejectFailed: 'Could not turn down that payment. Please try again.',\n membershipWithdrawFailed: 'Could not withdraw that request. Please try again.',\n /** The URL did not come from our own storage — a broken or hostile client. */\n paymentProofInvalid: 'That payment screenshot could not be attached. Upload it again.',\n /** The upload itself worked; saving it against the request did not. */\n paymentProofAttachFailed: 'Could not send that screenshot. Please try again.',\n\n // Training\n workoutPlanRequired: 'Choose a plan to assign',\n // Roster (owner console)\n attendanceMarkFailed: 'Could not save that attendance. Please try again.',\n memberStatusFailed: \"Could not change that member's status. Please try again.\",\n memberDeleteFailed: 'Could not remove that member. Please try again.',\n memberPlanAssignFailed: 'Could not update that plan. Please try again.',\n memberPauseFailed: 'Could not pause that membership. Please try again.',\n memberCancelFailed: 'Could not cancel that membership. Please try again.',\n paymentCollectFailed: 'Could not record that payment. Please try again.',\n paymentAmountRequired: 'Enter the amount collected',\n pauseDatesRequired: 'Pick both pause dates',\n pauseDatesOrder: 'The end date has to be after the start date',\n /**\n * Attendance, workout plans and payments are all keyed on the central-auth\n * user, which an invited record does not have until the person claims it.\n */\n memberNotClaimed: 'This member has not claimed their invite yet.',\n\n // Sessions\n checkInFailed: 'Could not check you in. Please try again.',\n checkOutFailed: 'Could not check you out. Please try again.',\n /** The camera decoded a QR, but it is not a gymmonk check-in poster. */\n qrNotRecognised: 'That is not a gym check-in QR. Point at the poster at the gym.',\n /** A valid gymmonk QR, but for a gym the member does not belong to. */\n qrWrongGym: 'That QR belongs to a different gym.',\n /** The scanned code matches no center — a retired or mistyped poster. */\n qrUnknown: 'This QR is no longer valid. Ask the gym for the current poster.',\n /** Checking out with a poster from somewhere other than where you started. */\n qrWrongGymForCheckOut: 'Scan the QR at the gym where you checked in.',\n /** Manual entry only accepts a full, well-formed code. */\n checkInCodeInvalid: 'Enter the 16-character code printed under the QR.',\n checkInQrRotateFailed: 'Could not generate a new QR. Please try again.',\n /**\n * Ticking an exercise off records it against a live session, so there has to\n * be one. Shown when a member opens an exercise outside a workout and taps\n * Mark As Done.\n */\n noSessionToTrack: 'Check in at your gym to track this workout.',\n\n // ── Membership join requests ───────────────────────────────────────────────\n /** Scanned a valid poster, but the gym has not accepted this member yet. */\n membershipNotApproved:\n 'Your gym has not accepted your join request yet. You can check in once they do.',\n /** Accepted, but with no live plan — check-in needs both. */\n membershipNotActive: 'Your membership plan is not active. Renew it to start checking in again.',\n /** A second request while one is already open. */\n membershipRequestPending: 'You already have a request waiting with this gym.',\n /** Requesting a gym they are already an accepted member of. */\n membershipRequestAlreadyMember: 'You are already a member of this gym.',\n /** v1 memberships are single-center — leave the current gym first. */\n membershipRequestAlreadyAtAnotherGym:\n 'You already belong to a gym. Cancel that membership before joining another.',\n membershipRequestNotFound: 'That join request no longer exists.',\n /** Two staff acting on the same request; the second one loses. */\n membershipRequestAlreadyDecided: 'Someone has already answered this request.',\n membershipRequestFailed: 'Could not send your request. Please try again.',\n gymCodeUnknown: 'No gym found with that id. Check it with your gym.',\n /** Actions that only make sense once a gym has taken the member on. */\n noGymJoined: 'Join a gym first. You can find one from your Me tab.',\n /** Searching by name needs somewhere to look — see `gymSearchQuerySchema`. */\n gymSearchStateRequired: 'Pick a state to search gyms by name.',\n gymSearchNoResults: 'No gyms matched. Try a different area, or enter the gym id.',\n\n /**\n * Camera (QR scanning)\n *\n * ── THESE USED TO POINT AT A BOX THAT DOES NOT EXIST ──────────────────────\n * Two of them ended \"Enter the code printed under the QR\", and both halves of\n * that sentence were wrong: the scanner has no field to type a code into, and\n * the poster does not print the check-in code at all — it prints the gym's\n * PUBLIC join code, which cannot check anybody in. So a member whose camera\n * failed was sent looking for a box that is not there, to type a number that\n * is not printed.\n *\n * They now point at the thing that IS there: the check-in button under the\n * viewfinder, which needs no code at all.\n */\n cameraDenied:\n 'Camera access is blocked. Allow it in your browser settings, or check in without scanning.',\n cameraUnavailable: 'No camera found on this device. Check in without scanning instead.',\n cameraInsecure: 'Scanning needs a secure (https) connection.',\n cameraFailed: 'Could not start the camera. Check in without scanning instead.',\n /**\n * The member is not attached to a gym, on the codeless path.\n *\n * Its own sentence because that path reached for `qrUnknown` before it had\n * one, and that string opens \"This QR is no longer valid\" — advice about a\n * poster, given to somebody who never scanned one.\n */\n gymUnavailable: 'You are not checked in to a gym yet. Join one from the Me tab first.',\n\n // Engagement\n feedbackRatingRequired: 'Choose a rating to submit your feedback',\n complaintIssueRequired: 'Choose the issue you are reporting',\n\n // Security (role-switch PIN)\n mpinIncorrect: 'Incorrect PIN.',\n mpinVerifyFailed: \"Couldn't verify. Try again.\",\n mpinSetFailed: \"Couldn't set your PIN. Try again.\",\n mpinMismatch: \"Those didn't match. Try again.\",\n mpinResetLinkFailed: \"Couldn't send the reset link. Try again.\",\n mpinResetFailed: \"Couldn't reset your PIN. Try again.\",\n\n // Uploads\n imageUploadFailed: 'Could not upload that image. Please try again.',\n imageProcessFailed: 'Could not process that image. Please try again.',\n} as const satisfies Record<string, string>;\n\nexport type ErrorMessageKey = keyof typeof ERROR_MESSAGE;\n\n/** Error messages that name a limit or value. */\nexport const ERROR_MESSAGE_FOR = {\n maxPhotos: (max: number): string => `You can add up to ${max} photos`,\n /**\n * Refused at the door because the membership is paused and still inside its\n * window.\n *\n * Its own sentence because \"renew your plan\" is wrong advice here twice\n * over: nothing has lapsed, and paying again would not open the door a day\n * sooner. The resume date is the only thing this member wants to know, and\n * it is the reason this one takes a parameter at all.\n */\n membershipPausedUntil: (resumesOn: string): string =>\n `Your membership is paused until ${resumesOn}. You can check in again from that day.`,\n /** Role-switch PIN lockout, in whole minutes remaining. */\n mpinLockedOut: (minutes: number): string =>\n `Too many attempts. Try again in ${minutes} minute${minutes > 1 ? 's' : ''}.`,\n} as const;\n"]}
|
package/dist/nutrition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nutrition.d.ts","sourceRoot":"","sources":["../src/nutrition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;EAAmC,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;iBAI9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAIhE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;iBAQ1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;iBAOhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,eAAe,EAAE,SAO7B,CAAC;AAOF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,CAUjF;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE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AAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQxD"}
|
package/dist/nutrition.js
CHANGED
|
@@ -128,7 +128,14 @@ export function scaleNutrition(per100g, grams) {
|
|
|
128
128
|
* whoever entered them will fix the food rather than trust a silent total.
|
|
129
129
|
*/
|
|
130
130
|
export function sumNutrition(parts) {
|
|
131
|
-
const total = {
|
|
131
|
+
const total = {
|
|
132
|
+
calories: 0,
|
|
133
|
+
protein: 0,
|
|
134
|
+
carbs: 0,
|
|
135
|
+
fat: 0,
|
|
136
|
+
fibre: 0,
|
|
137
|
+
micros: [],
|
|
138
|
+
};
|
|
132
139
|
const micros = new Map();
|
|
133
140
|
for (const p of parts) {
|
|
134
141
|
total.calories += p.calories;
|
package/dist/nutrition.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nutrition.js","sourceRoot":"","sources":["../src/nutrition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAGnE,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1D,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;IACtC,IAAI,EAAE,kBAAkB;CACzB,CAAC,CAAC;A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,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACrF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CACxB,CAAqD;IAErD,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACrD,IAAI,IAAI,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;QACnD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;QAC/C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;KAC5C,CAAC;AACJ,CAAC","sourcesContent":["/**\n * gymmonk-schema — Nutrition: the numbers, their units, and how they add up\n * =========================================================================\n * What a nutrition profile IS, and the two operations every diet surface needs:\n * scale one to a quantity, and sum a list of them.\n *\n * The arithmetic lives here for the same reason the BMI formula does (see\n * `body-metrics`): a chart's daily total is DERIVED, never stored, so two\n * surfaces adding the same meals up differently would show one member two\n * different calorie counts for the same food. The owner's builder computes a\n * running total as it is edited, the API computes the same totals when it\n * populates a chart, and the member's screen renders them. One implementation.\n *\n * ── Macros are fields, micros are a list ────────────────────────────────────\n * Calories, protein, carbs, fat and fibre are named paths because every food\n * has them, every screen shows them, and a plan is judged on them. Micronutrients\n * are an open `{ name, amount, unit }` list instead of twenty-five more columns:\n * which micros matter depends on the gym and the member, nobody fills in all of\n * them, and a fixed set would make every future nutrient a schema change and a\n * republish for a field most rows leave empty.\n *\n * ── Everything is per 100g at rest ──────────────────────────────────────────\n * A `Food` stores its profile per 100 grams, which is how packaging and every\n * nutrition database quote it. A chart entry stores a quantity in grams. The\n * numbers a member reads are `scaleNutrition(food.per100g, grams)`. Storing a\n * pre-scaled copy on the chart entry would freeze it: correcting a food's\n * calories would leave every chart that used it quoting the old value.\n *\n * @module gymmonk-schema/nutrition\n */\n\nimport { z } from 'zod';\n\n// ─── Units ───────────────────────────────────────────────────────────────────\n\n/**\n * The units a micronutrient is quoted in.\n *\n * `iu` is here because fat-soluble vitamins (A, D, E) are still labelled in\n * International Units on a great deal of packaging and on most supplements. It\n * is NOT convertible to a mass without knowing which vitamin it measures, so it\n * is carried as its own unit and never silently normalised.\n */\nexport const nutrientUnitSchema = z.enum(['g', 'mg', 'mcg', 'iu']);\nexport type NutrientUnit = z.infer<typeof nutrientUnitSchema>;\n\n// ─── Micronutrient ───────────────────────────────────────────────────────────\n\n/**\n * One micronutrient reading: what it is, how much, in which unit.\n *\n * `name` is free text rather than an enum, deliberately — see the module note.\n * It is trimmed and capped, not normalised to a vocabulary, because \"Vitamin\n * B12\" and \"Cobalamin\" are the same thing to a nutritionist and forcing a\n * choice between them would only make the field harder to fill in honestly.\n */\nexport const micronutrientSchema = z.object({\n name: z.string().trim().min(1, 'Name is required').max(60),\n amount: z.number().min(0).max(100_000),\n unit: nutrientUnitSchema,\n});\nexport type Micronutrient = z.infer<typeof micronutrientSchema>;\n\n// ─── Nutrition profile ───────────────────────────────────────────────────────\n\n/**\n * The macros, plus whatever micros were recorded.\n *\n * Every number is in grams except `calories`, which is kilocalories — the\n * \"calorie\" every label, every app and every member means. Bounds are per-100g\n * sanity limits: pure fat is 900 kcal/100g, so 1000 is comfortably above\n * anything real while still rejecting a misplaced decimal point.\n */\nexport const nutritionSchema = z.object({\n /** Kilocalories. */\n calories: z.number().min(0).max(1000),\n protein: z.number().min(0).max(100),\n carbs: z.number().min(0).max(100),\n fat: z.number().min(0).max(100),\n fibre: z.number().min(0).max(100),\n micros: z.array(micronutrientSchema).max(40).default([]),\n});\nexport type Nutrition = z.infer<typeof nutritionSchema>;\n\n/**\n * A nutrition profile that has been SCALED to a quantity, so its bounds no\n * longer apply.\n *\n * 400g of rice is more than 100g of anything can be, which is why this cannot\n * reuse `nutritionSchema`: the per-100g ceilings exist to catch a typo at the\n * point of entry, and applying them to a computed total would reject perfectly\n * ordinary portions. Same shape, no upper bounds.\n */\nexport const scaledNutritionSchema = z.object({\n calories: z.number().min(0),\n protein: z.number().min(0),\n carbs: z.number().min(0),\n fat: z.number().min(0),\n fibre: z.number().min(0),\n micros: z.array(micronutrientSchema),\n});\nexport type ScaledNutrition = z.infer<typeof scaledNutritionSchema>;\n\nexport const EMPTY_NUTRITION: Nutrition = {\n calories: 0,\n protein: 0,\n carbs: 0,\n fat: 0,\n fibre: 0,\n micros: [],\n};\n\n// ─── Arithmetic ──────────────────────────────────────────────────────────────\n\n/** One decimal place. Nutrition is an estimate; more digits imply precision it does not have. */\nconst round1 = (n: number): number => Math.round(n * 10) / 10;\n\n/**\n * A per-100g profile scaled to `grams`.\n *\n * Micros scale with everything else — a micronutrient is a quantity per 100g\n * exactly as a macro is, and leaving them unscaled would report the iron in\n * 100g of spinach for a 30g portion.\n */\nexport function scaleNutrition(per100g: Nutrition, grams: number): ScaledNutrition {\n const factor = grams / 100;\n return {\n calories: round1(per100g.calories * factor),\n protein: round1(per100g.protein * factor),\n carbs: round1(per100g.carbs * factor),\n fat: round1(per100g.fat * factor),\n fibre: round1(per100g.fibre * factor),\n micros: per100g.micros.map((m) => ({ ...m, amount: round1(m.amount * factor) })),\n };\n}\n\n/**\n * Add scaled profiles together — a meal from its items, a day from its meals, a\n * chart from its days.\n *\n * Micros are summed by name AND unit together. Two readings of \"Vitamin D\", one\n * in mcg and one in IU, are not addable: IU has no fixed mass equivalent\n * without knowing the compound, so adding them would invent a number. They stay\n * as separate lines, which is the honest result and is visibly odd enough that\n * whoever entered them will fix the food rather than trust a silent total.\n */\nexport function sumNutrition(parts: readonly ScaledNutrition[]): ScaledNutrition {\n const total: ScaledNutrition = { calories: 0, protein: 0, carbs: 0, fat: 0, fibre: 0, micros: [] };\n const micros = new Map<string, Micronutrient>();\n\n for (const p of parts) {\n total.calories += p.calories;\n total.protein += p.protein;\n total.carbs += p.carbs;\n total.fat += p.fat;\n total.fibre += p.fibre;\n for (const m of p.micros) {\n const key = `${m.name.toLowerCase()}|${m.unit}`;\n const seen = micros.get(key);\n if (seen) seen.amount += m.amount;\n else micros.set(key, { ...m });\n }\n }\n\n total.calories = round1(total.calories);\n total.protein = round1(total.protein);\n total.carbs = round1(total.carbs);\n total.fat = round1(total.fat);\n total.fibre = round1(total.fibre);\n total.micros = [...micros.values()].map((m) => ({ ...m, amount: round1(m.amount) }));\n return total;\n}\n\n/**\n * The share of energy coming from each macro, as whole percentages.\n *\n * Atwater factors: protein and carbohydrate 4 kcal/g, fat 9. Computed from the\n * MACROS rather than from the stored `calories`, and the two can legitimately\n * disagree by a little — a label rounds, and fibre is partly indigestible. The\n * split is what a plan is judged on (\"40/30/30\"), so it has to come from the\n * grams that produced it.\n *\n * Returns nulls when there is no macro mass at all, so a caller renders a dash\n * rather than three zeroes that look like a real 0/0/0 split.\n */\nexport function macroSplit(\n n: Pick<ScaledNutrition, 'protein' | 'carbs' | 'fat'>,\n): { protein: number; carbs: number; fat: number } | null {\n const kcal = n.protein * 4 + n.carbs * 4 + n.fat * 9;\n if (kcal <= 0) return null;\n return {\n protein: Math.round(((n.protein * 4) / kcal) * 100),\n carbs: Math.round(((n.carbs * 4) / kcal) * 100),\n fat: Math.round(((n.fat * 9) / kcal) * 100),\n };\n}\n"]}
|
|
1
|
+
{"version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,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;QACnD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;QAC/C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;KAC5C,CAAC;AACJ,CAAC","sourcesContent":["/**\n * gymmonk-schema — Nutrition: the numbers, their units, and how they add up\n * =========================================================================\n * What a nutrition profile IS, and the two operations every diet surface needs:\n * scale one to a quantity, and sum a list of them.\n *\n * The arithmetic lives here for the same reason the BMI formula does (see\n * `body-metrics`): a chart's daily total is DERIVED, never stored, so two\n * surfaces adding the same meals up differently would show one member two\n * different calorie counts for the same food. The owner's builder computes a\n * running total as it is edited, the API computes the same totals when it\n * populates a chart, and the member's screen renders them. One implementation.\n *\n * ── Macros are fields, micros are a list ────────────────────────────────────\n * Calories, protein, carbs, fat and fibre are named paths because every food\n * has them, every screen shows them, and a plan is judged on them. Micronutrients\n * are an open `{ name, amount, unit }` list instead of twenty-five more columns:\n * which micros matter depends on the gym and the member, nobody fills in all of\n * them, and a fixed set would make every future nutrient a schema change and a\n * republish for a field most rows leave empty.\n *\n * ── Everything is per 100g at rest ──────────────────────────────────────────\n * A `Food` stores its profile per 100 grams, which is how packaging and every\n * nutrition database quote it. A chart entry stores a quantity in grams. The\n * numbers a member reads are `scaleNutrition(food.per100g, grams)`. Storing a\n * pre-scaled copy on the chart entry would freeze it: correcting a food's\n * calories would leave every chart that used it quoting the old value.\n *\n * @module gymmonk-schema/nutrition\n */\n\nimport { z } from 'zod';\n\n// ─── Units ───────────────────────────────────────────────────────────────────\n\n/**\n * The units a micronutrient is quoted in.\n *\n * `iu` is here because fat-soluble vitamins (A, D, E) are still labelled in\n * International Units on a great deal of packaging and on most supplements. It\n * is NOT convertible to a mass without knowing which vitamin it measures, so it\n * is carried as its own unit and never silently normalised.\n */\nexport const nutrientUnitSchema = z.enum(['g', 'mg', 'mcg', 'iu']);\nexport type NutrientUnit = z.infer<typeof nutrientUnitSchema>;\n\n// ─── Micronutrient ───────────────────────────────────────────────────────────\n\n/**\n * One micronutrient reading: what it is, how much, in which unit.\n *\n * `name` is free text rather than an enum, deliberately — see the module note.\n * It is trimmed and capped, not normalised to a vocabulary, because \"Vitamin\n * B12\" and \"Cobalamin\" are the same thing to a nutritionist and forcing a\n * choice between them would only make the field harder to fill in honestly.\n */\nexport const micronutrientSchema = z.object({\n name: z.string().trim().min(1, 'Name is required').max(60),\n amount: z.number().min(0).max(100_000),\n unit: nutrientUnitSchema,\n});\nexport type Micronutrient = z.infer<typeof micronutrientSchema>;\n\n// ─── Nutrition profile ───────────────────────────────────────────────────────\n\n/**\n * The macros, plus whatever micros were recorded.\n *\n * Every number is in grams except `calories`, which is kilocalories — the\n * \"calorie\" every label, every app and every member means. Bounds are per-100g\n * sanity limits: pure fat is 900 kcal/100g, so 1000 is comfortably above\n * anything real while still rejecting a misplaced decimal point.\n */\nexport const nutritionSchema = z.object({\n /** Kilocalories. */\n calories: z.number().min(0).max(1000),\n protein: z.number().min(0).max(100),\n carbs: z.number().min(0).max(100),\n fat: z.number().min(0).max(100),\n fibre: z.number().min(0).max(100),\n micros: z.array(micronutrientSchema).max(40).default([]),\n});\nexport type Nutrition = z.infer<typeof nutritionSchema>;\n\n/**\n * A nutrition profile that has been SCALED to a quantity, so its bounds no\n * longer apply.\n *\n * 400g of rice is more than 100g of anything can be, which is why this cannot\n * reuse `nutritionSchema`: the per-100g ceilings exist to catch a typo at the\n * point of entry, and applying them to a computed total would reject perfectly\n * ordinary portions. Same shape, no upper bounds.\n */\nexport const scaledNutritionSchema = z.object({\n calories: z.number().min(0),\n protein: z.number().min(0),\n carbs: z.number().min(0),\n fat: z.number().min(0),\n fibre: z.number().min(0),\n micros: z.array(micronutrientSchema),\n});\nexport type ScaledNutrition = z.infer<typeof scaledNutritionSchema>;\n\nexport const EMPTY_NUTRITION: Nutrition = {\n calories: 0,\n protein: 0,\n carbs: 0,\n fat: 0,\n fibre: 0,\n micros: [],\n};\n\n// ─── Arithmetic ──────────────────────────────────────────────────────────────\n\n/** One decimal place. Nutrition is an estimate; more digits imply precision it does not have. */\nconst round1 = (n: number): number => Math.round(n * 10) / 10;\n\n/**\n * A per-100g profile scaled to `grams`.\n *\n * Micros scale with everything else — a micronutrient is a quantity per 100g\n * exactly as a macro is, and leaving them unscaled would report the iron in\n * 100g of spinach for a 30g portion.\n */\nexport function scaleNutrition(per100g: Nutrition, grams: number): ScaledNutrition {\n const factor = grams / 100;\n return {\n calories: round1(per100g.calories * factor),\n protein: round1(per100g.protein * factor),\n carbs: round1(per100g.carbs * factor),\n fat: round1(per100g.fat * factor),\n fibre: round1(per100g.fibre * factor),\n micros: per100g.micros.map((m) => ({ ...m, amount: round1(m.amount * factor) })),\n };\n}\n\n/**\n * Add scaled profiles together — a meal from its items, a day from its meals, a\n * chart from its days.\n *\n * Micros are summed by name AND unit together. Two readings of \"Vitamin D\", one\n * in mcg and one in IU, are not addable: IU has no fixed mass equivalent\n * without knowing the compound, so adding them would invent a number. They stay\n * as separate lines, which is the honest result and is visibly odd enough that\n * whoever entered them will fix the food rather than trust a silent total.\n */\nexport function sumNutrition(parts: readonly ScaledNutrition[]): ScaledNutrition {\n const total: ScaledNutrition = {\n calories: 0,\n protein: 0,\n carbs: 0,\n fat: 0,\n fibre: 0,\n micros: [],\n };\n const micros = new Map<string, Micronutrient>();\n\n for (const p of parts) {\n total.calories += p.calories;\n total.protein += p.protein;\n total.carbs += p.carbs;\n total.fat += p.fat;\n total.fibre += p.fibre;\n for (const m of p.micros) {\n const key = `${m.name.toLowerCase()}|${m.unit}`;\n const seen = micros.get(key);\n if (seen) seen.amount += m.amount;\n else micros.set(key, { ...m });\n }\n }\n\n total.calories = round1(total.calories);\n total.protein = round1(total.protein);\n total.carbs = round1(total.carbs);\n total.fat = round1(total.fat);\n total.fibre = round1(total.fibre);\n total.micros = [...micros.values()].map((m) => ({ ...m, amount: round1(m.amount) }));\n return total;\n}\n\n/**\n * The share of energy coming from each macro, as whole percentages.\n *\n * Atwater factors: protein and carbohydrate 4 kcal/g, fat 9. Computed from the\n * MACROS rather than from the stored `calories`, and the two can legitimately\n * disagree by a little — a label rounds, and fibre is partly indigestible. The\n * split is what a plan is judged on (\"40/30/30\"), so it has to come from the\n * grams that produced it.\n *\n * Returns nulls when there is no macro mass at all, so a caller renders a dash\n * rather than three zeroes that look like a real 0/0/0 split.\n */\nexport function macroSplit(\n n: Pick<ScaledNutrition, 'protein' | 'carbs' | 'fat'>,\n): { protein: number; carbs: number; fat: number } | null {\n const kcal = n.protein * 4 + n.carbs * 4 + n.fat * 9;\n if (kcal <= 0) return null;\n return {\n protein: Math.round(((n.protein * 4) / kcal) * 100),\n carbs: Math.round(((n.carbs * 4) / kcal) * 100),\n fat: Math.round(((n.fat * 9) / kcal) * 100),\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gymmonk-schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.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",
|