gymmonk-schema 0.35.0 → 0.37.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/add-person-form.d.ts +6 -6
- package/dist/add-person-form.d.ts.map +1 -1
- package/dist/add-person-form.js +6 -8
- package/dist/add-person-form.js.map +1 -1
- package/dist/center.d.ts +12 -12
- package/dist/equipment.d.ts +8 -8
- package/dist/gym-registration.d.ts +3 -3
- package/dist/member.d.ts +5 -44
- package/dist/member.d.ts.map +1 -1
- package/dist/member.js +0 -3
- package/dist/member.js.map +1 -1
- package/dist/membership-plan.d.ts +655 -128
- package/dist/membership-plan.d.ts.map +1 -1
- package/dist/membership-plan.js +180 -51
- package/dist/membership-plan.js.map +1 -1
- package/dist/membership.d.ts +5 -21
- package/dist/membership.d.ts.map +1 -1
- package/dist/membership.js +12 -5
- package/dist/membership.js.map +1 -1
- package/dist/messages.d.ts +3 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +3 -1
- package/dist/messages.js.map +1 -1
- package/dist/onboarding-form.d.ts +6 -6
- package/dist/onboarding.d.ts +3 -3
- package/package.json +1 -1
|
@@ -130,11 +130,13 @@ export type AddMemberFormValues = {
|
|
|
130
130
|
trainerId: string;
|
|
131
131
|
};
|
|
132
132
|
/**
|
|
133
|
-
* Staff keep the address
|
|
133
|
+
* Staff keep the address a member is no longer asked for — but not an ID proof.
|
|
134
134
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
135
|
+
* The address stays because this is an employment record: a gym holds one for
|
|
136
|
+
* the people it EMPLOYS for reasons that have nothing to do with why it holds a
|
|
137
|
+
* member's phone number. The ID upload went for the opposite reason — nothing
|
|
138
|
+
* in the product ever showed it back, so it was a document collected and then
|
|
139
|
+
* never looked at, which is the worst thing to ask anyone for.
|
|
138
140
|
*/
|
|
139
141
|
export declare const addStaffFormSchema: z.ZodObject<{
|
|
140
142
|
role: z.ZodNullable<z.ZodEnum<{
|
|
@@ -180,7 +182,6 @@ export declare const addStaffFormSchema: z.ZodObject<{
|
|
|
180
182
|
source: z.ZodString;
|
|
181
183
|
}, z.core.$strip>>;
|
|
182
184
|
}, z.core.$strip>>;
|
|
183
|
-
idProofUrl: z.ZodString;
|
|
184
185
|
name: z.ZodString;
|
|
185
186
|
email: z.ZodEmail;
|
|
186
187
|
phone: z.ZodString;
|
|
@@ -212,7 +213,6 @@ export declare const addStaffFormSchema: z.ZodObject<{
|
|
|
212
213
|
export type AddStaffFormValues = Omit<AddMemberFormValues, 'trainerId'> & {
|
|
213
214
|
role: z.infer<typeof staffRoleSchema> | null;
|
|
214
215
|
address: Address | null;
|
|
215
|
-
idProofUrl: string;
|
|
216
216
|
};
|
|
217
217
|
/** One blank row so the section renders with a contact to fill. */
|
|
218
218
|
export declare const EMPTY_EMERGENCY_CONTACT: EmergencyContactRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-person-form.d.ts","sourceRoot":"","sources":["../src/add-person-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,KAAK,OAAO,EAAiB,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI7C;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAI5C;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAA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,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,gBAAgB,CAYjF"}
|
package/dist/add-person-form.js
CHANGED
|
@@ -178,11 +178,13 @@ export const addMemberFormSchema = z
|
|
|
178
178
|
});
|
|
179
179
|
// ─── Staff form ──────────────────────────────────────────────────────────────
|
|
180
180
|
/**
|
|
181
|
-
* Staff keep the address
|
|
181
|
+
* Staff keep the address a member is no longer asked for — but not an ID proof.
|
|
182
182
|
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
183
|
+
* The address stays because this is an employment record: a gym holds one for
|
|
184
|
+
* the people it EMPLOYS for reasons that have nothing to do with why it holds a
|
|
185
|
+
* member's phone number. The ID upload went for the opposite reason — nothing
|
|
186
|
+
* in the product ever showed it back, so it was a document collected and then
|
|
187
|
+
* never looked at, which is the worst thing to ask anyone for.
|
|
186
188
|
*/
|
|
187
189
|
export const addStaffFormSchema = z
|
|
188
190
|
.object({
|
|
@@ -194,8 +196,6 @@ export const addStaffFormSchema = z
|
|
|
194
196
|
* coordinates — or nothing.
|
|
195
197
|
*/
|
|
196
198
|
address: addressSchema.nullable(),
|
|
197
|
-
/** GCS URL — uploads on pick, so this is never a file. */
|
|
198
|
-
idProofUrl: z.string(),
|
|
199
199
|
})
|
|
200
200
|
.superRefine((v, ctx) => {
|
|
201
201
|
refineDob(v, ctx);
|
|
@@ -228,7 +228,6 @@ export const EMPTY_ADD_STAFF_FORM = {
|
|
|
228
228
|
contacts: [{ ...EMPTY_EMERGENCY_CONTACT }],
|
|
229
229
|
role: null,
|
|
230
230
|
address: null,
|
|
231
|
-
idProofUrl: '',
|
|
232
231
|
};
|
|
233
232
|
// ─── Form → API body ─────────────────────────────────────────────────────────
|
|
234
233
|
/** One "Name" field on screen, `firstName` + `lastName` on the wire. */
|
|
@@ -296,7 +295,6 @@ export function toCreateStaffBody(values) {
|
|
|
296
295
|
// Staff-only — see `addStaffFormSchema`. Already a complete `Address` or
|
|
297
296
|
// null; the location drawer cannot produce anything in between.
|
|
298
297
|
address: values.address ?? undefined,
|
|
299
|
-
idProofUrl: orUndefined(values.idProofUrl),
|
|
300
298
|
};
|
|
301
299
|
}
|
|
302
300
|
// ─── Edit member ─────────────────────────────────────────────────────────────
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-person-form.js","sourceRoot":"","sources":["../src/add-person-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAAgB,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE1F,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,gFAAgF;AAEhF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,KAAa,EAAE,IAAY;IACtE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC9C,OAAO,GAAG,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,eAAe,CAAC,GAA8B;IAK5D,MAAM,KAAK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,MAAM,CAAC,CAAC;IAClC,OAAO;QACL,GAAG,MAAM;QACT,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,IAAI;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI;QACrC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QACpC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QAClC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI;QACxD,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE;KACpF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * gymmonk-schema — \"Add member\" / \"Add staff\" FORM schemas\n * ========================================================\n * The client-side validation contract for the owner's desk-entry forms, and the\n * mappers that turn a filled form into the `createMember` / `createStaff` API\n * bodies.\n *\n * Why these live here rather than in the client, and why they are distinct from\n * `createMemberBodySchema`: the form's working shape is not the wire shape. It\n * holds ONE \"name\" field the API splits in two, `null` for a choice not yet\n * made, and `''` for an optional value left blank. Those are legitimate mid-edit\n * states that the API body must never see. Expressing the same rules over the\n * form shape here keeps\n * every message, bound and regex defined once — the client cannot drift from\n * what the server will accept, and the coercion from one shape to the other is\n * part of the contract instead of ad-hoc code in a component.\n *\n * Mirrors `onboarding-form.ts`, which does the same job for the wizards.\n *\n * @module gymmonk-schema/add-person-form\n */\n\nimport { z } from 'zod';\nimport { ageInYears, isRealDate, PHONE_REGEX } from './common.js';\nimport type { CreateMemberBody, UpdateMemberBody } from './member.js';\nimport { emergencyContactSchema, MAX_EMERGENCY_CONTACTS } from './member-profile.js';\nimport type { AssignMembershipBody } from './membership.js';\nimport { type Address, addressSchema, bloodGroupSchema, genderSchema } from './shared.js';\nimport type { CreateStaffBody } from './staff.js';\nimport { staffRoleSchema } from './staff.js';\n\n// ─── Bounds ──────────────────────────────────────────────────────────────────\n\n/**\n * Age bounds for someone signed up at the desk. Wider than the member wizard's\n * because a gym also enrols juniors with a guardian present, and the date is\n * typed by staff rather than by the person themselves.\n */\nexport const ADD_PERSON_MIN_AGE_YEARS = 5;\nexport const ADD_PERSON_MAX_AGE_YEARS = 100;\n\n// ─── Date of birth, as three cells ───────────────────────────────────────────\n\n/**\n * The three cells joined into the `YYYY-MM-DD` the API stores, or `undefined`\n * when nothing was entered.\n *\n * Desk entry does not require a date of birth — a gym adds people with\n * whatever it has to hand — so \"blank\" is a real answer and has to survive the\n * whole way to the body as an ABSENT field rather than an empty string the\n * API would reject.\n */\nexport function isoFromDobCells(day: string, month: string, year: string): string | undefined {\n if (!day || !month || !year) return undefined;\n return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;\n}\n\n/** A stored `YYYY-MM-DD` split back into the cells, for seeding an edit form. */\nexport function dobCellsFromIso(iso: string | null | undefined): {\n dobDay: string;\n dobMonth: string;\n dobYear: string;\n} {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso ?? '');\n if (!match) return { dobDay: '', dobMonth: '', dobYear: '' };\n return { dobYear: match[1] as string, dobMonth: match[2] as string, dobDay: match[3] as string };\n}\n\n// ─── Field-level rules ───────────────────────────────────────────────────────\n\nconst requiredChoice = <T extends z.ZodTypeAny>(inner: T, message: string) =>\n inner.nullable().refine((v: unknown) => v !== null, { message });\n\n// ─── One emergency-contact row ───────────────────────────────────────────────\n\n/**\n * One emergency-contact row: WHO to call, on what number, and how they are\n * related. A row is either wholly blank (ignored) or names a person.\n *\n * ── Why `name` exists now ───────────────────────────────────────────────────\n * This form used to collect a relationship and a phone with no name at all,\n * and the mapper wrote the relationship INTO `name` because\n * `emergencyContactSchema` requires one. The member's own surfaces store a real\n * name, so the two halves of the product disagreed about what the field held,\n * and the disagreement destroyed data: a member onboards with \"Priya\", the\n * owner opens Edit Member and sees Relationship prefilled \"Priya\" (the reader\n * fell back to `name`), corrects it to \"Sister\", saves — and the contact is now\n * called Sister. Whoever has to ring that number in an emergency is left with\n * a word instead of a person.\n *\n * `relationship` stays OPTIONAL, matching `emergencyContactSchema`. It is\n * useful context, not something to block a desk entry over.\n */\nexport const emergencyContactRowSchema = z\n .object({\n name: z.string().trim().max(120),\n relationship: z.string().trim().max(60),\n phone: z.string().trim(),\n })\n .superRefine((v, ctx) => {\n const blank = v.name === '' && v.relationship === '' && v.phone === '';\n if (blank) return;\n if (v.name === '') {\n ctx.addIssue({\n code: 'custom',\n path: ['name'],\n message: \"Add the contact's name\",\n });\n }\n if (!PHONE_REGEX.test(v.phone)) {\n ctx.addIssue({\n code: 'custom',\n path: ['phone'],\n message: 'Enter a valid 10-digit mobile number',\n });\n }\n });\n\nexport interface EmergencyContactRow {\n name: string;\n relationship: string;\n phone: string;\n}\n\n// ─── Shared base ─────────────────────────────────────────────────────────────\n\nconst addPersonBaseShape = {\n /** One field on screen; split into `firstName` / `lastName` on the wire. */\n name: z.string().trim().min(1, 'Name is required').max(160),\n email: z.email('Enter a valid email'),\n phone: z.string().regex(PHONE_REGEX, 'Enter a valid 10-digit mobile number'),\n /**\n * Three cells, not a native date input.\n *\n * `<input type=\"date\">` renders in the BROWSER'S locale, so the same field\n * read \"mm/dd/yyyy\" at an Indian gym's front desk — and a member's own\n * onboarding asked for the very same fact through `DobInput`'s DD/MM/YYYY\n * cells. Two surfaces collecting one fact in two formats is how a birthday\n * gets typed the wrong way round.\n *\n * All three or none: desk entry does not require a date of birth, so blank\n * is a real answer, but half a date is not.\n */\n dobDay: z.string(),\n dobMonth: z.string(),\n dobYear: z.string(),\n gender: requiredChoice(genderSchema, 'Select a gender'),\n\n /** Blank when not recorded. */\n bloodGroup: bloodGroupSchema.or(z.literal('')),\n avatarUrl: z.string(),\n\n contacts: z.array(emergencyContactRowSchema).max(MAX_EMERGENCY_CONTACTS),\n};\n\n/**\n * Date of birth is optional, but a typed one has to be real and plausible —\n * a mis-keyed year is the single most common desk-entry slip.\n */\nfunction refineDob(\n v: { dobDay: string; dobMonth: string; dobYear: string },\n ctx: z.RefinementCtx,\n): void {\n const touched = Boolean(v.dobDay || v.dobMonth || v.dobYear);\n // Nothing entered is fine — the desk records what it has.\n if (!touched) return;\n\n // Every message lands on `dobDay`, the first cell, because the three are one\n // control on screen: an error parked on `dobYear` would sit under a field\n // the form renders as a single row and reads back from `dobDay`.\n if (!v.dobDay || !v.dobMonth || v.dobYear.length !== 4) {\n ctx.addIssue({ code: 'custom', path: ['dobDay'], message: 'Enter the full date of birth' });\n return;\n }\n\n const day = Number(v.dobDay);\n const month = Number(v.dobMonth);\n const year = Number(v.dobYear);\n\n if (!isRealDate(year, month, day)) {\n ctx.addIssue({ code: 'custom', path: ['dobDay'], message: 'That date does not exist' });\n return;\n }\n\n const age = ageInYears(year, month, day);\n if (age < 0) {\n ctx.addIssue({\n code: 'custom',\n path: ['dobDay'],\n message: 'Date of birth cannot be in the future',\n });\n } else if (age < ADD_PERSON_MIN_AGE_YEARS || age > ADD_PERSON_MAX_AGE_YEARS) {\n ctx.addIssue({ code: 'custom', path: ['dobDay'], message: 'Check the year of birth' });\n }\n}\n\n// ─── Member form ─────────────────────────────────────────────────────────────\n\nexport const addMemberFormSchema = z\n .object({\n ...addPersonBaseShape,\n /**\n * Central-auth user id of the trainer, or `''` for none. Only trainers who\n * have CLAIMED their invite can be assigned — an unclaimed staff record has\n * no user to point at (`MemberProfile.assignedTrainerId` refs `User`).\n */\n trainerId: z.string(),\n })\n .superRefine((v, ctx) => {\n refineDob(v, ctx);\n });\n\n/**\n * Adding a member asks for the person, not their paperwork.\n *\n * No address and no ID proof: neither is something a front desk has when\n * somebody walks in, both were optional and therefore skipped, and the member's\n * own screens never collected them either. They live on the EDIT form, where an\n * owner fills them in once they actually have them, and on the staff form,\n * where an employer legitimately does.\n */\nexport type AddMemberFormValues = {\n name: string;\n email: string;\n phone: string;\n dobDay: string;\n dobMonth: string;\n dobYear: string;\n gender: z.infer<typeof genderSchema> | null;\n bloodGroup: z.infer<typeof bloodGroupSchema> | '';\n avatarUrl: string;\n contacts: EmergencyContactRow[];\n /** Optional — a gym with no trainers yet, or none chosen. `''` for none. */\n trainerId: string;\n};\n\n// ─── Staff form ──────────────────────────────────────────────────────────────\n\n/**\n * Staff keep the address and the ID proof a member is no longer asked for.\n *\n * Not an oversight: this is an employment record. A gym holds an address and\n * an identity document for the people it EMPLOYS for reasons that have nothing\n * to do with why it holds a member's phone number.\n */\nexport const addStaffFormSchema = z\n .object({\n ...addPersonBaseShape,\n role: requiredChoice(staffRoleSchema, 'Select a staff role'),\n /**\n * The whole address, or null. Picked through the location drawer, which\n * hands back a complete `Address` — area chain, ids, names, ancestry,\n * coordinates — or nothing.\n */\n address: addressSchema.nullable(),\n /** GCS URL — uploads on pick, so this is never a file. */\n idProofUrl: z.string(),\n })\n .superRefine((v, ctx) => {\n refineDob(v, ctx);\n });\n\nexport type AddStaffFormValues = Omit<AddMemberFormValues, 'trainerId'> & {\n role: z.infer<typeof staffRoleSchema> | null;\n address: Address | null;\n idProofUrl: string;\n};\n\n// ─── Empty states ────────────────────────────────────────────────────────────\n\nconst EMPTY_BASE = {\n name: '',\n email: '',\n phone: '',\n dobDay: '',\n dobMonth: '',\n dobYear: '',\n gender: null,\n bloodGroup: '' as const,\n avatarUrl: '',\n} satisfies Omit<AddMemberFormValues, 'contacts' | 'trainerId'>;\n\n/** One blank row so the section renders with a contact to fill. */\nexport const EMPTY_EMERGENCY_CONTACT: EmergencyContactRow = {\n name: '',\n relationship: '',\n phone: '',\n};\n\nexport const EMPTY_ADD_MEMBER_FORM: AddMemberFormValues = {\n ...EMPTY_BASE,\n contacts: [{ ...EMPTY_EMERGENCY_CONTACT }],\n trainerId: '',\n};\n\nexport const EMPTY_ADD_STAFF_FORM: AddStaffFormValues = {\n ...EMPTY_BASE,\n contacts: [{ ...EMPTY_EMERGENCY_CONTACT }],\n role: null,\n address: null,\n idProofUrl: '',\n};\n\n// ─── Form → API body ─────────────────────────────────────────────────────────\n\n/** One \"Name\" field on screen, `firstName` + `lastName` on the wire. */\nfunction splitName(value: string): { firstName: string; lastName?: string } {\n const parts = value.trim().split(/\\s+/).filter(Boolean);\n const lastName = parts.slice(1).join(' ');\n return { firstName: parts[0] ?? '', ...(lastName ? { lastName } : {}) };\n}\n\n/** Drop a blank optional so it reads as \"not provided\" rather than `''`. */\nfunction orUndefined(value: string): string | undefined {\n const trimmed = value.trim();\n return trimmed === '' ? undefined : trimmed;\n}\n\n/** Phones are STORED raw — strip any display formatting back to 10 digits. */\nfunction asPhone(value: string): string {\n return value.replace(/\\D/g, '').slice(-10);\n}\n\n/**\n * The fields EVERY desk form sends. Address and ID proof are not among them —\n * only two of the three forms ask for those, so each adds its own.\n */\nfunction sharedBody(v: Omit<AddMemberFormValues, 'trainerId'>) {\n // A row with nothing in it is not a contact. Anything else has already been\n // through `emergencyContactRowSchema`, which requires a name and a valid\n // phone the moment a row is touched.\n const emergencyContacts = v.contacts\n .filter((c) => c.name !== '' || c.relationship !== '' || c.phone !== '')\n .map((c) =>\n emergencyContactSchema.parse({\n name: c.name.trim(),\n phone: asPhone(c.phone),\n relationship: orUndefined(c.relationship),\n }),\n )\n .slice(0, MAX_EMERGENCY_CONTACTS);\n\n return {\n ...splitName(v.name),\n email: v.email.trim(),\n phone: asPhone(v.phone),\n // The form schema guarantees a choice was made before we get here.\n gender: v.gender ?? 'other',\n // Absent rather than empty when the desk did not record one — see\n // `isoFromDobCells`.\n dob: isoFromDobCells(v.dobDay, v.dobMonth, v.dobYear),\n bloodGroup: v.bloodGroup === '' ? undefined : v.bloodGroup,\n emergencyContacts,\n avatarUrl: orUndefined(v.avatarUrl),\n };\n}\n\n/**\n * Validated member form → `POST /members` body. `initialPlan` comes from the\n * membership step, which the form itself knows nothing about.\n */\nexport function toCreateMemberBody(\n values: AddMemberFormValues,\n initialPlan?: AssignMembershipBody,\n): CreateMemberBody {\n return {\n ...sharedBody(values),\n assignedTrainerId: orUndefined(values.trainerId),\n ...(initialPlan ? { initialPlan } : {}),\n };\n}\n\n/** Validated staff form → `POST /staff` body. */\nexport function toCreateStaffBody(values: AddStaffFormValues): CreateStaffBody {\n return {\n ...sharedBody(values),\n // The form schema guarantees a role was chosen.\n role: values.role ?? 'trainer',\n // Staff-only — see `addStaffFormSchema`. Already a complete `Address` or\n // null; the location drawer cannot produce anything in between.\n address: values.address ?? undefined,\n idProofUrl: orUndefined(values.idProofUrl),\n };\n}\n\n// ─── Edit member ─────────────────────────────────────────────────────────────\n\n/**\n * Editing a member reuses the add form's every rule, plus the Aadhaar last-four\n * the desk may not have taken at signup.\n *\n * It is a separate schema rather than the same one because the two forms differ\n * in what \"blank\" means. On the add form a blank optional is simply not\n * provided; on the edit form it is an instruction to CLEAR a value that is\n * already stored, and the mapper has to send `null` rather than omit the field.\n */\nexport const editMemberFormSchema = z\n .object({\n ...addPersonBaseShape,\n trainerId: z.string(),\n /** Blank when not recorded; exactly four digits otherwise. */\n aadhaarLast4: z\n .string()\n .trim()\n .refine((v) => v === '' || /^\\d{4}$/.test(v), 'Enter the last four digits'),\n /**\n * Address and ID proof are asked HERE and not on the add form.\n *\n * Adding somebody happens at a desk with a queue behind them; editing\n * happens later, once the gym actually holds the document. Dropping them\n * from EDIT as well would leave three fields the API stores, the detail\n * screen renders, and no screen anywhere can write.\n */\n address: addressSchema.nullable(),\n idProofUrl: z.string(),\n })\n .superRefine((v, ctx) => {\n refineDob(v, ctx);\n });\n\nexport type EditMemberFormValues = AddMemberFormValues & {\n aadhaarLast4: string;\n address: Address | null;\n idProofUrl: string;\n};\n\n/**\n * Validated edit form → `PATCH /members/:id` body.\n *\n * Sends every field, including the cleared ones as `null`, because the owner\n * emptying a field is an edit like any other. The four identity fields go\n * along too; the server drops them once the member has claimed their account.\n */\nexport function toUpdateMemberBody(values: EditMemberFormValues): UpdateMemberBody {\n const shared = sharedBody(values);\n return {\n ...shared,\n dob: shared.dob ?? null,\n bloodGroup: shared.bloodGroup ?? null,\n address: values.address,\n idProofUrl: values.idProofUrl.trim(),\n avatarUrl: values.avatarUrl.trim(),\n assignedTrainerId: orUndefined(values.trainerId) ?? null,\n aadhaarLast4: values.aadhaarLast4.trim() === '' ? null : values.aadhaarLast4.trim(),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"add-person-form.js","sourceRoot":"","sources":["../src/add-person-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAAgB,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE1F,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,gFAAgF;AAEhF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,KAAa,EAAE,IAAY;IACtE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC9C,OAAO,GAAG,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,eAAe,CAAC,GAA8B;IAK5D,MAAM,KAAK,GAAG,2BAA2B,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;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MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QACpC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QAClC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI;QACxD,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE;KACpF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * gymmonk-schema — \"Add member\" / \"Add staff\" FORM schemas\n * ========================================================\n * The client-side validation contract for the owner's desk-entry forms, and the\n * mappers that turn a filled form into the `createMember` / `createStaff` API\n * bodies.\n *\n * Why these live here rather than in the client, and why they are distinct from\n * `createMemberBodySchema`: the form's working shape is not the wire shape. It\n * holds ONE \"name\" field the API splits in two, `null` for a choice not yet\n * made, and `''` for an optional value left blank. Those are legitimate mid-edit\n * states that the API body must never see. Expressing the same rules over the\n * form shape here keeps\n * every message, bound and regex defined once — the client cannot drift from\n * what the server will accept, and the coercion from one shape to the other is\n * part of the contract instead of ad-hoc code in a component.\n *\n * Mirrors `onboarding-form.ts`, which does the same job for the wizards.\n *\n * @module gymmonk-schema/add-person-form\n */\n\nimport { z } from 'zod';\nimport { ageInYears, isRealDate, PHONE_REGEX } from './common.js';\nimport type { CreateMemberBody, UpdateMemberBody } from './member.js';\nimport { emergencyContactSchema, MAX_EMERGENCY_CONTACTS } from './member-profile.js';\nimport type { AssignMembershipBody } from './membership.js';\nimport { type Address, addressSchema, bloodGroupSchema, genderSchema } from './shared.js';\nimport type { CreateStaffBody } from './staff.js';\nimport { staffRoleSchema } from './staff.js';\n\n// ─── Bounds ──────────────────────────────────────────────────────────────────\n\n/**\n * Age bounds for someone signed up at the desk. Wider than the member wizard's\n * because a gym also enrols juniors with a guardian present, and the date is\n * typed by staff rather than by the person themselves.\n */\nexport const ADD_PERSON_MIN_AGE_YEARS = 5;\nexport const ADD_PERSON_MAX_AGE_YEARS = 100;\n\n// ─── Date of birth, as three cells ───────────────────────────────────────────\n\n/**\n * The three cells joined into the `YYYY-MM-DD` the API stores, or `undefined`\n * when nothing was entered.\n *\n * Desk entry does not require a date of birth — a gym adds people with\n * whatever it has to hand — so \"blank\" is a real answer and has to survive the\n * whole way to the body as an ABSENT field rather than an empty string the\n * API would reject.\n */\nexport function isoFromDobCells(day: string, month: string, year: string): string | undefined {\n if (!day || !month || !year) return undefined;\n return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;\n}\n\n/** A stored `YYYY-MM-DD` split back into the cells, for seeding an edit form. */\nexport function dobCellsFromIso(iso: string | null | undefined): {\n dobDay: string;\n dobMonth: string;\n dobYear: string;\n} {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso ?? '');\n if (!match) return { dobDay: '', dobMonth: '', dobYear: '' };\n return { dobYear: match[1] as string, dobMonth: match[2] as string, dobDay: match[3] as string };\n}\n\n// ─── Field-level rules ───────────────────────────────────────────────────────\n\nconst requiredChoice = <T extends z.ZodTypeAny>(inner: T, message: string) =>\n inner.nullable().refine((v: unknown) => v !== null, { message });\n\n// ─── One emergency-contact row ───────────────────────────────────────────────\n\n/**\n * One emergency-contact row: WHO to call, on what number, and how they are\n * related. A row is either wholly blank (ignored) or names a person.\n *\n * ── Why `name` exists now ───────────────────────────────────────────────────\n * This form used to collect a relationship and a phone with no name at all,\n * and the mapper wrote the relationship INTO `name` because\n * `emergencyContactSchema` requires one. The member's own surfaces store a real\n * name, so the two halves of the product disagreed about what the field held,\n * and the disagreement destroyed data: a member onboards with \"Priya\", the\n * owner opens Edit Member and sees Relationship prefilled \"Priya\" (the reader\n * fell back to `name`), corrects it to \"Sister\", saves — and the contact is now\n * called Sister. Whoever has to ring that number in an emergency is left with\n * a word instead of a person.\n *\n * `relationship` stays OPTIONAL, matching `emergencyContactSchema`. It is\n * useful context, not something to block a desk entry over.\n */\nexport const emergencyContactRowSchema = z\n .object({\n name: z.string().trim().max(120),\n relationship: z.string().trim().max(60),\n phone: z.string().trim(),\n })\n .superRefine((v, ctx) => {\n const blank = v.name === '' && v.relationship === '' && v.phone === '';\n if (blank) return;\n if (v.name === '') {\n ctx.addIssue({\n code: 'custom',\n path: ['name'],\n message: \"Add the contact's name\",\n });\n }\n if (!PHONE_REGEX.test(v.phone)) {\n ctx.addIssue({\n code: 'custom',\n path: ['phone'],\n message: 'Enter a valid 10-digit mobile number',\n });\n }\n });\n\nexport interface EmergencyContactRow {\n name: string;\n relationship: string;\n phone: string;\n}\n\n// ─── Shared base ─────────────────────────────────────────────────────────────\n\nconst addPersonBaseShape = {\n /** One field on screen; split into `firstName` / `lastName` on the wire. */\n name: z.string().trim().min(1, 'Name is required').max(160),\n email: z.email('Enter a valid email'),\n phone: z.string().regex(PHONE_REGEX, 'Enter a valid 10-digit mobile number'),\n /**\n * Three cells, not a native date input.\n *\n * `<input type=\"date\">` renders in the BROWSER'S locale, so the same field\n * read \"mm/dd/yyyy\" at an Indian gym's front desk — and a member's own\n * onboarding asked for the very same fact through `DobInput`'s DD/MM/YYYY\n * cells. Two surfaces collecting one fact in two formats is how a birthday\n * gets typed the wrong way round.\n *\n * All three or none: desk entry does not require a date of birth, so blank\n * is a real answer, but half a date is not.\n */\n dobDay: z.string(),\n dobMonth: z.string(),\n dobYear: z.string(),\n gender: requiredChoice(genderSchema, 'Select a gender'),\n\n /** Blank when not recorded. */\n bloodGroup: bloodGroupSchema.or(z.literal('')),\n avatarUrl: z.string(),\n\n contacts: z.array(emergencyContactRowSchema).max(MAX_EMERGENCY_CONTACTS),\n};\n\n/**\n * Date of birth is optional, but a typed one has to be real and plausible —\n * a mis-keyed year is the single most common desk-entry slip.\n */\nfunction refineDob(\n v: { dobDay: string; dobMonth: string; dobYear: string },\n ctx: z.RefinementCtx,\n): void {\n const touched = Boolean(v.dobDay || v.dobMonth || v.dobYear);\n // Nothing entered is fine — the desk records what it has.\n if (!touched) return;\n\n // Every message lands on `dobDay`, the first cell, because the three are one\n // control on screen: an error parked on `dobYear` would sit under a field\n // the form renders as a single row and reads back from `dobDay`.\n if (!v.dobDay || !v.dobMonth || v.dobYear.length !== 4) {\n ctx.addIssue({ code: 'custom', path: ['dobDay'], message: 'Enter the full date of birth' });\n return;\n }\n\n const day = Number(v.dobDay);\n const month = Number(v.dobMonth);\n const year = Number(v.dobYear);\n\n if (!isRealDate(year, month, day)) {\n ctx.addIssue({ code: 'custom', path: ['dobDay'], message: 'That date does not exist' });\n return;\n }\n\n const age = ageInYears(year, month, day);\n if (age < 0) {\n ctx.addIssue({\n code: 'custom',\n path: ['dobDay'],\n message: 'Date of birth cannot be in the future',\n });\n } else if (age < ADD_PERSON_MIN_AGE_YEARS || age > ADD_PERSON_MAX_AGE_YEARS) {\n ctx.addIssue({ code: 'custom', path: ['dobDay'], message: 'Check the year of birth' });\n }\n}\n\n// ─── Member form ─────────────────────────────────────────────────────────────\n\nexport const addMemberFormSchema = z\n .object({\n ...addPersonBaseShape,\n /**\n * Central-auth user id of the trainer, or `''` for none. Only trainers who\n * have CLAIMED their invite can be assigned — an unclaimed staff record has\n * no user to point at (`MemberProfile.assignedTrainerId` refs `User`).\n */\n trainerId: z.string(),\n })\n .superRefine((v, ctx) => {\n refineDob(v, ctx);\n });\n\n/**\n * Adding a member asks for the person, not their paperwork.\n *\n * No address and no ID proof: neither is something a front desk has when\n * somebody walks in, both were optional and therefore skipped, and the member's\n * own screens never collected them either. They live on the EDIT form, where an\n * owner fills them in once they actually have them, and on the staff form,\n * where an employer legitimately does.\n */\nexport type AddMemberFormValues = {\n name: string;\n email: string;\n phone: string;\n dobDay: string;\n dobMonth: string;\n dobYear: string;\n gender: z.infer<typeof genderSchema> | null;\n bloodGroup: z.infer<typeof bloodGroupSchema> | '';\n avatarUrl: string;\n contacts: EmergencyContactRow[];\n /** Optional — a gym with no trainers yet, or none chosen. `''` for none. */\n trainerId: string;\n};\n\n// ─── Staff form ──────────────────────────────────────────────────────────────\n\n/**\n * Staff keep the address a member is no longer asked for — but not an ID proof.\n *\n * The address stays because this is an employment record: a gym holds one for\n * the people it EMPLOYS for reasons that have nothing to do with why it holds a\n * member's phone number. The ID upload went for the opposite reason — nothing\n * in the product ever showed it back, so it was a document collected and then\n * never looked at, which is the worst thing to ask anyone for.\n */\nexport const addStaffFormSchema = z\n .object({\n ...addPersonBaseShape,\n role: requiredChoice(staffRoleSchema, 'Select a staff role'),\n /**\n * The whole address, or null. Picked through the location drawer, which\n * hands back a complete `Address` — area chain, ids, names, ancestry,\n * coordinates — or nothing.\n */\n address: addressSchema.nullable(),\n })\n .superRefine((v, ctx) => {\n refineDob(v, ctx);\n });\n\nexport type AddStaffFormValues = Omit<AddMemberFormValues, 'trainerId'> & {\n role: z.infer<typeof staffRoleSchema> | null;\n address: Address | null;\n};\n\n// ─── Empty states ────────────────────────────────────────────────────────────\n\nconst EMPTY_BASE = {\n name: '',\n email: '',\n phone: '',\n dobDay: '',\n dobMonth: '',\n dobYear: '',\n gender: null,\n bloodGroup: '' as const,\n avatarUrl: '',\n} satisfies Omit<AddMemberFormValues, 'contacts' | 'trainerId'>;\n\n/** One blank row so the section renders with a contact to fill. */\nexport const EMPTY_EMERGENCY_CONTACT: EmergencyContactRow = {\n name: '',\n relationship: '',\n phone: '',\n};\n\nexport const EMPTY_ADD_MEMBER_FORM: AddMemberFormValues = {\n ...EMPTY_BASE,\n contacts: [{ ...EMPTY_EMERGENCY_CONTACT }],\n trainerId: '',\n};\n\nexport const EMPTY_ADD_STAFF_FORM: AddStaffFormValues = {\n ...EMPTY_BASE,\n contacts: [{ ...EMPTY_EMERGENCY_CONTACT }],\n role: null,\n address: null,\n};\n\n// ─── Form → API body ─────────────────────────────────────────────────────────\n\n/** One \"Name\" field on screen, `firstName` + `lastName` on the wire. */\nfunction splitName(value: string): { firstName: string; lastName?: string } {\n const parts = value.trim().split(/\\s+/).filter(Boolean);\n const lastName = parts.slice(1).join(' ');\n return { firstName: parts[0] ?? '', ...(lastName ? { lastName } : {}) };\n}\n\n/** Drop a blank optional so it reads as \"not provided\" rather than `''`. */\nfunction orUndefined(value: string): string | undefined {\n const trimmed = value.trim();\n return trimmed === '' ? undefined : trimmed;\n}\n\n/** Phones are STORED raw — strip any display formatting back to 10 digits. */\nfunction asPhone(value: string): string {\n return value.replace(/\\D/g, '').slice(-10);\n}\n\n/**\n * The fields EVERY desk form sends. Address and ID proof are not among them —\n * only two of the three forms ask for those, so each adds its own.\n */\nfunction sharedBody(v: Omit<AddMemberFormValues, 'trainerId'>) {\n // A row with nothing in it is not a contact. Anything else has already been\n // through `emergencyContactRowSchema`, which requires a name and a valid\n // phone the moment a row is touched.\n const emergencyContacts = v.contacts\n .filter((c) => c.name !== '' || c.relationship !== '' || c.phone !== '')\n .map((c) =>\n emergencyContactSchema.parse({\n name: c.name.trim(),\n phone: asPhone(c.phone),\n relationship: orUndefined(c.relationship),\n }),\n )\n .slice(0, MAX_EMERGENCY_CONTACTS);\n\n return {\n ...splitName(v.name),\n email: v.email.trim(),\n phone: asPhone(v.phone),\n // The form schema guarantees a choice was made before we get here.\n gender: v.gender ?? 'other',\n // Absent rather than empty when the desk did not record one — see\n // `isoFromDobCells`.\n dob: isoFromDobCells(v.dobDay, v.dobMonth, v.dobYear),\n bloodGroup: v.bloodGroup === '' ? undefined : v.bloodGroup,\n emergencyContacts,\n avatarUrl: orUndefined(v.avatarUrl),\n };\n}\n\n/**\n * Validated member form → `POST /members` body. `initialPlan` comes from the\n * membership step, which the form itself knows nothing about.\n */\nexport function toCreateMemberBody(\n values: AddMemberFormValues,\n initialPlan?: AssignMembershipBody,\n): CreateMemberBody {\n return {\n ...sharedBody(values),\n assignedTrainerId: orUndefined(values.trainerId),\n ...(initialPlan ? { initialPlan } : {}),\n };\n}\n\n/** Validated staff form → `POST /staff` body. */\nexport function toCreateStaffBody(values: AddStaffFormValues): CreateStaffBody {\n return {\n ...sharedBody(values),\n // The form schema guarantees a role was chosen.\n role: values.role ?? 'trainer',\n // Staff-only — see `addStaffFormSchema`. Already a complete `Address` or\n // null; the location drawer cannot produce anything in between.\n address: values.address ?? undefined,\n };\n}\n\n// ─── Edit member ─────────────────────────────────────────────────────────────\n\n/**\n * Editing a member reuses the add form's every rule, plus the Aadhaar last-four\n * the desk may not have taken at signup.\n *\n * It is a separate schema rather than the same one because the two forms differ\n * in what \"blank\" means. On the add form a blank optional is simply not\n * provided; on the edit form it is an instruction to CLEAR a value that is\n * already stored, and the mapper has to send `null` rather than omit the field.\n */\nexport const editMemberFormSchema = z\n .object({\n ...addPersonBaseShape,\n trainerId: z.string(),\n /** Blank when not recorded; exactly four digits otherwise. */\n aadhaarLast4: z\n .string()\n .trim()\n .refine((v) => v === '' || /^\\d{4}$/.test(v), 'Enter the last four digits'),\n /**\n * Address and ID proof are asked HERE and not on the add form.\n *\n * Adding somebody happens at a desk with a queue behind them; editing\n * happens later, once the gym actually holds the document. Dropping them\n * from EDIT as well would leave three fields the API stores, the detail\n * screen renders, and no screen anywhere can write.\n */\n address: addressSchema.nullable(),\n idProofUrl: z.string(),\n })\n .superRefine((v, ctx) => {\n refineDob(v, ctx);\n });\n\nexport type EditMemberFormValues = AddMemberFormValues & {\n aadhaarLast4: string;\n address: Address | null;\n idProofUrl: string;\n};\n\n/**\n * Validated edit form → `PATCH /members/:id` body.\n *\n * Sends every field, including the cleared ones as `null`, because the owner\n * emptying a field is an edit like any other. The four identity fields go\n * along too; the server drops them once the member has claimed their account.\n */\nexport function toUpdateMemberBody(values: EditMemberFormValues): UpdateMemberBody {\n const shared = sharedBody(values);\n return {\n ...shared,\n dob: shared.dob ?? null,\n bloodGroup: shared.bloodGroup ?? null,\n address: values.address,\n idProofUrl: values.idProofUrl.trim(),\n avatarUrl: values.avatarUrl.trim(),\n assignedTrainerId: orUndefined(values.trainerId) ?? null,\n aadhaarLast4: values.aadhaarLast4.trim() === '' ? null : values.aadhaarLast4.trim(),\n };\n}\n"]}
|
package/dist/center.d.ts
CHANGED
|
@@ -54,20 +54,20 @@ import { z } from 'zod';
|
|
|
54
54
|
*/
|
|
55
55
|
export declare const CENTER_TYPES: readonly ["gym", "strength", "crossfit", "functional", "bodybuilding", "powerlifting", "calisthenics", "cardio", "hiit", "spinning", "bootcamp", "aerobics", "sports-conditioning", "yoga", "pilates", "meditation", "zumba", "dance", "boxing", "kickboxing", "mma", "martial-arts", "swimming", "physiotherapy"];
|
|
56
56
|
export declare const centerTypeSchema: z.ZodEnum<{
|
|
57
|
-
|
|
57
|
+
gym: "gym";
|
|
58
58
|
strength: "strength";
|
|
59
|
-
yoga: "yoga";
|
|
60
59
|
crossfit: "crossfit";
|
|
61
|
-
gym: "gym";
|
|
62
60
|
functional: "functional";
|
|
63
61
|
bodybuilding: "bodybuilding";
|
|
64
62
|
powerlifting: "powerlifting";
|
|
65
63
|
calisthenics: "calisthenics";
|
|
64
|
+
cardio: "cardio";
|
|
66
65
|
hiit: "hiit";
|
|
67
66
|
spinning: "spinning";
|
|
68
67
|
bootcamp: "bootcamp";
|
|
69
68
|
aerobics: "aerobics";
|
|
70
69
|
"sports-conditioning": "sports-conditioning";
|
|
70
|
+
yoga: "yoga";
|
|
71
71
|
pilates: "pilates";
|
|
72
72
|
meditation: "meditation";
|
|
73
73
|
zumba: "zumba";
|
|
@@ -92,20 +92,20 @@ export declare const createCenterBodySchema: z.ZodObject<{
|
|
|
92
92
|
name: z.ZodString;
|
|
93
93
|
description: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
94
94
|
types: z.ZodArray<z.ZodEnum<{
|
|
95
|
-
|
|
95
|
+
gym: "gym";
|
|
96
96
|
strength: "strength";
|
|
97
|
-
yoga: "yoga";
|
|
98
97
|
crossfit: "crossfit";
|
|
99
|
-
gym: "gym";
|
|
100
98
|
functional: "functional";
|
|
101
99
|
bodybuilding: "bodybuilding";
|
|
102
100
|
powerlifting: "powerlifting";
|
|
103
101
|
calisthenics: "calisthenics";
|
|
102
|
+
cardio: "cardio";
|
|
104
103
|
hiit: "hiit";
|
|
105
104
|
spinning: "spinning";
|
|
106
105
|
bootcamp: "bootcamp";
|
|
107
106
|
aerobics: "aerobics";
|
|
108
107
|
"sports-conditioning": "sports-conditioning";
|
|
108
|
+
yoga: "yoga";
|
|
109
109
|
pilates: "pilates";
|
|
110
110
|
meditation: "meditation";
|
|
111
111
|
zumba: "zumba";
|
|
@@ -206,20 +206,20 @@ export declare const updateCenterBodySchema: z.ZodObject<{
|
|
|
206
206
|
name: z.ZodOptional<z.ZodString>;
|
|
207
207
|
description: z.ZodOptional<z.ZodPreprocess<z.ZodOptional<z.ZodString>>>;
|
|
208
208
|
types: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
209
|
-
|
|
209
|
+
gym: "gym";
|
|
210
210
|
strength: "strength";
|
|
211
|
-
yoga: "yoga";
|
|
212
211
|
crossfit: "crossfit";
|
|
213
|
-
gym: "gym";
|
|
214
212
|
functional: "functional";
|
|
215
213
|
bodybuilding: "bodybuilding";
|
|
216
214
|
powerlifting: "powerlifting";
|
|
217
215
|
calisthenics: "calisthenics";
|
|
216
|
+
cardio: "cardio";
|
|
218
217
|
hiit: "hiit";
|
|
219
218
|
spinning: "spinning";
|
|
220
219
|
bootcamp: "bootcamp";
|
|
221
220
|
aerobics: "aerobics";
|
|
222
221
|
"sports-conditioning": "sports-conditioning";
|
|
222
|
+
yoga: "yoga";
|
|
223
223
|
pilates: "pilates";
|
|
224
224
|
meditation: "meditation";
|
|
225
225
|
zumba: "zumba";
|
|
@@ -335,20 +335,20 @@ export declare const centerSchema: z.ZodObject<{
|
|
|
335
335
|
name: z.ZodString;
|
|
336
336
|
description: z.ZodNullable<z.ZodString>;
|
|
337
337
|
types: z.ZodArray<z.ZodEnum<{
|
|
338
|
-
|
|
338
|
+
gym: "gym";
|
|
339
339
|
strength: "strength";
|
|
340
|
-
yoga: "yoga";
|
|
341
340
|
crossfit: "crossfit";
|
|
342
|
-
gym: "gym";
|
|
343
341
|
functional: "functional";
|
|
344
342
|
bodybuilding: "bodybuilding";
|
|
345
343
|
powerlifting: "powerlifting";
|
|
346
344
|
calisthenics: "calisthenics";
|
|
345
|
+
cardio: "cardio";
|
|
347
346
|
hiit: "hiit";
|
|
348
347
|
spinning: "spinning";
|
|
349
348
|
bootcamp: "bootcamp";
|
|
350
349
|
aerobics: "aerobics";
|
|
351
350
|
"sports-conditioning": "sports-conditioning";
|
|
351
|
+
yoga: "yoga";
|
|
352
352
|
pilates: "pilates";
|
|
353
353
|
meditation: "meditation";
|
|
354
354
|
zumba: "zumba";
|
package/dist/equipment.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { z } from 'zod';
|
|
|
10
10
|
export declare const EQUIPMENT_CATEGORIES: readonly ["cardio", "strength", "weight", "training", "recovery", "custom"];
|
|
11
11
|
export declare const equipmentCategorySchema: z.ZodEnum<{
|
|
12
12
|
custom: "custom";
|
|
13
|
-
cardio: "cardio";
|
|
14
13
|
strength: "strength";
|
|
14
|
+
cardio: "cardio";
|
|
15
15
|
weight: "weight";
|
|
16
16
|
training: "training";
|
|
17
17
|
recovery: "recovery";
|
|
@@ -22,8 +22,8 @@ export declare const equipmentSchema: z.ZodObject<{
|
|
|
22
22
|
centerId: z.ZodString;
|
|
23
23
|
category: z.ZodEnum<{
|
|
24
24
|
custom: "custom";
|
|
25
|
-
cardio: "cardio";
|
|
26
25
|
strength: "strength";
|
|
26
|
+
cardio: "cardio";
|
|
27
27
|
weight: "weight";
|
|
28
28
|
training: "training";
|
|
29
29
|
recovery: "recovery";
|
|
@@ -39,8 +39,8 @@ export type Equipment = z.infer<typeof equipmentSchema>;
|
|
|
39
39
|
export declare const equipmentCategorySummarySchema: z.ZodObject<{
|
|
40
40
|
category: z.ZodEnum<{
|
|
41
41
|
custom: "custom";
|
|
42
|
-
cardio: "cardio";
|
|
43
42
|
strength: "strength";
|
|
43
|
+
cardio: "cardio";
|
|
44
44
|
weight: "weight";
|
|
45
45
|
training: "training";
|
|
46
46
|
recovery: "recovery";
|
|
@@ -53,8 +53,8 @@ export declare const createEquipmentBodySchema: z.ZodObject<{
|
|
|
53
53
|
centerId: z.ZodString;
|
|
54
54
|
category: z.ZodEnum<{
|
|
55
55
|
custom: "custom";
|
|
56
|
-
cardio: "cardio";
|
|
57
56
|
strength: "strength";
|
|
57
|
+
cardio: "cardio";
|
|
58
58
|
weight: "weight";
|
|
59
59
|
training: "training";
|
|
60
60
|
recovery: "recovery";
|
|
@@ -68,8 +68,8 @@ export declare const updateEquipmentBodySchema: z.ZodObject<{
|
|
|
68
68
|
name: z.ZodOptional<z.ZodString>;
|
|
69
69
|
category: z.ZodOptional<z.ZodEnum<{
|
|
70
70
|
custom: "custom";
|
|
71
|
-
cardio: "cardio";
|
|
72
71
|
strength: "strength";
|
|
72
|
+
cardio: "cardio";
|
|
73
73
|
weight: "weight";
|
|
74
74
|
training: "training";
|
|
75
75
|
recovery: "recovery";
|
|
@@ -101,8 +101,8 @@ export declare const EQUIPMENT_CATALOG: Record<EquipmentCategory, readonly strin
|
|
|
101
101
|
export declare const equipmentQuantityEntrySchema: z.ZodObject<{
|
|
102
102
|
category: z.ZodEnum<{
|
|
103
103
|
custom: "custom";
|
|
104
|
-
cardio: "cardio";
|
|
105
104
|
strength: "strength";
|
|
105
|
+
cardio: "cardio";
|
|
106
106
|
weight: "weight";
|
|
107
107
|
training: "training";
|
|
108
108
|
recovery: "recovery";
|
|
@@ -116,8 +116,8 @@ export declare const setEquipmentQuantitiesBodySchema: z.ZodObject<{
|
|
|
116
116
|
items: z.ZodArray<z.ZodObject<{
|
|
117
117
|
category: z.ZodEnum<{
|
|
118
118
|
custom: "custom";
|
|
119
|
-
cardio: "cardio";
|
|
120
119
|
strength: "strength";
|
|
120
|
+
cardio: "cardio";
|
|
121
121
|
weight: "weight";
|
|
122
122
|
training: "training";
|
|
123
123
|
recovery: "recovery";
|
|
@@ -131,8 +131,8 @@ export declare const equipmentQuerySchema: z.ZodObject<{
|
|
|
131
131
|
centerId: z.ZodString;
|
|
132
132
|
category: z.ZodOptional<z.ZodEnum<{
|
|
133
133
|
custom: "custom";
|
|
134
|
-
cardio: "cardio";
|
|
135
134
|
strength: "strength";
|
|
135
|
+
cardio: "cardio";
|
|
136
136
|
weight: "weight";
|
|
137
137
|
training: "training";
|
|
138
138
|
recovery: "recovery";
|
|
@@ -88,20 +88,20 @@ export declare const gymRegistrationBodySchema: z.ZodObject<{
|
|
|
88
88
|
name: z.ZodString;
|
|
89
89
|
description: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
90
90
|
types: z.ZodArray<z.ZodEnum<{
|
|
91
|
-
|
|
91
|
+
gym: "gym";
|
|
92
92
|
strength: "strength";
|
|
93
|
-
yoga: "yoga";
|
|
94
93
|
crossfit: "crossfit";
|
|
95
|
-
gym: "gym";
|
|
96
94
|
functional: "functional";
|
|
97
95
|
bodybuilding: "bodybuilding";
|
|
98
96
|
powerlifting: "powerlifting";
|
|
99
97
|
calisthenics: "calisthenics";
|
|
98
|
+
cardio: "cardio";
|
|
100
99
|
hiit: "hiit";
|
|
101
100
|
spinning: "spinning";
|
|
102
101
|
bootcamp: "bootcamp";
|
|
103
102
|
aerobics: "aerobics";
|
|
104
103
|
"sports-conditioning": "sports-conditioning";
|
|
104
|
+
yoga: "yoga";
|
|
105
105
|
pilates: "pilates";
|
|
106
106
|
meditation: "meditation";
|
|
107
107
|
zumba: "zumba";
|
package/dist/member.d.ts
CHANGED
|
@@ -32,12 +32,6 @@ export declare const memberRosterItemSchema: z.ZodObject<{
|
|
|
32
32
|
phone: z.ZodNullable<z.ZodString>;
|
|
33
33
|
email: z.ZodNullable<z.ZodEmail>;
|
|
34
34
|
planName: z.ZodNullable<z.ZodString>;
|
|
35
|
-
tier: z.ZodNullable<z.ZodEnum<{
|
|
36
|
-
free: "free";
|
|
37
|
-
basic: "basic";
|
|
38
|
-
standard: "standard";
|
|
39
|
-
premium: "premium";
|
|
40
|
-
}>>;
|
|
41
35
|
status: z.ZodNullable<z.ZodEnum<{
|
|
42
36
|
invited: "invited";
|
|
43
37
|
active: "active";
|
|
@@ -100,12 +94,6 @@ export declare const memberListQuerySchema: z.ZodObject<{
|
|
|
100
94
|
expiry: "expiry";
|
|
101
95
|
dues: "dues";
|
|
102
96
|
}>>;
|
|
103
|
-
tier: z.ZodOptional<z.ZodEnum<{
|
|
104
|
-
free: "free";
|
|
105
|
-
basic: "basic";
|
|
106
|
-
standard: "standard";
|
|
107
|
-
premium: "premium";
|
|
108
|
-
}>>;
|
|
109
97
|
q: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
110
98
|
}, z.core.$strip>;
|
|
111
99
|
export type MemberListQuery = z.infer<typeof memberListQuerySchema>;
|
|
@@ -206,20 +194,9 @@ export declare const memberDetailSchema: z.ZodObject<{
|
|
|
206
194
|
userId: z.ZodNullable<z.ZodString>;
|
|
207
195
|
centerId: z.ZodString;
|
|
208
196
|
planId: z.ZodString;
|
|
209
|
-
tier: z.ZodEnum<{
|
|
210
|
-
free: "free";
|
|
211
|
-
basic: "basic";
|
|
212
|
-
standard: "standard";
|
|
213
|
-
premium: "premium";
|
|
214
|
-
}>;
|
|
215
197
|
planName: z.ZodString;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"3m": "3m";
|
|
219
|
-
"6m": "6m";
|
|
220
|
-
"1y": "1y";
|
|
221
|
-
}>;
|
|
222
|
-
tenureLabel: z.ZodString;
|
|
198
|
+
variantId: z.ZodString;
|
|
199
|
+
variantLabel: z.ZodString;
|
|
223
200
|
priceInr: z.ZodNumber;
|
|
224
201
|
status: z.ZodEnum<{
|
|
225
202
|
invited: "invited";
|
|
@@ -306,12 +283,7 @@ export declare const createMemberBodySchema: z.ZodObject<{
|
|
|
306
283
|
assignedTrainerId: z.ZodOptional<z.ZodString>;
|
|
307
284
|
initialPlan: z.ZodOptional<z.ZodObject<{
|
|
308
285
|
planId: z.ZodString;
|
|
309
|
-
|
|
310
|
-
"1m": "1m";
|
|
311
|
-
"3m": "3m";
|
|
312
|
-
"6m": "6m";
|
|
313
|
-
"1y": "1y";
|
|
314
|
-
}>;
|
|
286
|
+
variantId: z.ZodString;
|
|
315
287
|
startDate: z.ZodOptional<z.ZodString>;
|
|
316
288
|
payment: z.ZodOptional<z.ZodObject<{
|
|
317
289
|
amountInr: z.ZodNumber;
|
|
@@ -450,20 +422,9 @@ export declare const provisionResultSchema: z.ZodObject<{
|
|
|
450
422
|
userId: z.ZodNullable<z.ZodString>;
|
|
451
423
|
centerId: z.ZodString;
|
|
452
424
|
planId: z.ZodString;
|
|
453
|
-
tier: z.ZodEnum<{
|
|
454
|
-
free: "free";
|
|
455
|
-
basic: "basic";
|
|
456
|
-
standard: "standard";
|
|
457
|
-
premium: "premium";
|
|
458
|
-
}>;
|
|
459
425
|
planName: z.ZodString;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
"3m": "3m";
|
|
463
|
-
"6m": "6m";
|
|
464
|
-
"1y": "1y";
|
|
465
|
-
}>;
|
|
466
|
-
tenureLabel: z.ZodString;
|
|
426
|
+
variantId: z.ZodString;
|
|
427
|
+
variantLabel: z.ZodString;
|
|
467
428
|
priceInr: z.ZodNumber;
|
|
468
429
|
status: z.ZodEnum<{
|
|
469
430
|
invited: "invited";
|
package/dist/member.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member.d.ts","sourceRoot":"","sources":["../src/member.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"member.d.ts","sourceRoot":"","sources":["../src/member.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsBxB,kDAAkD;AAClD,eAAO,MAAM,mBAAmB;;;;EAAyC,CAAC;AAC1E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAIhE,eAAO,MAAM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,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
|
@@ -13,7 +13,6 @@ import { isoDateSchema, isoDateTimeSchema, objectIdSchema, optionalTrimmedString
|
|
|
13
13
|
import { enrolmentStatusSchema } from './enrolment.js';
|
|
14
14
|
import { emergencyContactSchema, MAX_EMERGENCY_CONTACTS } from './member-profile.js';
|
|
15
15
|
import { assignMembershipBodySchema, membershipSchema, membershipStatusSchema, } from './membership.js';
|
|
16
|
-
import { planTierSchema } from './membership-plan.js';
|
|
17
16
|
import { addressSchema, bloodGroupSchema, genderSchema } from './shared.js';
|
|
18
17
|
// ─── Segments ────────────────────────────────────────────────────────────────
|
|
19
18
|
/** Attention buckets surfaced on roster cards. */
|
|
@@ -46,7 +45,6 @@ export const memberRosterItemSchema = z.object({
|
|
|
46
45
|
phone: z.string().nullable(),
|
|
47
46
|
email: z.email().nullable(),
|
|
48
47
|
planName: z.string().nullable(),
|
|
49
|
-
tier: planTierSchema.nullable(),
|
|
50
48
|
status: membershipStatusSchema.nullable(),
|
|
51
49
|
endDate: isoDateSchema.nullable(),
|
|
52
50
|
lastVisitAt: isoDateTimeSchema.nullable(),
|
|
@@ -88,7 +86,6 @@ export const memberListQuerySchema = paginationSchema.extend({
|
|
|
88
86
|
centerId: objectIdSchema.optional(),
|
|
89
87
|
filter: memberFilterSchema.default('all'),
|
|
90
88
|
sort: memberSortSchema.default('recent'),
|
|
91
|
-
tier: planTierSchema.optional(),
|
|
92
89
|
q: optionalTrimmedString(120),
|
|
93
90
|
});
|
|
94
91
|
// ─── Detail projection ───────────────────────────────────────────────────────
|