66 lines
2.8 KiB
TypeScript
66 lines
2.8 KiB
TypeScript
import type { TechLogStudioApplication } from "../../src/features/tech-log/application/studio-application.ts";
|
|
import type { StudioAssetGateway } from "../../src/features/tech-log/application/ports/studio-asset-gateway.ts";
|
|
import type { StudioGateway } from "../../src/features/tech-log/application/ports/studio-gateway.ts";
|
|
|
|
export function studioGatewayFromApplication(
|
|
application: TechLogStudioApplication,
|
|
): StudioGateway {
|
|
return {
|
|
getDashboard: application.workspaceQueries.getDashboard,
|
|
listDocuments: application.workspaceQueries.listDocuments,
|
|
createDocument: application.workspaceCommands.createDocument,
|
|
getDocument: application.documentQueries.getDocument,
|
|
saveDocument: application.documentCommands.saveDocument,
|
|
validateDocument: application.documentCommands.validateDocument,
|
|
createPreview: application.documentCommands.createPreview,
|
|
getCurrentPreview: application.documentQueries.getCurrentPreview,
|
|
publishDocument: application.documentCommands.publishDocument,
|
|
unpublishPublication: application.workspaceCommands.unpublishPublication,
|
|
listPublications: application.workspaceQueries.listPublications,
|
|
getPublicationSnapshot: application.workspaceQueries.getPublicationSnapshot,
|
|
getCatalog: application.workspaceQueries.getCatalog,
|
|
};
|
|
}
|
|
|
|
export function studioAssetGatewayFromApplication(
|
|
application: TechLogStudioApplication,
|
|
): StudioAssetGateway {
|
|
return {
|
|
listAssets: application.assetQueries.listAssets,
|
|
uploadAsset: application.assetCommands.uploadAsset,
|
|
getAsset: application.assetQueries.getAsset,
|
|
updateAssetMetadata: application.assetCommands.updateAssetMetadata,
|
|
deleteAsset: application.assetCommands.deleteAsset,
|
|
};
|
|
}
|
|
|
|
export function withStudioGateway(
|
|
application: TechLogStudioApplication,
|
|
gateway: StudioGateway,
|
|
): TechLogStudioApplication {
|
|
return Object.freeze({
|
|
...application,
|
|
workspaceQueries: Object.freeze({
|
|
getDashboard: gateway.getDashboard.bind(gateway),
|
|
listDocuments: gateway.listDocuments.bind(gateway),
|
|
listPublications: gateway.listPublications.bind(gateway),
|
|
getPublicationSnapshot: gateway.getPublicationSnapshot.bind(gateway),
|
|
getCatalog: gateway.getCatalog.bind(gateway),
|
|
}),
|
|
workspaceCommands: Object.freeze({
|
|
createDocument: gateway.createDocument.bind(gateway),
|
|
unpublishPublication: gateway.unpublishPublication.bind(gateway),
|
|
}),
|
|
documentQueries: Object.freeze({
|
|
getDocument: gateway.getDocument.bind(gateway),
|
|
getCurrentPreview: gateway.getCurrentPreview.bind(gateway),
|
|
}),
|
|
documentCommands: Object.freeze({
|
|
saveDocument: gateway.saveDocument.bind(gateway),
|
|
validateDocument: gateway.validateDocument.bind(gateway),
|
|
createPreview: gateway.createPreview.bind(gateway),
|
|
publishDocument: gateway.publishDocument.bind(gateway),
|
|
}),
|
|
});
|
|
}
|