mem0ai 1.0.17 → 1.0.19
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/package.json +16 -5
- package/src/index.cjs +20 -1
- package/src/index.d.ts +2 -0
- package/src/index.js +22 -2
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mem0ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "The Memory Layer For Your AI Apps",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
7
|
+
"test": "jest"
|
|
8
8
|
},
|
|
9
9
|
"types": "src/index.d.ts",
|
|
10
10
|
"keywords": [
|
|
@@ -26,7 +26,18 @@
|
|
|
26
26
|
"type": "module",
|
|
27
27
|
"exports": {
|
|
28
28
|
"require": "./src/index.cjs",
|
|
29
|
-
"import": "./
|
|
29
|
+
"import": "./src/index.js"
|
|
30
30
|
},
|
|
31
|
-
"module": "dist/index.mjs"
|
|
32
|
-
|
|
31
|
+
"module": "dist/index.mjs",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^22.7.6",
|
|
34
|
+
"dotenv": "^16.4.5",
|
|
35
|
+
"jest": "^29.7.0",
|
|
36
|
+
"rollup": "^4.24.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"axios": "^1.7.7",
|
|
40
|
+
"crypto": "^1.0.1",
|
|
41
|
+
"posthog-node": "^4.2.1"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var axios = require('axios');
|
|
4
|
+
|
|
3
5
|
class APIError extends Error {
|
|
4
6
|
constructor(message) {
|
|
5
7
|
super(message);
|
|
@@ -28,7 +30,17 @@ class MemoryClient {
|
|
|
28
30
|
'Content-Type': 'application/json'
|
|
29
31
|
};
|
|
30
32
|
|
|
33
|
+
|
|
34
|
+
this.client = axios.create({
|
|
35
|
+
baseURL: this.host,
|
|
36
|
+
headers: { Authorization: `Token ${this.apiKey}` },
|
|
37
|
+
timeout: 60000,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// captureClientEvent('init', this);
|
|
41
|
+
|
|
31
42
|
this._validateApiKey();
|
|
43
|
+
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
_validateApiKey() {
|
|
@@ -141,6 +153,14 @@ class MemoryClient {
|
|
|
141
153
|
return response;
|
|
142
154
|
}
|
|
143
155
|
|
|
156
|
+
async deleteUser(entityId, entity = { type: 'user' }) {
|
|
157
|
+
const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/${entity.type}/${entityId}/`, {
|
|
158
|
+
method: 'DELETE',
|
|
159
|
+
headers: this.headers
|
|
160
|
+
});
|
|
161
|
+
return response;
|
|
162
|
+
}
|
|
163
|
+
|
|
144
164
|
async deleteUsers() {
|
|
145
165
|
const entities = await this.users();
|
|
146
166
|
for (const entity of entities.results) {
|
|
@@ -175,7 +195,6 @@ class MemoryClient {
|
|
|
175
195
|
_prepareParams(options) {
|
|
176
196
|
return Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null));
|
|
177
197
|
}
|
|
178
|
-
|
|
179
198
|
}
|
|
180
199
|
|
|
181
200
|
module.exports = MemoryClient;
|
package/src/index.d.ts
CHANGED
|
@@ -108,6 +108,8 @@ declare module 'mem0ai' {
|
|
|
108
108
|
|
|
109
109
|
deleteUsers(): Promise<{ message: string }>;
|
|
110
110
|
|
|
111
|
+
deleteUser(entityId: string, entity?: { type: string }): Promise<{ message: string }>;
|
|
112
|
+
|
|
111
113
|
private _validateApiKey(): Promise<void>;
|
|
112
114
|
|
|
113
115
|
private _preparePayload(
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
|
|
1
4
|
class APIError extends Error {
|
|
2
5
|
constructor(message) {
|
|
3
6
|
super(message);
|
|
@@ -26,7 +29,17 @@ class MemoryClient {
|
|
|
26
29
|
'Content-Type': 'application/json'
|
|
27
30
|
};
|
|
28
31
|
|
|
32
|
+
|
|
33
|
+
this.client = axios.create({
|
|
34
|
+
baseURL: this.host,
|
|
35
|
+
headers: { Authorization: `Token ${this.apiKey}` },
|
|
36
|
+
timeout: 60000,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// captureClientEvent('init', this);
|
|
40
|
+
|
|
29
41
|
this._validateApiKey();
|
|
42
|
+
|
|
30
43
|
}
|
|
31
44
|
|
|
32
45
|
_validateApiKey() {
|
|
@@ -139,6 +152,14 @@ class MemoryClient {
|
|
|
139
152
|
return response;
|
|
140
153
|
}
|
|
141
154
|
|
|
155
|
+
async deleteUser(entityId, entity = { type: 'user' }) {
|
|
156
|
+
const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/${entity.type}/${entityId}/`, {
|
|
157
|
+
method: 'DELETE',
|
|
158
|
+
headers: this.headers
|
|
159
|
+
});
|
|
160
|
+
return response;
|
|
161
|
+
}
|
|
162
|
+
|
|
142
163
|
async deleteUsers() {
|
|
143
164
|
const entities = await this.users();
|
|
144
165
|
for (const entity of entities.results) {
|
|
@@ -173,7 +194,6 @@ class MemoryClient {
|
|
|
173
194
|
_prepareParams(options) {
|
|
174
195
|
return Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null));
|
|
175
196
|
}
|
|
176
|
-
|
|
177
197
|
}
|
|
178
198
|
|
|
179
|
-
export default MemoryClient;
|
|
199
|
+
export default MemoryClient;
|