From 7db0fad1d10609db23bb473bd754b280e175c6f3 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Tue, 5 Nov 2024 10:58:33 +0100 Subject: [PATCH] refactor: extract interface --- .../lib/domain/shared-dimension.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/apis/shared-dimensions/lib/domain/shared-dimension.ts b/apis/shared-dimensions/lib/domain/shared-dimension.ts index 8e3c071fe..2f723a5eb 100644 --- a/apis/shared-dimensions/lib/domain/shared-dimension.ts +++ b/apis/shared-dimensions/lib/domain/shared-dimension.ts @@ -18,13 +18,15 @@ import * as queries from './shared-dimension/queries' export { importDimension } from './shared-dimension/import' +interface Contributor { + name: string + email?: string +} + interface CreateSharedDimension { resource: GraphPointer store: SharedDimensionsStore - contributor: { - name: string - email?: string - } + contributor: Contributor } export async function create({ resource, store, contributor }: CreateSharedDimension): Promise { @@ -87,10 +89,7 @@ interface UpdateSharedDimension { store: SharedDimensionsStore shape: MultiPointer | undefined queries?: typeof queries - contributor: { - name: string - email?: string - } + contributor: Contributor } function removeSubgraph(pointer: GraphPointer, predicate?: Term) { @@ -128,10 +127,7 @@ export async function update({ resource, store, shape, queries, contributor }: U return resource } -function setDefaultContributor(termSet: GraphPointer, contributor: { - name: string - email?: string -}) { +function setDefaultContributor(termSet: GraphPointer, contributor: Contributor) { if (termSet.out(dcterms.contributor).terms.length === 0) { termSet.addOut(dcterms.contributor, contributorPtr => { contributorPtr.addOut(schema.name, contributor.name)