From 722376a5b320f05f45e810dc8422dc71f3503762 Mon Sep 17 00:00:00 2001 From: Ross Nelson Date: Sat, 19 Sep 2026 13:22:06 -0400 Subject: [PATCH] refactor(workers): describe a compute provider in one place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A provider was described in ten places, in four shapes, under two naming conventions: an icon map and two label switches in the picker, a release stage map in shared.ts, a second icon-and-label map in compute-badge keyed by the wire name rather than the short one, an if-chain normalising those wire names in lock-compute-provider, a default provider list, and five raw template imports resolved through provider ternaries in compute-fields. Adding a provider meant finding all ten, and the templates alone had grown to seven props threaded through pages, forms, and fields. COMPUTE_PROVIDERS now holds all of it, keyed by provider, and the ten readers derive from it. The Record is exhaustive over ComputeProviderValue, so adding a provider is one entry and the compiler names whatever is still missing. The seven template props collapse to one `templates` map, defaulting to the bundled templates that a self-hosted deployment wants. Because that map is exhaustive too, a consumer supplying its own — Temporal Cloud does, per environment — fails its type check when a provider is added without templates, rather than silently falling back and shipping the wrong infrastructure snippet. Two asymmetries are now modelled rather than inferred. CloudFormation is AWS-only, so it is optional on the templates type and Cloud Run simply has none, in place of the isAgentCore ternaries that decided it. The Terraform module link is likewise per provider rather than an AWS-only string built from a boolean. The provider ternary for Terraform interpolation is gone entirely: interpolateTerraformTemplate already no-ops on the ARN key absent from a given snippet, which its own comment noted, so both are passed. Behaviour is unchanged. No markup branching was touched: the per-provider field blocks render genuinely different inputs and belong where they are. --- .../deployments/compute-badge.svelte | 20 +- .../compute-fields.svelte | 81 ++++---- .../compute-fields.test.ts | 25 ++- .../compute-provider-picker.svelte | 50 ++--- .../compute-providers.ts | 175 ++++++++++++++++++ .../create-version-form.svelte | 13 +- .../edit-version-form.svelte | 10 +- .../serverless-worker-create-form.svelte | 25 +-- .../workers/serverless-worker-form/shared.ts | 29 ++- src/lib/pages/serverless-worker-create.svelte | 32 +--- .../worker-deployment-version-create.svelte | 13 +- .../worker-deployment-version-edit.svelte | 13 +- src/lib/utilities/lock-compute-provider.ts | 17 +- 13 files changed, 325 insertions(+), 178 deletions(-) create mode 100644 src/lib/components/workers/serverless-worker-form/compute-providers.ts diff --git a/src/lib/components/deployments/compute-badge.svelte b/src/lib/components/deployments/compute-badge.svelte index 1d6b1b9306..958f8a0c7f 100644 --- a/src/lib/components/deployments/compute-badge.svelte +++ b/src/lib/components/deployments/compute-badge.svelte @@ -1,6 +1,9 @@