phase01
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "@source/shared",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"scripts": {
|
||||
"lint": "eslint src/",
|
||||
"build": "tsc"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './permissions';
|
||||
export * from './roles';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,57 @@
|
||||
export const PERMISSIONS = {
|
||||
// Server
|
||||
'server.create': 'Create servers',
|
||||
'server.read': 'View servers',
|
||||
'server.update': 'Update server settings',
|
||||
'server.delete': 'Delete servers',
|
||||
|
||||
// Console
|
||||
'console.read': 'View console output',
|
||||
'console.write': 'Send console commands',
|
||||
|
||||
// Files
|
||||
'files.read': 'View and download files',
|
||||
'files.write': 'Create, edit, and upload files',
|
||||
'files.delete': 'Delete files',
|
||||
'files.archive': 'Compress and decompress files',
|
||||
|
||||
// Backup
|
||||
'backup.create': 'Create backups',
|
||||
'backup.restore': 'Restore backups',
|
||||
'backup.delete': 'Delete backups',
|
||||
'backup.download': 'Download backups',
|
||||
|
||||
// Schedule
|
||||
'schedule.read': 'View scheduled tasks',
|
||||
'schedule.manage': 'Create, edit, and delete scheduled tasks',
|
||||
|
||||
// Subuser
|
||||
'subuser.read': 'View subusers',
|
||||
'subuser.manage': 'Create, edit, and delete subusers',
|
||||
|
||||
// Plugin
|
||||
'plugin.read': 'View installed plugins',
|
||||
'plugin.manage': 'Install and remove plugins',
|
||||
|
||||
// Config
|
||||
'config.read': 'View server config',
|
||||
'config.write': 'Edit server config',
|
||||
|
||||
// Power
|
||||
'power.start': 'Start server',
|
||||
'power.stop': 'Stop server',
|
||||
'power.restart': 'Restart server',
|
||||
'power.kill': 'Kill server',
|
||||
|
||||
// Node (org admin)
|
||||
'node.read': 'View nodes',
|
||||
'node.manage': 'Manage nodes and allocations',
|
||||
|
||||
// Organization
|
||||
'org.settings': 'Manage organization settings',
|
||||
'org.members': 'Manage organization members',
|
||||
} as const;
|
||||
|
||||
export type Permission = keyof typeof PERMISSIONS;
|
||||
|
||||
export const ALL_PERMISSIONS = Object.keys(PERMISSIONS) as Permission[];
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { Permission } from './permissions';
|
||||
import { ALL_PERMISSIONS } from './permissions';
|
||||
|
||||
export const ROLES = {
|
||||
admin: {
|
||||
name: 'Admin',
|
||||
description: 'Full access to the organization',
|
||||
permissions: ALL_PERMISSIONS,
|
||||
},
|
||||
user: {
|
||||
name: 'User',
|
||||
description: 'Limited access, must be granted server-specific permissions',
|
||||
permissions: [
|
||||
'server.read',
|
||||
'console.read',
|
||||
'files.read',
|
||||
'backup.create',
|
||||
'backup.download',
|
||||
'schedule.read',
|
||||
'plugin.read',
|
||||
'config.read',
|
||||
'power.start',
|
||||
'power.stop',
|
||||
'power.restart',
|
||||
] as Permission[],
|
||||
},
|
||||
} as const;
|
||||
|
||||
export type Role = keyof typeof ROLES;
|
||||
@@ -0,0 +1,24 @@
|
||||
export type ServerStatus = 'installing' | 'running' | 'stopped' | 'suspended' | 'error';
|
||||
|
||||
export type PowerAction = 'start' | 'stop' | 'restart' | 'kill';
|
||||
|
||||
export type ScheduleType = 'interval' | 'daily' | 'weekly' | 'cron';
|
||||
|
||||
export type ScheduleAction = 'command' | 'power' | 'backup';
|
||||
|
||||
export type PluginSource = 'spiget' | 'manual';
|
||||
|
||||
export interface PaginationParams {
|
||||
page: number;
|
||||
perPage: number;
|
||||
}
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
data: T[];
|
||||
meta: {
|
||||
page: number;
|
||||
perPage: number;
|
||||
total: number;
|
||||
totalPages: number;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in New Issue
Block a user