@engini/sdk 0.34.0 → 0.35.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/README.md CHANGED
@@ -200,8 +200,8 @@ for await (const event of client.triggers.subscribe({
200
200
 
201
201
  ## Executions
202
202
 
203
- `client.executions` is the read-only run history of workflows, table automations and
204
- business rules (no rerun):
203
+ `client.executions` is the run history of workflows, table automations and
204
+ business rules, and `rerun` runs one again:
205
205
 
206
206
  ```ts
207
207
  // Every failed run of one workflow. With no `top` this follows `nextCursor` until it is
@@ -223,6 +223,30 @@ const slowest = (await client.executions.data(4567, 3, { type: "status" }))
223
223
  Sorting by `closedAt` (or several keys) has no cursor on the server, so `list` drains those
224
224
  by `offset` instead.
225
225
 
226
+ ```ts
227
+ const again = await client.executions.rerun(4567); // the new execution; EnginiConflictError (409) if it cannot be re-run
228
+ ```
229
+
230
+ `rerun` needs a workspace-scoped API key (an unscoped key gets `EnginiAuthError`, `errorCode`
231
+ `SCOPE_READ_ONLY`) and has no idempotency key: a retry after a lost answer starts a second run.
232
+
233
+ ## Reading and running a workflow
234
+
235
+ `workflows.get` returns one workflow with its steps (and `webhookUrl` for a webhook trigger - its token
236
+ authorizes calls to it, so treat it like a credential); `workflows.revisions` returns one page of its stored
237
+ revisions, newest first. `setEnabled`, `delete` and `run` change state and need a workspace-scoped API key
238
+ (an unscoped key gets `EnginiAuthError` with `errorCode` `SCOPE_READ_ONLY`; reads still work). `delete` is a
239
+ soft delete and succeeds for an already-deleted workflow. `run` starts one run now, even for a turned-off
240
+ workflow, and has no idempotency key: a retry after a lost answer starts a second run.
241
+
242
+ ```ts
243
+ const wf = await client.workflows.get(1234); // wf.steps, wf.webhookUrl
244
+ const revs = await client.workflows.revisions(1234, { top: 10 }); // { items, totalCount, offset, top }
245
+ await client.workflows.setEnabled(1234, true);
246
+ const execution = await client.workflows.run(1234, { email: "a@b.co" }); // trigger payload, default {}
247
+ await client.workflows.delete(1234);
248
+ ```
249
+
226
250
  ## Building workflows
227
251
 
228
252
  `client.workflows` is the workflow builder: look up what a plan may use, dry-run it, then
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Executions resource — read-only history of workflow, table-automation and
3
- * business-rule runs (`/v1/executions*`). There is no rerun on this surface.
2
+ * Executions resource — history of workflow, table-automation and business-rule runs
3
+ * (`/v1/executions*`), and `rerun` to run one again.
4
4
  */
5
5
  import { type ExecutionDataEntryPublicDto, type ExecutionLogEntryPublicDto, type ExecutionPublicDto, type ExecutionsListExecutionsData } from "@engini/client";
6
6
  import { type Transport } from "../http.js";
@@ -39,6 +39,13 @@ export declare class ExecutionsResource {
39
39
  listPage(params?: ExecutionsListParams): Promise<import("@engini/client").CursorPaginatedResponseOfExecutionPublicDto>;
40
40
  /** One execution. */
41
41
  get(executionId: number): Promise<ExecutionPublicDto>;
42
+ /**
43
+ * Run an execution again; returns the new execution. A run that is still in progress, or of
44
+ * a kind that cannot be re-run, or an account limit, is refused with `EnginiConflictError`
45
+ * (409). Needs a workspace-scoped API key: 403 `SCOPE_READ_ONLY` otherwise. There is no
46
+ * idempotency key: a retry after a lost answer starts a second run.
47
+ */
48
+ rerun(executionId: number): Promise<ExecutionPublicDto>;
42
49
  /**
43
50
  * The execution's per-step log. A 410 (retention window passed) throws
44
51
  * `EnginiAPIError` — the execution itself is still listed.
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Executions resource — read-only history of workflow, table-automation and
3
- * business-rule runs (`/v1/executions*`). There is no rerun on this surface.
2
+ * Executions resource — history of workflow, table-automation and business-rule runs
3
+ * (`/v1/executions*`), and `rerun` to run one again.
4
4
  */
5
- import { executionsGetExecution, executionsGetExecutionLog, executionsListExecutionData, executionsListExecutions, } from "@engini/client";
5
+ import { executionsGetExecution, executionsGetExecutionLog, executionsListExecutionData, executionsListExecutions, executionsRerunExecution, } from "@engini/client";
6
6
  import { EnginiClientError } from "../errors.js";
7
7
  import { call } from "../http.js";
8
8
  import { collect, paginate, paginateCursor } from "../pagination.js";
@@ -67,6 +67,18 @@ export class ExecutionsResource {
67
67
  path: { executionId },
68
68
  });
69
69
  }
70
+ /**
71
+ * Run an execution again; returns the new execution. A run that is still in progress, or of
72
+ * a kind that cannot be re-run, or an account limit, is refused with `EnginiConflictError`
73
+ * (409). Needs a workspace-scoped API key: 403 `SCOPE_READ_ONLY` otherwise. There is no
74
+ * idempotency key: a retry after a lost answer starts a second run.
75
+ */
76
+ async rerun(executionId) {
77
+ return call(executionsRerunExecution, {
78
+ client: this.client._transport,
79
+ path: { executionId },
80
+ });
81
+ }
70
82
  /**
71
83
  * The execution's per-step log. A 410 (retention window passed) throws
72
84
  * `EnginiAPIError` — the execution itself is still listed.
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Workflows resource — list workflows (`GET /v1/workflows`) and the workflow builder
2
+ * Workflows resource — list workflows (`GET /v1/workflows`), read one (`get`, `revisions`), turn
3
+ * one on or off, delete it, run it (`setEnabled`, `delete`, `run`), and the workflow builder
3
4
  * (`/v1/workflows*`): look up what a plan may use
4
5
  * (catalog, schemas, options, tables, connections), dry-run a plan with `compile`, and write
5
6
  * one with `create` / `update`.
@@ -8,13 +9,15 @@
8
9
  * `currentRevisionId`). Writes need a workspace-scoped API key (`SCOPE_REQUIRED` otherwise),
9
10
  * and a workflow is always created turned off.
10
11
  */
11
- import { type BuilderConnectionInfo, type CatalogHit, type CompiledWorkflowDto, type CreateFromPlanResponse, type OptionItem, type TableColumn, type TableItem, type ToolSchema as BuilderToolSchema, type UpdateFromPlanResponse, type WorkflowPlan, type WorkflowPublicDto, type WorkflowsListWorkflowsData } from "@engini/client";
12
+ import { type BuilderConnectionInfo, type CatalogHit, type CompiledWorkflowDto, type CreateFromPlanResponse, type ExecutionPublicDto, type OptionItem, type PaginatedResponseOfWorkflowRevisionPublicDto, type TableColumn, type TableItem, type ToolSchema as BuilderToolSchema, type UpdateFromPlanResponse, type WorkflowDetailPublicDto, type WorkflowPlan, type WorkflowPublicDto, type WorkflowsListRevisionsData, type WorkflowsListWorkflowsData } from "@engini/client";
12
13
  import { type Transport } from "../http.js";
13
14
  /** Minimal client surface this resource needs (satisfied by `Engini`). */
14
15
  export interface WorkflowsClient {
15
16
  _transport: Transport;
16
17
  }
17
18
  type ListQuery = NonNullable<WorkflowsListWorkflowsData["query"]>;
19
+ /** Filters, sort and paging for `workflows.revisions` (one page; `top` is capped at 100 by the server). */
20
+ export type WorkflowRevisionsParams = NonNullable<WorkflowsListRevisionsData["query"]>;
18
21
  /** Filters for `workflows.list`; `top` / `offset` are handled by the method. */
19
22
  export type WorkflowsListParams = Omit<ListQuery, "top" | "offset"> & {
20
23
  /** With `top`, fetch one page of at most `top` rows (server cap 100) instead of draining. */
@@ -38,6 +41,34 @@ export declare class WorkflowsResource {
38
41
  list(params?: WorkflowsListParams): Promise<WorkflowPublicDto[]>;
39
42
  /** One page, with its `totalCount`. */
40
43
  listPage(params?: WorkflowsListParams): Promise<import("@engini/client").PaginatedResponseOfWorkflowPublicDto>;
44
+ /**
45
+ * One workflow with its steps. `webhookUrl` is present only for a webhook trigger Engini hands
46
+ * out; the token inside it authorizes calls to it, so treat it like a credential.
47
+ */
48
+ get(workflowId: number): Promise<WorkflowDetailPublicDto>;
49
+ /**
50
+ * One page of a workflow's stored revisions, newest first by default (`revisionId desc`),
51
+ * with `totalCount`. Restoring a revision is not part of the API.
52
+ */
53
+ revisions(workflowId: number, params?: WorkflowRevisionsParams): Promise<PaginatedResponseOfWorkflowRevisionPublicDto>;
54
+ /**
55
+ * Turn a workflow on or off; returns the workflow as it stands afterwards. Needs a
56
+ * workspace-scoped API key (an unscoped key is refused 403 `SCOPE_READ_ONLY`). Turning on a
57
+ * workflow created through the API is how it starts listening: it is always created off.
58
+ */
59
+ setEnabled(workflowId: number, enabled: boolean): Promise<WorkflowPublicDto>;
60
+ /**
61
+ * Delete a workflow (a soft delete). Succeeds, with no result, for an already-deleted one.
62
+ * Needs a workspace-scoped API key: 403 `SCOPE_READ_ONLY` otherwise.
63
+ */
64
+ delete(workflowId: number): Promise<void>;
65
+ /**
66
+ * Start one run now; `body` is the trigger payload handed to the workflow's trigger step.
67
+ * Returns the execution that was started (read its outcome with `executions.get`). A
68
+ * disabled or blocked workflow may still be run this way. There is no idempotency key: a
69
+ * retry after a lost answer starts a second run.
70
+ */
71
+ run(workflowId: number, body?: Record<string, unknown>): Promise<ExecutionPublicDto>;
41
72
  /** Search the catalog of actions, triggers and blocks a plan step can name. */
42
73
  searchCatalog(params?: {
43
74
  q?: string;
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Workflows resource — list workflows (`GET /v1/workflows`) and the workflow builder
2
+ * Workflows resource — list workflows (`GET /v1/workflows`), read one (`get`, `revisions`), turn
3
+ * one on or off, delete it, run it (`setEnabled`, `delete`, `run`), and the workflow builder
3
4
  * (`/v1/workflows*`): look up what a plan may use
4
5
  * (catalog, schemas, options, tables, connections), dry-run a plan with `compile`, and write
5
6
  * one with `create` / `update`.
@@ -8,7 +9,7 @@
8
9
  * `currentRevisionId`). Writes need a workspace-scoped API key (`SCOPE_REQUIRED` otherwise),
9
10
  * and a workflow is always created turned off.
10
11
  */
11
- import { workflowsCompile, workflowsCreateWorkflow, workflowsGetOptions, workflowsGetPlan, workflowsGetSchema, workflowsListConnections, workflowsListTableColumns, workflowsListTables, workflowsListWorkflows, workflowsSearchCatalog, workflowsUpdateWorkflow, } from "@engini/client";
12
+ import { workflowsCompile, workflowsCreateWorkflow, workflowsDeleteWorkflow, workflowsGetOptions, workflowsGetPlan, workflowsGetSchema, workflowsGetWorkflow, workflowsListConnections, workflowsListRevisions, workflowsListTableColumns, workflowsListTables, workflowsListWorkflows, workflowsRunWorkflow, workflowsSearchCatalog, workflowsSetWorkflowEnabled, workflowsUpdateWorkflow, } from "@engini/client";
12
13
  import { EnginiClientError } from "../errors.js";
13
14
  import { call } from "../http.js";
14
15
  import { collect, paginate } from "../pagination.js";
@@ -46,6 +47,56 @@ export class WorkflowsResource {
46
47
  async listPage(params = {}) {
47
48
  return call(workflowsListWorkflows, { client: this.client._transport, query: params });
48
49
  }
50
+ /**
51
+ * One workflow with its steps. `webhookUrl` is present only for a webhook trigger Engini hands
52
+ * out; the token inside it authorizes calls to it, so treat it like a credential.
53
+ */
54
+ async get(workflowId) {
55
+ return call(workflowsGetWorkflow, { client: this.client._transport, path: { workflowId } });
56
+ }
57
+ /**
58
+ * One page of a workflow's stored revisions, newest first by default (`revisionId desc`),
59
+ * with `totalCount`. Restoring a revision is not part of the API.
60
+ */
61
+ async revisions(workflowId, params = {}) {
62
+ return call(workflowsListRevisions, {
63
+ client: this.client._transport,
64
+ path: { workflowId },
65
+ query: params,
66
+ });
67
+ }
68
+ /**
69
+ * Turn a workflow on or off; returns the workflow as it stands afterwards. Needs a
70
+ * workspace-scoped API key (an unscoped key is refused 403 `SCOPE_READ_ONLY`). Turning on a
71
+ * workflow created through the API is how it starts listening: it is always created off.
72
+ */
73
+ async setEnabled(workflowId, enabled) {
74
+ return call(workflowsSetWorkflowEnabled, {
75
+ client: this.client._transport,
76
+ path: { workflowId },
77
+ body: { enabled },
78
+ });
79
+ }
80
+ /**
81
+ * Delete a workflow (a soft delete). Succeeds, with no result, for an already-deleted one.
82
+ * Needs a workspace-scoped API key: 403 `SCOPE_READ_ONLY` otherwise.
83
+ */
84
+ async delete(workflowId) {
85
+ await call(workflowsDeleteWorkflow, { client: this.client._transport, path: { workflowId } });
86
+ }
87
+ /**
88
+ * Start one run now; `body` is the trigger payload handed to the workflow's trigger step.
89
+ * Returns the execution that was started (read its outcome with `executions.get`). A
90
+ * disabled or blocked workflow may still be run this way. There is no idempotency key: a
91
+ * retry after a lost answer starts a second run.
92
+ */
93
+ async run(workflowId, body = {}) {
94
+ return call(workflowsRunWorkflow, {
95
+ client: this.client._transport,
96
+ path: { workflowId },
97
+ body,
98
+ });
99
+ }
49
100
  /** Search the catalog of actions, triggers and blocks a plan step can name. */
50
101
  async searchCatalog(params = {}) {
51
102
  return call(workflowsSearchCatalog, { client: this.client._transport, query: params });
package/dist/version.d.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  * Regenerated on every build/typecheck/test (see the "pre*" scripts in
4
4
  * package.json). Un-stamped local builds yield "0.0.0".
5
5
  */
6
- export declare const VERSION = "0.34.0";
6
+ export declare const VERSION = "0.35.0";
package/dist/version.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Regenerated on every build/typecheck/test (see the "pre*" scripts in
4
4
  * package.json). Un-stamped local builds yield "0.0.0".
5
5
  */
6
- export const VERSION = "0.34.0";
6
+ export const VERSION = "0.35.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engini/sdk",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Engini SDK — agent-first ergonomic layer over the Engini Public API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "test": "vitest run"
28
28
  },
29
29
  "dependencies": {
30
- "@engini/client": "0.21.0",
30
+ "@engini/client": "0.22.0",
31
31
  "undici": "^6.0.0"
32
32
  },
33
33
  "devDependencies": {