@protobase/server 0.133.4 → 0.133.5

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.
@@ -30,7 +30,7 @@ const readCapture = (triggers) => async (db, input) => {
30
30
  const [outbox] = await rowsOf(db, sql`select to_regclass(${`${quoteIdent(schema)}."outbox"`}) is not null as found,
31
31
  exists (select from information_schema.columns where table_schema = ${schema} and table_name = 'outbox' and column_name = 'database_role') as role`);
32
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`);
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`);
34
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
35
  const current = capture && capture.definer && capture.source === captureBody(schema);
36
36
  const found = capture ? await readTriggers(db, capture.oid) : [];
@@ -5,7 +5,7 @@ import { relationFound } from "../relation-found.js";
5
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
6
  const readComments = async (db) => {
7
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`);
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`);
9
9
  return {
10
10
  lastStep: 1,
11
11
  replaceables: {}
@@ -49,7 +49,7 @@ const readDerived = async (db, input) => {
49
49
  const [found] = await rowsOf(db, sql`select to_regclass('derived.values') is not null as values,
50
50
  to_regclass('derived.reads') is not null and to_regclass('derived.declared') is not null and to_regclass('derived.versions') is not null and to_regclass('derived.pending') is not null as complete`);
51
51
  if (!found.values) return;
52
- if (!(found.complete && await hasIndexes(db, "derived", "reads", ["reads_match", "reads_value"]) && await hasIndexes(db, "derived", "pending", ["pending_value"]))) throw new Error("The derived schema lacks its versions sequence, pending table or indexes, which no step of this version of Protobase records: bring it there with `protobase migration` and `protobase migrate` of the Protobase release before this one first, then run this command again");
52
+ if (!(found.complete && await hasIndexes(db, "derived", "reads", ["reads_match", "reads_value"]) && await hasIndexes(db, "derived", "pending", ["pending_value"]))) throw new Error("The derived schema lacks its versions sequence, pending table or indexes, which no step of this version of Protobase records");
53
53
  const declared = (await rowsOf(db, sql`select "name" from "derived"."declared"`)).map((row) => row.name);
54
54
  const given = input.resources[values.name] ?? {};
55
55
  const entries = {};
@@ -8,7 +8,7 @@ const readHistory = async (db, { names }) => {
8
8
  const schema = names.schema;
9
9
  const { rows } = await sql`select to_regclass(${`${quoteIdent(schema)}."history"`}) is not null as found`.execute(db);
10
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`);
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`);
12
12
  return {
13
13
  lastStep: 1,
14
14
  replaceables: {},
@@ -47,7 +47,7 @@ const readJobs = async (db) => {
47
47
  const step = Object.entries(pgBossSteps).find(([, version]) => version === pgBoss)?.[0];
48
48
  const pinned = Object.values(pgBossSteps).at(-1);
49
49
  if (pgBoss > pinned) throw new Error(`The jobs schema is at pg-boss schema version ${pgBoss}, newer than the ${pinned} this version of Protobase records: upgrade Protobase`);
50
- if (step === void 0) throw new Error(`The jobs schema is at pg-boss schema version ${pgBoss}, which no step of this version of Protobase records: bring it to version ${pgBossSteps[1]} with \`protobase migration\` and \`protobase migrate\` of Protobase 0.14.2 first, then run this command again`);
50
+ if (step === void 0) throw new Error(`The jobs schema is at pg-boss schema version ${pgBoss}, which no step of this version of Protobase records`);
51
51
  const functions = await rows(db, `select obj_description(to_regprocedure(signature), 'pg_proc') as comment from unnest($1::text[]) with ordinality as s(signature, n) order by n`, [functionSignatures.map((signature) => `${jobsSchema}.${signature}`)]);
52
52
  return {
53
53
  lastStep: Number(step),
@@ -9,7 +9,7 @@ import { feedbackIndexes, feedbackTableSql } from "./feedback-schema.js";
9
9
  */
10
10
  const readMailFeedback = async (db) => {
11
11
  if (!await relationFound(db, feedbackTable)) return;
12
- if (!await hasIndexes(db, "mail", "feedback", feedbackIndexes.map(([name]) => name))) throw new Error(`The table ${feedbackTable} of mailFeedback lacks indexes 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`);
12
+ if (!await hasIndexes(db, "mail", "feedback", feedbackIndexes.map(([name]) => name))) throw new Error(`The table ${feedbackTable} of mailFeedback lacks indexes no step of this version of Protobase records`);
13
13
  return {
14
14
  lastStep: 1,
15
15
  replaceables: {}
@@ -6,7 +6,7 @@ import { unsubscribesIndexes, unsubscribesTableSql } from "./unsubscribe-schema.
6
6
  /** The opt-outs table as the database has it: step 1 once it is there with every index. Refuses one without them, which no step records. */
7
7
  const readUnsubscribes = async (db) => {
8
8
  if (!await relationFound(db, unsubscribesTable)) return;
9
- if (!await hasIndexes(db, "mail", "unsubscribes", unsubscribesIndexes.map(([name]) => name))) throw new Error(`The opt-outs table ${unsubscribesTable} 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
+ if (!await hasIndexes(db, "mail", "unsubscribes", unsubscribesIndexes.map(([name]) => name))) throw new Error(`The opt-outs table ${unsubscribesTable} lacks indexes no step of this version of Protobase records`);
10
10
  return {
11
11
  lastStep: 1,
12
12
  replaceables: {}
@@ -6,7 +6,6 @@ import { regclass } from "./schema.js";
6
6
  import { tableNames } from "./table-names.js";
7
7
  import { sql } from "kysely";
8
8
  //#region src/notifications/devices-module.ts
9
- const upgradeFirst = "with `protobase migration` and `protobase migrate` of Protobase 0.14.2 first, then run this command again";
10
9
  const kindChecksWithoutRelay = async (db, oid, names) => {
11
10
  const { rows } = await sql`select c.conname as name, pg_get_constraintdef(c.oid) as def from pg_constraint c
12
11
  join pg_attribute a on a.attrelid = c.conrelid and a.attnum = any(c.conkey)
@@ -25,7 +24,7 @@ const readDevices = async (db, input) => {
25
24
  const oid = await regclass(db, devices);
26
25
  if (oid === null) return;
27
26
  const numbers = await columnNumbers(db, oid, names);
28
- if (numbers.session_id === void 0 || (await kindChecksWithoutRelay(db, oid, names)).length > 0) throw new Error(`The devices table ${devices} was written before devices kept their session and could be relay devices, which no step of this version of Protobase records: bring it there ${upgradeFirst}`);
27
+ if (numbers.session_id === void 0 || (await kindChecksWithoutRelay(db, oid, names)).length > 0) throw new Error(`The devices table ${devices} was written before devices kept their session and could be relay devices, which no step of this version of Protobase records`);
29
28
  const missing = deviceColumns.find((column) => numbers[column] === void 0);
30
29
  if (missing !== void 0) throw new Error(`The devices table ${devices} has no column "${names.columns[missing]}": add it, or name the table's own with notifications: { devices: { columns: { ${missing}: ... } } } in protobase.config.ts`);
31
30
  if (!await uniqueOn(db, oid, numbers.token)) throw new Error(`The devices table ${devices} needs a unique index on its token column "${names.columns.token}" alone, which moving a device to the user who registers it relies on`);
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.133.4";
2
+ var version = "0.133.5";
3
3
  //#endregion
4
4
  export { version };
@@ -12,7 +12,7 @@ const readRealtimeRelay = async (db) => {
12
12
  (select count(*)::int from information_schema.columns where table_schema = ${relaySchema} and table_name = any(${[...spacedTables]}::text[]) and column_name = 'space') as spaced`.execute(db);
13
13
  const { found, spaced } = rows[0];
14
14
  if (found === 0) return;
15
- if (found < relayTables.length || spaced < spacedTables.length) throw new Error(`The ${relaySchema} schema lacks tables or columns 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`);
15
+ if (found < relayTables.length || spaced < spacedTables.length) throw new Error(`The ${relaySchema} schema lacks tables or columns no step of this version of Protobase records`);
16
16
  return {
17
17
  lastStep: 1,
18
18
  replaceables: {}
@@ -77,7 +77,7 @@ const readRelay = (members, organization) => async (db, input) => {
77
77
  const sessions = await sessionsCurrent(db, input.names.sessions);
78
78
  if (!state.table && !sessions) return;
79
79
  const version = state.comment?.match(/^Protobase realtime members (\d+)$/)?.[1];
80
- if (state.comment && Number(version) !== 3) throw new Error(`The functions that keep realtime.members are at ${version === void 0 ? "a version" : `version ${version}`} no step of this version of Protobase records: bring them to version 3 with \`protobase migration\` and \`protobase migrate\` of Protobase 0.14.2 first, then run this command again`);
80
+ if (state.comment && Number(version) !== 3) throw new Error(`The functions that keep realtime.members are at ${version === void 0 ? "a version" : `version ${version}`} no step of this version of Protobase records`);
81
81
  const found = await readTriggers(db);
82
82
  const given = Object.entries(input.resources[members.name] ?? {});
83
83
  const rels = await regclassText(db, given.map(([, { input: listed }]) => listed.table));
@@ -32,7 +32,7 @@ export type ModulesModel = Partial<Record<SchemaModuleId, ModuleModel>>;
32
32
  /** The schema modules an app needs, each with what it gives the module (`neededModules`), in their order. */
33
33
  export type ModuleTargets = Partial<Record<SchemaModuleId, ModuleInput>>;
34
34
  /** The modules of `targets`, in their order. */
35
- export declare const targetIds: (targets: ModuleTargets) => ("status" | "query" | "user_tables" | "history" | "comments" | "derived" | "jobs" | "changes" | "mail_feedback" | "calls" | "webhooks" | "webhook_delivery_log" | "workflows" | "workflow_custom_steps" | "computed" | "change_stream" | "notices" | "workflow_storage" | "notification_devices" | "notification_history" | "relay" | "realtime_relay" | "channel_sends" | "unsubscribes")[];
35
+ export declare const targetIds: (targets: ModuleTargets) => ("status" | "query" | "user_tables" | "history" | "comments" | "derived" | "jobs" | "changes" | "mail_feedback" | "calls" | "workflows" | "workflow_custom_steps" | "webhooks" | "webhook_delivery_log" | "computed" | "change_stream" | "notices" | "workflow_storage" | "notification_devices" | "notification_history" | "relay" | "realtime_relay" | "channel_sends" | "unsubscribes")[];
36
36
  /** The model of each module of `targets` this version of Protobase reads. */
37
37
  export declare const latestModules: (targets: ModuleTargets) => ModulesModel;
38
38
  //#endregion
@@ -27,7 +27,7 @@ const userTablesModule = {
27
27
  read: async (db) => {
28
28
  const found = await readUserTablesSchema(db);
29
29
  if (!found.tables) return;
30
- if (!userTablesCurrent(found)) throw new Error(`The ${definitionsSchema} schema lacks the default of a definition's version, a definition's organization, the position index of its fields, the ${userTablesSchema} schema or pg_trgm, which no step of this version of Protobase records: bring it there with \`protobase migration\` and \`protobase migrate\` of the Protobase release before this one first, then run this command again`);
30
+ if (!userTablesCurrent(found)) throw new Error(`The ${definitionsSchema} schema lacks the default of a definition's version, a definition's organization, the position index of its fields, the ${userTablesSchema} schema or pg_trgm, which no step of this version of Protobase records`);
31
31
  return {
32
32
  lastStep: 1,
33
33
  replaceables: {}
@@ -7,7 +7,7 @@ import { relationFound } from "../../relation-found.js";
7
7
  const readDeliveryLog = async (db, { names }) => {
8
8
  const schema = names.schema;
9
9
  if (!await relationFound(db, `${quoteIdent(schema)}."delivery_log"`)) return;
10
- if (!await hasIndexes(db, schema, "delivery_log", deliveryLogIndexes)) throw new Error(`The delivery log 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`);
10
+ if (!await hasIndexes(db, schema, "delivery_log", deliveryLogIndexes)) throw new Error(`The delivery log in schema "${schema}" lacks indexes no step of this version of Protobase records`);
11
11
  return {
12
12
  lastStep: 1,
13
13
  replaceables: {},
@@ -84,7 +84,7 @@ export declare const webhooksModule: (options?: WebhooksOptions) => {
84
84
  readonly tenant_id: import("@protobase/schema").Field<string | null>;
85
85
  readonly event_type: import("@protobase/schema").Field<string>;
86
86
  readonly event_id: import("@protobase/schema").Field<string>;
87
- readonly status: import("@protobase/schema").Field<"waiting" | "failed">;
87
+ readonly status: import("@protobase/schema").Field<"failed" | "waiting">;
88
88
  readonly attempt: import("@protobase/schema").Field<number>;
89
89
  readonly next_attempt: import("@protobase/schema").Field<string | null>;
90
90
  readonly last_error: import("@protobase/schema").Field<string | null>;
@@ -97,7 +97,7 @@ export declare const webhooksModule: (options?: WebhooksOptions) => {
97
97
  readonly tenant_id: import("@protobase/schema").Field<string | null>;
98
98
  readonly event_type: import("@protobase/schema").Field<string>;
99
99
  readonly event_id: import("@protobase/schema").Field<string>;
100
- readonly status: import("@protobase/schema").Field<"waiting" | "failed">;
100
+ readonly status: import("@protobase/schema").Field<"failed" | "waiting">;
101
101
  readonly attempt: import("@protobase/schema").Field<number>;
102
102
  readonly next_attempt: import("@protobase/schema").Field<string | null>;
103
103
  readonly last_error: import("@protobase/schema").Field<string | null>;
@@ -5,7 +5,6 @@ import { relationFound } from "../../relation-found.js";
5
5
  import { sql } from "kysely";
6
6
  //#region src/webhooks/table/webhooks-schema-module.ts
7
7
  const functionNames = ["subscription_commands", "deliveries_resend"];
8
- const upgradeFirst = "with `protobase migration` and `protobase migrate` of Protobase 0.14.2 first, then run this command again";
9
8
  /**
10
9
  * The functions' version, from the oldest version their comments name, `undefined` when one of them or the deliveries
11
10
  * view is missing, so they are written again as new. Refuses a version newer than this version of Protobase writes.
@@ -27,7 +26,7 @@ const readFunctions = async (db, schema) => {
27
26
  const readWebhooks = async (db, { names }) => {
28
27
  const schema = names.schema;
29
28
  if (!await relationFound(db, `${quoteIdent(schema)}."subscriptions"`)) return;
30
- if (!await hasIndexes(db, schema, "subscriptions", subscriptionsIndexes)) throw new Error(`The subscriptions table in schema "${schema}" lacks indexes no step of this version of Protobase records: add them ${upgradeFirst}`);
29
+ if (!await hasIndexes(db, schema, "subscriptions", subscriptionsIndexes)) throw new Error(`The subscriptions table in schema "${schema}" lacks indexes no step of this version of Protobase records`);
31
30
  return {
32
31
  lastStep: 1,
33
32
  replaceables: await readFunctions(db, schema),
@@ -16,7 +16,7 @@ const readCustomSteps = async (db, { names }) => {
16
16
  const schema = names.schema;
17
17
  const tables = [...customStepsTables, ...runnersTables];
18
18
  if (!await tablesFound(db, schema, tables.slice(0, 1))) return;
19
- if (!await tablesFound(db, schema, tables)) throw new Error(`The custom steps' tables in schema "${schema}" are not all there, which 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`);
19
+ if (!await tablesFound(db, schema, tables)) throw new Error(`The custom steps' tables in schema "${schema}" are not all there, which no step of this version of Protobase records`);
20
20
  return {
21
21
  lastStep: 1,
22
22
  replaceables: await triggersFound(db, schema, triggers) ? { functions: 1 } : {},
@@ -280,7 +280,7 @@ export declare const workflowsModule: (options?: Pick<WorkflowsOptions, "schema"
280
280
  readonly version: import("@protobase/schema").Field<number | null>;
281
281
  readonly input: import("@protobase/schema").Field<import("zod").JSONType>;
282
282
  readonly key: import("@protobase/schema").Field<string | null>;
283
- readonly status: import("@protobase/schema").Field<"waiting" | "failed" | "queued" | "running" | "succeeded">;
283
+ readonly status: import("@protobase/schema").Field<"failed" | "queued" | "running" | "waiting" | "succeeded">;
284
284
  readonly output: import("@protobase/schema").Field<import("zod").JSONType>;
285
285
  readonly error: import("@protobase/schema").Field<string | null>;
286
286
  readonly cause: import("@protobase/schema").Field<string | null>;
@@ -306,7 +306,7 @@ export declare const workflowsModule: (options?: Pick<WorkflowsOptions, "schema"
306
306
  readonly version: import("@protobase/schema").Field<number | null>;
307
307
  readonly input: import("@protobase/schema").Field<import("zod").JSONType>;
308
308
  readonly key: import("@protobase/schema").Field<string | null>;
309
- readonly status: import("@protobase/schema").Field<"waiting" | "failed" | "queued" | "running" | "succeeded">;
309
+ readonly status: import("@protobase/schema").Field<"failed" | "queued" | "running" | "waiting" | "succeeded">;
310
310
  readonly output: import("@protobase/schema").Field<import("zod").JSONType>;
311
311
  readonly error: import("@protobase/schema").Field<string | null>;
312
312
  readonly cause: import("@protobase/schema").Field<string | null>;
@@ -13,7 +13,7 @@ const readWorkflows = async (db, { names }) => {
13
13
  if (!await tablesFound(db, schema, ["runs"])) return;
14
14
  const version = commentVersion(await functionComment(db, schema, "run_version"));
15
15
  if (version !== void 0 && version > 28) throw new Error(`The ${schema} schema is at version ${version}, newer than the 28 this version of Protobase writes: upgrade Protobase`);
16
- if (version !== 28 || !await tablesFound(db, schema, ["triggers"])) throw new Error(`The ${schema} schema is at ${version === void 0 ? "a version" : `version ${version}`} no step of this version of Protobase records: bring it to version 28 with \`protobase migration\` and \`protobase migrate\` of Protobase 0.14.2 first, then run this command again`);
16
+ if (version !== 28 || !await tablesFound(db, schema, ["triggers"])) throw new Error(`The ${schema} schema is at ${version === void 0 ? "a version" : `version ${version}`} no step of this version of Protobase records`);
17
17
  return {
18
18
  lastStep: 1,
19
19
  replaceables: await triggersFound(db, schema, [...workflowsTriggers, ...statusTriggers]) ? { functions: 28 } : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.133.4",
3
+ "version": "0.133.5",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -44,11 +44,11 @@
44
44
  "@better-auth/sso": "^1.7.12",
45
45
  "@livekit/protocol": "1.53.1",
46
46
  "@modelcontextprotocol/server": "^2.3.1",
47
- "@protobase/layout": "0.133.4",
48
- "@protobase/query": "0.133.4",
49
- "@protobase/schema": "0.133.4",
50
- "@protobase/workflow-plugins": "0.133.4",
51
- "@protobase/workflows": "0.133.4",
47
+ "@protobase/layout": "0.133.5",
48
+ "@protobase/query": "0.133.5",
49
+ "@protobase/schema": "0.133.5",
50
+ "@protobase/workflow-plugins": "0.133.5",
51
+ "@protobase/workflows": "0.133.5",
52
52
  "@react-email/render": "^2.1.0",
53
53
  "@react-pdf/primitives": "^4.4.0",
54
54
  "@react-pdf/renderer": "^4.9.1",