@softr/sdk 1.11.1 → 1.12.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 +12 -0
- package/dist/auth/sso.js +31 -15
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/package.js +1 -1
- package/dist/softr-config.d.ts +8 -0
- package/dist/softr-config.js +5 -1
- package/dist/softr-config.schema.d.ts +31 -0
- package/dist/softr-config.schema.js +22 -2
- package/package.json +1 -1
- package/schema/softr.schema.json +36 -0
- package/skills/softr-sdk/SKILL.md +29 -5
- package/skills/softr-sdk/ai/SKILL.md +1 -1
- package/skills/softr-sdk/auth/SKILL.md +1 -1
- package/skills/softr-sdk/auth/references/single-sign-on.md +2 -2
- 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.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- When single sign-on fails, the SSO page (`auth.routes.sso`) gets the path the visitor wanted in the login redirect param, as it already did for an authenticator code. When the sign-in has expired there may be no path, and the param is left out. An SSO page that ignores the param works as before. Action: on that page, link "Try again" to `ssoSignInHref(toReturnPath(location).href)` and keep the redirect param on the login link.
|
|
8
|
+
|
|
9
|
+
## 1.12.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- `logo` in `softr.json` is the app's logo: an icon or images, with a file for dark backgrounds. `getLogo()` reads it, with the `layers` icon when the key is missing, and the `Logo` and `LogoFile` types describe it. A field this version does not know is ignored and an unknown `source` shows the icon, so a newer Studio cannot break the build. An image without `onLight`, an icon name that is not kebab case or a file that is not a path or an https URL fails the build.
|
|
14
|
+
|
|
3
15
|
## 1.11.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/auth/sso.js
CHANGED
|
@@ -48,13 +48,16 @@ function ssoMiddleware() {
|
|
|
48
48
|
const code = url.searchParams.get("code");
|
|
49
49
|
const binding = readSsoBinding();
|
|
50
50
|
clearSsoBinding();
|
|
51
|
-
if (code === null) return toSsoPage({
|
|
51
|
+
if (code === null) return toSsoPage({
|
|
52
|
+
error: "idp",
|
|
53
|
+
returnPath: binding?.returnPath
|
|
54
|
+
});
|
|
52
55
|
if (binding === null) return toSsoPage({ error: "expired" });
|
|
53
56
|
return await finish(await platform().signInWithOpenId({
|
|
54
57
|
code,
|
|
55
58
|
state: url.searchParams.get("state") ?? "",
|
|
56
59
|
...binding
|
|
57
|
-
}));
|
|
60
|
+
}), binding.returnPath);
|
|
58
61
|
}
|
|
59
62
|
case SAML_CALLBACK_PATH: {
|
|
60
63
|
if (request.method !== "POST") return methodNotAllowed("POST");
|
|
@@ -62,25 +65,32 @@ function ssoMiddleware() {
|
|
|
62
65
|
const samlResponse = form?.get("SAMLResponse");
|
|
63
66
|
const binding = readSsoBinding();
|
|
64
67
|
clearSsoBinding();
|
|
65
|
-
if (typeof samlResponse !== "string" || samlResponse === "") return toSsoPage({
|
|
68
|
+
if (typeof samlResponse !== "string" || samlResponse === "") return toSsoPage({
|
|
69
|
+
error: "idp",
|
|
70
|
+
returnPath: binding?.returnPath
|
|
71
|
+
});
|
|
66
72
|
if (binding === null) return toSsoPage({ error: "expired" });
|
|
67
73
|
const relayState = form?.get("RelayState");
|
|
68
74
|
return await finish(await platform().signInWithSaml({
|
|
69
75
|
samlResponse,
|
|
70
76
|
relayState: typeof relayState === "string" ? relayState : "",
|
|
71
77
|
...binding
|
|
72
|
-
}));
|
|
78
|
+
}), binding.returnPath);
|
|
73
79
|
}
|
|
74
80
|
default: return await next();
|
|
75
81
|
}
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
84
|
async function start(url) {
|
|
85
|
+
const returnPath = resolveReturnPath(url.searchParams.get("return"));
|
|
79
86
|
const result = await platform().ssoStart({
|
|
80
87
|
origin: url.origin,
|
|
81
|
-
returnPath
|
|
88
|
+
returnPath
|
|
89
|
+
});
|
|
90
|
+
if (!result.ok) return toSsoPage({
|
|
91
|
+
...failure(result),
|
|
92
|
+
returnPath
|
|
82
93
|
});
|
|
83
|
-
if (!result.ok) return toSsoPage(failure(result));
|
|
84
94
|
const started = result.data;
|
|
85
95
|
const binding = makeSsoBindingCookie({
|
|
86
96
|
bindingToken: started.bindingToken,
|
|
@@ -101,8 +111,15 @@ async function start(url) {
|
|
|
101
111
|
writeCookies([binding]);
|
|
102
112
|
return samlForm(started.formAction, started.samlRequest, started.relayState);
|
|
103
113
|
}
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
/**
|
|
115
|
+
* `startedFor` is where the visitor wanted to go, so a retry after a failure
|
|
116
|
+
* gets there.
|
|
117
|
+
*/
|
|
118
|
+
async function finish(result, startedFor) {
|
|
119
|
+
if (!result.ok) return toSsoPage({
|
|
120
|
+
...failure(result),
|
|
121
|
+
returnPath: startedFor
|
|
122
|
+
});
|
|
106
123
|
const { result: signIn, returnPath } = result.data;
|
|
107
124
|
if (signIn.status === "MFA_REQUIRED") {
|
|
108
125
|
const { mfa } = signIn;
|
|
@@ -110,7 +127,7 @@ async function finish(result) {
|
|
|
110
127
|
writeCookies([makePendingAuthCookie(mfa.challengeToken)]);
|
|
111
128
|
return toSsoPage({
|
|
112
129
|
authenticator: mfa.action === "VERIFICATION_REQUIRED" ? "verify" : mfa.action === "SETUP_REQUIRED" ? "setup" : "setupOptional",
|
|
113
|
-
returnPath
|
|
130
|
+
returnPath
|
|
114
131
|
});
|
|
115
132
|
}
|
|
116
133
|
const { session } = signIn;
|
|
@@ -140,17 +157,16 @@ function failure(result) {
|
|
|
140
157
|
}
|
|
141
158
|
/**
|
|
142
159
|
* The app's SSO page, for a second factor or a failure. The return path rides
|
|
143
|
-
* in the login page's redirect param
|
|
144
|
-
*
|
|
160
|
+
* in the login page's redirect param. The page's "done" step, its "Try again"
|
|
161
|
+
* and its login link all read it from there. Without the binding cookie there
|
|
162
|
+
* is no path, and the visitor lands where any sign-in does.
|
|
145
163
|
*/
|
|
146
164
|
function toSsoPage(search) {
|
|
147
165
|
const { routes } = softrConfig().auth;
|
|
148
166
|
const params = new URLSearchParams();
|
|
149
167
|
if ("error" in search) params.set("error", search.error);
|
|
150
|
-
else
|
|
151
|
-
|
|
152
|
-
params.set(routes.login.redirectParam, search.returnPath);
|
|
153
|
-
}
|
|
168
|
+
else params.set("authenticator", search.authenticator);
|
|
169
|
+
if (search.returnPath !== void 0) params.set(routes.login.redirectParam, resolveReturnPath(search.returnPath));
|
|
154
170
|
return seeOther(`${routes.sso?.path ?? DEFAULT_SSO_PATH}?${params}`);
|
|
155
171
|
}
|
|
156
172
|
function seeOther(location) {
|
package/dist/index.d.ts
CHANGED
|
@@ -22,4 +22,6 @@ import { PwaInstall, PwaPlatform, SoftrPwaHead, usePwaInstall } from "./pwa.js";
|
|
|
22
22
|
import { PushNotifications, PushPrompt, usePushNotifications } from "./push.js";
|
|
23
23
|
import { DefaultErrorOverlay } from "./default-error-overlay.js";
|
|
24
24
|
import { Audience } from "./route/audience.js";
|
|
25
|
-
|
|
25
|
+
import { Logo, LogoFile } from "./softr-config.schema.js";
|
|
26
|
+
import { getLogo } from "./softr-config.js";
|
|
27
|
+
export { type ActionPermissions, type AiAnswer, type AiFile, type AiGenerateInit, type AiMessage, type AiUsage, Audience, type AuthOptions, type AuthSettings, AuthSettingsProvider, type DateOptions, type DateParts, type DateSeparator, type DateValue, DefaultErrorOverlay, type EmailErrorCode, type EmailSendInit, type EmailSent, type FieldShape, type FileAttachment, type FileItem, type FixedDateFormat, FormattedDate, type Formatting, FormattingScope, type Logo, type LogoFile, type Page, type PageSettings, type PushNotifications, type PushPrompt, type PwaInstall, type PwaPlatform, type SoftrContext, type SoftrDatasources, type SoftrFieldRegistry, SoftrPwaHead, type SoftrUserGroupId, type SoftrUserGroups, type SoftrUserProperties, type SsoError, type User, type WeekDay, assertRouteAccess, checkAccess, defineAiAction, defineEmailAction, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getLogo, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, ssoSignInHref, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useIdleTimeout, useOverrides, usePushNotifications, usePwaInstall, useUserTimezone };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getLogo } from "./softr-config.js";
|
|
1
2
|
import { defineAiAction, defineEmailAction, defineIntegration, defineMutation, defineQuery, defineWorkflow } from "./action.js";
|
|
2
3
|
import { useFileUpload } from "./core/use-file-upload.js";
|
|
3
4
|
import { checkAccess, defineVisibility, isAuthorized } from "./route/visibility.js";
|
|
@@ -17,4 +18,4 @@ import { useUserTimezone } from "./timezone.js";
|
|
|
17
18
|
import { DefaultErrorOverlay } from "./default-error-overlay.js";
|
|
18
19
|
import { Audience } from "./route/audience.js";
|
|
19
20
|
|
|
20
|
-
export { Audience, AuthSettingsProvider, DefaultErrorOverlay, FormattedDate, FormattingScope, SoftrPwaHead, assertRouteAccess, checkAccess, defineAiAction, defineEmailAction, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, ssoSignInHref, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useIdleTimeout, useOverrides, usePushNotifications, usePwaInstall, useUserTimezone };
|
|
21
|
+
export { Audience, AuthSettingsProvider, DefaultErrorOverlay, FormattedDate, FormattingScope, SoftrPwaHead, assertRouteAccess, checkAccess, defineAiAction, defineEmailAction, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getLogo, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, ssoSignInHref, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useIdleTimeout, useOverrides, usePushNotifications, usePwaInstall, useUserTimezone };
|
package/dist/package.js
CHANGED
package/dist/softr-config.js
CHANGED
|
@@ -4,6 +4,10 @@ import { panic } from "./assertions.js";
|
|
|
4
4
|
function softrConfig() {
|
|
5
5
|
return typeof __SOFTR_CONFIG__ === "undefined" ? panic("softr.json is missing") : __SOFTR_CONFIG__;
|
|
6
6
|
}
|
|
7
|
+
/** The app's logo, as `logo` in softr.json sets it. An app without the key gets the "layers" icon. */
|
|
8
|
+
function getLogo() {
|
|
9
|
+
return softrConfig().logo;
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
//#endregion
|
|
9
|
-
export { softrConfig };
|
|
13
|
+
export { getLogo, softrConfig };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/softr-config.schema.d.ts
|
|
4
|
+
|
|
5
|
+
declare const LogoFile: z.ZodObject<{
|
|
6
|
+
onLight: z.ZodString;
|
|
7
|
+
onDark: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
/** One logo image: the file for light backgrounds, and optionally one for dark backgrounds. */
|
|
10
|
+
type LogoFile = z.infer<typeof LogoFile>;
|
|
11
|
+
declare const Logo: z.ZodObject<{
|
|
12
|
+
source: z.ZodCatch<z.ZodEnum<{
|
|
13
|
+
image: "image";
|
|
14
|
+
icon: "icon";
|
|
15
|
+
}>>;
|
|
16
|
+
icon: z.ZodString;
|
|
17
|
+
image: z.ZodObject<{
|
|
18
|
+
square: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
onLight: z.ZodString;
|
|
20
|
+
onDark: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
horizontal: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
onLight: z.ZodString;
|
|
24
|
+
onDark: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
/** The app's logo: `logo` in softr.json, with the default icon when the key is missing. */
|
|
29
|
+
type Logo = z.infer<typeof Logo>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { Logo, LogoFile };
|
|
@@ -20,8 +20,23 @@ const AccessBehaviour = z.union([
|
|
|
20
20
|
}),
|
|
21
21
|
z.object({ strategy: z.literal("throw") })
|
|
22
22
|
], { error: "must be a path like \"/login\", { \"strategy\": \"redirect\", \"to\": \"/login\" } or { \"strategy\": \"throw\" }" });
|
|
23
|
-
const
|
|
23
|
+
const PLACEHOLDER_ORIGIN = "https://app.invalid";
|
|
24
|
+
const isPathOnApp = (path$1) => path$1.startsWith("/") && URL.canParse(path$1, PLACEHOLDER_ORIGIN) && new URL(path$1, PLACEHOLDER_ORIGIN).origin === PLACEHOLDER_ORIGIN;
|
|
25
|
+
const AppPath = z.string().refine((path$1) => isPathOnApp(path$1) && !path$1.includes("?") && !path$1.includes("#"), { error: "must be a path on this app like \"/login\", with no \"?\" or \"#\"" });
|
|
24
26
|
const Origin = z.union([z.literal("*"), z.string().regex(/^https:\/\/[^/\\?#@\s;,]+$/).refine(URL.canParse).transform((origin) => new URL(origin).origin)], { error: "must be an https origin like \"https://partner.com\", with no path or trailing \"/\", or \"*\" for any site" });
|
|
27
|
+
const LogoUrl = z.string().refine((url) => !/[\\\p{Cc}]/u.test(url) && (url.startsWith("/") ? isPathOnApp(url) : URL.canParse(url) && new URL(url).protocol === "https:"), { error: "must be a path under public/ like \"/logo.svg\", or an https URL, with no backslash or control character" });
|
|
28
|
+
const LogoFile = z.object({
|
|
29
|
+
onLight: LogoUrl,
|
|
30
|
+
onDark: LogoUrl.optional()
|
|
31
|
+
});
|
|
32
|
+
const Logo = z.object({
|
|
33
|
+
source: z.enum(["image", "icon"]).catch("icon"),
|
|
34
|
+
icon: z.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, { error: "must be a Lucide icon name like \"layers\" or \"paw-print\"" }),
|
|
35
|
+
image: z.object({
|
|
36
|
+
square: LogoFile.optional(),
|
|
37
|
+
horizontal: LogoFile.optional()
|
|
38
|
+
})
|
|
39
|
+
});
|
|
25
40
|
const SoftrConfigSchema = z.object({
|
|
26
41
|
auth: z.strictObject({
|
|
27
42
|
routes: z.strictObject({
|
|
@@ -50,7 +65,12 @@ const SoftrConfigSchema = z.object({
|
|
|
50
65
|
})
|
|
51
66
|
}),
|
|
52
67
|
user: z.strictObject({ properties: z.record(z.string(), z.string()) }).optional(),
|
|
53
|
-
allowEmbedding: z.array(Origin).optional()
|
|
68
|
+
allowEmbedding: z.array(Origin).optional(),
|
|
69
|
+
logo: Logo.default({
|
|
70
|
+
source: "icon",
|
|
71
|
+
icon: "layers",
|
|
72
|
+
image: {}
|
|
73
|
+
})
|
|
54
74
|
});
|
|
55
75
|
function loadSoftrConfig(root) {
|
|
56
76
|
const file = path.join(root, SOFTR_CONFIG_FILE);
|
package/package.json
CHANGED
package/schema/softr.schema.json
CHANGED
|
@@ -81,6 +81,29 @@
|
|
|
81
81
|
"type": "array",
|
|
82
82
|
"description": "Sites that may show the published app in an iframe, signed-in pages included, as https origins like \"https://partner.com\", or \"*\" for any site. Any other site is still blocked. With at least one, session cookies use SameSite=None, which drops the browser's CSRF protection. Empty by default.",
|
|
83
83
|
"items": { "type": "string", "pattern": "^(\\*|https://[^/\\\\?#@\\s;,]+)$" }
|
|
84
|
+
},
|
|
85
|
+
"logo": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"description": "The app's logo, written by the Logo field in Studio. Every place the app shows its brand reads it. Defaults to the \"layers\" icon.",
|
|
88
|
+
"properties": {
|
|
89
|
+
"source": {
|
|
90
|
+
"enum": ["image", "icon"],
|
|
91
|
+
"description": "Which of the two the app shows. Both are kept, so switching back loses nothing."
|
|
92
|
+
},
|
|
93
|
+
"icon": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
|
|
96
|
+
"description": "A Lucide icon name, like \"layers\". Shown next to the app's name. Also what shows when source is \"image\" and no image fits."
|
|
97
|
+
},
|
|
98
|
+
"image": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"properties": {
|
|
101
|
+
"square": { "$ref": "#/$defs/logoFile", "description": "The logo without the app name, about square." },
|
|
102
|
+
"horizontal": { "$ref": "#/$defs/logoFile", "description": "The logo with the app name in it, wide." }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"required": ["source", "icon", "image"]
|
|
84
107
|
}
|
|
85
108
|
},
|
|
86
109
|
"required": ["auth"],
|
|
@@ -102,6 +125,19 @@
|
|
|
102
125
|
"required": ["path", "tokenParam"],
|
|
103
126
|
"additionalProperties": false
|
|
104
127
|
},
|
|
128
|
+
"logoFile": {
|
|
129
|
+
"type": "object",
|
|
130
|
+
"properties": {
|
|
131
|
+
"onLight": { "$ref": "#/$defs/logoUrl", "description": "The file for light backgrounds." },
|
|
132
|
+
"onDark": { "$ref": "#/$defs/logoUrl", "description": "The file for dark backgrounds, such as dark mode. onLight shows there when it is missing." }
|
|
133
|
+
},
|
|
134
|
+
"required": ["onLight"]
|
|
135
|
+
},
|
|
136
|
+
"logoUrl": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"pattern": "^(/(?!/)|https://)[^\\\\\\u0000-\\u001F\\u007F-\\u009F]*$",
|
|
139
|
+
"description": "A path under public/, like \"/logo.svg\", or an https URL, with no backslash or control character."
|
|
140
|
+
},
|
|
105
141
|
"accessBehaviour": {
|
|
106
142
|
"oneOf": [
|
|
107
143
|
{ "type": "string", "description": "A path to redirect to." },
|
|
@@ -4,13 +4,14 @@ 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
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
|
|
8
|
-
applies, when touching the wiring, when the user
|
|
9
|
-
elsewhere,
|
|
7
|
+
the app's logo in softr.json, and which sub-skill covers each task. Load it
|
|
8
|
+
when unsure which sub-skill applies, when touching the wiring, when the user
|
|
9
|
+
wants the app embedded elsewhere, when the favicon set in Studio does not
|
|
10
|
+
show, or when the app's logo changes.
|
|
10
11
|
metadata:
|
|
11
12
|
type: core
|
|
12
13
|
library: softr-sdk
|
|
13
|
-
library_version: 1.
|
|
14
|
+
library_version: 1.12.1
|
|
14
15
|
---
|
|
15
16
|
|
|
16
17
|
# Softr SDK core
|
|
@@ -33,7 +34,7 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
|
|
|
33
34
|
|
|
34
35
|
| Import | Runs | Holds |
|
|
35
36
|
| --- | --- | --- |
|
|
36
|
-
| `@softr/sdk` | Both | `defineQuery`, `defineMutation`, `defineAiAction`, `definePage`, `pageHead`, `defineVisibility`, `guardRoute`, `assertRouteAccess`, `isAuthorized`, `checkAccess`, `Audience`, `useCurrentUser`, `useUserTimezone`, `useIdleTimeout`, `FormattedDate`, `FormattingScope`, `useFormatting`, `formatDate`, `formatDateTime`, `formatNumber`, `formatValue`, `formatField`, `fieldShape`, `registerSoftrFields`, `useOverrides`, `SoftrPwaHead`, `usePwaInstall`, `usePushNotifications`, `getSoftrContext`, `initialSoftrContext`, `softrAuthMiddleware`, the error predicates, and every type |
|
|
37
|
+
| `@softr/sdk` | Both | `defineQuery`, `defineMutation`, `defineAiAction`, `definePage`, `pageHead`, `defineVisibility`, `guardRoute`, `assertRouteAccess`, `isAuthorized`, `checkAccess`, `Audience`, `useCurrentUser`, `useUserTimezone`, `useIdleTimeout`, `FormattedDate`, `FormattingScope`, `useFormatting`, `formatDate`, `formatDateTime`, `formatNumber`, `formatValue`, `formatField`, `fieldShape`, `registerSoftrFields`, `useOverrides`, `SoftrPwaHead`, `usePwaInstall`, `usePushNotifications`, `getSoftrContext`, `getLogo`, `initialSoftrContext`, `softrAuthMiddleware`, the error predicates, and every type |
|
|
37
38
|
| `@softr/sdk/server` | Server only | `ds`, `auth`, `workflow`, `integration`, `ai` |
|
|
38
39
|
| `@softr/sdk/client` | Browser only | `useFileUpload` |
|
|
39
40
|
| `@softr/sdk/vite` | Build | `softr()`, already in `vite.config.ts` |
|
|
@@ -108,6 +109,9 @@ Showing a date, a time or a number on a page?
|
|
|
108
109
|
The favicon set in Studio does not show?
|
|
109
110
|
read "The app's favicon" below
|
|
110
111
|
|
|
112
|
+
Changing the app's logo, or reading it in code?
|
|
113
|
+
read "The app's logo" below
|
|
114
|
+
|
|
111
115
|
Writing a server function, loader, or middleware in general?
|
|
112
116
|
not a Softr concern. Use the TanStack Start skills.
|
|
113
117
|
```
|
|
@@ -178,3 +182,23 @@ The app's favicon is a Studio setting: Settings → General → Favicon. The app
|
|
|
178
182
|
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
183
|
|
|
180
184
|
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.
|
|
185
|
+
|
|
186
|
+
## The app's logo
|
|
187
|
+
|
|
188
|
+
The app's logo is `logo` in `softr.json`. The Logo field in Studio writes it, and code edits it like any other file. `getLogo()` from `@softr/sdk` reads it, on the server and in the browser. Read it there, never by importing `softr.json`.
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
"logo": {
|
|
192
|
+
"source": "image",
|
|
193
|
+
"icon": "paw-print",
|
|
194
|
+
"image": {
|
|
195
|
+
"square": { "onLight": "/logo.png", "onDark": "/logo-dark.png" },
|
|
196
|
+
"horizontal": { "onLight": "/logo-wide.svg" }
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- `source` is what the app shows, `"image"` or `"icon"`. The file keeps both, so a switch back loses nothing.
|
|
202
|
+
- `icon` is a Lucide icon name in kebab case, like `"layers"`. It is always set, and it shows when `source` is `"image"` and no image fits.
|
|
203
|
+
- `image.square` is the logo without the app's name, about square. `image.horizontal` is the logo with the name in it, wide. Either may be missing. Each has `onLight`, and `onDark` for dark backgrounds, which falls back to `onLight`. A file is a path under `public/`, like `"/logo.svg"`, or an https URL.
|
|
204
|
+
- An app without the key gets `{ "source": "icon", "icon": "layers", "image": {} }`. A field this SDK does not know is ignored, and an unknown `source` shows the icon. An `icon` that is not a kebab-case name, an image without `onLight` or a file that is neither a path under `public/` nor an https URL fails the build, naming the key.
|
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: sub-skill
|
|
15
15
|
library: softr-sdk
|
|
16
|
-
library_version: 1.
|
|
16
|
+
library_version: 1.12.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.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.
|
|
13
|
+
library_version: 1.12.1
|
|
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.
|
|
@@ -20,12 +20,12 @@ A plain `<a href>`, never `<Link>` or `navigate`: the visitor leaves the app for
|
|
|
20
20
|
|
|
21
21
|
Sign-in starts in the app, always. A sign-in started at the identity provider, from an app tile on its dashboard, is not supported: it arrives without the app's record of having started and ends in `expired`.
|
|
22
22
|
|
|
23
|
-
When single sign-on needs more from the visitor, or fails, they come back to the page `auth.routes.sso.path` in `softr.json` names, `/sso-authentication` when it is not set. That page must exist. It reads two search params:
|
|
23
|
+
When single sign-on needs more from the visitor, or fails, they come back to the page `auth.routes.sso.path` in `softr.json` names, `/sso-authentication` when it is not set. That page must exist. It reads two search params, and the login page's redirect param (`auth.routes.login.redirectParam`) with the path the visitor wanted:
|
|
24
24
|
|
|
25
25
|
| Param | Means | Show |
|
|
26
26
|
| --- | --- | --- |
|
|
27
27
|
| `authenticator` | `'verify'`, `'setup'` or `'setupOptional'`: the app asks for an authenticator app as well | the second-factor step, as for `authenticatorRequired` and its `step`. Finish with the same calls, then `toReturnPath(location)` |
|
|
28
|
-
| `error` | why it did not finish, one of the codes below | a message, a "Try again" link to `ssoSignInHref()`, and a link to the login page |
|
|
28
|
+
| `error` | why it did not finish, one of the codes below | a message, a "Try again" link to `ssoSignInHref(toReturnPath(location).href)`, and a link to the login page that keeps the redirect param, so either way the visitor ends where they wanted |
|
|
29
29
|
|
|
30
30
|
| `error` | Means |
|
|
31
31
|
| --- | --- |
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.
|
|
13
|
+
library_version: 1.12.1
|
|
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.
|
|
15
|
+
library_version: 1.12.1
|
|
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.
|
|
10
|
+
library_version: 1.12.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.
|
|
10
|
+
library_version: 1.12.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.
|
|
12
|
+
library_version: 1.12.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.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.
|
|
13
|
+
library_version: 1.12.1
|
|
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.
|
|
14
|
+
library_version: 1.12.1
|
|
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.
|
|
12
|
+
library_version: 1.12.1
|
|
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.
|
|
12
|
+
library_version: 1.12.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.
|