@heymantle/core-api-client 0.1.26 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +626 -87
- package/dist/index.d.mts +21950 -4644
- package/dist/index.d.ts +21950 -4644
- package/dist/index.js +519 -2216
- package/dist/index.mjs +501 -2215
- 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,218 +56,124 @@ var BaseResource = class {
|
|
|
184
56
|
constructor(client) {
|
|
185
57
|
this.client = client;
|
|
186
58
|
}
|
|
187
|
-
get(
|
|
188
|
-
return this.client.
|
|
59
|
+
get api() {
|
|
60
|
+
return this.client._api;
|
|
189
61
|
}
|
|
190
|
-
|
|
191
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Access the API client without path type-checking.
|
|
64
|
+
* Used for endpoints not yet in the OpenAPI spec.
|
|
65
|
+
*/
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
get untypedApi() {
|
|
68
|
+
return this.client._api;
|
|
192
69
|
}
|
|
193
|
-
|
|
194
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Unwraps an openapi-fetch response, throwing typed errors on failure.
|
|
72
|
+
*/
|
|
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;
|
|
195
79
|
}
|
|
196
|
-
|
|
197
|
-
|
|
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
|
+
}
|
|
198
103
|
}
|
|
199
104
|
};
|
|
200
105
|
|
|
201
106
|
// src/resources/customers.ts
|
|
202
107
|
var CustomersResource = class extends BaseResource {
|
|
203
|
-
/**
|
|
204
|
-
* List customers with optional filters and pagination
|
|
205
|
-
*/
|
|
206
108
|
async list(params) {
|
|
207
|
-
|
|
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
|
-
};
|
|
109
|
+
return this.unwrap(this.api.GET("/customers", { params: { query: params } }));
|
|
215
110
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
*/
|
|
219
|
-
async retrieve(customerId, params) {
|
|
220
|
-
return this.get(
|
|
221
|
-
`/customers/${customerId}`,
|
|
222
|
-
params
|
|
223
|
-
);
|
|
111
|
+
async get(customerId) {
|
|
112
|
+
return this.unwrap(this.api.GET("/customers/{id}", { params: { path: { id: customerId } } }));
|
|
224
113
|
}
|
|
225
|
-
/**
|
|
226
|
-
* Create a new customer
|
|
227
|
-
*/
|
|
228
114
|
async create(data) {
|
|
229
|
-
return this.
|
|
115
|
+
return this.unwrap(this.api.POST("/customers", { body: data }));
|
|
230
116
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Update an existing customer
|
|
233
|
-
*/
|
|
234
117
|
async update(customerId, data) {
|
|
235
|
-
return this.
|
|
236
|
-
`/customers/${customerId}`,
|
|
237
|
-
data
|
|
238
|
-
);
|
|
118
|
+
return this.unwrap(this.api.PUT("/customers/{id}", { params: { path: { id: customerId } }, body: data }));
|
|
239
119
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Add tags to a customer
|
|
242
|
-
*/
|
|
243
120
|
async addTags(customerId, tags) {
|
|
244
|
-
return this.
|
|
245
|
-
`/customers/${customerId}/addTags`,
|
|
246
|
-
{ tags }
|
|
247
|
-
);
|
|
121
|
+
return this.unwrap(this.api.POST("/customers/{id}/addTags", { params: { path: { id: customerId } }, body: { tags } }));
|
|
248
122
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Remove tags from a customer
|
|
251
|
-
*/
|
|
252
123
|
async removeTags(customerId, tags) {
|
|
253
|
-
return this.
|
|
254
|
-
`/customers/${customerId}/removeTags`,
|
|
255
|
-
{ tags }
|
|
256
|
-
);
|
|
124
|
+
return this.unwrap(this.api.POST("/customers/{id}/removeTags", { params: { path: { id: customerId } }, body: { tags } }));
|
|
257
125
|
}
|
|
258
|
-
/**
|
|
259
|
-
* Get customer activity timeline
|
|
260
|
-
*/
|
|
261
126
|
async getTimeline(customerId, params) {
|
|
262
|
-
|
|
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
|
-
};
|
|
127
|
+
return this.unwrap(this.api.GET("/customers/{id}/timeline", { params: { path: { id: customerId }, query: params } }));
|
|
272
128
|
}
|
|
273
|
-
/**
|
|
274
|
-
* List account owners for a customer
|
|
275
|
-
*/
|
|
276
129
|
async listAccountOwners(customerId) {
|
|
277
|
-
return this.
|
|
278
|
-
`/customers/${customerId}/account_owners`
|
|
279
|
-
);
|
|
130
|
+
return this.unwrap(this.api.GET("/customers/{id}/account_owners", { params: { path: { id: customerId } } }));
|
|
280
131
|
}
|
|
281
|
-
/**
|
|
282
|
-
* Add an account owner to a customer
|
|
283
|
-
*/
|
|
284
132
|
async addAccountOwner(customerId, data) {
|
|
285
|
-
return this.
|
|
133
|
+
return this.unwrap(this.api.POST("/customers/{id}/account_owners", { params: { path: { id: customerId } }, body: data }));
|
|
286
134
|
}
|
|
287
|
-
/**
|
|
288
|
-
* Remove an account owner from a customer
|
|
289
|
-
*/
|
|
290
135
|
async removeAccountOwner(customerId, ownerId) {
|
|
291
|
-
return this.
|
|
292
|
-
`/customers/${customerId}/account_owners/${ownerId}`
|
|
293
|
-
);
|
|
136
|
+
return this.unwrap(this.api.DELETE("/customers/{id}/account_owners/{ownerId}", { params: { path: { id: customerId, ownerId } } }));
|
|
294
137
|
}
|
|
295
|
-
/**
|
|
296
|
-
* List custom fields
|
|
297
|
-
*/
|
|
298
138
|
async listCustomFields(params) {
|
|
299
|
-
return this.
|
|
300
|
-
"/customers/custom_fields",
|
|
301
|
-
params
|
|
302
|
-
);
|
|
139
|
+
return this.unwrap(this.api.GET("/customers/custom_fields", { params: { query: params } }));
|
|
303
140
|
}
|
|
304
|
-
/**
|
|
305
|
-
* Create a custom field
|
|
306
|
-
*/
|
|
307
141
|
async createCustomField(data) {
|
|
308
|
-
return this.
|
|
309
|
-
"/customers/custom_fields",
|
|
310
|
-
data
|
|
311
|
-
);
|
|
142
|
+
return this.unwrap(this.api.POST("/customers/custom_fields", { body: data }));
|
|
312
143
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
*/
|
|
316
|
-
async retrieveCustomField(fieldId) {
|
|
317
|
-
return this.get(
|
|
318
|
-
`/customers/custom_fields/${fieldId}`
|
|
319
|
-
);
|
|
144
|
+
async getCustomField(fieldId) {
|
|
145
|
+
return this.unwrap(this.api.GET("/customers/custom_fields/{id}", { params: { path: { id: fieldId } } }));
|
|
320
146
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Update a custom field
|
|
323
|
-
*/
|
|
324
147
|
async updateCustomField(fieldId, data) {
|
|
325
|
-
return this.
|
|
326
|
-
`/customers/custom_fields/${fieldId}`,
|
|
327
|
-
data
|
|
328
|
-
);
|
|
148
|
+
return this.unwrap(this.api.PUT("/customers/custom_fields/{id}", { params: { path: { id: fieldId } }, body: data }));
|
|
329
149
|
}
|
|
330
|
-
/**
|
|
331
|
-
* Delete a custom field
|
|
332
|
-
*/
|
|
333
150
|
async deleteCustomField(fieldId) {
|
|
334
|
-
return this.
|
|
335
|
-
`/customers/custom_fields/${fieldId}`
|
|
336
|
-
);
|
|
151
|
+
return this.unwrap(this.api.DELETE("/customers/custom_fields/{id}", { params: { path: { id: fieldId } } }));
|
|
337
152
|
}
|
|
338
153
|
};
|
|
339
154
|
|
|
340
155
|
// src/resources/contacts.ts
|
|
341
156
|
var ContactsResource = class extends BaseResource {
|
|
342
|
-
/**
|
|
343
|
-
* List contacts with optional filters and pagination
|
|
344
|
-
*/
|
|
345
157
|
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
|
-
};
|
|
158
|
+
return this.unwrap(this.api.GET("/contacts", { params: { query: params } }));
|
|
354
159
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
*/
|
|
358
|
-
async retrieve(contactId) {
|
|
359
|
-
return this.get(`/contacts/${contactId}`);
|
|
160
|
+
async get(contactId) {
|
|
161
|
+
return this.unwrap(this.api.GET("/contacts/{id}", { params: { path: { id: contactId } } }));
|
|
360
162
|
}
|
|
361
|
-
/**
|
|
362
|
-
* Create or update a contact.
|
|
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
163
|
async create(data) {
|
|
368
|
-
return this.
|
|
164
|
+
return this.unwrap(this.api.POST("/contacts", { body: data }));
|
|
369
165
|
}
|
|
370
|
-
/**
|
|
371
|
-
* Update an existing contact
|
|
372
|
-
*/
|
|
373
166
|
async update(contactId, data) {
|
|
374
|
-
return this.
|
|
167
|
+
return this.unwrap(this.api.PUT("/contacts/{id}", { params: { path: { id: contactId } }, body: data }));
|
|
375
168
|
}
|
|
376
|
-
/**
|
|
377
|
-
* Delete a contact
|
|
378
|
-
*/
|
|
379
169
|
async del(contactId) {
|
|
380
|
-
return this.
|
|
170
|
+
return this.unwrap(this.api.DELETE("/contacts/{id}", { params: { path: { id: contactId } } }));
|
|
381
171
|
}
|
|
382
|
-
/**
|
|
383
|
-
* Add tags to a contact
|
|
384
|
-
*/
|
|
385
172
|
async addTags(contactId, tags) {
|
|
386
|
-
return this.
|
|
387
|
-
`/contacts/${contactId}/addTags`,
|
|
388
|
-
{ tags }
|
|
389
|
-
);
|
|
173
|
+
return this.unwrap(this.api.POST("/contacts/{id}/addTags", { params: { path: { id: contactId } }, body: { tags } }));
|
|
390
174
|
}
|
|
391
|
-
/**
|
|
392
|
-
* Remove tags from a contact
|
|
393
|
-
*/
|
|
394
175
|
async removeTags(contactId, tags) {
|
|
395
|
-
return this.
|
|
396
|
-
`/contacts/${contactId}/removeTags`,
|
|
397
|
-
{ tags }
|
|
398
|
-
);
|
|
176
|
+
return this.unwrap(this.api.POST("/contacts/{id}/removeTags", { params: { path: { id: contactId } }, body: { tags } }));
|
|
399
177
|
}
|
|
400
178
|
};
|
|
401
179
|
|
|
@@ -405,25 +183,13 @@ var SubscriptionsResource = class extends BaseResource {
|
|
|
405
183
|
* List subscriptions with optional filters and pagination
|
|
406
184
|
*/
|
|
407
185
|
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
|
-
};
|
|
186
|
+
return this.unwrap(this.api.GET("/subscriptions", { params: { query: params } }));
|
|
419
187
|
}
|
|
420
188
|
/**
|
|
421
|
-
*
|
|
189
|
+
* Get a single subscription by ID
|
|
422
190
|
*/
|
|
423
|
-
async
|
|
424
|
-
return this.
|
|
425
|
-
`/subscriptions/${subscriptionId}`
|
|
426
|
-
);
|
|
191
|
+
async get(subscriptionId) {
|
|
192
|
+
return this.unwrap(this.api.GET("/subscriptions/{id}", { params: { path: { id: subscriptionId } } }));
|
|
427
193
|
}
|
|
428
194
|
};
|
|
429
195
|
|
|
@@ -433,18 +199,7 @@ var UsageEventsResource = class extends BaseResource {
|
|
|
433
199
|
* List usage events with optional filters and pagination
|
|
434
200
|
*/
|
|
435
201
|
async list(params) {
|
|
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
|
-
};
|
|
202
|
+
return this.unwrap(this.api.GET("/usage_events", { params: { query: params } }));
|
|
448
203
|
}
|
|
449
204
|
/**
|
|
450
205
|
* Create usage event(s)
|
|
@@ -468,549 +223,212 @@ var UsageEventsResource = class extends BaseResource {
|
|
|
468
223
|
* });
|
|
469
224
|
*/
|
|
470
225
|
async create(data) {
|
|
471
|
-
return this.
|
|
226
|
+
return this.unwrap(this.api.POST("/usage_events", { body: data }));
|
|
472
227
|
}
|
|
473
228
|
};
|
|
474
229
|
|
|
475
230
|
// src/resources/apps.ts
|
|
476
231
|
var AppsResource = class extends BaseResource {
|
|
477
|
-
|
|
478
|
-
* List all apps
|
|
479
|
-
*/
|
|
232
|
+
// Apps
|
|
480
233
|
async list(params) {
|
|
481
|
-
return this.
|
|
234
|
+
return this.unwrap(this.api.GET("/apps", { params: { query: params } }));
|
|
482
235
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
*/
|
|
486
|
-
async retrieve(appId) {
|
|
487
|
-
return this.get(`/apps/${appId}`);
|
|
236
|
+
async get(appId) {
|
|
237
|
+
return this.unwrap(this.api.GET("/apps/{id}", { params: { path: { id: appId } } }));
|
|
488
238
|
}
|
|
489
|
-
//
|
|
490
|
-
/**
|
|
491
|
-
* List plans for an app
|
|
492
|
-
*/
|
|
239
|
+
// Plans
|
|
493
240
|
async listPlans(appId, params) {
|
|
494
|
-
return this.
|
|
241
|
+
return this.unwrap(this.api.GET("/apps/{id}/plans", { params: { path: { id: appId }, query: params } }));
|
|
495
242
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
*/
|
|
499
|
-
async retrievePlan(appId, planId) {
|
|
500
|
-
return this.get(`/apps/${appId}/plans/${planId}`);
|
|
243
|
+
async getPlan(appId, planId) {
|
|
244
|
+
return this.unwrap(this.api.GET("/apps/{id}/plans/{planId}", { params: { path: { id: appId, planId } } }));
|
|
501
245
|
}
|
|
502
|
-
/**
|
|
503
|
-
* Create a new plan for an app
|
|
504
|
-
*/
|
|
505
246
|
async createPlan(appId, data) {
|
|
506
|
-
return this.
|
|
247
|
+
return this.unwrap(this.api.POST("/apps/{id}/plans", { params: { path: { id: appId } }, body: data }));
|
|
507
248
|
}
|
|
508
|
-
/**
|
|
509
|
-
* Update an existing plan
|
|
510
|
-
*/
|
|
511
249
|
async updatePlan(appId, planId, data) {
|
|
512
|
-
return this.
|
|
250
|
+
return this.unwrap(this.api.PUT("/apps/{id}/plans/{planId}", { params: { path: { id: appId, planId } }, body: data }));
|
|
513
251
|
}
|
|
514
|
-
/**
|
|
515
|
-
* Archive a plan
|
|
516
|
-
*/
|
|
517
252
|
async archivePlan(appId, planId) {
|
|
518
|
-
return this.
|
|
519
|
-
`/apps/${appId}/plans/${planId}/archive`,
|
|
520
|
-
{}
|
|
521
|
-
);
|
|
253
|
+
return this.unwrap(this.api.PUT("/apps/{id}/plans/{planId}/archive", { params: { path: { id: appId, planId } } }));
|
|
522
254
|
}
|
|
523
|
-
/**
|
|
524
|
-
* Unarchive a plan
|
|
525
|
-
*/
|
|
526
255
|
async unarchivePlan(appId, planId) {
|
|
527
|
-
return this.
|
|
528
|
-
`/apps/${appId}/plans/${planId}/unarchive`,
|
|
529
|
-
{}
|
|
530
|
-
);
|
|
256
|
+
return this.unwrap(this.api.PUT("/apps/{id}/plans/{planId}/unarchive", { params: { path: { id: appId, planId } } }));
|
|
531
257
|
}
|
|
532
|
-
//
|
|
533
|
-
/**
|
|
534
|
-
* List features for an app
|
|
535
|
-
*/
|
|
258
|
+
// Features
|
|
536
259
|
async listFeatures(appId) {
|
|
537
|
-
return this.
|
|
260
|
+
return this.unwrap(this.api.GET("/apps/{appId}/plans/features", { params: { path: { appId } } }));
|
|
538
261
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
*/
|
|
542
|
-
async retrieveFeature(appId, featureId) {
|
|
543
|
-
return this.get(
|
|
544
|
-
`/apps/${appId}/plans/features/${featureId}`
|
|
545
|
-
);
|
|
262
|
+
async getFeature(appId, featureId) {
|
|
263
|
+
return this.unwrap(this.api.GET("/apps/{appId}/plans/features/{featureId}", { params: { path: { appId, featureId } } }));
|
|
546
264
|
}
|
|
547
|
-
/**
|
|
548
|
-
* Create a new feature for an app
|
|
549
|
-
*/
|
|
550
265
|
async createFeature(appId, data) {
|
|
551
|
-
return this.
|
|
552
|
-
`/apps/${appId}/plans/features`,
|
|
553
|
-
data
|
|
554
|
-
);
|
|
266
|
+
return this.unwrap(this.api.POST("/apps/{appId}/plans/features", { params: { path: { appId } }, body: data }));
|
|
555
267
|
}
|
|
556
|
-
/**
|
|
557
|
-
* Update an existing feature
|
|
558
|
-
*/
|
|
559
268
|
async updateFeature(appId, featureId, data) {
|
|
560
|
-
return this.
|
|
561
|
-
`/apps/${appId}/plans/features/${featureId}`,
|
|
562
|
-
data
|
|
563
|
-
);
|
|
269
|
+
return this.unwrap(this.api.PUT("/apps/{appId}/plans/features/{featureId}", { params: { path: { appId, featureId } }, body: data }));
|
|
564
270
|
}
|
|
565
|
-
/**
|
|
566
|
-
* Delete a feature
|
|
567
|
-
*/
|
|
568
271
|
async deleteFeature(appId, featureId) {
|
|
569
|
-
return this.
|
|
570
|
-
`/apps/${appId}/plans/features/${featureId}`
|
|
571
|
-
);
|
|
272
|
+
return this.unwrap(this.api.DELETE("/apps/{appId}/plans/features/{featureId}", { params: { path: { appId, featureId } } }));
|
|
572
273
|
}
|
|
573
|
-
//
|
|
574
|
-
/**
|
|
575
|
-
* List reviews for an app
|
|
576
|
-
*/
|
|
274
|
+
// Reviews
|
|
577
275
|
async listReviews(appId) {
|
|
578
|
-
return this.
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Retrieve a single review
|
|
582
|
-
*/
|
|
583
|
-
async retrieveReview(appId, reviewId) {
|
|
584
|
-
return this.get(`/apps/${appId}/reviews/${reviewId}`);
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Create a new review for an app
|
|
588
|
-
*/
|
|
589
|
-
async createReview(appId, data) {
|
|
590
|
-
return this.post(`/apps/${appId}/reviews`, data);
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Update an existing review
|
|
594
|
-
*/
|
|
595
|
-
async updateReview(appId, reviewId, data) {
|
|
596
|
-
return this.put(
|
|
597
|
-
`/apps/${appId}/reviews/${reviewId}`,
|
|
598
|
-
data
|
|
599
|
-
);
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Delete a review
|
|
603
|
-
*/
|
|
604
|
-
async deleteReview(appId, reviewId) {
|
|
605
|
-
return this._delete(`/apps/${appId}/reviews/${reviewId}`);
|
|
276
|
+
return this.unwrap(this.api.GET("/apps/{id}/reviews", { params: { path: { id: appId } } }));
|
|
606
277
|
}
|
|
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
|
-
);
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* Get property keys for a specific event name
|
|
618
|
-
*/
|
|
619
|
-
async listPropertyKeys(appId, eventName) {
|
|
620
|
-
return this.get(
|
|
621
|
-
`/apps/${appId}/usage_events/property_keys`,
|
|
622
|
-
{ eventName }
|
|
623
|
-
);
|
|
278
|
+
async getReview(appId, reviewId) {
|
|
279
|
+
return this.unwrap(this.api.GET("/apps/{id}/reviews/{reviewId}", { params: { path: { id: appId, reviewId } } }));
|
|
624
280
|
}
|
|
625
|
-
//
|
|
626
|
-
/**
|
|
627
|
-
* List usage metrics for an app
|
|
628
|
-
*/
|
|
281
|
+
// Usage Metrics
|
|
629
282
|
async listUsageMetrics(appId) {
|
|
630
|
-
return this.
|
|
631
|
-
`/apps/${appId}/usage_metrics`
|
|
632
|
-
);
|
|
283
|
+
return this.unwrap(this.api.GET("/apps/{id}/usage_metrics", { params: { path: { id: appId } } }));
|
|
633
284
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
*/
|
|
637
|
-
async retrieveUsageMetric(appId, usageMetricId) {
|
|
638
|
-
return this.get(
|
|
639
|
-
`/apps/${appId}/usage_metrics/${usageMetricId}`
|
|
640
|
-
);
|
|
285
|
+
async getUsageMetric(appId, usageMetricId) {
|
|
286
|
+
return this.unwrap(this.api.GET("/apps/{id}/usage_metrics/{usageMetricId}", { params: { path: { id: appId, usageMetricId } } }));
|
|
641
287
|
}
|
|
642
|
-
/**
|
|
643
|
-
* Create a new usage metric for an app
|
|
644
|
-
*/
|
|
645
288
|
async createUsageMetric(appId, data) {
|
|
646
|
-
return this.
|
|
647
|
-
`/apps/${appId}/usage_metrics`,
|
|
648
|
-
data
|
|
649
|
-
);
|
|
289
|
+
return this.unwrap(this.api.POST("/apps/{id}/usage_metrics", { params: { path: { id: appId } }, body: data }));
|
|
650
290
|
}
|
|
651
|
-
/**
|
|
652
|
-
* Update an existing usage metric
|
|
653
|
-
*/
|
|
654
291
|
async updateUsageMetric(appId, usageMetricId, data) {
|
|
655
|
-
return this.
|
|
656
|
-
`/apps/${appId}/usage_metrics/${usageMetricId}`,
|
|
657
|
-
data
|
|
658
|
-
);
|
|
292
|
+
return this.unwrap(this.api.PUT("/apps/{id}/usage_metrics/{usageMetricId}", { params: { path: { id: appId, usageMetricId } }, body: data }));
|
|
659
293
|
}
|
|
660
|
-
/**
|
|
661
|
-
* Delete a usage metric
|
|
662
|
-
*/
|
|
663
294
|
async deleteUsageMetric(appId, usageMetricId) {
|
|
664
|
-
return this.
|
|
665
|
-
`/apps/${appId}/usage_metrics/${usageMetricId}`
|
|
666
|
-
);
|
|
295
|
+
return this.unwrap(this.api.DELETE("/apps/{id}/usage_metrics/{usageMetricId}", { params: { path: { id: appId, usageMetricId } } }));
|
|
667
296
|
}
|
|
668
|
-
//
|
|
669
|
-
/**
|
|
670
|
-
* List app events
|
|
671
|
-
*/
|
|
297
|
+
// App Events
|
|
672
298
|
async listAppEvents(appId, params) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
);
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
681
|
-
total: response.total,
|
|
682
|
-
cursor: response.cursor
|
|
683
|
-
};
|
|
299
|
+
return this.unwrap(this.api.GET("/apps/{id}/app_events", { params: { path: { id: appId }, query: params } }));
|
|
300
|
+
}
|
|
301
|
+
async getAppEvent(appId, appEventId) {
|
|
302
|
+
return this.unwrap(this.api.GET("/apps/{id}/app_events/{appEventId}", { params: { path: { id: appId, appEventId } } }));
|
|
303
|
+
}
|
|
304
|
+
async createAppEvent(appId, data) {
|
|
305
|
+
return this.unwrap(this.api.POST("/apps/{id}/app_events", { params: { path: { id: appId } }, body: data }));
|
|
684
306
|
}
|
|
685
307
|
};
|
|
686
308
|
|
|
687
309
|
// src/resources/deals.ts
|
|
688
310
|
var DealsResource = class extends BaseResource {
|
|
689
|
-
/**
|
|
690
|
-
* List deals with optional filters and pagination
|
|
691
|
-
*/
|
|
692
311
|
async list(params) {
|
|
693
|
-
|
|
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
|
-
};
|
|
312
|
+
return this.unwrap(this.api.GET("/deals", { params: { query: params } }));
|
|
701
313
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
*/
|
|
705
|
-
async retrieve(dealId) {
|
|
706
|
-
return this.get(`/deals/${dealId}`);
|
|
314
|
+
async get(dealId) {
|
|
315
|
+
return this.unwrap(this.api.GET("/deals/{id}", { params: { path: { id: dealId } } }));
|
|
707
316
|
}
|
|
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
317
|
async create(data) {
|
|
747
|
-
return this.
|
|
318
|
+
return this.unwrap(this.api.POST("/deals", { body: data }));
|
|
748
319
|
}
|
|
749
|
-
/**
|
|
750
|
-
* Update an existing deal
|
|
751
|
-
*
|
|
752
|
-
* **Updating Customer Association:**
|
|
753
|
-
* There are three ways to change or update the customer (use only one):
|
|
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
320
|
async update(dealId, data) {
|
|
782
|
-
return this.
|
|
321
|
+
return this.unwrap(this.api.PUT("/deals/{id}", { params: { path: { id: dealId } }, body: data }));
|
|
783
322
|
}
|
|
784
|
-
/**
|
|
785
|
-
* Archive (soft delete) a deal
|
|
786
|
-
*/
|
|
787
323
|
async del(dealId) {
|
|
788
|
-
return this.
|
|
324
|
+
return this.unwrap(this.api.DELETE("/deals/{id}", { params: { path: { id: dealId } } }));
|
|
789
325
|
}
|
|
790
|
-
/**
|
|
791
|
-
* Get deal activity timeline
|
|
792
|
-
*/
|
|
793
326
|
async timeline(dealId) {
|
|
794
|
-
|
|
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
|
-
};
|
|
327
|
+
return this.unwrap(this.api.GET("/deals/{id}/timeline", { params: { path: { id: dealId } } }));
|
|
803
328
|
}
|
|
804
|
-
/**
|
|
805
|
-
* List deal events
|
|
806
|
-
*/
|
|
807
329
|
async listEvents(dealId) {
|
|
808
|
-
|
|
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
|
-
};
|
|
330
|
+
return this.unwrap(this.api.GET("/deals/{id}/events", { params: { path: { id: dealId } } }));
|
|
818
331
|
}
|
|
819
|
-
/**
|
|
820
|
-
* Create a deal event
|
|
821
|
-
*
|
|
822
|
-
* Creates an event on a deal. If `dealStageId` is provided, the deal will
|
|
823
|
-
* progress to that stage. If `dealActivityId` is provided and the activity
|
|
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
332
|
async createEvent(dealId, data) {
|
|
837
|
-
return this.
|
|
333
|
+
return this.unwrap(this.api.POST("/deals/{id}/events", { params: { path: { id: dealId } }, body: data }));
|
|
838
334
|
}
|
|
839
335
|
};
|
|
840
336
|
|
|
841
337
|
// src/resources/deal-flows.ts
|
|
842
338
|
var DealFlowsResource = class extends BaseResource {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
*/
|
|
846
|
-
async list() {
|
|
847
|
-
return this.get("/deal_flows");
|
|
339
|
+
async list(params) {
|
|
340
|
+
return this.unwrap(this.api.GET("/deal_flows", { params: { query: params } }));
|
|
848
341
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
*/
|
|
852
|
-
async retrieve(dealFlowId) {
|
|
853
|
-
return this.get(`/deal_flows/${dealFlowId}`);
|
|
342
|
+
async get(dealFlowId) {
|
|
343
|
+
return this.unwrap(this.api.GET("/deal_flows/{id}", { params: { path: { id: dealFlowId } } }));
|
|
854
344
|
}
|
|
855
|
-
/**
|
|
856
|
-
* Create a new deal flow
|
|
857
|
-
*/
|
|
858
345
|
async create(data) {
|
|
859
|
-
return this.
|
|
346
|
+
return this.unwrap(this.api.POST("/deal_flows", { body: data }));
|
|
860
347
|
}
|
|
861
|
-
/**
|
|
862
|
-
* Update an existing deal flow
|
|
863
|
-
*/
|
|
864
348
|
async update(dealFlowId, data) {
|
|
865
|
-
return this.
|
|
866
|
-
`/deal_flows/${dealFlowId}`,
|
|
867
|
-
data
|
|
868
|
-
);
|
|
349
|
+
return this.unwrap(this.api.PUT("/deal_flows/{id}", { params: { path: { id: dealFlowId } }, body: data }));
|
|
869
350
|
}
|
|
870
|
-
/**
|
|
871
|
-
* Delete a deal flow
|
|
872
|
-
*/
|
|
873
351
|
async del(dealFlowId) {
|
|
874
|
-
return this.
|
|
352
|
+
return this.unwrap(this.api.DELETE("/deal_flows/{id}", { params: { path: { id: dealFlowId } } }));
|
|
875
353
|
}
|
|
876
354
|
};
|
|
877
355
|
|
|
878
356
|
// src/resources/deal-activities.ts
|
|
879
357
|
var DealActivitiesResource = class extends BaseResource {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
*/
|
|
883
|
-
async list() {
|
|
884
|
-
return this.get("/deal_activities");
|
|
358
|
+
async list(params) {
|
|
359
|
+
return this.unwrap(this.api.GET("/deal_activities", { params: { query: params } }));
|
|
885
360
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
*/
|
|
889
|
-
async retrieve(dealActivityId) {
|
|
890
|
-
return this.get(
|
|
891
|
-
`/deal_activities/${dealActivityId}`
|
|
892
|
-
);
|
|
361
|
+
async get(dealActivityId) {
|
|
362
|
+
return this.unwrap(this.api.GET("/deal_activities/{id}", { params: { path: { id: dealActivityId } } }));
|
|
893
363
|
}
|
|
894
|
-
/**
|
|
895
|
-
* Create a new deal activity
|
|
896
|
-
*/
|
|
897
364
|
async create(data) {
|
|
898
|
-
return this.
|
|
365
|
+
return this.unwrap(this.api.POST("/deal_activities", { body: data }));
|
|
899
366
|
}
|
|
900
|
-
/**
|
|
901
|
-
* Update an existing deal activity
|
|
902
|
-
*/
|
|
903
367
|
async update(dealActivityId, data) {
|
|
904
|
-
return this.
|
|
905
|
-
`/deal_activities/${dealActivityId}`,
|
|
906
|
-
data
|
|
907
|
-
);
|
|
368
|
+
return this.unwrap(this.api.PUT("/deal_activities/{id}", { params: { path: { id: dealActivityId } }, body: data }));
|
|
908
369
|
}
|
|
909
|
-
/**
|
|
910
|
-
* Delete a deal activity
|
|
911
|
-
*/
|
|
912
370
|
async del(dealActivityId) {
|
|
913
|
-
return this.
|
|
371
|
+
return this.unwrap(this.api.DELETE("/deal_activities/{id}", { params: { path: { id: dealActivityId } } }));
|
|
914
372
|
}
|
|
915
373
|
};
|
|
916
374
|
|
|
917
375
|
// src/resources/tickets.ts
|
|
918
376
|
var TicketsResource = class extends BaseResource {
|
|
919
|
-
|
|
920
|
-
* List tickets with optional filters and pagination
|
|
921
|
-
*/
|
|
377
|
+
// Tickets
|
|
922
378
|
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
|
-
};
|
|
379
|
+
return this.unwrap(this.api.GET("/tickets", { params: { query: params } }));
|
|
931
380
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
*/
|
|
935
|
-
async retrieve(ticketId) {
|
|
936
|
-
return this.get(`/tickets/${ticketId}`);
|
|
381
|
+
async get(ticketId) {
|
|
382
|
+
return this.unwrap(this.api.GET("/tickets/{id}", { params: { path: { id: ticketId } } }));
|
|
937
383
|
}
|
|
938
|
-
/**
|
|
939
|
-
* Create a new ticket
|
|
940
|
-
*/
|
|
941
384
|
async create(data) {
|
|
942
|
-
return this.
|
|
385
|
+
return this.unwrap(this.api.POST("/tickets", { body: data }));
|
|
943
386
|
}
|
|
944
|
-
/**
|
|
945
|
-
* Update an existing ticket
|
|
946
|
-
*/
|
|
947
387
|
async update(ticketId, data) {
|
|
948
|
-
return this.
|
|
949
|
-
}
|
|
950
|
-
/**
|
|
951
|
-
* Delete a ticket
|
|
952
|
-
*/
|
|
953
|
-
async del(ticketId) {
|
|
954
|
-
return this._delete(`/tickets/${ticketId}`);
|
|
388
|
+
return this.unwrap(this.api.PUT("/tickets/{id}", { params: { path: { id: ticketId } }, body: data }));
|
|
955
389
|
}
|
|
956
|
-
//
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
*/
|
|
960
|
-
async listMessages(ticketId) {
|
|
961
|
-
return this.get(
|
|
962
|
-
`/tickets/${ticketId}/messages`
|
|
963
|
-
);
|
|
390
|
+
// Messages
|
|
391
|
+
async listMessages(ticketId, params) {
|
|
392
|
+
return this.unwrap(this.api.GET("/tickets/{id}/messages", { params: { path: { id: ticketId }, query: params } }));
|
|
964
393
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
*/
|
|
968
|
-
async retrieveMessage(ticketId, messageId) {
|
|
969
|
-
return this.get(
|
|
970
|
-
`/tickets/${ticketId}/messages/${messageId}`
|
|
971
|
-
);
|
|
394
|
+
async getMessage(ticketId, messageId) {
|
|
395
|
+
return this.unwrap(this.api.GET("/tickets/{id}/messages/{messageId}", { params: { path: { id: ticketId, messageId } } }));
|
|
972
396
|
}
|
|
973
|
-
/**
|
|
974
|
-
* Create a new message on a ticket
|
|
975
|
-
*/
|
|
976
397
|
async createMessage(ticketId, data) {
|
|
977
|
-
return this.
|
|
978
|
-
`/tickets/${ticketId}/messages`,
|
|
979
|
-
data
|
|
980
|
-
);
|
|
398
|
+
return this.unwrap(this.api.POST("/tickets/{id}/messages", { params: { path: { id: ticketId } }, body: data }));
|
|
981
399
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
*/
|
|
985
|
-
async updateMessage(ticketId, messageId, data) {
|
|
986
|
-
return this.put(
|
|
987
|
-
`/tickets/${ticketId}/messages/${messageId}`,
|
|
988
|
-
data
|
|
989
|
-
);
|
|
400
|
+
async updateMessage(ticketId, data) {
|
|
401
|
+
return this.unwrap(this.api.PUT("/tickets/{id}/messages", { params: { path: { id: ticketId } }, body: data }));
|
|
990
402
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
403
|
+
// Events
|
|
404
|
+
async listEvents(ticketId, params) {
|
|
405
|
+
return this.unwrap(this.api.GET("/tickets/{id}/events", { params: { path: { id: ticketId }, query: params } }));
|
|
406
|
+
}
|
|
407
|
+
async createEvent(ticketId, data) {
|
|
408
|
+
return this.unwrap(this.api.POST("/tickets/{id}/events", { params: { path: { id: ticketId } }, body: data }));
|
|
409
|
+
}
|
|
410
|
+
// Loops
|
|
411
|
+
async listLoops(ticketId) {
|
|
412
|
+
return this.unwrap(this.api.GET("/tickets/{id}/loops", { params: { path: { id: ticketId } } }));
|
|
413
|
+
}
|
|
414
|
+
async getLoop(ticketId, loopId) {
|
|
415
|
+
return this.unwrap(this.api.GET("/tickets/{id}/loops/{loopId}", { params: { path: { id: ticketId, loopId } } }));
|
|
998
416
|
}
|
|
999
417
|
};
|
|
1000
418
|
|
|
1001
419
|
// src/resources/channels.ts
|
|
1002
420
|
var ChannelsResource = class extends BaseResource {
|
|
1003
421
|
/**
|
|
1004
|
-
* List CX channels
|
|
422
|
+
* List CX channels with optional filters
|
|
1005
423
|
*/
|
|
1006
424
|
async list(params) {
|
|
1007
|
-
return this.
|
|
425
|
+
return this.unwrap(this.api.GET("/channels", { params: { query: params } }));
|
|
1008
426
|
}
|
|
1009
427
|
/**
|
|
1010
428
|
* Create a new CX channel
|
|
1011
429
|
*/
|
|
1012
430
|
async create(data) {
|
|
1013
|
-
return this.
|
|
431
|
+
return this.unwrap(this.api.POST("/channels", { body: data }));
|
|
1014
432
|
}
|
|
1015
433
|
};
|
|
1016
434
|
|
|
@@ -1020,113 +438,67 @@ var FlowsResource = class extends BaseResource {
|
|
|
1020
438
|
* List flows with optional filters and pagination
|
|
1021
439
|
*/
|
|
1022
440
|
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
|
-
};
|
|
441
|
+
return this.unwrap(this.api.GET("/flows", { params: { query: params } }));
|
|
1031
442
|
}
|
|
1032
443
|
/**
|
|
1033
|
-
*
|
|
444
|
+
* Get a single flow by ID
|
|
1034
445
|
*/
|
|
1035
|
-
async
|
|
1036
|
-
return this.
|
|
446
|
+
async get(flowId) {
|
|
447
|
+
return this.unwrap(this.api.GET("/flows/{id}", { params: { path: { id: flowId } } }));
|
|
1037
448
|
}
|
|
1038
449
|
/**
|
|
1039
450
|
* Create a new flow
|
|
1040
451
|
*/
|
|
1041
452
|
async create(data) {
|
|
1042
|
-
return this.
|
|
453
|
+
return this.unwrap(this.api.POST("/flows", { body: data }));
|
|
1043
454
|
}
|
|
1044
455
|
/**
|
|
1045
456
|
* Update an existing flow
|
|
1046
457
|
*/
|
|
1047
458
|
async update(flowId, data) {
|
|
1048
|
-
return this.
|
|
459
|
+
return this.unwrap(this.api.PATCH("/flows/{id}", { params: { path: { id: flowId } }, body: data }));
|
|
1049
460
|
}
|
|
1050
461
|
/**
|
|
1051
462
|
* Delete a flow
|
|
1052
463
|
*/
|
|
1053
464
|
async del(flowId) {
|
|
1054
|
-
return this.
|
|
465
|
+
return this.unwrap(this.api.DELETE("/flows/{id}", { params: { path: { id: flowId } } }));
|
|
1055
466
|
}
|
|
1056
467
|
};
|
|
1057
468
|
|
|
1058
469
|
// src/resources/tasks.ts
|
|
1059
470
|
var TasksResource = class extends BaseResource {
|
|
1060
|
-
|
|
1061
|
-
* List tasks with optional filters and pagination
|
|
1062
|
-
*/
|
|
471
|
+
// Tasks
|
|
1063
472
|
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
|
-
};
|
|
473
|
+
return this.unwrap(this.api.GET("/tasks", { params: { query: params } }));
|
|
1072
474
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
*/
|
|
1076
|
-
async retrieve(taskId) {
|
|
1077
|
-
return this.get(`/tasks/${taskId}`);
|
|
475
|
+
async get(taskId) {
|
|
476
|
+
return this.unwrap(this.api.GET("/tasks/{id}", { params: { path: { id: taskId } } }));
|
|
1078
477
|
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Create a new task
|
|
1081
|
-
*/
|
|
1082
478
|
async create(data) {
|
|
1083
|
-
return this.
|
|
479
|
+
return this.unwrap(this.api.POST("/tasks", { body: data }));
|
|
1084
480
|
}
|
|
1085
|
-
/**
|
|
1086
|
-
* Update an existing task
|
|
1087
|
-
*/
|
|
1088
481
|
async update(taskId, data) {
|
|
1089
|
-
return this.
|
|
482
|
+
return this.unwrap(this.api.PUT("/tasks/{id}", { params: { path: { id: taskId } }, body: data }));
|
|
1090
483
|
}
|
|
1091
|
-
/**
|
|
1092
|
-
* Delete a task
|
|
1093
|
-
*/
|
|
1094
484
|
async del(taskId) {
|
|
1095
|
-
return this.
|
|
485
|
+
return this.unwrap(this.api.DELETE("/tasks/{id}", { params: { path: { id: taskId } } }));
|
|
1096
486
|
}
|
|
1097
|
-
//
|
|
1098
|
-
/**
|
|
1099
|
-
* List todo items for a task
|
|
1100
|
-
*/
|
|
487
|
+
// Todo Items
|
|
1101
488
|
async listTodoItems(taskId) {
|
|
1102
|
-
return this.
|
|
489
|
+
return this.unwrap(this.api.GET("/tasks/{id}/todo-items", { params: { path: { id: taskId } } }));
|
|
1103
490
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
*/
|
|
1107
|
-
async retrieveTodoItem(taskId, itemId) {
|
|
1108
|
-
return this.get(`/tasks/${taskId}/todo-items/${itemId}`);
|
|
491
|
+
async getTodoItem(taskId, itemId) {
|
|
492
|
+
return this.unwrap(this.api.GET("/tasks/{id}/todo-items/{itemId}", { params: { path: { id: taskId, itemId } } }));
|
|
1109
493
|
}
|
|
1110
|
-
/**
|
|
1111
|
-
* Create a todo item for a task
|
|
1112
|
-
*/
|
|
1113
494
|
async createTodoItem(taskId, data) {
|
|
1114
|
-
return this.
|
|
495
|
+
return this.unwrap(this.api.POST("/tasks/{id}/todo-items", { params: { path: { id: taskId } }, body: data }));
|
|
1115
496
|
}
|
|
1116
|
-
/**
|
|
1117
|
-
* Update a todo item
|
|
1118
|
-
*/
|
|
1119
497
|
async updateTodoItem(taskId, itemId, data) {
|
|
1120
|
-
return this.
|
|
1121
|
-
`/tasks/${taskId}/todo-items/${itemId}`,
|
|
1122
|
-
data
|
|
1123
|
-
);
|
|
498
|
+
return this.unwrap(this.api.PUT("/tasks/{id}/todo-items/{itemId}", { params: { path: { id: taskId, itemId } }, body: data }));
|
|
1124
499
|
}
|
|
1125
|
-
/**
|
|
1126
|
-
* Delete a todo item
|
|
1127
|
-
*/
|
|
1128
500
|
async deleteTodoItem(taskId, itemId) {
|
|
1129
|
-
return this.
|
|
501
|
+
return this.unwrap(this.api.DELETE("/tasks/{id}/todo-items/{itemId}", { params: { path: { id: taskId, itemId } } }));
|
|
1130
502
|
}
|
|
1131
503
|
};
|
|
1132
504
|
|
|
@@ -1136,36 +508,25 @@ var WebhooksResource = class extends BaseResource {
|
|
|
1136
508
|
* List all webhooks
|
|
1137
509
|
*/
|
|
1138
510
|
async list() {
|
|
1139
|
-
|
|
1140
|
-
return {
|
|
1141
|
-
webhooks: response.webhooks || [],
|
|
1142
|
-
hasNextPage: response.hasNextPage || false,
|
|
1143
|
-
hasPreviousPage: response.hasPreviousPage || false
|
|
1144
|
-
};
|
|
1145
|
-
}
|
|
1146
|
-
/**
|
|
1147
|
-
* Retrieve a single webhook by ID
|
|
1148
|
-
*/
|
|
1149
|
-
async retrieve(webhookId) {
|
|
1150
|
-
return this.get(`/webhooks/${webhookId}`);
|
|
511
|
+
return this.unwrap(this.api.GET("/webhooks"));
|
|
1151
512
|
}
|
|
1152
513
|
/**
|
|
1153
514
|
* Create a new webhook
|
|
1154
515
|
*/
|
|
1155
516
|
async create(data) {
|
|
1156
|
-
return this.
|
|
517
|
+
return this.unwrap(this.api.POST("/webhooks", { body: data }));
|
|
1157
518
|
}
|
|
1158
519
|
/**
|
|
1159
520
|
* Update an existing webhook
|
|
1160
521
|
*/
|
|
1161
522
|
async update(webhookId, data) {
|
|
1162
|
-
return this.
|
|
523
|
+
return this.unwrap(this.api.PUT("/webhooks/{id}", { params: { path: { id: webhookId } }, body: data }));
|
|
1163
524
|
}
|
|
1164
525
|
/**
|
|
1165
526
|
* Delete a webhook
|
|
1166
527
|
*/
|
|
1167
528
|
async del(webhookId) {
|
|
1168
|
-
return this.
|
|
529
|
+
return this.unwrap(this.api.DELETE("/webhooks/{id}", { params: { path: { id: webhookId } } }));
|
|
1169
530
|
}
|
|
1170
531
|
};
|
|
1171
532
|
|
|
@@ -1175,37 +536,31 @@ var CompaniesResource = class extends BaseResource {
|
|
|
1175
536
|
* List companies with optional pagination
|
|
1176
537
|
*/
|
|
1177
538
|
async list(params) {
|
|
1178
|
-
|
|
1179
|
-
return {
|
|
1180
|
-
companies: response.companies || [],
|
|
1181
|
-
hasNextPage: response.hasNextPage || false,
|
|
1182
|
-
hasPreviousPage: response.hasPreviousPage || false,
|
|
1183
|
-
cursor: response.cursor
|
|
1184
|
-
};
|
|
539
|
+
return this.unwrap(this.api.GET("/companies", { params: { query: params } }));
|
|
1185
540
|
}
|
|
1186
541
|
/**
|
|
1187
|
-
*
|
|
542
|
+
* Get a single company by ID
|
|
1188
543
|
*/
|
|
1189
|
-
async
|
|
1190
|
-
return this.
|
|
544
|
+
async get(companyId) {
|
|
545
|
+
return this.unwrap(this.api.GET("/companies/{id}", { params: { path: { id: companyId } } }));
|
|
1191
546
|
}
|
|
1192
547
|
/**
|
|
1193
548
|
* Create a new company
|
|
1194
549
|
*/
|
|
1195
550
|
async create(data) {
|
|
1196
|
-
return this.
|
|
551
|
+
return this.unwrap(this.api.POST("/companies", { body: data }));
|
|
1197
552
|
}
|
|
1198
553
|
/**
|
|
1199
554
|
* Update an existing company
|
|
1200
555
|
*/
|
|
1201
556
|
async update(companyId, data) {
|
|
1202
|
-
return this.
|
|
557
|
+
return this.unwrap(this.api.PUT("/companies/{id}", { params: { path: { id: companyId } }, body: data }));
|
|
1203
558
|
}
|
|
1204
559
|
/**
|
|
1205
560
|
* Delete a company
|
|
1206
561
|
*/
|
|
1207
562
|
async del(companyId) {
|
|
1208
|
-
return this.
|
|
563
|
+
return this.unwrap(this.api.DELETE("/companies/{id}", { params: { path: { id: companyId } } }));
|
|
1209
564
|
}
|
|
1210
565
|
};
|
|
1211
566
|
|
|
@@ -1215,24 +570,13 @@ var CustomerSegmentsResource = class extends BaseResource {
|
|
|
1215
570
|
* List public customer segments with optional pagination
|
|
1216
571
|
*/
|
|
1217
572
|
async list(params) {
|
|
1218
|
-
|
|
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
|
-
};
|
|
573
|
+
return this.unwrap(this.api.GET("/customer_segments", { params: { query: params } }));
|
|
1228
574
|
}
|
|
1229
575
|
/**
|
|
1230
|
-
*
|
|
576
|
+
* Get a single customer segment by ID
|
|
1231
577
|
*/
|
|
1232
|
-
async
|
|
1233
|
-
return this.
|
|
1234
|
-
`/customer_segments/${segmentId}`
|
|
1235
|
-
);
|
|
578
|
+
async get(segmentId) {
|
|
579
|
+
return this.unwrap(this.api.GET("/customer_segments/{id}", { params: { path: { id: segmentId } } }));
|
|
1236
580
|
}
|
|
1237
581
|
};
|
|
1238
582
|
|
|
@@ -1242,75 +586,57 @@ var AffiliatesResource = class extends BaseResource {
|
|
|
1242
586
|
* List affiliates with optional filters and pagination
|
|
1243
587
|
*/
|
|
1244
588
|
async list(params) {
|
|
1245
|
-
|
|
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
|
-
};
|
|
589
|
+
return this.unwrap(this.api.GET("/affiliates", { params: { query: params } }));
|
|
1255
590
|
}
|
|
1256
591
|
/**
|
|
1257
|
-
*
|
|
592
|
+
* Get a single affiliate by ID
|
|
1258
593
|
*/
|
|
1259
|
-
async
|
|
1260
|
-
return this.
|
|
594
|
+
async get(affiliateId) {
|
|
595
|
+
return this.unwrap(this.api.GET("/affiliates/{id}", { params: { path: { id: affiliateId } } }));
|
|
1261
596
|
}
|
|
1262
597
|
/**
|
|
1263
598
|
* Update an existing affiliate
|
|
599
|
+
* Note: PUT not in OpenAPI spec but kept for backwards compatibility
|
|
1264
600
|
*/
|
|
1265
601
|
async update(affiliateId, data) {
|
|
1266
|
-
return this.
|
|
1267
|
-
`/affiliates/${affiliateId}`,
|
|
1268
|
-
data
|
|
1269
|
-
);
|
|
602
|
+
return this.unwrap(this.untypedApi.PUT("/affiliates/{id}", { params: { path: { id: affiliateId } }, body: data }));
|
|
1270
603
|
}
|
|
1271
604
|
};
|
|
1272
605
|
|
|
1273
606
|
// src/resources/affiliate-programs.ts
|
|
1274
607
|
var AffiliateProgramsResource = class extends BaseResource {
|
|
1275
608
|
/**
|
|
1276
|
-
* List
|
|
609
|
+
* List affiliate programs with optional filters and pagination
|
|
1277
610
|
*/
|
|
1278
|
-
async list() {
|
|
1279
|
-
return this.
|
|
1280
|
-
"/affiliate_programs"
|
|
1281
|
-
);
|
|
611
|
+
async list(params) {
|
|
612
|
+
return this.unwrap(this.api.GET("/affiliate_programs", { params: { query: params } }));
|
|
1282
613
|
}
|
|
1283
614
|
/**
|
|
1284
|
-
*
|
|
615
|
+
* Get a single affiliate program by ID
|
|
1285
616
|
*/
|
|
1286
|
-
async
|
|
1287
|
-
return this.
|
|
1288
|
-
`/affiliate_programs/${programId}`
|
|
1289
|
-
);
|
|
617
|
+
async get(programId) {
|
|
618
|
+
return this.unwrap(this.api.GET("/affiliate_programs/{id}", { params: { path: { id: programId } } }));
|
|
1290
619
|
}
|
|
1291
620
|
/**
|
|
1292
621
|
* Create a new affiliate program
|
|
622
|
+
* Note: POST not yet in OpenAPI spec
|
|
1293
623
|
*/
|
|
1294
624
|
async create(data) {
|
|
1295
|
-
return this.
|
|
1296
|
-
"/affiliate_programs",
|
|
1297
|
-
data
|
|
1298
|
-
);
|
|
625
|
+
return this.unwrap(this.untypedApi.POST("/affiliate_programs", { body: data }));
|
|
1299
626
|
}
|
|
1300
627
|
/**
|
|
1301
628
|
* Update an existing affiliate program
|
|
629
|
+
* Note: PUT not yet in OpenAPI spec
|
|
1302
630
|
*/
|
|
1303
631
|
async update(programId, data) {
|
|
1304
|
-
return this.
|
|
1305
|
-
`/affiliate_programs/${programId}`,
|
|
1306
|
-
data
|
|
1307
|
-
);
|
|
632
|
+
return this.unwrap(this.untypedApi.PUT("/affiliate_programs/{id}", { params: { path: { id: programId } }, body: data }));
|
|
1308
633
|
}
|
|
1309
634
|
/**
|
|
1310
635
|
* Delete an affiliate program
|
|
636
|
+
* Note: DELETE not yet in OpenAPI spec
|
|
1311
637
|
*/
|
|
1312
638
|
async del(programId) {
|
|
1313
|
-
return this.
|
|
639
|
+
return this.unwrap(this.untypedApi.DELETE("/affiliate_programs/{id}", { params: { path: { id: programId } } }));
|
|
1314
640
|
}
|
|
1315
641
|
};
|
|
1316
642
|
|
|
@@ -1320,24 +646,13 @@ var AffiliateCommissionsResource = class extends BaseResource {
|
|
|
1320
646
|
* List affiliate commissions with optional filters and pagination
|
|
1321
647
|
*/
|
|
1322
648
|
async list(params) {
|
|
1323
|
-
|
|
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
|
-
};
|
|
649
|
+
return this.unwrap(this.api.GET("/affiliate_commissions", { params: { query: params } }));
|
|
1333
650
|
}
|
|
1334
651
|
/**
|
|
1335
|
-
*
|
|
652
|
+
* Get a single affiliate commission by ID
|
|
1336
653
|
*/
|
|
1337
|
-
async
|
|
1338
|
-
return this.
|
|
1339
|
-
`/affiliate_commissions/${commissionId}`
|
|
1340
|
-
);
|
|
654
|
+
async get(commissionId) {
|
|
655
|
+
return this.unwrap(this.api.GET("/affiliate_commissions/{id}", { params: { path: { id: commissionId } } }));
|
|
1341
656
|
}
|
|
1342
657
|
};
|
|
1343
658
|
|
|
@@ -1347,24 +662,13 @@ var AffiliatePayoutsResource = class extends BaseResource {
|
|
|
1347
662
|
* List affiliate payouts with optional filters and pagination
|
|
1348
663
|
*/
|
|
1349
664
|
async list(params) {
|
|
1350
|
-
|
|
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
|
-
};
|
|
665
|
+
return this.unwrap(this.api.GET("/affiliate_payouts", { params: { query: params } }));
|
|
1360
666
|
}
|
|
1361
667
|
/**
|
|
1362
|
-
*
|
|
668
|
+
* Get a single affiliate payout by ID
|
|
1363
669
|
*/
|
|
1364
|
-
async
|
|
1365
|
-
return this.
|
|
1366
|
-
`/affiliate_payouts/${payoutId}`
|
|
1367
|
-
);
|
|
670
|
+
async get(payoutId) {
|
|
671
|
+
return this.unwrap(this.api.GET("/affiliate_payouts/{id}", { params: { path: { id: payoutId } } }));
|
|
1368
672
|
}
|
|
1369
673
|
};
|
|
1370
674
|
|
|
@@ -1374,24 +678,13 @@ var AffiliateReferralsResource = class extends BaseResource {
|
|
|
1374
678
|
* List affiliate referrals with optional filters and pagination
|
|
1375
679
|
*/
|
|
1376
680
|
async list(params) {
|
|
1377
|
-
|
|
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
|
-
};
|
|
681
|
+
return this.unwrap(this.api.GET("/affiliate_referrals", { params: { query: params } }));
|
|
1387
682
|
}
|
|
1388
683
|
/**
|
|
1389
|
-
*
|
|
684
|
+
* Get a single affiliate referral by ID
|
|
1390
685
|
*/
|
|
1391
|
-
async
|
|
1392
|
-
return this.
|
|
1393
|
-
`/affiliate_referrals/${referralId}`
|
|
1394
|
-
);
|
|
686
|
+
async get(referralId) {
|
|
687
|
+
return this.unwrap(this.api.GET("/affiliate_referrals/{id}", { params: { path: { id: referralId } } }));
|
|
1395
688
|
}
|
|
1396
689
|
};
|
|
1397
690
|
|
|
@@ -1401,14 +694,7 @@ var ChargesResource = class extends BaseResource {
|
|
|
1401
694
|
* List charges with optional filters and pagination
|
|
1402
695
|
*/
|
|
1403
696
|
async list(params) {
|
|
1404
|
-
|
|
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
|
-
};
|
|
697
|
+
return this.unwrap(this.api.GET("/charges", { params: { query: params } }));
|
|
1412
698
|
}
|
|
1413
699
|
};
|
|
1414
700
|
|
|
@@ -1418,227 +704,62 @@ var TransactionsResource = class extends BaseResource {
|
|
|
1418
704
|
* List transactions with optional filters and pagination
|
|
1419
705
|
*/
|
|
1420
706
|
async list(params) {
|
|
1421
|
-
|
|
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
|
-
};
|
|
707
|
+
return this.unwrap(this.api.GET("/transactions", { params: { query: params } }));
|
|
1432
708
|
}
|
|
1433
709
|
/**
|
|
1434
|
-
*
|
|
710
|
+
* Get a single transaction by ID
|
|
1435
711
|
*/
|
|
1436
|
-
async
|
|
1437
|
-
return this.
|
|
1438
|
-
`/transactions/${transactionId}`
|
|
1439
|
-
);
|
|
712
|
+
async get(transactionId) {
|
|
713
|
+
return this.unwrap(this.api.GET("/transactions/{id}", { params: { path: { id: transactionId } } }));
|
|
1440
714
|
}
|
|
1441
715
|
};
|
|
1442
716
|
|
|
1443
717
|
// src/resources/metrics.ts
|
|
1444
718
|
var MetricsResource = class extends BaseResource {
|
|
1445
|
-
|
|
1446
|
-
|
|
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
|
-
};
|
|
719
|
+
async mrr(params) {
|
|
720
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/mrr", { params: { query: params } }));
|
|
1466
721
|
}
|
|
1467
|
-
/**
|
|
1468
|
-
* Get Annual Recurring Revenue (ARR)
|
|
1469
|
-
*/
|
|
1470
722
|
async arr(params) {
|
|
1471
|
-
return this.
|
|
1472
|
-
metric: "PlatformApp.arr",
|
|
1473
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1474
|
-
...params
|
|
1475
|
-
});
|
|
723
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/arr", { params: { query: params } }));
|
|
1476
724
|
}
|
|
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
|
-
});
|
|
725
|
+
async arpu(params) {
|
|
726
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/arpu", { params: { query: params } }));
|
|
1486
727
|
}
|
|
1487
|
-
/**
|
|
1488
|
-
* Get active subscriptions count
|
|
1489
|
-
*/
|
|
1490
728
|
async activeSubscriptions(params) {
|
|
1491
|
-
return this.
|
|
1492
|
-
metric: "PlatformApp.activeSubscriptions",
|
|
1493
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1494
|
-
...params
|
|
1495
|
-
});
|
|
729
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/activeSubscriptions", { params: { query: params } }));
|
|
1496
730
|
}
|
|
1497
|
-
/**
|
|
1498
|
-
* Get active installations count
|
|
1499
|
-
*/
|
|
1500
731
|
async activeInstalls(params) {
|
|
1501
|
-
return this.
|
|
1502
|
-
metric: "PlatformApp.activeInstalls",
|
|
1503
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1504
|
-
...params
|
|
1505
|
-
});
|
|
732
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/activeInstalls", { params: { query: params } }));
|
|
1506
733
|
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Get net new installations
|
|
1509
|
-
*/
|
|
1510
734
|
async netInstalls(params) {
|
|
1511
|
-
return this.
|
|
1512
|
-
metric: "PlatformApp.netInstalls",
|
|
1513
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1514
|
-
...params
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
/**
|
|
1518
|
-
* Get Average Revenue Per User (ARPU)
|
|
1519
|
-
*/
|
|
1520
|
-
async arpu(params) {
|
|
1521
|
-
return this.fetch({
|
|
1522
|
-
metric: "PlatformApp.arpu",
|
|
1523
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1524
|
-
...params
|
|
1525
|
-
});
|
|
735
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/netInstalls", { params: { query: params } }));
|
|
1526
736
|
}
|
|
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
|
-
});
|
|
737
|
+
async logoChurn(params) {
|
|
738
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/logoChurn", { params: { query: params } }));
|
|
1536
739
|
}
|
|
1537
|
-
/**
|
|
1538
|
-
* Get revenue churn rate
|
|
1539
|
-
*/
|
|
1540
740
|
async revenueChurn(params) {
|
|
1541
|
-
return this.
|
|
1542
|
-
metric: "PlatformApp.revenueChurn",
|
|
1543
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1544
|
-
...params
|
|
1545
|
-
});
|
|
741
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/revenueChurn", { params: { query: params } }));
|
|
1546
742
|
}
|
|
1547
|
-
/**
|
|
1548
|
-
* Get logo (customer) churn rate
|
|
1549
|
-
*/
|
|
1550
|
-
async logoChurn(params) {
|
|
1551
|
-
return this.fetch({
|
|
1552
|
-
metric: "PlatformApp.logoChurn",
|
|
1553
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1554
|
-
...params
|
|
1555
|
-
});
|
|
1556
|
-
}
|
|
1557
|
-
/**
|
|
1558
|
-
* Get revenue retention rate
|
|
1559
|
-
*/
|
|
1560
743
|
async revenueRetention(params) {
|
|
1561
|
-
return this.
|
|
1562
|
-
metric: "PlatformApp.revenueRetention",
|
|
1563
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1564
|
-
...params
|
|
1565
|
-
});
|
|
744
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/revenueRetention", { params: { query: params } }));
|
|
1566
745
|
}
|
|
1567
|
-
/**
|
|
1568
|
-
* Get net revenue retention rate
|
|
1569
|
-
*/
|
|
1570
746
|
async netRevenueRetention(params) {
|
|
1571
|
-
return this.
|
|
1572
|
-
metric: "PlatformApp.netRevenueRetention",
|
|
1573
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1574
|
-
...params
|
|
1575
|
-
});
|
|
747
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/netRevenueRetention", { params: { query: params } }));
|
|
1576
748
|
}
|
|
1577
|
-
/**
|
|
1578
|
-
* Get net revenue
|
|
1579
|
-
*/
|
|
1580
749
|
async netRevenue(params) {
|
|
1581
|
-
return this.
|
|
1582
|
-
metric: "PlatformApp.netRevenue",
|
|
1583
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1584
|
-
...params
|
|
1585
|
-
});
|
|
750
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/netRevenue", { params: { query: params } }));
|
|
1586
751
|
}
|
|
1587
|
-
/**
|
|
1588
|
-
* Get payout amount
|
|
1589
|
-
*/
|
|
1590
752
|
async payout(params) {
|
|
1591
|
-
return this.
|
|
1592
|
-
metric: "PlatformApp.payout",
|
|
1593
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1594
|
-
...params
|
|
1595
|
-
});
|
|
753
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/payout", { params: { query: params } }));
|
|
1596
754
|
}
|
|
1597
|
-
/**
|
|
1598
|
-
* Get predicted Lifetime Value
|
|
1599
|
-
*/
|
|
1600
755
|
async predictedLtv(params) {
|
|
1601
|
-
return this.
|
|
1602
|
-
metric: "PlatformApp.predictedLtv",
|
|
1603
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1604
|
-
...params
|
|
1605
|
-
});
|
|
1606
|
-
}
|
|
1607
|
-
/**
|
|
1608
|
-
* Get charges
|
|
1609
|
-
*/
|
|
1610
|
-
async charges(params) {
|
|
1611
|
-
return this.fetch({
|
|
1612
|
-
metric: "PlatformApp.charges",
|
|
1613
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1614
|
-
...params
|
|
1615
|
-
});
|
|
756
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/predictedLtv", { params: { query: params } }));
|
|
1616
757
|
}
|
|
1617
|
-
/**
|
|
1618
|
-
* Get usage event metrics
|
|
1619
|
-
*/
|
|
1620
758
|
async usageEvent(params) {
|
|
1621
|
-
return this.
|
|
1622
|
-
metric: "PlatformApp.usageEvent",
|
|
1623
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1624
|
-
...params
|
|
1625
|
-
});
|
|
759
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/usageEvent", { params: { query: params } }));
|
|
1626
760
|
}
|
|
1627
|
-
/**
|
|
1628
|
-
* Get usage metric data
|
|
1629
|
-
*/
|
|
1630
761
|
async usageMetric(params) {
|
|
1631
|
-
return this.
|
|
1632
|
-
metric: "PlatformApp.usageMetric",
|
|
1633
|
-
dateRange: params.dateRange || "last_30_days",
|
|
1634
|
-
...params
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
/**
|
|
1638
|
-
* Get key sales metrics
|
|
1639
|
-
*/
|
|
1640
|
-
async sales(params) {
|
|
1641
|
-
return this.get("/metrics/sales", params);
|
|
762
|
+
return this.unwrap(this.api.GET("/api/core/v1/metrics/usageMetric", { params: { query: params } }));
|
|
1642
763
|
}
|
|
1643
764
|
};
|
|
1644
765
|
|
|
@@ -1648,29 +769,20 @@ var UsersResource = class extends BaseResource {
|
|
|
1648
769
|
* List organization users with optional pagination
|
|
1649
770
|
*/
|
|
1650
771
|
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
|
-
};
|
|
772
|
+
return this.unwrap(this.api.GET("/users", { params: { query: params } }));
|
|
1658
773
|
}
|
|
1659
774
|
/**
|
|
1660
|
-
*
|
|
775
|
+
* Get a single user by ID
|
|
1661
776
|
*/
|
|
1662
|
-
async
|
|
1663
|
-
return this.
|
|
777
|
+
async get(userId) {
|
|
778
|
+
return this.unwrap(this.api.GET("/users/{id}", { params: { path: { id: userId } } }));
|
|
1664
779
|
}
|
|
1665
780
|
};
|
|
1666
781
|
|
|
1667
782
|
// src/resources/me.ts
|
|
1668
783
|
var MeResource = class extends BaseResource {
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
*/
|
|
1672
|
-
async retrieve() {
|
|
1673
|
-
return this.client.get("/me");
|
|
784
|
+
async get() {
|
|
785
|
+
return this.unwrap(this.untypedApi.GET("/me", {}));
|
|
1674
786
|
}
|
|
1675
787
|
};
|
|
1676
788
|
|
|
@@ -1679,206 +791,77 @@ var OrganizationResource = class extends BaseResource {
|
|
|
1679
791
|
/**
|
|
1680
792
|
* Get organization details
|
|
1681
793
|
*/
|
|
1682
|
-
async
|
|
1683
|
-
return this.
|
|
794
|
+
async get() {
|
|
795
|
+
return this.unwrap(this.api.GET("/organization"));
|
|
1684
796
|
}
|
|
1685
797
|
};
|
|
1686
798
|
|
|
1687
799
|
// src/resources/agents.ts
|
|
1688
800
|
var AgentsResource = class extends BaseResource {
|
|
1689
|
-
/**
|
|
1690
|
-
* List support agents
|
|
1691
|
-
*/
|
|
1692
801
|
async list() {
|
|
1693
|
-
return this.
|
|
802
|
+
return this.unwrap(this.untypedApi.GET("/agents", {}));
|
|
1694
803
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
*/
|
|
1698
|
-
async retrieve(agentId) {
|
|
1699
|
-
return this.get(`/agents/${agentId}`);
|
|
804
|
+
async get(agentId) {
|
|
805
|
+
return this.unwrap(this.untypedApi.GET("/agents/{id}", { params: { path: { id: agentId } } }));
|
|
1700
806
|
}
|
|
1701
|
-
/**
|
|
1702
|
-
* Create a new agent
|
|
1703
|
-
*/
|
|
1704
807
|
async create(params) {
|
|
1705
|
-
return this.
|
|
808
|
+
return this.unwrap(this.untypedApi.POST("/agents", { body: params }));
|
|
1706
809
|
}
|
|
1707
|
-
/**
|
|
1708
|
-
* Find an existing agent by email, or create one if not found.
|
|
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
810
|
async findOrCreate(params) {
|
|
1716
|
-
|
|
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
|
-
}
|
|
811
|
+
return this.unwrap(this.untypedApi.POST("/agents/find_or_create", { body: params }));
|
|
1730
812
|
}
|
|
1731
813
|
};
|
|
1732
814
|
|
|
1733
815
|
// src/resources/docs.ts
|
|
1734
816
|
var DocsResource = class extends BaseResource {
|
|
1735
|
-
//
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
*/
|
|
1739
|
-
async listCollections() {
|
|
1740
|
-
return this.get("/docs/collections");
|
|
817
|
+
// Collections
|
|
818
|
+
async listCollections(params) {
|
|
819
|
+
return this.unwrap(this.api.GET("/docs/collections", { params: { query: params } }));
|
|
1741
820
|
}
|
|
1742
|
-
/**
|
|
1743
|
-
* Retrieve a single doc collection
|
|
1744
|
-
*/
|
|
1745
|
-
async retrieveCollection(collectionId) {
|
|
1746
|
-
return this.get(
|
|
1747
|
-
`/docs/collections/${collectionId}`
|
|
1748
|
-
);
|
|
1749
|
-
}
|
|
1750
|
-
/**
|
|
1751
|
-
* Create a new doc collection
|
|
1752
|
-
*/
|
|
1753
821
|
async createCollection(data) {
|
|
1754
|
-
return this.
|
|
822
|
+
return this.unwrap(this.api.POST("/docs/collections", { body: data }));
|
|
1755
823
|
}
|
|
1756
|
-
/**
|
|
1757
|
-
* Update a doc collection
|
|
1758
|
-
*/
|
|
1759
824
|
async updateCollection(collectionId, data) {
|
|
1760
|
-
return this.
|
|
1761
|
-
`/docs/collections/${collectionId}`,
|
|
1762
|
-
data
|
|
1763
|
-
);
|
|
825
|
+
return this.unwrap(this.api.PUT("/docs/collections/{collection_id}", { params: { path: { collection_id: collectionId } }, body: data }));
|
|
1764
826
|
}
|
|
1765
|
-
/**
|
|
1766
|
-
* Delete a doc collection
|
|
1767
|
-
*/
|
|
1768
827
|
async deleteCollection(collectionId) {
|
|
1769
|
-
return this.
|
|
1770
|
-
}
|
|
1771
|
-
// ========== Groups ==========
|
|
1772
|
-
/**
|
|
1773
|
-
* List all doc groups
|
|
1774
|
-
*/
|
|
1775
|
-
async listGroups() {
|
|
1776
|
-
return this.get("/docs/groups");
|
|
828
|
+
return this.unwrap(this.api.DELETE("/docs/collections/{collection_id}", { params: { path: { collection_id: collectionId } } }));
|
|
1777
829
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
async retrieveGroup(groupId) {
|
|
1782
|
-
return this.get(`/docs/groups/${groupId}`);
|
|
830
|
+
// Groups
|
|
831
|
+
async listGroups(params) {
|
|
832
|
+
return this.unwrap(this.api.GET("/docs/groups", { params: { query: params } }));
|
|
1783
833
|
}
|
|
1784
|
-
/**
|
|
1785
|
-
* Create a new doc group
|
|
1786
|
-
*/
|
|
1787
834
|
async createGroup(data) {
|
|
1788
|
-
return this.
|
|
835
|
+
return this.unwrap(this.api.POST("/docs/groups", { body: data }));
|
|
1789
836
|
}
|
|
1790
|
-
/**
|
|
1791
|
-
* Update a doc group
|
|
1792
|
-
*/
|
|
1793
837
|
async updateGroup(groupId, data) {
|
|
1794
|
-
return this.
|
|
838
|
+
return this.unwrap(this.api.PUT("/docs/groups/{group_id}", { params: { path: { group_id: groupId } }, body: data }));
|
|
1795
839
|
}
|
|
1796
|
-
/**
|
|
1797
|
-
* Delete a doc group
|
|
1798
|
-
*/
|
|
1799
840
|
async deleteGroup(groupId) {
|
|
1800
|
-
return this.
|
|
841
|
+
return this.unwrap(this.api.DELETE("/docs/groups/{group_id}", { params: { path: { group_id: groupId } } }));
|
|
1801
842
|
}
|
|
1802
|
-
//
|
|
1803
|
-
/**
|
|
1804
|
-
* List doc pages with optional filters
|
|
1805
|
-
*/
|
|
843
|
+
// Pages
|
|
1806
844
|
async listPages(params) {
|
|
1807
|
-
|
|
1808
|
-
return {
|
|
1809
|
-
pages: response.pages || [],
|
|
1810
|
-
hasNextPage: response.hasNextPage || false,
|
|
1811
|
-
hasPreviousPage: response.hasPreviousPage || false
|
|
1812
|
-
};
|
|
845
|
+
return this.unwrap(this.api.GET("/docs/pages", { params: { query: params } }));
|
|
1813
846
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
*/
|
|
1817
|
-
async retrievePage(pageId) {
|
|
1818
|
-
return this.get(`/docs/pages/${pageId}`);
|
|
847
|
+
async getPage(pageId) {
|
|
848
|
+
return this.unwrap(this.api.GET("/docs/pages/{page_id}", { params: { path: { page_id: pageId } } }));
|
|
1819
849
|
}
|
|
1820
|
-
/**
|
|
1821
|
-
* Create a new doc page
|
|
1822
|
-
*/
|
|
1823
850
|
async createPage(data) {
|
|
1824
|
-
return this.
|
|
851
|
+
return this.unwrap(this.api.POST("/docs/pages", { body: data }));
|
|
1825
852
|
}
|
|
1826
|
-
/**
|
|
1827
|
-
* Update a doc page
|
|
1828
|
-
*/
|
|
1829
853
|
async updatePage(pageId, data) {
|
|
1830
|
-
return this.
|
|
854
|
+
return this.unwrap(this.api.PUT("/docs/pages/{page_id}", { params: { path: { page_id: pageId } }, body: data }));
|
|
1831
855
|
}
|
|
1832
|
-
/**
|
|
1833
|
-
* Publish a doc page
|
|
1834
|
-
*/
|
|
1835
|
-
async publishPage(pageId) {
|
|
1836
|
-
return this.post(`/docs/pages/${pageId}/publish`, {});
|
|
1837
|
-
}
|
|
1838
|
-
/**
|
|
1839
|
-
* Archive a doc page
|
|
1840
|
-
*/
|
|
1841
|
-
async archivePage(pageId) {
|
|
1842
|
-
return this.post(`/docs/pages/${pageId}/archive`, {});
|
|
1843
|
-
}
|
|
1844
|
-
/**
|
|
1845
|
-
* Delete a doc page
|
|
1846
|
-
*/
|
|
1847
856
|
async deletePage(pageId) {
|
|
1848
|
-
return this.
|
|
1849
|
-
}
|
|
1850
|
-
// ========== Tree ==========
|
|
1851
|
-
/**
|
|
1852
|
-
* Get the full documentation tree structure
|
|
1853
|
-
*/
|
|
1854
|
-
async getTree() {
|
|
1855
|
-
return this.get("/docs/tree");
|
|
857
|
+
return this.unwrap(this.api.DELETE("/docs/pages/{page_id}", { params: { path: { page_id: pageId } } }));
|
|
1856
858
|
}
|
|
1857
|
-
//
|
|
1858
|
-
/**
|
|
1859
|
-
* List all doc repositories
|
|
1860
|
-
*/
|
|
859
|
+
// Repositories
|
|
1861
860
|
async listRepositories(params) {
|
|
1862
|
-
|
|
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
|
-
};
|
|
861
|
+
return this.unwrap(this.api.GET("/docs/repositories", { params: { query: params } }));
|
|
1873
862
|
}
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
*/
|
|
1877
|
-
async retrieveRepository(repositoryId, params) {
|
|
1878
|
-
return this.get(
|
|
1879
|
-
`/docs/repositories/${repositoryId}`,
|
|
1880
|
-
params
|
|
1881
|
-
);
|
|
863
|
+
async getRepository(repositoryId, params) {
|
|
864
|
+
return this.unwrap(this.api.GET("/docs/repositories/{id}", { params: { path: { id: repositoryId }, query: params } }));
|
|
1882
865
|
}
|
|
1883
866
|
};
|
|
1884
867
|
|
|
@@ -1889,50 +872,17 @@ var EntitiesResource = class extends BaseResource {
|
|
|
1889
872
|
* Returns entities with a _type discriminator field
|
|
1890
873
|
*/
|
|
1891
874
|
async search(params) {
|
|
1892
|
-
|
|
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
|
-
};
|
|
875
|
+
return this.unwrap(this.api.GET("/entities", { params: { query: params } }));
|
|
1900
876
|
}
|
|
1901
877
|
};
|
|
1902
878
|
|
|
1903
879
|
// src/resources/custom-data.ts
|
|
1904
880
|
var CustomDataResource = class extends BaseResource {
|
|
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);
|
|
881
|
+
async set(data) {
|
|
882
|
+
return this.unwrap(this.api.PUT("/custom_data", { body: data }));
|
|
1913
883
|
}
|
|
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
884
|
async getValue(params) {
|
|
1921
|
-
|
|
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
|
-
);
|
|
885
|
+
return this.unwrap(this.api.GET("/custom_data", { params: { query: params } }));
|
|
1936
886
|
}
|
|
1937
887
|
};
|
|
1938
888
|
|
|
@@ -1942,130 +892,56 @@ var TimelineCommentsResource = class extends BaseResource {
|
|
|
1942
892
|
* List timeline comments with optional filters and pagination
|
|
1943
893
|
*/
|
|
1944
894
|
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
|
-
};
|
|
895
|
+
return this.unwrap(this.api.GET("/timeline_comments", { params: { query: params } }));
|
|
1956
896
|
}
|
|
1957
897
|
/**
|
|
1958
|
-
*
|
|
898
|
+
* Get a single timeline comment by ID
|
|
1959
899
|
*/
|
|
1960
|
-
async
|
|
1961
|
-
return this.
|
|
1962
|
-
`/timeline_comments/${id}`
|
|
1963
|
-
);
|
|
900
|
+
async get(id) {
|
|
901
|
+
return this.unwrap(this.api.GET("/timeline_comments/{id}", { params: { path: { id } } }));
|
|
1964
902
|
}
|
|
1965
903
|
/**
|
|
1966
904
|
* Create a new timeline comment
|
|
1967
905
|
*/
|
|
1968
906
|
async create(data) {
|
|
1969
|
-
return this.
|
|
907
|
+
return this.unwrap(this.api.POST("/timeline_comments", { body: data }));
|
|
1970
908
|
}
|
|
1971
909
|
/**
|
|
1972
910
|
* Update an existing timeline comment
|
|
1973
911
|
*/
|
|
1974
912
|
async update(id, data) {
|
|
1975
|
-
return this.
|
|
1976
|
-
`/timeline_comments/${id}`,
|
|
1977
|
-
data
|
|
1978
|
-
);
|
|
913
|
+
return this.unwrap(this.api.PUT("/timeline_comments/{id}", { params: { path: { id } }, body: data }));
|
|
1979
914
|
}
|
|
1980
915
|
/**
|
|
1981
916
|
* Delete a timeline comment
|
|
1982
917
|
*/
|
|
1983
|
-
async del(id) {
|
|
1984
|
-
return this.
|
|
918
|
+
async del(id, data) {
|
|
919
|
+
return this.unwrap(this.api.DELETE("/timeline_comments/{id}", { params: { path: { id } }, body: data }));
|
|
1985
920
|
}
|
|
1986
921
|
};
|
|
1987
922
|
|
|
1988
923
|
// src/resources/lists.ts
|
|
1989
924
|
var ListsResource = class extends BaseResource {
|
|
1990
|
-
/**
|
|
1991
|
-
* List all lists
|
|
1992
|
-
*
|
|
1993
|
-
* @param params - Optional list parameters
|
|
1994
|
-
* @returns Paginated list of lists
|
|
1995
|
-
*/
|
|
1996
925
|
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
|
-
};
|
|
926
|
+
return this.unwrap(this.api.GET("/lists", { params: { query: params } }));
|
|
2004
927
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
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
|
-
};
|
|
928
|
+
async get(listId) {
|
|
929
|
+
return this.unwrap(this.api.GET("/lists/{id}", { params: { path: { id: listId } } }));
|
|
2021
930
|
}
|
|
2022
|
-
/**
|
|
2023
|
-
* Create a new list
|
|
2024
|
-
*
|
|
2025
|
-
* @param data - List creation parameters
|
|
2026
|
-
* @returns The created list
|
|
2027
|
-
*/
|
|
2028
931
|
async create(data) {
|
|
2029
|
-
return this.
|
|
932
|
+
return this.unwrap(this.api.POST("/lists", { body: data }));
|
|
2030
933
|
}
|
|
2031
|
-
/**
|
|
2032
|
-
* Update an existing list
|
|
2033
|
-
*
|
|
2034
|
-
* @param listId - The ID of the list to update
|
|
2035
|
-
* @param data - List update parameters
|
|
2036
|
-
* @returns The updated list
|
|
2037
|
-
*/
|
|
2038
934
|
async update(listId, data) {
|
|
2039
|
-
return this.
|
|
935
|
+
return this.unwrap(this.api.PUT("/lists/{id}", { params: { path: { id: listId } }, body: data }));
|
|
2040
936
|
}
|
|
2041
|
-
/**
|
|
2042
|
-
* Delete a list
|
|
2043
|
-
*
|
|
2044
|
-
* @param listId - The ID of the list to delete
|
|
2045
|
-
* @returns Delete confirmation
|
|
2046
|
-
*/
|
|
2047
937
|
async del(listId) {
|
|
2048
|
-
return this.
|
|
938
|
+
return this.unwrap(this.api.DELETE("/lists/{id}", { params: { path: { id: listId } } }));
|
|
2049
939
|
}
|
|
2050
|
-
/**
|
|
2051
|
-
* Add customers and/or contacts to a list
|
|
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
940
|
async addEntities(listId, data) {
|
|
2058
|
-
return this.
|
|
941
|
+
return this.unwrap(this.api.POST("/lists/{id}/add", { params: { path: { id: listId } }, body: data }));
|
|
2059
942
|
}
|
|
2060
|
-
/**
|
|
2061
|
-
* Remove customers and/or contacts from a list
|
|
2062
|
-
*
|
|
2063
|
-
* @param listId - The ID of the list
|
|
2064
|
-
* @param data - IDs of customers and/or contacts to remove
|
|
2065
|
-
* @returns Count of removed entities
|
|
2066
|
-
*/
|
|
2067
943
|
async removeEntities(listId, data) {
|
|
2068
|
-
return this.
|
|
944
|
+
return this.unwrap(this.api.POST("/lists/{id}/remove", { params: { path: { id: listId } }, body: data }));
|
|
2069
945
|
}
|
|
2070
946
|
};
|
|
2071
947
|
|
|
@@ -2075,566 +951,172 @@ var JournalEntriesResource = class extends BaseResource {
|
|
|
2075
951
|
* List journal entries with optional filters and pagination
|
|
2076
952
|
*/
|
|
2077
953
|
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
|
-
};
|
|
954
|
+
return this.unwrap(this.api.GET("/journal_entries", { params: { query: params } }));
|
|
2089
955
|
}
|
|
2090
956
|
/**
|
|
2091
|
-
*
|
|
957
|
+
* Get a single journal entry by ID
|
|
2092
958
|
*/
|
|
2093
|
-
async
|
|
2094
|
-
return this.
|
|
2095
|
-
`/journal_entries/${entryId}`
|
|
2096
|
-
);
|
|
959
|
+
async get(entryId, params) {
|
|
960
|
+
return this.unwrap(this.api.GET("/journal_entries/{id}", { params: { path: { id: entryId }, query: params } }));
|
|
2097
961
|
}
|
|
2098
962
|
/**
|
|
2099
963
|
* Create a new journal entry
|
|
2100
964
|
*/
|
|
2101
965
|
async create(data) {
|
|
2102
|
-
return this.
|
|
966
|
+
return this.unwrap(this.api.POST("/journal_entries", { body: data }));
|
|
2103
967
|
}
|
|
2104
968
|
/**
|
|
2105
969
|
* Update an existing journal entry
|
|
2106
970
|
*/
|
|
2107
971
|
async update(entryId, data) {
|
|
2108
|
-
return this.
|
|
2109
|
-
`/journal_entries/${entryId}`,
|
|
2110
|
-
data
|
|
2111
|
-
);
|
|
972
|
+
return this.unwrap(this.api.PUT("/journal_entries/{id}", { params: { path: { id: entryId } }, body: data }));
|
|
2112
973
|
}
|
|
2113
974
|
/**
|
|
2114
975
|
* Delete a journal entry
|
|
2115
976
|
*/
|
|
2116
977
|
async del(entryId) {
|
|
2117
|
-
return this.
|
|
978
|
+
return this.unwrap(this.api.DELETE("/journal_entries/{id}", { params: { path: { id: entryId } } }));
|
|
2118
979
|
}
|
|
2119
980
|
};
|
|
2120
981
|
|
|
2121
982
|
// src/resources/email-unsubscribe-groups.ts
|
|
2122
983
|
var EmailUnsubscribeGroupsResource = class extends BaseResource {
|
|
2123
|
-
/**
|
|
2124
|
-
* List all email unsubscribe groups
|
|
2125
|
-
*/
|
|
2126
984
|
async list(params) {
|
|
2127
|
-
|
|
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
|
-
};
|
|
985
|
+
return this.unwrap(this.api.GET("/email/unsubscribe_groups", { params: { query: params } }));
|
|
2138
986
|
}
|
|
2139
|
-
/**
|
|
2140
|
-
* Retrieve a single unsubscribe group
|
|
2141
|
-
*/
|
|
2142
|
-
async retrieve(groupId) {
|
|
2143
|
-
return this.get(
|
|
2144
|
-
`/email/unsubscribe_groups/${groupId}`
|
|
2145
|
-
);
|
|
2146
|
-
}
|
|
2147
|
-
// ========== Members ==========
|
|
2148
|
-
/**
|
|
2149
|
-
* List members of an unsubscribe group
|
|
2150
|
-
*/
|
|
2151
987
|
async listMembers(groupId, params) {
|
|
2152
|
-
|
|
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
|
-
};
|
|
988
|
+
return this.unwrap(this.api.GET("/email/unsubscribe_groups/{id}/members", { params: { path: { id: groupId }, query: params } }));
|
|
2163
989
|
}
|
|
2164
|
-
/**
|
|
2165
|
-
* Add members to an unsubscribe group by email addresses
|
|
2166
|
-
*/
|
|
2167
990
|
async addMembers(groupId, data) {
|
|
2168
|
-
return this.
|
|
2169
|
-
`/email/unsubscribe_groups/${groupId}/members`,
|
|
2170
|
-
data
|
|
2171
|
-
);
|
|
991
|
+
return this.unwrap(this.api.POST("/email/unsubscribe_groups/{id}/members", { params: { path: { id: groupId } }, body: data }));
|
|
2172
992
|
}
|
|
2173
|
-
/**
|
|
2174
|
-
* Remove members from an unsubscribe group by email addresses
|
|
2175
|
-
*/
|
|
2176
993
|
async removeMembers(groupId, data) {
|
|
2177
|
-
return this.
|
|
2178
|
-
`/email/unsubscribe_groups/${groupId}/members?emails=${encodeURIComponent(data.emails.join(","))}`
|
|
2179
|
-
);
|
|
994
|
+
return this.unwrap(this.api.DELETE("/email/unsubscribe_groups/{id}/members", { params: { path: { id: groupId } }, body: data }));
|
|
2180
995
|
}
|
|
2181
|
-
/**
|
|
2182
|
-
* Remove a single member from an unsubscribe group by member ID
|
|
2183
|
-
*/
|
|
2184
996
|
async removeMember(groupId, memberId) {
|
|
2185
|
-
return this.
|
|
2186
|
-
`/email/unsubscribe_groups/${groupId}/members/${memberId}`
|
|
2187
|
-
);
|
|
997
|
+
return this.unwrap(this.api.DELETE("/email/unsubscribe_groups/{id}/members/{member_id}", { params: { path: { id: groupId, member_id: memberId } } }));
|
|
2188
998
|
}
|
|
2189
999
|
};
|
|
2190
1000
|
|
|
2191
1001
|
// src/resources/flow-extensions.ts
|
|
2192
1002
|
var FlowExtensionsResource = class extends BaseResource {
|
|
2193
|
-
//
|
|
2194
|
-
/**
|
|
2195
|
-
* List flow extension actions
|
|
2196
|
-
*/
|
|
1003
|
+
// Actions
|
|
2197
1004
|
async listActions(params) {
|
|
2198
|
-
|
|
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
|
-
};
|
|
1005
|
+
return this.unwrap(this.api.GET("/flow/extensions/actions", { params: { query: params } }));
|
|
2209
1006
|
}
|
|
2210
|
-
/**
|
|
2211
|
-
* Retrieve a single flow extension action
|
|
2212
|
-
*/
|
|
2213
|
-
async retrieveAction(actionId) {
|
|
2214
|
-
return this.get(
|
|
2215
|
-
`/flow/extensions/actions/${actionId}`
|
|
2216
|
-
);
|
|
2217
|
-
}
|
|
2218
|
-
/**
|
|
2219
|
-
* Create a new flow extension action
|
|
2220
|
-
*/
|
|
2221
1007
|
async createAction(data) {
|
|
2222
|
-
return this.
|
|
2223
|
-
"/flow/extensions/actions",
|
|
2224
|
-
data
|
|
2225
|
-
);
|
|
1008
|
+
return this.unwrap(this.api.POST("/flow/extensions/actions", { body: data }));
|
|
2226
1009
|
}
|
|
2227
|
-
/**
|
|
2228
|
-
* Update an existing flow extension action
|
|
2229
|
-
*/
|
|
2230
1010
|
async updateAction(actionId, data) {
|
|
2231
|
-
return this.
|
|
2232
|
-
`/flow/extensions/actions/${actionId}`,
|
|
2233
|
-
data
|
|
2234
|
-
);
|
|
1011
|
+
return this.unwrap(this.api.PUT("/flow/extensions/actions/{id}", { params: { path: { id: actionId } }, body: data }));
|
|
2235
1012
|
}
|
|
2236
|
-
/**
|
|
2237
|
-
* Delete a flow extension action
|
|
2238
|
-
*/
|
|
2239
1013
|
async deleteAction(actionId) {
|
|
2240
|
-
return this.
|
|
2241
|
-
`/flow/extensions/actions/${actionId}`
|
|
2242
|
-
);
|
|
1014
|
+
return this.unwrap(this.api.DELETE("/flow/extensions/actions/{id}", { params: { path: { id: actionId } } }));
|
|
2243
1015
|
}
|
|
2244
|
-
//
|
|
2245
|
-
/**
|
|
2246
|
-
* Update a flow action run status
|
|
2247
|
-
* Used to report completion or failure of async action execution
|
|
2248
|
-
*/
|
|
1016
|
+
// Action Runs
|
|
2249
1017
|
async updateActionRun(runId, data) {
|
|
2250
|
-
return this.
|
|
1018
|
+
return this.unwrap(this.api.PUT("/flow/actions/runs/{id}", { params: { path: { id: runId } }, body: data }));
|
|
1019
|
+
}
|
|
1020
|
+
// Triggers
|
|
1021
|
+
async listTriggers() {
|
|
1022
|
+
return this.unwrap(this.api.GET("/flow/extensions/triggers"));
|
|
1023
|
+
}
|
|
1024
|
+
async getTrigger(handle) {
|
|
1025
|
+
return this.unwrap(this.api.GET("/flow/extensions/triggers/{handle}", { params: { path: { handle } } }));
|
|
1026
|
+
}
|
|
1027
|
+
async createTrigger(data) {
|
|
1028
|
+
return this.unwrap(this.api.POST("/flow/extensions/triggers", { body: data }));
|
|
1029
|
+
}
|
|
1030
|
+
async updateTrigger(handle, data) {
|
|
1031
|
+
return this.unwrap(this.api.PUT("/flow/extensions/triggers/{handle}", { params: { path: { handle } }, body: data }));
|
|
1032
|
+
}
|
|
1033
|
+
async deleteTrigger(handle) {
|
|
1034
|
+
return this.unwrap(this.api.DELETE("/flow/extensions/triggers/{handle}", { params: { path: { handle } } }));
|
|
1035
|
+
}
|
|
1036
|
+
async fireTrigger(handle, data) {
|
|
1037
|
+
return this.unwrap(this.api.POST("/flow/extensions/triggers/{handle}/fire", { params: { path: { handle } }, body: data }));
|
|
2251
1038
|
}
|
|
2252
1039
|
};
|
|
2253
1040
|
|
|
2254
1041
|
// src/resources/ai-agent-runs.ts
|
|
2255
1042
|
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
1043
|
async create(agentId, data) {
|
|
2262
|
-
return this.
|
|
2263
|
-
`/ai/agents/${agentId}/runs`,
|
|
2264
|
-
data || {}
|
|
2265
|
-
);
|
|
1044
|
+
return this.unwrap(this.api.POST("/ai/agents/{agentId}/runs", { params: { path: { agentId } }, body: data }));
|
|
2266
1045
|
}
|
|
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
|
-
);
|
|
1046
|
+
async get(agentId, runId) {
|
|
1047
|
+
return this.unwrap(this.api.GET("/ai/agents/{agentId}/runs/{runId}", { params: { path: { agentId, runId } } }));
|
|
2275
1048
|
}
|
|
2276
1049
|
/**
|
|
2277
|
-
* Create
|
|
2278
|
-
* Convenience method that handles the async polling pattern
|
|
2279
|
-
*
|
|
2280
|
-
* @param agentId - The ID of the AI agent
|
|
2281
|
-
* @param data - Optional parameters for the run
|
|
2282
|
-
* @param options - Polling options
|
|
2283
|
-
* @returns The completed agent run
|
|
1050
|
+
* Create an agent run and poll until it completes or errors.
|
|
2284
1051
|
*/
|
|
2285
1052
|
async createAndWait(agentId, data, options) {
|
|
2286
|
-
const timeout = options
|
|
2287
|
-
const
|
|
2288
|
-
const
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
1053
|
+
const { timeout = 3e5, pollInterval = 2e3 } = options || {};
|
|
1054
|
+
const result = await this.create(agentId, data);
|
|
1055
|
+
const run = result.run;
|
|
1056
|
+
if (!run?.id) throw new Error("Agent run ID not returned");
|
|
1057
|
+
const start = Date.now();
|
|
1058
|
+
while (Date.now() - start < timeout) {
|
|
1059
|
+
const response = await this.get(agentId, run.id);
|
|
1060
|
+
const agentRun = response.run;
|
|
1061
|
+
if (agentRun.status === "completed" || agentRun.status === "error") {
|
|
1062
|
+
return agentRun;
|
|
2294
1063
|
}
|
|
2295
1064
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
2296
1065
|
}
|
|
2297
|
-
throw new Error(
|
|
2298
|
-
`Agent run ${run.id} did not complete within ${timeout}ms timeout`
|
|
2299
|
-
);
|
|
1066
|
+
throw new Error(`Agent run timed out after ${timeout}ms`);
|
|
2300
1067
|
}
|
|
2301
1068
|
};
|
|
2302
1069
|
|
|
2303
1070
|
// src/resources/meetings.ts
|
|
2304
1071
|
var MeetingsResource = class extends BaseResource {
|
|
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
|
-
*/
|
|
2323
1072
|
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
|
-
};
|
|
1073
|
+
return this.unwrap(this.api.GET("/meetings", { params: { query: params } }));
|
|
2333
1074
|
}
|
|
2334
|
-
|
|
2335
|
-
|
|
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}`);
|
|
1075
|
+
async get(meetingId) {
|
|
1076
|
+
return this.unwrap(this.api.GET("/meetings/{id}", { params: { path: { id: meetingId } } }));
|
|
2348
1077
|
}
|
|
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
1078
|
async create(data) {
|
|
2388
|
-
return this.
|
|
1079
|
+
return this.unwrap(this.api.POST("/meetings", { body: data }));
|
|
2389
1080
|
}
|
|
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
1081
|
async update(meetingId, data) {
|
|
2407
|
-
return this.
|
|
1082
|
+
return this.unwrap(this.api.PUT("/meetings/{id}", { params: { path: { id: meetingId } }, body: data }));
|
|
2408
1083
|
}
|
|
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
1084
|
async del(meetingId) {
|
|
2421
|
-
return this.
|
|
1085
|
+
return this.unwrap(this.api.DELETE("/meetings/{id}", { params: { path: { id: meetingId } } }));
|
|
2422
1086
|
}
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
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
|
-
);
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
// src/resources/synced-emails.ts
|
|
1090
|
+
var SyncedEmailsResource = class extends BaseResource {
|
|
1091
|
+
async list(params) {
|
|
1092
|
+
return this.unwrap(this.untypedApi.GET("/synced_emails", { params: { query: params } }));
|
|
2454
1093
|
}
|
|
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);
|
|
1094
|
+
async get(syncedEmailId) {
|
|
1095
|
+
return this.unwrap(this.untypedApi.GET("/synced_emails/{id}", { params: { path: { id: syncedEmailId } } }));
|
|
2478
1096
|
}
|
|
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
|
-
);
|
|
1097
|
+
async create(data) {
|
|
1098
|
+
return this.unwrap(this.untypedApi.POST("/synced_emails", { body: data }));
|
|
2514
1099
|
}
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
*
|
|
2518
|
-
* Updates attendee details such as name or links the attendee to a Mantle contact.
|
|
2519
|
-
* This is useful for speaker identification in transcripts.
|
|
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
|
-
);
|
|
1100
|
+
async update(syncedEmailId, data) {
|
|
1101
|
+
return this.unwrap(this.untypedApi.PUT("/synced_emails/{id}", { params: { path: { id: syncedEmailId } }, body: data }));
|
|
2559
1102
|
}
|
|
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
|
-
);
|
|
1103
|
+
async del(syncedEmailId) {
|
|
1104
|
+
return this.unwrap(this.untypedApi.DELETE("/synced_emails/{id}", { params: { path: { id: syncedEmailId } } }));
|
|
2581
1105
|
}
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
*
|
|
2585
|
-
* Creates a real Task from the suggestion. Optional overrides allow
|
|
2586
|
-
* modifying the title, description, priority, due date, or assignee
|
|
2587
|
-
* before creating the task.
|
|
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
|
-
);
|
|
1106
|
+
async addMessages(syncedEmailId, data) {
|
|
1107
|
+
return this.unwrap(this.untypedApi.POST("/synced_emails/{id}/messages", { params: { path: { id: syncedEmailId } }, body: data }));
|
|
2615
1108
|
}
|
|
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
|
-
);
|
|
1109
|
+
async getMessages(syncedEmailId) {
|
|
1110
|
+
return this.unwrap(this.untypedApi.GET("/synced_emails/{id}/messages", { params: { path: { id: syncedEmailId } } }));
|
|
2634
1111
|
}
|
|
2635
1112
|
};
|
|
2636
1113
|
|
|
2637
1114
|
// src/client.ts
|
|
1115
|
+
function createTimeoutSignal(ms) {
|
|
1116
|
+
const controller = new AbortController();
|
|
1117
|
+
setTimeout(() => controller.abort(), ms);
|
|
1118
|
+
return controller.signal;
|
|
1119
|
+
}
|
|
2638
1120
|
var MantleCoreClient = class {
|
|
2639
1121
|
constructor(config) {
|
|
2640
1122
|
if (!config.apiKey && !config.accessToken) {
|
|
@@ -2642,18 +1124,35 @@ var MantleCoreClient = class {
|
|
|
2642
1124
|
"MantleCoreClient requires either apiKey or accessToken"
|
|
2643
1125
|
);
|
|
2644
1126
|
}
|
|
2645
|
-
this.baseURL = config.baseURL || "https://api.heymantle.com/v1";
|
|
2646
1127
|
this.apiKey = config.apiKey;
|
|
2647
1128
|
this.accessToken = config.accessToken;
|
|
2648
|
-
|
|
2649
|
-
this.
|
|
1129
|
+
const timeoutMs = config.timeout ?? 3e4;
|
|
1130
|
+
this._api = createClient({
|
|
1131
|
+
baseUrl: config.baseURL || "https://api.heymantle.com/v1",
|
|
1132
|
+
headers: {
|
|
1133
|
+
"Content-Type": "application/json"
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
this._api.use({
|
|
1137
|
+
onRequest: ({ request }) => {
|
|
1138
|
+
const token = this.accessToken || this.apiKey;
|
|
1139
|
+
if (token) {
|
|
1140
|
+
request.headers.set("Authorization", `Bearer ${token}`);
|
|
1141
|
+
}
|
|
1142
|
+
return request;
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
if (timeoutMs > 0) {
|
|
1146
|
+
this._api.use({
|
|
1147
|
+
onRequest: ({ request }) => {
|
|
1148
|
+
const signal = typeof AbortSignal !== "undefined" && "timeout" in AbortSignal ? AbortSignal.timeout(timeoutMs) : createTimeoutSignal(timeoutMs);
|
|
1149
|
+
return new Request(request, { signal });
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
2650
1153
|
if (config.middleware) {
|
|
2651
1154
|
for (const mw of config.middleware) {
|
|
2652
|
-
|
|
2653
|
-
this.middlewareManager.use(mw[0], mw[1]);
|
|
2654
|
-
} else {
|
|
2655
|
-
this.middlewareManager.use(mw);
|
|
2656
|
-
}
|
|
1155
|
+
this._api.use(mw);
|
|
2657
1156
|
}
|
|
2658
1157
|
}
|
|
2659
1158
|
this.customers = new CustomersResource(this);
|
|
@@ -2693,41 +1192,24 @@ var MantleCoreClient = class {
|
|
|
2693
1192
|
this.flowExtensions = new FlowExtensionsResource(this);
|
|
2694
1193
|
this.aiAgentRuns = new AiAgentRunsResource(this);
|
|
2695
1194
|
this.meetings = new MeetingsResource(this);
|
|
1195
|
+
this.syncedEmails = new SyncedEmailsResource(this);
|
|
2696
1196
|
}
|
|
2697
1197
|
/**
|
|
2698
|
-
* Register
|
|
2699
|
-
*
|
|
2700
|
-
* @param middleware - The middleware function to register
|
|
2701
|
-
* @param options - Optional configuration (name, priority)
|
|
2702
|
-
* @returns this for chaining
|
|
2703
|
-
*
|
|
2704
|
-
* @example
|
|
2705
|
-
* ```typescript
|
|
2706
|
-
* client.use(async (ctx, next) => {
|
|
2707
|
-
* console.log('Request:', ctx.request.url);
|
|
2708
|
-
* await next();
|
|
2709
|
-
* console.log('Response:', ctx.response?.status);
|
|
2710
|
-
* });
|
|
2711
|
-
* ```
|
|
1198
|
+
* Register an openapi-fetch middleware
|
|
2712
1199
|
*/
|
|
2713
|
-
use(middleware
|
|
2714
|
-
this.
|
|
1200
|
+
use(middleware) {
|
|
1201
|
+
this._api.use(middleware);
|
|
2715
1202
|
return this;
|
|
2716
1203
|
}
|
|
2717
1204
|
/**
|
|
2718
|
-
* Remove a middleware
|
|
2719
|
-
*
|
|
2720
|
-
* @param name - The name of the middleware to remove
|
|
2721
|
-
* @returns true if removed, false if not found
|
|
1205
|
+
* Remove a registered middleware
|
|
2722
1206
|
*/
|
|
2723
|
-
|
|
2724
|
-
|
|
1207
|
+
eject(middleware) {
|
|
1208
|
+
this._api.eject(middleware);
|
|
1209
|
+
return this;
|
|
2725
1210
|
}
|
|
2726
1211
|
/**
|
|
2727
1212
|
* Update authentication credentials
|
|
2728
|
-
* Useful for middleware that needs to refresh tokens
|
|
2729
|
-
*
|
|
2730
|
-
* @param credentials - New credentials to set
|
|
2731
1213
|
*/
|
|
2732
1214
|
updateAuth(credentials) {
|
|
2733
1215
|
if (credentials.apiKey !== void 0) {
|
|
@@ -2737,234 +1219,43 @@ var MantleCoreClient = class {
|
|
|
2737
1219
|
this.accessToken = credentials.accessToken;
|
|
2738
1220
|
}
|
|
2739
1221
|
}
|
|
2740
|
-
/**
|
|
2741
|
-
* Performs a GET request to the API
|
|
2742
|
-
*/
|
|
2743
|
-
async get(endpoint, params) {
|
|
2744
|
-
const sanitizedParams = params ? sanitizeObject(params) : {};
|
|
2745
|
-
const query = toQueryString(sanitizedParams);
|
|
2746
|
-
const url = query ? `${endpoint}?${query}` : endpoint;
|
|
2747
|
-
return this.makeRequest(url, { method: "GET" });
|
|
2748
|
-
}
|
|
2749
|
-
/**
|
|
2750
|
-
* Performs a POST request to the API
|
|
2751
|
-
*/
|
|
2752
|
-
async post(endpoint, data) {
|
|
2753
|
-
const sanitizedData = data ? sanitizeObject(data) : {};
|
|
2754
|
-
return this.makeRequest(endpoint, {
|
|
2755
|
-
method: "POST",
|
|
2756
|
-
body: JSON.stringify(sanitizedData)
|
|
2757
|
-
});
|
|
2758
|
-
}
|
|
2759
|
-
/**
|
|
2760
|
-
* Performs a PUT request to the API
|
|
2761
|
-
*/
|
|
2762
|
-
async put(endpoint, data) {
|
|
2763
|
-
const sanitizedData = data ? sanitizeObject(data) : {};
|
|
2764
|
-
return this.makeRequest(endpoint, {
|
|
2765
|
-
method: "PUT",
|
|
2766
|
-
body: JSON.stringify(sanitizedData)
|
|
2767
|
-
});
|
|
2768
|
-
}
|
|
2769
|
-
/**
|
|
2770
|
-
* Performs a DELETE request to the API
|
|
2771
|
-
*/
|
|
2772
|
-
async delete(endpoint) {
|
|
2773
|
-
return this.makeRequest(endpoint, { method: "DELETE" });
|
|
2774
|
-
}
|
|
2775
|
-
/**
|
|
2776
|
-
* Makes an HTTP request to the API
|
|
2777
|
-
*/
|
|
2778
|
-
async makeRequest(endpoint, options) {
|
|
2779
|
-
if (this.middlewareManager.hasMiddleware()) {
|
|
2780
|
-
return this.makeRequestWithMiddleware(endpoint, options);
|
|
2781
|
-
}
|
|
2782
|
-
return this.executeRequest(endpoint, options);
|
|
2783
|
-
}
|
|
2784
|
-
/**
|
|
2785
|
-
* Execute request through middleware chain
|
|
2786
|
-
*/
|
|
2787
|
-
async makeRequestWithMiddleware(endpoint, options) {
|
|
2788
|
-
const request = {
|
|
2789
|
-
url: `${this.baseURL}${endpoint}`,
|
|
2790
|
-
method: options.method,
|
|
2791
|
-
headers: {
|
|
2792
|
-
Authorization: this.getAuthHeader(),
|
|
2793
|
-
"Content-Type": "application/json",
|
|
2794
|
-
...options.headers
|
|
2795
|
-
},
|
|
2796
|
-
body: options.body,
|
|
2797
|
-
endpoint
|
|
2798
|
-
};
|
|
2799
|
-
const ctx = {
|
|
2800
|
-
request,
|
|
2801
|
-
retry: false,
|
|
2802
|
-
retryCount: 0,
|
|
2803
|
-
maxRetries: 3,
|
|
2804
|
-
updateAuth: (credentials) => this.updateAuth(credentials)
|
|
2805
|
-
};
|
|
2806
|
-
const coreHandler = async () => {
|
|
2807
|
-
const controller = new AbortController();
|
|
2808
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2809
|
-
try {
|
|
2810
|
-
const response2 = await fetch(ctx.request.url, {
|
|
2811
|
-
method: ctx.request.method,
|
|
2812
|
-
body: ctx.request.body,
|
|
2813
|
-
headers: ctx.request.headers,
|
|
2814
|
-
signal: controller.signal
|
|
2815
|
-
});
|
|
2816
|
-
clearTimeout(timeoutId);
|
|
2817
|
-
if (!response2.ok) {
|
|
2818
|
-
await this.handleErrorResponse(response2);
|
|
2819
|
-
}
|
|
2820
|
-
const text = await response2.text();
|
|
2821
|
-
const data = text ? JSON.parse(text) : {};
|
|
2822
|
-
return {
|
|
2823
|
-
data,
|
|
2824
|
-
status: response2.status,
|
|
2825
|
-
headers: response2.headers
|
|
2826
|
-
};
|
|
2827
|
-
} catch (error) {
|
|
2828
|
-
clearTimeout(timeoutId);
|
|
2829
|
-
if (error instanceof MantleAPIError) {
|
|
2830
|
-
throw error;
|
|
2831
|
-
}
|
|
2832
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
2833
|
-
throw new MantleAPIError("Request timeout", 408);
|
|
2834
|
-
}
|
|
2835
|
-
throw new MantleAPIError(
|
|
2836
|
-
error instanceof Error ? error.message : "Unknown error occurred",
|
|
2837
|
-
500
|
|
2838
|
-
);
|
|
2839
|
-
}
|
|
2840
|
-
};
|
|
2841
|
-
const response = await this.middlewareManager.execute(ctx, coreHandler);
|
|
2842
|
-
return response.data;
|
|
2843
|
-
}
|
|
2844
|
-
/**
|
|
2845
|
-
* Direct request execution (no middleware)
|
|
2846
|
-
*/
|
|
2847
|
-
async executeRequest(endpoint, options) {
|
|
2848
|
-
const authHeader = this.getAuthHeader();
|
|
2849
|
-
const controller = new AbortController();
|
|
2850
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
2851
|
-
try {
|
|
2852
|
-
const response = await fetch(`${this.baseURL}${endpoint}`, {
|
|
2853
|
-
method: options.method,
|
|
2854
|
-
body: options.body,
|
|
2855
|
-
headers: {
|
|
2856
|
-
Authorization: authHeader,
|
|
2857
|
-
"Content-Type": "application/json",
|
|
2858
|
-
...options.headers
|
|
2859
|
-
},
|
|
2860
|
-
signal: controller.signal
|
|
2861
|
-
});
|
|
2862
|
-
clearTimeout(timeoutId);
|
|
2863
|
-
if (!response.ok) {
|
|
2864
|
-
await this.handleErrorResponse(response);
|
|
2865
|
-
}
|
|
2866
|
-
const text = await response.text();
|
|
2867
|
-
if (!text) {
|
|
2868
|
-
return {};
|
|
2869
|
-
}
|
|
2870
|
-
return JSON.parse(text);
|
|
2871
|
-
} catch (error) {
|
|
2872
|
-
clearTimeout(timeoutId);
|
|
2873
|
-
if (error instanceof MantleAPIError) {
|
|
2874
|
-
throw error;
|
|
2875
|
-
}
|
|
2876
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
2877
|
-
throw new MantleAPIError("Request timeout", 408);
|
|
2878
|
-
}
|
|
2879
|
-
throw new MantleAPIError(
|
|
2880
|
-
error instanceof Error ? error.message : "Unknown error occurred",
|
|
2881
|
-
500
|
|
2882
|
-
);
|
|
2883
|
-
}
|
|
2884
|
-
}
|
|
2885
|
-
/**
|
|
2886
|
-
* Gets the authorization header value
|
|
2887
|
-
*/
|
|
2888
|
-
getAuthHeader() {
|
|
2889
|
-
if (this.accessToken) {
|
|
2890
|
-
return `Bearer ${this.accessToken}`;
|
|
2891
|
-
}
|
|
2892
|
-
if (this.apiKey) {
|
|
2893
|
-
return `Bearer ${this.apiKey}`;
|
|
2894
|
-
}
|
|
2895
|
-
throw new MantleAuthenticationError(
|
|
2896
|
-
"Authentication not configured. Please set up API key or OAuth."
|
|
2897
|
-
);
|
|
2898
|
-
}
|
|
2899
|
-
/**
|
|
2900
|
-
* Handles error responses from the API
|
|
2901
|
-
*/
|
|
2902
|
-
async handleErrorResponse(response) {
|
|
2903
|
-
let errorData = {};
|
|
2904
|
-
try {
|
|
2905
|
-
const text = await response.text();
|
|
2906
|
-
if (text) {
|
|
2907
|
-
errorData = JSON.parse(text);
|
|
2908
|
-
}
|
|
2909
|
-
} catch {
|
|
2910
|
-
}
|
|
2911
|
-
const message = errorData.error || `API request failed: ${response.status}`;
|
|
2912
|
-
switch (response.status) {
|
|
2913
|
-
case 401:
|
|
2914
|
-
throw new MantleAuthenticationError(message);
|
|
2915
|
-
case 403:
|
|
2916
|
-
throw new MantlePermissionError(message);
|
|
2917
|
-
case 404:
|
|
2918
|
-
throw new MantleAPIError(message, 404, errorData.details);
|
|
2919
|
-
case 422:
|
|
2920
|
-
throw new MantleValidationError(message, errorData.details);
|
|
2921
|
-
case 429: {
|
|
2922
|
-
const retryAfter = response.headers.get("Retry-After");
|
|
2923
|
-
throw new MantleRateLimitError(
|
|
2924
|
-
message,
|
|
2925
|
-
retryAfter ? parseInt(retryAfter, 10) : void 0
|
|
2926
|
-
);
|
|
2927
|
-
}
|
|
2928
|
-
default:
|
|
2929
|
-
throw new MantleAPIError(message, response.status, errorData.details);
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2932
1222
|
};
|
|
2933
1223
|
|
|
2934
1224
|
// src/middleware/auth-refresh.ts
|
|
2935
1225
|
function createAuthRefreshMiddleware(options) {
|
|
2936
1226
|
const {
|
|
2937
1227
|
refreshToken,
|
|
1228
|
+
updateAuth,
|
|
2938
1229
|
onRefreshSuccess,
|
|
2939
1230
|
onRefreshFailed,
|
|
2940
1231
|
maxRefreshAttempts = 1
|
|
2941
1232
|
} = options;
|
|
2942
1233
|
let refreshAttempts = 0;
|
|
2943
|
-
return
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
} catch (error) {
|
|
2947
|
-
if (!(error instanceof MantleAuthenticationError)) {
|
|
2948
|
-
throw error;
|
|
2949
|
-
}
|
|
1234
|
+
return {
|
|
1235
|
+
async onResponse({ request, response }) {
|
|
1236
|
+
if (response.status !== 401) return void 0;
|
|
2950
1237
|
if (refreshAttempts >= maxRefreshAttempts) {
|
|
2951
1238
|
refreshAttempts = 0;
|
|
2952
|
-
|
|
1239
|
+
return void 0;
|
|
2953
1240
|
}
|
|
2954
1241
|
refreshAttempts++;
|
|
2955
1242
|
try {
|
|
2956
1243
|
const newToken = await refreshToken();
|
|
2957
|
-
|
|
2958
|
-
ctx.request.headers.Authorization = `Bearer ${newToken}`;
|
|
1244
|
+
updateAuth(newToken);
|
|
2959
1245
|
onRefreshSuccess?.(newToken);
|
|
2960
|
-
ctx.retry = true;
|
|
2961
1246
|
refreshAttempts = 0;
|
|
1247
|
+
const headers = new Headers(request.headers);
|
|
1248
|
+
headers.set("Authorization", `Bearer ${newToken}`);
|
|
1249
|
+
return fetch(new Request(request.url, {
|
|
1250
|
+
method: request.method,
|
|
1251
|
+
headers,
|
|
1252
|
+
body: request.body,
|
|
1253
|
+
signal: request.signal
|
|
1254
|
+
}));
|
|
2962
1255
|
} catch (refreshError) {
|
|
2963
1256
|
refreshAttempts = 0;
|
|
2964
1257
|
onRefreshFailed?.(refreshError);
|
|
2965
|
-
|
|
2966
|
-
"Authentication failed. Please re-authenticate."
|
|
2967
|
-
);
|
|
1258
|
+
return void 0;
|
|
2968
1259
|
}
|
|
2969
1260
|
}
|
|
2970
1261
|
};
|
|
@@ -2979,69 +1270,52 @@ var RateLimiter = class {
|
|
|
2979
1270
|
this.burstWindowMs = options.burstWindowMs;
|
|
2980
1271
|
this.throttleThreshold = options.throttleThreshold;
|
|
2981
1272
|
}
|
|
2982
|
-
/**
|
|
2983
|
-
* Prune timestamps older than the burst window
|
|
2984
|
-
*/
|
|
2985
1273
|
prune() {
|
|
2986
|
-
const
|
|
2987
|
-
const cutoff = now - this.burstWindowMs;
|
|
1274
|
+
const cutoff = Date.now() - this.burstWindowMs;
|
|
2988
1275
|
this.timestamps = this.timestamps.filter((ts) => ts > cutoff);
|
|
2989
1276
|
}
|
|
2990
|
-
/**
|
|
2991
|
-
* Get current usage statistics
|
|
2992
|
-
*/
|
|
2993
1277
|
getUsage() {
|
|
2994
1278
|
this.prune();
|
|
2995
|
-
const
|
|
2996
|
-
const oneMinuteAgo = now - 6e4;
|
|
1279
|
+
const oneMinuteAgo = Date.now() - 6e4;
|
|
2997
1280
|
const minuteUsage = this.timestamps.filter((ts) => ts > oneMinuteAgo).length;
|
|
2998
|
-
|
|
2999
|
-
return { minuteUsage, burstUsage };
|
|
1281
|
+
return { minuteUsage, burstUsage: this.timestamps.length };
|
|
3000
1282
|
}
|
|
3001
|
-
/**
|
|
3002
|
-
* Calculate the delay needed before the next request can be made
|
|
3003
|
-
* Returns 0 if no delay is needed
|
|
3004
|
-
*/
|
|
3005
1283
|
getDelay() {
|
|
3006
1284
|
const { minuteUsage, burstUsage } = this.getUsage();
|
|
3007
1285
|
const minuteThreshold = Math.floor(this.requestsPerMinute * this.throttleThreshold);
|
|
3008
1286
|
const burstThreshold = Math.floor(this.burstLimit * this.throttleThreshold);
|
|
1287
|
+
const now = Date.now();
|
|
3009
1288
|
if (minuteUsage >= minuteThreshold) {
|
|
3010
|
-
const now = Date.now();
|
|
3011
1289
|
const oneMinuteAgo = now - 6e4;
|
|
3012
|
-
const
|
|
3013
|
-
if (
|
|
3014
|
-
const delay =
|
|
3015
|
-
if (delay > 0)
|
|
3016
|
-
return delay;
|
|
3017
|
-
}
|
|
1290
|
+
const oldest = this.timestamps.find((ts) => ts > oneMinuteAgo);
|
|
1291
|
+
if (oldest) {
|
|
1292
|
+
const delay = oldest + 6e4 - now;
|
|
1293
|
+
if (delay > 0) return delay;
|
|
3018
1294
|
}
|
|
3019
1295
|
}
|
|
3020
1296
|
if (burstUsage >= burstThreshold) {
|
|
3021
|
-
const now = Date.now();
|
|
3022
1297
|
const burstCutoff = now - this.burstWindowMs;
|
|
3023
|
-
const
|
|
3024
|
-
if (
|
|
3025
|
-
const delay =
|
|
3026
|
-
if (delay > 0)
|
|
3027
|
-
return delay;
|
|
3028
|
-
}
|
|
1298
|
+
const oldest = this.timestamps.find((ts) => ts > burstCutoff);
|
|
1299
|
+
if (oldest) {
|
|
1300
|
+
const delay = oldest + this.burstWindowMs - now;
|
|
1301
|
+
if (delay > 0) return delay;
|
|
3029
1302
|
}
|
|
3030
1303
|
}
|
|
3031
1304
|
return 0;
|
|
3032
1305
|
}
|
|
3033
|
-
/**
|
|
3034
|
-
* Record a request timestamp
|
|
3035
|
-
*/
|
|
3036
1306
|
recordRequest() {
|
|
3037
1307
|
this.timestamps.push(Date.now());
|
|
3038
1308
|
}
|
|
3039
1309
|
};
|
|
3040
|
-
function calculateRetryDelay(
|
|
1310
|
+
function calculateRetryDelay(retryAfterHeader, retryCount, options) {
|
|
1311
|
+
if (retryAfterHeader) {
|
|
1312
|
+
const retryAfter = parseInt(retryAfterHeader, 10);
|
|
1313
|
+
if (!isNaN(retryAfter) && retryAfter > 0) {
|
|
1314
|
+
return retryAfter * 1e3;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
3041
1317
|
let delay;
|
|
3042
|
-
if (
|
|
3043
|
-
return retryAfter * 1e3;
|
|
3044
|
-
} else if (options.exponentialBackoff) {
|
|
1318
|
+
if (options.exponentialBackoff) {
|
|
3045
1319
|
delay = options.baseDelay * Math.pow(2, retryCount);
|
|
3046
1320
|
} else {
|
|
3047
1321
|
delay = options.baseDelay;
|
|
@@ -3065,37 +1339,42 @@ function createRateLimitMiddleware(options = {}) {
|
|
|
3065
1339
|
burstWindowMs = 3e5,
|
|
3066
1340
|
throttleThreshold = 0.9
|
|
3067
1341
|
} = options;
|
|
3068
|
-
const rateLimiter = enableThrottle ? new RateLimiter({
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
if (rateLimiter) {
|
|
3076
|
-
const delay = rateLimiter.getDelay();
|
|
3077
|
-
if (delay > 0) {
|
|
3078
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
try {
|
|
3082
|
-
await next();
|
|
3083
|
-
rateLimiter?.recordRequest();
|
|
3084
|
-
} catch (error) {
|
|
3085
|
-
rateLimiter?.recordRequest();
|
|
3086
|
-
if (enableRetry && error instanceof MantleRateLimitError) {
|
|
3087
|
-
if (ctx.retryCount < maxRetries) {
|
|
3088
|
-
const delay = calculateRetryDelay(error.retryAfter, ctx.retryCount, {
|
|
3089
|
-
baseDelay,
|
|
3090
|
-
exponentialBackoff,
|
|
3091
|
-
jitter
|
|
3092
|
-
});
|
|
1342
|
+
const rateLimiter = enableThrottle ? new RateLimiter({ requestsPerMinute, burstLimit, burstWindowMs, throttleThreshold }) : null;
|
|
1343
|
+
let retryCount = 0;
|
|
1344
|
+
return {
|
|
1345
|
+
async onRequest({ request }) {
|
|
1346
|
+
if (rateLimiter) {
|
|
1347
|
+
const delay = rateLimiter.getDelay();
|
|
1348
|
+
if (delay > 0) {
|
|
3093
1349
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
3094
|
-
ctx.retry = true;
|
|
3095
|
-
return;
|
|
3096
1350
|
}
|
|
3097
1351
|
}
|
|
3098
|
-
|
|
1352
|
+
return request;
|
|
1353
|
+
},
|
|
1354
|
+
async onResponse({ request, response }) {
|
|
1355
|
+
rateLimiter?.recordRequest();
|
|
1356
|
+
if (response.status !== 429 || !enableRetry) return void 0;
|
|
1357
|
+
if (retryCount >= maxRetries) {
|
|
1358
|
+
retryCount = 0;
|
|
1359
|
+
return void 0;
|
|
1360
|
+
}
|
|
1361
|
+
const delay = calculateRetryDelay(
|
|
1362
|
+
response.headers.get("Retry-After"),
|
|
1363
|
+
retryCount,
|
|
1364
|
+
{ baseDelay, exponentialBackoff, jitter }
|
|
1365
|
+
);
|
|
1366
|
+
retryCount++;
|
|
1367
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1368
|
+
const retryResponse = await fetch(new Request(request.url, {
|
|
1369
|
+
method: request.method,
|
|
1370
|
+
headers: request.headers,
|
|
1371
|
+
body: request.body,
|
|
1372
|
+
signal: request.signal
|
|
1373
|
+
}));
|
|
1374
|
+
if (retryResponse.status !== 429) {
|
|
1375
|
+
retryCount = 0;
|
|
1376
|
+
}
|
|
1377
|
+
return retryResponse;
|
|
3099
1378
|
}
|
|
3100
1379
|
};
|
|
3101
1380
|
}
|
|
@@ -3106,6 +1385,7 @@ export {
|
|
|
3106
1385
|
AffiliateReferralsResource,
|
|
3107
1386
|
AffiliatesResource,
|
|
3108
1387
|
AgentsResource,
|
|
1388
|
+
AiAgentRunsResource,
|
|
3109
1389
|
AppsResource,
|
|
3110
1390
|
BaseResource,
|
|
3111
1391
|
ChannelsResource,
|
|
@@ -3119,8 +1399,12 @@ export {
|
|
|
3119
1399
|
DealFlowsResource,
|
|
3120
1400
|
DealsResource,
|
|
3121
1401
|
DocsResource,
|
|
1402
|
+
EmailUnsubscribeGroupsResource,
|
|
3122
1403
|
EntitiesResource,
|
|
1404
|
+
FlowExtensionsResource,
|
|
3123
1405
|
FlowsResource,
|
|
1406
|
+
JournalEntriesResource,
|
|
1407
|
+
ListsResource,
|
|
3124
1408
|
MantleAPIError,
|
|
3125
1409
|
MantleAuthenticationError,
|
|
3126
1410
|
MantleCoreClient,
|
|
@@ -3129,12 +1413,14 @@ export {
|
|
|
3129
1413
|
MantleRateLimitError,
|
|
3130
1414
|
MantleValidationError,
|
|
3131
1415
|
MeResource,
|
|
1416
|
+
MeetingsResource,
|
|
3132
1417
|
MetricsResource,
|
|
3133
|
-
MiddlewareManager,
|
|
3134
1418
|
OrganizationResource,
|
|
3135
1419
|
SubscriptionsResource,
|
|
1420
|
+
SyncedEmailsResource,
|
|
3136
1421
|
TasksResource,
|
|
3137
1422
|
TicketsResource,
|
|
1423
|
+
TimelineCommentsResource,
|
|
3138
1424
|
TransactionsResource,
|
|
3139
1425
|
UsageEventsResource,
|
|
3140
1426
|
UsersResource,
|