@effected/github-actions 0.34.0 → 0.35.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/Action.js CHANGED
@@ -19,9 +19,9 @@ import { FetchHttpClient } from "effect/http";
19
19
  * a GitHub Action is a Node process on a GitHub-provided runner.
20
20
  *
21
21
  * **The cache, artifact and blob services are deliberately NOT in here.** They
22
- * are the only modules that import `@azure/storage-blob`, and folding them into
23
- * the default runtime would put a blob-storage client in the bundle of every
24
- * action that merely sets an output. Their requirements are all satisfied by
22
+ * carry the Twirp results protocols and the blob transport, and folding them
23
+ * into the default runtime would put both in the bundle of every action that
24
+ * merely sets an output. Their requirements are all satisfied by
25
25
  * this layer, so taking one costs a caller exactly one line:
26
26
  * `Action.run(program, { layer: ActionCache.layer })`.
27
27
  *
package/ActionCache.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
- import { BlobTransferError } from "./BlobTransfer.js";
3
2
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
4
- import { blobCause } from "./internal/blobCause.js";
3
+ import { httpFileTransfer } from "./internal/blobTransport.js";
5
4
  import { CACHE_SERVICE, finalizeUpload, lookupDownload, reserveUpload } from "./internal/cacheService.js";
6
5
  import { sha256Hex } from "./internal/digest.js";
7
6
  import { isWindowsRunner } from "./internal/runner.js";
@@ -10,7 +9,6 @@ import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
10
9
  import { unstubbed } from "./internal/unstubbed.js";
11
10
  import { Context, Effect, FileSystem, Layer, Option, Path, Schema } from "effect";
12
11
  import { HttpClient } from "effect/http";
13
- import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
14
12
  import { GlobPattern, GlobSet } from "@effected/glob";
15
13
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
16
14
 
@@ -82,36 +80,6 @@ const versionOf = (paths) => sha256Hex([
82
80
  "gzip",
83
81
  "1.0"
84
82
  ].join("|"));
85
- /**
86
- * The Azure half, duplicated on purpose.
87
- *
88
- * @remarks
89
- * `@azure/storage-blob` may be imported here, by `Artifact` and by
90
- * `BlobStore.githubCache`, and nowhere else — hoisting these two calls into a
91
- * shared `internal/` helper is exactly how a heavy import leaks into the graph
92
- * of a module that only sets an output. `__test__/reachability.test.ts`
93
- * measures that these are the only three.
94
- */
95
- const azure = {
96
- uploadFile: (url, file) => Effect.tryPromise({
97
- try: () => new BlockBlobClient(url).uploadFile(file, {
98
- blockSize: 67108864,
99
- concurrency: 8,
100
- maxSingleShotSize: 134217728
101
- }),
102
- catch: (cause) => new BlobTransferError({
103
- reason: "uploadFailed",
104
- cause: blobCause(cause)
105
- })
106
- }).pipe(Effect.asVoid),
107
- downloadToFile: (url, file) => Effect.tryPromise({
108
- try: () => new BlobClient(url).downloadToFile(file),
109
- catch: (cause) => new BlobTransferError({
110
- reason: "downloadFailed",
111
- cause: blobCause(cause)
112
- })
113
- }).pipe(Effect.asVoid)
114
- };
115
83
  /** The primary key and the ladder to fall back through. */
116
84
  const ladder = (key, restoreKeys) => typeof key === "string" ? {
117
85
  primary: key,
@@ -120,9 +88,10 @@ const ladder = (key, restoreKeys) => typeof key === "string" ? {
120
88
  primary: key.key,
121
89
  fallbacks: restoreKeys ?? key.restoreKeys
122
90
  };
123
- const make = (transfer) => Effect.gen(function* () {
91
+ const make = (custom) => Effect.gen(function* () {
124
92
  const http = yield* HttpClient.HttpClient;
125
93
  const fs = yield* FileSystem.FileSystem;
94
+ const transfer = custom ?? httpFileTransfer(http, fs);
126
95
  const path = yield* Path.Path;
127
96
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
128
97
  const env = yield* ActionEnvironment;
@@ -353,8 +322,16 @@ const dies = unstubbed("ActionCache.makeTest");
353
322
  * @public
354
323
  */
355
324
  var ActionCache = class ActionCache extends Context.Service()("@effected/github-actions/ActionCache") {
356
- /** The cache, over the real Azure client and the real `tar`. */
357
- static layer = Layer.effect(this, make(azure));
325
+ /**
326
+ * The cache, over the `HttpClient` blob transport and the real `tar`.
327
+ *
328
+ * @remarks
329
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
330
+ * the caller's client, not a bundled SDK or a platform client of this
331
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
332
+ * and `ActionEnvironment`.
333
+ */
334
+ static layer = Layer.effect(this, make());
358
335
  /**
359
336
  * The cache, over a supplied transport.
360
337
  *
package/Artifact.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
- import { BlobTransferError } from "./BlobTransfer.js";
3
2
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
4
3
  import { unzipCommand, zipCommand, zipManifest } from "./internal/archiveCommands.js";
5
- import { blobCause } from "./internal/blobCause.js";
4
+ import { httpFileTransfer } from "./internal/blobTransport.js";
6
5
  import { digestFileHex } from "./internal/digest.js";
7
6
  import { isWindowsRunner } from "./internal/runner.js";
8
7
  import { spawnOnce } from "./internal/spawn.js";
@@ -10,7 +9,6 @@ import { CONFLICT, field, isOk, stringField, twirpCall, twirpFailureFields } fro
10
9
  import { unstubbed } from "./internal/unstubbed.js";
11
10
  import { Context, DateTime, Duration, Effect, FileSystem, Layer, Option, Path, Result, Schema } from "effect";
12
11
  import { HttpClient } from "effect/http";
13
- import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
14
12
  import { ChildProcessSpawner } from "effect/process";
15
13
 
16
14
  // src/Artifact.ts
@@ -76,36 +74,6 @@ const SERVICE = "github.actions.results.api.v1.ArtifactService";
76
74
  * create the backend rejects.
77
75
  */
78
76
  const ARTIFACT_VERSION = 7;
79
- /**
80
- * The Azure half, duplicated on purpose.
81
- *
82
- * @remarks
83
- * `@azure/storage-blob` may be imported here, by `ActionCache` and by
84
- * `BlobStore.githubCache`, and nowhere else. Hoisting these two calls into a
85
- * shared `internal/` helper is exactly how a heavy import leaks into the graph
86
- * of a module that only sets an output; `__test__/reachability.test.ts`
87
- * measures that these are the only three.
88
- */
89
- const azure = {
90
- uploadFile: (url, file) => Effect.tryPromise({
91
- try: () => new BlockBlobClient(url).uploadFile(file, {
92
- blockSize: 67108864,
93
- concurrency: 8,
94
- maxSingleShotSize: 134217728
95
- }),
96
- catch: (cause) => new BlobTransferError({
97
- reason: "uploadFailed",
98
- cause: blobCause(cause)
99
- })
100
- }).pipe(Effect.asVoid),
101
- downloadToFile: (url, file) => Effect.tryPromise({
102
- try: () => new BlobClient(url).downloadToFile(file),
103
- catch: (cause) => new BlobTransferError({
104
- reason: "downloadFailed",
105
- cause: blobCause(cause)
106
- })
107
- }).pipe(Effect.asVoid)
108
- };
109
77
  /** One row of a `ListArtifacts` answer, read under either field spelling. */
110
78
  const toItem = (row) => {
111
79
  const createdAt = stringField(row, "createdAt");
@@ -116,9 +84,10 @@ const toItem = (row) => {
116
84
  ...createdAt === void 0 ? {} : { createdAt }
117
85
  };
118
86
  };
119
- const make = (transfer) => Effect.gen(function* () {
87
+ const make = (custom) => Effect.gen(function* () {
120
88
  const http = yield* HttpClient.HttpClient;
121
89
  const fs = yield* FileSystem.FileSystem;
90
+ const transfer = custom ?? httpFileTransfer(http, fs);
122
91
  const path = yield* Path.Path;
123
92
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
124
93
  const env = yield* ActionEnvironment;
@@ -373,8 +342,16 @@ const dies = unstubbed("Artifact.makeTest");
373
342
  * @public
374
343
  */
375
344
  var Artifact = class Artifact extends Context.Service()("@effected/github-actions/Artifact") {
376
- /** The service, over the real Azure client and the real `zip`. */
377
- static layer = Layer.effect(this, make(azure));
345
+ /**
346
+ * The service, over the `HttpClient` blob transport and the real `zip`.
347
+ *
348
+ * @remarks
349
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
350
+ * the caller's client, not a bundled SDK or a platform client of this
351
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
352
+ * and `ActionEnvironment`.
353
+ */
354
+ static layer = Layer.effect(this, make());
378
355
  /**
379
356
  * The service, over a supplied transport.
380
357
  *
@@ -1,15 +1,13 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
2
  import { BlobEnvelope } from "./BlobEnvelope.js";
3
3
  import { BlobStore, BlobStoreError } from "./BlobStore.js";
4
- import { BlobTransferError } from "./BlobTransfer.js";
5
4
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
6
- import { blobCause } from "./internal/blobCause.js";
5
+ import { httpDataTransfer } from "./internal/blobTransport.js";
7
6
  import { CACHE_SERVICE, finalizeUpload, lookupDownload, reserveUpload } from "./internal/cacheService.js";
8
7
  import { sha256Hex } from "./internal/digest.js";
9
8
  import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
10
9
  import { Effect, Layer, Option } from "effect";
11
10
  import { HttpClient } from "effect/http";
12
- import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
13
11
 
14
12
  // src/BlobStore.githubCache.ts
15
13
  /**
@@ -26,34 +24,9 @@ import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
26
24
  * that strands every existing entry.
27
25
  */
28
26
  const VERSION = sha256Hex("blobstore|1.0");
29
- /**
30
- * The Azure half, ~15 lines and duplicated on purpose.
31
- *
32
- * @remarks
33
- * `@azure/storage-blob` may be imported by this module, `ActionCache` and
34
- * `Artifact` and by nothing else. Hoisting these two calls into a shared
35
- * `internal/` helper is exactly how the import would leak into the graph of a
36
- * module that only sets an output — so the three modules each carry their own,
37
- * and `__test__/reachability.test.ts` measures that they are the only three.
38
- */
39
- const azure = {
40
- uploadData: (url, data) => Effect.tryPromise({
41
- try: () => new BlockBlobClient(url).uploadData(data),
42
- catch: (cause) => new BlobTransferError({
43
- reason: "uploadFailed",
44
- cause: blobCause(cause)
45
- })
46
- }).pipe(Effect.asVoid),
47
- downloadToBuffer: (url) => Effect.tryPromise({
48
- try: () => new BlobClient(url).downloadToBuffer(),
49
- catch: (cause) => new BlobTransferError({
50
- reason: "downloadFailed",
51
- cause: blobCause(cause)
52
- })
53
- }).pipe(Effect.map((buffer) => new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength)))
54
- };
55
- const make = (transfer) => Effect.gen(function* () {
27
+ const make = (custom) => Effect.gen(function* () {
56
28
  const http = yield* HttpClient.HttpClient;
29
+ const transfer = custom ?? httpDataTransfer(http);
57
30
  const env = yield* ActionEnvironment;
58
31
  const backend = resultsBackend(env).pipe(Effect.mapError((name) => new BlobStoreError({
59
32
  reason: "misconfigured",
@@ -114,9 +87,8 @@ const make = (transfer) => Effect.gen(function* () {
114
87
  * The Actions cache is reachable over a Twirp v2 protocol at
115
88
  * `ACTIONS_RESULTS_URL`, which answers a `CreateCacheEntry` /
116
89
  * `GetCacheEntryDownloadURL` RPC with a **pre-signed Azure blob url** — which is
117
- * why this backend lives in its own module rather than beside the S3 one: it,
118
- * `ActionCache` and `Artifact` are the only three modules that import the
119
- * Azure client.
90
+ * why this backend lives in its own module rather than beside the S3 one. The
91
+ * bytes move over the package's own `HttpClient` blob transport.
120
92
  *
121
93
  * **Only reachable from a `uses:` step.** The runner injects
122
94
  * `ACTIONS_RESULTS_URL` and `ACTIONS_RUNTIME_TOKEN` into action execution
@@ -126,9 +98,9 @@ const make = (transfer) => Effect.gen(function* () {
126
98
  * for exactly that reason.
127
99
  *
128
100
  * The layer statics live here rather than on {@link BlobStore} because a static
129
- * belongs to the module that owns the dependency it needs: putting
130
- * `BlobStore.layerGitHubCache` on the service class would make `@azure/storage-blob`
131
- * reachable from every module that reads a blob.
101
+ * belongs to the module that owns the protocol it needs: putting
102
+ * `BlobStore.layerGitHubCache` on the service class would make the Twirp cache
103
+ * protocol reachable from every module that reads a blob.
132
104
  *
133
105
  * @example
134
106
  * ```ts
@@ -142,21 +114,23 @@ const make = (transfer) => Effect.gen(function* () {
142
114
  var GitHubCacheBlobStore = class {
143
115
  constructor() {}
144
116
  /**
145
- * The backend, over the real Azure client.
117
+ * The backend, over the `HttpClient` blob transport.
146
118
  *
147
119
  * @remarks
148
- * Requires `ActionEnvironment` for `ACTIONS_RESULTS_URL` and
120
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
121
+ * the caller's client, not a bundled SDK or a platform client of this
122
+ * package's own. Requires `ActionEnvironment` for `ACTIONS_RESULTS_URL` and
149
123
  * `ACTIONS_RUNTIME_TOKEN`; fails with `BlobStoreError` (`misconfigured`) when
150
124
  * either is absent.
151
125
  */
152
- static layer = Layer.effect(BlobStore, make(azure));
126
+ static layer = Layer.effect(BlobStore, make());
153
127
  /**
154
128
  * The backend, over a supplied transport.
155
129
  *
156
130
  * @remarks
157
131
  * The Twirp protocol — the RPC sequence, the conflict handling, the retry
158
132
  * policy, the framing — is what this package owns and what a test needs to
159
- * exercise; the Azure client is a pre-signed `PUT` that owns none of it. This
133
+ * exercise; the blob transfer is a pre-signed `PUT` that owns none of it. This
160
134
  * is also the seam an integration test uses to point the same protocol at a
161
135
  * local blob endpoint.
162
136
  *
package/README.md CHANGED
@@ -123,7 +123,7 @@ const program = Effect.gen(function* () {
123
123
 
124
124
  ## The runner's cache, artifacts and OIDC
125
125
 
126
- `ActionCache` and `Artifact` speak the Actions Twirp v2 protocol directly — no `@actions/cache` or `@actions/artifact` dependency, and both are excluded from `ActionRuntime.layer` on purpose, so a consumer that only sets an output never links `@azure/storage-blob`:
126
+ `ActionCache` and `Artifact` speak the Actions Twirp v2 protocol directly — no `@actions/cache` or `@actions/artifact` dependency, and both are excluded from `ActionRuntime.layer` on purpose, so a consumer that only sets an output never links the blob transport:
127
127
 
128
128
  ```ts
129
129
  import { ActionCache, CacheKey } from "@effected/github-actions";
@@ -301,7 +301,7 @@ const TestOutputs = ActionOutputs.layerTest({
301
301
  - `DryRun` — the rehearsal guard every mutation goes through, driven by the `dry-run` input by default.
302
302
  - `Secret` — the one declassification seam between a `Redacted` value and a plain string, masking before it returns plaintext.
303
303
  - `GitHubToken` — the App-token lifecycle shaped like the `pre`/`main`/`post` workflow: mint, verify scopes, persist, read, revoke.
304
- - `ActionCache` / `Artifact` — the runner's cache and artifact protocols over Twirp v2, excluded from the default runtime so a consumer that skips them never links Azure.
304
+ - `ActionCache` / `Artifact` — the runner's cache and artifact protocols over Twirp v2, excluded from the default runtime so a consumer that skips them never links the blob transport.
305
305
  - `CacheKey` — cache keys and their restore-key ladder, `withNamespace(segment)` for a bust token or a shared-runner prefix, plus `hashFiles`/`matchingFiles`/`hashMatching` byte-compatible with `@actions/glob`.
306
306
  - `OidcTokenIssuer` — the runner's OIDC token service, with unverified claim decoding for provenance predicates, and a `recording(claims)` double that journals the audiences asked for.
307
307
  - `ActionsRegistryCredential` — `workload({ audience, prefix })` mints an identity token for a registry, masks the bare and the prefixed value, and returns `@effected/npm`'s publish-only `WorkloadCredential` for `PackagePublish.setupAuth`.
package/index.d.ts CHANGED
@@ -943,9 +943,9 @@ type ActionServices = ActionEnvironment | ActionLogger | ActionOutputs | ActionS
943
943
  * a GitHub Action is a Node process on a GitHub-provided runner.
944
944
  *
945
945
  * **The cache, artifact and blob services are deliberately NOT in here.** They
946
- * are the only modules that import `@azure/storage-blob`, and folding them into
947
- * the default runtime would put a blob-storage client in the bundle of every
948
- * action that merely sets an output. Their requirements are all satisfied by
946
+ * carry the Twirp results protocols and the blob transport, and folding them
947
+ * into the default runtime would put both in the bundle of every action that
948
+ * merely sets an output. Their requirements are all satisfied by
949
949
  * this layer, so taking one costs a caller exactly one line:
950
950
  * `Action.run(program, { layer: ActionCache.layer })`.
951
951
  *
@@ -1103,8 +1103,8 @@ export declare class BlobTransferError extends BlobTransferError_base {
1103
1103
  * pre-signed Azure url, and everything interesting — the RPC sequence, the
1104
1104
  * conflict handling, the retry policy, the version hash — happens on this side
1105
1105
  * of it. Taking the transport as an argument means all of that is exercised by
1106
- * a test rather than described by one, and the Azure client stays confined to
1107
- * the three modules permitted to import it.
1106
+ * a test rather than described by one. The default transport is the package's
1107
+ * own `HttpClient` implementation of the Azure Blob REST calls.
1108
1108
  *
1109
1109
  * A url is a plain string on purpose: it is a **credential** (the signature is
1110
1110
  * in the query), and it is never logged, annotated on a span, or carried on an
@@ -1607,7 +1607,15 @@ declare const ActionCache_base: Context.ServiceClass<ActionCache, "@effected/git
1607
1607
  * @public
1608
1608
  */
1609
1609
  export declare class ActionCache extends ActionCache_base {
1610
- /** The cache, over the real Azure client and the real `tar`. */
1610
+ /**
1611
+ * The cache, over the `HttpClient` blob transport and the real `tar`.
1612
+ *
1613
+ * @remarks
1614
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
1615
+ * the caller's client, not a bundled SDK or a platform client of this
1616
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
1617
+ * and `ActionEnvironment`.
1618
+ */
1611
1619
  static readonly layer: Layer.Layer<ActionCache, never, ActionEnvironment | HttpClient.HttpClient | FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
1612
1620
  /**
1613
1621
  * The cache, over a supplied transport.
@@ -3021,7 +3029,15 @@ declare const Artifact_base: Context.ServiceClass<Artifact, "@effected/github-ac
3021
3029
  * @public
3022
3030
  */
3023
3031
  export declare class Artifact extends Artifact_base {
3024
- /** The service, over the real Azure client and the real `zip`. */
3032
+ /**
3033
+ * The service, over the `HttpClient` blob transport and the real `zip`.
3034
+ *
3035
+ * @remarks
3036
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
3037
+ * the caller's client, not a bundled SDK or a platform client of this
3038
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
3039
+ * and `ActionEnvironment`.
3040
+ */
3025
3041
  static readonly layer: Layer.Layer<Artifact, never, ActionEnvironment | HttpClient.HttpClient | FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
3026
3042
  /**
3027
3043
  * The service, over a supplied transport.
@@ -3353,9 +3369,8 @@ export declare class BlobStore extends BlobStore_base {
3353
3369
  * The Actions cache is reachable over a Twirp v2 protocol at
3354
3370
  * `ACTIONS_RESULTS_URL`, which answers a `CreateCacheEntry` /
3355
3371
  * `GetCacheEntryDownloadURL` RPC with a **pre-signed Azure blob url** — which is
3356
- * why this backend lives in its own module rather than beside the S3 one: it,
3357
- * `ActionCache` and `Artifact` are the only three modules that import the
3358
- * Azure client.
3372
+ * why this backend lives in its own module rather than beside the S3 one. The
3373
+ * bytes move over the package's own `HttpClient` blob transport.
3359
3374
  *
3360
3375
  * **Only reachable from a `uses:` step.** The runner injects
3361
3376
  * `ACTIONS_RESULTS_URL` and `ACTIONS_RUNTIME_TOKEN` into action execution
@@ -3365,9 +3380,9 @@ export declare class BlobStore extends BlobStore_base {
3365
3380
  * for exactly that reason.
3366
3381
  *
3367
3382
  * The layer statics live here rather than on {@link BlobStore} because a static
3368
- * belongs to the module that owns the dependency it needs: putting
3369
- * `BlobStore.layerGitHubCache` on the service class would make `@azure/storage-blob`
3370
- * reachable from every module that reads a blob.
3383
+ * belongs to the module that owns the protocol it needs: putting
3384
+ * `BlobStore.layerGitHubCache` on the service class would make the Twirp cache
3385
+ * protocol reachable from every module that reads a blob.
3371
3386
  *
3372
3387
  * @example
3373
3388
  * ```ts
@@ -3381,10 +3396,12 @@ export declare class BlobStore extends BlobStore_base {
3381
3396
  export declare class GitHubCacheBlobStore {
3382
3397
  private constructor();
3383
3398
  /**
3384
- * The backend, over the real Azure client.
3399
+ * The backend, over the `HttpClient` blob transport.
3385
3400
  *
3386
3401
  * @remarks
3387
- * Requires `ActionEnvironment` for `ACTIONS_RESULTS_URL` and
3402
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
3403
+ * the caller's client, not a bundled SDK or a platform client of this
3404
+ * package's own. Requires `ActionEnvironment` for `ACTIONS_RESULTS_URL` and
3388
3405
  * `ACTIONS_RUNTIME_TOKEN`; fails with `BlobStoreError` (`misconfigured`) when
3389
3406
  * either is absent.
3390
3407
  */
@@ -3395,7 +3412,7 @@ export declare class GitHubCacheBlobStore {
3395
3412
  * @remarks
3396
3413
  * The Twirp protocol — the RPC sequence, the conflict handling, the retry
3397
3414
  * policy, the framing — is what this package owns and what a test needs to
3398
- * exercise; the Azure client is a pre-signed `PUT` that owns none of it. This
3415
+ * exercise; the blob transfer is a pre-signed `PUT` that owns none of it. This
3399
3416
  * is also the seam an integration test uses to point the same protocol at a
3400
3417
  * local blob endpoint.
3401
3418
  *
@@ -1,9 +1,7 @@
1
- import { Predicate } from "effect";
2
1
  import { UrlParams } from "effect/http";
3
2
  import { HttpRedaction } from "@effected/crypto";
4
3
 
5
4
  // src/internal/blobCause.ts
6
- const REDACTED = "REDACTED";
7
5
  const SAS_NAMES = [
8
6
  "sig",
9
7
  "se",
@@ -20,81 +18,5 @@ const SAS_NAMES = [
20
18
  ];
21
19
  /** A signed blob url with its SAS credential fields and userinfo redacted. */
22
20
  const blobUrl = (raw) => UrlParams.redactUrl(HttpRedaction.url(raw), SAS_NAMES);
23
- const text = (raw) => HttpRedaction.text(raw).replace(/https?:\/\/[^\s"'<>`]+/gi, (match) => UrlParams.redactUrl(match, SAS_NAMES));
24
- /** A header record (`details`, or a response's headers) minus cookies, sensitive values redacted. */
25
- const headerRecord = (input) => {
26
- const entries = headerEntries(input);
27
- if (entries === void 0) return void 0;
28
- const out = {};
29
- for (const [name, value] of entries) {
30
- const lower = name.toLowerCase();
31
- if (lower === "set-cookie" || lower === "cookie") continue;
32
- if (typeof value === "string") out[name] = HttpRedaction.isSensitiveHeader(lower) ? REDACTED : text(value);
33
- else if (Predicate.isNumber(value) || Predicate.isBoolean(value)) out[name] = value;
34
- }
35
- return out;
36
- };
37
- const headerEntries = (input) => {
38
- if (input === null || typeof input !== "object") return void 0;
39
- if (Predicate.hasProperty(input, "toJSON") && typeof input.toJSON === "function") {
40
- const json = input.toJSON();
41
- return json !== null && typeof json === "object" ? Object.entries(json) : void 0;
42
- }
43
- return Object.entries(input);
44
- };
45
- const isRestShaped = (value) => Predicate.hasProperty(value, "request") || Predicate.hasProperty(value, "response");
46
- const MAX_DEPTH = 8;
47
- const define = (target, key, value, enumerable) => {
48
- Object.defineProperty(target, key, {
49
- value,
50
- enumerable,
51
- writable: true,
52
- configurable: true
53
- });
54
- };
55
- const copy = (value, depth) => {
56
- if (typeof value === "string") return text(value);
57
- if (value === null || typeof value !== "object") return value;
58
- if (depth >= MAX_DEPTH) return void 0;
59
- const source = value;
60
- const out = value instanceof Error ? Object.create(Object.getPrototypeOf(value)) : new Error(text(typeof source.message === "string" ? source.message : Object.prototype.toString.call(value)));
61
- if (value instanceof Error) {
62
- define(out, "message", text(value.message), false);
63
- if (value.stack !== void 0) define(out, "stack", text(value.stack), false);
64
- }
65
- for (const [key, field] of Object.entries(source)) if (key === "details") {
66
- const details = headerRecord(field);
67
- if (details !== void 0) define(out, key, details, true);
68
- } else if (typeof field === "string") define(out, key, text(field), true);
69
- else if (Predicate.isNumber(field) || Predicate.isBoolean(field)) define(out, key, field, true);
70
- const request = Predicate.hasProperty(value, "request") ? asRecord(value.request) : void 0;
71
- if (request !== void 0) define(out, "request", {
72
- ...typeof request.method === "string" ? { method: request.method } : {},
73
- ...typeof request.url === "string" ? { url: blobUrl(request.url) } : {},
74
- ...headerRecord(request.headers) !== void 0 ? { headers: headerRecord(request.headers) } : {}
75
- }, false);
76
- const response = Predicate.hasProperty(value, "response") ? asRecord(value.response) : void 0;
77
- if (response !== void 0) define(out, "response", {
78
- ...Predicate.isNumber(response.status) ? { status: response.status } : {},
79
- ...headerRecord(response.headers) !== void 0 ? { headers: headerRecord(response.headers) } : {}
80
- }, false);
81
- if (Predicate.hasProperty(value, "cause") && value.cause !== void 0) {
82
- const nested = copy(value.cause, depth + 1);
83
- if (nested !== void 0) define(out, "cause", nested, true);
84
- }
85
- return out;
86
- };
87
- const asRecord = (value) => value !== null && typeof value === "object" ? value : void 0;
88
- /**
89
- * Sanitize what a blob transfer threw before keeping it as a cause: a
90
- * `RestError`-shaped value (one carrying a `request` or `response`) becomes a
91
- * copy on the same prototype that keeps `name`, `message`, `code`,
92
- * `statusCode`, the method, the url with its SAS credential fields redacted,
93
- * and the headers minus `set-cookie`, with sensitive values redacted; the
94
- * request and response bodies, the pipeline options and the raw url are gone.
95
- * Anything else — a filesystem error writing the download, a kit error — is
96
- * returned unchanged, by identity.
97
- */
98
- const blobCause = (cause) => cause !== null && typeof cause === "object" && isRestShaped(cause) ? copy(cause, 0) : cause;
99
21
 
100
- export { blobCause, blobUrl };
22
+ export { blobUrl };
@@ -0,0 +1,172 @@
1
+ import { BlobTransferError } from "../BlobTransfer.js";
2
+ import { blobUrl } from "./blobCause.js";
3
+ import { Effect, PlatformError, Schedule, Stream } from "effect";
4
+ import { HttpBody, HttpClientRequest } from "effect/http";
5
+
6
+ // src/internal/blobTransport.ts
7
+ /**
8
+ * The storage service version sent as `x-ms-version`.
9
+ *
10
+ * @remarks
11
+ * The version `@azure/storage-blob` 12.34 sent, which is the one the transport
12
+ * replaced. A SAS url's own `sv` governs what the signature authorizes; this
13
+ * header selects the REST behaviour of the call.
14
+ *
15
+ * @internal
16
+ */
17
+ const SERVICE_VERSION = "2026-10-06";
18
+ const MIB = 1048576;
19
+ /** The sizing `ActionCache` and `Artifact` upload files with. @internal */
20
+ const FILE_OPTIONS = {
21
+ maxSingleShotSize: 128 * MIB,
22
+ blockSize: 64 * MIB,
23
+ concurrency: 8,
24
+ retrySchedule: Schedule.exponential("1 second", 2),
25
+ retries: 4
26
+ };
27
+ /** The sizing `BlobStore.githubCache` uploads buffers with. @internal */
28
+ const DATA_OPTIONS = {
29
+ ...FILE_OPTIONS,
30
+ maxSingleShotSize: 256 * MIB
31
+ };
32
+ /**
33
+ * Why a blob request did not succeed.
34
+ *
35
+ * @remarks
36
+ * A plain `Error` subclass rather than a Schema class: it is only ever kept as
37
+ * `BlobTransferError.cause`, and it holds nothing that was not redacted on the
38
+ * way in.
39
+ *
40
+ * @internal
41
+ */
42
+ var BlobRequestError = class extends Error {
43
+ name = "BlobRequestError";
44
+ method;
45
+ /** The request url with its SAS credential fields redacted. */
46
+ url;
47
+ /** The HTTP status, absent for a transport fault. */
48
+ statusCode;
49
+ /** The storage service's `<Code>`, read from an XML error body. */
50
+ code;
51
+ /** The `x-ms-request-id` the service answered with. */
52
+ requestId;
53
+ constructor(fields) {
54
+ super(fields.message);
55
+ this.method = fields.method;
56
+ this.url = blobUrl(fields.url);
57
+ if (fields.statusCode !== void 0) this.statusCode = fields.statusCode;
58
+ if (fields.code !== void 0) this.code = fields.code;
59
+ if (fields.requestId !== void 0) this.requestId = fields.requestId;
60
+ }
61
+ };
62
+ const isTransient = (error) => error.statusCode === void 0 || error.statusCode >= 500 || error.statusCode === 408 || error.statusCode === 429;
63
+ /** The service's `<Code>` out of an XML error body. */
64
+ const errorCode = (body) => /<Code>([^<]+)<\/Code>/.exec(body)?.[1];
65
+ const base = (method, url) => (method === "PUT" ? HttpClientRequest.put(url) : HttpClientRequest.get(url)).pipe(HttpClientRequest.setHeader("x-ms-version", SERVICE_VERSION));
66
+ /** Send one request; a non-2xx answer or a transport fault is a {@link BlobRequestError}. */
67
+ const send = (http, method, url, request) => http.execute(request).pipe(Effect.mapError((cause) => new BlobRequestError({
68
+ method,
69
+ url,
70
+ message: `${method} did not complete (${cause.reason._tag})`
71
+ })), Effect.flatMap((response) => {
72
+ if (response.status >= 200 && response.status < 300) return Effect.succeed(response);
73
+ return response.text.pipe(Effect.orElseSucceed(() => ""), Effect.flatMap((body) => Effect.fail(new BlobRequestError({
74
+ method,
75
+ url,
76
+ message: `${method} answered ${response.status}`,
77
+ statusCode: response.status,
78
+ code: errorCode(body),
79
+ requestId: response.headers["x-ms-request-id"]
80
+ }))));
81
+ }));
82
+ const withRetry = (options, attempt) => Effect.retry(attempt, {
83
+ schedule: options.retrySchedule,
84
+ times: options.retries,
85
+ while: (error) => error instanceof BlobRequestError && isTransient(error)
86
+ });
87
+ const putBody = (http, options, url, params, body, blobType) => {
88
+ const request = Object.entries(params).reduce((req, [name, value]) => HttpClientRequest.setUrlParam(req, name, value), base("PUT", url).pipe(HttpClientRequest.setBody(body)));
89
+ const typed = blobType ? HttpClientRequest.setHeader(request, "x-ms-blob-type", "BlockBlob") : request;
90
+ return withRetry(options, Effect.asVoid(Effect.scoped(send(http, "PUT", url, typed))));
91
+ };
92
+ /** The fixed-width base64 id of block `index`; every id in a blob must be one length. */
93
+ const blockId = (index) => btoa(String(index).padStart(8, "0"));
94
+ const blocklistXml = (count) => `<?xml version="1.0" encoding="utf-8"?><BlockList>${Array.from({ length: count }, (_, index) => `<Latest>${blockId(index)}</Latest>`).join("")}</BlockList>`;
95
+ /**
96
+ * Upload `size` bytes, whole or as blocks, reading each span with `read`.
97
+ *
98
+ * @remarks
99
+ * `read` runs once per block, outside the retry: a retried `PUT` sends the
100
+ * same bytes again, which a `Uint8Array` body can do and a consumed stream
101
+ * could not.
102
+ */
103
+ const upload = (http, options, url, size, read) => {
104
+ if (size <= options.maxSingleShotSize) return Effect.flatMap(read(0, size), (bytes) => putBody(http, options, url, {}, HttpBody.uint8Array(bytes, "application/octet-stream"), true));
105
+ const count = Math.ceil(size / options.blockSize);
106
+ return Effect.forEach(Array.from({ length: count }, (_, index) => index), (index) => Effect.flatMap(read(index * options.blockSize, Math.min(options.blockSize, size - index * options.blockSize)), (bytes) => putBody(http, options, url, {
107
+ comp: "block",
108
+ blockid: blockId(index)
109
+ }, HttpBody.uint8Array(bytes, "application/octet-stream"), false)), {
110
+ concurrency: options.concurrency,
111
+ discard: true
112
+ }).pipe(Effect.andThen(putBody(http, options, url, { comp: "blocklist" }, HttpBody.text(blocklistXml(count), "application/xml"), false)));
113
+ };
114
+ /**
115
+ * Read `length` bytes of `file` from `offset` into one buffer, written as each chunk arrives: the chunks are never
116
+ * held beside the joined copy, so a block costs its own size once. A file that ends early fails, rather than send
117
+ * zero bytes the signature would accept.
118
+ */
119
+ const readSpan = (fs, file, offset, length) => Effect.suspend(() => {
120
+ const out = new Uint8Array(length);
121
+ let at = 0;
122
+ return fs.stream(file, {
123
+ offset,
124
+ bytesToRead: length
125
+ }).pipe(Stream.runForEach((chunk) => Effect.sync(() => {
126
+ const take = Math.min(chunk.byteLength, length - at);
127
+ out.set(take === chunk.byteLength ? chunk : chunk.subarray(0, take), at);
128
+ at += take;
129
+ })), Effect.flatMap(() => at === length ? Effect.succeed(out) : Effect.fail(PlatformError.systemError({
130
+ _tag: "UnexpectedEof",
131
+ module: "FileSystem",
132
+ method: "stream",
133
+ description: `expected ${length} bytes at offset ${offset}, read ${at}`,
134
+ pathOrDescriptor: file
135
+ }))));
136
+ });
137
+ const uploadFailed = (cause) => new BlobTransferError({
138
+ reason: "uploadFailed",
139
+ cause
140
+ });
141
+ const downloadFailed = (cause) => new BlobTransferError({
142
+ reason: "downloadFailed",
143
+ cause
144
+ });
145
+ /**
146
+ * The {@link DataBlobTransfer} over `HttpClient`.
147
+ *
148
+ * @internal
149
+ */
150
+ const httpDataTransfer = (http, options = DATA_OPTIONS) => ({
151
+ uploadData: (url, data) => upload(http, options, url, data.byteLength, (offset, length) => Effect.succeed(data.subarray(offset, offset + length))).pipe(Effect.mapError(uploadFailed)),
152
+ downloadToBuffer: (url) => withRetry(options, Effect.scoped(Effect.flatMap(send(http, "GET", url, base("GET", url)), (response) => response.arrayBuffer.pipe(Effect.map((buffer) => new Uint8Array(buffer)), Effect.mapError((cause) => new BlobRequestError({
153
+ method: "GET",
154
+ url,
155
+ message: `GET body did not complete (${cause.reason._tag})`
156
+ })))))).pipe(Effect.mapError(downloadFailed))
157
+ });
158
+ /**
159
+ * The {@link FileBlobTransfer} over `HttpClient` and `FileSystem`.
160
+ *
161
+ * @internal
162
+ */
163
+ const httpFileTransfer = (http, fs, options = FILE_OPTIONS) => ({
164
+ uploadFile: (url, file) => Effect.flatMap(fs.stat(file), (info) => upload(http, options, url, Number(info.size), (offset, length) => readSpan(fs, file, offset, length))).pipe(Effect.mapError(uploadFailed)),
165
+ downloadToFile: (url, file) => withRetry(options, Effect.scoped(Effect.flatMap(send(http, "GET", url, base("GET", url)), (response) => response.stream.pipe(Stream.mapError((cause) => new BlobRequestError({
166
+ method: "GET",
167
+ url,
168
+ message: `GET body did not complete (${cause.reason._tag})`
169
+ })), Stream.run(fs.sink(file)))))).pipe(Effect.mapError(downloadFailed))
170
+ });
171
+
172
+ export { BlobRequestError, DATA_OPTIONS, FILE_OPTIONS, SERVICE_VERSION, httpDataTransfer, httpFileTransfer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/github-actions",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "private": false,
5
5
  "description": "The GitHub Actions runtime: env, inputs, outputs, state, logging, cache, artifacts, blob storage, OIDC and the token bridge.",
6
6
  "keywords": [
@@ -38,19 +38,18 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "dependencies": {
41
- "@azure/storage-blob": "^12.33.0",
42
41
  "@effected/crypto": "^0.7.0",
43
- "@effected/github": "^0.32.1",
42
+ "@effected/github": "^0.33.0",
44
43
  "@effected/github-commands": "^0.10.0",
45
- "@effected/glob": "^0.22.0",
44
+ "@effected/glob": "^0.23.0",
46
45
  "@effected/jwt": "^0.10.0",
47
46
  "@effected/markdown": "^0.29.0",
48
- "@effected/npm": "^0.35.0",
47
+ "@effected/npm": "^0.35.1",
49
48
  "@effected/oidc": "^0.5.0",
50
49
  "@effected/sbom": "^0.21.0",
51
50
  "@effected/semver": "^0.24.0",
52
51
  "@effected/templates": "^0.20.0",
53
- "@effected/walker": "^0.29.0",
52
+ "@effected/walker": "^0.30.0",
54
53
  "@effected/yaml": "^0.30.0"
55
54
  },
56
55
  "peerDependencies": {