@happyvertical/smrt-config 0.61.0 → 0.61.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"deployment.js","names":["describe"],"sources":["../src/deployment/chart-values.ts","../src/deployment/compose-contract.ts"],"sourcesContent":["/**\n * Self-host rendering of the compose deployment contract: turn a resolved\n * declaration into values for the `smrt-app` chart.\n *\n * The declaration says what the application is. Everything the chart needs\n * beyond that is environment-owned and comes in as explicit inputs: release\n * identity, Secret references, resources, the maintenance responder and the\n * ingress class. Nothing here invents a default for those, and the inputs are\n * checked: they normally come from a hand-written JSON file.\n */\n\nimport type {\n ComposeDeploymentDeclaration,\n ComposeDeploymentWorkload,\n} from './compose-contract.js';\n\n/**\n * The migration guard capability the chart requires a release to declare.\n * Rendering it is a declaration, not an implementation: the application's\n * `migrate.command` has to be a wrapper that implements the guard.\n */\nexport const SMRT_RELEASE_GUARD = 'smrt-release-v1';\n\nconst CHART_NAME = /^[a-z][a-z0-9-]{0,30}$/;\nconst DIGEST_IMAGE = /^[a-zA-Z0-9./:_-]+@sha256:[a-f0-9]{64}$/;\nconst WORKER_ROLES = ['background', 'task', 'schedule'] as const;\n// charts/smrt-app/templates/validate.yaml: \"reserved workload name\".\nconst RESERVED_WORKLOAD_NAMES = ['maintenance', 'inventory'];\nconst PROBE_TIMING_FIELDS = [\n 'initialDelaySeconds',\n 'periodSeconds',\n 'timeoutSeconds',\n 'failureThreshold',\n 'successThreshold',\n] as const;\n\nexport interface SmrtAppChartSecretRef {\n secretName: string;\n secretKey: string;\n}\n\nexport interface SmrtAppChartSecretEnv extends SmrtAppChartSecretRef {\n /** Environment variable name. */\n name: string;\n /** Limit the variable to these services. Defaults to every workload. */\n services?: string[];\n}\n\nexport interface SmrtAppChartResources {\n requests: Record<string, string>;\n limits: Record<string, string>;\n}\n\n/** Chart roles a contract `worker` may be rendered as. */\nexport type SmrtAppChartWorkerRole = (typeof WORKER_ROLES)[number];\n\n/** Timing of the readiness probe rendered from a service's `health`. */\nexport type SmrtAppChartProbeTiming = Partial<\n Record<(typeof PROBE_TIMING_FIELDS)[number], number>\n>;\n\nexport interface SmrtAppChartWorkloadInputs {\n /**\n * Chart role for a contract `worker`. Defaults to `background`, the\n * singleton runner. Not allowed on the web service.\n */\n role?: SmrtAppChartWorkerRole;\n /** `background` and `schedule` workloads are singletons and stay at 1. */\n replicas?: number;\n /** Whether the workload writes to the database. Defaults to `true`. */\n writer?: boolean;\n resources?: SmrtAppChartResources;\n terminationGracePeriodSeconds?: number;\n /** Kubernetes defaults apply to whatever is left out (1 s timeout, 10 s period). */\n readiness?: SmrtAppChartProbeTiming;\n}\n\nexport interface SmrtAppChartInputs {\n release: {\n id: string;\n phase: 'maintenance' | 'stopped' | 'migrate' | 'verify' | 'active';\n sequence: number;\n attempt: number;\n };\n app: {\n /** Defaults to the Compose file's top-level `name:`. */\n name?: string;\n environment: string;\n };\n /**\n * The runtime that is running now: the `target` block of the values\n * document the previous release was rendered to, unchanged. Leave it out\n * (or pass `false`) for a first install. It is never derived from the new\n * declaration, because the running release may differ from it in more than\n * its image digests.\n */\n current?: false | Record<string, unknown>;\n bindings: {\n /** Required when the declaration has a `postgres` binding. */\n postgres?: {\n /** Secret key holding the runtime `DATABASE_URL`. */\n runtime: SmrtAppChartSecretRef;\n /** Secret key holding the migration-only `DATABASE_URL`, in a different Secret. */\n migration: SmrtAppChartSecretRef;\n };\n /** Required when the declaration has a `bucket` binding. */\n bucket?: SmrtAppChartSecretRef;\n };\n /** Further runtime settings, each read from a named Secret key. */\n env?: SmrtAppChartSecretEnv[];\n defaults: {\n resources: SmrtAppChartResources;\n terminationGracePeriodSeconds: number;\n replicas?: number;\n };\n /** Per-service overrides, keyed by Compose service name. */\n workloads?: Record<string, SmrtAppChartWorkloadInputs>;\n migration?: {\n resources?: SmrtAppChartResources;\n terminationGracePeriodSeconds?: number;\n };\n /** Passed through as the chart's `maintenance` block. */\n maintenance: Record<string, unknown>;\n /** Passed through as the chart's `ingress` block. `host` defaults to the declared domain. */\n ingress: { className: string; host?: string } & Record<string, unknown>;\n}\n\n/** Thrown when a declaration cannot be rendered with the inputs given. */\nexport class SmrtAppChartValuesError extends Error {\n readonly problems: string[];\n\n constructor(problems: string[]) {\n super(\n `Cannot render smrt-app chart values:\\n${problems.map((problem) => `- ${problem}`).join('\\n')}`,\n );\n this.name = 'SmrtAppChartValuesError';\n this.problems = problems;\n }\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isText(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0;\n}\n\nfunction isPositiveInteger(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value > 0;\n}\n\nfunction isSecretRef(value: unknown): value is SmrtAppChartSecretRef {\n return isObject(value) && isText(value.secretName) && isText(value.secretKey);\n}\n\n/** Own keys only: a Compose service may be called `constructor` or `toString`. */\nfunction own<T>(\n record: Record<string, T> | undefined,\n key: string,\n): T | undefined {\n return record && Object.hasOwn(record, key) ? record[key] : undefined;\n}\n\nfunction workloadInputProblems(\n field: string,\n overrides: unknown,\n isWeb: boolean,\n need: (field: string, ok: boolean, what: string) => void,\n): void {\n if (!isObject(overrides)) {\n need(field, false, 'an object');\n return;\n }\n const role = overrides.role;\n if (role !== undefined) {\n if (isWeb) {\n need(\n `${field}.role`,\n false,\n \"left out: the web service is always the chart's `web` workload\",\n );\n } else {\n need(\n `${field}.role`,\n (WORKER_ROLES as readonly unknown[]).includes(role),\n `one of: ${WORKER_ROLES.join(', ')}`,\n );\n }\n }\n if (overrides.replicas !== undefined) {\n const singleton = !isWeb && role !== 'task';\n need(\n `${field}.replicas`,\n isPositiveInteger(overrides.replicas) &&\n (!singleton || overrides.replicas === 1),\n singleton\n ? '1: `background` and `schedule` workloads are singletons. Use `role: task` for a worker that scales'\n : 'a whole number of at least 1',\n );\n }\n need(\n `${field}.writer`,\n overrides.writer === undefined || typeof overrides.writer === 'boolean',\n '`true` or `false`',\n );\n need(\n `${field}.terminationGracePeriodSeconds`,\n overrides.terminationGracePeriodSeconds === undefined ||\n isPositiveInteger(overrides.terminationGracePeriodSeconds),\n 'a whole number of seconds',\n );\n need(\n `${field}.resources`,\n overrides.resources === undefined || isObject(overrides.resources),\n 'an object',\n );\n const timing = overrides.readiness;\n need(\n `${field}.readiness`,\n timing === undefined ||\n (isObject(timing) &&\n Object.entries(timing).every(\n ([key, value]) =>\n (PROBE_TIMING_FIELDS as readonly string[]).includes(key) &&\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value >= (key === 'initialDelaySeconds' ? 0 : 1),\n )),\n `an object of whole numbers using only: ${PROBE_TIMING_FIELDS.join(', ')}`,\n );\n}\n\n/**\n * Check the shape of the inputs and that they only name services the\n * declaration has. Returns one sentence per problem.\n */\nfunction inputProblems(\n inputs: unknown,\n declaration: ComposeDeploymentDeclaration,\n): string[] {\n if (!isObject(inputs)) {\n return ['The inputs must be a JSON object. See the deployment guide.'];\n }\n const problems: string[] = [];\n const need = (field: string, ok: boolean, what: string): void => {\n if (!ok) problems.push(`\\`${field}\\` must be ${what}.`);\n };\n const services = declaration.workloads.map((workload) => workload.name);\n const web = declaration.workloads.find((item) => item.role === 'web')?.name;\n\n need('release', isObject(inputs.release), 'an object');\n\n if (isObject(inputs.app)) {\n need('app.environment', isText(inputs.app.environment), 'a name');\n need(\n 'app.name',\n inputs.app.name === undefined || isText(inputs.app.name),\n 'a name',\n );\n } else {\n need('app', false, 'an object');\n }\n\n need(\n 'current',\n inputs.current === undefined ||\n inputs.current === false ||\n isObject(inputs.current),\n \"left out or `false` for a first install, or the previous release's `target` block\",\n );\n\n let migrationSecret: string | undefined;\n if (isObject(inputs.bindings)) {\n const postgres = inputs.bindings.postgres;\n if (postgres !== undefined) {\n if (\n isObject(postgres) &&\n isSecretRef(postgres.runtime) &&\n isSecretRef(postgres.migration)\n ) {\n migrationSecret = postgres.migration.secretName;\n need(\n 'bindings.postgres.migration.secretName',\n postgres.migration.secretName !== postgres.runtime.secretName,\n 'a different Secret from `bindings.postgres.runtime.secretName`: the migration and the running application never share credentials',\n );\n } else {\n need(\n 'bindings.postgres',\n false,\n '`{ runtime, migration }`, each with `secretName` and `secretKey`',\n );\n }\n }\n const bucket = inputs.bindings.bucket;\n if (bucket === undefined || isSecretRef(bucket)) {\n need(\n 'bindings.bucket.secretName',\n bucket === undefined || bucket.secretName !== migrationSecret,\n 'a runtime Secret, not the migration Secret',\n );\n } else {\n need(\n 'bindings.bucket',\n false,\n 'an object with `secretName` and `secretKey`',\n );\n }\n } else {\n need('bindings', false, 'an object');\n }\n\n if (Array.isArray(inputs.env)) {\n const names = new Set<string>(\n isObject(inputs.bindings) && inputs.bindings.postgres !== undefined\n ? ['DATABASE_URL']\n : [],\n );\n inputs.env.forEach((entry, index) => {\n const field = `env[${index}]`;\n if (!isObject(entry) || !isText(entry.name) || !isSecretRef(entry)) {\n need(\n field,\n false,\n 'an object with `name`, `secretName` and `secretKey`',\n );\n return;\n }\n // Kubernetes keeps the last of two variables with one name, which\n // would silently replace the bound database credential or an earlier\n // entry.\n need(\n `${field}.name`,\n !names.has(entry.name),\n entry.name === 'DATABASE_URL'\n ? 'something other than `DATABASE_URL`, which the `postgres` binding sets'\n : `unique: another entry already sets \\`${entry.name}\\``,\n );\n names.add(entry.name);\n need(\n `${field}.secretName`,\n entry.secretName !== migrationSecret,\n 'a runtime Secret, not the migration Secret',\n );\n need(\n `${field}.services`,\n entry.services === undefined ||\n (Array.isArray(entry.services) &&\n entry.services.length > 0 &&\n entry.services.every((name) => services.includes(name))),\n `left out, or a list naming one or more of: ${services.join(', ')}`,\n );\n });\n } else {\n need('env', inputs.env === undefined, 'a list');\n }\n\n if (isObject(inputs.defaults)) {\n need(\n 'defaults.resources',\n isObject(inputs.defaults.resources),\n 'an object',\n );\n need(\n 'defaults.terminationGracePeriodSeconds',\n isPositiveInteger(inputs.defaults.terminationGracePeriodSeconds),\n 'a whole number of seconds',\n );\n need(\n 'defaults.replicas',\n inputs.defaults.replicas === undefined ||\n isPositiveInteger(inputs.defaults.replicas),\n 'a whole number of at least 1',\n );\n } else {\n need('defaults', false, 'an object');\n }\n\n if (isObject(inputs.workloads)) {\n for (const [name, overrides] of Object.entries(inputs.workloads)) {\n if (services.includes(name)) {\n workloadInputProblems(\n `workloads.${name}`,\n overrides,\n name === web,\n need,\n );\n } else {\n problems.push(\n `\\`workloads.${name}\\` names a service the declaration does not have. Its web and worker services are: ${services.join(', ')}.`,\n );\n }\n }\n } else {\n need(\n 'workloads',\n inputs.workloads === undefined,\n 'an object keyed by service name',\n );\n }\n\n need(\n 'migration',\n inputs.migration === undefined || isObject(inputs.migration),\n 'an object',\n );\n need('maintenance', isObject(inputs.maintenance), 'an object');\n if (isObject(inputs.ingress)) {\n need('ingress.className', isText(inputs.ingress.className), 'a name');\n need(\n 'ingress.host',\n inputs.ingress.host === undefined || isText(inputs.ingress.host),\n 'a hostname',\n );\n } else {\n need('ingress', false, 'an object');\n }\n return problems;\n}\n\nfunction secretEnv(name: string, ref: SmrtAppChartSecretRef) {\n return {\n name,\n valueFrom: {\n secretKeyRef: { name: ref.secretName, key: ref.secretKey },\n },\n };\n}\n\nfunction runtimeEnv(workload: string, inputs: SmrtAppChartInputs) {\n const env: Array<ReturnType<typeof secretEnv>> = [];\n if (inputs.bindings.postgres) {\n env.push(secretEnv('DATABASE_URL', inputs.bindings.postgres.runtime));\n }\n for (const entry of inputs.env ?? []) {\n if (entry.services === undefined || entry.services.includes(workload)) {\n env.push(secretEnv(entry.name, entry));\n }\n }\n return env;\n}\n\nfunction workloadValues(\n workload: ComposeDeploymentWorkload,\n image: string,\n inputs: SmrtAppChartInputs,\n): Record<string, unknown> {\n const overrides = own(inputs.workloads, workload.name) ?? {};\n const isWeb = workload.role === 'web';\n const role = isWeb ? 'web' : (overrides.role ?? 'background');\n const probe =\n 'path' in workload.health\n ? { httpGet: { path: workload.health.path, port: workload.port } }\n : { exec: { command: workload.health.command } };\n return {\n role,\n writer: overrides.writer ?? true,\n image,\n // The chart's `command` replaces the image's entrypoint, so the complete\n // argv is the declared entrypoint followed by the declared command.\n command: [...(workload.entrypoint ?? []), ...(workload.command ?? [])],\n env: runtimeEnv(workload.name, inputs),\n // A singleton runner stays at one replica whatever the default is.\n replicas:\n role === 'background' || role === 'schedule'\n ? 1\n : (overrides.replicas ?? inputs.defaults.replicas ?? 1),\n readinessProbe: { ...probe, ...(overrides.readiness ?? {}) },\n resources: overrides.resources ?? inputs.defaults.resources,\n terminationGracePeriodSeconds:\n overrides.terminationGracePeriodSeconds ??\n inputs.defaults.terminationGracePeriodSeconds,\n ...(isWeb ? { port: workload.port, service: { port: workload.port } } : {}),\n };\n}\n\n/**\n * Render `smrt-app` chart values from a declaration resolved at the `deploy`\n * stage. Throws {@link SmrtAppChartValuesError} listing every problem when\n * the declaration or the inputs cannot produce a faithful release.\n *\n * `target` is rendered from the declaration. `current` is whatever the caller\n * passes as the running release and is never synthesized.\n */\nexport function renderSmrtAppChartValues(\n declaration: ComposeDeploymentDeclaration,\n inputs: SmrtAppChartInputs,\n): Record<string, unknown> {\n const problems = inputProblems(inputs, declaration);\n if (problems.length > 0) throw new SmrtAppChartValuesError(problems);\n\n const name = inputs.app.name ?? declaration.name;\n if (name === undefined || !CHART_NAME.test(name)) {\n problems.push(\n name === undefined\n ? 'The application has no name. Set `name:` at the top of the Compose file or `app.name` in the inputs.'\n : `The application name \\`${name}\\` must be lowercase letters, digits and hyphens, starting with a letter, at most 31 characters.`,\n );\n }\n\n const host = inputs.ingress.host ?? declaration.domain;\n if (host === undefined) {\n problems.push(\n 'There is no hostname to serve on. Set `domain` in the `x-happyvertical` block or `ingress.host` in the inputs.',\n );\n }\n\n const images: Record<string, string> = {};\n for (const workload of declaration.workloads) {\n if (RESERVED_WORKLOAD_NAMES.includes(workload.name)) {\n problems.push(\n `Service \\`${workload.name}\\` uses a name the chart keeps for its own resources (${RESERVED_WORKLOAD_NAMES.join(', ')}). Rename the service.`,\n );\n }\n if (workload.image !== undefined && DIGEST_IMAGE.test(workload.image)) {\n images[workload.name] = workload.image;\n } else {\n problems.push(\n `Service \\`${workload.name}\\` has no image digest. Validate the Compose file at the \\`deploy\\` stage with the digests CI pushed.`,\n );\n }\n if (workload.entrypoint === undefined) {\n problems.push(\n `Service \\`${workload.name}\\` leaves its entrypoint to the image. The chart starts a workload with exactly the command it is given and never runs the image's own entrypoint, so the Compose file has to state it: add \\`entrypoint:\\` to the service, naming the image's entrypoint, or \\`entrypoint: []\\` when \\`command\\` is complete on its own.`,\n );\n } else if (\n workload.entrypoint.length + (workload.command ?? []).length ===\n 0\n ) {\n problems.push(\n `Service \\`${workload.name}\\` has an empty \\`entrypoint\\` and no \\`command\\`, so there is nothing to start.`,\n );\n }\n if (workload.volumes.length > 0) {\n problems.push(\n `Service \\`${workload.name}\\` mounts a data volume (\\`${workload.volumes[0].name}\\`). The chart binds existing databases and buckets and has no persistent volumes; keep that data in a platform service.`,\n );\n }\n }\n\n const kinds = new Set(declaration.bindings.map((binding) => binding.kind));\n if (!kinds.has('postgres')) {\n problems.push(\n 'The declaration has no `postgres` binding. The chart binds exactly one existing PostgreSQL database.',\n );\n } else if (!inputs.bindings.postgres) {\n problems.push(\n 'The declaration binds `postgres` but the inputs have no `bindings.postgres` Secret references.',\n );\n }\n const bucket = declaration.bindings.find(\n (binding) => binding.kind === 'bucket',\n );\n if (bucket && !inputs.bindings.bucket) {\n problems.push(\n 'The declaration binds `bucket` but the inputs have no `bindings.bucket` Secret reference.',\n );\n }\n\n if (problems.length > 0 || name === undefined || host === undefined) {\n throw new SmrtAppChartValuesError(problems);\n }\n\n const workloads: Record<string, unknown> = {};\n for (const workload of declaration.workloads) {\n workloads[workload.name] = workloadValues(\n workload,\n images[workload.name],\n inputs,\n );\n }\n const { host: _host, className, ...ingress } = inputs.ingress;\n return {\n release: { ...inputs.release },\n app: { name, environment: inputs.app.environment },\n current: inputs.current ? inputs.current : false,\n target: {\n workloads,\n migration: {\n image: images[declaration.migrate.service],\n command: declaration.migrate.command,\n env: inputs.bindings.postgres\n ? [secretEnv('DATABASE_URL', inputs.bindings.postgres.migration)]\n : [],\n guard: SMRT_RELEASE_GUARD,\n resources: inputs.migration?.resources ?? inputs.defaults.resources,\n terminationGracePeriodSeconds:\n inputs.migration?.terminationGracePeriodSeconds ??\n inputs.defaults.terminationGracePeriodSeconds,\n },\n },\n maintenance: inputs.maintenance,\n bindings: {\n database: inputs.bindings.postgres?.runtime,\n privateBuckets:\n bucket && inputs.bindings.bucket\n ? [{ name: bucket.name, ...inputs.bindings.bucket }]\n : [],\n },\n ingress: { host, className, ...ingress },\n };\n}\n","/**\n * The compose deployment contract: a Compose file annotated with\n * `x-happyvertical` extension fields is an application's deployment\n * declaration. Compose ignores `x-` keys, so the same file runs locally, on a\n * self-hosted box, and on a platform that reads the annotations.\n *\n * This module validates a parsed Compose document against contract version 1\n * and the supported platform subset, and resolves it into a plain declaration\n * that a platform composer or the `smrt-app` chart renderer consumes. It does\n * no I/O and has no Node dependency: the caller parses the YAML.\n *\n * The published JSON Schema (`schemas/x-happyvertical.v1.schema.json`) covers\n * the shape of the annotations. The rules that span services live here.\n */\n\n/** The Compose extension key the contract lives under. */\nexport const X_HAPPYVERTICAL_KEY = 'x-happyvertical';\n\n/** The contract version this module validates. */\nexport const X_HAPPYVERTICAL_VERSION = 1;\n\n/** `$id` of the published JSON Schema for {@link X_HAPPYVERTICAL_VERSION}. */\nexport const X_HAPPYVERTICAL_SCHEMA_ID =\n 'https://s-m-r-t.dev/schemas/x-happyvertical/v1.schema.json';\n\n/** Platform presets a version 1 declaration may name. */\nexport const X_HAPPYVERTICAL_PRESETS = ['smrt'] as const;\n\n/** Roles a service the application runs may take. */\nexport const X_HAPPYVERTICAL_ROLES = ['web', 'worker'] as const;\n\n/** Platform services a local container may stand in for. */\nexport const X_HAPPYVERTICAL_BINDINGS = [\n 'postgres',\n 'bucket',\n 'email',\n 'ai',\n] as const;\n\nexport type XHappyVerticalPreset = (typeof X_HAPPYVERTICAL_PRESETS)[number];\nexport type XHappyVerticalRole = (typeof X_HAPPYVERTICAL_ROLES)[number];\nexport type XHappyVerticalBinding = (typeof X_HAPPYVERTICAL_BINDINGS)[number];\n\n/**\n * `declare` checks the file as it sits in the repository: services may be\n * built locally or use tags. `deploy` additionally requires every web and\n * worker service to resolve to an image digest, because the platform deploys\n * what CI already built and never runs `build:`.\n */\nexport type ComposeDeploymentStage = 'declare' | 'deploy';\n\nexport interface ComposeDeploymentOptions {\n /** Defaults to `declare`. */\n stage?: ComposeDeploymentStage;\n /**\n * Image digest references by service name (`registry/name@sha256:…`),\n * normally the digests a release carries. They take precedence over the\n * `image:` written in the file.\n */\n images?: Record<string, string>;\n}\n\nexport type ComposeDeploymentIssueCode =\n | 'document-invalid'\n | 'not-self-contained'\n | 'contract-missing'\n | 'contract-invalid'\n | 'version-unsupported'\n | 'preset-unknown'\n | 'domain-invalid'\n | 'migrate-missing'\n | 'migrate-invalid'\n | 'migrate-service-not-role'\n | 'services-missing'\n | 'service-invalid'\n | 'service-name-invalid'\n | 'annotation-invalid'\n | 'role-and-binding'\n | 'role-unknown'\n | 'binding-unknown'\n | 'binding-duplicate'\n | 'binding-with-health'\n | 'binding-no-local-image'\n | 'health-missing'\n | 'health-invalid'\n | 'worker-health-needs-command'\n | 'web-service-count'\n | 'ingress-port-count'\n | 'ingress-port-invalid'\n | 'worker-publishes-port'\n | 'service-no-image'\n | 'image-not-digest'\n | 'image-for-unknown-service'\n | 'privileged'\n | 'host-network'\n | 'volume-not-declared'\n | 'volume-not-plain'\n | 'command-not-list'\n | 'interpolated-value'\n | 'merge-key-unresolved'\n | 'local-only-service';\n\nexport interface ComposeDeploymentIssue {\n code: ComposeDeploymentIssueCode;\n severity: 'error' | 'warning';\n /** Where in the Compose file the problem is, for example `services.web.ports`. */\n path: string;\n /** The service the issue belongs to, when it belongs to one. */\n service?: string;\n /** What is wrong, in plain language. */\n message: string;\n /** What to change. */\n fix: string;\n}\n\nexport type ComposeDeploymentHealth = { path: string } | { command: string[] };\n\nexport interface ComposeDeploymentVolume {\n /** Name of the volume declared under top-level `volumes:`. */\n name: string;\n /** Path the volume is mounted at inside the container. */\n target: string;\n readOnly: boolean;\n}\n\nexport interface ComposeDeploymentWorkload {\n name: string;\n role: XHappyVerticalRole;\n /**\n * At the `deploy` stage, always an image digest reference. At the `declare`\n * stage, the `image:` written in the file, absent for a service that is\n * only built locally or whose image is interpolated (contains `$`).\n */\n image?: string;\n /**\n * Present only when the Compose file sets `entrypoint`; an empty list means\n * the image's own entrypoint is ignored. Absent means the image's entrypoint\n * runs, with `command` as its arguments, exactly as Compose does.\n */\n entrypoint?: string[];\n /**\n * Present only when the Compose file sets `command`; an empty list means\n * the image's default command is discarded. Absent means the image's\n * default command runs.\n */\n command?: string[];\n /** The ingress port. Present on the web service only. */\n port?: number;\n health: ComposeDeploymentHealth;\n volumes: ComposeDeploymentVolume[];\n}\n\nexport interface ComposeDeploymentBinding {\n /** The Compose service name of the local stand-in. */\n name: string;\n kind: XHappyVerticalBinding;\n}\n\nexport interface ComposeDeploymentMigration {\n /** The web or worker service whose image runs the migration. */\n service: string;\n command: string[];\n /** Same meaning as {@link ComposeDeploymentWorkload.image}. */\n image?: string;\n}\n\n/** The resolved declaration. Environment values are deliberately not part of it. */\nexport interface ComposeDeploymentDeclaration {\n version: typeof X_HAPPYVERTICAL_VERSION;\n preset: XHappyVerticalPreset;\n stage: ComposeDeploymentStage;\n /** Top-level Compose `name:`, when the file sets a literal one (no `$`). */\n name?: string;\n domain?: string;\n migrate: ComposeDeploymentMigration;\n workloads: ComposeDeploymentWorkload[];\n bindings: ComposeDeploymentBinding[];\n /** Services with no annotation. They run locally and are never deployed. */\n localOnly: string[];\n}\n\nexport interface ComposeDeploymentResult {\n ok: boolean;\n errors: ComposeDeploymentIssue[];\n warnings: ComposeDeploymentIssue[];\n /** Present only when there are no errors. */\n declaration?: ComposeDeploymentDeclaration;\n}\n\ntype UnknownRecord = Record<string, unknown>;\n\nconst SERVICE_NAME = /^[a-z][a-z0-9-]{0,30}$/;\nconst DIGEST_IMAGE = /^[a-zA-Z0-9./:_-]+@sha256:[a-f0-9]{64}$/;\nconst DOMAIN =\n /^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z][a-z0-9-]{0,61}[a-z0-9]$/;\nconst HEALTH_PATH = /^\\/\\S*$/;\n// A string command Compose splits exactly as whitespace does: no quoting,\n// escaping, or interpolation that a shell-style split would treat specially.\nconst PLAIN_COMMAND = /^[A-Za-z0-9_./:=@,+-]+( +[A-Za-z0-9_./:=@,+-]+)*$/;\nconst INTERPOLATION = /\\$\\{[^}]*\\}|\\$[A-Za-z_][A-Za-z0-9_]*/g;\n\nconst APPLICATION_FIELDS = ['version', 'preset', 'domain', 'migrate'];\nconst MIGRATE_FIELDS = ['service', 'command'];\nconst SERVICE_FIELDS = ['role', 'health', 'binding'];\nconst HEALTH_FIELDS = ['path', 'command'];\n\nfunction isRecord(value: unknown): value is UnknownRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isStringList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => typeof item === 'string' && item.length > 0)\n );\n}\n\n/**\n * Put an arbitrary parsed value into a message without ever throwing: the\n * document is hostile input and may hold objects with no usable `toString`,\n * cycles built from YAML aliases, or values JSON cannot serialize.\n */\nfunction describe(value: unknown): string {\n if (typeof value === 'string') {\n return value.length > 80 ? `${value.slice(0, 80)}…` : value;\n }\n if (\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n typeof value === 'bigint'\n ) {\n return `${value}`;\n }\n if (value === null || value === undefined) return 'an empty value';\n if (Array.isArray(value)) return 'a list';\n return typeof value === 'object' ? 'a mapping' : `a ${typeof value}`;\n}\n\n/**\n * Compose substitutes `$VAR` and `${VAR}` in every string of the file,\n * extension fields included, before it runs anything. A consumer of the\n * declaration reads the file as written, so a carried string that contains\n * `$` would mean one thing locally and another once deployed.\n */\nfunction refuseVariables(\n values: readonly string[],\n path: string,\n what: string,\n issues: IssueCollector,\n service?: string,\n): boolean {\n if (!values.some((value) => value.includes('$'))) return false;\n issues.error(\n 'interpolated-value',\n path,\n `${what} contains \\`$\\`. Compose replaces variables before it runs the stack, but the platform reads the file as written, so the two would not run the same thing.`,\n 'Write the literal value. Settings that differ between environments belong in the environment the application reads, not in this line.',\n service,\n );\n return true;\n}\n\n/**\n * Path of the first `<<` key anywhere in the document, or undefined. Visits\n * each object once, so cycles built from YAML aliases cannot loop.\n */\nfunction findMergeKey(root: unknown): string | undefined {\n const seen = new Set<object>();\n const pending: Array<[unknown, string]> = [[root, '']];\n while (pending.length > 0) {\n const [value, path] = pending.pop() as [unknown, string];\n if (typeof value !== 'object' || value === null || seen.has(value)) {\n continue;\n }\n seen.add(value);\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n pending.push([item, `${path}[${index}]`]);\n });\n continue;\n }\n for (const [key, item] of Object.entries(value)) {\n const here = path ? `${path}.${key}` : key;\n if (key === '<<') return here;\n pending.push([item, here]);\n }\n }\n return undefined;\n}\n\n/** Compose interpolates this value, so the text in the file is not what runs. */\nfunction isLiteral(value: string): boolean {\n return !value.includes('$');\n}\n\nfunction quoteList(values: readonly string[]): string {\n return values.map((value) => `\\`${value}\\``).join(', ');\n}\n\nfunction unknownFields(value: UnknownRecord, known: string[]): string[] {\n return Object.keys(value).filter((key) => !known.includes(key));\n}\n\nclass IssueCollector {\n readonly errors: ComposeDeploymentIssue[] = [];\n readonly warnings: ComposeDeploymentIssue[] = [];\n\n error(\n code: ComposeDeploymentIssueCode,\n path: string,\n message: string,\n fix: string,\n service?: string,\n ): void {\n this.errors.push({\n code,\n severity: 'error',\n path,\n ...(service ? { service } : {}),\n message,\n fix,\n });\n }\n\n warning(\n code: ComposeDeploymentIssueCode,\n path: string,\n message: string,\n fix: string,\n service?: string,\n ): void {\n this.warnings.push({\n code,\n severity: 'warning',\n path,\n ...(service ? { service } : {}),\n message,\n fix,\n });\n }\n}\n\ninterface ParsedApplication {\n preset?: XHappyVerticalPreset;\n domain?: string;\n migrateService?: string;\n migrateCommand?: string[];\n}\n\nfunction parseApplication(\n document: UnknownRecord,\n issues: IssueCollector,\n): ParsedApplication {\n const path = X_HAPPYVERTICAL_KEY;\n const block = document[X_HAPPYVERTICAL_KEY];\n if (block === undefined) {\n issues.error(\n 'contract-missing',\n path,\n `The file has no top-level \\`${X_HAPPYVERTICAL_KEY}\\` block, so it is an ordinary Compose file and not a deployment declaration.`,\n `Add a top-level \\`${X_HAPPYVERTICAL_KEY}\\` block with \\`version: 1\\`, \\`preset: smrt\\` and a \\`migrate\\` command.`,\n );\n return {};\n }\n if (!isRecord(block)) {\n issues.error(\n 'contract-invalid',\n path,\n `The top-level \\`${X_HAPPYVERTICAL_KEY}\\` block must be a mapping of fields.`,\n 'Write it as indented `key: value` lines: `version`, `preset`, `domain`, `migrate`.',\n );\n return {};\n }\n\n const parsed: ParsedApplication = {};\n for (const field of unknownFields(block, APPLICATION_FIELDS)) {\n issues.error(\n 'contract-invalid',\n `${path}.${field}`,\n `\\`${field}\\` is not a field of the version 1 contract.`,\n `Remove it or fix the spelling. The top-level fields are ${quoteList(APPLICATION_FIELDS)}.`,\n );\n }\n\n if (block.version !== X_HAPPYVERTICAL_VERSION) {\n issues.error(\n 'version-unsupported',\n `${path}.version`,\n block.version === undefined\n ? 'The contract version is missing.'\n : `Contract version \\`${describe(block.version)}\\` is not supported here.`,\n 'Set `version: 1` (a number, without quotes).',\n );\n }\n\n if (\n typeof block.preset === 'string' &&\n (X_HAPPYVERTICAL_PRESETS as readonly string[]).includes(block.preset)\n ) {\n parsed.preset = block.preset as XHappyVerticalPreset;\n } else {\n issues.error(\n 'preset-unknown',\n `${path}.preset`,\n block.preset === undefined\n ? 'The preset is missing, so the platform does not know what kind of application this is.'\n : `\\`${describe(block.preset)}\\` is not a preset the platform knows.`,\n `Set \\`preset\\` to one of: ${quoteList(X_HAPPYVERTICAL_PRESETS)}.`,\n );\n }\n\n if (block.domain !== undefined) {\n if (\n typeof block.domain === 'string' &&\n block.domain.length <= 253 &&\n DOMAIN.test(block.domain)\n ) {\n parsed.domain = block.domain;\n } else {\n issues.error(\n 'domain-invalid',\n `${path}.domain`,\n `\\`${describe(block.domain)}\\` is not a hostname.`,\n 'Write only the hostname in lowercase, for example `app.example.com`: no `https://`, no port, no path.',\n );\n }\n }\n\n const migrate = block.migrate;\n if (migrate === undefined) {\n issues.error(\n 'migrate-missing',\n `${path}.migrate`,\n 'There is no `migrate` entry, so the platform does not know how to prepare the database before a release starts.',\n 'Add `migrate:` with a `command` list, for example `command: [\"pnpm\", \"exec\", \"smrt\", \"db:migrate\"]`.',\n );\n return parsed;\n }\n if (!isRecord(migrate)) {\n issues.error(\n 'migrate-invalid',\n `${path}.migrate`,\n '`migrate` must be a mapping with a `command`.',\n 'Write `migrate:` followed by an indented `command:` list.',\n );\n return parsed;\n }\n for (const field of unknownFields(migrate, MIGRATE_FIELDS)) {\n issues.error(\n 'migrate-invalid',\n `${path}.migrate.${field}`,\n `\\`${field}\\` is not a field of \\`migrate\\`.`,\n `Remove it or fix the spelling. \\`migrate\\` takes ${quoteList(MIGRATE_FIELDS)}.`,\n );\n }\n if (isStringList(migrate.command)) {\n if (\n !refuseVariables(\n migrate.command,\n `${path}.migrate.command`,\n 'The migration command',\n issues,\n )\n ) {\n parsed.migrateCommand = [...migrate.command];\n }\n } else {\n issues.error(\n 'migrate-invalid',\n `${path}.migrate.command`,\n 'The migration command must be a list with one argument per item.',\n 'Write it as a list, for example `command: [\"pnpm\", \"exec\", \"smrt\", \"db:migrate\"]`.',\n );\n }\n if (migrate.service !== undefined) {\n if (typeof migrate.service === 'string' && migrate.service.length > 0) {\n parsed.migrateService = migrate.service;\n } else {\n issues.error(\n 'migrate-invalid',\n `${path}.migrate.service`,\n '`migrate.service` must be the name of a service in this file.',\n 'Name your web or worker service, or remove the line to use the web service.',\n );\n }\n }\n return parsed;\n}\n\nfunction parseHealth(\n name: string,\n role: XHappyVerticalRole,\n health: unknown,\n issues: IssueCollector,\n): ComposeDeploymentHealth | undefined {\n const path = `services.${name}.${X_HAPPYVERTICAL_KEY}.health`;\n if (health === undefined) {\n issues.error(\n 'health-missing',\n path,\n `Service \\`${name}\\` has no health check, so the platform cannot tell when it is ready.`,\n role === 'web'\n ? 'Add `health:` with a `path` that answers 200 when the app is ready, for example `path: /api/health`.'\n : 'Add `health:` with a `command` list that exits 0 when the worker is ready.',\n name,\n );\n return undefined;\n }\n if (!isRecord(health)) {\n issues.error(\n 'health-invalid',\n path,\n `The health check of \\`${name}\\` must be a mapping with either \\`path\\` or \\`command\\`.`,\n 'Write `health:` followed by an indented `path:` or `command:`.',\n name,\n );\n return undefined;\n }\n const extra = unknownFields(health, HEALTH_FIELDS);\n if (extra.length > 0) {\n issues.error(\n 'health-invalid',\n `${path}.${extra[0]}`,\n `\\`${extra[0]}\\` is not a field of a health check.`,\n `Remove it or fix the spelling. A health check takes ${quoteList(HEALTH_FIELDS)}.`,\n name,\n );\n return undefined;\n }\n const hasPath = health.path !== undefined;\n const hasCommand = health.command !== undefined;\n if (hasPath === hasCommand) {\n issues.error(\n 'health-invalid',\n path,\n hasPath\n ? `The health check of \\`${name}\\` has both \\`path\\` and \\`command\\`.`\n : `The health check of \\`${name}\\` is empty.`,\n 'Keep exactly one: `path` for an HTTP check, or `command` for a check run inside the container.',\n name,\n );\n return undefined;\n }\n if (hasPath) {\n if (role === 'worker') {\n issues.error(\n 'worker-health-needs-command',\n `${path}.path`,\n `Worker \\`${name}\\` has an HTTP health path, but workers do not serve HTTP.`,\n 'Use `command:` with a list that exits 0 when the worker is ready.',\n name,\n );\n return undefined;\n }\n if (typeof health.path !== 'string' || !HEALTH_PATH.test(health.path)) {\n issues.error(\n 'health-invalid',\n `${path}.path`,\n `The health path of \\`${name}\\` must start with \\`/\\` and contain no spaces.`,\n 'Write a path such as `/api/health`.',\n name,\n );\n return undefined;\n }\n if (\n refuseVariables(\n [health.path],\n `${path}.path`,\n `The health path of \\`${name}\\``,\n issues,\n name,\n )\n ) {\n return undefined;\n }\n return { path: health.path };\n }\n if (!isStringList(health.command)) {\n issues.error(\n 'health-invalid',\n `${path}.command`,\n `The health command of \\`${name}\\` must be a list with one argument per item.`,\n 'Write it as a list, for example `command: [\"pnpm\", \"exec\", \"smrt\", \"app\", \"doctor\"]`.',\n name,\n );\n return undefined;\n }\n if (\n refuseVariables(\n health.command,\n `${path}.command`,\n `The health command of \\`${name}\\``,\n issues,\n name,\n )\n ) {\n return undefined;\n }\n return { command: [...health.command] };\n}\n\nfunction parseCommand(\n name: string,\n field: 'command' | 'entrypoint',\n value: unknown,\n issues: IssueCollector,\n): string[] | undefined {\n if (value === undefined || value === null) return undefined;\n // Empty is meaningful in Compose, for both fields: `[]` or '' discards what\n // the image declares, and only a missing or null value inherits it.\n const empty =\n (Array.isArray(value) && value.length === 0) ||\n (typeof value === 'string' && value.trim() === '');\n if (empty) return [];\n const path = `services.${name}.${field}`;\n const what = `The \\`${field}\\` of \\`${name}\\``;\n if (isStringList(value)) {\n return refuseVariables(value, path, what, issues, name)\n ? undefined\n : [...value];\n }\n if (typeof value === 'string') {\n if (refuseVariables([value], path, what, issues, name)) return undefined;\n if (PLAIN_COMMAND.test(value.trim())) return value.trim().split(/ +/);\n }\n issues.error(\n 'command-not-list',\n `services.${name}.${field}`,\n `The \\`${field}\\` of \\`${name}\\` uses quoting or shell syntax, or is not text, which Compose and the platform would read differently.`,\n `Write \\`${field}\\` as a list with one argument per item, for example \\`[\"node\", \"build\"]\\`.`,\n name,\n );\n return undefined;\n}\n\ninterface PortScan {\n ports: number[];\n invalid: boolean;\n}\n\nfunction scanPortEntry(\n name: string,\n field: 'ports' | 'expose',\n entry: unknown,\n index: number,\n issues: IssueCollector,\n): number | undefined {\n const path = `services.${name}.${field}[${index}]`;\n const invalid = (reason: string): undefined => {\n issues.error(\n 'ingress-port-invalid',\n path,\n `Port entry \\`${describe(entry)}\\` of \\`${name}\\` ${reason}.`,\n 'Publish one fixed TCP port, for example `\"3000:3000\"`.',\n name,\n );\n return undefined;\n };\n\n if (typeof entry === 'number') {\n return Number.isInteger(entry) && entry > 0 && entry < 65536\n ? entry\n : invalid('is not a valid port number');\n }\n if (typeof entry === 'string') {\n // A published side may be interpolated (`${WEB_PORT:-3000}:3000`); only\n // the container side has to be a literal the platform can read.\n const withoutVariables = entry.replace(INTERPOLATION, '\\u0000');\n const [address, protocol] = withoutVariables.split('/');\n if (protocol !== undefined && protocol.toLowerCase() !== 'tcp') {\n return invalid('is not TCP');\n }\n const container = address.split(':').at(-1) ?? '';\n if (!/^\\d+$/.test(container)) {\n return invalid(\n container.includes('-')\n ? 'is a port range'\n : 'does not name a fixed container port',\n );\n }\n const port = Number(container);\n return port > 0 && port < 65536\n ? port\n : invalid('is not a valid port number');\n }\n if (isRecord(entry)) {\n if (entry.mode !== undefined && entry.mode !== 'ingress') {\n issues.error(\n 'host-network',\n path,\n `Service \\`${name}\\` publishes a port in \\`${describe(entry.mode)}\\` mode, which binds it to the network of the machine it runs on.`,\n 'Remove the `mode` line. The platform routes traffic to the container for you.',\n name,\n );\n return undefined;\n }\n if (\n entry.protocol !== undefined &&\n !(\n typeof entry.protocol === 'string' &&\n entry.protocol.toLowerCase() === 'tcp'\n )\n ) {\n return invalid('is not TCP');\n }\n const target =\n typeof entry.target === 'number'\n ? entry.target\n : typeof entry.target === 'string' && /^\\d+$/.test(entry.target)\n ? Number(entry.target)\n : Number.NaN;\n return Number.isInteger(target) && target > 0 && target < 65536\n ? target\n : invalid('does not name a fixed container port in `target`');\n }\n return invalid('is not a port');\n}\n\nfunction scanPorts(\n name: string,\n field: 'ports' | 'expose',\n value: unknown,\n issues: IssueCollector,\n): PortScan {\n if (value === undefined || value === null) {\n return { ports: [], invalid: false };\n }\n if (!Array.isArray(value)) {\n issues.error(\n 'ingress-port-invalid',\n `services.${name}.${field}`,\n `\\`${field}\\` of \\`${name}\\` must be a list.`,\n 'Publish one fixed TCP port, for example `ports: [\"3000:3000\"]`.',\n name,\n );\n return { ports: [], invalid: true };\n }\n const before = issues.errors.length;\n const ports = new Set<number>();\n value.forEach((entry, index) => {\n const port = scanPortEntry(name, field, entry, index, issues);\n if (port !== undefined) ports.add(port);\n });\n return { ports: [...ports], invalid: issues.errors.length > before };\n}\n\nfunction isHostPath(source: string): boolean {\n return (\n source.startsWith('.') ||\n source.startsWith('/') ||\n source.startsWith('~') ||\n source.includes('$') ||\n source.includes('\\\\') ||\n /^[A-Za-z]:/.test(source)\n );\n}\n\nfunction scanVolumes(\n name: string,\n service: UnknownRecord,\n declared: UnknownRecord,\n issues: IssueCollector,\n): ComposeDeploymentVolume[] {\n const volumes: ComposeDeploymentVolume[] = [];\n const notDeclared = (path: string, what: string): void => {\n issues.error(\n 'volume-not-declared',\n path,\n `Service \\`${name}\\` ${what}. The platform only keeps data in volumes the file declares.`,\n 'Declare a named volume under top-level `volumes:` and mount it as `name:/path/in/container`. Files the app needs belong in its image.',\n name,\n );\n };\n const useNamed = (\n path: string,\n source: string,\n target: string,\n readOnly: boolean,\n ): void => {\n if (!Object.hasOwn(declared, source)) {\n notDeclared(\n path,\n `mounts the volume \\`${source}\\`, which is not declared in this file`,\n );\n return;\n }\n const definition = declared[source];\n if (isRecord(definition)) {\n const external =\n definition.external !== undefined && definition.external !== false;\n const customDriver =\n definition.driver !== undefined && definition.driver !== 'local';\n if (external || customDriver || definition.driver_opts !== undefined) {\n issues.error(\n 'volume-not-plain',\n `volumes.${source}`,\n `Volume \\`${source}\\` is external or uses driver options, so its contents live somewhere this file does not describe.`,\n 'Declare it as a plain named volume (just `name:` with nothing under it).',\n name,\n );\n return;\n }\n }\n if (\n refuseVariables(\n [target],\n path,\n `The mount path of volume \\`${source}\\` in \\`${name}\\``,\n issues,\n name,\n )\n ) {\n return;\n }\n volumes.push({ name: source, target, readOnly });\n };\n\n if (\n Array.isArray(service.volumes_from)\n ? service.volumes_from.length > 0\n : service.volumes_from !== undefined && service.volumes_from !== null\n ) {\n notDeclared(\n `services.${name}.volumes_from`,\n \"borrows another container's volumes with `volumes_from`\",\n );\n }\n\n const entries = service.volumes;\n if (entries === undefined || entries === null) return volumes;\n if (!Array.isArray(entries)) {\n notDeclared(\n `services.${name}.volumes`,\n 'has a `volumes` entry that is not a list',\n );\n return volumes;\n }\n entries.forEach((entry, index) => {\n const path = `services.${name}.volumes[${index}]`;\n if (typeof entry === 'string') {\n // A drive letter or a backslash is a Windows host path; splitting it\n // on `:` would mistake the drive letter for a volume name.\n if (/^[A-Za-z]:[\\\\/]/.test(entry) || entry.includes('\\\\')) {\n notDeclared(\n path,\n `mounts \\`${describe(entry)}\\` from the machine it runs on (a bind mount)`,\n );\n return;\n }\n const [source, target, mode] = entry.split(':');\n if (target === undefined) {\n notDeclared(path, `mounts an unnamed volume at \\`${entry}\\``);\n } else if (isHostPath(source)) {\n notDeclared(\n path,\n `mounts \\`${source}\\` from the machine it runs on (a bind mount)`,\n );\n } else {\n useNamed(path, source, target, (mode ?? '').split(',').includes('ro'));\n }\n return;\n }\n if (isRecord(entry)) {\n const type = entry.type ?? 'volume';\n if (type === 'tmpfs') return;\n if (type !== 'volume') {\n notDeclared(\n path,\n `uses a \\`${describe(type)}\\` mount, which reads from the machine it runs on`,\n );\n return;\n }\n if (typeof entry.source !== 'string' || entry.source.length === 0) {\n notDeclared(path, 'mounts an unnamed volume');\n return;\n }\n if (typeof entry.target !== 'string' || entry.target.length === 0) {\n notDeclared(path, 'has a volume entry with no `target` path');\n return;\n }\n useNamed(\n path,\n entry.source,\n entry.target,\n entry.read_only !== undefined && entry.read_only !== false,\n );\n return;\n }\n notDeclared(path, 'has a volume entry that is not a mount');\n });\n return volumes;\n}\n\ninterface RoleService {\n name: string;\n role: XHappyVerticalRole;\n definition: UnknownRecord;\n health?: ComposeDeploymentHealth;\n}\n\nfunction resolveImage(\n entry: RoleService,\n options: ComposeDeploymentOptions,\n stage: ComposeDeploymentStage,\n issues: IssueCollector,\n): string | undefined {\n const { name, definition } = entry;\n const declared =\n typeof definition.image === 'string' && definition.image.length > 0\n ? definition.image\n : undefined;\n const hasBuild = definition.build !== undefined && definition.build !== null;\n // Own keys only: a service may be called `constructor` or `toString`.\n const supplied =\n options.images && Object.hasOwn(options.images, name)\n ? options.images[name]\n : undefined;\n\n if (declared === undefined && !hasBuild) {\n issues.error(\n 'service-no-image',\n `services.${name}`,\n `Service \\`${name}\\` has neither \\`image\\` nor \\`build\\`, so nothing can run it.`,\n 'Add `build: .` to build it locally, or `image:` with the image to run.',\n name,\n );\n }\n if (stage === 'declare') {\n // Informational at this stage: carry the image only as literal text.\n const image = supplied ?? declared;\n return image !== undefined && isLiteral(image) ? image : undefined;\n }\n\n const effective = supplied ?? declared;\n if (effective !== undefined && DIGEST_IMAGE.test(effective)) {\n return effective;\n }\n issues.error(\n 'image-not-digest',\n `services.${name}.image`,\n effective === undefined\n ? `Service \\`${name}\\` is only built locally. The platform deploys an image that CI already built and pushed; it never runs \\`build:\\`.`\n : `The image of \\`${name}\\` (\\`${effective}\\`) is a tag, which can change after it was tested. The platform deploys exact image digests only.`,\n `Supply the digest CI pushed for \\`${name}\\`, in the form \\`registry/name@sha256:\\` followed by 64 hex characters.`,\n name,\n );\n return undefined;\n}\n\nfunction checkRoleService(\n entry: RoleService,\n declaredVolumes: UnknownRecord,\n options: ComposeDeploymentOptions,\n stage: ComposeDeploymentStage,\n issues: IssueCollector,\n): ComposeDeploymentWorkload | undefined {\n const { name, role, definition } = entry;\n const before = issues.errors.length;\n\n if (definition.extends !== undefined) {\n issues.error(\n 'not-self-contained',\n `services.${name}.extends`,\n `Service \\`${name}\\` takes part of its definition from another service with \\`extends\\`, so what it runs is not written here.`,\n 'Write the service out in full. The platform reads each service as written, in this one file.',\n name,\n );\n }\n\n const image = resolveImage(entry, options, stage, issues);\n\n // Fail closed: Compose reads YAML 1.1 booleans (`yes`, `on`), which a\n // YAML 1.2 parser hands over as strings. Anything but an explicit false is\n // treated as a request for privileged mode.\n if (\n definition.privileged !== undefined &&\n definition.privileged !== null &&\n definition.privileged !== false\n ) {\n issues.error(\n 'privileged',\n `services.${name}.privileged`,\n `Service \\`${name}\\` sets \\`privileged\\`. Privileged mode gives a container control of the machine it runs on, and Compose accepts more spellings of \"yes\" than can be told apart here.`,\n 'Remove the `privileged` line. The platform never runs privileged containers.',\n name,\n );\n }\n\n if (definition.network_mode === 'host') {\n issues.error(\n 'host-network',\n `services.${name}.network_mode`,\n `Service \\`${name}\\` uses the host's network instead of its own.`,\n 'Remove `network_mode: host`. Services reach each other by service name, and the platform routes outside traffic to the web service.',\n name,\n );\n }\n\n const volumes = scanVolumes(name, definition, declaredVolumes, issues);\n const entrypoint = parseCommand(\n name,\n 'entrypoint',\n definition.entrypoint,\n issues,\n );\n const command = parseCommand(name, 'command', definition.command, issues);\n\n let port: number | undefined;\n const publishesNothing =\n definition.ports === undefined ||\n definition.ports === null ||\n (Array.isArray(definition.ports) && definition.ports.length === 0);\n const published =\n role === 'web'\n ? scanPorts(name, 'ports', definition.ports, issues)\n : { ports: [], invalid: false };\n if (role === 'web') {\n const exposed =\n published.ports.length === 0 && !published.invalid\n ? scanPorts(name, 'expose', definition.expose, issues)\n : { ports: [], invalid: false };\n const ports = published.ports.length > 0 ? published.ports : exposed.ports;\n if (!published.invalid && !exposed.invalid && ports.length !== 1) {\n issues.error(\n 'ingress-port-count',\n `services.${name}.ports`,\n ports.length === 0\n ? `Web service \\`${name}\\` publishes no port, so there is nothing to send visitors to.`\n : `Web service \\`${name}\\` publishes ${ports.length} ports (${ports.join(', ')}). The platform routes visitors to exactly one.`,\n 'Publish exactly one port, the one the app listens on, for example `ports: [\"3000:3000\"]`.',\n name,\n );\n }\n port = ports[0];\n } else if (!publishesNothing) {\n issues.error(\n 'worker-publishes-port',\n `services.${name}.ports`,\n `Worker \\`${name}\\` publishes a port, but only the web service receives traffic.`,\n 'Remove `ports` from the worker, or give the service `role: web` if it is the one visitors reach.',\n name,\n );\n }\n\n if (issues.errors.length > before || entry.health === undefined) {\n return undefined;\n }\n return {\n name,\n role,\n ...(image !== undefined ? { image } : {}),\n ...(entrypoint ? { entrypoint } : {}),\n ...(command ? { command } : {}),\n ...(port !== undefined ? { port } : {}),\n health: entry.health,\n volumes,\n };\n}\n\n/**\n * Validate a parsed Compose document as a deployment declaration.\n *\n * Errors are things the platform refuses. Warnings never block: they report\n * services that only run locally. `declaration` is present when there are no\n * errors.\n */\nexport function validateComposeDeployment(\n document: unknown,\n options: ComposeDeploymentOptions = {},\n): ComposeDeploymentResult {\n const issues = new IssueCollector();\n const stage = options.stage ?? 'declare';\n const finish = (\n declaration?: ComposeDeploymentDeclaration,\n ): ComposeDeploymentResult => ({\n ok: issues.errors.length === 0,\n errors: issues.errors,\n warnings: issues.warnings,\n ...(issues.errors.length === 0 && declaration ? { declaration } : {}),\n });\n\n if (!isRecord(document)) {\n issues.error(\n 'document-invalid',\n '',\n 'This is not a Compose file: the top level must be a mapping with `services`.',\n 'Check that the file is valid YAML and starts with top-level keys such as `services:`.',\n );\n return finish();\n }\n\n // A `<<` key anywhere means the caller parsed without YAML merge keys, so\n // some mapping is missing whatever its anchor carries: a port's protocol, a\n // volume's driver, a whole service. Nothing below can be trusted, so stop.\n const mergeKey = findMergeKey(document);\n if (mergeKey !== undefined) {\n issues.error(\n 'merge-key-unresolved',\n mergeKey,\n 'The file still contains a YAML merge key (`<<`), so the part of it that comes from an anchor was not read.',\n 'Parse the file with YAML merge keys enabled, as Compose does (`smrt deploy:check` does this for you).',\n );\n return finish();\n }\n\n if (document.include !== undefined) {\n issues.error(\n 'not-self-contained',\n 'include',\n 'The file pulls in other Compose files with `include`.',\n 'Put every service in this one file. The platform reads this file and nothing else.',\n );\n }\n\n const application = parseApplication(document, issues);\n\n const services = document.services;\n if (!isRecord(services) || Object.keys(services).length === 0) {\n issues.error(\n 'services-missing',\n 'services',\n 'The file declares no services.',\n 'Add your application under `services:`, with at least a web service.',\n );\n return finish();\n }\n const declaredVolumes = isRecord(document.volumes) ? document.volumes : {};\n\n const roleServices: RoleService[] = [];\n const bindings: ComposeDeploymentBinding[] = [];\n const localOnly: string[] = [];\n\n for (const [name, definition] of Object.entries(services)) {\n if (!isRecord(definition)) {\n issues.error(\n 'service-invalid',\n `services.${name}`,\n `Service \\`${name}\\` is empty or not a mapping.`,\n 'Give it an `image` or `build` and the settings it needs, or remove it.',\n name,\n );\n continue;\n }\n const annotationPath = `services.${name}.${X_HAPPYVERTICAL_KEY}`;\n const annotation = definition[X_HAPPYVERTICAL_KEY];\n if (annotation === undefined) {\n localOnly.push(name);\n continue;\n }\n if (!isRecord(annotation)) {\n issues.error(\n 'annotation-invalid',\n annotationPath,\n `The \\`${X_HAPPYVERTICAL_KEY}\\` block of \\`${name}\\` must be a mapping.`,\n 'Write `role: web` or `role: worker` with a `health` check, or `binding:` with the platform service it stands in for.',\n name,\n );\n continue;\n }\n const extra = unknownFields(annotation, SERVICE_FIELDS);\n if (extra.length > 0) {\n issues.error(\n 'annotation-invalid',\n `${annotationPath}.${extra[0]}`,\n `\\`${extra[0]}\\` is not a field of a service annotation.`,\n `Remove it or fix the spelling. A service takes ${quoteList(SERVICE_FIELDS)}.`,\n name,\n );\n continue;\n }\n const hasRole = annotation.role !== undefined;\n const hasBinding = annotation.binding !== undefined;\n if (hasRole && hasBinding) {\n issues.error(\n 'role-and-binding',\n annotationPath,\n `Service \\`${name}\\` has both \\`role\\` and \\`binding\\`. A service is either part of your application or a stand-in for a platform service.`,\n 'Keep `role` for something you build and run, or `binding` for something the platform provides.',\n name,\n );\n continue;\n }\n if (!hasRole && !hasBinding) {\n issues.error(\n 'annotation-invalid',\n annotationPath,\n `The \\`${X_HAPPYVERTICAL_KEY}\\` block of \\`${name}\\` says neither what the service is nor what it stands in for.`,\n 'Add `role: web`, `role: worker`, or `binding:`. Remove the block if the service is only for local use.',\n name,\n );\n continue;\n }\n if (!SERVICE_NAME.test(name)) {\n issues.error(\n 'service-name-invalid',\n `services.${name}`,\n `The service name \\`${name}\\` cannot be used as a platform resource name.`,\n 'Rename it using lowercase letters, digits and hyphens, starting with a letter, at most 31 characters.',\n name,\n );\n }\n\n if (hasBinding) {\n const kind = annotation.binding;\n if (\n typeof kind !== 'string' ||\n !(X_HAPPYVERTICAL_BINDINGS as readonly string[]).includes(kind)\n ) {\n issues.error(\n 'binding-unknown',\n `${annotationPath}.binding`,\n `\\`${describe(kind)}\\` is not a platform service this contract knows.`,\n `Set \\`binding\\` to one of: ${quoteList(X_HAPPYVERTICAL_BINDINGS)}.`,\n name,\n );\n continue;\n }\n if (annotation.health !== undefined) {\n issues.error(\n 'binding-with-health',\n `${annotationPath}.health`,\n `Binding \\`${name}\\` has a \\`health\\` check, but the platform runs its own service in place of this container.`,\n 'Remove `health` from the annotation. A Compose `healthcheck:` on the service is fine for local use.',\n name,\n );\n }\n const hasImage =\n typeof definition.image === 'string' && definition.image.length > 0;\n const hasBuild =\n definition.build !== undefined && definition.build !== null;\n if (!hasImage && !hasBuild) {\n issues.error(\n 'binding-no-local-image',\n `services.${name}.image`,\n `Binding \\`${name}\\` has no local image, so the stack cannot run anywhere the platform is not providing ${kind}.`,\n 'Add the image you run locally, for example `image: postgres:18-alpine`, so the file stays a complete working stack on its own.',\n name,\n );\n }\n const duplicate = bindings.find((binding) => binding.kind === kind);\n if (duplicate) {\n issues.error(\n 'binding-duplicate',\n `${annotationPath}.binding`,\n `Services \\`${duplicate.name}\\` and \\`${name}\\` both stand in for \\`${kind}\\`. Version 1 binds each platform service once.`,\n `Keep one \\`${kind}\\` binding.`,\n name,\n );\n continue;\n }\n bindings.push({ name, kind: kind as XHappyVerticalBinding });\n continue;\n }\n\n const role = annotation.role;\n if (\n typeof role !== 'string' ||\n !(X_HAPPYVERTICAL_ROLES as readonly string[]).includes(role)\n ) {\n issues.error(\n 'role-unknown',\n `${annotationPath}.role`,\n `\\`${describe(role)}\\` is not a role.`,\n `Set \\`role\\` to one of: ${quoteList(X_HAPPYVERTICAL_ROLES)}.`,\n name,\n );\n continue;\n }\n roleServices.push({\n name,\n role: role as XHappyVerticalRole,\n definition,\n health: parseHealth(\n name,\n role as XHappyVerticalRole,\n annotation.health,\n issues,\n ),\n });\n }\n\n const webServices = roleServices.filter((entry) => entry.role === 'web');\n if (webServices.length !== 1) {\n issues.error(\n 'web-service-count',\n 'services',\n webServices.length === 0\n ? 'No service has `role: web`, so there is nothing for visitors to reach.'\n : `${webServices.length} services have \\`role: web\\` (${quoteList(webServices.map((entry) => entry.name))}). The platform routes visitors to exactly one.`,\n 'Give exactly one service `role: web`. Anything else you run is `role: worker`.',\n );\n }\n\n const workloads: ComposeDeploymentWorkload[] = [];\n for (const entry of roleServices) {\n const workload = checkRoleService(\n entry,\n declaredVolumes,\n options,\n stage,\n issues,\n );\n if (workload) workloads.push(workload);\n }\n\n for (const name of Object.keys(options.images ?? {})) {\n if (!roleServices.some((entry) => entry.name === name)) {\n issues.error(\n 'image-for-unknown-service',\n `services.${name}`,\n `An image digest was supplied for \\`${name}\\`, which is not a web or worker service in this file.`,\n `Supply digests only for: ${quoteList(roleServices.map((entry) => entry.name))}.`,\n name,\n );\n }\n }\n\n const migrateService = application.migrateService ?? webServices[0]?.name;\n if (\n application.migrateService !== undefined &&\n !roleServices.some((entry) => entry.name === application.migrateService)\n ) {\n issues.error(\n 'migrate-service-not-role',\n `${X_HAPPYVERTICAL_KEY}.migrate.service`,\n `\\`migrate.service\\` names \\`${application.migrateService}\\`, which is not a web or worker service in this file. The migration ships inside one of your application images.`,\n `Name one of: ${quoteList(roleServices.map((entry) => entry.name))}, or remove the line to use the web service.`,\n );\n }\n\n for (const name of localOnly) {\n issues.warning(\n 'local-only-service',\n `services.${name}`,\n `Service \\`${name}\\` has no \\`${X_HAPPYVERTICAL_KEY}\\` annotation. It runs on your machine only; the platform will not run it.`,\n 'Nothing to do if that is intended. Otherwise give it `role: web`, `role: worker` or a `binding`.',\n name,\n );\n }\n\n if (\n issues.errors.length > 0 ||\n application.preset === undefined ||\n application.migrateCommand === undefined ||\n migrateService === undefined\n ) {\n return finish();\n }\n\n const migrateImage = workloads.find(\n (workload) => workload.name === migrateService,\n )?.image;\n return finish({\n version: X_HAPPYVERTICAL_VERSION,\n preset: application.preset,\n stage,\n ...(typeof document.name === 'string' &&\n document.name.length > 0 &&\n isLiteral(document.name)\n ? { name: document.name }\n : {}),\n ...(application.domain !== undefined ? { domain: application.domain } : {}),\n migrate: {\n service: migrateService,\n command: application.migrateCommand,\n ...(migrateImage !== undefined ? { image: migrateImage } : {}),\n },\n workloads,\n bindings,\n localOnly,\n });\n}\n\nfunction formatIssue(issue: ComposeDeploymentIssue, index: number): string {\n const where = issue.path ? `${issue.path}: ` : '';\n return `${index + 1}. ${where}${issue.message}\\n Fix: ${issue.fix}`;\n}\n\n/** Render a validation result as plain text for a terminal or a log. */\nexport function formatComposeDeploymentReport(\n result: ComposeDeploymentResult,\n): string {\n const lines: string[] = [];\n if (result.ok) {\n lines.push('The deployment declaration is valid.');\n const declaration = result.declaration;\n if (declaration) {\n const describe = (workload: ComposeDeploymentWorkload): string =>\n workload.port !== undefined\n ? `${workload.name} (${workload.role}, port ${workload.port})`\n : `${workload.name} (${workload.role})`;\n lines.push(\n `Preset: ${declaration.preset}`,\n `Runs: ${declaration.workloads.map(describe).join(', ')}`,\n `Migration: ${declaration.migrate.command.join(' ')} (in the ${declaration.migrate.service} image)`,\n `Platform services: ${\n declaration.bindings.length > 0\n ? declaration.bindings\n .map((binding) => `${binding.kind} (local: ${binding.name})`)\n .join(', ')\n : 'none'\n }`,\n );\n if (declaration.domain) lines.push(`Domain: ${declaration.domain}`);\n }\n } else {\n const count = result.errors.length;\n lines.push(\n `The deployment declaration has ${count} problem${count === 1 ? '' : 's'}.`,\n '',\n ...result.errors.map(formatIssue),\n );\n }\n if (result.warnings.length > 0) {\n lines.push(\n '',\n `Runs only on your machine (the platform will not run it): ${result.warnings\n .map((warning) => warning.service ?? warning.path)\n .join(', ')}`,\n );\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,KAAK,IAAI;AACxB"}
1
+ {"version":3,"file":"deployment.js","names":[],"sources":["../src/deployment/chart-values.ts"],"sourcesContent":["/**\n * Self-host rendering of the compose deployment contract: turn a resolved\n * declaration into values for the `smrt-app` chart.\n *\n * The declaration says what the application is. Everything the chart needs\n * beyond that is environment-owned and comes in as explicit inputs: release\n * identity, Secret references, resources, the maintenance responder and the\n * ingress class. Nothing here invents a default for those, and the inputs are\n * checked: they normally come from a hand-written JSON file.\n */\n\nimport type {\n ComposeDeploymentDeclaration,\n ComposeDeploymentWorkload,\n} from './compose-contract.js';\n\n/**\n * The migration guard capability the chart requires a release to declare.\n * Rendering it is a declaration, not an implementation: the application's\n * `migrate.command` has to be a wrapper that implements the guard.\n */\nexport const SMRT_RELEASE_GUARD = 'smrt-release-v1';\n\nconst CHART_NAME = /^[a-z][a-z0-9-]{0,30}$/;\nconst DIGEST_IMAGE = /^[a-zA-Z0-9./:_-]+@sha256:[a-f0-9]{64}$/;\nconst WORKER_ROLES = ['background', 'task', 'schedule'] as const;\n// charts/smrt-app/templates/validate.yaml: \"reserved workload name\".\nconst RESERVED_WORKLOAD_NAMES = ['maintenance', 'inventory'];\nconst PROBE_TIMING_FIELDS = [\n 'initialDelaySeconds',\n 'periodSeconds',\n 'timeoutSeconds',\n 'failureThreshold',\n 'successThreshold',\n] as const;\n\nexport interface SmrtAppChartSecretRef {\n secretName: string;\n secretKey: string;\n}\n\nexport interface SmrtAppChartSecretEnv extends SmrtAppChartSecretRef {\n /** Environment variable name. */\n name: string;\n /** Limit the variable to these services. Defaults to every workload. */\n services?: string[];\n}\n\nexport interface SmrtAppChartResources {\n requests: Record<string, string>;\n limits: Record<string, string>;\n}\n\n/** Chart roles a contract `worker` may be rendered as. */\nexport type SmrtAppChartWorkerRole = (typeof WORKER_ROLES)[number];\n\n/** Timing of the readiness probe rendered from a service's `health`. */\nexport type SmrtAppChartProbeTiming = Partial<\n Record<(typeof PROBE_TIMING_FIELDS)[number], number>\n>;\n\nexport interface SmrtAppChartWorkloadInputs {\n /**\n * Chart role for a contract `worker`. Defaults to `background`, the\n * singleton runner. Not allowed on the web service.\n */\n role?: SmrtAppChartWorkerRole;\n /** `background` and `schedule` workloads are singletons and stay at 1. */\n replicas?: number;\n /** Whether the workload writes to the database. Defaults to `true`. */\n writer?: boolean;\n resources?: SmrtAppChartResources;\n terminationGracePeriodSeconds?: number;\n /** Kubernetes defaults apply to whatever is left out (1 s timeout, 10 s period). */\n readiness?: SmrtAppChartProbeTiming;\n}\n\nexport interface SmrtAppChartInputs {\n release: {\n id: string;\n phase: 'maintenance' | 'stopped' | 'migrate' | 'verify' | 'active';\n sequence: number;\n attempt: number;\n };\n app: {\n /** Defaults to the Compose file's top-level `name:`. */\n name?: string;\n environment: string;\n };\n /**\n * The runtime that is running now: the `target` block of the values\n * document the previous release was rendered to, unchanged. Leave it out\n * (or pass `false`) for a first install. It is never derived from the new\n * declaration, because the running release may differ from it in more than\n * its image digests.\n */\n current?: false | Record<string, unknown>;\n bindings: {\n /** Required when the declaration has a `postgres` binding. */\n postgres?: {\n /** Secret key holding the runtime `DATABASE_URL`. */\n runtime: SmrtAppChartSecretRef;\n /** Secret key holding the migration-only `DATABASE_URL`, in a different Secret. */\n migration: SmrtAppChartSecretRef;\n };\n /** Required when the declaration has a `bucket` binding. */\n bucket?: SmrtAppChartSecretRef;\n };\n /** Further runtime settings, each read from a named Secret key. */\n env?: SmrtAppChartSecretEnv[];\n defaults: {\n resources: SmrtAppChartResources;\n terminationGracePeriodSeconds: number;\n replicas?: number;\n };\n /** Per-service overrides, keyed by Compose service name. */\n workloads?: Record<string, SmrtAppChartWorkloadInputs>;\n migration?: {\n resources?: SmrtAppChartResources;\n terminationGracePeriodSeconds?: number;\n };\n /** Passed through as the chart's `maintenance` block. */\n maintenance: Record<string, unknown>;\n /** Passed through as the chart's `ingress` block. `host` defaults to the declared domain. */\n ingress: { className: string; host?: string } & Record<string, unknown>;\n}\n\n/** Thrown when a declaration cannot be rendered with the inputs given. */\nexport class SmrtAppChartValuesError extends Error {\n readonly problems: string[];\n\n constructor(problems: string[]) {\n super(\n `Cannot render smrt-app chart values:\\n${problems.map((problem) => `- ${problem}`).join('\\n')}`,\n );\n this.name = 'SmrtAppChartValuesError';\n this.problems = problems;\n }\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isText(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0;\n}\n\nfunction isPositiveInteger(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value > 0;\n}\n\nfunction isSecretRef(value: unknown): value is SmrtAppChartSecretRef {\n return isObject(value) && isText(value.secretName) && isText(value.secretKey);\n}\n\n/** Own keys only: a Compose service may be called `constructor` or `toString`. */\nfunction own<T>(\n record: Record<string, T> | undefined,\n key: string,\n): T | undefined {\n return record && Object.hasOwn(record, key) ? record[key] : undefined;\n}\n\nfunction workloadInputProblems(\n field: string,\n overrides: unknown,\n isWeb: boolean,\n need: (field: string, ok: boolean, what: string) => void,\n): void {\n if (!isObject(overrides)) {\n need(field, false, 'an object');\n return;\n }\n const role = overrides.role;\n if (role !== undefined) {\n if (isWeb) {\n need(\n `${field}.role`,\n false,\n \"left out: the web service is always the chart's `web` workload\",\n );\n } else {\n need(\n `${field}.role`,\n (WORKER_ROLES as readonly unknown[]).includes(role),\n `one of: ${WORKER_ROLES.join(', ')}`,\n );\n }\n }\n if (overrides.replicas !== undefined) {\n const singleton = !isWeb && role !== 'task';\n need(\n `${field}.replicas`,\n isPositiveInteger(overrides.replicas) &&\n (!singleton || overrides.replicas === 1),\n singleton\n ? '1: `background` and `schedule` workloads are singletons. Use `role: task` for a worker that scales'\n : 'a whole number of at least 1',\n );\n }\n need(\n `${field}.writer`,\n overrides.writer === undefined || typeof overrides.writer === 'boolean',\n '`true` or `false`',\n );\n need(\n `${field}.terminationGracePeriodSeconds`,\n overrides.terminationGracePeriodSeconds === undefined ||\n isPositiveInteger(overrides.terminationGracePeriodSeconds),\n 'a whole number of seconds',\n );\n need(\n `${field}.resources`,\n overrides.resources === undefined || isObject(overrides.resources),\n 'an object',\n );\n const timing = overrides.readiness;\n need(\n `${field}.readiness`,\n timing === undefined ||\n (isObject(timing) &&\n Object.entries(timing).every(\n ([key, value]) =>\n (PROBE_TIMING_FIELDS as readonly string[]).includes(key) &&\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value >= (key === 'initialDelaySeconds' ? 0 : 1),\n )),\n `an object of whole numbers using only: ${PROBE_TIMING_FIELDS.join(', ')}`,\n );\n}\n\n/**\n * Check the shape of the inputs and that they only name services the\n * declaration has. Returns one sentence per problem.\n */\nfunction inputProblems(\n inputs: unknown,\n declaration: ComposeDeploymentDeclaration,\n): string[] {\n if (!isObject(inputs)) {\n return ['The inputs must be a JSON object. See the deployment guide.'];\n }\n const problems: string[] = [];\n const need = (field: string, ok: boolean, what: string): void => {\n if (!ok) problems.push(`\\`${field}\\` must be ${what}.`);\n };\n const services = declaration.workloads.map((workload) => workload.name);\n const web = declaration.workloads.find((item) => item.role === 'web')?.name;\n\n need('release', isObject(inputs.release), 'an object');\n\n if (isObject(inputs.app)) {\n need('app.environment', isText(inputs.app.environment), 'a name');\n need(\n 'app.name',\n inputs.app.name === undefined || isText(inputs.app.name),\n 'a name',\n );\n } else {\n need('app', false, 'an object');\n }\n\n need(\n 'current',\n inputs.current === undefined ||\n inputs.current === false ||\n isObject(inputs.current),\n \"left out or `false` for a first install, or the previous release's `target` block\",\n );\n\n let migrationSecret: string | undefined;\n if (isObject(inputs.bindings)) {\n const postgres = inputs.bindings.postgres;\n if (postgres !== undefined) {\n if (\n isObject(postgres) &&\n isSecretRef(postgres.runtime) &&\n isSecretRef(postgres.migration)\n ) {\n migrationSecret = postgres.migration.secretName;\n need(\n 'bindings.postgres.migration.secretName',\n postgres.migration.secretName !== postgres.runtime.secretName,\n 'a different Secret from `bindings.postgres.runtime.secretName`: the migration and the running application never share credentials',\n );\n } else {\n need(\n 'bindings.postgres',\n false,\n '`{ runtime, migration }`, each with `secretName` and `secretKey`',\n );\n }\n }\n const bucket = inputs.bindings.bucket;\n if (bucket === undefined || isSecretRef(bucket)) {\n need(\n 'bindings.bucket.secretName',\n bucket === undefined || bucket.secretName !== migrationSecret,\n 'a runtime Secret, not the migration Secret',\n );\n } else {\n need(\n 'bindings.bucket',\n false,\n 'an object with `secretName` and `secretKey`',\n );\n }\n } else {\n need('bindings', false, 'an object');\n }\n\n if (Array.isArray(inputs.env)) {\n const names = new Set<string>(\n isObject(inputs.bindings) && inputs.bindings.postgres !== undefined\n ? ['DATABASE_URL']\n : [],\n );\n inputs.env.forEach((entry, index) => {\n const field = `env[${index}]`;\n if (!isObject(entry) || !isText(entry.name) || !isSecretRef(entry)) {\n need(\n field,\n false,\n 'an object with `name`, `secretName` and `secretKey`',\n );\n return;\n }\n // Kubernetes keeps the last of two variables with one name, which\n // would silently replace the bound database credential or an earlier\n // entry.\n need(\n `${field}.name`,\n !names.has(entry.name),\n entry.name === 'DATABASE_URL'\n ? 'something other than `DATABASE_URL`, which the `postgres` binding sets'\n : `unique: another entry already sets \\`${entry.name}\\``,\n );\n names.add(entry.name);\n need(\n `${field}.secretName`,\n entry.secretName !== migrationSecret,\n 'a runtime Secret, not the migration Secret',\n );\n need(\n `${field}.services`,\n entry.services === undefined ||\n (Array.isArray(entry.services) &&\n entry.services.length > 0 &&\n entry.services.every((name) => services.includes(name))),\n `left out, or a list naming one or more of: ${services.join(', ')}`,\n );\n });\n } else {\n need('env', inputs.env === undefined, 'a list');\n }\n\n if (isObject(inputs.defaults)) {\n need(\n 'defaults.resources',\n isObject(inputs.defaults.resources),\n 'an object',\n );\n need(\n 'defaults.terminationGracePeriodSeconds',\n isPositiveInteger(inputs.defaults.terminationGracePeriodSeconds),\n 'a whole number of seconds',\n );\n need(\n 'defaults.replicas',\n inputs.defaults.replicas === undefined ||\n isPositiveInteger(inputs.defaults.replicas),\n 'a whole number of at least 1',\n );\n } else {\n need('defaults', false, 'an object');\n }\n\n if (isObject(inputs.workloads)) {\n for (const [name, overrides] of Object.entries(inputs.workloads)) {\n if (services.includes(name)) {\n workloadInputProblems(\n `workloads.${name}`,\n overrides,\n name === web,\n need,\n );\n } else {\n problems.push(\n `\\`workloads.${name}\\` names a service the declaration does not have. Its web and worker services are: ${services.join(', ')}.`,\n );\n }\n }\n } else {\n need(\n 'workloads',\n inputs.workloads === undefined,\n 'an object keyed by service name',\n );\n }\n\n need(\n 'migration',\n inputs.migration === undefined || isObject(inputs.migration),\n 'an object',\n );\n need('maintenance', isObject(inputs.maintenance), 'an object');\n if (isObject(inputs.ingress)) {\n need('ingress.className', isText(inputs.ingress.className), 'a name');\n need(\n 'ingress.host',\n inputs.ingress.host === undefined || isText(inputs.ingress.host),\n 'a hostname',\n );\n } else {\n need('ingress', false, 'an object');\n }\n return problems;\n}\n\nfunction secretEnv(name: string, ref: SmrtAppChartSecretRef) {\n return {\n name,\n valueFrom: {\n secretKeyRef: { name: ref.secretName, key: ref.secretKey },\n },\n };\n}\n\nfunction runtimeEnv(workload: string, inputs: SmrtAppChartInputs) {\n const env: Array<ReturnType<typeof secretEnv>> = [];\n if (inputs.bindings.postgres) {\n env.push(secretEnv('DATABASE_URL', inputs.bindings.postgres.runtime));\n }\n for (const entry of inputs.env ?? []) {\n if (entry.services === undefined || entry.services.includes(workload)) {\n env.push(secretEnv(entry.name, entry));\n }\n }\n return env;\n}\n\nfunction workloadValues(\n workload: ComposeDeploymentWorkload,\n image: string,\n inputs: SmrtAppChartInputs,\n): Record<string, unknown> {\n const overrides = own(inputs.workloads, workload.name) ?? {};\n const isWeb = workload.role === 'web';\n const role = isWeb ? 'web' : (overrides.role ?? 'background');\n const probe =\n 'path' in workload.health\n ? { httpGet: { path: workload.health.path, port: workload.port } }\n : { exec: { command: workload.health.command } };\n return {\n role,\n writer: overrides.writer ?? true,\n image,\n // The chart's `command` replaces the image's entrypoint, so the complete\n // argv is the declared entrypoint followed by the declared command.\n command: [...(workload.entrypoint ?? []), ...(workload.command ?? [])],\n env: runtimeEnv(workload.name, inputs),\n // A singleton runner stays at one replica whatever the default is.\n replicas:\n role === 'background' || role === 'schedule'\n ? 1\n : (overrides.replicas ?? inputs.defaults.replicas ?? 1),\n readinessProbe: { ...probe, ...(overrides.readiness ?? {}) },\n resources: overrides.resources ?? inputs.defaults.resources,\n terminationGracePeriodSeconds:\n overrides.terminationGracePeriodSeconds ??\n inputs.defaults.terminationGracePeriodSeconds,\n ...(isWeb ? { port: workload.port, service: { port: workload.port } } : {}),\n };\n}\n\n/**\n * Render `smrt-app` chart values from a declaration resolved at the `deploy`\n * stage. Throws {@link SmrtAppChartValuesError} listing every problem when\n * the declaration or the inputs cannot produce a faithful release.\n *\n * `target` is rendered from the declaration. `current` is whatever the caller\n * passes as the running release and is never synthesized.\n */\nexport function renderSmrtAppChartValues(\n declaration: ComposeDeploymentDeclaration,\n inputs: SmrtAppChartInputs,\n): Record<string, unknown> {\n const problems = inputProblems(inputs, declaration);\n if (problems.length > 0) throw new SmrtAppChartValuesError(problems);\n\n const name = inputs.app.name ?? declaration.name;\n if (name === undefined || !CHART_NAME.test(name)) {\n problems.push(\n name === undefined\n ? 'The application has no name. Set `name:` at the top of the Compose file or `app.name` in the inputs.'\n : `The application name \\`${name}\\` must be lowercase letters, digits and hyphens, starting with a letter, at most 31 characters.`,\n );\n }\n\n const host = inputs.ingress.host ?? declaration.domain;\n if (host === undefined) {\n problems.push(\n 'There is no hostname to serve on. Set `domain` in the `x-happyvertical` block or `ingress.host` in the inputs.',\n );\n }\n\n const images: Record<string, string> = {};\n for (const workload of declaration.workloads) {\n if (RESERVED_WORKLOAD_NAMES.includes(workload.name)) {\n problems.push(\n `Service \\`${workload.name}\\` uses a name the chart keeps for its own resources (${RESERVED_WORKLOAD_NAMES.join(', ')}). Rename the service.`,\n );\n }\n if (workload.image !== undefined && DIGEST_IMAGE.test(workload.image)) {\n images[workload.name] = workload.image;\n } else {\n problems.push(\n `Service \\`${workload.name}\\` has no image digest. Validate the Compose file at the \\`deploy\\` stage with the digests CI pushed.`,\n );\n }\n if (workload.entrypoint === undefined) {\n problems.push(\n `Service \\`${workload.name}\\` leaves its entrypoint to the image. The chart starts a workload with exactly the command it is given and never runs the image's own entrypoint, so the Compose file has to state it: add \\`entrypoint:\\` to the service, naming the image's entrypoint, or \\`entrypoint: []\\` when \\`command\\` is complete on its own.`,\n );\n } else if (\n workload.entrypoint.length + (workload.command ?? []).length ===\n 0\n ) {\n problems.push(\n `Service \\`${workload.name}\\` has an empty \\`entrypoint\\` and no \\`command\\`, so there is nothing to start.`,\n );\n }\n if (workload.volumes.length > 0) {\n problems.push(\n `Service \\`${workload.name}\\` mounts a data volume (\\`${workload.volumes[0].name}\\`). The chart binds existing databases and buckets and has no persistent volumes; keep that data in a platform service.`,\n );\n }\n }\n\n const kinds = new Set(declaration.bindings.map((binding) => binding.kind));\n if (!kinds.has('postgres')) {\n problems.push(\n 'The declaration has no `postgres` binding. The chart binds exactly one existing PostgreSQL database.',\n );\n } else if (!inputs.bindings.postgres) {\n problems.push(\n 'The declaration binds `postgres` but the inputs have no `bindings.postgres` Secret references.',\n );\n }\n const bucket = declaration.bindings.find(\n (binding) => binding.kind === 'bucket',\n );\n if (bucket && !inputs.bindings.bucket) {\n problems.push(\n 'The declaration binds `bucket` but the inputs have no `bindings.bucket` Secret reference.',\n );\n }\n\n if (problems.length > 0 || name === undefined || host === undefined) {\n throw new SmrtAppChartValuesError(problems);\n }\n\n const workloads: Record<string, unknown> = {};\n for (const workload of declaration.workloads) {\n workloads[workload.name] = workloadValues(\n workload,\n images[workload.name],\n inputs,\n );\n }\n const { host: _host, className, ...ingress } = inputs.ingress;\n return {\n release: { ...inputs.release },\n app: { name, environment: inputs.app.environment },\n current: inputs.current ? inputs.current : false,\n target: {\n workloads,\n migration: {\n image: images[declaration.migrate.service],\n command: declaration.migrate.command,\n env: inputs.bindings.postgres\n ? [secretEnv('DATABASE_URL', inputs.bindings.postgres.migration)]\n : [],\n guard: SMRT_RELEASE_GUARD,\n resources: inputs.migration?.resources ?? inputs.defaults.resources,\n terminationGracePeriodSeconds:\n inputs.migration?.terminationGracePeriodSeconds ??\n inputs.defaults.terminationGracePeriodSeconds,\n },\n },\n maintenance: inputs.maintenance,\n bindings: {\n database: inputs.bindings.postgres?.runtime,\n privateBuckets:\n bucket && inputs.bindings.bucket\n ? [{ name: bucket.name, ...inputs.bindings.bucket }]\n : [],\n },\n ingress: { host, className, ...ingress },\n };\n}\n"],"mappings":";;AAqBO,IAAM,qBAAqB;AAElC,IAAM,aAAa;AACnB,IAAM,eAAe;AACrB,IAAM,eAAe;CAAC;CAAc;CAAQ;AAAU;AAEtD,IAAM,0BAA0B,CAAC,eAAe,WAAW;AAC3D,IAAM,sBAAsB;CAC1B;CACA;CACA;CACA;CACA;AACF;AA8FO,IAAM,0BAAN,cAAsC,MAAM;CACxC;CAET,YAAY,UAAoB;EAC9B,MACE;EAAyC,SAAS,KAAK,YAAY,KAAK,SAAS,CAAA,CAAE,KAAK,IAAI,GAC9F;EACA,KAAK,OAAO;EACZ,KAAK,WAAW;CAClB;AACF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,OAAO,OAAiC;CAC/C,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS;AACrD;AAEA,SAAS,kBAAkB,OAAiC;CAC1D,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,QAAQ;AACzE;AAEA,SAAS,YAAY,OAAgD;CACnE,OAAO,SAAS,KAAK,KAAK,OAAO,MAAM,UAAU,KAAK,OAAO,MAAM,SAAS;AAC9E;AAGA,SAAS,IACP,QACA,KACe;CACf,OAAO,UAAU,OAAO,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,KAAA;AAC9D;AAEA,SAAS,sBACP,OACA,WACA,OACA,MACM;CACN,IAAI,CAAC,SAAS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QAAQ,IAAI,CACnE,CAAA,CAAM,IAAI,UAAU,GACvB,SAAS,KACP,sGACF;MACF,IAAW,CAAC,OAAO,SAAS,UAC1B,SAAS,KACP,gGACF;CAEF,MAAM,SAAS,YAAY,SAAS,MACjC,YAAY,QAAQ,SAAS,QAChC;CACA,IAAI,UAAU,CAAC,OAAO,SAAS,QAC7B,SAAS,KACP,2FACF;CAGF,IAAI,SAAS,SAAS,KAAK,SAAS,KAAA,KAAa,SAAS,KAAA,GACxD,MAAM,IAAI,wBAAwB,QAAQ;CAG5C,MAAM,YAAqC,CAAC;CAC5C,KAAA,MAAW,YAAY,YAAY,WACjC,UAAU,SAAS,QAAQ,eACzB,UACA,OAAO,SAAS,OAChB,MACF;CAEF,MAAM,EAAE,MAAM,OAAO,WAAW,GAAG,YAAY,OAAO;CACtD,OAAO;EACL,SAAS,EAAE,GAAG,OAAO,QAAQ;EAC7B,KAAK;GAAE;GAAM,aAAa,OAAO,IAAI;EAAY;EACjD,SAAS,OAAO,UAAU,OAAO,UAAU;EAC3C,QAAQ;GACN;GACA,WAAW;IACT,OAAO,OAAO,YAAY,QAAQ;IAClC,SAAS,YAAY,QAAQ;IAC7B,KAAK,OAAO,SAAS,WACjB,CAAC,UAAU,gBAAgB,OAAO,SAAS,SAAS,SAAS,CAAC,IAC9D,CAAC;IACL,OAAO;IACP,WAAW,OAAO,WAAW,aAAa,OAAO,SAAS;IAC1D,+BACE,OAAO,WAAW,iCAClB,OAAO,SAAS;GACpB;EACF;EACA,aAAa,OAAO;EACpB,UAAU;GACR,UAAU,OAAO,SAAS,UAAU;GACpC,gBACE,UAAU,OAAO,SAAS,SACtB,CAAC;IAAE,MAAM,OAAO;IAAM,GAAG,OAAO,SAAS;GAAO,CAAC,IACjD,CAAC;EACT;EACA,SAAS;GAAE;GAAM;GAAW,GAAG;EAAQ;CACzC;AACF"}
@@ -5,10 +5,10 @@ description: "Centralized configuration management for SMRT modules"
5
5
  status: "stable"
6
6
  generated:
7
7
  by: "smrt/scripts/generate-knowledge-okf.ts"
8
- at: "2026-11-09T13:55:53Z"
8
+ at: "2026-11-14T05:25:25Z"
9
9
  audience: "internal"
10
10
  evidence_level: "manifest-described"
11
- source_revision: "sha256:9df8b4d67f668690cb0b4e0e4a1e5a0eff5db26448e99a86d1ea9232faaebfa7"
11
+ source_revision: "sha256:2851087fe23705d097ebe85d7dd29337e38730199c292f31a7016f1050406cb4"
12
12
  sources:
13
13
  - id: "manifest"
14
14
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/config/package.json"
@@ -39,4 +39,5 @@ sources:
39
39
 
40
40
  - `.`
41
41
  - `./deployment`
42
+ - `./deployment/hosting`
42
43
  - `./schemas/*`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-config",
3
- "version": "0.61.0",
3
+ "version": "0.61.1",
4
4
  "type": "module",
5
5
  "description": "Centralized configuration management for SMRT modules",
6
6
  "author": "HappyVertical",
@@ -17,6 +17,10 @@
17
17
  "types": "./dist/deployment.d.ts",
18
18
  "import": "./dist/deployment.js"
19
19
  },
20
+ "./deployment/hosting": {
21
+ "types": "./dist/deployment-hosting.d.ts",
22
+ "import": "./dist/deployment-hosting.js"
23
+ },
20
24
  "./schemas/*": "./schemas/*"
21
25
  },
22
26
  "files": [
@@ -26,9 +30,10 @@
26
30
  "AGENTS.md"
27
31
  ],
28
32
  "dependencies": {
29
- "@happyvertical/smrt-types": "0.61.0",
33
+ "@happyvertical/smrt-types": "0.61.1",
30
34
  "cosmiconfig": "^10.0.1",
31
- "jiti": "^2.7.0"
35
+ "jiti": "^2.7.0",
36
+ "yaml": "^2.9.1"
32
37
  },
33
38
  "devDependencies": {
34
39
  "@types/node": "24.13.6",