@softr/sdk 1.15.2 → 1.15.3
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/CHANGELOG.md +6 -0
- package/dist/datasource/chart.js +5 -0
- package/dist/datasource/record.js +1 -0
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +1 -1
- package/skills/softr-sdk/ai/SKILL.md +1 -1
- package/skills/softr-sdk/auth/SKILL.md +1 -1
- package/skills/softr-sdk/charts-and-metrics/SKILL.md +3 -1
- package/skills/softr-sdk/current-user/SKILL.md +1 -1
- package/skills/softr-sdk/email/SKILL.md +1 -1
- package/skills/softr-sdk/file-uploads/SKILL.md +1 -1
- package/skills/softr-sdk/formatting/SKILL.md +1 -1
- package/skills/softr-sdk/integrations/SKILL.md +1 -1
- package/skills/softr-sdk/mcp/SKILL.md +1 -1
- package/skills/softr-sdk/push-notifications/SKILL.md +1 -1
- package/skills/softr-sdk/pwa/SKILL.md +1 -1
- package/skills/softr-sdk/record-mutations/SKILL.md +1 -1
- package/skills/softr-sdk/record-queries/SKILL.md +21 -1
- package/skills/softr-sdk/region-visibility/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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @softr/sdk
|
|
2
2
|
|
|
3
|
+
## 1.15.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- A `ds.get`, `ds.chart` or `ds.metric` builder reads again after a call such as `where` changes it, the same as `ds.list` and `ds.export`. Before, it answered the result of its first read and left out the new filter. Skills: record-queries and charts-and-metrics say that one builder is for one read, because `where` and `orderBy` add to the builder they are called on. No action is needed.
|
|
8
|
+
|
|
3
9
|
## 1.15.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/datasource/chart.js
CHANGED
|
@@ -100,6 +100,7 @@ function chart(query) {
|
|
|
100
100
|
const groups = entries;
|
|
101
101
|
assert(groups.length < 2 || groups[0][1].fieldId !== groups[1][1].fieldId, "a chart may group by a field only once");
|
|
102
102
|
state.groups = groups;
|
|
103
|
+
result = void 0;
|
|
103
104
|
return builder;
|
|
104
105
|
},
|
|
105
106
|
metrics(build) {
|
|
@@ -114,15 +115,18 @@ function chart(query) {
|
|
|
114
115
|
seen.add(pair);
|
|
115
116
|
}
|
|
116
117
|
state.metrics = metrics;
|
|
118
|
+
result = void 0;
|
|
117
119
|
return builder;
|
|
118
120
|
},
|
|
119
121
|
where(build) {
|
|
120
122
|
state.filters.push(build(makeFieldSet(aliases)));
|
|
123
|
+
result = void 0;
|
|
121
124
|
return builder;
|
|
122
125
|
},
|
|
123
126
|
orderBy(build) {
|
|
124
127
|
const sorting = build(makeSortSet([...state.groups ?? [], ...state.metrics ?? []].map(([key]) => key)));
|
|
125
128
|
state.orderBys.push(...buildOrderBy(Array.isArray(sorting) ? sorting : [sorting]));
|
|
129
|
+
result = void 0;
|
|
126
130
|
return builder;
|
|
127
131
|
},
|
|
128
132
|
then(onfulfilled, onrejected) {
|
|
@@ -238,6 +242,7 @@ function metric(query, pick) {
|
|
|
238
242
|
[Symbol.toStringTag]: "MetricQuery",
|
|
239
243
|
where(build) {
|
|
240
244
|
filters.push(build(makeFieldSet(aliases)));
|
|
245
|
+
result = void 0;
|
|
241
246
|
return builder;
|
|
242
247
|
},
|
|
243
248
|
then(onfulfilled, onrejected) {
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: sub-skill
|
|
15
15
|
library: softr-sdk
|
|
16
|
-
library_version: 1.15.
|
|
16
|
+
library_version: 1.15.3
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
**Boundary.** `ai` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineAiAction` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.15.
|
|
13
|
+
library_version: 1.15.3
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.15.
|
|
13
|
+
library_version: 1.15.3
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. A helper that calls `ds` outside a handler goes in `createServerOnlyFn` from `@tanstack/react-start` (the `record-queries` boundary). `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -195,6 +195,8 @@ A chart can group, aggregate and `where` only on `fields`, not on `filterFields`
|
|
|
195
195
|
|
|
196
196
|
`groupBy` comes first and exactly once; a chart cannot be awaited before it. `metrics` follows, at most once, or not at all for distinct values. `where` can be chained anywhere, repeatedly, and calling it more than once ands the filters together. `orderBy` sorts by the chart's own keys, group and metric alike, and only sees the keys declared so far, so call it last.
|
|
197
197
|
|
|
198
|
+
A builder is for one read. `where` adds to the builder it is called on, so a `ds.chart` or `ds.metric` kept in a variable and read again carries the filters of the earlier read. Start each figure from its own `ds.chart` or `ds.metric`, as the dashboard load above does.
|
|
199
|
+
|
|
198
200
|
## References
|
|
199
201
|
|
|
200
202
|
- [references/aggregations.md](./references/aggregations.md): every bucket interval and its value type, and which aggregations each kind of field offers. Load it when choosing a bucket or when a field does not offer the aggregation you expected.
|
|
@@ -12,7 +12,7 @@ description: >-
|
|
|
12
12
|
metadata:
|
|
13
13
|
type: sub-skill
|
|
14
14
|
library: softr-sdk
|
|
15
|
-
library_version: 1.15.
|
|
15
|
+
library_version: 1.15.3
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
**Boundary.** `email` and `EmailError` live on `@softr/sdk/server` and run only inside a `createServerFn` handler — importing them into a component fails the build. `defineEmailAction` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 1.15.
|
|
10
|
+
library_version: 1.15.3
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
**Boundary.** `upload` lives on `@softr/sdk/server` and runs inside server functions. `useFileUpload` and `FileItem` live on `@softr/sdk` and run in components. `FileAttachment` comes from `@softr/sdk` and can be imported anywhere.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 1.15.
|
|
10
|
+
library_version: 1.15.3
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
**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.
|
|
@@ -11,7 +11,7 @@ description: >-
|
|
|
11
11
|
metadata:
|
|
12
12
|
type: sub-skill
|
|
13
13
|
library: softr-sdk
|
|
14
|
-
library_version: 1.15.
|
|
14
|
+
library_version: 1.15.3
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
**Boundary.** `softrMcpMiddleware` lives on `@softr/sdk` and is registered once, in `src/start.ts`. The actions you hand it are the same `defineQuery` / `defineMutation` values the app's own pages use — declared wherever they already live, not duplicated for MCP. The tools you hand it come from `defineTool`, also on `@softr/sdk`, and call the same server logic the pages do.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.15.
|
|
13
|
+
library_version: 1.15.3
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**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.
|
|
@@ -11,7 +11,7 @@ description: >-
|
|
|
11
11
|
metadata:
|
|
12
12
|
type: sub-skill
|
|
13
13
|
library: softr-sdk
|
|
14
|
-
library_version: 1.15.
|
|
14
|
+
library_version: 1.15.3
|
|
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. A route `loader` also runs in the browser, so it calls a server function, never `ds`. A helper that calls `ds` outside a handler, in this file or in another one, goes in `createServerOnlyFn` from `@tanstack/react-start`, or inside the handler. An exported helper without it keeps the server-only import in the browser bundle, and every page stops loading until it moves. Do not make such a helper a server function when it takes an id: any visitor can call a server function with any id. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -99,6 +99,26 @@ Calling `.where` more than once ands the filters together, and the query's `filt
|
|
|
99
99
|
.orderBy((q) => [q.views.desc, q.title.asc]) // array for tie-breakers
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
### One builder, one read
|
|
103
|
+
|
|
104
|
+
`where` and `orderBy` add to the builder they are called on and return that same builder. A builder kept in a variable carries its filters and sorts into every later read, with no error. Start each read from its own `ds.list`, `ds.get` or `ds.export`:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
// Wrong: the second read asks for open AND closed, and returns no records.
|
|
108
|
+
const list = ds.list(orders)
|
|
109
|
+
const open = await list.where((q) => q.status.is('open'))
|
|
110
|
+
const closed = await list.where((q) => q.status.is('closed'))
|
|
111
|
+
|
|
112
|
+
// Right: one builder for each read.
|
|
113
|
+
const open = await ds.list(orders).where((q) => q.status.is('open'))
|
|
114
|
+
const closed = await ds.list(orders).where((q) => q.status.is('closed'))
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- A loop with one filter per pass, such as one count per tab, starts a new builder on each pass.
|
|
118
|
+
- A second `orderBy` on the same builder only breaks the ties of the first.
|
|
119
|
+
- A reused `ds.export` builder writes a file with only the records that match every filter it collected.
|
|
120
|
+
- To add a filter only when an input is set, reassign the builder before its one read: `if (search) list = list.where(...)`, as in [Keep a large table on the server](#keep-a-large-table-on-the-server).
|
|
121
|
+
|
|
102
122
|
### Get one record
|
|
103
123
|
|
|
104
124
|
```ts
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.15.
|
|
12
|
+
library_version: 1.15.3
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `definePage`, `pageHead`, the access functions and the error predicates come from `@softr/sdk` and work anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.15.
|
|
12
|
+
library_version: 1.15.3
|
|
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.
|