@effected/package-json 0.12.0 → 0.14.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/Funding.js ADDED
@@ -0,0 +1,146 @@
1
+ import { Effect, Schema, SchemaTransformation } from "effect";
2
+
3
+ //#region src/Funding.ts
4
+ const entryWires = /* @__PURE__ */ new WeakMap();
5
+ /**
6
+ * Entries that were the WHOLE field, written bare rather than inside an array.
7
+ *
8
+ * Keyed by the ENTRY, not by the decoded array: `Schema.Array` rebuilds the
9
+ * array on the way out of the transform, so an array-keyed WeakMap is empty by
10
+ * the time `encode` runs — verified by the arity round trip failing under it.
11
+ * Arity provenance therefore rides the one instance that was the field, and
12
+ * the replay is guarded on that instance still being alone.
13
+ */
14
+ const bareEntries = /* @__PURE__ */ new WeakSet();
15
+ const KNOWN_FUNDING_KEYS = /* @__PURE__ */ new Set(["type", "url"]);
16
+ const FundingFields = Schema.Struct({
17
+ type: Schema.optionalKey(Schema.String),
18
+ url: Schema.String
19
+ });
20
+ const decodeFundingFields = Schema.decodeUnknownEffect(FundingFields);
21
+ const restOf = (raw) => {
22
+ const rest = {};
23
+ for (const [key, value] of Object.entries(raw)) if (!KNOWN_FUNDING_KEYS.has(key)) rest[key] = value;
24
+ return rest;
25
+ };
26
+ /**
27
+ * Whether the remembered object still describes this entry. Guarding the
28
+ * replay is load-bearing: `Schema.Class` instances are not frozen, so an entry
29
+ * mutated in place keeps a provenance entry that no longer describes it, and
30
+ * an unguarded replay would write the ORIGINAL object back — silently
31
+ * discarding the edit.
32
+ */
33
+ const isFaithfulObject = (wire, funding) => {
34
+ if (wire.url !== funding.url) return false;
35
+ if ((typeof wire.type === "string" ? wire.type : void 0) !== funding.type) return false;
36
+ for (const [key, value] of Object.entries(funding.rest ?? {})) if (wire[key] !== value) return false;
37
+ return true;
38
+ };
39
+ /** Whether the bare string form can still carry everything this entry holds. */
40
+ const isStringExpressible = (funding) => funding.type === void 0 && Object.keys(funding.rest ?? {}).length === 0;
41
+ const encodeEntry = (funding) => {
42
+ const wire = entryWires.get(funding);
43
+ if (typeof wire === "string" && isStringExpressible(funding)) return funding.url;
44
+ if (wire !== void 0 && typeof wire !== "string" && isFaithfulObject(wire, funding)) return wire;
45
+ return {
46
+ ...funding.type !== void 0 && { type: funding.type },
47
+ url: funding.url,
48
+ ...funding.rest
49
+ };
50
+ };
51
+ const decodeEntry = (input) => {
52
+ if (typeof input === "string") {
53
+ const funding = Funding.make({ url: input });
54
+ entryWires.set(funding, input);
55
+ return Effect.succeed(funding);
56
+ }
57
+ return decodeFundingFields(input).pipe(Effect.mapError((error) => error.issue), Effect.map((fields) => {
58
+ const rest = restOf(input);
59
+ const funding = Funding.make({
60
+ ...fields,
61
+ ...Object.keys(rest).length > 0 ? { rest } : {}
62
+ });
63
+ entryWires.set(funding, input);
64
+ return funding;
65
+ }));
66
+ };
67
+ const EntryValue = Schema.Union([Schema.Record(Schema.String, Schema.Unknown), Schema.String]);
68
+ const FieldValue = Schema.Union([EntryValue, Schema.Array(EntryValue)]);
69
+ /**
70
+ * Where to send money for a package: one funding entry.
71
+ *
72
+ * @remarks
73
+ * npm's `funding` field accepts a bare URL string, this object form, or an
74
+ * array of either. `url` is **required** — it is the only thing the field
75
+ * actually says — so an object without one fails to decode rather than
76
+ * producing a half-populated entry. `type` (`"individual"`, `"github"`, …) is
77
+ * caller data and is kept **verbatim**, never normalized.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { Funding } from "@effected/package-json";
82
+ * import { Effect, Schema } from "effect";
83
+ *
84
+ * const program = Effect.gen(function* () {
85
+ * // Always an array, whichever encoding the manifest used.
86
+ * const entries = yield* Schema.decodeUnknownEffect(Funding.FromField)("https://example.com/sponsor");
87
+ * console.log(entries[0]?.url); // "https://example.com/sponsor"
88
+ * });
89
+ * ```
90
+ *
91
+ * @public
92
+ */
93
+ var Funding = class Funding extends Schema.Class("Funding")({
94
+ /** The funding platform, when the object form carried one (`"github"`, …). */
95
+ type: Schema.optionalKey(Schema.String),
96
+ /** Where the money goes, exactly as the manifest wrote it. */
97
+ url: Schema.String,
98
+ /** Keys outside the documented set, preserved so encoding does not drop them. */
99
+ rest: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown))
100
+ }) {
101
+ /**
102
+ * A single `funding` entry: the bare URL string or the object form, always
103
+ * decoded to a {@link Funding} and always re-encoded in the form it was read
104
+ * from.
105
+ *
106
+ * @remarks
107
+ * Provenance belongs to the instance, so an entry that is *rebuilt* rather
108
+ * than carried through has none and encodes in the canonical object form.
109
+ */
110
+ static FromValue = EntryValue.pipe(Schema.decodeTo(Schema.instanceOf(Funding), SchemaTransformation.transformOrFail({
111
+ decode: (input) => decodeEntry(input),
112
+ encode: (funding) => Effect.succeed(encodeEntry(funding))
113
+ })));
114
+ /**
115
+ * The `funding` field: a lone entry or an array of them, **always** decoded
116
+ * to an array so a consumer never branches on arity.
117
+ *
118
+ * @remarks
119
+ * The normalization is one-directional. A field written bare re-encodes
120
+ * bare, not as a one-element array — the arity is remembered against the
121
+ * single entry that WAS the field, and the replay is guarded on that entry
122
+ * still being alone, so pushing a second entry into the decoded array in
123
+ * place upgrades the field to the array form instead of silently dropping
124
+ * the addition. An entry built by hand has no provenance, so an array of
125
+ * such entries encodes as an array.
126
+ */
127
+ static FromField = FieldValue.pipe(Schema.decodeTo(Schema.Array(Schema.instanceOf(Funding)), SchemaTransformation.transformOrFail({
128
+ decode: (input) => {
129
+ const bare = !Array.isArray(input);
130
+ const values = bare ? [input] : input;
131
+ return Effect.map(Effect.forEach(values, decodeEntry), (entries) => {
132
+ const only = entries[0];
133
+ if (bare && only !== void 0) bareEntries.add(only);
134
+ return entries;
135
+ });
136
+ },
137
+ encode: (entries) => {
138
+ const only = entries.length === 1 ? entries[0] : void 0;
139
+ if (only !== void 0 && bareEntries.has(only)) return Effect.succeed(encodeEntry(only));
140
+ return Effect.succeed(entries.map(encodeEntry));
141
+ }
142
+ })));
143
+ };
144
+
145
+ //#endregion
146
+ export { Funding };
@@ -60,6 +60,10 @@ const FIELD_GUARDS = /* @__PURE__ */ new Map([
60
60
  }],
61
61
  ["repository", stringOrRecordGuard],
62
62
  ["bugs", stringOrRecordGuard],
63
+ ["funding", {
64
+ expected: "a string, an object, or an array of either",
65
+ test: (value) => isStringOrRecord(value) || isStringOrRecordArray(value)
66
+ }],
63
67
  ["homepage", stringGuard],
64
68
  ["dependencies", stringRecordGuard],
65
69
  ["devDependencies", stringRecordGuard],
@@ -163,6 +167,7 @@ var LenientManifest = class LenientManifest extends Schema.Class("LenientManifes
163
167
  keywords: Schema.optionalKey(Schema.Array(Schema.String)),
164
168
  repository: Schema.optionalKey(StringOrRecord),
165
169
  bugs: Schema.optionalKey(StringOrRecord),
170
+ funding: Schema.optionalKey(Schema.Union([StringOrRecord, Schema.Array(StringOrRecord)])),
166
171
  homepage: Schema.optionalKey(Schema.String),
167
172
  dependencies: Schema.optionalKey(StringRecord),
168
173
  devDependencies: Schema.optionalKey(StringRecord),
package/License.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Schema } from "effect";
2
- import { isValidExpression } from "@effected/spdx";
1
+ import { Result, Schema } from "effect";
2
+ import { SpdxExpression, isValidExpression } from "@effected/spdx";
3
3
 
4
4
  //#region src/License.ts
5
5
  /**
@@ -32,9 +32,54 @@ const isValidSpdx = (value) => {
32
32
  * A valid SPDX license identifier, expression, `UNLICENSED`, or
33
33
  * `SEE LICENSE IN <file>`.
34
34
  *
35
+ * @remarks
36
+ * **A branded value here is not necessarily parseable as SPDX.** npm's
37
+ * `license` field admits two strings that the SPDX grammar does not —
38
+ * `UNLICENSED` and `SEE LICENSE IN <file>` — and this brand accepts both,
39
+ * because it models what a manifest may legally carry, not what SPDX defines.
40
+ * Feeding a branded value straight to `SpdxExpression.parse` therefore fails
41
+ * on exactly those two forms. Do not hand-screen for them — reach for
42
+ * {@link licenseExpressionOf}, which answers "what expression is this, if any"
43
+ * and yields `Option.none()` for a spelling that is not one. Reach for
44
+ * {@link isValidSpdx} when the question is instead "may a manifest carry this".
45
+ *
35
46
  * @public
36
47
  */
37
48
  const SpdxLicense = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => isValidSpdx(value) ? void 0 : "Expected a valid SPDX license expression")), Schema.brand("SpdxLicense"));
49
+ /**
50
+ * The parsed SPDX expression a manifest's `license` denotes, or `Option.none()`
51
+ * when it denotes no expression at all.
52
+ *
53
+ * @remarks
54
+ * This is the accessor to reach for whenever a branded `SpdxLicense` has
55
+ * to become an actual expression — a license URL, a badge, structured data, a
56
+ * policy check. It exists because the brand and the grammar disagree, and that
57
+ * disagreement is knowledge these two packages jointly own rather than
58
+ * something each consumer should rediscover.
59
+ *
60
+ * `UNLICENSED` and `SEE LICENSE IN <file>` are legal in a manifest and are not
61
+ * SPDX expressions, so they yield `Option.none()`. Everything else parses.
62
+ * A consumer screening for those two spellings by hand gets it wrong the day
63
+ * npm admits a third — this accessor is the mechanism that prose could not be,
64
+ * and it needs no change on that day, because "not an expression" is answered
65
+ * by the grammar rather than by a list of spellings kept in step with npm.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * import { licenseExpressionOf } from "@effected/package-json";
70
+ * import { SpdxExpression } from "@effected/spdx";
71
+ *
72
+ * // "MIT" => Option.some(<LicenseNode MIT>)
73
+ * // "UNLICENSED" => Option.none()
74
+ * // "SEE LICENSE IN LICENSE.txt" => Option.none()
75
+ * ```
76
+ *
77
+ * @param license - a branded manifest license value
78
+ * @returns the parsed expression, or none for a spelling that is not one
79
+ *
80
+ * @public
81
+ */
82
+ const licenseExpressionOf = (license) => Result.getSuccess(SpdxExpression.parseResult(license));
38
83
 
39
84
  //#endregion
40
- export { InvalidSpdxLicenseError, SpdxLicense, isValidSpdx };
85
+ export { InvalidSpdxLicenseError, SpdxLicense, isValidSpdx, licenseExpressionOf };
package/Package.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Dependency } from "./Dependency.js";
2
2
  import { DevEnginesSchema } from "./DevEngines.js";
3
+ import { Funding } from "./Funding.js";
3
4
  import { renderJson, resolveFormatOptions } from "./internal/format.js";
4
5
  import { makeWire } from "./internal/wire.js";
5
6
  import { InvalidSpdxLicenseError, SpdxLicense, isValidSpdx } from "./License.js";
@@ -121,6 +122,7 @@ var Package = class Package extends Schema.Class("Package")({
121
122
  keywords: Schema.optionalKey(Schema.Array(Schema.String)),
122
123
  repository: Schema.optionalKey(Repository.FromValue),
123
124
  bugs: Schema.optionalKey(Bugs.FromValue),
125
+ funding: Schema.optionalKey(Funding.FromField),
124
126
  homepage: Schema.optionalKey(Schema.String),
125
127
  dependencies: DependencyMapField,
126
128
  devDependencies: DependencyMapField,
package/README.md CHANGED
@@ -264,7 +264,10 @@ Every failure is a `Schema.TaggedError` routed with `Effect.catchTag`. Causes ar
264
264
  - `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.
265
265
  - `LenientManifest` — the shape-lenient discovery tier below `PackageManifest`: malformed known fields degrade to absence, are preserved verbatim in `rest` and reported on `issues`, rather than failing the document; `decodeResult`/`decode` and `parseResult`/`parse` in the package's usual `Result`/`Effect` pairing.
266
266
  - `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.
267
- - `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://`.
267
+ - `PackageName`, `DependencySpecifier`, `Dependency`, `SpdxLicense`, `PackageManager`, `Person`, `Repository`, `Bugs`, `Funding`, `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://`.
268
+ - `Repository.directoryUrl` — the browse URL of a monorepo member's own subdirectory, built from `repository.directory` against the host's path convention on GitHub, GitLab and Bitbucket. `none` for a host whose convention is unknown, or for a `directory` that climbs out of the repository — a guessed path would resolve to nothing while looking authoritative. With no `directory`, it is `browseUrl`.
269
+ - `Funding` — the `funding` field, decoded from a bare URL string, an object, or an array of either, and **always** to an array so a consumer never branches on arity. Each entry re-encodes in the form it was read from, and unrecognized keys survive in `rest`.
270
+ - `licenseExpressionOf` — a `SpdxLicense` as an `Option<SpdxExpression>` from `@effected/spdx`, for a caller that wants the parsed expression rather than the string. `none` for the `SEE LICENSE IN …` and `UNLICENSED` forms, which are valid `license` values but not license expressions.
268
271
  - `Package` also types `keywords`, `maintainers` and `homepage` directly, alongside the existing `author` and `contributors`.
269
272
  - Field schemas (`DependencyMapField`, `BinField`, `ExportsField`, `PublishConfigField`, `PeerDependenciesMetaField`, `StringMapField`) exported for subclasses that extend the model. `RepositoryField` is exported too but deprecated: `Package.repository` now decodes through `Repository.FromValue`, which round-trips the original shorthand or object form; `RepositoryField` remains only for consumers still matching on the raw union.
270
273
 
package/Repository.js CHANGED
@@ -13,6 +13,16 @@ const BARE_SHORTHAND = /^[\w.-]+\/[\w.-]+$/;
13
13
  const PREFIXED_SHORTHAND = /^([a-z]+):(.+)$/;
14
14
  /** The scp-like form git accepts: `git@host:owner/name.git`. */
15
15
  const SCP_LIKE = /^(?:([\w.-]+)@)?([\w.-]+):(.+)$/;
16
+ /**
17
+ * How each known forge spells "browse this subdirectory". `HEAD` is used
18
+ * rather than a branch name because the default branch is not knowable from a
19
+ * manifest, and every one of these hosts resolves `HEAD` to it.
20
+ */
21
+ const DIRECTORY_PATHS = /* @__PURE__ */ new Map([
22
+ ["github.com", "tree/HEAD"],
23
+ ["gitlab.com", "-/tree/HEAD"],
24
+ ["bitbucket.org", "src/HEAD"]
25
+ ]);
16
26
  const stripGitSuffix = (value) => value.endsWith(".git") ? value.slice(0, -4) : value;
17
27
  /**
18
28
  * The browsable `https://host/path` form of a repository reference, or none
@@ -53,6 +63,34 @@ const KNOWN_REPOSITORY_KEYS = /* @__PURE__ */ new Set([
53
63
  "directory"
54
64
  ]);
55
65
  const KNOWN_BUGS_KEYS = /* @__PURE__ */ new Set(["url", "email"]);
66
+ const sameRest = (a, b) => JSON.stringify(a ?? {}) === JSON.stringify(b ?? {});
67
+ /** The keys of `wire` outside the documented set, which is what `rest` holds. */
68
+ const restOf = (wire, known) => {
69
+ const rest = {};
70
+ for (const [key, value] of Object.entries(wire)) if (!known.has(key)) rest[key] = value;
71
+ return rest;
72
+ };
73
+ /**
74
+ * Whether the shorthand string can still carry everything this value holds.
75
+ *
76
+ * @remarks
77
+ * A shorthand is only a `url` — it has no syntax for `type`, `directory` or an
78
+ * unknown key. So a repository decoded from a string that later GAINS one of
79
+ * those is no longer described by the wire it remembers, and replaying that
80
+ * wire drops the addition silently. This is the same stale-provenance class the
81
+ * object branch guards, reached through the one field the shorthand cannot
82
+ * express, and `Person.isShorthandExpressible` / `Funding.isStringExpressible`
83
+ * already gate their own string branches this way.
84
+ *
85
+ * `directory` is the live case: this package ships `Repository.directoryUrl`,
86
+ * so a consumer reading a bare-string `repository` and making it a monorepo
87
+ * member is the natural mutator.
88
+ */
89
+ const isStringExpressibleRepository = (repository) => repository.type === void 0 && repository.directory === void 0 && Object.keys(repository.rest ?? {}).length === 0;
90
+ /** Whether the bare URL string can still carry everything this `bugs` entry holds. */
91
+ const isStringExpressibleBugs = (bugs) => bugs.email === void 0 && Object.keys(bugs.rest ?? {}).length === 0;
92
+ const isFaithfulRepository = (wire, repository) => wire.url === repository.url && wire.type === repository.type && wire.directory === repository.directory && sameRest(restOf(wire, KNOWN_REPOSITORY_KEYS), repository.rest);
93
+ const isFaithfulBugs = (wire, bugs) => wire.url === bugs.url && wire.email === bugs.email && sameRest(restOf(wire, KNOWN_BUGS_KEYS), bugs.rest);
56
94
  /**
57
95
  * Where a package's source lives.
58
96
  *
@@ -92,6 +130,60 @@ var Repository = class Repository extends Schema.Class("Repository")({
92
130
  return Option.map(this.browseUrl, (url) => `${url}.git`);
93
131
  }
94
132
  /**
133
+ * The browsable URL of **this package** — {@link Repository.browseUrl}
134
+ * descended into `directory` when the package is a monorepo
135
+ * member.
136
+ *
137
+ * @remarks
138
+ * Prefer this over `browseUrl` whenever the question is "where does this
139
+ * package live". For a monorepo, `browseUrl` answers with the repository
140
+ * root, so every member of the repository reports the same location — which
141
+ * matters because that URL is exactly what a consumer (a docs site's
142
+ * structured data, say) uses to tell two packages apart.
143
+ *
144
+ * The three outcomes are deliberately distinct:
145
+ *
146
+ * - **No `directory`** — the package *is* the repository root, so this is
147
+ * `browseUrl`. A correct answer, not a missing one.
148
+ * - **`directory` on a host this model knows** (GitHub, GitLab, Bitbucket) —
149
+ * the descended URL.
150
+ * - **`directory` on any other host** — `Option.none()`. The path convention
151
+ * for browsing a subdirectory is per-forge and cannot be guessed, and
152
+ * fabricating one would produce a URL that resolves to nothing while
153
+ * looking authoritative.
154
+ *
155
+ * What to do with that `none` is a policy this getter deliberately leaves to
156
+ * the caller, because it depends on what is being filled in. Falling back to
157
+ * {@link Repository.browseUrl} is reasonable wherever a less precise answer
158
+ * beats no answer — the repository root is a *true* location for the package,
159
+ * merely one that does not distinguish it from its siblings. Omit the value
160
+ * instead wherever that lack of distinction is the whole point. What is never
161
+ * reasonable is inventing a subdirectory path for a host this model does not
162
+ * recognize, which is the case this `none` exists to prevent.
163
+ *
164
+ * A `directory` that escapes the repository (any `..` segment) is refused the
165
+ * same way. One that resolves to the root itself (`"."`, `"/"`) is the root.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * // { url: "effected/kit", directory: "packages/spdx" }
170
+ * // => https://github.com/effected/kit/tree/HEAD/packages/spdx
171
+ * ```
172
+ */
173
+ get directoryUrl() {
174
+ const directory = this.directory;
175
+ if (directory === void 0) return this.browseUrl;
176
+ const segments = directory.split("/").map((segment) => segment.trim()).filter((segment) => segment !== "" && segment !== ".");
177
+ if (segments.some((segment) => segment === "..")) return Option.none();
178
+ if (segments.length === 0) return this.browseUrl;
179
+ return Option.flatMap(this.browseUrl, (url) => {
180
+ const host = /^https:\/\/([^/]+)/.exec(url)?.[1];
181
+ const path = host === void 0 ? void 0 : DIRECTORY_PATHS.get(host);
182
+ if (path === void 0) return Option.none();
183
+ return Option.some(`${url}/${path}/${segments.map((segment) => encodeURIComponent(segment)).join("/")}`);
184
+ });
185
+ }
186
+ /**
95
187
  * The `repository` field: the shorthand string or the object form, always
96
188
  * decoded to a {@link Repository}, and always re-encoded in the form it was
97
189
  * read from.
@@ -116,8 +208,8 @@ var Repository = class Repository extends Schema.Class("Repository")({
116
208
  },
117
209
  encode: (repository) => {
118
210
  const wire = repositoryWires.get(repository);
119
- if (typeof wire === "string" && wire === repository.url) return wire;
120
- if (wire !== void 0 && typeof wire !== "string") return wire;
211
+ if (typeof wire === "string" && wire === repository.url && isStringExpressibleRepository(repository)) return wire;
212
+ if (wire !== void 0 && typeof wire !== "string" && isFaithfulRepository(wire, repository)) return wire;
121
213
  return {
122
214
  ...repository.type !== void 0 && { type: repository.type },
123
215
  url: repository.url,
@@ -164,8 +256,8 @@ var Bugs = class Bugs extends Schema.Class("Bugs")({
164
256
  },
165
257
  encode: (bugs) => {
166
258
  const wire = bugsWires.get(bugs);
167
- if (typeof wire === "string" && wire === bugs.url && bugs.email === void 0) return wire;
168
- if (wire !== void 0 && typeof wire !== "string") return wire;
259
+ if (typeof wire === "string" && wire === bugs.url && isStringExpressibleBugs(bugs)) return wire;
260
+ if (wire !== void 0 && typeof wire !== "string" && isFaithfulBugs(wire, bugs)) return wire;
169
261
  return {
170
262
  ...bugs.url !== void 0 && { url: bugs.url },
171
263
  ...bugs.email !== void 0 && { email: bugs.email },
package/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { JsoncEdit, JsoncEdit as JsoncEdit$1, JsoncPath, JsoncPath as JsoncPath$
2
2
  import { CatalogResolver, DependencyKind, DependencyProtocol, DependencyProtocol as DependencyProtocol$1, DependencySpecifier, DependencySpecifierBrand, InvalidDependencySpecifierError, WorkspaceResolver, isValidDependencySpecifier } from "@effected/npm";
3
3
  import { InvalidVersionError, Range, SemVer } from "@effected/semver";
4
4
  import { Brand, Context, Effect, FileSystem, HashMap, Layer, Option, Path, Result, Schema } from "effect";
5
+ import { SpdxExpression } from "@effected/spdx";
5
6
  //#region src/Dependency.d.ts
6
7
  declare const Dependency_base: Schema.Class<Dependency, Schema.Struct<{
7
8
  /** The package name. */
@@ -20,7 +21,7 @@ declare const Dependency_base: Schema.Class<Dependency, Schema.Struct<{
20
21
  *
21
22
  * @public
22
23
  */
23
- declare class Dependency extends Dependency_base {
24
+ export declare class Dependency extends Dependency_base {
24
25
  /** The classified protocol, or `None` for an empty specifier. */
25
26
  get protocol(): Option.Option<DependencyProtocol$1>;
26
27
  /** Parse the specifier as a semver `Range`, `None` when it is not a range. */
@@ -59,7 +60,7 @@ type UnresolvedDependency = Dependency & {
59
60
  *
60
61
  * @public
61
62
  */
62
- declare const isUnresolvedDependency: <T extends {
63
+ export declare const isUnresolvedDependency: <T extends {
63
64
  readonly isUnresolved: boolean;
64
65
  }>(dependency: T) => dependency is T & {
65
66
  readonly isUnresolved: true;
@@ -79,20 +80,20 @@ declare const DevEngine_base: Schema.Class<DevEngine, Schema.Struct<{
79
80
  *
80
81
  * @public
81
82
  */
82
- declare class DevEngine extends DevEngine_base {}
83
+ export declare class DevEngine extends DevEngine_base {}
83
84
  /**
84
85
  * A `devEngines` constraint slot: a single {@link DevEngine} or an array of them.
85
86
  *
86
87
  * @public
87
88
  */
88
- declare const DevEngineOrArray: Schema.Union<[typeof DevEngine, Schema.$Array<typeof DevEngine>]>;
89
+ export declare const DevEngineOrArray: Schema.Union<[typeof DevEngine, Schema.$Array<typeof DevEngine>]>;
89
90
  /**
90
91
  * The `devEngines` field schema, modeling runtime and package-manager
91
92
  * constraints as optional {@link DevEngine} slots.
92
93
  *
93
94
  * @public
94
95
  */
95
- declare const DevEnginesSchema: Schema.Struct<{
96
+ export declare const DevEnginesSchema: Schema.Struct<{
96
97
  readonly packageManager: Schema.optionalKey<typeof DevEngineOrArray>;
97
98
  readonly runtime: Schema.optionalKey<typeof DevEngineOrArray>;
98
99
  readonly os: Schema.optionalKey<typeof DevEngineOrArray>;
@@ -149,7 +150,7 @@ declare const UnresolvedEntryPointError_base: Schema.Class<UnresolvedEntryPointE
149
150
  *
150
151
  * @public
151
152
  */
152
- declare class UnresolvedEntryPointError extends UnresolvedEntryPointError_base {
153
+ export declare class UnresolvedEntryPointError extends UnresolvedEntryPointError_base {
153
154
  get message(): string;
154
155
  }
155
156
  /**
@@ -222,7 +223,73 @@ interface EntryPointManifest {
222
223
  *
223
224
  * @public
224
225
  */
225
- declare const resolveEntryPoint: (manifest: EntryPointManifest, options?: ResolveEntryPointOptions) => Result.Result<string, UnresolvedEntryPointError>;
226
+ export declare const resolveEntryPoint: (manifest: EntryPointManifest, options?: ResolveEntryPointOptions) => Result.Result<string, UnresolvedEntryPointError>;
227
+ //#endregion
228
+ //#region src/Funding.d.ts
229
+ declare const Funding_base: Schema.Class<Funding, Schema.Struct<{
230
+ /** The funding platform, when the object form carried one (`"github"`, …). */
231
+ readonly type: Schema.optionalKey<Schema.String>;
232
+ /** Where the money goes, exactly as the manifest wrote it. */
233
+ readonly url: Schema.String;
234
+ /** Keys outside the documented set, preserved so encoding does not drop them. */
235
+ readonly rest: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
236
+ }>, {}>;
237
+ /**
238
+ * Where to send money for a package: one funding entry.
239
+ *
240
+ * @remarks
241
+ * npm's `funding` field accepts a bare URL string, this object form, or an
242
+ * array of either. `url` is **required** — it is the only thing the field
243
+ * actually says — so an object without one fails to decode rather than
244
+ * producing a half-populated entry. `type` (`"individual"`, `"github"`, …) is
245
+ * caller data and is kept **verbatim**, never normalized.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * import { Funding } from "@effected/package-json";
250
+ * import { Effect, Schema } from "effect";
251
+ *
252
+ * const program = Effect.gen(function* () {
253
+ * // Always an array, whichever encoding the manifest used.
254
+ * const entries = yield* Schema.decodeUnknownEffect(Funding.FromField)("https://example.com/sponsor");
255
+ * console.log(entries[0]?.url); // "https://example.com/sponsor"
256
+ * });
257
+ * ```
258
+ *
259
+ * @public
260
+ */
261
+ export declare class Funding extends Funding_base {
262
+ /**
263
+ * A single `funding` entry: the bare URL string or the object form, always
264
+ * decoded to a {@link Funding} and always re-encoded in the form it was read
265
+ * from.
266
+ *
267
+ * @remarks
268
+ * Provenance belongs to the instance, so an entry that is *rebuilt* rather
269
+ * than carried through has none and encodes in the canonical object form.
270
+ */
271
+ static readonly FromValue: Schema.Codec<Funding, string | {
272
+ readonly [k: string]: unknown;
273
+ }>;
274
+ /**
275
+ * The `funding` field: a lone entry or an array of them, **always** decoded
276
+ * to an array so a consumer never branches on arity.
277
+ *
278
+ * @remarks
279
+ * The normalization is one-directional. A field written bare re-encodes
280
+ * bare, not as a one-element array — the arity is remembered against the
281
+ * single entry that WAS the field, and the replay is guarded on that entry
282
+ * still being alone, so pushing a second entry into the decoded array in
283
+ * place upgrades the field to the array form instead of silently dropping
284
+ * the addition. An entry built by hand has no provenance, so an array of
285
+ * such entries encodes as an array.
286
+ */
287
+ static readonly FromField: Schema.Codec<ReadonlyArray<Funding>, string | {
288
+ readonly [k: string]: unknown;
289
+ } | ReadonlyArray<string | {
290
+ readonly [k: string]: unknown;
291
+ }>>;
292
+ }
226
293
  //#endregion
227
294
  //#region src/License.d.ts
228
295
  declare const InvalidSpdxLicenseError_base: Schema.Class<InvalidSpdxLicenseError, Schema.TaggedStruct<"InvalidSpdxLicenseError", {
@@ -237,7 +304,7 @@ declare const InvalidSpdxLicenseError_base: Schema.Class<InvalidSpdxLicenseError
237
304
  *
238
305
  * @public
239
306
  */
240
- declare class InvalidSpdxLicenseError extends InvalidSpdxLicenseError_base {
307
+ export declare class InvalidSpdxLicenseError extends InvalidSpdxLicenseError_base {
241
308
  get message(): string;
242
309
  }
243
310
  /**
@@ -246,20 +313,65 @@ declare class InvalidSpdxLicenseError extends InvalidSpdxLicenseError_base {
246
313
  *
247
314
  * @public
248
315
  */
249
- declare const isValidSpdx: (value: string) => boolean;
316
+ export declare const isValidSpdx: (value: string) => boolean;
250
317
  /**
251
318
  * A valid SPDX license identifier, expression, `UNLICENSED`, or
252
319
  * `SEE LICENSE IN <file>`.
253
320
  *
321
+ * @remarks
322
+ * **A branded value here is not necessarily parseable as SPDX.** npm's
323
+ * `license` field admits two strings that the SPDX grammar does not —
324
+ * `UNLICENSED` and `SEE LICENSE IN <file>` — and this brand accepts both,
325
+ * because it models what a manifest may legally carry, not what SPDX defines.
326
+ * Feeding a branded value straight to `SpdxExpression.parse` therefore fails
327
+ * on exactly those two forms. Do not hand-screen for them — reach for
328
+ * {@link licenseExpressionOf}, which answers "what expression is this, if any"
329
+ * and yields `Option.none()` for a spelling that is not one. Reach for
330
+ * {@link isValidSpdx} when the question is instead "may a manifest carry this".
331
+ *
254
332
  * @public
255
333
  */
256
- declare const SpdxLicense: Schema.brand<Schema.String, "SpdxLicense">;
334
+ export declare const SpdxLicense: Schema.brand<Schema.String, "SpdxLicense">;
257
335
  /**
258
336
  * A branded SPDX license string.
259
337
  *
260
338
  * @public
261
339
  */
262
- type SpdxLicense = string & Brand.Brand<"SpdxLicense">;
340
+ export type SpdxLicense = string & Brand.Brand<"SpdxLicense">;
341
+ /**
342
+ * The parsed SPDX expression a manifest's `license` denotes, or `Option.none()`
343
+ * when it denotes no expression at all.
344
+ *
345
+ * @remarks
346
+ * This is the accessor to reach for whenever a branded `SpdxLicense` has
347
+ * to become an actual expression — a license URL, a badge, structured data, a
348
+ * policy check. It exists because the brand and the grammar disagree, and that
349
+ * disagreement is knowledge these two packages jointly own rather than
350
+ * something each consumer should rediscover.
351
+ *
352
+ * `UNLICENSED` and `SEE LICENSE IN <file>` are legal in a manifest and are not
353
+ * SPDX expressions, so they yield `Option.none()`. Everything else parses.
354
+ * A consumer screening for those two spellings by hand gets it wrong the day
355
+ * npm admits a third — this accessor is the mechanism that prose could not be,
356
+ * and it needs no change on that day, because "not an expression" is answered
357
+ * by the grammar rather than by a list of spellings kept in step with npm.
358
+ *
359
+ * @example
360
+ * ```ts
361
+ * import { licenseExpressionOf } from "@effected/package-json";
362
+ * import { SpdxExpression } from "@effected/spdx";
363
+ *
364
+ * // "MIT" => Option.some(<LicenseNode MIT>)
365
+ * // "UNLICENSED" => Option.none()
366
+ * // "SEE LICENSE IN LICENSE.txt" => Option.none()
367
+ * ```
368
+ *
369
+ * @param license - a branded manifest license value
370
+ * @returns the parsed expression, or none for a spelling that is not one
371
+ *
372
+ * @public
373
+ */
374
+ export declare const licenseExpressionOf: (license: SpdxLicense) => Option.Option<SpdxExpression>;
263
375
  //#endregion
264
376
  //#region src/PackageManager.d.ts
265
377
  declare const PackageManager_base: Schema.Class<PackageManager, Schema.Struct<{
@@ -325,7 +437,7 @@ declare const PackageManager_base: Schema.Class<PackageManager, Schema.Struct<{
325
437
  *
326
438
  * @public
327
439
  */
328
- declare class PackageManager extends PackageManager_base {
440
+ export declare class PackageManager extends PackageManager_base {
329
441
  /**
330
442
  * Schema transformation between the `"name@version+integrity"` string and a
331
443
  * {@link PackageManager}.
@@ -357,7 +469,7 @@ declare const InvalidPackageNameError_base: Schema.Class<InvalidPackageNameError
357
469
  *
358
470
  * @public
359
471
  */
360
- declare class InvalidPackageNameError extends InvalidPackageNameError_base {
472
+ export declare class InvalidPackageNameError extends InvalidPackageNameError_base {
361
473
  get message(): string;
362
474
  }
363
475
  /**
@@ -365,31 +477,31 @@ declare class InvalidPackageNameError extends InvalidPackageNameError_base {
365
477
  *
366
478
  * @public
367
479
  */
368
- declare const ScopedPackageName: Schema.brand<Schema.String, "ScopedPackageName">;
480
+ export declare const ScopedPackageName: Schema.brand<Schema.String, "ScopedPackageName">;
369
481
  /**
370
482
  * A valid npm scoped package name.
371
483
  *
372
484
  * @public
373
485
  */
374
- type ScopedPackageName = string & Brand.Brand<"ScopedPackageName">;
486
+ export type ScopedPackageName = string & Brand.Brand<"ScopedPackageName">;
375
487
  /**
376
488
  * A valid npm unscoped package name (no `@scope/` prefix).
377
489
  *
378
490
  * @public
379
491
  */
380
- declare const UnscopedPackageName: Schema.brand<Schema.String, "UnscopedPackageName">;
492
+ export declare const UnscopedPackageName: Schema.brand<Schema.String, "UnscopedPackageName">;
381
493
  /**
382
494
  * A valid npm unscoped package name.
383
495
  *
384
496
  * @public
385
497
  */
386
- type UnscopedPackageName = string & Brand.Brand<"UnscopedPackageName">;
498
+ export type UnscopedPackageName = string & Brand.Brand<"UnscopedPackageName">;
387
499
  /**
388
500
  * A valid npm package name, scoped or unscoped.
389
501
  *
390
502
  * @public
391
503
  */
392
- type PackageName = ScopedPackageName | UnscopedPackageName;
504
+ export type PackageName = ScopedPackageName | UnscopedPackageName;
393
505
  /**
394
506
  * The union of `ScopedPackageName` and `UnscopedPackageName`,
395
507
  * carrying the classification statics (`PackageName.isValid` and friends)
@@ -398,7 +510,7 @@ type PackageName = ScopedPackageName | UnscopedPackageName;
398
510
  *
399
511
  * @public
400
512
  */
401
- declare const PackageName: Schema.Union<readonly [Schema.brand<Schema.String, "ScopedPackageName">, Schema.brand<Schema.String, "UnscopedPackageName">]> & {
513
+ export declare const PackageName: Schema.Union<readonly [Schema.brand<Schema.String, "ScopedPackageName">, Schema.brand<Schema.String, "UnscopedPackageName">]> & {
402
514
  isValid: (name: string) => boolean;
403
515
  scope: (name: string) => Option.Option<string>;
404
516
  unscoped: (name: string) => string;
@@ -422,7 +534,7 @@ declare const Person_base: Schema.Class<Person, Schema.Struct<{
422
534
  *
423
535
  * @public
424
536
  */
425
- declare class Person extends Person_base {
537
+ export declare class Person extends Person_base {
426
538
  /**
427
539
  * The object wire codec: an open JSON object ↔ a {@link Person}, partitioning
428
540
  * unknown keys into `rest` and flattening them back on encode so the on-disk
@@ -497,7 +609,7 @@ declare const Repository_base: Schema.Class<Repository, Schema.Struct<{
497
609
  *
498
610
  * @public
499
611
  */
500
- declare class Repository extends Repository_base {
612
+ export declare class Repository extends Repository_base {
501
613
  /**
502
614
  * The browsable `https://` URL, or `Option.none()` when `url` is not a form
503
615
  * this model recognizes.
@@ -505,6 +617,48 @@ declare class Repository extends Repository_base {
505
617
  get browseUrl(): Option.Option<string>;
506
618
  /** The canonical https clone URL, or none when it cannot be derived. */
507
619
  get gitUrl(): Option.Option<string>;
620
+ /**
621
+ * The browsable URL of **this package** — {@link Repository.browseUrl}
622
+ * descended into `directory` when the package is a monorepo
623
+ * member.
624
+ *
625
+ * @remarks
626
+ * Prefer this over `browseUrl` whenever the question is "where does this
627
+ * package live". For a monorepo, `browseUrl` answers with the repository
628
+ * root, so every member of the repository reports the same location — which
629
+ * matters because that URL is exactly what a consumer (a docs site's
630
+ * structured data, say) uses to tell two packages apart.
631
+ *
632
+ * The three outcomes are deliberately distinct:
633
+ *
634
+ * - **No `directory`** — the package *is* the repository root, so this is
635
+ * `browseUrl`. A correct answer, not a missing one.
636
+ * - **`directory` on a host this model knows** (GitHub, GitLab, Bitbucket) —
637
+ * the descended URL.
638
+ * - **`directory` on any other host** — `Option.none()`. The path convention
639
+ * for browsing a subdirectory is per-forge and cannot be guessed, and
640
+ * fabricating one would produce a URL that resolves to nothing while
641
+ * looking authoritative.
642
+ *
643
+ * What to do with that `none` is a policy this getter deliberately leaves to
644
+ * the caller, because it depends on what is being filled in. Falling back to
645
+ * {@link Repository.browseUrl} is reasonable wherever a less precise answer
646
+ * beats no answer — the repository root is a *true* location for the package,
647
+ * merely one that does not distinguish it from its siblings. Omit the value
648
+ * instead wherever that lack of distinction is the whole point. What is never
649
+ * reasonable is inventing a subdirectory path for a host this model does not
650
+ * recognize, which is the case this `none` exists to prevent.
651
+ *
652
+ * A `directory` that escapes the repository (any `..` segment) is refused the
653
+ * same way. One that resolves to the root itself (`"."`, `"/"`) is the root.
654
+ *
655
+ * @example
656
+ * ```ts
657
+ * // { url: "effected/kit", directory: "packages/spdx" }
658
+ * // => https://github.com/effected/kit/tree/HEAD/packages/spdx
659
+ * ```
660
+ */
661
+ get directoryUrl(): Option.Option<string>;
508
662
  /**
509
663
  * The `repository` field: the shorthand string or the object form, always
510
664
  * decoded to a {@link Repository}, and always re-encoded in the form it was
@@ -531,7 +685,7 @@ declare const Bugs_base: Schema.Class<Bugs, Schema.Struct<{
531
685
  *
532
686
  * @public
533
687
  */
534
- declare class Bugs extends Bugs_base {
688
+ export declare class Bugs extends Bugs_base {
535
689
  /** The `bugs` field: a URL string or the object form. */
536
690
  static readonly FromValue: Schema.Codec<Bugs, string | {
537
691
  readonly [k: string]: unknown;
@@ -546,7 +700,7 @@ declare class Bugs extends Bugs_base {
546
700
  *
547
701
  * @public
548
702
  */
549
- declare const DependencyMapField: Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>, never, never>;
703
+ export declare const DependencyMapField: Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>, never, never>;
550
704
  /**
551
705
  * A string→string map field decoding a plain JSON object to a `HashMap`,
552
706
  * with no default (an absent key stays absent). Backs `engines`. Not meant to
@@ -554,21 +708,21 @@ declare const DependencyMapField: Schema.decodeTo<Schema.HashMap<Schema.String,
554
708
  *
555
709
  * @public
556
710
  */
557
- declare const StringMapField: Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.$Record<Schema.String, Schema.String>, never, never>;
711
+ export declare const StringMapField: Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.$Record<Schema.String, Schema.String>, never, never>;
558
712
  /**
559
713
  * The `bin` field: a single string path or a name→path map. Not meant to be
560
714
  * referenced directly.
561
715
  *
562
716
  * @public
563
717
  */
564
- declare const BinField: Schema.Union<readonly [Schema.String, Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.$Record<Schema.String, Schema.String>, never, never>]>;
718
+ export declare const BinField: Schema.Union<readonly [Schema.String, Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.$Record<Schema.String, Schema.String>, never, never>]>;
565
719
  /**
566
720
  * The `exports` field: a single string entry point or an open object of
567
721
  * conditional exports. Not meant to be referenced directly.
568
722
  *
569
723
  * @public
570
724
  */
571
- declare const ExportsField: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>;
725
+ export declare const ExportsField: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>;
572
726
  /**
573
727
  * The `publishConfig` field: an open record preserving known npm keys
574
728
  * (`access`, `directory`, ...) plus extensions like `targets`. Not meant to be
@@ -576,14 +730,14 @@ declare const ExportsField: Schema.Union<readonly [Schema.String, Schema.$Record
576
730
  *
577
731
  * @public
578
732
  */
579
- declare const PublishConfigField: Schema.$Record<Schema.String, Schema.Unknown>;
733
+ export declare const PublishConfigField: Schema.$Record<Schema.String, Schema.Unknown>;
580
734
  /**
581
735
  * The `peerDependenciesMeta` field: a map of package name to `{ optional? }`.
582
736
  * Not meant to be referenced directly.
583
737
  *
584
738
  * @public
585
739
  */
586
- declare const PeerDependenciesMetaField: Schema.$Record<Schema.String, Schema.Struct<{
740
+ export declare const PeerDependenciesMetaField: Schema.$Record<Schema.String, Schema.Struct<{
587
741
  readonly optional: Schema.optionalKey<Schema.Boolean>;
588
742
  }>>;
589
743
  /**
@@ -596,7 +750,7 @@ declare const PeerDependenciesMetaField: Schema.$Record<Schema.String, Schema.St
596
750
  *
597
751
  * @public
598
752
  */
599
- declare const RepositoryField: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>;
753
+ export declare const RepositoryField: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>;
600
754
  declare const PackageDecodeError_base: Schema.Class<PackageDecodeError, Schema.TaggedStruct<"PackageDecodeError", {
601
755
  /** The underlying `SchemaError`, preserved structurally rather than stringified. */
602
756
  readonly cause: Schema.Defect;
@@ -610,7 +764,7 @@ declare const PackageDecodeError_base: Schema.Class<PackageDecodeError, Schema.T
610
764
  *
611
765
  * @public
612
766
  */
613
- declare class PackageDecodeError extends PackageDecodeError_base {
767
+ export declare class PackageDecodeError extends PackageDecodeError_base {
614
768
  get message(): string;
615
769
  }
616
770
  /**
@@ -681,6 +835,11 @@ declare const Package_base: Schema.Class<Package, Schema.Struct<{
681
835
  readonly bugs: Schema.optionalKey<Schema.Codec<Bugs, string | {
682
836
  readonly [k: string]: unknown;
683
837
  }, never, never>>;
838
+ readonly funding: Schema.optionalKey<Schema.Codec<readonly Funding[], string | readonly (string | {
839
+ readonly [k: string]: unknown;
840
+ })[] | {
841
+ readonly [k: string]: unknown;
842
+ }, never, never>>;
684
843
  readonly homepage: Schema.optionalKey<Schema.String>;
685
844
  readonly dependencies: Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>, never, never>;
686
845
  readonly devDependencies: Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>, never, never>;
@@ -723,7 +882,7 @@ declare const Package_base: Schema.Class<Package, Schema.Struct<{
723
882
  *
724
883
  * @public
725
884
  */
726
- declare class Package extends Package_base {
885
+ export declare class Package extends Package_base {
727
886
  pipe<A>(this: A): A;
728
887
  pipe<A, B>(this: A, ab: (_: A) => B): B;
729
888
  pipe<A, B, C>(this: A, ab: (_: A) => B, bc: (_: B) => C): C;
@@ -886,7 +1045,7 @@ declare const PackageJsonSyntaxError_base: Schema.Class<PackageJsonSyntaxError,
886
1045
  *
887
1046
  * @public
888
1047
  */
889
- declare class PackageJsonSyntaxError extends PackageJsonSyntaxError_base {
1048
+ export declare class PackageJsonSyntaxError extends PackageJsonSyntaxError_base {
890
1049
  get message(): string;
891
1050
  }
892
1051
  /**
@@ -936,7 +1095,7 @@ declare const PackageJsonModifyError_base: Schema.Class<PackageJsonModifyError,
936
1095
  *
937
1096
  * @public
938
1097
  */
939
- declare class PackageJsonModifyError extends PackageJsonModifyError_base {
1098
+ export declare class PackageJsonModifyError extends PackageJsonModifyError_base {
940
1099
  get message(): string;
941
1100
  }
942
1101
  /**
@@ -958,7 +1117,7 @@ declare class PackageJsonModifyError extends PackageJsonModifyError_base {
958
1117
  *
959
1118
  * @public
960
1119
  */
961
- declare class PackageJsonFormat {
1120
+ export declare class PackageJsonFormat {
962
1121
  private constructor();
963
1122
  /**
964
1123
  * Order a package.json object's keys canonically **without decoding it into
@@ -1112,6 +1271,7 @@ declare const LenientManifest_base: Schema.Class<LenientManifest, Schema.Struct<
1112
1271
  readonly keywords: Schema.optionalKey<Schema.$Array<Schema.String>>;
1113
1272
  readonly repository: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>>;
1114
1273
  readonly bugs: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>>;
1274
+ readonly funding: Schema.optionalKey<Schema.Union<readonly [Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Unknown>]>>]>>;
1115
1275
  readonly homepage: Schema.optionalKey<Schema.String>;
1116
1276
  readonly dependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
1117
1277
  readonly devDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
@@ -1185,7 +1345,7 @@ declare const LenientManifest_base: Schema.Class<LenientManifest, Schema.Struct<
1185
1345
  *
1186
1346
  * @public
1187
1347
  */
1188
- declare class LenientManifest extends LenientManifest_base {
1348
+ export declare class LenientManifest extends LenientManifest_base {
1189
1349
  /**
1190
1350
  * Decode an unknown JSON value leniently, degrading malformed fields instead
1191
1351
  * of failing the document. The sync primitive backing
@@ -1293,7 +1453,7 @@ declare const PackageManagerRange_base: Schema.Class<PackageManagerRange, Schema
1293
1453
  *
1294
1454
  * @public
1295
1455
  */
1296
- declare class PackageManagerRange extends PackageManagerRange_base {
1456
+ export declare class PackageManagerRange extends PackageManagerRange_base {
1297
1457
  /**
1298
1458
  * Schema transformation between the `"name@range[+integrity]"` string and a
1299
1459
  * {@link PackageManagerRange}.
@@ -1343,6 +1503,11 @@ declare const PackageManifest_base: Schema.Class<PackageManifest, Schema.Struct<
1343
1503
  readonly bugs: Schema.optionalKey<Schema.Codec<Bugs, string | {
1344
1504
  readonly [k: string]: unknown;
1345
1505
  }, never, never>>;
1506
+ readonly funding: Schema.optionalKey<Schema.Codec<readonly Funding[], string | readonly (string | {
1507
+ readonly [k: string]: unknown;
1508
+ })[] | {
1509
+ readonly [k: string]: unknown;
1510
+ }, never, never>>;
1346
1511
  readonly homepage: Schema.optionalKey<Schema.String>;
1347
1512
  readonly dependencies: Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>, never, never>;
1348
1513
  readonly devDependencies: Schema.decodeTo<Schema.HashMap<Schema.String, Schema.String>, Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>, never, never>;
@@ -1416,7 +1581,7 @@ declare const PackageManifest_base: Schema.Class<PackageManifest, Schema.Struct<
1416
1581
  *
1417
1582
  * @public
1418
1583
  */
1419
- declare class PackageManifest extends PackageManifest_base {
1584
+ export declare class PackageManifest extends PackageManifest_base {
1420
1585
  /**
1421
1586
  * The wire codec: an open JSON object ↔ a {@link PackageManifest} instance,
1422
1587
  * partitioning unknown keys into `rest` and flattening them back on encode —
@@ -1460,7 +1625,7 @@ declare const PackageJsonReadError_base: Schema.Class<PackageJsonReadError, Sche
1460
1625
  *
1461
1626
  * @public
1462
1627
  */
1463
- declare class PackageJsonReadError extends PackageJsonReadError_base {
1628
+ export declare class PackageJsonReadError extends PackageJsonReadError_base {
1464
1629
  get message(): string;
1465
1630
  }
1466
1631
  declare const PackageJsonNotFoundError_base: Schema.Class<PackageJsonNotFoundError, Schema.TaggedStruct<"PackageJsonNotFoundError", {
@@ -1473,7 +1638,7 @@ declare const PackageJsonNotFoundError_base: Schema.Class<PackageJsonNotFoundErr
1473
1638
  *
1474
1639
  * @public
1475
1640
  */
1476
- declare class PackageJsonNotFoundError extends PackageJsonNotFoundError_base {
1641
+ export declare class PackageJsonNotFoundError extends PackageJsonNotFoundError_base {
1477
1642
  get message(): string;
1478
1643
  }
1479
1644
  declare const PackageJsonParseError_base: Schema.Class<PackageJsonParseError, Schema.TaggedStruct<"PackageJsonParseError", {
@@ -1487,7 +1652,7 @@ declare const PackageJsonParseError_base: Schema.Class<PackageJsonParseError, Sc
1487
1652
  *
1488
1653
  * @public
1489
1654
  */
1490
- declare class PackageJsonParseError extends PackageJsonParseError_base {
1655
+ export declare class PackageJsonParseError extends PackageJsonParseError_base {
1491
1656
  get message(): string;
1492
1657
  }
1493
1658
  declare const PackageJsonWriteError_base: Schema.Class<PackageJsonWriteError, Schema.TaggedStruct<"PackageJsonWriteError", {
@@ -1503,7 +1668,7 @@ declare const PackageJsonWriteError_base: Schema.Class<PackageJsonWriteError, Sc
1503
1668
  *
1504
1669
  * @public
1505
1670
  */
1506
- declare class PackageJsonWriteError extends PackageJsonWriteError_base {
1671
+ export declare class PackageJsonWriteError extends PackageJsonWriteError_base {
1507
1672
  get message(): string;
1508
1673
  }
1509
1674
  /**
@@ -1591,7 +1756,7 @@ declare const PackageJsonFile_base: Context.ServiceClass<PackageJsonFile, "@effe
1591
1756
  *
1592
1757
  * @public
1593
1758
  */
1594
- declare class PackageJsonFile extends PackageJsonFile_base {
1759
+ export declare class PackageJsonFile extends PackageJsonFile_base {
1595
1760
  /** Build the service implementation from `FileSystem` / `Path` in context; use {@link PackageJsonFile.layer} to provide it. */
1596
1761
  static readonly make: Effect.Effect<PackageJsonFileShape, never, FileSystem.FileSystem | Path.Path>;
1597
1762
  /**
@@ -1641,7 +1806,7 @@ declare const PackageValidationError_base: Schema.Class<PackageValidationError,
1641
1806
  *
1642
1807
  * @public
1643
1808
  */
1644
- declare class PackageValidationError extends PackageValidationError_base {
1809
+ export declare class PackageValidationError extends PackageValidationError_base {
1645
1810
  get message(): string;
1646
1811
  }
1647
1812
  /**
@@ -1650,21 +1815,21 @@ declare class PackageValidationError extends PackageValidationError_base {
1650
1815
  *
1651
1816
  * @public
1652
1817
  */
1653
- declare const noUnresolvedDepsRule: ValidationRule;
1818
+ export declare const noUnresolvedDepsRule: ValidationRule;
1654
1819
  /**
1655
1820
  * A rule that fails when any dependency uses a local `file:`, `link:` or
1656
1821
  * `portal:` specifier.
1657
1822
  *
1658
1823
  * @public
1659
1824
  */
1660
- declare const noLocalDepsRule: ValidationRule;
1825
+ export declare const noLocalDepsRule: ValidationRule;
1661
1826
  /**
1662
1827
  * The default validation rules: license, description, repository and
1663
1828
  * not-private.
1664
1829
  *
1665
1830
  * @public
1666
1831
  */
1667
- declare const defaultRules: ReadonlyArray<ValidationRule>;
1832
+ export declare const defaultRules: ReadonlyArray<ValidationRule>;
1668
1833
  declare const PackageValidator_base: Context.ServiceClass<PackageValidator, "@effected/package-json/PackageValidator", {
1669
1834
  readonly validate: (pkg: Package) => Effect.Effect<void, PackageValidationError>;
1670
1835
  }>;
@@ -1686,7 +1851,7 @@ declare const PackageValidator_base: Context.ServiceClass<PackageValidator, "@ef
1686
1851
  *
1687
1852
  * @public
1688
1853
  */
1689
- declare class PackageValidator extends PackageValidator_base {
1854
+ export declare class PackageValidator extends PackageValidator_base {
1690
1855
  /** The default layer, backed by {@link defaultRules}. */
1691
1856
  static readonly layer: Layer.Layer<PackageValidator>;
1692
1857
  /**
@@ -1700,5 +1865,5 @@ declare class PackageValidator extends PackageValidator_base {
1700
1865
  }): Layer.Layer<PackageValidator>;
1701
1866
  }
1702
1867
  //#endregion
1703
- 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 };
1868
+ export { type DependencyKind, type DependencyProtocol, DependencySpecifier, type DependencySpecifierBrand, type DevEngines, type EntryPointManifest, InvalidDependencySpecifierError, JsoncEdit, type JsoncPath, type LenientFieldIssue, type PackageFieldEdit, type PackageFormatOptions, type PackageFormatTextOptions, type PackageIndent, type PackageJsonFileShape, type PackagePatch, type ResolveEntryPointOptions, type RuleFailure, type UnresolvedDependency, type ValidationRule, isValidDependencySpecifier };
1704
1869
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Dependency, isUnresolvedDependency } from "./Dependency.js";
2
2
  import { DevEngine, DevEngineOrArray, DevEnginesSchema } from "./DevEngines.js";
3
3
  import { UnresolvedEntryPointError, resolveEntryPoint } from "./EntryPoint.js";
4
- import { InvalidSpdxLicenseError, SpdxLicense, isValidSpdx } from "./License.js";
4
+ import { Funding } from "./Funding.js";
5
+ import { InvalidSpdxLicenseError, SpdxLicense, isValidSpdx, licenseExpressionOf } from "./License.js";
5
6
  import { PackageManager } from "./PackageManager.js";
6
7
  import { InvalidPackageNameError, PackageName, ScopedPackageName, UnscopedPackageName } from "./PackageName.js";
7
8
  import { Person } from "./Person.js";
@@ -16,4 +17,4 @@ import { PackageValidationError, PackageValidator, defaultRules, noLocalDepsRule
16
17
  import { JsoncEdit } from "@effected/jsonc";
17
18
  import { DependencySpecifier, InvalidDependencySpecifierError, isValidDependencySpecifier } from "@effected/npm";
18
19
 
19
- export { BinField, Bugs, Dependency, DependencyMapField, DependencySpecifier, DevEngine, DevEngineOrArray, DevEnginesSchema, ExportsField, InvalidDependencySpecifierError, InvalidPackageNameError, InvalidSpdxLicenseError, JsoncEdit, LenientManifest, 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 };
20
+ export { BinField, Bugs, Dependency, DependencyMapField, DependencySpecifier, DevEngine, DevEngineOrArray, DevEnginesSchema, ExportsField, Funding, InvalidDependencySpecifierError, InvalidPackageNameError, InvalidSpdxLicenseError, JsoncEdit, LenientManifest, 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, licenseExpressionOf, noLocalDepsRule, noUnresolvedDepsRule, resolveEntryPoint };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/package-json",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "private": false,
5
5
  "description": "package.json parsing, editing, validation and file IO as Effect schemas.",
6
6
  "keywords": [
@@ -38,13 +38,13 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "dependencies": {
41
- "@effected/jsonc": "^0.8.0",
42
- "@effected/npm": "^0.12.0",
43
- "@effected/semver": "^0.5.0",
44
- "@effected/spdx": "^0.4.0"
41
+ "@effected/jsonc": "^0.9.0",
42
+ "@effected/npm": "^0.13.0",
43
+ "@effected/semver": "^0.6.0",
44
+ "@effected/spdx": "^0.6.0"
45
45
  },
46
46
  "peerDependencies": {
47
- "effect": "4.0.0-rc.109"
47
+ "effect": "4.0.0-rc.112"
48
48
  },
49
49
  "engines": {
50
50
  "node": ">=24.11.0"