@softr/sdk 0.0.31 → 0.0.32

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,3 +1,4 @@
1
+ import { fetch } from "../fetch.js";
1
2
  import { panic } from "../assertions.js";
2
3
  import { sessionConfig } from "./config.js";
3
4
  import { userSchema } from "./user.js";
@@ -1,3 +1,4 @@
1
+ import { fetch } from "../fetch.js";
1
2
  import { panic } from "../assertions.js";
2
3
 
3
4
  //#region src/codegen/fetch-metadata.ts
@@ -1,3 +1,4 @@
1
+ import { fetch } from "../fetch.js";
1
2
  import { readSessionToken } from "../auth/session.js";
2
3
  import { dsUrl } from "../datasource/record.js";
3
4
 
@@ -1,3 +1,4 @@
1
+ import { fetch } from "../fetch.js";
1
2
  import { sessionConfig } from "../auth/config.js";
2
3
  import { platformApiUrl } from "../auth/platform.js";
3
4
  import { readSessionToken } from "../auth/session.js";
@@ -1,3 +1,4 @@
1
+ import { fetch } from "../fetch.js";
1
2
  import { assert, panic } from "../assertions.js";
2
3
  import { readUserTimezone } from "../cookies.js";
3
4
  import { readSessionToken } from "../auth/session.js";
@@ -1,3 +1,4 @@
1
+ import { fetch } from "../fetch.js";
1
2
  import { assert, panic } from "../assertions.js";
2
3
  import { isDatasourceAction } from "../action.js";
3
4
  import { readUserTimezone } from "../cookies.js";
package/dist/fetch.js ADDED
@@ -0,0 +1,21 @@
1
+ import { logger } from "./logger.js";
2
+
3
+ //#region src/fetch.ts
4
+ const fetch = async (input, init) => {
5
+ if (process.env.NODE_ENV === "production") return globalThis.fetch(input, init);
6
+ const url = input instanceof Request ? input.url : String(input);
7
+ const method = init?.method ?? (input instanceof Request ? input.method : "GET");
8
+ const started = Date.now();
9
+ try {
10
+ const response = await globalThis.fetch(input, init);
11
+ logger.info(`${method} ${response.status} ${url} ${Date.now() - started}ms`);
12
+ return response;
13
+ } catch (error) {
14
+ const label = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
15
+ logger.info(`${method} ERR ${url} ${label} in ${Date.now() - started}ms`);
16
+ throw error;
17
+ }
18
+ };
19
+
20
+ //#endregion
21
+ export { fetch };
package/dist/logger.js ADDED
@@ -0,0 +1,15 @@
1
+ //#region src/logger.ts
2
+ const PREFIX = "[@softr/sdk]";
3
+ function emit(method, args) {
4
+ if (process.env.NODE_ENV === "production") return;
5
+ console[method](PREFIX, ...args);
6
+ }
7
+ const logger = {
8
+ info: (...args) => emit("info", args),
9
+ log: (...args) => emit("log", args),
10
+ warn: (...args) => emit("warn", args),
11
+ error: (...args) => emit("error", args)
12
+ };
13
+
14
+ //#endregion
15
+ export { logger };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.31";
2
+ var version = "0.0.32";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
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.31
14
+ library_version: 0.0.32
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.31
19
+ library_version: 0.0.32
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. `defineVisibility`, the hooks and every type come from `@softr/sdk`. The app is already wired (`src/start.ts`, `src/router.tsx`, `src/routes/__root.tsx`); never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
@@ -12,7 +12,7 @@ description: >-
12
12
  metadata:
13
13
  type: sub-skill
14
14
  library: softr-sdk
15
- library_version: 0.0.31
15
+ library_version: 0.0.32
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. The app is already wired (`src/start.ts`, `src/router.tsx`, `src/routes/__root.tsx`); never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.31
13
+ library_version: 0.0.32
14
14
  ---
15
15
 
16
16
  **Boundary.** `useCurrentUser`, `usePermissions` and every type come from `@softr/sdk` and work anywhere; `ds` and `auth` live on `@softr/sdk/server` and run only inside a `createServerFn` handler. The app is already wired — `src/start.ts` registers `softrAuthMiddleware`, `src/routes/__root.tsx` publishes the visitor as route context — never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
@@ -3,13 +3,13 @@ name: integrations
3
3
  description: >-
4
4
  Call a third-party service connected to the app as an integration:
5
5
  defineIntegration from @softr/sdk declares the action with its datasourceId
6
- and permissions; integration.createFetcher from @softr/sdk/server binds it
7
- and returns a fetcher function you call with url, optional method, headers,
8
- and body. Check res.ok before res.json().
6
+ and permissions; integration.createFetcher from @softr/sdk/server binds it and
7
+ returns a fetcher function you call with url, optional method, headers, and
8
+ body. Check res.ok before res.json().
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.31
12
+ library_version: 0.0.32
13
13
  ---
14
14
 
15
15
  **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. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: sub-skill
13
13
  library: softr-sdk
14
- library_version: 0.0.31
14
+ library_version: 0.0.32
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. The app is already wired (`src/start.ts`, `src/router.tsx`, `src/routes/__root.tsx`); never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
@@ -12,7 +12,7 @@ description: >-
12
12
  metadata:
13
13
  type: sub-skill
14
14
  library: softr-sdk
15
- library_version: 0.0.31
15
+ library_version: 0.0.32
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. The app is already wired (`src/start.ts`, `src/router.tsx`, `src/routes/__root.tsx`); never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
@@ -12,7 +12,7 @@ description: >-
12
12
  metadata:
13
13
  type: sub-skill
14
14
  library: softr-sdk
15
- library_version: 0.0.31
15
+ library_version: 0.0.32
16
16
  ---
17
17
 
18
18
  **Boundary.** `defineVisibility`, the error predicates and every type come from `@softr/sdk` and work anywhere; `ds` and `auth` live on `@softr/sdk/server` and run only inside a `createServerFn` handler. The app is already wired — `src/start.ts` registers `softrAuthMiddleware`, `src/routes/__root.tsx` publishes the visitor as route context — never add a second registration. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.
@@ -1,14 +1,15 @@
1
1
  ---
2
2
  name: workflows
3
3
  description: >-
4
- Trigger a Softr workflow from a server function: defineWorkflow from @softr/sdk
5
- declares the action with its workflowId, triggerId, permissions, and optional
6
- hardcoded body; workflow.trigger from @softr/sdk/server fires it with an optional
7
- flat runtime payload and resolves to void when the workflow finishes.
4
+ Trigger a Softr workflow from a server function: defineWorkflow from
5
+ @softr/sdk declares the action with its workflowId, triggerId, permissions,
6
+ and optional hardcoded body; workflow.trigger from @softr/sdk/server fires it
7
+ with an optional flat runtime payload and resolves to void when the workflow
8
+ finishes.
8
9
  metadata:
9
10
  type: sub-skill
10
11
  library: softr-sdk
11
- library_version: 0.0.31
12
+ library_version: 0.0.32
12
13
  ---
13
14
 
14
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. Load the core `softr-sdk` skill only if you are unsure this is the right sub-skill.