@softr/sdk 0.0.84 → 0.0.85-alpha.1
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/auth/isomorphic.d.ts +3 -2
- package/dist/auth/isomorphic.js +4 -1
- package/dist/auth/platform.js +1 -1
- package/dist/cookies.js +2 -1
- package/dist/embedding.js +24 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/package.js +1 -1
- package/dist/route/route.js +1 -1
- package/dist/softr-config.schema.js +2 -1
- package/package.json +1 -1
- package/schema/softr.schema.json +4 -0
- package/skills/softr-sdk/SKILL.md +8 -3
- 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/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/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
|
@@ -14,14 +14,15 @@ import * as _tanstack_react_start0 from "@tanstack/react-start";
|
|
|
14
14
|
* to read.
|
|
15
15
|
*
|
|
16
16
|
* Register it once, as a global request middleware in the app's `src/start.ts`.
|
|
17
|
-
* It writes
|
|
17
|
+
* It writes the session cookie, and in production a header that stops other
|
|
18
|
+
* sites from embedding the app.
|
|
18
19
|
*
|
|
19
20
|
* @example
|
|
20
21
|
* export const startInstance = createStart(() => ({
|
|
21
22
|
* requestMiddleware: [softrAuthMiddleware()],
|
|
22
23
|
* }))
|
|
23
24
|
*/
|
|
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>], {
|
|
25
|
+
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>], {
|
|
25
26
|
user: User | null;
|
|
26
27
|
permissions: Permissions;
|
|
27
28
|
formatting: Formatting;
|
package/dist/auth/isomorphic.js
CHANGED
|
@@ -9,6 +9,7 @@ import { settings } from "./methods/settings.js";
|
|
|
9
9
|
import { bootErrorMiddleware } from "../boot-error.js";
|
|
10
10
|
import { pwaMiddleware } from "../pwa.js";
|
|
11
11
|
import { faviconMiddleware } from "../favicon.js";
|
|
12
|
+
import { embeddingMiddleware } from "../embedding.js";
|
|
12
13
|
import { createContext, useContext } from "react";
|
|
13
14
|
import { createMiddleware, createServerFn, getGlobalStartContext } from "@tanstack/react-start";
|
|
14
15
|
import { getRequestHeader } from "@tanstack/react-start/server";
|
|
@@ -22,7 +23,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
22
23
|
* to read.
|
|
23
24
|
*
|
|
24
25
|
* Register it once, as a global request middleware in the app's `src/start.ts`.
|
|
25
|
-
* It writes
|
|
26
|
+
* It writes the session cookie, and in production a header that stops other
|
|
27
|
+
* sites from embedding the app.
|
|
26
28
|
*
|
|
27
29
|
* @example
|
|
28
30
|
* export const startInstance = createStart(() => ({
|
|
@@ -31,6 +33,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
31
33
|
*/
|
|
32
34
|
function softrAuthMiddleware() {
|
|
33
35
|
return createMiddleware({ type: "request" }).middleware([
|
|
36
|
+
embeddingMiddleware(),
|
|
34
37
|
bootErrorMiddleware(),
|
|
35
38
|
pwaMiddleware(),
|
|
36
39
|
faviconMiddleware()
|
package/dist/auth/platform.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assert, panic } from "../assertions.js";
|
|
2
2
|
import { fetch } from "../fetch.js";
|
|
3
|
+
import { softrConfig } from "../softr-config.js";
|
|
3
4
|
import { permissionsSchema } from "./permissions.js";
|
|
4
5
|
import { softrApiUrl } from "../softr-api.js";
|
|
5
|
-
import { softrConfig } from "../softr-config.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
|
|
8
8
|
//#region src/auth/platform.ts
|
package/dist/cookies.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { softAssert } from "./assertions.js";
|
|
2
|
+
import { softrConfig } from "./softr-config.js";
|
|
2
3
|
import { getRequestHeader, getResponseHeaders, setResponseHeader } from "@tanstack/react-start/server";
|
|
3
4
|
|
|
4
5
|
//#region src/cookies.ts
|
|
@@ -36,7 +37,7 @@ function serializeCookie(name, value, { maxAge, secure }) {
|
|
|
36
37
|
return parts.join("; ");
|
|
37
38
|
}
|
|
38
39
|
function sameSiteAttributes(secure) {
|
|
39
|
-
if (secure && process.env.NODE_ENV !== "production") return ["SameSite=None", "Partitioned"];
|
|
40
|
+
if (secure && (process.env.NODE_ENV !== "production" || softrConfig().allowEmbedding === true)) return ["SameSite=None", "Partitioned"];
|
|
40
41
|
return ["SameSite=Lax"];
|
|
41
42
|
}
|
|
42
43
|
const USER_TIMEZONE_COOKIE = "user-timezone";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { softrConfig } from "./softr-config.js";
|
|
2
|
+
import { createMiddleware } from "@tanstack/react-start";
|
|
3
|
+
|
|
4
|
+
//#region src/embedding.ts
|
|
5
|
+
/**
|
|
6
|
+
* Stops other sites from showing the published app in an iframe, unless
|
|
7
|
+
* softr.json sets `allowEmbedding`.
|
|
8
|
+
*
|
|
9
|
+
* Production only. The dev server runs in the preview pod, and Studio shows
|
|
10
|
+
* that preview in an iframe on another site.
|
|
11
|
+
*/
|
|
12
|
+
function embeddingMiddleware() {
|
|
13
|
+
return createMiddleware({ type: "request" }).server(async ({ next }) => {
|
|
14
|
+
const result = await next();
|
|
15
|
+
if (process.env.NODE_ENV !== "production") return result;
|
|
16
|
+
if (softrConfig().allowEmbedding === true) return result;
|
|
17
|
+
const response = new Response(result.response.body, result.response);
|
|
18
|
+
response.headers.set("content-security-policy", "frame-ancestors 'self'");
|
|
19
|
+
return response;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { embeddingMiddleware };
|
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_start6 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_start6.RequestMiddlewareAfterServer<{}, undefined, undefined>;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { softrMcpMiddleware };
|
package/dist/mcp.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { assert } from "./assertions.js";
|
|
2
2
|
import { fetch } from "./fetch.js";
|
|
3
|
+
import { softrConfig } from "./softr-config.js";
|
|
3
4
|
import { sessionConfig } from "./auth/config.js";
|
|
4
5
|
import { readSessionToken, withSessionToken } from "./auth/session.js";
|
|
5
6
|
import { softrApiUrl } from "./softr-api.js";
|
|
6
7
|
import { isDatasourceAction } from "./action.js";
|
|
7
|
-
import { softrConfig } from "./softr-config.js";
|
|
8
8
|
import { makePlatform } from "./auth/platform.js";
|
|
9
9
|
import { ds } from "./datasource/datasource.js";
|
|
10
10
|
import { z } from "zod";
|
package/dist/package.js
CHANGED
package/dist/route/route.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { panic } from "../assertions.js";
|
|
2
|
-
import { ACCESS_REASONS, checkRule } from "./visibility.js";
|
|
3
2
|
import { softrConfig } from "../softr-config.js";
|
|
3
|
+
import { ACCESS_REASONS, checkRule } from "./visibility.js";
|
|
4
4
|
import { redirect } from "@tanstack/react-router";
|
|
5
5
|
|
|
6
6
|
//#region src/route/route.ts
|
|
@@ -47,7 +47,8 @@ const SoftrConfigSchema = z.object({
|
|
|
47
47
|
alreadyAuthenticated: AccessBehaviour
|
|
48
48
|
})
|
|
49
49
|
}),
|
|
50
|
-
user: z.strictObject({ properties: z.record(z.string(), z.string()) }).optional()
|
|
50
|
+
user: z.strictObject({ properties: z.record(z.string(), z.string()) }).optional(),
|
|
51
|
+
allowEmbedding: z.boolean().optional()
|
|
51
52
|
});
|
|
52
53
|
function loadSoftrConfig(root) {
|
|
53
54
|
const file = path.join(root, SOFTR_CONFIG_FILE);
|
package/package.json
CHANGED
package/schema/softr.schema.json
CHANGED
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
},
|
|
68
68
|
"required": ["properties"],
|
|
69
69
|
"additionalProperties": false
|
|
70
|
+
},
|
|
71
|
+
"allowEmbedding": {
|
|
72
|
+
"type": "boolean",
|
|
73
|
+
"description": "Lets other sites show the published app in an iframe, signed-in pages included. Off by default."
|
|
70
74
|
}
|
|
71
75
|
},
|
|
72
76
|
"required": ["auth"],
|
|
@@ -3,12 +3,13 @@ name: softr-sdk
|
|
|
3
3
|
description: >-
|
|
4
4
|
Entry point for @softr/sdk: its four entrypoints (@softr/sdk, /server,
|
|
5
5
|
/client, /vite) and their client-server boundary, softrAuthMiddleware and the
|
|
6
|
-
Softr context,
|
|
7
|
-
sub-skill applies,
|
|
6
|
+
Softr context, embedding the app in another site's iframe, and which sub-skill
|
|
7
|
+
covers each task. Load it when unsure which sub-skill applies, when touching
|
|
8
|
+
the wiring, or when the user wants the app embedded elsewhere.
|
|
8
9
|
metadata:
|
|
9
10
|
type: core
|
|
10
11
|
library: softr-sdk
|
|
11
|
-
library_version: 0.0.
|
|
12
|
+
library_version: 0.0.85-alpha.1
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
# Softr SDK core
|
|
@@ -145,3 +146,7 @@ type User = {
|
|
|
145
146
|
userGroupIds: Array<SoftrUserGroupId> // the app's own group ids
|
|
146
147
|
}
|
|
147
148
|
```
|
|
149
|
+
|
|
150
|
+
## Embedding the app in another site
|
|
151
|
+
|
|
152
|
+
The published app refuses to load inside another site's iframe. The Studio preview is not affected. When the user asks to embed the app on their site, set `"allowEmbedding": true` in `softr.json`. Remove it to block embedding again. Sign-in then works inside the embed, with two limits to tell the user: Safari may not keep the visitor signed in, and links from emails (magic link, password reset) open the app in a new tab, not in the embed.
|
|
@@ -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.85-alpha.1
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
|
|
@@ -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.85-alpha.1
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**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.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 0.0.
|
|
10
|
+
library_version: 0.0.85-alpha.1
|
|
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: 0.0.
|
|
10
|
+
library_version: 0.0.85-alpha.1
|
|
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: 0.0.
|
|
12
|
+
library_version: 0.0.85-alpha.1
|
|
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.
|
|
@@ -8,7 +8,7 @@ description: >-
|
|
|
8
8
|
metadata:
|
|
9
9
|
type: sub-skill
|
|
10
10
|
library: softr-sdk
|
|
11
|
-
library_version: 0.0.
|
|
11
|
+
library_version: 0.0.85-alpha.1
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
**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.
|
|
@@ -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.85-alpha.1
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**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. The same holds for any helper that calls `ds`: declare it inside the handler. A function at module level that calls `ds` keeps the server-only import in the browser bundle, and every page stops loading until it moves. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -8,7 +8,7 @@ description: >-
|
|
|
8
8
|
metadata:
|
|
9
9
|
type: sub-skill
|
|
10
10
|
library: softr-sdk
|
|
11
|
-
library_version: 0.0.
|
|
11
|
+
library_version: 0.0.85-alpha.1
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
**Boundary.** `defineVisibility`, 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: 0.0.
|
|
12
|
+
library_version: 0.0.85-alpha.1
|
|
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.
|