@micacms/runtime 0.4.1 → 0.5.0-rc.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/README.md +2 -2
- package/dist/app.d.ts +8 -37
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +7 -42
- package/dist/app.js.map +1 -1
- package/dist/config.d.ts +12 -82
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -82
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +37 -66
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +24 -75
- package/dist/context.js.map +1 -1
- package/dist/http.d.ts +8 -16
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +6 -13
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +13 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/dist/routes/admin-content.d.ts +4 -17
- package/dist/routes/admin-content.d.ts.map +1 -1
- package/dist/routes/admin-content.js +11 -51
- package/dist/routes/admin-content.js.map +1 -1
- package/dist/routes/admin-media.d.ts +3 -14
- package/dist/routes/admin-media.d.ts.map +1 -1
- package/dist/routes/admin-media.js +7 -29
- package/dist/routes/admin-media.js.map +1 -1
- package/dist/routes/admin-staging.d.ts +4 -9
- package/dist/routes/admin-staging.d.ts.map +1 -1
- package/dist/routes/admin-staging.js +31 -18
- package/dist/routes/admin-staging.js.map +1 -1
- package/dist/routes/admin-system.d.ts +2 -8
- package/dist/routes/admin-system.d.ts.map +1 -1
- package/dist/routes/admin-system.js +9 -44
- package/dist/routes/admin-system.js.map +1 -1
- package/dist/routes/health.d.ts +3 -10
- package/dist/routes/health.d.ts.map +1 -1
- package/dist/routes/health.js +9 -26
- package/dist/routes/health.js.map +1 -1
- package/dist/schema.d.ts +10 -38
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +14 -65
- package/dist/schema.js.map +1 -1
- package/dist/server.d.ts +2 -10
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -9
- package/dist/server.js.map +1 -1
- package/dist/services/changes.d.ts +150 -0
- package/dist/services/changes.d.ts.map +1 -0
- package/dist/services/changes.js +339 -0
- package/dist/services/changes.js.map +1 -0
- package/dist/services/content-store.d.ts +61 -0
- package/dist/services/content-store.d.ts.map +1 -0
- package/dist/services/content-store.js +330 -0
- package/dist/services/content-store.js.map +1 -0
- package/dist/services/media.d.ts +9 -29
- package/dist/services/media.d.ts.map +1 -1
- package/dist/services/media.js +17 -57
- package/dist/services/media.js.map +1 -1
- package/dist/services/staging.d.ts +35 -167
- package/dist/services/staging.d.ts.map +1 -1
- package/dist/services/staging.js +195 -458
- package/dist/services/staging.js.map +1 -1
- package/dist/workspace/developer.d.ts +14 -0
- package/dist/workspace/developer.d.ts.map +1 -0
- package/dist/workspace/developer.js +31 -0
- package/dist/workspace/developer.js.map +1 -0
- package/dist/workspace/files.d.ts +70 -0
- package/dist/workspace/files.d.ts.map +1 -0
- package/dist/workspace/files.js +176 -0
- package/dist/workspace/files.js.map +1 -0
- package/dist/workspace/git.d.ts +45 -0
- package/dist/workspace/git.d.ts.map +1 -0
- package/dist/workspace/git.js +68 -0
- package/dist/workspace/git.js.map +1 -0
- package/dist/workspace/locks.d.ts +33 -0
- package/dist/workspace/locks.d.ts.map +1 -0
- package/dist/workspace/locks.js +76 -0
- package/dist/workspace/locks.js.map +1 -0
- package/dist/workspace/policy.d.ts +92 -0
- package/dist/workspace/policy.d.ts.map +1 -0
- package/dist/workspace/policy.js +7 -0
- package/dist/workspace/policy.js.map +1 -0
- package/dist/workspace/tree.d.ts +73 -0
- package/dist/workspace/tree.d.ts.map +1 -0
- package/dist/workspace/tree.js +229 -0
- package/dist/workspace/tree.js.map +1 -0
- package/package.json +2 -3
- package/dist/db/driver.d.ts +0 -35
- package/dist/db/driver.d.ts.map +0 -1
- package/dist/db/driver.js +0 -95
- package/dist/db/driver.js.map +0 -1
- package/dist/lib/git.d.ts +0 -29
- package/dist/lib/git.d.ts.map +0 -1
- package/dist/lib/git.js +0 -62
- package/dist/lib/git.js.map +0 -1
- package/dist/services/staging-local.d.ts +0 -58
- package/dist/services/staging-local.d.ts.map +0 -1
- package/dist/services/staging-local.js +0 -391
- package/dist/services/staging-local.js.map +0 -1
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Admin
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* validation, slugs and layout lives in the store, which is shared with the
|
|
6
|
-
* Astro build rather than reimplemented here.
|
|
7
|
-
*
|
|
8
|
-
* Three things shape this surface:
|
|
9
|
-
*
|
|
10
|
-
* - An entry is addressed by `collection/slug`. The path in the API is the
|
|
11
|
-
* path in the repository, so a URL here can be read off a diff.
|
|
12
|
-
* - There are no revision endpoints. Git is the history.
|
|
13
|
-
* - There is no status endpoint. Committed is published, and a draft is
|
|
14
|
-
* unsaved work in the editor that never reaches the server.
|
|
15
|
-
*
|
|
16
|
-
* `revision` is what makes concurrent editing safe: an opaque token naming the
|
|
17
|
-
* version an editor opened, sent back with the save.
|
|
2
|
+
* Admin routes for entries and singletons. The content store holds every rule;
|
|
3
|
+
* these routes only parse and serialize. The API path is the repository path,
|
|
4
|
+
* Git is the history, and `revision` makes concurrent edits safe.
|
|
18
5
|
*/
|
|
19
|
-
import {
|
|
6
|
+
import { ValidationError } from "../services/content-store.js";
|
|
7
|
+
import { ConflictError } from "../workspace/files.js";
|
|
20
8
|
import { collectionEntryPath, compareEntries, entryTitle, singletonPath } from "@micacms/core";
|
|
21
9
|
import { Hono } from "hono";
|
|
22
10
|
import { z } from "zod";
|
|
23
11
|
import { ApiError, badRequest, notFound } from "../lib/errors.js";
|
|
24
|
-
import { actorOf } from "../http.js";
|
|
25
12
|
const saveSchema = z.object({
|
|
26
13
|
data: z.record(z.string(), z.unknown()),
|
|
27
14
|
slug: z.string().max(120).optional(),
|
|
28
15
|
/**
|
|
29
|
-
* The revision the editor opened. `null` asserts the entry
|
|
30
|
-
*
|
|
31
|
-
* overwriting the other.
|
|
16
|
+
* The revision the editor opened. `null` asserts that the entry does not
|
|
17
|
+
* exist, so two parallel creates cannot overwrite.
|
|
32
18
|
*/
|
|
33
19
|
revision: z.string().nullable().optional(),
|
|
34
20
|
});
|
|
@@ -38,13 +24,7 @@ async function jsonBody(c) {
|
|
|
38
24
|
throw badRequest("The request body must be valid JSON.");
|
|
39
25
|
});
|
|
40
26
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Turns a store failure into the HTTP answer it deserves.
|
|
43
|
-
*
|
|
44
|
-
* A conflict is 409 and is recoverable in the editor — reload and reapply. A
|
|
45
|
-
* validation failure is 422 with the offending fields. Everything else is a
|
|
46
|
-
* genuine fault and reaches the error handler unchanged.
|
|
47
|
-
*/
|
|
27
|
+
/** Maps a conflict to 409 and a validation failure to 422; other errors go to the error handler. */
|
|
48
28
|
async function handled(run) {
|
|
49
29
|
try {
|
|
50
30
|
return await run();
|
|
@@ -60,7 +40,6 @@ async function handled(run) {
|
|
|
60
40
|
}
|
|
61
41
|
export function adminContentRoutes() {
|
|
62
42
|
const app = new Hono();
|
|
63
|
-
/* ------------------------------------------------------------ entries */
|
|
64
43
|
app.get("/collections/:collection/entries", async (c) => {
|
|
65
44
|
const { content } = c.get("ctx").services;
|
|
66
45
|
const collection = c.req.param("collection");
|
|
@@ -74,13 +53,8 @@ export function adminContentRoutes() {
|
|
|
74
53
|
title: entryTitle(def, entry.data),
|
|
75
54
|
data: entry.data,
|
|
76
55
|
}))
|
|
77
|
-
//
|
|
78
|
-
// Content trees are small enough that filtering in memory is simpler than
|
|
79
|
-
// an index, and it can no longer disagree with what is on disk.
|
|
56
|
+
// Content trees are small, so an in-memory substring match is sufficient.
|
|
80
57
|
.filter((item) => !search || JSON.stringify(item.data).toLowerCase().includes(search))
|
|
81
|
-
// The order the model asks for — newest first for news, by hand for a
|
|
82
|
-
// menu. Ties fall back to the manual position, so the list is stable
|
|
83
|
-
// between requests whatever the sort field says.
|
|
84
58
|
.sort(compareEntries(def));
|
|
85
59
|
return c.json({ items, total: items.length });
|
|
86
60
|
});
|
|
@@ -91,9 +65,7 @@ export function adminContentRoutes() {
|
|
|
91
65
|
throw badRequest("The entry payload is malformed.");
|
|
92
66
|
const saved = await handled(() => content.save(c.req.param("collection"), {
|
|
93
67
|
data: parsed.data.data,
|
|
94
|
-
// A create asserts absence unless the client says otherwise.
|
|
95
68
|
expectedRevision: parsed.data.revision ?? null,
|
|
96
|
-
author: actorOf(c) ? { name: actorOf(c).email, email: actorOf(c).email } : undefined,
|
|
97
69
|
}));
|
|
98
70
|
return c.json(saved, 201);
|
|
99
71
|
});
|
|
@@ -129,12 +101,8 @@ export function adminContentRoutes() {
|
|
|
129
101
|
position: entry.position,
|
|
130
102
|
title: entryTitle(def, entry.data),
|
|
131
103
|
data: entry.data,
|
|
132
|
-
//
|
|
133
|
-
// entry is one file or a directory depends on whether it has rich text or
|
|
134
|
-
// media — a rule the editor should not have to reimplement to show it.
|
|
104
|
+
// From the model, so the editor need not know when an entry is a directory.
|
|
135
105
|
path: collectionEntryPath(def.fields, collection, entry.slug),
|
|
136
|
-
// Sent back with the save. Without it the editor cannot tell the server
|
|
137
|
-
// which version of the entry it was looking at.
|
|
138
106
|
revision: await content.revisionOf(collection, slug),
|
|
139
107
|
});
|
|
140
108
|
});
|
|
@@ -143,21 +111,16 @@ export function adminContentRoutes() {
|
|
|
143
111
|
const parsed = saveSchema.safeParse(await jsonBody(c));
|
|
144
112
|
if (!parsed.success)
|
|
145
113
|
throw badRequest("The entry payload is malformed.");
|
|
146
|
-
const actor = actorOf(c);
|
|
147
114
|
const saved = await handled(() => content.save(c.req.param("collection"), {
|
|
148
115
|
data: parsed.data.data,
|
|
149
116
|
slug: c.req.param("slug"),
|
|
150
117
|
expectedRevision: parsed.data.revision,
|
|
151
|
-
author: actor ? { name: actor.email, email: actor.email } : undefined,
|
|
152
118
|
}));
|
|
153
119
|
return c.json(saved);
|
|
154
120
|
});
|
|
155
121
|
app.delete("/collections/:collection/entries/:slug", async (c) => {
|
|
156
122
|
const { content } = c.get("ctx").services;
|
|
157
|
-
|
|
158
|
-
await handled(() => content.remove(c.req.param("collection"), c.req.param("slug"), {
|
|
159
|
-
author: actor ? { name: actor.email, email: actor.email } : undefined,
|
|
160
|
-
}));
|
|
123
|
+
await handled(() => content.remove(c.req.param("collection"), c.req.param("slug")));
|
|
161
124
|
return c.json({ ok: true });
|
|
162
125
|
});
|
|
163
126
|
/** Entries elsewhere that point at this one — shown before a delete. */
|
|
@@ -166,7 +129,6 @@ export function adminContentRoutes() {
|
|
|
166
129
|
const references = await handled(() => content.findReferences(c.req.param("collection"), c.req.param("slug")));
|
|
167
130
|
return c.json({ references });
|
|
168
131
|
});
|
|
169
|
-
/* --------------------------------------------------------- singletons */
|
|
170
132
|
app.get("/singletons/:name", async (c) => {
|
|
171
133
|
const { content } = c.get("ctx").services;
|
|
172
134
|
const name = c.req.param("name");
|
|
@@ -182,10 +144,8 @@ export function adminContentRoutes() {
|
|
|
182
144
|
app.put("/singletons/:name", async (c) => {
|
|
183
145
|
const { content } = c.get("ctx").services;
|
|
184
146
|
const body = (await jsonBody(c));
|
|
185
|
-
const actor = actorOf(c);
|
|
186
147
|
const saved = await handled(() => content.saveSingleton(c.req.param("name"), body?.data ?? {}, {
|
|
187
148
|
expectedRevision: body?.revision,
|
|
188
|
-
author: actor ? { name: actor.email, email: actor.email } : undefined,
|
|
189
149
|
}));
|
|
190
150
|
return c.json(saved);
|
|
191
151
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-content.js","sourceRoot":"","sources":["../../src/routes/admin-content.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin-content.js","sourceRoot":"","sources":["../../src/routes/admin-content.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CA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AEF,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Admin media routes.
|
|
3
|
-
*
|
|
4
|
-
* Media is files in the content repository now, so these routes are much
|
|
5
|
-
* smaller than they were. There is no upload table to keep in step, no storage
|
|
6
|
-
* key to generate, and no delete endpoint — removing a file that an entry still
|
|
7
|
-
* references is a content decision made in a diff, not an API call.
|
|
8
|
-
*
|
|
9
|
-
* Uploads are committed on their own rather than folded into the entry save.
|
|
10
|
-
* The editor needs a path to put in the field before it can save the entry that
|
|
11
|
-
* references it, and a two-step flow is the honest way to say so. The cost is
|
|
12
|
-
* an occasional unreferenced file, which is visible in the repository and
|
|
13
|
-
* cheap to remove; the alternative would be holding uploads in server memory
|
|
14
|
-
* between requests.
|
|
2
|
+
* Admin media routes. Media is files in the content repository, and there is no delete endpoint.
|
|
3
|
+
* An upload is written on its own, before the entry save, because the editor needs its path first.
|
|
15
4
|
*/
|
|
16
5
|
import { Hono } from "hono";
|
|
17
|
-
import {
|
|
6
|
+
import type { Env } from "../http.js";
|
|
18
7
|
export declare function adminMediaRoutes(): Hono<Env>;
|
|
19
8
|
//# sourceMappingURL=admin-media.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-media.d.ts","sourceRoot":"","sources":["../../src/routes/admin-media.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin-media.d.ts","sourceRoot":"","sources":["../../src/routes/admin-media.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAK5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,wBAAgB,gBAAgB,IAAI,IAAI,CAAC,GAAG,CAAC,CA+E5C"}
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Admin media routes.
|
|
3
|
-
*
|
|
4
|
-
* Media is files in the content repository now, so these routes are much
|
|
5
|
-
* smaller than they were. There is no upload table to keep in step, no storage
|
|
6
|
-
* key to generate, and no delete endpoint — removing a file that an entry still
|
|
7
|
-
* references is a content decision made in a diff, not an API call.
|
|
8
|
-
*
|
|
9
|
-
* Uploads are committed on their own rather than folded into the entry save.
|
|
10
|
-
* The editor needs a path to put in the field before it can save the entry that
|
|
11
|
-
* references it, and a two-step flow is the honest way to say so. The cost is
|
|
12
|
-
* an occasional unreferenced file, which is visible in the repository and
|
|
13
|
-
* cheap to remove; the alternative would be holding uploads in server memory
|
|
14
|
-
* between requests.
|
|
2
|
+
* Admin media routes. Media is files in the content repository, and there is no delete endpoint.
|
|
3
|
+
* An upload is written on its own, before the entry save, because the editor needs its path first.
|
|
15
4
|
*/
|
|
16
5
|
import { Hono } from "hono";
|
|
17
6
|
import { badRequest, notFound } from "../lib/errors.js";
|
|
18
7
|
import { isImageType } from "../lib/file-type.js";
|
|
19
8
|
import { MAX_FILES_PER_UPLOAD } from "../middleware/index.js";
|
|
20
|
-
import { actorOf } from "../http.js";
|
|
21
9
|
export function adminMediaRoutes() {
|
|
22
10
|
const app = new Hono();
|
|
23
11
|
app.get("/", async (c) => {
|
|
@@ -29,9 +17,7 @@ export function adminMediaRoutes() {
|
|
|
29
17
|
const form = await c.req.formData().catch(() => {
|
|
30
18
|
throw badRequest("Expected a multipart upload.");
|
|
31
19
|
});
|
|
32
|
-
//
|
|
33
|
-
// structurally different. The runtime check is the same either way; the
|
|
34
|
-
// cast is only to pick one of them for the compiler.
|
|
20
|
+
// The cast picks one of the two structurally different `File` types (Node's and undici's).
|
|
35
21
|
const files = form
|
|
36
22
|
.getAll("file")
|
|
37
23
|
.filter((value) => typeof value !== "string");
|
|
@@ -41,33 +27,25 @@ export function adminMediaRoutes() {
|
|
|
41
27
|
throw badRequest(`Upload at most ${MAX_FILES_PER_UPLOAD} files at a time.`);
|
|
42
28
|
}
|
|
43
29
|
const accept = form.get("accept");
|
|
44
|
-
//
|
|
45
|
-
// the shared one. The media service refuses anything else.
|
|
30
|
+
// An entry's own `media/` directory or the shared one; the media service refuses anything else.
|
|
46
31
|
const directory = typeof form.get("directory") === "string" ? String(form.get("directory")) : undefined;
|
|
47
32
|
const prepared = await Promise.all(files.map((file) => ctx.services.media.prepare({
|
|
48
33
|
file,
|
|
49
34
|
directory,
|
|
50
35
|
accept: accept === "image" || accept === "document" ? accept : "any",
|
|
51
36
|
})));
|
|
52
|
-
|
|
53
|
-
await ctx.site.contentRepository.commit({
|
|
54
|
-
message: `Media: upload ${prepared.map((item) => item.file.filename).join(", ")}`,
|
|
37
|
+
await ctx.site.contentRepository.apply({
|
|
55
38
|
changes: prepared.map((item) => ({
|
|
56
39
|
type: "write",
|
|
57
40
|
path: item.file.path,
|
|
58
41
|
contents: item.contents,
|
|
59
42
|
})),
|
|
60
|
-
author: actor ? { name: actor.email, email: actor.email } : undefined,
|
|
61
43
|
});
|
|
62
44
|
return c.json({ items: prepared.map((item) => item.file) }, 201);
|
|
63
45
|
});
|
|
64
46
|
/**
|
|
65
|
-
* Serves a file to the editor.
|
|
66
|
-
*
|
|
67
|
-
* Behind the admin session, unlike the old `/media/*`, which had to be public
|
|
68
|
-
* so that the Astro build could fetch it. The build reads the repository
|
|
69
|
-
* directly now, so nothing outside this session needs these bytes and the
|
|
70
|
-
* whole "media is effectively public" trade-off disappears with the route.
|
|
47
|
+
* Serves a file to the editor, behind the admin gate. The site build reads
|
|
48
|
+
* the repository, not this route.
|
|
71
49
|
*/
|
|
72
50
|
app.get("/file/*", async (c) => {
|
|
73
51
|
const { media } = c.get("ctx").services;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-media.js","sourceRoot":"","sources":["../../src/routes/admin-media.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin-media.js","sourceRoot":"","sources":["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liberately. The commit is real and the
|
|
9
|
-
* state is recoverable by design; an error status would make the editor treat
|
|
10
|
-
* a publication that half-happened as one that did not happen at all.
|
|
2
|
+
* Admin routes for the pending changes and Publish. Sync and conflict
|
|
3
|
+
* resolution exist only for a clone that Mica keeps. `committed-pending-push`
|
|
4
|
+
* is a 200: the commit is real, and an error status would tell the editor that
|
|
5
|
+
* nothing happened.
|
|
11
6
|
*/
|
|
12
7
|
import { Hono } from "hono";
|
|
13
8
|
import { type Env } from "../http.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-staging.d.ts","sourceRoot":"","sources":["../../src/routes/admin-staging.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin-staging.d.ts","sourceRoot":"","sources":["../../src/routes/admin-staging.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AA4C/C,wBAAgB,kBAAkB,IAAI,IAAI,CAAC,GAAG,CAAC,CAuE9C"}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Admin
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* onto the API's error envelope.
|
|
7
|
-
*
|
|
8
|
-
* `committed-pending-push` is a 200, deliberately. The commit is real and the
|
|
9
|
-
* state is recoverable by design; an error status would make the editor treat
|
|
10
|
-
* a publication that half-happened as one that did not happen at all.
|
|
2
|
+
* Admin routes for the pending changes and Publish. Sync and conflict
|
|
3
|
+
* resolution exist only for a clone that Mica keeps. `committed-pending-push`
|
|
4
|
+
* is a 200: the commit is real, and an error status would tell the editor that
|
|
5
|
+
* nothing happened.
|
|
11
6
|
*/
|
|
12
|
-
import { ConflictError } from "@micacms/connectors";
|
|
13
7
|
import { Hono } from "hono";
|
|
14
8
|
import { z } from "zod";
|
|
15
|
-
import { ApiError, badRequest } from "../lib/errors.js";
|
|
16
9
|
import { actorOf } from "../http.js";
|
|
10
|
+
import { ApiError, badRequest } from "../lib/errors.js";
|
|
11
|
+
import { ConflictError } from "../workspace/files.js";
|
|
17
12
|
const publishSchema = z.object({
|
|
18
13
|
message: z.string().max(500),
|
|
19
|
-
/** The
|
|
20
|
-
|
|
14
|
+
/** The reviewed paths, with the revision each had in the review. */
|
|
15
|
+
paths: z.record(z.string().min(1), z.string().nullable()),
|
|
16
|
+
});
|
|
17
|
+
const resolveSchema = z.object({
|
|
18
|
+
group: z.string().min(1),
|
|
19
|
+
choice: z.enum(["mine", "website"]),
|
|
21
20
|
});
|
|
22
21
|
const discardSchema = z.object({ paths: z.array(z.string().min(1)).min(1).max(2000) });
|
|
23
22
|
const compareSchema = z.discriminatedUnion("kind", [
|
|
@@ -52,8 +51,7 @@ export function adminStagingRoutes() {
|
|
|
52
51
|
const { staging } = c.get("ctx").services;
|
|
53
52
|
return c.json(await staging.status());
|
|
54
53
|
});
|
|
55
|
-
//
|
|
56
|
-
// raw data on both sides; the editor renders the comparison from the model.
|
|
54
|
+
// Raw data before and after one pending change; the editor renders the comparison.
|
|
57
55
|
app.get("/changes/compare", async (c) => {
|
|
58
56
|
const { staging } = c.get("ctx").services;
|
|
59
57
|
const parsed = compareSchema.safeParse({
|
|
@@ -65,7 +63,8 @@ export function adminStagingRoutes() {
|
|
|
65
63
|
});
|
|
66
64
|
if (!parsed.success)
|
|
67
65
|
throw badRequest("The compare target is malformed.");
|
|
68
|
-
|
|
66
|
+
const against = c.req.query("against") === "origin" ? "origin" : "head";
|
|
67
|
+
return c.json(await staging.compare(parsed.data, against));
|
|
69
68
|
});
|
|
70
69
|
app.post("/publish", async (c) => {
|
|
71
70
|
const { staging } = c.get("ctx").services;
|
|
@@ -75,8 +74,8 @@ export function adminStagingRoutes() {
|
|
|
75
74
|
const actor = actorOf(c);
|
|
76
75
|
const result = await handled(() => staging.publish({
|
|
77
76
|
message: parsed.data.message,
|
|
78
|
-
|
|
79
|
-
author: actor ? { name: actor.email, email: actor.email } : undefined,
|
|
77
|
+
paths: parsed.data.paths,
|
|
78
|
+
author: actor ? { name: actor.name || actor.email, email: actor.email } : undefined,
|
|
80
79
|
}));
|
|
81
80
|
return c.json(result);
|
|
82
81
|
});
|
|
@@ -84,6 +83,20 @@ export function adminStagingRoutes() {
|
|
|
84
83
|
const { staging } = c.get("ctx").services;
|
|
85
84
|
return c.json(await handled(() => staging.push()));
|
|
86
85
|
});
|
|
86
|
+
// "Try again" after a sync error.
|
|
87
|
+
app.post("/sync", async (c) => {
|
|
88
|
+
const { staging } = c.get("ctx").services;
|
|
89
|
+
await staging.sync();
|
|
90
|
+
return c.json(await staging.status());
|
|
91
|
+
});
|
|
92
|
+
app.post("/changes/resolve", async (c) => {
|
|
93
|
+
const { staging } = c.get("ctx").services;
|
|
94
|
+
const parsed = resolveSchema.safeParse(await jsonBody(c));
|
|
95
|
+
if (!parsed.success)
|
|
96
|
+
throw badRequest("Expected a group and a choice: mine or website.");
|
|
97
|
+
await handled(() => staging.resolve(parsed.data.group, parsed.data.choice));
|
|
98
|
+
return c.json(await staging.status());
|
|
99
|
+
});
|
|
87
100
|
app.post("/changes/discard", async (c) => {
|
|
88
101
|
const { staging } = c.get("ctx").services;
|
|
89
102
|
const parsed = discardSchema.safeParse(await jsonBody(c));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-staging.js","sourceRoot":"","sources":["../../src/routes/admin-staging.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin-staging.js","sourceRoot":"","sources":["../../src/routes/admin-staging.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAY,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,UAAU,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AAO,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;QAC1C,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,MAAM,UAAU,CAAC,iDAAiD,CAAC,CAAC;QAEzF,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5E,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACvC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;QAC1C,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,MAAM,UAAU,CAAC,kCAAkC,CAAC,CAAC;QAE1E,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Schema, dashboard and system information.
|
|
3
|
-
*
|
|
4
|
-
* The schema endpoint is what makes the admin generic: the SPA ships no
|
|
5
|
-
* knowledge of any particular collection, it renders whatever this returns.
|
|
6
|
-
*
|
|
7
|
-
* There is no publish route. Publishing is a commit, and the commit happened
|
|
8
|
-
* when the editor pressed Save; what follows belongs to the repository's CI,
|
|
9
|
-
* which Mica neither owns nor should pretend to.
|
|
2
|
+
* Schema, dashboard and system information. The SPA knows no collection; it
|
|
3
|
+
* renders what `/schema` returns.
|
|
10
4
|
*/
|
|
11
5
|
import { Hono } from "hono";
|
|
12
6
|
import type { Env } from "../http.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-system.d.ts","sourceRoot":"","sources":["../../src/routes/admin-system.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin-system.d.ts","sourceRoot":"","sources":["../../src/routes/admin-system.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAMtC,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,GAAG,CAAC,CAgI7C"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Schema, dashboard and system information.
|
|
3
|
-
*
|
|
4
|
-
* The schema endpoint is what makes the admin generic: the SPA ships no
|
|
5
|
-
* knowledge of any particular collection, it renders whatever this returns.
|
|
6
|
-
*
|
|
7
|
-
* There is no publish route. Publishing is a commit, and the commit happened
|
|
8
|
-
* when the editor pressed Save; what follows belongs to the repository's CI,
|
|
9
|
-
* which Mica neither owns nor should pretend to.
|
|
2
|
+
* Schema, dashboard and system information. The SPA knows no collection; it
|
|
3
|
+
* renders what `/schema` returns.
|
|
10
4
|
*/
|
|
11
5
|
import { Hono } from "hono";
|
|
12
6
|
import { listedFields, resolveSlugField, resolveTitleField } from "@micacms/core";
|
|
@@ -16,11 +10,7 @@ import { VERSION } from "../lib/version.js";
|
|
|
16
10
|
import { formatBytes } from "../services/media.js";
|
|
17
11
|
export function adminSystemRoutes() {
|
|
18
12
|
const app = new Hono();
|
|
19
|
-
/**
|
|
20
|
-
* The content model, plus the few derived values the UI would otherwise have
|
|
21
|
-
* to recompute. Field descriptors are already plain data, so the model
|
|
22
|
-
* serialises as-is.
|
|
23
|
-
*/
|
|
13
|
+
/** The content model, plus the derived values that the UI would otherwise recompute. */
|
|
24
14
|
app.get("/schema", (c) => {
|
|
25
15
|
const { site } = c.get("ctx");
|
|
26
16
|
return c.json({
|
|
@@ -47,8 +37,6 @@ export function adminSystemRoutes() {
|
|
|
47
37
|
app.get("/overview", async (c) => {
|
|
48
38
|
const ctx = c.get("ctx");
|
|
49
39
|
const { content, media } = ctx.services;
|
|
50
|
-
// Read from the repository rather than counted in SQL. A count that can
|
|
51
|
-
// disagree with the files is worse than no count.
|
|
52
40
|
const collections = await Promise.all(Object.values(ctx.site.model.collections).map(async (def) => ({
|
|
53
41
|
name: def.name,
|
|
54
42
|
label: def.label,
|
|
@@ -66,16 +54,8 @@ export function adminSystemRoutes() {
|
|
|
66
54
|
});
|
|
67
55
|
});
|
|
68
56
|
/**
|
|
69
|
-
* What this deployment is and
|
|
70
|
-
*
|
|
71
|
-
* Answers the questions that otherwise need shell access: which version is
|
|
72
|
-
* running, which content model it was handed, how large the database has
|
|
73
|
-
* grown, how this deployment decides who may edit it.
|
|
74
|
-
*
|
|
75
|
-
* All of it goes to everybody who is admitted. There is no administrator
|
|
76
|
-
* role to withhold it from: admission is configuration, so the people who
|
|
77
|
-
* reach this endpoint are exactly the people the operator named. No secret
|
|
78
|
-
* value is returned anywhere, only whether one is set.
|
|
57
|
+
* What this deployment is and serves. Every admitted editor sees it, because
|
|
58
|
+
* there is no administrator role. It never returns a secret value.
|
|
79
59
|
*/
|
|
80
60
|
app.get("/system", async (c) => {
|
|
81
61
|
const ctx = c.get("ctx");
|
|
@@ -85,9 +65,8 @@ export function adminSystemRoutes() {
|
|
|
85
65
|
const files = await ctx.services.media.list();
|
|
86
66
|
const mediaBytes = files.reduce((sum, file) => sum + file.size, 0);
|
|
87
67
|
const uptimeSeconds = Math.floor(process.uptime());
|
|
88
|
-
// The composition's own facts — database, authentication, admission —
|
|
89
|
-
// come from the app. The runtime cannot know them, which is the point.
|
|
90
68
|
const operational = ctx.operational();
|
|
69
|
+
const repository = await ctx.services.staging.repository();
|
|
91
70
|
return c.json({
|
|
92
71
|
cms: {
|
|
93
72
|
version: VERSION,
|
|
@@ -101,48 +80,34 @@ export function adminSystemRoutes() {
|
|
|
101
80
|
totals: stats.totals,
|
|
102
81
|
kinds: stats.kinds,
|
|
103
82
|
relations: stats.relations,
|
|
104
|
-
// Entry counts alongside the shape, because "8 fields, 0 entries" is
|
|
105
|
-
// the pair that tells an editor a collection was never filled in.
|
|
106
83
|
collections: stats.collections.map((item) => ({
|
|
107
84
|
...item,
|
|
108
85
|
entries: counts[item.name] ?? 0,
|
|
109
86
|
})),
|
|
110
87
|
singletons: stats.singletons,
|
|
111
88
|
},
|
|
112
|
-
/**
|
|
113
|
-
* Deliberately two separate things. `repository` is where the website's
|
|
114
|
-
* content lives and what must be backed up — by Git, which is doing it
|
|
115
|
-
* already. `database` is the composition's operational state, and null
|
|
116
|
-
* where the composition has none: the local editor keeps no database at
|
|
117
|
-
* all.
|
|
118
|
-
*/
|
|
119
89
|
repository: {
|
|
120
90
|
origin: ctx.site.contentRepository.origin,
|
|
121
91
|
entries: Object.values(counts).reduce((sum, count) => sum + count, 0),
|
|
122
92
|
media: { files: files.length, bytes: mediaBytes, readable: formatBytes(mediaBytes) },
|
|
93
|
+
...repository,
|
|
123
94
|
},
|
|
124
|
-
database: operational.database,
|
|
125
95
|
deployment: {
|
|
126
96
|
site: ctx.site.id,
|
|
127
97
|
baseUrl: config.MICA_PUBLIC_URL,
|
|
128
98
|
schemaOrigin: schemaOrigin(ctx.site.contentRepository),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// in `repository.origin` above.
|
|
132
|
-
contentRoot: config.REPOSITORY === "local" ? config.contentRoot : null,
|
|
99
|
+
// A clone that Mica keeps names its remote in `repository.url` instead.
|
|
100
|
+
contentRoot: repository.owner === "developer" ? config.contentRoot : null,
|
|
133
101
|
dataDir: operational.dataDir ?? null,
|
|
134
102
|
logLevel: config.LOG_LEVEL,
|
|
135
103
|
maxUploadBytes: config.MAX_UPLOAD_BYTES,
|
|
136
104
|
maxUploadReadable: formatBytes(config.MAX_UPLOAD_BYTES),
|
|
137
105
|
sessionTtlHours: operational.sessionTtlHours ?? null,
|
|
138
106
|
sessionIdleHours: operational.sessionIdleHours ?? null,
|
|
139
|
-
/** How this deployment authenticates, in words. */
|
|
140
107
|
auth: operational.auth,
|
|
141
|
-
/** What decides who may edit here, in the operator's own words. */
|
|
142
108
|
admission: operational.admission ?? null,
|
|
143
109
|
trustProxy: config.TRUST_PROXY,
|
|
144
110
|
adminOrigins: config.adminOrigins,
|
|
145
|
-
/** Names of the secrets this process generated for itself. */
|
|
146
111
|
generatedSecrets: operational.generatedSecrets ?? [],
|
|
147
112
|
memoryBytes: process.memoryUsage().rss,
|
|
148
113
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-system.js","sourceRoot":"","sources":["../../src/routes/admin-system.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin-system.js","sourceRoot":"","sources":["../../src/routes/admin-system.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,UAAU,iBAAiB;IAC/B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAO,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