@effected/package-json 0.10.1 → 0.11.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.
- package/EntryPoint.js +156 -0
- package/README.md +28 -0
- package/index.d.ts +127 -3
- package/index.js +2 -1
- package/package.json +2 -2
- package/tsdoc-metadata.json +1 -1
package/EntryPoint.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Result, Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/EntryPoint.ts
|
|
4
|
+
/**
|
|
5
|
+
* Raised when a manifest resolves no root entry point.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The reason is discriminated rather than a bare "not found" because the three
|
|
9
|
+
* shapes call for different responses, and a caller staring at a consumer's
|
|
10
|
+
* plugin at 3am needs to know which one it hit. Collapsing them into one
|
|
11
|
+
* sentinel is the same class of quiet wrong answer as an untyped error channel.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
var UnresolvedEntryPointError = class extends Schema.TaggedError()("UnresolvedEntryPointError", {
|
|
16
|
+
/**
|
|
17
|
+
* `noRootExport` — `exports` is a subpath map with no `"."` entry, so the
|
|
18
|
+
* package exports subpaths but no root. `noConditionMatched` — a root
|
|
19
|
+
* entry exists but none of the requested conditions are present, e.g. a
|
|
20
|
+
* `require`-only package read with `["import"]`.
|
|
21
|
+
* `unsupportedExportsForm` — an array fallback list, or another shape this
|
|
22
|
+
* resolver does not implement.
|
|
23
|
+
*/
|
|
24
|
+
reason: Schema.Literals([
|
|
25
|
+
"noRootExport",
|
|
26
|
+
"noConditionMatched",
|
|
27
|
+
"unsupportedExportsForm"
|
|
28
|
+
]),
|
|
29
|
+
/** The conditions that were tried, for `noConditionMatched`. */
|
|
30
|
+
conditions: Schema.optionalKey(Schema.Array(Schema.String))
|
|
31
|
+
}) {
|
|
32
|
+
get message() {
|
|
33
|
+
switch (this.reason) {
|
|
34
|
+
case "noRootExport": return "The manifest's \"exports\" declares subpaths but no \".\" entry, so it has no root entry point";
|
|
35
|
+
case "noConditionMatched": return `The manifest's "exports" matched none of the conditions ${JSON.stringify(this.conditions ?? [])}`;
|
|
36
|
+
default: return "The manifest's \"exports\" uses a form this resolver does not implement";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const DEFAULT_CONDITIONS = ["import", "default"];
|
|
41
|
+
/** A plain object — not an array, not `null`. */
|
|
42
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43
|
+
/**
|
|
44
|
+
* Is this `exports` object a conditions map rather than a subpath map?
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Node's rule: the two forms cannot be mixed, and a subpath map is identified
|
|
48
|
+
* by keys starting with `"."`. So an object with no `"."`-prefixed key is
|
|
49
|
+
* conditions-only sugar for the `"."` subpath. An empty object is neither — it
|
|
50
|
+
* exports nothing.
|
|
51
|
+
*/
|
|
52
|
+
const isRootConditions = (exportsObject) => {
|
|
53
|
+
const keys = Object.keys(exportsObject);
|
|
54
|
+
return keys.length > 0 && !keys.some((key) => key.startsWith("."));
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a conditions object to a file, honouring `conditions` in order.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Recurses, because conditions nest: `{ "import": { "node": "./n.js" } }` is
|
|
61
|
+
* legal and a non-recursive reader answers an object where a path belongs.
|
|
62
|
+
*/
|
|
63
|
+
const resolveConditions = (conditionsObject, conditions) => {
|
|
64
|
+
for (const condition of conditions) {
|
|
65
|
+
const matched = conditionsObject[condition];
|
|
66
|
+
if (typeof matched === "string") return matched;
|
|
67
|
+
if (isPlainObject(matched)) {
|
|
68
|
+
const nested = resolveConditions(matched, conditions);
|
|
69
|
+
if (nested !== void 0) return nested;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Resolve a package's root entry point from its manifest.
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* The half of "read something out of a published package" that has no home
|
|
78
|
+
* anywhere else: given a manifest, which file is the package's `"."` entry?
|
|
79
|
+
* It is pure and IO-free by design — nothing here touches a filesystem, so it
|
|
80
|
+
* is testable against plain manifest objects with no package on disk, and it
|
|
81
|
+
* composes with a directory that arrived by any route.
|
|
82
|
+
*
|
|
83
|
+
* All three legal `exports` spellings are honoured, because all three appear in
|
|
84
|
+
* real published packages:
|
|
85
|
+
*
|
|
86
|
+
* - **String shorthand** — `"exports": "./index.js"`, sugar for `{ ".": … }`.
|
|
87
|
+
* - **Subpath map** — `{ ".": "./index.js" }`, or `{ ".": { import, … } }`.
|
|
88
|
+
* - **Root conditions** — `{ "import": "./index.js", "default": "./index.cjs" }`,
|
|
89
|
+
* conditions at the root with no `"."` key.
|
|
90
|
+
*
|
|
91
|
+
* **`exports` encapsulates the package.** When it is present but nothing
|
|
92
|
+
* matches, the answer is a typed failure and `main` is **not** consulted — that
|
|
93
|
+
* is Node's rule, and the lenient reading (falling through to `main`, then to
|
|
94
|
+
* `index.js`) is the subtly wrong one: it answers a file the package
|
|
95
|
+
* deliberately does not export, which loads and behaves plausibly instead of
|
|
96
|
+
* failing. Only when `exports` is **absent** does `main`, and then the legacy
|
|
97
|
+
* `index.js` default, apply.
|
|
98
|
+
*
|
|
99
|
+
* A failure is also the answer for an `exports` form this resolver does not
|
|
100
|
+
* implement — an array fallback list, or a subpath map with no `"."` entry.
|
|
101
|
+
* Both are honest "this resolver cannot tell you", never a guess, and each
|
|
102
|
+
* carries its own {@link UnresolvedEntryPointError} reason so a caller can log
|
|
103
|
+
* which shape a package actually had rather than a flat "could not resolve".
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { resolveEntryPoint } from "@effected/package-json";
|
|
108
|
+
* import { Result, Schema } from "effect";
|
|
109
|
+
*
|
|
110
|
+
* resolveEntryPoint({ exports: { import: "./esm.js", require: "./cjs.js" } });
|
|
111
|
+
* // Result.succeed("./esm.js")
|
|
112
|
+
*
|
|
113
|
+
* resolveEntryPoint({ exports: { require: "./cjs.js" } }, { conditions: ["require"] });
|
|
114
|
+
* // Result.succeed("./cjs.js")
|
|
115
|
+
*
|
|
116
|
+
* resolveEntryPoint({ exports: { require: "./cjs.js" }, main: "./legacy.js" });
|
|
117
|
+
* // Result.fail(UnresolvedEntryPointError { reason: "noConditionMatched" })
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @param manifest - A package manifest, or any object carrying `exports`/`main`.
|
|
121
|
+
* @param options - Which conditions to honour, in priority order.
|
|
122
|
+
* @returns The entry path as written in the manifest, relative to the package
|
|
123
|
+
* root, or a typed {@link UnresolvedEntryPointError} naming which shape
|
|
124
|
+
* blocked resolution.
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
const resolveEntryPoint = (manifest, options) => {
|
|
129
|
+
const conditions = options?.conditions ?? DEFAULT_CONDITIONS;
|
|
130
|
+
const exportsField = manifest.exports;
|
|
131
|
+
if (typeof exportsField === "string") return Result.succeed(exportsField);
|
|
132
|
+
if (isPlainObject(exportsField)) {
|
|
133
|
+
if (isRootConditions(exportsField)) {
|
|
134
|
+
const resolved = resolveConditions(exportsField, conditions);
|
|
135
|
+
return resolved === void 0 ? Result.fail(new UnresolvedEntryPointError({
|
|
136
|
+
reason: "noConditionMatched",
|
|
137
|
+
conditions
|
|
138
|
+
})) : Result.succeed(resolved);
|
|
139
|
+
}
|
|
140
|
+
const dot = exportsField["."];
|
|
141
|
+
if (typeof dot === "string") return Result.succeed(dot);
|
|
142
|
+
if (isPlainObject(dot)) {
|
|
143
|
+
const resolved = resolveConditions(dot, conditions);
|
|
144
|
+
return resolved === void 0 ? Result.fail(new UnresolvedEntryPointError({
|
|
145
|
+
reason: "noConditionMatched",
|
|
146
|
+
conditions
|
|
147
|
+
})) : Result.succeed(resolved);
|
|
148
|
+
}
|
|
149
|
+
return Result.fail(new UnresolvedEntryPointError({ reason: "noRootExport" }));
|
|
150
|
+
}
|
|
151
|
+
if (exportsField !== void 0) return Result.fail(new UnresolvedEntryPointError({ reason: "unsupportedExportsForm" }));
|
|
152
|
+
return Result.succeed(typeof manifest.main === "string" && manifest.main !== "" ? manifest.main : "index.js");
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
export { UnresolvedEntryPointError, resolveEntryPoint };
|
package/README.md
CHANGED
|
@@ -184,6 +184,32 @@ console.log(Effect.runSync(program));
|
|
|
184
184
|
|
|
185
185
|
The `workspace:` range modifier is honored: `workspace:*` takes the bare version, `workspace:^` and `workspace:~` prefix it, and an explicit modifier is used as-is. The projection is `@effected/npm`'s `DependencySpecifier` statics with full pnpm publish semantics: the alias form `workspace:<name>@<range>` resolves the *target* package's version and becomes the `npm:<name>@<range>` alias pnpm publishes, and a blank catalog name selects the default catalog. A failed catalog assembly surfaces typed as `@effected/npm`'s `CatalogAssemblyError`, alongside the contracts' `DependencyResolutionError`.
|
|
186
186
|
|
|
187
|
+
## Resolving an entry point
|
|
188
|
+
|
|
189
|
+
`resolveEntryPoint` answers one question about a manifest — which file is the package's `"."` entry — and it is pure, IO-free and `Result`-returning, so it works against a plain object with no package on disk:
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import { resolveEntryPoint } from "@effected/package-json";
|
|
193
|
+
|
|
194
|
+
resolveEntryPoint({ exports: { import: "./esm.js", require: "./cjs.js" } });
|
|
195
|
+
// Result.succeed("./esm.js")
|
|
196
|
+
|
|
197
|
+
resolveEntryPoint({ exports: { require: "./cjs.js" } }, { conditions: ["require"] });
|
|
198
|
+
// Result.succeed("./cjs.js")
|
|
199
|
+
|
|
200
|
+
resolveEntryPoint({ main: "./legacy.js" });
|
|
201
|
+
// Result.succeed("./legacy.js") — no exports field, so main applies
|
|
202
|
+
|
|
203
|
+
resolveEntryPoint({ exports: { require: "./cjs.js" }, main: "./legacy.js" });
|
|
204
|
+
// Result.fail(UnresolvedEntryPointError { reason: "noConditionMatched" })
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
All three legal `exports` spellings are honored — the string shorthand, a subpath map, and conditions at the root with no `"."` key — and conditions default to `["import", "default"]`, in priority order.
|
|
208
|
+
|
|
209
|
+
The last case above is the semantic worth knowing: **`exports` encapsulates the package**, so a present-but-unmatched `exports` is a typed failure and `main` is *not* consulted. That is Node's rule. The lenient reading — falling through to `main`, then to `index.js` — answers a file the package deliberately does not export, and it loads and behaves plausibly instead of failing. Only an **absent** `exports` reaches `main`, and then the legacy `index.js` default. An `exports` form the resolver does not implement (an array fallback list, or a subpath map with no `"."` entry) fails for its own reason rather than being guessed at.
|
|
210
|
+
|
|
211
|
+
Pair it with `@effected/npm`'s `PackageTarball` to find the entry file inside a tarball extracted before any install has run.
|
|
212
|
+
|
|
187
213
|
## Errors
|
|
188
214
|
|
|
189
215
|
Every failure is a `Schema.TaggedError` routed with `Effect.catchTag`. Causes are preserved structurally on a `Schema.Defect` field — a `PackageDecodeError` hands you the `SchemaError` issue tree, not `String(error)`.
|
|
@@ -199,6 +225,7 @@ Every failure is a `Schema.TaggedError` routed with `Effect.catchTag`. Causes ar
|
|
|
199
225
|
| `InvalidPackageNameError` | A string does not satisfy npm's naming rules. Raised by `Package.setName`. |
|
|
200
226
|
| `InvalidSpdxLicenseError` | A string is not a valid SPDX license expression. Raised by `Package.setLicense`. |
|
|
201
227
|
| `InvalidDependencySpecifierError` | A string is not a recognized dependency specifier. Raised by `DependencySpecifier.decode`. |
|
|
228
|
+
| `UnresolvedEntryPointError` | No entry point could be resolved from a manifest. Returned in a `Result` by `resolveEntryPoint`, never raised, with `reason` telling `noConditionMatched`, `noRootExport` and `unsupportedExportsForm` apart. |
|
|
202
229
|
|
|
203
230
|
`Package.setVersion` fails with `InvalidVersionError` from `@effected/semver`, which is where the version grammar lives.
|
|
204
231
|
|
|
@@ -208,6 +235,7 @@ Every failure is a `Schema.TaggedError` routed with `Effect.catchTag`. Causes ar
|
|
|
208
235
|
- `Package.schema` / `Package.wireFor` — the open-JSON ↔ class wire codec, and the factory that builds one for a `.extend()`ed subclass so its custom fields decode as typed members instead of falling into `rest`.
|
|
209
236
|
- `PackageJsonFile` — the IO surface: `read` and `write` over core `FileSystem` / `Path`, with the platform implementation supplied at the edge.
|
|
210
237
|
- `PackageValidator` — rule-based validation aggregating every failure, with the default rule set, a parameterized `layerRules` factory, and the publish-gate rules `noUnresolvedDepsRule` and `noLocalDepsRule`.
|
|
238
|
+
- `resolveEntryPoint` — the pure, `Result`-returning entry-point resolver over a manifest's `exports`/`main`, honoring `exports` encapsulation rather than falling through to `main`, with `EntryPointManifest` as its tolerant input shape.
|
|
211
239
|
- `Package.resolve` — `catalog:` and `workspace:` expansion over the `@effected/npm` contracts with pnpm's publish-time projection (alias form included), as an explicit step that `write` never performs for you.
|
|
212
240
|
- `PackageName`, `DependencySpecifier`, `Dependency`, `SpdxLicense`, `PackageManager`, `Person`, `Repository`, `Bugs`, `DevEngine` — the leaf concepts, each owning its own statics, brand and error, usable independently of `Package`. `Repository` and `Bugs` decode the `repository` and `bugs` fields from either their shorthand or object form, the same way `Person` does for `author`, `contributors` and `maintainers`; `Repository` also exposes `browseUrl` and `gitUrl` getters that normalize a shorthand or SSH form to `https://`.
|
|
213
241
|
- `Package` also types `keywords`, `maintainers` and `homepage` directly, alongside the existing `author` and `contributors`.
|
package/index.d.ts
CHANGED
|
@@ -106,6 +106,124 @@ declare const DevEnginesSchema: Schema.Struct<{
|
|
|
106
106
|
*/
|
|
107
107
|
type DevEngines = typeof DevEnginesSchema.Type;
|
|
108
108
|
//#endregion
|
|
109
|
+
//#region src/EntryPoint.d.ts
|
|
110
|
+
/**
|
|
111
|
+
* Options for {@link resolveEntryPoint}.
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
interface ResolveEntryPointOptions {
|
|
116
|
+
/**
|
|
117
|
+
* The export conditions to honour, in priority order.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* The first condition present in the manifest wins, so the order is the
|
|
121
|
+
* policy — `["require", "import"]` and `["import", "require"]` resolve the
|
|
122
|
+
* same manifest to different files, on purpose.
|
|
123
|
+
*
|
|
124
|
+
* @defaultValue `["import", "default"]`
|
|
125
|
+
*/
|
|
126
|
+
readonly conditions?: ReadonlyArray<string>;
|
|
127
|
+
}
|
|
128
|
+
declare const UnresolvedEntryPointError_base: Schema.Class<UnresolvedEntryPointError, Schema.TaggedStruct<"UnresolvedEntryPointError", {
|
|
129
|
+
/**
|
|
130
|
+
* `noRootExport` — `exports` is a subpath map with no `"."` entry, so the
|
|
131
|
+
* package exports subpaths but no root. `noConditionMatched` — a root
|
|
132
|
+
* entry exists but none of the requested conditions are present, e.g. a
|
|
133
|
+
* `require`-only package read with `["import"]`.
|
|
134
|
+
* `unsupportedExportsForm` — an array fallback list, or another shape this
|
|
135
|
+
* resolver does not implement.
|
|
136
|
+
*/
|
|
137
|
+
readonly reason: Schema.Literals<readonly ["noRootExport", "noConditionMatched", "unsupportedExportsForm"]>;
|
|
138
|
+
/** The conditions that were tried, for `noConditionMatched`. */
|
|
139
|
+
readonly conditions: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
140
|
+
}>, import("effect/Cause").YieldableError>;
|
|
141
|
+
/**
|
|
142
|
+
* Raised when a manifest resolves no root entry point.
|
|
143
|
+
*
|
|
144
|
+
* @remarks
|
|
145
|
+
* The reason is discriminated rather than a bare "not found" because the three
|
|
146
|
+
* shapes call for different responses, and a caller staring at a consumer's
|
|
147
|
+
* plugin at 3am needs to know which one it hit. Collapsing them into one
|
|
148
|
+
* sentinel is the same class of quiet wrong answer as an untyped error channel.
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
declare class UnresolvedEntryPointError extends UnresolvedEntryPointError_base {
|
|
153
|
+
get message(): string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The manifest fields entry resolution reads.
|
|
157
|
+
*
|
|
158
|
+
* @remarks
|
|
159
|
+
* Deliberately structural rather than the full {@link PackageManifest}, so a
|
|
160
|
+
* caller can resolve an entry point from any object carrying these two fields —
|
|
161
|
+
* a manifest parsed straight from a tarball, for instance, with nothing else
|
|
162
|
+
* validated yet.
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
interface EntryPointManifest {
|
|
167
|
+
readonly exports?: unknown;
|
|
168
|
+
readonly main?: unknown;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Resolve a package's root entry point from its manifest.
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* The half of "read something out of a published package" that has no home
|
|
175
|
+
* anywhere else: given a manifest, which file is the package's `"."` entry?
|
|
176
|
+
* It is pure and IO-free by design — nothing here touches a filesystem, so it
|
|
177
|
+
* is testable against plain manifest objects with no package on disk, and it
|
|
178
|
+
* composes with a directory that arrived by any route.
|
|
179
|
+
*
|
|
180
|
+
* All three legal `exports` spellings are honoured, because all three appear in
|
|
181
|
+
* real published packages:
|
|
182
|
+
*
|
|
183
|
+
* - **String shorthand** — `"exports": "./index.js"`, sugar for `{ ".": … }`.
|
|
184
|
+
* - **Subpath map** — `{ ".": "./index.js" }`, or `{ ".": { import, … } }`.
|
|
185
|
+
* - **Root conditions** — `{ "import": "./index.js", "default": "./index.cjs" }`,
|
|
186
|
+
* conditions at the root with no `"."` key.
|
|
187
|
+
*
|
|
188
|
+
* **`exports` encapsulates the package.** When it is present but nothing
|
|
189
|
+
* matches, the answer is a typed failure and `main` is **not** consulted — that
|
|
190
|
+
* is Node's rule, and the lenient reading (falling through to `main`, then to
|
|
191
|
+
* `index.js`) is the subtly wrong one: it answers a file the package
|
|
192
|
+
* deliberately does not export, which loads and behaves plausibly instead of
|
|
193
|
+
* failing. Only when `exports` is **absent** does `main`, and then the legacy
|
|
194
|
+
* `index.js` default, apply.
|
|
195
|
+
*
|
|
196
|
+
* A failure is also the answer for an `exports` form this resolver does not
|
|
197
|
+
* implement — an array fallback list, or a subpath map with no `"."` entry.
|
|
198
|
+
* Both are honest "this resolver cannot tell you", never a guess, and each
|
|
199
|
+
* carries its own {@link UnresolvedEntryPointError} reason so a caller can log
|
|
200
|
+
* which shape a package actually had rather than a flat "could not resolve".
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* import { resolveEntryPoint } from "@effected/package-json";
|
|
205
|
+
* import { Result, Schema } from "effect";
|
|
206
|
+
*
|
|
207
|
+
* resolveEntryPoint({ exports: { import: "./esm.js", require: "./cjs.js" } });
|
|
208
|
+
* // Result.succeed("./esm.js")
|
|
209
|
+
*
|
|
210
|
+
* resolveEntryPoint({ exports: { require: "./cjs.js" } }, { conditions: ["require"] });
|
|
211
|
+
* // Result.succeed("./cjs.js")
|
|
212
|
+
*
|
|
213
|
+
* resolveEntryPoint({ exports: { require: "./cjs.js" }, main: "./legacy.js" });
|
|
214
|
+
* // Result.fail(UnresolvedEntryPointError { reason: "noConditionMatched" })
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @param manifest - A package manifest, or any object carrying `exports`/`main`.
|
|
218
|
+
* @param options - Which conditions to honour, in priority order.
|
|
219
|
+
* @returns The entry path as written in the manifest, relative to the package
|
|
220
|
+
* root, or a typed {@link UnresolvedEntryPointError} naming which shape
|
|
221
|
+
* blocked resolution.
|
|
222
|
+
*
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
declare const resolveEntryPoint: (manifest: EntryPointManifest, options?: ResolveEntryPointOptions) => Result.Result<string, UnresolvedEntryPointError>;
|
|
226
|
+
//#endregion
|
|
109
227
|
//#region src/License.d.ts
|
|
110
228
|
declare const InvalidSpdxLicenseError_base: Schema.Class<InvalidSpdxLicenseError, Schema.TaggedStruct<"InvalidSpdxLicenseError", {
|
|
111
229
|
/** The raw input string that failed validation. */
|
|
@@ -163,7 +281,10 @@ declare const PackageManager_base: Schema.Class<PackageManager, Schema.Struct<{
|
|
|
163
281
|
* `CorepackIntegrityHash`, the shared restriction of the `IntegrityHash`
|
|
164
282
|
* brand to the corepack `<algo>.<hex>` form.
|
|
165
283
|
*/
|
|
166
|
-
readonly integrity: Schema.Option<Schema.brand<Schema.String, "IntegrityHash"
|
|
284
|
+
readonly integrity: Schema.Option<Schema.brand<Schema.String, "IntegrityHash"> & {
|
|
285
|
+
FromSri: Schema.Codec<import("@effected/npm").IntegrityHashBrand, string, never, never>;
|
|
286
|
+
fromSri: (input: string) => Effect.Effect<import("@effected/npm").IntegrityHashBrand, import("@effected/npm").InvalidSriIntegrityHashError>;
|
|
287
|
+
}>;
|
|
167
288
|
}>, {}>;
|
|
168
289
|
/**
|
|
169
290
|
* A structured `packageManager` value with `name`, `version` and an optional
|
|
@@ -974,7 +1095,10 @@ declare const PackageManagerRange_base: Schema.Class<PackageManagerRange, Schema
|
|
|
974
1095
|
* an integrity pins one artifact — but carried whenever the manifest
|
|
975
1096
|
* carries it, because fidelity outranks plausibility in a field model.
|
|
976
1097
|
*/
|
|
977
|
-
readonly integrity: Schema.Option<Schema.brand<Schema.String, "IntegrityHash"
|
|
1098
|
+
readonly integrity: Schema.Option<Schema.brand<Schema.String, "IntegrityHash"> & {
|
|
1099
|
+
FromSri: Schema.Codec<import("@effected/npm").IntegrityHashBrand, string, never, never>;
|
|
1100
|
+
fromSri: (input: string) => Effect.Effect<import("@effected/npm").IntegrityHashBrand, import("@effected/npm").InvalidSriIntegrityHashError>;
|
|
1101
|
+
}>;
|
|
978
1102
|
}>, {}>;
|
|
979
1103
|
/**
|
|
980
1104
|
* A structured `packageManager` value whose version position is a semver
|
|
@@ -1418,5 +1542,5 @@ declare class PackageValidator extends PackageValidator_base {
|
|
|
1418
1542
|
}): Layer.Layer<PackageValidator>;
|
|
1419
1543
|
}
|
|
1420
1544
|
//#endregion
|
|
1421
|
-
export { BinField, Bugs, Dependency, type DependencyKind, DependencyMapField, type DependencyProtocol, DependencySpecifier, type DependencySpecifierBrand, DevEngine, DevEngineOrArray, type DevEngines, DevEnginesSchema, ExportsField, InvalidDependencySpecifierError, InvalidPackageNameError, InvalidSpdxLicenseError, JsoncEdit, type JsoncPath, 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 RuleFailure, ScopedPackageName, SpdxLicense, StringMapField, type UnresolvedDependency, UnscopedPackageName, type ValidationRule, defaultRules, isUnresolvedDependency, isValidDependencySpecifier, isValidSpdx, noLocalDepsRule, noUnresolvedDepsRule };
|
|
1545
|
+
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, 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 };
|
|
1422
1546
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Dependency, isUnresolvedDependency } from "./Dependency.js";
|
|
2
2
|
import { DevEngine, DevEngineOrArray, DevEnginesSchema } from "./DevEngines.js";
|
|
3
|
+
import { UnresolvedEntryPointError, resolveEntryPoint } from "./EntryPoint.js";
|
|
3
4
|
import { InvalidSpdxLicenseError, SpdxLicense, isValidSpdx } from "./License.js";
|
|
4
5
|
import { PackageManager } from "./PackageManager.js";
|
|
5
6
|
import { InvalidPackageNameError, PackageName, ScopedPackageName, UnscopedPackageName } from "./PackageName.js";
|
|
@@ -14,4 +15,4 @@ import { PackageValidationError, PackageValidator, defaultRules, noLocalDepsRule
|
|
|
14
15
|
import { JsoncEdit } from "@effected/jsonc";
|
|
15
16
|
import { DependencySpecifier, InvalidDependencySpecifierError, isValidDependencySpecifier } from "@effected/npm";
|
|
16
17
|
|
|
17
|
-
export { BinField, Bugs, Dependency, DependencyMapField, DependencySpecifier, DevEngine, DevEngineOrArray, DevEnginesSchema, ExportsField, InvalidDependencySpecifierError, InvalidPackageNameError, InvalidSpdxLicenseError, JsoncEdit, Package, PackageDecodeError, PackageJsonFile, PackageJsonFormat, PackageJsonModifyError, PackageJsonNotFoundError, PackageJsonParseError, PackageJsonReadError, PackageJsonSyntaxError, PackageJsonWriteError, PackageManager, PackageManagerRange, PackageManifest, PackageName, PackageValidationError, PackageValidator, PeerDependenciesMetaField, Person, PublishConfigField, Repository, RepositoryField, ScopedPackageName, SpdxLicense, StringMapField, UnscopedPackageName, defaultRules, isUnresolvedDependency, isValidDependencySpecifier, isValidSpdx, noLocalDepsRule, noUnresolvedDepsRule };
|
|
18
|
+
export { BinField, Bugs, Dependency, DependencyMapField, DependencySpecifier, DevEngine, DevEngineOrArray, DevEnginesSchema, ExportsField, InvalidDependencySpecifierError, InvalidPackageNameError, InvalidSpdxLicenseError, JsoncEdit, Package, PackageDecodeError, PackageJsonFile, PackageJsonFormat, PackageJsonModifyError, PackageJsonNotFoundError, PackageJsonParseError, PackageJsonReadError, PackageJsonSyntaxError, PackageJsonWriteError, PackageManager, PackageManagerRange, PackageManifest, PackageName, PackageValidationError, PackageValidator, PeerDependenciesMetaField, Person, PublishConfigField, Repository, RepositoryField, ScopedPackageName, SpdxLicense, StringMapField, UnresolvedEntryPointError, UnscopedPackageName, defaultRules, isUnresolvedDependency, isValidDependencySpecifier, isValidSpdx, noLocalDepsRule, noUnresolvedDepsRule, resolveEntryPoint };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "package.json parsing, editing, validation and file IO as Effect schemas.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@effected/jsonc": "^0.7.0",
|
|
42
|
-
"@effected/npm": "^0.
|
|
42
|
+
"@effected/npm": "^0.12.0",
|
|
43
43
|
"@effected/semver": "^0.5.0",
|
|
44
44
|
"@effected/spdx": "^0.4.0"
|
|
45
45
|
},
|