src/features/local-draft-feature는 기능이 아니라 IndexedDB recipe의 소비자다. 시험 5개와 recipe가 쓰고, 그래서 생성기에 NOT_A_FEATURE 예외가 있었다(S4 3.1절 S-3). 코드를 tests/fixtures/indexeddb-consumer/로 옮기고 import만 고쳤다. NOT_A_FEATURE 표식은 이 폴더만 썼고 다운스트림 둘에도 없어 생성기에서 지웠다. 선언 없는 폴더는 밖으로 옮기라는 메시지로 실패한다. 매뉴얼 오류표, README, starter-experience, capability-consumer-experience, patterns를 고쳤다. 위험: fixture는 기능 폴더 밖이라 기능 계층 규칙(dependency-cruiser)이 걸리지 않는다. recipe가 tests/ 아래 파일을 type import한다. 검증(desktop): test:contract, test:recipes, test:browser-capabilities, test:unit 통과.
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import {
|
|
defineFeatureAdapterContribution,
|
|
} from "../../../../src/features/feature-adapter-contribution.ts";
|
|
import type {} from "../../../../src/features/feature-adapter-contribution.ts";
|
|
import {
|
|
createLocalDraftFeatureInput,
|
|
} from "../application/local-draft-api.ts";
|
|
import {
|
|
LOCAL_DRAFT_FEATURE_ID,
|
|
LOCAL_DRAFT_REPOSITORY_ID,
|
|
} from "../contracts/local-draft-contract.ts";
|
|
import {
|
|
createLocalDraftStore,
|
|
type LocalDraftRepository,
|
|
} from "./local-draft-indexeddb-store.ts";
|
|
|
|
/**
|
|
* The IndexedDB consumer the tests compose: a local-draft store shaped like a
|
|
* feature's adapters, application and domain folders, with
|
|
* `needs: ["indexedDb"]`. It was the template's local-draft sample under
|
|
* src/features, a folder the generator skipped; it is a test fixture now. Its users:
|
|
* tests/contract/reusable-capability/feature-adapter-composition.test.ts,
|
|
* tests/contract/consumer-experience/indexeddb-local-draft.test.ts,
|
|
* tests/unit/local-draft-api.test.ts, tests/recipes/indexeddb-feature-capability.test.ts,
|
|
* tests/browser-capabilities/local-draft-composition.spec.ts and the recipe
|
|
* recipes/frontend-capabilities/indexeddb-feature-capability.ts.
|
|
*/
|
|
declare module "../../../../src/features/feature-adapter-contribution.ts" {
|
|
interface FeatureIndexedDbRepositories {
|
|
"local-draft": LocalDraftRepository;
|
|
}
|
|
}
|
|
|
|
export function createLocalDraftFeatureInstalledInput(context: Readonly<{
|
|
indexedDb: Readonly<{
|
|
get(repositoryId: "local-draft"): LocalDraftRepository;
|
|
}>;
|
|
}>) {
|
|
const repository = context.indexedDb.get(LOCAL_DRAFT_REPOSITORY_ID);
|
|
return Object.freeze({
|
|
featureId: LOCAL_DRAFT_FEATURE_ID,
|
|
input: createLocalDraftFeatureInput(createLocalDraftStore(repository)),
|
|
});
|
|
}
|
|
|
|
export const LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION =
|
|
defineFeatureAdapterContribution({
|
|
featureId: LOCAL_DRAFT_FEATURE_ID,
|
|
needs: ["indexedDb"] as const,
|
|
createInput: createLocalDraftFeatureInstalledInput,
|
|
});
|