7bf6df74412d54de3d7f013da6f5f9fb8b15dc76
[arvados-workbench2.git] / src / models / collection-file.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Tree } from './tree';
6
7 export type CollectionFilesTree = Tree<CollectionDirectory | CollectionFile>;
8
9 export enum CollectionFileType {
10     DIRECTORY = 'directory',
11     FILE = 'file'
12 }
13
14 export interface CollectionDirectory {
15     path: string;
16     id: string;
17     name: string;
18     type: CollectionFileType.DIRECTORY;
19 }
20
21 export interface CollectionFile {
22     path: string;
23     id: string;
24     name: string;
25     size: number;
26     type: CollectionFileType.FILE;
27 }
28
29 export const createCollectionDirectory = (data: Partial<CollectionDirectory>): CollectionDirectory => ({
30     id: '',
31     name: '',
32     path: '',
33     type: CollectionFileType.DIRECTORY,
34     ...data
35 });
36
37 export const createCollectionFile = (data: Partial<CollectionFile>): CollectionFile => ({
38     id: '',
39     name: '',
40     path: '',
41     size: 0,
42     type: CollectionFileType.FILE,
43     ...data
44 });