@softr/sdk 0.0.81-envvars.0 → 0.0.82

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/action.d.ts CHANGED
@@ -234,35 +234,5 @@ type IntegrationDefinition<TId extends string> = {
234
234
  * const res = await listEvents({ query: { timeMin: now, singleEvents: "true" } })
235
235
  */
236
236
  declare function defineIntegration<const TId extends string>(definition: IntegrationDefinition<TId>): IntegrationAction<TId>;
237
- type CommentsResource = {
238
- type: "COMMENTS";
239
- datasourceId: SoftrDatasourceId;
240
- };
241
- /** Comment threads on the records of one datasource. It has no `permissions`. */
242
- type CommentsAction<TId extends string = string> = {
243
- id: TId;
244
- resource: CommentsResource;
245
- };
246
- type CommentsDefinition<TId extends string> = {
247
- id: TId;
248
- datasourceId: SoftrDatasourceId;
249
- };
250
- /**
251
- * Declares comment threads on the records of a datasource. Each record has one thread.
252
- *
253
- * Who may read, post and delete comes from the app's comment settings in Softr, not from code. Two
254
- * declarations on the same datasource share the same threads.
255
- *
256
- * Pass the returned object to `comments.*` from `@softr/sdk/server`.
257
- *
258
- * @example
259
- * const orderComments = defineComments({
260
- * id: "orderComments",
261
- * datasourceId: "8f14e45f-ceea-467a-9d0b-2c1a0e3b5d77",
262
- * })
263
- *
264
- * const thread = await comments.list(orderComments, { recordId })
265
- */
266
- declare function defineComments<const TId extends string>(definition: CommentsDefinition<TId>): CommentsAction<TId>;
267
237
  //#endregion
268
- export { ActionData, ActionPermissions, ActionRecord, ActionShape, CommentsAction, DatasourceAction, FieldTypeOf, IntegrationAction, ReadOf, ReadShape, SoftrDatasources, WorkflowAction, defineComments, defineIntegration, defineMutation, defineQuery, defineWorkflow };
238
+ export { ActionData, ActionPermissions, ActionRecord, ActionShape, DatasourceAction, FieldTypeOf, IntegrationAction, ReadOf, ReadShape, SoftrDatasources, WorkflowAction, defineIntegration, defineMutation, defineQuery, defineWorkflow };
package/dist/action.js CHANGED
@@ -50,31 +50,6 @@ function defineIntegration(definition) {
50
50
  permissions
51
51
  };
52
52
  }
53
- /**
54
- * Declares comment threads on the records of a datasource. Each record has one thread.
55
- *
56
- * Who may read, post and delete comes from the app's comment settings in Softr, not from code. Two
57
- * declarations on the same datasource share the same threads.
58
- *
59
- * Pass the returned object to `comments.*` from `@softr/sdk/server`.
60
- *
61
- * @example
62
- * const orderComments = defineComments({
63
- * id: "orderComments",
64
- * datasourceId: "8f14e45f-ceea-467a-9d0b-2c1a0e3b5d77",
65
- * })
66
- *
67
- * const thread = await comments.list(orderComments, { recordId })
68
- */
69
- function defineComments(definition) {
70
- return {
71
- id: definition.id,
72
- resource: {
73
- type: "COMMENTS",
74
- datasourceId: definition.datasourceId
75
- }
76
- };
77
- }
78
53
  function isDatasourceAction(value) {
79
54
  if (typeof value !== "object" || value === null) return false;
80
55
  const candidate = value;
@@ -83,4 +58,4 @@ function isDatasourceAction(value) {
83
58
  }
84
59
 
85
60
  //#endregion
86
- export { defineComments, defineIntegration, defineMutation, defineQuery, defineWorkflow, isDatasourceAction };
61
+ export { defineIntegration, defineMutation, defineQuery, defineWorkflow, isDatasourceAction };
package/dist/client.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { FileItem, useFileUpload } from "./core/use-file-upload.js";
2
- import { useCommentComposer } from "./comments/use-comment-composer.js";
3
2
  import "@tanstack/react-start/client-only";
4
- export { type FileItem, useCommentComposer, useFileUpload };
3
+ export { type FileItem, useFileUpload };
package/dist/client.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { useFileUpload } from "./core/use-file-upload.js";
2
- import { useCommentComposer } from "./comments/use-comment-composer.js";
3
2
  import "@tanstack/react-start/client-only";
4
3
 
5
- export { useCommentComposer, useFileUpload };
4
+ export { useFileUpload };
@@ -1,4 +1,4 @@
1
- import { CommentsAction, DatasourceAction } from "../action.js";
1
+ import { DatasourceAction } from "../action.js";
2
2
 
3
3
  //#region src/core/file-upload.d.ts
4
4
 
@@ -12,10 +12,6 @@ type FileAttachment = {
12
12
  id: string;
13
13
  type?: string | null;
14
14
  };
15
- /**
16
- * A COMMENTS action uploads a comment attachment.
17
- * The platform checks the comment settings.
18
- */
19
- declare function upload(action: DatasourceAction | CommentsAction, file: File): Promise<FileAttachment>;
15
+ declare function upload(action: DatasourceAction, file: File): Promise<FileAttachment>;
20
16
  //#endregion
21
17
  export { FileAttachment, upload };
@@ -5,10 +5,6 @@ import { softrApiUrl } from "../softr-api.js";
5
5
  import { randomUUID } from "node:crypto";
6
6
 
7
7
  //#region src/core/file-upload.ts
8
- /**
9
- * A COMMENTS action uploads a comment attachment.
10
- * The platform checks the comment settings.
11
- */
12
8
  async function upload(action, file) {
13
9
  const { applicationId } = sessionConfig();
14
10
  const baseUrl = softrApiUrl("SOFTR_PLATFORM_API_URL");
@@ -1,4 +1,4 @@
1
- import { CommentsAction, DatasourceAction } from "../action.js";
1
+ import { DatasourceAction } from "../action.js";
2
2
  import { FileAttachment } from "./file-upload.js";
3
3
 
4
4
  //#region src/core/use-file-upload.d.ts
@@ -16,7 +16,7 @@ type FileItem = {
16
16
  filename: string;
17
17
  error: Error;
18
18
  };
19
- declare function useFileUpload(action: DatasourceAction | CommentsAction, options?: {
19
+ declare function useFileUpload(action: DatasourceAction, options?: {
20
20
  initialAttachments?: FileAttachment[];
21
21
  }): {
22
22
  files: FileItem[];
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { SoftrUserGroupId, SoftrUserGroups, SoftrUserProperties, User } from "./auth/user.js";
2
- import { ActionPermissions, SoftrDatasources, defineComments, defineIntegration, defineMutation, defineQuery, defineWorkflow } from "./action.js";
2
+ import { ActionPermissions, SoftrDatasources, defineIntegration, defineMutation, defineQuery, defineWorkflow } from "./action.js";
3
3
  import { FileAttachment } from "./core/file-upload.js";
4
4
  import { FileItem, useFileUpload } from "./core/use-file-upload.js";
5
- import { CommentAttachmentInput, CommentMention, CommentThread, CommentView } from "./comments/comments.js";
6
5
  import { DateOptions, DateParts, DateSeparator, DateValue, FixedDateFormat, FormattedDate, Formatting, FormattingScope, WeekDay, formatDate, formatDateTime, formatNumber, useFormatting } from "./formatting.js";
7
6
  import { SoftrContext } from "./auth/context.js";
8
7
  import { AuthSettings } from "./auth/platform.js";
@@ -18,4 +17,4 @@ import { useUserTimezone } from "./timezone.js";
18
17
  import { PwaInstall, PwaPlatform, SoftrPwaHead, usePwaInstall } from "./pwa.js";
19
18
  import { DefaultErrorOverlay } from "./default-error-overlay.js";
20
19
  import { Audience } from "./route/audience.js";
21
- export { type ActionPermissions, Audience, type AuthOptions, type AuthSettings, AuthSettingsProvider, type CommentAttachmentInput, type CommentMention, type CommentThread, type CommentView, type DateOptions, type DateParts, type DateSeparator, type DateValue, DefaultErrorOverlay, type FieldShape, type FileAttachment, type FileItem, type FixedDateFormat, FormattedDate, type Formatting, FormattingScope, type Page, type PageSettings, type PwaInstall, type PwaPlatform, type SoftrContext, type SoftrDatasources, type SoftrFieldRegistry, SoftrPwaHead, type SoftrUserGroupId, type SoftrUserGroups, type SoftrUserProperties, type User, type WeekDay, assertRouteAccess, checkAccess, defineComments, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useOverrides, usePwaInstall, useUserTimezone };
20
+ export { type ActionPermissions, Audience, type AuthOptions, type AuthSettings, AuthSettingsProvider, type DateOptions, type DateParts, type DateSeparator, type DateValue, DefaultErrorOverlay, type FieldShape, type FileAttachment, type FileItem, type FixedDateFormat, FormattedDate, type Formatting, FormattingScope, type Page, type PageSettings, type PwaInstall, type PwaPlatform, type SoftrContext, type SoftrDatasources, type SoftrFieldRegistry, SoftrPwaHead, type SoftrUserGroupId, type SoftrUserGroups, type SoftrUserProperties, type User, type WeekDay, assertRouteAccess, checkAccess, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useOverrides, usePwaInstall, useUserTimezone };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useFileUpload } from "./core/use-file-upload.js";
2
- import { defineComments, defineIntegration, defineMutation, defineQuery, defineWorkflow } from "./action.js";
2
+ import { defineIntegration, defineMutation, defineQuery, defineWorkflow } from "./action.js";
3
3
  import { checkAccess, defineVisibility, isAuthorized } from "./route/visibility.js";
4
4
  import { assertRouteAccess, guardRoute, isAccessError, isAlreadyAuthenticatedError, isForbiddenError, isUnauthenticatedError } from "./route/route.js";
5
5
  import { definePage, pageHead } from "./route/page.js";
@@ -14,4 +14,4 @@ import { useUserTimezone } from "./timezone.js";
14
14
  import { DefaultErrorOverlay } from "./default-error-overlay.js";
15
15
  import { Audience } from "./route/audience.js";
16
16
 
17
- export { Audience, AuthSettingsProvider, DefaultErrorOverlay, FormattedDate, FormattingScope, SoftrPwaHead, assertRouteAccess, checkAccess, defineComments, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useOverrides, usePwaInstall, useUserTimezone };
17
+ export { Audience, AuthSettingsProvider, DefaultErrorOverlay, FormattedDate, FormattingScope, SoftrPwaHead, assertRouteAccess, checkAccess, defineIntegration, defineMutation, definePage, defineQuery, defineVisibility, defineWorkflow, fieldShape, formatDate, formatDateTime, formatDuration, formatField, formatNumber, formatValue, getAuthSettings, getSoftrContext, guardRoute, initialSoftrContext, isAccessError, isAlreadyAuthenticatedError, isAuthorized, isForbiddenError, isUnauthenticatedError, pageHead, registerSoftrFields, softrAuthMiddleware, softrMcpMiddleware, toReturnPath, useAuthSettings, useCurrentUser, useFileUpload, useFormatting, useOverrides, usePwaInstall, useUserTimezone };
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_start5 from "@tanstack/react-start";
3
3
 
4
4
  //#region src/mcp.d.ts
5
5
 
@@ -31,6 +31,6 @@ type SoftrMcpOptions = {
31
31
  * ],
32
32
  * }))
33
33
  */
34
- declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>;
34
+ declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start5.RequestMiddlewareAfterServer<{}, undefined, undefined>;
35
35
  //#endregion
36
36
  export { softrMcpMiddleware };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.81-envvars.0";
2
+ var version = "0.0.82";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/dist/server.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { upload } from "./core/file-upload.js";
2
- import { comments } from "./comments/comments.js";
3
2
  import { auth } from "./auth/server.js";
4
3
  import { FieldChoice, RecordOption, RecordOptions } from "./core/options.js";
5
4
  import { ds } from "./datasource/datasource.js";
6
5
  import { workflow } from "./core/workflow.js";
7
6
  import { integration } from "./core/integration.js";
8
7
  import "@tanstack/react-start/server-only";
9
- export { type FieldChoice, type RecordOption, type RecordOptions, auth, comments, ds, integration, upload, workflow };
8
+ export { type FieldChoice, type RecordOption, type RecordOptions, auth, ds, integration, upload, workflow };
package/dist/server.js CHANGED
@@ -3,7 +3,6 @@ import { ds } from "./datasource/datasource.js";
3
3
  import { auth } from "./auth/server.js";
4
4
  import { workflow } from "./core/workflow.js";
5
5
  import { integration } from "./core/integration.js";
6
- import { comments } from "./comments/comments.js";
7
6
  import "@tanstack/react-start/server-only";
8
7
 
9
- export { auth, comments, ds, integration, upload, workflow };
8
+ export { auth, ds, integration, upload, workflow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "0.0.81-envvars.0",
3
+ "version": "0.0.82",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
@@ -17,8 +17,6 @@
17
17
  "typecheck": "tsc --noEmit"
18
18
  },
19
19
  "dependencies": {
20
- "marked": "^18.0.14",
21
- "xss": "^1.0.15",
22
20
  "zod": "^4.4.3"
23
21
  },
24
22
  "devDependencies": {
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: core
10
10
  library: softr-sdk
11
- library_version: 0.0.81-envvars.0
11
+ library_version: 0.0.82
12
12
  ---
13
13
 
14
14
  # Softr SDK core
@@ -26,9 +26,9 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
26
26
 
27
27
  | Import | Runs | Holds |
28
28
  | --- | --- | --- |
29
- | `@softr/sdk` | Both | `defineQuery`, `defineMutation`, `defineComments`, `defineVisibility`, `guardRoute`, `assertRouteAccess`, `isAuthorized`, `checkAccess`, `Audience`, `useCurrentUser`, `useUserTimezone`, `FormattedDate`, `FormattingScope`, `useFormatting`, `formatDate`, `formatDateTime`, `formatNumber`, `formatValue`, `formatField`, `fieldShape`, `registerSoftrFields`, `useOverrides`, `SoftrPwaHead`, `usePwaInstall`, `getSoftrContext`, `initialSoftrContext`, `softrAuthMiddleware`, the error predicates, and every type |
30
- | `@softr/sdk/server` | Server only | `ds`, `auth`, `workflow`, `integration`, `comments` |
31
- | `@softr/sdk/client` | Browser only | `useFileUpload`, `useCommentComposer` |
29
+ | `@softr/sdk` | Both | `defineQuery`, `defineMutation`, `defineVisibility`, `guardRoute`, `assertRouteAccess`, `isAuthorized`, `checkAccess`, `Audience`, `useCurrentUser`, `useUserTimezone`, `FormattedDate`, `FormattingScope`, `useFormatting`, `formatDate`, `formatDateTime`, `formatNumber`, `formatValue`, `formatField`, `fieldShape`, `registerSoftrFields`, `useOverrides`, `SoftrPwaHead`, `usePwaInstall`, `getSoftrContext`, `initialSoftrContext`, `softrAuthMiddleware`, the error predicates, and every type |
30
+ | `@softr/sdk/server` | Server only | `ds`, `auth`, `workflow`, `integration` |
31
+ | `@softr/sdk/client` | Browser only | `useFileUpload` |
32
32
  | `@softr/sdk/vite` | Build | `softr()`, already in `vite.config.ts` |
33
33
 
34
34
  ## Sub-Skills
@@ -47,7 +47,6 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
47
47
  | Open the app to AI assistants over MCP | [mcp/SKILL.md](./mcp/SKILL.md) |
48
48
  | Let visitors install the app on their home screen | [pwa/SKILL.md](./pwa/SKILL.md) |
49
49
  | Show a date, a time or a number | [formatting/SKILL.md](./formatting/SKILL.md) |
50
- | Add comments to a record | [comments/SKILL.md](./comments/SKILL.md) |
51
50
 
52
51
  ## Quick Decision Tree
53
52
 
@@ -88,9 +87,6 @@ Adding an install button, or making the app installable?
88
87
  Showing a date, a time or a number on a page?
89
88
  load softr-sdk/formatting
90
89
 
91
- Letting visitors comment on a record?
92
- load softr-sdk/comments
93
-
94
90
  Writing a server function, loader, or middleware in general?
95
91
  not a Softr concern. Use the TanStack Start skills.
96
92
  ```
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.81-envvars.0
12
+ library_version: 0.0.82
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: 0.0.81-envvars.0
12
+ library_version: 0.0.82
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.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.81-envvars.0
12
+ library_version: 0.0.82
13
13
  ---
14
14
 
15
15
  # The current user
@@ -7,7 +7,7 @@ description: >-
7
7
  metadata:
8
8
  type: sub-skill
9
9
  library: softr-sdk
10
- library_version: 0.0.81-envvars.0
10
+ library_version: 0.0.82
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.
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: sub-skill
10
10
  library: softr-sdk
11
- library_version: 0.0.81-envvars.0
11
+ library_version: 0.0.82
12
12
  ---
13
13
 
14
14
  # Dates, times and numbers
@@ -7,7 +7,7 @@ description: >-
7
7
  metadata:
8
8
  type: sub-skill
9
9
  library: softr-sdk
10
- library_version: 0.0.81-envvars.0
10
+ library_version: 0.0.82
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: 0.0.81-envvars.0
12
+ library_version: 0.0.82
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.81-envvars.0
12
+ library_version: 0.0.82
13
13
  ---
14
14
 
15
15
  # Installing the app
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: sub-skill
10
10
  library: softr-sdk
11
- library_version: 0.0.81-envvars.0
11
+ library_version: 0.0.82
12
12
  ---
13
13
 
14
14
  **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.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.81-envvars.0
12
+ library_version: 0.0.82
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. 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.81-envvars.0
12
+ library_version: 0.0.82
13
13
  ---
14
14
 
15
15
  **Boundary.** `Audience` and `defineVisibility` come from `@softr/sdk` and work anywhere.
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: sub-skill
10
10
  library: softr-sdk
11
- library_version: 0.0.81-envvars.0
11
+ library_version: 0.0.82
12
12
  ---
13
13
 
14
14
  **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.81-envvars.0
12
+ library_version: 0.0.82
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.
@@ -1,168 +0,0 @@
1
- import { CommentsAction } from "../action.js";
2
-
3
- //#region src/comments/comments.d.ts
4
- /** A person picked in the composer, and where their `@name` sits in the text. */
5
- type CommentMention = {
6
- name: string;
7
- email: string;
8
- start: number;
9
- end: number;
10
- };
11
- type CommentAttachmentInput = {
12
- url: string;
13
- filename: string;
14
- type?: string | null;
15
- };
16
- type CommentView = {
17
- id: string;
18
- /** The body as safe HTML. Render it with `dangerouslySetInnerHTML`, never as text. */
19
- bodyHtml: string;
20
- attachments: Array<{
21
- url: string;
22
- filename: string;
23
- type: string | null;
24
- }>;
25
- author: {
26
- name: string;
27
- avatar: string | null;
28
- isDeactivated: boolean;
29
- };
30
- /** ISO 8601. */
31
- createdAt: string;
32
- canDelete: boolean;
33
- canEdit: boolean;
34
- edited: boolean;
35
- /** The body as the visitor typed it, to fill an edit box. `null` unless `canEdit`. */
36
- source: {
37
- text: string;
38
- mentions: Array<CommentMention>;
39
- } | null;
40
- reactions: Array<{
41
- emoji: string;
42
- label: string;
43
- count: number;
44
- isSelected: boolean;
45
- }>;
46
- };
47
- type CommentThread = {
48
- canPost: boolean;
49
- allowMentions: boolean;
50
- allowAttachments: boolean;
51
- notificationsEnabled: boolean;
52
- quickReactions: ReadonlyArray<{
53
- emoji: string;
54
- label: string;
55
- }>;
56
- total: number;
57
- /** Pass it back as `offset` for the next page. `null` on the last page. */
58
- nextOffset: number | null;
59
- items: Array<CommentView>;
60
- };
61
- /**
62
- * The thread on one record, or `null` when this visitor cannot see comments on it. Render nothing
63
- * for `null`.
64
- *
65
- * @example
66
- * const thread = await comments.list(orderComments, { recordId: order.id })
67
- */
68
- declare function listComments(action: CommentsAction, options: {
69
- recordId: string;
70
- offset?: number | null;
71
- limit?: number;
72
- }): Promise<CommentThread | null>;
73
- /**
74
- * Posts a comment. `body` is the text the visitor typed. `mentions` are the people they picked,
75
- * each with the range of its `@name` in `body`. A range that no longer reads as `@name` is posted as
76
- * plain text. `attachments` are the files `useFileUpload` finished uploading.
77
- *
78
- * @example
79
- * await comments.create(orderComments, { recordId, body: "Hey @Ann", mentions, attachments })
80
- */
81
- declare function createComment(action: CommentsAction, options: {
82
- recordId: string;
83
- body: string;
84
- mentions: ReadonlyArray<CommentMention>;
85
- attachments?: ReadonlyArray<CommentAttachmentInput>;
86
- }): Promise<void>;
87
- /**
88
- * Saves an edit. Offer it only where the comment's `canEdit` is true, and fill the edit box from its
89
- * `source`. `attachments` is the full list after the edit: the files kept plus any new ones.
90
- *
91
- * @example
92
- * await comments.update(orderComments, { recordId, commentId, body, mentions, attachments })
93
- */
94
- declare function updateComment(action: CommentsAction, options: {
95
- recordId: string;
96
- commentId: string;
97
- body: string;
98
- mentions: ReadonlyArray<CommentMention>;
99
- attachments: ReadonlyArray<CommentAttachmentInput>;
100
- }): Promise<void>;
101
- /**
102
- * Deletes a comment. Offer it only where the comment's `canDelete` is true.
103
- *
104
- * @example
105
- * await comments.delete(orderComments, { recordId, commentId })
106
- */
107
- declare function deleteComment(action: CommentsAction, options: {
108
- recordId: string;
109
- commentId: string;
110
- }): Promise<void>;
111
- /**
112
- * Adds the visitor's reaction when `selected` is true, and removes it when false. Pass the
113
- * reaction's current `isSelected` negated.
114
- *
115
- * @example
116
- * await comments.react(orderComments, { recordId, commentId, emoji: "👍", selected: true })
117
- */
118
- declare function reactToComment(action: CommentsAction, options: {
119
- recordId: string;
120
- commentId: string;
121
- emoji: string;
122
- selected: boolean;
123
- }): Promise<void>;
124
- /**
125
- * Whether the visitor gets an email when someone comments on this record.
126
- *
127
- * @example
128
- * const subscribed = await comments.subscription(orderComments, { recordId })
129
- */
130
- declare function readSubscription(action: CommentsAction, options: {
131
- recordId: string;
132
- }): Promise<boolean>;
133
- /**
134
- * Turns the visitor's emails about this record's comments on or off.
135
- *
136
- * @example
137
- * await comments.setSubscription(orderComments, { recordId, subscribed: false })
138
- */
139
- declare function setSubscription(action: CommentsAction, options: {
140
- recordId: string;
141
- subscribed: boolean;
142
- }): Promise<void>;
143
- /**
144
- * The people the visitor may mention whose name or email matches `query`. Only call it when the
145
- * thread's `allowMentions` is true.
146
- *
147
- * @example
148
- * const people = await comments.searchMentions(orderComments, { query: "an" })
149
- */
150
- declare function searchMentions(action: CommentsAction, options: {
151
- query: string;
152
- }): Promise<Array<{
153
- name: string;
154
- email: string;
155
- avatar: string | null;
156
- }>>;
157
- declare const comments: {
158
- list: typeof listComments;
159
- create: typeof createComment;
160
- update: typeof updateComment;
161
- delete: typeof deleteComment;
162
- react: typeof reactToComment;
163
- subscription: typeof readSubscription;
164
- setSubscription: typeof setSubscription;
165
- searchMentions: typeof searchMentions;
166
- };
167
- //#endregion
168
- export { CommentAttachmentInput, CommentMention, CommentThread, CommentView, comments };