@protobase/cli 0.102.2 → 0.102.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/register.js +7 -2
- package/dist/cli/package.js +1 -1
- package/dist/doctor/run.js +9 -1
- package/dist/doctor/startup.js +41 -0
- package/dist/main.js +3 -2
- package/dist/serve/lifecycle.js +3 -19
- package/dist/serve/startup-checks.js +30 -0
- package/dist/users/load-auth.d.ts +1 -7
- package/dist/users/load-auth.js +13 -7
- package/package.json +8 -8
- package/skills/protobase/references/features/build-and-run.md +1 -0
- package/skills/protobase/references/features/start-a-project.md +1 -1
- package/skills/protobase/references/guides/deploy.md +23 -1
- package/skills/protobase/references/reference/blocks.md +4 -4
- package/skills/protobase/references/reference/cli.md +3 -1
- package/skills/protobase-cloud/SKILL.md +3 -1
package/dist/auth/register.js
CHANGED
|
@@ -3,9 +3,14 @@ import path from "node:path";
|
|
|
3
3
|
const out = (text) => process.stdout.write(text);
|
|
4
4
|
const registerAuth = (program) => {
|
|
5
5
|
program.command("auth").description("The auth schema of the project in the current directory").command("migration").description("Write the auth schema changes this Protobase version needs as the project's next SQL migration, compared with its database").option("--dir <dir>", "migrations folder", "db/migrations").option("--name <name>", "file name after the number", "auth").action(async (opts) => {
|
|
6
|
-
const [{
|
|
6
|
+
const [{ loadSignIn }, { writeAuthMigration }] = await Promise.all([import("../users/load-auth.js"), import("./write-migration.js")]);
|
|
7
|
+
const auth = await loadSignIn(process.cwd());
|
|
8
|
+
if (!auth) {
|
|
9
|
+
out("sign-in is off in the project's config; nothing to write\n");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
7
12
|
const file = await writeAuthMigration({
|
|
8
|
-
auth
|
|
13
|
+
auth,
|
|
9
14
|
dir: path.resolve(opts.dir),
|
|
10
15
|
name: opts.name
|
|
11
16
|
});
|
package/dist/cli/package.js
CHANGED
package/dist/doctor/run.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { userTablesOn } from "../config/user-tables-config.js";
|
|
2
2
|
import { loadSourceConfig } from "../config/source-config.js";
|
|
3
|
+
import { openAppDatabase } from "../project/pg-db.js";
|
|
3
4
|
import { connect } from "../db/connect.js";
|
|
4
5
|
import { introspect } from "../db/introspect.js";
|
|
5
6
|
import { loadDataConfig } from "../project/load-data-config.js";
|
|
@@ -11,9 +12,11 @@ import { unplannedBlocks } from "./page-shapes.js";
|
|
|
11
12
|
import { readShapes } from "./read-shapes.js";
|
|
12
13
|
import { relationIssues } from "./relation-issues.js";
|
|
13
14
|
import { sortIssues } from "./sort-issues.js";
|
|
15
|
+
import { checkServerStartup } from "./startup.js";
|
|
14
16
|
import { userTableModels } from "./user-table-models.js";
|
|
15
17
|
import { existsSync } from "node:fs";
|
|
16
18
|
import path from "node:path";
|
|
19
|
+
import pg from "pg";
|
|
17
20
|
import { tableIndexes } from "@protobase/query";
|
|
18
21
|
//#region src/doctor/run.ts
|
|
19
22
|
const format = (issue) => ` ${issue.severity.padEnd(7)} ${issue.resource}: ${issue.message}${issue.suggestion ? `\n fix: ${issue.suggestion}` : ""}\n`;
|
|
@@ -51,8 +54,13 @@ const runDoctor = async (options, out) => {
|
|
|
51
54
|
const byName = Object.fromEntries(models.map((model) => [model.name, model]));
|
|
52
55
|
for (const block of config.pages.flatMap((page) => unplannedBlocks(page, byName))) out(` note ${block} declares no reads, so it is outside the page's read plan and reads whatever it reads once it draws\n`);
|
|
53
56
|
const errors = issues.filter((i) => i.severity === "error").length;
|
|
57
|
+
const startup = options.startupChecks === true && errors === 0;
|
|
58
|
+
if (startup) {
|
|
59
|
+
const database = openAppDatabase(pg, options.url);
|
|
60
|
+
await checkServerStartup(source, database).finally(() => database.db.destroy());
|
|
61
|
+
}
|
|
54
62
|
const counted = userTables.models.length > 0 ? `${config.models.length} resources, ${userTables.models.length} user tables` : `${config.models.length} resources`;
|
|
55
|
-
out(`Checked ${builtIn.models.length > 0 ? `${counted} and ${builtIn.models.length} built-in ones` : counted}: ${errors} errors, ${issues.length - errors} warnings.\n`);
|
|
63
|
+
out(`Checked ${builtIn.models.length > 0 ? `${counted} and ${builtIn.models.length} built-in ones` : counted}${startup ? " and the server's startup checks" : ""}: ${errors} errors, ${issues.length - errors} warnings.\n`);
|
|
56
64
|
return {
|
|
57
65
|
errors,
|
|
58
66
|
warnings: issues.length - errors,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { buildProject } from "../config/build-project.js";
|
|
2
|
+
import { servedAdmin } from "../project/served-admin.js";
|
|
3
|
+
import { checkStartup } from "../serve/startup-checks.js";
|
|
4
|
+
import { checkJobsSchema } from "@protobase/server";
|
|
5
|
+
import { readOrigins, readPasskeyDomain } from "@protobase/server/internal";
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
7
|
+
//#region src/doctor/startup.ts
|
|
8
|
+
/**
|
|
9
|
+
* The app's URL, or a stand-in that sign-in accepts: on the passkey domain when the config or `PROTOBASE_PASSKEY_DOMAIN`
|
|
10
|
+
* names one, since it must be the host of one of the app's origins, and on localhost otherwise; with the scheme of the
|
|
11
|
+
* app's other origins (`auth.origins` or `PROTOBASE_ORIGINS`), which must share the URL's, and https or http without them.
|
|
12
|
+
*/
|
|
13
|
+
const startupUrl = (config, env) => {
|
|
14
|
+
if (config.url) return config.url;
|
|
15
|
+
const auth = config.auth || {};
|
|
16
|
+
const passkeyDomain = auth.passkeyDomain ?? readPasskeyDomain(env);
|
|
17
|
+
const origin = (auth.origins ?? readOrigins(env))[0];
|
|
18
|
+
return `${origin ? new URL(origin).protocol : passkeyDomain ? "https:" : "http:"}//${passkeyDomain ?? "localhost"}`;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Builds the app from its config over `database` as `serve` does and runs the server's startup checks of the database,
|
|
22
|
+
* its jobs schema included, so doctor refuses what the server would refuse to start on, with the server's own message.
|
|
23
|
+
* The environment's settings, such as the assistant's key, are the running app's and are not checked here; sign-in is
|
|
24
|
+
* built only to read its store, so without the app's URL and secret it gets stand-ins for them (`startupUrl`).
|
|
25
|
+
* It checks the app as `serve` runs it, from protobase.config.ts and the convention's config folder, whatever folder
|
|
26
|
+
* doctor's own checks read.
|
|
27
|
+
*/
|
|
28
|
+
const checkServerStartup = async (config, database) => {
|
|
29
|
+
const readOnly = {
|
|
30
|
+
...config,
|
|
31
|
+
url: startupUrl(config, process.env),
|
|
32
|
+
secret: config.secret ?? randomBytes(32).toString("base64")
|
|
33
|
+
};
|
|
34
|
+
const project = await buildProject(readOnly, database);
|
|
35
|
+
await checkStartup(project, database.db);
|
|
36
|
+
const { admin, jobs } = await servedAdmin(project, database.db);
|
|
37
|
+
await admin.stopHolding();
|
|
38
|
+
if (jobs.length > 0) await checkJobsSchema(database.db);
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { checkServerStartup, startupUrl };
|
package/dist/main.js
CHANGED
|
@@ -50,14 +50,15 @@ program.command("scaffold").description("Generate or update config/<resource>/da
|
|
|
50
50
|
excludes: opts.exclude
|
|
51
51
|
}, out);
|
|
52
52
|
});
|
|
53
|
-
program.command("doctor").description("Check a config folder against the database").argument("[connection]", "connection string (default: DATABASE_URL from the environment or .env)").option("--env <variable>", "read the connection string from this environment variable").option("--config <dir>", "config folder", "config").action(async (connection, opts) => {
|
|
53
|
+
program.command("doctor").description("Check a config folder against the database, and the database against the server's startup checks").argument("[connection]", "connection string (default: DATABASE_URL from the environment or .env)").option("--env <variable>", "read the connection string from this environment variable").option("--config <dir>", "config folder", "config").action(async (connection, opts) => {
|
|
54
54
|
loadNearestEnvFile(process.cwd());
|
|
55
55
|
const url = resolveConnectionUrl(connection, opts.env);
|
|
56
56
|
const { runDoctor } = await import("./doctor/run.js");
|
|
57
57
|
const { errors } = await runDoctor({
|
|
58
58
|
url,
|
|
59
59
|
configDir: path.resolve(opts.config),
|
|
60
|
-
projectDir: process.cwd()
|
|
60
|
+
projectDir: process.cwd(),
|
|
61
|
+
startupChecks: true
|
|
61
62
|
}, out);
|
|
62
63
|
if (errors > 0) process.exitCode = 1;
|
|
63
64
|
});
|
package/dist/serve/lifecycle.js
CHANGED
|
@@ -7,10 +7,11 @@ import { withClientAddress } from "./client-address.js";
|
|
|
7
7
|
import { createServeApp } from "./app.js";
|
|
8
8
|
import { startCleanupTimer } from "./cleanup-timer.js";
|
|
9
9
|
import { serverCloser } from "./close-server.js";
|
|
10
|
+
import { checkStartup } from "./startup-checks.js";
|
|
10
11
|
import { closeSockets } from "./close-sockets.js";
|
|
11
12
|
import { servedRelease } from "./mobile-release.js";
|
|
12
13
|
import pg from "pg";
|
|
13
|
-
import {
|
|
14
|
+
import { backgroundSettled, checkAi, checkJobsSchema, configExports, createFileCleanup, startJobs } from "@protobase/server";
|
|
14
15
|
import { createAdaptorServer, upgradeWebSocket } from "@hono/node-server";
|
|
15
16
|
//#region src/serve/lifecycle.ts
|
|
16
17
|
const listen = (server, port, host) => new Promise((resolve, reject) => {
|
|
@@ -28,31 +29,14 @@ const startServe = async ({ config, env, openDb = (url) => openAppDatabase(pg, u
|
|
|
28
29
|
const { db } = database;
|
|
29
30
|
const startJobsAndListen = async () => {
|
|
30
31
|
const project = await buildProject(config, database);
|
|
31
|
-
if (env.startupChecks
|
|
32
|
+
if (env.startupChecks) await checkStartup(project, db);
|
|
32
33
|
const { resources, views } = configExports(project.config);
|
|
33
|
-
if (env.startupChecks && project.auth) await checkResourcesOutsideAuthStore(db, resources.map((resource) => resource.toModel()), project.auth);
|
|
34
|
-
if (env.startupChecks) await checkChanges(db, resources.map((resource) => resource.toModel()), project.events);
|
|
35
|
-
if (env.startupChecks) await checkComments(db, resources.map((resource) => resource.toModel()));
|
|
36
|
-
if (env.startupChecks) await checkDerived(db, resources.map((resource) => resource.toModel()));
|
|
37
|
-
if (env.startupChecks) await checkCalls(db, project.calls, project.events);
|
|
38
|
-
if (env.startupChecks) await checkComputed(db, resources.map((resource) => resource.toModel()));
|
|
39
|
-
if (env.startupChecks && assistantSettings(project.options?.assistant, process.env)?.kind === "built-in") await checkQueryRunner(db, project.auth ? authStoreTables(project.auth) : {
|
|
40
|
-
tables: [],
|
|
41
|
-
schemas: []
|
|
42
|
-
});
|
|
43
34
|
if (env.startupChecks) checkAi({
|
|
44
35
|
models: resources.map((resource) => resource.toModel()),
|
|
45
36
|
views: views.map((source) => source.toModel()),
|
|
46
37
|
assistant: project.options?.assistant,
|
|
47
38
|
env: process.env
|
|
48
39
|
});
|
|
49
|
-
if (env.startupChecks && project.webhooks) await checkWebhooksSchema(db, project.webhooks);
|
|
50
|
-
if (env.startupChecks && project.workflows) await checkWorkflowsSchema(db, project.workflows);
|
|
51
|
-
if (env.startupChecks && relayed(project.realtime)) await checkRealtimeRelay(db);
|
|
52
|
-
if (env.startupChecks && sqlSends(project.realtime)) await checkChannelSends(db);
|
|
53
|
-
if (env.startupChecks && project.notifications) await checkNotificationsSchema(db, project.notifications, project.auth);
|
|
54
|
-
if (env.startupChecks && project.status) await checkStatusSchema(db, project.status, project.auth);
|
|
55
|
-
if (env.startupChecks && project.userTables) await checkUserTablesSchema(db);
|
|
56
40
|
const { admin, jobs: definitions } = await servedAdmin(project, db, ui, reporter, upgradeWebSocket);
|
|
57
41
|
if (env.startupChecks && definitions.length > 0) await checkJobsSchema(db);
|
|
58
42
|
const jobs = definitions.length > 0 ? await startJobs({
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { assistantSettings, authStoreTables, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkStatusSchema, checkUserTablesSchema, checkWebhooksSchema, checkWorkflowsSchema, configExports, relayed, sqlSends } from "@protobase/server";
|
|
2
|
+
//#region src/serve/startup-checks.ts
|
|
3
|
+
/**
|
|
4
|
+
* The server's startup checks of the database: each throws, with what to write as a migration, while a schema the
|
|
5
|
+
* project's features need is missing or behind. They only read. `serve` runs them before it builds the admin, and
|
|
6
|
+
* `protobase doctor` runs them too, so a change that would not start fails wherever doctor runs.
|
|
7
|
+
*/
|
|
8
|
+
const checkStartup = async (project, db) => {
|
|
9
|
+
const models = configExports(project.config).resources.map((resource) => resource.toModel());
|
|
10
|
+
if (project.auth) await checkAuthSchema(project.auth);
|
|
11
|
+
if (project.auth) await checkResourcesOutsideAuthStore(db, models, project.auth);
|
|
12
|
+
await checkChanges(db, models, project.events);
|
|
13
|
+
await checkComments(db, models);
|
|
14
|
+
await checkDerived(db, models);
|
|
15
|
+
await checkCalls(db, project.calls, project.events);
|
|
16
|
+
await checkComputed(db, models);
|
|
17
|
+
if (assistantSettings(project.options?.assistant, process.env)?.kind === "built-in") await checkQueryRunner(db, project.auth ? authStoreTables(project.auth) : {
|
|
18
|
+
tables: [],
|
|
19
|
+
schemas: []
|
|
20
|
+
});
|
|
21
|
+
if (project.webhooks) await checkWebhooksSchema(db, project.webhooks);
|
|
22
|
+
if (project.workflows) await checkWorkflowsSchema(db, project.workflows);
|
|
23
|
+
if (relayed(project.realtime)) await checkRealtimeRelay(db);
|
|
24
|
+
if (sqlSends(project.realtime)) await checkChannelSends(db);
|
|
25
|
+
if (project.notifications) await checkNotificationsSchema(db, project.notifications, project.auth);
|
|
26
|
+
if (project.status) await checkStatusSchema(db, project.status, project.auth);
|
|
27
|
+
if (project.userTables) await checkUserTablesSchema(db);
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { checkStartup };
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { AdminAuth } from "@protobase/server";
|
|
2
2
|
//#region src/users/load-auth.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* The sign-in of the project in `projectDir`, built from its config's `auth` over DATABASE_URL, with only the plugins
|
|
5
|
-
* it turns on. With a device or history store of the app's own (notifications/store.ts, notifications/history-store.ts),
|
|
6
|
-
* deleting a user removes their devices or history from it too; the built-in tables go with the user by their foreign
|
|
7
|
-
* keys. With workflows, deleting a user revokes their connected accounts and parks the triggers on them, as the app
|
|
8
|
-
* does, reporting a token it left valid on stderr.
|
|
9
|
-
*/
|
|
3
|
+
/** The project's sign-in (`loadSignIn`), refused when it is off, for the commands that manage its users. */
|
|
10
4
|
export declare const loadProjectAuth: (projectDir: string) => Promise<AdminAuth>;
|
|
11
5
|
//#endregion
|
package/dist/users/load-auth.js
CHANGED
|
@@ -8,15 +8,15 @@ import { releaseConnectionsWithUsers, removeDevicesWithUsers, removeHistoryWithU
|
|
|
8
8
|
//#region src/users/load-auth.ts
|
|
9
9
|
/**
|
|
10
10
|
* The sign-in of the project in `projectDir`, built from its config's `auth` over DATABASE_URL, with only the plugins
|
|
11
|
-
* it turns on. With a device or history store of the app's own (notifications/store.ts,
|
|
12
|
-
* deleting a user removes their devices or history from it too; the built-in tables go
|
|
13
|
-
* keys. With workflows, deleting a user revokes their connected accounts and parks the
|
|
14
|
-
* does, reporting a token it left valid on stderr.
|
|
11
|
+
* it turns on; `undefined` when sign-in is off. With a device or history store of the app's own (notifications/store.ts,
|
|
12
|
+
* notifications/history-store.ts), deleting a user removes their devices or history from it too; the built-in tables go
|
|
13
|
+
* with the user by their foreign keys. With workflows, deleting a user revokes their connected accounts and parks the
|
|
14
|
+
* triggers on them, as the app does, reporting a token it left valid on stderr.
|
|
15
15
|
*/
|
|
16
|
-
const
|
|
16
|
+
const loadSignIn = async (projectDir) => {
|
|
17
17
|
loadNearestEnvFile(projectDir);
|
|
18
18
|
const config = await loadSourceConfig(projectDir, { command: "tool" });
|
|
19
|
-
if (!config.auth)
|
|
19
|
+
if (!config.auth) return;
|
|
20
20
|
if (!process.env.DATABASE_URL) throw new Error("No database: set DATABASE_URL");
|
|
21
21
|
const database = openAppDatabase(pg, process.env.DATABASE_URL);
|
|
22
22
|
const [workflows, notifications] = await Promise.all([projectWorkflows(config), projectNotifications(config)]);
|
|
@@ -29,5 +29,11 @@ const loadProjectAuth = async (projectDir) => {
|
|
|
29
29
|
if (notifications?.historyStore) removeHistoryWithUsers(auth, notifications.historyStore);
|
|
30
30
|
return auth;
|
|
31
31
|
};
|
|
32
|
+
/** The project's sign-in (`loadSignIn`), refused when it is off, for the commands that manage its users. */
|
|
33
|
+
const loadProjectAuth = async (projectDir) => {
|
|
34
|
+
const auth = await loadSignIn(projectDir);
|
|
35
|
+
if (!auth) throw new Error("Sign-in is off (`auth: false` in the config), so the app has no users to manage");
|
|
36
|
+
return auth;
|
|
37
|
+
};
|
|
32
38
|
//#endregion
|
|
33
|
-
export { loadProjectAuth };
|
|
39
|
+
export { loadProjectAuth, loadSignIn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.102.
|
|
3
|
+
"version": "0.102.4",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@better-auth/core": "^1.7.12",
|
|
45
45
|
"@hono/node-server": "^2.1.3",
|
|
46
|
-
"@protobase/config": "0.102.
|
|
47
|
-
"@protobase/layout": "0.102.
|
|
48
|
-
"@protobase/query": "0.102.
|
|
49
|
-
"@protobase/schema": "0.102.
|
|
50
|
-
"@protobase/server": "0.102.
|
|
51
|
-
"@protobase/ui": "0.102.
|
|
52
|
-
"@protobase/workflows": "0.102.
|
|
46
|
+
"@protobase/config": "0.102.4",
|
|
47
|
+
"@protobase/layout": "0.102.4",
|
|
48
|
+
"@protobase/query": "0.102.4",
|
|
49
|
+
"@protobase/schema": "0.102.4",
|
|
50
|
+
"@protobase/server": "0.102.4",
|
|
51
|
+
"@protobase/ui": "0.102.4",
|
|
52
|
+
"@protobase/workflows": "0.102.4",
|
|
53
53
|
"@react-email/render": "^2.1.0",
|
|
54
54
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
55
55
|
"@sentry/vite-plugin": "^11.10.0",
|
|
@@ -26,6 +26,7 @@ Develop, build and run an app, on servers, in containers and on phones.
|
|
|
26
26
|
- [Container images](../guides/deploy.md#images): A runtime image for each release, for amd64 and arm64.
|
|
27
27
|
- [Self-hosted image](../guides/deploy.md#a-self-hosted-image): One image with the app inside that serves, migrates and creates the first admin.
|
|
28
28
|
- [Protobase Cloud deploys](../guides/deploy.md#protobase-cloud): A push to the app's GitHub branch builds it, migrates and checks its database in one transaction, and switches to the new version once it answers its health check.
|
|
29
|
+
- [Deploy checks in CI](../guides/deploy.md#check-a-change-before-it-merges): One step in an app's GitHub workflow runs the checks a Protobase Cloud deploy runs, the server's startup checks included, on a fresh Postgres of its own, so a change that would not deploy or start fails before it merges.
|
|
29
30
|
- [Mobile apps](../guides/mobile-app.md) (beta): Runs an app on iOS and Android, also on your own iPhone, with sign-in, and builds signed store releases from a section in its config. Your app shows its own home-screen icon on iOS and Android, generated from one image you name in your config. It can open on a splash screen of its own, an image on a colour, in light and dark mode.
|
|
30
31
|
- [Files from the phone](../guides/mobile-app.md#files-from-the-phone) (beta): In the iOS and Android app, Import and file fields open the phone's file picker, offering Excel, CSV and JSON files from the device and its cloud drives.
|
|
31
32
|
- [Mobile releases](../reference/cli.md#mobile-releases) (in development): The server offers the mobile app a newer copy of its files, signed, and any host that serves bundles can offer the same from the bundle's files without running its config.
|
|
@@ -20,7 +20,7 @@ Start a new app, or an admin over an existing Postgres database, and keep the co
|
|
|
20
20
|
- [Scaffold from a database](../reference/cli.md#scaffold): Reads your Postgres tables and writes the data config for them, with field types, keys, relations, enums, soft delete, tenants and search filled in, and with `--ui` a first view of each.
|
|
21
21
|
- [Safe re-scaffolding](../reference/cli.md#re-running): Running scaffold again adds only the columns that are not declared yet and leaves your own config code as it is.
|
|
22
22
|
- [Schema drift report](../reference/cli.md#drift-report): After each scaffold, lists declared fields whose column is gone, whose type changed or whose enum values differ, with a suggested fix.
|
|
23
|
-
- [Doctor](../reference/cli.md#doctor): Checks every resource and view against the database, the ones Protobase adds such as webhook subscriptions included, with the reads that lack an index, and prints the fix for each problem.
|
|
23
|
+
- [Doctor](../reference/cli.md#doctor): Checks every resource and view against the database, the ones Protobase adds such as webhook subscriptions included, with the reads that lack an index, and prints the fix for each problem. It then runs the server's startup checks, such as the triggers of resources with events, so a project it passes starts.
|
|
24
24
|
- [Admin without a view](../guides/table-to-admin.md#1-the-table-as-it-is): A table with an empty view already gives a working admin with every column, sorting, paging, a record page and a New button.
|
|
25
25
|
- [Agent skills](../reference/cli.md#skill): `protobase skill install` writes agent skills that match the installed version into the project, for the coding agents that work on it.
|
|
26
26
|
- [Docs as Markdown](../getting-started.md#docs-as-markdown): Every docs page is also Markdown at its address plus `.md`, for coding agents and chat assistants.
|
|
@@ -202,6 +202,28 @@ An app on Protobase Cloud whose code is on GitHub follows one branch of its repo
|
|
|
202
202
|
|
|
203
203
|
When a step fails, the previous version keeps serving on the database as it was, except after a failed start, which comes after the migrations committed: they stay applied. Each build reports on GitHub as the check run `Protobase deploy` on the commit it built, with the step that failed and the end of its output. A commit whose build failed is not built again: the fix is a new push.
|
|
204
204
|
|
|
205
|
-
Since the deploy runs neither the typecheck nor the tests, and refuses what `doctor` refuses, check a change before pushing it: the project's typecheck and tests, `protobase doctor --env DATABASE_URL` on a database with the migrations applied,
|
|
205
|
+
Since the deploy runs neither the typecheck nor the tests, and refuses what `doctor` refuses, check a change before pushing it: the project's typecheck and tests, `protobase build`, and `protobase doctor --env DATABASE_URL` on a database with the migrations applied, which also runs the server's [startup checks](../reference/cli.md#doctor); on GitHub, [the check action](#check-a-change-before-it-merges) runs them all on every pull request. The migrations run in one transaction, so a statement Postgres refuses in one, such as `create index concurrently`, fails the deploy. Protobase Cloud also pushes to the branch itself, for an update of the app's Protobase packages, so pull before pushing.
|
|
206
|
+
|
|
207
|
+
### Check a change before it merges
|
|
208
|
+
|
|
209
|
+
Protobase's check action runs those checks on every pull request in one step of the app's GitHub workflow:
|
|
210
|
+
|
|
211
|
+
```yaml
|
|
212
|
+
name: check
|
|
213
|
+
on: pull_request
|
|
214
|
+
jobs:
|
|
215
|
+
check:
|
|
216
|
+
runs-on: ubuntu-latest
|
|
217
|
+
steps:
|
|
218
|
+
- uses: actions/checkout@v4
|
|
219
|
+
- uses: PrototeamHQ/protobase/actions/check@main
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
It installs Bun and the app's packages with `bun install --frozen-lockfile`, those of every platform, as the build needs for [native packages](../reference/cli.md#native-packages), then runs the app's `typecheck` and `test` scripts and `protobase build`. It then starts a fresh Postgres 18 of its own in Docker, with a role that is no superuser and may only create in its own database, as a hosted app's is, and runs the app's `db:migrate` (`protobase migrate` without one), the auth schema's migration and `protobase doctor`. Every `protobase` command is the app's own installed CLI, so the checks are those of the version the app deploys with. Each step's output is a group of its own in the log, and the first that fails stops the check with an error naming it, which the action's `failed` output holds too. A script the app does not have is skipped with a notice. The workflow declares no database service and needs no secrets: sign-in gets stand-ins for `PROTOBASE_URL` and `PROTOBASE_SECRET` when the workflow sets none, and doctor does not check the [model key](../reference/ai.md#the-model) of AI fields, which belongs to the deploy's environment.
|
|
223
|
+
|
|
224
|
+
- `working-directory`: the app's folder, for an app that is not at the root of its repository.
|
|
225
|
+
- `bun-version`: the Bun to install, `latest` by default.
|
|
226
|
+
|
|
227
|
+
The action needs a Linux runner with Docker, such as `ubuntu-latest`. `@main` follows the action as it changes; a release tag, such as `@v0.99.9`, pins it.
|
|
206
228
|
|
|
207
229
|
[`protobase skill install`](../reference/cli.md#skill) writes the `protobase-cloud` agent skill into the project, with how to check that a change went live and why a deploy failed, step by step.
|
|
@@ -553,20 +553,20 @@ Each value takes its colour from the view's `valueColors`, else an enum value's
|
|
|
553
553
|
### Timeline
|
|
554
554
|
|
|
555
555
|
:::caution[Beta]
|
|
556
|
-
A timeline is read-only: bars cannot be dragged or edited, and it has no zoom
|
|
556
|
+
A timeline is read-only: bars cannot be dragged or edited, and it has no zoom.
|
|
557
557
|
:::
|
|
558
558
|
|
|
559
559
|
Records of `resource` that match `filter` as a timeline, a Gantt chart for projects, orders or work: a lane per value of `lane`, a bar per value of `bar` in it, and each record a segment of its bar from `start` to `end`, coloured by its `color` value. A record without an end runs to now. The time axis runs from the earliest start to the latest end and always fits the page's width, so a phone shows the same time compressed, its lanes stacked under their names, and the page never scrolls sideways. Bars that overlap in time get rows of their own in their lane. Pointing at a bar, or moving focus to it, shows its times and each segment's under the lanes, which a screen reader reads from the bar too, a relation's bar by the name of the record it points at.
|
|
560
560
|
|
|
561
561
|
| Prop | |
|
|
562
562
|
| --- | --- |
|
|
563
|
-
| `resource`, `filter` | The records it draws, the
|
|
563
|
+
| `resource`, `filter` | The records it draws, every one the filter matches, read page after page. `resource` is required. |
|
|
564
564
|
| `lane` | The field whose values each get a lane, in the order they first start, such as a project. Required. |
|
|
565
565
|
| `bar` | The field whose values each get a bar in their lane, its records the bar's segments, such as a task; the record's own key gives a bar per record. Required. |
|
|
566
566
|
| `start`, `end` | Date or timestamp fields where a segment starts and ends. Required. |
|
|
567
567
|
| `color` | An enum field: a segment takes its value's tone or colour from the view's [`valueColors`](ui-config.md#value-tones-and-currencies), else the [chart token](theme.md#tokens) of its place among the enum's values, and is striped for a value the view marks with `.waitingValues(...)`. A legend names the values the bars hold. Required. |
|
|
568
568
|
| `select` | The [page parameter](layouts.md#page-parameters) a bar's choice sets, such as `task`: each bar links to the page with its `bar` value there (`?task=42`), the chosen bar is marked `aria-current`, and the timeline's children draw under it inside the chosen bar's first record, or nothing while none is chosen. |
|
|
569
|
-
| `limit` | How many records it reads at most; default and
|
|
569
|
+
| `limit` | How many records it reads at most, from 1 to 100,000; default 20,000. When more match, it draws the latest by `start` and a line under the lanes says how many it shows. |
|
|
570
570
|
| `title`, `description`, `actions`, `empty`, `span` | As on `Table`. |
|
|
571
571
|
|
|
572
572
|
```tsx
|
|
@@ -581,7 +581,7 @@ view<typeof phases>('phases').fields((r) => ({
|
|
|
581
581
|
}))
|
|
582
582
|
```
|
|
583
583
|
|
|
584
|
-
Its [text form](layouts.md#text-form) is a Markdown table with a row per segment: its lane, bar, value, start and end under the fields' labels. A timeline whose fields the user cannot read is left out of their page, and a field it cannot draw, such as a `start` that is no date, stops the server at startup.
|
|
584
|
+
Its [text form](layouts.md#text-form) is a Markdown table with a row per segment of its latest 500, the earliest first: its lane, bar, value, start and end under the fields' labels. A timeline whose fields the user cannot read is left out of their page, and a field it cannot draw, such as a `start` that is no date, stops the server at startup.
|
|
585
585
|
|
|
586
586
|
### Graph
|
|
587
587
|
|
|
@@ -130,6 +130,8 @@ Imports `config/index.ts` and the views of `config/*/ui.ts`, as the config modul
|
|
|
130
130
|
|
|
131
131
|
Doctor also lists, as a note it does not count, each custom component of a page that declares no [reads](custom-components.md#reads), since it reads outside the page's plan.
|
|
132
132
|
|
|
133
|
+
When the config has no errors, doctor then builds the app from `protobase.config.ts` and its own `config` folder, whatever `--config` names, as [`serve`](#serve) does and runs the server's startup checks of the database, and stops with the server's own message at the first one that fails: an auth store behind this version, a resource over a table of the auth store, [events](events.md), [history](history.md) or live updates without their triggers, a missing [comments](comments.md#the-table) table, [rollup and formula fields](data-config.md#rollups-and-formulas) without their columns or triggers, and a jobs, webhooks, workflows, notifications, status or user tables schema that is missing or behind. A change that passes doctor so starts. Sign-in is built only to read its store, so doctor needs neither `PROTOBASE_URL` nor `PROTOBASE_SECRET`. The one startup check doctor leaves out is the [model key](ai.md#the-model) of AI fields and actions, which belongs to the environment the app runs in. <gap>Doctor cannot run its checks that need only the config, such as relations and sorts, without a database because a run without a connection is not implemented.</gap>
|
|
134
|
+
|
|
133
135
|
Exit code is 1 when there are errors. Run it after the project's migrations and before a new version serves, as a platform's deploy does: a read it fails is one the API would refuse once the version runs. `protobase build` needs no database, so the indexes are doctor's to check.
|
|
134
136
|
|
|
135
137
|
## `eject`
|
|
@@ -620,7 +622,7 @@ bun run db:migrate # applies them
|
|
|
620
622
|
protobase auth migration [--dir db/migrations] [--name auth]
|
|
621
623
|
```
|
|
622
624
|
|
|
623
|
-
Run inside a project
|
|
625
|
+
Run inside a project, against its database with the project's migrations applied. It reads the versions the store applied from its `auth_migrations` table and writes the auth migrations of this Protobase it has not, each followed by its row there, as the next migration in `--dir`: `009_auth.sql` after `008_...`, with the store's schema, user table, columns and id type as the config's `auth` names them. Nothing is written when the store is current, nor with sign-in off, when it says so and exits 0. The file only adds, never drops; apply it with the project's other migrations. For a store made before 0.48, without `auth_migrations`, it writes the step that adopts it once, and refuses one that matches no version, naming what differs. See [migrations](auth.md#migrations).
|
|
624
626
|
|
|
625
627
|
## `import supabase`
|
|
626
628
|
|
|
@@ -59,8 +59,10 @@ Work down the list; the first that matches is the cause.
|
|
|
59
59
|
The deploy does not run the project's typecheck or tests, and refuses what doctor refuses, so run them before pushing:
|
|
60
60
|
|
|
61
61
|
1. The project's typecheck and tests.
|
|
62
|
-
2. `protobase doctor --env DATABASE_URL` against a database with the project's migrations applied; exit code 1 means the deploy will be refused.
|
|
62
|
+
2. `protobase doctor --env DATABASE_URL` against a database with the project's migrations applied; exit code 1 means the deploy will be refused, or the new version would not start, since doctor runs the server's startup checks too.
|
|
63
63
|
3. `protobase build`.
|
|
64
64
|
4. Migrations that work inside one transaction (no `CONCURRENTLY`), since the deploy runs them all in one.
|
|
65
65
|
|
|
66
|
+
A pull request runs all four with one step in the app's GitHub workflow, `uses: PrototeamHQ/protobase/actions/check@main` after `actions/checkout`, which starts its own Postgres (see the deploy guide's "Check a change before it merges").
|
|
67
|
+
|
|
66
68
|
After pushing, the change is done when `Protobase deploy` succeeded on its commit or a later one that contains it. A failure leaves the previous version live: fix it with a new push.
|