feat: Fleet Forge UEM - device management, agent, remote desktop (VNC), TLS reverse proxy
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@fleetforge/shared",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"lint": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.0",
|
||||
"vitest": "^3.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
export const Roles = {
|
||||
OWNER: "owner",
|
||||
ADMIN: "admin",
|
||||
OPERATOR: "operator",
|
||||
READ_ONLY: "read_only",
|
||||
} as const;
|
||||
|
||||
export type Role = (typeof Roles)[keyof typeof Roles];
|
||||
|
||||
export const DeviceStatus = {
|
||||
ONLINE: "online",
|
||||
OFFLINE: "offline",
|
||||
WARNING: "warning",
|
||||
} as const;
|
||||
|
||||
export type DeviceStatus = (typeof DeviceStatus)[keyof typeof DeviceStatus];
|
||||
|
||||
export const DeviceType = {
|
||||
LINUX_SERVER: "linux_server",
|
||||
LINUX_DESKTOP: "linux_desktop",
|
||||
WINDOWS_SERVER: "windows_server",
|
||||
WINDOWS_CLIENT: "windows_client",
|
||||
MACOS: "macos",
|
||||
IOS: "ios",
|
||||
IPADOS: "ipados",
|
||||
ANDROID: "android",
|
||||
VM: "vm",
|
||||
CLOUD_INSTANCE: "cloud_instance",
|
||||
CONTAINER_HOST: "container_host",
|
||||
NETWORK_DEVICE: "network_device",
|
||||
IOT: "iot",
|
||||
} as const;
|
||||
|
||||
export type DeviceType = (typeof DeviceType)[keyof typeof DeviceType];
|
||||
|
||||
export const JobStatus = {
|
||||
QUEUED: "queued",
|
||||
DISPATCHED: "dispatched",
|
||||
RUNNING: "running",
|
||||
SUCCEEDED: "succeeded",
|
||||
FAILED: "failed",
|
||||
CANCELLED: "cancelled",
|
||||
EXPIRED: "expired",
|
||||
} as const;
|
||||
|
||||
export type JobStatus = (typeof JobStatus)[keyof typeof JobStatus];
|
||||
|
||||
export const JobType = {
|
||||
UPDATE_INVENTORY: "update_inventory",
|
||||
UPDATE_SYSTEM_INFO: "update_system_info",
|
||||
CHECK_SERVICE_STATUS: "check_service_status",
|
||||
START_SERVICE: "start_service",
|
||||
STOP_SERVICE: "stop_service",
|
||||
RESTART_SERVICE: "restart_service",
|
||||
INSTALL_PACKAGE: "install_package",
|
||||
UPDATE_PACKAGE: "update_package",
|
||||
REMOVE_PACKAGE: "remove_package",
|
||||
REBOOT_SYSTEM: "reboot_system",
|
||||
SHUTDOWN_SYSTEM: "shutdown_system",
|
||||
START_REMOTE_SESSION: "start_remote_session",
|
||||
STOP_REMOTE_SESSION: "stop_remote_session",
|
||||
INSTALL_FROM_FILE: "install_from_file",
|
||||
DOWNLOAD_AND_INSTALL: "download_and_install",
|
||||
INSTALL_REGISTRY_PACKAGE: "install_registry_package",
|
||||
} as const;
|
||||
|
||||
export type JobType = (typeof JobType)[keyof typeof JobType];
|
||||
|
||||
export const ComplianceStatus = {
|
||||
COMPLIANT: "compliant",
|
||||
NON_COMPLIANT: "non_compliant",
|
||||
UNKNOWN: "unknown",
|
||||
NOT_APPLICABLE: "not_applicable",
|
||||
} as const;
|
||||
|
||||
export type ComplianceStatus =
|
||||
(typeof ComplianceStatus)[keyof typeof ComplianceStatus];
|
||||
|
||||
export const AlertSeverity = {
|
||||
INFO: "info",
|
||||
WARNING: "warning",
|
||||
ERROR: "error",
|
||||
CRITICAL: "critical",
|
||||
} as const;
|
||||
|
||||
export type AlertSeverity = (typeof AlertSeverity)[keyof typeof AlertSeverity];
|
||||
|
||||
export const AlertType = {
|
||||
DEVICE_OFFLINE: "device_offline",
|
||||
DISK_CRITICAL: "disk_critical",
|
||||
AGENT_OUTDATED: "agent_outdated",
|
||||
JOB_FAILED: "job_failed",
|
||||
AUTH_FAILURES: "auth_failures",
|
||||
} as const;
|
||||
|
||||
export type AlertType = (typeof AlertType)[keyof typeof AlertType];
|
||||
|
||||
export const UpdateRequestStatus = {
|
||||
PENDING: "pending",
|
||||
APPROVED: "approved",
|
||||
REJECTED: "rejected",
|
||||
DEPLOYED: "deployed",
|
||||
CANCELLED: "cancelled",
|
||||
} as const;
|
||||
|
||||
export type UpdateRequestStatus = (typeof UpdateRequestStatus)[keyof typeof UpdateRequestStatus];
|
||||
|
||||
export const DeploymentStatus = {
|
||||
DRAFT: "draft",
|
||||
PENDING_APPROVAL: "pending_approval",
|
||||
APPROVED: "approved",
|
||||
RUNNING: "running",
|
||||
COMPLETED: "completed",
|
||||
PARTIALLY_COMPLETED: "partially_completed",
|
||||
FAILED: "failed",
|
||||
CANCELLED: "cancelled",
|
||||
} as const;
|
||||
|
||||
export type DeploymentStatus = (typeof DeploymentStatus)[keyof typeof DeploymentStatus];
|
||||
|
||||
export interface UpdateRequest {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
deviceId: string;
|
||||
deviceName?: string;
|
||||
packageName: string;
|
||||
packageManager: string;
|
||||
currentVersion: string | null;
|
||||
targetVersion: string;
|
||||
requestedByUserId: string;
|
||||
requestedByName?: string;
|
||||
status: UpdateRequestStatus;
|
||||
approvedByUserId: string | null;
|
||||
approvedAt: string | null;
|
||||
rejectionReason: string | null;
|
||||
deploymentId: string | null;
|
||||
notes: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface Deployment {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
jobType: string;
|
||||
parameters: Record<string, unknown>;
|
||||
status: DeploymentStatus;
|
||||
createdByUserId: string;
|
||||
createdByName?: string;
|
||||
approvedByUserId: string | null;
|
||||
approvedAt: string | null;
|
||||
scheduledAt: string | null;
|
||||
startedAt: string | null;
|
||||
completedAt: string | null;
|
||||
totalTargets: number;
|
||||
completedTargets: number;
|
||||
failedTargets: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface DeploymentTarget {
|
||||
id: string;
|
||||
deploymentId: string;
|
||||
deviceId: string;
|
||||
deviceName?: string;
|
||||
jobId: string | null;
|
||||
status: string;
|
||||
result: Record<string, unknown> | null;
|
||||
startedAt: string | null;
|
||||
completedAt: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface SoftwarePackage {
|
||||
name: string;
|
||||
version: string;
|
||||
manager: string;
|
||||
deviceCount: number;
|
||||
devices: Array<{ deviceId: string; deviceName: string }>;
|
||||
}
|
||||
|
||||
export interface Organization {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface User {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
email: string;
|
||||
passwordHash: string;
|
||||
displayName: string;
|
||||
role: Role;
|
||||
isActive: boolean;
|
||||
lastLoginAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface Device {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
deviceGroupId: string | null;
|
||||
name: string;
|
||||
deviceType: DeviceType;
|
||||
platform: string;
|
||||
osName: string;
|
||||
osVersion: string;
|
||||
architecture: string;
|
||||
kernelVersion: string | null;
|
||||
cpuModel: string | null;
|
||||
cpuCores: number | null;
|
||||
totalMemoryBytes: number | null;
|
||||
totalDiskBytes: number | null;
|
||||
ipAddress: string | null;
|
||||
agentVersion: string;
|
||||
status: DeviceStatus;
|
||||
lastHeartbeatAt: Date | null;
|
||||
enrolledAt: Date;
|
||||
isDisabled: boolean;
|
||||
isArchived: boolean;
|
||||
tags: string[];
|
||||
metadata: Record<string, unknown>;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface DeviceCredential {
|
||||
id: string;
|
||||
deviceId: string;
|
||||
credentialType: string;
|
||||
credentialHash: string;
|
||||
expiresAt: Date | null;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface EnrollmentToken {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
tokenHash: string;
|
||||
expiresAt: Date;
|
||||
maxUses: number | null;
|
||||
useCount: number;
|
||||
isRevoked: boolean;
|
||||
label: string | null;
|
||||
createdByUserId: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface DeviceGroup {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface InventorySnapshot {
|
||||
id: string;
|
||||
deviceId: string;
|
||||
reportedAt: Date;
|
||||
packages: PackageInfo[];
|
||||
services: ServiceInfo[];
|
||||
networkInterfaces: NetworkInterface[];
|
||||
platformData: Record<string, unknown>;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface PackageInfo {
|
||||
name: string;
|
||||
version: string;
|
||||
manager: string;
|
||||
}
|
||||
|
||||
export interface ServiceInfo {
|
||||
name: string;
|
||||
status: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface NetworkInterface {
|
||||
name: string;
|
||||
addresses: string[];
|
||||
macAddress: string | null;
|
||||
}
|
||||
|
||||
export interface MetricSnapshot {
|
||||
id: string;
|
||||
deviceId: string;
|
||||
reportedAt: Date;
|
||||
cpuUsagePercent: number | null;
|
||||
memoryUsagePercent: number | null;
|
||||
memoryUsedBytes: number | null;
|
||||
memoryTotalBytes: number | null;
|
||||
diskUsagePercent: number | null;
|
||||
diskUsedBytes: number | null;
|
||||
diskTotalBytes: number | null;
|
||||
loadAverage1m: number | null;
|
||||
loadAverage5m: number | null;
|
||||
loadAverage15m: number | null;
|
||||
uptimeSeconds: number | null;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface Policy {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
rules: PolicyRule[];
|
||||
isEnabled: boolean;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface PolicyRule {
|
||||
type: string;
|
||||
condition: string;
|
||||
value: string | number | boolean;
|
||||
}
|
||||
|
||||
export interface ComplianceResult {
|
||||
id: string;
|
||||
deviceId: string;
|
||||
policyId: string;
|
||||
status: ComplianceStatus;
|
||||
details: Record<string, unknown>;
|
||||
evaluatedAt: Date;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface Job {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
createdByUserId: string;
|
||||
jobType: JobType;
|
||||
status: JobStatus;
|
||||
parameters: Record<string, unknown>;
|
||||
dispatchedAt: Date | null;
|
||||
startedAt: Date | null;
|
||||
completedAt: Date | null;
|
||||
expiresAt: Date | null;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface JobTarget {
|
||||
id: string;
|
||||
jobId: string;
|
||||
deviceId: string;
|
||||
status: JobStatus;
|
||||
result: Record<string, unknown> | null;
|
||||
startedAt: Date | null;
|
||||
completedAt: Date | null;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface Alert {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
deviceId: string | null;
|
||||
alertType: AlertType;
|
||||
severity: AlertSeverity;
|
||||
title: string;
|
||||
message: string;
|
||||
isResolved: boolean;
|
||||
resolvedAt: Date | null;
|
||||
resolvedByUserId: string | null;
|
||||
metadata: Record<string, unknown>;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface AuditEvent {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
userId: string | null;
|
||||
action: string;
|
||||
targetType: string;
|
||||
targetId: string | null;
|
||||
deviceIds: string[];
|
||||
result: string;
|
||||
ipAddress: string | null;
|
||||
metadata: Record<string, unknown>;
|
||||
correlationId: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface ApiToken {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
userId: string;
|
||||
name: string;
|
||||
tokenHash: string;
|
||||
expiresAt: Date | null;
|
||||
lastUsedAt: Date | null;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export const HttpStatusCode = {
|
||||
OK: 200,
|
||||
CREATED: 201,
|
||||
NO_CONTENT: 204,
|
||||
BAD_REQUEST: 400,
|
||||
UNAUTHORIZED: 401,
|
||||
FORBIDDEN: 403,
|
||||
NOT_FOUND: 404,
|
||||
CONFLICT: 409,
|
||||
UNPROCESSABLE_ENTITY: 422,
|
||||
TOO_MANY_REQUESTS: 429,
|
||||
INTERNAL_SERVER_ERROR: 500,
|
||||
} as const;
|
||||
|
||||
export interface ApiResponse<T = unknown> {
|
||||
success: boolean;
|
||||
data?: T;
|
||||
error?: {
|
||||
code: string;
|
||||
message: string;
|
||||
details?: Record<string, unknown>;
|
||||
};
|
||||
meta?: {
|
||||
page: number;
|
||||
limit: number;
|
||||
total: number;
|
||||
totalPages: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface PaginatedRequest {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
sort?: string;
|
||||
order?: "asc" | "desc";
|
||||
search?: string;
|
||||
}
|
||||
|
||||
export interface AuthenticatedUser {
|
||||
userId: string;
|
||||
organizationId: string;
|
||||
role: Role;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface UploadedSoftwarePackage {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
version: string;
|
||||
packageType: string;
|
||||
platform: string;
|
||||
architecture: string;
|
||||
filename: string;
|
||||
fileSize: number;
|
||||
checksum: string | null;
|
||||
installCommand: string | null;
|
||||
tags: string[];
|
||||
metadata: Record<string, unknown>;
|
||||
uploadedByUserId: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in New Issue
Block a user