@ztorchan/mem0ai 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,687 @@
1
+ // src/client/mem0.ts
2
+ import axios from "axios";
3
+
4
+ // src/client/telemetry.ts
5
+ var version = "2.1.36";
6
+ var MEM0_TELEMETRY = true;
7
+ var _a;
8
+ try {
9
+ MEM0_TELEMETRY = ((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.MEM0_TELEMETRY) === "false" ? false : true;
10
+ } catch (error) {
11
+ }
12
+ var POSTHOG_API_KEY = "phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX";
13
+ var POSTHOG_HOST = "https://us.i.posthog.com/i/v0/e/";
14
+ function generateHash(input) {
15
+ const randomStr = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
16
+ return randomStr;
17
+ }
18
+ var UnifiedTelemetry = class {
19
+ constructor(projectApiKey, host) {
20
+ this.apiKey = projectApiKey;
21
+ this.host = host;
22
+ }
23
+ async captureEvent(distinctId, eventName, properties = {}) {
24
+ if (!MEM0_TELEMETRY) return;
25
+ const eventProperties = {
26
+ client_version: version,
27
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
28
+ ...properties,
29
+ $process_person_profile: false,
30
+ $lib: "posthog-node"
31
+ };
32
+ const payload = {
33
+ api_key: this.apiKey,
34
+ distinct_id: distinctId,
35
+ event: eventName,
36
+ properties: eventProperties
37
+ };
38
+ try {
39
+ const response = await fetch(this.host, {
40
+ method: "POST",
41
+ headers: {
42
+ "Content-Type": "application/json"
43
+ },
44
+ body: JSON.stringify(payload)
45
+ });
46
+ if (!response.ok) {
47
+ console.error("Telemetry event capture failed:", await response.text());
48
+ }
49
+ } catch (error) {
50
+ console.error("Telemetry event capture failed:", error);
51
+ }
52
+ }
53
+ async shutdown() {
54
+ }
55
+ };
56
+ var telemetry = new UnifiedTelemetry(POSTHOG_API_KEY, POSTHOG_HOST);
57
+ async function captureClientEvent(eventName, instance, additionalData = {}) {
58
+ if (!instance.telemetryId) {
59
+ console.warn("No telemetry ID found for instance");
60
+ return;
61
+ }
62
+ const eventData = {
63
+ function: `${instance.constructor.name}`,
64
+ method: eventName,
65
+ api_host: instance.host,
66
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
67
+ client_version: version,
68
+ keys: (additionalData == null ? void 0 : additionalData.keys) || [],
69
+ ...additionalData
70
+ };
71
+ await telemetry.captureEvent(
72
+ instance.telemetryId,
73
+ `client.${eventName}`,
74
+ eventData
75
+ );
76
+ }
77
+
78
+ // src/client/mem0.ts
79
+ var APIError = class extends Error {
80
+ constructor(message) {
81
+ super(message);
82
+ this.name = "APIError";
83
+ }
84
+ };
85
+ var MemoryClient = class {
86
+ _validateApiKey() {
87
+ if (!this.apiKey) {
88
+ throw new Error("Mem0 API key is required");
89
+ }
90
+ if (typeof this.apiKey !== "string") {
91
+ throw new Error("Mem0 API key must be a string");
92
+ }
93
+ if (this.apiKey.trim() === "") {
94
+ throw new Error("Mem0 API key cannot be empty");
95
+ }
96
+ }
97
+ _validateOrgProject() {
98
+ if (this.organizationName === null && this.projectName !== null || this.organizationName !== null && this.projectName === null) {
99
+ console.warn(
100
+ "Warning: Both organizationName and projectName must be provided together when using either. This will be removed from version 1.0.40. Note that organizationName/projectName are being deprecated in favor of organizationId/projectId."
101
+ );
102
+ }
103
+ if (this.organizationId === null && this.projectId !== null || this.organizationId !== null && this.projectId === null) {
104
+ console.warn(
105
+ "Warning: Both organizationId and projectId must be provided together when using either. This will be removed from version 1.0.40."
106
+ );
107
+ }
108
+ }
109
+ constructor(options) {
110
+ this.apiKey = options.apiKey;
111
+ this.host = options.host || "https://api.mem0.ai";
112
+ this.organizationName = options.organizationName || null;
113
+ this.projectName = options.projectName || null;
114
+ this.organizationId = options.organizationId || null;
115
+ this.projectId = options.projectId || null;
116
+ this.headers = {
117
+ Authorization: `Token ${this.apiKey}`,
118
+ "Content-Type": "application/json"
119
+ };
120
+ this.client = axios.create({
121
+ baseURL: this.host,
122
+ headers: { Authorization: `Token ${this.apiKey}` },
123
+ timeout: 6e4
124
+ });
125
+ this._validateApiKey();
126
+ this.telemetryId = "";
127
+ this._initializeClient();
128
+ }
129
+ async _initializeClient() {
130
+ try {
131
+ await this.ping();
132
+ if (!this.telemetryId) {
133
+ this.telemetryId = generateHash(this.apiKey);
134
+ }
135
+ this._validateOrgProject();
136
+ captureClientEvent("init", this, {
137
+ api_version: "v1",
138
+ client_type: "MemoryClient"
139
+ }).catch((error) => {
140
+ console.error("Failed to capture event:", error);
141
+ });
142
+ } catch (error) {
143
+ console.error("Failed to initialize client:", error);
144
+ await captureClientEvent("init_error", this, {
145
+ error: (error == null ? void 0 : error.message) || "Unknown error",
146
+ stack: (error == null ? void 0 : error.stack) || "No stack trace"
147
+ });
148
+ }
149
+ }
150
+ _captureEvent(methodName, args) {
151
+ captureClientEvent(methodName, this, {
152
+ success: true,
153
+ args_count: args.length,
154
+ keys: args.length > 0 ? args[0] : []
155
+ }).catch((error) => {
156
+ console.error("Failed to capture event:", error);
157
+ });
158
+ }
159
+ async _fetchWithErrorHandling(url, options) {
160
+ const response = await fetch(url, {
161
+ ...options,
162
+ headers: {
163
+ ...options.headers,
164
+ Authorization: `Token ${this.apiKey}`,
165
+ "Mem0-User-ID": this.telemetryId
166
+ }
167
+ });
168
+ if (!response.ok) {
169
+ const errorData = await response.text();
170
+ throw new APIError(`API request failed: ${errorData}`);
171
+ }
172
+ const jsonResponse = await response.json();
173
+ return jsonResponse;
174
+ }
175
+ _preparePayload(messages, options) {
176
+ const payload = {};
177
+ payload.messages = messages;
178
+ return { ...payload, ...options };
179
+ }
180
+ _prepareParams(options) {
181
+ return Object.fromEntries(
182
+ Object.entries(options).filter(([_, v]) => v != null)
183
+ );
184
+ }
185
+ async ping() {
186
+ try {
187
+ const response = await this._fetchWithErrorHandling(
188
+ `${this.host}/v1/ping/`,
189
+ {
190
+ method: "GET",
191
+ headers: {
192
+ Authorization: `Token ${this.apiKey}`
193
+ }
194
+ }
195
+ );
196
+ if (!response || typeof response !== "object") {
197
+ throw new APIError("Invalid response format from ping endpoint");
198
+ }
199
+ if (response.status !== "ok") {
200
+ throw new APIError(response.message || "API Key is invalid");
201
+ }
202
+ const { org_id, project_id, user_email } = response;
203
+ if (org_id && !this.organizationId) this.organizationId = org_id;
204
+ if (project_id && !this.projectId) this.projectId = project_id;
205
+ if (user_email) this.telemetryId = user_email;
206
+ } catch (error) {
207
+ if (error instanceof APIError) {
208
+ throw error;
209
+ } else {
210
+ throw new APIError(
211
+ `Failed to ping server: ${error.message || "Unknown error"}`
212
+ );
213
+ }
214
+ }
215
+ }
216
+ async add(messages, options = {}) {
217
+ if (this.telemetryId === "") await this.ping();
218
+ this._validateOrgProject();
219
+ if (this.organizationName != null && this.projectName != null) {
220
+ options.org_name = this.organizationName;
221
+ options.project_name = this.projectName;
222
+ }
223
+ if (this.organizationId != null && this.projectId != null) {
224
+ options.org_id = this.organizationId;
225
+ options.project_id = this.projectId;
226
+ if (options.org_name) delete options.org_name;
227
+ if (options.project_name) delete options.project_name;
228
+ }
229
+ if (options.api_version) {
230
+ options.version = options.api_version.toString() || "v2";
231
+ }
232
+ const payload = this._preparePayload(messages, options);
233
+ const payloadKeys = Object.keys(payload);
234
+ this._captureEvent("add", [payloadKeys]);
235
+ const response = await this._fetchWithErrorHandling(
236
+ `${this.host}/v1/memories/`,
237
+ {
238
+ method: "POST",
239
+ headers: this.headers,
240
+ body: JSON.stringify(payload)
241
+ }
242
+ );
243
+ return response;
244
+ }
245
+ async update(memoryId, {
246
+ text,
247
+ metadata,
248
+ timestamp
249
+ }) {
250
+ if (text === void 0 && metadata === void 0 && timestamp === void 0) {
251
+ throw new Error(
252
+ "At least one of text, metadata, or timestamp must be provided for update."
253
+ );
254
+ }
255
+ if (this.telemetryId === "") await this.ping();
256
+ this._validateOrgProject();
257
+ const payload = {};
258
+ if (text !== void 0) payload.text = text;
259
+ if (metadata !== void 0) payload.metadata = metadata;
260
+ if (timestamp !== void 0) payload.timestamp = timestamp;
261
+ const payloadKeys = Object.keys(payload);
262
+ this._captureEvent("update", [payloadKeys]);
263
+ const response = await this._fetchWithErrorHandling(
264
+ `${this.host}/v1/memories/${memoryId}/`,
265
+ {
266
+ method: "PUT",
267
+ headers: this.headers,
268
+ body: JSON.stringify(payload)
269
+ }
270
+ );
271
+ return response;
272
+ }
273
+ async get(memoryId) {
274
+ if (this.telemetryId === "") await this.ping();
275
+ this._captureEvent("get", []);
276
+ return this._fetchWithErrorHandling(
277
+ `${this.host}/v1/memories/${memoryId}/`,
278
+ {
279
+ headers: this.headers
280
+ }
281
+ );
282
+ }
283
+ async getAll(options) {
284
+ if (this.telemetryId === "") await this.ping();
285
+ this._validateOrgProject();
286
+ const payloadKeys = Object.keys(options || {});
287
+ this._captureEvent("get_all", [payloadKeys]);
288
+ const { api_version, page, page_size, ...otherOptions } = options;
289
+ if (this.organizationName != null && this.projectName != null) {
290
+ otherOptions.org_name = this.organizationName;
291
+ otherOptions.project_name = this.projectName;
292
+ }
293
+ let appendedParams = "";
294
+ let paginated_response = false;
295
+ if (page && page_size) {
296
+ appendedParams += `page=${page}&page_size=${page_size}`;
297
+ paginated_response = true;
298
+ }
299
+ if (this.organizationId != null && this.projectId != null) {
300
+ otherOptions.org_id = this.organizationId;
301
+ otherOptions.project_id = this.projectId;
302
+ if (otherOptions.org_name) delete otherOptions.org_name;
303
+ if (otherOptions.project_name) delete otherOptions.project_name;
304
+ }
305
+ if (api_version === "v2") {
306
+ let url = paginated_response ? `${this.host}/v2/memories/?${appendedParams}` : `${this.host}/v2/memories/`;
307
+ return this._fetchWithErrorHandling(url, {
308
+ method: "POST",
309
+ headers: this.headers,
310
+ body: JSON.stringify(otherOptions)
311
+ });
312
+ } else {
313
+ const params = new URLSearchParams(this._prepareParams(otherOptions));
314
+ const url = paginated_response ? `${this.host}/v1/memories/?${params}&${appendedParams}` : `${this.host}/v1/memories/?${params}`;
315
+ return this._fetchWithErrorHandling(url, {
316
+ headers: this.headers
317
+ });
318
+ }
319
+ }
320
+ async search(query, options) {
321
+ if (this.telemetryId === "") await this.ping();
322
+ this._validateOrgProject();
323
+ const payloadKeys = Object.keys(options || {});
324
+ this._captureEvent("search", [payloadKeys]);
325
+ const { api_version, ...otherOptions } = options;
326
+ const payload = { query, ...otherOptions };
327
+ if (this.organizationName != null && this.projectName != null) {
328
+ payload.org_name = this.organizationName;
329
+ payload.project_name = this.projectName;
330
+ }
331
+ if (this.organizationId != null && this.projectId != null) {
332
+ payload.org_id = this.organizationId;
333
+ payload.project_id = this.projectId;
334
+ if (payload.org_name) delete payload.org_name;
335
+ if (payload.project_name) delete payload.project_name;
336
+ }
337
+ const endpoint = api_version === "v2" ? "/v2/memories/search/" : "/v1/memories/search/";
338
+ const response = await this._fetchWithErrorHandling(
339
+ `${this.host}${endpoint}`,
340
+ {
341
+ method: "POST",
342
+ headers: this.headers,
343
+ body: JSON.stringify(payload)
344
+ }
345
+ );
346
+ return response;
347
+ }
348
+ async delete(memoryId) {
349
+ if (this.telemetryId === "") await this.ping();
350
+ this._captureEvent("delete", []);
351
+ return this._fetchWithErrorHandling(
352
+ `${this.host}/v1/memories/${memoryId}/`,
353
+ {
354
+ method: "DELETE",
355
+ headers: this.headers
356
+ }
357
+ );
358
+ }
359
+ async deleteAll(options = {}) {
360
+ if (this.telemetryId === "") await this.ping();
361
+ this._validateOrgProject();
362
+ const payloadKeys = Object.keys(options || {});
363
+ this._captureEvent("delete_all", [payloadKeys]);
364
+ if (this.organizationName != null && this.projectName != null) {
365
+ options.org_name = this.organizationName;
366
+ options.project_name = this.projectName;
367
+ }
368
+ if (this.organizationId != null && this.projectId != null) {
369
+ options.org_id = this.organizationId;
370
+ options.project_id = this.projectId;
371
+ if (options.org_name) delete options.org_name;
372
+ if (options.project_name) delete options.project_name;
373
+ }
374
+ const params = new URLSearchParams(this._prepareParams(options));
375
+ const response = await this._fetchWithErrorHandling(
376
+ `${this.host}/v1/memories/?${params}`,
377
+ {
378
+ method: "DELETE",
379
+ headers: this.headers
380
+ }
381
+ );
382
+ return response;
383
+ }
384
+ async history(memoryId) {
385
+ if (this.telemetryId === "") await this.ping();
386
+ this._captureEvent("history", []);
387
+ const response = await this._fetchWithErrorHandling(
388
+ `${this.host}/v1/memories/${memoryId}/history/`,
389
+ {
390
+ headers: this.headers
391
+ }
392
+ );
393
+ return response;
394
+ }
395
+ async users() {
396
+ if (this.telemetryId === "") await this.ping();
397
+ this._validateOrgProject();
398
+ this._captureEvent("users", []);
399
+ const options = {};
400
+ if (this.organizationName != null && this.projectName != null) {
401
+ options.org_name = this.organizationName;
402
+ options.project_name = this.projectName;
403
+ }
404
+ if (this.organizationId != null && this.projectId != null) {
405
+ options.org_id = this.organizationId;
406
+ options.project_id = this.projectId;
407
+ if (options.org_name) delete options.org_name;
408
+ if (options.project_name) delete options.project_name;
409
+ }
410
+ const params = new URLSearchParams(options);
411
+ const response = await this._fetchWithErrorHandling(
412
+ `${this.host}/v1/entities/?${params}`,
413
+ {
414
+ headers: this.headers
415
+ }
416
+ );
417
+ return response;
418
+ }
419
+ /**
420
+ * @deprecated The method should not be used, use `deleteUsers` instead. This will be removed in version 2.2.0.
421
+ */
422
+ async deleteUser(data) {
423
+ if (this.telemetryId === "") await this.ping();
424
+ this._captureEvent("delete_user", []);
425
+ if (!data.entity_type) {
426
+ data.entity_type = "user";
427
+ }
428
+ const response = await this._fetchWithErrorHandling(
429
+ `${this.host}/v1/entities/${data.entity_type}/${data.entity_id}/`,
430
+ {
431
+ method: "DELETE",
432
+ headers: this.headers
433
+ }
434
+ );
435
+ return response;
436
+ }
437
+ async deleteUsers(params = {}) {
438
+ if (this.telemetryId === "") await this.ping();
439
+ this._validateOrgProject();
440
+ let to_delete = [];
441
+ const { user_id, agent_id, app_id, run_id } = params;
442
+ if (user_id) {
443
+ to_delete = [{ type: "user", name: user_id }];
444
+ } else if (agent_id) {
445
+ to_delete = [{ type: "agent", name: agent_id }];
446
+ } else if (app_id) {
447
+ to_delete = [{ type: "app", name: app_id }];
448
+ } else if (run_id) {
449
+ to_delete = [{ type: "run", name: run_id }];
450
+ } else {
451
+ const entities = await this.users();
452
+ to_delete = entities.results.map((entity) => ({
453
+ type: entity.type,
454
+ name: entity.name
455
+ }));
456
+ }
457
+ if (to_delete.length === 0) {
458
+ throw new Error("No entities to delete");
459
+ }
460
+ const requestOptions = {};
461
+ if (this.organizationName != null && this.projectName != null) {
462
+ requestOptions.org_name = this.organizationName;
463
+ requestOptions.project_name = this.projectName;
464
+ }
465
+ if (this.organizationId != null && this.projectId != null) {
466
+ requestOptions.org_id = this.organizationId;
467
+ requestOptions.project_id = this.projectId;
468
+ if (requestOptions.org_name) delete requestOptions.org_name;
469
+ if (requestOptions.project_name) delete requestOptions.project_name;
470
+ }
471
+ for (const entity of to_delete) {
472
+ try {
473
+ await this.client.delete(
474
+ `/v2/entities/${entity.type}/${entity.name}/`,
475
+ {
476
+ params: requestOptions
477
+ }
478
+ );
479
+ } catch (error) {
480
+ throw new APIError(
481
+ `Failed to delete ${entity.type} ${entity.name}: ${error.message}`
482
+ );
483
+ }
484
+ }
485
+ this._captureEvent("delete_users", [
486
+ {
487
+ user_id,
488
+ agent_id,
489
+ app_id,
490
+ run_id,
491
+ sync_type: "sync"
492
+ }
493
+ ]);
494
+ return {
495
+ message: user_id || agent_id || app_id || run_id ? "Entity deleted successfully." : "All users, agents, apps and runs deleted."
496
+ };
497
+ }
498
+ async batchUpdate(memories) {
499
+ if (this.telemetryId === "") await this.ping();
500
+ this._captureEvent("batch_update", []);
501
+ const memoriesBody = memories.map((memory) => ({
502
+ memory_id: memory.memoryId,
503
+ text: memory.text
504
+ }));
505
+ const response = await this._fetchWithErrorHandling(
506
+ `${this.host}/v1/batch/`,
507
+ {
508
+ method: "PUT",
509
+ headers: this.headers,
510
+ body: JSON.stringify({ memories: memoriesBody })
511
+ }
512
+ );
513
+ return response;
514
+ }
515
+ async batchDelete(memories) {
516
+ if (this.telemetryId === "") await this.ping();
517
+ this._captureEvent("batch_delete", []);
518
+ const memoriesBody = memories.map((memory) => ({
519
+ memory_id: memory
520
+ }));
521
+ const response = await this._fetchWithErrorHandling(
522
+ `${this.host}/v1/batch/`,
523
+ {
524
+ method: "DELETE",
525
+ headers: this.headers,
526
+ body: JSON.stringify({ memories: memoriesBody })
527
+ }
528
+ );
529
+ return response;
530
+ }
531
+ async getProject(options) {
532
+ if (this.telemetryId === "") await this.ping();
533
+ this._validateOrgProject();
534
+ const payloadKeys = Object.keys(options || {});
535
+ this._captureEvent("get_project", [payloadKeys]);
536
+ const { fields } = options;
537
+ if (!(this.organizationId && this.projectId)) {
538
+ throw new Error(
539
+ "organizationId and projectId must be set to access instructions or categories"
540
+ );
541
+ }
542
+ const params = new URLSearchParams();
543
+ fields == null ? void 0 : fields.forEach((field) => params.append("fields", field));
544
+ const response = await this._fetchWithErrorHandling(
545
+ `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/?${params.toString()}`,
546
+ {
547
+ headers: this.headers
548
+ }
549
+ );
550
+ return response;
551
+ }
552
+ async updateProject(prompts) {
553
+ if (this.telemetryId === "") await this.ping();
554
+ this._validateOrgProject();
555
+ this._captureEvent("update_project", []);
556
+ if (!(this.organizationId && this.projectId)) {
557
+ throw new Error(
558
+ "organizationId and projectId must be set to update instructions or categories"
559
+ );
560
+ }
561
+ const response = await this._fetchWithErrorHandling(
562
+ `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/`,
563
+ {
564
+ method: "PATCH",
565
+ headers: this.headers,
566
+ body: JSON.stringify(prompts)
567
+ }
568
+ );
569
+ return response;
570
+ }
571
+ // WebHooks
572
+ async getWebhooks(data) {
573
+ if (this.telemetryId === "") await this.ping();
574
+ this._captureEvent("get_webhooks", []);
575
+ const project_id = (data == null ? void 0 : data.projectId) || this.projectId;
576
+ const response = await this._fetchWithErrorHandling(
577
+ `${this.host}/api/v1/webhooks/projects/${project_id}/`,
578
+ {
579
+ headers: this.headers
580
+ }
581
+ );
582
+ return response;
583
+ }
584
+ async createWebhook(webhook) {
585
+ if (this.telemetryId === "") await this.ping();
586
+ this._captureEvent("create_webhook", []);
587
+ const response = await this._fetchWithErrorHandling(
588
+ `${this.host}/api/v1/webhooks/projects/${this.projectId}/`,
589
+ {
590
+ method: "POST",
591
+ headers: this.headers,
592
+ body: JSON.stringify(webhook)
593
+ }
594
+ );
595
+ return response;
596
+ }
597
+ async updateWebhook(webhook) {
598
+ if (this.telemetryId === "") await this.ping();
599
+ this._captureEvent("update_webhook", []);
600
+ const project_id = webhook.projectId || this.projectId;
601
+ const response = await this._fetchWithErrorHandling(
602
+ `${this.host}/api/v1/webhooks/${webhook.webhookId}/`,
603
+ {
604
+ method: "PUT",
605
+ headers: this.headers,
606
+ body: JSON.stringify({
607
+ ...webhook,
608
+ projectId: project_id
609
+ })
610
+ }
611
+ );
612
+ return response;
613
+ }
614
+ async deleteWebhook(data) {
615
+ if (this.telemetryId === "") await this.ping();
616
+ this._captureEvent("delete_webhook", []);
617
+ const webhook_id = data.webhookId || data;
618
+ const response = await this._fetchWithErrorHandling(
619
+ `${this.host}/api/v1/webhooks/${webhook_id}/`,
620
+ {
621
+ method: "DELETE",
622
+ headers: this.headers
623
+ }
624
+ );
625
+ return response;
626
+ }
627
+ async feedback(data) {
628
+ if (this.telemetryId === "") await this.ping();
629
+ const payloadKeys = Object.keys(data || {});
630
+ this._captureEvent("feedback", [payloadKeys]);
631
+ const response = await this._fetchWithErrorHandling(
632
+ `${this.host}/v1/feedback/`,
633
+ {
634
+ method: "POST",
635
+ headers: this.headers,
636
+ body: JSON.stringify(data)
637
+ }
638
+ );
639
+ return response;
640
+ }
641
+ async createMemoryExport(data) {
642
+ var _a2, _b;
643
+ if (this.telemetryId === "") await this.ping();
644
+ this._captureEvent("create_memory_export", []);
645
+ if (!data.filters || !data.schema) {
646
+ throw new Error("Missing filters or schema");
647
+ }
648
+ data.org_id = ((_a2 = this.organizationId) == null ? void 0 : _a2.toString()) || null;
649
+ data.project_id = ((_b = this.projectId) == null ? void 0 : _b.toString()) || null;
650
+ const response = await this._fetchWithErrorHandling(
651
+ `${this.host}/v1/exports/`,
652
+ {
653
+ method: "POST",
654
+ headers: this.headers,
655
+ body: JSON.stringify(data)
656
+ }
657
+ );
658
+ return response;
659
+ }
660
+ async getMemoryExport(data) {
661
+ var _a2, _b;
662
+ if (this.telemetryId === "") await this.ping();
663
+ this._captureEvent("get_memory_export", []);
664
+ if (!data.memory_export_id && !data.filters) {
665
+ throw new Error("Missing memory_export_id or filters");
666
+ }
667
+ data.org_id = ((_a2 = this.organizationId) == null ? void 0 : _a2.toString()) || "";
668
+ data.project_id = ((_b = this.projectId) == null ? void 0 : _b.toString()) || "";
669
+ const response = await this._fetchWithErrorHandling(
670
+ `${this.host}/v1/exports/get/`,
671
+ {
672
+ method: "POST",
673
+ headers: this.headers,
674
+ body: JSON.stringify(data)
675
+ }
676
+ );
677
+ return response;
678
+ }
679
+ };
680
+
681
+ // src/client/index.ts
682
+ var index_default = MemoryClient;
683
+ export {
684
+ MemoryClient,
685
+ index_default as default
686
+ };
687
+ //# sourceMappingURL=index.mjs.map