@jambonz/sdk 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/dist/client/index.cjs +119 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +58 -0
- package/dist/client/index.d.ts +58 -0
- package/dist/client/index.js +115 -0
- package/dist/client/index.js.map +1 -0
- package/dist/common-Bsqv1Brz.d.cts +69 -0
- package/dist/common-Bsqv1Brz.d.ts +69 -0
- package/dist/index.cjs +1014 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +996 -0
- package/dist/index.js.map +1 -0
- package/dist/rest-BV_FsqnH.d.cts +97 -0
- package/dist/rest-CthGXHnw.d.ts +97 -0
- package/dist/types/index.cjs +4 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/verb-builder-But-DJle.d.cts +82 -0
- package/dist/verb-builder-CO_qoYxC.d.ts +82 -0
- package/dist/verbs-B_afNNUM.d.cts +770 -0
- package/dist/verbs-B_afNNUM.d.ts +770 -0
- package/dist/webhook/index.cjs +320 -0
- package/dist/webhook/index.cjs.map +1 -0
- package/dist/webhook/index.d.cts +26 -0
- package/dist/webhook/index.d.ts +26 -0
- package/dist/webhook/index.js +313 -0
- package/dist/webhook/index.js.map +1 -0
- package/dist/websocket/index.cjs +833 -0
- package/dist/websocket/index.cjs.map +1 -0
- package/dist/websocket/index.d.cts +179 -0
- package/dist/websocket/index.d.ts +179 -0
- package/dist/websocket/index.js +822 -0
- package/dist/websocket/index.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/client/api.ts
|
|
4
|
+
var HttpClient = class {
|
|
5
|
+
baseUrl;
|
|
6
|
+
headers;
|
|
7
|
+
constructor(opts) {
|
|
8
|
+
this.baseUrl = opts.baseUrl.replace(/\/+$/, "") + "/v1";
|
|
9
|
+
this.headers = {
|
|
10
|
+
"Authorization": `Bearer ${opts.apiKey}`,
|
|
11
|
+
"Content-Type": "application/json"
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
async get(path) {
|
|
15
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
16
|
+
method: "GET",
|
|
17
|
+
headers: this.headers
|
|
18
|
+
});
|
|
19
|
+
if (!res.ok) throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);
|
|
20
|
+
return res.json();
|
|
21
|
+
}
|
|
22
|
+
async post(path, body) {
|
|
23
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
headers: this.headers,
|
|
26
|
+
body: JSON.stringify(body)
|
|
27
|
+
});
|
|
28
|
+
if (!res.ok) throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);
|
|
29
|
+
return res.json();
|
|
30
|
+
}
|
|
31
|
+
async put(path, body) {
|
|
32
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
33
|
+
method: "PUT",
|
|
34
|
+
headers: this.headers,
|
|
35
|
+
body: JSON.stringify(body)
|
|
36
|
+
});
|
|
37
|
+
if (!res.ok) throw new Error(`PUT ${path} failed: ${res.status} ${res.statusText}`);
|
|
38
|
+
}
|
|
39
|
+
async del(path) {
|
|
40
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
41
|
+
method: "DELETE",
|
|
42
|
+
headers: this.headers
|
|
43
|
+
});
|
|
44
|
+
if (!res.ok) throw new Error(`DELETE ${path} failed: ${res.status} ${res.statusText}`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var CallsResource = class {
|
|
48
|
+
constructor(http, accountSid) {
|
|
49
|
+
this.http = http;
|
|
50
|
+
this.accountSid = accountSid;
|
|
51
|
+
}
|
|
52
|
+
/** Create a new outbound call. */
|
|
53
|
+
async create(opts) {
|
|
54
|
+
const result = await this.http.post(
|
|
55
|
+
`/Accounts/${this.accountSid}/Calls`,
|
|
56
|
+
opts
|
|
57
|
+
);
|
|
58
|
+
return result.sid;
|
|
59
|
+
}
|
|
60
|
+
/** Get info about an active call. */
|
|
61
|
+
async get(callSid) {
|
|
62
|
+
return this.http.get(
|
|
63
|
+
`/Accounts/${this.accountSid}/Calls/${callSid}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
/** Update an active call (redirect, mute, hangup, etc). */
|
|
67
|
+
async update(callSid, opts) {
|
|
68
|
+
return this.http.put(
|
|
69
|
+
`/Accounts/${this.accountSid}/Calls/${callSid}`,
|
|
70
|
+
opts
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
/** Terminate a call. */
|
|
74
|
+
async delete(callSid) {
|
|
75
|
+
return this.http.del(
|
|
76
|
+
`/Accounts/${this.accountSid}/Calls/${callSid}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
/** Redirect call execution to a new webhook URL. */
|
|
80
|
+
async redirect(callSid, hook) {
|
|
81
|
+
return this.update(callSid, { call_hook: hook });
|
|
82
|
+
}
|
|
83
|
+
/** Inject a whisper verb (say/play) to one party on the call. */
|
|
84
|
+
async whisper(callSid, verb) {
|
|
85
|
+
return this.update(callSid, { whisper: verb });
|
|
86
|
+
}
|
|
87
|
+
/** Mute or unmute a call. */
|
|
88
|
+
async mute(callSid, status) {
|
|
89
|
+
return this.update(callSid, { mute_status: status });
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var MessagesResource = class {
|
|
93
|
+
constructor(http, accountSid) {
|
|
94
|
+
this.http = http;
|
|
95
|
+
this.accountSid = accountSid;
|
|
96
|
+
}
|
|
97
|
+
/** Send an SMS/MMS message. */
|
|
98
|
+
async create(opts) {
|
|
99
|
+
return this.http.post(
|
|
100
|
+
`/Accounts/${this.accountSid}/Messages`,
|
|
101
|
+
opts
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var JambonzClient = class {
|
|
106
|
+
calls;
|
|
107
|
+
messages;
|
|
108
|
+
constructor(opts) {
|
|
109
|
+
const http = new HttpClient(opts);
|
|
110
|
+
this.calls = new CallsResource(http, opts.accountSid);
|
|
111
|
+
this.messages = new MessagesResource(http, opts.accountSid);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
exports.CallsResource = CallsResource;
|
|
116
|
+
exports.JambonzClient = JambonzClient;
|
|
117
|
+
exports.MessagesResource = MessagesResource;
|
|
118
|
+
//# sourceMappingURL=index.cjs.map
|
|
119
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/api.ts"],"names":[],"mappings":";;;AAwBA,IAAM,aAAN,MAAiB;AAAA,EACP,OAAA;AAAA,EACA,OAAA;AAAA,EAER,YAAY,IAAA,EAAqB;AAC/B,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,GAAI,KAAA;AAClD,IAAA,IAAA,CAAK,OAAA,GAAU;AAAA,MACb,eAAA,EAAiB,CAAA,OAAA,EAAU,IAAA,CAAK,MAAM,CAAA,CAAA;AAAA,MACtC,cAAA,EAAgB;AAAA,KAClB;AAAA,EACF;AAAA,EAEA,MAAM,IAAO,IAAA,EAA0B;AACrC,IAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,CAAA,EAAG,KAAK,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI;AAAA,MAChD,MAAA,EAAQ,KAAA;AAAA,MACR,SAAS,IAAA,CAAK;AAAA,KACf,CAAA;AACD,IAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,MAAM,IAAI,KAAA,CAAM,CAAA,IAAA,EAAO,IAAI,CAAA,SAAA,EAAY,GAAA,CAAI,MAAM,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A,CAAiB,IAAA,EAAM,KAAK,UAAU,CAAA;AAAA,EAC5D;AACF","file":"index.cjs","sourcesContent":["/**\n * JambonzClient — REST API client for the jambonz platform.\n * Uses native fetch (Node 18+).\n */\n\nimport type {\n CallInfo,\n CreateCallRequest,\n UpdateCallRequest,\n SendMessageRequest,\n MessageInfo,\n} from '../types/rest.js';\nimport type { ActionHook } from '../types/components.js';\nimport type { Verb } from '../types/verbs.js';\n\nexport interface ClientOptions {\n /** Base URL of the jambonz API (e.g. 'https://api.jambonz.us'). */\n baseUrl: string;\n /** Account SID. */\n accountSid: string;\n /** API key (Bearer token). */\n apiKey: string;\n}\n\nclass HttpClient {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(opts: ClientOptions) {\n this.baseUrl = opts.baseUrl.replace(/\\/+$/, '') + '/v1';\n this.headers = {\n 'Authorization': `Bearer ${opts.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n async get<T>(path: string): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: 'GET',\n headers: this.headers,\n });\n if (!res.ok) throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);\n return res.json() as Promise<T>;\n }\n\n async post<T>(path: string, body: unknown): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(body),\n });\n if (!res.ok) throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);\n return res.json() as Promise<T>;\n }\n\n async put(path: string, body: unknown): Promise<void> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: 'PUT',\n headers: this.headers,\n body: JSON.stringify(body),\n });\n if (!res.ok) throw new Error(`PUT ${path} failed: ${res.status} ${res.statusText}`);\n }\n\n async del(path: string): Promise<void> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: 'DELETE',\n headers: this.headers,\n });\n if (!res.ok) throw new Error(`DELETE ${path} failed: ${res.status} ${res.statusText}`);\n }\n}\n\nexport class CallsResource {\n constructor(private http: HttpClient, private accountSid: string) {}\n\n /** Create a new outbound call. */\n async create(opts: CreateCallRequest): Promise<string> {\n const result = await this.http.post<{ sid: string }>(\n `/Accounts/${this.accountSid}/Calls`,\n opts\n );\n return result.sid;\n }\n\n /** Get info about an active call. */\n async get(callSid: string): Promise<CallInfo> {\n return this.http.get<CallInfo>(\n `/Accounts/${this.accountSid}/Calls/${callSid}`\n );\n }\n\n /** Update an active call (redirect, mute, hangup, etc). */\n async update(callSid: string, opts: UpdateCallRequest): Promise<void> {\n return this.http.put(\n `/Accounts/${this.accountSid}/Calls/${callSid}`,\n opts\n );\n }\n\n /** Terminate a call. */\n async delete(callSid: string): Promise<void> {\n return this.http.del(\n `/Accounts/${this.accountSid}/Calls/${callSid}`\n );\n }\n\n /** Redirect call execution to a new webhook URL. */\n async redirect(callSid: string, hook: ActionHook): Promise<void> {\n return this.update(callSid, { call_hook: hook });\n }\n\n /** Inject a whisper verb (say/play) to one party on the call. */\n async whisper(callSid: string, verb: Verb): Promise<void> {\n return this.update(callSid, { whisper: verb });\n }\n\n /** Mute or unmute a call. */\n async mute(callSid: string, status: 'mute' | 'unmute'): Promise<void> {\n return this.update(callSid, { mute_status: status });\n }\n}\n\nexport class MessagesResource {\n constructor(private http: HttpClient, private accountSid: string) {}\n\n /** Send an SMS/MMS message. */\n async create(opts: SendMessageRequest): Promise<MessageInfo> {\n return this.http.post<MessageInfo>(\n `/Accounts/${this.accountSid}/Messages`,\n opts\n );\n }\n}\n\nexport class JambonzClient {\n readonly calls: CallsResource;\n readonly messages: MessagesResource;\n\n constructor(opts: ClientOptions) {\n const http = new HttpClient(opts);\n this.calls = new CallsResource(http, opts.accountSid);\n this.messages = new MessagesResource(http, opts.accountSid);\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { a as CreateCallRequest, C as CallInfo, U as UpdateCallRequest, S as SendMessageRequest, M as MessageInfo } from '../rest-BV_FsqnH.cjs';
|
|
2
|
+
import { A as ActionHook, w as Verb } from '../verbs-B_afNNUM.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* JambonzClient — REST API client for the jambonz platform.
|
|
6
|
+
* Uses native fetch (Node 18+).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface ClientOptions {
|
|
10
|
+
/** Base URL of the jambonz API (e.g. 'https://api.jambonz.us'). */
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/** Account SID. */
|
|
13
|
+
accountSid: string;
|
|
14
|
+
/** API key (Bearer token). */
|
|
15
|
+
apiKey: string;
|
|
16
|
+
}
|
|
17
|
+
declare class HttpClient {
|
|
18
|
+
private baseUrl;
|
|
19
|
+
private headers;
|
|
20
|
+
constructor(opts: ClientOptions);
|
|
21
|
+
get<T>(path: string): Promise<T>;
|
|
22
|
+
post<T>(path: string, body: unknown): Promise<T>;
|
|
23
|
+
put(path: string, body: unknown): Promise<void>;
|
|
24
|
+
del(path: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
declare class CallsResource {
|
|
27
|
+
private http;
|
|
28
|
+
private accountSid;
|
|
29
|
+
constructor(http: HttpClient, accountSid: string);
|
|
30
|
+
/** Create a new outbound call. */
|
|
31
|
+
create(opts: CreateCallRequest): Promise<string>;
|
|
32
|
+
/** Get info about an active call. */
|
|
33
|
+
get(callSid: string): Promise<CallInfo>;
|
|
34
|
+
/** Update an active call (redirect, mute, hangup, etc). */
|
|
35
|
+
update(callSid: string, opts: UpdateCallRequest): Promise<void>;
|
|
36
|
+
/** Terminate a call. */
|
|
37
|
+
delete(callSid: string): Promise<void>;
|
|
38
|
+
/** Redirect call execution to a new webhook URL. */
|
|
39
|
+
redirect(callSid: string, hook: ActionHook): Promise<void>;
|
|
40
|
+
/** Inject a whisper verb (say/play) to one party on the call. */
|
|
41
|
+
whisper(callSid: string, verb: Verb): Promise<void>;
|
|
42
|
+
/** Mute or unmute a call. */
|
|
43
|
+
mute(callSid: string, status: 'mute' | 'unmute'): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
declare class MessagesResource {
|
|
46
|
+
private http;
|
|
47
|
+
private accountSid;
|
|
48
|
+
constructor(http: HttpClient, accountSid: string);
|
|
49
|
+
/** Send an SMS/MMS message. */
|
|
50
|
+
create(opts: SendMessageRequest): Promise<MessageInfo>;
|
|
51
|
+
}
|
|
52
|
+
declare class JambonzClient {
|
|
53
|
+
readonly calls: CallsResource;
|
|
54
|
+
readonly messages: MessagesResource;
|
|
55
|
+
constructor(opts: ClientOptions);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { CallsResource, type ClientOptions, JambonzClient, MessagesResource };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { a as CreateCallRequest, C as CallInfo, U as UpdateCallRequest, S as SendMessageRequest, M as MessageInfo } from '../rest-CthGXHnw.js';
|
|
2
|
+
import { A as ActionHook, w as Verb } from '../verbs-B_afNNUM.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* JambonzClient — REST API client for the jambonz platform.
|
|
6
|
+
* Uses native fetch (Node 18+).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface ClientOptions {
|
|
10
|
+
/** Base URL of the jambonz API (e.g. 'https://api.jambonz.us'). */
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/** Account SID. */
|
|
13
|
+
accountSid: string;
|
|
14
|
+
/** API key (Bearer token). */
|
|
15
|
+
apiKey: string;
|
|
16
|
+
}
|
|
17
|
+
declare class HttpClient {
|
|
18
|
+
private baseUrl;
|
|
19
|
+
private headers;
|
|
20
|
+
constructor(opts: ClientOptions);
|
|
21
|
+
get<T>(path: string): Promise<T>;
|
|
22
|
+
post<T>(path: string, body: unknown): Promise<T>;
|
|
23
|
+
put(path: string, body: unknown): Promise<void>;
|
|
24
|
+
del(path: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
declare class CallsResource {
|
|
27
|
+
private http;
|
|
28
|
+
private accountSid;
|
|
29
|
+
constructor(http: HttpClient, accountSid: string);
|
|
30
|
+
/** Create a new outbound call. */
|
|
31
|
+
create(opts: CreateCallRequest): Promise<string>;
|
|
32
|
+
/** Get info about an active call. */
|
|
33
|
+
get(callSid: string): Promise<CallInfo>;
|
|
34
|
+
/** Update an active call (redirect, mute, hangup, etc). */
|
|
35
|
+
update(callSid: string, opts: UpdateCallRequest): Promise<void>;
|
|
36
|
+
/** Terminate a call. */
|
|
37
|
+
delete(callSid: string): Promise<void>;
|
|
38
|
+
/** Redirect call execution to a new webhook URL. */
|
|
39
|
+
redirect(callSid: string, hook: ActionHook): Promise<void>;
|
|
40
|
+
/** Inject a whisper verb (say/play) to one party on the call. */
|
|
41
|
+
whisper(callSid: string, verb: Verb): Promise<void>;
|
|
42
|
+
/** Mute or unmute a call. */
|
|
43
|
+
mute(callSid: string, status: 'mute' | 'unmute'): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
declare class MessagesResource {
|
|
46
|
+
private http;
|
|
47
|
+
private accountSid;
|
|
48
|
+
constructor(http: HttpClient, accountSid: string);
|
|
49
|
+
/** Send an SMS/MMS message. */
|
|
50
|
+
create(opts: SendMessageRequest): Promise<MessageInfo>;
|
|
51
|
+
}
|
|
52
|
+
declare class JambonzClient {
|
|
53
|
+
readonly calls: CallsResource;
|
|
54
|
+
readonly messages: MessagesResource;
|
|
55
|
+
constructor(opts: ClientOptions);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { CallsResource, type ClientOptions, JambonzClient, MessagesResource };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// src/client/api.ts
|
|
2
|
+
var HttpClient = class {
|
|
3
|
+
baseUrl;
|
|
4
|
+
headers;
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
this.baseUrl = opts.baseUrl.replace(/\/+$/, "") + "/v1";
|
|
7
|
+
this.headers = {
|
|
8
|
+
"Authorization": `Bearer ${opts.apiKey}`,
|
|
9
|
+
"Content-Type": "application/json"
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
async get(path) {
|
|
13
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
14
|
+
method: "GET",
|
|
15
|
+
headers: this.headers
|
|
16
|
+
});
|
|
17
|
+
if (!res.ok) throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);
|
|
18
|
+
return res.json();
|
|
19
|
+
}
|
|
20
|
+
async post(path, body) {
|
|
21
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
headers: this.headers,
|
|
24
|
+
body: JSON.stringify(body)
|
|
25
|
+
});
|
|
26
|
+
if (!res.ok) throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);
|
|
27
|
+
return res.json();
|
|
28
|
+
}
|
|
29
|
+
async put(path, body) {
|
|
30
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
31
|
+
method: "PUT",
|
|
32
|
+
headers: this.headers,
|
|
33
|
+
body: JSON.stringify(body)
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok) throw new Error(`PUT ${path} failed: ${res.status} ${res.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
async del(path) {
|
|
38
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
39
|
+
method: "DELETE",
|
|
40
|
+
headers: this.headers
|
|
41
|
+
});
|
|
42
|
+
if (!res.ok) throw new Error(`DELETE ${path} failed: ${res.status} ${res.statusText}`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var CallsResource = class {
|
|
46
|
+
constructor(http, accountSid) {
|
|
47
|
+
this.http = http;
|
|
48
|
+
this.accountSid = accountSid;
|
|
49
|
+
}
|
|
50
|
+
/** Create a new outbound call. */
|
|
51
|
+
async create(opts) {
|
|
52
|
+
const result = await this.http.post(
|
|
53
|
+
`/Accounts/${this.accountSid}/Calls`,
|
|
54
|
+
opts
|
|
55
|
+
);
|
|
56
|
+
return result.sid;
|
|
57
|
+
}
|
|
58
|
+
/** Get info about an active call. */
|
|
59
|
+
async get(callSid) {
|
|
60
|
+
return this.http.get(
|
|
61
|
+
`/Accounts/${this.accountSid}/Calls/${callSid}`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
/** Update an active call (redirect, mute, hangup, etc). */
|
|
65
|
+
async update(callSid, opts) {
|
|
66
|
+
return this.http.put(
|
|
67
|
+
`/Accounts/${this.accountSid}/Calls/${callSid}`,
|
|
68
|
+
opts
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
/** Terminate a call. */
|
|
72
|
+
async delete(callSid) {
|
|
73
|
+
return this.http.del(
|
|
74
|
+
`/Accounts/${this.accountSid}/Calls/${callSid}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
/** Redirect call execution to a new webhook URL. */
|
|
78
|
+
async redirect(callSid, hook) {
|
|
79
|
+
return this.update(callSid, { call_hook: hook });
|
|
80
|
+
}
|
|
81
|
+
/** Inject a whisper verb (say/play) to one party on the call. */
|
|
82
|
+
async whisper(callSid, verb) {
|
|
83
|
+
return this.update(callSid, { whisper: verb });
|
|
84
|
+
}
|
|
85
|
+
/** Mute or unmute a call. */
|
|
86
|
+
async mute(callSid, status) {
|
|
87
|
+
return this.update(callSid, { mute_status: status });
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var MessagesResource = class {
|
|
91
|
+
constructor(http, accountSid) {
|
|
92
|
+
this.http = http;
|
|
93
|
+
this.accountSid = accountSid;
|
|
94
|
+
}
|
|
95
|
+
/** Send an SMS/MMS message. */
|
|
96
|
+
async create(opts) {
|
|
97
|
+
return this.http.post(
|
|
98
|
+
`/Accounts/${this.accountSid}/Messages`,
|
|
99
|
+
opts
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var JambonzClient = class {
|
|
104
|
+
calls;
|
|
105
|
+
messages;
|
|
106
|
+
constructor(opts) {
|
|
107
|
+
const http = new HttpClient(opts);
|
|
108
|
+
this.calls = new CallsResource(http, opts.accountSid);
|
|
109
|
+
this.messages = new MessagesResource(http, opts.accountSid);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export { CallsResource, JambonzClient, MessagesResource };
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/api.ts"],"names":[],"mappings":";AAwBA,IAAM,aAAN,MAAiB;AAAA,EACP,OAAA;AAAA,EACA,OAAA;AAAA,EAER,YAAY,IAAA,EAAqB;AAC/B,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,GAAI,KAAA;AAClD,IAAA,IAAA,CAAK,OAAA,GAAU;AAAA,MACb,eAAA,EAAiB,CAAA,OAAA,EAAU,IAAA,CAAK,MAAM,CAAA,CAAA;AAAA,MACtC,cAAA,EAAgB;AAAA,KAClB;AAAA,EACF;AAAA,EAEA,MAAM,IAAO,IAAA,EAA0B;AACrC,IAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,CAAA,EAAG,KAAK,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI;AAAA,MAChD,MAAA,EAAQ,KAAA;AAAA,MACR,SAAS,IAAA,CAAK;AAAA,KACf,CAAA;AACD,IAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,MAAM,IAAI,KAAA,CAAM,CAAA,IAAA,EAAO,IAAI,CAAA,SAAA,EAAY,GAAA,CAAI,MAAM,CAAA,CAAA,EAAI,GAAA,CAAI,UAAU,CAAA,CAAE,CAAA;AAClF,IAAA,OAAO,IAAI,IAAA,EAAK;AAAA,EAClB;AAAA,EAEA,MAAM,IAAA,CAAQ,IAAA,EAAc,IAAA,EAA2B;AACrD,IAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,CAAA,EAAG,KAAK,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI;AAAA,MAChD,MAA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A,EAGA,MAAM,OAAA,CAAQ,OAAA,EAAiB,IAAA,EAA2B;AACxD,IAAA,OAAO,KAAK,MAAA,CAAO,OAAA,EAAS,EAAE,OAAA,EAAS,MAAM,CAAA;AAAA,EAC/C;AAAA;AAAA,EAGA,MAAM,IAAA,CAAK,OAAA,EAAiB,MAAA,EAA0C;AACpE,IAAA,OAAO,KAAK,MAAA,CAAO,OAAA,EAAS,EAAE,WAAA,EAAa,QAAQ,CAAA;AAAA,EACrD;AACF;AAEO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,WAAA,CAAoB,MAA0B,UAAA,EAAoB;AAA9C,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAA0B,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAAA,EAAqB;AAAA;AAAA,EAGnE,MAAM,OAAO,IAAA,EAAgD;AAC3D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,UAAA,EAAa,KAAK,UAAU,CAAA,SAAA,CAAA;AAAA,MAC5B;AAAA,KACF;AAAA,EACF;AACF;AAEO,IAAM,gBAAN,MAAoB;AAAA,EAChB,KAAA;AAAA,EACA,QAAA;AAAA,EAET,YAAY,IAAA,EAAqB;AAC/B,IAAA,MAAM,IAAA,GAAO,IAAI,UAAA,CAAW,IAAI,CAAA;AAChC,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,EAAM,KAAK,UAAU,CAAA;AACpD,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,gBAAA,CAAiB,IAAA,EAAM,KAAK,UAAU,CAAA;AAAA,EAC5D;AACF","file":"index.js","sourcesContent":["/**\n * JambonzClient — REST API client for the jambonz platform.\n * Uses native fetch (Node 18+).\n */\n\nimport type {\n CallInfo,\n CreateCallRequest,\n UpdateCallRequest,\n SendMessageRequest,\n MessageInfo,\n} from '../types/rest.js';\nimport type { ActionHook } from '../types/components.js';\nimport type { Verb } from '../types/verbs.js';\n\nexport interface ClientOptions {\n /** Base URL of the jambonz API (e.g. 'https://api.jambonz.us'). */\n baseUrl: string;\n /** Account SID. */\n accountSid: string;\n /** API key (Bearer token). */\n apiKey: string;\n}\n\nclass HttpClient {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(opts: ClientOptions) {\n this.baseUrl = opts.baseUrl.replace(/\\/+$/, '') + '/v1';\n this.headers = {\n 'Authorization': `Bearer ${opts.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n async get<T>(path: string): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: 'GET',\n headers: this.headers,\n });\n if (!res.ok) throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);\n return res.json() as Promise<T>;\n }\n\n async post<T>(path: string, body: unknown): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(body),\n });\n if (!res.ok) throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);\n return res.json() as Promise<T>;\n }\n\n async put(path: string, body: unknown): Promise<void> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: 'PUT',\n headers: this.headers,\n body: JSON.stringify(body),\n });\n if (!res.ok) throw new Error(`PUT ${path} failed: ${res.status} ${res.statusText}`);\n }\n\n async del(path: string): Promise<void> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n method: 'DELETE',\n headers: this.headers,\n });\n if (!res.ok) throw new Error(`DELETE ${path} failed: ${res.status} ${res.statusText}`);\n }\n}\n\nexport class CallsResource {\n constructor(private http: HttpClient, private accountSid: string) {}\n\n /** Create a new outbound call. */\n async create(opts: CreateCallRequest): Promise<string> {\n const result = await this.http.post<{ sid: string }>(\n `/Accounts/${this.accountSid}/Calls`,\n opts\n );\n return result.sid;\n }\n\n /** Get info about an active call. */\n async get(callSid: string): Promise<CallInfo> {\n return this.http.get<CallInfo>(\n `/Accounts/${this.accountSid}/Calls/${callSid}`\n );\n }\n\n /** Update an active call (redirect, mute, hangup, etc). */\n async update(callSid: string, opts: UpdateCallRequest): Promise<void> {\n return this.http.put(\n `/Accounts/${this.accountSid}/Calls/${callSid}`,\n opts\n );\n }\n\n /** Terminate a call. */\n async delete(callSid: string): Promise<void> {\n return this.http.del(\n `/Accounts/${this.accountSid}/Calls/${callSid}`\n );\n }\n\n /** Redirect call execution to a new webhook URL. */\n async redirect(callSid: string, hook: ActionHook): Promise<void> {\n return this.update(callSid, { call_hook: hook });\n }\n\n /** Inject a whisper verb (say/play) to one party on the call. */\n async whisper(callSid: string, verb: Verb): Promise<void> {\n return this.update(callSid, { whisper: verb });\n }\n\n /** Mute or unmute a call. */\n async mute(callSid: string, status: 'mute' | 'unmute'): Promise<void> {\n return this.update(callSid, { mute_status: status });\n }\n}\n\nexport class MessagesResource {\n constructor(private http: HttpClient, private accountSid: string) {}\n\n /** Send an SMS/MMS message. */\n async create(opts: SendMessageRequest): Promise<MessageInfo> {\n return this.http.post<MessageInfo>(\n `/Accounts/${this.accountSid}/Messages`,\n opts\n );\n }\n}\n\nexport class JambonzClient {\n readonly calls: CallsResource;\n readonly messages: MessagesResource;\n\n constructor(opts: ClientOptions) {\n const http = new HttpClient(opts);\n this.calls = new CallsResource(http, opts.accountSid);\n this.messages = new MessagesResource(http, opts.accountSid);\n }\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for call session data received from jambonz.
|
|
3
|
+
*/
|
|
4
|
+
/** Call session data provided in webhook requests and WebSocket session:new messages. */
|
|
5
|
+
interface CallSession {
|
|
6
|
+
/** Unique call identifier. */
|
|
7
|
+
call_sid: string;
|
|
8
|
+
/** Account identifier. */
|
|
9
|
+
account_sid: string;
|
|
10
|
+
/** Application identifier. */
|
|
11
|
+
application_sid: string;
|
|
12
|
+
/** Call direction. */
|
|
13
|
+
direction: 'inbound' | 'outbound';
|
|
14
|
+
/** Caller phone number or SIP URI. */
|
|
15
|
+
from: string;
|
|
16
|
+
/** Called phone number or SIP URI. */
|
|
17
|
+
to: string;
|
|
18
|
+
/** SIP Call-ID header. */
|
|
19
|
+
call_id: string;
|
|
20
|
+
/** SIP response status code. */
|
|
21
|
+
sip_status: number;
|
|
22
|
+
/** Caller display name. */
|
|
23
|
+
caller_name?: string;
|
|
24
|
+
/** Call status. */
|
|
25
|
+
call_status?: string;
|
|
26
|
+
/** SIP trunk name. */
|
|
27
|
+
trunk?: string;
|
|
28
|
+
/** Service provider SID. */
|
|
29
|
+
service_provider_sid?: string;
|
|
30
|
+
/** Distributed tracing ID. */
|
|
31
|
+
trace_id?: string;
|
|
32
|
+
/** Custom SIP headers from the INVITE. */
|
|
33
|
+
sip_headers?: Record<string, string>;
|
|
34
|
+
/** Additional properties. */
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** WebSocket message types received from jambonz. */
|
|
38
|
+
type WsMessageType = 'session:new' | 'session:adulting' | 'session:reconnect' | 'session:redirect' | 'verb:hook' | 'dial:confirm' | 'call:status' | 'verb:status' | 'llm:event' | 'llm:tool-call' | 'tts:streaming-event' | 'tts:tokens-result' | 'jambonz:error';
|
|
39
|
+
/** Inbound WebSocket message from jambonz. */
|
|
40
|
+
interface WsMessage {
|
|
41
|
+
type: WsMessageType;
|
|
42
|
+
msgid: string;
|
|
43
|
+
call_sid?: string;
|
|
44
|
+
hook?: string;
|
|
45
|
+
data?: Record<string, unknown>;
|
|
46
|
+
b3?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Outbound WebSocket message to jambonz. */
|
|
49
|
+
interface WsResponse {
|
|
50
|
+
type: 'ack' | 'command';
|
|
51
|
+
msgid?: string;
|
|
52
|
+
command?: string;
|
|
53
|
+
queueCommand?: boolean;
|
|
54
|
+
data?: unknown;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Common types and re-exports.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/** Logger interface expected by SDK components. */
|
|
62
|
+
interface Logger {
|
|
63
|
+
info: (...args: unknown[]) => void;
|
|
64
|
+
error: (...args: unknown[]) => void;
|
|
65
|
+
debug: (...args: unknown[]) => void;
|
|
66
|
+
child?: (bindings: Record<string, unknown>) => Logger;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type { CallSession as C, Logger as L, WsMessage as W, WsMessageType as a, WsResponse as b };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for call session data received from jambonz.
|
|
3
|
+
*/
|
|
4
|
+
/** Call session data provided in webhook requests and WebSocket session:new messages. */
|
|
5
|
+
interface CallSession {
|
|
6
|
+
/** Unique call identifier. */
|
|
7
|
+
call_sid: string;
|
|
8
|
+
/** Account identifier. */
|
|
9
|
+
account_sid: string;
|
|
10
|
+
/** Application identifier. */
|
|
11
|
+
application_sid: string;
|
|
12
|
+
/** Call direction. */
|
|
13
|
+
direction: 'inbound' | 'outbound';
|
|
14
|
+
/** Caller phone number or SIP URI. */
|
|
15
|
+
from: string;
|
|
16
|
+
/** Called phone number or SIP URI. */
|
|
17
|
+
to: string;
|
|
18
|
+
/** SIP Call-ID header. */
|
|
19
|
+
call_id: string;
|
|
20
|
+
/** SIP response status code. */
|
|
21
|
+
sip_status: number;
|
|
22
|
+
/** Caller display name. */
|
|
23
|
+
caller_name?: string;
|
|
24
|
+
/** Call status. */
|
|
25
|
+
call_status?: string;
|
|
26
|
+
/** SIP trunk name. */
|
|
27
|
+
trunk?: string;
|
|
28
|
+
/** Service provider SID. */
|
|
29
|
+
service_provider_sid?: string;
|
|
30
|
+
/** Distributed tracing ID. */
|
|
31
|
+
trace_id?: string;
|
|
32
|
+
/** Custom SIP headers from the INVITE. */
|
|
33
|
+
sip_headers?: Record<string, string>;
|
|
34
|
+
/** Additional properties. */
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** WebSocket message types received from jambonz. */
|
|
38
|
+
type WsMessageType = 'session:new' | 'session:adulting' | 'session:reconnect' | 'session:redirect' | 'verb:hook' | 'dial:confirm' | 'call:status' | 'verb:status' | 'llm:event' | 'llm:tool-call' | 'tts:streaming-event' | 'tts:tokens-result' | 'jambonz:error';
|
|
39
|
+
/** Inbound WebSocket message from jambonz. */
|
|
40
|
+
interface WsMessage {
|
|
41
|
+
type: WsMessageType;
|
|
42
|
+
msgid: string;
|
|
43
|
+
call_sid?: string;
|
|
44
|
+
hook?: string;
|
|
45
|
+
data?: Record<string, unknown>;
|
|
46
|
+
b3?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Outbound WebSocket message to jambonz. */
|
|
49
|
+
interface WsResponse {
|
|
50
|
+
type: 'ack' | 'command';
|
|
51
|
+
msgid?: string;
|
|
52
|
+
command?: string;
|
|
53
|
+
queueCommand?: boolean;
|
|
54
|
+
data?: unknown;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Common types and re-exports.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/** Logger interface expected by SDK components. */
|
|
62
|
+
interface Logger {
|
|
63
|
+
info: (...args: unknown[]) => void;
|
|
64
|
+
error: (...args: unknown[]) => void;
|
|
65
|
+
debug: (...args: unknown[]) => void;
|
|
66
|
+
child?: (bindings: Record<string, unknown>) => Logger;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type { CallSession as C, Logger as L, WsMessage as W, WsMessageType as a, WsResponse as b };
|