@astrale-os/adapter-cloudflare 0.5.0-beta.19 → 0.5.0-beta.191
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 +241 -2
- package/dist/adapter.d.ts +8 -17
- package/dist/adapter.js +41 -310
- package/dist/build/bundle/admit.d.ts +3 -0
- package/dist/build/bundle/admit.js +46 -0
- package/dist/build/bundle/compiled-wasm-loader.d.ts +8 -0
- package/dist/build/bundle/compiled-wasm-loader.js +21 -0
- package/dist/build/bundler.d.ts +21 -0
- package/dist/build/bundler.js +96 -0
- package/dist/build/closure.d.ts +4 -2
- package/dist/build/closure.js +7 -2
- package/dist/build/codegen/execution.d.ts +3 -14
- package/dist/build/codegen/execution.js +2 -41
- package/dist/build/codegen/merge.d.ts +0 -1
- package/dist/build/codegen/merge.js +0 -1
- package/dist/build/codegen/wrangler.d.ts +30 -6
- package/dist/build/codegen/wrangler.js +76 -20
- package/dist/build/configuration/invocation-timeout.d.ts +2 -0
- package/dist/build/configuration/invocation-timeout.js +9 -0
- package/dist/build/configuration/request-limit.d.ts +2 -0
- package/dist/build/configuration/request-limit.js +9 -0
- package/dist/build/configuration/router.d.ts +7 -0
- package/dist/build/configuration/router.js +17 -0
- package/dist/build/configuration/settings.d.ts +6 -0
- package/dist/build/configuration/settings.js +40 -0
- package/dist/build/configuration.d.ts +4 -9
- package/dist/build/configuration.js +4 -26
- package/dist/build/frontend/files.d.ts +19 -0
- package/dist/build/frontend/files.js +99 -0
- package/dist/build/frontend/readiness.d.ts +16 -0
- package/dist/build/frontend/readiness.js +21 -0
- package/dist/build/frontend/revision.d.ts +5 -0
- package/dist/build/frontend/revision.js +14 -0
- package/dist/build/frontend/vite.d.ts +14 -0
- package/dist/build/frontend/vite.js +42 -0
- package/dist/build/frontend/vite.process.d.ts +7 -0
- package/dist/build/frontend/vite.process.js +65 -0
- package/dist/build/frontend/vite.runner.d.ts +1 -0
- package/dist/build/frontend/vite.runner.js +155 -0
- package/dist/build/index.d.ts +10 -5
- package/dist/build/index.js +10 -5
- package/dist/build/material.d.ts +10 -0
- package/dist/build/material.js +25 -0
- package/dist/build/metafile.d.ts +0 -1
- package/dist/build/metafile.js +0 -1
- package/dist/build/qualification.d.ts +0 -1
- package/dist/build/qualification.js +0 -1
- package/dist/build/roots.d.ts +0 -1
- package/dist/build/roots.js +0 -1
- package/dist/build/worker/codegen/entry.d.ts +9 -0
- package/dist/build/worker/codegen/entry.js +65 -0
- package/dist/build/worker/codegen/literal.d.ts +28 -0
- package/dist/build/worker/codegen/literal.js +136 -0
- package/dist/build/worker/codegen/service.d.ts +14 -0
- package/dist/build/worker/codegen/service.js +57 -0
- package/dist/build/worker/execution.prepare.d.ts +20 -0
- package/dist/build/worker/execution.prepare.js +128 -0
- package/dist/build/worker/media-type.d.ts +1 -0
- package/dist/build/worker/media-type.js +20 -0
- package/dist/build/worker/modules.d.ts +20 -0
- package/dist/build/worker/modules.js +32 -0
- package/dist/build/worker/specifier.d.ts +5 -0
- package/dist/build/worker/specifier.js +15 -0
- package/dist/build/worker/upload.d.ts +23 -0
- package/dist/build/worker/upload.js +42 -0
- package/dist/cloudflare.d.ts +1 -2
- package/dist/cloudflare.js +1 -2
- package/dist/hosting/activation.d.ts +38 -0
- package/dist/hosting/activation.js +109 -0
- package/dist/hosting/assets.d.ts +14 -0
- package/dist/hosting/assets.js +53 -0
- package/dist/hosting/bounded.d.ts +10 -0
- package/dist/hosting/bounded.js +32 -0
- package/dist/hosting/bytes.d.ts +6 -0
- package/dist/hosting/bytes.js +25 -0
- package/dist/hosting/client.d.ts +144 -0
- package/dist/hosting/client.js +491 -0
- package/dist/hosting/dispatcher/cron.d.mts +10 -0
- package/dist/hosting/dispatcher/cron.mjs +135 -0
- package/dist/hosting/dispatcher/deployments.d.mts +26 -0
- package/dist/hosting/dispatcher/deployments.mjs +158 -0
- package/dist/hosting/dispatcher/dispatcher.d.mts +17 -0
- package/dist/hosting/dispatcher/dispatcher.mjs +76 -0
- package/dist/hosting/dispatcher/env.d.mts +51 -0
- package/dist/hosting/dispatcher/failure.d.mts +4 -0
- package/dist/hosting/dispatcher/failure.mjs +15 -0
- package/dist/hosting/dispatcher/index.d.mts +4 -0
- package/dist/hosting/dispatcher/index.mjs +8 -0
- package/dist/hosting/dispatcher/modules.d.ts +24 -0
- package/dist/hosting/dispatcher/modules.js +55 -0
- package/dist/hosting/dispatcher/services.d.mts +23 -0
- package/dist/hosting/dispatcher/services.mjs +202 -0
- package/dist/hosting/identity.d.ts +15 -0
- package/dist/hosting/identity.js +36 -0
- package/dist/hosting/index.d.ts +34 -0
- package/dist/hosting/index.js +32 -0
- package/dist/hosting/kv.d.ts +90 -0
- package/dist/hosting/kv.js +207 -0
- package/dist/hosting/listing.d.ts +34 -0
- package/dist/hosting/listing.js +50 -0
- package/dist/hosting/names.d.ts +16 -0
- package/dist/hosting/names.js +28 -0
- package/dist/hosting/provision/account.d.ts +11 -0
- package/dist/hosting/provision/account.js +86 -0
- package/dist/hosting/provision/dispatcher.d.ts +42 -0
- package/dist/hosting/provision/dispatcher.js +99 -0
- package/dist/hosting/provision/ingress.d.ts +12 -0
- package/dist/hosting/provision/ingress.js +31 -0
- package/dist/hosting/provision/plan.d.ts +143 -0
- package/dist/hosting/provision/plan.js +246 -0
- package/dist/hosting/provision/routing.d.ts +82 -0
- package/dist/hosting/provision/routing.js +226 -0
- package/dist/hosting/readiness.d.ts +53 -0
- package/dist/hosting/readiness.js +82 -0
- package/dist/hosting/refusal.d.ts +28 -0
- package/dist/hosting/refusal.js +13 -0
- package/dist/hosting/retirement.d.ts +70 -0
- package/dist/hosting/retirement.js +107 -0
- package/dist/hosting/retry-after.d.ts +6 -0
- package/dist/hosting/retry-after.js +55 -0
- package/dist/hosting/script.d.ts +186 -0
- package/dist/hosting/script.js +324 -0
- package/dist/hosting/testing/fake-cloudflare.d.ts +212 -0
- package/dist/hosting/testing/fake-cloudflare.js +757 -0
- package/dist/hosting/testing/index.d.ts +6 -0
- package/dist/hosting/testing/index.js +6 -0
- package/dist/hosting/time.d.ts +4 -0
- package/dist/hosting/time.js +20 -0
- package/dist/identity/binding.d.ts +2 -0
- package/dist/identity/binding.js +2 -0
- package/dist/identity/material.d.ts +6 -0
- package/dist/identity/material.js +29 -0
- package/dist/index.d.ts +14 -13
- package/dist/index.js +13 -12
- package/dist/namespace/configure.d.ts +22 -0
- package/dist/namespace/configure.js +199 -0
- package/dist/namespace/coordinates.d.ts +15 -0
- package/dist/namespace/coordinates.js +49 -0
- package/dist/namespace/deploy-release.d.ts +53 -0
- package/dist/namespace/deploy-release.js +389 -0
- package/dist/namespace/hosting.d.ts +29 -0
- package/dist/namespace/hosting.js +120 -0
- package/dist/namespace/index.d.ts +12 -0
- package/dist/namespace/index.js +12 -0
- package/dist/namespace/list.d.ts +18 -0
- package/dist/namespace/list.js +63 -0
- package/dist/namespace/readiness.d.ts +30 -0
- package/dist/namespace/readiness.js +31 -0
- package/dist/namespace/record.d.ts +21 -0
- package/dist/namespace/record.js +53 -0
- package/dist/params.d.ts +59 -66
- package/dist/params.js +0 -1
- package/dist/release/build.d.ts +35 -0
- package/dist/release/build.js +44 -0
- package/dist/release/deployment.d.ts +44 -0
- package/dist/release/deployment.js +141 -0
- package/dist/release/index.d.ts +2 -0
- package/dist/release/index.js +2 -0
- package/dist/worker/build-digest.d.ts +10 -0
- package/dist/worker/build-digest.js +22 -0
- package/dist/worker/cache.d.ts +28 -0
- package/dist/worker/cache.js +70 -0
- package/dist/worker/durable.d.ts +3 -0
- package/dist/worker/durable.js +5 -0
- package/dist/worker/entry.d.ts +38 -25
- package/dist/worker/entry.js +82 -110
- package/dist/worker/fetch.d.ts +0 -1
- package/dist/worker/fetch.js +0 -1
- package/dist/worker/front.d.ts +56 -0
- package/dist/worker/front.js +59 -0
- package/dist/worker/frontend.d.ts +4 -0
- package/dist/worker/frontend.js +83 -0
- package/dist/worker/identity.d.ts +7 -0
- package/dist/worker/identity.js +23 -0
- package/dist/worker/index.d.ts +5 -1
- package/dist/worker/index.js +5 -1
- package/dist/worker/restate.d.ts +6 -0
- package/dist/worker/restate.js +6 -0
- package/dist/worker/settings.d.ts +47 -0
- package/dist/worker/settings.js +161 -0
- package/dist/wrangler/bundle.d.ts +10 -0
- package/dist/wrangler/bundle.js +27 -0
- package/dist/wrangler/index.d.ts +3 -0
- package/dist/wrangler/index.js +3 -0
- package/dist/wrangler/process.d.ts +15 -0
- package/dist/wrangler/process.js +102 -0
- package/dist/wrangler/type-generation.d.ts +6 -0
- package/dist/wrangler/type-generation.js +19 -0
- package/package.json +40 -16
- package/template/astrale.config.ts +43 -31
- package/dist/adapter.d.ts.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/build/artifact.d.ts +0 -9
- package/dist/build/artifact.d.ts.map +0 -1
- package/dist/build/artifact.js +0 -145
- package/dist/build/artifact.js.map +0 -1
- package/dist/build/closure.d.ts.map +0 -1
- package/dist/build/closure.js.map +0 -1
- package/dist/build/codegen/execution.d.ts.map +0 -1
- package/dist/build/codegen/execution.js.map +0 -1
- package/dist/build/codegen/identity.d.ts +0 -10
- package/dist/build/codegen/identity.d.ts.map +0 -1
- package/dist/build/codegen/identity.js +0 -32
- package/dist/build/codegen/identity.js.map +0 -1
- package/dist/build/codegen/merge.d.ts.map +0 -1
- package/dist/build/codegen/merge.js.map +0 -1
- package/dist/build/codegen/wrangler.d.ts.map +0 -1
- package/dist/build/codegen/wrangler.js.map +0 -1
- package/dist/build/configuration.d.ts.map +0 -1
- package/dist/build/configuration.js.map +0 -1
- package/dist/build/frontend-v1.d.ts +0 -17
- package/dist/build/frontend-v1.d.ts.map +0 -1
- package/dist/build/frontend-v1.js +0 -134
- package/dist/build/frontend-v1.js.map +0 -1
- package/dist/build/index.d.ts.map +0 -1
- package/dist/build/index.js.map +0 -1
- package/dist/build/metafile.d.ts.map +0 -1
- package/dist/build/metafile.js.map +0 -1
- package/dist/build/parse-output.d.ts +0 -27
- package/dist/build/parse-output.d.ts.map +0 -1
- package/dist/build/parse-output.js +0 -58
- package/dist/build/parse-output.js.map +0 -1
- package/dist/build/qualification.d.ts.map +0 -1
- package/dist/build/qualification.js.map +0 -1
- package/dist/build/roots.d.ts.map +0 -1
- package/dist/build/roots.js.map +0 -1
- package/dist/build/wrangler-cli.d.ts +0 -115
- package/dist/build/wrangler-cli.d.ts.map +0 -1
- package/dist/build/wrangler-cli.js +0 -377
- package/dist/build/wrangler-cli.js.map +0 -1
- package/dist/cloudflare.d.ts.map +0 -1
- package/dist/cloudflare.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/params.d.ts.map +0 -1
- package/dist/params.js.map +0 -1
- package/dist/worker/entry.d.ts.map +0 -1
- package/dist/worker/entry.js.map +0 -1
- package/dist/worker/fetch.d.ts.map +0 -1
- package/dist/worker/fetch.js.map +0 -1
- package/dist/worker/index.d.ts.map +0 -1
- package/dist/worker/index.js.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as nodeModule from 'node:module';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { compiledWasmLoader, compiledWasmSource } from './compiled-wasm-loader.js';
|
|
4
|
+
let compiledWasm = false;
|
|
5
|
+
/**
|
|
6
|
+
* Import a WebAssembly module as Workers do for `CompiledWasm`: its default export is the compiled
|
|
7
|
+
* `WebAssembly.Module`, instantiated by the importing code. The CLI admits bundles under Bun; Node
|
|
8
|
+
* serves programmatic builds.
|
|
9
|
+
*/
|
|
10
|
+
function admitCompiledWasm() {
|
|
11
|
+
if (compiledWasm)
|
|
12
|
+
return;
|
|
13
|
+
if (process.versions.bun !== undefined) {
|
|
14
|
+
;
|
|
15
|
+
Reflect.get(globalThis, 'Bun').plugin({
|
|
16
|
+
name: 'astrale-compiled-wasm',
|
|
17
|
+
setup(build) {
|
|
18
|
+
build.onLoad({ filter: /\.wasm$/ }, ({ path }) => ({
|
|
19
|
+
loader: 'js',
|
|
20
|
+
contents: compiledWasmSource(JSON.stringify(path)),
|
|
21
|
+
}));
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
compiledWasm = true;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
nodeModule.register(compiledWasmLoader);
|
|
28
|
+
compiledWasm = true;
|
|
29
|
+
}
|
|
30
|
+
export async function admitWorkerBundle(path) {
|
|
31
|
+
admitCompiledWasm();
|
|
32
|
+
const loaded = (await import(`${pathToFileURL(path).href}?admit=${Date.now()}`));
|
|
33
|
+
if (loaded.default === null ||
|
|
34
|
+
typeof loaded.default !== 'object' ||
|
|
35
|
+
typeof Reflect.get(loaded.default, 'fetch') !== 'function') {
|
|
36
|
+
throw new TypeError('Generated Worker bundle does not export a Fetch handler.');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Admit the separately emitted engine's actual platform exports, including its compiled WASM. */
|
|
40
|
+
export async function admitDurableEngineBundle(path) {
|
|
41
|
+
admitCompiledWasm();
|
|
42
|
+
const engine = (await import(`${pathToFileURL(path).href}?admit=${Date.now()}`));
|
|
43
|
+
if (['createEndpointHandler', 'workflow', 'TerminalError', 'CancelledError'].some((key) => typeof engine[key] !== 'function')) {
|
|
44
|
+
throw new TypeError('Generated durable engine bundle does not export the platform Fetch entrypoint.');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Workers expose CompiledWasm imports as modules, rather than instantiated exports. */
|
|
2
|
+
export declare function compiledWasmSource(file: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Async hooks run in a separate Node thread. A self-contained ESM hook admits both emitted JS and
|
|
5
|
+
* source builds under tsx without requiring that thread to resolve or transpile our source files.
|
|
6
|
+
* The emitted import source is shared with Bun.
|
|
7
|
+
*/
|
|
8
|
+
export declare const compiledWasmLoader: string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const SOURCE_PREFIX = "import { readFileSync } from 'node:fs'\nexport default new WebAssembly.Module(readFileSync(";
|
|
2
|
+
const SOURCE_SUFFIX = '))\n';
|
|
3
|
+
/** Workers expose CompiledWasm imports as modules, rather than instantiated exports. */
|
|
4
|
+
export function compiledWasmSource(file) {
|
|
5
|
+
return `${SOURCE_PREFIX}${file}${SOURCE_SUFFIX}`;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Async hooks run in a separate Node thread. A self-contained ESM hook admits both emitted JS and
|
|
9
|
+
* source builds under tsx without requiring that thread to resolve or transpile our source files.
|
|
10
|
+
* The emitted import source is shared with Bun.
|
|
11
|
+
*/
|
|
12
|
+
export const compiledWasmLoader = `data:text/javascript,${encodeURIComponent(`
|
|
13
|
+
export function load(url, context, nextLoad) {
|
|
14
|
+
if (!url.startsWith('file:') || !url.endsWith('.wasm')) return nextLoad(url, context);
|
|
15
|
+
return {
|
|
16
|
+
format: 'module',
|
|
17
|
+
shortCircuit: true,
|
|
18
|
+
source: ${JSON.stringify(SOURCE_PREFIX)} + 'new URL(' + JSON.stringify(url) + ')' + ${JSON.stringify(SOURCE_SUFFIX)},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
`)}`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Bundle, BundleContext, Bundler } from '@astrale-os/sdk/deployment/adapter';
|
|
2
|
+
import type { frontend as frontendBuild } from '@astrale-os/sdk/deployment/build';
|
|
3
|
+
import type { ReleaseModule } from './worker/execution.prepare.js';
|
|
4
|
+
/**
|
|
5
|
+
* Environment-free bytes of one generated Worker: its entry, the modules it loads (the execution
|
|
6
|
+
* Service, the deferred workflow engine and their WASM) and its frontend.
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkerBytes {
|
|
9
|
+
readonly entry: Uint8Array;
|
|
10
|
+
readonly modules: readonly ReleaseModule[];
|
|
11
|
+
readonly frontend: readonly frontendBuild.FrontendFile[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Bundles every generated Cloudflare Worker, for adapter-cloudflare and adapter-astrale alike. It
|
|
15
|
+
* reads no Environment: settings, address, issuer and key are bound at deploy.
|
|
16
|
+
*/
|
|
17
|
+
export declare const cloudflareWorkerBundler: Bundler;
|
|
18
|
+
/** Bundle the Worker modules and build the frontend they serve, in one scratch directory. */
|
|
19
|
+
export declare function bundleWorker(context: BundleContext): Promise<WorkerBytes>;
|
|
20
|
+
/** Read back the Worker bytes of a Bundle this bundler produced for the same Build. */
|
|
21
|
+
export declare function bundledWorker(bundle: Bundle, build: Bundle['build']): WorkerBytes;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, rm } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { CLOUDFLARE_WORKER_BUNDLER, workerAssetFile } from '../release/build.js';
|
|
4
|
+
import { frontendFiles } from './frontend/files.js';
|
|
5
|
+
import { frontendRevision } from './frontend/revision.js';
|
|
6
|
+
import { prepareExecution, RELEASE_ENTRY, RELEASE_SERVICE } from './worker/execution.prepare.js';
|
|
7
|
+
/** Worker modules live beside the entry; WASM is the only non-ESM kind preparation emits. */
|
|
8
|
+
const MODULE_DIRECTORY = 'bundle/';
|
|
9
|
+
/**
|
|
10
|
+
* Bundles every generated Cloudflare Worker, for adapter-cloudflare and adapter-astrale alike. It
|
|
11
|
+
* reads no Environment: settings, address, issuer and key are bound at deploy.
|
|
12
|
+
*/
|
|
13
|
+
export const cloudflareWorkerBundler = Object.freeze({
|
|
14
|
+
id: CLOUDFLARE_WORKER_BUNDLER.id,
|
|
15
|
+
version: CLOUDFLARE_WORKER_BUNDLER.version,
|
|
16
|
+
async bundle(context) {
|
|
17
|
+
const worker = await bundleWorker(context);
|
|
18
|
+
return Object.freeze({
|
|
19
|
+
entrypoint: RELEASE_ENTRY,
|
|
20
|
+
files: Object.freeze([
|
|
21
|
+
{ path: RELEASE_ENTRY, content: worker.entry },
|
|
22
|
+
...worker.modules.map(({ path, content }) => ({ path, content })),
|
|
23
|
+
...worker.frontend.map((file) => ({
|
|
24
|
+
path: workerAssetFile(`/${file.path}`),
|
|
25
|
+
content: file.bytes(),
|
|
26
|
+
})),
|
|
27
|
+
]),
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
/** Bundle the Worker modules and build the frontend they serve, in one scratch directory. */
|
|
32
|
+
export async function bundleWorker(context) {
|
|
33
|
+
const stateDirectory = join(context.projectDir, '.astrale');
|
|
34
|
+
await mkdir(stateDirectory, { recursive: true });
|
|
35
|
+
const directory = await mkdtemp(join(stateDirectory, 'prepare-'));
|
|
36
|
+
try {
|
|
37
|
+
// `frontend` is the served file list; `addressed` rides alongside it into the Worker, where it
|
|
38
|
+
// decides which of those files a browser may retain.
|
|
39
|
+
const { files: frontend, addressed } = await frontendFiles({
|
|
40
|
+
frontend: context.build.frontend,
|
|
41
|
+
projectDir: context.projectDir,
|
|
42
|
+
output: join(directory, 'frontend'),
|
|
43
|
+
recordSource: context.recordSource,
|
|
44
|
+
signal: context.signal,
|
|
45
|
+
});
|
|
46
|
+
const modules = await prepareExecution({
|
|
47
|
+
context,
|
|
48
|
+
directory,
|
|
49
|
+
...(frontend.length === 0 ? {} : { frontendRevision: frontendRevision(frontend) }),
|
|
50
|
+
...(addressed.length === 0 ? {} : { frontendAddressed: addressed }),
|
|
51
|
+
});
|
|
52
|
+
return Object.freeze({ entry: modules.entry, modules: modules.modules, frontend });
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
await rm(directory, { recursive: true, force: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Read back the Worker bytes of a Bundle this bundler produced for the same Build. */
|
|
59
|
+
export function bundledWorker(bundle, build) {
|
|
60
|
+
const { id, version } = bundle.manifest.bundler;
|
|
61
|
+
if (bundle.build !== build ||
|
|
62
|
+
id !== CLOUDFLARE_WORKER_BUNDLER.id ||
|
|
63
|
+
version !== CLOUDFLARE_WORKER_BUNDLER.version ||
|
|
64
|
+
bundle.entrypoint !== RELEASE_ENTRY) {
|
|
65
|
+
throw new TypeError('Cloudflare preparation requires the Bundle of its Worker bundler.');
|
|
66
|
+
}
|
|
67
|
+
let entry;
|
|
68
|
+
const modules = [];
|
|
69
|
+
const frontend = [];
|
|
70
|
+
for (const file of bundle.files) {
|
|
71
|
+
if (file.path === RELEASE_ENTRY)
|
|
72
|
+
entry = file.bytes();
|
|
73
|
+
else if (file.path.startsWith(MODULE_DIRECTORY) && /\.(?:mjs|wasm)$/u.test(file.path)) {
|
|
74
|
+
modules.push(Object.freeze({
|
|
75
|
+
path: file.path,
|
|
76
|
+
kind: file.path.endsWith('.wasm') ? 'wasm' : 'esm',
|
|
77
|
+
content: file.bytes(),
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
else if (file.path.startsWith('assets/')) {
|
|
81
|
+
const content = file.bytes();
|
|
82
|
+
frontend.push(Object.freeze({ path: file.path.slice('assets/'.length), bytes: () => content.slice() }));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw new TypeError(`Cloudflare Worker Bundle file ${file.path} is not a Worker file.`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (entry === undefined || !modules.some((module) => module.path === RELEASE_SERVICE)) {
|
|
89
|
+
throw new TypeError('Cloudflare Worker Bundle lacks its execution modules.');
|
|
90
|
+
}
|
|
91
|
+
return Object.freeze({
|
|
92
|
+
entry,
|
|
93
|
+
modules: Object.freeze(modules),
|
|
94
|
+
frontend: Object.freeze(frontend),
|
|
95
|
+
});
|
|
96
|
+
}
|
package/dist/build/closure.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Prove emitted Worker reachability excludes authoring tooling, compilation, and broad Core Schema
|
|
3
|
+
* owners.
|
|
4
|
+
*/
|
|
2
5
|
export declare function assertRuntimeClosure(metafilePath: string): Promise<void>;
|
|
3
|
-
//# sourceMappingURL=closure.d.ts.map
|
package/dist/build/closure.js
CHANGED
|
@@ -8,8 +8,14 @@ const FORBIDDEN_RUNTIME_INPUTS = [
|
|
|
8
8
|
'/core/domain/',
|
|
9
9
|
'/kernel-core/schema/index.',
|
|
10
10
|
'/core/schema/index.',
|
|
11
|
+
// SDK authoring tooling (CLI, lint, packaging) and the scaffold generator.
|
|
12
|
+
'/@astrale-os/sdk/dist/tooling/',
|
|
13
|
+
'/create-astrale-domain/',
|
|
11
14
|
];
|
|
12
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Prove emitted Worker reachability excludes authoring tooling, compilation, and broad Core Schema
|
|
17
|
+
* owners.
|
|
18
|
+
*/
|
|
13
19
|
export async function assertRuntimeClosure(metafilePath) {
|
|
14
20
|
const metafile = await readWranglerMetafile(metafilePath);
|
|
15
21
|
const forbidden = Object.keys(metafile.inputs).filter((input) => {
|
|
@@ -20,4 +26,3 @@ export async function assertRuntimeClosure(metafilePath) {
|
|
|
20
26
|
throw new Error(`Cloudflare Worker reaches build-side modules: ${forbidden.sort().join(', ')}.`);
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
|
-
//# sourceMappingURL=closure.js.map
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
readonly runtimeSpecifier: string;
|
|
5
|
-
readonly material: BuildMaterial;
|
|
6
|
-
readonly providerAssignedWorker?: string;
|
|
7
|
-
readonly router?: {
|
|
8
|
-
readonly binding: string;
|
|
9
|
-
readonly hostSuffix: string;
|
|
10
|
-
readonly minLabels: number;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export declare function generateExecutionEntry(options: ExecutionCodegenOptions): string;
|
|
14
|
-
//# sourceMappingURL=execution.d.ts.map
|
|
1
|
+
export { generateExecutionEntry } from '../worker/codegen/entry.js';
|
|
2
|
+
export { generateExecutionService } from '../worker/codegen/service.js';
|
|
3
|
+
export type { ExecutionCodegenOptions } from '../worker/codegen/service.js';
|
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
const routerPredicate = router === undefined
|
|
4
|
-
? ''
|
|
5
|
-
: `
|
|
6
|
-
function isInstanceHost(host: string): boolean {
|
|
7
|
-
return host.endsWith(${JSON.stringify(router.hostSuffix)}) && host.split('.').length >= ${router.minLabels}
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
const routeSubrequest = router === undefined
|
|
11
|
-
? ''
|
|
12
|
-
: `
|
|
13
|
-
routeSubrequest: (url, env) => {
|
|
14
|
-
const labels = url.hostname.split('.')
|
|
15
|
-
if (env.DISPATCHER && labels[1] === 'svc') return env.DISPATCHER.get(labels[0]!)
|
|
16
|
-
if (env.${router.binding} && isInstanceHost(url.hostname)) return env.${router.binding}
|
|
17
|
-
return null
|
|
18
|
-
},`;
|
|
19
|
-
return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
|
|
20
|
-
// Domain origin: ${options.origin}
|
|
21
|
-
import type { BuildMaterial } from '@astrale-os/sdk/deployment/build'
|
|
22
|
-
import type { CloudflareAdapterBindings } from '@astrale-os/adapter-cloudflare/worker'
|
|
23
|
-
|
|
24
|
-
import { cloudflareWorkerEntry } from '@astrale-os/adapter-cloudflare/worker'
|
|
25
|
-
import runtime from ${JSON.stringify(options.runtimeSpecifier)}
|
|
26
|
-
import { PRIVATE_JWK } from './identity.js'
|
|
27
|
-
|
|
28
|
-
type WorkerEnv = CloudflareEnv & CloudflareAdapterBindings
|
|
29
|
-
const MATERIAL = ${JSON.stringify(options.material)} as const satisfies BuildMaterial
|
|
30
|
-
${routerPredicate}
|
|
31
|
-
export default cloudflareWorkerEntry<WorkerEnv>()({
|
|
32
|
-
runtime,
|
|
33
|
-
material: MATERIAL,
|
|
34
|
-
privateKey: PRIVATE_JWK,
|
|
35
|
-
resolveUrl: (env, requestOrigin) => env.WORKER_URL ?? env.IDENTITY_ISS ?? requestOrigin,
|
|
36
|
-
${options.providerAssignedWorker === undefined ? '' : `providerAssignedWorker: ${JSON.stringify(options.providerAssignedWorker)},`}
|
|
37
|
-
selfBinding: (env) => env.SELF,${routeSubrequest}
|
|
38
|
-
})
|
|
39
|
-
`;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=execution.js.map
|
|
1
|
+
export { generateExecutionEntry } from '../worker/codegen/entry.js';
|
|
2
|
+
export { generateExecutionService } from '../worker/codegen/service.js';
|
|
@@ -20,17 +20,25 @@ export interface WranglerCodegenOptions {
|
|
|
20
20
|
/** Exact materialized local frontend; absence means no ASSETS binding. */
|
|
21
21
|
frontend?: {
|
|
22
22
|
readonly directory: string;
|
|
23
|
-
readonly routes: readonly string[];
|
|
24
|
-
readonly dev: boolean;
|
|
25
23
|
};
|
|
26
24
|
/** Plain (non-secret) vars to bake in. */
|
|
27
25
|
vars?: Record<string, string>;
|
|
26
|
+
/** Secret binding names required by generated Worker code. */
|
|
27
|
+
secretBindings?: readonly string[];
|
|
28
|
+
/** Modules retained outside the startup entry and loaded on demand. */
|
|
29
|
+
modules?: {
|
|
30
|
+
readonly baseDir: string;
|
|
31
|
+
readonly rules: readonly {
|
|
32
|
+
readonly type: 'ESModule' | 'CompiledWasm' | 'Text' | 'Data';
|
|
33
|
+
readonly globs: readonly string[];
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
28
36
|
/** Add the SELF service binding (autobinding). */
|
|
29
37
|
selfBinding: boolean;
|
|
30
38
|
/**
|
|
31
39
|
* Add a service binding to a router Worker for instance-host subrequest
|
|
32
|
-
* routing (see `CloudflareParams.router`). Pairs with the
|
|
33
|
-
*
|
|
40
|
+
* routing (see `CloudflareParams.router`). Pairs with the router rule bound
|
|
41
|
+
* in `ASTRALE_SETTINGS`.
|
|
34
42
|
*/
|
|
35
43
|
router?: {
|
|
36
44
|
binding: string;
|
|
@@ -41,9 +49,25 @@ export interface WranglerCodegenOptions {
|
|
|
41
49
|
* hatch for extra bindings (KV, R2, D1, queues, service bindings, extra
|
|
42
50
|
* `compatibility_flags`, cron `triggers`, …). Arrays concat; new keys are
|
|
43
51
|
* added as-is. The adapter-owned keys `name`, `main`, `assets`, `routes` are
|
|
44
|
-
* rejected (throws) — use `workerName` / `route` instead
|
|
52
|
+
* rejected (throws) — use `workerName` / `route` instead — and so are the keys
|
|
53
|
+
* and compatibility flags Wrangler's bundler reads.
|
|
45
54
|
*/
|
|
46
55
|
wrangler?: Record<string, unknown>;
|
|
47
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* The Workers runtime every generated Worker runs on, wherever it is deployed: its compatibility
|
|
59
|
+
* date, kept on the runtime baseline qualified with Wrangler 4.123.0, and its compatibility flags.
|
|
60
|
+
* Domain execution calls its Kernel through the invocation's public issuer, so Cloudflare must route
|
|
61
|
+
* same-zone callbacks through the public front door instead of bypassing Worker routes
|
|
62
|
+
* (`global_fetch_strictly_public`). An immutable deployment freezes it into its configuration.
|
|
63
|
+
*/
|
|
64
|
+
export declare const GENERATED_WORKER_RUNTIME: Readonly<{
|
|
65
|
+
compatibilityDate: "2026-08-11";
|
|
66
|
+
compatibilityFlags: readonly string[];
|
|
67
|
+
}>;
|
|
48
68
|
export declare function generateWranglerConfig(opts: WranglerCodegenOptions): string;
|
|
49
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Whether a compatibility flag shapes the bundle (Wrangler's bundler reads it), so that no
|
|
71
|
+
* Environment may add it: bundling takes no Environment.
|
|
72
|
+
*/
|
|
73
|
+
export declare function isBundlingCompatibilityFlag(flag: string): boolean;
|
|
@@ -12,17 +12,27 @@
|
|
|
12
12
|
* (extra bindings: KV, R2, D1, queues, …) — see `mergeUserConfig`.
|
|
13
13
|
*/
|
|
14
14
|
import { deepMergeConfig } from './merge.js';
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The Workers runtime every generated Worker runs on, wherever it is deployed: its compatibility
|
|
17
|
+
* date, kept on the runtime baseline qualified with Wrangler 4.123.0, and its compatibility flags.
|
|
18
|
+
* Domain execution calls its Kernel through the invocation's public issuer, so Cloudflare must route
|
|
19
|
+
* same-zone callbacks through the public front door instead of bypassing Worker routes
|
|
20
|
+
* (`global_fetch_strictly_public`). An immutable deployment freezes it into its configuration.
|
|
21
|
+
*/
|
|
22
|
+
export const GENERATED_WORKER_RUNTIME = Object.freeze({
|
|
23
|
+
compatibilityDate: '2026-08-11',
|
|
24
|
+
compatibilityFlags: Object.freeze(['nodejs_compat', 'global_fetch_strictly_public']),
|
|
25
|
+
});
|
|
17
26
|
export function generateWranglerConfig(opts) {
|
|
18
27
|
const config = {
|
|
19
28
|
name: opts.workerName,
|
|
20
29
|
main: opts.main ?? './worker.gen.ts',
|
|
21
|
-
compatibility_date:
|
|
22
|
-
compatibility_flags: [
|
|
23
|
-
workers_dev:
|
|
30
|
+
compatibility_date: GENERATED_WORKER_RUNTIME.compatibilityDate,
|
|
31
|
+
compatibility_flags: [...GENERATED_WORKER_RUNTIME.compatibilityFlags],
|
|
32
|
+
workers_dev: opts.route === undefined,
|
|
24
33
|
version_metadata: { binding: 'ASTRALE_VERSION_METADATA' },
|
|
25
34
|
observability: { enabled: true },
|
|
35
|
+
minify: true,
|
|
26
36
|
};
|
|
27
37
|
if (opts.route) {
|
|
28
38
|
config.routes = [{ pattern: opts.route, custom_domain: true }];
|
|
@@ -31,19 +41,10 @@ export function generateWranglerConfig(opts) {
|
|
|
31
41
|
config.assets = {
|
|
32
42
|
directory: opts.frontend.directory,
|
|
33
43
|
binding: 'ASSETS',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
'/releases/*',
|
|
39
|
-
'/install',
|
|
40
|
-
'/install/*',
|
|
41
|
-
'/health',
|
|
42
|
-
'/health/*',
|
|
43
|
-
'/.well-known',
|
|
44
|
-
'/.well-known/*',
|
|
45
|
-
...opts.frontend.routes,
|
|
46
|
-
],
|
|
44
|
+
html_handling: 'none',
|
|
45
|
+
// Match the portable Worker artifact: frontend routing and sandbox-safe asset
|
|
46
|
+
// response headers are owned by the Worker for both deployment adapters.
|
|
47
|
+
run_worker_first: true,
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
const services = [];
|
|
@@ -57,6 +58,18 @@ export function generateWranglerConfig(opts) {
|
|
|
57
58
|
if (opts.vars && Object.keys(opts.vars).length > 0) {
|
|
58
59
|
config.vars = opts.vars;
|
|
59
60
|
}
|
|
61
|
+
if (opts.secretBindings && opts.secretBindings.length > 0) {
|
|
62
|
+
config.secrets = { required: [...opts.secretBindings] };
|
|
63
|
+
}
|
|
64
|
+
if (opts.modules !== undefined) {
|
|
65
|
+
config.find_additional_modules = true;
|
|
66
|
+
config.base_dir = opts.modules.baseDir;
|
|
67
|
+
config.rules = opts.modules.rules.map((rule) => ({
|
|
68
|
+
type: rule.type,
|
|
69
|
+
globs: [...rule.globs],
|
|
70
|
+
fallthrough: true,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
60
73
|
const merged = opts.wrangler ? mergeUserConfig(config, opts.wrangler) : config;
|
|
61
74
|
return JSON.stringify(merged, null, 2) + '\n';
|
|
62
75
|
}
|
|
@@ -67,11 +80,43 @@ const ADAPTER_OWNED_KEYS = [
|
|
|
67
80
|
'assets',
|
|
68
81
|
'routes',
|
|
69
82
|
'compatibility_date',
|
|
83
|
+
'workers_dev',
|
|
70
84
|
'version_metadata',
|
|
85
|
+
'secrets',
|
|
86
|
+
'find_additional_modules',
|
|
87
|
+
'base_dir',
|
|
71
88
|
];
|
|
89
|
+
/**
|
|
90
|
+
* Keys Wrangler's bundler reads. Bundling sees the adapter base configuration only, so that every
|
|
91
|
+
* Environment of one source bundles the same bytes; an Environment's overlay never sets these.
|
|
92
|
+
*/
|
|
93
|
+
const BUNDLING_KEYS = [
|
|
94
|
+
'alias',
|
|
95
|
+
'build',
|
|
96
|
+
'define',
|
|
97
|
+
'jsx_factory',
|
|
98
|
+
'jsx_fragment',
|
|
99
|
+
'keep_names',
|
|
100
|
+
'minify',
|
|
101
|
+
'no_bundle',
|
|
102
|
+
'node_compat',
|
|
103
|
+
'preserve_file_names',
|
|
104
|
+
'rules',
|
|
105
|
+
'tsconfig',
|
|
106
|
+
'upload_source_maps',
|
|
107
|
+
];
|
|
108
|
+
/** Compatibility flags Wrangler's bundler reads: Node.js polyfills, `navigator`, fetch typing, Python. */
|
|
109
|
+
const BUNDLING_FLAG = /nodejs|navigator|fetch_iterable_type_support|python_workers/u;
|
|
110
|
+
/**
|
|
111
|
+
* Whether a compatibility flag shapes the bundle (Wrangler's bundler reads it), so that no
|
|
112
|
+
* Environment may add it: bundling takes no Environment.
|
|
113
|
+
*/
|
|
114
|
+
export function isBundlingCompatibilityFlag(flag) {
|
|
115
|
+
return BUNDLING_FLAG.test(flag);
|
|
116
|
+
}
|
|
72
117
|
/**
|
|
73
118
|
* Deep-merge the dev's raw wrangler overlay over the generated config, after
|
|
74
|
-
* refusing any attempt to override an adapter-owned key. Throwing (rather than
|
|
119
|
+
* refusing any attempt to override an adapter-owned key or a bundler input. Throwing (rather than
|
|
75
120
|
* silently dropping) keeps a stray `main` from breaking the Worker unnoticed.
|
|
76
121
|
*/
|
|
77
122
|
function mergeUserConfig(base, user) {
|
|
@@ -81,6 +126,17 @@ function mergeUserConfig(base, user) {
|
|
|
81
126
|
'Use `workerName` for the worker name and `route` for routing; ' +
|
|
82
127
|
'`main` and `assets` are generated by the adapter.');
|
|
83
128
|
}
|
|
129
|
+
const baseFlags = Array.isArray(base.compatibility_flags) ? base.compatibility_flags : [];
|
|
130
|
+
const bundling = [
|
|
131
|
+
...BUNDLING_KEYS.filter((k) => k in user),
|
|
132
|
+
...(Array.isArray(user.compatibility_flags) ? user.compatibility_flags : [])
|
|
133
|
+
.filter((flag) => typeof flag === 'string' && BUNDLING_FLAG.test(flag))
|
|
134
|
+
.filter((flag) => !baseFlags.includes(flag))
|
|
135
|
+
.map((flag) => `compatibility_flags ${String(flag)}`),
|
|
136
|
+
];
|
|
137
|
+
if (bundling.length > 0) {
|
|
138
|
+
throw new Error(`wrangler: ${bundling.join(', ')} shape(s) the bundle, which takes no Environment. ` +
|
|
139
|
+
'Bundling uses the adapter base configuration only.');
|
|
140
|
+
}
|
|
84
141
|
return deepMergeConfig(base, user);
|
|
85
142
|
}
|
|
86
|
-
//# sourceMappingURL=wrangler.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MAXIMUM_INVOCATION_TIMEOUT_MS } from '../../worker/settings.js';
|
|
2
|
+
export function workerInvocationTimeout(value) {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return undefined;
|
|
5
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value > MAXIMUM_INVOCATION_TIMEOUT_MS) {
|
|
6
|
+
throw new TypeError('Cloudflare invocationTimeoutMs must be a positive integer within the platform timer range.');
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MAXIMUM_REQUEST_BYTES } from '../../worker/settings.js';
|
|
2
|
+
export function workerRequestLimit(value) {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return undefined;
|
|
5
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value > MAXIMUM_REQUEST_BYTES) {
|
|
6
|
+
throw new TypeError('Cloudflare maximumRequestBytes must be a positive integer at most 16 MiB.');
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CloudflareParams } from '../../params.js';
|
|
2
|
+
export declare function resolveRouter(input: CloudflareParams['router']): {
|
|
3
|
+
readonly binding: string;
|
|
4
|
+
readonly service: string;
|
|
5
|
+
readonly hostSuffix: string;
|
|
6
|
+
readonly minLabels: number;
|
|
7
|
+
} | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function resolveRouter(input) {
|
|
2
|
+
if (input === false || input === undefined)
|
|
3
|
+
return undefined;
|
|
4
|
+
if (input === null ||
|
|
5
|
+
typeof input !== 'object' ||
|
|
6
|
+
Array.isArray(input) ||
|
|
7
|
+
Reflect.ownKeys(input).some((key) => !['service', 'hostSuffix', 'minLabels'].includes(String(key)))) {
|
|
8
|
+
throw new TypeError('Cloudflare router parameters contain unknown fields.');
|
|
9
|
+
}
|
|
10
|
+
const value = input;
|
|
11
|
+
return Object.freeze({
|
|
12
|
+
binding: 'ROUTER',
|
|
13
|
+
service: value.service ?? 'admin-router',
|
|
14
|
+
hostSuffix: value.hostSuffix ?? '.astrale.ai',
|
|
15
|
+
minLabels: value.minLabels ?? 4,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CloudflareParams } from '../../params.js';
|
|
2
|
+
import type { WorkerSettings } from '../../worker/settings.js';
|
|
3
|
+
/** Whether a binding name is one the adapter owns, so no author var or secret may take it. */
|
|
4
|
+
export declare function isAdapterVar(name: string): boolean;
|
|
5
|
+
/** Resolve one Environment's execution settings, defaults included, as its deployment binds them. */
|
|
6
|
+
export declare function workerSettings(parameters: Pick<CloudflareParams, 'durable' | 'maximumRequestBytes' | 'invocationTimeoutMs' | 'tokenExchange' | 'router'>): WorkerSettings;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { maximumExchangeTtl } from '@astrale-os/sdk/execution';
|
|
2
|
+
import { BUILD_DIGEST_BINDING } from '../../worker/build-digest.js';
|
|
3
|
+
import { captureDurableOptions, DEFAULT_INVOCATION_TIMEOUT_MS, DEFAULT_MAXIMUM_REQUEST_BYTES, SETTINGS_BINDING, } from '../../worker/settings.js';
|
|
4
|
+
import { workerInvocationTimeout } from './invocation-timeout.js';
|
|
5
|
+
import { workerRequestLimit } from './request-limit.js';
|
|
6
|
+
import { resolveRouter } from './router.js';
|
|
7
|
+
/**
|
|
8
|
+
* Plain bindings the adapter owns on a deployment, bound or not; no author var or secret takes
|
|
9
|
+
* these names.
|
|
10
|
+
*/
|
|
11
|
+
const ADAPTER_VARS = new Set([
|
|
12
|
+
'WORKER_URL',
|
|
13
|
+
BUILD_DIGEST_BINDING,
|
|
14
|
+
SETTINGS_BINDING,
|
|
15
|
+
]);
|
|
16
|
+
/** Whether a binding name is one the adapter owns, so no author var or secret may take it. */
|
|
17
|
+
export function isAdapterVar(name) {
|
|
18
|
+
return ADAPTER_VARS.has(name);
|
|
19
|
+
}
|
|
20
|
+
/** Resolve one Environment's execution settings, defaults included, as its deployment binds them. */
|
|
21
|
+
export function workerSettings(parameters) {
|
|
22
|
+
const router = resolveRouter(parameters.router);
|
|
23
|
+
return Object.freeze({
|
|
24
|
+
...(parameters.durable === undefined
|
|
25
|
+
? {}
|
|
26
|
+
: { durableOptions: captureDurableOptions(parameters.durable) }),
|
|
27
|
+
maximumRequestBytes: workerRequestLimit(parameters.maximumRequestBytes) ?? DEFAULT_MAXIMUM_REQUEST_BYTES,
|
|
28
|
+
invocationTimeoutMs: workerInvocationTimeout(parameters.invocationTimeoutMs) ?? DEFAULT_INVOCATION_TIMEOUT_MS,
|
|
29
|
+
tokenExchange: parameters.tokenExchange === false
|
|
30
|
+
? false
|
|
31
|
+
: Object.freeze({ maximumLifetimeSeconds: maximumExchangeTtl(parameters.tokenExchange) }),
|
|
32
|
+
router: router === undefined
|
|
33
|
+
? false
|
|
34
|
+
: Object.freeze({
|
|
35
|
+
binding: router.binding,
|
|
36
|
+
hostSuffix: router.hostSuffix,
|
|
37
|
+
minLabels: router.minLabels,
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
readonly service: string;
|
|
6
|
-
readonly hostSuffix: string;
|
|
7
|
-
readonly minLabels: number;
|
|
8
|
-
} | undefined;
|
|
9
|
-
//# sourceMappingURL=configuration.d.ts.map
|
|
1
|
+
export { workerInvocationTimeout } from './configuration/invocation-timeout.js';
|
|
2
|
+
export { workerRequestLimit } from './configuration/request-limit.js';
|
|
3
|
+
export { resolveRouter } from './configuration/router.js';
|
|
4
|
+
export { isAdapterVar, workerSettings } from './configuration/settings.js';
|
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
throw new TypeError('Cloudflare workerName is invalid.');
|
|
6
|
-
}
|
|
7
|
-
return parameters.workerName;
|
|
8
|
-
}
|
|
9
|
-
return origin
|
|
10
|
-
.toLowerCase()
|
|
11
|
-
.replace(/[^a-z0-9]+/gu, '-')
|
|
12
|
-
.slice(0, 54)
|
|
13
|
-
.replace(/^-+|-+$/gu, '');
|
|
14
|
-
}
|
|
15
|
-
export function resolveRouter(input) {
|
|
16
|
-
if (input === false)
|
|
17
|
-
return undefined;
|
|
18
|
-
const value = input ?? {};
|
|
19
|
-
return Object.freeze({
|
|
20
|
-
binding: value.binding ?? 'ROUTER',
|
|
21
|
-
service: value.service ?? 'admin-router',
|
|
22
|
-
hostSuffix: value.hostSuffix ?? '.astrale.ai',
|
|
23
|
-
minLabels: value.minLabels ?? 4,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=configuration.js.map
|
|
1
|
+
export { workerInvocationTimeout } from './configuration/invocation-timeout.js';
|
|
2
|
+
export { workerRequestLimit } from './configuration/request-limit.js';
|
|
3
|
+
export { resolveRouter } from './configuration/router.js';
|
|
4
|
+
export { isAdapterVar, workerSettings } from './configuration/settings.js';
|