@midsummer-ai/sdk 0.1.0-next.1723 → 0.1.0-next.1979

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.
@@ -240,11 +240,13 @@ const SUBSCRIBE_WINDOW_MS = breakEvenMs({
240
240
  holdUsdPerSec: PUSH_USD / 60,
241
241
  eachUsd: READ_USD
242
242
  });
243
- /** Whether a token says server code: ours with `ro: "server"`, or the platform's for a Database Key (`iss: "midsummer"`,
244
- * `sub: "key:<id>"`; a person's, `user:<handle>`, is not). */
243
+ /** Whether a token says server code: ours with `ro: "server"`, or the platform's for a Database Key (`key:<id>`), a
244
+ * Deployment (`site:<project>:<environment>`) or a CI or Agent run (`workload:<project>:<environment>`), each with
245
+ * `iss: "midsummer"`; a person's, `user:<handle>`, is not. */
246
+ const SERVER_SUBJECTS = /^(?:key|site|workload):/u;
245
247
  const serverToken = (token) => {
246
248
  const p = payloadOf(token);
247
- return p?.ro === "server" || p?.iss === "midsummer" && String(p?.sub ?? "").startsWith("key:");
249
+ return p?.ro === "server" || p?.iss === "midsummer" && SERVER_SUBJECTS.test(String(p?.sub ?? ""));
248
250
  };
249
251
  /** The shape `Connection.connect` takes: "binding" (a server object binding in `opts.env.DATABASE_EDGE` or
250
252
  * `opts.binding`), "server" (a runtime with no `window` / `document`, and a server token), else "browser". `g`: the
@@ -406,8 +408,8 @@ var Connection = class Connection {
406
408
  ...options,
407
409
  shape
408
410
  };
409
- if (o.store === void 0 && typeof indexedDB !== "undefined" && typeof document !== "undefined") o.store = (await import("./store-BA8K-bAR.mjs")).idbStore(new URL(url).host);
410
- if (o.tabs !== false && typeof document !== "undefined") return (await import("./tabs-DEeMee7M.mjs")).ConnectionTabs.connect(url, o);
411
+ if (o.store === void 0 && typeof indexedDB !== "undefined" && typeof document !== "undefined") o.store = (await import("./store-CfQLVX-u.mjs")).idbStore(new URL(url).host);
412
+ if (o.tabs !== false && typeof document !== "undefined") return (await import("./tabs-C5uIkZzN.mjs")).ConnectionTabs.connect(url, o);
411
413
  return Connection.open(url, o);
412
414
  }
413
415
  /** A Connection over one socket, of the shape given (default "browser"), no detection (tabs.mjs opens its own so). */
@@ -1,5 +1,5 @@
1
1
  import { DatabaseError } from "./errors.mjs";
2
- import { t as Connection } from "../connection-BHjDaLYA.mjs";
2
+ import { t as Connection } from "../connection-CCeSgaOV.mjs";
3
3
  //#region src/database/client.ts
4
4
  /**
5
5
  * `@midsummer-ai/sdk/database`: a Project's Database, from its app or its server.
@@ -54,6 +54,7 @@ const caught = (error) => ({
54
54
  });
55
55
  async function connect(options) {
56
56
  let url, token, refresh;
57
+ const server = !("url" in options);
57
58
  if ("database" in options) {
58
59
  const first = await options.database.token(options.binding);
59
60
  url = first.url;
@@ -97,7 +98,8 @@ async function connect(options) {
97
98
  }
98
99
  const connection = await Connection.connect(url, {
99
100
  ...token !== void 0 ? { token } : {},
100
- ...refresh ? { refresh } : {}
101
+ ...refresh ? { refresh } : {},
102
+ ...server ? { shape: "server" } : {}
101
103
  });
102
104
  const call = (fn) => ({
103
105
  name: fn.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midsummer-ai/sdk",
3
- "version": "0.1.0-next.1723",
3
+ "version": "0.1.0-next.1979",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Midsummer's handles for an app's code: its Database, Storage, Queues, Vector DB, AI, Email and Agents, with stand-ins for tests.",
@@ -1,4 +1,4 @@
1
- import "./connection-BHjDaLYA.mjs";
1
+ import "./connection-CCeSgaOV.mjs";
2
2
  //#region src/database/client/store.mjs
3
3
  const STORES = [
4
4
  "ops",
@@ -1,4 +1,4 @@
1
- import { t as Connection } from "./connection-BHjDaLYA.mjs";
1
+ import { t as Connection } from "./connection-CCeSgaOV.mjs";
2
2
  //#region src/database/client/tabs.mjs
3
3
  /** Argument index of the options that take a `tag` (a tab tags its own writes: the same tag after a handover). */
4
4
  const TAGGED = {