@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/AI_USAGE_GUIDE.md +165 -164
- package/LICENSE +21 -21
- package/README.md +222 -216
- package/dist/data/data-client.d.ts +36 -41
- package/dist/data/data-client.js +116 -85
- package/dist/data/types.d.ts +124 -33
- package/dist/iam/types.d.ts +3 -1
- package/dist/index.d.ts +1 -1
- package/package.json +48 -48
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
- `blocks.
|
|
181
|
-
- `blocks.
|
|
182
|
-
- `blocks.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
-
|
|
207
|
-
-
|
|
208
|
-
-
|
|
209
|
-
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
/**
|