gymmonk-schema 0.8.0 → 0.9.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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/membership-request.d.ts +118 -0
- package/dist/membership-request.d.ts.map +1 -0
- package/dist/membership-request.js +79 -0
- package/dist/membership-request.js.map +1 -0
- package/dist/messages.d.ts +25 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +27 -0
- package/dist/messages.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from './member.js';
|
|
|
24
24
|
export * from './member-profile.js';
|
|
25
25
|
export * from './membership.js';
|
|
26
26
|
export * from './membership-plan.js';
|
|
27
|
+
export * from './membership-request.js';
|
|
27
28
|
export * from './messages.js';
|
|
28
29
|
export * from './notification.js';
|
|
29
30
|
export * from './onboarding.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,aAAa,CAAC;AAE5B,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,sBAAsB,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,aAAa,CAAC;AAE5B,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AAExC,cAAc,eAAe,CAAC;AAE9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,sBAAsB,CAAC;AAErC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export * from './member-profile.js';
|
|
|
32
32
|
export * from './membership.js';
|
|
33
33
|
// ─── Membership ──────────────────────────────────────────────────────────────
|
|
34
34
|
export * from './membership-plan.js';
|
|
35
|
+
export * from './membership-request.js';
|
|
35
36
|
// ─── API result messages + error codes ───────────────────────────────────────
|
|
36
37
|
export * from './messages.js';
|
|
37
38
|
// ─── Engagement & analytics ──────────────────────────────────────────────────
|
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,aAAa,CAAC;AAC5B,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,gFAAgF;AAChF,cAAc,sBAAsB,CAAC;AACrC,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,gFAAgF;AAChF,cAAc,sBAAsB,CAAC;AACrC,gFAAgF;AAChF,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,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 './center.js';\n// ─── Check-in QR (poster payload shared by owner, member and backend) ────────\nexport * from './check-in.js';\n// ─── Foundation ──────────────────────────────────────────────────────────────\nexport * from './common.js';\nexport * from './equipment.js';\n// ─── Training ────────────────────────────────────────────────────────────────\nexport * from './exercise.js';\nexport * from './feedback.js';\n// ─── Uploads ─────────────────────────────────────────────────────────────────\nexport * from './file.js';\nexport * from './home.js';\nexport * from './insights.js';\n// ─── People ──────────────────────────────────────────────────────────────────\nexport * from './member.js';\nexport * from './member-profile.js';\nexport * from './membership.js';\n// ─── Membership ──────────────────────────────────────────────────────────────\nexport * from './membership-plan.js';\n// ─── API result messages + error codes ───────────────────────────────────────\nexport * from './messages.js';\n// ─── Engagement & analytics ──────────────────────────────────────────────────\nexport * from './notification.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';\nexport * from './pricing.js';\nexport * from './session.js';\nexport * from './shared.js';\nexport * from './staff.js';\nexport * from './subscription.js';\nexport * from './user.js';\nexport * from './workout-plan.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gFAAgF;AAChF,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,6EAA6E;AAC7E,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,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,gFAAgF;AAChF,cAAc,eAAe,CAAC;AAC9B,gFAAgF;AAChF,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,gFAAgF;AAChF,cAAc,sBAAsB,CAAC;AACrC,gFAAgF;AAChF,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,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 './center.js';\n// ─── Check-in QR (poster payload shared by owner, member and backend) ────────\nexport * from './check-in.js';\n// ─── Foundation ──────────────────────────────────────────────────────────────\nexport * from './common.js';\nexport * from './equipment.js';\n// ─── Training ────────────────────────────────────────────────────────────────\nexport * from './exercise.js';\nexport * from './feedback.js';\n// ─── Uploads ─────────────────────────────────────────────────────────────────\nexport * from './file.js';\nexport * from './home.js';\nexport * from './insights.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';\n// ─── API result messages + error codes ───────────────────────────────────────\nexport * from './messages.js';\n// ─── Engagement & analytics ──────────────────────────────────────────────────\nexport * from './notification.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';\nexport * from './pricing.js';\nexport * from './session.js';\nexport * from './shared.js';\nexport * from './staff.js';\nexport * from './subscription.js';\nexport * from './user.js';\nexport * from './workout-plan.js';\n"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gymmonk-schema — Membership join requests
|
|
3
|
+
* ==========================================
|
|
4
|
+
* A member asking to join a gym, and the gym's decision on it.
|
|
5
|
+
*
|
|
6
|
+
* WHY THIS EXISTS
|
|
7
|
+
* A member picks a gym during onboarding, but picking is a CLAIM, not
|
|
8
|
+
* membership. Until someone at the gym (owner, manager or front desk) accepts,
|
|
9
|
+
* the person is not a member of that center and cannot check in. Without this
|
|
10
|
+
* step anyone could self-serve into any gym's roster and start marking
|
|
11
|
+
* attendance there.
|
|
12
|
+
*
|
|
13
|
+
* LIFECYCLE
|
|
14
|
+
* member selects gym → `pending`
|
|
15
|
+
* gym accepts → `approved` (member may now check in)
|
|
16
|
+
* gym declines → `rejected` (member may request again, or elsewhere)
|
|
17
|
+
* member cancels their plan → the approval is spent; a new request is needed
|
|
18
|
+
*
|
|
19
|
+
* A gym-CREATED member (the invite/claim path) never produces a request: the
|
|
20
|
+
* gym made the record, so it has already decided.
|
|
21
|
+
*
|
|
22
|
+
* This is a LOG, not a flag: one row per request, so a cancel-and-rejoin cycle
|
|
23
|
+
* leaves a trail and a rejection is not silently overwritten by the next
|
|
24
|
+
* attempt. The member's CURRENT standing is the latest row for that center.
|
|
25
|
+
*
|
|
26
|
+
* @module gymmonk-schema/membership-request
|
|
27
|
+
*/
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
export declare const membershipRequestStatusSchema: z.ZodEnum<{
|
|
30
|
+
pending: "pending";
|
|
31
|
+
approved: "approved";
|
|
32
|
+
rejected: "rejected";
|
|
33
|
+
}>;
|
|
34
|
+
export type MembershipRequestStatus = z.infer<typeof membershipRequestStatusSchema>;
|
|
35
|
+
export declare const membershipRequestSchema: z.ZodObject<{
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
userId: z.ZodString;
|
|
38
|
+
centerId: z.ZodString;
|
|
39
|
+
status: z.ZodEnum<{
|
|
40
|
+
pending: "pending";
|
|
41
|
+
approved: "approved";
|
|
42
|
+
rejected: "rejected";
|
|
43
|
+
}>;
|
|
44
|
+
requestedAt: z.ZodISODateTime;
|
|
45
|
+
decidedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
46
|
+
decidedBy: z.ZodNullable<z.ZodString>;
|
|
47
|
+
note: z.ZodNullable<z.ZodString>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export type MembershipRequest = z.infer<typeof membershipRequestSchema>;
|
|
50
|
+
/**
|
|
51
|
+
* A row in the gym's requests inbox: the request plus enough of the person to
|
|
52
|
+
* decide without opening each one.
|
|
53
|
+
*/
|
|
54
|
+
export declare const membershipRequestItemSchema: z.ZodObject<{
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
userId: z.ZodString;
|
|
57
|
+
centerId: z.ZodString;
|
|
58
|
+
status: z.ZodEnum<{
|
|
59
|
+
pending: "pending";
|
|
60
|
+
approved: "approved";
|
|
61
|
+
rejected: "rejected";
|
|
62
|
+
}>;
|
|
63
|
+
requestedAt: z.ZodISODateTime;
|
|
64
|
+
decidedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
65
|
+
decidedBy: z.ZodNullable<z.ZodString>;
|
|
66
|
+
note: z.ZodNullable<z.ZodString>;
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
email: z.ZodString;
|
|
69
|
+
phone: z.ZodNullable<z.ZodString>;
|
|
70
|
+
avatarUrl: z.ZodNullable<z.ZodString>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export type MembershipRequestItem = z.infer<typeof membershipRequestItemSchema>;
|
|
73
|
+
/**
|
|
74
|
+
* The member asks to join. Identified by the gym's PUBLIC code (`GYM-YYYY-NNN`)
|
|
75
|
+
* — that is what the member typed or picked during onboarding, and it keeps the
|
|
76
|
+
* center's Mongo id out of a member-facing request.
|
|
77
|
+
*/
|
|
78
|
+
export declare const createMembershipRequestBodySchema: z.ZodObject<{
|
|
79
|
+
gymCode: z.ZodString;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
export type CreateMembershipRequestBody = z.infer<typeof createMembershipRequestBodySchema>;
|
|
82
|
+
/** Accept or decline. The note is surfaced to the member on a decline. */
|
|
83
|
+
export declare const decideMembershipRequestBodySchema: z.ZodObject<{
|
|
84
|
+
note: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export type DecideMembershipRequestBody = z.infer<typeof decideMembershipRequestBodySchema>;
|
|
87
|
+
export declare const membershipRequestQuerySchema: z.ZodObject<{
|
|
88
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
89
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
90
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
91
|
+
pending: "pending";
|
|
92
|
+
approved: "approved";
|
|
93
|
+
rejected: "rejected";
|
|
94
|
+
}>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
export type MembershipRequestQuery = z.infer<typeof membershipRequestQuerySchema>;
|
|
97
|
+
/**
|
|
98
|
+
* What the member's own surfaces need: their standing at the gym they picked.
|
|
99
|
+
* `null` when they have never requested one.
|
|
100
|
+
*/
|
|
101
|
+
export declare const myMembershipRequestSchema: z.ZodNullable<z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
userId: z.ZodString;
|
|
104
|
+
centerId: z.ZodString;
|
|
105
|
+
status: z.ZodEnum<{
|
|
106
|
+
pending: "pending";
|
|
107
|
+
approved: "approved";
|
|
108
|
+
rejected: "rejected";
|
|
109
|
+
}>;
|
|
110
|
+
requestedAt: z.ZodISODateTime;
|
|
111
|
+
decidedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
112
|
+
decidedBy: z.ZodNullable<z.ZodString>;
|
|
113
|
+
note: z.ZodNullable<z.ZodString>;
|
|
114
|
+
centerName: z.ZodString;
|
|
115
|
+
gymCode: z.ZodString;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
export type MyMembershipRequest = z.infer<typeof myMembershipRequestSchema>;
|
|
118
|
+
//# sourceMappingURL=membership-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership-request.d.ts","sourceRoot":"","sources":["../src/membership-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,6BAA6B;;;;EAA8C,CAAC;AACzF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAIpF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;iBAYlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;iBAKtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAIhF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC;;iBAE5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F,0EAA0E;AAC1E,eAAO,MAAM,iCAAiC;;iBAE5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F,eAAO,MAAM,4BAA4B;;;;;;;;iBAEvC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;kBAEzB,CAAC;AACd,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gymmonk-schema — Membership join requests
|
|
3
|
+
* ==========================================
|
|
4
|
+
* A member asking to join a gym, and the gym's decision on it.
|
|
5
|
+
*
|
|
6
|
+
* WHY THIS EXISTS
|
|
7
|
+
* A member picks a gym during onboarding, but picking is a CLAIM, not
|
|
8
|
+
* membership. Until someone at the gym (owner, manager or front desk) accepts,
|
|
9
|
+
* the person is not a member of that center and cannot check in. Without this
|
|
10
|
+
* step anyone could self-serve into any gym's roster and start marking
|
|
11
|
+
* attendance there.
|
|
12
|
+
*
|
|
13
|
+
* LIFECYCLE
|
|
14
|
+
* member selects gym → `pending`
|
|
15
|
+
* gym accepts → `approved` (member may now check in)
|
|
16
|
+
* gym declines → `rejected` (member may request again, or elsewhere)
|
|
17
|
+
* member cancels their plan → the approval is spent; a new request is needed
|
|
18
|
+
*
|
|
19
|
+
* A gym-CREATED member (the invite/claim path) never produces a request: the
|
|
20
|
+
* gym made the record, so it has already decided.
|
|
21
|
+
*
|
|
22
|
+
* This is a LOG, not a flag: one row per request, so a cancel-and-rejoin cycle
|
|
23
|
+
* leaves a trail and a rejection is not silently overwritten by the next
|
|
24
|
+
* attempt. The member's CURRENT standing is the latest row for that center.
|
|
25
|
+
*
|
|
26
|
+
* @module gymmonk-schema/membership-request
|
|
27
|
+
*/
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
import { isoDateTimeSchema, objectIdSchema, optionalTrimmedString, paginationSchema, } from './common.js';
|
|
30
|
+
// ─── Status ──────────────────────────────────────────────────────────────────
|
|
31
|
+
export const membershipRequestStatusSchema = z.enum(['pending', 'approved', 'rejected']);
|
|
32
|
+
// ─── Entity ──────────────────────────────────────────────────────────────────
|
|
33
|
+
export const membershipRequestSchema = z.object({
|
|
34
|
+
id: objectIdSchema,
|
|
35
|
+
userId: objectIdSchema,
|
|
36
|
+
centerId: objectIdSchema,
|
|
37
|
+
status: membershipRequestStatusSchema,
|
|
38
|
+
requestedAt: isoDateTimeSchema,
|
|
39
|
+
/** Null while pending. */
|
|
40
|
+
decidedAt: isoDateTimeSchema.nullable(),
|
|
41
|
+
/** The staff user who accepted or declined. Null while pending. */
|
|
42
|
+
decidedBy: objectIdSchema.nullable(),
|
|
43
|
+
/** Optional reason shown to the member on a rejection. */
|
|
44
|
+
note: z.string().nullable(),
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* A row in the gym's requests inbox: the request plus enough of the person to
|
|
48
|
+
* decide without opening each one.
|
|
49
|
+
*/
|
|
50
|
+
export const membershipRequestItemSchema = membershipRequestSchema.extend({
|
|
51
|
+
name: z.string(),
|
|
52
|
+
email: z.string(),
|
|
53
|
+
phone: z.string().nullable(),
|
|
54
|
+
avatarUrl: z.string().nullable(),
|
|
55
|
+
});
|
|
56
|
+
// ─── Requests ────────────────────────────────────────────────────────────────
|
|
57
|
+
/**
|
|
58
|
+
* The member asks to join. Identified by the gym's PUBLIC code (`GYM-YYYY-NNN`)
|
|
59
|
+
* — that is what the member typed or picked during onboarding, and it keeps the
|
|
60
|
+
* center's Mongo id out of a member-facing request.
|
|
61
|
+
*/
|
|
62
|
+
export const createMembershipRequestBodySchema = z.object({
|
|
63
|
+
gymCode: z.string().trim().min(1),
|
|
64
|
+
});
|
|
65
|
+
/** Accept or decline. The note is surfaced to the member on a decline. */
|
|
66
|
+
export const decideMembershipRequestBodySchema = z.object({
|
|
67
|
+
note: optionalTrimmedString(300),
|
|
68
|
+
});
|
|
69
|
+
export const membershipRequestQuerySchema = paginationSchema.extend({
|
|
70
|
+
status: membershipRequestStatusSchema.optional(),
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* What the member's own surfaces need: their standing at the gym they picked.
|
|
74
|
+
* `null` when they have never requested one.
|
|
75
|
+
*/
|
|
76
|
+
export const myMembershipRequestSchema = membershipRequestSchema
|
|
77
|
+
.extend({ centerName: z.string(), gymCode: z.string() })
|
|
78
|
+
.nullable();
|
|
79
|
+
//# sourceMappingURL=membership-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership-request.js","sourceRoot":"","sources":["../src/membership-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AAGzF,gFAAgF;AAEhF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,EAAE,EAAE,cAAc;IAClB,MAAM,EAAE,cAAc;IACtB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,6BAA6B;IACrC,WAAW,EAAE,iBAAiB;IAC9B,0BAA0B;IAC1B,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE;IACvC,mEAAmE;IACnE,SAAS,EAAE,cAAc,CAAC,QAAQ,EAAE;IACpC,0DAA0D;IAC1D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAGH;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC,MAAM,CAAC;IACxE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAGH,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAClC,CAAC,CAAC;AAGH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,IAAI,EAAE,qBAAqB,CAAC,GAAG,CAAC;CACjC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,4BAA4B,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAClE,MAAM,EAAE,6BAA6B,CAAC,QAAQ,EAAE;CACjD,CAAC,CAAC;AAGH;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB;KAC7D,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;KACvD,QAAQ,EAAE,CAAC","sourcesContent":["/**\n * gymmonk-schema — Membership join requests\n * ==========================================\n * A member asking to join a gym, and the gym's decision on it.\n *\n * WHY THIS EXISTS\n * A member picks a gym during onboarding, but picking is a CLAIM, not\n * membership. Until someone at the gym (owner, manager or front desk) accepts,\n * the person is not a member of that center and cannot check in. Without this\n * step anyone could self-serve into any gym's roster and start marking\n * attendance there.\n *\n * LIFECYCLE\n * member selects gym → `pending`\n * gym accepts → `approved` (member may now check in)\n * gym declines → `rejected` (member may request again, or elsewhere)\n * member cancels their plan → the approval is spent; a new request is needed\n *\n * A gym-CREATED member (the invite/claim path) never produces a request: the\n * gym made the record, so it has already decided.\n *\n * This is a LOG, not a flag: one row per request, so a cancel-and-rejoin cycle\n * leaves a trail and a rejection is not silently overwritten by the next\n * attempt. The member's CURRENT standing is the latest row for that center.\n *\n * @module gymmonk-schema/membership-request\n */\n\nimport { z } from 'zod';\nimport {\n isoDateTimeSchema,\n objectIdSchema,\n optionalTrimmedString,\n paginationSchema,\n} from './common.js';\n\n// ─── Status ──────────────────────────────────────────────────────────────────\n\nexport const membershipRequestStatusSchema = z.enum(['pending', 'approved', 'rejected']);\nexport type MembershipRequestStatus = z.infer<typeof membershipRequestStatusSchema>;\n\n// ─── Entity ──────────────────────────────────────────────────────────────────\n\nexport const membershipRequestSchema = z.object({\n id: objectIdSchema,\n userId: objectIdSchema,\n centerId: objectIdSchema,\n status: membershipRequestStatusSchema,\n requestedAt: isoDateTimeSchema,\n /** Null while pending. */\n decidedAt: isoDateTimeSchema.nullable(),\n /** The staff user who accepted or declined. Null while pending. */\n decidedBy: objectIdSchema.nullable(),\n /** Optional reason shown to the member on a rejection. */\n note: z.string().nullable(),\n});\nexport type MembershipRequest = z.infer<typeof membershipRequestSchema>;\n\n/**\n * A row in the gym's requests inbox: the request plus enough of the person to\n * decide without opening each one.\n */\nexport const membershipRequestItemSchema = membershipRequestSchema.extend({\n name: z.string(),\n email: z.string(),\n phone: z.string().nullable(),\n avatarUrl: z.string().nullable(),\n});\nexport type MembershipRequestItem = z.infer<typeof membershipRequestItemSchema>;\n\n// ─── Requests ────────────────────────────────────────────────────────────────\n\n/**\n * The member asks to join. Identified by the gym's PUBLIC code (`GYM-YYYY-NNN`)\n * — that is what the member typed or picked during onboarding, and it keeps the\n * center's Mongo id out of a member-facing request.\n */\nexport const createMembershipRequestBodySchema = z.object({\n gymCode: z.string().trim().min(1),\n});\nexport type CreateMembershipRequestBody = z.infer<typeof createMembershipRequestBodySchema>;\n\n/** Accept or decline. The note is surfaced to the member on a decline. */\nexport const decideMembershipRequestBodySchema = z.object({\n note: optionalTrimmedString(300),\n});\nexport type DecideMembershipRequestBody = z.infer<typeof decideMembershipRequestBodySchema>;\n\nexport const membershipRequestQuerySchema = paginationSchema.extend({\n status: membershipRequestStatusSchema.optional(),\n});\nexport type MembershipRequestQuery = z.infer<typeof membershipRequestQuerySchema>;\n\n/**\n * What the member's own surfaces need: their standing at the gym they picked.\n * `null` when they have never requested one.\n */\nexport const myMembershipRequestSchema = membershipRequestSchema\n .extend({ centerName: z.string(), gymCode: z.string() })\n .nullable();\nexport type MyMembershipRequest = z.infer<typeof myMembershipRequestSchema>;\n"]}
|
package/dist/messages.d.ts
CHANGED
|
@@ -112,6 +112,18 @@ export declare const SUCCESS_MESSAGE: {
|
|
|
112
112
|
readonly title: "New QR generated";
|
|
113
113
|
readonly description: "Print it and replace the old poster.";
|
|
114
114
|
};
|
|
115
|
+
readonly membershipRequestSent: {
|
|
116
|
+
readonly title: "Request sent";
|
|
117
|
+
readonly description: "The gym will review it shortly.";
|
|
118
|
+
};
|
|
119
|
+
readonly membershipRequestApproved: {
|
|
120
|
+
readonly title: "Member approved";
|
|
121
|
+
readonly description: "They can now check in at your gym.";
|
|
122
|
+
};
|
|
123
|
+
readonly membershipRequestRejected: {
|
|
124
|
+
readonly title: "Request declined";
|
|
125
|
+
readonly description: "The member has been told.";
|
|
126
|
+
};
|
|
115
127
|
readonly feedbackSubmitted: {
|
|
116
128
|
readonly title: "Feedback sent";
|
|
117
129
|
readonly description: "Thank you for helping us improve.";
|
|
@@ -188,6 +200,19 @@ export declare const ERROR_MESSAGE: {
|
|
|
188
200
|
/** Manual entry only accepts a full, well-formed code. */
|
|
189
201
|
readonly checkInCodeInvalid: "Enter the 16-character code printed under the QR.";
|
|
190
202
|
readonly checkInQrRotateFailed: "Could not generate a new QR. Please try again.";
|
|
203
|
+
/** Scanned a valid poster, but the gym has not accepted this member yet. */
|
|
204
|
+
readonly membershipNotApproved: "Your gym has not accepted your join request yet. You can check in once they do.";
|
|
205
|
+
/** Accepted, but with no live plan — check-in needs both. */
|
|
206
|
+
readonly membershipNotActive: "Your membership plan is not active. Renew it to start checking in again.";
|
|
207
|
+
/** A second request while one is already open. */
|
|
208
|
+
readonly membershipRequestPending: "You already have a request waiting with this gym.";
|
|
209
|
+
/** Requesting a gym they are already an accepted member of. */
|
|
210
|
+
readonly membershipRequestAlreadyMember: "You are already a member of this gym.";
|
|
211
|
+
readonly membershipRequestNotFound: "That join request no longer exists.";
|
|
212
|
+
/** Two staff acting on the same request; the second one loses. */
|
|
213
|
+
readonly membershipRequestAlreadyDecided: "Someone has already answered this request.";
|
|
214
|
+
readonly membershipRequestFailed: "Could not send your request. Please try again.";
|
|
215
|
+
readonly gymCodeUnknown: "No gym found with that id. Check it with your gym.";
|
|
191
216
|
readonly cameraDenied: "Camera access is blocked. Allow it in your browser settings to scan.";
|
|
192
217
|
readonly cameraUnavailable: "No camera found on this device. Enter the code printed under the QR.";
|
|
193
218
|
readonly cameraInsecure: "Scanning needs a secure (https) connection.";
|
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;;;;;;;;;;;;;;;CAwBb,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;C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AAM,iBAAiB;8BACX,MAAM,KAAG,MAAM;IAChC,2DAA2D;sCAClC,MAAM,KAAG,MAAM;CAEhC,CAAC"}
|
package/dist/messages.js
CHANGED
|
@@ -82,6 +82,19 @@ export const SUCCESS_MESSAGE = {
|
|
|
82
82
|
title: 'New QR generated',
|
|
83
83
|
description: 'Print it and replace the old poster.',
|
|
84
84
|
},
|
|
85
|
+
// Membership join requests
|
|
86
|
+
membershipRequestSent: {
|
|
87
|
+
title: 'Request sent',
|
|
88
|
+
description: 'The gym will review it shortly.',
|
|
89
|
+
},
|
|
90
|
+
membershipRequestApproved: {
|
|
91
|
+
title: 'Member approved',
|
|
92
|
+
description: 'They can now check in at your gym.',
|
|
93
|
+
},
|
|
94
|
+
membershipRequestRejected: {
|
|
95
|
+
title: 'Request declined',
|
|
96
|
+
description: 'The member has been told.',
|
|
97
|
+
},
|
|
85
98
|
// Engagement
|
|
86
99
|
feedbackSubmitted: { title: 'Feedback sent', description: 'Thank you for helping us improve.' },
|
|
87
100
|
complaintSubmitted: { title: 'Complaint submitted', description: 'Your gym will look into it.' },
|
|
@@ -162,6 +175,20 @@ export const ERROR_MESSAGE = {
|
|
|
162
175
|
/** Manual entry only accepts a full, well-formed code. */
|
|
163
176
|
checkInCodeInvalid: 'Enter the 16-character code printed under the QR.',
|
|
164
177
|
checkInQrRotateFailed: 'Could not generate a new QR. Please try again.',
|
|
178
|
+
// ── Membership join requests ───────────────────────────────────────────────
|
|
179
|
+
/** Scanned a valid poster, but the gym has not accepted this member yet. */
|
|
180
|
+
membershipNotApproved: 'Your gym has not accepted your join request yet. You can check in once they do.',
|
|
181
|
+
/** Accepted, but with no live plan — check-in needs both. */
|
|
182
|
+
membershipNotActive: 'Your membership plan is not active. Renew it to start checking in again.',
|
|
183
|
+
/** A second request while one is already open. */
|
|
184
|
+
membershipRequestPending: 'You already have a request waiting with this gym.',
|
|
185
|
+
/** Requesting a gym they are already an accepted member of. */
|
|
186
|
+
membershipRequestAlreadyMember: 'You are already a member of this gym.',
|
|
187
|
+
membershipRequestNotFound: 'That join request no longer exists.',
|
|
188
|
+
/** Two staff acting on the same request; the second one loses. */
|
|
189
|
+
membershipRequestAlreadyDecided: 'Someone has already answered this request.',
|
|
190
|
+
membershipRequestFailed: 'Could not send your request. Please try again.',
|
|
191
|
+
gymCodeUnknown: 'No gym found with that id. Check it with your gym.',
|
|
165
192
|
// Camera (QR scanning)
|
|
166
193
|
cameraDenied: 'Camera access is blocked. Allow it in your browser settings to scan.',
|
|
167
194
|
cameraUnavailable: 'No camera found on this device. Enter the code printed under the QR.',
|
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,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,EAAE,qBAAqB;IAE1C,oCAAoC;IACpC,mBAAmB,EAAE,qBAAqB;CAClC,CAAC;AAYX,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,aAAa;IACb,wBAAwB,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,qBAAqB,EAAE;IACzF,uBAAuB,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,W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AAC;AAI5C,iDAAiD;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,CAAC,GAAW,EAAU,EAAE,CAAC,qBAAqB,GAAG,SAAS;IACrE,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 // 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: { title: \"You're all set\", description: 'Welcome to GymMonk.' },\n ownerOnboardingComplete: { title: 'Your gym is ready', description: 'Welcome to GymMonk.' },\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\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 workoutCreated: { title: 'Workout created' },\n workoutPlanAssigned: { title: 'Workout plan assigned' },\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 // Engagement\n feedbackSubmitted: { title: 'Feedback sent', description: 'Thank you for helping us improve.' },\n complaintSubmitted: { title: 'Complaint submitted', description: 'Your gym will look into it.' },\n announcementSent: { title: 'Announcement sent' },\n announcementScheduled: { title: 'Announcement scheduled' },\n announcementDraftSaved: { title: 'Draft saved' },\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} 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} 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 memberOnboardingFailed: 'We could not save your details. Please try again.',\n ownerOnboardingFailed: 'We could not create your gym. Please try again.',\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 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\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 // Training\n workoutPlanRequired: 'Choose a plan to assign',\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 // Camera (QR scanning)\n cameraDenied: 'Camera access is blocked. Allow it in your browser settings to scan.',\n cameraUnavailable: 'No camera found on this device. Enter the code printed under the QR.',\n cameraInsecure: 'Scanning needs a secure (https) connection.',\n cameraFailed: 'Could not start the camera. Enter the code printed under the QR.',\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 /** 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,EAAE,qBAAqB;IAE1C,oCAAoC;IACpC,mBAAmB,EAAE,qBAAqB;CAClC,CAAC;AAYX,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,aAAa;IACb,wBAAwB,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,qBAAqB,EAAE;IACzF,uBAAuB,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,qBAAqB,EAAE;IAC3F,sEAAsE;IACtE,mBAAmB,E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C;IAC7E,uBAAuB,EAAE,gDAAgD;IACzE,cAAc,EAAE,oDAAoD;IAEpE,uBAAuB;IACvB,YAAY,EAAE,sEAAsE;IACpF,iBAAiB,EAAE,sEAAsE;IACzF,cAAc,EAAE,6CAA6C;IAC7D,YAAY,EAAE,kEAAkE;IAEhF,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,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 // 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: { title: \"You're all set\", description: 'Welcome to GymMonk.' },\n ownerOnboardingComplete: { title: 'Your gym is ready', description: 'Welcome to GymMonk.' },\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\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 workoutCreated: { title: 'Workout created' },\n workoutPlanAssigned: { title: 'Workout plan assigned' },\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 // Engagement\n feedbackSubmitted: { title: 'Feedback sent', description: 'Thank you for helping us improve.' },\n complaintSubmitted: { title: 'Complaint submitted', description: 'Your gym will look into it.' },\n announcementSent: { title: 'Announcement sent' },\n announcementScheduled: { title: 'Announcement scheduled' },\n announcementDraftSaved: { title: 'Draft saved' },\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} 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} 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 memberOnboardingFailed: 'We could not save your details. Please try again.',\n ownerOnboardingFailed: 'We could not create your gym. Please try again.',\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 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\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 // Training\n workoutPlanRequired: 'Choose a plan to assign',\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 // ── 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:\n '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 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\n // Camera (QR scanning)\n cameraDenied: 'Camera access is blocked. Allow it in your browser settings to scan.',\n cameraUnavailable: 'No camera found on this device. Enter the code printed under the QR.',\n cameraInsecure: 'Scanning needs a secure (https) connection.',\n cameraFailed: 'Could not start the camera. Enter the code printed under the QR.',\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 /** 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gymmonk-schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|