/** * Pure render-decision core for — kept dependency-free so it can * be unit-tested in the node jest environment (no @components imports here). * * Inputs are the two per-render lookups: * - `descriptor`: the active theme's DECLARED field from the * manifest-descriptor projection (eContext.config.themeMetafieldDescriptors) * - `entry`: the ACTUAL shaped metafield from the entity's GraphQL data * (`metafields { namespace key type value }`) * * The matrix (theme-metafields design § V1b): * declared + visibleToCustomer:false → hidden (never the default — the * customer GraphQL response omits hidden fields, so `value ?? default` * would otherwise render a private field's default publicly) * value present, type matches → value * absent / unset → defaultValue ?? placeholder * resolved type ≠ declared type → default (conflict-skipped incumbent) * undeclared key → GraphQL-only best effort */ export interface ShapedMetafieldEntry { namespace: string; key: string; /** GraphQL returns the enum NAME (e.g. "SHORT_TEXT"); normalized here. */ type?: string | null; value?: unknown; } export interface ProjectedDescriptorLike { type: string; isList?: boolean; visibleToCustomer: boolean; name?: string; description?: string; placeholder?: string; } export interface MetafieldMeta { /** Normalized (lowercase) field type, declared-first. */ type?: string; isList?: boolean; name?: string; placeholder?: string; /** True when the rendered value is a fallback, not stored data. */ isDefault: boolean; } export type MetafieldResolution = { kind: 'hidden'; } | { kind: 'value'; value: unknown; meta: MetafieldMeta; warn?: string; } | { kind: 'default'; value: unknown; meta: MetafieldMeta; warn?: string; } | { kind: 'empty'; warn?: string; }; export declare function resolveMetafield(opts: { ref: string; descriptor?: ProjectedDescriptorLike; entry?: ShapedMetafieldEntry; defaultValue?: unknown; }): MetafieldResolution;