@softr/sdk 0.0.73 → 0.0.74
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/auth/methods/profile.d.ts +12 -3
- package/dist/auth/methods/profile.js +18 -4
- package/dist/auth/platform.js +4 -0
- package/dist/auth/server.d.ts +2 -1
- package/dist/auth/server.js +2 -1
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +1 -1
- package/skills/softr-sdk/auth/SKILL.md +4 -3
- 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/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
|
@@ -5,7 +5,7 @@ import { AuthError, Result } from "./utils.js";
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Changes the signed-in visitor's own name, photo, or both. A field left out
|
|
8
|
-
* stays as it is
|
|
8
|
+
* stays as it is. {@link removeAvatar} removes the photo.
|
|
9
9
|
*
|
|
10
10
|
* The photo can change only where `user.avatarEditable` is true. Elsewhere a
|
|
11
11
|
* photo answers `avatarNotSupported`, so hide the photo controls instead.
|
|
@@ -20,7 +20,16 @@ import { AuthError, Result } from "./utils.js";
|
|
|
20
20
|
*/
|
|
21
21
|
declare function updateProfile(changes: {
|
|
22
22
|
fullName?: string;
|
|
23
|
-
avatar?: File
|
|
23
|
+
avatar?: File;
|
|
24
24
|
}): Promise<Result<User, AuthError>>;
|
|
25
|
+
/**
|
|
26
|
+
* Removes the signed-in visitor's own photo. Like {@link updateProfile}, it
|
|
27
|
+
* works only where `user.avatarEditable` is true, and answers with the visitor
|
|
28
|
+
* as they are now.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const result = await auth.removeAvatar()
|
|
32
|
+
*/
|
|
33
|
+
declare function removeAvatar(): Promise<Result<User, AuthError>>;
|
|
25
34
|
//#endregion
|
|
26
|
-
export { updateProfile };
|
|
35
|
+
export { removeAvatar, updateProfile };
|
|
@@ -7,7 +7,7 @@ import { authError } from "./utils.js";
|
|
|
7
7
|
//#region src/auth/methods/profile.ts
|
|
8
8
|
/**
|
|
9
9
|
* Changes the signed-in visitor's own name, photo, or both. A field left out
|
|
10
|
-
* stays as it is
|
|
10
|
+
* stays as it is. {@link removeAvatar} removes the photo.
|
|
11
11
|
*
|
|
12
12
|
* The photo can change only where `user.avatarEditable` is true. Elsewhere a
|
|
13
13
|
* photo answers `avatarNotSupported`, so hide the photo controls instead.
|
|
@@ -26,9 +26,23 @@ async function updateProfile(changes) {
|
|
|
26
26
|
if (token === null) return authError("notAuthenticated", "Nobody is signed in.");
|
|
27
27
|
const form = new FormData();
|
|
28
28
|
if (changes.fullName !== void 0) form.set("fullName", changes.fullName);
|
|
29
|
-
if (changes.avatar === null) form.set("removeAvatar", "true");
|
|
30
29
|
if (changes.avatar) form.set("avatar", changes.avatar);
|
|
31
|
-
|
|
30
|
+
return answer(await makePlatform(sessionConfig().applicationId).updateProfile(token, form));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Removes the signed-in visitor's own photo. Like {@link updateProfile}, it
|
|
34
|
+
* works only where `user.avatarEditable` is true, and answers with the visitor
|
|
35
|
+
* as they are now.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* const result = await auth.removeAvatar()
|
|
39
|
+
*/
|
|
40
|
+
async function removeAvatar() {
|
|
41
|
+
const token = readSessionToken();
|
|
42
|
+
if (token === null) return authError("notAuthenticated", "Nobody is signed in.");
|
|
43
|
+
return answer(await makePlatform(sessionConfig().applicationId).removeAvatar(token));
|
|
44
|
+
}
|
|
45
|
+
function answer(result) {
|
|
32
46
|
if (!result.ok) {
|
|
33
47
|
switch (result.status) {
|
|
34
48
|
case 400: return authError("invalidName", result.message);
|
|
@@ -49,4 +63,4 @@ async function updateProfile(changes) {
|
|
|
49
63
|
}
|
|
50
64
|
|
|
51
65
|
//#endregion
|
|
52
|
-
export { updateProfile };
|
|
66
|
+
export { removeAvatar, updateProfile };
|
package/dist/auth/platform.js
CHANGED
|
@@ -272,6 +272,10 @@ function makePlatform(applicationId) {
|
|
|
272
272
|
token,
|
|
273
273
|
form
|
|
274
274
|
}, userSchema),
|
|
275
|
+
removeAvatar: (token) => request(`/v1/vibe/applications/${applicationId}/users/me/profile/avatar`, {
|
|
276
|
+
method: "DELETE",
|
|
277
|
+
token
|
|
278
|
+
}, userSchema),
|
|
275
279
|
signOut: (token) => request(`/v1/applications/${applicationId}/users/sign-out`, {
|
|
276
280
|
method: "POST",
|
|
277
281
|
token
|
package/dist/auth/server.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { checkPasswordLink, requestPasswordReset, setPasswordWithLink } from "./
|
|
|
6
6
|
import { settings } from "./methods/settings.js";
|
|
7
7
|
import { confirmSignUp, signUp } from "./methods/signup.js";
|
|
8
8
|
import { signInWithGoogle } from "./methods/social.js";
|
|
9
|
-
import { updateProfile } from "./methods/profile.js";
|
|
9
|
+
import { removeAvatar, updateProfile } from "./methods/profile.js";
|
|
10
10
|
import { currentUserRow } from "./current-user-row.js";
|
|
11
11
|
import "@tanstack/react-start/server-only";
|
|
12
12
|
|
|
@@ -36,6 +36,7 @@ declare const auth: {
|
|
|
36
36
|
removeAuthenticator: typeof removeAuthenticator;
|
|
37
37
|
settings: typeof settings;
|
|
38
38
|
updateProfile: typeof updateProfile;
|
|
39
|
+
removeAvatar: typeof removeAvatar;
|
|
39
40
|
currentUserRow: typeof currentUserRow;
|
|
40
41
|
};
|
|
41
42
|
//#endregion
|
package/dist/auth/server.js
CHANGED
|
@@ -6,7 +6,7 @@ import { signIn, signOut } from "./methods/password.js";
|
|
|
6
6
|
import { checkPasswordLink, requestPasswordReset, setPasswordWithLink } from "./methods/passwordLink.js";
|
|
7
7
|
import { confirmSignUp, signUp } from "./methods/signup.js";
|
|
8
8
|
import { signInWithGoogle } from "./methods/social.js";
|
|
9
|
-
import { updateProfile } from "./methods/profile.js";
|
|
9
|
+
import { removeAvatar, updateProfile } from "./methods/profile.js";
|
|
10
10
|
import { currentUserRow } from "./current-user-row.js";
|
|
11
11
|
import "@tanstack/react-start/server-only";
|
|
12
12
|
|
|
@@ -35,6 +35,7 @@ const auth = {
|
|
|
35
35
|
removeAuthenticator,
|
|
36
36
|
settings,
|
|
37
37
|
updateProfile,
|
|
38
|
+
removeAvatar,
|
|
38
39
|
currentUserRow
|
|
39
40
|
};
|
|
40
41
|
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ description: >-
|
|
|
18
18
|
metadata:
|
|
19
19
|
type: sub-skill
|
|
20
20
|
library: softr-sdk
|
|
21
|
-
library_version: 0.0.
|
|
21
|
+
library_version: 0.0.74
|
|
22
22
|
---
|
|
23
23
|
|
|
24
24
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
|
|
@@ -85,7 +85,8 @@ Changing the visitor's own profile:
|
|
|
85
85
|
|
|
86
86
|
| Call | Does |
|
|
87
87
|
| --- | --- |
|
|
88
|
-
| `auth.updateProfile({ fullName?, avatar? })` | Changes their name, their photo, or both
|
|
88
|
+
| `auth.updateProfile({ fullName?, avatar? })` | Changes their name, their photo, or both |
|
|
89
|
+
| `auth.removeAvatar()` | Removes their photo |
|
|
89
90
|
|
|
90
91
|
## Setup
|
|
91
92
|
|
|
@@ -461,7 +462,7 @@ After a reset, enrol the new app with `startAuthenticatorSetup` and `confirmAuth
|
|
|
461
462
|
```ts
|
|
462
463
|
const result = await auth.updateProfile({ fullName: 'Ann Lee' })
|
|
463
464
|
const result = await auth.updateProfile({ avatar: file }) // a File from an <input type="file">
|
|
464
|
-
const result = await auth.
|
|
465
|
+
const result = await auth.removeAvatar() // removes the photo
|
|
465
466
|
```
|
|
466
467
|
|
|
467
468
|
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`.
|
|
@@ -12,7 +12,7 @@ description: >-
|
|
|
12
12
|
metadata:
|
|
13
13
|
type: sub-skill
|
|
14
14
|
library: softr-sdk
|
|
15
|
-
library_version: 0.0.
|
|
15
|
+
library_version: 0.0.74
|
|
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.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 0.0.
|
|
13
|
+
library_version: 0.0.74
|
|
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.
|
|
13
|
+
library_version: 0.0.74
|
|
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.
|
|
12
|
+
library_version: 0.0.74
|
|
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.
|
|
@@ -11,7 +11,7 @@ description: >-
|
|
|
11
11
|
metadata:
|
|
12
12
|
type: sub-skill
|
|
13
13
|
library: softr-sdk
|
|
14
|
-
library_version: 0.0.
|
|
14
|
+
library_version: 0.0.74
|
|
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.
|
|
16
|
+
library_version: 0.0.74
|
|
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.
|
|
12
|
+
library_version: 0.0.74
|
|
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.
|