{"version":3,"file":"changed-slots.cjs","names":["remoteDigests"],"sources":["../../../src/services/deploy/changed-slots.ts"],"sourcesContent":["import type { BosConfigInput } from \"../../types\";\nimport { remoteDigests } from \"../registry/fingerprint\";\nimport { walkRemotes } from \"../remotes\";\n\n/**\n * The published-config diff the post-publish legs decide on (#826 follow-up):\n * a deploy that touches only SnapshotWatch-adopted surfaces — the ui slot,\n * folder-form plugin ui overrides — needs no host restart, so the Railway\n * leg skips and the soft-refresh banner carries the adoption. Everything\n * else (api/auth/plugin backends, any non-remote config change) is\n * boot-frozen and keeps the redeploy. Uncertainty reads cold: the worst case\n * is an unnecessary restart, never a missed one.\n */\n\nexport interface PublishedDiff {\n  /** remote keys whose digest pin moved (added, removed, or re-pinned) */\n  changedRemotes: string[];\n  /** any published-config change outside the remote digest coordinates */\n  configChanged: boolean;\n}\n\n/** Surfaces the running host adopts without a process restart. */\nexport function isHotRemote(remote: string): boolean {\n  return remote === \"app.ui\" || /^plugins\\.[^.]+\\.ui$/.test(remote);\n}\n\nexport function isUiOnlyDiff(diff: PublishedDiff): boolean {\n  return (\n    !diff.configChanged && diff.changedRemotes.length > 0 && diff.changedRemotes.every(isHotRemote)\n  );\n}\n\n/** Key-sorted JSON so two serializations of the same document compare equal. */\nfunction canonical(value: unknown): string {\n  if (Array.isArray(value)) return `[${value.map(canonical).join(\",\")}]`;\n  if (value && typeof value === \"object\") {\n    return `{${Object.entries(value as Record<string, unknown>)\n      .filter(([, v]) => v !== undefined)\n      .map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`)\n      .sort()\n      .join(\",\")}}`;\n  }\n  return JSON.stringify(value) ?? \"null\";\n}\n\n/** Deep clone with every remote's `digest` pin removed — the volatile\n * coordinates the hot/cold classification excludes from the body compare. */\nfunction withoutRemoteDigests(config: BosConfigInput): Record<string, unknown> {\n  const clone = JSON.parse(JSON.stringify(config ?? {})) as Record<string, unknown>;\n  walkRemotes(clone, ({ entry }) => {\n    if (entry && typeof entry === \"object\" && !Array.isArray(entry)) {\n      delete (entry as Record<string, unknown>).digest;\n    }\n  });\n  return clone;\n}\n\nexport function classifyPublishedDiff(\n  previous: BosConfigInput | null,\n  next: BosConfigInput,\n): PublishedDiff {\n  const previousRemotes = previous ? remoteDigests(previous as never) : {};\n  const nextRemotes = remoteDigests(next as never);\n  const changedRemotes = Object.keys(previousRemotes)\n    .concat(Object.keys(nextRemotes))\n    .filter((remote, index, all) => all.indexOf(remote) === index)\n    .filter((remote) => previousRemotes[remote] !== nextRemotes[remote])\n    .sort();\n  const configChanged = previous\n    ? canonical(withoutRemoteDigests(previous)) !== canonical(withoutRemoteDigests(next))\n    : true;\n  return { changedRemotes, configChanged };\n}\n"],"mappings":";;;;;AAsBA,SAAgB,YAAY,QAAyB;CACnD,OAAO,WAAW,YAAY,uBAAuB,KAAK,MAAM;AAClE;AAEA,SAAgB,aAAa,MAA8B;CACzD,OACE,CAAC,KAAK,iBAAiB,KAAK,eAAe,SAAS,KAAK,KAAK,eAAe,MAAM,WAAW;AAElG;;AAGA,SAAS,UAAU,OAAwB;CACzC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,IAAI,MAAM,IAAI,SAAS,CAAC,CAAC,KAAK,GAAG,EAAE;CACpE,IAAI,SAAS,OAAO,UAAU,UAC5B,OAAO,IAAI,OAAO,QAAQ,KAAgC,CAAC,CACxD,QAAQ,GAAG,OAAO,MAAM,MAAS,CAAC,CAClC,KAAK,CAAC,GAAG,OAAO,GAAG,KAAK,UAAU,CAAC,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CACvD,KAAK,CAAC,CACN,KAAK,GAAG,EAAE;CAEf,OAAO,KAAK,UAAU,KAAK,KAAK;AAClC;;;AAIA,SAAS,qBAAqB,QAAiD;CAC7E,MAAM,QAAQ,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC,CAAC,CAAC;CACrD,4BAAY,QAAQ,EAAE,YAAY;EAChC,IAAI,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ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