@halix/action-sdk 1.0.43 → 1.0.45

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.
@@ -0,0 +1,229 @@
1
+ import { Observable } from 'rxjs';
2
+ /**
3
+ * A data scope assigned to a user as part of a sandbox scope entry.
4
+ */
5
+ export interface ScopeKeyItem {
6
+ /** Object key for the scoped record, such as an organization or user proxy object key. */
7
+ scopeKey: string;
8
+ /** Data element ID for the scoped object. */
9
+ dataElementId: string;
10
+ /** Optional display label for the scope entry. */
11
+ label?: string;
12
+ /** Optional custom data scope identifier when assigning a custom scope. */
13
+ customDataScopeId?: string;
14
+ }
15
+ /**
16
+ * Role metadata available in the current sandbox.
17
+ *
18
+ * Use `id` to identify the intended role in code. Use `objKey` when assigning the role to a user through `roleKeys`.
19
+ */
20
+ export interface Role {
21
+ /** Persisted role object key. Required when assigning roles through `roleKeys`. */
22
+ objKey?: string;
23
+ /** Stable semantic role identifier. Do not submit this as a role key. */
24
+ id: string;
25
+ /** Human-readable role name. */
26
+ name: string;
27
+ /** Human-readable role description. */
28
+ description?: string;
29
+ /** Navigation object keys granted to this role. */
30
+ navigationKeys?: string[];
31
+ /** Data element object keys readable by this role. */
32
+ readDataElementKeys?: string[];
33
+ /** Data element object keys writable by this role. */
34
+ writeDataElementKeys?: string[];
35
+ /** Data element object keys deletable by this role. */
36
+ deleteDataElementKeys?: string[];
37
+ /** Platform system roles granted to this role. */
38
+ systemRoles?: string[];
39
+ /** Business privilege IDs granted to this role. */
40
+ businessPrivilegeIds?: string[];
41
+ /** Optional role grouping labels. */
42
+ categories?: string[];
43
+ }
44
+ /**
45
+ * Business privilege metadata available in the current sandbox.
46
+ */
47
+ export interface BusinessPrivilege {
48
+ /** Persisted privilege object key, when included by the API. */
49
+ objKey?: string;
50
+ /** Stable business privilege identifier used for checks and role grants. */
51
+ id: string;
52
+ /** Human-readable privilege name. */
53
+ name: string;
54
+ /** Human-readable privilege description. */
55
+ description?: string;
56
+ /** Optional privilege grouping labels. */
57
+ categories?: string[];
58
+ }
59
+ /**
60
+ * User summary for a user with access to the current sandbox.
61
+ */
62
+ export interface SandboxUser {
63
+ /** Persisted user object key. */
64
+ userKey: string;
65
+ /** Display name, when available. */
66
+ name?: string;
67
+ /** Email address, when available. */
68
+ email?: string;
69
+ /** Raw scope entries returned by the access service. */
70
+ scopeElements?: unknown[];
71
+ }
72
+ /**
73
+ * Full access wrapper for one user, including scope entries and role metadata when returned by the access service.
74
+ */
75
+ export interface UserAccessWrapper {
76
+ /** Raw user payload returned by the access service. */
77
+ user: unknown;
78
+ /** Raw scope entries for the user. */
79
+ scopeElements: unknown[];
80
+ /** Role metadata associated with the user's access, when returned. */
81
+ roles?: Role[];
82
+ }
83
+ /**
84
+ * Request body for inviting a user and assigning initial sandbox access.
85
+ */
86
+ export interface InviteUserRequest {
87
+ /** Email address for the invited user. */
88
+ email: string;
89
+ /** Optional first name for the invited user. */
90
+ firstName?: string;
91
+ /** Optional last name for the invited user. */
92
+ lastName?: string;
93
+ /** User proxy data element ID used to create or link the user proxy record. */
94
+ userProxyElementId: string;
95
+ /** Optional organization proxy object key for organization-scoped invitations. */
96
+ orgProxyKey?: string;
97
+ /** Persisted role object keys (`Role.objKey`). Never pass semantic `Role.id` values here. */
98
+ roleKeys: string[];
99
+ /** Optional data scopes granted to the invited user. */
100
+ scopeKeyItems?: ScopeKeyItem[];
101
+ /** Optional notification template identifier. */
102
+ notificationTemplate?: string;
103
+ }
104
+ /**
105
+ * Result returned from an invitation request.
106
+ */
107
+ export interface InviteResult {
108
+ /** Invitation/user token key, when returned by the access service. */
109
+ userTokenKey?: string;
110
+ /** Persisted user object key, when a user was created or resolved. */
111
+ userKey?: string;
112
+ /** Invited email address. */
113
+ email?: string;
114
+ [key: string]: unknown;
115
+ }
116
+ /**
117
+ * Request body for adding or updating one user scope entry.
118
+ */
119
+ export interface UpdateAccessRequest {
120
+ /** Existing scope element ID. When omitted, a new scope entry is added. */
121
+ scopeElementId?: string;
122
+ /** Persisted role object keys (`Role.objKey`). Never pass semantic `Role.id` values here. */
123
+ roleKeys: string[];
124
+ /** Data scopes to store on the scope entry. */
125
+ scopeKeyItems: ScopeKeyItem[];
126
+ /** Whether this scope entry should apply globally instead of being limited to the provided scopes. */
127
+ globalAccess?: boolean;
128
+ }
129
+ /**
130
+ * Lists roles available in the current sandbox.
131
+ *
132
+ * Use this before assigning roles so semantic role IDs can be resolved to persisted `objKey` values. Assignment
133
+ * requests must send `Role.objKey` values in `roleKeys`.
134
+ *
135
+ * @returns Promise resolving to role metadata for the current sandbox
136
+ */
137
+ export declare function listRoles(): Promise<Role[]>;
138
+ /**
139
+ * Observable version of `listRoles`. See `listRoles` for details.
140
+ */
141
+ export declare function listRolesAsObservable(): Observable<Role[]>;
142
+ /**
143
+ * Lists business privileges available in the current sandbox.
144
+ *
145
+ * Business privilege IDs are used by `hasBusinessPrivilege`, current-user privilege checks, and role
146
+ * `businessPrivilegeIds`.
147
+ *
148
+ * @returns Promise resolving to business privilege metadata
149
+ */
150
+ export declare function listBusinessPrivileges(): Promise<BusinessPrivilege[]>;
151
+ /**
152
+ * Observable version of `listBusinessPrivileges`. See `listBusinessPrivileges` for details.
153
+ */
154
+ export declare function listBusinessPrivilegesAsObservable(): Observable<BusinessPrivilege[]>;
155
+ /**
156
+ * Lists users with access to the current sandbox.
157
+ *
158
+ * Use `getUserAccess` when full scope-entry details are needed for a specific user.
159
+ *
160
+ * @returns Promise resolving to sandbox user summaries
161
+ */
162
+ export declare function listSandboxUsers(): Promise<SandboxUser[]>;
163
+ /**
164
+ * Observable version of `listSandboxUsers`. See `listSandboxUsers` for details.
165
+ */
166
+ export declare function listSandboxUsersAsObservable(): Observable<SandboxUser[]>;
167
+ /**
168
+ * Gets one user's current sandbox access, including scope entries and any role metadata returned by the access service.
169
+ *
170
+ * @param userKey - Persisted user object key
171
+ * @returns Promise resolving to the user's access wrapper
172
+ */
173
+ export declare function getUserAccess(userKey: string): Promise<UserAccessWrapper>;
174
+ /**
175
+ * Observable version of `getUserAccess`. See `getUserAccess` for details.
176
+ */
177
+ export declare function getUserAccessAsObservable(userKey: string): Observable<UserAccessWrapper>;
178
+ /**
179
+ * Invites a user by email and assigns initial sandbox access.
180
+ *
181
+ * `req.roleKeys` must contain persisted role object keys from `Role.objKey`, not semantic role IDs. Resolve desired
182
+ * semantic IDs with `listRoles` before calling this function.
183
+ *
184
+ * @param req - Invitation and initial access request
185
+ * @returns Promise resolving to invitation result metadata
186
+ */
187
+ export declare function inviteUser(req: InviteUserRequest): Promise<InviteResult>;
188
+ /**
189
+ * Observable version of `inviteUser`. See `inviteUser` for details.
190
+ */
191
+ export declare function inviteUserAsObservable(req: InviteUserRequest): Observable<InviteResult>;
192
+ /**
193
+ * Adds or updates one user's sandbox scope entry.
194
+ *
195
+ * If `req.scopeElementId` is present, the existing scope entry is updated. If it is omitted, a new scope entry is
196
+ * added. `req.roleKeys` must contain persisted role object keys from `Role.objKey`, not semantic role IDs.
197
+ *
198
+ * @param userKey - Persisted user object key
199
+ * @param req - Scope-entry access update request
200
+ */
201
+ export declare function updateUserAccess(userKey: string, req: UpdateAccessRequest): Promise<void>;
202
+ /**
203
+ * Observable version of `updateUserAccess`. See `updateUserAccess` for details.
204
+ */
205
+ export declare function updateUserAccessAsObservable(userKey: string, req: UpdateAccessRequest): Observable<void>;
206
+ /**
207
+ * Removes one sandbox scope entry from a user.
208
+ *
209
+ * @param userKey - Persisted user object key
210
+ * @param scopeElementId - Scope element ID to remove from the user
211
+ */
212
+ export declare function removeUserAccess(userKey: string, scopeElementId: string): Promise<void>;
213
+ /**
214
+ * Observable version of `removeUserAccess`. See `removeUserAccess` for details.
215
+ */
216
+ export declare function removeUserAccessAsObservable(userKey: string, scopeElementId: string): Observable<void>;
217
+ /**
218
+ * Checks whether the current user context contains a business privilege ID.
219
+ *
220
+ * @param privilegeId - Stable business privilege ID
221
+ * @returns True when the current user has the privilege
222
+ */
223
+ export declare function hasBusinessPrivilege(privilegeId: string): boolean;
224
+ /**
225
+ * Returns the current user's business privilege IDs from the SDK user context.
226
+ *
227
+ * @returns Business privilege IDs for the current user, or an empty array when none are available
228
+ */
229
+ export declare function userPrivileges(): string[];
@@ -58,3 +58,45 @@ export declare function createOrUpdateResource(resourceKey: string | null, fileT
58
58
  * Observable version of createOrUpdateResource. See createOrUpdateResource for details.
59
59
  */
60
60
  export declare function createOrUpdateResourceAsObservable(resourceKey: string | null, fileToUpload: File | Blob, publicFlag: boolean, resourceType: string, tags: string[]): Observable<ContentResource>;
61
+ /**
62
+ * Fetches a file resource from the Halix content service and returns it as a `Blob` along with
63
+ * the filename derived from the `Content-Disposition` response header (falling back to
64
+ * `resourceKey` when the header is absent).
65
+ *
66
+ * This function is environment-agnostic: it performs only the authenticated HTTP fetch and leaves
67
+ * all presentation logic to the caller.
68
+ *
69
+ * **Browser download example** — trigger the native Save dialog from a click handler:
70
+ * ```js
71
+ * button.addEventListener('click', async () => {
72
+ * const { blob, fileName } = await downloadResource(recipe.attachmentKey);
73
+ * const url = URL.createObjectURL(blob);
74
+ * const a = document.createElement('a');
75
+ * a.href = url;
76
+ * a.download = fileName;
77
+ * a.click();
78
+ * URL.revokeObjectURL(url);
79
+ * });
80
+ * ```
81
+ *
82
+ * **Node.js example** — write the blob to disk:
83
+ * ```js
84
+ * const { blob } = await downloadResource(recipe.attachmentKey);
85
+ * const buffer = Buffer.from(await blob.arrayBuffer());
86
+ * fs.writeFileSync('attachment.pdf', buffer);
87
+ * ```
88
+ *
89
+ * @param resourceKey - Key of the content resource to fetch
90
+ * @returns Promise resolving to `{ blob, fileName }`
91
+ */
92
+ export declare function downloadResource(resourceKey: string): Promise<{
93
+ blob: Blob;
94
+ fileName: string;
95
+ }>;
96
+ /**
97
+ * Observable version of downloadResource. See downloadResource for details.
98
+ */
99
+ export declare function downloadResourceAsObservable(resourceKey: string): Observable<{
100
+ blob: Blob;
101
+ fileName: string;
102
+ }>;
@@ -5,7 +5,8 @@
5
5
  */
6
6
  export { getAuthToken, sandboxKey, serviceAddress, actionSubject, userContext, params, useBody, initialize, type UserContext, type IncomingEventBody, type BaseActionResponse, type ActionResponse, type NotificationConfig, type ListActionResponse, type FormTemplateActionResponse, type PageTemplateActionResponse, type ObjectSaveActionResponse, type CalculatedFieldActionResponse, type SingleValueActionResponse, type ErrorResponse, prepareSuccessResponse, prepareErrorResponse } from './sdk-general';
7
7
  export { type SaveOptions, getObject, getObjectAsObservable, getRelatedObjects, getRelatedObjectsAsObservable, getAccessibleObjects, getAccessibleObjectsAsObservable, getObjects, getObjectsAsObservable, saveObject, saveObjectAsObservable, saveRelatedObject, saveRelatedObjectAsObservable, deleteObject, deleteObjectAsObservable, deleteRelatedObject, deleteRelatedObjectAsObservable, deleteRelatedObjects, deleteRelatedObjectsAsObservable } from './data-crud';
8
- export { type ContentResource, getOrCreateResource, getOrCreateResourceAsObservable, saveResource, saveResourceAsObservable, sendFileContents, sendFileContentsAsObservable, createOrUpdateResource, createOrUpdateResourceAsObservable } from './content';
8
+ export { type ScopeKeyItem, type Role, type BusinessPrivilege, type SandboxUser, type UserAccessWrapper, type InviteUserRequest, type InviteResult, type UpdateAccessRequest, listRoles, listRolesAsObservable, listBusinessPrivileges, listBusinessPrivilegesAsObservable, listSandboxUsers, listSandboxUsersAsObservable, getUserAccess, getUserAccessAsObservable, inviteUser, inviteUserAsObservable, updateUserAccess, updateUserAccessAsObservable, removeUserAccess, removeUserAccessAsObservable, hasBusinessPrivilege, userPrivileges, } from './access';
9
+ export { type ContentResource, getOrCreateResource, getOrCreateResourceAsObservable, saveResource, saveResourceAsObservable, sendFileContents, sendFileContentsAsObservable, createOrUpdateResource, createOrUpdateResourceAsObservable, downloadResource, downloadResourceAsObservable } from './content';
9
10
  export { MessageMethod, type MessageRequest, sendMessage, sendMessageAsObservable } from './messaging';
10
11
  export { getUserPreference, getOrganizationPreference, getUserPreferenceAsObservable, getOrganizationPreferenceAsObservable } from './preferences';
11
12
  export { type SortField, type DataSortField, type BaseListDataRequest, type PagedListDataRequest, type ListDataResponse, type ListDataOptions, type ListDataSearchOptions, type MassEditValueType, type MassEditRequest, type MassDeleteRequest, type MassChangeResponse, getListData, getListDataAsObservable, massEdit, massEditAsObservable, massDelete, massDeleteAsObservable } from './lists';
@@ -58,6 +58,7 @@ export interface UserContext {
58
58
  orgProxyKey: string;
59
59
  orgKey: string;
60
60
  userProxyKey: string;
61
+ businessPrivileges: string[];
61
62
  navigationContext: {
62
63
  navigationKey: string;
63
64
  navLevel: "organization" | "user";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halix/action-sdk",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "Halix Platform action SDK",
5
5
  "types": "./lib/cjs/types/index.d.ts",
6
6
  "main": "./lib/cjs/index.js",