-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathITwinJob.ts
More file actions
85 lines (79 loc) · 2.78 KB
/
ITwinJob.ts
File metadata and controls
85 lines (79 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import type { ErrorDetail } from "./CommonApiTypes";
/**
* Represents the current status of an iTwin job operation.
* Jobs progress through these states as they are processed by the system.
*/
export type ITwinJobStatus =
| "Active" // Job is currently being processed
| "Completed" // Job has finished successfully
| "PartialCompleted" // Job completed with some failures
| "Failed"; // Job failed to complete
/**
* This interface represents a job that manages user access control operations
* such as assigning roles, removing members, etc.
*/
export interface ITwinJob {
/** Unique identifier for the job */
id: string;
/** The iTwin ID this job operates on */
itwinId: string;
/** Current status of the job */
status: ITwinJobStatus;
/** Error details if the job encountered issues, empty array if no errors */
error: ErrorDetail[];
}
/**
* Available action types that can be performed in an iTwin job.
* These represent the different operations that can be batched together.
*/
export type ItwinJobActions = "assignRoles" | "unassignRoles" | "removeMembers";
/**
* Defines the structure for iTwin job actions with type-safe action payloads.
*
* @remarks
* - `assignRoles` and `unassignRoles` actions include both email and roleIds
* - `removeMembers` actions only include email (roleIds are omitted)
* - Additional options can be provided for job configuration
*
* @example
* ```typescript
* const jobActions: ITwinJobActions = {
* assignRoles: [
* { email: "user@example.com", roleIds: ["admin", "viewer"] }
* ],
* removeMembers: [
* { email: "former-user@example.com" } // No roleIds needed
* ],
* options: {
* timeout: 30000,
* retries: 3
* }
* };
* ```
*/
export type ITwinJobActions = {
[K in ItwinJobActions]?: K extends "removeMembers"
? Omit<ITwinJobAction, "roleIds">[]
: ITwinJobAction[];
} & {
/** Additional configuration options for the job */
options?: Record<string, unknown>;
};
/**
* Represents a single action within an iTwin job that affects a user's access.
*
* @remarks
* This interface defines the core structure for user-related operations.
* When used with `removeMembers` actions, the `roleIds` property should be
* omitted.
*/
export interface ITwinJobAction {
/** Email address of the user to be affected by this action */
email: string;
/** Array of role IDs to assign or unassign (not used for removeMembers) */
roleIds: string[];
}