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

Add node api version to query options #204

Open
wants to merge 1 commit into
base: v8/kcs-integration
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion managers/graph-operations-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class GraphOperationsManager {
* @returns {Promise} A Promise that resolves to the query result.
*/
async query(queryString, queryType, options = {}) {
const { endpoint, port, maxNumberOfRetries, frequency, authToken, paranetUAL, repository } =
const { endpoint, port, maxNumberOfRetries, frequency, authToken, paranetUAL, repository, nodeApiVersion } =
this.inputService.getQueryArguments(options);

this.validationService.validateGraphQuery(
Expand All @@ -49,6 +49,7 @@ export default class GraphOperationsManager {
frequency,
authToken,
repository,
nodeApiVersion,
);

const operationId = await this.nodeApiService.query(
Expand All @@ -59,6 +60,7 @@ export default class GraphOperationsManager {
queryType,
paranetUAL,
repository,
nodeApiVersion,
);

return this.nodeApiService.getOperationResult(
Expand Down
4 changes: 4 additions & 0 deletions services/input-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default class InputService {
authToken: this.getAuthToken(options),
paranetUAL: this.getParanetUAL(options),
repository: this.getRepository(options),
nodeApiVersion: this.getNodeApiVersion(options),
};
}

Expand Down Expand Up @@ -416,4 +417,7 @@ export default class InputService {
getAssertionCachedLocally(options) {
return options.assertionCachedLocally ?? false;
}
getNodeApiVersion(options) {
return options.ndeApiVersion ?? config.nodeApiVersion ?? '/v1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

}
}
8 changes: 4 additions & 4 deletions services/node-api-service/implementations/http-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ export default class HttpService {
}
}

async query(endpoint, port, authToken, query, type, paranetUAL, repository) {
async query(endpoint, port, authToken, query, type, paranetUAL, repository, nodeApiVersion) {
try {
const response = await axios({
method: 'post',
url: `${this.getBaseUrl(endpoint, port)}/query`,
url: `${this.getBaseUrl(endpoint, port, nodeApiVersion)}/query`,
data: { query, type, repository, paranetUAL },
headers: this.prepareRequestConfig(authToken),
});
Expand Down Expand Up @@ -316,7 +316,7 @@ export default class HttpService {
return {};
}

getBaseUrl(endpoint, port) {
return `${endpoint}:${port}${this.apiVersion}`;
getBaseUrl(endpoint, port, apiVersion = null) {
return `${endpoint}:${port}${apiVersion ?? this.apiVersion}`;
}
}
6 changes: 6 additions & 0 deletions services/validation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class ValidationService {
frequency,
authToken,
repository,
nodeApiVersion,
) {
this.validateQueryString(queryString);
this.validateQueryType(queryType);
Expand All @@ -37,6 +38,7 @@ export default class ValidationService {
this.validateMaxNumberOfRetries(maxNumberOfRetries);
this.validateFrequency(frequency);
this.validateAuthToken(authToken);
this.validateNodeApiVersion(nodeApiVersion);

if (repository) {
this.validateRepository(repository);
Expand Down Expand Up @@ -773,4 +775,8 @@ export default class ValidationService {
minimumNumberOfFinalizationConfirmations,
);
}

validateNodeApiVersion(nodeApiVersion) {
nodeApiVersion === '/v1' || nodeApiVersion === '/v0'
}
}