@solo3li/backend-node 1.0.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.
@@ -0,0 +1,19 @@
1
+ export interface CPaaSConfig {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+ export interface CreateTokenRequest {
6
+ agentId: string;
7
+ participantName?: string;
8
+ metadata?: Record<string, string>;
9
+ }
10
+ export interface CreateTokenResponse {
11
+ token: string;
12
+ roomName: string;
13
+ livekitUrl: string;
14
+ }
15
+ export declare class CPaaSClient {
16
+ private client;
17
+ constructor(config: CPaaSConfig);
18
+ createConnectionToken(request: CreateTokenRequest): Promise<CreateTokenResponse>;
19
+ }
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CPaaSClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class CPaaSClient {
9
+ client;
10
+ constructor(config) {
11
+ this.client = axios_1.default.create({
12
+ baseURL: config.baseUrl || 'https://api.yourcpaas.com',
13
+ headers: {
14
+ 'Authorization': `Bearer ${config.apiKey}`,
15
+ 'Content-Type': 'application/json'
16
+ }
17
+ });
18
+ }
19
+ async createConnectionToken(request) {
20
+ try {
21
+ const response = await this.client.post('/api/Connection/token', {
22
+ agentId: request.agentId,
23
+ participantName: request.participantName || 'user',
24
+ metadata: request.metadata || {}
25
+ });
26
+ return response.data;
27
+ }
28
+ catch (error) {
29
+ if (error.response) {
30
+ throw new Error(`CPaaS API Error: ${error.response.status} - ${JSON.stringify(error.response.data)}`);
31
+ }
32
+ throw error;
33
+ }
34
+ }
35
+ }
36
+ exports.CPaaSClient = CPaaSClient;
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@solo3li/backend-node",
3
+ "version": "1.0.0",
4
+ "description": "Node.js SDK for Voice AI CPaaS",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc"
12
+ },
13
+ "dependencies": {
14
+ "axios": "^1.6.0"
15
+ },
16
+ "devDependencies": {
17
+ "typescript": "^5.0.0"
18
+ }
19
+ }