@engini/sdk 0.37.0 → 0.38.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 +35 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.js +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/resources/_access.d.ts +47 -0
- package/dist/resources/_access.js +42 -0
- package/dist/resources/folders.d.ts +8 -6
- package/dist/resources/folders.js +9 -8
- package/dist/resources/index.d.ts +4 -0
- package/dist/resources/index.js +2 -0
- package/dist/resources/tables.d.ts +186 -0
- package/dist/resources/tables.js +283 -0
- package/dist/resources/workflows.d.ts +3 -0
- package/dist/resources/workflows.js +16 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -268,7 +268,7 @@ need a workspace-scoped API key.
|
|
|
268
268
|
`workflows.list` and `folders.list` find the ids a plan or an edit needs. With no `top` they drain
|
|
269
269
|
every match (100 per page); with `top` they return one page, and `listPage` also returns
|
|
270
270
|
`totalCount`. `name` is a case-insensitive substring match, so compare it yourself for an exact one.
|
|
271
|
-
Rows carry no steps: read a workflow back with `getPlan`. `folders.list` lists workflow folders
|
|
271
|
+
Rows carry no steps: read a workflow back with `getPlan`. `folders.list` lists workflow folders unless you pass `type: "table"`.
|
|
272
272
|
|
|
273
273
|
```ts
|
|
274
274
|
const folders = await client.folders.list({ name: "Sales" }); // substring match
|
|
@@ -310,6 +310,40 @@ try {
|
|
|
310
310
|
}
|
|
311
311
|
```
|
|
312
312
|
|
|
313
|
+
## Tables and access
|
|
314
|
+
|
|
315
|
+
`client.tables` covers `/v1/tables`: `list`, `schema`, `create`, and the sub-resources `columns`, `views`,
|
|
316
|
+
`records` (single, by filter, `batchCreate` / `batchUpdate` / `batchDelete`), `comments`, `files` and
|
|
317
|
+
`history`. Table ids are UUID strings; a table folder id comes from `folders.list({ type: "table" })`.
|
|
318
|
+
`tables.access` and `workflows.access` share one shape: `list`, `grant`, `change`, `revoke`, `setPublic`.
|
|
319
|
+
Grantees are users with the role `Owner` or `Member`, by `accountUserId` or `email`. With roles and
|
|
320
|
+
permissions (RBAC) off for the account every access call is refused 409 `RBAC_DISABLED`
|
|
321
|
+
(`EnginiBuilderError` on tables, `EnginiConflictError` on workflows - `code` / `errorCode`).
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
const [leads] = await client.tables.list({ name: "Leads" });
|
|
325
|
+
await client.tables.records.create(leads.id!, { Text1: "a@b.co" }); // record keys are column keys (see `key` in tables.schema)
|
|
326
|
+
await client.tables.records.create(leads.id!, { Email: "a@b.co" }, { columnNames: true }); // or display names, per call
|
|
327
|
+
const page = await client.tables.history.table(leads.id!, { pageSize: 20 }); // { items, totalSize }
|
|
328
|
+
await client.tables.access.grant(leads.id!, "Member", { email: "qa@acme.co" });
|
|
329
|
+
await client.workflows.access.setPublic(1234, true); // toggles IsPublic, not a user role
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Record comments (`client.tables.comments`): `list(table, record, { replies, top, offset })` (top-level,
|
|
333
|
+
newest first, with `replies`; `replies: "none"` omits them, `top` is at most 500), `get`, `add`, `reply`,
|
|
334
|
+
`edit`, `delete`, `react`, `unreact`. `add` / `reply` / `edit` take `{ text }` (stored escaped) or `{ html }`
|
|
335
|
+
(sanitized server-side, @mentions kept), exactly one. A reply to a reply lands on its top-level comment;
|
|
336
|
+
`edit` and `delete` are author-only (403); one reaction per user, so reacting with another emoji replaces it.
|
|
337
|
+
`files.attachLink(table, record, { columnKey, externalUrl, fileName? })` attaches an https Google Drive /
|
|
338
|
+
OneDrive / SharePoint link; `files.list` entries carry `Source` (`upload` | `google_drive` | `onedrive`)
|
|
339
|
+
and `ExternalUrl`.
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
const c = await client.tables.comments.add(leads.id!, 5, { text: "Called the customer" });
|
|
343
|
+
await client.tables.comments.reply(leads.id!, 5, c.commentId!, { text: "Thanks" });
|
|
344
|
+
await client.tables.comments.react(leads.id!, 5, c.commentId!, "👍");
|
|
345
|
+
```
|
|
346
|
+
|
|
313
347
|
## Files
|
|
314
348
|
|
|
315
349
|
Tools whose `inputSchema` marks a field `"format": "engini/file"` accept files. Wrap a file with
|
package/dist/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { OpaResource } from "./resources/opa.js";
|
|
|
10
10
|
import { TriggersResource } from "./resources/triggers.js";
|
|
11
11
|
import { ExecutionsResource } from "./resources/executions.js";
|
|
12
12
|
import { FoldersResource } from "./resources/folders.js";
|
|
13
|
+
import { TablesResource } from "./resources/tables.js";
|
|
13
14
|
import { WorkflowsResource } from "./resources/workflows.js";
|
|
14
15
|
import { ApplicationsResource } from "./resources/applications.js";
|
|
15
16
|
import { AuthResource } from "./resources/auth.js";
|
|
@@ -82,6 +83,7 @@ export declare class Engini {
|
|
|
82
83
|
readonly executions: ExecutionsResource;
|
|
83
84
|
readonly workflows: WorkflowsResource;
|
|
84
85
|
readonly folders: FoldersResource;
|
|
86
|
+
readonly tables: TablesResource;
|
|
85
87
|
readonly applications: ApplicationsResource;
|
|
86
88
|
readonly auth: AuthResource;
|
|
87
89
|
readonly provider: Provider;
|
package/dist/client.js
CHANGED
|
@@ -11,6 +11,7 @@ import { OpaResource } from "./resources/opa.js";
|
|
|
11
11
|
import { TriggersResource } from "./resources/triggers.js";
|
|
12
12
|
import { ExecutionsResource } from "./resources/executions.js";
|
|
13
13
|
import { FoldersResource } from "./resources/folders.js";
|
|
14
|
+
import { TablesResource } from "./resources/tables.js";
|
|
14
15
|
import { WorkflowsResource } from "./resources/workflows.js";
|
|
15
16
|
import { ApplicationsResource } from "./resources/applications.js";
|
|
16
17
|
import { AuthResource } from "./resources/auth.js";
|
|
@@ -47,6 +48,7 @@ export class Engini {
|
|
|
47
48
|
executions;
|
|
48
49
|
workflows;
|
|
49
50
|
folders;
|
|
51
|
+
tables;
|
|
50
52
|
applications;
|
|
51
53
|
auth;
|
|
52
54
|
provider;
|
|
@@ -111,6 +113,7 @@ export class Engini {
|
|
|
111
113
|
this.executions = new ExecutionsResource(this);
|
|
112
114
|
this.workflows = new WorkflowsResource(this);
|
|
113
115
|
this.folders = new FoldersResource(this);
|
|
116
|
+
this.tables = new TablesResource(this);
|
|
114
117
|
this.applications = new ApplicationsResource(this);
|
|
115
118
|
this.auth = new AuthResource(this);
|
|
116
119
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export { EnginiError, EnginiNetworkError, EnginiAPIError, EnginiAuthError, Engin
|
|
|
9
9
|
export type { EnginiAPIErrorOptions, EnginiBuilderErrorOptions, BuilderDiagnostic, } from "./errors.js";
|
|
10
10
|
export { paginateCursor } from "./pagination.js";
|
|
11
11
|
export type { CursorPage } from "./pagination.js";
|
|
12
|
-
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, OpaResource, AuthProvidersResource, TriggersResource, ApplicationsResource, ExecutionsResource, WorkflowsResource, FoldersResource, refreshFailed, verifyWebhook, } from "./resources/index.js";
|
|
13
|
-
export type { ToolsGetOptions, ToolsExecuteOptions, ApplicationsListOptions, TriggersClient, TriggerWebhookEvent, ExecutionsClient, ExecutionsListParams, WorkflowsClient, WorkflowsListParams, FoldersClient, FoldersListParams, } from "./resources/index.js";
|
|
12
|
+
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, OpaResource, AuthProvidersResource, TriggersResource, ApplicationsResource, ExecutionsResource, WorkflowsResource, FoldersResource, TablesResource, AssetAccess, refreshFailed, verifyWebhook, } from "./resources/index.js";
|
|
13
|
+
export type { ToolsGetOptions, ToolsExecuteOptions, ApplicationsListOptions, TriggersClient, TriggerWebhookEvent, ExecutionsClient, ExecutionsListParams, WorkflowsClient, WorkflowsListParams, FoldersClient, FoldersListParams, TablesClient, TablesListParams, TablesHistoryParams, RecordFilter, CommentContent, CommentsListParams, TableFile, AccessGrantee, } from "./resources/index.js";
|
|
14
14
|
export { Toolset } from "./toolset.js";
|
|
15
15
|
export type { ConnectionBinding, ToolsetExecuteOptions } from "./toolset.js";
|
|
16
16
|
export { File } from "./files.js";
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { composeUserAgent } from "./http.js";
|
|
|
4
4
|
export { VERSION } from "./version.js";
|
|
5
5
|
export { EnginiError, EnginiNetworkError, EnginiAPIError, EnginiAuthError, EnginiNotFoundError, EnginiValidationError, EnginiRateLimitError, EnginiConflictError, EnginiServerError, EnginiClientError, EnginiConnectionError, EnginiToolsetError, EnginiToolsetNotFoundError, EnginiMcpServerNotFoundError, EnginiTimeoutError, EnginiToolExecutionError, EnginiOpaAgentNotFoundError, EnginiOpaAgentOfflineError, EnginiOpaApplicationAmbiguousError, EnginiOpaAgentTimeoutError, EnginiOpaAgentDispatchError, EnginiTriggerGapError, EnginiTriggerSubscribeFailedError, EnginiTriggerStreamLimitError, EnginiWebhookSignatureError, EnginiBuilderError, } from "./errors.js";
|
|
6
6
|
export { paginateCursor } from "./pagination.js";
|
|
7
|
-
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, OpaResource, AuthProvidersResource, TriggersResource, ApplicationsResource, ExecutionsResource, WorkflowsResource, FoldersResource, refreshFailed, verifyWebhook, } from "./resources/index.js";
|
|
7
|
+
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, OpaResource, AuthProvidersResource, TriggersResource, ApplicationsResource, ExecutionsResource, WorkflowsResource, FoldersResource, TablesResource, AssetAccess, refreshFailed, verifyWebhook, } from "./resources/index.js";
|
|
8
8
|
export { Toolset } from "./toolset.js";
|
|
9
9
|
export { File } from "./files.js";
|
|
10
10
|
export { OpenAIProvider } from "./providers/openai.js";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The asset-access methods `client.tables.access` and `client.workflows.access` share: both
|
|
3
|
+
* assets serve the same five routes with the same bodies and responses, so one class fronts
|
|
4
|
+
* either set of generated operations.
|
|
5
|
+
*/
|
|
6
|
+
import type { AssetAccessEntry, AssetAccessList, AssetVisibilityRequest, ChangeAssetAccessRequest, GrantAssetAccessRequest } from "@engini/client";
|
|
7
|
+
/** The five generated calls for one asset kind, with its id already in place. */
|
|
8
|
+
export interface AccessOps<Id> {
|
|
9
|
+
list(id: Id): Promise<AssetAccessList>;
|
|
10
|
+
grant(id: Id, body: GrantAssetAccessRequest): Promise<AssetAccessEntry>;
|
|
11
|
+
change(id: Id, accountUserId: number, body: ChangeAssetAccessRequest): Promise<AssetAccessEntry>;
|
|
12
|
+
revoke(id: Id, accountUserId: number): Promise<void>;
|
|
13
|
+
setPublic(id: Id, body: AssetVisibilityRequest): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/** The grantee of `access.grant`: a user by account-user id or by email, exactly one. */
|
|
16
|
+
export type AccessGrantee = {
|
|
17
|
+
accountUserId: number;
|
|
18
|
+
email?: never;
|
|
19
|
+
} | {
|
|
20
|
+
email: string;
|
|
21
|
+
accountUserId?: never;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Who may open one table or workflow, and whether it is public.
|
|
25
|
+
*
|
|
26
|
+
* Needs roles and permissions (RBAC) on for the account: with it off every call is refused 409
|
|
27
|
+
* `RBAC_DISABLED` (every member opens every asset). Grantees are users, with the role `Owner`
|
|
28
|
+
* or `Member`.
|
|
29
|
+
*/
|
|
30
|
+
export declare class AssetAccess<Id> {
|
|
31
|
+
private readonly ops;
|
|
32
|
+
constructor(ops: AccessOps<Id>);
|
|
33
|
+
/** `isPublic` and the users with a role (`accountUserId`, `name`, `email`, `role`). */
|
|
34
|
+
list(id: Id): Promise<AssetAccessList>;
|
|
35
|
+
/**
|
|
36
|
+
* Give a user the role `Owner` or `Member`. The user must be able to open the asset's
|
|
37
|
+
* workspace and environment. A user who already has a role is refused 409 `CONFLICT`: use
|
|
38
|
+
* `change`.
|
|
39
|
+
*/
|
|
40
|
+
grant(id: Id, role: string, user: AccessGrantee): Promise<AssetAccessEntry>;
|
|
41
|
+
/** Set a user's role. Demoting the last owner is refused 409 `CONFLICT`. */
|
|
42
|
+
change(id: Id, accountUserId: number, role: string): Promise<AssetAccessEntry>;
|
|
43
|
+
/** Remove a user's role. Removing the last owner is refused 409 `CONFLICT`. */
|
|
44
|
+
revoke(id: Id, accountUserId: number): Promise<void>;
|
|
45
|
+
/** Turn the asset's `isPublic` visibility on or off (not a per-user role). */
|
|
46
|
+
setPublic(id: Id, isPublic: boolean): Promise<void>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { EnginiClientError } from "../errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Who may open one table or workflow, and whether it is public.
|
|
4
|
+
*
|
|
5
|
+
* Needs roles and permissions (RBAC) on for the account: with it off every call is refused 409
|
|
6
|
+
* `RBAC_DISABLED` (every member opens every asset). Grantees are users, with the role `Owner`
|
|
7
|
+
* or `Member`.
|
|
8
|
+
*/
|
|
9
|
+
export class AssetAccess {
|
|
10
|
+
ops;
|
|
11
|
+
constructor(ops) {
|
|
12
|
+
this.ops = ops;
|
|
13
|
+
}
|
|
14
|
+
/** `isPublic` and the users with a role (`accountUserId`, `name`, `email`, `role`). */
|
|
15
|
+
list(id) {
|
|
16
|
+
return this.ops.list(id);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Give a user the role `Owner` or `Member`. The user must be able to open the asset's
|
|
20
|
+
* workspace and environment. A user who already has a role is refused 409 `CONFLICT`: use
|
|
21
|
+
* `change`.
|
|
22
|
+
*/
|
|
23
|
+
async grant(id, role, user) {
|
|
24
|
+
const { accountUserId, email } = user;
|
|
25
|
+
if ((accountUserId === undefined) === (email === undefined)) {
|
|
26
|
+
throw new EnginiClientError("Pass exactly one of accountUserId or email.");
|
|
27
|
+
}
|
|
28
|
+
return this.ops.grant(id, { accountUserId, email, role });
|
|
29
|
+
}
|
|
30
|
+
/** Set a user's role. Demoting the last owner is refused 409 `CONFLICT`. */
|
|
31
|
+
change(id, accountUserId, role) {
|
|
32
|
+
return this.ops.change(id, accountUserId, { role });
|
|
33
|
+
}
|
|
34
|
+
/** Remove a user's role. Removing the last owner is refused 409 `CONFLICT`. */
|
|
35
|
+
revoke(id, accountUserId) {
|
|
36
|
+
return this.ops.revoke(id, accountUserId);
|
|
37
|
+
}
|
|
38
|
+
/** Turn the asset's `isPublic` visibility on or off (not a per-user role). */
|
|
39
|
+
setPublic(id, isPublic) {
|
|
40
|
+
return this.ops.setPublic(id, { isPublic });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Folders resource — the folders that organize workflows in each workspace and
|
|
3
|
-
* (`GET /v1/folders`). Use it to turn a folder name into the `folderId` that
|
|
4
|
-
* `workflows.list` and `workflows.create` take.
|
|
2
|
+
* Folders resource — the folders that organize workflows and tables in each workspace and
|
|
3
|
+
* environment (`GET /v1/folders`). Use it to turn a folder name into the `folderId` that
|
|
4
|
+
* `workflows.list` and `workflows.create` take, or with `type: "table"` the one `tables.list`
|
|
5
|
+
* and `tables.create` take (a string id).
|
|
5
6
|
*/
|
|
6
7
|
import { type FolderPublicDto, type FoldersListFoldersData } from "@engini/client";
|
|
7
8
|
import { type Transport } from "../http.js";
|
|
@@ -11,10 +12,11 @@ export interface FoldersClient {
|
|
|
11
12
|
}
|
|
12
13
|
type ListQuery = NonNullable<FoldersListFoldersData["query"]>;
|
|
13
14
|
/**
|
|
14
|
-
* Filters for `folders.list`. `type` is
|
|
15
|
-
*
|
|
15
|
+
* Filters for `folders.list`. `type` is `"workflow"` (the default) or `"table"`: this resource
|
|
16
|
+
* always sends one, never listing both kinds.
|
|
16
17
|
*/
|
|
17
18
|
export type FoldersListParams = Omit<ListQuery, "type" | "top" | "offset"> & {
|
|
19
|
+
type?: "workflow" | "table";
|
|
18
20
|
/** With `top`, fetch one page of at most `top` rows (server cap 100) instead of draining. */
|
|
19
21
|
top?: number;
|
|
20
22
|
/** Only meaningful together with `top`. */
|
|
@@ -24,7 +26,7 @@ export declare class FoldersResource {
|
|
|
24
26
|
private readonly client;
|
|
25
27
|
constructor(client: FoldersClient);
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
29
|
+
* Folders of `type` (workflow unless `"table"`), by name unless `sort` says otherwise. `name` is a case-insensitive
|
|
28
30
|
* substring match, so several folders can match: compare `name` yourself for an exact one.
|
|
29
31
|
*
|
|
30
32
|
* With no `top`, drains every match by `offset`, 100 per page. Pass `top` for one bounded page
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Folders resource — the folders that organize workflows in each workspace and
|
|
3
|
-
* (`GET /v1/folders`). Use it to turn a folder name into the `folderId` that
|
|
4
|
-
* `workflows.list` and `workflows.create` take.
|
|
2
|
+
* Folders resource — the folders that organize workflows and tables in each workspace and
|
|
3
|
+
* environment (`GET /v1/folders`). Use it to turn a folder name into the `folderId` that
|
|
4
|
+
* `workflows.list` and `workflows.create` take, or with `type: "table"` the one `tables.list`
|
|
5
|
+
* and `tables.create` take (a string id).
|
|
5
6
|
*/
|
|
6
7
|
import { foldersListFolders } from "@engini/client";
|
|
7
8
|
import { EnginiClientError } from "../errors.js";
|
|
@@ -13,7 +14,7 @@ export class FoldersResource {
|
|
|
13
14
|
this.client = client;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Folders of `type` (workflow unless `"table"`), by name unless `sort` says otherwise. `name` is a case-insensitive
|
|
17
18
|
* substring match, so several folders can match: compare `name` yourself for an exact one.
|
|
18
19
|
*
|
|
19
20
|
* With no `top`, drains every match by `offset`, 100 per page. Pass `top` for one bounded page
|
|
@@ -21,15 +22,15 @@ export class FoldersResource {
|
|
|
21
22
|
* A row deleted mid-drain can still be skipped.
|
|
22
23
|
*/
|
|
23
24
|
async list(params = {}) {
|
|
24
|
-
const { top, offset, ...filters } = params;
|
|
25
|
+
const { top, offset, type = "workflow", ...filters } = params;
|
|
25
26
|
if (top !== undefined)
|
|
26
|
-
return (await this.listPage({ ...filters, top, offset })).items ?? [];
|
|
27
|
+
return (await this.listPage({ ...filters, type, top, offset })).items ?? [];
|
|
27
28
|
if (offset !== undefined) {
|
|
28
29
|
throw new EnginiClientError("`offset` needs `top`; without `top` every page is drained from the start.");
|
|
29
30
|
}
|
|
30
31
|
const rows = await collect(paginate((skip, pageSize) => call(foldersListFolders, {
|
|
31
32
|
client: this.client._transport,
|
|
32
|
-
query: { ...filters, type
|
|
33
|
+
query: { ...filters, type, offset: skip, top: pageSize },
|
|
33
34
|
})));
|
|
34
35
|
// A folder created mid-drain shifts later pages and repeats a row: keep the first (rows without an id all stay).
|
|
35
36
|
const seen = new Set();
|
|
@@ -39,7 +40,7 @@ export class FoldersResource {
|
|
|
39
40
|
async listPage(params = {}) {
|
|
40
41
|
return call(foldersListFolders, {
|
|
41
42
|
client: this.client._transport,
|
|
42
|
-
query: { ...params, type: "workflow" },
|
|
43
|
+
query: { ...params, type: params.type ?? "workflow" },
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
}
|
|
@@ -15,5 +15,9 @@ export { WorkflowsResource } from "./workflows.js";
|
|
|
15
15
|
export type { WorkflowsClient, WorkflowsListParams } from "./workflows.js";
|
|
16
16
|
export { FoldersResource } from "./folders.js";
|
|
17
17
|
export type { FoldersClient, FoldersListParams } from "./folders.js";
|
|
18
|
+
export { TablesResource } from "./tables.js";
|
|
19
|
+
export type { TablesClient, TablesListParams, TablesHistoryParams, RecordFilter, CommentContent, CommentsListParams, TableFile, } from "./tables.js";
|
|
20
|
+
export { AssetAccess } from "./_access.js";
|
|
21
|
+
export type { AccessGrantee } from "./_access.js";
|
|
18
22
|
export { ApplicationsResource } from "./applications.js";
|
|
19
23
|
export type { ApplicationsListOptions } from "./applications.js";
|
package/dist/resources/index.js
CHANGED
|
@@ -8,4 +8,6 @@ export { TriggersResource, verifyWebhook } from "./triggers.js";
|
|
|
8
8
|
export { ExecutionsResource } from "./executions.js";
|
|
9
9
|
export { WorkflowsResource } from "./workflows.js";
|
|
10
10
|
export { FoldersResource } from "./folders.js";
|
|
11
|
+
export { TablesResource } from "./tables.js";
|
|
12
|
+
export { AssetAccess } from "./_access.js";
|
|
11
13
|
export { ApplicationsResource } from "./applications.js";
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tables resource - the caller's Engini Tables over `/v1/tables`: tables, columns, views,
|
|
3
|
+
* records (single, by filter, and batch), comments, files, history, and who may open a table.
|
|
4
|
+
*
|
|
5
|
+
* Bodies are the API's camelCase JSON. Refusals of this surface arrive as `EnginiBuilderError`
|
|
6
|
+
* (`code`, `path`, `fix`). Writes need a workspace-scoped API key.
|
|
7
|
+
*/
|
|
8
|
+
import { type RecordBatchRowV1, type RecordCommentV1Dto, type RecordFileV1Request, type RecordFilterV1, type RecordQueryV1Request, type RecordUpdateByFilterV1Request, type TableColumnDto, type TableHistoryPageV1, type TableSchemaV1Dto, type TableV1Dto, type TableViewDto, type TablesV1GetTableHistoryData, type TablesV1ListTablesData } from "@engini/client";
|
|
9
|
+
import { type Transport } from "../http.js";
|
|
10
|
+
import { AssetAccess } from "./_access.js";
|
|
11
|
+
/** Minimal client surface this resource needs (satisfied by `Engini`). */
|
|
12
|
+
export interface TablesClient {
|
|
13
|
+
_transport: Transport;
|
|
14
|
+
}
|
|
15
|
+
/** Filters for `tables.list`; the server returns one page of at most `top` (default 100). */
|
|
16
|
+
export type TablesListParams = NonNullable<TablesV1ListTablesData["query"]>;
|
|
17
|
+
/** Paging and filters for `history.table` / `history.record`; `userIds` and `actions` are comma-separated. */
|
|
18
|
+
export type TablesHistoryParams = NonNullable<TablesV1GetTableHistoryData["query"]>;
|
|
19
|
+
/** A record filter: `where` conditions ANDed unless `isAnd` is false, with paging and ordering. */
|
|
20
|
+
export type RecordFilter = RecordFilterV1;
|
|
21
|
+
/** A comment's content: plain `text` (stored escaped) or sanitized `html`, exactly one. */
|
|
22
|
+
export type CommentContent = {
|
|
23
|
+
text: string;
|
|
24
|
+
html?: never;
|
|
25
|
+
} | {
|
|
26
|
+
html: string;
|
|
27
|
+
text?: never;
|
|
28
|
+
};
|
|
29
|
+
/** Paging for `comments.list`: `replies` is `all` (default) or `none`; `top` is at most 500. */
|
|
30
|
+
export type CommentsListParams = {
|
|
31
|
+
replies?: "all" | "none";
|
|
32
|
+
top?: number;
|
|
33
|
+
offset?: number;
|
|
34
|
+
};
|
|
35
|
+
/** One entry of `files.list`: the API's PascalCase file document. */
|
|
36
|
+
export interface TableFile {
|
|
37
|
+
FileId?: string;
|
|
38
|
+
Name?: string;
|
|
39
|
+
Size?: number;
|
|
40
|
+
DownloadUrl?: string;
|
|
41
|
+
/** Set on an attached link (not signed); null or absent on an uploaded file. */
|
|
42
|
+
ExternalUrl?: string | null;
|
|
43
|
+
/** The file's type document, e.g. `{ Name: "PDF", ContentType: "application/pdf", Extensions: ".pdf" }`. */
|
|
44
|
+
FileType?: {
|
|
45
|
+
Name?: string;
|
|
46
|
+
ContentType?: string;
|
|
47
|
+
Extensions?: string;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
};
|
|
50
|
+
/** `upload`, `google_drive` or `onedrive` (SharePoint counts as onedrive). */
|
|
51
|
+
Source?: "upload" | "google_drive" | "onedrive";
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
export declare class TablesResource {
|
|
55
|
+
private readonly client;
|
|
56
|
+
readonly columns: TableColumns;
|
|
57
|
+
readonly views: TableViews;
|
|
58
|
+
readonly records: TableRecords;
|
|
59
|
+
readonly comments: TableComments;
|
|
60
|
+
readonly files: TableFiles;
|
|
61
|
+
readonly history: TableHistory;
|
|
62
|
+
/** Who may open a table, and its `isPublic` visibility; needs RBAC on for the account. */
|
|
63
|
+
readonly access: AssetAccess<string>;
|
|
64
|
+
constructor(client: TablesClient);
|
|
65
|
+
/**
|
|
66
|
+
* The tables the credential can open, in its workspace and environment. `name` is a
|
|
67
|
+
* substring match; `folderId` is a folder id from `folders.list({ type: "table" })`.
|
|
68
|
+
*/
|
|
69
|
+
list(params?: TablesListParams): Promise<TableV1Dto[]>;
|
|
70
|
+
/** The table (`table`) and its columns (`columns`). */
|
|
71
|
+
schema(tableId: string): Promise<TableSchemaV1Dto>;
|
|
72
|
+
/** Create a table; returns its schema. */
|
|
73
|
+
create(params: {
|
|
74
|
+
name: string;
|
|
75
|
+
columns?: TableColumnDto[];
|
|
76
|
+
folderId?: string;
|
|
77
|
+
isPublic?: boolean;
|
|
78
|
+
}): Promise<TableSchemaV1Dto>;
|
|
79
|
+
}
|
|
80
|
+
declare class TableColumns {
|
|
81
|
+
private readonly client;
|
|
82
|
+
constructor(client: Transport);
|
|
83
|
+
/** Add a column (`name`, `type`, ...); returns it with its `key`. */
|
|
84
|
+
add(tableId: string, column: TableColumnDto): Promise<TableColumnDto>;
|
|
85
|
+
/** Change a column; `key` is the column `key` from `tables.schema` (e.g. `"Text1"`). */
|
|
86
|
+
update(tableId: string, key: string, column: TableColumnDto): Promise<TableColumnDto>;
|
|
87
|
+
/** Delete a column; one something still uses is refused 409 unless `force`. */
|
|
88
|
+
delete(tableId: string, key: string, params?: {
|
|
89
|
+
force?: boolean;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
declare class TableViews {
|
|
93
|
+
private readonly client;
|
|
94
|
+
constructor(client: Transport);
|
|
95
|
+
/** The table's views; `name` is a substring match. */
|
|
96
|
+
list(tableId: string, params?: {
|
|
97
|
+
name?: string;
|
|
98
|
+
sort?: string;
|
|
99
|
+
}): Promise<TableViewDto[]>;
|
|
100
|
+
get(tableId: string, viewId: string): Promise<TableViewDto>;
|
|
101
|
+
create(tableId: string, view: TableViewDto): Promise<TableViewDto>;
|
|
102
|
+
update(tableId: string, viewId: string, view: TableViewDto): Promise<TableViewDto>;
|
|
103
|
+
delete(tableId: string, viewId: string): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Record keys (`values`, filter and `orderBy` field names, `fields`, and the records returned) are column keys (e.g. `Text1`, see
|
|
107
|
+
* `tables.schema`) by default; `columnNames: true` uses the columns' display names for that call instead.
|
|
108
|
+
*/
|
|
109
|
+
export interface RecordKeyOptions {
|
|
110
|
+
columnNames?: boolean;
|
|
111
|
+
}
|
|
112
|
+
declare class TableRecords {
|
|
113
|
+
private readonly client;
|
|
114
|
+
constructor(client: Transport);
|
|
115
|
+
get(tableId: string, recordId: number, opts?: RecordKeyOptions): Promise<Record<string, unknown>>;
|
|
116
|
+
/**
|
|
117
|
+
* Records matching `where` (`[{ fieldName, operator, value }]`), ANDed unless `isAnd` is
|
|
118
|
+
* false; `fields` limits the columns returned. `operator` is one of the column's `operators`
|
|
119
|
+
* (from `schema()`); a numeric `conditionId` is still accepted. A mismatch is a 400.
|
|
120
|
+
*/
|
|
121
|
+
query(tableId: string, params?: RecordQueryV1Request, opts?: RecordKeyOptions): Promise<unknown>;
|
|
122
|
+
/** Add one record; `values` maps column key (or name, with `columnNames`) to value. */
|
|
123
|
+
create(tableId: string, values: Record<string, unknown>, opts?: RecordKeyOptions): Promise<Record<string, unknown>>;
|
|
124
|
+
update(tableId: string, recordId: number, values: Record<string, unknown>, opts?: RecordKeyOptions): Promise<Record<string, unknown>>;
|
|
125
|
+
/** Delete one record; returns how many were deleted. */
|
|
126
|
+
delete(tableId: string, recordId: number): Promise<number>;
|
|
127
|
+
/** Set `values` on every record matching the filter (same shape as `query`). */
|
|
128
|
+
updateByFilter(tableId: string, params: RecordUpdateByFilterV1Request, opts?: RecordKeyOptions): Promise<Record<string, unknown>[]>;
|
|
129
|
+
/** Delete every record matching the filter; returns how many. */
|
|
130
|
+
deleteByFilter(tableId: string, filter: RecordFilter, opts?: RecordKeyOptions): Promise<number>;
|
|
131
|
+
/** Add records; each row is `{ values: {...} }`. */
|
|
132
|
+
batchCreate(tableId: string, rows: RecordBatchRowV1[], opts?: RecordKeyOptions): Promise<Record<string, unknown>[]>;
|
|
133
|
+
/** Update records; each row is `{ recordId, values }` or `{ filters, values }` (one kind per page). */
|
|
134
|
+
batchUpdate(tableId: string, rows: RecordBatchRowV1[], opts?: RecordKeyOptions): Promise<Record<string, unknown>[]>;
|
|
135
|
+
/** Delete records; each row is `{ recordId }` or `{ filters }` (one kind per page). Returns how many. */
|
|
136
|
+
batchDelete(tableId: string, rows: RecordBatchRowV1[], opts?: RecordKeyOptions): Promise<number>;
|
|
137
|
+
}
|
|
138
|
+
declare class TableComments {
|
|
139
|
+
private readonly client;
|
|
140
|
+
constructor(client: Transport);
|
|
141
|
+
/** Top-level comments, newest first, each with its `replies` unless `replies: "none"`. */
|
|
142
|
+
list(tableId: string, recordId: number, params?: CommentsListParams): Promise<RecordCommentV1Dto[]>;
|
|
143
|
+
get(tableId: string, recordId: number, commentId: number): Promise<RecordCommentV1Dto>;
|
|
144
|
+
/** Add a top-level comment as the caller. */
|
|
145
|
+
add(tableId: string, recordId: number, content: CommentContent): Promise<RecordCommentV1Dto>;
|
|
146
|
+
/** Reply to a comment; a reply to a reply lands on that reply's top-level comment (threads are one level deep). */
|
|
147
|
+
reply(tableId: string, recordId: number, commentId: number, content: CommentContent): Promise<RecordCommentV1Dto>;
|
|
148
|
+
/** Edit a comment; author only (403 otherwise). */
|
|
149
|
+
edit(tableId: string, recordId: number, commentId: number, content: CommentContent): Promise<RecordCommentV1Dto>;
|
|
150
|
+
/** Delete a comment; author only. Deleting a top-level comment deletes its replies. */
|
|
151
|
+
delete(tableId: string, recordId: number, commentId: number): Promise<void>;
|
|
152
|
+
/** React with one emoji; one reaction per user, so a different emoji replaces the caller's. Idempotent. */
|
|
153
|
+
react(tableId: string, recordId: number, commentId: number, emoji: string): Promise<RecordCommentV1Dto>;
|
|
154
|
+
/** Remove the caller's reaction; a no-op if they hold a different emoji or none. */
|
|
155
|
+
unreact(tableId: string, recordId: number, commentId: number, emoji: string): Promise<RecordCommentV1Dto>;
|
|
156
|
+
search(tableId: string, recordId: number, filter?: RecordFilter): Promise<unknown>;
|
|
157
|
+
}
|
|
158
|
+
declare class TableFiles {
|
|
159
|
+
private readonly client;
|
|
160
|
+
constructor(client: Transport);
|
|
161
|
+
/** Attach a file to a record's file column; `file` is `{ columnKey, fileName, fileBase64 }`. */
|
|
162
|
+
upload(tableId: string, recordId: number, file: RecordFileV1Request): Promise<unknown>;
|
|
163
|
+
/**
|
|
164
|
+
* Attach an https Google Drive / OneDrive / SharePoint link to a file column (other hosts are
|
|
165
|
+
* 400). Returns the file document; the link is kept as `ExternalUrl`, not copied or signed.
|
|
166
|
+
*/
|
|
167
|
+
attachLink(tableId: string, recordId: number, link: {
|
|
168
|
+
columnKey: string;
|
|
169
|
+
externalUrl: string;
|
|
170
|
+
fileName?: string;
|
|
171
|
+
}): Promise<TableFile>;
|
|
172
|
+
list(tableId: string, recordId: number, params?: {
|
|
173
|
+
columnKey?: string;
|
|
174
|
+
}): Promise<TableFile[]>;
|
|
175
|
+
/** Remove the files in one record's file column (its `key`). */
|
|
176
|
+
delete(tableId: string, recordId: number, key: string): Promise<void>;
|
|
177
|
+
}
|
|
178
|
+
declare class TableHistory {
|
|
179
|
+
private readonly client;
|
|
180
|
+
constructor(client: Transport);
|
|
181
|
+
/** One page of the table's change history (`items`, `totalSize`); needs the table-access permission. */
|
|
182
|
+
table(tableId: string, params?: TablesHistoryParams): Promise<TableHistoryPageV1>;
|
|
183
|
+
/** One page of one record's change history; a record of another table is 404. */
|
|
184
|
+
record(tableId: string, recordId: number, params?: TablesHistoryParams): Promise<TableHistoryPageV1>;
|
|
185
|
+
}
|
|
186
|
+
export {};
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tables resource - the caller's Engini Tables over `/v1/tables`: tables, columns, views,
|
|
3
|
+
* records (single, by filter, and batch), comments, files, history, and who may open a table.
|
|
4
|
+
*
|
|
5
|
+
* Bodies are the API's camelCase JSON. Refusals of this surface arrive as `EnginiBuilderError`
|
|
6
|
+
* (`code`, `path`, `fix`). Writes need a workspace-scoped API key.
|
|
7
|
+
*/
|
|
8
|
+
import { tablesV1AddColumn, tablesV1AddComment, tablesV1AddReaction, tablesV1AddReply, tablesV1ChangeAccess, tablesV1CreateRecord, tablesV1CreateRecordsBatch, tablesV1CreateTable, tablesV1CreateView, tablesV1DeleteColumn, tablesV1DeleteComment, tablesV1DeleteFiles, tablesV1DeleteRecord, tablesV1DeleteRecordsBatch, tablesV1DeleteRecordsByFilter, tablesV1DeleteView, tablesV1GetComment, tablesV1GetFiles, tablesV1GetRecord, tablesV1GetRecordHistory, tablesV1GetSchema, tablesV1GetTableHistory, tablesV1GetView, tablesV1GrantAccess, tablesV1ListAccess, tablesV1ListComments, tablesV1ListTables, tablesV1ListViews, tablesV1QueryRecords, tablesV1RemoveReaction, tablesV1RevokeAccess, tablesV1SearchComments, tablesV1SetPublic, tablesV1UpdateColumn, tablesV1UpdateComment, tablesV1UpdateRecord, tablesV1UpdateRecordsBatch, tablesV1UpdateRecordsByFilter, tablesV1UpdateView, tablesV1UploadFile, } from "@engini/client";
|
|
9
|
+
import { call } from "../http.js";
|
|
10
|
+
import { EnginiClientError } from "../errors.js";
|
|
11
|
+
import { AssetAccess } from "./_access.js";
|
|
12
|
+
/** Exactly one of `text` / `html`; the server refuses anything else, so fail before the request. */
|
|
13
|
+
function commentBody(content) {
|
|
14
|
+
const { text, html } = content;
|
|
15
|
+
if ((text === undefined) === (html === undefined)) {
|
|
16
|
+
throw new EnginiClientError("Pass exactly one of text or html.");
|
|
17
|
+
}
|
|
18
|
+
return { text, html };
|
|
19
|
+
}
|
|
20
|
+
export class TablesResource {
|
|
21
|
+
client;
|
|
22
|
+
columns;
|
|
23
|
+
views;
|
|
24
|
+
records;
|
|
25
|
+
comments;
|
|
26
|
+
files;
|
|
27
|
+
history;
|
|
28
|
+
/** Who may open a table, and its `isPublic` visibility; needs RBAC on for the account. */
|
|
29
|
+
access;
|
|
30
|
+
constructor(client) {
|
|
31
|
+
this.client = client;
|
|
32
|
+
const c = client._transport;
|
|
33
|
+
this.columns = new TableColumns(c);
|
|
34
|
+
this.views = new TableViews(c);
|
|
35
|
+
this.records = new TableRecords(c);
|
|
36
|
+
this.comments = new TableComments(c);
|
|
37
|
+
this.files = new TableFiles(c);
|
|
38
|
+
this.history = new TableHistory(c);
|
|
39
|
+
this.access = new AssetAccess({
|
|
40
|
+
list: (tableId) => call(tablesV1ListAccess, { client: c, path: { tableId } }),
|
|
41
|
+
grant: (tableId, body) => call(tablesV1GrantAccess, { client: c, path: { tableId }, body }),
|
|
42
|
+
change: (tableId, accountUserId, body) => call(tablesV1ChangeAccess, { client: c, path: { tableId, accountUserId }, body }),
|
|
43
|
+
revoke: async (tableId, accountUserId) => {
|
|
44
|
+
await call(tablesV1RevokeAccess, { client: c, path: { tableId, accountUserId } });
|
|
45
|
+
},
|
|
46
|
+
setPublic: async (tableId, body) => {
|
|
47
|
+
await call(tablesV1SetPublic, { client: c, path: { tableId }, body });
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The tables the credential can open, in its workspace and environment. `name` is a
|
|
53
|
+
* substring match; `folderId` is a folder id from `folders.list({ type: "table" })`.
|
|
54
|
+
*/
|
|
55
|
+
async list(params = {}) {
|
|
56
|
+
return call(tablesV1ListTables, { client: this.client._transport, query: params });
|
|
57
|
+
}
|
|
58
|
+
/** The table (`table`) and its columns (`columns`). */
|
|
59
|
+
async schema(tableId) {
|
|
60
|
+
return call(tablesV1GetSchema, { client: this.client._transport, path: { tableId } });
|
|
61
|
+
}
|
|
62
|
+
/** Create a table; returns its schema. */
|
|
63
|
+
async create(params) {
|
|
64
|
+
return call(tablesV1CreateTable, { client: this.client._transport, body: params });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
class TableColumns {
|
|
68
|
+
client;
|
|
69
|
+
constructor(client) {
|
|
70
|
+
this.client = client;
|
|
71
|
+
}
|
|
72
|
+
/** Add a column (`name`, `type`, ...); returns it with its `key`. */
|
|
73
|
+
async add(tableId, column) {
|
|
74
|
+
return call(tablesV1AddColumn, { client: this.client, path: { tableId }, body: column });
|
|
75
|
+
}
|
|
76
|
+
/** Change a column; `key` is the column `key` from `tables.schema` (e.g. `"Text1"`). */
|
|
77
|
+
async update(tableId, key, column) {
|
|
78
|
+
return call(tablesV1UpdateColumn, { client: this.client, path: { tableId, key }, body: column });
|
|
79
|
+
}
|
|
80
|
+
/** Delete a column; one something still uses is refused 409 unless `force`. */
|
|
81
|
+
async delete(tableId, key, params = {}) {
|
|
82
|
+
await call(tablesV1DeleteColumn, { client: this.client, path: { tableId, key }, query: params });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class TableViews {
|
|
86
|
+
client;
|
|
87
|
+
constructor(client) {
|
|
88
|
+
this.client = client;
|
|
89
|
+
}
|
|
90
|
+
/** The table's views; `name` is a substring match. */
|
|
91
|
+
async list(tableId, params = {}) {
|
|
92
|
+
return call(tablesV1ListViews, { client: this.client, path: { tableId }, query: params });
|
|
93
|
+
}
|
|
94
|
+
async get(tableId, viewId) {
|
|
95
|
+
return call(tablesV1GetView, { client: this.client, path: { tableId, viewId } });
|
|
96
|
+
}
|
|
97
|
+
async create(tableId, view) {
|
|
98
|
+
return call(tablesV1CreateView, { client: this.client, path: { tableId }, body: view });
|
|
99
|
+
}
|
|
100
|
+
async update(tableId, viewId, view) {
|
|
101
|
+
return call(tablesV1UpdateView, { client: this.client, path: { tableId, viewId }, body: view });
|
|
102
|
+
}
|
|
103
|
+
async delete(tableId, viewId) {
|
|
104
|
+
await call(tablesV1DeleteView, { client: this.client, path: { tableId, viewId } });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Only sent when set, so a default call keeps the bare URL.
|
|
108
|
+
const keyQuery = (o) => o.columnNames === undefined ? undefined : { columnNames: o.columnNames };
|
|
109
|
+
class TableRecords {
|
|
110
|
+
client;
|
|
111
|
+
constructor(client) {
|
|
112
|
+
this.client = client;
|
|
113
|
+
}
|
|
114
|
+
async get(tableId, recordId, opts = {}) {
|
|
115
|
+
return (await call(tablesV1GetRecord, {
|
|
116
|
+
client: this.client,
|
|
117
|
+
path: { tableId, recordId },
|
|
118
|
+
query: keyQuery(opts),
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Records matching `where` (`[{ fieldName, operator, value }]`), ANDed unless `isAnd` is
|
|
123
|
+
* false; `fields` limits the columns returned. `operator` is one of the column's `operators`
|
|
124
|
+
* (from `schema()`); a numeric `conditionId` is still accepted. A mismatch is a 400.
|
|
125
|
+
*/
|
|
126
|
+
async query(tableId, params = {}, opts = {}) {
|
|
127
|
+
return call(tablesV1QueryRecords, { client: this.client, path: { tableId }, body: params, query: keyQuery(opts) });
|
|
128
|
+
}
|
|
129
|
+
/** Add one record; `values` maps column key (or name, with `columnNames`) to value. */
|
|
130
|
+
async create(tableId, values, opts = {}) {
|
|
131
|
+
return (await call(tablesV1CreateRecord, {
|
|
132
|
+
client: this.client,
|
|
133
|
+
path: { tableId },
|
|
134
|
+
body: { values },
|
|
135
|
+
query: keyQuery(opts),
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
async update(tableId, recordId, values, opts = {}) {
|
|
139
|
+
return (await call(tablesV1UpdateRecord, {
|
|
140
|
+
client: this.client,
|
|
141
|
+
path: { tableId, recordId },
|
|
142
|
+
body: { values },
|
|
143
|
+
query: keyQuery(opts),
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
/** Delete one record; returns how many were deleted. */
|
|
147
|
+
async delete(tableId, recordId) {
|
|
148
|
+
return call(tablesV1DeleteRecord, { client: this.client, path: { tableId, recordId } });
|
|
149
|
+
}
|
|
150
|
+
/** Set `values` on every record matching the filter (same shape as `query`). */
|
|
151
|
+
async updateByFilter(tableId, params, opts = {}) {
|
|
152
|
+
return (await call(tablesV1UpdateRecordsByFilter, {
|
|
153
|
+
client: this.client,
|
|
154
|
+
path: { tableId },
|
|
155
|
+
body: params,
|
|
156
|
+
query: keyQuery(opts),
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
/** Delete every record matching the filter; returns how many. */
|
|
160
|
+
async deleteByFilter(tableId, filter, opts = {}) {
|
|
161
|
+
return call(tablesV1DeleteRecordsByFilter, { client: this.client, path: { tableId }, body: filter, query: keyQuery(opts) });
|
|
162
|
+
}
|
|
163
|
+
/** Add records; each row is `{ values: {...} }`. */
|
|
164
|
+
async batchCreate(tableId, rows, opts = {}) {
|
|
165
|
+
return (await call(tablesV1CreateRecordsBatch, {
|
|
166
|
+
client: this.client,
|
|
167
|
+
path: { tableId },
|
|
168
|
+
body: { rows },
|
|
169
|
+
query: keyQuery(opts),
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
/** Update records; each row is `{ recordId, values }` or `{ filters, values }` (one kind per page). */
|
|
173
|
+
async batchUpdate(tableId, rows, opts = {}) {
|
|
174
|
+
return (await call(tablesV1UpdateRecordsBatch, {
|
|
175
|
+
client: this.client,
|
|
176
|
+
path: { tableId },
|
|
177
|
+
body: { rows },
|
|
178
|
+
query: keyQuery(opts),
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
/** Delete records; each row is `{ recordId }` or `{ filters }` (one kind per page). Returns how many. */
|
|
182
|
+
async batchDelete(tableId, rows, opts = {}) {
|
|
183
|
+
return call(tablesV1DeleteRecordsBatch, { client: this.client, path: { tableId }, body: { rows }, query: keyQuery(opts) });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
class TableComments {
|
|
187
|
+
client;
|
|
188
|
+
constructor(client) {
|
|
189
|
+
this.client = client;
|
|
190
|
+
}
|
|
191
|
+
/** Top-level comments, newest first, each with its `replies` unless `replies: "none"`. */
|
|
192
|
+
async list(tableId, recordId, params = {}) {
|
|
193
|
+
return call(tablesV1ListComments, { client: this.client, path: { tableId, recordId }, query: params });
|
|
194
|
+
}
|
|
195
|
+
async get(tableId, recordId, commentId) {
|
|
196
|
+
return call(tablesV1GetComment, { client: this.client, path: { tableId, recordId, commentId } });
|
|
197
|
+
}
|
|
198
|
+
/** Add a top-level comment as the caller. */
|
|
199
|
+
async add(tableId, recordId, content) {
|
|
200
|
+
return call(tablesV1AddComment, {
|
|
201
|
+
client: this.client,
|
|
202
|
+
path: { tableId, recordId },
|
|
203
|
+
body: commentBody(content),
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/** Reply to a comment; a reply to a reply lands on that reply's top-level comment (threads are one level deep). */
|
|
207
|
+
async reply(tableId, recordId, commentId, content) {
|
|
208
|
+
return call(tablesV1AddReply, {
|
|
209
|
+
client: this.client,
|
|
210
|
+
path: { tableId, recordId, commentId },
|
|
211
|
+
body: commentBody(content),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/** Edit a comment; author only (403 otherwise). */
|
|
215
|
+
async edit(tableId, recordId, commentId, content) {
|
|
216
|
+
return call(tablesV1UpdateComment, {
|
|
217
|
+
client: this.client,
|
|
218
|
+
path: { tableId, recordId, commentId },
|
|
219
|
+
body: commentBody(content),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/** Delete a comment; author only. Deleting a top-level comment deletes its replies. */
|
|
223
|
+
async delete(tableId, recordId, commentId) {
|
|
224
|
+
await call(tablesV1DeleteComment, { client: this.client, path: { tableId, recordId, commentId } });
|
|
225
|
+
}
|
|
226
|
+
/** React with one emoji; one reaction per user, so a different emoji replaces the caller's. Idempotent. */
|
|
227
|
+
async react(tableId, recordId, commentId, emoji) {
|
|
228
|
+
return call(tablesV1AddReaction, { client: this.client, path: { tableId, recordId, commentId, emoji } });
|
|
229
|
+
}
|
|
230
|
+
/** Remove the caller's reaction; a no-op if they hold a different emoji or none. */
|
|
231
|
+
async unreact(tableId, recordId, commentId, emoji) {
|
|
232
|
+
return call(tablesV1RemoveReaction, { client: this.client, path: { tableId, recordId, commentId, emoji } });
|
|
233
|
+
}
|
|
234
|
+
async search(tableId, recordId, filter = {}) {
|
|
235
|
+
return call(tablesV1SearchComments, { client: this.client, path: { tableId, recordId }, body: filter });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
class TableFiles {
|
|
239
|
+
client;
|
|
240
|
+
constructor(client) {
|
|
241
|
+
this.client = client;
|
|
242
|
+
}
|
|
243
|
+
/** Attach a file to a record's file column; `file` is `{ columnKey, fileName, fileBase64 }`. */
|
|
244
|
+
async upload(tableId, recordId, file) {
|
|
245
|
+
return call(tablesV1UploadFile, { client: this.client, path: { tableId, recordId }, body: file });
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Attach an https Google Drive / OneDrive / SharePoint link to a file column (other hosts are
|
|
249
|
+
* 400). Returns the file document; the link is kept as `ExternalUrl`, not copied or signed.
|
|
250
|
+
*/
|
|
251
|
+
async attachLink(tableId, recordId, link) {
|
|
252
|
+
return (await call(tablesV1UploadFile, {
|
|
253
|
+
client: this.client,
|
|
254
|
+
path: { tableId, recordId },
|
|
255
|
+
body: link,
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
async list(tableId, recordId, params = {}) {
|
|
259
|
+
return (await call(tablesV1GetFiles, {
|
|
260
|
+
client: this.client,
|
|
261
|
+
path: { tableId, recordId },
|
|
262
|
+
query: params,
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
/** Remove the files in one record's file column (its `key`). */
|
|
266
|
+
async delete(tableId, recordId, key) {
|
|
267
|
+
await call(tablesV1DeleteFiles, { client: this.client, path: { tableId, recordId, key } });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
class TableHistory {
|
|
271
|
+
client;
|
|
272
|
+
constructor(client) {
|
|
273
|
+
this.client = client;
|
|
274
|
+
}
|
|
275
|
+
/** One page of the table's change history (`items`, `totalSize`); needs the table-access permission. */
|
|
276
|
+
async table(tableId, params = {}) {
|
|
277
|
+
return call(tablesV1GetTableHistory, { client: this.client, path: { tableId }, query: params });
|
|
278
|
+
}
|
|
279
|
+
/** One page of one record's change history; a record of another table is 404. */
|
|
280
|
+
async record(tableId, recordId, params = {}) {
|
|
281
|
+
return call(tablesV1GetRecordHistory, { client: this.client, path: { tableId, recordId }, query: params });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
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";
|
|
13
13
|
import { type Transport } from "../http.js";
|
|
14
|
+
import { AssetAccess } from "./_access.js";
|
|
14
15
|
/** Minimal client surface this resource needs (satisfied by `Engini`). */
|
|
15
16
|
export interface WorkflowsClient {
|
|
16
17
|
_transport: Transport;
|
|
@@ -27,6 +28,8 @@ export type WorkflowsListParams = Omit<ListQuery, "top" | "offset"> & {
|
|
|
27
28
|
};
|
|
28
29
|
export declare class WorkflowsResource {
|
|
29
30
|
private readonly client;
|
|
31
|
+
/** Who may open a workflow, and its `isPublic` visibility; needs RBAC on for the account. */
|
|
32
|
+
readonly access: AssetAccess<number>;
|
|
30
33
|
constructor(client: WorkflowsClient);
|
|
31
34
|
/**
|
|
32
35
|
* Workflows the credential can see, without their steps (read one back as a plan with `getPlan`).
|
|
@@ -9,14 +9,29 @@
|
|
|
9
9
|
* `currentRevisionId`). Writes need a workspace-scoped API key (`SCOPE_REQUIRED` otherwise),
|
|
10
10
|
* and a workflow is always created turned off.
|
|
11
11
|
*/
|
|
12
|
-
import { workflowsCompile, workflowsCreateWorkflow, workflowsDeleteWorkflow, workflowsGetOptions, workflowsGetPlan, workflowsGetSchema, workflowsGetWorkflow, workflowsListConnections, workflowsListRevisions, workflowsListTableColumns, workflowsListTables, workflowsListWorkflows, workflowsRunWorkflow, workflowsSearchCatalog, workflowsSetWorkflowEnabled, workflowsUpdateWorkflow, } from "@engini/client";
|
|
12
|
+
import { workflowsChangeAccess, workflowsCompile, workflowsCreateWorkflow, workflowsDeleteWorkflow, workflowsGetOptions, workflowsGetPlan, workflowsGetSchema, workflowsGetWorkflow, workflowsGrantAccess, workflowsListAccess, workflowsListConnections, workflowsListRevisions, workflowsListTableColumns, workflowsListTables, workflowsListWorkflows, workflowsRevokeAccess, workflowsRunWorkflow, workflowsSearchCatalog, workflowsSetPublic, workflowsSetWorkflowEnabled, workflowsUpdateWorkflow, } from "@engini/client";
|
|
13
13
|
import { EnginiClientError } from "../errors.js";
|
|
14
14
|
import { call } from "../http.js";
|
|
15
15
|
import { collect, paginate } from "../pagination.js";
|
|
16
|
+
import { AssetAccess } from "./_access.js";
|
|
16
17
|
export class WorkflowsResource {
|
|
17
18
|
client;
|
|
19
|
+
/** Who may open a workflow, and its `isPublic` visibility; needs RBAC on for the account. */
|
|
20
|
+
access;
|
|
18
21
|
constructor(client) {
|
|
19
22
|
this.client = client;
|
|
23
|
+
const c = client._transport;
|
|
24
|
+
this.access = new AssetAccess({
|
|
25
|
+
list: (workflowId) => call(workflowsListAccess, { client: c, path: { workflowId } }),
|
|
26
|
+
grant: (workflowId, body) => call(workflowsGrantAccess, { client: c, path: { workflowId }, body }),
|
|
27
|
+
change: (workflowId, accountUserId, body) => call(workflowsChangeAccess, { client: c, path: { workflowId, accountUserId }, body }),
|
|
28
|
+
revoke: async (workflowId, accountUserId) => {
|
|
29
|
+
await call(workflowsRevokeAccess, { client: c, path: { workflowId, accountUserId } });
|
|
30
|
+
},
|
|
31
|
+
setPublic: async (workflowId, body) => {
|
|
32
|
+
await call(workflowsSetPublic, { client: c, path: { workflowId }, body });
|
|
33
|
+
},
|
|
34
|
+
});
|
|
20
35
|
}
|
|
21
36
|
/**
|
|
22
37
|
* Workflows the credential can see, without their steps (read one back as a plan with `getPlan`).
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@engini/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.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.
|
|
30
|
+
"@engini/client": "0.24.0",
|
|
31
31
|
"undici": "^6.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|