@softr/sdk 0.0.68 → 0.0.69

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.
@@ -315,4 +315,4 @@ function words(value) {
315
315
  }
316
316
 
317
317
  //#endregion
318
- export { renderDatasourceDoc, renderDatasourceIndex };
318
+ export { DOC_NOTE, renderDatasourceDoc, renderDatasourceIndex };
@@ -1,22 +1,29 @@
1
1
  import { requireDefined } from "../assertions.js";
2
- import { renderDatasourceDoc, renderDatasourceIndex } from "./datasource-docs.js";
2
+ import { DOC_NOTE, renderDatasourceDoc, renderDatasourceIndex } from "./datasource-docs.js";
3
3
  import { renderDatasourceSchema } from "./datasource-schema.js";
4
4
  import { docFileNames } from "./doc-file-names.js";
5
5
  import { writeIfChanged } from "./write-if-changed.js";
6
+ import { existsSync, readFileSync, readdirSync, rmSync } from "node:fs";
6
7
  import path from "node:path";
7
8
 
8
9
  //#region src/codegen/write-datasource-docs.ts
9
10
  /**
10
- * Writes the index, and one doc and one schema JSON per datasource, and touches nothing else in
11
- * `docsDir`: the caller resolves it against `process.cwd()`, which can be any
12
- * directory a developer ran the bin from. `changed` is true when any file it
13
- * wrote now reads differently.
11
+ * Writes the index, and one doc and one schema JSON per datasource, and removes the doc and schema
12
+ * of a datasource no longer registered. It removes only a doc that carries the generated note: the
13
+ * caller resolves `docsDir` against `process.cwd()`, which can be any directory a developer ran the
14
+ * bin from. `changed` is true when any file it wrote now reads differently, or it removed one.
14
15
  */
15
16
  function writeDatasourceDocs(datasources, docsDir) {
16
17
  const context = {
17
18
  datasources: new Map(datasources.map((datasource) => [datasource.id, datasource])),
18
19
  fileNames: docFileNames(datasources)
19
20
  };
21
+ const current = new Set(context.fileNames.values());
22
+ const stale = (existsSync(docsDir) ? readdirSync(docsDir, { withFileTypes: true }) : []).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => entry.name).filter((name) => !current.has(name) && readFileSync(path.join(docsDir, name), "utf8").includes(DOC_NOTE));
23
+ for (const name of stale) {
24
+ rmSync(path.join(docsDir, name));
25
+ rmSync(path.join(docsDir, name.replace(/\.md$/, ".json")), { force: true });
26
+ }
20
27
  const writes = [
21
28
  writeIfChanged(path.join(docsDir, "README.md"), renderDatasourceIndex(datasources, context)),
22
29
  ...datasources.map((datasource) => writeIfChanged(path.join(docsDir, requireDefined(context.fileNames.get(datasource.id))), renderDatasourceDoc(datasource, context))),
@@ -24,7 +31,7 @@ function writeDatasourceDocs(datasources, docsDir) {
24
31
  ];
25
32
  return {
26
33
  fileNames: context.fileNames,
27
- changed: writes.includes(true)
34
+ changed: stale.length > 0 || writes.includes(true)
28
35
  };
29
36
  }
30
37
 
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.68";
2
+ var version = "0.0.69";
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.68",
3
+ "version": "0.0.69",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
@@ -12,7 +12,7 @@ description: >-
12
12
  metadata:
13
13
  type: core
14
14
  library: softr-sdk
15
- library_version: 0.0.68
15
+ library_version: 0.0.69
16
16
  ---
17
17
 
18
18
  # Softr SDK core
@@ -19,7 +19,7 @@ description: >-
19
19
  metadata:
20
20
  type: sub-skill
21
21
  library: softr-sdk
22
- library_version: 0.0.68
22
+ library_version: 0.0.69
23
23
  ---
24
24
 
25
25
  **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.68
15
+ library_version: 0.0.69
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.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.68
12
+ library_version: 0.0.69
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.68
13
+ library_version: 0.0.69
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.68
13
+ library_version: 0.0.69
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.68
13
+ library_version: 0.0.69
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.68
12
+ library_version: 0.0.69
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.68
12
+ library_version: 0.0.69
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.68
14
+ library_version: 0.0.69
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.68
16
+ library_version: 0.0.69
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.68
12
+ library_version: 0.0.69
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.68
16
+ library_version: 0.0.69
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.68
12
+ library_version: 0.0.69
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.