better-auth 1.7.12 → 1.7.13
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/adapters/index.d.mts +5 -10
- package/dist/api/dispatch.d.mts +3 -5
- package/dist/api/dispatch.mjs +6 -4
- package/dist/api/index.d.mts +506 -508
- package/dist/api/index.mjs +35 -34
- package/dist/api/middlewares/authorization.d.mts +15 -12
- package/dist/api/middlewares/authorization.mjs +2 -1
- package/dist/api/middlewares/index.d.mts +2 -1
- package/dist/api/middlewares/origin-check.d.mts +4 -7
- package/dist/api/routes/account.d.mts +11 -15
- package/dist/api/routes/account.mjs +7 -4
- package/dist/api/routes/callback.d.mts +2 -5
- package/dist/api/routes/callback.mjs +4 -2
- package/dist/api/routes/email-verification.d.mts +7 -12
- package/dist/api/routes/error.d.mts +2 -5
- package/dist/api/routes/index.d.mts +2 -1
- package/dist/api/routes/ok.d.mts +2 -5
- package/dist/api/routes/password.d.mts +8 -11
- package/dist/api/routes/password.mjs +3 -2
- package/dist/api/routes/session.d.mts +26 -29
- package/dist/api/routes/sign-in.d.mts +4 -6
- package/dist/api/routes/sign-out.d.mts +2 -5
- package/dist/api/routes/sign-up.d.mts +4 -6
- package/dist/api/routes/update-session.d.mts +4 -6
- package/dist/api/routes/update-user.d.mts +14 -16
- package/dist/api/routes/update-user.mjs +1 -1
- package/dist/api/state/oauth.d.mts +0 -3
- package/dist/api/state/oauth.mjs +2 -1
- package/dist/auth/full.d.mts +3 -4
- package/dist/auth/minimal.d.mts +3 -3
- package/dist/client/broadcast-channel.d.mts +6 -7
- package/dist/client/config.d.mts +15 -19
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +3 -5
- package/dist/client/focus-manager.d.mts +4 -5
- package/dist/client/index.d.mts +8 -7
- package/dist/client/lynx/index.d.mts +6 -7
- package/dist/client/lynx/index.mjs +3 -2
- package/dist/client/lynx/lynx-store.d.mts +3 -4
- package/dist/client/online-manager.d.mts +4 -5
- package/dist/client/parser.d.mts +9 -5
- package/dist/client/path-to-object.d.mts +13 -14
- package/dist/client/plugins/index.d.mts +1 -1
- package/dist/client/plugins/infer-plugin.d.mts +2 -4
- package/dist/client/query.d.mts +4 -6
- package/dist/client/react/index.d.mts +6 -7
- package/dist/client/react/index.mjs +3 -2
- package/dist/client/react/react-store.d.mts +3 -4
- package/dist/client/session-atom.d.mts +4 -4
- package/dist/client/session-refresh.d.mts +3 -5
- package/dist/client/solid/index.d.mts +6 -7
- package/dist/client/solid/index.mjs +3 -2
- package/dist/client/svelte/index.d.mts +6 -7
- package/dist/client/svelte/index.mjs +3 -2
- package/dist/client/types.d.mts +11 -11
- package/dist/client/vanilla.d.mts +4 -5
- package/dist/client/vanilla.mjs +3 -2
- package/dist/client/vue/index.d.mts +6 -7
- package/dist/client/vue/index.mjs +3 -2
- package/dist/context/create-context.mjs +7 -7
- package/dist/context/helpers.mjs +9 -7
- package/dist/cookies/cookie-utils.d.mts +13 -13
- package/dist/cookies/cookie-utils.mjs +1 -3
- package/dist/cookies/index.d.mts +17 -18
- package/dist/cookies/index.mjs +11 -7
- package/dist/cookies/jwt.mjs +2 -1
- package/dist/cookies/session-store.d.mts +6 -5
- package/dist/cookies/session-store.mjs +3 -2
- package/dist/crypto/buffer.d.mts +2 -3
- package/dist/crypto/index.d.mts +9 -16
- package/dist/crypto/index.mjs +2 -1
- package/dist/crypto/jwt.d.mts +5 -7
- package/dist/crypto/jwt.mjs +2 -1
- package/dist/crypto/password.d.mts +1 -5
- package/dist/crypto/random.d.mts +2 -3
- package/dist/db/adapter-base.d.mts +2 -4
- package/dist/db/adapter-kysely.d.mts +2 -4
- package/dist/db/field-converter.d.mts +3 -5
- package/dist/db/field.d.mts +11 -12
- package/dist/db/get-migration.d.mts +4 -8
- package/dist/db/get-migration.mjs +22 -22
- package/dist/db/get-schema.d.mts +2 -4
- package/dist/db/internal-adapter.d.mts +2 -4
- package/dist/db/internal-adapter.mjs +6 -4
- package/dist/db/revoke-unproven-account-access.d.mts +3 -4
- package/dist/db/schema.d.mts +15 -16
- package/dist/db/schema.mjs +6 -3
- package/dist/db/to-zod.d.mts +5 -9
- package/dist/db/with-hooks.d.mts +3 -5
- package/dist/index.d.mts +4 -3
- package/dist/integrations/next-js.d.mts +7 -11
- package/dist/integrations/node.d.mts +5 -7
- package/dist/integrations/node.mjs +4 -2
- package/dist/integrations/solid-start.d.mts +2 -3
- package/dist/integrations/svelte-kit.d.mts +6 -14
- package/dist/integrations/tanstack-start-solid.d.mts +4 -8
- package/dist/integrations/tanstack-start.d.mts +4 -8
- package/dist/oauth2/link-account.d.mts +5 -11
- package/dist/oauth2/link-account.mjs +12 -6
- package/dist/oauth2/state.d.mts +5 -7
- package/dist/oauth2/state.mjs +1 -1
- package/dist/oauth2/utils.d.mts +4 -6
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +4 -6
- package/dist/plugins/access/index.mjs +1 -2
- package/dist/plugins/access/types.d.mts +12 -14
- package/dist/plugins/additional-fields/client.d.mts +2 -4
- package/dist/plugins/admin/access/index.mjs +1 -2
- package/dist/plugins/admin/access/statement.d.mts +7 -7
- package/dist/plugins/admin/admin.d.mts +122 -128
- package/dist/plugins/admin/client.d.mts +32 -32
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +25 -28
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/index.mjs +1 -2
- package/dist/plugins/admin/schema.d.mts +3 -4
- package/dist/plugins/admin/types.d.mts +8 -8
- package/dist/plugins/anonymous/client.d.mts +10 -12
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +10 -13
- package/dist/plugins/anonymous/index.d.mts +17 -21
- package/dist/plugins/anonymous/schema.d.mts +2 -3
- package/dist/plugins/anonymous/types.d.mts +5 -6
- package/dist/plugins/bearer/index.d.mts +7 -11
- package/dist/plugins/captcha/constants.d.mts +2 -3
- package/dist/plugins/captcha/index.d.mts +6 -9
- package/dist/plugins/captcha/types.d.mts +11 -13
- package/dist/plugins/custom-session/client.d.mts +2 -4
- package/dist/plugins/custom-session/index.d.mts +10 -16
- package/dist/plugins/device-authorization/client.d.mts +2 -4
- package/dist/plugins/device-authorization/index.d.mts +39 -44
- package/dist/plugins/device-authorization/index.mjs +10 -9
- package/dist/plugins/device-authorization/routes.d.mts +7 -5
- package/dist/plugins/device-authorization/routes.mjs +6 -5
- package/dist/plugins/device-authorization/schema.d.mts +2 -3
- package/dist/plugins/email-otp/client.d.mts +5 -7
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +5 -8
- package/dist/plugins/email-otp/index.d.mts +69 -76
- package/dist/plugins/email-otp/otp-token.mjs +19 -7
- package/dist/plugins/email-otp/types.d.mts +2 -4
- package/dist/plugins/generic-oauth/index.d.mts +9 -13
- package/dist/plugins/generic-oauth/index.mjs +6 -4
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +2 -1
- package/dist/plugins/generic-oauth/providers/index.d.mts +2 -1
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/line.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/okta.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/slack.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +3 -5
- package/dist/plugins/generic-oauth/types.d.mts +6 -7
- package/dist/plugins/haveibeenpwned/index.d.mts +7 -11
- package/dist/plugins/index.d.mts +4 -1
- package/dist/plugins/jwt/client.d.mts +2 -3
- package/dist/plugins/jwt/index.d.mts +11 -14
- package/dist/plugins/jwt/index.mjs +1 -1
- package/dist/plugins/jwt/schema.d.mts +2 -3
- package/dist/plugins/jwt/sign.d.mts +9 -8
- package/dist/plugins/jwt/types.d.mts +7 -8
- package/dist/plugins/jwt/utils.d.mts +6 -9
- package/dist/plugins/jwt/verify.d.mts +2 -4
- package/dist/plugins/last-login-method/client.d.mts +3 -4
- package/dist/plugins/last-login-method/index.d.mts +5 -9
- package/dist/plugins/last-login-method/index.mjs +1 -1
- package/dist/plugins/magic-link/client.d.mts +2 -4
- package/dist/plugins/magic-link/index.d.mts +7 -10
- package/dist/plugins/magic-link/index.mjs +20 -17
- package/dist/plugins/multi-session/client.d.mts +3 -5
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +3 -6
- package/dist/plugins/multi-session/index.d.mts +10 -14
- package/dist/plugins/oauth-popup/client.d.mts +11 -17
- package/dist/plugins/oauth-popup/client.mjs +6 -4
- package/dist/plugins/oauth-popup/constants.d.mts +5 -6
- package/dist/plugins/oauth-popup/error-codes.d.mts +6 -9
- package/dist/plugins/oauth-popup/index.d.mts +11 -15
- package/dist/plugins/oauth-popup/index.mjs +8 -7
- package/dist/plugins/oauth-popup/types.d.mts +4 -6
- package/dist/plugins/oauth-proxy/index.d.mts +11 -15
- package/dist/plugins/oauth-proxy/index.mjs +10 -7
- package/dist/plugins/one-tap/client.d.mts +6 -9
- package/dist/plugins/one-tap/index.d.mts +4 -7
- package/dist/plugins/one-time-token/client.d.mts +2 -3
- package/dist/plugins/one-time-token/index.d.mts +8 -10
- package/dist/plugins/open-api/generator.d.mts +8 -8
- package/dist/plugins/open-api/generator.mjs +5 -5
- package/dist/plugins/open-api/index.d.mts +5 -7
- package/dist/plugins/organization/access/index.mjs +1 -2
- package/dist/plugins/organization/access/statement.d.mts +8 -8
- package/dist/plugins/organization/adapter.d.mts +60 -87
- package/dist/plugins/organization/adapter.mjs +14 -10
- package/dist/plugins/organization/client.d.mts +108 -107
- package/dist/plugins/organization/client.mjs +9 -5
- package/dist/plugins/organization/error-codes.d.mts +61 -64
- package/dist/plugins/organization/has-permission.d.mts +2 -4
- package/dist/plugins/organization/has-permission.mjs +1 -1
- package/dist/plugins/organization/index.d.mts +1 -1
- package/dist/plugins/organization/organization.d.mts +20 -20
- package/dist/plugins/organization/organization.mjs +13 -8
- package/dist/plugins/organization/permission.d.mts +4 -5
- package/dist/plugins/organization/routes/crud-access-control.d.mts +28 -28
- package/dist/plugins/organization/routes/crud-invites.d.mts +64 -65
- package/dist/plugins/organization/routes/crud-invites.mjs +21 -18
- package/dist/plugins/organization/routes/crud-members.d.mts +53 -56
- package/dist/plugins/organization/routes/crud-members.mjs +23 -21
- package/dist/plugins/organization/routes/crud-org.d.mts +63 -65
- package/dist/plugins/organization/routes/crud-org.mjs +4 -2
- package/dist/plugins/organization/routes/crud-team.d.mts +65 -66
- package/dist/plugins/organization/routes/crud-team.mjs +4 -2
- package/dist/plugins/organization/schema.d.mts +33 -33
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +16 -17
- package/dist/plugins/phone-number/client.d.mts +14 -16
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +14 -17
- package/dist/plugins/phone-number/index.d.mts +48 -54
- package/dist/plugins/phone-number/schema.d.mts +2 -3
- package/dist/plugins/phone-number/types.d.mts +4 -5
- package/dist/plugins/siwe/client.d.mts +2 -4
- package/dist/plugins/siwe/index.d.mts +7 -9
- package/dist/plugins/siwe/index.mjs +1 -1
- package/dist/plugins/siwe/parse-message.mjs +1 -3
- package/dist/plugins/siwe/schema.d.mts +3 -4
- package/dist/plugins/siwe/types.d.mts +4 -4
- package/dist/plugins/test-utils/auth-helpers.mjs +4 -2
- package/dist/plugins/test-utils/index.d.mts +3 -5
- package/dist/plugins/test-utils/types.d.mts +7 -7
- package/dist/plugins/two-factor/backup-codes/index.d.mts +11 -14
- package/dist/plugins/two-factor/backup-codes/index.mjs +12 -6
- package/dist/plugins/two-factor/client.d.mts +16 -19
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/constant.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +15 -18
- package/dist/plugins/two-factor/index.d.mts +31 -35
- package/dist/plugins/two-factor/index.mjs +6 -3
- package/dist/plugins/two-factor/otp/index.d.mts +5 -8
- package/dist/plugins/two-factor/otp/index.mjs +159 -154
- package/dist/plugins/two-factor/schema.d.mts +2 -3
- package/dist/plugins/two-factor/totp/index.d.mts +7 -10
- package/dist/plugins/two-factor/totp/index.mjs +153 -148
- package/dist/plugins/two-factor/types.d.mts +6 -7
- package/dist/plugins/username/client.d.mts +12 -14
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +11 -14
- package/dist/plugins/username/index.d.mts +26 -31
- package/dist/plugins/username/schema.d.mts +7 -10
- package/dist/state.d.mts +4 -5
- package/dist/test-utils/headers.d.mts +2 -3
- package/dist/test-utils/http-test-instance.d.mts +26 -29
- package/dist/test-utils/test-instance.d.mts +7 -6
- package/dist/test-utils/test-instance.mjs +4 -2
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +4 -6
- package/dist/types/auth.d.mts +2 -4
- package/dist/types/helper.d.mts +11 -12
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +4 -5
- package/dist/types/plugins.d.mts +7 -8
- package/dist/utils/hide-metadata.d.mts +2 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/is-api-error.mjs +1 -2
- package/dist/utils/time.d.mts +4 -4
- package/dist/utils/url.d.mts +13 -15
- package/dist/utils/wildcard.mjs +5 -3
- package/package.json +12 -12
|
@@ -130,13 +130,14 @@ const getOrgAdapter = (context, options) => {
|
|
|
130
130
|
const teamAdditionalFields = options?.schema?.team?.additionalFields;
|
|
131
131
|
return {
|
|
132
132
|
findOrganizationBySlug: async (slug) => {
|
|
133
|
-
|
|
133
|
+
const organization = await (await getCurrentAdapter(baseAdapter)).findOne({
|
|
134
134
|
model: "organization",
|
|
135
135
|
where: [{
|
|
136
136
|
field: "slug",
|
|
137
137
|
value: slug
|
|
138
138
|
}]
|
|
139
|
-
})
|
|
139
|
+
});
|
|
140
|
+
return filterOutputFields(organization, orgAdditionalFields);
|
|
140
141
|
},
|
|
141
142
|
createOrganization: async (data) => {
|
|
142
143
|
const organization = await (await getCurrentAdapter(baseAdapter)).create({
|
|
@@ -147,10 +148,11 @@ const getOrgAdapter = (context, options) => {
|
|
|
147
148
|
},
|
|
148
149
|
forceAllowId: true
|
|
149
150
|
});
|
|
150
|
-
|
|
151
|
+
const result = {
|
|
151
152
|
...organization,
|
|
152
153
|
metadata: organization.metadata && typeof organization.metadata === "string" ? JSON.parse(organization.metadata) : void 0
|
|
153
|
-
}
|
|
154
|
+
};
|
|
155
|
+
return filterOutputFields(result, orgAdditionalFields);
|
|
154
156
|
},
|
|
155
157
|
findMemberByEmail: async (data) => {
|
|
156
158
|
const adapter = await getCurrentAdapter(baseAdapter);
|
|
@@ -362,10 +364,11 @@ const getOrgAdapter = (context, options) => {
|
|
|
362
364
|
}
|
|
363
365
|
});
|
|
364
366
|
if (!organization) return null;
|
|
365
|
-
|
|
367
|
+
const result = {
|
|
366
368
|
...organization,
|
|
367
369
|
metadata: organization.metadata ? parseJSON(organization.metadata) : void 0
|
|
368
|
-
}
|
|
370
|
+
};
|
|
371
|
+
return filterOutputFields(result, orgAdditionalFields);
|
|
369
372
|
},
|
|
370
373
|
deleteOrganization: async (organizationId) => {
|
|
371
374
|
return runWithTransaction(baseAdapter, async () => {
|
|
@@ -398,13 +401,14 @@ const getOrgAdapter = (context, options) => {
|
|
|
398
401
|
return await context.internalAdapter.updateSession(sessionToken, { activeOrganizationId: organizationId });
|
|
399
402
|
},
|
|
400
403
|
findOrganizationById: async (organizationId) => {
|
|
401
|
-
|
|
404
|
+
const organization = await (await getCurrentAdapter(baseAdapter)).findOne({
|
|
402
405
|
model: "organization",
|
|
403
406
|
where: [{
|
|
404
407
|
field: "id",
|
|
405
408
|
value: organizationId
|
|
406
409
|
}]
|
|
407
|
-
})
|
|
410
|
+
});
|
|
411
|
+
return filterOutputFields(organization, orgAdditionalFields);
|
|
408
412
|
},
|
|
409
413
|
checkMembership: async ({ userId, organizationId }) => {
|
|
410
414
|
return await (await getCurrentAdapter(baseAdapter)).findOne({
|
|
@@ -557,7 +561,7 @@ const getOrgAdapter = (context, options) => {
|
|
|
557
561
|
return filterOutputFields(output, teamAdditionalFields);
|
|
558
562
|
});
|
|
559
563
|
},
|
|
560
|
-
createTeamInvitation: async ({ email, role, teamId, organizationId, inviterId, expiresIn =
|
|
564
|
+
createTeamInvitation: async ({ email, role, teamId, organizationId, inviterId, expiresIn = 1728e5 }) => {
|
|
561
565
|
const adapter = await getCurrentAdapter(baseAdapter);
|
|
562
566
|
const expiresAt = getDate(expiresIn);
|
|
563
567
|
return await adapter.create({
|
|
@@ -727,7 +731,7 @@ const getOrgAdapter = (context, options) => {
|
|
|
727
731
|
},
|
|
728
732
|
createInvitation: async ({ invitation, user }) => {
|
|
729
733
|
const adapter = await getCurrentAdapter(baseAdapter);
|
|
730
|
-
const expiresAt = getDate(options?.invitationExpiresIn ||
|
|
734
|
+
const expiresAt = getDate(options?.invitationExpiresIn || 172800, "sec");
|
|
731
735
|
return await adapter.create({
|
|
732
736
|
model: "invitation",
|
|
733
737
|
data: {
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { FieldAttributeToObject, RemoveFieldsWithReturnedFalse } from "../../db/field.mjs";
|
|
2
2
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
|
-
import { BetterAuthOptions
|
|
3
|
+
import { BetterAuthOptions } from "../../types/index.mjs";
|
|
4
4
|
import { AuthQueryAtom } from "../../client/query.mjs";
|
|
5
5
|
import { AccessControl, ArrayElement, Role, Statements } from "../access/types.mjs";
|
|
6
|
+
import "../access/index.mjs";
|
|
7
|
+
import "../../db/index.mjs";
|
|
6
8
|
import { OrganizationOptions } from "./types.mjs";
|
|
7
9
|
import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferTeam, Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, Team, TeamInput, TeamMember, TeamMemberInput, defaultRolesSchema, invitationSchema, invitationStatus, memberSchema, organizationRoleSchema, organizationSchema, roleSchema, teamMemberSchema, teamSchema } from "./schema.mjs";
|
|
10
|
+
import "../index.mjs";
|
|
8
11
|
import { ORGANIZATION_ERROR_CODES } from "./error-codes.mjs";
|
|
9
12
|
import { HasPermissionBaseInput } from "./permission.mjs";
|
|
10
13
|
import { OrganizationPlugin } from "./organization.mjs";
|
|
11
|
-
import
|
|
14
|
+
import "./index.mjs";
|
|
15
|
+
import "../../client/index.mjs";
|
|
12
16
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
13
|
-
import * as _$_better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
14
|
-
import * as _$nanostores from "nanostores";
|
|
15
17
|
import { BetterFetch } from "@better-fetch/fetch";
|
|
16
|
-
|
|
17
18
|
//#region src/plugins/organization/client.d.ts
|
|
18
19
|
/**
|
|
19
20
|
* Using the same `hasPermissionFn` function, but without the need for a `ctx` parameter or the `organizationId` parameter.
|
|
20
21
|
*/
|
|
21
|
-
declare const clientSideHasPermission: (input: HasPermissionBaseInput) => boolean;
|
|
22
|
-
interface OrganizationClientOptions {
|
|
22
|
+
export declare const clientSideHasPermission: (input: HasPermissionBaseInput) => boolean;
|
|
23
|
+
export interface OrganizationClientOptions {
|
|
23
24
|
ac?: AccessControl | undefined;
|
|
24
|
-
roles?: { [key in string]: Role } | undefined;
|
|
25
|
+
roles?: { [key in string]: Role; } | undefined;
|
|
25
26
|
teams?: {
|
|
26
27
|
enabled: boolean;
|
|
27
28
|
} | undefined;
|
|
@@ -56,7 +57,7 @@ interface OrganizationClientOptions {
|
|
|
56
57
|
enabled: boolean;
|
|
57
58
|
} | undefined;
|
|
58
59
|
}
|
|
59
|
-
declare const organizationClient: <CO extends OrganizationClientOptions>(options?: CO | undefined) => {
|
|
60
|
+
export declare const organizationClient: <CO extends OrganizationClientOptions>(options?: CO | undefined) => {
|
|
60
61
|
id: "organization";
|
|
61
62
|
version: string;
|
|
62
63
|
$InferServerPlugin: OrganizationPlugin<{
|
|
@@ -84,7 +85,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
84
85
|
} ? true : false;
|
|
85
86
|
};
|
|
86
87
|
}>;
|
|
87
|
-
getActions: ($fetch: BetterFetch, _$store:
|
|
88
|
+
getActions: ($fetch: BetterFetch, _$store: import("@better-auth/core").ClientStore, co: import("@better-auth/core").BetterAuthClientOptions | undefined) => {
|
|
88
89
|
$Infer: {
|
|
89
90
|
ActiveOrganization: CO["teams"] extends {
|
|
90
91
|
enabled: true;
|
|
@@ -103,7 +104,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
103
104
|
organization?: {
|
|
104
105
|
additionalFields: infer Field extends Record<string, DBFieldAttribute>;
|
|
105
106
|
} | undefined;
|
|
106
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) : {
|
|
107
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) : {
|
|
107
108
|
members: InferMember<CO>[];
|
|
108
109
|
invitations: InferInvitation<CO>[];
|
|
109
110
|
} & ({
|
|
@@ -117,16 +118,16 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
117
118
|
organization?: {
|
|
118
119
|
additionalFields: infer Field extends Record<string, DBFieldAttribute>;
|
|
119
120
|
} | undefined;
|
|
120
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends infer T_1 ? { [K in keyof T_1]: T_1[K] } : never);
|
|
121
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T_1) ? { [K in keyof T_1]: T_1[K]; } : never);
|
|
121
122
|
Organization: InferOrganization<CO>;
|
|
122
123
|
Invitation: InferInvitation<CO>;
|
|
123
124
|
Member: InferMember<CO>;
|
|
124
125
|
Team: InferTeam<CO>;
|
|
125
126
|
};
|
|
126
127
|
organization: {
|
|
127
|
-
checkRolePermission: <R extends
|
|
128
|
+
checkRolePermission: <R extends CO extends {
|
|
128
129
|
roles: any;
|
|
129
|
-
} ? keyof CO["roles"] : "admin" | "member" | "owner"
|
|
130
|
+
} ? keyof CO["roles"] : "admin" | "member" | "owner">(data: {
|
|
130
131
|
permissions: { [key in keyof (CO["ac"] extends AccessControl<infer S extends Statements> ? S : {
|
|
131
132
|
readonly organization: readonly ["update", "delete"];
|
|
132
133
|
readonly member: readonly ["create", "update", "delete"];
|
|
@@ -145,17 +146,17 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
145
146
|
readonly invitation: readonly ["create", "cancel"];
|
|
146
147
|
readonly team: readonly ["create", "update", "delete"];
|
|
147
148
|
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
148
|
-
})[key]> : never)[] | undefined };
|
|
149
|
+
})[key]> : never)[] | undefined; };
|
|
149
150
|
} & {
|
|
150
151
|
role: R;
|
|
151
152
|
}) => boolean;
|
|
152
153
|
};
|
|
153
154
|
};
|
|
154
155
|
getAtoms: ($fetch: BetterFetch) => {
|
|
155
|
-
$listOrg:
|
|
156
|
-
$activeOrgSignal:
|
|
157
|
-
$activeMemberSignal:
|
|
158
|
-
$activeMemberRoleSignal:
|
|
156
|
+
$listOrg: import("nanostores").PreinitializedWritableAtom<boolean> & object;
|
|
157
|
+
$activeOrgSignal: import("nanostores").PreinitializedWritableAtom<boolean> & object;
|
|
158
|
+
$activeMemberSignal: import("nanostores").PreinitializedWritableAtom<boolean> & object;
|
|
159
|
+
$activeMemberRoleSignal: import("nanostores").PreinitializedWritableAtom<boolean> & object;
|
|
159
160
|
activeOrganization: AuthQueryAtom<Prettify<({
|
|
160
161
|
id: string;
|
|
161
162
|
name: string;
|
|
@@ -167,7 +168,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
167
168
|
organization?: {
|
|
168
169
|
additionalFields: infer Field extends Record<string, DBFieldAttribute>;
|
|
169
170
|
} | undefined;
|
|
170
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) & {
|
|
171
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) & {
|
|
171
172
|
members: InferMember<CO>[];
|
|
172
173
|
invitations: InferInvitation<CO>[];
|
|
173
174
|
}>>;
|
|
@@ -182,7 +183,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
182
183
|
organization?: {
|
|
183
184
|
additionalFields: infer Field extends Record<string, DBFieldAttribute>;
|
|
184
185
|
} | undefined;
|
|
185
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends infer T_1 ? { [K in keyof T_1]: T_1[K] } : never)[]>;
|
|
186
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T_1) ? { [K in keyof T_1]: T_1[K]; } : never)[]>;
|
|
186
187
|
activeMember: AuthQueryAtom<{
|
|
187
188
|
id: string;
|
|
188
189
|
organizationId: string;
|
|
@@ -215,69 +216,69 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
215
216
|
signal: "$activeMemberRoleSignal";
|
|
216
217
|
})[];
|
|
217
218
|
$ERROR_CODES: {
|
|
218
|
-
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:
|
|
219
|
-
YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:
|
|
220
|
-
ORGANIZATION_ALREADY_EXISTS:
|
|
221
|
-
ORGANIZATION_SLUG_ALREADY_TAKEN:
|
|
222
|
-
ORGANIZATION_NOT_FOUND:
|
|
223
|
-
USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:
|
|
224
|
-
YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:
|
|
225
|
-
YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:
|
|
226
|
-
NO_ACTIVE_ORGANIZATION:
|
|
227
|
-
USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:
|
|
228
|
-
MEMBER_NOT_FOUND:
|
|
229
|
-
ROLE_NOT_FOUND:
|
|
230
|
-
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:
|
|
231
|
-
TEAM_ALREADY_EXISTS:
|
|
232
|
-
TEAM_NOT_FOUND:
|
|
233
|
-
YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:
|
|
234
|
-
YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:
|
|
235
|
-
YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:
|
|
236
|
-
YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:
|
|
237
|
-
USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:
|
|
238
|
-
INVITATION_NOT_FOUND:
|
|
239
|
-
YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:
|
|
240
|
-
EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:
|
|
241
|
-
EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION:
|
|
242
|
-
YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:
|
|
243
|
-
INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:
|
|
244
|
-
YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:
|
|
245
|
-
FAILED_TO_RETRIEVE_INVITATION:
|
|
246
|
-
YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:
|
|
247
|
-
UNABLE_TO_REMOVE_LAST_TEAM:
|
|
248
|
-
YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:
|
|
249
|
-
ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:
|
|
250
|
-
YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:
|
|
251
|
-
YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:
|
|
252
|
-
YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:
|
|
253
|
-
YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:
|
|
254
|
-
INVITATION_LIMIT_REACHED:
|
|
255
|
-
TEAM_MEMBER_LIMIT_REACHED:
|
|
256
|
-
USER_IS_NOT_A_MEMBER_OF_THE_TEAM:
|
|
257
|
-
YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:
|
|
258
|
-
YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:
|
|
259
|
-
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:
|
|
260
|
-
YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:
|
|
261
|
-
YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:
|
|
262
|
-
YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:
|
|
263
|
-
MISSING_AC_INSTANCE:
|
|
264
|
-
YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:
|
|
265
|
-
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:
|
|
266
|
-
YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:
|
|
267
|
-
YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:
|
|
268
|
-
YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:
|
|
269
|
-
YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:
|
|
270
|
-
YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:
|
|
271
|
-
TOO_MANY_ROLES:
|
|
272
|
-
INVALID_RESOURCE:
|
|
273
|
-
ROLE_NAME_IS_ALREADY_TAKEN:
|
|
274
|
-
CANNOT_DELETE_A_PRE_DEFINED_ROLE:
|
|
275
|
-
ROLE_IS_ASSIGNED_TO_MEMBERS:
|
|
276
|
-
INVALID_TEAM_ID:
|
|
219
|
+
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION">;
|
|
220
|
+
YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS: import("@better-auth/core/utils/error-codes").RawError<"YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS">;
|
|
221
|
+
ORGANIZATION_ALREADY_EXISTS: import("@better-auth/core/utils/error-codes").RawError<"ORGANIZATION_ALREADY_EXISTS">;
|
|
222
|
+
ORGANIZATION_SLUG_ALREADY_TAKEN: import("@better-auth/core/utils/error-codes").RawError<"ORGANIZATION_SLUG_ALREADY_TAKEN">;
|
|
223
|
+
ORGANIZATION_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"ORGANIZATION_NOT_FOUND">;
|
|
224
|
+
USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION">;
|
|
225
|
+
YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION">;
|
|
226
|
+
YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION">;
|
|
227
|
+
NO_ACTIVE_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"NO_ACTIVE_ORGANIZATION">;
|
|
228
|
+
USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION">;
|
|
229
|
+
MEMBER_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"MEMBER_NOT_FOUND">;
|
|
230
|
+
ROLE_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"ROLE_NOT_FOUND">;
|
|
231
|
+
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM">;
|
|
232
|
+
TEAM_ALREADY_EXISTS: import("@better-auth/core/utils/error-codes").RawError<"TEAM_ALREADY_EXISTS">;
|
|
233
|
+
TEAM_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"TEAM_NOT_FOUND">;
|
|
234
|
+
YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER: import("@better-auth/core/utils/error-codes").RawError<"YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER">;
|
|
235
|
+
YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER: import("@better-auth/core/utils/error-codes").RawError<"YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER">;
|
|
236
|
+
YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER">;
|
|
237
|
+
YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION">;
|
|
238
|
+
USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION">;
|
|
239
|
+
INVITATION_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"INVITATION_NOT_FOUND">;
|
|
240
|
+
YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION">;
|
|
241
|
+
EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION: import("@better-auth/core/utils/error-codes").RawError<"EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION">;
|
|
242
|
+
EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION: import("@better-auth/core/utils/error-codes").RawError<"EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION">;
|
|
243
|
+
YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION">;
|
|
244
|
+
INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION">;
|
|
245
|
+
YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE">;
|
|
246
|
+
FAILED_TO_RETRIEVE_INVITATION: import("@better-auth/core/utils/error-codes").RawError<"FAILED_TO_RETRIEVE_INVITATION">;
|
|
247
|
+
YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS: import("@better-auth/core/utils/error-codes").RawError<"YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS">;
|
|
248
|
+
UNABLE_TO_REMOVE_LAST_TEAM: import("@better-auth/core/utils/error-codes").RawError<"UNABLE_TO_REMOVE_LAST_TEAM">;
|
|
249
|
+
YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER">;
|
|
250
|
+
ORGANIZATION_MEMBERSHIP_LIMIT_REACHED: import("@better-auth/core/utils/error-codes").RawError<"ORGANIZATION_MEMBERSHIP_LIMIT_REACHED">;
|
|
251
|
+
YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION">;
|
|
252
|
+
YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION">;
|
|
253
|
+
YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM">;
|
|
254
|
+
YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM">;
|
|
255
|
+
INVITATION_LIMIT_REACHED: import("@better-auth/core/utils/error-codes").RawError<"INVITATION_LIMIT_REACHED">;
|
|
256
|
+
TEAM_MEMBER_LIMIT_REACHED: import("@better-auth/core/utils/error-codes").RawError<"TEAM_MEMBER_LIMIT_REACHED">;
|
|
257
|
+
USER_IS_NOT_A_MEMBER_OF_THE_TEAM: import("@better-auth/core/utils/error-codes").RawError<"USER_IS_NOT_A_MEMBER_OF_THE_TEAM">;
|
|
258
|
+
YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM: import("@better-auth/core/utils/error-codes").RawError<"YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM">;
|
|
259
|
+
YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM: import("@better-auth/core/utils/error-codes").RawError<"YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM">;
|
|
260
|
+
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER">;
|
|
261
|
+
YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER">;
|
|
262
|
+
YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION">;
|
|
263
|
+
YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION">;
|
|
264
|
+
MISSING_AC_INSTANCE: import("@better-auth/core/utils/error-codes").RawError<"MISSING_AC_INSTANCE">;
|
|
265
|
+
YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE: import("@better-auth/core/utils/error-codes").RawError<"YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE">;
|
|
266
|
+
YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE">;
|
|
267
|
+
YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE">;
|
|
268
|
+
YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE">;
|
|
269
|
+
YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE">;
|
|
270
|
+
YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE">;
|
|
271
|
+
YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE">;
|
|
272
|
+
TOO_MANY_ROLES: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ROLES">;
|
|
273
|
+
INVALID_RESOURCE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_RESOURCE">;
|
|
274
|
+
ROLE_NAME_IS_ALREADY_TAKEN: import("@better-auth/core/utils/error-codes").RawError<"ROLE_NAME_IS_ALREADY_TAKEN">;
|
|
275
|
+
CANNOT_DELETE_A_PRE_DEFINED_ROLE: import("@better-auth/core/utils/error-codes").RawError<"CANNOT_DELETE_A_PRE_DEFINED_ROLE">;
|
|
276
|
+
ROLE_IS_ASSIGNED_TO_MEMBERS: import("@better-auth/core/utils/error-codes").RawError<"ROLE_IS_ASSIGNED_TO_MEMBERS">;
|
|
277
|
+
INVALID_TEAM_ID: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TEAM_ID">;
|
|
277
278
|
};
|
|
278
279
|
};
|
|
279
|
-
declare const inferOrgAdditionalFields: <O extends {
|
|
280
|
-
options: BetterAuthOptions
|
|
280
|
+
export declare const inferOrgAdditionalFields: <O extends {
|
|
281
|
+
options: BetterAuthOptions;
|
|
281
282
|
}, S extends OrganizationOptions["schema"] = undefined>(schema?: S | undefined) => undefined extends S ? O extends Object ? O extends {
|
|
282
283
|
session?: {
|
|
283
284
|
fields?: {
|
|
@@ -287,32 +288,32 @@ declare const inferOrgAdditionalFields: <O extends {
|
|
|
287
288
|
};
|
|
288
289
|
organization?: {
|
|
289
290
|
modelName?: string;
|
|
290
|
-
fields?: { [key in keyof Omit<Organization, "id">]?: string };
|
|
291
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
291
|
+
fields?: { [key in keyof Omit<Organization, "id">]?: string; };
|
|
292
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
292
293
|
};
|
|
293
294
|
member?: {
|
|
294
295
|
modelName?: string;
|
|
295
|
-
fields?: { [key in keyof Omit<Member, "id">]?: string };
|
|
296
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
296
|
+
fields?: { [key in keyof Omit<Member, "id">]?: string; };
|
|
297
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
297
298
|
};
|
|
298
299
|
invitation?: {
|
|
299
300
|
modelName?: string;
|
|
300
|
-
fields?: { [key in keyof Omit<Invitation, "id">]?: string };
|
|
301
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
301
|
+
fields?: { [key in keyof Omit<Invitation, "id">]?: string; };
|
|
302
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
302
303
|
};
|
|
303
304
|
team?: {
|
|
304
305
|
modelName?: string;
|
|
305
|
-
fields?: { [key in keyof Omit<Team, "id"> | "memberCount"]?: string };
|
|
306
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
306
|
+
fields?: { [key in keyof Omit<Team, "id"> | "memberCount"]?: string; };
|
|
307
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
307
308
|
};
|
|
308
309
|
teamMember?: {
|
|
309
310
|
modelName?: string;
|
|
310
|
-
fields?: { [key in keyof Omit<TeamMember, "id"> | "membershipKey"]?: string };
|
|
311
|
+
fields?: { [key in keyof Omit<TeamMember, "id"> | "membershipKey"]?: string; };
|
|
311
312
|
};
|
|
312
313
|
organizationRole?: {
|
|
313
314
|
modelName?: string;
|
|
314
|
-
fields?: { [key in keyof Omit<OrganizationRole, "id">]?: string };
|
|
315
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
315
|
+
fields?: { [key in keyof Omit<OrganizationRole, "id">]?: string; };
|
|
316
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
316
317
|
};
|
|
317
318
|
} ? O : ((O extends {
|
|
318
319
|
options: any;
|
|
@@ -320,7 +321,7 @@ declare const inferOrgAdditionalFields: <O extends {
|
|
|
320
321
|
options: {
|
|
321
322
|
plugins: [];
|
|
322
323
|
};
|
|
323
|
-
})["options"]["plugins"][number] extends infer T ? T extends (O extends {
|
|
324
|
+
})["options"]["plugins"][number] extends (infer T) ? T extends (O extends {
|
|
324
325
|
options: any;
|
|
325
326
|
} ? O : {
|
|
326
327
|
options: {
|
|
@@ -341,35 +342,35 @@ declare const inferOrgAdditionalFields: <O extends {
|
|
|
341
342
|
};
|
|
342
343
|
organization?: {
|
|
343
344
|
modelName?: string;
|
|
344
|
-
fields?: { [key in keyof Omit<Organization, "id">]?: string };
|
|
345
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
345
|
+
fields?: { [key in keyof Omit<Organization, "id">]?: string; };
|
|
346
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
346
347
|
};
|
|
347
348
|
member?: {
|
|
348
349
|
modelName?: string;
|
|
349
|
-
fields?: { [key in keyof Omit<Member, "id">]?: string };
|
|
350
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
350
|
+
fields?: { [key in keyof Omit<Member, "id">]?: string; };
|
|
351
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
351
352
|
};
|
|
352
353
|
invitation?: {
|
|
353
354
|
modelName?: string;
|
|
354
|
-
fields?: { [key in keyof Omit<Invitation, "id">]?: string };
|
|
355
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
355
|
+
fields?: { [key in keyof Omit<Invitation, "id">]?: string; };
|
|
356
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
356
357
|
};
|
|
357
358
|
team?: {
|
|
358
359
|
modelName?: string;
|
|
359
|
-
fields?: { [key in keyof Omit<Team, "id"> | "memberCount"]?: string };
|
|
360
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
360
|
+
fields?: { [key in keyof Omit<Team, "id"> | "memberCount"]?: string; };
|
|
361
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
361
362
|
};
|
|
362
363
|
teamMember?: {
|
|
363
364
|
modelName?: string;
|
|
364
|
-
fields?: { [key in keyof Omit<TeamMember, "id"> | "membershipKey"]?: string };
|
|
365
|
+
fields?: { [key in keyof Omit<TeamMember, "id"> | "membershipKey"]?: string; };
|
|
365
366
|
};
|
|
366
367
|
organizationRole?: {
|
|
367
368
|
modelName?: string;
|
|
368
|
-
fields?: { [key in keyof Omit<OrganizationRole, "id">]?: string };
|
|
369
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
369
|
+
fields?: { [key in keyof Omit<OrganizationRole, "id">]?: string; };
|
|
370
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
370
371
|
};
|
|
371
372
|
} | undefined ? { [K in keyof S_1 as S_1[K] extends {
|
|
372
373
|
additionalFields: unknown;
|
|
373
|
-
} ? K : never]: S_1[K] } : undefined : undefined : undefined : S;
|
|
374
|
+
} ? K : never]: S_1[K]; } : undefined : undefined : undefined : S;
|
|
374
375
|
//#endregion
|
|
375
|
-
export {
|
|
376
|
+
export { type InferInvitation, type InferMember, type InferOrganization, type InferOrganizationRolesFromOption, type InferOrganizationZodRolesFromOption, type InferTeam, type Invitation, type InvitationInput, type InvitationStatus, type Member, type MemberInput, ORGANIZATION_ERROR_CODES, type Organization, type OrganizationInput, type OrganizationRole, type OrganizationSchema, type Team, type TeamInput, type TeamMember, type TeamMemberInput, type defaultRolesSchema, type invitationSchema, type invitationStatus, type memberSchema, type organizationRoleSchema, type organizationSchema, type roleSchema, type teamMemberSchema, type teamSchema };
|
|
@@ -10,7 +10,8 @@ import { atom } from "nanostores";
|
|
|
10
10
|
* Using the same `hasPermissionFn` function, but without the need for a `ctx` parameter or the `organizationId` parameter.
|
|
11
11
|
*/
|
|
12
12
|
const clientSideHasPermission = (input) => {
|
|
13
|
-
|
|
13
|
+
const acRoles = input.options.roles || defaultRoles;
|
|
14
|
+
return hasPermissionFn(input, acRoles);
|
|
14
15
|
};
|
|
15
16
|
const organizationClient = (options) => {
|
|
16
17
|
const $listOrg = atom(false);
|
|
@@ -48,15 +49,18 @@ const organizationClient = (options) => {
|
|
|
48
49
|
}),
|
|
49
50
|
getAtoms: ($fetch) => {
|
|
50
51
|
const listOrganizations = useAuthQuery($listOrg, "/organization/list", $fetch, { method: "GET" });
|
|
52
|
+
const activeOrganization = useAuthQuery([$activeOrgSignal], "/organization/get-full-organization", $fetch, () => ({ method: "GET" }));
|
|
53
|
+
const activeMember = useAuthQuery([$activeOrgSignal, $activeMemberSignal], "/organization/get-active-member", $fetch, { method: "GET" });
|
|
54
|
+
const activeMemberRole = useAuthQuery([$activeOrgSignal, $activeMemberRoleSignal], "/organization/get-active-member-role", $fetch, { method: "GET" });
|
|
51
55
|
return {
|
|
52
56
|
$listOrg,
|
|
53
57
|
$activeOrgSignal,
|
|
54
58
|
$activeMemberSignal,
|
|
55
59
|
$activeMemberRoleSignal,
|
|
56
|
-
activeOrganization
|
|
60
|
+
activeOrganization,
|
|
57
61
|
listOrganizations,
|
|
58
|
-
activeMember
|
|
59
|
-
activeMemberRole
|
|
62
|
+
activeMember,
|
|
63
|
+
activeMemberRole
|
|
60
64
|
};
|
|
61
65
|
},
|
|
62
66
|
pathMethods: {
|
|
@@ -102,4 +106,4 @@ const inferOrgAdditionalFields = (schema) => {
|
|
|
102
106
|
return {};
|
|
103
107
|
};
|
|
104
108
|
//#endregion
|
|
105
|
-
export { clientSideHasPermission, inferOrgAdditionalFields, organizationClient };
|
|
109
|
+
export { ORGANIZATION_ERROR_CODES, clientSideHasPermission, inferOrgAdditionalFields, organizationClient };
|