@astrale-os/adapter-cloudflare 0.5.0-beta.53 → 0.5.0-beta.55

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.
@@ -1,9 +1,9 @@
1
- import type { BuildMaterial } from '@astrale-os/sdk/deployment/build';
1
+ import type { Build } from '@astrale-os/sdk/deployment/build';
2
2
  export interface ExecutionCodegenOptions {
3
3
  readonly origin: string;
4
4
  readonly runtimeSpecifier: string;
5
5
  readonly workerSpecifier?: string;
6
- readonly material: BuildMaterial;
6
+ readonly build: Build;
7
7
  readonly maximumRequestBytes?: number;
8
8
  readonly providerAssignedWorker?: string;
9
9
  readonly router?: {
@@ -1,5 +1,7 @@
1
+ import { generatedMaterial } from '@astrale-os/sdk/deployment/build';
1
2
  export function generateExecutionService(options) {
2
3
  const workerSpecifier = options.workerSpecifier ?? '@astrale-os/adapter-cloudflare/worker';
4
+ const generated = generatedMaterial(options.build);
3
5
  const router = options.router;
4
6
  const routerPredicate = router === undefined
5
7
  ? ''
@@ -17,15 +19,15 @@ function isInstanceHost(host: string): boolean {
17
19
  if (env.${router.binding} && isInstanceHost(url.hostname)) return env.${router.binding}
18
20
  return null
19
21
  },`;
20
- const frontend = options.material.frontend === undefined
22
+ const frontend = generated.material.frontend === undefined
21
23
  ? ''
22
- : ` frontend: ${JSON.stringify(options.material.frontend)} as const satisfies NonNullable<BuildMaterial['frontend']>,\n`;
24
+ : ` frontend: ${JSON.stringify(generated.material.frontend)} as const satisfies NonNullable<BuildMaterial['frontend']>,\n`;
23
25
  return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
24
26
  // Domain origin: ${options.origin}
25
- import type { BuildMaterial } from '@astrale-os/sdk/deployment/build'
27
+ import type { BuildMaterial, GeneratedBuildMaterial } from '@astrale-os/sdk/deployment/build'
26
28
  import type { CloudflareAdapterBindings } from ${JSON.stringify(workerSpecifier)}
27
29
 
28
- import { cloudflareWorkerEntry } from ${JSON.stringify(workerSpecifier)}
30
+ import { generatedCloudflareWorkerEntry } from ${JSON.stringify(workerSpecifier)}
29
31
  import { decodeSigningIdentity, runtimeBindings } from ${JSON.stringify(workerSpecifier)}
30
32
 
31
33
  type WorkerEnv = CloudflareEnv & CloudflareAdapterBindings & {
@@ -33,10 +35,10 @@ type WorkerEnv = CloudflareEnv & CloudflareAdapterBindings & {
33
35
  }
34
36
  type RuntimeEnv = Omit<WorkerEnv, 'ASTRALE_SIGNING_IDENTITY'>
35
37
  ${routerPredicate}
36
- export default cloudflareWorkerEntry<WorkerEnv, RuntimeEnv>()({
38
+ export default generatedCloudflareWorkerEntry<WorkerEnv, RuntimeEnv>()({
37
39
  ${frontend} load: async () => ({
38
40
  runtime: (await import(${JSON.stringify(options.runtimeSpecifier)})).default,
39
- material: ${JSON.stringify(options.material)} as const satisfies BuildMaterial,
41
+ material: ${JSON.stringify(generated)} as unknown as GeneratedBuildMaterial,
40
42
  }),
41
43
  privateKey: (env) => decodeSigningIdentity(env.ASTRALE_SIGNING_IDENTITY),
42
44
  resolveEnvironment: runtimeBindings,
@@ -1,4 +1,3 @@
1
- import { material } from '@astrale-os/sdk/deployment/build';
2
1
  import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
3
2
  import { dirname, join, relative, resolve } from 'node:path';
4
3
  import { SIGNING_IDENTITY_BINDING } from '../../identity/binding.js';
@@ -20,7 +19,7 @@ export async function prepareExecution(input) {
20
19
  origin: input.context.build.schema.compiled.root.origin,
21
20
  runtimeSpecifier,
22
21
  workerSpecifier,
23
- material: material(input.context.build),
22
+ build: input.context.build,
24
23
  ...(maximumRequestBytes === undefined ? {} : { maximumRequestBytes }),
25
24
  ...(input.configuredIssuer === undefined && input.direct
26
25
  ? { providerAssignedWorker: input.name }
@@ -1,5 +1,5 @@
1
1
  import type { JsonWebKey } from '@astrale-os/sdk/auth';
2
- import type { BuildMaterial } from '@astrale-os/sdk/deployment/build/material';
2
+ import type { BuildMaterial, GeneratedBuildMaterial } from '@astrale-os/sdk/deployment/build/material';
3
3
  import type { ExecutionContext } from '@astrale-os/sdk/execution';
4
4
  import type { Runtime } from '@astrale-os/sdk/runtime';
5
5
  export interface Fetcher {
@@ -16,11 +16,11 @@ export interface CloudflareAdapterBindings {
16
16
  get(name: string): Fetcher;
17
17
  };
18
18
  }
19
- export interface CloudflareWorkerConfig<RuntimeValue extends Runtime, Bindings extends CloudflareAdapterBindings, Environment> {
19
+ export interface CloudflareWorkerConfig<RuntimeValue extends Runtime, Bindings extends CloudflareAdapterBindings, Environment, Material = BuildMaterial> {
20
20
  /** Generated frontend evidence available without restoring the execution Build. */
21
21
  readonly frontend?: BuildMaterial['frontend'];
22
22
  /** Load the exact Runtime and Build once, after the isolate has accepted a request. */
23
- readonly load: () => CloudflareWorkerSource<RuntimeValue> | Promise<CloudflareWorkerSource<RuntimeValue>>;
23
+ readonly load: () => CloudflareWorkerSource<RuntimeValue, Material> | Promise<CloudflareWorkerSource<RuntimeValue, Material>>;
24
24
  readonly privateKey: JsonWebKey | ((bindings: Bindings) => JsonWebKey);
25
25
  readonly resolveEnvironment?: (bindings: Bindings) => Environment;
26
26
  readonly resolveUrl?: (bindings: Bindings, requestOrigin: string) => string;
@@ -30,12 +30,14 @@ export interface CloudflareWorkerConfig<RuntimeValue extends Runtime, Bindings e
30
30
  readonly invocationTimeoutMs?: number;
31
31
  readonly maximumRequestBytes?: number;
32
32
  }
33
- export interface CloudflareWorkerSource<RuntimeValue extends Runtime> {
33
+ export interface CloudflareWorkerSource<RuntimeValue extends Runtime, Material = BuildMaterial> {
34
34
  readonly runtime: RuntimeValue;
35
- readonly material: BuildMaterial;
35
+ readonly material: Material;
36
36
  }
37
37
  export interface CloudflareWorker<Bindings> {
38
38
  fetch(request: Request, environment: Bindings, executionContext?: ExecutionContext): Response | Promise<Response>;
39
39
  }
40
40
  /** Compose one exact revision Service; the provider gateway owns revision selection. */
41
- export declare function cloudflareWorkerEntry<Bindings extends CloudflareAdapterBindings, Environment = Bindings>(): <RuntimeValue extends Runtime>(config: CloudflareWorkerConfig<RuntimeValue, Bindings, Environment>) => CloudflareWorker<Bindings>;
41
+ export declare function cloudflareWorkerEntry<Bindings extends CloudflareAdapterBindings, Environment = Bindings>(): <RuntimeValue extends Runtime>(config: CloudflareWorkerConfig<RuntimeValue, Bindings, Environment, BuildMaterial>) => CloudflareWorker<Bindings>;
42
+ /** Compose generated execution code whose exact Build material carries build-owner evidence. */
43
+ export declare function generatedCloudflareWorkerEntry<Bindings extends CloudflareAdapterBindings, Environment = Bindings>(): <RuntimeValue extends Runtime>(config: CloudflareWorkerConfig<RuntimeValue, Bindings, Environment, GeneratedBuildMaterial>) => CloudflareWorker<Bindings>;
@@ -1,10 +1,17 @@
1
1
  import { issuer } from '@astrale-os/sdk/auth';
2
- import { restoreBuild } from '@astrale-os/sdk/deployment/build/material';
2
+ import { restoreBuild, restoreGeneratedBuild } from '@astrale-os/sdk/deployment/build/material';
3
3
  import { addressing, assemble } from '@astrale-os/sdk/deployment/release/runtime';
4
4
  import { createIdentity, serve } from '@astrale-os/sdk/execution';
5
5
  import { dispatchCloudflareRequest, prepareCloudflareRequest } from './fetch.js';
6
6
  /** Compose one exact revision Service; the provider gateway owns revision selection. */
7
7
  export function cloudflareWorkerEntry() {
8
+ return createCloudflareWorkerEntry(restoreBuild);
9
+ }
10
+ /** Compose generated execution code whose exact Build material carries build-owner evidence. */
11
+ export function generatedCloudflareWorkerEntry() {
12
+ return createCloudflareWorkerEntry(restoreGeneratedBuild);
13
+ }
14
+ function createCloudflareWorkerEntry(restore) {
8
15
  return function (config) {
9
16
  let currentIssuer;
10
17
  let realized;
@@ -14,7 +21,7 @@ export function cloudflareWorkerEntry() {
14
21
  realized = Promise.resolve()
15
22
  .then(config.load)
16
23
  .then((source) => {
17
- const build = restoreBuild(source.material, source.runtime);
24
+ const build = restore(source.material, source.runtime);
18
25
  const application = serve({
19
26
  runtime: source.runtime,
20
27
  load(environment) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/adapter-cloudflare",
3
- "version": "0.5.0-beta.53",
3
+ "version": "0.5.0-beta.55",
4
4
  "description": "Deploy an Astrale application through Cloudflare Workers",
5
5
  "keywords": [
6
6
  "adapter",
@@ -41,14 +41,17 @@
41
41
  },
42
42
  "./package.json": "./package.json"
43
43
  },
44
+ "publishConfig": {
45
+ "registry": "https://registry.npmjs.org/"
46
+ },
44
47
  "dependencies": {
45
48
  "hono": "^4.6.20",
46
49
  "jose": "^6.1.3",
47
50
  "wrangler": "4.123.0",
48
- "@astrale-os/sdk": "0.5.0-beta.50"
51
+ "@astrale-os/sdk": "0.5.0-beta.52"
49
52
  },
50
53
  "devDependencies": {
51
- "@astrale-os/ox": ">=0.1.0 <1.0.0",
54
+ "@astrale-os/ox": "0.1.3",
52
55
  "@types/node": "^22.0.0",
53
56
  "oxfmt": "0.63.0",
54
57
  "oxlint": "1.78.0",
@@ -60,7 +63,7 @@
60
63
  "node": ">=22"
61
64
  },
62
65
  "scripts": {
63
- "typecheck": "tsc --noEmit",
66
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json && tsc --noEmit -p __tests__/tsconfig.types.json",
64
67
  "test": "vitest run",
65
68
  "lint": "oxlint --disable-nested-config .",
66
69
  "format": "pnpm exec oxfmt --write .",