@seliseblocks/client 0.1.1 → 0.1.3

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,161 +1,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
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()`, `auth.socialCallback()`, 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
- ## Common Runtime Calls
77
-
78
- ```ts
79
- const me = await blocks.iam.me();
80
- const orgs = await blocks.iam.organizations.my();
81
- const features = await blocks.iam.resources.features();
82
- ```
83
-
84
- ```ts
85
- const schemas = await blocks.data.schemas.list();
86
- const schemaInfo = await blocks.data.schemas.infoByName("Student");
87
- const schemaRules = await blocks.data.validations.bySchemaId("schema-id");
88
-
89
- const students = blocks.data.collection("Students");
90
- const rows = await students.list({ pageNo: 1, pageSize: 20 });
91
- await students.create({ firstName: "Test" });
92
-
93
- const graph = await blocks.data.graphql({
94
- query: "{ students { items { itemId firstName } } }"
95
- });
96
- ```
97
-
98
- ```ts
99
- const upload = await blocks.data.files.presignedUploadUrl({
100
- name: "avatar.png",
101
- configurationName: "default",
102
- parentDirectoryId: "root",
103
- accessModifier: "Private"
104
- });
105
-
106
- await blocks.data.files.uploadToUrl({
107
- url: upload.uploadUrl,
108
- body: file,
109
- contentType: file.type
110
- });
111
-
112
- const items = await blocks.data.dms.list({
113
- configurationName: "default",
114
- parentId: "root",
115
- skip: 0,
116
- take: 20
117
- });
118
- ```
119
-
120
- ```ts
121
- await blocks.localization.load("en-US", ["common", "dashboard"]);
122
- const label = blocks.localization.t("dashboard.title", "Dashboard");
123
-
124
- const tenantLanguages = await blocks.localization.languagesForCurrentTenant();
125
- const selectedKeys = await blocks.localization.keysByNames({
126
- keyNames: ["dashboard.title"]
127
- });
128
- ```
129
-
130
- ## API Surface
131
-
132
- - `blocks.auth`: AuthController login, social login, refresh, org switch, logout, signup, recovery, activation, auth config, user codes, client credentials, identity providers.
133
- - `blocks.auth.idp`: hosted IdP initiate, browser redirect, callback, UI config.
134
- - `blocks.auth.oidc`: refresh-token and client-credentials token endpoint helpers.
135
- - `blocks.iam`: current user, users, roles, permissions, resources, organizations, signup settings.
136
- - `blocks.data`: schema reads, validation reads, GraphQL gateway execution, file/storage helpers, DMS file/folder helpers, runtime collection CRUD.
137
- - `blocks.localization`: tenant language/module discovery, UILM dictionary loading, selected key lookup, simple `t()` lookup.
138
-
139
- Professional class names are exported for advanced typing and adapters: `BlocksAuthenticationClient`, `BlocksIAMClient`, `BlocksDataClient`, and `BlocksLocalizationClient`.
140
-
141
- ## Boundaries
142
-
143
- This package must not contain:
144
-
145
- - CLI client secrets
146
- - impersonation APIs
147
- - project create/list/use
148
- - schema/rules deploy
149
- - release deploy
150
- - token/session/PKCE storage
151
- - Node filesystem or OS credential storage
152
- - framework UI components
153
- - Localization authoring/admin endpoints
154
- - Data schema/rules mutation endpoints
155
-
156
- ## Package Checks
157
-
158
- ```bash
159
- npm test
160
- npm pack --dry-run
161
- ```
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
+ ```
package/dist/client.d.ts CHANGED
@@ -3,6 +3,9 @@ import { BlocksDataClient } from "./data/data-client.js";
3
3
  import { BlocksHttpClient } from "./http/http-client.js";
4
4
  import { BlocksIAMClient } from "./iam/iam-client.js";
5
5
  import { BlocksLocalizationClient } from "./localization/localization-client.js";
6
+ import { BlocksMailClient } from "./mail/mail-client.js";
7
+ import { BlocksMfaClient } from "./mfa/mfa-client.js";
8
+ import { BlocksNotifierClient } from "./notifier/notifier-client.js";
6
9
  export type BlocksOidcConfig = {
7
10
  /**
8
11
  * Public browser OIDC client id used by Blocks IAM IdpController and refresh-token calls.
@@ -55,6 +58,9 @@ export type BlocksClient = {
55
58
  http: BlocksHttpClient;
56
59
  iam: BlocksIAMClient;
57
60
  localization: BlocksLocalizationClient;
61
+ mail: BlocksMailClient;
62
+ mfa: BlocksMfaClient;
63
+ notifier: BlocksNotifierClient;
58
64
  };
59
65
  export type RequiredConfig = {
60
66
  accessToken?: string | (() => Promise<string | undefined> | string | undefined);
package/dist/client.js CHANGED
@@ -3,6 +3,9 @@ import { BlocksDataClient } from "./data/data-client.js";
3
3
  import { BlocksHttpClient } from "./http/http-client.js";
4
4
  import { BlocksIAMClient } from "./iam/iam-client.js";
5
5
  import { BlocksLocalizationClient } from "./localization/localization-client.js";
6
+ import { BlocksMailClient } from "./mail/mail-client.js";
7
+ import { BlocksMfaClient } from "./mfa/mfa-client.js";
8
+ import { BlocksNotifierClient } from "./notifier/notifier-client.js";
6
9
  /**
7
10
  * What: creates a framework-neutral Blocks SDK instance for one tenant/app runtime.
8
11
  * Why: frontend code needs a single configured entry point for IAM, Auth, Data, and Localization APIs.
@@ -18,7 +21,10 @@ export function createBlocksClient(config) {
18
21
  data: new BlocksDataClient(http),
19
22
  http,
20
23
  iam: new BlocksIAMClient(http),
21
- localization: new BlocksLocalizationClient(http)
24
+ localization: new BlocksLocalizationClient(http),
25
+ mail: new BlocksMailClient(http),
26
+ mfa: new BlocksMfaClient(http),
27
+ notifier: new BlocksNotifierClient(http)
22
28
  };
23
29
  }
24
30
  function normalizeConfig(config) {
@@ -85,7 +85,7 @@ export declare class BlocksDataClient {
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 through `POST /data/v4/Files/UpdateFileAdditionalInfo`.
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
  */
@@ -124,11 +124,11 @@ export class BlocksDataClient {
124
124
  body: withoutProjectKey(request)
125
125
  }),
126
126
  /**
127
- * What: updates file additional properties through `POST /data/v4/Files/updateFileAdditionalInfo`.
127
+ * What: updates file additional properties through `POST /data/v4/Files/UpdateFileAdditionalInfo`.
128
128
  * Why: apps often need to attach searchable metadata such as agent status or business references to a file.
129
129
  * How: pass `itemId` and `additionalProperties`; the SDK forwards the request as-is except for not adding project fields.
130
130
  */
131
- updateAdditionalInfo: (request) => this.http.request(`${DATA_API}/Files/updateFileAdditionalInfo`, {
131
+ updateAdditionalInfo: (request) => this.http.request(`${DATA_API}/Files/UpdateFileAdditionalInfo`, {
132
132
  body: withoutProjectKey(request)
133
133
  }),
134
134
  /**
@@ -258,13 +258,13 @@ export class BlocksDataClient {
258
258
  */
259
259
  create: (payload) => this.graphql({
260
260
  operationName: createField,
261
- query: `mutation ${createField}($input: ${schemaName}InsertInput!) {
262
- ${createField}(input: $input) {
263
- acknowledged
264
- itemId
265
- message
266
- totalImpactedData
267
- }
261
+ query: `mutation ${createField}($input: ${schemaName}InsertInput!) {
262
+ ${createField}(input: $input) {
263
+ acknowledged
264
+ itemId
265
+ message
266
+ totalImpactedData
267
+ }
268
268
  }`,
269
269
  variables: { input: payload }
270
270
  }),
@@ -275,13 +275,13 @@ export class BlocksDataClient {
275
275
  */
276
276
  delete: (itemId, deleteOptions = {}) => this.graphql({
277
277
  operationName: deleteField,
278
- query: `mutation ${deleteField}($filter: String, $input: ${schemaName}DeleteInput!) {
279
- ${deleteField}(filter: $filter, input: $input) {
280
- acknowledged
281
- itemId
282
- message
283
- totalImpactedData
284
- }
278
+ query: `mutation ${deleteField}($filter: String, $input: ${schemaName}DeleteInput!) {
279
+ ${deleteField}(filter: $filter, input: $input) {
280
+ acknowledged
281
+ itemId
282
+ message
283
+ totalImpactedData
284
+ }
285
285
  }`,
286
286
  variables: {
287
287
  filter: itemIdFilter(itemId),
@@ -323,13 +323,13 @@ export class BlocksDataClient {
323
323
  */
324
324
  update: (itemId, payload) => this.graphql({
325
325
  operationName: updateField,
326
- query: `mutation ${updateField}($filter: String, $input: ${schemaName}UpdateInput!) {
327
- ${updateField}(filter: $filter, input: $input) {
328
- acknowledged
329
- itemId
330
- message
331
- totalImpactedData
332
- }
326
+ query: `mutation ${updateField}($filter: String, $input: ${schemaName}UpdateInput!) {
327
+ ${updateField}(filter: $filter, input: $input) {
328
+ acknowledged
329
+ itemId
330
+ message
331
+ totalImpactedData
332
+ }
333
333
  }`,
334
334
  variables: {
335
335
  filter: itemIdFilter(itemId),
@@ -441,18 +441,18 @@ function dynamicQueryInput(options) {
441
441
  };
442
442
  }
443
443
  function collectionListQuery(fieldName, selection) {
444
- return `query ${fieldName}($input: DynamicQueryInput) {
445
- ${fieldName}(input: $input) {
446
- items {
447
- ${indent(selection, 6)}
448
- }
449
- totalCount
450
- pageNo
451
- pageSize
452
- totalPages
453
- hasNextPage
454
- hasPreviousPage
455
- }
444
+ return `query ${fieldName}($input: DynamicQueryInput) {
445
+ ${fieldName}(input: $input) {
446
+ items {
447
+ ${indent(selection, 6)}
448
+ }
449
+ totalCount
450
+ pageNo
451
+ pageSize
452
+ totalPages
453
+ hasNextPage
454
+ hasPreviousPage
455
+ }
456
456
  }`;
457
457
  }
458
458
  function selectionFor(fields) {
package/dist/index.d.ts CHANGED
@@ -5,8 +5,14 @@ export type { BlocksClient, BlocksClientConfig, BlocksOidcConfig } from "./clien
5
5
  export { BlocksApiError } from "./http/errors.js";
6
6
  export { BlocksIAMClient } from "./iam/iam-client.js";
7
7
  export { BlocksLocalizationClient } from "./localization/localization-client.js";
8
+ export { BlocksMailClient } from "./mail/mail-client.js";
9
+ export { BlocksMfaClient } from "./mfa/mfa-client.js";
10
+ export { BlocksNotifierClient } from "./notifier/notifier-client.js";
8
11
  export type { BlocksAuthPassThroughResponse, BlocksAuthResponse, BlocksClientCredentialsRequest, BlocksAuthLoginRequest, BlocksIdpCallbackRequest, BlocksIdpInitiateRequest, BlocksIdpInitiateResponse, BlocksLoginOption, BlocksLogoutRequest, BlocksOidcRefreshRequest, BlocksOidcUserInfo, BlocksRefreshRequest, BlocksSocialLoginRequest, BlocksSwitchOrganizationRequest } from "./auth/auth-client.js";
9
12
  export type { BlocksRequestOptions } from "./types.js";
10
13
  export type { BlocksBaseResponse, BlocksGetMyOrganizationsResponse, BlocksGetOrganizationResponse, BlocksGetOrganizationsResponse, BlocksGetPermissionResponse, BlocksGetPermissionsResponse, BlocksGetRoleResponse, BlocksGetRolesResponse, BlocksGetUserResponse, BlocksGetUsersResponse, BlocksIamListRequest, BlocksMeResponse, BlocksOrganization, BlocksPermission, BlocksQueryListResponse, BlocksQueryResponse, BlocksRole, BlocksUser } from "./iam/types.js";
11
14
  export type { BlocksDataCollection, BlocksDataListOptions, BlocksDmsCreateFolderRequest, BlocksDmsListRequest, BlocksDmsMetaDataValue, BlocksDmsUploadItem, BlocksDmsUploadRequest, BlocksFileDeleteRequest, BlocksFileGetOptions, BlocksFileInfoListRequest, BlocksFileListRequest, BlocksFileUpdateAdditionalInfoRequest, BlocksFileUploadRequest, BlocksFolderDeleteRequest, BlocksGraphqlRequest, BlocksLocalStorageUploadRequest, BlocksPagedResult, BlocksRegexGenerateRequest, BlocksSchemaFieldValidationOptions, BlocksSchemaListOptions, BlocksSchemaValidationListOptions, BlocksUploadToUrlRequest } from "./data/types.js";
12
- export type { BlocksLocalizationDictionary, BlocksLocalizationKey, BlocksLocalizationKeysByNamesRequest, BlocksLocalizationKeysByNamesResponse, BlocksLocalizationLanguage, BlocksLocalizationModule, BlocksLocalizationTranslationOptions } from "./localization/types.js";
15
+ export type { BlocksLocalizationDictionary, BlocksLocalizationKey, BlocksLocalizationKeyResource, BlocksLocalizationKeysByNamesRequest, BlocksLocalizationKeysByNamesResponse, BlocksLocalizationLanguage, BlocksLocalizationModule, BlocksLocalizationTranslationOptions } from "./localization/types.js";
16
+ export type { BlocksMfaBackupCodeUseRequest, BlocksMfaConfig, BlocksMfaConfigSaveRequest, BlocksMfaGenerateRequest, BlocksMfaPassThroughResponse, BlocksMfaResendRequest, BlocksMfaSetMethodRequest, BlocksMfaVerifyRequest, BlocksMfaVerifyTotpSetupRequest } from "./mfa/types.js";
17
+ export type { BlocksMailPassThroughResponse, BlocksSendMailRequest, BlocksSendMailToAnyRequest } from "./mail/types.js";
18
+ export type { BlocksGetNotificationsOptions, BlocksGetNotificationsResponse, BlocksGetUnreadNotificationsBySubscriptionFilterRequest, BlocksMarkNotificationAsReadRequest, BlocksNotifierPassThroughResponse, BlocksNotifierSubscriptionFilter, BlocksNotifyRequest, BlocksOfflineNotification } from "./notifier/types.js";
package/dist/index.js CHANGED
@@ -4,3 +4,6 @@ export { BlocksDataClient } from "./data/data-client.js";
4
4
  export { BlocksApiError } from "./http/errors.js";
5
5
  export { BlocksIAMClient } from "./iam/iam-client.js";
6
6
  export { BlocksLocalizationClient } from "./localization/localization-client.js";
7
+ export { BlocksMailClient } from "./mail/mail-client.js";
8
+ export { BlocksMfaClient } from "./mfa/mfa-client.js";
9
+ export { BlocksNotifierClient } from "./notifier/notifier-client.js";
@@ -18,12 +18,20 @@ export type BlocksLocalizationTranslationOptions = {
18
18
  language: string;
19
19
  moduleName: string;
20
20
  };
21
+ export type BlocksLocalizationKeyResource = {
22
+ characterLength?: number;
23
+ culture?: string;
24
+ value?: string;
25
+ };
21
26
  export type BlocksLocalizationKey = Record<string, unknown> & {
27
+ context?: string;
28
+ isNewKey?: boolean;
29
+ isPartiallyTranslated?: boolean;
22
30
  itemId?: string;
23
31
  keyName?: string;
24
32
  moduleId?: string;
25
- moduleName?: string;
26
- values?: Record<string, unknown>;
33
+ resources?: BlocksLocalizationKeyResource[];
34
+ routes?: string[];
27
35
  };
28
36
  export type BlocksLocalizationKeysByNamesRequest = {
29
37
  keyNames: string[];
@@ -0,0 +1,23 @@
1
+ import { BlocksHttpClient } from "../http/http-client.js";
2
+ import { BlocksMailPassThroughResponse, BlocksSendMailRequest, BlocksSendMailToAnyRequest } from "./types.js";
3
+ /**
4
+ * Mail sending surface: fires a purpose/language-templated email through the tenant's
5
+ * configured mail provider. Mail server/template/mailbox management (Mail/Save, Mail/Get,
6
+ * templates, mailbox reads) is a CLI/admin concern and is not exposed here.
7
+ */
8
+ export declare class BlocksMailClient {
9
+ private readonly http;
10
+ constructor(http: BlocksHttpClient);
11
+ /**
12
+ * What: sends an email through `POST /logic/v4/Mail/Send` using the tenant's default mail configuration.
13
+ * Why: app code needs to trigger transactional email (welcome, password reset, alerts) without managing SMTP directly.
14
+ * How: pass recipients plus `purpose`/`language` to select the right template, and `subjectDataContext`/`bodyDataContext` for placeholder values.
15
+ */
16
+ send(request: BlocksSendMailRequest): Promise<BlocksMailPassThroughResponse>;
17
+ /**
18
+ * What: sends an email through `POST /logic/v4/Mail/SendToAny`.
19
+ * Why: some sends need a provider-routing hint the default `send` doesn't take, such as marking a test send.
20
+ * How: same fields as `send`, plus `isTestMail`.
21
+ */
22
+ sendToAny(request: BlocksSendMailToAnyRequest): Promise<BlocksMailPassThroughResponse>;
23
+ }
@@ -0,0 +1,28 @@
1
+ const MAIL_API = "/logic/v4/Mail";
2
+ /**
3
+ * Mail sending surface: fires a purpose/language-templated email through the tenant's
4
+ * configured mail provider. Mail server/template/mailbox management (Mail/Save, Mail/Get,
5
+ * templates, mailbox reads) is a CLI/admin concern and is not exposed here.
6
+ */
7
+ export class BlocksMailClient {
8
+ http;
9
+ constructor(http) {
10
+ this.http = http;
11
+ }
12
+ /**
13
+ * What: sends an email through `POST /logic/v4/Mail/Send` using the tenant's default mail configuration.
14
+ * Why: app code needs to trigger transactional email (welcome, password reset, alerts) without managing SMTP directly.
15
+ * How: pass recipients plus `purpose`/`language` to select the right template, and `subjectDataContext`/`bodyDataContext` for placeholder values.
16
+ */
17
+ send(request) {
18
+ return this.http.request(`${MAIL_API}/Send`, { body: request });
19
+ }
20
+ /**
21
+ * What: sends an email through `POST /logic/v4/Mail/SendToAny`.
22
+ * Why: some sends need a provider-routing hint the default `send` doesn't take, such as marking a test send.
23
+ * How: same fields as `send`, plus `isTestMail`.
24
+ */
25
+ sendToAny(request) {
26
+ return this.http.request(`${MAIL_API}/SendToAny`, { body: request });
27
+ }
28
+ }