{"version":3,"sources":["../../src/iac/graph.ts","../../src/iac/compatibility.ts","../../src/iac/cli-version.ts","../../src/iac/sdk.ts"],"names":["process","execFileSync","createHash","path","fileURLToPath","isAbsolute","resolve","readFileSync","callSites","dirname"],"mappings":";;;;;;;;;;;;;;AAaO,IAAM,qBAAA,GAAwB;AA0I9B,SAAS,eAAA,CAAgB,MAAoB,IAAA,EAA+B;AACjF,EAAA,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AACxB;AAEO,SAAS,WAAW,KAAA,EAAiC;AAC1D,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAmC;AACzD,EAAA,MAAM,aAAA,uBAAoB,GAAA,EAA+C;AAEzE,EAAA,KAAA,MAAW,QAAA,IAAY,MAAM,SAAA,EAAW;AACtC,IAAA,SAAA,CAAU,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAQ,CAAA;AACxC,IAAA,aAAA,CAAc,GAAA,CAAI,GAAG,QAAA,CAAS,IAAI,IAAI,QAAA,CAAS,IAAI,IAAI,QAAQ,CAAA;AAAA,EACjE;AAEA,EAAA,OAAO,EAAE,WAAW,aAAA,EAAc;AACpC;AAEO,SAAS,cAAc,KAAA,EAA+B;AAC3D,EAAA,MAAM,SAAmB,EAAC;AAC1B,EAAA,IAAI,KAAA,CAAM,YAAY,qBAAA,EAAuB,MAAA,CAAO,KAAK,CAAA,2BAAA,EAA8B,KAAA,CAAM,OAAO,CAAA,CAAE,CAAA;AAEtG,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAqB;AAC3C,EAAA,KAAA,MAAW,QAAA,IAAY,MAAM,SAAA,EAAW;AACtC,IAAA,IAAI,SAAA,CAAU,GAAA,CAAI,QAAA,CAAS,OAAO,CAAA,SAAU,IAAA,CAAK,CAAA,4BAAA,EAA+B,QAAA,CAAS,OAAO,CAAA,CAAE,CAAA;AAClG,IAAA,SAAA,CAAU,GAAA,CAAI,SAAS,OAAO,CAAA;AAAA,E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AK,MAAA,CAAO,OAAA,CAAQ,YAAY,CAAA,EAAG;AACvD,IAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,UAAU,KAAA,IAAS,KAAA,CAAM,SAAS,QAAA,EAAU;AACpF,MAAA,WAAA,CAAY,KAAA,CAAM,IAAI,CAAA,GAAI;AAAA,QACxB,QAAQ,KAAA,CAAM,OAAA;AAAA,QACd,SAAA,EAAW,GAAA;AAAA,QACX,GAAI,MAAM,MAAA,GAAS,EAAE,cAAc,KAAA,CAAM,MAAA,KAAW;AAAC,OACvD;AACA,MAAA;AAAA,IACF;AACA,IAAA,SAAA,CAAU,GAAG,CAAA,GAAI,KAAA;AAAA,EACnB;AACA,EAAA,OAAO,UAAA,CAAW,EAAE,YAAA,EAAc,SAAA,EAAW,mBAAmB,WAAA,EAAa,KAAK,EAAC;AACrF;AAEA,SAAS,WAAc,KAAA,EAAyB;AAC9C,EAAA,IAAI,KAAA,IAAS,IAAA,IAAQ,OAAO,KAAA,KAAU,UAAU,OAAO,KAAA;AACvD,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,CAAE,MAAA,CAAO,CAAC,GAAG,KAAK,CAAA,KAAM,KAAA,IAAS,IAAI,CAAA;AACzE,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AACjC,EAAA,OAAO,MAAA,CAAO,YAAY,OAAO,CAAA;AACnC","file":"index.cjs","sourcesContent":["import type {\n  BucketConfig,\n  BuildConfig,\n  DeployConfig,\n  EnvironmentConfig,\n  ServiceConfig,\n  ServiceNetworking,\n  ServiceSource,\n  VariableConfig,\n  VolumeConfig,\n  VolumeMount,\n} from \"./schema.js\";\n\nexport const RAILWAY_GRAPH_VERSION = 1 as const;\n\nexport type GraphVersion = typeof RAILWAY_GRAPH_VERSION;\nexport type ResourceType = \"service\" | \"database\" | \"volume\" | \"bucket\" | \"group\";\nexport type ResourceAddress = `${ResourceType}.${string}`;\n\nexport interface RailwayGraph {\n  version: GraphVersion;\n  project: ProjectNode;\n  environments: EnvironmentNode[];\n  resources: ResourceNode[];\n  edges: Edge[];\n}\n\nexport interface ProjectNode {\n  name: string;\n}\n\nexport interface EnvironmentNode {\n  name: string;\n}\n\nexport interface GraphResourceBase {\n  /** Deterministic graph handle. Remote Railway IDs live in bindings/lock state. */\n  address: ResourceAddress;\n  type: ResourceType;\n  name: string;\n  groupId?: string;\n}\n\nexport type ResourceNode = ServiceNode | DatabaseNode | VolumeNode | BucketNode | GroupNode;\n\nexport type ServiceKind = \"empty\" | \"github\" | \"docker-image\" | \"database\" | \"function\" | \"template\";\n\nexport interface SourceConfig extends ServiceSource {\n  type: \"github\" | \"image\" | \"empty\" | \"template\";\n  repo?: string | null;\n  image?: string | null;\n  template?: string | null;\n}\n\nexport interface ServiceNode extends GraphResourceBase {\n  address: `service.${string}`;\n  type: \"service\";\n  kind: ServiceKind;\n  source?: SourceConfig;\n  build?: BuildConfig;\n  deploy?: DeployConfig;\n  networking?: ServiceNetworking;\n  variables?: Record<string, VariableValue>;\n  volumeMounts?: Record<string, VolumeMount | null>;\n  // volumeConfig carries an inline-declared volume's config to the compiler, which\n  // hoists it onto the synthesized volume resource and strips it from the wire graph.\n  volumeAttachments?: Record<string, { volume: ResourceAddress; mountPath: string; backupSchedules?: VolumeMount[\"backupSchedules\"]; volumeConfig?: VolumeConfig }>;\n  configFile?: string;\n  parentServiceId?: string;\n  groupId?: string;\n  clusterRole?: ServiceConfig[\"clusterRole\"];\n  replicaConfig?: ServiceConfig[\"replicaConfig\"];\n  clusterDisplay?: ServiceConfig[\"clusterDisplay\"];\n  tracing?: ServiceConfig[\"tracing\"];\n  cdn?: ServiceConfig[\"cdn\"];\n}\n\nexport interface DatabaseNode extends Omit<ServiceNode, \"address\" | \"id\" | \"type\" | \"kind\"> {\n  address: `database.${string}`;\n  type: \"database\";\n  kind: \"database\";\n  engine: \"postgres\" | \"mysql\" | \"redis\" | \"mongo\" | \"private\";\n  image: string;\n  output: string;\n  defaultMountPath?: string;\n}\n\nexport interface VolumeNode extends GraphResourceBase {\n  address: `volume.${string}`;\n  type: \"volume\";\n  config?: VolumeConfig;\n}\n\nexport interface BucketNode extends GraphResourceBase {\n  address: `bucket.${string}`;\n  type: \"bucket\";\n  config?: BucketConfig;\n}\n\nexport interface GroupNode extends GraphResourceBase {\n  address: `group.${string}`;\n  type: \"group\";\n  color?: string;\n  icon?: string;\n  isCollapsed?: boolean;\n}\n\nexport type VariableValue =\n  | ({ type: \"literal\" } & VariableConfig)\n  | { type: \"reference\"; resource: ResourceAddress; output: string }\n  | { type: \"sharedReference\"; name: string }\n  | { type: \"preserve\" }\n  | { type: \"raw\"; value: VariableConfig };\n\nexport interface Edge {\n  from: ResourceAddress;\n  to: ResourceAddress;\n  type: \"variable\" | \"mount\" | \"group\";\n  key?: string;\n}\n\nexport type GroupableResourceNode = ResourceNode;\nexport type GroupableResourceInput = GroupableResourceNode | GroupableResourceNode[];\nexport type ProjectResourceInput = ResourceNode | ResourceNode[];\n\nexport interface ProjectDefinition {\n  name: string;\n  environments?: string[];\n  resources?: ProjectResourceInput[];\n  /** @deprecated Use resources instead. */\n  services?: ProjectResourceInput[];\n}\n\nexport interface GraphCompileOptions {\n  serviceIdsByName?: Record<string, string>;\n  existingServiceIds?: string[];\n  volumeIdsByServiceName?: Record<string, string>;\n  volumeIdsByName?: Record<string, string>;\n  bucketIdsByName?: Record<string, string>;\n}\n\nexport interface CompileResult {\n  graph: RailwayGraph;\n  desiredConfig: EnvironmentConfig;\n}\n\nexport interface GraphIndex {\n  byAddress: Map<ResourceAddress, ResourceNode>;\n  byTypeAndName: Map<`${ResourceType}:${string}`, ResourceNode>;\n}\n\nexport function resourceAddress(type: ResourceType, name: string): ResourceAddress {\n  return `${type}.${name}` as ResourceAddress;\n}\n\nexport function indexGraph(graph: RailwayGraph): GraphIndex {\n  const byAddress = new Map<ResourceAddress, ResourceNode>();\n  const byTypeAndName = new Map<`${ResourceType}:${string}`, ResourceNode>();\n\n  for (const resource of graph.resources) {\n    byAddress.set(resource.address, resource);\n    byTypeAndName.set(`${resource.type}:${resource.name}`, resource);\n  }\n\n  return { byAddress, byTypeAndName };\n}\n\nexport function validateGraph(graph: RailwayGraph): string[] {\n  const errors: string[] = [];\n  if (graph.version !== RAILWAY_GRAPH_VERSION) errors.push(`Unsupported graph version: ${graph.version}`);\n\n  const addresses = new Set<ResourceAddress>();\n  for (const resource of graph.resources) {\n    if (addresses.has(resource.address)) errors.push(`Duplicate resource address: ${resource.address}`);\n    addresses.add(resource.address);\n  }\n\n  for (const edge of graph.edges) {\n    if (!addresses.has(edge.from)) errors.push(`Edge references missing source: ${edge.from}`);\n    if (!addresses.has(edge.to)) errors.push(`Edge references missing target: ${edge.to}`);\n  }\n\n  return errors;\n}\n","export const MINIMUM_IAC_CLI_VERSION = \"5.42.1\";\nexport const MINIMUM_IAC_CLI_MESSAGE =\n  `This version of railway/iac requires Railway CLI ${MINIMUM_IAC_CLI_VERSION} or newer. ` +\n  \"Upgrade the CLI and run the command again. The IaC engine now ships in the CLI, not the TypeScript SDK.\";\n","import { execFileSync } from \"node:child_process\";\nimport process from \"node:process\";\nimport { MINIMUM_IAC_CLI_MESSAGE } from \"./compatibility.js\";\n\nexport function assertMinimumIacCliVersion(): void {\n  if (!isNativeCliEvaluation()) return;\n\n  const executable = process.env._ || \"railway\";\n  let output = \"\";\n  try {\n    output = execFileSync(executable, [\"--version\"], {\n      encoding: \"utf8\",\n      stdio: [\"ignore\", \"pipe\", \"ignore\"],\n    });\n  } catch {\n    throw new Error(MINIMUM_IAC_CLI_MESSAGE);\n  }\n\n  const version = output.match(/\\b(\\d+)\\.(\\d+)\\.(\\d+)\\b/);\n  if (!version || compareVersions(version.slice(1).map(Number), [5, 42, 1]) < 0) {\n    throw new Error(MINIMUM_IAC_CLI_MESSAGE);\n  }\n}\n\nfunction isNativeCliEvaluation(): boolean {\n  const evalFlag = process.execArgv.indexOf(\"-e\");\n  const source = evalFlag >= 0 ? process.execArgv[evalFlag + 1] : undefined;\n  return (\n    process.execArgv.includes(\"--experimental-strip-types\") &&\n    process.execArgv.includes(\"--input-type=module\") &&\n    source?.includes(\"const partial = mod.partial\") === true &&\n    source.includes(\"process.stdout.write(JSON.stringify({ partial, project: graph }))\")\n  );\n}\n\nfunction compareVersions(left: number[], right: number[]): number {\n  for (let index = 0; index < 3; index += 1) {\n    const difference = (left[index] ?? 0) - (right[index] ?? 0);\n    if (difference !== 0) return difference;\n  }\n  return 0;\n}\n","import { createHash } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { assertMinimumIacCliVersion } from \"./cli-version.js\";\nimport { resourceAddress } from \"./graph.js\";\nimport type {\n  BucketNode,\n  DatabaseNode,\n  GroupNode,\n  GroupableResourceInput,\n  GroupableResourceNode,\n  ProjectDefinition,\n  ProjectResourceInput,\n  ResourceNode,\n  ServiceNode,\n  SourceConfig,\n  VariableValue,\n  VolumeNode,\n} from \"./graph.js\";\nimport type {\n  AutoUpdateScheduleWindow,\n  BucketConfig,\n  BuildConfig,\n  DeployConfig,\n  ServiceConfig,\n  ServiceNetworking,\n  VariableConfig,\n  VolumeConfig,\n  VolumeMount,\n} from \"./schema.js\";\n\nassertMinimumIacCliVersion();\n\nexport interface RailwayContextInput {\n  command?: string;\n  projectId?: string;\n  projectName?: string;\n  environmentId?: string;\n  environment?: string;\n  environmentName?: string;\n}\n\nexport interface RailwayContext extends RailwayContextInput {\n  randomString: (label?: string, bytes?: number) => string;\n  isEnvironment: (name: string) => boolean;\n  shared: SharedVariableRef;\n}\n\nexport type RailwayProgram = (\n  ctx: RailwayContext,\n  project: (name: string, definition: Omit<ProjectDefinition, \"name\">) => ProjectDefinition,\n) => ProjectDefinition | Promise<ProjectDefinition>;\n\nexport function defineRailway(program: RailwayProgram): RailwayProgram {\n  return program;\n}\n\nexport const define = defineRailway;\n\nexport function project(name: string, definition: Omit<ProjectDefinition, \"name\">): ProjectDefinition {\n  const resources = (definition.resources ?? definition.services ?? []).flat();\n  return { name, ...definition, resources };\n}\n\nexport function createRailwayContext(input: RailwayContextInput = {}): RailwayContext {\n  const environment = input.environment ?? input.environmentName;\n  return {\n    ...input,\n    ...(environment ? { environment, environmentName: environment } : {}),\n    randomString: (label = \"random\", bytes = 12) =>\n      createHash(\"sha256\").update(`railway-iac:${environment ?? \"default\"}:${label}`).digest(\"hex\").slice(0, bytes * 2),\n    isEnvironment: (name: string) => environment === name,\n    shared: createSharedVariableRefs(),\n  };\n}\n\nexport type RegionConfig = number | { count?: number; replicas?: number; stacker?: string | null };\n\nexport interface IntentServiceConfig {\n  source?: SourceConfig | Omit<SourceConfig, \"type\">;\n  root?: string;\n  rootDirectory?: string;\n  build?: string | BuildConfig;\n  deploy?: DeployConfig;\n  run?: { command?: string; preDeploy?: string | string[]; healthcheck?: string; healthcheckTimeout?: number };\n  start?: string;\n  startCommand?: string;\n  preDeploy?: string | string[];\n  preDeployCommand?: string | string[];\n  healthcheck?: string;\n  healthcheckPath?: string;\n  healthcheckTimeout?: number;\n  replicas?: number | Record<string, RegionConfig>;\n  regions?: Record<string, RegionConfig>;\n  networking?: ServiceNetworking;\n  domains?: Array<string | { domain: string; port?: number }>;\n  tcp?: Array<string | number>;\n  tcpProxies?: string[];\n  env?: Record<string, string | VariableConfig | VariableValue>;\n  variables?: Record<string, string | VariableConfig | VariableValue>;\n  volumeMounts?: Record<string, VolumeMount | null | VolumeNode>;\n  configFile?: string;\n  parentServiceId?: string;\n  groupId?: string;\n  clusterRole?: ServiceConfig[\"clusterRole\"];\n  replicaConfig?: ServiceConfig[\"replicaConfig\"];\n  clusterDisplay?: ServiceConfig[\"clusterDisplay\"];\n  tracing?: ServiceConfig[\"tracing\"];\n  cdn?: ServiceConfig[\"cdn\"];\n}\n\nexport type ServiceConfigInput = IntentServiceConfig;\n\nexport type RailwayProvidedVariable =\n  | \"RAILWAY_PUBLIC_DOMAIN\"\n  | \"RAILWAY_PRIVATE_DOMAIN\"\n  | \"RAILWAY_TCP_PROXY_DOMAIN\"\n  | \"RAILWAY_TCP_PROXY_PORT\"\n  | \"RAILWAY_DEPLOYMENT_ID\"\n  | \"RAILWAY_DEPLOYMENT_DRAINING_SECONDS\"\n  | \"RAILWAY_ENVIRONMENT\"\n  | \"RAILWAY_ENVIRONMENT_ID\"\n  | \"RAILWAY_PROJECT_ID\"\n  | \"RAILWAY_PROJECT_NAME\"\n  | \"RAILWAY_SERVICE_ID\"\n  | \"RAILWAY_SERVICE_NAME\"\n  | \"RAILWAY_REPLICA_ID\"\n  | \"PORT\";\n\nexport type PostgresVariable = RailwayProvidedVariable | \"DATABASE_PUBLIC_URL\" | \"DATABASE_URL\" | \"PGDATA\" | \"PGDATABASE\" | \"PGHOST\" | \"PGPASSWORD\" | \"PGPORT\" | \"PGUSER\" | \"POSTGRES_DB\" | \"POSTGRES_PASSWORD\" | \"POSTGRES_USER\" | \"SSL_CERT_DAYS\";\nexport type RedisVariable = RailwayProvidedVariable | \"REDIS_PASSWORD\" | \"REDIS_PUBLIC_URL\" | \"REDIS_URL\" | \"REDISHOST\" | \"REDISPASSWORD\" | \"REDISPORT\" | \"REDISUSER\";\nexport type MongoVariable = RailwayProvidedVariable | \"MONGO_INITDB_ROOT_PASSWORD\" | \"MONGO_INITDB_ROOT_USERNAME\" | \"MONGO_PUBLIC_URL\" | \"MONGO_URL\" | \"MONGOHOST\" | \"MONGOPASSWORD\" | \"MONGOPORT\" | \"MONGOUSER\";\nexport type MySqlVariable = RailwayProvidedVariable | \"MYSQL_DATABASE\" | \"MYSQL_PUBLIC_URL\" | \"MYSQL_ROOT_PASSWORD\" | \"MYSQL_URL\" | \"MYSQLDATABASE\" | \"MYSQLHOST\" | \"MYSQLPASSWORD\" | \"MYSQLPORT\" | \"MYSQLUSER\";\nexport type DatabaseVariable<E extends DatabaseNode[\"engine\"]> = E extends \"postgres\" ? PostgresVariable : E extends \"redis\" ? RedisVariable : E extends \"mongo\" ? MongoVariable : E extends \"mysql\" ? MySqlVariable : RailwayProvidedVariable | string;\nexport type ServiceVariableRef<K extends string = RailwayProvidedVariable | string> = { readonly [P in K]: VariableValue };\nexport type SharedVariableRef = { readonly [name: string]: VariableValue } & { readonly [name: string]: any };\nexport type ReferencableServiceNode<K extends string = RailwayProvidedVariable | string> = ServiceNode & { readonly env: ServiceVariableRef<K> };\nexport type ReferencableDatabaseNode<E extends DatabaseNode[\"engine\"]> = DatabaseNode & { readonly env: ServiceVariableRef<DatabaseVariable<E>> };\n\nexport function github(repo: string, options: Omit<SourceConfig, \"type\" | \"repo\" | \"image\" | \"autoUpdates\"> = {}): SourceConfig {\n  if ((options as { autoUpdates?: unknown }).autoUpdates !== undefined) {\n    throw new Error(\"Image auto updates are only supported for Docker image sources.\");\n  }\n  return { type: \"github\", repo, branch: options.branch ?? \"main\", ...options };\n}\n\nexport function image(imageName: string, options: Pick<SourceConfig, \"rootDirectory\" | \"autoUpdates\"> = {}): SourceConfig {\n  if (options.autoUpdates !== undefined && !supportsImageAutoUpdates(imageName)) {\n    throw new Error(\"Image auto updates are only supported for Docker Hub and GHCR images.\");\n  }\n  if (options.autoUpdates?.schedule != null) {\n    validateAutoUpdateSchedule(options.autoUpdates.schedule);\n  }\n  return { type: \"image\", image: imageName, ...options };\n}\n\n// Mirrors backboard's schedule window schema (@railway/models): day 0-6,\n// startHour 0-23, endHour 1-24 exclusive and after startHour, all integers.\n// Backboard rejects anything else at commit time; failing here surfaces the\n// mistake at authoring time with the offending window named.\nfunction validateAutoUpdateSchedule(schedule: unknown): asserts schedule is AutoUpdateScheduleWindow[] {\n  if (!Array.isArray(schedule)) {\n    throw new Error(\"Image auto update schedule must be an array of { day, startHour, endHour } windows.\");\n  }\n  schedule.forEach((window, index) => {\n    const where = `autoUpdates.schedule[${index}]`;\n    if (typeof window !== \"object\" || window === null || Array.isArray(window)) {\n      throw new Error(`${where} must be an object with day, startHour and endHour.`);\n    }\n    const { day, startHour, endHour } = window as Record<string, unknown>;\n    if (!isIntegerInRange(day, 0, 6)) {\n      throw new Error(`${where}.day must be an integer from 0 (Sunday) to 6 (Saturday) UTC.`);\n    }\n    if (!isIntegerInRange(startHour, 0, 23)) {\n      throw new Error(`${where}.startHour must be an integer UTC hour from 0 to 23.`);\n    }\n    if (!isIntegerInRange(endHour, 1, 24)) {\n      throw new Error(`${where}.endHour must be an integer UTC hour from 1 to 24 (exclusive).`);\n    }\n    if (endHour <= startHour) {\n      throw new Error(`${where}.endHour must be greater than startHour; a window cannot cross midnight.`);\n    }\n  });\n}\n\nfunction isIntegerInRange(value: unknown, min: number, max: number): value is number {\n  return typeof value === \"number\" && Number.isInteger(value) && value >= min && value <= max;\n}\n\nfunction supportsImageAutoUpdates(imageName: string): boolean {\n  const normalized = imageName.trim().toLowerCase();\n  if (normalized === \"\") return false;\n  if (!normalized.includes(\"/\")) return true;\n  const registry = normalized.split(\"/\", 1)[0] ?? \"\";\n  return (!registry.includes(\".\") && !registry.includes(\":\") && registry !== \"localhost\") || registry === \"docker.io\" || registry === \"ghcr.io\";\n}\n\nexport function template(templateName: string, options: Omit<SourceConfig, \"type\" | \"template\"> = {}): SourceConfig {\n  return { type: \"template\", template: templateName, ...options };\n}\n\nexport function empty(): SourceConfig {\n  return { type: \"empty\" };\n}\n\nexport function service<const Env extends Record<string, string | VariableConfig | VariableValue> = {}>(name: string, config: Omit<ServiceConfigInput, \"env\" | \"variables\"> & { env?: Env; variables?: Env } = {}): ReferencableServiceNode<RailwayProvidedVariable | Extract<keyof Env, string>> {\n  const source = normalizeSource(config.source, config.root ?? config.rootDirectory);\n  const node = pruneEmpty({\n    address: resourceAddress(\"service\", name) as `service.${string}`,\n    type: \"service\",\n    kind: source?.type === \"github\" ? \"github\" : source?.type === \"image\" ? \"docker-image\" : source?.type === \"template\" ? \"template\" : \"empty\",\n    name,\n    ...(source ? { source } : {}),\n    build: normalizeBuild(config),\n    deploy: normalizeDeploy(config),\n    networking: normalizeNetworking(config),\n    ...(config.env || config.variables ? { variables: normalizeVariables({ ...(config.variables ?? {}), ...(config.env ?? {}) }) } : {}),\n    ...normalizeVolumeMounts(config.volumeMounts),\n    ...(config.configFile ? { configFile: config.configFile } : {}),\n    ...(config.parentServiceId ? { parentServiceId: config.parentServiceId } : {}),\n    ...(config.groupId ? { groupId: config.groupId } : {}),\n    ...(config.clusterRole ? { clusterRole: config.clusterRole } : {}),\n    ...(config.replicaConfig ? { replicaConfig: config.replicaConfig } : {}),\n    ...(config.clusterDisplay ? { clusterDisplay: config.clusterDisplay } : {}),\n    ...(config.tracing ? { tracing: config.tracing } : {}),\n    ...(config.cdn ? { cdn: config.cdn } : {}),\n  }) as ServiceNode;\n  return withVariableRefs(node) as ReferencableServiceNode<RailwayProvidedVariable | Extract<keyof Env, string>>;\n}\n\nexport type FunctionRuntime = \"bun\";\n\n// Runtime images for Railway Functions. Pinned so an authored function plans\n// the same on every machine; pass `source: image(...)` to pick another tag.\nconst FUNCTION_IMAGES: Readonly<Record<FunctionRuntime, string>> = {\n  bun: \"ghcr.io/railwayapp/function-bun:1.4.0\",\n};\n\n// A start command reaches the container as one argv string, and Linux caps a\n// single argument at MAX_ARG_STRLEN: 128 KiB counting the terminating NUL.\nconst MAX_COMMAND_BYTES = 128 * 1024 - 1;\nconst FUNCTION_START_COMMAND_PREFIX = \"./run.sh \";\n\n/**\n * Largest function source `fn()` accepts, in UTF-8 bytes: 98295. The source\n * is base64 after the `./run.sh ` prefix of that one argument, so the limit is\n * the largest whole number of 3-byte groups whose base64 still fits. The API\n * derives the same number and rejects anything larger on plan and apply.\n */\nexport const FUNCTION_SOURCE_MAX_BYTES = Math.floor((MAX_COMMAND_BYTES - FUNCTION_START_COMMAND_PREFIX.length) / 4) * 3;\n\nexport interface FunctionConfigInput extends IntentServiceConfig {\n  /**\n   * Path to the function's source file. `fn()` reads it when the config is\n   * evaluated and base64-encodes it into the deploy start command, which is\n   * how Railway stores function code; the service has no repository. A\n   * relative path resolves against the directory of the file calling `fn()`,\n   * normally `.railway/`. The file must stay within `FUNCTION_SOURCE_MAX_BYTES`.\n   */\n  codeFile?: string | URL;\n  /** Runtime image the function runs on. Defaults to `\"bun\"`. */\n  runtime?: FunctionRuntime;\n}\n\nexport function fn<const Env extends Record<string, string | VariableConfig | VariableValue> = {}>(name: string, config: Omit<FunctionConfigInput, \"env\" | \"variables\"> & { env?: Env; variables?: Env } = {}): ReferencableServiceNode<RailwayProvidedVariable | Extract<keyof Env, string>> {\n  const { codeFile, runtime, ...serviceConfig } = config;\n  if (runtime !== undefined && !Object.hasOwn(FUNCTION_IMAGES, runtime)) {\n    throw new Error(`Unknown function runtime \"${String(runtime)}\"; supported runtimes: ${Object.keys(FUNCTION_IMAGES).join(\", \")}.`);\n  }\n  if ((codeFile !== undefined || runtime !== undefined) && serviceConfig.source === undefined) {\n    serviceConfig.source = image(FUNCTION_IMAGES[runtime ?? \"bun\"]);\n  }\n  if (codeFile !== undefined) {\n    if (serviceConfig.start ?? serviceConfig.startCommand ?? serviceConfig.run?.command ?? serviceConfig.deploy?.startCommand) {\n      throw new Error(`fn(\"${name}\"): \"codeFile\" sets the start command; drop \"start\", \"startCommand\", \"run.command\" or \"deploy.startCommand\".`);\n    }\n    serviceConfig.start = functionStartCommand(readFunctionSource(name, codeFile));\n  }\n  return withVariableRefs({ ...service(name, serviceConfig), kind: \"function\" } as ServiceNode) as ReferencableServiceNode<RailwayProvidedVariable | Extract<keyof Env, string>>;\n}\n\nfunction readFunctionSource(name: string, codeFile: string | URL): string {\n  const path = codeFile instanceof URL ? fileURLToPath(codeFile) : isAbsolute(codeFile) ? codeFile : resolve(callerDirectory() ?? process.cwd(), codeFile);\n  try {\n    return readFileSync(path, \"utf8\");\n  } catch (error) {\n    throw new Error(`fn(\"${name}\"): cannot read codeFile ${path}: ${error instanceof Error ? error.message : String(error)}`);\n  }\n}\n\n// Directory of the module that called into this one: the config file, so a\n// relative `codeFile` means \"next to railway.ts\" no matter which directory\n// `railway config plan` or `node` runs from. Node's CallSite API gives file\n// names without parsing the stack text; ESM frames carry `file:` URLs (the\n// CLI imports the config with a cache-busting query, which `fileURLToPath`\n// drops). A host that overrides stack formatting or sets `stackTraceLimit`\n// to 0 yields no frames, and the caller falls back to the working directory.\nfunction callerDirectory(): string | undefined {\n  const original = Error.prepareStackTrace;\n  Error.prepareStackTrace = (_error, callSites) => callSites;\n  const stack: unknown = new Error().stack;\n  Error.prepareStackTrace = original;\n  if (!Array.isArray(stack)) return undefined;\n  const callSites = stack as NodeJS.CallSite[];\n  const self = callSites[0]?.getFileName();\n  for (const site of callSites) {\n    const file = site.getFileName();\n    if (!file || file === self || file.startsWith(\"node:\")) continue;\n    return dirname(file.startsWith(\"file:\") ? fileURLToPath(file) : file);\n  }\n  return undefined;\n}\n\n// The function image's `run.sh` decodes its argument, writes it to\n// `index.tsx` and runs it with the runtime; Railway decodes the same form to\n// show the source in the dashboard. The error text matches the API's.\nfunction functionStartCommand(code: string): string {\n  const bytes = Buffer.byteLength(code, \"utf8\");\n  if (bytes > FUNCTION_SOURCE_MAX_BYTES) {\n    throw new Error(`Function source code is ${bytes} bytes; the limit is ${FUNCTION_SOURCE_MAX_BYTES} bytes`);\n  }\n  return `${FUNCTION_START_COMMAND_PREFIX}${Buffer.from(code, \"utf8\").toString(\"base64\")}`;\n}\n\nexport interface DatabaseConfig {\n  region?: string;\n}\n\nexport function postgres(name: string, config: DatabaseConfig = {}): ReferencableDatabaseNode<\"postgres\"> {\n  return database(name, \"postgres\", {\n    image: \"ghcr.io/railwayapp-templates/postgres-ssl:18\",\n    output: \"DATABASE_URL\",\n    defaultMountPath: \"/var/lib/postgresql/data\",\n    ...config,\n  });\n}\n\nexport function mysql(name: string, config: DatabaseConfig = {}): ReferencableDatabaseNode<\"mysql\"> {\n  return database(name, \"mysql\", { image: \"mysql:9\", output: \"MYSQL_URL\", defaultMountPath: \"/var/lib/mysql\", ...config });\n}\n\nexport function redis(name: string, config: DatabaseConfig = {}): ReferencableDatabaseNode<\"redis\"> {\n  return database(name, \"redis\", { image: \"railwayapp/redis:8.2\", output: \"REDIS_URL\", defaultMountPath: \"/bitnami\", ...config });\n}\n\nexport function mongo(name: string, config: DatabaseConfig = {}): ReferencableDatabaseNode<\"mongo\"> {\n  return database(name, \"mongo\", { image: \"mongo:8\", output: \"MONGO_URL\", defaultMountPath: \"/data/db\", ...config });\n}\n\nexport function database<E extends DatabaseNode[\"engine\"]>(\n  name: string,\n  engine: E,\n  options: { image: string; output?: string; defaultMountPath?: string; region?: string },\n): ReferencableDatabaseNode<E> {\n  const output = options.output ?? \"DATABASE_URL\";\n  const node = {\n    address: resourceAddress(\"database\", name) as `database.${string}`,\n    type: \"database\",\n    kind: \"database\",\n    engine,\n    name,\n    image: options.image,\n    output,\n    defaultMountPath: options.defaultMountPath,\n    source: image(options.image),\n    ...(options.region ? { deploy: { multiRegionConfig: { [options.region]: { numReplicas: 1 } } } } : {}),\n  } as DatabaseNode;\n  return withVariableRefs(node) as ReferencableDatabaseNode<E>;\n}\n\nexport function volume(name: string, config: VolumeConfig = {}): VolumeNode {\n  return { address: resourceAddress(\"volume\", name) as `volume.${string}`, type: \"volume\", name, config };\n}\n\nexport function bucket(name: string, config: BucketConfig = {}): BucketNode {\n  return { address: resourceAddress(\"bucket\", name) as `bucket.${string}`, type: \"bucket\", name, config };\n}\n\nexport function group(name: string, resources: GroupableResourceInput[], options?: Omit<GroupNode, \"address\" | \"type\" | \"name\">): GroupableResourceNode[];\nexport function group(name: string, options?: Omit<GroupNode, \"address\" | \"type\" | \"name\">): GroupNode;\nexport function group(\n  name: string,\n  resourcesOrOptions: GroupableResourceInput[] | Omit<GroupNode, \"address\" | \"type\" | \"name\"> = {},\n  maybeOptions: Omit<GroupNode, \"address\" | \"type\" | \"name\"> = {},\n): GroupNode | GroupableResourceNode[] {\n  const resources = Array.isArray(resourcesOrOptions) ? resourcesOrOptions.flat(Infinity) as GroupableResourceNode[] : undefined;\n  const options = Array.isArray(resourcesOrOptions) ? maybeOptions : resourcesOrOptions;\n  const node: GroupNode = { address: resourceAddress(\"group\", name) as `group.${string}`, type: \"group\", name, ...options };\n  if (!resources) return node;\n  return [node, ...resources.map(resource => ({ ...resource, groupId: name }))];\n}\n\nexport function ref(resource: ResourceNode, output: string): VariableValue {\n  return variableReference(resource, output);\n}\n\nexport function preserve(): VariableValue {\n  return { type: \"preserve\" };\n}\n\nfunction variableReference(resource: ResourceNode, output: string): VariableValue {\n  return { type: \"reference\", resource: resource.address, output };\n}\n\nfunction sharedVariableReference(name: string): VariableValue {\n  return { type: \"sharedReference\", name };\n}\n\nfunction createSharedVariableRefs(): SharedVariableRef {\n  return new Proxy({} as SharedVariableRef, {\n    get(_target, property) {\n      if (typeof property !== \"string\") return undefined;\n      return sharedVariableReference(property);\n    },\n  });\n}\n\nfunction createVariableRefAccessor(resource: ResourceNode): ServiceVariableRef<string> {\n  return new Proxy({} as ServiceVariableRef<string>, {\n    get(_target, property) {\n      if (typeof property !== \"string\") return undefined;\n      return variableReference(resource, property);\n    },\n  });\n}\n\nfunction withVariableRefs<T extends ServiceNode | DatabaseNode>(node: T): T {\n  Object.defineProperty(node, \"env\", { enumerable: false, value: createVariableRefAccessor(node) });\n  return node;\n}\n\nfunction normalizeSource(source: ServiceConfigInput[\"source\"], rootDirectory?: string): SourceConfig | undefined {\n  if (source == null) return rootDirectory ? { type: \"empty\", rootDirectory } : undefined;\n  if (\"type\" in source && source.type) return pruneEmpty({ ...source, rootDirectory: source.rootDirectory ?? rootDirectory }) as SourceConfig;\n  if (\"repo\" in source && source.repo) return pruneEmpty({ type: \"github\", repo: source.repo, branch: source.branch ?? \"main\", rootDirectory }) as SourceConfig;\n  if (\"image\" in source && source.image) return pruneEmpty({ type: \"image\", image: source.image, rootDirectory }) as SourceConfig;\n  return rootDirectory ? { type: \"empty\", rootDirectory } : undefined;\n}\n\nfunction normalizeBuild(config: ServiceConfigInput): BuildConfig | undefined {\n  if (typeof config.build === \"string\") return { buildCommand: config.build };\n  return pruneEmpty({ ...config.build });\n}\n\nfunction normalizeDeploy(config: ServiceConfigInput): DeployConfig | undefined {\n  const preDeployCommand = config.preDeploy ?? config.preDeployCommand ?? config.run?.preDeploy;\n  const replicaConfig = normalizeReplicas(config.replicas, config.regions);\n  return pruneEmpty({\n    ...config.deploy,\n    startCommand: config.start ?? config.startCommand ?? config.run?.command ?? config.deploy?.startCommand,\n    preDeployCommand: Array.isArray(preDeployCommand) ? preDeployCommand : preDeployCommand ? [preDeployCommand] : config.deploy?.preDeployCommand,\n    healthcheckPath: config.healthcheck ?? config.healthcheckPath ?? config.run?.healthcheck ?? config.deploy?.healthcheckPath,\n    healthcheckTimeout: config.healthcheckTimeout ?? config.run?.healthcheckTimeout ?? config.deploy?.healthcheckTimeout,\n    ...replicaConfig,\n    multiRegionConfig: replicaConfig?.multiRegionConfig ?? config.deploy?.multiRegionConfig,\n  }) as DeployConfig | undefined;\n}\n\nfunction normalizeReplicas(replicas: ServiceConfigInput[\"replicas\"], regions: ServiceConfigInput[\"regions\"]): Pick<DeployConfig, \"numReplicas\" | \"multiRegionConfig\"> | undefined {\n  if (typeof replicas === \"number\") return { numReplicas: replicas };\n  if (replicas) return { multiRegionConfig: normalizeRegions(replicas) };\n  if (regions) return { multiRegionConfig: normalizeRegions(regions) };\n  return undefined;\n}\n\nfunction normalizeRegions(regions: Record<string, RegionConfig>): NonNullable<DeployConfig[\"multiRegionConfig\"]> {\n  return Object.fromEntries(\n    Object.entries(regions).map(([region, value]) => [\n      region,\n      typeof value === \"number\"\n        ? { numReplicas: value }\n        : (pruneEmpty({ numReplicas: value.count ?? value.replicas, stackerAssignment: value.stacker }) ?? {}),\n    ]),\n  ) as NonNullable<DeployConfig[\"multiRegionConfig\"]>;\n}\n\nfunction normalizeNetworking(config: ServiceConfigInput): ServiceNetworking | undefined {\n  const customDomains = config.domains\n    ? Object.fromEntries(config.domains.map(domain => (typeof domain === \"string\" ? [domain, { port: 8080 }] : [domain.domain, { port: domain.port ?? 8080 }])))\n    : undefined;\n  const tcpProxies = config.tcp\n    ? Object.fromEntries(config.tcp.map(port => [String(port), {}]))\n    : config.tcpProxies\n      ? Object.fromEntries(config.tcpProxies.map(port => [port, {}]))\n      : undefined;\n  return pruneEmpty({ ...config.networking, customDomains, tcpProxies }) as ServiceNetworking | undefined;\n}\n\nfunction normalizeVariables(variables: Record<string, string | VariableConfig | VariableValue>): Record<string, VariableValue> {\n  return Object.fromEntries(\n    Object.entries(variables).map(([key, value]) => {\n      if (typeof value === \"string\") return [key, { type: \"literal\", value }];\n      if (\"type\" in value) return [key, value];\n      return [key, { type: \"raw\", value }];\n    }),\n  );\n}\n\nfunction normalizeVolumeMounts(volumeMounts: ServiceConfigInput[\"volumeMounts\"]): Pick<ServiceNode, \"volumeMounts\" | \"volumeAttachments\"> {\n  if (!volumeMounts) return {};\n  const rawMounts: ServiceNode[\"volumeMounts\"] = {};\n  const attachments: NonNullable<ServiceNode[\"volumeAttachments\"]> = {};\n  for (const [key, value] of Object.entries(volumeMounts)) {\n    if (value && typeof value === \"object\" && \"type\" in value && value.type === \"volume\") {\n      attachments[value.name] = {\n        volume: value.address,\n        mountPath: key,\n        ...(value.config ? { volumeConfig: value.config } : {}),\n      };\n      continue;\n    }\n    rawMounts[key] = value as VolumeMount | null;\n  }\n  return pruneEmpty({ volumeMounts: rawMounts, volumeAttachments: attachments }) ?? {};\n}\n\nfunction pruneEmpty<T>(value: T): T | undefined {\n  if (value == null || typeof value !== \"object\") return value;\n  const entries = Object.entries(value).filter(([, child]) => child != null);\n  if (entries.length === 0) return undefined;\n  return Object.fromEntries(entries) as T;\n}\n"]}