1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 export interface Resource {
9 modifiedByClientUuid: string;
10 modifiedByUserUuid: string;
17 export interface TrashableResource extends Resource {
23 export enum ResourceKind {
24 COLLECTION = "arvados#collection",
25 CONTAINER = "arvados#container",
26 CONTAINER_REQUEST = "arvados#containerRequest",
27 GROUP = "arvados#group",
29 PROCESS = "arvados#containerRequest",
30 PROJECT = "arvados#group",
31 USER = "arvados#user",
32 WORKFLOW = "arvados#workflow",
36 export enum ResourceObjectType {
39 CONTAINER_REQUEST = 'xvhdp',
45 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
46 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
48 export const isResourceUuid = (uuid: string) =>
49 RESOURCE_UUID_REGEX.test(uuid);
51 export const extractUuidObjectType = (uuid: string) => {
52 const match = RESOURCE_UUID_REGEX.exec(uuid);
54 ? match[0].split('-')[1]
58 export const extractUuidKind = (uuid: string = '') => {
59 const objectType = extractUuidObjectType(uuid);
61 case ResourceObjectType.USER:
62 return ResourceKind.USER;
63 case ResourceObjectType.GROUP:
64 return ResourceKind.GROUP;
65 case ResourceObjectType.COLLECTION:
66 return ResourceKind.COLLECTION;
67 case ResourceObjectType.CONTAINER_REQUEST:
68 return ResourceKind.CONTAINER_REQUEST;
69 case ResourceObjectType.CONTAINER:
70 return ResourceKind.CONTAINER;
71 case ResourceObjectType.LOG:
72 return ResourceKind.LOG;