import type { ClosureFixture } from "./types.js";

const currentInputs = {
  sourceRevision: "rev-current-9f2a",
  configDigest: "cfg-digest-aa11",
  lockDigest: "lock-digest-bb22",
};

export const closureKnownGood: ClosureFixture = {
  fixtureId: "closure/known-good",
  closureVersion: "1.0",
  scenarios: [
    {
      scenarioId: "packaged-runtime-references-resolve",
      kind: "runtime-reference",
      references: [
        {
          referenceId: "checkout-route",
          kind: "route",
          target: "/checkout/confirm",
          packagedEnvironment: "static-site",
          resolved: true,
        },
        {
          referenceId: "worker-asset",
          kind: "asset",
          target: "dist/client/assets/logo.svg",
          packagedEnvironment: "cloudflare-worker",
          resolved: true,
        },
        {
          referenceId: "runtime-config",
          kind: "config-path",
          target: "config/production.json",
          packagedEnvironment: "node-package",
          resolved: true,
        },
      ],
    },
    {
      scenarioId: "deploy-artifacts-track-current-inputs",
      kind: "artifact-closure",
      currentInputs,
      artifacts: [
        {
          artifactId: "deploy-bundle",
          path: "dist/server/index.js",
          present: true,
          status: "current",
          derivedFrom: currentInputs,
        },
        {
          artifactId: "client-bundle",
          path: "dist/client/app.js",
          present: true,
          status: "current",
          derivedFrom: currentInputs,
        },
      ],
    },
    {
      scenarioId: "production-inventory-retains-provenance",
      kind: "inventory-provenance",
      entries: [
        {
          surfaceId: "route-contact-form",
          path: "src/pages/contact.astro",
          actualProvenance: "production",
          declaredProvenance: "production",
          includedInProductionInventory: true,
        },
        {
          surfaceId: "route-contact-form-test",
          path: "src/pages/contact.test.ts",
          actualProvenance: "test",
          declaredProvenance: "test",
          includedInProductionInventory: false,
        },
        {
          surfaceId: "fixture-checkout",
          path: "fixtures/checkout/payload.json",
          actualProvenance: "fixture",
          declaredProvenance: "fixture",
          includedInProductionInventory: false,
        },
      ],
    },
  ],
};
