@protobase/server 0.129.1 → 0.130.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 (253) hide show
  1. package/dist/assistant/query-runner/grants-sql.js +32 -0
  2. package/dist/assistant/query-runner/query-input.js +33 -0
  3. package/dist/assistant/query-runner/query-module.js +44 -0
  4. package/dist/assistant/query-runner/query-runner.d.ts +8 -11
  5. package/dist/assistant/query-runner/query-runner.js +15 -57
  6. package/dist/assistant/query-runner/read-query.js +54 -0
  7. package/dist/assistant/query-runner/runner-sql.js +4 -20
  8. package/dist/assistant/query-runner/steps/001-role.js +19 -0
  9. package/dist/auth-store.d.ts +2 -2
  10. package/dist/auth-store.js +3 -3
  11. package/dist/better-auth/auth-schema.d.ts +13 -4
  12. package/dist/better-auth/auth-schema.js +40 -32
  13. package/dist/better-auth/auth-settings.d.ts +59 -11
  14. package/dist/better-auth/auth-settings.js +57 -13
  15. package/dist/better-auth/auth-tables.d.ts +6 -3
  16. package/dist/better-auth/auth-tables.js +12 -7
  17. package/dist/better-auth/authenticator.js +10 -2
  18. package/dist/better-auth/create-auth.d.ts +62 -7
  19. package/dist/better-auth/create-auth.js +55 -14
  20. package/dist/better-auth/device-sign-in-check.js +13 -0
  21. package/dist/better-auth/names/declaration.d.ts +18 -5
  22. package/dist/better-auth/names/declaration.js +3 -1
  23. package/dist/better-auth/names/modules/auth.js +9 -0
  24. package/dist/better-auth/names/modules/index.d.ts +34 -4
  25. package/dist/better-auth/names/modules/organizations.js +10 -3
  26. package/dist/better-auth/names/modules/personal-access-tokens.js +6 -3
  27. package/dist/better-auth/names/modules-on.js +25 -2
  28. package/dist/better-auth/names/resolve-names.d.ts +9 -1
  29. package/dist/better-auth/names/resolve-names.js +15 -9
  30. package/dist/better-auth/organizations/accept-invitation.js +5 -4
  31. package/dist/better-auth/organizations/add-every-user.js +3 -2
  32. package/dist/better-auth/organizations/host-scope.d.ts +10 -0
  33. package/dist/better-auth/organizations/host-scope.js +15 -0
  34. package/dist/better-auth/organizations/host.d.ts +12 -6
  35. package/dist/better-auth/organizations/host.js +99 -61
  36. package/dist/better-auth/organizations/kept-organizations.d.ts +21 -0
  37. package/dist/better-auth/organizations/kept-organizations.js +62 -0
  38. package/dist/better-auth/organizations/member-endpoints.js +4 -3
  39. package/dist/better-auth/organizations/options.d.ts +15 -0
  40. package/dist/better-auth/organizations/options.js +19 -1
  41. package/dist/better-auth/organizations/people-endpoint.js +3 -2
  42. package/dist/better-auth/organizations/pinned-membership.js +81 -0
  43. package/dist/better-auth/organizations/pinned-sessions.js +46 -0
  44. package/dist/better-auth/organizations/session-organization.js +3 -2
  45. package/dist/better-auth/organizations/store.d.ts +1 -1
  46. package/dist/better-auth/organizations/store.js +14 -9
  47. package/dist/better-auth/personal-access-tokens/pinned-tokens.js +23 -0
  48. package/dist/better-auth/personal-access-tokens/token-plugin.js +75 -54
  49. package/dist/better-auth/personal-access-tokens/token-sessions.js +6 -3
  50. package/dist/better-auth/personal-access-tokens/token-store.js +15 -11
  51. package/dist/better-auth/store/adoption.js +25 -10
  52. package/dist/better-auth/store/drift.js +5 -4
  53. package/dist/better-auth/store/legacy-record.d.ts +10 -0
  54. package/dist/better-auth/store/legacy-record.js +56 -0
  55. package/dist/better-auth/store/migration-sql.js +31 -26
  56. package/dist/better-auth/store/offline/archive-revival.d.ts +11 -0
  57. package/dist/better-auth/store/offline/archive-revival.js +25 -0
  58. package/dist/better-auth/store/offline/baseline-store.d.ts +11 -7
  59. package/dist/better-auth/store/offline/baseline-store.js +15 -12
  60. package/dist/better-auth/store/offline/contract-gate.d.ts +18 -0
  61. package/dist/better-auth/store/offline/contract-gate.js +35 -0
  62. package/dist/better-auth/store/offline/module-archive.d.ts +41 -0
  63. package/dist/better-auth/store/offline/module-archive.js +95 -0
  64. package/dist/better-auth/store/offline/module-delete.d.ts +22 -0
  65. package/dist/better-auth/store/offline/module-delete.js +99 -0
  66. package/dist/better-auth/store/offline/module-switches.d.ts +32 -0
  67. package/dist/better-auth/store/offline/module-switches.js +113 -0
  68. package/dist/better-auth/store/offline/name-changes.d.ts +4 -1
  69. package/dist/better-auth/store/offline/name-changes.js +5 -2
  70. package/dist/better-auth/store/offline/offline-steps.d.ts +21 -7
  71. package/dist/better-auth/store/offline/offline-steps.js +29 -20
  72. package/dist/better-auth/store/offline/retired-watch.d.ts +5 -0
  73. package/dist/better-auth/store/offline/retired-watch.js +43 -0
  74. package/dist/better-auth/store/offline/settings-names.d.ts +3 -2
  75. package/dist/better-auth/store/offline/settings-names.js +10 -3
  76. package/dist/better-auth/store/offline/store-model.d.ts +27 -1
  77. package/dist/better-auth/store/offline/store-model.js +22 -5
  78. package/dist/better-auth/store/resources-outside.js +1 -1
  79. package/dist/better-auth/store/step-record.d.ts +13 -0
  80. package/dist/better-auth/store/step-record.js +59 -0
  81. package/dist/better-auth/store/steps/index.js +6 -1
  82. package/dist/better-auth/store/steps/legacy-versions.d.ts +7 -0
  83. package/dist/better-auth/store/steps/legacy-versions.js +4 -0
  84. package/dist/better-auth/store/steps/organizations/003-default-organization.js +113 -0
  85. package/dist/better-auth/store/steps/render.d.ts +3 -0
  86. package/dist/better-auth/store/steps/render.js +48 -25
  87. package/dist/better-auth/store/steps/step-lint.d.ts +14 -0
  88. package/dist/better-auth/store/steps/step-lint.js +31 -10
  89. package/dist/better-auth/store/steps/step.d.ts +18 -0
  90. package/dist/better-auth/store/steps/step.js +7 -1
  91. package/dist/better-auth/store/store-db.d.ts +6 -0
  92. package/dist/better-auth/store/store-db.js +11 -5
  93. package/dist/better-auth/store/store-names.d.ts +4 -0
  94. package/dist/better-auth/store/store-sql.d.ts +1 -1
  95. package/dist/better-auth/token-standing.js +12 -7
  96. package/dist/better-auth/users.d.ts +7 -2
  97. package/dist/better-auth/users.js +25 -3
  98. package/dist/built-in-resources.js +1 -1
  99. package/dist/calls/calls-module.js +42 -0
  100. package/dist/calls/calls-sql.js +4 -30
  101. package/dist/changes/capture-names.d.ts +3 -1
  102. package/dist/changes/capture-names.js +5 -2
  103. package/dist/changes/capture-schema-sql.d.ts +10 -0
  104. package/dist/changes/capture-schema-sql.js +21 -0
  105. package/dist/changes/capture-schema.d.ts +0 -18
  106. package/dist/changes/capture-schema.js +1 -74
  107. package/dist/changes/capture-sql.js +30 -24
  108. package/dist/changes/changes-input.js +36 -0
  109. package/dist/changes/changes-module.js +44 -0
  110. package/dist/changes/read-capture.js +67 -0
  111. package/dist/changes/steps/001-outbox.js +23 -0
  112. package/dist/channels/sends-module.js +37 -0
  113. package/dist/channels/sends-schema-sql.js +5 -5
  114. package/dist/comments/comments-module.js +30 -0
  115. package/dist/comments/comments-sql.js +1 -22
  116. package/dist/computed/buckets-sql.d.ts +5 -1
  117. package/dist/computed/buckets-sql.js +39 -46
  118. package/dist/computed/{buckets-schema.d.ts → buckets-targets.d.ts} +2 -3
  119. package/dist/computed/buckets-targets.js +50 -0
  120. package/dist/computed/computed-input.js +65 -0
  121. package/dist/computed/computed-module.js +102 -0
  122. package/dist/computed/formula-sql.js +14 -1
  123. package/dist/computed/read-computed.js +100 -0
  124. package/dist/computed/rollup-sql.js +13 -10
  125. package/dist/config-exports.d.ts +2 -2
  126. package/dist/create-admin.js +21 -5
  127. package/dist/derived/derived-module.js +89 -0
  128. package/dist/derived/derived-sql.js +1 -47
  129. package/dist/functions/define-function.d.ts +10 -4
  130. package/dist/functions/routes.js +5 -3
  131. package/dist/functions/supabase-routes.js +7 -5
  132. package/dist/history/history-module.js +34 -0
  133. package/dist/index.d.ts +19 -28
  134. package/dist/index.js +11 -21
  135. package/dist/internal.d.ts +30 -10
  136. package/dist/internal.js +26 -8
  137. package/dist/jobs/functions-sql.js +7 -11
  138. package/dist/jobs/job-data.js +36 -0
  139. package/dist/jobs/job-types.d.ts +6 -3
  140. package/dist/jobs/jobs-module.d.ts +5 -0
  141. package/dist/jobs/jobs-module.js +84 -0
  142. package/dist/jobs/run-job.d.ts +1 -1
  143. package/dist/jobs/run-job.js +7 -5
  144. package/dist/jobs/runtime.d.ts +9 -4
  145. package/dist/jobs/runtime.js +11 -6
  146. package/dist/jobs/schema.d.ts +0 -11
  147. package/dist/jobs/schema.js +1 -59
  148. package/dist/jobs/steps/001-pg-boss-45.js +483 -0
  149. package/dist/live/notices-module.js +30 -0
  150. package/dist/live/notices-sql.js +2 -1
  151. package/dist/mail/feedback/feedback-schema.js +3 -30
  152. package/dist/mail/feedback/mail-feedback-module.js +37 -0
  153. package/dist/mail/unsubscribe/unsubscribe-schema.js +3 -21
  154. package/dist/mail/unsubscribe/unsubscribes-module.js +31 -0
  155. package/dist/migration-record/check-record.d.ts +9 -7
  156. package/dist/migration-record/check-record.js +12 -11
  157. package/dist/migration-record/module-needs.js +30 -0
  158. package/dist/migration-record/read-record.js +27 -15
  159. package/dist/migration-record/record-model.d.ts +7 -2
  160. package/dist/migration-record/record-model.js +14 -6
  161. package/dist/migration-record/startup-decision.js +18 -7
  162. package/dist/migration-sql/additive-statements.d.ts +4 -0
  163. package/dist/migration-sql/additive-statements.js +105 -0
  164. package/dist/notifications/devices-module.js +61 -0
  165. package/dist/notifications/history-module.js +50 -0
  166. package/dist/notifications/notifications-targets.js +23 -0
  167. package/dist/notifications/read-table.js +16 -0
  168. package/dist/notifications/schema-sql.js +1 -22
  169. package/dist/notifications/schema.js +1 -101
  170. package/dist/notifications/table-names.js +40 -0
  171. package/dist/organization-scope/app-scope.js +38 -0
  172. package/dist/organization-scope/auth-request-organization.js +71 -0
  173. package/dist/organization-scope/organization-tables.js +20 -0
  174. package/dist/organization-scope/sign-in-organization.js +21 -0
  175. package/dist/package.js +1 -1
  176. package/dist/personal-mail/shared-sender-store.js +4 -2
  177. package/dist/realtime/relay/realtime-relay-module.js +37 -0
  178. package/dist/relation-found.js +6 -0
  179. package/dist/relay/read-relay.js +85 -0
  180. package/dist/relay/realtime-members-sql.js +51 -28
  181. package/dist/relay/relay-module.js +53 -0
  182. package/dist/relay/relay-targets.js +28 -0
  183. package/dist/relay/session-end.js +1 -3
  184. package/dist/relay/sessions-sql.js +4 -27
  185. package/dist/rest/table-routes.js +9 -2
  186. package/dist/schema-modules/feature-schemas-sql.d.ts +40 -0
  187. package/dist/schema-modules/feature-schemas-sql.js +51 -0
  188. package/dist/schema-modules/module-difference.d.ts +31 -0
  189. package/dist/schema-modules/module-difference.js +98 -0
  190. package/dist/schema-modules/modules-sql.js +13 -0
  191. package/dist/schema-modules/modules.d.ts +37 -0
  192. package/dist/schema-modules/modules.js +56 -0
  193. package/dist/schema-modules/needed-modules.d.ts +41 -0
  194. package/dist/schema-modules/needed-modules.js +61 -0
  195. package/dist/schema-modules/resource-difference.js +83 -0
  196. package/dist/schema-modules/schema-module.d.ts +112 -0
  197. package/dist/schema-modules/schema-module.js +8 -0
  198. package/dist/status/status-module.js +63 -0
  199. package/dist/status/status-targets.js +21 -0
  200. package/dist/types.d.ts +6 -1
  201. package/dist/user-tables/reloading-admin.d.ts +1 -0
  202. package/dist/user-tables/reloading-admin.js +1 -0
  203. package/dist/user-tables/schema-sql.js +1 -14
  204. package/dist/user-tables/schema.js +4 -27
  205. package/dist/user-tables/user-tables-module.js +38 -0
  206. package/dist/webhooks/table/delivery-log-module.js +36 -0
  207. package/dist/webhooks/table/owner-roles.js +3 -2
  208. package/dist/webhooks/table/schema-sql.js +27 -26
  209. package/dist/webhooks/table/webhooks-schema-module.js +63 -0
  210. package/dist/webhooks/table/webhooks-targets.js +26 -0
  211. package/dist/webhooks/webhooks.js +1 -1
  212. package/dist/workflows/custom-steps/custom-steps-module.js +51 -0
  213. package/dist/workflows/custom-steps/custom-steps-sql.js +10 -7
  214. package/dist/workflows/custom-steps/runners-sql.js +10 -7
  215. package/dist/workflows/read-catalogue.js +23 -0
  216. package/dist/workflows/schema-sql.js +12 -9
  217. package/dist/workflows/status-sql.js +12 -6
  218. package/dist/workflows/storage/storage-module.js +39 -0
  219. package/dist/workflows/storage/storage-sql.js +8 -5
  220. package/dist/workflows/workflows-schema-module.js +49 -0
  221. package/dist/workflows/workflows-tables-sql.js +32 -0
  222. package/dist/workflows/workflows-targets.js +16 -0
  223. package/package.json +6 -6
  224. package/dist/assistant/query-runner/runner-plan.js +0 -30
  225. package/dist/better-auth/store/migrations-table.js +0 -27
  226. package/dist/better-auth/store/modules-off.js +0 -17
  227. package/dist/calls/calls-sql.d.ts +0 -11
  228. package/dist/changes/capture-plan.js +0 -79
  229. package/dist/channels/sends-schema.d.ts +0 -7
  230. package/dist/channels/sends-schema.js +0 -18
  231. package/dist/comments/comments-sql.d.ts +0 -14
  232. package/dist/computed/buckets-plan.d.ts +0 -2
  233. package/dist/computed/buckets-plan.js +0 -88
  234. package/dist/computed/buckets-schema.js +0 -39
  235. package/dist/computed/computed-plan.js +0 -81
  236. package/dist/computed/computed-schema.d.ts +0 -16
  237. package/dist/computed/computed-schema.js +0 -63
  238. package/dist/derived/derived-sql.d.ts +0 -12
  239. package/dist/mail/feedback/feedback-schema.d.ts +0 -7
  240. package/dist/mail/unsubscribe/unsubscribe-schema.d.ts +0 -10
  241. package/dist/notifications/schema.d.ts +0 -14
  242. package/dist/realtime/relay/relay-schema.d.ts +0 -7
  243. package/dist/realtime/relay/relay-schema.js +0 -20
  244. package/dist/relay/realtime-members-schema.js +0 -67
  245. package/dist/relay/relay-schema.d.ts +0 -14
  246. package/dist/relay/relay-schema.js +0 -28
  247. package/dist/status/schema.d.ts +0 -12
  248. package/dist/status/schema.js +0 -33
  249. package/dist/user-tables/schema.d.ts +0 -11
  250. package/dist/webhooks/table/schema.d.ts +0 -16
  251. package/dist/webhooks/table/schema.js +0 -56
  252. package/dist/workflows/schema.d.ts +0 -13
  253. package/dist/workflows/schema.js +0 -88
@@ -9,6 +9,7 @@ import { callsAccess } from "../calls/calls-access.js";
9
9
  import { ownMailbox } from "./own-mailbox.js";
10
10
  import { sameCaller } from "./same-caller.js";
11
11
  import { Hono } from "hono";
12
+ import { scopedDb } from "@protobase/query";
12
13
  import { cors } from "hono/cors";
13
14
  //#region src/functions/routes.ts
14
15
  const relativeRequest = (request, prefix) => {
@@ -32,7 +33,7 @@ const isUpgrade = (request) => request.headers.get("upgrade")?.toLowerCase() ===
32
33
  * A function may answer an upgrade with a socket, only once it returned. While it is open, its caller is checked again
33
34
  * every minute: a protected function's always, a public one's once `caller()` resolved.
34
35
  */
35
- const functionRoutes = ({ basePath, functions, authenticate, access, db, records, channels, decryptField, personalMailer = noPersonalMail, onError, wake, upgradeWebSocket, upgradeAuthenticate = authenticate, calls, report }) => {
36
+ const functionRoutes = ({ basePath, functions, authenticate, access, db, records, channels, decryptField, personalMailer = noPersonalMail, onError, wake, upgradeWebSocket, upgradeAuthenticate = authenticate, calls, report, scope }) => {
36
37
  const app = new Hono().basePath(basePath);
37
38
  app.onError(onError);
38
39
  const sessionOf = (request) => isUpgrade(request) ? upgradeAuthenticate(request) : authenticate(request);
@@ -74,7 +75,7 @@ const functionRoutes = ({ basePath, functions, authenticate, access, db, records
74
75
  });
75
76
  const context = {
76
77
  name,
77
- db,
78
+ db: scopedDb(db, (await scope()).tables, void 0),
78
79
  channels,
79
80
  caller: resolveCaller,
80
81
  acceptWebSocket: acceptor.accept,
@@ -100,9 +101,10 @@ const functionRoutes = ({ basePath, functions, authenticate, access, db, records
100
101
  },
101
102
  origin: auditOrigin(c.req.raw.headers)
102
103
  };
104
+ const { tables, organizationOf } = await scope();
103
105
  const context = {
104
106
  name,
105
- db,
107
+ db: scopedDb(db, tables, organizationOf(caller.session)),
106
108
  channels,
107
109
  ...caller,
108
110
  caller: async () => caller,
@@ -5,6 +5,7 @@ import { invokeFunction } from "./define-function.js";
5
5
  import { runInBackground } from "../background-work.js";
6
6
  import { relativeRequest } from "./routes.js";
7
7
  import { Hono } from "hono";
8
+ import { scopedDb } from "@protobase/query";
8
9
  import { cors } from "hono/cors";
9
10
  //#region src/functions/supabase-routes.ts
10
11
  /**
@@ -15,7 +16,7 @@ import { cors } from "hono/cors";
15
16
  * `/<name>/more/parts`, and a CORS preflight, which carries no key, reaches it unchecked. Every other function is a 404
16
17
  * here, and none of its code runs.
17
18
  */
18
- const supabaseFunctionRoutes = ({ functions, db, keys, caller, onError }) => {
19
+ const supabaseFunctionRoutes = ({ functions, db, scope, keys, caller, onError }) => {
19
20
  const app = new Hono().basePath(supabaseFunctionsPath);
20
21
  app.onError(onError);
21
22
  const hasKeys = keys.publishable !== void 0 || keys.secret !== void 0;
@@ -36,17 +37,18 @@ const supabaseFunctionRoutes = ({ functions, db, keys, caller, onError }) => {
36
37
  const request = relativeRequest(c.req.raw, supabaseFunctionsPath);
37
38
  if (options.public || c.req.method === "OPTIONS") {
38
39
  let resolved;
39
- return invokeFunction(name, fn, request, {
40
+ const context = {
40
41
  name,
41
- db,
42
+ db: scopedDb(db, (await scope()).tables, void 0),
42
43
  caller: () => resolved ??= caller(c.req.raw)
43
- });
44
+ };
45
+ return invokeFunction(name, fn, request, context);
44
46
  }
45
47
  if (!hasKeys) throw unauthorized("This app has no keys, so only its public functions answer here");
46
48
  const resolved = await caller(c.req.raw);
47
49
  return invokeFunction(name, fn, request, {
48
50
  name,
49
- db,
51
+ db: scopedDb(db, (await scope()).tables, void 0),
50
52
  caller: async () => resolved
51
53
  });
52
54
  }), { longQueries: options.longQueries }));
@@ -0,0 +1,34 @@
1
+ import { quoteIdent } from "../changes/capture-sql.js";
2
+ import { hasIndexes } from "../has-indexes.js";
3
+ import { historyIndexes, historyTableSql } from "./history-sql.js";
4
+ import { sql } from "kysely";
5
+ //#region src/history/history-module.ts
6
+ /** The history table as the database has it: step 1 once it is there with every index. Refuses one without them, which no step records. */
7
+ const readHistory = async (db, { names }) => {
8
+ const schema = names.schema;
9
+ const { rows } = await sql`select to_regclass(${`${quoteIdent(schema)}."history"`}) is not null as found`.execute(db);
10
+ if (!rows[0].found) return;
11
+ if (!await hasIndexes(db, schema, "history", historyIndexes.map(([name]) => name))) throw new Error(`The history table in schema "${schema}" lacks indexes no step of this version of Protobase records: add them with \`protobase migration\` and \`protobase migrate\` of Protobase 0.14.2 first, then run this command again`);
12
+ return {
13
+ lastStep: 1,
14
+ replaceables: {},
15
+ names
16
+ };
17
+ };
18
+ /** The history table of the resources with `.history()`, in the schema `events` names (`names.schema`). */
19
+ const historyModule = {
20
+ label: "the history table",
21
+ title: "The history table of the resources with history",
22
+ steps: [{
23
+ step: 1,
24
+ name: "history",
25
+ title: "The history table and its indexes",
26
+ additive: true,
27
+ sql: (names) => `create schema if not exists ${quoteIdent(names.schema)};\n${historyTableSql(names.schema)};`
28
+ }],
29
+ replaceables: [],
30
+ resourceReplaceables: [],
31
+ read: readHistory
32
+ };
33
+ //#endregion
34
+ export { historyModule };
package/dist/index.d.ts CHANGED
@@ -15,7 +15,6 @@ import { ConnectionListing } from "./personal-mail/sender-listing.js";
15
15
  import { PersonalMail, PersonalMailMessage } from "./personal-mail/personal-mailer.js";
16
16
  import { OperatorProvider, readOperatorSettings } from "./better-auth/operator-provider.js";
17
17
  import { SignInPolicy, SignInRule, StaffAccessRule, defaultSignInPolicy, signInPolicyMethods } from "./better-auth/sign-in-policy.js";
18
- import { OrganizationsOptions } from "./better-auth/organizations/options.js";
19
18
  import { UnsubscribeLinks } from "./mail/unsubscribe/unsubscribe-links.js";
20
19
  import { DecryptField, FieldDecrypter, FieldReader, RecordKey } from "./encryption/decrypt-field-types.js";
21
20
  import { StandardSchema, readJson } from "./functions/read-json.js";
@@ -26,6 +25,7 @@ import { NotificationRecipients, NotificationSendError, SendNotification, maxMes
26
25
  import { EnqueueOptions, JobContext, JobDefinition, JobOptions } from "./jobs/job-types.js";
27
26
  import { RealtimePrune } from "./realtime/realtime-prune.js";
28
27
  import { Admin, AuditEvent, AuditQueue, Authenticator, Membership, PipelineHook, ScanGuardMode, Session, SessionOrganization, TenantValue, User, ViewSource, WriteEvent, WriteOperation } from "./types.js";
28
+ import { DefaultOrganization, OrganizationsOptions } from "./better-auth/organizations/options.js";
29
29
  import { PlatformSignIn } from "./better-auth/platform-sign-in.js";
30
30
  import { AdminAuth, CreateAuthOptions, UserCreatedHook, normalizeRoles } from "./better-auth/create-auth.js";
31
31
  import { DerivedClock } from "./derived/tracked-clock.js";
@@ -93,6 +93,7 @@ import { TrustedApp, withTrustedApps } from "./better-auth/app-tokens.js";
93
93
  import { BetterAuthAuthenticator, BetterAuthAuthenticatorOptions, betterAuthTokens } from "./better-auth/authenticator.js";
94
94
  import { AuthenticateSettings } from "./better-auth/authenticate-settings.js";
95
95
  import { OverSignIn, overSignIn } from "./better-auth/over-sign-in.js";
96
+ import { HostScope } from "./better-auth/organizations/host-scope.js";
96
97
  import { parseRoles } from "./better-auth/parse-roles.js";
97
98
  import { LinkedAccount, NewUser, StoredUser, UsersCursor, UsersPage, createUser, deleteUser, hasUsers, listUsers, roleChoices, setUserBanned, setUserRole, usersPageSize } from "./better-auth/users.js";
98
99
  import { IssueTokenOptions, issueToken, maxTokenTtlSeconds } from "./better-auth/tokens.js";
@@ -105,37 +106,34 @@ import { capSocketMessages, honorSocketMessageCaps, socketMessageCapOf } from ".
105
106
  import { appNameOver, defaultAppName, shownAppName } from "./app-name.js";
106
107
  import { webManifestPath } from "./web-app/web-manifest-route.js";
107
108
  import { readPlatformSignIns } from "./better-auth/platform-sign-in-env.js";
108
- import { authSchemaMigration } from "./better-auth/auth-schema.js";
109
+ import { FileLimits, limitedFileStore, storeUsage } from "./files/limits.js";
110
+ import { LocalFilesOptions, localFileStore } from "./files/local-files.js";
111
+ import { S3Bucket, S3FilesOptions, S3ListPage, S3Object, s3FileStore } from "./files/s3-files.js";
112
+ import { FileProviderSettings } from "./files/provider-settings.js";
113
+ import { ArgumentsPayload, EnqueueJob, JobDeclaration, JobName, JobPayload, JobRun, enqueueJob } from "./jobs/declared-job.js";
109
114
  import { checkMigrationRecord } from "./migration-record/check-record.js";
115
+ import { authSchemaMigration } from "./better-auth/auth-schema.js";
116
+ import { appRelayChannels, defaultRelayChannels } from "./relay/realtime-channels.js";
117
+ import { ModuleApp, neededModules } from "./schema-modules/needed-modules.js";
110
118
  import { authSchemaDrift } from "./better-auth/store/drift.js";
111
119
  import { checkResourcesOutsideAuthStore } from "./better-auth/store/resources-outside.js";
112
- import { changesMigration, checkChanges, migrationCommand } from "./changes/capture-schema.js";
113
- import { checkComputed, computedMigration } from "./computed/computed-schema.js";
114
- import { hasBuckets } from "./computed/buckets-schema.js";
120
+ import { migrationCommand } from "./changes/capture-schema.js";
121
+ import { hasBuckets } from "./computed/buckets-targets.js";
115
122
  import { capturedBy, isCaptured } from "./changes/capture-sql.js";
116
123
  import { CapturedRow, CoalescedChange, coalesce } from "./changes/coalesce.js";
117
124
  import { ResourceChange, recordOf, resourceChange } from "./changes/resource-change.js";
118
125
  import { eventMatcher } from "./changes/match-events.js";
119
126
  import { parseColumns, readOutbox } from "./changes/outbox.js";
120
127
  import { newWebhookSecret } from "./webhooks/standard-webhooks.js";
121
- import { checkWebhooksSchema, webhooksMigration } from "./webhooks/table/schema.js";
122
- import { checkWorkflowsSchema, workflowsMigration } from "./workflows/schema.js";
123
128
  import { StartWorkflowOptions, startWorkflow } from "./workflows/start-workflow.js";
124
129
  import { releaseConnectionsWithUsers } from "./workflows/connections/release-without-engine.js";
125
130
  import { hookPath, redactHookKeys, webhookIssuePath, webhookParams } from "./workflows/hooks/hook-paths.js";
126
- import { checkUserTablesSchema, userTablesMigration } from "./user-tables/schema.js";
127
131
  import { ownedDefinitionsMigration } from "./user-tables/owned-definitions.js";
128
132
  import { UserTables, userTableResources } from "./user-tables/user-table-resources.js";
129
133
  import { readDefinitionsVersion } from "./user-tables/definitions-version.js";
130
134
  import { reloadingAdmin } from "./user-tables/reloading-admin.js";
131
- import { checkRealtimeRelay, realtimeRelayMigration } from "./realtime/relay/relay-schema.js";
132
- import { channelSendsMigration, checkChannelSends } from "./channels/sends-schema.js";
133
- import { checkComments, commentsMigration } from "./comments/comments-sql.js";
134
- import { checkDerived, derivedMigration } from "./derived/derived-sql.js";
135
- import { callsMigration, checkCalls } from "./calls/calls-sql.js";
136
135
  import { CheckAiInput, checkAi } from "./ai/check-ai.js";
137
136
  import { CommentItem } from "./comments/comment-item.js";
138
- import { checkNotificationsSchema, notificationsMigration } from "./notifications/schema.js";
139
137
  import { deviceStore, removeDevicesWithUsers } from "./notifications/device-store-of.js";
140
138
  import { DeviceStoreError, postgresDeviceStore } from "./notifications/postgres-store.js";
141
139
  import { deviceIdParam, devicesPath, historyIdParam, historyPath } from "./notifications/paths.js";
@@ -155,20 +153,15 @@ import { FcmOptions, fcmSender } from "./notifications/fcm/fcm-sender.js";
155
153
  import { RelayDevice, RelayResult, RelaySendAnswer, RelaySendRequest, maxRelayDevices, relayHandle, relayResults, relaySendAnswer, relaySendPath, relaySendRequest } from "./notifications/relay/relay-protocol.js";
156
154
  import { RelaySettings, readRelaySettings, relayCredentialVariable, relayUrlVariable } from "./notifications/relay/relay-settings.js";
157
155
  import { relaySender } from "./notifications/relay/relay-sender.js";
158
- import { checkStatusSchema, statusMigration } from "./status/schema.js";
159
- import { checkUnsubscribesSchema, unsubscribesMigration } from "./mail/unsubscribe/unsubscribe-schema.js";
160
156
  import { BulkMailError } from "./mail/unsubscribe/bulk-mail-error.js";
161
- import { checkMailFeedbackSchema, mailFeedbackMigration } from "./mail/feedback/feedback-schema.js";
162
157
  import { mailFeedbackResource } from "./mail/feedback/mail-feedback-resource.js";
163
158
  import { mailFeedbackHeaders, mailFeedbackSecret } from "./mail/feedback/feedback-signing.js";
164
159
  import { MailFeedback } from "./mail/feedback/feedback-record.js";
165
160
  import { onDoNotDisturb } from "./status/do-not-disturb.js";
166
- import { appRelayChannels, defaultRelayChannels } from "./relay/realtime-channels.js";
167
161
  import { readRelaySwitch, realtimeSwitchVariable } from "./relay/relay-switch.js";
168
162
  import { relayPresencePath } from "./relay/presence-route.js";
169
163
  import { relayClientEvents, typingResources } from "./relay/client-events.js";
170
- import { checkRelaySchema, relayMigration } from "./relay/relay-schema.js";
171
- import { ListedOrganization, MemberInput, NewOrganization, OrganizationsCursor, OrganizationsPage, addAppRoleToOwners, addMember, createOrganization, listOrganizations, organizationsPageSize, removeMember, setMemberRoles } from "./better-auth/organizations/host.js";
164
+ import { ListedOrganization, MemberInput, NewOrganization, OrganizationsCursor, OrganizationsPage, addAppRoleToOwners, addMember, createOrganization, isMemberByEmail, listOrganizations, organizationByKey, organizationsPageSize, removeMember, setMemberRoles } from "./better-auth/organizations/host.js";
172
165
  import { JoinedUser, addEveryUser } from "./better-auth/organizations/add-every-user.js";
173
166
  import { AssistantBackend, assistantProtocolRoutes } from "./assistant/protocol-routes.js";
174
167
  import { fileConversationStore } from "./assistant/file-conversation-store.js";
@@ -199,7 +192,7 @@ import { McpGateInput, mcpGate, sessionOf } from "./mcp/mcp-gate.js";
199
192
  import { McpHandlerInput, mcpHandler } from "./mcp/mcp-handler.js";
200
193
  import { McpRoutesInput, mcpRoutes } from "./mcp/mcp-routes.js";
201
194
  import { mcpToolContext } from "./mcp/mcp-context.js";
202
- import { checkQueryRunner, queryRunnerMigration } from "./assistant/query-runner/query-runner.js";
195
+ import { checkQueryRoleSafety } from "./assistant/query-runner/query-runner.js";
203
196
  import { authStoreTables } from "./better-auth/auth-tables.js";
204
197
  import { ErrorReporter } from "./error-reporting/sentry-reporter.js";
205
198
  import { startErrorReporting } from "./error-reporting/error-reporter.js";
@@ -210,10 +203,6 @@ import { backgroundSettled, waitUntil } from "./functions/wait-until.js";
210
203
  import { BridgeTarget } from "./bridges/bridge-target.js";
211
204
  import { BridgeRule, TcpBridge, TcpBridgeOptions, tcpBridge } from "./bridges/tcp-bridge.js";
212
205
  import { BridgeClosing, bridgeClosings } from "./bridges/bridge-closings.js";
213
- import { FileLimits, limitedFileStore, storeUsage } from "./files/limits.js";
214
- import { LocalFilesOptions, localFileStore } from "./files/local-files.js";
215
- import { S3Bucket, S3FilesOptions, S3ListPage, S3Object, s3FileStore } from "./files/s3-files.js";
216
- import { FileProviderSettings } from "./files/provider-settings.js";
217
206
  import { StoreFileInput, storeFile } from "./files/store-file.js";
218
207
  import { storageProvider } from "./files/storage-provider.js";
219
208
  import { objectKey } from "./storage/object-key.js";
@@ -227,7 +216,6 @@ import { FileRef, formatUri, variantPath } from "./files/uri.js";
227
216
  import { aspectRatio, fileSize, fileType, imageSize, processor } from "./files/processors.js";
228
217
  import { defineJob, isJobDefinition, jobDefinitions } from "./jobs/define-job.js";
229
218
  import { FatalJobError } from "./jobs/run-job.js";
230
- import { ArgumentsPayload, EnqueueJob, JobDeclaration, JobName, JobPayload, JobRun, enqueueJob } from "./jobs/declared-job.js";
231
219
  import { isSchedule } from "./jobs/schedule.js";
232
220
  import { MailServerTimeoutError } from "./mail/mail-server-timeout.js";
233
221
  import { PersonalMailError, PersonalMailErrorCode } from "./personal-mail/personal-mail-error.js";
@@ -237,6 +225,9 @@ import { SenderAddressError, SenderAddressErrorCode, SenderAddressNotFoundError
237
225
  import { PdfComponent, PdfOptions, PdfTemplate, definePdf } from "./pdf/define-pdf.js";
238
226
  import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/runtime.js";
239
227
  import { jobsDrainApp } from "./jobs/drain-route.js";
240
- import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
228
+ import { jobsSchema } from "./jobs/schema.js";
229
+ import { jobsSchemaSql } from "./jobs/jobs-module.js";
230
+ import { captureSchemaSql } from "./changes/capture-schema-sql.js";
231
+ import { callsSchemaSql, channelSendsSchemaSql, commentsSchemaSql, computedSchemaSql, derivedSchemaSql, mailFeedbackSchemaSql, notificationsSchemaSql, querySchemaSql, realtimeRelaySchemaSql, relaySchemaSql, statusSchemaSql, unsubscribesSchemaSql, userTablesSchemaSql, webhooksSchemaSql, workflowsSchemaSql } from "./schema-modules/feature-schemas-sql.js";
241
232
  import { ResourceSource, configExports } from "./resource-source.js";
242
- export { type AddVerifier, type Admin, type AdminAuth, type AdminOptions, type AggregateParams, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type ApnsOptions, type ApnsSettings, type AppIcons, type AppIdentity, type AppPoolConfig, type ApplyOptions, type ApplyResult, type ApprovalAnswer, type ApprovalRequest, type ArgumentsPayload, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type AuthHooks, type AuthSettings, type AuthenticateSettings, type Authenticator, type BaseToolContext, type BatchOperation, type BatchResult, type BetterAuthAuthenticator, type BetterAuthAuthenticatorOptions, type BridgeClosing, type BridgeRule, type BridgeTarget, BulkMailError, type CallBackend, type CallMember, type Caller, type CallerOptions, type CallsAccess, type CallsOptions, type CapturedRow, type CascadingKey, type ChannelBroadcast, type ChannelSender, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentToolsInput, type CommentUsers, type Completion, type CompletionOptions, type ConnectionListing, ConnectionsBusy, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DecryptField, type DerivedClock, type DerivedCompute, type DerivedContext, type Device, type DeviceColumn, type DeviceKind, type DeviceStore, DeviceStoreError, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EncryptionStatus, type EncryptionTools, type EncryptionToolsInput, type EnqueueJob, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FcmOptions, type FcmSettings, type FieldApplied, type FieldDecrypter, type FieldReader, type FieldStatus, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileProviderSettings, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSocket, type FunctionSource, type HistoryColumn, type HistoryOptions, type HistoryPosition, type HistoryStore, HistoryStoreError, type HookContext, HttpProblem, type IssueTokenOptions, type JobContext, type JobDeclaration, type JobDefinition, type JobName, type JobOptions, type JobPayload, type JobRun, type JobsRuntime, type JoinedUser, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type ListedOrganization, type LiveKitBackend, type LocalFilesOptions, type MailAttachment, type MailFeedback, type MailMessage, type MailSender, MailSenderRefusedError, MailServerTimeoutError, type MailTemplate, type Mailer, type MapLayer, type MapOptions, type MapSettings, type McpApprovals, type McpGateInput, type McpHandlerInput, type McpRoutesInput, type McpServerInput, type McpToolsInput, type McpWrites, type MemberInput, type Membership, MissingCredentials, type MobileConfig, type MobileSplash, type MobileSplashLook, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OperatorProvider, type OrganizationRole, type OrganizationsCursor, type OrganizationsOptions, type OrganizationsPage, type OverSignIn, type PdfComponent, type PdfOptions, type PdfTemplate, type PersonalMail, type PersonalMailEntry, PersonalMailError, type PersonalMailErrorCode, type PersonalMailMessage, type PersonalMailProviderId, type PgModule, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type PushAnswer, type PushMessage, PushMessageError, type PushSender, type QueryOptions, type QueryResult, type ReadableResources, type RealtimeOptions, type RealtimePrune, type RealtimeRelayOptions, type RealtimeRelaySettings, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, type RecordKeyInput, type RecordPage, type RelayChannelOptions, type RelayClientEvent, type RelayDevice, type RelayListedMembers, type RelayMembers, type RelayPresence, type RelayResult, type RelaySendAnswer, type RelaySendRequest, type RelaySettings, type RenderedEmail, type RenderedTemplate, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type SendNotification, SenderAddressError, type SenderAddressErrorCode, SenderAddressNotFoundError, type SenderAddressState, type SenderAddressVerifier, type SentMail, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SocketEvents, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StartWorkflowOptions, type StatusOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TcpBridge, type TcpBridgeOptions, TemplateDataError, type TemplateOptions, type TemplateSchema, type TemplateScope, type TemplateSendOptions, type TemplateText, type TenantValue, type ToolAnnotations, type ToolCall, type ToolComment, type ToolCommentPage, type ToolComments, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type UnreadableEntry, type UnsubscribeLinks, type Urgency, type User, type UserCreatedHook, type UserTables, type UsersCursor, type UsersPage, type VapidSettings, type VerificationInput, type VerificationMessage, type VerificationOutcome, type VerifyInput, type VerifyTools, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WorkflowCatalog, type WorkflowTypes, type WorkflowsOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, appRelayChannels, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkMigrationRecord, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultRelayChannels, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, gmailSettingsScope, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readRelaySwitch, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, realtimeSwitchVariable, realtimeVariables, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relaySettings, relayUrlVariable, relayed, releaseConnectionsWithUsers, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
233
+ export { type AddVerifier, type Admin, type AdminAuth, type AdminOptions, type AggregateParams, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type ApnsOptions, type ApnsSettings, type AppIcons, type AppIdentity, type AppPoolConfig, type ApplyOptions, type ApplyResult, type ApprovalAnswer, type ApprovalRequest, type ArgumentsPayload, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type AuthHooks, type AuthSettings, type AuthenticateSettings, type Authenticator, type BaseToolContext, type BatchOperation, type BatchResult, type BetterAuthAuthenticator, type BetterAuthAuthenticatorOptions, type BridgeClosing, type BridgeRule, type BridgeTarget, BulkMailError, type CallBackend, type CallMember, type Caller, type CallerOptions, type CallsAccess, type CallsOptions, type CapturedRow, type CascadingKey, type ChannelBroadcast, type ChannelSender, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentToolsInput, type CommentUsers, type Completion, type CompletionOptions, type ConnectionListing, ConnectionsBusy, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DecryptField, type DefaultOrganization, type DerivedClock, type DerivedCompute, type DerivedContext, type Device, type DeviceColumn, type DeviceKind, type DeviceStore, DeviceStoreError, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EncryptionStatus, type EncryptionTools, type EncryptionToolsInput, type EnqueueJob, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FcmOptions, type FcmSettings, type FieldApplied, type FieldDecrypter, type FieldReader, type FieldStatus, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileProviderSettings, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSocket, type FunctionSource, type HistoryColumn, type HistoryOptions, type HistoryPosition, type HistoryStore, HistoryStoreError, type HookContext, type HostScope, HttpProblem, type IssueTokenOptions, type JobContext, type JobDeclaration, type JobDefinition, type JobName, type JobOptions, type JobPayload, type JobRun, type JobsRuntime, type JoinedUser, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type ListedOrganization, type LiveKitBackend, type LocalFilesOptions, type MailAttachment, type MailFeedback, type MailMessage, type MailSender, MailSenderRefusedError, MailServerTimeoutError, type MailTemplate, type Mailer, type MapLayer, type MapOptions, type MapSettings, type McpApprovals, type McpGateInput, type McpHandlerInput, type McpRoutesInput, type McpServerInput, type McpToolsInput, type McpWrites, type MemberInput, type Membership, MissingCredentials, type MobileConfig, type MobileSplash, type MobileSplashLook, ModelError, type ModelSettings, type ModuleApp, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OperatorProvider, type OrganizationRole, type OrganizationsCursor, type OrganizationsOptions, type OrganizationsPage, type OverSignIn, type PdfComponent, type PdfOptions, type PdfTemplate, type PersonalMail, type PersonalMailEntry, PersonalMailError, type PersonalMailErrorCode, type PersonalMailMessage, type PersonalMailProviderId, type PgModule, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type PushAnswer, type PushMessage, PushMessageError, type PushSender, type QueryOptions, type QueryResult, type ReadableResources, type RealtimeOptions, type RealtimePrune, type RealtimeRelayOptions, type RealtimeRelaySettings, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, type RecordKeyInput, type RecordPage, type RelayChannelOptions, type RelayClientEvent, type RelayDevice, type RelayListedMembers, type RelayMembers, type RelayPresence, type RelayResult, type RelaySendAnswer, type RelaySendRequest, type RelaySettings, type RenderedEmail, type RenderedTemplate, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type SendNotification, SenderAddressError, type SenderAddressErrorCode, SenderAddressNotFoundError, type SenderAddressState, type SenderAddressVerifier, type SentMail, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SocketEvents, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StartWorkflowOptions, type StatusOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TcpBridge, type TcpBridgeOptions, TemplateDataError, type TemplateOptions, type TemplateSchema, type TemplateScope, type TemplateSendOptions, type TemplateText, type TenantValue, type ToolAnnotations, type ToolCall, type ToolComment, type ToolCommentPage, type ToolComments, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type UnreadableEntry, type UnsubscribeLinks, type Urgency, type User, type UserCreatedHook, type UserTables, type UsersCursor, type UsersPage, type VapidSettings, type VerificationInput, type VerificationMessage, type VerificationOutcome, type VerifyInput, type VerifyTools, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WorkflowCatalog, type WorkflowTypes, type WorkflowsOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, appRelayChannels, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsSchemaSql, capSocketMessages, captureSchemaSql, capturedBy, channelSendsSchemaSql, checkAi, checkMigrationRecord, checkQueryRoleSafety, checkRelayOptions, checkResourcesOutsideAuthStore, checkSourceNames, checkViewQueries, coalesce, commentTools, commentsSchemaSql, computedSchemaSql, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultRelayChannels, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedSchemaSql, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, gmailSettingsScope, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isMemberByEmail, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaSql, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailFeedbackHeaders, mailFeedbackResource, mailFeedbackSchemaSql, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, neededModules, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsSchemaSql, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationByKey, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, querySchemaSql, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readRelaySwitch, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelaySchemaSql, realtimeSwitchVariable, realtimeVariables, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayPresencePath, relayResults, relaySchemaSql, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relaySettings, relayUrlVariable, relayed, releaseConnectionsWithUsers, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, startWorkflow, statusNames, statusSchemaSql, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesSchemaSql, updateRecordTool, urgencies, userTableResources, userTablesSchemaSql, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksSchemaSql, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsSchemaSql, writeRecordTools };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { HttpProblem, MissingCredentials, badRequest, forbidden, notFound, unauthorized } from "./problem.js";
2
- import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
2
+ import { jobsSchema } from "./jobs/schema.js";
3
3
  import { capturedBy, isCaptured } from "./changes/capture-sql.js";
4
4
  import { ConnectionsBusy } from "./connections-busy.js";
5
5
  import { longQueryTimeoutMs } from "./statement-timeout.js";
@@ -29,6 +29,7 @@ import { relayed, sqlSends } from "./realtime/relay/realtime-options.js";
29
29
  import { backgroundSettled, waitUntil } from "./functions/wait-until.js";
30
30
  import { objectKey } from "./storage/object-key.js";
31
31
  import { appNameOver, defaultAppName, shownAppName } from "./app-name.js";
32
+ import { authStoreTables } from "./better-auth/auth-tables.js";
32
33
  import { supabasePath } from "./supabase-paths.js";
33
34
  import { goTruePath } from "./gotrue/keys.js";
34
35
  import { defaultSignInPolicy, signInPolicyMethods } from "./better-auth/sign-in-policy.js";
@@ -43,8 +44,6 @@ import { readOperatorSettings } from "./better-auth/operator-provider.js";
43
44
  import { readPlatformSignIns } from "./better-auth/platform-sign-in-env.js";
44
45
  import { normalizeRoles } from "./better-auth/create-auth.js";
45
46
  import { mcpApprovals } from "./mcp/mcp-approval-store.js";
46
- import { changesMigration, checkChanges, migrationCommand } from "./changes/capture-schema.js";
47
- import { checkComments, commentsMigration } from "./comments/comments-sql.js";
48
47
  import { mcpToolContext } from "./mcp/mcp-context.js";
49
48
  import { mcpGate, sessionOf } from "./mcp/mcp-gate.js";
50
49
  import { mcpHandler } from "./mcp/mcp-handler.js";
@@ -62,11 +61,10 @@ import { workflowReadTools } from "./workflows/mcp/workflow-read-tools.js";
62
61
  import { workflowWriteTools } from "./workflows/mcp/workflow-write-tools.js";
63
62
  import { mcpTools } from "./mcp/mcp-tools.js";
64
63
  import { workflowInstructions } from "./workflows/mcp/workflow-instructions.js";
65
- import { addAppRoleToOwners, addMember, createOrganization, listOrganizations, organizationsPageSize, removeMember, setMemberRoles } from "./better-auth/organizations/host.js";
64
+ import { addAppRoleToOwners, addMember, createOrganization, isMemberByEmail, listOrganizations, organizationByKey, organizationsPageSize, removeMember, setMemberRoles } from "./better-auth/organizations/host.js";
66
65
  import { createUser, deleteUser, hasUsers, listUsers, roleChoices, setUserBanned, setUserRole, usersPageSize } from "./better-auth/users.js";
67
66
  import { enqueueJob } from "./jobs/declared-job.js";
68
- import { checkDerived, derivedMigration } from "./derived/derived-sql.js";
69
- import { hasBuckets } from "./computed/buckets-schema.js";
67
+ import { hasBuckets } from "./computed/buckets-targets.js";
70
68
  import { coalesce } from "./changes/coalesce.js";
71
69
  import { eventMatcher } from "./changes/match-events.js";
72
70
  import { parseColumns, readOutbox } from "./changes/outbox.js";
@@ -137,33 +135,23 @@ import { betterAuthTokens } from "./better-auth/authenticator.js";
137
135
  import { overSignIn } from "./better-auth/over-sign-in.js";
138
136
  import { issueToken, maxTokenTtlSeconds } from "./better-auth/tokens.js";
139
137
  import { authSchemaMigration } from "./better-auth/auth-schema.js";
138
+ import { jobsSchemaSql } from "./jobs/jobs-module.js";
140
139
  import { checkMigrationRecord } from "./migration-record/check-record.js";
140
+ import { neededModules } from "./schema-modules/needed-modules.js";
141
141
  import { authSchemaDrift } from "./better-auth/store/drift.js";
142
- import { authStoreTables } from "./better-auth/auth-tables.js";
143
142
  import { checkResourcesOutsideAuthStore } from "./better-auth/store/resources-outside.js";
144
- import { checkComputed, computedMigration } from "./computed/computed-schema.js";
145
- import { checkWebhooksSchema, webhooksMigration } from "./webhooks/table/schema.js";
146
- import { checkWorkflowsSchema, workflowsMigration } from "./workflows/schema.js";
143
+ import { migrationCommand } from "./changes/capture-schema.js";
147
144
  import { releaseConnectionsWithUsers } from "./workflows/connections/release-without-engine.js";
148
- import { checkUserTablesSchema, userTablesMigration } from "./user-tables/schema.js";
149
145
  import { ownedDefinitionsMigration } from "./user-tables/owned-definitions.js";
150
146
  import { userTableResources } from "./user-tables/user-table-resources.js";
151
147
  import { readDefinitionsVersion } from "./user-tables/definitions-version.js";
152
148
  import { reloadingAdmin } from "./user-tables/reloading-admin.js";
153
- import { checkRealtimeRelay, realtimeRelayMigration } from "./realtime/relay/relay-schema.js";
154
- import { channelSendsMigration, checkChannelSends } from "./channels/sends-schema.js";
155
- import { callsMigration, checkCalls } from "./calls/calls-sql.js";
156
149
  import { checkAi } from "./ai/check-ai.js";
157
- import { checkNotificationsSchema, notificationsMigration } from "./notifications/schema.js";
158
- import { checkStatusSchema, statusMigration } from "./status/schema.js";
159
- import { checkUnsubscribesSchema, unsubscribesMigration } from "./mail/unsubscribe/unsubscribe-schema.js";
160
150
  import { BulkMailError } from "./mail/unsubscribe/bulk-mail-error.js";
161
- import { checkMailFeedbackSchema, mailFeedbackMigration } from "./mail/feedback/feedback-schema.js";
162
151
  import { relayClientEvents, typingResources } from "./relay/client-events.js";
163
- import { checkRelaySchema, relayMigration } from "./relay/relay-schema.js";
164
152
  import { addEveryUser } from "./better-auth/organizations/add-every-user.js";
165
153
  import { maxWidgetPropsBytes, widget } from "./assistant/widget.js";
166
- import { checkQueryRunner, queryRunnerMigration } from "./assistant/query-runner/query-runner.js";
154
+ import { checkQueryRoleSafety } from "./assistant/query-runner/query-runner.js";
167
155
  import { startErrorReporting } from "./error-reporting/error-reporter.js";
168
156
  import { functionApp } from "./functions/function-app.js";
169
157
  import { readJson } from "./functions/read-json.js";
@@ -178,4 +166,6 @@ import { defineEmail } from "./mail/define-email.js";
178
166
  import { definePdf } from "./pdf/define-pdf.js";
179
167
  import { startJobs } from "./jobs/runtime.js";
180
168
  import { jobsDrainApp } from "./jobs/drain-route.js";
181
- export { BulkMailError, ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailSenderRefusedError, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, SenderAddressError, SenderAddressNotFoundError, TemplateDataError, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, appRelayChannels, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkMigrationRecord, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultRelayChannels, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, gmailSettingsScope, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readRelaySwitch, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, realtimeSwitchVariable, realtimeVariables, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relaySettings, relayUrlVariable, relayed, releaseConnectionsWithUsers, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
169
+ import { captureSchemaSql } from "./changes/capture-schema-sql.js";
170
+ import { callsSchemaSql, channelSendsSchemaSql, commentsSchemaSql, computedSchemaSql, derivedSchemaSql, mailFeedbackSchemaSql, notificationsSchemaSql, querySchemaSql, realtimeRelaySchemaSql, relaySchemaSql, statusSchemaSql, unsubscribesSchemaSql, userTablesSchemaSql, webhooksSchemaSql, workflowsSchemaSql } from "./schema-modules/feature-schemas-sql.js";
171
+ export { BulkMailError, ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailSenderRefusedError, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, SenderAddressError, SenderAddressNotFoundError, TemplateDataError, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, appRelayChannels, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsSchemaSql, capSocketMessages, captureSchemaSql, capturedBy, channelSendsSchemaSql, checkAi, checkMigrationRecord, checkQueryRoleSafety, checkRelayOptions, checkResourcesOutsideAuthStore, checkSourceNames, checkViewQueries, coalesce, commentTools, commentsSchemaSql, computedSchemaSql, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultRelayChannels, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedSchemaSql, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, gmailSettingsScope, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isMemberByEmail, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaSql, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailFeedbackHeaders, mailFeedbackResource, mailFeedbackSchemaSql, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, neededModules, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsSchemaSql, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationByKey, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, querySchemaSql, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readRelaySwitch, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelaySchemaSql, realtimeSwitchVariable, realtimeVariables, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayPresencePath, relayResults, relaySchemaSql, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relaySettings, relayUrlVariable, relayed, releaseConnectionsWithUsers, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, startWorkflow, statusNames, statusSchemaSql, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesSchemaSql, updateRecordTool, urgencies, userTableResources, userTablesSchemaSql, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksSchemaSql, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsSchemaSql, writeRecordTools };
@@ -1,3 +1,7 @@
1
+ import { ModuleId } from "./better-auth/names/modules/index.js";
2
+ import { resolveNames } from "./better-auth/names/resolve-names.js";
3
+ import { organizationsEnabled } from "./better-auth/organizations/options.js";
4
+ import { keptNames } from "./better-auth/organizations/kept-organizations.js";
1
5
  import { AuthPlugins, buildAuth, createAuth, loadAuthPlugins } from "./better-auth/create-auth.js";
2
6
  import { checkNotificationsOptions } from "./notifications/options.js";
3
7
  import { checkCallsOptions } from "./calls/calls-options.js";
@@ -9,26 +13,42 @@ import { betterAuthAuthenticator } from "./better-auth/authenticator.js";
9
13
  import { buildAuthenticator } from "./better-auth/authenticate-settings.js";
10
14
  import { isOverSignIn } from "./better-auth/over-sign-in.js";
11
15
  import { readOrigins } from "./better-auth/origins.js";
12
- import { recordsRuntimeModel } from "./migration-record/check-record.js";
13
- import { uncapturedMessage } from "./changes/capture-schema.js";
16
+ import { appDialect } from "./app-dialect.js";
17
+ import { readPasskeyDomain } from "./better-auth/passkey-domain.js";
14
18
  import { localFiles } from "./files/local-files.js";
15
19
  import { s3Files } from "./files/s3-files.js";
16
20
  import { fileProviderOf } from "./files/provider-settings.js";
17
- import { declaredJob } from "./jobs/declared-job.js";
18
21
  import { webhooksModule } from "./webhooks/table/webhooks-module.js";
19
22
  import { workflowsModule } from "./workflows/workflows-module.js";
20
- import { appDialect } from "./app-dialect.js";
21
- import { readPasskeyDomain } from "./better-auth/passkey-domain.js";
22
- import { captureNames } from "./changes/capture-names.js";
23
+ import { captureNames, uncapturedMessage } from "./changes/capture-names.js";
24
+ import { declaredJob } from "./jobs/declared-job.js";
23
25
  import { bucketsRefreshes, refreshBuckets } from "./computed/buckets-job.js";
24
26
  import { workflowPlugins } from "./workflows/default-plugins.js";
25
27
  import { StoreNames, storeNames } from "./better-auth/store/store-names.js";
26
28
  import { settingsStoreNames } from "./better-auth/store/offline/settings-names.js";
27
- import { LastSteps, StoreModel, latestSteps, storeModel, storeNamesList } from "./better-auth/store/offline/store-model.js";
29
+ import { OrganizationsInput, organizationsInput } from "./better-auth/store/steps/step.js";
30
+ import { DeferredOff, KeptModule, LastSteps, RetiredName, StoreModel, keptModule, latestSteps, storeModel, storeNamesList } from "./better-auth/store/offline/store-model.js";
28
31
  import { nameChanges } from "./better-auth/store/offline/name-changes.js";
29
- import { offlineStepsMigration } from "./better-auth/store/offline/offline-steps.js";
32
+ import { SnapshotStore, offlineStepsMigration } from "./better-auth/store/offline/offline-steps.js";
33
+ import { retiredSchema } from "./better-auth/store/offline/retired-watch.js";
34
+ import { OffChoice, forceSetting, keepSql, keptTables, offChoices, retiredNames, revivalCheckSql, revivalRefusal, unwatchSql } from "./better-auth/store/offline/module-switches.js";
35
+ import { SignedOff, contractMark, markedSql, signOffGate } from "./better-auth/store/offline/contract-gate.js";
36
+ import { ArchivedModule, archiveSchema, archiveStatements, archivedColumn, archivedModule, revokeStatements } from "./better-auth/store/offline/module-archive.js";
37
+ import { StepRecord, deleteStatements, forgetStepsSql, stepRecordOf } from "./better-auth/store/offline/module-delete.js";
38
+ import { restoredKeysSql } from "./better-auth/store/offline/archive-revival.js";
39
+ import { bucketsCommentPrefix } from "./computed/buckets-sql.js";
40
+ import { AppliedStep } from "./better-auth/store/step-record.js";
30
41
  import { LiveStore, baselineStore } from "./better-auth/store/offline/baseline-store.js";
31
- import { LintedStep, lintSteps } from "./better-auth/store/steps/step-lint.js";
42
+ import { stepRecordMigration, stepsOfVersions } from "./better-auth/store/legacy-record.js";
43
+ import { legacyVersions } from "./better-auth/store/steps/legacy-versions.js";
44
+ import { LintedStep, SquawkFinding, contractingRules, lintSteps, lockingRules, squawkReport } from "./better-auth/store/steps/step-lint.js";
45
+ import { contractingSql } from "./migration-sql/additive-statements.js";
46
+ import { ModuleInput, ModuleModel, SchemaModule, noInput } from "./schema-modules/schema-module.js";
47
+ import { ModuleTargets, ModulesModel, SchemaModuleId, latestModules, schemaModules, targetIds } from "./schema-modules/modules.js";
32
48
  import { RecordModel, modelHash, runtimeModel } from "./migration-record/record-model.js";
33
49
  import { AfterIndex, recordTable, recordTableSql } from "./migration-record/record-table.js";
34
- export { type AfterIndex, type AppAuthInput, type AuthPlugins, type LastSteps, type LintedStep, type LiveStore, type RecordModel, type StoreModel, type StoreNames, appAuthOptions, appDialect, appPool, baselineStore, betterAuthAuthenticator, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, createAuth, declaredJob, fileProviderOf, isOverSignIn, isSubscription, latestSteps, lintSteps, loadAuthPlugins, localFiles, longQueryPool, modelHash, nameChanges, offlineStepsMigration, readOrigins, readPasskeyDomain, recordTable, recordTableSql, recordsRuntimeModel, refreshBuckets, runtimeModel, s3Files, settingsStoreNames, storeModel, storeNames, storeNamesList, uncapturedMessage, webhooksModule, workflowPlugins, workflowsModule };
50
+ import { recordsRuntimeModel } from "./migration-record/check-record.js";
51
+ import { plainStoreDb } from "./better-auth/store/store-db.js";
52
+ import { moduleDifference, retiredDifference } from "./schema-modules/module-difference.js";
53
+ 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 };
package/dist/internal.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { readOrigins } from "./better-auth/origins.js";
2
- import { readPasskeyDomain } from "./better-auth/passkey-domain.js";
2
+ import { resolveNames } from "./better-auth/names/resolve-names.js";
3
3
  import { storeNames } from "./better-auth/store/store-names.js";
4
+ import { plainStoreDb } from "./better-auth/store/store-db.js";
5
+ import { keptNames } from "./better-auth/organizations/kept-organizations.js";
6
+ import { organizationsEnabled } from "./better-auth/organizations/options.js";
7
+ import { readPasskeyDomain } from "./better-auth/passkey-domain.js";
4
8
  import { buildAuth, createAuth, loadAuthPlugins } from "./better-auth/create-auth.js";
5
- import { uncapturedMessage } from "./changes/capture-schema.js";
6
9
  import { declaredJob } from "./jobs/declared-job.js";
10
+ import { bucketsCommentPrefix } from "./computed/buckets-sql.js";
7
11
  import { bucketsRefreshes, refreshBuckets } from "./computed/buckets-job.js";
8
12
  import { isSubscription } from "./webhooks/subscription.js";
9
13
  import { workflowPlugins } from "./workflows/default-plugins.js";
@@ -15,9 +19,17 @@ import { checkStatusOptions } from "./status/options.js";
15
19
  import { appPool, longQueryPool } from "./app-pool.js";
16
20
  import { betterAuthAuthenticator } from "./better-auth/authenticator.js";
17
21
  import { isOverSignIn } from "./better-auth/over-sign-in.js";
18
- import { latestSteps, storeModel, storeNamesList } from "./better-auth/store/offline/store-model.js";
19
- import { modelHash, runtimeModel } from "./migration-record/record-model.js";
22
+ import { keptModule, latestSteps, storeModel, storeNamesList } from "./better-auth/store/offline/store-model.js";
23
+ import { baselineStore } from "./better-auth/store/offline/baseline-store.js";
24
+ 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 { keptStoreModules } from "./better-auth/auth-schema.js";
20
28
  import { recordTable, recordTableSql } from "./migration-record/record-table.js";
29
+ import { noInput } from "./schema-modules/schema-module.js";
30
+ import { moduleDifference, retiredDifference } from "./schema-modules/module-difference.js";
31
+ import { latestModules, schemaModules, targetIds } from "./schema-modules/modules.js";
32
+ import { modelHash, runtimeModel } from "./migration-record/record-model.js";
21
33
  import { nameChanges } from "./better-auth/store/offline/name-changes.js";
22
34
  import { recordsRuntimeModel } from "./migration-record/check-record.js";
23
35
  import { webhooksModule } from "./webhooks/table/webhooks-module.js";
@@ -25,10 +37,16 @@ import { workflowsModule } from "./workflows/workflows-module.js";
25
37
  import { appDialect } from "./app-dialect.js";
26
38
  import { appAuthOptions, buildAppAuth } from "./better-auth/auth-settings.js";
27
39
  import { buildAuthenticator } from "./better-auth/authenticate-settings.js";
28
- import { captureNames } from "./changes/capture-names.js";
40
+ import { captureNames, uncapturedMessage } from "./changes/capture-names.js";
29
41
  import { checkCallsOptions } from "./calls/calls-options.js";
30
42
  import { settingsStoreNames } from "./better-auth/store/offline/settings-names.js";
31
43
  import { offlineStepsMigration } from "./better-auth/store/offline/offline-steps.js";
32
- import { baselineStore } from "./better-auth/store/offline/baseline-store.js";
33
- import { lintSteps } from "./better-auth/store/steps/step-lint.js";
34
- export { appAuthOptions, appDialect, appPool, baselineStore, betterAuthAuthenticator, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, createAuth, declaredJob, fileProviderOf, isOverSignIn, isSubscription, latestSteps, lintSteps, loadAuthPlugins, localFiles, longQueryPool, modelHash, nameChanges, offlineStepsMigration, readOrigins, readPasskeyDomain, recordTable, recordTableSql, recordsRuntimeModel, refreshBuckets, runtimeModel, s3Files, settingsStoreNames, storeModel, storeNames, storeNamesList, uncapturedMessage, webhooksModule, workflowPlugins, workflowsModule };
44
+ import { retiredSchema } from "./better-auth/store/offline/retired-watch.js";
45
+ import { forceSetting, keepSql, keptTables, offChoices, retiredNames, revivalCheckSql, revivalRefusal, unwatchSql } from "./better-auth/store/offline/module-switches.js";
46
+ import { contractMark, markedSql, signOffGate } from "./better-auth/store/offline/contract-gate.js";
47
+ import { archiveSchema, archiveStatements, archivedColumn, archivedModule, revokeStatements } from "./better-auth/store/offline/module-archive.js";
48
+ import { deleteStatements, forgetStepsSql, stepRecordOf } from "./better-auth/store/offline/module-delete.js";
49
+ import { restoredKeysSql } from "./better-auth/store/offline/archive-revival.js";
50
+ import { contractingRules, lintSteps, lockingRules, squawkReport } from "./better-auth/store/steps/step-lint.js";
51
+ 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 };
@@ -1,12 +1,6 @@
1
+ import { organizationKey } from "./job-data.js";
1
2
  /** The comment each Protobase function in the jobs schema carries, which the startup check reads. */
2
- const functionsComment = `Protobase jobs 3`;
3
- /** Protobase's own functions beside pg-boss's tables, by name; each carries `functionsComment`. */
4
- const functionNames = [
5
- "enqueue",
6
- "next_due",
7
- "failed_retry",
8
- "failed_delete"
9
- ];
3
+ const functionsComment = `Protobase jobs 4`;
10
4
  /**
11
5
  * `jobs.enqueue(name, payload, run_at, key, group_key, priority)`: a job from SQL, such as a trigger, in the caller's
12
6
  * transaction. It inserts what pg-boss's `send()` does, with the queue's retry settings; it creates a queue that no
@@ -87,12 +81,14 @@ $$;
87
81
  comment on function ${schema}.next_due() is '${functionsComment}';`;
88
82
  /**
89
83
  * `jobs.failed`: the failed jobs, for the admin app's page, with their last error. Updating `retry` to true retries a
90
- * job, as pg-boss's `retry()` does: one more attempt, from now; deleting a row deletes the job.
84
+ * job, as pg-boss's `retry()` does: one more attempt, from now; deleting a row deletes the job. Its `payload` is the
85
+ * job's payload alone, without the organization the runtime stores beside it (`jobData`).
91
86
  */
92
87
  const failed = (schema) => `create index if not exists job_failed_i on ${schema}.job (completed_on) where state = 'failed';
93
88
  drop view if exists ${schema}.failed;
94
89
  create view ${schema}.failed as
95
- select id, name, data as payload, retry_count + 1 as attempts,
90
+ select id, name,
91
+ case when jsonb_typeof(data) = 'object' and data ? '${organizationKey}' then data -> 'payload' else data end as payload, retry_count + 1 as attempts,
96
92
  coalesce(output ->> 'message', output -> 'value' ->> 'message', output ->> 'value') as error,
97
93
  output, completed_on as failed_at, created_on as created_at, singleton_key as key, false as retry
98
94
  from ${schema}.job where state = 'failed';
@@ -126,4 +122,4 @@ const functionsSql = (schema) => [
126
122
  failed(schema)
127
123
  ].join("\n\n");
128
124
  //#endregion
129
- export { functionNames, functionsComment, functionsSql };
125
+ export { functionsComment, functionsSql };