@softr/sdk 1.2.0 → 1.2.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/CHANGELOG.md +6 -0
- package/dist/favicon.js +30 -8
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +16 -4
- 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/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,11 @@
|
|
|
1
1
|
# @softr/sdk
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `softrAuthMiddleware` serves the favicon set in Studio, Settings → General → Favicon, at `/favicon.ico`. Without one, it serves the Softr icon. An icon link or `public/favicon.ico` in the app still wins.
|
|
8
|
+
|
|
3
9
|
## 1.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/favicon.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import { logger } from "./logger.js";
|
|
2
|
+
import { softrApiUrl } from "./softr-api.js";
|
|
2
3
|
import { fetch } from "./fetch.js";
|
|
4
|
+
import { sessionConfig } from "./auth/config.js";
|
|
5
|
+
import { readCached } from "./cache.js";
|
|
6
|
+
import { z } from "zod";
|
|
3
7
|
import { createMiddleware } from "@tanstack/react-start";
|
|
4
8
|
|
|
5
9
|
//#region src/favicon.ts
|
|
6
10
|
const FAVICON_PATH = "/favicon.ico";
|
|
7
11
|
const DEFAULT_FAVICON_URL = "https://assets.softr-files.com/assets/images/favicon.ico";
|
|
8
|
-
const
|
|
12
|
+
const TTL_MS = 6e4;
|
|
13
|
+
const CACHE_CONTROL = "public, max-age=60";
|
|
14
|
+
const faviconSchema = z.object({ url: z.string() });
|
|
15
|
+
let cached;
|
|
9
16
|
/**
|
|
10
|
-
*
|
|
17
|
+
* The URL of the favicon set in Studio, or `null` when there is none. A
|
|
18
|
+
* failure also reads as `null`, so the app shows the default icon.
|
|
19
|
+
*/
|
|
20
|
+
function readStudioFaviconUrl() {
|
|
21
|
+
return readCached("the favicon setting", TTL_MS, () => cached, (entry) => cached = entry, async () => {
|
|
22
|
+
const { applicationId } = sessionConfig();
|
|
23
|
+
const response = await fetch(`${softrApiUrl("SOFTR_PLATFORM_API_URL")}/v1/vibe/applications/${applicationId}/favicon`, { headers: { accept: "application/json" } });
|
|
24
|
+
if (response.status === 404) return null;
|
|
25
|
+
if (!response.ok) throw new Error(`The platform answered ${response.status}`);
|
|
26
|
+
return faviconSchema.parse(await response.json()).url;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Serves the app's favicon at `/favicon.ico`: the one the builder set in
|
|
31
|
+
* Studio, or the default Softr favicon when there is none. Every other request
|
|
11
32
|
* passes through untouched.
|
|
12
33
|
*
|
|
13
34
|
* Proxied, not redirected: some clients do not follow a redirect for an icon.
|
|
@@ -19,15 +40,16 @@ const CACHE_CONTROL = "public, max-age=86400";
|
|
|
19
40
|
function faviconMiddleware() {
|
|
20
41
|
return createMiddleware({ type: "request" }).server(async ({ next, pathname }) => {
|
|
21
42
|
if (pathname !== FAVICON_PATH) return next();
|
|
43
|
+
const iconUrl = await readStudioFaviconUrl() ?? DEFAULT_FAVICON_URL;
|
|
22
44
|
try {
|
|
23
|
-
const iconResponse = await fetch(
|
|
45
|
+
const iconResponse = await fetch(iconUrl);
|
|
24
46
|
if (!iconResponse.ok) return new Response(null, { status: 404 });
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
47
|
+
const headers = new Headers({ "cache-control": CACHE_CONTROL });
|
|
48
|
+
const contentType = iconResponse.headers.get("content-type");
|
|
49
|
+
if (contentType !== null) headers.set("content-type", contentType);
|
|
50
|
+
return new Response(iconResponse.body, { headers });
|
|
29
51
|
} catch (error) {
|
|
30
|
-
logger.warn("Could not fetch the
|
|
52
|
+
logger.warn("Could not fetch the favicon:", error);
|
|
31
53
|
return new Response(null, { status: 404 });
|
|
32
54
|
}
|
|
33
55
|
});
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -3,13 +3,14 @@ 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, embedding the app in another site's iframe,
|
|
7
|
-
covers each task. Load it when unsure which sub-skill
|
|
8
|
-
the wiring,
|
|
6
|
+
Softr context, embedding the app in another site's iframe, the app's favicon,
|
|
7
|
+
and which sub-skill covers each task. Load it when unsure which sub-skill
|
|
8
|
+
applies, when touching the wiring, when the user wants the app embedded
|
|
9
|
+
elsewhere, or when the favicon set in Studio does not show.
|
|
9
10
|
metadata:
|
|
10
11
|
type: core
|
|
11
12
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.
|
|
13
|
+
library_version: 1.2.1
|
|
13
14
|
---
|
|
14
15
|
|
|
15
16
|
# Softr SDK core
|
|
@@ -104,6 +105,9 @@ Letting visitors turn on push notifications, or "notify users when …"?
|
|
|
104
105
|
Showing a date, a time or a number on a page?
|
|
105
106
|
load softr-sdk/formatting
|
|
106
107
|
|
|
108
|
+
The favicon set in Studio does not show?
|
|
109
|
+
read "The app's favicon" below
|
|
110
|
+
|
|
107
111
|
Writing a server function, loader, or middleware in general?
|
|
108
112
|
not a Softr concern. Use the TanStack Start skills.
|
|
109
113
|
```
|
|
@@ -166,3 +170,11 @@ type User = {
|
|
|
166
170
|
## Embedding the app in another site
|
|
167
171
|
|
|
168
172
|
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, list that site's origin in `softr.json`: `"allowEmbedding": ["https://partner.com"]`. Ask for the exact origin if you don't have it. Only listed sites can embed the app. Use `["*"]` only when the user wants any site to embed it. Remove the list to block embedding again. Sign-in then works inside the embed. Session cookies switch from SameSite=Lax to None, so the app loses the browser's CSRF protection. Only set it when the user asks. There are two more 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.
|
|
173
|
+
|
|
174
|
+
## The app's favicon
|
|
175
|
+
|
|
176
|
+
The app's favicon is a Studio setting: Settings → General → Favicon. The app shows it, and shows the Softr icon while the setting is empty. The preview shows a change with no publish. The published app shows it after the next publish.
|
|
177
|
+
|
|
178
|
+
A `rel: 'icon'` link in `head.links` or a `public/favicon.ico` file wins over the setting. While the code has one, the Studio setting has no effect.
|
|
179
|
+
|
|
180
|
+
When the user asks why the Studio favicon does not show, check the code for an icon. When only the published app lacks it, the app needs a new publish. The published app keeps the code, the SDK and the favicon of its last publish.
|
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: sub-skill
|
|
15
15
|
library: softr-sdk
|
|
16
|
-
library_version: 1.2.
|
|
16
|
+
library_version: 1.2.1
|
|
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.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.
|
|
12
|
+
library_version: 1.2.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: 1.2.
|
|
12
|
+
library_version: 1.2.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: 1.2.
|
|
10
|
+
library_version: 1.2.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: 1.2.
|
|
10
|
+
library_version: 1.2.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: 1.2.
|
|
12
|
+
library_version: 1.2.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.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.
|
|
12
|
+
library_version: 1.2.1
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**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.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.2.
|
|
13
|
+
library_version: 1.2.1
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**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.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.
|
|
12
|
+
library_version: 1.2.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.
|