import { JsoncEdit, JsoncEdit as JsoncEdit$1, JsoncPath, JsoncPath as JsoncPath$1 } from "@effected/jsonc"; import { CatalogResolver, DependencyKind, DependencyProtocol, DependencyProtocol as DependencyProtocol$1, DependencySpecifier, DependencySpecifierBrand, InvalidDependencySpecifierError, WorkspaceResolver, isValidDependencySpecifier } from "@effected/npm"; import { InvalidVersionError, Range, SemVer } from "@effected/semver"; import { Brand, Context, Effect, FileSystem, HashMap, Layer, Option, Path, Result, Schema } from "effect"; //#region src/Dependency.d.ts declare const Dependency_base: Schema.Class; /** For `peer` dependencies, whether the peer is optional (from `peerDependenciesMeta`). */ readonly isOptional: Schema.optionalKey; }>, {}>; /** * A resolved dependency entry pairing a package name with its version * specifier and the `kind` of map it came from (`@effected/npm`'s * `DependencyKind`). The protocol predicates delegate to `DependencySpecifier`. * * @public */ declare class Dependency extends Dependency_base { /** The classified protocol, or `None` for an empty specifier. */ get protocol(): Option.Option; /** Parse the specifier as a semver `Range`, `None` when it is not a range. */ get range(): Option.Option; /** Whether the specifier points to a local path. */ get isLocal(): boolean; /** Whether the specifier uses the `link:` protocol. */ get isLink(): boolean; /** Whether the specifier uses the `portal:` protocol. */ get isPortal(): boolean; /** Whether the specifier uses the `catalog:` protocol. */ get isCatalog(): boolean; /** Whether the specifier uses the `workspace:` protocol. */ get isWorkspace(): boolean; /** Whether the specifier is an unresolved `catalog:` or `workspace:` protocol. */ get isUnresolved(): boolean; /** Whether the specifier resolves to a git source. */ get isGit(): boolean; /** Whether the specifier is a parseable semver range. */ get isRange(): boolean; /** Whether the specifier is a dist-tag. */ get isTag(): boolean; } /** * A {@link Dependency} whose specifier is an unresolved `catalog:` or * `workspace:` protocol. * * @public */ type UnresolvedDependency = Dependency & { readonly isUnresolved: true; }; /** * Type guard narrowing any dependency-like value to * {@link UnresolvedDependency}, preserving the concrete type. * * @public */ declare const isUnresolvedDependency: (dependency: T) => dependency is T & { readonly isUnresolved: true; }; //#endregion //#region src/DevEngines.d.ts declare const DevEngine_base: Schema.Class; /** The optional behavior when the constraint is unmet. */ readonly onFail: Schema.optionalKey>; }>, {}>; /** * A single `devEngines` constraint with a name and optional `version` / `onFail`. * * @public */ declare class DevEngine extends DevEngine_base {} /** * A `devEngines` constraint slot: a single {@link DevEngine} or an array of them. * * @public */ declare const DevEngineOrArray: Schema.Union<[typeof DevEngine, Schema.$Array]>; /** * The `devEngines` field schema, modeling runtime and package-manager * constraints as optional {@link DevEngine} slots. * * @public */ declare const DevEnginesSchema: Schema.Struct<{ readonly packageManager: Schema.optionalKey; readonly runtime: Schema.optionalKey; readonly os: Schema.optionalKey; readonly cpu: Schema.optionalKey; readonly libc: Schema.optionalKey; }>; /** * The decoded `devEngines` field type. * * @public */ type DevEngines = typeof DevEnginesSchema.Type; //#endregion //#region src/EntryPoint.d.ts /** * Options for {@link resolveEntryPoint}. * * @public */ interface ResolveEntryPointOptions { /** * The export conditions to honour, in priority order. * * @remarks * The first condition present in the manifest wins, so the order is the * policy — `["require", "import"]` and `["import", "require"]` resolve the * same manifest to different files, on purpose. * * @defaultValue `["import", "default"]` */ readonly conditions?: ReadonlyArray; } declare const UnresolvedEntryPointError_base: Schema.Class; /** The conditions that were tried, for `noConditionMatched`. */ readonly conditions: Schema.optionalKey>; }>, import("effect/Cause").YieldableError>; /** * Raised when a manifest resolves no root entry point. * * @remarks * The reason is discriminated rather than a bare "not found" because the three * shapes call for different responses, and a caller staring at a consumer's * plugin at 3am needs to know which one it hit. Collapsing them into one * sentinel is the same class of quiet wrong answer as an untyped error channel. * * @public */ declare class UnresolvedEntryPointError extends UnresolvedEntryPointError_base { get message(): string; } /** * The manifest fields entry resolution reads. * * @remarks * Deliberately structural rather than the full {@link PackageManifest}, so a * caller can resolve an entry point from any object carrying these two fields — * a manifest parsed straight from a tarball, for instance, with nothing else * validated yet. * * @public */ interface EntryPointManifest { readonly exports?: unknown; readonly main?: unknown; } /** * Resolve a package's root entry point from its manifest. * * @remarks * The half of "read something out of a published package" that has no home * anywhere else: given a manifest, which file is the package's `"."` entry? * It is pure and IO-free by design — nothing here touches a filesystem, so it * is testable against plain manifest objects with no package on disk, and it * composes with a directory that arrived by any route. * * All three legal `exports` spellings are honoured, because all three appear in * real published packages: * * - **String shorthand** — `"exports": "./index.js"`, sugar for `{ ".": … }`. * - **Subpath map** — `{ ".": "./index.js" }`, or `{ ".": { import, … } }`. * - **Root conditions** — `{ "import": "./index.js", "default": "./index.cjs" }`, * conditions at the root with no `"."` key. * * **`exports` encapsulates the package.** When it is present but nothing * matches, the answer is a typed failure and `main` is **not** consulted — that * is Node's rule, and the lenient reading (falling through to `main`, then to * `index.js`) is the subtly wrong one: it answers a file the package * deliberately does not export, which loads and behaves plausibly instead of * failing. Only when `exports` is **absent** does `main`, and then the legacy * `index.js` default, apply. * * A failure is also the answer for an `exports` form this resolver does not * implement — an array fallback list, or a subpath map with no `"."` entry. * Both are honest "this resolver cannot tell you", never a guess, and each * carries its own {@link UnresolvedEntryPointError} reason so a caller can log * which shape a package actually had rather than a flat "could not resolve". * * @example * ```ts * import { resolveEntryPoint } from "@effected/package-json"; * import { Result, Schema } from "effect"; * * resolveEntryPoint({ exports: { import: "./esm.js", require: "./cjs.js" } }); * // Result.succeed("./esm.js") * * resolveEntryPoint({ exports: { require: "./cjs.js" } }, { conditions: ["require"] }); * // Result.succeed("./cjs.js") * * resolveEntryPoint({ exports: { require: "./cjs.js" }, main: "./legacy.js" }); * // Result.fail(UnresolvedEntryPointError { reason: "noConditionMatched" }) * ``` * * @param manifest - A package manifest, or any object carrying `exports`/`main`. * @param options - Which conditions to honour, in priority order. * @returns The entry path as written in the manifest, relative to the package * root, or a typed {@link UnresolvedEntryPointError} naming which shape * blocked resolution. * * @public */ declare const resolveEntryPoint: (manifest: EntryPointManifest, options?: ResolveEntryPointOptions) => Result.Result; //#endregion //#region src/License.d.ts declare const InvalidSpdxLicenseError_base: Schema.Class, import("effect/Cause").YieldableError>; /** * Indicates that a string is not a valid SPDX license identifier or expression. * * Raised by {@link Package.setLicense} and the decode direction of * `SpdxLicense`. The offending string is preserved on `input`. * * @public */ declare class InvalidSpdxLicenseError extends InvalidSpdxLicenseError_base { get message(): string; } /** * Whether a string is a valid SPDX license identifier or expression, or one of * the npm special cases `UNLICENSED` / `SEE LICENSE IN `. * * @public */ declare const isValidSpdx: (value: string) => boolean; /** * A valid SPDX license identifier, expression, `UNLICENSED`, or * `SEE LICENSE IN `. * * @public */ declare const SpdxLicense: Schema.brand; /** * A branded SPDX license string. * * @public */ type SpdxLicense = string & Brand.Brand<"SpdxLicense">; //#endregion //#region src/PackageManager.d.ts declare const PackageManager_base: Schema.Class.` form. */ readonly integrity: Schema.Option & { FromSri: Schema.Codec; fromSri: (input: string) => Effect.Effect; }>; }>, {}>; /** * A structured `packageManager` value with `name`, `version` and an optional * `integrity` hash. * * @remarks * The same `@[+]` triple `@effected/npm`'s * `PackageManagerPin` models, in its `package.json` field form. Both share the * strict pieces — the version is `@effected/semver`'s * `SemVer.PinnableVersionString` (decode rules through `SemVer.isPinnable`), * the integrity is npm's `CorepackIntegrityHash` — and * both apply the first-`+`-is-integrity rule. Reach for the pin when * provisioning a package manager; reach for this class when reading or writing * the manifest field. * * **The one deliberate divergence is the name grammar**, and it points this * way: the pin closes the set to the four managers the kit can provision * (`npm | pnpm | yarn | bun`), while this field model accepts any lowercase * name. The evidence: * * - Corepack 0.34.0 (`specUtils.ts`, `parseSpec`) recognises **three** names — * `npm`, `pnpm`, `yarn` — and throws an "unsupported package manager * specification" usage error for any other. Adopting that set here would reject * `bun@1.2.20`, which is real: six published packages in this repo's own * `node_modules` carry exactly that value, and a manifest model that cannot * read them is useless for the job it has. * - Corepack does not treat the set as closed either. `parseSpec` skips the * name check entirely when the spec is a URL, so a custom name is reachable * in corepack's own grammar (behind `COREPACK_ENABLE_UNSAFE_CUSTOM_URLS`). * - npm documents no constraint on this field at all. Its `package.json` * reference constrains only `devEngines.packageManager.name` — a different * field, modeled here by `DevEngine` and out of scope for this class. * * So: field model = manifests as they exist in the wild; pin = the kit's * provisioning vocabulary. A name outside the pin's four is representable here * and simply will not be installable through the pin — which is the honest * relationship between a document model and a provisioning contract. * * @public */ declare class PackageManager extends PackageManager_base { /** * Schema transformation between the `"name@version+integrity"` string and a * {@link PackageManager}. * * @remarks * Decoding splits on the first `@`, then on the first `+` — which always * begins the integrity, never semver build metadata — and validates each * component: the name against the lowercase grammar, the version through * `@effected/semver`'s strict parse, the integrity through * `CorepackIntegrityHash`. Every failure is a typed decode failure naming * the component that failed. Encoding prints the canonical string, which is * byte-identical to any input this codec accepts. */ static readonly FromString: Schema.Codec; /** Whether an integrity hash is present. */ get hasIntegrity(): boolean; } //#endregion //#region src/PackageName.d.ts declare const InvalidPackageNameError_base: Schema.Class, import("effect/Cause").YieldableError>; /** * Indicates that a string could not be used as a valid npm package name. * * Raised by {@link Package.setName} and the decode direction of * `PackageName`. The offending string is preserved on `input`. * * @public */ declare class InvalidPackageNameError extends InvalidPackageNameError_base { get message(): string; } /** * A valid npm scoped package name (`@scope/name`). * * @public */ declare const ScopedPackageName: Schema.brand; /** * A valid npm scoped package name. * * @public */ type ScopedPackageName = string & Brand.Brand<"ScopedPackageName">; /** * A valid npm unscoped package name (no `@scope/` prefix). * * @public */ declare const UnscopedPackageName: Schema.brand; /** * A valid npm unscoped package name. * * @public */ type UnscopedPackageName = string & Brand.Brand<"UnscopedPackageName">; /** * A valid npm package name, scoped or unscoped. * * @public */ type PackageName = ScopedPackageName | UnscopedPackageName; /** * The union of `ScopedPackageName` and `UnscopedPackageName`, * carrying the classification statics (`PackageName.isValid` and friends) * that absorb the v3 floating `PackageNameUtil` object. Use it as the schema * for a package-name field and reach for the statics to inspect a raw string. * * @public */ declare const PackageName: Schema.Union, Schema.brand]> & { isValid: (name: string) => boolean; scope: (name: string) => Option.Option; unscoped: (name: string) => string; isScoped: (name: string) => boolean; }; //#endregion //#region src/Person.d.ts declare const Person_base: Schema.Class; /** The optional homepage URL. */ readonly url: Schema.optionalKey; /** Any additional keys, preserved verbatim and flattened back on encode. */ readonly rest: Schema.optionalKey>; }>, {}>; /** * A structured person object with `name`, optional `email` / `url`, and a * `rest` catch-all preserving any additional keys across a read/write cycle. * * @public */ declare class Person extends Person_base { /** * The object wire codec: an open JSON object ↔ a {@link Person}, partitioning * unknown keys into `rest` and flattening them back on encode so the on-disk * shape never carries a literal `rest` key. */ static readonly schema: Schema.Codec; /** * Schema transformation between the `"Name (url)"` shorthand string * and a {@link Person}. Decoding remembers the input text so that encoding * reproduces it verbatim; see {@link Person.wireStringOf}. */ static readonly FromString: Schema.Codec; /** * The `author` / `contributors` value: either the shorthand string or the * structured object, always decoded to a {@link Person}. * * The wire form is preserved across a round trip — a person read from the * shorthand string encodes back to that string, byte for byte, and one read * from an object encodes back to an object with its unknown keys intact. * Formatting a manifest therefore never rewrites one legal encoding into the * other. * * Provenance belongs to the instance, so a person that is *rebuilt* (rather * than carried through unchanged) has none and encodes in the canonical * object form. Editing an unrelated field of the surrounding `Package` * carries the same person instance through and preserves its encoding. */ static readonly FromValue: Schema.Codec; /** * The shorthand text this person was decoded from, when it was decoded from * the string form and still matches its fields; `None` for a person built * from an object or by hand. * * Exposed so callers can tell which encoding a manifest used without * re-reading the file. * * @param person - the person to inspect * @returns the original shorthand text, or `None` */ static wireStringOf(person: Person): Option.Option; } //#endregion //#region src/Repository.d.ts declare const Repository_base: Schema.Class; /** The reference exactly as written: a shorthand, a git URL, or an https URL. */ readonly url: Schema.String; /** The subdirectory within the repository, for a monorepo member. */ readonly directory: Schema.optionalKey; /** Keys outside the documented set, preserved so encoding does not drop them. */ readonly rest: Schema.optionalKey>; }>, {}>; /** * Where a package's source lives. * * @remarks * `url` is **verbatim** — exactly the string the manifest carried, shorthand * and all. Normalization is offered through {@link Repository.browseUrl} and * {@link Repository.gitUrl}, so reading a manifest never rewrites it and a * caller that wants the original still has it. * * @example * ```ts * // "effected/kit" → https://github.com/effected/kit * // "git@github.com:effected/kit.git" → https://github.com/effected/kit * ``` * * @public */ declare class Repository extends Repository_base { /** * The browsable `https://` URL, or `Option.none()` when `url` is not a form * this model recognizes. */ get browseUrl(): Option.Option; /** The canonical https clone URL, or none when it cannot be derived. */ get gitUrl(): Option.Option; /** * The `repository` field: the shorthand string or the object form, always * decoded to a {@link Repository}, and always re-encoded in the form it was * read from. */ static readonly FromValue: Schema.Codec; } declare const Bugs_base: Schema.Class; /** The address to mail instead of, or alongside, filing an issue. */ readonly email: Schema.optionalKey; /** Keys outside the documented set, preserved so encoding does not drop them. */ readonly rest: Schema.optionalKey>; }>, {}>; /** * Where to report problems with a package. * * @remarks * npm permits a bare URL string, or an object with `url`, `email`, or both — * an email-only entry is legal, which is why `url` is optional. * * @public */ declare class Bugs extends Bugs_base { /** The `bugs` field: a URL string or the object form. */ static readonly FromValue: Schema.Codec; } //#endregion //#region src/Package.d.ts /** * A string→string map field decoding a plain JSON object to a `HashMap`, * defaulting to an empty map when the key is absent. Backs the four dependency * maps and `scripts`. Not meant to be referenced directly. * * @public */ declare const DependencyMapField: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; /** * A string→string map field decoding a plain JSON object to a `HashMap`, * with no default (an absent key stays absent). Backs `engines`. Not meant to * be referenced directly. * * @public */ declare const StringMapField: Schema.decodeTo, Schema.$Record, never, never>; /** * The `bin` field: a single string path or a name→path map. Not meant to be * referenced directly. * * @public */ declare const BinField: Schema.Union, Schema.$Record, never, never>]>; /** * The `exports` field: a single string entry point or an open object of * conditional exports. Not meant to be referenced directly. * * @public */ declare const ExportsField: Schema.Union]>; /** * The `publishConfig` field: an open record preserving known npm keys * (`access`, `directory`, ...) plus extensions like `targets`. Not meant to be * referenced directly. * * @public */ declare const PublishConfigField: Schema.$Record; /** * The `peerDependenciesMeta` field: a map of package name to `{ optional? }`. * Not meant to be referenced directly. * * @public */ declare const PeerDependenciesMetaField: Schema.$Record; }>>; /** * The `repository` field's raw wire shape: a shorthand string or an object. * * @deprecated Superseded by {@link Repository.FromValue}, which decodes both * encodings into a typed {@link Repository} with normalization getters and * round-trips the original form. Kept as a named type for consumers that were * matching on the raw union; it is no longer what `Package.repository` uses. * * @public */ declare const RepositoryField: Schema.Union]>; declare const PackageDecodeError_base: Schema.Class, import("effect/Cause").YieldableError>; /** * Indicates that a JSON value could not be decoded into a valid {@link Package}. * * Raised by {@link Package.decode}. The underlying `SchemaError` is preserved on * the structured `cause` field (never stringified), so callers keep the issue * tree for diagnostics. * * @public */ declare class PackageDecodeError extends PackageDecodeError_base { get message(): string; } /** * Indentation for serialized package.json output: a spaces count, `"tab"` for * real tab indentation, or `"preserve"` to reuse the indentation detected from * the original source text (falling back to the two-space default when no * source text is available). * * @public */ type PackageIndent = number | "tab" | "preserve"; /** * Options for {@link Package.toJsonString} and `PackageJsonFile.write`. * * @public */ interface PackageFormatOptions { /** Indentation: a spaces count, `"tab"`, or `"preserve"` (default `2`). */ readonly indent?: PackageIndent; /** * The original source text backing `indent: "preserve"`: its indentation * (tab vs N spaces, detected from the first indented line) is reused. * Ignored for other `indent` values. When absent, `PackageJsonFile.write` * supplies the existing file's text automatically; the pure * {@link Package.toJsonString} falls back to the default indentation. */ readonly sourceText?: string; /** Order top-level keys canonically and alphabetize dependency maps (default `true`). */ readonly sort?: boolean; /** Strip empty dependency-map keys (default `true`). */ readonly stripEmpty?: boolean; /** Append a trailing newline (default `true`). */ readonly newline?: boolean; } /** * A patch over {@link Package}'s modeled fields — every field optional, * derived from the schema so it never drifts from the model. * * @public */ type PackagePatch = Partial<{ readonly [K in keyof (typeof Package)["fields"]]: (typeof Package)["fields"][K]["Type"]; }>; declare const Package_base: Schema.Class, Schema.brand]> & { isValid: (name: string) => boolean; scope: (name: string) => Option.Option; unscoped: (name: string) => string; isScoped: (name: string) => boolean; }; readonly version: Schema.Codec; readonly description: Schema.optionalKey; readonly private: Schema.optionalKey; readonly type: Schema.optionalKey>; readonly main: Schema.optionalKey; readonly license: Schema.optionalKey>; readonly author: Schema.optionalKey>; readonly contributors: Schema.optionalKey>>; readonly maintainers: Schema.optionalKey>>; readonly keywords: Schema.optionalKey>; readonly repository: Schema.optionalKey>; readonly bugs: Schema.optionalKey>; readonly homepage: Schema.optionalKey; readonly dependencies: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly devDependencies: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly peerDependencies: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly optionalDependencies: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly peerDependenciesMeta: Schema.optionalKey; }>>>; readonly scripts: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly bin: Schema.optionalKey, Schema.$Record, never, never>]>>; readonly engines: Schema.optionalKey, Schema.$Record, never, never>>; readonly exports: Schema.optionalKey]>>; readonly publishConfig: Schema.optionalKey>; readonly packageManager: Schema.optionalKey>; readonly devEngines: Schema.optionalKey; readonly runtime: Schema.optionalKey; readonly os: Schema.optionalKey; readonly cpu: Schema.optionalKey; readonly libc: Schema.optionalKey; }>>; readonly rest: Schema.optionalKey>; }>, {}>; /** * A package.json document as a rich `Schema.Class`: typed known fields, a * `rest` catch-all preserving unknown top-level fields across a read/edit/write * cycle, computed getters, and immutable mutation statics. * * @example * ```ts * import { Package } from "@effected/package-json"; * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const pkg = yield* Package.decode({ name: "my-pkg", version: "1.0.0" }); * const next = yield* Package.setVersion(pkg, "1.1.0"); * console.log(next.toJsonString()); * }); * ``` * * @public */ declare class Package extends Package_base { pipe(this: A): A; pipe(this: A, ab: (_: A) => B): B; pipe(this: A, ab: (_: A) => B, bc: (_: B) => C): C; pipe(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; pipe(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E): E; /** * The default wire codec: an open JSON object ↔ a {@link Package} instance, * partitioning unknown keys into `rest` and flattening them back on encode. */ static readonly schema: Schema.Codec; /** * Build the wire codec for a `.extend()`ed subclass, so its custom fields * decode as typed members and are excluded from `rest`. * * @param Class - the extended `Schema.Class`, carrying its own `fields` * @returns a codec between an open JSON object and `Class` instances */ static wireFor(Class: Schema.Codec & { readonly fields: Record; }): Schema.Codec; /** * Decode an unknown JSON value into a {@link Package}, normalizing any * `SchemaError` to a typed {@link PackageDecodeError} at the boundary. * * @param input - the parsed package.json JSON value (e.g. from `JSON.parse`) * @returns an Effect resolving to the decoded `Package` * @throws (typed) `PackageDecodeError` when `input` does not satisfy the schema */ static readonly decode: (input: unknown) => Effect.Effect; /** Whether the package is marked private. */ get isPrivate(): boolean; /** Whether the package name is scoped (`@scope/name`). */ get isScoped(): boolean; /** Whether the package is ESM (`"type": "module"`). */ get isESM(): boolean; /** Whether any dependency map contains `name`. */ hasDependency(name: string): boolean; /** The `dependencies` map as {@link Dependency} instances (`kind: "prod"`). */ getDependencies(): HashMap.HashMap; /** The `devDependencies` map as {@link Dependency} instances (`kind: "dev"`). */ getDevDependencies(): HashMap.HashMap; /** The `peerDependencies` map as {@link Dependency} instances (`kind: "peer"`), carrying `isOptional` from `peerDependenciesMeta`. */ getPeerDependencies(): HashMap.HashMap; /** The `optionalDependencies` map as {@link Dependency} instances (`kind: "optional"`). */ getOptionalDependencies(): HashMap.HashMap; /** Return a new {@link Package} with the given fields replaced. */ copyWith(patch: PackagePatch): Package; /** Set the version from a string. Fails with `InvalidVersionError`. Dual API. */ static readonly setVersion: { (version: string): (pkg: Package) => Effect.Effect; (pkg: Package, version: string): Effect.Effect; }; /** Set the package name. Fails with `InvalidPackageNameError`. Dual API. */ static readonly setName: { (name: string): (pkg: Package) => Effect.Effect; (pkg: Package, name: string): Effect.Effect; }; /** Set the license from an SPDX string. Fails with `InvalidSpdxLicenseError`. Dual API. */ static readonly setLicense: { (license: string): (pkg: Package) => Effect.Effect; (pkg: Package, license: string): Effect.Effect; }; /** Add or replace a `dependencies` entry. Dual API. */ static readonly addDependency: { (name: string, specifier: string): (pkg: Package) => Package; (pkg: Package, name: string, specifier: string): Package; }; /** Remove a `dependencies` entry. Dual API. */ static readonly removeDependency: { (name: string): (pkg: Package) => Package; (pkg: Package, name: string): Package; }; /** Add or replace a `devDependencies` entry. Dual API. */ static readonly addDevDependency: { (name: string, specifier: string): (pkg: Package) => Package; (pkg: Package, name: string, specifier: string): Package; }; /** Remove a `devDependencies` entry. Dual API. */ static readonly removeDevDependency: { (name: string): (pkg: Package) => Package; (pkg: Package, name: string): Package; }; /** Add or replace a `peerDependencies` entry. Dual API. */ static readonly addPeerDependency: { (name: string, specifier: string): (pkg: Package) => Package; (pkg: Package, name: string, specifier: string): Package; }; /** Remove a `peerDependencies` entry. Dual API. */ static readonly removePeerDependency: { (name: string): (pkg: Package) => Package; (pkg: Package, name: string): Package; }; /** Add or replace an `optionalDependencies` entry. Dual API. */ static readonly addOptionalDependency: { (name: string, specifier: string): (pkg: Package) => Package; (pkg: Package, name: string, specifier: string): Package; }; /** Remove an `optionalDependencies` entry. Dual API. */ static readonly removeOptionalDependency: { (name: string): (pkg: Package) => Package; (pkg: Package, name: string): Package; }; /** Add or replace a `scripts` entry. Dual API. */ static readonly setScript: { (name: string, command: string): (pkg: Package) => Package; (pkg: Package, name: string, command: string): Package; }; /** Remove a `scripts` entry. Dual API. */ static readonly removeScript: { (name: string): (pkg: Package) => Package; (pkg: Package, name: string): Package; }; /** * Resolve `catalog:` and `workspace:` specifiers across all four dependency * maps using the `CatalogResolver` and `WorkspaceResolver` from context, * classifying and projecting through `@effected/npm`'s `DependencySpecifier` * statics (`workspace:` uses the pnpm publish-time projection; the alias * form `workspace:@` resolves the TARGET package's version and * becomes the published `npm:@` alias). Specifiers the * resolvers return `None` for are left unchanged — resolution still * succeeds. A `CatalogResolver` whose catalog assembly failed surfaces * typed as `@effected/npm`'s `CatalogAssemblyError`, alongside the * contracts' `DependencyResolutionError`. This is the explicit resolution * step — `PackageJsonFile.write` never resolves. * * @remarks * Leaves unresolvable specifiers unchanged. For fail-typed manifest * resolution over the tolerant model, see `@effected/npm`'s * `Manifest#resolve`. */ static readonly resolve: (pkg: Package) => Effect.Effect; /** * Serialize to a formatted package.json string: encode through the wire * codec (flattening `rest`), then apply the canonical key order, dependency * sorting and empty-map stripping unless the options opt out. Pure. */ toJsonString(options?: PackageFormatOptions): string; } //#endregion //#region src/PackageJsonFormat.d.ts declare const PackageJsonSyntaxError_base: Schema.Class; /** The underlying `SyntaxError` for `"invalid-json"`, preserved structurally. */ readonly cause: Schema.optionalKey; }>, import("effect/Cause").YieldableError>; /** * Indicates that a text input could not be treated as a package.json document: * either it is not valid JSON (`"invalid-json"`, carrying the underlying * `SyntaxError` on `cause`) or it parsed to something other than a JSON object * (`"not-an-object"` — an array, a scalar or `null`). * * Raised by {@link PackageJsonFormat.formatToString}. This is a *syntactic* * failure only; it says nothing about whether the document is a valid package * manifest, which the decode-free path deliberately does not check. * * @public */ declare class PackageJsonSyntaxError extends PackageJsonSyntaxError_base { get message(): string; } /** * Options for {@link PackageJsonFormat.formatToString}. * * Deliberately not `PackageFormatOptions`: there is no `sourceText` member, * because the text being formatted *is* the source text, and the defaults for * `indent` and `stripEmpty` differ — see each member. * * @public */ interface PackageFormatTextOptions { /** * Indentation: a spaces count, `"tab"`, or `"preserve"`. Defaults to * `"preserve"` — unlike `Package.toJsonString`, this path always has the * original text in hand, and reformatting a file in place should not * silently restyle its indentation. */ readonly indent?: number | "tab" | "preserve"; /** Order top-level keys canonically and alphabetize dependency maps (default `true`). */ readonly sort?: boolean; /** * Strip dependency-map keys whose value is an empty object (default * `false`). The strict path defaults this on because the model materializes * absent maps as empty ones; here an empty map is a key the author actually * wrote, and removing it would be a silent edit rather than a format. */ readonly stripEmpty?: boolean; /** Append a trailing newline (default `true`). */ readonly newline?: boolean; } declare const PackageJsonModifyError_base: Schema.Class>; /** The underlying `JsoncModificationError`, preserved structurally. */ readonly cause: Schema.Defect; }>, import("effect/Cause").YieldableError>; /** * Indicates that a surgical modification could not be applied: the value on * the navigation path is not the container kind the next path segment * requires. The underlying `@effected/jsonc` `JsoncModificationError` — * which names the expected container and the 1-based depth of the mismatch — * is preserved on the structured `cause` field, never stringified. * * Raised by {@link PackageJsonFormat.modify} and * {@link PackageJsonFormat.modifyToString}. * * @public */ declare class PackageJsonModifyError extends PackageJsonModifyError_base { get message(): string; } /** * Decode-free canonical sort and format statics. Not instantiable. * * @remarks * The guarantee both statics make is that they are **source-preserving**: * neither decodes into a `Package`, so neither can normalize a field encoding. * String-form `author` shorthand, unknown fields, unusual value shapes and * empty maps all survive untouched, because they are never looked at. Key * order, indentation and the trailing newline are the only things that change. * * That is what makes this usable as a lint-hook handler where the strict path * is not: any syntactically valid JSON object formats, including the * version-less workspace roots and `{"private": true}` manifests that * `Package.decode` rejects. Reach for `Package.decode` + * `Package.toJsonString` instead when the job needs the validated model and an * invalid manifest should fail loudly. * * @public */ declare class PackageJsonFormat { private constructor(); /** * Order a package.json object's keys canonically **without decoding it into * a `Package`**: known top-level keys in `sort-package-json`'s order, then * unknown public keys alphabetically, then `_`-prefixed keys, with the * dependency maps and `scripts` / `engines` / `bin` alphabetized. * * Value in, value out — for hosts that already hold parsed JSON and never * want a string. {@link PackageJsonFormat.formatToString} is the same * ordering for hosts holding file text. Pure and total. * * Returns a new object; nested values are shared by reference rather than * cloned, except the maps whose own keys are reordered. A value that is not * a JSON object (an array, a scalar, `null`) is returned unchanged rather * than mangled, so a mistyped `Json` union cannot silently lose data. * * Reordering keys is the whole of it — **no key is ever added or removed**, * which is what lets the return type be the input type `T` and makes this a * drop-in. Use {@link PackageJsonFormat.formatToString} with `stripEmpty` * when removing empty maps is wanted; it returns a string and so carries no * such obligation. * * @param value - the parsed package.json object * @returns a new object with canonically ordered keys * * @example * ```ts * import { PackageJsonFormat } from "@effected/package-json"; * * const sorted = PackageJsonFormat.sortValue({ version: "1.0.0", name: "p" }); * // => { name: "p", version: "1.0.0" } * ``` */ static sortValue(value: T): T; /** * Sort and format package.json text **without decoding it into a * `Package`**. Text in, text out — for hosts that hold file contents and * cannot afford a decode. {@link PackageJsonFormat.sortValue} is the same * ordering for hosts that already hold parsed JSON. * * Any syntactically valid JSON object formats, whatever it contains: a * version-less root, `{"private": true}`, a malformed `packageManager` * integrity. Nothing is decoded, so nothing is normalized — string-form * `author` shorthand, unknown fields, unusual value shapes and empty maps * all survive byte-for-byte. Only key order, indentation and the trailing * newline change. * * Pure and synchronous: it returns a `Result` rather than an `Effect`, so * synchronous hosts can call it directly. Lift it with `Effect.fromResult`. * * @param source - the package.json file contents * @param options - formatting options; see {@link PackageFormatTextOptions} * @returns the formatted text, or a {@link PackageJsonSyntaxError} * * @example * ```ts * import { PackageJsonFormat } from "@effected/package-json"; * import { Effect, Result } from "effect"; * * const formatted = PackageJsonFormat.formatToString('{"private": true}'); * if (Result.isSuccess(formatted)) console.log(formatted.success); * * // In an Effect program: * const program = Effect.fromResult(PackageJsonFormat.formatToString('{"private": true}')); * ``` */ static formatToString(source: string, options?: PackageFormatTextOptions): Result.Result; /** * Compute the surgical edits that set, replace or delete the value at * `path` **without decoding, sorting or reformatting anything else**. The * opposite posture to {@link PackageJsonFormat.formatToString}: where the * formatter's job is the canonical order, the mutator's job is to leave * every untouched byte untouched — key order, indentation, line endings and * the trailing newline all survive, because only the edited span changes. * That is what makes the result reviewable when a tool commits a one-field * change to someone else's repository. * * Built on `@effected/jsonc`'s scanner-based edit engine. Inserted content * matches the source's own style: indentation (tab vs N spaces) is detected * from the first indented line and the line ending from the first `\r\n`. * * Passing `value === undefined` deletes the target key (including its * comma) — the `@effected/jsonc` / `@effected/yaml` modify convention. A * missing insertion target appends after the last key of its container. * * @param source - the package.json file contents (strict JSON — npm does * not accept comments, and neither does this) * @param path - the field path, e.g. `["packageManager"]` or * `["devEngines", "runtime", "version"]` * @param value - the plain JSON value to write, or `undefined` to delete * @returns the edits to apply via `JsoncEdit.applyAll` — or use * {@link PackageJsonFormat.modifyToString} for the applied text in one step */ static readonly modify: (source: string, path: JsoncPath$1, value: unknown) => Effect.Effect; /** * Modify `source` and apply the resulting edits in one step * (`JsoncEdit.applyAll` composed over {@link PackageJsonFormat.modify}). * Text in, text out; every byte outside the edited span is preserved. * Inherits the modify error channel: {@link PackageJsonSyntaxError} when * the source is not a JSON object, {@link PackageJsonModifyError} when the * path cannot be navigated. * * @example * ```ts * import { PackageJsonFormat } from "@effected/package-json"; * import { Effect } from "effect"; * * const program = PackageJsonFormat.modifyToString( * '{\n "private": true,\n "packageManager": "pnpm@11.2.0"\n}\n', * ["packageManager"], * "pnpm@11.3.0", * ); // only the packageManager value changes; every other byte survives * ``` */ static readonly modifyToString: (source: string, path: JsoncPath$1, value: unknown) => Effect.Effect; } //#endregion //#region src/LenientManifest.d.ts /** * One degraded field from a lenient decode: the top-level `field` that did not * match its permissive shape, a human-readable description of the `expected` * shape, and the raw `value` found there (also preserved verbatim under * `LenientManifest.rest[field]`). * * A value, not an error — the decode still succeeds; issues exist so callers * can report what degraded. * * @public */ interface LenientFieldIssue { /** The top-level field name that degraded, e.g. `"name"`. */ readonly field: string; /** A human-readable description of the permissive shape the field required. */ readonly expected: string; /** The raw value found on the wire, preserved for reporting. */ readonly value: unknown; } declare const LenientManifest_base: Schema.Class; readonly version: Schema.optionalKey; readonly description: Schema.optionalKey; readonly private: Schema.optionalKey; readonly type: Schema.optionalKey; readonly main: Schema.optionalKey; readonly license: Schema.optionalKey; readonly author: Schema.optionalKey]>>; readonly contributors: Schema.optionalKey]>>>; readonly maintainers: Schema.optionalKey]>>>; readonly keywords: Schema.optionalKey>; readonly repository: Schema.optionalKey]>>; readonly bugs: Schema.optionalKey]>>; readonly homepage: Schema.optionalKey; readonly dependencies: Schema.optionalKey>; readonly devDependencies: Schema.optionalKey>; readonly peerDependencies: Schema.optionalKey>; readonly optionalDependencies: Schema.optionalKey>; readonly peerDependenciesMeta: Schema.optionalKey>; readonly scripts: Schema.optionalKey>; readonly bin: Schema.optionalKey]>>; readonly engines: Schema.optionalKey>; readonly exports: Schema.optionalKey]>>; readonly publishConfig: Schema.optionalKey>; readonly packageManager: Schema.optionalKey; readonly devEngines: Schema.optionalKey>; /** * Unknown top-level keys, plus every degraded known field's raw value, * verbatim. Always present after a lenient decode (possibly empty). */ readonly rest: Schema.optionalKey>; /** The degradations collected by the decode — empty when nothing degraded. */ readonly issues: Schema.$Array>; }>, {}>; /** * The shape-lenient view of a package.json document, for discovery and * sniffing — probing a fetched tarball's manifest, walking a `node_modules` * tree, listing candidate packages — where the document is other people's * data and one malformed field must not fail the read. * * @remarks * **This is the discovery tier, not a validation bypass.** Every field shares * its name with the strict `Package` model, but is typed as its plain permissive JSON * shape: `name` and `version` are any string (a legacy uppercase name or a * non-semver `"1.0"` is recovered, not rejected), `license` is any string (no * SPDX check), the dependency maps and `scripts` are plain string→string * records rather than `HashMap`s. A present field that is not even that shape * **degrades to absence** rather than failing the document: the raw value is * preserved verbatim in `rest` and the degradation is reported on `issues`, * so callers can surface what was ignored. Degradation granularity is the * top-level field — one junk entry degrades its whole map, with the raw map * still in `rest`. * * Leniency is per-field, never per-syntax: text that is not valid JSON fails * {@link LenientManifest.parseResult} as a typed * {@link PackageJsonSyntaxError}, and a value that is not a JSON object fails * {@link LenientManifest.decodeResult} as a typed {@link PackageDecodeError}. * * An empty `issues` array does **not** mean the strict tiers would accept the * document — the permissive shapes check JSON shape, not npm semantics. The * upgrade path is to decode the *original* input through * `PackageManifest.decode` (presence-lenient, shape-strict) or * `Package.decode` (strict, publishable) when validation is actually * wanted. This class deliberately carries no mutation statics and no write * path; editing belongs to the strict tiers and to * `PackageJsonFormat.modifyToString` / `PackageJsonFile.modify`. * * @example * ```ts * import { LenientManifest } from "@effected/package-json"; * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const sniffed = yield* LenientManifest.decode({ name: "JSONStream", version: "1.0", license: 42 }); * console.log(sniffed.name, sniffed.version); // "JSONStream" "1.0" * console.log(sniffed.issues); // [{ field: "license", expected: "a string", value: 42 }] * console.log(sniffed.rest?.license); // 42 — degraded, preserved verbatim * }); * ``` * * @public */ declare class LenientManifest extends LenientManifest_base { /** * Decode an unknown JSON value leniently, degrading malformed fields instead * of failing the document. The sync primitive backing * {@link LenientManifest.decode}. * * @param input - the parsed package.json JSON value (e.g. from `JSON.parse`) * @returns the lenient manifest, or a {@link PackageDecodeError} when * `input` is not a JSON object at all (`null`, an array or a scalar) — the * one failure leniency does not cover */ static decodeResult(input: unknown): Result.Result; /** * Decode an unknown JSON value leniently, degrading malformed fields instead * of failing the document. The `Effect` form of * {@link LenientManifest.decodeResult}, adding the tracing span. * * @param input - the parsed package.json JSON value (e.g. from `JSON.parse`) * @returns an Effect resolving to the decoded {@link LenientManifest} * @throws (typed) `PackageDecodeError` when `input` is not a JSON object */ static readonly decode: (input: unknown) => Effect.Effect; /** * Parse package.json text and decode it leniently. The sync primitive * backing {@link LenientManifest.parse}. * * @param text - the package.json source text * @returns the lenient manifest, or a {@link PackageJsonSyntaxError} when * the text is not valid JSON (`"invalid-json"`) or parses to something * other than a JSON object (`"not-an-object"`) — leniency is per-field, * never per-syntax */ static parseResult(text: string): Result.Result; /** * Parse package.json text and decode it leniently. The `Effect` form of * {@link LenientManifest.parseResult}, adding the tracing span. * * @param text - the package.json source text * @returns an Effect resolving to the decoded {@link LenientManifest} * @throws (typed) `PackageJsonSyntaxError` when the text is not valid JSON * or is not a JSON object */ static readonly parse: (text: string) => Effect.Effect; /** Whether the manifest is marked private. */ get isPrivate(): boolean; /** Whether the manifest declares ESM (`"type": "module"`, exact comparison). */ get isESM(): boolean; } //#endregion //#region src/PackageManagerRange.d.ts declare const PackageManagerRange_base: Schema.Class=10 <12`, ...) or an exact version (`11.2.0`). Validated to parse * through `@effected/semver`'s `Range.parseResult`; never normalized, so * the field round-trips byte-identically. */ readonly range: Schema.String; /** * The optional integrity hash (e.g. `sha512.abc`): `@effected/npm`'s * `CorepackIntegrityHash`. Meaningful only alongside an exact range — * an integrity pins one artifact — but carried whenever the manifest * carries it, because fidelity outranks plausibility in a field model. */ readonly integrity: Schema.Option & { FromSri: Schema.Codec; fromSri: (input: string) => Effect.Effect; }>; }>, {}>; /** * A structured `packageManager` value whose version position is a semver * **range**, carried verbatim: `name`, `range` and an optional `integrity` * hash. * * @remarks * The range-tolerant sibling of {@link PackageManager}. The strict class * models the corepack pin — an exact version, which is all corepack itself * accepts — and stays strict; this class models the field as pnpm reads it, * where a range such as `^11.20.0` is a supported spelling that pnpm resolves * to a concrete version. An exact version is a valid range, so every string * the strict codec accepts decodes here too; {@link PackageManagerRange.isExact} * is how a caller tracks which form the manifest actually carried. * * The `range` field is the manifest's text **verbatim** — validated to parse * as a semver range but never normalized, so encoding is byte-identical to * the accepted input and reading a manifest never rewrites the field. * Interpretation is a derived getter, following `Repository`'s * carry-verbatim posture. * * The first `+` after the `@` begins the integrity component, exactly as in * the strict grammar — the version position of this field never carries * semver build metadata. * * @example * ```ts * import { PackageManagerRange } from "@effected/package-json"; * import { Effect, Schema } from "effect"; * * const program = Effect.gen(function* () { * const pm = yield* Schema.decodeUnknownEffect(PackageManagerRange.FromString)("pnpm@^11.20.0"); * console.log(pm.name, pm.range, pm.isExact); // "pnpm" "^11.20.0" false * }); * ``` * * @public */ declare class PackageManagerRange extends PackageManagerRange_base { /** * Schema transformation between the `"name@range[+integrity]"` string and a * {@link PackageManagerRange}. * * @remarks * Decoding splits on the first `@`, then on the first `+` — which always * begins the integrity, never semver build metadata — and validates each * component: the name against the lowercase grammar, the range through * `@effected/semver`'s `Range.parseResult`, the integrity through * `CorepackIntegrityHash`. Every failure is a typed decode failure naming * the component that failed. Encoding reconstructs the string from the * verbatim parts, so it is byte-identical to any input this codec accepts. */ static readonly FromString: Schema.Codec; /** * Whether the range is an exact, pinnable version (`11.2.0`) rather than a * genuine range (`^11.20.0`) — decided by `SemVer.isPinnable` over the * verbatim text, so `=11.2.0` and other range spellings of a single * version report `false`. This is the exactness a consumer tracks when it * must re-emit the same spelling it read. */ get isExact(): boolean; /** Whether an integrity hash is present. */ get hasIntegrity(): boolean; } //#endregion //#region src/PackageManifest.d.ts declare const PackageManifest_base: Schema.Class; readonly private: Schema.optionalKey; readonly type: Schema.optionalKey>; readonly main: Schema.optionalKey; readonly license: Schema.optionalKey>; readonly author: Schema.optionalKey>; readonly contributors: Schema.optionalKey>>; readonly maintainers: Schema.optionalKey>>; readonly keywords: Schema.optionalKey>; readonly repository: Schema.optionalKey>; readonly bugs: Schema.optionalKey>; readonly homepage: Schema.optionalKey; readonly dependencies: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly devDependencies: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly peerDependencies: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly optionalDependencies: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly peerDependenciesMeta: Schema.optionalKey; }>>>; readonly scripts: Schema.decodeTo, Schema.withDecodingDefaultKey, never>, never, never>; readonly bin: Schema.optionalKey, Schema.$Record, never, never>]>>; readonly engines: Schema.optionalKey, Schema.$Record, never, never>>; readonly exports: Schema.optionalKey]>>; readonly publishConfig: Schema.optionalKey>; readonly devEngines: Schema.optionalKey; readonly runtime: Schema.optionalKey; readonly os: Schema.optionalKey; readonly cpu: Schema.optionalKey; readonly libc: Schema.optionalKey; }>>; readonly rest: Schema.optionalKey>; readonly name: Schema.optionalKey, Schema.brand]> & { isValid: (name: string) => boolean; scope: (name: string) => import("effect/Option").Option; unscoped: (name: string) => string; isScoped: (name: string) => boolean; }>; readonly version: Schema.optionalKey>; readonly packageManager: Schema.optionalKey>; }>, {}>; /** * A package.json document as it exists on disk, publishable or not: every * field of {@link Package} with `name` and `version` optional and * `packageManager` accepting the range spelling. * * @remarks * **Lenient about absence, strict about shape.** npm requires `name` and * `version` only for a package that will be published; the idiomatic private * workspace root (`{ "private": true, "packageManager": "pnpm@11.2.0" }`) * carries neither, and {@link Package.decode} rightly rejects it — the strict * model's contract is publishability. This class decodes that shape, and any * other manifest, so long as every field that IS present satisfies its typed * codec: a present `version` must still be strict semver (`"1.0"` fails * typed), a present `name` must still satisfy the npm grammar, a present * `packageManager` must still parse — though here the version position may be * a semver range (`pnpm@^11.20.0`), decoded as {@link PackageManagerRange}. * For tolerance of malformed fields, use the shape-lenient `LenientManifest` * discovery tier — which degrades them to absence, preserved in `rest` and * reported on `issues` — or the decode-free {@link PackageJsonFormat} text * path (or `@effected/npm`'s shape-blind `Manifest`); here, silently carrying * a value the type claims to have validated would be a lie, and silently * dropping it would break round-trip fidelity. * * The model is deliberately lean — fields, the `rest` catch-all wire codec, * {@link PackageManifest.decode} and {@link PackageManifest.toJsonString} — * because the write half of a manifest-editing tool is the surgical * {@link PackageJsonFormat.modifyToString} / `PackageJsonFile.modify` path, * which never goes through a model at all. Mutation statics live on the * strict {@link Package}. * * @example * ```ts * import { PackageManifest } from "@effected/package-json"; * import { Effect, Option } from "effect"; * * const program = Effect.gen(function* () { * const root = yield* PackageManifest.decode({ private: true, packageManager: "pnpm@^11.20.0" }); * console.log(root.isPrivate, root.packageManager?.isExact); // true false * }); * ``` * * @public */ declare class PackageManifest extends PackageManifest_base { /** * The wire codec: an open JSON object ↔ a {@link PackageManifest} instance, * partitioning unknown keys into `rest` and flattening them back on encode — * the same transform {@link Package.schema} uses, over this class's fields. */ static readonly schema: Schema.Codec; /** * Decode an unknown JSON value into a {@link PackageManifest}, normalizing * any `SchemaError` to a typed {@link PackageDecodeError} at the boundary. * * @param input - the parsed package.json JSON value (e.g. from `JSON.parse`) * @returns an Effect resolving to the decoded `PackageManifest` * @throws (typed) `PackageDecodeError` when a present field does not satisfy * its codec */ static readonly decode: (input: unknown) => Effect.Effect; /** Whether the manifest is marked private. */ get isPrivate(): boolean; /** * Serialize to a formatted package.json string: encode through the wire * codec (flattening `rest`), then apply the canonical key order, dependency * sorting and empty-map stripping unless the options opt out. Pure, and * shared with `Package.toJsonString` down to the same internal renderer. * Absent `name` / `version` keys stay absent — nothing is invented. */ toJsonString(options?: PackageFormatOptions): string; } //#endregion //#region src/PackageJsonFile.d.ts declare const PackageJsonReadError_base: Schema.Class, import("effect/Cause").YieldableError>; /** * Indicates that a package.json file could not be read from the filesystem * (a filesystem error other than not-found). * * @public */ declare class PackageJsonReadError extends PackageJsonReadError_base { get message(): string; } declare const PackageJsonNotFoundError_base: Schema.Class, import("effect/Cause").YieldableError>; /** * Indicates that no package.json file exists at the expected path. Carries its * own tag for `catchTag` routing. * * @public */ declare class PackageJsonNotFoundError extends PackageJsonNotFoundError_base { get message(): string; } declare const PackageJsonParseError_base: Schema.Class, import("effect/Cause").YieldableError>; /** * Indicates that a package.json file's contents are not valid JSON. * * @public */ declare class PackageJsonParseError extends PackageJsonParseError_base { get message(): string; } declare const PackageJsonWriteError_base: Schema.Class, import("effect/Cause").YieldableError>; /** * Indicates that a package.json file could not be written to the filesystem. * Narrowed to the filesystem-write failure only — never a resolution or encode * error. * * @public */ declare class PackageJsonWriteError extends PackageJsonWriteError_base { get message(): string; } /** * One surgical field edit for {@link PackageJsonFile}'s `modify`: set `value` * at `path`, or delete the key there when `value` is `undefined` (the * `@effected/jsonc` / `@effected/yaml` modify convention — deletion is spelled * with an explicit `value: undefined`, so it is always deliberate). * * @public */ interface PackageFieldEdit { /** The field path, e.g. `["packageManager"]` or `["devEngines", "runtime", "version"]`. */ readonly path: JsoncPath$1; /** The plain JSON value to write, or `undefined` to delete the target key. */ readonly value: unknown; } /** * The shape of the {@link PackageJsonFile} service — the value produced by * {@link PackageJsonFile.make} and carried by its layer. * * @public */ interface PackageJsonFileShape { /** * Read and decode a package.json file. Fails with `PackageJsonNotFoundError` * (ENOENT), `PackageJsonReadError` (other fs errors), `PackageJsonParseError` * (invalid JSON) or `PackageDecodeError` (schema decode). */ readonly read: (path: string) => Effect.Effect; /** * Serialize and write a package.json file. Fails with * `PackageJsonWriteError`. With `indent: "preserve"` and no explicit * `sourceText`, the existing file at `path` (when readable) supplies the * source text whose indentation is preserved. */ readonly write: (path: string, pkg: Package, options?: PackageFormatOptions) => Effect.Effect; /** * Read and decode a package.json file through the presence-lenient * {@link PackageManifest} — the read that accepts the private * workspace-root shape (`{ "private": true, "packageManager": ... }`) * `read` rejects. Same error channel as `read`; a present field that does * not satisfy its codec still fails as `PackageDecodeError`. */ readonly readManifest: (path: string) => Effect.Effect; /** * Serialize and write a {@link PackageManifest}. Fails with * `PackageJsonWriteError`. Shares `write`'s `indent: "preserve"` behavior: * with no explicit `sourceText`, the existing file at `path` (when * readable) supplies the source text whose indentation is preserved. */ readonly writeManifest: (path: string, manifest: PackageManifest, options?: PackageFormatOptions) => Effect.Effect; /** * Apply surgical field edits to a package.json file **without decoding * it**: one read, each {@link PackageFieldEdit} applied in order through * `PackageJsonFormat.modifyToString`, one write — skipped when the result * is byte-identical to what was read. Every byte outside the edited spans * is preserved (key order, indentation, line endings, trailing newline), * which is what keeps a one-field change reviewable in someone else's * repository. Succeeds with the file's final text. * * Invalid JSON at `path` fails as `PackageJsonParseError` — the same tag * `read` uses for it — and an unnavigable edit path as * `PackageJsonModifyError`. */ readonly modify: (path: string, edits: ReadonlyArray) => Effect.Effect; } declare const PackageJsonFile_base: Context.ServiceClass; /** * Reads and writes package.json over core `FileSystem` / `Path`. The layer * requires those services; provide `@effect/platform-node`'s `NodeFileSystem` / * `NodePath` (or a bun equivalent) at the application boundary. * * @example * ```ts * import { PackageJsonFile } from "@effected/package-json"; * import { NodeFileSystem, NodePath } from "@effect/platform-node"; * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const files = yield* PackageJsonFile; * const pkg = yield* files.read("./package.json"); * console.log(pkg.name); * }).pipe(Effect.provide(PackageJsonFile.layer), Effect.provide(NodeFileSystem.layer), Effect.provide(NodePath.layer)); * ``` * * @public */ declare class PackageJsonFile extends PackageJsonFile_base { /** Build the service implementation from `FileSystem` / `Path` in context; use {@link PackageJsonFile.layer} to provide it. */ static readonly make: Effect.Effect; /** * The live layer. Requires core `FileSystem` / `Path`, provided by the * consumer's platform implementation at the edge. */ static readonly layer: Layer.Layer; } //#endregion //#region src/PackageValidator.d.ts /** * A single validation-rule failure. * * @public */ interface RuleFailure { /** A human-readable description of the failure. */ readonly message: string; /** The JSON path where the failure occurred; `Option.none()` when not applicable. */ readonly path: Option.Option; } /** * A single validation rule: a name and a check that fails with a * {@link RuleFailure}. * * @public */ interface ValidationRule { /** The rule identifier (e.g. `has-license`). */ readonly name: string; /** The check — succeeds or fails with a {@link RuleFailure}. */ readonly validate: (pkg: Package) => Effect.Effect; } declare const PackageValidationError_base: Schema.Class; }>>; }>, import("effect/Cause").YieldableError>; /** * Indicates that a {@link Package} failed one or more validation rules. * * Raised by {@link PackageValidator}. Every rule failure is aggregated on * `failures`; the `message` getter renders a multi-line report. * * @public */ declare class PackageValidationError extends PackageValidationError_base { get message(): string; } /** * A rule that fails when any dependency uses an unresolved `workspace:` or * `catalog:` specifier. * * @public */ declare const noUnresolvedDepsRule: ValidationRule; /** * A rule that fails when any dependency uses a local `file:`, `link:` or * `portal:` specifier. * * @public */ declare const noLocalDepsRule: ValidationRule; /** * The default validation rules: license, description, repository and * not-private. * * @public */ declare const defaultRules: ReadonlyArray; declare const PackageValidator_base: Context.ServiceClass Effect.Effect; }>; /** * Validates a {@link Package} against a set of {@link ValidationRule}s, * aggregating every failure into one {@link PackageValidationError}. * * @example * ```ts * import { Package, PackageValidator } from "@effected/package-json"; * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const pkg = yield* Package.decode({ name: "my-pkg", version: "1.0.0" }); * const validator = yield* PackageValidator; * yield* validator.validate(pkg); * }).pipe(Effect.provide(PackageValidator.layer)); * ``` * * @public */ declare class PackageValidator extends PackageValidator_base { /** The default layer, backed by {@link defaultRules}. */ static readonly layer: Layer.Layer; /** * Build a layer from a custom set of rules (a genuinely-parameterized factory). * * @param config - the rule set to validate against, replacing {@link defaultRules} * @returns a layer providing `PackageValidator` backed by `config.rules` */ static layerRules(config: { readonly rules: ReadonlyArray; }): Layer.Layer; } //#endregion export { BinField, Bugs, Dependency, type DependencyKind, DependencyMapField, type DependencyProtocol, DependencySpecifier, type DependencySpecifierBrand, DevEngine, DevEngineOrArray, type DevEngines, DevEnginesSchema, type EntryPointManifest, ExportsField, InvalidDependencySpecifierError, InvalidPackageNameError, InvalidSpdxLicenseError, JsoncEdit, type JsoncPath, type LenientFieldIssue, LenientManifest, Package, PackageDecodeError, type PackageFieldEdit, type PackageFormatOptions, type PackageFormatTextOptions, type PackageIndent, PackageJsonFile, type PackageJsonFileShape, PackageJsonFormat, PackageJsonModifyError, PackageJsonNotFoundError, PackageJsonParseError, PackageJsonReadError, PackageJsonSyntaxError, PackageJsonWriteError, PackageManager, PackageManagerRange, PackageManifest, PackageName, type PackagePatch, PackageValidationError, PackageValidator, PeerDependenciesMetaField, Person, PublishConfigField, Repository, RepositoryField, type ResolveEntryPointOptions, type RuleFailure, ScopedPackageName, SpdxLicense, StringMapField, type UnresolvedDependency, UnresolvedEntryPointError, UnscopedPackageName, type ValidationRule, defaultRules, isUnresolvedDependency, isValidDependencySpecifier, isValidSpdx, noLocalDepsRule, noUnresolvedDepsRule, resolveEntryPoint }; //# sourceMappingURL=index.d.ts.map