@protobase/server 0.130.1 → 0.131.1

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.
Files changed (33) hide show
  1. package/dist/assistant/query-runner/query-module.js +4 -4
  2. package/dist/assistant/query-runner/query-runner.d.ts +1 -1
  3. package/dist/assistant/query-runner/query-runner.js +3 -3
  4. package/dist/auth-store.d.ts +2 -2
  5. package/dist/auth-store.js +3 -3
  6. package/dist/better-auth/auth-schema.d.ts +6 -5
  7. package/dist/better-auth/auth-schema.js +12 -12
  8. package/dist/better-auth/names/modules/auth.js +1 -9
  9. package/dist/better-auth/names/modules/index.d.ts +0 -14
  10. package/dist/better-auth/store/adoption.js +2 -2
  11. package/dist/better-auth/store/legacy-record.d.ts +6 -4
  12. package/dist/better-auth/store/legacy-record.js +13 -32
  13. package/dist/better-auth/store/offline/baseline-store.d.ts +1 -2
  14. package/dist/better-auth/store/offline/baseline-store.js +1 -2
  15. package/dist/better-auth/store/offline/name-changes.d.ts +2 -2
  16. package/dist/better-auth/store/offline/name-changes.js +5 -3
  17. package/dist/better-auth/store/offline/offline-steps.d.ts +2 -2
  18. package/dist/better-auth/store/offline/offline-steps.js +6 -5
  19. package/dist/better-auth/store/steps/auth/006-drop-version-record.js +20 -0
  20. package/dist/better-auth/store/steps/index.d.ts +7 -0
  21. package/dist/better-auth/store/steps/index.js +9 -2
  22. package/dist/better-auth/store/steps/legacy-versions.d.ts +1 -1
  23. package/dist/better-auth/store/steps/legacy-versions.js +5 -1
  24. package/dist/better-auth/store/steps/step-lint.d.ts +6 -1
  25. package/dist/better-auth/store/steps/step-lint.js +2 -1
  26. package/dist/better-auth/store/steps/step.js +28 -3
  27. package/dist/internal.d.ts +3 -2
  28. package/dist/internal.js +4 -3
  29. package/dist/package.js +1 -1
  30. package/dist/schema-modules/feature-schemas-sql.d.ts +1 -1
  31. package/dist/schema-modules/feature-schemas-sql.js +1 -1
  32. package/dist/schema-modules/needed-modules.d.ts +1 -1
  33. package/package.json +7 -7
@@ -17,12 +17,12 @@ const grants = {
17
17
  keptWhileOthers: false
18
18
  };
19
19
  /**
20
- * The role the built-in assistant's read-only queries run as, `<database>_query`, which reads only the resources'
21
- * tables (`queryInput`), and `query.run_read_only`, the runner every query goes through as that role.
20
+ * The role read-only queries run as, `<database>_query`, of the built-in assistant and the MCP endpoint's `sql`, which
21
+ * reads only the resources' tables (`queryInput`), and `query.run_read_only`, the runner every query goes through as that role.
22
22
  */
23
23
  const queryModule = {
24
- label: "the query role of the assistant's read-only queries",
25
- title: "The role the assistant's read-only queries run as, which reads only the resources' tables",
24
+ label: "the query role of read-only queries",
25
+ title: "The role read-only queries run as, which reads only the resources' tables",
26
26
  steps: [{
27
27
  step: 1,
28
28
  name: "role",
@@ -11,7 +11,7 @@ export type GuardedTables = {
11
11
  schemas: readonly string[];
12
12
  };
13
13
  /**
14
- * Refuses to go on while the runner of the assistant's read-only queries, which the record of migrations says is there,
14
+ * Refuses to go on while the runner of read-only queries, which the record of migrations says is there,
15
15
  * does not run as a role weaker than the app's: it is no security definer, or runs as the app's role itself or one it
16
16
  * is a member of, a superuser, a login role, or one that can read an auth table, or while that role may call a
17
17
  * security-definer function that runs as a role able to read one. A migration cannot promise these: they are the live
@@ -5,7 +5,7 @@ import { sql } from "kysely";
5
5
  const rowsOf = async (db, query) => (await query.execute(db)).rows;
6
6
  const guardedRelations = ({ tables, schemas }) => sql`select c.oid, c.relnamespace from pg_class c join pg_namespace n on n.oid = c.relnamespace
7
7
  where c.oid in (select to_regclass(t.name) from unnest(${tables.map(regclassText)}::text[]) as t(name)) or n.nspname = any(${[...schemas]}::text[])`;
8
- const refusal = (state) => /* @__PURE__ */ new Error(`The query role of the assistant's read-only queries ${state}. Take back by hand what it was given, then start again.`);
8
+ const refusal = (state) => /* @__PURE__ */ new Error(`The query role of read-only queries ${state}. Take back by hand what it was given, then start again.`);
9
9
  const leakingFunctions = (db, authTables) => rowsOf(db, sql`with runner as (select proowner as role from pg_proc where oid = to_regprocedure(${queryRunnerSignature}))
10
10
  select format('%I.%I(%s)', n.nspname, p.proname, pg_get_function_identity_arguments(p.oid)) as name
11
11
  from pg_proc p join pg_namespace n on n.oid = p.pronamespace, runner
@@ -15,7 +15,7 @@ const leakingFunctions = (db, authTables) => rowsOf(db, sql`with runner as (sele
15
15
  where has_schema_privilege(p.proowner, c.relnamespace, 'USAGE') and has_any_column_privilege(p.proowner, c.oid, 'SELECT'))
16
16
  order by 1`);
17
17
  /**
18
- * Refuses to go on while the runner of the assistant's read-only queries, which the record of migrations says is there,
18
+ * Refuses to go on while the runner of read-only queries, which the record of migrations says is there,
19
19
  * does not run as a role weaker than the app's: it is no security definer, or runs as the app's role itself or one it
20
20
  * is a member of, a superuser, a login role, or one that can read an auth table, or while that role may call a
21
21
  * security-definer function that runs as a role able to read one. A migration cannot promise these: they are the live
@@ -35,7 +35,7 @@ const checkQueryRoleSafety = async (db, authTables) => {
35
35
  if (runner.reads_auth) throw refusal("can read the auth schema");
36
36
  const leaking = await leakingFunctions(db, authTables);
37
37
  if (leaking.length === 0) return;
38
- throw new Error(`The query role of the assistant's read-only queries can read the auth schema through the security-definer functions ${leaking.map((found) => found.name).join(", ")}. Revoke execute on them from PUBLIC, or move them to a schema without a resource, then start again.`);
38
+ throw new Error(`The query role of read-only queries can read the auth schema through the security-definer functions ${leaking.map((found) => found.name).join(", ")}. Revoke execute on them from PUBLIC, or move them to a schema without a resource, then start again.`);
39
39
  };
40
40
  //#endregion
41
41
  export { checkQueryRoleSafety };
@@ -1,6 +1,6 @@
1
1
  //#region src/auth-store.d.ts
2
2
  /** The store's tables besides the user table, under their built-in names. */
3
3
  export declare const storeTableNames: string[];
4
- /** The records of the store's steps, `auth_steps`, and of the versions a store recorded before it, under their built-in names. */
5
- export declare const storeRecordNames: string[];
4
+ /** The record of the store's steps, `auth_steps`, under its built-in name. */
5
+ export declare const storeRecordName: string;
6
6
  //#endregion
@@ -3,7 +3,7 @@ import { storeTableNamesOf } from "./better-auth/store/table-names.js";
3
3
  //#region src/auth-store.ts
4
4
  /** The store's tables besides the user table, under their built-in names. */
5
5
  const storeTableNames = storeTableNamesOf(resolveNames({ schema: void 0 }));
6
- /** The records of the store's steps, `auth_steps`, and of the versions a store recorded before it, under their built-in names. */
7
- const storeRecordNames = [resolveNames({ schema: void 0 }).table("auth_steps").name, resolveNames({ schema: void 0 }).table("auth_migrations").name];
6
+ /** The record of the store's steps, `auth_steps`, under its built-in name. */
7
+ const storeRecordName = resolveNames({ schema: void 0 }).table("auth_steps").name;
8
8
  //#endregion
9
- export { storeRecordNames, storeTableNames };
9
+ export { storeRecordName, storeTableNames };
@@ -5,15 +5,16 @@ import "../internal.js";
5
5
  /**
6
6
  * The SQL that brings the admin store to this version of Protobase: the parts of the modules that are on it has not
7
7
  * applied, each followed by its row in `auth_steps`; for a store without that table, the table first. A store that
8
- * recorded versions of the former chain in `auth_migrations` gets its parts recorded from them; one an earlier
9
- * Protobase made without any record is adopted: the versions it matches are recorded as applied (`planAdoption`), the
10
- * others' steps follow. `undefined` when the store is current. The SQL never drops anything.
8
+ * records versions of the former chain instead is refused (`refuseVersionRecord`); one an earlier Protobase made
9
+ * without any record is adopted: the versions it matches are recorded as applied (`planAdoption`), the
10
+ * others' steps follow. `undefined` when the store is current. The SQL drops nothing but the former record of versions
11
+ * (`steps/auth/006-drop-version-record.ts`).
11
12
  */
12
13
  export declare const authSchemaMigration: (auth: AdminAuth) => Promise<string | undefined>;
13
14
  /**
14
15
  * The modules the config turns off whose steps the store has, each at its last step, which a project's first snapshot
15
- * keeps: the store has their tables. Read from `auth_steps`, or from `auth_migrations`, or for a store with neither,
16
- * from the versions its adoption finds it has.
16
+ * keeps: the store has their tables. Read from `auth_steps`, or for a store without any record, from the versions its
17
+ * adoption finds it has; a store that records versions instead is refused.
17
18
  */
18
19
  export declare const keptStoreModules: (auth: AdminAuth) => Promise<KeptModule[]>;
19
20
  //#endregion
@@ -1,13 +1,13 @@
1
1
  import { allModules } from "./names/modules-on.js";
2
2
  import { storeNames } from "./store/store-names.js";
3
3
  import { plainStoreDb } from "./store/store-db.js";
4
+ import { migrationNames, organizationsInput } from "./store/steps/step.js";
4
5
  import { appliedSteps, hadOf } from "./store/step-record.js";
5
6
  import { keptModule } from "./store/offline/store-model.js";
6
7
  import { recordedSteps } from "./store/offline/baseline-store.js";
7
- import { stepRecordSql, stepsSql } from "./store/migration-sql.js";
8
8
  import { renderSteps } from "./store/steps/render.js";
9
- import { appliedVersions, stepRecordMigration, stepsOfVersions } from "./store/legacy-record.js";
10
- import { migrationNames, organizationsInput } from "./store/steps/step.js";
9
+ import { refuseVersionRecord, stepsOfVersions } from "./store/legacy-record.js";
10
+ import { stepRecordSql, stepsSql } from "./store/migration-sql.js";
11
11
  import { adoptionSql, planAdoption, storeHasTables } from "./store/adoption.js";
12
12
  //#region src/better-auth/auth-schema.ts
13
13
  const pendingSql = (auth, names, had) => {
@@ -17,18 +17,18 @@ const pendingSql = (auth, names, had) => {
17
17
  /**
18
18
  * The SQL that brings the admin store to this version of Protobase: the parts of the modules that are on it has not
19
19
  * applied, each followed by its row in `auth_steps`; for a store without that table, the table first. A store that
20
- * recorded versions of the former chain in `auth_migrations` gets its parts recorded from them; one an earlier
21
- * Protobase made without any record is adopted: the versions it matches are recorded as applied (`planAdoption`), the
22
- * others' steps follow. `undefined` when the store is current. The SQL never drops anything.
20
+ * records versions of the former chain instead is refused (`refuseVersionRecord`); one an earlier Protobase made
21
+ * without any record is adopted: the versions it matches are recorded as applied (`planAdoption`), the
22
+ * others' steps follow. `undefined` when the store is current. The SQL drops nothing but the former record of versions
23
+ * (`steps/auth/006-drop-version-record.ts`).
23
24
  */
24
25
  const authSchemaMigration = async (auth) => {
25
26
  const names = storeNames(auth);
26
27
  const db = plainStoreDb(auth);
27
28
  const applied = await appliedSteps(db, names);
28
29
  if (applied !== void 0) return pendingSql(auth, names, hadOf(applied))[0];
30
+ await refuseVersionRecord(db, names);
29
31
  const record = stepRecordSql(names);
30
- const versions = await appliedVersions(db, names);
31
- if (versions !== void 0) return [stepRecordMigration(names), ...pendingSql(auth, names, hadOf(stepsOfVersions(versions)))].join("\n\n");
32
32
  if (!await storeHasTables(db, names)) return [record, ...pendingSql(auth, names, hadOf([]))].join("\n\n");
33
33
  const { adopted, pending } = await planAdoption(db, names);
34
34
  const rest = pending.length === 0 ? [] : pendingSql(auth, names, hadOf(stepsOfVersions(adopted.map(({ migration }) => migration.version))));
@@ -41,15 +41,15 @@ const authSchemaMigration = async (auth) => {
41
41
  const adoptedVersions = async (db, names) => await storeHasTables(db, names) ? (await planAdoption(db, names)).adopted.map(({ migration }) => migration.version) : [];
42
42
  /**
43
43
  * The modules the config turns off whose steps the store has, each at its last step, which a project's first snapshot
44
- * keeps: the store has their tables. Read from `auth_steps`, or from `auth_migrations`, or for a store with neither,
45
- * from the versions its adoption finds it has.
44
+ * keeps: the store has their tables. Read from `auth_steps`, or for a store without any record, from the versions its
45
+ * adoption finds it has; a store that records versions instead is refused.
46
46
  */
47
47
  const keptStoreModules = async (auth) => {
48
48
  const names = storeNames(auth);
49
49
  const db = plainStoreDb(auth);
50
50
  const steps = await appliedSteps(db, names);
51
- const versions = steps === void 0 ? await appliedVersions(db, names) ?? await adoptedVersions(db, names) : void 0;
52
- const applied = steps ?? stepsOfVersions(versions ?? []);
51
+ if (steps === void 0) await refuseVersionRecord(db, names);
52
+ const applied = steps ?? stepsOfVersions(await adoptedVersions(db, names));
53
53
  const recorded = recordedSteps(applied);
54
54
  return allModules.filter((module) => !names.names.modules.includes(module) && recorded[module] !== void 0).map((module) => keptModule(names, module, recorded[module]));
55
55
  };
@@ -1,6 +1,6 @@
1
1
  import { field, own } from "../declaration.js";
2
2
  //#region src/better-auth/names/modules/auth.ts
3
- /** Sign-in itself: users, with their roles and bans, sessions, accounts, codes, the token signing keys and the record of migrations. */
3
+ /** Sign-in itself: users, with their roles and bans, sessions, accounts, codes, the token signing keys and the record of its steps. */
4
4
  const auth = {
5
5
  id: "auth",
6
6
  requires: [],
@@ -109,14 +109,6 @@ const auth = {
109
109
  crv: field("crv")
110
110
  }
111
111
  },
112
- auth_migrations: {
113
- scope: "global",
114
- columns: {
115
- version: field("version"),
116
- name: field("name"),
117
- applied_at: field("appliedAt")
118
- }
119
- },
120
112
  auth_steps: {
121
113
  scope: "global",
122
114
  columns: {
@@ -194,20 +194,6 @@ export declare const builtInModules: readonly [{
194
194
  };
195
195
  };
196
196
  };
197
- readonly auth_migrations: {
198
- readonly scope: "global";
199
- readonly columns: {
200
- readonly version: {
201
- field: "version";
202
- };
203
- readonly name: {
204
- field: "name";
205
- };
206
- readonly applied_at: {
207
- field: "appliedAt";
208
- };
209
- };
210
- };
211
197
  readonly auth_steps: {
212
198
  readonly scope: "global";
213
199
  readonly columns: {
@@ -1,13 +1,13 @@
1
1
  import { allModules } from "../names/modules-on.js";
2
2
  import { resolveNames } from "../names/resolve-names.js";
3
3
  import { ddl } from "./ddl.js";
4
+ import { migrationNames } from "./steps/step.js";
4
5
  import { moduleSteps } from "./steps/index.js";
5
6
  import { recordSteps } from "./step-record.js";
6
- import { statementsSql } from "./migration-sql.js";
7
7
  import { legacyVersions } from "./steps/legacy-versions.js";
8
8
  import { renderSteps } from "./steps/render.js";
9
9
  import { stepsOfVersions } from "./legacy-record.js";
10
- import { migrationNames } from "./steps/step.js";
10
+ import { statementsSql } from "./migration-sql.js";
11
11
  import { sql } from "kysely";
12
12
  //#region src/better-auth/store/adoption.ts
13
13
  const key = ({ table, column }) => `${table}.${column}`;
@@ -1,10 +1,12 @@
1
- import "../names/resolve-names.js";
1
+ import { TableId } from "../names/identifiers.js";
2
2
  import { StoreNames } from "./store-names.js";
3
3
  import { AppliedStep } from "./step-record.js";
4
4
  import { Kysely } from "kysely";
5
5
  //#region src/better-auth/store/legacy-record.d.ts
6
- /** The parts the store applied, from the versions it recorded: every part of each version. */
6
+ /** The parts the store applied, from the versions it has: every part of each version. */
7
7
  export declare const stepsOfVersions: (versions: readonly number[]) => AppliedStep[];
8
- /** The record of the store's steps, made when it is missing and filled from `auth_migrations`, for a store that recorded versions. */
9
- export declare const stepRecordMigration: (names: StoreNames) => string;
8
+ /** The former record of versions, in the store's schema, as the store's names named it. */
9
+ export declare const versionRecordTable: (names: StoreNames) => TableId;
10
+ /** Why a store that records its migrations by version alone, in `table`, is refused, and how to bring it on. */
11
+ export declare const versionRecordRefusal: (table: string) => string;
10
12
  //#endregion
@@ -1,14 +1,11 @@
1
1
  import { allModules } from "../names/modules-on.js";
2
- import { ddl } from "./ddl.js";
2
+ import { versionRecord } from "./steps/auth/006-drop-version-record.js";
3
+ import { migrationNames } from "./steps/step.js";
3
4
  import { moduleSteps } from "./steps/index.js";
4
- import { stepRecordTable } from "./step-record.js";
5
- import { guardedBlock, stepRecordSql } from "./migration-sql.js";
6
5
  import { latestStoreVersion } from "./steps/legacy-versions.js";
7
6
  import { partVersion } from "./steps/render.js";
8
7
  import { sql } from "kysely";
9
8
  //#region src/better-auth/store/legacy-record.ts
10
- /** The table, in the store's schema, as the store's names resolve `auth_migrations`. */
11
- const legacyRecordTable = ({ names }) => names.table("auth_migrations");
12
9
  /** Every part of every step with the version of the former chain that made it, as that chain made them, every module on. */
13
10
  const legacyParts = () => allModules.flatMap((module) => moduleSteps[module].flatMap((step) => [module, ...allModules.filter((target) => step.adds?.[target])].map((target) => ({
14
11
  module,
@@ -16,41 +13,25 @@ const legacyParts = () => allModules.flatMap((module) => moduleSteps[module].fla
16
13
  target,
17
14
  version: partVersion(module, step, target)
18
15
  }))));
19
- /** The parts the store applied, from the versions it recorded: every part of each version. */
16
+ /** The parts the store applied, from the versions it has: every part of each version. */
20
17
  const stepsOfVersions = (versions) => {
21
18
  const newer = versions.filter((version) => version > latestStoreVersion);
22
- if (newer.length > 0) throw new Error(`The auth store records version ${newer.join(", ")} in auth_migrations, which this version of Protobase does not ship; upgrade Protobase`);
19
+ if (newer.length > 0) throw new Error(`The auth store has version ${newer.join(", ")}, which this version of Protobase does not ship; upgrade Protobase`);
23
20
  return legacyParts().filter((part) => versions.includes(part.version)).map(({ module, step, target }) => ({
24
21
  module,
25
22
  step,
26
23
  target
27
24
  }));
28
25
  };
29
- /** The versions the store recorded, in order; `undefined` when it has no `auth_migrations`. */
30
- const appliedVersions = async (db, names) => {
31
- const table = legacyRecordTable(names);
26
+ /** The former record of versions, in the store's schema, as the store's names named it. */
27
+ const versionRecordTable = (names) => migrationNames(names).former(versionRecord);
28
+ /** Why a store that records its migrations by version alone, in `table`, is refused, and how to bring it on. */
29
+ const versionRecordRefusal = (table) => `The auth store records its migrations by version in ${table}, without auth_steps, as a Protobase before 0.130 left it: bring the project to Protobase 0.130 first, write and apply its migration with that version's \`protobase migration\` and \`protobase migrate\`, then run this again`;
30
+ /** Refuses a store without `auth_steps` that has the former record of versions. */
31
+ const refuseVersionRecord = async (db, names) => {
32
+ const table = versionRecordTable(names);
32
33
  const [found] = (await sql`select to_regclass(${String(table)}) is not null as found`.execute(db)).rows;
33
- if (!found?.found) return;
34
- const { version } = table.columns;
35
- return (await sql`select ${version} as version from ${table} order by ${version}`.execute(db)).rows.map((row) => row.version);
34
+ if (found?.found) throw new Error(versionRecordRefusal(table.name));
36
35
  };
37
- /**
38
- * The statement that fills `auth_steps` from `auth_migrations`, once that table is there: every part of each version
39
- * it records, at the time it recorded it. A part recorded already is left as it is.
40
- */
41
- const fillFromLegacySql = (names) => {
42
- const legacy = legacyRecordTable(names);
43
- const steps = stepRecordTable(names);
44
- const { module, step, target, applied_at } = steps.columns;
45
- const parts = legacyParts().map((part) => ddl`(${sql.lit(part.module)}, ${sql.lit(part.step)}, ${sql.lit(part.target)}, ${sql.lit(part.version)})`);
46
- const fill = ddl`insert into ${steps} (${module}, ${step}, ${target}, ${applied_at})
47
- select part.module, part.step, part.target, legacy.${legacy.columns.applied_at}
48
- from (values ${sql.join(parts, sql`, `)}) as part (module, step, target, version)
49
- join ${legacy} legacy on legacy.${legacy.columns.version} = part.version
50
- on conflict do nothing`;
51
- return `-- The steps the store recorded by version in ${legacy.name}, recorded by step.\n${guardedBlock(ddl`to_regclass(${sql.lit(String(legacy))}) is not null`, [fill])}`;
52
- };
53
- /** The record of the store's steps, made when it is missing and filled from `auth_migrations`, for a store that recorded versions. */
54
- const stepRecordMigration = (names) => [stepRecordSql(names), fillFromLegacySql(names)].join("\n\n");
55
36
  //#endregion
56
- export { appliedVersions, fillFromLegacySql, legacyParts, legacyRecordTable, stepRecordMigration, stepsOfVersions };
37
+ export { legacyParts, refuseVersionRecord, stepsOfVersions, versionRecordRefusal, versionRecordTable };
@@ -14,14 +14,13 @@ export type LiveStore = {
14
14
  };
15
15
  /**
16
16
  * What the store is: each module's last step, the modules off that have tables, whether organizations were ever on,
17
- * the relations Protobase did not make, and whether it has `auth_steps`.
17
+ * and the relations Protobase did not make.
18
18
  */
19
19
  export type BaselineStore = {
20
20
  lastSteps: LastSteps;
21
21
  kept: KeptModule[];
22
22
  organizationsEverOn: boolean;
23
23
  external: string[];
24
- stepRecord: boolean;
25
24
  };
26
25
  /**
27
26
  * The store at `live` under the config's `names`: each module that is on at the step the record holds, every module
@@ -57,8 +57,7 @@ const baselineStore = (names, live) => {
57
57
  lastSteps,
58
58
  kept,
59
59
  organizationsEverOn,
60
- external: externalUser ? [`${prefix}${user.name}`] : [],
61
- stepRecord: has("auth_steps")
60
+ external: externalUser ? [`${prefix}${user.name}`] : []
62
61
  };
63
62
  };
64
63
  //#endregion
@@ -1,8 +1,8 @@
1
1
  import { StoreModel } from "./store-model.js";
2
2
  //#region src/better-auth/store/offline/name-changes.d.ts
3
3
  /**
4
- * How `after` changes what `before`, from `source`, has, one line each, the last steps and the tables' scopes aside:
5
- * a scope is Protobase's to declare, not a name the store has; none when it only adds.
4
+ * How `after` changes what `before`, from `source`, has, one line each, the last steps, the tables' scopes and the
5
+ * tables a step drops aside: a scope is Protobase's to declare, not a name the store has; none when it only adds.
6
6
  */
7
7
  export declare const nameChanges: (before: StoreModel, after: StoreModel, source?: string) => string[];
8
8
  //#endregion
@@ -1,3 +1,4 @@
1
+ import { droppedTables } from "../steps/index.js";
1
2
  //#region src/better-auth/store/offline/name-changes.ts
2
3
  const changes = (before, after, at, source) => {
3
4
  if (after === void 0) return [`${at} is gone`];
@@ -5,13 +6,14 @@ const changes = (before, after, at, source) => {
5
6
  return Object.entries(before).flatMap(([key, value]) => changes(value, after[key], at === "" ? key : `${at}.${key}`, source));
6
7
  };
7
8
  /**
8
- * How `after` changes what `before`, from `source`, has, one line each, the last steps and the tables' scopes aside:
9
- * a scope is Protobase's to declare, not a name the store has; none when it only adds.
9
+ * How `after` changes what `before`, from `source`, has, one line each, the last steps, the tables' scopes and the
10
+ * tables a step drops aside: a scope is Protobase's to declare, not a name the store has; none when it only adds.
10
11
  */
11
12
  const nameChanges = (before, after, source = "the snapshot") => {
13
+ const kept = (tables) => Object.entries(tables).filter(([internal]) => !droppedTables.includes(internal));
12
14
  const withoutSteps = (model) => ({
13
15
  ...model,
14
- modules: Object.fromEntries(Object.entries(model.modules).map(([module, entry]) => [module, Object.fromEntries(Object.entries(entry.tables).map(([internal, { scope: _, ...table }]) => [internal, table]))]))
16
+ modules: Object.fromEntries(Object.entries(model.modules).map(([module, entry]) => [module, Object.fromEntries(kept(entry.tables).map(([internal, { scope: _, ...table }]) => [internal, table]))]))
15
17
  });
16
18
  return changes(withoutSteps(before), withoutSteps(after), "", source);
17
19
  };
@@ -5,7 +5,7 @@ import { LastSteps } from "./store-model.js";
5
5
  //#region src/better-auth/store/offline/offline-steps.d.ts
6
6
  /**
7
7
  * The store as a project's snapshot has it: each module's last step, those kept while off included; the modules that
8
- * are on; and whether it has `auth_steps`, which a store a version before it made lacks.
8
+ * are on; and whether it has `auth_steps`, which a store a Protobase before 0.130 made lacks.
9
9
  */
10
10
  export type SnapshotStore = {
11
11
  lastSteps: LastSteps;
@@ -15,7 +15,7 @@ export type SnapshotStore = {
15
15
  /**
16
16
  * The parts of the modules that are on that the snapshot's store lacks, each followed by its row in `auth_steps`, each
17
17
  * run only while that table lacks it, so a database that has it already skips it; for a store the snapshot has none of
18
- * (`store` undefined), that table first, and for one without it, that table, filled from `auth_migrations`. `checks`:
18
+ * (`store` undefined), that table first; one without it, which records versions instead, is refused. `checks`:
19
19
  * the checks of the parts on tables the store has already, which refuse when its rows break what a step assumes;
20
20
  * `after`, what the parts leave for the migration's `.after.sql`, when they leave anything. `undefined` when the
21
21
  * snapshot's store has every part. `externalUser`: the snapshot records the user table as a relation Protobase did
@@ -1,8 +1,8 @@
1
+ import { migrationNames } from "../steps/step.js";
1
2
  import { moduleSteps } from "../steps/index.js";
2
- import { afterStepsSql, guardedStepsSql, statementsSql, stepRecordSql } from "../migration-sql.js";
3
3
  import { renderSteps } from "../steps/render.js";
4
- import { stepRecordMigration } from "../legacy-record.js";
5
- import { migrationNames } from "../steps/step.js";
4
+ import { versionRecordRefusal, versionRecordTable } from "../legacy-record.js";
5
+ import { afterStepsSql, guardedStepsSql, statementsSql, stepRecordSql } from "../migration-sql.js";
6
6
  //#region src/better-auth/store/offline/offline-steps.ts
7
7
  const refuseNewer = (lastSteps) => {
8
8
  for (const [module, last] of Object.entries(lastSteps)) {
@@ -19,7 +19,7 @@ const snapshotHad = ({ lastSteps, on }) => (module, step, target) => step <= (la
19
19
  /**
20
20
  * The parts of the modules that are on that the snapshot's store lacks, each followed by its row in `auth_steps`, each
21
21
  * run only while that table lacks it, so a database that has it already skips it; for a store the snapshot has none of
22
- * (`store` undefined), that table first, and for one without it, that table, filled from `auth_migrations`. `checks`:
22
+ * (`store` undefined), that table first; one without it, which records versions instead, is refused. `checks`:
23
23
  * the checks of the parts on tables the store has already, which refuse when its rows break what a step assumes;
24
24
  * `after`, what the parts leave for the migration's `.after.sql`, when they leave anything. `undefined` when the
25
25
  * snapshot's store has every part. `externalUser`: the snapshot records the user table as a relation Protobase did
@@ -28,10 +28,11 @@ const snapshotHad = ({ lastSteps, on }) => (module, step, target) => step <= (la
28
28
  */
29
29
  const offlineStepsMigration = (names, store, organizations, externalUser = false) => {
30
30
  if (store) refuseNewer(store.lastSteps);
31
+ if (store && !store.stepRecord) throw new Error(versionRecordRefusal(versionRecordTable(names).name));
31
32
  const had = store ? snapshotHad(store) : () => false;
32
33
  const migration = migrationNames(names, externalUser || names.users.keyTable !== void 0);
33
34
  const rendered = renderSteps(migration, names.names.modules, had, organizations);
34
- const record = !store ? [stepRecordSql(names)] : store.stepRecord ? [] : [stepRecordMigration(names)];
35
+ const record = store ? [] : [stepRecordSql(names)];
35
36
  if (rendered.length === 0 && record.length === 0) return;
36
37
  const steps = rendered.length === 0 ? [] : [guardedStepsSql(names, rendered)];
37
38
  const onTablesThere = ({ module, on = module }) => had(on, moduleSteps[on][0].step, on);
@@ -0,0 +1,20 @@
1
+ import { ddl } from "../../ddl.js";
2
+ //#region src/better-auth/store/steps/auth/006-drop-version-record.ts
3
+ /** The record of versions a store kept before `auth_steps`, by its built-in name, which nothing reads any more. */
4
+ const versionRecord = "auth_migrations";
5
+ /**
6
+ * The drop of the record of versions, once `auth_steps` holds every step it recorded: the migrations of Protobase 0.130
7
+ * filled `auth_steps` from it, so the store keeps one record of its steps. The one step that drops a table, which the
8
+ * step lint allows it alone (`drops`).
9
+ */
10
+ const dropVersionRecord = {
11
+ step: 6,
12
+ version: 19,
13
+ name: "drop_version_record",
14
+ title: "The drop of the former record of versions, which auth_steps replaced",
15
+ tables: [],
16
+ drops: [versionRecord],
17
+ statements: ({ former }) => [ddl`drop table if exists ${former(versionRecord)}`]
18
+ };
19
+ //#endregion
20
+ export { dropVersionRecord, versionRecord };
@@ -0,0 +1,7 @@
1
+ import "../../names/modules/index.js";
2
+ import { StoreNames } from "../store-names.js";
3
+ import "./step.js";
4
+ //#region src/better-auth/store/steps/index.d.ts
5
+ /** Those tables as the store's names name them, as SQL text: no older code reads them, so their drop takes nothing from it. */
6
+ export declare const droppedTableIds: (names: StoreNames) => string[];
7
+ //#endregion
@@ -3,6 +3,7 @@ import { accountKeys } from "./auth/002-account-keys.js";
3
3
  import { userIndexes } from "./auth/003-user-indexes.js";
4
4
  import { verificationPatternIndex } from "./auth/004-verification-pattern-index.js";
5
5
  import { userNameSearch } from "./auth/005-user-name-search.js";
6
+ import { dropVersionRecord } from "./auth/006-drop-version-record.js";
6
7
  import { mailSenders } from "./mail-senders/001-mail-senders.js";
7
8
  import { mailSenderNames } from "./mail-senders/002-mail-sender-names.js";
8
9
  import { senderAddressEvidence } from "./mail-senders/003-sender-address-evidence.js";
@@ -20,6 +21,7 @@ import { signInPolicy } from "./sign-in-policy/001-sign-in-policy.js";
20
21
  import { staffSignIn } from "./staff-sign-in/001-staff-sign-in.js";
21
22
  import { staffSignInIndexes } from "./staff-sign-in/002-staff-sign-in-indexes.js";
22
23
  import { twoFactor } from "./two-factor/001-two-factor.js";
24
+ import { migrationNames } from "./step.js";
23
25
  //#region src/better-auth/store/steps/index.ts
24
26
  /** Each module's chain of steps, the only source of its tables: a new step goes last in its module's chain, with the next number. */
25
27
  const moduleSteps = {
@@ -28,7 +30,8 @@ const moduleSteps = {
28
30
  accountKeys,
29
31
  userIndexes,
30
32
  verificationPatternIndex,
31
- userNameSearch
33
+ userNameSearch,
34
+ dropVersionRecord
32
35
  ],
33
36
  two_factor: [twoFactor],
34
37
  passkeys: [passkeys, rpIdIndex],
@@ -50,5 +53,9 @@ const moduleSteps = {
50
53
  ],
51
54
  platform_devices: [platformDevices]
52
55
  };
56
+ /** The tables a step drops, by internal name, which no module declares any more. */
57
+ const droppedTables = Object.values(moduleSteps).flatMap((steps) => steps.flatMap((step) => step.drops ?? []));
58
+ /** Those tables as the store's names name them, as SQL text: no older code reads them, so their drop takes nothing from it. */
59
+ const droppedTableIds = (names) => droppedTables.map((internal) => String(migrationNames(names).former(internal)));
53
60
  //#endregion
54
- export { moduleSteps };
61
+ export { droppedTableIds, droppedTables, moduleSteps };
@@ -1,5 +1,5 @@
1
1
  //#region src/better-auth/store/steps/legacy-versions.d.ts
2
- /** Each version with the name its row in `auth_migrations` holds. */
2
+ /** Each version with its name. */
3
3
  export declare const legacyVersions: {
4
4
  version: number;
5
5
  name: string;
@@ -1,5 +1,5 @@
1
1
  //#region src/better-auth/store/steps/legacy-versions.ts
2
- /** Each version with the name its row in `auth_migrations` holds. */
2
+ /** Each version with its name. */
3
3
  const legacyVersions = [
4
4
  {
5
5
  version: 1,
@@ -72,6 +72,10 @@ const legacyVersions = [
72
72
  {
73
73
  version: 18,
74
74
  name: "default_organization"
75
+ },
76
+ {
77
+ version: 19,
78
+ name: "drop_version_record"
75
79
  }
76
80
  ];
77
81
  /** The version the store is at once every step is applied. */
@@ -7,12 +7,17 @@ export declare const contractingRules: string[];
7
7
  * migrations run in one transaction while nothing else writes.
8
8
  */
9
9
  export declare const lockingRules: string[];
10
- /** A rendered step: `made`, the tables it makes as its SQL names them; `checked`, whether it starts with a check. */
10
+ /**
11
+ * A rendered step: `made`, the tables it makes as its SQL names them; `checked`, whether it starts with a check;
12
+ * `drops`, whether it is a step that drops a table Protobase no longer declares (`Step.drops`), the reviewed exception
13
+ * to `ban-drop-table`.
14
+ */
11
15
  export type LintedStep = {
12
16
  label: string;
13
17
  sql: string;
14
18
  made: string[];
15
19
  checked: boolean;
20
+ drops?: boolean;
16
21
  };
17
22
  export type StepFinding = {
18
23
  step: string;
@@ -60,7 +60,8 @@ const squawkReport = (steps, squawk = createRequire(import.meta.url).resolve("sq
60
60
  line: finding.line
61
61
  }));
62
62
  };
63
- const squawkFindings = (steps, squawk) => squawkReport(steps, squawk).filter((finding) => refusedRules.includes(finding.rule)).map(({ step, rule, message }) => ({
63
+ const reviewedDrop = (steps, finding) => finding.rule === "ban-drop-table" && steps.some((step) => step.label === finding.step && step.drops);
64
+ const squawkFindings = (steps, squawk) => squawkReport(steps, squawk).filter((finding) => refusedRules.includes(finding.rule) && !reviewedDrop(steps, finding)).map(({ step, rule, message }) => ({
64
65
  step,
65
66
  rule,
66
67
  message
@@ -1,4 +1,6 @@
1
1
  import { tableId } from "../../names/identifiers.js";
2
+ import { allModules } from "../../names/modules-on.js";
3
+ import { resolveNames, tableNameOf } from "../../names/resolve-names.js";
2
4
  import { sql } from "kysely";
3
5
  //#region src/better-auth/store/steps/step.ts
4
6
  /** The organizations' input of the steps from their settings; `undefined` without a default organization. */
@@ -7,17 +9,40 @@ const organizationsInput = (settings) => settings?.default ? {
7
9
  existingUsersRole: settings.existingUsersRole
8
10
  } : void 0;
9
11
  /**
12
+ * A table Protobase no longer declares, as `former` names it. Refuses when a table the config names, of a module on or
13
+ * off, or the user key table in the store's schema has that name, so a step that drops it never drops a table in use.
14
+ */
15
+ const formerTable = ({ schema, names, users }, internal) => {
16
+ const id = tableId(schema, tableNameOf(names.input.tables ?? {}, internal));
17
+ const every = resolveNames({
18
+ ...names.input,
19
+ modules: allModules
20
+ });
21
+ const taken = Object.values(every.tables).find((table) => table.name === id.name);
22
+ const keyTable = users.keyTable && users.keyTable.schema === schema && users.keyTable.table === id.name;
23
+ if (taken || keyTable) {
24
+ const which = taken ? `${taken.internal} table` : "users.keyTable table";
25
+ throw new Error(`The auth store's ${which} is named ${id.name}, the name of the former ${internal} table that a step drops: give it another name in the config`);
26
+ }
27
+ return id;
28
+ };
29
+ /**
10
30
  * The `ddl` parts of the store's names. `externalUser`: the user table is a relation Protobase did not make, which its
11
31
  * statements leave alone, as under `users.keyTable` or as a project's snapshot records it.
12
32
  */
13
- const migrationNames = ({ names, users, uuidIds }, externalUser = users.keyTable !== void 0) => ({
33
+ const migrationNames = ({ schema, names, users, uuidIds }, externalUser = users.keyTable !== void 0) => ({
14
34
  table: names.table,
15
35
  user: users.keyTable ? tableId(users.keyTable.schema, users.keyTable.table) : names.table("user"),
16
36
  userDdl: (statements) => externalUser ? [] : statements,
17
37
  externalUser,
18
38
  metadata: users.metadata,
19
39
  id: sql.raw(uuidIds ? "uuid default pg_catalog.gen_random_uuid()" : "text"),
20
- idRef: sql.raw(uuidIds ? "uuid" : "text")
40
+ idRef: sql.raw(uuidIds ? "uuid" : "text"),
41
+ former: (internal) => formerTable({
42
+ schema,
43
+ names,
44
+ users
45
+ }, internal)
21
46
  });
22
47
  //#endregion
23
- export { migrationNames, organizationsInput };
48
+ export { formerTable, migrationNames, organizationsInput };
@@ -39,7 +39,8 @@ import { restoredKeysSql } from "./better-auth/store/offline/archive-revival.js"
39
39
  import { bucketsCommentPrefix } from "./computed/buckets-sql.js";
40
40
  import { AppliedStep } from "./better-auth/store/step-record.js";
41
41
  import { LiveStore, baselineStore } from "./better-auth/store/offline/baseline-store.js";
42
- import { stepRecordMigration, stepsOfVersions } from "./better-auth/store/legacy-record.js";
42
+ import { stepsOfVersions, versionRecordRefusal, versionRecordTable } from "./better-auth/store/legacy-record.js";
43
+ import { droppedTableIds } from "./better-auth/store/steps/index.js";
43
44
  import { legacyVersions } from "./better-auth/store/steps/legacy-versions.js";
44
45
  import { LintedStep, SquawkFinding, contractingRules, lintSteps, lockingRules, squawkReport } from "./better-auth/store/steps/step-lint.js";
45
46
  import { contractingSql } from "./migration-sql/additive-statements.js";
@@ -51,4 +52,4 @@ import { recordsRuntimeModel } from "./migration-record/check-record.js";
51
52
  import { plainStoreDb } from "./better-auth/store/store-db.js";
52
53
  import { moduleDifference, retiredDifference } from "./schema-modules/module-difference.js";
53
54
  import { keptStoreModules } from "./better-auth/auth-schema.js";
54
- export { type AfterIndex, type AppAuthInput, type AppliedStep, type ArchivedModule, type AuthPlugins, type DeferredOff, type KeptModule, type LastSteps, type LintedStep, type LiveStore, type ModuleId, type ModuleInput, type ModuleModel, type ModuleTargets, type ModulesModel, type OffChoice, type OrganizationsInput, type RecordModel, type RetiredName, type SchemaModule, type SchemaModuleId, type SignedOff, type SnapshotStore, type SquawkFinding, type StepRecord, type StoreModel, type StoreNames, appAuthOptions, appDialect, appPool, archiveSchema, archiveStatements, archivedColumn, archivedModule, baselineStore, betterAuthAuthenticator, bucketsCommentPrefix, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, contractMark, contractingRules, contractingSql, createAuth, declaredJob, deleteStatements, fileProviderOf, forceSetting, forgetStepsSql, isOverSignIn, isSubscription, keepSql, keptModule, keptNames, keptStoreModules, keptTables, latestModules, latestSteps, legacyVersions, lintSteps, loadAuthPlugins, localFiles, lockingRules, longQueryPool, markedSql, modelHash, moduleDifference, nameChanges, noInput, offChoices, offlineStepsMigration, organizationsEnabled, organizationsInput, plainStoreDb, readOrigins, readPasskeyDomain, recordTable, recordTableSql, recordsRuntimeModel, refreshBuckets, resolveNames, restoredKeysSql, retiredDifference, retiredNames, retiredSchema, revivalCheckSql, revivalRefusal, revokeStatements, runtimeModel, s3Files, schemaModules, settingsStoreNames, signOffGate, squawkReport, stepRecordMigration, stepRecordOf, stepsOfVersions, storeModel, storeNames, storeNamesList, targetIds, uncapturedMessage, unwatchSql, webhooksModule, workflowPlugins, workflowsModule };
55
+ export { type AfterIndex, type AppAuthInput, type AppliedStep, type ArchivedModule, type AuthPlugins, type DeferredOff, type KeptModule, type LastSteps, type LintedStep, type LiveStore, type ModuleId, type ModuleInput, type ModuleModel, type ModuleTargets, type ModulesModel, type OffChoice, type OrganizationsInput, type RecordModel, type RetiredName, type SchemaModule, type SchemaModuleId, type SignedOff, type SnapshotStore, type SquawkFinding, type StepRecord, type StoreModel, type StoreNames, appAuthOptions, appDialect, appPool, archiveSchema, archiveStatements, archivedColumn, archivedModule, baselineStore, betterAuthAuthenticator, bucketsCommentPrefix, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, contractMark, contractingRules, contractingSql, createAuth, declaredJob, deleteStatements, droppedTableIds, fileProviderOf, forceSetting, forgetStepsSql, isOverSignIn, isSubscription, keepSql, keptModule, keptNames, keptStoreModules, keptTables, latestModules, latestSteps, legacyVersions, lintSteps, loadAuthPlugins, localFiles, lockingRules, longQueryPool, markedSql, modelHash, moduleDifference, nameChanges, noInput, offChoices, offlineStepsMigration, organizationsEnabled, organizationsInput, plainStoreDb, readOrigins, readPasskeyDomain, recordTable, recordTableSql, recordsRuntimeModel, refreshBuckets, resolveNames, restoredKeysSql, retiredDifference, retiredNames, retiredSchema, revivalCheckSql, revivalRefusal, revokeStatements, runtimeModel, s3Files, schemaModules, settingsStoreNames, signOffGate, squawkReport, stepRecordOf, stepsOfVersions, storeModel, storeNames, storeNamesList, targetIds, uncapturedMessage, unwatchSql, versionRecordRefusal, versionRecordTable, webhooksModule, workflowPlugins, workflowsModule };
package/dist/internal.js CHANGED
@@ -19,11 +19,12 @@ import { checkStatusOptions } from "./status/options.js";
19
19
  import { appPool, longQueryPool } from "./app-pool.js";
20
20
  import { betterAuthAuthenticator } from "./better-auth/authenticator.js";
21
21
  import { isOverSignIn } from "./better-auth/over-sign-in.js";
22
+ import { organizationsInput } from "./better-auth/store/steps/step.js";
23
+ import { droppedTableIds } from "./better-auth/store/steps/index.js";
22
24
  import { keptModule, latestSteps, storeModel, storeNamesList } from "./better-auth/store/offline/store-model.js";
23
25
  import { baselineStore } from "./better-auth/store/offline/baseline-store.js";
24
26
  import { legacyVersions } from "./better-auth/store/steps/legacy-versions.js";
25
- import { stepRecordMigration, stepsOfVersions } from "./better-auth/store/legacy-record.js";
26
- import { organizationsInput } from "./better-auth/store/steps/step.js";
27
+ import { stepsOfVersions, versionRecordRefusal, versionRecordTable } from "./better-auth/store/legacy-record.js";
27
28
  import { keptStoreModules } from "./better-auth/auth-schema.js";
28
29
  import { recordTable, recordTableSql } from "./migration-record/record-table.js";
29
30
  import { noInput } from "./schema-modules/schema-module.js";
@@ -49,4 +50,4 @@ import { deleteStatements, forgetStepsSql, stepRecordOf } from "./better-auth/st
49
50
  import { restoredKeysSql } from "./better-auth/store/offline/archive-revival.js";
50
51
  import { contractingRules, lintSteps, lockingRules, squawkReport } from "./better-auth/store/steps/step-lint.js";
51
52
  import { contractingSql } from "./migration-sql/additive-statements.js";
52
- export { appAuthOptions, appDialect, appPool, archiveSchema, archiveStatements, archivedColumn, archivedModule, baselineStore, betterAuthAuthenticator, bucketsCommentPrefix, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, contractMark, contractingRules, contractingSql, createAuth, declaredJob, deleteStatements, fileProviderOf, forceSetting, forgetStepsSql, isOverSignIn, isSubscription, keepSql, keptModule, keptNames, keptStoreModules, keptTables, latestModules, latestSteps, legacyVersions, lintSteps, loadAuthPlugins, localFiles, lockingRules, longQueryPool, markedSql, modelHash, moduleDifference, nameChanges, noInput, offChoices, offlineStepsMigration, organizationsEnabled, organizationsInput, plainStoreDb, readOrigins, readPasskeyDomain, recordTable, recordTableSql, recordsRuntimeModel, refreshBuckets, resolveNames, restoredKeysSql, retiredDifference, retiredNames, retiredSchema, revivalCheckSql, revivalRefusal, revokeStatements, runtimeModel, s3Files, schemaModules, settingsStoreNames, signOffGate, squawkReport, stepRecordMigration, stepRecordOf, stepsOfVersions, storeModel, storeNames, storeNamesList, targetIds, uncapturedMessage, unwatchSql, webhooksModule, workflowPlugins, workflowsModule };
53
+ export { appAuthOptions, appDialect, appPool, archiveSchema, archiveStatements, archivedColumn, archivedModule, baselineStore, betterAuthAuthenticator, bucketsCommentPrefix, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, contractMark, contractingRules, contractingSql, createAuth, declaredJob, deleteStatements, droppedTableIds, fileProviderOf, forceSetting, forgetStepsSql, isOverSignIn, isSubscription, keepSql, keptModule, keptNames, keptStoreModules, keptTables, latestModules, latestSteps, legacyVersions, lintSteps, loadAuthPlugins, localFiles, lockingRules, longQueryPool, markedSql, modelHash, moduleDifference, nameChanges, noInput, offChoices, offlineStepsMigration, organizationsEnabled, organizationsInput, plainStoreDb, readOrigins, readPasskeyDomain, recordTable, recordTableSql, recordsRuntimeModel, refreshBuckets, resolveNames, restoredKeysSql, retiredDifference, retiredNames, retiredSchema, revivalCheckSql, revivalRefusal, revokeStatements, runtimeModel, s3Files, schemaModules, settingsStoreNames, signOffGate, squawkReport, stepRecordOf, stepsOfVersions, storeModel, storeNames, storeNamesList, targetIds, uncapturedMessage, unwatchSql, versionRecordRefusal, versionRecordTable, webhooksModule, workflowPlugins, workflowsModule };
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.130.1";
2
+ var version = "0.131.1";
3
3
  //#endregion
4
4
  export { version };
@@ -35,6 +35,6 @@ export declare const commentsSchemaSql: () => string;
35
35
  export declare const mailFeedbackSchemaSql: () => string;
36
36
  /** The table of who unsubscribed from which topic of the bulk mail. */
37
37
  export declare const unsubscribesSchemaSql: () => string;
38
- /** The role of the built-in assistant's read-only queries and its runner, with select on the tables of `models` but those of `auth`'s store. */
38
+ /** The role of read-only queries and its runner, with select on the tables of `models` but those of `auth`'s store. */
39
39
  export declare const querySchemaSql: (models: readonly ResourceModel[], auth?: StoreNamesSource) => string;
40
40
  //#endregion
@@ -45,7 +45,7 @@ const commentsSchemaSql = () => modulesSql({ comments: noInput });
45
45
  const mailFeedbackSchemaSql = () => modulesSql({ mail_feedback: noInput });
46
46
  /** The table of who unsubscribed from which topic of the bulk mail. */
47
47
  const unsubscribesSchemaSql = () => modulesSql({ unsubscribes: noInput });
48
- /** The role of the built-in assistant's read-only queries and its runner, with select on the tables of `models` but those of `auth`'s store. */
48
+ /** The role of read-only queries and its runner, with select on the tables of `models` but those of `auth`'s store. */
49
49
  const querySchemaSql = (models, auth) => modulesSql({ query: queryInput(models, auth && storeNames(auth)) });
50
50
  //#endregion
51
51
  export { callsSchemaSql, channelSendsSchemaSql, commentsSchemaSql, computedSchemaSql, derivedSchemaSql, mailFeedbackSchemaSql, notificationsSchemaSql, querySchemaSql, realtimeRelaySchemaSql, relaySchemaSql, statusSchemaSql, unsubscribesSchemaSql, userTablesSchemaSql, webhooksSchemaSql, workflowsSchemaSql };
@@ -30,7 +30,7 @@ export type ModuleApp = {
30
30
  events?: EventsOptions;
31
31
  /** Whether the tables users add serve (`userTables`). */
32
32
  userTables?: boolean;
33
- /** Whether the built-in assistant's read-only queries run, as a role of their own that must not read the auth store. */
33
+ /** Whether read-only queries run, of the built-in assistant or the MCP endpoint's `sql`, as a role of their own that must not read the auth store. */
34
34
  readOnlyQueries?: boolean;
35
35
  };
36
36
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.130.1",
3
+ "version": "0.131.1",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -44,14 +44,14 @@
44
44
  "@better-auth/sso": "^1.7.12",
45
45
  "@livekit/protocol": "1.53.1",
46
46
  "@modelcontextprotocol/server": "^2.3.1",
47
- "@protobase/layout": "0.130.1",
48
- "@protobase/query": "0.130.1",
49
- "@protobase/schema": "0.130.1",
50
- "@protobase/workflow-plugins": "0.130.1",
51
- "@protobase/workflows": "0.130.1",
47
+ "@protobase/layout": "0.131.1",
48
+ "@protobase/query": "0.131.1",
49
+ "@protobase/schema": "0.131.1",
50
+ "@protobase/workflow-plugins": "0.131.1",
51
+ "@protobase/workflows": "0.131.1",
52
52
  "@react-email/render": "^2.1.0",
53
53
  "@react-pdf/primitives": "^4.4.0",
54
- "@react-pdf/renderer": "^4.9.0",
54
+ "@react-pdf/renderer": "^4.9.1",
55
55
  "@scalar/hono-api-reference": "^0.12.10",
56
56
  "@sentry/core": "^11.7.0",
57
57
  "@simplewebauthn/server": "^13.3.1",