@astrale-os/adapter-cloudflare 0.5.0-beta.23 → 0.5.0-beta.231

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.
Files changed (201) hide show
  1. package/README.md +258 -0
  2. package/dist/adapter.d.ts +9 -15
  3. package/dist/adapter.js +43 -129
  4. package/dist/build/bundle/admit.d.ts +3 -0
  5. package/dist/build/bundle/admit.js +47 -0
  6. package/dist/build/bundle/compiled-wasm-loader.d.ts +8 -0
  7. package/dist/build/bundle/compiled-wasm-loader.js +21 -0
  8. package/dist/build/bundler.d.ts +23 -0
  9. package/dist/build/bundler.js +103 -0
  10. package/dist/build/closure.d.ts +4 -1
  11. package/dist/build/closure.js +7 -1
  12. package/dist/build/codegen/execution.d.ts +3 -13
  13. package/dist/build/codegen/execution.js +2 -44
  14. package/dist/build/codegen/wrangler.d.ts +28 -10
  15. package/dist/build/codegen/wrangler.js +71 -21
  16. package/dist/build/configuration/invocation-timeout.d.ts +2 -0
  17. package/dist/build/configuration/invocation-timeout.js +9 -0
  18. package/dist/build/configuration/request-limit.d.ts +2 -0
  19. package/dist/build/configuration/request-limit.js +9 -0
  20. package/dist/build/configuration/router.d.ts +7 -0
  21. package/dist/build/configuration/router.js +17 -0
  22. package/dist/build/configuration/settings.d.ts +6 -0
  23. package/dist/build/configuration/settings.js +40 -0
  24. package/dist/build/configuration.d.ts +4 -9
  25. package/dist/build/configuration.js +4 -40
  26. package/dist/build/frontend/files.d.ts +19 -0
  27. package/dist/build/frontend/files.js +99 -0
  28. package/dist/build/frontend/readiness.d.ts +16 -0
  29. package/dist/build/frontend/readiness.js +21 -0
  30. package/dist/build/frontend/revision.d.ts +5 -0
  31. package/dist/build/frontend/revision.js +14 -0
  32. package/dist/build/frontend/vite.d.ts +14 -0
  33. package/dist/build/frontend/vite.js +42 -0
  34. package/dist/build/frontend/vite.process.d.ts +7 -0
  35. package/dist/build/frontend/vite.process.js +65 -0
  36. package/dist/build/frontend/vite.runner.d.ts +1 -0
  37. package/dist/build/frontend/vite.runner.js +155 -0
  38. package/dist/build/index.d.ts +10 -6
  39. package/dist/build/index.js +10 -6
  40. package/dist/build/material.d.ts +10 -0
  41. package/dist/build/material.js +25 -0
  42. package/dist/build/worker/codegen/entry.d.ts +9 -0
  43. package/dist/build/worker/codegen/entry.js +65 -0
  44. package/dist/build/worker/codegen/literal.d.ts +28 -0
  45. package/dist/build/worker/codegen/literal.js +136 -0
  46. package/dist/build/worker/codegen/service.d.ts +14 -0
  47. package/dist/build/worker/codegen/service.js +56 -0
  48. package/dist/build/worker/execution.prepare.d.ts +22 -0
  49. package/dist/build/worker/execution.prepare.js +131 -0
  50. package/dist/build/worker/media-type.d.ts +1 -0
  51. package/dist/build/worker/media-type.js +20 -0
  52. package/dist/build/worker/modules.d.ts +20 -0
  53. package/dist/build/worker/modules.js +32 -0
  54. package/dist/build/worker/specifier.d.ts +5 -0
  55. package/dist/build/worker/specifier.js +15 -0
  56. package/dist/build/worker/upload.d.ts +23 -0
  57. package/dist/build/worker/upload.js +42 -0
  58. package/dist/hosting/activation.d.ts +46 -0
  59. package/dist/hosting/activation.js +127 -0
  60. package/dist/hosting/assets.d.ts +14 -0
  61. package/dist/hosting/assets.js +53 -0
  62. package/dist/hosting/bounded.d.ts +10 -0
  63. package/dist/hosting/bounded.js +32 -0
  64. package/dist/hosting/bytes.d.ts +6 -0
  65. package/dist/hosting/bytes.js +25 -0
  66. package/dist/hosting/client.d.ts +153 -0
  67. package/dist/hosting/client.js +516 -0
  68. package/dist/hosting/dispatcher/cron.d.mts +10 -0
  69. package/dist/hosting/dispatcher/cron.mjs +135 -0
  70. package/dist/hosting/dispatcher/deployments.d.mts +26 -0
  71. package/dist/hosting/dispatcher/deployments.mjs +158 -0
  72. package/dist/hosting/dispatcher/dispatcher.d.mts +17 -0
  73. package/dist/hosting/dispatcher/dispatcher.mjs +76 -0
  74. package/dist/hosting/dispatcher/env.d.mts +51 -0
  75. package/dist/hosting/dispatcher/failure.d.mts +4 -0
  76. package/dist/hosting/dispatcher/failure.mjs +15 -0
  77. package/dist/hosting/dispatcher/index.d.mts +4 -0
  78. package/dist/hosting/dispatcher/index.mjs +8 -0
  79. package/dist/hosting/dispatcher/modules.d.ts +24 -0
  80. package/dist/hosting/dispatcher/modules.js +55 -0
  81. package/dist/hosting/dispatcher/services.d.mts +23 -0
  82. package/dist/hosting/dispatcher/services.mjs +202 -0
  83. package/dist/hosting/identity.d.ts +15 -0
  84. package/dist/hosting/identity.js +36 -0
  85. package/dist/hosting/index.d.ts +34 -0
  86. package/dist/hosting/index.js +32 -0
  87. package/dist/hosting/kv.d.ts +106 -0
  88. package/dist/hosting/kv.js +235 -0
  89. package/dist/hosting/listing.d.ts +34 -0
  90. package/dist/hosting/listing.js +49 -0
  91. package/dist/hosting/names.d.ts +16 -0
  92. package/dist/hosting/names.js +28 -0
  93. package/dist/hosting/provision/account.d.ts +11 -0
  94. package/dist/hosting/provision/account.js +86 -0
  95. package/dist/hosting/provision/dispatcher.d.ts +42 -0
  96. package/dist/hosting/provision/dispatcher.js +99 -0
  97. package/dist/hosting/provision/ingress.d.ts +12 -0
  98. package/dist/hosting/provision/ingress.js +31 -0
  99. package/dist/hosting/provision/plan.d.ts +143 -0
  100. package/dist/hosting/provision/plan.js +246 -0
  101. package/dist/hosting/provision/routing.d.ts +82 -0
  102. package/dist/hosting/provision/routing.js +226 -0
  103. package/dist/hosting/readiness.d.ts +53 -0
  104. package/dist/hosting/readiness.js +79 -0
  105. package/dist/hosting/refusal.d.ts +28 -0
  106. package/dist/hosting/refusal.js +13 -0
  107. package/dist/hosting/retirement.d.ts +68 -0
  108. package/dist/hosting/retirement.js +99 -0
  109. package/dist/hosting/retry-after.d.ts +6 -0
  110. package/dist/hosting/retry-after.js +55 -0
  111. package/dist/hosting/script.d.ts +186 -0
  112. package/dist/hosting/script.js +324 -0
  113. package/dist/hosting/testing/fake-cloudflare.d.ts +212 -0
  114. package/dist/hosting/testing/fake-cloudflare.js +757 -0
  115. package/dist/hosting/testing/index.d.ts +6 -0
  116. package/dist/hosting/testing/index.js +6 -0
  117. package/dist/hosting/time.d.ts +25 -0
  118. package/dist/hosting/time.js +48 -0
  119. package/dist/identity/binding.d.ts +1 -1
  120. package/dist/identity/binding.js +1 -1
  121. package/dist/identity/material.d.ts +1 -2
  122. package/dist/identity/material.js +5 -18
  123. package/dist/index.d.ts +14 -12
  124. package/dist/index.js +13 -11
  125. package/dist/namespace/configure.d.ts +22 -0
  126. package/dist/namespace/configure.js +199 -0
  127. package/dist/namespace/coordinates.d.ts +15 -0
  128. package/dist/namespace/coordinates.js +49 -0
  129. package/dist/namespace/deploy-release.d.ts +53 -0
  130. package/dist/namespace/deploy-release.js +387 -0
  131. package/dist/namespace/hosting.d.ts +29 -0
  132. package/dist/namespace/hosting.js +120 -0
  133. package/dist/namespace/index.d.ts +12 -0
  134. package/dist/namespace/index.js +12 -0
  135. package/dist/namespace/list.d.ts +18 -0
  136. package/dist/namespace/list.js +63 -0
  137. package/dist/namespace/readiness.d.ts +32 -0
  138. package/dist/namespace/readiness.js +35 -0
  139. package/dist/namespace/record.d.ts +21 -0
  140. package/dist/namespace/record.js +53 -0
  141. package/dist/params.d.ts +60 -76
  142. package/dist/release/build.d.ts +35 -0
  143. package/dist/release/build.js +44 -0
  144. package/dist/release/deployment.d.ts +44 -0
  145. package/dist/release/deployment.js +141 -0
  146. package/dist/release/index.d.ts +2 -2
  147. package/dist/release/index.js +2 -2
  148. package/dist/worker/binary.d.ts +21 -0
  149. package/dist/worker/binary.js +31 -0
  150. package/dist/worker/build-digest.d.ts +10 -0
  151. package/dist/worker/build-digest.js +22 -0
  152. package/dist/worker/cache.d.ts +28 -0
  153. package/dist/worker/cache.js +70 -0
  154. package/dist/worker/durable.d.ts +3 -0
  155. package/dist/worker/durable.js +5 -0
  156. package/dist/worker/entry.d.ts +38 -25
  157. package/dist/worker/entry.js +87 -109
  158. package/dist/worker/front.d.ts +56 -0
  159. package/dist/worker/front.js +59 -0
  160. package/dist/worker/frontend.d.ts +4 -0
  161. package/dist/worker/frontend.js +83 -0
  162. package/dist/worker/index.d.ts +4 -1
  163. package/dist/worker/index.js +4 -1
  164. package/dist/worker/restate.d.ts +6 -0
  165. package/dist/worker/restate.js +6 -0
  166. package/dist/worker/settings.d.ts +47 -0
  167. package/dist/worker/settings.js +163 -0
  168. package/dist/wrangler/bundle.d.ts +18 -0
  169. package/dist/wrangler/bundle.js +36 -0
  170. package/dist/wrangler/index.d.ts +3 -0
  171. package/dist/wrangler/index.js +3 -0
  172. package/dist/wrangler/process.d.ts +15 -0
  173. package/dist/wrangler/process.js +113 -0
  174. package/dist/wrangler/type-generation.d.ts +6 -0
  175. package/dist/wrangler/type-generation.js +19 -0
  176. package/package.json +36 -14
  177. package/template/astrale.config.ts +42 -36
  178. package/dist/build/artifact.d.ts +0 -8
  179. package/dist/build/artifact.js +0 -179
  180. package/dist/build/codegen/gateway.d.ts +0 -1
  181. package/dist/build/codegen/gateway.js +0 -7
  182. package/dist/build/frontend-v1.d.ts +0 -16
  183. package/dist/build/frontend-v1.js +0 -133
  184. package/dist/build/parse-output.d.ts +0 -26
  185. package/dist/build/parse-output.js +0 -57
  186. package/dist/build/wrangler-cli.d.ts +0 -105
  187. package/dist/build/wrangler-cli.js +0 -448
  188. package/dist/deploy/deploy.d.ts +0 -17
  189. package/dist/deploy/deploy.js +0 -207
  190. package/dist/deploy/index.d.ts +0 -1
  191. package/dist/deploy/index.js +0 -1
  192. package/dist/identity/secret.d.ts +0 -3
  193. package/dist/identity/secret.js +0 -7
  194. package/dist/identity/source.d.ts +0 -26
  195. package/dist/identity/source.js +0 -98
  196. package/dist/release/namespace.d.ts +0 -2
  197. package/dist/release/namespace.js +0 -6
  198. package/dist/release/target.d.ts +0 -2
  199. package/dist/release/target.js +0 -9
  200. package/dist/worker/gateway.d.ts +0 -15
  201. package/dist/worker/gateway.js +0 -26
@@ -1,26 +0,0 @@
1
- import { SIGNING_IDENTITY_BINDING } from './binding.js';
2
- export interface SigningIdentitySource {
3
- readonly binding: typeof SIGNING_IDENTITY_BINDING;
4
- readonly path: string;
5
- readonly secret: string;
6
- readonly keyId: string;
7
- }
8
- export interface SigningIdentityInput {
9
- readonly projectDir: string;
10
- readonly origin: string;
11
- readonly source?: string;
12
- readonly mode: 'local' | 'deploy';
13
- }
14
- /** Resolve one admitted execution identity for local or remote provider custody. */
15
- export declare function signingIdentity(input: SigningIdentityInput): Promise<SigningIdentitySource>;
16
- /**
17
- * Read an explicitly retained deployment identity. Deployment never generates
18
- * one: a missing file is a pre-provider configuration failure, not an implicit
19
- * key rotation.
20
- */
21
- export declare function readSigningIdentity(projectDir: string, declaration: string | undefined): Promise<SigningIdentitySource>;
22
- /**
23
- * Resolve local development identity. The default is generated once inside
24
- * `.astrale`; an explicit source is always read-only and must already exist.
25
- */
26
- export declare function localSigningIdentity(projectDir: string, declaration: string | undefined, origin: string): Promise<SigningIdentitySource>;
@@ -1,98 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
- import { dirname, isAbsolute, join, resolve } from 'node:path';
4
- import { SIGNING_IDENTITY_BINDING } from './binding.js';
5
- import { admitSigningIdentity, createSigningIdentity } from './material.js';
6
- const DEFAULT_IDENTITY = join('.astrale', 'identity.json');
7
- /** Resolve one admitted execution identity for local or remote provider custody. */
8
- export function signingIdentity(input) {
9
- return input.mode === 'local'
10
- ? localSigningIdentity(input.projectDir, input.source, input.origin)
11
- : readSigningIdentity(input.projectDir, input.source);
12
- }
13
- /**
14
- * Read an explicitly retained deployment identity. Deployment never generates
15
- * one: a missing file is a pre-provider configuration failure, not an implicit
16
- * key rotation.
17
- */
18
- export async function readSigningIdentity(projectDir, declaration) {
19
- if (declaration === undefined || declaration.length === 0) {
20
- throw new TypeError("Cloudflare deployment requires 'signingIdentity: <private-jwk-file>'. " +
21
- 'Run local development once to create .astrale/identity.json, then retain that file in managed secret storage.');
22
- }
23
- return readSource(pathOf(projectDir, declaration), declaration);
24
- }
25
- /**
26
- * Resolve local development identity. The default is generated once inside
27
- * `.astrale`; an explicit source is always read-only and must already exist.
28
- */
29
- export async function localSigningIdentity(projectDir, declaration, origin) {
30
- if (declaration !== undefined)
31
- return readSource(pathOf(projectDir, declaration), declaration);
32
- const path = join(projectDir, DEFAULT_IDENTITY);
33
- if (!existsSync(path)) {
34
- const legacy = join(projectDir, '.astrale', 'identity.ts');
35
- if (existsSync(legacy))
36
- await migrateLegacyIdentity(legacy, path, origin);
37
- else
38
- await generateIdentity(path);
39
- }
40
- return readSource(path, DEFAULT_IDENTITY);
41
- }
42
- async function generateIdentity(path) {
43
- const value = await createSigningIdentity();
44
- await mkdir(dirname(path), { recursive: true });
45
- await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
46
- process.stderr.write(`\x1b[33m!\x1b[0m new signing identity generated at .astrale/identity.json (kid ${value.kid}).\n` +
47
- ` Retain it in managed secret storage before deploying; remote deploy fails closed without an explicit identity file.\n`);
48
- }
49
- async function migrateLegacyIdentity(legacy, destination, origin) {
50
- const source = await readFile(legacy, 'utf8');
51
- const match = /export const PRIVATE_JWK = (\{[\s\S]*\}) as const\n?$/u.exec(source);
52
- if (match?.[1] === undefined)
53
- throw invalidIdentity(legacy);
54
- let decoded;
55
- try {
56
- decoded = JSON.parse(match[1]);
57
- }
58
- catch (cause) {
59
- throw invalidIdentity(legacy, cause);
60
- }
61
- const value = await admitSigningIdentity(decoded, legacy, `${origin}-key`);
62
- await mkdir(dirname(destination), { recursive: true });
63
- await writeFile(destination, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
64
- process.stderr.write(`\x1b[33m!\x1b[0m migrated .astrale/identity.ts to secret-backed .astrale/identity.json (kid ${value.kid}).\n`);
65
- }
66
- async function readSource(path, declaration) {
67
- let source;
68
- try {
69
- source = await readFile(path, 'utf8');
70
- }
71
- catch (cause) {
72
- if (!(cause instanceof Error && 'code' in cause && cause.code === 'ENOENT'))
73
- throw cause;
74
- throw new TypeError(`Cloudflare signing identity '${declaration}' is missing at ${path}.`, {
75
- cause,
76
- });
77
- }
78
- let decoded;
79
- try {
80
- decoded = JSON.parse(source);
81
- }
82
- catch (cause) {
83
- throw invalidIdentity(declaration, cause);
84
- }
85
- const value = await admitSigningIdentity(decoded, declaration);
86
- return Object.freeze({
87
- binding: SIGNING_IDENTITY_BINDING,
88
- path,
89
- secret: JSON.stringify(value),
90
- keyId: value.kid,
91
- });
92
- }
93
- function pathOf(projectDir, declaration) {
94
- return isAbsolute(declaration) ? declaration : resolve(projectDir, declaration);
95
- }
96
- function invalidIdentity(owner, cause) {
97
- return new TypeError(`Cloudflare signing identity '${owner}' is not a private Ed25519 JWK.`, cause === undefined ? undefined : { cause });
98
- }
@@ -1,2 +0,0 @@
1
- /** One private dispatch namespace per stable public Worker. */
2
- export declare function releaseNamespace(worker: string): string;
@@ -1,6 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- /** One private dispatch namespace per stable public Worker. */
3
- export function releaseNamespace(worker) {
4
- const digest = createHash('sha256').update(worker).digest('hex');
5
- return `astrale-${digest.slice(0, 24)}`;
6
- }
@@ -1,2 +0,0 @@
1
- /** Exact Schema revisions select stable Workers inside the private namespace. */
2
- export declare function releaseWorkerName(revision: string): string;
@@ -1,9 +0,0 @@
1
- const REVISION = /^sha256:([0-9a-f]{64})$/u;
2
- /** Exact Schema revisions select stable Workers inside the private namespace. */
3
- export function releaseWorkerName(revision) {
4
- const digest = REVISION.exec(revision)?.[1];
5
- if (digest === undefined)
6
- throw new TypeError('Cloudflare Release revision is invalid.');
7
- const encoded = BigInt(`0x${digest}`).toString(36).padStart(50, '0');
8
- return `r-${encoded}`;
9
- }
@@ -1,15 +0,0 @@
1
- import type { Revision } from '@astrale-os/sdk/schema';
2
- export interface DispatchNamespace {
3
- get(name: string): {
4
- fetch(request: Request): Response | Promise<Response>;
5
- };
6
- }
7
- export interface CloudflareGatewayBindings {
8
- readonly RELEASES: DispatchNamespace;
9
- }
10
- /** Stable public Worker that selects one exact immutable Schema-revision Service. */
11
- export declare function cloudflareGatewayEntry(config: {
12
- readonly current: Revision;
13
- }): {
14
- fetch(request: Request, bindings: CloudflareGatewayBindings): Promise<Response>;
15
- };
@@ -1,26 +0,0 @@
1
- import { releaseUnavailable, requestedRevision } from '@astrale-os/sdk/deployment/release/runtime';
2
- import { releaseWorkerName } from '../release/target.js';
3
- /** Stable public Worker that selects one exact immutable Schema-revision Service. */
4
- export function cloudflareGatewayEntry(config) {
5
- const current = releaseWorkerName(config.current);
6
- return Object.freeze({
7
- async fetch(request, bindings) {
8
- const revision = requestedRevision(new URL(request.url).pathname);
9
- const target = revision === undefined ? current : releaseWorkerName(revision);
10
- let worker;
11
- try {
12
- worker = bindings.RELEASES.get(target);
13
- }
14
- catch (cause) {
15
- if (isMissingWorker(cause))
16
- return releaseUnavailable();
17
- throw cause;
18
- }
19
- return worker.fetch(request);
20
- },
21
- });
22
- }
23
- /** Admit only Cloudflare's documented missing-script failure at the provider boundary. */
24
- function isMissingWorker(cause) {
25
- return cause instanceof Error && /^Worker not found(?:\b|:)/iu.test(cause.message);
26
- }