@astrale-os/adapter-cloudflare 0.5.0-beta.22 → 0.5.0-beta.221

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 +246 -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 +21 -0
  9. package/dist/build/bundler.js +96 -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 +57 -0
  48. package/dist/build/worker/execution.prepare.d.ts +20 -0
  49. package/dist/build/worker/execution.prepare.js +129 -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 +144 -0
  67. package/dist/hosting/client.js +491 -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 +90 -0
  88. package/dist/hosting/kv.js +207 -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 +82 -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 +4 -0
  118. package/dist/hosting/time.js +20 -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 +386 -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 +30 -0
  138. package/dist/namespace/readiness.js +31 -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 +10 -0
  169. package/dist/wrangler/bundle.js +27 -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
@@ -0,0 +1,212 @@
1
+ import type { Dispatcher } from '../dispatcher/dispatcher.mjs';
2
+ import type { DispatcherEnvironment } from '../dispatcher/env.mjs';
3
+ export declare const FAKE_ACCOUNT = "0123456789abcdef0123456789abcdef";
4
+ export declare const FAKE_TOKEN = "hosting-test-token";
5
+ export declare const FAKE_API_BASE = "https://api.cloudflare.test/client/v4";
6
+ export declare const FAKE_ZONE = "fake-zone";
7
+ /** One binding as an upload's metadata declares it, secret values included. */
8
+ export type FakeBinding = Readonly<Record<string, unknown>> & {
9
+ readonly type: string;
10
+ readonly name: string;
11
+ };
12
+ /** One script of a fake dispatch namespace, as Cloudflare keeps it. */
13
+ export interface FakeScript {
14
+ readonly name: string;
15
+ readonly namespace: string;
16
+ readonly etag: string;
17
+ /** The current provider version (`deployment_id`), in Cloudflare's compact form. */
18
+ version: string;
19
+ readonly createdOn: string;
20
+ readonly tags: readonly string[];
21
+ readonly compatibilityDate: string;
22
+ readonly compatibilityFlags: readonly string[];
23
+ readonly mainModule: string;
24
+ readonly modules: ReadonlyMap<string, {
25
+ readonly type: string;
26
+ readonly bytes: Uint8Array;
27
+ }>;
28
+ readonly assets: ReadonlyMap<string, Uint8Array>;
29
+ bindings: FakeBinding[];
30
+ /**
31
+ * The version a secret write replaced, which the namespace still serves for `requests` more
32
+ * calls: Cloudflare propagates a new version in about 4 s (OPS-2 X1).
33
+ */
34
+ stale?: {
35
+ version: string;
36
+ bindings: FakeBinding[];
37
+ requests: number;
38
+ };
39
+ }
40
+ /** One account Worker (a dispatcher), as its upload declared it. */
41
+ export interface FakeWorker {
42
+ readonly metadata: Readonly<Record<string, unknown>> & {
43
+ readonly bindings: readonly FakeBinding[];
44
+ readonly main_module: string;
45
+ };
46
+ readonly modules: ReadonlyMap<string, {
47
+ readonly type: string;
48
+ readonly bytes: Uint8Array;
49
+ }>;
50
+ schedules: readonly {
51
+ readonly cron: string;
52
+ }[];
53
+ subdomain?: {
54
+ readonly enabled: boolean;
55
+ readonly previews_enabled: boolean;
56
+ };
57
+ }
58
+ /** One API request as the fake received it. Secret values appear only in `body`. */
59
+ export interface RecordedRequest {
60
+ readonly method: string;
61
+ /** The path below `/accounts/<account>`, or from `/zones` on, with its query. */
62
+ readonly path: string;
63
+ readonly ifNoneMatch?: string;
64
+ readonly status: number;
65
+ readonly body?: unknown;
66
+ }
67
+ /** What runs a namespace script for one request. */
68
+ export type ScriptRunner = (request: Request, script: {
69
+ readonly name: string;
70
+ readonly namespace: string;
71
+ /** The version serving this call, in UUID form. */
72
+ readonly version: string;
73
+ readonly bindings: readonly FakeBinding[];
74
+ readonly script: FakeScript;
75
+ }) => Promise<Response>;
76
+ export interface FakeCloudflareOptions {
77
+ readonly account?: string;
78
+ readonly token?: string;
79
+ /**
80
+ * Runs a namespace script. Default: 200 `script <name>`, answered with its version as
81
+ * `x-astrale-worker-version`, as a generated Worker reports it.
82
+ */
83
+ readonly runScript?: ScriptRunner;
84
+ /**
85
+ * The dispatcher code every account Worker that binds `DEPLOYMENTS` runs. Default: the kit's own
86
+ * (`dispatcher/index.mjs`); a consumer can pass its own dispatcher.
87
+ */
88
+ readonly dispatcher?: Dispatcher<DispatcherEnvironment & Record<string, unknown>>;
89
+ /** KV namespaces per page of the namespace listing, to page it. */
90
+ readonly kvPageSize?: number;
91
+ /** Keys per page of a KV key listing, to page it by its cursor. */
92
+ readonly kvKeysPageSize?: number;
93
+ }
94
+ interface KvNamespace {
95
+ readonly id: string;
96
+ readonly title: string;
97
+ readonly values: Map<string, string>;
98
+ /** The metadata a value was written with; a value written without has none. */
99
+ readonly metadata: Map<string, unknown>;
100
+ }
101
+ interface Zone {
102
+ readonly id: string;
103
+ readonly name: string;
104
+ readonly dns: {
105
+ id: string;
106
+ type: string;
107
+ name: string;
108
+ content: string;
109
+ proxied: boolean;
110
+ comment?: string;
111
+ }[];
112
+ readonly routes: {
113
+ id: string;
114
+ pattern: string;
115
+ script?: string;
116
+ }[];
117
+ }
118
+ /**
119
+ * One fake Cloudflare account: dispatch namespaces and their scripts (create-only uploads, asset
120
+ * sessions, secrets, settings, deletion), Workers KV, account Workers with their settings,
121
+ * schedules and workers.dev, zones with DNS records and Worker routes, and Workers custom domains.
122
+ * It answers as the OPS-2 transcripts recorded Cloudflare: a create-only upload over an existing
123
+ * script answers 412 with code 10018; a secret PUT keeps the script's etag and tags, mints a new
124
+ * `deployment_id` and answers only `{ name, type }`.
125
+ *
126
+ * A request to any other host is a public request: the zone route that matches it names an account
127
+ * Worker, which runs the REAL kit dispatcher (or the consumer's) over the bindings its upload
128
+ * declared — `DEPLOYMENTS` reaching the namespace's scripts, `SCHEDULES` the KV, `CALLS` recording
129
+ * data points (Analytics Engine is otherwise a no-op). Every API request is recorded.
130
+ */
131
+ export declare class FakeCloudflare {
132
+ readonly account: string;
133
+ readonly token: string;
134
+ readonly requests: RecordedRequest[];
135
+ /** Requests to fail before they reach the fake, by `METHOD path` (as recorded). */
136
+ readonly failures: Map<string, Response>;
137
+ readonly namespaces: Map<string, Map<string, FakeScript>>;
138
+ readonly kvs: KvNamespace[];
139
+ readonly workers: Map<string, FakeWorker>;
140
+ readonly zones: Map<string, Zone>;
141
+ readonly customDomains: {
142
+ hostname: string;
143
+ service?: string;
144
+ }[];
145
+ /** The data points the dispatchers wrote to their `CALLS` datasets. */
146
+ readonly points: {
147
+ readonly dataset: string;
148
+ readonly indexes: readonly string[];
149
+ }[];
150
+ /** How many dispatched calls still reach the previous version after a secret write. */
151
+ propagation: number;
152
+ /** The clock scripts are created on. */
153
+ now: () => number;
154
+ private readonly options;
155
+ private readonly assetSessions;
156
+ private readonly assetUploads;
157
+ private readonly completions;
158
+ private sequence;
159
+ constructor(options?: FakeCloudflareOptions);
160
+ /**
161
+ * A fake account with one hosting already provisioned, as `provisionHosting` leaves it: the
162
+ * namespace, its routing KV under the derived title (after `otherKvs` other KV namespaces), the
163
+ * dispatcher Worker bound to both and to the calls dataset, and the zone's wildcard route to it.
164
+ */
165
+ static provisioned(hosting: {
166
+ readonly namespace: string;
167
+ readonly routingDomain: string;
168
+ readonly worker?: string;
169
+ readonly otherKvs?: number;
170
+ /** Default: the derived title; another title leaves the namespace unprovisioned for a deployer. */
171
+ readonly routingKvTitle?: string;
172
+ }, options?: FakeCloudflareOptions): Promise<FakeCloudflare>;
173
+ /** Add one KV namespace; its id is derived from its title. */
174
+ addKv(title: string): KvNamespace;
175
+ /** Add one zone named `name` (the fake's first zone is `FAKE_ZONE`). */
176
+ addZone(name: string): Zone;
177
+ /**
178
+ * The values of the KV namespace titled `title` (or with that id), as UTF-8 text: the fake keeps
179
+ * UTF-8 values only. A value set here keeps the metadata its key already has (`kvMetadata`), and
180
+ * a new key has none: a deployment record set here needs its `{"contentType":...}` set there too,
181
+ * or the kit refuses it as no record it writes.
182
+ */
183
+ kv(titleOrId: string): Map<string, string>;
184
+ /** The metadata of the values of the KV namespace titled `title` (or with that id), by key. */
185
+ kvMetadata(titleOrId: string): Map<string, unknown>;
186
+ private kvNamespace;
187
+ /** The scripts of one dispatch namespace. */
188
+ scripts(namespace: string): Map<string, FakeScript>;
189
+ /** A provider version in the UUID form a Worker's version metadata reports. */
190
+ static uuid(version: string): string;
191
+ /** Every request, to the API or to a public host. */
192
+ readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
193
+ /** Fire one account Worker's `scheduled` handler, as its cron trigger would. */
194
+ scheduled(worker: string, scheduledTime: number): Promise<void>;
195
+ private dispatcher;
196
+ /** Answer one public request: the zone route matching its host runs its Worker. */
197
+ private publicRequest;
198
+ /** The environment an account Worker runs with: its upload's bindings, live. */
199
+ private environment;
200
+ private namespaceBinding;
201
+ private kvBinding;
202
+ /** Run one script for one call, from its stale version while a secret write propagates. */
203
+ private run;
204
+ private api;
205
+ private route;
206
+ private script;
207
+ private accountWorker;
208
+ private zoneRoute;
209
+ private version;
210
+ private id;
211
+ }
212
+ export {};