@pnpm/resolving.resolver-base 1100.1.3 → 1100.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.d.ts +114 -1
  2. package/package.json +3 -3
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DependencyManifest, PackageVersionPolicy, PinnedVersion, PkgResolutionId, ProjectRootDir, SupportedArchitectures, TrustPolicy } from '@pnpm/types';
1
+ import type { DependencyManifest, PackageManifest, PackageVersionPolicy, PinnedVersion, PkgResolutionId, ProjectRootDir, SupportedArchitectures, TrustPolicy } from '@pnpm/types';
2
2
  export { type PkgResolutionId };
3
3
  /**
4
4
  * tarball hosted remotely
@@ -57,6 +57,77 @@ export interface VariationsResolution {
57
57
  variants: PlatformAssetResolution[];
58
58
  }
59
59
  export type Resolution = AtomicResolution | VariationsResolution;
60
+ /**
61
+ * Outcome of asking a `ResolutionVerifier` whether a (name, version,
62
+ * resolution) entry from a lockfile is acceptable under whatever policies
63
+ * the resolver chain has been configured with. Resolvers that don't have
64
+ * an opinion on a given resolution should return `{ ok: true }`.
65
+ */
66
+ export type ResolutionVerification = {
67
+ ok: true;
68
+ } | {
69
+ ok: false;
70
+ code: string;
71
+ reason: string;
72
+ };
73
+ /**
74
+ * Optional companion to a resolver factory.
75
+ *
76
+ * `verify` inspects the `resolution` shape to decide whether the entry
77
+ * is within its protocol; for entries outside its protocol it should
78
+ * return `{ ok: true }`. The install side fans out across the verifier
79
+ * list rather than asking a combinator to dispatch.
80
+ *
81
+ * `policy` and `canTrustPastCheck` describe the verifier's cache
82
+ * contract. Policies from every active verifier are merged into a
83
+ * single shared bag stored alongside the lockfile hash; the
84
+ * install-side verification cache reads them to decide if a previous
85
+ * run on the same lockfile is still trustworthy under today's policy
86
+ * without re-issuing the registry round-trips that `verify` would.
87
+ * Verifiers that check the same logical policy (e.g. minimumReleaseAge
88
+ * across registries) name it the same and share the cache slot.
89
+ */
90
+ export interface ResolutionVerifier {
91
+ verify: (resolution: Resolution, ctx: {
92
+ name: string;
93
+ version: string;
94
+ }) => Promise<ResolutionVerification>;
95
+ /**
96
+ * Snapshot of the policy fields this verifier enforces. Merged with
97
+ * every other active verifier's `policy` into the cache record. A
98
+ * field shared across verifiers (same key) should carry the same
99
+ * value; if it doesn't, the last verifier in the list wins.
100
+ */
101
+ policy: Record<string, unknown>;
102
+ /**
103
+ * Returns true when the previously cached policy (the merged snapshot
104
+ * from the last successful run) can be trusted to still satisfy what
105
+ * this verifier currently demands. Reads whichever fields the
106
+ * verifier owns; missing or non-conforming values (e.g. an older
107
+ * record shape) should return false. A loosened policy can trust a
108
+ * stricter cached run; a tightened policy cannot.
109
+ */
110
+ canTrustPastCheck: (cachedPolicy: Record<string, unknown>) => boolean;
111
+ }
112
+ /**
113
+ * A `ResolutionVerifier`'s rejection materialized for one (name,
114
+ * version, resolution) entry. The install side aggregates these across
115
+ * every active verifier on the freshly-resolved tree and either prompts
116
+ * the user, persists them (e.g. into `minimumReleaseAgeExclude`), or
117
+ * aborts. Code is the verifier-defined error code
118
+ * (`MINIMUM_RELEASE_AGE_VIOLATION`, `TRUST_DOWNGRADE`, etc.) — the
119
+ * install command filters by code to decide downstream UX. Lifted here
120
+ * (rather than in deps-installer) so both deps-resolver and
121
+ * deps-installer can share one shape; future resolver packages plug in
122
+ * without needing the deps-installer dependency.
123
+ */
124
+ export interface ResolutionPolicyViolation {
125
+ name: string;
126
+ version: string;
127
+ resolution: Resolution;
128
+ code: string;
129
+ reason: string;
130
+ }
60
131
  /** Concrete platform selector used when picking a variant from a VariationsResolution. */
61
132
  export interface PlatformSelector {
62
133
  os: string;
@@ -94,6 +165,22 @@ export interface ResolveResult {
94
165
  resolvedVia: string;
95
166
  normalizedBareSpecifier?: string;
96
167
  alias?: string;
168
+ /**
169
+ * Set when the resolver picked this version despite a policy
170
+ * violation (e.g. immature relative to `publishedBy`, trust
171
+ * downgrade detected by `failIfTrustDowngraded`). The resolver
172
+ * already has the metadata it needs to decide, so reporting inline
173
+ * here avoids the install layer having to re-scan the tree and
174
+ * re-fetch the same metadata. The deps-resolver aggregates these
175
+ * across every resolve call into a single set the install command
176
+ * can react to.
177
+ *
178
+ * `resolution` on the violation is the same `resolution` field
179
+ * above — supplied for symmetry with `ResolutionPolicyViolation`
180
+ * entries that flow out of `verifyLockfileResolutions` for
181
+ * lockfile-only paths.
182
+ */
183
+ policyViolation?: ResolutionPolicyViolation;
97
184
  }
98
185
  export interface WorkspacePackage {
99
186
  rootDir: ProjectRootDir;
@@ -137,6 +224,7 @@ export interface ResolveOptions {
137
224
  name?: string;
138
225
  version?: string;
139
226
  resolution: Resolution;
227
+ publishedAt?: string;
140
228
  };
141
229
  }
142
230
  export type WantedDependency = {
@@ -152,3 +240,28 @@ export type WantedDependency = {
152
240
  export type ResolveFunction = (wantedDependency: WantedDependency & {
153
241
  optional?: boolean;
154
242
  }, opts: ResolveOptions) => Promise<ResolveResult>;
243
+ /**
244
+ * Input to a resolver's `resolveLatest` function. The resolver decides
245
+ * whether it owns this dep purely from `wantedDependency` (its alias and
246
+ * manifest specifier) — the lockfile-resolved ref is the caller's
247
+ * concern, not the resolver's.
248
+ */
249
+ export interface LatestQuery {
250
+ wantedDependency: WantedDependency;
251
+ compatible?: boolean;
252
+ }
253
+ /**
254
+ * Result of a resolver's `resolveLatest` call.
255
+ *
256
+ * - `undefined` means "this resolver does not handle this dep — try
257
+ * the next one".
258
+ * - An object (even without a `latestManifest`) means "I claim this
259
+ * dep, but I can't tell you what's latest" (e.g. policy blocked,
260
+ * network unavailable, no concept of latest for this protocol).
261
+ * The caller still surfaces a ref-mismatch report if the lockfile
262
+ * shifted.
263
+ */
264
+ export interface LatestInfo {
265
+ latestManifest?: PackageManifest;
266
+ }
267
+ export type ResolveLatestFunction = (query: LatestQuery, opts: ResolveOptions) => Promise<LatestInfo | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/resolving.resolver-base",
3
- "version": "1100.1.3",
3
+ "version": "1100.3.0",
4
4
  "description": "Types for pnpm-compatible resolvers",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -25,10 +25,10 @@
25
25
  "!*.map"
26
26
  ],
27
27
  "dependencies": {
28
- "@pnpm/types": "1101.1.0"
28
+ "@pnpm/types": "1101.1.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@pnpm/resolving.resolver-base": "1100.1.3"
31
+ "@pnpm/resolving.resolver-base": "1100.3.0"
32
32
  },
33
33
  "engines": {
34
34
  "node": ">=22.13"