Skip to content

Commit 7b75915

Browse files
committed
docs: add HTML page SDK API references
1 parent 7e40c39 commit 7b75915

6 files changed

Lines changed: 495 additions & 3 deletions

File tree

‎docs/html-pages/index.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ flowchart LR
2424

2525
The SDK offers:
2626

27-
- **Data APIs** — list, add, update and delete rows; upload files and images.
27+
- **Data APIs** — list, add, update and delete rows; manage links; upload files and images.
28+
- **User APIs** — read the signed-in user and resolve collaborators.
29+
- **Action APIs** — send notifications and emails, and run configured Python scripts.
2830
- **Event propagation** — bidirectional events (mouse, keyboard, drag-and-drop) between the page and the app.
2931

3032
## Prerequisites
@@ -66,7 +68,7 @@ The same kind of page can be built two ways. Pick the one that matches how you l
6668

6769
- [Low-code quickstart](low-code-quickstart.md) — build a page with a visual editor and copy-paste snippets, no toolchain.
6870
- [Developer setup](getting-started.md) — set up the project, develop locally, build and upload a page. We follow the official [simple form template](https://github.com/seatable/seatable-html-page-template-simple-form) end to end.
69-
- [SDK Reference](sdk/initialization.md) — installation, initialization, and the full API for rows, files and images.
71+
- [SDK Reference](sdk/initialization.md) — installation, initialization, and the full API for rows, links, users, actions, files and images.
7072

7173
!!! tip "Example project"
7274

‎docs/html-pages/sdk/actions.md‎

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
---
2+
description: seatable-html-page-sdk reference for sending notifications and emails, and running configured Python scripts from an HTML page.
3+
---
4+
5+
# Actions
6+
7+
Action operations on the `seatable-html-page-sdk`. They start asynchronous notification, email, or Python-script tasks. All methods are asynchronous — `await` them. The `sdk` instance below is created and initialized as shown in [Initialization](initialization.md).
8+
9+
!!! warning "Response format"
10+
11+
Action methods resolve to the underlying HTTP response. Read the payload from `.data`. Methods that start a task return its identifier in `.data.task_id`; retain this ID when the page needs to query task progress or results.
12+
13+
## Notifications and email
14+
15+
!!! abstract "sendNotification"
16+
17+
Create a notification task associated with one row.
18+
19+
```js
20+
sdk.sendNotification({ tableName, rowId, emails, msg });
21+
```
22+
23+
__Parameters__
24+
25+
`tableName`
26+
: string — display name of the table containing the row
27+
28+
`rowId`
29+
: string — `_id` of the row associated with the notification
30+
31+
`emails`
32+
: array — non-empty list of recipient email addresses
33+
34+
`msg`
35+
: string — non-empty notification text. It can contain row-value template placeholders such as `{Order number}`.
36+
37+
__Returns__ `.data` holds `{ task_id }` — use `task_id` with `getMessageStatus`.
38+
39+
__Example__
40+
```js
41+
const res = await sdk.sendNotification({
42+
tableName: "Orders",
43+
rowId: "fcHIocncTsOygA3FjL-toQ",
44+
emails: ["a7f34c91e2bd4d6b8a50f1c73e9d2a48@auth.local"],
45+
msg: "Your order {Order number} has been shipped.",
46+
});
47+
const taskId = res.data.task_id;
48+
```
49+
50+
!!! abstract "sendEmail"
51+
52+
Create an email task associated with one row.
53+
54+
```js
55+
sdk.sendEmail({
56+
tableName,
57+
rowId,
58+
accountName,
59+
sendTo,
60+
copyTo,
61+
replyTo,
62+
subject,
63+
message,
64+
htmlMessage,
65+
attachmentColumnNames,
66+
});
67+
```
68+
69+
__Parameters__
70+
71+
`tableName`
72+
: string — display name of the table containing the row
73+
74+
`rowId`
75+
: string — `_id` of the row associated with the email
76+
77+
`accountName`
78+
: string — name of the configured email account
79+
80+
`sendTo`
81+
: array — non-empty list of recipient email addresses or row-value templates
82+
83+
`copyTo`
84+
: array — optional list of CC email addresses or row-value templates
85+
86+
`replyTo`
87+
: string — optional Reply-To email address or row-value template
88+
89+
`subject`
90+
: string — non-empty plain-text email subject
91+
92+
`message`
93+
: string — plain-text body template
94+
95+
`htmlMessage`
96+
: string — HTML body template
97+
98+
`attachmentColumnNames`
99+
: array — optional list of FILE column display names; do not use column keys
100+
101+
`message` and `htmlMessage` must provide exactly one body: do not pass both, and do not omit both. Recipient values and the message body can use row-value template placeholders such as `{Customer email}` and `{Order number}`.
102+
103+
__Returns__ `.data` holds `{ task_id }` — use `task_id` with `getMessageStatus`.
104+
105+
__Example__
106+
```js
107+
const res = await sdk.sendEmail({
108+
tableName: "Orders",
109+
rowId: "fcHIocncTsOygA3FjL-toQ",
110+
accountName: "Operations SMTP",
111+
sendTo: ["customer@example.com"],
112+
copyTo: ["orders-audit@example.com"],
113+
replyTo: "support@example.com",
114+
subject: "Order shipment notification",
115+
htmlMessage: "<p>Your order <strong>{Order number}</strong> has been shipped.</p>",
116+
attachmentColumnNames: ["Invoice"],
117+
});
118+
const taskId = res.data.task_id;
119+
```
120+
121+
!!! abstract "getMessageStatus"
122+
123+
Get the status of a notification or email task returned by `sendNotification` or `sendEmail`.
124+
125+
```js
126+
sdk.getMessageStatus({ taskId });
127+
```
128+
129+
__Parameters__
130+
131+
`taskId`
132+
: string — task identifier returned in `response.data.task_id`
133+
134+
__Example__
135+
```js
136+
const res = await sdk.getMessageStatus({ taskId });
137+
if (res.data.is_finished) {
138+
// Stop polling and update the UI.
139+
}
140+
```
141+
142+
Do not query the status until the task-starting method has returned its `task_id`.
143+
144+
## Python scripts
145+
146+
!!! abstract "runScript"
147+
148+
Start a configured Python script.
149+
150+
```js
151+
sdk.runScript({ scriptName, tableName, rowId });
152+
```
153+
154+
__Parameters__
155+
156+
`scriptName`
157+
: string — displayed name of the configured script, not its internal ID or file name
158+
159+
`tableName`
160+
: string — optional display name of the table that supplies the row context
161+
162+
`rowId`
163+
: string — optional `_id` of the row that supplies the row context
164+
165+
Provide `tableName` and `rowId` together when the script needs a row context, or omit both when it does not.
166+
167+
__Returns__ `.data` holds `{ task_id }` — use `task_id` with `getScriptResult`.
168+
169+
__Example__
170+
```js
171+
const res = await sdk.runScript({
172+
scriptName: "Generate order report",
173+
tableName: "Orders",
174+
rowId: "fcHIocncTsOygA3FjL-toQ",
175+
});
176+
const taskId = res.data.task_id;
177+
```
178+
179+
!!! abstract "getScriptResult"
180+
181+
Get the result of a script started by `runScript`.
182+
183+
```js
184+
sdk.getScriptResult({ scriptName, taskId });
185+
```
186+
187+
__Parameters__
188+
189+
`scriptName`
190+
: string — the same displayed script name used to start the task
191+
192+
`taskId`
193+
: string — task identifier returned in `runScript` response `.data.task_id`
194+
195+
__Returns__ `.data` holds `{ script }`. The `script` object includes `state`, `success`, `output`, `return_code`, `started_at`, and `finished_at`.
196+
197+
__Example__
198+
```js
199+
const res = await sdk.getScriptResult({
200+
scriptName: "Generate order report",
201+
taskId,
202+
});
203+
const scriptResult = res.data.script;
204+
205+
if (scriptResult.state === "finished") {
206+
if (scriptResult.success) {
207+
// The script completed successfully.
208+
} else {
209+
// Inspect scriptResult.return_code and scriptResult.output.
210+
}
211+
}
212+
```
213+
214+
Query the result only with the `taskId` returned by the corresponding `runScript` call. Treat `success: false` or a non-zero `return_code` as a failed execution, and render `output` as plain text rather than HTML.

‎docs/html-pages/sdk/initialization.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Install and initialize the seatable-html-page-sdk. Set up the SDK v
44

55
# Initialization
66

7-
The `seatable-html-page-sdk` is the bridge between an HTML page and its Universal App. It exposes APIs for data interaction and event subscription. This page covers installation and initialization. For data operations, see [Rows](rows.md) and [Files & Images](files.md).
7+
The `seatable-html-page-sdk` is the bridge between an HTML page and its Universal App. It exposes APIs for data interaction and event subscription. This page covers installation and initialization. For API details, see [Rows](rows.md), [Links](links.md), [Users](users.md), [Actions](actions.md), and [Files & Images](files.md).
88

99
## Installation
1010

@@ -98,4 +98,7 @@ All SDK methods are asynchronous and return promises — always `await` them. Ro
9898
## Next steps
9999

100100
- [Rows](rows.md) — list, add, update and delete rows, including batch operations.
101+
- [Links](links.md) — incrementally add and remove linked records.
102+
- [Users](users.md) — read the signed-in user and resolve collaborators.
103+
- [Actions](actions.md) — send notifications and emails, and run configured Python scripts.
101104
- [Files & Images](files.md) — upload files and images for file and image columns.

0 commit comments

Comments
 (0)