@protobase/server 0.129.0 → 0.130.0

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 (243) 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.js +14 -9
  46. package/dist/better-auth/personal-access-tokens/pinned-tokens.js +23 -0
  47. package/dist/better-auth/personal-access-tokens/token-plugin.js +75 -54
  48. package/dist/better-auth/personal-access-tokens/token-sessions.js +6 -3
  49. package/dist/better-auth/personal-access-tokens/token-store.js +15 -11
  50. package/dist/better-auth/store/adoption.js +25 -10
  51. package/dist/better-auth/store/drift.js +5 -4
  52. package/dist/better-auth/store/legacy-record.d.ts +10 -0
  53. package/dist/better-auth/store/legacy-record.js +56 -0
  54. package/dist/better-auth/store/migration-sql.js +31 -26
  55. package/dist/better-auth/store/offline/baseline-store.d.ts +35 -0
  56. package/dist/better-auth/store/offline/baseline-store.js +65 -0
  57. package/dist/better-auth/store/offline/module-switches.d.ts +27 -0
  58. package/dist/better-auth/store/offline/module-switches.js +94 -0
  59. package/dist/better-auth/store/offline/name-changes.d.ts +4 -1
  60. package/dist/better-auth/store/offline/name-changes.js +5 -2
  61. package/dist/better-auth/store/offline/offline-steps.d.ts +21 -6
  62. package/dist/better-auth/store/offline/offline-steps.js +30 -20
  63. package/dist/better-auth/store/offline/retired-watch.d.ts +5 -0
  64. package/dist/better-auth/store/offline/retired-watch.js +36 -0
  65. package/dist/better-auth/store/offline/settings-names.d.ts +3 -2
  66. package/dist/better-auth/store/offline/settings-names.js +10 -3
  67. package/dist/better-auth/store/offline/store-model.d.ts +9 -1
  68. package/dist/better-auth/store/offline/store-model.js +22 -5
  69. package/dist/better-auth/store/resources-outside.js +1 -1
  70. package/dist/better-auth/store/step-record.d.ts +13 -0
  71. package/dist/better-auth/store/step-record.js +59 -0
  72. package/dist/better-auth/store/steps/index.js +6 -1
  73. package/dist/better-auth/store/steps/legacy-versions.d.ts +7 -0
  74. package/dist/better-auth/store/steps/legacy-versions.js +4 -0
  75. package/dist/better-auth/store/steps/organizations/003-default-organization.js +113 -0
  76. package/dist/better-auth/store/steps/render.d.ts +3 -0
  77. package/dist/better-auth/store/steps/render.js +48 -25
  78. package/dist/better-auth/store/steps/step-lint.d.ts +14 -0
  79. package/dist/better-auth/store/steps/step-lint.js +31 -10
  80. package/dist/better-auth/store/steps/step.d.ts +18 -0
  81. package/dist/better-auth/store/steps/step.js +13 -4
  82. package/dist/better-auth/store/store-db.d.ts +6 -0
  83. package/dist/better-auth/store/store-db.js +11 -5
  84. package/dist/better-auth/store/store-names.d.ts +4 -0
  85. package/dist/better-auth/token-standing.js +12 -7
  86. package/dist/better-auth/users.d.ts +7 -2
  87. package/dist/better-auth/users.js +25 -3
  88. package/dist/built-in-resources.js +1 -1
  89. package/dist/calls/calls-module.js +42 -0
  90. package/dist/calls/calls-sql.js +4 -30
  91. package/dist/changes/capture-names.d.ts +3 -1
  92. package/dist/changes/capture-names.js +5 -2
  93. package/dist/changes/capture-schema-sql.d.ts +10 -0
  94. package/dist/changes/capture-schema-sql.js +21 -0
  95. package/dist/changes/capture-schema.d.ts +0 -18
  96. package/dist/changes/capture-schema.js +1 -74
  97. package/dist/changes/capture-sql.js +30 -24
  98. package/dist/changes/changes-input.js +36 -0
  99. package/dist/changes/changes-module.js +44 -0
  100. package/dist/changes/read-capture.js +67 -0
  101. package/dist/changes/steps/001-outbox.js +23 -0
  102. package/dist/channels/sends-module.js +37 -0
  103. package/dist/channels/sends-schema-sql.js +5 -5
  104. package/dist/comments/comments-module.js +30 -0
  105. package/dist/comments/comments-sql.js +1 -22
  106. package/dist/computed/buckets-sql.d.ts +5 -1
  107. package/dist/computed/buckets-sql.js +39 -46
  108. package/dist/computed/{buckets-schema.d.ts → buckets-targets.d.ts} +2 -3
  109. package/dist/computed/buckets-targets.js +50 -0
  110. package/dist/computed/computed-input.js +65 -0
  111. package/dist/computed/computed-module.js +102 -0
  112. package/dist/computed/formula-sql.js +14 -1
  113. package/dist/computed/read-computed.js +100 -0
  114. package/dist/computed/rollup-sql.js +13 -10
  115. package/dist/config-exports.d.ts +2 -2
  116. package/dist/create-admin.js +21 -5
  117. package/dist/derived/derived-module.js +89 -0
  118. package/dist/derived/derived-sql.js +1 -47
  119. package/dist/functions/define-function.d.ts +10 -4
  120. package/dist/functions/routes.js +5 -3
  121. package/dist/functions/supabase-routes.js +7 -5
  122. package/dist/history/history-module.js +34 -0
  123. package/dist/index.d.ts +19 -28
  124. package/dist/index.js +11 -21
  125. package/dist/internal.d.ts +27 -10
  126. package/dist/internal.js +22 -7
  127. package/dist/jobs/functions-sql.js +7 -11
  128. package/dist/jobs/job-data.js +36 -0
  129. package/dist/jobs/job-types.d.ts +6 -3
  130. package/dist/jobs/jobs-module.d.ts +5 -0
  131. package/dist/jobs/jobs-module.js +84 -0
  132. package/dist/jobs/run-job.d.ts +1 -1
  133. package/dist/jobs/run-job.js +7 -5
  134. package/dist/jobs/runtime.d.ts +9 -4
  135. package/dist/jobs/runtime.js +11 -6
  136. package/dist/jobs/schema.d.ts +0 -11
  137. package/dist/jobs/schema.js +1 -59
  138. package/dist/jobs/steps/001-pg-boss-45.js +483 -0
  139. package/dist/live/notices-module.js +30 -0
  140. package/dist/live/notices-sql.js +2 -1
  141. package/dist/mail/feedback/feedback-schema.js +3 -30
  142. package/dist/mail/feedback/mail-feedback-module.js +37 -0
  143. package/dist/mail/unsubscribe/unsubscribe-schema.js +3 -21
  144. package/dist/mail/unsubscribe/unsubscribes-module.js +31 -0
  145. package/dist/migration-record/check-record.d.ts +9 -7
  146. package/dist/migration-record/check-record.js +12 -11
  147. package/dist/migration-record/module-needs.js +30 -0
  148. package/dist/migration-record/read-record.js +27 -15
  149. package/dist/migration-record/record-model.d.ts +7 -2
  150. package/dist/migration-record/record-model.js +14 -6
  151. package/dist/migration-record/startup-decision.js +18 -7
  152. package/dist/migration-sql/additive-statements.d.ts +4 -0
  153. package/dist/migration-sql/additive-statements.js +105 -0
  154. package/dist/notifications/devices-module.js +61 -0
  155. package/dist/notifications/history-module.js +50 -0
  156. package/dist/notifications/notifications-targets.js +23 -0
  157. package/dist/notifications/read-table.js +16 -0
  158. package/dist/notifications/schema-sql.js +1 -22
  159. package/dist/notifications/schema.js +1 -101
  160. package/dist/notifications/table-names.js +40 -0
  161. package/dist/organization-scope/app-scope.js +38 -0
  162. package/dist/organization-scope/auth-request-organization.js +71 -0
  163. package/dist/organization-scope/organization-tables.js +20 -0
  164. package/dist/organization-scope/sign-in-organization.js +21 -0
  165. package/dist/package.js +1 -1
  166. package/dist/personal-mail/shared-sender-store.js +4 -2
  167. package/dist/realtime/relay/realtime-relay-module.js +37 -0
  168. package/dist/relation-found.js +6 -0
  169. package/dist/relay/read-relay.js +85 -0
  170. package/dist/relay/realtime-members-sql.js +51 -28
  171. package/dist/relay/relay-module.js +53 -0
  172. package/dist/relay/relay-targets.js +28 -0
  173. package/dist/relay/session-end.js +1 -3
  174. package/dist/relay/sessions-sql.js +4 -27
  175. package/dist/rest/table-routes.js +9 -2
  176. package/dist/schema-modules/feature-schemas-sql.d.ts +40 -0
  177. package/dist/schema-modules/feature-schemas-sql.js +51 -0
  178. package/dist/schema-modules/module-difference.d.ts +31 -0
  179. package/dist/schema-modules/module-difference.js +98 -0
  180. package/dist/schema-modules/modules-sql.js +13 -0
  181. package/dist/schema-modules/modules.d.ts +37 -0
  182. package/dist/schema-modules/modules.js +56 -0
  183. package/dist/schema-modules/needed-modules.d.ts +41 -0
  184. package/dist/schema-modules/needed-modules.js +61 -0
  185. package/dist/schema-modules/resource-difference.js +83 -0
  186. package/dist/schema-modules/schema-module.d.ts +112 -0
  187. package/dist/schema-modules/schema-module.js +8 -0
  188. package/dist/status/status-module.js +63 -0
  189. package/dist/status/status-targets.js +21 -0
  190. package/dist/types.d.ts +6 -1
  191. package/dist/user-tables/reloading-admin.d.ts +1 -0
  192. package/dist/user-tables/reloading-admin.js +1 -0
  193. package/dist/user-tables/schema-sql.js +1 -14
  194. package/dist/user-tables/schema.js +4 -27
  195. package/dist/user-tables/user-tables-module.js +38 -0
  196. package/dist/webhooks/table/delivery-log-module.js +36 -0
  197. package/dist/webhooks/table/owner-roles.js +3 -2
  198. package/dist/webhooks/table/schema-sql.js +27 -26
  199. package/dist/webhooks/table/webhooks-schema-module.js +63 -0
  200. package/dist/webhooks/table/webhooks-targets.js +26 -0
  201. package/dist/webhooks/webhooks.js +1 -1
  202. package/dist/workflows/custom-steps/custom-steps-module.js +51 -0
  203. package/dist/workflows/custom-steps/custom-steps-sql.js +10 -7
  204. package/dist/workflows/custom-steps/runners-sql.js +10 -7
  205. package/dist/workflows/read-catalogue.js +23 -0
  206. package/dist/workflows/schema-sql.js +12 -9
  207. package/dist/workflows/status-sql.js +12 -6
  208. package/dist/workflows/storage/storage-module.js +39 -0
  209. package/dist/workflows/storage/storage-sql.js +8 -5
  210. package/dist/workflows/workflows-schema-module.js +49 -0
  211. package/dist/workflows/workflows-tables-sql.js +32 -0
  212. package/dist/workflows/workflows-targets.js +16 -0
  213. package/package.json +6 -6
  214. package/dist/assistant/query-runner/runner-plan.js +0 -30
  215. package/dist/better-auth/store/migrations-table.js +0 -27
  216. package/dist/better-auth/store/modules-off.js +0 -17
  217. package/dist/calls/calls-sql.d.ts +0 -11
  218. package/dist/changes/capture-plan.js +0 -79
  219. package/dist/channels/sends-schema.d.ts +0 -7
  220. package/dist/channels/sends-schema.js +0 -18
  221. package/dist/comments/comments-sql.d.ts +0 -14
  222. package/dist/computed/buckets-plan.d.ts +0 -2
  223. package/dist/computed/buckets-plan.js +0 -88
  224. package/dist/computed/buckets-schema.js +0 -39
  225. package/dist/computed/computed-plan.js +0 -81
  226. package/dist/computed/computed-schema.d.ts +0 -16
  227. package/dist/computed/computed-schema.js +0 -63
  228. package/dist/derived/derived-sql.d.ts +0 -12
  229. package/dist/mail/feedback/feedback-schema.d.ts +0 -7
  230. package/dist/mail/unsubscribe/unsubscribe-schema.d.ts +0 -10
  231. package/dist/notifications/schema.d.ts +0 -14
  232. package/dist/realtime/relay/relay-schema.d.ts +0 -7
  233. package/dist/realtime/relay/relay-schema.js +0 -20
  234. package/dist/relay/realtime-members-schema.js +0 -67
  235. package/dist/relay/relay-schema.d.ts +0 -14
  236. package/dist/relay/relay-schema.js +0 -28
  237. package/dist/status/schema.d.ts +0 -12
  238. package/dist/status/schema.js +0 -33
  239. package/dist/user-tables/schema.d.ts +0 -11
  240. package/dist/webhooks/table/schema.d.ts +0 -16
  241. package/dist/webhooks/table/schema.js +0 -56
  242. package/dist/workflows/schema.d.ts +0 -13
  243. package/dist/workflows/schema.js +0 -88
@@ -2,7 +2,7 @@ import { EventsOptions } from "./events-options.js";
2
2
  import { ResourceModel } from "@protobase/schema";
3
3
  //#region src/changes/capture-names.d.ts
4
4
  /**
5
- * What the change capture of `models` names in the database, as `checkChanges` looks it up in the catalog: the changes
5
+ * What the change capture of `models` names in the database, as the change capture module writes it: the changes
6
6
  * schema, which holds `capture()` and the outbox, history and notices tables, and each captured resource's triggers.
7
7
  */
8
8
  export declare const captureNames: (models: readonly ResourceModel[], options?: EventsOptions) => {
@@ -12,4 +12,6 @@ export declare const captureNames: (models: readonly ResourceModel[], options?:
12
12
  triggers: string[];
13
13
  }[];
14
14
  };
15
+ /** What `protobase doctor` reports while the changes of the `missing` resources are not captured. */
16
+ export declare const uncapturedMessage: (missing: readonly string[]) => string;
15
17
  //#endregion
@@ -1,8 +1,9 @@
1
1
  import { capturedBy, resourceTriggers } from "./capture-sql.js";
2
2
  import { changesSchema } from "./events-options.js";
3
+ import { migrationCommand } from "./capture-schema.js";
3
4
  //#region src/changes/capture-names.ts
4
5
  /**
5
- * What the change capture of `models` names in the database, as `checkChanges` looks it up in the catalog: the changes
6
+ * What the change capture of `models` names in the database, as the change capture module writes it: the changes
6
7
  * schema, which holds `capture()` and the outbox, history and notices tables, and each captured resource's triggers.
7
8
  */
8
9
  const captureNames = (models, options) => ({
@@ -12,5 +13,7 @@ const captureNames = (models, options) => ({
12
13
  triggers: resourceTriggers(model).map((trigger) => trigger.name)
13
14
  }))
14
15
  });
16
+ /** What `protobase doctor` reports while the changes of the `missing` resources are not captured. */
17
+ const uncapturedMessage = (missing) => `The changes of ${missing.join(", ")} are not captured as their events, history or live updates need: their triggers, the history or notices table or the changes schema are missing or out of date. Write the change as a migration with \`${migrationCommand}\`, apply it with the project's migrations, then start again.`;
15
18
  //#endregion
16
- export { captureNames };
19
+ export { captureNames, uncapturedMessage };
@@ -0,0 +1,10 @@
1
+ import { EventsOptions } from "./events-options.js";
2
+ import { ResourceModel } from "@protobase/schema";
3
+ //#region src/changes/capture-schema-sql.d.ts
4
+ /**
5
+ * The change capture `models` need, as a migration writes it on a database without it: the change capture module, and
6
+ * the history and notices tables when a resource has history or live updates. The jobs schema it enqueues into is not
7
+ * part of it (`jobsSchemaSql`), nor are the rollups and formulas of `models` (`computedSchemaSql`).
8
+ */
9
+ export declare const captureSchemaSql: (models: readonly ResourceModel[], events?: EventsOptions) => string;
10
+ //#endregion
@@ -0,0 +1,21 @@
1
+ import { moduleDifference } from "../schema-modules/module-difference.js";
2
+ import { schemaModules, targetIds } from "../schema-modules/modules.js";
3
+ import { neededModules } from "../schema-modules/needed-modules.js";
4
+ //#region src/changes/capture-schema-sql.ts
5
+ /**
6
+ * The change capture `models` need, as a migration writes it on a database without it: the change capture module, and
7
+ * the history and notices tables when a resource has history or live updates. The jobs schema it enqueues into is not
8
+ * part of it (`jobsSchemaSql`), nor are the rollups and formulas of `models` (`computedSchemaSql`).
9
+ */
10
+ const captureSchemaSql = (models, events) => {
11
+ const targets = neededModules({
12
+ models,
13
+ views: [],
14
+ jobs: [],
15
+ signIn: false,
16
+ ...events && { events }
17
+ });
18
+ return targetIds(targets).filter((id) => id !== "jobs" && id !== "computed").map((id) => moduleDifference(schemaModules[id], targets[id], void 0).sql).join("\n\n");
19
+ };
20
+ //#endregion
21
+ export { captureSchemaSql };
@@ -1,22 +1,4 @@
1
- import { EventsOptions } from "./events-options.js";
2
- import { ResourceModel } from "@protobase/schema";
3
- import { Db } from "@protobase/query";
4
1
  //#region src/changes/capture-schema.d.ts
5
2
  /** The command that writes what the config needs as a migration file of the project. */
6
3
  export declare const migrationCommand = "protobase migration";
7
- /**
8
- * The SQL that brings the database to the capture the resources' events, history and live updates need: the schema
9
- * with the outbox and `capture()`, the history and notices tables, and a trigger pair per resource with any of them, recreated when its fields changed;
10
- * triggers of resources without any of them any more are dropped. `undefined` when the database is current. Tables are
11
- * never dropped. The tables of the `pending` resources are created by a migration written before this one.
12
- */
13
- export declare const changesMigration: (db: Db, models: readonly ResourceModel[], options?: EventsOptions, pending?: readonly string[]) => Promise<string | undefined>;
14
- /**
15
- * Refuses to go on while a resource's events, history or live updates would not be captured as declared: a missing or
16
- * out-of-date schema, history or notices table, or trigger. The server never changes the schema itself: the project's migrations do, before the
17
- * new version serves.
18
- */
19
- export declare const checkChanges: (db: Db, models: readonly ResourceModel[], options?: EventsOptions) => Promise<void>;
20
- /** What the server refuses to start with while the changes of the `missing` resources are not captured. */
21
- export declare const uncapturedMessage: (missing: readonly string[]) => string;
22
4
  //#endregion
@@ -1,78 +1,5 @@
1
- import { capturedBy, quoteIdent, tableSql } from "./capture-sql.js";
2
- import { historyIndexes } from "../history/history-sql.js";
3
- import { capturePlan, planSql, uncaptured } from "./capture-plan.js";
4
- import { changesSchema } from "./events-options.js";
5
- import { hasIndexes } from "../has-indexes.js";
6
- import { sql } from "kysely";
7
1
  //#region src/changes/capture-schema.ts
8
2
  /** The command that writes what the config needs as a migration file of the project. */
9
3
  const migrationCommand = "protobase migration";
10
- const triggerArgs = (hex) => {
11
- const bytes = new Uint8Array((hex.match(/../g) ?? []).map((pair) => parseInt(pair, 16)));
12
- return new TextDecoder().decode(bytes).split("\0").slice(0, -1);
13
- };
14
- const rowsOf = async (db, query) => (await query.execute(db)).rows;
15
- const readCaptureState = async (db, schema, models) => {
16
- const exists = async (table) => (await rowsOf(db, sql`select to_regclass(${`${quoteIdent(schema)}.${quoteIdent(table)}`}) is not null as found`))[0]?.found ?? false;
17
- const [capture] = await rowsOf(db, sql`select p.oid::text as oid, p.prosrc as source, p.prosecdef as definer from pg_proc p join pg_namespace n on n.oid = p.pronamespace where n.nspname = ${schema} and p.proname = 'capture' and p.pronargs = 0`);
18
- const tables = {};
19
- const views = [];
20
- for (const model of models) {
21
- const [found] = await rowsOf(db, sql`select c.oid::text as oid, c.relkind in ('v', 'm') as view from (select to_regclass(${tableSql(model)}) as oid) r left join pg_class c on c.oid = r.oid`);
22
- tables[model.name] = found?.oid ?? null;
23
- if (found?.view) views.push(model.name);
24
- }
25
- const oids = Object.values(tables).filter((oid) => oid !== null);
26
- const triggers = await rowsOf(db, sql`select t.tgrelid::text as "table", format('%I.%I', ns.nspname, c.relname) as "tableSql", t.tgname as name,
27
- t.tgfoid::text as "function", t.tgtype::int as type, encode(t.tgargs, 'hex') as args
28
- from pg_trigger t join pg_class c on c.oid = t.tgrelid join pg_namespace ns on ns.oid = c.relnamespace
29
- where not t.tgisinternal and (t.tgfoid::text = ${capture?.oid ?? ""} or t.tgrelid::text = any(${oids}::text[]))`);
30
- const outbox = await exists("outbox");
31
- const history = await exists("history");
32
- return {
33
- outbox,
34
- history,
35
- historyIndexed: history && await hasIndexes(db, schema, "history", historyIndexes.map(([name]) => name)),
36
- notices: await exists("notices"),
37
- ...capture && { capture },
38
- triggers: triggers.map((trigger) => ({
39
- ...trigger,
40
- args: triggerArgs(trigger.args)
41
- })),
42
- tables,
43
- views
44
- };
45
- };
46
- const plan = async (db, models, options, pending = []) => {
47
- const schema = changesSchema(options);
48
- return {
49
- schema,
50
- plan: capturePlan(schema, models, await readCaptureState(db, schema, models.filter(capturedBy(models))), pending)
51
- };
52
- };
53
- /**
54
- * The SQL that brings the database to the capture the resources' events, history and live updates need: the schema
55
- * with the outbox and `capture()`, the history and notices tables, and a trigger pair per resource with any of them, recreated when its fields changed;
56
- * triggers of resources without any of them any more are dropped. `undefined` when the database is current. Tables are
57
- * never dropped. The tables of the `pending` resources are created by a migration written before this one.
58
- */
59
- const changesMigration = async (db, models, options, pending = []) => {
60
- const { schema, plan: found } = await plan(db, models, options, pending);
61
- return planSql(schema, found);
62
- };
63
- /**
64
- * Refuses to go on while a resource's events, history or live updates would not be captured as declared: a missing or
65
- * out-of-date schema, history or notices table, or trigger. The server never changes the schema itself: the project's migrations do, before the
66
- * new version serves.
67
- */
68
- const checkChanges = async (db, models, options) => {
69
- if (!models.some(capturedBy(models))) return;
70
- const { plan: found } = await plan(db, models, options);
71
- const missing = uncaptured(found, models);
72
- if (missing.length === 0) return;
73
- throw new Error(uncapturedMessage(missing));
74
- };
75
- /** What the server refuses to start with while the changes of the `missing` resources are not captured. */
76
- const uncapturedMessage = (missing) => `The changes of ${missing.join(", ")} are not captured as their events, history or live updates need: their triggers, the history or notices table or the changes schema are missing or out of date. Write the change as a migration with \`${migrationCommand}\`, apply it with the project's migrations, then start again.`;
77
4
  //#endregion
78
- export { changesMigration, checkChanges, migrationCommand, uncapturedMessage };
5
+ export { migrationCommand };
@@ -30,25 +30,6 @@ const capturedBy = (models) => {
30
30
  const read = new Set(models.flatMap((model) => [...(model.derived ?? []).flatMap((value) => value.reads), ...model.liveReads ?? []]));
31
31
  return (model) => isCaptured(model) || read.has(model.name);
32
32
  };
33
- /**
34
- * The outbox: one row per changed row, written in the writer's transaction. `transaction` is the writer's transaction
35
- * id; `database_role` the role that wrote; `dispatch_after` holds back a change that the process which wrote it is
36
- * delivering itself. The `alter` adds the role to an outbox of an earlier version.
37
- */
38
- const outboxSql = (schema) => `create table if not exists ${quoteIdent(schema)}."outbox" (
39
- "id" bigint generated always as identity primary key,
40
- "transaction" bigint not null,
41
- "resource" text not null,
42
- "op" text not null,
43
- "old" jsonb,
44
- "new" jsonb,
45
- "changed" text[],
46
- "actor" jsonb,
47
- "database_role" text,
48
- "dispatch_after" timestamptz not null default now(),
49
- "created_at" timestamptz not null default now()
50
- );
51
- alter table ${quoteIdent(schema)}."outbox" add column if not exists "database_role" text`;
52
33
  /** The job that turns captured changes into events and deliveries: one per writing transaction, run one at a time. */
53
34
  const dispatchJobName = "changes.dispatch";
54
35
  /** Every dispatch job's group in its ordered queue, so only one runs at a time, across processes too. */
@@ -111,6 +92,14 @@ end
111
92
  const captureFunctionSql = (schema) => `create or replace function ${quoteIdent(schema)}."capture"() returns trigger language plpgsql security definer set search_path = pg_catalog, pg_temp as $capture$${captureBody(schema)}$capture$`;
112
93
  /** The columns that hold fields, each once: a relation's are the ones holding the other record's key. */
113
94
  const columnsOf = (fields) => [...new Set(fields.flatMap((field) => field.relation?.columns ?? [field.column]))];
95
+ const suffixed = (name, suffix) => `${identifier(name, 63 - new TextEncoder().encode(suffix).length)}${suffix}`;
96
+ /** The names of the two triggers on `table`: inserts and deletes, and updates. */
97
+ const triggerNames = (table) => [suffixed(table.name, "_changes"), suffixed(table.name, "_changes_update")];
98
+ /**
99
+ * The names an earlier version gave the triggers of a table whose name is too long for them, cut at 63 bytes so both
100
+ * were one name, that `triggerNames` no longer gives: dropped before the triggers are made.
101
+ */
102
+ const cutNames = (table) => [.../* @__PURE__ */ new Set([identifier(`${table.name}_changes`), identifier(`${table.name}_changes_update`)])].filter((name) => !triggerNames(table).includes(name));
114
103
  /**
115
104
  * The two triggers of a resource whose changes are captured: inserts and deletes, and updates that change the row. The
116
105
  * fields history ignores are left out of both, and an update fires only when it changes another's columns.
@@ -123,13 +112,14 @@ const resourceTriggers = (model) => {
123
112
  textArray(columnsOf(fields.filter((field) => !field.sensitive))),
124
113
  textArray(columnsOf(fields.filter((field) => field.sensitive)))
125
114
  ];
115
+ const [insertDelete, updateName] = triggerNames(model.table);
126
116
  const update = {
127
- name: identifier(`${model.table.name}_changes_update`),
117
+ name: updateName,
128
118
  type: 17,
129
119
  args
130
120
  };
131
121
  return [{
132
- name: identifier(`${model.table.name}_changes`),
122
+ name: insertDelete,
133
123
  type: 13,
134
124
  args
135
125
  }, ignored.length > 0 ? {
@@ -138,10 +128,13 @@ const resourceTriggers = (model) => {
138
128
  } : update];
139
129
  };
140
130
  const dropTriggerSql = (name, table) => `drop trigger if exists ${quoteIdent(name)} on ${table}`;
131
+ /**
132
+ * The condition an update must meet to fire a trigger that names `columns`: any column changed without them. Each
133
+ * column is compared on its own, as Postgres words a row comparison back, so the catalogue's condition reads the same.
134
+ */
141
135
  const rowsDiffer = (columns) => {
142
136
  if (!columns) return "old.* is distinct from new.*";
143
- const row = (side) => `(${columns.map((column) => `${side}.${quoteIdent(column)}`).join(", ")})`;
144
- return `${row("old")} is distinct from ${row("new")}`;
137
+ return columns.map((column) => `(old.${quoteIdent(column)} is distinct from new.${quoteIdent(column)})`).join(" or ");
145
138
  };
146
139
  const createTriggerSql = (schema, trigger, table) => {
147
140
  const timing = trigger.type & 16 ? "after update" : "after insert or delete";
@@ -149,5 +142,18 @@ const createTriggerSql = (schema, trigger, table) => {
149
142
  const args = trigger.args.map(quoteLiteral).join(", ");
150
143
  return `create trigger ${quoteIdent(trigger.name)} ${timing} on ${table} for each row${when} execute function ${quoteIdent(schema)}."capture"(${args})`;
151
144
  };
145
+ /** One resource's triggers, each dropped and made again, so a trigger of an earlier shape is replaced. */
146
+ const resourceCaptureSql = (schema, { table, triggers, replaces = [] }) => [...replaces.map((name) => `${dropTriggerSql(name, table)};`), ...triggers.flatMap((trigger) => [`${dropTriggerSql(trigger.name, table)};`, `${createTriggerSql(schema, trigger, table)};`])].join("\n");
147
+ /** What the triggers of `model` are made from. */
148
+ const resourceCapture = (model) => {
149
+ const replaces = cutNames(model.table);
150
+ return {
151
+ table: tableSql(model),
152
+ triggers: resourceTriggers(model),
153
+ ...replaces.length > 0 && { replaces }
154
+ };
155
+ };
156
+ /** Drops the triggers a resource on `table` had. */
157
+ const dropCaptureSql = (table) => [...cutNames(table), ...triggerNames(table)].map((name) => `${dropTriggerSql(name, qualified(table))};`).join("\n");
152
158
  //#endregion
153
- export { captureBody, captureFunctionSql, capturedBy, createTriggerSql, dispatchGroup, dispatchJobName, dropTriggerSql, identifier, isCaptured, outboxSql, quoteIdent, resourceTriggers, tableSql };
159
+ export { captureBody, captureFunctionSql, capturedBy, createTriggerSql, dispatchGroup, dispatchJobName, dropCaptureSql, dropTriggerSql, identifier, isCaptured, quoteIdent, resourceCapture, resourceCaptureSql, resourceTriggers, rowsDiffer, tableSql, triggerNames };
@@ -0,0 +1,36 @@
1
+ import { capturedBy, quoteIdent, resourceCapture } from "./capture-sql.js";
2
+ import { changesSchema } from "./events-options.js";
3
+ import { checkLiveReads } from "../check-live-reads.js";
4
+ //#region src/changes/changes-input.ts
5
+ const tableKey = ({ table }) => `${quoteIdent(table.schema ?? "public")}.${quoteIdent(table.name)}`;
6
+ const tableOf = ({ table }) => ({
7
+ ...table.schema !== void 0 && { schema: table.schema },
8
+ name: table.name
9
+ });
10
+ /**
11
+ * What the change capture module takes from the app: the changes schema `events` names, and the triggers of each of
12
+ * `models`, kept only for one whose changes are not captured (`capturedBy`), so its triggers follow its fields while
13
+ * older code may still capture it. Refuses two captured resources on one table, and live reads `checkLiveReads` refuses.
14
+ */
15
+ const changesInput = (models, events) => {
16
+ checkLiveReads(models);
17
+ const captured = capturedBy(models);
18
+ const tables = /* @__PURE__ */ new Map();
19
+ for (const model of models.filter(captured)) {
20
+ const other = tables.get(tableKey(model));
21
+ if (other) throw new Error(`Not implemented: resources "${other}" and "${model.name}" both have events or history on table ${tableKey(model)}; declare them on one`);
22
+ tables.set(tableKey(model), model.name);
23
+ }
24
+ const kept = models.filter((model) => !captured(model) && !tables.has(tableKey(model)));
25
+ const triggers = Object.fromEntries([...models.filter(captured), ...kept].map((model) => [model.name, {
26
+ table: tableOf(model),
27
+ input: resourceCapture(model),
28
+ ...!captured(model) && { kept: true }
29
+ }]));
30
+ return {
31
+ names: { schema: changesSchema(events) },
32
+ resources: { triggers }
33
+ };
34
+ };
35
+ //#endregion
36
+ export { changesInput };
@@ -0,0 +1,44 @@
1
+ import { captureFunctionSql, dropCaptureSql, resourceCaptureSql } from "./capture-sql.js";
2
+ import { readCapture } from "./read-capture.js";
3
+ import { outboxStep } from "./steps/001-outbox.js";
4
+ //#region src/changes/changes-module.ts
5
+ /**
6
+ * The triggers that capture one resource's changes. Kept on a resource that no longer needs them while another still
7
+ * does, so the code still running while the migration deploys, or the version before once rolled back, still captures
8
+ * it, as the dispatch job still drains the outbox; once none does, they go.
9
+ */
10
+ const triggers = {
11
+ name: "triggers",
12
+ title: "The triggers that capture the changes",
13
+ version: 1,
14
+ compatibleFrom: 1,
15
+ sql: (names, input) => resourceCaptureSql(names.schema, input),
16
+ drop: (_names, table) => dropCaptureSql(table),
17
+ keptWhileOthers: true
18
+ };
19
+ /**
20
+ * The change capture the resources' events, history, live updates and derived values need, in the schema `events`
21
+ * names (`names.schema`): the outbox, `capture()`, and each captured resource's triggers. Its tables are never dropped.
22
+ */
23
+ const changesModule = {
24
+ label: "the change capture",
25
+ title: "The change capture the resources' events and history need",
26
+ steps: [{
27
+ step: 1,
28
+ name: "outbox",
29
+ title: "The outbox of captured changes",
30
+ additive: true,
31
+ sql: (names) => outboxStep(names.schema)
32
+ }],
33
+ replaceables: [{
34
+ name: "capture",
35
+ title: "The function the triggers call, capture()",
36
+ version: 1,
37
+ compatibleFrom: 1,
38
+ sql: (names) => `${captureFunctionSql(names.schema)};`
39
+ }],
40
+ resourceReplaceables: [triggers],
41
+ read: readCapture(triggers)
42
+ };
43
+ //#endregion
44
+ export { changesModule };
@@ -0,0 +1,67 @@
1
+ import { captureBody, quoteIdent, rowsDiffer } from "./capture-sql.js";
2
+ import { resourceEntry } from "../schema-modules/resource-difference.js";
3
+ import { sql } from "kysely";
4
+ const rowsOf = async (db, query) => (await query.execute(db)).rows;
5
+ const triggerArgs = (hex) => {
6
+ const bytes = new Uint8Array((hex.match(/../g) ?? []).map((pair) => parseInt(pair, 16)));
7
+ return new TextDecoder().decode(bytes).split("\0").slice(0, -1);
8
+ };
9
+ const comparable = (condition) => condition.toLowerCase().replace(/["()\s]/g, "");
10
+ const condition = (trigger) => trigger.type & 16 ? rowsDiffer(trigger.columns) : "";
11
+ const sameTriggers = (found, wanted) => found.length === wanted.triggers.length && wanted.triggers.every((trigger) => found.some((one) => one.enabled && one.name === trigger.name && one.type === trigger.type && one.args.join("\0") === trigger.args.join("\0") && comparable(one.when) === comparable(condition(trigger))));
12
+ const readTriggers = async (db, captureOid) => (await rowsOf(db, sql`select n.nspname as schema, c.relname as table, t.tgname as name,
13
+ t.tgtype::int as type, encode(t.tgargs, 'hex') as args, t.tgenabled <> 'D' as enabled,
14
+ coalesce(substring(pg_get_triggerdef(t.oid) from ' WHEN (.*) EXECUTE FUNCTION '), '') as when
15
+ from pg_trigger t join pg_class c on c.oid = t.tgrelid join pg_namespace n on n.oid = c.relnamespace
16
+ where not t.tgisinternal and t.tgfoid::text = ${captureOid} order by n.nspname, c.relname, t.tgname`)).map((trigger) => ({
17
+ ...trigger,
18
+ args: triggerArgs(trigger.args)
19
+ }));
20
+ const onTable = (found, table) => found.table === table.name && (table.schema === void 0 || found.schema === table.schema);
21
+ /**
22
+ * The change capture as the database has it for `input`: step 1 once the outbox is there, `capture()` at its version
23
+ * when its body is the one this version writes, and each resource of the input whose table has triggers calling it,
24
+ * at the digest of its input when they are the ones it makes, enabled, else at none, so they are written again; and the
25
+ * triggers on other tables, by the resource they capture (`readTriggers`). Refuses an outbox of an earlier shape, which
26
+ * no step records.
27
+ */
28
+ const readCapture = (triggers) => async (db, input) => {
29
+ const schema = input.names.schema;
30
+ const [outbox] = await rowsOf(db, sql`select to_regclass(${`${quoteIdent(schema)}."outbox"`}) is not null as found,
31
+ exists (select from information_schema.columns where table_schema = ${schema} and table_name = 'outbox' and column_name = 'database_role') as role`);
32
+ if (!outbox.found) return;
33
+ if (!outbox.role) throw new Error(`The outbox of the change capture in schema "${schema}" lacks its database_role column, which no step of this version of Protobase records: bring it there with \`protobase migration\` and \`protobase migrate\` of Protobase 0.14.2 first, then run this command again`);
34
+ const [capture] = await rowsOf(db, sql`select p.oid::text as oid, p.prosrc as source, p.prosecdef as definer from pg_proc p join pg_namespace n on n.oid = p.pronamespace where n.nspname = ${schema} and p.proname = 'capture' and p.pronargs = 0`);
35
+ const current = capture && capture.definer && capture.source === captureBody(schema);
36
+ const found = capture ? await readTriggers(db, capture.oid) : [];
37
+ const entries = {};
38
+ for (const [key, given] of Object.entries(input.resources[triggers.name] ?? {})) {
39
+ const own = found.filter((one) => onTable(one, given.table));
40
+ if (own.length === 0) continue;
41
+ const entry = resourceEntry(triggers, input.names, given);
42
+ entries[key] = sameTriggers(own, given.input) ? entry : {
43
+ ...entry,
44
+ digest: ""
45
+ };
46
+ }
47
+ for (const one of found) {
48
+ const resource = one.args[0] ?? one.name;
49
+ if (entries[resource] || Object.values(input.resources[triggers.name] ?? {}).some((given) => onTable(one, given.table))) continue;
50
+ entries[resource] = {
51
+ version: triggers.version,
52
+ digest: "",
53
+ table: {
54
+ schema: one.schema,
55
+ name: one.table
56
+ }
57
+ };
58
+ }
59
+ return {
60
+ lastStep: 1,
61
+ replaceables: current ? { capture: 1 } : {},
62
+ names: input.names,
63
+ ...Object.keys(entries).length > 0 && { resources: { [triggers.name]: entries } }
64
+ };
65
+ };
66
+ //#endregion
67
+ export { readCapture };
@@ -0,0 +1,23 @@
1
+ import { quoteIdent } from "../capture-sql.js";
2
+ //#region src/changes/steps/001-outbox.ts
3
+ /**
4
+ * The outbox: one row per changed row, written in the writer's transaction. `transaction` is the writer's transaction
5
+ * id; `database_role` the role that wrote; `dispatch_after` holds back a change that the process which wrote it is
6
+ * delivering itself.
7
+ */
8
+ const outboxStep = (schema) => `create schema if not exists ${quoteIdent(schema)};
9
+ create table if not exists ${quoteIdent(schema)}."outbox" (
10
+ "id" bigint generated always as identity primary key,
11
+ "transaction" bigint not null,
12
+ "resource" text not null,
13
+ "op" text not null,
14
+ "old" jsonb,
15
+ "new" jsonb,
16
+ "changed" text[],
17
+ "actor" jsonb,
18
+ "database_role" text,
19
+ "dispatch_after" timestamptz not null default now(),
20
+ "created_at" timestamptz not null default now()
21
+ );`;
22
+ //#endregion
23
+ export { outboxStep };
@@ -0,0 +1,37 @@
1
+ import { sendFunctionSql, sendsSchema, sendsTableSql } from "./sends-schema-sql.js";
2
+ import { sql } from "kysely";
3
+ //#region src/channels/sends-module.ts
4
+ /** The `channels` schema as the database has it: step 1 once the sends table is there, and `send()` once it is. */
5
+ const readSends = async (db) => {
6
+ const { rows } = await sql`select to_regclass(${`${sendsSchema}.sends`}) is not null as table,
7
+ to_regprocedure(${`${sendsSchema}.send(text, text, text, jsonb)`}) is not null as send`.execute(db);
8
+ const found = rows[0];
9
+ if (!found.table) return;
10
+ return {
11
+ lastStep: 1,
12
+ replaceables: found.send ? { send: 1 } : {}
13
+ };
14
+ };
15
+ /** The `channels` schema of SQL's broadcasts to the record channels, and `channels.send()`. Never dropped. */
16
+ const channelSendsModule = {
17
+ label: `the ${sendsSchema} schema`,
18
+ title: "SQL's broadcasts to the record channels, channels.send()",
19
+ steps: [{
20
+ step: 1,
21
+ name: "sends",
22
+ title: "The sends table",
23
+ additive: true,
24
+ sql: () => sendsTableSql
25
+ }],
26
+ replaceables: [{
27
+ name: "send",
28
+ title: "The function SQL sends with, channels.send()",
29
+ version: 1,
30
+ compatibleFrom: 1,
31
+ sql: () => sendFunctionSql
32
+ }],
33
+ resourceReplaceables: [],
34
+ read: readSends
35
+ };
36
+ //#endregion
37
+ export { channelSendsModule };
@@ -8,7 +8,7 @@ const sendsSchema = "channels";
8
8
  * so that no other role, such as one of `/api/sb/rest/v1`'s, sends as the server; a trigger function that sends for
9
9
  * them is `security definer`.
10
10
  */
11
- const sendsSchemaSql = `create schema if not exists ${sendsSchema};
11
+ const sendsTableSql = `create schema if not exists ${sendsSchema};
12
12
 
13
13
  create table if not exists ${sendsSchema}.sends (
14
14
  id bigint generated always as identity primary key,
@@ -19,12 +19,12 @@ create table if not exists ${sendsSchema}.sends (
19
19
  sent_at timestamptz not null default now()
20
20
  );
21
21
 
22
- create index if not exists sends_sent_at on ${sendsSchema}.sends (sent_at);
23
-
24
- create or replace function ${sendsSchema}.send(resource text, key text, event text, payload jsonb) returns void
22
+ create index if not exists sends_sent_at on ${sendsSchema}.sends (sent_at);`;
23
+ /** `send()` at version 1 of `channelSendsModule`'s replaceable: a change to it bumps its version. */
24
+ const sendFunctionSql = `create or replace function ${sendsSchema}.send(resource text, key text, event text, payload jsonb) returns void
25
25
  language sql security definer set search_path = ''
26
26
  as $$ insert into ${sendsSchema}.sends (resource, key, event, payload) values (send.resource, send.key, send.event, send.payload) $$;
27
27
 
28
28
  revoke execute on function ${sendsSchema}.send(text, text, text, jsonb) from public;`;
29
29
  //#endregion
30
- export { sendsSchema, sendsSchemaSql };
30
+ export { sendFunctionSql, sendsSchema, sendsTableSql };
@@ -0,0 +1,30 @@
1
+ import { commentsIndexes, commentsTable, commentsTableSql } from "./comments-sql.js";
2
+ import { hasIndexes } from "../has-indexes.js";
3
+ import { relationFound } from "../relation-found.js";
4
+ //#region src/comments/comments-module.ts
5
+ /** The comments table as the database has it: step 1 once it is there with every index. Refuses one without them, which no step records. */
6
+ const readComments = async (db) => {
7
+ if (!await relationFound(db, "\"comments\".\"comments\"")) return;
8
+ if (!await hasIndexes(db, "comments", "comments", commentsIndexes.map(([name]) => name))) throw new Error(`The comments table ${commentsTable} 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`);
9
+ return {
10
+ lastStep: 1,
11
+ replaceables: {}
12
+ };
13
+ };
14
+ /** The comments table of the resources with `.comments()`, in a `comments` schema of its own. Never dropped. */
15
+ const commentsModule = {
16
+ label: "the comments table",
17
+ title: "The comments table of the resources with comments",
18
+ steps: [{
19
+ step: 1,
20
+ name: "comments",
21
+ title: "The comments table and its indexes",
22
+ additive: true,
23
+ sql: () => `create schema if not exists "comments";\n${commentsTableSql()};`
24
+ }],
25
+ replaceables: [],
26
+ resourceReplaceables: [],
27
+ read: readComments
28
+ };
29
+ //#endregion
30
+ export { commentsModule };
@@ -1,6 +1,3 @@
1
- import { hasIndexes } from "../has-indexes.js";
2
- import { migrationCommand } from "../changes/capture-schema.js";
3
- import { sql } from "kysely";
4
1
  //#region src/comments/comments-sql.ts
5
2
  /** The table the comments of every resource with `.comments()` are kept in, in a schema of its own. */
6
3
  const commentsTable = "\"comments\".\"comments\"";
@@ -27,23 +24,5 @@ const commentsTableSql = () => `create table if not exists ${commentsTable} (
27
24
  "created_at" timestamptz not null default now()
28
25
  );
29
26
  ${commentsIndexes.map(([name, columns]) => `create index if not exists "${name}" on ${commentsTable} (${columns})`).join(";\n")}`;
30
- const hasCommentsTable = async (db) => (await sql`select to_regclass('comments.comments') is not null as found`.execute(db)).rows[0].found;
31
- /**
32
- * The SQL that adds the `comments` schema and its table, or the indexes it lacks, `undefined` when it has them all. The
33
- * table is never dropped.
34
- */
35
- const commentsMigration = async (db) => {
36
- if (await hasCommentsTable(db) && await hasIndexes(db, "comments", "comments", commentsIndexes.map(([name]) => name))) return void 0;
37
- return `create schema if not exists "comments";\n\n${commentsTableSql()};`;
38
- };
39
- /**
40
- * Refuses to go on while a resource has `.comments()` and the database lacks their table; the project's migrations add
41
- * it. An index added since only speeds reads up, so a table without it still serves and `protobase migration` adds it.
42
- */
43
- const checkComments = async (db, models) => {
44
- if (!models.some((model) => model.comments)) return;
45
- if (await hasCommentsTable(db)) return;
46
- throw new Error(`The comments schema is missing, and resources with .comments() keep their comments in comments.comments. Write it as a migration with \`${migrationCommand}\`, apply it with the project's migrations, then start again.`);
47
- };
48
27
  //#endregion
49
- export { checkComments, commentsMigration, commentsTable, commentsTableSql };
28
+ export { commentsIndexes, commentsTable, commentsTableSql };
@@ -1 +1,5 @@
1
- import { ResourceModel } from "@protobase/schema";
1
+ import { ResourceModel } from "@protobase/schema";
2
+ //#region src/computed/buckets-sql.d.ts
3
+ /** The comment that marks a table as a time rollup Protobase keeps. */
4
+ export declare const bucketsCommentPrefix = "protobase time rollup: ";
5
+ //#endregion