@softr/sdk 0.0.50-alpha.0 → 0.0.50
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.
|
@@ -24,9 +24,17 @@ function makeSortSet(aliases) {
|
|
|
24
24
|
};
|
|
25
25
|
return set;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Ands the filters of every `where` call into one, which is what an accumulated `where` needs.
|
|
29
|
+
*
|
|
30
|
+
* The backend takes a group inside a group and no deeper, and the docs promise the caller both levels.
|
|
31
|
+
* A wrapper added here would spend one of them: a single `where` handing over an AND with an OR inside
|
|
32
|
+
* would arrive three deep and be refused. So one filter goes through as it is, and a group that is itself
|
|
33
|
+
* an AND contributes its members to the group built here rather than sitting inside it.
|
|
34
|
+
*/
|
|
28
35
|
function andAll(filters) {
|
|
29
|
-
|
|
36
|
+
if (filters.length === 1) return filters[0];
|
|
37
|
+
return group("AND", filters.flatMap((filter) => filter[INTERNAL_KIND] === "LOGICAL_GROUP" && filter.logicalOperator === "AND" ? filter.filters : [filter]));
|
|
30
38
|
}
|
|
31
39
|
function group(logicalOperator, filters) {
|
|
32
40
|
return {
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRouter } from "@tanstack/react-router";
|
|
1
|
+
import { useRef, useState } from "react";
|
|
3
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
3
|
|
|
5
4
|
//#region src/default-error-overlay.tsx
|
|
6
|
-
function subscribeToAgentTurn(listener) {
|
|
7
|
-
const observer = new MutationObserver(listener);
|
|
8
|
-
observer.observe(document.documentElement, {
|
|
9
|
-
attributes: true,
|
|
10
|
-
attributeFilter: ["data-agent-turn"]
|
|
11
|
-
});
|
|
12
|
-
return () => observer.disconnect();
|
|
13
|
-
}
|
|
14
|
-
function isAgentTurnRunning() {
|
|
15
|
-
return document.documentElement.dataset.agentTurn === "running";
|
|
16
|
-
}
|
|
17
5
|
function DefaultErrorOverlay({ error, reset }) {
|
|
18
6
|
if (process.env.NODE_ENV === "production") return /* @__PURE__ */ jsx("div", {
|
|
19
7
|
style: s.overlay,
|
|
20
|
-
"data-softr-error-overlay": "error",
|
|
21
8
|
children: /* @__PURE__ */ jsxs("div", {
|
|
22
9
|
style: s.card,
|
|
23
10
|
children: [
|
|
@@ -39,33 +26,8 @@ function DefaultErrorOverlay({ error, reset }) {
|
|
|
39
26
|
});
|
|
40
27
|
}
|
|
41
28
|
function DevView({ error, reset }) {
|
|
42
|
-
const running = useSyncExternalStore(subscribeToAgentTurn, isAgentTurnRunning, () => false);
|
|
43
|
-
const [caughtDuringTurn, setCaughtDuringTurn] = useState(running);
|
|
44
|
-
const router = useRouter();
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (running) {
|
|
47
|
-
setCaughtDuringTurn(true);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (!caughtDuringTurn) return;
|
|
51
|
-
const showError = () => setCaughtDuringTurn(false);
|
|
52
|
-
const timer = setTimeout(() => {
|
|
53
|
-
router.invalidate().then(() => {
|
|
54
|
-
reset?.();
|
|
55
|
-
showError();
|
|
56
|
-
}, showError);
|
|
57
|
-
}, 1e3);
|
|
58
|
-
return () => clearTimeout(timer);
|
|
59
|
-
}, [
|
|
60
|
-
running,
|
|
61
|
-
caughtDuringTurn,
|
|
62
|
-
reset,
|
|
63
|
-
router
|
|
64
|
-
]);
|
|
65
|
-
if (running || caughtDuringTurn) return /* @__PURE__ */ jsx(UpdatingView, {});
|
|
66
29
|
return /* @__PURE__ */ jsx("div", {
|
|
67
30
|
style: s.overlay,
|
|
68
|
-
"data-softr-error-overlay": "error",
|
|
69
31
|
children: /* @__PURE__ */ jsxs("div", {
|
|
70
32
|
style: s.card,
|
|
71
33
|
children: [
|
|
@@ -94,39 +56,6 @@ function DevView({ error, reset }) {
|
|
|
94
56
|
})
|
|
95
57
|
});
|
|
96
58
|
}
|
|
97
|
-
function UpdatingView() {
|
|
98
|
-
return /* @__PURE__ */ jsx("div", {
|
|
99
|
-
style: s.overlay,
|
|
100
|
-
"data-softr-error-overlay": "updating",
|
|
101
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
102
|
-
style: s.card,
|
|
103
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
104
|
-
style: s.pending,
|
|
105
|
-
children: /* @__PURE__ */ jsxs("svg", {
|
|
106
|
-
style: icon.md,
|
|
107
|
-
viewBox: "0 0 24 24",
|
|
108
|
-
fill: "none",
|
|
109
|
-
stroke: "currentColor",
|
|
110
|
-
strokeWidth: "2",
|
|
111
|
-
strokeLinecap: "round",
|
|
112
|
-
strokeLinejoin: "round",
|
|
113
|
-
children: [
|
|
114
|
-
/* @__PURE__ */ jsx("path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" }),
|
|
115
|
-
/* @__PURE__ */ jsx("path", { d: "M21 3v5h-5" }),
|
|
116
|
-
/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" }),
|
|
117
|
-
/* @__PURE__ */ jsx("path", { d: "M8 16H3v5" })
|
|
118
|
-
]
|
|
119
|
-
})
|
|
120
|
-
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h1", {
|
|
121
|
-
style: s.heading,
|
|
122
|
-
children: "Updating the app…"
|
|
123
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
124
|
-
style: s.body,
|
|
125
|
-
children: "The agent is still working on this change. The preview will recover once it is complete."
|
|
126
|
-
})] })]
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
59
|
function cleanStack(stack) {
|
|
131
60
|
return stack.split("\n").slice(1).filter((line) => line.trim().startsWith("at ") && !line.includes("/node_modules/")).map((line) => line.replace(/https?:\/\/[^/]+\//, "").replace(/\?[^):]+/g, "")).join("\n");
|
|
132
61
|
}
|
|
@@ -299,17 +228,6 @@ const s = {
|
|
|
299
228
|
color: "var(--destructive, oklch(0.577 0.245 27.325))",
|
|
300
229
|
flexShrink: 0
|
|
301
230
|
},
|
|
302
|
-
pending: {
|
|
303
|
-
display: "flex",
|
|
304
|
-
alignItems: "center",
|
|
305
|
-
justifyContent: "center",
|
|
306
|
-
width: "2.5rem",
|
|
307
|
-
height: "2.5rem",
|
|
308
|
-
borderRadius: "var(--radius, 0.625rem)",
|
|
309
|
-
background: "var(--muted, oklch(0.97 0 0))",
|
|
310
|
-
color: "var(--muted-foreground, oklch(0.556 0 0))",
|
|
311
|
-
flexShrink: 0
|
|
312
|
-
},
|
|
313
231
|
heading: {
|
|
314
232
|
margin: 0,
|
|
315
233
|
fontSize: "1rem",
|
|
@@ -349,7 +267,7 @@ const s = {
|
|
|
349
267
|
border: "1px solid var(--input, oklch(0.922 0 0))",
|
|
350
268
|
borderRadius: "var(--radius, 0.625rem)",
|
|
351
269
|
background: "var(--input-fill, oklch(1 0 0))",
|
|
352
|
-
color: "var(--foreground, oklch(0.
|
|
270
|
+
color: "var(--primary-foreground, oklch(0.985 0 0))",
|
|
353
271
|
fontFamily: "inherit",
|
|
354
272
|
fontSize: "0.875rem",
|
|
355
273
|
fontWeight: 500,
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softr/sdk",
|
|
3
|
-
"version": "0.0.50
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
|
-
".": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"./server": {
|
|
15
|
-
"types": "./dist/server.d.ts",
|
|
16
|
-
"import": "./dist/server.js"
|
|
17
|
-
},
|
|
18
|
-
"./vite": {
|
|
19
|
-
"types": "./dist/vite.d.ts",
|
|
20
|
-
"import": "./dist/vite.js"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"bin": {
|
|
24
|
-
"softr-sdk": "./dist/cli.js"
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist",
|
|
28
|
-
"schema",
|
|
29
|
-
"skills",
|
|
30
|
-
"!skills/_artifacts"
|
|
31
|
-
],
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"access": "public"
|
|
34
|
-
},
|
|
6
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
|
|
7
|
+
"./client": { "types": "./dist/client.d.ts", "import": "./dist/client.js" },
|
|
8
|
+
"./server": { "types": "./dist/server.d.ts", "import": "./dist/server.js" },
|
|
9
|
+
"./vite": { "types": "./dist/vite.d.ts", "import": "./dist/vite.js" }
|
|
10
|
+
},
|
|
11
|
+
"bin": { "softr-sdk": "./dist/cli.js" },
|
|
12
|
+
"files": ["dist", "schema", "skills", "!skills/_artifacts"],
|
|
13
|
+
"publishConfig": { "access": "public" },
|
|
35
14
|
"scripts": {
|
|
36
15
|
"build": "tsdown",
|
|
37
16
|
"test": "node --import ./src/test-utils/setup.ts --test",
|
|
@@ -63,9 +42,7 @@
|
|
|
63
42
|
"optional": true
|
|
64
43
|
}
|
|
65
44
|
},
|
|
66
|
-
"keywords": [
|
|
67
|
-
"tanstack-intent"
|
|
68
|
-
],
|
|
45
|
+
"keywords": ["tanstack-intent"],
|
|
69
46
|
"intent": {
|
|
70
47
|
"version": 1,
|
|
71
48
|
"repo": "@softr/sdk",
|
|
@@ -51,8 +51,8 @@ const publishedPosts = defineQuery({
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
- `id` is the name the person building the app sees, so `publishedPosts`, not `q1`. It must be unique across the app: no two declarations may share one, queries and mutations counted together.
|
|
54
|
-
- `datasourceId` is the opaque UUID from the table's registration on the application (Softr Studio's Data tab, or the `
|
|
55
|
-
- The keys of `fields` are names you choose. The values are field ids, opaque strings the table's schema gives you: `
|
|
54
|
+
- `datasourceId` is the opaque UUID from the table's registration on the application (Softr Studio's Data tab, or the `application_register_data_source` tool when an agent does it). It is not the table id and is never derived from the table's name.
|
|
55
|
+
- The keys of `fields` are names you choose. The values are field ids, opaque strings the table's schema gives you: `database_get_table` returns them for a Softr table, `integration_list_table_fields` for a table on a connected database. Everything downstream speaks your names: the returned records, `where`, `orderBy`.
|
|
56
56
|
- `permissions` declares who may run the query, and the SDK enforces it:
|
|
57
57
|
- `{ userGroup: 'ALL_USERS' }`: everyone, signed out included.
|
|
58
58
|
- `{ userGroup: 'NON_LOGGED_IN_USERS' }`: signed-out visitors only.
|
|
@@ -45,7 +45,7 @@ const sendWelcomeEmail = defineWorkflow({
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
- `id` is a name you choose, unique across the app.
|
|
48
|
-
- `workflowId` and `triggerId` are opaque UUIDs identifying the workflow and its **Run custom workflow** trigger. `
|
|
48
|
+
- `workflowId` and `triggerId` are opaque UUIDs identifying the workflow and its **Run custom workflow** trigger. `workflow_list` returns both. Pass them as inline string literals — never derive them at runtime.
|
|
49
49
|
- `permissions` declares who may run the trigger. Uses the same format as queries and mutations.
|
|
50
50
|
- `body` is hardcoded data the server resolves before calling the workflow. It is **not** passed by the caller at runtime — the workflow always receives it. Template values draw from the signed-in user and the current time (see table below).
|
|
51
51
|
|