@globalscoutme/api-client 1.1.11 → 1.1.15
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/README.md +297 -297
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/sdk.gen.d.ts +29 -1
- package/dist/sdk.gen.js +55 -0
- package/dist/types.gen.d.ts +267 -0
- package/index.ts +33 -0
- package/package.json +1 -1
- package/sdk.gen.ts +117 -0
- package/types.gen.ts +305 -0
package/README.md
CHANGED
|
@@ -1,297 +1,297 @@
|
|
|
1
|
-
# @globalscoutme/api-client
|
|
2
|
-
|
|
3
|
-
Auto-generated TypeScript HTTP client for the GlobalScoutMe API, built with [`@hey-api/openapi-ts`](https://heyapi.dev/) and axios.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @globalscoutme/api-client
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Setup
|
|
12
|
-
|
|
13
|
-
Configure the client once at app startup with your API base URL and auth token:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { client } from '@globalscoutme/api-client';
|
|
17
|
-
|
|
18
|
-
client.setConfig({
|
|
19
|
-
baseURL: 'https://your-api-url.com',
|
|
20
|
-
headers: {
|
|
21
|
-
Authorization: `Bearer ${yourSupabaseAccessToken}`,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Usage
|
|
27
|
-
|
|
28
|
-
All endpoints are grouped by controller and fully typed:
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
import {
|
|
32
|
-
Auth,
|
|
33
|
-
Dashboard,
|
|
34
|
-
Players,
|
|
35
|
-
Profile,
|
|
36
|
-
Documents,
|
|
37
|
-
Videos,
|
|
38
|
-
Achievements,
|
|
39
|
-
Body,
|
|
40
|
-
Index,
|
|
41
|
-
Kyc,
|
|
42
|
-
Offers,
|
|
43
|
-
Organizations,
|
|
44
|
-
Clubs,
|
|
45
|
-
Challenges,
|
|
46
|
-
Training,
|
|
47
|
-
Invitations,
|
|
48
|
-
Storage,
|
|
49
|
-
Subscriptions,
|
|
50
|
-
} from '@globalscoutme/api-client';
|
|
51
|
-
|
|
52
|
-
// Auth
|
|
53
|
-
const authMe = await Auth.getAuthMe();
|
|
54
|
-
// Returns { id: string, userType: string | null }
|
|
55
|
-
|
|
56
|
-
// Players
|
|
57
|
-
const player = await Players.getMe();
|
|
58
|
-
await Players.patchMe({ body: { fullName: 'John Doe' } });
|
|
59
|
-
await Players.deleteMe();
|
|
60
|
-
const dashboard = await Players.getMyDashboard();
|
|
61
|
-
await Players.heartbeat({ body: { timezone: 'Europe/Bucharest' } });
|
|
62
|
-
const results = await Players.searchPlayers({
|
|
63
|
-
body: {
|
|
64
|
-
search: 'John',
|
|
65
|
-
page: 1,
|
|
66
|
-
pageSize: 20,
|
|
67
|
-
sortBy: 'age_asc',
|
|
68
|
-
nationalities: ['EG', 'MA'],
|
|
69
|
-
positions: ['CM', 'CB'],
|
|
70
|
-
baseFoot: 'right',
|
|
71
|
-
isFreeAgent: true,
|
|
72
|
-
hasVideo: true,
|
|
73
|
-
heightOperator: 'gte',
|
|
74
|
-
heightCm: 180,
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
const playerProfile = await Players.getPlayerById({
|
|
78
|
-
path: { id: 'player-uuid' },
|
|
79
|
-
});
|
|
80
|
-
const playerMeasurements = await Players.getPlayerMeasurementProfile({
|
|
81
|
-
path: { id: 'player-uuid' },
|
|
82
|
-
});
|
|
83
|
-
// Returns { status, body, cmj, session, updatedAt } — accessible to all roles (no player-only restriction)
|
|
84
|
-
// status: 'missing' | 'partial' | 'ready' | 'needs_update'
|
|
85
|
-
const playerVideoMetrics = await Players.getPlayerVideoMetrics({
|
|
86
|
-
path: { id: 'player-uuid' },
|
|
87
|
-
});
|
|
88
|
-
// Returns { id, createdAt, videoDurationS, physicalMetrics, trackingQuality, trackedFrames, totalFrames }
|
|
89
|
-
// physicalMetrics: { totalDistance, sprintDistance, maxSpeed, averageSpeed, highIntensityRuns, sprints }
|
|
90
|
-
// Speed/distance values are strings with units already included (e.g. "31.0 km/h", "21.4 m")
|
|
91
|
-
// trackingQuality: confidence label from the analysis service (e.g. "High Confidence") — null if unavailable
|
|
92
|
-
// Returns 404 if the player has no completed video analysis yet
|
|
93
|
-
const playerReport = await Players.getPlayerReport({
|
|
94
|
-
path: { id: 'player-uuid' },
|
|
95
|
-
});
|
|
96
|
-
// Returns { reportReferenceId, generatedAt, scouterView: { technicalPillar, physicalPillar, tacticalPillar, mentalPillar } }
|
|
97
|
-
// Returns 404 if the player has no completed AI report yet
|
|
98
|
-
|
|
99
|
-
// Profile
|
|
100
|
-
const profile = await Profile.getProfileMe();
|
|
101
|
-
await Profile.updateProfileMe({ body: { dominantFoot: 'Right' } });
|
|
102
|
-
|
|
103
|
-
// Documents
|
|
104
|
-
const docs = await Documents.getMyDocuments();
|
|
105
|
-
await Documents.createDocument({ body: { type: 'license' } });
|
|
106
|
-
|
|
107
|
-
// Videos
|
|
108
|
-
const videos = await Videos.getMyVideos();
|
|
109
|
-
await Videos.createVideo({
|
|
110
|
-
body: { type: 'cmj', storagePath: 'path/to/video' },
|
|
111
|
-
});
|
|
112
|
-
const playUrl = await Videos.getVideoPlayUrl({ path: { id: 'video-uuid' } });
|
|
113
|
-
await Videos.deleteVideo({ path: { id: 'video-uuid' } });
|
|
114
|
-
|
|
115
|
-
// Achievements
|
|
116
|
-
const catalog = await Achievements.getAchievementsCatalog();
|
|
117
|
-
const myAchievements = await Achievements.getMyAchievements();
|
|
118
|
-
|
|
119
|
-
// Body measurements
|
|
120
|
-
const measurement = await Body.getMyMeasurements();
|
|
121
|
-
await Body.createMeasurement({ body: { heightCm: 180 } });
|
|
122
|
-
|
|
123
|
-
// Index (lookup tables)
|
|
124
|
-
const positions = await Index.getIndexItems({
|
|
125
|
-
path: { tableName: 'positions' },
|
|
126
|
-
});
|
|
127
|
-
const countries = await Index.getCountries();
|
|
128
|
-
// Returns [{ code: 'BR', name: 'Brazil', nationalityName: 'Brazilian', flagEmoji: '🇧🇷' }, ...]
|
|
129
|
-
|
|
130
|
-
// Dashboard (scout/club portal — single aggregated call)
|
|
131
|
-
const dashboard = await Dashboard.getScoutDashboard();
|
|
132
|
-
// Returns: stats (watchlisted, offersSent, playersViewed, videosWatched),
|
|
133
|
-
// lastPlayersViewed (last 6 distinct players),
|
|
134
|
-
// lastVideosWatched (last 6 distinct videos with player info)
|
|
135
|
-
|
|
136
|
-
const videoUrl = await Dashboard.getScoutVideoPlayUrl({
|
|
137
|
-
path: { id: 'video-uuid' },
|
|
138
|
-
});
|
|
139
|
-
// Returns signed play URL + records the view in video_views
|
|
140
|
-
|
|
141
|
-
// Offers (conversations between scouts and players)
|
|
142
|
-
const conversations = await Offers.listConversations({
|
|
143
|
-
query: { filter: 'all', page: 1, pageSize: 20 },
|
|
144
|
-
});
|
|
145
|
-
const conversation = await Offers.createConversation({
|
|
146
|
-
body: { playerId: 'player-uuid', initialMessage: 'Hi!' },
|
|
147
|
-
});
|
|
148
|
-
const messages = await Offers.listMessages({
|
|
149
|
-
path: { id: 'conversation-uuid' },
|
|
150
|
-
query: { page: 1, pageSize: 20 },
|
|
151
|
-
});
|
|
152
|
-
await Offers.sendMessage({
|
|
153
|
-
path: { id: 'conversation-uuid' },
|
|
154
|
-
body: { body: 'Looking forward to it!' },
|
|
155
|
-
});
|
|
156
|
-
await Offers.markConversationRead({ path: { id: 'conversation-uuid' } });
|
|
157
|
-
|
|
158
|
-
// Organizations
|
|
159
|
-
const org = await Organizations.getMyOrganization();
|
|
160
|
-
await Organizations.updateMyOrganization({ body: { name: 'FC Example' } });
|
|
161
|
-
await Organizations.registerClub({
|
|
162
|
-
body: { name: 'FC Example', email: 'admin@example.com' },
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Clubs (coach/admin club entries within an organization)
|
|
166
|
-
const clubs = await Clubs.getMyClubs();
|
|
167
|
-
const club = await Clubs.createMyClub({ body: { name: 'U19 Team' } });
|
|
168
|
-
await Clubs.updateMyClub({
|
|
169
|
-
path: { id: 'club-uuid' },
|
|
170
|
-
body: { name: 'U21 Team' },
|
|
171
|
-
});
|
|
172
|
-
await Clubs.deleteMyClub({ path: { id: 'club-uuid' } });
|
|
173
|
-
|
|
174
|
-
// Challenges
|
|
175
|
-
const challengeCatalog = await Challenges.getChallengesCatalog();
|
|
176
|
-
const myChallenges = await Challenges.getMyChallenges();
|
|
177
|
-
|
|
178
|
-
// Training
|
|
179
|
-
const grouped = await Training.getTrainingGrouped();
|
|
180
|
-
const trainingList = await Training.getTrainingList({
|
|
181
|
-
query: { categoryCode: 'fitness', page: 1, pageSize: 20 },
|
|
182
|
-
});
|
|
183
|
-
const trainingItem = await Training.getTrainingById({
|
|
184
|
-
path: { id: 'training-uuid' },
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// Invitations (org admin invites members)
|
|
188
|
-
await Invitations.sendInvitation({
|
|
189
|
-
body: { email: 'coach@example.com', role: 'coach' },
|
|
190
|
-
});
|
|
191
|
-
const invitations = await Invitations.listInvitations();
|
|
192
|
-
await Invitations.resendInvitation({ path: { id: 'invitation-uuid' } });
|
|
193
|
-
await Invitations.deleteInvitation({ path: { id: 'invitation-uuid' } });
|
|
194
|
-
await Invitations.acceptInvitation(); // called after Supabase auth callback
|
|
195
|
-
|
|
196
|
-
// KYC — SmileID Enhanced Document Verification
|
|
197
|
-
//
|
|
198
|
-
// Two integration options:
|
|
199
|
-
|
|
200
|
-
// Option A — Smile Links (recommended for web)
|
|
201
|
-
// Backend returns a hosted SmileID URL; redirect the user to it.
|
|
202
|
-
// SmileID handles the full capture UI and fires the webhook when done.
|
|
203
|
-
const linkResult = await Kyc.startSmileLink({
|
|
204
|
-
body: {
|
|
205
|
-
country: 'gh', // stored on the verification record; does NOT filter the SmileID dropdown
|
|
206
|
-
channel: 'web',
|
|
207
|
-
returnUrl: 'https://yourapp.com/onboarding/kyc/callback',
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
// linkResult: { url, jobId, status, retriesRemaining }
|
|
211
|
-
// url is null when no redirect is needed (approved / blocked / processing).
|
|
212
|
-
if (linkResult.data.url) {
|
|
213
|
-
window.location.href = linkResult.data.url; // redirect user to SmileID
|
|
214
|
-
}
|
|
215
|
-
// The SmileID hosted page shows all countries configured in index.kyc_supported_id_types.
|
|
216
|
-
// The user selects their country and document type on that page.
|
|
217
|
-
// After the user returns to returnUrl, poll getKycStatus to confirm the result.
|
|
218
|
-
// markSubmittedKyc is NOT needed for Smile Links — SmileID fires the webhook directly.
|
|
219
|
-
|
|
220
|
-
// Option B — SDK widget (embedded, for mobile / advanced web)
|
|
221
|
-
const kycResult = await Kyc.startKyc({
|
|
222
|
-
body: { country: 'gh', channel: 'web' },
|
|
223
|
-
});
|
|
224
|
-
// kycResult: { token, partnerId, jobId, status, retriesRemaining }
|
|
225
|
-
// Pass token + partnerId to the SmileID web SDK widget to start document capture.
|
|
226
|
-
// After the SDK reports successful submission, call markSubmittedKyc with jobId.
|
|
227
|
-
await Kyc.markSubmittedKyc({ body: { jobId: kycResult.data.jobId! } });
|
|
228
|
-
// SmileID also calls POST /kyc/webhook under the configured API base/prefix
|
|
229
|
-
// (for staging: https://staging.globalscoutme.com/api/kyc/webhook).
|
|
230
|
-
|
|
231
|
-
const kycStatus = await Kyc.getKycStatus({
|
|
232
|
-
path: { userId: supabaseAuthUuid },
|
|
233
|
-
});
|
|
234
|
-
// kycStatus: { status, retryCount, retriesRemaining }
|
|
235
|
-
// status: 'pending' | 'capture_started' | 'processing' | 'approved' | 'rejected' | 'blocked'
|
|
236
|
-
// Older API clients may still see legacy 'in_progress', which maps to 'capture_started'.
|
|
237
|
-
|
|
238
|
-
// Subscriptions (Stripe recurring billing)
|
|
239
|
-
const plans = await Subscriptions.getSubscriptionPlans();
|
|
240
|
-
// Returns: { plans: [{ id, code, name, price, currency, billingInterval, trialDays, features, displayOrder }] }
|
|
241
|
-
|
|
242
|
-
const mySubscription = await Subscriptions.getMySubscription();
|
|
243
|
-
// Returns: { status, isActive, planId, planName, billingInterval,
|
|
244
|
-
// currentPeriodStart, currentPeriodEnd, cancelAtPeriodEnd, canceledAt, gracePeriodUntil }
|
|
245
|
-
// status: 'inactive' when the user has never subscribed
|
|
246
|
-
|
|
247
|
-
// Start a subscription — redirect the user to the returned URL
|
|
248
|
-
const checkout = await Subscriptions.createCheckout({
|
|
249
|
-
body: {
|
|
250
|
-
providerProductId: 'billing-provider-products-uuid', // pick from billing_provider_products table
|
|
251
|
-
successUrl: 'https://yourapp.com/subscription/success', // or a mobile deep-link
|
|
252
|
-
cancelUrl: 'https://yourapp.com/subscription/cancel',
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
// redirect user to checkout.url
|
|
256
|
-
|
|
257
|
-
// Open the Stripe Billing Portal (manage / cancel subscription)
|
|
258
|
-
const portal = await Subscriptions.createPortal({
|
|
259
|
-
body: { returnUrl: 'https://yourapp.com/account' },
|
|
260
|
-
});
|
|
261
|
-
// redirect user to portal.url
|
|
262
|
-
|
|
263
|
-
// Storage — get a signed upload URL, then PUT the file directly to Supabase Storage
|
|
264
|
-
const { uploadUrl, token, path, bucket, expiresIn } = await Storage.createUploadUrl({
|
|
265
|
-
body: { bucket: 'avatars', contentType: 'image/jpeg', sizeBytes: 204800 },
|
|
266
|
-
});
|
|
267
|
-
await fetch(uploadUrl, {
|
|
268
|
-
method: 'PUT',
|
|
269
|
-
body: fileBlob,
|
|
270
|
-
headers: { 'Content-Type': 'image/jpeg' },
|
|
271
|
-
});
|
|
272
|
-
// persist `path` on the player record (e.g. patchMe with avatarPath: path)
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
## Updating auth token
|
|
276
|
-
|
|
277
|
-
Update the Bearer token after sign-in or token refresh:
|
|
278
|
-
|
|
279
|
-
```ts
|
|
280
|
-
client.setConfig({
|
|
281
|
-
headers: {
|
|
282
|
-
Authorization: `Bearer ${newAccessToken}`,
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
## Versioning
|
|
288
|
-
|
|
289
|
-
This package is auto-generated from the backend OpenAPI spec. Version increments follow semver:
|
|
290
|
-
|
|
291
|
-
- **patch** — no API shape changes
|
|
292
|
-
- **minor** — new endpoints added
|
|
293
|
-
- **major** — breaking changes (renamed/removed endpoints or fields)
|
|
294
|
-
|
|
295
|
-
## Package format
|
|
296
|
-
|
|
297
|
-
The published package ships compiled JavaScript (`dist/`) alongside the raw TypeScript source. `main` points to `dist/index.js` so all bundlers work without extra configuration.
|
|
1
|
+
# @globalscoutme/api-client
|
|
2
|
+
|
|
3
|
+
Auto-generated TypeScript HTTP client for the GlobalScoutMe API, built with [`@hey-api/openapi-ts`](https://heyapi.dev/) and axios.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @globalscoutme/api-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Configure the client once at app startup with your API base URL and auth token:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { client } from '@globalscoutme/api-client';
|
|
17
|
+
|
|
18
|
+
client.setConfig({
|
|
19
|
+
baseURL: 'https://your-api-url.com',
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${yourSupabaseAccessToken}`,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
All endpoints are grouped by controller and fully typed:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import {
|
|
32
|
+
Auth,
|
|
33
|
+
Dashboard,
|
|
34
|
+
Players,
|
|
35
|
+
Profile,
|
|
36
|
+
Documents,
|
|
37
|
+
Videos,
|
|
38
|
+
Achievements,
|
|
39
|
+
Body,
|
|
40
|
+
Index,
|
|
41
|
+
Kyc,
|
|
42
|
+
Offers,
|
|
43
|
+
Organizations,
|
|
44
|
+
Clubs,
|
|
45
|
+
Challenges,
|
|
46
|
+
Training,
|
|
47
|
+
Invitations,
|
|
48
|
+
Storage,
|
|
49
|
+
Subscriptions,
|
|
50
|
+
} from '@globalscoutme/api-client';
|
|
51
|
+
|
|
52
|
+
// Auth
|
|
53
|
+
const authMe = await Auth.getAuthMe();
|
|
54
|
+
// Returns { id: string, userType: string | null }
|
|
55
|
+
|
|
56
|
+
// Players
|
|
57
|
+
const player = await Players.getMe();
|
|
58
|
+
await Players.patchMe({ body: { fullName: 'John Doe' } });
|
|
59
|
+
await Players.deleteMe();
|
|
60
|
+
const dashboard = await Players.getMyDashboard();
|
|
61
|
+
await Players.heartbeat({ body: { timezone: 'Europe/Bucharest' } });
|
|
62
|
+
const results = await Players.searchPlayers({
|
|
63
|
+
body: {
|
|
64
|
+
search: 'John',
|
|
65
|
+
page: 1,
|
|
66
|
+
pageSize: 20,
|
|
67
|
+
sortBy: 'age_asc',
|
|
68
|
+
nationalities: ['EG', 'MA'],
|
|
69
|
+
positions: ['CM', 'CB'],
|
|
70
|
+
baseFoot: 'right',
|
|
71
|
+
isFreeAgent: true,
|
|
72
|
+
hasVideo: true,
|
|
73
|
+
heightOperator: 'gte',
|
|
74
|
+
heightCm: 180,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
const playerProfile = await Players.getPlayerById({
|
|
78
|
+
path: { id: 'player-uuid' },
|
|
79
|
+
});
|
|
80
|
+
const playerMeasurements = await Players.getPlayerMeasurementProfile({
|
|
81
|
+
path: { id: 'player-uuid' },
|
|
82
|
+
});
|
|
83
|
+
// Returns { status, body, cmj, session, updatedAt } — accessible to all roles (no player-only restriction)
|
|
84
|
+
// status: 'missing' | 'partial' | 'ready' | 'needs_update'
|
|
85
|
+
const playerVideoMetrics = await Players.getPlayerVideoMetrics({
|
|
86
|
+
path: { id: 'player-uuid' },
|
|
87
|
+
});
|
|
88
|
+
// Returns { id, createdAt, videoDurationS, physicalMetrics, trackingQuality, trackedFrames, totalFrames }
|
|
89
|
+
// physicalMetrics: { totalDistance, sprintDistance, maxSpeed, averageSpeed, highIntensityRuns, sprints }
|
|
90
|
+
// Speed/distance values are strings with units already included (e.g. "31.0 km/h", "21.4 m")
|
|
91
|
+
// trackingQuality: confidence label from the analysis service (e.g. "High Confidence") — null if unavailable
|
|
92
|
+
// Returns 404 if the player has no completed video analysis yet
|
|
93
|
+
const playerReport = await Players.getPlayerReport({
|
|
94
|
+
path: { id: 'player-uuid' },
|
|
95
|
+
});
|
|
96
|
+
// Returns { reportReferenceId, generatedAt, scouterView: { technicalPillar, physicalPillar, tacticalPillar, mentalPillar } }
|
|
97
|
+
// Returns 404 if the player has no completed AI report yet
|
|
98
|
+
|
|
99
|
+
// Profile
|
|
100
|
+
const profile = await Profile.getProfileMe();
|
|
101
|
+
await Profile.updateProfileMe({ body: { dominantFoot: 'Right' } });
|
|
102
|
+
|
|
103
|
+
// Documents
|
|
104
|
+
const docs = await Documents.getMyDocuments();
|
|
105
|
+
await Documents.createDocument({ body: { type: 'license' } });
|
|
106
|
+
|
|
107
|
+
// Videos
|
|
108
|
+
const videos = await Videos.getMyVideos();
|
|
109
|
+
await Videos.createVideo({
|
|
110
|
+
body: { type: 'cmj', storagePath: 'path/to/video' },
|
|
111
|
+
});
|
|
112
|
+
const playUrl = await Videos.getVideoPlayUrl({ path: { id: 'video-uuid' } });
|
|
113
|
+
await Videos.deleteVideo({ path: { id: 'video-uuid' } });
|
|
114
|
+
|
|
115
|
+
// Achievements
|
|
116
|
+
const catalog = await Achievements.getAchievementsCatalog();
|
|
117
|
+
const myAchievements = await Achievements.getMyAchievements();
|
|
118
|
+
|
|
119
|
+
// Body measurements
|
|
120
|
+
const measurement = await Body.getMyMeasurements();
|
|
121
|
+
await Body.createMeasurement({ body: { heightCm: 180 } });
|
|
122
|
+
|
|
123
|
+
// Index (lookup tables)
|
|
124
|
+
const positions = await Index.getIndexItems({
|
|
125
|
+
path: { tableName: 'positions' },
|
|
126
|
+
});
|
|
127
|
+
const countries = await Index.getCountries();
|
|
128
|
+
// Returns [{ code: 'BR', name: 'Brazil', nationalityName: 'Brazilian', flagEmoji: '🇧🇷' }, ...]
|
|
129
|
+
|
|
130
|
+
// Dashboard (scout/club portal — single aggregated call)
|
|
131
|
+
const dashboard = await Dashboard.getScoutDashboard();
|
|
132
|
+
// Returns: stats (watchlisted, offersSent, playersViewed, videosWatched),
|
|
133
|
+
// lastPlayersViewed (last 6 distinct players),
|
|
134
|
+
// lastVideosWatched (last 6 distinct videos with player info)
|
|
135
|
+
|
|
136
|
+
const videoUrl = await Dashboard.getScoutVideoPlayUrl({
|
|
137
|
+
path: { id: 'video-uuid' },
|
|
138
|
+
});
|
|
139
|
+
// Returns signed play URL + records the view in video_views
|
|
140
|
+
|
|
141
|
+
// Offers (conversations between scouts and players)
|
|
142
|
+
const conversations = await Offers.listConversations({
|
|
143
|
+
query: { filter: 'all', page: 1, pageSize: 20 },
|
|
144
|
+
});
|
|
145
|
+
const conversation = await Offers.createConversation({
|
|
146
|
+
body: { playerId: 'player-uuid', initialMessage: 'Hi!' },
|
|
147
|
+
});
|
|
148
|
+
const messages = await Offers.listMessages({
|
|
149
|
+
path: { id: 'conversation-uuid' },
|
|
150
|
+
query: { page: 1, pageSize: 20 },
|
|
151
|
+
});
|
|
152
|
+
await Offers.sendMessage({
|
|
153
|
+
path: { id: 'conversation-uuid' },
|
|
154
|
+
body: { body: 'Looking forward to it!' },
|
|
155
|
+
});
|
|
156
|
+
await Offers.markConversationRead({ path: { id: 'conversation-uuid' } });
|
|
157
|
+
|
|
158
|
+
// Organizations
|
|
159
|
+
const org = await Organizations.getMyOrganization();
|
|
160
|
+
await Organizations.updateMyOrganization({ body: { name: 'FC Example' } });
|
|
161
|
+
await Organizations.registerClub({
|
|
162
|
+
body: { name: 'FC Example', email: 'admin@example.com' },
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Clubs (coach/admin club entries within an organization)
|
|
166
|
+
const clubs = await Clubs.getMyClubs();
|
|
167
|
+
const club = await Clubs.createMyClub({ body: { name: 'U19 Team' } });
|
|
168
|
+
await Clubs.updateMyClub({
|
|
169
|
+
path: { id: 'club-uuid' },
|
|
170
|
+
body: { name: 'U21 Team' },
|
|
171
|
+
});
|
|
172
|
+
await Clubs.deleteMyClub({ path: { id: 'club-uuid' } });
|
|
173
|
+
|
|
174
|
+
// Challenges
|
|
175
|
+
const challengeCatalog = await Challenges.getChallengesCatalog();
|
|
176
|
+
const myChallenges = await Challenges.getMyChallenges();
|
|
177
|
+
|
|
178
|
+
// Training
|
|
179
|
+
const grouped = await Training.getTrainingGrouped();
|
|
180
|
+
const trainingList = await Training.getTrainingList({
|
|
181
|
+
query: { categoryCode: 'fitness', page: 1, pageSize: 20 },
|
|
182
|
+
});
|
|
183
|
+
const trainingItem = await Training.getTrainingById({
|
|
184
|
+
path: { id: 'training-uuid' },
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Invitations (org admin invites members)
|
|
188
|
+
await Invitations.sendInvitation({
|
|
189
|
+
body: { email: 'coach@example.com', role: 'coach' },
|
|
190
|
+
});
|
|
191
|
+
const invitations = await Invitations.listInvitations();
|
|
192
|
+
await Invitations.resendInvitation({ path: { id: 'invitation-uuid' } });
|
|
193
|
+
await Invitations.deleteInvitation({ path: { id: 'invitation-uuid' } });
|
|
194
|
+
await Invitations.acceptInvitation(); // called after Supabase auth callback
|
|
195
|
+
|
|
196
|
+
// KYC — SmileID Enhanced Document Verification
|
|
197
|
+
//
|
|
198
|
+
// Two integration options:
|
|
199
|
+
|
|
200
|
+
// Option A — Smile Links (recommended for web)
|
|
201
|
+
// Backend returns a hosted SmileID URL; redirect the user to it.
|
|
202
|
+
// SmileID handles the full capture UI and fires the webhook when done.
|
|
203
|
+
const linkResult = await Kyc.startSmileLink({
|
|
204
|
+
body: {
|
|
205
|
+
country: 'gh', // stored on the verification record; does NOT filter the SmileID dropdown
|
|
206
|
+
channel: 'web',
|
|
207
|
+
returnUrl: 'https://yourapp.com/onboarding/kyc/callback',
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
// linkResult: { url, jobId, status, retriesRemaining }
|
|
211
|
+
// url is null when no redirect is needed (approved / blocked / processing).
|
|
212
|
+
if (linkResult.data.url) {
|
|
213
|
+
window.location.href = linkResult.data.url; // redirect user to SmileID
|
|
214
|
+
}
|
|
215
|
+
// The SmileID hosted page shows all countries configured in index.kyc_supported_id_types.
|
|
216
|
+
// The user selects their country and document type on that page.
|
|
217
|
+
// After the user returns to returnUrl, poll getKycStatus to confirm the result.
|
|
218
|
+
// markSubmittedKyc is NOT needed for Smile Links — SmileID fires the webhook directly.
|
|
219
|
+
|
|
220
|
+
// Option B — SDK widget (embedded, for mobile / advanced web)
|
|
221
|
+
const kycResult = await Kyc.startKyc({
|
|
222
|
+
body: { country: 'gh', channel: 'web' },
|
|
223
|
+
});
|
|
224
|
+
// kycResult: { token, partnerId, jobId, status, retriesRemaining }
|
|
225
|
+
// Pass token + partnerId to the SmileID web SDK widget to start document capture.
|
|
226
|
+
// After the SDK reports successful submission, call markSubmittedKyc with jobId.
|
|
227
|
+
await Kyc.markSubmittedKyc({ body: { jobId: kycResult.data.jobId! } });
|
|
228
|
+
// SmileID also calls POST /kyc/webhook under the configured API base/prefix
|
|
229
|
+
// (for staging: https://staging.globalscoutme.com/api/kyc/webhook).
|
|
230
|
+
|
|
231
|
+
const kycStatus = await Kyc.getKycStatus({
|
|
232
|
+
path: { userId: supabaseAuthUuid },
|
|
233
|
+
});
|
|
234
|
+
// kycStatus: { status, retryCount, retriesRemaining }
|
|
235
|
+
// status: 'pending' | 'capture_started' | 'processing' | 'approved' | 'rejected' | 'blocked'
|
|
236
|
+
// Older API clients may still see legacy 'in_progress', which maps to 'capture_started'.
|
|
237
|
+
|
|
238
|
+
// Subscriptions (Stripe recurring billing)
|
|
239
|
+
const plans = await Subscriptions.getSubscriptionPlans();
|
|
240
|
+
// Returns: { plans: [{ id, code, name, price, currency, billingInterval, trialDays, features, displayOrder }] }
|
|
241
|
+
|
|
242
|
+
const mySubscription = await Subscriptions.getMySubscription();
|
|
243
|
+
// Returns: { status, isActive, planId, planName, billingInterval,
|
|
244
|
+
// currentPeriodStart, currentPeriodEnd, cancelAtPeriodEnd, canceledAt, gracePeriodUntil }
|
|
245
|
+
// status: 'inactive' when the user has never subscribed
|
|
246
|
+
|
|
247
|
+
// Start a subscription — redirect the user to the returned URL
|
|
248
|
+
const checkout = await Subscriptions.createCheckout({
|
|
249
|
+
body: {
|
|
250
|
+
providerProductId: 'billing-provider-products-uuid', // pick from billing_provider_products table
|
|
251
|
+
successUrl: 'https://yourapp.com/subscription/success', // or a mobile deep-link
|
|
252
|
+
cancelUrl: 'https://yourapp.com/subscription/cancel',
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
// redirect user to checkout.url
|
|
256
|
+
|
|
257
|
+
// Open the Stripe Billing Portal (manage / cancel subscription)
|
|
258
|
+
const portal = await Subscriptions.createPortal({
|
|
259
|
+
body: { returnUrl: 'https://yourapp.com/account' },
|
|
260
|
+
});
|
|
261
|
+
// redirect user to portal.url
|
|
262
|
+
|
|
263
|
+
// Storage — get a signed upload URL, then PUT the file directly to Supabase Storage
|
|
264
|
+
const { uploadUrl, token, path, bucket, expiresIn } = await Storage.createUploadUrl({
|
|
265
|
+
body: { bucket: 'avatars', contentType: 'image/jpeg', sizeBytes: 204800 },
|
|
266
|
+
});
|
|
267
|
+
await fetch(uploadUrl, {
|
|
268
|
+
method: 'PUT',
|
|
269
|
+
body: fileBlob,
|
|
270
|
+
headers: { 'Content-Type': 'image/jpeg' },
|
|
271
|
+
});
|
|
272
|
+
// persist `path` on the player record (e.g. patchMe with avatarPath: path)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Updating auth token
|
|
276
|
+
|
|
277
|
+
Update the Bearer token after sign-in or token refresh:
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
client.setConfig({
|
|
281
|
+
headers: {
|
|
282
|
+
Authorization: `Bearer ${newAccessToken}`,
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Versioning
|
|
288
|
+
|
|
289
|
+
This package is auto-generated from the backend OpenAPI spec. Version increments follow semver:
|
|
290
|
+
|
|
291
|
+
- **patch** — no API shape changes
|
|
292
|
+
- **minor** — new endpoints added
|
|
293
|
+
- **major** — breaking changes (renamed/removed endpoints or fields)
|
|
294
|
+
|
|
295
|
+
## Package format
|
|
296
|
+
|
|
297
|
+
The published package ships compiled JavaScript (`dist/`) alongside the raw TypeScript source. `main` points to `dist/index.js` so all bundlers work without extra configuration.
|