@softr/sdk 0.0.62-alpha.0 → 0.0.63-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.
@@ -1,6 +1,6 @@
1
1
  import { fetch } from "../fetch.js";
2
2
  import { readSessionToken } from "../auth/session.js";
3
- import { dsUrl } from "../datasource/record.js";
3
+ import { dsUrl, refererHeader } from "../datasource/record.js";
4
4
 
5
5
  //#region src/core/integration.ts
6
6
  async function integrationFetch(action, { params, query, headers = {}, body, signal } = {}) {
@@ -15,7 +15,8 @@ async function integrationFetch(action, { params, query, headers = {}, body, sig
15
15
  method: "POST",
16
16
  headers: {
17
17
  "Content-Type": "application/json",
18
- "Authorization": `Bearer ${readSessionToken()}`
18
+ "Authorization": `Bearer ${readSessionToken()}`,
19
+ ...refererHeader()
19
20
  },
20
21
  body: JSON.stringify(payload),
21
22
  signal
@@ -4,7 +4,7 @@ import { readUserTimezone } from "../cookies.js";
4
4
  import { readSessionToken } from "../auth/session.js";
5
5
  import { INTERNAL_KIND, buildFilterCriteria, buildOrderBy, dealiasFilterCriteria } from "./filter.js";
6
6
  import { andAll, makeFieldSet, makeSortSet } from "./fields.js";
7
- import { describeFailure, dsUrl, resolveTarget } from "./record.js";
7
+ import { describeFailure, dsUrl, refererHeader, resolveTarget } from "./record.js";
8
8
 
9
9
  //#region src/datasource/chart.ts
10
10
  const COUNT_CNT = "COUNT_CNT";
@@ -198,7 +198,8 @@ async function executeChart(query, state) {
198
198
  headers: {
199
199
  "Content-Type": "application/json",
200
200
  "X-User-Timezone": readUserTimezone() ?? "UTC",
201
- Authorization: `Bearer ${readSessionToken()}`
201
+ Authorization: `Bearer ${readSessionToken()}`,
202
+ ...refererHeader()
202
203
  },
203
204
  body: JSON.stringify(body)
204
205
  });
@@ -271,7 +272,8 @@ async function executeMetric(query, handle, filters) {
271
272
  headers: {
272
273
  "Content-Type": "application/json",
273
274
  "X-User-Timezone": readUserTimezone() ?? "UTC",
274
- Authorization: `Bearer ${readSessionToken()}`
275
+ Authorization: `Bearer ${readSessionToken()}`,
276
+ ...refererHeader()
275
277
  },
276
278
  body: JSON.stringify(body)
277
279
  });
@@ -5,6 +5,7 @@ import { readSessionToken } from "../auth/session.js";
5
5
  import { isDatasourceAction } from "../action.js";
6
6
  import { buildFilterCriteria, buildOrderBy, dealiasFilterCriteria, dealiasOrderBy } from "./filter.js";
7
7
  import { andAll, makeFieldSet, makeSortSet } from "./fields.js";
8
+ import { getRequestHeader } from "@tanstack/react-start/server";
8
9
 
9
10
  //#region src/datasource/record.ts
10
11
  const MAX_RECORD_COUNT = 100;
@@ -15,6 +16,15 @@ const dsUrl = (actionId) => {
15
16
  if (!applicationId) panic("SOFTR_APPLICATION_ID is not set.");
16
17
  return `${withoutTrailingSlash(datasourceApiUrl)}/v1/datasource/vibe/applications/${applicationId}/actions/${actionId}`;
17
18
  };
19
+ /**
20
+ * The datasource API wants to know which page made the call.
21
+ * The browser sends that page to the app server, so we pass it on.
22
+ * Without an incoming Referer, we send none.
23
+ */
24
+ function refererHeader() {
25
+ const referer = getRequestHeader("referer");
26
+ return referer ? { Referer: referer } : {};
27
+ }
18
28
  async function describeFailure(res) {
19
29
  const body = await res.json().catch(() => null);
20
30
  const message = typeof body === "object" && body !== null && "message" in body ? body.message : null;
@@ -80,7 +90,8 @@ async function executeList(query, args) {
80
90
  headers: {
81
91
  "Content-Type": "application/json",
82
92
  "X-User-Timezone": readUserTimezone() ?? "UTC",
83
- Authorization: `Bearer ${readSessionToken()}`
93
+ Authorization: `Bearer ${readSessionToken()}`,
94
+ ...refererHeader()
84
95
  },
85
96
  body: JSON.stringify({
86
97
  options: { userLocale: "en-US" },
@@ -151,7 +162,8 @@ async function executeGet(query, id, filters) {
151
162
  headers: {
152
163
  "Content-Type": "application/json",
153
164
  "X-User-Timezone": readUserTimezone() ?? "UTC",
154
- Authorization: `Bearer ${readSessionToken()}`
165
+ Authorization: `Bearer ${readSessionToken()}`,
166
+ ...refererHeader()
155
167
  },
156
168
  body: JSON.stringify({
157
169
  options: { userLocale: "en-US" },
@@ -183,7 +195,8 @@ async function createRecord(action, options) {
183
195
  method: "POST",
184
196
  headers: {
185
197
  "Content-Type": "application/json",
186
- Authorization: `Bearer ${readSessionToken()}`
198
+ Authorization: `Bearer ${readSessionToken()}`,
199
+ ...refererHeader()
187
200
  },
188
201
  body: JSON.stringify({ fields: rawFields })
189
202
  });
@@ -212,7 +225,8 @@ async function updateRecord(action, options) {
212
225
  method: "PATCH",
213
226
  headers: {
214
227
  "Content-Type": "application/json",
215
- Authorization: `Bearer ${readSessionToken()}`
228
+ Authorization: `Bearer ${readSessionToken()}`,
229
+ ...refererHeader()
216
230
  },
217
231
  body: JSON.stringify({ fields: rawFields })
218
232
  });
@@ -233,7 +247,10 @@ async function deleteRecord(action, options) {
233
247
  const { actionId } = resolveTarget(action, "delete");
234
248
  const res = await fetch(`${dsUrl(actionId)}/records/${options.id}`, {
235
249
  method: "DELETE",
236
- headers: { Authorization: `Bearer ${readSessionToken()}` }
250
+ headers: {
251
+ Authorization: `Bearer ${readSessionToken()}`,
252
+ ...refererHeader()
253
+ }
237
254
  });
238
255
  if (!res.ok) throw new Error(`datasource delete failed for action "${actionId}": ${await describeFailure(res)}`);
239
256
  }
@@ -262,4 +279,4 @@ function withoutTrailingSlash(url) {
262
279
  }
263
280
 
264
281
  //#endregion
265
- export { createRecord, deleteRecord, describeFailure, dsUrl, getRecord, listRecords, resolveTarget, updateRecord };
282
+ export { createRecord, deleteRecord, describeFailure, dsUrl, getRecord, listRecords, refererHeader, resolveTarget, updateRecord };
@@ -1,4 +1,4 @@
1
- import * as react3 from "react";
1
+ import * as react5 from "react";
2
2
 
3
3
  //#region src/default-error-overlay.d.ts
4
4
  type Props = {
@@ -8,6 +8,6 @@ type Props = {
8
8
  declare function DefaultErrorOverlay({
9
9
  error,
10
10
  reset
11
- }: Props): react3.JSX.Element;
11
+ }: Props): react5.JSX.Element;
12
12
  //#endregion
13
13
  export { DefaultErrorOverlay };
@@ -1,4 +1,4 @@
1
- import * as react0 from "react";
1
+ import * as react1 from "react";
2
2
  import { ReactNode } from "react";
3
3
  import { z } from "zod";
4
4
 
@@ -94,7 +94,7 @@ declare function FormattingScope({
94
94
  /** A BCP 47 locale, such as `de-DE`. It drops the app's fixed date format inside the scope. */
95
95
  locale?: string;
96
96
  children?: ReactNode;
97
- }): react0.FunctionComponentElement<react0.ProviderProps<Scope>>;
97
+ }): react1.FunctionComponentElement<react1.ProviderProps<Scope>>;
98
98
  /**
99
99
  * A date in the app's format, safe to render on the server. A timestamp whose
100
100
  * zone is not known yet renders `fallback` until the browser supplies it, so
@@ -115,6 +115,6 @@ declare function FormattedDate({
115
115
  time?: boolean;
116
116
  /** What renders while the visitor's zone is unknown. */
117
117
  fallback?: ReactNode;
118
- }): react0.FunctionComponentElement<react0.FragmentProps>;
118
+ }): react1.FunctionComponentElement<react1.FragmentProps>;
119
119
  //#endregion
120
120
  export { DateOptions, DateParts, DateSeparator, DateValue, FixedDateFormat, FormattedDate, Formatting, FormattingScope, WeekDay, formatDate, formatDateTime, formatNumber, useFormatting };
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DatasourceAction } from "./action.js";
2
- import * as _tanstack_react_start0 from "@tanstack/react-start";
2
+ import * as _tanstack_react_start3 from "@tanstack/react-start";
3
3
 
4
4
  //#region src/mcp.d.ts
5
5
 
@@ -37,6 +37,6 @@ type SoftrMcpOptions = {
37
37
  * ],
38
38
  * }))
39
39
  */
40
- declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>;
40
+ declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start3.RequestMiddlewareAfterServer<{}, undefined, undefined>;
41
41
  //#endregion
42
42
  export { softrMcpMiddleware };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.62-alpha.0";
2
+ var version = "0.0.63-alpha.0";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/dist/pwa.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as react4 from "react";
1
+ import * as react0 from "react";
2
2
  import "@tanstack/react-start";
3
3
 
4
4
  //#region src/pwa.d.ts
@@ -23,7 +23,7 @@ import "@tanstack/react-start";
23
23
  * )
24
24
  * }
25
25
  */
26
- declare function SoftrPwaHead(): react4.FunctionComponentElement<react4.FragmentProps>;
26
+ declare function SoftrPwaHead(): react0.FunctionComponentElement<react0.FragmentProps>;
27
27
  type PwaPlatform = "ios" | "android" | "desktop";
28
28
  type PwaInstall = {
29
29
  available: false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "0.0.62-alpha.0",
3
+ "version": "0.0.63-alpha.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: core
13
13
  library: softr-sdk
14
- library_version: 0.0.62-alpha.0
14
+ library_version: 0.0.63-alpha.0
15
15
  ---
16
16
 
17
17
  # Softr SDK core
@@ -16,7 +16,7 @@ description: >-
16
16
  metadata:
17
17
  type: sub-skill
18
18
  library: softr-sdk
19
- library_version: 0.0.62-alpha.0
19
+ library_version: 0.0.63-alpha.0
20
20
  ---
21
21
 
22
22
  **Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
@@ -12,7 +12,7 @@ description: >-
12
12
  metadata:
13
13
  type: sub-skill
14
14
  library: softr-sdk
15
- library_version: 0.0.62-alpha.0
15
+ library_version: 0.0.63-alpha.0
16
16
  ---
17
17
 
18
18
  **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.
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: sub-skill
13
13
  library: softr-sdk
14
- library_version: 0.0.62-alpha.0
14
+ library_version: 0.0.63-alpha.0
15
15
  ---
16
16
 
17
17
  **Boundary.** `comments` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler. Importing it into a component fails the build. `useCommentComposer` lives on `@softr/sdk/client` and runs in components. `defineComments` comes 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.62-alpha.0
12
+ library_version: 0.0.63-alpha.0
13
13
  ---
14
14
 
15
15
  # The current user
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.62-alpha.0
13
+ library_version: 0.0.63-alpha.0
14
14
  ---
15
15
 
16
16
  **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.
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.62-alpha.0
13
+ library_version: 0.0.63-alpha.0
14
14
  ---
15
15
 
16
16
  # Dates, times and numbers
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.62-alpha.0
13
+ library_version: 0.0.63-alpha.0
14
14
  ---
15
15
 
16
16
  **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.62-alpha.0
12
+ library_version: 0.0.63-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.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.62-alpha.0
12
+ library_version: 0.0.63-alpha.0
13
13
  ---
14
14
 
15
15
  # Installing the app
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: sub-skill
13
13
  library: softr-sdk
14
- library_version: 0.0.62-alpha.0
14
+ library_version: 0.0.63-alpha.0
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. `defineMutation` and every type come from `@softr/sdk` and can be imported anywhere.
@@ -13,7 +13,7 @@ description: >-
13
13
  metadata:
14
14
  type: sub-skill
15
15
  library: softr-sdk
16
- library_version: 0.0.62-alpha.0
16
+ library_version: 0.0.63-alpha.0
17
17
  ---
18
18
 
19
19
  **Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. The same holds for any helper that calls `ds`: declare it inside the handler. A function at module level that calls `ds` keeps the server-only import in the browser bundle, and every page stops loading until it moves. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.62-alpha.0
12
+ library_version: 0.0.63-alpha.0
13
13
  ---
14
14
 
15
15
  **Boundary.** `Audience` and `defineVisibility` come from `@softr/sdk` and work anywhere.
@@ -13,7 +13,7 @@ description: >-
13
13
  metadata:
14
14
  type: sub-skill
15
15
  library: softr-sdk
16
- library_version: 0.0.62-alpha.0
16
+ library_version: 0.0.63-alpha.0
17
17
  ---
18
18
 
19
19
  **Boundary.** `defineVisibility`, 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: 0.0.62-alpha.0
12
+ library_version: 0.0.63-alpha.0
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.