/** * Item ref resolver — classifies each preset item's ref and produces an apply plan. * * Three ref types: * - Asset ref: `/@` → create new Instance + assign * - Library ref: `library:///instances/` → reuse existing Instance * - Nested Preset: another preset ref → recursively apply * - Cross-item ref: `#` → resolved at apply-time from sibling item results * * @docLink packages/library/concepts#preset-item-resolution */ import type { PresetItem } from "@skaile/workspaces/types/manifests"; import type { AssetDefinition, IAssetIndex, Instance } from "../library.js"; /** * Classification of a preset item's ref string. * * @docLink packages/library/concepts#preset-item-resolution */ export type ItemRefKind = "asset" | "library-instance" | "nested-preset" | "cross-item"; /** * A resolved preset item whose ref is an asset definition ref. * * At apply-time, a new Instance will be created from `defRef`. * * @docLink packages/library/concepts#preset-item-resolution */ export interface ResolvedAssetItem { kind: "asset"; item: PresetItem; /** The asset definition ref (may include version). */ defRef: string; /** Resolved asset definition from library cache (null if not cached). */ assetDef: AssetDefinition | null; } /** * A resolved preset item whose ref is a `library://` URI pointing to an existing Instance. * * @docLink packages/library/concepts#preset-item-resolution */ export interface ResolvedLibraryItem { kind: "library-instance"; item: PresetItem; /** The instance UUID extracted from the library:// URI. */ instanceId: string; /** The resolved instance (null if not found). */ instance: Instance | null; } /** * A resolved preset item that recursively refers to another preset. * * @docLink packages/library/concepts#preset-item-resolution */ export interface ResolvedNestedPresetItem { kind: "nested-preset"; item: PresetItem; /** The nested preset ref. */ presetRef: string; } /** * A resolved preset item that is a cross-item reference (`#`). * * Resolved at apply-time from sibling item results (items must be ordered). * * @docLink packages/library/concepts#preset-item-resolution */ export interface ResolvedCrossItemRef { kind: "cross-item"; item: PresetItem; /** The target item id (without the # prefix). */ targetId: string; } /** * Discriminated union of all resolved preset item types. * * @docLink packages/library/concepts#preset-item-resolution */ export type ResolvedItem = ResolvedAssetItem | ResolvedLibraryItem | ResolvedNestedPresetItem | ResolvedCrossItemRef; /** * Classify a single item ref string into its {@link ItemRefKind}. * * Returns `"asset"` by default when the ref doesn't match a known prefix. * The caller (apply.ts) re-classifies based on `knownPresetRefs`. * * @param ref - The raw ref string from a preset item. * @returns The classified kind. * @docLink packages/library/concepts#preset-item-resolution */ export declare function classifyRef(ref: string): ItemRefKind; /** * Extract the instance UUID from a `library://` URI. * * Format: `library:///instances/` where tier is `personal | team | org`. * * @param ref - The full `library://` URI string. * @returns The UUID string, or null if the URI is malformed. * @docLink packages/library/concepts#preset-item-resolution */ export declare function extractLibraryInstanceId(ref: string): string | null; /** * Resolve a single preset item against the library. * * @param item - The preset item to resolve. * @param library - The library to look up definitions/instances. * @param knownPresetRefs - Set of refs known to be presets (for nested detection). * @returns A typed {@link ResolvedItem} discriminated by kind. * @docLink packages/library/concepts#preset-item-resolution */ export declare function resolveItem(item: PresetItem, library: IAssetIndex, knownPresetRefs?: Set): Promise; /** * Resolve all items in a preset in parallel. * * @param items - Array of preset items to resolve. * @param library - The library to look up definitions/instances. * @param knownPresetRefs - Set of refs known to be presets. * @returns Array of resolved items in the same order as the input. * @docLink packages/library/concepts#preset-item-resolution */ export declare function resolveAllItems(items: PresetItem[], library: IAssetIndex, knownPresetRefs?: Set): Promise; //# sourceMappingURL=resolve-item.d.ts.map