@seliseblocks/client 0.1.0-beta.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/AI_USAGE_GUIDE.md +149 -0
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/dist/auth/auth-client.d.ts +256 -0
- package/dist/auth/auth-client.js +427 -0
- package/dist/auth/types.d.ts +77 -0
- package/dist/auth/types.js +1 -0
- package/dist/client.d.ts +74 -0
- package/dist/client.js +49 -0
- package/dist/data/data-client.d.ts +178 -0
- package/dist/data/data-client.js +385 -0
- package/dist/data/types.d.ts +148 -0
- package/dist/data/types.js +1 -0
- package/dist/http/errors.d.ts +6 -0
- package/dist/http/errors.js +23 -0
- package/dist/http/http-client.d.ts +11 -0
- package/dist/http/http-client.js +82 -0
- package/dist/iam/iam-client.d.ts +226 -0
- package/dist/iam/iam-client.js +230 -0
- package/dist/iam/types.d.ts +56 -0
- package/dist/iam/types.js +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -0
- package/dist/localization/localization-client.d.ts +71 -0
- package/dist/localization/localization-client.js +148 -0
- package/dist/localization/types.d.ts +35 -0
- package/dist/localization/types.js +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.js +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export type BlocksPagedResult<T> = {
|
|
2
|
+
data?: {
|
|
3
|
+
items?: T[];
|
|
4
|
+
totalCount?: number;
|
|
5
|
+
};
|
|
6
|
+
errors?: unknown;
|
|
7
|
+
httpStatusCode?: number;
|
|
8
|
+
isSuccess?: boolean;
|
|
9
|
+
message?: string | null;
|
|
10
|
+
};
|
|
11
|
+
export type BlocksDataListOptions = {
|
|
12
|
+
pageNo?: number;
|
|
13
|
+
pageSize?: number;
|
|
14
|
+
query?: Record<string, boolean | number | string | undefined>;
|
|
15
|
+
};
|
|
16
|
+
export type BlocksDataCollection<T = Record<string, unknown>> = {
|
|
17
|
+
create(payload: Partial<T>): Promise<unknown>;
|
|
18
|
+
delete(itemId: string): Promise<unknown>;
|
|
19
|
+
get(itemId: string): Promise<unknown>;
|
|
20
|
+
list(options?: BlocksDataListOptions): Promise<unknown>;
|
|
21
|
+
update(itemId: string, payload: Partial<T>): Promise<unknown>;
|
|
22
|
+
};
|
|
23
|
+
export type BlocksDataSchema = Record<string, unknown> & {
|
|
24
|
+
schemaName?: string;
|
|
25
|
+
};
|
|
26
|
+
export type BlocksSchemaListOptions = {
|
|
27
|
+
collectionName?: string;
|
|
28
|
+
keyword?: string;
|
|
29
|
+
pageNo?: number;
|
|
30
|
+
pageSize?: number;
|
|
31
|
+
schemaName?: string;
|
|
32
|
+
schemaType?: number;
|
|
33
|
+
sortBy?: string;
|
|
34
|
+
sortDescending?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type BlocksSchemaValidationListOptions = BlocksSchemaListOptions & {
|
|
37
|
+
fieldName?: string;
|
|
38
|
+
schemaId?: string;
|
|
39
|
+
};
|
|
40
|
+
export type BlocksSchemaFieldValidationOptions = {
|
|
41
|
+
fieldName: string;
|
|
42
|
+
schemaId: string;
|
|
43
|
+
};
|
|
44
|
+
export type BlocksRegexGenerateRequest = Record<string, unknown> & {
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
export type BlocksGraphqlRequest = {
|
|
48
|
+
headers?: HeadersInit;
|
|
49
|
+
operationName?: string;
|
|
50
|
+
query: string;
|
|
51
|
+
variables?: Record<string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
export type BlocksFileUploadRequest = Record<string, unknown> & {
|
|
54
|
+
accessModifier?: string;
|
|
55
|
+
additionalProperties?: Record<string, string>;
|
|
56
|
+
configurationName?: string;
|
|
57
|
+
contentType?: string;
|
|
58
|
+
fileName?: string;
|
|
59
|
+
itemId?: string;
|
|
60
|
+
metaData?: string;
|
|
61
|
+
moduleName?: number | string;
|
|
62
|
+
name?: string;
|
|
63
|
+
parentDirectoryId?: string;
|
|
64
|
+
tags?: string;
|
|
65
|
+
};
|
|
66
|
+
export type BlocksFileListRequest = Record<string, unknown> & {
|
|
67
|
+
configurationName?: string;
|
|
68
|
+
fileIds?: string[];
|
|
69
|
+
};
|
|
70
|
+
export type BlocksFileInfoListRequest = Record<string, unknown> & {
|
|
71
|
+
filter?: Record<string, unknown>;
|
|
72
|
+
page?: number;
|
|
73
|
+
pageNo?: number;
|
|
74
|
+
pageSize?: number;
|
|
75
|
+
sort?: {
|
|
76
|
+
isDescending?: boolean;
|
|
77
|
+
property?: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export type BlocksFileGetOptions = {
|
|
81
|
+
configurationName?: string;
|
|
82
|
+
version?: number;
|
|
83
|
+
};
|
|
84
|
+
export type BlocksFileDeleteRequest = Record<string, unknown> & {
|
|
85
|
+
configurationName?: string;
|
|
86
|
+
eventQueueName?: string;
|
|
87
|
+
fileId: string;
|
|
88
|
+
};
|
|
89
|
+
export type BlocksFolderDeleteRequest = Record<string, unknown> & {
|
|
90
|
+
configurationName?: string;
|
|
91
|
+
folderId: string;
|
|
92
|
+
};
|
|
93
|
+
export type BlocksFileUpdateAdditionalInfoRequest = Record<string, unknown> & {
|
|
94
|
+
additionalProperties?: Record<string, string>;
|
|
95
|
+
itemId: string;
|
|
96
|
+
};
|
|
97
|
+
export type BlocksLocalStorageUploadRequest = Record<string, unknown> & {
|
|
98
|
+
accessModifier?: string;
|
|
99
|
+
additionalProperties?: Record<string, string>;
|
|
100
|
+
configurationName?: string;
|
|
101
|
+
file: Blob;
|
|
102
|
+
itemId?: string;
|
|
103
|
+
metaData?: string;
|
|
104
|
+
name: string;
|
|
105
|
+
parentDirectoryId?: string;
|
|
106
|
+
tags?: string | string[];
|
|
107
|
+
};
|
|
108
|
+
export type BlocksUploadToUrlRequest = {
|
|
109
|
+
body: Blob | ArrayBuffer | ArrayBufferView | ReadableStream;
|
|
110
|
+
contentType?: string;
|
|
111
|
+
headers?: HeadersInit;
|
|
112
|
+
url: string;
|
|
113
|
+
};
|
|
114
|
+
export type BlocksDmsListRequest = Record<string, unknown> & {
|
|
115
|
+
configurationName?: string;
|
|
116
|
+
moduleName?: string;
|
|
117
|
+
parentId?: string;
|
|
118
|
+
searchKey?: string;
|
|
119
|
+
skip?: number;
|
|
120
|
+
take?: number;
|
|
121
|
+
};
|
|
122
|
+
export type BlocksDmsMetaDataValue = {
|
|
123
|
+
type: string;
|
|
124
|
+
value: string;
|
|
125
|
+
};
|
|
126
|
+
export type BlocksDmsUploadItem = Record<string, unknown> & {
|
|
127
|
+
artifactName?: string;
|
|
128
|
+
configurationName?: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
fileStorageId: string;
|
|
131
|
+
metaData?: Record<string, BlocksDmsMetaDataValue>;
|
|
132
|
+
organizationId?: string;
|
|
133
|
+
parentId?: string;
|
|
134
|
+
tags?: string[];
|
|
135
|
+
};
|
|
136
|
+
export type BlocksDmsUploadRequest = Record<string, unknown> & {
|
|
137
|
+
upload: BlocksDmsUploadItem[];
|
|
138
|
+
};
|
|
139
|
+
export type BlocksDmsCreateFolderRequest = Record<string, unknown> & {
|
|
140
|
+
artifactName: string;
|
|
141
|
+
configurationName?: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
fileStorageId?: string;
|
|
144
|
+
metaData?: Record<string, BlocksDmsMetaDataValue>;
|
|
145
|
+
organizationId?: string;
|
|
146
|
+
parentId?: string;
|
|
147
|
+
tags?: string[];
|
|
148
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class BlocksApiError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
statusText;
|
|
4
|
+
body;
|
|
5
|
+
constructor(status, statusText, body) {
|
|
6
|
+
super(buildMessage(status, statusText, body));
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.statusText = statusText;
|
|
9
|
+
this.body = body;
|
|
10
|
+
this.name = "BlocksApiError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function buildMessage(status, statusText, body) {
|
|
14
|
+
if (typeof body === "object" && body) {
|
|
15
|
+
const record = body;
|
|
16
|
+
const message = record.message ?? record.detail ?? record.error_description ?? record.error;
|
|
17
|
+
if (typeof message === "string" && message)
|
|
18
|
+
return `Blocks API ${status} ${statusText}: ${message}`;
|
|
19
|
+
}
|
|
20
|
+
if (typeof body === "string" && body)
|
|
21
|
+
return `Blocks API ${status} ${statusText}: ${body}`;
|
|
22
|
+
return `Blocks API ${status} ${statusText}`;
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BlocksAuthenticationClient } from "../auth/auth-client.js";
|
|
2
|
+
import { RequiredConfig } from "../client.js";
|
|
3
|
+
import { BlocksExternalRequestOptions, BlocksRequestOptions } from "../types.js";
|
|
4
|
+
export declare class BlocksHttpClient {
|
|
5
|
+
private readonly config;
|
|
6
|
+
private readonly auth;
|
|
7
|
+
private readonly fetchImpl;
|
|
8
|
+
constructor(config: RequiredConfig, auth: BlocksAuthenticationClient, fetchImpl?: typeof fetch);
|
|
9
|
+
request<T>(path: string, options?: BlocksRequestOptions): Promise<T>;
|
|
10
|
+
external<T = unknown>(url: string, options?: BlocksExternalRequestOptions): Promise<T>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BlocksApiError } from "./errors.js";
|
|
2
|
+
export class BlocksHttpClient {
|
|
3
|
+
config;
|
|
4
|
+
auth;
|
|
5
|
+
fetchImpl;
|
|
6
|
+
constructor(config, auth, fetchImpl = globalThis.fetch) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
this.auth = auth;
|
|
9
|
+
this.fetchImpl = fetchImpl;
|
|
10
|
+
if (!this.fetchImpl)
|
|
11
|
+
throw new Error("Blocks client requires fetch.");
|
|
12
|
+
}
|
|
13
|
+
async request(path, options = {}) {
|
|
14
|
+
const url = buildUrl(this.config.apiUrl, path, options.query);
|
|
15
|
+
const headers = new Headers(options.headers);
|
|
16
|
+
const rawBody = isBodyInit(options.body) ? options.body : undefined;
|
|
17
|
+
headers.set("Accept", "application/json");
|
|
18
|
+
headers.set("x-blocks-key", this.config.xBlocksKey);
|
|
19
|
+
if (options.body !== undefined && !rawBody && !headers.has("Content-Type")) {
|
|
20
|
+
headers.set("Content-Type", "application/json");
|
|
21
|
+
}
|
|
22
|
+
if (options.auth !== false) {
|
|
23
|
+
const token = options.accessToken ?? await this.auth.accessToken();
|
|
24
|
+
if (token)
|
|
25
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
26
|
+
}
|
|
27
|
+
const response = await this.fetchImpl(url, {
|
|
28
|
+
body: rawBody ?? (options.body === undefined ? undefined : JSON.stringify(options.body)),
|
|
29
|
+
headers,
|
|
30
|
+
method: options.method ?? (options.body === undefined ? "GET" : "POST")
|
|
31
|
+
});
|
|
32
|
+
const body = await parseBody(response);
|
|
33
|
+
if (!response.ok)
|
|
34
|
+
throw new BlocksApiError(response.status, response.statusText, body);
|
|
35
|
+
return body;
|
|
36
|
+
}
|
|
37
|
+
async external(url, options = {}) {
|
|
38
|
+
const response = await this.fetchImpl(url, {
|
|
39
|
+
body: options.body,
|
|
40
|
+
headers: options.headers,
|
|
41
|
+
method: options.method ?? "GET"
|
|
42
|
+
});
|
|
43
|
+
const body = await parseBody(response);
|
|
44
|
+
if (!response.ok)
|
|
45
|
+
throw new BlocksApiError(response.status, response.statusText, body);
|
|
46
|
+
return body;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function isBodyInit(value) {
|
|
50
|
+
return typeof Blob !== "undefined" && value instanceof Blob
|
|
51
|
+
|| typeof FormData !== "undefined" && value instanceof FormData
|
|
52
|
+
|| typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams
|
|
53
|
+
|| typeof ReadableStream !== "undefined" && value instanceof ReadableStream
|
|
54
|
+
|| value instanceof ArrayBuffer
|
|
55
|
+
|| ArrayBuffer.isView(value);
|
|
56
|
+
}
|
|
57
|
+
function buildUrl(baseUrl, path, query) {
|
|
58
|
+
const url = /^https?:\/\//i.test(path)
|
|
59
|
+
? new URL(path)
|
|
60
|
+
: new URL(path.replace(/^\/+/, ""), `${baseUrl}/`);
|
|
61
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
62
|
+
if (value !== undefined)
|
|
63
|
+
url.searchParams.set(key, String(value));
|
|
64
|
+
}
|
|
65
|
+
return url.toString();
|
|
66
|
+
}
|
|
67
|
+
async function parseBody(response) {
|
|
68
|
+
if (response.status === 204)
|
|
69
|
+
return undefined;
|
|
70
|
+
const text = await response.text();
|
|
71
|
+
if (!text)
|
|
72
|
+
return undefined;
|
|
73
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
74
|
+
if (contentType.includes("application/json"))
|
|
75
|
+
return JSON.parse(text);
|
|
76
|
+
try {
|
|
77
|
+
return JSON.parse(text);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return text;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { BlocksHttpClient } from "../http/http-client.js";
|
|
2
|
+
import { BlocksBaseResponse, BlocksGetMyOrganizationsResponse, BlocksGetOrganizationResponse, BlocksGetOrganizationsResponse, BlocksGetPermissionResponse, BlocksGetPermissionsResponse, BlocksGetRoleResponse, BlocksGetRolesResponse, BlocksGetUserResponse, BlocksGetUsersResponse, BlocksIamListRequest, BlocksMeResponse } from "./types.js";
|
|
3
|
+
export declare class BlocksIAMClient {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: BlocksHttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* Current authenticated IAM account from `GET /iam/v4/iam/me`.
|
|
8
|
+
* Use this for app profile bootstrapping because it returns the Blocks user record,
|
|
9
|
+
* roles, permissions, and active organization context according to the access token.
|
|
10
|
+
*/
|
|
11
|
+
me(): Promise<BlocksMeResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Updates the current authenticated user's IAM profile through `POST /iam/v4/iam/me`.
|
|
14
|
+
* The backend resolves the user id from the token; callers must not send another user's id.
|
|
15
|
+
*/
|
|
16
|
+
updateMe(request: Record<string, unknown>): Promise<BlocksBaseResponse>;
|
|
17
|
+
users: {
|
|
18
|
+
/**
|
|
19
|
+
* What: creates a user through `POST /iam/v4/iam/users/create`.
|
|
20
|
+
* Why: authorized admin UIs need to invite/provision users in the active tenant/organization.
|
|
21
|
+
* How: pass IAM's create-user payload; caller permissions determine whether the API accepts it.
|
|
22
|
+
*/
|
|
23
|
+
create: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* What: updates a user through `POST /iam/v4/iam/users/{id}`.
|
|
26
|
+
* Why: authorized admin UIs need to edit IAM profile fields.
|
|
27
|
+
* How: pass the user id in the route and IAM's update payload in the body.
|
|
28
|
+
*/
|
|
29
|
+
update: (id: string, request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* What: deactivates a user through `POST /iam/v4/iam/users/deactivate`.
|
|
32
|
+
* Why: admin UIs need to remove access without deleting the user record.
|
|
33
|
+
* How: pass IAM's deactivate payload for the target user.
|
|
34
|
+
*/
|
|
35
|
+
deactivate: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* What: activates a user through `POST /iam/v4/iam/users/activate`.
|
|
38
|
+
* Why: admin UIs need to restore access for a previously inactive account.
|
|
39
|
+
* How: pass IAM's activate payload for the target user.
|
|
40
|
+
*/
|
|
41
|
+
activate: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* What: queries users through `POST /iam/v4/iam/users`.
|
|
44
|
+
* Why: IAM uses a POST-read contract for paging/filtering user lists.
|
|
45
|
+
* How: pass `pageNo`, `pageSize`, search/filter fields, or the exact IAM list payload your UI needs.
|
|
46
|
+
*/
|
|
47
|
+
list: (request?: BlocksIamListRequest) => Promise<BlocksGetUsersResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* What: reads one user through `GET /iam/v4/iam/users/{id}`.
|
|
50
|
+
* Why: user detail screens need one IAM user record, optionally for a specific organization context.
|
|
51
|
+
* How: pass the user id and optional `organizationId`.
|
|
52
|
+
*/
|
|
53
|
+
get: (id: string, options?: {
|
|
54
|
+
organizationId?: string;
|
|
55
|
+
}) => Promise<BlocksGetUserResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* What: updates user access through `POST /iam/v4/iam/users/access`.
|
|
58
|
+
* Why: admin UIs need to grant or change roles/permissions for a user.
|
|
59
|
+
* How: pass IAM's access payload; the active token and tenant header define allowed scope.
|
|
60
|
+
*/
|
|
61
|
+
updateAccess: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* What: revokes user access through `POST /iam/v4/iam/users/revoke-access`.
|
|
64
|
+
* Why: admin UIs need to remove roles/permissions or organization access.
|
|
65
|
+
* How: pass IAM's revoke-access payload.
|
|
66
|
+
*/
|
|
67
|
+
revokeAccess: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* What: checks email availability through `GET /iam/v4/iam/email/available`.
|
|
70
|
+
* Why: signup and invite forms can validate duplicate email state before submit.
|
|
71
|
+
* How: pass the email query fields IAM expects; this is public but still sends `x-blocks-key`.
|
|
72
|
+
*/
|
|
73
|
+
emailAvailable: (query: Record<string, string | undefined>) => Promise<{
|
|
74
|
+
isAvailable?: boolean;
|
|
75
|
+
IsAvailable?: boolean;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* What: checks whether a user exists through `GET /iam/v4/iam/users/exists`.
|
|
79
|
+
* Why: account and invite flows may need an existence check by email.
|
|
80
|
+
* How: pass the email string; the SDK sends it as the `email` query parameter.
|
|
81
|
+
*/
|
|
82
|
+
exists: (email: string) => Promise<unknown>;
|
|
83
|
+
};
|
|
84
|
+
permissions: {
|
|
85
|
+
/**
|
|
86
|
+
* What: creates a permission through `POST /iam/v4/iam/permissions/create`.
|
|
87
|
+
* Why: authorized admin tooling may manage custom IAM permission definitions.
|
|
88
|
+
* How: pass IAM's create-permission payload.
|
|
89
|
+
*/
|
|
90
|
+
create: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
91
|
+
/**
|
|
92
|
+
* What: updates a permission through `POST /iam/v4/iam/permissions/{id}`.
|
|
93
|
+
* Why: admin tooling may need to edit permission metadata.
|
|
94
|
+
* How: pass the permission id and IAM's update payload.
|
|
95
|
+
*/
|
|
96
|
+
update: (id: string, request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
97
|
+
/**
|
|
98
|
+
* What: queries permissions through `POST /iam/v4/iam/permissions`.
|
|
99
|
+
* Why: IAM uses a POST-read contract for permission paging/filtering.
|
|
100
|
+
* How: pass `pageNo`, `pageSize`, search/filter fields, or IAM's exact list payload.
|
|
101
|
+
*/
|
|
102
|
+
list: (request?: BlocksIamListRequest) => Promise<BlocksGetPermissionsResponse>;
|
|
103
|
+
/**
|
|
104
|
+
* What: groups permissions by severity through `GET /iam/v4/iam/permissions/by-severity`.
|
|
105
|
+
* Why: role/access UIs often display permissions grouped by risk or category.
|
|
106
|
+
* How: call after an authorized token is available.
|
|
107
|
+
*/
|
|
108
|
+
bySeverity: () => Promise<unknown[]>;
|
|
109
|
+
/**
|
|
110
|
+
* What: reads one permission through `GET /iam/v4/iam/permissions/{id}`.
|
|
111
|
+
* Why: admin detail/edit screens need one permission record.
|
|
112
|
+
* How: pass the permission id from IAM.
|
|
113
|
+
*/
|
|
114
|
+
get: (id: string) => Promise<BlocksGetPermissionResponse>;
|
|
115
|
+
};
|
|
116
|
+
roles: {
|
|
117
|
+
/**
|
|
118
|
+
* What: creates a role through `POST /iam/v4/iam/roles/create`.
|
|
119
|
+
* Why: admin UIs need to define permission bundles users can be assigned to.
|
|
120
|
+
* How: pass IAM's create-role payload.
|
|
121
|
+
*/
|
|
122
|
+
create: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
123
|
+
/**
|
|
124
|
+
* What: updates a role through `POST /iam/v4/iam/roles/update`.
|
|
125
|
+
* Why: admin UIs need to edit role names, metadata, or other IAM-supported fields.
|
|
126
|
+
* How: pass IAM's role update payload.
|
|
127
|
+
*/
|
|
128
|
+
update: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* What: queries roles through `POST /iam/v4/iam/roles`.
|
|
131
|
+
* Why: IAM uses a POST-read contract for role paging/filtering.
|
|
132
|
+
* How: pass `pageNo`, `pageSize`, search/filter fields, or IAM's exact list payload.
|
|
133
|
+
*/
|
|
134
|
+
list: (request?: BlocksIamListRequest) => Promise<BlocksGetRolesResponse>;
|
|
135
|
+
/**
|
|
136
|
+
* What: reads one role through `GET /iam/v4/iam/roles/{id}`.
|
|
137
|
+
* Why: role detail/edit screens need one IAM role record.
|
|
138
|
+
* How: pass the role id from IAM.
|
|
139
|
+
*/
|
|
140
|
+
get: (id: string) => Promise<BlocksGetRoleResponse>;
|
|
141
|
+
/**
|
|
142
|
+
* What: assigns permissions to a role through `POST /iam/v4/iam/roles/assign-permissions`.
|
|
143
|
+
* Why: role editors need to attach or replace permission sets.
|
|
144
|
+
* How: pass IAM's assign-permissions payload.
|
|
145
|
+
*/
|
|
146
|
+
assignPermissions: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
147
|
+
/**
|
|
148
|
+
* What: lists assignable roles through `GET /iam/v4/iam/roles/assignable`.
|
|
149
|
+
* Why: user-access UIs should only show roles the current user can assign.
|
|
150
|
+
* How: call after an authorized token is available.
|
|
151
|
+
*/
|
|
152
|
+
assignable: () => Promise<unknown>;
|
|
153
|
+
};
|
|
154
|
+
resources: {
|
|
155
|
+
/**
|
|
156
|
+
* What: lists resource groups through `GET /iam/v4/iam/resource-groups`.
|
|
157
|
+
* Why: permission screens need resource grouping metadata for navigation and display.
|
|
158
|
+
* How: call after an authorized token is available.
|
|
159
|
+
*/
|
|
160
|
+
groups: () => Promise<unknown[]>;
|
|
161
|
+
/**
|
|
162
|
+
* What: lists feature/resource flags through `GET /iam/v4/iam/resource/features`.
|
|
163
|
+
* Why: frontends use this to feature-gate UI based on current roles and permissions.
|
|
164
|
+
* How: pass optional query fields supported by IAM; the active token defines the user context.
|
|
165
|
+
*/
|
|
166
|
+
features: (query?: Record<string, string | number | boolean | undefined>) => Promise<unknown[]>;
|
|
167
|
+
};
|
|
168
|
+
organizations: {
|
|
169
|
+
/**
|
|
170
|
+
* What: creates an organization through `POST /iam/v4/iam/organizations/create`.
|
|
171
|
+
* Why: authorized admin UIs may need tenant organization management.
|
|
172
|
+
* How: pass IAM's create-organization payload.
|
|
173
|
+
*/
|
|
174
|
+
create: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
175
|
+
/**
|
|
176
|
+
* What: updates an organization through `POST /iam/v4/iam/organizations/{id}`.
|
|
177
|
+
* Why: organization settings screens need to edit metadata/config.
|
|
178
|
+
* How: pass the organization id and IAM's update payload.
|
|
179
|
+
*/
|
|
180
|
+
update: (id: string, request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
181
|
+
/**
|
|
182
|
+
* What: lists organizations through `GET /iam/v4/iam/organizations`.
|
|
183
|
+
* Why: admin UIs need organization browsing and selection.
|
|
184
|
+
* How: pass IAM-supported query fields such as paging/search options.
|
|
185
|
+
*/
|
|
186
|
+
list: (query?: Record<string, string | number | boolean | undefined>) => Promise<BlocksGetOrganizationsResponse>;
|
|
187
|
+
/**
|
|
188
|
+
* What: reads one organization through `GET /iam/v4/iam/organizations/{id}`.
|
|
189
|
+
* Why: organization detail screens need one organization record.
|
|
190
|
+
* How: pass the organization id from IAM.
|
|
191
|
+
*/
|
|
192
|
+
get: (id: string) => Promise<BlocksGetOrganizationResponse>;
|
|
193
|
+
/**
|
|
194
|
+
* What: lists current-user organizations through `GET /iam/v4/iam/organizations/my`.
|
|
195
|
+
* Why: apps need available organizations for org switchers and context selectors.
|
|
196
|
+
* How: call with the current user's access token.
|
|
197
|
+
*/
|
|
198
|
+
my: () => Promise<BlocksGetMyOrganizationsResponse>;
|
|
199
|
+
/**
|
|
200
|
+
* What: reads organization configuration through `GET /iam/v4/iam/organizations/config`.
|
|
201
|
+
* Why: settings screens need the active organization's current configuration.
|
|
202
|
+
* How: call with an authorized token in the desired organization context.
|
|
203
|
+
*/
|
|
204
|
+
getConfig: () => Promise<Record<string, unknown>>;
|
|
205
|
+
/**
|
|
206
|
+
* What: saves organization configuration through `POST /iam/v4/iam/organizations/config`.
|
|
207
|
+
* Why: settings screens need to persist organization-level behavior.
|
|
208
|
+
* How: pass IAM's organization config payload.
|
|
209
|
+
*/
|
|
210
|
+
saveConfig: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
211
|
+
};
|
|
212
|
+
signupSettings: {
|
|
213
|
+
/**
|
|
214
|
+
* What: reads signup settings through `GET /iam/v4/iam/signup-settings`.
|
|
215
|
+
* Why: public signup screens need tenant policy before a user is authenticated.
|
|
216
|
+
* How: call without an access token; the SDK still sends `x-blocks-key`.
|
|
217
|
+
*/
|
|
218
|
+
get: () => Promise<Record<string, unknown>>;
|
|
219
|
+
/**
|
|
220
|
+
* What: saves signup settings through `POST /iam/v4/iam/signup-settings`.
|
|
221
|
+
* Why: admin/settings screens need to configure signup policy.
|
|
222
|
+
* How: pass IAM's signup-settings payload with an authorized token.
|
|
223
|
+
*/
|
|
224
|
+
save: (request: Record<string, unknown>) => Promise<BlocksBaseResponse>;
|
|
225
|
+
};
|
|
226
|
+
}
|