runtime-resolver 0.3.21 → 1.0.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 (68) hide show
  1. package/README.md +34 -35
  2. package/bin/runtime-resolver.js +12 -31
  3. package/command.js +120 -0
  4. package/layers.js +61 -0
  5. package/output.js +55 -0
  6. package/package.json +6 -18
  7. package/report.js +24 -0
  8. package/cli/commands/resolve.js +0 -242
  9. package/cli/schemas/json-schema.js +0 -12
  10. package/cli/schemas/response.js +0 -86
  11. package/data/bun-defaults.js +0 -850
  12. package/data/deno-defaults.js +0 -1534
  13. package/data/node-defaults.js +0 -4430
  14. package/errors/AuthenticationError.js +0 -35
  15. package/errors/CacheError.js +0 -32
  16. package/errors/FreshnessError.js +0 -38
  17. package/errors/InvalidInputError.js +0 -33
  18. package/errors/NetworkError.js +0 -34
  19. package/errors/ParseError.js +0 -33
  20. package/errors/RateLimitError.js +0 -37
  21. package/errors/VersionNotFoundError.js +0 -37
  22. package/index.d.ts +0 -2575
  23. package/index.js +0 -166
  24. package/layers/AutoBunCacheLive.js +0 -47
  25. package/layers/AutoDenoCacheLive.js +0 -47
  26. package/layers/AutoNodeCacheLive.js +0 -58
  27. package/layers/BunReleaseCacheLive.js +0 -25
  28. package/layers/BunResolverLive.js +0 -85
  29. package/layers/BunVersionFetcherLive.js +0 -55
  30. package/layers/DenoReleaseCacheLive.js +0 -25
  31. package/layers/DenoResolverLive.js +0 -84
  32. package/layers/DenoVersionFetcherLive.js +0 -51
  33. package/layers/FreshBunCacheLive.js +0 -60
  34. package/layers/FreshDenoCacheLive.js +0 -60
  35. package/layers/FreshNodeCacheLive.js +0 -55
  36. package/layers/GitHubAppAuth.js +0 -58
  37. package/layers/GitHubAutoAuth.js +0 -70
  38. package/layers/GitHubClientLive.js +0 -130
  39. package/layers/GitHubTokenAuth.js +0 -50
  40. package/layers/NodeReleaseCacheLive.js +0 -77
  41. package/layers/NodeResolverLive.js +0 -107
  42. package/layers/NodeScheduleFetcherLive.js +0 -37
  43. package/layers/NodeVersionFetcherLive.js +0 -55
  44. package/layers/OfflineBunCacheLive.js +0 -40
  45. package/layers/OfflineDenoCacheLive.js +0 -40
  46. package/layers/OfflineNodeCacheLive.js +0 -39
  47. package/layers/RuntimeCacheLive.js +0 -78
  48. package/lib/retry.js +0 -27
  49. package/lib/semver.js +0 -21
  50. package/schemas/bun-release.js +0 -63
  51. package/schemas/deno-release.js +0 -63
  52. package/schemas/github.js +0 -74
  53. package/schemas/node-release.js +0 -133
  54. package/schemas/node-schedule.js +0 -110
  55. package/schemas/node.js +0 -68
  56. package/services/BunReleaseCache.js +0 -33
  57. package/services/BunResolver.js +0 -36
  58. package/services/BunVersionFetcher.js +0 -41
  59. package/services/DenoReleaseCache.js +0 -33
  60. package/services/DenoResolver.js +0 -36
  61. package/services/DenoVersionFetcher.js +0 -41
  62. package/services/GitHubClient.js +0 -40
  63. package/services/NodeReleaseCache.js +0 -41
  64. package/services/NodeResolver.js +0 -44
  65. package/services/NodeScheduleFetcher.js +0 -38
  66. package/services/NodeVersionFetcher.js +0 -39
  67. package/services/OctokitInstance.js +0 -44
  68. package/tsdoc-metadata.json +0 -11
package/index.d.ts DELETED
@@ -1,2575 +0,0 @@
1
- import { Context, DateTime, Effect, Layer, Option, Ref, Schema } from "effect";
2
- import { EmptyCacheError, InvalidRangeError, InvalidVersionError, SemVer, UnsatisfiedRangeError, VersionCache } from "semver-effect";
3
-
4
- //#region src/schemas/common.d.ts
5
- /**
6
- * Discriminates which JavaScript runtime a resolver targets.
7
- *
8
- * @see {@link resolveNode}
9
- * @see {@link resolveBun}
10
- * @see {@link resolveDeno}
11
- *
12
- * @public
13
- */
14
- declare const Runtime: Schema.Literal<["node", "bun", "deno"]>;
15
- /**
16
- * Discriminates which JavaScript runtime a resolver targets.
17
- *
18
- * @see {@link resolveNode}
19
- * @see {@link resolveBun}
20
- * @see {@link resolveDeno}
21
- *
22
- * @public
23
- */
24
- type Runtime = typeof Runtime.Type;
25
- /**
26
- * Indicates whether a `ResolvedVersions` result was served from
27
- * a live API call or a local cache.
28
- *
29
- * @public
30
- */
31
- declare const Source: Schema.Literal<["api", "cache"]>;
32
- /**
33
- * Indicates whether a `ResolvedVersions` result was served from
34
- * a live API call or a local cache.
35
- *
36
- * @public
37
- */
38
- type Source = typeof Source.Type;
39
- /**
40
- * The primary return type produced by every runtime resolver.
41
- *
42
- * Contains the full list of matching versions, the latest version string, and
43
- * optional `lts` / `default` version strings depending on the runtime.
44
- * The `source` field indicates whether the data came from a live API call or
45
- * a cached snapshot.
46
- *
47
- * @see {@link resolveNode}
48
- * @see {@link resolveBun}
49
- * @see {@link resolveDeno}
50
- *
51
- * @example
52
- * ```typescript
53
- * import { Effect } from "effect";
54
- * import type { ResolvedVersions } from "./common.js";
55
- * import { resolveNode } from "../resolvers/node.js";
56
- *
57
- * const program: Effect.Effect<ResolvedVersions> = resolveNode(">=20");
58
- *
59
- * Effect.runPromise(program).then((result: ResolvedVersions) => {
60
- * console.log(result.latest); // e.g. "22.3.0"
61
- * console.log(result.source); // "api" | "cache"
62
- * console.log(result.versions); // ["22.3.0", "22.2.0", ...]
63
- * });
64
- * ```
65
- *
66
- * @public
67
- */
68
- declare const ResolvedVersions: Schema.Struct<{
69
- source: Schema.Literal<["api", "cache"]>;
70
- versions: Schema.Array$<typeof Schema.String>;
71
- latest: typeof Schema.String;
72
- lts: Schema.optional<typeof Schema.String>;
73
- default: Schema.optional<typeof Schema.String>;
74
- }>;
75
- /**
76
- * The primary return type produced by every runtime resolver.
77
- *
78
- * @see {@link resolveNode}
79
- * @see {@link resolveBun}
80
- * @see {@link resolveDeno}
81
- *
82
- * @public
83
- */
84
- type ResolvedVersions = typeof ResolvedVersions.Type;
85
- /**
86
- * Lifecycle phase of a Node.js major release line, derived from the official
87
- * Node.js release schedule.
88
- *
89
- * - `"current"` — actively receiving features and bug fixes.
90
- * - `"active-lts"` — Long-Term Support; stable, receiving only bug and
91
- * security fixes.
92
- * - `"maintenance-lts"` — critical security fixes only.
93
- * - `"end-of-life"` — no longer maintained.
94
- *
95
- * @see {@link NodeRelease.phase}
96
- *
97
- * @public
98
- */
99
- declare const NodePhase: Schema.Literal<["current", "active-lts", "maintenance-lts", "end-of-life"]>;
100
- /**
101
- * Lifecycle phase of a Node.js major release line.
102
- *
103
- * @see {@link NodeRelease.phase}
104
- *
105
- * @public
106
- */
107
- type NodePhase = typeof NodePhase.Type;
108
- /**
109
- * Controls the granularity at which matching versions are grouped when a
110
- * resolver returns multiple results.
111
- *
112
- * - `"latest"` — return only the single highest matching version.
113
- * - `"minor"` — return the latest patch for every minor line.
114
- * - `"patch"` — return every individual patch release.
115
- *
116
- * @public
117
- */
118
- declare const Increments: Schema.Literal<["latest", "minor", "patch"]>;
119
- /**
120
- * Controls the granularity at which matching versions are grouped.
121
- *
122
- * @public
123
- */
124
- type Increments = typeof Increments.Type;
125
- //#endregion
126
- //#region src/errors/VersionNotFoundError.d.ts
127
- declare const VersionNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
128
- readonly _tag: "VersionNotFoundError";
129
- } & Readonly<A>;
130
- /**
131
- * Raised when no published version satisfies the requested constraint.
132
- *
133
- * This error is produced by {@link NodeResolver}, {@link BunResolver}, and
134
- * {@link DenoResolver} after the full list of available versions has been
135
- * fetched and filtered but no entry matches the caller-supplied semver
136
- * constraint. The `runtime` field identifies which runtime was queried and
137
- * `constraint` echoes the range string that was provided.
138
- *
139
- * @see {@link NodeResolver}
140
- * @see {@link BunResolver}
141
- * @see {@link DenoResolver}
142
- *
143
- * @example
144
- * ```typescript
145
- * import { Effect } from "effect";
146
- * import type { VersionNotFoundError } from "./VersionNotFoundError.js";
147
- * import { resolveNode } from "../resolvers/node.js";
148
- *
149
- * const program = resolveNode(">=999").pipe(
150
- * Effect.catchTag("VersionNotFoundError", (err: VersionNotFoundError) =>
151
- * Effect.logError(
152
- * `No ${err.runtime} version matched "${err.constraint}": ${err.message}`
153
- * ).pipe(Effect.andThen(Effect.fail(err)))
154
- * )
155
- * );
156
- * ```
157
- *
158
- * @public
159
- */
160
- declare class VersionNotFoundError extends VersionNotFoundError_base<{
161
- readonly runtime: Runtime;
162
- readonly constraint: string;
163
- readonly message: string;
164
- }> {}
165
- //#endregion
166
- //#region src/services/BunResolver.d.ts
167
- /**
168
- * Options accepted by `BunResolver.resolve`.
169
- *
170
- * All fields are optional; omitting them causes the resolver to fall back to
171
- * its built-in defaults (latest stable release, `"latest"` increment
172
- * granularity).
173
- *
174
- * @see {@link BunResolver}
175
- * @see {@link (Increments:type)}
176
- * @see {@link (ResolvedVersions:type)}
177
- *
178
- * @public
179
- */
180
- interface BunResolverOptions {
181
- /**
182
- * A semver range string used to constrain which Bun releases are
183
- * considered (e.g. `"^1.0.0"` or `">=1.1.0 <2.0.0"`).
184
- *
185
- * When omitted all cached releases are eligible.
186
- */
187
- readonly semverRange?: string;
188
- /**
189
- * A fallback version string returned when no release satisfies
190
- * `semverRange`. Must be a valid semver version (e.g. `"1.0.0"`).
191
- *
192
- * When omitted and no match is found the effect fails with
193
- * {@link VersionNotFoundError}.
194
- */
195
- readonly defaultVersion?: string;
196
- /**
197
- * Controls the granularity of the version list included in
198
- * the `versions` field of {@link (ResolvedVersions:type)}.
199
- *
200
- * - `"latest"` — only the single highest matching version.
201
- * - `"minor"` — the latest patch for every minor line.
202
- * - `"patch"` — every individual patch release.
203
- *
204
- * Defaults to `"latest"` when omitted.
205
- *
206
- * @see {@link (Increments:type)}
207
- */
208
- readonly increments?: Increments;
209
- }
210
- /**
211
- * Union of all typed errors that `BunResolver.resolve` can fail with.
212
- *
213
- * @see {@link VersionNotFoundError}
214
- *
215
- * @public
216
- */
217
- type BunResolverError = VersionNotFoundError;
218
- declare const BunResolver_base: Context.TagClass<BunResolver, "runtime-resolver/BunResolver", {
219
- /**
220
- * Resolves Bun versions according to `options` and returns a
221
- * {@link (ResolvedVersions:type)} object containing the matching version list,
222
- * the latest version string, and the data source indicator.
223
- *
224
- * Fails with {@link BunResolverError} when no version can be resolved and
225
- * no `defaultVersion` was provided.
226
- *
227
- * @param options - Optional resolution constraints.
228
- *
229
- * @see {@link BunResolverOptions}
230
- */
231
- readonly resolve: (options?: BunResolverOptions) => Effect.Effect<ResolvedVersions, BunResolverError>;
232
- }>;
233
- /**
234
- * Service for resolving Bun runtime versions against the cached
235
- * release index.
236
- *
237
- * For a one-shot Promise-based API see {@link resolveBun}.
238
- *
239
- * @example
240
- * ```typescript
241
- * import type { ResolvedVersions } from "runtime-resolver";
242
- * import { BunResolver, BunResolverLive } from "runtime-resolver";
243
- * import { Effect } from "effect";
244
- *
245
- * const program = Effect.gen(function* () {
246
- * const resolver = yield* BunResolver;
247
- * const result = yield* resolver.resolve({ semverRange: "^1.0.0", increments: "minor" });
248
- * console.log(result.latest);
249
- * console.log(result.versions);
250
- * });
251
- *
252
- * Effect.runPromise(program.pipe(Effect.provide(BunResolverLive)));
253
- * ```
254
- *
255
- * @see {@link BunResolverLive}
256
- * @see {@link resolveBun}
257
- * @see {@link BunResolverOptions}
258
- * @see {@link (ResolvedVersions:type)}
259
- *
260
- * @public
261
- */
262
- declare class BunResolver extends BunResolver_base {}
263
- //#endregion
264
- //#region src/services/DenoResolver.d.ts
265
- /**
266
- * Options accepted by `DenoResolver.resolve`.
267
- *
268
- * All fields are optional; omitting them causes the resolver to fall back to
269
- * its built-in defaults (latest stable release, `"latest"` increment
270
- * granularity).
271
- *
272
- * @see {@link DenoResolver}
273
- * @see {@link (Increments:type)}
274
- * @see {@link (ResolvedVersions:type)}
275
- *
276
- * @public
277
- */
278
- interface DenoResolverOptions {
279
- /**
280
- * A semver range string used to constrain which Deno releases are
281
- * considered (e.g. `"^2.0.0"` or `">=1.40.0 <2.0.0"`).
282
- *
283
- * When omitted all cached releases are eligible.
284
- */
285
- readonly semverRange?: string;
286
- /**
287
- * A fallback version string returned when no release satisfies
288
- * `semverRange`. Must be a valid semver version (e.g. `"2.0.0"`).
289
- *
290
- * When omitted and no match is found the effect fails with
291
- * {@link VersionNotFoundError}.
292
- */
293
- readonly defaultVersion?: string;
294
- /**
295
- * Controls the granularity of the version list included in
296
- * the `versions` field of {@link (ResolvedVersions:type)}.
297
- *
298
- * - `"latest"` — only the single highest matching version.
299
- * - `"minor"` — the latest patch for every minor line.
300
- * - `"patch"` — every individual patch release.
301
- *
302
- * Defaults to `"latest"` when omitted.
303
- *
304
- * @see {@link (Increments:type)}
305
- */
306
- readonly increments?: Increments;
307
- }
308
- /**
309
- * Union of all typed errors that `DenoResolver.resolve` can fail with.
310
- *
311
- * @see {@link VersionNotFoundError}
312
- *
313
- * @public
314
- */
315
- type DenoResolverError = VersionNotFoundError;
316
- declare const DenoResolver_base: Context.TagClass<DenoResolver, "runtime-resolver/DenoResolver", {
317
- /**
318
- * Resolves Deno versions according to `options` and returns a
319
- * {@link (ResolvedVersions:type)} object containing the matching version list,
320
- * the latest version string, and the data source indicator.
321
- *
322
- * Fails with {@link DenoResolverError} when no version can be resolved and
323
- * no `defaultVersion` was provided.
324
- *
325
- * @param options - Optional resolution constraints.
326
- *
327
- * @see {@link DenoResolverOptions}
328
- */
329
- readonly resolve: (options?: DenoResolverOptions) => Effect.Effect<ResolvedVersions, DenoResolverError>;
330
- }>;
331
- /**
332
- * Service for resolving Deno runtime versions against the cached
333
- * release index.
334
- *
335
- * For a one-shot Promise-based API see {@link resolveDeno}.
336
- *
337
- * @example
338
- * ```typescript
339
- * import type { ResolvedVersions } from "runtime-resolver";
340
- * import { DenoResolver, DenoResolverLive } from "runtime-resolver";
341
- * import { Effect } from "effect";
342
- *
343
- * const program = Effect.gen(function* () {
344
- * const resolver = yield* DenoResolver;
345
- * const result = yield* resolver.resolve({ semverRange: "^2.0.0", increments: "minor" });
346
- * console.log(result.latest);
347
- * console.log(result.versions);
348
- * });
349
- *
350
- * Effect.runPromise(program.pipe(Effect.provide(DenoResolverLive)));
351
- * ```
352
- *
353
- * @see {@link DenoResolverLive}
354
- * @see {@link resolveDeno}
355
- * @see {@link DenoResolverOptions}
356
- * @see {@link (ResolvedVersions:type)}
357
- *
358
- * @public
359
- */
360
- declare class DenoResolver extends DenoResolver_base {}
361
- //#endregion
362
- //#region src/services/NodeResolver.d.ts
363
- /**
364
- * Options accepted by `NodeResolver.resolve`.
365
- *
366
- * All fields are optional; omitting them causes the resolver to fall back to
367
- * its built-in defaults (all lifecycle phases, latest stable release,
368
- * `"latest"` increment granularity, current wall-clock date).
369
- *
370
- * @see {@link NodeResolver}
371
- * @see {@link (NodePhase:type)}
372
- * @see {@link (Increments:type)}
373
- * @see {@link (ResolvedVersions:type)}
374
- *
375
- * @public
376
- */
377
- interface NodeResolverOptions {
378
- /**
379
- * A semver range string used to constrain which Node.js releases are
380
- * considered (e.g. `"^20.0.0"` or `">=18.0.0 <22.0.0"`).
381
- *
382
- * When omitted all cached releases are eligible.
383
- */
384
- readonly semverRange?: string;
385
- /**
386
- * A fallback version string returned when no release satisfies
387
- * `semverRange`. Must be a valid semver version (e.g. `"20.0.0"`).
388
- *
389
- * When omitted and no match is found the effect fails with
390
- * {@link VersionNotFoundError}.
391
- */
392
- readonly defaultVersion?: string;
393
- /**
394
- * Restricts resolution to releases whose lifecycle phase is included in
395
- * this list. For example, passing `["active-lts"]` excludes `"current"`
396
- * and `"maintenance-lts"` releases from consideration.
397
- *
398
- * When omitted all phases are eligible.
399
- *
400
- * @see {@link (NodePhase:type)}
401
- */
402
- readonly phases?: ReadonlyArray<NodePhase>;
403
- /**
404
- * Controls the granularity of the version list included in
405
- * the `versions` field of {@link (ResolvedVersions:type)}.
406
- *
407
- * - `"latest"` — only the single highest matching version.
408
- * - `"minor"` — the latest patch for every minor line.
409
- * - `"patch"` — every individual patch release.
410
- *
411
- * Defaults to `"latest"` when omitted.
412
- *
413
- * @see {@link (Increments:type)}
414
- */
415
- readonly increments?: Increments;
416
- /**
417
- * Reference date used when evaluating Node.js lifecycle phases. Releases
418
- * whose LTS or end-of-life boundaries fall relative to this date are
419
- * classified accordingly.
420
- *
421
- * When omitted the current wall-clock date is used.
422
- */
423
- readonly date?: Date;
424
- }
425
- /**
426
- * Union of all typed errors that `NodeResolver.resolve` can fail with.
427
- *
428
- * @see {@link VersionNotFoundError}
429
- *
430
- * @public
431
- */
432
- type NodeResolverError = VersionNotFoundError;
433
- declare const NodeResolver_base: Context.TagClass<NodeResolver, "runtime-resolver/NodeResolver", {
434
- /**
435
- * Resolves Node.js versions according to `options` and returns a
436
- * {@link (ResolvedVersions:type)} object containing the matching version list,
437
- * the latest version string, optional LTS version string, and the data
438
- * source indicator.
439
- *
440
- * Fails with {@link NodeResolverError} when no version can be resolved and
441
- * no `defaultVersion` was provided.
442
- *
443
- * @param options - Optional resolution constraints.
444
- *
445
- * @see {@link NodeResolverOptions}
446
- */
447
- readonly resolve: (options?: NodeResolverOptions) => Effect.Effect<ResolvedVersions, NodeResolverError>;
448
- }>;
449
- /**
450
- * Service for resolving Node.js runtime versions against the cached
451
- * release index.
452
- *
453
- * Unlike {@link BunResolver} and {@link DenoResolver}, this service is
454
- * lifecycle-aware: results can be filtered by {@link (NodePhase:type)} and evaluated
455
- * against a specific reference date.
456
- *
457
- * For a one-shot Promise-based API see {@link resolveNode}.
458
- *
459
- * @example
460
- * ```typescript
461
- * import type { ResolvedVersions } from "runtime-resolver";
462
- * import { NodeResolver, NodeResolverLive } from "runtime-resolver";
463
- * import { Effect } from "effect";
464
- *
465
- * const program = Effect.gen(function* () {
466
- * const resolver = yield* NodeResolver;
467
- * const result = yield* resolver.resolve({
468
- * semverRange: "^20.0.0",
469
- * phases: ["active-lts"],
470
- * increments: "minor",
471
- * });
472
- * console.log(result.latest);
473
- * console.log(result.lts);
474
- * });
475
- *
476
- * Effect.runPromise(program.pipe(Effect.provide(NodeResolverLive)));
477
- * ```
478
- *
479
- * @see {@link NodeResolverLive}
480
- * @see {@link resolveNode}
481
- * @see {@link NodeResolverOptions}
482
- * @see {@link (ResolvedVersions:type)}
483
- *
484
- * @public
485
- */
486
- declare class NodeResolver extends NodeResolver_base {}
487
- //#endregion
488
- //#region src/errors/AuthenticationError.d.ts
489
- declare const AuthenticationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
490
- readonly _tag: "AuthenticationError";
491
- } & Readonly<A>;
492
- /**
493
- * Raised when a GitHub authentication attempt fails.
494
- *
495
- * This error is produced by the {@link GitHubTokenAuth} and
496
- * {@link GitHubAppAuth} layers when the supplied credentials are rejected by
497
- * the GitHub API or when required configuration values (e.g. a token or app
498
- * private key) are missing from the environment.
499
- *
500
- * @see {@link GitHubTokenAuth}
501
- * @see {@link GitHubAppAuth}
502
- *
503
- * @example
504
- * ```typescript
505
- * import { Effect } from "effect";
506
- * import type { AuthenticationError } from "./AuthenticationError.js";
507
- * import { resolveNode } from "../resolvers/node.js";
508
- *
509
- * const program = resolveNode(">=20").pipe(
510
- * Effect.catchTag("AuthenticationError", (err: AuthenticationError) =>
511
- * Effect.logError(
512
- * `Auth failed via ${err.method}: ${err.message}`
513
- * ).pipe(Effect.andThen(Effect.fail(err)))
514
- * )
515
- * );
516
- * ```
517
- *
518
- * @public
519
- */
520
- declare class AuthenticationError extends AuthenticationError_base<{
521
- readonly method: "token" | "app";
522
- readonly message: string;
523
- }> {}
524
- //#endregion
525
- //#region src/errors/CacheError.d.ts
526
- declare const CacheError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
527
- readonly _tag: "CacheError";
528
- } & Readonly<A>;
529
- /**
530
- * Raised when a cache read or write operation fails.
531
- *
532
- * This error surfaces when the local on-disk version cache cannot be accessed
533
- * or updated. The `operation` field distinguishes between failures that occur
534
- * while loading cached data (`"read"`) and failures that occur while
535
- * persisting new data (`"write"`).
536
- *
537
- * @example
538
- * ```typescript
539
- * import { Effect } from "effect";
540
- * import type { CacheError } from "./CacheError.js";
541
- * import { resolveNode } from "../resolvers/node.js";
542
- *
543
- * const program = resolveNode(">=20").pipe(
544
- * Effect.catchTag("CacheError", (err: CacheError) =>
545
- * Effect.logWarning(
546
- * `Cache ${err.operation} failed: ${err.message}`
547
- * ).pipe(Effect.andThen(Effect.fail(err)))
548
- * )
549
- * );
550
- * ```
551
- *
552
- * @public
553
- */
554
- declare class CacheError extends CacheError_base<{
555
- readonly operation: "read" | "write";
556
- readonly message: string;
557
- }> {}
558
- //#endregion
559
- //#region src/errors/FreshnessError.d.ts
560
- declare const FreshnessError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
561
- readonly _tag: "FreshnessError";
562
- } & Readonly<A>;
563
- /**
564
- * Raised when a cache freshness check cannot be completed.
565
- *
566
- * Each runtime cache layer ({@link FreshBunCacheLive}, {@link FreshDenoCacheLive},
567
- * {@link FreshNodeCacheLive}) validates whether locally stored version data is
568
- * still current before returning it. This error is produced when that
569
- * validation fails — for example, when the upstream API is unreachable during
570
- * an `"api"` freshness check, or when the cached timestamp is corrupt during
571
- * an `"auto"` or `"cache"` check.
572
- *
573
- * @see {@link FreshBunCacheLive}
574
- * @see {@link FreshDenoCacheLive}
575
- * @see {@link FreshNodeCacheLive}
576
- *
577
- * @example
578
- * ```typescript
579
- * import { Effect } from "effect";
580
- * import type { FreshnessError } from "./FreshnessError.js";
581
- * import { resolveNode } from "../resolvers/node.js";
582
- *
583
- * const program = resolveNode(">=20").pipe(
584
- * Effect.catchTag("FreshnessError", (err: FreshnessError) =>
585
- * Effect.logWarning(
586
- * `Freshness check (${err.strategy}) failed: ${err.message}`
587
- * ).pipe(Effect.andThen(Effect.fail(err)))
588
- * )
589
- * );
590
- * ```
591
- *
592
- * @public
593
- */
594
- declare class FreshnessError extends FreshnessError_base<{
595
- readonly strategy: "auto" | "api" | "cache";
596
- readonly message: string;
597
- }> {}
598
- //#endregion
599
- //#region src/errors/InvalidInputError.d.ts
600
- declare const InvalidInputError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
601
- readonly _tag: "InvalidInputError";
602
- } & Readonly<A>;
603
- /**
604
- * Raised when a caller-supplied value fails validation.
605
- *
606
- * This error is produced at the boundary where user-provided inputs (such as
607
- * version constraint strings or runtime identifiers) are decoded against their
608
- * expected schemas. The `field` identifies which input was invalid, `value`
609
- * carries the raw string that was rejected, and `message` explains the
610
- * specific violation.
611
- *
612
- * @example
613
- * ```typescript
614
- * import { Effect } from "effect";
615
- * import type { InvalidInputError } from "./InvalidInputError.js";
616
- * import { resolveNode } from "../resolvers/node.js";
617
- *
618
- * const program = resolveNode("not-a-semver-range").pipe(
619
- * Effect.catchTag("InvalidInputError", (err: InvalidInputError) =>
620
- * Effect.logError(
621
- * `Invalid value for "${err.field}": ${err.value} — ${err.message}`
622
- * ).pipe(Effect.andThen(Effect.fail(err)))
623
- * )
624
- * );
625
- * ```
626
- *
627
- * @public
628
- */
629
- declare class InvalidInputError extends InvalidInputError_base<{
630
- readonly field: string;
631
- readonly value: string;
632
- readonly message: string;
633
- }> {}
634
- //#endregion
635
- //#region src/errors/NetworkError.d.ts
636
- declare const NetworkError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
637
- readonly _tag: "NetworkError";
638
- } & Readonly<A>;
639
- /**
640
- * Raised when an HTTP request to an upstream API fails.
641
- *
642
- * This error is produced when a fetch to a runtime release API (e.g. the
643
- * Node.js release index, the Deno release feed, or the Bun GitHub releases
644
- * endpoint) either does not receive a response or receives a non-successful
645
- * HTTP status code. When a status code is available it is included in the
646
- * `status` field; for connection-level failures (timeouts, DNS errors) that
647
- * field is absent.
648
- *
649
- * @example
650
- * ```typescript
651
- * import { Effect } from "effect";
652
- * import type { NetworkError } from "./NetworkError.js";
653
- * import { resolveNode } from "../resolvers/node.js";
654
- *
655
- * const program = resolveNode(">=20").pipe(
656
- * Effect.catchTag("NetworkError", (err: NetworkError) =>
657
- * Effect.logError(
658
- * `Request to ${err.url} failed${err.status != null ? ` with status ${err.status}` : ""}: ${err.message}`
659
- * ).pipe(Effect.andThen(Effect.fail(err)))
660
- * )
661
- * );
662
- * ```
663
- *
664
- * @public
665
- */
666
- declare class NetworkError extends NetworkError_base<{
667
- readonly url: string;
668
- readonly status?: number;
669
- readonly message: string;
670
- }> {}
671
- //#endregion
672
- //#region src/errors/ParseError.d.ts
673
- declare const ParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
674
- readonly _tag: "ParseError";
675
- } & Readonly<A>;
676
- /**
677
- * Raised when the body of an upstream API response cannot be decoded.
678
- *
679
- * This error is produced after a successful HTTP response is received but
680
- * its payload does not match the expected shape — for example, when a release
681
- * index returns malformed JSON or when a required field is missing from the
682
- * response structure. The `source` field identifies the URL or data source
683
- * that produced the unparseable content.
684
- *
685
- * @example
686
- * ```typescript
687
- * import { Effect } from "effect";
688
- * import type { ParseError } from "./ParseError.js";
689
- * import { resolveNode } from "../resolvers/node.js";
690
- *
691
- * const program = resolveNode(">=20").pipe(
692
- * Effect.catchTag("ParseError", (err: ParseError) =>
693
- * Effect.logError(
694
- * `Failed to parse response from ${err.source}: ${err.message}`
695
- * ).pipe(Effect.andThen(Effect.fail(err)))
696
- * )
697
- * );
698
- * ```
699
- *
700
- * @public
701
- */
702
- declare class ParseError extends ParseError_base<{
703
- readonly source: string;
704
- readonly message: string;
705
- }> {}
706
- //#endregion
707
- //#region src/errors/RateLimitError.d.ts
708
- declare const RateLimitError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
709
- readonly _tag: "RateLimitError";
710
- } & Readonly<A>;
711
- /**
712
- * Raised when a GitHub API rate limit is exceeded.
713
- *
714
- * The `limit` and `remaining` fields reflect the values returned in the
715
- * `X-RateLimit-Limit` and `X-RateLimit-Remaining` response headers. When the
716
- * API indicates how long to wait before the quota resets, that duration (in
717
- * seconds) is available via `retryAfter`.
718
- *
719
- * Use `retryOnRateLimit` to automatically retry an effect with
720
- * exponential backoff whenever this error is encountered.
721
- *
722
- * @example
723
- * ```typescript
724
- * import { Effect } from "effect";
725
- * import type { RateLimitError } from "./RateLimitError.js";
726
- * import { resolveNode } from "../resolvers/node.js";
727
- *
728
- * const program = resolveNode(">=20").pipe(
729
- * Effect.catchTag("RateLimitError", (err: RateLimitError) =>
730
- * Effect.logWarning(
731
- * `Rate limit hit (${err.remaining}/${err.limit} remaining)` +
732
- * (err.retryAfter != null ? `, retry after ${err.retryAfter}s` : "") +
733
- * `: ${err.message}`
734
- * ).pipe(Effect.andThen(Effect.fail(err)))
735
- * )
736
- * );
737
- * ```
738
- *
739
- * @public
740
- */
741
- declare class RateLimitError extends RateLimitError_base<{
742
- readonly retryAfter?: number;
743
- readonly limit: number;
744
- readonly remaining: number;
745
- readonly message: string;
746
- }> {}
747
- //#endregion
748
- //#region src/schemas/runtime-release.d.ts
749
- /**
750
- * Structural base constraint shared by {@link BunRelease}, {@link DenoRelease},
751
- * and {@link NodeRelease}.
752
- *
753
- * Enables the generic `RuntimeCache<R extends RuntimeRelease>` service to
754
- * operate over any runtime release type without coupling to a concrete class.
755
- *
756
- * @see {@link RuntimeCache}
757
- * @see {@link BunRelease}
758
- * @see {@link DenoRelease}
759
- * @see {@link NodeRelease}
760
- *
761
- * @public
762
- */
763
- interface RuntimeRelease {
764
- readonly _tag: string;
765
- readonly version: SemVer;
766
- readonly date: DateTime.DateTime;
767
- }
768
- /**
769
- * Lean input schema used to construct {@link BunRelease} and
770
- * {@link DenoRelease} instances from bundled default data files.
771
- *
772
- * Both Bun and Deno source their offline snapshots from JSON/TS data files
773
- * whose entries conform to this shape. The `version` and `date` fields are
774
- * plain strings that are subsequently parsed by `SemVer.parse` and
775
- * `DateTime.unsafeMake` respectively.
776
- *
777
- * @see {@link BunRelease.fromInput}
778
- * @see {@link DenoRelease.fromInput}
779
- *
780
- * @public
781
- */
782
- declare const RuntimeReleaseInput: Schema.Struct<{
783
- version: typeof Schema.String;
784
- date: typeof Schema.String;
785
- }>;
786
- /**
787
- * Lean input type used to construct {@link BunRelease} and {@link DenoRelease}
788
- * instances from bundled default data files.
789
- *
790
- * @see {@link BunRelease.fromInput}
791
- * @see {@link DenoRelease.fromInput}
792
- *
793
- * @public
794
- */
795
- type RuntimeReleaseInput = typeof RuntimeReleaseInput.Type;
796
- //#endregion
797
- //#region src/schemas/bun-release.d.ts
798
- declare const BunRelease_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Readonly<A> & {
799
- readonly _tag: "BunRelease";
800
- };
801
- /**
802
- * A Bun release entry with a parsed `SemVer` version and an
803
- * Effect `DateTime.DateTime` publication date.
804
- *
805
- * `BunRelease` extends `Data.TaggedClass` so instances support structural
806
- * equality comparison and can be used safely inside Effect data structures.
807
- * Construct instances via the {@link BunRelease.fromInput} factory rather than
808
- * calling `new BunRelease(...)` directly, as the factory validates the version
809
- * string through `SemVer.parse`.
810
- *
811
- * @see {@link BunReleaseCache}
812
- * @see {@link BunResolver}
813
- * @see `RuntimeReleaseInput`
814
- *
815
- * @example
816
- * ```typescript
817
- * import { Effect } from "effect";
818
- * import type { BunRelease } from "./bun-release.js";
819
- * import { BunRelease as BunReleaseClass } from "./bun-release.js";
820
- *
821
- * const program = BunReleaseClass.fromInput({ version: "1.1.0", date: "2024-03-01" }).pipe(
822
- * Effect.map((release: BunRelease) => {
823
- * console.log(release.version.major); // 1
824
- * console.log(release.version.minor); // 1
825
- * console.log(release._tag); // "BunRelease"
826
- * }),
827
- * );
828
- *
829
- * Effect.runPromise(program);
830
- * ```
831
- *
832
- * @public
833
- */
834
- declare class BunRelease extends BunRelease_base<{
835
- readonly version: SemVer;
836
- readonly date: DateTime.DateTime;
837
- }> {
838
- /**
839
- * Create a {@link BunRelease} from lean string inputs.
840
- *
841
- * Parses `input.version` via `SemVer.parse` and constructs the
842
- * publication date with `DateTime.unsafeMake`. Falls back to the current
843
- * timestamp when `input.date` is an empty string (rare in production data).
844
- *
845
- * @param input - A `RuntimeReleaseInput` object with raw string fields.
846
- * @returns An `Effect` that succeeds with a `BunRelease` or fails with an
847
- * `InvalidVersionError` when the version string cannot be parsed.
848
- */
849
- static fromInput(input: RuntimeReleaseInput): Effect.Effect<BunRelease, InvalidVersionError>;
850
- }
851
- //#endregion
852
- //#region src/services/RuntimeCache.d.ts
853
- /**
854
- * Generic in-memory cache service for a typed runtime release collection,
855
- * built on top of semver-effect's version cache primitives.
856
- *
857
- * Concrete instantiations are {@link BunReleaseCache}, {@link DenoReleaseCache},
858
- * and {@link NodeReleaseCache}. The canonical factory function for obtaining a
859
- * `RuntimeCache` implementation is {@link createRuntimeCache}.
860
- *
861
- * @typeParam R - A {@link RuntimeRelease} subtype specific to the runtime
862
- * (e.g. `BunRelease`, `DenoRelease`, `NodeRelease`).
863
- *
864
- * @example
865
- * ```typescript
866
- * import type { BunRelease } from "runtime-resolver";
867
- * import { BunReleaseCache, OfflineBunCacheLive } from "runtime-resolver";
868
- * import { Effect } from "effect";
869
- *
870
- * const program = Effect.gen(function* () {
871
- * const cache = yield* BunReleaseCache;
872
- * const latest = yield* cache.latest();
873
- * console.log(latest.version.toString());
874
- * });
875
- *
876
- * Effect.runPromise(program.pipe(Effect.provide(OfflineBunCacheLive)));
877
- * ```
878
- *
879
- * @see {@link BunReleaseCache}
880
- * @see {@link DenoReleaseCache}
881
- * @see {@link NodeReleaseCache}
882
- * @see {@link createRuntimeCache}
883
- *
884
- * @public
885
- */
886
- interface RuntimeCache<R extends RuntimeRelease> {
887
- /**
888
- * Populates the cache with the given array of typed release objects,
889
- * replacing any previously loaded entries.
890
- *
891
- * @param releases - The full set of releases to store.
892
- */
893
- readonly load: (releases: ReadonlyArray<R>) => Effect.Effect<void>;
894
- /**
895
- * Finds the single best-matching release for the given semver range string,
896
- * preferring the highest satisfying version.
897
- *
898
- * Fails with `InvalidRangeError` when `range` is not a valid semver
899
- * range expression, or with `UnsatisfiedRangeError` when no cached
900
- * release satisfies the range.
901
- *
902
- * @param range - A semver range string (e.g. `">=1.0.0 <2.0.0"`).
903
- */
904
- readonly resolve: (range: string) => Effect.Effect<R, InvalidRangeError | UnsatisfiedRangeError>;
905
- /**
906
- * Returns the complete list of all releases currently held in the cache,
907
- * in the order they were loaded.
908
- */
909
- readonly releases: () => Effect.Effect<ReadonlyArray<R>>;
910
- /**
911
- * Returns all cached releases whose version satisfies the given semver
912
- * range string.
913
- *
914
- * Fails with `InvalidRangeError` when `range` is not a valid semver
915
- * range expression.
916
- *
917
- * @param range - A semver range string (e.g. `"^20.0.0"`).
918
- */
919
- readonly filter: (range: string) => Effect.Effect<ReadonlyArray<R>, InvalidRangeError>;
920
- /**
921
- * Returns the release with the highest version among all entries in the
922
- * cache.
923
- *
924
- * Fails with `EmptyCacheError` when the cache contains no releases.
925
- */
926
- readonly latest: () => Effect.Effect<R, EmptyCacheError>;
927
- /**
928
- * Returns one release per major version line, each being the highest
929
- * available version within that major line.
930
- *
931
- * Returns an empty array when the cache is empty.
932
- */
933
- readonly latestByMajor: () => Effect.Effect<ReadonlyArray<R>>;
934
- /**
935
- * Returns one release per minor version line, each being the highest
936
- * available patch version within that minor line.
937
- *
938
- * Returns an empty array when the cache is empty.
939
- */
940
- readonly latestByMinor: () => Effect.Effect<ReadonlyArray<R>>;
941
- }
942
- //#endregion
943
- //#region src/services/BunReleaseCache.d.ts
944
- declare const BunReleaseCache_base: Context.TagClass<BunReleaseCache, "runtime-resolver/BunReleaseCache", RuntimeCache<BunRelease>>;
945
- /**
946
- * Specialisation of {@link RuntimeCache} for Bun release objects.
947
- *
948
- * @example
949
- * ```typescript
950
- * import type { BunRelease } from "runtime-resolver";
951
- * import { BunReleaseCache, OfflineBunCacheLive } from "runtime-resolver";
952
- * import { Effect } from "effect";
953
- *
954
- * const program = Effect.gen(function* () {
955
- * const cache = yield* BunReleaseCache;
956
- * const releases = yield* cache.releases();
957
- * console.log(releases.length);
958
- * });
959
- *
960
- * Effect.runPromise(program.pipe(Effect.provide(OfflineBunCacheLive)));
961
- * ```
962
- *
963
- * @see {@link BunRelease}
964
- * @see {@link RuntimeCache}
965
- * @see {@link AutoBunCacheLive}
966
- * @see {@link FreshBunCacheLive}
967
- * @see {@link OfflineBunCacheLive}
968
- *
969
- * @public
970
- */
971
- declare class BunReleaseCache extends BunReleaseCache_base {}
972
- //#endregion
973
- //#region src/services/BunVersionFetcher.d.ts
974
- declare const BunVersionFetcher_base: Context.TagClass<BunVersionFetcher, "runtime-resolver/BunVersionFetcher", {
975
- /**
976
- * Fetches all available Bun releases from the GitHub API and returns both
977
- * the parsed semver version objects and the raw release input records.
978
- *
979
- * Fails with:
980
- * - {@link AuthenticationError} — missing or invalid GitHub credentials.
981
- * - {@link NetworkError} — the upstream request could not be completed.
982
- * - {@link ParseError} — the response payload could not be decoded.
983
- * - {@link RateLimitError} — the GitHub API rate limit was exceeded.
984
- */
985
- readonly fetch: () => Effect.Effect<{
986
- readonly versions: ReadonlyArray<SemVer>;
987
- readonly inputs: ReadonlyArray<RuntimeReleaseInput>;
988
- }, AuthenticationError | NetworkError | ParseError | RateLimitError>;
989
- }>;
990
- /**
991
- * Service for fetching Bun release data from the GitHub API.
992
- *
993
- * Retrieves both the parsed semver version list and the raw release input
994
- * records needed to populate a {@link BunReleaseCache}. The live
995
- * implementation queries the `oven-sh/bun` GitHub repository via
996
- * {@link GitHubClient}.
997
- *
998
- * @example
999
- * ```typescript
1000
- * import type { RuntimeReleaseInput } from "runtime-resolver";
1001
- * import { BunVersionFetcher, BunVersionFetcherLive, GitHubAutoAuth } from "runtime-resolver";
1002
- * import { Effect } from "effect";
1003
- *
1004
- * const program = Effect.gen(function* () {
1005
- * const fetcher = yield* BunVersionFetcher;
1006
- * const { versions, inputs } = yield* fetcher.fetch();
1007
- * console.log(`Fetched ${versions.length} Bun releases`);
1008
- * });
1009
- *
1010
- * Effect.runPromise(
1011
- * program.pipe(Effect.provide(BunVersionFetcherLive), Effect.provide(GitHubAutoAuth)),
1012
- * );
1013
- * ```
1014
- *
1015
- * @see {@link BunVersionFetcherLive}
1016
- * @see {@link BunReleaseCache}
1017
- * @see {@link AuthenticationError}
1018
- * @see {@link NetworkError}
1019
- * @see {@link ParseError}
1020
- * @see {@link RateLimitError}
1021
- *
1022
- * @public
1023
- */
1024
- declare class BunVersionFetcher extends BunVersionFetcher_base {}
1025
- //#endregion
1026
- //#region src/layers/AutoBunCacheLive.d.ts
1027
- /**
1028
- * Provides the {@link BunReleaseCache} service using the "Auto" cache strategy.
1029
- *
1030
- * Attempts to fetch live release data from the GitHub API via
1031
- * {@link BunVersionFetcher}. If the fetch fails for any reason — authentication
1032
- * errors, network errors, parse errors, or rate-limit errors — it silently falls
1033
- * back to the bundled default release data so the layer always succeeds.
1034
- *
1035
- * Use this strategy when you want the freshest data when available but can
1036
- * tolerate slightly stale bundled data in degraded environments.
1037
- *
1038
- * The three Bun cache strategy layers are:
1039
- * - `AutoBunCacheLive` — tries API first, falls back to bundled defaults on any error
1040
- * - {@link FreshBunCacheLive} — requires live API data, fails with `FreshnessError` if unavailable
1041
- * - {@link OfflineBunCacheLive} — uses only bundled defaults, no network I/O
1042
- *
1043
- * @see {@link BunReleaseCache}
1044
- * @see {@link FreshBunCacheLive}
1045
- * @see {@link OfflineBunCacheLive}
1046
- * @public
1047
- */
1048
- declare const AutoBunCacheLive: Layer.Layer<BunReleaseCache, never, BunVersionFetcher>;
1049
- //#endregion
1050
- //#region src/schemas/deno-release.d.ts
1051
- declare const DenoRelease_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Readonly<A> & {
1052
- readonly _tag: "DenoRelease";
1053
- };
1054
- /**
1055
- * A Deno release entry with a parsed `SemVer` version and an
1056
- * Effect `DateTime.DateTime` publication date.
1057
- *
1058
- * `DenoRelease` extends `Data.TaggedClass` so instances support structural
1059
- * equality comparison and can be used safely inside Effect data structures.
1060
- * Construct instances via the {@link DenoRelease.fromInput} factory rather than
1061
- * calling `new DenoRelease(...)` directly, as the factory validates the version
1062
- * string through `SemVer.parse`.
1063
- *
1064
- * @see {@link DenoReleaseCache}
1065
- * @see {@link DenoResolver}
1066
- * @see `RuntimeReleaseInput`
1067
- *
1068
- * @example
1069
- * ```typescript
1070
- * import { Effect } from "effect";
1071
- * import type { DenoRelease } from "./deno-release.js";
1072
- * import { DenoRelease as DenoReleaseClass } from "./deno-release.js";
1073
- *
1074
- * const program = DenoReleaseClass.fromInput({ version: "1.44.0", date: "2024-05-23" }).pipe(
1075
- * Effect.map((release: DenoRelease) => {
1076
- * console.log(release.version.major); // 1
1077
- * console.log(release.version.minor); // 44
1078
- * console.log(release._tag); // "DenoRelease"
1079
- * }),
1080
- * );
1081
- *
1082
- * Effect.runPromise(program);
1083
- * ```
1084
- *
1085
- * @public
1086
- */
1087
- declare class DenoRelease extends DenoRelease_base<{
1088
- readonly version: SemVer;
1089
- readonly date: DateTime.DateTime;
1090
- }> {
1091
- /**
1092
- * Create a {@link DenoRelease} from lean string inputs.
1093
- *
1094
- * Parses `input.version` via `SemVer.parse` and constructs the
1095
- * publication date with `DateTime.unsafeMake`. Falls back to the current
1096
- * timestamp when `input.date` is an empty string (rare in production data).
1097
- *
1098
- * @param input - A `RuntimeReleaseInput` object with raw string fields.
1099
- * @returns An `Effect` that succeeds with a `DenoRelease` or fails with an
1100
- * `InvalidVersionError` when the version string cannot be parsed.
1101
- */
1102
- static fromInput(input: RuntimeReleaseInput): Effect.Effect<DenoRelease, InvalidVersionError>;
1103
- }
1104
- //#endregion
1105
- //#region src/services/DenoReleaseCache.d.ts
1106
- declare const DenoReleaseCache_base: Context.TagClass<DenoReleaseCache, "runtime-resolver/DenoReleaseCache", RuntimeCache<DenoRelease>>;
1107
- /**
1108
- * Specialisation of {@link RuntimeCache} for Deno release objects.
1109
- *
1110
- * @example
1111
- * ```typescript
1112
- * import type { DenoRelease } from "runtime-resolver";
1113
- * import { DenoReleaseCache, OfflineDenoCacheLive } from "runtime-resolver";
1114
- * import { Effect } from "effect";
1115
- *
1116
- * const program = Effect.gen(function* () {
1117
- * const cache = yield* DenoReleaseCache;
1118
- * const latest = yield* cache.latest();
1119
- * console.log(latest.version.toString());
1120
- * });
1121
- *
1122
- * Effect.runPromise(program.pipe(Effect.provide(OfflineDenoCacheLive)));
1123
- * ```
1124
- *
1125
- * @see {@link DenoRelease}
1126
- * @see {@link RuntimeCache}
1127
- * @see {@link AutoDenoCacheLive}
1128
- * @see {@link FreshDenoCacheLive}
1129
- * @see {@link OfflineDenoCacheLive}
1130
- *
1131
- * @public
1132
- */
1133
- declare class DenoReleaseCache extends DenoReleaseCache_base {}
1134
- //#endregion
1135
- //#region src/services/DenoVersionFetcher.d.ts
1136
- declare const DenoVersionFetcher_base: Context.TagClass<DenoVersionFetcher, "runtime-resolver/DenoVersionFetcher", {
1137
- /**
1138
- * Fetches all available Deno releases from the GitHub API and returns both
1139
- * the parsed semver version objects and the raw release input records.
1140
- *
1141
- * Fails with:
1142
- * - {@link AuthenticationError} — missing or invalid GitHub credentials.
1143
- * - {@link NetworkError} — the upstream request could not be completed.
1144
- * - {@link ParseError} — the response payload could not be decoded.
1145
- * - {@link RateLimitError} — the GitHub API rate limit was exceeded.
1146
- */
1147
- readonly fetch: () => Effect.Effect<{
1148
- readonly versions: ReadonlyArray<SemVer>;
1149
- readonly inputs: ReadonlyArray<RuntimeReleaseInput>;
1150
- }, AuthenticationError | NetworkError | ParseError | RateLimitError>;
1151
- }>;
1152
- /**
1153
- * Service for fetching Deno release data from the GitHub API.
1154
- *
1155
- * Retrieves both the parsed semver version list and the raw release input
1156
- * records needed to populate a {@link DenoReleaseCache}. The live
1157
- * implementation queries the `denoland/deno` GitHub repository via
1158
- * {@link GitHubClient}.
1159
- *
1160
- * @example
1161
- * ```typescript
1162
- * import type { RuntimeReleaseInput } from "runtime-resolver";
1163
- * import { DenoVersionFetcher, DenoVersionFetcherLive, GitHubAutoAuth } from "runtime-resolver";
1164
- * import { Effect } from "effect";
1165
- *
1166
- * const program = Effect.gen(function* () {
1167
- * const fetcher = yield* DenoVersionFetcher;
1168
- * const { versions, inputs } = yield* fetcher.fetch();
1169
- * console.log(`Fetched ${versions.length} Deno releases`);
1170
- * });
1171
- *
1172
- * Effect.runPromise(
1173
- * program.pipe(Effect.provide(DenoVersionFetcherLive), Effect.provide(GitHubAutoAuth)),
1174
- * );
1175
- * ```
1176
- *
1177
- * @see {@link DenoVersionFetcherLive}
1178
- * @see {@link DenoReleaseCache}
1179
- * @see {@link AuthenticationError}
1180
- * @see {@link NetworkError}
1181
- * @see {@link ParseError}
1182
- * @see {@link RateLimitError}
1183
- *
1184
- * @public
1185
- */
1186
- declare class DenoVersionFetcher extends DenoVersionFetcher_base {}
1187
- //#endregion
1188
- //#region src/layers/AutoDenoCacheLive.d.ts
1189
- /**
1190
- * Provides the {@link DenoReleaseCache} service using the "Auto" cache strategy.
1191
- *
1192
- * Attempts to fetch live release data from the GitHub API via
1193
- * {@link DenoVersionFetcher}. If the fetch fails for any reason — authentication
1194
- * errors, network errors, parse errors, or rate-limit errors — it silently falls
1195
- * back to the bundled default release data so the layer always succeeds.
1196
- *
1197
- * Use this strategy when you want the freshest data when available but can
1198
- * tolerate slightly stale bundled data in degraded environments.
1199
- *
1200
- * The three Deno cache strategy layers are:
1201
- * - `AutoDenoCacheLive` — tries API first, falls back to bundled defaults on any error
1202
- * - {@link FreshDenoCacheLive} — requires live API data, fails with `FreshnessError` if unavailable
1203
- * - {@link OfflineDenoCacheLive} — uses only bundled defaults, no network I/O
1204
- *
1205
- * @see {@link DenoReleaseCache}
1206
- * @see {@link FreshDenoCacheLive}
1207
- * @see {@link OfflineDenoCacheLive}
1208
- * @public
1209
- */
1210
- declare const AutoDenoCacheLive: Layer.Layer<DenoReleaseCache, never, DenoVersionFetcher>;
1211
- //#endregion
1212
- //#region src/schemas/node-schedule.d.ts
1213
- /**
1214
- * A single entry in the Node.js release schedule, representing one major
1215
- * release line's lifecycle dates and optional LTS codename.
1216
- *
1217
- * All date fields have already been converted from ISO strings to Effect
1218
- * `DateTime.DateTime` values by {@link NodeSchedule.fromData}.
1219
- *
1220
- * @see {@link NodeSchedule}
1221
- * @see {@link NodeSchedule.phaseFor}
1222
- *
1223
- * @public
1224
- */
1225
- interface NodeScheduleEntry {
1226
- readonly major: number;
1227
- readonly start: DateTime.DateTime;
1228
- readonly lts: DateTime.DateTime | null;
1229
- readonly maintenance: DateTime.DateTime | null;
1230
- readonly end: DateTime.DateTime;
1231
- readonly codename: string;
1232
- }
1233
- /**
1234
- * Raw schedule format as fetched from the Node.js Release GitHub repository
1235
- * (`nodejs/Release`).
1236
- *
1237
- * This is the intermediate type between the {@link NodeScheduleFetcher} layer
1238
- * and the {@link NodeSchedule} class. Date values are plain ISO strings; the
1239
- * `NodeSchedule.fromData` factory converts them to `DateTime`.
1240
- *
1241
- * @see {@link NodeSchedule.fromData}
1242
- * @see {@link NodeScheduleFetcher}
1243
- *
1244
- * @public
1245
- */
1246
- type NodeScheduleData = Record<string, {
1247
- readonly start: string;
1248
- readonly lts?: string;
1249
- readonly maintenance?: string;
1250
- readonly end: string;
1251
- readonly codename?: string;
1252
- }>;
1253
- declare const NodeSchedule_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Readonly<A> & {
1254
- readonly _tag: "NodeSchedule";
1255
- };
1256
- /**
1257
- * Immutable snapshot of the Node.js release schedule.
1258
- *
1259
- * Holds a `ReadonlyArray<NodeScheduleEntry>` parsed from the raw
1260
- * {@link NodeScheduleData} fetched by {@link NodeScheduleFetcher}. A single
1261
- * `NodeSchedule` instance lives inside a `Ref<NodeSchedule>` that is shared
1262
- * across all {@link NodeRelease} instances so that schedule updates propagate
1263
- * without rebuilding the release cache.
1264
- *
1265
- * `NodeSchedule` extends `Data.TaggedClass` and therefore supports structural
1266
- * equality — two schedules built from identical data compare as equal.
1267
- *
1268
- * @see {@link NodeRelease}
1269
- * @see {@link NodeScheduleFetcher}
1270
- *
1271
- * @example
1272
- * ```typescript
1273
- * import { Effect } from "effect";
1274
- * import type { NodePhase } from "./common.js";
1275
- * import type { NodeScheduleData } from "./node-schedule.js";
1276
- * import { NodeSchedule } from "./node-schedule.js";
1277
- *
1278
- * const data: NodeScheduleData = {
1279
- * v20: {
1280
- * start: "2023-04-18",
1281
- * lts: "2023-10-24",
1282
- * maintenance: "2024-10-22",
1283
- * end: "2026-04-30",
1284
- * codename: "Iron",
1285
- * },
1286
- * };
1287
- *
1288
- * const schedule = NodeSchedule.fromData(data);
1289
- *
1290
- * const program = schedule.phaseFor(20, new Date("2024-01-01") as any).pipe(
1291
- * Effect.map((phase: NodePhase | null) => {
1292
- * console.log(phase); // "active-lts"
1293
- * }),
1294
- * );
1295
- *
1296
- * Effect.runPromise(program);
1297
- * ```
1298
- *
1299
- * @public
1300
- */
1301
- declare class NodeSchedule extends NodeSchedule_base<{
1302
- readonly entries: ReadonlyArray<NodeScheduleEntry>;
1303
- }> {
1304
- /**
1305
- * Parse raw {@link NodeScheduleData} into a `NodeSchedule` instance.
1306
- *
1307
- * Iterates over every key of the form `"vNN"`, converts ISO date strings
1308
- * to `DateTime.DateTime`, and normalises missing codenames to `""`.
1309
- *
1310
- * @param data - The raw JSON object fetched from the Node.js release repo.
1311
- * @returns A fully constructed, immutable `NodeSchedule`.
1312
- */
1313
- static fromData(data: NodeScheduleData): NodeSchedule;
1314
- /**
1315
- * Determine the current {@link (NodePhase:type)} for a given major version number
1316
- * at the specified point in time.
1317
- *
1318
- * Returns `null` when the major is not present in the schedule or when
1319
- * `now` is before the release's start date.
1320
- *
1321
- * @param major - The Node.js major version number (e.g. `20`).
1322
- * @param now - The reference `DateTime` against which phases are evaluated.
1323
- */
1324
- phaseFor(major: number, now: DateTime.DateTime): Effect.Effect<NodePhase | null>;
1325
- /**
1326
- * Look up the {@link NodeScheduleEntry} for a given major version number.
1327
- *
1328
- * Returns `Option.none()` when the major is not present in the schedule.
1329
- *
1330
- * @param major - The Node.js major version number (e.g. `20`).
1331
- */
1332
- entryFor(major: number): Option.Option<NodeScheduleEntry>;
1333
- }
1334
- //#endregion
1335
- //#region src/schemas/node-release.d.ts
1336
- /**
1337
- * Lean input schema used to construct {@link NodeRelease} instances from
1338
- * bundled default data files and the Node.js dist API response.
1339
- *
1340
- * The `version` and `npm` fields are raw version strings validated by
1341
- * `SemVer.parse`; `date` is a date string accepted by
1342
- * `DateTime.unsafeMake`.
1343
- *
1344
- * @see {@link NodeRelease.fromInput}
1345
- * @see {@link NodeVersionFetcher}
1346
- *
1347
- * @public
1348
- */
1349
- declare const NodeReleaseInput: Schema.Struct<{
1350
- version: typeof Schema.String;
1351
- npm: typeof Schema.String;
1352
- date: typeof Schema.String;
1353
- }>;
1354
- /**
1355
- * Lean input type used to construct {@link NodeRelease} instances.
1356
- *
1357
- * @see {@link NodeRelease.fromInput}
1358
- *
1359
- * @public
1360
- */
1361
- type NodeReleaseInput = typeof NodeReleaseInput.Type;
1362
- /**
1363
- * A Node.js release entry with parsed version, bundled npm version,
1364
- * publication date, and a shared reference to the Node.js release schedule.
1365
- *
1366
- * `NodeRelease` is a plain class rather than a `Data.TaggedClass` because it
1367
- * holds a `Ref<NodeSchedule>` — mutable Effect references break structural
1368
- * equality semantics, making `Data.TaggedClass` unsuitable here. The
1369
- * `_tag` field is set manually to preserve tagged-union compatibility.
1370
- *
1371
- * Use {@link NodeRelease.fromInput} to construct instances; call
1372
- * {@link NodeRelease.phase} or {@link NodeRelease.lts} to query the lifecycle
1373
- * state of the release at a given point in time.
1374
- *
1375
- * @see {@link NodeReleaseCache}
1376
- * @see {@link NodeResolver}
1377
- * @see {@link NodeSchedule}
1378
- *
1379
- * @example
1380
- * ```typescript
1381
- * import { Effect, Ref } from "effect";
1382
- * import type { NodePhase } from "./common.js";
1383
- * import type { NodeRelease } from "./node-release.js";
1384
- * import { NodeRelease as NodeReleaseClass } from "./node-release.js";
1385
- * import { NodeSchedule } from "./node-schedule.js";
1386
- *
1387
- * const program = Effect.gen(function* () {
1388
- * const schedule = NodeSchedule.fromData({
1389
- * v20: { start: "2023-04-18", lts: "2023-10-24", end: "2026-04-30" },
1390
- * });
1391
- * const scheduleRef = yield* Ref.make(schedule);
1392
- *
1393
- * const release: NodeRelease = yield* NodeReleaseClass.fromInput(
1394
- * { version: "v20.0.0", npm: "9.6.4", date: "2023-04-18" },
1395
- * scheduleRef,
1396
- * );
1397
- *
1398
- * const phase: NodePhase | null = yield* release.phase();
1399
- * const isLts: boolean = yield* release.lts();
1400
- * console.log(phase); // e.g. "active-lts"
1401
- * console.log(isLts); // true
1402
- * });
1403
- *
1404
- * Effect.runPromise(program);
1405
- * ```
1406
- *
1407
- * @public
1408
- */
1409
- declare class NodeRelease {
1410
- readonly version: SemVer;
1411
- readonly npm: SemVer;
1412
- readonly date: DateTime.DateTime;
1413
- readonly scheduleRef: Ref.Ref<NodeSchedule>;
1414
- readonly _tag: "NodeRelease";
1415
- constructor(version: SemVer, npm: SemVer, date: DateTime.DateTime, scheduleRef: Ref.Ref<NodeSchedule>);
1416
- /**
1417
- * Determine this release's lifecycle phase at the given point in time.
1418
- *
1419
- * Reads the current value of the shared `scheduleRef` and delegates to
1420
- * {@link NodeSchedule.phaseFor}. Defaults to the current wall-clock time
1421
- * when `now` is omitted.
1422
- *
1423
- * @param now - Optional reference time; defaults to `new Date()`.
1424
- * @returns An `Effect` that resolves to a `NodePhase` string, or
1425
- * `null` when the major version is not present in the schedule or has
1426
- * not yet been released.
1427
- */
1428
- phase(now?: DateTime.DateTime): Effect.Effect<NodePhase | null>;
1429
- /**
1430
- * Whether this release is currently in Long-Term Support.
1431
- *
1432
- * Returns `true` for both `"active-lts"` and `"maintenance-lts"` phases.
1433
- * Defaults to the current wall-clock time when `now` is omitted.
1434
- *
1435
- * @param now - Optional reference time; defaults to `new Date()`.
1436
- */
1437
- lts(now?: DateTime.DateTime): Effect.Effect<boolean>;
1438
- /**
1439
- * Create a {@link NodeRelease} from lean string inputs.
1440
- *
1441
- * Parses `input.version` and `input.npm` via `SemVer.parse` and
1442
- * constructs the publication date with `DateTime.unsafeMake`.
1443
- *
1444
- * @param input - A {@link (NodeReleaseInput:type)} object with raw string fields.
1445
- * @param scheduleRef - A shared `Ref<NodeSchedule>` injected by the cache layer.
1446
- * @returns An `Effect` that succeeds with a `NodeRelease` or fails with an
1447
- * `InvalidVersionError` when either version string cannot be parsed.
1448
- */
1449
- static fromInput(input: NodeReleaseInput, scheduleRef: Ref.Ref<NodeSchedule>): Effect.Effect<NodeRelease, InvalidVersionError>;
1450
- }
1451
- //#endregion
1452
- //#region src/services/NodeReleaseCache.d.ts
1453
- declare const NodeReleaseCache_base: Context.TagClass<NodeReleaseCache, "runtime-resolver/NodeReleaseCache", RuntimeCache<NodeRelease> & {
1454
- /**
1455
- * Merges Node.js release-schedule data into the cache, updating lifecycle
1456
- * phase information (LTS dates, end-of-life dates, etc.) for every major
1457
- * release line.
1458
- *
1459
- * @param data - Parsed schedule payload, typically fetched via
1460
- * {@link NodeScheduleFetcher}.
1461
- *
1462
- * @see {@link NodeScheduleData}
1463
- */
1464
- readonly updateSchedule: (data: NodeScheduleData) => Effect.Effect<void>;
1465
- /**
1466
- * Populates the cache from raw {@link (NodeReleaseInput:type)} records (as
1467
- * returned by the Node.js release index JSON) rather than from already-
1468
- * decoded {@link NodeRelease} objects.
1469
- *
1470
- * Prefer this over `load` when consuming data directly from the Node.js
1471
- * distribution server.
1472
- *
1473
- * @param inputs - An array of un-decoded release index entries.
1474
- *
1475
- * @see {@link (NodeReleaseInput:type)}
1476
- */
1477
- readonly loadFromInputs: (inputs: ReadonlyArray<NodeReleaseInput>) => Effect.Effect<void>;
1478
- /**
1479
- * Returns all cached releases whose lifecycle phase is `"active-lts"` or
1480
- * `"maintenance-lts"` as of the given point in time.
1481
- *
1482
- * When `now` is omitted the current wall-clock time is used.
1483
- *
1484
- * @param now - Optional reference timestamp for phase evaluation.
1485
- *
1486
- * @see {@link NodeRelease}
1487
- */
1488
- readonly ltsReleases: (now?: DateTime.DateTime) => Effect.Effect<ReadonlyArray<NodeRelease>>;
1489
- /**
1490
- * Returns all cached releases whose lifecycle phase is `"current"` as of
1491
- * the given point in time.
1492
- *
1493
- * When `now` is omitted the current wall-clock time is used.
1494
- *
1495
- * @param now - Optional reference timestamp for phase evaluation.
1496
- *
1497
- * @see {@link NodeRelease}
1498
- */
1499
- readonly currentReleases: (now?: DateTime.DateTime) => Effect.Effect<ReadonlyArray<NodeRelease>>;
1500
- }>;
1501
- /**
1502
- * Node.js-specific cache service that extends {@link RuntimeCache} with
1503
- * additional operations for lifecycle schedule data and LTS / current
1504
- * release filtering.
1505
- *
1506
- * Unlike the Bun and Deno equivalents this service is not a plain type alias
1507
- * — it adds four Node-specific methods on top of the generic cache contract.
1508
- *
1509
- * @example
1510
- * ```typescript
1511
- * import type { NodeRelease } from "runtime-resolver";
1512
- * import { NodeReleaseCache, OfflineNodeCacheLive } from "runtime-resolver";
1513
- * import { Effect } from "effect";
1514
- *
1515
- * const program = Effect.gen(function* () {
1516
- * const cache = yield* NodeReleaseCache;
1517
- * const lts = yield* cache.ltsReleases();
1518
- * for (const release of lts) {
1519
- * console.log(release.version.toString(), release.phase);
1520
- * }
1521
- * });
1522
- *
1523
- * Effect.runPromise(program.pipe(Effect.provide(OfflineNodeCacheLive)));
1524
- * ```
1525
- *
1526
- * @see {@link NodeRelease}
1527
- * @see {@link NodeScheduleData}
1528
- * @see {@link RuntimeCache}
1529
- * @see {@link AutoNodeCacheLive}
1530
- * @see {@link FreshNodeCacheLive}
1531
- * @see {@link OfflineNodeCacheLive}
1532
- *
1533
- * @public
1534
- */
1535
- declare class NodeReleaseCache extends NodeReleaseCache_base {}
1536
- //#endregion
1537
- //#region src/services/NodeScheduleFetcher.d.ts
1538
- declare const NodeScheduleFetcher_base: Context.TagClass<NodeScheduleFetcher, "runtime-resolver/NodeScheduleFetcher", {
1539
- /**
1540
- * Fetches and decodes the Node.js release schedule JSON, returning a
1541
- * typed {@link NodeScheduleData} map keyed by major release line.
1542
- *
1543
- * Fails with:
1544
- * - {@link NetworkError} — the upstream request could not be completed.
1545
- * - {@link ParseError} — the response payload could not be decoded.
1546
- */
1547
- readonly fetch: () => Effect.Effect<NodeScheduleData, NetworkError | ParseError>;
1548
- }>;
1549
- /**
1550
- * Service for fetching the official Node.js release schedule.
1551
- *
1552
- * The schedule maps each major release line to its LTS start date and
1553
- * end-of-life date, and is used by {@link NodeReleaseCache} to assign
1554
- * lifecycle phases to individual releases. The live implementation fetches
1555
- * from the `nodejs/Release` GitHub repository via a plain HTTP request.
1556
- *
1557
- * @example
1558
- * ```typescript
1559
- * import type { NodeScheduleData } from "runtime-resolver";
1560
- * import { NodeScheduleFetcher, NodeScheduleFetcherLive } from "runtime-resolver";
1561
- * import { Effect } from "effect";
1562
- *
1563
- * const program = Effect.gen(function* () {
1564
- * const fetcher = yield* NodeScheduleFetcher;
1565
- * const schedule = yield* fetcher.fetch();
1566
- * console.log(Object.keys(schedule).length, "major release lines");
1567
- * });
1568
- *
1569
- * Effect.runPromise(program.pipe(Effect.provide(NodeScheduleFetcherLive)));
1570
- * ```
1571
- *
1572
- * @see {@link NodeScheduleFetcherLive}
1573
- * @see {@link NodeReleaseCache}
1574
- * @see {@link NodeScheduleData}
1575
- * @see {@link NetworkError}
1576
- * @see {@link ParseError}
1577
- *
1578
- * @public
1579
- */
1580
- declare class NodeScheduleFetcher extends NodeScheduleFetcher_base {}
1581
- //#endregion
1582
- //#region src/services/NodeVersionFetcher.d.ts
1583
- declare const NodeVersionFetcher_base: Context.TagClass<NodeVersionFetcher, "runtime-resolver/NodeVersionFetcher", {
1584
- /**
1585
- * Fetches all available Node.js releases from the distribution index and
1586
- * returns both the parsed semver version objects and the raw release input
1587
- * records.
1588
- *
1589
- * Fails with:
1590
- * - {@link NetworkError} — the upstream request could not be completed.
1591
- * - {@link ParseError} — the response payload could not be decoded.
1592
- */
1593
- readonly fetch: () => Effect.Effect<{
1594
- readonly versions: ReadonlyArray<SemVer>;
1595
- readonly inputs: ReadonlyArray<NodeReleaseInput>;
1596
- }, NetworkError | ParseError>;
1597
- }>;
1598
- /**
1599
- * Service for fetching Node.js release data from the official
1600
- * Node.js distribution index.
1601
- *
1602
- * Retrieves both the parsed semver version list and the raw
1603
- * {@link (NodeReleaseInput:type)} records needed to populate a
1604
- * {@link NodeReleaseCache}. The live implementation fetches from
1605
- * `https://nodejs.org/dist/index.json` via a plain HTTP request — no GitHub
1606
- * credentials are required.
1607
- *
1608
- * @example
1609
- * ```typescript
1610
- * import type { NodeReleaseInput } from "runtime-resolver";
1611
- * import { NodeVersionFetcher, NodeVersionFetcherLive } from "runtime-resolver";
1612
- * import { Effect } from "effect";
1613
- *
1614
- * const program = Effect.gen(function* () {
1615
- * const fetcher = yield* NodeVersionFetcher;
1616
- * const { versions, inputs } = yield* fetcher.fetch();
1617
- * console.log(`Fetched ${versions.length} Node.js releases`);
1618
- * });
1619
- *
1620
- * Effect.runPromise(program.pipe(Effect.provide(NodeVersionFetcherLive)));
1621
- * ```
1622
- *
1623
- * @see {@link NodeVersionFetcherLive}
1624
- * @see {@link NodeReleaseCache}
1625
- * @see {@link NetworkError}
1626
- * @see {@link ParseError}
1627
- *
1628
- * @public
1629
- */
1630
- declare class NodeVersionFetcher extends NodeVersionFetcher_base {}
1631
- //#endregion
1632
- //#region src/layers/AutoNodeCacheLive.d.ts
1633
- /**
1634
- * Provides the {@link NodeReleaseCache} service using the "Auto" cache strategy.
1635
- *
1636
- * Attempts to fetch live release data from `nodejs.org/dist/index.json` via
1637
- * {@link NodeVersionFetcher} and the release schedule from the `nodejs/Release`
1638
- * repository via {@link NodeScheduleFetcher}. If either fetch fails — due to
1639
- * network errors or parse errors — the layer silently falls back to bundled
1640
- * default data (both version list and schedule) so it always succeeds.
1641
- *
1642
- * Node.js requires both a version fetcher and a schedule fetcher because LTS and
1643
- * maintenance phase information is tracked separately from the version index.
1644
- *
1645
- * The three Node cache strategy layers are:
1646
- * - `AutoNodeCacheLive` — tries API first, falls back to bundled defaults on any error
1647
- * - {@link FreshNodeCacheLive} — requires live API data, fails with `FreshnessError` if unavailable
1648
- * - {@link OfflineNodeCacheLive} — uses only bundled defaults, no network I/O
1649
- *
1650
- * @see {@link NodeReleaseCache}
1651
- * @see {@link FreshNodeCacheLive}
1652
- * @see {@link OfflineNodeCacheLive}
1653
- * @public
1654
- */
1655
- declare const AutoNodeCacheLive: Layer.Layer<NodeReleaseCache, never, NodeVersionFetcher | NodeScheduleFetcher>;
1656
- //#endregion
1657
- //#region src/layers/BunReleaseCacheLive.d.ts
1658
- /**
1659
- * Low-level layer that constructs the {@link BunReleaseCache} service backed by
1660
- * a `SemVerVersionCache` instance from `semver-effect`.
1661
- *
1662
- * This layer wires up the cache storage but does not populate it with any
1663
- * release data. Callers are responsible for loading releases after construction.
1664
- * In normal usage you should prefer the higher-level cache strategy layers
1665
- * instead of using this layer directly:
1666
- * - {@link AutoBunCacheLive} — API with fallback to bundled defaults
1667
- * - {@link FreshBunCacheLive} — API only, fails if unavailable
1668
- * - {@link OfflineBunCacheLive} — bundled defaults only
1669
- *
1670
- * @see {@link BunReleaseCache}
1671
- * @see {@link createRuntimeCache}
1672
- * @internal
1673
- */
1674
- declare const BunReleaseCacheLive: Layer.Layer<BunReleaseCache, never, VersionCache>;
1675
- //#endregion
1676
- //#region src/layers/BunResolverLive.d.ts
1677
- /**
1678
- * Provides the {@link BunResolver} service backed by a {@link BunReleaseCache}.
1679
- *
1680
- * This layer composes with any of the three Bun cache strategy layers to form
1681
- * a complete resolver stack. It implements semver range filtering and increment
1682
- * grouping (latest per major, latest per minor, or all patch versions) using
1683
- * the releases already loaded into the cache.
1684
- *
1685
- * @example
1686
- * ```ts
1687
- * import { BunResolverLive, AutoBunCacheLive, BunVersionFetcherLive, GitHubClientLive, GitHubAutoAuth } from "runtime-resolver";
1688
- * import type { ResolvedVersions } from "runtime-resolver";
1689
- * import { BunResolver } from "runtime-resolver";
1690
- * import { Effect, Layer } from "effect";
1691
- *
1692
- * const GitHubLayer = GitHubClientLive.pipe(Layer.provide(GitHubAutoAuth));
1693
- * const CacheLayer = AutoBunCacheLive.pipe(Layer.provide(BunVersionFetcherLive.pipe(Layer.provide(GitHubLayer))));
1694
- * const ResolverLayer = BunResolverLive.pipe(Layer.provide(CacheLayer));
1695
- *
1696
- * const program = Effect.gen(function* () {
1697
- * const resolver = yield* BunResolver;
1698
- * const result = yield* resolver.resolve({ semverRange: "^1.0.0" });
1699
- * console.log(result.latest);
1700
- * });
1701
- *
1702
- * Effect.runPromise(program.pipe(Effect.provide(ResolverLayer)));
1703
- * ```
1704
- *
1705
- * @see {@link BunResolver}
1706
- * @see {@link BunReleaseCache}
1707
- * @see {@link AutoBunCacheLive}
1708
- * @see {@link FreshBunCacheLive}
1709
- * @see {@link OfflineBunCacheLive}
1710
- * @public
1711
- */
1712
- declare const BunResolverLive: Layer.Layer<BunResolver, never, BunReleaseCache>;
1713
- //#endregion
1714
- //#region src/schemas/github.d.ts
1715
- /**
1716
- * A single tag entry as returned by the GitHub REST API
1717
- * (`GET /repos/{owner}/{repo}/tags`).
1718
- *
1719
- * Consumed by {@link GitHubClient} when fetching Bun and Deno release tags.
1720
- *
1721
- * @see {@link GitHubClient}
1722
- * @see `GitHubTagList`
1723
- *
1724
- * @public
1725
- */
1726
- declare const GitHubTag: Schema.Struct<{
1727
- name: typeof Schema.String;
1728
- zipball_url: typeof Schema.String;
1729
- tarball_url: typeof Schema.String;
1730
- commit: Schema.Struct<{
1731
- sha: typeof Schema.String;
1732
- url: typeof Schema.String;
1733
- }>;
1734
- node_id: typeof Schema.String;
1735
- }>;
1736
- /**
1737
- * A single tag entry as returned by the GitHub REST API.
1738
- *
1739
- * @see {@link GitHubClient}
1740
- *
1741
- * @public
1742
- */
1743
- type GitHubTag = typeof GitHubTag.Type;
1744
- /**
1745
- * A single release entry as returned by the GitHub REST API
1746
- * (`GET /repos/{owner}/{repo}/releases`).
1747
- *
1748
- * Consumed by {@link GitHubClient} when fetching Deno releases that carry
1749
- * publication timestamps.
1750
- *
1751
- * @see {@link GitHubClient}
1752
- * @see `GitHubReleaseList`
1753
- *
1754
- * @public
1755
- */
1756
- declare const GitHubRelease: Schema.Struct<{
1757
- tag_name: typeof Schema.String;
1758
- name: Schema.NullOr<typeof Schema.String>;
1759
- draft: typeof Schema.Boolean;
1760
- prerelease: typeof Schema.Boolean;
1761
- published_at: Schema.NullOr<typeof Schema.String>;
1762
- }>;
1763
- /**
1764
- * A single release entry as returned by the GitHub REST API.
1765
- *
1766
- * @see {@link GitHubClient}
1767
- *
1768
- * @public
1769
- */
1770
- type GitHubRelease = typeof GitHubRelease.Type;
1771
- //#endregion
1772
- //#region src/services/GitHubClient.d.ts
1773
- /**
1774
- * Pagination options shared by all list operations on {@link GitHubClient}.
1775
- *
1776
- * @see {@link GitHubClient}
1777
- *
1778
- * @public
1779
- */
1780
- interface ListOptions {
1781
- /**
1782
- * Number of items to request per page. Defaults to the GitHub API maximum
1783
- * of `100` when omitted.
1784
- */
1785
- readonly perPage?: number;
1786
- /**
1787
- * Maximum number of pages to fetch. When omitted all pages are fetched
1788
- * until the API returns an empty result set.
1789
- */
1790
- readonly pages?: number;
1791
- }
1792
- declare const GitHubClient_base: Context.TagClass<GitHubClient, "runtime-resolver/GitHubClient", {
1793
- /**
1794
- * Lists all git tags for the given repository, automatically paginating
1795
- * through results according to `options`.
1796
- *
1797
- * Fails with:
1798
- * - {@link AuthenticationError} — missing or invalid GitHub credentials.
1799
- * - {@link NetworkError} — the upstream request could not be completed.
1800
- * - {@link RateLimitError} — the GitHub API rate limit was exceeded.
1801
- * - {@link ParseError} — a response page could not be decoded.
1802
- *
1803
- * @param owner - GitHub organisation or user name (e.g. `"oven-sh"`).
1804
- * @param repo - Repository name (e.g. `"bun"`).
1805
- * @param options - Optional pagination controls.
1806
- */
1807
- readonly listTags: (owner: string, repo: string, options?: ListOptions) => Effect.Effect<ReadonlyArray<GitHubTag>, AuthenticationError | NetworkError | RateLimitError | ParseError>;
1808
- /**
1809
- * Lists all GitHub Releases for the given repository, automatically
1810
- * paginating through results according to `options`.
1811
- *
1812
- * Fails with:
1813
- * - {@link AuthenticationError} — missing or invalid GitHub credentials.
1814
- * - {@link NetworkError} — the upstream request could not be completed.
1815
- * - {@link RateLimitError} — the GitHub API rate limit was exceeded.
1816
- * - {@link ParseError} — a response page could not be decoded.
1817
- *
1818
- * @param owner - GitHub organisation or user name (e.g. `"denoland"`).
1819
- * @param repo - Repository name (e.g. `"deno"`).
1820
- * @param options - Optional pagination controls.
1821
- */
1822
- readonly listReleases: (owner: string, repo: string, options?: ListOptions) => Effect.Effect<ReadonlyArray<GitHubRelease>, AuthenticationError | NetworkError | RateLimitError | ParseError>;
1823
- /**
1824
- * Fetches arbitrary JSON from `url` and decodes it with the provided
1825
- * schema, returning the typed result.
1826
- *
1827
- * Useful for endpoints outside the standard Octokit REST methods (e.g.
1828
- * raw GitHub content URLs).
1829
- *
1830
- * Fails with:
1831
- * - {@link NetworkError} — the upstream request could not be completed.
1832
- * - {@link ParseError} — the response body could not be decoded by `schema`.
1833
- *
1834
- * @typeParam A - The decoded output type produced by `schema`.
1835
- * @param url - Fully qualified URL to fetch.
1836
- * @param schema - An object with a `decode` method compatible with
1837
- * Effect Schema's `decodeUnknown`.
1838
- */
1839
- readonly getJson: <A>(url: string, schema: {
1840
- readonly decode: (input: unknown) => Effect.Effect<A, ParseError>;
1841
- }) => Effect.Effect<A, NetworkError | ParseError>;
1842
- }>;
1843
- /**
1844
- * Service for GitHub REST API operations used by the version
1845
- * fetcher services.
1846
- *
1847
- * Abstracts over pagination and authentication so that higher-level services
1848
- * such as {@link BunVersionFetcher}, {@link DenoVersionFetcher}, and
1849
- * {@link NodeScheduleFetcher} remain independent of the underlying HTTP
1850
- * transport. The live implementation is provided by {@link GitHubClientLive}
1851
- * and requires an {@link OctokitInstance} in its dependency graph.
1852
- *
1853
- * @example
1854
- * ```typescript
1855
- * import type { GitHubTag } from "runtime-resolver";
1856
- * import { GitHubClient, GitHubClientLive, GitHubAutoAuth } from "runtime-resolver";
1857
- * import { Effect } from "effect";
1858
- *
1859
- * const program = Effect.gen(function* () {
1860
- * const client = yield* GitHubClient;
1861
- * const tags = yield* client.listTags("oven-sh", "bun", { perPage: 100 });
1862
- * console.log(`Found ${tags.length} tags`);
1863
- * });
1864
- *
1865
- * Effect.runPromise(
1866
- * program.pipe(Effect.provide(GitHubClientLive), Effect.provide(GitHubAutoAuth)),
1867
- * );
1868
- * ```
1869
- *
1870
- * @see {@link GitHubClientLive}
1871
- * @see {@link OctokitInstance}
1872
- * @see {@link ListOptions}
1873
- *
1874
- * @public
1875
- */
1876
- declare class GitHubClient extends GitHubClient_base {}
1877
- //#endregion
1878
- //#region src/layers/BunVersionFetcherLive.d.ts
1879
- /**
1880
- * Provides the {@link BunVersionFetcher} service using the live GitHub API.
1881
- *
1882
- * Fetches Bun releases from the `oven-sh/bun` GitHub repository using the
1883
- * provided {@link GitHubClient}. Draft releases and pre-releases are excluded.
1884
- * Tag names are normalized by stripping the `bun-` prefix and any leading `v`
1885
- * or `V` before parsing as semver.
1886
- *
1887
- * This layer is a required dependency of {@link AutoBunCacheLive} and
1888
- * {@link FreshBunCacheLive}. It is not needed by {@link OfflineBunCacheLive}.
1889
- *
1890
- * @see {@link BunVersionFetcher}
1891
- * @see {@link GitHubClient}
1892
- * @see {@link AutoBunCacheLive}
1893
- * @see {@link FreshBunCacheLive}
1894
- * @public
1895
- */
1896
- declare const BunVersionFetcherLive: Layer.Layer<BunVersionFetcher, never, GitHubClient>;
1897
- //#endregion
1898
- //#region src/layers/DenoReleaseCacheLive.d.ts
1899
- /**
1900
- * Low-level layer that constructs the {@link DenoReleaseCache} service backed by
1901
- * a `SemVerVersionCache` instance from `semver-effect`.
1902
- *
1903
- * This layer wires up the cache storage but does not populate it with any
1904
- * release data. Callers are responsible for loading releases after construction.
1905
- * In normal usage you should prefer the higher-level cache strategy layers
1906
- * instead of using this layer directly:
1907
- * - {@link AutoDenoCacheLive} — API with fallback to bundled defaults
1908
- * - {@link FreshDenoCacheLive} — API only, fails if unavailable
1909
- * - {@link OfflineDenoCacheLive} — bundled defaults only
1910
- *
1911
- * @see {@link DenoReleaseCache}
1912
- * @see {@link createRuntimeCache}
1913
- * @internal
1914
- */
1915
- declare const DenoReleaseCacheLive: Layer.Layer<DenoReleaseCache, never, VersionCache>;
1916
- //#endregion
1917
- //#region src/layers/DenoResolverLive.d.ts
1918
- /**
1919
- * Provides the {@link DenoResolver} service backed by a {@link DenoReleaseCache}.
1920
- *
1921
- * This layer composes with any of the three Deno cache strategy layers to form
1922
- * a complete resolver stack. It implements semver range filtering and increment
1923
- * grouping (latest per major, latest per minor, or all patch versions) using
1924
- * the releases already loaded into the cache.
1925
- *
1926
- * @example
1927
- * ```ts
1928
- * import { DenoResolverLive, AutoDenoCacheLive, DenoVersionFetcherLive, GitHubClientLive, GitHubAutoAuth } from "runtime-resolver";
1929
- * import { DenoResolver } from "runtime-resolver";
1930
- * import { Effect, Layer } from "effect";
1931
- *
1932
- * const GitHubLayer = GitHubClientLive.pipe(Layer.provide(GitHubAutoAuth));
1933
- * const CacheLayer = AutoDenoCacheLive.pipe(Layer.provide(DenoVersionFetcherLive.pipe(Layer.provide(GitHubLayer))));
1934
- * const ResolverLayer = DenoResolverLive.pipe(Layer.provide(CacheLayer));
1935
- *
1936
- * const program = Effect.gen(function* () {
1937
- * const resolver = yield* DenoResolver;
1938
- * const result = yield* resolver.resolve({ semverRange: "^2.0.0" });
1939
- * console.log(result.latest);
1940
- * });
1941
- *
1942
- * Effect.runPromise(program.pipe(Effect.provide(ResolverLayer)));
1943
- * ```
1944
- *
1945
- * @see {@link DenoResolver}
1946
- * @see {@link DenoReleaseCache}
1947
- * @see {@link AutoDenoCacheLive}
1948
- * @see {@link FreshDenoCacheLive}
1949
- * @see {@link OfflineDenoCacheLive}
1950
- * @public
1951
- */
1952
- declare const DenoResolverLive: Layer.Layer<DenoResolver, never, DenoReleaseCache>;
1953
- //#endregion
1954
- //#region src/layers/DenoVersionFetcherLive.d.ts
1955
- /**
1956
- * Provides the {@link DenoVersionFetcher} service using the live GitHub API.
1957
- *
1958
- * Fetches Deno releases from the `denoland/deno` GitHub repository using the
1959
- * provided {@link GitHubClient}. Draft releases and pre-releases are excluded.
1960
- * Tag names are normalized by stripping any leading `v` before parsing as
1961
- * semver.
1962
- *
1963
- * This layer is a required dependency of {@link AutoDenoCacheLive} and
1964
- * {@link FreshDenoCacheLive}. It is not needed by {@link OfflineDenoCacheLive}.
1965
- *
1966
- * @see {@link DenoVersionFetcher}
1967
- * @see {@link GitHubClient}
1968
- * @see {@link AutoDenoCacheLive}
1969
- * @see {@link FreshDenoCacheLive}
1970
- * @public
1971
- */
1972
- declare const DenoVersionFetcherLive: Layer.Layer<DenoVersionFetcher, never, GitHubClient>;
1973
- //#endregion
1974
- //#region src/layers/FreshBunCacheLive.d.ts
1975
- /**
1976
- * Provides the {@link BunReleaseCache} service using the "Fresh" cache strategy.
1977
- *
1978
- * Requires live release data from the GitHub API via {@link BunVersionFetcher}.
1979
- * If the fetch fails for any reason — authentication errors, network errors,
1980
- * parse errors, or rate-limit errors — the layer fails with a `FreshnessError`
1981
- * rather than falling back to stale data.
1982
- *
1983
- * Use this strategy in contexts where working with outdated version data would
1984
- * be incorrect or misleading, such as CI pipelines or tooling that must reflect
1985
- * the true current state of Bun releases.
1986
- *
1987
- * The three Bun cache strategy layers are:
1988
- * - {@link AutoBunCacheLive} — tries API first, falls back to bundled defaults on any error
1989
- * - `FreshBunCacheLive` — requires live API data, fails with `FreshnessError` if unavailable
1990
- * - {@link OfflineBunCacheLive} — uses only bundled defaults, no network I/O
1991
- *
1992
- * @see {@link BunReleaseCache}
1993
- * @see {@link AutoBunCacheLive}
1994
- * @see {@link OfflineBunCacheLive}
1995
- * @public
1996
- */
1997
- declare const FreshBunCacheLive: Layer.Layer<BunReleaseCache, FreshnessError, BunVersionFetcher>;
1998
- //#endregion
1999
- //#region src/layers/FreshDenoCacheLive.d.ts
2000
- /**
2001
- * Provides the {@link DenoReleaseCache} service using the "Fresh" cache strategy.
2002
- *
2003
- * Requires live release data from the GitHub API via {@link DenoVersionFetcher}.
2004
- * If the fetch fails for any reason — authentication errors, network errors,
2005
- * parse errors, or rate-limit errors — the layer fails with a `FreshnessError`
2006
- * rather than falling back to stale data.
2007
- *
2008
- * Use this strategy in contexts where working with outdated version data would
2009
- * be incorrect or misleading, such as CI pipelines or tooling that must reflect
2010
- * the true current state of Deno releases.
2011
- *
2012
- * The three Deno cache strategy layers are:
2013
- * - {@link AutoDenoCacheLive} — tries API first, falls back to bundled defaults on any error
2014
- * - `FreshDenoCacheLive` — requires live API data, fails with `FreshnessError` if unavailable
2015
- * - {@link OfflineDenoCacheLive} — uses only bundled defaults, no network I/O
2016
- *
2017
- * @see {@link DenoReleaseCache}
2018
- * @see {@link AutoDenoCacheLive}
2019
- * @see {@link OfflineDenoCacheLive}
2020
- * @public
2021
- */
2022
- declare const FreshDenoCacheLive: Layer.Layer<DenoReleaseCache, FreshnessError, DenoVersionFetcher>;
2023
- //#endregion
2024
- //#region src/layers/FreshNodeCacheLive.d.ts
2025
- /**
2026
- * Provides the {@link NodeReleaseCache} service using the "Fresh" cache strategy.
2027
- *
2028
- * Requires live release data from `nodejs.org/dist/index.json` via
2029
- * {@link NodeVersionFetcher} and the release schedule from the `nodejs/Release`
2030
- * repository via {@link NodeScheduleFetcher}. If either fetch fails — due to
2031
- * network errors or parse errors — the layer fails with a `FreshnessError`
2032
- * rather than falling back to stale data.
2033
- *
2034
- * Use this strategy in contexts where working with outdated version data would
2035
- * be incorrect or misleading, such as CI pipelines or tooling that must reflect
2036
- * the true current state of Node.js releases and LTS schedule.
2037
- *
2038
- * The three Node cache strategy layers are:
2039
- * - {@link AutoNodeCacheLive} — tries API first, falls back to bundled defaults on any error
2040
- * - `FreshNodeCacheLive` — requires live API data, fails with `FreshnessError` if unavailable
2041
- * - {@link OfflineNodeCacheLive} — uses only bundled defaults, no network I/O
2042
- *
2043
- * @see {@link NodeReleaseCache}
2044
- * @see {@link AutoNodeCacheLive}
2045
- * @see {@link OfflineNodeCacheLive}
2046
- * @public
2047
- */
2048
- declare const FreshNodeCacheLive: Layer.Layer<NodeReleaseCache, FreshnessError, NodeVersionFetcher | NodeScheduleFetcher>;
2049
- //#endregion
2050
- //#region src/services/OctokitInstance.d.ts
2051
- declare const OctokitInstance_base: Context.TagClass<OctokitInstance, "runtime-resolver/OctokitInstance", {
2052
- readonly rest: {
2053
- readonly repos: {
2054
- /**
2055
- * Lists git tags for a repository, corresponding to
2056
- * `GET /repos/{owner}/{repo}/tags`.
2057
- *
2058
- * @param params - Owner, repo, and optional pagination parameters.
2059
- */
2060
- readonly listTags: (params: {
2061
- owner: string;
2062
- repo: string;
2063
- per_page?: number;
2064
- page?: number;
2065
- }) => Promise<{
2066
- data: Array<unknown>;
2067
- }>;
2068
- /**
2069
- * Lists GitHub Releases for a repository, corresponding to
2070
- * `GET /repos/{owner}/{repo}/releases`.
2071
- *
2072
- * @param params - Owner, repo, and optional pagination parameters.
2073
- */
2074
- readonly listReleases: (params: {
2075
- owner: string;
2076
- repo: string;
2077
- per_page?: number;
2078
- page?: number;
2079
- }) => Promise<{
2080
- data: Array<unknown>;
2081
- }>;
2082
- };
2083
- };
2084
- }>;
2085
- /**
2086
- * Thin wrapper around the subset of Octokit's REST client used by
2087
- * {@link GitHubClient}.
2088
- *
2089
- * Exposing only the repository methods actually consumed by this library
2090
- * keeps the surface area narrow and makes the interface straightforward to
2091
- * stub in tests without pulling in the full Octokit type.
2092
- *
2093
- * An `OctokitInstance` is provided to the dependency graph by one of the
2094
- * three authentication layers: {@link GitHubTokenAuth}, {@link GitHubAppAuth},
2095
- * or {@link GitHubAutoAuth}.
2096
- *
2097
- * @example
2098
- * ```typescript
2099
- * import { OctokitInstance, GitHubClientLive, GitHubAutoAuth } from "runtime-resolver";
2100
- * import { Effect } from "effect";
2101
- *
2102
- * const program = Effect.gen(function* () {
2103
- * const octokit = yield* OctokitInstance;
2104
- * const response = await octokit.rest.repos.listTags({
2105
- * owner: "oven-sh",
2106
- * repo: "bun",
2107
- * per_page: 10,
2108
- * });
2109
- * console.log(response.data.length);
2110
- * });
2111
- *
2112
- * Effect.runPromise(program.pipe(Effect.provide(GitHubAutoAuth)));
2113
- * ```
2114
- *
2115
- * @see {@link GitHubClientLive}
2116
- * @see {@link GitHubTokenAuth}
2117
- * @see {@link GitHubAppAuth}
2118
- * @see {@link GitHubAutoAuth}
2119
- *
2120
- * @public
2121
- */
2122
- declare class OctokitInstance extends OctokitInstance_base {}
2123
- //#endregion
2124
- //#region src/layers/GitHubAppAuth.d.ts
2125
- /**
2126
- * Configuration required to authenticate as a GitHub App installation.
2127
- *
2128
- * @see {@link GitHubAppAuth}
2129
- * @public
2130
- */
2131
- interface GitHubAppAuthConfig {
2132
- readonly appId: string;
2133
- readonly privateKey: string;
2134
- readonly installationId?: number;
2135
- }
2136
- /**
2137
- * Provides an {@link OctokitInstance} authenticated as a GitHub App installation.
2138
- *
2139
- * Accepts a {@link GitHubAppAuthConfig} and uses `@octokit/auth-app` to obtain
2140
- * an installation access token. If `installationId` is omitted, the first
2141
- * installation returned by the GitHub API is used automatically (suitable for
2142
- * apps with a single installation). If authentication fails for any reason the
2143
- * layer fails with an `AuthenticationError`.
2144
- *
2145
- * Use this auth method when your integration runs as a GitHub App rather than
2146
- * as an individual user or a CI token.
2147
- *
2148
- * @param config - App credentials and optional installation ID.
2149
- *
2150
- * @see {@link GitHubAppAuthConfig}
2151
- * @see {@link OctokitInstance}
2152
- * @see {@link GitHubAutoAuth}
2153
- * @see {@link GitHubTokenAuth}
2154
- * @public
2155
- */
2156
- declare const GitHubAppAuth: (config: GitHubAppAuthConfig) => Layer.Layer<OctokitInstance, AuthenticationError>;
2157
- //#endregion
2158
- //#region src/layers/GitHubAutoAuth.d.ts
2159
- /**
2160
- * Provides an {@link OctokitInstance} by auto-detecting the available
2161
- * authentication credentials from environment variables at layer construction
2162
- * time.
2163
- *
2164
- * Credentials are evaluated in the following priority order:
2165
- * 1. **GitHub App** — when both `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY`
2166
- * are set, authenticates as a GitHub App installation via {@link GitHubAppAuth}.
2167
- * `GITHUB_APP_INSTALLATION_ID` is optional; if absent the first installation
2168
- * is used automatically.
2169
- * 2. **Personal Access Token** — when `GITHUB_PERSONAL_ACCESS_TOKEN` is set,
2170
- * authenticates with that token.
2171
- * 3. **`GITHUB_TOKEN`** — when `GITHUB_TOKEN` is set (e.g., the default token
2172
- * injected in GitHub Actions), authenticates with that token.
2173
- * 4. **Unauthenticated** — falls back to an unauthenticated Octokit instance
2174
- * when no credentials are found (lower rate limits apply).
2175
- *
2176
- * If both App and token credentials are present, App auth takes precedence and
2177
- * a warning is logged. This layer fails with `AuthenticationError` only when
2178
- * App credentials are present but the App authentication itself fails.
2179
- *
2180
- * Use this layer as the default auth strategy in most applications. Switch to
2181
- * {@link GitHubTokenAuth} or {@link GitHubAppAuth} when you need explicit control
2182
- * over which credential source is used.
2183
- *
2184
- * @example
2185
- * ```ts
2186
- * import { GitHubClientLive, GitHubAutoAuth } from "runtime-resolver";
2187
- * import { Layer } from "effect";
2188
- *
2189
- * const GitHubLayer = GitHubClientLive.pipe(Layer.provide(GitHubAutoAuth));
2190
- * ```
2191
- *
2192
- * @see {@link OctokitInstance}
2193
- * @see {@link GitHubTokenAuth}
2194
- * @see {@link GitHubAppAuth}
2195
- * @public
2196
- */
2197
- declare const GitHubAutoAuth: Layer.Layer<OctokitInstance, AuthenticationError>;
2198
- //#endregion
2199
- //#region src/layers/GitHubClientLive.d.ts
2200
- /**
2201
- * Provides the {@link GitHubClient} service backed by an {@link OctokitInstance}.
2202
- *
2203
- * This layer wraps an Octokit instance and exposes a typed, Effect-native API
2204
- * for listing GitHub releases, listing tags, and fetching arbitrary JSON from
2205
- * URLs. HTTP errors are mapped to typed domain errors (`NetworkError`,
2206
- * `RateLimitError`, `AuthenticationError`) so they can be handled precisely in
2207
- * calling code.
2208
- *
2209
- * Pair this layer with one of the auth layers to form a complete GitHub
2210
- * integration stack:
2211
- * - {@link GitHubAutoAuth} — auto-detects auth from environment variables
2212
- * - {@link GitHubTokenAuth} — authenticates using a personal access token
2213
- * - {@link GitHubAppAuth} — authenticates as a GitHub App installation
2214
- *
2215
- * @see {@link GitHubClient}
2216
- * @see {@link OctokitInstance}
2217
- * @see {@link GitHubAutoAuth}
2218
- * @public
2219
- */
2220
- declare const GitHubClientLive: Layer.Layer<GitHubClient, never, OctokitInstance>;
2221
- //#endregion
2222
- //#region src/layers/GitHubTokenAuth.d.ts
2223
- /**
2224
- * Provides an {@link OctokitInstance} authenticated with a GitHub personal
2225
- * access token read from the environment at layer construction time.
2226
- *
2227
- * The token is resolved by checking, in order:
2228
- * 1. `GITHUB_PERSONAL_ACCESS_TOKEN` environment variable
2229
- * 2. `GITHUB_TOKEN` environment variable
2230
- *
2231
- * If neither variable is set the layer constructs an unauthenticated Octokit
2232
- * instance (lower rate limits apply). This layer never fails.
2233
- *
2234
- * Use {@link GitHubTokenAuthFromToken} when you have the token value available
2235
- * programmatically at construction time.
2236
- *
2237
- * @see {@link OctokitInstance}
2238
- * @see {@link GitHubTokenAuthFromToken}
2239
- * @see {@link GitHubAutoAuth}
2240
- * @see {@link GitHubAppAuth}
2241
- * @public
2242
- */
2243
- declare const GitHubTokenAuth: Layer.Layer<OctokitInstance>;
2244
- /**
2245
- * Provides an {@link OctokitInstance} authenticated with the given personal
2246
- * access token string.
2247
- *
2248
- * Use this variant when the token is available as a value in your program
2249
- * rather than read from an environment variable. The resulting layer never
2250
- * fails.
2251
- *
2252
- * @param token - A GitHub personal access token string.
2253
- *
2254
- * @see {@link OctokitInstance}
2255
- * @see {@link GitHubTokenAuth}
2256
- * @see {@link GitHubAutoAuth}
2257
- * @see {@link GitHubAppAuth}
2258
- * @public
2259
- */
2260
- declare const GitHubTokenAuthFromToken: (token: string) => Layer.Layer<OctokitInstance>;
2261
- //#endregion
2262
- //#region src/layers/NodeReleaseCacheLive.d.ts
2263
- /**
2264
- * Low-level layer that constructs the {@link NodeReleaseCache} service backed by
2265
- * a `SemVerVersionCache` instance from `semver-effect`.
2266
- *
2267
- * This layer is more complex than the Bun and Deno equivalents because it manages
2268
- * additional LTS schedule state via an internal `Ref`. The schedule is stored
2269
- * separately from the version list so that calling `updateSchedule` can
2270
- * transparently rebuild all release objects with the latest phase information
2271
- * without reloading data from the network.
2272
- *
2273
- * This layer wires up the cache storage but does not populate it with any
2274
- * release data. Callers are responsible for calling `updateSchedule` and
2275
- * `loadFromInputs` after construction. In normal usage you should prefer the
2276
- * higher-level cache strategy layers instead of using this layer directly:
2277
- * - {@link AutoNodeCacheLive} — API with fallback to bundled defaults
2278
- * - {@link FreshNodeCacheLive} — API only, fails if unavailable
2279
- * - {@link OfflineNodeCacheLive} — bundled defaults only
2280
- *
2281
- * @see {@link NodeReleaseCache}
2282
- * @see {@link createRuntimeCache}
2283
- * @internal
2284
- */
2285
- declare const NodeReleaseCacheLive: Layer.Layer<NodeReleaseCache, never, VersionCache>;
2286
- //#endregion
2287
- //#region src/layers/NodeResolverLive.d.ts
2288
- /**
2289
- * Provides the {@link NodeResolver} service backed by a {@link NodeReleaseCache}.
2290
- *
2291
- * This layer composes with any of the three Node cache strategy layers to form
2292
- * a complete resolver stack. In addition to semver range filtering and increment
2293
- * grouping, it supports filtering by Node.js release phase (e.g., `"current"`,
2294
- * `"active-lts"`, `"maintenance-lts"`, `"end-of-life"`) and automatically
2295
- * determines the current LTS version from the loaded schedule data.
2296
- *
2297
- * @example
2298
- * ```ts
2299
- * import {
2300
- * NodeResolverLive, AutoNodeCacheLive,
2301
- * NodeVersionFetcherLive, NodeScheduleFetcherLive,
2302
- * GitHubClientLive, GitHubAutoAuth,
2303
- * } from "runtime-resolver";
2304
- * import { NodeResolver } from "runtime-resolver";
2305
- * import { Effect, Layer } from "effect";
2306
- *
2307
- * const GitHubLayer = GitHubClientLive.pipe(Layer.provide(GitHubAutoAuth));
2308
- * const FetchersLayer = Layer.merge(
2309
- * NodeVersionFetcherLive.pipe(Layer.provide(GitHubLayer)),
2310
- * NodeScheduleFetcherLive.pipe(Layer.provide(GitHubLayer)),
2311
- * );
2312
- * const CacheLayer = AutoNodeCacheLive.pipe(Layer.provide(FetchersLayer));
2313
- * const ResolverLayer = NodeResolverLive.pipe(Layer.provide(CacheLayer));
2314
- *
2315
- * const program = Effect.gen(function* () {
2316
- * const resolver = yield* NodeResolver;
2317
- * // Resolve only active-LTS and maintenance-LTS releases in the ^20 range
2318
- * const result = yield* resolver.resolve({
2319
- * semverRange: "^20.0.0",
2320
- * phases: ["active-lts", "maintenance-lts"],
2321
- * });
2322
- * console.log(result.lts);
2323
- * });
2324
- *
2325
- * Effect.runPromise(program.pipe(Effect.provide(ResolverLayer)));
2326
- * ```
2327
- *
2328
- * @see {@link NodeResolver}
2329
- * @see {@link NodeReleaseCache}
2330
- * @see {@link AutoNodeCacheLive}
2331
- * @see {@link FreshNodeCacheLive}
2332
- * @see {@link OfflineNodeCacheLive}
2333
- * @public
2334
- */
2335
- declare const NodeResolverLive: Layer.Layer<NodeResolver, never, NodeReleaseCache>;
2336
- //#endregion
2337
- //#region src/layers/NodeScheduleFetcherLive.d.ts
2338
- /**
2339
- * Provides the {@link NodeScheduleFetcher} service using the live Node.js release schedule.
2340
- *
2341
- * Fetches the Node.js release schedule from the raw GitHub content URL for
2342
- * `nodejs/Release` (`schedule.json` on the `main` branch) using the HTTP client
2343
- * on the provided {@link GitHubClient} service. The schedule data maps major
2344
- * version codenames to their start, LTS, and end-of-life dates and is used by
2345
- * {@link NodeReleaseCache} to compute per-release lifecycle phases.
2346
- *
2347
- * This layer is a required dependency of {@link AutoNodeCacheLive} and
2348
- * {@link FreshNodeCacheLive}. It is not needed by {@link OfflineNodeCacheLive}.
2349
- *
2350
- * @see {@link NodeScheduleFetcher}
2351
- * @see {@link GitHubClient}
2352
- * @see {@link AutoNodeCacheLive}
2353
- * @see {@link FreshNodeCacheLive}
2354
- * @public
2355
- */
2356
- declare const NodeScheduleFetcherLive: Layer.Layer<NodeScheduleFetcher, never, GitHubClient>;
2357
- //#endregion
2358
- //#region src/layers/NodeVersionFetcherLive.d.ts
2359
- /**
2360
- * Provides the {@link NodeVersionFetcher} service using the live Node.js dist index.
2361
- *
2362
- * Fetches the full Node.js version list from `https://nodejs.org/dist/index.json`
2363
- * using the HTTP client on the provided {@link GitHubClient} service. Version
2364
- * strings are normalized by stripping the leading `v` before parsing as semver.
2365
- * Entries with non-string `npm` fields (present in very old releases prior to
2366
- * v0.6.3) are substituted with the sentinel version `"0.0.0"`.
2367
- *
2368
- * This layer is a required dependency of {@link AutoNodeCacheLive} and
2369
- * {@link FreshNodeCacheLive}. It is not needed by {@link OfflineNodeCacheLive}.
2370
- *
2371
- * @see {@link NodeVersionFetcher}
2372
- * @see {@link GitHubClient}
2373
- * @see {@link AutoNodeCacheLive}
2374
- * @see {@link FreshNodeCacheLive}
2375
- * @public
2376
- */
2377
- declare const NodeVersionFetcherLive: Layer.Layer<NodeVersionFetcher, never, GitHubClient>;
2378
- //#endregion
2379
- //#region src/layers/OfflineBunCacheLive.d.ts
2380
- /**
2381
- * Provides the {@link BunReleaseCache} service using the "Offline" cache strategy.
2382
- *
2383
- * Uses only the bundled default Bun release data that was baked in at build time.
2384
- * Makes no network requests and has no runtime dependencies. This layer always
2385
- * succeeds immediately.
2386
- *
2387
- * Use this strategy in environments where network access is unavailable or
2388
- * undesirable (e.g., air-gapped systems, hermetic test environments, or any
2389
- * context where version data from the bundle is sufficient).
2390
- *
2391
- * The three Bun cache strategy layers are:
2392
- * - {@link AutoBunCacheLive} — tries API first, falls back to bundled defaults on any error
2393
- * - {@link FreshBunCacheLive} — requires live API data, fails with `FreshnessError` if unavailable
2394
- * - `OfflineBunCacheLive` — uses only bundled defaults, no network I/O
2395
- *
2396
- * @see {@link BunReleaseCache}
2397
- * @see {@link AutoBunCacheLive}
2398
- * @see {@link FreshBunCacheLive}
2399
- * @public
2400
- */
2401
- declare const OfflineBunCacheLive: Layer.Layer<BunReleaseCache>;
2402
- //#endregion
2403
- //#region src/layers/OfflineDenoCacheLive.d.ts
2404
- /**
2405
- * Provides the {@link DenoReleaseCache} service using the "Offline" cache strategy.
2406
- *
2407
- * Uses only the bundled default Deno release data that was baked in at build time.
2408
- * Makes no network requests and has no runtime dependencies. This layer always
2409
- * succeeds immediately.
2410
- *
2411
- * Use this strategy in environments where network access is unavailable or
2412
- * undesirable (e.g., air-gapped systems, hermetic test environments, or any
2413
- * context where version data from the bundle is sufficient).
2414
- *
2415
- * The three Deno cache strategy layers are:
2416
- * - {@link AutoDenoCacheLive} — tries API first, falls back to bundled defaults on any error
2417
- * - {@link FreshDenoCacheLive} — requires live API data, fails with `FreshnessError` if unavailable
2418
- * - `OfflineDenoCacheLive` — uses only bundled defaults, no network I/O
2419
- *
2420
- * @see {@link DenoReleaseCache}
2421
- * @see {@link AutoDenoCacheLive}
2422
- * @see {@link FreshDenoCacheLive}
2423
- * @public
2424
- */
2425
- declare const OfflineDenoCacheLive: Layer.Layer<DenoReleaseCache>;
2426
- //#endregion
2427
- //#region src/layers/OfflineNodeCacheLive.d.ts
2428
- /**
2429
- * Provides the {@link NodeReleaseCache} service using the "Offline" cache strategy.
2430
- *
2431
- * Uses only the bundled default Node.js release data and schedule data that were
2432
- * baked in at build time. Makes no network requests and has no runtime
2433
- * dependencies. This layer always succeeds immediately.
2434
- *
2435
- * Use this strategy in environments where network access is unavailable or
2436
- * undesirable (e.g., air-gapped systems, hermetic test environments, or any
2437
- * context where version data from the bundle is sufficient).
2438
- *
2439
- * The three Node cache strategy layers are:
2440
- * - {@link AutoNodeCacheLive} — tries API first, falls back to bundled defaults on any error
2441
- * - {@link FreshNodeCacheLive} — requires live API data, fails with `FreshnessError` if unavailable
2442
- * - `OfflineNodeCacheLive` — uses only bundled defaults, no network I/O
2443
- *
2444
- * @see {@link NodeReleaseCache}
2445
- * @see {@link AutoNodeCacheLive}
2446
- * @see {@link FreshNodeCacheLive}
2447
- * @public
2448
- */
2449
- declare const OfflineNodeCacheLive: Layer.Layer<NodeReleaseCache>;
2450
- //#endregion
2451
- //#region src/layers/RuntimeCacheLive.d.ts
2452
- /**
2453
- * Factory that creates a {@link RuntimeCache} implementation backed by
2454
- * `semver-effect`'s `VersionCache`.
2455
- *
2456
- * The returned `Effect` must be executed within an Effect context that provides
2457
- * a `SemVerVersionCache` service (i.e., it requires `SemVerVersionCache` in its
2458
- * environment). The cache maintains an internal lookup map from version string
2459
- * to the full release object so that resolved semver versions can be
2460
- * round-tripped back to their typed release records.
2461
- *
2462
- * This factory is used internally by {@link BunReleaseCacheLive},
2463
- * {@link DenoReleaseCacheLive}, and {@link NodeReleaseCacheLive} to build their
2464
- * respective cache service implementations. Prefer those higher-level layers
2465
- * over calling this factory directly.
2466
- *
2467
- * Note: `load` is not concurrency-safe. Callers must not invoke it concurrently.
2468
- * In practice this constraint is upheld because `load` is only called from layer
2469
- * setup and `NodeReleaseCacheLive.loadFromInputs`, both of which are serialized
2470
- * by the Effect runtime.
2471
- *
2472
- * @typeParam R - The runtime release type stored in the cache. Must extend
2473
- * {@link RuntimeRelease}.
2474
- *
2475
- * @see {@link RuntimeCache}
2476
- * @see {@link BunReleaseCacheLive}
2477
- * @see {@link DenoReleaseCacheLive}
2478
- * @see {@link NodeReleaseCacheLive}
2479
- * @public
2480
- */
2481
- declare const createRuntimeCache: <R extends RuntimeRelease>() => Effect.Effect<RuntimeCache<R>, never, VersionCache>;
2482
- //#endregion
2483
- //#region src/index.d.ts
2484
- /**
2485
- * Resolve Node.js versions matching the given options.
2486
- *
2487
- * Fetches release data from the Node.js GitHub repository and the official
2488
- * release schedule API, then filters and ranks versions according to
2489
- * `options`. Authentication is read from `GITHUB_PERSONAL_ACCESS_TOKEN` or
2490
- * `GITHUB_TOKEN` environment variables. Falls back to a build-time offline
2491
- * cache when the network is unavailable.
2492
- *
2493
- * @param options - Filtering and ranking options. See {@link NodeResolverOptions}.
2494
- * @returns A promise that resolves to a `ResolvedVersions` object
2495
- * containing the matched version list, the highest matching version as
2496
- * `latest`, and optional `lts` / `default` strings.
2497
- *
2498
- * @example
2499
- * ```ts
2500
- * import type { ResolvedVersions } from "runtime-resolver";
2501
- * import { resolveNode } from "runtime-resolver";
2502
- *
2503
- * const result: ResolvedVersions = await resolveNode({
2504
- * semverRange: ">=20.0.0",
2505
- * phases: ["active-lts"],
2506
- * });
2507
- * console.log(result.latest); // e.g. "22.11.0"
2508
- * console.log(result.versions); // all matching versions
2509
- * ```
2510
- *
2511
- * @see {@link NodeResolver} for the Effect-based API
2512
- * @see {@link NodeResolverOptions} for available options
2513
- *
2514
- * @public
2515
- */
2516
- declare const resolveNode: (options?: NodeResolverOptions) => Promise<ResolvedVersions>;
2517
- /**
2518
- * Resolve Bun versions matching the given options.
2519
- *
2520
- * Fetches release data from the Bun GitHub repository, then filters and ranks
2521
- * versions according to `options`. Authentication is read from
2522
- * `GITHUB_PERSONAL_ACCESS_TOKEN` or `GITHUB_TOKEN` environment variables.
2523
- * Falls back to a build-time offline cache when the network is unavailable.
2524
- *
2525
- * @param options - Filtering and ranking options. See {@link BunResolverOptions}.
2526
- * @returns A promise that resolves to a `ResolvedVersions` object
2527
- * containing the matched version list and the highest matching version as
2528
- * `latest`.
2529
- *
2530
- * @example
2531
- * ```ts
2532
- * import type { ResolvedVersions } from "runtime-resolver";
2533
- * import { resolveBun } from "runtime-resolver";
2534
- *
2535
- * const result: ResolvedVersions = await resolveBun({ semverRange: "^1.0.0" });
2536
- * console.log(result.latest);
2537
- * ```
2538
- *
2539
- * @see {@link BunResolver} for the Effect-based API
2540
- * @see {@link BunResolverOptions} for available options
2541
- *
2542
- * @public
2543
- */
2544
- declare const resolveBun: (options?: BunResolverOptions) => Promise<ResolvedVersions>;
2545
- /**
2546
- * Resolve Deno versions matching the given options.
2547
- *
2548
- * Fetches release data from the Deno GitHub repository, then filters and ranks
2549
- * versions according to `options`. Authentication is read from
2550
- * `GITHUB_PERSONAL_ACCESS_TOKEN` or `GITHUB_TOKEN` environment variables.
2551
- * Falls back to a build-time offline cache when the network is unavailable.
2552
- *
2553
- * @param options - Filtering and ranking options. See {@link DenoResolverOptions}.
2554
- * @returns A promise that resolves to a `ResolvedVersions` object
2555
- * containing the matched version list and the highest matching version as
2556
- * `latest`.
2557
- *
2558
- * @example
2559
- * ```ts
2560
- * import type { ResolvedVersions } from "runtime-resolver";
2561
- * import { resolveDeno } from "runtime-resolver";
2562
- *
2563
- * const result: ResolvedVersions = await resolveDeno({ semverRange: "^2.0.0" });
2564
- * console.log(result.latest);
2565
- * ```
2566
- *
2567
- * @see {@link DenoResolver} for the Effect-based API
2568
- * @see {@link DenoResolverOptions} for available options
2569
- *
2570
- * @public
2571
- */
2572
- declare const resolveDeno: (options?: DenoResolverOptions) => Promise<ResolvedVersions>;
2573
- //#endregion
2574
- export { AuthenticationError, AutoBunCacheLive, AutoDenoCacheLive, AutoNodeCacheLive, BunRelease, BunReleaseCache, BunReleaseCacheLive, BunResolver, type BunResolverError, BunResolverLive, type BunResolverOptions, BunVersionFetcher, BunVersionFetcherLive, CacheError, DenoRelease, DenoReleaseCache, DenoReleaseCacheLive, DenoResolver, type DenoResolverError, DenoResolverLive, type DenoResolverOptions, DenoVersionFetcher, DenoVersionFetcherLive, FreshBunCacheLive, FreshDenoCacheLive, FreshNodeCacheLive, FreshnessError, GitHubAppAuth, type GitHubAppAuthConfig, GitHubAutoAuth, GitHubClient, GitHubClientLive, type GitHubRelease, type GitHubTag, GitHubTokenAuth, GitHubTokenAuthFromToken, type Increments, InvalidInputError, type ListOptions, NetworkError, type NodePhase, NodeRelease, NodeReleaseCache, NodeReleaseCacheLive, type NodeReleaseInput, NodeResolver, type NodeResolverError, NodeResolverLive, type NodeResolverOptions, NodeSchedule, type NodeScheduleData, type NodeScheduleEntry, NodeScheduleFetcher, NodeScheduleFetcherLive, NodeVersionFetcher, NodeVersionFetcherLive, OctokitInstance, OfflineBunCacheLive, OfflineDenoCacheLive, OfflineNodeCacheLive, ParseError, RateLimitError, type ResolvedVersions, type Runtime, type RuntimeCache, type RuntimeRelease, type RuntimeReleaseInput, type Source, VersionNotFoundError, createRuntimeCache, resolveBun, resolveDeno, resolveNode };
2575
- //# sourceMappingURL=index.d.ts.map