@astrale-os/adapter-cloudflare 0.3.0 → 0.3.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 +1 -1
- package/template/README.md +6 -5
- package/template/functions/index.ts +15 -3
- package/template/package.json +2 -2
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -97,11 +97,12 @@ adapter-owned keys `name`, `main`, `assets`, `routes` are rejected (use
|
|
|
97
97
|
|
|
98
98
|
- **Edit a handler** (`core/` logic or `runtime/` wiring) → hot-reloads at the same URL. Nothing to reinstall.
|
|
99
99
|
- **Edit the schema** (`schema/`) → rebuilds the graph; reinstall with `astrale domain install <url> --direct`.
|
|
100
|
-
- **`postInstall`** (the
|
|
101
|
-
the system identity, so the domain can seed
|
|
102
|
-
`/monitoring/pages/status` and set its own grants.
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
- **`postInstall`** (the standalone `seed` function in `functions/`) runs once
|
|
101
|
+
after install, as the system identity, so the domain can seed
|
|
102
|
+
`/monitoring/monitors` and `/monitoring/pages/status` and set its own grants.
|
|
103
|
+
`domain.ts` references it directly (`postInstall: functions.seed`) and the SDK
|
|
104
|
+
derives its path — functions are first-class domain members, addressable at
|
|
105
|
+
`/:origin:function.seed`.
|
|
105
106
|
|
|
106
107
|
## Identity
|
|
107
108
|
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
* A standalone function's `execute` receives the same request context as a
|
|
11
11
|
* method MINUS `self` (it is not node-bound): `{ params, kernel, deps, auth, … }`.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { __SYSTEM__ } from '@astrale-os/kernel-core'
|
|
14
|
+
import { assertPerm, defineRemoteFunction, EDIT } from '@astrale-os/sdk'
|
|
14
15
|
import { z } from 'zod'
|
|
15
16
|
|
|
16
17
|
import type { Deps } from '../deps'
|
|
17
18
|
|
|
19
|
+
import { MONITORS_PARENT } from '../core/monitor'
|
|
18
20
|
import { monitor } from '../runtime/monitoring'
|
|
19
21
|
|
|
20
22
|
export const functions = {
|
|
@@ -23,11 +25,21 @@ export const functions = {
|
|
|
23
25
|
// function's own identity), so the domain comes up demonstrable. Must stay
|
|
24
26
|
// idempotent — a re-install runs it again. `auth: 'required'` (the default)
|
|
25
27
|
// makes `ctx.kernel` non-null; the body delegates to the per-operation seed
|
|
26
|
-
// logic in `runtime/monitor/seed.ts`.
|
|
28
|
+
// logic in `runtime/monitoring/monitor/seed.ts`.
|
|
27
29
|
seed: defineRemoteFunction<Record<string, never>, { seeded: number }, Deps>({
|
|
28
30
|
inputSchema: z.object({}),
|
|
29
31
|
outputSchema: z.object({ seeded: z.number().int() }),
|
|
30
|
-
|
|
32
|
+
// Additive throw-to-deny pre-check (the kernel ALSO enforces `has_perm` on the
|
|
33
|
+
// create downstream — this just fails fast with the exact target). Two cases:
|
|
34
|
+
// • postInstall runs as __SYSTEM__ (full authority) and on the FIRST install
|
|
35
|
+
// `/monitoring/monitors` doesn't exist yet — seed creates it — so the
|
|
36
|
+
// short-circuit MUST skip the check, or first install would wrongly deny.
|
|
37
|
+
// • A later DIRECT call carries a real principal (and by then the folder
|
|
38
|
+
// exists), so require EDIT — the bit a child-create under it needs.
|
|
39
|
+
authorize: async ({ kernel, auth }) => {
|
|
40
|
+
if (auth.principal === __SYSTEM__) return
|
|
41
|
+
await assertPerm(kernel, MONITORS_PARENT, auth.principal, EDIT)
|
|
42
|
+
},
|
|
31
43
|
execute: ({ kernel, deps }) => monitor.seed(kernel, deps.prober()),
|
|
32
44
|
}),
|
|
33
45
|
}
|
package/template/package.json
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"typecheck": "tsgo --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@astrale-os/adapter-cloudflare": ">=0.3.
|
|
18
|
-
"@astrale-os/kernel-core": ">=0.
|
|
17
|
+
"@astrale-os/adapter-cloudflare": ">=0.3.1 <1.0.0",
|
|
18
|
+
"@astrale-os/kernel-core": ">=0.5.0 <1.0.0",
|
|
19
19
|
"@astrale-os/kernel-dsl": ">=0.1.2 <1.0.0",
|
|
20
20
|
"@astrale-os/sdk": ">=0.2.0 <1.0.0",
|
|
21
21
|
"@hono/node-server": "^1.19.0",
|