@astrale-os/adapter-cloudflare 0.4.10 → 0.5.0-beta.2
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/codegen/identity.d.ts.map +1 -0
- package/dist/build/codegen/identity.js.map +1 -0
- package/dist/build/codegen/merge.d.ts.map +1 -0
- package/dist/build/codegen/merge.js.map +1 -0
- package/dist/build/codegen/worker.d.ts +12 -0
- package/dist/build/codegen/worker.d.ts.map +1 -0
- package/dist/build/codegen/worker.js +40 -0
- package/dist/build/codegen/worker.js.map +1 -0
- package/dist/{codegen → build/codegen}/wrangler.d.ts +6 -3
- package/dist/build/codegen/wrangler.d.ts.map +1 -0
- package/dist/{codegen → build/codegen}/wrangler.js +29 -10
- package/dist/build/codegen/wrangler.js.map +1 -0
- package/dist/build/frontend.d.ts +26 -0
- package/dist/build/frontend.d.ts.map +1 -0
- package/dist/build/frontend.js +263 -0
- package/dist/build/frontend.js.map +1 -0
- package/dist/{build.js → build/index.d.ts} +5 -4
- package/dist/build/index.d.ts.map +1 -0
- package/dist/{build.d.ts → build/index.js} +5 -5
- package/dist/build/index.js.map +1 -0
- package/dist/{parse-output.d.ts → build/parse-output.d.ts} +2 -0
- package/dist/build/parse-output.d.ts.map +1 -0
- package/dist/{parse-output.js → build/parse-output.js} +5 -0
- package/dist/build/parse-output.js.map +1 -0
- package/dist/build/prepare.d.ts +18 -0
- package/dist/build/prepare.d.ts.map +1 -0
- package/dist/build/prepare.js +117 -0
- package/dist/build/prepare.js.map +1 -0
- package/dist/build/worker.d.ts +15 -0
- package/dist/build/worker.d.ts.map +1 -0
- package/dist/build/worker.js +21 -0
- package/dist/build/worker.js.map +1 -0
- package/dist/{wrangler-cli.d.ts → build/wrangler-cli.d.ts} +8 -0
- package/dist/build/wrangler-cli.d.ts.map +1 -0
- package/dist/{wrangler-cli.js → build/wrangler-cli.js} +28 -4
- package/dist/build/wrangler-cli.js.map +1 -0
- package/dist/cloudflare.d.ts +21 -24
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +125 -191
- package/dist/cloudflare.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/params.d.ts +13 -16
- package/dist/params.d.ts.map +1 -1
- package/dist/worker/index.d.ts +48 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +186 -0
- package/dist/worker/index.js.map +1 -0
- package/package.json +13 -5
- package/src/build/codegen/worker.ts +53 -0
- package/src/{codegen → build/codegen}/wrangler.ts +34 -12
- package/src/build/frontend.ts +324 -0
- package/src/{build.ts → build/index.ts} +17 -4
- package/src/{parse-output.ts → build/parse-output.ts} +6 -0
- package/src/build/prepare.ts +161 -0
- package/src/build/worker.ts +37 -0
- package/src/{wrangler-cli.ts → build/wrangler-cli.ts} +44 -6
- package/src/cloudflare.ts +153 -223
- package/src/index.ts +4 -4
- package/src/params.ts +13 -17
- package/src/worker/index.ts +276 -0
- package/src/worker/tsconfig.json +10 -0
- package/template/astrale.config.ts +7 -7
- package/dist/assets-pack.d.ts +0 -8
- package/dist/assets-pack.d.ts.map +0 -1
- package/dist/assets-pack.js +0 -30
- package/dist/assets-pack.js.map +0 -1
- package/dist/build.d.ts.map +0 -1
- package/dist/build.js.map +0 -1
- package/dist/client.d.ts +0 -17
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -59
- package/dist/client.js.map +0 -1
- package/dist/codegen/identity.d.ts.map +0 -1
- package/dist/codegen/identity.js.map +0 -1
- package/dist/codegen/merge.d.ts.map +0 -1
- package/dist/codegen/merge.js.map +0 -1
- package/dist/codegen/worker.d.ts +0 -51
- package/dist/codegen/worker.d.ts.map +0 -1
- package/dist/codegen/worker.js +0 -120
- package/dist/codegen/worker.js.map +0 -1
- package/dist/codegen/wrangler.d.ts.map +0 -1
- package/dist/codegen/wrangler.js.map +0 -1
- package/dist/parse-output.d.ts.map +0 -1
- package/dist/parse-output.js.map +0 -1
- package/dist/wrangler-cli.d.ts.map +0 -1
- package/dist/wrangler-cli.js.map +0 -1
- package/src/assets-pack.ts +0 -32
- package/src/client.ts +0 -89
- package/src/codegen/worker.ts +0 -136
- package/template/.env.example +0 -9
- package/template/.gitignore.template +0 -16
- package/template/CLAUDE.md +0 -13
- package/template/README.md +0 -47
- package/template/client/.gitignore.template +0 -4
- package/template/client/__tests__/app.test.tsx +0 -15
- package/template/client/components.json +0 -25
- package/template/client/index.html +0 -12
- package/template/client/package.json +0 -35
- package/template/client/src/app.tsx +0 -52
- package/template/client/src/components/ui/cn.ts +0 -6
- package/template/client/src/main.tsx +0 -9
- package/template/client/src/styles.css +0 -78
- package/template/client/tsconfig.json +0 -26
- package/template/client/vite.config.ts +0 -22
- package/template/client/vitest.config.ts +0 -13
- package/template/core/README.md +0 -7
- package/template/deps.ts +0 -9
- package/template/domain.ts +0 -11
- package/template/env.ts +0 -8
- package/template/icons.ts +0 -4
- package/template/integrations/README.md +0 -7
- package/template/oxlint.config.ts +0 -1
- package/template/package.json +0 -58
- package/template/pnpm-workspace.yaml +0 -31
- package/template/runtime/index.ts +0 -8
- package/template/schema/index.ts +0 -10
- package/template/simulation/README.md +0 -12
- package/template/tsconfig.json +0 -28
- package/template/vitest.config.ts +0 -7
- /package/dist/{codegen → build/codegen}/identity.d.ts +0 -0
- /package/dist/{codegen → build/codegen}/identity.js +0 -0
- /package/dist/{codegen → build/codegen}/merge.d.ts +0 -0
- /package/dist/{codegen → build/codegen}/merge.js +0 -0
- /package/src/{codegen → build/codegen}/identity.ts +0 -0
- /package/src/{codegen → build/codegen}/merge.ts +0 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import type { schema } from '@astrale-os/kernel-dsl/v1'
|
|
2
|
+
import type { DomainDefinition, FrontendRoute } from '@astrale-os/sdk'
|
|
3
|
+
import type {
|
|
4
|
+
Application,
|
|
5
|
+
RemoteDeploymentInput,
|
|
6
|
+
RemoteIdentityInput,
|
|
7
|
+
} from '@astrale-os/sdk/server'
|
|
8
|
+
import type { ExecutionContext, Hono } from 'hono'
|
|
9
|
+
|
|
10
|
+
import { issuer } from '@astrale-os/kernel-core/auth'
|
|
11
|
+
import { createRemoteApplication } from '@astrale-os/sdk/server'
|
|
12
|
+
import { Hono as HonoApplication } from 'hono'
|
|
13
|
+
|
|
14
|
+
const MAXIMUM_CACHED_APPLICATIONS = 4
|
|
15
|
+
const APPLICATION_CLOSE_TIMEOUT_MS = 5_000
|
|
16
|
+
|
|
17
|
+
/** SDK-owned Publication manifest passed through without adapter interpretation. */
|
|
18
|
+
export type CloudflareManifest = NonNullable<RemoteDeploymentInput['manifest']>
|
|
19
|
+
|
|
20
|
+
export interface Fetcher {
|
|
21
|
+
fetch(request: Request): Response | Promise<Response>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Adapter-owned bindings generated into every Cloudflare deployment. */
|
|
25
|
+
export interface CloudflareAdapterBindings {
|
|
26
|
+
/** Native Cloudflare deployment metadata (direct Wrangler deployments). */
|
|
27
|
+
readonly ASTRALE_VERSION_METADATA?: {
|
|
28
|
+
readonly id: string
|
|
29
|
+
readonly tag: string
|
|
30
|
+
readonly timestamp: string
|
|
31
|
+
}
|
|
32
|
+
/** Content-derived generation supplied by providers without version metadata. */
|
|
33
|
+
readonly ASTRALE_DEPLOYMENT_VERSION?: string
|
|
34
|
+
readonly WORKER_URL?: string
|
|
35
|
+
readonly ASSETS?: Fetcher
|
|
36
|
+
readonly SELF?: Fetcher
|
|
37
|
+
readonly FRONTEND_DEV_URL?: string
|
|
38
|
+
readonly DISPATCHER?: { get(name: string): Fetcher }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface CloudflareWorkerConfig<
|
|
42
|
+
S extends schema.DomainSchema,
|
|
43
|
+
Bindings extends CloudflareAdapterBindings,
|
|
44
|
+
Environment,
|
|
45
|
+
> {
|
|
46
|
+
readonly definition: DomainDefinition<S>
|
|
47
|
+
readonly privateKey:
|
|
48
|
+
| RemoteIdentityInput['privateKey']
|
|
49
|
+
| ((bindings: Bindings) => RemoteIdentityInput['privateKey'])
|
|
50
|
+
/** Compose provider bindings into the exact Domain environment once per deployment generation. */
|
|
51
|
+
readonly resolveEnvironment?: (bindings: Bindings) => Environment | Promise<Environment>
|
|
52
|
+
readonly manifest?: CloudflareManifest
|
|
53
|
+
readonly resolveUrl?: (bindings: Bindings, requestOrigin: string) => string
|
|
54
|
+
readonly selfBinding?: (bindings: Bindings) => Fetcher | null | undefined
|
|
55
|
+
readonly routeSubrequest?: (url: URL, bindings: Bindings) => Fetcher | null | undefined
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface CloudflareWorker<Environment> {
|
|
59
|
+
fetch(
|
|
60
|
+
request: Request,
|
|
61
|
+
environment: Environment,
|
|
62
|
+
executionContext?: ExecutionContext,
|
|
63
|
+
): Response | Promise<Response>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface CachedApplication<Environment> {
|
|
67
|
+
readonly origin: string
|
|
68
|
+
readonly application: Application<Hono>
|
|
69
|
+
readonly environment: Environment
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Compose one Cloudflare module Worker without request-global mutation.
|
|
74
|
+
* Environment bindings are captured once per immutable serving URL/version generation.
|
|
75
|
+
*/
|
|
76
|
+
export function cloudflareWorkerEntry<
|
|
77
|
+
Bindings extends CloudflareAdapterBindings,
|
|
78
|
+
Environment = Bindings,
|
|
79
|
+
>() {
|
|
80
|
+
return function <const S extends schema.DomainSchema>(
|
|
81
|
+
config: CloudflareWorkerConfig<S, Bindings, Environment>,
|
|
82
|
+
): CloudflareWorker<Bindings> {
|
|
83
|
+
const applications = new Map<string, CachedApplication<Environment>>()
|
|
84
|
+
|
|
85
|
+
const applicationFor = async (
|
|
86
|
+
url: string,
|
|
87
|
+
bindings: Bindings,
|
|
88
|
+
): Promise<CachedApplication<Environment>> => {
|
|
89
|
+
const version = deploymentVersion(bindings)
|
|
90
|
+
const key = `${url}\u0000${version}`
|
|
91
|
+
const cached = applications.get(key)
|
|
92
|
+
if (cached !== undefined) return cached
|
|
93
|
+
const environment =
|
|
94
|
+
config.resolveEnvironment === undefined
|
|
95
|
+
? (bindings as unknown as Environment)
|
|
96
|
+
: await config.resolveEnvironment(bindings)
|
|
97
|
+
|
|
98
|
+
const routedFetch: typeof fetch = async (input, init) => {
|
|
99
|
+
const request = new Request(input, init)
|
|
100
|
+
const destination = new URL(request.url)
|
|
101
|
+
if (destination.origin === new URL(url).origin) {
|
|
102
|
+
const self = config.selfBinding?.(bindings)
|
|
103
|
+
if (self !== null && self !== undefined) return self.fetch(request)
|
|
104
|
+
return serving.app.fetch(request, environment)
|
|
105
|
+
}
|
|
106
|
+
const route = config.routeSubrequest?.(destination, bindings)
|
|
107
|
+
return route === null || route === undefined ? fetch(request) : route.fetch(request)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const deploymentQuery = `deployment=${encodeURIComponent(version)}`
|
|
111
|
+
const issuerId = issuer.accept(url)
|
|
112
|
+
const host = new HonoApplication()
|
|
113
|
+
host.get('/meta', (context) =>
|
|
114
|
+
context.json({
|
|
115
|
+
origin: config.definition.schema.origin,
|
|
116
|
+
issuer: issuerId,
|
|
117
|
+
schemaRevision: config.definition.domain.$.revision,
|
|
118
|
+
deploymentVersion: version,
|
|
119
|
+
}),
|
|
120
|
+
)
|
|
121
|
+
const serving: Application<Hono> = createRemoteApplication({
|
|
122
|
+
definition: config.definition,
|
|
123
|
+
environment,
|
|
124
|
+
identity: {
|
|
125
|
+
issuer: issuerId,
|
|
126
|
+
subject: config.definition.schema.origin,
|
|
127
|
+
privateKey:
|
|
128
|
+
typeof config.privateKey === 'function'
|
|
129
|
+
? config.privateKey(bindings)
|
|
130
|
+
: config.privateKey,
|
|
131
|
+
fetch: routedFetch,
|
|
132
|
+
...(new URL(url).protocol === 'http:' ? { allowInsecureHttp: true } : {}),
|
|
133
|
+
},
|
|
134
|
+
deployment: {
|
|
135
|
+
bundleHref: `${url}/.well-known/astrale/domain.bundle.json?${deploymentQuery}`,
|
|
136
|
+
endpoint: { http: `${url}/invoke` },
|
|
137
|
+
...(config.definition.frontend === undefined
|
|
138
|
+
? {}
|
|
139
|
+
: { frontendBaseHref: url, frontendCacheKey: version }),
|
|
140
|
+
...(config.manifest === undefined ? {} : { manifest: config.manifest }),
|
|
141
|
+
installation: {
|
|
142
|
+
href: `${url}/install`,
|
|
143
|
+
method: 'POST',
|
|
144
|
+
authentication: { kind: 'public' },
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
app: host,
|
|
148
|
+
server: {
|
|
149
|
+
path: '/invoke',
|
|
150
|
+
health: { probe: { check: () => true } },
|
|
151
|
+
limits: {
|
|
152
|
+
maximumRequestBytes: 1024 * 1024,
|
|
153
|
+
maximumPublicationBytes: 1024 * 1024,
|
|
154
|
+
maximumBundleBytes: 8 * 1024 * 1024,
|
|
155
|
+
maximumInstallationBytes: 8 * 1024 * 1024,
|
|
156
|
+
invocationTimeoutMs: 30_000,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
const created = Object.freeze({
|
|
161
|
+
origin: new URL(url).origin,
|
|
162
|
+
application: serving,
|
|
163
|
+
environment,
|
|
164
|
+
})
|
|
165
|
+
if (applications.size >= MAXIMUM_CACHED_APPLICATIONS) {
|
|
166
|
+
const oldest = applications.keys().next().value
|
|
167
|
+
if (oldest !== undefined) {
|
|
168
|
+
const evicted = applications.get(oldest)
|
|
169
|
+
applications.delete(oldest)
|
|
170
|
+
if (evicted !== undefined) {
|
|
171
|
+
try {
|
|
172
|
+
await closeEvictedApplication(evicted.application)
|
|
173
|
+
} catch (cause) {
|
|
174
|
+
await serving
|
|
175
|
+
.close({ deadline: Date.now() + APPLICATION_CLOSE_TIMEOUT_MS })
|
|
176
|
+
.catch(() => undefined)
|
|
177
|
+
throw cause
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
applications.set(key, created)
|
|
183
|
+
return created
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return Object.freeze({
|
|
187
|
+
async fetch(request: Request, bindings: Bindings, executionContext?: ExecutionContext) {
|
|
188
|
+
const requestUrl = new URL(request.url)
|
|
189
|
+
if (config.definition.frontend !== undefined) {
|
|
190
|
+
const asset = await frontendAsset(config.definition, bindings, requestUrl, request)
|
|
191
|
+
if (asset !== undefined) return asset
|
|
192
|
+
}
|
|
193
|
+
const publicUrl = canonicalServingUrl(
|
|
194
|
+
config.resolveUrl?.(bindings, requestOrigin(requestUrl, request)) ??
|
|
195
|
+
bindings.WORKER_URL ??
|
|
196
|
+
requestOrigin(requestUrl, request),
|
|
197
|
+
)
|
|
198
|
+
const serving = await applicationFor(publicUrl, bindings)
|
|
199
|
+
return serving.application.app.fetch(request, serving.environment, executionContext)
|
|
200
|
+
},
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Close an evicted Application before its environment bindings leave the cache. */
|
|
206
|
+
export function closeEvictedApplication(
|
|
207
|
+
application: Pick<Application, 'close'>,
|
|
208
|
+
now: () => number = Date.now,
|
|
209
|
+
): Promise<void> {
|
|
210
|
+
return application.close({ deadline: now() + APPLICATION_CLOSE_TIMEOUT_MS })
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function frontendAsset<S extends schema.DomainSchema>(
|
|
214
|
+
definition: DomainDefinition<S>,
|
|
215
|
+
environment: CloudflareAdapterBindings,
|
|
216
|
+
url: URL,
|
|
217
|
+
request: Request,
|
|
218
|
+
): Promise<Response | undefined> {
|
|
219
|
+
const frontend = definition.frontend
|
|
220
|
+
if (frontend === undefined || frontend.source.kind === 'external') return undefined
|
|
221
|
+
const routes = frontend.routes as Readonly<Record<string, FrontendRoute>>
|
|
222
|
+
const route = Object.values(routes).find((candidate) => candidate.path === url.pathname)
|
|
223
|
+
const staticAsset = url.pathname.startsWith('/assets/')
|
|
224
|
+
if (route === undefined && !staticAsset) return undefined
|
|
225
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') return undefined
|
|
226
|
+
const binding = environment.ASSETS
|
|
227
|
+
if (binding === undefined) return undefined
|
|
228
|
+
const dev = environment.FRONTEND_DEV_URL?.replace(/\/+$/u, '')
|
|
229
|
+
if (dev !== undefined && dev.length > 0) {
|
|
230
|
+
return fetch(new Request(`${dev}${url.pathname}${url.search}`, request))
|
|
231
|
+
}
|
|
232
|
+
const path =
|
|
233
|
+
route === undefined ? `${url.pathname}${url.search}` : `/${route.document}${url.search}`
|
|
234
|
+
return binding.fetch(new Request(new URL(path, url.origin), request))
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function requestOrigin(url: URL, request: Request): string {
|
|
238
|
+
if (url.protocol !== 'http:') return url.origin
|
|
239
|
+
const forwarded = request.headers.get('x-forwarded-proto')?.split(',')[0]?.trim().toLowerCase()
|
|
240
|
+
return forwarded === 'https' ? `https://${url.host}` : url.origin
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function canonicalServingUrl(input: string): string {
|
|
244
|
+
let url: URL
|
|
245
|
+
try {
|
|
246
|
+
url = new URL(input)
|
|
247
|
+
} catch (cause) {
|
|
248
|
+
throw new TypeError('Cloudflare Worker serving URL is invalid.', { cause })
|
|
249
|
+
}
|
|
250
|
+
if (
|
|
251
|
+
(url.protocol !== 'https:' && url.protocol !== 'http:') ||
|
|
252
|
+
url.username !== '' ||
|
|
253
|
+
url.password !== '' ||
|
|
254
|
+
url.pathname !== '/' ||
|
|
255
|
+
url.search !== '' ||
|
|
256
|
+
url.hash !== ''
|
|
257
|
+
) {
|
|
258
|
+
throw new TypeError('Cloudflare Worker serving URL must be one HTTP(S) origin.')
|
|
259
|
+
}
|
|
260
|
+
return url.origin
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function deploymentVersion(environment: CloudflareAdapterBindings): string {
|
|
264
|
+
const input = environment.ASTRALE_VERSION_METADATA
|
|
265
|
+
if (
|
|
266
|
+
input !== null &&
|
|
267
|
+
typeof input === 'object' &&
|
|
268
|
+
typeof input.id === 'string' &&
|
|
269
|
+
input.id.length > 0
|
|
270
|
+
) {
|
|
271
|
+
return input.id
|
|
272
|
+
}
|
|
273
|
+
const fallback = environment.ASTRALE_DEPLOYMENT_VERSION
|
|
274
|
+
if (typeof fallback === 'string' && fallback.length > 0) return fallback
|
|
275
|
+
throw new TypeError('Cloudflare Worker deployment version is unavailable.')
|
|
276
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* astrale.config.ts — binds the worker-safe
|
|
2
|
+
* astrale.config.ts — binds the worker-safe composition (`implementation.ts`) to its deploy
|
|
3
3
|
* adapter for the `astrale-domain` CLI. This is a NODE-only module: it imports
|
|
4
4
|
* the adapter (wrangler + filesystem). The generated worker never imports this
|
|
5
|
-
* file — it imports `
|
|
5
|
+
* file — it imports `implementation.ts` directly — so the adapter stays out of the bundle.
|
|
6
6
|
*
|
|
7
7
|
* This variant deploys to YOUR OWN Cloudflare account (the `cloudflare` adapter).
|
|
8
8
|
*
|
|
@@ -18,19 +18,19 @@ import { deploy } from '@astrale-os/sdk'
|
|
|
18
18
|
//
|
|
19
19
|
// import { astrale } from '@astrale-os/adapter-astrale'
|
|
20
20
|
// export default deploy(domain, astrale({
|
|
21
|
-
// dev: {
|
|
22
|
-
// prod: {
|
|
21
|
+
// dev: { secrets: '.env.dev' }, // local wrangler dev
|
|
22
|
+
// prod: { instance: '<your-instance-slug>' }, // managed deploy
|
|
23
23
|
// }))
|
|
24
24
|
|
|
25
|
-
import { domain } from './
|
|
25
|
+
import { domain } from './implementation'
|
|
26
26
|
|
|
27
27
|
export default deploy(
|
|
28
28
|
domain,
|
|
29
29
|
cloudflare({
|
|
30
30
|
// Local dev: `wrangler dev`. No route → URL is http://localhost:8787.
|
|
31
|
-
dev: {
|
|
31
|
+
dev: { secrets: '.env.dev' },
|
|
32
32
|
// Custom-domain prod. Drop `route` to ship to *.workers.dev instead.
|
|
33
|
-
prod: {
|
|
33
|
+
prod: { route: 'astrale-domain.example.dev', secrets: '.env.prod' },
|
|
34
34
|
// Author secrets ship via `secrets: '.env.prod'` on any env. Extra bindings
|
|
35
35
|
// (KV, R2, D1, queues, …) ride a `wrangler` block on any env (deep-merged).
|
|
36
36
|
}),
|
package/dist/assets-pack.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pack a built client SPA (the `CLIENT_DIST_DIR` build) into the host box's asset-archive
|
|
3
|
-
* format: `gzip(JSON [{ path, contentBase64 }])` — the exact shape
|
|
4
|
-
* `downloadAssets` on the box consumes (kernel/host workerd service layout).
|
|
5
|
-
*/
|
|
6
|
-
/** Gzip the SPA dir into the box's asset archive. Returns null when empty. */
|
|
7
|
-
export declare function packAssets(distClientDir: string): Buffer | null;
|
|
8
|
-
//# sourceMappingURL=assets-pack.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assets-pack.d.ts","sourceRoot":"","sources":["../src/assets-pack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK/D"}
|
package/dist/assets-pack.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pack a built client SPA (the `CLIENT_DIST_DIR` build) into the host box's asset-archive
|
|
3
|
-
* format: `gzip(JSON [{ path, contentBase64 }])` — the exact shape
|
|
4
|
-
* `downloadAssets` on the box consumes (kernel/host workerd service layout).
|
|
5
|
-
*/
|
|
6
|
-
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
7
|
-
import { join, relative } from 'node:path';
|
|
8
|
-
import { gzipSync } from 'node:zlib';
|
|
9
|
-
function walk(dir, root, out) {
|
|
10
|
-
for (const name of readdirSync(dir)) {
|
|
11
|
-
const full = join(dir, name);
|
|
12
|
-
if (statSync(full).isDirectory())
|
|
13
|
-
walk(full, root, out);
|
|
14
|
-
else {
|
|
15
|
-
out.push({
|
|
16
|
-
path: relative(root, full).split('\\').join('/'),
|
|
17
|
-
contentBase64: readFileSync(full).toString('base64'),
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Gzip the SPA dir into the box's asset archive. Returns null when empty. */
|
|
23
|
-
export function packAssets(distClientDir) {
|
|
24
|
-
const files = [];
|
|
25
|
-
walk(distClientDir, distClientDir, files);
|
|
26
|
-
if (files.length === 0)
|
|
27
|
-
return null;
|
|
28
|
-
return gzipSync(Buffer.from(JSON.stringify(files)));
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=assets-pack.js.map
|
package/dist/assets-pack.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assets-pack.js","sourceRoot":"","sources":["../src/assets-pack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,SAAS,IAAI,CAAC,GAAW,EAAE,IAAY,EAAE,GAAgB;IACvD,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAC5B,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;YAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;aAClD,CAAC;YACJ,GAAG,CAAC,IAAI,CAAC;gBACP,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAChD,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;aACrD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,aAAqB;IAC9C,MAAM,KAAK,GAAgB,EAAE,CAAA;IAC7B,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,CAAC,CAAA;IACzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACnC,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC"}
|
package/dist/build.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/build.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEzE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/client.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Client SPA build helpers. The source dir is adapter env config, not domain config. */
|
|
2
|
-
import type { DomainInfo } from '@astrale-os/sdk';
|
|
3
|
-
export type ClientConfig = {
|
|
4
|
-
/** Vite project directory, relative to the domain project root unless absolute. */
|
|
5
|
-
dir: string;
|
|
6
|
-
};
|
|
7
|
-
/** Built client output, relative to the project root. The Vite config must emit here. */
|
|
8
|
-
export declare const CLIENT_DIST_DIR = ".dist";
|
|
9
|
-
export declare function resolveClientDir(args: {
|
|
10
|
-
adapterName: string;
|
|
11
|
-
env: string;
|
|
12
|
-
projectDir: string;
|
|
13
|
-
client?: ClientConfig;
|
|
14
|
-
domain: DomainInfo;
|
|
15
|
-
}): string | undefined;
|
|
16
|
-
export declare function buildClient(clientDir: string, projectDir: string, onLog?: (line: string) => void): Promise<void>;
|
|
17
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAMjD,MAAM,MAAM,YAAY,GAAG;IACzB,mFAAmF;IACnF,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,yFAAyF;AACzF,eAAO,MAAM,eAAe,UAAU,CAAA;AAEtC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,MAAM,GAAG,SAAS,CAoBrB;AAMD,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,IAAI,CAAC,CAef"}
|
package/dist/client.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/** Client SPA build helpers. The source dir is adapter env config, not domain config. */
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
import { isAbsolute, join } from 'node:path';
|
|
5
|
-
/** Built client output, relative to the project root. The Vite config must emit here. */
|
|
6
|
-
export const CLIENT_DIST_DIR = '.dist';
|
|
7
|
-
export function resolveClientDir(args) {
|
|
8
|
-
const { adapterName, projectDir, client, domain } = args;
|
|
9
|
-
for (const view of domain.mountedViews) {
|
|
10
|
-
if (!isUiMount(view.mount)) {
|
|
11
|
-
throw new Error(`${adapterName} adapter: mounted view "${view.slug}" uses mount "${view.mount}", ` +
|
|
12
|
-
'but adapter-managed client assets currently serve only /ui routes.');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (domain.mountedViews.length > 0 && !client) {
|
|
16
|
-
const mounts = domain.mountedViews.map((v) => `${v.slug}:${v.mount}`).join(', ');
|
|
17
|
-
throw new Error(`${adapterName} adapter: ${domain.origin} declares mounted view(s) (${mounts}) ` +
|
|
18
|
-
`but env "${args.env}" has no \`client: { dir: ... }\` config. ` +
|
|
19
|
-
'Add `client` to the selected adapter env in astrale.config.ts.');
|
|
20
|
-
}
|
|
21
|
-
if (!client)
|
|
22
|
-
return undefined;
|
|
23
|
-
return isAbsolute(client.dir) ? client.dir : join(projectDir, client.dir);
|
|
24
|
-
}
|
|
25
|
-
function isUiMount(mount) {
|
|
26
|
-
return mount === '/ui' || mount.startsWith('/ui/');
|
|
27
|
-
}
|
|
28
|
-
export async function buildClient(clientDir, projectDir, onLog) {
|
|
29
|
-
const viteBin = [
|
|
30
|
-
join(clientDir, 'node_modules', '.bin', 'vite'),
|
|
31
|
-
join(projectDir, 'node_modules', '.bin', 'vite'),
|
|
32
|
-
].find((p) => existsSync(p));
|
|
33
|
-
if (!viteBin) {
|
|
34
|
-
throw new Error(`client build: vite not found in ${clientDir}. Run \`pnpm install\` at the project root ` +
|
|
35
|
-
`first.`);
|
|
36
|
-
}
|
|
37
|
-
const { code, out } = await runCapture(viteBin, ['build'], clientDir, onLog);
|
|
38
|
-
if (code !== 0) {
|
|
39
|
-
throw new Error(`client build failed (code ${code}):\n${out.slice(-1500)}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function runCapture(cmd, args, cwd, onLog) {
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
const child = spawn(cmd, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
45
|
-
let out = '';
|
|
46
|
-
const onData = (buf) => {
|
|
47
|
-
const text = buf.toString();
|
|
48
|
-
out += text;
|
|
49
|
-
for (const line of text.split('\n'))
|
|
50
|
-
if (line.trim())
|
|
51
|
-
onLog?.(line);
|
|
52
|
-
};
|
|
53
|
-
child.stdout?.on('data', onData);
|
|
54
|
-
child.stderr?.on('data', onData);
|
|
55
|
-
child.on('exit', (code) => resolve({ code: code ?? 1, out }));
|
|
56
|
-
child.on('error', reject);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAIzF,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAO5C,yFAAyF;AACzF,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAA;AAEtC,MAAM,UAAU,gBAAg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,KAAK,EAAE,CAAC,IAAI,CAAC,CAAA;QACrE,CAAC,CAAA;QACD,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QAC7D,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/codegen/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBtF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/codegen/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAAkB,EAAE,MAAc;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;IAC5C,IAAI,UAAU,CAAC,IAAI,CAAC;QAAE,OAAM;IAE5B,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5E,MAAM,GAAG,GAAG,CAAC,MAAM,SAAS,CAAC,UAAU,CAAC,CAA4B,CAAA;IACpE,GAAG,CAAC,GAAG,GAAG,OAAO,CAAA;IACjB,GAAG,CAAC,GAAG,GAAG,GAAG,MAAM,MAAM,CAAA;IAEzB,MAAM,KAAK,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5C,MAAM,SAAS,CACb,IAAI,EACJ,kDAAkD,MAAM,mCAAmC;QACzF,8BAA8B,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,aAAa,CAC1E,CAAA;IAED,wEAAwE;IACxE,uEAAuE;IACvE,0EAA0E;IAC1E,2DAA2D;IAC3D,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,gFAAgF,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM;QACnG,kBAAkB,MAAM,+DAA+D;QACvF,gGAAgG,CACnG,CAAA;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/codegen/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/codegen/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAC7B,IAA6B,EAC7B,OAAgC;IAEhC,MAAM,GAAG,G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@@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codegen for the Cloudflare Worker entry (`.astrale/worker.gen.ts`).
|
|
3
|
-
*
|
|
4
|
-
* The dev wires the domain ONCE in a worker-safe `domain.ts`
|
|
5
|
-
* (`export const domain = defineDomain({ schema, methods, deps, views,
|
|
6
|
-
* functions })`) and binds it to an adapter in `astrale.config.ts`
|
|
7
|
-
* (`deploy(domain, cloudflare({ … }))`). This generates the
|
|
8
|
-
* `export default { fetch }` plumbing the adapter owns by importing that single
|
|
9
|
-
* `domain` and SPREADING it into `domainWorkerEntry` — so the author's folder
|
|
10
|
-
* layout is irrelevant (any internal organization works as long as `domain.ts`
|
|
11
|
-
* re-exports the wired definition) and the node-only deploy adapter, which lives
|
|
12
|
-
* in `astrale.config.ts`, never enters this worker bundle.
|
|
13
|
-
*
|
|
14
|
-
* Everything the entry needs — schema/methods/deps/views/functions/requires/
|
|
15
|
-
* postInstall — rides on the spread; the only build-time signal left is whether
|
|
16
|
-
* this adapter env serves a client SPA (`hasClient`), which gates the `/ui`
|
|
17
|
-
* asset hook and its import. Key properties:
|
|
18
|
-
*
|
|
19
|
-
* • Per-request `url` = the live serving origin (`scheme://host`). It is passed
|
|
20
|
-
* only to `createRemoteServer({ url })`; the SDK stamps every
|
|
21
|
-
* `binding.remoteUrl` from that single value at spec-build time — so deployed
|
|
22
|
-
* Function nodes point back at THIS worker with zero hardcoded URLs.
|
|
23
|
-
* • Self-issued JWKS: a Worker can't fetch its own hostname; the verifier
|
|
24
|
-
* resolves a credential whose `iss` is this worker from the in-memory key,
|
|
25
|
-
* so no self-fetch is attempted (the worker's JWKS is served as a normal
|
|
26
|
-
* route by createRemoteServer).
|
|
27
|
-
* • Self-binding (autobinding): when a handler calls back into its OWN domain
|
|
28
|
-
* (`ctx.kernel.call` / `ctx.fn.kernel().call`), the redirect resolves to
|
|
29
|
-
* this worker's own host — a forbidden same-host subrequest. We route those
|
|
30
|
-
* through the `SELF` service binding instead.
|
|
31
|
-
* • SPA: `/ui/*` is served from the `ASSETS` binding (or proxied to Vite in
|
|
32
|
-
* dev via `VIEW_DEV_URL`).
|
|
33
|
-
*/
|
|
34
|
-
export interface WorkerCodegenOptions {
|
|
35
|
-
origin: string;
|
|
36
|
-
hasClient: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* When set, the worker routes subrequests to platform INSTANCE hostnames
|
|
39
|
-
* through `<binding>` (a service binding to a router Worker) instead of the
|
|
40
|
-
* public edge — a same-zone Worker→Worker public fetch 522s, which otherwise
|
|
41
|
-
* blocks fetching an instance kernel's JWKS to verify a cross-instance
|
|
42
|
-
* credential.
|
|
43
|
-
*/
|
|
44
|
-
router?: {
|
|
45
|
-
binding: string;
|
|
46
|
-
hostSuffix: string;
|
|
47
|
-
minLabels: number;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export declare function generateWorkerEntry(opts: WorkerCodegenOptions): string;
|
|
51
|
-
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/codegen/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;IAClB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CACpE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAwFtE"}
|