@protobase/cli 0.129.1 → 0.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/config-organizations.js +15 -0
- package/dist/auth/register.js +8 -2
- package/dist/auth/write-migration.js +34 -12
- package/dist/cli/package.js +1 -1
- package/dist/config/build-project.js +1 -0
- package/dist/config/project-modules.js +64 -0
- package/dist/config/read-only-queries.js +9 -0
- package/dist/config/user-tables-config.js +1 -1
- package/dist/dev/dev-jobs.js +12 -6
- package/dist/dev/entry.js +12 -19
- package/dist/doctor/capture-files.js +3 -3
- package/dist/doctor/startup.js +2 -4
- package/dist/migration/apply-migrations.js +9 -6
- package/dist/migration/baseline/read-live-modules.js +31 -0
- package/dist/migration/baseline/read-live-store.js +18 -4
- package/dist/migration/baseline/write-baseline.js +50 -17
- package/dist/migration/migrate-project.js +3 -3
- package/dist/migration/migration-project.js +29 -15
- package/dist/migration/older-code/catalog.js +34 -0
- package/dist/migration/older-code/contractions.js +86 -0
- package/dist/migration/older-code/lint-files.js +55 -0
- package/dist/migration/older-code/refusal.js +9 -0
- package/dist/migration/older-code/trial.js +58 -0
- package/dist/migration/parts.js +8 -104
- package/dist/migration/record/after-file.js +20 -2
- package/dist/migration/register.js +67 -19
- package/dist/migration/release/release-record.js +9 -7
- package/dist/migration/release/release-steps.js +15 -3
- package/dist/migration/sign-off/contract.js +65 -0
- package/dist/migration/sign-off/delete.js +50 -0
- package/dist/migration/sign-off/signed-off-file.js +19 -0
- package/dist/migration/snapshot/auth-difference.js +135 -15
- package/dist/migration/snapshot/auth-target.js +9 -3
- package/dist/migration/snapshot/check.js +24 -5
- package/dist/migration/snapshot/custom.js +6 -3
- package/dist/migration/snapshot/drop.js +7 -2
- package/dist/migration/snapshot/header.js +11 -4
- package/dist/migration/snapshot/module-changes.js +22 -0
- package/dist/migration/snapshot/module-prompts.js +42 -0
- package/dist/migration/snapshot/module-sections.js +38 -0
- package/dist/migration/snapshot/next-snapshot.js +13 -7
- package/dist/migration/snapshot/off-choice.js +11 -0
- package/dist/migration/snapshot/organizations-off-facts.js +49 -0
- package/dist/migration/snapshot/revival-rows.js +34 -0
- package/dist/migration/snapshot/run-migration.js +82 -15
- package/dist/migration/snapshot/snapshot-file.js +7 -0
- package/dist/migration/snapshot/terminal-prompts.js +21 -0
- package/dist/migration/snapshot/write-file.js +1 -1
- package/dist/migration/summary.js +3 -2
- package/dist/organizations/api.js +4 -2
- package/dist/organizations/commands.js +27 -10
- package/dist/organizations/pin-source.js +20 -0
- package/dist/organizations/pin.js +40 -0
- package/dist/organizations/register.js +20 -12
- package/dist/scaffold/protobase-tables.js +2 -2
- package/dist/serve/create-admin.js +6 -3
- package/dist/serve/lifecycle.js +2 -2
- package/dist/serve/migrate-release.js +1 -1
- package/dist/serve/relay-check.js +7 -8
- package/dist/serve/startup-checks.js +12 -22
- package/dist/supabase/load-phase.js +3 -1
- package/dist/supabase/project-users.js +4 -1
- package/dist/users/commands.js +44 -6
- package/dist/users/load-auth.js +9 -3
- package/dist/users/manage.js +16 -1
- package/dist/users/register.js +28 -25
- package/dist/users/set-disabled.js +3 -2
- package/dist/users/users-api.js +9 -3
- package/dist/worker/start-worker.js +7 -4
- package/package.json +8 -8
- package/skills/protobase/references/features/api-functions.md +1 -0
- package/skills/protobase/references/features/build-and-run.md +4 -2
- package/skills/protobase/references/features/sign-in-and-accounts.md +2 -1
- package/skills/protobase/references/guides/api-functions.md +27 -2
- package/skills/protobase/references/guides/deploy.md +2 -2
- package/skills/protobase/references/reference/assistant.md +1 -1
- package/skills/protobase/references/reference/auth.md +52 -17
- package/skills/protobase/references/reference/calls.md +1 -1
- package/skills/protobase/references/reference/cli.md +48 -28
- package/skills/protobase/references/reference/comments.md +1 -1
- package/skills/protobase/references/reference/config/api.md +1 -1
- package/skills/protobase/references/reference/config/jobs-and-events.md +1 -1
- package/skills/protobase/references/reference/config/sign-in.md +22 -4
- package/skills/protobase/references/reference/config.md +1 -1
- package/skills/protobase/references/reference/data-config.md +9 -9
- package/skills/protobase/references/reference/derived.md +1 -1
- package/skills/protobase/references/reference/email.md +2 -2
- package/skills/protobase/references/reference/events.md +2 -2
- package/skills/protobase/references/reference/history.md +1 -1
- package/skills/protobase/references/reference/jobs.md +5 -5
- package/skills/protobase/references/reference/live.md +2 -2
- package/skills/protobase/references/reference/notifications.md +4 -4
- package/skills/protobase/references/reference/personal-access-tokens.md +2 -2
- package/skills/protobase/references/reference/realtime-relay.md +1 -1
- package/skills/protobase/references/reference/status.md +2 -2
- package/skills/protobase/references/reference/supabase-rest.md +1 -1
- package/skills/protobase/references/reference/user-tables.md +1 -1
- package/skills/protobase/references/reference/webhooks.md +1 -1
- package/dist/migration/snapshot/lint-custom.js +0 -23
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { protobaseVersion } from "../version/version.js";
|
|
2
|
-
import {
|
|
2
|
+
import { buildProject } from "../config/build-project.js";
|
|
3
|
+
import { builtRuntimeModel } from "../config/project-modules.js";
|
|
3
4
|
import { openAppDatabase } from "../project/pg-db.js";
|
|
4
5
|
import { readHidden } from "../users/password.js";
|
|
5
6
|
import { createUserCommand } from "../users/commands.js";
|
|
@@ -16,8 +17,10 @@ const createAdminInBundle = async (bundle, email, options, out) => {
|
|
|
16
17
|
const config = await loadBundle(file);
|
|
17
18
|
if (!config.auth) throw new Error("Sign-in is off in the bundle's config (`auth: false`), so the app has no users to manage");
|
|
18
19
|
if (!process.env.DATABASE_URL) throw new Error("No database: set DATABASE_URL");
|
|
19
|
-
const
|
|
20
|
-
await
|
|
20
|
+
const database = openAppDatabase(pg, process.env.DATABASE_URL);
|
|
21
|
+
const project = await buildProject(config, database);
|
|
22
|
+
await checkMigrationRecord(database.db, builtRuntimeModel(project), protobaseVersion);
|
|
23
|
+
const auth = project.auth;
|
|
21
24
|
await createUserCommand(usersApi(auth), {
|
|
22
25
|
email,
|
|
23
26
|
role: "admin",
|
package/dist/serve/lifecycle.js
CHANGED
|
@@ -11,7 +11,7 @@ import { checkStartup } from "./startup-checks.js";
|
|
|
11
11
|
import { closeSockets } from "./close-sockets.js";
|
|
12
12
|
import { servedRelease } from "./mobile-release.js";
|
|
13
13
|
import pg from "pg";
|
|
14
|
-
import { backgroundSettled, checkAi,
|
|
14
|
+
import { backgroundSettled, checkAi, configExports, createFileCleanup, startJobs } from "@protobase/server";
|
|
15
15
|
import { createAdaptorServer, upgradeWebSocket } from "@hono/node-server";
|
|
16
16
|
//#region src/serve/lifecycle.ts
|
|
17
17
|
const listen = (server, port, host) => new Promise((resolve, reject) => {
|
|
@@ -38,9 +38,9 @@ const startServe = async ({ config, env, openDb = (url) => openAppDatabase(pg, u
|
|
|
38
38
|
env: process.env
|
|
39
39
|
});
|
|
40
40
|
const { admin, jobs: definitions } = await servedAdmin(project, db, ui, reporter, upgradeWebSocket);
|
|
41
|
-
if (env.startupChecks && definitions.length > 0) await checkJobsSchema(db);
|
|
42
41
|
const jobs = definitions.length > 0 ? await startJobs({
|
|
43
42
|
db,
|
|
43
|
+
scope: await admin.organizationScope(),
|
|
44
44
|
jobs: definitions,
|
|
45
45
|
work: env.runJobs,
|
|
46
46
|
decryptField: admin.decryptField,
|
|
@@ -35,7 +35,7 @@ const migrateRelease = async (bundle, env, out, plan) => {
|
|
|
35
35
|
const pending = migrations ? await pendingIn(tx, await readMigrationDir(path.join(dir, migrations))) : [];
|
|
36
36
|
if (pending.length > 0) throw new Error(`The database lacks the bundle's migrations ${pending.map(({ file }) => file).join(", ")}: apply them first with \`protobase-serve migrate\``);
|
|
37
37
|
const steps = await releaseSteps(project);
|
|
38
|
-
const record =
|
|
38
|
+
const record = await releaseRecord(project, steps, protobaseVersion, randomUUID());
|
|
39
39
|
return record ? [...steps, record] : steps;
|
|
40
40
|
};
|
|
41
41
|
await (plan ? planReleaseSteps(sql, find, out) : applyReleaseSteps(sql, find, out));
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { appRelayChannels,
|
|
1
|
+
import { appRelayChannels, readRelaySwitch } from "@protobase/server";
|
|
2
2
|
//#region src/serve/relay-check.ts
|
|
3
3
|
/**
|
|
4
|
-
* Refuses to start while the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Refuses to start while the platform's switch is neither true nor false, or the relay is on, by the config's
|
|
5
|
+
* `realtime.relay` or the switch, and its channels do not fit the views. What the channels need of the database is
|
|
6
|
+
* the relay module, which the record of migrations holds. A switch with no channels to derive is left to the server,
|
|
7
|
+
* which stops naming it.
|
|
7
8
|
*/
|
|
8
|
-
const checkProjectRelay =
|
|
9
|
+
const checkProjectRelay = ({ realtime, auth, models, views }, env) => {
|
|
9
10
|
if (!realtime?.relay && !readRelaySwitch(env)) return;
|
|
10
|
-
|
|
11
|
+
appRelayChannels(realtime?.relay, {
|
|
11
12
|
views,
|
|
12
13
|
models,
|
|
13
14
|
signIn: Boolean(auth)
|
|
14
15
|
});
|
|
15
|
-
if (!channels) return;
|
|
16
|
-
await checkRelaySchema(db, auth, channels, models);
|
|
17
16
|
};
|
|
18
17
|
//#endregion
|
|
19
18
|
export { checkProjectRelay };
|
|
@@ -1,42 +1,32 @@
|
|
|
1
1
|
import { protobaseVersion } from "../version/version.js";
|
|
2
|
+
import { readOnlyQueriesOn } from "../config/read-only-queries.js";
|
|
3
|
+
import { builtRuntimeModel } from "../config/project-modules.js";
|
|
2
4
|
import { checkProjectRelay } from "./relay-check.js";
|
|
3
|
-
import {
|
|
5
|
+
import { authStoreTables, checkMigrationRecord, checkQueryRoleSafety, checkResourcesOutsideAuthStore, configExports } from "@protobase/server";
|
|
4
6
|
//#region src/serve/startup-checks.ts
|
|
5
7
|
/**
|
|
6
|
-
* The server's startup checks of the database: the record of its migrations (`checkMigrationRecord`),
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* The server's startup checks of the database: the record of its migrations (`checkMigrationRecord`), which holds the
|
|
9
|
+
* auth store and the schema modules, such as the jobs schema, the rollups and formulas, the change capture, the derived schema, the schemas of user tables, webhooks, workflows, status, calls, the relay, comments, mail feedback, unsubscribe and the assistant's query role, the organization pinned while organizations are off
|
|
10
|
+
* after being on (`pinnedOrganization`), the resources over the auth store's tables, and what the live database gave the
|
|
11
|
+
* query role (`checkQueryRoleSafety`); each throws, with what to write as a migration, while a schema the project's
|
|
12
|
+
* features need is missing or behind. They only read. `serve` runs them before it builds the admin, and
|
|
9
13
|
* `protobase doctor` runs them too, so a change that would not start fails wherever doctor runs.
|
|
10
14
|
*/
|
|
11
15
|
const checkStartup = async (project, db) => {
|
|
12
16
|
const exported = configExports(project.config);
|
|
13
17
|
const models = exported.resources.map((resource) => resource.toModel());
|
|
14
|
-
|
|
15
|
-
await
|
|
18
|
+
await checkMigrationRecord(db, builtRuntimeModel(project), protobaseVersion);
|
|
19
|
+
await project.auth?.pinnedOrganization();
|
|
16
20
|
if (project.auth) await checkResourcesOutsideAuthStore(db, models, project.auth);
|
|
17
|
-
if (project.
|
|
18
|
-
await checkChanges(db, captured, project.events);
|
|
19
|
-
await checkComments(db, models);
|
|
20
|
-
await checkDerived(db, models);
|
|
21
|
-
await checkCalls(db, project.calls, project.events);
|
|
22
|
-
await checkComputed(db, models);
|
|
23
|
-
if (assistantSettings(project.options?.assistant, process.env)?.kind === "built-in") await checkQueryRunner(db, project.auth ? authStoreTables(project.auth) : {
|
|
21
|
+
if (readOnlyQueriesOn(project.options?.assistant, process.env)) await checkQueryRoleSafety(db, project.auth ? authStoreTables(project.auth) : {
|
|
24
22
|
tables: [],
|
|
25
23
|
schemas: []
|
|
26
24
|
});
|
|
27
|
-
|
|
28
|
-
if (project.workflows) await checkWorkflowsSchema(db, project.workflows);
|
|
29
|
-
if (relayed(project.realtime)) await checkRealtimeRelay(db);
|
|
30
|
-
if (sqlSends(project.realtime)) await checkChannelSends(db);
|
|
31
|
-
await checkProjectRelay(db, {
|
|
25
|
+
checkProjectRelay({
|
|
32
26
|
...project,
|
|
33
27
|
models,
|
|
34
28
|
views: exported.views.map((view) => view.toModel())
|
|
35
29
|
}, process.env);
|
|
36
|
-
if (project.notifications) await checkNotificationsSchema(db, project.notifications, project.auth);
|
|
37
|
-
if (project.status) await checkStatusSchema(db, project.status, project.auth);
|
|
38
|
-
if (project.unsubscribe) await checkUnsubscribesSchema(db);
|
|
39
|
-
if (project.userTables) await checkUserTablesSchema(db);
|
|
40
30
|
};
|
|
41
31
|
//#endregion
|
|
42
32
|
export { checkStartup };
|
|
@@ -2,6 +2,7 @@ import { loadProjectAuth } from "../users/load-auth.js";
|
|
|
2
2
|
import { connect } from "../db/connect.js";
|
|
3
3
|
import { authStorageSchemas } from "./platform-schemas.js";
|
|
4
4
|
import { runScaffold } from "../scaffold/run.js";
|
|
5
|
+
import { loadConfigOrganizations } from "../auth/config-organizations.js";
|
|
5
6
|
import { readSnapshot } from "../migration/snapshot/snapshot-file.js";
|
|
6
7
|
import { readMigrationFiles } from "../migration/snapshot/migration-files.js";
|
|
7
8
|
import { refuseInconsistent } from "../migration/snapshot/consistency.js";
|
|
@@ -104,7 +105,8 @@ const runLoadPhase = async (options, out) => {
|
|
|
104
105
|
auth,
|
|
105
106
|
projectDir: options.projectDir,
|
|
106
107
|
dir: options.migrationsDir,
|
|
107
|
-
name: "auth"
|
|
108
|
+
name: "auth",
|
|
109
|
+
organizations: await loadConfigOrganizations(options.projectDir)
|
|
108
110
|
});
|
|
109
111
|
if (authFile) out(`wrote ${path.relative(options.projectDir, authFile)}, Better Auth's tables next to auth.users\n`);
|
|
110
112
|
const accountsFile = await writeMigration(options.migrationsDir, "supabase_accounts", accountsMigration());
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { loadProjectAuth } from "../users/load-auth.js";
|
|
2
|
+
import { loadConfigOrganizations } from "../auth/config-organizations.js";
|
|
2
3
|
import { writeAuthMigration } from "../auth/write-migration.js";
|
|
3
4
|
import { planAuthConfig, sharedUsersConfig, sharedUsersSchema } from "./auth-config.js";
|
|
4
5
|
import { writeMigration } from "./migration-files.js";
|
|
@@ -24,12 +25,14 @@ const useSupabaseUsers = async (projectDir, out) => {
|
|
|
24
25
|
await authConfig.write();
|
|
25
26
|
if (storeMigrations.length > 0) out(`removed ${storeMigrations.length} migrations of Protobase's own user table: Supabase's users replace it\n`);
|
|
26
27
|
out(`pointed ${relative(authConfig.file)} at ${sharedUsersSchema}.users, a view over auth.users\n`);
|
|
28
|
+
const organizations = await loadConfigOrganizations(projectDir);
|
|
27
29
|
const authFile = await writeAuthMigration({
|
|
28
30
|
auth: await loadProjectAuth(projectDir),
|
|
29
31
|
projectDir,
|
|
30
32
|
dir: migrationsDir,
|
|
31
33
|
name: "auth",
|
|
32
|
-
writer: "create protobase"
|
|
34
|
+
writer: "create protobase",
|
|
35
|
+
organizations
|
|
33
36
|
});
|
|
34
37
|
if (authFile) out(`wrote ${relative(authFile)}, Better Auth's tables in ${sharedUsersSchema}, pointing at auth.users\n`);
|
|
35
38
|
const usersFile = await writeMigration(migrationsDir, "supabase_users", sharedUsersMigration());
|
package/dist/users/commands.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { pinLine, resolveOptionalPin, scopeOf } from "../organizations/pin.js";
|
|
2
|
+
import { parseRoleList } from "../organizations/commands.js";
|
|
1
3
|
import { resolvePassword } from "./password.js";
|
|
4
|
+
import { everyOrganization } from "@protobase/query";
|
|
2
5
|
//#region src/users/commands.ts
|
|
3
6
|
const githubId = /^[1-9][0-9]*$/;
|
|
4
7
|
const shownAs = (role, labels) => {
|
|
@@ -10,7 +13,8 @@ const createUserCommand = async (api, options, deps, out) => {
|
|
|
10
13
|
if (!options.email.includes("@")) throw new Error(`"${options.email}" is not an email address`);
|
|
11
14
|
if (options.githubId !== void 0 && !githubId.test(options.githubId)) throw new Error(`"${options.githubId}" is not a GitHub user id, a number such as 583231`);
|
|
12
15
|
const { password, generated } = await resolvePassword(options, deps);
|
|
13
|
-
const
|
|
16
|
+
const first = !await api.hasUsers();
|
|
17
|
+
const role = first ? "admin" : options.role;
|
|
14
18
|
const user = await api.createUser({
|
|
15
19
|
email: options.email,
|
|
16
20
|
...password !== void 0 && { password },
|
|
@@ -24,10 +28,44 @@ const createUserCommand = async (api, options, deps, out) => {
|
|
|
24
28
|
const { labels } = await api.roles();
|
|
25
29
|
out(`Created ${user.role} ${user.email}${shownAs(user.role, labels)}${options.githubId ? `, linked to GitHub user ${options.githubId}` : ""}\n`);
|
|
26
30
|
if (generated) out(`Password (shown once): ${password}\n`);
|
|
31
|
+
return {
|
|
32
|
+
email: user.email,
|
|
33
|
+
first
|
|
34
|
+
};
|
|
27
35
|
};
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Creates the user (`createUserCommand`) and, with organizations, adds them to the pinned organization, or to none
|
|
38
|
+
* with `--all-organizations`. The pin is resolved first, so an unknown organization creates nobody.
|
|
39
|
+
*/
|
|
40
|
+
const createMemberCommand = async (api, options, deps, out) => {
|
|
41
|
+
if (options.allOrganizations && !api.organizationsOn) throw new Error("--all-organizations needs organizations: turn on auth.organizations in the config");
|
|
42
|
+
if (options.allOrganizations && options.organization !== void 0) throw new Error("Pass --organization or --all-organizations, not both");
|
|
43
|
+
const pin = options.allOrganizations ? void 0 : await resolveOptionalPin(api, options, "users create");
|
|
44
|
+
const user = await createUserCommand(api, options, deps, out);
|
|
45
|
+
if (options.allOrganizations) out(`${user.email} joins no organization\n`);
|
|
46
|
+
if (!pin || "every" in pin) return;
|
|
47
|
+
if (user.first && await api.isMember(pin.organization.id, user.email)) {
|
|
48
|
+
out(`${user.email} owns ${pin.organization.slug}\n`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const appRoles = parseRoleList(options.appRoles);
|
|
52
|
+
await api.addMember({
|
|
53
|
+
organization: pin.organization.id,
|
|
54
|
+
email: user.email,
|
|
55
|
+
...options.orgRole && { role: options.orgRole },
|
|
56
|
+
...appRoles && { appRoles }
|
|
57
|
+
});
|
|
58
|
+
out(`Added ${user.email} to ${pin.organization.slug}${options.orgRole ? ` as ${options.orgRole}` : ""}\n`);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Prints the users, oldest first, a page at a time as the store pages them; the first page sets the columns' width. With
|
|
62
|
+
* organizations, the members of the pinned organization, or every user with `--all-organizations`.
|
|
63
|
+
*/
|
|
64
|
+
const listUsersCommand = async (api, options, out) => {
|
|
65
|
+
const pin = await resolveOptionalPin(api, options, "users list", () => everyOrganization("protobase users list: --all-organizations"));
|
|
66
|
+
if (pin) out(pinLine(pin));
|
|
67
|
+
const scope = pin && scopeOf(pin);
|
|
68
|
+
let page = await api.listUsers(scope);
|
|
31
69
|
if (page.users.length === 0) {
|
|
32
70
|
out("No users yet. Create the first admin with: protobase users create you@example.com\n");
|
|
33
71
|
return;
|
|
@@ -37,7 +75,7 @@ const listUsersCommand = async (api, out) => {
|
|
|
37
75
|
for (;;) {
|
|
38
76
|
for (const user of page.users) out(`${user.email.padEnd(width)} ${user.role.padEnd(8)} ${user.createdAt}${user.banned ? " disabled" : ""}\n`);
|
|
39
77
|
if (!page.next) return;
|
|
40
|
-
page = await api.listUsers(page.next);
|
|
78
|
+
page = await api.listUsers(scope, page.next);
|
|
41
79
|
}
|
|
42
80
|
};
|
|
43
81
|
const listRolesCommand = async (api, out) => {
|
|
@@ -45,4 +83,4 @@ const listRolesCommand = async (api, out) => {
|
|
|
45
83
|
for (const role of roles) out(`${role}${role === defaultRole ? " (default for new users)" : ""}\n`);
|
|
46
84
|
};
|
|
47
85
|
//#endregion
|
|
48
|
-
export { createUserCommand, listRolesCommand, listUsersCommand };
|
|
86
|
+
export { createMemberCommand, createUserCommand, listRolesCommand, listUsersCommand };
|
package/dist/users/load-auth.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { loadNearestEnvFile } from "../dev/env.js";
|
|
2
2
|
import { projectNotifications, projectWorkflows } from "../config/project-parts.js";
|
|
3
3
|
import { projectAuth } from "../config/build-project.js";
|
|
4
|
+
import { configModules } from "../config/project-modules.js";
|
|
4
5
|
import { loadSourceConfig } from "../config/source-config.js";
|
|
5
6
|
import { withDevUrl } from "../config/tool-url.js";
|
|
6
7
|
import { openAppDatabase } from "../project/pg-db.js";
|
|
7
8
|
import pg from "pg";
|
|
8
9
|
import { releaseConnectionsWithUsers, removeDevicesWithUsers, removeHistoryWithUsers } from "@protobase/server";
|
|
9
10
|
//#region src/users/load-auth.ts
|
|
11
|
+
const loadToolConfig = async (projectDir) => {
|
|
12
|
+
loadNearestEnvFile(projectDir);
|
|
13
|
+
return withDevUrl(await loadSourceConfig(projectDir, { command: "tool" }), projectDir);
|
|
14
|
+
};
|
|
15
|
+
/** The schema modules the config of the project in `projectDir` needs (`configModules`). */
|
|
16
|
+
const loadProjectModules = async (projectDir) => configModules(await loadToolConfig(projectDir));
|
|
10
17
|
/**
|
|
11
18
|
* The sign-in of the project in `projectDir`, built from its config's `auth` over DATABASE_URL, with only the plugins
|
|
12
19
|
* it turns on, at the project's dev address when it sets no `url` (`withDevUrl`); `undefined` when sign-in is off.
|
|
@@ -16,8 +23,7 @@ import { releaseConnectionsWithUsers, removeDevicesWithUsers, removeHistoryWithU
|
|
|
16
23
|
* reporting a token it left valid on stderr.
|
|
17
24
|
*/
|
|
18
25
|
const loadSignIn = async (projectDir) => {
|
|
19
|
-
|
|
20
|
-
const config = await withDevUrl(await loadSourceConfig(projectDir, { command: "tool" }), projectDir);
|
|
26
|
+
const config = await loadToolConfig(projectDir);
|
|
21
27
|
if (!config.auth) return;
|
|
22
28
|
if (!process.env.DATABASE_URL) throw new Error("No database: set DATABASE_URL");
|
|
23
29
|
const database = openAppDatabase(pg, process.env.DATABASE_URL);
|
|
@@ -38,4 +44,4 @@ const loadProjectAuth = async (projectDir) => {
|
|
|
38
44
|
return auth;
|
|
39
45
|
};
|
|
40
46
|
//#endregion
|
|
41
|
-
export { loadProjectAuth, loadSignIn };
|
|
47
|
+
export { loadProjectAuth, loadProjectModules, loadSignIn };
|
package/dist/users/manage.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import { checkPinnedUser, pinLine, resolveOptionalPin } from "../organizations/pin.js";
|
|
2
|
+
import { everyOrganization } from "@protobase/query";
|
|
1
3
|
//#region src/users/manage.ts
|
|
4
|
+
const reachUser = async (api, options, command, wide, out) => {
|
|
5
|
+
const pin = await resolveOptionalPin(api, options, command, wide);
|
|
6
|
+
if (!pin) return;
|
|
7
|
+
await checkPinnedUser(api, pin, options.email);
|
|
8
|
+
out(pinLine(pin));
|
|
9
|
+
};
|
|
2
10
|
const deleteUserCommand = async (api, options, confirm, out) => {
|
|
11
|
+
await reachUser(api, options, "users delete", () => everyOrganization("protobase users delete: --all-organizations"), out);
|
|
3
12
|
if (!options.yes) {
|
|
4
13
|
if ((await confirm(`This permanently deletes ${options.email}. Type the email to confirm: `)).trim() !== options.email) throw new Error("The typed email does not match; nothing was deleted");
|
|
5
14
|
}
|
|
@@ -7,10 +16,16 @@ const deleteUserCommand = async (api, options, confirm, out) => {
|
|
|
7
16
|
out(`Deleted ${options.email}\n`);
|
|
8
17
|
};
|
|
9
18
|
const setRoleCommand = async (api, options, out) => {
|
|
10
|
-
|
|
19
|
+
await reachUser(api, options, "users set-role", () => everyOrganization("protobase users set-role: --all-organizations"), out);
|
|
20
|
+
const user = await api.setUserRole({
|
|
21
|
+
email: options.email,
|
|
22
|
+
role: options.role
|
|
23
|
+
});
|
|
11
24
|
out(`${user.email} is now ${user.role}\n`);
|
|
12
25
|
};
|
|
13
26
|
const setDisabledCommand = async (api, options, out) => {
|
|
27
|
+
const command = options.disabled ? "users disable" : "users enable";
|
|
28
|
+
await reachUser(api, options, command, () => everyOrganization(options.disabled ? "protobase users disable: --all-organizations" : "protobase users enable: --all-organizations"), out);
|
|
14
29
|
await api.setUserBanned({
|
|
15
30
|
email: options.email,
|
|
16
31
|
banned: options.disabled
|
package/dist/users/register.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pinOptions } from "../organizations/register.js";
|
|
1
2
|
import { parseTtl } from "./ttl.js";
|
|
2
3
|
import { Option } from "commander";
|
|
3
4
|
import { createInterface } from "node:readline/promises";
|
|
@@ -21,57 +22,56 @@ const ask = async (question) => {
|
|
|
21
22
|
const finish = (code) => process.exit(code);
|
|
22
23
|
const registerUsers = (program) => {
|
|
23
24
|
const users = program.command("users").description("Manage the admin users of the project in the current directory");
|
|
24
|
-
users.command("create").description("Create a user; the first user is always an admin").argument("<email>").option("--name <name>", "display name").option("--role <role>", "role for users after the first (default: the project's default role; see `users roles`)").option("--password-stdin", "read the password from stdin", false).option("--generate-password", "generate a strong password and print it once", false).option("--no-password", "no password: the user signs in by emailed code, passkey or a sign-in provider").option("--github-id <id>", "link the user to this GitHub user id, so signing in with GitHub finds them whatever their address").option("--
|
|
25
|
+
pinOptions(users.command("create").description("Create a user; the first user is always an admin. With organizations, they join the organization; with --all-organizations, none")).argument("<email>").option("--name <name>", "display name").option("--role <role>", "role for users after the first (default: the project's default role; see `users roles`)").option("--password-stdin", "read the password from stdin", false).option("--generate-password", "generate a strong password and print it once", false).option("--no-password", "no password: the user signs in by emailed code, passkey or a sign-in provider").option("--github-id <id>", "link the user to this GitHub user id, so signing in with GitHub finds them whatever their address").option("--org-role <role>", "with organizations: owner, admin or member in the organization (default member)").option("--app-roles <roles>", "with organizations: app roles in the organization, comma separated").addOption(new Option("--password <value>").hideHelp()).action(async (email, opts) => {
|
|
25
26
|
const { readHidden, rejectPasswordArgument } = await import("./password.js");
|
|
26
27
|
rejectPasswordArgument(opts.password);
|
|
27
|
-
const [{
|
|
28
|
-
|
|
29
|
-
import("./users-api.js"),
|
|
30
|
-
import("../organizations/api.js"),
|
|
31
|
-
import("../organizations/commands.js"),
|
|
32
|
-
loadAuth()
|
|
33
|
-
]);
|
|
34
|
-
await createUserCommand(usersApi(auth), {
|
|
28
|
+
const [{ createMemberCommand }, api] = await Promise.all([import("./commands.js"), projectApi()]);
|
|
29
|
+
await createMemberCommand(api, {
|
|
35
30
|
email,
|
|
36
31
|
name: opts.name,
|
|
37
32
|
role: opts.role,
|
|
38
33
|
passwordStdin: opts.passwordStdin,
|
|
39
34
|
generatePassword: opts.generatePassword,
|
|
40
35
|
noPassword: opts.password === false,
|
|
41
|
-
githubId: opts.githubId
|
|
42
|
-
}, {
|
|
43
|
-
stdin: process.stdin,
|
|
44
|
-
prompt: readHidden
|
|
45
|
-
}, out);
|
|
46
|
-
if (opts.organization) await addMemberCommand(organizationsApi(auth), {
|
|
36
|
+
githubId: opts.githubId,
|
|
47
37
|
organization: opts.organization,
|
|
48
|
-
|
|
38
|
+
allOrganizations: opts.allOrganizations,
|
|
49
39
|
orgRole: opts.orgRole,
|
|
50
40
|
appRoles: opts.appRoles
|
|
41
|
+
}, {
|
|
42
|
+
stdin: process.stdin,
|
|
43
|
+
prompt: readHidden
|
|
51
44
|
}, out);
|
|
52
45
|
finish(0);
|
|
53
46
|
});
|
|
54
|
-
users.command("delete").description("Delete a user (refuses the last admin)").argument("<email>").option("--yes", "skip the confirmation", false).action(async (email, opts) => {
|
|
47
|
+
pinOptions(users.command("delete").description("Delete a user (refuses the last admin)")).argument("<email>").option("--yes", "skip the confirmation", false).action(async (email, opts) => {
|
|
55
48
|
const { deleteUserCommand } = await import("./manage.js");
|
|
56
49
|
await deleteUserCommand(await projectApi(), {
|
|
57
50
|
email,
|
|
58
|
-
yes: opts.yes
|
|
51
|
+
yes: opts.yes,
|
|
52
|
+
organization: opts.organization,
|
|
53
|
+
allOrganizations: opts.allOrganizations
|
|
59
54
|
}, ask, out);
|
|
60
55
|
finish(0);
|
|
61
56
|
});
|
|
62
|
-
users.command("set-role").description("Change a user's role, or several comma separated (refuses to demote the last admin)").argument("<email>").argument("<role>").action(async (email, role) => {
|
|
57
|
+
pinOptions(users.command("set-role").description("Change a user's role, or several comma separated (refuses to demote the last admin)")).argument("<email>").argument("<role>").action(async (email, role, opts) => {
|
|
63
58
|
const { setRoleCommand } = await import("./manage.js");
|
|
64
59
|
await setRoleCommand(await projectApi(), {
|
|
65
60
|
email,
|
|
66
|
-
role
|
|
61
|
+
role,
|
|
62
|
+
organization: opts.organization,
|
|
63
|
+
allOrganizations: opts.allOrganizations
|
|
67
64
|
}, out);
|
|
68
65
|
finish(0);
|
|
69
66
|
});
|
|
70
|
-
for (const disabled of [true, false]) users.command(disabled ? "disable" : "enable").description(disabled ? "Ban a user and revoke their sessions" : "Lift a ban").argument("<email>").action(async (email) => {
|
|
67
|
+
for (const disabled of [true, false]) pinOptions(users.command(disabled ? "disable" : "enable").description(disabled ? "Ban a user and revoke their sessions" : "Lift a ban")).argument("<email>").action(async (email, opts) => {
|
|
71
68
|
const { setDisabledInProject } = await import("./set-disabled.js");
|
|
72
|
-
|
|
69
|
+
const { loadProjectModules } = await import("./load-auth.js");
|
|
70
|
+
await setDisabledInProject(await loadAuth(), await loadProjectModules(process.cwd()), {
|
|
73
71
|
email,
|
|
74
|
-
disabled
|
|
72
|
+
disabled,
|
|
73
|
+
organization: opts.organization,
|
|
74
|
+
allOrganizations: opts.allOrganizations
|
|
75
75
|
}, out);
|
|
76
76
|
finish(0);
|
|
77
77
|
});
|
|
@@ -80,9 +80,12 @@ const registerUsers = (program) => {
|
|
|
80
80
|
await listRolesCommand(await projectApi(), out);
|
|
81
81
|
finish(0);
|
|
82
82
|
});
|
|
83
|
-
users.command("list").description("List users: email, role, creation date").action(async () => {
|
|
83
|
+
pinOptions(users.command("list").description("List users: email, role, creation date; with organizations, the members of the organization")).action(async (opts) => {
|
|
84
84
|
const { listUsersCommand } = await import("./commands.js");
|
|
85
|
-
await listUsersCommand(await projectApi(),
|
|
85
|
+
await listUsersCommand(await projectApi(), {
|
|
86
|
+
organization: opts.organization,
|
|
87
|
+
allOrganizations: opts.allOrganizations
|
|
88
|
+
}, out);
|
|
86
89
|
finish(0);
|
|
87
90
|
});
|
|
88
91
|
};
|
|
@@ -2,9 +2,10 @@ import { protobaseVersion } from "../version/version.js";
|
|
|
2
2
|
import { usersApi } from "./users-api.js";
|
|
3
3
|
import { setDisabledCommand } from "./manage.js";
|
|
4
4
|
import { checkMigrationRecord } from "@protobase/server";
|
|
5
|
+
import { plainStoreDb, runtimeModel } from "@protobase/server/internal";
|
|
5
6
|
//#region src/users/set-disabled.ts
|
|
6
|
-
const setDisabledInProject = async (auth, options, out) => {
|
|
7
|
-
await checkMigrationRecord(auth, protobaseVersion);
|
|
7
|
+
const setDisabledInProject = async (auth, modules, options, out) => {
|
|
8
|
+
await checkMigrationRecord(plainStoreDb(auth), runtimeModel(auth, modules), protobaseVersion);
|
|
8
9
|
await setDisabledCommand(usersApi(auth), options, out);
|
|
9
10
|
};
|
|
10
11
|
//#endregion
|
package/dist/users/users-api.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pinSource } from "../organizations/pin-source.js";
|
|
2
|
+
import { addMember, createUser, deleteUser, hasUsers, listUsers, roleChoices, setUserBanned, setUserRole } from "@protobase/server";
|
|
2
3
|
//#region src/users/users-api.ts
|
|
3
4
|
const usersApi = (auth) => ({
|
|
5
|
+
...pinSource(auth),
|
|
4
6
|
hasUsers: () => hasUsers(auth),
|
|
5
7
|
roles: async () => ({
|
|
6
8
|
roles: roleChoices(auth),
|
|
@@ -8,10 +10,14 @@ const usersApi = (auth) => ({
|
|
|
8
10
|
labels: auth.roleDefinitions.labels
|
|
9
11
|
}),
|
|
10
12
|
createUser: (input) => createUser(auth, input),
|
|
11
|
-
listUsers: (after) => listUsers(auth,
|
|
13
|
+
listUsers: (scope, after) => listUsers(auth, {
|
|
14
|
+
...after && { after },
|
|
15
|
+
...scope !== void 0 && { scope }
|
|
16
|
+
}),
|
|
12
17
|
deleteUser: (email) => deleteUser(auth, email),
|
|
13
18
|
setUserRole: (input) => setUserRole(auth, input),
|
|
14
|
-
setUserBanned: (input) => setUserBanned(auth, input)
|
|
19
|
+
setUserBanned: (input) => setUserBanned(auth, input),
|
|
20
|
+
addMember: (input) => addMember(auth, input)
|
|
15
21
|
});
|
|
16
22
|
//#endregion
|
|
17
23
|
export { usersApi };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { protobaseVersion } from "../version/version.js";
|
|
1
2
|
import { buildProject } from "../config/build-project.js";
|
|
3
|
+
import { builtRuntimeModel } from "../config/project-modules.js";
|
|
2
4
|
import { openAppDatabase } from "../project/pg-db.js";
|
|
3
5
|
import { projectAdmin } from "../project/project-admin.js";
|
|
4
6
|
import { readManifest } from "../bundle/manifest.js";
|
|
@@ -7,7 +9,7 @@ import { loadBundle } from "../serve/load-bundle.js";
|
|
|
7
9
|
import { statSync } from "node:fs";
|
|
8
10
|
import path from "node:path";
|
|
9
11
|
import pg from "pg";
|
|
10
|
-
import {
|
|
12
|
+
import { checkMigrationRecord, configExports, hasBuckets, isCaptured, startJobs } from "@protobase/server";
|
|
11
13
|
//#region src/worker/start-worker.ts
|
|
12
14
|
const bundleConfigFile = async (bundle) => {
|
|
13
15
|
if (!statSync(bundle).isDirectory()) return bundle;
|
|
@@ -15,8 +17,8 @@ const bundleConfigFile = async (bundle) => {
|
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* Runs the project's jobs, and nothing else, until `stop`: the same handlers `protobase serve` runs, in a process of
|
|
18
|
-
* their own, built from the config the same way. It reads the
|
|
19
|
-
*
|
|
20
|
+
* their own, built from the config the same way. It reads the record of migrations at start and refuses a database
|
|
21
|
+
* the app would not start on, like `serve`.
|
|
20
22
|
*/
|
|
21
23
|
const startWorker = async ({ config, databaseUrl, openDb = (url) => openAppDatabase(pg, url) }) => {
|
|
22
24
|
if (!databaseUrl) throw new Error("No database: set DATABASE_URL");
|
|
@@ -30,11 +32,12 @@ const startWorker = async ({ config, databaseUrl, openDb = (url) => openAppDatab
|
|
|
30
32
|
});
|
|
31
33
|
if (project.jobs.length === 0 && !builtIn) throw new Error("The bundle has no jobs: name their module in protobase.config.ts as `jobs`, or give a resource events, history, comments or an AI field, or declare a time rollup");
|
|
32
34
|
const { admin, jobs: definitions } = projectAdmin(project, db);
|
|
33
|
-
await
|
|
35
|
+
await checkMigrationRecord(db, builtRuntimeModel(project), protobaseVersion);
|
|
34
36
|
return {
|
|
35
37
|
definitions,
|
|
36
38
|
runtime: await startJobs({
|
|
37
39
|
db,
|
|
40
|
+
scope: await admin.organizationScope(),
|
|
38
41
|
jobs: definitions,
|
|
39
42
|
decryptField: admin.decryptField,
|
|
40
43
|
...project.mailer && { mailer: project.mailer },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.130.1",
|
|
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.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.130.1",
|
|
47
|
+
"@protobase/layout": "0.130.1",
|
|
48
|
+
"@protobase/query": "0.130.1",
|
|
49
|
+
"@protobase/schema": "0.130.1",
|
|
50
|
+
"@protobase/server": "0.130.1",
|
|
51
|
+
"@protobase/ui": "0.130.1",
|
|
52
|
+
"@protobase/workflows": "0.130.1",
|
|
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",
|
|
@@ -14,4 +14,5 @@ Endpoints of your own beside the REST API.
|
|
|
14
14
|
- [Calling a function](../guides/api-functions.md#calling-a-function): The typed client's `invoke` calls a function with the signed-in user's token, from an action or any page.
|
|
15
15
|
- [Work after the response](../guides/api-functions.md#work-after-the-response): A function can answer at once and finish its work afterwards, which a graceful stop waits for.
|
|
16
16
|
- [Hono apps](../guides/api-functions.md#hono-apps): A function with several routes can be a Hono app.
|
|
17
|
+
- [The organization's tables](../guides/api-functions.md#the-organizations-tables) (beta): With organizations on, the `db` of functions, jobs and hooks, and sign-in's own queries, read and write the memberships, invitations and personal access tokens of one organization only, the caller's, and with organizations off after being on, the default organization's, unless the code opts out with `db.unscoped('<reason>')`; raw SQL names those tables through `scoped()` or `unscoped()`.
|
|
17
18
|
- [Long queries](../guides/api-functions.md#long-queries): A function or job that does bulk work may run queries for up to 30 seconds, on a connection kept for it, and functions and jobs always leave a connection to page requests.
|
|
@@ -12,8 +12,8 @@ Develop, build and run an app, on servers, in containers and on phones.
|
|
|
12
12
|
- [Project scripts](../reference/cli.md#run): `protobase run` runs a seed or a migration script on the CLI's packages.
|
|
13
13
|
- [Migrate command](../reference/cli.md#migrate): `protobase migrate` applies the project's SQL migrations, with nothing installed, and `--plan` prints the SQL it would apply.
|
|
14
14
|
- [Migrations from config](../reference/cli.md#migration): Writes the SQL migrations for what the config turns on, as files of the project.
|
|
15
|
-
- [Schema snapshot](../reference/cli.md#migration) (beta): `protobase.snapshot.json` in the project describes the schema its migrations make, so each new migration is the next numbered file and the change shows in review. The sign-in tables are worked out from it without a database, `protobase migration check` fails CI when the config has a change the migrations lack, `drop` takes the newest file back, and `protobase migration baseline` starts the snapshot of an existing app from its database, once, without changing or dropping anything.
|
|
16
|
-
- [User and organization commands](../reference/cli.md#users): Create users, set roles and manage organizations from the terminal.
|
|
15
|
+
- [Schema snapshot](../reference/cli.md#migration) (beta): `protobase.snapshot.json` in the project describes the schema its migrations make, so each new migration is the next numbered file and the change shows in review. The sign-in tables and every built-in schema are worked out from it without a database, `protobase migration check` fails CI when the config has a change the migrations lack, `drop` takes the newest file back, and `protobase migration baseline` starts the snapshot of an existing app from its database, or records the built-in schemas an earlier version made, once, without changing or dropping anything.
|
|
16
|
+
- [User and organization commands](../reference/cli.md#users): Create users, set roles and manage organizations from the terminal, in the organization the config pins, another one you name, or every one when you ask.
|
|
17
17
|
- [Encryption commands](../reference/cli.md#encryption-status): Report and fix plaintext or old-key values of encrypted fields.
|
|
18
18
|
- [One bundle](../reference/cli.md#build): `protobase build` writes one folder with everything the app needs, without a database or secrets. It fails on a view that filters, sorts or searches by a field its resource does not allow.
|
|
19
19
|
- [Source maps](../reference/cli.md#source-maps): The bundle and plugins can carry source maps with debug ids, for an error tracker to read browser stack frames.
|
|
@@ -23,6 +23,8 @@ Develop, build and run an app, on servers, in containers and on phones.
|
|
|
23
23
|
- [Host module list](../reference/cli.md#the-config-module): Each release of `@protobase/cli` carries the modules its runtime supplies to a bundle as `@protobase/cli/host-modules.json`, for a host to check a bundle's imports against the version that serves it.
|
|
24
24
|
- [Migrations at update time](../guides/deploy.md#migrations): The bundle carries the project's migrations, and the runtime applies them before the new version serves, in batches of one transaction each, refusing a second run while one runs, with an `.after.sql` beside a file for statements such as `create index concurrently`, which a stopped run's next run finishes.
|
|
25
25
|
- [Migration record](../guides/deploy.md#the-record-of-migrations): Every migration file Protobase writes ends by adding its own row to `migrations.history`, so any tool that applies the file also records it. At startup the server reads the record: it starts when the database matches its version or is ahead only by additive migrations, and when the database is behind, it refuses and says what is missing and how to fix it.
|
|
26
|
+
- [Changes that break older code](../reference/cli.md#changes-that-break-older-code) (beta): `protobase migration` applies each new file to the database in a transaction it rolls back and names what the code still running would lose; Protobase's own parts keep what older code reads, a change only a hand-written file can make is refused with the way through, and a file that breaks older code makes the version before it refuse to start, saying rolling back is blocked. `protobase migration check` lints hand-written files with Postgres's own parser and warns of statements that lock reads.
|
|
27
|
+
- [Signing off an update](../reference/cli.md#signing-off-an-update) (beta): Sign off an update with `protobase migration contract` to archive what it retired, and remove it later with `protobase migration delete` once nothing writes it.
|
|
26
28
|
- [Release steps](../reference/cli.md#release-steps): `protobase-serve migrate-release` brings a database up to a release's own built-in schema steps straight from a built bundle, with a dry-run plan, without writing files into the project.
|
|
27
29
|
- [Single-file runtime](../reference/cli.md#build-serve): The runtime as one file, so a host needs only Bun and that file.
|
|
28
30
|
- [Separate worker](../reference/cli.md#worker): Jobs and event delivery in their own process.
|
|
@@ -8,7 +8,7 @@ Sign-in methods, users, roles, organizations and tokens.
|
|
|
8
8
|
- [Sign-in page](../reference/client.md#the-admin-app): The app signs people in at its own address, where the browser's Back returns to the step before, and signing in comes back to the page they were on.
|
|
9
9
|
- [First admin](../reference/auth.md#first-run): No account can be made over the web while the app has no users. You create the first admin from the terminal, and the last active admin cannot be deleted, demoted or blocked.
|
|
10
10
|
- [Users from a script](../reference/auth.md#first-run): A seed or another script of the project creates and lists users, and mints their tokens, on the app's own sign-in.
|
|
11
|
-
- [Versioned sign-in tables](../reference/auth.md#migrations): The sign-in tables come from numbered steps that ship with Protobase, a chain for each module of sign-in, written as the project's own migrations and recorded in the database, so a deploy checks them without comparing tables. Every step only adds, and one that assumes something of the rows already there checks it first and names the rows to fix.
|
|
11
|
+
- [Versioned sign-in tables](../reference/auth.md#migrations): The sign-in tables come from numbered steps that ship with Protobase, a chain for each module of sign-in, written as the project's own migrations and recorded in the database, so a deploy checks them without comparing tables. Every step only adds, and one that assumes something of the rows already there checks it first and names the rows to fix. A feature's tables exist only once the config turns it on, and turning it on is the next migration. Turning it off keeps its tables and rows, and the columns it adds to other tables, counting by hour the writes older code still makes to them, and turning it on again goes on from them, refusing while they hold rows unless `protobase migrate --force` brings them back. Archiving or deleting them is coming soon.
|
|
12
12
|
- [Table and column names](../reference/auth.md#table-and-column-names): Every sign-in table can take another name or a prefix, and every column but `id` another name, from the config, and the migrations, sign-in and Protobase's own queries all use it.
|
|
13
13
|
- [Existing users table](../reference/auth.md#an-existing-users-table): Sign-in can use the users table another system keeps in the same database.
|
|
14
14
|
- [Users page](../reference/auth.md#users-page): Admins find people, set roles, block them, add accounts and invite people by email.
|
|
@@ -39,6 +39,7 @@ Sign-in methods, users, roles, organizations and tokens.
|
|
|
39
39
|
- [Staff sign-in](../reference/auth.md#staff-sign-in): The team that runs an app signs in as a person to help them, with a reason and a log entry.
|
|
40
40
|
- [Roles](../reference/auth.md#roles): A user holds one or more roles and switches between them without signing in again.
|
|
41
41
|
- [Organizations](../reference/auth.md#organizations): People work in one organization at a time, see only its records, and are invited with their own roles.
|
|
42
|
+
- [The default organization](../reference/auth.md#the-default-organization) (beta): Turning organizations on makes the default organization your config names, with every existing user its member in the role you choose, and every personal access token working in it; turning them off keeps every row, and until they are turned back on, only members of the default organization can sign in and use their tokens.
|
|
42
43
|
- [First organization](../reference/auth.md#first-organization-and-start-address) (beta): People outside any organization name their first one, called by your app's word such as workspace, in one step, or join one they are invited to, and land on the start address your app sets. The screen says what it is doing while it creates or joins, and lets them try again after a network failure.
|
|
43
44
|
- [Status](../reference/status.md) (beta): People set themselves busy or do not disturb, with a text of their own such as "Having lunch" and a time it clears, from the user menu; the people they share an organization with see it beside their name, with your app's online or away mark on the members page and in the sidebar.
|
|
44
45
|
- [API tokens](../reference/auth.md#tokens-and-roles): A signed-in session gets short-lived tokens for the API.
|