@tapis/tapisui-api
Version:
Typescript library for making api calls with react query
39 lines (38 loc) • 1.23 kB
JavaScript
import { Workflows } from '@tapis/tapis-typescript';
import { apiGenerator, errorDecoder } from '../../utils';
const listAll = async (params, basePath, jwt) => {
const api = apiGenerator(Workflows, Workflows.PipelinesApi, basePath, jwt);
const resps = await Promise.all(params.groupIds.map((groupId) => {
try {
return errorDecoder(() => api.listPipelines({ groupId }));
}
catch (e) {
throw e;
}
}));
let pipelines = [];
// Add every pipeline from each response to the list
resps.map((resp) => resp.result.map((pipeline) => pipelines.push(pipeline)));
const last = resps[resps.length - 1];
const hasNullResults = resps.some((resp) => {
return resp.result === null;
});
if (hasNullResults) {
return {
status: 'failure',
message: 'Failed to list all Pipelines',
metadata: last.metadata,
result: [],
version: last.version,
};
}
let respAll = {
status: last.status,
message: last.message,
metadata: last.metadata,
result: pipelines,
version: last.version,
};
return respAll;
};
export default listAll;