@softr/sdk 0.0.88-signing.0 → 0.0.89-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/dist/agent/agent-fns.d.ts +30 -0
- package/dist/agent/agent-fns.js +172 -0
- package/dist/agent/use-agent-chat.d.ts +100 -0
- package/dist/agent/use-agent-chat.js +419 -0
- package/dist/auth/isomorphic.d.ts +3 -2
- package/dist/auth/isomorphic.js +4 -1
- package/dist/auth/methods/authenticator.js +3 -3
- package/dist/auth/methods/code.js +1 -1
- package/dist/auth/methods/magicLink.js +1 -1
- package/dist/auth/methods/password.js +1 -1
- package/dist/auth/methods/passwordLink.js +1 -1
- package/dist/auth/methods/signup.js +1 -1
- package/dist/auth/methods/social.js +1 -1
- package/dist/auth/platform.js +2 -2
- package/dist/auth/session.js +8 -7
- package/dist/codegen/datasource-docs.js +9 -3
- package/dist/cookies.js +29 -3
- package/dist/core/file-upload.js +1 -1
- package/dist/core/workflow.js +1 -1
- package/dist/datasource/record.js +1 -1
- package/dist/embedding.js +33 -0
- package/dist/fetch.js +1 -61
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/locale-settings.js +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +6 -4
- package/dist/package.js +1 -1
- package/dist/pwa.js +2 -2
- package/dist/route/route.js +1 -1
- package/dist/softr-config.schema.js +3 -1
- package/package.json +1 -1
- package/schema/softr.schema.json +5 -0
- package/skills/softr-sdk/SKILL.md +14 -5
- package/skills/softr-sdk/agent-chat/SKILL.md +122 -0
- 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 +9 -5
- 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 +2 -2
- package/skills/softr-sdk/region-visibility/SKILL.md +3 -5
- package/skills/softr-sdk/routes-and-visibility/SKILL.md +85 -44
- package/skills/softr-sdk/workflows/SKILL.md +1 -1
package/dist/core/file-upload.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { softrApiUrl } from "../softr-api.js";
|
|
2
1
|
import { fetch } from "../fetch.js";
|
|
3
2
|
import { sessionConfig } from "../auth/config.js";
|
|
4
3
|
import { readSessionToken } from "../auth/session.js";
|
|
4
|
+
import { softrApiUrl } from "../softr-api.js";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
|
|
7
7
|
//#region src/core/file-upload.ts
|
package/dist/core/workflow.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { softrApiUrl } from "../softr-api.js";
|
|
2
1
|
import { fetch } from "../fetch.js";
|
|
3
2
|
import { sessionConfig } from "../auth/config.js";
|
|
4
3
|
import { readSessionToken } from "../auth/session.js";
|
|
4
|
+
import { softrApiUrl } from "../softr-api.js";
|
|
5
5
|
|
|
6
6
|
//#region src/core/workflow.ts
|
|
7
7
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assert, panic } from "../assertions.js";
|
|
2
|
-
import { softrApiUrl } from "../softr-api.js";
|
|
3
2
|
import { fetch } from "../fetch.js";
|
|
4
3
|
import { readUserTimezone } from "../cookies.js";
|
|
5
4
|
import { readSessionToken } from "../auth/session.js";
|
|
5
|
+
import { softrApiUrl } from "../softr-api.js";
|
|
6
6
|
import { isDatasourceAction } from "../action.js";
|
|
7
7
|
import { buildFilterCriteria, buildOrderBy, dealiasFilterCriteria, dealiasOrderBy } from "./filter.js";
|
|
8
8
|
import { andAll, makeFieldSet, makeSortSet } from "./fields.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
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. The origins
|
|
7
|
+
* softr.json lists in `allowEmbedding` still can.
|
|
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
|
+
const policy = [
|
|
17
|
+
"frame-ancestors",
|
|
18
|
+
"'self'",
|
|
19
|
+
...softrConfig().allowEmbedding ?? []
|
|
20
|
+
].join(" ");
|
|
21
|
+
try {
|
|
22
|
+
result.response.headers.append("content-security-policy", policy);
|
|
23
|
+
return result;
|
|
24
|
+
} catch {
|
|
25
|
+
const response = new Response(result.response.body, result.response);
|
|
26
|
+
response.headers.append("content-security-policy", policy);
|
|
27
|
+
return response;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { embeddingMiddleware };
|
package/dist/fetch.js
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
|
-
import { version } from "./package.js";
|
|
2
|
-
import { assert, requireDefined } from "./assertions.js";
|
|
3
1
|
import { logger } from "./logger.js";
|
|
4
|
-
import { softrApiUrl } from "./softr-api.js";
|
|
5
2
|
|
|
6
3
|
//#region src/fetch.ts
|
|
7
4
|
const fetch = async (input, init) => {
|
|
8
|
-
const url = input instanceof Request ? input.url : String(input);
|
|
9
|
-
if ([
|
|
10
|
-
softrApiUrl("SOFTR_PLATFORM_API_URL"),
|
|
11
|
-
softrApiUrl("SOFTR_DATASOURCE_API_URL"),
|
|
12
|
-
softrApiUrl("SOFTR_WORKFLOWS_API_URL")
|
|
13
|
-
].some((base) => url.startsWith(`${base}/`))) {
|
|
14
|
-
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : void 0));
|
|
15
|
-
headers.set("user-agent", `softr-sdk/${version}`);
|
|
16
|
-
init = {
|
|
17
|
-
...init,
|
|
18
|
-
headers
|
|
19
|
-
};
|
|
20
|
-
const signed = await sign(input, init);
|
|
21
|
-
if (signed) {
|
|
22
|
-
input = signed;
|
|
23
|
-
init = void 0;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
5
|
if (process.env.NODE_ENV === "production") return globalThis.fetch(input, init);
|
|
6
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
27
7
|
const method = init?.method ?? (input instanceof Request ? input.method : "GET");
|
|
28
8
|
const started = Date.now();
|
|
29
9
|
try {
|
|
@@ -36,46 +16,6 @@ const fetch = async (input, init) => {
|
|
|
36
16
|
throw error;
|
|
37
17
|
}
|
|
38
18
|
};
|
|
39
|
-
async function sign(input, init) {
|
|
40
|
-
const key = process.env.SOFTR_REQUEST_SIGNING_KEY;
|
|
41
|
-
const keyId = process.env.SOFTR_REQUEST_SIGNING_KEY_ID;
|
|
42
|
-
if (!key || !keyId) return void 0;
|
|
43
|
-
assert(/^[0-9a-f]{64}$/i.test(key), "SOFTR_REQUEST_SIGNING_KEY must be 64 hex characters");
|
|
44
|
-
assert(!/["\\]/.test(keyId), "SOFTR_REQUEST_SIGNING_KEY_ID must not contain quotes or backslashes");
|
|
45
|
-
const request = new Request(input, init);
|
|
46
|
-
const headers = new Headers(request.headers);
|
|
47
|
-
const { host, pathname, search } = new URL(request.url);
|
|
48
|
-
const derived = {
|
|
49
|
-
"@method": request.method,
|
|
50
|
-
"@authority": host,
|
|
51
|
-
"@path": pathname,
|
|
52
|
-
"@query": search || "?"
|
|
53
|
-
};
|
|
54
|
-
const fields = Object.keys(derived);
|
|
55
|
-
const body = request.body ? new Uint8Array(await request.arrayBuffer()) : void 0;
|
|
56
|
-
if (body) {
|
|
57
|
-
headers.set("content-digest", `sha-256=:${base64(await crypto.subtle.digest("SHA-256", body))}:`);
|
|
58
|
-
fields.push("content-type", "content-digest");
|
|
59
|
-
}
|
|
60
|
-
if (headers.has("authorization")) fields.push("authorization");
|
|
61
|
-
const created = Math.floor(Date.now() / 1e3);
|
|
62
|
-
const params = `(${fields.map((field) => `"${field}"`).join(" ")});created=${created};keyid="${keyId}";tag="softr-code-app"`;
|
|
63
|
-
const base = [...fields.map((field) => `"${field}": ${derived[field] ?? requireDefined(headers.get(field), field)}`), `"@signature-params": ${params}`].join("\n");
|
|
64
|
-
const hmacKey = await crypto.subtle.importKey("raw", Uint8Array.from(key.match(/../g) ?? [], (byte) => parseInt(byte, 16)), {
|
|
65
|
-
name: "HMAC",
|
|
66
|
-
hash: "SHA-256"
|
|
67
|
-
}, false, ["sign"]);
|
|
68
|
-
const signature = base64(await crypto.subtle.sign("HMAC", hmacKey, new TextEncoder().encode(base)));
|
|
69
|
-
headers.set("signature-input", `softr=${params}`);
|
|
70
|
-
headers.set("signature", `softr=:${signature}:`);
|
|
71
|
-
return new Request(request, {
|
|
72
|
-
headers,
|
|
73
|
-
body
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function base64(bytes) {
|
|
77
|
-
return btoa(String.fromCharCode(...new Uint8Array(bytes)));
|
|
78
|
-
}
|
|
79
19
|
|
|
80
20
|
//#endregion
|
|
81
21
|
export { fetch };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,5 +16,7 @@ import { useOverrides } from "./core/use-overrides.js";
|
|
|
16
16
|
import { useUserTimezone } from "./timezone.js";
|
|
17
17
|
import { PwaInstall, PwaPlatform, SoftrPwaHead, usePwaInstall } from "./pwa.js";
|
|
18
18
|
import { DefaultErrorOverlay } from "./default-error-overlay.js";
|
|
19
|
+
import { Agent, AgentChatSummary, listAgents } from "./agent/agent-fns.js";
|
|
20
|
+
import { AgentBlock, AgentChat, AgentChatOptions, AgentMessage, AgentQuestion, AgentTodo, AgentToolCall, useAgentChat } from "./agent/use-agent-chat.js";
|
|
19
21
|
import { Audience } from "./route/audience.js";
|
|
20
|
-
export { type ActionPermissions, Audience, type AuthOptions, type AuthSettings, AuthSettingsProvider, type DateOptions, type DateParts, type DateSeparator, type DateValue, DefaultErrorOverlay, type FieldShape, type FileAttachment, type FileItem, type FixedDateFormat, FormattedDate, type Formatting, FormattingScope, type Page, type PageSettings, type PwaInstall, type PwaPlatform, type SoftrContext, type SoftrDatasources, type SoftrFieldRegistry, SoftrPwaHead, type SoftrUserGroupId, type SoftrUserGroups, type SoftrUserProperties, type User, type WeekDay, assertRouteAccess, checkAccess, 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, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useOverrides, usePwaInstall, useUserTimezone };
|
|
22
|
+
export { type ActionPermissions, type Agent, type AgentBlock, type AgentChat, type AgentChatOptions, type AgentChatSummary, type AgentMessage, type AgentQuestion, type AgentTodo, type AgentToolCall, Audience, type AuthOptions, type AuthSettings, AuthSettingsProvider, type DateOptions, type DateParts, type DateSeparator, type DateValue, DefaultErrorOverlay, type FieldShape, type FileAttachment, type FileItem, type FixedDateFormat, FormattedDate, type Formatting, FormattingScope, type Page, type PageSettings, type PwaInstall, type PwaPlatform, type SoftrContext, type SoftrDatasources, type SoftrFieldRegistry, SoftrPwaHead, type SoftrUserGroupId, type SoftrUserGroups, type SoftrUserProperties, type User, type WeekDay, assertRouteAccess, checkAccess, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, listAgents, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, toReturnPath, useAgentChat, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useOverrides, usePwaInstall, useUserTimezone };
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ import { fieldShape, formatDuration, formatField, formatValue, registerSoftrFiel
|
|
|
12
12
|
import { useOverrides } from "./core/use-overrides.js";
|
|
13
13
|
import { useUserTimezone } from "./timezone.js";
|
|
14
14
|
import { DefaultErrorOverlay } from "./default-error-overlay.js";
|
|
15
|
+
import { listAgents } from "./agent/agent-fns.js";
|
|
16
|
+
import { useAgentChat } from "./agent/use-agent-chat.js";
|
|
15
17
|
import { Audience } from "./route/audience.js";
|
|
16
18
|
|
|
17
|
-
export { Audience, AuthSettingsProvider, DefaultErrorOverlay, FormattedDate, FormattingScope, SoftrPwaHead, assertRouteAccess, checkAccess, 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, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useOverrides, usePwaInstall, useUserTimezone };
|
|
19
|
+
export { Audience, AuthSettingsProvider, DefaultErrorOverlay, FormattedDate, FormattingScope, SoftrPwaHead, assertRouteAccess, checkAccess, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, listAgents, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, toReturnPath, useAgentChat, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useOverrides, usePwaInstall, useUserTimezone };
|
package/dist/locale-settings.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { logger } from "./logger.js";
|
|
2
|
-
import { softrApiUrl } from "./softr-api.js";
|
|
3
2
|
import { fetch } from "./fetch.js";
|
|
4
3
|
import { readRequestCookies, serializeCookie, writeCookies } from "./cookies.js";
|
|
5
4
|
import { sessionConfig } from "./auth/config.js";
|
|
5
|
+
import { softrApiUrl } from "./softr-api.js";
|
|
6
6
|
import { localeSettingsSchema } from "./formatting.js";
|
|
7
7
|
import { getRequestProtocol } from "@tanstack/react-start/server";
|
|
8
8
|
|
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
|
-
import { softrApiUrl } from "./softr-api.js";
|
|
3
2
|
import { fetch } from "./fetch.js";
|
|
3
|
+
import { softrConfig } from "./softr-config.js";
|
|
4
4
|
import { sessionConfig } from "./auth/config.js";
|
|
5
5
|
import { readSessionToken, withSessionToken } from "./auth/session.js";
|
|
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";
|
|
@@ -385,8 +385,10 @@ async function rpc(request, origin, actions) {
|
|
|
385
385
|
const token = bearerToken(request);
|
|
386
386
|
if (token === null) return unauthorized(origin);
|
|
387
387
|
const session = await platformSession(token);
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
let sessionToken;
|
|
389
|
+
if (session.ok) sessionToken = session.sessionToken;
|
|
390
|
+
else if (session.refused && await resolveUser(token) !== null) sessionToken = token;
|
|
391
|
+
else return session.refused ? unauthorized(origin) : unavailable();
|
|
390
392
|
const body = await readJson(request);
|
|
391
393
|
const message = z.object({
|
|
392
394
|
id: z.union([z.string(), z.number()]).optional(),
|
package/dist/package.js
CHANGED
package/dist/pwa.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logger } from "./logger.js";
|
|
2
|
-
import { softrApiUrl } from "./softr-api.js";
|
|
3
2
|
import { fetch } from "./fetch.js";
|
|
4
3
|
import { sessionConfig } from "./auth/config.js";
|
|
4
|
+
import { softrApiUrl } from "./softr-api.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { Fragment, createElement, useEffect, useState } from "react";
|
|
7
7
|
import { createMiddleware } from "@tanstack/react-start";
|
|
@@ -125,7 +125,7 @@ function usePwaInstall() {
|
|
|
125
125
|
useEffect(() => {
|
|
126
126
|
if (window.matchMedia("(display-mode: standalone)").matches || "standalone" in navigator && navigator.standalone === true) return;
|
|
127
127
|
let cancelled = false;
|
|
128
|
-
|
|
128
|
+
fetch(INSTALL_PATH, { headers: { accept: "application/json" } }).then(async (response) => {
|
|
129
129
|
if (!response.ok) return;
|
|
130
130
|
const parsed = installSchema.safeParse(await response.json());
|
|
131
131
|
if (!parsed.success || cancelled) return;
|
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
|
|
@@ -21,6 +21,7 @@ const AccessBehaviour = z.union([
|
|
|
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
23
|
const AppPath = z.string().refine((path$1) => path$1.startsWith("/") && !path$1.includes("?") && !path$1.includes("#") && new URL(path$1, "https://app.invalid").origin === "https://app.invalid", { error: "must be a path on this app like \"/login\", with no \"?\" or \"#\"" });
|
|
24
|
+
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" });
|
|
24
25
|
const SoftrConfigSchema = z.object({
|
|
25
26
|
auth: z.strictObject({
|
|
26
27
|
routes: z.strictObject({
|
|
@@ -47,7 +48,8 @@ const SoftrConfigSchema = z.object({
|
|
|
47
48
|
alreadyAuthenticated: AccessBehaviour
|
|
48
49
|
})
|
|
49
50
|
}),
|
|
50
|
-
user: z.strictObject({ properties: z.record(z.string(), z.string()) }).optional()
|
|
51
|
+
user: z.strictObject({ properties: z.record(z.string(), z.string()) }).optional(),
|
|
52
|
+
allowEmbedding: z.array(Origin).optional()
|
|
51
53
|
});
|
|
52
54
|
function loadSoftrConfig(root) {
|
|
53
55
|
const file = path.join(root, SOFTR_CONFIG_FILE);
|
package/package.json
CHANGED
package/schema/softr.schema.json
CHANGED
|
@@ -67,6 +67,11 @@
|
|
|
67
67
|
},
|
|
68
68
|
"required": ["properties"],
|
|
69
69
|
"additionalProperties": false
|
|
70
|
+
},
|
|
71
|
+
"allowEmbedding": {
|
|
72
|
+
"type": "array",
|
|
73
|
+
"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.",
|
|
74
|
+
"items": { "type": "string", "pattern": "^(\\*|https://[^/\\\\?#@\\s;,]+)$" }
|
|
70
75
|
}
|
|
71
76
|
},
|
|
72
77
|
"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.89-alpha.0
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
# Softr SDK core
|
|
@@ -17,7 +18,7 @@ metadata:
|
|
|
17
18
|
|
|
18
19
|
> **CRITICAL**: The SDK is split across four entrypoints and the split is enforced. `ds` and `auth` exist only on `@softr/sdk/server` and only run inside a `createServerFn` handler. Importing them anywhere else fails the build.
|
|
19
20
|
>
|
|
20
|
-
> **CRITICAL**: Every route file must declare its
|
|
21
|
+
> **CRITICAL**: Every route file must declare its settings with `definePage`, guard itself with them in `beforeLoad` and render them in `head`. There is no default and nothing is inherited from a sibling.
|
|
21
22
|
>
|
|
22
23
|
> **CRITICAL**: The app is already wired. `src/start.ts`, `src/router.tsx` and `src/routes/__root.tsx` register `softrAuthMiddleware` and resolve the session. Do not add a second registration of it. `softrMcpMiddleware` is the one thing an app adds to `src/start.ts` itself — load the `softr-sdk/mcp` sub-skill before doing so.
|
|
23
24
|
>
|
|
@@ -29,7 +30,7 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
|
|
|
29
30
|
|
|
30
31
|
| Import | Runs | Holds |
|
|
31
32
|
| --- | --- | --- |
|
|
32
|
-
| `@softr/sdk` | Both | `defineQuery`, `defineMutation`, `defineVisibility`, `guardRoute`, `assertRouteAccess`, `isAuthorized`, `checkAccess`, `Audience`, `useCurrentUser`, `useUserTimezone`, `FormattedDate`, `FormattingScope`, `useFormatting`, `formatDate`, `formatDateTime`, `formatNumber`, `formatValue`, `formatField`, `fieldShape`, `registerSoftrFields`, `useOverrides`, `SoftrPwaHead`, `usePwaInstall`, `getSoftrContext`, `initialSoftrContext`, `softrAuthMiddleware`, the error predicates, and every type |
|
|
33
|
+
| `@softr/sdk` | Both | `defineQuery`, `defineMutation`, `definePage`, `pageHead`, `defineVisibility`, `guardRoute`, `assertRouteAccess`, `isAuthorized`, `checkAccess`, `Audience`, `useCurrentUser`, `useUserTimezone`, `FormattedDate`, `FormattingScope`, `useFormatting`, `formatDate`, `formatDateTime`, `formatNumber`, `formatValue`, `formatField`, `fieldShape`, `registerSoftrFields`, `useOverrides`, `SoftrPwaHead`, `usePwaInstall`, `getSoftrContext`, `initialSoftrContext`, `softrAuthMiddleware`, the error predicates, and every type |
|
|
33
34
|
| `@softr/sdk/server` | Server only | `ds`, `auth`, `workflow`, `integration` |
|
|
34
35
|
| `@softr/sdk/client` | Browser only | `useFileUpload` |
|
|
35
36
|
| `@softr/sdk/vite` | Build | `softr()`, already in `vite.config.ts` |
|
|
@@ -48,6 +49,7 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
|
|
|
48
49
|
| Sign a visitor in, out, or up | [auth/SKILL.md](./auth/SKILL.md) |
|
|
49
50
|
| Call a connected third-party API (Slack, Stripe, Gmail, …) | [integrations/SKILL.md](./integrations/SKILL.md) |
|
|
50
51
|
| Open the app to AI assistants over MCP | [mcp/SKILL.md](./mcp/SKILL.md) |
|
|
52
|
+
| Let visitors chat with a Softr agent | [agent-chat/SKILL.md](./agent-chat/SKILL.md) |
|
|
51
53
|
| Let visitors install the app on their home screen | [pwa/SKILL.md](./pwa/SKILL.md) |
|
|
52
54
|
| Show a date, a time or a number | [formatting/SKILL.md](./formatting/SKILL.md) |
|
|
53
55
|
|
|
@@ -84,6 +86,9 @@ Calling a connected third-party API (Slack, Stripe, Gmail, Google Calendar, …)
|
|
|
84
86
|
Opening the app to an AI assistant over MCP?
|
|
85
87
|
load softr-sdk/mcp
|
|
86
88
|
|
|
89
|
+
Adding a chat with one of the app's Softr agents?
|
|
90
|
+
load softr-sdk/agent-chat
|
|
91
|
+
|
|
87
92
|
Adding an install button, or making the app installable?
|
|
88
93
|
load softr-sdk/pwa
|
|
89
94
|
|
|
@@ -148,3 +153,7 @@ type User = {
|
|
|
148
153
|
userGroupIds: Array<SoftrUserGroupId> // the app's own group ids
|
|
149
154
|
}
|
|
150
155
|
```
|
|
156
|
+
|
|
157
|
+
## Embedding the app in another site
|
|
158
|
+
|
|
159
|
+
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.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-chat
|
|
3
|
+
description: >-
|
|
4
|
+
Let visitors chat with one of the app's Softr agents: listAgents() from
|
|
5
|
+
@softr/sdk gives the agents the visitor may use, and useAgentChat(agentId, {
|
|
6
|
+
record }) returns the messages, the reply as it streams, and
|
|
7
|
+
send, stop, approve and reject, with no UI. Build the chat from the app's own
|
|
8
|
+
components. The agent acts on the app's data through the app's MCP, so
|
|
9
|
+
softrMcpMiddleware must list the actions it may use.
|
|
10
|
+
metadata:
|
|
11
|
+
type: sub-skill
|
|
12
|
+
library: softr-sdk
|
|
13
|
+
library_version: 0.0.89-alpha.0
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
**Boundary.** `listAgents` and `useAgentChat` live on `@softr/sdk`. `listAgents` runs in a route loader, `useAgentChat` in a component. Neither needs a route, server function or registration of its own. It chats as the signed-in visitor, or anonymously when no one is signed in.
|
|
17
|
+
|
|
18
|
+
# Agent chat
|
|
19
|
+
|
|
20
|
+
A Softr agent is set up in Studio's Agents tab and attached to the app there. The app gives it a chat. There is no ready-made chat widget: the hook gives the state, and the app draws it with its own components.
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { listAgents, useAgentChat } from '@softr/sdk'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`listAgents()` resolves to the agents this visitor may chat with, `{ id, title, avatar, thumbnail }[]`. Call it in the route's `loader`. An agent hidden from this visitor isn't in the list, so show no chat when it's empty. When there are several, let the visitor pick one, or pick the one the builder named by its `title`. Take the id from the list, never write one by hand.
|
|
29
|
+
|
|
30
|
+
## Core pattern
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
// agentId comes from listAgents() in the route's loader.
|
|
34
|
+
function AgentPanel({ agentId, ticket }: { agentId: string; ticket: Ticket | null }) {
|
|
35
|
+
const chat = useAgentChat(agentId, {
|
|
36
|
+
record: ticket && { id: ticket.id, fields: { Title: ticket.title, Status: ticket.status } },
|
|
37
|
+
})
|
|
38
|
+
const [draft, setDraft] = useState('')
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{chat.messages.map((message) => (
|
|
43
|
+
<Message key={message.id} message={message} onApprove={chat.approve} onReject={chat.reject} />
|
|
44
|
+
))}
|
|
45
|
+
{chat.error && <p role="alert">{chat.error.message}</p>}
|
|
46
|
+
<form onSubmit={(e) => { e.preventDefault(); chat.send(draft); setDraft('') }}>
|
|
47
|
+
<Textarea value={draft} onChange={(e) => setDraft(e.target.value)} />
|
|
48
|
+
{chat.status === 'idle'
|
|
49
|
+
? <Button type="submit">Send</Button>
|
|
50
|
+
: <Button type="button" onClick={chat.stop}>Stop</Button>}
|
|
51
|
+
</form>
|
|
52
|
+
</>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## What the hook returns
|
|
58
|
+
|
|
59
|
+
- `messages`: the whole chat, oldest first. While the agent answers, its reply is the last message and grows as it streams.
|
|
60
|
+
- `status`: `thinking` until the first part of the reply arrives, `replying` until it ends, then `idle`. Show a typing hint while it's `thinking`.
|
|
61
|
+
- `loading`: `true` while a past chat loads. Show a spinner, not the empty-chat greeting.
|
|
62
|
+
- `error`: why the last request failed, or `null`.
|
|
63
|
+
- `send(text)`, `stop()`, `newChat()`.
|
|
64
|
+
- `listChats()` resolves to the visitor's past chats, `{ id, title }[]`, with `title` `null` until the agent names the chat. `openChat(id)` loads one. `chatId` is the open one, `null` for a new chat. The open chat is kept in the browser for each visitor, so the hook reopens it after a remount or a reload.
|
|
65
|
+
- `approve(toolCallId, scope?)` and `reject(toolCallId)` answer a tool waiting for approval. `scope` is `ONCE` (default), `SESSION` for the rest of this chat, or `USER` for always.
|
|
66
|
+
|
|
67
|
+
## Rendering a message
|
|
68
|
+
|
|
69
|
+
Each message has `role` (`user` or `assistant`) and `blocks`, in the order the agent produced them. Render every block type:
|
|
70
|
+
|
|
71
|
+
| Block | Show it as |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| `text` | Markdown text |
|
|
74
|
+
| `tool` | One line: the tool `name` and its `status`. Collapse finished ones. Expanded, show `thought`, `input`, `error` and `durationMs`. |
|
|
75
|
+
| `todo` | A checklist of the agent's plan. It updates in place. |
|
|
76
|
+
| `question` | The questions with their options. One question with a single choice sends its label with `send` on click. Several questions, or `multiSelect`, collect the picks and show a Send button, enabled once each question has one. It sends one line per question, picked labels joined by ", ". |
|
|
77
|
+
| `error` | An error line inside the reply |
|
|
78
|
+
|
|
79
|
+
A `tool` with status `awaiting-approval` blocks the agent until the visitor answers. Show Approve and Reject buttons on it. The agent continues on its own after an approval.
|
|
80
|
+
|
|
81
|
+
A `tool` with status `awaiting-connection` needs the visitor to connect the `integration` first. Code apps can't do that yet. Say which integration the agent needs, and that the builder has to connect it for this agent in Studio.
|
|
82
|
+
|
|
83
|
+
## The chat panel
|
|
84
|
+
|
|
85
|
+
Classic Softr apps ship a chat panel. Visitors expect the same from yours:
|
|
86
|
+
|
|
87
|
+
- A round button in a corner opens it. A right-side panel on desktop, full screen on mobile.
|
|
88
|
+
- The header shows the agent's avatar and name, a picker when there are several agents, new chat, past chats and close.
|
|
89
|
+
- An empty chat greets the visitor with the agent's avatar.
|
|
90
|
+
- The list scrolls to the newest message as the reply streams, until the visitor scrolls up. Then a button takes them back down.
|
|
91
|
+
- Text renders as Markdown, tables included.
|
|
92
|
+
- The input says "Ask {agent title}…". Enter sends. Shift+Enter adds a line.
|
|
93
|
+
- A line under the input: "AI can make mistakes. Please double-check responses."
|
|
94
|
+
- A question with one choice sends on click. One with `multiSelect` or several questions sends once all are answered. An answered question stays locked.
|
|
95
|
+
- Approve offers the three scopes: once, for this chat, always for this agent.
|
|
96
|
+
|
|
97
|
+
## Context
|
|
98
|
+
|
|
99
|
+
`record` is the one record the visitor is looking at, so they can say "close this one". Pass it where a page shows one record, and `null` elsewhere. Use readable field names as keys. The agent reads them as they are.
|
|
100
|
+
|
|
101
|
+
The page title and URL go along on their own. Nothing else about the page does, so don't try to send whole lists.
|
|
102
|
+
|
|
103
|
+
## Letting the agent act on the app
|
|
104
|
+
|
|
105
|
+
The agent reads and changes data through the app's own MCP, as the visitor who is chatting. Their groups and each action's `permissions` apply. The actions it may use are the ones listed in `softrMcpMiddleware`. With no MCP wired, the agent can only talk. Load [mcp/SKILL.md](../mcp/SKILL.md) to wire it.
|
|
106
|
+
|
|
107
|
+
## Failure modes
|
|
108
|
+
|
|
109
|
+
**Building a chat without the hook.** Calling the agents service from the browser fails: only the app's server can sign the request in as the visitor. Use `useAgentChat`.
|
|
110
|
+
|
|
111
|
+
**Rendering only `text` blocks.** A tool waiting for approval never shows, and the agent waits forever. Render every block type.
|
|
112
|
+
|
|
113
|
+
**The hook inside a panel that unmounts when it closes.** Closing it stops a reply that is still coming. Call `useAgentChat` in the component that owns the open state, such as the layout, and pass `chat` into the panel. Keep the selected agent there too, or closing the panel resets it.
|
|
114
|
+
|
|
115
|
+
**An agent id written by hand.** The chat fails on the first message, and an agent hidden from the visitor still shows. Take the id from `listAgents`.
|
|
116
|
+
|
|
117
|
+
**Expecting the agent to change data with no MCP wired.** It answers but can't act. List the actions it needs in `softrMcpMiddleware`.
|
|
118
|
+
|
|
119
|
+
## References
|
|
120
|
+
|
|
121
|
+
- [mcp/SKILL.md](../mcp/SKILL.md): the actions the agent may call
|
|
122
|
+
- [current-user/SKILL.md](../current-user/SKILL.md): showing the chat to signed-in visitors only
|
|
@@ -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.89-alpha.0
|
|
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.89-alpha.0
|
|
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.
|
|
@@ -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.89-alpha.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
# The current user
|
|
@@ -55,12 +55,16 @@ It returns `User | null` and never suspends or fetches. It selects off root rout
|
|
|
55
55
|
|
|
56
56
|
```tsx
|
|
57
57
|
export const Route = createFileRoute('/_app/invoices')({
|
|
58
|
-
beforeLoad: guardRoute(
|
|
59
|
-
loader: (
|
|
58
|
+
beforeLoad: guardRoute(pageSettings),
|
|
59
|
+
loader: (opts) => {
|
|
60
|
+
assertRouteAccess(pageSettings, opts)
|
|
61
|
+
return fetchInvoicesFor({ data: { userId: opts.context.user.id } })
|
|
62
|
+
},
|
|
63
|
+
head: pageHead(pageSettings),
|
|
60
64
|
})
|
|
61
65
|
```
|
|
62
66
|
|
|
63
|
-
A `guardRoute` in `beforeLoad` guarantees a visitor at runtime, but it does not change what the compiler sees. `context.user` is still `User | null`
|
|
67
|
+
A `guardRoute` in `beforeLoad` guarantees a visitor at runtime, but it does not change what the compiler sees. `context.user` is still `User | null` in the loader. `assertRouteAccess(pageSettings, opts)` at the top of the loader narrows it there, so prefer that over `!`. Take `opts` whole: a destructured `context` does not narrow. See [routes-and-visibility](../routes-and-visibility/SKILL.md).
|
|
64
68
|
|
|
65
69
|
### In a server function: `context`
|
|
66
70
|
|
|
@@ -94,7 +98,7 @@ For every group's name and id, read `docs/user-groups.md`. It lists every group
|
|
|
94
98
|
|
|
95
99
|
## References
|
|
96
100
|
|
|
97
|
-
- [routes-and-visibility/SKILL.md](../routes-and-visibility/SKILL.md): `
|
|
101
|
+
- [routes-and-visibility/SKILL.md](../routes-and-visibility/SKILL.md): `assertRouteAccess` narrows `context.user` while applying the route's rule
|
|
98
102
|
- [region-visibility/SKILL.md](../region-visibility/SKILL.md): rendering a region only to the visitors a rule admits
|
|
99
103
|
- [record-queries/SKILL.md](../record-queries/SKILL.md): filtering a query by the visitor, and who really authorizes the read
|
|
100
104
|
- [auth/SKILL.md](../auth/SKILL.md): what changes the value `useCurrentUser` returns
|
|
@@ -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.89-alpha.0
|
|
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.89-alpha.0
|
|
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.89-alpha.0
|
|
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.89-alpha.0
|
|
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.89-alpha.0
|
|
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.
|
|
@@ -53,7 +53,7 @@ const publishedPosts = defineQuery({
|
|
|
53
53
|
- `{ userGroupTypes: ['NON_LOGGED_IN_USERS', 'LOGGED_IN_USERS'] }`: everyone, signed out included. `customGroups` narrows only the signed-in half.
|
|
54
54
|
- `{ userGroupTypes: ['NON_LOGGED_IN_USERS'] }`: signed-out visitors only.
|
|
55
55
|
- `{ userGroupTypes: ['LOGGED_IN_USERS'] }`: any signed-in visitor, narrowed to particular groups with `customGroups: ['00000000-0000-0000-0000-00000000000a']`. `customGroups` is added to `userGroupTypes`, never written in place of it.
|
|
56
|
-
- Write each group id as a literal in `permissions`. An id taken from a `const` is a lint error
|
|
56
|
+
- Write each group id as a literal in `permissions`. An id taken from a `const` is a lint error.
|
|
57
57
|
- Write the object inline in the `defineQuery` call. Passing the declaration or its `fields` through a variable, or spreading one in, widens the field ids to `string` and the types stop checking.
|
|
58
58
|
|
|
59
59
|
A query fixes the table and the columns, not the rows: filters, sorting and paging stay at the call site, because a list screen changes them as the user types. Declare as many queries over one datasource as the app needs, each carrying the fields its own screen touches.
|