@podosoft/podokit-api-client 0.5.0 → 0.6.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/README.md +4 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.js +20 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@ Typed API client for PodoKit backends. Every frontend talks to the backend
|
|
|
4
4
|
through this single entry point — never with a raw `fetch`.
|
|
5
5
|
|
|
6
6
|
- `client.auth` — the [better-auth](https://better-auth.com) client (email/password,
|
|
7
|
-
sessions, and the admin plugin: `listUsers`,
|
|
7
|
+
sessions, the `signupApproved` user field, and the admin plugin: `listUsers`,
|
|
8
|
+
`updateUser`, `banUser`, `setRole`, `listUserSessions`, …).
|
|
8
9
|
- `client.get/post/put/patch/del` — the app's REST endpoints, parsing the standard
|
|
9
10
|
error envelope and throwing `ApiError` on failure.
|
|
10
11
|
|
|
@@ -32,3 +33,5 @@ const session = await api.auth.getSession();
|
|
|
32
33
|
| `credentials` | `include` | Send cookies with requests. |
|
|
33
34
|
|
|
34
35
|
Errors are thrown as `ApiError` (`code`, `message`, `statusCode`, `details`).
|
|
36
|
+
`SIGNUP_APPROVAL_REQUIRED` is re-exported for provider-independent pending-account
|
|
37
|
+
handling.
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface ApiClientOptions {
|
|
|
19
19
|
* for the shape — the backend controller and every SvelteKit loader import it.
|
|
20
20
|
*/
|
|
21
21
|
export type { Capabilities } from "@podosoft/podokit-contracts";
|
|
22
|
+
/** Stable better-auth error code returned when a user still needs approval. */
|
|
23
|
+
export declare const SIGNUP_APPROVAL_REQUIRED: "SIGNUP_APPROVAL_REQUIRED";
|
|
22
24
|
/** Error thrown when the API returns the standard error envelope or a non-2xx status. */
|
|
23
25
|
export declare class ApiError extends Error {
|
|
24
26
|
readonly code: string;
|
|
@@ -5227,6 +5229,28 @@ export declare function createApiClient(options?: ApiClientOptions): {
|
|
|
5227
5229
|
ROLE_IS_ASSIGNED_TO_MEMBERS: import("better-auth").RawError<"ROLE_IS_ASSIGNED_TO_MEMBERS">;
|
|
5228
5230
|
INVALID_TEAM_ID: import("better-auth").RawError<"INVALID_TEAM_ID">;
|
|
5229
5231
|
};
|
|
5232
|
+
} | {
|
|
5233
|
+
id: "additional-fields-client";
|
|
5234
|
+
version: string;
|
|
5235
|
+
$InferServerPlugin: {
|
|
5236
|
+
id: "additional-fields-client";
|
|
5237
|
+
version: string;
|
|
5238
|
+
schema: {
|
|
5239
|
+
user: {
|
|
5240
|
+
fields: {
|
|
5241
|
+
signupApproved: {
|
|
5242
|
+
type: "boolean";
|
|
5243
|
+
required: false;
|
|
5244
|
+
defaultValue: true;
|
|
5245
|
+
input: false;
|
|
5246
|
+
};
|
|
5247
|
+
};
|
|
5248
|
+
};
|
|
5249
|
+
session: {
|
|
5250
|
+
fields: {};
|
|
5251
|
+
};
|
|
5252
|
+
};
|
|
5253
|
+
};
|
|
5230
5254
|
})[];
|
|
5231
5255
|
fetchOptions: {
|
|
5232
5256
|
customFetchImpl?: typeof fetch | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createAuthClient } from "better-auth/client";
|
|
2
|
-
import { adminClient, twoFactorClient, magicLinkClient, emailOTPClient, usernameClient, multiSessionClient, phoneNumberClient, organizationClient } from "better-auth/client/plugins";
|
|
2
|
+
import { adminClient, twoFactorClient, magicLinkClient, emailOTPClient, usernameClient, multiSessionClient, phoneNumberClient, organizationClient, inferAdditionalFields } from "better-auth/client/plugins";
|
|
3
3
|
import { apiKeyClient } from "@better-auth/api-key/client";
|
|
4
4
|
import { passkeyClient } from "@better-auth/passkey/client";
|
|
5
|
+
/** Stable better-auth error code returned when a user still needs approval. */
|
|
6
|
+
export const SIGNUP_APPROVAL_REQUIRED = "SIGNUP_APPROVAL_REQUIRED";
|
|
5
7
|
/** Error thrown when the API returns the standard error envelope or a non-2xx status. */
|
|
6
8
|
export class ApiError extends Error {
|
|
7
9
|
code;
|
|
@@ -46,7 +48,23 @@ export function createApiClient(options = {}) {
|
|
|
46
48
|
// (a bare ReturnType<typeof createAuthClient> would drop the plugin augmentation).
|
|
47
49
|
const makeAuthClient = () => createAuthClient({
|
|
48
50
|
baseURL: authOrigin,
|
|
49
|
-
plugins: [
|
|
51
|
+
plugins: [
|
|
52
|
+
adminClient(),
|
|
53
|
+
twoFactorClient(),
|
|
54
|
+
magicLinkClient(),
|
|
55
|
+
emailOTPClient(),
|
|
56
|
+
usernameClient(),
|
|
57
|
+
multiSessionClient(),
|
|
58
|
+
phoneNumberClient(),
|
|
59
|
+
apiKeyClient(),
|
|
60
|
+
passkeyClient(),
|
|
61
|
+
organizationClient(),
|
|
62
|
+
inferAdditionalFields({
|
|
63
|
+
user: {
|
|
64
|
+
signupApproved: { type: "boolean", required: false, defaultValue: true, input: false },
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
50
68
|
fetchOptions: {
|
|
51
69
|
credentials,
|
|
52
70
|
...(options.fetch ? { customFetchImpl: options.fetch } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podosoft/podokit-api-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Typed API client for PodoKit backends: better-auth (auth + admin) plus a standard error-envelope request layer.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"provenance": true
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@podosoft/podokit-contracts": "^0.
|
|
32
|
+
"@podosoft/podokit-contracts": "^0.2.0",
|
|
33
33
|
"better-auth": "^1.6.23",
|
|
34
34
|
"@better-auth/api-key": "^1.6.23",
|
|
35
35
|
"@better-auth/passkey": "^1.6.23"
|