@authhero/multi-tenancy 14.12.0 → 14.14.0

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.
@@ -1,30 +1,30 @@
1
- var Y = Object.defineProperty;
2
- var Z = (e, t, n) => t in e ? Y(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var M = (e, t, n) => Z(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { Hono as x } from "hono";
5
- import { MANAGEMENT_API_SCOPES as ee, MANAGEMENT_API_AUDIENCE as Q, fetchAll as z, auth0QuerySchema as te, tenantSchema as N, tenantInsertSchema as ne, connectionSchema as re, connectionOptionsSchema as se, init as ae } from "authhero";
6
- import { OpenAPIHono as oe, createRoute as O, z as S } from "@hono/zod-openapi";
7
- function ie(e) {
1
+ var Z = Object.defineProperty;
2
+ var x = (e, t, n) => t in e ? Z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var q = (e, t, n) => x(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { Hono as ee } from "hono";
5
+ import { MANAGEMENT_API_SCOPES as te, MANAGEMENT_API_AUDIENCE as V, fetchAll as M, auth0QuerySchema as ne, tenantSchema as B, tenantInsertSchema as re, connectionSchema as ae, connectionOptionsSchema as se, init as oe } from "authhero";
6
+ import { OpenAPIHono as ie, createRoute as j, z } from "@hono/zod-openapi";
7
+ function ce(e) {
8
8
  const { controlPlaneTenantId: t, requireOrganizationMatch: n = !0 } = e;
9
9
  return {
10
- async onTenantAccessValidation(r, s) {
11
- if (s === t)
10
+ async onTenantAccessValidation(r, a) {
11
+ if (a === t)
12
12
  return !0;
13
13
  if (n) {
14
- const a = r.var.org_name, o = r.var.organization_id, i = a || o;
15
- return i ? i.toLowerCase() === s.toLowerCase() : !1;
14
+ const s = r.var.org_name, o = r.var.organization_id, i = s || o;
15
+ return i ? i.toLowerCase() === a.toLowerCase() : !1;
16
16
  }
17
17
  return !0;
18
18
  }
19
19
  };
20
20
  }
21
- function ce(e, t, n, r) {
21
+ function le(e, t, n, r) {
22
22
  if (t === n)
23
23
  return !0;
24
- const s = r || e;
25
- return s ? s.toLowerCase() === t.toLowerCase() : !1;
24
+ const a = r || e;
25
+ return a ? a.toLowerCase() === t.toLowerCase() : !1;
26
26
  }
27
- function le(e) {
27
+ function ue(e) {
28
28
  return {
29
29
  async resolveDataAdapters(t) {
30
30
  try {
@@ -39,23 +39,23 @@ function le(e) {
39
39
  }
40
40
  };
41
41
  }
42
- function ue(e) {
42
+ function de(e) {
43
43
  return `urn:authhero:tenant:${e.toLowerCase()}`;
44
44
  }
45
- function de(e) {
45
+ function J(e) {
46
46
  return {
47
47
  async beforeCreate(t, n) {
48
48
  return !n.audience && n.id ? {
49
49
  ...n,
50
- audience: ue(n.id)
50
+ audience: de(n.id)
51
51
  } : n;
52
52
  },
53
53
  async afterCreate(t, n) {
54
- const { accessControl: r, databaseIsolation: s } = e;
55
- r && t.ctx && await fe(t, n, r), s != null && s.onProvision && await s.onProvision(n.id);
54
+ const { accessControl: r, databaseIsolation: a } = e;
55
+ r && t.ctx && await fe(t, n, r), a != null && a.onProvision && await a.onProvision(n.id);
56
56
  },
57
57
  async beforeDelete(t, n) {
58
- const { accessControl: r, databaseIsolation: s } = e;
58
+ const { accessControl: r, databaseIsolation: a } = e;
59
59
  if (r)
60
60
  try {
61
61
  const o = (await t.adapters.organizations.list(
@@ -65,19 +65,19 @@ function de(e) {
65
65
  r.controlPlaneTenantId,
66
66
  o.id
67
67
  );
68
- } catch (a) {
68
+ } catch (s) {
69
69
  console.warn(
70
70
  `Failed to remove organization for tenant ${n}:`,
71
- a
71
+ s
72
72
  );
73
73
  }
74
- if (s != null && s.onDeprovision)
74
+ if (a != null && a.onDeprovision)
75
75
  try {
76
- await s.onDeprovision(n);
77
- } catch (a) {
76
+ await a.onDeprovision(n);
77
+ } catch (s) {
78
78
  console.warn(
79
79
  `Failed to deprovision database for tenant ${n}:`,
80
- a
80
+ s
81
81
  );
82
82
  }
83
83
  }
@@ -86,8 +86,8 @@ function de(e) {
86
86
  async function fe(e, t, n) {
87
87
  const {
88
88
  controlPlaneTenantId: r,
89
- defaultPermissions: s,
90
- defaultRoles: a,
89
+ defaultPermissions: a,
90
+ defaultRoles: s,
91
91
  issuer: o,
92
92
  adminRoleName: i = "Tenant Admin",
93
93
  adminRoleDescription: u = "Full access to all tenant management operations",
@@ -130,10 +130,10 @@ async function fe(e, t, n) {
130
130
  );
131
131
  }
132
132
  }
133
- a && a.length > 0 && console.log(
134
- `Would assign roles ${a.join(", ")} to organization ${l.id}`
135
- ), s && s.length > 0 && console.log(
136
- `Would grant permissions ${s.join(", ")} to organization ${l.id}`
133
+ s && s.length > 0 && console.log(
134
+ `Would assign roles ${s.join(", ")} to organization ${l.id}`
135
+ ), a && a.length > 0 && console.log(
136
+ `Would grant permissions ${a.join(", ")} to organization ${l.id}`
137
137
  );
138
138
  }
139
139
  async function me(e, t, n) {
@@ -144,10 +144,10 @@ async function me(e, t, n) {
144
144
  ""
145
145
  // Empty string for global roles
146
146
  );
147
- for (const s of r)
147
+ for (const a of r)
148
148
  if ((await e.adapters.rolePermissions.list(
149
149
  t,
150
- s.id,
150
+ a.id,
151
151
  { per_page: 1e3 }
152
152
  )).some(
153
153
  (i) => i.permission_name === "admin:organizations"
@@ -156,13 +156,13 @@ async function me(e, t, n) {
156
156
  return !1;
157
157
  }
158
158
  async function ge(e, t, n, r) {
159
- const a = (await e.adapters.roles.list(t, {})).roles.find((c) => c.name === n);
160
- if (a)
161
- return a.id;
159
+ const s = (await e.adapters.roles.list(t, {})).roles.find((c) => c.name === n);
160
+ if (s)
161
+ return s.id;
162
162
  const o = await e.adapters.roles.create(t, {
163
163
  name: n,
164
164
  description: r
165
- }), i = Q, u = ee.map((c) => ({
165
+ }), i = V, u = te.map((c) => ({
166
166
  role_id: o.id,
167
167
  resource_server_identifier: i,
168
168
  permission_name: c.value
@@ -173,8 +173,8 @@ async function ge(e, t, n, r) {
173
173
  u
174
174
  ), o.id;
175
175
  }
176
- function H(e, t, n = () => !0) {
177
- const { controlPlaneTenantId: r, getChildTenantIds: s, getAdapters: a } = e, o = /* @__PURE__ */ new Map();
176
+ function G(e, t, n = () => !0) {
177
+ const { controlPlaneTenantId: r, getChildTenantIds: a, getAdapters: s } = e, o = /* @__PURE__ */ new Map();
178
178
  async function i(l, g, d) {
179
179
  return (await t(l).list(g, {
180
180
  q: `name:${d}`,
@@ -182,19 +182,19 @@ function H(e, t, n = () => !0) {
182
182
  }))[0] ?? null;
183
183
  }
184
184
  async function u(l) {
185
- const g = await s(), d = t(await a(r));
185
+ const g = await a(), d = t(await s(r));
186
186
  await Promise.all(
187
187
  g.map(async (f) => {
188
188
  try {
189
- const m = await a(f), w = t(m), p = {
189
+ const m = await s(f), w = t(m), h = {
190
190
  ...d.transform(l),
191
191
  is_system: !0
192
- }, y = await i(m, f, l.name), _ = y ? w.getId(y) : void 0;
193
- if (y && _) {
194
- const T = w.preserveOnUpdate ? w.preserveOnUpdate(y, p) : p;
195
- await w.update(f, _, T);
192
+ }, _ = await i(m, f, l.name), P = _ ? w.getId(_) : void 0;
193
+ if (_ && P) {
194
+ const b = w.preserveOnUpdate ? w.preserveOnUpdate(_, h) : h;
195
+ await w.update(f, P, b);
196
196
  } else
197
- await w.create(f, p);
197
+ await w.create(f, h);
198
198
  } catch (m) {
199
199
  console.error(
200
200
  `Failed to sync ${d.listKey} "${l.name}" to tenant "${f}":`,
@@ -205,12 +205,12 @@ function H(e, t, n = () => !0) {
205
205
  );
206
206
  }
207
207
  async function c(l) {
208
- const g = await s();
208
+ const g = await a();
209
209
  await Promise.all(
210
210
  g.map(async (d) => {
211
211
  try {
212
- const f = await a(d), m = t(f), w = await i(f, d, l), h = w ? m.getId(w) : void 0;
213
- w && h && await m.remove(d, h);
212
+ const f = await s(d), m = t(f), w = await i(f, d, l), C = w ? m.getId(w) : void 0;
213
+ w && C && await m.remove(d, C);
214
214
  } catch (f) {
215
215
  console.error(
216
216
  `Failed to delete entity "${l}" from tenant "${d}":`,
@@ -239,13 +239,13 @@ function H(e, t, n = () => !0) {
239
239
  }
240
240
  };
241
241
  }
242
- function B(e, t, n = () => !0) {
243
- const { controlPlaneTenantId: r, getControlPlaneAdapters: s, getAdapters: a } = e;
242
+ function U(e, t, n = () => !0) {
243
+ const { controlPlaneTenantId: r, getControlPlaneAdapters: a, getAdapters: s } = e;
244
244
  return {
245
245
  async afterCreate(o, i) {
246
246
  if (i.id !== r)
247
247
  try {
248
- const u = await s(), c = await a(i.id), l = t(u), g = t(c), d = await z(
248
+ const u = await a(), c = await s(i.id), l = t(u), g = t(c), d = await M(
249
249
  (f) => l.listPaginated(r, f),
250
250
  l.listKey,
251
251
  { cursorField: "id", pageSize: 100 }
@@ -275,7 +275,7 @@ function B(e, t, n = () => !0) {
275
275
  }
276
276
  };
277
277
  }
278
- const G = (e) => ({
278
+ const L = (e) => ({
279
279
  list: async (t, n) => (await e.resourceServers.list(t, n)).resource_servers,
280
280
  listPaginated: (t, n) => e.resourceServers.list(t, n),
281
281
  get: (t, n) => e.resourceServers.get(t, n),
@@ -293,7 +293,7 @@ const G = (e) => ({
293
293
  token_lifetime: t.token_lifetime,
294
294
  token_lifetime_for_web: t.token_lifetime_for_web
295
295
  })
296
- }), U = (e) => ({
296
+ }), H = (e) => ({
297
297
  list: async (t, n) => (await e.roles.list(t, n)).roles,
298
298
  listPaginated: (t, n) => e.roles.list(t, n),
299
299
  get: (t, n) => e.roles.get(t, n),
@@ -308,96 +308,92 @@ const G = (e) => ({
308
308
  description: t.description
309
309
  })
310
310
  });
311
- function L(e) {
311
+ function W(e) {
312
312
  var t;
313
313
  return ((t = e.metadata) == null ? void 0 : t.sync) !== !1;
314
314
  }
315
315
  function we(e) {
316
- const { sync: t = {}, filters: n = {} } = e, r = t.resourceServers ?? !0, s = t.roles ?? !0, a = (m) => L(m) ? n.resourceServers ? n.resourceServers(m) : !0 : !1, o = (m) => L(m) ? n.roles ? n.roles(m) : !0 : !1, i = r ? H(
317
- e,
318
- G,
319
- a
320
- ) : void 0, u = s ? H(
316
+ const { sync: t = {}, filters: n = {} } = e, r = t.resourceServers ?? !0, a = t.roles ?? !0, s = (m) => W(m) ? n.resourceServers ? n.resourceServers(m) : !0 : !1, o = (m) => W(m) ? n.roles ? n.roles(m) : !0 : !1, i = r ? G(
321
317
  e,
322
- U,
323
- o
324
- ) : void 0, c = r ? B(
318
+ L,
319
+ s
320
+ ) : void 0, u = a ? G(e, H, o) : void 0, c = r ? U(
325
321
  e,
326
- G,
327
- a
328
- ) : void 0, l = s ? B(
322
+ L,
323
+ s
324
+ ) : void 0, l = a ? U(
329
325
  e,
330
- U,
326
+ H,
331
327
  o
332
- ) : void 0, g = s ? {
328
+ ) : void 0, g = a ? {
333
329
  async afterCreate(m, w) {
334
- var h;
330
+ var C;
335
331
  if (w.id !== e.controlPlaneTenantId) {
336
- await ((h = l == null ? void 0 : l.afterCreate) == null ? void 0 : h.call(l, m, w));
332
+ await ((C = l == null ? void 0 : l.afterCreate) == null ? void 0 : C.call(l, m, w));
337
333
  try {
338
- const p = await e.getControlPlaneAdapters(), y = await e.getAdapters(w.id), _ = await z(
339
- (C) => p.roles.list(
334
+ const h = await e.getControlPlaneAdapters(), _ = await e.getAdapters(w.id), P = await M(
335
+ (p) => h.roles.list(
340
336
  e.controlPlaneTenantId,
341
- C
337
+ p
342
338
  ),
343
339
  "roles",
344
340
  { cursorField: "id", pageSize: 100 }
345
- ), T = /* @__PURE__ */ new Map();
346
- for (const C of _.filter(
347
- (v) => {
348
- var P;
349
- return ((P = n.roles) == null ? void 0 : P.call(n, v)) ?? !0;
341
+ ), b = /* @__PURE__ */ new Map();
342
+ for (const p of P.filter(
343
+ (T) => {
344
+ var y;
345
+ return ((y = n.roles) == null ? void 0 : y.call(n, T)) ?? !0;
350
346
  }
351
347
  )) {
352
- const v = await d(
353
- y,
348
+ const T = await d(
349
+ _,
354
350
  w.id,
355
- C.name
351
+ p.name
356
352
  );
357
- v && T.set(C.name, v.id);
353
+ T && b.set(p.name, T.id);
358
354
  }
359
- for (const C of _.filter(
360
- (v) => {
361
- var P;
362
- return ((P = n.roles) == null ? void 0 : P.call(n, v)) ?? !0;
355
+ for (const p of P.filter(
356
+ (T) => {
357
+ var y;
358
+ return ((y = n.roles) == null ? void 0 : y.call(n, T)) ?? !0;
363
359
  }
364
360
  )) {
365
- const v = T.get(C.name);
366
- if (v)
361
+ const T = b.get(p.name);
362
+ if (T)
367
363
  try {
368
- const P = await p.rolePermissions.list(
364
+ const y = await h.rolePermissions.list(
369
365
  e.controlPlaneTenantId,
370
- C.id,
366
+ p.id,
371
367
  {}
372
368
  );
373
- P.length > 0 && await y.rolePermissions.assign(
369
+ y.length > 0 && await _.rolePermissions.assign(
374
370
  w.id,
375
- v,
376
- P.map((A) => ({
377
- role_id: v,
378
- resource_server_identifier: A.resource_server_identifier,
379
- permission_name: A.permission_name
371
+ T,
372
+ y.map((R) => ({
373
+ role_id: T,
374
+ resource_server_identifier: R.resource_server_identifier,
375
+ permission_name: R.permission_name
380
376
  }))
381
377
  );
382
- } catch (P) {
378
+ } catch (y) {
383
379
  console.error(
384
- `Failed to sync permissions for role "${C.name}" to tenant "${w.id}":`,
385
- P
380
+ `Failed to sync permissions for role "${p.name}" to tenant "${w.id}":`,
381
+ y
386
382
  );
387
383
  }
388
384
  }
389
- } catch (p) {
385
+ } catch (h) {
390
386
  console.error(
391
387
  `Failed to sync role permissions to tenant "${w.id}":`,
392
- p
388
+ h
393
389
  );
394
390
  }
395
391
  }
396
392
  }
397
393
  } : void 0;
398
- async function d(m, w, h) {
394
+ async function d(m, w, C) {
399
395
  return (await m.roles.list(w, {
400
- q: `name:${h}`,
396
+ q: `name:${C}`,
401
397
  per_page: 1
402
398
  })).roles[0] ?? null;
403
399
  }
@@ -408,28 +404,28 @@ function we(e) {
408
404
  },
409
405
  tenantHooks: {
410
406
  async afterCreate(m, w) {
411
- const h = [
407
+ const C = [
412
408
  c == null ? void 0 : c.afterCreate,
413
409
  (g == null ? void 0 : g.afterCreate) ?? (l == null ? void 0 : l.afterCreate)
414
- ], p = [];
415
- for (const y of h)
416
- if (y)
410
+ ], h = [];
411
+ for (const _ of C)
412
+ if (_)
417
413
  try {
418
- await y(m, w);
419
- } catch (_) {
420
- p.push(_ instanceof Error ? _ : new Error(String(_)));
414
+ await _(m, w);
415
+ } catch (P) {
416
+ h.push(P instanceof Error ? P : new Error(String(P)));
421
417
  }
422
- if (p.length === 1) throw p[0];
423
- if (p.length > 1)
418
+ if (h.length === 1) throw h[0];
419
+ if (h.length > 1)
424
420
  throw new AggregateError(
425
- p,
426
- p.map((y) => y.message).join("; ")
421
+ h,
422
+ h.map((_) => _.message).join("; ")
427
423
  );
428
424
  }
429
425
  }
430
426
  };
431
427
  }
432
- var b = class extends Error {
428
+ var S = class extends Error {
433
429
  /**
434
430
  * Creates an instance of `HTTPException`.
435
431
  * @param status - HTTP status code for the exception. Defaults to 500.
@@ -437,8 +433,8 @@ var b = class extends Error {
437
433
  */
438
434
  constructor(t = 500, n) {
439
435
  super(n == null ? void 0 : n.message, { cause: n == null ? void 0 : n.cause });
440
- M(this, "res");
441
- M(this, "status");
436
+ q(this, "res");
437
+ q(this, "status");
442
438
  this.res = n == null ? void 0 : n.res, this.status = t;
443
439
  }
444
440
  /**
@@ -455,15 +451,15 @@ var b = class extends Error {
455
451
  });
456
452
  }
457
453
  };
458
- function q(e, t) {
459
- const n = new oe();
454
+ function k(e, t) {
455
+ const n = new ie();
460
456
  return n.openapi(
461
- O({
457
+ j({
462
458
  tags: ["tenants"],
463
459
  method: "get",
464
460
  path: "/",
465
461
  request: {
466
- query: te
462
+ query: ne
467
463
  },
468
464
  security: [
469
465
  {
@@ -474,11 +470,11 @@ function q(e, t) {
474
470
  200: {
475
471
  content: {
476
472
  "application/json": {
477
- schema: S.object({
478
- tenants: S.array(N),
479
- start: S.number().optional(),
480
- limit: S.number().optional(),
481
- length: S.number().optional()
473
+ schema: z.object({
474
+ tenants: z.array(B),
475
+ start: z.number().optional(),
476
+ limit: z.number().optional(),
477
+ length: z.number().optional()
482
478
  })
483
479
  }
484
480
  },
@@ -487,75 +483,75 @@ function q(e, t) {
487
483
  }
488
484
  }),
489
485
  async (r) => {
490
- var m, w, h, p, y, _;
491
- const s = r.req.valid("query"), { page: a, per_page: o, include_totals: i, q: u } = s, c = r.var.user, l = (c == null ? void 0 : c.permissions) || [];
486
+ var m, w, C, h, _, P;
487
+ const a = r.req.valid("query"), { page: s, per_page: o, include_totals: i, q: u } = a, c = r.var.user, l = (c == null ? void 0 : c.permissions) || [];
492
488
  if (l.includes("auth:read") || l.includes("admin:organizations")) {
493
- const T = await r.env.data.tenants.list({
494
- page: a,
489
+ const b = await r.env.data.tenants.list({
490
+ page: s,
495
491
  per_page: o,
496
492
  include_totals: i,
497
493
  q: u
498
494
  });
499
495
  return i ? r.json({
500
- tenants: T.tenants,
501
- start: ((m = T.totals) == null ? void 0 : m.start) ?? 0,
502
- limit: ((w = T.totals) == null ? void 0 : w.limit) ?? o,
503
- length: T.tenants.length
504
- }) : r.json({ tenants: T.tenants });
496
+ tenants: b.tenants,
497
+ start: ((m = b.totals) == null ? void 0 : m.start) ?? 0,
498
+ limit: ((w = b.totals) == null ? void 0 : w.limit) ?? o,
499
+ length: b.tenants.length
500
+ }) : r.json({ tenants: b.tenants });
505
501
  }
506
- const d = ((h = e.accessControl) == null ? void 0 : h.controlPlaneTenantId) ?? ((p = r.env.data.multiTenancyConfig) == null ? void 0 : p.controlPlaneTenantId);
502
+ const d = ((C = e.accessControl) == null ? void 0 : C.controlPlaneTenantId) ?? ((h = r.env.data.multiTenancyConfig) == null ? void 0 : h.controlPlaneTenantId);
507
503
  if (d && (c != null && c.sub)) {
508
- const C = (await z(
509
- ($) => r.env.data.userOrganizations.listUserOrganizations(
504
+ const p = (await M(
505
+ (I) => r.env.data.userOrganizations.listUserOrganizations(
510
506
  d,
511
507
  c.sub,
512
- $
508
+ I
513
509
  ),
514
510
  "organizations"
515
- )).map(($) => $.name);
516
- if (C.length === 0)
511
+ )).map((I) => I.name);
512
+ if (p.length === 0)
517
513
  return i ? r.json({
518
514
  tenants: [],
519
515
  start: 0,
520
516
  limit: o ?? 50,
521
517
  length: 0
522
518
  }) : r.json({ tenants: [] });
523
- const v = C.length, P = a ?? 0, A = o ?? 50, R = P * A, I = C.slice(R, R + A);
524
- if (I.length === 0)
519
+ const T = p.length, y = s ?? 0, R = o ?? 50, F = y * R, D = p.slice(F, F + R);
520
+ if (D.length === 0)
525
521
  return i ? r.json({
526
522
  tenants: [],
527
- start: R,
528
- limit: A,
529
- length: v
523
+ start: F,
524
+ limit: R,
525
+ length: T
530
526
  }) : r.json({ tenants: [] });
531
- const k = I.map(($) => `id:${$}`).join(" OR "), X = u ? `(${k}) AND (${u})` : k, E = await r.env.data.tenants.list({
532
- q: X,
533
- per_page: A,
527
+ const A = D.map((I) => `id:${I}`).join(" OR "), v = u ? `(${A}) AND (${u})` : A, $ = await r.env.data.tenants.list({
528
+ q: v,
529
+ per_page: R,
534
530
  include_totals: !1
535
531
  // We calculate totals from accessibleTenantIds
536
532
  });
537
533
  return i ? r.json({
538
- tenants: E.tenants,
539
- start: R,
540
- limit: A,
541
- length: v
542
- }) : r.json({ tenants: E.tenants });
534
+ tenants: $.tenants,
535
+ start: F,
536
+ limit: R,
537
+ length: T
538
+ }) : r.json({ tenants: $.tenants });
543
539
  }
544
540
  const f = await r.env.data.tenants.list({
545
- page: a,
541
+ page: s,
546
542
  per_page: o,
547
543
  include_totals: i,
548
544
  q: u
549
545
  });
550
546
  return i ? r.json({
551
547
  tenants: f.tenants,
552
- start: ((y = f.totals) == null ? void 0 : y.start) ?? 0,
553
- limit: ((_ = f.totals) == null ? void 0 : _.limit) ?? o,
548
+ start: ((_ = f.totals) == null ? void 0 : _.start) ?? 0,
549
+ limit: ((P = f.totals) == null ? void 0 : P.limit) ?? o,
554
550
  length: f.tenants.length
555
551
  }) : r.json({ tenants: f.tenants });
556
552
  }
557
553
  ), n.openapi(
558
- O({
554
+ j({
559
555
  tags: ["tenants"],
560
556
  method: "post",
561
557
  path: "/",
@@ -563,7 +559,7 @@ function q(e, t) {
563
559
  body: {
564
560
  content: {
565
561
  "application/json": {
566
- schema: ne
562
+ schema: re
567
563
  }
568
564
  }
569
565
  }
@@ -577,7 +573,7 @@ function q(e, t) {
577
573
  201: {
578
574
  content: {
579
575
  "application/json": {
580
- schema: N
576
+ schema: B
581
577
  }
582
578
  },
583
579
  description: "Tenant created"
@@ -592,28 +588,28 @@ function q(e, t) {
592
588
  }),
593
589
  async (r) => {
594
590
  var u, c;
595
- const s = r.var.user;
596
- if (!(s != null && s.sub))
597
- throw new b(401, {
591
+ const a = r.var.user;
592
+ if (!(a != null && a.sub))
593
+ throw new S(401, {
598
594
  message: "Authentication required to create tenants"
599
595
  });
600
- let a = r.req.valid("json");
596
+ let s = r.req.valid("json");
601
597
  const o = {
602
598
  adapters: r.env.data,
603
599
  ctx: r
604
600
  };
605
- (u = t.tenants) != null && u.beforeCreate && (a = await t.tenants.beforeCreate(o, a));
606
- const i = await r.env.data.tenants.create(a);
601
+ (u = t.tenants) != null && u.beforeCreate && (s = await t.tenants.beforeCreate(o, s));
602
+ const i = await r.env.data.tenants.create(s);
607
603
  return (c = t.tenants) != null && c.afterCreate && await t.tenants.afterCreate(o, i), r.json(i, 201);
608
604
  }
609
605
  ), n.openapi(
610
- O({
606
+ j({
611
607
  tags: ["tenants"],
612
608
  method: "delete",
613
609
  path: "/{id}",
614
610
  request: {
615
- params: S.object({
616
- id: S.string()
611
+ params: z.object({
612
+ id: z.string()
617
613
  })
618
614
  },
619
615
  security: [
@@ -635,38 +631,38 @@ function q(e, t) {
635
631
  }),
636
632
  async (r) => {
637
633
  var u, c, l, g;
638
- const { id: s } = r.req.valid("param"), a = ((u = e.accessControl) == null ? void 0 : u.controlPlaneTenantId) ?? ((c = r.env.data.multiTenancyConfig) == null ? void 0 : c.controlPlaneTenantId);
639
- if (a) {
634
+ const { id: a } = r.req.valid("param"), s = ((u = e.accessControl) == null ? void 0 : u.controlPlaneTenantId) ?? ((c = r.env.data.multiTenancyConfig) == null ? void 0 : c.controlPlaneTenantId);
635
+ if (s) {
640
636
  const d = r.var.user;
641
637
  if (!(d != null && d.sub))
642
- throw new b(401, {
638
+ throw new S(401, {
643
639
  message: "Authentication required"
644
640
  });
645
- if (s === a)
646
- throw new b(403, {
641
+ if (a === s)
642
+ throw new S(403, {
647
643
  message: "Cannot delete the control plane"
648
644
  });
649
- if (!(await z(
645
+ if (!(await M(
650
646
  (w) => r.env.data.userOrganizations.listUserOrganizations(
651
- a,
647
+ s,
652
648
  d.sub,
653
649
  w
654
650
  ),
655
651
  "organizations"
656
- )).some((w) => w.name === s))
657
- throw new b(403, {
652
+ )).some((w) => w.name === a))
653
+ throw new S(403, {
658
654
  message: "Access denied to this tenant"
659
655
  });
660
656
  }
661
- if (!await r.env.data.tenants.get(s))
662
- throw new b(404, {
657
+ if (!await r.env.data.tenants.get(a))
658
+ throw new S(404, {
663
659
  message: "Tenant not found"
664
660
  });
665
661
  const i = {
666
662
  adapters: r.env.data,
667
663
  ctx: r
668
664
  };
669
- return (l = t.tenants) != null && l.beforeDelete && await t.tenants.beforeDelete(i, s), await r.env.data.tenants.remove(s), (g = t.tenants) != null && g.afterDelete && await t.tenants.afterDelete(i, s), r.body(null, 204);
665
+ return (l = t.tenants) != null && l.beforeDelete && await t.tenants.beforeDelete(i, a), await r.env.data.tenants.remove(a), (g = t.tenants) != null && g.afterDelete && await t.tenants.afterDelete(i, a), r.body(null, 204);
670
666
  }
671
667
  ), n;
672
668
  }
@@ -680,9 +676,9 @@ function pe(e) {
680
676
  { pattern: /\/api\/v2\/connections\/([^/]+)$/, type: "connection" }
681
677
  ];
682
678
  for (const { pattern: n, type: r } of t) {
683
- const s = e.match(n);
684
- if (s && s[1])
685
- return { type: r, id: s[1] };
679
+ const a = e.match(n);
680
+ if (a && a[1])
681
+ return { type: r, id: a[1] };
686
682
  }
687
683
  return null;
688
684
  }
@@ -726,19 +722,19 @@ function ve() {
726
722
  if (!r)
727
723
  return t();
728
724
  if (await ye(e.env.data, r, n))
729
- throw new b(403, {
725
+ throw new S(403, {
730
726
  message: `This ${he(n.type)} is a system resource and cannot be modified. Make changes in the control plane instead.`
731
727
  });
732
728
  return t();
733
729
  };
734
730
  }
735
- function D(e, t) {
731
+ function E(e, t) {
736
732
  const n = t.find(
737
- (s) => s.strategy === e.strategy
733
+ (a) => a.strategy === e.strategy
738
734
  );
739
735
  if (!(n != null && n.options))
740
736
  return e;
741
- const r = re.passthrough().parse({
737
+ const r = ae.passthrough().parse({
742
738
  ...n,
743
739
  ...e
744
740
  });
@@ -747,11 +743,8 @@ function D(e, t) {
747
743
  ...e.options
748
744
  }), r;
749
745
  }
750
- function F(e, t) {
751
- const n = [
752
- ...t || [],
753
- ...e || []
754
- ];
746
+ function O(e, t) {
747
+ const n = [...t || [], ...e || []];
755
748
  return [...new Set(n)];
756
749
  }
757
750
  function _e(e, t) {
@@ -766,7 +759,7 @@ function _e(e, t) {
766
759
  n.set(r.value, r);
767
760
  return Array.from(n.values());
768
761
  }
769
- function W(e, t) {
762
+ function K(e, t) {
770
763
  return t ? {
771
764
  ...e,
772
765
  scopes: _e(
@@ -775,25 +768,25 @@ function W(e, t) {
775
768
  )
776
769
  } : e;
777
770
  }
778
- function K(e, t) {
771
+ function Q(e, t) {
779
772
  return t ? {
780
773
  ...e,
781
- callbacks: F(e.callbacks, t.callbacks),
782
- web_origins: F(
774
+ callbacks: O(e.callbacks, t.callbacks),
775
+ web_origins: O(
783
776
  e.web_origins,
784
777
  t.web_origins
785
778
  ),
786
- allowed_logout_urls: F(
779
+ allowed_logout_urls: O(
787
780
  e.allowed_logout_urls,
788
781
  t.allowed_logout_urls
789
782
  ),
790
- allowed_origins: F(
783
+ allowed_origins: O(
791
784
  e.allowed_origins,
792
785
  t.allowed_origins
793
786
  )
794
787
  } : e;
795
788
  }
796
- function Te(e, t) {
789
+ function Ce(e, t) {
797
790
  const { controlPlaneTenantId: n, controlPlaneClientId: r } = t;
798
791
  return {
799
792
  ...e,
@@ -804,25 +797,25 @@ function Te(e, t) {
804
797
  },
805
798
  connections: {
806
799
  ...e.connections,
807
- get: async (s, a) => {
800
+ get: async (a, s) => {
808
801
  const o = await e.connections.get(
809
- s,
810
- a
802
+ a,
803
+ s
811
804
  );
812
- if (!o || !n || s === n)
805
+ if (!o || !n || a === n)
813
806
  return o;
814
807
  const i = await e.connections.list(n);
815
- return D(
808
+ return E(
816
809
  o,
817
810
  i.connections || []
818
811
  );
819
812
  },
820
- list: async (s, a) => {
821
- const o = await e.connections.list(s, a);
822
- if (!n || s === n)
813
+ list: async (a, s) => {
814
+ const o = await e.connections.list(a, s);
815
+ if (!n || a === n)
823
816
  return o;
824
817
  const i = await e.connections.list(n), u = o.connections.map(
825
- (c) => D(
818
+ (c) => E(
826
819
  c,
827
820
  i.connections || []
828
821
  )
@@ -835,16 +828,16 @@ function Te(e, t) {
835
828
  },
836
829
  clientConnections: {
837
830
  ...e.clientConnections,
838
- listByClient: async (s, a) => {
831
+ listByClient: async (a, s) => {
839
832
  let o = await e.clientConnections.listByClient(
840
- s,
841
- a
833
+ a,
834
+ s
842
835
  );
843
- if (o.length === 0 && (o = (await e.connections.list(s)).connections || []), !n || s === n)
836
+ if (o.length === 0 && (o = (await e.connections.list(a)).connections || []), !n || a === n)
844
837
  return o;
845
838
  const i = await e.connections.list(n);
846
839
  return o.map(
847
- (u) => D(
840
+ (u) => E(
848
841
  u,
849
842
  i.connections || []
850
843
  )
@@ -853,69 +846,70 @@ function Te(e, t) {
853
846
  },
854
847
  clients: {
855
848
  ...e.clients,
856
- get: async (s, a) => {
857
- const o = await e.clients.get(s, a);
849
+ get: async (a, s) => {
850
+ const o = await e.clients.get(a, s);
858
851
  if (!o)
859
852
  return null;
860
- if (!n || !r || s === n && a === r)
853
+ if (!n || !r || a === n && s === r)
861
854
  return o;
862
855
  const i = await e.clients.get(
863
856
  n,
864
857
  r
865
858
  );
866
- return K(o, i);
859
+ return Q(o, i);
867
860
  },
868
- getByClientId: async (s) => {
869
- const a = await e.clients.getByClientId(s);
870
- if (!a)
861
+ getByClientId: async (a) => {
862
+ const s = await e.clients.getByClientId(a);
863
+ if (!s)
871
864
  return null;
872
- if (!n || !r || a.tenant_id === n && a.client_id === r)
873
- return a;
865
+ if (!n || !r || s.tenant_id === n && s.client_id === r)
866
+ return s;
874
867
  const o = await e.clients.get(
875
868
  n,
876
869
  r
877
870
  );
878
871
  return {
879
- ...K(a, o),
880
- tenant_id: a.tenant_id
872
+ ...Q(s, o),
873
+ tenant_id: s.tenant_id
881
874
  };
882
875
  }
883
876
  },
884
877
  emailProviders: {
885
878
  ...e.emailProviders,
886
- get: async (s) => {
887
- const a = await e.emailProviders.get(s);
888
- return a || (!n || s === n ? null : e.emailProviders.get(n));
879
+ get: async (a) => {
880
+ const s = await e.emailProviders.get(a);
881
+ return s || (!n || a === n ? null : e.emailProviders.get(n));
889
882
  }
890
883
  },
891
884
  resourceServers: {
892
885
  ...e.resourceServers,
893
- get: async (s, a) => {
886
+ get: async (a, s) => {
894
887
  const o = await e.resourceServers.get(
895
- s,
896
- a
888
+ a,
889
+ s
897
890
  );
898
- if (!o || !n || s === n)
891
+ if (!o || !n || a === n)
899
892
  return o;
900
893
  const u = (await e.resourceServers.list(
901
894
  n,
902
895
  { q: `identifier:${o.identifier}`, per_page: 1 }
903
896
  )).resource_servers[0] ?? null;
904
- return W(
897
+ return K(
905
898
  o,
906
899
  u
907
900
  );
908
901
  },
909
- list: async (s, a) => {
910
- const o = await e.resourceServers.list(s, a);
911
- if (!n || s === n)
902
+ list: async (a, s) => {
903
+ const o = await e.resourceServers.list(
904
+ a,
905
+ s
906
+ );
907
+ if (!n || a === n)
912
908
  return o;
913
- const i = await e.resourceServers.list(
914
- n
915
- ), u = new Map(
909
+ const i = await e.resourceServers.list(n), u = new Map(
916
910
  i.resource_servers.map((l) => [l.identifier, l])
917
911
  ), c = o.resource_servers.map(
918
- (l) => W(
912
+ (l) => K(
919
913
  l,
920
914
  u.get(l.identifier) ?? null
921
915
  )
@@ -931,10 +925,10 @@ function Te(e, t) {
931
925
  // - branding: Fall back to control plane branding/themes
932
926
  };
933
927
  }
934
- function V(e, t) {
935
- return Te(e, t);
928
+ function X(e, t) {
929
+ return Ce(e, t);
936
930
  }
937
- function Ce(e) {
931
+ function Te(e) {
938
932
  return async (t, n) => {
939
933
  const r = t.var.user;
940
934
  return (r == null ? void 0 : r.tenant_id) === e && r.org_name && t.set("tenant_id", r.org_name), n();
@@ -944,44 +938,44 @@ function Pe(e) {
944
938
  return async (t, n) => {
945
939
  if (!e.accessControl)
946
940
  return n();
947
- const { controlPlaneTenantId: r } = e.accessControl, s = t.var.org_name, a = t.var.organization_id, o = s || a;
941
+ const { controlPlaneTenantId: r } = e.accessControl, a = t.var.org_name, s = t.var.organization_id, o = a || s;
948
942
  let i = t.var.tenant_id;
949
- const u = t.var.user, l = (u != null && u.aud ? Array.isArray(u.aud) ? u.aud : [u.aud] : []).includes(Q);
943
+ const u = t.var.user, l = (u != null && u.aud ? Array.isArray(u.aud) ? u.aud : [u.aud] : []).includes(V);
950
944
  if (!i && o && l && (t.set("tenant_id", o), i = o), !i)
951
- throw new b(400, {
945
+ throw new S(400, {
952
946
  message: "Tenant ID not found in request"
953
947
  });
954
- if (!ce(
955
- a,
948
+ if (!le(
949
+ s,
956
950
  i,
957
951
  r,
958
- s
952
+ a
959
953
  ))
960
- throw new b(403, {
954
+ throw new S(403, {
961
955
  message: `Access denied to tenant ${i}`
962
956
  });
963
957
  return n();
964
958
  };
965
959
  }
966
- function Ae(e) {
960
+ function be(e) {
967
961
  return async (t, n) => {
968
962
  if (!e.subdomainRouting)
969
963
  return n();
970
964
  const {
971
965
  baseDomain: r,
972
- reservedSubdomains: s = [],
973
- resolveSubdomain: a
966
+ reservedSubdomains: a = [],
967
+ resolveSubdomain: s
974
968
  } = e.subdomainRouting, o = t.req.header("host") || "";
975
969
  let i = null;
976
970
  if (o.endsWith(r)) {
977
971
  const c = o.slice(0, -(r.length + 1));
978
972
  c && !c.includes(".") && (i = c);
979
973
  }
980
- if (i && s.includes(i) && (i = null), !i)
974
+ if (i && a.includes(i) && (i = null), !i)
981
975
  return e.accessControl && t.set("tenant_id", e.accessControl.controlPlaneTenantId), n();
982
976
  let u = null;
983
- if (a)
984
- u = await a(i);
977
+ if (s)
978
+ u = await s(i);
985
979
  else if (e.subdomainRouting.useOrganizations !== !1 && e.accessControl)
986
980
  try {
987
981
  const c = await t.env.data.organizations.get(
@@ -992,41 +986,41 @@ function Ae(e) {
992
986
  } catch {
993
987
  }
994
988
  if (!u)
995
- throw new b(404, {
989
+ throw new S(404, {
996
990
  message: `Tenant not found for subdomain: ${i}`
997
991
  });
998
992
  return t.set("tenant_id", u), n();
999
993
  };
1000
994
  }
1001
- function be(e) {
995
+ function Ae(e) {
1002
996
  return async (t, n) => {
1003
997
  if (!e.databaseIsolation)
1004
998
  return n();
1005
999
  const r = t.var.tenant_id;
1006
1000
  if (!r)
1007
- throw new b(400, {
1001
+ throw new S(400, {
1008
1002
  message: "Tenant ID not found in request"
1009
1003
  });
1010
1004
  try {
1011
- const s = await e.databaseIsolation.getAdapters(r);
1012
- t.env.data = s;
1013
- } catch (s) {
1005
+ const a = await e.databaseIsolation.getAdapters(r);
1006
+ t.env.data = a;
1007
+ } catch (a) {
1014
1008
  throw console.error(
1015
1009
  `Failed to resolve database for tenant ${r}:`,
1016
- s
1017
- ), new b(500, {
1010
+ a
1011
+ ), new S(500, {
1018
1012
  message: "Failed to resolve tenant database"
1019
1013
  });
1020
1014
  }
1021
1015
  return n();
1022
1016
  };
1023
1017
  }
1024
- function J(e) {
1025
- const t = Ae(e), n = Pe(e), r = be(e);
1026
- return async (s, a) => (await t(s, async () => {
1027
- }), await n(s, async () => {
1028
- }), await r(s, async () => {
1029
- }), a());
1018
+ function Y(e) {
1019
+ const t = be(e), n = Pe(e), r = Ae(e);
1020
+ return async (a, s) => (await t(a, async () => {
1021
+ }), await n(a, async () => {
1022
+ }), await r(a, async () => {
1023
+ }), s());
1030
1024
  }
1031
1025
  function Fe(e) {
1032
1026
  const {
@@ -1034,9 +1028,9 @@ function Fe(e) {
1034
1028
  controlPlane: n,
1035
1029
  controlPlane: {
1036
1030
  tenantId: r = "control_plane",
1037
- clientId: s
1031
+ clientId: a
1038
1032
  } = {},
1039
- sync: a = { resourceServers: !0, roles: !0 },
1033
+ sync: s = { resourceServers: !0, roles: !0 },
1040
1034
  defaultPermissions: o = ["tenant:admin"],
1041
1035
  requireOrganizationMatch: i = !1,
1042
1036
  managementApiExtensions: u = [],
@@ -1046,39 +1040,45 @@ function Fe(e) {
1046
1040
  ...d
1047
1041
  } = e;
1048
1042
  let f = t, m = t;
1049
- n && (f = V(t, {
1043
+ n && (f = X(t, {
1050
1044
  controlPlaneTenantId: r,
1051
- controlPlaneClientId: s
1045
+ controlPlaneClientId: a
1052
1046
  }), m = {
1053
1047
  ...t,
1054
1048
  multiTenancyConfig: {
1055
1049
  controlPlaneTenantId: r,
1056
- controlPlaneClientId: s
1050
+ controlPlaneClientId: a
1057
1051
  }
1058
1052
  });
1059
- const w = a !== !1, h = w ? {
1060
- resourceServers: a.resourceServers ?? !0,
1061
- roles: a.roles ?? !0
1062
- } : { resourceServers: !1, roles: !1 }, _ = {
1053
+ const w = s !== !1, C = w ? {
1054
+ resourceServers: s.resourceServers ?? !0,
1055
+ roles: s.roles ?? !0
1056
+ } : { resourceServers: !1, roles: !1 }, P = {
1063
1057
  controlPlaneTenantId: r,
1064
- getChildTenantIds: l ?? (async () => (await z(
1065
- (I) => f.tenants.list(I),
1058
+ getChildTenantIds: l ?? (async () => (await M(
1059
+ (v) => f.tenants.list(v),
1066
1060
  "tenants",
1067
1061
  { cursorField: "id", pageSize: 100 }
1068
- )).filter((I) => I.id !== r).map((I) => I.id)),
1062
+ )).filter((v) => v.id !== r).map((v) => v.id)),
1069
1063
  getAdapters: g ?? (async () => f),
1070
1064
  getControlPlaneAdapters: async () => f,
1071
- sync: h
1072
- }, { entityHooks: T, tenantHooks: C } = we(_), v = {
1065
+ sync: C
1066
+ }, { entityHooks: b, tenantHooks: p } = we(P), T = {
1073
1067
  resourceServers: [
1074
- T.resourceServers,
1068
+ b.resourceServers,
1075
1069
  ...(c == null ? void 0 : c.resourceServers) ?? []
1076
1070
  ],
1077
- roles: [T.roles, ...(c == null ? void 0 : c.roles) ?? []],
1071
+ roles: [b.roles, ...(c == null ? void 0 : c.roles) ?? []],
1078
1072
  connections: (c == null ? void 0 : c.connections) ?? [],
1079
1073
  tenants: (c == null ? void 0 : c.tenants) ?? [],
1080
1074
  rolePermissions: (c == null ? void 0 : c.rolePermissions) ?? []
1081
- }, P = q(
1075
+ }, y = J({
1076
+ accessControl: {
1077
+ controlPlaneTenantId: r,
1078
+ requireOrganizationMatch: i,
1079
+ defaultPermissions: o
1080
+ }
1081
+ }), F = k(
1082
1082
  {
1083
1083
  accessControl: {
1084
1084
  controlPlaneTenantId: r,
@@ -1086,32 +1086,47 @@ function Fe(e) {
1086
1086
  defaultPermissions: o
1087
1087
  }
1088
1088
  },
1089
- { tenants: C }
1090
- ), { app: A } = ae({
1089
+ { tenants: {
1090
+ async beforeCreate(A, v) {
1091
+ return y.beforeCreate && (v = await y.beforeCreate(A, v)), p.beforeCreate && (v = await p.beforeCreate(A, v)), v;
1092
+ },
1093
+ async afterCreate(A, v) {
1094
+ var $, I;
1095
+ await (($ = y.afterCreate) == null ? void 0 : $.call(y, A, v)), await ((I = p.afterCreate) == null ? void 0 : I.call(p, A, v));
1096
+ },
1097
+ async beforeDelete(A, v) {
1098
+ var $, I;
1099
+ await (($ = y.beforeDelete) == null ? void 0 : $.call(y, A, v)), await ((I = p.beforeDelete) == null ? void 0 : I.call(p, A, v));
1100
+ }
1101
+ } }
1102
+ ), { app: D } = oe({
1091
1103
  dataAdapter: f,
1092
1104
  managementDataAdapter: m,
1093
1105
  ...d,
1094
- entityHooks: v,
1106
+ entityHooks: T,
1095
1107
  managementApiExtensions: [
1096
1108
  ...u,
1097
- { path: "/tenants", router: P }
1109
+ { path: "/tenants", router: F }
1098
1110
  ]
1099
1111
  });
1100
- return A.use("/api/v2/*", Ce(r)), w && A.use("/api/v2/*", ve()), { app: A, controlPlaneTenantId: r };
1112
+ return D.use(
1113
+ "/api/v2/*",
1114
+ Te(r)
1115
+ ), w && D.use("/api/v2/*", ve()), { app: D, controlPlaneTenantId: r };
1101
1116
  }
1102
- function Me(e) {
1103
- const t = j(e);
1117
+ function De(e) {
1118
+ const t = N(e);
1104
1119
  return {
1105
1120
  name: "multi-tenancy",
1106
1121
  // Apply multi-tenancy middleware for subdomain routing, database resolution, etc.
1107
- middleware: J(e),
1122
+ middleware: Y(e),
1108
1123
  // Provide lifecycle hooks
1109
1124
  hooks: t,
1110
1125
  // Mount tenant management routes
1111
1126
  routes: [
1112
1127
  {
1113
1128
  path: "/management",
1114
- handler: q(e, t)
1129
+ handler: k(e, t)
1115
1130
  }
1116
1131
  ],
1117
1132
  // Called when plugin is registered
@@ -1124,8 +1139,8 @@ function Me(e) {
1124
1139
  }
1125
1140
  };
1126
1141
  }
1127
- function j(e) {
1128
- const t = e.accessControl ? ie(e.accessControl) : {}, n = e.databaseIsolation ? le(e.databaseIsolation) : {}, r = de(e);
1142
+ function N(e) {
1143
+ const t = e.accessControl ? ce(e.accessControl) : {}, n = e.databaseIsolation ? ue(e.databaseIsolation) : {}, r = J(e);
1129
1144
  return {
1130
1145
  ...t,
1131
1146
  ...n,
@@ -1133,13 +1148,13 @@ function j(e) {
1133
1148
  };
1134
1149
  }
1135
1150
  function Ie(e) {
1136
- const t = new x(), n = j(e);
1137
- return t.route("/tenants", q(e, n)), t;
1151
+ const t = new ee(), n = N(e);
1152
+ return t.route("/tenants", k(e, n)), t;
1138
1153
  }
1139
- function Oe(e) {
1154
+ function Me(e) {
1140
1155
  return {
1141
- hooks: j(e),
1142
- middleware: J(e),
1156
+ hooks: N(e),
1157
+ middleware: Y(e),
1143
1158
  app: Ie(e),
1144
1159
  config: e,
1145
1160
  /**
@@ -1152,7 +1167,7 @@ function Oe(e) {
1152
1167
  */
1153
1168
  wrapAdapters: (t, n) => {
1154
1169
  var r;
1155
- return V(t, {
1170
+ return X(t, {
1156
1171
  controlPlaneTenantId: (r = e.accessControl) == null ? void 0 : r.controlPlaneTenantId,
1157
1172
  controlPlaneClientId: n == null ? void 0 : n.controlPlaneClientId
1158
1173
  });
@@ -1160,23 +1175,23 @@ function Oe(e) {
1160
1175
  };
1161
1176
  }
1162
1177
  export {
1163
- ie as createAccessControlHooks,
1178
+ ce as createAccessControlHooks,
1164
1179
  Pe as createAccessControlMiddleware,
1165
- Ce as createControlPlaneTenantMiddleware,
1166
- le as createDatabaseHooks,
1167
- be as createDatabaseMiddleware,
1180
+ Te as createControlPlaneTenantMiddleware,
1181
+ ue as createDatabaseHooks,
1182
+ Ae as createDatabaseMiddleware,
1168
1183
  Ie as createMultiTenancy,
1169
- j as createMultiTenancyHooks,
1170
- J as createMultiTenancyMiddleware,
1171
- Me as createMultiTenancyPlugin,
1184
+ N as createMultiTenancyHooks,
1185
+ Y as createMultiTenancyMiddleware,
1186
+ De as createMultiTenancyPlugin,
1172
1187
  ve as createProtectSyncedMiddleware,
1173
- de as createProvisioningHooks,
1174
- Te as createRuntimeFallbackAdapter,
1175
- Ae as createSubdomainMiddleware,
1188
+ J as createProvisioningHooks,
1189
+ Ce as createRuntimeFallbackAdapter,
1190
+ be as createSubdomainMiddleware,
1176
1191
  we as createSyncHooks,
1177
- q as createTenantsOpenAPIRouter,
1192
+ k as createTenantsOpenAPIRouter,
1178
1193
  Fe as initMultiTenant,
1179
- Oe as setupMultiTenancy,
1180
- ce as validateTenantAccess,
1181
- V as withRuntimeFallback
1194
+ Me as setupMultiTenancy,
1195
+ le as validateTenantAccess,
1196
+ X as withRuntimeFallback
1182
1197
  };