feat: add the TechLog asset multipart upload transport

Wires the whole Asset capability into the running application: the
multipart upload transport (the contract runtime can only express JSON
bodies), a single composition-root-owned CSRF provider shared between
the platform's credential collaborator (18 JSON operations) and the
upload transport (1 multipart operation), and Studio/StudioShell
exposure of the Asset gateway alongside the existing document gateway.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-08-18 02:39:51 +09:00
co-authored by Claude Opus 5
parent d9c2d8bc5e
commit c9c832c365
15 changed files with 473 additions and 3 deletions
@@ -2,10 +2,13 @@ import {
TECH_LOG_FEATURE_ID,
type TechLogFeatureInput,
} from "../application/tech-log-feature-input.ts";
import { createAssetUploadTransport } from "./http/asset-upload-transport.ts";
import { createHttpStudioAssetGateway } from "./http/http-studio-asset-gateway.ts";
import {
createHttpStudioGateway,
type StudioOperationExecutor,
} from "./http/http-studio-gateway.ts";
import type { CsrfTokenProvider } from "./http/studio-session-csrf.ts";
import { createMockStudioGateway } from "./mock/mock-studio-gateway.ts";
import { publicContentQueries } from "./static/public-query.ts";
@@ -15,15 +18,35 @@ import { publicContentQueries } from "./static/public-query.ts";
* platform's `attachCredentials` collaborator at the composition root. This
* context only has to say which adapter to construct and hand it the
* composed contract executor.
*
* CSRF has exactly one provider per Studio session, owned by the composition
* root — it is shared with the platform's credential collaborator, so it is
* threaded in here rather than constructed locally.
*/
export type TechLogInstallContext = Readonly<{
studioSource: "MOCK" | "HTTP";
contractOperations: StudioOperationExecutor;
apiBaseUrl: string;
requestTimeoutMs: number;
csrf: CsrfTokenProvider;
}>;
export function createTechLogFeatureInstalledInput(
context: TechLogInstallContext,
) {
// The Asset gateway is needed even on MOCK: with no backend behind it, the
// list comes back empty and uploads fail with a transport error — the UI
// surfacing that state is the correct behavior, not a bug to route around.
const createStudioAssetGateway = () =>
createHttpStudioAssetGateway({
operations: context.contractOperations,
csrf: context.csrf,
upload: createAssetUploadTransport({
baseUrl: context.apiBaseUrl,
timeoutMs: context.requestTimeoutMs,
}),
});
const createStudioGateway = () =>
context.studioSource === "MOCK"
? createMockStudioGateway()
@@ -32,6 +55,7 @@ export function createTechLogFeatureInstalledInput(
const input: TechLogFeatureInput = Object.freeze({
publicContent: publicContentQueries,
createStudioGateway,
createStudioAssetGateway,
});
return Object.freeze({