@better-auth-ui/core 1.6.8 → 1.6.9
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/config/additional-fields-config.js +37 -25
- package/dist/config/auth-config.d.ts +9 -9
- package/dist/config/auth-config.js +33 -31
- package/dist/config/avatar-config.js +1 -0
- package/dist/config/email-and-password-config.js +1 -0
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +4 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -11
- package/dist/lib/auth-mutation-keys.d.ts +9 -20
- package/dist/lib/auth-mutation-keys.js +69 -56
- package/dist/lib/auth-plugin.d.ts +6 -7
- package/dist/lib/auth-plugin.js +1 -0
- package/dist/lib/auth-query-keys.d.ts +6 -6
- package/dist/lib/auth-query-keys.js +41 -38
- package/dist/lib/base-paths.js +4 -7
- package/dist/lib/create-auth-plugin.d.ts +5 -21
- package/dist/lib/create-auth-plugin.js +22 -8
- package/dist/lib/deep-partial.js +1 -0
- package/dist/lib/localization.d.ts +2 -2
- package/dist/lib/localization.js +149 -80
- package/dist/lib/provider-names.d.ts +1 -1
- package/dist/lib/provider-names.js +48 -41
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +111 -43
- package/dist/lib/view-paths.d.ts +0 -4
- package/dist/lib/view-paths.js +12 -15
- package/dist/plugins/api-key/api-key-localization.js +23 -15
- package/dist/plugins/api-key/api-key-mutation-keys.d.ts +4 -2
- package/dist/plugins/api-key/api-key-mutation-keys.js +10 -14
- package/dist/plugins/api-key/api-key-plugin.d.ts +24 -3
- package/dist/plugins/api-key/api-key-plugin.js +6 -9
- package/dist/plugins/api-key/api-key-query-keys.d.ts +6 -0
- package/dist/plugins/api-key/api-key-query-keys.js +7 -0
- package/dist/plugins/delete-user/delete-user-localization.d.ts +3 -3
- package/dist/plugins/delete-user/delete-user-localization.js +9 -8
- package/dist/plugins/delete-user/delete-user-mutation-keys.d.ts +7 -0
- package/dist/plugins/delete-user/delete-user-mutation-keys.js +7 -0
- package/dist/plugins/delete-user/delete-user-plugin.d.ts +5 -5
- package/dist/plugins/delete-user/delete-user-plugin.js +5 -11
- package/dist/plugins/magic-link/magic-link-localization.js +7 -7
- package/dist/plugins/magic-link/magic-link-mutation-keys.js +17 -8
- package/dist/plugins/magic-link/magic-link-plugin.d.ts +3 -3
- package/dist/plugins/magic-link/magic-link-plugin.js +7 -11
- package/dist/plugins/multi-session/multi-session-localization.js +9 -8
- package/dist/plugins/multi-session/multi-session-mutation-keys.d.ts +11 -0
- package/dist/plugins/multi-session/multi-session-mutation-keys.js +11 -0
- package/dist/plugins/multi-session/multi-session-plugin.d.ts +3 -3
- package/dist/plugins/multi-session/multi-session-plugin.js +5 -9
- package/dist/plugins/multi-session/multi-session-query-keys.d.ts +6 -0
- package/dist/plugins/multi-session/multi-session-query-keys.js +7 -0
- package/dist/plugins/organization/organization-localization.d.ts +115 -0
- package/dist/plugins/organization/organization-localization.js +114 -0
- package/dist/plugins/organization/organization-mutation-keys.d.ts +40 -0
- package/dist/plugins/organization/organization-mutation-keys.js +40 -0
- package/dist/plugins/organization/organization-plugin.d.ts +152 -0
- package/dist/plugins/organization/organization-plugin.js +35 -0
- package/dist/plugins/organization/organization-query-keys.d.ts +40 -0
- package/dist/plugins/organization/organization-query-keys.js +54 -0
- package/dist/plugins/organization/organization-view-paths.d.ts +19 -0
- package/dist/plugins/organization/organization-view-paths.js +1 -0
- package/dist/plugins/passkey/passkey-localization.js +19 -13
- package/dist/plugins/passkey/passkey-mutation-keys.js +14 -19
- package/dist/plugins/passkey/passkey-plugin.d.ts +3 -3
- package/dist/plugins/passkey/passkey-plugin.js +5 -9
- package/dist/plugins/passkey/passkey-query-keys.d.ts +6 -0
- package/dist/plugins/passkey/passkey-query-keys.js +7 -0
- package/dist/plugins/theme/theme-localization.js +11 -9
- package/dist/plugins/theme/theme-plugin.d.ts +3 -3
- package/dist/plugins/theme/theme-plugin.js +7 -17
- package/dist/plugins/username/username-localization.js +15 -11
- package/dist/plugins/username/username-mutation-keys.d.ts +17 -0
- package/dist/plugins/username/username-mutation-keys.js +17 -0
- package/dist/plugins/username/username-plugin.d.ts +4 -4
- package/dist/plugins/username/username-plugin.js +35 -32
- package/dist/plugins.d.ts +28 -0
- package/dist/plugins.js +28 -18
- package/package.json +8 -7
- package/src/config/auth-config.ts +1 -1
- package/src/lib/auth-mutation-keys.ts +11 -24
- package/src/lib/auth-plugin.ts +4 -5
- package/src/lib/auth-query-keys.ts +6 -23
- package/src/lib/create-auth-plugin.ts +9 -26
- package/src/lib/localization.ts +4 -4
- package/src/lib/view-paths.ts +0 -4
- package/src/plugins/api-key/api-key-mutation-keys.ts +4 -2
- package/src/plugins/api-key/api-key-plugin.ts +22 -1
- package/src/plugins/api-key/api-key-query-keys.ts +13 -0
- package/src/plugins/delete-user/delete-user-localization.ts +3 -3
- package/src/plugins/delete-user/delete-user-mutation-keys.ts +7 -0
- package/src/plugins/multi-session/multi-session-mutation-keys.ts +11 -0
- package/src/plugins/multi-session/multi-session-query-keys.ts +13 -0
- package/src/plugins/organization/organization-localization.ts +123 -0
- package/src/plugins/organization/organization-mutation-keys.ts +52 -0
- package/src/plugins/organization/organization-plugin.ts +112 -0
- package/src/plugins/organization/organization-query-keys.ts +86 -0
- package/src/plugins/organization/organization-view-paths.ts +20 -0
- package/src/plugins/passkey/passkey-query-keys.ts +13 -0
- package/src/plugins/username/username-mutation-keys.ts +17 -0
- package/src/plugins.ts +28 -0
- package/dist/plugins/index.d.ts +0 -17
- package/src/plugins/index.ts +0 -17
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hierarchical mutation key factory for organization-related mutations.
|
|
3
|
+
*
|
|
4
|
+
* Mutation keys are mostly used for `useIsMutating` and global
|
|
5
|
+
* `MutationCache` observers (e.g. toast handling), so the keys are static
|
|
6
|
+
* tuples rather than parameterised factories. Each grouping exposes an
|
|
7
|
+
* `all` prefix so consumers can match a whole feature at once:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* useIsMutating({ mutationKey: organizationMutationKeys.all })
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const organizationMutationKeys: {
|
|
14
|
+
/** Root key for every organization mutation. */
|
|
15
|
+
readonly all: readonly ["auth", "organization"];
|
|
16
|
+
/** Key for `organization.create`. */
|
|
17
|
+
readonly create: readonly ["auth", "organization", "create"];
|
|
18
|
+
/** Key for `organization.delete`. */
|
|
19
|
+
readonly delete: readonly ["auth", "organization", "delete"];
|
|
20
|
+
/** Key for `organization.update`. */
|
|
21
|
+
readonly update: readonly ["auth", "organization", "update"];
|
|
22
|
+
/** Key for `organization.setActive`. */
|
|
23
|
+
readonly setActive: readonly ["auth", "organization", "setActive"];
|
|
24
|
+
/** Key for `organization.inviteMember`. */
|
|
25
|
+
readonly inviteMember: readonly ["auth", "organization", "inviteMember"];
|
|
26
|
+
/** Key for `organization.removeMember`. */
|
|
27
|
+
readonly removeMember: readonly ["auth", "organization", "removeMember"];
|
|
28
|
+
/** Key for `organization.leave`. */
|
|
29
|
+
readonly leave: readonly ["auth", "organization", "leave"];
|
|
30
|
+
/** Key for `organization.updateMemberRole`. */
|
|
31
|
+
readonly updateMemberRole: readonly ["auth", "organization", "updateMemberRole"];
|
|
32
|
+
/** Key for `organization.acceptInvitation`. */
|
|
33
|
+
readonly acceptInvitation: readonly ["auth", "organization", "acceptInvitation"];
|
|
34
|
+
/** Key for `organization.cancelInvitation`. */
|
|
35
|
+
readonly cancelInvitation: readonly ["auth", "organization", "cancelInvitation"];
|
|
36
|
+
/** Key for `organization.rejectInvitation` (invitee declines). */
|
|
37
|
+
readonly rejectInvitation: readonly ["auth", "organization", "rejectInvitation"];
|
|
38
|
+
/** Key for `organization.checkSlug`. */
|
|
39
|
+
readonly checkSlug: readonly ["auth", "organization", "checkSlug"];
|
|
40
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hierarchical mutation key factory for organization-related mutations.
|
|
3
|
+
*
|
|
4
|
+
* Mutation keys are mostly used for `useIsMutating` and global
|
|
5
|
+
* `MutationCache` observers (e.g. toast handling), so the keys are static
|
|
6
|
+
* tuples rather than parameterised factories. Each grouping exposes an
|
|
7
|
+
* `all` prefix so consumers can match a whole feature at once:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* useIsMutating({ mutationKey: organizationMutationKeys.all })
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export const organizationMutationKeys = {
|
|
14
|
+
/** Root key for every organization mutation. */
|
|
15
|
+
all: ["auth", "organization"],
|
|
16
|
+
/** Key for `organization.create`. */
|
|
17
|
+
create: ["auth", "organization", "create"],
|
|
18
|
+
/** Key for `organization.delete`. */
|
|
19
|
+
delete: ["auth", "organization", "delete"],
|
|
20
|
+
/** Key for `organization.update`. */
|
|
21
|
+
update: ["auth", "organization", "update"],
|
|
22
|
+
/** Key for `organization.setActive`. */
|
|
23
|
+
setActive: ["auth", "organization", "setActive"],
|
|
24
|
+
/** Key for `organization.inviteMember`. */
|
|
25
|
+
inviteMember: ["auth", "organization", "inviteMember"],
|
|
26
|
+
/** Key for `organization.removeMember`. */
|
|
27
|
+
removeMember: ["auth", "organization", "removeMember"],
|
|
28
|
+
/** Key for `organization.leave`. */
|
|
29
|
+
leave: ["auth", "organization", "leave"],
|
|
30
|
+
/** Key for `organization.updateMemberRole`. */
|
|
31
|
+
updateMemberRole: ["auth", "organization", "updateMemberRole"],
|
|
32
|
+
/** Key for `organization.acceptInvitation`. */
|
|
33
|
+
acceptInvitation: ["auth", "organization", "acceptInvitation"],
|
|
34
|
+
/** Key for `organization.cancelInvitation`. */
|
|
35
|
+
cancelInvitation: ["auth", "organization", "cancelInvitation"],
|
|
36
|
+
/** Key for `organization.rejectInvitation` (invitee declines). */
|
|
37
|
+
rejectInvitation: ["auth", "organization", "rejectInvitation"],
|
|
38
|
+
/** Key for `organization.checkSlug`. */
|
|
39
|
+
checkSlug: ["auth", "organization", "checkSlug"]
|
|
40
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { AvatarConfig } from "../../config/avatar-config";
|
|
2
|
+
import { type OrganizationLocalization } from "./organization-localization";
|
|
3
|
+
import type { OrganizationViewPaths } from "./organization-view-paths";
|
|
4
|
+
declare module "../../lib/view-paths" {
|
|
5
|
+
/** Widens `SettingsViewPaths` by adding the `"organizations"` path when this plugin is imported. */
|
|
6
|
+
interface SettingsViewPaths {
|
|
7
|
+
/** @default "organizations" */
|
|
8
|
+
organizations?: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
declare module "../../lib/auth-plugin" {
|
|
12
|
+
interface AuthPluginViewPaths {
|
|
13
|
+
organization?: Partial<OrganizationViewPaths>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export type OrganizationPluginOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* Whether to call `organization.checkSlug` when entering an organization slug.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
checkSlug?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Override the plugin's default localization strings.
|
|
24
|
+
* @remarks `OrganizationLocalization`
|
|
25
|
+
*/
|
|
26
|
+
localization?: Partial<OrganizationLocalization>;
|
|
27
|
+
/**
|
|
28
|
+
* Override URL segments contributed by this plugin.
|
|
29
|
+
*
|
|
30
|
+
* - `settings.organizations` — segment for the organizations settings view (default `"organizations"`).
|
|
31
|
+
* - `organization.settings` — segment for the `/organization/...` profile and danger zone tab (default `"settings"`).
|
|
32
|
+
* - `organization.people` — segment for the `/organization/...` members and invitations tab (default `"people"`).
|
|
33
|
+
*/
|
|
34
|
+
viewPaths?: {
|
|
35
|
+
settings?: {
|
|
36
|
+
/** @default "organizations" */
|
|
37
|
+
organizations?: string;
|
|
38
|
+
};
|
|
39
|
+
organization?: Partial<OrganizationViewPaths>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Organization logo upload, optimization, and deletion configuration.
|
|
43
|
+
* Same shape as {@link AvatarConfig} used for user avatars (`AuthConfig.avatar`).
|
|
44
|
+
* @remarks `AvatarConfig`
|
|
45
|
+
* @default { enabled: true, resize: resizeAvatar, size: 256, extension: "png" }
|
|
46
|
+
*/
|
|
47
|
+
logo?: Partial<AvatarConfig>;
|
|
48
|
+
/**
|
|
49
|
+
* Map of role keys to display labels. When omitted, defaults to localized
|
|
50
|
+
* labels for `owner`, `admin`, and `member` (from `localization.owner`
|
|
51
|
+
* etc.) plus {@link OrganizationPluginOptions.additionalRoles}. When set,
|
|
52
|
+
* replaces that default map entirely; use {@link OrganizationPluginOptions.additionalRoles}
|
|
53
|
+
* to add more labels on top. Looked up at render time via `roles?.[role]`.
|
|
54
|
+
* @remarks `Record<string, string>`
|
|
55
|
+
*/
|
|
56
|
+
roles?: Record<string, string>;
|
|
57
|
+
/**
|
|
58
|
+
* Extra role labels merged after the effective role map (either
|
|
59
|
+
* {@link OrganizationPluginOptions.roles} when provided, or the localized
|
|
60
|
+
* defaults). Use this for custom server roles without redefining built-in
|
|
61
|
+
* labels.
|
|
62
|
+
* @remarks `Record<string, string>`
|
|
63
|
+
*/
|
|
64
|
+
additionalRoles?: Record<string, string>;
|
|
65
|
+
slug?: string | null;
|
|
66
|
+
};
|
|
67
|
+
export declare const organizationPlugin: ((options?: OrganizationPluginOptions | undefined) => {
|
|
68
|
+
slug: string | null | undefined;
|
|
69
|
+
checkSlug: boolean;
|
|
70
|
+
localization: {
|
|
71
|
+
accept: string;
|
|
72
|
+
accepted: string;
|
|
73
|
+
actions: string;
|
|
74
|
+
admin: string;
|
|
75
|
+
all: string;
|
|
76
|
+
canceled: string;
|
|
77
|
+
cancelInvitation: string;
|
|
78
|
+
changeLogo: string;
|
|
79
|
+
changeMemberRole: string;
|
|
80
|
+
clear: string;
|
|
81
|
+
createOrganization: string;
|
|
82
|
+
deleteLogo: string;
|
|
83
|
+
deleteOrganization: string;
|
|
84
|
+
deleteOrganizationDescription: string;
|
|
85
|
+
invitations: string;
|
|
86
|
+
invitedAt: string;
|
|
87
|
+
inviteMember: string;
|
|
88
|
+
inviteMemberSuccess: string;
|
|
89
|
+
inviteMemberDescription: string;
|
|
90
|
+
leftOrganization: string;
|
|
91
|
+
leaveOrganization: string;
|
|
92
|
+
leaveOrganizationDescription: string;
|
|
93
|
+
logo: string;
|
|
94
|
+
logoChangedSuccess: string;
|
|
95
|
+
logoDeletedSuccess: string;
|
|
96
|
+
manage: string;
|
|
97
|
+
member: string;
|
|
98
|
+
memberRemoved: string;
|
|
99
|
+
memberRoleUpdated: string;
|
|
100
|
+
members: string;
|
|
101
|
+
people: string;
|
|
102
|
+
name: string;
|
|
103
|
+
namePlaceholder: string;
|
|
104
|
+
noInvitations: string;
|
|
105
|
+
noOrganizations: string;
|
|
106
|
+
organization: string;
|
|
107
|
+
organizationDeleted: string;
|
|
108
|
+
organizationInvitationsEmptyDescription: string;
|
|
109
|
+
organizations: string;
|
|
110
|
+
organizationsDescription: string;
|
|
111
|
+
organizationProfile: string;
|
|
112
|
+
organizationUpdatedSuccess: string;
|
|
113
|
+
owner: string;
|
|
114
|
+
pending: string;
|
|
115
|
+
personalAccount: string;
|
|
116
|
+
rejected: string;
|
|
117
|
+
rejectInvitation: string;
|
|
118
|
+
removeMember: string;
|
|
119
|
+
removeMemberWarning: string;
|
|
120
|
+
role: string;
|
|
121
|
+
search: string;
|
|
122
|
+
slug: string;
|
|
123
|
+
slugPlaceholder: string;
|
|
124
|
+
status: string;
|
|
125
|
+
uploadLogo: string;
|
|
126
|
+
userInvitationsEmptyDescription: string;
|
|
127
|
+
};
|
|
128
|
+
logo: {
|
|
129
|
+
delete?: (url: string) => Promise<void>;
|
|
130
|
+
enabled: boolean;
|
|
131
|
+
extension: "png" | "jpg" | "webp" | "inherit";
|
|
132
|
+
resize: (file: File, size?: number, extension?: "png" | "jpg" | "webp" | "inherit") => Promise<File>;
|
|
133
|
+
size: number;
|
|
134
|
+
upload?: (file: File) => Promise<string>;
|
|
135
|
+
};
|
|
136
|
+
roles: {
|
|
137
|
+
[x: string]: string;
|
|
138
|
+
};
|
|
139
|
+
viewPaths: {
|
|
140
|
+
settings: {
|
|
141
|
+
organizations: string;
|
|
142
|
+
};
|
|
143
|
+
organization: {
|
|
144
|
+
settings: string;
|
|
145
|
+
people: string;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
} & {
|
|
149
|
+
id: "organization";
|
|
150
|
+
}) & {
|
|
151
|
+
id: "organization";
|
|
152
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defaultAuthConfig } from "../../config";
|
|
2
|
+
import { createAuthPlugin } from "../../lib/create-auth-plugin";
|
|
3
|
+
import { organizationLocalization } from "./organization-localization";
|
|
4
|
+
export const organizationPlugin = createAuthPlugin("organization", (options = {}) => {
|
|
5
|
+
const localization = {
|
|
6
|
+
...organizationLocalization,
|
|
7
|
+
...options.localization
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
slug: options.slug,
|
|
11
|
+
checkSlug: options.checkSlug ?? true,
|
|
12
|
+
localization,
|
|
13
|
+
logo: {
|
|
14
|
+
...defaultAuthConfig.avatar,
|
|
15
|
+
...options.logo
|
|
16
|
+
},
|
|
17
|
+
roles: {
|
|
18
|
+
...(options.roles ?? {
|
|
19
|
+
owner: localization.owner,
|
|
20
|
+
admin: localization.admin,
|
|
21
|
+
member: localization.member
|
|
22
|
+
}),
|
|
23
|
+
...options.additionalRoles
|
|
24
|
+
},
|
|
25
|
+
viewPaths: {
|
|
26
|
+
settings: {
|
|
27
|
+
organizations: options.viewPaths?.settings?.organizations ?? "organizations"
|
|
28
|
+
},
|
|
29
|
+
organization: {
|
|
30
|
+
settings: options.viewPaths?.organization?.settings ?? "settings",
|
|
31
|
+
people: options.viewPaths?.organization?.people ?? "people"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Query key factory for organization queries, scoped per user. */
|
|
2
|
+
export declare const organizationQueryKeys: {
|
|
3
|
+
readonly all: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization"];
|
|
4
|
+
readonly lists: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "list"];
|
|
5
|
+
readonly list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "organization", "list", NonNullable<TQuery> | null];
|
|
6
|
+
readonly fullDetails: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "fullDetails"];
|
|
7
|
+
readonly fullDetail: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "organization", "fullDetails", NonNullable<TQuery> | null];
|
|
8
|
+
/**
|
|
9
|
+
* Prefix for every active-organization cache entry (used for invalidation
|
|
10
|
+
* across slug-partitioned variants).
|
|
11
|
+
*/
|
|
12
|
+
readonly activeOrganizations: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "active"];
|
|
13
|
+
/**
|
|
14
|
+
* Cache entry for the currently active organization. Holds a {@link
|
|
15
|
+
* ListOrganization}-shaped value — distinct from `fullDetail`, which
|
|
16
|
+
* carries members and invitations — so `setActive`'s optimistic update
|
|
17
|
+
* (which can only produce a list-shaped org) doesn't corrupt the full
|
|
18
|
+
* cache.
|
|
19
|
+
*/
|
|
20
|
+
readonly activeOrganization: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "organization", "active", NonNullable<TQuery> | null];
|
|
21
|
+
readonly members: {
|
|
22
|
+
readonly all: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "members"];
|
|
23
|
+
readonly lists: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "members", "list"];
|
|
24
|
+
readonly list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "organization", "members", "list", NonNullable<TQuery> | null];
|
|
25
|
+
};
|
|
26
|
+
readonly invitations: {
|
|
27
|
+
readonly all: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "invitations"];
|
|
28
|
+
readonly lists: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "invitations", "list"];
|
|
29
|
+
readonly list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "organization", "invitations", "list", NonNullable<TQuery> | null];
|
|
30
|
+
};
|
|
31
|
+
readonly userInvitations: {
|
|
32
|
+
readonly all: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "userInvitations"];
|
|
33
|
+
readonly lists: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "userInvitations", "list"];
|
|
34
|
+
readonly list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "organization", "userInvitations", "list", NonNullable<TQuery> | null];
|
|
35
|
+
};
|
|
36
|
+
readonly permissions: {
|
|
37
|
+
readonly all: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "organization", "permissions"];
|
|
38
|
+
readonly has: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "organization", "permissions", "has", NonNullable<TQuery> | null];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { authQueryKeys } from "../../lib/auth-query-keys";
|
|
2
|
+
/** Query key factory for organization queries, scoped per user. */
|
|
3
|
+
export const organizationQueryKeys = {
|
|
4
|
+
all: (userId) => [...authQueryKeys.user(userId), "organization"],
|
|
5
|
+
lists: (userId) => [...organizationQueryKeys.all(userId), "list"],
|
|
6
|
+
list: (userId, query) => [...organizationQueryKeys.lists(userId), query ?? null],
|
|
7
|
+
fullDetails: (userId) => [...organizationQueryKeys.all(userId), "fullDetails"],
|
|
8
|
+
fullDetail: (userId, query) => [...organizationQueryKeys.fullDetails(userId), query ?? null],
|
|
9
|
+
/**
|
|
10
|
+
* Prefix for every active-organization cache entry (used for invalidation
|
|
11
|
+
* across slug-partitioned variants).
|
|
12
|
+
*/
|
|
13
|
+
activeOrganizations: (userId) => [...organizationQueryKeys.all(userId), "active"],
|
|
14
|
+
/**
|
|
15
|
+
* Cache entry for the currently active organization. Holds a {@link
|
|
16
|
+
* ListOrganization}-shaped value — distinct from `fullDetail`, which
|
|
17
|
+
* carries members and invitations — so `setActive`'s optimistic update
|
|
18
|
+
* (which can only produce a list-shaped org) doesn't corrupt the full
|
|
19
|
+
* cache.
|
|
20
|
+
*/
|
|
21
|
+
activeOrganization: (userId, query) => [
|
|
22
|
+
...organizationQueryKeys.activeOrganizations(userId),
|
|
23
|
+
query ?? null
|
|
24
|
+
],
|
|
25
|
+
members: {
|
|
26
|
+
all: (userId) => [...organizationQueryKeys.all(userId), "members"],
|
|
27
|
+
lists: (userId) => [...organizationQueryKeys.members.all(userId), "list"],
|
|
28
|
+
list: (userId, query) => [...organizationQueryKeys.members.lists(userId), query ?? null]
|
|
29
|
+
},
|
|
30
|
+
invitations: {
|
|
31
|
+
all: (userId) => [...organizationQueryKeys.all(userId), "invitations"],
|
|
32
|
+
lists: (userId) => [...organizationQueryKeys.invitations.all(userId), "list"],
|
|
33
|
+
list: (userId, query) => [
|
|
34
|
+
...organizationQueryKeys.invitations.lists(userId),
|
|
35
|
+
query ?? null
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
userInvitations: {
|
|
39
|
+
all: (userId) => [...organizationQueryKeys.all(userId), "userInvitations"],
|
|
40
|
+
lists: (userId) => [...organizationQueryKeys.userInvitations.all(userId), "list"],
|
|
41
|
+
list: (userId, query) => [
|
|
42
|
+
...organizationQueryKeys.userInvitations.lists(userId),
|
|
43
|
+
query ?? null
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
permissions: {
|
|
47
|
+
all: (userId) => [...organizationQueryKeys.all(userId), "permissions"],
|
|
48
|
+
has: (userId, query) => [
|
|
49
|
+
...organizationQueryKeys.permissions.all(userId),
|
|
50
|
+
"has",
|
|
51
|
+
query ?? null
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path segments under `/organization/...` contributed by `organizationPlugin`.
|
|
3
|
+
*
|
|
4
|
+
* Read at runtime via `useAuthPlugin(organizationPlugin).viewPaths.organization`.
|
|
5
|
+
*/
|
|
6
|
+
export interface OrganizationViewPaths {
|
|
7
|
+
/**
|
|
8
|
+
* Path segment for organization profile and danger zone
|
|
9
|
+
* @default "settings"
|
|
10
|
+
*/
|
|
11
|
+
settings: string;
|
|
12
|
+
/**
|
|
13
|
+
* Path segment for members and invitations
|
|
14
|
+
* @default "people"
|
|
15
|
+
*/
|
|
16
|
+
people: string;
|
|
17
|
+
}
|
|
18
|
+
/** Valid organization management tab / route key. */
|
|
19
|
+
export type OrganizationView = keyof OrganizationViewPaths;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export const passkeyLocalization = {
|
|
2
|
+
/** @remarks `"Passkey"` */
|
|
3
|
+
passkey: "Passkey",
|
|
4
|
+
/** @remarks `"Add passkey"` */
|
|
5
|
+
addPasskey: "Add passkey",
|
|
6
|
+
/** @remarks `"Delete passkey {{name}}"` */
|
|
7
|
+
deletePasskey: "Delete passkey {{name}}",
|
|
8
|
+
/** @remarks `"Delete passkey"` */
|
|
9
|
+
deletePasskeyTitle: "Delete passkey",
|
|
10
|
+
/** @remarks `"This action cannot be undone. You will need to add this passkey again before you can use it to sign in."` */
|
|
11
|
+
deletePasskeyWarning: "This action cannot be undone. You will need to add this passkey again before you can use it to sign in.",
|
|
12
|
+
/** @remarks `"Passkeys"` */
|
|
13
|
+
passkeys: "Passkeys",
|
|
14
|
+
/** @remarks `"Create a passkey to securely access your account."` */
|
|
15
|
+
passkeysDescription: "Create a passkey to securely access your account.",
|
|
16
|
+
/** @remarks `"No passkeys"` */
|
|
17
|
+
noPasskeys: "No passkeys",
|
|
18
|
+
/** @remarks `"Name"` */
|
|
19
|
+
name: "Name"
|
|
12
20
|
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { e as passkeyLocalization };
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"passkey",
|
|
16
|
-
"deletePasskey"
|
|
17
|
-
]
|
|
1
|
+
/**
|
|
2
|
+
* Mutation keys contributed by the passkey plugin.
|
|
3
|
+
*
|
|
4
|
+
* `signIn` is kept under the shared `["auth", "signIn", ...]` namespace so
|
|
5
|
+
* consumers can match the whole sign-in surface with
|
|
6
|
+
* `useIsMutating({ mutationKey: ["auth", "signIn"] })`.
|
|
7
|
+
*/
|
|
8
|
+
export const passkeyMutationKeys = {
|
|
9
|
+
/** Key for `signIn.passkey`. */
|
|
10
|
+
signIn: ["auth", "signIn", "passkey"],
|
|
11
|
+
/** Key for `passkey.addPasskey`. */
|
|
12
|
+
addPasskey: ["auth", "passkey", "addPasskey"],
|
|
13
|
+
/** Key for `passkey.deletePasskey`. */
|
|
14
|
+
deletePasskey: ["auth", "passkey", "deletePasskey"]
|
|
18
15
|
};
|
|
19
|
-
//#endregion
|
|
20
|
-
export { e as passkeyMutationKeys };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PasskeyLocalization } from
|
|
1
|
+
import { type PasskeyLocalization } from "./passkey-localization";
|
|
2
2
|
export type PasskeyPluginOptions = {
|
|
3
3
|
/**
|
|
4
4
|
* Override the plugin's default localization strings.
|
|
@@ -6,7 +6,7 @@ export type PasskeyPluginOptions = {
|
|
|
6
6
|
*/
|
|
7
7
|
localization?: Partial<PasskeyLocalization>;
|
|
8
8
|
};
|
|
9
|
-
export declare const passkeyPlugin: ((options?: PasskeyPluginOptions | undefined) =>
|
|
9
|
+
export declare const passkeyPlugin: ((options?: PasskeyPluginOptions | undefined) => {
|
|
10
10
|
localization: {
|
|
11
11
|
passkey: string;
|
|
12
12
|
addPasskey: string;
|
|
@@ -18,7 +18,7 @@ export declare const passkeyPlugin: ((options?: PasskeyPluginOptions | undefined
|
|
|
18
18
|
noPasskeys: string;
|
|
19
19
|
name: string;
|
|
20
20
|
};
|
|
21
|
-
}
|
|
21
|
+
} & {
|
|
22
22
|
id: "passkey";
|
|
23
23
|
}) & {
|
|
24
24
|
id: "passkey";
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { createAuthPlugin
|
|
2
|
-
import { passkeyLocalization
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
...e.localization
|
|
7
|
-
} }));
|
|
8
|
-
//#endregion
|
|
9
|
-
export { n as passkeyPlugin };
|
|
1
|
+
import { createAuthPlugin } from "../../lib/create-auth-plugin";
|
|
2
|
+
import { passkeyLocalization } from "./passkey-localization";
|
|
3
|
+
export const passkeyPlugin = createAuthPlugin("passkey", (options = {}) => ({
|
|
4
|
+
localization: { ...passkeyLocalization, ...options.localization }
|
|
5
|
+
}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Query key factory for passkey queries, scoped per user. */
|
|
2
|
+
export declare const passkeyQueryKeys: {
|
|
3
|
+
readonly all: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "passkey"];
|
|
4
|
+
readonly lists: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "passkey", "list"];
|
|
5
|
+
readonly list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "passkey", "list", NonNullable<TQuery> | null];
|
|
6
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { authQueryKeys } from "../../lib/auth-query-keys";
|
|
2
|
+
/** Query key factory for passkey queries, scoped per user. */
|
|
3
|
+
export const passkeyQueryKeys = {
|
|
4
|
+
all: (userId) => [...authQueryKeys.user(userId), "passkey"],
|
|
5
|
+
lists: (userId) => [...passkeyQueryKeys.all(userId), "list"],
|
|
6
|
+
list: (userId, query) => [...passkeyQueryKeys.lists(userId), query ?? null]
|
|
7
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export const themeLocalization = {
|
|
2
|
+
/** @remarks `"Appearance"` */
|
|
3
|
+
appearance: "Appearance",
|
|
4
|
+
/** @remarks `"Theme"` */
|
|
5
|
+
theme: "Theme",
|
|
6
|
+
/** @remarks `"System"` */
|
|
7
|
+
system: "System",
|
|
8
|
+
/** @remarks `"Light"` */
|
|
9
|
+
light: "Light",
|
|
10
|
+
/** @remarks `"Dark"` */
|
|
11
|
+
dark: "Dark"
|
|
8
12
|
};
|
|
9
|
-
//#endregion
|
|
10
|
-
export { e as themeLocalization };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThemeLocalization } from
|
|
1
|
+
import { type ThemeLocalization } from "./theme-localization";
|
|
2
2
|
export type ThemePluginOptions = {
|
|
3
3
|
/**
|
|
4
4
|
* Override the plugin's default localization strings.
|
|
@@ -19,7 +19,7 @@ export type ThemePluginOptions = {
|
|
|
19
19
|
*/
|
|
20
20
|
themes?: string[];
|
|
21
21
|
};
|
|
22
|
-
export declare const themePlugin: ((options: ThemePluginOptions) =>
|
|
22
|
+
export declare const themePlugin: ((options: ThemePluginOptions) => {
|
|
23
23
|
localization: {
|
|
24
24
|
appearance: string;
|
|
25
25
|
theme: string;
|
|
@@ -30,7 +30,7 @@ export declare const themePlugin: ((options: ThemePluginOptions) => Omit<{
|
|
|
30
30
|
theme: string;
|
|
31
31
|
setTheme: (theme: string) => void;
|
|
32
32
|
themes: string[];
|
|
33
|
-
}
|
|
33
|
+
} & {
|
|
34
34
|
id: "theme";
|
|
35
35
|
}) & {
|
|
36
36
|
id: "theme";
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { createAuthPlugin
|
|
2
|
-
import { themeLocalization
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
theme: e.theme ?? "system",
|
|
10
|
-
setTheme: e.setTheme,
|
|
11
|
-
themes: e.themes ?? [
|
|
12
|
-
"system",
|
|
13
|
-
"light",
|
|
14
|
-
"dark"
|
|
15
|
-
]
|
|
1
|
+
import { createAuthPlugin } from "../../lib/create-auth-plugin";
|
|
2
|
+
import { themeLocalization } from "./theme-localization";
|
|
3
|
+
export const themePlugin = createAuthPlugin("theme", (options) => ({
|
|
4
|
+
localization: { ...themeLocalization, ...options.localization },
|
|
5
|
+
theme: options.theme ?? "system",
|
|
6
|
+
setTheme: options.setTheme,
|
|
7
|
+
themes: options.themes ?? ["system", "light", "dark"]
|
|
16
8
|
}));
|
|
17
|
-
//#endregion
|
|
18
|
-
export { n as themePlugin };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export const usernameLocalization = {
|
|
2
|
+
/** @remarks `"Username"` */
|
|
3
|
+
username: "Username",
|
|
4
|
+
/** @remarks `"Enter your username"` */
|
|
5
|
+
usernamePlaceholder: "Enter your username",
|
|
6
|
+
/** @remarks `"Enter your username or email"` */
|
|
7
|
+
usernameOrEmailPlaceholder: "Enter your username or email",
|
|
8
|
+
/** @remarks `"Username is available"` */
|
|
9
|
+
usernameAvailable: "Username is available",
|
|
10
|
+
/** @remarks `"Username is already taken. Please try another."` */
|
|
11
|
+
usernameTaken: "Username is already taken. Please try another.",
|
|
12
|
+
/** @remarks `"Display Username"` */
|
|
13
|
+
displayUsername: "Display Username",
|
|
14
|
+
/** @remarks `"Enter your display username"` */
|
|
15
|
+
displayUsernamePlaceholder: "Enter your display username"
|
|
10
16
|
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { e as usernameLocalization };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutation keys contributed by the username plugin.
|
|
3
|
+
*
|
|
4
|
+
* `signIn` is kept under the shared `["auth", "signIn", ...]` namespace so
|
|
5
|
+
* consumers can match the whole sign-in surface with
|
|
6
|
+
* `useIsMutating({ mutationKey: ["auth", "signIn"] })`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const usernameMutationKeys: {
|
|
9
|
+
/** Key for `signIn.username`. */
|
|
10
|
+
readonly signIn: readonly ["auth", "signIn", "username"];
|
|
11
|
+
/**
|
|
12
|
+
* Key for `isUsernameAvailable`. This is technically a read, but it's
|
|
13
|
+
* exposed via better-auth's mutation surface and lives under the mutation
|
|
14
|
+
* factories for parity with other username flows.
|
|
15
|
+
*/
|
|
16
|
+
readonly isUsernameAvailable: readonly ["auth", "isUsernameAvailable"];
|
|
17
|
+
};
|