@crombolo/server 0.48.0 → 0.48.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/package.json +13 -13
- package/src/config.ts +1 -1
- package/src/remote.ts +5 -4
- package/src/server.ts +11 -1
- package/src/view-runtime.ts +13 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/server",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.1",
|
|
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",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@crombolo/api-delivery": "0.48.
|
|
35
|
-
"@crombolo/api-management": "0.48.
|
|
36
|
-
"@crombolo/auth": "0.48.
|
|
37
|
-
"@crombolo/backoffice-host": "0.48.
|
|
38
|
-
"@crombolo/common": "0.48.
|
|
39
|
-
"@crombolo/content": "0.48.
|
|
40
|
-
"@crombolo/contracts": "0.48.
|
|
41
|
-
"@crombolo/core": "0.48.
|
|
42
|
-
"@crombolo/data": "0.48.
|
|
43
|
-
"@crombolo/render": "0.48.
|
|
44
|
-
"@crombolo/schema": "0.48.
|
|
45
|
-
"@crombolo/transfer": "0.48.
|
|
34
|
+
"@crombolo/api-delivery": "0.48.1",
|
|
35
|
+
"@crombolo/api-management": "0.48.1",
|
|
36
|
+
"@crombolo/auth": "0.48.1",
|
|
37
|
+
"@crombolo/backoffice-host": "0.48.1",
|
|
38
|
+
"@crombolo/common": "0.48.1",
|
|
39
|
+
"@crombolo/content": "0.48.1",
|
|
40
|
+
"@crombolo/contracts": "0.48.1",
|
|
41
|
+
"@crombolo/core": "0.48.1",
|
|
42
|
+
"@crombolo/data": "0.48.1",
|
|
43
|
+
"@crombolo/render": "0.48.1",
|
|
44
|
+
"@crombolo/schema": "0.48.1",
|
|
45
|
+
"@crombolo/transfer": "0.48.1",
|
|
46
46
|
"@logtape/logtape": "^2.3.8",
|
|
47
47
|
"@opentelemetry/api": "1.10.0",
|
|
48
48
|
"@opentelemetry/context-async-hooks": "3.0.0",
|
package/src/config.ts
CHANGED
|
@@ -1086,7 +1086,7 @@ export function describeDatabase(
|
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
|
-
export const VERSION = '0.48.
|
|
1089
|
+
export const VERSION = '0.48.1'
|
|
1090
1090
|
|
|
1091
1091
|
/** A whole number of seconds from the environment; undefined when unset or not one. */
|
|
1092
1092
|
/** A positive number from a setting, else the default. */
|
package/src/remote.ts
CHANGED
|
@@ -83,7 +83,8 @@ export interface RemoteOptions {
|
|
|
83
83
|
* Told once a push has landed, so this node's published cache is rebuilt: the
|
|
84
84
|
* import's cache instruction carries this node's id, and a node skips its own.
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
/** After a push, an apply or a revert: awaited, so the answer comes after what it changed renders. */
|
|
87
|
+
onApplied?(): void | Promise<void>
|
|
87
88
|
/** A new server from the supervising `crombolo start`, once it is healthy (story 241). */
|
|
88
89
|
restart?: () => Promise<RestartOutcome>
|
|
89
90
|
/** Installed bundles (story 241); absent where this node does not manage them. */
|
|
@@ -523,7 +524,7 @@ export function createRemote(options: RemoteOptions): Remote {
|
|
|
523
524
|
})
|
|
524
525
|
return
|
|
525
526
|
}
|
|
526
|
-
options.onApplied?.()
|
|
527
|
+
await options.onApplied?.()
|
|
527
528
|
await jobs.update(job.id, {
|
|
528
529
|
state: 'done',
|
|
529
530
|
stage:
|
|
@@ -790,7 +791,7 @@ export function createRemote(options: RemoteOptions): Remote {
|
|
|
790
791
|
'RemoteBundleApplied',
|
|
791
792
|
`${result.bundle.id} as run ${result.runId}${structural ? ', with structure' : ''}; ${describeProvenance(provenance)}`,
|
|
792
793
|
)
|
|
793
|
-
options.onApplied?.()
|
|
794
|
+
await options.onApplied?.()
|
|
794
795
|
}
|
|
795
796
|
return Response.json(
|
|
796
797
|
{
|
|
@@ -996,7 +997,7 @@ export function createRemote(options: RemoteOptions): Remote {
|
|
|
996
997
|
})
|
|
997
998
|
const files = await revertSections(db, config, runId)
|
|
998
999
|
await audit(principal, request, 'RemoteBundleReverted', `${runId} as run ${result.runId}`)
|
|
999
|
-
options.onApplied?.()
|
|
1000
|
+
await options.onApplied?.()
|
|
1000
1001
|
return Response.json({
|
|
1001
1002
|
runId: result.runId,
|
|
1002
1003
|
reverted: runId,
|
package/src/server.ts
CHANGED
|
@@ -819,9 +819,19 @@ export async function createServer(
|
|
|
819
819
|
authenticate,
|
|
820
820
|
bundles: bundleAdmin,
|
|
821
821
|
restart: serverOptions.restart,
|
|
822
|
-
onApplied: () => {
|
|
822
|
+
onApplied: async () => {
|
|
823
823
|
cache.invalidate()
|
|
824
824
|
mediaCache.clear()
|
|
825
|
+
// A push or an apply may have replaced views: a new snapshot here, as an
|
|
826
|
+
// edit in the back office takes one, and every other node told.
|
|
827
|
+
const hash = await snapshots.refresh()
|
|
828
|
+
await appendCacheInstruction(db, {
|
|
829
|
+
kind: 'components',
|
|
830
|
+
payload: hash ? { hash } : {},
|
|
831
|
+
by: schema.nodeId,
|
|
832
|
+
}).catch((error: unknown) => {
|
|
833
|
+
renderLog.error('Could not announce the views a push changed: {error}', { error })
|
|
834
|
+
})
|
|
825
835
|
},
|
|
826
836
|
})
|
|
827
837
|
const members = createMemberAuth(db, config, {
|
package/src/view-runtime.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* Checked at boot because the alternative is every render failing with a message
|
|
11
11
|
* that names the runtime rather than the configuration that moved it.
|
|
12
12
|
*/
|
|
13
|
-
import { mkdirSync } from 'node:fs'
|
|
13
|
+
import { existsSync, mkdirSync } from 'node:fs'
|
|
14
|
+
import { dirname, join, resolve } from 'node:path'
|
|
14
15
|
|
|
15
16
|
export const JSX_RUNTIME = '@crombolo/crombolo/jsx-runtime'
|
|
16
17
|
|
|
@@ -28,9 +29,20 @@ export class ViewRuntimeUnreachableError extends Error {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
/** Whether `dir` or a folder above it holds a node_modules. */
|
|
33
|
+
function insideNodeModules(dir: string): boolean {
|
|
34
|
+
for (let at = resolve(dir); ; at = dirname(at)) {
|
|
35
|
+
if (existsSync(join(at, 'node_modules'))) return true
|
|
36
|
+
if (dirname(at) === at) return false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
31
40
|
/** Throws unless a `.tsx` placed in `dir` could resolve the JSX runtime. */
|
|
32
41
|
export function assertViewRuntime(dir: string): void {
|
|
33
42
|
mkdirSync(dir, { recursive: true })
|
|
43
|
+
// With no node_modules at or above it, Bun installs a package it cannot find,
|
|
44
|
+
// and the resolve blocks on the registry: `crombolo status` is read-only.
|
|
45
|
+
if (!insideNodeModules(dir)) throw new ViewRuntimeUnreachableError(dir, 'no node_modules there')
|
|
34
46
|
try {
|
|
35
47
|
Bun.resolveSync(JSX_RUNTIME, dir)
|
|
36
48
|
} catch (error) {
|