# Subpath map

Every entry point the package publishes, where each one can run, and
everything it exports. Each entry ships as ESM and CommonJS with type
declarations.

## At a glance

| Import                                       | Runs in       | What's there                                                                                |
| -------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------- |
| `@sonordev/agency-site-kit`                  | Server        | Everything: the layout, brand and API utilities, every type, and everything in `/portfolio` |
| `@sonordev/agency-site-kit/portfolio`        | Anywhere      | The pure rules and the case study types                                                     |
| `@sonordev/agency-site-kit/portfolio/pure`   | Anywhere      | The same pure rules, without the types or `PORTFOLIO_SECTION_TYPES`                         |
| `@sonordev/agency-site-kit/portfolio/server` | Server        | The fetchers, Next.js helpers and errors, plus every pure rule                              |
| `@sonordev/agency-site-kit/layout`           | Server        | `AgencySiteKitLayout` and its props type                                                    |
| `@sonordev/agency-site-kit/revalidate`       | Route handler | `createRevalidateHandler`                                                                   |
| `@sonordev/agency-site-kit/preview`          | Route handler | `createPortfolioPreviewHandler`                                                             |

**Anywhere** means no React, no network and no server guard: a server
component, a client component, a plain module or a test runner can all import
it. **Server** entries pull in `@sonordev/site-kit`'s server-only guard, so
importing one from a client component fails the build (on purpose: that's
what keeps your API key out of the browser). **Route handler** entries use
`next/cache` or `next/headers`, so they belong in `app/**/route.ts`.

In a client component, import rules from `/portfolio` and types with
`import type` from wherever they live.

## `@sonordev/agency-site-kit/portfolio`

The rules every renderer shares, and the types.

| Group               | Exports                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Proof               | `curatePortfolioProof`, `curateHeroKpis`, `curateResultItems`, `gateMetricsDeltas`, `headlineKpi`, `metricCredit`, `metricNote`, `formatMetricValue`                                                                                                                                                                                                                                                                                                               |
| Provenance contract | `METRIC_SOURCES`, `isHeadlineMetric`, `metricSourceLabel`, `metricSourceProblem`, `formatAttribution`, `shortAttribution`                                                                                                                                                                                                                                                                                                                                          |
| Sections            | `PORTFOLIO_SECTION_ORDER`, `PORTFOLIO_SECTION_TYPES`, `orderedSections`, `sectionData`, `projectBrandColor`                                                                                                                                                                                                                                                                                                                                                        |
| Devices             | `shouldRenderSoloDevice`, `resolveSoloScreenshot`, `isSoftwareCategory`                                                                                                                                                                                                                                                                                                                                                                                            |
| JSON-LD             | `buildPortfolioJsonLd`, `jsonLdString`                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Images and labels   | `resolvePortfolioImage`, `formatCategoryLabel`, `formatServiceTag`, `formatIsoDate`                                                                                                                                                                                                                                                                                                                                                                                |
| Paths               | `sanitizeSiteArchitectureData`, `humanizeArchPageEntry`                                                                                                                                                                                                                                                                                                                                                                                                            |
| Types               | `PortfolioItem`, `PortfolioItemFull`, `PortfolioListResponse`, `PortfolioSection`, `PortfolioSectionType`, `PortfolioSectionData`, `PortfolioSectionDataMap`, `PortfolioKPI`, `MetricsDelta`, `MetricsSnapshot`, `MetricSource`, `MetricAttribution`, every section's data type (`PortfolioHeroData` through `PortfolioCTAData`), `PortfolioLighthouseScores`, `ProofRecord`, `HeadlineKpi`, `SoloDeviceInput`, `PortfolioJsonLdOptions`, `ResolvedPortfolioImage` |

Pages: [Proof and provenance](https://sonor.dev/agency-site-kit/proof), [Sections and devices](https://sonor.dev/agency-site-kit/sections),
[Images, labels and paths](https://sonor.dev/agency-site-kit/images), [JSON-LD](https://sonor.dev/agency-site-kit/json-ld),
[Types](https://sonor.dev/agency-site-kit/types).

## `@sonordev/agency-site-kit/portfolio/pure`

The same functions and constants as `/portfolio`, and the helper types
(`HeadlineKpi`, `SoloDeviceInput`, `PortfolioJsonLdOptions`,
`ResolvedPortfolioImage`), without the case study types,
`MetricSource`, `MetricAttribution` or `PORTFOLIO_SECTION_TYPES`. It exists
for code that already imports it; new code can use `/portfolio`.

## `@sonordev/agency-site-kit/portfolio/server`

| Group           | Exports                                                                                                                                                                                       |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Fetchers        | `getPortfolioItems`, `getPortfolioItem`, `getPortfolioCategories`, `getProofRecords`, `getPortfolioBrandConfig`                                                                               |
| Next.js helpers | `generatePortfolioMetadata`, `generatePortfolioStaticParams`, `generatePortfolioCategoryStaticParams`, `generatePortfolioIndexMetadata`, `generatePortfolioSitemapEntries`, `slugifyCategory` |
| Errors          | `PortfolioApiError`, `PortfolioContractError`, `assertPortfolioItemShape`                                                                                                                     |
| Cache           | `PORTFOLIO_CACHE_TAG` (`'portfolio'`)                                                                                                                                                         |
| Types           | `PortfolioSitemapEntry`, and the helper types from `/portfolio/pure`                                                                                                                          |
| Rules           | Every function and constant from `/portfolio/pure`, so a server component needs one import                                                                                                    |

It doesn't export the case study types; take those from `/portfolio`. See
[Fetching](https://sonor.dev/agency-site-kit/fetching).

## `@sonordev/agency-site-kit`

The root entry. It includes everything in `/portfolio`, plus:

| Group  | Exports                                                                                                                                                                                                                                                                                                                                                  |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Layout | `AgencySiteKitLayout` (its props type is in `/layout`)                                                                                                                                                                                                                                                                                                   |
| Brand  | `generateBrandCSS`, `mergeBrandConfig`, `hexToRgb`, `DEFAULT_BRAND_CONFIG`, `DEFAULT_DARK_MODE`                                                                                                                                                                                                                                                          |
| API    | `apiFetch`, `apiGet`, `getApiConfig`                                                                                                                                                                                                                                                                                                                     |
| Types  | `BrandConfig`, `SanityImageRef`, `PortfolioConfigResponse`, and the item-level types inside sections: `PortfolioChallengeItem`, `PortfolioStrategyPhase`, `PortfolioResultItem`, `PortfolioTechItem`, `PortfolioServiceItem`, `PortfolioGalleryImage`, `PortfolioTeamMember`, `PortfolioAnnotation`, `PortfolioMetricsDataPoint`, `PortfolioFunnelStage` |

It doesn't include the fetchers, the route handlers or
`PORTFOLIO_CACHE_TAG`. See [Brand layout](https://sonor.dev/agency-site-kit/layout) and
[Fetching](https://sonor.dev/agency-site-kit/fetching#lower-level-api-helpers).

## `@sonordev/agency-site-kit/layout`

`AgencySiteKitLayout` and `AgencySiteKitLayoutProps`. See
[Brand layout](https://sonor.dev/agency-site-kit/layout).

## `@sonordev/agency-site-kit/revalidate`

`createRevalidateHandler`, `CreateRevalidateHandlerOptions` and
`PORTFOLIO_CACHE_TAG`. See [Live updates and preview](https://sonor.dev/agency-site-kit/live-updates).

## `@sonordev/agency-site-kit/preview`

`createPortfolioPreviewHandler` and `PortfolioPreviewHandlerOptions`. See
[Live updates and preview](https://sonor.dev/agency-site-kit/live-updates#draft-preview-createportfoliopreviewhandler).

## Also in the package

| Path                          | What it is                                                                     |
| ----------------------------- | ------------------------------------------------------------------------------ |
| `agency-site-kit-setup` (bin) | The setup CLI. See [Quickstart](https://sonor.dev/agency-site-kit/quickstart). |
| `templates/`                  | The files the CLI copies into a site, laid out the way they land               |

## Peer dependencies

| Package              | Version   |
| -------------------- | --------- |
| `@sonordev/site-kit` | >= 6.5.0  |
| `next`               | >= 14.0.0 |
| `react`, `react-dom` | >= 18.0.0 |

`@sonordev/site-kit` is never bundled into the kit: your site's one install
provides it, so the two always agree.
