memorysync-sdk 1.7.2 → 1.7.3

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 CHANGED
@@ -532,7 +532,7 @@ var IntegrationsNamespace = class extends Namespace {
532
532
  };
533
533
 
534
534
  // src/control-plane.ts
535
- var SDK_VERSION = "1.7.2";
535
+ var SDK_VERSION = "1.7.3";
536
536
  function safeJson(text) {
537
537
  try {
538
538
  return JSON.parse(text);
@@ -1088,7 +1088,23 @@ var ControlPlaneClient = class {
1088
1088
  };
1089
1089
 
1090
1090
  // src/index.ts
1091
- var SDK_VERSION2 = "1.7.2";
1091
+ function asSkipped(raw, defaultReason) {
1092
+ if (!raw || typeof raw !== "object") return null;
1093
+ if (raw.status === "skipped") {
1094
+ return {
1095
+ status: "skipped",
1096
+ reason: raw.reason ?? defaultReason,
1097
+ memoryIds: raw.memory_ids ?? [],
1098
+ candidatesExtracted: raw.candidates_extracted ?? 0,
1099
+ candidatesStored: raw.candidates_stored ?? 0
1100
+ };
1101
+ }
1102
+ if (raw.status === "ok" && raw.id === void 0) {
1103
+ return { status: "skipped", reason: "quota_exhausted", memoryIds: [], candidatesExtracted: 0, candidatesStored: 0 };
1104
+ }
1105
+ return null;
1106
+ }
1107
+ var SDK_VERSION2 = "1.7.3";
1092
1108
  function camelToSnakeKey(key) {
1093
1109
  return key.replace(/([A-Z])/g, "_$1").toLowerCase();
1094
1110
  }
@@ -1259,15 +1275,8 @@ var MemorySyncClient = class {
1259
1275
  body,
1260
1276
  endUserOverride: req.endUserId
1261
1277
  });
1262
- if (raw && raw.status === "skipped") {
1263
- return {
1264
- status: "skipped",
1265
- reason: raw.reason ?? "no_high_value_content",
1266
- memoryIds: raw.memory_ids ?? [],
1267
- candidatesExtracted: raw.candidates_extracted ?? 0,
1268
- candidatesStored: raw.candidates_stored ?? 0
1269
- };
1270
- }
1278
+ const notStored = asSkipped(raw, "no_high_value_content");
1279
+ if (notStored) return notStored;
1271
1280
  return snakeToCamelMemory(raw);
1272
1281
  }
1273
1282
  async bulkAdd(items, opts = {}) {
@@ -1287,12 +1296,23 @@ var MemorySyncClient = class {
1287
1296
  deduplicate: opts.deduplicate ?? true
1288
1297
  };
1289
1298
  const raw = await this.request("POST", "/memory/bulk-add", { body });
1299
+ if (!Array.isArray(raw.results)) {
1300
+ return {
1301
+ total: items.length,
1302
+ created: 0,
1303
+ skipped: 0,
1304
+ rejected: 0,
1305
+ results: [],
1306
+ unreported: items.length
1307
+ };
1308
+ }
1290
1309
  return {
1291
1310
  total: raw.total,
1292
1311
  created: raw.created,
1293
1312
  skipped: raw.skipped,
1294
1313
  rejected: raw.rejected,
1295
- results: (raw.results ?? []).map((r) => ({
1314
+ unreported: 0,
1315
+ results: raw.results.map((r) => ({
1296
1316
  index: r.index,
1297
1317
  status: r.status,
1298
1318
  memoryIds: r.memory_ids ?? [],
@@ -1489,15 +1509,8 @@ var MemorySyncClient = class {
1489
1509
  form,
1490
1510
  endUserOverride: req.endUserId
1491
1511
  });
1492
- if (raw && raw.status === "skipped") {
1493
- return {
1494
- status: "skipped",
1495
- reason: raw.reason ?? "no_extractable_text",
1496
- memoryIds: raw.memory_ids ?? [],
1497
- candidatesExtracted: raw.candidates_extracted ?? 0,
1498
- candidatesStored: raw.candidates_stored ?? 0
1499
- };
1500
- }
1512
+ const notStored = asSkipped(raw, "no_extractable_text");
1513
+ if (notStored) return notStored;
1501
1514
  return snakeToCamelMemory(raw);
1502
1515
  }
1503
1516
  // ── Bulk edit ──────────────────────────────────────────────────────