@micacms/runtime 0.2.0

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.
Files changed (110) hide show
  1. package/README.md +16 -0
  2. package/dist/app.d.ts +62 -0
  3. package/dist/app.d.ts.map +1 -0
  4. package/dist/app.js +107 -0
  5. package/dist/app.js.map +1 -0
  6. package/dist/config.d.ts +187 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +154 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/context.d.ts +121 -0
  11. package/dist/context.d.ts.map +1 -0
  12. package/dist/context.js +117 -0
  13. package/dist/context.js.map +1 -0
  14. package/dist/db/driver.d.ts +35 -0
  15. package/dist/db/driver.d.ts.map +1 -0
  16. package/dist/db/driver.js +95 -0
  17. package/dist/db/driver.js.map +1 -0
  18. package/dist/http.d.ts +40 -0
  19. package/dist/http.d.ts.map +1 -0
  20. package/dist/http.js +38 -0
  21. package/dist/http.js.map +1 -0
  22. package/dist/index.d.ts +31 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +31 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/lib/errors.d.ts +39 -0
  27. package/dist/lib/errors.d.ts.map +1 -0
  28. package/dist/lib/errors.js +52 -0
  29. package/dist/lib/errors.js.map +1 -0
  30. package/dist/lib/file-type.d.ts +26 -0
  31. package/dist/lib/file-type.d.ts.map +1 -0
  32. package/dist/lib/file-type.js +89 -0
  33. package/dist/lib/file-type.js.map +1 -0
  34. package/dist/lib/git.d.ts +29 -0
  35. package/dist/lib/git.d.ts.map +1 -0
  36. package/dist/lib/git.js +62 -0
  37. package/dist/lib/git.js.map +1 -0
  38. package/dist/lib/id.d.ts +13 -0
  39. package/dist/lib/id.d.ts.map +1 -0
  40. package/dist/lib/id.js +56 -0
  41. package/dist/lib/id.js.map +1 -0
  42. package/dist/lib/logger.d.ts +20 -0
  43. package/dist/lib/logger.d.ts.map +1 -0
  44. package/dist/lib/logger.js +65 -0
  45. package/dist/lib/logger.js.map +1 -0
  46. package/dist/lib/ports.d.ts +17 -0
  47. package/dist/lib/ports.d.ts.map +1 -0
  48. package/dist/lib/ports.js +17 -0
  49. package/dist/lib/ports.js.map +1 -0
  50. package/dist/lib/rate-limit.d.ts +29 -0
  51. package/dist/lib/rate-limit.d.ts.map +1 -0
  52. package/dist/lib/rate-limit.js +47 -0
  53. package/dist/lib/rate-limit.js.map +1 -0
  54. package/dist/lib/schema-stats.d.ts +64 -0
  55. package/dist/lib/schema-stats.d.ts.map +1 -0
  56. package/dist/lib/schema-stats.js +103 -0
  57. package/dist/lib/schema-stats.js.map +1 -0
  58. package/dist/lib/version.d.ts +14 -0
  59. package/dist/lib/version.d.ts.map +1 -0
  60. package/dist/lib/version.js +25 -0
  61. package/dist/lib/version.js.map +1 -0
  62. package/dist/middleware/index.d.ts +41 -0
  63. package/dist/middleware/index.d.ts.map +1 -0
  64. package/dist/middleware/index.js +142 -0
  65. package/dist/middleware/index.js.map +1 -0
  66. package/dist/routes/admin-content.d.ts +22 -0
  67. package/dist/routes/admin-content.d.ts.map +1 -0
  68. package/dist/routes/admin-content.js +194 -0
  69. package/dist/routes/admin-content.js.map +1 -0
  70. package/dist/routes/admin-media.d.ts +19 -0
  71. package/dist/routes/admin-media.d.ts.map +1 -0
  72. package/dist/routes/admin-media.js +81 -0
  73. package/dist/routes/admin-media.js.map +1 -0
  74. package/dist/routes/admin-spa.d.ts +13 -0
  75. package/dist/routes/admin-spa.d.ts.map +1 -0
  76. package/dist/routes/admin-spa.js +72 -0
  77. package/dist/routes/admin-spa.js.map +1 -0
  78. package/dist/routes/admin-staging.d.ts +15 -0
  79. package/dist/routes/admin-staging.d.ts.map +1 -0
  80. package/dist/routes/admin-staging.js +90 -0
  81. package/dist/routes/admin-staging.js.map +1 -0
  82. package/dist/routes/admin-system.d.ts +14 -0
  83. package/dist/routes/admin-system.d.ts.map +1 -0
  84. package/dist/routes/admin-system.js +153 -0
  85. package/dist/routes/admin-system.js.map +1 -0
  86. package/dist/routes/health.d.ts +12 -0
  87. package/dist/routes/health.d.ts.map +1 -0
  88. package/dist/routes/health.js +44 -0
  89. package/dist/routes/health.js.map +1 -0
  90. package/dist/schema.d.ts +56 -0
  91. package/dist/schema.d.ts.map +1 -0
  92. package/dist/schema.js +173 -0
  93. package/dist/schema.js.map +1 -0
  94. package/dist/server.d.ts +28 -0
  95. package/dist/server.d.ts.map +1 -0
  96. package/dist/server.js +47 -0
  97. package/dist/server.js.map +1 -0
  98. package/dist/services/media.d.ts +65 -0
  99. package/dist/services/media.d.ts.map +1 -0
  100. package/dist/services/media.js +180 -0
  101. package/dist/services/media.js.map +1 -0
  102. package/dist/services/staging-local.d.ts +58 -0
  103. package/dist/services/staging-local.d.ts.map +1 -0
  104. package/dist/services/staging-local.js +391 -0
  105. package/dist/services/staging-local.js.map +1 -0
  106. package/dist/services/staging.d.ts +167 -0
  107. package/dist/services/staging.d.ts.map +1 -0
  108. package/dist/services/staging.js +333 -0
  109. package/dist/services/staging.js.map +1 -0
  110. package/package.json +49 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-content.js","sourceRoot":"","sources":["../../src/routes/admin-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAY,MAAM,YAAY,CAAC;AAE/C,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,EAAE,CA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,mBAAmB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACvC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;QAC1C,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAiD,CAAC;QACjF,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAEzB,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAC/B,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE;YAC3D,gBAAgB,EAAE,IAAI,EAAE,QAAQ;YAChC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS;SACtE,CAAC,CACH,CAAC;QAEF,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,19 @@
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.
15
+ */
16
+ import { Hono } from "hono";
17
+ import { type Env } from "../http.js";
18
+ export declare function adminMediaRoutes(): Hono<Env>;
19
+ //# sourceMappingURL=admin-media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-media.d.ts","sourceRoot":"","sources":["../../src/routes/admin-media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAgB,gBAAgB,IAAI,IAAI,CAAC,GAAG,CAAC,CA2E5C"}
@@ -0,0 +1,81 @@
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.
15
+ */
16
+ import { Hono } from "hono";
17
+ import { badRequest, notFound } from "../lib/errors.js";
18
+ import { actorOf } from "../http.js";
19
+ export function adminMediaRoutes() {
20
+ const app = new Hono();
21
+ app.get("/", async (c) => {
22
+ const { media } = c.get("ctx").services;
23
+ return c.json({ items: await media.list() });
24
+ });
25
+ app.post("/", async (c) => {
26
+ const ctx = c.get("ctx");
27
+ const form = await c.req.formData().catch(() => {
28
+ throw badRequest("Expected a multipart upload.");
29
+ });
30
+ // Two `File` types are in scope here — Node's and undici's — and they are
31
+ // structurally different. The runtime check is the same either way; the
32
+ // cast is only to pick one of them for the compiler.
33
+ const files = form
34
+ .getAll("file")
35
+ .filter((value) => typeof value !== "string");
36
+ if (files.length === 0)
37
+ throw badRequest("No file was uploaded.");
38
+ const accept = form.get("accept");
39
+ // Where the editor wants the file: an entry's own `media/` directory, or
40
+ // the shared one. Validated by the connector, which refuses any path that
41
+ // leaves the content root.
42
+ const directory = typeof form.get("directory") === "string" ? String(form.get("directory")) : undefined;
43
+ const prepared = await Promise.all(files.map((file) => ctx.services.media.prepare({
44
+ file,
45
+ directory,
46
+ accept: accept === "image" || accept === "document" ? accept : "any",
47
+ })));
48
+ const actor = actorOf(c);
49
+ await ctx.site.contentRepository.commit({
50
+ message: `Media: upload ${prepared.map((item) => item.file.filename).join(", ")}`,
51
+ changes: prepared.map((item) => ({
52
+ type: "write",
53
+ path: item.file.path,
54
+ contents: item.contents,
55
+ })),
56
+ author: actor ? { name: actor.email, email: actor.email } : undefined,
57
+ });
58
+ return c.json({ items: prepared.map((item) => item.file) }, 201);
59
+ });
60
+ /**
61
+ * Serves a file to the editor.
62
+ *
63
+ * Behind the admin session, unlike the old `/media/*`, which had to be public
64
+ * so that the Astro build could fetch it. The build reads the repository
65
+ * directly now, so nothing outside this session needs these bytes and the
66
+ * whole "media is effectively public" trade-off disappears with the route.
67
+ */
68
+ app.get("/file/*", async (c) => {
69
+ const { media } = c.get("ctx").services;
70
+ const mediaPath = c.req.path.replace(/^.*\/file\//, "");
71
+ const found = await media.read(decodeURIComponent(mediaPath));
72
+ if (!found)
73
+ throw notFound("No such file.");
74
+ return c.body(found.bytes, 200, {
75
+ "content-type": found.mimeType,
76
+ "cache-control": "private, max-age=60",
77
+ });
78
+ });
79
+ return app;
80
+ }
81
+ //# sourceMappingURL=admin-media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-media.js","sourceRoot":"","sources":["../../src/routes/admin-media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAY,MAAM,YAAY,CAAC;AAE/C,MAAM,UAAU,gBAAgB;IAC9B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAO,CAAC;IAE5B,GA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AAK,CAAC,CAAC,QAAQ,CAAC;QACxC,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAExD,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,KAAK;YAAE,MAAM,QAAQ,CAAC,eAAe,CAAC,CAAC;QAE5C,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAA+B,EAAE,GAAG,EAAE;YACxD,cAAc,EAAE,KAAK,CAAC,QAAQ;YAC9B,eAAe,EAAE,qBAAqB;SACvC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Serves the built administration SPA.
3
+ *
4
+ * Small enough to do directly rather than pull in a static-file middleware,
5
+ * and doing it here means the caching rules are explicit: hashed asset files
6
+ * are immutable, `index.html` never is — otherwise a deploy leaves editors on
7
+ * a stale bundle pointing at assets that no longer exist.
8
+ */
9
+ import { Hono } from "hono";
10
+ import type { Env } from "../http.js";
11
+ export declare function adminAssetsExist(directory: string): boolean;
12
+ export declare function adminSpaRoutes(directory: string): Hono<Env>;
13
+ //# sourceMappingURL=admin-spa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-spa.d.ts","sourceRoot":"","sources":["../../src/routes/admin-spa.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAiBtC,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CA4C3D"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Serves the built administration SPA.
3
+ *
4
+ * Small enough to do directly rather than pull in a static-file middleware,
5
+ * and doing it here means the caching rules are explicit: hashed asset files
6
+ * are immutable, `index.html` never is — otherwise a deploy leaves editors on
7
+ * a stale bundle pointing at assets that no longer exist.
8
+ */
9
+ import fs from "node:fs";
10
+ import fsp from "node:fs/promises";
11
+ import path from "node:path";
12
+ import { Readable } from "node:stream";
13
+ import { Hono } from "hono";
14
+ const CONTENT_TYPES = {
15
+ ".html": "text/html; charset=utf-8",
16
+ ".js": "text/javascript; charset=utf-8",
17
+ ".css": "text/css; charset=utf-8",
18
+ ".json": "application/json; charset=utf-8",
19
+ ".svg": "image/svg+xml",
20
+ ".png": "image/png",
21
+ ".jpg": "image/jpeg",
22
+ ".webp": "image/webp",
23
+ ".ico": "image/x-icon",
24
+ ".woff2": "font/woff2",
25
+ ".woff": "font/woff",
26
+ ".map": "application/json; charset=utf-8",
27
+ };
28
+ export function adminAssetsExist(directory) {
29
+ return fs.existsSync(path.join(directory, "index.html"));
30
+ }
31
+ export function adminSpaRoutes(directory) {
32
+ const app = new Hono();
33
+ const root = path.resolve(directory);
34
+ const send = async (c, filePath, immutable) => {
35
+ const stat = await fsp.stat(filePath);
36
+ const extension = path.extname(filePath).toLowerCase();
37
+ return c.body(Readable.toWeb(fs.createReadStream(filePath)), 200, {
38
+ "content-type": CONTENT_TYPES[extension] ?? "application/octet-stream",
39
+ "content-length": String(stat.size),
40
+ "cache-control": immutable
41
+ ? "public, max-age=31536000, immutable"
42
+ : "no-cache, must-revalidate",
43
+ });
44
+ };
45
+ app.get("/*", async (c) => {
46
+ const url = new URL(c.req.url);
47
+ const relative = decodeURIComponent(url.pathname.replace(/^\/admin\/?/, ""));
48
+ const target = path.join(root, relative);
49
+ // Never serve outside the build directory, whatever the path contains.
50
+ if (relative && !path.relative(root, target).startsWith("..")) {
51
+ try {
52
+ const stat = await fsp.stat(target);
53
+ if (stat.isFile()) {
54
+ // Vite emits hashed filenames under /assets, so those are immutable.
55
+ return await send(c, target, relative.startsWith("assets/"));
56
+ }
57
+ }
58
+ catch {
59
+ // Fall through to the SPA entry point.
60
+ }
61
+ }
62
+ // Any other path belongs to the client-side router.
63
+ try {
64
+ return await send(c, path.join(root, "index.html"), false);
65
+ }
66
+ catch {
67
+ return c.text("The admin interface has not been built. Run `rush build`.", 503);
68
+ }
69
+ });
70
+ return app;
71
+ }
72
+ //# sourceMappingURL=admin-spa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-spa.js","sourceRoot":"","sources":["../../src/routes/admin-spa.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAI1C,MAAM,aAAa,GAA2B;IAC5C,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,gCAAgC;IACvC,MAAM,EAAE,yBAAyB;IACjC,OAAO,EAAE,iCAAiC;IAC1C,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,cAAc;IACtB,QAAQ,EAAE,YAAY;IACtB,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,iCAAiC;CAC1C,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAO,CAAC;IAC5B,MAAM,IAAI,GAAG,IA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AAI,CAAC,MAAM,EAAE,EAAE,CAAC;oBAClB,qEAAqE;oBACrE,OAAO,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,uCAAuC;YACzC,CAAC;QACH,CAAC;QAED,oDAAoD;QACpD,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC,IAAI,CAAC,2DAA2D,EAAE,GAAG,CAAC,CAAC;QAClF,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Admin staging routes — the pending change set, and Publish.
3
+ *
4
+ * Thin, like the content routes: the two staging implementations own every
5
+ * rule, and what happens here is parsing and the mapping of their refusals
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.
11
+ */
12
+ import { Hono } from "hono";
13
+ import { type Env } from "../http.js";
14
+ export declare function adminStagingRoutes(): Hono<Env>;
15
+ //# sourceMappingURL=admin-staging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-staging.d.ts","sourceRoot":"","sources":["../../src/routes/admin-staging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAgC/C,wBAAgB,kBAAkB,IAAI,IAAI,CAAC,GAAG,CAAC,CAsD9C"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Admin staging routes — the pending change set, and Publish.
3
+ *
4
+ * Thin, like the content routes: the two staging implementations own every
5
+ * rule, and what happens here is parsing and the mapping of their refusals
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.
11
+ */
12
+ import { ConflictError } from "@micacms/connectors";
13
+ import { Hono } from "hono";
14
+ import { z } from "zod";
15
+ import { ApiError, badRequest } from "../lib/errors.js";
16
+ import { actorOf } from "../http.js";
17
+ const publishSchema = z.object({
18
+ message: z.string().max(500),
19
+ /** The base revision the editor reviewed. Null where the workspace has none. */
20
+ expectedBase: z.string().nullable().optional(),
21
+ });
22
+ const discardSchema = z.object({ paths: z.array(z.string().min(1)).min(1).max(2000) });
23
+ const compareSchema = z.discriminatedUnion("kind", [
24
+ z.object({ kind: z.literal("entry"), collection: z.string().min(1), slug: z.string().min(1) }),
25
+ z.object({ kind: z.literal("singleton"), name: z.string().min(1) }),
26
+ z.object({ kind: z.literal("order"), collection: z.string().min(1) }),
27
+ ]);
28
+ async function jsonBody(c) {
29
+ return c.req.json().catch(() => {
30
+ throw badRequest("The request body must be valid JSON.");
31
+ });
32
+ }
33
+ /** A repository conflict is 409 and recoverable — refresh, review, retry. */
34
+ async function handled(run) {
35
+ try {
36
+ return await run();
37
+ }
38
+ catch (error) {
39
+ if (error instanceof ConflictError)
40
+ throw new ApiError("conflict", error.message);
41
+ throw error;
42
+ }
43
+ }
44
+ export function adminStagingRoutes() {
45
+ const app = new Hono();
46
+ app.get("/changes", async (c) => {
47
+ const { staging } = c.get("ctx").services;
48
+ return c.json(await staging.status());
49
+ });
50
+ // The document one pending change touches, before and after that change —
51
+ // raw data on both sides; the editor renders the comparison from the model.
52
+ app.get("/changes/compare", async (c) => {
53
+ const { staging } = c.get("ctx").services;
54
+ const parsed = compareSchema.safeParse({
55
+ kind: c.req.query("kind"),
56
+ collection: c.req.query("collection"),
57
+ slug: c.req.query("slug"),
58
+ name: c.req.query("name"),
59
+ });
60
+ if (!parsed.success)
61
+ throw badRequest("The compare target is malformed.");
62
+ return c.json(await staging.compare(parsed.data));
63
+ });
64
+ app.post("/publish", async (c) => {
65
+ const { staging } = c.get("ctx").services;
66
+ const parsed = publishSchema.safeParse(await jsonBody(c));
67
+ if (!parsed.success)
68
+ throw badRequest("The publish payload is malformed.");
69
+ const actor = actorOf(c);
70
+ const result = await handled(() => staging.publish({
71
+ message: parsed.data.message,
72
+ expectedBase: parsed.data.expectedBase ?? null,
73
+ author: actor ? { name: actor.email, email: actor.email } : undefined,
74
+ }));
75
+ return c.json(result);
76
+ });
77
+ app.post("/publish/push", async (c) => {
78
+ const { staging } = c.get("ctx").services;
79
+ return c.json(await handled(() => staging.push()));
80
+ });
81
+ app.post("/changes/discard", async (c) => {
82
+ const { staging } = c.get("ctx").services;
83
+ const parsed = discardSchema.safeParse(await jsonBody(c));
84
+ if (!parsed.success)
85
+ throw badRequest("Expected a list of change paths.");
86
+ return c.json(await handled(() => staging.discard(parsed.data.paths)));
87
+ });
88
+ return app;
89
+ }
90
+ //# sourceMappingURL=admin-staging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-staging.js","sourceRoot":"","sources":["../../src/routes/admin-staging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAY,MAAM,YAAY,CAAC;AAE/C,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;I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D,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"}
@@ -0,0 +1,14 @@
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.
10
+ */
11
+ import { Hono } from "hono";
12
+ import type { Env } from "../http.js";
13
+ export declare function adminSystemRoutes(): Hono<Env>;
14
+ //# sourceMappingURL=admin-system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-system.d.ts","sourceRoot":"","sources":["../../src/routes/admin-system.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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,CA6J7C"}
@@ -0,0 +1,153 @@
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.
10
+ */
11
+ import { Hono } from "hono";
12
+ import { listedFields, resolveSlugField, resolveTitleField } from "@micacms/core";
13
+ import { schemaStats } from "../lib/schema-stats.js";
14
+ import { schemaOrigin } from "../schema.js";
15
+ import { VERSION } from "../lib/version.js";
16
+ import { formatBytes } from "../services/media.js";
17
+ export function adminSystemRoutes() {
18
+ 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
+ */
24
+ app.get("/schema", (c) => {
25
+ const { site } = c.get("ctx");
26
+ return c.json({
27
+ collections: Object.values(site.model.collections).map((def) => ({
28
+ name: def.name,
29
+ label: def.label,
30
+ labelSingular: def.labelSingular ?? def.label,
31
+ description: def.description ?? null,
32
+ sortable: def.sortable ?? false,
33
+ defaultSort: def.defaultSort ?? null,
34
+ titleField: resolveTitleField(def),
35
+ slugField: resolveSlugField(def),
36
+ listedFields: listedFields(def),
37
+ fields: def.fields,
38
+ })),
39
+ singletons: Object.values(site.model.singletons).map((def) => ({
40
+ name: def.name,
41
+ label: def.label,
42
+ description: def.description ?? null,
43
+ fields: def.fields,
44
+ })),
45
+ });
46
+ });
47
+ app.get("/overview", async (c) => {
48
+ const ctx = c.get("ctx");
49
+ 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
+ const collections = await Promise.all(Object.values(ctx.site.model.collections).map(async (def) => ({
53
+ name: def.name,
54
+ label: def.label,
55
+ total: (await content.list(def.name)).length,
56
+ })));
57
+ const files = await media.list();
58
+ return c.json({
59
+ collections,
60
+ media: {
61
+ files: files.length,
62
+ bytes: files.reduce((sum, file) => sum + file.size, 0),
63
+ readable: formatBytes(files.reduce((sum, file) => sum + file.size, 0)),
64
+ },
65
+ repository: ctx.site.contentRepository.origin,
66
+ });
67
+ });
68
+ /**
69
+ * What this deployment is and what it is serving.
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.
79
+ */
80
+ app.get("/system", async (c) => {
81
+ const ctx = c.get("ctx");
82
+ const { config } = ctx;
83
+ const stats = schemaStats(ctx.site.model);
84
+ const counts = Object.fromEntries(await Promise.all(Object.values(ctx.site.model.collections).map(async (def) => [def.name, (await ctx.services.content.list(def.name)).length])));
85
+ const files = await ctx.services.media.list();
86
+ const mediaBytes = files.reduce((sum, file) => sum + file.size, 0);
87
+ 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
+ const operational = ctx.operational();
91
+ return c.json({
92
+ cms: {
93
+ version: VERSION,
94
+ environment: config.NODE_ENV,
95
+ node: process.version,
96
+ platform: `${process.platform}/${process.arch}`,
97
+ startedAt: new Date(Date.now() - uptimeSeconds * 1000).toISOString(),
98
+ uptimeSeconds,
99
+ },
100
+ schema: {
101
+ totals: stats.totals,
102
+ kinds: stats.kinds,
103
+ 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
+ collections: stats.collections.map((item) => ({
107
+ ...item,
108
+ entries: counts[item.name] ?? 0,
109
+ })),
110
+ singletons: stats.singletons,
111
+ },
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
+ repository: {
120
+ origin: ctx.site.contentRepository.origin,
121
+ entries: Object.values(counts).reduce((sum, count) => sum + count, 0),
122
+ media: { files: files.length, bytes: mediaBytes, readable: formatBytes(mediaBytes) },
123
+ },
124
+ database: operational.database,
125
+ deployment: {
126
+ site: ctx.site.id,
127
+ baseUrl: config.MICA_PUBLIC_URL,
128
+ schemaOrigin: schemaOrigin(ctx.site.contentRepository),
129
+ repositoryMode: config.REPOSITORY,
130
+ // Only meaningful for the local connector; a remote one names itself
131
+ // in `repository.origin` above.
132
+ contentRoot: config.REPOSITORY === "local" ? config.contentRoot : null,
133
+ dataDir: operational.dataDir ?? null,
134
+ logLevel: config.LOG_LEVEL,
135
+ maxUploadBytes: config.MAX_UPLOAD_BYTES,
136
+ maxUploadReadable: formatBytes(config.MAX_UPLOAD_BYTES),
137
+ sessionTtlHours: operational.sessionTtlHours ?? null,
138
+ sessionIdleHours: operational.sessionIdleHours ?? null,
139
+ /** How this deployment authenticates, in words. */
140
+ auth: operational.auth,
141
+ /** What decides who may edit here, in the operator's own words. */
142
+ admission: operational.admission ?? null,
143
+ trustProxy: config.TRUST_PROXY,
144
+ adminOrigins: config.adminOrigins,
145
+ /** Names of the secrets this process generated for itself. */
146
+ generatedSecrets: operational.generatedSecrets ?? [],
147
+ memoryBytes: process.memoryUsage().rss,
148
+ },
149
+ });
150
+ });
151
+ return app;
152
+ }
153
+ //# sourceMappingURL=admin-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-system.js","sourceRoot":"","sources":["../../src/routes/admin-system.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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,YA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AAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC;gBACtD,cAAc,EAAE,MAAM,CAAC,UAAU;gBACjC,qEAAqE;gBACrE,gCAAgC;gBAChC,WAAW,EAAE,MAAM,CAAC,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI;gBACtE,OAAO,EAAE,WAAW,CAAC,OAAO,IAAI,IAAI;gBACpC,QAAQ,EAAE,MAAM,CAAC,SAAS;gBAC1B,cAAc,EAAE,MAAM,CAAC,gBAAgB;gBACvC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC;gBACvD,eAAe,EAAE,WAAW,CAAC,eAAe,IAAI,IAAI;gBACpD,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,IAAI,IAAI;gBACtD,mDAAmD;gBACnD,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,mEAAmE;gBACnE,SAAS,EAAE,WAAW,CAAC,SAAS,IAAI,IAAI;gBACxC,UAAU,EAAE,MAAM,CAAC,WAAW;gBAC9B,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,8DAA8D;gBAC9D,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,IAAI,EAAE;gBACpD,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG;aACvC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Health endpoint for container orchestration and uptime monitoring.
3
+ *
4
+ * Touches what a request could need: the content repository, and — where the
5
+ * composition has one — the database. A process that is listening but cannot
6
+ * reach either is not healthy, and a check that only proves the event loop is
7
+ * alive would not notice.
8
+ */
9
+ import { Hono } from "hono";
10
+ import type { Env } from "../http.js";
11
+ export declare function healthRoutes(): Hono<Env>;
12
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAItC,wBAAgB,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,CAmCxC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Health endpoint for container orchestration and uptime monitoring.
3
+ *
4
+ * Touches what a request could need: the content repository, and — where the
5
+ * composition has one — the database. A process that is listening but cannot
6
+ * reach either is not healthy, and a check that only proves the event loop is
7
+ * alive would not notice.
8
+ */
9
+ import { Hono } from "hono";
10
+ const startedAt = Date.now();
11
+ export function healthRoutes() {
12
+ const app = new Hono();
13
+ app.get("/", async (c) => {
14
+ const ctx = c.get("ctx");
15
+ // A probe only where the composition has a database. The local editor
16
+ // does not, and a health check must not invent one to report on.
17
+ if (ctx.health.database) {
18
+ try {
19
+ ctx.health.database();
20
+ }
21
+ catch (error) {
22
+ c.get("logger").error("Health check failed", { error: String(error) });
23
+ return c.json({ status: "error", database: "unavailable" }, 503);
24
+ }
25
+ }
26
+ // `list` on a missing root returns an empty array rather than throwing, so
27
+ // this proves reachability, not that anyone has written content yet.
28
+ try {
29
+ await ctx.site.contentRepository.list("");
30
+ }
31
+ catch (error) {
32
+ c.get("logger").error("Content repository is unreachable", { error: String(error) });
33
+ return c.json({ status: "error", repository: "unavailable" }, 503);
34
+ }
35
+ return c.json({
36
+ status: "ok",
37
+ uptimeSeconds: Math.floor((Date.now() - startedAt) / 1000),
38
+ ...(ctx.health.database ? { database: "ok" } : {}),
39
+ repository: ctx.site.contentRepository.origin,
40
+ });
41
+ });
42
+ return app;
43
+ }
44
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,E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