@globalscoutme/api-client 1.1.9 → 1.1.11
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 -0
- package/client/client.gen.ts +25 -48
- package/client/types.gen.ts +12 -41
- package/client/utils.gen.ts +12 -33
- package/client.gen.ts +2 -7
- package/core/auth.gen.ts +2 -3
- package/core/bodySerializer.gen.ts +6 -22
- package/core/params.gen.ts +3 -10
- package/core/pathSerializer.gen.ts +6 -15
- package/core/queryKeySerializer.gen.ts +6 -25
- package/core/serverSentEvents.gen.ts +8 -31
- package/core/types.gen.ts +3 -13
- package/core/utils.gen.ts +4 -7
- package/dist/client/client.gen.js +1 -2
- package/dist/client/utils.gen.js +2 -5
- package/dist/client.gen.js +1 -1
- package/dist/core/bodySerializer.gen.js +1 -1
- package/dist/core/pathSerializer.gen.js +3 -11
- package/dist/core/queryKeySerializer.gen.js +4 -11
- package/dist/core/serverSentEvents.gen.js +3 -7
- package/dist/index.d.ts +1 -1
- package/dist/sdk.gen.js +8 -2
- package/dist/types.gen.d.ts +71 -18
- package/index.ts +6 -1
- package/package.json +2 -2
- package/sdk.gen.ts +104 -122
- package/tsconfig.json +1 -2
- package/types.gen.ts +104 -68
package/README.md
ADDED
|
@@ -0,0 +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.
|
package/client/client.gen.ts
CHANGED
|
@@ -3,12 +3,7 @@
|
|
|
3
3
|
import { createSseClient } from '../core/serverSentEvents.gen.js';
|
|
4
4
|
import type { HttpMethod } from '../core/types.gen.js';
|
|
5
5
|
import { getValidRequestBody } from '../core/utils.gen.js';
|
|
6
|
-
import type {
|
|
7
|
-
Client,
|
|
8
|
-
Config,
|
|
9
|
-
RequestOptions,
|
|
10
|
-
ResolvedRequestOptions,
|
|
11
|
-
} from './types.gen.js';
|
|
6
|
+
import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen.js';
|
|
12
7
|
import {
|
|
13
8
|
buildUrl,
|
|
14
9
|
createConfig,
|
|
@@ -34,12 +29,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
34
29
|
return getConfig();
|
|
35
30
|
};
|
|
36
31
|
|
|
37
|
-
const interceptors = createInterceptors<
|
|
38
|
-
Request,
|
|
39
|
-
Response,
|
|
40
|
-
unknown,
|
|
41
|
-
ResolvedRequestOptions
|
|
42
|
-
>();
|
|
32
|
+
const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>();
|
|
43
33
|
|
|
44
34
|
const beforeRequest = async (options: RequestOptions) => {
|
|
45
35
|
const opts = {
|
|
@@ -105,12 +95,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
105
95
|
|
|
106
96
|
for (const fn of interceptors.error.fns) {
|
|
107
97
|
if (fn) {
|
|
108
|
-
finalError = (await fn(
|
|
109
|
-
error,
|
|
110
|
-
undefined as any,
|
|
111
|
-
request,
|
|
112
|
-
opts,
|
|
113
|
-
)) as unknown;
|
|
98
|
+
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
|
|
114
99
|
}
|
|
115
100
|
}
|
|
116
101
|
|
|
@@ -147,10 +132,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
147
132
|
? getParseAs(response.headers.get('Content-Type'))
|
|
148
133
|
: opts.parseAs) ?? 'json';
|
|
149
134
|
|
|
150
|
-
if (
|
|
151
|
-
response.status === 204 ||
|
|
152
|
-
response.headers.get('Content-Length') === '0'
|
|
153
|
-
) {
|
|
135
|
+
if (response.status === 204 || response.headers.get('Content-Length') === '0') {
|
|
154
136
|
let emptyData: any;
|
|
155
137
|
switch (parseAs) {
|
|
156
138
|
case 'arrayBuffer':
|
|
@@ -252,34 +234,29 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
252
234
|
};
|
|
253
235
|
};
|
|
254
236
|
|
|
255
|
-
const makeMethodFn =
|
|
256
|
-
(
|
|
257
|
-
request({ ...options, method });
|
|
237
|
+
const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
238
|
+
request({ ...options, method });
|
|
258
239
|
|
|
259
|
-
const makeSseFn =
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
request = await fn(request, opts);
|
|
272
|
-
}
|
|
240
|
+
const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
|
|
241
|
+
const { opts, url } = await beforeRequest(options);
|
|
242
|
+
return createSseClient({
|
|
243
|
+
...opts,
|
|
244
|
+
body: opts.body as BodyInit | null | undefined,
|
|
245
|
+
headers: opts.headers as unknown as Record<string, string>,
|
|
246
|
+
method,
|
|
247
|
+
onRequest: async (url, init) => {
|
|
248
|
+
let request = new Request(url, init);
|
|
249
|
+
for (const fn of interceptors.request.fns) {
|
|
250
|
+
if (fn) {
|
|
251
|
+
request = await fn(request, opts);
|
|
273
252
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
});
|
|
282
|
-
};
|
|
253
|
+
}
|
|
254
|
+
return request;
|
|
255
|
+
},
|
|
256
|
+
serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
|
|
257
|
+
url,
|
|
258
|
+
});
|
|
259
|
+
};
|
|
283
260
|
|
|
284
261
|
return {
|
|
285
262
|
buildUrl,
|
package/client/types.gen.ts
CHANGED
|
@@ -5,10 +5,7 @@ import type {
|
|
|
5
5
|
ServerSentEventsOptions,
|
|
6
6
|
ServerSentEventsResult,
|
|
7
7
|
} from '../core/serverSentEvents.gen.js';
|
|
8
|
-
import type {
|
|
9
|
-
Client as CoreClient,
|
|
10
|
-
Config as CoreConfig,
|
|
11
|
-
} from '../core/types.gen.js';
|
|
8
|
+
import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen.js';
|
|
12
9
|
import type { Middleware } from './utils.gen.js';
|
|
13
10
|
|
|
14
11
|
export type ResponseStyle = 'data' | 'fields';
|
|
@@ -41,14 +38,7 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|
|
41
38
|
*
|
|
42
39
|
* @default 'auto'
|
|
43
40
|
*/
|
|
44
|
-
parseAs?:
|
|
45
|
-
| 'arrayBuffer'
|
|
46
|
-
| 'auto'
|
|
47
|
-
| 'blob'
|
|
48
|
-
| 'formData'
|
|
49
|
-
| 'json'
|
|
50
|
-
| 'stream'
|
|
51
|
-
| 'text';
|
|
41
|
+
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
|
52
42
|
/**
|
|
53
43
|
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
54
44
|
*
|
|
@@ -117,32 +107,22 @@ export type RequestResult<
|
|
|
117
107
|
? TData[keyof TData]
|
|
118
108
|
: TData
|
|
119
109
|
: {
|
|
120
|
-
data: TData extends Record<string, unknown>
|
|
121
|
-
? TData[keyof TData]
|
|
122
|
-
: TData;
|
|
110
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
123
111
|
request: Request;
|
|
124
112
|
response: Response;
|
|
125
113
|
}
|
|
126
114
|
>
|
|
127
115
|
: Promise<
|
|
128
116
|
TResponseStyle extends 'data'
|
|
129
|
-
?
|
|
130
|
-
| (TData extends Record<string, unknown>
|
|
131
|
-
? TData[keyof TData]
|
|
132
|
-
: TData)
|
|
133
|
-
| undefined
|
|
117
|
+
? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
|
|
134
118
|
: (
|
|
135
119
|
| {
|
|
136
|
-
data: TData extends Record<string, unknown>
|
|
137
|
-
? TData[keyof TData]
|
|
138
|
-
: TData;
|
|
120
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
139
121
|
error: undefined;
|
|
140
122
|
}
|
|
141
123
|
| {
|
|
142
124
|
data: undefined;
|
|
143
|
-
error: TError extends Record<string, unknown>
|
|
144
|
-
? TError[keyof TError]
|
|
145
|
-
: TError;
|
|
125
|
+
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
146
126
|
}
|
|
147
127
|
) & {
|
|
148
128
|
request: Request;
|
|
@@ -162,7 +142,7 @@ type MethodFn = <
|
|
|
162
142
|
ThrowOnError extends boolean = false,
|
|
163
143
|
TResponseStyle extends ResponseStyle = 'fields',
|
|
164
144
|
>(
|
|
165
|
-
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'
|
|
145
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>
|
|
166
146
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
167
147
|
|
|
168
148
|
type SseFn = <
|
|
@@ -171,7 +151,7 @@ type SseFn = <
|
|
|
171
151
|
ThrowOnError extends boolean = false,
|
|
172
152
|
TResponseStyle extends ResponseStyle = 'fields',
|
|
173
153
|
>(
|
|
174
|
-
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'
|
|
154
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>
|
|
175
155
|
) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
176
156
|
|
|
177
157
|
type RequestFn = <
|
|
@@ -181,10 +161,7 @@ type RequestFn = <
|
|
|
181
161
|
TResponseStyle extends ResponseStyle = 'fields',
|
|
182
162
|
>(
|
|
183
163
|
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
|
|
184
|
-
Pick<
|
|
185
|
-
Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
|
|
186
|
-
'method'
|
|
187
|
-
>,
|
|
164
|
+
Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>
|
|
188
165
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
189
166
|
|
|
190
167
|
type BuildUrlFn = <
|
|
@@ -195,16 +172,10 @@ type BuildUrlFn = <
|
|
|
195
172
|
url: string;
|
|
196
173
|
},
|
|
197
174
|
>(
|
|
198
|
-
options: TData & Options<TData
|
|
175
|
+
options: TData & Options<TData>
|
|
199
176
|
) => string;
|
|
200
177
|
|
|
201
|
-
export type Client = CoreClient<
|
|
202
|
-
RequestFn,
|
|
203
|
-
Config,
|
|
204
|
-
MethodFn,
|
|
205
|
-
BuildUrlFn,
|
|
206
|
-
SseFn
|
|
207
|
-
> & {
|
|
178
|
+
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
208
179
|
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
209
180
|
};
|
|
210
181
|
|
|
@@ -217,7 +188,7 @@ export type Client = CoreClient<
|
|
|
217
188
|
* to ensure your client always has the correct values.
|
|
218
189
|
*/
|
|
219
190
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
|
220
|
-
override?: Config<ClientOptions & T
|
|
191
|
+
override?: Config<ClientOptions & T>
|
|
221
192
|
) => Config<Required<ClientOptions> & T>;
|
|
222
193
|
|
|
223
194
|
export interface TDataShape {
|
package/client/utils.gen.ts
CHANGED
|
@@ -9,12 +9,7 @@ import {
|
|
|
9
9
|
serializePrimitiveParam,
|
|
10
10
|
} from '../core/pathSerializer.gen.js';
|
|
11
11
|
import { getUrl } from '../core/utils.gen.js';
|
|
12
|
-
import type {
|
|
13
|
-
Client,
|
|
14
|
-
ClientOptions,
|
|
15
|
-
Config,
|
|
16
|
-
RequestOptions,
|
|
17
|
-
} from './types.gen.js';
|
|
12
|
+
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen.js';
|
|
18
13
|
|
|
19
14
|
export const createQuerySerializer = <T = unknown>({
|
|
20
15
|
parameters = {},
|
|
@@ -70,9 +65,7 @@ export const createQuerySerializer = <T = unknown>({
|
|
|
70
65
|
/**
|
|
71
66
|
* Infers parseAs value from provided Content-Type header.
|
|
72
67
|
*/
|
|
73
|
-
export const getParseAs = (
|
|
74
|
-
contentType: string | null,
|
|
75
|
-
): Exclude<Config['parseAs'], 'auto'> => {
|
|
68
|
+
export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => {
|
|
76
69
|
if (!contentType) {
|
|
77
70
|
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
78
71
|
// which is effectively the same as the 'stream' option.
|
|
@@ -85,10 +78,7 @@ export const getParseAs = (
|
|
|
85
78
|
return;
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
if (
|
|
89
|
-
cleanContent.startsWith('application/json') ||
|
|
90
|
-
cleanContent.endsWith('+json')
|
|
91
|
-
) {
|
|
81
|
+
if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
|
|
92
82
|
return 'json';
|
|
93
83
|
}
|
|
94
84
|
|
|
@@ -97,9 +87,7 @@ export const getParseAs = (
|
|
|
97
87
|
}
|
|
98
88
|
|
|
99
89
|
if (
|
|
100
|
-
['application/', 'audio/', 'image/', 'video/'].some((type) =>
|
|
101
|
-
cleanContent.startsWith(type),
|
|
102
|
-
)
|
|
90
|
+
['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))
|
|
103
91
|
) {
|
|
104
92
|
return 'blob';
|
|
105
93
|
}
|
|
@@ -115,7 +103,7 @@ const checkForExistence = (
|
|
|
115
103
|
options: Pick<RequestOptions, 'auth' | 'query'> & {
|
|
116
104
|
headers: Headers;
|
|
117
105
|
},
|
|
118
|
-
name?: string
|
|
106
|
+
name?: string
|
|
119
107
|
): boolean => {
|
|
120
108
|
if (!name) {
|
|
121
109
|
return false;
|
|
@@ -206,10 +194,7 @@ export const mergeHeaders = (
|
|
|
206
194
|
continue;
|
|
207
195
|
}
|
|
208
196
|
|
|
209
|
-
const iterator =
|
|
210
|
-
header instanceof Headers
|
|
211
|
-
? headersEntries(header)
|
|
212
|
-
: Object.entries(header);
|
|
197
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
213
198
|
|
|
214
199
|
for (const [key, value] of iterator) {
|
|
215
200
|
if (value === null) {
|
|
@@ -223,7 +208,7 @@ export const mergeHeaders = (
|
|
|
223
208
|
// content value in OpenAPI specification is 'application/json'
|
|
224
209
|
mergedHeaders.set(
|
|
225
210
|
key,
|
|
226
|
-
typeof value === 'object' ? JSON.stringify(value) : (value as string)
|
|
211
|
+
typeof value === 'object' ? JSON.stringify(value) : (value as string)
|
|
227
212
|
);
|
|
228
213
|
}
|
|
229
214
|
}
|
|
@@ -235,18 +220,15 @@ type ErrInterceptor<Err, Res, Req, Options> = (
|
|
|
235
220
|
error: Err,
|
|
236
221
|
response: Res,
|
|
237
222
|
request: Req,
|
|
238
|
-
options: Options
|
|
223
|
+
options: Options
|
|
239
224
|
) => Err | Promise<Err>;
|
|
240
225
|
|
|
241
|
-
type ReqInterceptor<Req, Options> = (
|
|
242
|
-
request: Req,
|
|
243
|
-
options: Options,
|
|
244
|
-
) => Req | Promise<Req>;
|
|
226
|
+
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
245
227
|
|
|
246
228
|
type ResInterceptor<Res, Req, Options> = (
|
|
247
229
|
response: Res,
|
|
248
230
|
request: Req,
|
|
249
|
-
options: Options
|
|
231
|
+
options: Options
|
|
250
232
|
) => Res | Promise<Res>;
|
|
251
233
|
|
|
252
234
|
class Interceptors<Interceptor> {
|
|
@@ -275,10 +257,7 @@ class Interceptors<Interceptor> {
|
|
|
275
257
|
return this.fns.indexOf(id);
|
|
276
258
|
}
|
|
277
259
|
|
|
278
|
-
update(
|
|
279
|
-
id: number | Interceptor,
|
|
280
|
-
fn: Interceptor,
|
|
281
|
-
): number | Interceptor | false {
|
|
260
|
+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false {
|
|
282
261
|
const index = this.getInterceptorIndex(id);
|
|
283
262
|
if (this.fns[index]) {
|
|
284
263
|
this.fns[index] = fn;
|
|
@@ -327,7 +306,7 @@ const defaultHeaders = {
|
|
|
327
306
|
};
|
|
328
307
|
|
|
329
308
|
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
330
|
-
override: Config<Omit<ClientOptions, keyof T> & T> = {}
|
|
309
|
+
override: Config<Omit<ClientOptions, keyof T> & T> = {}
|
|
331
310
|
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
|
332
311
|
...jsonBodySerializer,
|
|
333
312
|
headers: defaultHeaders,
|
package/client.gen.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
type ClientOptions,
|
|
5
|
-
type Config,
|
|
6
|
-
createClient,
|
|
7
|
-
createConfig,
|
|
8
|
-
} from './client/index.js';
|
|
3
|
+
import { type ClientOptions, type Config, createClient, createConfig } from './client/index.js';
|
|
9
4
|
import type { ClientOptions as ClientOptions2 } from './types.gen.js';
|
|
10
5
|
|
|
11
6
|
/**
|
|
@@ -17,7 +12,7 @@ import type { ClientOptions as ClientOptions2 } from './types.gen.js';
|
|
|
17
12
|
* to ensure your client always has the correct values.
|
|
18
13
|
*/
|
|
19
14
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
|
|
20
|
-
override?: Config<ClientOptions & T
|
|
15
|
+
override?: Config<ClientOptions & T>
|
|
21
16
|
) => Config<Required<ClientOptions> & T>;
|
|
22
17
|
|
|
23
18
|
export const client = createClient(createConfig<ClientOptions2>());
|
package/core/auth.gen.ts
CHANGED
|
@@ -21,10 +21,9 @@ export interface Auth {
|
|
|
21
21
|
|
|
22
22
|
export const getAuthToken = async (
|
|
23
23
|
auth: Auth,
|
|
24
|
-
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken
|
|
24
|
+
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken
|
|
25
25
|
): Promise<string | undefined> => {
|
|
26
|
-
const token =
|
|
27
|
-
typeof callback === 'function' ? await callback(auth) : callback;
|
|
26
|
+
const token = typeof callback === 'function' ? await callback(auth) : callback;
|
|
28
27
|
|
|
29
28
|
if (!token) {
|
|
30
29
|
return;
|