@seliseblocks/client 0.1.2 → 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/AI_USAGE_GUIDE.md CHANGED
@@ -9,6 +9,7 @@ Source refs:
9
9
  - IAM: `src/iam/iam-client.ts`
10
10
  - Data: `src/data/data-client.ts`
11
11
  - Localization: `src/localization/localization-client.ts`
12
+ - MFA: `src/mfa/mfa-client.ts`
12
13
  - HTTP/errors: `src/http/http-client.ts`, `src/http/errors.ts`
13
14
 
14
15
  ## Non-Negotiable Rules
@@ -56,7 +57,7 @@ OIDC/hosted IAM flow:
56
57
  Embedded/app-owned flow:
57
58
 
58
59
  - Login: `blocks.auth.login(...)`
59
- - Social: `blocks.auth.socialInitiate(...)`, `blocks.auth.socialCallback(...)`
60
+ - Social: `blocks.auth.socialInitiate(clientId, redirectUri)` (two positional strings), `blocks.auth.socialCallback(request)` (object)
60
61
  - Refresh: `blocks.auth.refresh({ refreshToken })`
61
62
  - Routes: `/iam/v4/auth/login`, `/iam/v4/auth/social/*`, `/iam/v4/auth/refresh`
62
63
 
@@ -69,6 +70,8 @@ Shared auth methods for both flows:
69
70
  - `changePassword(...)`
70
71
  - `activate(...)`, `resendActivation(...)`, `validateActivation(...)`
71
72
  - `identityProviders.*`, `config.*`, `userCodes.*`, `clientCredentials.*` when app has permission
73
+ - `accessToken()` - resolves the caller-owned bearer token configured on `createBlocksClient`.
74
+ - `isAuthenticated()` - checks the session against IAM via `GET /iam/v4/auth/me`, returns a boolean from the raw response status. Prefer this over `userInfo()` for a true/false check, since a hosted-IdP session may live in a cookie with no local `accessToken` to inspect.
72
75
 
73
76
  ## Service Map
74
77
 
@@ -80,7 +83,15 @@ IAM:
80
83
  - `blocks.iam.permissions.*`
81
84
  - `blocks.iam.resources.*`
82
85
  - `blocks.iam.organizations.*`
83
- - `blocks.iam.signup.*`
86
+ - `blocks.iam.signupSettings.get()` / `.save(...)`
87
+
88
+ MFA:
89
+
90
+ - `blocks.mfa.config()` / `.saveConfig(...)` - tenant MFA policy
91
+ - `blocks.mfa.totp.setup()` / `.verifySetup({ code })` - TOTP enrollment
92
+ - `blocks.mfa.generate(...)` / `.resend(...)` / `.verify(...)` - OTP challenge flow
93
+ - `blocks.mfa.setMethod({ mfaType })`, `.disable()`
94
+ - `blocks.mfa.backupCodes.list()` / `.generate()` / `.use({ code, userId })`
84
95
 
85
96
  Data:
86
97
 
@@ -110,6 +121,10 @@ HTTP fallback:
110
121
  - Use `blocks.http.request("/service/v4/...")` only when no typed method exists.
111
122
  - Use `blocks.http.external(url, ...)` only for external URLs such as pre-signed uploads.
112
123
 
124
+ Errors:
125
+
126
+ - Every non-2xx response from `http.request`/`http.external` throws `BlocksApiError` (`status`, `statusText`, `body`). Catch it with `instanceof BlocksApiError` rather than assuming a generic `Error` shape.
127
+
113
128
  ## Minimal Examples
114
129
 
115
130
  ```ts
package/README.md CHANGED
@@ -56,7 +56,7 @@ const refreshed = await blocks.auth.oidc.refreshToken({
56
56
  });
57
57
  ```
58
58
 
59
- Embedded/app-owned login UI uses AuthController methods directly on `auth`: `auth.login()`, `auth.socialInitiate()`, `auth.socialCallback()`, and `auth.refresh()`.
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
60
 
61
61
  ```ts
62
62
  const login = await blocks.auth.login({
@@ -73,6 +73,48 @@ Other auth APIs, such as user info, organization switch, logout, signup, recover
73
73
 
74
74
  `auth.oidc.clientCredentials()` is for trusted non-browser runtimes only because it requires a client secret.
75
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
+
76
118
  ## Common Runtime Calls
77
119
 
78
120
  ```ts
@@ -132,11 +174,24 @@ const selectedKeys = await blocks.localization.keysByNames({
132
174
  - `blocks.auth`: AuthController login, social login, refresh, org switch, logout, signup, recovery, activation, auth config, user codes, client credentials, identity providers.
133
175
  - `blocks.auth.idp`: hosted IdP initiate, browser redirect, callback, UI config.
134
176
  - `blocks.auth.oidc`: refresh-token and client-credentials token endpoint helpers.
135
- - `blocks.iam`: current user, users, roles, permissions, resources, organizations, signup settings.
177
+ - `blocks.iam`: current user, users, roles, permissions, resources, organizations, signup settings (`blocks.iam.signupSettings`).
136
178
  - `blocks.data`: schema reads, validation reads, GraphQL gateway execution, file/storage helpers, DMS file/folder helpers, runtime collection CRUD.
137
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`.
138
183
 
139
- Professional class names are exported for advanced typing and adapters: `BlocksAuthenticationClient`, `BlocksIAMClient`, `BlocksDataClient`, and `BlocksLocalizationClient`.
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
+ ```
140
195
 
141
196
  ## Boundaries
142
197
 
package/dist/client.d.ts CHANGED
@@ -3,7 +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";
6
7
  import { BlocksMfaClient } from "./mfa/mfa-client.js";
8
+ import { BlocksNotifierClient } from "./notifier/notifier-client.js";
7
9
  export type BlocksOidcConfig = {
8
10
  /**
9
11
  * Public browser OIDC client id used by Blocks IAM IdpController and refresh-token calls.
@@ -56,7 +58,9 @@ export type BlocksClient = {
56
58
  http: BlocksHttpClient;
57
59
  iam: BlocksIAMClient;
58
60
  localization: BlocksLocalizationClient;
61
+ mail: BlocksMailClient;
59
62
  mfa: BlocksMfaClient;
63
+ notifier: BlocksNotifierClient;
60
64
  };
61
65
  export type RequiredConfig = {
62
66
  accessToken?: string | (() => Promise<string | undefined> | string | undefined);
package/dist/client.js CHANGED
@@ -3,7 +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";
6
7
  import { BlocksMfaClient } from "./mfa/mfa-client.js";
8
+ import { BlocksNotifierClient } from "./notifier/notifier-client.js";
7
9
  /**
8
10
  * What: creates a framework-neutral Blocks SDK instance for one tenant/app runtime.
9
11
  * Why: frontend code needs a single configured entry point for IAM, Auth, Data, and Localization APIs.
@@ -20,7 +22,9 @@ export function createBlocksClient(config) {
20
22
  http,
21
23
  iam: new BlocksIAMClient(http),
22
24
  localization: new BlocksLocalizationClient(http),
23
- mfa: new BlocksMfaClient(http)
25
+ mail: new BlocksMailClient(http),
26
+ mfa: new BlocksMfaClient(http),
27
+ notifier: new BlocksNotifierClient(http)
24
28
  };
25
29
  }
26
30
  function normalizeConfig(config) {
package/dist/index.d.ts CHANGED
@@ -5,10 +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";
8
9
  export { BlocksMfaClient } from "./mfa/mfa-client.js";
10
+ export { BlocksNotifierClient } from "./notifier/notifier-client.js";
9
11
  export type { BlocksAuthPassThroughResponse, BlocksAuthResponse, BlocksClientCredentialsRequest, BlocksAuthLoginRequest, BlocksIdpCallbackRequest, BlocksIdpInitiateRequest, BlocksIdpInitiateResponse, BlocksLoginOption, BlocksLogoutRequest, BlocksOidcRefreshRequest, BlocksOidcUserInfo, BlocksRefreshRequest, BlocksSocialLoginRequest, BlocksSwitchOrganizationRequest } from "./auth/auth-client.js";
10
12
  export type { BlocksRequestOptions } from "./types.js";
11
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";
12
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";
13
15
  export type { BlocksLocalizationDictionary, BlocksLocalizationKey, BlocksLocalizationKeyResource, BlocksLocalizationKeysByNamesRequest, BlocksLocalizationKeysByNamesResponse, BlocksLocalizationLanguage, BlocksLocalizationModule, BlocksLocalizationTranslationOptions } from "./localization/types.js";
14
- export type { BlocksMfaBackupCodeUseRequest, BlocksMfaConfig, BlocksMfaGenerateRequest, BlocksMfaPassThroughResponse, BlocksMfaResendRequest, BlocksMfaSetMethodRequest, BlocksMfaVerifyRequest, BlocksMfaVerifyTotpSetupRequest } from "./mfa/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,4 +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";
7
8
  export { BlocksMfaClient } from "./mfa/mfa-client.js";
9
+ export { BlocksNotifierClient } from "./notifier/notifier-client.js";
@@ -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
+ }
@@ -0,0 +1,18 @@
1
+ export type BlocksSendMailRequest = {
2
+ attachments?: string[];
3
+ bcc?: string[];
4
+ bodyDataContext?: Record<string, string>;
5
+ cc?: string[];
6
+ language?: string;
7
+ /** Defaults to the tenant's `x-blocks-key` on the server side when omitted. */
8
+ projectKey?: string;
9
+ purpose?: string;
10
+ replyTo?: string[];
11
+ sendPhoneNumberAsEmail?: boolean;
12
+ subjectDataContext?: Record<string, string>;
13
+ to?: string[];
14
+ };
15
+ export type BlocksSendMailToAnyRequest = BlocksSendMailRequest & {
16
+ isTestMail?: boolean;
17
+ };
18
+ export type BlocksMailPassThroughResponse = Record<string, unknown>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,10 @@
1
1
  import { BlocksHttpClient } from "../http/http-client.js";
2
- import { BlocksMfaBackupCodeUseRequest, BlocksMfaConfig, BlocksMfaGenerateRequest, BlocksMfaPassThroughResponse, BlocksMfaResendRequest, BlocksMfaSetMethodRequest, BlocksMfaVerifyRequest, BlocksMfaVerifyTotpSetupRequest } from "./types.js";
2
+ import { BlocksMfaBackupCodeUseRequest, BlocksMfaConfig, BlocksMfaConfigSaveRequest, BlocksMfaGenerateRequest, BlocksMfaPassThroughResponse, BlocksMfaResendRequest, BlocksMfaSetMethodRequest, BlocksMfaVerifyRequest, BlocksMfaVerifyTotpSetupRequest } from "./types.js";
3
3
  /**
4
- * Consumer-facing MFA surface: enroll, verify, switch, or disable the signed-in user's own MFA,
5
- * and manage their own backup codes. Tenant-wide MFA policy (`POST /iam/v4/mfa/config`) is
6
- * deliberately not exposed here -- that's an admin/tenant-settings action, not a user self-service
7
- * flow, the same distinction the SDK already draws for `identityProviders` admin methods.
4
+ * MFA surface: enroll, verify, switch, or disable the signed-in user's own MFA and manage
5
+ * their own backup codes, plus `saveConfig` for the tenant-wide MFA policy. Like
6
+ * `identityProviders`/`config`/`clientCredentials` on `BlocksAuthenticationClient`, `saveConfig`
7
+ * is an admin/tenant-settings action -- IAM enforces the required role, the SDK does not gate it.
8
8
  */
9
9
  export declare class BlocksMfaClient {
10
10
  private readonly http;
@@ -15,6 +15,13 @@ export declare class BlocksMfaClient {
15
15
  * How: call with an authorized token; the SDK returns IAM's policy shape as-is.
16
16
  */
17
17
  config(): Promise<BlocksMfaConfig>;
18
+ /**
19
+ * What: saves the tenant's MFA policy through `POST /iam/v4/mfa/config`.
20
+ * Why: tenant admin/settings screens need to turn MFA on/off, require it for specific roles,
21
+ * or configure backup codes -- this is not a user self-service action.
22
+ * How: pass IAM's full config payload with an authorized, sufficiently-privileged token.
23
+ */
24
+ saveConfig(request: BlocksMfaConfigSaveRequest): Promise<BlocksMfaPassThroughResponse>;
18
25
  readonly totp: {
19
26
  /**
20
27
  * What: starts TOTP enrollment through `POST /iam/v4/mfa/totp/setup`.
@@ -1,9 +1,9 @@
1
1
  const MFA_API = "/iam/v4/mfa";
2
2
  /**
3
- * Consumer-facing MFA surface: enroll, verify, switch, or disable the signed-in user's own MFA,
4
- * and manage their own backup codes. Tenant-wide MFA policy (`POST /iam/v4/mfa/config`) is
5
- * deliberately not exposed here -- that's an admin/tenant-settings action, not a user self-service
6
- * flow, the same distinction the SDK already draws for `identityProviders` admin methods.
3
+ * MFA surface: enroll, verify, switch, or disable the signed-in user's own MFA and manage
4
+ * their own backup codes, plus `saveConfig` for the tenant-wide MFA policy. Like
5
+ * `identityProviders`/`config`/`clientCredentials` on `BlocksAuthenticationClient`, `saveConfig`
6
+ * is an admin/tenant-settings action -- IAM enforces the required role, the SDK does not gate it.
7
7
  */
8
8
  export class BlocksMfaClient {
9
9
  http;
@@ -18,6 +18,15 @@ export class BlocksMfaClient {
18
18
  config() {
19
19
  return this.http.request(`${MFA_API}/config`);
20
20
  }
21
+ /**
22
+ * What: saves the tenant's MFA policy through `POST /iam/v4/mfa/config`.
23
+ * Why: tenant admin/settings screens need to turn MFA on/off, require it for specific roles,
24
+ * or configure backup codes -- this is not a user self-service action.
25
+ * How: pass IAM's full config payload with an authorized, sufficiently-privileged token.
26
+ */
27
+ saveConfig(request) {
28
+ return this.http.request(`${MFA_API}/config`, { body: request });
29
+ }
21
30
  totp = {
22
31
  /**
23
32
  * What: starts TOTP enrollment through `POST /iam/v4/mfa/totp/setup`.
@@ -6,6 +6,20 @@ export type BlocksMfaConfig = Record<string, unknown> & {
6
6
  requireMfaForAllUsers?: boolean;
7
7
  userMfaType?: number[];
8
8
  };
9
+ export type BlocksMfaConfigSaveRequest = Record<string, unknown> & {
10
+ allowBackupCodes?: boolean;
11
+ allowUserOptOut?: boolean;
12
+ backupCodesCount?: number;
13
+ enableMfa?: boolean;
14
+ mfaExemptRoles?: string[];
15
+ mfaRequiredRoles?: string[];
16
+ mfaTemplate?: {
17
+ templateId?: string;
18
+ templateName?: string;
19
+ };
20
+ requireMfaForAllUsers?: boolean;
21
+ userMfaType?: number[];
22
+ };
9
23
  export type BlocksMfaGenerateRequest = {
10
24
  /** IAM-defined numeric MFA method (its enum names aren't in the swagger contract -- treat as opaque). */
11
25
  mfaType: number;
@@ -0,0 +1,43 @@
1
+ import { BlocksHttpClient } from "../http/http-client.js";
2
+ import { BlocksGetNotificationsOptions, BlocksGetNotificationsResponse, BlocksGetUnreadNotificationsBySubscriptionFilterRequest, BlocksMarkNotificationAsReadRequest, BlocksNotifierPassThroughResponse, BlocksNotifyRequest, BlocksOfflineNotification } from "./types.js";
3
+ /**
4
+ * Real-time/offline notification surface: push a notification to specific users, roles, or
5
+ * subscription-filter matches, and read/manage the signed-in user's own notification inbox.
6
+ * Tenant-wide notification *channel configuration* (Notification/Save etc., under
7
+ * `BlocksIAMClient`/CLI `notification` commands) is a separate, admin-facing concern.
8
+ */
9
+ export declare class BlocksNotifierClient {
10
+ private readonly http;
11
+ constructor(http: BlocksHttpClient);
12
+ /**
13
+ * What: pushes a notification through `POST /logic/v4/Notifier/Notify`.
14
+ * Why: app code needs to notify specific users/roles, or everyone subscribed to a filter, in real time with an offline/persisted fallback.
15
+ * How: target with at least one of `userIds`/`roles`/`subscriptionFilters`; set `saveDenormalizedPayloadAsAnObject` if `denormalizedPayload` is a JSON string clients should receive parsed.
16
+ */
17
+ notify(request: BlocksNotifyRequest): Promise<BlocksNotifierPassThroughResponse>;
18
+ /**
19
+ * What: reads unread notifications matching a subscription filter through `GET /logic/v4/Notifier/GetUnreadNotificationsBySubscriptionFilter`.
20
+ * Why: clients that subscribe by filter (rather than by user id) need to catch up on what they missed while offline.
21
+ * How: pass `userId` and the same `subscriptionFilterData` shape used with `notify`. Swagger documents this endpoint
22
+ * as GET with a JSON body, which the Fetch spec forbids -- the SDK sends the same fields as a flattened query string instead.
23
+ */
24
+ getUnreadNotificationsBySubscriptionFilter(request: BlocksGetUnreadNotificationsBySubscriptionFilterRequest): Promise<BlocksOfflineNotification[]>;
25
+ /**
26
+ * What: lists the signed-in user's notifications through `GET /logic/v4/Notifier/GetNotifications`.
27
+ * Why: notification-inbox UIs need paged, sortable, filterable access plus unread/total counts.
28
+ * How: pass paging/sort/filter options; omit them for the API's defaults.
29
+ */
30
+ getNotifications(options?: BlocksGetNotificationsOptions): Promise<BlocksGetNotificationsResponse>;
31
+ /**
32
+ * What: marks every notification read through `POST /logic/v4/Notifier/MarkAllNotificationAsRead`.
33
+ * Why: inbox UIs offer a bulk "mark all as read" action.
34
+ * How: call with an authorized token for the signed-in user.
35
+ */
36
+ markAllNotificationAsRead(): Promise<BlocksNotifierPassThroughResponse>;
37
+ /**
38
+ * What: marks one notification read through `POST /logic/v4/Notifier/MarkNotificationAsRead`.
39
+ * Why: inbox UIs mark individual notifications read as the user views them.
40
+ * How: pass the notification's `id`.
41
+ */
42
+ markNotificationAsRead(request: BlocksMarkNotificationAsReadRequest): Promise<BlocksNotifierPassThroughResponse>;
43
+ }
@@ -0,0 +1,71 @@
1
+ const NOTIFIER_API = "/logic/v4/Notifier";
2
+ /**
3
+ * Real-time/offline notification surface: push a notification to specific users, roles, or
4
+ * subscription-filter matches, and read/manage the signed-in user's own notification inbox.
5
+ * Tenant-wide notification *channel configuration* (Notification/Save etc., under
6
+ * `BlocksIAMClient`/CLI `notification` commands) is a separate, admin-facing concern.
7
+ */
8
+ export class BlocksNotifierClient {
9
+ http;
10
+ constructor(http) {
11
+ this.http = http;
12
+ }
13
+ /**
14
+ * What: pushes a notification through `POST /logic/v4/Notifier/Notify`.
15
+ * Why: app code needs to notify specific users/roles, or everyone subscribed to a filter, in real time with an offline/persisted fallback.
16
+ * How: target with at least one of `userIds`/`roles`/`subscriptionFilters`; set `saveDenormalizedPayloadAsAnObject` if `denormalizedPayload` is a JSON string clients should receive parsed.
17
+ */
18
+ notify(request) {
19
+ return this.http.request(`${NOTIFIER_API}/Notify`, { body: request });
20
+ }
21
+ /**
22
+ * What: reads unread notifications matching a subscription filter through `GET /logic/v4/Notifier/GetUnreadNotificationsBySubscriptionFilter`.
23
+ * Why: clients that subscribe by filter (rather than by user id) need to catch up on what they missed while offline.
24
+ * How: pass `userId` and the same `subscriptionFilterData` shape used with `notify`. Swagger documents this endpoint
25
+ * as GET with a JSON body, which the Fetch spec forbids -- the SDK sends the same fields as a flattened query string instead.
26
+ */
27
+ getUnreadNotificationsBySubscriptionFilter(request) {
28
+ return this.http.request(`${NOTIFIER_API}/GetUnreadNotificationsBySubscriptionFilter`, {
29
+ query: {
30
+ OrderBy: request.orderBy,
31
+ "SubscriptionFilterData.ActionName": request.subscriptionFilterData?.actionName,
32
+ "SubscriptionFilterData.Context": request.subscriptionFilterData?.context,
33
+ "SubscriptionFilterData.Value": request.subscriptionFilterData?.value,
34
+ UserId: request.userId
35
+ }
36
+ });
37
+ }
38
+ /**
39
+ * What: lists the signed-in user's notifications through `GET /logic/v4/Notifier/GetNotifications`.
40
+ * Why: notification-inbox UIs need paged, sortable, filterable access plus unread/total counts.
41
+ * How: pass paging/sort/filter options; omit them for the API's defaults.
42
+ */
43
+ getNotifications(options = {}) {
44
+ return this.http.request(`${NOTIFIER_API}/GetNotifications`, {
45
+ query: {
46
+ Filter: options.filter,
47
+ IsUnreadOnly: options.isUnreadOnly,
48
+ Page: options.page,
49
+ PageSize: options.pageSize,
50
+ "Sort.IsDescending": options.sortDescending,
51
+ "Sort.Property": options.sortBy
52
+ }
53
+ });
54
+ }
55
+ /**
56
+ * What: marks every notification read through `POST /logic/v4/Notifier/MarkAllNotificationAsRead`.
57
+ * Why: inbox UIs offer a bulk "mark all as read" action.
58
+ * How: call with an authorized token for the signed-in user.
59
+ */
60
+ markAllNotificationAsRead() {
61
+ return this.http.request(`${NOTIFIER_API}/MarkAllNotificationAsRead`, { method: "POST" });
62
+ }
63
+ /**
64
+ * What: marks one notification read through `POST /logic/v4/Notifier/MarkNotificationAsRead`.
65
+ * Why: inbox UIs mark individual notifications read as the user views them.
66
+ * How: pass the notification's `id`.
67
+ */
68
+ markNotificationAsRead(request) {
69
+ return this.http.request(`${NOTIFIER_API}/MarkNotificationAsRead`, { body: request });
70
+ }
71
+ }
@@ -0,0 +1,50 @@
1
+ export type BlocksNotifierSubscriptionFilter = {
2
+ actionName?: string;
3
+ context?: string;
4
+ value?: string;
5
+ };
6
+ export type BlocksNotifyRequest = {
7
+ configurationName?: string;
8
+ connectionId?: string;
9
+ contentAvailable?: boolean;
10
+ denormalizedPayload?: string;
11
+ responseKey?: string;
12
+ responseValue?: string;
13
+ roles?: string[];
14
+ saveDenormalizedPayloadAsAnObject?: boolean;
15
+ subscriptionFilters?: BlocksNotifierSubscriptionFilter[];
16
+ userIds?: string[];
17
+ };
18
+ export type BlocksGetUnreadNotificationsBySubscriptionFilterRequest = {
19
+ /** IAM/Notifier-defined order enum (its meanings aren't in the swagger contract -- treat as opaque). */
20
+ orderBy?: 1 | 2;
21
+ subscriptionFilterData?: BlocksNotifierSubscriptionFilter;
22
+ userId?: string;
23
+ };
24
+ export type BlocksGetNotificationsOptions = {
25
+ filter?: string;
26
+ isUnreadOnly?: boolean;
27
+ page?: number;
28
+ pageSize?: number;
29
+ sortBy?: string;
30
+ sortDescending?: boolean;
31
+ };
32
+ export type BlocksOfflineNotification = Record<string, unknown> & {
33
+ correlationId?: string;
34
+ createdTime?: string;
35
+ denormalizedPayload?: string;
36
+ id?: string;
37
+ isRead?: boolean;
38
+ payload?: string;
39
+ readByRoles?: string[];
40
+ readByUserIds?: string[];
41
+ };
42
+ export type BlocksGetNotificationsResponse = {
43
+ notifications: Record<string, unknown>[];
44
+ totalNotificationsCount: number;
45
+ unReadNotificationsCount: number;
46
+ };
47
+ export type BlocksMarkNotificationAsReadRequest = {
48
+ id: string;
49
+ };
50
+ export type BlocksNotifierPassThroughResponse = Record<string, unknown>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seliseblocks/client",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Framework-neutral TypeScript client SDK for SELISE Blocks frontend applications.",
5
5
  "license": "MIT",
6
6
  "type": "module",