@substrat-run/adapter-cloudflare 0.92.1 → 0.94.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/control-plane-do.d.ts +69 -4
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +101 -5
- package/dist/control-plane-do.js.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +74 -6
- package/dist/host.js.map +1 -1
- package/dist/route-resolver.d.ts +23 -6
- package/dist/route-resolver.d.ts.map +1 -1
- package/dist/route-resolver.js +4 -2
- package/dist/route-resolver.js.map +1 -1
- package/dist/sql.d.ts +6 -1
- package/dist/sql.d.ts.map +1 -1
- package/dist/sql.js +8 -2
- package/dist/sql.js.map +1 -1
- package/package.json +4 -4
package/dist/route-resolver.d.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { type RouteTarget } from '@substrat-run/contracts';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Hostname → route target, for the router worker (K-26).
|
|
4
|
+
*
|
|
5
|
+
* Deliberately NOT `CloudflareScopeHost`. That coordinator needs a `SCOPE`
|
|
6
|
+
* namespace binding because it can open scope DOs, and the router has no business
|
|
7
|
+
* doing that — it resolves a name and forwards. Handing it the full host would give
|
|
8
|
+
* it authority over every tenant's data to save one file.
|
|
9
|
+
*
|
|
10
|
+
* So this is the whole surface: one directory read, and no way to reach a scope.
|
|
11
|
+
* The router's wrangler config binds `CONTROL_PLANE` and nothing else, which makes
|
|
12
|
+
* that boundary a deployment fact rather than a convention.
|
|
13
|
+
*/
|
|
14
|
+
/** A route row as the control-plane DO's `readRoute` hands it back. */
|
|
15
|
+
export interface RouteRowLike {
|
|
6
16
|
tenant_id: string;
|
|
7
17
|
scope_id: string;
|
|
8
18
|
vertical_slug: string | null;
|
|
9
19
|
surface: string;
|
|
10
20
|
region: string | null;
|
|
11
|
-
|
|
21
|
+
/** The scope's bound version's dispatch script, joined in the read. */
|
|
12
22
|
deployment_ref?: string | null;
|
|
23
|
+
/** The dispatched code's declared outbound surface (#303) as JSON text — the
|
|
24
|
+
* `outbound` array lifted from the resolved version's manifest in the same read.
|
|
25
|
+
* Null = a pre-#303 manifest (or no version), which dispatches unenforced. */
|
|
13
26
|
outbound_json?: string | null;
|
|
14
|
-
}
|
|
27
|
+
}
|
|
28
|
+
export type RouteResolver = (hostname: string) => Promise<RouteTarget | undefined>;
|
|
29
|
+
/** A hostname row → what the router dispatches on. Shared with `CloudflareScopeHost`
|
|
30
|
+
* so the two cannot drift on what "resolvable" means. */
|
|
31
|
+
export declare function toRouteTarget(row: RouteRowLike | undefined): RouteTarget | undefined;
|
|
15
32
|
/** DNS is case-insensitive, so the map is normalized and lookups must match. */
|
|
16
33
|
export declare const normalizeHostname: (hostname: string) => string;
|
|
17
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-resolver.d.ts","sourceRoot":"","sources":["../src/route-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"route-resolver.d.ts","sourceRoot":"","sources":["../src/route-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAExE;;;;;;;;;;;GAWG;AAEH,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,uEAAuE;IACvE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;mFAE+E;IAC/E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAOD,MAAM,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;AAEnF;yDACyD;AACzD,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CA2BpF;AAED,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,aAAc,MAAM,KAAG,MAAgC,CAAC;AAEtF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,GAAG,aAAa,CAgBvF"}
|
package/dist/route-resolver.js
CHANGED
|
@@ -2,7 +2,9 @@ import { routeTarget } from '@substrat-run/contracts';
|
|
|
2
2
|
/** A hostname row → what the router dispatches on. Shared with `CloudflareScopeHost`
|
|
3
3
|
* so the two cannot drift on what "resolvable" means. */
|
|
4
4
|
export function toRouteTarget(row) {
|
|
5
|
-
|
|
5
|
+
// No status check here: `readRoute` filters `h.status = 'active'` in SQL, the same
|
|
6
|
+
// way adapter-sqlite's `resolveHostname` does. One place decides what resolves.
|
|
7
|
+
if (!row)
|
|
6
8
|
return undefined;
|
|
7
9
|
// The declared outbound surface rides as JSON text from the directory read (#303).
|
|
8
10
|
// A row that carries none — pre-#303 manifest, no bound version — resolves null,
|
|
@@ -58,7 +60,7 @@ export function createRouteResolver(controlPlane) {
|
|
|
58
60
|
//
|
|
59
61
|
// Only the NAMESPACE may be held across requests. Nothing derived from it may be.
|
|
60
62
|
const cp = controlPlane.get(controlPlane.idFromName('control-plane'));
|
|
61
|
-
return toRouteTarget(await cp.
|
|
63
|
+
return toRouteTarget(await cp.readRoute(normalizeHostname(hostname)));
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
//# sourceMappingURL=route-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-resolver.js","sourceRoot":"","sources":["../src/route-resolver.ts"],"names":[],"mappings":"AAA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ACH,MAAM,UAAU,mBAAmB,CAAC,YAAoC;IACtE,OAAO,KAAK,EAAE,QAAgB,EAAE,EAAE;QAChC,oEAAoE;QACpE,EAAE;QACF,+EAA+E;QAC/E,kFAAkF;QAClF,8EAA8E;QAC9E,gFAAgF;QAChF,gFAAgF;QAChF,EAAE;QACF,kFAAkF;QAClF,MAAM,EAAE,GAAG,YAAY,CAAC,GAAG,CACzB,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,CACZ,CAAC;QAC/B,OAAO,aAAa,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/sql.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ScopedSql } from '@substrat-run/kernel';
|
|
2
2
|
/**
|
|
3
3
|
* Adapts a Durable Object's `SqlStorage` to the kernel's `ScopedSql` contract
|
|
4
4
|
* (`query`/`exec`). DO SQL is synchronous — `exec` returns a cursor eagerly —
|
|
@@ -12,6 +12,11 @@ import type { ScopedSql } from '@substrat-run/kernel';
|
|
|
12
12
|
* commit or roll back together, with read-your-own-writes intact and no buffering.
|
|
13
13
|
* (`transactionSync` also exists but is synchronous-only — it commits at the first
|
|
14
14
|
* await, so it is not used for the async operation body.)
|
|
15
|
+
*
|
|
16
|
+
* `guardSpine` wraps it because this is the connection MODULE code holds (#954):
|
|
17
|
+
* "never write `_substrat_*`" was a lint rule only, and lint never runs on the
|
|
18
|
+
* hosted push path. The DO's own spine writes go through `this.sql` directly and
|
|
19
|
+
* never pass through here.
|
|
15
20
|
*/
|
|
16
21
|
export declare function doScopedSql(sql: SqlStorage): ScopedSql;
|
|
17
22
|
//# sourceMappingURL=sql.d.ts.map
|
package/dist/sql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,SAAS,EAAiB,MAAM,sBAAsB,CAAC;AAEjF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CAStD"}
|
package/dist/sql.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { guardSpine } from '@substrat-run/kernel';
|
|
1
2
|
/**
|
|
2
3
|
* Adapts a Durable Object's `SqlStorage` to the kernel's `ScopedSql` contract
|
|
3
4
|
* (`query`/`exec`). DO SQL is synchronous — `exec` returns a cursor eagerly —
|
|
@@ -11,14 +12,19 @@
|
|
|
11
12
|
* commit or roll back together, with read-your-own-writes intact and no buffering.
|
|
12
13
|
* (`transactionSync` also exists but is synchronous-only — it commits at the first
|
|
13
14
|
* await, so it is not used for the async operation body.)
|
|
15
|
+
*
|
|
16
|
+
* `guardSpine` wraps it because this is the connection MODULE code holds (#954):
|
|
17
|
+
* "never write `_substrat_*`" was a lint rule only, and lint never runs on the
|
|
18
|
+
* hosted push path. The DO's own spine writes go through `this.sql` directly and
|
|
19
|
+
* never pass through here.
|
|
14
20
|
*/
|
|
15
21
|
export function doScopedSql(sql) {
|
|
16
|
-
return {
|
|
22
|
+
return guardSpine({
|
|
17
23
|
query: (q, params = []) => sql.exec(q, ...params).toArray(),
|
|
18
24
|
exec: (q, params = []) => {
|
|
19
25
|
const cursor = sql.exec(q, ...params);
|
|
20
26
|
return { changes: cursor.rowsWritten };
|
|
21
27
|
},
|
|
22
|
-
};
|
|
28
|
+
});
|
|
23
29
|
}
|
|
24
30
|
//# sourceMappingURL=sql.js.map
|
package/dist/sql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.js","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql.js","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiC,MAAM,sBAAsB,CAAC;AAEjF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW,CAAC,GAAe;IACzC,OAAO,UAAU,CAAC;QAChB,KAAK,EAAE,CAA+B,CAAS,EAAE,MAAM,GAAwB,EAAE,EAAO,EAAE,CACxF,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,GAAI,MAAqB,CAAC,CAAC,OAAO,EAAS;QACzD,IAAI,EAAE,CAAC,CAAS,EAAE,MAAM,GAAwB,EAAE,EAAE,EAAE;YACpD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,GAAI,MAAqB,CAAC,CAAC;YACtD,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;QACzC,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/adapter-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.94.0",
|
|
4
4
|
"description": "Cloudflare Durable-Object scope host (D-14): DO-per-scope, real kernel semantics on Workers",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@substrat-run/contracts": "^0.
|
|
30
|
-
"@substrat-run/kernel": "^0.
|
|
29
|
+
"@substrat-run/contracts": "^0.94.0",
|
|
30
|
+
"@substrat-run/kernel": "^0.94.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@cloudflare/vitest-pool-workers": "^0.9.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"typescript": "^7.0.0",
|
|
36
36
|
"vitest": "^3.2.7",
|
|
37
37
|
"wrangler": "^4.110.0",
|
|
38
|
-
"@substrat-run/contract-tests": "^0.
|
|
38
|
+
"@substrat-run/contract-tests": "^0.94.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|