@blocksdiy/blocks-client-sdk 1.21.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Action.d.ts CHANGED
@@ -101,5 +101,16 @@ export declare class Action<AC extends ActionConfig = ActionConfig> {
101
101
  execute(input: AC["inputInstanceType"], { onChunk }?: {
102
102
  onChunk?: (chunk: any) => void;
103
103
  }): Promise<AC["outputInstanceType"]>;
104
+ /**
105
+ * Starts the action in the background and returns its run id at once, without waiting for the
106
+ * result. Use it for a long-running action (`execute` would wait in the browser for hours and
107
+ * lose the run on reload). Keep the id — e.g. on a row — and check on the run with
108
+ * `client.getActionRunStatus(workflowId)` or the `useActionRun` hook.
109
+ *
110
+ * @throws {ActionRunError} with a structured `code` when the platform refuses, e.g. DURABLE_RUN_LIMIT
111
+ */
112
+ start(input: AC["inputInstanceType"]): Promise<{
113
+ workflowId: string;
114
+ }>;
104
115
  }
105
116
  //# sourceMappingURL=Action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Action.d.ts","sourceRoot":"","sources":["../src/Action.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,YAAY,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE;IAC5G,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,EAAE,CAAC;IACtB,kBAAkB,EAAE,EAAE,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,qBAAa,MAAM,CAAC,EAAE,SAAS,YAAY,GAAG,YAAY;IACxD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAC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AO,CAAC,OAAO,CAAC,CAAyB;IACzC,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB;;;OAGG;gBAED,MAAM,EAAE,EAAE,EACV,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAUhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmDG;IACG,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,EAAE,OAAO,EAAE,GAAE;QAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;KAAO;IAwBlG;;;;;;;OAOG;IACG,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAS7E"}
package/dist/Action.js CHANGED
@@ -102,4 +102,21 @@ export class Action {
102
102
  });
103
103
  return result;
104
104
  }
105
+ /**
106
+ * Starts the action in the background and returns its run id at once, without waiting for the
107
+ * result. Use it for a long-running action (`execute` would wait in the browser for hours and
108
+ * lose the run on reload). Keep the id — e.g. on a row — and check on the run with
109
+ * `client.getActionRunStatus(workflowId)` or the `useActionRun` hook.
110
+ *
111
+ * @throws {ActionRunError} with a structured `code` when the platform refuses, e.g. DURABLE_RUN_LIMIT
112
+ */
113
+ async start(input) {
114
+ return WorkflowRequest.start({
115
+ workflowBlockId: this.actionBlockId,
116
+ appId: this.appId,
117
+ token: this.token,
118
+ input: { ...input, toolId: this.toolId },
119
+ context: { appId: this.appId, toolSetId: this.toolSetId },
120
+ });
121
+ }
105
122
  }
@@ -1,9 +1,11 @@
1
+ import { type ActionRunStatus } from "@blocksdiy/blocks-client-api/workflowService";
1
2
  import { Action, type ActionConfig } from "./Action.js";
2
3
  import { Agent, type AgentConfig } from "./Agent.js";
3
4
  import { AgentChat, AgentChatConfig } from "./AgentChat.js";
4
5
  import { Entity, type EntityConfig } from "./Entity.js";
5
6
  import { Integration } from "./Integration.js";
6
7
  import { Page, type PageConfig } from "./Page.js";
8
+ import type { AppUserPermission } from "./Permission.js";
7
9
  /**
8
10
  * Represents a user's data
9
11
  * @interface User
@@ -14,7 +16,7 @@ import { Page, type PageConfig } from "./Page.js";
14
16
  * @property {string} [firstName] - The user's first name (optional)
15
17
  * @property {string} [lastName] - The user's last name (optional)
16
18
  * @property {string} [role] - The user's role name (optional)
17
- * @property {string} [permission] - The user's permission level: 'build' (can modify app) or 'use' (read-only) (optional)
19
+ * @property {string} [permission] - The user's permission level: 'build' (can modify the app), 'manage' (can manage users and roles, sees all tenants' data) or 'use' (optional)
18
20
  * @property {number} [accountId] - The id of the account the user belongs to (optional, must exist if user is authenticated)
19
21
  * @property {boolean} [isAuthenticated] - Whether the user is authenticated
20
22
  * @property {string} [timeZone] - The viewer's IANA time zone from the browser, e.g. "Asia/Jerusalem" (optional: unset where the browser can't tell)
@@ -27,7 +29,7 @@ export interface User {
27
29
  firstName?: string;
28
30
  lastName?: string;
29
31
  role?: string;
30
- permission?: "build" | "use";
32
+ permission?: AppUserPermission;
31
33
  accountId?: number;
32
34
  isAuthenticated: boolean;
33
35
  timeZone?: string;
@@ -139,6 +141,38 @@ export declare class ClientSdk {
139
141
  * ```
140
142
  */
141
143
  action<AC extends ActionConfig = ActionConfig>(actionConfig: AC): Action<AC>;
144
+ /**
145
+ * The state of a run started with `action(...).start(...)`: `status` (RUNNING / COMPLETED /
146
+ * FAILED / CANCELLED), loop `progress`, `awaitingRetry` while the run is paused after a failure, `paused`, and
147
+ * `pausable` (false while something waits synchronously on the run).
148
+ */
149
+ getActionRunStatus(workflowId: string): Promise<ActionRunStatus>;
150
+ /** Stops a long-running run: no new steps start; steps already running finish. */
151
+ cancelActionRun(workflowId: string): Promise<{
152
+ workflowId: string;
153
+ status: string;
154
+ }>;
155
+ /**
156
+ * Pauses a long-running run: no new steps start until `resumeActionRun`; what is running
157
+ * finishes, and nothing fails. Throws an `ActionRunError` with code RUN_NOT_RUNNING once the
158
+ * run has ended, RUN_NOT_PAUSABLE when something is waiting synchronously on it,
159
+ * RUN_NOT_CONTROLLABLE for a run started before run control existed.
160
+ */
161
+ pauseActionRun(workflowId: string): Promise<{
162
+ workflowId: string;
163
+ status: string;
164
+ }>;
165
+ /**
166
+ * Resumes a paused long-running run — paused on request (`paused`) or after a failure (its
167
+ * status lists `awaitingRetry`): failed steps and loop items run again, what succeeded stays
168
+ * done. Throws an `ActionRunError` with code RUN_NOT_RESUMABLE once the run has ended,
169
+ * NOTHING_TO_RESUME when it isn't paused, RUN_NOT_CONTROLLABLE for a run started before run
170
+ * control existed.
171
+ */
172
+ resumeActionRun(workflowId: string): Promise<{
173
+ workflowId: string;
174
+ retried: import("@blocksdiy/blocks-client-api").ActionRunWaitingEntry[];
175
+ }>;
142
176
  /**
143
177
  * Gets or creates a Page instance for the specified page configuration
144
178
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ClientSdk.d.ts","sourceRoot":"","sources":["../src/ClientSdk.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,WAAW,EAA0B,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,CAAC,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C;YAOhE,iBAAiB;IAyB/B;;;;;;;;;;OAUG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB;IAoBlF;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAmBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,iBAAiB;CAGlB"}
package/dist/ClientSdk.js CHANGED
@@ -2,6 +2,7 @@ import { DataApiService } from "@blocksdiy/blocks-client-api";
2
2
  import { AppVersionService } from "@blocksdiy/blocks-client-api/appVersionService";
3
3
  import { BlocksApiService } from "@blocksdiy/blocks-client-api/blocksStoreService";
4
4
  import { getGoogleBaseUrl, getHost } from "@blocksdiy/blocks-client-api/envService";
5
+ import { WorkflowRequest } from "@blocksdiy/blocks-client-api/workflowService";
5
6
  import { Action } from "./Action.js";
6
7
  import { Agent } from "./Agent.js";
7
8
  import { AgentChat } from "./AgentChat.js";
@@ -148,6 +149,37 @@ export class ClientSdk {
148
149
  }
149
150
  return this.actions.get(key);
150
151
  }
152
+ /**
153
+ * The state of a run started with `action(...).start(...)`: `status` (RUNNING / COMPLETED /
154
+ * FAILED / CANCELLED), loop `progress`, `awaitingRetry` while the run is paused after a failure, `paused`, and
155
+ * `pausable` (false while something waits synchronously on the run).
156
+ */
157
+ getActionRunStatus(workflowId) {
158
+ return WorkflowRequest.getRunStatus({ appId: this.appId, token: this.token, workflowId });
159
+ }
160
+ /** Stops a long-running run: no new steps start; steps already running finish. */
161
+ cancelActionRun(workflowId) {
162
+ return WorkflowRequest.cancelRun({ appId: this.appId, token: this.token, workflowId });
163
+ }
164
+ /**
165
+ * Pauses a long-running run: no new steps start until `resumeActionRun`; what is running
166
+ * finishes, and nothing fails. Throws an `ActionRunError` with code RUN_NOT_RUNNING once the
167
+ * run has ended, RUN_NOT_PAUSABLE when something is waiting synchronously on it,
168
+ * RUN_NOT_CONTROLLABLE for a run started before run control existed.
169
+ */
170
+ pauseActionRun(workflowId) {
171
+ return WorkflowRequest.pauseRun({ appId: this.appId, token: this.token, workflowId });
172
+ }
173
+ /**
174
+ * Resumes a paused long-running run — paused on request (`paused`) or after a failure (its
175
+ * status lists `awaitingRetry`): failed steps and loop items run again, what succeeded stays
176
+ * done. Throws an `ActionRunError` with code RUN_NOT_RESUMABLE once the run has ended,
177
+ * NOTHING_TO_RESUME when it isn't paused, RUN_NOT_CONTROLLABLE for a run started before run
178
+ * control existed.
179
+ */
180
+ resumeActionRun(workflowId) {
181
+ return WorkflowRequest.resumeRun({ appId: this.appId, token: this.token, workflowId });
182
+ }
151
183
  /**
152
184
  * Gets or creates a Page instance for the specified page configuration
153
185
  *
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The platform permission an app user holds on the app:
3
+ * - `build`: edits the app (Ella, Design) and manages its users.
4
+ * - `manage`: uses the app, invites users, sets their roles, and sees every tenant's data.
5
+ * - `use`: uses the app.
6
+ */
7
+ export type AppUserPermission = "build" | "manage" | "use";
8
+ /** Whether the user may manage the app's users (invite, change roles): builders and managers. */
9
+ export declare const canManageUsers: (user: {
10
+ permission?: string | null;
11
+ } | null | undefined) => boolean;
12
+ //# sourceMappingURL=Permission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Permission.d.ts","sourceRoot":"","sources":["../src/Permission.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE3D,iGAAiG;AACjG,eAAO,MAAM,cAAc,GAAI,MAAM;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KAAG,OAC1B,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** Whether the user may manage the app's users (invite, change roles): builders and managers. */
2
+ export const canManageUsers = (user) => user?.permission === "build" || user?.permission === "manage";
@@ -1,3 +1,5 @@
1
+ import { ActionRunError } from "@blocksdiy/blocks-client-api/errors";
2
+ import { type ActionRunStatus, type ActionRunWaitingEntry } from "@blocksdiy/blocks-client-api/workflowService";
1
3
  import { type AgentContext, type AgentContextShare, type AgentScreenRead } from "@blocksdiy/react-common/agent-threads";
2
4
  import type { ActionConfig } from "./Action.js";
3
5
  import type { AgentConfig } from "./Agent.js";
@@ -7,6 +9,9 @@ import type { EntityAttribution, EntityConfig, EntityType, EntityTypeOnlyMutable
7
9
  import { type EntityQuery } from "./EntityQuery.js";
8
10
  import type { Integration } from "./Integration.js";
9
11
  import type { PageConfig } from "./Page.js";
12
+ import { canManageUsers } from "./Permission.js";
13
+ export { canManageUsers };
14
+ export type { AppUserPermission } from "./Permission.js";
10
15
  export declare class ReactClientSdk extends ClientSdk {
11
16
  }
12
17
  export declare enum AppDataEventTypes {
@@ -460,12 +465,15 @@ export declare const useEntityDeleteMany: <EC extends EntityConfig = EntityConfi
460
465
  * @param {AC} actionConfig - Configuration for the action
461
466
  * @returns {Object} Action execution object with functions, state, and results
462
467
  * @returns {Function} returns.executeFunction - Function to execute the action with inputs
468
+ * @returns {Function} returns.executeBackgroundRunFunction - Starts the action on the server and resolves with `{ runId }` as soon as the run is accepted; the run keeps going after a reload or unmount. Store the id (e.g. on a row) and follow it with `useActionRun`. Rejects with an `ActionRunError` (branch on `code`, e.g. DURABLE_RUN_LIMIT).
463
469
  * @returns {AC["outputInstanceType"]} returns.result - Final result after action completes
464
470
  * @returns {AC["outputInstanceType"]} returns.streamResult - Incrementally updated result during streaming
465
471
  * @returns {boolean} returns.isLoading - Whether the action is currently executing
466
472
  * @returns {boolean} returns.isDone - Whether the action has completed
467
473
  * @returns {Error | null} returns.error - Any error that occurred during execution
468
- * @returns {Function} returns.clear - Function to clear result and streamResult values
474
+ * @returns {boolean} returns.isStartingBackgroundRun - Whether `executeBackgroundRunFunction` is waiting for the run to be accepted (not for it to finish)
475
+ * @returns {Error | null} returns.backgroundRunError - The error of the last `executeBackgroundRunFunction` call
476
+ * @returns {Function} returns.clear - Function to clear result, streamResult and both errors
469
477
  * @example
470
478
  * ```tsx
471
479
  * import { ExportDataAction, ProcessPaymentAction } from '@/product-types';
@@ -545,13 +553,75 @@ export declare const useEntityDeleteMany: <EC extends EntityConfig = EntityConfi
545
553
  */
546
554
  export declare const useExecuteAction: <AC extends ActionConfig = ActionConfig>(actionConfig: AC) => {
547
555
  executeFunction: import("@tanstack/react-query").UseMutateAsyncFunction<AC["outputInstanceType"], Error, AC["inputInstanceType"], unknown>;
556
+ executeBackgroundRunFunction: import("@tanstack/react-query").UseMutateAsyncFunction<{
557
+ runId: string;
558
+ }, Error, AC["inputInstanceType"], unknown>;
548
559
  result: AC["outputInstanceType"] | undefined;
549
560
  streamResult: AC["outputInstanceType"] | undefined;
550
561
  isLoading: boolean;
551
562
  isDone: boolean;
552
563
  error: Error | null;
564
+ isStartingBackgroundRun: boolean;
565
+ backgroundRunError: Error | null;
553
566
  clear: () => void;
554
567
  };
568
+ export { ActionRunError };
569
+ export type { ActionRunStatus, ActionRunWaitingEntry };
570
+ /**
571
+ * Hook to follow a run started with `useExecuteAction`'s `executeBackgroundRunFunction` (or by a
572
+ * code action): its `status`, loop `progress`, whether it waits for `resume` (`canResume`: paused
573
+ * by `pause`, or after a failure — then `awaitingRetry` lists what failed) — polled until the run
574
+ * ends — plus `pause`, `resume` and `cancel`. Pass `undefined` until there is a run.
575
+ *
576
+ * Errors from `pause` / `resume` / `cancel` are `ActionRunError`s: branch on `error.code`
577
+ * (RUN_NOT_RESUMABLE, NOTHING_TO_RESUME, RUN_NOT_FOUND, …), never on the message.
578
+ *
579
+ * @example
580
+ * ```tsx
581
+ * const { status, progress, awaitingRetry, canPause, canResume, pause, resume, cancel } = useActionRun(run.runId);
582
+ * {canPause && <Button onClick={() => pause()}>Pause</Button>}
583
+ * {canResume && <Button onClick={() => resume()}>Resume</Button>}
584
+ * ```
585
+ */
586
+ export declare const useActionRun: (runId: string | undefined | null) => {
587
+ status: string | undefined;
588
+ progress: {
589
+ loops: {
590
+ loopKey: string;
591
+ blockId: string;
592
+ total: number;
593
+ succeeded: number;
594
+ failed: number;
595
+ inFlight: number;
596
+ }[];
597
+ } | undefined;
598
+ awaitingRetry: ActionRunWaitingEntry[];
599
+ /** Paused by a `pause()` call, until `resume()`. A step already running can still fail meanwhile, so `awaitingRetry` alone can't tell this apart. */
600
+ isManuallyPaused: boolean;
601
+ /** The run waits for `resume()`: paused by `pause()`, or after a failure (then `awaitingRetry` lists it). Show the Resume button on this. */
602
+ canResume: boolean;
603
+ /** `pause` would be accepted: the run is running, not already paused, and nothing waits on it synchronously. */
604
+ canPause: boolean;
605
+ /** The run has ended (completed, failed or cancelled); polling has stopped. */
606
+ isDone: boolean;
607
+ isLoading: boolean;
608
+ error: Error | null;
609
+ cancel: import("@tanstack/react-query").UseMutateAsyncFunction<{
610
+ workflowId: string;
611
+ status: string;
612
+ }, Error, void, unknown>;
613
+ isCancelling: boolean;
614
+ pause: import("@tanstack/react-query").UseMutateAsyncFunction<{
615
+ workflowId: string;
616
+ status: string;
617
+ }, Error, void, unknown>;
618
+ isPausing: boolean;
619
+ resume: import("@tanstack/react-query").UseMutateAsyncFunction<{
620
+ workflowId: string;
621
+ retried: ActionRunWaitingEntry[];
622
+ }, Error, void, unknown>;
623
+ isResuming: boolean;
624
+ };
555
625
  /**
556
626
  * Hook to get an AgentChat instance
557
627
  *
@@ -714,7 +784,7 @@ export declare const useFileUpload: () => {
714
784
  * @property {string} [firstName] - The user's first name (optional)
715
785
  * @property {string} [lastName] - The user's last name (optional)
716
786
  * @property {string} [role] - The user's role name (optional)
717
- * @property {string} [permission] - The user's permission level: 'build' (can modify app) or 'use' (read-only) (optional)
787
+ * @property {string} [permission] - The user's permission level: 'build' (can modify the app), 'manage' (can manage users and roles, sees all tenants' data) or 'use' (optional)
718
788
  * @property {number} [accountId] - The id of the account the user belongs to (optional)
719
789
  */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E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,EAAE,SAAS,UAAU,GAAG,UAAU,EAAE,YAAY,EAAE,WAI5E,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { AppVersionService } from "@blocksdiy/blocks-client-api/appVersionService";
2
- import { FatalAppError } from "@blocksdiy/blocks-client-api/errors";
2
+ import { ActionRunError, FatalAppError } from "@blocksdiy/blocks-client-api/errors";
3
3
  import { useWebsockets, useWebsocketsAppSubscribe } from "@blocksdiy/blocks-client-api/websocketService";
4
4
  import { websocketsService } from "@blocksdiy/blocks-client-api/websocketService";
5
+ import { isTerminalWorkflowStatus, } from "@blocksdiy/blocks-client-api/workflowService";
5
6
  import { createAgentContextStore, useAgentContextRegistration, useAgentContextValues, } from "@blocksdiy/react-common/agent-threads";
6
7
  import { useAiStreamChunks } from "@blocksdiy/react-common/useAiStreamChunks";
7
8
  import { QueryClient, QueryClientProvider, useInfiniteQuery, useMutation, useQuery, useQueryClient, } from "@tanstack/react-query";
@@ -11,6 +12,8 @@ import { ClientSdk } from "./ClientSdk.js";
11
12
  import { applyEntityCreateResult, applyEntityDeleteResult, applyEntityRowPatch, applyEntityRowsDeleted, beginEntityOptimisticWrite, ENTITIES_QUERY_KEY, entityAttributionKey, entityPagesKey, fetchEntityPagedListPage, rollbackEntityOptimisticWrite, } from "./EntityCache.js";
12
13
  import { createEntityLiveSync } from "./EntityLiveSync.js";
13
14
  import { isEntityQuery } from "./EntityQuery.js";
15
+ import { canManageUsers } from "./Permission.js";
16
+ export { canManageUsers };
14
17
  export class ReactClientSdk extends ClientSdk {
15
18
  }
16
19
  const CURRENT_USER_QUERY_KEY = "currentUser";
@@ -816,12 +819,15 @@ export const useEntityDeleteMany = (entityConfig) => {
816
819
  * @param {AC} actionConfig - Configuration for the action
817
820
  * @returns {Object} Action execution object with functions, state, and results
818
821
  * @returns {Function} returns.executeFunction - Function to execute the action with inputs
822
+ * @returns {Function} returns.executeBackgroundRunFunction - Starts the action on the server and resolves with `{ runId }` as soon as the run is accepted; the run keeps going after a reload or unmount. Store the id (e.g. on a row) and follow it with `useActionRun`. Rejects with an `ActionRunError` (branch on `code`, e.g. DURABLE_RUN_LIMIT).
819
823
  * @returns {AC["outputInstanceType"]} returns.result - Final result after action completes
820
824
  * @returns {AC["outputInstanceType"]} returns.streamResult - Incrementally updated result during streaming
821
825
  * @returns {boolean} returns.isLoading - Whether the action is currently executing
822
826
  * @returns {boolean} returns.isDone - Whether the action has completed
823
827
  * @returns {Error | null} returns.error - Any error that occurred during execution
824
- * @returns {Function} returns.clear - Function to clear result and streamResult values
828
+ * @returns {boolean} returns.isStartingBackgroundRun - Whether `executeBackgroundRunFunction` is waiting for the run to be accepted (not for it to finish)
829
+ * @returns {Error | null} returns.backgroundRunError - The error of the last `executeBackgroundRunFunction` call
830
+ * @returns {Function} returns.clear - Function to clear result, streamResult and both errors
825
831
  * @example
826
832
  * ```tsx
827
833
  * import { ExportDataAction, ProcessPaymentAction } from '@/product-types';
@@ -941,14 +947,113 @@ export const useExecuteAction = (actionConfig) => {
941
947
  setIsDone(true);
942
948
  },
943
949
  });
950
+ // Starts the run and resolves with its id; the run carries on server-side. Its state is kept
951
+ // apart on purpose: result, streamResult, isDone, isLoading and error describe executeFunction.
952
+ // Same rate-limit budget: a start loop is costlier than an execute loop (a run can last hours).
953
+ const { mutateAsync: executeBackgroundRunFunction, isPending: isStartingBackgroundRun, error: backgroundRunError, reset: resetBackgroundRun, } = useMutation({
954
+ mutationFn: async (inputs) => {
955
+ validateExceededMaxCount(inputs);
956
+ const { workflowId } = await client.action(actionConfig).start(inputs);
957
+ return { runId: workflowId };
958
+ },
959
+ });
944
960
  if (error instanceof FatalAppError) {
945
961
  throw error;
946
962
  }
963
+ if (backgroundRunError instanceof FatalAppError) {
964
+ throw backgroundRunError;
965
+ }
947
966
  const clear = useCallback(() => {
948
967
  reset();
968
+ resetBackgroundRun();
949
969
  setStreamResult(undefined);
950
970
  }, []);
951
- return { executeFunction, result, streamResult, isLoading, isDone, error, clear };
971
+ return {
972
+ executeFunction,
973
+ executeBackgroundRunFunction,
974
+ result,
975
+ streamResult,
976
+ isLoading,
977
+ isDone,
978
+ error,
979
+ isStartingBackgroundRun,
980
+ backgroundRunError,
981
+ clear,
982
+ };
983
+ };
984
+ export { ActionRunError };
985
+ /** How often `useActionRun` re-reads a run that hasn't ended. */
986
+ const ACTION_RUN_POLL_MS = 5000;
987
+ /**
988
+ * Hook to follow a run started with `useExecuteAction`'s `executeBackgroundRunFunction` (or by a
989
+ * code action): its `status`, loop `progress`, whether it waits for `resume` (`canResume`: paused
990
+ * by `pause`, or after a failure — then `awaitingRetry` lists what failed) — polled until the run
991
+ * ends — plus `pause`, `resume` and `cancel`. Pass `undefined` until there is a run.
992
+ *
993
+ * Errors from `pause` / `resume` / `cancel` are `ActionRunError`s: branch on `error.code`
994
+ * (RUN_NOT_RESUMABLE, NOTHING_TO_RESUME, RUN_NOT_FOUND, …), never on the message.
995
+ *
996
+ * @example
997
+ * ```tsx
998
+ * const { status, progress, awaitingRetry, canPause, canResume, pause, resume, cancel } = useActionRun(run.runId);
999
+ * {canPause && <Button onClick={() => pause()}>Pause</Button>}
1000
+ * {canResume && <Button onClick={() => resume()}>Resume</Button>}
1001
+ * ```
1002
+ */
1003
+ export const useActionRun = (runId) => {
1004
+ const client = useClient();
1005
+ const queryClient = useQueryClient();
1006
+ const queryKey = ["actionRun", client.appId, runId];
1007
+ // An ended run never changes again, so nothing re-reads it (a status read of a closed
1008
+ // long-running run replays its history on a worker).
1009
+ const stillRunning = (query) => !isTerminalWorkflowStatus(query.state.data?.status);
1010
+ const { data, isLoading, error } = useQuery({
1011
+ queryKey,
1012
+ queryFn: () => client.getActionRunStatus(runId),
1013
+ enabled: !!runId,
1014
+ refetchInterval: (query) => (stillRunning(query) ? ACTION_RUN_POLL_MS : false),
1015
+ refetchOnWindowFocus: stillRunning,
1016
+ refetchOnReconnect: stillRunning,
1017
+ refetchOnMount: stillRunning,
1018
+ });
1019
+ // Read the run again right after a control call, so the UI doesn't wait for the next poll.
1020
+ const refresh = () => queryClient.invalidateQueries({ queryKey });
1021
+ const cancelMutation = useMutation({
1022
+ mutationFn: () => client.cancelActionRun(runId),
1023
+ onSettled: refresh,
1024
+ });
1025
+ const pauseMutation = useMutation({
1026
+ mutationFn: () => client.pauseActionRun(runId),
1027
+ onSettled: refresh,
1028
+ });
1029
+ const resumeMutation = useMutation({
1030
+ mutationFn: () => client.resumeActionRun(runId),
1031
+ onSettled: refresh,
1032
+ });
1033
+ const awaitingRetry = data?.awaitingRetry ?? [];
1034
+ const isManuallyPaused = data?.paused === true;
1035
+ const canResume = isManuallyPaused || awaitingRetry.length > 0;
1036
+ return {
1037
+ status: data?.status,
1038
+ progress: data?.progress,
1039
+ awaitingRetry,
1040
+ /** Paused by a `pause()` call, until `resume()`. A step already running can still fail meanwhile, so `awaitingRetry` alone can't tell this apart. */
1041
+ isManuallyPaused,
1042
+ /** The run waits for `resume()`: paused by `pause()`, or after a failure (then `awaitingRetry` lists it). Show the Resume button on this. */
1043
+ canResume,
1044
+ /** `pause` would be accepted: the run is running, not already paused, and nothing waits on it synchronously. */
1045
+ canPause: data?.status === "RUNNING" && data?.pausable !== false && !canResume,
1046
+ /** The run has ended (completed, failed or cancelled); polling has stopped. */
1047
+ isDone: isTerminalWorkflowStatus(data?.status),
1048
+ isLoading,
1049
+ error,
1050
+ cancel: cancelMutation.mutateAsync,
1051
+ isCancelling: cancelMutation.isPending,
1052
+ pause: pauseMutation.mutateAsync,
1053
+ isPausing: pauseMutation.isPending,
1054
+ resume: resumeMutation.mutateAsync,
1055
+ isResuming: resumeMutation.isPending,
1056
+ };
952
1057
  };
953
1058
  /**
954
1059
  * Hook to get an AgentChat instance
@@ -1149,7 +1254,7 @@ export const useFileUpload = () => {
1149
1254
  * @property {string} [firstName] - The user's first name (optional)
1150
1255
  * @property {string} [lastName] - The user's last name (optional)
1151
1256
  * @property {string} [role] - The user's role name (optional)
1152
- * @property {string} [permission] - The user's permission level: 'build' (can modify app) or 'use' (read-only) (optional)
1257
+ * @property {string} [permission] - The user's permission level: 'build' (can modify the app), 'manage' (can manage users and roles, sees all tenants' data) or 'use' (optional)
1153
1258
  * @property {number} [accountId] - The id of the account the user belongs to (optional)
1154
1259
  */
1155
1260
  /**
@@ -1368,7 +1473,7 @@ export const useChangeUserRole = ({ options } = {}) => {
1368
1473
  const client = useClient();
1369
1474
  const queryClient = useQueryClient();
1370
1475
  const currentUser = useUser();
1371
- const isEnabled = currentUser?.permission === "build";
1476
+ const isEnabled = canManageUsers(currentUser);
1372
1477
  const { mutateAsync: changeUserRoleFunction, isPending: isLoading, error, } = useMutation({
1373
1478
  mutationFn: ({ userId, role }) => {
1374
1479
  if (!isEnabled) {
package/dist/index.d.ts CHANGED
@@ -6,5 +6,6 @@ export * from "./Entity.js";
6
6
  export * from "./EntityQuery.js";
7
7
  export * from "./Integration.js";
8
8
  export * from "./Page.js";
9
+ export * from "./Permission.js";
9
10
  export * from "./ReactClientSdk";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -6,4 +6,5 @@ export * from "./Entity.js";
6
6
  export * from "./EntityQuery.js";
7
7
  export * from "./Integration.js";
8
8
  export * from "./Page.js";
9
+ export * from "./Permission.js";
9
10
  export * from "./ReactClientSdk";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocksdiy/blocks-client-sdk",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "type": "module",
5
5
  "description": "Blocks client sdk",
6
6
  "keywords": [],
@@ -46,8 +46,8 @@
46
46
  ]
47
47
  },
48
48
  "dependencies": {
49
- "@blocksdiy/blocks-client-api": "1.27.0",
50
- "@blocksdiy/react-common": "1.60.0",
49
+ "@blocksdiy/blocks-client-api": "1.28.0",
50
+ "@blocksdiy/react-common": "1.61.1",
51
51
  "@tanstack/react-query": "^5.101.0"
52
52
  },
53
53
  "devDependencies": {