@bitbitpress/client 0.1.3 → 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 +213 -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 +237 -28
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/user/index.d.ts +27 -4
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user/index.js +13 -5
- package/dist/user/index.js.map +1 -1
- package/dist/user/profile.d.ts +11 -0
- package/dist/user/profile.d.ts.map +1 -0
- package/dist/user/profile.js +21 -0
- package/dist/user/profile.js.map +1 -0
- package/dist/user/report.d.ts +13 -0
- package/dist/user/report.d.ts.map +1 -0
- package/dist/user/report.js +23 -0
- package/dist/user/report.js.map +1 -0
- 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
|
@@ -115,6 +115,104 @@ export interface paths {
|
|
|
115
115
|
patch?: never;
|
|
116
116
|
trace?: never;
|
|
117
117
|
};
|
|
118
|
+
"/v1/user/profile": {
|
|
119
|
+
parameters: {
|
|
120
|
+
query?: never;
|
|
121
|
+
header?: never;
|
|
122
|
+
path?: never;
|
|
123
|
+
cookie?: never;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Get User Profile
|
|
127
|
+
* @description **GET** `/app/v1/user/profile` Returns information relevant for the user's profile.
|
|
128
|
+
*/
|
|
129
|
+
get: {
|
|
130
|
+
parameters: {
|
|
131
|
+
query?: never;
|
|
132
|
+
header: {
|
|
133
|
+
/** @description Bearer token for authentication */
|
|
134
|
+
authorization: string;
|
|
135
|
+
};
|
|
136
|
+
path?: never;
|
|
137
|
+
cookie?: never;
|
|
138
|
+
};
|
|
139
|
+
requestBody?: never;
|
|
140
|
+
responses: {
|
|
141
|
+
/** @description Successful response */
|
|
142
|
+
200: {
|
|
143
|
+
headers: {
|
|
144
|
+
[name: string]: unknown;
|
|
145
|
+
};
|
|
146
|
+
content: {
|
|
147
|
+
"application/json": {
|
|
148
|
+
/** @example true */
|
|
149
|
+
success?: boolean;
|
|
150
|
+
/** @description User profile related information */
|
|
151
|
+
data?: {
|
|
152
|
+
/**
|
|
153
|
+
* @description Suggested interest topics for the user
|
|
154
|
+
* @example [
|
|
155
|
+
* "Technology",
|
|
156
|
+
* "Science",
|
|
157
|
+
* "Business"
|
|
158
|
+
* ]
|
|
159
|
+
*/
|
|
160
|
+
suggestedInterestTopics?: string[];
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
/** @description Bad request - missing or invalid parameters */
|
|
166
|
+
400: {
|
|
167
|
+
headers: {
|
|
168
|
+
[name: string]: unknown;
|
|
169
|
+
};
|
|
170
|
+
content: {
|
|
171
|
+
"application/json": {
|
|
172
|
+
/** @example Bad request */
|
|
173
|
+
error?: string;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
/** @description Unauthorized errors */
|
|
178
|
+
401: {
|
|
179
|
+
headers: {
|
|
180
|
+
[name: string]: unknown;
|
|
181
|
+
};
|
|
182
|
+
content: {
|
|
183
|
+
"application/json": {
|
|
184
|
+
/**
|
|
185
|
+
* @example Unauthorized: No authentication token provided
|
|
186
|
+
* @enum {string}
|
|
187
|
+
*/
|
|
188
|
+
error?: "Unauthorized: No authentication token provided" | "Unauthorized: Token has expired" | "Unauthorized: Invalid token" | "Unauthorized: Authentication failed";
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
/** @description Internal server error */
|
|
193
|
+
500: {
|
|
194
|
+
headers: {
|
|
195
|
+
[name: string]: unknown;
|
|
196
|
+
};
|
|
197
|
+
content: {
|
|
198
|
+
"application/json": {
|
|
199
|
+
/** @example false */
|
|
200
|
+
success?: boolean;
|
|
201
|
+
/** @example Internal server error: An unknown error occurred */
|
|
202
|
+
error?: string;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
put?: never;
|
|
209
|
+
post?: never;
|
|
210
|
+
delete?: never;
|
|
211
|
+
options?: never;
|
|
212
|
+
head?: never;
|
|
213
|
+
patch?: never;
|
|
214
|
+
trace?: never;
|
|
215
|
+
};
|
|
118
216
|
"/v1/user/recommendations": {
|
|
119
217
|
parameters: {
|
|
120
218
|
query?: never;
|
|
@@ -127,6 +225,20 @@ export interface paths {
|
|
|
127
225
|
/**
|
|
128
226
|
* Retrieve User Recommendations
|
|
129
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) |
|
|
130
242
|
*/
|
|
131
243
|
post: {
|
|
132
244
|
parameters: {
|
|
@@ -145,6 +257,8 @@ export interface paths {
|
|
|
145
257
|
limit?: number;
|
|
146
258
|
/** @description Cursor from previous response to fetch the next page of recommendations */
|
|
147
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[];
|
|
148
262
|
};
|
|
149
263
|
};
|
|
150
264
|
};
|
|
@@ -162,18 +276,12 @@ export interface paths {
|
|
|
162
276
|
data?: {
|
|
163
277
|
/** @description List of recommended articles */
|
|
164
278
|
items?: {
|
|
165
|
-
/** @example Your article id */
|
|
166
|
-
id?: string;
|
|
167
279
|
/** @example BitBitPress's id */
|
|
168
280
|
assetId?: string;
|
|
169
|
-
/** @example Title */
|
|
170
|
-
title?: string;
|
|
171
|
-
/** @example Content */
|
|
172
|
-
content?: string;
|
|
173
|
-
/** @example 2021-01-01 */
|
|
174
|
-
publishedAt?: string;
|
|
175
281
|
/** @example 0.95 */
|
|
176
282
|
score?: number;
|
|
283
|
+
/** @description JSON string of requested asset fields (when `fields` provided in request) */
|
|
284
|
+
fields?: string;
|
|
177
285
|
}[];
|
|
178
286
|
/** @description Cursor to request the next page, if any */
|
|
179
287
|
cursor?: string;
|
|
@@ -230,7 +338,7 @@ export interface paths {
|
|
|
230
338
|
patch?: never;
|
|
231
339
|
trace?: never;
|
|
232
340
|
};
|
|
233
|
-
"/v1/user/
|
|
341
|
+
"/v1/user/report": {
|
|
234
342
|
parameters: {
|
|
235
343
|
query?: never;
|
|
236
344
|
header?: never;
|
|
@@ -240,8 +348,8 @@ export interface paths {
|
|
|
240
348
|
get?: never;
|
|
241
349
|
put?: never;
|
|
242
350
|
/**
|
|
243
|
-
*
|
|
244
|
-
* @description **POST** `/v1/user/
|
|
351
|
+
* Report Bit
|
|
352
|
+
* @description **POST** `/v1/user/report` Creates a user-provided bit to be ingested into the system. This may include news or any other content that the user wants to share.
|
|
245
353
|
*/
|
|
246
354
|
post: {
|
|
247
355
|
parameters: {
|
|
@@ -256,30 +364,129 @@ export interface paths {
|
|
|
256
364
|
requestBody: {
|
|
257
365
|
content: {
|
|
258
366
|
"application/json": {
|
|
259
|
-
/** @description
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
367
|
+
/** @description Title of the reported content */
|
|
368
|
+
title?: string;
|
|
369
|
+
/** @description Content body of the report */
|
|
370
|
+
content: string;
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
responses: {
|
|
375
|
+
/** @description Successful response */
|
|
376
|
+
200: {
|
|
377
|
+
headers: {
|
|
378
|
+
[name: string]: unknown;
|
|
379
|
+
};
|
|
380
|
+
content: {
|
|
381
|
+
"application/json": {
|
|
382
|
+
/** @example true */
|
|
383
|
+
success?: boolean;
|
|
384
|
+
data?: unknown;
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
/** @description Bad request - missing or invalid parameters */
|
|
389
|
+
400: {
|
|
390
|
+
headers: {
|
|
391
|
+
[name: string]: unknown;
|
|
392
|
+
};
|
|
393
|
+
content: {
|
|
394
|
+
"application/json": {
|
|
395
|
+
/** @example Bad request */
|
|
396
|
+
error?: string;
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
/** @description Unauthorized errors */
|
|
401
|
+
401: {
|
|
402
|
+
headers: {
|
|
403
|
+
[name: string]: unknown;
|
|
404
|
+
};
|
|
405
|
+
content: {
|
|
406
|
+
"application/json": {
|
|
272
407
|
/**
|
|
273
|
-
* @
|
|
408
|
+
* @example Unauthorized: No authentication token provided
|
|
274
409
|
* @enum {string}
|
|
275
410
|
*/
|
|
276
|
-
|
|
411
|
+
error?: "Unauthorized: No authentication token provided" | "Unauthorized: Token has expired" | "Unauthorized: Invalid token" | "Unauthorized: Authentication failed";
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
/** @description Internal server error */
|
|
416
|
+
500: {
|
|
417
|
+
headers: {
|
|
418
|
+
[name: string]: unknown;
|
|
419
|
+
};
|
|
420
|
+
content: {
|
|
421
|
+
"application/json": {
|
|
422
|
+
/** @example false */
|
|
423
|
+
success?: boolean;
|
|
424
|
+
/** @example Internal server error: An unknown error occurred */
|
|
425
|
+
error?: string;
|
|
277
426
|
};
|
|
278
427
|
};
|
|
279
428
|
};
|
|
280
429
|
};
|
|
430
|
+
};
|
|
431
|
+
delete?: never;
|
|
432
|
+
options?: never;
|
|
433
|
+
head?: never;
|
|
434
|
+
patch?: never;
|
|
435
|
+
trace?: never;
|
|
436
|
+
};
|
|
437
|
+
"/v1/user/signal": {
|
|
438
|
+
parameters: {
|
|
439
|
+
query?: never;
|
|
440
|
+
header?: never;
|
|
441
|
+
path?: never;
|
|
442
|
+
cookie?: never;
|
|
443
|
+
};
|
|
444
|
+
get?: never;
|
|
445
|
+
put?: never;
|
|
446
|
+
/**
|
|
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.
|
|
449
|
+
*/
|
|
450
|
+
post: {
|
|
451
|
+
parameters: {
|
|
452
|
+
query?: never;
|
|
453
|
+
header: {
|
|
454
|
+
/** @description Bearer token for authentication */
|
|
455
|
+
authorization: string;
|
|
456
|
+
};
|
|
457
|
+
path?: never;
|
|
458
|
+
cookie?: never;
|
|
459
|
+
};
|
|
460
|
+
requestBody: {
|
|
461
|
+
content: {
|
|
462
|
+
"application/json": {
|
|
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;
|
|
467
|
+
/**
|
|
468
|
+
* @description `active` = explicit intent (click, search, subscribe). `passive` = implicit (read, scroll, dwell).
|
|
469
|
+
* @enum {string}
|
|
470
|
+
*/
|
|
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
|
+
}[];
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
};
|
|
281
488
|
responses: {
|
|
282
|
-
/** @description
|
|
489
|
+
/** @description Signals recorded */
|
|
283
490
|
200: {
|
|
284
491
|
headers: {
|
|
285
492
|
[name: string]: unknown;
|
|
@@ -294,7 +501,7 @@ export interface paths {
|
|
|
294
501
|
/** @description Response payload */
|
|
295
502
|
data?: {
|
|
296
503
|
/**
|
|
297
|
-
* @description Whether the
|
|
504
|
+
* @description Whether the signals were recorded (false if no app user or no valid signals)
|
|
298
505
|
* @example true
|
|
299
506
|
*/
|
|
300
507
|
recorded?: boolean;
|
|
@@ -398,6 +605,8 @@ export interface paths {
|
|
|
398
605
|
fieldName: string;
|
|
399
606
|
/** @description A prompt describing the value of the field */
|
|
400
607
|
fieldDescription: string;
|
|
608
|
+
/** @description Optional max number of characters that can be returned for this field */
|
|
609
|
+
fieldCharacterLimit?: number;
|
|
401
610
|
}[];
|
|
402
611
|
/** @description Context data to provide to the prompt. */
|
|
403
612
|
contentContext: {
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,10 @@ 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
|
+
export type { ProfileResponse } from './user/profile.js';
|
|
14
|
+
export type { ReportRequest, ReportResponse } from './user/report.js';
|
|
13
15
|
export type { TokenRequest, TokenResponse } from './user/token.js';
|
|
14
16
|
export type { SynthesizeRequest } from './user/typeDefs.js';
|
|
15
17
|
export type { SynthesizeEvent } from './user/synthesize.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
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { RequestConfig } from '../request.js';
|
|
2
2
|
import { type RecommendationsRequest, type RecommendationsResponse } from './recommendations.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type ProfileResponse } from './profile.js';
|
|
4
|
+
import { type ReportRequest, type ReportResponse } from './report.js';
|
|
5
|
+
import { type Signal, type SignalRequest, type SignalResponse } from './signal.js';
|
|
4
6
|
import { type SynthesizeEvent } from './synthesize.js';
|
|
5
7
|
import { type TokenRequest, type TokenResponse } from './token.js';
|
|
6
8
|
import type { SynthesizeRequest } from './typeDefs.js';
|
|
@@ -24,6 +26,12 @@ export interface UserMethods {
|
|
|
24
26
|
* @returns Promise that resolves with the token response containing idToken or accessToken
|
|
25
27
|
*/
|
|
26
28
|
token(ssoToken: TokenRequest['ssoToken']): Promise<TokenResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Get user profile information
|
|
31
|
+
*
|
|
32
|
+
* @returns Promise that resolves with user profile data
|
|
33
|
+
*/
|
|
34
|
+
profile(): Promise<NonNullable<ProfileResponse>>;
|
|
27
35
|
/**
|
|
28
36
|
* Get recommended articles for the authenticated user
|
|
29
37
|
*
|
|
@@ -32,12 +40,27 @@ export interface UserMethods {
|
|
|
32
40
|
*/
|
|
33
41
|
recommendations(options?: RecommendationsRequest): Promise<NonNullable<RecommendationsResponse>>;
|
|
34
42
|
/**
|
|
35
|
-
*
|
|
43
|
+
* Report a bit (create a user-provided bit to be ingested into the system)
|
|
44
|
+
*
|
|
45
|
+
* @param options - Report request parameters
|
|
46
|
+
* @returns Promise that resolves with report response data
|
|
47
|
+
*/
|
|
48
|
+
report(options: ReportRequest): Promise<NonNullable<ReportResponse>>;
|
|
49
|
+
/**
|
|
50
|
+
* Record user signals (e.g. clicked topic, read article) to inform profile interests
|
|
36
51
|
*
|
|
37
|
-
* @param options - Signal request parameters
|
|
52
|
+
* @param options - Signal request parameters containing an array of signals
|
|
38
53
|
* @returns Promise that resolves with the signal response
|
|
39
54
|
*/
|
|
40
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>>;
|
|
41
64
|
/**
|
|
42
65
|
* Synthesize user content (streaming)
|
|
43
66
|
*
|
|
@@ -57,5 +80,5 @@ export interface UserMethods {
|
|
|
57
80
|
/**
|
|
58
81
|
* User-related API methods
|
|
59
82
|
*/
|
|
60
|
-
export declare function createUserMethods(config: RequestConfig, synthesizeBatchTimeout?: number): UserMethods;
|
|
83
|
+
export declare function createUserMethods(config: RequestConfig, synthesizeBatchTimeout?: number, signalBatchTimeout?: number): UserMethods;
|
|
61
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,EAAgB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
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,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjG,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAiB,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAElE;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;IAEjD;;;;;OAKG;IACH,eAAe,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAEjG;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;IAErE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,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
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createUserMethods = createUserMethods;
|
|
4
4
|
const batch_manager_js_1 = require("./batch-manager.js");
|
|
5
5
|
const recommendations_js_1 = require("./recommendations.js");
|
|
6
|
+
const profile_js_1 = require("./profile.js");
|
|
7
|
+
const report_js_1 = require("./report.js");
|
|
6
8
|
const signal_js_1 = require("./signal.js");
|
|
9
|
+
const signal_batch_manager_js_1 = require("./signal-batch-manager.js");
|
|
7
10
|
const synthesize_js_1 = require("./synthesize.js");
|
|
8
11
|
const token_js_1 = require("./token.js");
|
|
9
12
|
/**
|
|
10
13
|
* User-related API methods
|
|
11
14
|
*/
|
|
12
|
-
function createUserMethods(config, synthesizeBatchTimeout = 250) {
|
|
15
|
+
function createUserMethods(config, synthesizeBatchTimeout = 250, signalBatchTimeout = 250) {
|
|
13
16
|
// Store token in closure - will be set by authenticate method
|
|
14
17
|
let userToken;
|
|
15
18
|
// Create a config getter that includes the user token
|
|
@@ -17,25 +20,30 @@ function createUserMethods(config, synthesizeBatchTimeout = 250) {
|
|
|
17
20
|
...config,
|
|
18
21
|
token: userToken,
|
|
19
22
|
});
|
|
20
|
-
const
|
|
23
|
+
const synthesizeBatchManager = new batch_manager_js_1.SynthesizeBatchManager(getConfigWithToken(), synthesizeBatchTimeout);
|
|
24
|
+
const signalBatchManager = new signal_batch_manager_js_1.SignalBatchManager(getConfigWithToken(), signalBatchTimeout);
|
|
21
25
|
return {
|
|
22
26
|
async authenticate(ssoToken) {
|
|
23
27
|
const tokenResponse = await (0, token_js_1.exchangeToken)(config, ssoToken);
|
|
24
28
|
const accessToken = tokenResponse?.idToken || tokenResponse?.accessToken;
|
|
25
29
|
if (accessToken) {
|
|
26
30
|
userToken = accessToken;
|
|
27
|
-
// Update batch manager
|
|
28
|
-
|
|
31
|
+
// Update batch manager configs with new token
|
|
32
|
+
synthesizeBatchManager.updateConfig(getConfigWithToken());
|
|
33
|
+
signalBatchManager.updateConfig(getConfigWithToken());
|
|
29
34
|
}
|
|
30
35
|
else {
|
|
31
36
|
throw new Error('Token exchange failed: no access token in response');
|
|
32
37
|
}
|
|
33
38
|
},
|
|
34
39
|
token: (ssoToken) => (0, token_js_1.exchangeToken)(config, ssoToken),
|
|
40
|
+
profile: () => (0, profile_js_1.getProfile)(getConfigWithToken()),
|
|
35
41
|
recommendations: (options) => (0, recommendations_js_1.getRecommendations)(getConfigWithToken(), options),
|
|
42
|
+
report: (options) => (0, report_js_1.reportBit)(getConfigWithToken(), options),
|
|
36
43
|
signal: (options) => (0, signal_js_1.recordSignal)(getConfigWithToken(), options),
|
|
44
|
+
signalItem: (signal) => signalBatchManager.addSignal(signal),
|
|
37
45
|
synthesize: (items) => (0, synthesize_js_1.synthesize)(getConfigWithToken(), items),
|
|
38
|
-
synthesizeItem: (item) =>
|
|
46
|
+
synthesizeItem: (item) => synthesizeBatchManager.addItem(item),
|
|
39
47
|
};
|
|
40
48
|
}
|
|
41
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,6DAI8B;AAC9B,6CAAgE;AAChE,2CAAiF;AACjF,2CAAiG;AACjG,uEAA+D;AAC/D,mDAAmE;AACnE,yCAAkF;AAmFlF;;GAEG;AACH,SAAgB,iBAAiB,CAC/B,MAAqB,EACrB,yBAAiC,GAAG,EACpC,qBAA6B,GAAG;IAEhC,8DAA8D;IAC9D,IAAI,SAA6B,CAAC;IAElC,sDAAsD;IACtD,MAAM,kBAAkB,GAAG,GAAkB,EAAE,CAAC,CAAC;QAC/C,GAAG,MAAM;QACT,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,MAAM,sBAAsB,GAAG,IAAI,yCAAsB,CAAC,kBAAkB,EAAE,EAAE,sBAAsB,CAAC,CAAC;IACxG,MAAM,kBAAkB,GAAG,IAAI,4CAAkB,CAAC,kBAAkB,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAE5F,OAAO;QACL,KAAK,CAAC,YAAY,CAAC,QAAgB;YACjC,MAAM,aAAa,GAAG,MAAM,IAAA,wBAAa,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC5D,MAAM,WAAW,GAAG,aAAa,EAAE,OAAO,IAAI,aAAa,EAAE,WAAW,CAAC;YACzE,IAAI,WAAW,EAAE,CAAC;gBAChB,SAAS,GAAG,WAAW,CAAC;gBACxB,8CAA8C;gBAC9C,sBAAsB,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC,CAAC;gBAC1D,kBAAkB,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC,CAAC;YACxD,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;QAED,KAAK,EAAE,CAAC,QAAkC,EAAE,EAAE,CAAC,IAAA,wBAAa,EAAC,MAAM,EAAE,QAAQ,CAAC;QAE9E,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,uBAAU,EAAC,kBAAkB,EAAE,CAAC;QAE/C,eAAe,EAAE,CAAC,OAAgC,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,11 @@
|
|
|
1
|
+
import type { paths } from '../generated/openapi.js';
|
|
2
|
+
import type { RequestConfig } from '../request.js';
|
|
3
|
+
export type ProfileResponse = paths['/v1/user/profile']['get']['responses'][200]['content']['application/json']['data'];
|
|
4
|
+
/**
|
|
5
|
+
* Get user profile information
|
|
6
|
+
*
|
|
7
|
+
* @param config - Request configuration with base URL, timeout, fetch, and optional token
|
|
8
|
+
* @returns Promise that resolves with user profile data
|
|
9
|
+
*/
|
|
10
|
+
export declare function getProfile(config: RequestConfig): Promise<NonNullable<ProfileResponse>>;
|
|
11
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/user/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,MAAM,eAAe,GACzB,KAAK,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5F;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAavC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProfile = getProfile;
|
|
4
|
+
const request_js_1 = require("../request.js");
|
|
5
|
+
/**
|
|
6
|
+
* Get user profile information
|
|
7
|
+
*
|
|
8
|
+
* @param config - Request configuration with base URL, timeout, fetch, and optional token
|
|
9
|
+
* @returns Promise that resolves with user profile data
|
|
10
|
+
*/
|
|
11
|
+
async function getProfile(config) {
|
|
12
|
+
const response = await (0, request_js_1.makeRequest)(config, {
|
|
13
|
+
method: 'GET',
|
|
14
|
+
path: '/v1/user/profile',
|
|
15
|
+
});
|
|
16
|
+
if (!response) {
|
|
17
|
+
throw new Error('Failed to get profile: no data in response');
|
|
18
|
+
}
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/user/profile.ts"],"names":[],"mappings":";;AAcA,gCAeC;AA3BD,8CAA4C;AAM5C;;;;;GAKG;AACI,KAAK,UAAU,UAAU,CAC9B,MAAqB;IAErB,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAW,EAEhC,MAAM,EAAE;QACR,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAkB;KACzB,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { paths } from '../generated/openapi.js';
|
|
2
|
+
import type { RequestConfig } from '../request.js';
|
|
3
|
+
export type ReportRequest = paths['/v1/user/report']['post']['requestBody']['content']['application/json'];
|
|
4
|
+
export type ReportResponse = paths['/v1/user/report']['post']['responses'][200]['content']['application/json']['data'];
|
|
5
|
+
/**
|
|
6
|
+
* Report a bit (create a user-provided bit to be ingested into the system)
|
|
7
|
+
*
|
|
8
|
+
* @param config - Request configuration with base URL, timeout, fetch, and optional token
|
|
9
|
+
* @param options - Report request parameters
|
|
10
|
+
* @returns Promise that resolves with report response data
|
|
11
|
+
*/
|
|
12
|
+
export declare function reportBit(config: RequestConfig, options: ReportRequest): Promise<NonNullable<ReportResponse>>;
|
|
13
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/user/report.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;AAE5F;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CActC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reportBit = reportBit;
|
|
4
|
+
const request_js_1 = require("../request.js");
|
|
5
|
+
/**
|
|
6
|
+
* Report a bit (create a user-provided bit to be ingested into the system)
|
|
7
|
+
*
|
|
8
|
+
* @param config - Request configuration with base URL, timeout, fetch, and optional token
|
|
9
|
+
* @param options - Report request parameters
|
|
10
|
+
* @returns Promise that resolves with report response data
|
|
11
|
+
*/
|
|
12
|
+
async function reportBit(config, options) {
|
|
13
|
+
const response = await (0, request_js_1.makeRequest)(config, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
path: '/v1/user/report',
|
|
16
|
+
body: options,
|
|
17
|
+
});
|
|
18
|
+
if (!response) {
|
|
19
|
+
throw new Error('Failed to report bit: no data in response');
|
|
20
|
+
}
|
|
21
|
+
return response;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/user/report.ts"],"names":[],"mappings":";;AAiBA,8BAiBC;AAhCD,8CAA4C;AAQ5C;;;;;;GAMG;AACI,KAAK,UAAU,SAAS,CAC7B,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,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,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"}
|