To avoid getting a whole collection record with its manifest_text field,
we use the list request with a uuid filter.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>
collectionService.update = jest.fn();
});
collectionService.update = jest.fn();
});
+ describe('get', () => {
+ it('should make a list request with uuid filtering', async () => {
+ serverApi.get = jest.fn(() => Promise.resolve(
+ { data: { items: [{}] } }
+ ));
+ const uuid = 'zzzzz-4zz18-0123456789abcde'
+ await collectionService.get(uuid);
+ expect(serverApi.get).toHaveBeenCalledWith(
+ '/collections', {
+ params: {
+ filters: `[["uuid","=","zzzzz-4zz18-0123456789abcde"]]`,
+ order: undefined
+ },
+ }
+ );
+ });
+ });
+
describe('update', () => {
it('should call put selecting updated fields + others', async () => {
serverApi.put = jest.fn(() => Promise.resolve({ data: {} }));
describe('update', () => {
it('should call put selecting updated fields + others', async () => {
serverApi.put = jest.fn(() => Promise.resolve({ data: {} }));
import { TrashableResourceService } from "services/common-service/trashable-resource-service";
import { ApiActions } from "services/api/api-actions";
import { customEncodeURI } from "common/url";
import { TrashableResourceService } from "services/common-service/trashable-resource-service";
import { ApiActions } from "services/api/api-actions";
import { customEncodeURI } from "common/url";
+import { FilterBuilder } from "services/api/filter-builder";
export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
+ async get(uuid: string, showErrors?: boolean) {
+ super.validateUuid(uuid);
+ // We use a filtered list request to avoid getting the manifest text
+ const filters = new FilterBuilder().addEqual('uuid', uuid).getFilters();
+ const lst = await super.list({filters}, showErrors);
+ return lst.items[0];
+ }
+
create(data?: Partial<CollectionResource>) {
return super.create({ ...data, preserveVersion: true });
}
create(data?: Partial<CollectionResource>) {
return super.create({ ...data, preserveVersion: true });
}
- private validateUuid(uuid: string) {
+ protected validateUuid(uuid: string) {
if (uuid === "") {
throw new Error('UUID cannot be empty string');
}
if (uuid === "") {
throw new Error('UUID cannot be empty string');
}
- list(args: ListArguments = {}): Promise<ListResults<T>> {
+ list(args: ListArguments = {}, showErrors?: boolean): Promise<ListResults<T>> {
const { filters, order, ...other } = args;
const params = {
...CommonService.mapKeys(snakeCase)(other),
const { filters, order, ...other } = args;
const params = {
...CommonService.mapKeys(snakeCase)(other),
if (QueryString.stringify(params).length <= 1500) {
return CommonService.defaultResponse(
this.serverApi.get(`/${this.resourceType}`, { params }),
if (QueryString.stringify(params).length <= 1500) {
return CommonService.defaultResponse(
this.serverApi.get(`/${this.resourceType}`, { params }),
+ this.actions,
+ showErrors
);
} else {
// Using the POST special case to avoid URI length 414 errors.
);
} else {
// Using the POST special case to avoid URI length 414 errors.
+ this.actions,
+ showErrors