Skip to content

Commit

Permalink
Merge pull request #88 from biothings/move-redisclient
Browse files Browse the repository at this point in the history
Export additional types
  • Loading branch information
tokebe authored Apr 1, 2024
2 parents 7386b43 + 20a1f3b commit 07a50cb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
26 changes: 20 additions & 6 deletions src/operations_builder/sync_operations_builder_with_reasoner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 => {
Expand Down
10 changes: 6 additions & 4 deletions src/parser/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -161,9 +165,7 @@ interface KGAssociationObject {
smartapi?: SmartAPIRegistryRecordObject;
"x-translator"?: any;
"x-trapi"?: XTRAPIObject;
qualifiers?: {
[qualifierType: string]: string | string[];
};
qualifiers?: KGQualifiersObject;
}

export interface QueryOperationInterface {
Expand Down

0 comments on commit 07a50cb

Please sign in to comment.