Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRAPI 1.4: Provenance refactor #79

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/operations_builder/sync_builder_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,34 @@ export const syncBuilderFactory = (
options: BuilderOptions,
includeReasoner: boolean,
smartapi_path: string,
predicates_path: string
predicates_path: string,
): SmartAPIKGOperationObject[] => {
let builder;
if (includeReasoner === true) {
builder = new SyncOperationsBuilderWithReasoner(
options,
smartapi_path,
predicates_path
);
builder = new SyncOperationsBuilderWithReasoner(options, smartapi_path, predicates_path);
} else {
builder = new SyncOperationsBuilder(options, smartapi_path);
}
const ops = builder.build();

const primaryKnowledgeAPIs = new Set();
options.apiList?.include.forEach(api => {
if (api.primarySource) {
if (api.id) primaryKnowledgeAPIs.add(api.id);
if (api.infores) primaryKnowledgeAPIs.add(api.infores);
}
});
options.apiList?.exclude.forEach(api => {
if (api.primarySource) {
if (api.id) primaryKnowledgeAPIs.add(api.id);
if (api.infores) primaryKnowledgeAPIs.add(api.infores);
}
});
ops.map(op => {
const apiIsPrimaryKnowledgeSource =
primaryKnowledgeAPIs.has(op.association.smartapi.id) ||
primaryKnowledgeAPIs.has(op.association["x-translator"].infores);
op.association.apiIsPrimaryKnowledgeSource = apiIsPrimaryKnowledgeSource ? true : false;
});
return ops;
};
7 changes: 4 additions & 3 deletions src/parser/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface XTranslatorObject {
component: string;
team: string[];
"infores"?: string;
infores?: string;
}

interface SmartAIPInfoObject {
Expand Down Expand Up @@ -111,7 +111,7 @@ export interface XBTEKGSOperationObject {
inputs: XBTEKGSOperationBioEntityObject[];
outputs: XBTEKGSOperationBioEntityObject[];
predicate: string;
qualifiers?: { [qualifierType: string]: string; };
qualifiers?: { [qualifierType: string]: string };
source?: string;
parameters?: XBTEParametersObject;
requestBody?: any;
Expand Down Expand Up @@ -157,12 +157,13 @@ interface KGAssociationObject {
source?: string;
api_name?: string;
component?: string;
apiIsPrimaryKnowledgeSource?: boolean;
smartapi?: SmartAPIRegistryRecordObject;
"x-translator"?: any;
"x-trapi"?: XTRAPIObject;
qualifiers?: {
[qualifierType: string]: string;
}
};
}

export interface QueryOperationInterface {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface SmartAPIQueryResult {
}

export interface apiListItem {
primarySource?: boolean;
id?: string;
infores?: string;
name: string;
Expand Down