diff --git a/src/domain-services/external-reference/external-reference-service.ts b/src/domain-services/external-reference/external-reference-service.ts index 5c016473..15afaa35 100644 --- a/src/domain-services/external-reference/external-reference-service.ts +++ b/src/domain-services/external-reference/external-reference-service.ts @@ -1,9 +1,9 @@ -import { Database } from '@unocha/hpc-api-core/src/db'; -import { FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; +import { type Database } from '@unocha/hpc-api-core/src/db'; +import { type FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; import { Op } from '@unocha/hpc-api-core/src/db/util/conditions'; -import { InstanceDataOfModel } from '@unocha/hpc-api-core/src/db/util/raw-model'; +import { type InstanceDataOfModel } from '@unocha/hpc-api-core/src/db/util/raw-model'; import { Service } from 'typedi'; -import { FlowExternalReference } from '../flows/graphql/types'; +import { type FlowExternalReference } from '../flows/graphql/types'; @Service() export class ExternalReferenceService { @@ -19,11 +19,11 @@ export class ExternalReferenceService { const externalReferencesMap = new Map(); - flowIDs.forEach((flowID) => { + for (const flowID of flowIDs) { externalReferencesMap.set(flowID, []); - }); + } - externalReferences.forEach((externalReference) => { + for (const externalReference of externalReferences) { const flowID = externalReference.flowID; const externalReferenceMapped = this.mapExternalReferenceToExternalReferenceFlows(externalReference); @@ -33,7 +33,7 @@ export class ExternalReferenceService { } externalReferencesMap.get(flowID).push(externalReferenceMapped); - }); + } return externalReferencesMap; } diff --git a/src/domain-services/flow-link/flow-link-service.ts b/src/domain-services/flow-link/flow-link-service.ts index 8252340c..4952c7a2 100644 --- a/src/domain-services/flow-link/flow-link-service.ts +++ b/src/domain-services/flow-link/flow-link-service.ts @@ -1,7 +1,7 @@ -import { FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; -import { Database } from '@unocha/hpc-api-core/src/db/type'; +import { type FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; +import { type Database } from '@unocha/hpc-api-core/src/db/type'; import { Op } from '@unocha/hpc-api-core/src/db/util/conditions'; -import { InstanceOfModel } from '@unocha/hpc-api-core/src/db/util/types'; +import { type InstanceOfModel } from '@unocha/hpc-api-core/src/db/util/types'; import { Service } from 'typedi'; @Service() @@ -9,7 +9,7 @@ export class FlowLinkService { async getFlowLinksForFlows( flowIds: FlowId[], models: Database - ): Promise[]>> { + ): Promise>>> { const flowLinks = await models.flowLink.find({ where: { childID: { @@ -21,11 +21,11 @@ export class FlowLinkService { // Group flowLinks by flow ID for easy mapping const flowLinksMap = new Map< number, - InstanceOfModel[] + Array> >(); // Populate the map with flowLinks for each flow - flowLinks.forEach((flowLink) => { + for (const flowLink of flowLinks) { const flowId = flowLink.childID.valueOf(); if (!flowLinksMap.has(flowId)) { @@ -35,7 +35,7 @@ export class FlowLinkService { const flowLinksForFlow = flowLinksMap.get(flowId)!; flowLinksForFlow.push(flowLink); - }); + } return flowLinksMap; } diff --git a/src/domain-services/flow-object/flow-object-service.ts b/src/domain-services/flow-object/flow-object-service.ts index 049bd03d..aeb25120 100644 --- a/src/domain-services/flow-object/flow-object-service.ts +++ b/src/domain-services/flow-object/flow-object-service.ts @@ -1,5 +1,5 @@ -import { Database } from '@unocha/hpc-api-core/src/db'; -import { FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; +import { type Database } from '@unocha/hpc-api-core/src/db'; +import { type FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; import { Op } from '@unocha/hpc-api-core/src/db/util/conditions'; import { Service } from 'typedi'; diff --git a/src/domain-services/flow-object/model.ts b/src/domain-services/flow-object/model.ts index 1d666288..e8c19d72 100644 --- a/src/domain-services/flow-object/model.ts +++ b/src/domain-services/flow-object/model.ts @@ -1,4 +1,4 @@ -import { Database } from '@unocha/hpc-api-core/src/db'; -import { InstanceOfModel } from '@unocha/hpc-api-core/src/db/util/types'; +import { type Database } from '@unocha/hpc-api-core/src/db'; +import { type InstanceOfModel } from '@unocha/hpc-api-core/src/db/util/types'; export type FlowObject = InstanceOfModel; diff --git a/src/domain-services/flows/model.ts b/src/domain-services/flows/model.ts index b5d35436..3c425a7e 100644 --- a/src/domain-services/flows/model.ts +++ b/src/domain-services/flows/model.ts @@ -1,4 +1,4 @@ -import { Database } from '@unocha/hpc-api-core/src/db'; -import { InstanceDataOfModel } from '@unocha/hpc-api-core/src/db/util/raw-model'; +import { type Database } from '@unocha/hpc-api-core/src/db'; +import { type InstanceDataOfModel } from '@unocha/hpc-api-core/src/db/util/raw-model'; export type FlowEntity = InstanceDataOfModel; diff --git a/src/domain-services/flows/strategy/flow-search-strategy.ts b/src/domain-services/flows/strategy/flow-search-strategy.ts index cd15f90e..ff11e0b5 100644 --- a/src/domain-services/flows/strategy/flow-search-strategy.ts +++ b/src/domain-services/flows/strategy/flow-search-strategy.ts @@ -1,5 +1,5 @@ -import { Database } from '@unocha/hpc-api-core/src/db'; -import { FlowEntity } from '../model'; +import { type Database } from '@unocha/hpc-api-core/src/db'; +import { type FlowEntity } from '../model'; export interface FlowSearchStrategyResponse { flows: FlowEntity[]; diff --git a/src/domain-services/flows/strategy/impl/only-flow-conditions-strategy.ts b/src/domain-services/flows/strategy/impl/only-flow-conditions-strategy.ts index 2af8506b..d6557e9e 100644 --- a/src/domain-services/flows/strategy/impl/only-flow-conditions-strategy.ts +++ b/src/domain-services/flows/strategy/impl/only-flow-conditions-strategy.ts @@ -1,9 +1,9 @@ -import { Database } from '@unocha/hpc-api-core/src/db'; +import { type Database } from '@unocha/hpc-api-core/src/db'; import { Service } from 'typedi'; import { FlowService } from '../../flow-service'; import { - FlowSearchStrategy, - FlowSearchStrategyResponse, + type FlowSearchStrategy, + type FlowSearchStrategyResponse, } from '../flow-search-strategy'; @Service() diff --git a/src/domain-services/report-details/report-detail-service.ts b/src/domain-services/report-details/report-detail-service.ts index 70b8b015..9d0f898a 100644 --- a/src/domain-services/report-details/report-detail-service.ts +++ b/src/domain-services/report-details/report-detail-service.ts @@ -1,16 +1,16 @@ -import { Database } from '@unocha/hpc-api-core/src/db'; -import { FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; +import { type Database } from '@unocha/hpc-api-core/src/db'; +import { type FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; import { Op } from '@unocha/hpc-api-core/src/db/util/conditions'; -import { InstanceDataOfModel } from '@unocha/hpc-api-core/src/db/util/raw-model'; +import { type InstanceDataOfModel } from '@unocha/hpc-api-core/src/db/util/raw-model'; import { Service } from 'typedi'; -import { ReportDetail } from './graphql/types'; +import { type ReportDetail } from './graphql/types'; @Service() export class ReportDetailService { async getReportDetailsForFlows( flowIds: FlowId[], models: Database ): Promise> { - const reportDetails: InstanceDataOfModel[] = + const reportDetails: Array> = await models.reportDetail.find({ where: { flowID: { @@ -22,7 +22,7 @@ export class ReportDetailService { const reportDetailsMap = new Map(); - flowIds.forEach((flowId: FlowId) => { + for (const flowId of flowIds) { if (!reportDetailsMap.has(flowId)) { reportDetailsMap.set(flowId, []); } @@ -35,7 +35,7 @@ export class ReportDetailService { this.mapReportDetailsToFlowReportDetail(reportDetail); reportDetailsMap.get(flowId)?.push(reportDetailMapped); } - }); + } return reportDetailsMap; } diff --git a/src/utils/graphql/pagination.ts b/src/utils/graphql/pagination.ts index c4765253..d53648b4 100644 --- a/src/utils/graphql/pagination.ts +++ b/src/utils/graphql/pagination.ts @@ -1,6 +1,6 @@ import { Op } from '@unocha/hpc-api-core/src/db/util/conditions'; import { createBrandedValue } from '@unocha/hpc-api-core/src/util/types'; -import { ObjectType, Field, ArgsType } from 'type-graphql'; +import { ArgsType, Field, ObjectType } from 'type-graphql'; export type SortOrder = 'asc' | 'desc'; @@ -46,7 +46,7 @@ export function prepareConditionFromCursor( if (afterCursor || beforeCursor) { const isAscending = sortCondition.order === 'asc'; - const cursorValue = afterCursor || beforeCursor; + const cursorValue = afterCursor ?? beforeCursor; let op; if (isAscending) {