better-auth-organization-member 1.0.3 → 1.0.4
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 +58 -0
- package/dist/{client-C8Kd58Mh.d.mts → client-B37NOqhK.d.mts} +53 -9
- package/dist/client-B37NOqhK.d.mts.map +1 -0
- package/dist/{client-BxYSj_vy.mjs → client-DBKhJdwU.mjs} +9 -1
- package/dist/client-DBKhJdwU.mjs.map +1 -0
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +45 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -0
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{server-CO0gB_2G.mjs → server-BfqTHsC-.mjs} +91 -2
- package/dist/server-BfqTHsC-.mjs.map +1 -0
- package/dist/{server-DzmSHpFU.d.mts → server-uBIvbfMk.d.mts} +5 -5
- package/dist/{server-DzmSHpFU.d.mts.map → server-uBIvbfMk.d.mts.map} +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +174 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
- package/dist/client-BxYSj_vy.mjs.map +0 -1
- package/dist/client-C8Kd58Mh.d.mts.map +0 -1
- package/dist/server-CO0gB_2G.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -197,6 +197,26 @@ await client.organization.updateInvitation({
|
|
|
197
197
|
},
|
|
198
198
|
},
|
|
199
199
|
});
|
|
200
|
+
|
|
201
|
+
// List invitations with filtering and sorting (overrides original listInvitations)
|
|
202
|
+
const result = await client.organization.listInvitations({
|
|
203
|
+
query: {
|
|
204
|
+
organizationId: 'org-id', // optional
|
|
205
|
+
limit: 10,
|
|
206
|
+
offset: 0,
|
|
207
|
+
sortBy: 'createdAt',
|
|
208
|
+
sortDirection: 'desc',
|
|
209
|
+
filterField: 'status',
|
|
210
|
+
filterValue: 'pending',
|
|
211
|
+
filterOperator: 'eq',
|
|
212
|
+
},
|
|
213
|
+
fetchOptions: {
|
|
214
|
+
headers: {
|
|
215
|
+
'X-Custom-Header': 'value',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
// Response: { invitations: [...], total: number }
|
|
200
220
|
```
|
|
201
221
|
|
|
202
222
|
## API
|
|
@@ -247,6 +267,44 @@ Updates member information in an organization. Follows the **exact same permissi
|
|
|
247
267
|
- ❌ Last owner cannot demote themselves
|
|
248
268
|
- ❌ Same permission checks as the built-in role update
|
|
249
269
|
|
|
270
|
+
### Endpoint: `/organization/list-invitations`
|
|
271
|
+
|
|
272
|
+
Lists invitations in an organization with filtering, sorting, and pagination support. **This endpoint overrides the original `listInvitations` endpoint** from the organization plugin.
|
|
273
|
+
|
|
274
|
+
**Method**: `GET`
|
|
275
|
+
|
|
276
|
+
**Query Parameters**:
|
|
277
|
+
```typescript
|
|
278
|
+
{
|
|
279
|
+
organizationId?: string; // Optional: defaults to active organization
|
|
280
|
+
organizationSlug?: string; // Optional: organization slug instead of ID
|
|
281
|
+
limit?: number; // Optional: number of invitations to return (default: 100)
|
|
282
|
+
offset?: number; // Optional: offset to start from (default: 0)
|
|
283
|
+
sortBy?: string; // Optional: field to sort by
|
|
284
|
+
sortDirection?: "asc" | "desc"; // Optional: sort direction (default: "asc")
|
|
285
|
+
filterField?: string; // Optional: field to filter by
|
|
286
|
+
filterValue?: string | number | boolean; // Optional: value to filter by
|
|
287
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains"; // Optional: filter operator
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Response**:
|
|
292
|
+
```typescript
|
|
293
|
+
{
|
|
294
|
+
invitations: Invitation[]; // Array of invitations
|
|
295
|
+
total: number; // Total count of invitations (before pagination)
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
**Permissions**: Requires membership in the organization.
|
|
300
|
+
|
|
301
|
+
**Features**:
|
|
302
|
+
- ✅ **Filtering**: Filter by any field using operators (`eq`, `ne`, `lt`, `lte`, `gt`, `gte`, `contains`)
|
|
303
|
+
- ✅ **Sorting**: Sort by any field in ascending or descending order
|
|
304
|
+
- ✅ **Pagination**: Support for `limit` and `offset`
|
|
305
|
+
- ✅ **Organization support**: Can filter by `organizationId` or `organizationSlug`
|
|
306
|
+
- ✅ **Same response format as `listMembers`**: Returns `{ invitations, total }` for consistency
|
|
307
|
+
|
|
250
308
|
## Hooks
|
|
251
309
|
|
|
252
310
|
### `beforeUpdateMember`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as organizationMember } from "./server-
|
|
2
|
-
import * as
|
|
1
|
+
import { i as organizationMember } from "./server-uBIvbfMk.mjs";
|
|
2
|
+
import * as better_auth4 from "better-auth";
|
|
3
3
|
import { InferAdditionalFieldsFromPluginOptions } from "better-auth/db";
|
|
4
4
|
import * as better_auth_plugins0 from "better-auth/plugins";
|
|
5
5
|
import { InferInvitation, InferMember, OrganizationOptions } from "better-auth/plugins";
|
|
@@ -10,7 +10,7 @@ import { BetterAuthOptions } from "better-auth/types";
|
|
|
10
10
|
interface OrganizationMemberClientOptions {
|
|
11
11
|
schema?: OrganizationOptions["schema"];
|
|
12
12
|
}
|
|
13
|
-
interface OrganizationMemberClient {
|
|
13
|
+
interface OrganizationMemberClient<CO extends OrganizationMemberClientOptions = OrganizationMemberClientOptions> {
|
|
14
14
|
updateMember: <T extends Record<string, any> = {}>(data: {
|
|
15
15
|
memberId: string;
|
|
16
16
|
organizationId?: string;
|
|
@@ -33,6 +33,26 @@ interface OrganizationMemberClient {
|
|
|
33
33
|
data: any | null;
|
|
34
34
|
error: Error | null;
|
|
35
35
|
}>;
|
|
36
|
+
listInvitations: (data?: {
|
|
37
|
+
query?: {
|
|
38
|
+
limit?: number;
|
|
39
|
+
offset?: number;
|
|
40
|
+
sortBy?: string;
|
|
41
|
+
sortDirection?: "asc" | "desc";
|
|
42
|
+
filterField?: string;
|
|
43
|
+
filterValue?: string | number | boolean;
|
|
44
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains";
|
|
45
|
+
organizationId?: string;
|
|
46
|
+
organizationSlug?: string;
|
|
47
|
+
};
|
|
48
|
+
fetchOptions?: BetterFetchOption;
|
|
49
|
+
}) => Promise<{
|
|
50
|
+
data: {
|
|
51
|
+
invitations: InferInvitation<CO, false>[];
|
|
52
|
+
total: number;
|
|
53
|
+
} | null;
|
|
54
|
+
error: Error | null;
|
|
55
|
+
}>;
|
|
36
56
|
}
|
|
37
57
|
declare const organizationMemberClient: <CO extends OrganizationMemberClientOptions = OrganizationMemberClientOptions>(options?: CO) => {
|
|
38
58
|
id: "organization-member";
|
|
@@ -79,6 +99,30 @@ declare const organizationMemberClient: <CO extends OrganizationMemberClientOpti
|
|
|
79
99
|
statusText: string;
|
|
80
100
|
};
|
|
81
101
|
}>;
|
|
102
|
+
listInvitations: (data?: {
|
|
103
|
+
query?: {
|
|
104
|
+
limit?: number;
|
|
105
|
+
offset?: number;
|
|
106
|
+
sortBy?: string;
|
|
107
|
+
sortDirection?: "asc" | "desc";
|
|
108
|
+
filterField?: string;
|
|
109
|
+
filterValue?: string | number | boolean;
|
|
110
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains";
|
|
111
|
+
organizationId?: string;
|
|
112
|
+
organizationSlug?: string;
|
|
113
|
+
};
|
|
114
|
+
fetchOptions?: BetterFetchOption;
|
|
115
|
+
}) => Promise<{
|
|
116
|
+
data: unknown;
|
|
117
|
+
error: null;
|
|
118
|
+
} | {
|
|
119
|
+
data: null;
|
|
120
|
+
error: {
|
|
121
|
+
message?: string | undefined;
|
|
122
|
+
status: number;
|
|
123
|
+
statusText: string;
|
|
124
|
+
};
|
|
125
|
+
}>;
|
|
82
126
|
};
|
|
83
127
|
};
|
|
84
128
|
};
|
|
@@ -116,22 +160,22 @@ declare const inferOrgMemberAdditionalFields: <O extends {
|
|
|
116
160
|
organization?: {
|
|
117
161
|
modelName?: string;
|
|
118
162
|
fields?: { [key in keyof Omit<better_auth_plugins0.Organization, "id">]?: string };
|
|
119
|
-
additionalFields?: { [key in string]:
|
|
163
|
+
additionalFields?: { [key in string]: better_auth4.DBFieldAttribute };
|
|
120
164
|
};
|
|
121
165
|
member?: {
|
|
122
166
|
modelName?: string;
|
|
123
167
|
fields?: { [key in keyof Omit<better_auth_plugins0.Member, "id">]?: string };
|
|
124
|
-
additionalFields?: { [key in string]:
|
|
168
|
+
additionalFields?: { [key in string]: better_auth4.DBFieldAttribute };
|
|
125
169
|
};
|
|
126
170
|
invitation?: {
|
|
127
171
|
modelName?: string;
|
|
128
172
|
fields?: { [key in keyof Omit<better_auth_plugins0.Invitation, "id">]?: string };
|
|
129
|
-
additionalFields?: { [key in string]:
|
|
173
|
+
additionalFields?: { [key in string]: better_auth4.DBFieldAttribute };
|
|
130
174
|
};
|
|
131
175
|
team?: {
|
|
132
176
|
modelName?: string;
|
|
133
177
|
fields?: { [key in keyof Omit<better_auth_plugins0.Team, "id">]?: string };
|
|
134
|
-
additionalFields?: { [key in string]:
|
|
178
|
+
additionalFields?: { [key in string]: better_auth4.DBFieldAttribute };
|
|
135
179
|
};
|
|
136
180
|
teamMember?: {
|
|
137
181
|
modelName?: string;
|
|
@@ -140,11 +184,11 @@ declare const inferOrgMemberAdditionalFields: <O extends {
|
|
|
140
184
|
organizationRole?: {
|
|
141
185
|
modelName?: string;
|
|
142
186
|
fields?: { [key in keyof Omit<better_auth_plugins0.OrganizationRole, "id">]?: string };
|
|
143
|
-
additionalFields?: { [key in string]:
|
|
187
|
+
additionalFields?: { [key in string]: better_auth4.DBFieldAttribute };
|
|
144
188
|
};
|
|
145
189
|
} | undefined ? { [K in keyof S_1]: S_1[K] extends {
|
|
146
190
|
additionalFields: infer _AF;
|
|
147
191
|
} ? S_1[K] : undefined } : undefined : undefined : undefined : S;
|
|
148
192
|
//#endregion
|
|
149
193
|
export { organizationMemberClient as i, OrganizationMemberClientOptions as n, inferOrgMemberAdditionalFields as r, OrganizationMemberClient as t };
|
|
150
|
-
//# sourceMappingURL=client-
|
|
194
|
+
//# sourceMappingURL=client-B37NOqhK.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-B37NOqhK.d.mts","names":[],"sources":["../src/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAaiB,+BAAA;WACN;;UAGM,oCACJ,kCAAkC;2BAEpB;IAPV,QAAA,EAAA,MAAA;IAIA,cAAA,CAAA,EAAA,MAAwB;IAC5B,IAAA,EAAA;MAAkC,IAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;IAEpB,CAAA,GAKnB,OALmB,CAKX,CALW,CAAA;IAKX,YAAA,CAAA,EACG,iBADH;EAAR,CAAA,EAAA,GAEA,OAFA,CAAA;IACW,IAAA,EAAA,GAAA,GAAA,IAAA;IAGR,KAAA,EAAA,KAAA,GAAA,IAAA;EAFH,CAAA,CAAA;EAIuB,gBAAA,EAAA,CAAA,UAAA,MAAA,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA;IAKf,YAAA,EAAA,MAAA;IAAR,cAAA,CAAA,EAAA,MAAA;IACW,IAAA,EAAA;MAGR,IAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;IAFH,CAAA,GAFA,OAEA,CAFQ,CAER,CAAA;IAgBW,YAAA,CAAA,EAjBA,iBAiBA;EAGgB,CAAA,EAAA,GAnB3B,OAmB2B,CAAA;IAAhB,IAAA,EAAA,GAAA,GAAA,IAAA;IAGR,KAAA,EApBA,KAoBA,GAAA,IAAA;EALH,CAAA,CAAA;EAAO,eAAA,EAAA,CAAA,IA8BO,CA9BP,EAAA;IASF,KAAA,CAAA,EAAA;MACA,KAAA,CAAA,EAAA,MAAA;MAAkC,MAAA,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AA7H,oBAAA,CAA6H,gBAAA;0CAAA,YAAA,CAAmF,gBAAA;;8BAjB7zD,MAAA,IAAA;;+DAewC"}
|
|
@@ -24,6 +24,14 @@ const organizationMemberClient = (options) => {
|
|
|
24
24
|
body,
|
|
25
25
|
fetchOptions
|
|
26
26
|
});
|
|
27
|
+
},
|
|
28
|
+
listInvitations: async (data) => {
|
|
29
|
+
const { fetchOptions, query } = data || {};
|
|
30
|
+
return await $fetch("/organization/list-invitations", {
|
|
31
|
+
method: "GET",
|
|
32
|
+
query,
|
|
33
|
+
fetchOptions
|
|
34
|
+
});
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
})
|
|
@@ -39,4 +47,4 @@ const inferOrgMemberAdditionalFields = (schema) => {
|
|
|
39
47
|
|
|
40
48
|
//#endregion
|
|
41
49
|
export { organizationMemberClient as n, inferOrgMemberAdditionalFields as t };
|
|
42
|
-
//# sourceMappingURL=client-
|
|
50
|
+
//# sourceMappingURL=client-DBKhJdwU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-DBKhJdwU.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type {\n BetterAuthClientPlugin,\n BetterFetch,\n BetterFetchOption,\n} from \"better-auth/client\";\nimport type { InferAdditionalFieldsFromPluginOptions } from \"better-auth/db\";\nimport type {\n InferInvitation,\n InferMember,\n OrganizationOptions,\n} from \"better-auth/plugins\";\nimport type { BetterAuthOptions, BetterAuthPlugin } from \"better-auth/types\";\n\nexport interface OrganizationMemberClientOptions {\n schema?: OrganizationOptions[\"schema\"];\n}\n\nexport interface OrganizationMemberClient<\n CO extends OrganizationMemberClientOptions = OrganizationMemberClientOptions,\n> {\n updateMember: <T extends Record<string, any> = {}>(data: {\n memberId: string;\n organizationId?: string;\n data: {\n role?: string | string[];\n } & Partial<T>;\n fetchOptions?: BetterFetchOption;\n }) => Promise<{\n data: any | null;\n error: Error | null;\n }>;\n updateInvitation: <T extends Record<string, any> = {}>(data: {\n invitationId: string;\n organizationId?: string;\n data: {\n role?: string | string[];\n } & Partial<T>;\n fetchOptions?: BetterFetchOption;\n }) => Promise<{\n data: any | null;\n error: Error | null;\n }>;\n listInvitations: (data?: {\n query?: {\n limit?: number;\n offset?: number;\n sortBy?: string;\n sortDirection?: \"asc\" | \"desc\";\n filterField?: string;\n filterValue?: string | number | boolean;\n filterOperator?: \"eq\" | \"ne\" | \"lt\" | \"lte\" | \"gt\" | \"gte\" | \"contains\";\n organizationId?: string;\n organizationSlug?: string;\n };\n fetchOptions?: BetterFetchOption;\n }) => Promise<{\n data: {\n invitations: InferInvitation<CO, false>[];\n total: number;\n } | null;\n error: Error | null;\n }>;\n}\n\nexport const organizationMemberClient = <\n CO extends OrganizationMemberClientOptions = OrganizationMemberClientOptions,\n>(\n options?: CO\n) => {\n return {\n id: \"organization-member\",\n $InferServerPlugin: {} as ReturnType<\n typeof import(\"./server\").organizationMember\n >,\n getActions: ($fetch: BetterFetch) => ({\n $Infer: {\n Member: {} as InferMember<CO, false>,\n Invitation: {} as InferInvitation<CO, false>,\n },\n organization: {\n updateMember: async (data: {\n memberId: string;\n organizationId?: string;\n data: {\n role?: string | string[];\n } & Partial<InferAdditionalFieldsFromPluginOptions<\"member\", CO>>;\n fetchOptions?: BetterFetchOption;\n }) => {\n const { fetchOptions, ...body } = data;\n return await $fetch(\"/organization/update-member\", {\n method: \"POST\",\n body,\n fetchOptions,\n });\n },\n updateInvitation: async (data: {\n invitationId: string;\n organizationId?: string;\n data: {\n role?: string | string[];\n } & Partial<InferAdditionalFieldsFromPluginOptions<\"invitation\", CO>>;\n fetchOptions?: BetterFetchOption;\n }) => {\n const { fetchOptions, ...body } = data;\n return await $fetch(\"/organization/update-invitation\", {\n method: \"POST\",\n body,\n fetchOptions,\n });\n },\n listInvitations: async (data?: {\n query?: {\n limit?: number;\n offset?: number;\n sortBy?: string;\n sortDirection?: \"asc\" | \"desc\";\n filterField?: string;\n filterValue?: string | number | boolean;\n filterOperator?:\n | \"eq\"\n | \"ne\"\n | \"lt\"\n | \"lte\"\n | \"gt\"\n | \"gte\"\n | \"contains\";\n organizationId?: string;\n organizationSlug?: string;\n };\n fetchOptions?: BetterFetchOption;\n }) => {\n const { fetchOptions, query } = data || {};\n return await $fetch(\"/organization/list-invitations\", {\n method: \"GET\",\n query,\n fetchOptions,\n });\n },\n },\n }),\n } satisfies BetterAuthClientPlugin;\n};\n\n/**\n * Infer additional fields from the auth object type or schema\n * Similar to inferOrgAdditionalFields from better-auth/plugins/organization/client\n */\nexport const inferOrgMemberAdditionalFields = <\n O extends {\n options: BetterAuthOptions;\n },\n S extends OrganizationMemberClientOptions[\"schema\"] = undefined,\n>(\n schema?: S | undefined\n) => {\n type FindById<\n T extends readonly BetterAuthPlugin[],\n TargetId extends string,\n > = Extract<T[number], { id: TargetId }>;\n\n type Auth = O extends { options: any } ? O : { options: { plugins: [] } };\n\n type OrganizationMemberPlugin = FindById<\n // @ts-expect-error\n Auth[\"options\"][\"plugins\"],\n \"organization-member\"\n >;\n\n // The server schema can contain more properties other than additionalFields, but the client only supports additionalFields\n // if we don't remove all other properties we may see assignability issues\n\n type ExtractClientOnlyFields<T> = {\n [K in keyof T]: T[K] extends { additionalFields: infer _AF }\n ? T[K]\n : undefined;\n };\n\n type Schema = O extends Object\n ? O extends Exclude<S, undefined>\n ? O\n : OrganizationMemberPlugin extends { options: { schema: infer S } }\n ? S extends OrganizationMemberClientOptions[\"schema\"]\n ? ExtractClientOnlyFields<S>\n : undefined\n : undefined\n : undefined;\n\n return {} as undefined extends S ? Schema : S;\n};\n"],"mappings":";AAgEA,MAAa,4BAGX,YACG;AACH,QAAO;EACL,IAAI;EACJ,oBAAoB,EAAE;EAGtB,aAAa,YAAyB;GACpC,QAAQ;IACN,QAAQ,EAAE;IACV,YAAY,EAAE;IACf;GACD,cAAc;IACZ,cAAc,OAAO,SAOf;KACJ,MAAM,EAAE,cAAc,GAAG,SAAS;AAClC,YAAO,MAAM,OAAO,+BAA+B;MACjD,QAAQ;MACR;MACA;MACD,CAAC;;IAEJ,kBAAkB,OAAO,SAOnB;KACJ,MAAM,EAAE,cAAc,GAAG,SAAS;AAClC,YAAO,MAAM,OAAO,mCAAmC;MACrD,QAAQ;MACR;MACA;MACD,CAAC;;IAEJ,iBAAiB,OAAO,SAoBlB;KACJ,MAAM,EAAE,cAAc,UAAU,QAAQ,EAAE;AAC1C,YAAO,MAAM,OAAO,kCAAkC;MACpD,QAAQ;MACR;MACA;MACD,CAAC;;IAEL;GACF;EACF;;;;;;AAOH,MAAa,kCAMX,WACG;AAiCH,QAAO,EAAE"}
|
package/dist/client.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./server-
|
|
2
|
-
import { i as organizationMemberClient, n as OrganizationMemberClientOptions, r as inferOrgMemberAdditionalFields, t as OrganizationMemberClient } from "./client-
|
|
1
|
+
import "./server-uBIvbfMk.mjs";
|
|
2
|
+
import { i as organizationMemberClient, n as OrganizationMemberClientOptions, r as inferOrgMemberAdditionalFields, t as OrganizationMemberClient } from "./client-B37NOqhK.mjs";
|
|
3
3
|
export { OrganizationMemberClient, OrganizationMemberClientOptions, inferOrgMemberAdditionalFields, organizationMemberClient };
|
package/dist/client.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { BetterAuthOptions } from "better-auth/types";
|
|
|
5
5
|
export interface OrganizationMemberClientOptions {
|
|
6
6
|
schema?: OrganizationOptions["schema"];
|
|
7
7
|
}
|
|
8
|
-
export interface OrganizationMemberClient {
|
|
8
|
+
export interface OrganizationMemberClient<CO extends OrganizationMemberClientOptions = OrganizationMemberClientOptions> {
|
|
9
9
|
updateMember: <T extends Record<string, any> = {}>(data: {
|
|
10
10
|
memberId: string;
|
|
11
11
|
organizationId?: string;
|
|
@@ -28,6 +28,26 @@ export interface OrganizationMemberClient {
|
|
|
28
28
|
data: any | null;
|
|
29
29
|
error: Error | null;
|
|
30
30
|
}>;
|
|
31
|
+
listInvitations: (data?: {
|
|
32
|
+
query?: {
|
|
33
|
+
limit?: number;
|
|
34
|
+
offset?: number;
|
|
35
|
+
sortBy?: string;
|
|
36
|
+
sortDirection?: "asc" | "desc";
|
|
37
|
+
filterField?: string;
|
|
38
|
+
filterValue?: string | number | boolean;
|
|
39
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains";
|
|
40
|
+
organizationId?: string;
|
|
41
|
+
organizationSlug?: string;
|
|
42
|
+
};
|
|
43
|
+
fetchOptions?: BetterFetchOption;
|
|
44
|
+
}) => Promise<{
|
|
45
|
+
data: {
|
|
46
|
+
invitations: InferInvitation<CO, false>[];
|
|
47
|
+
total: number;
|
|
48
|
+
} | null;
|
|
49
|
+
error: Error | null;
|
|
50
|
+
}>;
|
|
31
51
|
}
|
|
32
52
|
export declare const organizationMemberClient: <CO extends OrganizationMemberClientOptions = OrganizationMemberClientOptions>(options?: CO) => {
|
|
33
53
|
id: "organization-member";
|
|
@@ -74,6 +94,30 @@ export declare const organizationMemberClient: <CO extends OrganizationMemberCli
|
|
|
74
94
|
statusText: string;
|
|
75
95
|
};
|
|
76
96
|
}>;
|
|
97
|
+
listInvitations: (data?: {
|
|
98
|
+
query?: {
|
|
99
|
+
limit?: number;
|
|
100
|
+
offset?: number;
|
|
101
|
+
sortBy?: string;
|
|
102
|
+
sortDirection?: "asc" | "desc";
|
|
103
|
+
filterField?: string;
|
|
104
|
+
filterValue?: string | number | boolean;
|
|
105
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains";
|
|
106
|
+
organizationId?: string;
|
|
107
|
+
organizationSlug?: string;
|
|
108
|
+
};
|
|
109
|
+
fetchOptions?: BetterFetchOption;
|
|
110
|
+
}) => Promise<{
|
|
111
|
+
data: unknown;
|
|
112
|
+
error: null;
|
|
113
|
+
} | {
|
|
114
|
+
data: null;
|
|
115
|
+
error: {
|
|
116
|
+
message?: string | undefined;
|
|
117
|
+
status: number;
|
|
118
|
+
statusText: string;
|
|
119
|
+
};
|
|
120
|
+
}>;
|
|
77
121
|
};
|
|
78
122
|
};
|
|
79
123
|
};
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAE7E,MAAM,WAAW,+BAA+B;IAC9C,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,wBAAwB;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAE7E,MAAM,WAAW,+BAA+B;IAC9C,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,wBAAwB,CACvC,EAAE,SAAS,+BAA+B,GAAG,+BAA+B;IAE5E,YAAY,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE;QACvD,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,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A+C,MAAM,GAAG;gEAehB,CAC7C,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -24,6 +24,14 @@ export const organizationMemberClient = (options) => {
|
|
|
24
24
|
fetchOptions,
|
|
25
25
|
});
|
|
26
26
|
},
|
|
27
|
+
listInvitations: async (data) => {
|
|
28
|
+
const { fetchOptions, query } = data || {};
|
|
29
|
+
return await $fetch("/organization/list-invitations", {
|
|
30
|
+
method: "GET",
|
|
31
|
+
query,
|
|
32
|
+
fetchOptions,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
27
35
|
},
|
|
28
36
|
}),
|
|
29
37
|
};
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAgEA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAGtC,OAAY,EACZ,EAAE;IACF,OAAO;QACL,EAAE,EAAE,qBAAqB;QACzB,kBAAkB,EAAE,EAEnB;QACD,UAAU,EAAE,CAAC,MAAmB,EAAE,EAAE,CAAC,CAAC;YACpC,MAAM,EAAE;gBACN,MAAM,EAAE,EAA4B;gBACpC,UAAU,EAAE,EAAgC;aAC7C;YACD,YAAY,EAAE;gBACZ,YAAY,EAAE,KAAK,EAAE,IAOpB,EAAE,EAAE;oBACH,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;oBACvC,OAAO,MAAM,MAAM,CAAC,6BAA6B,EAAE;wBACjD,MAAM,EAAE,MAAM;wBACd,IAAI;wBACJ,YAAY;qBACb,CAAC,CAAC;gBACL,CAAC;gBACD,gBAAgB,EAAE,KAAK,EAAE,IAOxB,EAAE,EAAE;oBACH,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;oBACvC,OAAO,MAAM,MAAM,CAAC,iCAAiC,EAAE;wBACrD,MAAM,EAAE,MAAM;wBACd,IAAI;wBACJ,YAAY;qBACb,CAAC,CAAC;gBACL,CAAC;gBACD,eAAe,EAAE,KAAK,EAAE,IAoBvB,EAAE,EAAE;oBACH,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;oBAC3C,OAAO,MAAM,MAAM,CAAC,gCAAgC,EAAE;wBACpD,MAAM,EAAE,KAAK;wBACb,KAAK;wBACL,YAAY;qBACb,CAAC,CAAC;gBACL,CAAC;aACF;SACF,CAAC;KAC8B,CAAC;AACrC,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAM5C,MAAsB,EACtB,EAAE;IAiCF,OAAO,EAAsC,CAAC;AAChD,CAAC,CAAC"}
|
package/dist/client.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as organizationMemberClient, t as inferOrgMemberAdditionalFields } from "./client-
|
|
1
|
+
import { n as organizationMemberClient, t as inferOrgMemberAdditionalFields } from "./client-DBKhJdwU.mjs";
|
|
2
2
|
|
|
3
3
|
export { inferOrgMemberAdditionalFields, organizationMemberClient };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as organizationMember, t as OrganizationMemberOptions } from "./server-
|
|
2
|
-
import { i as organizationMemberClient, n as OrganizationMemberClientOptions, r as inferOrgMemberAdditionalFields, t as OrganizationMemberClient } from "./client-
|
|
1
|
+
import { i as organizationMember, t as OrganizationMemberOptions } from "./server-uBIvbfMk.mjs";
|
|
2
|
+
import { i as organizationMemberClient, n as OrganizationMemberClientOptions, r as inferOrgMemberAdditionalFields, t as OrganizationMemberClient } from "./client-B37NOqhK.mjs";
|
|
3
3
|
export { type OrganizationMemberClient, type OrganizationMemberClientOptions, type OrganizationMemberOptions, inferOrgMemberAdditionalFields, organizationMember, organizationMemberClient };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as organizationMember } from "./server-
|
|
2
|
-
import { n as organizationMemberClient, t as inferOrgMemberAdditionalFields } from "./client-
|
|
1
|
+
import { r as organizationMember } from "./server-BfqTHsC-.mjs";
|
|
2
|
+
import { n as organizationMemberClient, t as inferOrgMemberAdditionalFields } from "./client-DBKhJdwU.mjs";
|
|
3
3
|
|
|
4
4
|
export { inferOrgMemberAdditionalFields, organizationMember, organizationMemberClient };
|
|
@@ -900,6 +900,94 @@ const createUpdateInvitationEndpoint = (options) => {
|
|
|
900
900
|
return ctx.json(updatedInvitation);
|
|
901
901
|
});
|
|
902
902
|
};
|
|
903
|
+
const createListInvitationsEndpoint = (options) => {
|
|
904
|
+
return createAuthEndpoint("/organization/list-invitations", {
|
|
905
|
+
method: "GET",
|
|
906
|
+
query: z.object({
|
|
907
|
+
limit: z.string().meta({ description: "The number of invitations to return" }).or(z.number()).optional(),
|
|
908
|
+
offset: z.string().meta({ description: "The offset to start from" }).or(z.number()).optional(),
|
|
909
|
+
sortBy: z.string().meta({ description: "The field to sort by" }).optional(),
|
|
910
|
+
sortDirection: z.enum(["asc", "desc"]).meta({ description: "The direction to sort by" }).optional(),
|
|
911
|
+
filterField: z.string().meta({ description: "The field to filter by" }).optional(),
|
|
912
|
+
filterValue: z.string().meta({ description: "The value to filter by" }).or(z.number()).or(z.boolean()).optional(),
|
|
913
|
+
filterOperator: z.enum([
|
|
914
|
+
"eq",
|
|
915
|
+
"ne",
|
|
916
|
+
"lt",
|
|
917
|
+
"lte",
|
|
918
|
+
"gt",
|
|
919
|
+
"gte",
|
|
920
|
+
"contains"
|
|
921
|
+
]).meta({ description: "The operator to use for the filter" }).optional(),
|
|
922
|
+
organizationId: z.string().meta({ description: "The organization ID to list invitations for. If not provided, will default to the user's active organization. Eg: \"organization-id\"" }).optional(),
|
|
923
|
+
organizationSlug: z.string().meta({ description: "The organization slug to list invitations for. If not provided, will default to the user's active organization. Eg: \"organization-slug\"" }).optional()
|
|
924
|
+
}).optional(),
|
|
925
|
+
requireHeaders: true,
|
|
926
|
+
use: [orgMiddleware, orgSessionMiddleware],
|
|
927
|
+
metadata: {
|
|
928
|
+
$Infer: { query: {} },
|
|
929
|
+
openapi: {
|
|
930
|
+
operationId: "listOrganizationInvitations",
|
|
931
|
+
description: "List invitations in an organization with filtering and sorting",
|
|
932
|
+
responses: { "200": {
|
|
933
|
+
description: "Success",
|
|
934
|
+
content: { "application/json": { schema: {
|
|
935
|
+
type: "object",
|
|
936
|
+
properties: {
|
|
937
|
+
invitations: {
|
|
938
|
+
type: "array",
|
|
939
|
+
items: { type: "object" }
|
|
940
|
+
},
|
|
941
|
+
total: { type: "number" }
|
|
942
|
+
}
|
|
943
|
+
} } }
|
|
944
|
+
} }
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}, async (ctx) => {
|
|
948
|
+
const session = ctx.context.session;
|
|
949
|
+
let organizationId = ctx.query?.organizationId || session.session.activeOrganizationId;
|
|
950
|
+
const organizationPlugin = getOrganizationPlugin(ctx.context);
|
|
951
|
+
if (!organizationPlugin) throw new Error("organization-member plugin requires the organization plugin");
|
|
952
|
+
const adapter = getOrgAdapter(ctx.context, organizationPlugin.options);
|
|
953
|
+
if (ctx.query?.organizationSlug) {
|
|
954
|
+
const organization = await adapter.findOrganizationBySlug(ctx.query.organizationSlug);
|
|
955
|
+
if (!organization) throw new APIError("BAD_REQUEST", { message: ORGANIZATION_ERROR_CODES.ORGANIZATION_NOT_FOUND });
|
|
956
|
+
organizationId = organization.id;
|
|
957
|
+
}
|
|
958
|
+
if (!organizationId) throw new APIError("BAD_REQUEST", { message: ORGANIZATION_ERROR_CODES.NO_ACTIVE_ORGANIZATION });
|
|
959
|
+
if (!await adapter.findMemberByOrgId({
|
|
960
|
+
userId: session.user.id,
|
|
961
|
+
organizationId
|
|
962
|
+
})) throw new APIError("FORBIDDEN", { message: ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION });
|
|
963
|
+
const where = [{
|
|
964
|
+
field: "organizationId",
|
|
965
|
+
value: organizationId
|
|
966
|
+
}];
|
|
967
|
+
if (ctx.query?.filterField) where.push({
|
|
968
|
+
field: ctx.query.filterField,
|
|
969
|
+
value: ctx.query.filterValue,
|
|
970
|
+
...ctx.query.filterOperator ? { operator: ctx.query.filterOperator } : {}
|
|
971
|
+
});
|
|
972
|
+
const [invitations, total] = await Promise.all([ctx.context.adapter.findMany({
|
|
973
|
+
model: "invitation",
|
|
974
|
+
where,
|
|
975
|
+
limit: ctx.query?.limit ? Number(ctx.query.limit) : 100,
|
|
976
|
+
offset: ctx.query?.offset ? Number(ctx.query.offset) : 0,
|
|
977
|
+
sortBy: ctx.query?.sortBy ? {
|
|
978
|
+
field: ctx.query.sortBy,
|
|
979
|
+
direction: ctx.query.sortDirection || "asc"
|
|
980
|
+
} : void 0
|
|
981
|
+
}), ctx.context.adapter.count({
|
|
982
|
+
model: "invitation",
|
|
983
|
+
where
|
|
984
|
+
})]);
|
|
985
|
+
return ctx.json({
|
|
986
|
+
invitations,
|
|
987
|
+
total
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
};
|
|
903
991
|
const organizationMember = (userConfig) => {
|
|
904
992
|
({ ...userConfig });
|
|
905
993
|
return {
|
|
@@ -939,7 +1027,8 @@ const organizationMember = (userConfig) => {
|
|
|
939
1027
|
},
|
|
940
1028
|
endpoints: {
|
|
941
1029
|
updateMember: createUpdateMemberEndpoint(userConfig),
|
|
942
|
-
updateInvitation: createUpdateInvitationEndpoint(userConfig)
|
|
1030
|
+
updateInvitation: createUpdateInvitationEndpoint(userConfig),
|
|
1031
|
+
listInvitations: createListInvitationsEndpoint(userConfig)
|
|
943
1032
|
},
|
|
944
1033
|
options: userConfig,
|
|
945
1034
|
$ERROR_CODES: ORGANIZATION_ERROR_CODES
|
|
@@ -948,4 +1037,4 @@ const organizationMember = (userConfig) => {
|
|
|
948
1037
|
|
|
949
1038
|
//#endregion
|
|
950
1039
|
export { orgSessionMiddleware as n, organizationMember as r, orgMiddleware as t };
|
|
951
|
-
//# sourceMappingURL=server-
|
|
1040
|
+
//# sourceMappingURL=server-BfqTHsC-.mjs.map
|