@crombolo/server 0.36.2 → 0.37.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/server",
3
- "version": "0.36.2",
3
+ "version": "0.37.0",
4
4
  "description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. The crombolo HTTP server: routing, configuration, media stores and background jobs.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -30,17 +30,18 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@crombolo/api-delivery": "0.36.2",
34
- "@crombolo/api-management": "0.36.2",
35
- "@crombolo/auth": "0.36.2",
36
- "@crombolo/backoffice-host": "0.36.2",
37
- "@crombolo/content": "0.36.2",
38
- "@crombolo/contracts": "0.36.2",
39
- "@crombolo/core": "0.36.2",
40
- "@crombolo/data": "0.36.2",
41
- "@crombolo/render": "0.36.2",
42
- "@crombolo/schema": "0.36.2",
43
- "@crombolo/transfer": "0.36.2",
33
+ "@crombolo/api-delivery": "0.37.0",
34
+ "@crombolo/api-management": "0.37.0",
35
+ "@crombolo/auth": "0.37.0",
36
+ "@crombolo/backoffice-host": "0.37.0",
37
+ "@crombolo/common": "0.37.0",
38
+ "@crombolo/content": "0.37.0",
39
+ "@crombolo/contracts": "0.37.0",
40
+ "@crombolo/core": "0.37.0",
41
+ "@crombolo/data": "0.37.0",
42
+ "@crombolo/render": "0.37.0",
43
+ "@crombolo/schema": "0.37.0",
44
+ "@crombolo/transfer": "0.37.0",
44
45
  "@logtape/logtape": "^2.3.8",
45
46
  "jose": "^6.2.12"
46
47
  }
@@ -35,6 +35,7 @@ const CHECKS = {
35
35
  email: { id: '6f1d4a8e-0047-4c1a-9e7d-000000000004', name: 'E-mail delivery' },
36
36
  nodes: { id: '6f1d4a8e-0047-4c1a-9e7d-000000000005', name: 'Servers' },
37
37
  outgoing: { id: '6f1d4a8e-0047-4c1a-9e7d-000000000006', name: 'Outgoing changes' },
38
+ routes: { id: '6f1d4a8e-0047-4c1a-9e7d-000000000007', name: 'Routes and pages' },
38
39
  } as const
39
40
 
40
41
  /** Waiting longer than this means nothing is sending: no server is running its jobs, or one is stuck. */
@@ -73,6 +74,16 @@ const GROUPS: HealthCheckGroup[] = [
73
74
  },
74
75
  ],
75
76
  },
77
+ {
78
+ name: 'Site',
79
+ checks: [
80
+ {
81
+ ...CHECKS.routes,
82
+ description:
83
+ "Whether a route in the site's code answers at an address a published page also has, which hides the page.",
84
+ },
85
+ ],
86
+ },
76
87
  ]
77
88
 
78
89
  /** Behind the latest content for longer than this, a node is worth a warning: it is not catching up. */
@@ -148,6 +159,8 @@ export interface HealthCheckOptions {
148
159
  nodeState?: NodeSchemaState
149
160
  fetch?: typeof fetch
150
161
  now?: () => Date
162
+ /** Published pages a route answers in place of (story 211). */
163
+ hiddenByRoutes?: () => Promise<Array<{ route: string; owner: string; page: string; url: string }>>
151
164
  }
152
165
 
153
166
  const result = (
@@ -323,6 +336,16 @@ export function createDiagnosticsPort(options: HealthCheckOptions): DiagnosticsP
323
336
  [CHECKS.media.id]: mediaStorage,
324
337
  [CHECKS.email.id]: email,
325
338
  [CHECKS.nodes.id]: nodes,
339
+ [CHECKS.routes.id]: async () => {
340
+ const hidden = (await options.hiddenByRoutes?.()) ?? []
341
+ if (hidden.length === 0) return [result('Success', 'No route hides a published page.')]
342
+ return hidden.map((h) =>
343
+ result(
344
+ 'Warning',
345
+ `The route ${h.route} (${h.owner}) answers ${h.url}, so the page "${h.page}" published there is never shown.`,
346
+ ),
347
+ )
348
+ },
326
349
  [CHECKS.outgoing.id]: async () =>
327
350
  outgoingResults(
328
351
  {
@@ -4,6 +4,7 @@
4
4
  * Umbraco keeps templates at ~/components/{alias}.cshtml and treats the file as the
5
5
  * source of truth for its content; we do the same with .tsx.
6
6
  */
7
+ import { existsSync } from 'node:fs'
7
8
  import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'
8
9
  import { join } from 'node:path'
9
10
  import type { ComponentFileStore } from '@crombolo/data'
@@ -26,7 +27,11 @@ export function createTemplateFileStore(
26
27
  ): ComponentFileStore {
27
28
  const fileFor = (alias: string): string | undefined => {
28
29
  const safe = safeAlias(alias)
29
- return safe ? join(dir, `${safe}.tsx`) : undefined
30
+ if (!safe) return undefined
31
+ const file = join(dir, `${safe}.tsx`)
32
+ // A folder template (story 206) is edited where it lives.
33
+ const folder = join(dir, safe, 'page.tsx')
34
+ return !existsSync(file) && existsSync(folder) ? folder : file
30
35
  }
31
36
 
32
37
  return {