import { boundWorkspaceReferences, parseWorkspaceReference, type WorkspaceReference, withWorkspaceReferenceUrls, workspaceReferenceHref, } from "./workspace-references"; export function campaignReferenceResult( context: { host?: string; workspaceSlug?: string }, result: Record, sequenceId: string, label: string, ) { const inherited = Array.isArray(result.references) ? result.references .map(parseWorkspaceReference) .find( (ref) => ref?.kind === "campaign" && ref.sequenceId === sequenceId, ) : undefined; const identity = { kind: "campaign" as const, sequenceId }; const reference: WorkspaceReference = withWorkspaceReferenceUrls( { ...identity, label, href: workspaceReferenceHref(identity), ...(inherited?.imageUrl ? { imageUrl: inherited.imageUrl } : {}), ...(inherited?.objectIcon ? { objectIcon: inherited.objectIcon } : {}), }, context, ); return { ...result, ...boundWorkspaceReferences([reference]), href: reference.href, ...(reference.url ? { url: reference.url } : {}), }; }