memorysync-sdk 1.7.3 → 1.9.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 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.3";
535
+ var SDK_VERSION = "1.9.0";
536
536
  function safeJson(text) {
537
537
  try {
538
538
  return JSON.parse(text);
@@ -1104,7 +1104,7 @@ function asSkipped(raw, defaultReason) {
1104
1104
  }
1105
1105
  return null;
1106
1106
  }
1107
- var SDK_VERSION2 = "1.7.3";
1107
+ var SDK_VERSION2 = "1.9.0";
1108
1108
  function camelToSnakeKey(key) {
1109
1109
  return key.replace(/([A-Z])/g, "_$1").toLowerCase();
1110
1110
  }
@@ -1271,6 +1271,7 @@ var MemorySyncClient = class {
1271
1271
  if (req.sessionId !== void 0) body.session_id = req.sessionId;
1272
1272
  if (req.metadata !== void 0) body.metadata = req.metadata;
1273
1273
  if (req.endUserId !== void 0) body.end_user_id = req.endUserId;
1274
+ if (req.clientRef !== void 0) body.client_ref = req.clientRef;
1274
1275
  const raw = await this.request("POST", "/memory/add", {
1275
1276
  body,
1276
1277
  endUserOverride: req.endUserId
@@ -1291,6 +1292,7 @@ var MemorySyncClient = class {
1291
1292
  if (i.metadata !== void 0) o.metadata = i.metadata;
1292
1293
  if (i.importance !== void 0) o.importance = i.importance;
1293
1294
  if (i.endUserId !== void 0) o.end_user_id = i.endUserId;
1295
+ if (i.clientRef !== void 0) o.client_ref = i.clientRef;
1294
1296
  return o;
1295
1297
  }),
1296
1298
  deduplicate: opts.deduplicate ?? true
@@ -1320,6 +1322,63 @@ var MemorySyncClient = class {
1320
1322
  }))
1321
1323
  };
1322
1324
  }
1325
+ // ── Bulk import ────────────────────────────────────────────────────
1326
+ /**
1327
+ * Upload a payload and get an import job back, without waiting for it.
1328
+ *
1329
+ * `bulkAdd` accepts fifty records per call because each one runs the extraction
1330
+ * pipeline. For a migration out of another system, upload the whole file here
1331
+ * and poll {@link getImport}.
1332
+ *
1333
+ * `resume` requires `clientRef` on every record and is what makes re-running the
1334
+ * same file safe: records a previous run already stored come back counted as
1335
+ * `alreadyImported` rather than stored again.
1336
+ *
1337
+ * The payload is JSONL, or JSON when `filename` ends in `.json`. The extension
1338
+ * is how the server picks the reader, so it is required.
1339
+ */
1340
+ async createImport(req) {
1341
+ if (!req.filename?.trim()) {
1342
+ throw new ValidationError("filename is required so the server can pick a reader");
1343
+ }
1344
+ const form = new FormData();
1345
+ form.set("resume", req.resume ? "true" : "false");
1346
+ form.set("continue_on_error", req.continueOnError ? "true" : "false");
1347
+ if (req.endUserId !== void 0) form.set("end_user_id", req.endUserId);
1348
+ const blob = req.file instanceof Blob ? req.file : new Blob([req.file], { type: "application/octet-stream" });
1349
+ form.set("file", blob, req.filename);
1350
+ return this.request("POST", "/imports", {
1351
+ form,
1352
+ endUserOverride: req.endUserId
1353
+ });
1354
+ }
1355
+ /**
1356
+ * One import job's status, progress and per-outcome counters.
1357
+ *
1358
+ * `progress_percentage` stays below 100 until the job is genuinely finished, so
1359
+ * reaching 100 means done.
1360
+ */
1361
+ async getImport(jobId) {
1362
+ if (!jobId?.trim()) throw new ValidationError("jobId is required");
1363
+ return this.request("GET", `/imports/${encodeURIComponent(jobId)}`);
1364
+ }
1365
+ /** Recent import jobs, newest first. */
1366
+ async listImports(opts = {}) {
1367
+ return this.request("GET", "/imports", { query: opts });
1368
+ }
1369
+ /**
1370
+ * Ask the worker to stop between batches.
1371
+ *
1372
+ * Records already imported stay imported, and the counters report how far it
1373
+ * reached. Cancelling a finished job is a no-op rather than an error.
1374
+ */
1375
+ async cancelImport(jobId) {
1376
+ if (!jobId?.trim()) throw new ValidationError("jobId is required");
1377
+ return this.request(
1378
+ "POST",
1379
+ `/imports/${encodeURIComponent(jobId)}/cancel`
1380
+ );
1381
+ }
1323
1382
  async query(req) {
1324
1383
  const body = { query: req.query };
1325
1384
  if (req.k !== void 0) body.k = req.k;