cloud / internal-packages / installer / worker / stack-config.jsmain at aacbc74
// stack-config.js — THE CONFIG OF A STACK THAT THE WIZARD MAKES. A module of its own, with no import,
// so that a test in plain Node can hold it against the stack's own schema (test/stack-config.mjs).
/** The stack's config (core/alchemy/src/config.ts) for a first deploy: the owners sign in with a
* mailed code. `mind` says the sandboxes' containers and images: the wizard's is iterate's public
* image, which the deploy pushes to the account's registry with no Docker
* (core/alchemy/scripts/sandbox-image.ts); a chat installation's is `containers: false` before
* the domain, then no named image, so sandboxes start `cloudflare/debian-trixie`. With no
* `zone` the stack is deployed before its domain, with no mail and so no mailed sign-in code
* (container/run.sh `stack_updatable` adds the three with the domain); `cloudflarePlan: "free"` also
* leaves out what needs Workers Paid and R2 (core/alchemy README, "Before the domain and before
* Workers Paid"). `telemetry`, when the person's consent was
* the one for it (scopes.js `telemetryGranted`): the stack keeps its own events, logs and
* traces in a warehouse in the account, with two narrow API tokens that the deploy makes for its
* telemetry Worker alone (core/alchemy README, "Telemetry"). `cloudflareToken`, when the person's
* consent was the one for a mind's Cloudflare connection: the deploy makes one API token of the
* account for the mind itself (core/alchemy README, "The mind's Cloudflare token"). `keys`, the public keys the deployment trusts (the Cloud's), and `cloudOrigin`, the
* origin of the Cloud whose clients the deployment may use, are left out when absent. Null with no
* `ownerEmails`: an update writes no config, and the stack deploys from the one it keeps beside
* its own state, with whatever its owner changed since. */
export function configOf({
name,
accountId,
zone,
ownerEmails,
trustedClients,
keys,
cloudOrigin,
telemetry,
cloudflareToken,
mind,
cloudflarePlan,
}) {
if (!ownerEmails) return null;
return {
name,
accountId,
domain: zone,
cloudflarePlan,
mind,
auth: {
login: {
methods: zone ? { email: {} } : {},
allow: ownerEmails.map((email) => ({ email })),
},
trustedClients,
keys,
},
...(zone && { mail: true }),
...(telemetry && { telemetry: true }),
...(cloudflareToken && { cloudflareToken: true }),
...(cloudOrigin && { cloud: { origin: cloudOrigin } }),
};
}