Carries 21 template commits: the shared IndexedDB connection/transaction
kernel and the four runtimes moved onto it, the adapter barrel boundary and
the architecture rule that enforces it, the feature adapter contribution
model, `feature-http-binding`, the split of several oversized test files,
and the release identity now derived from the package name.
Product identity is unchanged. The three hard-coded `tech-log-frontend/…`
verifier ids are gone because the template derives them from the package
name and this package is `tech-log-frontend`.
Two decisions worth naming. The platform HTTP executor is the template's
verbatim — it now takes the installed contract so a feature's types flow
through the binding — and TechLog's four gateways, which address operations
by id, reach it through one adapter at the composition root instead of being
rewritten here. And the three derived CI baselines were recomputed from the
merged `config/ci/gates.json` rather than taken from either side: 94 command
definitions, 106 references, 141 artifacts, gate shape `629e5898…`. The
method was checked by first reproducing the pre-merge values from the
pre-merge file.
Verified here: types, lint, architecture, adapter inventory, CI contract,
design system, diagnostics, remediation ledger, browser security and build
all pass; 1789 unit, 152 component, 415 TechLog, 102 integration, 19
reference-feature, 17 recipe and 7 contract tests pass. Five gates stay
red and every one was reproduced at b297d65 first: `check:i18n`,
`check:registries`, `test:runtime-schema`, `verify:documentation` and
`test:sample-removal`.
Full decision record, including what was deliberately not carried and the
five open follow-ups, in `docs/operations/template-sync-2026-09-21.md`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
123 lines
3.7 KiB
TypeScript
123 lines
3.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import type {
|
|
IndexedDbRepositoryPort,
|
|
} from "../../../src/application/ports/browser-file-storage/index.ts";
|
|
import type {
|
|
InstalledHttpOperationExecutor,
|
|
} from "../../../src/adapters/http/index.ts";
|
|
import {
|
|
composeFeatureAdapterInputs,
|
|
defineFeatureAdapterContribution,
|
|
type IndexedDbRepositoryProvider,
|
|
} from "../../../src/features/feature-adapter-contribution.ts";
|
|
import {
|
|
LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION,
|
|
} from "../../../src/features/local-draft-feature/adapters/create-local-draft-feature-input.ts";
|
|
import type { LocalDraft } from "../../../src/features/local-draft-feature/domain/local-draft.ts";
|
|
|
|
type TestHttpFeatureInput = Readonly<{
|
|
ping(): Promise<"pong">;
|
|
}>;
|
|
|
|
declare module "../../../src/application/ports/in/application-api.ts" {
|
|
interface ApplicationFeatureInputs {
|
|
"test-http-feature": TestHttpFeatureInput;
|
|
}
|
|
}
|
|
|
|
const TEST_HTTP_FEATURE_ADAPTER_CONTRIBUTION =
|
|
defineFeatureAdapterContribution({
|
|
featureId: "test-http-feature",
|
|
needs: ["http"] as const,
|
|
createInput() {
|
|
return Object.freeze({
|
|
featureId: "test-http-feature" as const,
|
|
input: Object.freeze({
|
|
async ping() {
|
|
return "pong" as const;
|
|
},
|
|
}),
|
|
});
|
|
},
|
|
});
|
|
|
|
function localDraftRepository() {
|
|
let stored: Readonly<{ value: LocalDraft; revision: number }> | null = null;
|
|
const repository = Object.freeze({
|
|
async compareAndSwap(input: Readonly<{ value: LocalDraft }>) {
|
|
stored = Object.freeze({ value: input.value, revision: 1 });
|
|
return Object.freeze({
|
|
ok: true as const,
|
|
value: Object.freeze({ revision: 1 }),
|
|
});
|
|
},
|
|
async read() {
|
|
return Object.freeze({ ok: true as const, value: stored });
|
|
},
|
|
async remove() {
|
|
stored = null;
|
|
return Object.freeze({
|
|
ok: true as const,
|
|
value: Object.freeze({ revision: 2 }),
|
|
});
|
|
},
|
|
}) as unknown as IndexedDbRepositoryPort<LocalDraft, never>;
|
|
return repository;
|
|
}
|
|
|
|
describe("feature adapter composition", () => {
|
|
it("composes HTTP-only and IndexedDB-only concrete contributions together", async () => {
|
|
const repository = localDraftRepository();
|
|
const get = ((repositoryId: string) => {
|
|
expect(repositoryId).toBe("local-draft");
|
|
return repository;
|
|
}) as unknown as IndexedDbRepositoryProvider["get"];
|
|
|
|
const indexedDb = Object.freeze({ get }) satisfies IndexedDbRepositoryProvider;
|
|
const http = Object.freeze({
|
|
execute: async () => {
|
|
throw new Error("HTTP should not execute during composition");
|
|
},
|
|
}) as unknown as InstalledHttpOperationExecutor;
|
|
|
|
const inputs = composeFeatureAdapterInputs(
|
|
Object.freeze([
|
|
TEST_HTTP_FEATURE_ADAPTER_CONTRIBUTION,
|
|
LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION,
|
|
] as const),
|
|
Object.freeze(["test-http-feature", "local-draft"]),
|
|
Object.freeze({ http, indexedDb }),
|
|
);
|
|
|
|
expect(Object.keys(inputs).sort()).toEqual([
|
|
"local-draft",
|
|
"test-http-feature",
|
|
]);
|
|
|
|
await expect(inputs["test-http-feature"]?.ping()).resolves.toBe("pong");
|
|
|
|
const localDraft = inputs["local-draft"];
|
|
if (!localDraft) throw new Error("local-draft input was not composed");
|
|
|
|
const draft = Object.freeze({
|
|
draftId: "draft-1",
|
|
title: "Local draft",
|
|
body: "Body",
|
|
});
|
|
|
|
await expect(
|
|
localDraft.saveDraft({
|
|
draft,
|
|
expectedRevision: null,
|
|
idempotencyKey: "save-draft-1",
|
|
}),
|
|
).resolves.toEqual({ ok: true, value: { revision: 1 } });
|
|
|
|
await expect(localDraft.findDraft("draft-1")).resolves.toEqual({
|
|
ok: true,
|
|
value: { draft, revision: 1 },
|
|
});
|
|
});
|
|
});
|