Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/biothings/smartapi-kg.js in…
Browse files Browse the repository at this point in the history
…to dev
  • Loading branch information
tokebe committed Nov 13, 2024
2 parents e3b6e44 + a9519aa commit e891b00
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"@babel/preset-typescript": "^7.23.2",
"@types/debug": "^4.1.10",
"@types/express": "^4.17.20",
"@types/node": "^14.18.63",
"@types/jest": "^26.0.24",
"@types/lodash": "^4.14.200",
"@types/node": "^14.18.63",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"babel-loader": "^8.3.0",
Expand All @@ -71,9 +71,9 @@
},
"dependencies": {
"@babel/runtime": "^7.23.2",
"@biothings-explorer/utils": "workspace:../utils",
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^11.0.0",
"@biothings-explorer/utils": "workspace:../utils",
"axios": "^0.21.4",
"camelcase": "^6.3.0",
"core-js": "^3.33.1",
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const FILTER_FIELDS: FIELDS_FOR_FILTER[] = [
export const SMARTAPI_URL =
"https://smart-api.info/api/query?q=tags.name:translator&size=1000&fields=paths,servers,tags,components.x-bte*,info,_meta";

export const SINGLE_API_SMARTAPI_QUERY_TEMPLATE = "https://smart-api.info/api/metadata/{smartapi_id}";
export const SINGLE_API_SMARTAPI_QUERY_TEMPLATE = "https://smart-api.info/api/metadata/{smartAPIID}";

export const TEAM_SMARTAPI_QUERY_TEMPLATE =
'https://smart-api.info/api/query?q=info.x-translator.team:"{team_name}"&size=1000&fields=paths,servers,tags,components.x-bte*,info,_meta';
'https://smart-api.info/api/query?q=info.x-translator.team:"{teamName}"&size=1000&fields=paths,servers,tags,components.x-bte*,info,_meta';

export const COMPONENT_SMARTAPI_QUERY_TEMPLATE =
'https://smart-api.info/api/query?q=info.x-translator.component:"{component_name}"&size=1000&fields=paths,servers,tags,components.x-bte*,info,_meta';
Expand Down
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ft } from "./filter";
import path from "path";
import Debug from "debug";
import QueryOperationObject from "./parser/query_operation";
import { lockWithActionAsync } from "@biothings-explorer/utils";
const debug = Debug("bte:smartapi-kg:MetaKG");

export * from "./types";
Expand Down Expand Up @@ -66,6 +67,18 @@ export default class MetaKG {
return this.ops;
}

/* Async wrapper for using constructMetaKGSync to enable using async file locking */
async constructMetaKGWithFileLock(includeReasoner = false, options: BuilderOptions = {}): Promise<SmartAPIKGOperationObject[]> {
this._ops = await lockWithActionAsync(
[this._file_path, this._predicates_path],
async () => {
return syncBuilderFactory(options, includeReasoner, this._file_path, this._predicates_path);
},
debug
);
return this.ops;
}

/**
* Filters the whole meta kg based on apiList, teamName, tag or component
* @param {Object} options - filtering options
Expand Down
6 changes: 3 additions & 3 deletions src/load/single_spec_async_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { SmartAPISpec } from "../parser/types";

export default class SingleSpecAsyncLoader extends BaseAsyncLoader {
private _smartapi_id: string;
constructor(smartapiID: string) {
super(SINGLE_API_SMARTAPI_QUERY_TEMPLATE.replace("{smartapi_id}", smartapiID));
this._smartapi_id = smartapiID;
constructor(smartAPIID: string) {
super(SINGLE_API_SMARTAPI_QUERY_TEMPLATE.replace("{smartAPIID}", smartAPIID));
this._smartapi_id = smartAPIID;
}

protected async fetch(): Promise<SmartAPISpec> {
Expand Down
2 changes: 1 addition & 1 deletion src/load/team_specs_async_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SmartAPISpec } from "../parser/types";

export default class TeamSpecsAsyncLoader extends BaseAsyncLoader {
constructor(teamName: string) {
super(TEAM_SMARTAPI_QUERY_TEMPLATE.replace("{team_name}", teamName));
super(TEAM_SMARTAPI_QUERY_TEMPLATE.replace("{teamName}", teamName));
}

protected async fetch(): Promise<SmartAPIQueryResult> {
Expand Down

0 comments on commit e891b00

Please sign in to comment.