@meistrari/auth-core 1.5.0 → 1.5.2
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 +2 -6
- package/dist/index.d.mts +26 -45
- package/dist/index.d.ts +26 -45
- package/dist/index.mjs +7 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -157,14 +157,10 @@ const organizations = await authClient.organization.listOrganizations()
|
|
|
157
157
|
|
|
158
158
|
#### getOrganization
|
|
159
159
|
|
|
160
|
-
Retrieves a single organization with
|
|
160
|
+
Retrieves a single organization with teams, invites and members.
|
|
161
161
|
|
|
162
162
|
```typescript
|
|
163
|
-
const organization = await authClient.organization.getOrganization('org-123'
|
|
164
|
-
includeMembers: true,
|
|
165
|
-
includeInvitations: true,
|
|
166
|
-
includeTeams: true
|
|
167
|
-
})
|
|
163
|
+
const organization = await authClient.organization.getOrganization('org-123')
|
|
168
164
|
```
|
|
169
165
|
|
|
170
166
|
#### setActiveOrganization
|
package/dist/index.d.mts
CHANGED
|
@@ -5985,9 +5985,9 @@ type ExtendedOrganization = Organization & {
|
|
|
5985
5985
|
settings?: OrganizationSettings;
|
|
5986
5986
|
};
|
|
5987
5987
|
type FullOrganization = ExtendedOrganization & {
|
|
5988
|
-
members
|
|
5989
|
-
invitations
|
|
5990
|
-
teams
|
|
5988
|
+
members: Member[];
|
|
5989
|
+
invitations: Invitation[];
|
|
5990
|
+
teams: Team[];
|
|
5991
5991
|
};
|
|
5992
5992
|
type TeamMember = {
|
|
5993
5993
|
id: string;
|
|
@@ -5996,12 +5996,7 @@ type TeamMember = {
|
|
|
5996
5996
|
createdAt: Date;
|
|
5997
5997
|
};
|
|
5998
5998
|
|
|
5999
|
-
type
|
|
6000
|
-
includeMembers?: boolean;
|
|
6001
|
-
includeInvitations?: boolean;
|
|
6002
|
-
includeTeams?: boolean;
|
|
6003
|
-
};
|
|
6004
|
-
type UpdateOrganizationPayload = Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>;
|
|
5999
|
+
type UpdateOrganizationPayload = Partial<Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>>;
|
|
6005
6000
|
type ListMembersOptions = {
|
|
6006
6001
|
limit?: number;
|
|
6007
6002
|
offset?: number;
|
|
@@ -6047,21 +6042,24 @@ declare class OrganizationService {
|
|
|
6047
6042
|
* Retrieves a single organization by ID with optional related data.
|
|
6048
6043
|
*
|
|
6049
6044
|
* @param id - The organization ID
|
|
6050
|
-
* @
|
|
6051
|
-
* @param options.includeMembers - Include organization members
|
|
6052
|
-
* @param options.includeInvitations - Include pending invitations
|
|
6053
|
-
* @param options.includeTeams - Include organization teams
|
|
6054
|
-
* @returns The organization with optionally included related data
|
|
6045
|
+
* @returns The organization with members, invitations, and teams
|
|
6055
6046
|
*/
|
|
6056
|
-
getOrganization(id: string
|
|
6057
|
-
|
|
6047
|
+
getOrganization(id: string): Promise<{
|
|
6048
|
+
members: {
|
|
6058
6049
|
id: string;
|
|
6059
|
-
name: string;
|
|
6060
6050
|
organizationId: string;
|
|
6051
|
+
role: "org:admin" | "org:member" | "org:reviewer";
|
|
6061
6052
|
createdAt: Date;
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6053
|
+
userId: string;
|
|
6054
|
+
teamId?: string | undefined | undefined;
|
|
6055
|
+
user: {
|
|
6056
|
+
id: string;
|
|
6057
|
+
email: string;
|
|
6058
|
+
name: string;
|
|
6059
|
+
image?: string | undefined;
|
|
6060
|
+
};
|
|
6061
|
+
}[];
|
|
6062
|
+
invitations: {
|
|
6065
6063
|
id: string;
|
|
6066
6064
|
organizationId: string;
|
|
6067
6065
|
email: string;
|
|
@@ -6071,38 +6069,21 @@ declare class OrganizationService {
|
|
|
6071
6069
|
expiresAt: Date;
|
|
6072
6070
|
createdAt: Date;
|
|
6073
6071
|
teamId?: string | undefined | undefined;
|
|
6074
|
-
}[]
|
|
6075
|
-
|
|
6072
|
+
}[];
|
|
6073
|
+
teams: {
|
|
6076
6074
|
id: string;
|
|
6075
|
+
name: string;
|
|
6077
6076
|
organizationId: string;
|
|
6078
|
-
role: "org:admin" | "org:member" | "org:reviewer";
|
|
6079
6077
|
createdAt: Date;
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
id: string;
|
|
6084
|
-
email: string;
|
|
6085
|
-
name: string;
|
|
6086
|
-
image?: string | undefined;
|
|
6087
|
-
};
|
|
6088
|
-
} & {
|
|
6089
|
-
user: {
|
|
6090
|
-
id: string;
|
|
6091
|
-
name: string;
|
|
6092
|
-
email: string;
|
|
6093
|
-
image: string | null | undefined;
|
|
6094
|
-
};
|
|
6095
|
-
})[] | undefined;
|
|
6078
|
+
updatedAt?: Date | undefined;
|
|
6079
|
+
}[];
|
|
6080
|
+
} & {
|
|
6096
6081
|
id: string;
|
|
6097
6082
|
name: string;
|
|
6098
6083
|
slug: string;
|
|
6099
6084
|
createdAt: Date;
|
|
6100
|
-
logo?: string | null | undefined;
|
|
6085
|
+
logo?: string | null | undefined | undefined;
|
|
6101
6086
|
metadata?: any;
|
|
6102
|
-
settings?: {
|
|
6103
|
-
disableStorage?: boolean;
|
|
6104
|
-
dataRetentionHours?: number;
|
|
6105
|
-
};
|
|
6106
6087
|
}>;
|
|
6107
6088
|
/**
|
|
6108
6089
|
* Lists all organizations accessible to the current user.
|
|
@@ -6710,4 +6691,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
6710
6691
|
declare function extractTokenPayload(token: string): JWTTokenPayload;
|
|
6711
6692
|
|
|
6712
6693
|
export { AuthClient, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, Roles, ac, createAPIClient, extractTokenPayload, isTokenExpired, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
6713
|
-
export type { APIClient, ApiKeyMetadata, CreateApiKeyPayload, CreateTeamPayload, FullOrganization,
|
|
6694
|
+
export type { APIClient, ApiKeyMetadata, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListMembersOptions, ExtendedMember as Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User };
|
package/dist/index.d.ts
CHANGED
|
@@ -5985,9 +5985,9 @@ type ExtendedOrganization = Organization & {
|
|
|
5985
5985
|
settings?: OrganizationSettings;
|
|
5986
5986
|
};
|
|
5987
5987
|
type FullOrganization = ExtendedOrganization & {
|
|
5988
|
-
members
|
|
5989
|
-
invitations
|
|
5990
|
-
teams
|
|
5988
|
+
members: Member[];
|
|
5989
|
+
invitations: Invitation[];
|
|
5990
|
+
teams: Team[];
|
|
5991
5991
|
};
|
|
5992
5992
|
type TeamMember = {
|
|
5993
5993
|
id: string;
|
|
@@ -5996,12 +5996,7 @@ type TeamMember = {
|
|
|
5996
5996
|
createdAt: Date;
|
|
5997
5997
|
};
|
|
5998
5998
|
|
|
5999
|
-
type
|
|
6000
|
-
includeMembers?: boolean;
|
|
6001
|
-
includeInvitations?: boolean;
|
|
6002
|
-
includeTeams?: boolean;
|
|
6003
|
-
};
|
|
6004
|
-
type UpdateOrganizationPayload = Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>;
|
|
5999
|
+
type UpdateOrganizationPayload = Partial<Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>>;
|
|
6005
6000
|
type ListMembersOptions = {
|
|
6006
6001
|
limit?: number;
|
|
6007
6002
|
offset?: number;
|
|
@@ -6047,21 +6042,24 @@ declare class OrganizationService {
|
|
|
6047
6042
|
* Retrieves a single organization by ID with optional related data.
|
|
6048
6043
|
*
|
|
6049
6044
|
* @param id - The organization ID
|
|
6050
|
-
* @
|
|
6051
|
-
* @param options.includeMembers - Include organization members
|
|
6052
|
-
* @param options.includeInvitations - Include pending invitations
|
|
6053
|
-
* @param options.includeTeams - Include organization teams
|
|
6054
|
-
* @returns The organization with optionally included related data
|
|
6045
|
+
* @returns The organization with members, invitations, and teams
|
|
6055
6046
|
*/
|
|
6056
|
-
getOrganization(id: string
|
|
6057
|
-
|
|
6047
|
+
getOrganization(id: string): Promise<{
|
|
6048
|
+
members: {
|
|
6058
6049
|
id: string;
|
|
6059
|
-
name: string;
|
|
6060
6050
|
organizationId: string;
|
|
6051
|
+
role: "org:admin" | "org:member" | "org:reviewer";
|
|
6061
6052
|
createdAt: Date;
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6053
|
+
userId: string;
|
|
6054
|
+
teamId?: string | undefined | undefined;
|
|
6055
|
+
user: {
|
|
6056
|
+
id: string;
|
|
6057
|
+
email: string;
|
|
6058
|
+
name: string;
|
|
6059
|
+
image?: string | undefined;
|
|
6060
|
+
};
|
|
6061
|
+
}[];
|
|
6062
|
+
invitations: {
|
|
6065
6063
|
id: string;
|
|
6066
6064
|
organizationId: string;
|
|
6067
6065
|
email: string;
|
|
@@ -6071,38 +6069,21 @@ declare class OrganizationService {
|
|
|
6071
6069
|
expiresAt: Date;
|
|
6072
6070
|
createdAt: Date;
|
|
6073
6071
|
teamId?: string | undefined | undefined;
|
|
6074
|
-
}[]
|
|
6075
|
-
|
|
6072
|
+
}[];
|
|
6073
|
+
teams: {
|
|
6076
6074
|
id: string;
|
|
6075
|
+
name: string;
|
|
6077
6076
|
organizationId: string;
|
|
6078
|
-
role: "org:admin" | "org:member" | "org:reviewer";
|
|
6079
6077
|
createdAt: Date;
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
id: string;
|
|
6084
|
-
email: string;
|
|
6085
|
-
name: string;
|
|
6086
|
-
image?: string | undefined;
|
|
6087
|
-
};
|
|
6088
|
-
} & {
|
|
6089
|
-
user: {
|
|
6090
|
-
id: string;
|
|
6091
|
-
name: string;
|
|
6092
|
-
email: string;
|
|
6093
|
-
image: string | null | undefined;
|
|
6094
|
-
};
|
|
6095
|
-
})[] | undefined;
|
|
6078
|
+
updatedAt?: Date | undefined;
|
|
6079
|
+
}[];
|
|
6080
|
+
} & {
|
|
6096
6081
|
id: string;
|
|
6097
6082
|
name: string;
|
|
6098
6083
|
slug: string;
|
|
6099
6084
|
createdAt: Date;
|
|
6100
|
-
logo?: string | null | undefined;
|
|
6085
|
+
logo?: string | null | undefined | undefined;
|
|
6101
6086
|
metadata?: any;
|
|
6102
|
-
settings?: {
|
|
6103
|
-
disableStorage?: boolean;
|
|
6104
|
-
dataRetentionHours?: number;
|
|
6105
|
-
};
|
|
6106
6087
|
}>;
|
|
6107
6088
|
/**
|
|
6108
6089
|
* Lists all organizations accessible to the current user.
|
|
@@ -6710,4 +6691,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
6710
6691
|
declare function extractTokenPayload(token: string): JWTTokenPayload;
|
|
6711
6692
|
|
|
6712
6693
|
export { AuthClient, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, Roles, ac, createAPIClient, extractTokenPayload, isTokenExpired, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
6713
|
-
export type { APIClient, ApiKeyMetadata, CreateApiKeyPayload, CreateTeamPayload, FullOrganization,
|
|
6694
|
+
export type { APIClient, ApiKeyMetadata, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListMembersOptions, ExtendedMember as Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User };
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { createAccessControl } from 'better-auth/plugins/access';
|
|
|
6
6
|
import { defaultStatements } from 'better-auth/plugins/organization/access';
|
|
7
7
|
export { BetterFetchError as APIError } from '@better-fetch/fetch';
|
|
8
8
|
|
|
9
|
-
const version = "1.5.
|
|
9
|
+
const version = "1.5.2";
|
|
10
10
|
|
|
11
11
|
const statements = {
|
|
12
12
|
...defaultStatements,
|
|
@@ -122,40 +122,15 @@ class OrganizationService {
|
|
|
122
122
|
* Retrieves a single organization by ID with optional related data.
|
|
123
123
|
*
|
|
124
124
|
* @param id - The organization ID
|
|
125
|
-
* @
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
* @returns The organization with optionally included related data
|
|
130
|
-
*/
|
|
131
|
-
async getOrganization(id, options) {
|
|
132
|
-
const organizationPromise = this.client.organization.list({
|
|
133
|
-
query: {
|
|
134
|
-
id
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
const membersPromise = options?.includeMembers ? this.client.organization.listMembers({
|
|
138
|
-
query: {
|
|
139
|
-
organizationId: id
|
|
140
|
-
}
|
|
141
|
-
}) : void 0;
|
|
142
|
-
const invitationsPromise = options?.includeInvitations ? this.client.organization.listInvitations({
|
|
143
|
-
query: {
|
|
144
|
-
organizationId: id
|
|
145
|
-
}
|
|
146
|
-
}) : void 0;
|
|
147
|
-
const teamsPromise = options?.includeTeams ? this.client.organization.listTeams({
|
|
125
|
+
* @returns The organization with members, invitations, and teams
|
|
126
|
+
*/
|
|
127
|
+
async getOrganization(id) {
|
|
128
|
+
const organization = await this.client.organization.getFullOrganization({
|
|
148
129
|
query: {
|
|
149
130
|
organizationId: id
|
|
150
131
|
}
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
...organization[0],
|
|
155
|
-
...members && { members: members.members },
|
|
156
|
-
...invitations && { invitations },
|
|
157
|
-
...teams && { teams }
|
|
158
|
-
};
|
|
132
|
+
});
|
|
133
|
+
return organization;
|
|
159
134
|
}
|
|
160
135
|
/**
|
|
161
136
|
* Lists all organizations accessible to the current user.
|