@classytic/arc 2.6.3 → 2.7.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.
Files changed (143) hide show
  1. package/README.md +98 -3
  2. package/dist/{BaseController-DzRtluEF.mjs → BaseController-CpMfCXdn.mjs} +134 -16
  3. package/dist/adapters/index.d.mts +2 -2
  4. package/dist/adapters/index.mjs +1 -1
  5. package/dist/{adapters-gM-WYjNe.mjs → adapters-BxGgSHjj.mjs} +1 -9
  6. package/dist/applyPermissionResult-D6GPMsvh.mjs +37 -0
  7. package/dist/audit/index.d.mts +1 -1
  8. package/dist/audit/index.mjs +1 -1
  9. package/dist/audit/mongodb.d.mts +1 -1
  10. package/dist/audit/mongodb.mjs +1 -1
  11. package/dist/auth/index.d.mts +4 -4
  12. package/dist/auth/index.mjs +7 -6
  13. package/dist/auth/mongoose.d.mts +191 -0
  14. package/dist/auth/mongoose.mjs +73 -0
  15. package/dist/auth/redis-session.d.mts +1 -1
  16. package/dist/{betterAuthOpenApi-lz0IRbXJ.mjs → betterAuthOpenApi-CCw3YX0g.mjs} +1 -1
  17. package/dist/cache/index.d.mts +2 -2
  18. package/dist/cache/index.mjs +2 -2
  19. package/dist/cli/commands/docs.mjs +2 -2
  20. package/dist/cli/commands/generate.mjs +1 -1
  21. package/dist/cli/commands/init.mjs +7 -5
  22. package/dist/cli/commands/introspect.mjs +1 -1
  23. package/dist/core/index.d.mts +3 -3
  24. package/dist/core/index.mjs +4 -4
  25. package/dist/{core-C1XCMtqM.mjs → core-BWekSEju.mjs} +41 -13
  26. package/dist/{createApp-D2w0LdYJ.mjs → createApp-D7e77m8C.mjs} +25 -14
  27. package/dist/{defineResource-wWMBB4GP.mjs → defineResource-DZzyl4a4.mjs} +42 -37
  28. package/dist/docs/index.d.mts +2 -2
  29. package/dist/docs/index.mjs +1 -1
  30. package/dist/dynamic/index.d.mts +2 -2
  31. package/dist/dynamic/index.mjs +2 -2
  32. package/dist/{elevation-BEdACOLB.mjs → elevation-By_p2lnn.mjs} +1 -1
  33. package/dist/elevation-D7WK0RXq.d.mts +23 -0
  34. package/dist/{errorHandler-r2595m8T.mjs → errorHandler-CH8wk1eD.mjs} +17 -2
  35. package/dist/{errorHandler-Do4vVQ1f.d.mts → errorHandler-pCpEtNd7.d.mts} +46 -2
  36. package/dist/{eventPlugin-Ba00swHF.mjs → eventPlugin-B6U_nCFU.mjs} +4 -3
  37. package/dist/{eventPlugin-DW45v4V5.d.mts → eventPlugin-CdvUoUna.d.mts} +1 -1
  38. package/dist/events/index.d.mts +3 -3
  39. package/dist/events/index.mjs +1 -1
  40. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  41. package/dist/events/transports/redis.d.mts +1 -1
  42. package/dist/factory/index.d.mts +1 -1
  43. package/dist/factory/index.mjs +1 -1
  44. package/dist/hooks/index.d.mts +1 -1
  45. package/dist/hooks/index.mjs +1 -1
  46. package/dist/idempotency/index.d.mts +3 -3
  47. package/dist/idempotency/mongodb.d.mts +1 -1
  48. package/dist/idempotency/redis.d.mts +1 -1
  49. package/dist/index-B0extFr4.d.mts +640 -0
  50. package/dist/{index-gz6iuzCp.d.mts → index-BjShrzoj.d.mts} +47 -4
  51. package/dist/{index-CHeJa4Zd.d.mts → index-C9eYNjGR.d.mts} +1 -1
  52. package/dist/index.d.mts +9 -8
  53. package/dist/index.mjs +10 -9
  54. package/dist/integrations/event-gateway.d.mts +1 -1
  55. package/dist/integrations/event-gateway.mjs +1 -1
  56. package/dist/integrations/index.d.mts +1 -1
  57. package/dist/integrations/mcp/index.d.mts +2 -2
  58. package/dist/integrations/mcp/index.mjs +8 -5
  59. package/dist/integrations/mcp/testing.d.mts +1 -1
  60. package/dist/integrations/mcp/testing.mjs +1 -1
  61. package/dist/integrations/webhooks.d.mts +58 -1
  62. package/dist/integrations/webhooks.mjs +78 -7
  63. package/dist/integrations/websocket.d.mts +7 -1
  64. package/dist/integrations/websocket.mjs +7 -1
  65. package/dist/{interface-DYH8AXGe.d.mts → interface-B91alUzq.d.mts} +151 -15
  66. package/dist/{mongodb-pMvOlR5_.d.mts → mongodb-B7zupyck.d.mts} +1 -1
  67. package/dist/{mongodb-kltrBPa1.d.mts → mongodb-Cgu9F1Nd.d.mts} +1 -1
  68. package/dist/{openapi-CBmZ6EQN.mjs → openapi-BBSTVcMm.mjs} +1 -1
  69. package/dist/org/index.d.mts +2 -2
  70. package/dist/org/index.mjs +1 -1
  71. package/dist/permissions/index.d.mts +4 -4
  72. package/dist/permissions/index.mjs +3 -2
  73. package/dist/{permissions-C8ImI8gC.mjs → permissions-CH4cNwJi.mjs} +358 -64
  74. package/dist/plugins/index.d.mts +52 -5
  75. package/dist/plugins/index.mjs +12 -11
  76. package/dist/plugins/response-cache.mjs +1 -1
  77. package/dist/plugins/tracing-entry.d.mts +1 -1
  78. package/dist/plugins/tracing-entry.mjs +1 -1
  79. package/dist/policies/index.d.mts +1 -1
  80. package/dist/presets/index.d.mts +3 -3
  81. package/dist/presets/index.mjs +1 -1
  82. package/dist/presets/multiTenant.d.mts +53 -3
  83. package/dist/presets/multiTenant.mjs +89 -47
  84. package/dist/{presets-BMfdy34e.mjs → presets-BFrGvvjL.mjs} +2 -2
  85. package/dist/{queryCachePlugin-DcmETvcB.d.mts → queryCachePlugin-Ckl71mkc.d.mts} +1 -1
  86. package/dist/{queryCachePlugin-XtFplYO9.mjs → queryCachePlugin-CwTpR04-.mjs} +2 -2
  87. package/dist/{redis-D0Qc-9EW.d.mts → redis-3TQxm2VZ.d.mts} +1 -1
  88. package/dist/{redis-stream-BW9UKLZM.d.mts → redis-stream-Dag5LFa9.d.mts} +1 -1
  89. package/dist/registry/index.d.mts +1 -1
  90. package/dist/registry/index.mjs +2 -2
  91. package/dist/replyHelpers-uDUIYh7u.mjs +40 -0
  92. package/dist/{resourceToTools-nCJWnG1r.mjs → resourceToTools-BJkoQoUP.mjs} +74 -25
  93. package/dist/rpc/index.d.mts +1 -1
  94. package/dist/rpc/index.mjs +1 -1
  95. package/dist/scope/index.d.mts +3 -2
  96. package/dist/scope/index.mjs +4 -3
  97. package/dist/{sse-BF7GR7IB.mjs → sse-6W0hjVS_.mjs} +2 -2
  98. package/dist/testing/index.d.mts +2 -2
  99. package/dist/testing/index.mjs +1 -1
  100. package/dist/types/index.d.mts +4 -3
  101. package/dist/types/index.mjs +1 -1
  102. package/dist/types--D3vvfdt.d.mts +286 -0
  103. package/dist/{types-By-5mIfn.d.mts → types-2FlNl0mL.d.mts} +44 -9
  104. package/dist/types-AOD8fxIw.mjs +229 -0
  105. package/dist/types-B4BNthET.d.mts +178 -0
  106. package/dist/{types-B4_TDdPe.d.mts → types-C5g2oRC7.d.mts} +18 -2
  107. package/dist/utils/index.d.mts +3 -3
  108. package/dist/utils/index.mjs +5 -5
  109. package/package.json +21 -6
  110. package/skills/arc/SKILL.md +314 -6
  111. package/skills/arc/references/integrations.md +32 -7
  112. package/skills/arc/references/mcp.md +31 -7
  113. package/skills/arc/references/multi-tenancy.md +208 -0
  114. package/skills/arc/references/production.md +69 -0
  115. package/dist/elevation-C_taLQrM.d.mts +0 -147
  116. package/dist/index-NGZksqM5.d.mts +0 -398
  117. package/dist/types-BNUccdcf.d.mts +0 -101
  118. package/dist/types-BhtYdxZU.mjs +0 -91
  119. /package/dist/{EventTransport-wc5hSLik.d.mts → EventTransport-C4VheKeC.d.mts} +0 -0
  120. /package/dist/{HookSystem-COkyWztM.mjs → HookSystem-D7lfx--K.mjs} +0 -0
  121. /package/dist/{ResourceRegistry-C6ngvOnn.mjs → ResourceRegistry-DsHiG9cL.mjs} +0 -0
  122. /package/dist/{caching-BSXB-Xr7.mjs → caching-5DtLwIqb.mjs} +0 -0
  123. /package/dist/{circuitBreaker-JP2GdJ4b.d.mts → circuitBreaker-BBPDt-J_.d.mts} +0 -0
  124. /package/dist/{circuitBreaker-BOBOpN2w.mjs → circuitBreaker-l18oRgL5.mjs} +0 -0
  125. /package/dist/{errors-CcVbl1-T.d.mts → errors-BS6lZvWy.d.mts} +0 -0
  126. /package/dist/{errors-NoQKsbAT.mjs → errors-Cg58SLNi.mjs} +0 -0
  127. /package/dist/{externalPaths-DpO-s7r8.d.mts → externalPaths-iba7jD3d.d.mts} +0 -0
  128. /package/dist/{fields-DFwdaWCq.d.mts → fields-D4nMDqnK.d.mts} +0 -0
  129. /package/dist/{interface-D_BWALyZ.d.mts → interface-CG7oRZjX.d.mts} +0 -0
  130. /package/dist/{interface-gr-7qo9j.d.mts → interface-CSbZdv_3.d.mts} +0 -0
  131. /package/dist/{logger-Dz3j1ItV.mjs → logger-DLg8-Ueg.mjs} +0 -0
  132. /package/dist/{memory-BFAYkf8H.mjs → memory-Cp7_cAko.mjs} +0 -0
  133. /package/dist/{metrics-Csh4nsvv.mjs → metrics-Qnvwc-LQ.mjs} +0 -0
  134. /package/dist/{mongodb-BuQ7fNTg.mjs → mongodb-B7X7P1P8.mjs} +0 -0
  135. /package/dist/{pluralize-CcT6qF0a.mjs → pluralize-Dckfq6US.mjs} +0 -0
  136. /package/dist/{registry-I-ogLgL9.mjs → registry-B3lRFBWo.mjs} +0 -0
  137. /package/dist/{requestContext-DYtmNpm5.mjs → requestContext-xHIKedG6.mjs} +0 -0
  138. /package/dist/{schemaConverter-DjzHpFam.mjs → schemaConverter-0TyONAwM.mjs} +0 -0
  139. /package/dist/{sessionManager-wbkYj2HL.d.mts → sessionManager-CEo9jwPI.d.mts} +0 -0
  140. /package/dist/{tracing-bz_U4EM1.d.mts → tracing-DEqdGkr-.d.mts} +0 -0
  141. /package/dist/{typeGuards-Cj5Rgvlg.mjs → typeGuards-CcFZXgU7.mjs} +0 -0
  142. /package/dist/{utils-Dc0WhlIl.mjs → utils-B-l6410F.mjs} +0 -0
  143. /package/dist/{versioning-BzfeHmhj.mjs → versioning-CdBbFefk.mjs} +0 -0
@@ -0,0 +1,191 @@
1
+ //#region src/auth/mongoose.d.ts
2
+ /**
3
+ * Better Auth × Mongoose Bridge
4
+ *
5
+ * Optional helper that registers stub Mongoose models for the collections
6
+ * that Better Auth's MongoDB adapter writes to. This is a one-way *read*
7
+ * bridge: Better Auth still writes via its own native `mongodb` driver
8
+ * (through `@better-auth/mongo-adapter`), but stub models let arc resources
9
+ * built on Mongoose use `.populate()` against BA-owned collections.
10
+ *
11
+ * **Why this is needed**: Mongoose's `populate()` looks up the target model
12
+ * by name. BA never registers anything with Mongoose, so a schema like
13
+ * `new Schema({ userId: { ref: 'user' } })` throws `MissingSchemaError`
14
+ * the first time you call `.populate('userId')`. This helper registers an
15
+ * empty `strict: false` schema for each BA collection, so populate works
16
+ * without interfering with BA's writes.
17
+ *
18
+ * **DB-agnostic by design**: this file lives at the dedicated subpath
19
+ * `@classytic/arc/auth/mongoose`. Users on Prisma/Drizzle/Kysely never
20
+ * import it and never get Mongoose pulled into their bundle. Mongoose is
21
+ * passed in as a parameter so this module has zero runtime imports of it.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import mongoose from 'mongoose';
26
+ * import { betterAuth } from 'better-auth';
27
+ * import { mongodbAdapter } from '@better-auth/mongo-adapter';
28
+ * import { organization } from 'better-auth/plugins';
29
+ * import { registerBetterAuthMongooseModels } from '@classytic/arc/auth/mongoose';
30
+ *
31
+ * const auth = betterAuth({
32
+ * database: mongodbAdapter(mongoose.connection.getClient().db()),
33
+ * plugins: [organization({ teams: { enabled: true } })],
34
+ * // ...
35
+ * });
36
+ *
37
+ * // Register stub models AFTER betterAuth() so collections are known.
38
+ * // For plugins shipped as separate @better-auth/* packages (passkey, sso,
39
+ * // api-key, oauth-provider, etc.), add their collection names via
40
+ * // `extraCollections` — see the JSDoc on that option for known names.
41
+ * registerBetterAuthMongooseModels(mongoose, {
42
+ * plugins: ['organization', 'organization-teams', 'mcp'],
43
+ * extraCollections: ['passkey', 'ssoProvider'], // @better-auth/passkey, @better-auth/sso
44
+ * });
45
+ *
46
+ * // Now an arc resource can populate BA-owned references:
47
+ * const PostSchema = new mongoose.Schema({
48
+ * title: String,
49
+ * authorId: { type: String, ref: 'user' },
50
+ * });
51
+ * const Post = mongoose.model('Post', PostSchema);
52
+ * await Post.findOne().populate('authorId'); // resolves against BA's user collection
53
+ * ```
54
+ */
55
+ /**
56
+ * Minimal structural type for the subset of Mongoose we touch.
57
+ * Declared structurally so this file has zero `import` of mongoose —
58
+ * mongoose stays a peer dep and is never bundled with arc.
59
+ */
60
+ interface MongooseLike {
61
+ models: Record<string, unknown>;
62
+ Schema: new (definition: Record<string, unknown>, options?: {
63
+ strict?: boolean;
64
+ collection?: string;
65
+ _id?: boolean;
66
+ }) => unknown;
67
+ model: (name: string, schema?: unknown) => unknown;
68
+ }
69
+ /**
70
+ * Plugin keys that map to Better Auth collection sets.
71
+ *
72
+ * Only plugins that ship inside the **core `better-auth` package** are listed
73
+ * here. Plugins distributed as separate `@better-auth/*` packages
74
+ * (api-key, passkey, sso, oauth-provider, etc.) evolve independently and
75
+ * should be handled via `extraCollections` — see the JSDoc on that option.
76
+ *
77
+ * Plugins that only add *fields* to existing tables (admin, username,
78
+ * phoneNumber, magicLink, emailOtp, anonymous, bearer, multiSession, siwe,
79
+ * lastLoginMethod, genericOAuth, etc.) don't need an entry here — the stub
80
+ * schemas are registered with `strict: false`, so extra fields round-trip
81
+ * automatically.
82
+ *
83
+ * - `core` — always included; covers `user`, `session`, `account`, `verification`.
84
+ * - `organization` — adds `organization`, `member`, `invitation`.
85
+ * - `organization-teams` — adds `team`, `teamMember` (only when `teams.enabled`).
86
+ * - `twoFactor` — adds `twoFactor`.
87
+ * - `jwt` — adds `jwks`.
88
+ * - `oidcProvider` — adds `oauthApplication`, `oauthAccessToken`, `oauthConsent`.
89
+ * - `oauthProvider` — alias of `oidcProvider` (same schema). Use this key if
90
+ * you've migrated to `@better-auth/oauth-provider` per BA 1.6 release notes
91
+ * — the collections are identical.
92
+ * - `mcp` — MCP plugin **reuses the oidcProvider schema** (docs: "The MCP
93
+ * plugin uses the same schema as the OIDC Provider plugin"). Selecting this
94
+ * registers the oauth* collections.
95
+ * - `deviceAuthorization` — adds `deviceCode` (RFC 8628 device authorization).
96
+ */
97
+ type BetterAuthPluginKey = "core" | "organization" | "organization-teams" | "twoFactor" | "jwt" | "oidcProvider" | "oauthProvider" | "mcp" | "deviceAuthorization";
98
+ interface RegisterBetterAuthMongooseModelsOptions {
99
+ /**
100
+ * Which Better Auth plugin collection sets to register stubs for.
101
+ * `'core'` is always included implicitly (covers `user`, `session`,
102
+ * `account`, `verification`).
103
+ *
104
+ * **Default is `[]` (core only) on purpose** — the helper should never
105
+ * register stubs for plugins you haven't enabled. Opt in explicitly to
106
+ * each plugin you've added to your `betterAuth({ plugins: [...] })` config.
107
+ *
108
+ * @default []
109
+ * @example
110
+ * ```ts
111
+ * // Just core BA (email/password, sessions)
112
+ * registerBetterAuthMongooseModels(mongoose);
113
+ *
114
+ * // Core + organization plugin
115
+ * registerBetterAuthMongooseModels(mongoose, { plugins: ['organization'] });
116
+ *
117
+ * // Core + organization with teams + MCP server
118
+ * registerBetterAuthMongooseModels(mongoose, {
119
+ * plugins: ['organization', 'organization-teams', 'mcp'],
120
+ * });
121
+ * ```
122
+ */
123
+ plugins?: BetterAuthPluginKey[];
124
+ /**
125
+ * Whether Better Auth's mongo adapter was configured with `usePlural: true`.
126
+ * When true, model names and collection names are pluralized
127
+ * (`user` → `users`, `organization` → `organizations`, etc).
128
+ *
129
+ * **Must match** the `usePlural` value passed to `mongodbAdapter()`.
130
+ *
131
+ * @default false
132
+ */
133
+ usePlural?: boolean;
134
+ /**
135
+ * Override the model name for specific Better Auth collections.
136
+ * Use this when you've passed `user: { modelName: 'profiles' }` (or similar)
137
+ * to `betterAuth()` — pass the same map here so populate names line up.
138
+ *
139
+ * Keys are the canonical BA names (`user`, `session`, etc.); values are
140
+ * the model name to register with Mongoose. The collection name is also
141
+ * set to the override value.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * registerBetterAuthMongooseModels(mongoose, {
146
+ * modelOverrides: { user: 'profile', member: 'orgMember' },
147
+ * });
148
+ * ```
149
+ */
150
+ modelOverrides?: Partial<Record<string, string>>;
151
+ /**
152
+ * Additional collection names to register beyond the built-in plugin set.
153
+ *
154
+ * **Use this for plugins that ship as separate `@better-auth/*` packages**
155
+ * (they're intentionally not hardcoded in `BetterAuthPluginKey` because
156
+ * their collection names live in their own packages and can evolve
157
+ * independently of the core `better-auth` release cycle).
158
+ *
159
+ * Known collection names for official separate-package plugins:
160
+ * - `@better-auth/passkey` → `'passkey'`
161
+ * - `@better-auth/sso` → `'ssoProvider'`
162
+ * - `@better-auth/oauth-provider` → already covered by `plugins: ['oauthProvider']`
163
+ * (same schema as the in-core `oidcProvider`)
164
+ * - `@better-auth/api-key` → consult the plugin's docs for the current
165
+ * model name; it's one collection
166
+ *
167
+ * For your own custom Better Auth plugins, pass whatever collection names
168
+ * they write to.
169
+ *
170
+ * @default []
171
+ * @example
172
+ * ```ts
173
+ * registerBetterAuthMongooseModels(mongoose, {
174
+ * plugins: ['organization'],
175
+ * extraCollections: ['passkey', 'ssoProvider'],
176
+ * });
177
+ * ```
178
+ */
179
+ extraCollections?: string[];
180
+ }
181
+ /**
182
+ * Register stub Mongoose models for Better Auth's collections so that
183
+ * Mongoose-based arc resources can `.populate()` references to BA-owned
184
+ * documents. Idempotent — safe to call multiple times.
185
+ *
186
+ * Returns the list of model names that were newly registered (excluding
187
+ * any that already existed on `mongoose.models`).
188
+ */
189
+ declare function registerBetterAuthMongooseModels(mongoose: MongooseLike, options?: RegisterBetterAuthMongooseModelsOptions): string[];
190
+ //#endregion
191
+ export { BetterAuthPluginKey, MongooseLike, RegisterBetterAuthMongooseModelsOptions, registerBetterAuthMongooseModels };
@@ -0,0 +1,73 @@
1
+ //#region src/auth/mongoose.ts
2
+ const COLLECTIONS_BY_PLUGIN = {
3
+ core: [
4
+ "user",
5
+ "session",
6
+ "account",
7
+ "verification"
8
+ ],
9
+ organization: [
10
+ "organization",
11
+ "member",
12
+ "invitation"
13
+ ],
14
+ "organization-teams": ["team", "teamMember"],
15
+ twoFactor: ["twoFactor"],
16
+ jwt: ["jwks"],
17
+ oidcProvider: [
18
+ "oauthApplication",
19
+ "oauthAccessToken",
20
+ "oauthConsent"
21
+ ],
22
+ oauthProvider: [
23
+ "oauthApplication",
24
+ "oauthAccessToken",
25
+ "oauthConsent"
26
+ ],
27
+ mcp: [
28
+ "oauthApplication",
29
+ "oauthAccessToken",
30
+ "oauthConsent"
31
+ ],
32
+ deviceAuthorization: ["deviceCode"]
33
+ };
34
+ /**
35
+ * Naive English pluralization that matches Better Auth's `usePlural` behavior.
36
+ * BA's mongo adapter just appends `s` (it doesn't handle irregular nouns —
37
+ * none of its collection names are irregular). We mirror that exactly.
38
+ */
39
+ function pluralize(name) {
40
+ return name.endsWith("s") ? name : `${name}s`;
41
+ }
42
+ /**
43
+ * Register stub Mongoose models for Better Auth's collections so that
44
+ * Mongoose-based arc resources can `.populate()` references to BA-owned
45
+ * documents. Idempotent — safe to call multiple times.
46
+ *
47
+ * Returns the list of model names that were newly registered (excluding
48
+ * any that already existed on `mongoose.models`).
49
+ */
50
+ function registerBetterAuthMongooseModels(mongoose, options = {}) {
51
+ const { plugins = [], usePlural = false, modelOverrides = {}, extraCollections = [] } = options;
52
+ const pluginSet = new Set(["core", ...plugins]);
53
+ const collected = [];
54
+ for (const key of pluginSet) for (const name of COLLECTIONS_BY_PLUGIN[key]) collected.push(name);
55
+ for (const name of extraCollections) collected.push(name);
56
+ const seen = /* @__PURE__ */ new Set();
57
+ const unique = collected.filter((n) => seen.has(n) ? false : (seen.add(n), true));
58
+ const registered = [];
59
+ for (const canonical of unique) {
60
+ const finalName = modelOverrides[canonical] ?? (usePlural ? pluralize(canonical) : canonical);
61
+ if (mongoose.models[finalName]) continue;
62
+ const schema = new mongoose.Schema({}, {
63
+ strict: false,
64
+ collection: finalName,
65
+ _id: false
66
+ });
67
+ mongoose.model(finalName, schema);
68
+ registered.push(finalName);
69
+ }
70
+ return registered;
71
+ }
72
+ //#endregion
73
+ export { registerBetterAuthMongooseModels };
@@ -1,4 +1,4 @@
1
- import { i as SessionData, s as SessionStore } from "../sessionManager-wbkYj2HL.mjs";
1
+ import { i as SessionData, s as SessionStore } from "../sessionManager-CEo9jwPI.mjs";
2
2
 
3
3
  //#region src/auth/redis-session.d.ts
4
4
  /** Minimal Redis client interface — compatible with ioredis */
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-BpYLSNr0.mjs";
2
- import { a as toJsonSchema } from "./schemaConverter-DjzHpFam.mjs";
2
+ import { a as toJsonSchema } from "./schemaConverter-0TyONAwM.mjs";
3
3
  //#region src/auth/betterAuthOpenApi.ts
4
4
  var betterAuthOpenApi_exports = /* @__PURE__ */ __exportAll({ extractBetterAuthOpenApi: () => extractBetterAuthOpenApi });
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { i as CacheStore, n as CacheSetOptions, r as CacheStats, t as CacheLogger } from "../interface-D_BWALyZ.mjs";
2
- import { a as CacheEnvelope, c as QueryCache, i as queryCachePlugin, l as QueryCacheConfig, n as QueryCacheDefaults, o as CacheResult, r as QueryCachePluginOptions, s as CacheStatus, t as CrossResourceRule } from "../queryCachePlugin-DcmETvcB.mjs";
1
+ import { i as CacheStore, n as CacheSetOptions, r as CacheStats, t as CacheLogger } from "../interface-CG7oRZjX.mjs";
2
+ import { a as CacheEnvelope, c as QueryCache, i as queryCachePlugin, l as QueryCacheConfig, n as QueryCacheDefaults, o as CacheResult, r as QueryCachePluginOptions, s as CacheStatus, t as CrossResourceRule } from "../queryCachePlugin-Ckl71mkc.mjs";
3
3
 
4
4
  //#region src/cache/keys.d.ts
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { i as versionKey, n as hashParams, r as tagVersionKey, t as buildQueryKey } from "../keys-qcD-TVJl.mjs";
2
- import { t as MemoryCacheStore } from "../memory-BFAYkf8H.mjs";
3
- import { r as QueryCache, t as queryCachePlugin } from "../queryCachePlugin-XtFplYO9.mjs";
2
+ import { t as MemoryCacheStore } from "../memory-Cp7_cAko.mjs";
3
+ import { r as QueryCache, t as queryCachePlugin } from "../queryCachePlugin-CwTpR04-.mjs";
4
4
  //#region src/cache/redis.ts
5
5
  /**
6
6
  * Redis-backed cache store.
@@ -1,5 +1,5 @@
1
- import { t as ResourceRegistry } from "../../ResourceRegistry-C6ngvOnn.mjs";
2
- import { t as buildOpenApiSpec } from "../../openapi-CBmZ6EQN.mjs";
1
+ import { t as ResourceRegistry } from "../../ResourceRegistry-DsHiG9cL.mjs";
2
+ import { t as buildOpenApiSpec } from "../../openapi-BBSTVcMm.mjs";
3
3
  import { dirname, resolve } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import { mkdirSync, writeFileSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { t as pluralize } from "../../pluralize-CcT6qF0a.mjs";
1
+ import { t as pluralize } from "../../pluralize-Dckfq6US.mjs";
2
2
  import { join } from "node:path";
3
3
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
4
  //#region src/cli/commands/generate.ts
@@ -100,9 +100,9 @@ async function installDependencies(projectPath, config, pm) {
100
100
  "@fastify/under-pressure@latest",
101
101
  "dotenv@latest"
102
102
  ];
103
- if (config.auth === "better-auth") deps.push("better-auth@latest", "mongodb@latest");
103
+ if (config.auth === "better-auth") deps.push("better-auth@^1.6.0", "mongodb@latest");
104
104
  else deps.push("@fastify/jwt@latest", "bcryptjs@latest");
105
- if (config.adapter === "mongokit") deps.push("@classytic/mongokit@latest", "mongoose@latest");
105
+ if (config.adapter === "mongokit") deps.push("@classytic/mongokit@^3.5.5", "mongoose@^9.4.1");
106
106
  const devDeps = ["vitest@latest", "pino-pretty@latest"];
107
107
  if (config.typescript) devDeps.push("typescript@latest", "@types/node@latest", "tsx@latest");
108
108
  const installCmd = getInstallCommand(pm, deps, false);
@@ -1323,13 +1323,15 @@ export const requireSuperadmin = ()${returnType} =>
1323
1323
  /**
1324
1324
  * Organization-level guards (per-org member.role):
1325
1325
  *
1326
- * - roles('admin') — checks BOTH user.role AND org member.role (recommended)
1326
+ * - requireRoles('admin') — checks BOTH user.role AND org member.role (recommended)
1327
1327
  * - requireOrgRole(['admin','owner']) — checks member.role in active org ONLY
1328
1328
  * - requireOrgMembership() — just checks if user is in the org (any role)
1329
1329
  * - requireTeamMembership() — checks if user is in the active team
1330
1330
  *
1331
- * RECOMMENDED: Use roles() for most cases it checks platform + org roles automatically.
1332
- * Use requireOrgRole() when you ONLY want org-level checks (exclude platform admins).
1331
+ * RECOMMENDED: Use requireRoles() for most cases. Since Arc 2.7.1 it defaults to
1332
+ * checking both platform AND org roles, so a single call covers BA org plugin users
1333
+ * with platform-admin overrides. Use requireOrgRole() when you ONLY want org-level
1334
+ * checks (and want to explicitly exclude platform admins).
1333
1335
  *
1334
1336
  * Platform superadmin automatically bypasses all org role checks.
1335
1337
  *
@@ -1,4 +1,4 @@
1
- import { t as ResourceRegistry } from "../../ResourceRegistry-C6ngvOnn.mjs";
1
+ import { t as ResourceRegistry } from "../../ResourceRegistry-DsHiG9cL.mjs";
2
2
  import { resolve } from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
4
  //#region src/cli/commands/introspect.ts
@@ -1,3 +1,3 @@
1
- import { At as AccessControl, Dt as QueryResolverConfig, Et as QueryResolver, Ht as defineResource, Ot as BodySanitizer, Tt as BaseControllerOptions, Vt as ResourceDefinition, jt as AccessControlConfig, kt as BodySanitizerConfig, wt as BaseController } from "../interface-DYH8AXGe.mjs";
2
- import { A as RESERVED_QUERY_PARAMS, C as HookOperation, D as MAX_SEARCH_LENGTH, E as MAX_REGEX_LENGTH, O as MUTATION_OPERATIONS, S as HOOK_PHASES, T as MAX_FILTER_DEPTH, _ as DEFAULT_MAX_LIMIT, a as getControllerScope, b as DEFAULT_UPDATE_METHOD, c as createPermissionMiddleware, d as IdempotencyService, f as createActionRouter, g as DEFAULT_LIMIT, h as DEFAULT_ID_FIELD, i as getControllerContext, j as SYSTEM_FIELDS, k as MutationOperation, l as ActionHandler, m as CrudOperation, n as createFastifyHandler, o as sendControllerResponse, p as CRUD_OPERATIONS, r as createRequestContext, s as createCrudRouter, t as createCrudHandlers, u as ActionRouterConfig, v as DEFAULT_SORT, w as HookPhase, x as HOOK_OPERATIONS, y as DEFAULT_TENANT_FIELD } from "../index-gz6iuzCp.mjs";
3
- export { AccessControl, AccessControlConfig, ActionHandler, ActionRouterConfig, BaseController, BaseControllerOptions, BodySanitizer, BodySanitizerConfig, CRUD_OPERATIONS, CrudOperation, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, HOOK_OPERATIONS, HOOK_PHASES, HookOperation, HookPhase, IdempotencyService, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, MutationOperation, QueryResolver, QueryResolverConfig, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, createActionRouter, createCrudHandlers, createCrudRouter, createFastifyHandler, createPermissionMiddleware, createRequestContext, defineResource, getControllerContext, getControllerScope, sendControllerResponse };
1
+ import { At as AccessControl, Dt as QueryResolverConfig, Et as QueryResolver, Ht as defineResource, Ot as BodySanitizer, Tt as BaseControllerOptions, Vt as ResourceDefinition, jt as AccessControlConfig, kt as BodySanitizerConfig, wt as BaseController } from "../interface-B91alUzq.mjs";
2
+ import { A as MutationOperation, C as HOOK_PHASES, D as MAX_REGEX_LENGTH, E as MAX_FILTER_DEPTH, M as SYSTEM_FIELDS, O as MAX_SEARCH_LENGTH, S as HOOK_OPERATIONS, T as HookPhase, _ as DEFAULT_LIMIT, a as getControllerScope, b as DEFAULT_TENANT_FIELD, c as createCrudRouter, d as ActionRouterConfig, f as IdempotencyService, g as DEFAULT_ID_FIELD, h as CrudOperation, i as getControllerContext, j as RESERVED_QUERY_PARAMS, k as MUTATION_OPERATIONS, l as createPermissionMiddleware, m as CRUD_OPERATIONS, n as createFastifyHandler, o as sendControllerResponse, p as createActionRouter, r as createRequestContext, s as defineResourceVariants, t as createCrudHandlers, u as ActionHandler, v as DEFAULT_MAX_LIMIT, w as HookOperation, x as DEFAULT_UPDATE_METHOD, y as DEFAULT_SORT } from "../index-BjShrzoj.mjs";
3
+ export { AccessControl, AccessControlConfig, ActionHandler, ActionRouterConfig, BaseController, BaseControllerOptions, BodySanitizer, BodySanitizerConfig, CRUD_OPERATIONS, CrudOperation, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, HOOK_OPERATIONS, HOOK_PHASES, HookOperation, HookPhase, IdempotencyService, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, MutationOperation, QueryResolver, QueryResolverConfig, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, createActionRouter, createCrudHandlers, createCrudRouter, createFastifyHandler, createPermissionMiddleware, createRequestContext, defineResource, defineResourceVariants, getControllerContext, getControllerScope, sendControllerResponse };
@@ -1,5 +1,5 @@
1
1
  import { a as DEFAULT_SORT, c as HOOK_OPERATIONS, d as MAX_REGEX_LENGTH, f as MAX_SEARCH_LENGTH, h as SYSTEM_FIELDS, i as DEFAULT_MAX_LIMIT, l as HOOK_PHASES, m as RESERVED_QUERY_PARAMS, n as DEFAULT_ID_FIELD, o as DEFAULT_TENANT_FIELD, p as MUTATION_OPERATIONS, r as DEFAULT_LIMIT, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS, u as MAX_FILTER_DEPTH } from "../constants-Cxde4rpC.mjs";
2
- import { i as AccessControl, n as QueryResolver, r as BodySanitizer, t as BaseController } from "../BaseController-DzRtluEF.mjs";
3
- import { t as createActionRouter } from "../core-C1XCMtqM.mjs";
4
- import { c as createCrudHandlers, d as getControllerContext, f as getControllerScope, l as createFastifyHandler, n as defineResource, o as createCrudRouter, p as sendControllerResponse, s as createPermissionMiddleware, t as ResourceDefinition, u as createRequestContext } from "../defineResource-wWMBB4GP.mjs";
5
- export { AccessControl, BaseController, BodySanitizer, CRUD_OPERATIONS, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, HOOK_OPERATIONS, HOOK_PHASES, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, QueryResolver, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, createActionRouter, createCrudHandlers, createCrudRouter, createFastifyHandler, createPermissionMiddleware, createRequestContext, defineResource, getControllerContext, getControllerScope, sendControllerResponse };
2
+ import { i as AccessControl, n as QueryResolver, r as BodySanitizer, t as BaseController } from "../BaseController-CpMfCXdn.mjs";
3
+ import { n as createActionRouter, t as defineResourceVariants } from "../core-BWekSEju.mjs";
4
+ import { c as createCrudHandlers, d as getControllerContext, f as getControllerScope, l as createFastifyHandler, n as defineResource, o as createCrudRouter, p as sendControllerResponse, s as createPermissionMiddleware, t as ResourceDefinition, u as createRequestContext } from "../defineResource-DZzyl4a4.mjs";
5
+ export { AccessControl, BaseController, BodySanitizer, CRUD_OPERATIONS, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, HOOK_OPERATIONS, HOOK_PHASES, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, QueryResolver, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, createActionRouter, createCrudHandlers, createCrudRouter, createFastifyHandler, createPermissionMiddleware, createRequestContext, defineResource, defineResourceVariants, getControllerContext, getControllerScope, sendControllerResponse };
@@ -1,3 +1,5 @@
1
+ import { n as normalizePermissionResult, t as applyPermissionResult } from "./applyPermissionResult-D6GPMsvh.mjs";
2
+ import { n as defineResource } from "./defineResource-DZzyl4a4.mjs";
1
3
  //#region src/core/createActionRouter.ts
2
4
  /**
3
5
  * Create action-based state transition endpoint
@@ -103,18 +105,12 @@ function createActionRouter(fastify, config) {
103
105
  error: "Permission denied"
104
106
  });
105
107
  }
106
- if (typeof result === "boolean") {
107
- if (!result) return reply.code(context.user ? 403 : 401).send({
108
- success: false,
109
- error: context.user ? `Permission denied for '${action}'` : "Authentication required"
110
- });
111
- } else {
112
- const permResult = result;
113
- if (!permResult.granted) return reply.code(context.user ? 403 : 401).send({
114
- success: false,
115
- error: permResult.reason ?? (context.user ? `Permission denied for '${action}'` : "Authentication required")
116
- });
117
- }
108
+ const permResult = normalizePermissionResult(result);
109
+ if (!permResult.granted) return reply.code(context.user ? 403 : 401).send({
110
+ success: false,
111
+ error: permResult.reason ?? (context.user ? `Permission denied for '${action}'` : "Authentication required")
112
+ });
113
+ applyPermissionResult(permResult, req);
118
114
  }
119
115
  try {
120
116
  if (idempotencyKey && idempotencyService) {
@@ -182,4 +178,36 @@ function buildActionDescription(actions, actionPermissions) {
182
178
  return lines.join("\n");
183
179
  }
184
180
  //#endregion
185
- export { createActionRouter as t };
181
+ //#region src/core/defineResourceVariants.ts
182
+ /**
183
+ * Define multiple resources from a shared base config and per-variant overrides.
184
+ *
185
+ * Each variant is independently passed through `defineResource()` — the
186
+ * returned `ResourceDefinition`s are real, fully-registered resources.
187
+ * Register each one's plugin in your app:
188
+ *
189
+ * ```typescript
190
+ * await app.register(articlePublic.toPlugin());
191
+ * await app.register(articleAdmin.toPlugin());
192
+ * ```
193
+ *
194
+ * @param base Shared config — adapter, queryParser, schemaOptions, hooks, etc.
195
+ * Must NOT include `name` or `prefix` (those are per-variant).
196
+ * @param variants Map of variant key → override. Each variant must declare
197
+ * its own `name` and `prefix`. Other fields override the base.
198
+ * @returns A record where each key from `variants` maps to a real
199
+ * `ResourceDefinition` ready for `.toPlugin()` registration.
200
+ */
201
+ function defineResourceVariants(base, variants) {
202
+ const out = {};
203
+ for (const key of Object.keys(variants)) {
204
+ const override = variants[key];
205
+ out[key] = defineResource({
206
+ ...base,
207
+ ...override
208
+ });
209
+ }
210
+ return out;
211
+ }
212
+ //#endregion
213
+ export { createActionRouter as n, defineResourceVariants as t };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-BpYLSNr0.mjs";
2
- import { n as PUBLIC_SCOPE } from "./types-BhtYdxZU.mjs";
2
+ import { n as PUBLIC_SCOPE } from "./types-AOD8fxIw.mjs";
3
3
  import Fastify from "fastify";
4
4
  import qs from "qs";
5
5
  //#region src/factory/presets.ts
@@ -73,9 +73,8 @@ const productionPreset = {
73
73
  */
74
74
  function devLoggerConfig() {
75
75
  try {
76
- const req = eval("require") ?? null;
77
- if (req?.resolve) {
78
- req.resolve("pino-pretty");
76
+ if (typeof import.meta?.resolve === "function") {
77
+ import.meta.resolve("pino-pretty");
79
78
  return {
80
79
  level: "debug",
81
80
  transport: {
@@ -208,7 +207,7 @@ async function registerArcCore(fastify, config, trackPlugin) {
208
207
  await fastify.register(arcCorePlugin, { emitEvents: config.arcPlugins?.emitEvents !== false });
209
208
  trackPlugin("arc-core");
210
209
  if (config.arcPlugins?.events !== false) {
211
- const { default: eventPlugin } = await import("./eventPlugin-Ba00swHF.mjs").then((n) => n.n);
210
+ const { default: eventPlugin } = await import("./eventPlugin-B6U_nCFU.mjs").then((n) => n.n);
212
211
  const eventOpts = typeof config.arcPlugins?.events === "object" ? config.arcPlugins.events : {};
213
212
  await fastify.register(eventPlugin, {
214
213
  ...eventOpts,
@@ -244,15 +243,15 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules) {
244
243
  trackPlugin("arc-graceful-shutdown");
245
244
  }
246
245
  if (config.arcPlugins?.caching) {
247
- const { default: cachingPlugin } = await import("./caching-BSXB-Xr7.mjs").then((n) => n.r);
246
+ const { default: cachingPlugin } = await import("./caching-5DtLwIqb.mjs").then((n) => n.r);
248
247
  const opts = config.arcPlugins.caching === true ? {} : config.arcPlugins.caching;
249
248
  await fastify.register(cachingPlugin, opts);
250
249
  trackPlugin("arc-caching", opts);
251
250
  }
252
251
  if (config.arcPlugins?.queryCache) {
253
- const { queryCachePlugin } = await import("./queryCachePlugin-XtFplYO9.mjs").then((n) => n.n);
252
+ const { queryCachePlugin } = await import("./queryCachePlugin-CwTpR04-.mjs").then((n) => n.n);
254
253
  const opts = config.arcPlugins.queryCache === true ? {} : config.arcPlugins.queryCache;
255
- const store = config.stores?.queryCache ?? new (await (import("./memory-BFAYkf8H.mjs").then((n) => n.n))).MemoryCacheStore();
254
+ const store = config.stores?.queryCache ?? new (await (import("./memory-Cp7_cAko.mjs").then((n) => n.n))).MemoryCacheStore();
256
255
  await fastify.register(queryCachePlugin, {
257
256
  store,
258
257
  ...opts
@@ -261,19 +260,19 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules) {
261
260
  }
262
261
  if (config.arcPlugins?.sse) if (config.arcPlugins?.events === false) fastify.log.warn("SSE plugin requires events plugin (arcPlugins.events). SSE disabled.");
263
262
  else {
264
- const { default: ssePlugin } = await import("./sse-BF7GR7IB.mjs").then((n) => n.r);
263
+ const { default: ssePlugin } = await import("./sse-6W0hjVS_.mjs").then((n) => n.r);
265
264
  const opts = config.arcPlugins.sse === true ? {} : config.arcPlugins.sse;
266
265
  await fastify.register(ssePlugin, opts);
267
266
  trackPlugin("arc-sse", opts);
268
267
  }
269
268
  if (config.arcPlugins?.metrics) {
270
- const { default: metricsPlugin } = await import("./metrics-Csh4nsvv.mjs").then((n) => n.r);
269
+ const { default: metricsPlugin } = await import("./metrics-Qnvwc-LQ.mjs").then((n) => n.r);
271
270
  const opts = config.arcPlugins.metrics === true ? {} : config.arcPlugins.metrics;
272
271
  await fastify.register(metricsPlugin, opts);
273
272
  trackPlugin("arc-metrics", opts);
274
273
  }
275
274
  if (config.arcPlugins?.versioning) {
276
- const { default: versioningPlugin } = await import("./versioning-BzfeHmhj.mjs").then((n) => n.r);
275
+ const { default: versioningPlugin } = await import("./versioning-CdBbFefk.mjs").then((n) => n.r);
277
276
  await fastify.register(versioningPlugin, config.arcPlugins.versioning);
278
277
  trackPlugin("arc-versioning", config.arcPlugins.versioning);
279
278
  }
@@ -341,7 +340,7 @@ async function registerAuth(fastify, config, trackPlugin) {
341
340
  */
342
341
  async function registerElevation(fastify, config, trackPlugin) {
343
342
  if (!config.elevation) return;
344
- const { elevationPlugin } = await import("./elevation-BEdACOLB.mjs").then((n) => n.r);
343
+ const { elevationPlugin } = await import("./elevation-By_p2lnn.mjs").then((n) => n.r);
345
344
  await fastify.register(elevationPlugin, config.elevation);
346
345
  trackPlugin("arc-elevation", config.elevation);
347
346
  fastify.log.debug("Elevation plugin enabled");
@@ -351,7 +350,7 @@ async function registerElevation(fastify, config, trackPlugin) {
351
350
  */
352
351
  async function registerErrorHandler(fastify, config, trackPlugin) {
353
352
  if (config.errorHandler === false) return;
354
- const { errorHandlerPlugin } = await import("./errorHandler-r2595m8T.mjs").then((n) => n.n);
353
+ const { errorHandlerPlugin } = await import("./errorHandler-CH8wk1eD.mjs").then((n) => n.n);
355
354
  const errorOpts = typeof config.errorHandler === "object" ? config.errorHandler : { includeStack: config.preset !== "production" };
356
355
  await fastify.register(errorHandlerPlugin, errorOpts);
357
356
  trackPlugin("arc-error-handler", errorOpts);
@@ -668,7 +667,7 @@ function validateDistributedRuntime(options) {
668
667
  */
669
668
  async function createApp(options) {
670
669
  if (options.debug !== void 0 && options.debug !== false) {
671
- const { configureArcLogger } = await import("./logger-Dz3j1ItV.mjs").then((n) => n.r);
670
+ const { configureArcLogger } = await import("./logger-DLg8-Ueg.mjs").then((n) => n.r);
672
671
  configureArcLogger({ debug: options.debug });
673
672
  }
674
673
  validateAuthOptions(options);
@@ -720,6 +719,18 @@ async function createApp(options) {
720
719
  await registerElevation(fastify, config, trackPlugin);
721
720
  await registerErrorHandler(fastify, config, trackPlugin);
722
721
  await registerResources(fastify, config);
722
+ if (config.replyHelpers) {
723
+ const { replyHelpersPlugin } = await import("./replyHelpers-uDUIYh7u.mjs").then((n) => n.n);
724
+ await fastify.register(replyHelpersPlugin);
725
+ }
726
+ if (config.serializeBigInt) fastify.addHook("preSerialization", async (_request, _reply, payload) => {
727
+ if (payload === null || payload === void 0) return payload;
728
+ try {
729
+ return JSON.parse(JSON.stringify(payload, (_key, value) => typeof value === "bigint" ? Number(value) : value));
730
+ } catch {
731
+ return payload;
732
+ }
733
+ });
723
734
  const authMode = config.auth === false ? "none" : config.auth ? config.auth.type : "none";
724
735
  fastify.log.info({
725
736
  preset: config.preset ?? "custom",