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",
22 PROCESS = "arvados#containerRequest",
23 PROJECT = "arvados#group",
24 USER = "arvados#user",
25 WORKFLOW = "arvados#workflow",
28 export enum ResourceObjectType {
31 CONTAINER_REQUEST = 'xvhdp',
36 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
37 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
39 export const isResourceUuid = (uuid: string) =>
40 RESOURCE_UUID_REGEX.test(uuid);
42 export const extractUuidObjectType = (uuid: string) => {
43 const match = RESOURCE_UUID_REGEX.exec(uuid);
45 ? match[0].split('-')[1]
49 export const extractUuidKind = (uuid: string = '') => {
50 const objectType = extractUuidObjectType(uuid);
52 case ResourceObjectType.USER:
53 return ResourceKind.USER;
54 case ResourceObjectType.GROUP:
55 return ResourceKind.GROUP;
56 case ResourceObjectType.COLLECTION:
57 return ResourceKind.COLLECTION;
58 case ResourceObjectType.CONTAINER_REQUEST:
59 return ResourceKind.CONTAINER_REQUEST;
60 case ResourceObjectType.CONTAINER:
61 return ResourceKind.CONTAINER;