@granular-software/sdk 0.4.5 → 0.4.6

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
@@ -4555,7 +4555,8 @@ var Session = class {
4555
4555
  * ```typescript
4556
4556
  * import { Author, Book, global_search } from './sandbox-tools';
4557
4557
  *
4558
- * const tolkien = await Author.find({ id: 'tolkien' });
4558
+ * const authors = await Author.list({ limit: 10, saveAs: 'recent_authors' });
4559
+ * const tolkien = await Author.get({ path: 'author_tolkien' });
4559
4560
  * const bio = await tolkien.get_bio({ detailed: true });
4560
4561
  * const books = await tolkien.get_books();
4561
4562
  * ```
@@ -6127,7 +6128,21 @@ var Granular = class {
6127
6128
  const effects = Array.from(this.getSandboxEffectMap(host.sandboxId).values()).map(
6128
6129
  (effect) => this.serializeEffect(effect)
6129
6130
  );
6130
- await host.wsClient.call("effects.publishCatalog", { effects });
6131
+ const result = await host.wsClient.call("effects.publishCatalog", { effects });
6132
+ const acceptedCount = typeof result?.acceptedCount === "number" ? result.acceptedCount : 0;
6133
+ const rejected = Array.isArray(result?.rejected) ? result.rejected : [];
6134
+ if (acceptedCount === 0 && rejected.length > 0) {
6135
+ const detail = rejected.map((entry) => `${entry.name || "unknown"}: ${entry.reason || "rejected"}`).join("; ");
6136
+ throw new Error(
6137
+ `Failed to publish live effects for sandbox ${host.sandboxId}: ${detail}`
6138
+ );
6139
+ }
6140
+ if (rejected.length > 0) {
6141
+ console.warn(
6142
+ `[Granular] Some live effects were rejected for sandbox ${host.sandboxId}:`,
6143
+ rejected
6144
+ );
6145
+ }
6131
6146
  }
6132
6147
  async syncSandboxEffectCatalog(sandboxId) {
6133
6148
  const host = await this.ensureSandboxEffectHost(sandboxId);
@@ -6293,6 +6308,22 @@ var Granular = class {
6293
6308
  }
6294
6309
  await this.syncSandboxEffectCatalog(sandboxId);
6295
6310
  }
6311
+ /**
6312
+ * Disconnect one sandbox-scoped effect host, or all of them when no sandbox is provided.
6313
+ *
6314
+ * This is primarily useful for long-lived helper processes such as generated
6315
+ * `granular-effects.ts` scripts that need to shut down cleanly on SIGINT/SIGTERM.
6316
+ */
6317
+ async disconnectEffects(sandboxNameOrId) {
6318
+ if (sandboxNameOrId) {
6319
+ const sandbox = await this.findOrCreateSandbox(sandboxNameOrId);
6320
+ this.disconnectSandboxEffectHost(sandbox.sandboxId);
6321
+ return;
6322
+ }
6323
+ for (const sandboxId of Array.from(this.sandboxEffectHosts.keys())) {
6324
+ this.disconnectSandboxEffectHost(sandboxId);
6325
+ }
6326
+ }
6296
6327
  /**
6297
6328
  * Unregister all effects for a sandbox.
6298
6329
  */