@openmdm/core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +105 -3
- package/dist/index.js +1553 -41
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +9 -0
- package/dist/schema.js +259 -0
- package/dist/schema.js.map +1 -1
- package/dist/types.d.ts +591 -1
- package/dist/types.js +21 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/audit.ts +317 -0
- package/src/authorization.ts +418 -0
- package/src/dashboard.ts +327 -0
- package/src/index.ts +222 -0
- package/src/plugin-storage.ts +128 -0
- package/src/queue.ts +161 -0
- package/src/schedule.ts +325 -0
- package/src/schema.ts +277 -0
- package/src/tenant.ts +237 -0
- package/src/types.ts +708 -0
package/dist/types.d.ts
CHANGED
|
@@ -439,6 +439,31 @@ interface MDMConfig {
|
|
|
439
439
|
onHeartbeat?: (device: Device, heartbeat: Heartbeat) => Promise<void>;
|
|
440
440
|
onCommand?: (command: Command) => Promise<void>;
|
|
441
441
|
onEvent?: (event: MDMEvent) => Promise<void>;
|
|
442
|
+
/** Multi-tenancy configuration */
|
|
443
|
+
multiTenancy?: {
|
|
444
|
+
enabled: boolean;
|
|
445
|
+
defaultTenantId?: string;
|
|
446
|
+
tenantResolver?: (context: unknown) => Promise<string | null>;
|
|
447
|
+
};
|
|
448
|
+
/** Authorization (RBAC) configuration */
|
|
449
|
+
authorization?: {
|
|
450
|
+
enabled: boolean;
|
|
451
|
+
defaultRole?: string;
|
|
452
|
+
};
|
|
453
|
+
/** Audit logging configuration */
|
|
454
|
+
audit?: {
|
|
455
|
+
enabled: boolean;
|
|
456
|
+
retentionDays?: number;
|
|
457
|
+
};
|
|
458
|
+
/** Scheduling configuration */
|
|
459
|
+
scheduling?: {
|
|
460
|
+
enabled: boolean;
|
|
461
|
+
timezone?: string;
|
|
462
|
+
};
|
|
463
|
+
/** Plugin storage configuration */
|
|
464
|
+
pluginStorage?: {
|
|
465
|
+
adapter: 'database' | 'memory';
|
|
466
|
+
};
|
|
442
467
|
}
|
|
443
468
|
interface StorageConfig {
|
|
444
469
|
/** Storage provider (s3, local, custom) */
|
|
@@ -574,6 +599,69 @@ interface DatabaseAdapter {
|
|
|
574
599
|
deviceId?: string;
|
|
575
600
|
packageName?: string;
|
|
576
601
|
}): Promise<AppRollback[]>;
|
|
602
|
+
getGroupChildren?(parentId: string | null): Promise<Group[]>;
|
|
603
|
+
getGroupAncestors?(groupId: string): Promise<Group[]>;
|
|
604
|
+
getGroupDescendants?(groupId: string): Promise<Group[]>;
|
|
605
|
+
getGroupTree?(rootId?: string): Promise<GroupTreeNode[]>;
|
|
606
|
+
getGroupEffectivePolicy?(groupId: string): Promise<Policy | null>;
|
|
607
|
+
moveGroup?(groupId: string, newParentId: string | null): Promise<Group>;
|
|
608
|
+
getGroupHierarchyStats?(): Promise<GroupHierarchyStats>;
|
|
609
|
+
findTenant?(id: string): Promise<Tenant | null>;
|
|
610
|
+
findTenantBySlug?(slug: string): Promise<Tenant | null>;
|
|
611
|
+
listTenants?(filter?: TenantFilter): Promise<TenantListResult>;
|
|
612
|
+
createTenant?(data: CreateTenantInput): Promise<Tenant>;
|
|
613
|
+
updateTenant?(id: string, data: UpdateTenantInput): Promise<Tenant>;
|
|
614
|
+
deleteTenant?(id: string): Promise<void>;
|
|
615
|
+
getTenantStats?(tenantId: string): Promise<TenantStats>;
|
|
616
|
+
findUser?(id: string): Promise<User | null>;
|
|
617
|
+
findUserByEmail?(email: string, tenantId?: string): Promise<User | null>;
|
|
618
|
+
listUsers?(filter?: UserFilter): Promise<UserListResult>;
|
|
619
|
+
createUser?(data: CreateUserInput): Promise<User>;
|
|
620
|
+
updateUser?(id: string, data: UpdateUserInput): Promise<User>;
|
|
621
|
+
deleteUser?(id: string): Promise<void>;
|
|
622
|
+
findRole?(id: string): Promise<Role | null>;
|
|
623
|
+
listRoles?(tenantId?: string): Promise<Role[]>;
|
|
624
|
+
createRole?(data: CreateRoleInput): Promise<Role>;
|
|
625
|
+
updateRole?(id: string, data: UpdateRoleInput): Promise<Role>;
|
|
626
|
+
deleteRole?(id: string): Promise<void>;
|
|
627
|
+
assignRoleToUser?(userId: string, roleId: string): Promise<void>;
|
|
628
|
+
removeRoleFromUser?(userId: string, roleId: string): Promise<void>;
|
|
629
|
+
getUserRoles?(userId: string): Promise<Role[]>;
|
|
630
|
+
createAuditLog?(data: CreateAuditLogInput): Promise<AuditLog>;
|
|
631
|
+
listAuditLogs?(filter?: AuditLogFilter): Promise<AuditLogListResult>;
|
|
632
|
+
deleteAuditLogs?(filter: {
|
|
633
|
+
olderThan?: Date;
|
|
634
|
+
tenantId?: string;
|
|
635
|
+
}): Promise<number>;
|
|
636
|
+
findScheduledTask?(id: string): Promise<ScheduledTask | null>;
|
|
637
|
+
listScheduledTasks?(filter?: ScheduledTaskFilter): Promise<ScheduledTaskListResult>;
|
|
638
|
+
createScheduledTask?(data: CreateScheduledTaskInput): Promise<ScheduledTask>;
|
|
639
|
+
updateScheduledTask?(id: string, data: UpdateScheduledTaskInput): Promise<ScheduledTask>;
|
|
640
|
+
deleteScheduledTask?(id: string): Promise<void>;
|
|
641
|
+
getUpcomingTasks?(hours: number): Promise<ScheduledTask[]>;
|
|
642
|
+
createTaskExecution?(data: {
|
|
643
|
+
taskId: string;
|
|
644
|
+
}): Promise<TaskExecution>;
|
|
645
|
+
updateTaskExecution?(id: string, data: Partial<TaskExecution>): Promise<TaskExecution>;
|
|
646
|
+
listTaskExecutions?(taskId: string, limit?: number): Promise<TaskExecution[]>;
|
|
647
|
+
enqueueMessage?(data: EnqueueMessageInput): Promise<QueuedMessage>;
|
|
648
|
+
dequeueMessages?(deviceId: string, limit?: number): Promise<QueuedMessage[]>;
|
|
649
|
+
peekMessages?(deviceId: string, limit?: number): Promise<QueuedMessage[]>;
|
|
650
|
+
acknowledgeMessage?(messageId: string): Promise<void>;
|
|
651
|
+
failMessage?(messageId: string, error: string): Promise<void>;
|
|
652
|
+
retryFailedMessages?(maxAttempts?: number): Promise<number>;
|
|
653
|
+
purgeExpiredMessages?(): Promise<number>;
|
|
654
|
+
getQueueStats?(tenantId?: string): Promise<QueueStats>;
|
|
655
|
+
getPluginValue?(pluginName: string, key: string): Promise<unknown | null>;
|
|
656
|
+
setPluginValue?(pluginName: string, key: string, value: unknown): Promise<void>;
|
|
657
|
+
deletePluginValue?(pluginName: string, key: string): Promise<void>;
|
|
658
|
+
listPluginKeys?(pluginName: string, prefix?: string): Promise<string[]>;
|
|
659
|
+
clearPluginData?(pluginName: string): Promise<void>;
|
|
660
|
+
getDashboardStats?(tenantId?: string): Promise<DashboardStats>;
|
|
661
|
+
getDeviceStatusBreakdown?(tenantId?: string): Promise<DeviceStatusBreakdown>;
|
|
662
|
+
getEnrollmentTrend?(days: number, tenantId?: string): Promise<EnrollmentTrendPoint[]>;
|
|
663
|
+
getCommandSuccessRates?(tenantId?: string): Promise<CommandSuccessRates>;
|
|
664
|
+
getAppInstallationSummary?(tenantId?: string): Promise<AppInstallationSummary>;
|
|
577
665
|
transaction?<T>(fn: () => Promise<T>): Promise<T>;
|
|
578
666
|
}
|
|
579
667
|
interface PushAdapter {
|
|
@@ -681,6 +769,20 @@ interface MDMInstance {
|
|
|
681
769
|
commands: CommandManager;
|
|
682
770
|
/** Group management */
|
|
683
771
|
groups: GroupManager;
|
|
772
|
+
/** Tenant management (if multi-tenancy enabled) */
|
|
773
|
+
tenants?: TenantManager;
|
|
774
|
+
/** Authorization management (RBAC) */
|
|
775
|
+
authorization?: AuthorizationManager;
|
|
776
|
+
/** Audit logging */
|
|
777
|
+
audit?: AuditManager;
|
|
778
|
+
/** Scheduled task management */
|
|
779
|
+
schedules?: ScheduleManager;
|
|
780
|
+
/** Persistent message queue */
|
|
781
|
+
messageQueue?: MessageQueueManager;
|
|
782
|
+
/** Dashboard analytics */
|
|
783
|
+
dashboard?: DashboardManager;
|
|
784
|
+
/** Plugin storage */
|
|
785
|
+
pluginStorage?: PluginStorageAdapter;
|
|
684
786
|
/** Push notification service */
|
|
685
787
|
push: PushAdapter;
|
|
686
788
|
/** Webhook delivery (if configured) */
|
|
@@ -767,6 +869,482 @@ interface GroupManager {
|
|
|
767
869
|
addDevice(groupId: string, deviceId: string): Promise<void>;
|
|
768
870
|
removeDevice(groupId: string, deviceId: string): Promise<void>;
|
|
769
871
|
getChildren(groupId: string): Promise<Group[]>;
|
|
872
|
+
getTree(rootId?: string): Promise<GroupTreeNode[]>;
|
|
873
|
+
getAncestors(groupId: string): Promise<Group[]>;
|
|
874
|
+
getDescendants(groupId: string): Promise<Group[]>;
|
|
875
|
+
move(groupId: string, newParentId: string | null): Promise<Group>;
|
|
876
|
+
getEffectivePolicy(groupId: string): Promise<Policy | null>;
|
|
877
|
+
getHierarchyStats(): Promise<GroupHierarchyStats>;
|
|
878
|
+
}
|
|
879
|
+
interface GroupTreeNode extends Group {
|
|
880
|
+
children: GroupTreeNode[];
|
|
881
|
+
depth: number;
|
|
882
|
+
path: string[];
|
|
883
|
+
effectivePolicyId?: string | null;
|
|
884
|
+
}
|
|
885
|
+
interface GroupHierarchyStats {
|
|
886
|
+
totalGroups: number;
|
|
887
|
+
maxDepth: number;
|
|
888
|
+
groupsWithDevices: number;
|
|
889
|
+
groupsWithPolicies: number;
|
|
890
|
+
}
|
|
891
|
+
type TenantStatus = 'active' | 'suspended' | 'pending';
|
|
892
|
+
interface Tenant {
|
|
893
|
+
id: string;
|
|
894
|
+
name: string;
|
|
895
|
+
slug: string;
|
|
896
|
+
status: TenantStatus;
|
|
897
|
+
settings?: TenantSettings | null;
|
|
898
|
+
metadata?: Record<string, unknown> | null;
|
|
899
|
+
createdAt: Date;
|
|
900
|
+
updatedAt: Date;
|
|
901
|
+
}
|
|
902
|
+
interface TenantSettings {
|
|
903
|
+
maxDevices?: number;
|
|
904
|
+
maxUsers?: number;
|
|
905
|
+
features?: string[];
|
|
906
|
+
branding?: {
|
|
907
|
+
logo?: string;
|
|
908
|
+
primaryColor?: string;
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
interface CreateTenantInput {
|
|
912
|
+
name: string;
|
|
913
|
+
slug: string;
|
|
914
|
+
settings?: TenantSettings;
|
|
915
|
+
metadata?: Record<string, unknown>;
|
|
916
|
+
}
|
|
917
|
+
interface UpdateTenantInput {
|
|
918
|
+
name?: string;
|
|
919
|
+
slug?: string;
|
|
920
|
+
status?: TenantStatus;
|
|
921
|
+
settings?: TenantSettings;
|
|
922
|
+
metadata?: Record<string, unknown>;
|
|
923
|
+
}
|
|
924
|
+
interface TenantFilter {
|
|
925
|
+
status?: TenantStatus;
|
|
926
|
+
search?: string;
|
|
927
|
+
limit?: number;
|
|
928
|
+
offset?: number;
|
|
929
|
+
}
|
|
930
|
+
interface TenantListResult {
|
|
931
|
+
tenants: Tenant[];
|
|
932
|
+
total: number;
|
|
933
|
+
limit: number;
|
|
934
|
+
offset: number;
|
|
935
|
+
}
|
|
936
|
+
interface TenantStats {
|
|
937
|
+
deviceCount: number;
|
|
938
|
+
userCount: number;
|
|
939
|
+
policyCount: number;
|
|
940
|
+
appCount: number;
|
|
941
|
+
}
|
|
942
|
+
type PermissionAction = 'create' | 'read' | 'update' | 'delete' | 'manage' | '*';
|
|
943
|
+
type PermissionResource = 'devices' | 'policies' | 'apps' | 'groups' | 'commands' | 'users' | 'roles' | 'tenants' | 'audit' | '*';
|
|
944
|
+
interface Permission {
|
|
945
|
+
action: PermissionAction;
|
|
946
|
+
resource: PermissionResource;
|
|
947
|
+
resourceId?: string;
|
|
948
|
+
}
|
|
949
|
+
interface Role {
|
|
950
|
+
id: string;
|
|
951
|
+
tenantId?: string | null;
|
|
952
|
+
name: string;
|
|
953
|
+
description?: string | null;
|
|
954
|
+
permissions: Permission[];
|
|
955
|
+
isSystem: boolean;
|
|
956
|
+
createdAt: Date;
|
|
957
|
+
updatedAt: Date;
|
|
958
|
+
}
|
|
959
|
+
interface CreateRoleInput {
|
|
960
|
+
tenantId?: string;
|
|
961
|
+
name: string;
|
|
962
|
+
description?: string;
|
|
963
|
+
permissions: Permission[];
|
|
964
|
+
}
|
|
965
|
+
interface UpdateRoleInput {
|
|
966
|
+
name?: string;
|
|
967
|
+
description?: string;
|
|
968
|
+
permissions?: Permission[];
|
|
969
|
+
}
|
|
970
|
+
interface User {
|
|
971
|
+
id: string;
|
|
972
|
+
tenantId?: string | null;
|
|
973
|
+
email: string;
|
|
974
|
+
name?: string | null;
|
|
975
|
+
status: 'active' | 'inactive' | 'pending';
|
|
976
|
+
metadata?: Record<string, unknown> | null;
|
|
977
|
+
lastLoginAt?: Date | null;
|
|
978
|
+
createdAt: Date;
|
|
979
|
+
updatedAt: Date;
|
|
980
|
+
}
|
|
981
|
+
interface UserWithRoles extends User {
|
|
982
|
+
roles: Role[];
|
|
983
|
+
}
|
|
984
|
+
interface CreateUserInput {
|
|
985
|
+
tenantId?: string;
|
|
986
|
+
email: string;
|
|
987
|
+
name?: string;
|
|
988
|
+
status?: 'active' | 'inactive' | 'pending';
|
|
989
|
+
metadata?: Record<string, unknown>;
|
|
990
|
+
}
|
|
991
|
+
interface UpdateUserInput {
|
|
992
|
+
email?: string;
|
|
993
|
+
name?: string;
|
|
994
|
+
status?: 'active' | 'inactive' | 'pending';
|
|
995
|
+
metadata?: Record<string, unknown>;
|
|
996
|
+
}
|
|
997
|
+
interface UserFilter {
|
|
998
|
+
tenantId?: string;
|
|
999
|
+
status?: 'active' | 'inactive' | 'pending';
|
|
1000
|
+
search?: string;
|
|
1001
|
+
limit?: number;
|
|
1002
|
+
offset?: number;
|
|
1003
|
+
}
|
|
1004
|
+
interface UserListResult {
|
|
1005
|
+
users: User[];
|
|
1006
|
+
total: number;
|
|
1007
|
+
limit: number;
|
|
1008
|
+
offset: number;
|
|
1009
|
+
}
|
|
1010
|
+
type AuditAction = 'create' | 'read' | 'update' | 'delete' | 'login' | 'logout' | 'enroll' | 'unenroll' | 'command' | 'export' | 'import' | 'custom';
|
|
1011
|
+
interface AuditLog {
|
|
1012
|
+
id: string;
|
|
1013
|
+
tenantId?: string | null;
|
|
1014
|
+
userId?: string | null;
|
|
1015
|
+
action: AuditAction;
|
|
1016
|
+
resource: string;
|
|
1017
|
+
resourceId?: string | null;
|
|
1018
|
+
status: 'success' | 'failure';
|
|
1019
|
+
error?: string | null;
|
|
1020
|
+
details?: Record<string, unknown> | null;
|
|
1021
|
+
ipAddress?: string | null;
|
|
1022
|
+
userAgent?: string | null;
|
|
1023
|
+
createdAt: Date;
|
|
1024
|
+
}
|
|
1025
|
+
interface CreateAuditLogInput {
|
|
1026
|
+
tenantId?: string;
|
|
1027
|
+
userId?: string;
|
|
1028
|
+
action: AuditAction;
|
|
1029
|
+
resource: string;
|
|
1030
|
+
resourceId?: string;
|
|
1031
|
+
status?: 'success' | 'failure';
|
|
1032
|
+
error?: string;
|
|
1033
|
+
details?: Record<string, unknown>;
|
|
1034
|
+
ipAddress?: string;
|
|
1035
|
+
userAgent?: string;
|
|
1036
|
+
}
|
|
1037
|
+
interface AuditConfig {
|
|
1038
|
+
enabled: boolean;
|
|
1039
|
+
retentionDays?: number;
|
|
1040
|
+
skipReadOperations?: boolean;
|
|
1041
|
+
logActions?: AuditAction[];
|
|
1042
|
+
logResources?: string[];
|
|
1043
|
+
}
|
|
1044
|
+
interface AuditSummary {
|
|
1045
|
+
totalLogs: number;
|
|
1046
|
+
byAction: Record<AuditAction, number>;
|
|
1047
|
+
byResource: Record<string, number>;
|
|
1048
|
+
byStatus: {
|
|
1049
|
+
success: number;
|
|
1050
|
+
failure: number;
|
|
1051
|
+
};
|
|
1052
|
+
topUsers: Array<{
|
|
1053
|
+
userId: string;
|
|
1054
|
+
count: number;
|
|
1055
|
+
}>;
|
|
1056
|
+
recentFailures: AuditLog[];
|
|
1057
|
+
}
|
|
1058
|
+
interface AuditLogFilter {
|
|
1059
|
+
tenantId?: string;
|
|
1060
|
+
userId?: string;
|
|
1061
|
+
action?: string;
|
|
1062
|
+
resource?: string;
|
|
1063
|
+
resourceId?: string;
|
|
1064
|
+
startDate?: Date;
|
|
1065
|
+
endDate?: Date;
|
|
1066
|
+
limit?: number;
|
|
1067
|
+
offset?: number;
|
|
1068
|
+
}
|
|
1069
|
+
interface AuditLogListResult {
|
|
1070
|
+
logs: AuditLog[];
|
|
1071
|
+
total: number;
|
|
1072
|
+
limit: number;
|
|
1073
|
+
offset: number;
|
|
1074
|
+
}
|
|
1075
|
+
type TaskType = 'command' | 'policy_update' | 'app_install' | 'maintenance' | 'custom';
|
|
1076
|
+
type ScheduledTaskStatus = 'active' | 'paused' | 'completed' | 'failed';
|
|
1077
|
+
interface MaintenanceWindow {
|
|
1078
|
+
daysOfWeek: number[];
|
|
1079
|
+
startTime: string;
|
|
1080
|
+
endTime: string;
|
|
1081
|
+
timezone: string;
|
|
1082
|
+
}
|
|
1083
|
+
interface TaskSchedule {
|
|
1084
|
+
type: 'once' | 'recurring' | 'window';
|
|
1085
|
+
executeAt?: Date;
|
|
1086
|
+
cron?: string;
|
|
1087
|
+
window?: MaintenanceWindow;
|
|
1088
|
+
}
|
|
1089
|
+
interface ScheduledTask {
|
|
1090
|
+
id: string;
|
|
1091
|
+
tenantId?: string | null;
|
|
1092
|
+
name: string;
|
|
1093
|
+
description?: string | null;
|
|
1094
|
+
taskType: TaskType;
|
|
1095
|
+
schedule: TaskSchedule;
|
|
1096
|
+
target?: DeployTarget;
|
|
1097
|
+
payload?: Record<string, unknown> | null;
|
|
1098
|
+
status: ScheduledTaskStatus;
|
|
1099
|
+
nextRunAt?: Date | null;
|
|
1100
|
+
lastRunAt?: Date | null;
|
|
1101
|
+
maxRetries: number;
|
|
1102
|
+
retryCount: number;
|
|
1103
|
+
createdAt: Date;
|
|
1104
|
+
updatedAt: Date;
|
|
1105
|
+
}
|
|
1106
|
+
interface CreateScheduledTaskInput {
|
|
1107
|
+
tenantId?: string;
|
|
1108
|
+
name: string;
|
|
1109
|
+
description?: string;
|
|
1110
|
+
taskType: TaskType;
|
|
1111
|
+
schedule: TaskSchedule;
|
|
1112
|
+
target?: DeployTarget;
|
|
1113
|
+
payload?: Record<string, unknown>;
|
|
1114
|
+
maxRetries?: number;
|
|
1115
|
+
}
|
|
1116
|
+
interface UpdateScheduledTaskInput {
|
|
1117
|
+
name?: string;
|
|
1118
|
+
description?: string;
|
|
1119
|
+
schedule?: TaskSchedule;
|
|
1120
|
+
target?: DeployTarget;
|
|
1121
|
+
payload?: Record<string, unknown>;
|
|
1122
|
+
status?: ScheduledTaskStatus;
|
|
1123
|
+
maxRetries?: number;
|
|
1124
|
+
}
|
|
1125
|
+
interface ScheduledTaskFilter {
|
|
1126
|
+
tenantId?: string;
|
|
1127
|
+
taskType?: TaskType | TaskType[];
|
|
1128
|
+
status?: ScheduledTaskStatus | ScheduledTaskStatus[];
|
|
1129
|
+
limit?: number;
|
|
1130
|
+
offset?: number;
|
|
1131
|
+
}
|
|
1132
|
+
interface ScheduledTaskListResult {
|
|
1133
|
+
tasks: ScheduledTask[];
|
|
1134
|
+
total: number;
|
|
1135
|
+
limit: number;
|
|
1136
|
+
offset: number;
|
|
1137
|
+
}
|
|
1138
|
+
interface TaskExecution {
|
|
1139
|
+
id: string;
|
|
1140
|
+
taskId: string;
|
|
1141
|
+
status: 'running' | 'completed' | 'failed';
|
|
1142
|
+
startedAt: Date;
|
|
1143
|
+
completedAt?: Date | null;
|
|
1144
|
+
devicesProcessed: number;
|
|
1145
|
+
devicesSucceeded: number;
|
|
1146
|
+
devicesFailed: number;
|
|
1147
|
+
error?: string | null;
|
|
1148
|
+
details?: Record<string, unknown> | null;
|
|
1149
|
+
}
|
|
1150
|
+
type QueueMessageStatus = 'pending' | 'processing' | 'delivered' | 'failed' | 'expired';
|
|
1151
|
+
interface QueuedMessage {
|
|
1152
|
+
id: string;
|
|
1153
|
+
tenantId?: string | null;
|
|
1154
|
+
deviceId: string;
|
|
1155
|
+
messageType: string;
|
|
1156
|
+
payload: Record<string, unknown>;
|
|
1157
|
+
priority: 'high' | 'normal' | 'low';
|
|
1158
|
+
status: QueueMessageStatus;
|
|
1159
|
+
attempts: number;
|
|
1160
|
+
maxAttempts: number;
|
|
1161
|
+
lastAttemptAt?: Date | null;
|
|
1162
|
+
lastError?: string | null;
|
|
1163
|
+
expiresAt?: Date | null;
|
|
1164
|
+
createdAt: Date;
|
|
1165
|
+
updatedAt: Date;
|
|
1166
|
+
}
|
|
1167
|
+
interface EnqueueMessageInput {
|
|
1168
|
+
tenantId?: string;
|
|
1169
|
+
deviceId: string;
|
|
1170
|
+
messageType: string;
|
|
1171
|
+
payload: Record<string, unknown>;
|
|
1172
|
+
priority?: 'high' | 'normal' | 'low';
|
|
1173
|
+
maxAttempts?: number;
|
|
1174
|
+
ttlSeconds?: number;
|
|
1175
|
+
}
|
|
1176
|
+
interface QueueStats {
|
|
1177
|
+
pending: number;
|
|
1178
|
+
processing: number;
|
|
1179
|
+
delivered: number;
|
|
1180
|
+
failed: number;
|
|
1181
|
+
expired: number;
|
|
1182
|
+
byDevice: Record<string, number>;
|
|
1183
|
+
oldestPending?: Date;
|
|
1184
|
+
}
|
|
1185
|
+
interface DashboardStats {
|
|
1186
|
+
devices: {
|
|
1187
|
+
total: number;
|
|
1188
|
+
enrolled: number;
|
|
1189
|
+
active: number;
|
|
1190
|
+
blocked: number;
|
|
1191
|
+
pending: number;
|
|
1192
|
+
};
|
|
1193
|
+
policies: {
|
|
1194
|
+
total: number;
|
|
1195
|
+
deployed: number;
|
|
1196
|
+
};
|
|
1197
|
+
applications: {
|
|
1198
|
+
total: number;
|
|
1199
|
+
deployed: number;
|
|
1200
|
+
};
|
|
1201
|
+
commands: {
|
|
1202
|
+
pendingCount: number;
|
|
1203
|
+
last24hTotal: number;
|
|
1204
|
+
last24hSuccess: number;
|
|
1205
|
+
last24hFailed: number;
|
|
1206
|
+
};
|
|
1207
|
+
groups: {
|
|
1208
|
+
total: number;
|
|
1209
|
+
withDevices: number;
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
interface DeviceStatusBreakdown {
|
|
1213
|
+
byStatus: Record<DeviceStatus, number>;
|
|
1214
|
+
byOs: Record<string, number>;
|
|
1215
|
+
byManufacturer: Record<string, number>;
|
|
1216
|
+
byModel: Record<string, number>;
|
|
1217
|
+
}
|
|
1218
|
+
interface EnrollmentTrendPoint {
|
|
1219
|
+
date: Date;
|
|
1220
|
+
enrolled: number;
|
|
1221
|
+
unenrolled: number;
|
|
1222
|
+
netChange: number;
|
|
1223
|
+
totalDevices: number;
|
|
1224
|
+
}
|
|
1225
|
+
interface CommandSuccessRates {
|
|
1226
|
+
overall: {
|
|
1227
|
+
total: number;
|
|
1228
|
+
completed: number;
|
|
1229
|
+
failed: number;
|
|
1230
|
+
successRate: number;
|
|
1231
|
+
};
|
|
1232
|
+
byType: Record<string, {
|
|
1233
|
+
total: number;
|
|
1234
|
+
completed: number;
|
|
1235
|
+
failed: number;
|
|
1236
|
+
successRate: number;
|
|
1237
|
+
avgExecutionTimeMs?: number;
|
|
1238
|
+
}>;
|
|
1239
|
+
last24h: {
|
|
1240
|
+
total: number;
|
|
1241
|
+
completed: number;
|
|
1242
|
+
failed: number;
|
|
1243
|
+
pending: number;
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
interface AppInstallationSummary {
|
|
1247
|
+
total: number;
|
|
1248
|
+
byStatus: Record<string, number>;
|
|
1249
|
+
recentFailures: Array<{
|
|
1250
|
+
packageName: string;
|
|
1251
|
+
deviceId: string;
|
|
1252
|
+
error: string;
|
|
1253
|
+
timestamp: Date;
|
|
1254
|
+
}>;
|
|
1255
|
+
topInstalled: Array<{
|
|
1256
|
+
packageName: string;
|
|
1257
|
+
name: string;
|
|
1258
|
+
installedCount: number;
|
|
1259
|
+
}>;
|
|
1260
|
+
}
|
|
1261
|
+
interface PluginStorageAdapter {
|
|
1262
|
+
get<T>(pluginName: string, key: string): Promise<T | null>;
|
|
1263
|
+
set<T>(pluginName: string, key: string, value: T): Promise<void>;
|
|
1264
|
+
delete(pluginName: string, key: string): Promise<void>;
|
|
1265
|
+
list(pluginName: string, prefix?: string): Promise<string[]>;
|
|
1266
|
+
clear(pluginName: string): Promise<void>;
|
|
1267
|
+
}
|
|
1268
|
+
interface PluginStorageEntry {
|
|
1269
|
+
pluginName: string;
|
|
1270
|
+
key: string;
|
|
1271
|
+
value: unknown;
|
|
1272
|
+
createdAt: Date;
|
|
1273
|
+
updatedAt: Date;
|
|
1274
|
+
}
|
|
1275
|
+
interface TenantManager {
|
|
1276
|
+
get(id: string): Promise<Tenant | null>;
|
|
1277
|
+
getBySlug(slug: string): Promise<Tenant | null>;
|
|
1278
|
+
list(filter?: TenantFilter): Promise<TenantListResult>;
|
|
1279
|
+
create(data: CreateTenantInput): Promise<Tenant>;
|
|
1280
|
+
update(id: string, data: UpdateTenantInput): Promise<Tenant>;
|
|
1281
|
+
delete(id: string, cascade?: boolean): Promise<void>;
|
|
1282
|
+
getStats(tenantId: string): Promise<TenantStats>;
|
|
1283
|
+
activate(id: string): Promise<Tenant>;
|
|
1284
|
+
deactivate(id: string): Promise<Tenant>;
|
|
1285
|
+
}
|
|
1286
|
+
interface AuthorizationManager {
|
|
1287
|
+
createRole(data: CreateRoleInput): Promise<Role>;
|
|
1288
|
+
getRole(id: string): Promise<Role | null>;
|
|
1289
|
+
listRoles(tenantId?: string): Promise<Role[]>;
|
|
1290
|
+
updateRole(id: string, data: UpdateRoleInput): Promise<Role>;
|
|
1291
|
+
deleteRole(id: string): Promise<void>;
|
|
1292
|
+
createUser(data: CreateUserInput): Promise<User>;
|
|
1293
|
+
getUser(id: string): Promise<UserWithRoles | null>;
|
|
1294
|
+
getUserByEmail(email: string, tenantId?: string): Promise<UserWithRoles | null>;
|
|
1295
|
+
listUsers(filter?: UserFilter): Promise<UserListResult>;
|
|
1296
|
+
updateUser(id: string, data: UpdateUserInput): Promise<User>;
|
|
1297
|
+
deleteUser(id: string): Promise<void>;
|
|
1298
|
+
assignRole(userId: string, roleId: string): Promise<void>;
|
|
1299
|
+
removeRole(userId: string, roleId: string): Promise<void>;
|
|
1300
|
+
getUserRoles(userId: string): Promise<Role[]>;
|
|
1301
|
+
can(userId: string, action: PermissionAction, resource: PermissionResource, resourceId?: string): Promise<boolean>;
|
|
1302
|
+
canAny(userId: string, permissions: Array<{
|
|
1303
|
+
action: PermissionAction;
|
|
1304
|
+
resource: PermissionResource;
|
|
1305
|
+
}>): Promise<boolean>;
|
|
1306
|
+
requirePermission(userId: string, action: PermissionAction, resource: PermissionResource, resourceId?: string): Promise<void>;
|
|
1307
|
+
isAdmin(userId: string): Promise<boolean>;
|
|
1308
|
+
}
|
|
1309
|
+
interface AuditManager {
|
|
1310
|
+
log(entry: CreateAuditLogInput): Promise<AuditLog>;
|
|
1311
|
+
list(filter?: AuditLogFilter): Promise<AuditLogListResult>;
|
|
1312
|
+
getByResource(resource: string, resourceId: string): Promise<AuditLog[]>;
|
|
1313
|
+
getByUser(userId: string, filter?: AuditLogFilter): Promise<AuditLogListResult>;
|
|
1314
|
+
export(filter: AuditLogFilter, format: 'json' | 'csv'): Promise<string>;
|
|
1315
|
+
purge(olderThanDays?: number): Promise<number>;
|
|
1316
|
+
getSummary(tenantId?: string, days?: number): Promise<AuditSummary>;
|
|
1317
|
+
}
|
|
1318
|
+
interface ScheduleManager {
|
|
1319
|
+
get(id: string): Promise<ScheduledTask | null>;
|
|
1320
|
+
list(filter?: ScheduledTaskFilter): Promise<ScheduledTaskListResult>;
|
|
1321
|
+
create(data: CreateScheduledTaskInput): Promise<ScheduledTask>;
|
|
1322
|
+
update(id: string, data: UpdateScheduledTaskInput): Promise<ScheduledTask>;
|
|
1323
|
+
delete(id: string): Promise<void>;
|
|
1324
|
+
pause(id: string): Promise<ScheduledTask>;
|
|
1325
|
+
resume(id: string): Promise<ScheduledTask>;
|
|
1326
|
+
runNow(id: string): Promise<TaskExecution>;
|
|
1327
|
+
getUpcoming(hours: number): Promise<ScheduledTask[]>;
|
|
1328
|
+
getExecutions(taskId: string, limit?: number): Promise<TaskExecution[]>;
|
|
1329
|
+
calculateNextRun(schedule: TaskSchedule): Date | null;
|
|
1330
|
+
}
|
|
1331
|
+
interface MessageQueueManager {
|
|
1332
|
+
enqueue(message: EnqueueMessageInput): Promise<QueuedMessage>;
|
|
1333
|
+
enqueueBatch(messages: EnqueueMessageInput[]): Promise<QueuedMessage[]>;
|
|
1334
|
+
dequeue(deviceId: string, limit?: number): Promise<QueuedMessage[]>;
|
|
1335
|
+
acknowledge(messageId: string): Promise<void>;
|
|
1336
|
+
fail(messageId: string, error: string): Promise<void>;
|
|
1337
|
+
retryFailed(maxAttempts?: number): Promise<number>;
|
|
1338
|
+
purgeExpired(): Promise<number>;
|
|
1339
|
+
getStats(tenantId?: string): Promise<QueueStats>;
|
|
1340
|
+
peek(deviceId: string, limit?: number): Promise<QueuedMessage[]>;
|
|
1341
|
+
}
|
|
1342
|
+
interface DashboardManager {
|
|
1343
|
+
getStats(tenantId?: string): Promise<DashboardStats>;
|
|
1344
|
+
getDeviceStatusBreakdown(tenantId?: string): Promise<DeviceStatusBreakdown>;
|
|
1345
|
+
getEnrollmentTrend(days: number, tenantId?: string): Promise<EnrollmentTrendPoint[]>;
|
|
1346
|
+
getCommandSuccessRates(tenantId?: string): Promise<CommandSuccessRates>;
|
|
1347
|
+
getAppInstallationSummary(tenantId?: string): Promise<AppInstallationSummary>;
|
|
770
1348
|
}
|
|
771
1349
|
type EventHandler<T extends EventType> = (event: MDMEvent<EventPayloadMap[T]>) => Promise<void> | void;
|
|
772
1350
|
interface EventPayloadMap {
|
|
@@ -883,6 +1461,18 @@ declare class PolicyNotFoundError extends MDMError {
|
|
|
883
1461
|
declare class ApplicationNotFoundError extends MDMError {
|
|
884
1462
|
constructor(identifier: string);
|
|
885
1463
|
}
|
|
1464
|
+
declare class TenantNotFoundError extends MDMError {
|
|
1465
|
+
constructor(identifier: string);
|
|
1466
|
+
}
|
|
1467
|
+
declare class RoleNotFoundError extends MDMError {
|
|
1468
|
+
constructor(identifier: string);
|
|
1469
|
+
}
|
|
1470
|
+
declare class GroupNotFoundError extends MDMError {
|
|
1471
|
+
constructor(identifier: string);
|
|
1472
|
+
}
|
|
1473
|
+
declare class UserNotFoundError extends MDMError {
|
|
1474
|
+
constructor(identifier: string);
|
|
1475
|
+
}
|
|
886
1476
|
declare class EnrollmentError extends MDMError {
|
|
887
1477
|
constructor(message: string, details?: unknown);
|
|
888
1478
|
}
|
|
@@ -896,4 +1486,4 @@ declare class ValidationError extends MDMError {
|
|
|
896
1486
|
constructor(message: string, details?: unknown);
|
|
897
1487
|
}
|
|
898
1488
|
|
|
899
|
-
export { type AppRollback, type AppVersion, type Application, type ApplicationManager, ApplicationNotFoundError, type AuthConfig, AuthenticationError, AuthorizationError, type Command, type CommandFilter, type CommandManager, type CommandResult, type CommandStatus, type CommandType, type CreateAppRollbackInput, type CreateApplicationInput, type CreateDeviceInput, type CreateGroupInput, type CreatePolicyInput, type DatabaseAdapter, type DeployTarget, type Device, type DeviceFilter, type DeviceListResult, type DeviceLocation, type DeviceManager, DeviceNotFoundError, type DeviceStatus, type EnrollmentConfig, EnrollmentError, type EnrollmentMethod, type EnrollmentRequest, type EnrollmentResponse, type EventFilter, type EventHandler, type EventPayloadMap, type EventType, type Group, type GroupManager, type HardwareControl, type Heartbeat, type InstalledApp, type MDMConfig, MDMError, type MDMEvent, type MDMInstance, type MDMPlugin, type PasswordPolicy, type PluginMiddleware, type PluginRoute, type Policy, type PolicyApplication, type PolicyManager, PolicyNotFoundError, type PolicySettings, type PushAdapter, type PushBatchResult, type PushConfig, type PushMessage, type PushProviderConfig, type PushResult, type PushToken, type RegisterPushTokenInput, type SendCommandInput, type StorageConfig, type SystemUpdatePolicy, type TimeWindow, type UpdateApplicationInput, type UpdateDeviceInput, type UpdateGroupInput, type UpdatePolicyInput, ValidationError, type VpnConfig, type WebhookConfig, type WebhookDeliveryResult, type WebhookEndpoint, type WebhookManager, type WifiConfig };
|
|
1489
|
+
export { type AppInstallationSummary, type AppRollback, type AppVersion, type Application, type ApplicationManager, ApplicationNotFoundError, type AuditAction, type AuditConfig, type AuditLog, type AuditLogFilter, type AuditLogListResult, type AuditManager, type AuditSummary, type AuthConfig, AuthenticationError, AuthorizationError, type AuthorizationManager, type Command, type CommandFilter, type CommandManager, type CommandResult, type CommandStatus, type CommandSuccessRates, type CommandType, type CreateAppRollbackInput, type CreateApplicationInput, type CreateAuditLogInput, type CreateDeviceInput, type CreateGroupInput, type CreatePolicyInput, type CreateRoleInput, type CreateScheduledTaskInput, type CreateTenantInput, type CreateUserInput, type DashboardManager, type DashboardStats, type DatabaseAdapter, type DeployTarget, type Device, type DeviceFilter, type DeviceListResult, type DeviceLocation, type DeviceManager, DeviceNotFoundError, type DeviceStatus, type DeviceStatusBreakdown, type EnqueueMessageInput, type EnrollmentConfig, EnrollmentError, type EnrollmentMethod, type EnrollmentRequest, type EnrollmentResponse, type EnrollmentTrendPoint, type EventFilter, type EventHandler, type EventPayloadMap, type EventType, type Group, type GroupHierarchyStats, type GroupManager, GroupNotFoundError, type GroupTreeNode, type HardwareControl, type Heartbeat, type InstalledApp, type MDMConfig, MDMError, type MDMEvent, type MDMInstance, type MDMPlugin, type MaintenanceWindow, type MessageQueueManager, type PasswordPolicy, type Permission, type PermissionAction, type PermissionResource, type PluginMiddleware, type PluginRoute, type PluginStorageAdapter, type PluginStorageEntry, type Policy, type PolicyApplication, type PolicyManager, PolicyNotFoundError, type PolicySettings, type PushAdapter, type PushBatchResult, type PushConfig, type PushMessage, type PushProviderConfig, type PushResult, type PushToken, type QueueMessageStatus, type QueueStats, type QueuedMessage, type RegisterPushTokenInput, type Role, RoleNotFoundError, type ScheduleManager, type ScheduledTask, type ScheduledTaskFilter, type ScheduledTaskListResult, type ScheduledTaskStatus, type SendCommandInput, type StorageConfig, type SystemUpdatePolicy, type TaskExecution, type TaskSchedule, type TaskType, type Tenant, type TenantFilter, type TenantListResult, type TenantManager, TenantNotFoundError, type TenantSettings, type TenantStats, type TenantStatus, type TimeWindow, type UpdateApplicationInput, type UpdateDeviceInput, type UpdateGroupInput, type UpdatePolicyInput, type UpdateRoleInput, type UpdateScheduledTaskInput, type UpdateTenantInput, type UpdateUserInput, type User, type UserFilter, type UserListResult, UserNotFoundError, type UserWithRoles, ValidationError, type VpnConfig, type WebhookConfig, type WebhookDeliveryResult, type WebhookEndpoint, type WebhookManager, type WifiConfig };
|
package/dist/types.js
CHANGED
|
@@ -23,6 +23,26 @@ var ApplicationNotFoundError = class extends MDMError {
|
|
|
23
23
|
super(`Application not found: ${identifier}`, "APPLICATION_NOT_FOUND", 404);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
+
var TenantNotFoundError = class extends MDMError {
|
|
27
|
+
constructor(identifier) {
|
|
28
|
+
super(`Tenant not found: ${identifier}`, "TENANT_NOT_FOUND", 404);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var RoleNotFoundError = class extends MDMError {
|
|
32
|
+
constructor(identifier) {
|
|
33
|
+
super(`Role not found: ${identifier}`, "ROLE_NOT_FOUND", 404);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var GroupNotFoundError = class extends MDMError {
|
|
37
|
+
constructor(identifier) {
|
|
38
|
+
super(`Group not found: ${identifier}`, "GROUP_NOT_FOUND", 404);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var UserNotFoundError = class extends MDMError {
|
|
42
|
+
constructor(identifier) {
|
|
43
|
+
super(`User not found: ${identifier}`, "USER_NOT_FOUND", 404);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
26
46
|
var EnrollmentError = class extends MDMError {
|
|
27
47
|
constructor(message, details) {
|
|
28
48
|
super(message, "ENROLLMENT_ERROR", 400, details);
|
|
@@ -44,6 +64,6 @@ var ValidationError = class extends MDMError {
|
|
|
44
64
|
}
|
|
45
65
|
};
|
|
46
66
|
|
|
47
|
-
export { ApplicationNotFoundError, AuthenticationError, AuthorizationError, DeviceNotFoundError, EnrollmentError, MDMError, PolicyNotFoundError, ValidationError };
|
|
67
|
+
export { ApplicationNotFoundError, AuthenticationError, AuthorizationError, DeviceNotFoundError, EnrollmentError, GroupNotFoundError, MDMError, PolicyNotFoundError, RoleNotFoundError, TenantNotFoundError, UserNotFoundError, ValidationError };
|
|
48
68
|
//# sourceMappingURL=types.js.map
|
|
49
69
|
//# sourceMappingURL=types.js.map
|