@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.
- package/dist/auth/platform.js +1 -0
- package/dist/codegen/fetch-metadata.js +1 -0
- package/dist/core/integration.js +1 -0
- package/dist/core/workflow.js +1 -0
- package/dist/datasource/chart.js +1 -0
- package/dist/datasource/record.js +1 -0
- package/dist/fetch.js +21 -0
- package/dist/logger.js +15 -0
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +1 -1
- 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/integrations/SKILL.md +4 -4
- package/skills/softr-sdk/record-mutations/SKILL.md +1 -1
- package/skills/softr-sdk/record-queries/SKILL.md +1 -1
- package/skills/softr-sdk/routes-and-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/workflows/SKILL.md +6 -5
package/dist/auth/platform.js
CHANGED
package/dist/core/integration.js
CHANGED
package/dist/core/workflow.js
CHANGED
package/dist/datasource/chart.js
CHANGED
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
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ description: >-
|
|
|
16
16
|
metadata:
|
|
17
17
|
type: sub-skill
|
|
18
18
|
library: softr-sdk
|
|
19
|
-
library_version: 0.0.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
8
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
5
|
-
declares the action with its workflowId, triggerId, permissions,
|
|
6
|
-
hardcoded body; workflow.trigger from @softr/sdk/server fires it
|
|
7
|
-
flat runtime payload and resolves to void when the workflow
|
|
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.
|
|
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.
|