@astrale-os/adapter-cloudflare 0.5.0-beta.36 → 0.5.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/gateway/prepare.js +2 -1
- package/dist/build/gateway/source.d.ts +1 -1
- package/dist/build/gateway/source.js +2 -2
- package/dist/build/worker/codegen/entry.d.ts +1 -1
- package/dist/build/worker/codegen/entry.js +2 -2
- package/dist/build/worker/codegen/service.d.ts +1 -0
- package/dist/build/worker/codegen/service.js +4 -3
- package/dist/build/worker/execution.prepare.js +4 -1
- package/dist/build/worker/specifier.d.ts +1 -0
- package/dist/build/worker/specifier.js +5 -0
- package/package.json +2 -2
|
@@ -3,11 +3,12 @@ import { dirname, join } from 'node:path';
|
|
|
3
3
|
import { admitWorkerBundle } from '../bundle/admit.js';
|
|
4
4
|
import { generateWranglerConfig } from '../codegen/wrangler.js';
|
|
5
5
|
import { qualifyWorkerBundle } from '../qualification.js';
|
|
6
|
+
import { workerModuleSpecifier } from '../worker/specifier.js';
|
|
6
7
|
import { runWranglerBundle } from '../wrangler-cli.js';
|
|
7
8
|
import { generateGatewayEntry } from './source.js';
|
|
8
9
|
export async function prepareGateway(input) {
|
|
9
10
|
const gatewaySource = join(input.directory, 'gateway.gen.ts');
|
|
10
|
-
await writeFile(gatewaySource, generateGatewayEntry(input.revision));
|
|
11
|
+
await writeFile(gatewaySource, generateGatewayEntry(input.revision, workerModuleSpecifier()));
|
|
11
12
|
const configPath = join(input.directory, 'wrangler.gateway.prepare.jsonc');
|
|
12
13
|
await writeFile(configPath, generateWranglerConfig({
|
|
13
14
|
workerName: input.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function generateGatewayEntry(revision: string): string;
|
|
1
|
+
export declare function generateGatewayEntry(revision: string, workerSpecifier?: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function generateGatewayEntry(revision) {
|
|
1
|
+
export function generateGatewayEntry(revision, workerSpecifier = '@astrale-os/adapter-cloudflare/worker') {
|
|
2
2
|
return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
|
|
3
|
-
import { cloudflareGatewayEntry } from
|
|
3
|
+
import { cloudflareGatewayEntry } from ${JSON.stringify(workerSpecifier)}
|
|
4
4
|
|
|
5
5
|
export default cloudflareGatewayEntry({ current: ${JSON.stringify(revision)} })
|
|
6
6
|
`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Generate the isolate-startup entry that realizes the heavy Service on first request. */
|
|
2
|
-
export declare function generateExecutionEntry(serviceSpecifier: string): string;
|
|
2
|
+
export declare function generateExecutionEntry(serviceSpecifier: string, workerSpecifier?: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Generate the isolate-startup entry that realizes the heavy Service on first request. */
|
|
2
|
-
export function generateExecutionEntry(serviceSpecifier) {
|
|
2
|
+
export function generateExecutionEntry(serviceSpecifier, workerSpecifier = '@astrale-os/adapter-cloudflare/worker') {
|
|
3
3
|
return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
|
|
4
|
-
import type { CloudflareWorker } from
|
|
4
|
+
import type { CloudflareWorker } from ${JSON.stringify(workerSpecifier)}
|
|
5
5
|
|
|
6
6
|
const SERVICE_SPECIFIER = ${JSON.stringify(serviceSpecifier)}
|
|
7
7
|
let servicePromise: Promise<CloudflareWorker<CloudflareEnv>> | undefined
|
|
@@ -2,6 +2,7 @@ import type { BuildMaterial } from '@astrale-os/sdk/deployment/build';
|
|
|
2
2
|
export interface ExecutionCodegenOptions {
|
|
3
3
|
readonly origin: string;
|
|
4
4
|
readonly runtimeSpecifier: string;
|
|
5
|
+
readonly workerSpecifier?: string;
|
|
5
6
|
readonly material: BuildMaterial;
|
|
6
7
|
readonly maximumRequestBytes?: number;
|
|
7
8
|
readonly providerAssignedWorker?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export function generateExecutionService(options) {
|
|
2
|
+
const workerSpecifier = options.workerSpecifier ?? '@astrale-os/adapter-cloudflare/worker';
|
|
2
3
|
const router = options.router;
|
|
3
4
|
const routerPredicate = router === undefined
|
|
4
5
|
? ''
|
|
@@ -19,10 +20,10 @@ function isInstanceHost(host: string): boolean {
|
|
|
19
20
|
return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
|
|
20
21
|
// Domain origin: ${options.origin}
|
|
21
22
|
import type { BuildMaterial } from '@astrale-os/sdk/deployment/build'
|
|
22
|
-
import type { CloudflareAdapterBindings } from
|
|
23
|
+
import type { CloudflareAdapterBindings } from ${JSON.stringify(workerSpecifier)}
|
|
23
24
|
|
|
24
|
-
import { cloudflareWorkerEntry } from
|
|
25
|
-
import { decodeSigningIdentity, runtimeBindings } from
|
|
25
|
+
import { cloudflareWorkerEntry } from ${JSON.stringify(workerSpecifier)}
|
|
26
|
+
import { decodeSigningIdentity, runtimeBindings } from ${JSON.stringify(workerSpecifier)}
|
|
26
27
|
|
|
27
28
|
type WorkerEnv = CloudflareEnv & CloudflareAdapterBindings & {
|
|
28
29
|
readonly ASTRALE_SIGNING_IDENTITY: string
|
|
@@ -8,15 +8,18 @@ import { generateWranglerConfig } from '../codegen/wrangler.js';
|
|
|
8
8
|
import { workerRequestLimit } from '../configuration.js';
|
|
9
9
|
import { qualifyWorkerBundle } from '../qualification.js';
|
|
10
10
|
import { runWranglerBundle } from '../wrangler-cli.js';
|
|
11
|
+
import { workerModuleSpecifier } from './specifier.js';
|
|
11
12
|
export const RELEASE_ENTRY = 'bundle/index.mjs';
|
|
12
13
|
export const RELEASE_SERVICE = 'bundle/service.mjs';
|
|
13
14
|
export async function prepareExecution(input) {
|
|
14
15
|
const runtimePath = resolve(input.context.projectDir, input.context.runtime.reference.path);
|
|
15
16
|
const runtimeSpecifier = moduleSpecifier(relative(input.directory, runtimePath));
|
|
17
|
+
const workerSpecifier = workerModuleSpecifier();
|
|
16
18
|
const maximumRequestBytes = workerRequestLimit(input.params.maximumRequestBytes);
|
|
17
19
|
const serviceSource = generateExecutionService({
|
|
18
20
|
origin: input.context.build.schema.compiled.root.origin,
|
|
19
21
|
runtimeSpecifier,
|
|
22
|
+
workerSpecifier,
|
|
20
23
|
material: material(input.context.build),
|
|
21
24
|
...(maximumRequestBytes === undefined ? {} : { maximumRequestBytes }),
|
|
22
25
|
...(input.configuredIssuer === undefined && input.direct
|
|
@@ -62,7 +65,7 @@ export async function prepareExecution(input) {
|
|
|
62
65
|
await mkdir(dirname(join(input.directory, RELEASE_SERVICE)), { recursive: true });
|
|
63
66
|
await writeFile(join(input.directory, RELEASE_SERVICE), service);
|
|
64
67
|
const sourcePath = join(input.directory, 'worker.gen.ts');
|
|
65
|
-
await writeFile(sourcePath, generateExecutionEntry('./service.mjs'));
|
|
68
|
+
await writeFile(sourcePath, generateExecutionEntry('./service.mjs', workerSpecifier));
|
|
66
69
|
const configPath = join(input.directory, 'wrangler.prepare.jsonc');
|
|
67
70
|
await writeFile(configPath, generateWranglerConfig({
|
|
68
71
|
workerName: input.name,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function workerModuleSpecifier(): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/adapter-cloudflare",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.37",
|
|
4
4
|
"description": "Deploy an Astrale application through Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"hono": "^4.6.20",
|
|
46
46
|
"jose": "^6.1.3",
|
|
47
47
|
"wrangler": "4.123.0",
|
|
48
|
-
"@astrale-os/sdk": "^0.5.0-beta.
|
|
48
|
+
"@astrale-os/sdk": "^0.5.0-beta.34"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@astrale-os/ox": ">=0.1.0 <1.0.0",
|