@bitbitpress/client 0.1.0
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 +38 -0
- package/dist/client.d.ts +85 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +60 -0
- package/dist/client.js.map +1 -0
- package/dist/examples/basic-usage.d.ts +11 -0
- package/dist/examples/basic-usage.d.ts.map +1 -0
- package/dist/examples/basic-usage.js +129 -0
- package/dist/examples/basic-usage.js.map +1 -0
- package/dist/generated/openapi.d.ts +8 -0
- package/dist/generated/openapi.d.ts.map +1 -0
- package/dist/generated/openapi.js +3 -0
- package/dist/generated/openapi.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/request.d.ts +37 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +126 -0
- package/dist/request.js.map +1 -0
- package/dist/user/batch-manager.d.ts +20 -0
- package/dist/user/batch-manager.d.ts.map +1 -0
- package/dist/user/batch-manager.js +145 -0
- package/dist/user/batch-manager.js.map +1 -0
- package/dist/user/index.d.ts +56 -0
- package/dist/user/index.d.ts.map +1 -0
- package/dist/user/index.js +62 -0
- package/dist/user/index.js.map +1 -0
- package/dist/user/recommendations.d.ts +17 -0
- package/dist/user/recommendations.d.ts.map +1 -0
- package/dist/user/recommendations.js +19 -0
- package/dist/user/recommendations.js.map +1 -0
- package/dist/user/signal.d.ts +9 -0
- package/dist/user/signal.d.ts.map +1 -0
- package/dist/user/signal.js +19 -0
- package/dist/user/signal.js.map +1 -0
- package/dist/user/synthesize.d.ts +21 -0
- package/dist/user/synthesize.d.ts.map +1 -0
- package/dist/user/synthesize.js +15 -0
- package/dist/user/synthesize.js.map +1 -0
- package/dist/user/token.d.ts +9 -0
- package/dist/user/token.d.ts.map +1 -0
- package/dist/user/token.js +19 -0
- package/dist/user/token.js.map +1 -0
- package/dist/user/typeDefs.d.ts +3 -0
- package/dist/user/typeDefs.d.ts.map +1 -0
- package/dist/user/typeDefs.js +3 -0
- package/dist/user/typeDefs.js.map +1 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @bitbitpress/client
|
|
2
|
+
|
|
3
|
+
BitBitPress TypeScript client library for use in your clients.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @bitbitpress/client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Basic Setup
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { BitBitPressClient } from '@bitbitpress/client';
|
|
17
|
+
|
|
18
|
+
const client = new BitBitPressClient({
|
|
19
|
+
baseUrl: 'https://your-control-room.api.dev.bitbitpress.com', // Your custom Control Room API Url
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Authentication
|
|
24
|
+
|
|
25
|
+
#### Authenticate with SSO Token
|
|
26
|
+
|
|
27
|
+
The `authenticate` method exchanges your SSO token for an authentication token and automatically sets it for all subsequent user method calls.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
await client.user.authenticate('your-user\'s-auth-sso-token');
|
|
31
|
+
// Token is automatically set for all user methods
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Note:** You must call `authenticate()` before using any other user methods (recommendations, synthesize, etc.).
|
|
35
|
+
|
|
36
|
+
### API
|
|
37
|
+
|
|
38
|
+
See API.md for more details or reference your control room API docs: https://your-control-room.api.dev.bitbitpress.com/docs
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the BitBitPress client
|
|
3
|
+
*/
|
|
4
|
+
export interface BitBitPressClientConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Base URL of the API server (your custom Control Room API Url)
|
|
7
|
+
*/
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* Custom fetch implementation (useful for React Native)
|
|
11
|
+
*/
|
|
12
|
+
fetch?: typeof fetch;
|
|
13
|
+
/**
|
|
14
|
+
* Custom headers to include in all requests
|
|
15
|
+
*/
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Request timeout in milliseconds
|
|
19
|
+
* @default 30000
|
|
20
|
+
*/
|
|
21
|
+
timeout?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Batch timeout for synthesizeItem in milliseconds
|
|
24
|
+
* Items will be batched and sent after this delay
|
|
25
|
+
* @default 250
|
|
26
|
+
*/
|
|
27
|
+
synthesizeBatchTimeout?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for creating a BitBitPress client instance
|
|
31
|
+
*/
|
|
32
|
+
export interface BitBitPressClientOptions extends BitBitPressClientConfig {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* BitBitPress API Client
|
|
36
|
+
*
|
|
37
|
+
* A type-safe client for interacting with the BitBitPress API.
|
|
38
|
+
* Supports both React Native and Node.js environments.
|
|
39
|
+
*/
|
|
40
|
+
export declare class BitBitPressClient {
|
|
41
|
+
private config;
|
|
42
|
+
constructor(options: BitBitPressClientOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Update the base URL
|
|
45
|
+
*/
|
|
46
|
+
setBaseUrl(baseUrl: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Get request configuration for making API calls
|
|
49
|
+
*/
|
|
50
|
+
private getRequestConfig;
|
|
51
|
+
/**
|
|
52
|
+
* Get synthesize batch timeout configuration
|
|
53
|
+
*/
|
|
54
|
+
private getSynthesizeBatchTimeout;
|
|
55
|
+
/**
|
|
56
|
+
* User-related API methods
|
|
57
|
+
*/
|
|
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
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA;;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;gBAEpE,OAAO,EAAE,wBAAwB;IAqB7C;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAIjC;;OAEG;IACH,IAAI,IAAI;;;;;;;;;;kBAIq4G,CAAC;uBAA0H,CAAC;qBAA6G,CAAC;uBAA2H,CAAC;uBAAiH,CAAC;2BAAwH,CAAC;qBAA4G,CAAC;;;;;;;;+BANnkI,uDAET;MAEE;CACF"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitBitPressClient = void 0;
|
|
4
|
+
const index_js_1 = require("./user/index.js");
|
|
5
|
+
/**
|
|
6
|
+
* BitBitPress API Client
|
|
7
|
+
*
|
|
8
|
+
* A type-safe client for interacting with the BitBitPress API.
|
|
9
|
+
* Supports both React Native and Node.js environments.
|
|
10
|
+
*/
|
|
11
|
+
class BitBitPressClient {
|
|
12
|
+
config;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
if (!options.baseUrl) {
|
|
15
|
+
throw new Error('baseUrl is required. Please provide your custom Control Room API Url.');
|
|
16
|
+
}
|
|
17
|
+
this.config = {
|
|
18
|
+
baseUrl: options.baseUrl,
|
|
19
|
+
timeout: options.timeout ?? 30000,
|
|
20
|
+
synthesizeBatchTimeout: options.synthesizeBatchTimeout,
|
|
21
|
+
fetch: options.fetch ?? (typeof globalThis !== 'undefined' ? globalThis.fetch : undefined),
|
|
22
|
+
headers: options.headers,
|
|
23
|
+
};
|
|
24
|
+
// Validate fetch is available
|
|
25
|
+
if (!this.config.fetch) {
|
|
26
|
+
throw new Error('Fetch is not available. Please provide a fetch implementation via the `fetch` option or ensure your environment supports fetch.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Update the base URL
|
|
31
|
+
*/
|
|
32
|
+
setBaseUrl(baseUrl) {
|
|
33
|
+
this.config.baseUrl = baseUrl;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get request configuration for making API calls
|
|
37
|
+
*/
|
|
38
|
+
getRequestConfig() {
|
|
39
|
+
return {
|
|
40
|
+
baseUrl: this.config.baseUrl,
|
|
41
|
+
timeout: this.config.timeout,
|
|
42
|
+
fetch: this.config.fetch,
|
|
43
|
+
headers: this.config.headers,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get synthesize batch timeout configuration
|
|
48
|
+
*/
|
|
49
|
+
getSynthesizeBatchTimeout() {
|
|
50
|
+
return this.config.synthesizeBatchTimeout;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* User-related API methods
|
|
54
|
+
*/
|
|
55
|
+
get user() {
|
|
56
|
+
return (0, index_js_1.createUserMethods)(this.getRequestConfig(), this.getSynthesizeBatchTimeout());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.BitBitPressClient = BitBitPressClient;
|
|
60
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AACA,8CAAoD;AAwCpD;;;;;GAKG;AACH,MAAa,iBAAiB;IACpB,MAAM,CACkE;IAEhF,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;IAChC,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;IACH,IAAI,IAAI;QACN,OAAO,IAAA,4BAAiB,EAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC;IACtF,CAAC;CACF;AAzDD,8CAyDC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage of the BitBitPress client library
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the client in different scenarios.
|
|
5
|
+
*/
|
|
6
|
+
declare function basicExample(): Promise<void>;
|
|
7
|
+
declare function streamingExample(): Promise<void>;
|
|
8
|
+
declare function batchedSynthesisExample(): Promise<void>;
|
|
9
|
+
declare function signalExample(): Promise<void>;
|
|
10
|
+
export { basicExample, streamingExample, batchedSynthesisExample, signalExample };
|
|
11
|
+
//# sourceMappingURL=basic-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-usage.d.ts","sourceRoot":"","sources":["../../src/examples/basic-usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,iBAAe,YAAY,kBAwB1B;AAGD,iBAAe,gBAAgB,kBAyC9B;AAGD,iBAAe,uBAAuB,kBA4BrC;AAGD,iBAAe,aAAa,kBAkC3B;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage of the BitBitPress client library
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the client in different scenarios.
|
|
5
|
+
*/
|
|
6
|
+
import { BitBitPressClient } from '../client.js';
|
|
7
|
+
// Example 1: Basic setup with authentication
|
|
8
|
+
async function basicExample() {
|
|
9
|
+
const client = new BitBitPressClient({
|
|
10
|
+
baseUrl: 'https://your-control-room.api.dev.bitbitpress.com',
|
|
11
|
+
});
|
|
12
|
+
// Authenticate with SSO token (token is automatically set for all user methods)
|
|
13
|
+
await client.user.authenticate("your-user's-auth-sso-token");
|
|
14
|
+
// Get recommendations
|
|
15
|
+
const recommendations = await client.user.recommendations({
|
|
16
|
+
limit: 10,
|
|
17
|
+
});
|
|
18
|
+
console.log('Recommendations:', recommendations.items);
|
|
19
|
+
// Record a user signal (e.g., user clicked on an article)
|
|
20
|
+
const signalResult = await client.user.signal({
|
|
21
|
+
signal: 'clicked "Warriors intend to keep Jimmy Butler despite season-ending injury"',
|
|
22
|
+
type: 'active',
|
|
23
|
+
contentContext: {
|
|
24
|
+
contentId: 'article-123',
|
|
25
|
+
contentType: 'article',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
console.log('Signal recorded:', signalResult.recorded);
|
|
29
|
+
}
|
|
30
|
+
// Example 2: Streaming synthesis
|
|
31
|
+
async function streamingExample() {
|
|
32
|
+
const client = new BitBitPressClient({
|
|
33
|
+
baseUrl: 'https://your-control-room.api.dev.bitbitpress.com',
|
|
34
|
+
});
|
|
35
|
+
// Authenticate first
|
|
36
|
+
await client.user.authenticate("your-user's-auth-sso-token");
|
|
37
|
+
const stream = await client.user.synthesize([
|
|
38
|
+
{
|
|
39
|
+
type: 'DAILY_SUMMARY',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'CUSTOM',
|
|
43
|
+
schema: [
|
|
44
|
+
{ fieldName: 'title', fieldDescription: 'The article title' },
|
|
45
|
+
{ fieldName: 'summary', fieldDescription: 'A brief summary' },
|
|
46
|
+
],
|
|
47
|
+
contentContext: {
|
|
48
|
+
contentId: 'article-123',
|
|
49
|
+
contentType: 'article',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
for await (const event of stream) {
|
|
54
|
+
switch (event.type) {
|
|
55
|
+
case 'connected':
|
|
56
|
+
console.log('Stream connected');
|
|
57
|
+
break;
|
|
58
|
+
case 'DAILY_SUMMARY':
|
|
59
|
+
console.log('Daily summary:', event.data);
|
|
60
|
+
break;
|
|
61
|
+
case 'CUSTOM':
|
|
62
|
+
console.log('Custom data:', event.data);
|
|
63
|
+
break;
|
|
64
|
+
case 'complete':
|
|
65
|
+
console.log('Stream complete');
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Example 3: Batched synthesis with synthesizeItem
|
|
71
|
+
async function batchedSynthesisExample() {
|
|
72
|
+
const client = new BitBitPressClient({
|
|
73
|
+
baseUrl: 'https://your-control-room.api.dev.bitbitpress.com',
|
|
74
|
+
synthesizeBatchTimeout: 250, // Optional: customize batch timeout
|
|
75
|
+
});
|
|
76
|
+
// Authenticate first
|
|
77
|
+
await client.user.authenticate("your-user's-auth-sso-token");
|
|
78
|
+
// Items are automatically batched and sent together after the timeout
|
|
79
|
+
// Each promise resolves with the data field from the event
|
|
80
|
+
const dailySummaryData = await client.user.synthesizeItem({
|
|
81
|
+
type: 'DAILY_SUMMARY',
|
|
82
|
+
});
|
|
83
|
+
console.log('Daily summary:', dailySummaryData);
|
|
84
|
+
const customData = await client.user.synthesizeItem({
|
|
85
|
+
type: 'CUSTOM',
|
|
86
|
+
schema: [{ fieldName: 'title', fieldDescription: 'The article title' }],
|
|
87
|
+
contentContext: {
|
|
88
|
+
contentId: 'article-123',
|
|
89
|
+
contentType: 'article',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
console.log('Custom data:', customData);
|
|
93
|
+
// Both items are sent together in a single batch request
|
|
94
|
+
// Each promise resolves immediately when its data event arrives
|
|
95
|
+
}
|
|
96
|
+
// Example 4: Recording user signals
|
|
97
|
+
async function signalExample() {
|
|
98
|
+
const client = new BitBitPressClient({
|
|
99
|
+
baseUrl: 'https://your-control-room.api.dev.bitbitpress.com',
|
|
100
|
+
});
|
|
101
|
+
// Authenticate first
|
|
102
|
+
await client.user.authenticate("your-user's-auth-sso-token");
|
|
103
|
+
// Record an active signal (explicit intent like click, search, subscribe)
|
|
104
|
+
await client.user.signal({
|
|
105
|
+
signal: 'clicked "Warriors intend to keep Jimmy Butler despite season-ending injury"',
|
|
106
|
+
type: 'active',
|
|
107
|
+
contentContext: {
|
|
108
|
+
contentId: 'article-123',
|
|
109
|
+
contentType: 'article',
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
// Record a passive signal (implicit like read, scroll, dwell)
|
|
113
|
+
await client.user.signal({
|
|
114
|
+
signal: 'read about NBA trades',
|
|
115
|
+
type: 'passive',
|
|
116
|
+
contentContext: {
|
|
117
|
+
contentId: 'article-456',
|
|
118
|
+
contentType: 'article',
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
// Record a negative signal (e.g., dislike, unfollow) - use sparingly
|
|
122
|
+
await client.user.signal({
|
|
123
|
+
signal: 'unfollowed topic "Politics"',
|
|
124
|
+
type: 'active',
|
|
125
|
+
negative: true,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
export { basicExample, streamingExample, batchedSynthesisExample, signalExample };
|
|
129
|
+
//# sourceMappingURL=basic-usage.js.map
|
|
@@ -0,0 +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,0DAA0D;IAC1D,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5C,MAAM,EAAE,6EAA6E;QACrF,IAAI,EAAE,QAAQ;QACd,cAAc,EAAE;YACd,SAAS,EAAE,aAAa;YACxB,WAAW,EAAE,SAAS;SACvB;KACF,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;AACzD,CAAC;AAED,iCAAiC;AACjC,KAAK,UAAU,gBAAgB;IAC7B,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC;QACnC,OAAO,EAAE,mDAAmD;KAC7D,CAAC,CAAC;IAEH,qBAAqB;IACrB,MAAM,MAAM,CAAC,IAAI,CA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ACrC,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/generated/openapi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,mBAAmB,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../src/generated/openapi.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @bitbitpress/client
|
|
3
|
+
*
|
|
4
|
+
* TypeScript SDK for BitBitPress API
|
|
5
|
+
* Works in React Native and Node.js environments
|
|
6
|
+
*/
|
|
7
|
+
export type { BitBitPressClientConfig, BitBitPressClientOptions } from './client.js';
|
|
8
|
+
export { BitBitPressClient } from './client.js';
|
|
9
|
+
export type * from './generated/openapi.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @bitbitpress/client
|
|
4
|
+
*
|
|
5
|
+
* TypeScript SDK for BitBitPress API
|
|
6
|
+
* Works in React Native and Node.js environments
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BitBitPressClient = void 0;
|
|
10
|
+
var client_js_1 = require("./client.js");
|
|
11
|
+
Object.defineProperty(exports, "BitBitPressClient", { enumerable: true, get: function () { return client_js_1.BitBitPressClient; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,yCAAgD;AAAvC,8GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP method types
|
|
3
|
+
*/
|
|
4
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
5
|
+
/**
|
|
6
|
+
* Request options for API calls
|
|
7
|
+
*/
|
|
8
|
+
export interface RequestOptions {
|
|
9
|
+
method: HttpMethod;
|
|
10
|
+
path: string;
|
|
11
|
+
body?: unknown;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* API response wrapper
|
|
17
|
+
*/
|
|
18
|
+
export interface ApiResponse<T = unknown> {
|
|
19
|
+
success: boolean;
|
|
20
|
+
data?: T;
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Client configuration for making requests
|
|
25
|
+
*/
|
|
26
|
+
export interface RequestConfig {
|
|
27
|
+
baseUrl: string;
|
|
28
|
+
timeout: number;
|
|
29
|
+
token?: string;
|
|
30
|
+
fetch: typeof fetch;
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Make an HTTP request to the API
|
|
35
|
+
*/
|
|
36
|
+
export declare function makeRequest<T = unknown>(config: RequestConfig, options: RequestOptions): Promise<T>;
|
|
37
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAChE;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,OAAO,EAC3C,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,CAAC,CAAC,CAgFZ"}
|
package/dist/request.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeRequest = makeRequest;
|
|
4
|
+
/**
|
|
5
|
+
* Make an HTTP request to the API
|
|
6
|
+
*/
|
|
7
|
+
async function makeRequest(config, options) {
|
|
8
|
+
const { method, path, body, headers = {}, params } = options;
|
|
9
|
+
// Build URL with query parameters
|
|
10
|
+
const url = new URL(path, config.baseUrl);
|
|
11
|
+
if (params) {
|
|
12
|
+
for (const [key, value] of Object.entries(params)) {
|
|
13
|
+
if (value !== undefined && value !== null) {
|
|
14
|
+
url.searchParams.append(key, String(value));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// Prepare headers
|
|
19
|
+
const requestHeaders = {
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
...config.headers,
|
|
22
|
+
...headers,
|
|
23
|
+
};
|
|
24
|
+
// Add authentication token if available
|
|
25
|
+
if (config.token) {
|
|
26
|
+
requestHeaders.Authorization = `Bearer ${config.token}`;
|
|
27
|
+
}
|
|
28
|
+
// Prepare request options
|
|
29
|
+
const requestOptions = {
|
|
30
|
+
method,
|
|
31
|
+
headers: requestHeaders,
|
|
32
|
+
};
|
|
33
|
+
// Add body for non-GET requests
|
|
34
|
+
if (body && method !== 'GET') {
|
|
35
|
+
requestOptions.body = JSON.stringify(body);
|
|
36
|
+
}
|
|
37
|
+
// Create abort controller for timeout
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
const timeoutId = setTimeout(() => controller.abort(), config.timeout);
|
|
40
|
+
requestOptions.signal = controller.signal;
|
|
41
|
+
try {
|
|
42
|
+
const response = await config.fetch(url.toString(), requestOptions);
|
|
43
|
+
// Handle streaming responses (Server-Sent Events)
|
|
44
|
+
if (response.headers.get('content-type')?.includes('text/event-stream')) {
|
|
45
|
+
return handleStreamingResponse(response);
|
|
46
|
+
}
|
|
47
|
+
// Parse JSON response
|
|
48
|
+
const data = await response.json();
|
|
49
|
+
// Check for API error format
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
const errorData = data;
|
|
52
|
+
const errorMessage = ('error' in errorData && errorData.error) ||
|
|
53
|
+
('message' in errorData && errorData.message) ||
|
|
54
|
+
`HTTP ${response.status}: ${response.statusText}`;
|
|
55
|
+
throw new Error(errorMessage);
|
|
56
|
+
}
|
|
57
|
+
// Return data from API response wrapper if present
|
|
58
|
+
if (typeof data === 'object' && data !== null && 'success' in data && 'data' in data) {
|
|
59
|
+
const apiResponse = data;
|
|
60
|
+
if (!apiResponse.success) {
|
|
61
|
+
throw new Error(apiResponse.error || 'API request failed');
|
|
62
|
+
}
|
|
63
|
+
return apiResponse.data;
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
69
|
+
throw new Error(`Request timeout after ${config.timeout}ms`);
|
|
70
|
+
}
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
clearTimeout(timeoutId);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Handle streaming Server-Sent Events response
|
|
79
|
+
*/
|
|
80
|
+
async function handleStreamingResponse(response) {
|
|
81
|
+
if (!response.body) {
|
|
82
|
+
throw new Error('Response body is null');
|
|
83
|
+
}
|
|
84
|
+
const reader = response.body.getReader();
|
|
85
|
+
const decoder = new TextDecoder();
|
|
86
|
+
let buffer = '';
|
|
87
|
+
return {
|
|
88
|
+
async *[Symbol.asyncIterator]() {
|
|
89
|
+
try {
|
|
90
|
+
while (true) {
|
|
91
|
+
const { done, value } = await reader.read();
|
|
92
|
+
if (done)
|
|
93
|
+
break;
|
|
94
|
+
buffer += decoder.decode(value, { stream: true });
|
|
95
|
+
const lines = buffer.split('\n\n');
|
|
96
|
+
buffer = lines.pop() || '';
|
|
97
|
+
for (const line of lines) {
|
|
98
|
+
if (line.startsWith('data: ')) {
|
|
99
|
+
try {
|
|
100
|
+
const data = JSON.parse(line.slice(6));
|
|
101
|
+
yield data;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Skip invalid JSON
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Process remaining buffer
|
|
110
|
+
if (buffer.startsWith('data: ')) {
|
|
111
|
+
try {
|
|
112
|
+
const data = JSON.parse(buffer.slice(6));
|
|
113
|
+
yield data;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Skip invalid JSON
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
reader.releaseLock();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";;AAuCA,kCAmFC;AAtFD;;GAEG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAqB,EACrB,OAAuB;IAEvB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE7D,kCAAkC;IAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC1C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAED,kBAAkB;IAClB,MAAM,cAAc,GAA2B;QAC7C,cAAc,EAAE,kBAAkB;QAClC,GAAG,MAAM,CAAC,OAAO;QAC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'./typeDefs.js';
|
|
3
|
+
/**
|
|
4
|
+
* Batch manager for synthesizeItem
|
|
5
|
+
* Resolves each item individually based on its index in the response
|
|
6
|
+
*/
|
|
7
|
+
export declare class SynthesizeBatchManager {
|
|
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
|
+
addItem(item: SynthesizeRequest['items'][number]): Promise<unknown>;
|
|
18
|
+
private flush;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=batch-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-manager.d.ts","sourceRoot":"","sources":["../../src/user/batch-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAkBvD;;;GAGG;AACH,qBAAa,sBAAsB;IACjC,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,OAAO,CAAC,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAenE,OAAO,CAAC,KAAK;CA4Bd"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SynthesizeBatchManager = void 0;
|
|
4
|
+
const synthesize_js_1 = require("./synthesize.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 synthesizeItem
|
|
16
|
+
* Resolves each item individually based on its index in the response
|
|
17
|
+
*/
|
|
18
|
+
class SynthesizeBatchManager {
|
|
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
|
+
addItem(item) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
this.queue.push({ item, 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
|
+
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
|
+
// Create a shared stream router that will distribute events to indexed promises
|
|
54
|
+
const router = new StreamRouter(batch);
|
|
55
|
+
// Send batch request in the background
|
|
56
|
+
// Don't await - let it run asynchronously
|
|
57
|
+
const items = batch.map((b) => b.item);
|
|
58
|
+
(0, synthesize_js_1.synthesize)(this.config, items)
|
|
59
|
+
.then((stream) => {
|
|
60
|
+
router.setStream(stream);
|
|
61
|
+
router.start();
|
|
62
|
+
})
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
// Reject all pending promises
|
|
65
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
66
|
+
router.setError(err);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.SynthesizeBatchManager = SynthesizeBatchManager;
|
|
71
|
+
/**
|
|
72
|
+
* Routes stream events to indexed promises
|
|
73
|
+
* Resolves each promise with the data field from the event (excluding 'connected' and 'complete' events)
|
|
74
|
+
*/
|
|
75
|
+
class StreamRouter {
|
|
76
|
+
resolvers;
|
|
77
|
+
error = null;
|
|
78
|
+
stream = null;
|
|
79
|
+
constructor(batch) {
|
|
80
|
+
// Build resolvers map from batch using array index
|
|
81
|
+
this.resolvers = new Map();
|
|
82
|
+
for (let index = 0; index < batch.length; index++) {
|
|
83
|
+
const { resolve, reject } = batch[index];
|
|
84
|
+
this.resolvers.set(index, { resolve, reject });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Set the stream after it's been created
|
|
89
|
+
*/
|
|
90
|
+
setStream(stream) {
|
|
91
|
+
this.stream = stream;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Set an error to be propagated to all resolvers
|
|
95
|
+
*/
|
|
96
|
+
setError(error) {
|
|
97
|
+
this.error = error;
|
|
98
|
+
// Reject all pending resolvers
|
|
99
|
+
for (const { reject } of this.resolvers.values()) {
|
|
100
|
+
reject(error);
|
|
101
|
+
}
|
|
102
|
+
this.resolvers.clear();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Start consuming the stream and routing events
|
|
106
|
+
* Resolves promises with the data field from events (DAILY_SUMMARY or CUSTOM) for their index
|
|
107
|
+
*/
|
|
108
|
+
async start() {
|
|
109
|
+
if (!this.stream) {
|
|
110
|
+
this.setError(new Error('Stream not set'));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
for await (const event of this.stream) {
|
|
115
|
+
// Skip connection and completion events - we only care about data events
|
|
116
|
+
if (event.type === 'connected' || event.type === 'complete') {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
// Handle data events (DAILY_SUMMARY or CUSTOM) - route to specific index
|
|
120
|
+
if (event.index !== undefined &&
|
|
121
|
+
(event.type === 'DAILY_SUMMARY' || event.type === 'CUSTOM')) {
|
|
122
|
+
const index = event.index;
|
|
123
|
+
const resolver = this.resolvers.get(index);
|
|
124
|
+
if (resolver) {
|
|
125
|
+
// Resolve the promise with only the data field
|
|
126
|
+
resolver.resolve(event.data);
|
|
127
|
+
// Remove the resolver since it's been resolved
|
|
128
|
+
this.resolvers.delete(index);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// If stream ends and there are still unresolved promises, reject them
|
|
133
|
+
for (const { reject } of this.resolvers.values()) {
|
|
134
|
+
reject(new Error('Stream ended without data event for this item'));
|
|
135
|
+
}
|
|
136
|
+
this.resolvers.clear();
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
// Reject all pending resolvers
|
|
140
|
+
this.error = error instanceof Error ? error : new Error(String(error));
|
|
141
|
+
this.setError(this.error);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=batch-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-manager.js","sourceRoot":"","sources":["../../src/user/batch-manager.ts"],"names":[],"mappings":";;;AACA,mDAAmE;AAGnE,mDAAmD;AACnD,SAAS,aAAa;IACpB,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,YAAY,CAAC;AACtB,C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AAC;YAED,sEAAsE;YACtE,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;gBACjD,MAAM,CAAC,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,+BAA+B;YAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACvE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { RequestConfig } from '../request.js';
|
|
2
|
+
import { type RecommendationsRequest } from './recommendations.js';
|
|
3
|
+
import { type SignalRequest } from './signal.js';
|
|
4
|
+
import { type TokenRequest } from './token.js';
|
|
5
|
+
import type { SynthesizeRequest } from './typeDefs.js';
|
|
6
|
+
/**
|
|
7
|
+
* User-related API methods
|
|
8
|
+
*/
|
|
9
|
+
export declare function createUserMethods(config: RequestConfig, synthesizeBatchTimeout?: number): {
|
|
10
|
+
/**
|
|
11
|
+
* Authenticate with SSO token
|
|
12
|
+
* Exchanges SSO token for authentication token and sets it for all user methods
|
|
13
|
+
*/
|
|
14
|
+
authenticate(ssoToken: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Exchange SSO token for authentication token (returns token without setting it)
|
|
17
|
+
*/
|
|
18
|
+
token: (ssoToken: TokenRequest["ssoToken"]) => Promise<{
|
|
19
|
+
idToken?: string;
|
|
20
|
+
accessToken?: string;
|
|
21
|
+
refreshToken?: string;
|
|
22
|
+
expiresIn?: number;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Get recommended articles for the authenticated user
|
|
26
|
+
*/
|
|
27
|
+
recommendations: (options?: RecommendationsRequest) => Promise<{
|
|
28
|
+
items?: {
|
|
29
|
+
id?: string;
|
|
30
|
+
assetId?: string;
|
|
31
|
+
title?: string;
|
|
32
|
+
summary?: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
publishedAt?: string;
|
|
35
|
+
score?: number;
|
|
36
|
+
}[];
|
|
37
|
+
cursor?: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Record a user signal (e.g. clicked topic, read article) to inform profile interests
|
|
41
|
+
*/
|
|
42
|
+
signal: (options: SignalRequest) => Promise<{
|
|
43
|
+
recorded?: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Synthesize user content (streaming)
|
|
47
|
+
*/
|
|
48
|
+
synthesize: (items: SynthesizeRequest["items"]) => Promise<AsyncIterable<import("./synthesize.js").SynthesizeEvent>>;
|
|
49
|
+
/**
|
|
50
|
+
* Synthesize a single item (batched)
|
|
51
|
+
* Items are batched and sent together after the configured timeout
|
|
52
|
+
* Returns a promise that resolves with the data field from the event (excluding 'connected' and 'complete' events)
|
|
53
|
+
*/
|
|
54
|
+
synthesizeItem: (item: SynthesizeRequest["items"][number]) => Promise<unknown>;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EAAsB,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,sBAAsB,GAAE,MAAY;IAazF;;;OAGG;2BAC0B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnD;;OAEG;sBACe,YAAY,CAAC,UAAU,CAAC;;;;;;IAE1C;;OAEG;gCACyB,sBAAsB;;cAsB83G,CAAC;mBAA0H,CAAC;iBAA6G,CAAC;mBAA2H,CAAC;mBAAiH,CAAC;uBAAwH,CAAC;iBAA4G,CAAC;;;;IAnB9mI;;OAEG;sBACe,aAAa;;;IAE/B;;OAEG;wBACiB,iBAAiB,CAAC,OAAO,CAAC;IAE9C;;;;OAIG;2BACoB,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAG,OAAO,CAAC,OAAO,CAAC;EAG/E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUserMethods = createUserMethods;
|
|
4
|
+
const batch_manager_js_1 = require("./batch-manager.js");
|
|
5
|
+
const recommendations_js_1 = require("./recommendations.js");
|
|
6
|
+
const signal_js_1 = require("./signal.js");
|
|
7
|
+
const synthesize_js_1 = require("./synthesize.js");
|
|
8
|
+
const token_js_1 = require("./token.js");
|
|
9
|
+
/**
|
|
10
|
+
* User-related API methods
|
|
11
|
+
*/
|
|
12
|
+
function createUserMethods(config, synthesizeBatchTimeout = 250) {
|
|
13
|
+
// Store token in closure - will be set by authenticate method
|
|
14
|
+
let userToken;
|
|
15
|
+
// Create a config getter that includes the user token
|
|
16
|
+
const getConfigWithToken = () => ({
|
|
17
|
+
...config,
|
|
18
|
+
token: userToken,
|
|
19
|
+
});
|
|
20
|
+
const batchManager = new batch_manager_js_1.SynthesizeBatchManager(getConfigWithToken(), synthesizeBatchTimeout);
|
|
21
|
+
return {
|
|
22
|
+
/**
|
|
23
|
+
* Authenticate with SSO token
|
|
24
|
+
* Exchanges SSO token for authentication token and sets it for all user methods
|
|
25
|
+
*/
|
|
26
|
+
async authenticate(ssoToken) {
|
|
27
|
+
const tokenResponse = await (0, token_js_1.exchangeToken)(config, ssoToken);
|
|
28
|
+
const accessToken = tokenResponse?.accessToken || tokenResponse?.idToken;
|
|
29
|
+
if (accessToken) {
|
|
30
|
+
userToken = accessToken;
|
|
31
|
+
// Update batch manager config with new token
|
|
32
|
+
batchManager.updateConfig(getConfigWithToken());
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new Error('Token exchange failed: no access token in response');
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Exchange SSO token for authentication token (returns token without setting it)
|
|
40
|
+
*/
|
|
41
|
+
token: (ssoToken) => (0, token_js_1.exchangeToken)(config, ssoToken),
|
|
42
|
+
/**
|
|
43
|
+
* Get recommended articles for the authenticated user
|
|
44
|
+
*/
|
|
45
|
+
recommendations: (options) => (0, recommendations_js_1.getRecommendations)(getConfigWithToken(), options),
|
|
46
|
+
/**
|
|
47
|
+
* Record a user signal (e.g. clicked topic, read article) to inform profile interests
|
|
48
|
+
*/
|
|
49
|
+
signal: (options) => (0, signal_js_1.recordSignal)(getConfigWithToken(), options),
|
|
50
|
+
/**
|
|
51
|
+
* Synthesize user content (streaming)
|
|
52
|
+
*/
|
|
53
|
+
synthesize: (items) => (0, synthesize_js_1.synthesize)(getConfigWithToken(), items),
|
|
54
|
+
/**
|
|
55
|
+
* Synthesize a single item (batched)
|
|
56
|
+
* Items are batched and sent together after the configured timeout
|
|
57
|
+
* Returns a promise that resolves with the data field from the event (excluding 'connected' and 'complete' events)
|
|
58
|
+
*/
|
|
59
|
+
synthesizeItem: (item) => batchManager.addItem(item),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user/index.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H,UAAU,EAAE,CAAC,KAAiC,EAAE,EAAE,CAAC,IAAA,0BAAU,EAAC,kBAAkB,EAAE,EAAE,KAAK,CAAC;QAE1F;;;;WAIG;QACH,cAAc,EAAE,CAAC,IAAwC,EAAoB,EAAE,CAC7E,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { paths } from '../generated/openapi.js';
|
|
2
|
+
import type { RequestConfig } from '../request.js';
|
|
3
|
+
export type RecommendationsRequest = paths['/v1/user/recommendations']['post']['requestBody'] extends infer RB ? RB extends {
|
|
4
|
+
content: {
|
|
5
|
+
'application/json': infer U;
|
|
6
|
+
};
|
|
7
|
+
} ? U : RB extends {
|
|
8
|
+
content?: {
|
|
9
|
+
'application/json': infer U;
|
|
10
|
+
};
|
|
11
|
+
} ? U : never : never;
|
|
12
|
+
export type RecommendationsResponse = paths['/v1/user/recommendations']['post']['responses'][200]['content']['application/json']['data'];
|
|
13
|
+
/**
|
|
14
|
+
* Get recommended articles for the authenticated user
|
|
15
|
+
*/
|
|
16
|
+
export declare function getRecommendations(config: RequestConfig, options?: RecommendationsRequest): Promise<NonNullable<RecommendationsResponse>>;
|
|
17
|
+
//# sourceMappingURL=recommendations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommendations.d.ts","sourceRoot":"","sources":["../../src/user/recommendations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,MAAM,sBAAsB,GAChC,KAAK,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,SAAS,MAAM,EAAE,GACrE,EAAE,SAAS;IACT,OAAO,EAAE;QAAE,kBAAkB,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;CAC1C,GACC,CAAC,GACD,EAAE,SAAS;IACP,OAAO,CAAC,EAAE;QAAE,kBAAkB,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;CAC3C,GACD,CAAC,GACD,KAAK,GACT,KAAK,CAAC;AACZ,MAAM,MAAM,uBAAuB,GACjC,KAAK,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErG;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC,CAc/C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRecommendations = getRecommendations;
|
|
4
|
+
const request_js_1 = require("../request.js");
|
|
5
|
+
/**
|
|
6
|
+
* Get recommended articles for the authenticated user
|
|
7
|
+
*/
|
|
8
|
+
async function getRecommendations(config, options) {
|
|
9
|
+
const response = await (0, request_js_1.makeRequest)(config, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/v1/user/recommendations',
|
|
12
|
+
body: options,
|
|
13
|
+
});
|
|
14
|
+
if (!response) {
|
|
15
|
+
throw new Error('Failed to get recommendations: no data in response');
|
|
16
|
+
}
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=recommendations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommendations.js","sourceRoot":"","sources":["../../src/user/recommendations.ts"],"names":[],"mappings":";;AAuBA,gDAiBC;AAtCD,8CAA4C;AAkB5C;;GAEG;AACI,KAAK,UAAU,kBAAkB,CACtC,MAAqB,EACrB,OAAgC;IAEhC,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAW,EAEhC,MAAM,EAAE;QACR,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,OAAO;KACd,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { paths } from '../generated/openapi.js';
|
|
2
|
+
import type { RequestConfig } from '../request.js';
|
|
3
|
+
export type SignalRequest = paths['/v1/user/signal']['post']['requestBody']['content']['application/json'];
|
|
4
|
+
export type SignalResponse = paths['/v1/user/signal']['post']['responses'][200]['content']['application/json']['data'];
|
|
5
|
+
/**
|
|
6
|
+
* Record a user signal (e.g. clicked topic, read article) to inform profile interests
|
|
7
|
+
*/
|
|
8
|
+
export declare function recordSignal(config: RequestConfig, options: SignalRequest): Promise<NonNullable<SignalResponse>>;
|
|
9
|
+
//# sourceMappingURL=signal.d.ts.map
|
|
@@ -0,0 +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;AAE5F;;GAEG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CActC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recordSignal = recordSignal;
|
|
4
|
+
const request_js_1 = require("../request.js");
|
|
5
|
+
/**
|
|
6
|
+
* Record a user signal (e.g. clicked topic, read article) to inform profile interests
|
|
7
|
+
*/
|
|
8
|
+
async function recordSignal(config, options) {
|
|
9
|
+
const response = await (0, request_js_1.makeRequest)(config, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/v1/user/signal',
|
|
12
|
+
body: options,
|
|
13
|
+
});
|
|
14
|
+
if (!response) {
|
|
15
|
+
throw new Error('Failed to record signal: no data in response');
|
|
16
|
+
}
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/user/signal.ts"],"names":[],"mappings":";;AAaA,oCAiBC;AA5BD,8CAA4C;AAQ5C;;GAEG;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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RequestConfig } from '../request.js';
|
|
2
|
+
import type { SynthesizeRequest } from './typeDefs.js';
|
|
3
|
+
/**
|
|
4
|
+
* Type for synthesize stream events
|
|
5
|
+
* Derived from the synthesize function's return type
|
|
6
|
+
*/
|
|
7
|
+
export type SynthesizeEvent = {
|
|
8
|
+
type: 'DAILY_SUMMARY' | 'CUSTOM' | 'connected' | 'complete';
|
|
9
|
+
index?: number;
|
|
10
|
+
data?: unknown;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Synthesize user content (streaming)
|
|
14
|
+
*/
|
|
15
|
+
export declare function synthesize(config: RequestConfig, items: SynthesizeRequest['items']): Promise<AsyncIterable<SynthesizeEvent>>;
|
|
16
|
+
/**
|
|
17
|
+
* Extract the event type from the synthesize function's return type
|
|
18
|
+
* This provides a type-safe way to reference the event type
|
|
19
|
+
*/
|
|
20
|
+
export type SynthesizeEventFromReturn = Awaited<ReturnType<typeof synthesize>> extends AsyncIterable<infer T> ? T : never;
|
|
21
|
+
//# sourceMappingURL=synthesize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/user/synthesize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,eAAe,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAChC,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAMzC;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GACnC,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.synthesize = synthesize;
|
|
4
|
+
const request_js_1 = require("../request.js");
|
|
5
|
+
/**
|
|
6
|
+
* Synthesize user content (streaming)
|
|
7
|
+
*/
|
|
8
|
+
async function synthesize(config, items) {
|
|
9
|
+
return (0, request_js_1.makeRequest)(config, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/v1/user/synthesize',
|
|
12
|
+
body: { items },
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=synthesize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesize.js","sourceRoot":"","sources":["../../src/user/synthesize.ts"],"names":[],"mappings":";;AAiBA,gCASC;AAzBD,8CAA4C;AAa5C;;GAEG;AACI,KAAK,UAAU,UAAU,CAC9B,MAAqB,EACrB,KAAiC;IAEjC,OAAO,IAAA,wBAAW,EAAC,MAAM,EAAE;QACzB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,EAAE,KAAK,EAAE;KAChB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { paths } from '../generated/openapi.js';
|
|
2
|
+
import type { RequestConfig } from '../request.js';
|
|
3
|
+
export type TokenRequest = paths['/v1/auth/token']['post']['requestBody']['content']['application/json'];
|
|
4
|
+
export type TokenResponse = paths['/v1/auth/token']['post']['responses'][200]['content']['application/json']['data'];
|
|
5
|
+
/**
|
|
6
|
+
* Exchange SSO token for authentication token
|
|
7
|
+
*/
|
|
8
|
+
export declare function exchangeToken(config: RequestConfig, ssoToken: TokenRequest['ssoToken']): Promise<NonNullable<TokenResponse>>;
|
|
9
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/user/token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,MAAM,YAAY,GACtB,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAChF,MAAM,MAAM,aAAa,GACvB,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3F;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,GACjC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAcrC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exchangeToken = exchangeToken;
|
|
4
|
+
const request_js_1 = require("../request.js");
|
|
5
|
+
/**
|
|
6
|
+
* Exchange SSO token for authentication token
|
|
7
|
+
*/
|
|
8
|
+
async function exchangeToken(config, ssoToken) {
|
|
9
|
+
const response = await (0, request_js_1.makeRequest)(config, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/v1/auth/token',
|
|
12
|
+
body: { ssoToken },
|
|
13
|
+
});
|
|
14
|
+
if (!response) {
|
|
15
|
+
throw new Error('Token exchange failed: no data in response');
|
|
16
|
+
}
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/user/token.ts"],"names":[],"mappings":";;AAaA,sCAiBC;AA5BD,8CAA4C;AAQ5C;;GAEG;AACI,KAAK,UAAU,aAAa,CACjC,MAAqB,EACrB,QAAkC;IAElC,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAW,EAEhC,MAAM,EAAE;QACR,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,EAAE,QAAQ,EAAE;KACnB,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 @@
|
|
|
1
|
+
{"version":3,"file":"typeDefs.d.ts","sourceRoot":"","sources":["../../src/user/typeDefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGrD,MAAM,MAAM,iBAAiB,GAC3B,KAAK,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDefs.js","sourceRoot":"","sources":["../../src/user/typeDefs.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bitbitpress/client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "BitBitPress TypeScript client library",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"prebuild": "rimraf dist",
|
|
21
|
+
"build": "tsc && npm run build:cjs",
|
|
22
|
+
"build:with-types": "npm run generate:types && npm run build",
|
|
23
|
+
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
24
|
+
"build:watch": "npm-run-all --parallel generate:types:watch ts:watch",
|
|
25
|
+
"generate:types": "./scripts/generate-types.sh",
|
|
26
|
+
"generate:types:url": "./scripts/generate-types.sh",
|
|
27
|
+
"generate:types:watch": "chokidar 'http://localhost:4001/docs/json' -c 'npm run generate:types'",
|
|
28
|
+
"ts:watch": "tsc -w",
|
|
29
|
+
"lint": "biome check .",
|
|
30
|
+
"lint:fix": "biome check . --write",
|
|
31
|
+
"test": "tsx --test src/**/*.test.ts",
|
|
32
|
+
"test:watch": "tsx --test --watch src/**/*.test.ts",
|
|
33
|
+
"prepublishOnly": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"bitbitpress",
|
|
37
|
+
"sdk",
|
|
38
|
+
"typescript",
|
|
39
|
+
"react-native",
|
|
40
|
+
"api-client"
|
|
41
|
+
],
|
|
42
|
+
"author": "",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/bitbitpress/bitbit-client.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/bitbitpress/bitbit-client/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/bitbitpress/bitbit-client#readme",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"zod": "^4.3.5"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@biomejs/biome": "^2.3.11",
|
|
57
|
+
"@types/node": "^24.10.8",
|
|
58
|
+
"chokidar-cli": "^3.0.0",
|
|
59
|
+
"npm-run-all": "^4.1.5",
|
|
60
|
+
"openapi-typescript": "^7.4.2",
|
|
61
|
+
"rimraf": "^6.1.2",
|
|
62
|
+
"tsx": "^4.21.0",
|
|
63
|
+
"typescript": "^5.9.3"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"@types/react-native": "*"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"@types/react-native": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|