@midsummer-ai/sdk 0.1.0-staging.5091 → 0.1.0-staging.5109

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/auth/contract.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { s as AuthError } from "../auth-Cq_UKvop.mjs";
1
+ import { s as AuthError } from "../auth-DauDyrcI.mjs";
2
2
  import { d as SETTINGS_TTL_MS, n as LIMIT_WINDOW_MS, t as LIMITS } from "../guard-VPI6xq4z.mjs";
3
3
  import { IMPERSONATION_TOKEN_MS, startImpersonation } from "./impersonate.mjs";
4
4
  //#region src/auth/contract.ts
package/auth/files.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as authTables, c as tablesFile, i as authFiles, l as tablesFromEngine, n as EngineField, o as schemaLines, r as FUNCTIONS_FILE, s as schemaUpToDate, t as AuthTable } from "../files-CLuPkXhj.mjs";
2
- export { AuthTable, EngineField, FUNCTIONS_FILE, authFiles, authTables, schemaLines, schemaUpToDate, tablesFile, tablesFromEngine };
1
+ import { a as authTables, c as tablesFile, i as authFiles, l as tablesFromEngine, n as EngineField, o as schemaLines, r as FUNCTIONS_FILE, s as schemaUpToDate, t as AuthTable, u as withAuthTables } from "../files--dL7S8VF.mjs";
2
+ export { AuthTable, EngineField, FUNCTIONS_FILE, authFiles, authTables, schemaLines, schemaUpToDate, tablesFile, tablesFromEngine, withAuthTables };
package/auth/files.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as schemaUpToDate, i as schemaLines, n as authFiles, o as tablesFile, r as authTables, s as tablesFromEngine, t as FUNCTIONS_FILE } from "../files-ZySaprII.mjs";
2
- export { FUNCTIONS_FILE, authFiles, authTables, schemaLines, schemaUpToDate, tablesFile, tablesFromEngine };
1
+ import { a as schemaUpToDate, c as withAuthTables, i as schemaLines, n as authFiles, o as tablesFile, r as authTables, s as tablesFromEngine, t as FUNCTIONS_FILE } from "../files-BhGkb17f.mjs";
2
+ export { FUNCTIONS_FILE, authFiles, authTables, schemaLines, schemaUpToDate, tablesFile, tablesFromEngine, withAuthTables };
package/auth/index.d.mts CHANGED
@@ -3,5 +3,5 @@ import { i as SignUpPolicy, n as CaptchaProvider, r as PublicSettings, t as Auth
3
3
  import { SignInMail, SignInMailKind, checkSignInMail, signInWords } from "./mail.mjs";
4
4
  import { _ as AuthEventBatch, a as Auth, c as AuthUserRecord, d as SignedInAgent, f as auth, g as AuthEvent, h as AuthErrorCode, i as AgentKey, l as SESSION_CACHE_S, m as AuthError, n as AUTH_ROUTES, o as AuthOptions, p as createAuth, r as AgentGrant, s as AuthUser, t as AUTH_PATH, u as SignedIn, v as AuthEventType, y as EventSend } from "../index-CkBabhgi.mjs";
5
5
  import { t as IMPERSONATION_S } from "../impersonate-BI_aYw9e.mjs";
6
- import { i as authFiles } from "../files-CLuPkXhj.mjs";
6
+ import { i as authFiles } from "../files--dL7S8VF.mjs";
7
7
  export { AUTH_PATH, AUTH_ROUTES, AgentGrant, AgentKey, Auth, type AuthCall, AuthError, type AuthErrorCode, type AuthEvent, type AuthEventBatch, type AuthEventType, AuthOptions, type AuthSettings, type AuthStore, AuthUser, AuthUserRecord, type CaptchaProvider, type EventSend, IMPERSONATION_S, type PublicSettings, SESSION_CACHE_S, type SignInMail, type SignInMailKind, type SignUpPolicy, SignedIn, SignedInAgent, auth, authFiles, checkSignInMail, createAuth, databaseStore, signInWords };
package/auth/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as createAuth, i as auth, n as AUTH_ROUTES, o as databaseStore, r as SESSION_CACHE_S, s as AuthError, t as AUTH_PATH } from "../auth-Cq_UKvop.mjs";
1
+ import { a as createAuth, i as auth, n as AUTH_ROUTES, o as databaseStore, r as SESSION_CACHE_S, s as AuthError, t as AUTH_PATH } from "../auth-DauDyrcI.mjs";
2
2
  import { checkSignInMail, signInWords } from "./mail.mjs";
3
- import { n as authFiles } from "../files-ZySaprII.mjs";
3
+ import { n as authFiles } from "../files-BhGkb17f.mjs";
4
4
  import { IMPERSONATION_S } from "./impersonate.mjs";
5
5
  export { AUTH_PATH, AUTH_ROUTES, AuthError, IMPERSONATION_S, SESSION_CACHE_S, auth, authFiles, checkSignInMail, createAuth, databaseStore, signInWords };
package/auth/stand-in.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as authTables } from "../files-ZySaprII.mjs";
1
+ import { r as authTables } from "../files-BhGkb17f.mjs";
2
2
  //#region src/auth/stand-in.ts
3
3
  const text = (value) => typeof value === "string" ? value.toLowerCase() : value;
4
4
  /** Whether one clause holds for a row, as `db/auth.ts` decides it. */
@@ -3,7 +3,7 @@ import { DatabaseError } from "./database/errors.mjs";
3
3
  import { d as userToken, o as connect, s as databaseUrl } from "./client-5gJ-6h4y.mjs";
4
4
  import { CALL_STATUS } from "./calls/protocol.mjs";
5
5
  import { sendSignInMail } from "./auth/mail.mjs";
6
- import "./files-ZySaprII.mjs";
6
+ import "./files-BhGkb17f.mjs";
7
7
  import { standIn } from "./auth/stand-in.mjs";
8
8
  import { a as WORDS, c as deviceOf, i as CAPTCHA_WIDGETS, l as screenName, n as textOn, o as ago, r as GEIST_WOFF2, s as defaultAppName, t as authCss, u as setupKeyOf } from "./style-DXd-0Cxo.mjs";
9
9
  import { _ as challenge, a as leakedPassword, b as remembering, c as refusal, f as mayJoin, g as agentOfKey, i as guard, l as verifyHuman, m as settingsReader, o as ourWords, p as publicSettings, r as REFUSALS, s as rateLimiter, u as JoinRefused, v as consentPage, x as resourceOf, y as credentialOf } from "./guard-VPI6xq4z.mjs";
@@ -60,6 +60,15 @@ declare function schemaUpToDate(schema: string, tables?: Readonly<Record<string,
60
60
  readonly schema: string;
61
61
  readonly added: ReadonlyArray<string>;
62
62
  } | null;
63
+ /**
64
+ * A db/schema.ts of the person's own with sign-in's tables spread into its one `defineSchema({`, first, and their import
65
+ * after its last import (Zander, 11-17: "auth init asks you to paste 22 table entries by hand… have it write ...authTables
66
+ * itself"). Undefined when it has no `defineSchema({`, or more than one, so the caller says where they go instead.
67
+ *
68
+ * withAuthTables('import { defineSchema } from "@midsummer-ai/sdk/server"\nexport default defineSchema({ notes: t })\n')
69
+ * // 'import { defineSchema } from "@midsummer-ai/sdk/server"\nimport { authTables } from "./authTables"\nexport default defineSchema({ ...authTables, notes: t })\n'
70
+ */
71
+ declare function withAuthTables(schema: string): string | undefined;
63
72
  /** The lines db/schema.ts names sign-in's tables with, inside `defineSchema({ ... })`. */
64
73
  declare function schemaLines(tables: Readonly<Record<string, AuthTable>>): string;
65
74
  /**
@@ -83,4 +92,4 @@ declare function authFiles(): {
83
92
  };
84
93
  };
85
94
  //#endregion
86
- export { authTables as a, tablesFile as c, authFiles as i, tablesFromEngine as l, EngineField as n, schemaLines as o, FUNCTIONS_FILE as r, schemaUpToDate as s, AuthTable as t };
95
+ export { authTables as a, tablesFile as c, authFiles as i, tablesFromEngine as l, EngineField as n, schemaLines as o, FUNCTIONS_FILE as r, schemaUpToDate as s, AuthTable as t, withAuthTables as u };
@@ -463,6 +463,27 @@ function schemaUpToDate(schema, tables = authTables()) {
463
463
  added
464
464
  };
465
465
  }
466
+ /**
467
+ * A db/schema.ts of the person's own with sign-in's tables spread into its one `defineSchema({`, first, and their import
468
+ * after its last import (Zander, 11-17: "auth init asks you to paste 22 table entries by hand… have it write ...authTables
469
+ * itself"). Undefined when it has no `defineSchema({`, or more than one, so the caller says where they go instead.
470
+ *
471
+ * withAuthTables('import { defineSchema } from "@midsummer-ai/sdk/server"\nexport default defineSchema({ notes: t })\n')
472
+ * // 'import { defineSchema } from "@midsummer-ai/sdk/server"\nimport { authTables } from "./authTables"\nexport default defineSchema({ ...authTables, notes: t })\n'
473
+ */
474
+ function withAuthTables(schema) {
475
+ const calls = [...schema.matchAll(/defineSchema\(\s*\{/g)];
476
+ if (calls.length !== 1 || calls[0].index === void 0) return void 0;
477
+ const at = calls[0].index + calls[0][0].length;
478
+ const after = schema.slice(at);
479
+ const indent = /^[ \t]*\r?\n([ \t]*)/.exec(after)?.[1];
480
+ const spread = indent !== void 0 ? `\n${indent}...authTables,` : /^\s*\}/.test(after) ? " ...authTables " : " ...authTables,";
481
+ const body = `${schema.slice(0, at)}${spread}${indent !== void 0 || /^\s*\}/.test(after) ? after : after.replace(/^[ \t]*/, " ")}`;
482
+ if (/import\s*\{[^}]*\bauthTables\b[^}]*\}\s*from\s*["']\.\/authTables["']/.test(body)) return body;
483
+ const imports = [...body.matchAll(/^import\s[\s\S]*?["'][^"'\n]+["'];?[^\S\n]*\n/gm)].at(-1);
484
+ const line = "import { authTables } from \"./authTables\"\n";
485
+ return imports?.index === void 0 ? `${line}${body}` : `${body.slice(0, imports.index + imports[0].length)}${line}${body.slice(imports.index + imports[0].length)}`;
486
+ }
466
487
  /** The lines db/schema.ts names sign-in's tables with, inside `defineSchema({ ... })`. */
467
488
  function schemaLines(tables) {
468
489
  return Object.keys(tables).map((name) => `${name}: authTables.${name},`).join(" ");
@@ -777,4 +798,4 @@ function authFiles() {
777
798
  };
778
799
  }
779
800
  //#endregion
780
- export { schemaUpToDate as a, schemaLines as i, authFiles as n, tablesFile as o, authTables as r, tablesFromEngine as s, FUNCTIONS_FILE as t };
801
+ export { schemaUpToDate as a, withAuthTables as c, schemaLines as i, authFiles as n, tablesFile as o, authTables as r, tablesFromEngine as s, FUNCTIONS_FILE as t };
package/here-C2jhTheQ.mjs CHANGED
@@ -12,7 +12,7 @@ function processEnv() {
12
12
  * This package's version: `0.0.0-dev` here, and in a published package the version it was published at, which the
13
13
  * release writes in its place as it stages the package (`stampSdk` in `scripts/release/packages.ts`).
14
14
  */
15
- const SDK_VERSION = "0.1.0-staging.5091";
15
+ const SDK_VERSION = "0.1.0-staging.5109";
16
16
  /**
17
17
  * The header that tells Midsummer which client made each of this package's calls: `Midsummer-Client: sdk/<version>
18
18
  * <part>`, `part` the product whose client it is (`database`, `storage`, `queues`, ...), so the platform counts which
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midsummer-ai/sdk",
3
- "version": "0.1.0-staging.5091",
3
+ "version": "0.1.0-staging.5109",
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.",