@softr/sdk 1.13.0 → 1.13.2-alpha.0
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 +12 -0
- package/dist/auth/isomorphic.d.ts +1 -1
- package/dist/auth/isomorphic.js +3 -1
- package/dist/default-error-overlay.js +1 -1
- package/dist/formatting.d.ts +3 -3
- package/dist/mcp.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/pwa.d.ts +2 -2
- package/dist/route/access-denied-status.js +25 -0
- package/dist/route/route.js +15 -3
- package/package.json +38 -11
- 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 +1 -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 +1 -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,17 @@
|
|
|
1
1
|
# @softr/sdk
|
|
2
2
|
|
|
3
|
+
## 1.13.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
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.
|
|
8
|
+
|
|
9
|
+
## 1.13.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- The "Stack trace" button on the development error page (`DefaultErrorOverlay`) is readable in a dark theme. Its background was always white, so its light text in a dark theme did not show. No action is needed.
|
|
14
|
+
|
|
3
15
|
## 1.13.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -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>], {
|
|
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>], {
|
|
25
25
|
user: User | null;
|
|
26
26
|
permissions: {
|
|
27
27
|
datasources: {};
|
package/dist/auth/isomorphic.js
CHANGED
|
@@ -14,6 +14,7 @@ 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";
|
|
17
18
|
import { getRequestHeader } from "@tanstack/react-start/server";
|
|
18
19
|
import { createContext, useContext } from "react";
|
|
19
20
|
import { createMiddleware, createServerFn } from "@tanstack/react-start";
|
|
@@ -43,7 +44,8 @@ function softrAuthMiddleware() {
|
|
|
43
44
|
pwaMiddleware(),
|
|
44
45
|
pushMiddleware(),
|
|
45
46
|
faviconMiddleware(),
|
|
46
|
-
ssoMiddleware()
|
|
47
|
+
ssoMiddleware(),
|
|
48
|
+
accessDeniedStatusMiddleware()
|
|
47
49
|
]).server(async ({ next }) => {
|
|
48
50
|
async function getSession() {
|
|
49
51
|
const token = readSessionToken();
|
|
@@ -364,7 +364,7 @@ const s = {
|
|
|
364
364
|
padding: "0 0.75rem 0 0.5rem",
|
|
365
365
|
border: "1px solid var(--input, oklch(0.922 0 0))",
|
|
366
366
|
borderRadius: "var(--radius, 0.625rem)",
|
|
367
|
-
background: "
|
|
367
|
+
background: "transparent",
|
|
368
368
|
color: "var(--foreground, oklch(0.145 0 0))",
|
|
369
369
|
fontFamily: "inherit",
|
|
370
370
|
fontSize: "0.875rem",
|
package/dist/formatting.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react2 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
|
-
}):
|
|
99
|
+
}): react2.FunctionComponentElement<react2.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
|
-
}):
|
|
121
|
+
}): react2.FunctionComponentElement<react2.FragmentProps> | react2.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
|
|
2
|
+
import * as _tanstack_react_start11 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):
|
|
34
|
+
declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start11.RequestMiddlewareAfterServer<{}, undefined, undefined>;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { softrMcpMiddleware };
|
package/dist/package.js
CHANGED
package/dist/pwa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react0 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():
|
|
27
|
+
declare function SoftrPwaHead(): react0.FunctionComponentElement<react0.FragmentProps>;
|
|
28
28
|
type PwaPlatform = "ios" | "android" | "desktop";
|
|
29
29
|
type InstallChoice = "accepted" | "dismissed";
|
|
30
30
|
type PwaInstall = {
|
|
@@ -0,0 +1,25 @@
|
|
|
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 };
|
package/dist/route/route.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { panic } from "../assertions.js";
|
|
2
|
-
import { logger } from "../logger.js";
|
|
3
2
|
import { softrConfig } from "../softr-config.js";
|
|
4
3
|
import { ACCESS_REASONS, checkRule } from "./visibility.js";
|
|
4
|
+
import { setResponseHeader } from "@tanstack/react-start/server";
|
|
5
|
+
import { createIsomorphicFn } from "@tanstack/react-start";
|
|
5
6
|
import { redirect } from "@tanstack/react-router";
|
|
6
7
|
|
|
7
8
|
//#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
|
+
});
|
|
8
20
|
function isAccessReason(value) {
|
|
9
21
|
return ACCESS_REASONS.some((reason) => reason === value);
|
|
10
22
|
}
|
|
@@ -62,7 +74,7 @@ function thrownFor(reason, overrides, location) {
|
|
|
62
74
|
type: "access_error",
|
|
63
75
|
reason
|
|
64
76
|
};
|
|
65
|
-
|
|
77
|
+
markRefused(reason);
|
|
66
78
|
return error;
|
|
67
79
|
}
|
|
68
80
|
function ruleOf(page) {
|
|
@@ -104,4 +116,4 @@ function assertRouteAccess(page, opts) {
|
|
|
104
116
|
}
|
|
105
117
|
|
|
106
118
|
//#endregion
|
|
107
|
-
export { ACCESS_DENIED_MESSAGES, assertRouteAccess, guardRoute, isAccessError, isAlreadyAuthenticatedError, isForbiddenError, isUnauthenticatedError };
|
|
119
|
+
export { ACCESS_DENIED_HEADER, ACCESS_DENIED_MESSAGES, assertRouteAccess, guardRoute, isAccessError, isAlreadyAuthenticatedError, isForbiddenError, isUnauthenticatedError };
|
package/package.json
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softr/sdk",
|
|
3
|
-
"version": "1.13.0",
|
|
3
|
+
"version": "1.13.2-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
|
-
".": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"./
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
},
|
|
15
40
|
"scripts": {
|
|
16
41
|
"build": "tsdown",
|
|
17
42
|
"test": "node --import ./src/test-utils/setup.ts --test",
|
|
@@ -43,7 +68,9 @@
|
|
|
43
68
|
"optional": true
|
|
44
69
|
}
|
|
45
70
|
},
|
|
46
|
-
"keywords": [
|
|
71
|
+
"keywords": [
|
|
72
|
+
"tanstack-intent"
|
|
73
|
+
],
|
|
47
74
|
"intent": {
|
|
48
75
|
"version": 1,
|
|
49
76
|
"repo": "@softr/sdk",
|
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: sub-skill
|
|
15
15
|
library: softr-sdk
|
|
16
|
-
library_version: 1.13.
|
|
16
|
+
library_version: 1.13.2
|
|
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.13.
|
|
13
|
+
library_version: 1.13.2
|
|
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.13.
|
|
13
|
+
library_version: 1.13.2
|
|
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.
|
|
@@ -12,7 +12,7 @@ description: >-
|
|
|
12
12
|
metadata:
|
|
13
13
|
type: sub-skill
|
|
14
14
|
library: softr-sdk
|
|
15
|
-
library_version: 1.13.
|
|
15
|
+
library_version: 1.13.2
|
|
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.13.
|
|
10
|
+
library_version: 1.13.2
|
|
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.13.
|
|
10
|
+
library_version: 1.13.2
|
|
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.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.13.
|
|
12
|
+
library_version: 1.13.2
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**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.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.13.
|
|
13
|
+
library_version: 1.13.2
|
|
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.13.
|
|
14
|
+
library_version: 1.13.2
|
|
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.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.13.
|
|
12
|
+
library_version: 1.13.2
|
|
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.13.
|
|
12
|
+
library_version: 1.13.2
|
|
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.
|