@heymantle/core-api-client 0.1.27 → 0.2.1
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/index.d.mts +24564 -5256
- package/dist/index.d.ts +24564 -5256
- package/dist/index.js +786 -2795
- package/dist/index.mjs +769 -2794
- package/package.json +7 -1
package/dist/index.mjs
CHANGED
|
@@ -1,133 +1,5 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
constructor() {
|
|
4
|
-
this.middlewares = [];
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Register a middleware function
|
|
8
|
-
*
|
|
9
|
-
* @param middleware - The middleware function to register
|
|
10
|
-
* @param options - Optional configuration
|
|
11
|
-
* @returns this for chaining
|
|
12
|
-
*/
|
|
13
|
-
use(middleware, options = {}) {
|
|
14
|
-
const registered = {
|
|
15
|
-
fn: middleware,
|
|
16
|
-
name: options.name ?? `middleware_${Date.now()}_${Math.random().toString(36).slice(2)}`,
|
|
17
|
-
priority: options.priority ?? 100
|
|
18
|
-
};
|
|
19
|
-
this.middlewares.push(registered);
|
|
20
|
-
this.middlewares.sort((a, b) => a.priority - b.priority);
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Remove a middleware by name
|
|
25
|
-
*
|
|
26
|
-
* @param name - The name of the middleware to remove
|
|
27
|
-
* @returns true if removed, false if not found
|
|
28
|
-
*/
|
|
29
|
-
remove(name) {
|
|
30
|
-
const index = this.middlewares.findIndex((m) => m.name === name);
|
|
31
|
-
if (index !== -1) {
|
|
32
|
-
this.middlewares.splice(index, 1);
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get all registered middleware names
|
|
39
|
-
*/
|
|
40
|
-
list() {
|
|
41
|
-
return this.middlewares.map((m) => m.name);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Check if any middleware is registered
|
|
45
|
-
*/
|
|
46
|
-
hasMiddleware() {
|
|
47
|
-
return this.middlewares.length > 0;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Execute the middleware chain with retry support
|
|
51
|
-
*
|
|
52
|
-
* @param ctx - The middleware context
|
|
53
|
-
* @param coreHandler - The core request handler to call at the end of the chain
|
|
54
|
-
* @returns The response from the core handler
|
|
55
|
-
*/
|
|
56
|
-
async execute(ctx, coreHandler) {
|
|
57
|
-
const maxAttempts = ctx.maxRetries + 1;
|
|
58
|
-
let attempts = 0;
|
|
59
|
-
while (attempts < maxAttempts) {
|
|
60
|
-
ctx.retryCount = attempts;
|
|
61
|
-
ctx.retry = false;
|
|
62
|
-
ctx.error = void 0;
|
|
63
|
-
try {
|
|
64
|
-
await this.runChain(ctx, coreHandler);
|
|
65
|
-
if (!ctx.retry) {
|
|
66
|
-
return ctx.response;
|
|
67
|
-
}
|
|
68
|
-
attempts++;
|
|
69
|
-
} catch (error) {
|
|
70
|
-
if (!ctx.retry || attempts >= maxAttempts - 1) {
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
attempts++;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
throw ctx.error ?? new Error("Max retries exceeded");
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Run the middleware chain (onion model)
|
|
80
|
-
*/
|
|
81
|
-
async runChain(ctx, coreHandler) {
|
|
82
|
-
let index = -1;
|
|
83
|
-
const dispatch = async (i) => {
|
|
84
|
-
if (i <= index) {
|
|
85
|
-
throw new Error("next() called multiple times");
|
|
86
|
-
}
|
|
87
|
-
index = i;
|
|
88
|
-
if (i < this.middlewares.length) {
|
|
89
|
-
const middleware = this.middlewares[i];
|
|
90
|
-
await middleware.fn(ctx, () => dispatch(i + 1));
|
|
91
|
-
} else {
|
|
92
|
-
try {
|
|
93
|
-
ctx.response = await coreHandler();
|
|
94
|
-
} catch (error) {
|
|
95
|
-
ctx.error = error;
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
await dispatch(0);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/utils/sanitize.ts
|
|
105
|
-
function sanitizeObject(obj) {
|
|
106
|
-
if (!obj || typeof obj !== "object") {
|
|
107
|
-
return obj;
|
|
108
|
-
}
|
|
109
|
-
const sanitized = {};
|
|
110
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
111
|
-
if (value !== void 0) {
|
|
112
|
-
sanitized[key] = value;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return sanitized;
|
|
116
|
-
}
|
|
117
|
-
function toQueryString(params) {
|
|
118
|
-
const sanitized = sanitizeObject(params);
|
|
119
|
-
const searchParams = new URLSearchParams();
|
|
120
|
-
for (const [key, value] of Object.entries(sanitized)) {
|
|
121
|
-
if (Array.isArray(value)) {
|
|
122
|
-
if (value.length > 0) {
|
|
123
|
-
searchParams.append(key, value.map(String).join(","));
|
|
124
|
-
}
|
|
125
|
-
} else if (value !== null && value !== void 0) {
|
|
126
|
-
searchParams.append(key, String(value));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return searchParams.toString();
|
|
130
|
-
}
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import createClient from "openapi-fetch";
|
|
131
3
|
|
|
132
4
|
// src/utils/errors.ts
|
|
133
5
|
var MantleAPIError = class _MantleAPIError extends Error {
|
|
@@ -184,2712 +56,1012 @@ var BaseResource = class {
|
|
|
184
56
|
constructor(client) {
|
|
185
57
|
this.client = client;
|
|
186
58
|
}
|
|
187
|
-
get(
|
|
188
|
-
return this.client.
|
|
189
|
-
}
|
|
190
|
-
post(endpoint, data) {
|
|
191
|
-
return this.client.post(endpoint, data);
|
|
192
|
-
}
|
|
193
|
-
put(endpoint, data) {
|
|
194
|
-
return this.client.put(endpoint, data);
|
|
195
|
-
}
|
|
196
|
-
_delete(endpoint) {
|
|
197
|
-
return this.client.delete(endpoint);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
// src/resources/customers.ts
|
|
202
|
-
var CustomersResource = class extends BaseResource {
|
|
203
|
-
/**
|
|
204
|
-
* List customers with optional filters and pagination
|
|
205
|
-
*/
|
|
206
|
-
async list(params) {
|
|
207
|
-
const response = await this.get("/customers", params);
|
|
208
|
-
return {
|
|
209
|
-
customers: response.customers || [],
|
|
210
|
-
hasNextPage: response.hasNextPage || false,
|
|
211
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
212
|
-
total: response.total,
|
|
213
|
-
cursor: response.cursor
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Retrieve a single customer by ID
|
|
218
|
-
*/
|
|
219
|
-
async retrieve(customerId, params) {
|
|
220
|
-
return this.get(
|
|
221
|
-
`/customers/${customerId}`,
|
|
222
|
-
params
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Create a new customer
|
|
227
|
-
*/
|
|
228
|
-
async create(data) {
|
|
229
|
-
return this.post("/customers", data);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Update an existing customer
|
|
233
|
-
*/
|
|
234
|
-
async update(customerId, data) {
|
|
235
|
-
return this.put(
|
|
236
|
-
`/customers/${customerId}`,
|
|
237
|
-
data
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Add tags to a customer
|
|
242
|
-
*/
|
|
243
|
-
async addTags(customerId, tags) {
|
|
244
|
-
return this.post(
|
|
245
|
-
`/customers/${customerId}/addTags`,
|
|
246
|
-
{ tags }
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Remove tags from a customer
|
|
251
|
-
*/
|
|
252
|
-
async removeTags(customerId, tags) {
|
|
253
|
-
return this.post(
|
|
254
|
-
`/customers/${customerId}/removeTags`,
|
|
255
|
-
{ tags }
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Get customer activity timeline
|
|
260
|
-
*/
|
|
261
|
-
async getTimeline(customerId, params) {
|
|
262
|
-
const response = await this.get(
|
|
263
|
-
`/customers/${customerId}/timeline`,
|
|
264
|
-
{ limit: 25, ...params }
|
|
265
|
-
);
|
|
266
|
-
return {
|
|
267
|
-
events: response.events || [],
|
|
268
|
-
hasNextPage: response.hasNextPage || false,
|
|
269
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
270
|
-
cursor: response.cursor
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* List account owners for a customer
|
|
275
|
-
*/
|
|
276
|
-
async listAccountOwners(customerId) {
|
|
277
|
-
return this.get(
|
|
278
|
-
`/customers/${customerId}/account_owners`
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Add an account owner to a customer
|
|
283
|
-
*/
|
|
284
|
-
async addAccountOwner(customerId, data) {
|
|
285
|
-
return this.post(`/customers/${customerId}/account_owners`, data);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Remove an account owner from a customer
|
|
289
|
-
*/
|
|
290
|
-
async removeAccountOwner(customerId, ownerId) {
|
|
291
|
-
return this._delete(
|
|
292
|
-
`/customers/${customerId}/account_owners/${ownerId}`
|
|
293
|
-
);
|
|
59
|
+
get api() {
|
|
60
|
+
return this.client._api;
|
|
294
61
|
}
|
|
295
62
|
/**
|
|
296
|
-
*
|
|
63
|
+
* Access the API client without path type-checking.
|
|
64
|
+
* Used for endpoints not yet in the OpenAPI spec.
|
|
297
65
|
*/
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
params
|
|
302
|
-
);
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
get untypedApi() {
|
|
68
|
+
return this.client._api;
|
|
303
69
|
}
|
|
304
70
|
/**
|
|
305
|
-
*
|
|
71
|
+
* Unwraps an openapi-fetch response, throwing typed errors on failure.
|
|
306
72
|
*/
|
|
307
|
-
async
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
73
|
+
async unwrap(promise) {
|
|
74
|
+
const { data, error, response } = await promise;
|
|
75
|
+
if (error !== void 0) {
|
|
76
|
+
throw this.createError(response, error);
|
|
77
|
+
}
|
|
78
|
+
return data;
|
|
312
79
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
80
|
+
createError(response, error) {
|
|
81
|
+
const err = error;
|
|
82
|
+
const message = (typeof err?.error === "string" ? err.error : null) || `API request failed: ${response.status}`;
|
|
83
|
+
const details = typeof err?.details === "string" ? err.details : void 0;
|
|
84
|
+
switch (response.status) {
|
|
85
|
+
case 401:
|
|
86
|
+
return new MantleAuthenticationError(message);
|
|
87
|
+
case 403:
|
|
88
|
+
return new MantlePermissionError(message);
|
|
89
|
+
case 404:
|
|
90
|
+
return new MantleAPIError(message, 404, details);
|
|
91
|
+
case 422:
|
|
92
|
+
return new MantleValidationError(message, details);
|
|
93
|
+
case 429: {
|
|
94
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
95
|
+
return new MantleRateLimitError(
|
|
96
|
+
message,
|
|
97
|
+
retryAfter ? parseInt(retryAfter, 10) : void 0
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
default:
|
|
101
|
+
return new MantleAPIError(message, response.status, details);
|
|
102
|
+
}
|
|
320
103
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
data
|
|
328
|
-
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/resources/affiliate-commissions.ts
|
|
107
|
+
var AffiliateCommissionsResource = class extends BaseResource {
|
|
108
|
+
async list(params) {
|
|
109
|
+
return this.unwrap(this.api.GET("/affiliate_commissions", { params: { query: params } }));
|
|
329
110
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
*/
|
|
333
|
-
async deleteCustomField(fieldId) {
|
|
334
|
-
return this._delete(
|
|
335
|
-
`/customers/custom_fields/${fieldId}`
|
|
336
|
-
);
|
|
111
|
+
async get(commissionId) {
|
|
112
|
+
return this.unwrap(this.api.GET("/affiliate_commissions/{id}", { params: { path: { id: commissionId } } }));
|
|
337
113
|
}
|
|
338
114
|
};
|
|
339
115
|
|
|
340
|
-
// src/resources/
|
|
341
|
-
var
|
|
342
|
-
/**
|
|
343
|
-
* List contacts with optional filters and pagination
|
|
344
|
-
*/
|
|
116
|
+
// src/resources/affiliate-payouts.ts
|
|
117
|
+
var AffiliatePayoutsResource = class extends BaseResource {
|
|
345
118
|
async list(params) {
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
contacts: response.contacts || [],
|
|
349
|
-
hasNextPage: response.hasNextPage || false,
|
|
350
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
351
|
-
total: response.total,
|
|
352
|
-
cursor: response.cursor
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Retrieve a single contact by ID
|
|
357
|
-
*/
|
|
358
|
-
async retrieve(contactId) {
|
|
359
|
-
return this.get(`/contacts/${contactId}`);
|
|
119
|
+
return this.unwrap(this.api.GET("/affiliate_payouts", { params: { query: params } }));
|
|
360
120
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
* If a contact with the same email exists in the organization, it will be updated.
|
|
364
|
-
* Otherwise, a new contact will be created.
|
|
365
|
-
* @returns The contact and a boolean indicating if it was newly created
|
|
366
|
-
*/
|
|
367
|
-
async create(data) {
|
|
368
|
-
return this.post("/contacts", data);
|
|
121
|
+
async get(payoutId) {
|
|
122
|
+
return this.unwrap(this.api.GET("/affiliate_payouts/{id}", { params: { path: { id: payoutId } } }));
|
|
369
123
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// src/resources/affiliate-programs.ts
|
|
127
|
+
var AffiliateProgramsResource = class extends BaseResource {
|
|
128
|
+
async list(params) {
|
|
129
|
+
return this.unwrap(this.api.GET("/affiliate_programs", { params: { query: params } }));
|
|
375
130
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
*/
|
|
379
|
-
async del(contactId) {
|
|
380
|
-
return this._delete(`/contacts/${contactId}`);
|
|
131
|
+
async get(programId) {
|
|
132
|
+
return this.unwrap(this.api.GET("/affiliate_programs/{id}", { params: { path: { id: programId } } }));
|
|
381
133
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
{ tags }
|
|
389
|
-
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// src/resources/affiliate-referrals.ts
|
|
137
|
+
var AffiliateReferralsResource = class extends BaseResource {
|
|
138
|
+
async list(params) {
|
|
139
|
+
return this.unwrap(this.api.GET("/affiliate_referrals", { params: { query: params } }));
|
|
390
140
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
*/
|
|
394
|
-
async removeTags(contactId, tags) {
|
|
395
|
-
return this.post(
|
|
396
|
-
`/contacts/${contactId}/removeTags`,
|
|
397
|
-
{ tags }
|
|
398
|
-
);
|
|
141
|
+
async get(referralId) {
|
|
142
|
+
return this.unwrap(this.api.GET("/affiliate_referrals/{id}", { params: { path: { id: referralId } } }));
|
|
399
143
|
}
|
|
400
144
|
};
|
|
401
145
|
|
|
402
|
-
// src/resources/
|
|
403
|
-
var
|
|
404
|
-
/**
|
|
405
|
-
* List subscriptions with optional filters and pagination
|
|
406
|
-
*/
|
|
146
|
+
// src/resources/affiliates.ts
|
|
147
|
+
var AffiliatesResource = class extends BaseResource {
|
|
407
148
|
async list(params) {
|
|
408
|
-
|
|
409
|
-
"/subscriptions",
|
|
410
|
-
params
|
|
411
|
-
);
|
|
412
|
-
return {
|
|
413
|
-
subscriptions: response.subscriptions || [],
|
|
414
|
-
hasNextPage: response.hasNextPage || false,
|
|
415
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
416
|
-
total: response.total,
|
|
417
|
-
cursor: response.cursor
|
|
418
|
-
};
|
|
149
|
+
return this.unwrap(this.api.GET("/affiliates", { params: { query: params } }));
|
|
419
150
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
*/
|
|
423
|
-
async retrieve(subscriptionId) {
|
|
424
|
-
return this.get(
|
|
425
|
-
`/subscriptions/${subscriptionId}`
|
|
426
|
-
);
|
|
151
|
+
async get(affiliateId) {
|
|
152
|
+
return this.unwrap(this.api.GET("/affiliates/{id}", { params: { path: { id: affiliateId } } }));
|
|
427
153
|
}
|
|
428
154
|
};
|
|
429
155
|
|
|
430
|
-
// src/resources/
|
|
431
|
-
var
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
async
|
|
436
|
-
|
|
437
|
-
"/usage_events",
|
|
438
|
-
params
|
|
439
|
-
);
|
|
440
|
-
return {
|
|
441
|
-
usageEvents: response.usageEvents || response.events || [],
|
|
442
|
-
events: response.events,
|
|
443
|
-
hasNextPage: response.hasNextPage || false,
|
|
444
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
445
|
-
total: response.total,
|
|
446
|
-
cursor: response.cursor
|
|
447
|
-
};
|
|
156
|
+
// src/resources/ai-agent-runs.ts
|
|
157
|
+
var AiAgentRunsResource = class extends BaseResource {
|
|
158
|
+
async create(agentId, data) {
|
|
159
|
+
return this.unwrap(this.api.POST("/ai/agents/{agentId}/runs", { params: { path: { agentId } }, body: data }));
|
|
160
|
+
}
|
|
161
|
+
async get(agentId, runId) {
|
|
162
|
+
return this.unwrap(this.api.GET("/ai/agents/{agentId}/runs/{runId}", { params: { path: { agentId, runId } } }));
|
|
448
163
|
}
|
|
449
164
|
/**
|
|
450
|
-
* Create
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* // Single event
|
|
454
|
-
* await client.usageEvents.create({
|
|
455
|
-
* eventName: 'api_call',
|
|
456
|
-
* customerId: 'cust_123',
|
|
457
|
-
* appId: 'app_456',
|
|
458
|
-
* properties: { endpoint: '/users' },
|
|
459
|
-
* });
|
|
460
|
-
*
|
|
461
|
-
* @example
|
|
462
|
-
* // Multiple events
|
|
463
|
-
* await client.usageEvents.create({
|
|
464
|
-
* events: [
|
|
465
|
-
* { eventName: 'api_call', customerId: 'cust_123', appId: 'app_456' },
|
|
466
|
-
* { eventName: 'api_call', customerId: 'cust_789', appId: 'app_456' },
|
|
467
|
-
* ],
|
|
468
|
-
* });
|
|
165
|
+
* Create an agent run and poll until it reaches a terminal status.
|
|
469
166
|
*/
|
|
470
|
-
async
|
|
471
|
-
|
|
167
|
+
async createAndWait(agentId, data, options) {
|
|
168
|
+
const { timeout = 3e5, pollInterval = 2e3 } = options ?? {};
|
|
169
|
+
const result = await this.create(agentId, data);
|
|
170
|
+
const run = result.run;
|
|
171
|
+
if (!run?.id) throw new Error("Agent run ID not returned");
|
|
172
|
+
const start = Date.now();
|
|
173
|
+
while (Date.now() - start < timeout) {
|
|
174
|
+
const response = await this.get(agentId, run.id);
|
|
175
|
+
const agentRun = response.run;
|
|
176
|
+
if (agentRun.status === "completed" || agentRun.status === "error") return agentRun;
|
|
177
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
178
|
+
}
|
|
179
|
+
throw new Error(`Agent run timed out after ${timeout}ms`);
|
|
472
180
|
}
|
|
473
181
|
};
|
|
474
182
|
|
|
475
183
|
// src/resources/apps.ts
|
|
476
184
|
var AppsResource = class extends BaseResource {
|
|
477
|
-
/**
|
|
478
|
-
* List all apps
|
|
479
|
-
*/
|
|
480
185
|
async list(params) {
|
|
481
|
-
return this.
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Retrieve a single app by ID
|
|
485
|
-
*/
|
|
486
|
-
async retrieve(appId) {
|
|
487
|
-
return this.get(`/apps/${appId}`);
|
|
186
|
+
return this.unwrap(this.api.GET("/apps", { params: { query: params } }));
|
|
488
187
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
* List plans for an app
|
|
492
|
-
*/
|
|
493
|
-
async listPlans(appId, params) {
|
|
494
|
-
return this.get(`/apps/${appId}/plans`, params);
|
|
188
|
+
async analyze(appId, data) {
|
|
189
|
+
return this.unwrap(this.api.POST("/apps/{id}/analyze", { params: { path: { id: appId } }, body: data }));
|
|
495
190
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
*/
|
|
499
|
-
async retrievePlan(appId, planId) {
|
|
500
|
-
return this.get(`/apps/${appId}/plans/${planId}`);
|
|
191
|
+
async get(appId) {
|
|
192
|
+
return this.unwrap(this.api.GET("/apps/{id}", { params: { path: { id: appId } } }));
|
|
501
193
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
*/
|
|
505
|
-
async createPlan(appId, data) {
|
|
506
|
-
return this.post(`/apps/${appId}/plans`, data);
|
|
194
|
+
async getPlan(appId, planId) {
|
|
195
|
+
return this.unwrap(this.api.GET("/apps/{id}/plans/{planId}", { params: { path: { id: appId, planId } } }));
|
|
507
196
|
}
|
|
508
|
-
/**
|
|
509
|
-
* Update an existing plan
|
|
510
|
-
*/
|
|
511
197
|
async updatePlan(appId, planId, data) {
|
|
512
|
-
return this.
|
|
198
|
+
return this.unwrap(this.api.PUT("/apps/{id}/plans/{planId}", { params: { path: { id: appId, planId } }, body: data }));
|
|
513
199
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
*/
|
|
517
|
-
async archivePlan(appId, planId) {
|
|
518
|
-
return this.post(
|
|
519
|
-
`/apps/${appId}/plans/${planId}/archive`,
|
|
520
|
-
{}
|
|
521
|
-
);
|
|
200
|
+
async getAppEvent(appId, appEventId) {
|
|
201
|
+
return this.unwrap(this.api.GET("/apps/{id}/app_events/{appEventId}", { params: { path: { id: appId, appEventId } } }));
|
|
522
202
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
*/
|
|
526
|
-
async unarchivePlan(appId, planId) {
|
|
527
|
-
return this.post(
|
|
528
|
-
`/apps/${appId}/plans/${planId}/unarchive`,
|
|
529
|
-
{}
|
|
530
|
-
);
|
|
203
|
+
async listAppEvents(appId, params) {
|
|
204
|
+
return this.unwrap(this.api.GET("/apps/{id}/app_events", { params: { path: { id: appId }, query: params } }));
|
|
531
205
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
* List features for an app
|
|
535
|
-
*/
|
|
536
|
-
async listFeatures(appId) {
|
|
537
|
-
return this.get(`/apps/${appId}/plans/features`);
|
|
206
|
+
async createAppEvent(appId, data) {
|
|
207
|
+
return this.unwrap(this.api.POST("/apps/{id}/app_events", { params: { path: { id: appId } }, body: data }));
|
|
538
208
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
*/
|
|
542
|
-
async retrieveFeature(appId, featureId) {
|
|
543
|
-
return this.get(
|
|
544
|
-
`/apps/${appId}/plans/features/${featureId}`
|
|
545
|
-
);
|
|
209
|
+
async getChecklist(appId, checklistId) {
|
|
210
|
+
return this.unwrap(this.api.GET("/apps/{appId}/checklists/{checklistId}", { params: { path: { appId, checklistId } } }));
|
|
546
211
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
async
|
|
551
|
-
return this.
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
);
|
|
212
|
+
async updateChecklist(appId, checklistId, data) {
|
|
213
|
+
return this.unwrap(this.api.PUT("/apps/{appId}/checklists/{checklistId}", { params: { path: { appId, checklistId } }, body: data }));
|
|
214
|
+
}
|
|
215
|
+
async deleteChecklist(appId, checklistId) {
|
|
216
|
+
return this.unwrap(this.api.DELETE("/apps/{appId}/checklists/{checklistId}", { params: { path: { appId, checklistId } } }));
|
|
217
|
+
}
|
|
218
|
+
async listChecklists(appId) {
|
|
219
|
+
return this.unwrap(this.api.GET("/apps/{appId}/checklists", { params: { path: { appId } } }));
|
|
220
|
+
}
|
|
221
|
+
async createChecklist(appId, data) {
|
|
222
|
+
return this.unwrap(this.api.POST("/apps/{appId}/checklists", { params: { path: { appId } }, body: data }));
|
|
223
|
+
}
|
|
224
|
+
async archivePlan(appId, planId) {
|
|
225
|
+
return this.unwrap(this.api.PUT("/apps/{id}/plans/{planId}/archive", { params: { path: { id: appId, planId } } }));
|
|
226
|
+
}
|
|
227
|
+
async unarchivePlan(appId, planId) {
|
|
228
|
+
return this.unwrap(this.api.PUT("/apps/{id}/plans/{planId}/unarchive", { params: { path: { id: appId, planId } } }));
|
|
229
|
+
}
|
|
230
|
+
async getFeature(appId, featureId) {
|
|
231
|
+
return this.unwrap(this.api.GET("/apps/{appId}/plans/features/{featureId}", { params: { path: { appId, featureId } } }));
|
|
555
232
|
}
|
|
556
|
-
/**
|
|
557
|
-
* Update an existing feature
|
|
558
|
-
*/
|
|
559
233
|
async updateFeature(appId, featureId, data) {
|
|
560
|
-
return this.
|
|
561
|
-
`/apps/${appId}/plans/features/${featureId}`,
|
|
562
|
-
data
|
|
563
|
-
);
|
|
234
|
+
return this.unwrap(this.api.PUT("/apps/{appId}/plans/features/{featureId}", { params: { path: { appId, featureId } }, body: data }));
|
|
564
235
|
}
|
|
565
|
-
/**
|
|
566
|
-
* Delete a feature
|
|
567
|
-
*/
|
|
568
236
|
async deleteFeature(appId, featureId) {
|
|
569
|
-
return this.
|
|
570
|
-
`/apps/${appId}/plans/features/${featureId}`
|
|
571
|
-
);
|
|
572
|
-
}
|
|
573
|
-
// ========== Reviews ==========
|
|
574
|
-
/**
|
|
575
|
-
* List reviews for an app
|
|
576
|
-
*/
|
|
577
|
-
async listReviews(appId) {
|
|
578
|
-
return this.get(`/apps/${appId}/reviews`);
|
|
237
|
+
return this.unwrap(this.api.DELETE("/apps/{appId}/plans/features/{featureId}", { params: { path: { appId, featureId } } }));
|
|
579
238
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
*/
|
|
583
|
-
async retrieveReview(appId, reviewId) {
|
|
584
|
-
return this.get(`/apps/${appId}/reviews/${reviewId}`);
|
|
239
|
+
async listFeatures(appId) {
|
|
240
|
+
return this.unwrap(this.api.GET("/apps/{appId}/plans/features", { params: { path: { appId } } }));
|
|
585
241
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
*/
|
|
589
|
-
async createReview(appId, data) {
|
|
590
|
-
return this.post(`/apps/${appId}/reviews`, data);
|
|
242
|
+
async createFeature(appId, data) {
|
|
243
|
+
return this.unwrap(this.api.POST("/apps/{appId}/plans/features", { params: { path: { appId } }, body: data }));
|
|
591
244
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
*/
|
|
595
|
-
async updateReview(appId, reviewId, data) {
|
|
596
|
-
return this.put(
|
|
597
|
-
`/apps/${appId}/reviews/${reviewId}`,
|
|
598
|
-
data
|
|
599
|
-
);
|
|
245
|
+
async listPlans(appId, params) {
|
|
246
|
+
return this.unwrap(this.api.GET("/apps/{id}/plans", { params: { path: { id: appId }, query: params } }));
|
|
600
247
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
*/
|
|
604
|
-
async deleteReview(appId, reviewId) {
|
|
605
|
-
return this._delete(`/apps/${appId}/reviews/${reviewId}`);
|
|
248
|
+
async createPlan(appId, data) {
|
|
249
|
+
return this.unwrap(this.api.POST("/apps/{id}/plans", { params: { path: { id: appId } }, body: data }));
|
|
606
250
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
* Get usage event names for an app
|
|
610
|
-
*/
|
|
611
|
-
async listEventNames(appId) {
|
|
612
|
-
return this.get(
|
|
613
|
-
`/apps/${appId}/usage_events/event_names`
|
|
614
|
-
);
|
|
251
|
+
async getReview(appId, reviewId) {
|
|
252
|
+
return this.unwrap(this.api.GET("/apps/{id}/reviews/{reviewId}", { params: { path: { id: appId, reviewId } } }));
|
|
615
253
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
*/
|
|
619
|
-
async listPropertyKeys(appId, eventName) {
|
|
620
|
-
return this.get(
|
|
621
|
-
`/apps/${appId}/usage_events/property_keys`,
|
|
622
|
-
{ eventName }
|
|
623
|
-
);
|
|
254
|
+
async listReviews(appId, params) {
|
|
255
|
+
return this.unwrap(this.api.GET("/apps/{id}/reviews", { params: { path: { id: appId }, query: params } }));
|
|
624
256
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
* List usage metrics for an app
|
|
628
|
-
*/
|
|
629
|
-
async listUsageMetrics(appId) {
|
|
630
|
-
return this.get(
|
|
631
|
-
`/apps/${appId}/usage_metrics`
|
|
632
|
-
);
|
|
257
|
+
async getSkill(appId, skillId, params) {
|
|
258
|
+
return this.unwrap(this.api.GET("/apps/{id}/skills/{skillId}", { params: { path: { id: appId, skillId }, query: params } }));
|
|
633
259
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
*/
|
|
637
|
-
async retrieveUsageMetric(appId, usageMetricId) {
|
|
638
|
-
return this.get(
|
|
639
|
-
`/apps/${appId}/usage_metrics/${usageMetricId}`
|
|
640
|
-
);
|
|
260
|
+
async createSkill(appId, skillId, data) {
|
|
261
|
+
return this.unwrap(this.api.POST("/apps/{id}/skills/{skillId}", { params: { path: { id: appId, skillId } }, body: data }));
|
|
641
262
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
*/
|
|
645
|
-
async createUsageMetric(appId, data) {
|
|
646
|
-
return this.post(
|
|
647
|
-
`/apps/${appId}/usage_metrics`,
|
|
648
|
-
data
|
|
649
|
-
);
|
|
263
|
+
async getUsageMetric(appId, usageMetricId) {
|
|
264
|
+
return this.unwrap(this.api.GET("/apps/{id}/usage_metrics/{usageMetricId}", { params: { path: { id: appId, usageMetricId } } }));
|
|
650
265
|
}
|
|
651
|
-
/**
|
|
652
|
-
* Update an existing usage metric
|
|
653
|
-
*/
|
|
654
266
|
async updateUsageMetric(appId, usageMetricId, data) {
|
|
655
|
-
return this.
|
|
656
|
-
`/apps/${appId}/usage_metrics/${usageMetricId}`,
|
|
657
|
-
data
|
|
658
|
-
);
|
|
267
|
+
return this.unwrap(this.api.PUT("/apps/{id}/usage_metrics/{usageMetricId}", { params: { path: { id: appId, usageMetricId } }, body: data }));
|
|
659
268
|
}
|
|
660
|
-
/**
|
|
661
|
-
* Delete a usage metric
|
|
662
|
-
*/
|
|
663
269
|
async deleteUsageMetric(appId, usageMetricId) {
|
|
664
|
-
return this.
|
|
665
|
-
`/apps/${appId}/usage_metrics/${usageMetricId}`
|
|
666
|
-
);
|
|
270
|
+
return this.unwrap(this.api.DELETE("/apps/{id}/usage_metrics/{usageMetricId}", { params: { path: { id: appId, usageMetricId } } }));
|
|
667
271
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
const response = await this.get(
|
|
674
|
-
`/apps/${appId}/app_events`,
|
|
675
|
-
params
|
|
676
|
-
);
|
|
677
|
-
return {
|
|
678
|
-
appEvents: response.appEvents || [],
|
|
679
|
-
hasNextPage: response.hasNextPage || false,
|
|
680
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
681
|
-
total: response.total,
|
|
682
|
-
cursor: response.cursor
|
|
683
|
-
};
|
|
272
|
+
async listUsageMetrics(appId) {
|
|
273
|
+
return this.unwrap(this.api.GET("/apps/{id}/usage_metrics", { params: { path: { id: appId } } }));
|
|
274
|
+
}
|
|
275
|
+
async createUsageMetric(appId, data) {
|
|
276
|
+
return this.unwrap(this.api.POST("/apps/{id}/usage_metrics", { params: { path: { id: appId } }, body: data }));
|
|
684
277
|
}
|
|
685
278
|
};
|
|
686
279
|
|
|
687
|
-
// src/resources/
|
|
688
|
-
var
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
*/
|
|
692
|
-
async list(params) {
|
|
693
|
-
const response = await this.get("/deals", params);
|
|
694
|
-
return {
|
|
695
|
-
deals: response.deals || [],
|
|
696
|
-
hasNextPage: response.hasNextPage || false,
|
|
697
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
698
|
-
total: response.total,
|
|
699
|
-
cursor: response.cursor
|
|
700
|
-
};
|
|
280
|
+
// src/resources/assistant.ts
|
|
281
|
+
var AssistantResource = class extends BaseResource {
|
|
282
|
+
async getConversation(conversationId) {
|
|
283
|
+
return this.unwrap(this.api.GET("/assistant/conversations/{id}", { params: { path: { id: conversationId } } }));
|
|
701
284
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// src/resources/channels.ts
|
|
288
|
+
var ChannelsResource = class extends BaseResource {
|
|
289
|
+
async list(params) {
|
|
290
|
+
return this.unwrap(this.api.GET("/channels", { params: { query: params } }));
|
|
707
291
|
}
|
|
708
|
-
/**
|
|
709
|
-
* Create a new deal
|
|
710
|
-
*
|
|
711
|
-
* **Linking a Customer:**
|
|
712
|
-
* There are three ways to associate a customer with a deal (use only one):
|
|
713
|
-
*
|
|
714
|
-
* 1. `customerId` - Link to an existing customer by ID
|
|
715
|
-
* 2. `customer` - Create or update a customer inline. Matches existing customers
|
|
716
|
-
* by `domain` or `shopifyDomain`. If no match, creates a new customer.
|
|
717
|
-
* 3. `domain` and/or `shopifyDomain` - Find an existing customer by domain,
|
|
718
|
-
* or create a minimal customer record if not found.
|
|
719
|
-
*
|
|
720
|
-
* If `domain` or `shopifyDomain` are provided alongside `customerId` or `customer`,
|
|
721
|
-
* they will be used to update the customer's domain fields only if not already set.
|
|
722
|
-
*
|
|
723
|
-
* **Linking Contacts:**
|
|
724
|
-
* There are two ways to associate contacts with a deal (use only one):
|
|
725
|
-
*
|
|
726
|
-
* 1. `contactIds` - Link to existing contacts by their IDs
|
|
727
|
-
* 2. `contacts` - Create or update contacts inline. Matches existing contacts
|
|
728
|
-
* by email. Contacts are automatically linked to both the customer and the deal.
|
|
729
|
-
*
|
|
730
|
-
* @example
|
|
731
|
-
* // Using an existing customer
|
|
732
|
-
* await client.deals.create({ name: 'Deal', customerId: 'cust_123', dealFlowId: '...', dealStageId: '...' });
|
|
733
|
-
*
|
|
734
|
-
* // Creating a customer inline
|
|
735
|
-
* await client.deals.create({
|
|
736
|
-
* name: 'Deal',
|
|
737
|
-
* customer: { name: 'Acme Corp', domain: 'acme.com', email: 'info@acme.com' },
|
|
738
|
-
* contacts: [{ email: 'john@acme.com', name: 'John Doe', jobTitle: 'CEO' }],
|
|
739
|
-
* dealFlowId: '...',
|
|
740
|
-
* dealStageId: '...',
|
|
741
|
-
* });
|
|
742
|
-
*
|
|
743
|
-
* // Using domain to find/create customer
|
|
744
|
-
* await client.deals.create({ name: 'Deal', shopifyDomain: 'acme.myshopify.com', dealFlowId: '...', dealStageId: '...' });
|
|
745
|
-
*/
|
|
746
292
|
async create(data) {
|
|
747
|
-
return this.
|
|
293
|
+
return this.unwrap(this.api.POST("/channels", { body: data }));
|
|
748
294
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
* 1. `customerId` - Change to a different existing customer
|
|
756
|
-
* 2. `customer` - Update the linked customer inline, or create/link a new one.
|
|
757
|
-
* Matches existing customers by `domain` or `shopifyDomain`.
|
|
758
|
-
* 3. `domain` and/or `shopifyDomain` - Find a different customer by domain,
|
|
759
|
-
* or create a minimal customer record if not found.
|
|
760
|
-
*
|
|
761
|
-
* If `domain` or `shopifyDomain` are provided alongside `customerId` or `customer`,
|
|
762
|
-
* they will be used to update the customer's domain fields only if not already set.
|
|
763
|
-
*
|
|
764
|
-
* **Updating Contacts:**
|
|
765
|
-
* There are two ways to update contacts (use only one):
|
|
766
|
-
*
|
|
767
|
-
* 1. `contactIds` - Replace deal contacts with the specified contact IDs
|
|
768
|
-
* 2. `contacts` - Create or update contacts inline. Matches existing contacts
|
|
769
|
-
* by email. Contacts are automatically linked to both the customer and the deal.
|
|
770
|
-
*
|
|
771
|
-
* @example
|
|
772
|
-
* // Update customer's domain if not set
|
|
773
|
-
* await client.deals.update('deal_123', { customerId: 'cust_456', domain: 'newdomain.com' });
|
|
774
|
-
*
|
|
775
|
-
* // Update customer and contacts inline
|
|
776
|
-
* await client.deals.update('deal_123', {
|
|
777
|
-
* customer: { name: 'Updated Name', domain: 'acme.com' },
|
|
778
|
-
* contacts: [{ email: 'new@acme.com', name: 'New Contact' }],
|
|
779
|
-
* });
|
|
780
|
-
*/
|
|
781
|
-
async update(dealId, data) {
|
|
782
|
-
return this.put(`/deals/${dealId}`, data);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// src/resources/charges.ts
|
|
298
|
+
var ChargesResource = class extends BaseResource {
|
|
299
|
+
async list(params) {
|
|
300
|
+
return this.unwrap(this.api.GET("/charges", { params: { query: params } }));
|
|
783
301
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// src/resources/companies.ts
|
|
305
|
+
var CompaniesResource = class extends BaseResource {
|
|
306
|
+
async list(params) {
|
|
307
|
+
return this.unwrap(this.api.GET("/companies", { params: { query: params } }));
|
|
789
308
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
*/
|
|
793
|
-
async timeline(dealId) {
|
|
794
|
-
const response = await this.get(
|
|
795
|
-
`/deals/${dealId}/timeline`
|
|
796
|
-
);
|
|
797
|
-
return {
|
|
798
|
-
events: response.events || [],
|
|
799
|
-
hasNextPage: response.hasNextPage || false,
|
|
800
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
801
|
-
cursor: response.cursor
|
|
802
|
-
};
|
|
309
|
+
async create(data) {
|
|
310
|
+
return this.unwrap(this.api.POST("/companies", { body: data }));
|
|
803
311
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
*/
|
|
807
|
-
async listEvents(dealId) {
|
|
808
|
-
const response = await this.get(
|
|
809
|
-
`/deals/${dealId}/events`
|
|
810
|
-
);
|
|
811
|
-
return {
|
|
812
|
-
events: response.events || [],
|
|
813
|
-
hasNextPage: response.hasNextPage || false,
|
|
814
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
815
|
-
total: response.total,
|
|
816
|
-
cursor: response.cursor
|
|
817
|
-
};
|
|
312
|
+
async get(companyId) {
|
|
313
|
+
return this.unwrap(this.api.GET("/companies/{id}", { params: { path: { id: companyId } } }));
|
|
818
314
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
* is configured for a future stage, the deal will automatically progress.
|
|
825
|
-
*
|
|
826
|
-
* @example
|
|
827
|
-
* // Create a simple note
|
|
828
|
-
* await client.deals.createEvent('deal_123', { notes: 'Follow-up call completed' });
|
|
829
|
-
*
|
|
830
|
-
* // Create an event and progress to a new stage
|
|
831
|
-
* await client.deals.createEvent('deal_123', {
|
|
832
|
-
* dealStageId: 'stage_456',
|
|
833
|
-
* notes: 'Moving to negotiation phase',
|
|
834
|
-
* });
|
|
835
|
-
*/
|
|
836
|
-
async createEvent(dealId, data) {
|
|
837
|
-
return this.post(`/deals/${dealId}/events`, data);
|
|
315
|
+
async update(companyId, data) {
|
|
316
|
+
return this.unwrap(this.api.PUT("/companies/{id}", { params: { path: { id: companyId } }, body: data }));
|
|
317
|
+
}
|
|
318
|
+
async del(companyId) {
|
|
319
|
+
return this.unwrap(this.api.DELETE("/companies/{id}", { params: { path: { id: companyId } } }));
|
|
838
320
|
}
|
|
839
321
|
};
|
|
840
322
|
|
|
841
|
-
// src/resources/
|
|
842
|
-
var
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
*/
|
|
846
|
-
async list() {
|
|
847
|
-
return this.get("/deal_flows");
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
* Retrieve a single deal flow by ID
|
|
851
|
-
*/
|
|
852
|
-
async retrieve(dealFlowId) {
|
|
853
|
-
return this.get(`/deal_flows/${dealFlowId}`);
|
|
323
|
+
// src/resources/contacts.ts
|
|
324
|
+
var ContactsResource = class extends BaseResource {
|
|
325
|
+
async list(params) {
|
|
326
|
+
return this.unwrap(this.api.GET("/contacts", { params: { query: params } }));
|
|
854
327
|
}
|
|
855
|
-
/**
|
|
856
|
-
* Create a new deal flow
|
|
857
|
-
*/
|
|
858
328
|
async create(data) {
|
|
859
|
-
return this.
|
|
329
|
+
return this.unwrap(this.api.POST("/contacts", { body: data }));
|
|
860
330
|
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
*/
|
|
864
|
-
async update(dealFlowId, data) {
|
|
865
|
-
return this.put(
|
|
866
|
-
`/deal_flows/${dealFlowId}`,
|
|
867
|
-
data
|
|
868
|
-
);
|
|
331
|
+
async addTags(contactId, data) {
|
|
332
|
+
return this.unwrap(this.api.POST("/contacts/{id}/addTags", { params: { path: { id: contactId } }, body: data }));
|
|
869
333
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
*/
|
|
873
|
-
async del(dealFlowId) {
|
|
874
|
-
return this._delete(`/deal_flows/${dealFlowId}`);
|
|
334
|
+
async get(contactId) {
|
|
335
|
+
return this.unwrap(this.api.GET("/contacts/{id}", { params: { path: { id: contactId } } }));
|
|
875
336
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
// src/resources/deal-activities.ts
|
|
879
|
-
var DealActivitiesResource = class extends BaseResource {
|
|
880
|
-
/**
|
|
881
|
-
* List all deal activities
|
|
882
|
-
*/
|
|
883
|
-
async list() {
|
|
884
|
-
return this.get("/deal_activities");
|
|
337
|
+
async update(contactId, data) {
|
|
338
|
+
return this.unwrap(this.api.PUT("/contacts/{id}", { params: { path: { id: contactId } }, body: data }));
|
|
885
339
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
*/
|
|
889
|
-
async retrieve(dealActivityId) {
|
|
890
|
-
return this.get(
|
|
891
|
-
`/deal_activities/${dealActivityId}`
|
|
892
|
-
);
|
|
340
|
+
async del(contactId) {
|
|
341
|
+
return this.unwrap(this.api.DELETE("/contacts/{id}", { params: { path: { id: contactId } } }));
|
|
893
342
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
*/
|
|
897
|
-
async create(data) {
|
|
898
|
-
return this.post("/deal_activities", data);
|
|
343
|
+
async removeTags(contactId, data) {
|
|
344
|
+
return this.unwrap(this.api.POST("/contacts/{id}/removeTags", { params: { path: { id: contactId } }, body: data }));
|
|
899
345
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
data
|
|
907
|
-
);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
// src/resources/custom-data.ts
|
|
349
|
+
var CustomDataResource = class extends BaseResource {
|
|
350
|
+
async getValue(params) {
|
|
351
|
+
return this.unwrap(this.api.GET("/custom_data", { params: { query: params } }));
|
|
908
352
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
*/
|
|
912
|
-
async del(dealActivityId) {
|
|
913
|
-
return this._delete(`/deal_activities/${dealActivityId}`);
|
|
353
|
+
async set(data) {
|
|
354
|
+
return this.unwrap(this.api.PUT("/custom_data", { body: data }));
|
|
914
355
|
}
|
|
915
356
|
};
|
|
916
357
|
|
|
917
|
-
// src/resources/
|
|
918
|
-
var
|
|
919
|
-
/**
|
|
920
|
-
* List tickets with optional filters and pagination
|
|
921
|
-
*/
|
|
358
|
+
// src/resources/customer-segments.ts
|
|
359
|
+
var CustomerSegmentsResource = class extends BaseResource {
|
|
922
360
|
async list(params) {
|
|
923
|
-
|
|
924
|
-
return {
|
|
925
|
-
tickets: response.tickets || [],
|
|
926
|
-
hasNextPage: response.hasNextPage || false,
|
|
927
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
928
|
-
total: response.total,
|
|
929
|
-
cursor: response.cursor
|
|
930
|
-
};
|
|
361
|
+
return this.unwrap(this.api.GET("/customer_segments", { params: { query: params } }));
|
|
931
362
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
363
|
+
async get(segmentId) {
|
|
364
|
+
return this.unwrap(this.api.GET("/customer_segments/{id}", { params: { path: { id: segmentId } } }));
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// src/resources/customers.ts
|
|
369
|
+
var CustomersResource = class extends BaseResource {
|
|
370
|
+
async list(params) {
|
|
371
|
+
return this.unwrap(this.api.GET("/customers", { params: { query: params } }));
|
|
937
372
|
}
|
|
938
|
-
/**
|
|
939
|
-
* Create a new ticket
|
|
940
|
-
*/
|
|
941
373
|
async create(data) {
|
|
942
|
-
return this.
|
|
374
|
+
return this.unwrap(this.api.POST("/customers", { body: data }));
|
|
943
375
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
*/
|
|
947
|
-
async update(ticketId, data) {
|
|
948
|
-
return this.put(`/tickets/${ticketId}`, data);
|
|
376
|
+
async listCustomFields(params) {
|
|
377
|
+
return this.unwrap(this.api.GET("/customers/custom_fields", { params: { query: params } }));
|
|
949
378
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
*/
|
|
953
|
-
async del(ticketId) {
|
|
954
|
-
return this._delete(`/tickets/${ticketId}`);
|
|
379
|
+
async createCustomField(data) {
|
|
380
|
+
return this.unwrap(this.api.POST("/customers/custom_fields", { body: data }));
|
|
955
381
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
* List messages for a ticket
|
|
959
|
-
*/
|
|
960
|
-
async listMessages(ticketId) {
|
|
961
|
-
return this.get(
|
|
962
|
-
`/tickets/${ticketId}/messages`
|
|
963
|
-
);
|
|
382
|
+
async updateAccountOwner(customerId, ownerId, data) {
|
|
383
|
+
return this.unwrap(this.api.PUT("/customers/{id}/account_owners/{ownerId}", { params: { path: { id: customerId, ownerId } }, body: data }));
|
|
964
384
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
*/
|
|
968
|
-
async retrieveMessage(ticketId, messageId) {
|
|
969
|
-
return this.get(
|
|
970
|
-
`/tickets/${ticketId}/messages/${messageId}`
|
|
971
|
-
);
|
|
385
|
+
async deleteAccountOwner(customerId, ownerId) {
|
|
386
|
+
return this.unwrap(this.api.DELETE("/customers/{id}/account_owners/{ownerId}", { params: { path: { id: customerId, ownerId } } }));
|
|
972
387
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
*/
|
|
976
|
-
async createMessage(ticketId, data) {
|
|
977
|
-
return this.post(
|
|
978
|
-
`/tickets/${ticketId}/messages`,
|
|
979
|
-
data
|
|
980
|
-
);
|
|
388
|
+
async addTags(customerId, data) {
|
|
389
|
+
return this.unwrap(this.api.POST("/customers/{id}/addTags", { params: { path: { id: customerId } }, body: data }));
|
|
981
390
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
*/
|
|
985
|
-
async updateMessage(ticketId, messageId, data) {
|
|
986
|
-
return this.put(
|
|
987
|
-
`/tickets/${ticketId}/messages/${messageId}`,
|
|
988
|
-
data
|
|
989
|
-
);
|
|
391
|
+
async get(customerId) {
|
|
392
|
+
return this.unwrap(this.api.GET("/customers/{id}", { params: { path: { id: customerId } } }));
|
|
990
393
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
async
|
|
995
|
-
return this.
|
|
996
|
-
|
|
997
|
-
|
|
394
|
+
async update(customerId, data) {
|
|
395
|
+
return this.unwrap(this.api.PUT("/customers/{id}", { params: { path: { id: customerId } }, body: data }));
|
|
396
|
+
}
|
|
397
|
+
async removeTags(customerId, data) {
|
|
398
|
+
return this.unwrap(this.api.POST("/customers/{id}/removeTags", { params: { path: { id: customerId } }, body: data }));
|
|
399
|
+
}
|
|
400
|
+
async getTimeline(customerId, params) {
|
|
401
|
+
return this.unwrap(this.api.GET("/customers/{id}/timeline", { params: { path: { id: customerId }, query: params } }));
|
|
402
|
+
}
|
|
403
|
+
async listAccountOwners(customerId) {
|
|
404
|
+
return this.unwrap(this.api.GET("/customers/{id}/account_owners", { params: { path: { id: customerId } } }));
|
|
405
|
+
}
|
|
406
|
+
async createAccountOwner(customerId, data) {
|
|
407
|
+
return this.unwrap(this.api.POST("/customers/{id}/account_owners", { params: { path: { id: customerId } }, body: data }));
|
|
408
|
+
}
|
|
409
|
+
async getCustomField(customerId) {
|
|
410
|
+
return this.unwrap(this.api.GET("/customers/custom_fields/{id}", { params: { path: { id: customerId } } }));
|
|
411
|
+
}
|
|
412
|
+
async updateCustomField(customerId, data) {
|
|
413
|
+
return this.unwrap(this.api.PUT("/customers/custom_fields/{id}", { params: { path: { id: customerId } }, body: data }));
|
|
414
|
+
}
|
|
415
|
+
async deleteCustomField(customerId) {
|
|
416
|
+
return this.unwrap(this.api.DELETE("/customers/custom_fields/{id}", { params: { path: { id: customerId } } }));
|
|
998
417
|
}
|
|
999
418
|
};
|
|
1000
419
|
|
|
1001
|
-
// src/resources/
|
|
1002
|
-
var
|
|
1003
|
-
/**
|
|
1004
|
-
* List CX channels
|
|
1005
|
-
*/
|
|
420
|
+
// src/resources/deal-activities.ts
|
|
421
|
+
var DealActivitiesResource = class extends BaseResource {
|
|
1006
422
|
async list(params) {
|
|
1007
|
-
return this.
|
|
423
|
+
return this.unwrap(this.api.GET("/deal_activities", { params: { query: params } }));
|
|
1008
424
|
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Create a new CX channel
|
|
1011
|
-
*/
|
|
1012
425
|
async create(data) {
|
|
1013
|
-
return this.
|
|
426
|
+
return this.unwrap(this.api.POST("/deal_activities", { body: data }));
|
|
427
|
+
}
|
|
428
|
+
async get(activityId) {
|
|
429
|
+
return this.unwrap(this.api.GET("/deal_activities/{id}", { params: { path: { id: activityId } } }));
|
|
430
|
+
}
|
|
431
|
+
async update(activityId, data) {
|
|
432
|
+
return this.unwrap(this.api.PUT("/deal_activities/{id}", { params: { path: { id: activityId } }, body: data }));
|
|
433
|
+
}
|
|
434
|
+
async del(activityId) {
|
|
435
|
+
return this.unwrap(this.api.DELETE("/deal_activities/{id}", { params: { path: { id: activityId } } }));
|
|
1014
436
|
}
|
|
1015
437
|
};
|
|
1016
438
|
|
|
1017
|
-
// src/resources/flows.ts
|
|
1018
|
-
var
|
|
1019
|
-
/**
|
|
1020
|
-
* List flows with optional filters and pagination
|
|
1021
|
-
*/
|
|
439
|
+
// src/resources/deal-flows.ts
|
|
440
|
+
var DealFlowsResource = class extends BaseResource {
|
|
1022
441
|
async list(params) {
|
|
1023
|
-
|
|
1024
|
-
return {
|
|
1025
|
-
flows: response.flows || [],
|
|
1026
|
-
hasNextPage: response.hasNextPage || false,
|
|
1027
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1028
|
-
total: response.total,
|
|
1029
|
-
cursor: response.cursor
|
|
1030
|
-
};
|
|
442
|
+
return this.unwrap(this.api.GET("/deal_flows", { params: { query: params } }));
|
|
1031
443
|
}
|
|
1032
|
-
/**
|
|
1033
|
-
* Retrieve a single flow by ID
|
|
1034
|
-
*/
|
|
1035
|
-
async retrieve(flowId) {
|
|
1036
|
-
return this.get(`/flows/${flowId}`);
|
|
1037
|
-
}
|
|
1038
|
-
/**
|
|
1039
|
-
* Create a new flow
|
|
1040
|
-
*/
|
|
1041
444
|
async create(data) {
|
|
1042
|
-
return this.
|
|
445
|
+
return this.unwrap(this.api.POST("/deal_flows", { body: data }));
|
|
1043
446
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
*/
|
|
1047
|
-
async update(flowId, data) {
|
|
1048
|
-
return this.put(`/flows/${flowId}`, data);
|
|
447
|
+
async get(dealFlowId) {
|
|
448
|
+
return this.unwrap(this.api.GET("/deal_flows/{id}", { params: { path: { id: dealFlowId } } }));
|
|
1049
449
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
async del(
|
|
1054
|
-
return this.
|
|
450
|
+
async update(dealFlowId, data) {
|
|
451
|
+
return this.unwrap(this.api.PUT("/deal_flows/{id}", { params: { path: { id: dealFlowId } }, body: data }));
|
|
452
|
+
}
|
|
453
|
+
async del(dealFlowId) {
|
|
454
|
+
return this.unwrap(this.api.DELETE("/deal_flows/{id}", { params: { path: { id: dealFlowId } } }));
|
|
1055
455
|
}
|
|
1056
456
|
};
|
|
1057
457
|
|
|
1058
|
-
// src/resources/
|
|
1059
|
-
var
|
|
1060
|
-
/**
|
|
1061
|
-
* List tasks with optional filters and pagination
|
|
1062
|
-
*/
|
|
458
|
+
// src/resources/deals.ts
|
|
459
|
+
var DealsResource = class extends BaseResource {
|
|
1063
460
|
async list(params) {
|
|
1064
|
-
|
|
1065
|
-
return {
|
|
1066
|
-
tasks: response.tasks || [],
|
|
1067
|
-
hasNextPage: response.hasNextPage || false,
|
|
1068
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1069
|
-
total: response.total,
|
|
1070
|
-
cursor: response.cursor
|
|
1071
|
-
};
|
|
461
|
+
return this.unwrap(this.api.GET("/deals", { params: { query: params } }));
|
|
1072
462
|
}
|
|
1073
|
-
/**
|
|
1074
|
-
* Retrieve a single task by ID
|
|
1075
|
-
*/
|
|
1076
|
-
async retrieve(taskId) {
|
|
1077
|
-
return this.get(`/tasks/${taskId}`);
|
|
1078
|
-
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Create a new task
|
|
1081
|
-
*/
|
|
1082
463
|
async create(data) {
|
|
1083
|
-
return this.
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* Update an existing task
|
|
1087
|
-
*/
|
|
1088
|
-
async update(taskId, data) {
|
|
1089
|
-
return this.put(`/tasks/${taskId}`, data);
|
|
464
|
+
return this.unwrap(this.api.POST("/deals", { body: data }));
|
|
1090
465
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
*/
|
|
1094
|
-
async del(taskId) {
|
|
1095
|
-
return this._delete(`/tasks/${taskId}`);
|
|
466
|
+
async listEvents(dealId, params) {
|
|
467
|
+
return this.unwrap(this.api.GET("/deals/{id}/events", { params: { path: { id: dealId }, query: params } }));
|
|
1096
468
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
* List todo items for a task
|
|
1100
|
-
*/
|
|
1101
|
-
async listTodoItems(taskId) {
|
|
1102
|
-
return this.get(`/tasks/${taskId}/todo-items`);
|
|
469
|
+
async createEvent(dealId, data) {
|
|
470
|
+
return this.unwrap(this.api.POST("/deals/{id}/events", { params: { path: { id: dealId } }, body: data }));
|
|
1103
471
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
*/
|
|
1107
|
-
async retrieveTodoItem(taskId, itemId) {
|
|
1108
|
-
return this.get(`/tasks/${taskId}/todo-items/${itemId}`);
|
|
472
|
+
async get(dealId) {
|
|
473
|
+
return this.unwrap(this.api.GET("/deals/{id}", { params: { path: { id: dealId } } }));
|
|
1109
474
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
*/
|
|
1113
|
-
async createTodoItem(taskId, data) {
|
|
1114
|
-
return this.post(`/tasks/${taskId}/todo-items`, data);
|
|
475
|
+
async update(dealId, data) {
|
|
476
|
+
return this.unwrap(this.api.PUT("/deals/{id}", { params: { path: { id: dealId } }, body: data }));
|
|
1115
477
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
*/
|
|
1119
|
-
async updateTodoItem(taskId, itemId, data) {
|
|
1120
|
-
return this.put(
|
|
1121
|
-
`/tasks/${taskId}/todo-items/${itemId}`,
|
|
1122
|
-
data
|
|
1123
|
-
);
|
|
478
|
+
async del(dealId) {
|
|
479
|
+
return this.unwrap(this.api.DELETE("/deals/{id}", { params: { path: { id: dealId } } }));
|
|
1124
480
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
*/
|
|
1128
|
-
async deleteTodoItem(taskId, itemId) {
|
|
1129
|
-
return this._delete(`/tasks/${taskId}/todo-items/${itemId}`);
|
|
481
|
+
async getTimeline(dealId, params) {
|
|
482
|
+
return this.unwrap(this.api.GET("/deals/{id}/timeline", { params: { path: { id: dealId }, query: params } }));
|
|
1130
483
|
}
|
|
1131
484
|
};
|
|
1132
485
|
|
|
1133
|
-
// src/resources/
|
|
1134
|
-
var
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
*/
|
|
1138
|
-
async list() {
|
|
1139
|
-
const response = await this.get("/webhooks");
|
|
1140
|
-
return {
|
|
1141
|
-
webhooks: response.webhooks || [],
|
|
1142
|
-
hasNextPage: response.hasNextPage || false,
|
|
1143
|
-
hasPreviousPage: response.hasPreviousPage || false
|
|
1144
|
-
};
|
|
486
|
+
// src/resources/docs.ts
|
|
487
|
+
var DocsResource = class extends BaseResource {
|
|
488
|
+
async listCollections(params) {
|
|
489
|
+
return this.unwrap(this.api.GET("/docs/collections", { params: { query: params } }));
|
|
1145
490
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
*/
|
|
1149
|
-
async retrieve(webhookId) {
|
|
1150
|
-
return this.get(`/webhooks/${webhookId}`);
|
|
491
|
+
async createCollection(data) {
|
|
492
|
+
return this.unwrap(this.api.POST("/docs/collections", { body: data }));
|
|
1151
493
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
*/
|
|
1155
|
-
async create(data) {
|
|
1156
|
-
return this.post("/webhooks", data);
|
|
494
|
+
async listGroups(params) {
|
|
495
|
+
return this.unwrap(this.api.GET("/docs/groups", { params: { query: params } }));
|
|
1157
496
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
*/
|
|
1161
|
-
async update(webhookId, data) {
|
|
1162
|
-
return this.put(`/webhooks/${webhookId}`, data);
|
|
497
|
+
async createGroup(data) {
|
|
498
|
+
return this.unwrap(this.api.POST("/docs/groups", { body: data }));
|
|
1163
499
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
*/
|
|
1167
|
-
async del(webhookId) {
|
|
1168
|
-
return this._delete(`/webhooks/${webhookId}`);
|
|
500
|
+
async listPages(params) {
|
|
501
|
+
return this.unwrap(this.api.GET("/docs/pages", { params: { query: params } }));
|
|
1169
502
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
// src/resources/companies.ts
|
|
1173
|
-
var CompaniesResource = class extends BaseResource {
|
|
1174
|
-
/**
|
|
1175
|
-
* List companies with optional pagination
|
|
1176
|
-
*/
|
|
1177
|
-
async list(params) {
|
|
1178
|
-
const response = await this.get("/companies", params);
|
|
1179
|
-
return {
|
|
1180
|
-
companies: response.companies || [],
|
|
1181
|
-
hasNextPage: response.hasNextPage || false,
|
|
1182
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1183
|
-
cursor: response.cursor
|
|
1184
|
-
};
|
|
503
|
+
async createPage(data) {
|
|
504
|
+
return this.unwrap(this.api.POST("/docs/pages", { body: data }));
|
|
1185
505
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
*/
|
|
1189
|
-
async retrieve(companyId) {
|
|
1190
|
-
return this.get(`/companies/${companyId}`);
|
|
506
|
+
async listRepositories(params) {
|
|
507
|
+
return this.unwrap(this.api.GET("/docs/repositories", { params: { query: params } }));
|
|
1191
508
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
*/
|
|
1195
|
-
async create(data) {
|
|
1196
|
-
return this.post("/companies", data);
|
|
509
|
+
async updateCollection(collectionId, data) {
|
|
510
|
+
return this.unwrap(this.api.PUT("/docs/collections/{collection_id}", { params: { path: { collection_id: collectionId } }, body: data }));
|
|
1197
511
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
*/
|
|
1201
|
-
async update(companyId, data) {
|
|
1202
|
-
return this.put(`/companies/${companyId}`, data);
|
|
512
|
+
async deleteCollection(collectionId) {
|
|
513
|
+
return this.unwrap(this.api.DELETE("/docs/collections/{collection_id}", { params: { path: { collection_id: collectionId } } }));
|
|
1203
514
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
*/
|
|
1207
|
-
async del(companyId) {
|
|
1208
|
-
return this._delete(`/companies/${companyId}`);
|
|
515
|
+
async updateGroup(groupId, data) {
|
|
516
|
+
return this.unwrap(this.api.PUT("/docs/groups/{group_id}", { params: { path: { group_id: groupId } }, body: data }));
|
|
1209
517
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
// src/resources/customer-segments.ts
|
|
1213
|
-
var CustomerSegmentsResource = class extends BaseResource {
|
|
1214
|
-
/**
|
|
1215
|
-
* List public customer segments with optional pagination
|
|
1216
|
-
*/
|
|
1217
|
-
async list(params) {
|
|
1218
|
-
const response = await this.get(
|
|
1219
|
-
"/customer_segments",
|
|
1220
|
-
params
|
|
1221
|
-
);
|
|
1222
|
-
return {
|
|
1223
|
-
customerSegments: response.customerSegments || [],
|
|
1224
|
-
hasNextPage: response.hasNextPage || false,
|
|
1225
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1226
|
-
cursor: response.cursor
|
|
1227
|
-
};
|
|
518
|
+
async deleteGroup(groupId) {
|
|
519
|
+
return this.unwrap(this.api.DELETE("/docs/groups/{group_id}", { params: { path: { group_id: groupId } } }));
|
|
1228
520
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
*/
|
|
1232
|
-
async retrieve(segmentId) {
|
|
1233
|
-
return this.get(
|
|
1234
|
-
`/customer_segments/${segmentId}`
|
|
1235
|
-
);
|
|
521
|
+
async getPage(pageId, params) {
|
|
522
|
+
return this.unwrap(this.api.GET("/docs/pages/{page_id}", { params: { path: { page_id: pageId }, query: params } }));
|
|
1236
523
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
// src/resources/affiliates.ts
|
|
1240
|
-
var AffiliatesResource = class extends BaseResource {
|
|
1241
|
-
/**
|
|
1242
|
-
* List affiliates with optional filters and pagination
|
|
1243
|
-
*/
|
|
1244
|
-
async list(params) {
|
|
1245
|
-
const response = await this.get(
|
|
1246
|
-
"/affiliates",
|
|
1247
|
-
params
|
|
1248
|
-
);
|
|
1249
|
-
return {
|
|
1250
|
-
affiliates: response.affiliates || [],
|
|
1251
|
-
hasNextPage: response.hasNextPage || false,
|
|
1252
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1253
|
-
cursor: response.cursor
|
|
1254
|
-
};
|
|
524
|
+
async updatePage(pageId, data) {
|
|
525
|
+
return this.unwrap(this.api.PUT("/docs/pages/{page_id}", { params: { path: { page_id: pageId } }, body: data }));
|
|
1255
526
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
*/
|
|
1259
|
-
async retrieve(affiliateId) {
|
|
1260
|
-
return this.get(`/affiliates/${affiliateId}`);
|
|
527
|
+
async deletePage(pageId) {
|
|
528
|
+
return this.unwrap(this.api.DELETE("/docs/pages/{page_id}", { params: { path: { page_id: pageId } } }));
|
|
1261
529
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
*/
|
|
1265
|
-
async update(affiliateId, data) {
|
|
1266
|
-
return this.put(
|
|
1267
|
-
`/affiliates/${affiliateId}`,
|
|
1268
|
-
data
|
|
1269
|
-
);
|
|
530
|
+
async getRepository(docId, params) {
|
|
531
|
+
return this.unwrap(this.api.GET("/docs/repositories/{id}", { params: { path: { id: docId }, query: params } }));
|
|
1270
532
|
}
|
|
1271
533
|
};
|
|
1272
534
|
|
|
1273
|
-
// src/resources/
|
|
1274
|
-
var
|
|
1275
|
-
/**
|
|
1276
|
-
* List all affiliate programs
|
|
1277
|
-
*/
|
|
535
|
+
// src/resources/email-unsubscribe-groups.ts
|
|
536
|
+
var EmailUnsubscribeGroupsResource = class extends BaseResource {
|
|
1278
537
|
async list() {
|
|
1279
|
-
return this.
|
|
1280
|
-
"/affiliate_programs"
|
|
1281
|
-
);
|
|
538
|
+
return this.unwrap(this.api.GET("/email/unsubscribe_groups"));
|
|
1282
539
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
*/
|
|
1286
|
-
async retrieve(programId) {
|
|
1287
|
-
return this.get(
|
|
1288
|
-
`/affiliate_programs/${programId}`
|
|
1289
|
-
);
|
|
540
|
+
async deleteMemberDelete(groupId, memberId) {
|
|
541
|
+
return this.unwrap(this.api.DELETE("/email/unsubscribe_groups/{id}/members/{member_id}", { params: { path: { id: groupId, member_id: memberId } } }));
|
|
1290
542
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
*/
|
|
1294
|
-
async create(data) {
|
|
1295
|
-
return this.post(
|
|
1296
|
-
"/affiliate_programs",
|
|
1297
|
-
data
|
|
1298
|
-
);
|
|
543
|
+
async listMembers(groupId) {
|
|
544
|
+
return this.unwrap(this.api.GET("/email/unsubscribe_groups/{id}/members", { params: { path: { id: groupId } } }));
|
|
1299
545
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
*/
|
|
1303
|
-
async update(programId, data) {
|
|
1304
|
-
return this.put(
|
|
1305
|
-
`/affiliate_programs/${programId}`,
|
|
1306
|
-
data
|
|
1307
|
-
);
|
|
1308
|
-
}
|
|
1309
|
-
/**
|
|
1310
|
-
* Delete an affiliate program
|
|
1311
|
-
*/
|
|
1312
|
-
async del(programId) {
|
|
1313
|
-
return this._delete(`/affiliate_programs/${programId}`);
|
|
546
|
+
async createMember(groupId, data) {
|
|
547
|
+
return this.unwrap(this.api.POST("/email/unsubscribe_groups/{id}/members", { params: { path: { id: groupId } }, body: data }));
|
|
1314
548
|
}
|
|
1315
549
|
};
|
|
1316
550
|
|
|
1317
|
-
// src/resources/
|
|
1318
|
-
var
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
*/
|
|
1322
|
-
async list(params) {
|
|
1323
|
-
const response = await this.get(
|
|
1324
|
-
"/affiliate_commissions",
|
|
1325
|
-
params
|
|
1326
|
-
);
|
|
1327
|
-
return {
|
|
1328
|
-
commissions: response.commissions || [],
|
|
1329
|
-
hasNextPage: response.hasNextPage || false,
|
|
1330
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1331
|
-
cursor: response.cursor
|
|
1332
|
-
};
|
|
1333
|
-
}
|
|
1334
|
-
/**
|
|
1335
|
-
* Retrieve a single affiliate commission by ID
|
|
1336
|
-
*/
|
|
1337
|
-
async retrieve(commissionId) {
|
|
1338
|
-
return this.get(
|
|
1339
|
-
`/affiliate_commissions/${commissionId}`
|
|
1340
|
-
);
|
|
551
|
+
// src/resources/entities.ts
|
|
552
|
+
var EntitiesResource = class extends BaseResource {
|
|
553
|
+
async search(params) {
|
|
554
|
+
return this.unwrap(this.api.GET("/entities", { params: { query: params } }));
|
|
1341
555
|
}
|
|
1342
556
|
};
|
|
1343
557
|
|
|
1344
|
-
// src/resources/
|
|
1345
|
-
var
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
*/
|
|
1349
|
-
async list(params) {
|
|
1350
|
-
const response = await this.get(
|
|
1351
|
-
"/affiliate_payouts",
|
|
1352
|
-
params
|
|
1353
|
-
);
|
|
1354
|
-
return {
|
|
1355
|
-
payouts: response.payouts || [],
|
|
1356
|
-
hasNextPage: response.hasNextPage || false,
|
|
1357
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1358
|
-
cursor: response.cursor
|
|
1359
|
-
};
|
|
558
|
+
// src/resources/flow-extensions.ts
|
|
559
|
+
var FlowExtensionsResource = class extends BaseResource {
|
|
560
|
+
async listActions() {
|
|
561
|
+
return this.unwrap(this.api.GET("/flow/extensions/actions"));
|
|
1360
562
|
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
*/
|
|
1364
|
-
async retrieve(payoutId) {
|
|
1365
|
-
return this.get(
|
|
1366
|
-
`/affiliate_payouts/${payoutId}`
|
|
1367
|
-
);
|
|
563
|
+
async createAction(data) {
|
|
564
|
+
return this.unwrap(this.api.POST("/flow/extensions/actions", { body: data }));
|
|
1368
565
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
// src/resources/affiliate-referrals.ts
|
|
1372
|
-
var AffiliateReferralsResource = class extends BaseResource {
|
|
1373
|
-
/**
|
|
1374
|
-
* List affiliate referrals with optional filters and pagination
|
|
1375
|
-
*/
|
|
1376
|
-
async list(params) {
|
|
1377
|
-
const response = await this.get(
|
|
1378
|
-
"/affiliate_referrals",
|
|
1379
|
-
params
|
|
1380
|
-
);
|
|
1381
|
-
return {
|
|
1382
|
-
referrals: response.referrals || [],
|
|
1383
|
-
hasNextPage: response.hasNextPage || false,
|
|
1384
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1385
|
-
cursor: response.cursor
|
|
1386
|
-
};
|
|
566
|
+
async listTriggers() {
|
|
567
|
+
return this.unwrap(this.api.GET("/flow/extensions/triggers"));
|
|
1387
568
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
*/
|
|
1391
|
-
async retrieve(referralId) {
|
|
1392
|
-
return this.get(
|
|
1393
|
-
`/affiliate_referrals/${referralId}`
|
|
1394
|
-
);
|
|
569
|
+
async createTriggerPost(data) {
|
|
570
|
+
return this.unwrap(this.api.POST("/flow/extensions/triggers", { body: data }));
|
|
1395
571
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
// src/resources/charges.ts
|
|
1399
|
-
var ChargesResource = class extends BaseResource {
|
|
1400
|
-
/**
|
|
1401
|
-
* List charges with optional filters and pagination
|
|
1402
|
-
*/
|
|
1403
|
-
async list(params) {
|
|
1404
|
-
const response = await this.get("/charges", params);
|
|
1405
|
-
return {
|
|
1406
|
-
charges: response.charges || [],
|
|
1407
|
-
hasNextPage: response.hasNextPage || false,
|
|
1408
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1409
|
-
total: response.total,
|
|
1410
|
-
cursor: response.cursor
|
|
1411
|
-
};
|
|
572
|
+
async validateSchema(data) {
|
|
573
|
+
return this.unwrap(this.api.POST("/flow/extensions/triggers/validate-schema", { body: data }));
|
|
1412
574
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
// src/resources/transactions.ts
|
|
1416
|
-
var TransactionsResource = class extends BaseResource {
|
|
1417
|
-
/**
|
|
1418
|
-
* List transactions with optional filters and pagination
|
|
1419
|
-
*/
|
|
1420
|
-
async list(params) {
|
|
1421
|
-
const response = await this.get(
|
|
1422
|
-
"/transactions",
|
|
1423
|
-
params
|
|
1424
|
-
);
|
|
1425
|
-
return {
|
|
1426
|
-
transactions: response.transactions || [],
|
|
1427
|
-
hasNextPage: response.hasNextPage || false,
|
|
1428
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1429
|
-
total: response.total,
|
|
1430
|
-
cursor: response.cursor
|
|
1431
|
-
};
|
|
575
|
+
async updateRun(extensionId, data) {
|
|
576
|
+
return this.unwrap(this.api.PUT("/flow/actions/runs/{id}", { params: { path: { id: extensionId } }, body: data }));
|
|
1432
577
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
*/
|
|
1436
|
-
async retrieve(transactionId) {
|
|
1437
|
-
return this.get(
|
|
1438
|
-
`/transactions/${transactionId}`
|
|
1439
|
-
);
|
|
578
|
+
async fireTrigger(handle, data) {
|
|
579
|
+
return this.unwrap(this.api.POST("/flow/extensions/triggers/{handle}/fire", { params: { path: { handle } }, body: data }));
|
|
1440
580
|
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
// src/resources/metrics.ts
|
|
1444
|
-
var MetricsResource = class extends BaseResource {
|
|
1445
|
-
/**
|
|
1446
|
-
* Fetch metrics with custom parameters
|
|
1447
|
-
*/
|
|
1448
|
-
async fetch(params) {
|
|
1449
|
-
const response = await this.client.get("/metrics", {
|
|
1450
|
-
...params,
|
|
1451
|
-
includes: params.includes || ["includeTotal"],
|
|
1452
|
-
appEventsForMrr: params.appEventsForMrr ?? true
|
|
1453
|
-
});
|
|
1454
|
-
const data = Array.isArray(response) ? response : [];
|
|
1455
|
-
const first = data[0];
|
|
1456
|
-
return {
|
|
1457
|
-
data,
|
|
1458
|
-
total: first?.total,
|
|
1459
|
-
startingTotal: first?.startingTotal,
|
|
1460
|
-
change: first?.change,
|
|
1461
|
-
changePercentage: first?.changePercentage,
|
|
1462
|
-
formattedTotal: first?.formattedTotal,
|
|
1463
|
-
formattedChange: first?.formattedChange,
|
|
1464
|
-
formattedChangePercentage: first?.formattedChangePercentage
|
|
1465
|
-
};
|
|
581
|
+
async updateAction(extensionId, data) {
|
|
582
|
+
return this.unwrap(this.api.PUT("/flow/extensions/actions/{id}", { params: { path: { id: extensionId } }, body: data }));
|
|
1466
583
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
*/
|
|
1470
|
-
async arr(params) {
|
|
1471
|
-
return this.fetch({
|
|
1472
|
-
metric: "PlatformApp.arr",
|
|
1473
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1474
|
-
...params
|
|
1475
|
-
});
|
|
584
|
+
async deleteAction(extensionId) {
|
|
585
|
+
return this.unwrap(this.api.DELETE("/flow/extensions/actions/{id}", { params: { path: { id: extensionId } } }));
|
|
1476
586
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
*/
|
|
1480
|
-
async mrr(params) {
|
|
1481
|
-
return this.fetch({
|
|
1482
|
-
metric: "PlatformApp.mrr",
|
|
1483
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1484
|
-
...params
|
|
1485
|
-
});
|
|
587
|
+
async getTrigger(handle) {
|
|
588
|
+
return this.unwrap(this.api.GET("/flow/extensions/triggers/{handle}", { params: { path: { handle } } }));
|
|
1486
589
|
}
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
*/
|
|
1490
|
-
async activeSubscriptions(params) {
|
|
1491
|
-
return this.fetch({
|
|
1492
|
-
metric: "PlatformApp.activeSubscriptions",
|
|
1493
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1494
|
-
...params
|
|
1495
|
-
});
|
|
590
|
+
async replaceTrigger(handle, data) {
|
|
591
|
+
return this.unwrap(this.api.PUT("/flow/extensions/triggers/{handle}", { params: { path: { handle } }, body: data }));
|
|
1496
592
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
*/
|
|
1500
|
-
async activeInstalls(params) {
|
|
1501
|
-
return this.fetch({
|
|
1502
|
-
metric: "PlatformApp.activeInstalls",
|
|
1503
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1504
|
-
...params
|
|
1505
|
-
});
|
|
593
|
+
async updateTrigger(handle, data) {
|
|
594
|
+
return this.unwrap(this.api.PATCH("/flow/extensions/triggers/{handle}", { params: { path: { handle } }, body: data }));
|
|
1506
595
|
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
*/
|
|
1510
|
-
async netInstalls(params) {
|
|
1511
|
-
return this.fetch({
|
|
1512
|
-
metric: "PlatformApp.netInstalls",
|
|
1513
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1514
|
-
...params
|
|
1515
|
-
});
|
|
596
|
+
async deleteTrigger(handle) {
|
|
597
|
+
return this.unwrap(this.api.DELETE("/flow/extensions/triggers/{handle}", { params: { path: { handle } } }));
|
|
1516
598
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1524
|
-
...params
|
|
1525
|
-
});
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
// src/resources/flows.ts
|
|
602
|
+
var FlowsResource = class extends BaseResource {
|
|
603
|
+
async list(params) {
|
|
604
|
+
return this.unwrap(this.api.GET("/flows", { params: { query: params } }));
|
|
1526
605
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
*/
|
|
1530
|
-
async ltv(params) {
|
|
1531
|
-
return this.fetch({
|
|
1532
|
-
metric: "PlatformApp.ltv",
|
|
1533
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1534
|
-
...params
|
|
1535
|
-
});
|
|
606
|
+
async create(data) {
|
|
607
|
+
return this.unwrap(this.api.POST("/flows", { body: data }));
|
|
1536
608
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
*/
|
|
1540
|
-
async revenueChurn(params) {
|
|
1541
|
-
return this.fetch({
|
|
1542
|
-
metric: "PlatformApp.revenueChurn",
|
|
1543
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1544
|
-
...params
|
|
1545
|
-
});
|
|
609
|
+
async get(flowId) {
|
|
610
|
+
return this.unwrap(this.api.GET("/flows/{id}", { params: { path: { id: flowId } } }));
|
|
1546
611
|
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
*/
|
|
1550
|
-
async logoChurn(params) {
|
|
1551
|
-
return this.fetch({
|
|
1552
|
-
metric: "PlatformApp.logoChurn",
|
|
1553
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1554
|
-
...params
|
|
1555
|
-
});
|
|
612
|
+
async update(flowId, data) {
|
|
613
|
+
return this.unwrap(this.api.PATCH("/flows/{id}", { params: { path: { id: flowId } }, body: data }));
|
|
1556
614
|
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
*/
|
|
1560
|
-
async revenueRetention(params) {
|
|
1561
|
-
return this.fetch({
|
|
1562
|
-
metric: "PlatformApp.revenueRetention",
|
|
1563
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1564
|
-
...params
|
|
1565
|
-
});
|
|
615
|
+
async del(flowId) {
|
|
616
|
+
return this.unwrap(this.api.DELETE("/flows/{id}", { params: { path: { id: flowId } } }));
|
|
1566
617
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1574
|
-
...params
|
|
1575
|
-
});
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
// src/resources/journal-entries.ts
|
|
621
|
+
var JournalEntriesResource = class extends BaseResource {
|
|
622
|
+
async list(params) {
|
|
623
|
+
return this.unwrap(this.api.GET("/journal_entries", { params: { query: params } }));
|
|
1576
624
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
*/
|
|
1580
|
-
async netRevenue(params) {
|
|
1581
|
-
return this.fetch({
|
|
1582
|
-
metric: "PlatformApp.netRevenue",
|
|
1583
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1584
|
-
...params
|
|
1585
|
-
});
|
|
625
|
+
async create(data) {
|
|
626
|
+
return this.unwrap(this.api.POST("/journal_entries", { body: data }));
|
|
1586
627
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
*/
|
|
1590
|
-
async payout(params) {
|
|
1591
|
-
return this.fetch({
|
|
1592
|
-
metric: "PlatformApp.payout",
|
|
1593
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1594
|
-
...params
|
|
1595
|
-
});
|
|
628
|
+
async get(entryId, params) {
|
|
629
|
+
return this.unwrap(this.api.GET("/journal_entries/{id}", { params: { path: { id: entryId }, query: params } }));
|
|
1596
630
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
*/
|
|
1600
|
-
async predictedLtv(params) {
|
|
1601
|
-
return this.fetch({
|
|
1602
|
-
metric: "PlatformApp.predictedLtv",
|
|
1603
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1604
|
-
...params
|
|
1605
|
-
});
|
|
631
|
+
async update(entryId, data) {
|
|
632
|
+
return this.unwrap(this.api.PUT("/journal_entries/{id}", { params: { path: { id: entryId } }, body: data }));
|
|
1606
633
|
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
*/
|
|
1610
|
-
async charges(params) {
|
|
1611
|
-
return this.fetch({
|
|
1612
|
-
metric: "PlatformApp.charges",
|
|
1613
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1614
|
-
...params
|
|
1615
|
-
});
|
|
634
|
+
async del(entryId) {
|
|
635
|
+
return this.unwrap(this.api.DELETE("/journal_entries/{id}", { params: { path: { id: entryId } } }));
|
|
1616
636
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1624
|
-
...params
|
|
1625
|
-
});
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// src/resources/lists.ts
|
|
640
|
+
var ListsResource = class extends BaseResource {
|
|
641
|
+
async list(params) {
|
|
642
|
+
return this.unwrap(this.api.GET("/lists", { params: { query: params } }));
|
|
1626
643
|
}
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
*/
|
|
1630
|
-
async usageMetric(params) {
|
|
1631
|
-
return this.fetch({
|
|
1632
|
-
metric: "PlatformApp.usageMetric",
|
|
1633
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1634
|
-
...params
|
|
1635
|
-
});
|
|
644
|
+
async create(data) {
|
|
645
|
+
return this.unwrap(this.api.POST("/lists", { body: data }));
|
|
1636
646
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
async
|
|
1641
|
-
return this.
|
|
647
|
+
async add(listId, data) {
|
|
648
|
+
return this.unwrap(this.api.POST("/lists/{id}/add", { params: { path: { id: listId } }, body: data }));
|
|
649
|
+
}
|
|
650
|
+
async get(listId, params) {
|
|
651
|
+
return this.unwrap(this.api.GET("/lists/{id}", { params: { path: { id: listId }, query: params } }));
|
|
652
|
+
}
|
|
653
|
+
async update(listId, data) {
|
|
654
|
+
return this.unwrap(this.api.PUT("/lists/{id}", { params: { path: { id: listId } }, body: data }));
|
|
655
|
+
}
|
|
656
|
+
async del(listId) {
|
|
657
|
+
return this.unwrap(this.api.DELETE("/lists/{id}", { params: { path: { id: listId } } }));
|
|
658
|
+
}
|
|
659
|
+
async remove(listId, data) {
|
|
660
|
+
return this.unwrap(this.api.POST("/lists/{id}/remove", { params: { path: { id: listId } }, body: data }));
|
|
1642
661
|
}
|
|
1643
662
|
};
|
|
1644
663
|
|
|
1645
|
-
// src/resources/
|
|
1646
|
-
var
|
|
1647
|
-
/**
|
|
1648
|
-
* List organization users with optional pagination
|
|
1649
|
-
*/
|
|
664
|
+
// src/resources/meetings.ts
|
|
665
|
+
var MeetingsResource = class extends BaseResource {
|
|
1650
666
|
async list(params) {
|
|
1651
|
-
|
|
1652
|
-
return {
|
|
1653
|
-
users: response.users || [],
|
|
1654
|
-
hasNextPage: response.hasNextPage || false,
|
|
1655
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1656
|
-
cursor: response.cursor
|
|
1657
|
-
};
|
|
667
|
+
return this.unwrap(this.api.GET("/meetings", { params: { query: params } }));
|
|
1658
668
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
*/
|
|
1662
|
-
async retrieve(userId) {
|
|
1663
|
-
return this.get(`/users/${userId}`);
|
|
669
|
+
async create(data) {
|
|
670
|
+
return this.unwrap(this.api.POST("/meetings", { body: data }));
|
|
1664
671
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
// src/resources/me.ts
|
|
1668
|
-
var MeResource = class extends BaseResource {
|
|
1669
|
-
/**
|
|
1670
|
-
* Get current user and organization info
|
|
1671
|
-
*/
|
|
1672
|
-
async retrieve() {
|
|
1673
|
-
return this.client.get("/me");
|
|
672
|
+
async getRecordingUrl(meetingId) {
|
|
673
|
+
return this.unwrap(this.api.GET("/meetings/{id}/recording-url", { params: { path: { id: meetingId } } }));
|
|
1674
674
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
// src/resources/organization.ts
|
|
1678
|
-
var OrganizationResource = class extends BaseResource {
|
|
1679
|
-
/**
|
|
1680
|
-
* Get organization details
|
|
1681
|
-
*/
|
|
1682
|
-
async retrieve() {
|
|
1683
|
-
return this.client.get("/organization");
|
|
675
|
+
async acceptTaskSuggestion(meetingId, suggestionId, data) {
|
|
676
|
+
return this.unwrap(this.api.POST("/meetings/{id}/task-suggestions/{suggestionId}/accept", { params: { path: { id: meetingId, suggestionId } }, body: data }));
|
|
1684
677
|
}
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
// src/resources/agents.ts
|
|
1688
|
-
var AgentsResource = class extends BaseResource {
|
|
1689
|
-
/**
|
|
1690
|
-
* List support agents
|
|
1691
|
-
*/
|
|
1692
|
-
async list() {
|
|
1693
|
-
return this.get("/agents");
|
|
678
|
+
async dismissTaskSuggestion(meetingId, suggestionId) {
|
|
679
|
+
return this.unwrap(this.api.POST("/meetings/{id}/task-suggestions/{suggestionId}/dismiss", { params: { path: { id: meetingId, suggestionId } } }));
|
|
1694
680
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
*/
|
|
1698
|
-
async retrieve(agentId) {
|
|
1699
|
-
return this.get(`/agents/${agentId}`);
|
|
681
|
+
async updateAttendee(meetingId, attendeeId, data) {
|
|
682
|
+
return this.unwrap(this.api.PUT("/meetings/{id}/attendees/{attendeeId}", { params: { path: { id: meetingId, attendeeId } }, body: data }));
|
|
1700
683
|
}
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
*/
|
|
1704
|
-
async create(params) {
|
|
1705
|
-
return this.post("/agents", params);
|
|
684
|
+
async transcribeGet(meetingId) {
|
|
685
|
+
return this.unwrap(this.api.GET("/meetings/{id}/transcribe", { params: { path: { id: meetingId } } }));
|
|
1706
686
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
* This is useful for sync operations where you want to ensure
|
|
1710
|
-
* an agent exists without duplicating.
|
|
1711
|
-
*
|
|
1712
|
-
* @param params - Agent data (email required, name optional)
|
|
1713
|
-
* @returns The existing or newly created agent
|
|
1714
|
-
*/
|
|
1715
|
-
async findOrCreate(params) {
|
|
1716
|
-
try {
|
|
1717
|
-
return await this.create(params);
|
|
1718
|
-
} catch (error) {
|
|
1719
|
-
if (error instanceof MantleAPIError && error.statusCode === 409) {
|
|
1720
|
-
const { agents } = await this.list();
|
|
1721
|
-
const existingAgent = agents.find(
|
|
1722
|
-
(agent) => agent.email.toLowerCase() === params.email.toLowerCase()
|
|
1723
|
-
);
|
|
1724
|
-
if (existingAgent) {
|
|
1725
|
-
return { agent: existingAgent };
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
throw error;
|
|
1729
|
-
}
|
|
687
|
+
async transcribePost(meetingId, data) {
|
|
688
|
+
return this.unwrap(this.api.POST("/meetings/{id}/transcribe", { params: { path: { id: meetingId } }, body: data }));
|
|
1730
689
|
}
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
// src/resources/docs.ts
|
|
1734
|
-
var DocsResource = class extends BaseResource {
|
|
1735
|
-
// ========== Collections ==========
|
|
1736
|
-
/**
|
|
1737
|
-
* List all doc collections
|
|
1738
|
-
*/
|
|
1739
|
-
async listCollections() {
|
|
1740
|
-
return this.get("/docs/collections");
|
|
690
|
+
async transcribeUpload(meetingId, data) {
|
|
691
|
+
return this.unwrap(this.api.POST("/meetings/{id}/transcribe/upload", { params: { path: { id: meetingId } }, body: data }));
|
|
1741
692
|
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
*/
|
|
1745
|
-
async retrieveCollection(collectionId) {
|
|
1746
|
-
return this.get(
|
|
1747
|
-
`/docs/collections/${collectionId}`
|
|
1748
|
-
);
|
|
693
|
+
async get(meetingId) {
|
|
694
|
+
return this.unwrap(this.api.GET("/meetings/{id}", { params: { path: { id: meetingId } } }));
|
|
1749
695
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
*/
|
|
1753
|
-
async createCollection(data) {
|
|
1754
|
-
return this.post("/docs/collections", data);
|
|
696
|
+
async update(meetingId, data) {
|
|
697
|
+
return this.unwrap(this.api.PUT("/meetings/{id}", { params: { path: { id: meetingId } }, body: data }));
|
|
1755
698
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
*/
|
|
1759
|
-
async updateCollection(collectionId, data) {
|
|
1760
|
-
return this.put(
|
|
1761
|
-
`/docs/collections/${collectionId}`,
|
|
1762
|
-
data
|
|
1763
|
-
);
|
|
699
|
+
async del(meetingId) {
|
|
700
|
+
return this.unwrap(this.api.DELETE("/meetings/{id}", { params: { path: { id: meetingId } } }));
|
|
1764
701
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
// src/resources/me.ts
|
|
705
|
+
var MeResource = class extends BaseResource {
|
|
706
|
+
async get() {
|
|
707
|
+
return this.unwrap(this.untypedApi.GET("/me", {}));
|
|
1770
708
|
}
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
async
|
|
1776
|
-
return this.
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// src/resources/metrics.ts
|
|
712
|
+
var MetricsResource = class extends BaseResource {
|
|
713
|
+
async sales(params) {
|
|
714
|
+
return this.unwrap(this.api.GET("/metrics/sales", { params: { query: params } }));
|
|
1777
715
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
*/
|
|
1781
|
-
async retrieveGroup(groupId) {
|
|
1782
|
-
return this.get(`/docs/groups/${groupId}`);
|
|
716
|
+
async activeInstalls(params) {
|
|
717
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/activeInstalls", { params: { query: params } }));
|
|
1783
718
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
*/
|
|
1787
|
-
async createGroup(data) {
|
|
1788
|
-
return this.post("/docs/groups", data);
|
|
719
|
+
async activeSubscriptions(params) {
|
|
720
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/activeSubscriptions", { params: { query: params } }));
|
|
1789
721
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
*/
|
|
1793
|
-
async updateGroup(groupId, data) {
|
|
1794
|
-
return this.put(`/docs/groups/${groupId}`, data);
|
|
722
|
+
async arpu(params) {
|
|
723
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/arpu", { params: { query: params } }));
|
|
1795
724
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
*/
|
|
1799
|
-
async deleteGroup(groupId) {
|
|
1800
|
-
return this._delete(`/docs/groups/${groupId}`);
|
|
725
|
+
async arr(params) {
|
|
726
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/arr", { params: { query: params } }));
|
|
1801
727
|
}
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
* List doc pages with optional filters
|
|
1805
|
-
*/
|
|
1806
|
-
async listPages(params) {
|
|
1807
|
-
const response = await this.get("/docs/pages", params);
|
|
1808
|
-
return {
|
|
1809
|
-
pages: response.pages || [],
|
|
1810
|
-
hasNextPage: response.hasNextPage || false,
|
|
1811
|
-
hasPreviousPage: response.hasPreviousPage || false
|
|
1812
|
-
};
|
|
728
|
+
async logoChurn(params) {
|
|
729
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/logoChurn", { params: { query: params } }));
|
|
1813
730
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
*/
|
|
1817
|
-
async retrievePage(pageId) {
|
|
1818
|
-
return this.get(`/docs/pages/${pageId}`);
|
|
731
|
+
async mrr(params) {
|
|
732
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/mrr", { params: { query: params } }));
|
|
1819
733
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
*/
|
|
1823
|
-
async createPage(data) {
|
|
1824
|
-
return this.post("/docs/pages", data);
|
|
734
|
+
async netInstalls(params) {
|
|
735
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/netInstalls", { params: { query: params } }));
|
|
1825
736
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
*/
|
|
1829
|
-
async updatePage(pageId, data) {
|
|
1830
|
-
return this.put(`/docs/pages/${pageId}`, data);
|
|
737
|
+
async netRevenue(params) {
|
|
738
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/netRevenue", { params: { query: params } }));
|
|
1831
739
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
*/
|
|
1835
|
-
async publishPage(pageId) {
|
|
1836
|
-
return this.post(`/docs/pages/${pageId}/publish`, {});
|
|
740
|
+
async netRevenueRetention(params) {
|
|
741
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/netRevenueRetention", { params: { query: params } }));
|
|
1837
742
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
*/
|
|
1841
|
-
async archivePage(pageId) {
|
|
1842
|
-
return this.post(`/docs/pages/${pageId}/archive`, {});
|
|
743
|
+
async payout(params) {
|
|
744
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/payout", { params: { query: params } }));
|
|
1843
745
|
}
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
*/
|
|
1847
|
-
async deletePage(pageId) {
|
|
1848
|
-
return this._delete(`/docs/pages/${pageId}`);
|
|
746
|
+
async predictedLtv(params) {
|
|
747
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/predictedLtv", { params: { query: params } }));
|
|
1849
748
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
* Get the full documentation tree structure
|
|
1853
|
-
*/
|
|
1854
|
-
async getTree() {
|
|
1855
|
-
return this.get("/docs/tree");
|
|
749
|
+
async revenueChurn(params) {
|
|
750
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/revenueChurn", { params: { query: params } }));
|
|
1856
751
|
}
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
* List all doc repositories
|
|
1860
|
-
*/
|
|
1861
|
-
async listRepositories(params) {
|
|
1862
|
-
const response = await this.get(
|
|
1863
|
-
"/docs/repositories",
|
|
1864
|
-
params
|
|
1865
|
-
);
|
|
1866
|
-
return {
|
|
1867
|
-
repositories: response.repositories || [],
|
|
1868
|
-
hasNextPage: response.hasNextPage || false,
|
|
1869
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1870
|
-
total: response.total,
|
|
1871
|
-
cursor: response.cursor
|
|
1872
|
-
};
|
|
752
|
+
async revenueRetention(params) {
|
|
753
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/revenueRetention", { params: { query: params } }));
|
|
1873
754
|
}
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
*/
|
|
1877
|
-
async retrieveRepository(repositoryId, params) {
|
|
1878
|
-
return this.get(
|
|
1879
|
-
`/docs/repositories/${repositoryId}`,
|
|
1880
|
-
params
|
|
1881
|
-
);
|
|
755
|
+
async usageEvent(params) {
|
|
756
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/usageEvent", { params: { query: params } }));
|
|
1882
757
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
// src/resources/entities.ts
|
|
1886
|
-
var EntitiesResource = class extends BaseResource {
|
|
1887
|
-
/**
|
|
1888
|
-
* Search across contacts and customers
|
|
1889
|
-
* Returns entities with a _type discriminator field
|
|
1890
|
-
*/
|
|
1891
|
-
async search(params) {
|
|
1892
|
-
const response = await this.get("/entities", params);
|
|
1893
|
-
return {
|
|
1894
|
-
entities: response.entities || [],
|
|
1895
|
-
hasNextPage: response.hasNextPage || false,
|
|
1896
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1897
|
-
total: response.total,
|
|
1898
|
-
cursor: response.cursor
|
|
1899
|
-
};
|
|
758
|
+
async usageMetric(params) {
|
|
759
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/usageMetric", { params: { query: params } }));
|
|
1900
760
|
}
|
|
1901
761
|
};
|
|
1902
762
|
|
|
1903
|
-
// src/resources/
|
|
1904
|
-
var
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
* This will create or update the value for the given key.
|
|
1908
|
-
*
|
|
1909
|
-
* @param params - The custom data parameters
|
|
1910
|
-
*/
|
|
1911
|
-
async set(params) {
|
|
1912
|
-
await this.put("/custom_data", params);
|
|
1913
|
-
}
|
|
1914
|
-
/**
|
|
1915
|
-
* Get custom data from a resource.
|
|
1916
|
-
*
|
|
1917
|
-
* @param params - Parameters identifying the custom data to retrieve
|
|
1918
|
-
* @returns The custom data value
|
|
1919
|
-
*/
|
|
1920
|
-
async getValue(params) {
|
|
1921
|
-
const { resourceType, resourceId, key } = params;
|
|
1922
|
-
return this.get(
|
|
1923
|
-
`/custom_data/${resourceType}/${resourceId}/${encodeURIComponent(key)}`
|
|
1924
|
-
);
|
|
1925
|
-
}
|
|
1926
|
-
/**
|
|
1927
|
-
* Delete custom data from a resource.
|
|
1928
|
-
*
|
|
1929
|
-
* @param params - Parameters identifying the custom data to delete
|
|
1930
|
-
*/
|
|
1931
|
-
async del(params) {
|
|
1932
|
-
const { resourceType, resourceId, key } = params;
|
|
1933
|
-
await this._delete(
|
|
1934
|
-
`/custom_data/${resourceType}/${resourceId}/${encodeURIComponent(key)}`
|
|
1935
|
-
);
|
|
763
|
+
// src/resources/organization.ts
|
|
764
|
+
var OrganizationResource = class extends BaseResource {
|
|
765
|
+
async list() {
|
|
766
|
+
return this.unwrap(this.api.GET("/organization"));
|
|
1936
767
|
}
|
|
1937
768
|
};
|
|
1938
769
|
|
|
1939
|
-
// src/resources/
|
|
1940
|
-
var
|
|
1941
|
-
/**
|
|
1942
|
-
* List timeline comments with optional filters and pagination
|
|
1943
|
-
*/
|
|
770
|
+
// src/resources/subscriptions.ts
|
|
771
|
+
var SubscriptionsResource = class extends BaseResource {
|
|
1944
772
|
async list(params) {
|
|
1945
|
-
|
|
1946
|
-
"/timeline_comments",
|
|
1947
|
-
params
|
|
1948
|
-
);
|
|
1949
|
-
return {
|
|
1950
|
-
timelineComments: response.timelineComments || [],
|
|
1951
|
-
hasNextPage: response.hasNextPage || false,
|
|
1952
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1953
|
-
total: response.total,
|
|
1954
|
-
cursor: response.cursor
|
|
1955
|
-
};
|
|
773
|
+
return this.unwrap(this.api.GET("/subscriptions", { params: { query: params } }));
|
|
1956
774
|
}
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
*/
|
|
1960
|
-
async retrieve(id) {
|
|
1961
|
-
return this.get(
|
|
1962
|
-
`/timeline_comments/${id}`
|
|
1963
|
-
);
|
|
1964
|
-
}
|
|
1965
|
-
/**
|
|
1966
|
-
* Create a new timeline comment
|
|
1967
|
-
*/
|
|
1968
|
-
async create(data) {
|
|
1969
|
-
return this.post("/timeline_comments", data);
|
|
1970
|
-
}
|
|
1971
|
-
/**
|
|
1972
|
-
* Update an existing timeline comment
|
|
1973
|
-
*/
|
|
1974
|
-
async update(id, data) {
|
|
1975
|
-
return this.put(
|
|
1976
|
-
`/timeline_comments/${id}`,
|
|
1977
|
-
data
|
|
1978
|
-
);
|
|
1979
|
-
}
|
|
1980
|
-
/**
|
|
1981
|
-
* Delete a timeline comment
|
|
1982
|
-
*/
|
|
1983
|
-
async del(id) {
|
|
1984
|
-
return this._delete(`/timeline_comments/${id}`);
|
|
775
|
+
async get(subscriptionId) {
|
|
776
|
+
return this.unwrap(this.api.GET("/subscriptions/{id}", { params: { path: { id: subscriptionId } } }));
|
|
1985
777
|
}
|
|
1986
778
|
};
|
|
1987
779
|
|
|
1988
|
-
// src/resources/
|
|
1989
|
-
var
|
|
1990
|
-
/**
|
|
1991
|
-
* List all lists
|
|
1992
|
-
*
|
|
1993
|
-
* @param params - Optional list parameters
|
|
1994
|
-
* @returns Paginated list of lists
|
|
1995
|
-
*/
|
|
780
|
+
// src/resources/synced-emails.ts
|
|
781
|
+
var SyncedEmailsResource = class extends BaseResource {
|
|
1996
782
|
async list(params) {
|
|
1997
|
-
|
|
1998
|
-
return {
|
|
1999
|
-
lists: response.lists || [],
|
|
2000
|
-
hasNextPage: response.hasNextPage || false,
|
|
2001
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
2002
|
-
total: response.total
|
|
2003
|
-
};
|
|
2004
|
-
}
|
|
2005
|
-
/**
|
|
2006
|
-
* Retrieve a specific list with its entities
|
|
2007
|
-
*
|
|
2008
|
-
* @param listId - The ID of the list
|
|
2009
|
-
* @param params - Optional parameters to filter entities
|
|
2010
|
-
* @returns The list with its entities
|
|
2011
|
-
*/
|
|
2012
|
-
async retrieve(listId, params) {
|
|
2013
|
-
const response = await this.get(`/lists/${listId}`, params);
|
|
2014
|
-
return {
|
|
2015
|
-
list: response.list,
|
|
2016
|
-
entities: response.entities || [],
|
|
2017
|
-
hasNextPage: response.hasNextPage || false,
|
|
2018
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
2019
|
-
total: response.total
|
|
2020
|
-
};
|
|
783
|
+
return this.unwrap(this.api.GET("/synced_emails", { params: { query: params } }));
|
|
2021
784
|
}
|
|
2022
|
-
/**
|
|
2023
|
-
* Create a new list
|
|
2024
|
-
*
|
|
2025
|
-
* @param data - List creation parameters
|
|
2026
|
-
* @returns The created list
|
|
2027
|
-
*/
|
|
2028
785
|
async create(data) {
|
|
2029
|
-
return this.
|
|
786
|
+
return this.unwrap(this.api.POST("/synced_emails", { body: data }));
|
|
2030
787
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
*
|
|
2034
|
-
* @param listId - The ID of the list to update
|
|
2035
|
-
* @param data - List update parameters
|
|
2036
|
-
* @returns The updated list
|
|
2037
|
-
*/
|
|
2038
|
-
async update(listId, data) {
|
|
2039
|
-
return this.put(`/lists/${listId}`, data);
|
|
788
|
+
async listMessages(syncedEmailId) {
|
|
789
|
+
return this.unwrap(this.api.GET("/synced_emails/{id}/messages", { params: { path: { id: syncedEmailId } } }));
|
|
2040
790
|
}
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
*
|
|
2044
|
-
* @param listId - The ID of the list to delete
|
|
2045
|
-
* @returns Delete confirmation
|
|
2046
|
-
*/
|
|
2047
|
-
async del(listId) {
|
|
2048
|
-
return this._delete(`/lists/${listId}`);
|
|
791
|
+
async createMessage(syncedEmailId, data) {
|
|
792
|
+
return this.unwrap(this.api.POST("/synced_emails/{id}/messages", { params: { path: { id: syncedEmailId } }, body: data }));
|
|
2049
793
|
}
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
*
|
|
2053
|
-
* @param listId - The ID of the list
|
|
2054
|
-
* @param data - IDs of customers and/or contacts to add
|
|
2055
|
-
* @returns Count of added and skipped entities
|
|
2056
|
-
*/
|
|
2057
|
-
async addEntities(listId, data) {
|
|
2058
|
-
return this.post(`/lists/${listId}/add`, data);
|
|
794
|
+
async get(syncedEmailId) {
|
|
795
|
+
return this.unwrap(this.api.GET("/synced_emails/{id}", { params: { path: { id: syncedEmailId } } }));
|
|
2059
796
|
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
* @returns Count of removed entities
|
|
2066
|
-
*/
|
|
2067
|
-
async removeEntities(listId, data) {
|
|
2068
|
-
return this.post(`/lists/${listId}/remove`, data);
|
|
797
|
+
async update(syncedEmailId, data) {
|
|
798
|
+
return this.unwrap(this.api.PUT("/synced_emails/{id}", { params: { path: { id: syncedEmailId } }, body: data }));
|
|
799
|
+
}
|
|
800
|
+
async del(syncedEmailId) {
|
|
801
|
+
return this.unwrap(this.api.DELETE("/synced_emails/{id}", { params: { path: { id: syncedEmailId } } }));
|
|
2069
802
|
}
|
|
2070
803
|
};
|
|
2071
804
|
|
|
2072
|
-
// src/resources/
|
|
2073
|
-
var
|
|
2074
|
-
/**
|
|
2075
|
-
* List journal entries with optional filters and pagination
|
|
2076
|
-
*/
|
|
805
|
+
// src/resources/tasks.ts
|
|
806
|
+
var TasksResource = class extends BaseResource {
|
|
2077
807
|
async list(params) {
|
|
2078
|
-
|
|
2079
|
-
"/journal_entries",
|
|
2080
|
-
params
|
|
2081
|
-
);
|
|
2082
|
-
return {
|
|
2083
|
-
journalEntries: response.journalEntries || [],
|
|
2084
|
-
hasNextPage: response.hasNextPage || false,
|
|
2085
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
2086
|
-
total: response.total,
|
|
2087
|
-
cursor: response.cursor
|
|
2088
|
-
};
|
|
2089
|
-
}
|
|
2090
|
-
/**
|
|
2091
|
-
* Retrieve a single journal entry by ID
|
|
2092
|
-
*/
|
|
2093
|
-
async retrieve(entryId) {
|
|
2094
|
-
return this.get(
|
|
2095
|
-
`/journal_entries/${entryId}`
|
|
2096
|
-
);
|
|
808
|
+
return this.unwrap(this.api.GET("/tasks", { params: { query: params } }));
|
|
2097
809
|
}
|
|
2098
|
-
/**
|
|
2099
|
-
* Create a new journal entry
|
|
2100
|
-
*/
|
|
2101
810
|
async create(data) {
|
|
2102
|
-
return this.
|
|
811
|
+
return this.unwrap(this.api.POST("/tasks", { body: data }));
|
|
2103
812
|
}
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
*/
|
|
2107
|
-
async update(entryId, data) {
|
|
2108
|
-
return this.put(
|
|
2109
|
-
`/journal_entries/${entryId}`,
|
|
2110
|
-
data
|
|
2111
|
-
);
|
|
813
|
+
async get(taskId) {
|
|
814
|
+
return this.unwrap(this.api.GET("/tasks/{id}", { params: { path: { id: taskId } } }));
|
|
2112
815
|
}
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
*/
|
|
2116
|
-
async del(entryId) {
|
|
2117
|
-
return this._delete(`/journal_entries/${entryId}`);
|
|
816
|
+
async update(taskId, data) {
|
|
817
|
+
return this.unwrap(this.api.PUT("/tasks/{id}", { params: { path: { id: taskId } }, body: data }));
|
|
2118
818
|
}
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
// src/resources/email-unsubscribe-groups.ts
|
|
2122
|
-
var EmailUnsubscribeGroupsResource = class extends BaseResource {
|
|
2123
|
-
/**
|
|
2124
|
-
* List all email unsubscribe groups
|
|
2125
|
-
*/
|
|
2126
|
-
async list(params) {
|
|
2127
|
-
const response = await this.get(
|
|
2128
|
-
"/email/unsubscribe_groups",
|
|
2129
|
-
params
|
|
2130
|
-
);
|
|
2131
|
-
return {
|
|
2132
|
-
unsubscribeGroups: response.unsubscribeGroups || [],
|
|
2133
|
-
hasNextPage: response.hasNextPage || false,
|
|
2134
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
2135
|
-
total: response.total,
|
|
2136
|
-
cursor: response.cursor
|
|
2137
|
-
};
|
|
819
|
+
async del(taskId) {
|
|
820
|
+
return this.unwrap(this.api.DELETE("/tasks/{id}", { params: { path: { id: taskId } } }));
|
|
2138
821
|
}
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
*/
|
|
2142
|
-
async retrieve(groupId) {
|
|
2143
|
-
return this.get(
|
|
2144
|
-
`/email/unsubscribe_groups/${groupId}`
|
|
2145
|
-
);
|
|
822
|
+
async getTodoItem(taskId, itemId) {
|
|
823
|
+
return this.unwrap(this.api.GET("/tasks/{id}/todo-items/{itemId}", { params: { path: { id: taskId, itemId } } }));
|
|
2146
824
|
}
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
* List members of an unsubscribe group
|
|
2150
|
-
*/
|
|
2151
|
-
async listMembers(groupId, params) {
|
|
2152
|
-
const response = await this.get(
|
|
2153
|
-
`/email/unsubscribe_groups/${groupId}/members`,
|
|
2154
|
-
params
|
|
2155
|
-
);
|
|
2156
|
-
return {
|
|
2157
|
-
members: response.members || [],
|
|
2158
|
-
hasNextPage: response.hasNextPage || false,
|
|
2159
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
2160
|
-
total: response.total,
|
|
2161
|
-
cursor: response.cursor
|
|
2162
|
-
};
|
|
825
|
+
async updateTodoItem(taskId, itemId, data) {
|
|
826
|
+
return this.unwrap(this.api.PUT("/tasks/{id}/todo-items/{itemId}", { params: { path: { id: taskId, itemId } }, body: data }));
|
|
2163
827
|
}
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
*/
|
|
2167
|
-
async addMembers(groupId, data) {
|
|
2168
|
-
return this.post(
|
|
2169
|
-
`/email/unsubscribe_groups/${groupId}/members`,
|
|
2170
|
-
data
|
|
2171
|
-
);
|
|
828
|
+
async deleteTodoItem(taskId, itemId) {
|
|
829
|
+
return this.unwrap(this.api.DELETE("/tasks/{id}/todo-items/{itemId}", { params: { path: { id: taskId, itemId } } }));
|
|
2172
830
|
}
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
*/
|
|
2176
|
-
async removeMembers(groupId, data) {
|
|
2177
|
-
return this._delete(
|
|
2178
|
-
`/email/unsubscribe_groups/${groupId}/members?emails=${encodeURIComponent(data.emails.join(","))}`
|
|
2179
|
-
);
|
|
831
|
+
async getTodoItems(taskId) {
|
|
832
|
+
return this.unwrap(this.api.GET("/tasks/{id}/todo-items", { params: { path: { id: taskId } } }));
|
|
2180
833
|
}
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
*/
|
|
2184
|
-
async removeMember(groupId, memberId) {
|
|
2185
|
-
return this._delete(
|
|
2186
|
-
`/email/unsubscribe_groups/${groupId}/members/${memberId}`
|
|
2187
|
-
);
|
|
834
|
+
async createTodoItems(taskId, data) {
|
|
835
|
+
return this.unwrap(this.api.POST("/tasks/{id}/todo-items", { params: { path: { id: taskId } }, body: data }));
|
|
2188
836
|
}
|
|
2189
837
|
};
|
|
2190
838
|
|
|
2191
|
-
// src/resources/
|
|
2192
|
-
var
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
* List flow extension actions
|
|
2196
|
-
*/
|
|
2197
|
-
async listActions(params) {
|
|
2198
|
-
const response = await this.get(
|
|
2199
|
-
"/flow/extensions/actions",
|
|
2200
|
-
params
|
|
2201
|
-
);
|
|
2202
|
-
return {
|
|
2203
|
-
actions: response.actions || [],
|
|
2204
|
-
hasNextPage: response.hasNextPage || false,
|
|
2205
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
2206
|
-
total: response.total,
|
|
2207
|
-
cursor: response.cursor
|
|
2208
|
-
};
|
|
839
|
+
// src/resources/tickets.ts
|
|
840
|
+
var TicketsResource = class extends BaseResource {
|
|
841
|
+
async list(params) {
|
|
842
|
+
return this.unwrap(this.api.GET("/tickets", { params: { query: params } }));
|
|
2209
843
|
}
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
*/
|
|
2213
|
-
async retrieveAction(actionId) {
|
|
2214
|
-
return this.get(
|
|
2215
|
-
`/flow/extensions/actions/${actionId}`
|
|
2216
|
-
);
|
|
844
|
+
async create(data) {
|
|
845
|
+
return this.unwrap(this.api.POST("/tickets", { body: data }));
|
|
2217
846
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
*/
|
|
2221
|
-
async createAction(data) {
|
|
2222
|
-
return this.post(
|
|
2223
|
-
"/flow/extensions/actions",
|
|
2224
|
-
data
|
|
2225
|
-
);
|
|
847
|
+
async listEvents(ticketId, params) {
|
|
848
|
+
return this.unwrap(this.api.GET("/tickets/{id}/events", { params: { path: { id: ticketId }, query: params } }));
|
|
2226
849
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
*/
|
|
2230
|
-
async updateAction(actionId, data) {
|
|
2231
|
-
return this.put(
|
|
2232
|
-
`/flow/extensions/actions/${actionId}`,
|
|
2233
|
-
data
|
|
2234
|
-
);
|
|
850
|
+
async createEvent(ticketId, data) {
|
|
851
|
+
return this.unwrap(this.api.POST("/tickets/{id}/events", { params: { path: { id: ticketId } }, body: data }));
|
|
2235
852
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
*/
|
|
2239
|
-
async deleteAction(actionId) {
|
|
2240
|
-
return this._delete(
|
|
2241
|
-
`/flow/extensions/actions/${actionId}`
|
|
2242
|
-
);
|
|
853
|
+
async updateEvent(ticketId, data) {
|
|
854
|
+
return this.unwrap(this.api.PUT("/tickets/{id}/events", { params: { path: { id: ticketId } }, body: data }));
|
|
2243
855
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
* Update a flow action run status
|
|
2247
|
-
* Used to report completion or failure of async action execution
|
|
2248
|
-
*/
|
|
2249
|
-
async updateActionRun(runId, data) {
|
|
2250
|
-
return this.put(`/flow/actions/runs/${runId}`, data);
|
|
856
|
+
async getLoop(ticketId, loopId) {
|
|
857
|
+
return this.unwrap(this.api.GET("/tickets/{id}/loops/{loopId}", { params: { path: { id: ticketId, loopId } } }));
|
|
2251
858
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
// src/resources/ai-agent-runs.ts
|
|
2255
|
-
var AiAgentRunsResource = class extends BaseResource {
|
|
2256
|
-
/**
|
|
2257
|
-
* Create a new AI agent run
|
|
2258
|
-
* Returns 202 Accepted as the run executes asynchronously
|
|
2259
|
-
* Poll the retrieve endpoint to check for completion
|
|
2260
|
-
*/
|
|
2261
|
-
async create(agentId, data) {
|
|
2262
|
-
return this.post(
|
|
2263
|
-
`/ai/agents/${agentId}/runs`,
|
|
2264
|
-
data || {}
|
|
2265
|
-
);
|
|
859
|
+
async listLoops(ticketId, params) {
|
|
860
|
+
return this.unwrap(this.api.GET("/tickets/{id}/loops", { params: { path: { id: ticketId }, query: params } }));
|
|
2266
861
|
}
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
* Use this to poll for completion after creating a run
|
|
2270
|
-
*/
|
|
2271
|
-
async retrieve(agentId, runId) {
|
|
2272
|
-
return this.get(
|
|
2273
|
-
`/ai/agents/${agentId}/runs/${runId}`
|
|
2274
|
-
);
|
|
862
|
+
async getMessage(ticketId, messageId) {
|
|
863
|
+
return this.unwrap(this.api.GET("/tickets/{id}/messages/{messageId}", { params: { path: { id: ticketId, messageId } } }));
|
|
2275
864
|
}
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
async
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
while (Date.now() - startTime < timeout) {
|
|
2291
|
-
const { run: currentRun } = await this.retrieve(agentId, run.id);
|
|
2292
|
-
if (currentRun.status === "completed" || currentRun.status === "error") {
|
|
2293
|
-
return currentRun;
|
|
2294
|
-
}
|
|
2295
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
2296
|
-
}
|
|
2297
|
-
throw new Error(
|
|
2298
|
-
`Agent run ${run.id} did not complete within ${timeout}ms timeout`
|
|
2299
|
-
);
|
|
865
|
+
async listMessages(ticketId, params) {
|
|
866
|
+
return this.unwrap(this.api.GET("/tickets/{id}/messages", { params: { path: { id: ticketId }, query: params } }));
|
|
867
|
+
}
|
|
868
|
+
async createMessage(ticketId, data) {
|
|
869
|
+
return this.unwrap(this.api.POST("/tickets/{id}/messages", { params: { path: { id: ticketId } }, body: data }));
|
|
870
|
+
}
|
|
871
|
+
async updateMessage(ticketId, data) {
|
|
872
|
+
return this.unwrap(this.api.PUT("/tickets/{id}/messages", { params: { path: { id: ticketId } }, body: data }));
|
|
873
|
+
}
|
|
874
|
+
async get(ticketId) {
|
|
875
|
+
return this.unwrap(this.api.GET("/tickets/{id}", { params: { path: { id: ticketId } } }));
|
|
876
|
+
}
|
|
877
|
+
async update(ticketId, data) {
|
|
878
|
+
return this.unwrap(this.api.PUT("/tickets/{id}", { params: { path: { id: ticketId } }, body: data }));
|
|
2300
879
|
}
|
|
2301
880
|
};
|
|
2302
881
|
|
|
2303
|
-
// src/resources/
|
|
2304
|
-
var
|
|
2305
|
-
/**
|
|
2306
|
-
* List meetings with optional filters and pagination
|
|
2307
|
-
*
|
|
2308
|
-
* @param params - Filter and pagination parameters
|
|
2309
|
-
* @returns Paginated list of meetings
|
|
2310
|
-
*
|
|
2311
|
-
* @example
|
|
2312
|
-
* ```typescript
|
|
2313
|
-
* // List all meetings
|
|
2314
|
-
* const { meetings } = await client.meetings.list();
|
|
2315
|
-
*
|
|
2316
|
-
* // List meetings for a specific deal
|
|
2317
|
-
* const { meetings } = await client.meetings.list({ dealId: 'deal_123' });
|
|
2318
|
-
*
|
|
2319
|
-
* // List meetings from Google Meet
|
|
2320
|
-
* const { meetings } = await client.meetings.list({ platform: 'google_meet' });
|
|
2321
|
-
* ```
|
|
2322
|
-
*/
|
|
882
|
+
// src/resources/timeline-comments.ts
|
|
883
|
+
var TimelineCommentsResource = class extends BaseResource {
|
|
2323
884
|
async list(params) {
|
|
2324
|
-
|
|
2325
|
-
return {
|
|
2326
|
-
meetings: response.meetings || [],
|
|
2327
|
-
hasNextPage: response.hasNextPage || false,
|
|
2328
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
2329
|
-
total: response.total,
|
|
2330
|
-
page: response.page,
|
|
2331
|
-
totalPages: response.totalPages
|
|
2332
|
-
};
|
|
2333
|
-
}
|
|
2334
|
-
/**
|
|
2335
|
-
* Retrieve a single meeting by ID with full transcript and attendee data
|
|
2336
|
-
*
|
|
2337
|
-
* @param meetingId - The meeting ID
|
|
2338
|
-
* @returns The meeting with all related data
|
|
2339
|
-
*
|
|
2340
|
-
* @example
|
|
2341
|
-
* ```typescript
|
|
2342
|
-
* const { meeting } = await client.meetings.retrieve('meeting_123');
|
|
2343
|
-
* console.log(meeting.transcript?.fullText);
|
|
2344
|
-
* ```
|
|
2345
|
-
*/
|
|
2346
|
-
async retrieve(meetingId) {
|
|
2347
|
-
return this.get(`/meetings/${meetingId}`);
|
|
885
|
+
return this.unwrap(this.api.GET("/timeline_comments", { params: { query: params } }));
|
|
2348
886
|
}
|
|
2349
|
-
/**
|
|
2350
|
-
* Create a new meeting
|
|
2351
|
-
*
|
|
2352
|
-
* Typically called when a recording starts in the browser extension.
|
|
2353
|
-
* The meeting can be created with optional transcript and attendee data,
|
|
2354
|
-
* or these can be added later via transcription.
|
|
2355
|
-
*
|
|
2356
|
-
* @param data - Meeting creation parameters
|
|
2357
|
-
* @returns The created meeting
|
|
2358
|
-
*
|
|
2359
|
-
* @example
|
|
2360
|
-
* ```typescript
|
|
2361
|
-
* // Create meeting when recording starts
|
|
2362
|
-
* const meeting = await client.meetings.create({
|
|
2363
|
-
* meetingData: {
|
|
2364
|
-
* platform: 'zoom',
|
|
2365
|
-
* title: 'Weekly Sync',
|
|
2366
|
-
* meetingUrl: 'https://zoom.us/j/123456789',
|
|
2367
|
-
* startTime: new Date().toISOString(),
|
|
2368
|
-
* recordingStatus: 'pending',
|
|
2369
|
-
* }
|
|
2370
|
-
* });
|
|
2371
|
-
*
|
|
2372
|
-
* // Create meeting with transcript (from local transcription)
|
|
2373
|
-
* const meeting = await client.meetings.create({
|
|
2374
|
-
* meetingData: { ... },
|
|
2375
|
-
* transcript: {
|
|
2376
|
-
* fullText: 'Hello, this is the transcript...',
|
|
2377
|
-
* utterances: [
|
|
2378
|
-
* { attendeeId: 'A', text: 'Hello', startTime: 0, endTime: 500 },
|
|
2379
|
-
* ],
|
|
2380
|
-
* },
|
|
2381
|
-
* attendees: [
|
|
2382
|
-
* { externalId: 'A', name: 'John Doe', email: 'john@example.com' },
|
|
2383
|
-
* ],
|
|
2384
|
-
* });
|
|
2385
|
-
* ```
|
|
2386
|
-
*/
|
|
2387
887
|
async create(data) {
|
|
2388
|
-
return this.
|
|
2389
|
-
}
|
|
2390
|
-
/**
|
|
2391
|
-
* Update an existing meeting
|
|
2392
|
-
*
|
|
2393
|
-
* @param meetingId - The meeting ID
|
|
2394
|
-
* @param data - Fields to update
|
|
2395
|
-
* @returns The updated meeting
|
|
2396
|
-
*
|
|
2397
|
-
* @example
|
|
2398
|
-
* ```typescript
|
|
2399
|
-
* // Update meeting title and link to a deal
|
|
2400
|
-
* const meeting = await client.meetings.update('meeting_123', {
|
|
2401
|
-
* title: 'Updated Meeting Title',
|
|
2402
|
-
* dealId: 'deal_456',
|
|
2403
|
-
* });
|
|
2404
|
-
* ```
|
|
2405
|
-
*/
|
|
2406
|
-
async update(meetingId, data) {
|
|
2407
|
-
return this.put(`/meetings/${meetingId}`, data);
|
|
2408
|
-
}
|
|
2409
|
-
/**
|
|
2410
|
-
* Archive (soft delete) a meeting
|
|
2411
|
-
*
|
|
2412
|
-
* @param meetingId - The meeting ID
|
|
2413
|
-
* @returns Success response
|
|
2414
|
-
*
|
|
2415
|
-
* @example
|
|
2416
|
-
* ```typescript
|
|
2417
|
-
* await client.meetings.del('meeting_123');
|
|
2418
|
-
* ```
|
|
2419
|
-
*/
|
|
2420
|
-
async del(meetingId) {
|
|
2421
|
-
return this._delete(`/meetings/${meetingId}`);
|
|
888
|
+
return this.unwrap(this.api.POST("/timeline_comments", { body: data }));
|
|
2422
889
|
}
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
*
|
|
2426
|
-
* Returns a pre-signed S3 URL that can be used to upload the recording
|
|
2427
|
-
* directly from the client. After uploading, call `startTranscription`
|
|
2428
|
-
* to begin server-side transcription.
|
|
2429
|
-
*
|
|
2430
|
-
* @param meetingId - The meeting ID
|
|
2431
|
-
* @param filename - Optional filename (default: "recording.webm")
|
|
2432
|
-
* @returns Upload URL and recording key
|
|
2433
|
-
*
|
|
2434
|
-
* @example
|
|
2435
|
-
* ```typescript
|
|
2436
|
-
* const { uploadUrl, recordingKey } = await client.meetings.getUploadUrl('meeting_123');
|
|
2437
|
-
*
|
|
2438
|
-
* // Upload the recording blob directly to S3
|
|
2439
|
-
* const response = await fetch(uploadUrl, {
|
|
2440
|
-
* method: 'PUT',
|
|
2441
|
-
* body: recordingBlob,
|
|
2442
|
-
* headers: { 'Content-Type': 'audio/webm' },
|
|
2443
|
-
* });
|
|
2444
|
-
*
|
|
2445
|
-
* // Then start transcription
|
|
2446
|
-
* await client.meetings.startTranscription('meeting_123', { recordingKey });
|
|
2447
|
-
* ```
|
|
2448
|
-
*/
|
|
2449
|
-
async getUploadUrl(meetingId, filename) {
|
|
2450
|
-
return this.post(
|
|
2451
|
-
`/meetings/${meetingId}/transcribe/upload`,
|
|
2452
|
-
filename ? { filename } : {}
|
|
2453
|
-
);
|
|
890
|
+
async get(commentId) {
|
|
891
|
+
return this.unwrap(this.api.GET("/timeline_comments/{id}", { params: { path: { id: commentId } } }));
|
|
2454
892
|
}
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
*
|
|
2458
|
-
* The recording must first be uploaded using the URL from `getUploadUrl`.
|
|
2459
|
-
* Transcription is processed asynchronously - poll `getTranscriptionStatus`
|
|
2460
|
-
* or retrieve the meeting to check for completion.
|
|
2461
|
-
*
|
|
2462
|
-
* @param meetingId - The meeting ID
|
|
2463
|
-
* @param params - Transcription parameters including the recording key
|
|
2464
|
-
* @returns The meeting with pending transcription status
|
|
2465
|
-
*
|
|
2466
|
-
* @example
|
|
2467
|
-
* ```typescript
|
|
2468
|
-
* // Start transcription after uploading
|
|
2469
|
-
* const meeting = await client.meetings.startTranscription('meeting_123', {
|
|
2470
|
-
* recordingKey: 'meeting-recordings/org-id/meeting-123/uuid/recording.webm',
|
|
2471
|
-
* });
|
|
2472
|
-
*
|
|
2473
|
-
* // meeting.recordingStatus will be 'pending' or 'processing'
|
|
2474
|
-
* ```
|
|
2475
|
-
*/
|
|
2476
|
-
async startTranscription(meetingId, params) {
|
|
2477
|
-
return this.post(`/meetings/${meetingId}/transcribe`, params);
|
|
893
|
+
async update(commentId, data) {
|
|
894
|
+
return this.unwrap(this.api.PUT("/timeline_comments/{id}", { params: { path: { id: commentId } }, body: data }));
|
|
2478
895
|
}
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
*
|
|
2482
|
-
* Use this to poll for transcription completion after calling
|
|
2483
|
-
* `startTranscription`.
|
|
2484
|
-
*
|
|
2485
|
-
* @param meetingId - The meeting ID
|
|
2486
|
-
* @returns Current transcription status
|
|
2487
|
-
*
|
|
2488
|
-
* @example
|
|
2489
|
-
* ```typescript
|
|
2490
|
-
* // Poll for completion
|
|
2491
|
-
* const poll = async () => {
|
|
2492
|
-
* const status = await client.meetings.getTranscriptionStatus('meeting_123');
|
|
2493
|
-
*
|
|
2494
|
-
* if (status.recordingStatus === 'ready') {
|
|
2495
|
-
* // Transcription complete - fetch the full meeting
|
|
2496
|
-
* const meeting = await client.meetings.retrieve('meeting_123');
|
|
2497
|
-
* return meeting;
|
|
2498
|
-
* }
|
|
2499
|
-
*
|
|
2500
|
-
* if (status.recordingStatus === 'failed') {
|
|
2501
|
-
* throw new Error('Transcription failed');
|
|
2502
|
-
* }
|
|
2503
|
-
*
|
|
2504
|
-
* // Still processing - wait and retry
|
|
2505
|
-
* await new Promise(r => setTimeout(r, 5000));
|
|
2506
|
-
* return poll();
|
|
2507
|
-
* };
|
|
2508
|
-
* ```
|
|
2509
|
-
*/
|
|
2510
|
-
async getTranscriptionStatus(meetingId) {
|
|
2511
|
-
return this.get(
|
|
2512
|
-
`/meetings/${meetingId}/transcribe`
|
|
2513
|
-
);
|
|
896
|
+
async del(commentId, params) {
|
|
897
|
+
return this.unwrap(this.api.DELETE("/timeline_comments/{id}", { params: { path: { id: commentId }, query: params } }));
|
|
2514
898
|
}
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
* @param meetingId - The meeting ID
|
|
2522
|
-
* @param attendeeId - The attendee ID (or externalId if useExternalId option is set)
|
|
2523
|
-
* @param data - Fields to update
|
|
2524
|
-
* @param options - Additional options
|
|
2525
|
-
* @param options.useExternalId - If true, treat attendeeId as the externalId (e.g., "A", "B" from browser extension)
|
|
2526
|
-
* @returns The updated attendee
|
|
2527
|
-
*
|
|
2528
|
-
* @example
|
|
2529
|
-
* ```typescript
|
|
2530
|
-
* // Update attendee name by server ID
|
|
2531
|
-
* const { attendee } = await client.meetings.updateAttendee(
|
|
2532
|
-
* 'meeting_123',
|
|
2533
|
-
* 'attendee_456',
|
|
2534
|
-
* { name: 'John Doe' }
|
|
2535
|
-
* );
|
|
2536
|
-
*
|
|
2537
|
-
* // Update attendee name by external ID (e.g., from browser extension)
|
|
2538
|
-
* const { attendee } = await client.meetings.updateAttendee(
|
|
2539
|
-
* 'meeting_123',
|
|
2540
|
-
* 'A',
|
|
2541
|
-
* { name: 'John Doe' },
|
|
2542
|
-
* { useExternalId: true }
|
|
2543
|
-
* );
|
|
2544
|
-
*
|
|
2545
|
-
* // Link attendee to a contact
|
|
2546
|
-
* const { attendee } = await client.meetings.updateAttendee(
|
|
2547
|
-
* 'meeting_123',
|
|
2548
|
-
* 'attendee_456',
|
|
2549
|
-
* { contactId: 'contact_789' }
|
|
2550
|
-
* );
|
|
2551
|
-
* ```
|
|
2552
|
-
*/
|
|
2553
|
-
async updateAttendee(meetingId, attendeeId, data, options) {
|
|
2554
|
-
const queryParams = options?.useExternalId ? "?useExternalId=true" : "";
|
|
2555
|
-
return this.put(
|
|
2556
|
-
`/meetings/${meetingId}/attendees/${attendeeId}${queryParams}`,
|
|
2557
|
-
data
|
|
2558
|
-
);
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
// src/resources/transactions.ts
|
|
902
|
+
var TransactionsResource = class extends BaseResource {
|
|
903
|
+
async list(params) {
|
|
904
|
+
return this.unwrap(this.api.GET("/transactions", { params: { query: params } }));
|
|
2559
905
|
}
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
*
|
|
2563
|
-
* Returns a temporary signed URL that can be used to play or download
|
|
2564
|
-
* the meeting recording. URLs expire after 1 hour.
|
|
2565
|
-
*
|
|
2566
|
-
* @param meetingId - The meeting ID
|
|
2567
|
-
* @returns Signed URL and expiration info
|
|
2568
|
-
*
|
|
2569
|
-
* @example
|
|
2570
|
-
* ```typescript
|
|
2571
|
-
* const { recordingUrl, expiresIn } = await client.meetings.getRecordingUrl('meeting_123');
|
|
2572
|
-
*
|
|
2573
|
-
* // Use the URL in an audio/video element
|
|
2574
|
-
* audioElement.src = recordingUrl;
|
|
2575
|
-
* ```
|
|
2576
|
-
*/
|
|
2577
|
-
async getRecordingUrl(meetingId) {
|
|
2578
|
-
return this.get(
|
|
2579
|
-
`/meetings/${meetingId}/recording-url`
|
|
2580
|
-
);
|
|
906
|
+
async get(transactionId) {
|
|
907
|
+
return this.unwrap(this.api.GET("/transactions/{id}", { params: { path: { id: transactionId } } }));
|
|
2581
908
|
}
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
*
|
|
2589
|
-
* @param meetingId - The meeting ID
|
|
2590
|
-
* @param suggestionId - The task suggestion ID
|
|
2591
|
-
* @param overrides - Optional fields to override on the created task
|
|
2592
|
-
* @returns The created task and updated suggestion
|
|
2593
|
-
*
|
|
2594
|
-
* @example
|
|
2595
|
-
* ```typescript
|
|
2596
|
-
* // Accept a suggestion as-is
|
|
2597
|
-
* const { task, suggestion } = await client.meetings.acceptTaskSuggestion(
|
|
2598
|
-
* 'meeting_123',
|
|
2599
|
-
* 'suggestion_456'
|
|
2600
|
-
* );
|
|
2601
|
-
*
|
|
2602
|
-
* // Accept with overrides
|
|
2603
|
-
* const { task } = await client.meetings.acceptTaskSuggestion(
|
|
2604
|
-
* 'meeting_123',
|
|
2605
|
-
* 'suggestion_456',
|
|
2606
|
-
* { title: 'Custom title', priority: 'high' }
|
|
2607
|
-
* );
|
|
2608
|
-
* ```
|
|
2609
|
-
*/
|
|
2610
|
-
async acceptTaskSuggestion(meetingId, suggestionId, overrides) {
|
|
2611
|
-
return this.post(
|
|
2612
|
-
`/meetings/${meetingId}/task-suggestions/${suggestionId}/accept`,
|
|
2613
|
-
overrides || {}
|
|
2614
|
-
);
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
// src/resources/usage-events.ts
|
|
912
|
+
var UsageEventsResource = class extends BaseResource {
|
|
913
|
+
async list(params) {
|
|
914
|
+
return this.unwrap(this.api.GET("/usage_events", { params: { query: params } }));
|
|
2615
915
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
*
|
|
2619
|
-
* Marks the suggestion as dismissed so it no longer appears as pending.
|
|
2620
|
-
*
|
|
2621
|
-
* @param meetingId - The meeting ID
|
|
2622
|
-
* @param suggestionId - The task suggestion ID
|
|
2623
|
-
* @returns Success response
|
|
2624
|
-
*
|
|
2625
|
-
* @example
|
|
2626
|
-
* ```typescript
|
|
2627
|
-
* await client.meetings.dismissTaskSuggestion('meeting_123', 'suggestion_456');
|
|
2628
|
-
* ```
|
|
2629
|
-
*/
|
|
2630
|
-
async dismissTaskSuggestion(meetingId, suggestionId) {
|
|
2631
|
-
return this.post(
|
|
2632
|
-
`/meetings/${meetingId}/task-suggestions/${suggestionId}/dismiss`
|
|
2633
|
-
);
|
|
916
|
+
async create(data) {
|
|
917
|
+
return this.unwrap(this.api.POST("/usage_events", { body: data }));
|
|
2634
918
|
}
|
|
2635
919
|
};
|
|
2636
920
|
|
|
2637
|
-
// src/resources/
|
|
2638
|
-
var
|
|
2639
|
-
/**
|
|
2640
|
-
* List synced email threads with optional filters and pagination
|
|
2641
|
-
*
|
|
2642
|
-
* @param params - Filter and pagination parameters
|
|
2643
|
-
* @returns Paginated list of synced email threads
|
|
2644
|
-
*
|
|
2645
|
-
* @example
|
|
2646
|
-
* ```typescript
|
|
2647
|
-
* // List all synced emails
|
|
2648
|
-
* const { syncedEmails } = await client.syncedEmails.list();
|
|
2649
|
-
*
|
|
2650
|
-
* // List synced emails for a specific customer
|
|
2651
|
-
* const { syncedEmails } = await client.syncedEmails.list({ customerId: 'cust_123' });
|
|
2652
|
-
*
|
|
2653
|
-
* // List Gmail synced emails
|
|
2654
|
-
* const { syncedEmails } = await client.syncedEmails.list({ source: 'gmail' });
|
|
2655
|
-
* ```
|
|
2656
|
-
*/
|
|
921
|
+
// src/resources/users.ts
|
|
922
|
+
var UsersResource = class extends BaseResource {
|
|
2657
923
|
async list(params) {
|
|
2658
|
-
|
|
2659
|
-
return {
|
|
2660
|
-
syncedEmails: response.syncedEmails || [],
|
|
2661
|
-
hasNextPage: response.hasNextPage || false,
|
|
2662
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
2663
|
-
total: response.total,
|
|
2664
|
-
page: response.page,
|
|
2665
|
-
totalPages: response.totalPages
|
|
2666
|
-
};
|
|
924
|
+
return this.unwrap(this.api.GET("/users", { params: { query: params } }));
|
|
2667
925
|
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
* console.log(syncedEmail.messages?.length);
|
|
2678
|
-
* ```
|
|
2679
|
-
*/
|
|
2680
|
-
async retrieve(syncedEmailId) {
|
|
2681
|
-
return this.get(`/synced_emails/${syncedEmailId}`);
|
|
926
|
+
async get(userId) {
|
|
927
|
+
return this.unwrap(this.api.GET("/users/{id}", { params: { path: { id: userId } } }));
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
// src/resources/webhooks.ts
|
|
932
|
+
var WebhooksResource = class extends BaseResource {
|
|
933
|
+
async list() {
|
|
934
|
+
return this.unwrap(this.api.GET("/webhooks"));
|
|
2682
935
|
}
|
|
2683
|
-
/**
|
|
2684
|
-
* Create or sync a synced email thread
|
|
2685
|
-
*
|
|
2686
|
-
* If `emailData.externalId` is provided, performs an upsert: updates the
|
|
2687
|
-
* existing thread and adds new messages if a thread with that externalId
|
|
2688
|
-
* already exists. Otherwise creates a new thread.
|
|
2689
|
-
*
|
|
2690
|
-
* @param data - Email thread and messages data
|
|
2691
|
-
* @returns The created or updated synced email thread
|
|
2692
|
-
*
|
|
2693
|
-
* @example
|
|
2694
|
-
* ```typescript
|
|
2695
|
-
* // Create a new thread (or upsert if externalId matches)
|
|
2696
|
-
* const syncedEmail = await client.syncedEmails.create({
|
|
2697
|
-
* emailData: {
|
|
2698
|
-
* externalId: 'gmail-thread-123',
|
|
2699
|
-
* subject: 'Sales Discussion',
|
|
2700
|
-
* source: 'gmail',
|
|
2701
|
-
* },
|
|
2702
|
-
* messages: [
|
|
2703
|
-
* {
|
|
2704
|
-
* externalId: 'msg-1',
|
|
2705
|
-
* fromEmail: 'prospect@example.com',
|
|
2706
|
-
* subject: 'Sales Discussion',
|
|
2707
|
-
* bodyText: 'Interested in your product...',
|
|
2708
|
-
* date: new Date().toISOString(),
|
|
2709
|
-
* isInbound: true,
|
|
2710
|
-
* },
|
|
2711
|
-
* ],
|
|
2712
|
-
* });
|
|
2713
|
-
* ```
|
|
2714
|
-
*/
|
|
2715
936
|
async create(data) {
|
|
2716
|
-
return this.
|
|
937
|
+
return this.unwrap(this.api.POST("/webhooks", { body: data }));
|
|
2717
938
|
}
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
*
|
|
2721
|
-
* @param syncedEmailId - The synced email thread ID
|
|
2722
|
-
* @param data - Fields to update
|
|
2723
|
-
* @returns The updated synced email thread
|
|
2724
|
-
*
|
|
2725
|
-
* @example
|
|
2726
|
-
* ```typescript
|
|
2727
|
-
* // Link email to a deal
|
|
2728
|
-
* const syncedEmail = await client.syncedEmails.update('se_123', {
|
|
2729
|
-
* dealId: 'deal_456',
|
|
2730
|
-
* });
|
|
2731
|
-
* ```
|
|
2732
|
-
*/
|
|
2733
|
-
async update(syncedEmailId, data) {
|
|
2734
|
-
return this.put(`/synced_emails/${syncedEmailId}`, data);
|
|
939
|
+
async update(webhookId, data) {
|
|
940
|
+
return this.unwrap(this.api.PUT("/webhooks/{id}", { params: { path: { id: webhookId } }, body: data }));
|
|
2735
941
|
}
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
*
|
|
2739
|
-
* @param syncedEmailId - The synced email thread ID
|
|
2740
|
-
* @returns Success response
|
|
2741
|
-
*
|
|
2742
|
-
* @example
|
|
2743
|
-
* ```typescript
|
|
2744
|
-
* await client.syncedEmails.del('se_123');
|
|
2745
|
-
* ```
|
|
2746
|
-
*/
|
|
2747
|
-
async del(syncedEmailId) {
|
|
2748
|
-
return this._delete(`/synced_emails/${syncedEmailId}`);
|
|
942
|
+
async del(webhookId) {
|
|
943
|
+
return this.unwrap(this.api.DELETE("/webhooks/{id}", { params: { path: { id: webhookId } } }));
|
|
2749
944
|
}
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
*
|
|
2757
|
-
* @example
|
|
2758
|
-
* ```typescript
|
|
2759
|
-
* const syncedEmail = await client.syncedEmails.addMessages('se_123', {
|
|
2760
|
-
* messages: [
|
|
2761
|
-
* {
|
|
2762
|
-
* externalId: 'msg-2',
|
|
2763
|
-
* fromEmail: 'you@company.com',
|
|
2764
|
-
* toEmails: ['prospect@example.com'],
|
|
2765
|
-
* subject: 'Re: Sales Discussion',
|
|
2766
|
-
* bodyText: 'Thanks for your interest...',
|
|
2767
|
-
* date: new Date().toISOString(),
|
|
2768
|
-
* isInbound: false,
|
|
2769
|
-
* },
|
|
2770
|
-
* ],
|
|
2771
|
-
* });
|
|
2772
|
-
* ```
|
|
2773
|
-
*/
|
|
2774
|
-
async addMessages(syncedEmailId, data) {
|
|
2775
|
-
return this.post(
|
|
2776
|
-
`/synced_emails/${syncedEmailId}/messages`,
|
|
2777
|
-
data
|
|
2778
|
-
);
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
// src/resources/agents.ts
|
|
948
|
+
var AgentsResource = class extends BaseResource {
|
|
949
|
+
async list() {
|
|
950
|
+
return this.unwrap(this.untypedApi.GET("/agents", {}));
|
|
2779
951
|
}
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
* const { messages } = await client.syncedEmails.getMessages('se_123');
|
|
2789
|
-
* ```
|
|
2790
|
-
*/
|
|
2791
|
-
async getMessages(syncedEmailId) {
|
|
2792
|
-
return this.get(
|
|
2793
|
-
`/synced_emails/${syncedEmailId}/messages`
|
|
2794
|
-
);
|
|
952
|
+
async get(agentId) {
|
|
953
|
+
return this.unwrap(this.untypedApi.GET("/agents/{id}", { params: { path: { id: agentId } } }));
|
|
954
|
+
}
|
|
955
|
+
async create(params) {
|
|
956
|
+
return this.unwrap(this.untypedApi.POST("/agents", { body: params }));
|
|
957
|
+
}
|
|
958
|
+
async findOrCreate(params) {
|
|
959
|
+
return this.unwrap(this.untypedApi.POST("/agents/find_or_create", { body: params }));
|
|
2795
960
|
}
|
|
2796
961
|
};
|
|
2797
962
|
|
|
2798
963
|
// src/client.ts
|
|
964
|
+
function createTimeoutSignal(ms) {
|
|
965
|
+
const controller = new AbortController();
|
|
966
|
+
setTimeout(() => controller.abort(), ms);
|
|
967
|
+
return controller.signal;
|
|
968
|
+
}
|
|
2799
969
|
var MantleCoreClient = class {
|
|
970
|
+
// @generated-resource-properties-end
|
|
2800
971
|
constructor(config) {
|
|
2801
|
-
if (!config.apiKey && !config.accessToken) {
|
|
972
|
+
if (!config.apiKey && !config.accessToken && !config.fetch) {
|
|
2802
973
|
throw new Error(
|
|
2803
|
-
"MantleCoreClient requires either apiKey or
|
|
974
|
+
"MantleCoreClient requires either apiKey, accessToken, or a custom fetch function"
|
|
2804
975
|
);
|
|
2805
976
|
}
|
|
2806
|
-
this.baseURL = config.baseURL || "https://api.heymantle.com/v1";
|
|
2807
977
|
this.apiKey = config.apiKey;
|
|
2808
978
|
this.accessToken = config.accessToken;
|
|
2809
|
-
|
|
2810
|
-
this.
|
|
979
|
+
const timeoutMs = config.timeout ?? 3e4;
|
|
980
|
+
this._api = createClient({
|
|
981
|
+
baseUrl: config.baseURL || "https://api.heymantle.com/v1",
|
|
982
|
+
headers: {
|
|
983
|
+
"Content-Type": "application/json"
|
|
984
|
+
},
|
|
985
|
+
...config.fetch ? { fetch: config.fetch } : {}
|
|
986
|
+
});
|
|
987
|
+
this._api.use({
|
|
988
|
+
onRequest: ({ request }) => {
|
|
989
|
+
const token = this.accessToken || this.apiKey;
|
|
990
|
+
if (token) {
|
|
991
|
+
request.headers.set("Authorization", `Bearer ${token}`);
|
|
992
|
+
}
|
|
993
|
+
return request;
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
if (timeoutMs > 0) {
|
|
997
|
+
this._api.use({
|
|
998
|
+
onRequest: ({ request }) => {
|
|
999
|
+
const signal = typeof AbortSignal !== "undefined" && "timeout" in AbortSignal ? AbortSignal.timeout(timeoutMs) : createTimeoutSignal(timeoutMs);
|
|
1000
|
+
return new Request(request, { signal });
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
2811
1004
|
if (config.middleware) {
|
|
2812
1005
|
for (const mw of config.middleware) {
|
|
2813
|
-
|
|
2814
|
-
this.middlewareManager.use(mw[0], mw[1]);
|
|
2815
|
-
} else {
|
|
2816
|
-
this.middlewareManager.use(mw);
|
|
2817
|
-
}
|
|
1006
|
+
this._api.use(mw);
|
|
2818
1007
|
}
|
|
2819
1008
|
}
|
|
2820
|
-
this.customers = new CustomersResource(this);
|
|
2821
|
-
this.contacts = new ContactsResource(this);
|
|
2822
|
-
this.subscriptions = new SubscriptionsResource(this);
|
|
2823
|
-
this.usageEvents = new UsageEventsResource(this);
|
|
2824
|
-
this.apps = new AppsResource(this);
|
|
2825
|
-
this.deals = new DealsResource(this);
|
|
2826
|
-
this.dealFlows = new DealFlowsResource(this);
|
|
2827
|
-
this.dealActivities = new DealActivitiesResource(this);
|
|
2828
|
-
this.tickets = new TicketsResource(this);
|
|
2829
|
-
this.channels = new ChannelsResource(this);
|
|
2830
|
-
this.flows = new FlowsResource(this);
|
|
2831
|
-
this.tasks = new TasksResource(this);
|
|
2832
|
-
this.webhooks = new WebhooksResource(this);
|
|
2833
|
-
this.companies = new CompaniesResource(this);
|
|
2834
|
-
this.customerSegments = new CustomerSegmentsResource(this);
|
|
2835
|
-
this.affiliates = new AffiliatesResource(this);
|
|
2836
|
-
this.affiliatePrograms = new AffiliateProgramsResource(this);
|
|
2837
1009
|
this.affiliateCommissions = new AffiliateCommissionsResource(this);
|
|
2838
1010
|
this.affiliatePayouts = new AffiliatePayoutsResource(this);
|
|
1011
|
+
this.affiliatePrograms = new AffiliateProgramsResource(this);
|
|
2839
1012
|
this.affiliateReferrals = new AffiliateReferralsResource(this);
|
|
1013
|
+
this.affiliates = new AffiliatesResource(this);
|
|
1014
|
+
this.aiAgentRuns = new AiAgentRunsResource(this);
|
|
1015
|
+
this.apps = new AppsResource(this);
|
|
1016
|
+
this.assistant = new AssistantResource(this);
|
|
1017
|
+
this.channels = new ChannelsResource(this);
|
|
2840
1018
|
this.charges = new ChargesResource(this);
|
|
2841
|
-
this.
|
|
2842
|
-
this.
|
|
2843
|
-
this.users = new UsersResource(this);
|
|
2844
|
-
this.me = new MeResource(this);
|
|
2845
|
-
this.organization = new OrganizationResource(this);
|
|
2846
|
-
this.agents = new AgentsResource(this);
|
|
2847
|
-
this.docs = new DocsResource(this);
|
|
2848
|
-
this.entities = new EntitiesResource(this);
|
|
1019
|
+
this.companies = new CompaniesResource(this);
|
|
1020
|
+
this.contacts = new ContactsResource(this);
|
|
2849
1021
|
this.customData = new CustomDataResource(this);
|
|
2850
|
-
this.
|
|
2851
|
-
this.
|
|
2852
|
-
this.
|
|
1022
|
+
this.customerSegments = new CustomerSegmentsResource(this);
|
|
1023
|
+
this.customers = new CustomersResource(this);
|
|
1024
|
+
this.dealActivities = new DealActivitiesResource(this);
|
|
1025
|
+
this.dealFlows = new DealFlowsResource(this);
|
|
1026
|
+
this.deals = new DealsResource(this);
|
|
1027
|
+
this.docs = new DocsResource(this);
|
|
2853
1028
|
this.emailUnsubscribeGroups = new EmailUnsubscribeGroupsResource(this);
|
|
1029
|
+
this.entities = new EntitiesResource(this);
|
|
2854
1030
|
this.flowExtensions = new FlowExtensionsResource(this);
|
|
2855
|
-
this.
|
|
1031
|
+
this.flows = new FlowsResource(this);
|
|
1032
|
+
this.journalEntries = new JournalEntriesResource(this);
|
|
1033
|
+
this.lists = new ListsResource(this);
|
|
2856
1034
|
this.meetings = new MeetingsResource(this);
|
|
1035
|
+
this.me = new MeResource(this);
|
|
1036
|
+
this.metrics = new MetricsResource(this);
|
|
1037
|
+
this.organization = new OrganizationResource(this);
|
|
1038
|
+
this.subscriptions = new SubscriptionsResource(this);
|
|
2857
1039
|
this.syncedEmails = new SyncedEmailsResource(this);
|
|
1040
|
+
this.tasks = new TasksResource(this);
|
|
1041
|
+
this.tickets = new TicketsResource(this);
|
|
1042
|
+
this.timelineComments = new TimelineCommentsResource(this);
|
|
1043
|
+
this.transactions = new TransactionsResource(this);
|
|
1044
|
+
this.usageEvents = new UsageEventsResource(this);
|
|
1045
|
+
this.users = new UsersResource(this);
|
|
1046
|
+
this.webhooks = new WebhooksResource(this);
|
|
1047
|
+
this.agents = new AgentsResource(this);
|
|
2858
1048
|
}
|
|
2859
1049
|
/**
|
|
2860
|
-
* Register
|
|
2861
|
-
*
|
|
2862
|
-
* @param middleware - The middleware function to register
|
|
2863
|
-
* @param options - Optional configuration (name, priority)
|
|
2864
|
-
* @returns this for chaining
|
|
2865
|
-
*
|
|
2866
|
-
* @example
|
|
2867
|
-
* ```typescript
|
|
2868
|
-
* client.use(async (ctx, next) => {
|
|
2869
|
-
* console.log('Request:', ctx.request.url);
|
|
2870
|
-
* await next();
|
|
2871
|
-
* console.log('Response:', ctx.response?.status);
|
|
2872
|
-
* });
|
|
2873
|
-
* ```
|
|
1050
|
+
* Register an openapi-fetch middleware
|
|
2874
1051
|
*/
|
|
2875
|
-
use(middleware
|
|
2876
|
-
this.
|
|
1052
|
+
use(middleware) {
|
|
1053
|
+
this._api.use(middleware);
|
|
2877
1054
|
return this;
|
|
2878
1055
|
}
|
|
2879
1056
|
/**
|
|
2880
|
-
* Remove a middleware
|
|
2881
|
-
*
|
|
2882
|
-
* @param name - The name of the middleware to remove
|
|
2883
|
-
* @returns true if removed, false if not found
|
|
1057
|
+
* Remove a registered middleware
|
|
2884
1058
|
*/
|
|
2885
|
-
|
|
2886
|
-
|
|
1059
|
+
eject(middleware) {
|
|
1060
|
+
this._api.eject(middleware);
|
|
1061
|
+
return this;
|
|
2887
1062
|
}
|
|
2888
1063
|
/**
|
|
2889
1064
|
* Update authentication credentials
|
|
2890
|
-
* Useful for middleware that needs to refresh tokens
|
|
2891
|
-
*
|
|
2892
|
-
* @param credentials - New credentials to set
|
|
2893
1065
|
*/
|
|
2894
1066
|
updateAuth(credentials) {
|
|
2895
1067
|
if (credentials.apiKey !== void 0) {
|
|
@@ -2899,234 +1071,43 @@ var MantleCoreClient = class {
|
|
|
2899
1071
|
this.accessToken = credentials.accessToken;
|
|
2900
1072
|
}
|
|
2901
1073
|
}
|
|
2902
|
-
/**
|
|
2903
|
-
* Performs a GET request to the API
|
|
2904
|
-
*/
|
|
2905
|
-
async get(endpoint, params) {
|
|
2906
|
-
const sanitizedParams = params ? sanitizeObject(params) : {};
|
|
2907
|
-
const query = toQueryString(sanitizedParams);
|
|
2908
|
-
const url = query ? `${endpoint}?${query}` : endpoint;
|
|
2909
|
-
return this.makeRequest(url, { method: "GET" });
|
|
2910
|
-
}
|
|
2911
|
-
/**
|
|
2912
|
-
* Performs a POST request to the API
|
|
2913
|
-
*/
|
|
2914
|
-
async post(endpoint, data) {
|
|
2915
|
-
const sanitizedData = data ? sanitizeObject(data) : {};
|
|
2916
|
-
return this.makeRequest(endpoint, {
|
|
2917
|
-
method: "POST",
|
|
2918
|
-
body: JSON.stringify(sanitizedData)
|
|
2919
|
-
});
|
|
2920
|
-
}
|
|
2921
|
-
/**
|
|
2922
|
-
* Performs a PUT request to the API
|
|
2923
|
-
*/
|
|
2924
|
-
async put(endpoint, data) {
|
|
2925
|
-
const sanitizedData = data ? sanitizeObject(data) : {};
|
|
2926
|
-
return this.makeRequest(endpoint, {
|
|
2927
|
-
method: "PUT",
|
|
2928
|
-
body: JSON.stringify(sanitizedData)
|
|
2929
|
-
});
|
|
2930
|
-
}
|
|
2931
|
-
/**
|
|
2932
|
-
* Performs a DELETE request to the API
|
|
2933
|
-
*/
|
|
2934
|
-
async delete(endpoint) {
|
|
2935
|
-
return this.makeRequest(endpoint, { method: "DELETE" });
|
|
2936
|
-
}
|
|
2937
|
-
/**
|
|
2938
|
-
* Makes an HTTP request to the API
|
|
2939
|
-
*/
|
|
2940
|
-
async makeRequest(endpoint, options) {
|
|
2941
|
-
if (this.middlewareManager.hasMiddleware()) {
|
|
2942
|
-
return this.makeRequestWithMiddleware(endpoint, options);
|
|
2943
|
-
}
|
|
2944
|
-
return this.executeRequest(endpoint, options);
|
|
2945
|
-
}
|
|
2946
|
-
/**
|
|
2947
|
-
* Execute request through middleware chain
|
|
2948
|
-
*/
|
|
2949
|
-
async makeRequestWithMiddleware(endpoint, options) {
|
|
2950
|
-
const request = {
|
|
2951
|
-
url: `${this.baseURL}${endpoint}`,
|
|
2952
|
-
method: options.method,
|
|
2953
|
-
headers: {
|
|
2954
|
-
Authorization: this.getAuthHeader(),
|
|
2955
|
-
"Content-Type": "application/json",
|
|
2956
|
-
...options.headers
|
|
2957
|
-
},
|
|
2958
|
-
body: options.body,
|
|
2959
|
-
endpoint
|
|
2960
|
-
};
|
|
2961
|
-
const ctx = {
|
|
2962
|
-
request,
|
|
2963
|
-
retry: false,
|
|
2964
|
-
retryCount: 0,
|
|
2965
|
-
maxRetries: 3,
|
|
2966
|
-
updateAuth: (credentials) => this.updateAuth(credentials)
|
|
2967
|
-
};
|
|
2968
|
-
const coreHandler = async () => {
|
|
2969
|
-
const controller = new AbortController();
|
|
2970
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2971
|
-
try {
|
|
2972
|
-
const response2 = await fetch(ctx.request.url, {
|
|
2973
|
-
method: ctx.request.method,
|
|
2974
|
-
body: ctx.request.body,
|
|
2975
|
-
headers: ctx.request.headers,
|
|
2976
|
-
signal: controller.signal
|
|
2977
|
-
});
|
|
2978
|
-
clearTimeout(timeoutId);
|
|
2979
|
-
if (!response2.ok) {
|
|
2980
|
-
await this.handleErrorResponse(response2);
|
|
2981
|
-
}
|
|
2982
|
-
const text = await response2.text();
|
|
2983
|
-
const data = text ? JSON.parse(text) : {};
|
|
2984
|
-
return {
|
|
2985
|
-
data,
|
|
2986
|
-
status: response2.status,
|
|
2987
|
-
headers: response2.headers
|
|
2988
|
-
};
|
|
2989
|
-
} catch (error) {
|
|
2990
|
-
clearTimeout(timeoutId);
|
|
2991
|
-
if (error instanceof MantleAPIError) {
|
|
2992
|
-
throw error;
|
|
2993
|
-
}
|
|
2994
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
2995
|
-
throw new MantleAPIError("Request timeout", 408);
|
|
2996
|
-
}
|
|
2997
|
-
throw new MantleAPIError(
|
|
2998
|
-
error instanceof Error ? error.message : "Unknown error occurred",
|
|
2999
|
-
500
|
|
3000
|
-
);
|
|
3001
|
-
}
|
|
3002
|
-
};
|
|
3003
|
-
const response = await this.middlewareManager.execute(ctx, coreHandler);
|
|
3004
|
-
return response.data;
|
|
3005
|
-
}
|
|
3006
|
-
/**
|
|
3007
|
-
* Direct request execution (no middleware)
|
|
3008
|
-
*/
|
|
3009
|
-
async executeRequest(endpoint, options) {
|
|
3010
|
-
const authHeader = this.getAuthHeader();
|
|
3011
|
-
const controller = new AbortController();
|
|
3012
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
3013
|
-
try {
|
|
3014
|
-
const response = await fetch(`${this.baseURL}${endpoint}`, {
|
|
3015
|
-
method: options.method,
|
|
3016
|
-
body: options.body,
|
|
3017
|
-
headers: {
|
|
3018
|
-
Authorization: authHeader,
|
|
3019
|
-
"Content-Type": "application/json",
|
|
3020
|
-
...options.headers
|
|
3021
|
-
},
|
|
3022
|
-
signal: controller.signal
|
|
3023
|
-
});
|
|
3024
|
-
clearTimeout(timeoutId);
|
|
3025
|
-
if (!response.ok) {
|
|
3026
|
-
await this.handleErrorResponse(response);
|
|
3027
|
-
}
|
|
3028
|
-
const text = await response.text();
|
|
3029
|
-
if (!text) {
|
|
3030
|
-
return {};
|
|
3031
|
-
}
|
|
3032
|
-
return JSON.parse(text);
|
|
3033
|
-
} catch (error) {
|
|
3034
|
-
clearTimeout(timeoutId);
|
|
3035
|
-
if (error instanceof MantleAPIError) {
|
|
3036
|
-
throw error;
|
|
3037
|
-
}
|
|
3038
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
3039
|
-
throw new MantleAPIError("Request timeout", 408);
|
|
3040
|
-
}
|
|
3041
|
-
throw new MantleAPIError(
|
|
3042
|
-
error instanceof Error ? error.message : "Unknown error occurred",
|
|
3043
|
-
500
|
|
3044
|
-
);
|
|
3045
|
-
}
|
|
3046
|
-
}
|
|
3047
|
-
/**
|
|
3048
|
-
* Gets the authorization header value
|
|
3049
|
-
*/
|
|
3050
|
-
getAuthHeader() {
|
|
3051
|
-
if (this.accessToken) {
|
|
3052
|
-
return `Bearer ${this.accessToken}`;
|
|
3053
|
-
}
|
|
3054
|
-
if (this.apiKey) {
|
|
3055
|
-
return `Bearer ${this.apiKey}`;
|
|
3056
|
-
}
|
|
3057
|
-
throw new MantleAuthenticationError(
|
|
3058
|
-
"Authentication not configured. Please set up API key or OAuth."
|
|
3059
|
-
);
|
|
3060
|
-
}
|
|
3061
|
-
/**
|
|
3062
|
-
* Handles error responses from the API
|
|
3063
|
-
*/
|
|
3064
|
-
async handleErrorResponse(response) {
|
|
3065
|
-
let errorData = {};
|
|
3066
|
-
try {
|
|
3067
|
-
const text = await response.text();
|
|
3068
|
-
if (text) {
|
|
3069
|
-
errorData = JSON.parse(text);
|
|
3070
|
-
}
|
|
3071
|
-
} catch {
|
|
3072
|
-
}
|
|
3073
|
-
const message = errorData.error || `API request failed: ${response.status}`;
|
|
3074
|
-
switch (response.status) {
|
|
3075
|
-
case 401:
|
|
3076
|
-
throw new MantleAuthenticationError(message);
|
|
3077
|
-
case 403:
|
|
3078
|
-
throw new MantlePermissionError(message);
|
|
3079
|
-
case 404:
|
|
3080
|
-
throw new MantleAPIError(message, 404, errorData.details);
|
|
3081
|
-
case 422:
|
|
3082
|
-
throw new MantleValidationError(message, errorData.details);
|
|
3083
|
-
case 429: {
|
|
3084
|
-
const retryAfter = response.headers.get("Retry-After");
|
|
3085
|
-
throw new MantleRateLimitError(
|
|
3086
|
-
message,
|
|
3087
|
-
retryAfter ? parseInt(retryAfter, 10) : void 0
|
|
3088
|
-
);
|
|
3089
|
-
}
|
|
3090
|
-
default:
|
|
3091
|
-
throw new MantleAPIError(message, response.status, errorData.details);
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
1074
|
};
|
|
3095
1075
|
|
|
3096
1076
|
// src/middleware/auth-refresh.ts
|
|
3097
1077
|
function createAuthRefreshMiddleware(options) {
|
|
3098
1078
|
const {
|
|
3099
1079
|
refreshToken,
|
|
1080
|
+
updateAuth,
|
|
3100
1081
|
onRefreshSuccess,
|
|
3101
1082
|
onRefreshFailed,
|
|
3102
1083
|
maxRefreshAttempts = 1
|
|
3103
1084
|
} = options;
|
|
3104
1085
|
let refreshAttempts = 0;
|
|
3105
|
-
return
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
} catch (error) {
|
|
3109
|
-
if (!(error instanceof MantleAuthenticationError)) {
|
|
3110
|
-
throw error;
|
|
3111
|
-
}
|
|
1086
|
+
return {
|
|
1087
|
+
async onResponse({ request, response }) {
|
|
1088
|
+
if (response.status !== 401) return void 0;
|
|
3112
1089
|
if (refreshAttempts >= maxRefreshAttempts) {
|
|
3113
1090
|
refreshAttempts = 0;
|
|
3114
|
-
|
|
1091
|
+
return void 0;
|
|
3115
1092
|
}
|
|
3116
1093
|
refreshAttempts++;
|
|
3117
1094
|
try {
|
|
3118
1095
|
const newToken = await refreshToken();
|
|
3119
|
-
|
|
3120
|
-
ctx.request.headers.Authorization = `Bearer ${newToken}`;
|
|
1096
|
+
updateAuth(newToken);
|
|
3121
1097
|
onRefreshSuccess?.(newToken);
|
|
3122
|
-
ctx.retry = true;
|
|
3123
1098
|
refreshAttempts = 0;
|
|
1099
|
+
const headers = new Headers(request.headers);
|
|
1100
|
+
headers.set("Authorization", `Bearer ${newToken}`);
|
|
1101
|
+
return fetch(new Request(request.url, {
|
|
1102
|
+
method: request.method,
|
|
1103
|
+
headers,
|
|
1104
|
+
body: request.body,
|
|
1105
|
+
signal: request.signal
|
|
1106
|
+
}));
|
|
3124
1107
|
} catch (refreshError) {
|
|
3125
1108
|
refreshAttempts = 0;
|
|
3126
1109
|
onRefreshFailed?.(refreshError);
|
|
3127
|
-
|
|
3128
|
-
"Authentication failed. Please re-authenticate."
|
|
3129
|
-
);
|
|
1110
|
+
return void 0;
|
|
3130
1111
|
}
|
|
3131
1112
|
}
|
|
3132
1113
|
};
|
|
@@ -3141,69 +1122,52 @@ var RateLimiter = class {
|
|
|
3141
1122
|
this.burstWindowMs = options.burstWindowMs;
|
|
3142
1123
|
this.throttleThreshold = options.throttleThreshold;
|
|
3143
1124
|
}
|
|
3144
|
-
/**
|
|
3145
|
-
* Prune timestamps older than the burst window
|
|
3146
|
-
*/
|
|
3147
1125
|
prune() {
|
|
3148
|
-
const
|
|
3149
|
-
const cutoff = now - this.burstWindowMs;
|
|
1126
|
+
const cutoff = Date.now() - this.burstWindowMs;
|
|
3150
1127
|
this.timestamps = this.timestamps.filter((ts) => ts > cutoff);
|
|
3151
1128
|
}
|
|
3152
|
-
/**
|
|
3153
|
-
* Get current usage statistics
|
|
3154
|
-
*/
|
|
3155
1129
|
getUsage() {
|
|
3156
1130
|
this.prune();
|
|
3157
|
-
const
|
|
3158
|
-
const oneMinuteAgo = now - 6e4;
|
|
1131
|
+
const oneMinuteAgo = Date.now() - 6e4;
|
|
3159
1132
|
const minuteUsage = this.timestamps.filter((ts) => ts > oneMinuteAgo).length;
|
|
3160
|
-
|
|
3161
|
-
return { minuteUsage, burstUsage };
|
|
1133
|
+
return { minuteUsage, burstUsage: this.timestamps.length };
|
|
3162
1134
|
}
|
|
3163
|
-
/**
|
|
3164
|
-
* Calculate the delay needed before the next request can be made
|
|
3165
|
-
* Returns 0 if no delay is needed
|
|
3166
|
-
*/
|
|
3167
1135
|
getDelay() {
|
|
3168
1136
|
const { minuteUsage, burstUsage } = this.getUsage();
|
|
3169
1137
|
const minuteThreshold = Math.floor(this.requestsPerMinute * this.throttleThreshold);
|
|
3170
1138
|
const burstThreshold = Math.floor(this.burstLimit * this.throttleThreshold);
|
|
1139
|
+
const now = Date.now();
|
|
3171
1140
|
if (minuteUsage >= minuteThreshold) {
|
|
3172
|
-
const now = Date.now();
|
|
3173
1141
|
const oneMinuteAgo = now - 6e4;
|
|
3174
|
-
const
|
|
3175
|
-
if (
|
|
3176
|
-
const delay =
|
|
3177
|
-
if (delay > 0)
|
|
3178
|
-
return delay;
|
|
3179
|
-
}
|
|
1142
|
+
const oldest = this.timestamps.find((ts) => ts > oneMinuteAgo);
|
|
1143
|
+
if (oldest) {
|
|
1144
|
+
const delay = oldest + 6e4 - now;
|
|
1145
|
+
if (delay > 0) return delay;
|
|
3180
1146
|
}
|
|
3181
1147
|
}
|
|
3182
1148
|
if (burstUsage >= burstThreshold) {
|
|
3183
|
-
const now = Date.now();
|
|
3184
1149
|
const burstCutoff = now - this.burstWindowMs;
|
|
3185
|
-
const
|
|
3186
|
-
if (
|
|
3187
|
-
const delay =
|
|
3188
|
-
if (delay > 0)
|
|
3189
|
-
return delay;
|
|
3190
|
-
}
|
|
1150
|
+
const oldest = this.timestamps.find((ts) => ts > burstCutoff);
|
|
1151
|
+
if (oldest) {
|
|
1152
|
+
const delay = oldest + this.burstWindowMs - now;
|
|
1153
|
+
if (delay > 0) return delay;
|
|
3191
1154
|
}
|
|
3192
1155
|
}
|
|
3193
1156
|
return 0;
|
|
3194
1157
|
}
|
|
3195
|
-
/**
|
|
3196
|
-
* Record a request timestamp
|
|
3197
|
-
*/
|
|
3198
1158
|
recordRequest() {
|
|
3199
1159
|
this.timestamps.push(Date.now());
|
|
3200
1160
|
}
|
|
3201
1161
|
};
|
|
3202
|
-
function calculateRetryDelay(
|
|
1162
|
+
function calculateRetryDelay(retryAfterHeader, retryCount, options) {
|
|
1163
|
+
if (retryAfterHeader) {
|
|
1164
|
+
const retryAfter = parseInt(retryAfterHeader, 10);
|
|
1165
|
+
if (!isNaN(retryAfter) && retryAfter > 0) {
|
|
1166
|
+
return retryAfter * 1e3;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
3203
1169
|
let delay;
|
|
3204
|
-
if (
|
|
3205
|
-
return retryAfter * 1e3;
|
|
3206
|
-
} else if (options.exponentialBackoff) {
|
|
1170
|
+
if (options.exponentialBackoff) {
|
|
3207
1171
|
delay = options.baseDelay * Math.pow(2, retryCount);
|
|
3208
1172
|
} else {
|
|
3209
1173
|
delay = options.baseDelay;
|
|
@@ -3227,37 +1191,42 @@ function createRateLimitMiddleware(options = {}) {
|
|
|
3227
1191
|
burstWindowMs = 3e5,
|
|
3228
1192
|
throttleThreshold = 0.9
|
|
3229
1193
|
} = options;
|
|
3230
|
-
const rateLimiter = enableThrottle ? new RateLimiter({
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
if (rateLimiter) {
|
|
3238
|
-
const delay = rateLimiter.getDelay();
|
|
3239
|
-
if (delay > 0) {
|
|
3240
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
3241
|
-
}
|
|
3242
|
-
}
|
|
3243
|
-
try {
|
|
3244
|
-
await next();
|
|
3245
|
-
rateLimiter?.recordRequest();
|
|
3246
|
-
} catch (error) {
|
|
3247
|
-
rateLimiter?.recordRequest();
|
|
3248
|
-
if (enableRetry && error instanceof MantleRateLimitError) {
|
|
3249
|
-
if (ctx.retryCount < maxRetries) {
|
|
3250
|
-
const delay = calculateRetryDelay(error.retryAfter, ctx.retryCount, {
|
|
3251
|
-
baseDelay,
|
|
3252
|
-
exponentialBackoff,
|
|
3253
|
-
jitter
|
|
3254
|
-
});
|
|
1194
|
+
const rateLimiter = enableThrottle ? new RateLimiter({ requestsPerMinute, burstLimit, burstWindowMs, throttleThreshold }) : null;
|
|
1195
|
+
let retryCount = 0;
|
|
1196
|
+
return {
|
|
1197
|
+
async onRequest({ request }) {
|
|
1198
|
+
if (rateLimiter) {
|
|
1199
|
+
const delay = rateLimiter.getDelay();
|
|
1200
|
+
if (delay > 0) {
|
|
3255
1201
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
3256
|
-
ctx.retry = true;
|
|
3257
|
-
return;
|
|
3258
1202
|
}
|
|
3259
1203
|
}
|
|
3260
|
-
|
|
1204
|
+
return request;
|
|
1205
|
+
},
|
|
1206
|
+
async onResponse({ request, response }) {
|
|
1207
|
+
rateLimiter?.recordRequest();
|
|
1208
|
+
if (response.status !== 429 || !enableRetry) return void 0;
|
|
1209
|
+
if (retryCount >= maxRetries) {
|
|
1210
|
+
retryCount = 0;
|
|
1211
|
+
return void 0;
|
|
1212
|
+
}
|
|
1213
|
+
const delay = calculateRetryDelay(
|
|
1214
|
+
response.headers.get("Retry-After"),
|
|
1215
|
+
retryCount,
|
|
1216
|
+
{ baseDelay, exponentialBackoff, jitter }
|
|
1217
|
+
);
|
|
1218
|
+
retryCount++;
|
|
1219
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1220
|
+
const retryResponse = await fetch(new Request(request.url, {
|
|
1221
|
+
method: request.method,
|
|
1222
|
+
headers: request.headers,
|
|
1223
|
+
body: request.body,
|
|
1224
|
+
signal: request.signal
|
|
1225
|
+
}));
|
|
1226
|
+
if (retryResponse.status !== 429) {
|
|
1227
|
+
retryCount = 0;
|
|
1228
|
+
}
|
|
1229
|
+
return retryResponse;
|
|
3261
1230
|
}
|
|
3262
1231
|
};
|
|
3263
1232
|
}
|
|
@@ -3268,6 +1237,7 @@ export {
|
|
|
3268
1237
|
AffiliateReferralsResource,
|
|
3269
1238
|
AffiliatesResource,
|
|
3270
1239
|
AgentsResource,
|
|
1240
|
+
AiAgentRunsResource,
|
|
3271
1241
|
AppsResource,
|
|
3272
1242
|
BaseResource,
|
|
3273
1243
|
ChannelsResource,
|
|
@@ -3281,8 +1251,12 @@ export {
|
|
|
3281
1251
|
DealFlowsResource,
|
|
3282
1252
|
DealsResource,
|
|
3283
1253
|
DocsResource,
|
|
1254
|
+
EmailUnsubscribeGroupsResource,
|
|
3284
1255
|
EntitiesResource,
|
|
1256
|
+
FlowExtensionsResource,
|
|
3285
1257
|
FlowsResource,
|
|
1258
|
+
JournalEntriesResource,
|
|
1259
|
+
ListsResource,
|
|
3286
1260
|
MantleAPIError,
|
|
3287
1261
|
MantleAuthenticationError,
|
|
3288
1262
|
MantleCoreClient,
|
|
@@ -3291,13 +1265,14 @@ export {
|
|
|
3291
1265
|
MantleRateLimitError,
|
|
3292
1266
|
MantleValidationError,
|
|
3293
1267
|
MeResource,
|
|
1268
|
+
MeetingsResource,
|
|
3294
1269
|
MetricsResource,
|
|
3295
|
-
MiddlewareManager,
|
|
3296
1270
|
OrganizationResource,
|
|
3297
1271
|
SubscriptionsResource,
|
|
3298
1272
|
SyncedEmailsResource,
|
|
3299
1273
|
TasksResource,
|
|
3300
1274
|
TicketsResource,
|
|
1275
|
+
TimelineCommentsResource,
|
|
3301
1276
|
TransactionsResource,
|
|
3302
1277
|
UsageEventsResource,
|
|
3303
1278
|
UsersResource,
|