@bitbitpress/client 0.1.4 → 0.1.5
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 +130 -28
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -1
- package/dist/client.js.map +1 -1
- package/dist/examples/basic-usage.d.ts +2 -1
- package/dist/examples/basic-usage.d.ts.map +1 -1
- package/dist/examples/basic-usage.js +57 -17
- package/dist/examples/basic-usage.js.map +1 -1
- package/dist/generated/openapi.d.ts +43 -28
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/user/index.d.ts +12 -4
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user/index.js +9 -5
- package/dist/user/index.js.map +1 -1
- package/dist/user/signal-batch-manager.d.ts +22 -0
- package/dist/user/signal-batch-manager.d.ts.map +1 -0
- package/dist/user/signal-batch-manager.js +73 -0
- package/dist/user/signal-batch-manager.js.map +1 -0
- package/dist/user/signal.d.ts +3 -2
- package/dist/user/signal.d.ts.map +1 -1
- package/dist/user/signal.js +2 -2
- package/dist/user/signal.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ More details can also be found in your control room's API docs @ https://your-co
|
|
|
47
47
|
- [recommendations](#recommendations)
|
|
48
48
|
- [report](#report)
|
|
49
49
|
- [signal](#signal)
|
|
50
|
+
- [signalItem](#signalitem)
|
|
50
51
|
- [synthesizeItem](#synthesizeitem)
|
|
51
52
|
- [synthesize](#synthesize)
|
|
52
53
|
- [Types](#types)
|
|
@@ -68,6 +69,7 @@ new BitBitPressClient(options: BitBitPressClientOptions)
|
|
|
68
69
|
- `options.headers` (optional): Additional headers to include in all requests
|
|
69
70
|
- `options.timeout` (optional): Request timeout in milliseconds (default: `30000`)
|
|
70
71
|
- `options.synthesizeBatchTimeout` (optional): Batch timeout for `synthesizeItem` in milliseconds (default: `250`)
|
|
72
|
+
- `options.signalBatchTimeout` (optional): Batch timeout for `signalItem` in milliseconds (default: `250`)
|
|
71
73
|
|
|
72
74
|
##### Example
|
|
73
75
|
|
|
@@ -76,6 +78,7 @@ const client = new BitBitPressClient({
|
|
|
76
78
|
baseUrl: 'https://your-control-room.api.dev.bitbitpress.com',
|
|
77
79
|
timeout: 30000,
|
|
78
80
|
synthesizeBatchTimeout: 250,
|
|
81
|
+
signalBatchTimeout: 250,
|
|
79
82
|
});
|
|
80
83
|
```
|
|
81
84
|
|
|
@@ -191,6 +194,7 @@ client.user.recommendations(options?: RecommendationsRequest): Promise<Recommend
|
|
|
191
194
|
|
|
192
195
|
- `options.limit` (optional): Maximum number of recommendations to return
|
|
193
196
|
- `options.cursor` (optional): Cursor from previous response to fetch the next page
|
|
197
|
+
- `options.fields` (optional): Asset fields to return (dot or bracket notation, e.g. `tags[0]`, `images[1].src`). Allowed: `title`, `tags`, `images`, `videos`, `publishedAt`, `externalId` (your content id), `externalData` and subfields. Returned as JSON string in `fields`.
|
|
194
198
|
|
|
195
199
|
##### Returns
|
|
196
200
|
|
|
@@ -200,12 +204,23 @@ client.user.recommendations(options?: RecommendationsRequest): Promise<Recommend
|
|
|
200
204
|
|
|
201
205
|
##### RecommendationItem
|
|
202
206
|
|
|
203
|
-
- `id?: string`: Your article ID
|
|
204
207
|
- `assetId?: string`: BitBitPress's ID
|
|
205
|
-
- `title?: string`: Article title
|
|
206
|
-
- `content?: string`: Article content
|
|
207
|
-
- `publishedAt?: string`: Publication date (e.g., "2021-01-01")
|
|
208
208
|
- `score?: number`: Recommendation score (e.g., 0.95)
|
|
209
|
+
- `fields?: string`: JSON string of requested asset fields (when `fields` provided in request)
|
|
210
|
+
|
|
211
|
+
##### Available Fields
|
|
212
|
+
|
|
213
|
+
Use dot or bracket notation (e.g. `tags[0]`, `images[1].src`). Requested values are returned as a JSON string in each item's `fields` property.
|
|
214
|
+
|
|
215
|
+
| Field | Type | Structure |
|
|
216
|
+
|-------|------|-----------|
|
|
217
|
+
| `title` | string | Title |
|
|
218
|
+
| `tags` | string[] | Array of strings (auto-extracted or manual tags) |
|
|
219
|
+
| `images` | array | Each item: `{ src, externalId, alt, width, height, credit }` |
|
|
220
|
+
| `videos` | array | Each item: `{ sources: [{ mimeType, src }], externalId, alt, credit, posterUrl, caption, width, height }` |
|
|
221
|
+
| `publishedAt` | string | ISO date when the article was originally published |
|
|
222
|
+
| `externalId` | string | unique identifier from source (your content id) |
|
|
223
|
+
| `externalData` | any | data unique to your content (you must extract subfields that you need from your article data type) |
|
|
209
224
|
|
|
210
225
|
##### Example
|
|
211
226
|
|
|
@@ -213,10 +228,22 @@ client.user.recommendations(options?: RecommendationsRequest): Promise<Recommend
|
|
|
213
228
|
const recommendations = await client.user.recommendations({
|
|
214
229
|
limit: 10,
|
|
215
230
|
cursor: 'optional-cursor-from-previous-response',
|
|
231
|
+
fields: ['title', 'tags', 'images[0].src', 'publishedAt'],
|
|
216
232
|
});
|
|
217
233
|
|
|
218
234
|
console.log('Recommendations:', recommendations.items);
|
|
219
235
|
console.log('Next cursor:', recommendations.cursor);
|
|
236
|
+
|
|
237
|
+
// Access requested fields from the fields JSON string
|
|
238
|
+
if (recommendations.items) {
|
|
239
|
+
for (const item of recommendations.items) {
|
|
240
|
+
if (item.fields) {
|
|
241
|
+
const fields = JSON.parse(item.fields);
|
|
242
|
+
console.log('Title:', fields.title);
|
|
243
|
+
console.log('Tags:', fields.tags);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
220
247
|
```
|
|
221
248
|
|
|
222
249
|
##### Throws
|
|
@@ -259,7 +286,7 @@ await client.user.report({
|
|
|
259
286
|
|
|
260
287
|
#### signal
|
|
261
288
|
|
|
262
|
-
Record
|
|
289
|
+
Record user signals (e.g., clicked topic, read article) to inform profile interests. Signals are used to power a user's recommendations.
|
|
263
290
|
|
|
264
291
|
```typescript
|
|
265
292
|
client.user.signal(options: SignalRequest): Promise<SignalResponse>
|
|
@@ -267,25 +294,88 @@ client.user.signal(options: SignalRequest): Promise<SignalResponse>
|
|
|
267
294
|
|
|
268
295
|
##### Parameters
|
|
269
296
|
|
|
270
|
-
- `options.
|
|
271
|
-
- `
|
|
272
|
-
- `"active"
|
|
273
|
-
|
|
274
|
-
- `
|
|
275
|
-
- `
|
|
276
|
-
- `
|
|
277
|
-
|
|
297
|
+
- `options.signals` (required): Array of signals to record. Each signal object contains:
|
|
298
|
+
- `signal` (required): User action with the text associated with the interaction (e.g., `'searched for \"best restaurants\"'`)
|
|
299
|
+
- `type` (required): Signal type - `"active"` or `"passive"`
|
|
300
|
+
- `"active"`: Explicit intent (click, search, subscribe)
|
|
301
|
+
- `"passive"`: Implicit intent (read, scroll, dwell)
|
|
302
|
+
- `negative` (optional): When `true`, indicates the signal is negative (e.g., dislike, unfollow). Defaults to `false`. Use sparingly.
|
|
303
|
+
- `contentContext` (optional): Context about the content that triggered this signal
|
|
304
|
+
- `contentId` (required): The ID of the content (e.g., your article ID)
|
|
305
|
+
- `contentType` (required): The type of content (currently only `"article"`)
|
|
278
306
|
|
|
279
307
|
##### Returns
|
|
280
308
|
|
|
281
309
|
- `Promise<SignalResponse>`: Response containing:
|
|
282
|
-
- `recorded?: boolean`: Whether the
|
|
310
|
+
- `recorded?: boolean`: Whether the signals were recorded (false if no user or no valid signals)
|
|
283
311
|
|
|
284
312
|
##### Example
|
|
285
313
|
|
|
286
314
|
```typescript
|
|
287
|
-
//
|
|
315
|
+
// Record multiple signals at once
|
|
288
316
|
await client.user.signal({
|
|
317
|
+
signals: [
|
|
318
|
+
{
|
|
319
|
+
signal: 'searched "best restaurants"',
|
|
320
|
+
type: 'active',
|
|
321
|
+
contentContext: {
|
|
322
|
+
contentId: 'article-123',
|
|
323
|
+
contentType: 'article',
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
signal: 'read article about NBA trades',
|
|
328
|
+
type: 'passive',
|
|
329
|
+
contentContext: {
|
|
330
|
+
contentId: 'article-456',
|
|
331
|
+
contentType: 'article',
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
signal: 'unfollowed topic "Politics"',
|
|
336
|
+
type: 'active',
|
|
337
|
+
negative: true,
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
});
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
##### Throws
|
|
344
|
+
|
|
345
|
+
- `Error`: If the request fails or no data is returned
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
#### signalItem
|
|
350
|
+
|
|
351
|
+
Record a single signal (batched). Signals are automatically batched and sent together after the configured timeout.
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
client.user.signalItem(signal: Signal): Promise<SignalResponse>
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
##### Parameters
|
|
358
|
+
|
|
359
|
+
- `signal` (required): A single signal object (same format as items in the `signals` array for `signal`)
|
|
360
|
+
|
|
361
|
+
##### Returns
|
|
362
|
+
|
|
363
|
+
- `Promise<SignalResponse>`: Response containing:
|
|
364
|
+
- `recorded?: boolean`: Whether the signal was recorded (false if no user or no valid signals)
|
|
365
|
+
|
|
366
|
+
##### Behavior
|
|
367
|
+
|
|
368
|
+
- Signals added within the batch timeout window (default: 250ms) are grouped together and sent in a single request
|
|
369
|
+
- Each signal's promise resolves with the batch response when the request completes
|
|
370
|
+
- The batching happens in the background - promises resolve as soon as the batch request completes
|
|
371
|
+
- The batch timeout can be configured when creating the client via `signalBatchTimeout`
|
|
372
|
+
|
|
373
|
+
##### Example
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
// Signals are automatically batched and sent together after the timeout
|
|
377
|
+
// Each promise resolves with the batch response
|
|
378
|
+
const response1 = await client.user.signalItem({
|
|
289
379
|
signal: 'searched "best restaurants"',
|
|
290
380
|
type: 'active',
|
|
291
381
|
contentContext: {
|
|
@@ -294,8 +384,7 @@ await client.user.signal({
|
|
|
294
384
|
},
|
|
295
385
|
});
|
|
296
386
|
|
|
297
|
-
|
|
298
|
-
await client.user.signal({
|
|
387
|
+
const response2 = await client.user.signalItem({
|
|
299
388
|
signal: 'read article about NBA trades',
|
|
300
389
|
type: 'passive',
|
|
301
390
|
contentContext: {
|
|
@@ -304,12 +393,10 @@ await client.user.signal({
|
|
|
304
393
|
},
|
|
305
394
|
});
|
|
306
395
|
|
|
307
|
-
//
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
negative: true,
|
|
312
|
-
});
|
|
396
|
+
// Both signals are sent together in a single batch request
|
|
397
|
+
// Each promise resolves when the batch request completes
|
|
398
|
+
console.log('Signal 1 recorded:', response1.recorded);
|
|
399
|
+
console.log('Signal 2 recorded:', response2.recorded);
|
|
313
400
|
```
|
|
314
401
|
|
|
315
402
|
##### Throws
|
|
@@ -390,6 +477,7 @@ client.user.synthesize(items: SynthesizeRequest['items']): Promise<AsyncIterable
|
|
|
390
477
|
|
|
391
478
|
- `fieldName` (required): Name of the field
|
|
392
479
|
- `fieldDescription` (required): A prompt describing the value of the field
|
|
480
|
+
- `fieldCharacterLimit` (optional): The maximum number of characters that can be returned for this field
|
|
393
481
|
|
|
394
482
|
##### ContentContext (required for CUSTOM items)
|
|
395
483
|
|
|
@@ -460,6 +548,7 @@ interface BitBitPressClientConfig {
|
|
|
460
548
|
headers?: Record<string, string>;
|
|
461
549
|
timeout?: number;
|
|
462
550
|
synthesizeBatchTimeout?: number;
|
|
551
|
+
signalBatchTimeout?: number;
|
|
463
552
|
}
|
|
464
553
|
```
|
|
465
554
|
|
|
@@ -488,6 +577,7 @@ type TokenResponse = {
|
|
|
488
577
|
type RecommendationsRequest = {
|
|
489
578
|
limit?: number;
|
|
490
579
|
cursor?: string;
|
|
580
|
+
fields?: string[];
|
|
491
581
|
}
|
|
492
582
|
```
|
|
493
583
|
|
|
@@ -504,13 +594,9 @@ type ProfileResponse = {
|
|
|
504
594
|
```typescript
|
|
505
595
|
type RecommendationsResponse = {
|
|
506
596
|
items?: Array<{
|
|
507
|
-
id?: string;
|
|
508
597
|
assetId?: string;
|
|
509
|
-
title?: string;
|
|
510
|
-
summary?: string;
|
|
511
|
-
content?: string;
|
|
512
|
-
publishedAt?: string;
|
|
513
598
|
score?: number;
|
|
599
|
+
fields?: string; // JSON string of requested asset fields
|
|
514
600
|
}>;
|
|
515
601
|
cursor?: string;
|
|
516
602
|
}
|
|
@@ -535,6 +621,22 @@ type ReportResponse = unknown;
|
|
|
535
621
|
|
|
536
622
|
```typescript
|
|
537
623
|
type SignalRequest = {
|
|
624
|
+
signals: Array<{
|
|
625
|
+
signal: string;
|
|
626
|
+
type: 'active' | 'passive';
|
|
627
|
+
negative?: boolean;
|
|
628
|
+
contentContext?: {
|
|
629
|
+
contentId: string;
|
|
630
|
+
contentType: 'article';
|
|
631
|
+
};
|
|
632
|
+
}>;
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
#### Signal
|
|
637
|
+
|
|
638
|
+
```typescript
|
|
639
|
+
type Signal = {
|
|
538
640
|
signal: string;
|
|
539
641
|
type: 'active' | 'passive';
|
|
540
642
|
negative?: boolean;
|
package/dist/client.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface BitBitPressClientConfig {
|
|
|
26
26
|
* @default 250
|
|
27
27
|
*/
|
|
28
28
|
synthesizeBatchTimeout?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Batch timeout for signalItem in milliseconds
|
|
31
|
+
* Signals will be batched and sent after this delay
|
|
32
|
+
* @default 250
|
|
33
|
+
*/
|
|
34
|
+
signalBatchTimeout?: number;
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
31
37
|
* Options for creating a BitBitPress client instance
|
|
@@ -54,6 +60,10 @@ export declare class BitBitPressClient {
|
|
|
54
60
|
* Get synthesize batch timeout configuration
|
|
55
61
|
*/
|
|
56
62
|
private getSynthesizeBatchTimeout;
|
|
63
|
+
/**
|
|
64
|
+
* Get signal batch timeout configuration
|
|
65
|
+
*/
|
|
66
|
+
private getSignalBatchTimeout;
|
|
57
67
|
/**
|
|
58
68
|
* User-related API methods
|
|
59
69
|
* Provides type-safe access to user endpoints like signal, recommendations, synthesize, etc.
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAEhC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,uBAAuB;CAAG;AAE5E;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CACyF;IACvG,OAAO,CAAC,mBAAmB,CAAC,CAAc;gBAE9B,OAAO,EAAE,wBAAwB;IAsB7C;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAIjC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;;OAGG;IACH,IAAI,IAAI,IAAI,WAAW,CAStB;CACF"}
|
package/dist/client.js
CHANGED
|
@@ -19,6 +19,7 @@ class BitBitPressClient {
|
|
|
19
19
|
baseUrl: options.baseUrl,
|
|
20
20
|
timeout: options.timeout ?? 30000,
|
|
21
21
|
synthesizeBatchTimeout: options.synthesizeBatchTimeout,
|
|
22
|
+
signalBatchTimeout: options.signalBatchTimeout,
|
|
22
23
|
fetch: options.fetch ?? (typeof globalThis !== 'undefined' ? globalThis.fetch : undefined),
|
|
23
24
|
headers: options.headers,
|
|
24
25
|
};
|
|
@@ -52,13 +53,19 @@ class BitBitPressClient {
|
|
|
52
53
|
getSynthesizeBatchTimeout() {
|
|
53
54
|
return this.config.synthesizeBatchTimeout;
|
|
54
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Get signal batch timeout configuration
|
|
58
|
+
*/
|
|
59
|
+
getSignalBatchTimeout() {
|
|
60
|
+
return this.config.signalBatchTimeout;
|
|
61
|
+
}
|
|
55
62
|
/**
|
|
56
63
|
* User-related API methods
|
|
57
64
|
* Provides type-safe access to user endpoints like signal, recommendations, synthesize, etc.
|
|
58
65
|
*/
|
|
59
66
|
get user() {
|
|
60
67
|
if (!this.userMethodsInstance) {
|
|
61
|
-
this.userMethodsInstance = (0, index_js_1.createUserMethods)(this.getRequestConfig(), this.getSynthesizeBatchTimeout());
|
|
68
|
+
this.userMethodsInstance = (0, index_js_1.createUserMethods)(this.getRequestConfig(), this.getSynthesizeBatchTimeout(), this.getSignalBatchTimeout());
|
|
62
69
|
}
|
|
63
70
|
return this.userMethodsInstance;
|
|
64
71
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AACA,8CAAsE;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AACA,8CAAsE;AA+CtE;;;;;GAKG;AACH,MAAa,iBAAiB;IACpB,MAAM,CACyF;IAC/F,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,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;YAC9C,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;;OAEG;IACK,qBAAqB;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;IACxC,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,EAChC,IAAI,CAAC,qBAAqB,EAAE,CAC7B,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;CACF;AA5ED,8CA4EC"}
|
|
@@ -7,5 +7,6 @@ declare function basicExample(): Promise<void>;
|
|
|
7
7
|
declare function streamingExample(): Promise<void>;
|
|
8
8
|
declare function batchedSynthesisExample(): Promise<void>;
|
|
9
9
|
declare function signalExample(): Promise<void>;
|
|
10
|
-
|
|
10
|
+
declare function batchedSignalExample(): Promise<void>;
|
|
11
|
+
export { basicExample, streamingExample, batchedSynthesisExample, signalExample, batchedSignalExample };
|
|
11
12
|
//# sourceMappingURL=basic-usage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic-usage.d.ts","sourceRoot":"","sources":["../../src/examples/basic-usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,iBAAe,YAAY,
|
|
1
|
+
{"version":3,"file":"basic-usage.d.ts","sourceRoot":"","sources":["../../src/examples/basic-usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,iBAAe,YAAY,kBA4B1B;AAGD,iBAAe,gBAAgB,kBAyC9B;AAGD,iBAAe,uBAAuB,kBA4BrC;AAGD,iBAAe,aAAa,kBAqC3B;AAGD,iBAAe,oBAAoB,kBAiClC;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,aAAa,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -16,14 +16,18 @@ async function basicExample() {
|
|
|
16
16
|
limit: 10,
|
|
17
17
|
});
|
|
18
18
|
console.log('Recommendations:', recommendations.items);
|
|
19
|
-
// Record
|
|
19
|
+
// Record user signals (e.g., user clicked on an article)
|
|
20
20
|
const signalResult = await client.user.signal({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
signals: [
|
|
22
|
+
{
|
|
23
|
+
signal: 'searched "best restaurants"',
|
|
24
|
+
type: 'active',
|
|
25
|
+
contentContext: {
|
|
26
|
+
contentId: 'article-123',
|
|
27
|
+
contentType: 'article',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
27
31
|
});
|
|
28
32
|
console.log('Signal recorded:', signalResult.recorded);
|
|
29
33
|
}
|
|
@@ -100,8 +104,47 @@ async function signalExample() {
|
|
|
100
104
|
});
|
|
101
105
|
// Authenticate first
|
|
102
106
|
await client.user.authenticate("your-user's-auth-sso-token");
|
|
103
|
-
// Record
|
|
107
|
+
// Record multiple signals at once
|
|
104
108
|
await client.user.signal({
|
|
109
|
+
signals: [
|
|
110
|
+
// Active signal (explicit intent like click, search, subscribe)
|
|
111
|
+
{
|
|
112
|
+
signal: 'clicked "Warriors intend to keep Jimmy Butler despite season-ending injury"',
|
|
113
|
+
type: 'active',
|
|
114
|
+
contentContext: {
|
|
115
|
+
contentId: 'article-123',
|
|
116
|
+
contentType: 'article',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
// Passive signal (implicit like read, scroll, dwell)
|
|
120
|
+
{
|
|
121
|
+
signal: 'read about NBA trades',
|
|
122
|
+
type: 'passive',
|
|
123
|
+
contentContext: {
|
|
124
|
+
contentId: 'article-456',
|
|
125
|
+
contentType: 'article',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
// Negative signal (e.g., dislike, unfollow) - use sparingly
|
|
129
|
+
{
|
|
130
|
+
signal: 'unfollowed topic "Politics"',
|
|
131
|
+
type: 'active',
|
|
132
|
+
negative: true,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
// Example 5: Batched signals with signalItem
|
|
138
|
+
async function batchedSignalExample() {
|
|
139
|
+
const client = new BitBitPressClient({
|
|
140
|
+
baseUrl: 'https://your-control-room.api.dev.bitbitpress.com',
|
|
141
|
+
signalBatchTimeout: 250, // Optional: customize batch timeout
|
|
142
|
+
});
|
|
143
|
+
// Authenticate first
|
|
144
|
+
await client.user.authenticate("your-user's-auth-sso-token");
|
|
145
|
+
// Signals are automatically batched and sent together after the timeout
|
|
146
|
+
// Each promise resolves with the batch response
|
|
147
|
+
const response1 = await client.user.signalItem({
|
|
105
148
|
signal: 'clicked "Warriors intend to keep Jimmy Butler despite season-ending injury"',
|
|
106
149
|
type: 'active',
|
|
107
150
|
contentContext: {
|
|
@@ -109,8 +152,7 @@ async function signalExample() {
|
|
|
109
152
|
contentType: 'article',
|
|
110
153
|
},
|
|
111
154
|
});
|
|
112
|
-
|
|
113
|
-
await client.user.signal({
|
|
155
|
+
const response2 = await client.user.signalItem({
|
|
114
156
|
signal: 'read about NBA trades',
|
|
115
157
|
type: 'passive',
|
|
116
158
|
contentContext: {
|
|
@@ -118,12 +160,10 @@ async function signalExample() {
|
|
|
118
160
|
contentType: 'article',
|
|
119
161
|
},
|
|
120
162
|
});
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
negative: true,
|
|
126
|
-
});
|
|
163
|
+
// Both signals are sent together in a single batch request
|
|
164
|
+
// Each promise resolves when the batch request completes
|
|
165
|
+
console.log('Signal 1 recorded:', response1.recorded);
|
|
166
|
+
console.log('Signal 2 recorded:', response2.recorded);
|
|
127
167
|
}
|
|
128
|
-
export { basicExample, streamingExample, batchedSynthesisExample, signalExample };
|
|
168
|
+
export { basicExample, streamingExample, batchedSynthesisExample, signalExample, batchedSignalExample };
|
|
129
169
|
//# sourceMappingURL=basic-usage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic-usage.js","sourceRoot":"","sources":["../../src/examples/basic-usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,6CAA6C;AAC7C,KAAK,UAAU,YAAY;IACzB,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC;QACnC,OAAO,EAAE,mDAAmD;KAC7D,CAAC,CAAC;IAEH,gFAAgF;IAChF,MAAM,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC;IAE7D,sBAAsB;IACtB,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;QACxD,KAAK,EAAE,EAAE;KACV,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IAEvD,
|
|
1
|
+
{"version":3,"file":"basic-usage.js","sourceRoot":"","sources":["../../src/examples/basic-usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,6CAA6C;AAC7C,KAAK,UAAU,YAAY;IACzB,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC;QACnC,OAAO,EAAE,mDAAmD;KAC7D,CAAC,CAAC;IAEH,gFAAgF;IAChF,MAAM,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAC;IAE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C;IAEH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QAC7C,MAAM,EAAE,uBAAuB;QAC/B,IAAI,EAAE,SAAS;QACf,cAAc,EAAE;YACd,SAAS,EAAE,aAAa;YACxB,WAAW,EAAE,SAAS;SACvB;KACF,CAAC,CAAC;IAEH,2DAA2D;IAC3D,yDAAyD;IACzD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,aAAa,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -225,6 +225,20 @@ export interface paths {
|
|
|
225
225
|
/**
|
|
226
226
|
* Retrieve User Recommendations
|
|
227
227
|
* @description **POST** `/v1/user/recommendations` Returns recommended articles for the authenticated user based on their interests.
|
|
228
|
+
*
|
|
229
|
+
* #### Available fields (`fields` in request body)
|
|
230
|
+
*
|
|
231
|
+
* Use dot or bracket notation (e.g. `tags[0]`, `images[1].src`). Requested values are returned as a JSON string in each item's `fields` property.
|
|
232
|
+
*
|
|
233
|
+
* | Field | Type | Structure |
|
|
234
|
+
* |-------|------|-----------|
|
|
235
|
+
* | `title` | string | Title |
|
|
236
|
+
* | `tags` | string[] | Array of strings (auto-extracted or manual tags) |
|
|
237
|
+
* | `images` | array | Each item: `{ src, externalId, alt, width, height, credit }` |
|
|
238
|
+
* | `videos` | array | Each item: `{ sources: [{ mimeType, src }], externalId, alt, credit, posterUrl, caption, width, height }` |
|
|
239
|
+
* | `publishedAt` | string | ISO date when the article was originally published |
|
|
240
|
+
* | `externalId` | string | unique identifier from source (your content id) |
|
|
241
|
+
* | `externalData` | any | data unique to your content (you must extract subfields that you need from your article data type) |
|
|
228
242
|
*/
|
|
229
243
|
post: {
|
|
230
244
|
parameters: {
|
|
@@ -243,6 +257,8 @@ export interface paths {
|
|
|
243
257
|
limit?: number;
|
|
244
258
|
/** @description Cursor from previous response to fetch the next page of recommendations */
|
|
245
259
|
cursor?: string;
|
|
260
|
+
/** @description Asset fields to return (dot or bracket notation, e.g. tags[0], images[1].src). Allowed: title, tags, images, videos, publishedAt, externalId (your content id), externalData, and subfields. Returned as JSON string in `fields`. */
|
|
261
|
+
fields?: string[];
|
|
246
262
|
};
|
|
247
263
|
};
|
|
248
264
|
};
|
|
@@ -260,18 +276,12 @@ export interface paths {
|
|
|
260
276
|
data?: {
|
|
261
277
|
/** @description List of recommended articles */
|
|
262
278
|
items?: {
|
|
263
|
-
/** @example Your article id */
|
|
264
|
-
id?: string;
|
|
265
279
|
/** @example BitBitPress's id */
|
|
266
280
|
assetId?: string;
|
|
267
|
-
/** @example Title */
|
|
268
|
-
title?: string;
|
|
269
|
-
/** @example Content */
|
|
270
|
-
content?: string;
|
|
271
|
-
/** @example 2021-01-01 */
|
|
272
|
-
publishedAt?: string;
|
|
273
281
|
/** @example 0.95 */
|
|
274
282
|
score?: number;
|
|
283
|
+
/** @description JSON string of requested asset fields (when `fields` provided in request) */
|
|
284
|
+
fields?: string;
|
|
275
285
|
}[];
|
|
276
286
|
/** @description Cursor to request the next page, if any */
|
|
277
287
|
cursor?: string;
|
|
@@ -434,8 +444,8 @@ export interface paths {
|
|
|
434
444
|
get?: never;
|
|
435
445
|
put?: never;
|
|
436
446
|
/**
|
|
437
|
-
* Record User
|
|
438
|
-
* @description **POST** `/v1/user/signal` Records
|
|
447
|
+
* Record User Signals
|
|
448
|
+
* @description **POST** `/v1/user/signal` Records user signals (e.g. clicked topic, read article) to inform profile interests. Signals power the user's recommendations.
|
|
439
449
|
*/
|
|
440
450
|
post: {
|
|
441
451
|
parameters: {
|
|
@@ -450,30 +460,33 @@ export interface paths {
|
|
|
450
460
|
requestBody: {
|
|
451
461
|
content: {
|
|
452
462
|
"application/json": {
|
|
453
|
-
/** @description
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
* @enum {string}
|
|
458
|
-
*/
|
|
459
|
-
type: "active" | "passive";
|
|
460
|
-
/** @description When true, indicates the signal is negative (e.g. dislike, unfollow). Use sparingly. Optional; defaults to false. */
|
|
461
|
-
negative?: boolean;
|
|
462
|
-
/** @description Optional context about the content that triggered this signal. */
|
|
463
|
-
contentContext?: {
|
|
464
|
-
/** @description The ID of the content (e.g. article ID). */
|
|
465
|
-
contentId: string;
|
|
463
|
+
/** @description Array of signals to record. */
|
|
464
|
+
signals: {
|
|
465
|
+
/** @description User action with the text associated with the interaction. (e.g. liked "Warriors intend to keep Jimmy Butler despite season-ending injury") */
|
|
466
|
+
signal: string;
|
|
466
467
|
/**
|
|
467
|
-
* @description
|
|
468
|
+
* @description `active` = explicit intent (click, search, subscribe). `passive` = implicit (read, scroll, dwell).
|
|
468
469
|
* @enum {string}
|
|
469
470
|
*/
|
|
470
|
-
|
|
471
|
-
|
|
471
|
+
type: "active" | "passive";
|
|
472
|
+
/** @description When true, indicates the signal is negative (e.g. dislike, unfollow). Use sparingly. Optional; defaults to false. */
|
|
473
|
+
negative?: boolean;
|
|
474
|
+
/** @description Optional context about the content that triggered this signal. */
|
|
475
|
+
contentContext?: {
|
|
476
|
+
/** @description The ID of the content (e.g. article ID). */
|
|
477
|
+
contentId: string;
|
|
478
|
+
/**
|
|
479
|
+
* @description The type of content.
|
|
480
|
+
* @enum {string}
|
|
481
|
+
*/
|
|
482
|
+
contentType: "article";
|
|
483
|
+
};
|
|
484
|
+
}[];
|
|
472
485
|
};
|
|
473
486
|
};
|
|
474
487
|
};
|
|
475
488
|
responses: {
|
|
476
|
-
/** @description
|
|
489
|
+
/** @description Signals recorded */
|
|
477
490
|
200: {
|
|
478
491
|
headers: {
|
|
479
492
|
[name: string]: unknown;
|
|
@@ -488,7 +501,7 @@ export interface paths {
|
|
|
488
501
|
/** @description Response payload */
|
|
489
502
|
data?: {
|
|
490
503
|
/**
|
|
491
|
-
* @description Whether the
|
|
504
|
+
* @description Whether the signals were recorded (false if no app user or no valid signals)
|
|
492
505
|
* @example true
|
|
493
506
|
*/
|
|
494
507
|
recorded?: boolean;
|
|
@@ -592,6 +605,8 @@ export interface paths {
|
|
|
592
605
|
fieldName: string;
|
|
593
606
|
/** @description A prompt describing the value of the field */
|
|
594
607
|
fieldDescription: string;
|
|
608
|
+
/** @description Optional max number of characters that can be returned for this field */
|
|
609
|
+
fieldCharacterLimit?: number;
|
|
595
610
|
}[];
|
|
596
611
|
/** @description Context data to provide to the prompt. */
|
|
597
612
|
contentContext: {
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { BitBitPressClientConfig, BitBitPressClientOptions } from './client
|
|
|
8
8
|
export { BitBitPressClient } from './client.js';
|
|
9
9
|
export type * from './generated/openapi.js';
|
|
10
10
|
export type { UserMethods } from './user/index.js';
|
|
11
|
-
export type { SignalRequest, SignalResponse } from './user/signal.js';
|
|
11
|
+
export type { Signal, SignalRequest, SignalResponse } from './user/signal.js';
|
|
12
12
|
export type { RecommendationsRequest, RecommendationsResponse } from './user/recommendations.js';
|
|
13
13
|
export type { ProfileResponse } from './user/profile.js';
|
|
14
14
|
export type { ReportRequest, ReportResponse } from './user/report.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,mBAAmB,wBAAwB,CAAC;AAG5C,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,mBAAmB,wBAAwB,CAAC;AAG5C,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9E,YAAY,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACjG,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/user/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { RequestConfig } from '../request.js';
|
|
|
2
2
|
import { type RecommendationsRequest, type RecommendationsResponse } from './recommendations.js';
|
|
3
3
|
import { type ProfileResponse } from './profile.js';
|
|
4
4
|
import { type ReportRequest, type ReportResponse } from './report.js';
|
|
5
|
-
import { type SignalRequest, type SignalResponse } from './signal.js';
|
|
5
|
+
import { type Signal, type SignalRequest, type SignalResponse } from './signal.js';
|
|
6
6
|
import { type SynthesizeEvent } from './synthesize.js';
|
|
7
7
|
import { type TokenRequest, type TokenResponse } from './token.js';
|
|
8
8
|
import type { SynthesizeRequest } from './typeDefs.js';
|
|
@@ -47,12 +47,20 @@ export interface UserMethods {
|
|
|
47
47
|
*/
|
|
48
48
|
report(options: ReportRequest): Promise<NonNullable<ReportResponse>>;
|
|
49
49
|
/**
|
|
50
|
-
* Record
|
|
50
|
+
* Record user signals (e.g. clicked topic, read article) to inform profile interests
|
|
51
51
|
*
|
|
52
|
-
* @param options - Signal request parameters
|
|
52
|
+
* @param options - Signal request parameters containing an array of signals
|
|
53
53
|
* @returns Promise that resolves with the signal response
|
|
54
54
|
*/
|
|
55
55
|
signal(options: SignalRequest): Promise<NonNullable<SignalResponse>>;
|
|
56
|
+
/**
|
|
57
|
+
* Record a single signal (batched)
|
|
58
|
+
* Signals are batched and sent together after the configured timeout
|
|
59
|
+
*
|
|
60
|
+
* @param signal - Single signal to record
|
|
61
|
+
* @returns Promise that resolves with the signal response
|
|
62
|
+
*/
|
|
63
|
+
signalItem(signal: Signal): Promise<NonNullable<SignalResponse>>;
|
|
56
64
|
/**
|
|
57
65
|
* Synthesize user content (streaming)
|
|
58
66
|
*
|
|
@@ -72,5 +80,5 @@ export interface UserMethods {
|
|
|
72
80
|
/**
|
|
73
81
|
* User-related API methods
|
|
74
82
|
*/
|
|
75
|
-
export declare function createUserMethods(config: RequestConfig, synthesizeBatchTimeout?: number): UserMethods;
|
|
83
|
+
export declare function createUserMethods(config: RequestConfig, synthesizeBatchTimeout?: number, signalBatchTimeout?: number): UserMethods;
|
|
76
84
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/user/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAa,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAgB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"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AAc,CAAC,CAAC,CAAC;IAErE;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;IAEvF;;;;;;OAMG;IACH,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,EACrB,sBAAsB,GAAE,MAAY,EACpC,kBAAkB,GAAE,MAAY,GAC/B,WAAW,CA8Cb"}
|
package/dist/user/index.js
CHANGED
|
@@ -6,12 +6,13 @@ const recommendations_js_1 = require("./recommendations.js");
|
|
|
6
6
|
const profile_js_1 = require("./profile.js");
|
|
7
7
|
const report_js_1 = require("./report.js");
|
|
8
8
|
const signal_js_1 = require("./signal.js");
|
|
9
|
+
const signal_batch_manager_js_1 = require("./signal-batch-manager.js");
|
|
9
10
|
const synthesize_js_1 = require("./synthesize.js");
|
|
10
11
|
const token_js_1 = require("./token.js");
|
|
11
12
|
/**
|
|
12
13
|
* User-related API methods
|
|
13
14
|
*/
|
|
14
|
-
function createUserMethods(config, synthesizeBatchTimeout = 250) {
|
|
15
|
+
function createUserMethods(config, synthesizeBatchTimeout = 250, signalBatchTimeout = 250) {
|
|
15
16
|
// Store token in closure - will be set by authenticate method
|
|
16
17
|
let userToken;
|
|
17
18
|
// Create a config getter that includes the user token
|
|
@@ -19,15 +20,17 @@ function createUserMethods(config, synthesizeBatchTimeout = 250) {
|
|
|
19
20
|
...config,
|
|
20
21
|
token: userToken,
|
|
21
22
|
});
|
|
22
|
-
const
|
|
23
|
+
const synthesizeBatchManager = new batch_manager_js_1.SynthesizeBatchManager(getConfigWithToken(), synthesizeBatchTimeout);
|
|
24
|
+
const signalBatchManager = new signal_batch_manager_js_1.SignalBatchManager(getConfigWithToken(), signalBatchTimeout);
|
|
23
25
|
return {
|
|
24
26
|
async authenticate(ssoToken) {
|
|
25
27
|
const tokenResponse = await (0, token_js_1.exchangeToken)(config, ssoToken);
|
|
26
28
|
const accessToken = tokenResponse?.idToken || tokenResponse?.accessToken;
|
|
27
29
|
if (accessToken) {
|
|
28
30
|
userToken = accessToken;
|
|
29
|
-
// Update batch manager
|
|
30
|
-
|
|
31
|
+
// Update batch manager configs with new token
|
|
32
|
+
synthesizeBatchManager.updateConfig(getConfigWithToken());
|
|
33
|
+
signalBatchManager.updateConfig(getConfigWithToken());
|
|
31
34
|
}
|
|
32
35
|
else {
|
|
33
36
|
throw new Error('Token exchange failed: no access token in response');
|
|
@@ -38,8 +41,9 @@ function createUserMethods(config, synthesizeBatchTimeout = 250) {
|
|
|
38
41
|
recommendations: (options) => (0, recommendations_js_1.getRecommendations)(getConfigWithToken(), options),
|
|
39
42
|
report: (options) => (0, report_js_1.reportBit)(getConfigWithToken(), options),
|
|
40
43
|
signal: (options) => (0, signal_js_1.recordSignal)(getConfigWithToken(), options),
|
|
44
|
+
signalItem: (signal) => signalBatchManager.addSignal(signal),
|
|
41
45
|
synthesize: (items) => (0, synthesize_js_1.synthesize)(getConfigWithToken(), items),
|
|
42
|
-
synthesizeItem: (item) =>
|
|
46
|
+
synthesizeItem: (item) => synthesizeBatchManager.addItem(item),
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
49
|
//# sourceMappingURL=index.js.map
|
package/dist/user/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":";;AAkGA,8CAkDC;AAnJD,yDAA4D;AAC5D,6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gC,EAAE,EAAE,CACpD,IAAA,uCAAkB,EAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC;QAEnD,MAAM,EAAE,CAAC,OAAsB,EAAE,EAAE,CAAC,IAAA,qBAAS,EAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC;QAE5E,MAAM,EAAE,CAAC,OAAsB,EAAE,EAAE,CAAC,IAAA,wBAAY,EAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC;QAE/E,UAAU,EAAE,CAAC,MAAc,EAAwC,EAAE,CACnE,kBAAkB,CAAC,SAAS,CAAC,MAAM,CAAC;QAEtC,UAAU,EAAE,CAAC,KAAiC,EAAE,EAAE,CAAC,IAAA,0BAAU,EAAC,kBAAkB,EAAE,EAAE,KAAK,CAAC;QAE1F,cAAc,EAAE,CAAC,IAAwC,EAAoB,EAAE,CAC7E,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RequestConfig } from '../request.js';
|
|
2
|
+
import { type Signal } from './signal.js';
|
|
3
|
+
/**
|
|
4
|
+
* Batch manager for signalItem
|
|
5
|
+
* Batches individual signals and sends them together after the timeout
|
|
6
|
+
*/
|
|
7
|
+
export declare class SignalBatchManager {
|
|
8
|
+
private queue;
|
|
9
|
+
private timer;
|
|
10
|
+
private config;
|
|
11
|
+
private batchTimeout;
|
|
12
|
+
constructor(config: RequestConfig, batchTimeout: number);
|
|
13
|
+
/**
|
|
14
|
+
* Update the request configuration (e.g., when token changes)
|
|
15
|
+
*/
|
|
16
|
+
updateConfig(config: RequestConfig): void;
|
|
17
|
+
addSignal(signal: Signal): Promise<{
|
|
18
|
+
recorded?: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
private flush;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=signal-batch-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal-batch-manager.d.ts","sourceRoot":"","sources":["../../src/user/signal-batch-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAkBxD;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,KAAK,CAIL;IACR,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM;IAKvD;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAIzC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;YAe5C,KAAK;CA6BpB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignalBatchManager = void 0;
|
|
4
|
+
const signal_js_1 = require("./signal.js");
|
|
5
|
+
// Timer functions for cross-platform compatibility
|
|
6
|
+
function getSetTimeout() {
|
|
7
|
+
return setTimeout;
|
|
8
|
+
}
|
|
9
|
+
function getClearTimeout() {
|
|
10
|
+
return clearTimeout;
|
|
11
|
+
}
|
|
12
|
+
const setTimer = getSetTimeout();
|
|
13
|
+
const clearTimer = getClearTimeout();
|
|
14
|
+
/**
|
|
15
|
+
* Batch manager for signalItem
|
|
16
|
+
* Batches individual signals and sends them together after the timeout
|
|
17
|
+
*/
|
|
18
|
+
class SignalBatchManager {
|
|
19
|
+
queue = [];
|
|
20
|
+
timer = null;
|
|
21
|
+
config;
|
|
22
|
+
batchTimeout;
|
|
23
|
+
constructor(config, batchTimeout) {
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.batchTimeout = batchTimeout;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Update the request configuration (e.g., when token changes)
|
|
29
|
+
*/
|
|
30
|
+
updateConfig(config) {
|
|
31
|
+
this.config = config;
|
|
32
|
+
}
|
|
33
|
+
addSignal(signal) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
this.queue.push({ signal, resolve, reject });
|
|
36
|
+
// Reset timer
|
|
37
|
+
if (this.timer) {
|
|
38
|
+
clearTimer(this.timer);
|
|
39
|
+
}
|
|
40
|
+
this.timer = setTimer(() => {
|
|
41
|
+
this.flush();
|
|
42
|
+
}, this.batchTimeout);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async flush() {
|
|
46
|
+
if (this.queue.length === 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const batch = [...this.queue];
|
|
50
|
+
// Clear queue and reset state
|
|
51
|
+
this.queue = [];
|
|
52
|
+
this.timer = null;
|
|
53
|
+
try {
|
|
54
|
+
// Send batch request
|
|
55
|
+
const signals = batch.map((b) => b.signal);
|
|
56
|
+
const response = await (0, signal_js_1.recordSignal)(this.config, { signals });
|
|
57
|
+
// Resolve all promises with the same response
|
|
58
|
+
// The API returns a single response for the batch
|
|
59
|
+
for (const { resolve } of batch) {
|
|
60
|
+
resolve(response);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Reject all pending promises
|
|
65
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
66
|
+
for (const { reject } of batch) {
|
|
67
|
+
reject(err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.SignalBatchManager = SignalBatchManager;
|
|
73
|
+
//# sourceMappingURL=signal-batch-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal-batch-manager.js","sourceRoot":"","sources":["../../src/user/signal-batch-manager.ts"],"names":[],"mappings":";;;AACA,2CAAwD;AAExD,mDAAmD;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KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAElB,IAAI,CAAC;YACH,qBAAqB;YACrB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAC3C,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YAE9D,8CAA8C;YAC9C,kDAAkD;YAClD,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,KAAK,EAAE,CAAC;gBAChC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,8BAA8B;YAC9B,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACtE,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;gBAC/B,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAlED,gDAkEC"}
|
package/dist/user/signal.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import type { paths } from '../generated/openapi.js';
|
|
|
2
2
|
import type { RequestConfig } from '../request.js';
|
|
3
3
|
export type SignalRequest = paths['/v1/user/signal']['post']['requestBody']['content']['application/json'];
|
|
4
4
|
export type SignalResponse = paths['/v1/user/signal']['post']['responses'][200]['content']['application/json']['data'];
|
|
5
|
+
export type Signal = SignalRequest['signals'][number];
|
|
5
6
|
/**
|
|
6
|
-
* Record
|
|
7
|
+
* Record user signals (e.g. clicked topic, read article) to inform profile interests
|
|
7
8
|
*
|
|
8
9
|
* @param config - Request configuration with base URL, timeout, fetch, and optional token
|
|
9
|
-
* @param options - Signal request parameters (type: SignalRequest)
|
|
10
|
+
* @param options - Signal request parameters (type: SignalRequest) containing an array of signals
|
|
10
11
|
* @returns Promise that resolves with the signal response data
|
|
11
12
|
*/
|
|
12
13
|
export declare function recordSignal(config: RequestConfig, options: SignalRequest): Promise<NonNullable<SignalResponse>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/user/signal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,MAAM,aAAa,GACvB,KAAK,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AACjF,MAAM,MAAM,cAAc,GACxB,KAAK,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/user/signal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,MAAM,aAAa,GACvB,KAAK,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AACjF,MAAM,MAAM,cAAc,GACxB,KAAK,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAG5F,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CActC"}
|
package/dist/user/signal.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.recordSignal = recordSignal;
|
|
4
4
|
const request_js_1 = require("../request.js");
|
|
5
5
|
/**
|
|
6
|
-
* Record
|
|
6
|
+
* Record user signals (e.g. clicked topic, read article) to inform profile interests
|
|
7
7
|
*
|
|
8
8
|
* @param config - Request configuration with base URL, timeout, fetch, and optional token
|
|
9
|
-
* @param options - Signal request parameters (type: SignalRequest)
|
|
9
|
+
* @param options - Signal request parameters (type: SignalRequest) containing an array of signals
|
|
10
10
|
* @returns Promise that resolves with the signal response data
|
|
11
11
|
*/
|
|
12
12
|
async function recordSignal(config, options) {
|
package/dist/user/signal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/user/signal.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/user/signal.ts"],"names":[],"mappings":";;AAoBA,oCAiBC;AAnCD,8CAA4C;AAW5C;;;;;;GAMG;AACI,KAAK,UAAU,YAAY,CAChC,MAAqB,EACrB,OAAsB;IAEtB,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAW,EAEhC,MAAM,EAAE;QACR,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,OAAO;KACd,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|