@softr/sdk 1.13.2-alpha.0 → 1.13.2

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - A page that a route guard refuses with the `throw` strategy (`guardRoute`, `assertRouteAccess`) answers 403 instead of 500 when `softrAuthMiddleware` is registered, with an `x-softr-access-denied` header that names the reason. The page still shows the route's `errorComponent`. The guard no longer logs the refusal as an error, on the server or in the browser. No action is needed.
7
+ - A `ds.list` builder reads again after `where`, `orderBy`, `limit` or `offset` changes it. Before, it answered the first page it had read, so a loop that paged with one builder (`await list.offset(page.nextOffset)`) never ended and stopped the app's server. Awaiting an unchanged builder two times still reads one time. No action is needed.
8
8
 
9
9
  ## 1.13.1
10
10
 
@@ -21,7 +21,7 @@ import * as _tanstack_react_start0 from "@tanstack/react-start";
21
21
  * requestMiddleware: [softrAuthMiddleware()],
22
22
  * }))
23
23
  */
24
- declare function softrAuthMiddleware(): _tanstack_react_start0.RequestMiddlewareAfterServer<{}, readonly [_tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>], {
24
+ declare function softrAuthMiddleware(): _tanstack_react_start0.RequestMiddlewareAfterServer<{}, readonly [_tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>], {
25
25
  user: User | null;
26
26
  permissions: {
27
27
  datasources: {};
@@ -14,7 +14,6 @@ import { pushMiddleware } from "../push.js";
14
14
  import { faviconMiddleware } from "../favicon.js";
15
15
  import { embeddingMiddleware } from "../embedding.js";
16
16
  import { appIdentityMiddleware } from "../app-identity.js";
17
- import { accessDeniedStatusMiddleware } from "../route/access-denied-status.js";
18
17
  import { getRequestHeader } from "@tanstack/react-start/server";
19
18
  import { createContext, useContext } from "react";
20
19
  import { createMiddleware, createServerFn } from "@tanstack/react-start";
@@ -44,8 +43,7 @@ function softrAuthMiddleware() {
44
43
  pwaMiddleware(),
45
44
  pushMiddleware(),
46
45
  faviconMiddleware(),
47
- ssoMiddleware(),
48
- accessDeniedStatusMiddleware()
46
+ ssoMiddleware()
49
47
  ]).server(async ({ next }) => {
50
48
  async function getSession() {
51
49
  const token = readSessionToken();
@@ -60,19 +60,23 @@ function listRecords(query) {
60
60
  [Symbol.toStringTag]: "RecordListing",
61
61
  where(build) {
62
62
  args.filters.push(build(makeFieldSet(aliases)));
63
+ page = void 0;
63
64
  return builder;
64
65
  },
65
66
  orderBy(build) {
66
67
  const sorting = build(makeSortSet(aliases));
67
68
  args.orderBy.push(...Array.isArray(sorting) ? sorting : [sorting]);
69
+ page = void 0;
68
70
  return builder;
69
71
  },
70
72
  limit(count) {
71
73
  args.limit = count;
74
+ page = void 0;
72
75
  return builder;
73
76
  },
74
77
  offset(offset) {
75
78
  args.offset = offset;
79
+ page = void 0;
76
80
  return builder;
77
81
  },
78
82
  then(onfulfilled, onrejected) {
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import * as react2 from "react";
2
+ import * as react0 from "react";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/formatting.d.ts
@@ -96,7 +96,7 @@ declare function FormattingScope({
96
96
  /** A BCP 47 locale, such as `de-DE`. It drops the app's fixed date format inside the scope. */
97
97
  locale?: string;
98
98
  children?: ReactNode;
99
- }): react2.FunctionComponentElement<react2.ProviderProps<Scope>>;
99
+ }): react0.FunctionComponentElement<react0.ProviderProps<Scope>>;
100
100
  /**
101
101
  * A date in the app's format, in a `<span>`, safe to render on the server. A
102
102
  * timestamp whose zone is not known yet renders `fallback` until the browser
@@ -118,7 +118,7 @@ declare function FormattedDate({
118
118
  time?: boolean;
119
119
  /** What renders while the visitor's zone is unknown. */
120
120
  fallback?: ReactNode;
121
- }): react2.FunctionComponentElement<react2.FragmentProps> | react2.DetailedReactHTMLElement<{
121
+ }): react0.FunctionComponentElement<react0.FragmentProps> | react0.DetailedReactHTMLElement<{
122
122
  suppressHydrationWarning: true;
123
123
  }, HTMLElement> | null;
124
124
  //#endregion
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DatasourceAction } from "./action.js";
2
- import * as _tanstack_react_start11 from "@tanstack/react-start";
2
+ import * as _tanstack_react_start10 from "@tanstack/react-start";
3
3
 
4
4
  //#region src/mcp.d.ts
5
5
 
@@ -31,6 +31,6 @@ type SoftrMcpOptions = {
31
31
  * ],
32
32
  * }))
33
33
  */
34
- declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start11.RequestMiddlewareAfterServer<{}, undefined, undefined>;
34
+ declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start10.RequestMiddlewareAfterServer<{}, undefined, undefined>;
35
35
  //#endregion
36
36
  export { softrMcpMiddleware };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.13.2-alpha.0";
2
+ var version = "1.13.2";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/dist/pwa.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as react0 from "react";
1
+ import * as react5 from "react";
2
2
  import "@tanstack/react-start";
3
3
 
4
4
  //#region src/pwa.d.ts
@@ -24,7 +24,7 @@ import "@tanstack/react-start";
24
24
  * )
25
25
  * }
26
26
  */
27
- declare function SoftrPwaHead(): react0.FunctionComponentElement<react0.FragmentProps>;
27
+ declare function SoftrPwaHead(): react5.FunctionComponentElement<react5.FragmentProps>;
28
28
  type PwaPlatform = "ios" | "android" | "desktop";
29
29
  type InstallChoice = "accepted" | "dismissed";
30
30
  type PwaInstall = {
@@ -1,22 +1,10 @@
1
1
  import { panic } from "../assertions.js";
2
+ import { logger } from "../logger.js";
2
3
  import { softrConfig } from "../softr-config.js";
3
4
  import { ACCESS_REASONS, checkRule } from "./visibility.js";
4
- import { setResponseHeader } from "@tanstack/react-start/server";
5
- import { createIsomorphicFn } from "@tanstack/react-start";
6
5
  import { redirect } from "@tanstack/react-router";
7
6
 
8
7
  //#region src/route/route.ts
9
- /**
10
- * Marks the answer of a page a guard refused by throwing, with the reason as its
11
- * value. The pod reads it to tell a refusal from a server error, so its name and
12
- * values stay as they are.
13
- */
14
- const ACCESS_DENIED_HEADER = "x-softr-access-denied";
15
- const markRefused = createIsomorphicFn().server((reason) => {
16
- try {
17
- setResponseHeader(ACCESS_DENIED_HEADER, reason);
18
- } catch {}
19
- });
20
8
  function isAccessReason(value) {
21
9
  return ACCESS_REASONS.some((reason) => reason === value);
22
10
  }
@@ -74,7 +62,7 @@ function thrownFor(reason, overrides, location) {
74
62
  type: "access_error",
75
63
  reason
76
64
  };
77
- markRefused(reason);
65
+ logger.error(/* @__PURE__ */ new Error(`Access to ${location.href} denied: ${ACCESS_DENIED_MESSAGES[reason]}`));
78
66
  return error;
79
67
  }
80
68
  function ruleOf(page) {
@@ -116,4 +104,4 @@ function assertRouteAccess(page, opts) {
116
104
  }
117
105
 
118
106
  //#endregion
119
- export { ACCESS_DENIED_HEADER, ACCESS_DENIED_MESSAGES, assertRouteAccess, guardRoute, isAccessError, isAlreadyAuthenticatedError, isForbiddenError, isUnauthenticatedError };
107
+ export { ACCESS_DENIED_MESSAGES, assertRouteAccess, guardRoute, isAccessError, isAlreadyAuthenticatedError, isForbiddenError, isUnauthenticatedError };
package/package.json CHANGED
@@ -1,42 +1,17 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "1.13.2-alpha.0",
3
+ "version": "1.13.2",
4
4
  "type": "module",
5
5
  "exports": {
6
- ".": {
7
- "types": "./dist/index.d.ts",
8
- "import": "./dist/index.js"
9
- },
10
- "./client": {
11
- "types": "./dist/client.d.ts",
12
- "import": "./dist/client.js"
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
- "./logo-icon": {
23
- "types": "./dist/logo-icon.d.ts",
24
- "import": "./dist/logo-icon.js"
25
- }
26
- },
27
- "bin": {
28
- "softr-sdk": "./dist/cli.js"
29
- },
30
- "files": [
31
- "dist",
32
- "schema",
33
- "skills",
34
- "!skills/_artifacts",
35
- "CHANGELOG.md"
36
- ],
37
- "publishConfig": {
38
- "access": "public"
39
- },
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
+ "./logo-icon": { "types": "./dist/logo-icon.d.ts", "import": "./dist/logo-icon.js" }
11
+ },
12
+ "bin": { "softr-sdk": "./dist/cli.js" },
13
+ "files": ["dist", "schema", "skills", "!skills/_artifacts", "CHANGELOG.md"],
14
+ "publishConfig": { "access": "public" },
40
15
  "scripts": {
41
16
  "build": "tsdown",
42
17
  "test": "node --import ./src/test-utils/setup.ts --test",
@@ -68,9 +43,7 @@
68
43
  "optional": true
69
44
  }
70
45
  },
71
- "keywords": [
72
- "tanstack-intent"
73
- ],
46
+ "keywords": ["tanstack-intent"],
74
47
  "intent": {
75
48
  "version": 1,
76
49
  "repo": "@softr/sdk",
@@ -127,6 +127,18 @@ if (first.nextOffset !== null) {
127
127
 
128
128
  `nextOffset` is `null` when there are no more pages. `total` is the count of all matching records, not the count returned.
129
129
 
130
+ To read every page, loop until `nextOffset` is `null`, and start each pass from `ds.list`:
131
+
132
+ ```ts
133
+ const records = []
134
+ let offset: number | string | null = null
135
+ do {
136
+ const page = await ds.list(publishedPosts).limit(100).offset(offset)
137
+ records.push(...page.records)
138
+ offset = page.nextOffset
139
+ } while (offset !== null)
140
+ ```
141
+
130
142
  Pass `nextOffset` back unchanged, and type whatever carries it (a validator, a state, a search param) as `number | string | null`. Most datasources answer a number, the row position, and for those a page can also be reached directly, `.offset((page - 1) * PAGE_SIZE)`. Some datasources (BigQuery is one) answer a string, their own cursor: it reads only the page after the one that answered it, with the same `where` and `orderBy`, and a read with a computed number fails. For those, build "Load more" or next-page paging from `nextOffset`, never numbered pages.
131
143
 
132
144
  ### Populate a control from a linked table
@@ -1,25 +0,0 @@
1
- import { ACCESS_DENIED_HEADER } from "./route.js";
2
- import { getResponseHeader } from "@tanstack/react-start/server";
3
- import { createMiddleware } from "@tanstack/react-start";
4
-
5
- //#region src/route/access-denied-status.ts
6
- /**
7
- * Answers 403 for a page a guard refused by throwing, with the guard's mark.
8
- * TanStack answers any thrown value with 500, which reads as a server error.
9
- */
10
- function accessDeniedStatusMiddleware() {
11
- return createMiddleware({ type: "request" }).server(async ({ next }) => {
12
- const result = await next();
13
- const reason = getResponseHeader(ACCESS_DENIED_HEADER);
14
- if (result.response.status !== 500 || reason === void 0) return result;
15
- const headers = new Headers(result.response.headers);
16
- headers.set(ACCESS_DENIED_HEADER, reason);
17
- return new Response(result.response.body, {
18
- status: 403,
19
- headers
20
- });
21
- });
22
- }
23
-
24
- //#endregion
25
- export { accessDeniedStatusMiddleware };