diff --git a/src/adapters/http/fileserver-upload.ts b/src/adapters/http/fileserver-upload.ts index 47646e07..f3832d7e 100644 --- a/src/adapters/http/fileserver-upload.ts +++ b/src/adapters/http/fileserver-upload.ts @@ -1,4 +1,3 @@ -import type { FileByteSource } from "../../application/ports/browser-file-storage/file.ts"; import { createFailure, type AppFailure, @@ -46,7 +45,8 @@ import type { AuthOperationContext } from "./http-execution-v3.ts"; * public descriptor. * * The file arrives as the `FileByteSource` that `FileContentPort.openSource` - * gives, so no `File` or `Blob` crosses into this adapter. Its bytes are read + * gives (`FileserverByteSource` is its shape), so no `File` or `Blob` crosses + * into this adapter. Its bytes are read * once into the multipart body, at most `maxFileBytes` of them; a file that * declares a larger size is refused before reading. * @@ -59,6 +59,19 @@ import type { AuthOperationContext } from "./http-execution-v3.ts"; export type FileserverFileState = "READY" | "UPLOADED" | "VERIFYING" | "QUARANTINED"; +/** + * The bytes to send: structurally the browser-file-storage port's + * `FileByteSource`, which a product passes as it is. Written here instead of + * imported so this adapter does not depend on that optional runtime's port; + * test:browser-file-storage-removal deletes the port and this client stays. + */ +export type FileserverByteSource = Readonly<{ + byteLength: number | null; + stream( + signal: AbortSignal, + ): AsyncIterable>>; +}>; + /** The stored file, as the backend's `UploadedFileResponse` describes it. */ export type FileserverUploadedFile = Readonly<{ fileId: string; @@ -72,7 +85,7 @@ export type FileserverUploadedFile = Readonly<{ }>; export type FileserverUploadRequest = Readonly<{ - source: FileByteSource; + source: FileserverByteSource; /** The multipart filename, untrusted on the server. Defaults to `upload.bin`. */ filename?: string; /** The part's Content-Type, a claim the server verifies. */ @@ -345,7 +358,7 @@ function snapshotDependencies( } type AdmittedRequest = Readonly<{ - source: FileByteSource; + source: FileserverByteSource; filename: string; mediaType: string; idempotencyKey?: string; diff --git a/src/adapters/http/index.ts b/src/adapters/http/index.ts index 44291460..0e8e1b7e 100644 --- a/src/adapters/http/index.ts +++ b/src/adapters/http/index.ts @@ -47,6 +47,7 @@ export type { CredentialPatchOutcome } from "./http-contract-bridge.ts"; export { createFileserverUploadClient, FILESERVER_UPLOAD_OPERATION_ID, + type FileserverByteSource, type FileserverFileState, type FileserverUploadClient, type FileserverUploadClientDependencies,