@softr/sdk 0.0.56-alpha.0 → 0.0.56-alpha.2

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.
Files changed (39) hide show
  1. package/dist/action.d.ts +1 -31
  2. package/dist/action.js +1 -26
  3. package/dist/auth/isomorphic.d.ts +1 -1
  4. package/dist/auth/isomorphic.js +2 -1
  5. package/dist/client.d.ts +1 -2
  6. package/dist/client.js +1 -2
  7. package/dist/codegen/datasource-types.js +1 -1
  8. package/dist/core/file-upload.d.ts +2 -7
  9. package/dist/core/file-upload.js +1 -6
  10. package/dist/core/use-file-upload.d.ts +2 -2
  11. package/dist/default-error-overlay.d.ts +2 -2
  12. package/dist/index.d.ts +3 -3
  13. package/dist/index.js +3 -2
  14. package/dist/mcp.d.ts +2 -2
  15. package/dist/package.js +1 -1
  16. package/dist/pwa.d.ts +54 -0
  17. package/dist/pwa.js +152 -0
  18. package/dist/server.d.ts +1 -2
  19. package/dist/server.js +1 -2
  20. package/package.json +1 -3
  21. package/skills/softr-sdk/SKILL.md +7 -7
  22. package/skills/softr-sdk/auth/SKILL.md +1 -1
  23. package/skills/softr-sdk/charts-and-metrics/SKILL.md +1 -1
  24. package/skills/softr-sdk/current-user/SKILL.md +1 -1
  25. package/skills/softr-sdk/file-uploads/SKILL.md +4 -5
  26. package/skills/softr-sdk/integrations/SKILL.md +1 -1
  27. package/skills/softr-sdk/mcp/SKILL.md +1 -1
  28. package/skills/softr-sdk/pwa/SKILL.md +77 -0
  29. package/skills/softr-sdk/record-mutations/SKILL.md +1 -1
  30. package/skills/softr-sdk/record-queries/SKILL.md +2 -2
  31. package/skills/softr-sdk/record-queries/references/field-types.md +1 -1
  32. package/skills/softr-sdk/region-visibility/SKILL.md +1 -1
  33. package/skills/softr-sdk/routes-and-visibility/SKILL.md +1 -1
  34. package/skills/softr-sdk/workflows/SKILL.md +1 -1
  35. package/dist/comments/comments.d.ts +0 -168
  36. package/dist/comments/comments.js +0 -413
  37. package/dist/comments/use-comment-composer.d.ts +0 -46
  38. package/dist/comments/use-comment-composer.js +0 -134
  39. package/skills/softr-sdk/comments/SKILL.md +0 -182
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: pwa
3
+ description: >-
4
+ Let visitors install the app on their home screen: SoftrPwaHead for the
5
+ manifest and icon links, usePwaInstall to decide whether to show an install
6
+ button and which platform's steps to show, the PwaInstall and PwaPlatform
7
+ types, and how to check that the app is installable. The manifest and icon
8
+ are already served; never write them.
9
+ metadata:
10
+ type: sub-skill
11
+ library: softr-sdk
12
+ library_version: 0.0.55
13
+ ---
14
+
15
+ # Installing the app
16
+
17
+ The builder turns installing on in Studio, under Settings → Mobile app, and sets the name, colour and icon there. The app already answers with its manifest and icon once they do. What the app adds is two things: the links that point the browser at them, and a button that tells visitors how to install.
18
+
19
+ > **CRITICAL**: Never write a web app manifest, icon files, a service worker, or `manifest` / `apple-touch-icon` links of your own, in `public/` or in `head()`. The app already serves them from Studio's settings, and a file of your own shadows those settings.
20
+ > **CRITICAL**: Render an install button only while `usePwaInstall()` returns `available: true`. Never show it unconditionally, never cache the answer, never replace the check with your own. Softr can switch installing off for an app, and this check is the only way that reaches the button.
21
+
22
+ ## Setup
23
+
24
+ ```ts
25
+ import { SoftrPwaHead, usePwaInstall } from '@softr/sdk'
26
+ import type { PwaInstall, PwaPlatform } from '@softr/sdk'
27
+ ```
28
+
29
+ ```ts
30
+ type PwaPlatform = 'ios' | 'android' | 'desktop'
31
+
32
+ type PwaInstall =
33
+ | { available: false }
34
+ | {
35
+ available: true
36
+ platform: PwaPlatform // which steps install the app on this device
37
+ name: string // what the home screen will show
38
+ iconUrl: string // the icon the home screen will show
39
+ }
40
+ ```
41
+
42
+ ## Is the app installable?
43
+
44
+ The builder switches installing on in Studio, and `usePwaInstall()` reads that switch at runtime. To check it before writing any code, ask the running app for `/_softr/pwa.json`: `200` means installable, `404` means installing is off or there is no icon yet. Do not build an install button against a `404`: installing has to be turned on first. A change in Studio can take up to two minutes to reach the app.
45
+
46
+ ## Core Patterns
47
+
48
+ ### The links: `<SoftrPwaHead />`
49
+
50
+ Render it once, in `<head>` next to `<HeadContent />`, in `RootDocument` in `src/routes/__root.tsx`.
51
+
52
+ ```tsx
53
+ function RootDocument({ children }: { children: React.ReactNode }) {
54
+ return (
55
+ <html lang="en">
56
+ <head>
57
+ <HeadContent />
58
+ <SoftrPwaHead />
59
+ </head>
60
+ <body>
61
+ {children}
62
+ <Scripts />
63
+ </body>
64
+ </html>
65
+ )
66
+ }
67
+ ```
68
+
69
+ ### Whether to show a button: `usePwaInstall()`
70
+
71
+ It fetches after mount, so the first render, the server render included, always says `available: false`. It stays unavailable when the app is not installable, when the request fails, and when the app already runs installed from the home screen. Inside the Studio preview it says available, so the builder can see the button; installing itself only works on the published app.
72
+
73
+ There is no `install()` to call. No browser opens its install dialog for this app on request, so the button opens steps for `platform` instead: Share, then Add to Home Screen on iOS; the browser menu's Install app on Android and desktop. `name` and `iconUrl` tell the visitor what they are adding.
74
+
75
+ ## References
76
+
77
+ - [SKILL.md](../SKILL.md): the entrypoints and which one each export lives on
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: sub-skill
13
13
  library: softr-sdk
14
- library_version: 0.0.56-alpha.0
14
+ library_version: 0.0.55
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,10 +13,10 @@ description: >-
13
13
  metadata:
14
14
  type: sub-skill
15
15
  library: softr-sdk
16
- library_version: 0.0.56-alpha.0
16
+ library_version: 0.0.55
17
17
  ---
18
18
 
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. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
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.
20
20
 
21
21
  # Reading records
22
22
 
@@ -56,7 +56,7 @@ Every scalar above is `| null` on the record unless the field allows multiple en
56
56
  <td>{record.fields.status}</td>
57
57
  ```
58
58
 
59
- **DURATION** is seconds, whatever format the field displays in.
59
+ **DURATION** is milliseconds, whatever format the field displays in: `3600000` is one hour.
60
60
 
61
61
  **DATETIME at date precision** is generated as a `DATE` field and holds `'2026-03-14'`, not a timestamp.
62
62
 
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.56-alpha.0
12
+ library_version: 0.0.55
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.56-alpha.0
16
+ library_version: 0.0.55
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.56-alpha.0
12
+ library_version: 0.0.55
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 };