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