@midsummer-ai/sdk 0.1.0-staging.3554 → 0.1.0-staging.3557

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.
@@ -73,11 +73,11 @@ declare function enumAsObject(ts: string, line: number, column: number): string
73
73
  declare function blockNames(statements: ReadonlyArray<Any>, out: Set<string>): void;
74
74
  /** Every call of `name` where no scope around it binds `name`: the global's, which a module may not call. */
75
75
  declare function unboundCalls(tree: Any, name: string): Any[];
76
- type EngineName = "split-cell" | "ghost-fn";
76
+ type EngineName = "current" | "next";
77
77
  /**
78
78
  * The engine Databases run on today, which `midsummer db dev`, `midsummer dev` and `midsummer db deploy` build for, so
79
- * a function they admit runs there. When ghost-fn ships this is "ghost-fn", the one line to change. A build that
80
- * names no engine checks against ghost-fn's, the contract's engine.
79
+ * a function they admit runs there. When the next engine ships this is "next", the one line to change. A build that
80
+ * names no engine checks against the next engine's, the contract's engine.
81
81
  */
82
82
  declare const DEPLOYED_ENGINE: EngineName;
83
83
  /**
@@ -91,7 +91,7 @@ declare function exported(exports: unknown, sub: string, conditions?: ReadonlySe
91
91
  *
92
92
  * A build's own `files` build again to the same files: what a deploy uploads, and what the Database
93
93
  * checks, is the build. `engine` is the engine whose rules of what a function may name it checks
94
- * (`DEPLOYED_ENGINE` for what runs today; ghost-fn's when not given). Throws `Refused`.
94
+ * (`DEPLOYED_ENGINE` for what runs today; the next engine's when not given). Throws `Refused`.
95
95
  */
96
96
  declare function buildDatabase(sources: Readonly<Record<string, string>>, strip: (ts: string) => string, options?: {
97
97
  readonly packages?: Packages;
@@ -1,2 +1,2 @@
1
- import { a as DEPLOYED_ENGINE, c as Packages, d as buildDatabase, f as enumAsObject, g as unboundCalls, h as typeOf, i as BuiltFunction, l as Refused, m as isSource, n as BUILD_FILES, o as EngineName, p as exported, r as Built, s as MODULE_BYTES, t as BUILD_BYTES, u as blockNames } from "../build-D-cwtwV_.mjs";
1
+ import { a as DEPLOYED_ENGINE, c as Packages, d as buildDatabase, f as enumAsObject, g as unboundCalls, h as typeOf, i as BuiltFunction, l as Refused, m as isSource, n as BUILD_FILES, o as EngineName, p as exported, r as Built, s as MODULE_BYTES, t as BUILD_BYTES, u as blockNames } from "../build-Y6rsumMB.mjs";
2
2
  export { BUILD_BYTES, BUILD_FILES, Built, BuiltFunction, DEPLOYED_ENGINE, EngineName, MODULE_BYTES, Packages, Refused, blockNames, buildDatabase, enumAsObject, exported, isSource, typeOf, unboundCalls };
@@ -592,7 +592,7 @@ const LATER = "Schedule work with ctx.scheduler.runAfter(ms, fn, args) from a mu
592
592
  * (`SHADOWED` in its `tools/seal-core.mjs`, the fabric's list), and its `Math` has no `random`. So `Date.now()` fails
593
593
  * there as "Cannot read properties of undefined (reading 'now')". Every other global of its V8 runtime is there.
594
594
  */
595
- const SPLIT_CELL_SHADOWED = {
595
+ const CURRENT_SHADOWED = {
596
596
  ...Object.fromEntries([
597
597
  "Date",
598
598
  "Temporal",
@@ -670,15 +670,15 @@ const SPLIT_CELL_SHADOWED = {
670
670
  "Proxy"
671
671
  ].map((name) => [name, "A function can't use it here."]))
672
672
  };
673
- const SPLIT_CELL = {
674
- refuses: (name) => Object.hasOwn(SPLIT_CELL_SHADOWED, name) ? `\`${name}\` isn't available in database functions. ${SPLIT_CELL_SHADOWED[name]}` : void 0,
673
+ const CURRENT_RULES = {
674
+ refuses: (name) => Object.hasOwn(CURRENT_SHADOWED, name) ? `\`${name}\` isn't available in database functions. ${CURRENT_SHADOWED[name]}` : void 0,
675
675
  members: { "Math.random": `Math.random isn't available in database functions. ${RANDOM}` }
676
676
  };
677
677
  /**
678
- * ghost-fn's: the rebuild engine, not deployed yet. Its compiler takes these globals (`resolve` in its `compile.rs`)
679
- * and refuses any other at deploy, in the words below; `GHOST_FN_UNBOUND` compile and are undefined when read.
678
+ * The next engine's, not deployed yet. Its compiler takes these globals
679
+ * and refuses any other at deploy, in the words below; `NEXT_UNBOUND` compile and are undefined when read.
680
680
  */
681
- const GHOST_FN_GLOBALS = /* @__PURE__ */ new Set([
681
+ const NEXT_GLOBALS = /* @__PURE__ */ new Set([
682
682
  "Math",
683
683
  "JSON",
684
684
  "Object",
@@ -754,7 +754,7 @@ const GHOST_FN_GLOBALS = /* @__PURE__ */ new Set([
754
754
  "AbortSignal",
755
755
  "structuredClone"
756
756
  ]);
757
- const GHOST_FN_UNBOUND = /* @__PURE__ */ new Set([
757
+ const NEXT_UNBOUND = /* @__PURE__ */ new Set([
758
758
  "window",
759
759
  "document",
760
760
  "navigator",
@@ -775,8 +775,8 @@ const GHOST_FN_UNBOUND = /* @__PURE__ */ new Set([
775
775
  "addEventListener",
776
776
  "removeEventListener"
777
777
  ]);
778
- /** What to use instead of a global ghost-fn refuses, said after its words. */
779
- const GHOST_FN_INSTEAD = {
778
+ /** What to use instead of a global the next engine refuses, said after its words. */
779
+ const NEXT_INSTEAD = {
780
780
  performance: "Time a call with Date.now(), or read ctx.now for the call's time.",
781
781
  queueMicrotask: "Await Promise.resolve() instead.",
782
782
  setImmediate: "In an action, use setTimeout; a query or a mutation never waits.",
@@ -787,18 +787,18 @@ const GHOST_FN_INSTEAD = {
787
787
  WeakRef: "Keep the value in a Map, or read it again."
788
788
  };
789
789
  const ENGINES = {
790
- "split-cell": SPLIT_CELL,
791
- "ghost-fn": {
792
- refuses: (name) => GHOST_FN_GLOBALS.has(name) || GHOST_FN_UNBOUND.has(name) ? void 0 : `\`${name}\` is not defined here (a global a function may not use, or a name never declared)${GHOST_FN_INSTEAD[name] ? `. ${GHOST_FN_INSTEAD[name]}` : ""}`,
790
+ current: CURRENT_RULES,
791
+ next: {
792
+ refuses: (name) => NEXT_GLOBALS.has(name) || NEXT_UNBOUND.has(name) ? void 0 : `\`${name}\` is not defined here (a global a function may not use, or a name never declared)${NEXT_INSTEAD[name] ? `. ${NEXT_INSTEAD[name]}` : ""}`,
793
793
  members: {}
794
794
  }
795
795
  };
796
796
  /**
797
797
  * The engine Databases run on today, which `midsummer db dev`, `midsummer dev` and `midsummer db deploy` build for, so
798
- * a function they admit runs there. When ghost-fn ships this is "ghost-fn", the one line to change. A build that
799
- * names no engine checks against ghost-fn's, the contract's engine.
798
+ * a function they admit runs there. When the next engine ships this is "next", the one line to change. A build that
799
+ * names no engine checks against the next engine's, the contract's engine.
800
800
  */
801
- const DEPLOYED_ENGINE = "split-cell";
801
+ const DEPLOYED_ENGINE = "current";
802
802
  /** Whether a module's parse has an import or export of its own. */
803
803
  const hasModuleSyntax = (tree) => tree.body.some((node) => /^(Import|ExportNamed|ExportAll|ExportDefault)Declaration$/u.test(node.type));
804
804
  /** Whether a package's .js file is CommonJS: no import or export of its own, in a package that doesn't say `"type": "module"`. */
@@ -1601,7 +1601,7 @@ function authConfigFrom(file, tree) {
1601
1601
  *
1602
1602
  * A build's own `files` build again to the same files: what a deploy uploads, and what the Database
1603
1603
  * checks, is the build. `engine` is the engine whose rules of what a function may name it checks
1604
- * (`DEPLOYED_ENGINE` for what runs today; ghost-fn's when not given). Throws `Refused`.
1604
+ * (`DEPLOYED_ENGINE` for what runs today; the next engine's when not given). Throws `Refused`.
1605
1605
  */
1606
1606
  function buildDatabase(sources, strip, options = {}) {
1607
1607
  const { files, from, inputs } = linkAll(stripSources(sources, strip), options.packages, strip);
@@ -1611,7 +1611,7 @@ function buildDatabase(sources, strip, options = {}) {
1611
1611
  let cronTree = null;
1612
1612
  for (const file of Object.keys(files)) {
1613
1613
  const author = from[file];
1614
- const tree = inspect(author, file, files[file], files, ENGINES[options.engine ?? "ghost-fn"]);
1614
+ const tree = inspect(author, file, files[file], files, ENGINES[options.engine ?? "next"]);
1615
1615
  if (file.startsWith("node_modules/") && !file.startsWith(`${PROJECT}/`)) continue;
1616
1616
  const unsafe = authTests(tree)[0];
1617
1617
  if (unsafe) throw new Refused(`${author}${unsafe.loc ? `:${unsafe.loc.start.line}` : ""}: \`${files[file].slice(unsafe.start, unsafe.end)}\` checks nobody: \`ctx.auth\` is there for every caller, signed in or not. Check the caller instead: \`const user = await ctx.auth.getUserIdentity()\`, then \`if (!user)\`.`);
@@ -1,7 +1,7 @@
1
1
  import { p as Storage } from "../index-CXiY5knc.mjs";
2
2
  import { t as AuthConfig } from "../auth-B7rCtXFQ.mjs";
3
3
  import { a as FileMetadata, c as FunctionReference, d as HttpRouter, n as CronJob, s as FunctionKind, v as RegisteredFunction, y as Row } from "../server-B5HK2Ou9.mjs";
4
- import { r as Built } from "../build-D-cwtwV_.mjs";
4
+ import { r as Built } from "../build-Y6rsumMB.mjs";
5
5
  import { t as DatabaseError } from "../errors-x2vXKi0u.mjs";
6
6
  import { A as VectorControl, M as VectorEngine } from "../index-B9zs0wIp.mjs";
7
7
  //#region src/database/stand-in.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midsummer-ai/sdk",
3
- "version": "0.1.0-staging.3554",
3
+ "version": "0.1.0-staging.3557",
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.",