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