@protobase/server 0.28.2 → 0.28.3
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/create-admin.js +3 -1
- package/dist/functions/routes.js +6 -4
- package/package.json +4 -4
package/dist/create-admin.js
CHANGED
|
@@ -4,6 +4,7 @@ import { unauthorized } from "./problem.js";
|
|
|
4
4
|
import { fillHook } from "./ai/fill-hook.js";
|
|
5
5
|
import { createErrorHandler } from "./error-handler.js";
|
|
6
6
|
import { isCaptured } from "./changes/capture-sql.js";
|
|
7
|
+
import { wakeDispatch } from "./changes/actor.js";
|
|
7
8
|
import { assistantRecords } from "./assistant/records.js";
|
|
8
9
|
import { fillJob } from "./ai/fill-job.js";
|
|
9
10
|
import { assistantSettings } from "./assistant/assistant-settings.js";
|
|
@@ -271,7 +272,8 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
|
|
|
271
272
|
authenticate,
|
|
272
273
|
db,
|
|
273
274
|
records: (session) => callerRecords(deps, session),
|
|
274
|
-
onError
|
|
275
|
+
onError,
|
|
276
|
+
wake: () => wakeDispatch(deps)
|
|
275
277
|
}));
|
|
276
278
|
app.route("/", batchRoute(deps, authenticate, meta));
|
|
277
279
|
app.route("/", fileRoutes(deps, authenticate));
|
package/dist/functions/routes.js
CHANGED
|
@@ -16,9 +16,10 @@ const requireRoles = (name, session, roles) => {
|
|
|
16
16
|
/**
|
|
17
17
|
* Every function at `<basePath>/<name>` and below, any method. A protected function authenticates the request first, so
|
|
18
18
|
* a call without a valid token is the authenticator's 401 problem; a public one gets the caller only when it asks. Each
|
|
19
|
-
* call runs as background work, so calls that hold the database for long leave a connection to page requests.
|
|
19
|
+
* call runs as background work, so calls that hold the database for long leave a connection to page requests. Once a
|
|
20
|
+
* call ends, failed or not, `wake` runs, so what it wrote reaches open pages without waiting for the dispatcher's poll.
|
|
20
21
|
*/
|
|
21
|
-
const functionRoutes = ({ basePath, functions, authenticate, db, records, onError }) => {
|
|
22
|
+
const functionRoutes = ({ basePath, functions, authenticate, db, records, onError, wake }) => {
|
|
22
23
|
const app = new Hono().basePath(basePath);
|
|
23
24
|
app.onError(onError);
|
|
24
25
|
const callerOf = async (request) => {
|
|
@@ -28,11 +29,12 @@ const functionRoutes = ({ basePath, functions, authenticate, db, records, onErro
|
|
|
28
29
|
records: records(session)
|
|
29
30
|
};
|
|
30
31
|
};
|
|
32
|
+
const call = (work) => work().finally(wake);
|
|
31
33
|
for (const [name, fn] of Object.entries(functions)) {
|
|
32
34
|
const prefix = `${basePath}/${name}`;
|
|
33
35
|
const { options } = fn;
|
|
34
36
|
if (options.cors) app.use(`/${name}/*`, cors(options.cors));
|
|
35
|
-
app.all(`/${name}/*`, (c) => runInBackground(async () => {
|
|
37
|
+
app.all(`/${name}/*`, (c) => runInBackground(() => call(async () => {
|
|
36
38
|
const request = relativeRequest(c.req.raw, prefix);
|
|
37
39
|
if (options.public) {
|
|
38
40
|
let caller;
|
|
@@ -51,7 +53,7 @@ const functionRoutes = ({ basePath, functions, authenticate, db, records, onErro
|
|
|
51
53
|
caller: async () => caller
|
|
52
54
|
};
|
|
53
55
|
return invokeFunction(name, fn, request, context);
|
|
54
|
-
}));
|
|
56
|
+
})));
|
|
55
57
|
}
|
|
56
58
|
app.all("/*", (c) => {
|
|
57
59
|
throw notFound(`There is no function at ${c.req.path}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/server",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.3",
|
|
4
4
|
"description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@better-auth/passkey": "^1.7.7",
|
|
34
34
|
"@better-auth/sso": "^1.7.7",
|
|
35
|
-
"@protobase/layout": "0.28.
|
|
36
|
-
"@protobase/query": "0.28.
|
|
37
|
-
"@protobase/schema": "0.28.
|
|
35
|
+
"@protobase/layout": "0.28.3",
|
|
36
|
+
"@protobase/query": "0.28.3",
|
|
37
|
+
"@protobase/schema": "0.28.3",
|
|
38
38
|
"@react-email/render": "^2.1.0",
|
|
39
39
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
40
40
|
"@sentry/core": "^11.7.0",
|