@softr/sdk 1.3.1 → 1.4.0-se22529.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/CHANGELOG.md +6 -0
- package/dist/cli.js +5 -1
- package/dist/codegen/fetch-metadata.js +33 -13
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +1 -1
- package/skills/softr-sdk/ai/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/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/push-notifications/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 +1 -1
- package/skills/softr-sdk/region-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/routes-and-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/workflows/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @softr/sdk
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- `softr-sdk generate` no longer fails when a registered datasource's table no longer exists. It leaves that datasource out of `softr-env.d.ts` and the docs, and lists it under `datasourcesWithoutTable` in the `--json` report. Action: remove such a datasource from the app, or point it at another table.
|
|
8
|
+
|
|
3
9
|
## 1.3.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli.js
CHANGED
|
@@ -23,7 +23,10 @@ async function generate({ json }) {
|
|
|
23
23
|
if (json) console.info = console.error;
|
|
24
24
|
const input = await fetchSoftrEnvInput(metadataSourceFromEnv(), loadSoftrConfig(process.cwd()).user?.properties ?? {});
|
|
25
25
|
writeFileSync(path.resolve(process.cwd(), OUTPUT), renderSoftrEnv(input, version), "utf8");
|
|
26
|
-
const report =
|
|
26
|
+
const report = {
|
|
27
|
+
...writeDocs(input),
|
|
28
|
+
datasourcesWithoutTable: input.datasourcesWithoutTable
|
|
29
|
+
};
|
|
27
30
|
report.docs.push({
|
|
28
31
|
subject: "field shapes",
|
|
29
32
|
path: FIELDS_OUTPUT,
|
|
@@ -74,6 +77,7 @@ function printReport(report) {
|
|
|
74
77
|
console.log(`[softr] ${state} ${doc.path} for ${doc.subject}`);
|
|
75
78
|
}
|
|
76
79
|
for (const datasource of report.datasources) console.log(`[softr] wrote ${datasource.doc} for ${datasource.name} (${datasource.id})`);
|
|
80
|
+
for (const datasource of report.datasourcesWithoutTable) console.log(`[softr] left out ${datasource.name} (${datasource.id}): its table no longer exists`);
|
|
77
81
|
}
|
|
78
82
|
const { positionals, values } = parseArgs({
|
|
79
83
|
allowPositionals: true,
|
|
@@ -21,15 +21,21 @@ function metadataSourceFromEnv(env = process.env) {
|
|
|
21
21
|
async function fetchSoftrEnvInput(source, aliases) {
|
|
22
22
|
const { studioApiUrl, datasourceApiUrl, applicationId, token } = source;
|
|
23
23
|
const [registered, userGroups] = await Promise.all([apiFetch(`${studioApiUrl}/v1/applications/${applicationId}/datasources`, token), apiFetch(`${studioApiUrl}/v1/applications/${applicationId}/access-control/user-groups`, token)]);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
const fetched = await Promise.all(registered.map(async ({ name, datasource }) => ({
|
|
25
|
+
id: datasource.id,
|
|
26
|
+
name,
|
|
27
|
+
metadata: await fetchMetadata(`${datasourceApiUrl}/v1/datasource/vibe/studio/applications/${applicationId}/datasources/${datasource.id}/metadata`, token)
|
|
28
|
+
})));
|
|
29
|
+
const datasources = fetched.flatMap(({ id, name, metadata }) => metadata === null ? [] : [{
|
|
30
|
+
...metadata,
|
|
31
|
+
id,
|
|
32
|
+
tableId: metadata.id,
|
|
33
|
+
name
|
|
34
|
+
}]);
|
|
35
|
+
const datasourcesWithoutTable = fetched.flatMap(({ id, name, metadata }) => metadata === null ? [{
|
|
36
|
+
id,
|
|
37
|
+
name
|
|
38
|
+
}] : []);
|
|
33
39
|
let users = null;
|
|
34
40
|
if (Object.keys(aliases).length > 0) {
|
|
35
41
|
const metadata = await apiFetch(`${datasourceApiUrl}/v1/datasource/vibe/studio/applications/${applicationId}/user-connection/metadata`, token);
|
|
@@ -46,16 +52,30 @@ async function fetchSoftrEnvInput(source, aliases) {
|
|
|
46
52
|
return {
|
|
47
53
|
datasources,
|
|
48
54
|
userGroups,
|
|
49
|
-
users
|
|
55
|
+
users,
|
|
56
|
+
datasourcesWithoutTable
|
|
50
57
|
};
|
|
51
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Null when the datasource API answers 404: the registration points at a table that no longer
|
|
61
|
+
* exists. One such registration must not stop the types of every other one.
|
|
62
|
+
*/
|
|
63
|
+
async function fetchMetadata(url, token) {
|
|
64
|
+
const response = await request(url, token);
|
|
65
|
+
if (response.status === 404) return null;
|
|
66
|
+
if (!response.ok) panic(`${url} answered ${response.status}`);
|
|
67
|
+
return await response.json();
|
|
68
|
+
}
|
|
52
69
|
async function apiFetch(url, token) {
|
|
53
|
-
const response = await
|
|
70
|
+
const response = await request(url, token);
|
|
71
|
+
if (!response.ok) panic(`${url} answered ${response.status}`);
|
|
72
|
+
return await response.json();
|
|
73
|
+
}
|
|
74
|
+
function request(url, token) {
|
|
75
|
+
return fetch(url, { headers: {
|
|
54
76
|
accept: "application/json",
|
|
55
77
|
Authorization: `Bearer ${token}`
|
|
56
78
|
} }).catch(() => panic(`Could not reach ${url}`));
|
|
57
|
-
if (!response.ok) panic(`${url} answered ${response.status}`);
|
|
58
|
-
return await response.json();
|
|
59
79
|
}
|
|
60
80
|
function withoutTrailingSlash(url) {
|
|
61
81
|
return url.replace(/\/+$/, "");
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: sub-skill
|
|
15
15
|
library: softr-sdk
|
|
16
|
-
library_version: 1.
|
|
16
|
+
library_version: 1.4.0
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
**Boundary.** `ai` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineAiAction` 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: 1.
|
|
12
|
+
library_version: 1.4.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: 1.
|
|
12
|
+
library_version: 1.4.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.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 1.
|
|
10
|
+
library_version: 1.4.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: 1.
|
|
10
|
+
library_version: 1.4.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: 1.
|
|
12
|
+
library_version: 1.4.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: 1.
|
|
12
|
+
library_version: 1.4.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**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.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.
|
|
13
|
+
library_version: 1.4.0
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**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: 1.
|
|
12
|
+
library_version: 1.4.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.
|