@softr/sdk 1.9.1 → 1.10.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/auth/methods/profile.d.ts +4 -0
- package/dist/auth/methods/profile.js +10 -4
- package/dist/auth/methods/utils.d.ts +1 -1
- 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 +2 -2
- 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/email/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.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- `auth.updateProfile` and `auth.removeAvatar` answer `invalidPhoto` when the platform refuses a photo, instead of `invalidName`. Action: where a photo is saved or removed, handle `invalidPhoto` and say the photo cannot be used.
|
|
8
|
+
|
|
3
9
|
## 1.9.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -14,6 +14,10 @@ type Profile = Pick<User, "id" | "email" | "fullName" | "userGroupIds" | "avatar
|
|
|
14
14
|
* loaded until its route context loads again, so call `router.invalidate()`
|
|
15
15
|
* after a success.
|
|
16
16
|
*
|
|
17
|
+
* A bad name answers `invalidName`. A photo the platform refuses, sent alone,
|
|
18
|
+
* answers `invalidPhoto`. When a name and a photo are sent together, a refusal
|
|
19
|
+
* answers `invalidName`.
|
|
20
|
+
*
|
|
17
21
|
* @example
|
|
18
22
|
* const result = await auth.updateProfile({ fullName: 'Ann Lee' })
|
|
19
23
|
* const result = await auth.updateProfile({ avatar: file })
|
|
@@ -16,6 +16,10 @@ import { authError } from "./utils.js";
|
|
|
16
16
|
* loaded until its route context loads again, so call `router.invalidate()`
|
|
17
17
|
* after a success.
|
|
18
18
|
*
|
|
19
|
+
* A bad name answers `invalidName`. A photo the platform refuses, sent alone,
|
|
20
|
+
* answers `invalidPhoto`. When a name and a photo are sent together, a refusal
|
|
21
|
+
* answers `invalidName`.
|
|
22
|
+
*
|
|
19
23
|
* @example
|
|
20
24
|
* const result = await auth.updateProfile({ fullName: 'Ann Lee' })
|
|
21
25
|
* const result = await auth.updateProfile({ avatar: file })
|
|
@@ -27,7 +31,9 @@ async function updateProfile(changes) {
|
|
|
27
31
|
const form = new FormData();
|
|
28
32
|
if (changes.fullName !== void 0) form.set("fullName", changes.fullName);
|
|
29
33
|
if (changes.avatar) form.set("avatar", changes.avatar);
|
|
30
|
-
|
|
34
|
+
const platform = makePlatform(sessionConfig().applicationId);
|
|
35
|
+
const badRequest = changes.fullName === void 0 ? "invalidPhoto" : "invalidName";
|
|
36
|
+
return answer(await platform.updateProfile(token, form), badRequest);
|
|
31
37
|
}
|
|
32
38
|
/**
|
|
33
39
|
* Removes the signed-in visitor's own photo. Like {@link updateProfile}, it
|
|
@@ -40,12 +46,12 @@ async function updateProfile(changes) {
|
|
|
40
46
|
async function removeAvatar() {
|
|
41
47
|
const token = readSessionToken();
|
|
42
48
|
if (token === null) return authError("notAuthenticated", "Nobody is signed in.");
|
|
43
|
-
return answer(await makePlatform(sessionConfig().applicationId).removeAvatar(token));
|
|
49
|
+
return answer(await makePlatform(sessionConfig().applicationId).removeAvatar(token), "invalidPhoto");
|
|
44
50
|
}
|
|
45
|
-
function answer(result) {
|
|
51
|
+
function answer(result, badRequest) {
|
|
46
52
|
if (!result.ok) {
|
|
47
53
|
switch (result.status) {
|
|
48
|
-
case 400: return authError(
|
|
54
|
+
case 400: return authError(badRequest, result.message);
|
|
49
55
|
case 401: return authError("notAuthenticated", result.message);
|
|
50
56
|
case 409: return authError("avatarNotSupported", result.message);
|
|
51
57
|
case 413: return authError("fileTooLarge", result.message);
|
|
@@ -10,6 +10,6 @@ type AuthError = {
|
|
|
10
10
|
code: AuthErrorCode;
|
|
11
11
|
message: string;
|
|
12
12
|
};
|
|
13
|
-
type AuthErrorCode = "invalidCredentials" | "tooManyAttempts" | "emailTaken" | "invalidDetails" | "invalidCode" | "noAccount" | "accountDeactivated" | "notAuthenticated" | "emailDomainNotAllowed" | "notEnabled" | "linkExpired" | "invalidName" | "fileTooLarge" | "notAnImage" | "avatarNotSupported";
|
|
13
|
+
type AuthErrorCode = "invalidCredentials" | "tooManyAttempts" | "emailTaken" | "invalidDetails" | "invalidCode" | "noAccount" | "accountDeactivated" | "notAuthenticated" | "emailDomainNotAllowed" | "notEnabled" | "linkExpired" | "invalidName" | "invalidPhoto" | "fileTooLarge" | "notAnImage" | "avatarNotSupported";
|
|
14
14
|
//#endregion
|
|
15
15
|
export { AuthError, Result };
|
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.10.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.
|
|
@@ -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.10.0
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
|
|
@@ -486,7 +486,7 @@ const result = await auth.updateProfile({ avatar: file }) // a File from an <i
|
|
|
486
486
|
const result = await auth.removeAvatar() // removes the photo
|
|
487
487
|
```
|
|
488
488
|
|
|
489
|
-
It answers with the updated `User`. Pass the file through a server function that takes `FormData`. The photo must be a PNG, JPEG or GIF of at most 5 MB, or it answers `notAnImage` or `fileTooLarge`. A blank or unacceptable name answers `invalidName`.
|
|
489
|
+
It answers with the updated `User`. Pass the file through a server function that takes `FormData`. The photo must be a PNG, JPEG or GIF of at most 5 MB, or it answers `notAnImage` or `fileTooLarge`. A blank or unacceptable name answers `invalidName`. A photo the platform refuses for another reason answers `invalidPhoto`. Sent together with a name, a refusal answers `invalidName`.
|
|
490
490
|
|
|
491
491
|
Only some apps can store a photo. Show the photo controls only when `user.avatarEditable` is true; elsewhere a photo answers `avatarNotSupported`.
|
|
492
492
|
|
|
@@ -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.10.0
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. A helper that calls `ds` outside a handler goes in `createServerOnlyFn` from `@tanstack/react-start` (the `record-queries` boundary). `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -12,7 +12,7 @@ description: >-
|
|
|
12
12
|
metadata:
|
|
13
13
|
type: sub-skill
|
|
14
14
|
library: softr-sdk
|
|
15
|
-
library_version: 1.
|
|
15
|
+
library_version: 1.10.0
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
**Boundary.** `email` and `EmailError` live on `@softr/sdk/server` and run only inside a `createServerFn` handler — importing them into a component fails the build. `defineEmailAction` 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.10.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.10.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.10.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.
|
|
@@ -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.10.0
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**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.
|
|
@@ -11,7 +11,7 @@ description: >-
|
|
|
11
11
|
metadata:
|
|
12
12
|
type: sub-skill
|
|
13
13
|
library: softr-sdk
|
|
14
|
-
library_version: 1.
|
|
14
|
+
library_version: 1.10.0
|
|
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. A route `loader` also runs in the browser, so it calls a server function, never `ds`. A helper that calls `ds` outside a handler, in this file or in another one, goes in `createServerOnlyFn` from `@tanstack/react-start`, or inside the handler. An exported helper without it keeps the server-only import in the browser bundle, and every page stops loading until it moves. Do not make such a helper a server function when it takes an id: any visitor can call a server function with any id. `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.10.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.
|