import { EmbeddedPackagesMaterializer, PlannedTarball } from '../embedded-packages/materializer.js'; import { ComputeWorkspaceCacheHashOptions, EmbeddedPackageInput } from './cache-hash.js'; import { BundlePackagesPrune } from './package-prune.js'; import { PackageManager } from './package-files/package-manager.js'; import { File } from './parser.js'; import { Registries } from '../runner/registries.js'; import { Workspace } from './package-files/workspace.js'; export interface CreateBundleArchiveOptions { tempDir?: string; stripPrefix?: string; } export declare class BundleArchive { #private; static TMPDIR_PREFIX: string; static DEFAULT_FILENAME: string; private constructor(); static create(options: CreateBundleArchiveOptions): Promise; add(...files: File[]): Promise; finalize(): Promise; destroy(): Promise; } export interface BundleTooLargeErrorOptions { sizeBytes: number; maxBytes?: number; containsEmbeddedPackages?: boolean; cause?: unknown; } /** * Error thrown when the Checkly API rejects the code bundle upload because * the bundle exceeds the maximum size the API accepts (HTTP 413). The size * limit is enforced server-side and is not known ahead of time; it is parsed * from the response when the server names it. */ export declare class BundleTooLargeError extends Error { readonly sizeBytes: number; readonly maxBytes?: number; readonly containsEmbeddedPackages: boolean; constructor(options: BundleTooLargeErrorOptions); } export interface CreateFinalizedBundleArchiveOptions { archiveFile: string; containsEmbeddedPackages?: boolean; } export declare class FinalizedBundleArchive { #private; private constructor(); static create(options: CreateFinalizedBundleArchiveOptions): Promise; get archiveFile(): string; store(): Promise; } export interface CreateRemoteBundleArchiveOptions { key: string; } export declare class RemoteBundleArchive { #private; private constructor(); static create(options: CreateRemoteBundleArchiveOptions): Promise; get key(): string; } export interface CreateBundlerOptions { tempDir?: string; cacheHash: string; stripPrefix?: string; } export type CreateBundlerForWorkspaceOptions = Omit & Omit & { /** * The project's `runner.registries` option, when set. Serialized into * the bundle as {@link REGISTRIES_ARCHIVE_PATH} during finalize() so * Checkly runners route the bundle's package installs through the * configured upstreams, and mixed into the cache hash: repointing a * registry changes the runner's install inputs without necessarily * touching the lockfile. */ runnerRegistries?: Registries; /** * The materializer for the project's `bundle.packages.embed` option, * when set. The tarballs are materialized during finalize(), after the * bundled lockfile has been pruned, so only tarballs the shipped * lockfile still references are downloaded and shipped. That same * filtered set (name, version, integrity) is mixed into the cache hash: * embedded tarballs change the runner's install-step inputs without * necessarily touching the lockfile, so a changed embed set must * invalidate the dependency cache. */ embeddedPackagesMaterializer?: EmbeddedPackagesMaterializer; /** * The workspace's package manager. When it supports a lockfile-only * install, the bundled lockfile is pruned during finalize() to match the * bundle's actual set of manifests. */ packageManager: PackageManager; /** * The project's `bundle.packages.prune` option, when set. Matching * entries are removed from the workspace manifests shipped in the * bundle during finalize(), before lockfile pruning, so the removed * dependencies fall out of the pruned lockfile too. The rewritten * manifests are mixed into the cache hash the same way patch-rewritten * manifests are. Because the rewritten manifests only make sense next * to a matching lockfile, the rewrite is rolled back when a bundled * lockfile cannot be pruned in the same run. */ packagePrune?: BundlePackagesPrune; }; /** * Maps planned tarballs to cache-hash records. yarn.lock plans carry no SRI * tarball integrity (it is resolved from registry metadata only at * materialization time), so their records use the lockfile's own checksum — * an equally stable content pin that is known at plan time, keeping the * eager placeholder hash and the finalize hash consistent. The parsers * guarantee one of the two hashes is always present; the empty-string * fallback only satisfies the type. */ export declare function embeddedPackageHashInputs(tarballs: PlannedTarball[] | undefined): EmbeddedPackageInput[] | undefined; export declare class Bundler { #private; private constructor(); /** * Creates a bundler without a workspace context. Workspace-dependent * finalize() behavior — lockfile pruning, embedded package * materialization (`bundle.packages.embed`) and the cache-hash recompute * — only happens for bundlers built with {@link createForWorkspace}; a * plain bundler archives exactly the files registered into it. */ static create(options: CreateBundlerOptions): Promise; static createForWorkspace(workspace: Workspace, options: CreateBundlerForWorkspaceOptions): Promise; get marker(): BundlePathMarker; updateMarker(newValue: string): void; /** * The dependency cache hash. A mutable holder rather than a plain string: * consumers copy it into check payloads during bundle(), but the final * value — reflecting faux manifests and a possibly pruned lockfile — is * only known once finalize() has run, the same ordering problem * {@link BundlePathMarker} solves for the archive path. */ get cacheHash(): CacheHashMarker; /** * Whether any files have been registered for bundling. Only Playwright check * suites register files (see playwright-check.ts), so an empty bundler means the * project has nothing that needs a remote code bundle and the upload can be skipped. */ get isEmpty(): boolean; registerFiles(...files: File[]): void; finalize(): Promise; } export declare class BundlePathMarker { #private; constructor(initialValue: string); updateValue(newValue: string): void; toJSON(): string; } /** * Mutable holder for the dependency cache hash, serialized as a plain * string. See {@link Bundler.cacheHash} for why a holder is needed. * * Deliberately a standalone class rather than a subclass of * {@link BundlePathMarker}: the own `#value` field makes the two marker * types nominally incompatible, so a bundle path cannot be passed where the * cache hash is expected (or vice versa) without a compile error. */ export declare class CacheHashMarker { #private; constructor(initialValue: string); updateValue(newValue: string): void; toJSON(): string; }