@runeditrun/rer 0.2.83 → 0.2.85
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 +21 -24
- package/cli/README.md +17 -1
- package/cli/authoring.mjs +1 -0
- package/cli/bounded.mjs +1 -1
- package/cli/business/carry.mjs +149 -0
- package/cli/business/command.mjs +6 -1
- package/cli/business/connect.mjs +1 -1
- package/cli/business/local-commands.mjs +2 -0
- package/cli/business/opt-ins.mjs +8 -4
- package/cli/business/questions.mjs +4 -1
- package/cli/business/state.mjs +1 -1
- package/cli/business/supervisor.mjs +7 -1
- package/cli/container-transfer.mjs +2 -2
- package/cli/contract.mjs +7 -7
- package/cli/demo-host.mjs +5 -1
- package/cli/demo-native.mjs +2 -1
- package/cli/demo.mjs +6 -1
- package/cli/deploy-command.mjs +6 -4
- package/cli/deploy.mjs +9 -7
- package/cli/errors.mjs +1 -1
- package/cli/export.mjs +1 -1
- package/cli/human-error.mjs +20 -0
- package/cli/lifecycle.mjs +23 -5
- package/cli/main.mjs +1 -1
- package/cli/managed-data-schema.mjs +114 -0
- package/cli/managed-data-zip.mjs +116 -0
- package/cli/managed-data.mjs +110 -0
- package/cli/managed-server.mjs +25 -14
- package/cli/native-owner-entry.mjs +86 -0
- package/cli/output.mjs +3 -2
- package/cli/parse.mjs +3 -3
- package/cli/portability-empty.mjs +59 -0
- package/cli/portability-migrations.mjs +7 -5
- package/cli/portability-policy.mjs +5 -2
- package/cli/portability-worker.mjs +15 -6
- package/cli/portability.mjs +30 -8
- package/cli/ready-summary.mjs +9 -0
- package/cli/run-transfers.mjs +37 -0
- package/cli/runtime-front-door.mjs +4 -4
- package/cli/server-proxy.mjs +4 -3
- package/cli/server-registry.mjs +13 -8
- package/cli/site.mjs +6 -1
- package/cli/transfers.mjs +17 -4
- package/edition-authoring/base-copies.mjs +125 -30
- package/edition-authoring/copy-checkout.mjs +7 -120
- package/edition-authoring/edition-migrations.mjs +41 -0
- package/edition-authoring/files.mjs +67 -0
- package/edition-authoring/lock.mjs +2 -2
- package/edition-authoring/module-closure.mjs +232 -0
- package/edition-authoring/module-edges.mjs +100 -0
- package/edition-authoring/module-resolution.mjs +66 -0
- package/edition-authoring/module-syntax.mjs +57 -0
- package/edition-authoring/package-target.mjs +92 -0
- package/edition-authoring/runtime-dependencies.mjs +74 -97
- package/edition-authoring/vendor/babel-parser/LICENSE +22 -0
- package/edition-authoring/vendor/babel-parser/README.md +21 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-string-parser/index.mjs +292 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/identifier.mjs +66 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/index.mjs +13 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/keyword.mjs +31 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/index.mjs +99 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/options.mjs +81 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/bind-operator-errors.mjs +8 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/module-errors.mjs +15 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/parse-expression-errors.mjs +10 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/pipeline-operator-errors.mjs +29 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/standard-errors.mjs +224 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/strict-mode-errors.mjs +17 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/to-node-description.mjs +31 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error.mjs +114 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/base.mjs +34 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/comments.mjs +199 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/expression.mjs +1794 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/index.mjs +76 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/lval.mjs +439 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/node.mjs +111 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/statement.mjs +1962 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/util.mjs +244 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugin-utils.mjs +116 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/estree.mjs +417 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/index.mjs +2412 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/scope.mjs +37 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/index.mjs +420 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/xhtml.mjs +261 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/placeholders.mjs +205 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/index.mjs +2889 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/scope.mjs +115 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/v8intrinsic.mjs +26 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/context.mjs +22 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/index.mjs +1037 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/state.mjs +178 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/types.mjs +583 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/types.mjs +1 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/class-scope.mjs +82 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/expression-scope.mjs +121 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/identifier.mjs +23 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/location.mjs +34 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/production-parameter.mjs +40 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/scope.mjs +173 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/scopeflags.mjs +66 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/whitespace.mjs +61 -0
- package/edition-authoring/vendor/yaml/LICENSE +13 -0
- package/edition-authoring/vendor/yaml/README.md +11 -0
- package/edition-authoring/vendor/yaml/compose/compose-collection.mjs +88 -0
- package/edition-authoring/vendor/yaml/compose/compose-doc.mjs +43 -0
- package/edition-authoring/vendor/yaml/compose/compose-node.mjs +110 -0
- package/edition-authoring/vendor/yaml/compose/compose-scalar.mjs +86 -0
- package/edition-authoring/vendor/yaml/compose/composer.mjs +218 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-map.mjs +115 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-scalar.mjs +198 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-seq.mjs +49 -0
- package/edition-authoring/vendor/yaml/compose/resolve-end.mjs +37 -0
- package/edition-authoring/vendor/yaml/compose/resolve-flow-collection.mjs +207 -0
- package/edition-authoring/vendor/yaml/compose/resolve-flow-scalar.mjs +228 -0
- package/edition-authoring/vendor/yaml/compose/resolve-props.mjs +148 -0
- package/edition-authoring/vendor/yaml/compose/util-contains-newline.mjs +34 -0
- package/edition-authoring/vendor/yaml/compose/util-empty-scalar-position.mjs +27 -0
- package/edition-authoring/vendor/yaml/compose/util-flow-indent-check.mjs +15 -0
- package/edition-authoring/vendor/yaml/compose/util-map-includes.mjs +13 -0
- package/edition-authoring/vendor/yaml/doc/Document.mjs +333 -0
- package/edition-authoring/vendor/yaml/doc/anchors.mjs +74 -0
- package/edition-authoring/vendor/yaml/doc/applyReviver.mjs +54 -0
- package/edition-authoring/vendor/yaml/doc/createNode.mjs +88 -0
- package/edition-authoring/vendor/yaml/doc/directives.mjs +176 -0
- package/edition-authoring/vendor/yaml/errors.mjs +57 -0
- package/edition-authoring/vendor/yaml/index.mjs +17 -0
- package/edition-authoring/vendor/yaml/log.mjs +11 -0
- package/edition-authoring/vendor/yaml/nodes/Alias.mjs +119 -0
- package/edition-authoring/vendor/yaml/nodes/Collection.mjs +147 -0
- package/edition-authoring/vendor/yaml/nodes/Node.mjs +38 -0
- package/edition-authoring/vendor/yaml/nodes/Pair.mjs +36 -0
- package/edition-authoring/vendor/yaml/nodes/Scalar.mjs +24 -0
- package/edition-authoring/vendor/yaml/nodes/YAMLMap.mjs +144 -0
- package/edition-authoring/vendor/yaml/nodes/YAMLSeq.mjs +113 -0
- package/edition-authoring/vendor/yaml/nodes/addPairToJSMap.mjs +62 -0
- package/edition-authoring/vendor/yaml/nodes/identity.mjs +36 -0
- package/edition-authoring/vendor/yaml/nodes/toJS.mjs +35 -0
- package/edition-authoring/vendor/yaml/parse/cst-scalar.mjs +214 -0
- package/edition-authoring/vendor/yaml/parse/cst-stringify.mjs +61 -0
- package/edition-authoring/vendor/yaml/parse/cst-visit.mjs +97 -0
- package/edition-authoring/vendor/yaml/parse/cst.mjs +98 -0
- package/edition-authoring/vendor/yaml/parse/lexer.mjs +722 -0
- package/edition-authoring/vendor/yaml/parse/line-counter.mjs +39 -0
- package/edition-authoring/vendor/yaml/parse/parser.mjs +975 -0
- package/edition-authoring/vendor/yaml/public-api.mjs +102 -0
- package/edition-authoring/vendor/yaml/schema/Schema.mjs +37 -0
- package/edition-authoring/vendor/yaml/schema/common/map.mjs +17 -0
- package/edition-authoring/vendor/yaml/schema/common/null.mjs +15 -0
- package/edition-authoring/vendor/yaml/schema/common/seq.mjs +17 -0
- package/edition-authoring/vendor/yaml/schema/common/string.mjs +14 -0
- package/edition-authoring/vendor/yaml/schema/core/bool.mjs +19 -0
- package/edition-authoring/vendor/yaml/schema/core/float.mjs +43 -0
- package/edition-authoring/vendor/yaml/schema/core/int.mjs +38 -0
- package/edition-authoring/vendor/yaml/schema/core/schema.mjs +23 -0
- package/edition-authoring/vendor/yaml/schema/json/schema.mjs +62 -0
- package/edition-authoring/vendor/yaml/schema/tags.mjs +96 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/binary.mjs +59 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/bool.mjs +26 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/float.mjs +46 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/int.mjs +71 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/merge.mjs +67 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/omap.mjs +74 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/pairs.mjs +78 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/schema.mjs +39 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/set.mjs +93 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/timestamp.mjs +101 -0
- package/edition-authoring/vendor/yaml/stringify/foldFlowLines.mjs +146 -0
- package/edition-authoring/vendor/yaml/stringify/stringify.mjs +130 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyCollection.mjs +155 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyComment.mjs +20 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyDocument.mjs +85 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyNumber.mjs +25 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyPair.mjs +150 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyString.mjs +338 -0
- package/edition-authoring/vendor/yaml/util.mjs +11 -0
- package/edition-authoring/vendor/yaml/visit.mjs +233 -0
- package/edition-authoring/workflow-copies.mjs +125 -0
- package/edition-authoring/workflow-scripts.mjs +112 -0
- package/foundation/runtime/contract-docs.mjs +754 -0
- package/foundation/runtime/run-data.d.mts +1 -0
- package/foundation/runtime/run-data.mjs +2 -0
- package/global/CHANGELOG.md +55 -3
- package/global/README.md +21 -24
- package/global/cli/command.mjs +8 -2
- package/global/cli/install.mjs +4 -5
- package/global/cli/path-link.mjs +3 -2
- package/global/cli/repo-command.mjs +3 -7
- package/global/launch/dev.mjs +12 -2
- package/global/launch/facts.mjs +2 -2
- package/global/launch/render.mjs +16 -9
- package/global/launch/state.mjs +4 -4
- package/global/main.mjs +12 -7
- package/install.sh +17 -6
- package/modules/container/README.md +6 -1
- package/modules/container/adapters/d1-limits.mjs +286 -0
- package/modules/container/adapters/d1-sqlite.mjs +95 -0
- package/modules/container/adapters/d1-workerd-preload.mjs +19 -0
- package/modules/container/adapters/d1-workerd-setup.mjs +26 -0
- package/modules/container/adapters/d1-workerd.mjs +5 -0
- package/modules/container/adapters/sqlite-worker.mjs +5 -3
- package/modules/container/build.mjs +1 -0
- package/modules/container/image-variables.mjs +8 -3
- package/modules/container/transfer.mjs +14 -4
- package/modules/container/worker-engine.mjs +3 -3
- package/modules/demo/declaration.mjs +1 -4
- package/modules/demo/vite.mjs +1 -1
- package/modules/demo-host/build.mjs +1 -0
- package/modules/demo-host/native/prepare.mjs +2 -1
- package/modules/demo-host/native/sql.mjs +7 -2
- package/modules/deploy-kit/README.md +23 -3
- package/modules/deploy-kit/d1-import-diagnostics.mjs +56 -0
- package/modules/deploy-kit/d1-import.mjs +17 -5
- package/modules/deploy-kit/diagnostics.mjs +29 -3
- package/modules/deploy-kit/owner-cli.mjs +20 -7
- package/modules/deploy-kit/provider-transport.mjs +19 -4
- package/modules/deploy-kit/provider.mjs +57 -22
- package/modules/deploy-kit/readiness-window.mjs +1 -1
- package/modules/deploy-kit/site.mjs +8 -3
- package/modules/deploy-kit/templates.mjs +3 -3
- package/modules/deploy-kit/worker.mjs +4 -4
- package/modules/import-kit/src/d1/README.md +23 -4
- package/modules/import-kit/src/d1/atomic-prefix.ts +2 -2
- package/modules/import-kit/src/d1/budget.ts +15 -7
- package/modules/import-kit/src/d1/column-layout.ts +5 -0
- package/modules/import-kit/src/d1/creation.ts +15 -8
- package/modules/import-kit/src/d1/database.ts +3 -3
- package/modules/import-kit/src/d1/erasure-pages.ts +2 -1
- package/modules/import-kit/src/d1/erasure.ts +2 -2
- package/modules/import-kit/src/d1/jobs.ts +10 -6
- package/modules/import-kit/src/d1/plans.ts +14 -8
- package/modules/import-kit/src/d1/retirement.ts +2 -2
- package/modules/import-kit/src/d1/sets.ts +1 -3
- package/modules/import-kit/src/d1/staged-creation.ts +3 -3
- package/modules/import-kit/src/door/limits.ts +1 -1
- package/modules/import-kit/src/door/refusals.ts +1 -1
- package/modules/portability/README.md +112 -4
- package/modules/portability/backfills.mjs +9 -8
- package/modules/portability/bridge.mjs +12 -5
- package/modules/portability/catalogue.mjs +12 -5
- package/modules/portability/files.mjs +4 -3
- package/modules/portability/http.mjs +3 -3
- package/modules/portability/import.mjs +18 -9
- package/modules/portability/index.d.mts +4 -3
- package/modules/portability/index.mjs +1 -1
- package/modules/portability/ledgers.mjs +3 -2
- package/modules/portability/legacy-safety.mjs +11 -2
- package/modules/portability/migration-history.mjs +2 -2
- package/modules/portability/progress.mjs +1 -0
- package/modules/portability/restore-empty.mjs +12 -0
- package/modules/release/github-verify.mjs +11 -2
- package/onboarding/adapter.mjs +35 -6
- package/onboarding/app-fetch.mjs +6 -4
- package/onboarding/development-runtime.mjs +19 -0
- package/onboarding/local/operation.mjs +45 -27
- package/onboarding/loopback-fetch.mjs +16 -0
- package/onboarding/operator-installer.mjs +4 -6
- package/onboarding/process-diagnostics.mjs +6 -2
- package/onboarding/production-runtime.mjs +4 -2
- package/onboarding/readiness.mjs +1 -0
- package/package.json +1 -1
- package/scripts/publish-check/README.md +6 -0
- package/scripts/publish-check/history_scan.py +5 -3
- package/scripts/publish-check/hygiene_config.py +2 -1
- package/scripts/publish-check/public_hygiene.py +1 -1
- package/scripts/publish-check/report.py +9 -3
- package/scripts/publish-check/third-party-notices.json +13 -0
- package/scripts/publish-check/third_party_notices.py +38 -0
- package/scripts/publish-check/tree_scan.py +6 -0
- package/scripts/publish-check.mjs +1 -1
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/** Cloudflare D1 per-query limits, supplied from the platform limits page
|
|
2
|
+
* (updated 24 Oct 2026). Expression depth 100 is OBSERVED-NOT-DOCUMENTED:
|
|
3
|
+
* native D1 rejected a concatenation tree of depth 101 on 27 Oct 2026.
|
|
4
|
+
* Node 22.20.0 ignores DatabaseSync limits options: preflight is mandatory.
|
|
5
|
+
* Queries per Worker invocation (Paid 1000, Free 50, batch counts once) and
|
|
6
|
+
* the 30 second query deadline are NOT-ENFORCEABLE-LOCALLY here: a database
|
|
7
|
+
* connection has neither the invocation boundary nor the provider scheduler.
|
|
8
|
+
*/
|
|
9
|
+
export const d1NativeLimits = Object.freeze({ length: 2_000_000, sqlLength: 100_000,
|
|
10
|
+
column: 100, variableNumber: 100, functionArg: 32, likePatternLength: 50, exprDepth: 100 });
|
|
11
|
+
|
|
12
|
+
/** ENFORCED-BY-PREFLIGHT. Self-contained so workerd can run the same code.
|
|
13
|
+
* Depth is an estimate, not a complete SQLite parser. Parentheses, function
|
|
14
|
+
* calls, operator chains and CASE bodies are traversed without evaluating SQL.
|
|
15
|
+
*/
|
|
16
|
+
export function d1Preflight(sql, values = [], tableColumns) {
|
|
17
|
+
const bytes = value => typeof value === 'string' ? new TextEncoder().encode(value).length
|
|
18
|
+
: value instanceof ArrayBuffer ? value.byteLength : ArrayBuffer.isView(value) ? value.byteLength
|
|
19
|
+
: Array.isArray(value) ? value.length : 0;
|
|
20
|
+
const limit = (name, maximum, measured) => {
|
|
21
|
+
if (measured > maximum) throw new Error(`D1 limit exceeded: ${name} maximum ${maximum}, measured ${measured}`);
|
|
22
|
+
};
|
|
23
|
+
limit('SQL statement bytes', d1NativeLimits.sqlLength, bytes(sql));
|
|
24
|
+
limit('bound parameters', d1NativeLimits.variableNumber, values.length);
|
|
25
|
+
for (const value of values) limit('string or BLOB bytes', d1NativeLimits.length, bytes(value));
|
|
26
|
+
const tokens = [];
|
|
27
|
+
const pattern = /\s+|--[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/|[xX]'(?:[0-9a-fA-F]{2})*'|'(?:''|[^'])*'|"(?:""|[^"])*"|`(?:``|[^`])*`|\[[^\]]*\]|\?(?:\d+)?|[:@$][\w]+|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|[\p{L}_][\p{L}\p{N}_$]*|\|\||->>|->|<<|>>|<=|>=|<>|!=|==|[^\s]/gu;
|
|
28
|
+
let bindIndex = 0;
|
|
29
|
+
const names = new Map();
|
|
30
|
+
for (const match of sql.matchAll(pattern)) {
|
|
31
|
+
const text = match[0];
|
|
32
|
+
if (/^\s|^--|^\/\*/.test(text)) continue;
|
|
33
|
+
const token = { text, word: text.toUpperCase(), value: undefined, parameter: false };
|
|
34
|
+
if (text[0] === "'") token.value = text.slice(1, -1).replaceAll("''", "'");
|
|
35
|
+
else if (/^[xX]'/.test(text)) token.value = new Uint8Array((text.length - 3) / 2);
|
|
36
|
+
else if (/^[?:@$]/.test(text)) {
|
|
37
|
+
token.parameter = true;
|
|
38
|
+
let index;
|
|
39
|
+
if (/^\?\d+$/.test(text)) index = Number(text.slice(1));
|
|
40
|
+
else if (text === '?') index = bindIndex + 1;
|
|
41
|
+
else { if (!names.has(text)) names.set(text, bindIndex + 1); index = names.get(text); }
|
|
42
|
+
bindIndex = Math.max(bindIndex, index);
|
|
43
|
+
token.value = values[index - 1];
|
|
44
|
+
}
|
|
45
|
+
if (token.value !== undefined) limit('string or BLOB bytes', d1NativeLimits.length, bytes(token.value));
|
|
46
|
+
tokens.push(token);
|
|
47
|
+
}
|
|
48
|
+
limit('bound parameters', d1NativeLimits.variableNumber, bindIndex);
|
|
49
|
+
const structural = new Set(['IN', 'VALUES', 'AS', 'SELECT', 'FROM', 'WHERE', 'ON', 'USING', 'OVER', 'FILTER', 'EXISTS', 'TABLE', 'CHECK', 'KEY', 'UNIQUE', 'REFERENCES', 'CONSTRAINT', 'BY', 'WHEN', 'THEN', 'ELSE', 'END', 'AND', 'OR', 'NOT', 'IS', 'SET', 'RETURNING']);
|
|
50
|
+
const pairs = new Map(), stack = [];
|
|
51
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
52
|
+
if (tokens[i].text === '(') stack.push(i);
|
|
53
|
+
if (tokens[i].text === ')' && stack.length) { const open = stack.pop(); pairs.set(open, i); }
|
|
54
|
+
}
|
|
55
|
+
const split = (start, end) => {
|
|
56
|
+
const parts = []; let begin = start;
|
|
57
|
+
for (let i = start; i < end; i++) {
|
|
58
|
+
if (tokens[i].text === '(' && pairs.has(i)) i = pairs.get(i);
|
|
59
|
+
else if (tokens[i].text === ',') { parts.push([begin, i]); begin = i + 1; }
|
|
60
|
+
}
|
|
61
|
+
if (begin < end) parts.push([begin, end]);
|
|
62
|
+
return parts;
|
|
63
|
+
};
|
|
64
|
+
const projectedColumns = new Map();
|
|
65
|
+
const identifier = token => {
|
|
66
|
+
const text = token?.text ?? '';
|
|
67
|
+
return /^["'`\[]/.test(text) ? text.slice(1,-1).replace(/(["'`])\1/g, '$1') : text;
|
|
68
|
+
};
|
|
69
|
+
const tableAt = index => tokens[index + 1]?.text === '.' ? index + 2 : index;
|
|
70
|
+
const key = name => name.replace(/[A-Z]/g, char => char.toLowerCase());
|
|
71
|
+
const existing = name => projectedColumns.has(key(name)) ? projectedColumns.get(key(name)) : tableColumns?.(name);
|
|
72
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
73
|
+
const token = tokens[i], close = pairs.get(i + 1);
|
|
74
|
+
const call = close !== undefined && /^[\p{L}_][\p{L}\p{N}_$]*$/u.test(token.text) && !structural.has(token.word);
|
|
75
|
+
// A table name following CREATE TABLE or INSERT INTO is not a function.
|
|
76
|
+
const table = ['TABLE', 'INTO', 'EXISTS', 'REFERENCES', 'VIEW', 'USING'].includes(tokens[i - 1]?.word)
|
|
77
|
+
|| tokens[i - 1]?.text === '.' && ['TABLE', 'INTO', 'EXISTS', 'REFERENCES', 'VIEW'].includes(tokens[i - 3]?.word)
|
|
78
|
+
|| tokens[i - 1]?.word === 'ON' && tokens.slice(0, i).some(t => t.word === 'INDEX')
|
|
79
|
+
|| tokens[close + 1]?.word === 'AS' && ['(', 'MATERIALIZED', 'NOT'].includes(tokens[close + 2]?.word);
|
|
80
|
+
if (call && !table) {
|
|
81
|
+
const args = split(i + 2, close);
|
|
82
|
+
limit('SQL function arguments', d1NativeLimits.functionArg, args.length);
|
|
83
|
+
if (['LIKE', 'GLOB'].includes(token.word)) limit('LIKE or GLOB pattern bytes', d1NativeLimits.likePatternLength, bytes(tokens[args[0]?.[0]]?.value));
|
|
84
|
+
}
|
|
85
|
+
if (['LIKE', 'GLOB'].includes(token.word) && tokens[i + 1]?.text !== '(') limit('LIKE or GLOB pattern bytes', d1NativeLimits.likePatternLength, bytes(tokens[i + 1]?.value));
|
|
86
|
+
if (token.word === 'ALTER' && tokens[i + 1]?.word === 'TABLE') {
|
|
87
|
+
const nameIndex = tableAt(i + 2), name = identifier(tokens[nameIndex]), count = existing(name);
|
|
88
|
+
const action = tokens[nameIndex + 1]?.word;
|
|
89
|
+
if (count !== undefined && action === 'ADD') { limit('columns per table', d1NativeLimits.column, count + 1); projectedColumns.set(key(name), count + 1); }
|
|
90
|
+
if (count !== undefined && action === 'DROP') projectedColumns.set(key(name), count - 1);
|
|
91
|
+
if (count !== undefined && action === 'RENAME' && tokens[nameIndex + 2]?.word === 'TO') projectedColumns.set(key(identifier(tokens[nameIndex + 3])), count);
|
|
92
|
+
}
|
|
93
|
+
if (token.word === 'TABLE' && tokens[i - 1]?.word !== 'VIRTUAL' && tokens.slice(Math.max(0, i - 2), i).some(t => t.word === 'CREATE')) {
|
|
94
|
+
let open = i + 1;
|
|
95
|
+
while (open < tokens.length && tokens[open].text !== '(') open++;
|
|
96
|
+
const end = pairs.get(open);
|
|
97
|
+
if (end !== undefined) {
|
|
98
|
+
const columns = split(open + 1, end).filter(([start]) => !['CONSTRAINT', 'PRIMARY', 'UNIQUE', 'CHECK', 'FOREIGN'].includes(tokens[start].word));
|
|
99
|
+
limit('columns per table', d1NativeLimits.column, columns.length);
|
|
100
|
+
const name = identifier(tokens[tableAt(i + (tokens[i + 1]?.word === 'IF' ? 4 : 1))]);
|
|
101
|
+
projectedColumns.set(key(name), tokens[i + 1]?.word === 'IF' ? existing(name) ?? columns.length : columns.length);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Estimate expression-tree height with precedence, preserving left-associative
|
|
106
|
+
// chains. SQL clause boundaries reset trees; parentheses do not add a node.
|
|
107
|
+
const precedence = new Map([['OR', 1], ['AND', 2], ['=', 3], ['==', 3], ['!=', 3], ['<>', 3], ['IS', 3], ['LIKE', 3], ['GLOB', 3], ['IN', 3], ['<', 4], ['>', 4], ['<=', 4], ['>=', 4], ['|', 5], ['&', 5], ['<<', 5], ['>>', 5], ['+', 6], ['-', 6], ['*', 7], ['/', 7], ['%', 7], ['||', 8], ['->', 8], ['->>', 8]]);
|
|
108
|
+
let maximumDepth = 0;
|
|
109
|
+
function scan(start, end) {
|
|
110
|
+
let heights = [], operators = [], expect = true, localDepth = 1, unary = 0;
|
|
111
|
+
const reduce = () => { const right = heights.pop() ?? 1, left = heights.pop() ?? 1; operators.pop(); heights.push(1 + Math.max(left, right)); };
|
|
112
|
+
const flush = () => { while (operators.length) reduce(); localDepth = Math.max(localDepth, ...heights); maximumDepth = Math.max(maximumDepth, localDepth); heights = []; expect = true; unary = 0; };
|
|
113
|
+
const atom = height => { heights.push(height + unary); unary = 0; expect = false; };
|
|
114
|
+
for (let i = start; i < end; i++) {
|
|
115
|
+
const token = tokens[i];
|
|
116
|
+
if (expect && ['NOT', '+', '-', '~'].includes(token.word)) { unary++; continue; }
|
|
117
|
+
if (token.text === '(' && pairs.has(i)) {
|
|
118
|
+
const close = pairs.get(i), child = scan(i + 1, close);
|
|
119
|
+
const previous = tokens[i - 1];
|
|
120
|
+
const call = previous && /^[\p{L}_][\p{L}\p{N}_$]*$/u.test(previous.text) && !structural.has(previous.word);
|
|
121
|
+
const prefix = call && !expect ? Math.max(0, heights.pop() - 1) : 0;
|
|
122
|
+
atom(child + (call ? 1 : 0) + prefix); i = close;
|
|
123
|
+
} else if (precedence.has(token.word) && !expect) {
|
|
124
|
+
const priority = precedence.get(token.word);
|
|
125
|
+
while (operators.length && operators.at(-1) >= priority) reduce();
|
|
126
|
+
operators.push(priority); expect = true;
|
|
127
|
+
} else if (token.word === 'CASE') {
|
|
128
|
+
let nesting = 1, close = i + 1;
|
|
129
|
+
for (; close < end; close++) {
|
|
130
|
+
if (tokens[close].word === 'CASE') nesting++;
|
|
131
|
+
if (tokens[close].word === 'END' && --nesting === 0) break;
|
|
132
|
+
}
|
|
133
|
+
atom(scan(i + 1, close) + 1); i = close;
|
|
134
|
+
} else if (structural.has(token.word) || [',', ';'].includes(token.text)) flush();
|
|
135
|
+
else if (token.text !== ')' && token.text !== '.') atom(1);
|
|
136
|
+
}
|
|
137
|
+
flush(); return localDepth;
|
|
138
|
+
}
|
|
139
|
+
scan(0, tokens.length);
|
|
140
|
+
let caseDepth = 0;
|
|
141
|
+
for (const token of tokens) { if (token.word === 'CASE') maximumDepth = Math.max(maximumDepth, ++caseDepth + 1); if (token.word === 'END') caseDepth--; }
|
|
142
|
+
limit('expression depth estimate (OBSERVED-NOT-DOCUMENTED)', d1NativeLimits.exprDepth, maximumDepth);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Check computed result values before exposing a statement's results. Drivers
|
|
146
|
+
* call this inside their transaction so a failed RETURNING also rolls back. */
|
|
147
|
+
export function d1ResultPreflight(rows) {
|
|
148
|
+
for (const row of rows) for (const value of Object.values(row)) {
|
|
149
|
+
const size = typeof value === 'string' ? new TextEncoder().encode(value).length
|
|
150
|
+
: value instanceof ArrayBuffer || ArrayBuffer.isView(value) ? value.byteLength
|
|
151
|
+
: Array.isArray(value) ? value.length : 0;
|
|
152
|
+
if (size > d1NativeLimits.length) throw new Error(`D1 limit exceeded: string or BLOB bytes maximum ${d1NativeLimits.length}, measured ${size}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Shared encoded-record measurement. Node installs connection-local BEFORE
|
|
157
|
+
* triggers. Workerd forbids those triggers, so it checks uncommitted rows
|
|
158
|
+
* inside the existing D1 transaction and throws before that transaction commits.
|
|
159
|
+
*/
|
|
160
|
+
export function createD1RowGuard() {
|
|
161
|
+
const quote = name => '"' + name.replaceAll('"', '""') + '"';
|
|
162
|
+
const sum = terms => terms.length === 0 ? '0' : terms.length === 1 ? terms[0]
|
|
163
|
+
: `(${sum(terms.slice(0, terms.length >> 1))}+${sum(terms.slice(terms.length >> 1))})`;
|
|
164
|
+
const state = new WeakMap();
|
|
165
|
+
const key = name => name.replace(/[A-Z]/g, char => char.toLowerCase());
|
|
166
|
+
return function guardD1Rows(db, prepare, exec, query, schemaEdit = false) {
|
|
167
|
+
// Internal TEMP triggers must not participate in application schema edits.
|
|
168
|
+
// SQLite validates every trigger when a column is dropped, even though
|
|
169
|
+
// these guards will be regenerated against the resulting schema.
|
|
170
|
+
if (exec && schemaEdit) {
|
|
171
|
+
for (const name of state.get(db)?.names ?? []) exec(`DROP TRIGGER IF EXISTS temp.${quote(name)}`);
|
|
172
|
+
state.delete(db);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const version = exec ? prepare('PRAGMA main.schema_version').get().schema_version : undefined;
|
|
176
|
+
if (exec && state.get(db)?.version === version) return;
|
|
177
|
+
const tables = prepare("SELECT name,sql FROM sqlite_master WHERE type='table' AND name NOT GLOB 'sqlite_*'").all();
|
|
178
|
+
let touched;
|
|
179
|
+
if (query) {
|
|
180
|
+
// Read only the tables this statement and its SQL triggers can change.
|
|
181
|
+
// Quoted strings are opaque; quoted table identifiers are decoded only
|
|
182
|
+
// after a mutation keyword. This avoids rescanning unrelated large stores.
|
|
183
|
+
const targets = sql => {
|
|
184
|
+
const tokens = [...sql.matchAll(/--[^\n]*|\/\*[\s\S]*?\*\/|'(?:''|[^'])*'|"(?:""|[^"])*"|`(?:``|[^`])*`|\[[^\]]*\]|[a-zA-Z_\u0080-\uFFFF][a-zA-Z_0-9$\u0080-\uFFFF]*|[.;]/g)]
|
|
185
|
+
.map(match => match[0]).filter(text => !text.startsWith('--') && !text.startsWith('/*'));
|
|
186
|
+
const names = [];
|
|
187
|
+
const word = index => /^[a-zA-Z_]/.test(tokens[index] ?? '') ? tokens[index].toUpperCase() : '';
|
|
188
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
189
|
+
if (!['INSERT','UPDATE','DELETE','REPLACE'].includes(word(i))) continue;
|
|
190
|
+
let next = i + 1;
|
|
191
|
+
if (word(next) === 'OR') next += 2;
|
|
192
|
+
if (word(i) === 'DELETE') { if (word(next) !== 'FROM') continue; next++; }
|
|
193
|
+
else if (word(i) !== 'UPDATE') { if (word(next) !== 'INTO') continue; next++; }
|
|
194
|
+
if (tokens[next + 1] === '.') next += 2;
|
|
195
|
+
const name = tokens[next];
|
|
196
|
+
if (!name || /^[.;]$/.test(name)) continue;
|
|
197
|
+
names.push(/^["'`\[]/.test(name) ? name.slice(1,-1).replace(/(["'`])\1/g, '$1') : name);
|
|
198
|
+
}
|
|
199
|
+
return names;
|
|
200
|
+
};
|
|
201
|
+
touched = new Set(targets(query).map(key));
|
|
202
|
+
const triggers = prepare("SELECT tbl_name,sql FROM sqlite_master WHERE type='trigger'").all();
|
|
203
|
+
let previous;
|
|
204
|
+
do {
|
|
205
|
+
previous = touched.size;
|
|
206
|
+
for (const trigger of triggers) if (touched.has(key(trigger.tbl_name))) for (const name of targets(trigger.sql)) touched.add(key(name));
|
|
207
|
+
} while (previous !== touched.size);
|
|
208
|
+
for (const table of tables) if (touched.has(key(table.name)) && /^CREATE\s+VIRTUAL\s+TABLE\b/i.test(table.sql))
|
|
209
|
+
for (const shadow of tables) if (key(shadow.name).startsWith(key(table.name) + '_')) touched.add(key(shadow.name));
|
|
210
|
+
}
|
|
211
|
+
const names = [];
|
|
212
|
+
for (const table of tables) {
|
|
213
|
+
if (touched && !touched.has(key(table.name))) continue;
|
|
214
|
+
// Cloudflare owns reserved metadata; its authorizer forbids user access.
|
|
215
|
+
if (table.name.startsWith('_cf_')) continue;
|
|
216
|
+
// Virtual indexes store their data in ordinary shadow tables below.
|
|
217
|
+
if (/^CREATE\s+VIRTUAL\s+TABLE\b/i.test(table.sql)) continue;
|
|
218
|
+
const columns = prepare(`PRAGMA ${exec ? 'main.table_xinfo' : 'table_info'}(${quote(table.name)})`).all().filter(column => column.hidden !== 2);
|
|
219
|
+
if (columns.length > d1NativeLimits.column) throw new Error(`D1 limit exceeded: columns per table maximum ${d1NativeLimits.column}, measured ${columns.length}`);
|
|
220
|
+
const primary = columns.filter(column => column.pk);
|
|
221
|
+
// The primary-key index distinguishes stored INTEGER keys (including
|
|
222
|
+
// inline DESC and WITHOUT ROWID) from SQLite's rowid alias.
|
|
223
|
+
const integerPrimary = primary.length === 1 && primary[0].type.toUpperCase() === 'INTEGER';
|
|
224
|
+
const rowidAlias = integerPrimary && !prepare(`PRAGMA index_list(${quote(table.name)})`).all().some(index => index.origin === 'pk') ? primary[0].name : undefined;
|
|
225
|
+
const body = [], header = [], projection = [];
|
|
226
|
+
for (const [index, column] of columns.entries()) {
|
|
227
|
+
const value = `v${index}`, length = `length(CAST(${value} AS BLOB))`, type = `typeof(${value})`;
|
|
228
|
+
projection.push(`${column.name === rowidAlias ? 'NULL' : `${exec ? 'NEW.' : ''}${quote(column.name)}`} AS ${value}`);
|
|
229
|
+
body.push(`CASE WHEN ${value} IS NULL THEN 0 WHEN ${type} IN ('integer','real') THEN CASE WHEN ${type}='real' AND ${value}<>CAST(${value} AS INTEGER) THEN 8 WHEN ${value} IN (0,1) THEN 0 WHEN ${value} BETWEEN -128 AND 127 THEN 1 WHEN ${value} BETWEEN -32768 AND 32767 THEN 2 WHEN ${value} BETWEEN -8388608 AND 8388607 THEN 3 WHEN ${value} BETWEEN -2147483648 AND 2147483647 THEN 4 WHEN ${value} BETWEEN -140737488355328 AND 140737488355327 THEN 6 ELSE 8 END ELSE ${length} END`);
|
|
230
|
+
header.push(`CASE WHEN ${type} IN ('text','blob') THEN CASE WHEN ${length}<=57 THEN 1 WHEN ${length}<=8185 THEN 2 WHEN ${length}<=1048569 THEN 3 ELSE 4 END ELSE 1 END`);
|
|
231
|
+
}
|
|
232
|
+
// Aliases keep internal measurement below the SQL budget at 100 columns;
|
|
233
|
+
// balanced sums keep its own tree below the observed depth boundary.
|
|
234
|
+
const source = `SELECT ${projection.join(',')}${exec ? '' : ` FROM ${quote(table.name)}`}`;
|
|
235
|
+
const sizes = `SELECT ${sum(body)} AS payload,${sum(header)} AS header FROM (${source})`;
|
|
236
|
+
const measured = `SELECT payload+header+CASE WHEN header<127 THEN 1 ELSE 2 END AS measured FROM (${sizes})`;
|
|
237
|
+
if (!exec) {
|
|
238
|
+
const check = `SELECT measured FROM (${measured}) WHERE measured>${d1NativeLimits.length} LIMIT 1`;
|
|
239
|
+
const bytes = sql => new TextEncoder().encode(sql).length;
|
|
240
|
+
if (bytes(check) <= d1NativeLimits.sqlLength) {
|
|
241
|
+
const oversized = prepare(check).get();
|
|
242
|
+
if (oversized) throw new Error(`D1 limit exceeded: table row bytes maximum ${d1NativeLimits.length}, measured ${oversized.measured}`);
|
|
243
|
+
} else {
|
|
244
|
+
// Scan the same physical table order for each column chunk. NOT
|
|
245
|
+
// INDEXED prevents a projection-dependent covering-index choice;
|
|
246
|
+
// WITHOUT ROWID tables retain their primary-key storage order.
|
|
247
|
+
// Only numeric partial sizes leave SQLite, never cell contents.
|
|
248
|
+
const partial = (start, end) => `SELECT ${sum(body.slice(start,end))} AS payload,${sum(header.slice(start,end))} AS header FROM (SELECT ${projection.slice(start,end).join(',')} FROM ${quote(table.name)} NOT INDEXED)`;
|
|
249
|
+
const totals = [];
|
|
250
|
+
for (let start = 0; start < columns.length;) {
|
|
251
|
+
let end = start + 1;
|
|
252
|
+
while (end < columns.length && bytes(partial(start,end+1)) <= d1NativeLimits.sqlLength) end++;
|
|
253
|
+
const sql = partial(start,end);
|
|
254
|
+
d1Preflight(sql);
|
|
255
|
+
const rows = prepare(sql).all();
|
|
256
|
+
for (const [index,row] of rows.entries()) {
|
|
257
|
+
const total = totals[index] ??= { payload:0, header:0 };
|
|
258
|
+
total.payload += row.payload; total.header += row.header;
|
|
259
|
+
}
|
|
260
|
+
start = end;
|
|
261
|
+
}
|
|
262
|
+
for (const {payload,header} of totals) {
|
|
263
|
+
const size = payload + header + (header < 127 ? 1 : 2);
|
|
264
|
+
if (size > d1NativeLimits.length) throw new Error(`D1 limit exceeded: table row bytes maximum ${d1NativeLimits.length}, measured ${size}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
for (const action of ['INSERT', 'UPDATE']) {
|
|
270
|
+
const rawName = `rer_d1_row_${action}_${table.name}`;
|
|
271
|
+
names.push(rawName);
|
|
272
|
+
const name = quote(rawName);
|
|
273
|
+
exec(`DROP TRIGGER IF EXISTS temp.${name}`);
|
|
274
|
+
exec(`CREATE TEMP TRIGGER ${name} BEFORE ${action} ON main.${quote(table.name)} BEGIN SELECT CASE WHEN measured>${d1NativeLimits.length} THEN RAISE(ABORT,'D1 limit exceeded: table row bytes maximum ${d1NativeLimits.length}, measured '||measured) END FROM (${measured}); END`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (exec) state.set(db, {version,names});
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export const guardD1Rows = createD1RowGuard();
|
|
282
|
+
|
|
283
|
+
/** Driver-supplied schema access keeps ALTER admission before execution. */
|
|
284
|
+
export function d1ColumnCount(table, rows, pragma = 'table_info') {
|
|
285
|
+
return rows(`PRAGMA ${pragma}("${table.replaceAll('"', '""')}")`).length || undefined;
|
|
286
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { DatabaseSync as NativeDatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { d1Preflight, d1NativeLimits, d1ResultPreflight, guardD1Rows, d1ColumnCount } from './d1-limits.mjs';
|
|
3
|
+
|
|
4
|
+
// Ignore quoted strings and identifiers and SQL comments when deciding whether
|
|
5
|
+
// application SQL can invalidate the harness's temporary row triggers.
|
|
6
|
+
const schemaEdit = sql => /\bALTER\s+TABLE\b/i.test(sql.replace(/--[^\n]*|\/\*[\s\S]*?\*\/|'(?:''|[^'])*'|"(?:""|[^"])*"|`(?:``|[^`])*`|\[[^\]]*\]/g, ' '));
|
|
7
|
+
|
|
8
|
+
/** A local D1 stand-in, not a replacement for independent SQLite storage.
|
|
9
|
+
* Native options are passed on every open, including reopen and read-only
|
|
10
|
+
* proof connections. Node 22 enforces through the shared preflight instead.
|
|
11
|
+
*/
|
|
12
|
+
export class DatabaseSync extends NativeDatabaseSync {
|
|
13
|
+
constructor(path, options = {}) {
|
|
14
|
+
super(path, { ...options, limits: d1NativeLimits });
|
|
15
|
+
// SQL can derive a pattern from a column or another function. Check its
|
|
16
|
+
// evaluated bytes before SQLite compiles the pattern, then delegate to
|
|
17
|
+
// SQLite's own matching semantics on an isolated native connection.
|
|
18
|
+
this.patterns = new NativeDatabaseSync(':memory:', { limits: d1NativeLimits });
|
|
19
|
+
for (const name of ['like', 'glob']) {
|
|
20
|
+
const statements = new Map();
|
|
21
|
+
this.function(name, { varargs: true, deterministic: true, useBigIntArguments: true }, (...args) => {
|
|
22
|
+
const sql = `SELECT ${name}(${args.map(() => '?').join(',')}) AS value`;
|
|
23
|
+
d1Preflight(sql, args);
|
|
24
|
+
if (!statements.has(args.length)) statements.set(args.length, this.patterns.prepare(sql));
|
|
25
|
+
return statements.get(args.length).get(...args).value;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
close() { try { return super.close(); } finally { this.patterns.close(); } }
|
|
30
|
+
preflight(sql, args = []) { d1Preflight(sql, args, table => d1ColumnCount(table, text => NativeDatabaseSync.prototype.prepare.call(this, text).all(), 'table_xinfo')); }
|
|
31
|
+
guard(changingSchema = false) { guardD1Rows(this, sql => super.prepare(sql), sql => super.exec(sql), undefined, changingSchema); }
|
|
32
|
+
exec(sql) {
|
|
33
|
+
this.preflight(sql);
|
|
34
|
+
if (!schemaEdit(sql)) {
|
|
35
|
+
this.guard();
|
|
36
|
+
try { return super.exec(sql); } finally { this.guard(); }
|
|
37
|
+
}
|
|
38
|
+
// Let SQLite identify statement boundaries, including trigger bodies.
|
|
39
|
+
// Execute transaction control in its original order, and guard each schema
|
|
40
|
+
// edit separately so an error later in exec retains earlier effects.
|
|
41
|
+
let remaining = sql;
|
|
42
|
+
while (!/^(?:\s|;|--[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)*$/.test(remaining)) {
|
|
43
|
+
this.guard(schemaEdit(remaining));
|
|
44
|
+
let text;
|
|
45
|
+
try { text = super.prepare(remaining).sourceSQL; }
|
|
46
|
+
catch (error) { this.guard(); throw error; }
|
|
47
|
+
const changingSchema = schemaEdit(text);
|
|
48
|
+
this.guard(changingSchema);
|
|
49
|
+
if (changingSchema) super.exec('SAVEPOINT rer_d1_schema');
|
|
50
|
+
try {
|
|
51
|
+
super.exec(text);
|
|
52
|
+
if (changingSchema) {
|
|
53
|
+
guardD1Rows(this, query => super.prepare(query));
|
|
54
|
+
super.exec('RELEASE rer_d1_schema');
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (changingSchema) { super.exec('ROLLBACK TO rer_d1_schema'); super.exec('RELEASE rer_d1_schema'); }
|
|
58
|
+
throw error;
|
|
59
|
+
} finally { this.guard(); }
|
|
60
|
+
remaining = remaining.slice(text.length);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
prepare(sql) {
|
|
64
|
+
this.preflight(sql);
|
|
65
|
+
this.guard(schemaEdit(sql));
|
|
66
|
+
const statement = super.prepare(sql);
|
|
67
|
+
let proxy;
|
|
68
|
+
const db = this;
|
|
69
|
+
proxy = new Proxy(statement, { get(target, key) {
|
|
70
|
+
const value = Reflect.get(target, key, target);
|
|
71
|
+
if (typeof value !== 'function') return value;
|
|
72
|
+
return (...args) => {
|
|
73
|
+
if (['run', 'get', 'all', 'iterate'].includes(key)) { db.guard(schemaEdit(sql)); db.preflight(sql, args); }
|
|
74
|
+
const checked = ['get', 'all'].includes(key) && /^\s*(?:SELECT|WITH|INSERT|UPDATE|DELETE|REPLACE)\b/i.test(sql);
|
|
75
|
+
const exec = sql => NativeDatabaseSync.prototype.exec.call(db, sql);
|
|
76
|
+
if (checked) exec('SAVEPOINT rer_d1_result');
|
|
77
|
+
try {
|
|
78
|
+
const result = value.apply(target, args);
|
|
79
|
+
if (key === 'iterate') return (function* () {
|
|
80
|
+
// SQLite steps lazily, after the outer call restores its guards.
|
|
81
|
+
db.guard(schemaEdit(sql));
|
|
82
|
+
try { for (const row of result) { d1ResultPreflight([row]); yield row; } }
|
|
83
|
+
finally { db.guard(); }
|
|
84
|
+
})();
|
|
85
|
+
if (checked) { d1ResultPreflight(key === 'get' ? result ? [result] : [] : result); exec('RELEASE rer_d1_result'); }
|
|
86
|
+
return result === target ? proxy : result;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (checked) { exec('ROLLBACK TO rer_d1_result'); exec('RELEASE rer_d1_result'); }
|
|
89
|
+
throw error;
|
|
90
|
+
} finally { db.guard(); }
|
|
91
|
+
};
|
|
92
|
+
} });
|
|
93
|
+
return proxy;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Module from 'node:module';
|
|
2
|
+
import { installD1Preflight } from './d1-workerd-setup.mjs';
|
|
3
|
+
|
|
4
|
+
// Test journeys launch Wrangler in child processes, often before dependencies
|
|
5
|
+
// exist. Hook its eventual CommonJS load instead of resolving a driver early.
|
|
6
|
+
// This also instruments the exact Miniflare instance chosen by Wrangler.
|
|
7
|
+
const installed = Symbol.for('rer.d1.child-preflight');
|
|
8
|
+
if (!Module[installed]) {
|
|
9
|
+
const load = Module._load;
|
|
10
|
+
Module._load = function (...args) {
|
|
11
|
+
const value = load.apply(this, args);
|
|
12
|
+
if (value && Object.hasOwn(value, 'D1_PLUGIN') && typeof value.Miniflare === 'function') installD1Preflight(value.D1_PLUGIN);
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
Module[installed] = true;
|
|
16
|
+
}
|
|
17
|
+
const option = `--import=${import.meta.url}`;
|
|
18
|
+
const options = process.env.NODE_OPTIONS ?? '';
|
|
19
|
+
if (!options.includes(option)) process.env.NODE_OPTIONS = [options, option].filter(Boolean).join(' ');
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { d1Preflight, d1ResultPreflight, d1NativeLimits, createD1RowGuard, d1ColumnCount } from './d1-limits.mjs';
|
|
2
|
+
// Instrument the pinned local D1 storage service, rather than only the Node
|
|
3
|
+
// binding: SQL issued inside a Worker must pass the same preflight. Leave the
|
|
4
|
+
// workerd SQLite engine intact, including its independent native limits.
|
|
5
|
+
const installed = Symbol.for('rer.d1.preflight');
|
|
6
|
+
export function installD1Preflight(plugin) {
|
|
7
|
+
if (plugin[installed]) return;
|
|
8
|
+
const getServices = plugin.getServices;
|
|
9
|
+
plugin.getServices = async function (...args) {
|
|
10
|
+
const services = await getServices.apply(this, args);
|
|
11
|
+
for (const service of services) {
|
|
12
|
+
if (service.name !== 'd1:db') continue;
|
|
13
|
+
const module = service.worker.modules.find(module => module.name === 'database.worker.js');
|
|
14
|
+
const marker = '#query = (format, query) => {';
|
|
15
|
+
if (!module?.esModule?.includes(marker)) throw new Error('D1 preflight: pinned workerd query entry changed');
|
|
16
|
+
const after = 'let afterTime = performance.now()';
|
|
17
|
+
if (!module.esModule.includes(after)) throw new Error('D1 preflight: pinned workerd transaction entry changed');
|
|
18
|
+
module.esModule = `const d1NativeLimits = ${JSON.stringify(d1NativeLimits)};\n${d1Preflight.toString()}\n${d1ResultPreflight.toString()}\n${d1ColumnCount.toString()}\nconst guardD1Rows = (${createD1RowGuard.toString()})();\n`
|
|
19
|
+
+ module.esModule.replace(marker, `${marker}\n d1Preflight(query.sql, query.params ?? [], table => d1ColumnCount(table, sql => Array.from(this.db.prepare(sql)())));`)
|
|
20
|
+
.replace(after, `d1ResultPreflight(rows);\n if (this.#changes().totalChanges !== beforeChanges.totalChanges) guardD1Rows(this.db, sql => ({ get: () => { try { return Array.from(this.db.prepare(sql)())[0]; } catch (error) { throw new Error('D1 row preflight query ' + sql.slice(0,100) + ': ' + error.message); } }, all: () => { try { return Array.from(this.db.prepare(sql)()); } catch (error) { throw new Error('D1 row preflight query ' + sql.slice(0,100) + ': ' + error.message); } } }), undefined, query.sql);\n ${after}`);
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
return services;
|
|
24
|
+
};
|
|
25
|
+
plugin[installed] = true;
|
|
26
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { DatabaseSync } from '
|
|
1
|
+
import { DatabaseSync } from './d1-sqlite.mjs';
|
|
2
2
|
import { parentPort, workerData } from 'node:worker_threads';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
|
+
import { d1Preflight, d1NativeLimits } from './d1-limits.mjs';
|
|
4
5
|
import { sqliteError } from './sqlite-error.mjs';
|
|
5
|
-
const db = new DatabaseSync(workerData.path, { limits:
|
|
6
|
+
const db = new DatabaseSync(workerData.path, { limits:d1NativeLimits,enableDoubleQuotedStringLiterals:true });
|
|
6
7
|
db.exec('PRAGMA journal_mode=WAL; PRAGMA foreign_keys=ON; PRAGMA busy_timeout=30000;');
|
|
7
8
|
function execute({sql,args=[]}) {
|
|
9
|
+
d1Preflight(sql,args);
|
|
8
10
|
const started=performance.now(), statement=db.prepare(sql), columns=statement.columns();statement.setReturnArrays(true);
|
|
9
11
|
const before=db.prepare('SELECT total_changes() AS n').get().n;
|
|
10
12
|
const rawResults=columns.length ? statement.all(...args).map(row=>row.map(value=>ArrayBuffer.isView(value)?[...value]:value)) : (statement.run(...args),[]);
|
|
@@ -19,7 +21,7 @@ parentPort.on('message',({id,operation,statements,sql})=>{
|
|
|
19
21
|
let result;
|
|
20
22
|
if(operation==='batch') {
|
|
21
23
|
db.exec('BEGIN');try{result=statements.map(execute);db.exec('COMMIT');}catch(cause){db.exec('ROLLBACK');throw cause;}
|
|
22
|
-
} else if(operation==='exec') {const start=performance.now();db.exec(sql);result={count:sql.split('\n').filter(line=>line.trim()).length,duration:performance.now()-start};}
|
|
24
|
+
} else if(operation==='exec') {const start=performance.now();d1Preflight(sql);db.exec(sql);result={count:sql.split('\n').filter(line=>line.trim()).length,duration:performance.now()-start};}
|
|
23
25
|
else result=execute(statements[0]);
|
|
24
26
|
parentPort.postMessage({id,result});
|
|
25
27
|
}catch(cause){parentPort.postMessage({id,error:sqliteError(cause)});}
|
|
@@ -81,6 +81,7 @@ async function buildImage(root, { output = join(root,'.rer/container/image'), en
|
|
|
81
81
|
await readFile(join(root,entry));
|
|
82
82
|
if (engine === 'node' && workerConfig.kv_namespaces?.length) throw new Error('Node container does not support KV');
|
|
83
83
|
await checkImageVariables(root,workerConfig.vars ?? {},declaration.secrets ?? []);
|
|
84
|
+
if (engine === 'workerd') await writeFile(join(root,'dist/server/wrangler.json'),JSON.stringify(workerConfig)+'\n');
|
|
84
85
|
const manifest = { version:1,engine,entry,cacheContract,runner,config:workerConfig,migrations,portabilityMigrations:await portabilityPlan(split),maxRequestBytes:25*1024*1024 };
|
|
85
86
|
await rm(output,{recursive:true,force:true}); await mkdir(join(output,'app'),{recursive:true});
|
|
86
87
|
await cp(join(root,'dist'),join(output,'app/dist'),{recursive:true}); await writeFile(join(output,'app/container.json'),JSON.stringify(manifest,null,2)+'\n');
|
|
@@ -3,10 +3,14 @@ import {deliveryDeclarationSources} from '../../cli/delivery-declarations.mjs';
|
|
|
3
3
|
import {sourcePath} from '../delivery-producer/migrations.mjs';
|
|
4
4
|
import {usesManagedMail,validateMailSpec} from '../delivery-producer/mail.mjs';
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/** Drop empty runtime-secret placeholders; admit only managed-mail public legacy values. */
|
|
7
7
|
export async function checkImageVariables(root,vars,secrets) {
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const placeholders=secrets.filter(secret=>Object.hasOwn(vars,secret.binding) && vars[secret.binding] === '');
|
|
9
|
+
const overlaps=secrets.filter(secret=>Object.hasOwn(vars,secret.binding) && vars[secret.binding] !== '');
|
|
10
|
+
if (!overlaps.length) {
|
|
11
|
+
for (const {binding} of placeholders) delete vars[binding];
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
10
14
|
const publicMail=new Set(),privateNames=new Set();
|
|
11
15
|
for (const [candidate,select] of deliveryDeclarationSources) {
|
|
12
16
|
const path=await sourcePath(root,candidate,{optional:true});
|
|
@@ -23,5 +27,6 @@ export async function checkImageVariables(root,vars,secrets) {
|
|
|
23
27
|
for (const {binding} of overlaps) if (!publicMail.has(binding) || privateNames.has(binding)) {
|
|
24
28
|
throw new Error('Secret declared as an image variable: '+binding);
|
|
25
29
|
}
|
|
30
|
+
for (const {binding} of placeholders) delete vars[binding];
|
|
26
31
|
console.warn(overlaps.map(secret=>secret.binding).join(', ')+' are public mail configuration, not secrets. Remove these bindings from deploy.json secrets; keep them in the mail spec public variables and Wrangler vars. Accepting the legacy declaration; runtime demo settings override the image defaults.');
|
|
27
32
|
}
|
|
@@ -6,21 +6,31 @@ import { ensurePortabilitySchema } from './portability-schema.mjs';
|
|
|
6
6
|
import { migrate } from './migrations.mjs';
|
|
7
7
|
import { createPortability } from '../portability/index.mjs';
|
|
8
8
|
import { migrationReplay } from '../portability/migration-history.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import { requireProductEmpty } from '../portability/legacy-safety.mjs';
|
|
10
|
+
import { destinationLedger } from '../portability/ledgers.mjs';
|
|
11
|
+
import { exportArchive, importArchive, fileRecords } from '../portability/files.mjs';
|
|
10
12
|
let db,platform,worker;
|
|
11
13
|
try {
|
|
12
14
|
const spec=JSON.parse(await readFile('/private/transfer.json','utf8')),manifest=JSON.parse(await readFile('/app/container.json','utf8'));
|
|
15
|
+
let unverified=false;
|
|
16
|
+
if(spec.direction==='import' && spec.acknowledgeUnverifiedSchemaObjects===true)for await(const record of fileRecords('/archive/'+spec.file))if(record.kind==='manifest')unverified=record.schemaObjects===undefined;
|
|
17
|
+
const preflight=async database=>{
|
|
18
|
+
if(!unverified)return;
|
|
19
|
+
const names=(await destinationLedger(database)??[]).map(m=>m.name);
|
|
20
|
+
await requireProductEmpty({db:database,policy:spec.policy,migrations:async()=>migrationReplay(manifest.migrations[spec.binding].filter(m=>names.includes(m.name)),spec.policy)});
|
|
21
|
+
};
|
|
13
22
|
const buckets={};
|
|
14
23
|
if(manifest.engine==='node'){
|
|
15
|
-
db=new D1('/data/'+spec.binding+'.sqlite');await migrate(db,manifest.migrations[spec.binding]);await ensurePortabilitySchema(db,manifest.portabilityMigrations);
|
|
24
|
+
db=new D1('/data/'+spec.binding+'.sqlite');await preflight(db);await migrate(db,manifest.migrations[spec.binding]);await ensurePortabilitySchema(db,manifest.portabilityMigrations);
|
|
16
25
|
platform=new DatabaseSync('/data/platform.sqlite');
|
|
17
26
|
for(const [name,binding]of Object.entries(spec.buckets))buckets[name]=new Objects(platform,'/data/objects',binding);
|
|
18
27
|
}else{
|
|
19
|
-
const {workerEngine}=await import('./worker-engine.mjs');worker=await workerEngine({root:'/app',data:'/data',manifest,settings:{}});db=worker.databases[spec.binding];
|
|
28
|
+
const {workerEngine}=await import('./worker-engine.mjs');worker=await workerEngine({root:'/app',data:'/data',manifest,settings:{},applyMigrations:!unverified});db=worker.databases[spec.binding];
|
|
29
|
+
if(unverified){await preflight(db);for(const [binding,plan] of Object.entries(manifest.migrations)){await migrate(worker.databases[binding],plan);await ensurePortabilitySchema(worker.databases[binding],manifest.portabilityMigrations);}}
|
|
20
30
|
for(const [name,binding]of Object.entries(spec.buckets))buckets[name]=worker.objects[binding];
|
|
21
31
|
}
|
|
22
32
|
const service=await createPortability({db,buckets,policy:spec.policy,migrations:async()=>migrationReplay(manifest.migrations[spec.binding],spec.policy)});
|
|
23
|
-
const receipt=await(spec.direction==='export'?exportArchive:importArchive
|
|
33
|
+
const receipt=await(spec.direction==='export'?exportArchive(service,'/archive/'+spec.file,spec.transient):importArchive(service,'/archive/'+spec.file,spec.transient,spec.journal,undefined,{acknowledgeUnverifiedSchemaObjects:spec.acknowledgeUnverifiedSchemaObjects}));
|
|
24
34
|
console.log(JSON.stringify(receipt));
|
|
25
35
|
}catch(cause){console.error('Container transfer refused or failed:',cause.name);process.exitCode=1;}
|
|
26
36
|
finally{await worker?.close();await db?.close?.();platform?.close();}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Miniflare, convertV4MiniflareOptions, coupleWebSocket } from '
|
|
1
|
+
import { Miniflare, convertV4MiniflareOptions, coupleWebSocket } from './adapters/d1-workerd.mjs';
|
|
2
2
|
import { readdir } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { rootCertificates } from 'node:tls';
|
|
5
5
|
import { ensurePortabilitySchema } from './portability-schema.mjs';
|
|
6
6
|
import { migrate } from './migrations.mjs';
|
|
7
7
|
async function files(root) { const result = []; for (const item of await readdir(root, { withFileTypes: true })) { const path = join(root, item.name); if (item.isDirectory()) result.push(...await files(path)); else if (/\.(m?js)$/.test(item.name)) result.push(path); } return result; }
|
|
8
|
-
export async function workerEngine({ root, data, manifest, settings, edge }) {
|
|
8
|
+
export async function workerEngine({ root, data, manifest, settings, edge, applyMigrations=true }) {
|
|
9
9
|
const config = manifest.config, directory = join(root, 'dist/server'), entry = join(root, manifest.entry);
|
|
10
10
|
const modules = [entry, ...(await files(directory)).filter(path => path !== entry)].map(path => ({ type: 'ESModule', path }));
|
|
11
11
|
const app = { name:'app', modules, modulesRoot:directory, compatibilityDate:config.compatibility_date, compatibilityFlags:config.compatibility_flags,
|
|
@@ -23,7 +23,7 @@ export async function workerEngine({ root, data, manifest, settings, edge }) {
|
|
|
23
23
|
serviceBindings:{ NETWORK:{ network:{ allow:['public'],tlsOptions:{ trustBrowserCas:true,trustedCertificates:[...rootCertificates] } } } } }],
|
|
24
24
|
}));
|
|
25
25
|
await mf.ready; const databases = {}, objects = {};
|
|
26
|
-
for (const [binding, plan] of Object.entries(manifest.migrations)) { const db = await mf.getD1Database(binding, 'app'); databases[binding] = db; await migrate(db, plan); await ensurePortabilitySchema(db, manifest.portabilityMigrations); }
|
|
26
|
+
for (const [binding, plan] of Object.entries(manifest.migrations)) { const db = await mf.getD1Database(binding, 'app'); databases[binding] = db; if(applyMigrations){await migrate(db, plan); await ensurePortabilitySchema(db, manifest.portabilityMigrations);} }
|
|
27
27
|
for (const bucket of config.r2_buckets ?? []) objects[bucket.binding] = await mf.getR2Bucket(bucket.binding, 'app');
|
|
28
28
|
const worker = await mf.getWorker('app');
|
|
29
29
|
return { mf, databases, objects, app:worker, coupleWebSocket,
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { containedInput } from './input-path.mjs';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
4
3
|
|
|
5
4
|
export async function demoRunDeclaration(declaration, { root, adapter, read } = {}) {
|
|
6
5
|
if (declaration.runUrl !== undefined) return declaration;
|
|
7
6
|
read ??= async path => JSON.parse(await readFile(await containedInput(root, path), 'utf8'));
|
|
8
7
|
let bare = false;
|
|
9
8
|
if (adapter === undefined) {
|
|
10
|
-
|
|
11
|
-
try { operations = await read('OPERATIONS.json'); }
|
|
9
|
+
try { await read('OPERATIONS.json'); }
|
|
12
10
|
catch (error) { if (error.code !== 'ENOENT') throw error; bare = true; }
|
|
13
|
-
if (operations?.seedContract) adapter = (await import(pathToFileURL(await containedInput(root, operations.seedContract.adapter)).href)).commandAdapter;
|
|
14
11
|
}
|
|
15
12
|
const path = adapter?.site?.declaration ?? (bare ? 'deploy-site.json' : undefined);
|
|
16
13
|
if (!path) return declaration;
|
package/modules/demo/vite.mjs
CHANGED
|
@@ -21,7 +21,7 @@ export function demoSockets() {
|
|
|
21
21
|
if (error.code !== 'ENOENT') throw error;
|
|
22
22
|
if (on()) throw new Error('rer demo needs deploy-demo.json with the product name and canonical run-site domain. See DEMO.md.');
|
|
23
23
|
}
|
|
24
|
-
const resolved = declaration && await demoRunDeclaration(declaration, { root: config.root ?? process.cwd() });
|
|
24
|
+
const resolved = declaration && await demoRunDeclaration(process.env.RER_DEMO_RUN_URL === undefined ? declaration : {...declaration, runUrl: process.env.RER_DEMO_RUN_URL}, { root: config.root ?? process.cwd() });
|
|
25
25
|
return {
|
|
26
26
|
define: { 'import.meta.rerDemo': JSON.stringify(resolved ? { name: resolved.name, url: demoRunUrl(resolved.runUrl === undefined ? `https://${resolved.domain}/run` : resolved.runUrl) } : null) },
|
|
27
27
|
...(on() && command === 'serve' ? { resolve: { alias: [{ find: /^cloudflare:sockets$/, replacement: 'cloudflare:sockets' }] } } : {}),
|
|
@@ -33,6 +33,7 @@ export async function buildDemo(root, output, declaration) {
|
|
|
33
33
|
for (const binding of bindings.objects) if (!entryExports.get(entry)?.has(binding.class_name)) throw new Error(`Loader demo cannot bind ${binding.name}: missing Durable Object export ${binding.class_name}`);
|
|
34
34
|
if (!emitted.has(entry)) throw new Error('Demo Worker entry was not emitted by this build');
|
|
35
35
|
await checkBuildVariables(root, workerConfig.vars ?? {}, declaration.secrets ?? []);
|
|
36
|
+
await writeFile(join(root, 'dist/server/wrangler.json'), JSON.stringify(workerConfig) + '\n');
|
|
36
37
|
const { unstable_splitSqlQuery: split } = require('wrangler');
|
|
37
38
|
const migrations = Object.fromEntries((workerConfig.d1_databases ?? []).map(db => [db.binding, []]));
|
|
38
39
|
const inventory = withRewrites(await demoMigrationInventory(root, { config: workerConfig, configFile: 'dist/server/wrangler.json' }), await readMigrationRewrites(root));
|
|
@@ -31,7 +31,8 @@ export async function prepareNative(folder) {
|
|
|
31
31
|
const entry = `../app/${main}`;
|
|
32
32
|
modules['_rer/isolate.js'] = { js: (await readFile(new URL('./isolate.mjs', import.meta.url), 'utf8')).replace('__RER_APP_ENTRY__', entry)
|
|
33
33
|
+ objectExports(bindings) };
|
|
34
|
-
for (const file of ISOLATE_FILES) modules[`_rer/${file}.js`] = { js: await readFile(new URL(`./${file}.mjs`, import.meta.url), 'utf8') };
|
|
34
|
+
for (const file of ISOLATE_FILES) modules[`_rer/${file}.js`] = { js: (await readFile(new URL(`./${file}.mjs`, import.meta.url), 'utf8')).replace('../../container/adapters/d1-limits.mjs', './d1-limits.js') };
|
|
35
|
+
modules['_rer/d1-limits.js'] = { js: await readFile(new URL('../../container/adapters/d1-limits.mjs', import.meta.url), 'utf8') };
|
|
35
36
|
const assets = await collectFiles(join(app, 'dist/client'));
|
|
36
37
|
await cp(join(app, 'dist/client'), join(folder, 'assets'), { recursive: true });
|
|
37
38
|
const theme = await prepareTheme(folder, assets);
|