effect-cf 0.47.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # effect-cf
2
2
 
3
+ ## 0.48.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#192](https://github.com/danieljvdm/effect-cf/pull/192) [`761c4f4`](https://github.com/danieljvdm/effect-cf/commit/761c4f411e11ae0491f61c6fe7c7697faf68e7f0) Thanks [@danieljvdm](https://github.com/danieljvdm)! - Report absent Artifacts commits as `ArtifactsOperationError` with `NOT_FOUND` instead of succeeding with `null`. Correct the raw `ArtifactsRepoBinding.readCommit` return type to include `null`; the Effect client continues to return a commit or a typed failure.
8
+
3
9
  ## 0.47.0
4
10
 
5
11
  ### Minor Changes
@@ -145,7 +145,7 @@ interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo> {
145
145
  readonly revokeToken: (tokenOrId: string) => Promise<boolean>;
146
146
  readonly fork: (name: RepoName, options?: ArtifactsForkOptions) => Promise<ArtifactsCreateRepoResult>;
147
147
  readonly log: (options?: ArtifactsLogOptions) => Promise<ArtifactsLogResult>;
148
- readonly readCommit: (hash: string) => Promise<ArtifactsCommit>;
148
+ readonly readCommit: (hash: string) => Promise<ArtifactsCommit | null>;
149
149
  readonly readTree: (hash: string) => Promise<ArtifactsTree>;
150
150
  }
151
151
  interface ArtifactsBinding {
@@ -105,7 +105,17 @@ const wrapRepo = (binding, repo, info) => ({
105
105
  revokeToken: Effect.fn("Artifacts.revokeToken", spanOptions(binding, "revokeToken"))((tokenOrId) => tryArtifactsPromise(binding, "revokeToken", () => repo.revokeToken(tokenOrId))),
106
106
  fork: Effect.fn("Artifacts.fork", spanOptions(binding, "fork"))((name, options) => tryArtifactsPromise(binding, "fork", () => repo.fork(name, options))),
107
107
  log: Effect.fn("Artifacts.log", spanOptions(binding, "log"))((options) => tryArtifactsPromise(binding, "log", () => repo.log(options))),
108
- readCommit: Effect.fn("Artifacts.readCommit", spanOptions(binding, "readCommit"))((hash) => tryArtifactsPromise(binding, "readCommit", () => repo.readCommit(hash))),
108
+ readCommit: Effect.fn("Artifacts.readCommit", spanOptions(binding, "readCommit"))(function* (hash) {
109
+ const commit = yield* tryArtifactsPromise(binding, "readCommit", () => repo.readCommit(hash));
110
+ if (commit === null) return yield* new ArtifactsOperationError({
111
+ binding,
112
+ operation: "readCommit",
113
+ code: "NOT_FOUND",
114
+ numericCode: artifactsErrorNumericCodes.NOT_FOUND,
115
+ cause: /* @__PURE__ */ new Error("Commit not found")
116
+ });
117
+ return commit;
118
+ }),
109
119
  readTree: Effect.fn("Artifacts.readTree", spanOptions(binding, "readTree"))((hash) => tryArtifactsPromise(binding, "readTree", () => repo.readTree(hash))),
110
120
  raw: repo
111
121
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect-cf",
3
- "version": "0.47.0",
3
+ "version": "0.48.0",
4
4
  "description": "Effect-native primitives for Cloudflare Workers and bindings.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/Artifacts.ts CHANGED
@@ -222,7 +222,7 @@ export interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo> {
222
222
  options?: ArtifactsForkOptions,
223
223
  ) => Promise<ArtifactsCreateRepoResult>;
224
224
  readonly log: (options?: ArtifactsLogOptions) => Promise<ArtifactsLogResult>;
225
- readonly readCommit: (hash: string) => Promise<ArtifactsCommit>;
225
+ readonly readCommit: (hash: string) => Promise<ArtifactsCommit | null>;
226
226
  readonly readTree: (hash: string) => Promise<ArtifactsTree>;
227
227
  }
228
228
 
@@ -451,7 +451,20 @@ const wrapRepo = (
451
451
  readCommit: Effect.fn(
452
452
  "Artifacts.readCommit",
453
453
  spanOptions(binding, "readCommit"),
454
- )((hash: string) => tryArtifactsPromise(binding, "readCommit", () => repo.readCommit(hash))),
454
+ )(function* (hash: string) {
455
+ const commit = yield* tryArtifactsPromise(binding, "readCommit", () => repo.readCommit(hash));
456
+
457
+ if (commit === null)
458
+ return yield* new ArtifactsOperationError({
459
+ binding,
460
+ operation: "readCommit",
461
+ code: "NOT_FOUND",
462
+ numericCode: artifactsErrorNumericCodes.NOT_FOUND,
463
+ cause: new Error("Commit not found"),
464
+ });
465
+
466
+ return commit;
467
+ }),
455
468
  readTree: Effect.fn(
456
469
  "Artifacts.readTree",
457
470
  spanOptions(binding, "readTree"),