@substrat-run/adapter-cloudflare 0.138.0 → 0.140.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/README.md +2 -2
- package/dist/checker.d.ts.map +1 -1
- package/dist/checker.js +4 -0
- package/dist/checker.js.map +1 -1
- package/dist/control-plane-do.d.ts +95 -26
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +290 -35
- package/dist/control-plane-do.js.map +1 -1
- package/dist/host.d.ts +55 -14
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +347 -69
- package/dist/host.js.map +1 -1
- package/dist/live-reads.d.ts +30 -7
- package/dist/live-reads.d.ts.map +1 -1
- package/dist/live-reads.js +43 -9
- package/dist/live-reads.js.map +1 -1
- package/dist/route-resolver.d.ts +1 -1
- package/dist/route-resolver.d.ts.map +1 -1
- package/dist/route-resolver.js +7 -0
- package/dist/route-resolver.js.map +1 -1
- package/dist/scope-do.d.ts +29 -1
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +811 -257
- package/dist/scope-do.js.map +1 -1
- package/dist/sql.d.ts +7 -1
- package/dist/sql.d.ts.map +1 -1
- package/dist/sql.js +29 -3
- package/dist/sql.js.map +1 -1
- package/package.json +12 -10
package/dist/sql.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type RedactionSql, type ScopedSql } from '@substrat-run/kernel';
|
|
2
|
+
/** Workerd's `_cf_*` tables back runtime-owned KV and alarms, not module data. */
|
|
3
|
+
export declare function assertNoWorkerdStorage(sql: string): void;
|
|
2
4
|
/**
|
|
3
5
|
* Adapts a Durable Object's `SqlStorage` to the kernel's `ScopedSql` contract
|
|
4
6
|
* (`query`/`exec`). DO SQL is synchronous — `exec` returns a cursor eagerly —
|
|
@@ -18,7 +20,11 @@ import { type RedactionSql, type ScopedSql } from '@substrat-run/kernel';
|
|
|
18
20
|
* hosted push path. The DO's own spine writes go through `this.sql` directly and
|
|
19
21
|
* never pass through here.
|
|
20
22
|
*/
|
|
21
|
-
export declare function doScopedSql(sql: SqlStorage
|
|
23
|
+
export declare function doScopedSql(sql: SqlStorage,
|
|
24
|
+
/** #119: the module tables carrying archive/trash columns — `guardSpine` refuses positional writes to them. */
|
|
25
|
+
statefulTables?: ReadonlySet<string>,
|
|
26
|
+
/** #119: the kernel's integrity check, run after any runtime DDL — see `guardSpine`. */
|
|
27
|
+
afterDdl?: () => void): ScopedSql;
|
|
22
28
|
/**
|
|
23
29
|
* The kernel's OWN spine access (#1672) — `doScopedSql` without `guardSpine`, because these
|
|
24
30
|
* are the kernel's writes to `_substrat_capabilities`, which module code may never make.
|
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,EAAc,KAAK,YAAY,EAAE,KAAK,SAAS,EAAiB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,SAAS,EAAiB,MAAM,sBAAsB,CAAC;AAGpG,kFAAkF;AAClF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAaxD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,UAAU;AACf,+GAA+G;AAC/G,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;AACpC,wFAAwF;AACxF,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,SAAS,CAYX;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CASrD;AAED,2GAA2G;AAC3G,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,YAAY,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAWpF"}
|
package/dist/sql.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { guardSpine } from '@substrat-run/kernel';
|
|
2
|
+
import { substratError, tokenizeSql } from '@substrat-run/contracts';
|
|
3
|
+
/** Workerd's `_cf_*` tables back runtime-owned KV and alarms, not module data. */
|
|
4
|
+
export function assertNoWorkerdStorage(sql) {
|
|
5
|
+
const tokens = tokenizeSql(sql);
|
|
6
|
+
if (tokens.some((token, index) => {
|
|
7
|
+
if (!token.text.split('.').some((part) => part.toLowerCase().startsWith('_cf_')))
|
|
8
|
+
return false;
|
|
9
|
+
// Quoted tokens can also be string literals in an expression. A table name
|
|
10
|
+
// there still follows a source/target keyword, including when quoted.
|
|
11
|
+
if (!token.quoted)
|
|
12
|
+
return true;
|
|
13
|
+
const before = tokens[index - 1];
|
|
14
|
+
return before && !before.quoted &&
|
|
15
|
+
['FROM', 'JOIN', 'INTO', 'UPDATE', 'TABLE', 'REFERENCES', 'ON'].includes(before.text.toUpperCase());
|
|
16
|
+
})) {
|
|
17
|
+
throw substratError('forbidden', 'ctx.sql cannot read workerd internal storage');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
2
20
|
/**
|
|
3
21
|
* Adapts a Durable Object's `SqlStorage` to the kernel's `ScopedSql` contract
|
|
4
22
|
* (`query`/`exec`). DO SQL is synchronous — `exec` returns a cursor eagerly —
|
|
@@ -18,14 +36,22 @@ import { guardSpine } from '@substrat-run/kernel';
|
|
|
18
36
|
* hosted push path. The DO's own spine writes go through `this.sql` directly and
|
|
19
37
|
* never pass through here.
|
|
20
38
|
*/
|
|
21
|
-
export function doScopedSql(sql
|
|
39
|
+
export function doScopedSql(sql,
|
|
40
|
+
/** #119: the module tables carrying archive/trash columns — `guardSpine` refuses positional writes to them. */
|
|
41
|
+
statefulTables,
|
|
42
|
+
/** #119: the kernel's integrity check, run after any runtime DDL — see `guardSpine`. */
|
|
43
|
+
afterDdl) {
|
|
22
44
|
return guardSpine({
|
|
23
|
-
query: (q, params = []) =>
|
|
45
|
+
query: (q, params = []) => {
|
|
46
|
+
assertNoWorkerdStorage(q);
|
|
47
|
+
return sql.exec(q, ...params).toArray();
|
|
48
|
+
},
|
|
24
49
|
exec: (q, params = []) => {
|
|
50
|
+
assertNoWorkerdStorage(q);
|
|
25
51
|
const cursor = sql.exec(q, ...params);
|
|
26
52
|
return { changes: cursor.rowsWritten };
|
|
27
53
|
},
|
|
28
|
-
});
|
|
54
|
+
}, statefulTables, afterDdl);
|
|
29
55
|
}
|
|
30
56
|
/**
|
|
31
57
|
* The kernel's OWN spine access (#1672) — `doScopedSql` without `guardSpine`, because these
|
package/dist/sql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.js","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAoD,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sql.js","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAoD,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAErE,kFAAkF;AAClF,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC/F,2EA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,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;AACJ,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,cAAc,CAAC,GAAe;IAC5C,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,GAAI,MAAqB,CAAC,CAAC,OAAO,EAAE,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAe,EAAE,IAAY;IAC5D,gGAAgG;IAChG,iGAAiG;IACjG,MAAM,KAAK,GAAG,GAAG;SACd,IAAI,CACH;iEAC2D,EAC3D,IAAI,CACL;SACA,OAAO,EAAE,CAAC;IACb,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,WAAW,CAAC,CAAC,WAAW,CAAC;AAClG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/adapter-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.140.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.140.0",
|
|
30
|
+
"@substrat-run/kernel": "^0.140.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@cloudflare/vitest-pool-workers": "^0.12.21",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"typescript": "^7.0.0",
|
|
37
37
|
"vitest": "^3.2.7",
|
|
38
38
|
"wrangler": "^4.146.0",
|
|
39
|
-
"@substrat-run/attachment-extractors": "^0.1
|
|
40
|
-
"@substrat-run/
|
|
41
|
-
"@substrat-run/
|
|
42
|
-
"@substrat-run/control-plane-api": "^0.
|
|
43
|
-
"@substrat-run/
|
|
44
|
-
"@substrat-run/vertical-host": "^0.
|
|
39
|
+
"@substrat-run/attachment-extractors": "^0.2.1",
|
|
40
|
+
"@substrat-run/cli": "^0.41.0",
|
|
41
|
+
"@substrat-run/contract-tests": "^0.140.0",
|
|
42
|
+
"@substrat-run/control-plane-api": "^0.140.0",
|
|
43
|
+
"@substrat-run/vertical-auth": "^0.21.0",
|
|
44
|
+
"@substrat-run/vertical-host": "^0.140.0"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc -p tsconfig.json",
|
|
51
51
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
52
|
-
"test": "vitest run && vitest run -c vitest.supplied-sweeper.config.ts"
|
|
52
|
+
"test": "vitest run && vitest run -c vitest.supplied-sweeper.config.ts",
|
|
53
|
+
"test:contract": "vitest run test/contract.test.ts",
|
|
54
|
+
"test:rest": "vitest run --exclude test/contract.test.ts && vitest run -c vitest.supplied-sweeper.config.ts"
|
|
53
55
|
}
|
|
54
56
|
}
|