@authhero/multi-tenancy 14.20.2 → 14.20.3

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,18 +1,18 @@
1
1
  var ne = Object.defineProperty;
2
2
  var re = (e, t, n) => t in e ? ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var E = (e, t, n) => re(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { Hono as ae } from "hono";
5
- import { MANAGEMENT_API_SCOPES as se, MANAGEMENT_API_AUDIENCE as Y, fetchAll as D, auth0QuerySchema as oe, tenantSchema as O, tenantInsertSchema as G, deepMergePatch as ie, connectionSchema as ce, connectionOptionsSchema as le, init as ue } from "authhero";
6
- import { OpenAPIHono as de, createRoute as k, z as A } from "@hono/zod-openapi";
4
+ import { Hono as se } from "hono";
5
+ import { MANAGEMENT_API_SCOPES as ae, MANAGEMENT_API_AUDIENCE as Y, fetchAll as D, auth0QuerySchema as oe, tenantSchema as O, tenantInsertSchema as G, deepMergePatch as ie, connectionSchema as ce, connectionOptionsSchema as le, init as ue } from "authhero";
6
+ import { OpenAPIHono as de, createRoute as M, z as S } from "@hono/zod-openapi";
7
7
  function fe(e) {
8
8
  const { controlPlaneTenantId: t, requireOrganizationMatch: n = !0 } = e;
9
9
  return {
10
- async onTenantAccessValidation(r, a) {
11
- if (a === t)
10
+ async onTenantAccessValidation(r, s) {
11
+ if (s === t)
12
12
  return !0;
13
13
  if (n) {
14
- const s = r.var.org_name, i = r.var.organization_id, c = s || i;
15
- return c ? c.toLowerCase() === a.toLowerCase() : !1;
14
+ const o = r.var.org_name, i = r.var.organization_id, c = o || i;
15
+ return c ? c.toLowerCase() === s.toLowerCase() : !1;
16
16
  }
17
17
  return !0;
18
18
  }
@@ -21,8 +21,8 @@ function fe(e) {
21
21
  function me(e, t, n, r) {
22
22
  if (t === n)
23
23
  return !0;
24
- const a = r || e;
25
- return a ? a.toLowerCase() === t.toLowerCase() : !1;
24
+ const s = r || e;
25
+ return s ? s.toLowerCase() === t.toLowerCase() : !1;
26
26
  }
27
27
  function ge(e) {
28
28
  return {
@@ -51,11 +51,11 @@ function Z(e) {
51
51
  } : n;
52
52
  },
53
53
  async afterCreate(t, n) {
54
- const { accessControl: r, databaseIsolation: a } = e;
55
- r && t.ctx && await he(t, n, r), a != null && a.onProvision && await a.onProvision(n.id);
54
+ const { accessControl: r, databaseIsolation: s } = e;
55
+ r && t.ctx && await he(t, n, r), s != null && s.onProvision && await s.onProvision(n.id);
56
56
  },
57
57
  async beforeDelete(t, n) {
58
- const { accessControl: r, databaseIsolation: a } = e;
58
+ const { accessControl: r, databaseIsolation: s } = e;
59
59
  if (r)
60
60
  try {
61
61
  const i = (await t.adapters.organizations.list(
@@ -65,19 +65,19 @@ function Z(e) {
65
65
  r.controlPlaneTenantId,
66
66
  i.id
67
67
  );
68
- } catch (s) {
68
+ } catch (o) {
69
69
  console.warn(
70
70
  `Failed to remove organization for tenant ${n}:`,
71
- s
71
+ o
72
72
  );
73
73
  }
74
- if (a != null && a.onDeprovision)
74
+ if (s != null && s.onDeprovision)
75
75
  try {
76
- await a.onDeprovision(n);
77
- } catch (s) {
76
+ await s.onDeprovision(n);
77
+ } catch (o) {
78
78
  console.warn(
79
79
  `Failed to deprovision database for tenant ${n}:`,
80
- s
80
+ o
81
81
  );
82
82
  }
83
83
  }
@@ -86,13 +86,13 @@ function Z(e) {
86
86
  async function he(e, t, n) {
87
87
  const {
88
88
  controlPlaneTenantId: r,
89
- defaultPermissions: a,
90
- defaultRoles: s,
89
+ defaultPermissions: s,
90
+ defaultRoles: o,
91
91
  issuer: i,
92
92
  adminRoleName: c = "Tenant Admin",
93
- adminRoleDescription: u = "Full access to all tenant management operations",
94
- addCreatorToOrganization: o = !0
95
- } = n, l = await e.adapters.organizations.create(
93
+ adminRoleDescription: l = "Full access to all tenant management operations",
94
+ addCreatorToOrganization: a = !0
95
+ } = n, u = await e.adapters.organizations.create(
96
96
  r,
97
97
  {
98
98
  name: t.id,
@@ -104,8 +104,8 @@ async function he(e, t, n) {
104
104
  e,
105
105
  r,
106
106
  c,
107
- u
108
- )), o && e.ctx) {
107
+ l
108
+ )), a && e.ctx) {
109
109
  const d = e.ctx.var.user;
110
110
  if (d != null && d.sub && !await pe(
111
111
  e,
@@ -115,25 +115,25 @@ async function he(e, t, n) {
115
115
  try {
116
116
  await e.adapters.userOrganizations.create(r, {
117
117
  user_id: d.sub,
118
- organization_id: l.id
118
+ organization_id: u.id
119
119
  }), g && await e.adapters.userRoles.create(
120
120
  r,
121
121
  d.sub,
122
122
  g,
123
- l.id
123
+ u.id
124
124
  // organizationId
125
125
  );
126
126
  } catch (f) {
127
127
  console.warn(
128
- `Failed to add creator ${d.sub} to organization ${l.id}:`,
128
+ `Failed to add creator ${d.sub} to organization ${u.id}:`,
129
129
  f
130
130
  );
131
131
  }
132
132
  }
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}`
133
+ o && o.length > 0 && console.log(
134
+ `Would assign roles ${o.join(", ")} to organization ${u.id}`
135
+ ), s && s.length > 0 && console.log(
136
+ `Would grant permissions ${s.join(", ")} to organization ${u.id}`
137
137
  );
138
138
  }
139
139
  async function pe(e, t, n) {
@@ -144,10 +144,10 @@ async function pe(e, t, n) {
144
144
  ""
145
145
  // Empty string for global roles
146
146
  );
147
- for (const a of r)
147
+ for (const s of r)
148
148
  if ((await e.adapters.rolePermissions.list(
149
149
  t,
150
- a.id,
150
+ s.id,
151
151
  { per_page: 1e3 }
152
152
  )).some(
153
153
  (c) => c.permission_name === "admin:organizations"
@@ -156,64 +156,64 @@ async function pe(e, t, n) {
156
156
  return !1;
157
157
  }
158
158
  async function ye(e, t, n, r) {
159
- const s = (await e.adapters.roles.list(t, {})).roles.find((o) => o.name === n);
160
- if (s)
161
- return s.id;
159
+ const o = (await e.adapters.roles.list(t, {})).roles.find((a) => a.name === n);
160
+ if (o)
161
+ return o.id;
162
162
  const i = await e.adapters.roles.create(t, {
163
163
  name: n,
164
164
  description: r
165
- }), c = Y, u = se.map((o) => ({
165
+ }), c = Y, l = ae.map((a) => ({
166
166
  role_id: i.id,
167
167
  resource_server_identifier: c,
168
- permission_name: o.value
168
+ permission_name: a.value
169
169
  }));
170
170
  return await e.adapters.rolePermissions.assign(
171
171
  t,
172
172
  i.id,
173
- u
173
+ l
174
174
  ), i.id;
175
175
  }
176
176
  function H(e, t, n = () => !0) {
177
- const { controlPlaneTenantId: r, getChildTenantIds: a, getAdapters: s } = e, i = /* @__PURE__ */ new Map();
178
- async function c(l, g, d) {
179
- return (await t(l).list(g, {
177
+ const { controlPlaneTenantId: r, getChildTenantIds: s, getAdapters: o } = e, i = /* @__PURE__ */ new Map();
178
+ async function c(u, g, d) {
179
+ return (await t(u).list(g, {
180
180
  q: `name:${d}`,
181
181
  per_page: 1
182
182
  }))[0] ?? null;
183
183
  }
184
- async function u(l) {
185
- const g = await a(), d = t(await s(r));
184
+ async function l(u) {
185
+ const g = await s(), d = t(await o(r));
186
186
  await Promise.all(
187
187
  g.map(async (m) => {
188
188
  try {
189
- const f = await s(m), w = t(f), y = {
190
- ...d.transform(l),
189
+ const f = await o(m), w = t(f), y = {
190
+ ...d.transform(u),
191
191
  is_system: !0
192
- }, _ = await c(f, m, l.name), b = _ ? w.getId(_) : void 0;
193
- if (_ && b) {
192
+ }, _ = await c(f, m, u.name), P = _ ? w.getId(_) : void 0;
193
+ if (_ && P) {
194
194
  const I = w.preserveOnUpdate ? w.preserveOnUpdate(_, y) : y;
195
- await w.update(m, b, I);
195
+ await w.update(m, P, I);
196
196
  } else
197
197
  await w.create(m, y);
198
198
  } catch (f) {
199
199
  console.error(
200
- `Failed to sync ${d.listKey} "${l.name}" to tenant "${m}":`,
200
+ `Failed to sync ${d.listKey} "${u.name}" to tenant "${m}":`,
201
201
  f
202
202
  );
203
203
  }
204
204
  })
205
205
  );
206
206
  }
207
- async function o(l) {
208
- const g = await a();
207
+ async function a(u) {
208
+ const g = await s();
209
209
  await Promise.all(
210
210
  g.map(async (d) => {
211
211
  try {
212
- const m = await s(d), f = t(m), w = await c(m, d, l), T = w ? f.getId(w) : void 0;
212
+ const m = await o(d), f = t(m), w = await c(m, d, u), T = w ? f.getId(w) : void 0;
213
213
  w && T && await f.remove(d, T);
214
214
  } catch (m) {
215
215
  console.error(
216
- `Failed to delete entity "${l}" from tenant "${d}":`,
216
+ `Failed to delete entity "${u}" from tenant "${d}":`,
217
217
  m
218
218
  );
219
219
  }
@@ -221,39 +221,39 @@ function H(e, t, n = () => !0) {
221
221
  );
222
222
  }
223
223
  return {
224
- afterCreate: async (l, g) => {
225
- l.tenantId === r && n(g) && await u(g);
224
+ afterCreate: async (u, g) => {
225
+ u.tenantId === r && n(g) && await l(g);
226
226
  },
227
- afterUpdate: async (l, g, d) => {
228
- l.tenantId === r && n(d) && await u(d);
227
+ afterUpdate: async (u, g, d) => {
228
+ u.tenantId === r && n(d) && await l(d);
229
229
  },
230
- beforeDelete: async (l, g) => {
231
- if (l.tenantId !== r) return;
232
- const m = await t(l.adapters).get(l.tenantId, g);
230
+ beforeDelete: async (u, g) => {
231
+ if (u.tenantId !== r) return;
232
+ const m = await t(u.adapters).get(u.tenantId, g);
233
233
  m && n(m) && i.set(g, m);
234
234
  },
235
- afterDelete: async (l, g) => {
236
- if (l.tenantId !== r) return;
235
+ afterDelete: async (u, g) => {
236
+ if (u.tenantId !== r) return;
237
237
  const d = i.get(g);
238
- d && (i.delete(g), await o(d.name));
238
+ d && (i.delete(g), await a(d.name));
239
239
  }
240
240
  };
241
241
  }
242
242
  function W(e, t, n = () => !0) {
243
- const { controlPlaneTenantId: r, getControlPlaneAdapters: a, getAdapters: s } = e;
243
+ const { controlPlaneTenantId: r, getControlPlaneAdapters: s, getAdapters: o } = e;
244
244
  return {
245
245
  async afterCreate(i, c) {
246
246
  if (c.id !== r)
247
247
  try {
248
- const u = await a(), o = await s(c.id), l = t(u), g = t(o), d = await D(
249
- (m) => l.listPaginated(r, m),
250
- l.listKey,
248
+ const l = await s(), a = await o(c.id), u = t(l), g = t(a), d = await D(
249
+ (m) => u.listPaginated(r, m),
250
+ u.listKey,
251
251
  { cursorField: "id", pageSize: 100 }
252
252
  );
253
253
  await Promise.all(
254
254
  d.filter((m) => n(m)).map(async (m) => {
255
255
  try {
256
- const f = l.transform(m);
256
+ const f = u.transform(m);
257
257
  await g.create(c.id, {
258
258
  ...f,
259
259
  is_system: !0
@@ -266,10 +266,10 @@ function W(e, t, n = () => !0) {
266
266
  }
267
267
  })
268
268
  );
269
- } catch (u) {
269
+ } catch (l) {
270
270
  console.error(
271
271
  `Failed to sync entities to new tenant "${c.id}":`,
272
- u
272
+ l
273
273
  );
274
274
  }
275
275
  }
@@ -313,25 +313,25 @@ function Q(e) {
313
313
  return ((t = e.metadata) == null ? void 0 : t.sync) !== !1;
314
314
  }
315
315
  function ve(e) {
316
- const { sync: t = {}, filters: n = {} } = e, r = t.resourceServers ?? !0, a = t.roles ?? !0, s = (f) => Q(f) ? n.resourceServers ? n.resourceServers(f) : !0 : !1, i = (f) => Q(f) ? n.roles ? n.roles(f) : !0 : !1, c = r ? H(
316
+ const { sync: t = {}, filters: n = {} } = e, r = t.resourceServers ?? !0, s = t.roles ?? !0, o = (f) => Q(f) ? n.resourceServers ? n.resourceServers(f) : !0 : !1, i = (f) => Q(f) ? n.roles ? n.roles(f) : !0 : !1, c = r ? H(
317
317
  e,
318
318
  L,
319
- s
320
- ) : void 0, u = a ? H(e, K, i) : void 0, o = r ? W(
319
+ o
320
+ ) : void 0, l = s ? H(e, K, i) : void 0, a = r ? W(
321
321
  e,
322
322
  L,
323
- s
324
- ) : void 0, l = a ? W(
323
+ o
324
+ ) : void 0, u = s ? W(
325
325
  e,
326
326
  K,
327
327
  i
328
- ) : void 0, g = a ? {
328
+ ) : void 0, g = s ? {
329
329
  async afterCreate(f, w) {
330
330
  var T;
331
331
  if (w.id !== e.controlPlaneTenantId) {
332
- await ((T = l == null ? void 0 : l.afterCreate) == null ? void 0 : T.call(l, f, w));
332
+ await ((T = u == null ? void 0 : u.afterCreate) == null ? void 0 : T.call(u, f, w));
333
333
  try {
334
- const y = await e.getControlPlaneAdapters(), _ = await e.getAdapters(w.id), b = await D(
334
+ const y = await e.getControlPlaneAdapters(), _ = await e.getAdapters(w.id), P = await D(
335
335
  (h) => y.roles.list(
336
336
  e.controlPlaneTenantId,
337
337
  h
@@ -339,7 +339,7 @@ function ve(e) {
339
339
  "roles",
340
340
  { cursorField: "id", pageSize: 100 }
341
341
  ), I = /* @__PURE__ */ new Map();
342
- for (const h of b.filter(
342
+ for (const h of P.filter(
343
343
  (C) => {
344
344
  var p;
345
345
  return ((p = n.roles) == null ? void 0 : p.call(n, C)) ?? !0;
@@ -352,7 +352,7 @@ function ve(e) {
352
352
  );
353
353
  C && I.set(h.name, C.id);
354
354
  }
355
- for (const h of b.filter(
355
+ for (const h of P.filter(
356
356
  (C) => {
357
357
  var p;
358
358
  return ((p = n.roles) == null ? void 0 : p.call(n, C)) ?? !0;
@@ -400,20 +400,20 @@ function ve(e) {
400
400
  return {
401
401
  entityHooks: {
402
402
  resourceServers: c,
403
- roles: u
403
+ roles: l
404
404
  },
405
405
  tenantHooks: {
406
406
  async afterCreate(f, w) {
407
407
  const T = [
408
- o == null ? void 0 : o.afterCreate,
409
- (g == null ? void 0 : g.afterCreate) ?? (l == null ? void 0 : l.afterCreate)
408
+ a == null ? void 0 : a.afterCreate,
409
+ (g == null ? void 0 : g.afterCreate) ?? (u == null ? void 0 : u.afterCreate)
410
410
  ], y = [];
411
411
  for (const _ of T)
412
412
  if (_)
413
413
  try {
414
414
  await _(f, w);
415
- } catch (b) {
416
- y.push(b instanceof Error ? b : new Error(String(b)));
415
+ } catch (P) {
416
+ y.push(P instanceof Error ? P : new Error(String(P)));
417
417
  }
418
418
  if (y.length === 1) throw y[0];
419
419
  if (y.length > 1)
@@ -425,7 +425,7 @@ function ve(e) {
425
425
  }
426
426
  };
427
427
  }
428
- var P = class extends Error {
428
+ var b = class extends Error {
429
429
  /**
430
430
  * Creates an instance of `HTTPException`.
431
431
  * @param status - HTTP status code for the exception. Defaults to 500.
@@ -454,7 +454,7 @@ var P = class extends Error {
454
454
  function N(e, t) {
455
455
  const n = new de();
456
456
  return n.openapi(
457
- k({
457
+ M({
458
458
  tags: ["tenants"],
459
459
  method: "get",
460
460
  path: "/",
@@ -463,18 +463,18 @@ function N(e, t) {
463
463
  },
464
464
  security: [
465
465
  {
466
- Bearer: ["read:tenants", "auth:read"]
466
+ Bearer: []
467
467
  }
468
468
  ],
469
469
  responses: {
470
470
  200: {
471
471
  content: {
472
472
  "application/json": {
473
- schema: A.object({
474
- tenants: A.array(O),
475
- start: A.number().optional(),
476
- limit: A.number().optional(),
477
- length: A.number().optional()
473
+ schema: S.object({
474
+ tenants: S.array(O),
475
+ start: S.number().optional(),
476
+ limit: S.number().optional(),
477
+ length: S.number().optional()
478
478
  })
479
479
  }
480
480
  },
@@ -483,14 +483,14 @@ function N(e, t) {
483
483
  }
484
484
  }),
485
485
  async (r) => {
486
- var w, T, y, _, b, I;
487
- const a = r.req.valid("query"), { page: s, per_page: i, include_totals: c, q: u } = a, o = r.var.user, l = (o == null ? void 0 : o.permissions) || [];
488
- if (!!!((o == null ? void 0 : o.org_id) ?? r.var.organization_id) && (l.includes("auth:read") || l.includes("admin:organizations"))) {
486
+ var w, T, y, _, P, I;
487
+ const s = r.req.valid("query"), { page: o, per_page: i, include_totals: c, q: l } = s, a = r.var.user, u = (a == null ? void 0 : a.permissions) || [];
488
+ if (!!!((a == null ? void 0 : a.org_id) ?? r.var.organization_id) && u.includes("admin:organizations")) {
489
489
  const h = await r.env.data.tenants.list({
490
- page: s,
490
+ page: o,
491
491
  per_page: i,
492
492
  include_totals: c,
493
- q: u
493
+ q: l
494
494
  });
495
495
  return c ? r.json({
496
496
  tenants: h.tenants,
@@ -500,15 +500,19 @@ function N(e, t) {
500
500
  }) : r.json({ tenants: h.tenants });
501
501
  }
502
502
  const m = ((y = e.accessControl) == null ? void 0 : y.controlPlaneTenantId) ?? ((_ = r.env.data.multiTenancyConfig) == null ? void 0 : _.controlPlaneTenantId);
503
- if (m && (o != null && o.sub)) {
503
+ if (m && !(a != null && a.sub))
504
+ throw new b(403, {
505
+ message: "Access denied: token has no subject"
506
+ });
507
+ if (m && (a != null && a.sub)) {
504
508
  const C = (await D(
505
- (M) => r.env.data.userOrganizations.listUserOrganizations(
509
+ (k) => r.env.data.userOrganizations.listUserOrganizations(
506
510
  m,
507
- o.sub,
508
- M
511
+ a.sub,
512
+ k
509
513
  ),
510
514
  "organizations"
511
- )).map((M) => M.name);
515
+ )).map((k) => k.name);
512
516
  if (C.length === 0)
513
517
  return c ? r.json({
514
518
  tenants: [],
@@ -516,15 +520,15 @@ function N(e, t) {
516
520
  limit: i ?? 50,
517
521
  length: 0
518
522
  }) : r.json({ tenants: [] });
519
- const p = C.length, F = s ?? 0, $ = i ?? 50, R = F * $, S = C.slice(R, R + $);
520
- if (S.length === 0)
523
+ const p = C.length, F = o ?? 0, $ = i ?? 50, R = F * $, A = C.slice(R, R + $);
524
+ if (A.length === 0)
521
525
  return c ? r.json({
522
526
  tenants: [],
523
527
  start: R,
524
528
  limit: $,
525
529
  length: p
526
530
  }) : r.json({ tenants: [] });
527
- const v = S.map((M) => `id:${M}`).join(" OR "), j = u ? `(${v}) AND (${u})` : v, z = await r.env.data.tenants.list({
531
+ const v = A.map((k) => `id:${k}`).join(" OR "), j = l ? `(${v}) AND (${l})` : v, z = await r.env.data.tenants.list({
528
532
  q: j,
529
533
  per_page: $,
530
534
  include_totals: !1
@@ -538,20 +542,20 @@ function N(e, t) {
538
542
  }) : r.json({ tenants: z.tenants });
539
543
  }
540
544
  const f = await r.env.data.tenants.list({
541
- page: s,
545
+ page: o,
542
546
  per_page: i,
543
547
  include_totals: c,
544
- q: u
548
+ q: l
545
549
  });
546
550
  return c ? r.json({
547
551
  tenants: f.tenants,
548
- start: ((b = f.totals) == null ? void 0 : b.start) ?? 0,
552
+ start: ((P = f.totals) == null ? void 0 : P.start) ?? 0,
549
553
  limit: ((I = f.totals) == null ? void 0 : I.limit) ?? i,
550
554
  length: f.tenants.length
551
555
  }) : r.json({ tenants: f.tenants });
552
556
  }
553
557
  ), n.openapi(
554
- k({
558
+ M({
555
559
  tags: ["tenants"],
556
560
  method: "post",
557
561
  path: "/",
@@ -587,29 +591,29 @@ function N(e, t) {
587
591
  }
588
592
  }),
589
593
  async (r) => {
590
- var u, o;
591
- const a = r.var.user;
592
- if (!(a != null && a.sub))
593
- throw new P(401, {
594
+ var l, a;
595
+ const s = r.var.user;
596
+ if (!(s != null && s.sub))
597
+ throw new b(401, {
594
598
  message: "Authentication required to create tenants"
595
599
  });
596
- let s = r.req.valid("json");
600
+ let o = r.req.valid("json");
597
601
  const i = {
598
602
  adapters: r.env.data,
599
603
  ctx: r
600
604
  };
601
- (u = t.tenants) != null && u.beforeCreate && (s = await t.tenants.beforeCreate(i, s));
602
- const c = await r.env.data.tenants.create(s);
603
- return (o = t.tenants) != null && o.afterCreate && await t.tenants.afterCreate(i, c), r.json(c, 201);
605
+ (l = t.tenants) != null && l.beforeCreate && (o = await t.tenants.beforeCreate(i, o));
606
+ const c = await r.env.data.tenants.create(o);
607
+ return (a = t.tenants) != null && a.afterCreate && await t.tenants.afterCreate(i, c), r.json(c, 201);
604
608
  }
605
609
  ), n.openapi(
606
- k({
610
+ M({
607
611
  tags: ["tenants"],
608
612
  method: "delete",
609
613
  path: "/{id}",
610
614
  request: {
611
- params: A.object({
612
- id: A.string()
615
+ params: S.object({
616
+ id: S.string()
613
617
  })
614
618
  },
615
619
  security: [
@@ -630,48 +634,48 @@ function N(e, t) {
630
634
  }
631
635
  }),
632
636
  async (r) => {
633
- var u, o, l, g;
634
- const { id: a } = r.req.valid("param"), s = ((u = e.accessControl) == null ? void 0 : u.controlPlaneTenantId) ?? ((o = r.env.data.multiTenancyConfig) == null ? void 0 : o.controlPlaneTenantId);
635
- if (s) {
637
+ var l, a, u, g;
638
+ const { id: s } = r.req.valid("param"), o = ((l = e.accessControl) == null ? void 0 : l.controlPlaneTenantId) ?? ((a = r.env.data.multiTenancyConfig) == null ? void 0 : a.controlPlaneTenantId);
639
+ if (o) {
636
640
  const d = r.var.user;
637
641
  if (!(d != null && d.sub))
638
- throw new P(401, {
642
+ throw new b(401, {
639
643
  message: "Authentication required"
640
644
  });
641
- if (a === s)
642
- throw new P(403, {
645
+ if (s === o)
646
+ throw new b(403, {
643
647
  message: "Cannot delete the control plane"
644
648
  });
645
649
  if (!(await D(
646
650
  (w) => r.env.data.userOrganizations.listUserOrganizations(
647
- s,
651
+ o,
648
652
  d.sub,
649
653
  w
650
654
  ),
651
655
  "organizations"
652
- )).some((w) => w.name === a))
653
- throw new P(403, {
656
+ )).some((w) => w.name === s))
657
+ throw new b(403, {
654
658
  message: "Access denied to this tenant"
655
659
  });
656
660
  }
657
- if (!await r.env.data.tenants.get(a))
658
- throw new P(404, {
661
+ if (!await r.env.data.tenants.get(s))
662
+ throw new b(404, {
659
663
  message: "Tenant not found"
660
664
  });
661
665
  const c = {
662
666
  adapters: r.env.data,
663
667
  ctx: r
664
668
  };
665
- return (l = t.tenants) != null && l.beforeDelete && await t.tenants.beforeDelete(c, a), await r.env.data.tenants.remove(a), (g = t.tenants) != null && g.afterDelete && await t.tenants.afterDelete(c, a), r.body(null, 204);
669
+ return (u = t.tenants) != null && u.beforeDelete && await t.tenants.beforeDelete(c, s), await r.env.data.tenants.remove(s), (g = t.tenants) != null && g.afterDelete && await t.tenants.afterDelete(c, s), r.body(null, 204);
666
670
  }
667
671
  ), n.openapi(
668
- k({
672
+ M({
669
673
  tags: ["tenants", "settings"],
670
674
  method: "get",
671
675
  path: "/settings",
672
676
  request: {
673
- headers: A.object({
674
- "tenant-id": A.string().optional()
677
+ headers: S.object({
678
+ "tenant-id": S.string().optional()
675
679
  })
676
680
  },
677
681
  security: [
@@ -691,26 +695,26 @@ function N(e, t) {
691
695
  }
692
696
  }),
693
697
  async (r) => {
694
- const a = await r.env.data.tenants.get(r.var.tenant_id);
695
- if (!a)
696
- throw new P(404, {
698
+ const s = await r.env.data.tenants.get(r.var.tenant_id);
699
+ if (!s)
700
+ throw new b(404, {
697
701
  message: "Tenant not found"
698
702
  });
699
- return r.json(a);
703
+ return r.json(s);
700
704
  }
701
705
  ), n.openapi(
702
- k({
706
+ M({
703
707
  tags: ["tenants", "settings"],
704
708
  method: "patch",
705
709
  path: "/settings",
706
710
  request: {
707
- headers: A.object({
708
- "tenant-id": A.string().optional()
711
+ headers: S.object({
712
+ "tenant-id": S.string().optional()
709
713
  }),
710
714
  body: {
711
715
  content: {
712
716
  "application/json": {
713
- schema: A.object(G.shape).partial()
717
+ schema: S.object(G.shape).partial()
714
718
  }
715
719
  }
716
720
  }
@@ -732,19 +736,19 @@ function N(e, t) {
732
736
  }
733
737
  }),
734
738
  async (r) => {
735
- const a = r.req.valid("json"), { id: s, ...i } = a, c = await r.env.data.tenants.get(r.var.tenant_id);
739
+ const s = r.req.valid("json"), { id: o, ...i } = s, c = await r.env.data.tenants.get(r.var.tenant_id);
736
740
  if (!c)
737
- throw new P(404, {
741
+ throw new b(404, {
738
742
  message: "Tenant not found"
739
743
  });
740
- const u = ie(c, i);
741
- await r.env.data.tenants.update(r.var.tenant_id, u);
742
- const o = await r.env.data.tenants.get(r.var.tenant_id);
743
- if (!o)
744
- throw new P(500, {
744
+ const l = ie(c, i);
745
+ await r.env.data.tenants.update(r.var.tenant_id, l);
746
+ const a = await r.env.data.tenants.get(r.var.tenant_id);
747
+ if (!a)
748
+ throw new b(500, {
745
749
  message: "Failed to retrieve updated tenant"
746
750
  });
747
- return r.json(o);
751
+ return r.json(a);
748
752
  }
749
753
  ), n;
750
754
  }
@@ -758,9 +762,9 @@ function _e(e) {
758
762
  { pattern: /\/api\/v2\/connections\/([^/]+)$/, type: "connection" }
759
763
  ];
760
764
  for (const { pattern: n, type: r } of t) {
761
- const a = e.match(n);
762
- if (a && a[1])
763
- return { type: r, id: a[1] };
765
+ const s = e.match(n);
766
+ if (s && s[1])
767
+ return { type: r, id: s[1] };
764
768
  }
765
769
  return null;
766
770
  }
@@ -804,7 +808,7 @@ function be() {
804
808
  if (!r)
805
809
  return t();
806
810
  if (await Ce(e.env.data, r, n))
807
- throw new P(403, {
811
+ throw new b(403, {
808
812
  message: `This ${Te(n.type)} is a system resource and cannot be modified. Make changes in the control plane instead.`
809
813
  });
810
814
  return t();
@@ -812,7 +816,7 @@ function be() {
812
816
  }
813
817
  function B(e, t) {
814
818
  const n = t.find(
815
- (a) => a.strategy === e.strategy
819
+ (s) => s.strategy === e.strategy
816
820
  );
817
821
  if (!(n != null && n.options))
818
822
  return e;
@@ -872,51 +876,51 @@ function x(e, t) {
872
876
  return {
873
877
  ...e.resourceServers,
874
878
  get: async (n, r) => {
875
- const a = await e.resourceServers.get(
879
+ const s = await e.resourceServers.get(
876
880
  n,
877
881
  r
878
882
  );
879
- if (!a || !t || n === t || !a.is_system)
880
- return a;
881
- const s = await e.resourceServers.get(
883
+ if (!s || !t || n === t || !s.is_system)
884
+ return s;
885
+ const o = await e.resourceServers.get(
882
886
  t,
883
887
  r
884
888
  );
885
889
  return V(
886
- a,
887
- s
890
+ s,
891
+ o
888
892
  );
889
893
  },
890
894
  list: async (n, r) => {
891
- const a = await e.resourceServers.list(n, r);
895
+ const s = await e.resourceServers.list(n, r);
892
896
  if (!t || n === t)
893
- return a;
894
- const s = t, i = a.resource_servers.filter(
895
- (o) => !!(o.is_system && o.id)
896
- ).map((o) => o.id);
897
+ return s;
898
+ const o = t, i = s.resource_servers.filter(
899
+ (a) => !!(a.is_system && a.id)
900
+ ).map((a) => a.id);
897
901
  if (i.length === 0)
898
- return a;
902
+ return s;
899
903
  const c = /* @__PURE__ */ new Map();
900
904
  await Promise.all(
901
- i.map(async (o) => {
902
- const l = await e.resourceServers.get(s, o);
903
- l && c.set(o, l);
905
+ i.map(async (a) => {
906
+ const u = await e.resourceServers.get(o, a);
907
+ u && c.set(a, u);
904
908
  })
905
909
  );
906
- const u = a.resource_servers.map(
907
- (o) => o.is_system && o.id ? V(
908
- o,
909
- c.get(o.id) ?? null
910
- ) : o
910
+ const l = s.resource_servers.map(
911
+ (a) => a.is_system && a.id ? V(
912
+ a,
913
+ c.get(a.id) ?? null
914
+ ) : a
911
915
  );
912
916
  return {
913
- ...a,
914
- resource_servers: u
917
+ ...s,
918
+ resource_servers: l
915
919
  };
916
920
  }
917
921
  };
918
922
  }
919
- function Se(e, t) {
923
+ function Ae(e, t) {
920
924
  return {
921
925
  ...e,
922
926
  resourceServers: x(
@@ -925,7 +929,7 @@ function Se(e, t) {
925
929
  )
926
930
  };
927
931
  }
928
- function Ae(e, t) {
932
+ function Se(e, t) {
929
933
  const { controlPlaneTenantId: n, controlPlaneClientId: r } = t;
930
934
  return {
931
935
  ...e,
@@ -936,12 +940,12 @@ function Ae(e, t) {
936
940
  },
937
941
  connections: {
938
942
  ...e.connections,
939
- get: async (a, s) => {
943
+ get: async (s, o) => {
940
944
  const i = await e.connections.get(
941
- a,
942
- s
945
+ s,
946
+ o
943
947
  );
944
- if (!i || !n || a === n)
948
+ if (!i || !n || s === n)
945
949
  return i;
946
950
  const c = await e.connections.list(n);
947
951
  return B(
@@ -949,35 +953,35 @@ function Ae(e, t) {
949
953
  c.connections || []
950
954
  );
951
955
  },
952
- list: async (a, s) => {
953
- const i = await e.connections.list(a, s);
954
- if (!n || a === n)
956
+ list: async (s, o) => {
957
+ const i = await e.connections.list(s, o);
958
+ if (!n || s === n)
955
959
  return i;
956
- const c = await e.connections.list(n), u = i.connections.map(
957
- (o) => B(
958
- o,
960
+ const c = await e.connections.list(n), l = i.connections.map(
961
+ (a) => B(
962
+ a,
959
963
  c.connections || []
960
964
  )
961
965
  );
962
966
  return {
963
967
  ...i,
964
- connections: u
968
+ connections: l
965
969
  };
966
970
  }
967
971
  },
968
972
  clientConnections: {
969
973
  ...e.clientConnections,
970
- listByClient: async (a, s) => {
974
+ listByClient: async (s, o) => {
971
975
  let i = await e.clientConnections.listByClient(
972
- a,
973
- s
976
+ s,
977
+ o
974
978
  );
975
- if (i.length === 0 && (i = (await e.connections.list(a)).connections || []), !n || a === n)
979
+ if (i.length === 0 && (i = (await e.connections.list(s)).connections || []), !n || s === n)
976
980
  return i;
977
981
  const c = await e.connections.list(n);
978
982
  return i.map(
979
- (u) => B(
980
- u,
983
+ (l) => B(
984
+ l,
981
985
  c.connections || []
982
986
  )
983
987
  );
@@ -985,11 +989,11 @@ function Ae(e, t) {
985
989
  },
986
990
  clients: {
987
991
  ...e.clients,
988
- get: async (a, s) => {
989
- const i = await e.clients.get(a, s);
992
+ get: async (s, o) => {
993
+ const i = await e.clients.get(s, o);
990
994
  if (!i)
991
995
  return null;
992
- if (!n || !r || a === n && s === r)
996
+ if (!n || !r || s === n && o === r)
993
997
  return i;
994
998
  const c = await e.clients.get(
995
999
  n,
@@ -997,27 +1001,27 @@ function Ae(e, t) {
997
1001
  );
998
1002
  return J(i, c);
999
1003
  },
1000
- getByClientId: async (a) => {
1001
- const s = await e.clients.getByClientId(a);
1002
- if (!s)
1004
+ getByClientId: async (s) => {
1005
+ const o = await e.clients.getByClientId(s);
1006
+ if (!o)
1003
1007
  return null;
1004
- if (!n || !r || s.tenant_id === n && s.client_id === r)
1005
- return s;
1008
+ if (!n || !r || o.tenant_id === n && o.client_id === r)
1009
+ return o;
1006
1010
  const i = await e.clients.get(
1007
1011
  n,
1008
1012
  r
1009
1013
  );
1010
1014
  return {
1011
- ...J(s, i),
1012
- tenant_id: s.tenant_id
1015
+ ...J(o, i),
1016
+ tenant_id: o.tenant_id
1013
1017
  };
1014
1018
  }
1015
1019
  },
1016
1020
  emailProviders: {
1017
1021
  ...e.emailProviders,
1018
- get: async (a) => {
1019
- const s = await e.emailProviders.get(a);
1020
- return s || (!n || a === n ? null : e.emailProviders.get(n));
1022
+ get: async (s) => {
1023
+ const o = await e.emailProviders.get(s);
1024
+ return o || (!n || s === n ? null : e.emailProviders.get(n));
1021
1025
  }
1022
1026
  },
1023
1027
  resourceServers: x(
@@ -1039,9 +1043,9 @@ function Ie(e, t) {
1039
1043
  return {
1040
1044
  ...e.hooks,
1041
1045
  list: async (n, r) => {
1042
- const a = await e.hooks.list(n, r);
1046
+ const s = await e.hooks.list(n, r);
1043
1047
  if (!t || n === t)
1044
- return a;
1048
+ return s;
1045
1049
  const i = ((await e.hooks.list(
1046
1050
  t,
1047
1051
  r
@@ -1049,28 +1053,28 @@ function Ie(e, t) {
1049
1053
  X
1050
1054
  );
1051
1055
  if (i.length === 0)
1052
- return a;
1053
- const c = new Set((a.hooks || []).map((o) => o.hook_id)), u = i.filter((o) => !c.has(o.hook_id));
1056
+ return s;
1057
+ const c = new Set((s.hooks || []).map((a) => a.hook_id)), l = i.filter((a) => !c.has(a.hook_id));
1054
1058
  return {
1055
- ...a,
1056
- hooks: [...a.hooks || [], ...u],
1057
- length: typeof a.length == "number" ? a.length + u.length : a.length
1059
+ ...s,
1060
+ hooks: [...s.hooks || [], ...l],
1061
+ length: typeof s.length == "number" ? s.length + l.length : s.length
1058
1062
  };
1059
1063
  },
1060
1064
  get: async (n, r) => {
1061
- const a = await e.hooks.get(n, r);
1062
- if (a || !t || n === t)
1063
- return a;
1064
- const s = await e.hooks.get(
1065
+ const s = await e.hooks.get(n, r);
1066
+ if (s || !t || n === t)
1067
+ return s;
1068
+ const o = await e.hooks.get(
1065
1069
  t,
1066
1070
  r
1067
1071
  );
1068
- return s && X(s) ? s : null;
1072
+ return o && X(o) ? o : null;
1069
1073
  }
1070
1074
  };
1071
1075
  }
1072
1076
  function ee(e, t) {
1073
- return Ae(e, t);
1077
+ return Se(e, t);
1074
1078
  }
1075
1079
  function Re(e) {
1076
1080
  return async (t, n) => {
@@ -1082,20 +1086,20 @@ function ze(e) {
1082
1086
  return async (t, n) => {
1083
1087
  if (!e.accessControl)
1084
1088
  return n();
1085
- const { controlPlaneTenantId: r } = e.accessControl, a = t.var.org_name, s = t.var.organization_id, i = a || s;
1089
+ const { controlPlaneTenantId: r } = e.accessControl, s = t.var.org_name, o = t.var.organization_id, i = s || o;
1086
1090
  let c = t.var.tenant_id;
1087
- const u = t.var.user, l = (u != null && u.aud ? Array.isArray(u.aud) ? u.aud : [u.aud] : []).includes(Y);
1088
- if (!c && i && l && (t.set("tenant_id", i), c = i), !c)
1089
- throw new P(400, {
1091
+ const l = t.var.user, u = (l != null && l.aud ? Array.isArray(l.aud) ? l.aud : [l.aud] : []).includes(Y);
1092
+ if (!c && i && u && (t.set("tenant_id", i), c = i), !c)
1093
+ throw new b(400, {
1090
1094
  message: "Tenant ID not found in request"
1091
1095
  });
1092
1096
  if (!me(
1093
- s,
1097
+ o,
1094
1098
  c,
1095
1099
  r,
1096
- a
1100
+ s
1097
1101
  ))
1098
- throw new P(403, {
1102
+ throw new b(403, {
1099
1103
  message: `Access denied to tenant ${c}`
1100
1104
  });
1101
1105
  return n();
@@ -1107,33 +1111,33 @@ function $e(e) {
1107
1111
  return n();
1108
1112
  const {
1109
1113
  baseDomain: r,
1110
- reservedSubdomains: a = [],
1111
- resolveSubdomain: s
1114
+ reservedSubdomains: s = [],
1115
+ resolveSubdomain: o
1112
1116
  } = e.subdomainRouting, i = t.req.header("x-forwarded-host") || t.req.header("host") || "";
1113
1117
  let c = null;
1114
1118
  if (i.endsWith(r)) {
1115
- const o = i.slice(0, -(r.length + 1));
1116
- o && !o.includes(".") && (c = o);
1119
+ const a = i.slice(0, -(r.length + 1));
1120
+ a && !a.includes(".") && (c = a);
1117
1121
  }
1118
- if (c && a.includes(c) && (c = null), !c)
1122
+ if (c && s.includes(c) && (c = null), !c)
1119
1123
  return e.accessControl && t.set("tenant_id", e.accessControl.controlPlaneTenantId), n();
1120
- let u = null;
1121
- if (s)
1122
- u = await s(c);
1124
+ let l = null;
1125
+ if (o)
1126
+ l = await o(c);
1123
1127
  else if (e.subdomainRouting.useOrganizations !== !1 && e.accessControl)
1124
1128
  try {
1125
- const o = await t.env.data.organizations.get(
1129
+ const a = await t.env.data.organizations.get(
1126
1130
  e.accessControl.controlPlaneTenantId,
1127
1131
  c
1128
1132
  );
1129
- o && (u = o.id);
1133
+ a && (l = a.id);
1130
1134
  } catch {
1131
1135
  }
1132
- if (!u)
1133
- throw new P(404, {
1136
+ if (!l)
1137
+ throw new b(404, {
1134
1138
  message: `Tenant not found for subdomain: ${c}`
1135
1139
  });
1136
- return t.set("tenant_id", u), n();
1140
+ return t.set("tenant_id", l), n();
1137
1141
  };
1138
1142
  }
1139
1143
  function je(e) {
@@ -1142,17 +1146,17 @@ function je(e) {
1142
1146
  return n();
1143
1147
  const r = t.var.tenant_id;
1144
1148
  if (!r)
1145
- throw new P(400, {
1149
+ throw new b(400, {
1146
1150
  message: "Tenant ID not found in request"
1147
1151
  });
1148
1152
  try {
1149
- const a = await e.databaseIsolation.getAdapters(r);
1150
- t.env.data = a;
1151
- } catch (a) {
1153
+ const s = await e.databaseIsolation.getAdapters(r);
1154
+ t.env.data = s;
1155
+ } catch (s) {
1152
1156
  throw console.error(
1153
1157
  `Failed to resolve database for tenant ${r}:`,
1154
- a
1155
- ), new P(500, {
1158
+ s
1159
+ ), new b(500, {
1156
1160
  message: "Failed to resolve tenant database"
1157
1161
  });
1158
1162
  }
@@ -1161,10 +1165,10 @@ function je(e) {
1161
1165
  }
1162
1166
  function te(e) {
1163
1167
  const t = $e(e), n = ze(e), r = je(e);
1164
- return async (a, s) => (await t(a, async () => {
1165
- }), await n(a, async () => {
1166
- }), await r(a, async () => {
1167
- }), s());
1168
+ return async (s, o) => (await t(s, async () => {
1169
+ }), await n(s, async () => {
1170
+ }), await r(s, async () => {
1171
+ }), o());
1168
1172
  }
1169
1173
  function qe(e) {
1170
1174
  const {
@@ -1172,36 +1176,36 @@ function qe(e) {
1172
1176
  controlPlane: n,
1173
1177
  controlPlane: {
1174
1178
  tenantId: r = "control_plane",
1175
- clientId: a
1179
+ clientId: s
1176
1180
  } = {},
1177
- sync: s = { resourceServers: !0, roles: !0 },
1181
+ sync: o = { resourceServers: !0, roles: !0 },
1178
1182
  defaultPermissions: i = ["tenant:admin"],
1179
1183
  requireOrganizationMatch: c = !1,
1180
- managementApiExtensions: u = [],
1181
- entityHooks: o,
1182
- getChildTenantIds: l,
1184
+ managementApiExtensions: l = [],
1185
+ entityHooks: a,
1186
+ getChildTenantIds: u,
1183
1187
  getAdapters: g,
1184
1188
  ...d
1185
1189
  } = e;
1186
1190
  let m = t, f = t;
1187
1191
  n && (m = ee(t, {
1188
1192
  controlPlaneTenantId: r,
1189
- controlPlaneClientId: a
1193
+ controlPlaneClientId: s
1190
1194
  }), f = {
1191
- ...Se(t, {
1195
+ ...Ae(t, {
1192
1196
  controlPlaneTenantId: r
1193
1197
  }),
1194
1198
  multiTenancyConfig: {
1195
1199
  controlPlaneTenantId: r,
1196
- controlPlaneClientId: a
1200
+ controlPlaneClientId: s
1197
1201
  }
1198
1202
  });
1199
- const w = s !== !1, T = w ? {
1200
- resourceServers: s.resourceServers ?? !0,
1201
- roles: s.roles ?? !0
1202
- } : { resourceServers: !1, roles: !1 }, b = {
1203
+ const w = o !== !1, T = w ? {
1204
+ resourceServers: o.resourceServers ?? !0,
1205
+ roles: o.roles ?? !0
1206
+ } : { resourceServers: !1, roles: !1 }, P = {
1203
1207
  controlPlaneTenantId: r,
1204
- getChildTenantIds: l ?? (async () => (await D(
1208
+ getChildTenantIds: u ?? (async () => (await D(
1205
1209
  (v) => m.tenants.list(v),
1206
1210
  "tenants",
1207
1211
  { cursorField: "id", pageSize: 100 }
@@ -1209,15 +1213,15 @@ function qe(e) {
1209
1213
  getAdapters: g ?? (async () => m),
1210
1214
  getControlPlaneAdapters: async () => m,
1211
1215
  sync: T
1212
- }, { entityHooks: I, tenantHooks: h } = ve(b), C = {
1216
+ }, { entityHooks: I, tenantHooks: h } = ve(P), C = {
1213
1217
  resourceServers: [
1214
1218
  I.resourceServers,
1215
- ...(o == null ? void 0 : o.resourceServers) ?? []
1219
+ ...(a == null ? void 0 : a.resourceServers) ?? []
1216
1220
  ],
1217
- roles: [I.roles, ...(o == null ? void 0 : o.roles) ?? []],
1218
- connections: (o == null ? void 0 : o.connections) ?? [],
1219
- tenants: (o == null ? void 0 : o.tenants) ?? [],
1220
- rolePermissions: (o == null ? void 0 : o.rolePermissions) ?? []
1221
+ roles: [I.roles, ...(a == null ? void 0 : a.roles) ?? []],
1222
+ connections: (a == null ? void 0 : a.connections) ?? [],
1223
+ tenants: (a == null ? void 0 : a.tenants) ?? [],
1224
+ rolePermissions: (a == null ? void 0 : a.rolePermissions) ?? []
1221
1225
  }, p = Z({
1222
1226
  accessControl: {
1223
1227
  controlPlaneTenantId: r,
@@ -1233,16 +1237,16 @@ function qe(e) {
1233
1237
  }
1234
1238
  },
1235
1239
  { tenants: {
1236
- async beforeCreate(S, v) {
1237
- return p.beforeCreate && (v = await p.beforeCreate(S, v)), h.beforeCreate && (v = await h.beforeCreate(S, v)), v;
1240
+ async beforeCreate(A, v) {
1241
+ return p.beforeCreate && (v = await p.beforeCreate(A, v)), h.beforeCreate && (v = await h.beforeCreate(A, v)), v;
1238
1242
  },
1239
- async afterCreate(S, v) {
1243
+ async afterCreate(A, v) {
1240
1244
  var j, z;
1241
- await ((j = p.afterCreate) == null ? void 0 : j.call(p, S, v)), await ((z = h.afterCreate) == null ? void 0 : z.call(h, S, v));
1245
+ await ((j = p.afterCreate) == null ? void 0 : j.call(p, A, v)), await ((z = h.afterCreate) == null ? void 0 : z.call(h, A, v));
1242
1246
  },
1243
- async beforeDelete(S, v) {
1247
+ async beforeDelete(A, v) {
1244
1248
  var j, z;
1245
- await ((j = p.beforeDelete) == null ? void 0 : j.call(p, S, v)), await ((z = h.beforeDelete) == null ? void 0 : z.call(h, S, v));
1249
+ await ((j = p.beforeDelete) == null ? void 0 : j.call(p, A, v)), await ((z = h.beforeDelete) == null ? void 0 : z.call(h, A, v));
1246
1250
  }
1247
1251
  } }
1248
1252
  ), { app: R } = ue({
@@ -1251,7 +1255,7 @@ function qe(e) {
1251
1255
  ...d,
1252
1256
  entityHooks: C,
1253
1257
  managementApiExtensions: [
1254
- ...u,
1258
+ ...l,
1255
1259
  { path: "/tenants", router: $ }
1256
1260
  ]
1257
1261
  });
@@ -1294,7 +1298,7 @@ function U(e) {
1294
1298
  };
1295
1299
  }
1296
1300
  function Fe(e) {
1297
- const t = new ae(), n = U(e);
1301
+ const t = new se(), n = U(e);
1298
1302
  return t.route("/tenants", N(e, n)), t;
1299
1303
  }
1300
1304
  function Be(e) {
@@ -1332,7 +1336,7 @@ export {
1332
1336
  Ee as createMultiTenancyPlugin,
1333
1337
  be as createProtectSyncedMiddleware,
1334
1338
  Z as createProvisioningHooks,
1335
- Ae as createRuntimeFallbackAdapter,
1339
+ Se as createRuntimeFallbackAdapter,
1336
1340
  $e as createSubdomainMiddleware,
1337
1341
  ve as createSyncHooks,
1338
1342
  N as createTenantsOpenAPIRouter,
@@ -1340,5 +1344,5 @@ export {
1340
1344
  Be as setupMultiTenancy,
1341
1345
  me as validateTenantAccess,
1342
1346
  ee as withRuntimeFallback,
1343
- Se as withSystemResourceServerInheritance
1347
+ Ae as withSystemResourceServerInheritance
1344
1348
  };