/** Widget payload inside a resolve response, before it is prepared for render. */ export interface RuleCMSWidgetRawData { widget?: { publishedKey?: string; }; childCollections?: Record; [key: string]: unknown; } /** A JSON leaf or nested value accepted in resolve `params`. */ export type WidgetSelectionParamValue = string | number | boolean | null | WidgetSelectionParamValue[] | WidgetSelectionParams; /** * Any JSON object. Sent to the resolve endpoint as-is — the server flattens * nested objects (`user.plan`) before evaluating rules. `undefined` values are * allowed for ergonomics (`{ plan: user?.plan }`) and dropped by JSON. */ export interface WidgetSelectionParams { [name: string]: WidgetSelectionParamValue | undefined; } /** * `Content-Type` sent on the resolve POST. `text/plain` is CORS-safelisted, so * the browser skips the preflight; it is the default everywhere. * `application/json` is for server-to-server calls only. */ export type WidgetResolveContentType = 'application/json' | 'text/plain'; export type WidgetSelectionOutcome = 'rule' | 'default' | 'fallback-default'; /** Which widget a ruleset picked and why. Returned alongside the widget payload. */ export interface WidgetSelection { rulesetPublishedKey?: string; rulesetVersion?: string; schemaVersion?: number; outcome: WidgetSelectionOutcome; /** Matched rule id, or `null` for the default / fallback-default outcomes. */ ruleId: string | null; /** Experiment variant id, or `null` when the rule was not an experiment. */ variantId: string | null; widgetKey: string; widgetPublishedKey: string; } /** Options shared by every ruleset-driven entry point (hook, widget, server fetch). */ export interface WidgetResolveRequestOptions { /** * Staging/production: ruleset published key (`{environmentId}---ruleset-…`). * Development (`dev.` token): the `ruleset-…` key; a published key is * accepted and stripped to its `ruleset-…` suffix. */ rulesetPublishedKey: string; /** Any JSON object. Sent as-is; the server flattens nested objects. */ params?: WidgetSelectionParams; /** * Widget to GET through the plain published path when the resolve request * fails at the network level or with a 5xx. Not used on 4xx (bad token, * unknown ruleset…), and not needed for "no rule matched" — the ruleset's * own default covers that on the server. */ fallbackPublishedKey?: string; /** * Defaults to `text/plain` (no CORS preflight). Use `application/json` only * for server-to-server calls. */ contentType?: WidgetResolveContentType; } /** Published resolve response (`mode: "payload"`): today's GET envelope plus `selection`. */ export interface ResolveRuleCMSWidgetResponse { success: boolean; data?: RuleCMSWidgetRawData & { selection: WidgetSelection; }; } /** Draft resolve response — unwrapped, with `resolution` in place of `selection`. */ export interface DevResolveRuleCMSWidgetResponse extends RuleCMSWidgetRawData { resolution: { outcome: WidgetSelectionOutcome; ruleId?: string | null; variantId?: string | null; widgetKey: string; widgetPublishedKey: string; trace?: unknown; }; } /** Resolve response reduced to the existing widget payload plus its selection. */ export interface NormalizedWidgetResolveResult { raw: RuleCMSWidgetRawData; selection: WidgetSelection; } //# sourceMappingURL=types.d.ts.map