better-auth-studio 1.1.2-beta.15 → 1.1.2-beta.16

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.
Files changed (84) hide show
  1. package/README.md +36 -23
  2. package/data/default-geo.json +1 -1
  3. package/dist/adapters/astro.d.ts +1 -1
  4. package/dist/adapters/astro.js +13 -13
  5. package/dist/adapters/elysia.d.ts +2 -2
  6. package/dist/adapters/elysia.js +13 -13
  7. package/dist/adapters/express.d.ts +2 -2
  8. package/dist/adapters/express.js +4 -4
  9. package/dist/adapters/hono.d.ts +2 -2
  10. package/dist/adapters/hono.js +12 -12
  11. package/dist/adapters/nextjs.d.ts +1 -1
  12. package/dist/adapters/nextjs.js +10 -10
  13. package/dist/adapters/nuxt.d.ts +1 -1
  14. package/dist/adapters/nuxt.js +22 -22
  15. package/dist/adapters/remix.d.ts +1 -1
  16. package/dist/adapters/remix.js +13 -13
  17. package/dist/adapters/solid-start.d.ts +1 -1
  18. package/dist/adapters/solid-start.js +13 -13
  19. package/dist/adapters/svelte-kit.d.ts +2 -2
  20. package/dist/adapters/svelte-kit.js +13 -13
  21. package/dist/adapters/tanstack-start.d.ts +1 -1
  22. package/dist/adapters/tanstack-start.js +13 -13
  23. package/dist/add-svelte-kit-env-modules.js +11 -11
  24. package/dist/auth-adapter.d.ts +1 -1
  25. package/dist/auth-adapter.js +96 -96
  26. package/dist/cli/commands/init.js +57 -57
  27. package/dist/cli.js +75 -75
  28. package/dist/config.d.ts +5 -5
  29. package/dist/config.js +37 -37
  30. package/dist/core/handler.d.ts +1 -1
  31. package/dist/core/handler.js +115 -115
  32. package/dist/data.d.ts +2 -2
  33. package/dist/data.js +60 -60
  34. package/dist/geo-service.js +78 -78
  35. package/dist/get-tsconfig-info.js +4 -4
  36. package/dist/index.d.ts +8 -8
  37. package/dist/index.js +6 -6
  38. package/dist/providers/events/helpers.d.ts +2 -2
  39. package/dist/providers/events/helpers.js +156 -156
  40. package/dist/routes/api-router.d.ts +2 -2
  41. package/dist/routes/api-router.js +3 -3
  42. package/dist/routes.d.ts +4 -4
  43. package/dist/routes.d.ts.map +1 -1
  44. package/dist/routes.js +1272 -1272
  45. package/dist/routes.js.map +1 -1
  46. package/dist/studio.d.ts +3 -3
  47. package/dist/studio.js +64 -64
  48. package/dist/types/events.d.ts +7 -7
  49. package/dist/types/events.js +165 -165
  50. package/dist/types/handler.d.ts +5 -5
  51. package/dist/utils/auth-callbacks-injector.d.ts +2 -2
  52. package/dist/utils/auth-callbacks-injector.js +27 -27
  53. package/dist/utils/auth-callbacks-wrapper.d.ts +3 -3
  54. package/dist/utils/auth-callbacks-wrapper.js +117 -107
  55. package/dist/utils/database-detection.d.ts +1 -1
  56. package/dist/utils/database-detection.js +44 -44
  57. package/dist/utils/database-hook-injector.d.ts +3 -3
  58. package/dist/utils/database-hook-injector.js +135 -131
  59. package/dist/utils/email-otp-hooks-injector.d.ts +28 -12
  60. package/dist/utils/email-otp-hooks-injector.js +104 -97
  61. package/dist/utils/event-ingestion.d.ts +5 -5
  62. package/dist/utils/event-ingestion.d.ts.map +1 -1
  63. package/dist/utils/event-ingestion.js +14 -16
  64. package/dist/utils/event-ingestion.js.map +1 -1
  65. package/dist/utils/hook-injector.d.ts +2 -2
  66. package/dist/utils/hook-injector.js +199 -199
  67. package/dist/utils/html-injector.d.ts +3 -3
  68. package/dist/utils/html-injector.js +37 -37
  69. package/dist/utils/org-hooks-injector.d.ts +3 -3
  70. package/dist/utils/org-hooks-injector.js +63 -63
  71. package/dist/utils/org-hooks-wrapper.d.ts +41 -35
  72. package/dist/utils/org-hooks-wrapper.js +778 -658
  73. package/dist/utils/organization-hooks-wrapper.d.ts +23 -17
  74. package/dist/utils/organization-hooks-wrapper.js +325 -277
  75. package/dist/utils/package-json.js +11 -11
  76. package/dist/utils/paths.js +1 -1
  77. package/dist/utils/server-init.d.ts +1 -1
  78. package/dist/utils/server-init.js +25 -25
  79. package/dist/utils/session.js +12 -12
  80. package/dist/utils.js +24 -24
  81. package/package.json +26 -26
  82. package/scripts/download-geolite2.js +8 -8
  83. package/scripts/generate-default-db.js +324 -324
  84. package/scripts/postinstall.js +25 -25
@@ -6,7 +6,7 @@ export interface StudioMetadata {
6
6
  name?: string;
7
7
  website?: string;
8
8
  };
9
- theme?: 'light' | 'dark';
9
+ theme?: "light" | "dark";
10
10
  customStyles?: string;
11
11
  }
12
12
  export interface StudioAccessConfig {
@@ -29,7 +29,7 @@ export interface EventColors {
29
29
  error?: string;
30
30
  failed?: string;
31
31
  }
32
- export type TimeWindowPreset = '15m' | '30m' | '1h' | '2h' | '4h' | '6h' | '12h' | '1d' | '2d' | '3d' | '7d' | '14d' | '30d';
32
+ export type TimeWindowPreset = "15m" | "30m" | "1h" | "2h" | "4h" | "6h" | "12h" | "1d" | "2d" | "3d" | "7d" | "14d" | "30d";
33
33
  export type TimeWindowConfig = {
34
34
  since: TimeWindowPreset;
35
35
  custom?: never;
@@ -43,7 +43,7 @@ export interface LiveMarqueeConfig {
43
43
  speed?: number;
44
44
  pauseOnHover?: boolean;
45
45
  limit?: number;
46
- sort?: 'asc' | 'desc';
46
+ sort?: "asc" | "desc";
47
47
  colors?: EventColors;
48
48
  timeWindow?: TimeWindowConfig;
49
49
  }
@@ -1,23 +1,23 @@
1
- import { readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
3
  export function serveIndexHtml(publicDir, config = {}) {
4
- const indexPath = join(publicDir, 'index.html');
5
- let html = readFileSync(indexPath, 'utf-8');
4
+ const indexPath = join(publicDir, "index.html");
5
+ let html = readFileSync(indexPath, "utf-8");
6
6
  const frontendConfig = prepareFrontendConfig(config);
7
7
  html = injectConfig(html, frontendConfig);
8
8
  return html;
9
9
  }
10
10
  function prepareFrontendConfig(config) {
11
11
  const defaultMetadata = {
12
- title: 'Better Auth Studio',
13
- logo: '',
14
- favicon: '',
12
+ title: "Better Auth Studio",
13
+ logo: "",
14
+ favicon: "",
15
15
  company: {
16
- name: '',
17
- website: '',
16
+ name: "",
17
+ website: "",
18
18
  },
19
- theme: 'dark',
20
- customStyles: '',
19
+ theme: "dark",
20
+ customStyles: "",
21
21
  };
22
22
  const mergedMetadata = {
23
23
  ...defaultMetadata,
@@ -37,13 +37,13 @@ function prepareFrontendConfig(config) {
37
37
  speed: liveMarqueeConfig?.speed ?? 0.5, // Default: 0.5 pixels per frame
38
38
  pauseOnHover: liveMarqueeConfig?.pauseOnHover ?? true, // Default: true
39
39
  limit: liveMarqueeConfig?.limit ?? 50, // Default: 50 events in marquee
40
- sort: liveMarqueeConfig?.sort ?? 'desc', // Default: 'desc' (newest first)
40
+ sort: liveMarqueeConfig?.sort ?? "desc", // Default: 'desc' (newest first)
41
41
  colors: liveMarqueeConfig?.colors || undefined,
42
42
  timeWindow: liveMarqueeConfig?.timeWindow || undefined, // Include timeWindow config
43
43
  }
44
44
  : undefined;
45
45
  return {
46
- basePath: config.basePath || '',
46
+ basePath: config.basePath || "",
47
47
  metadata: mergedMetadata,
48
48
  liveMarquee: liveMarquee,
49
49
  };
@@ -51,16 +51,16 @@ function prepareFrontendConfig(config) {
51
51
  function injectConfig(html, config) {
52
52
  // Safely serialize (prevent XSS)
53
53
  const safeJson = JSON.stringify(config)
54
- .replace(/</g, '\\u003c')
55
- .replace(/>/g, '\\u003e')
56
- .replace(/&/g, '\\u0026');
54
+ .replace(/</g, "\\u003c")
55
+ .replace(/>/g, "\\u003e")
56
+ .replace(/&/g, "\\u0026");
57
57
  // Escape title for HTML insertion
58
58
  const escapedTitle = config.metadata.title
59
- .replace(/&/g, '&amp;')
60
- .replace(/</g, '&lt;')
61
- .replace(/>/g, '&gt;')
62
- .replace(/"/g, '&quot;')
63
- .replace(/'/g, '&#39;');
59
+ .replace(/&/g, "&amp;")
60
+ .replace(/</g, "&lt;")
61
+ .replace(/>/g, "&gt;")
62
+ .replace(/"/g, "&quot;")
63
+ .replace(/'/g, "&#39;");
64
64
  const script = `
65
65
  <script>
66
66
  window.__STUDIO_CONFIG__ = ${safeJson};
@@ -77,31 +77,31 @@ function injectConfig(html, config) {
77
77
  // Replace favicon if provided
78
78
  if (config.metadata.favicon) {
79
79
  const escapedFavicon = config.metadata.favicon
80
- .replace(/&/g, '&amp;')
81
- .replace(/</g, '&lt;')
82
- .replace(/>/g, '&gt;')
83
- .replace(/"/g, '&quot;')
84
- .replace(/'/g, '&#39;');
80
+ .replace(/&/g, "&amp;")
81
+ .replace(/</g, "&lt;")
82
+ .replace(/>/g, "&gt;")
83
+ .replace(/"/g, "&quot;")
84
+ .replace(/'/g, "&#39;");
85
85
  const faviconLower = config.metadata.favicon.toLowerCase();
86
- let mimeType = 'image/png'; // default
87
- if (faviconLower.endsWith('.ico')) {
88
- mimeType = 'image/x-icon';
86
+ let mimeType = "image/png"; // default
87
+ if (faviconLower.endsWith(".ico")) {
88
+ mimeType = "image/x-icon";
89
89
  }
90
- else if (faviconLower.endsWith('.svg')) {
91
- mimeType = 'image/svg+xml';
90
+ else if (faviconLower.endsWith(".svg")) {
91
+ mimeType = "image/svg+xml";
92
92
  }
93
- else if (faviconLower.endsWith('.jpg') || faviconLower.endsWith('.jpeg')) {
94
- mimeType = 'image/jpeg';
93
+ else if (faviconLower.endsWith(".jpg") || faviconLower.endsWith(".jpeg")) {
94
+ mimeType = "image/jpeg";
95
95
  }
96
- else if (faviconLower.endsWith('.webp')) {
97
- mimeType = 'image/webp';
96
+ else if (faviconLower.endsWith(".webp")) {
97
+ mimeType = "image/webp";
98
98
  }
99
99
  const faviconTag = `<link rel="icon" type="${mimeType}" href="${escapedFavicon}" />`;
100
100
  // Replace existing favicon/link rel="icon" tags
101
101
  modifiedHtml = modifiedHtml.replace(/<link[^>]*rel=["'](icon|shortcut icon)["'][^>]*>/gi, faviconTag);
102
102
  // If no existing favicon tag, add one before </head>
103
103
  if (!modifiedHtml.includes('rel="icon"') && !modifiedHtml.includes("rel='icon'")) {
104
- modifiedHtml = modifiedHtml.replace('</head>', ` ${faviconTag}\n</head>`);
104
+ modifiedHtml = modifiedHtml.replace("</head>", ` ${faviconTag}\n</head>`);
105
105
  }
106
106
  }
107
107
  if (config.basePath) {
@@ -114,6 +114,6 @@ function injectConfig(html, config) {
114
114
  .replace(/href="\/logo\.png"/g, `href="${basePath}/logo.png"`)
115
115
  .replace(/src="\/logo\.png"/g, `src="${basePath}/logo.png"`);
116
116
  }
117
- return modifiedHtml.replace('</head>', `${script}</head>`);
117
+ return modifiedHtml.replace("</head>", `${script}</head>`);
118
118
  }
119
119
  //# sourceMappingURL=html-injector.js.map
@@ -1,9 +1,9 @@
1
- import type { StudioConfig } from '../types/handler.js';
1
+ import type { StudioConfig } from "../types/handler.js";
2
2
  /**
3
3
  * Wraps organization hooks to automatically emit events
4
4
  * This should be used in the organization plugin's organizationHooks option
5
5
  */
6
- export declare function createOrganizationHooksWithEvents(eventsConfig: StudioConfig['events'], userHooks?: {
6
+ export declare function createOrganizationHooksWithEvents(eventsConfig: StudioConfig["events"], userHooks?: {
7
7
  beforeCreateOrganization?: any;
8
8
  afterCreateOrganization?: any;
9
9
  beforeUpdateOrganization?: any;
@@ -70,5 +70,5 @@ export declare function createOrganizationHooksWithEvents(eventsConfig: StudioCo
70
70
  * Automatically wraps organization plugin hooks to emit events
71
71
  * This should be called during Better Auth initialization
72
72
  */
73
- export declare function wrapOrganizationPluginHooks(auth: any, eventsConfig: StudioConfig['events']): void;
73
+ export declare function wrapOrganizationPluginHooks(auth: any, eventsConfig: StudioConfig["events"]): void;
74
74
  //# sourceMappingURL=org-hooks-injector.d.ts.map
@@ -1,4 +1,4 @@
1
- import { emitEvent } from './event-ingestion.js';
1
+ import { emitEvent } from "./event-ingestion.js";
2
2
  /**
3
3
  * Wraps organization hooks to automatically emit events
4
4
  * This should be used in the organization plugin's organizationHooks option
@@ -22,8 +22,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
22
22
  afterCreateOrganization: userHooks?.afterCreateOrganization
23
23
  ? async (data) => {
24
24
  await userHooks.afterCreateOrganization(data);
25
- emitEvent('organization.created', {
26
- status: 'success',
25
+ emitEvent("organization.created", {
26
+ status: "success",
27
27
  organizationId: data.organization.id,
28
28
  userId: data.user.id,
29
29
  metadata: {
@@ -36,8 +36,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
36
36
  }, capturedConfig).catch(() => { });
37
37
  }
38
38
  : async (data) => {
39
- emitEvent('organization.created', {
40
- status: 'success',
39
+ emitEvent("organization.created", {
40
+ status: "success",
41
41
  organizationId: data.organization.id,
42
42
  userId: data.user.id,
43
43
  metadata: {
@@ -59,8 +59,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
59
59
  ? async (data) => {
60
60
  await userHooks.afterUpdateOrganization?.(data);
61
61
  if (data.organization) {
62
- emitEvent('organization.updated', {
63
- status: 'success',
62
+ emitEvent("organization.updated", {
63
+ status: "success",
64
64
  organizationId: data.organization.id,
65
65
  userId: data.user.id,
66
66
  metadata: {
@@ -75,8 +75,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
75
75
  }
76
76
  : async (data) => {
77
77
  if (data.organization) {
78
- emitEvent('organization.updated', {
79
- status: 'success',
78
+ emitEvent("organization.updated", {
79
+ status: "success",
80
80
  organizationId: data.organization.id,
81
81
  userId: data.user.id,
82
82
  metadata: {
@@ -97,8 +97,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
97
97
  afterDeleteOrganization: userHooks?.afterDeleteOrganization
98
98
  ? async (data) => {
99
99
  await userHooks.afterDeleteOrganization?.(data);
100
- emitEvent('organization.deleted', {
101
- status: 'success',
100
+ emitEvent("organization.deleted", {
101
+ status: "success",
102
102
  organizationId: data.organization.id,
103
103
  userId: data.user.id,
104
104
  metadata: {
@@ -111,8 +111,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
111
111
  }, capturedConfig).catch(() => { });
112
112
  }
113
113
  : async (data) => {
114
- emitEvent('organization.deleted', {
115
- status: 'success',
114
+ emitEvent("organization.deleted", {
115
+ status: "success",
116
116
  organizationId: data.organization.id,
117
117
  userId: data.user.id,
118
118
  metadata: {
@@ -134,8 +134,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
134
134
  afterAddMember: userHooks?.afterAddMember
135
135
  ? async (data) => {
136
136
  await userHooks.afterAddMember?.(data);
137
- emitEvent('member.added', {
138
- status: 'success',
137
+ emitEvent("member.added", {
138
+ status: "success",
139
139
  organizationId: data.organization.id,
140
140
  userId: data.member.userId,
141
141
  metadata: {
@@ -151,8 +151,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
151
151
  }, capturedConfig).catch(() => { });
152
152
  }
153
153
  : async (data) => {
154
- emitEvent('member.added', {
155
- status: 'success',
154
+ emitEvent("member.added", {
155
+ status: "success",
156
156
  organizationId: data.organization.id,
157
157
  userId: data.member.userId,
158
158
  metadata: {
@@ -175,8 +175,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
175
175
  afterRemoveMember: userHooks?.afterRemoveMember
176
176
  ? async (data) => {
177
177
  await userHooks.afterRemoveMember?.(data);
178
- emitEvent('member.removed', {
179
- status: 'success',
178
+ emitEvent("member.removed", {
179
+ status: "success",
180
180
  organizationId: data.organization.id,
181
181
  userId: data.member.userId,
182
182
  metadata: {
@@ -189,8 +189,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
189
189
  }, capturedConfig).catch(() => { });
190
190
  }
191
191
  : async (data) => {
192
- emitEvent('member.removed', {
193
- status: 'success',
192
+ emitEvent("member.removed", {
193
+ status: "success",
194
194
  organizationId: data.organization.id,
195
195
  userId: data.member.userId,
196
196
  metadata: {
@@ -211,8 +211,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
211
211
  afterUpdateMemberRole: userHooks?.afterUpdateMemberRole
212
212
  ? async (data) => {
213
213
  await userHooks.afterUpdateMemberRole?.(data);
214
- emitEvent('member.role_changed', {
215
- status: 'success',
214
+ emitEvent("member.role_changed", {
215
+ status: "success",
216
216
  organizationId: data.organization.id,
217
217
  userId: data.member.userId,
218
218
  metadata: {
@@ -227,8 +227,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
227
227
  }, capturedConfig).catch(() => { });
228
228
  }
229
229
  : async (data) => {
230
- emitEvent('member.role_changed', {
231
- status: 'success',
230
+ emitEvent("member.role_changed", {
231
+ status: "success",
232
232
  organizationId: data.organization.id,
233
233
  userId: data.member.userId,
234
234
  metadata: {
@@ -252,8 +252,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
252
252
  afterCreateTeam: userHooks?.afterCreateTeam
253
253
  ? async (data) => {
254
254
  await userHooks.afterCreateTeam?.(data);
255
- emitEvent('team.created', {
256
- status: 'success',
255
+ emitEvent("team.created", {
256
+ status: "success",
257
257
  organizationId: data.organization.id,
258
258
  userId: data.user?.id,
259
259
  metadata: {
@@ -268,8 +268,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
268
268
  }, capturedConfig).catch(() => { });
269
269
  }
270
270
  : async (data) => {
271
- emitEvent('team.created', {
272
- status: 'success',
271
+ emitEvent("team.created", {
272
+ status: "success",
273
273
  organizationId: data.organization.id,
274
274
  userId: data.user?.id,
275
275
  metadata: {
@@ -293,8 +293,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
293
293
  ? async (data) => {
294
294
  await userHooks.afterUpdateTeam?.(data);
295
295
  if (data.team) {
296
- emitEvent('team.updated', {
297
- status: 'success',
296
+ emitEvent("team.updated", {
297
+ status: "success",
298
298
  organizationId: data.organization.id,
299
299
  userId: data.user.id,
300
300
  metadata: {
@@ -311,8 +311,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
311
311
  }
312
312
  : async (data) => {
313
313
  if (data.team) {
314
- emitEvent('team.updated', {
315
- status: 'success',
314
+ emitEvent("team.updated", {
315
+ status: "success",
316
316
  organizationId: data.organization.id,
317
317
  userId: data.user.id,
318
318
  metadata: {
@@ -335,8 +335,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
335
335
  afterDeleteTeam: userHooks?.afterDeleteTeam
336
336
  ? async (data) => {
337
337
  await userHooks.afterDeleteTeam?.(data);
338
- emitEvent('team.deleted', {
339
- status: 'success',
338
+ emitEvent("team.deleted", {
339
+ status: "success",
340
340
  organizationId: data.organization.id,
341
341
  userId: data.user?.id,
342
342
  metadata: {
@@ -351,8 +351,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
351
351
  }, capturedConfig).catch(() => { });
352
352
  }
353
353
  : async (data) => {
354
- emitEvent('team.deleted', {
355
- status: 'success',
354
+ emitEvent("team.deleted", {
355
+ status: "success",
356
356
  organizationId: data.organization.id,
357
357
  userId: data.user?.id,
358
358
  metadata: {
@@ -376,8 +376,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
376
376
  afterAddTeamMember: userHooks?.afterAddTeamMember
377
377
  ? async (data) => {
378
378
  await userHooks.afterAddTeamMember?.(data);
379
- emitEvent('team.member.added', {
380
- status: 'success',
379
+ emitEvent("team.member.added", {
380
+ status: "success",
381
381
  organizationId: data.organization.id,
382
382
  userId: data.teamMember.userId,
383
383
  metadata: {
@@ -395,8 +395,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
395
395
  }, capturedConfig).catch(() => { });
396
396
  }
397
397
  : async (data) => {
398
- emitEvent('team.member.added', {
399
- status: 'success',
398
+ emitEvent("team.member.added", {
399
+ status: "success",
400
400
  organizationId: data.organization.id,
401
401
  userId: data.teamMember.userId,
402
402
  metadata: {
@@ -421,8 +421,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
421
421
  afterRemoveTeamMember: userHooks?.afterRemoveTeamMember
422
422
  ? async (data) => {
423
423
  await userHooks.afterRemoveTeamMember?.(data);
424
- emitEvent('team.member.removed', {
425
- status: 'success',
424
+ emitEvent("team.member.removed", {
425
+ status: "success",
426
426
  organizationId: data.organization.id,
427
427
  userId: data.teamMember.userId,
428
428
  metadata: {
@@ -438,8 +438,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
438
438
  }, capturedConfig).catch(() => { });
439
439
  }
440
440
  : async (data) => {
441
- emitEvent('team.member.removed', {
442
- status: 'success',
441
+ emitEvent("team.member.removed", {
442
+ status: "success",
443
443
  organizationId: data.organization.id,
444
444
  userId: data.teamMember.userId,
445
445
  metadata: {
@@ -464,8 +464,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
464
464
  afterCreateInvitation: userHooks?.afterCreateInvitation
465
465
  ? async (data) => {
466
466
  await userHooks.afterCreateInvitation?.(data);
467
- emitEvent('invitation.created', {
468
- status: 'success',
467
+ emitEvent("invitation.created", {
468
+ status: "success",
469
469
  organizationId: data.organization.id,
470
470
  metadata: {
471
471
  invitationId: data.invitation.id,
@@ -482,8 +482,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
482
482
  }, capturedConfig).catch(() => { });
483
483
  }
484
484
  : async (data) => {
485
- emitEvent('invitation.created', {
486
- status: 'success',
485
+ emitEvent("invitation.created", {
486
+ status: "success",
487
487
  organizationId: data.organization.id,
488
488
  metadata: {
489
489
  invitationId: data.invitation.id,
@@ -507,8 +507,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
507
507
  afterAcceptInvitation: userHooks?.afterAcceptInvitation
508
508
  ? async (data) => {
509
509
  await userHooks.afterAcceptInvitation?.(data);
510
- emitEvent('invitation.accepted', {
511
- status: 'success',
510
+ emitEvent("invitation.accepted", {
511
+ status: "success",
512
512
  organizationId: data.organization.id,
513
513
  userId: data.user.id,
514
514
  metadata: {
@@ -523,8 +523,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
523
523
  }, capturedConfig).catch(() => { });
524
524
  }
525
525
  : async (data) => {
526
- emitEvent('invitation.accepted', {
527
- status: 'success',
526
+ emitEvent("invitation.accepted", {
527
+ status: "success",
528
528
  organizationId: data.organization.id,
529
529
  userId: data.user.id,
530
530
  metadata: {
@@ -546,8 +546,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
546
546
  afterRejectInvitation: userHooks?.afterRejectInvitation
547
547
  ? async (data) => {
548
548
  await userHooks.afterRejectInvitation?.(data);
549
- emitEvent('invitation.rejected', {
550
- status: 'success',
549
+ emitEvent("invitation.rejected", {
550
+ status: "success",
551
551
  organizationId: data.organization.id,
552
552
  userId: data.user.id,
553
553
  metadata: {
@@ -561,8 +561,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
561
561
  }, capturedConfig).catch(() => { });
562
562
  }
563
563
  : async (data) => {
564
- emitEvent('invitation.rejected', {
565
- status: 'success',
564
+ emitEvent("invitation.rejected", {
565
+ status: "success",
566
566
  organizationId: data.organization.id,
567
567
  userId: data.user.id,
568
568
  metadata: {
@@ -583,8 +583,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
583
583
  afterCancelInvitation: userHooks?.afterCancelInvitation
584
584
  ? async (data) => {
585
585
  await userHooks.afterCancelInvitation?.(data);
586
- emitEvent('invitation.cancelled', {
587
- status: 'success',
586
+ emitEvent("invitation.cancelled", {
587
+ status: "success",
588
588
  organizationId: data.organization.id,
589
589
  userId: data.cancelledBy.id,
590
590
  metadata: {
@@ -599,8 +599,8 @@ export function createOrganizationHooksWithEvents(eventsConfig, userHooks) {
599
599
  }, capturedConfig).catch(() => { });
600
600
  }
601
601
  : async (data) => {
602
- emitEvent('invitation.cancelled', {
603
- status: 'success',
602
+ emitEvent("invitation.cancelled", {
603
+ status: "success",
604
604
  organizationId: data.organization.id,
605
605
  userId: data.cancelledBy.id,
606
606
  metadata: {
@@ -626,7 +626,7 @@ export function wrapOrganizationPluginHooks(auth, eventsConfig) {
626
626
  }
627
627
  try {
628
628
  const plugins = auth.options?.plugins || [];
629
- const orgPlugin = plugins.find((p) => p?.id === 'organization');
629
+ const orgPlugin = plugins.find((p) => p?.id === "organization");
630
630
  if (!orgPlugin) {
631
631
  return;
632
632
  }
@@ -642,7 +642,7 @@ export function wrapOrganizationPluginHooks(auth, eventsConfig) {
642
642
  orgPlugin.organizationHooks = wrappedHooks;
643
643
  }
644
644
  catch (error) {
645
- console.error('[Organization Hooks] Failed to wrap hooks:', error);
645
+ console.error("[Organization Hooks] Failed to wrap hooks:", error);
646
646
  }
647
647
  }
648
648
  //# sourceMappingURL=org-hooks-injector.js.map
@@ -1,40 +1,11 @@
1
- import type { StudioConfig } from '../types/handler.js';
1
+ import type { StudioConfig } from "../types/handler.js";
2
2
  /**
3
3
  * Wraps organization hooks to automatically emit events
4
4
  * This should be used in the organization plugin's organizationHooks option
5
5
  */
6
- export declare function createOrganizationHooksWithEvents(eventsConfig: StudioConfig['events'], userHooks?: {
7
- beforeCreateOrganization?: any;
8
- afterCreateOrganization?: any;
9
- beforeUpdateOrganization?: any;
10
- afterUpdateOrganization?: any;
11
- beforeDeleteOrganization?: any;
12
- afterDeleteOrganization?: any;
13
- beforeAddMember?: any;
14
- afterAddMember?: any;
15
- beforeRemoveMember?: any;
16
- afterRemoveMember?: any;
17
- beforeUpdateMemberRole?: any;
18
- afterUpdateMemberRole?: any;
19
- beforeCreateTeam?: any;
20
- afterCreateTeam?: any;
21
- beforeUpdateTeam?: any;
22
- afterUpdateTeam?: any;
23
- beforeDeleteTeam?: any;
24
- afterDeleteTeam?: any;
25
- beforeAddTeamMember?: any;
26
- afterAddTeamMember?: any;
27
- beforeRemoveTeamMember?: any;
28
- afterRemoveTeamMember?: any;
29
- beforeCreateInvitation?: any;
30
- afterCreateInvitation?: any;
31
- beforeAcceptInvitation?: any;
32
- afterAcceptInvitation?: any;
33
- beforeRejectInvitation?: any;
34
- afterRejectInvitation?: any;
35
- beforeCancelInvitation?: any;
36
- afterCancelInvitation?: any;
37
- }): {
6
+ export declare function createOrganizationHooksWithEvents(
7
+ eventsConfig: StudioConfig["events"],
8
+ userHooks?: {
38
9
  beforeCreateOrganization?: any;
39
10
  afterCreateOrganization?: any;
40
11
  beforeUpdateOrganization?: any;
@@ -65,10 +36,45 @@ export declare function createOrganizationHooksWithEvents(eventsConfig: StudioCo
65
36
  afterRejectInvitation?: any;
66
37
  beforeCancelInvitation?: any;
67
38
  afterCancelInvitation?: any;
39
+ },
40
+ ): {
41
+ beforeCreateOrganization?: any;
42
+ afterCreateOrganization?: any;
43
+ beforeUpdateOrganization?: any;
44
+ afterUpdateOrganization?: any;
45
+ beforeDeleteOrganization?: any;
46
+ afterDeleteOrganization?: any;
47
+ beforeAddMember?: any;
48
+ afterAddMember?: any;
49
+ beforeRemoveMember?: any;
50
+ afterRemoveMember?: any;
51
+ beforeUpdateMemberRole?: any;
52
+ afterUpdateMemberRole?: any;
53
+ beforeCreateTeam?: any;
54
+ afterCreateTeam?: any;
55
+ beforeUpdateTeam?: any;
56
+ afterUpdateTeam?: any;
57
+ beforeDeleteTeam?: any;
58
+ afterDeleteTeam?: any;
59
+ beforeAddTeamMember?: any;
60
+ afterAddTeamMember?: any;
61
+ beforeRemoveTeamMember?: any;
62
+ afterRemoveTeamMember?: any;
63
+ beforeCreateInvitation?: any;
64
+ afterCreateInvitation?: any;
65
+ beforeAcceptInvitation?: any;
66
+ afterAcceptInvitation?: any;
67
+ beforeRejectInvitation?: any;
68
+ afterRejectInvitation?: any;
69
+ beforeCancelInvitation?: any;
70
+ afterCancelInvitation?: any;
68
71
  };
69
72
  /**
70
73
  * Automatically wraps organization plugin hooks to emit events
71
74
  * This should be called during Better Auth initialization
72
75
  */
73
- export declare function wrapOrganizationPluginHooks(auth: any, eventsConfig: StudioConfig['events']): void;
74
- //# sourceMappingURL=org-hooks-wrapper.d.ts.map
76
+ export declare function wrapOrganizationPluginHooks(
77
+ auth: any,
78
+ eventsConfig: StudioConfig["events"],
79
+ ): void;
80
+ //# sourceMappingURL=org-hooks-wrapper.d.ts.map