@seliseblocks/client 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -1,216 +1,222 @@
1
- # Blocks Client
2
-
3
- Framework-neutral TypeScript SDK for SELISE Blocks frontend and app-runtime code.
4
-
5
- `@seliseblocks/client` gives consumer apps a small, typed wrapper around the Blocks APIs they normally call at runtime: Auth/IAM, Data, Localization, and shared HTTP configuration. Detailed `what / why / how` descriptions are kept on the SDK functions themselves so editors and generated typings show the guidance where developers use the API.
6
-
7
- Admin/control-plane work belongs in `@seliseblocks/cli-os`: project setup, schema/rules deploy, release deploy, and AI/admin terminal workflows.
8
-
9
- For AI agents and automation, see [AI_USAGE_GUIDE.md](AI_USAGE_GUIDE.md).
10
-
11
- ## Install
12
-
13
- ```bash
14
- npm install @seliseblocks/client
15
- ```
16
-
17
- Requires Node.js 20+ or a browser/runtime with `fetch`.
18
-
19
- ## Create A Client
20
-
21
- ```ts
22
- import { createBlocksClient } from "@seliseblocks/client";
23
-
24
- const blocks = createBlocksClient({
25
- apiUrl: "https://api.seliseblocks.com",
26
- xBlocksKey: "<blocks-key>",
27
- accessToken: () => currentUserSession?.accessToken,
28
- oidc: {
29
- url: "https://iam.seliseblocks.com",
30
- clientId: "<public-browser-client-id>",
31
- redirectUri: configuredRedirectUri ?? `${window.location.origin}/login/callback`
32
- }
33
- });
34
- ```
35
-
36
- `xBlocksKey` is always sent as the `x-blocks-key` header. Do not send `ProjectKey` or `projectKey` in request query/body payloads.
37
-
38
- The SDK does not store tokens. Your app owns login state, refresh scheduling, storage, and logout cleanup.
39
-
40
- Use a configured OIDC redirect URI when your app has one. The current-origin `/login/callback` URL is only a browser fallback.
41
-
42
- ## Auth
43
-
44
- Auth has two login flows.
45
-
46
- OIDC/hosted IAM login uses `auth.idp`. The SDK relies on Blocks IAM `IdpController`, sends the configured public `clientId`, and does not manually build `oidc/authorize` URLs. Refresh OIDC sessions with `auth.oidc.refreshToken()`, which calls `/iam/v4/oidc/token` and sends `client_id`.
47
-
48
- ```ts
49
- await blocks.auth.idp.redirectToProvider();
50
-
51
- const result = await blocks.auth.idp.callback(window.location.href);
52
-
53
- const refreshed = await blocks.auth.oidc.refreshToken({
54
- refreshToken: result.refresh_token,
55
- clientId: "<public-browser-client-id>"
56
- });
57
- ```
58
-
59
- Embedded/app-owned login UI uses AuthController methods directly on `auth`: `auth.login()`, `auth.socialInitiate(clientId, redirectUri)` (two positional strings, not an object), `auth.socialCallback(request)`, and `auth.refresh()`.
60
-
61
- ```ts
62
- const login = await blocks.auth.login({
63
- username: "user@example.com",
64
- password: "password"
65
- });
66
-
67
- const refreshed = await blocks.auth.refresh({
68
- refreshToken: login.refresh_token
69
- });
70
- ```
71
-
72
- Other auth APIs, such as user info, organization switch, logout, signup, recovery, activation, auth config, user codes, client credentials, and identity providers, can be used by either flow when the app has the required token/permission.
73
-
74
- `auth.oidc.clientCredentials()` is for trusted non-browser runtimes only because it requires a client secret.
75
-
76
- `auth.accessToken()` resolves the caller-owned bearer token configured on `createBlocksClient` (string or callback). `auth.isAuthenticated()` checks the current session against IAM through `GET /iam/v4/auth/me` and returns a boolean based on the raw response status - use it instead of `userInfo()` when you need a true/false signal, since IAM's hosted IdP flow may set the session as a cookie with no local `accessToken` to inspect.
77
-
78
- ```ts
79
- const config = await blocks.mfa.config();
80
- await blocks.mfa.totp.setup();
81
- await blocks.mfa.totp.verifySetup({ code: "123456" });
82
- await blocks.mfa.setMethod({ mfaType: 1 });
83
- const backupCodes = await blocks.mfa.backupCodes.generate();
84
- ```
85
-
86
- ## Mail And Notifications
87
-
88
- ```ts
89
- await blocks.mail.send({
90
- to: ["user@example.com"],
91
- purpose: "welcome",
92
- language: "en",
93
- subjectDataContext: { firstName: "Ada" }
94
- });
95
-
96
- await blocks.mail.sendToAny({
97
- to: ["qa@example.com"],
98
- purpose: "welcome",
99
- language: "en",
100
- isTestMail: true
101
- });
102
-
103
- await blocks.notifier.notify({
104
- userIds: ["user-id"],
105
- denormalizedPayload: JSON.stringify({ orderId: "123" }),
106
- saveDenormalizedPayloadAsAnObject: true
107
- });
108
-
109
- const inbox = await blocks.notifier.getNotifications({ isUnreadOnly: true, page: 1, pageSize: 20 });
110
- await blocks.notifier.markNotificationAsRead({ id: inbox.notifications[0].id });
111
- await blocks.notifier.markAllNotificationAsRead();
112
- ```
113
-
114
- `mail.send`/`mail.sendToAny` call `/logic/v4/Mail/Send`/`SendToAny`. `notifier.*` calls `/logic/v4/Notifier/*`
115
- for sending/reading notifications; tenant notification *channel configuration* (`/os/v4/Notification/*`)
116
- is an admin concern handled by `@seliseblocks/cli-os`'s `notification *` commands, not this SDK.
117
-
118
- ## Common Runtime Calls
119
-
120
- ```ts
121
- const me = await blocks.iam.me();
122
- const orgs = await blocks.iam.organizations.my();
123
- const features = await blocks.iam.resources.features();
124
- ```
125
-
126
- ```ts
127
- const schemas = await blocks.data.schemas.list();
128
- const schemaInfo = await blocks.data.schemas.infoByName("Student");
129
- const schemaRules = await blocks.data.validations.bySchemaId("schema-id");
130
-
131
- const students = blocks.data.collection("Students");
132
- const rows = await students.list({ pageNo: 1, pageSize: 20 });
133
- await students.create({ firstName: "Test" });
134
-
135
- const graph = await blocks.data.graphql({
136
- query: "{ students { items { itemId firstName } } }"
137
- });
138
- ```
139
-
140
- ```ts
141
- const upload = await blocks.data.files.presignedUploadUrl({
142
- name: "avatar.png",
143
- configurationName: "default",
144
- parentDirectoryId: "root",
145
- accessModifier: "Private"
146
- });
147
-
148
- await blocks.data.files.uploadToUrl({
149
- url: upload.uploadUrl,
150
- body: file,
151
- contentType: file.type
152
- });
153
-
154
- const items = await blocks.data.dms.list({
155
- configurationName: "default",
156
- parentId: "root",
157
- skip: 0,
158
- take: 20
159
- });
160
- ```
161
-
162
- ```ts
163
- await blocks.localization.load("en-US", ["common", "dashboard"]);
164
- const label = blocks.localization.t("dashboard.title", "Dashboard");
165
-
166
- const tenantLanguages = await blocks.localization.languagesForCurrentTenant();
167
- const selectedKeys = await blocks.localization.keysByNames({
168
- keyNames: ["dashboard.title"]
169
- });
170
- ```
171
-
172
- ## API Surface
173
-
174
- - `blocks.auth`: AuthController login, social login, refresh, org switch, logout, signup, recovery, activation, auth config, user codes, client credentials, identity providers.
175
- - `blocks.auth.idp`: hosted IdP initiate, browser redirect, callback, UI config.
176
- - `blocks.auth.oidc`: refresh-token and client-credentials token endpoint helpers.
177
- - `blocks.iam`: current user, users, roles, permissions, resources, organizations, signup settings (`blocks.iam.signupSettings`).
178
- - `blocks.data`: schema reads, validation reads, GraphQL gateway execution, file/storage helpers, DMS file/folder helpers, runtime collection CRUD.
179
- - `blocks.localization`: tenant language/module discovery, UILM dictionary loading, selected key lookup, simple `t()` lookup.
180
- - `blocks.mfa`: tenant MFA policy read/save, TOTP enrollment, OTP generate/resend/verify, method switch, disable, and backup codes.
181
- - `blocks.mail`: `send`/`sendToAny` transactional email through the tenant's configured mail provider.
182
- - `blocks.notifier`: `notify`, `getNotifications`, `getUnreadNotificationsBySubscriptionFilter`, `markNotificationAsRead`, `markAllNotificationAsRead`.
183
-
184
- Professional class names are exported for advanced typing and adapters: `BlocksAuthenticationClient`, `BlocksIAMClient`, `BlocksDataClient`, `BlocksLocalizationClient`, `BlocksMfaClient`, `BlocksMailClient`, and `BlocksNotifierClient`. `BlocksApiError` is exported for typed error handling - every non-2xx response from `http.request`/`http.external` throws it, exposing `status`, `statusText`, and the parsed `body`:
185
-
186
- ```ts
187
- try {
188
- await blocks.iam.me();
189
- } catch (error) {
190
- if (error instanceof BlocksApiError) {
191
- console.error(error.status, error.body);
192
- }
193
- }
194
- ```
195
-
196
- ## Boundaries
197
-
198
- This package must not contain:
199
-
200
- - CLI client secrets
201
- - impersonation APIs
202
- - project create/list/use
203
- - schema/rules deploy
204
- - release deploy
205
- - token/session/PKCE storage
206
- - Node filesystem or OS credential storage
207
- - framework UI components
208
- - Localization authoring/admin endpoints
209
- - Data schema/rules mutation endpoints
210
-
211
- ## Package Checks
212
-
213
- ```bash
214
- npm test
215
- npm pack --dry-run
216
- ```
1
+ # Blocks Client
2
+
3
+ Framework-neutral TypeScript SDK for SELISE Blocks frontend and app-runtime code.
4
+
5
+ `@seliseblocks/client` gives consumer apps a small, typed wrapper around the Blocks APIs they normally call at runtime: Auth/IAM, Data, Localization, and shared HTTP configuration. Detailed `what / why / how` descriptions are kept on the SDK functions themselves so editors and generated typings show the guidance where developers use the API.
6
+
7
+ Admin/control-plane work belongs in `@seliseblocks/cli-os`: project setup, schema/rules deploy, release deploy, and AI/admin terminal workflows.
8
+
9
+ For AI agents and automation, see [AI_USAGE_GUIDE.md](AI_USAGE_GUIDE.md).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @seliseblocks/client@latest
15
+ ```
16
+
17
+ Requires Node.js 20+ or a browser/runtime with `fetch`.
18
+
19
+ ## Create A Client
20
+
21
+ ```ts
22
+ import { createBlocksClient } from "@seliseblocks/client";
23
+
24
+ const blocks = createBlocksClient({
25
+ apiUrl: "https://api.seliseblocks.com",
26
+ xBlocksKey: "<blocks-key>",
27
+ accessToken: () => currentUserSession?.accessToken,
28
+ oidc: {
29
+ url: "https://iam.seliseblocks.com",
30
+ clientId: "<public-browser-client-id>",
31
+ redirectUri: configuredRedirectUri ?? `${window.location.origin}/login/callback`
32
+ }
33
+ });
34
+ ```
35
+
36
+ `xBlocksKey` is always sent as the `x-blocks-key` header. Do not send `ProjectKey` or `projectKey` in request query/body payloads.
37
+
38
+ The SDK does not store tokens. Your app owns login state, refresh scheduling, storage, and logout cleanup.
39
+
40
+ Use a configured OIDC redirect URI when your app has one. The current-origin `/login/callback` URL is only a browser fallback.
41
+
42
+ ## Auth
43
+
44
+ Auth has two login flows.
45
+
46
+ OIDC/hosted IAM login uses `auth.idp`. The SDK relies on Blocks IAM `IdpController`, sends the configured public `clientId`, and does not manually build `oidc/authorize` URLs. Refresh OIDC sessions with `auth.oidc.refreshToken()`, which calls `/iam/v4/oidc/token` and sends `client_id`.
47
+
48
+ ```ts
49
+ await blocks.auth.idp.redirectToProvider();
50
+
51
+ const result = await blocks.auth.idp.callback(window.location.href);
52
+
53
+ const refreshed = await blocks.auth.oidc.refreshToken({
54
+ refreshToken: result.refresh_token,
55
+ clientId: "<public-browser-client-id>"
56
+ });
57
+ ```
58
+
59
+ Embedded/app-owned login UI uses AuthController methods directly on `auth`: `auth.login()`, `auth.socialInitiate(clientId, redirectUri)` (two positional strings, not an object), `auth.socialCallback(request)`, and `auth.refresh()`.
60
+
61
+ ```ts
62
+ const login = await blocks.auth.login({
63
+ username: "user@example.com",
64
+ password: "password"
65
+ });
66
+
67
+ const refreshed = await blocks.auth.refresh({
68
+ refreshToken: login.refresh_token
69
+ });
70
+ ```
71
+
72
+ Other auth APIs, such as user info, organization switch, logout, signup, recovery, activation, auth config, user codes, client credentials, and identity providers, can be used by either flow when the app has the required token/permission.
73
+
74
+ `auth.oidc.clientCredentials()` is for trusted non-browser runtimes only because it requires a client secret.
75
+
76
+ `auth.accessToken()` resolves the caller-owned bearer token configured on `createBlocksClient` (string or callback). `auth.isAuthenticated()` checks the current session against IAM through `GET /iam/v4/auth/me` and returns a boolean based on the raw response status - use it instead of `userInfo()` when you need a true/false signal, since IAM's hosted IdP flow may set the session as a cookie with no local `accessToken` to inspect.
77
+
78
+ ```ts
79
+ const config = await blocks.mfa.config();
80
+ await blocks.mfa.totp.setup();
81
+ await blocks.mfa.totp.verifySetup({ code: "123456" });
82
+ await blocks.mfa.setMethod({ mfaType: 1 });
83
+ const backupCodes = await blocks.mfa.backupCodes.generate();
84
+ ```
85
+
86
+ ## Mail And Notifications
87
+
88
+ ```ts
89
+ await blocks.mail.send({
90
+ to: ["user@example.com"],
91
+ purpose: "welcome",
92
+ language: "en",
93
+ subjectDataContext: { firstName: "Ada" }
94
+ });
95
+
96
+ await blocks.mail.sendToAny({
97
+ to: ["qa@example.com"],
98
+ purpose: "welcome",
99
+ language: "en",
100
+ isTestMail: true
101
+ });
102
+
103
+ await blocks.notifier.notify({
104
+ userIds: ["user-id"],
105
+ denormalizedPayload: JSON.stringify({ orderId: "123" }),
106
+ saveDenormalizedPayloadAsAnObject: true
107
+ });
108
+
109
+ const inbox = await blocks.notifier.getNotifications({ isUnreadOnly: true, page: 1, pageSize: 20 });
110
+ await blocks.notifier.markNotificationAsRead({ id: inbox.notifications[0].id });
111
+ await blocks.notifier.markAllNotificationAsRead();
112
+ ```
113
+
114
+ `mail.send`/`mail.sendToAny` call `/logic/v4/Mail/Send`/`SendToAny`. `notifier.*` calls `/logic/v4/Notifier/*`
115
+ for sending/reading notifications; tenant notification *channel configuration* (`/os/v4/Notification/*`)
116
+ is an admin concern handled by `@seliseblocks/cli-os`'s `notification *` commands, not this SDK.
117
+
118
+ ## Common Runtime Calls
119
+
120
+ ```ts
121
+ const me = await blocks.iam.me();
122
+ const orgs = await blocks.iam.organizations.my();
123
+ const features = await blocks.iam.resources.features();
124
+ ```
125
+
126
+ `iam.organizations.my()` returns the IAM envelope with `organizations`, not `data`.
127
+
128
+ ```ts
129
+ const schemas = await blocks.data.schemas.list();
130
+ const schemaInfo = await blocks.data.schemas.infoByName("Student");
131
+ const schemaRules = await blocks.data.validations.bySchemaId("schema-id");
132
+
133
+ const students = blocks.data.collection("Students");
134
+ const rows = await students.list({ pageNo: 1, pageSize: 20 });
135
+ await students.create({ firstName: "Test" });
136
+
137
+ const graph = await blocks.data.graphql({
138
+ query: "{ students { items { itemId firstName } } }"
139
+ });
140
+ ```
141
+
142
+ ```ts
143
+ const upload = await blocks.data.files.presignedUploadUrl({
144
+ name: "avatar.png",
145
+ configurationName: "default",
146
+ parentDirectoryId: "root",
147
+ accessModifier: "Private"
148
+ });
149
+
150
+ await blocks.data.files.uploadToUrl({
151
+ url: upload.uploadUrl,
152
+ body: file,
153
+ contentType: file.type
154
+ });
155
+
156
+ const items = await blocks.data.objects.list({
157
+ parentDirectoryId: "root",
158
+ limit: 20
159
+ });
160
+
161
+ const directory = await blocks.data.directories.create({
162
+ name: "Contracts",
163
+ parentDirectoryId: "root",
164
+ allowedFileExtensions: ["pdf", "docx"]
165
+ });
166
+ ```
167
+
168
+ ```ts
169
+ await blocks.localization.load("en-US", ["common", "dashboard"]);
170
+ const label = blocks.localization.t("dashboard.title", "Dashboard");
171
+
172
+ const tenantLanguages = await blocks.localization.languagesForCurrentTenant();
173
+ const selectedKeys = await blocks.localization.keysByNames({
174
+ keyNames: ["dashboard.title"]
175
+ });
176
+ ```
177
+
178
+ ## API Surface
179
+
180
+ - `blocks.auth`: AuthController login, social login, refresh, org switch, logout, signup, recovery, activation, auth config, user codes, client credentials, identity providers.
181
+ - `blocks.auth.idp`: hosted IdP initiate, browser redirect, callback, UI config.
182
+ - `blocks.auth.oidc`: refresh-token and client-credentials token endpoint helpers.
183
+ - `blocks.iam`: current user, users, roles, permissions, resources, organizations, signup settings (`blocks.iam.signupSettings`).
184
+ - `blocks.data`: schema reads, validation reads, GraphQL gateway execution, file/directory/object-tree storage helpers, and runtime collection CRUD.
185
+ - `blocks.localization`: tenant language/module discovery, UILM dictionary loading, selected key lookup, simple `t()` lookup.
186
+ - `blocks.mfa`: tenant MFA policy read/save, TOTP enrollment, OTP generate/resend/verify, method switch, disable, and backup codes.
187
+ - `blocks.mail`: `send`/`sendToAny` transactional email through the tenant's configured mail provider.
188
+ - `blocks.notifier`: `notify`, `getNotifications`, `getUnreadNotificationsBySubscriptionFilter`, `markNotificationAsRead`, `markAllNotificationAsRead`.
189
+
190
+ Professional class names are exported for advanced typing and adapters: `BlocksAuthenticationClient`, `BlocksIAMClient`, `BlocksDataClient`, `BlocksLocalizationClient`, `BlocksMfaClient`, `BlocksMailClient`, and `BlocksNotifierClient`. `BlocksApiError` is exported for typed error handling - every non-2xx response from `http.request`/`http.external` throws it, exposing `status`, `statusText`, and the parsed `body`:
191
+
192
+ ```ts
193
+ try {
194
+ await blocks.iam.me();
195
+ } catch (error) {
196
+ if (error instanceof BlocksApiError) {
197
+ console.error(error.status, error.body);
198
+ }
199
+ }
200
+ ```
201
+
202
+ ## Boundaries
203
+
204
+ This package must not contain:
205
+
206
+ - CLI client secrets
207
+ - impersonation APIs
208
+ - project create/list/use
209
+ - schema/rules deploy
210
+ - release deploy
211
+ - token/session/PKCE storage
212
+ - Node filesystem or OS credential storage
213
+ - framework UI components
214
+ - Localization authoring/admin endpoints
215
+ - Data schema/rules mutation endpoints
216
+
217
+ ## Package Checks
218
+
219
+ ```bash
220
+ npm test
221
+ npm pack --dry-run
222
+ ```
@@ -1,5 +1,5 @@
1
1
  import { BlocksHttpClient } from "../http/http-client.js";
2
- import { BlocksDataCollection, BlocksDataCollectionOptions, BlocksDmsCreateFolderRequest, BlocksDmsListRequest, BlocksDmsUploadRequest, BlocksFileDeleteRequest, BlocksFileGetOptions, BlocksFileInfoListRequest, BlocksDataSchema, BlocksFileListRequest, BlocksFileUpdateAdditionalInfoRequest, BlocksFileUploadRequest, BlocksFolderDeleteRequest, BlocksGraphqlRequest, BlocksLocalStorageUploadRequest, BlocksPagedResult, BlocksRegexGenerateRequest, BlocksSchemaFieldValidationOptions, BlocksSchemaListOptions, BlocksSchemaValidationListOptions, BlocksUploadToUrlRequest } from "./types.js";
2
+ import { BlocksDataCollection, BlocksDataCollectionOptions, BlocksDirectoryCreateRequest, BlocksDirectoryDeleteRequest, BlocksDirectoryMoveRequest, BlocksDirectoryUpdateRequest, BlocksFileCopyRequest, BlocksFileCreateVersionRequest, BlocksFileDeleteRequest, BlocksFileGetOptions, BlocksFileInfoListRequest, BlocksFileMoveRequest, BlocksFileRenameRequest, BlocksFileVersionsRequest, BlocksDataSchema, BlocksFileListRequest, BlocksFileUpdateAdditionalInfoRequest, BlocksFileUploadRequest, BlocksGraphqlRequest, BlocksLocalStorageUploadRequest, BlocksPagedResult, BlocksRegexGenerateRequest, BlocksSchemaFieldValidationOptions, BlocksSchemaListOptions, BlocksSchemaValidationListOptions, BlocksStorageAccessPolicyRequest, BlocksStorageObjectListRequest, BlocksStorageObjectPageRequest, BlocksStorageObjectSearchRequest, BlocksStorageObjectsResponse, BlocksStorageResourceRequest, BlocksStorageRevokeAccessRequest, BlocksStorageShareRequest, BlocksStorageToggleInheritanceRequest, BlocksUploadToUrlRequest } from "./types.js";
3
3
  export declare class BlocksDataClient {
4
4
  private readonly http;
5
5
  constructor(http: BlocksHttpClient);
@@ -43,27 +43,27 @@ export declare class BlocksDataClient {
43
43
  };
44
44
  files: {
45
45
  /**
46
- * What: reads one file record through `GET /data/v4/Files/GetFile`.
46
+ * What: reads one file record through the current file download operation.
47
47
  * Why: frontend views need file metadata or a downloadable reference by file id.
48
48
  * How: pass `fileId` and optional Data file configuration/version fields.
49
49
  */
50
50
  get: (fileId: string, options?: BlocksFileGetOptions) => Promise<unknown>;
51
51
  /**
52
- * What: batch-reads files through `POST /data/v4/Files/GetFiles`.
52
+ * What: batch-reads file metadata and download URLs.
53
53
  * Why: pages with many attachments should avoid one request per file.
54
54
  * How: pass the file-list payload exactly as Data expects; the SDK does not inject project fields.
55
55
  */
56
56
  getMany: (request: BlocksFileListRequest) => Promise<unknown>;
57
57
  /**
58
- * What: lists file records and metadata through `POST /data/v4/Files/GetFilesInfo`.
58
+ * What: lists file records and metadata.
59
59
  * Why: storage browsers and attachment managers need paged file metadata before downloading content.
60
60
  * How: pass paging, sort, and filter fields; the SDK sends your request without any `projectKey`.
61
61
  */
62
62
  info: (request: BlocksFileInfoListRequest) => Promise<unknown>;
63
63
  /**
64
- * What: requests an upload URL through `POST /data/v4/Files/GetPreSignedUrlForUpload`.
64
+ * What: creates file/version metadata and requests a pre-signed upload URL.
65
65
  * Why: browser apps should upload binary content through the URL issued by Blocks Data.
66
- * How: pass file metadata such as `name`, `contentType`, `configurationName`, and optional DMS fields.
66
+ * How: pass file metadata plus a parent directory id or module default.
67
67
  */
68
68
  presignedUploadUrl: (request: BlocksFileUploadRequest) => Promise<unknown>;
69
69
  /**
@@ -73,55 +73,50 @@ export declare class BlocksDataClient {
73
73
  */
74
74
  uploadToUrl: (request: BlocksUploadToUrlRequest) => Promise<unknown>;
75
75
  /**
76
- * What: uploads a file through `POST /data/v4/Files/UploadFileToLocalStorage`.
76
+ * What: creates a file/version and uploads its bytes to local storage.
77
77
  * Why: local-storage deployments need multipart upload through Blocks Data instead of a pre-signed cloud URL.
78
78
  * How: pass a `Blob`/`File` and metadata; the SDK builds `FormData` and does not add `projectKey`.
79
79
  */
80
80
  uploadToLocalStorage: (request: BlocksLocalStorageUploadRequest) => Promise<unknown>;
81
81
  /**
82
- * What: deletes a file through `POST /data/v4/Files/DeleteFile`.
82
+ * What: moves a file to trash or permanently deletes it.
83
83
  * Why: storage UIs need to remove files when permissions and Data rules allow it.
84
- * How: pass `fileId` and optional `configurationName`; the SDK sends no project key.
84
+ * How: pass `fileId` and an explicit `permanent` choice; false moves to trash.
85
85
  */
86
86
  delete: (request: BlocksFileDeleteRequest) => Promise<unknown>;
87
87
  /**
88
- * What: updates file additional properties through `POST /data/v4/Files/UpdateFileAdditionalInfo`.
88
+ * What: updates file additional properties.
89
89
  * Why: apps often need to attach searchable metadata such as agent status or business references to a file.
90
90
  * How: pass `itemId` and `additionalProperties`; the SDK forwards the request as-is except for not adding project fields.
91
91
  */
92
92
  updateAdditionalInfo: (request: BlocksFileUpdateAdditionalInfoRequest) => Promise<unknown>;
93
- /**
94
- * What: reads DMS file/folder entries through `POST /data/v4/Files/GetDmsFileAndFolder`.
95
- * Why: document-management views need combined folder and file listings.
96
- * How: pass Data's DMS listing payload exactly as your app builds it.
97
- */
98
- listFolder: (request: BlocksFileListRequest) => Promise<unknown>;
93
+ versions: (request: BlocksFileVersionsRequest) => Promise<unknown>;
94
+ createVersion: (request: BlocksFileCreateVersionRequest) => Promise<unknown>;
95
+ copy: (request: BlocksFileCopyRequest) => Promise<unknown>;
96
+ move: (request: BlocksFileMoveRequest) => Promise<unknown>;
97
+ rename: (request: BlocksFileRenameRequest) => Promise<unknown>;
99
98
  };
100
- dms: {
101
- /**
102
- * What: lists DMS files and folders through `POST /data/v4/Files/GetDmsFileAndFolder`.
103
- * Why: document-management screens need folder contents, search, skip/take paging, and file entries together.
104
- * How: pass DMS listing fields such as `parentId`, `configurationName`, `searchKey`, `skip`, and `take`.
105
- */
106
- list: (request: BlocksDmsListRequest) => Promise<unknown>;
107
- /**
108
- * What: registers uploaded files in DMS through `POST /data/v4/Files/UploadFile`.
109
- * Why: after binary upload, DMS needs artifact metadata so files appear in document folders.
110
- * How: pass the `upload` array with file storage ids and metadata returned from the upload flow.
111
- */
112
- uploadFiles: (request: BlocksDmsUploadRequest) => Promise<unknown>;
113
- /**
114
- * What: creates a DMS folder through `POST /data/v4/Files/CreateFolder`.
115
- * Why: document-management UIs need to create folder hierarchy for uploaded files.
116
- * How: pass folder metadata such as `artifactName`, `parentId`, and optional `configurationName`.
117
- */
118
- createFolder: (request: BlocksDmsCreateFolderRequest) => Promise<unknown>;
119
- /**
120
- * What: deletes a DMS folder through `POST /data/v4/Files/DeleteFolder`.
121
- * Why: document-management UIs need to remove empty or allowed folders.
122
- * How: pass `folderId` and optional `configurationName`; the SDK sends no project key.
123
- */
124
- deleteFolder: (request: BlocksFolderDeleteRequest) => Promise<unknown>;
99
+ directories: {
100
+ create: (request: BlocksDirectoryCreateRequest) => Promise<unknown>;
101
+ get: (directoryId: string) => Promise<unknown>;
102
+ update: (request: BlocksDirectoryUpdateRequest) => Promise<unknown>;
103
+ delete: (request: BlocksDirectoryDeleteRequest) => Promise<unknown>;
104
+ move: (request: BlocksDirectoryMoveRequest) => Promise<unknown>;
105
+ };
106
+ objects: {
107
+ list: (request?: BlocksStorageObjectListRequest) => Promise<BlocksStorageObjectsResponse>;
108
+ search: (request: BlocksStorageObjectSearchRequest) => Promise<BlocksStorageObjectsResponse>;
109
+ trash: (request?: BlocksStorageObjectPageRequest) => Promise<BlocksStorageObjectsResponse>;
110
+ shared: (request?: BlocksStorageObjectPageRequest) => Promise<BlocksStorageObjectsResponse>;
111
+ restore: (request: BlocksStorageResourceRequest) => Promise<unknown>;
112
+ deleteFromTrash: (request: BlocksStorageResourceRequest) => Promise<unknown>;
113
+ accessPolicies: (resourceId: string) => Promise<unknown>;
114
+ grantAccess: (request: BlocksStorageAccessPolicyRequest) => Promise<unknown>;
115
+ updateAccess: (request: BlocksStorageAccessPolicyRequest) => Promise<unknown>;
116
+ revokeAccess: (request: BlocksStorageRevokeAccessRequest) => Promise<unknown>;
117
+ resolveAccess: (resourceId: string) => Promise<unknown>;
118
+ toggleInheritance: (request: BlocksStorageToggleInheritanceRequest) => Promise<unknown>;
119
+ share: (request: BlocksStorageShareRequest) => Promise<unknown>;
125
120
  };
126
121
  validations: {
127
122
  /**