@softr/sdk 0.0.90-alpha.5 → 0.0.90-alpha.7
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 +215 -0
- package/dist/agent/use-agent-chat.d.ts +106 -0
- package/dist/agent/use-agent-chat.js +486 -0
- package/dist/auth/isomorphic.d.ts +3 -3
- package/dist/auth/isomorphic.js +0 -2
- package/dist/auth/server.js +1 -1
- package/dist/datasource/record.js +12 -3
- package/dist/formatting.d.ts +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/mcp.d.ts +17 -4
- package/dist/mcp.js +61 -18
- package/dist/package.js +1 -1
- package/dist/pwa.d.ts +2 -2
- package/package.json +35 -12
- package/skills/softr-sdk/SKILL.md +5 -1
- package/skills/softr-sdk/agent-chat/SKILL.md +110 -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 +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 +16 -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 +4 -4
- package/skills/softr-sdk/workflows/SKILL.md +1 -1
- package/dist/app-identity.js +0 -77
package/dist/app-identity.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { version } from "./package.js";
|
|
2
|
-
import { assert } from "./assertions.js";
|
|
3
|
-
import { createMiddleware } from "@tanstack/react-start";
|
|
4
|
-
import * as startServer from "@tanstack/react-start/server";
|
|
5
|
-
|
|
6
|
-
//#region src/app-identity.ts
|
|
7
|
-
const HTML_TAG = new TextEncoder().encode("<html");
|
|
8
|
-
const HTML_TAG_SEARCH_LIMIT = 1024;
|
|
9
|
-
/**
|
|
10
|
-
* Marks every HTML page with the Softr app it belongs to and the SDK version it
|
|
11
|
-
* runs on, so support can read both from the page source.
|
|
12
|
-
*
|
|
13
|
-
* They go on `<html>` as `data-appid` and `data-sdk-version`, and
|
|
14
|
-
* in a comment just before it. React keeps the attributes when it hydrates, but
|
|
15
|
-
* drops them if it ever renders the document again on the client. The comment
|
|
16
|
-
* sits outside what React owns, so it always stays.
|
|
17
|
-
*/
|
|
18
|
-
function appIdentityMiddleware() {
|
|
19
|
-
return createMiddleware({ type: "request" }).server(async ({ next }) => {
|
|
20
|
-
const result = await next();
|
|
21
|
-
const { response } = result;
|
|
22
|
-
if (!response.body || !response.headers.get("content-type")?.startsWith("text/html")) return result;
|
|
23
|
-
const applicationId = process.env.SOFTR_APPLICATION_ID;
|
|
24
|
-
if (!applicationId) return result;
|
|
25
|
-
assert(/^[\w-]+$/.test(applicationId), `SOFTR_APPLICATION_ID is not an id: "${applicationId}"`);
|
|
26
|
-
const encoder = new TextEncoder();
|
|
27
|
-
const comment = encoder.encode(`<!-- Softr app ${applicationId}, @softr/sdk ${version} -->`);
|
|
28
|
-
const attributes = encoder.encode(` data-appid="${applicationId}" data-sdk-version="${version}"`);
|
|
29
|
-
let held = new Uint8Array(0);
|
|
30
|
-
let done = false;
|
|
31
|
-
const body = response.body.pipeThrough(new TransformStream({
|
|
32
|
-
transform(chunk, controller) {
|
|
33
|
-
if (done) {
|
|
34
|
-
controller.enqueue(chunk);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const bytes = new Uint8Array(held.length + chunk.length);
|
|
38
|
-
bytes.set(held);
|
|
39
|
-
bytes.set(chunk, held.length);
|
|
40
|
-
let at = -1;
|
|
41
|
-
search: for (let i = 0; i + HTML_TAG.length < bytes.length; i++) {
|
|
42
|
-
for (let j = 0; j < HTML_TAG.length; j++) if (bytes[i + j] !== HTML_TAG[j]) continue search;
|
|
43
|
-
const after = bytes[i + HTML_TAG.length];
|
|
44
|
-
if (after === 32 || after === 62) {
|
|
45
|
-
at = i;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (at === -1) {
|
|
50
|
-
if (bytes.length > HTML_TAG_SEARCH_LIMIT) {
|
|
51
|
-
done = true;
|
|
52
|
-
controller.enqueue(bytes);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
held = bytes;
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
done = true;
|
|
59
|
-
const end = at + HTML_TAG.length;
|
|
60
|
-
controller.enqueue(bytes.subarray(0, at));
|
|
61
|
-
controller.enqueue(comment);
|
|
62
|
-
controller.enqueue(bytes.subarray(at, end));
|
|
63
|
-
controller.enqueue(attributes);
|
|
64
|
-
controller.enqueue(bytes.subarray(end));
|
|
65
|
-
},
|
|
66
|
-
flush(controller) {
|
|
67
|
-
if (!done) controller.enqueue(held);
|
|
68
|
-
}
|
|
69
|
-
}));
|
|
70
|
-
const marked = new Response(body, response);
|
|
71
|
-
marked.headers.delete("content-length");
|
|
72
|
-
return "transferResponseBodyOwnership" in startServer ? startServer.transferResponseBodyOwnership(response, marked) : marked;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
export { appIdentityMiddleware };
|