@softr/sdk 0.0.36 → 0.0.37
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/core/workflow.js +21 -12
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +1 -1
- package/skills/softr-sdk/auth/SKILL.md +1 -1
- package/skills/softr-sdk/charts-and-metrics/SKILL.md +1 -1
- package/skills/softr-sdk/current-user/SKILL.md +1 -1
- package/skills/softr-sdk/file-uploads/SKILL.md +1 -1
- package/skills/softr-sdk/integrations/SKILL.md +7 -4
- package/skills/softr-sdk/record-mutations/SKILL.md +1 -1
- package/skills/softr-sdk/record-queries/SKILL.md +1 -1
- package/skills/softr-sdk/routes-and-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/workflows/SKILL.md +1 -1
package/dist/core/workflow.js
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
import { fetch } from "../fetch.js";
|
|
2
|
+
import { panic } from "../assertions.js";
|
|
2
3
|
import { sessionConfig } from "../auth/config.js";
|
|
3
4
|
import { readSessionToken } from "../auth/session.js";
|
|
4
5
|
import { platformApiUrl } from "../auth/platform.js";
|
|
5
6
|
|
|
6
7
|
//#region src/core/workflow.ts
|
|
8
|
+
function workflowsApiUrl() {
|
|
9
|
+
const url = process.env.SOFTR_WORKFLOWS_API_URL;
|
|
10
|
+
if (!url) panic("SOFTR_WORKFLOWS_API_URL is not set.");
|
|
11
|
+
return url.replace(/\/+$/, "");
|
|
12
|
+
}
|
|
7
13
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8
14
|
async function triggerWorkflow(action, payload) {
|
|
9
|
-
const
|
|
10
|
-
const triggerRes = await fetch(baseUrl, {
|
|
15
|
+
const triggerRes = await fetch(`${await platformApiUrl()}/v1/vibe/applications/${sessionConfig().applicationId}/actions/${action.id}/workflow`, {
|
|
11
16
|
method: "POST",
|
|
12
17
|
headers: {
|
|
13
18
|
Authorization: `Bearer ${readSessionToken()}`,
|
|
14
19
|
"Content-Type": "application/json"
|
|
15
20
|
},
|
|
16
|
-
body: JSON.stringify(payload ?? {})
|
|
21
|
+
body: JSON.stringify({ input: payload ?? {} })
|
|
17
22
|
});
|
|
18
23
|
if (!triggerRes.ok) throw new Error(`Workflow trigger failed: ${triggerRes.status}`);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
let details = await triggerRes.json();
|
|
25
|
+
while (details.status !== "FINISHED") {
|
|
26
|
+
if (details.status === "PENDING_INTERACTION") for (const interaction of details.nextInteractions) {
|
|
27
|
+
const interactionRes = await fetch(`${workflowsApiUrl()}/v1/interactive-actions/executions/${details.id}/actions/${interaction.id}`, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: { "Content-Type": "application/json" },
|
|
30
|
+
body: "{}"
|
|
31
|
+
});
|
|
32
|
+
if (!interactionRes.ok) throw new Error(`Workflow interaction failed: ${interactionRes.status}`);
|
|
33
|
+
}
|
|
34
|
+
await sleep(1e3);
|
|
35
|
+
const detailsRes = await fetch(`${workflowsApiUrl()}/v1/workflows/${action.resource.workflowId}/executions/${details.id}/details`);
|
|
25
36
|
if (!detailsRes.ok) throw new Error(`Workflow status check failed: ${detailsRes.status}`);
|
|
26
|
-
|
|
27
|
-
if (details.status === "FINISHED") return;
|
|
28
|
-
if (details.status === "PENDING_INTERACTION") throw new Error("Workflow requires interaction");
|
|
37
|
+
details = await detailsRes.json();
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
40
|
const workflow = { trigger: triggerWorkflow };
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ description: >-
|
|
|
16
16
|
metadata:
|
|
17
17
|
type: sub-skill
|
|
18
18
|
library: softr-sdk
|
|
19
|
-
library_version: 0.0.
|
|
19
|
+
library_version: 0.0.37
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineVisibility`, the hooks and every type come from `@softr/sdk`. The app is already wired (`src/start.ts`, `src/router.tsx`, `src/routes/__root.tsx`); never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
|
|
@@ -12,7 +12,7 @@ description: >-
|
|
|
12
12
|
metadata:
|
|
13
13
|
type: sub-skill
|
|
14
14
|
library: softr-sdk
|
|
15
|
-
library_version: 0.0.
|
|
15
|
+
library_version: 0.0.37
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere. The app is already wired (`src/start.ts`, `src/router.tsx`, `src/routes/__root.tsx`); never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 0.0.
|
|
13
|
+
library_version: 0.0.37
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `useCurrentUser`, `usePermissions` and every type come from `@softr/sdk` and work anywhere; `ds` and `auth` live on `@softr/sdk/server` and run only inside a `createServerFn` handler. The app is already wired — `src/start.ts` registers `softrAuthMiddleware`, `src/routes/__root.tsx` publishes the visitor as route context — never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.
|
|
12
|
+
library_version: 0.0.37
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `upload` lives on `@softr/sdk/server` and runs inside server functions. `useFileUpload` and `FileItem` live on `@softr/sdk/client` and run only in components. `FileAttachment` comes from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.
|
|
12
|
+
library_version: 0.0.37
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `integration` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineIntegration` and every type come from `@softr/sdk` and can be imported anywhere. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
|
|
@@ -28,14 +28,17 @@ import { integration } from '@softr/sdk/server'
|
|
|
28
28
|
|
|
29
29
|
## Reading connected integrations from the prompt
|
|
30
30
|
|
|
31
|
-
When the user attaches integrations to the chat, they appear in the `## Attached
|
|
31
|
+
When the user attaches integrations to the chat, they appear in the `## Attached integrations` section of the prompt in this form:
|
|
32
32
|
|
|
33
33
|
```
|
|
34
|
-
-
|
|
34
|
+
- integration `<integrationId>`, type `GMAIL`, database `<databaseId>` "Gmail"
|
|
35
|
+
- integration `<integrationId>`, type `GMAIL`
|
|
35
36
|
```
|
|
36
37
|
|
|
37
38
|
Pass the `integration` value as `integrationId` in `defineIntegration`. The `database` value is the table coordinate; integrations do not use it, so do not pass it anywhere. Use `integrationType` (e.g. `GMAIL`) to look up the base URL from the reference table below — then construct the full URL path, including any query parameters, directly in the `url` string.
|
|
38
39
|
|
|
40
|
+
Either shape configures `defineIntegration`. An entry with no `database` coordinate carries the `integrationId`, which is all the call needs.
|
|
41
|
+
|
|
39
42
|
## Declare the integration action
|
|
40
43
|
|
|
41
44
|
```ts
|
|
@@ -93,7 +96,7 @@ Do not add an `Authorization` key to `headers` — Softr injects the integration
|
|
|
93
96
|
|
|
94
97
|
## Base URLs by integration type
|
|
95
98
|
|
|
96
|
-
Match the `integrationType` from the attached
|
|
99
|
+
Match the `integrationType` from the attached integrations section to find the base URL:
|
|
97
100
|
|
|
98
101
|
| integrationType | Base URL |
|
|
99
102
|
|---|---|
|
|
@@ -11,7 +11,7 @@ description: >-
|
|
|
11
11
|
metadata:
|
|
12
12
|
type: sub-skill
|
|
13
13
|
library: softr-sdk
|
|
14
|
-
library_version: 0.0.
|
|
14
|
+
library_version: 0.0.37
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineMutation` and every type come from `@softr/sdk` and can be imported anywhere. The app is already wired (`src/start.ts`, `src/router.tsx`, `src/routes/__root.tsx`); never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
|
|
@@ -12,7 +12,7 @@ description: >-
|
|
|
12
12
|
metadata:
|
|
13
13
|
type: sub-skill
|
|
14
14
|
library: softr-sdk
|
|
15
|
-
library_version: 0.0.
|
|
15
|
+
library_version: 0.0.37
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere. The app is already wired (`src/start.ts`, `src/router.tsx`, `src/routes/__root.tsx`); never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
|
|
@@ -12,7 +12,7 @@ description: >-
|
|
|
12
12
|
metadata:
|
|
13
13
|
type: sub-skill
|
|
14
14
|
library: softr-sdk
|
|
15
|
-
library_version: 0.0.
|
|
15
|
+
library_version: 0.0.37
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
**Boundary.** `defineVisibility`, the error predicates and every type come from `@softr/sdk` and work anywhere; `ds` and `auth` live on `@softr/sdk/server` and run only inside a `createServerFn` handler. The app is already wired — `src/start.ts` registers `softrAuthMiddleware`, `src/routes/__root.tsx` publishes the visitor as route context — never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.
|
|
12
|
+
library_version: 0.0.37
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `workflow` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineWorkflow` and every type come from `@softr/sdk` and can be imported anywhere. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
|