@bitbitpress/client 0.1.0 → 0.1.3
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 +475 -2
- package/dist/client.d.ts +4 -26
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -1
- package/dist/client.js.map +1 -1
- package/dist/generated/openapi.d.ts +509 -6
- package/dist/generated/openapi.ts +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/request.d.ts.map +1 -1
- package/dist/request.js +1 -1
- package/dist/request.js.map +1 -1
- package/dist/user/index.d.ts +35 -30
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user/index.js +1 -22
- package/dist/user/index.js.map +1 -1
- package/dist/user/recommendations.d.ts +4 -0
- package/dist/user/recommendations.d.ts.map +1 -1
- package/dist/user/recommendations.js +4 -0
- package/dist/user/recommendations.js.map +1 -1
- package/dist/user/signal.d.ts +4 -0
- package/dist/user/signal.d.ts.map +1 -1
- package/dist/user/signal.js +4 -0
- package/dist/user/signal.js.map +1 -1
- package/dist/user/synthesize.d.ts +4 -0
- package/dist/user/synthesize.d.ts.map +1 -1
- package/dist/user/synthesize.js +4 -0
- package/dist/user/synthesize.js.map +1 -1
- package/dist/user/token.d.ts +4 -0
- package/dist/user/token.d.ts.map +1 -1
- package/dist/user/token.js +4 -0
- package/dist/user/token.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -33,6 +33,479 @@ await client.user.authenticate('your-user\'s-auth-sso-token');
|
|
|
33
33
|
|
|
34
34
|
**Note:** You must call `authenticate()` before using any other user methods (recommendations, synthesize, etc.).
|
|
35
35
|
|
|
36
|
-
### API
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
## API Reference
|
|
38
|
+
|
|
39
|
+
More details can also be found in your control room's API docs @ https://your-control-room.api.dev.bitbitpress.com/docs.
|
|
40
|
+
|
|
41
|
+
- [BitBitPressClient](#bitbitpressclient)
|
|
42
|
+
- [Authentication](#authentication)
|
|
43
|
+
- [User Methods](#user-methods)
|
|
44
|
+
- [authenticate](#authenticate)
|
|
45
|
+
- [token](#token)
|
|
46
|
+
- [recommendations](#recommendations)
|
|
47
|
+
- [signal](#signal)
|
|
48
|
+
- [synthesizeItem](#synthesizeitem)
|
|
49
|
+
- [synthesize](#synthesize)
|
|
50
|
+
- [Types](#types)
|
|
51
|
+
|
|
52
|
+
### BitBitPressClient
|
|
53
|
+
|
|
54
|
+
Main client class for interacting with the BitBitPress API.
|
|
55
|
+
|
|
56
|
+
#### Constructor
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
new BitBitPressClient(options: BitBitPressClientOptions)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
##### Parameters
|
|
63
|
+
|
|
64
|
+
- `options.baseUrl` (required): Base URL of the API server (your custom Control Room API Url)
|
|
65
|
+
- `options.fetch` (optional): Custom fetch implementation (useful for React Native or Node.js polyfills)
|
|
66
|
+
- `options.headers` (optional): Additional headers to include in all requests
|
|
67
|
+
- `options.timeout` (optional): Request timeout in milliseconds (default: `30000`)
|
|
68
|
+
- `options.synthesizeBatchTimeout` (optional): Batch timeout for `synthesizeItem` in milliseconds (default: `250`)
|
|
69
|
+
|
|
70
|
+
##### Example
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const client = new BitBitPressClient({
|
|
74
|
+
baseUrl: 'https://your-control-room.api.dev.bitbitpress.com',
|
|
75
|
+
timeout: 30000,
|
|
76
|
+
synthesizeBatchTimeout: 250,
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
##### Methods
|
|
81
|
+
|
|
82
|
+
##### `setBaseUrl(baseUrl: string): void`
|
|
83
|
+
|
|
84
|
+
Update the base URL for API requests.
|
|
85
|
+
|
|
86
|
+
##### `get user`
|
|
87
|
+
|
|
88
|
+
Returns an object with user-related API methods. See [User Methods](#user-methods) below.
|
|
89
|
+
|
|
90
|
+
### Authentication
|
|
91
|
+
|
|
92
|
+
All user methods require authentication. You must call `client.user.authenticate()` before using other user methods.
|
|
93
|
+
|
|
94
|
+
### User Methods
|
|
95
|
+
|
|
96
|
+
#### authenticate
|
|
97
|
+
|
|
98
|
+
Exchanges an SSO token for an authentication token and automatically sets it for all subsequent user method calls.
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
await client.user.authenticate(ssoToken: string): Promise<void>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
##### Parameters
|
|
105
|
+
|
|
106
|
+
- `ssoToken` (required): The SSO token from your authentication provider
|
|
107
|
+
|
|
108
|
+
##### Returns
|
|
109
|
+
|
|
110
|
+
- `Promise<void>`: Resolves when authentication is complete
|
|
111
|
+
|
|
112
|
+
##### Example
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
await client.user.authenticate('your-user-s-auth-sso-token');
|
|
116
|
+
// Token is now automatically set for all user methods
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
##### Throws
|
|
120
|
+
|
|
121
|
+
- `Error`: If token exchange fails or no access token is returned
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
#### token
|
|
126
|
+
|
|
127
|
+
Exchanges an SSO token for an authentication token without automatically setting it for user methods.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
client.user.token(ssoToken: string): Promise<TokenResponse>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
##### Parameters
|
|
134
|
+
|
|
135
|
+
- `ssoToken` (required): The SSO token from your authentication provider
|
|
136
|
+
|
|
137
|
+
##### Returns
|
|
138
|
+
|
|
139
|
+
- `Promise<TokenResponse>`: The token response containing:
|
|
140
|
+
- `idToken?: string`
|
|
141
|
+
- `accessToken?: string`
|
|
142
|
+
- `refreshToken?: string`
|
|
143
|
+
- `expiresIn?: number`
|
|
144
|
+
|
|
145
|
+
##### Example
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const tokenResponse = await client.user.token('your-sso-token');
|
|
149
|
+
console.log('Access token:', tokenResponse.accessToken);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
#### recommendations
|
|
155
|
+
|
|
156
|
+
Get recommended articles for the authenticated user.
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
client.user.recommendations(options?: RecommendationsRequest): Promise<RecommendationsResponse>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
##### Parameters
|
|
163
|
+
|
|
164
|
+
- `options.limit` (optional): Maximum number of recommendations to return
|
|
165
|
+
- `options.cursor` (optional): Cursor from previous response to fetch the next page
|
|
166
|
+
|
|
167
|
+
##### Returns
|
|
168
|
+
|
|
169
|
+
- `Promise<RecommendationsResponse>`: Response containing:
|
|
170
|
+
- `items?: Array<RecommendationItem>`: List of recommended articles
|
|
171
|
+
- `cursor?: string`: Cursor to request the next page, if any
|
|
172
|
+
|
|
173
|
+
##### RecommendationItem
|
|
174
|
+
|
|
175
|
+
- `id?: string`: Your article ID
|
|
176
|
+
- `assetId?: string`: BitBitPress's ID
|
|
177
|
+
- `title?: string`: Article title
|
|
178
|
+
- `content?: string`: Article content
|
|
179
|
+
- `publishedAt?: string`: Publication date (e.g., "2021-01-01")
|
|
180
|
+
- `score?: number`: Recommendation score (e.g., 0.95)
|
|
181
|
+
|
|
182
|
+
##### Example
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
const recommendations = await client.user.recommendations({
|
|
186
|
+
limit: 10,
|
|
187
|
+
cursor: 'optional-cursor-from-previous-response',
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
console.log('Recommendations:', recommendations.items);
|
|
191
|
+
console.log('Next cursor:', recommendations.cursor);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
##### Throws
|
|
195
|
+
|
|
196
|
+
- `Error`: If the request fails or no data is returned
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
#### signal
|
|
201
|
+
|
|
202
|
+
Record a user signal (e.g., clicked topic, read article) to inform profile interests. Signals are used to power a user's recommendations.
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
client.user.signal(options: SignalRequest): Promise<SignalResponse>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
##### Parameters
|
|
209
|
+
|
|
210
|
+
- `options.signal` (required): User action with the text associated with the interaction (e.g., `'searched for \"best restaurants\"'`)
|
|
211
|
+
- `options.type` (required): Signal type - `"active"` or `"passive"`
|
|
212
|
+
- `"active"`: Explicit intent (click, search, subscribe)
|
|
213
|
+
- `"passive"`: Implicit intent (read, scroll, dwell)
|
|
214
|
+
- `options.negative` (optional): When `true`, indicates the signal is negative (e.g., dislike, unfollow). Defaults to `false`. Use sparingly.
|
|
215
|
+
- `options.contentContext` (optional): Context about the content that triggered this signal
|
|
216
|
+
- `contentId` (required): The ID of the content (e.g., your article ID)
|
|
217
|
+
- `contentType` (required): The type of content (currently only `"article"`)
|
|
218
|
+
|
|
219
|
+
##### Returns
|
|
220
|
+
|
|
221
|
+
- `Promise<SignalResponse>`: Response containing:
|
|
222
|
+
- `recorded?: boolean`: Whether the signal was recorded (false if no user or empty signal)
|
|
223
|
+
|
|
224
|
+
##### Example
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
// Active signal (explicit intent)
|
|
228
|
+
await client.user.signal({
|
|
229
|
+
signal: 'searched "best restaurants"',
|
|
230
|
+
type: 'active',
|
|
231
|
+
contentContext: {
|
|
232
|
+
contentId: 'article-123',
|
|
233
|
+
contentType: 'article',
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Passive signal (implicit intent)
|
|
238
|
+
await client.user.signal({
|
|
239
|
+
signal: 'read article about NBA trades',
|
|
240
|
+
type: 'passive',
|
|
241
|
+
contentContext: {
|
|
242
|
+
contentId: 'article-456',
|
|
243
|
+
contentType: 'article',
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// Negative signal (use sparingly)
|
|
248
|
+
await client.user.signal({
|
|
249
|
+
signal: 'unfollowed topic "Politics"',
|
|
250
|
+
type: 'active',
|
|
251
|
+
negative: true,
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
##### Throws
|
|
256
|
+
|
|
257
|
+
- `Error`: If the request fails or no data is returned
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
#### synthesizeItem
|
|
262
|
+
|
|
263
|
+
Synthesize a single item (batched). Items are automatically batched and sent together after the configured timeout. Returns a promise that resolves with the `data` field from the event (excluding 'connected' and 'complete' events).
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
client.user.synthesizeItem(item: SynthesizeRequest['items'][number]): Promise<unknown>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
##### Parameters
|
|
270
|
+
|
|
271
|
+
- `item` (required): A single synthesize item (same format as items in `synthesize`)
|
|
272
|
+
|
|
273
|
+
##### Returns
|
|
274
|
+
|
|
275
|
+
- `Promise<unknown>`: A promise that resolves with the `data` field from the event for this specific item. The data will be:
|
|
276
|
+
- For `DAILY_SUMMARY`: `{ summary: string | null }`
|
|
277
|
+
- For `CUSTOM`: An object following your schema input, where `fieldNames` are keys
|
|
278
|
+
|
|
279
|
+
##### Behavior
|
|
280
|
+
|
|
281
|
+
- Items added within the batch timeout window (default: 250ms) are grouped together and sent in a single request
|
|
282
|
+
- Each item's promise resolves immediately when its data event arrives (based on the `index` field)
|
|
283
|
+
- The batching happens in the background - promises resolve as soon as the batch request is sent
|
|
284
|
+
- Only data events (DAILY_SUMMARY or CUSTOM) resolve the promise - 'connected' and 'complete' events are ignored
|
|
285
|
+
- The batch timeout can be configured when creating the client via `synthesizeBatchTimeout`
|
|
286
|
+
|
|
287
|
+
##### Example
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
// Items are automatically batched and sent together after the timeout
|
|
291
|
+
// Each promise resolves with the data field from the event
|
|
292
|
+
const dailySummaryData = await client.user.synthesizeItem({
|
|
293
|
+
type: 'DAILY_SUMMARY',
|
|
294
|
+
});
|
|
295
|
+
// dailySummaryData will be: { summary: string | null }
|
|
296
|
+
console.log('Daily summary:', dailySummaryData);
|
|
297
|
+
|
|
298
|
+
const customData = await client.user.synthesizeItem({
|
|
299
|
+
type: 'CUSTOM',
|
|
300
|
+
schema: [{ fieldName: 'title', fieldDescription: 'The article title' }],
|
|
301
|
+
contentContext: {
|
|
302
|
+
contentId: 'article-123',
|
|
303
|
+
contentType: 'article',
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
// customData will be an object with keys matching your schema fieldNames
|
|
307
|
+
console.log('Custom data:', customData);
|
|
308
|
+
|
|
309
|
+
// Both items are sent together in a single batch request
|
|
310
|
+
// Each promise resolves immediately when its data event arrives
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
#### synthesize
|
|
316
|
+
|
|
317
|
+
Synthesize user content (streaming). Returns a stream of events for all items.
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
client.user.synthesize(items: SynthesizeRequest['items']): Promise<AsyncIterable<SynthesizeEvent>>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
##### Parameters
|
|
324
|
+
|
|
325
|
+
- `items` (required): Array of items to synthesize. Each item can be:
|
|
326
|
+
- `{ type: "DAILY_SUMMARY" }`: Generate a daily summary
|
|
327
|
+
- `{ type: "CUSTOM", schema: Array<SchemaField>, contentContext: ContentContext }`: Custom synthesis with schema (contentContext is required for CUSTOM items)
|
|
328
|
+
|
|
329
|
+
##### SchemaField
|
|
330
|
+
|
|
331
|
+
- `fieldName` (required): Name of the field
|
|
332
|
+
- `fieldDescription` (required): A prompt describing the value of the field
|
|
333
|
+
|
|
334
|
+
##### ContentContext (required for CUSTOM items)
|
|
335
|
+
|
|
336
|
+
- `contentId` (optional): Your content ID
|
|
337
|
+
- `contentType` (optional): The type of content to synthesize (currently only `"article"`)
|
|
338
|
+
|
|
339
|
+
##### Returns
|
|
340
|
+
|
|
341
|
+
- `Promise<AsyncIterable<SynthesizeEvent>>`: An async iterable stream of events
|
|
342
|
+
|
|
343
|
+
##### SynthesizeEvent
|
|
344
|
+
|
|
345
|
+
Events in the stream can be:
|
|
346
|
+
|
|
347
|
+
- `{ type: "connected" }`: Connection established
|
|
348
|
+
- `{ type: "DAILY_SUMMARY", index: number, data: { summary: string | null } }`: Daily summary data
|
|
349
|
+
- `{ type: "CUSTOM", index: number, data: {...} }`: Custom data following your schema
|
|
350
|
+
- `{ type: "complete" }`: Stream complete
|
|
351
|
+
|
|
352
|
+
##### Example
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
const stream = await client.user.synthesize([
|
|
356
|
+
{
|
|
357
|
+
type: 'DAILY_SUMMARY',
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
type: 'CUSTOM',
|
|
361
|
+
schema: [
|
|
362
|
+
{ fieldName: 'title', fieldDescription: 'The article title' },
|
|
363
|
+
{ fieldName: 'summary', fieldDescription: 'A brief summary' },
|
|
364
|
+
],
|
|
365
|
+
contentContext: {
|
|
366
|
+
contentId: 'article-123',
|
|
367
|
+
contentType: 'article',
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
]);
|
|
371
|
+
|
|
372
|
+
for await (const event of stream) {
|
|
373
|
+
switch (event.type) {
|
|
374
|
+
case 'connected':
|
|
375
|
+
console.log('Stream connected');
|
|
376
|
+
break;
|
|
377
|
+
case 'DAILY_SUMMARY':
|
|
378
|
+
console.log('Daily summary:', event.data);
|
|
379
|
+
break;
|
|
380
|
+
case 'CUSTOM':
|
|
381
|
+
console.log('Custom data:', event.data);
|
|
382
|
+
break;
|
|
383
|
+
case 'complete':
|
|
384
|
+
console.log('Stream complete');
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
### Types
|
|
393
|
+
|
|
394
|
+
#### BitBitPressClientConfig
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
interface BitBitPressClientConfig {
|
|
398
|
+
baseUrl: string;
|
|
399
|
+
fetch?: typeof fetch;
|
|
400
|
+
headers?: Record<string, string>;
|
|
401
|
+
timeout?: number;
|
|
402
|
+
synthesizeBatchTimeout?: number;
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
#### TokenRequest
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
type TokenRequest = {
|
|
410
|
+
ssoToken: string;
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
#### TokenResponse
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
type TokenResponse = {
|
|
418
|
+
idToken?: string;
|
|
419
|
+
accessToken?: string;
|
|
420
|
+
refreshToken?: string;
|
|
421
|
+
expiresIn?: number;
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
#### RecommendationsRequest
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
type RecommendationsRequest = {
|
|
429
|
+
limit?: number;
|
|
430
|
+
cursor?: string;
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
#### RecommendationsResponse
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
type RecommendationsResponse = {
|
|
438
|
+
items?: Array<{
|
|
439
|
+
id?: string;
|
|
440
|
+
assetId?: string;
|
|
441
|
+
title?: string;
|
|
442
|
+
summary?: string;
|
|
443
|
+
content?: string;
|
|
444
|
+
publishedAt?: string;
|
|
445
|
+
score?: number;
|
|
446
|
+
}>;
|
|
447
|
+
cursor?: string;
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
#### SignalRequest
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
type SignalRequest = {
|
|
455
|
+
signal: string;
|
|
456
|
+
type: 'active' | 'passive';
|
|
457
|
+
negative?: boolean;
|
|
458
|
+
contentContext?: {
|
|
459
|
+
contentId: string;
|
|
460
|
+
contentType: 'article';
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
#### SignalResponse
|
|
466
|
+
|
|
467
|
+
```typescript
|
|
468
|
+
type SignalResponse = {
|
|
469
|
+
recorded?: boolean;
|
|
470
|
+
}
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
#### SynthesizeRequest
|
|
474
|
+
|
|
475
|
+
```typescript
|
|
476
|
+
type SynthesizeRequest = {
|
|
477
|
+
items: Array<
|
|
478
|
+
| { type: 'DAILY_SUMMARY' }
|
|
479
|
+
| {
|
|
480
|
+
type: 'CUSTOM';
|
|
481
|
+
schema: Array<{
|
|
482
|
+
fieldName: string;
|
|
483
|
+
fieldDescription: string;
|
|
484
|
+
}>;
|
|
485
|
+
contentContext: {
|
|
486
|
+
contentId?: string;
|
|
487
|
+
contentType?: 'article';
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
>;
|
|
491
|
+
}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
#### SynthesizeEvent
|
|
495
|
+
|
|
496
|
+
```typescript
|
|
497
|
+
type SynthesizeEvent = {
|
|
498
|
+
type: 'DAILY_SUMMARY' | 'CUSTOM' | 'connected' | 'complete';
|
|
499
|
+
index?: number;
|
|
500
|
+
data?: unknown;
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
For `DAILY_SUMMARY` events, `data` will be:
|
|
505
|
+
```typescript
|
|
506
|
+
{
|
|
507
|
+
summary: string | null;
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
For `CUSTOM` events, `data` will be an object following your schema input, where `fieldNames` are keys.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type UserMethods } from './user/index.js';
|
|
1
2
|
/**
|
|
2
3
|
* Configuration for the BitBitPress client
|
|
3
4
|
*/
|
|
@@ -39,6 +40,7 @@ export interface BitBitPressClientOptions extends BitBitPressClientConfig {
|
|
|
39
40
|
*/
|
|
40
41
|
export declare class BitBitPressClient {
|
|
41
42
|
private config;
|
|
43
|
+
private userMethodsInstance?;
|
|
42
44
|
constructor(options: BitBitPressClientOptions);
|
|
43
45
|
/**
|
|
44
46
|
* Update the base URL
|
|
@@ -54,32 +56,8 @@ export declare class BitBitPressClient {
|
|
|
54
56
|
private getSynthesizeBatchTimeout;
|
|
55
57
|
/**
|
|
56
58
|
* User-related API methods
|
|
59
|
+
* Provides type-safe access to user endpoints like signal, recommendations, synthesize, etc.
|
|
57
60
|
*/
|
|
58
|
-
get user():
|
|
59
|
-
authenticate(ssoToken: string): Promise<void>;
|
|
60
|
-
token: (ssoToken: import("./user/token.js").TokenRequest["ssoToken"]) => Promise<{
|
|
61
|
-
idToken?: string;
|
|
62
|
-
accessToken?: string;
|
|
63
|
-
refreshToken?: string;
|
|
64
|
-
expiresIn?: number;
|
|
65
|
-
}>;
|
|
66
|
-
recommendations: (options?: import("./user/recommendations.js").RecommendationsRequest) => Promise<{
|
|
67
|
-
items?: {
|
|
68
|
-
id?: string;
|
|
69
|
-
assetId?: string;
|
|
70
|
-
title?: string;
|
|
71
|
-
summary?: string;
|
|
72
|
-
content?: string;
|
|
73
|
-
publishedAt?: string;
|
|
74
|
-
score?: number;
|
|
75
|
-
}[];
|
|
76
|
-
cursor?: string;
|
|
77
|
-
}>;
|
|
78
|
-
signal: (options: import("./user/signal.js").SignalRequest) => Promise<{
|
|
79
|
-
recorded?: boolean;
|
|
80
|
-
}>;
|
|
81
|
-
synthesize: (items: import("./user/typeDefs.js").SynthesizeRequest["items"]) => Promise<AsyncIterable<import("./user/synthesize.js").SynthesizeEvent>>;
|
|
82
|
-
synthesizeItem: (item: import("./user/typeDefs.js").SynthesizeRequest["items"][number]) => Promise<unknown>;
|
|
83
|
-
};
|
|
61
|
+
get user(): UserMethods;
|
|
84
62
|
}
|
|
85
63
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,uBAAuB;CAAG;AAE5E;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CACkE;IAChF,OAAO,CAAC,mBAAmB,CAAC,CAAc;gBAE9B,OAAO,EAAE,wBAAwB;IAqB7C;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAIjC;;;OAGG;IACH,IAAI,IAAI,IAAI,WAAW,CAQtB;CACF"}
|
package/dist/client.js
CHANGED
|
@@ -10,6 +10,7 @@ const index_js_1 = require("./user/index.js");
|
|
|
10
10
|
*/
|
|
11
11
|
class BitBitPressClient {
|
|
12
12
|
config;
|
|
13
|
+
userMethodsInstance;
|
|
13
14
|
constructor(options) {
|
|
14
15
|
if (!options.baseUrl) {
|
|
15
16
|
throw new Error('baseUrl is required. Please provide your custom Control Room API Url.');
|
|
@@ -31,6 +32,8 @@ class BitBitPressClient {
|
|
|
31
32
|
*/
|
|
32
33
|
setBaseUrl(baseUrl) {
|
|
33
34
|
this.config.baseUrl = baseUrl;
|
|
35
|
+
// Invalidate cached user methods instance so it gets recreated with new baseUrl
|
|
36
|
+
this.userMethodsInstance = undefined;
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
36
39
|
* Get request configuration for making API calls
|
|
@@ -51,9 +54,13 @@ class BitBitPressClient {
|
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
53
56
|
* User-related API methods
|
|
57
|
+
* Provides type-safe access to user endpoints like signal, recommendations, synthesize, etc.
|
|
54
58
|
*/
|
|
55
59
|
get user() {
|
|
56
|
-
|
|
60
|
+
if (!this.userMethodsInstance) {
|
|
61
|
+
this.userMethodsInstance = (0, index_js_1.createUserMethods)(this.getRequestConfig(), this.getSynthesizeBatchTimeout());
|
|
62
|
+
}
|
|
63
|
+
return this.userMethodsInstance;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
exports.BitBitPressClient = BitBitPressClient;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AACA,8CAAsE;AAwCtE;;;;;GAKG;AACH,MAAa,iBAAiB;IACpB,MAAM,CACkE;IACxE,mBAAmB,CAAe;IAE1C,YAAY,OAAiC;QAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;QAC3F,CAAC;QAED,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;YACjC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;YACtD,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YAC1F,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC;QAEF,8BAA8B;QAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,iIAAiI,CAClI,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAe;QACxB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC9B,gFAAgF;QAChF,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;IACvC,CAAC;IAED;;OAEG;IACK,gBAAgB;QACtB,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAM;YACzB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;SAC7B,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,yBAAyB;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC9B,IAAI,CAAC,mBAAmB,GAAG,IAAA,4BAAiB,EAC1C,IAAI,CAAC,gBAAgB,EAAE,EACvB,IAAI,CAAC,yBAAyB,EAAE,CACjC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;CACF;AAnED,8CAmEC"}
|