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, });