@ragable/sdk 0.6.16 → 0.6.18

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
@@ -2247,6 +2247,8 @@ var RagableBrowserDatabaseClient = class {
2247
2247
  this.ragableAuth = ragableAuth;
2248
2248
  __publicField(this, "fetchImpl");
2249
2249
  __publicField(this, "_transport", null);
2250
+ __publicField(this, "collections");
2251
+ __publicField(this, "collection");
2250
2252
  /**
2251
2253
  * PostgREST table access. Instance field so `client.database.from` is always an own,
2252
2254
  * enumerable function (avoids rare prototype/bundler issues).
@@ -2300,9 +2302,6 @@ var RagableBrowserDatabaseClient = class {
2300
2302
  };
2301
2303
  return new PostgrestTableApi(pgFetch, id, table);
2302
2304
  });
2303
- __publicField(this, "collection", (name, databaseInstanceId) => {
2304
- return new BrowserCollectionApi(this, name, databaseInstanceId);
2305
- });
2306
2305
  __publicField(this, "defineCollection", (name, schema, databaseInstanceId) => asPostgrestResponse(
2307
2306
  () => this._requestCollection(
2308
2307
  "POST",
@@ -2385,6 +2384,21 @@ var RagableBrowserDatabaseClient = class {
2385
2384
  )
2386
2385
  });
2387
2386
  this.fetchImpl = bindFetch(options.fetch);
2387
+ this.collections = new Proxy(
2388
+ {},
2389
+ {
2390
+ get: (_target, prop) => {
2391
+ if (typeof prop !== "string") return void 0;
2392
+ if (prop === "then") return void 0;
2393
+ return this.collection(prop);
2394
+ }
2395
+ }
2396
+ );
2397
+ this.collection = ((name, databaseInstanceId) => new BrowserCollectionApi(
2398
+ this,
2399
+ name,
2400
+ databaseInstanceId
2401
+ ));
2388
2402
  }
2389
2403
  /** @internal Called by RagableBrowser to share the Transport instance. */
2390
2404
  _setTransport(transport) {
@@ -2399,7 +2413,7 @@ var RagableBrowserDatabaseClient = class {
2399
2413
  const id = databaseInstanceId?.trim() || this.options.databaseInstanceId?.trim();
2400
2414
  if (!id) {
2401
2415
  throw new RagableError(
2402
- "db.collection() requires databaseInstanceId in client options or as an argument",
2416
+ "db.collections requires databaseInstanceId in client options. For dynamic collection() calls, you can also pass databaseInstanceId as the second argument.",
2403
2417
  400,
2404
2418
  { code: "SDK_MISSING_DATABASE_INSTANCE_ID" }
2405
2419
  );
@@ -2769,7 +2783,7 @@ function createClient(options) {
2769
2783
  if (isServerClientOptions(options)) {
2770
2784
  if (typeof options === "object" && options !== null && "organizationId" in options && typeof options.organizationId === "string") {
2771
2785
  console.warn(
2772
- "[@ragable/sdk] createClient: `apiKey` is set, so the server client is returned. It has no `database` or `auth` \u2014 only `agents` and `shift`. For `db.collection()` / `database.from()` / `auth.*`, use the browser client without `apiKey` (e.g. createClient({ organizationId, authGroupId, databaseInstanceId, ... }))."
2786
+ "[@ragable/sdk] createClient: `apiKey` is set, so the server client is returned. It has no `database` or `auth` \u2014 only `agents` and `shift`. For `db.collections.<name>` / `database.from()` / `auth.*`, use the browser client without `apiKey` (e.g. createClient({ organizationId, authGroupId, databaseInstanceId, ... }))."
2773
2787
  );
2774
2788
  }
2775
2789
  return new Ragable(options);