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 enum ResourceKind {
18 COLLECTION = "arvados#collection",
19 CONTAINER = "arvados#container",
20 CONTAINER_REQUEST = "arvados#containerRequest",
21 GROUP = "arvados#group",
23 PROCESS = "arvados#containerRequest",
24 PROJECT = "arvados#group",
25 USER = "arvados#user",
26 WORKFLOW = "arvados#workflow",
29 export enum ResourceObjectType {
32 CONTAINER_REQUEST = 'xvhdp',
38 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
39 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
41 export const isResourceUuid = (uuid: string) =>
42 RESOURCE_UUID_REGEX.test(uuid);
44 export const extractUuidObjectType = (uuid: string) => {
45 const match = RESOURCE_UUID_REGEX.exec(uuid);
47 ? match[0].split('-')[1]
51 export const extractUuidKind = (uuid: string = '') => {
52 const objectType = extractUuidObjectType(uuid);
54 case ResourceObjectType.USER:
55 return ResourceKind.USER;
56 case ResourceObjectType.GROUP:
57 return ResourceKind.GROUP;
58 case ResourceObjectType.COLLECTION:
59 return ResourceKind.COLLECTION;
60 case ResourceObjectType.CONTAINER_REQUEST:
61 return ResourceKind.CONTAINER_REQUEST;
62 case ResourceObjectType.CONTAINER:
63 return ResourceKind.CONTAINER;
64 case ResourceObjectType.LOG:
65 return ResourceKind.LOG;