import type { Project } from '../../constructs/project.js'; import type { DiffEntry, ResourceSync } from '../../rest/projects.js'; import { type PhysicalIds } from './import-shape.js'; import { type DiffLine } from './diff-lines.js'; import type { VariableNames } from './variable-names.js'; /** * The lines printed under one updated resource of a deploy preview: the * construct as Checkly has it against the construct as the local code would * make it, rendered by the import codegen on both sides and diffed as text * (spec 8.5). Everything here is reporting: a failure falls back to a coarser * listing of the reported changes, and never to a failed deploy. */ /** * One line printed under an updated resource. A `DiffLine` is a line of the * construct diff; a `note` is a fact stated in words (a change the diff * cannot show, a secret's movement, a listed property); a `reason` says why * the listing stands in for the diff; a `nested` line belongs to the text * diff of a property kept in a file of its own, printed under its `note`. */ export type RenderedLine = DiffLine | { kind: 'note'; text: string; } | { kind: 'reason'; text: string; } | { kind: 'nested'; line: DiffLine; }; export interface RenderResourceInput { /** The resource's preview entry, carrying `before`, `changes` and `redactions` under `detail: 'full'`. */ entry: DiffEntry; /** The resource's own local payload, as sent in the deploy. */ local: ResourceSync | undefined; /** Every resource of the local deploy payload (for the relations of a check or group). */ localResources: readonly ResourceSync[]; /** The whole preview (for the relation entries folded into this resource). */ diff: readonly DiffEntry[]; project: Project; ids: PhysicalIds; pruneRelations: boolean; /** The variable each construct has in the user's code; one without an entry gets a generated name. */ variableNames?: VariableNames; /** * The properties the resource's declaration spells out (`ContextOptions.spelledOut`): * rendered on both sides whatever their values, so that a value moved to or * from a default reads as a change of that line and not as its removal. */ spelledOut?: ReadonlySet; /** The most lines a diff may take before the listing is printed instead. */ maxLines?: number; } /** * Whether every change the entry reports is named by a cause and none is a * secret: such an entry is rendered as one `changed: ` notice, with * no diff, so it needs no deployed state, and the API sends it none. */ export declare function changedByCauseAlone(entry: DiffEntry): boolean; export declare function renderResourceDiff(input: RenderResourceInput): RenderedLine[];