@brainbox-labs/sdk 0.23.0 → 0.23.1

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.js CHANGED
@@ -405,13 +405,16 @@ var BrainBox = class {
405
405
  throw new Error("[BrainBox] brain.sync does not support tenant keys yet. Use a project or org key.");
406
406
  }
407
407
  const ctx = await this.ingestContext("sync");
408
- const { performSync } = await import("./sync-MXG4WALD.js");
408
+ const { performSync } = await import("./sync-K4NBZBF3.js");
409
409
  return performSync(ctx, opts);
410
410
  }
411
411
  /** Archive the synced pages for these `sourceKey`s (soft, reversible server-side). Unknown keys come back in `notFound`. */
412
412
  async prune(sourceKeys) {
413
+ if (isTenantKey(this.options.apiKey)) {
414
+ throw new Error("[BrainBox] brain.prune does not support tenant keys yet. Use a project or org key.");
415
+ }
413
416
  const ctx = await this.ingestContext("prune");
414
- const { performPrune } = await import("./sync-MXG4WALD.js");
417
+ const { performPrune } = await import("./sync-K4NBZBF3.js");
415
418
  return performPrune(ctx, sourceKeys);
416
419
  }
417
420
  /** Target for write-side calls: a tenant key's overlay project, else the handle's `project`. */
@@ -46,7 +46,7 @@ async function loadTransform(ref, baseDir) {
46
46
  try {
47
47
  mod = await import(pathToFileURL(file).href);
48
48
  } catch (err) {
49
- const hint = file.endsWith(".ts") ? " (.ts transforms need Node 22.6+ or a loader such as tsx; a .mjs works everywhere)" : "";
49
+ const hint = file.endsWith(".ts") ? " (.ts transforms need Node 22.18+ / 23.6+, plain typed JS only, or a loader such as tsx; a .mjs works everywhere)" : "";
50
50
  throw new Error(`[BrainBox] could not load transform ${file}: ${err instanceof Error ? err.message : String(err)}${hint}`);
51
51
  }
52
52
  if (typeof mod.default !== "function") throw new Error(`[BrainBox] transform ${file} must default-export a function`);
@@ -235,6 +235,7 @@ async function performSync(ctx, syncOpts, deps = {}) {
235
235
  }
236
236
  async function prune(api, orgId, projectId, keys) {
237
237
  const out = { archived: [], notFound: [] };
238
+ for (const key of keys) validateSourceKey(key);
238
239
  for (const key of keys) {
239
240
  const r = await api.archiveWikiSource(orgId, projectId, validateSourceKey(key));
240
241
  (r === "archived" ? out.archived : out.notFound).push(key);
@@ -243,8 +244,12 @@ async function prune(api, orgId, projectId, keys) {
243
244
  }
244
245
  async function performPrune(ctx, sourceKeys, ids) {
245
246
  const api = new BrainBoxApiClient(ctx.apiUrl, ctx.apiKey, noopLogger);
246
- const { orgId, projectId } = ids ?? await resolveIds(api, ctx);
247
- return prune(api, orgId, projectId, sourceKeys);
247
+ if (!ids) {
248
+ const found = await lookupIds(api, ctx);
249
+ if (!found.projectId) throw new Error(`[BrainBox] project "${ctx.project}" not found in org "${ctx.org}"`);
250
+ ids = { orgId: found.orgId, projectId: found.projectId };
251
+ }
252
+ return prune(api, ids.orgId, ids.projectId, sourceKeys);
248
253
  }
249
254
  export {
250
255
  applyTransform,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainbox-labs/sdk",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "description": "BrainBox JavaScript/TypeScript SDK — MCP server + API client",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",