@vates/types 1.23.0 → 1.25.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.mts CHANGED
@@ -3,4 +3,5 @@ export * from './xen-api.mjs';
3
3
  export * from './xo.mjs';
4
4
  export * from './xo-app.mjs';
5
5
  export * from './lib/xen-orchestra-xapi.mjs';
6
+ export * from './lib/xen-orchestra-acl.mjs';
6
7
  export * from './lib/complex-matcher.mjs';
package/dist/index.mjs CHANGED
@@ -3,4 +3,5 @@ export * from './xen-api.mjs';
3
3
  export * from './xo.mjs';
4
4
  export * from './xo-app.mjs';
5
5
  export * from './lib/xen-orchestra-xapi.mjs';
6
+ export * from './lib/xen-orchestra-acl.mjs';
6
7
  export * from './lib/complex-matcher.mjs';
@@ -0,0 +1,54 @@
1
+ import { Branded } from '../common.mjs';
2
+ import type { XoGroup, XoUser } from '../xo.mjs';
3
+ export type XoAclRole = {
4
+ id: Branded<'acl-v2-role'>;
5
+ name: string;
6
+ description?: string;
7
+ } | {
8
+ id: Branded<'acl-v2-role'>;
9
+ name: string;
10
+ description?: string;
11
+ isTemplate: true;
12
+ roleTemplateId: number;
13
+ };
14
+ export type XoAclSupportedActionsByResource = {
15
+ [resource: string]: Record<string, unknown>;
16
+ };
17
+ /**
18
+ * E.g
19
+ * vms {
20
+ * shutdown: {
21
+ * clean: true,
22
+ * hard: true,
23
+ * }
24
+ * }
25
+ *
26
+ * `shutdown | shutdown:clean | shutdown:hard`
27
+ */
28
+ export type GetKeysRecursively<T, Prefix extends string = ''> = {
29
+ [K in keyof T]: T[K] extends object ? K extends string ? `${Prefix}${K}` | GetKeysRecursively<T[K], `${Prefix}${K}:`> : never : K extends string ? `${Prefix}${K}` : never;
30
+ }[keyof T];
31
+ export type XoAclSupportedResource<TActionsByResource extends XoAclSupportedActionsByResource> = keyof TActionsByResource;
32
+ export type XoAclSupportedActions<TActionsByResource extends XoAclSupportedActionsByResource, TResource extends XoAclSupportedResource<TActionsByResource>> = (GetKeysRecursively<TActionsByResource[TResource]> & string) | '*';
33
+ export type XoAclBasePrivilege = {
34
+ id: Branded<'acl-v2-privilege'>;
35
+ resource: string;
36
+ action: string;
37
+ selector?: string;
38
+ effect: 'allow' | 'deny';
39
+ roleId: XoAclRole['id'];
40
+ };
41
+ export type XoAclPrivilege<TActionsByResource extends XoAclSupportedActionsByResource, TResource extends XoAclSupportedResource<TActionsByResource>> = XoAclBasePrivilege & {
42
+ resource: TResource;
43
+ action: XoAclSupportedActions<TActionsByResource, TResource>;
44
+ };
45
+ export type XoUserRole = {
46
+ id: string;
47
+ roleId: XoAclRole['id'];
48
+ userId: XoUser['id'];
49
+ };
50
+ export type XoGroupRole = {
51
+ id: string;
52
+ roleId: XoAclRole['id'];
53
+ groupId: XoGroup['id'];
54
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { WrappedXenApiRecord, XenApiHost, XenApiHostWrapped, XenApiNetwork, XenApiNetworkWrapped, XenApiRecord, XenApiSr, XenApiTask, XenApiVbd, XenApiVdi, XenApiVif, XenApiVm, XenApiVmWrapped, XenApiVtpm } from '../xen-api.mjs';
2
2
  import type { BOND_MODE, OPAQUE_REF_NULL, SUPPORTED_VDI_FORMAT, VBD_MODE, VBD_TYPE, VDI_TYPE, VIF_LOCKING_MODE } from '../common.mjs';
3
3
  import type { PassThrough, Readable } from 'node:stream';
4
- import type { XoGpuGroup, XoHost, XoNetwork, XoPif, XoSr, XoUser, XoVdi, XoVgpuType, XoVm, XoVmTemplate, XoVif } from '../xo.mjs';
4
+ import type { XapiXoRecord, XoGpuGroup, XoHost, XoNetwork, XoPif, XoSr, XoUser, XoVdi, XoVgpuType, XoVm, XoVmTemplate, XoVif, XoVmSnapshot } from '../xo.mjs';
5
5
  export type XcpPatches = {
6
6
  changelog?: {
7
7
  author: string;
@@ -36,8 +36,11 @@ export interface Xapi {
36
36
  barrier<T extends XenApiRecord>(ref: T['$ref']): Promise<Extract<WrappedXenApiRecord, {
37
37
  $ref: T['$ref'];
38
38
  }>>;
39
- getField<T extends XenApiRecord, K extends keyof T>(type: Extract<WrappedXenApiRecord, T>['$type'], ref: T['$ref'], field: K): Promise<T[K]>;
40
39
  connectVif(vifId: XoVif['id']): Promise<void>;
40
+ getField<T extends XenApiRecord, K extends keyof T>(type: Extract<WrappedXenApiRecord, T>['$type'], ref: T['$ref'], field: K): Promise<T[K]>;
41
+ getObject: <XoRecord extends XapiXoRecord, WrappedRecord extends WrappedXenApiRecord = Extract<WrappedXenApiRecord, {
42
+ $type: XoRecord['type'];
43
+ }>>(idOrUuidOrRef: XoRecord['id'] | WrappedRecord['$ref'] | WrappedRecord['uuid'], defaultValue?: WrappedRecord) => WrappedRecord;
41
44
  createNetwork(params: {
42
45
  name: string;
43
46
  description?: string;
@@ -71,6 +74,7 @@ export interface Xapi {
71
74
  listMissingPatches(host: XoHost['id']): Promise<XcpPatches[] | XsPatches[]>;
72
75
  pool_emergencyShutdown(): Promise<void>;
73
76
  resumeVm(id: XoVm['id']): Promise<void>;
77
+ revertVm(snapshotId: XoVmSnapshot['id']): Promise<void>;
74
78
  unpauseVm(id: XoVm['id']): Promise<void>;
75
79
  cloneVm(vmId: XoVm['id'], opts?: {
76
80
  nameLabel?: string;
@@ -258,4 +262,13 @@ export interface Xapi {
258
262
  is_unique?: boolean;
259
263
  contents?: string;
260
264
  }): Promise<XenApiVtpm['$ref']>;
265
+ destroySr(id: XoSr['id']): Promise<void>;
266
+ xostor_delete(ref: XenApiSr['$ref']): Promise<void>;
267
+ objects: {
268
+ indexes: {
269
+ type: {
270
+ [XenApiRecord in WrappedXenApiRecord as XenApiRecord['$type']]: Record<XenApiRecord['uuid'], XenApiRecord>;
271
+ };
272
+ };
273
+ };
261
274
  }
@@ -404,7 +404,9 @@ export interface XenApiDrTask {
404
404
  introduced_SRs: XenApiSr['$ref'][];
405
405
  uuid: string;
406
406
  }
407
- type XenApiHostCallMethods = TagCallMethods & {};
407
+ type XenApiHostCallMethods = TagCallMethods & {
408
+ <T>(method: 'call_plugin', plugin: string, fn: string, args: Record<string, string>): Promise<T>;
409
+ };
408
410
  export interface XenApiHost {
409
411
  $ref: Branded<'host'>;
410
412
  address: string;
package/dist/xo-app.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'node:stream';
2
2
  import type { AnyXoBackupJob, AnyXoJob, AnyXoLog, XapiXoRecord, XoAuthenticationToken, XoBackupRepository, XoConfigBackupArchive, XoGroup, XoHost, XoPool, XoPoolBackupArchive, XoProxy, XoSchedule, XoServer, XoTask, XoUser, XoVm, XoVmBackupArchive } from './xo.mjs';
3
3
  import { VatesTask } from './lib/vates-task.mjs';
4
- import { Xapi, XapiHostStats, XapiPoolStats, XapiStatsGranularity, XapiVmStats, XenApiGpuGroupWrapped, XenApiHostWrapped, XenApiMessageWrapped, XenApiNetworkWrapped, XenApiPbdWrapped, XenApiPciWrapped, XenApiPgpuWrapped, XenApiPifWrapped, XenApiPoolWrapped, XenApiSmWrapped, XenApiSrWrapped, XenApiVbdWrapped, XenApiVdiWrapped, XenApiVgpuTypeWrapped, XenApiVgpuWrapped, XenApiVifWrapped, XenApiVmWrapped, XenApiVtpmWrapped } from './index.mjs';
4
+ import { Xapi, XapiHostStats, XapiPoolStats, XapiStatsGranularity, XapiVmStats, XenApiGpuGroupWrapped, XenApiHostWrapped, XenApiMessageWrapped, XenApiNetworkWrapped, XenApiPbdWrapped, XenApiPciWrapped, XenApiPgpuWrapped, XenApiPifWrapped, XenApiPoolWrapped, XenApiSmWrapped, XenApiSrWrapped, XenApiVbdWrapped, XenApiVdiWrapped, XenApiVgpuTypeWrapped, XenApiVgpuWrapped, XenApiVifWrapped, XenApiVmWrapped, XenApiVtpmWrapped, XoAclBasePrivilege, XoAclRole, XoGroupRole, XoUserRole } from './index.mjs';
5
5
  export type XapiConnection = Xapi & {
6
6
  status: string;
7
7
  pool?: {
@@ -39,7 +39,41 @@ type XapiRecordByXapiXoRecord = {
39
39
  'VM-template': XenApiVmWrapped;
40
40
  VTPM: XenApiVtpmWrapped;
41
41
  };
42
+ type LicenseProductId = 'premium' | 'xcpng-enterprise' | 'xcpng-standard' | 'xo-proxy' | 'xosan.trial' | 'xostor' | 'xostor.trial';
43
+ type LicenseProductType = 'xo' | 'xoproxy' | 'xcpng' | 'xosan' | 'xostor';
44
+ type License = {
45
+ id: string;
46
+ type: 'license';
47
+ created: number;
48
+ licenseType: 'unit';
49
+ productId: LicenseProductId;
50
+ tags: string[];
51
+ expires?: number;
52
+ boundObjectId?: string;
53
+ bindDate?: number;
54
+ buyer?: {
55
+ token: string;
56
+ email: string;
57
+ };
58
+ history?: {
59
+ date: number;
60
+ boundObjectId: string;
61
+ }[];
62
+ rebound?: number;
63
+ productTypes?: LicenseProductType[];
64
+ bundleInfo?: {
65
+ name: string;
66
+ id: string;
67
+ };
68
+ };
42
69
  export type XoApp = {
70
+ hooks: EventEmitter;
71
+ _redis: {
72
+ get(key: string): Promise<string | null>;
73
+ mSet(args: string[]): Promise<unknown>;
74
+ sMembers(key: string): Promise<string[]>;
75
+ sIsMember(key: string, member: string): Promise<boolean>;
76
+ };
43
77
  config: {
44
78
  get<T = string>(path: string): T;
45
79
  getOptional(path: string): Record<string, string> | undefined;
@@ -90,7 +124,13 @@ export type XoApp = {
90
124
  user?: XoUser;
91
125
  permission?: XoUser['permission'] | 'none' | null;
92
126
  };
127
+ addAclV2GroupRole(groupId: XoGroup['id'], roleId: XoAclRole['id']): Promise<XoGroupRole>;
128
+ addAclV2UserRole(userId: XoUser['id'], roleId: XoAclRole['id']): Promise<XoUserRole>;
93
129
  addUserToGroup: (userId: XoUser['id'], groupId: XoGroup['id']) => Promise<void>;
130
+ addApiMethod: <A extends unknown[], R>(name: string, method: (...args: A) => Promise<R>, info: {
131
+ resolve?: any;
132
+ params?: any;
133
+ }) => () => void;
94
134
  authenticateUser: (credentials: {
95
135
  token?: string;
96
136
  username?: string;
@@ -107,6 +147,17 @@ export type XoApp = {
107
147
  }>;
108
148
  checkFeatureAuthorization(featureCode: string): Promise<void>;
109
149
  connectXenServer(id: XoServer['id']): Promise<void>;
150
+ createAclV2Privilege(privilege: Omit<XoAclBasePrivilege, 'id'>, options?: {
151
+ force?: boolean;
152
+ }): Promise<XoAclBasePrivilege>;
153
+ copyAclV2Role(id: XoAclRole['id'], params?: {
154
+ name?: XoAclRole['name'];
155
+ description?: XoAclRole['description'];
156
+ }): Promise<XoAclRole['id']>;
157
+ createAclV2Role(role: {
158
+ name: XoAclRole['name'];
159
+ description?: XoAclRole['description'];
160
+ }): Promise<XoAclRole>;
110
161
  createAuthenticationToken(opts: {
111
162
  client?: {
112
163
  id?: string;
@@ -121,6 +172,13 @@ export type XoApp = {
121
172
  password?: string;
122
173
  [key: string]: unknown;
123
174
  }): Promise<XoUser>;
175
+ deleteAclV2GroupRole(groupId: XoGroup['id'], roleId: XoAclRole['id']): Promise<boolean>;
176
+ deleteAclV2Privilege(privilegeId: XoAclBasePrivilege['id'], options?: {
177
+ force?: boolean;
178
+ }): Promise<boolean>;
179
+ deleteAclV2Role(roleId: XoAclRole['id'], options?: {
180
+ force?: boolean;
181
+ }): Promise<boolean>;
124
182
  deleteGroup(id: XoGroup['id']): Promise<void>;
125
183
  deleteUser(id: XoUser['id']): Promise<void>;
126
184
  createGroup(params: {
@@ -129,6 +187,13 @@ export type XoApp = {
129
187
  providerGroup?: string;
130
188
  }): Promise<XoGroup>;
131
189
  disconnectXenServer(id: XoServer['id']): Promise<void>;
190
+ getAclV2Privilege(id: XoAclBasePrivilege['id']): Promise<XoAclBasePrivilege>;
191
+ getAclV2Privileges(): Promise<XoAclBasePrivilege[]>;
192
+ getAclV2RolePrivileges(roleId: XoAclRole['id']): Promise<XoAclBasePrivilege[]>;
193
+ getAclV2Role(id: XoAclRole['id']): Promise<XoAclRole>;
194
+ deleteAclV2UserRole(userId: XoUser['id'], roleId: XoAclRole['id']): Promise<boolean>;
195
+ getAclV2Roles(): Promise<XoAclRole[]>;
196
+ getAclV2UserPrivileges(userId: XoUser['id']): Promise<XoAclBasePrivilege[]>;
132
197
  getAllGroups(): Promise<XoGroup[]>;
133
198
  getAllProxies(): Promise<XoProxy[]>;
134
199
  getAllJobs<T extends AnyXoBackupJob['type']>(type: T): Promise<Extract<AnyXoBackupJob, {
@@ -220,6 +285,13 @@ export type XoApp = {
220
285
  permission?: string;
221
286
  preferences?: Record<string, string>;
222
287
  }): Promise<void>;
288
+ updateAclV2Privilege(privilegeId: XoAclBasePrivilege['id'], privilege: XoAclBasePrivilege): Promise<XoAclBasePrivilege>;
289
+ updateAclV2Role(roleId: XoAclRole['id'], role: {
290
+ name?: XoAclRole['name'];
291
+ description?: XoAclRole['description'] | null;
292
+ }, options?: {
293
+ force?: boolean;
294
+ }): Promise<XoAclRole>;
223
295
  updateGroup(id: XoGroup['id'], updates: {
224
296
  name?: string;
225
297
  }): void;
@@ -228,5 +300,18 @@ export type XoApp = {
228
300
  filter?: Record<string, unknown>;
229
301
  limit?: number;
230
302
  }): Record<string, XapiXoRecord>;
303
+ getLicenses(params?: {
304
+ productType?: LicenseProductType;
305
+ }): Promise<License[]>;
306
+ bindLicense(params: {
307
+ licenseId: string;
308
+ boundObjectId: string;
309
+ }): Promise<License>;
310
+ unbindLicense(params: {
311
+ productId: LicenseProductId;
312
+ boundObjectId: string;
313
+ licenseId: string;
314
+ data?: Record<string, string>;
315
+ }): Promise<License>;
231
316
  };
232
317
  export {};
package/dist/xo.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Branded, DOMAIN_TYPE, HOST_ALLOWED_OPERATIONS, HOST_POWER_STATE, IP_CONFIGURATION_MODE, IPV6_CONFIGURATION_MODE, NETWORK_OPERATIONS, PGPU_DOM0_ACCESS, POOL_ALLOWED_OPERATIONS, PRIMARY_ADDRESS_TYPE, STORAGE_OPERATIONS, VDI_OPERATIONS, VDI_TYPE, VIF_LOCKING_MODE, VM_OPERATIONS, VM_POWER_STATE } from './common.mjs';
2
2
  import type * as CMType from './lib/complex-matcher.mjs';
3
+ import { XoAclPrivilege, XoAclRole, XoAclSupportedActionsByResource } from './lib/xen-orchestra-acl.mjs';
3
4
  import type { XenApiHost, XenApiPool } from './xen-api.mjs';
4
5
  type BaseXapiXo = {
5
6
  $pool: XoPool['id'];
@@ -299,6 +300,7 @@ export type XoNetwork = BaseXapiXo & {
299
300
  defaultIsLocked: boolean;
300
301
  id: Branded<'network'>;
301
302
  insecureNbd?: boolean;
303
+ isBonded: boolean;
302
304
  name_description: string;
303
305
  name_label: string;
304
306
  nbd?: boolean;
@@ -612,14 +614,14 @@ export type XoTask = {
612
614
  method?: string;
613
615
  name?: string;
614
616
  objectId?: string;
615
- objectType?: XapiXoRecord['type'] | 'backup' | 'backup-archive' | 'backup-job' | 'backup-log' | 'backup-repository' | 'group' | 'proxy' | 'restore' | 'restore-log' | 'schedule' | 'server' | 'task' | 'user';
617
+ objectType?: XapiXoRecord['type'] | 'backup' | 'backup-archive' | 'backup-job' | 'backup-log' | 'backup-repository' | 'group' | 'proxy' | 'restore' | 'restore-log' | 'schedule' | 'server' | 'task' | 'user' | 'acl-privilege' | 'acl-role';
616
618
  params?: Record<string, unknown>;
617
619
  progress?: number;
618
620
  type?: string;
619
621
  userId?: string;
620
622
  [key: string]: unknown | undefined;
621
623
  };
622
- result: Record<string, unknown>;
624
+ result?: Record<string, unknown>;
623
625
  start: number;
624
626
  status: 'failure' | 'interrupted' | 'pending' | 'success';
625
627
  tasks?: XoTask[];
@@ -635,7 +637,7 @@ export type XoUser = {
635
637
  groups: XoGroup['id'][];
636
638
  id: Branded<'user'>;
637
639
  name?: string;
638
- permission: string;
640
+ permission: 'none' | 'admin';
639
641
  pw_hash?: string;
640
642
  preferences: Record<string, string>;
641
643
  };
@@ -771,8 +773,8 @@ export type XoVtpm = BaseXapiXo & {
771
773
  type: 'VTPM';
772
774
  };
773
775
  export type XapiXoRecord = XoAlarm | XoGpuGroup | XoHost | XoMessage | XoNetwork | XoPbd | XoPci | XoPgpu | XoPif | XoPool | XoSr | XoVbd | XoVdi | XoVdiSnapshot | XoVdiUnmanaged | XoVgpu | XoVgpuType | XoVif | XoVm | XoVmController | XoVmSnapshot | XoVmTemplate | XoVtpm | XoSm;
774
- export type NonXapiXoRecord = AnyXoBackupArchive | AnyXoJob | AnyXoLog | XoGroup | XoProxy | XoGroup | XoProxy | XoJob | XoBackupRepository | XoSchedule | XoServer | XoTask | XoUser;
775
- export type XoRecord = XapiXoRecord | NonXapiXoRecord;
776
+ export type NonXapiXoRecord<TActionsByResource extends XoAclSupportedActionsByResource = never, TResource extends string = never> = AnyXoBackupArchive | AnyXoJob | AnyXoLog | XoGroup | XoProxy | XoGroup | XoProxy | XoJob | XoBackupRepository | XoSchedule | XoServer | XoTask | XoUser | XoAclRole | XoAclPrivilege<TActionsByResource, TResource>;
777
+ export type XoRecord<TActionsByResource extends XoAclSupportedActionsByResource = never, TResource extends string = never> = XapiXoRecord | NonXapiXoRecord<TActionsByResource, TResource>;
776
778
  export type AnyXoVm = XoVm | XoVmSnapshot | XoVmTemplate | XoVmController;
777
779
  export type AnyXoVdi = XoVdi | XoVdiSnapshot | XoVdiUnmanaged;
778
780
  export type AnyXoJob = XoJob | AnyXoBackupJob;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vates/types",
3
3
  "private": false,
4
- "version": "1.23.0",
4
+ "version": "1.25.0",
5
5
  "main": "./dist/index.mjs",
6
6
  "exports": {
7
7
  ".": {