@softr/sdk 0.0.101-seo.0 → 0.0.102
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/context.d.ts +0 -5
- package/dist/auth/isomorphic.d.ts +1 -2
- package/dist/auth/isomorphic.js +4 -4
- package/dist/auth/session.js +1 -11
- package/dist/cache.js +25 -0
- package/dist/formatting.d.ts +13 -10
- package/dist/formatting.js +11 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/push.d.ts +52 -0
- package/dist/push.js +295 -0
- package/dist/pwa.js +8 -19
- package/dist/route/page.d.ts +3 -41
- package/dist/route/page.js +25 -102
- package/dist/server.d.ts +1 -3
- package/dist/server.js +1 -3
- package/package.json +10 -33
- package/skills/softr-sdk/SKILL.md +7 -8
- package/skills/softr-sdk/ai/SKILL.md +2 -2
- 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 +3 -3
- 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 +140 -0
- 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 +4 -90
- package/skills/softr-sdk/workflows/SKILL.md +1 -1
- package/dist/auth/session.d.ts +0 -14
- package/dist/origin.js +0 -16
- package/dist/sitemap.d.ts +0 -35
- package/dist/sitemap.js +0 -56
- package/skills/softr-sdk/sitemap/SKILL.md +0 -112
package/dist/pwa.js
CHANGED
|
@@ -2,6 +2,7 @@ import { logger } from "./logger.js";
|
|
|
2
2
|
import { softrApiUrl } from "./softr-api.js";
|
|
3
3
|
import { fetch } from "./fetch.js";
|
|
4
4
|
import { sessionConfig } from "./auth/config.js";
|
|
5
|
+
import { readCached } from "./cache.js";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
import { Fragment, createElement, useEffect, useState } from "react";
|
|
7
8
|
import { createMiddleware } from "@tanstack/react-start";
|
|
@@ -20,24 +21,9 @@ const pwaSchema = z.object({
|
|
|
20
21
|
})
|
|
21
22
|
});
|
|
22
23
|
let cached;
|
|
23
|
-
/**
|
|
24
|
-
* The app's PWA, or `null` when it is not installable right now. Never
|
|
25
|
-
* rejects: a failure reads as not installable and is not remembered, so the
|
|
26
|
-
* next request tries again.
|
|
27
|
-
*/
|
|
24
|
+
/** The app's PWA, or `null` when it is not installable right now. */
|
|
28
25
|
function readPwa() {
|
|
29
|
-
|
|
30
|
-
if (cached !== void 0 && cached.expires > now) return cached.pwa;
|
|
31
|
-
const entry = {
|
|
32
|
-
expires: now + TTL_MS,
|
|
33
|
-
pwa: fetchPwa().catch((error) => {
|
|
34
|
-
logger.warn("Could not read the PWA settings:", error);
|
|
35
|
-
if (cached === entry) cached = void 0;
|
|
36
|
-
return null;
|
|
37
|
-
})
|
|
38
|
-
};
|
|
39
|
-
cached = entry;
|
|
40
|
-
return entry.pwa;
|
|
26
|
+
return readCached("the PWA settings", TTL_MS, () => cached, (entry) => cached = entry, fetchPwa);
|
|
41
27
|
}
|
|
42
28
|
async function fetchPwa() {
|
|
43
29
|
const { applicationId } = sessionConfig();
|
|
@@ -123,7 +109,7 @@ const installSchema = pwaSchema.shape.install;
|
|
|
123
109
|
function usePwaInstall() {
|
|
124
110
|
const [install, setInstall] = useState({ available: false });
|
|
125
111
|
useEffect(() => {
|
|
126
|
-
if (
|
|
112
|
+
if (isStandalone()) return;
|
|
127
113
|
let cancelled = false;
|
|
128
114
|
globalThis.fetch(INSTALL_PATH, { headers: { accept: "application/json" } }).then(async (response) => {
|
|
129
115
|
if (!response.ok) return;
|
|
@@ -147,6 +133,9 @@ function detectPlatform() {
|
|
|
147
133
|
if (/Android/.test(userAgent)) return "android";
|
|
148
134
|
return "desktop";
|
|
149
135
|
}
|
|
136
|
+
function isStandalone() {
|
|
137
|
+
return window.matchMedia("(display-mode: standalone)").matches || "standalone" in navigator && navigator.standalone === true;
|
|
138
|
+
}
|
|
150
139
|
|
|
151
140
|
//#endregion
|
|
152
|
-
export { SoftrPwaHead, pwaMiddleware, usePwaInstall };
|
|
141
|
+
export { SoftrPwaHead, detectPlatform, isStandalone, pwaMiddleware, usePwaInstall };
|
package/dist/route/page.d.ts
CHANGED
|
@@ -6,11 +6,6 @@ import { AnyRouteMatch } from "@tanstack/react-router";
|
|
|
6
6
|
type HeadContext = {
|
|
7
7
|
match: {
|
|
8
8
|
id: string;
|
|
9
|
-
pathname?: string;
|
|
10
|
-
search?: object;
|
|
11
|
-
context?: {
|
|
12
|
-
origin?: string;
|
|
13
|
-
};
|
|
14
9
|
};
|
|
15
10
|
matches: ReadonlyArray<{
|
|
16
11
|
id: string;
|
|
@@ -65,48 +60,15 @@ type Links = NonNullable<AnyRouteMatch["links"]>;
|
|
|
65
60
|
* A canonical URL names one page, so only the page the visitor is on renders
|
|
66
61
|
* its own.
|
|
67
62
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* description fall back to the title and description.
|
|
71
|
-
*
|
|
72
|
-
* Write a `head` that reads the loader's data after `loader`, so TypeScript
|
|
73
|
-
* infers the loader's types.
|
|
63
|
+
* Returned rather than called with the route's context: a `head` written as
|
|
64
|
+
* `(ctx) => …` before `loader` stops TypeScript inferring the loader's types.
|
|
74
65
|
*
|
|
75
66
|
* @example
|
|
76
67
|
* head: pageHead(pageSettings)
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* loader: ({ params }) => getArticle({ data: params.articleId }),
|
|
80
|
-
* head: (ctx) =>
|
|
81
|
-
* pageHead({
|
|
82
|
-
* ...pageSettings,
|
|
83
|
-
* title: ctx.loaderData?.fields.title ?? pageSettings.title,
|
|
84
|
-
* description: excerpt(ctx.loaderData?.fields.body) ?? pageSettings.description,
|
|
85
|
-
* })(ctx),
|
|
86
68
|
*/
|
|
87
69
|
declare function pageHead(page: Page): (ctx: HeadContext) => {
|
|
88
70
|
meta: Meta;
|
|
89
71
|
links: Links;
|
|
90
72
|
};
|
|
91
|
-
/**
|
|
92
|
-
* Plain text for a page description: markdown and HTML stripped, whitespace
|
|
93
|
-
* collapsed, and cut at a word boundary with an ellipsis when longer than
|
|
94
|
-
* `maxLength`. `undefined` when nothing is left.
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* description: excerpt(ctx.loaderData?.fields.body) ?? pageSettings.description
|
|
98
|
-
*/
|
|
99
|
-
declare function excerpt(text: string | null | undefined, maxLength?: number): string | undefined;
|
|
100
|
-
/**
|
|
101
|
-
* A `head` script entry carrying `data` as JSON-LD. Every `<` is escaped, so
|
|
102
|
-
* no value can close the script tag.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* scripts: [jsonLdScript({ "@context": "https://schema.org", "@type": "Article", headline: article.title })]
|
|
106
|
-
*/
|
|
107
|
-
declare function jsonLdScript(data: object): {
|
|
108
|
-
type: "application/ld+json";
|
|
109
|
-
children: string;
|
|
110
|
-
};
|
|
111
73
|
//#endregion
|
|
112
|
-
export { Page, PageSettings, definePage,
|
|
74
|
+
export { Page, PageSettings, definePage, pageHead };
|
package/dist/route/page.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { assert } from "../assertions.js";
|
|
2
|
-
|
|
3
1
|
//#region src/route/page.ts
|
|
4
2
|
/**
|
|
5
3
|
* Declares a route's settings: its name in Studio, who may open it, its title and its SEO tags.
|
|
@@ -31,126 +29,51 @@ function definePage(settings) {
|
|
|
31
29
|
* A canonical URL names one page, so only the page the visitor is on renders
|
|
32
30
|
* its own.
|
|
33
31
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* description fall back to the title and description.
|
|
37
|
-
*
|
|
38
|
-
* Write a `head` that reads the loader's data after `loader`, so TypeScript
|
|
39
|
-
* infers the loader's types.
|
|
32
|
+
* Returned rather than called with the route's context: a `head` written as
|
|
33
|
+
* `(ctx) => …` before `loader` stops TypeScript inferring the loader's types.
|
|
40
34
|
*
|
|
41
35
|
* @example
|
|
42
36
|
* head: pageHead(pageSettings)
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* loader: ({ params }) => getArticle({ data: params.articleId }),
|
|
46
|
-
* head: (ctx) =>
|
|
47
|
-
* pageHead({
|
|
48
|
-
* ...pageSettings,
|
|
49
|
-
* title: ctx.loaderData?.fields.title ?? pageSettings.title,
|
|
50
|
-
* description: excerpt(ctx.loaderData?.fields.body) ?? pageSettings.description,
|
|
51
|
-
* })(ctx),
|
|
52
37
|
*/
|
|
53
38
|
function pageHead(page) {
|
|
54
39
|
return (ctx) => {
|
|
55
|
-
const resolve = (setting) =>
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
const resolve = (setting) => typeof setting === "function" ? setting(ctx) : setting;
|
|
41
|
+
const tag = (setting, make) => {
|
|
42
|
+
const value = resolve(setting);
|
|
43
|
+
return typeof value === "string" && value !== "" ? [make(value)] : [];
|
|
58
44
|
};
|
|
59
|
-
const origin = ctx.match.context?.origin;
|
|
60
|
-
const title = resolve(page.title);
|
|
61
|
-
const description = resolve(page.description);
|
|
62
|
-
const socialTitle = resolve(page.socialTitle) ?? title;
|
|
63
|
-
const socialDescription = resolve(page.socialDescription) ?? description;
|
|
64
|
-
const socialImage = resolve(page.socialImage);
|
|
65
45
|
const indexing = resolve(page.searchEngineIndexing);
|
|
66
|
-
const canonical = ctx.matches.at(-1)?.id === ctx.match.id ? canonicalUrl(resolve(page.canonicalUrl), ctx.match.pathname, ctx.match.search, origin) : void 0;
|
|
67
46
|
return {
|
|
68
47
|
meta: [
|
|
69
|
-
...title
|
|
70
|
-
...description
|
|
48
|
+
...tag(page.title, (title) => ({ title })),
|
|
49
|
+
...tag(page.description, (content) => ({
|
|
71
50
|
name: "description",
|
|
72
|
-
content
|
|
73
|
-
}
|
|
74
|
-
...socialTitle
|
|
51
|
+
content
|
|
52
|
+
})),
|
|
53
|
+
...tag(page.socialTitle, (content) => ({
|
|
75
54
|
property: "og:title",
|
|
76
|
-
content
|
|
77
|
-
}
|
|
78
|
-
...socialDescription
|
|
55
|
+
content
|
|
56
|
+
})),
|
|
57
|
+
...tag(page.socialDescription, (content) => ({
|
|
79
58
|
property: "og:description",
|
|
80
|
-
content
|
|
81
|
-
}
|
|
82
|
-
...socialImage
|
|
59
|
+
content
|
|
60
|
+
})),
|
|
61
|
+
...tag(page.socialImage, (content) => ({
|
|
83
62
|
property: "og:image",
|
|
84
|
-
content
|
|
85
|
-
}
|
|
86
|
-
...
|
|
87
|
-
property: "og:url",
|
|
88
|
-
content: canonical
|
|
89
|
-
}],
|
|
90
|
-
...indexing === void 0 ? [] : [{
|
|
63
|
+
content
|
|
64
|
+
})),
|
|
65
|
+
...typeof indexing === "boolean" ? [{
|
|
91
66
|
name: "robots",
|
|
92
67
|
content: indexing ? "index" : "noindex"
|
|
93
|
-
}]
|
|
68
|
+
}] : []
|
|
94
69
|
],
|
|
95
|
-
links:
|
|
70
|
+
links: ctx.matches.at(-1)?.id === ctx.match.id ? tag(page.canonicalUrl, (href) => ({
|
|
96
71
|
rel: "canonical",
|
|
97
|
-
href
|
|
98
|
-
}]
|
|
72
|
+
href
|
|
73
|
+
})) : []
|
|
99
74
|
};
|
|
100
75
|
};
|
|
101
76
|
}
|
|
102
|
-
function canonicalUrl(stated, pathname, search, origin) {
|
|
103
|
-
if (stated !== void 0) return URL.parse(stated, origin)?.href;
|
|
104
|
-
if (origin === void 0 || pathname === void 0) return void 0;
|
|
105
|
-
const url = new URL(pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname, origin);
|
|
106
|
-
const page = typeof search === "object" && search !== null && "page" in search ? search.page : void 0;
|
|
107
|
-
if (typeof page === "string" || typeof page === "number") url.searchParams.set("page", String(page));
|
|
108
|
-
return url.href;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Plain text for a page description: markdown and HTML stripped, whitespace
|
|
112
|
-
* collapsed, and cut at a word boundary with an ellipsis when longer than
|
|
113
|
-
* `maxLength`. `undefined` when nothing is left.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* description: excerpt(ctx.loaderData?.fields.body) ?? pageSettings.description
|
|
117
|
-
*/
|
|
118
|
-
function excerpt(text, maxLength = 155) {
|
|
119
|
-
assert(maxLength > 1, "maxLength must be at least 2");
|
|
120
|
-
if (!text) return void 0;
|
|
121
|
-
const plain = text.replace(/<[^>]*>/g, " ").replace(/^\s*(`{3,}|~{3,}).*$/gm, "").replace(/^\s*([-*_]\s*){3,}$/gm, "").replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^\s*(#{1,6}|>+|[-*+]|\d+[.)])\s+/gm, "").replace(/[*`]+|~~|(?<!\w)_+|_+(?!\w)/g, "").replace(/&(#x[0-9a-f]{1,6}|#\d{1,7}|amp|lt|gt|quot|apos|nbsp);/gi, (entity, name) => {
|
|
122
|
-
const lower = name.toLowerCase();
|
|
123
|
-
if (!lower.startsWith("#")) return NAMED_ENTITIES[lower] ?? entity;
|
|
124
|
-
const code = lower.startsWith("#x") ? Number.parseInt(lower.slice(2), 16) : Number.parseInt(lower.slice(1), 10);
|
|
125
|
-
return code <= 1114111 ? String.fromCodePoint(code) : entity;
|
|
126
|
-
}).replace(/\s+/g, " ").replace(/ ([.,;:!?])/g, "$1").trim();
|
|
127
|
-
if (plain === "") return void 0;
|
|
128
|
-
if (plain.length <= maxLength) return plain;
|
|
129
|
-
const cut = plain.slice(0, maxLength);
|
|
130
|
-
const lastSpace = cut.lastIndexOf(" ");
|
|
131
|
-
return `${(lastSpace > 0 ? cut.slice(0, lastSpace) : cut.slice(0, maxLength - 1)).replace(/[\s.,;:!?-]+$/, "")}…`;
|
|
132
|
-
}
|
|
133
|
-
const NAMED_ENTITIES = {
|
|
134
|
-
amp: "&",
|
|
135
|
-
lt: "<",
|
|
136
|
-
gt: ">",
|
|
137
|
-
quot: "\"",
|
|
138
|
-
apos: "'",
|
|
139
|
-
nbsp: " "
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* A `head` script entry carrying `data` as JSON-LD. Every `<` is escaped, so
|
|
143
|
-
* no value can close the script tag.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* scripts: [jsonLdScript({ "@context": "https://schema.org", "@type": "Article", headline: article.title })]
|
|
147
|
-
*/
|
|
148
|
-
function jsonLdScript(data) {
|
|
149
|
-
return {
|
|
150
|
-
type: "application/ld+json",
|
|
151
|
-
children: JSON.stringify(data).replaceAll("<", "\\u003c")
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
77
|
|
|
155
78
|
//#endregion
|
|
156
|
-
export { definePage,
|
|
79
|
+
export { definePage, pageHead };
|
package/dist/server.d.ts
CHANGED
|
@@ -5,7 +5,5 @@ import { FieldChoice, RecordOption, RecordOptions } from "./core/options.js";
|
|
|
5
5
|
import { ds } from "./datasource/datasource.js";
|
|
6
6
|
import { workflow } from "./core/workflow.js";
|
|
7
7
|
import { integration } from "./core/integration.js";
|
|
8
|
-
import { asSignedOutVisitor } from "./auth/session.js";
|
|
9
|
-
import { SitemapEntry, sitemapXml } from "./sitemap.js";
|
|
10
8
|
import "@tanstack/react-start/server-only";
|
|
11
|
-
export { AiError, type FieldChoice, type RecordOption, type RecordOptions,
|
|
9
|
+
export { AiError, type FieldChoice, type RecordOption, type RecordOptions, ai, auth, ds, integration, upload, workflow };
|
package/dist/server.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { asSignedOutVisitor } from "./auth/session.js";
|
|
2
1
|
import { upload } from "./core/file-upload.js";
|
|
3
2
|
import { ds } from "./datasource/datasource.js";
|
|
4
3
|
import { auth } from "./auth/server.js";
|
|
5
4
|
import { workflow } from "./core/workflow.js";
|
|
6
5
|
import { integration } from "./core/integration.js";
|
|
7
6
|
import { AiError, ai } from "./core/ai.js";
|
|
8
|
-
import { sitemapXml } from "./sitemap.js";
|
|
9
7
|
import "@tanstack/react-start/server-only";
|
|
10
8
|
|
|
11
|
-
export { AiError, ai,
|
|
9
|
+
export { AiError, ai, auth, ds, integration, upload, workflow };
|
package/package.json
CHANGED
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softr/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.102",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
|
-
".": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
},
|
|
23
|
-
"bin": {
|
|
24
|
-
"softr-sdk": "./dist/cli.js"
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist",
|
|
28
|
-
"schema",
|
|
29
|
-
"skills",
|
|
30
|
-
"!skills/_artifacts"
|
|
31
|
-
],
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"access": "public"
|
|
34
|
-
},
|
|
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
|
+
},
|
|
11
|
+
"bin": { "softr-sdk": "./dist/cli.js" },
|
|
12
|
+
"files": ["dist", "schema", "skills", "!skills/_artifacts"],
|
|
13
|
+
"publishConfig": { "access": "public" },
|
|
35
14
|
"scripts": {
|
|
36
15
|
"build": "tsdown",
|
|
37
16
|
"test": "node --import ./src/test-utils/setup.ts --test",
|
|
@@ -63,9 +42,7 @@
|
|
|
63
42
|
"optional": true
|
|
64
43
|
}
|
|
65
44
|
},
|
|
66
|
-
"keywords": [
|
|
67
|
-
"tanstack-intent"
|
|
68
|
-
],
|
|
45
|
+
"keywords": ["tanstack-intent"],
|
|
69
46
|
"intent": {
|
|
70
47
|
"version": 1,
|
|
71
48
|
"repo": "@softr/sdk",
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: core
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.
|
|
12
|
+
library_version: 0.0.102
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
# Softr SDK core
|
|
@@ -32,8 +32,8 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
|
|
|
32
32
|
|
|
33
33
|
| Import | Runs | Holds |
|
|
34
34
|
| --- | --- | --- |
|
|
35
|
-
| `@softr/sdk` | Both | `defineQuery`, `defineMutation`, `defineAiAction`, `definePage`, `pageHead`, `
|
|
36
|
-
| `@softr/sdk/server` | Server only | `ds`, `auth`, `workflow`, `integration`, `ai
|
|
35
|
+
| `@softr/sdk` | Both | `defineQuery`, `defineMutation`, `defineAiAction`, `definePage`, `pageHead`, `defineVisibility`, `guardRoute`, `assertRouteAccess`, `isAuthorized`, `checkAccess`, `Audience`, `useCurrentUser`, `useUserTimezone`, `FormattedDate`, `FormattingScope`, `useFormatting`, `formatDate`, `formatDateTime`, `formatNumber`, `formatValue`, `formatField`, `fieldShape`, `registerSoftrFields`, `useOverrides`, `SoftrPwaHead`, `usePwaInstall`, `usePushNotifications`, `getSoftrContext`, `initialSoftrContext`, `softrAuthMiddleware`, the error predicates, and every type |
|
|
36
|
+
| `@softr/sdk/server` | Server only | `ds`, `auth`, `workflow`, `integration`, `ai` |
|
|
37
37
|
| `@softr/sdk/client` | Browser only | `useFileUpload` |
|
|
38
38
|
| `@softr/sdk/vite` | Build | `softr()`, already in `vite.config.ts` |
|
|
39
39
|
|
|
@@ -42,7 +42,6 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
|
|
|
42
42
|
| Task | Sub-Skill |
|
|
43
43
|
| --- | --- |
|
|
44
44
|
| Add a route, or change who can see one | [routes-and-visibility/SKILL.md](./routes-and-visibility/SKILL.md) |
|
|
45
|
-
| List the public pages in `/sitemap.xml` | [sitemap/SKILL.md](./sitemap/SKILL.md) |
|
|
46
45
|
| Show part of a page to some visitors only | [region-visibility/SKILL.md](./region-visibility/SKILL.md) |
|
|
47
46
|
| Read the signed-in visitor | [current-user/SKILL.md](./current-user/SKILL.md) |
|
|
48
47
|
| Fetch records from a datasource | [record-queries/SKILL.md](./record-queries/SKILL.md) |
|
|
@@ -54,6 +53,7 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
|
|
|
54
53
|
| Call a connected third-party API (Slack, Stripe, Gmail, …), or an AI model on the user's own provider account | [integrations/SKILL.md](./integrations/SKILL.md) |
|
|
55
54
|
| Open the app to AI assistants over MCP | [mcp/SKILL.md](./mcp/SKILL.md) |
|
|
56
55
|
| Let visitors install the app on their home screen | [pwa/SKILL.md](./pwa/SKILL.md) |
|
|
56
|
+
| Let visitors turn on push notifications | [push-notifications/SKILL.md](./push-notifications/SKILL.md) |
|
|
57
57
|
| Show a date, a time or a number | [formatting/SKILL.md](./formatting/SKILL.md) |
|
|
58
58
|
|
|
59
59
|
## Quick Decision Tree
|
|
@@ -62,9 +62,6 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
|
|
|
62
62
|
Adding a page, or changing who may see one?
|
|
63
63
|
load softr-sdk/routes-and-visibility
|
|
64
64
|
|
|
65
|
-
Serving /sitemap.xml, or adding a public page or public record page to it?
|
|
66
|
-
load softr-sdk/sitemap
|
|
67
|
-
|
|
68
65
|
Hiding a region of a page from some visitors?
|
|
69
66
|
load softr-sdk/region-visibility
|
|
70
67
|
|
|
@@ -101,6 +98,9 @@ Opening the app to an AI assistant over MCP?
|
|
|
101
98
|
Adding an install button, or making the app installable?
|
|
102
99
|
load softr-sdk/pwa
|
|
103
100
|
|
|
101
|
+
Letting visitors turn on push notifications, or "notify users when …"?
|
|
102
|
+
load softr-sdk/push-notifications
|
|
103
|
+
|
|
104
104
|
Showing a date, a time or a number on a page?
|
|
105
105
|
load softr-sdk/formatting
|
|
106
106
|
|
|
@@ -153,7 +153,6 @@ export function getRouter() {
|
|
|
153
153
|
```ts
|
|
154
154
|
type SoftrContext = {
|
|
155
155
|
user: User | null // null means signed out
|
|
156
|
-
origin?: string // the app's address, such as https://acme.com
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
type User = {
|
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: sub-skill
|
|
15
15
|
library: softr-sdk
|
|
16
|
-
library_version: 0.0.
|
|
16
|
+
library_version: 0.0.102
|
|
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.
|
|
@@ -26,7 +26,7 @@ An app asks a model through an AI action. Softr runs the call on its own provide
|
|
|
26
26
|
|
|
27
27
|
Never choose silently between Softr AI and the user's own account. Decide for each AI feature, before you write its code, in this order:
|
|
28
28
|
|
|
29
|
-
1. The user said who runs it: follow it. "My OpenAI key" or "our Anthropic account", with exactly one integration of that type in `integration_list`: use that one, without asking. A new
|
|
29
|
+
1. The user said who runs it: follow it. "My OpenAI key" or "our Anthropic account", with exactly one integration of that type in `integration_list`: use that one, without asking. A new key of a provider they named — they asked for a new one, or the workspace holds none of that type — is one `requestinput` of type `integration` for that type: its card connects one. A connected key runs the feature; a skipped request means Softr AI, and you say so. Several keys of that type, or "my own key" with no provider: ask (step 4). A provider or a model named without "my" or "our" ("use Claude", "summarise with GPT") is a model preference on Softr AI, not a reason to ask.
|
|
30
30
|
2. The app already has AI features: follow the choice they made, and say so in one line.
|
|
31
31
|
3. `integration_list` shows no `OPEN_AI`, `ANTHROPIC_AI` or `GEMINI_AI` integration: use Softr AI, and say so in one line. Call the tool; do not assume the answer.
|
|
32
32
|
4. Otherwise ask with one `requestinput` of type `aiProvider`. Its card lists every key the workspace holds and every provider to connect, unfiltered. The answer is Softr AI, or the integration with its id and type: follow it, even when it is another provider than the one the user named. A declined request means Softr AI: use it, and say so in one line.
|
|
@@ -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.102
|
|
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.102
|
|
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.102
|
|
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.
|
|
@@ -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.102
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
# Dates, times and numbers
|
|
@@ -27,7 +27,7 @@ import type { Formatting, DateValue, DateOptions } from '@softr/sdk'
|
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
type DateValue = Date | number | string // a record's date field works as is
|
|
30
|
+
type DateValue = Date | number | string // a record's date field works as is; null and undefined are accepted too and show nothing
|
|
31
31
|
|
|
32
32
|
type Formatting = {
|
|
33
33
|
dateLocale: string
|
|
@@ -113,7 +113,7 @@ formatNumber(99, formatting, { style: 'currency', currency: 'EUR' })
|
|
|
113
113
|
|
|
114
114
|
The currency comes from the field or from the user, never from the locale. A German visitor looking at a price in dollars still sees dollars.
|
|
115
115
|
|
|
116
|
-
`formatDate` and `formatDateTime` show a timestamp in UTC while `formatting.timeZone` is `null`. In JSX, prefer `<FormattedDate />`, which waits instead.
|
|
116
|
+
`formatDate` and `formatDateTime` show a timestamp in UTC while `formatting.timeZone` is `null`. In JSX, prefer `<FormattedDate />`, which waits instead. A `null` or `undefined` value returns `''` from the functions and renders nothing from `<FormattedDate />`, so a record's nullable date field needs no guard.
|
|
117
117
|
|
|
118
118
|
### A field's own text: `formatValue`
|
|
119
119
|
|
|
@@ -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.102
|
|
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.102
|
|
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.
|