@protobase/cli 0.21.7 → 0.21.8
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/dev/entry.js +9 -2
- package/dist/doctor/view-shapes.js +18 -0
- package/dist/migration/parts.js +32 -23
- package/dist/package.js +1 -1
- package/dist/serve/lifecycle.js +9 -2
- package/dist/worker/start-worker.js +5 -2
- package/package.json +6 -6
package/dist/dev/entry.js
CHANGED
|
@@ -2,13 +2,13 @@ import { devJobs } from "./dev-jobs.js";
|
|
|
2
2
|
import { projectErrorReporter } from "../project/error-reporter.js";
|
|
3
3
|
import { projectAdmin } from "../project/project-admin.js";
|
|
4
4
|
import { loadProject, projectDb } from "./project.js";
|
|
5
|
-
import { checkAuthSchema, checkChanges, checkWebhooksSchema, configExports, hasUsers } from "@protobase/server";
|
|
5
|
+
import { checkAi, checkAuthSchema, checkChanges, checkComments, checkWebhooksSchema, configExports, hasUsers } from "@protobase/server";
|
|
6
6
|
import { Hono } from "hono";
|
|
7
7
|
//#region src/dev/entry.ts
|
|
8
8
|
const projectDir = process.env.PROTOBASE_PROJECT;
|
|
9
9
|
const project = await loadProject(projectDir, JSON.parse(process.env.PROTOBASE_EXTENSIONS ?? "[]"));
|
|
10
10
|
const db = projectDb(project, projectDir);
|
|
11
|
-
const { resources } = configExports(project.exports);
|
|
11
|
+
const { resources, views } = configExports(project.exports);
|
|
12
12
|
if (!project.authenticate) throw new Error("No authenticator: export `authenticate` (and `auth`) from protobase.config.ts; see https://docs.protobase.net/reference/auth/");
|
|
13
13
|
const store = globalThis;
|
|
14
14
|
if (project.auth && !store.__protobaseAuthSchemaChecked) {
|
|
@@ -16,6 +16,13 @@ if (project.auth && !store.__protobaseAuthSchemaChecked) {
|
|
|
16
16
|
store.__protobaseAuthSchemaChecked = true;
|
|
17
17
|
}
|
|
18
18
|
await checkChanges(db, resources.map((resource) => resource.toModel()), project.events);
|
|
19
|
+
await checkComments(db, resources.map((resource) => resource.toModel()));
|
|
20
|
+
checkAi({
|
|
21
|
+
models: resources.map((resource) => resource.toModel()),
|
|
22
|
+
views: views.map((source) => source.toModel()),
|
|
23
|
+
assistant: project.options?.assistant,
|
|
24
|
+
env: process.env
|
|
25
|
+
});
|
|
19
26
|
if (project.webhooks) await checkWebhooksSchema(db, project.webhooks);
|
|
20
27
|
const reporter = await projectErrorReporter(project, process.env);
|
|
21
28
|
const { admin, jobs } = projectAdmin({
|
|
@@ -138,6 +138,24 @@ const displayShapes = (model, view, models) => (view.list?.displays ?? []).flatM
|
|
|
138
138
|
}
|
|
139
139
|
}];
|
|
140
140
|
}
|
|
141
|
+
if (display.kind === "calendar") {
|
|
142
|
+
const start = model.fields[display.start];
|
|
143
|
+
if (!start) return [];
|
|
144
|
+
const end = display.end === void 0 ? void 0 : model.fields[display.end];
|
|
145
|
+
const sort = [[start.name, "asc"]];
|
|
146
|
+
const within = all([compare(start, ">="), compare(start, "<")]);
|
|
147
|
+
const filter = end ? any([within, all([compare(start, "<"), compare(end, ">=")])]) : within;
|
|
148
|
+
const text = end ? `(${start.name} >= … AND ${start.name} < …) OR (${start.name} < … AND ${end.name} >= …)` : `${start.name} >= … AND ${start.name} < …`;
|
|
149
|
+
return [{
|
|
150
|
+
resource: model.name,
|
|
151
|
+
request: request(model.name, text, sort),
|
|
152
|
+
from: `the calendar display "${display.name}"`,
|
|
153
|
+
query: {
|
|
154
|
+
filter,
|
|
155
|
+
sort
|
|
156
|
+
}
|
|
157
|
+
}];
|
|
158
|
+
}
|
|
141
159
|
const photos = display.kind === "cards" ? display.photos : void 0;
|
|
142
160
|
const holder = photos && models[photos.resource];
|
|
143
161
|
const field = holder?.fields[photos.field];
|
package/dist/migration/parts.js
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
import { authSchemaMigration, changesMigration, isCaptured, jobsSchemaMigration, webhooksMigration } from "@protobase/server";
|
|
1
|
+
import { authSchemaMigration, changesMigration, commentsMigration, isCaptured, jobsSchemaMigration, webhooksMigration } from "@protobase/server";
|
|
2
2
|
//#region src/migration/parts.ts
|
|
3
3
|
/** Every feature the project's config enables, in the order their files are written. */
|
|
4
|
-
const migrationParts = (project) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
4
|
+
const migrationParts = (project) => {
|
|
5
|
+
const comments = project.models.some((model) => model.comments);
|
|
6
|
+
const aiFields = project.models.some((model) => Object.values(model.fields).some((field) => field.ai));
|
|
7
|
+
return [
|
|
8
|
+
...project.auth ? [{
|
|
9
|
+
name: "auth",
|
|
10
|
+
title: "The auth schema changes this version of Protobase needs",
|
|
11
|
+
sql: () => authSchemaMigration(project.auth)
|
|
12
|
+
}] : [],
|
|
13
|
+
...project.jobs.length > 0 || project.models.some(isCaptured) || comments || aiFields || project.webhooks ? [{
|
|
14
|
+
name: "jobs",
|
|
15
|
+
title: "The jobs schema this version of Protobase needs",
|
|
16
|
+
sql: () => jobsSchemaMigration(project.db)
|
|
17
|
+
}] : [],
|
|
18
|
+
{
|
|
19
|
+
name: "changes",
|
|
20
|
+
title: "The change capture the resources' events and history need",
|
|
21
|
+
sql: () => changesMigration(project.db, project.models, project.events)
|
|
22
|
+
},
|
|
23
|
+
...comments ? [{
|
|
24
|
+
name: "comments",
|
|
25
|
+
title: "The comments table of the resources with comments",
|
|
26
|
+
sql: () => commentsMigration(project.db)
|
|
27
|
+
}] : [],
|
|
28
|
+
...project.webhooks ? [{
|
|
29
|
+
name: "webhooks",
|
|
30
|
+
title: "The webhook subscriptions of webhooks()",
|
|
31
|
+
sql: () => webhooksMigration(project.db, project.webhooks, project.events)
|
|
32
|
+
}] : []
|
|
33
|
+
];
|
|
34
|
+
};
|
|
26
35
|
//#endregion
|
|
27
36
|
export { migrationParts };
|
package/dist/package.js
CHANGED
package/dist/serve/lifecycle.js
CHANGED
|
@@ -2,7 +2,7 @@ import { projectAdmin } from "../project/project-admin.js";
|
|
|
2
2
|
import { createPgDb } from "../project/pg-db.js";
|
|
3
3
|
import { createServeApp } from "./app.js";
|
|
4
4
|
import { startCleanupTimer } from "./cleanup-timer.js";
|
|
5
|
-
import { checkAuthSchema, checkChanges, checkJobsSchema, checkWebhooksSchema, configExports, createFileCleanup, startJobs } from "@protobase/server";
|
|
5
|
+
import { checkAi, checkAuthSchema, checkChanges, checkComments, checkJobsSchema, checkWebhooksSchema, configExports, createFileCleanup, startJobs } from "@protobase/server";
|
|
6
6
|
import pg from "pg";
|
|
7
7
|
import { createAdaptorServer } from "@hono/node-server";
|
|
8
8
|
//#region src/serve/lifecycle.ts
|
|
@@ -19,9 +19,16 @@ const startServe = async ({ project, env, createDb = (url) => createPgDb(pg, url
|
|
|
19
19
|
if (env.startupChecks && project.auth) await checkAuthSchema(project.auth);
|
|
20
20
|
const ownDb = project.db ? void 0 : createDb(env.databaseUrl);
|
|
21
21
|
const db = project.db ?? ownDb;
|
|
22
|
-
const { resources } = configExports(project.config);
|
|
22
|
+
const { resources, views } = configExports(project.config);
|
|
23
23
|
const startJobsAndListen = async () => {
|
|
24
24
|
if (env.startupChecks) await checkChanges(db, resources.map((resource) => resource.toModel()), project.events);
|
|
25
|
+
if (env.startupChecks) await checkComments(db, resources.map((resource) => resource.toModel()));
|
|
26
|
+
if (env.startupChecks) checkAi({
|
|
27
|
+
models: resources.map((resource) => resource.toModel()),
|
|
28
|
+
views: views.map((source) => source.toModel()),
|
|
29
|
+
assistant: project.options?.assistant,
|
|
30
|
+
env: process.env
|
|
31
|
+
});
|
|
25
32
|
if (env.startupChecks && project.webhooks) await checkWebhooksSchema(db, project.webhooks);
|
|
26
33
|
const { admin, jobs: definitions } = projectAdmin(project, project.config, db, ui, reporter);
|
|
27
34
|
if (env.startupChecks && definitions.length > 0) await checkJobsSchema(db);
|
|
@@ -17,8 +17,11 @@ const bundleConfigFile = async (bundle) => {
|
|
|
17
17
|
* their own. It reads the jobs schema at start and refuses one that is missing or behind, like `serve`.
|
|
18
18
|
*/
|
|
19
19
|
const startWorker = async ({ project, databaseUrl, createDb = (url) => createPgDb(pg, url) }) => {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const builtIn = configExports(project.config).resources.some((resource) => {
|
|
21
|
+
const model = resource.toModel();
|
|
22
|
+
return isCaptured(model) || model.comments || Object.values(model.fields).some((field) => field.ai);
|
|
23
|
+
});
|
|
24
|
+
if (jobDefinitions(project.jobs ?? {}).length === 0 && !builtIn) throw new Error("The bundle has no jobs: export them from protobase.config.ts as `jobs`, or give a resource events, history, comments or an AI field");
|
|
22
25
|
if (!project.db && !databaseUrl) throw new Error("No database: set DATABASE_URL or export `db` from protobase.config.ts");
|
|
23
26
|
const ownDb = project.db ? void 0 : createDb(databaseUrl);
|
|
24
27
|
const db = project.db ?? ownDb;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.8",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@hono/node-server": "^2.1.3",
|
|
36
36
|
"@hono/vite-dev-server": "^0.26.1",
|
|
37
|
-
"@protobase/layout": "0.21.
|
|
38
|
-
"@protobase/query": "0.21.
|
|
39
|
-
"@protobase/schema": "0.21.
|
|
40
|
-
"@protobase/server": "0.21.
|
|
41
|
-
"@protobase/ui": "0.21.
|
|
37
|
+
"@protobase/layout": "0.21.8",
|
|
38
|
+
"@protobase/query": "0.21.8",
|
|
39
|
+
"@protobase/schema": "0.21.8",
|
|
40
|
+
"@protobase/server": "0.21.8",
|
|
41
|
+
"@protobase/ui": "0.21.8",
|
|
42
42
|
"@react-email/render": "^2.1.0",
|
|
43
43
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
44
44
|
"@tailwindcss/vite": "^4.3.3",
|