File size: 975 Bytes
b39afbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * Copyright (c) 2023 MERCENARIES.AI PTE. LTD.
 * All rights reserved.
 */

import { DBObject, type IDBObjectLink } from './DBObject';

enum EObjectName {
  USER = 'User',
  GROUP = 'Group',
  ORGANISATION = 'Organisation',
  WORKFLOW = 'Workflow'
}

enum EObjectAction {
  CREATE = 'create',
  READ = 'read',
  UPDATE = 'update',
  DELETE = 'delete',
  EXECUTE = 'exec'
}

interface IGroupPermission {
  subject: any;
  action: string[];
  conditions?: any;
}

class Group extends DBObject {
  name: string;
  credit: number;
  organisation: IDBObjectLink | null;
  members: IDBObjectLink[];
  permission: IGroupPermission[];

  static readonly modelName = 'Group';

  constructor(id: string, name: string) {
    super(id);
    this._id = `${Group.modelName}:${this.id}`;
    this.name = name;
    this.credit = 0;
    this.organisation = null;
    this.members = [];
    this.permission = [];
  }
}

export { Group, type IGroupPermission, EObjectName, EObjectAction };