@dyrected/core 2.5.47 → 2.5.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -44,6 +44,7 @@ __export(index_exports, {
44
44
  parseSort: () => parseSort,
45
45
  parseSqlWhere: () => parseSqlWhere,
46
46
  publishingWorkflow: () => publishingWorkflow,
47
+ resolveAdminAuthCollection: () => resolveAdminAuthCollection,
47
48
  runCollectionHooks: () => runCollectionHooks,
48
49
  saveWorkflowDraft: () => saveWorkflowDraft,
49
50
  transitionWorkflow: () => transitionWorkflow,
@@ -322,22 +323,29 @@ async function transitionWorkflow(args) {
322
323
 
323
324
  // src/utils/admin-auth.ts
324
325
  function getAdminAuthCollection(config) {
325
- const requestedSlug = config.adminAuth?.collectionSlug;
326
- if (requestedSlug) {
327
- return config.collections.find((collection) => collection.slug === requestedSlug) ?? null;
326
+ const adminCollection = resolveAdminAuthCollection(config.collections, config.adminAuth?.collectionSlug);
327
+ return adminCollection ?? null;
328
+ }
329
+ function resolveAdminAuthCollection(collections, collectionSlug) {
330
+ const adminsCollection = collections.find((collection) => collection.slug === "__admins");
331
+ if (adminsCollection) return adminsCollection;
332
+ if (collectionSlug) {
333
+ const requestedCollection = collections.find((collection) => collection.slug === collectionSlug);
334
+ if (requestedCollection) return requestedCollection;
328
335
  }
329
- return config.collections.find((collection) => collection.slug === "__admins") ?? config.collections.find((collection) => collection.auth) ?? null;
336
+ return collections.find((collection) => collection.auth);
330
337
  }
331
- function getPublicAdminAuthConfig(adminAuth) {
338
+ function getPublicAdminAuthConfig(adminAuth, collections) {
332
339
  const providers = (adminAuth?.providers ?? []).map((provider) => ({
333
340
  id: provider.id,
334
341
  type: provider.type,
335
342
  displayName: provider.displayName || humanizeProviderName(provider.id, provider.type),
336
343
  autoRedirect: provider.autoRedirect
337
344
  }));
345
+ const resolvedCollectionSlug = collections ? resolveAdminAuthCollection(collections, adminAuth?.collectionSlug)?.slug : adminAuth?.collectionSlug;
338
346
  return {
339
347
  mode: adminAuth?.mode ?? "local",
340
- collectionSlug: adminAuth?.collectionSlug,
348
+ collectionSlug: resolvedCollectionSlug,
341
349
  provisioningMode: adminAuth?.provisioningMode,
342
350
  providers
343
351
  };
@@ -1775,6 +1783,7 @@ function defineConfig(config) {
1775
1783
  parseSort,
1776
1784
  parseSqlWhere,
1777
1785
  publishingWorkflow,
1786
+ resolveAdminAuthCollection,
1778
1787
  runCollectionHooks,
1779
1788
  saveWorkflowDraft,
1780
1789
  transitionWorkflow,
package/dist/index.d.cts CHANGED
@@ -81,7 +81,8 @@ type UploadDocFields = {
81
81
  declare function normalizeConfig(config: DyrectedConfig): DyrectedConfig;
82
82
 
83
83
  declare function getAdminAuthCollection(config: Pick<DyrectedConfig, "collections" | "adminAuth">): CollectionConfig | null;
84
- declare function getPublicAdminAuthConfig(adminAuth?: AdminAuthConfig): PublicAdminAuthConfig;
84
+ declare function resolveAdminAuthCollection(collections: CollectionConfig[], collectionSlug?: string): CollectionConfig | undefined;
85
+ declare function getPublicAdminAuthConfig(adminAuth?: AdminAuthConfig, collections?: CollectionConfig[]): PublicAdminAuthConfig;
85
86
 
86
87
  /**
87
88
  * Dyrected Where Clause DSL — shared query language across all database adapters.
@@ -341,4 +342,4 @@ declare function defineGlobal<TDoc extends object>(config: GlobalConfig<TDoc>):
341
342
  */
342
343
  declare function defineConfig(config: DyrectedConfig): DyrectedConfig;
343
344
 
344
- export { AdminAuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, CollectionConfig, DyrectedConfig, Field, GlobalConfig, HookRequestContext, type InferDocShape, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, type Prettify, PublicAdminAuthConfig, type SortClause, type SortDirection, type SqlWhereResult, type SystemDocFields, type UploadDocFields, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineCollection, defineConfig, defineGlobal, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
345
+ export { AdminAuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, CollectionConfig, DyrectedConfig, Field, GlobalConfig, HookRequestContext, type InferDocShape, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, type Prettify, PublicAdminAuthConfig, type SortClause, type SortDirection, type SqlWhereResult, type SystemDocFields, type UploadDocFields, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineCollection, defineConfig, defineGlobal, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
package/dist/index.d.ts CHANGED
@@ -81,7 +81,8 @@ type UploadDocFields = {
81
81
  declare function normalizeConfig(config: DyrectedConfig): DyrectedConfig;
82
82
 
83
83
  declare function getAdminAuthCollection(config: Pick<DyrectedConfig, "collections" | "adminAuth">): CollectionConfig | null;
84
- declare function getPublicAdminAuthConfig(adminAuth?: AdminAuthConfig): PublicAdminAuthConfig;
84
+ declare function resolveAdminAuthCollection(collections: CollectionConfig[], collectionSlug?: string): CollectionConfig | undefined;
85
+ declare function getPublicAdminAuthConfig(adminAuth?: AdminAuthConfig, collections?: CollectionConfig[]): PublicAdminAuthConfig;
85
86
 
86
87
  /**
87
88
  * Dyrected Where Clause DSL — shared query language across all database adapters.
@@ -341,4 +342,4 @@ declare function defineGlobal<TDoc extends object>(config: GlobalConfig<TDoc>):
341
342
  */
342
343
  declare function defineConfig(config: DyrectedConfig): DyrectedConfig;
343
344
 
344
- export { AdminAuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, CollectionConfig, DyrectedConfig, Field, GlobalConfig, HookRequestContext, type InferDocShape, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, type Prettify, PublicAdminAuthConfig, type SortClause, type SortDirection, type SqlWhereResult, type SystemDocFields, type UploadDocFields, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineCollection, defineConfig, defineGlobal, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
345
+ export { AdminAuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, CollectionConfig, DyrectedConfig, Field, GlobalConfig, HookRequestContext, type InferDocShape, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, type Prettify, PublicAdminAuthConfig, type SortClause, type SortDirection, type SqlWhereResult, type SystemDocFields, type UploadDocFields, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineCollection, defineConfig, defineGlobal, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
package/dist/index.js CHANGED
@@ -16,11 +16,12 @@ import {
16
16
  materializeWorkflowDocument,
17
17
  normalizeConfig,
18
18
  publishingWorkflow,
19
+ resolveAdminAuthCollection,
19
20
  runCollectionHooks,
20
21
  saveWorkflowDraft,
21
22
  transitionWorkflow,
22
23
  workflowCapabilities
23
- } from "./chunk-FCXE5CVC.js";
24
+ } from "./chunk-L65PQYDP.js";
24
25
 
25
26
  // src/types/workflows.ts
26
27
  var LIFECYCLE_EVENT_NAMES = [
@@ -240,6 +241,7 @@ export {
240
241
  parseSort,
241
242
  parseSqlWhere,
242
243
  publishingWorkflow,
244
+ resolveAdminAuthCollection,
243
245
  runCollectionHooks,
244
246
  saveWorkflowDraft,
245
247
  transitionWorkflow,
package/dist/server.cjs CHANGED
@@ -555,22 +555,29 @@ async function evaluateAccess(expression, context) {
555
555
 
556
556
  // src/utils/admin-auth.ts
557
557
  function getAdminAuthCollection(config) {
558
- const requestedSlug = config.adminAuth?.collectionSlug;
559
- if (requestedSlug) {
560
- return config.collections.find((collection) => collection.slug === requestedSlug) ?? null;
558
+ const adminCollection = resolveAdminAuthCollection(config.collections, config.adminAuth?.collectionSlug);
559
+ return adminCollection ?? null;
560
+ }
561
+ function resolveAdminAuthCollection(collections, collectionSlug) {
562
+ const adminsCollection = collections.find((collection) => collection.slug === "__admins");
563
+ if (adminsCollection) return adminsCollection;
564
+ if (collectionSlug) {
565
+ const requestedCollection = collections.find((collection) => collection.slug === collectionSlug);
566
+ if (requestedCollection) return requestedCollection;
561
567
  }
562
- return config.collections.find((collection) => collection.slug === "__admins") ?? config.collections.find((collection) => collection.auth) ?? null;
568
+ return collections.find((collection) => collection.auth);
563
569
  }
564
- function getPublicAdminAuthConfig(adminAuth) {
570
+ function getPublicAdminAuthConfig(adminAuth, collections) {
565
571
  const providers = (adminAuth?.providers ?? []).map((provider) => ({
566
572
  id: provider.id,
567
573
  type: provider.type,
568
574
  displayName: provider.displayName || humanizeProviderName(provider.id, provider.type),
569
575
  autoRedirect: provider.autoRedirect
570
576
  }));
577
+ const resolvedCollectionSlug = collections ? resolveAdminAuthCollection(collections, adminAuth?.collectionSlug)?.slug : adminAuth?.collectionSlug;
571
578
  return {
572
579
  mode: adminAuth?.mode ?? "local",
573
- collectionSlug: adminAuth?.collectionSlug,
580
+ collectionSlug: resolvedCollectionSlug,
574
581
  provisioningMode: adminAuth?.provisioningMode,
575
582
  providers
576
583
  };
@@ -818,12 +825,20 @@ var CollectionController = class {
818
825
  }
819
826
  return config.adminAuth?.providers?.find((p) => p.members) || null;
820
827
  }
828
+ toHookRequestContext(c) {
829
+ return {
830
+ query: c.req.query(),
831
+ headers: c.req.header(),
832
+ raw: c.req.raw
833
+ };
834
+ }
821
835
  async find(c) {
822
836
  const config = c.get("config");
823
837
  const db = config.db;
824
838
  if (!db) return c.json({ message: "Database not configured" }, 500);
825
839
  const provider = this.getDelegatedProvider(c);
826
840
  if (provider && provider.members?.list) {
841
+ const hookReq = this.toHookRequestContext(c);
827
842
  const limit2 = Number(c.req.query("limit")) || 10;
828
843
  const page2 = Number(c.req.query("page")) || 1;
829
844
  const sort2 = c.req.query("sort") || void 0;
@@ -835,7 +850,7 @@ var CollectionController = class {
835
850
  } catch {
836
851
  }
837
852
  }
838
- const paginatedResult = await provider.members.list({ limit: limit2, page: page2, sort: sort2, where: where2, req: c.req });
853
+ const paginatedResult = await provider.members.list({ limit: limit2, page: page2, sort: sort2, where: where2, req: hookReq });
839
854
  const mappedDocs = [];
840
855
  for (const m of paginatedResult.docs) {
841
856
  let localId = m.id;
@@ -942,15 +957,16 @@ var CollectionController = class {
942
957
  if (!db) return c.json({ message: "Database not configured" }, 500);
943
958
  const provider = this.getDelegatedProvider(c);
944
959
  if (provider && (provider.members?.get || provider.members?.list)) {
960
+ const hookReq = this.toHookRequestContext(c);
945
961
  const id2 = c.req.param("id");
946
962
  if (!id2) return c.json({ message: "Missing ID" }, 400);
947
963
  const localDoc = await db.findOne({ collection: this.collection.slug, id: id2 });
948
964
  const externalSubject = localDoc?.externalSubject || id2;
949
965
  let member = null;
950
966
  if (provider.members.get) {
951
- member = await provider.members.get({ externalSubject, req: c.req });
967
+ member = await provider.members.get({ externalSubject, req: hookReq });
952
968
  } else if (provider.members.list) {
953
- const listResult = await provider.members.list({ req: c.req });
969
+ const listResult = await provider.members.list({ req: hookReq });
954
970
  member = listResult.docs.find((m) => m.id === externalSubject) || null;
955
971
  }
956
972
  if (!member) return c.json({ message: "Not Found" }, 404);
@@ -997,12 +1013,13 @@ var CollectionController = class {
997
1013
  if (!db) return c.json({ message: "Database not configured" }, 500);
998
1014
  const provider = this.getDelegatedProvider(c);
999
1015
  if (provider && provider.members?.create) {
1016
+ const hookReq = this.toHookRequestContext(c);
1000
1017
  const contentType2 = c.req.header("Content-Type") || "";
1001
1018
  if (contentType2.toLowerCase().includes("multipart/form-data")) {
1002
1019
  return this.upload(c);
1003
1020
  }
1004
1021
  const body2 = await c.req.json();
1005
- const member = await provider.members.create({ data: body2, req: c.req });
1022
+ const member = await provider.members.create({ data: body2, req: hookReq });
1006
1023
  return c.json({
1007
1024
  ...member,
1008
1025
  id: member.id,
@@ -1137,12 +1154,13 @@ var CollectionController = class {
1137
1154
  if (!db) return c.json({ message: "Database not configured" }, 500);
1138
1155
  const provider = this.getDelegatedProvider(c);
1139
1156
  if (provider && provider.members?.update) {
1157
+ const hookReq = this.toHookRequestContext(c);
1140
1158
  const id2 = c.req.param("id");
1141
1159
  if (!id2) return c.json({ message: "Missing ID" }, 400);
1142
1160
  const body2 = await c.req.json();
1143
1161
  const localDoc = await db.findOne({ collection: this.collection.slug, id: id2 });
1144
1162
  const externalSubject = localDoc?.externalSubject || id2;
1145
- const member = await provider.members.update({ externalSubject, data: body2, req: c.req });
1163
+ const member = await provider.members.update({ externalSubject, data: body2, req: hookReq });
1146
1164
  return c.json({
1147
1165
  ...member,
1148
1166
  id: localDoc ? localDoc.id : member.id,
@@ -1339,11 +1357,12 @@ var CollectionController = class {
1339
1357
  if (!db) return c.json({ message: "Database not configured" }, 500);
1340
1358
  const provider = this.getDelegatedProvider(c);
1341
1359
  if (provider && provider.members?.delete) {
1360
+ const hookReq = this.toHookRequestContext(c);
1342
1361
  const id2 = c.req.param("id");
1343
1362
  if (!id2) return c.json({ message: "Missing ID" }, 400);
1344
1363
  const localDoc = await db.findOne({ collection: this.collection.slug, id: id2 });
1345
1364
  const externalSubject = localDoc?.externalSubject || id2;
1346
- await provider.members.delete({ externalSubject, req: c.req });
1365
+ await provider.members.delete({ externalSubject, req: hookReq });
1347
1366
  return c.json({ message: "Deleted" });
1348
1367
  }
1349
1368
  const readonlyDb = createReadonlyDb(db);
@@ -2234,8 +2253,9 @@ var AdminAuthController = class {
2234
2253
  this.config = config;
2235
2254
  }
2236
2255
  config;
2237
- providers(c) {
2238
- return c.json(getPublicAdminAuthConfig(this.config.adminAuth));
2256
+ async providers(c) {
2257
+ const requestConfig = await this.getRequestConfig(c);
2258
+ return c.json(getPublicAdminAuthConfig(requestConfig.adminAuth, requestConfig.collections));
2239
2259
  }
2240
2260
  async start(c) {
2241
2261
  const requestConfig = await this.getRequestConfig(c);
@@ -3728,7 +3748,7 @@ function registerRoutes(app, config) {
3728
3748
  collections: filteredCollections,
3729
3749
  globals: filteredGlobals,
3730
3750
  admin: config.admin || {},
3731
- adminAuth: getPublicAdminAuthConfig(config.adminAuth)
3751
+ adminAuth: getPublicAdminAuthConfig(config.adminAuth, collections)
3732
3752
  });
3733
3753
  });
3734
3754
  app.get("/api/dyrected/options/:collection/:field", optionalAuth(), async (c) => {
package/dist/server.d.cts CHANGED
@@ -156,6 +156,7 @@ declare class CollectionController {
156
156
  private collection;
157
157
  constructor(collection: CollectionConfig);
158
158
  private getDelegatedProvider;
159
+ private toHookRequestContext;
159
160
  find(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
160
161
  message: string;
161
162
  }, 500, "json">) | (Response & hono.TypedResponse<{
package/dist/server.d.ts CHANGED
@@ -156,6 +156,7 @@ declare class CollectionController {
156
156
  private collection;
157
157
  constructor(collection: CollectionConfig);
158
158
  private getDelegatedProvider;
159
+ private toHookRequestContext;
159
160
  find(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
160
161
  message: string;
161
162
  }, 500, "json">) | (Response & hono.TypedResponse<{
package/dist/server.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  runCollectionHooks,
14
14
  saveWorkflowDraft,
15
15
  transitionWorkflow
16
- } from "./chunk-FCXE5CVC.js";
16
+ } from "./chunk-L65PQYDP.js";
17
17
 
18
18
  // src/app.ts
19
19
  import { Hono } from "hono";
@@ -314,12 +314,20 @@ var CollectionController = class {
314
314
  }
315
315
  return config.adminAuth?.providers?.find((p) => p.members) || null;
316
316
  }
317
+ toHookRequestContext(c) {
318
+ return {
319
+ query: c.req.query(),
320
+ headers: c.req.header(),
321
+ raw: c.req.raw
322
+ };
323
+ }
317
324
  async find(c) {
318
325
  const config = c.get("config");
319
326
  const db = config.db;
320
327
  if (!db) return c.json({ message: "Database not configured" }, 500);
321
328
  const provider = this.getDelegatedProvider(c);
322
329
  if (provider && provider.members?.list) {
330
+ const hookReq = this.toHookRequestContext(c);
323
331
  const limit2 = Number(c.req.query("limit")) || 10;
324
332
  const page2 = Number(c.req.query("page")) || 1;
325
333
  const sort2 = c.req.query("sort") || void 0;
@@ -331,7 +339,7 @@ var CollectionController = class {
331
339
  } catch {
332
340
  }
333
341
  }
334
- const paginatedResult = await provider.members.list({ limit: limit2, page: page2, sort: sort2, where: where2, req: c.req });
342
+ const paginatedResult = await provider.members.list({ limit: limit2, page: page2, sort: sort2, where: where2, req: hookReq });
335
343
  const mappedDocs = [];
336
344
  for (const m of paginatedResult.docs) {
337
345
  let localId = m.id;
@@ -438,15 +446,16 @@ var CollectionController = class {
438
446
  if (!db) return c.json({ message: "Database not configured" }, 500);
439
447
  const provider = this.getDelegatedProvider(c);
440
448
  if (provider && (provider.members?.get || provider.members?.list)) {
449
+ const hookReq = this.toHookRequestContext(c);
441
450
  const id2 = c.req.param("id");
442
451
  if (!id2) return c.json({ message: "Missing ID" }, 400);
443
452
  const localDoc = await db.findOne({ collection: this.collection.slug, id: id2 });
444
453
  const externalSubject = localDoc?.externalSubject || id2;
445
454
  let member = null;
446
455
  if (provider.members.get) {
447
- member = await provider.members.get({ externalSubject, req: c.req });
456
+ member = await provider.members.get({ externalSubject, req: hookReq });
448
457
  } else if (provider.members.list) {
449
- const listResult = await provider.members.list({ req: c.req });
458
+ const listResult = await provider.members.list({ req: hookReq });
450
459
  member = listResult.docs.find((m) => m.id === externalSubject) || null;
451
460
  }
452
461
  if (!member) return c.json({ message: "Not Found" }, 404);
@@ -493,12 +502,13 @@ var CollectionController = class {
493
502
  if (!db) return c.json({ message: "Database not configured" }, 500);
494
503
  const provider = this.getDelegatedProvider(c);
495
504
  if (provider && provider.members?.create) {
505
+ const hookReq = this.toHookRequestContext(c);
496
506
  const contentType2 = c.req.header("Content-Type") || "";
497
507
  if (contentType2.toLowerCase().includes("multipart/form-data")) {
498
508
  return this.upload(c);
499
509
  }
500
510
  const body2 = await c.req.json();
501
- const member = await provider.members.create({ data: body2, req: c.req });
511
+ const member = await provider.members.create({ data: body2, req: hookReq });
502
512
  return c.json({
503
513
  ...member,
504
514
  id: member.id,
@@ -633,12 +643,13 @@ var CollectionController = class {
633
643
  if (!db) return c.json({ message: "Database not configured" }, 500);
634
644
  const provider = this.getDelegatedProvider(c);
635
645
  if (provider && provider.members?.update) {
646
+ const hookReq = this.toHookRequestContext(c);
636
647
  const id2 = c.req.param("id");
637
648
  if (!id2) return c.json({ message: "Missing ID" }, 400);
638
649
  const body2 = await c.req.json();
639
650
  const localDoc = await db.findOne({ collection: this.collection.slug, id: id2 });
640
651
  const externalSubject = localDoc?.externalSubject || id2;
641
- const member = await provider.members.update({ externalSubject, data: body2, req: c.req });
652
+ const member = await provider.members.update({ externalSubject, data: body2, req: hookReq });
642
653
  return c.json({
643
654
  ...member,
644
655
  id: localDoc ? localDoc.id : member.id,
@@ -835,11 +846,12 @@ var CollectionController = class {
835
846
  if (!db) return c.json({ message: "Database not configured" }, 500);
836
847
  const provider = this.getDelegatedProvider(c);
837
848
  if (provider && provider.members?.delete) {
849
+ const hookReq = this.toHookRequestContext(c);
838
850
  const id2 = c.req.param("id");
839
851
  if (!id2) return c.json({ message: "Missing ID" }, 400);
840
852
  const localDoc = await db.findOne({ collection: this.collection.slug, id: id2 });
841
853
  const externalSubject = localDoc?.externalSubject || id2;
842
- await provider.members.delete({ externalSubject, req: c.req });
854
+ await provider.members.delete({ externalSubject, req: hookReq });
843
855
  return c.json({ message: "Deleted" });
844
856
  }
845
857
  const readonlyDb = createReadonlyDb(db);
@@ -1735,8 +1747,9 @@ var AdminAuthController = class {
1735
1747
  this.config = config;
1736
1748
  }
1737
1749
  config;
1738
- providers(c) {
1739
- return c.json(getPublicAdminAuthConfig(this.config.adminAuth));
1750
+ async providers(c) {
1751
+ const requestConfig = await this.getRequestConfig(c);
1752
+ return c.json(getPublicAdminAuthConfig(requestConfig.adminAuth, requestConfig.collections));
1740
1753
  }
1741
1754
  async start(c) {
1742
1755
  const requestConfig = await this.getRequestConfig(c);
@@ -2404,7 +2417,7 @@ function registerRoutes(app, config) {
2404
2417
  collections: filteredCollections,
2405
2418
  globals: filteredGlobals,
2406
2419
  admin: config.admin || {},
2407
- adminAuth: getPublicAdminAuthConfig(config.adminAuth)
2420
+ adminAuth: getPublicAdminAuthConfig(config.adminAuth, collections)
2408
2421
  });
2409
2422
  });
2410
2423
  app.get("/api/dyrected/options/:collection/:field", optionalAuth(), async (c) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyrected/core",
3
- "version": "2.5.47",
3
+ "version": "2.5.49",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",