Skip to content

Commit

Permalink
chore: export types
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Mar 22, 2024
1 parent 7386b43 commit 20a1f3b
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,

Check warning on line 108 in src/operations_builder/sync_operations_builder_with_reasoner.ts

View check run for this annotation

Codecov / codecov/patch

src/operations_builder/sync_operations_builder_with_reasoner.ts#L108

Added line #L108 was not covered by tests
);

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 20a1f3b

Please sign in to comment.