@athos-sdk/api-types 1.0.0 → 2.0.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.mjs CHANGED
@@ -24,9 +24,429 @@ var ExpertRole = /* @__PURE__ */ ((ExpertRole2) => {
24
24
  ExpertRole2["DIETITIAN"] = "DIETITIAN";
25
25
  return ExpertRole2;
26
26
  })(ExpertRole || {});
27
+
28
+ // src/routes.ts
29
+ var ROUTES = {
30
+ // App
31
+ health: "/",
32
+ // Auth
33
+ auth: {
34
+ register: "/auth/register",
35
+ login: "/auth/login",
36
+ deleteMe: "/auth/me"
37
+ },
38
+ // Members
39
+ members: {
40
+ join: "/members/join",
41
+ me: "/members/me",
42
+ meStats: "/members/me/stats"
43
+ },
44
+ // Check-ins
45
+ checkIns: {
46
+ create: "/check-ins"
47
+ },
48
+ // Leaderboards
49
+ leaderboards: {
50
+ list: "/leaderboards",
51
+ create: "/leaderboards",
52
+ submitEntry: "/leaderboards/entries",
53
+ reviewEntry: "/leaderboards/entries/review"
54
+ },
55
+ // Challenges
56
+ challenges: {
57
+ create: "/challenges",
58
+ createOccurrence: "/challenges/occurrences",
59
+ meActive: "/challenges/me/active",
60
+ join: "/challenges/join",
61
+ complete: "/challenges/complete"
62
+ },
63
+ // Bookings
64
+ bookings: {
65
+ create: "/bookings",
66
+ updateStatus: "/bookings/status",
67
+ meMember: "/bookings/me/member",
68
+ meExpert: "/bookings/me/expert"
69
+ },
70
+ // Rewards
71
+ rewards: {
72
+ list: "/rewards",
73
+ me: "/rewards/me"
74
+ },
75
+ // Experts
76
+ experts: {
77
+ list: "/experts",
78
+ me: "/experts/me",
79
+ availability: (id) => `/experts/${id}/availability`,
80
+ meAvailability: "/experts/me/availability",
81
+ meAvailabilityExceptions: "/experts/me/availability-exceptions"
82
+ },
83
+ // Notifications
84
+ notifications: {
85
+ me: "/notifications/me",
86
+ meReadAll: "/notifications/me/read-all"
87
+ },
88
+ // Activities
89
+ activities: {
90
+ me: "/activities/me"
91
+ },
92
+ // Media
93
+ media: {
94
+ upload: "/media",
95
+ delete: (id) => `/media/${id}`
96
+ },
97
+ // Admin
98
+ admin: {
99
+ summary: "/admin/summary",
100
+ gym: "/admin/gym",
101
+ members: "/admin/members",
102
+ createMember: "/admin/members",
103
+ rewards: "/admin/rewards",
104
+ createReward: "/admin/rewards",
105
+ rewardById: (id) => `/admin/rewards/${id}`,
106
+ staff: "/admin/staff",
107
+ createStaff: "/admin/staff",
108
+ staffByUserId: (userId) => `/admin/staff/${userId}`,
109
+ staffDisable: (userId) => `/admin/staff/${userId}/disable`,
110
+ staffEnable: (userId) => `/admin/staff/${userId}/enable`,
111
+ experts: "/admin/experts",
112
+ createExpert: "/admin/experts",
113
+ expertByUserId: (userId) => `/admin/experts/${userId}`,
114
+ expertDisable: (userId) => `/admin/experts/${userId}/disable`,
115
+ expertEnable: (userId) => `/admin/experts/${userId}/enable`
116
+ }
117
+ };
118
+
119
+ // src/api-routes.ts
120
+ var auth = {
121
+ register: {
122
+ method: "POST",
123
+ path: "/auth/register",
124
+ _req: void 0,
125
+ _res: void 0
126
+ },
127
+ login: {
128
+ method: "POST",
129
+ path: "/auth/login",
130
+ _req: void 0,
131
+ _res: void 0
132
+ },
133
+ deleteMe: {
134
+ method: "DELETE",
135
+ path: "/auth/me"
136
+ }
137
+ };
138
+ var members = {
139
+ join: {
140
+ method: "POST",
141
+ path: "/members/join",
142
+ _req: void 0,
143
+ _res: void 0
144
+ },
145
+ me: {
146
+ method: "GET",
147
+ path: "/members/me"
148
+ },
149
+ updateMe: {
150
+ method: "PATCH",
151
+ path: "/members/me",
152
+ _req: void 0,
153
+ _res: void 0
154
+ },
155
+ meStats: {
156
+ method: "GET",
157
+ path: "/members/me/stats"
158
+ }
159
+ };
160
+ var checkIns = {
161
+ create: {
162
+ method: "POST",
163
+ path: "/check-ins",
164
+ _req: void 0,
165
+ _res: void 0
166
+ }
167
+ };
168
+ var leaderboards = {
169
+ list: {
170
+ method: "GET",
171
+ path: "/leaderboards"
172
+ },
173
+ create: {
174
+ method: "POST",
175
+ path: "/leaderboards",
176
+ _req: void 0,
177
+ _res: void 0
178
+ },
179
+ submitEntry: {
180
+ method: "POST",
181
+ path: "/leaderboards/entries",
182
+ _req: void 0,
183
+ _res: void 0
184
+ // entry type if needed
185
+ },
186
+ reviewEntry: {
187
+ method: "POST",
188
+ path: "/leaderboards/entries/review",
189
+ _req: void 0,
190
+ _res: void 0
191
+ }
192
+ };
193
+ var challenges = {
194
+ create: {
195
+ method: "POST",
196
+ path: "/challenges",
197
+ _req: void 0,
198
+ _res: void 0
199
+ },
200
+ createOccurrence: {
201
+ method: "POST",
202
+ path: "/challenges/occurrences",
203
+ _req: void 0,
204
+ _res: void 0
205
+ },
206
+ meActive: {
207
+ method: "GET",
208
+ path: "/challenges/me/active"
209
+ },
210
+ join: {
211
+ method: "POST",
212
+ path: "/challenges/join",
213
+ _req: void 0,
214
+ _res: void 0
215
+ },
216
+ complete: {
217
+ method: "POST",
218
+ path: "/challenges/complete",
219
+ _req: void 0,
220
+ _res: void 0
221
+ }
222
+ };
223
+ var bookings = {
224
+ create: {
225
+ method: "POST",
226
+ path: "/bookings",
227
+ _req: void 0,
228
+ _res: void 0
229
+ },
230
+ updateStatus: {
231
+ method: "POST",
232
+ path: "/bookings/status",
233
+ _req: void 0,
234
+ _res: void 0
235
+ },
236
+ meMember: {
237
+ method: "GET",
238
+ path: "/bookings/me/member"
239
+ },
240
+ meExpert: {
241
+ method: "GET",
242
+ path: "/bookings/me/expert"
243
+ }
244
+ };
245
+ var rewards = {
246
+ list: {
247
+ method: "GET",
248
+ path: "/rewards"
249
+ },
250
+ me: {
251
+ method: "GET",
252
+ path: "/rewards/me"
253
+ }
254
+ };
255
+ var experts = {
256
+ list: {
257
+ method: "GET",
258
+ path: "/experts"
259
+ },
260
+ me: {
261
+ method: "GET",
262
+ path: "/experts/me"
263
+ },
264
+ availability: (id) => ({
265
+ method: "GET",
266
+ path: `/experts/${id}/availability`,
267
+ _res: void 0
268
+ }),
269
+ meAvailability: {
270
+ method: "POST",
271
+ path: "/experts/me/availability",
272
+ _req: void 0,
273
+ _res: void 0
274
+ },
275
+ meAvailabilityExceptions: {
276
+ method: "POST",
277
+ path: "/experts/me/availability-exceptions",
278
+ _req: void 0,
279
+ _res: void 0
280
+ }
281
+ };
282
+ var notifications = {
283
+ me: {
284
+ method: "GET",
285
+ path: "/notifications/me"
286
+ },
287
+ meReadAll: {
288
+ method: "POST",
289
+ path: "/notifications/me/read-all"
290
+ }
291
+ };
292
+ var activities = {
293
+ me: {
294
+ method: "GET",
295
+ path: "/activities/me"
296
+ }
297
+ };
298
+ var media = {
299
+ upload: {
300
+ method: "POST",
301
+ path: "/media",
302
+ // FormData in practice; body type left as unknown for file upload
303
+ _res: void 0
304
+ },
305
+ delete: (id) => ({
306
+ method: "DELETE",
307
+ path: `/media/${id}`
308
+ })
309
+ };
310
+ var admin = {
311
+ summary: {
312
+ method: "GET",
313
+ path: "/admin/summary"
314
+ },
315
+ gym: {
316
+ method: "GET",
317
+ path: "/admin/gym"
318
+ },
319
+ updateGym: {
320
+ method: "PATCH",
321
+ path: "/admin/gym",
322
+ _req: void 0,
323
+ _res: void 0
324
+ },
325
+ members: {
326
+ method: "GET",
327
+ path: "/admin/members"
328
+ },
329
+ createMember: {
330
+ method: "POST",
331
+ path: "/admin/members",
332
+ _req: void 0,
333
+ _res: void 0
334
+ },
335
+ rewards: {
336
+ method: "GET",
337
+ path: "/admin/rewards"
338
+ },
339
+ createReward: {
340
+ method: "POST",
341
+ path: "/admin/rewards",
342
+ _req: void 0,
343
+ _res: void 0
344
+ },
345
+ updateReward: (id) => ({
346
+ method: "PATCH",
347
+ path: `/admin/rewards/${id}`,
348
+ _req: void 0,
349
+ _res: void 0
350
+ }),
351
+ deleteReward: (id) => ({
352
+ method: "DELETE",
353
+ path: `/admin/rewards/${id}`
354
+ }),
355
+ staff: {
356
+ method: "GET",
357
+ path: "/admin/staff"
358
+ },
359
+ createStaff: {
360
+ method: "POST",
361
+ path: "/admin/staff",
362
+ _req: void 0,
363
+ _res: void 0
364
+ },
365
+ deleteStaff: (userId) => ({
366
+ method: "DELETE",
367
+ path: `/admin/staff/${userId}`
368
+ }),
369
+ disableStaff: (userId) => ({
370
+ method: "PATCH",
371
+ path: `/admin/staff/${userId}/disable`
372
+ }),
373
+ enableStaff: (userId) => ({
374
+ method: "PATCH",
375
+ path: `/admin/staff/${userId}/enable`
376
+ }),
377
+ experts: {
378
+ method: "GET",
379
+ path: "/admin/experts"
380
+ },
381
+ createExpert: {
382
+ method: "POST",
383
+ path: "/admin/experts",
384
+ _req: void 0,
385
+ _res: void 0
386
+ },
387
+ deleteExpert: (userId) => ({
388
+ method: "DELETE",
389
+ path: `/admin/experts/${userId}`
390
+ }),
391
+ disableExpert: (userId) => ({
392
+ method: "PATCH",
393
+ path: `/admin/experts/${userId}/disable`
394
+ }),
395
+ enableExpert: (userId) => ({
396
+ method: "PATCH",
397
+ path: `/admin/experts/${userId}/enable`
398
+ })
399
+ };
400
+ var apiRoutes = {
401
+ auth,
402
+ members,
403
+ checkIns,
404
+ leaderboards,
405
+ challenges,
406
+ bookings,
407
+ rewards,
408
+ experts,
409
+ notifications,
410
+ activities,
411
+ media,
412
+ admin
413
+ };
414
+
415
+ // src/api-client.ts
416
+ function buildUrl(baseUrl, path) {
417
+ const base = baseUrl.replace(/\/$/, "");
418
+ const p = path.startsWith("/") ? path : `/${path}`;
419
+ return base ? `${base}${p}` : p;
420
+ }
421
+ function request(client, baseUrl, route, body) {
422
+ const url = buildUrl(baseUrl, route.path);
423
+ const config = {
424
+ method: route.method,
425
+ url,
426
+ headers: { "Content-Type": "application/json" }
427
+ };
428
+ if (body !== void 0 && body !== null && ["POST", "PUT", "PATCH"].includes(route.method)) {
429
+ config.data = body;
430
+ }
431
+ return client.request(config).then((res) => res.data);
432
+ }
433
+ function createApi(client, baseUrl = "") {
434
+ return {
435
+ /**
436
+ * Execute a typed request. The route defines method + path; body and response types are inferred.
437
+ */
438
+ request(route, body) {
439
+ return request(client, baseUrl, route, body);
440
+ }
441
+ };
442
+ }
27
443
  export {
28
444
  BookingStatus,
29
445
  ChallengeVerificationType,
30
446
  ExpertRole,
31
- LeaderboardEntryStatus
447
+ LeaderboardEntryStatus,
448
+ ROUTES,
449
+ apiRoutes,
450
+ createApi,
451
+ request
32
452
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athos-sdk/api-types",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Shared API request and response types for Athos backend, admin dashboard, and mobile app",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",