@cloudhal/cloudflare 0.7.2 → 0.8.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/dist/src/features.d.ts +15 -0
- package/dist/src/features.js +42 -3
- package/package.json +10 -10
package/dist/src/features.d.ts
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
* `expiry` until it answers `{ "gates": 2 }` (derived gates, RFC-0042 §3.6).
|
|
7
7
|
*/
|
|
8
8
|
import { type GateSupport } from "@cloudhal/core-ts/availability";
|
|
9
|
+
import { type FieldTypeSupport } from "@cloudhal/core-ts/fields";
|
|
9
10
|
import type { SiteFetch } from "./purge.js";
|
|
10
11
|
/** The features the site Worker reports, or `undefined` when it does not answer (older Workers). */
|
|
11
12
|
export declare function siteFeatures(fetch: SiteFetch, token: string): Promise<{
|
|
12
13
|
gates?: number;
|
|
14
|
+
fields?: number;
|
|
13
15
|
} | undefined>;
|
|
14
16
|
/**
|
|
15
17
|
* The store's gate capability for one admin Worker isolate. A confirmation is remembered as a
|
|
@@ -25,3 +27,16 @@ export declare function siteGateSupport(options: {
|
|
|
25
27
|
readonly remember: (version: number) => void;
|
|
26
28
|
readonly log?: (line: string) => void;
|
|
27
29
|
}): GateSupport;
|
|
30
|
+
/**
|
|
31
|
+
* RFC-0045 §1: the store's reference and repeater capability for one admin Worker isolate, the
|
|
32
|
+
* twin of `siteGateSupport`: yes once the site Worker answers `{ "fields": 2 }` or more (kept as
|
|
33
|
+
* a plain value); a refusal or an error is asked again. Built in rollout step 2; nothing passes it
|
|
34
|
+
* to a store until step 7 enables the types.
|
|
35
|
+
*/
|
|
36
|
+
export declare function siteFieldTypeSupport(options: {
|
|
37
|
+
readonly fetch: SiteFetch | undefined;
|
|
38
|
+
readonly token: string | undefined;
|
|
39
|
+
readonly confirmed: () => boolean;
|
|
40
|
+
readonly remember: () => void;
|
|
41
|
+
readonly log?: (line: string) => void;
|
|
42
|
+
}): FieldTypeSupport;
|
package/dist/src/features.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* `expiry` until it answers `{ "gates": 2 }` (derived gates, RFC-0042 §3.6).
|
|
7
7
|
*/
|
|
8
8
|
import { AVAILABILITY_GATES_VERSION, } from "@cloudhal/core-ts/availability";
|
|
9
|
+
import { FIELDS_FEATURE_VERSION, } from "@cloudhal/core-ts/fields";
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
const FEATURES_URL = "https://site.internal/__cloudhal/features";
|
|
@@ -14,7 +15,7 @@ const FEATURES_URL = "https://site.internal/__cloudhal/features";
|
|
|
14
15
|
export async function siteFeatures(
|
|
15
16
|
fetch ,
|
|
16
17
|
token ,
|
|
17
|
-
)
|
|
18
|
+
) {
|
|
18
19
|
const res = await fetch(FEATURES_URL, {
|
|
19
20
|
method: "GET",
|
|
20
21
|
headers: { authorization: `Bearer ${token}` },
|
|
@@ -23,8 +24,13 @@ export async function siteFeatures(
|
|
|
23
24
|
await res.body?.cancel();
|
|
24
25
|
return undefined;
|
|
25
26
|
}
|
|
26
|
-
const body = (await res.json().catch(() => undefined))
|
|
27
|
-
|
|
27
|
+
const body = (await res.json().catch(() => undefined))
|
|
28
|
+
|
|
29
|
+
;
|
|
30
|
+
return {
|
|
31
|
+
...(typeof body?.gates === "number" ? { gates: body.gates } : {}),
|
|
32
|
+
...(typeof body?.fields === "number" ? { fields: body.fields } : {}),
|
|
33
|
+
};
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
/**
|
|
@@ -68,3 +74,36 @@ export function siteGateSupport(options
|
|
|
68
74
|
},
|
|
69
75
|
};
|
|
70
76
|
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* RFC-0045 §1: the store's reference and repeater capability for one admin Worker isolate, the
|
|
80
|
+
* twin of `siteGateSupport`: yes once the site Worker answers `{ "fields": 2 }` or more (kept as
|
|
81
|
+
* a plain value); a refusal or an error is asked again. Built in rollout step 2; nothing passes it
|
|
82
|
+
* to a store until step 7 enables the types.
|
|
83
|
+
*/
|
|
84
|
+
export function siteFieldTypeSupport(options
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
) {
|
|
91
|
+
return {
|
|
92
|
+
supported: async () => {
|
|
93
|
+
if (options.confirmed()) return true;
|
|
94
|
+
if (!options.fetch || !options.token) return false;
|
|
95
|
+
try {
|
|
96
|
+
const fields = (await siteFeatures(options.fetch, options.token))?.fields ?? 0;
|
|
97
|
+
if (fields < FIELDS_FEATURE_VERSION) {
|
|
98
|
+
options.log?.("site Worker does not read reference and repeater fields yet");
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
options.remember();
|
|
102
|
+
return true;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
options.log?.(`features check failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudhal/cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Cloudhal on Cloudflare: the admin Worker (API, auth, MCP, Studio) over D1 + R2",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://cloudhal.dev",
|
|
@@ -48,19 +48,19 @@
|
|
|
48
48
|
"README.md"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@cloudhal/agent-runtime": "0.
|
|
52
|
-
"@cloudhal/analytics": "0.
|
|
53
|
-
"@cloudhal/api": "0.
|
|
54
|
-
"@cloudhal/comments": "0.
|
|
55
|
-
"@cloudhal/core-ts": "0.
|
|
56
|
-
"@cloudhal/mcp-server": "0.
|
|
57
|
-
"@cloudhal/schedules": "0.
|
|
58
|
-
"@cloudhal/storage": "0.
|
|
51
|
+
"@cloudhal/agent-runtime": "0.8.0",
|
|
52
|
+
"@cloudhal/analytics": "0.8.0",
|
|
53
|
+
"@cloudhal/api": "0.8.0",
|
|
54
|
+
"@cloudhal/comments": "0.8.0",
|
|
55
|
+
"@cloudhal/core-ts": "0.8.0",
|
|
56
|
+
"@cloudhal/mcp-server": "0.8.0",
|
|
57
|
+
"@cloudhal/schedules": "0.8.0",
|
|
58
|
+
"@cloudhal/storage": "0.8.0",
|
|
59
59
|
"zod": "^4.6.7"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@cloudflare/workers-types": "^5.20261007.1",
|
|
63
|
-
"@cloudhal/astro-renderer": "0.
|
|
63
|
+
"@cloudhal/astro-renderer": "0.8.0",
|
|
64
64
|
"@types/node": "^26.6.5",
|
|
65
65
|
"typescript": "7.0.2",
|
|
66
66
|
"vitest": "5.1.0",
|