monade-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.
Files changed (67) hide show
  1. package/README.md +98 -0
  2. package/dist/generated/apis/CampaignServiceApiApi.d.ts +302 -0
  3. package/dist/generated/apis/CampaignServiceApiApi.js +704 -0
  4. package/dist/generated/apis/ControlPlaneApi.d.ts +35 -0
  5. package/dist/generated/apis/ControlPlaneApi.js +87 -0
  6. package/dist/generated/apis/PostgresqlDbRoutesApi.d.ts +707 -0
  7. package/dist/generated/apis/PostgresqlDbRoutesApi.js +1314 -0
  8. package/dist/generated/apis/index.d.ts +3 -0
  9. package/dist/generated/apis/index.js +21 -0
  10. package/dist/generated/index.d.ts +3 -0
  11. package/dist/generated/index.js +21 -0
  12. package/dist/generated/models/AddContactsToCampaignRequest.d.ts +34 -0
  13. package/dist/generated/models/AddContactsToCampaignRequest.js +53 -0
  14. package/dist/generated/models/AddContactsToCampaignRequestContactsInner.d.ts +46 -0
  15. package/dist/generated/models/AddContactsToCampaignRequestContactsInner.js +61 -0
  16. package/dist/generated/models/AddContactsToCampaignRequestContactsInnerMetadata.d.ts +39 -0
  17. package/dist/generated/models/AddContactsToCampaignRequestContactsInnerMetadata.js +56 -0
  18. package/dist/generated/models/CreateAssistantRequest.d.ts +123 -0
  19. package/dist/generated/models/CreateAssistantRequest.js +112 -0
  20. package/dist/generated/models/CreateCampaignDupRequest.d.ts +93 -0
  21. package/dist/generated/models/CreateCampaignDupRequest.js +92 -0
  22. package/dist/generated/models/CreateCampaignRequest.d.ts +93 -0
  23. package/dist/generated/models/CreateCampaignRequest.js +92 -0
  24. package/dist/generated/models/CreateKnowledgeBaseRequest.d.ts +45 -0
  25. package/dist/generated/models/CreateKnowledgeBaseRequest.js +60 -0
  26. package/dist/generated/models/CreateTranscriptRecordRequest.d.ts +51 -0
  27. package/dist/generated/models/CreateTranscriptRecordRequest.js +64 -0
  28. package/dist/generated/models/CreateUserTrunkRequest.d.ts +57 -0
  29. package/dist/generated/models/CreateUserTrunkRequest.js +68 -0
  30. package/dist/generated/models/CreateWebhookEndpointRequest.d.ts +45 -0
  31. package/dist/generated/models/CreateWebhookEndpointRequest.js +60 -0
  32. package/dist/generated/models/HandleCallTerminationRequest.d.ts +70 -0
  33. package/dist/generated/models/HandleCallTerminationRequest.js +77 -0
  34. package/dist/generated/models/HandleCallTerminationRequestMetadata.d.ts +39 -0
  35. package/dist/generated/models/HandleCallTerminationRequestMetadata.js +56 -0
  36. package/dist/generated/models/SubmitAnalyticsDataRequest.d.ts +70 -0
  37. package/dist/generated/models/SubmitAnalyticsDataRequest.js +77 -0
  38. package/dist/generated/models/SubmitAnalyticsDataRequestAnalytics.d.ts +63 -0
  39. package/dist/generated/models/SubmitAnalyticsDataRequestAnalytics.js +72 -0
  40. package/dist/generated/models/UpdateAssistantRequest.d.ts +39 -0
  41. package/dist/generated/models/UpdateAssistantRequest.js +56 -0
  42. package/dist/generated/models/UpdateAssistantSpeakingAccentRequest.d.ts +33 -0
  43. package/dist/generated/models/UpdateAssistantSpeakingAccentRequest.js +52 -0
  44. package/dist/generated/models/UpdateCampaignDupRequest.d.ts +39 -0
  45. package/dist/generated/models/UpdateCampaignDupRequest.js +56 -0
  46. package/dist/generated/models/UpdateCampaignRequest.d.ts +51 -0
  47. package/dist/generated/models/UpdateCampaignRequest.js +64 -0
  48. package/dist/generated/models/UpdateUserTrunkRequest.d.ts +45 -0
  49. package/dist/generated/models/UpdateUserTrunkRequest.js +60 -0
  50. package/dist/generated/models/UpdateWebhookEndpointRequest.d.ts +51 -0
  51. package/dist/generated/models/UpdateWebhookEndpointRequest.js +64 -0
  52. package/dist/generated/models/index.d.ts +20 -0
  53. package/dist/generated/models/index.js +38 -0
  54. package/dist/generated/runtime.d.ts +184 -0
  55. package/dist/generated/runtime.js +338 -0
  56. package/dist/src/client.d.ts +231 -0
  57. package/dist/src/client.js +356 -0
  58. package/dist/src/errors.d.ts +11 -0
  59. package/dist/src/errors.js +26 -0
  60. package/dist/src/index.d.ts +5 -0
  61. package/dist/src/index.js +28 -0
  62. package/dist/src/operation-manifest.json +386 -0
  63. package/dist/src/operations.d.ts +4 -0
  64. package/dist/src/operations.js +16 -0
  65. package/dist/src/types.d.ts +14 -0
  66. package/dist/src/types.js +2 -0
  67. package/package.json +38 -0
@@ -0,0 +1,231 @@
1
+ import { CampaignServiceApiApi, ControlPlaneApi, PostgresqlDbRoutesApi } from '../generated/apis';
2
+ import type { MonadeClientConfig } from './types';
3
+ type Runner = <T>(fn: () => Promise<T>) => Promise<T>;
4
+ declare class CampaignsService {
5
+ private readonly api;
6
+ private readonly run;
7
+ constructor(api: CampaignServiceApiApi, run: Runner);
8
+ list(status?: string): Promise<{
9
+ [key: string]: any;
10
+ }>;
11
+ listForUser(userUid: string): Promise<{
12
+ [key: string]: any;
13
+ }>;
14
+ get(campaignId: string): Promise<{
15
+ [key: string]: any;
16
+ }>;
17
+ create(data: Record<string, unknown>): Promise<{
18
+ [key: string]: any;
19
+ }>;
20
+ update(campaignId: string, data: Record<string, unknown>, userUid?: string): Promise<{
21
+ [key: string]: any;
22
+ }>;
23
+ delete(campaignId: string, userUid?: string): Promise<{
24
+ [key: string]: any;
25
+ }>;
26
+ start(campaignId: string, userUid?: string): Promise<{
27
+ [key: string]: any;
28
+ }>;
29
+ pause(campaignId: string, userUid?: string): Promise<{
30
+ [key: string]: any;
31
+ }>;
32
+ resume(campaignId: string, userUid?: string): Promise<{
33
+ [key: string]: any;
34
+ }>;
35
+ stop(campaignId: string, userUid?: string): Promise<{
36
+ [key: string]: any;
37
+ }>;
38
+ addContacts(campaignId: string, contactsPayload: Record<string, unknown>, userUid?: string): Promise<{
39
+ [key: string]: any;
40
+ }>;
41
+ listContacts(campaignId: string, userUid?: string, skip?: number, limit?: number): Promise<{
42
+ [key: string]: any;
43
+ }>;
44
+ clearContacts(campaignId: string, userUid?: string): Promise<{
45
+ [key: string]: any;
46
+ }>;
47
+ getContact(campaignId: string, contactId: string, userUid?: string): Promise<{
48
+ [key: string]: any;
49
+ }>;
50
+ analytics(campaignId: string, userUid?: string): Promise<{
51
+ [key: string]: any;
52
+ }>;
53
+ raw(): CampaignServiceApiApi;
54
+ }
55
+ declare class AssistantsService {
56
+ private readonly api;
57
+ private readonly run;
58
+ constructor(api: PostgresqlDbRoutesApi, run: Runner);
59
+ list(): Promise<{
60
+ [key: string]: any;
61
+ }>;
62
+ listByUser(userUid: string): Promise<{
63
+ [key: string]: any;
64
+ }>;
65
+ listByUserViaUserRoute(userUid: string): Promise<{
66
+ [key: string]: any;
67
+ }>;
68
+ getById(assistantId: string): Promise<{
69
+ [key: string]: any;
70
+ }>;
71
+ getByPhone(phoneNumber: string): Promise<{
72
+ [key: string]: any;
73
+ }>;
74
+ create(data: Record<string, unknown>): Promise<{
75
+ [key: string]: any;
76
+ }>;
77
+ update(assistantId: string, data: Record<string, unknown>): Promise<{
78
+ [key: string]: any;
79
+ }>;
80
+ updateAccent(assistantId: string, data: Record<string, unknown>): Promise<{
81
+ [key: string]: any;
82
+ }>;
83
+ delete(assistantId: string): Promise<{
84
+ [key: string]: any;
85
+ }>;
86
+ raw(): PostgresqlDbRoutesApi;
87
+ }
88
+ declare class KnowledgeBasesService {
89
+ private readonly api;
90
+ private readonly run;
91
+ constructor(api: PostgresqlDbRoutesApi, run: Runner);
92
+ list(): Promise<{
93
+ [key: string]: any;
94
+ }>;
95
+ listByUser(userUid: string): Promise<{
96
+ [key: string]: any;
97
+ }>;
98
+ getById(kbId: string): Promise<{
99
+ [key: string]: any;
100
+ }>;
101
+ create(data: Record<string, unknown>): Promise<{
102
+ [key: string]: any;
103
+ }>;
104
+ delete(kbId: string): Promise<{
105
+ [key: string]: any;
106
+ }>;
107
+ raw(): PostgresqlDbRoutesApi;
108
+ }
109
+ declare class AnalyticsService {
110
+ private readonly dbApi;
111
+ private readonly campaignApi;
112
+ private readonly run;
113
+ constructor(dbApi: PostgresqlDbRoutesApi, campaignApi: CampaignServiceApiApi, run: Runner);
114
+ submit(data: Record<string, unknown>): Promise<{
115
+ [key: string]: any;
116
+ }>;
117
+ getByCallId(callId: string): Promise<{
118
+ [key: string]: any;
119
+ }>;
120
+ getUserAnalytics(userUid?: string): Promise<{
121
+ [key: string]: any;
122
+ }>;
123
+ getUserAnalyticsByUserId(userUid: string): Promise<{
124
+ [key: string]: any;
125
+ }>;
126
+ getUserStats(userUid: string): Promise<{
127
+ [key: string]: any;
128
+ }>;
129
+ getUserCampaignAnalytics(userUid: string, campaignId: string): Promise<{
130
+ [key: string]: any;
131
+ }>;
132
+ getCampaignAnalytics(campaignId: string, userUid?: string): Promise<{
133
+ [key: string]: any;
134
+ }>;
135
+ getCampaignStats(campaignId: string, userUid?: string): Promise<{
136
+ [key: string]: any;
137
+ }>;
138
+ getCallRecording(callId: string): Promise<{
139
+ [key: string]: any;
140
+ }>;
141
+ createTranscript(data: Record<string, unknown>): Promise<{
142
+ [key: string]: any;
143
+ }>;
144
+ listTranscripts(userUid: string): Promise<{
145
+ [key: string]: any;
146
+ }>;
147
+ raw(): PostgresqlDbRoutesApi;
148
+ }
149
+ declare class WebhooksService {
150
+ private readonly api;
151
+ private readonly run;
152
+ constructor(api: PostgresqlDbRoutesApi, run: Runner);
153
+ create(userUid: string, data: Record<string, unknown>): Promise<{
154
+ [key: string]: any;
155
+ }>;
156
+ list(userUid: string): Promise<{
157
+ [key: string]: any;
158
+ }>;
159
+ get(userUid: string, webhookId: string): Promise<{
160
+ [key: string]: any;
161
+ }>;
162
+ update(userUid: string, webhookId: string, data: Record<string, unknown>): Promise<{
163
+ [key: string]: any;
164
+ }>;
165
+ delete(userUid: string, webhookId: string): Promise<{
166
+ [key: string]: any;
167
+ }>;
168
+ supportedEvents(): Promise<{
169
+ [key: string]: any;
170
+ }>;
171
+ lookup(userUid?: string, eventType?: string): Promise<{
172
+ [key: string]: any;
173
+ }>;
174
+ raw(): PostgresqlDbRoutesApi;
175
+ }
176
+ declare class TrunksService {
177
+ private readonly api;
178
+ private readonly run;
179
+ constructor(api: PostgresqlDbRoutesApi, run: Runner);
180
+ list(userUid: string): Promise<{
181
+ [key: string]: any;
182
+ }>;
183
+ get(userUid: string, trunkId: string): Promise<{
184
+ [key: string]: any;
185
+ }>;
186
+ create(userUid: string, data: Record<string, unknown>): Promise<{
187
+ [key: string]: any;
188
+ }>;
189
+ update(userUid: string, trunkId: string, data: Record<string, unknown>): Promise<{
190
+ [key: string]: any;
191
+ }>;
192
+ delete(userUid: string, trunkId: string): Promise<{
193
+ [key: string]: any;
194
+ }>;
195
+ raw(): PostgresqlDbRoutesApi;
196
+ }
197
+ declare class WalletService {
198
+ private readonly api;
199
+ private readonly run;
200
+ constructor(api: PostgresqlDbRoutesApi, run: Runner);
201
+ getBalance(userUid: string): Promise<{
202
+ [key: string]: any;
203
+ }>;
204
+ raw(): PostgresqlDbRoutesApi;
205
+ }
206
+ declare class OutboundCallsService {
207
+ private readonly api;
208
+ private readonly run;
209
+ constructor(api: ControlPlaneApi, run: Runner);
210
+ create(phoneNumber: string, body: Record<string, unknown>): Promise<{
211
+ [key: string]: any;
212
+ }>;
213
+ raw(): ControlPlaneApi;
214
+ }
215
+ export declare class MonadeClient {
216
+ readonly campaigns: CampaignsService;
217
+ readonly assistants: AssistantsService;
218
+ readonly knowledgeBases: KnowledgeBasesService;
219
+ readonly analytics: AnalyticsService;
220
+ readonly webhooks: WebhooksService;
221
+ readonly trunks: TrunksService;
222
+ readonly wallet: WalletService;
223
+ readonly outboundCalls: OutboundCallsService;
224
+ readonly generated: {
225
+ campaignsApi: CampaignServiceApiApi;
226
+ dbApi: PostgresqlDbRoutesApi;
227
+ controlPlaneApi: ControlPlaneApi;
228
+ };
229
+ constructor(config?: MonadeClientConfig);
230
+ }
231
+ export {};
@@ -0,0 +1,356 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MonadeClient = void 0;
4
+ const runtime_1 = require("../generated/runtime");
5
+ const apis_1 = require("../generated/apis");
6
+ const errors_1 = require("./errors");
7
+ const DEFAULT_BASE_URL = 'http://35.200.254.189';
8
+ const DEFAULT_TIMEOUT_MS = 30000;
9
+ function createFetchWithTimeout(baseFetch, timeoutMs) {
10
+ return async (input, init) => {
11
+ const controller = new AbortController();
12
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
13
+ try {
14
+ return await baseFetch(input, {
15
+ ...init,
16
+ signal: init?.signal ?? controller.signal,
17
+ });
18
+ }
19
+ finally {
20
+ clearTimeout(timeout);
21
+ }
22
+ };
23
+ }
24
+ async function parseErrorPayload(response) {
25
+ const contentType = response.headers.get('content-type') || '';
26
+ if (contentType.includes('application/json')) {
27
+ const json = await response.clone().json().catch(() => undefined);
28
+ const message = (json && (json.detail || json.message || json.error)) || response.statusText || 'Request failed';
29
+ return { message, payload: json };
30
+ }
31
+ const text = await response.clone().text().catch(() => '');
32
+ return { message: text || response.statusText || 'Request failed', payload: text || undefined };
33
+ }
34
+ async function mapSdkError(error) {
35
+ if (error instanceof runtime_1.ResponseError) {
36
+ const status = error.response.status;
37
+ const { message, payload } = await parseErrorPayload(error.response);
38
+ if (status === 401 || status === 403) {
39
+ throw new errors_1.AuthError(message, status, payload);
40
+ }
41
+ if (status === 400 || status === 422) {
42
+ throw new errors_1.ValidationError(message, status, payload);
43
+ }
44
+ throw new errors_1.ApiError(message, status, payload);
45
+ }
46
+ if (error instanceof runtime_1.FetchError) {
47
+ throw new errors_1.ApiError(error.message || 'Network request failed');
48
+ }
49
+ if (error instanceof Error) {
50
+ throw new errors_1.ApiError(error.message);
51
+ }
52
+ throw new errors_1.ApiError('Unknown SDK error');
53
+ }
54
+ class CampaignsService {
55
+ constructor(api, run) {
56
+ this.api = api;
57
+ this.run = run;
58
+ }
59
+ list(status) {
60
+ return this.run(() => this.api.listCampaigns(status ? { status } : {}));
61
+ }
62
+ listForUser(userUid) {
63
+ return this.run(() => this.api.getAllCampaignsForUser({ userUid }));
64
+ }
65
+ get(campaignId) {
66
+ return this.run(() => this.api.getCampaignDetails({ campaignId }));
67
+ }
68
+ create(data) {
69
+ return this.run(() => this.api.createCampaign({ createCampaignRequest: data }));
70
+ }
71
+ update(campaignId, data, userUid) {
72
+ return this.run(() => this.api.updateCampaign({ campaignId, updateCampaignRequest: data, userUid }));
73
+ }
74
+ delete(campaignId, userUid) {
75
+ return this.run(() => this.api.deleteCampaign({ campaignId, userUid }));
76
+ }
77
+ start(campaignId, userUid) {
78
+ return this.run(() => this.api.startCampaign({ campaignId, userUid }));
79
+ }
80
+ pause(campaignId, userUid) {
81
+ return this.run(() => this.api.pauseCampaign({ campaignId, userUid }));
82
+ }
83
+ resume(campaignId, userUid) {
84
+ return this.run(() => this.api.resumeCampaign({ campaignId, userUid }));
85
+ }
86
+ stop(campaignId, userUid) {
87
+ return this.run(() => this.api.stopCampaign({ campaignId, userUid }));
88
+ }
89
+ addContacts(campaignId, contactsPayload, userUid) {
90
+ return this.run(() => this.api.addContactsToCampaign({
91
+ campaignId,
92
+ addContactsToCampaignRequest: contactsPayload,
93
+ userUid,
94
+ }));
95
+ }
96
+ listContacts(campaignId, userUid, skip, limit) {
97
+ return this.run(() => this.api.listCampaignContacts({
98
+ campaignId,
99
+ userUid,
100
+ skip: skip?.toString(),
101
+ limit: limit?.toString(),
102
+ }));
103
+ }
104
+ clearContacts(campaignId, userUid) {
105
+ return this.run(() => this.api.clearCampaignContacts({ campaignId, userUid }));
106
+ }
107
+ getContact(campaignId, contactId, userUid) {
108
+ return this.run(() => this.api.getContactDetails({ campaignId, contactId, userUid }));
109
+ }
110
+ analytics(campaignId, userUid) {
111
+ return this.run(() => this.api.getCampaignAnalytics({ campaignId, userUid }));
112
+ }
113
+ raw() {
114
+ return this.api;
115
+ }
116
+ }
117
+ class AssistantsService {
118
+ constructor(api, run) {
119
+ this.api = api;
120
+ this.run = run;
121
+ }
122
+ list() {
123
+ return this.run(() => this.api.getAllAssistants());
124
+ }
125
+ listByUser(userUid) {
126
+ return this.run(() => this.api.getAssistantsByUserId({ userUid }));
127
+ }
128
+ listByUserViaUserRoute(userUid) {
129
+ return this.run(() => this.api.getUserSAssistants({ userUid }));
130
+ }
131
+ getById(assistantId) {
132
+ return this.run(() => this.api.getAssistantById({ assistantId }));
133
+ }
134
+ getByPhone(phoneNumber) {
135
+ return this.run(() => this.api.getAssistantByPhoneNumber({ phoneNumber }));
136
+ }
137
+ create(data) {
138
+ return this.run(() => this.api.createAssistant({ createAssistantRequest: data }));
139
+ }
140
+ update(assistantId, data) {
141
+ return this.run(() => this.api.updateAssistant({ assistantId, updateAssistantRequest: data }));
142
+ }
143
+ updateAccent(assistantId, data) {
144
+ return this.run(() => this.api.updateAssistantSpeakingAccent({
145
+ assistantId,
146
+ updateAssistantSpeakingAccentRequest: data,
147
+ }));
148
+ }
149
+ delete(assistantId) {
150
+ return this.run(() => this.api.deleteAssistant({ assistantId }));
151
+ }
152
+ raw() {
153
+ return this.api;
154
+ }
155
+ }
156
+ class KnowledgeBasesService {
157
+ constructor(api, run) {
158
+ this.api = api;
159
+ this.run = run;
160
+ }
161
+ list() {
162
+ return this.run(() => this.api.getAllKnowledgeBases());
163
+ }
164
+ listByUser(userUid) {
165
+ return this.run(() => this.api.getUserSKnowledgeBases({ userUid }));
166
+ }
167
+ getById(kbId) {
168
+ return this.run(() => this.api.getKnowledgeBaseById({ kbId }));
169
+ }
170
+ create(data) {
171
+ return this.run(() => this.api.createKnowledgeBase({ createKnowledgeBaseRequest: data }));
172
+ }
173
+ delete(kbId) {
174
+ return this.run(() => this.api.deleteKnowledgeBase({ kbId }));
175
+ }
176
+ raw() {
177
+ return this.api;
178
+ }
179
+ }
180
+ class AnalyticsService {
181
+ constructor(dbApi, campaignApi, run) {
182
+ this.dbApi = dbApi;
183
+ this.campaignApi = campaignApi;
184
+ this.run = run;
185
+ }
186
+ submit(data) {
187
+ return this.run(() => this.dbApi.submitAnalyticsData({ submitAnalyticsDataRequest: data }));
188
+ }
189
+ getByCallId(callId) {
190
+ return this.run(() => this.dbApi.getAnalyticsByCallId({ callId }));
191
+ }
192
+ getUserAnalytics(userUid) {
193
+ return this.run(() => this.dbApi.getUserAnalytics(userUid ? { userUid } : {}));
194
+ }
195
+ getUserAnalyticsByUserId(userUid) {
196
+ return this.run(() => this.dbApi.getUserAnalyticsByUserId({ userUid }));
197
+ }
198
+ getUserStats(userUid) {
199
+ return this.run(() => this.dbApi.getUserAnalyticsStatistics({ userUid }));
200
+ }
201
+ getUserCampaignAnalytics(userUid, campaignId) {
202
+ return this.run(() => this.dbApi.getUserCampaignAnalytics({ userUid, campaignId }));
203
+ }
204
+ getCampaignAnalytics(campaignId, userUid) {
205
+ return this.run(() => this.campaignApi.getCampaignAnalytics({ campaignId, userUid }));
206
+ }
207
+ getCampaignStats(campaignId, userUid) {
208
+ return this.run(() => this.dbApi.getCampaignStatisticsDup({ campaignId, userUid }));
209
+ }
210
+ getCallRecording(callId) {
211
+ return this.run(() => this.dbApi.getCallRecording({ callId }));
212
+ }
213
+ createTranscript(data) {
214
+ return this.run(() => this.dbApi.createTranscriptRecord({ createTranscriptRecordRequest: data }));
215
+ }
216
+ listTranscripts(userUid) {
217
+ return this.run(() => this.dbApi.getUserSTranscripts({ userUid }));
218
+ }
219
+ raw() {
220
+ return this.dbApi;
221
+ }
222
+ }
223
+ class WebhooksService {
224
+ constructor(api, run) {
225
+ this.api = api;
226
+ this.run = run;
227
+ }
228
+ create(userUid, data) {
229
+ return this.run(() => this.api.createWebhookEndpoint({
230
+ userUid,
231
+ createWebhookEndpointRequest: data,
232
+ }));
233
+ }
234
+ list(userUid) {
235
+ return this.run(() => this.api.listUserWebhookEndpoints({ userUid }));
236
+ }
237
+ get(userUid, webhookId) {
238
+ return this.run(() => this.api.getWebhookEndpointById({ userUid, webhookId }));
239
+ }
240
+ update(userUid, webhookId, data) {
241
+ return this.run(() => this.api.updateWebhookEndpoint({
242
+ userUid,
243
+ webhookId,
244
+ updateWebhookEndpointRequest: data,
245
+ }));
246
+ }
247
+ delete(userUid, webhookId) {
248
+ return this.run(() => this.api.deleteWebhookEndpoint({ userUid, webhookId }));
249
+ }
250
+ supportedEvents() {
251
+ return this.run(() => this.api.getSupportedEventTypes());
252
+ }
253
+ lookup(userUid, eventType) {
254
+ return this.run(() => this.api.lookupActiveEndpointsInternal({ userUid, eventType }));
255
+ }
256
+ raw() {
257
+ return this.api;
258
+ }
259
+ }
260
+ class TrunksService {
261
+ constructor(api, run) {
262
+ this.api = api;
263
+ this.run = run;
264
+ }
265
+ list(userUid) {
266
+ return this.run(() => this.api.listUserTrunks({ userUid }));
267
+ }
268
+ get(userUid, trunkId) {
269
+ return this.run(() => this.api.getSpecificUserTrunk({ userUid, trunkId }));
270
+ }
271
+ create(userUid, data) {
272
+ return this.run(() => this.api.createUserTrunk({ userUid, createUserTrunkRequest: data }));
273
+ }
274
+ update(userUid, trunkId, data) {
275
+ return this.run(() => this.api.updateUserTrunk({
276
+ userUid,
277
+ trunkId,
278
+ updateUserTrunkRequest: data,
279
+ }));
280
+ }
281
+ delete(userUid, trunkId) {
282
+ return this.run(() => this.api.deleteTrunkGloballyWarning({ userUid, trunkId }));
283
+ }
284
+ raw() {
285
+ return this.api;
286
+ }
287
+ }
288
+ class WalletService {
289
+ constructor(api, run) {
290
+ this.api = api;
291
+ this.run = run;
292
+ }
293
+ getBalance(userUid) {
294
+ return this.run(() => this.api.getUserCredits({ userUid }));
295
+ }
296
+ raw() {
297
+ return this.api;
298
+ }
299
+ }
300
+ class OutboundCallsService {
301
+ constructor(api, run) {
302
+ this.api = api;
303
+ this.run = run;
304
+ }
305
+ create(phoneNumber, body) {
306
+ return this.run(() => this.api.postOutboundCallByPhoneNumber({ phoneNumber, requestBody: body }));
307
+ }
308
+ raw() {
309
+ return this.api;
310
+ }
311
+ }
312
+ class MonadeClient {
313
+ constructor(config = {}) {
314
+ const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
315
+ const fetchApi = createFetchWithTimeout((config.fetch ?? fetch), timeoutMs);
316
+ const headers = {
317
+ ...(config.headers ?? {}),
318
+ };
319
+ if (config.apiKey) {
320
+ headers.Authorization = headers.Authorization ?? `Bearer ${config.apiKey}`;
321
+ headers['X-API-Key'] = headers['X-API-Key'] ?? config.apiKey;
322
+ }
323
+ const runtimeConfig = new runtime_1.Configuration({
324
+ basePath: config.baseUrl ?? DEFAULT_BASE_URL,
325
+ headers,
326
+ fetchApi,
327
+ accessToken: config.apiKey,
328
+ apiKey: config.apiKey,
329
+ });
330
+ const campaignsApi = new apis_1.CampaignServiceApiApi(runtimeConfig);
331
+ const dbApi = new apis_1.PostgresqlDbRoutesApi(runtimeConfig);
332
+ const controlPlaneApi = new apis_1.ControlPlaneApi(runtimeConfig);
333
+ const run = async (fn) => {
334
+ try {
335
+ return await fn();
336
+ }
337
+ catch (error) {
338
+ return await mapSdkError(error);
339
+ }
340
+ };
341
+ this.campaigns = new CampaignsService(campaignsApi, run);
342
+ this.assistants = new AssistantsService(dbApi, run);
343
+ this.knowledgeBases = new KnowledgeBasesService(dbApi, run);
344
+ this.analytics = new AnalyticsService(dbApi, campaignsApi, run);
345
+ this.webhooks = new WebhooksService(dbApi, run);
346
+ this.trunks = new TrunksService(dbApi, run);
347
+ this.wallet = new WalletService(dbApi, run);
348
+ this.outboundCalls = new OutboundCallsService(controlPlaneApi, run);
349
+ this.generated = {
350
+ campaignsApi,
351
+ dbApi,
352
+ controlPlaneApi,
353
+ };
354
+ }
355
+ }
356
+ exports.MonadeClient = MonadeClient;
@@ -0,0 +1,11 @@
1
+ export declare class ApiError extends Error {
2
+ readonly status?: number;
3
+ readonly data?: unknown;
4
+ constructor(message: string, status?: number, data?: unknown);
5
+ }
6
+ export declare class AuthError extends ApiError {
7
+ constructor(message?: string, status?: number, data?: unknown);
8
+ }
9
+ export declare class ValidationError extends ApiError {
10
+ constructor(message?: string, status?: number, data?: unknown);
11
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationError = exports.AuthError = exports.ApiError = void 0;
4
+ class ApiError extends Error {
5
+ constructor(message, status, data) {
6
+ super(message);
7
+ this.name = 'ApiError';
8
+ this.status = status;
9
+ this.data = data;
10
+ }
11
+ }
12
+ exports.ApiError = ApiError;
13
+ class AuthError extends ApiError {
14
+ constructor(message = 'Authentication failed', status = 401, data) {
15
+ super(message, status, data);
16
+ this.name = 'AuthError';
17
+ }
18
+ }
19
+ exports.AuthError = AuthError;
20
+ class ValidationError extends ApiError {
21
+ constructor(message = 'Validation failed', status = 422, data) {
22
+ super(message, status, data);
23
+ this.name = 'ValidationError';
24
+ }
25
+ }
26
+ exports.ValidationError = ValidationError;
@@ -0,0 +1,5 @@
1
+ export { MonadeClient } from './client';
2
+ export type { MonadeClientConfig, OperationManifestEntry } from './types';
3
+ export { ApiError, AuthError, ValidationError } from './errors';
4
+ export { supportedOperations, supportedOperationIds, operationsByGroup } from './operations';
5
+ export * from '../generated/models';
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.operationsByGroup = exports.supportedOperationIds = exports.supportedOperations = exports.ValidationError = exports.AuthError = exports.ApiError = exports.MonadeClient = void 0;
18
+ var client_1 = require("./client");
19
+ Object.defineProperty(exports, "MonadeClient", { enumerable: true, get: function () { return client_1.MonadeClient; } });
20
+ var errors_1 = require("./errors");
21
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return errors_1.ApiError; } });
22
+ Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return errors_1.AuthError; } });
23
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
24
+ var operations_1 = require("./operations");
25
+ Object.defineProperty(exports, "supportedOperations", { enumerable: true, get: function () { return operations_1.supportedOperations; } });
26
+ Object.defineProperty(exports, "supportedOperationIds", { enumerable: true, get: function () { return operations_1.supportedOperationIds; } });
27
+ Object.defineProperty(exports, "operationsByGroup", { enumerable: true, get: function () { return operations_1.operationsByGroup; } });
28
+ __exportStar(require("../generated/models"), exports);