From 20a1f3b5c7102e80fc79c32609c6f0c3aa4f8b25 Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:04:15 -0400 Subject: [PATCH] chore: export types --- .../sync_operations_builder_with_reasoner.ts | 26 ++++++++++++++----- src/parser/types.ts | 10 ++++--- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/operations_builder/sync_operations_builder_with_reasoner.ts b/src/operations_builder/sync_operations_builder_with_reasoner.ts index 1e84329..b0c3ac1 100644 --- a/src/operations_builder/sync_operations_builder_with_reasoner.ts +++ b/src/operations_builder/sync_operations_builder_with_reasoner.ts @@ -16,7 +16,11 @@ export default class SyncOperationsBuilderWithReasoner extends BaseOperationsBui private _file_path: string; private _predicates_file_path: string; - constructor(options: BuilderOptions, path: string, predicates_file_path: string) { + constructor( + options: BuilderOptions, + path: string, + predicates_file_path: string, + ) { super(options); this._file_path = path; this._predicates_file_path = predicates_file_path; @@ -32,7 +36,9 @@ export default class SyncOperationsBuilderWithReasoner extends BaseOperationsBui return input; } - private parsePredicateEndpoint(metadata: PredicatesMetadata): SmartAPIKGOperationObject[] { + private parsePredicateEndpoint( + metadata: PredicatesMetadata, + ): SmartAPIKGOperationObject[] { const ops = [] as SmartAPIKGOperationObject[]; if (!("predicates" in metadata)) { return ops; @@ -49,7 +55,9 @@ export default class SyncOperationsBuilderWithReasoner extends BaseOperationsBui input_id: metadata?.nodes?.[sbj]?.id_prefixes, output_type: this.removeBioLinkPrefix(obj), output_id: metadata?.nodes?.[obj]?.id_prefixes, - predicate: this.removeBioLinkPrefix(typeof pred === "string" ? pred : pred.predicate), + predicate: this.removeBioLinkPrefix( + typeof pred === "string" ? pred : pred.predicate, + ), api_name: metadata.association.api_name, smartapi: metadata.association.smartapi, qualifiers: @@ -87,13 +95,17 @@ export default class SyncOperationsBuilderWithReasoner extends BaseOperationsBui api => api.id === op.association.smartapi.id && api.id !== undefined, ); const includeInfoRes = this._options.apiList.include.find( - api => api.infores === op.association?.["x-translator"]?.infores && api.infores !== undefined, + api => + api.infores === op.association?.["x-translator"]?.infores && + api.infores !== undefined, ); const excludeSmartAPI = this._options.apiList.exclude.find( api => api.id === op.association.smartapi.id && api.id !== undefined, ); const excludeInfoRes = this._options.apiList.exclude.find( - api => api.infores === op.association?.["x-translator"]?.infores && api.infores !== undefined, + api => + api.infores === op.association?.["x-translator"]?.infores && + api.infores !== undefined, ); let willBeIncluded; @@ -170,7 +182,9 @@ export default class SyncOperationsBuilderWithReasoner extends BaseOperationsBui "x-trapi" in spec.info && spec.servers.length && "/meta_knowledge_graph" in spec.paths && - !predicatesMetadata.map(m => m.association.smartapi.id).includes(spec._id), + !predicatesMetadata + .map(m => m.association.smartapi.id) + .includes(spec._id), ); let TRAPIOps = [] as SmartAPIKGOperationObject[]; predicatesMetadata.map(metadata => { diff --git a/src/parser/types.ts b/src/parser/types.ts index 42a5633..8cb1e47 100644 --- a/src/parser/types.ts +++ b/src/parser/types.ts @@ -148,7 +148,11 @@ export interface XTRAPIObject { rate_limit?: number; } -interface KGAssociationObject { +export interface KGQualifiersObject { + [qualifierType: string]: string | string[]; +} + +export interface KGAssociationObject { input_id?: string | string[]; input_type: string; output_id?: string | string[]; @@ -161,9 +165,7 @@ interface KGAssociationObject { smartapi?: SmartAPIRegistryRecordObject; "x-translator"?: any; "x-trapi"?: XTRAPIObject; - qualifiers?: { - [qualifierType: string]: string | string[]; - }; + qualifiers?: KGQualifiersObject; } export interface QueryOperationInterface {