import type { EdgeKind, GraphChange as InternalGraphChange, OverrideConstraint as InternalOverrideConstraint, OverrideManager, Patch, SourceDiscriminator } from '../../graph.js'; import { type Diagnostic } from './diagnostics.js'; export type { EdgeKind, OverrideManager, Patch, SourceDiscriminator }; export type NodeId = string; export type TarballKey = string; export interface Node { readonly id: NodeId; readonly name: string; readonly version: string; readonly peerContext: readonly NodeId[]; readonly patch?: Patch; readonly source?: SourceDiscriminator; readonly workspacePath?: string; } export type HashOrigin = 'sri' | 'berry-zip' | 'url-fragment' | 'registry' | 'recomputed'; export interface IntegrityHash { readonly algorithm: string; readonly digest: string; readonly origin: HashOrigin; } export interface Integrity { readonly hashes: readonly IntegrityHash[]; } export type HostingProvider = 'github' | 'gitlab' | 'bitbucket'; export type Resolution = Readonly<{ kind: 'registry'; bind?: string; }> | Readonly<{ kind: 'tarball'; url: string; hostingProvider?: HostingProvider; bind?: string; }> | Readonly<{ kind: 'git'; url: string; sha: string; hostingProvider?: HostingProvider; }> | Readonly<{ kind: 'directory'; path: string; }> | Readonly<{ kind: 'unknown'; raw: string; }>; export interface TarballKeyInput { readonly name: string; readonly version: string; readonly patch?: Patch; readonly source?: SourceDiscriminator; } export interface TarballPayload { readonly integrity?: Integrity; readonly berryChecksumCacheKey?: string; readonly engines?: Readonly>; readonly funding?: unknown; readonly license?: string; readonly bin?: string | Readonly>; readonly deprecated?: string; readonly cpu?: readonly string[]; readonly os?: readonly string[]; readonly libc?: readonly string[]; readonly hasInstallScript?: boolean; readonly bundledDependencies?: readonly string[]; readonly peerDependencies?: Readonly>; readonly peerDependenciesMeta?: Readonly>>; readonly resolution?: Resolution; readonly nativeResolution?: string; } export interface WorkspaceRange { readonly protocol: 'workspace'; readonly selector: string; } export interface EdgeAttributes { readonly range?: string; readonly overrideRange?: string; readonly optional?: boolean; readonly workspace?: boolean; readonly alias?: string; readonly workspaceRange?: WorkspaceRange; } export interface Edge { readonly source: NodeId; readonly target: NodeId; readonly kind: EdgeKind; readonly attributes?: EdgeAttributes; } export interface EdgeTriple { readonly source: NodeId; readonly target: NodeId; readonly kind: EdgeKind; } export interface LayoutHints { readonly strategy?: 'isolated' | 'hoisted' | 'pnp' | 'nm-linked'; } export interface Manifest { readonly name?: string; readonly version?: string; readonly dependencies?: Readonly>; readonly devDependencies?: Readonly>; readonly optionalDependencies?: Readonly>; readonly peerDependencies?: Readonly>; readonly workspaces?: readonly string[]; readonly overrides?: readonly OverrideConstraint[]; readonly native?: Readonly<{ npmOverrides?: unknown; yarnResolutions?: Readonly>; pnpmOverrides?: Readonly>; }>; } export interface OverrideConstraint { readonly name: string; readonly parentPath?: readonly string[]; readonly versionCondition?: string; readonly to: string; readonly selfRef?: boolean; readonly origin?: OverrideManager; readonly captureIndex?: number; } export interface GraphWalkOptions { readonly direction?: 'out' | 'in'; readonly kinds?: readonly EdgeKind[]; readonly maxDepth?: number; } export interface GraphDiff { readonly addedNodes: readonly NodeId[]; readonly removedNodes: readonly NodeId[]; readonly changedNodes: readonly NodeId[]; readonly addedEdges: readonly EdgeTriple[]; readonly removedEdges: readonly EdgeTriple[]; } export type GraphChange = Readonly<{ kind: 'node-added'; subject: NodeId; }> | Readonly<{ kind: 'node-removed'; subject: NodeId; }> | Readonly<{ kind: 'node-replaced'; subject: NodeId; previous?: NodeId; }> | Readonly<{ kind: 'edge-added'; subject: EdgeTriple; }> | Readonly<{ kind: 'edge-removed'; subject: EdgeTriple; }> | Readonly<{ kind: 'peer-context-replaced'; subject: NodeId; previous?: NodeId; }> | Readonly<{ kind: 'tarball-set'; subject: TarballKey; }> | Readonly<{ kind: 'tarball-removed'; subject: TarballKey; }>; export interface GraphMutation { replaceNode(id: NodeId, replacement: Node): void; addNode(node: Node): void; removeNode(id: NodeId): void; addEdge(source: NodeId, target: NodeId, kind: EdgeKind, attributes?: EdgeAttributes): void; removeEdge(source: NodeId, target: NodeId, kind: EdgeKind): void; replacePeerContext(id: NodeId, peers: readonly NodeId[]): void; setTarball(key: TarballKeyInput, payload: TarballPayload): void; removeTarball(key: TarballKeyInput): void; addDiagnostic(diagnostic: Diagnostic): void; } export interface GraphMutationResult { readonly graph: Graph; readonly diagnostics: readonly Diagnostic[]; readonly applied: readonly GraphChange[]; } export interface Graph { getNode(id: NodeId): Node | undefined; nodes(): IterableIterator; byName(name: string): readonly NodeId[]; roots(): ReadonlySet; out(id: NodeId, kind?: EdgeKind): readonly Edge[]; in(id: NodeId, kind?: EdgeKind): readonly Edge[]; walk(seeds: NodeId | readonly NodeId[], options?: GraphWalkOptions): IterableIterator; topoSort(): readonly (readonly NodeId[])[]; subgraph(seeds: NodeId | readonly NodeId[], options?: GraphWalkOptions): Graph; diff(other: Graph): GraphDiff; tarball(key: TarballKeyInput): TarballPayload | undefined; tarballOf(node: NodeId): TarballPayload | undefined; tarballs(): IterableIterator; overrides(): readonly OverrideConstraint[]; governingOverride(name: string, consumerPath: readonly string[], declaredRange?: string): OverrideConstraint | undefined; registryPackages(): Readonly>; diagnostics(): readonly Diagnostic[]; layoutHints(): LayoutHints | undefined; mutate(transaction: (mutation: GraphMutation) => void): GraphMutationResult; } export declare function publicOverride(value: InternalOverrideConstraint): OverrideConstraint; export declare function internalOverride(value: OverrideConstraint): InternalOverrideConstraint; export declare function publicGraphChange(value: InternalGraphChange): GraphChange;