fix(seo-graph-core): return GraphEntity from piece builders
Stacked on #54. Until that merges, this PR shows both commits; the diff here reduces to the GraphEntity change once #54 lands. Per-PR review of just this change: compare the second commit.
Problem
assembleGraph<T extends GraphEntity>(pieces: readonly T[]) requires each piece to satisfy GraphEntity, whose @type is required:
// types.ts
export interface GraphEntity {
'@type': string | readonly string[];
'@id'?: string;
[key: string]: unknown;
}
But every builder is declared to return Record<string, unknown>, which has no @type. So the pattern documented in the core README and AGENTS.md —
assembleGraph([buildWebSite(...), buildArticle(...)]);
— fails tsc / astro check under strict mode:
Property '@type' is missing in type 'Record<string, unknown>' but required in type 'GraphEntity'.
Callers must cast as GraphEntity[]. The same bite hits the aggregate / createSchemaEndpoint mapper, whose type is already (entry) => ReadonlyArray<GraphEntity> — builder outputs don't satisfy it without a cast.
Fix
Widen the return type (and the local piece) of all eight builders to GraphEntity:
buildWebSite, buildWebPage, buildArticle, buildBreadcrumbList, buildImageObject, buildVideoObject, buildSiteNavigationElement, buildPiece.
Every builder already constructs its object with a literal @type, so this is a pure type change — no runtime difference. buildPiece's public overloads already require @type on the input, so its result is a GraphEntity; the implementation signature stays wider and carries one local as GraphEntity (documented inline).
No changes needed in astro-seo-graph — aggregate already expects GraphEntity; this just lets callers satisfy it without a cast.
Test
Added an assembleGraph test that composes real builder outputs directly (no cast). Because pnpm typecheck covers the test files, it doubles as a compile-time regression guard — it would not have type-checked under the old Record<string, unknown> returns.
Verification
pnpm build && pnpm typecheck && pnpm test && pnpm format:check all green locally (core 60 tests, +1 new; 475 total).
changeset: minor (widens public return types; non-breaking).