mem0ai 2.4.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +90 -8
- package/dist/index.d.ts +90 -8
- package/dist/index.js +150 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +138 -10
- package/dist/index.mjs.map +1 -1
- package/dist/oss/index.d.mts +61 -1
- package/dist/oss/index.d.ts +61 -1
- package/dist/oss/index.js +402 -38
- package/dist/oss/index.js.map +1 -1
- package/dist/oss/index.mjs +395 -34
- package/dist/oss/index.mjs.map +1 -1
- package/package.json +5 -2
package/dist/index.d.mts
CHANGED
|
@@ -154,7 +154,8 @@ interface PromptUpdatePayload {
|
|
|
154
154
|
declare enum WebhookEvent {
|
|
155
155
|
MEMORY_ADDED = "memory_add",
|
|
156
156
|
MEMORY_UPDATED = "memory_update",
|
|
157
|
-
MEMORY_DELETED = "memory_delete"
|
|
157
|
+
MEMORY_DELETED = "memory_delete",
|
|
158
|
+
MEMORY_CATEGORIZED = "memory_categorize"
|
|
158
159
|
}
|
|
159
160
|
interface Webhook {
|
|
160
161
|
webhook_id?: string;
|
|
@@ -166,12 +167,16 @@ interface Webhook {
|
|
|
166
167
|
is_active?: boolean;
|
|
167
168
|
event_types?: WebhookEvent[];
|
|
168
169
|
}
|
|
169
|
-
interface
|
|
170
|
-
eventTypes: WebhookEvent[];
|
|
171
|
-
projectId: string;
|
|
172
|
-
webhookId: string;
|
|
170
|
+
interface WebhookCreatePayload {
|
|
173
171
|
name: string;
|
|
174
172
|
url: string;
|
|
173
|
+
eventTypes: WebhookEvent[];
|
|
174
|
+
}
|
|
175
|
+
interface WebhookUpdatePayload {
|
|
176
|
+
webhookId: string;
|
|
177
|
+
name?: string;
|
|
178
|
+
url?: string;
|
|
179
|
+
eventTypes?: WebhookEvent[];
|
|
175
180
|
}
|
|
176
181
|
interface FeedbackPayload {
|
|
177
182
|
memory_id: string;
|
|
@@ -256,8 +261,8 @@ declare class MemoryClient {
|
|
|
256
261
|
getWebhooks(data?: {
|
|
257
262
|
projectId?: string;
|
|
258
263
|
}): Promise<Array<Webhook>>;
|
|
259
|
-
createWebhook(webhook:
|
|
260
|
-
updateWebhook(webhook:
|
|
264
|
+
createWebhook(webhook: WebhookCreatePayload): Promise<Webhook>;
|
|
265
|
+
updateWebhook(webhook: WebhookUpdatePayload): Promise<{
|
|
261
266
|
message: string;
|
|
262
267
|
}>;
|
|
263
268
|
deleteWebhook(data: {
|
|
@@ -278,4 +283,81 @@ declare class MemoryClient {
|
|
|
278
283
|
}>;
|
|
279
284
|
}
|
|
280
285
|
|
|
281
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Structured exception classes for mem0 TypeScript SDK.
|
|
288
|
+
*
|
|
289
|
+
* Provides specific, actionable exceptions with error codes, suggestions,
|
|
290
|
+
* and debug information. Maps HTTP status codes to appropriate exception types.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* import { RateLimitError, MemoryNotFoundError } from 'mem0ai'
|
|
295
|
+
*
|
|
296
|
+
* try {
|
|
297
|
+
* await client.get(memoryId)
|
|
298
|
+
* } catch (e) {
|
|
299
|
+
* if (e instanceof MemoryNotFoundError) {
|
|
300
|
+
* console.log(e.suggestion) // "The requested resource was not found"
|
|
301
|
+
* } else if (e instanceof RateLimitError) {
|
|
302
|
+
* await sleep(e.debugInfo.retryAfter ?? 60)
|
|
303
|
+
* }
|
|
304
|
+
* }
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
interface MemoryErrorOptions {
|
|
308
|
+
details?: Record<string, unknown>;
|
|
309
|
+
suggestion?: string;
|
|
310
|
+
debugInfo?: Record<string, unknown>;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Base exception for all memory-related errors.
|
|
314
|
+
*
|
|
315
|
+
* Every mem0 exception includes an error code for programmatic handling,
|
|
316
|
+
* optional details, a user-friendly suggestion, and debug information.
|
|
317
|
+
*/
|
|
318
|
+
declare class MemoryError extends Error {
|
|
319
|
+
readonly errorCode: string;
|
|
320
|
+
readonly details: Record<string, unknown>;
|
|
321
|
+
readonly suggestion?: string;
|
|
322
|
+
readonly debugInfo: Record<string, unknown>;
|
|
323
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
324
|
+
}
|
|
325
|
+
/** Raised when authentication fails (401, 403). */
|
|
326
|
+
declare class AuthenticationError extends MemoryError {
|
|
327
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
328
|
+
}
|
|
329
|
+
/** Raised when rate limits are exceeded (429). */
|
|
330
|
+
declare class RateLimitError extends MemoryError {
|
|
331
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
332
|
+
}
|
|
333
|
+
/** Raised when input validation fails (400, 409, 422). */
|
|
334
|
+
declare class ValidationError extends MemoryError {
|
|
335
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
336
|
+
}
|
|
337
|
+
/** Raised when a memory is not found (404). */
|
|
338
|
+
declare class MemoryNotFoundError extends MemoryError {
|
|
339
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
340
|
+
}
|
|
341
|
+
/** Raised when network connectivity issues occur (408, 502, 503, 504). */
|
|
342
|
+
declare class NetworkError extends MemoryError {
|
|
343
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
344
|
+
}
|
|
345
|
+
/** Raised when client configuration is invalid. */
|
|
346
|
+
declare class ConfigurationError extends MemoryError {
|
|
347
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
348
|
+
}
|
|
349
|
+
/** Raised when memory quota is exceeded (413). */
|
|
350
|
+
declare class MemoryQuotaExceededError extends MemoryError {
|
|
351
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Create an appropriate exception based on HTTP response status code.
|
|
355
|
+
*
|
|
356
|
+
* @param statusCode - HTTP status code from the response
|
|
357
|
+
* @param responseText - Response body text
|
|
358
|
+
* @param options - Additional error context (details, debugInfo)
|
|
359
|
+
* @returns An instance of the appropriate MemoryError subclass
|
|
360
|
+
*/
|
|
361
|
+
declare function createExceptionFromResponse(statusCode: number, responseText: string, options?: Omit<MemoryErrorOptions, "suggestion">): MemoryError;
|
|
362
|
+
|
|
363
|
+
export { type AllUsers, AuthenticationError, ConfigurationError, Feedback, type FeedbackPayload, type Memory, MemoryClient, MemoryError, type MemoryErrorOptions, type MemoryHistory, MemoryNotFoundError, type MemoryOptions, MemoryQuotaExceededError, type MemoryUpdateBody, type Message, type Messages, NetworkError, type ProjectOptions, type ProjectResponse, type PromptUpdatePayload, RateLimitError, type SearchOptions, type User, ValidationError, type Webhook, type WebhookCreatePayload, WebhookEvent, type WebhookUpdatePayload, createExceptionFromResponse, MemoryClient as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -154,7 +154,8 @@ interface PromptUpdatePayload {
|
|
|
154
154
|
declare enum WebhookEvent {
|
|
155
155
|
MEMORY_ADDED = "memory_add",
|
|
156
156
|
MEMORY_UPDATED = "memory_update",
|
|
157
|
-
MEMORY_DELETED = "memory_delete"
|
|
157
|
+
MEMORY_DELETED = "memory_delete",
|
|
158
|
+
MEMORY_CATEGORIZED = "memory_categorize"
|
|
158
159
|
}
|
|
159
160
|
interface Webhook {
|
|
160
161
|
webhook_id?: string;
|
|
@@ -166,12 +167,16 @@ interface Webhook {
|
|
|
166
167
|
is_active?: boolean;
|
|
167
168
|
event_types?: WebhookEvent[];
|
|
168
169
|
}
|
|
169
|
-
interface
|
|
170
|
-
eventTypes: WebhookEvent[];
|
|
171
|
-
projectId: string;
|
|
172
|
-
webhookId: string;
|
|
170
|
+
interface WebhookCreatePayload {
|
|
173
171
|
name: string;
|
|
174
172
|
url: string;
|
|
173
|
+
eventTypes: WebhookEvent[];
|
|
174
|
+
}
|
|
175
|
+
interface WebhookUpdatePayload {
|
|
176
|
+
webhookId: string;
|
|
177
|
+
name?: string;
|
|
178
|
+
url?: string;
|
|
179
|
+
eventTypes?: WebhookEvent[];
|
|
175
180
|
}
|
|
176
181
|
interface FeedbackPayload {
|
|
177
182
|
memory_id: string;
|
|
@@ -256,8 +261,8 @@ declare class MemoryClient {
|
|
|
256
261
|
getWebhooks(data?: {
|
|
257
262
|
projectId?: string;
|
|
258
263
|
}): Promise<Array<Webhook>>;
|
|
259
|
-
createWebhook(webhook:
|
|
260
|
-
updateWebhook(webhook:
|
|
264
|
+
createWebhook(webhook: WebhookCreatePayload): Promise<Webhook>;
|
|
265
|
+
updateWebhook(webhook: WebhookUpdatePayload): Promise<{
|
|
261
266
|
message: string;
|
|
262
267
|
}>;
|
|
263
268
|
deleteWebhook(data: {
|
|
@@ -278,4 +283,81 @@ declare class MemoryClient {
|
|
|
278
283
|
}>;
|
|
279
284
|
}
|
|
280
285
|
|
|
281
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Structured exception classes for mem0 TypeScript SDK.
|
|
288
|
+
*
|
|
289
|
+
* Provides specific, actionable exceptions with error codes, suggestions,
|
|
290
|
+
* and debug information. Maps HTTP status codes to appropriate exception types.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* import { RateLimitError, MemoryNotFoundError } from 'mem0ai'
|
|
295
|
+
*
|
|
296
|
+
* try {
|
|
297
|
+
* await client.get(memoryId)
|
|
298
|
+
* } catch (e) {
|
|
299
|
+
* if (e instanceof MemoryNotFoundError) {
|
|
300
|
+
* console.log(e.suggestion) // "The requested resource was not found"
|
|
301
|
+
* } else if (e instanceof RateLimitError) {
|
|
302
|
+
* await sleep(e.debugInfo.retryAfter ?? 60)
|
|
303
|
+
* }
|
|
304
|
+
* }
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
interface MemoryErrorOptions {
|
|
308
|
+
details?: Record<string, unknown>;
|
|
309
|
+
suggestion?: string;
|
|
310
|
+
debugInfo?: Record<string, unknown>;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Base exception for all memory-related errors.
|
|
314
|
+
*
|
|
315
|
+
* Every mem0 exception includes an error code for programmatic handling,
|
|
316
|
+
* optional details, a user-friendly suggestion, and debug information.
|
|
317
|
+
*/
|
|
318
|
+
declare class MemoryError extends Error {
|
|
319
|
+
readonly errorCode: string;
|
|
320
|
+
readonly details: Record<string, unknown>;
|
|
321
|
+
readonly suggestion?: string;
|
|
322
|
+
readonly debugInfo: Record<string, unknown>;
|
|
323
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
324
|
+
}
|
|
325
|
+
/** Raised when authentication fails (401, 403). */
|
|
326
|
+
declare class AuthenticationError extends MemoryError {
|
|
327
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
328
|
+
}
|
|
329
|
+
/** Raised when rate limits are exceeded (429). */
|
|
330
|
+
declare class RateLimitError extends MemoryError {
|
|
331
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
332
|
+
}
|
|
333
|
+
/** Raised when input validation fails (400, 409, 422). */
|
|
334
|
+
declare class ValidationError extends MemoryError {
|
|
335
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
336
|
+
}
|
|
337
|
+
/** Raised when a memory is not found (404). */
|
|
338
|
+
declare class MemoryNotFoundError extends MemoryError {
|
|
339
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
340
|
+
}
|
|
341
|
+
/** Raised when network connectivity issues occur (408, 502, 503, 504). */
|
|
342
|
+
declare class NetworkError extends MemoryError {
|
|
343
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
344
|
+
}
|
|
345
|
+
/** Raised when client configuration is invalid. */
|
|
346
|
+
declare class ConfigurationError extends MemoryError {
|
|
347
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
348
|
+
}
|
|
349
|
+
/** Raised when memory quota is exceeded (413). */
|
|
350
|
+
declare class MemoryQuotaExceededError extends MemoryError {
|
|
351
|
+
constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Create an appropriate exception based on HTTP response status code.
|
|
355
|
+
*
|
|
356
|
+
* @param statusCode - HTTP status code from the response
|
|
357
|
+
* @param responseText - Response body text
|
|
358
|
+
* @param options - Additional error context (details, debugInfo)
|
|
359
|
+
* @returns An instance of the appropriate MemoryError subclass
|
|
360
|
+
*/
|
|
361
|
+
declare function createExceptionFromResponse(statusCode: number, responseText: string, options?: Omit<MemoryErrorOptions, "suggestion">): MemoryError;
|
|
362
|
+
|
|
363
|
+
export { type AllUsers, AuthenticationError, ConfigurationError, Feedback, type FeedbackPayload, type Memory, MemoryClient, MemoryError, type MemoryErrorOptions, type MemoryHistory, MemoryNotFoundError, type MemoryOptions, MemoryQuotaExceededError, type MemoryUpdateBody, type Message, type Messages, NetworkError, type ProjectOptions, type ProjectResponse, type PromptUpdatePayload, RateLimitError, type SearchOptions, type User, ValidationError, type Webhook, type WebhookCreatePayload, WebhookEvent, type WebhookUpdatePayload, createExceptionFromResponse, MemoryClient as default };
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/client/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
AuthenticationError: () => AuthenticationError,
|
|
34
|
+
ConfigurationError: () => ConfigurationError,
|
|
35
|
+
Feedback: () => Feedback,
|
|
33
36
|
MemoryClient: () => MemoryClient,
|
|
37
|
+
MemoryError: () => MemoryError,
|
|
38
|
+
MemoryNotFoundError: () => MemoryNotFoundError,
|
|
39
|
+
MemoryQuotaExceededError: () => MemoryQuotaExceededError,
|
|
40
|
+
NetworkError: () => NetworkError,
|
|
41
|
+
RateLimitError: () => RateLimitError,
|
|
42
|
+
ValidationError: () => ValidationError,
|
|
43
|
+
WebhookEvent: () => WebhookEvent,
|
|
44
|
+
createExceptionFromResponse: () => createExceptionFromResponse,
|
|
34
45
|
default: () => index_default
|
|
35
46
|
});
|
|
36
47
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -112,6 +123,103 @@ async function captureClientEvent(eventName, instance, additionalData = {}) {
|
|
|
112
123
|
);
|
|
113
124
|
}
|
|
114
125
|
|
|
126
|
+
// src/common/exceptions.ts
|
|
127
|
+
var MemoryError = class extends Error {
|
|
128
|
+
constructor(message, errorCode, options = {}) {
|
|
129
|
+
var _a2, _b;
|
|
130
|
+
super(message);
|
|
131
|
+
this.name = "MemoryError";
|
|
132
|
+
this.errorCode = errorCode;
|
|
133
|
+
this.details = (_a2 = options.details) != null ? _a2 : {};
|
|
134
|
+
this.suggestion = options.suggestion;
|
|
135
|
+
this.debugInfo = (_b = options.debugInfo) != null ? _b : {};
|
|
136
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var AuthenticationError = class extends MemoryError {
|
|
140
|
+
constructor(message, errorCode, options) {
|
|
141
|
+
super(message, errorCode, options);
|
|
142
|
+
this.name = "AuthenticationError";
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var RateLimitError = class extends MemoryError {
|
|
146
|
+
constructor(message, errorCode, options) {
|
|
147
|
+
super(message, errorCode, options);
|
|
148
|
+
this.name = "RateLimitError";
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var ValidationError = class extends MemoryError {
|
|
152
|
+
constructor(message, errorCode, options) {
|
|
153
|
+
super(message, errorCode, options);
|
|
154
|
+
this.name = "ValidationError";
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var MemoryNotFoundError = class extends MemoryError {
|
|
158
|
+
constructor(message, errorCode, options) {
|
|
159
|
+
super(message, errorCode, options);
|
|
160
|
+
this.name = "MemoryNotFoundError";
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var NetworkError = class extends MemoryError {
|
|
164
|
+
constructor(message, errorCode, options) {
|
|
165
|
+
super(message, errorCode, options);
|
|
166
|
+
this.name = "NetworkError";
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var ConfigurationError = class extends MemoryError {
|
|
170
|
+
constructor(message, errorCode, options) {
|
|
171
|
+
super(message, errorCode, options);
|
|
172
|
+
this.name = "ConfigurationError";
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
var MemoryQuotaExceededError = class extends MemoryError {
|
|
176
|
+
constructor(message, errorCode, options) {
|
|
177
|
+
super(message, errorCode, options);
|
|
178
|
+
this.name = "MemoryQuotaExceededError";
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var HTTP_STATUS_TO_EXCEPTION = {
|
|
182
|
+
400: ValidationError,
|
|
183
|
+
401: AuthenticationError,
|
|
184
|
+
403: AuthenticationError,
|
|
185
|
+
404: MemoryNotFoundError,
|
|
186
|
+
408: NetworkError,
|
|
187
|
+
409: ValidationError,
|
|
188
|
+
413: MemoryQuotaExceededError,
|
|
189
|
+
422: ValidationError,
|
|
190
|
+
429: RateLimitError,
|
|
191
|
+
500: MemoryError,
|
|
192
|
+
502: NetworkError,
|
|
193
|
+
503: NetworkError,
|
|
194
|
+
504: NetworkError
|
|
195
|
+
};
|
|
196
|
+
var HTTP_SUGGESTIONS = {
|
|
197
|
+
400: "Please check your request parameters and try again",
|
|
198
|
+
401: "Please check your API key and authentication credentials",
|
|
199
|
+
403: "You don't have permission to perform this operation",
|
|
200
|
+
404: "The requested resource was not found",
|
|
201
|
+
408: "Request timed out. Please try again",
|
|
202
|
+
409: "Resource conflict. Please check your request",
|
|
203
|
+
413: "Request too large. Please reduce the size of your request",
|
|
204
|
+
422: "Invalid request data. Please check your input",
|
|
205
|
+
429: "Rate limit exceeded. Please wait before making more requests",
|
|
206
|
+
500: "Internal server error. Please try again later",
|
|
207
|
+
502: "Service temporarily unavailable. Please try again later",
|
|
208
|
+
503: "Service unavailable. Please try again later",
|
|
209
|
+
504: "Gateway timeout. Please try again later"
|
|
210
|
+
};
|
|
211
|
+
function createExceptionFromResponse(statusCode, responseText, options = {}) {
|
|
212
|
+
var _a2, _b;
|
|
213
|
+
const ExceptionClass = (_a2 = HTTP_STATUS_TO_EXCEPTION[statusCode]) != null ? _a2 : MemoryError;
|
|
214
|
+
const errorCode = `HTTP_${statusCode}`;
|
|
215
|
+
const suggestion = (_b = HTTP_SUGGESTIONS[statusCode]) != null ? _b : "Please try again later";
|
|
216
|
+
return new ExceptionClass(
|
|
217
|
+
responseText || `HTTP ${statusCode} error`,
|
|
218
|
+
errorCode,
|
|
219
|
+
{ ...options, suggestion }
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
115
223
|
// src/client/mem0.ts
|
|
116
224
|
var APIError = class extends Error {
|
|
117
225
|
constructor(message) {
|
|
@@ -204,7 +312,7 @@ var MemoryClient = class {
|
|
|
204
312
|
});
|
|
205
313
|
if (!response.ok) {
|
|
206
314
|
const errorData = await response.text();
|
|
207
|
-
throw
|
|
315
|
+
throw createExceptionFromResponse(response.status, errorData);
|
|
208
316
|
}
|
|
209
317
|
const jsonResponse = await response.json();
|
|
210
318
|
return jsonResponse;
|
|
@@ -241,7 +349,7 @@ var MemoryClient = class {
|
|
|
241
349
|
if (project_id && !this.projectId) this.projectId = project_id;
|
|
242
350
|
if (user_email) this.telemetryId = user_email;
|
|
243
351
|
} catch (error) {
|
|
244
|
-
if (error instanceof APIError) {
|
|
352
|
+
if (error instanceof MemoryError || error instanceof APIError) {
|
|
245
353
|
throw error;
|
|
246
354
|
} else {
|
|
247
355
|
throw new APIError(
|
|
@@ -322,7 +430,7 @@ var MemoryClient = class {
|
|
|
322
430
|
this._validateOrgProject();
|
|
323
431
|
const payloadKeys = Object.keys(options || {});
|
|
324
432
|
this._captureEvent("get_all", [payloadKeys]);
|
|
325
|
-
const { api_version, page, page_size, ...otherOptions } = options;
|
|
433
|
+
const { api_version, page, page_size, ...otherOptions } = options != null ? options : {};
|
|
326
434
|
if (this.organizationName != null && this.projectName != null) {
|
|
327
435
|
otherOptions.org_name = this.organizationName;
|
|
328
436
|
otherOptions.project_name = this.projectName;
|
|
@@ -359,7 +467,7 @@ var MemoryClient = class {
|
|
|
359
467
|
this._validateOrgProject();
|
|
360
468
|
const payloadKeys = Object.keys(options || {});
|
|
361
469
|
this._captureEvent("search", [payloadKeys]);
|
|
362
|
-
const { api_version, ...otherOptions } = options;
|
|
470
|
+
const { api_version, ...otherOptions } = options != null ? options : {};
|
|
363
471
|
const payload = { query, ...otherOptions };
|
|
364
472
|
if (this.organizationName != null && this.projectName != null) {
|
|
365
473
|
payload.org_name = this.organizationName;
|
|
@@ -621,12 +729,17 @@ var MemoryClient = class {
|
|
|
621
729
|
async createWebhook(webhook) {
|
|
622
730
|
if (this.telemetryId === "") await this.ping();
|
|
623
731
|
this._captureEvent("create_webhook", []);
|
|
732
|
+
const body = {
|
|
733
|
+
name: webhook.name,
|
|
734
|
+
url: webhook.url,
|
|
735
|
+
event_types: webhook.eventTypes
|
|
736
|
+
};
|
|
624
737
|
const response = await this._fetchWithErrorHandling(
|
|
625
738
|
`${this.host}/api/v1/webhooks/projects/${this.projectId}/`,
|
|
626
739
|
{
|
|
627
740
|
method: "POST",
|
|
628
741
|
headers: this.headers,
|
|
629
|
-
body: JSON.stringify(
|
|
742
|
+
body: JSON.stringify(body)
|
|
630
743
|
}
|
|
631
744
|
);
|
|
632
745
|
return response;
|
|
@@ -634,16 +747,16 @@ var MemoryClient = class {
|
|
|
634
747
|
async updateWebhook(webhook) {
|
|
635
748
|
if (this.telemetryId === "") await this.ping();
|
|
636
749
|
this._captureEvent("update_webhook", []);
|
|
637
|
-
const
|
|
750
|
+
const body = {};
|
|
751
|
+
if (webhook.name != null) body.name = webhook.name;
|
|
752
|
+
if (webhook.url != null) body.url = webhook.url;
|
|
753
|
+
if (webhook.eventTypes != null) body.event_types = webhook.eventTypes;
|
|
638
754
|
const response = await this._fetchWithErrorHandling(
|
|
639
755
|
`${this.host}/api/v1/webhooks/${webhook.webhookId}/`,
|
|
640
756
|
{
|
|
641
757
|
method: "PUT",
|
|
642
758
|
headers: this.headers,
|
|
643
|
-
body: JSON.stringify(
|
|
644
|
-
...webhook,
|
|
645
|
-
projectId: project_id
|
|
646
|
-
})
|
|
759
|
+
body: JSON.stringify(body)
|
|
647
760
|
}
|
|
648
761
|
);
|
|
649
762
|
return response;
|
|
@@ -715,10 +828,36 @@ var MemoryClient = class {
|
|
|
715
828
|
}
|
|
716
829
|
};
|
|
717
830
|
|
|
831
|
+
// src/client/mem0.types.ts
|
|
832
|
+
var Feedback = /* @__PURE__ */ ((Feedback2) => {
|
|
833
|
+
Feedback2["POSITIVE"] = "POSITIVE";
|
|
834
|
+
Feedback2["NEGATIVE"] = "NEGATIVE";
|
|
835
|
+
Feedback2["VERY_NEGATIVE"] = "VERY_NEGATIVE";
|
|
836
|
+
return Feedback2;
|
|
837
|
+
})(Feedback || {});
|
|
838
|
+
var WebhookEvent = /* @__PURE__ */ ((WebhookEvent2) => {
|
|
839
|
+
WebhookEvent2["MEMORY_ADDED"] = "memory_add";
|
|
840
|
+
WebhookEvent2["MEMORY_UPDATED"] = "memory_update";
|
|
841
|
+
WebhookEvent2["MEMORY_DELETED"] = "memory_delete";
|
|
842
|
+
WebhookEvent2["MEMORY_CATEGORIZED"] = "memory_categorize";
|
|
843
|
+
return WebhookEvent2;
|
|
844
|
+
})(WebhookEvent || {});
|
|
845
|
+
|
|
718
846
|
// src/client/index.ts
|
|
719
847
|
var index_default = MemoryClient;
|
|
720
848
|
// Annotate the CommonJS export names for ESM import in node:
|
|
721
849
|
0 && (module.exports = {
|
|
722
|
-
|
|
850
|
+
AuthenticationError,
|
|
851
|
+
ConfigurationError,
|
|
852
|
+
Feedback,
|
|
853
|
+
MemoryClient,
|
|
854
|
+
MemoryError,
|
|
855
|
+
MemoryNotFoundError,
|
|
856
|
+
MemoryQuotaExceededError,
|
|
857
|
+
NetworkError,
|
|
858
|
+
RateLimitError,
|
|
859
|
+
ValidationError,
|
|
860
|
+
WebhookEvent,
|
|
861
|
+
createExceptionFromResponse
|
|
723
862
|
});
|
|
724
863
|
//# sourceMappingURL=index.js.map
|