@void/platform 0.20.0

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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/dist/index.d.mts +264 -0
  4. package/dist/index.mjs +895 -0
  5. package/dist/installer.d.mts +49 -0
  6. package/dist/installer.mjs +176 -0
  7. package/dist/runtime/api/README.md +1 -0
  8. package/dist/runtime/api/index.js +70824 -0
  9. package/dist/runtime/api/index.js.map +8 -0
  10. package/dist/runtime/dispatch/README.md +1 -0
  11. package/dist/runtime/dispatch/index.js +3289 -0
  12. package/dist/runtime/dispatch/index.js.map +8 -0
  13. package/dist/runtime/drizzle/0000_confused_starjammers.sql +66 -0
  14. package/dist/runtime/drizzle/0001_famous_magus.sql +15 -0
  15. package/dist/runtime/drizzle/0002_glorious_morgan_stark.sql +17 -0
  16. package/dist/runtime/drizzle/0003_awesome_ares.sql +3 -0
  17. package/dist/runtime/drizzle/0004_talented_mimic.sql +1 -0
  18. package/dist/runtime/drizzle/0005_legal_red_ghost.sql +15 -0
  19. package/dist/runtime/drizzle/0006_wonderful_madame_masque.sql +17 -0
  20. package/dist/runtime/drizzle/0007_normal_skin.sql +4 -0
  21. package/dist/runtime/drizzle/0008_auth_codes.sql +5 -0
  22. package/dist/runtime/drizzle/0009_chubby_masked_marvel.sql +1 -0
  23. package/dist/runtime/drizzle/0010_wild_aqueduct.sql +10 -0
  24. package/dist/runtime/drizzle/0011_curly_stryfe.sql +2 -0
  25. package/dist/runtime/drizzle/0012_eminent_mystique.sql +1 -0
  26. package/dist/runtime/drizzle/0013_quick_selene.sql +3 -0
  27. package/dist/runtime/drizzle/0014_mysterious_medusa.sql +1 -0
  28. package/dist/runtime/drizzle/0015_backfill_accepted_invitations.sql +14 -0
  29. package/dist/runtime/drizzle/0016_verified_phoenix.sql +1 -0
  30. package/dist/runtime/drizzle/0017_gorgeous_johnny_blaze.sql +3 -0
  31. package/dist/runtime/drizzle/0018_project_migrations.sql +21 -0
  32. package/dist/runtime/drizzle/0019_project_database_credentials.sql +10 -0
  33. package/dist/runtime/drizzle/0027_github_deploy.sql +82 -0
  34. package/dist/runtime/drizzle/0028_check_runs.sql +1 -0
  35. package/dist/runtime/drizzle/0029_fluffy_justin_hammer.sql +1 -0
  36. package/dist/runtime/drizzle/0030_smooth_marvel_boy.sql +13 -0
  37. package/dist/runtime/drizzle/0031_thankful_madame_masque.sql +9 -0
  38. package/dist/runtime/drizzle/0032_remarkable_skullbuster.sql +10 -0
  39. package/dist/runtime/drizzle/0033_operator_sessions_and_events.sql +21 -0
  40. package/dist/runtime/drizzle/0034_email_destinations.sql +21 -0
  41. package/dist/runtime/drizzle/0035_invitation_actor_history.sql +5 -0
  42. package/dist/runtime/drizzle/0036_flowery_master_chief.sql +2 -0
  43. package/dist/runtime/drizzle/0037_unusual_bloodaxe.sql +14 -0
  44. package/dist/runtime/drizzle/0038_deployment_admission_protocol.sql +25 -0
  45. package/dist/runtime/drizzle/compatibility.json +26 -0
  46. package/dist/runtime/drizzle/meta/_journal.json +230 -0
  47. package/dist/runtime/manifest.json +254 -0
  48. package/dist/runtime/proxy/README.md +1 -0
  49. package/dist/runtime/proxy/index.js +5416 -0
  50. package/dist/runtime/proxy/index.js.map +8 -0
  51. package/dist/runtime/tail/README.md +1 -0
  52. package/dist/runtime/tail/index.js +61 -0
  53. package/dist/runtime/tail/index.js.map +8 -0
  54. package/package.json +40 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,895 @@
1
+ //#region src/manifest.ts
2
+ const PLATFORM_DEPLOYMENT_SCHEMA_VERSION = 1;
3
+ const CORE_CAPABILITIES = {
4
+ ai: true,
5
+ customDomains: false,
6
+ email: false,
7
+ githubActions: false,
8
+ githubOAuth: true,
9
+ googleOAuth: false,
10
+ managedBuilds: false,
11
+ sandbox: false
12
+ };
13
+ const CONTROL_PLANE_DEFAULTS = {
14
+ apiHostname: null,
15
+ dashboardHostname: null,
16
+ proxyHostname: null
17
+ };
18
+ function assertRecord$1(value, label) {
19
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object.`);
20
+ }
21
+ function requiredString$1(value, label) {
22
+ if (typeof value !== "string" || value.trim() === "") throw new Error(`${label} must be a non-empty string.`);
23
+ return value;
24
+ }
25
+ function normalizeInstallationSlug(value) {
26
+ const slug = value.trim().toLowerCase().replaceAll(/[^a-z0-9-]+/g, "-").replaceAll(/^-+|-+$/g, "").replaceAll(/-{2,}/g, "-");
27
+ if (!slug) throw new Error("The installation name must contain a letter or number.");
28
+ if (slug.length > 40) throw new Error("The installation name must be 40 characters or fewer after normalization.");
29
+ return slug;
30
+ }
31
+ function normalizeApplicationDomain(value) {
32
+ let domain = value.trim().toLowerCase();
33
+ if (domain.endsWith(".")) domain = domain.slice(0, -1);
34
+ if (domain.length > 253 || !domain.includes(".") || domain.split(".").some((label) => !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label))) throw new Error(`Invalid domain: ${JSON.stringify(value)}.`);
35
+ return domain;
36
+ }
37
+ function createPlatformResourceNames(installationSlug) {
38
+ const prefix = `void-${normalizeInstallationSlug(installationSlug)}`;
39
+ const datasetPrefix = prefix.replaceAll("-", "_");
40
+ return {
41
+ aiGateway: prefix,
42
+ apiWorker: `${prefix}-api`,
43
+ assetsBucket: `${prefix}-assets`,
44
+ cronQueue: `${prefix}-cron-fires`,
45
+ dashboardWorker: `${prefix}-dashboard`,
46
+ dispatchNamespace: `${prefix}-users`,
47
+ dispatchWorker: `${prefix}-dispatch`,
48
+ hyperdrive: `${prefix}-database`,
49
+ isrCacheKv: `${prefix}-isr-cache`,
50
+ legacyAssetsKv: `${prefix}-legacy-assets`,
51
+ logsDataset: `${datasetPrefix}_logs`,
52
+ proxyWorker: `${prefix}-proxy`,
53
+ requestsDataset: `${datasetPrefix}_requests`,
54
+ routingKv: `${prefix}-routing`,
55
+ tailWorker: `${prefix}-tail`,
56
+ usageQueue: `${prefix}-usage-events`
57
+ };
58
+ }
59
+ function createApplicationRoutes(application) {
60
+ if (!application.zoneName && application.workersDev) {
61
+ if (application.dedicatedZone) throw new Error("workers.dev cannot use a dedicated-zone catch-all.");
62
+ return [];
63
+ }
64
+ const baseDomain = normalizeApplicationDomain(application.baseDomain);
65
+ const zoneName = normalizeApplicationDomain(application.zoneName);
66
+ if (baseDomain !== zoneName && !baseDomain.endsWith(`.${zoneName}`)) throw new Error(`Application domain ${baseDomain} is not inside zone ${zoneName}.`);
67
+ const routes = [{
68
+ pattern: `*.${baseDomain}/*`,
69
+ zoneName
70
+ }, {
71
+ pattern: `*.${baseDomain}`,
72
+ zoneName
73
+ }];
74
+ if (application.dedicatedZone) {
75
+ if (baseDomain !== zoneName) throw new Error("A dedicated-zone catch-all requires the application domain to be the zone.");
76
+ routes.push({
77
+ pattern: "*/*",
78
+ zoneName
79
+ }, {
80
+ pattern: "*",
81
+ zoneName
82
+ });
83
+ }
84
+ return routes;
85
+ }
86
+ function createPlatformDeploymentManifest(input) {
87
+ const installationSlug = normalizeInstallationSlug(input.installationSlug);
88
+ const baseDomain = normalizeApplicationDomain(input.application.baseDomain);
89
+ const workersDev = input.application.workersDev;
90
+ if (workersDev && (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(workersDev.subdomain) || !/^[a-z0-9][a-z0-9-]{0,80}$/.test(workersDev.installationId))) throw new Error("Invalid workers.dev installation identity.");
91
+ const zoneName = workersDev && input.application.zoneName === "" ? "" : normalizeApplicationDomain(input.application.zoneName);
92
+ if (!zoneName && baseDomain !== `${workersDev.subdomain}.workers.dev`) throw new Error("workers.dev application domain must match its account subdomain.");
93
+ const resources = {
94
+ ...createPlatformResourceNames(installationSlug),
95
+ ...input.resources
96
+ };
97
+ const capabilities = {
98
+ ...CORE_CAPABILITIES,
99
+ ...input.capabilities
100
+ };
101
+ if (capabilities.managedBuilds && !capabilities.githubActions) throw new Error("Managed builds require the GitHub Actions capability.");
102
+ const providers = input.authentication?.providers ?? ["github"];
103
+ if (providers.length === 0) throw new Error("At least one authentication provider is required.");
104
+ if (providers.includes("github") !== capabilities.githubOAuth) throw new Error("The GitHub provider and githubOAuth capability must agree.");
105
+ if (providers.includes("google") !== capabilities.googleOAuth) throw new Error("The Google provider and googleOAuth capability must agree.");
106
+ const manifest = {
107
+ application: {
108
+ baseDomain,
109
+ dedicatedZone: input.application.dedicatedZone ?? false,
110
+ zoneName,
111
+ ...workersDev ? { workersDev: { ...workersDev } } : {},
112
+ ...input.application.zoneId ? { zoneId: requiredString$1(input.application.zoneId, "application.zoneId") } : {}
113
+ },
114
+ authentication: { providers: [...providers] },
115
+ capabilities,
116
+ controlPlane: {
117
+ ...CONTROL_PLANE_DEFAULTS,
118
+ ...input.controlPlane
119
+ },
120
+ displayName: requiredString$1(input.displayName, "displayName").trim(),
121
+ installationSlug,
122
+ resources,
123
+ schemaVersion: workersDev ? 2 : 1
124
+ };
125
+ createApplicationRoutes(manifest.application);
126
+ for (const [key, value] of Object.entries(manifest.controlPlane)) {
127
+ if (value !== null) normalizeApplicationDomain(value);
128
+ if (value === "") throw new Error(`controlPlane.${key} must be a hostname or null.`);
129
+ }
130
+ for (const [key, value] of Object.entries(manifest.resources)) requiredString$1(value, `resources.${key}`);
131
+ return manifest;
132
+ }
133
+ function parsePlatformDeploymentManifest(value) {
134
+ assertRecord$1(value, "Platform deployment manifest");
135
+ if (value.schemaVersion !== 1 && value.schemaVersion !== 2) throw new Error(`Unsupported platform deployment schema version: ${String(value.schemaVersion)}.`);
136
+ const application = value.application;
137
+ const authentication = value.authentication;
138
+ const rawCapabilities = value.capabilities;
139
+ const controlPlane = value.controlPlane;
140
+ const rawResources = value.resources;
141
+ assertRecord$1(application, "application");
142
+ let workersDev;
143
+ if (value.schemaVersion === 2) {
144
+ assertRecord$1(application.workersDev, "application.workersDev");
145
+ workersDev = {
146
+ subdomain: requiredString$1(application.workersDev.subdomain, "workersDev.subdomain"),
147
+ installationId: requiredString$1(application.workersDev.installationId, "workersDev.installationId")
148
+ };
149
+ } else if (application.workersDev !== void 0) throw new Error("workers.dev requires platform deployment schema version 2.");
150
+ assertRecord$1(rawCapabilities, "capabilities");
151
+ assertRecord$1(controlPlane, "controlPlane");
152
+ assertRecord$1(authentication, "authentication");
153
+ assertRecord$1(rawResources, "resources");
154
+ const capabilityKeys = Object.keys(CORE_CAPABILITIES);
155
+ const capabilities = {};
156
+ for (const key of capabilityKeys) {
157
+ const entry = rawCapabilities[key];
158
+ if (typeof entry !== "boolean") throw new Error(`capabilities.${key} must be a boolean.`);
159
+ capabilities[key] = entry;
160
+ }
161
+ const providers = authentication.providers;
162
+ if (!Array.isArray(providers) || providers.some((provider) => provider !== "github" && provider !== "google")) throw new Error("authentication.providers must contain only github or google.");
163
+ const resourceDefaults = createPlatformResourceNames(requiredString$1(value.installationSlug, "installationSlug"));
164
+ const resources = {};
165
+ for (const key of Object.keys(resourceDefaults)) resources[key] = requiredString$1(rawResources[key], `resources.${key}`);
166
+ const readHostname = (key) => {
167
+ const hostname = controlPlane[key];
168
+ return hostname === null ? null : requiredString$1(hostname, `controlPlane.${key}`);
169
+ };
170
+ return createPlatformDeploymentManifest({
171
+ application: {
172
+ baseDomain: requiredString$1(application.baseDomain, "application.baseDomain"),
173
+ dedicatedZone: application.dedicatedZone === true,
174
+ zoneName: workersDev && application.zoneName === "" ? "" : requiredString$1(application.zoneName, "application.zoneName"),
175
+ ...workersDev ? { workersDev } : {},
176
+ ...typeof application.zoneId === "string" ? { zoneId: application.zoneId } : {}
177
+ },
178
+ authentication: { providers },
179
+ capabilities,
180
+ controlPlane: {
181
+ apiHostname: readHostname("apiHostname"),
182
+ dashboardHostname: readHostname("dashboardHostname"),
183
+ proxyHostname: readHostname("proxyHostname")
184
+ },
185
+ displayName: requiredString$1(value.displayName, "displayName"),
186
+ installationSlug: requiredString$1(value.installationSlug, "installationSlug"),
187
+ resources
188
+ });
189
+ }
190
+ //#endregion
191
+ //#region src/installation.ts
192
+ const PLATFORM_INSTALLATION_SCHEMA_VERSION = 1;
193
+ const PLATFORM_DISABLED_KEY = "__void/platform/disabled/v1";
194
+ const PLATFORM_DISABLED_VALUE = "disabled";
195
+ const PLATFORM_REMOTE_INSTALLATION_MANIFEST_KEY = "__void/platform/installation/v1";
196
+ const PLATFORM_SANDBOX_DRAIN_KEY = "__void/platform/sandbox-drain/v1";
197
+ const PLATFORM_R2_OWNERSHIP_MARKER_KEY = "__void/platform/ownership/v1";
198
+ const PLATFORM_RESOURCE_OWNERSHIP_SCHEMA_VERSION = 1;
199
+ const PLATFORM_USAGE_PROTOCOL_VERSION = 1;
200
+ const STATUS_TRANSITIONS = {
201
+ draft: [
202
+ "planned",
203
+ "failed",
204
+ "uninstalling"
205
+ ],
206
+ planned: [
207
+ "provisioning",
208
+ "failed",
209
+ "uninstalling"
210
+ ],
211
+ provisioning: [
212
+ "waiting-for-dns",
213
+ "waiting-for-oauth",
214
+ "deploying",
215
+ "disabling",
216
+ "failed",
217
+ "uninstalling"
218
+ ],
219
+ "waiting-for-dns": [
220
+ "provisioning",
221
+ "disabling",
222
+ "failed",
223
+ "uninstalling"
224
+ ],
225
+ "waiting-for-oauth": [
226
+ "provisioning",
227
+ "deploying",
228
+ "disabling",
229
+ "failed",
230
+ "uninstalling"
231
+ ],
232
+ deploying: [
233
+ "provisioning",
234
+ "verifying",
235
+ "disabling",
236
+ "disabled",
237
+ "failed",
238
+ "uninstalling"
239
+ ],
240
+ verifying: [
241
+ "provisioning",
242
+ "installed",
243
+ "disabling",
244
+ "failed",
245
+ "uninstalling"
246
+ ],
247
+ installed: [
248
+ "provisioning",
249
+ "disabling",
250
+ "uninstalling",
251
+ "failed"
252
+ ],
253
+ disabling: [
254
+ "disabled",
255
+ "failed",
256
+ "uninstalling"
257
+ ],
258
+ disabled: [
259
+ "provisioning",
260
+ "uninstalling",
261
+ "failed"
262
+ ],
263
+ uninstalling: ["uninstalled", "failed"],
264
+ uninstalled: [],
265
+ failed: [
266
+ "planned",
267
+ "provisioning",
268
+ "deploying",
269
+ "verifying",
270
+ "disabling",
271
+ "uninstalling"
272
+ ]
273
+ };
274
+ function assertRecord(value, label) {
275
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object.`);
276
+ }
277
+ function requiredString(value, label) {
278
+ if (typeof value !== "string" || value.trim() === "") throw new Error(`${label} must be a non-empty string.`);
279
+ return value;
280
+ }
281
+ function isInstallationStatus(value) {
282
+ return typeof value === "string" && Object.hasOwn(STATUS_TRANSITIONS, value);
283
+ }
284
+ function isResourceKind(value) {
285
+ return value === "ai-gateway" || value === "analytics-dataset" || value === "dispatch-namespace" || value === "dns-record" || value === "hyperdrive" || value === "kv-namespace" || value === "queue" || value === "r2-bucket" || value === "worker" || value === "worker-custom-domain" || value === "worker-route" || value === "zone";
286
+ }
287
+ function isOwnership(value) {
288
+ return value === "created" || value === "adopted" || value === "external";
289
+ }
290
+ function isResourceState(value) {
291
+ return value === "ready" || value === "retained" || value === "deleted";
292
+ }
293
+ function assertTimestamp(value, label) {
294
+ if (!Number.isFinite(Date.parse(value))) throw new Error(`${label} must be an ISO timestamp.`);
295
+ return value;
296
+ }
297
+ function createPlatformResourceOwnershipMarker(input) {
298
+ if (!isResourceKind(input.resourceKind)) throw new Error("Invalid ownership marker resource kind.");
299
+ return {
300
+ accountId: requiredString(input.accountId, "ownership accountId"),
301
+ installationId: requiredString(input.installationId, "ownership installationId"),
302
+ ownershipNonce: requiredString(input.ownershipNonce, "ownership ownershipNonce"),
303
+ resourceId: requiredString(input.resourceId, "ownership resourceId"),
304
+ resourceKey: requiredString(input.resourceKey, "ownership resourceKey"),
305
+ resourceKind: input.resourceKind,
306
+ resourceName: requiredString(input.resourceName, "ownership resourceName"),
307
+ schemaVersion: 1
308
+ };
309
+ }
310
+ function parsePlatformResourceOwnershipMarker(value) {
311
+ assertRecord(value, "Platform resource ownership marker");
312
+ if (value.schemaVersion !== 1) throw new Error(`Unsupported platform resource ownership schema version: ${String(value.schemaVersion)}.`);
313
+ if (!isResourceKind(value.resourceKind)) throw new Error("Invalid ownership marker resource kind.");
314
+ return createPlatformResourceOwnershipMarker({
315
+ accountId: requiredString(value.accountId, "ownership accountId"),
316
+ installationId: requiredString(value.installationId, "ownership installationId"),
317
+ ownershipNonce: requiredString(value.ownershipNonce, "ownership ownershipNonce"),
318
+ resourceId: requiredString(value.resourceId, "ownership resourceId"),
319
+ resourceKey: requiredString(value.resourceKey, "ownership resourceKey"),
320
+ resourceKind: value.resourceKind,
321
+ resourceName: requiredString(value.resourceName, "ownership resourceName")
322
+ });
323
+ }
324
+ function createPlatformInstallationManifest(input) {
325
+ const createdAt = assertTimestamp(input.createdAt, "createdAt");
326
+ if (!/^[a-z0-9][a-z0-9-]{7,79}$/.test(input.id)) throw new Error("Installation id must be a lowercase identifier between 8 and 80 characters.");
327
+ if (!/^[A-Za-z0-9_-]{32,128}$/.test(input.ownershipNonce)) throw new Error("Ownership nonce must contain 32 to 128 URL-safe characters.");
328
+ return {
329
+ account: {
330
+ id: requiredString(input.account.id, "account.id"),
331
+ name: requiredString(input.account.name, "account.name")
332
+ },
333
+ createdAt,
334
+ databaseSchemaDigest: null,
335
+ deployment: parsePlatformDeploymentManifest(JSON.parse(JSON.stringify(input.deployment))),
336
+ desiredState: "enabled",
337
+ endpoints: {
338
+ apiUrl: null,
339
+ dashboardUrl: null,
340
+ proxyUrl: null
341
+ },
342
+ id: input.id,
343
+ ownershipNonce: input.ownershipNonce,
344
+ platformVersion: requiredString(input.platformVersion, "platformVersion"),
345
+ resources: [],
346
+ runtime: null,
347
+ safetyProtocols: input.safetyProtocols ?? { sandboxDrain: 0 },
348
+ schemaVersion: 1,
349
+ status: "draft",
350
+ steps: [],
351
+ updatedAt: createdAt,
352
+ usageProtocolVersion: input.usageProtocolVersion ?? 0
353
+ };
354
+ }
355
+ function setInstallationDesiredState(manifest, desiredState, updatedAt) {
356
+ return {
357
+ ...manifest,
358
+ desiredState,
359
+ updatedAt: assertTimestamp(updatedAt, "updatedAt")
360
+ };
361
+ }
362
+ function normalizeEndpoint(value, label) {
363
+ if (value === null) return null;
364
+ let url;
365
+ try {
366
+ url = new URL(value);
367
+ } catch {
368
+ throw new Error(`${label} must be an absolute URL or null.`);
369
+ }
370
+ if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash) throw new Error(`${label} must be a credential-free HTTPS URL.`);
371
+ url.pathname = url.pathname.replace(/\/+$/, "") || "/";
372
+ return url.href.replace(/\/$/, "");
373
+ }
374
+ function setInstallationEndpoints(manifest, endpoints, updatedAt) {
375
+ return {
376
+ ...manifest,
377
+ endpoints: {
378
+ apiUrl: normalizeEndpoint(endpoints.apiUrl, "endpoints.apiUrl"),
379
+ dashboardUrl: normalizeEndpoint(endpoints.dashboardUrl, "endpoints.dashboardUrl"),
380
+ proxyUrl: normalizeEndpoint(endpoints.proxyUrl, "endpoints.proxyUrl")
381
+ },
382
+ updatedAt: assertTimestamp(updatedAt, "updatedAt")
383
+ };
384
+ }
385
+ function transitionInstallation(manifest, status, updatedAt) {
386
+ if (status !== manifest.status && !STATUS_TRANSITIONS[manifest.status].includes(status)) throw new Error(`Invalid installation transition: ${manifest.status} -> ${status}.`);
387
+ return {
388
+ ...manifest,
389
+ status,
390
+ updatedAt: assertTimestamp(updatedAt, "updatedAt")
391
+ };
392
+ }
393
+ function recordInstallationResource(manifest, resource, updatedAt) {
394
+ requiredString(resource.key, "resource.key");
395
+ requiredString(resource.id, "resource.id");
396
+ requiredString(resource.name, "resource.name");
397
+ requiredString(resource.configHash, "resource.configHash");
398
+ const collision = manifest.resources.find((entry) => entry.key !== resource.key && entry.kind === resource.kind && entry.id === resource.id);
399
+ if (collision) throw new Error(`Resource id ${resource.id} is already owned by ${collision.key}.`);
400
+ const resources = manifest.resources.filter((entry) => entry.key !== resource.key);
401
+ resources.push({ ...resource });
402
+ resources.sort((left, right) => left.key.localeCompare(right.key));
403
+ return {
404
+ ...manifest,
405
+ resources,
406
+ updatedAt: assertTimestamp(updatedAt, "updatedAt")
407
+ };
408
+ }
409
+ function recordInstallationStep(manifest, step, updatedAt) {
410
+ requiredString(step.key, "step.key");
411
+ requiredString(step.resultHash, "step.resultHash");
412
+ assertTimestamp(step.completedAt, "step.completedAt");
413
+ const existing = manifest.steps.find((entry) => entry.key === step.key);
414
+ if (existing && existing.resultHash !== step.resultHash) throw new Error(`Completed installation step ${step.key} has a different result.`);
415
+ const steps = existing ? manifest.steps : [...manifest.steps, { ...step }];
416
+ return {
417
+ ...manifest,
418
+ steps,
419
+ updatedAt: assertTimestamp(updatedAt, "updatedAt")
420
+ };
421
+ }
422
+ function parsePlatformInstallationManifest(value) {
423
+ assertRecord(value, "Platform installation manifest");
424
+ if (value.schemaVersion !== 1) throw new Error(`Unsupported platform installation schema version: ${String(value.schemaVersion)}.`);
425
+ const account = value.account;
426
+ const endpoints = value.endpoints;
427
+ assertRecord(account, "account");
428
+ assertRecord(endpoints, "endpoints");
429
+ if (!isInstallationStatus(value.status)) throw new Error(`Invalid installation status: ${String(value.status)}.`);
430
+ if (!Array.isArray(value.resources)) throw new Error("resources must be an array.");
431
+ if (!Array.isArray(value.steps)) throw new Error("steps must be an array.");
432
+ const manifest = createPlatformInstallationManifest({
433
+ account: {
434
+ id: requiredString(account.id, "account.id"),
435
+ name: requiredString(account.name, "account.name")
436
+ },
437
+ createdAt: requiredString(value.createdAt, "createdAt"),
438
+ deployment: parsePlatformDeploymentManifest(value.deployment),
439
+ id: requiredString(value.id, "id"),
440
+ ownershipNonce: requiredString(value.ownershipNonce, "ownershipNonce"),
441
+ platformVersion: requiredString(value.platformVersion, "platformVersion"),
442
+ safetyProtocols: parseSafetyProtocols(value.safetyProtocols),
443
+ usageProtocolVersion: parseUsageProtocolVersion$1(value.usageProtocolVersion)
444
+ });
445
+ const runtime = parsePlatformRuntimeProvenance(value.runtime);
446
+ let pendingDomain;
447
+ if (value.pendingDomain !== void 0) {
448
+ assertRecord(value.pendingDomain, "pendingDomain");
449
+ pendingDomain = createPlatformDeploymentManifest({
450
+ ...manifest.deployment,
451
+ application: value.pendingDomain
452
+ }).application;
453
+ if (!manifest.deployment.application.workersDev || !pendingDomain.zoneName || JSON.stringify(pendingDomain.workersDev) !== JSON.stringify(manifest.deployment.application.workersDev)) throw new Error("Pending domain must retain the installation workers.dev identity.");
454
+ }
455
+ const updatedAt = assertTimestamp(requiredString(value.updatedAt, "updatedAt"), "updatedAt");
456
+ let next = setInstallationEndpoints({
457
+ ...manifest,
458
+ desiredState: value.desiredState === "disabled" || value.desiredState === "enabled" ? value.desiredState : value.status === "disabled" || value.status === "disabling" ? "disabled" : "enabled",
459
+ status: value.status,
460
+ runtime,
461
+ ...pendingDomain ? { pendingDomain } : {},
462
+ updatedAt
463
+ }, {
464
+ apiUrl: endpoints.apiUrl === null ? null : requiredString(endpoints.apiUrl, "endpoints.apiUrl"),
465
+ dashboardUrl: endpoints.dashboardUrl === null ? null : requiredString(endpoints.dashboardUrl, "endpoints.dashboardUrl"),
466
+ proxyUrl: endpoints.proxyUrl === null ? null : requiredString(endpoints.proxyUrl, "endpoints.proxyUrl")
467
+ }, updatedAt);
468
+ for (const [index, entry] of value.resources.entries()) {
469
+ assertRecord(entry, `resources[${index}]`);
470
+ if (!isResourceKind(entry.kind)) throw new Error(`Invalid resources[${index}].kind.`);
471
+ if (!isOwnership(entry.ownership)) throw new Error(`Invalid resources[${index}].ownership.`);
472
+ if (!isResourceState(entry.state)) throw new Error(`Invalid resources[${index}].state.`);
473
+ next = recordInstallationResource(next, {
474
+ configHash: requiredString(entry.configHash, `resources[${index}].configHash`),
475
+ id: requiredString(entry.id, `resources[${index}].id`),
476
+ key: requiredString(entry.key, `resources[${index}].key`),
477
+ kind: entry.kind,
478
+ name: requiredString(entry.name, `resources[${index}].name`),
479
+ ownership: entry.ownership,
480
+ state: entry.state
481
+ }, next.updatedAt);
482
+ }
483
+ for (const [index, entry] of value.steps.entries()) {
484
+ assertRecord(entry, `steps[${index}]`);
485
+ next = recordInstallationStep(next, {
486
+ completedAt: requiredString(entry.completedAt, `steps[${index}].completedAt`),
487
+ key: requiredString(entry.key, `steps[${index}].key`),
488
+ resultHash: requiredString(entry.resultHash, `steps[${index}].resultHash`)
489
+ }, next.updatedAt);
490
+ }
491
+ const recordedDatabaseSchemaDigest = value.databaseSchemaDigest === void 0 || value.databaseSchemaDigest === null ? [...next.steps].reverse().find((step) => step.key.startsWith("database-schema:"))?.resultHash ?? null : requiredString(value.databaseSchemaDigest, "databaseSchemaDigest");
492
+ return {
493
+ ...next,
494
+ databaseSchemaDigest: recordedDatabaseSchemaDigest,
495
+ updatedAt
496
+ };
497
+ }
498
+ function parseUsageProtocolVersion$1(value) {
499
+ if (value === void 0 || value === 0) return 0;
500
+ if (value === 1) return 1;
501
+ throw new Error("usageProtocolVersion must be 0 or 1.");
502
+ }
503
+ function parseSafetyProtocols(value) {
504
+ if (value === void 0) return { sandboxDrain: 0 };
505
+ assertRecord(value, "safetyProtocols");
506
+ if (value.sandboxDrain !== 0 && value.sandboxDrain !== 1 && value.sandboxDrain !== 2) throw new Error("safetyProtocols.sandboxDrain must be 0, 1, or 2.");
507
+ return { sandboxDrain: value.sandboxDrain };
508
+ }
509
+ function parsePlatformRuntimeProvenance(value) {
510
+ if (value === void 0 || value === null) return null;
511
+ assertRecord(value, "runtime");
512
+ if (value.source !== "custom" && value.source !== "package") throw new Error("runtime.source must be custom or package.");
513
+ const manifestSha256 = requiredString(value.manifestSha256, "runtime.manifestSha256");
514
+ if (!/^[0-9a-f]{64}$/.test(manifestSha256)) throw new Error("runtime.manifestSha256 must be a SHA-256 digest.");
515
+ const sourceRevision = value.sourceRevision === null || value.sourceRevision === void 0 ? null : requiredString(value.sourceRevision, "runtime.sourceRevision");
516
+ if (sourceRevision !== null && (sourceRevision.length > 200 || !/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(sourceRevision))) throw new Error("runtime.sourceRevision is invalid.");
517
+ return {
518
+ manifestSha256,
519
+ source: value.source,
520
+ sourceRevision
521
+ };
522
+ }
523
+ //#endregion
524
+ //#region src/application.ts
525
+ /** Minimal public-origin adapter; request policy remains in the service-bound dispatcher. */
526
+ const PLATFORM_PROJECT_INGRESS_SOURCE = `export default {
527
+ fetch(request, env) {
528
+ if (new URL(request.url).hostname !== env.VOID_APP_HOSTNAME) {
529
+ return new Response('Not Found', {status: 404});
530
+ }
531
+ return env.PLATFORM_DISPATCH.fetch(request);
532
+ }
533
+ };`;
534
+ function readPlatformApplication(env) {
535
+ const baseDomain = env.SITE_DOMAIN ?? env.BASE_HOSTNAME ?? "void.app";
536
+ if (!env.PLATFORM_APPLICATION) return {
537
+ baseDomain,
538
+ zoneName: baseDomain,
539
+ dedicatedZone: false
540
+ };
541
+ return createPlatformDeploymentManifest({
542
+ installationSlug: "runtime",
543
+ displayName: "Runtime",
544
+ application: JSON.parse(env.PLATFORM_APPLICATION)
545
+ }).application;
546
+ }
547
+ function platformWorkersDevAliasKey(hostname) {
548
+ return `workers-dev:${hostname}`;
549
+ }
550
+ const PLATFORM_APPLICATION_KEY = "__void/platform/application/v1";
551
+ async function resolvePlatformApplicationEnvironment(env) {
552
+ if (!env.PLATFORM_APPLICATION) return env;
553
+ const raw = await env.ROUTING.get(PLATFORM_APPLICATION_KEY);
554
+ if (!raw) return env;
555
+ const previous = readPlatformApplication(env);
556
+ const next = readPlatformApplication({ PLATFORM_APPLICATION: raw });
557
+ if (!previous.workersDev || !next.workersDev || previous.workersDev.installationId !== next.workersDev.installationId || previous.workersDev.subdomain !== next.workersDev.subdomain) throw new Error("Application routing belongs to another platform installation.");
558
+ return {
559
+ ...env,
560
+ PLATFORM_APPLICATION: raw,
561
+ SITE_DOMAIN: next.baseDomain,
562
+ BASE_HOSTNAME: next.baseDomain,
563
+ ...next.zoneId ? { CF_ZONE_ID: next.zoneId } : {}
564
+ };
565
+ }
566
+ function platformProjectIngressName(project, workersDev) {
567
+ if (!/^proj_[a-z0-9]{1,32}$/.test(project.id) || !/^[a-z0-9][a-z0-9-]*$/.test(project.slug)) throw new Error("Invalid platform project identity.");
568
+ const prefix = `void-${workersDev.installationId.slice(-12)}-`;
569
+ const suffix = `-${project.id.slice(5)}`;
570
+ return `${prefix}${project.slug.slice(0, 63 - prefix.length - suffix.length).replace(/-+$/, "")}${suffix}`;
571
+ }
572
+ function platformProjectWorkersDevHostname(project, workersDev) {
573
+ return `${platformProjectIngressName(project, workersDev)}.${workersDev.subdomain}.workers.dev`;
574
+ }
575
+ function platformProjectHostname(project, application) {
576
+ if (!application.zoneName && application.workersDev) return platformProjectWorkersDevHostname(project, application.workersDev);
577
+ return `${project.slug}.${application.baseDomain}`;
578
+ }
579
+ function platformProjectHostnames(project, application) {
580
+ return [.../* @__PURE__ */ new Set([platformProjectHostname(project, application), ...application.workersDev ? [platformProjectWorkersDevHostname(project, application.workersDev)] : []])];
581
+ }
582
+ //#endregion
583
+ //#region src/discovery.ts
584
+ const PLATFORM_DISCOVERY_SCHEMA_VERSION = 1;
585
+ function normalizeOrigin(value, name) {
586
+ let url;
587
+ try {
588
+ url = new URL(value);
589
+ } catch {
590
+ throw new Error(`${name} must be an absolute URL.`);
591
+ }
592
+ if (!(url.protocol === "http:" && (url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "::1")) && url.protocol !== "https:" || url.username || url.password) throw new Error(`${name} must be a credential-free HTTPS URL.`);
593
+ if (url.pathname !== "" && url.pathname !== "/" || url.search || url.hash) throw new Error(`${name} must be an origin without a path, query, or fragment.`);
594
+ return url.origin;
595
+ }
596
+ function createPlatformDiscoveryDocument(input) {
597
+ if (!input.displayName.trim()) throw new Error("displayName must not be empty.");
598
+ if (!input.platformVersion.trim()) throw new Error("platformVersion must not be empty.");
599
+ if (input.applicationRouting) {
600
+ const application = readPlatformApplication({ PLATFORM_APPLICATION: JSON.stringify(input.applicationRouting) });
601
+ if (!application.workersDev || application.baseDomain !== input.applicationDomain || application.workersDev.installationId !== input.installationId) throw new Error("Application routing must match the discovery domain and installation identity.");
602
+ }
603
+ if (input.usageProtocolVersion !== void 0 && input.usageProtocolVersion !== 0 && input.usageProtocolVersion !== 1) throw new Error("usageProtocolVersion must be 0 or 1.");
604
+ if (input.authenticationProviders.length === 0) throw new Error("At least one authentication provider is required.");
605
+ if (input.authenticationProviders.includes("github") !== input.capabilities.githubOAuth || input.authenticationProviders.includes("google") !== input.capabilities.googleOAuth) throw new Error("Authentication providers and capabilities must agree.");
606
+ return {
607
+ ...input,
608
+ apiUrl: normalizeOrigin(input.apiUrl, "apiUrl"),
609
+ applicationDomain: normalizeApplicationDomain(input.applicationDomain),
610
+ authenticationProviders: [...input.authenticationProviders],
611
+ displayName: input.displayName.trim(),
612
+ installationId: input.installationId?.trim() || null,
613
+ platformVersion: input.platformVersion.trim(),
614
+ proxyUrl: normalizeOrigin(input.proxyUrl, "proxyUrl"),
615
+ schemaVersion: input.applicationRouting?.workersDev ? 2 : 1,
616
+ usageProtocolVersion: input.usageProtocolVersion ?? 0
617
+ };
618
+ }
619
+ function parsePlatformDiscoveryDocument(value) {
620
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Platform discovery document must be an object.");
621
+ const document = value;
622
+ if (document.schemaVersion !== 1 && document.schemaVersion !== 2) throw new Error(`Unsupported platform discovery schema version: ${String(document.schemaVersion)}.`);
623
+ const capabilities = document.capabilities;
624
+ if (document.schemaVersion === 1 && document.applicationRouting !== void 0) throw new Error("Application routing requires discovery schema version 2.");
625
+ if (!capabilities || typeof capabilities !== "object" || Array.isArray(capabilities)) throw new Error("capabilities must be an object.");
626
+ const capabilityNames = [
627
+ "ai",
628
+ "customDomains",
629
+ "email",
630
+ "githubActions",
631
+ "githubOAuth",
632
+ "googleOAuth",
633
+ "managedBuilds",
634
+ "sandbox"
635
+ ];
636
+ const parsedCapabilities = {};
637
+ for (const name of capabilityNames) {
638
+ const enabled = capabilities[name];
639
+ if (typeof enabled !== "boolean") throw new Error(`capabilities.${name} must be a boolean.`);
640
+ parsedCapabilities[name] = enabled;
641
+ }
642
+ const providers = document.authenticationProviders;
643
+ if (!Array.isArray(providers) || providers.some((provider) => provider !== "github" && provider !== "google")) throw new Error("authenticationProviders must contain only github or google.");
644
+ const string = (name) => {
645
+ const entry = document[name];
646
+ if (typeof entry !== "string" || !entry.trim()) throw new Error(`${name} must be a non-empty string.`);
647
+ return entry;
648
+ };
649
+ const apiUrl = string("apiUrl");
650
+ const proxyUrl = typeof document.proxyUrl === "string" && document.proxyUrl.trim() ? document.proxyUrl : apiUrl === "https://api.void.cloud" ? "https://proxy.void.cloud" : apiUrl === "https://api.staging.void.cloud" ? "https://proxy.staging.void.cloud" : string("proxyUrl");
651
+ return createPlatformDiscoveryDocument({
652
+ apiUrl,
653
+ applicationDomain: string("applicationDomain"),
654
+ ...document.schemaVersion === 2 ? { applicationRouting: readPlatformApplication({ PLATFORM_APPLICATION: JSON.stringify(document.applicationRouting ?? null) }) } : {},
655
+ authenticationProviders: providers,
656
+ capabilities: parsedCapabilities,
657
+ displayName: string("displayName"),
658
+ installationId: document.installationId === null ? null : string("installationId"),
659
+ platformVersion: string("platformVersion"),
660
+ proxyUrl,
661
+ usageProtocolVersion: parseUsageProtocolVersion(document.usageProtocolVersion)
662
+ });
663
+ }
664
+ function parseUsageProtocolVersion(value) {
665
+ if (value === void 0 || value === 0) return 0;
666
+ if (value === 1) return 1;
667
+ throw new Error("usageProtocolVersion must be 0 or 1.");
668
+ }
669
+ //#endregion
670
+ //#region src/worker-config.ts
671
+ function createPlatformWorkerConfigs(input) {
672
+ const { accountId, apiUrl, deployment, healthProbeToken, installationId, ownershipNonce, platformVersion, proxyUrl, resources, runtimeEntrypoints } = input;
673
+ const publicEndpoints = input.publicEndpoints ?? true;
674
+ const trafficState = input.trafficState ?? "enabled";
675
+ const names = deployment.resources;
676
+ const ownershipVars = (resourceKey, resourceName) => ({ PLATFORM_OWNERSHIP_MARKER: JSON.stringify(createPlatformResourceOwnershipMarker({
677
+ accountId,
678
+ installationId,
679
+ ownershipNonce,
680
+ resourceId: resourceName,
681
+ resourceKey,
682
+ resourceKind: "worker",
683
+ resourceName
684
+ })) });
685
+ const common = {
686
+ account_id: accountId,
687
+ compatibility_date: "2026-02-24",
688
+ observability: { enabled: true },
689
+ preview_urls: publicEndpoints,
690
+ workers_dev: publicEndpoints
691
+ };
692
+ const kv = [
693
+ {
694
+ binding: "ROUTING",
695
+ id: resources.routingKv
696
+ },
697
+ {
698
+ binding: "ISR_CACHE",
699
+ id: resources.isrCacheKv
700
+ },
701
+ {
702
+ binding: "STATIC_ASSETS",
703
+ id: resources.legacyAssetsKv
704
+ }
705
+ ];
706
+ const dispatchNamespace = [{
707
+ binding: "DISPATCH",
708
+ namespace: names.dispatchNamespace
709
+ }];
710
+ const r2 = [{
711
+ binding: "STATIC_ASSETS_R2",
712
+ bucket_name: names.assetsBucket
713
+ }];
714
+ const fetchWorkersDev = Boolean(deployment.application.workersDev) || [apiUrl, proxyUrl].some((url) => new URL(url).hostname.endsWith(".workers.dev"));
715
+ const api = {
716
+ ...common,
717
+ name: names.apiWorker,
718
+ main: runtimeEntrypoints.api,
719
+ no_bundle: true,
720
+ compatibility_flags: ["nodejs_compat", ...fetchWorkersDev ? ["global_fetch_strictly_public"] : []],
721
+ placement: { mode: "smart" },
722
+ hyperdrive: [{
723
+ binding: "HYPERDRIVE",
724
+ id: resources.hyperdrive
725
+ }],
726
+ kv_namespaces: kv,
727
+ r2_buckets: r2,
728
+ dispatch_namespaces: dispatchNamespace,
729
+ durable_objects: { bindings: [
730
+ {
731
+ name: "USAGE_COUNTER",
732
+ class_name: "UsageCounter"
733
+ },
734
+ {
735
+ name: "CRON_SCHEDULER",
736
+ class_name: "CronScheduler"
737
+ },
738
+ {
739
+ name: "ERROR_ALERT_MONITOR",
740
+ class_name: "ErrorAlertMonitor"
741
+ },
742
+ {
743
+ name: "SANDBOX_CONCURRENCY_COUNTER",
744
+ class_name: "SandboxConcurrencyCounter"
745
+ }
746
+ ] },
747
+ migrations: [
748
+ {
749
+ tag: "v1",
750
+ new_sqlite_classes: ["UsageCounter"]
751
+ },
752
+ {
753
+ tag: "v2",
754
+ new_sqlite_classes: ["CronScheduler"]
755
+ },
756
+ {
757
+ tag: "v3",
758
+ new_sqlite_classes: ["ErrorAlertMonitor"]
759
+ },
760
+ {
761
+ tag: "v4",
762
+ new_sqlite_classes: ["SandboxConcurrencyCounter"]
763
+ }
764
+ ],
765
+ queues: {
766
+ producers: [{
767
+ binding: "CRON_FIRES_QUEUE",
768
+ queue: names.cronQueue
769
+ }, {
770
+ binding: "USAGE_EVENTS_QUEUE",
771
+ queue: names.usageQueue
772
+ }],
773
+ consumers: [{
774
+ queue: names.usageQueue,
775
+ max_batch_size: 100,
776
+ max_batch_timeout: 5
777
+ }, {
778
+ queue: names.cronQueue,
779
+ max_batch_size: 50,
780
+ max_batch_timeout: 1,
781
+ max_retries: 3
782
+ }]
783
+ },
784
+ triggers: { crons: ["0 * * * *"] },
785
+ vars: {
786
+ AUTH_REDIRECT_URI: `${apiUrl}/auth/callback`,
787
+ AI_GATEWAY_ID: names.aiGateway,
788
+ CRON_FIRES_QUEUE_NAME: names.cronQueue,
789
+ DISPATCH_NAMESPACE: names.dispatchNamespace,
790
+ DISPATCH_WORKER_NAME: names.dispatchWorker,
791
+ LOGS_DATASET: names.logsDataset,
792
+ PLATFORM_CAPABILITIES: JSON.stringify(deployment.capabilities),
793
+ PLATFORM_DISPLAY_NAME: deployment.displayName,
794
+ PLATFORM_ENV: "production",
795
+ PLATFORM_HEALTH_PROBE_TOKEN: healthProbeToken,
796
+ PLATFORM_INSTALLATION_ID: installationId,
797
+ PLATFORM_TRAFFIC_STATE: trafficState,
798
+ ...ownershipVars("api-worker", names.apiWorker),
799
+ PLATFORM_VERSION: platformVersion,
800
+ PROXY_URL: proxyUrl,
801
+ R2_STATIC_ASSETS_BUCKET: names.assetsBucket,
802
+ REQUESTS_DATASET: names.requestsDataset,
803
+ SITE_DOMAIN: deployment.application.baseDomain,
804
+ ...deployment.application.workersDev ? { PLATFORM_APPLICATION: JSON.stringify(deployment.application) } : {},
805
+ TAIL_SERVICE_NAME: names.tailWorker,
806
+ VOID_PROXY_SERVICE: names.proxyWorker
807
+ }
808
+ };
809
+ if (publicEndpoints && deployment.controlPlane.apiHostname) api.routes = [{
810
+ pattern: deployment.controlPlane.apiHostname,
811
+ custom_domain: true
812
+ }];
813
+ const proxy = {
814
+ ...common,
815
+ name: names.proxyWorker,
816
+ main: runtimeEntrypoints.proxy,
817
+ no_bundle: true,
818
+ compatibility_flags: ["nodejs_compat"],
819
+ ai: { binding: "AI" },
820
+ kv_namespaces: [{
821
+ binding: "ROUTING",
822
+ id: resources.routingKv
823
+ }],
824
+ services: [{
825
+ binding: "API",
826
+ service: names.apiWorker
827
+ }],
828
+ dispatch_namespaces: dispatchNamespace,
829
+ vars: {
830
+ AI_GATEWAY_ID: names.aiGateway,
831
+ PLATFORM_CAPABILITIES: JSON.stringify(deployment.capabilities),
832
+ PLATFORM_HEALTH_PROBE_TOKEN: healthProbeToken,
833
+ PLATFORM_INSTALLATION_ID: installationId,
834
+ PLATFORM_TRAFFIC_STATE: trafficState,
835
+ ...ownershipVars("proxy-worker", names.proxyWorker)
836
+ }
837
+ };
838
+ if (publicEndpoints && deployment.controlPlane.proxyHostname) proxy.routes = [{
839
+ pattern: deployment.controlPlane.proxyHostname,
840
+ custom_domain: true
841
+ }];
842
+ return {
843
+ api,
844
+ proxy,
845
+ tail: {
846
+ ...common,
847
+ name: names.tailWorker,
848
+ main: runtimeEntrypoints.tail,
849
+ no_bundle: true,
850
+ analytics_engine_datasets: [{
851
+ binding: "ANALYTICS",
852
+ dataset: names.logsDataset
853
+ }],
854
+ vars: {
855
+ PLATFORM_DISPATCH_WORKER_NAME: names.dispatchWorker,
856
+ ...ownershipVars("tail-worker", names.tailWorker)
857
+ }
858
+ },
859
+ dispatch: {
860
+ ...common,
861
+ name: names.dispatchWorker,
862
+ main: runtimeEntrypoints.dispatch,
863
+ no_bundle: true,
864
+ ...publicEndpoints ? { routes: createApplicationRoutes(deployment.application).map((route) => ({
865
+ pattern: route.pattern,
866
+ zone_name: route.zoneName
867
+ })) } : {},
868
+ dispatch_namespaces: dispatchNamespace,
869
+ kv_namespaces: kv,
870
+ r2_buckets: r2,
871
+ analytics_engine_datasets: [{
872
+ binding: "ANALYTICS",
873
+ dataset: names.requestsDataset
874
+ }, {
875
+ binding: "LOGS",
876
+ dataset: names.logsDataset
877
+ }],
878
+ queues: { producers: [{
879
+ binding: "USAGE_QUEUE",
880
+ queue: names.usageQueue
881
+ }] },
882
+ tail_consumers: [{ service: names.tailWorker }],
883
+ vars: {
884
+ BASE_HOSTNAME: deployment.application.baseDomain,
885
+ ...deployment.application.workersDev ? { PLATFORM_APPLICATION: JSON.stringify(deployment.application) } : {},
886
+ PLATFORM_HEALTH_PROBE_TOKEN: healthProbeToken,
887
+ PLATFORM_INSTALLATION_ID: installationId,
888
+ PLATFORM_TRAFFIC_STATE: trafficState,
889
+ ...ownershipVars("dispatch-worker", names.dispatchWorker)
890
+ }
891
+ }
892
+ };
893
+ }
894
+ //#endregion
895
+ export { PLATFORM_APPLICATION_KEY, PLATFORM_DEPLOYMENT_SCHEMA_VERSION, PLATFORM_DISABLED_KEY, PLATFORM_DISABLED_VALUE, PLATFORM_DISCOVERY_SCHEMA_VERSION, PLATFORM_INSTALLATION_SCHEMA_VERSION, PLATFORM_PROJECT_INGRESS_SOURCE, PLATFORM_R2_OWNERSHIP_MARKER_KEY, PLATFORM_REMOTE_INSTALLATION_MANIFEST_KEY, PLATFORM_RESOURCE_OWNERSHIP_SCHEMA_VERSION, PLATFORM_SANDBOX_DRAIN_KEY, PLATFORM_USAGE_PROTOCOL_VERSION, createApplicationRoutes, createPlatformDeploymentManifest, createPlatformDiscoveryDocument, createPlatformInstallationManifest, createPlatformResourceNames, createPlatformResourceOwnershipMarker, createPlatformWorkerConfigs, normalizeApplicationDomain, normalizeInstallationSlug, parsePlatformDeploymentManifest, parsePlatformDiscoveryDocument, parsePlatformInstallationManifest, parsePlatformResourceOwnershipMarker, platformProjectHostname, platformProjectHostnames, platformProjectIngressName, platformProjectWorkersDevHostname, platformWorkersDevAliasKey, readPlatformApplication, recordInstallationResource, recordInstallationStep, resolvePlatformApplicationEnvironment, setInstallationDesiredState, setInstallationEndpoints, transitionInstallation };