@classytic/arc 2.48.0 → 2.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{EventTransport-BWwg5YAU.mjs → EventTransport-DbHZK230.mjs} +2 -2
- package/dist/{HookSystem-B9x-Y_k7.mjs → HookSystem-DMoeJ6Do.mjs} +2 -2
- package/dist/{QueryCache-DdvrGG8Q.d.mts → QueryCache-BE47tmlO.d.mts} +36 -1
- package/dist/{ResourceRegistry-BcvEJoZd.mjs → ResourceRegistry-CP-iTcKy.mjs} +2 -2
- package/dist/{acquire-D2yj6Zzl.mjs → acquire-CB0va87C.mjs} +1 -1
- package/dist/audit/index.d.mts +1 -1
- package/dist/audit/index.mjs +4 -4
- package/dist/auth/audit.mjs +1 -1
- package/dist/auth/index.d.mts +2 -2
- package/dist/auth/index.mjs +53 -15
- package/dist/auth/redis-session.mjs +1 -1
- package/dist/{authorizationDecision-BZSJcPNE.mjs → authorizationDecision-DHO94aV2.mjs} +4 -4
- package/dist/{boundedMap-o2KZDCWy.mjs → boundedMap-C51EUUOm.mjs} +1 -1
- package/dist/{buildHandler-G3k59KY2.mjs → buildHandler-9DuwEKvr.mjs} +23 -16
- package/dist/cache/index.d.mts +2 -2
- package/dist/cache/index.mjs +4 -4
- package/dist/{caching-CJIDPZOv.mjs → caching-COTX3sDa.mjs} +3 -6
- package/dist/{claimed-D0A43wjT.mjs → claimed-C7T1nHlo.mjs} +1 -1
- package/dist/cleanup/index.d.mts +2 -2
- package/dist/cleanup/index.mjs +4 -4
- package/dist/cli/commands/describe.d.mts +1 -1
- package/dist/cli/commands/describe.mjs +3 -3
- package/dist/cli/commands/docs.mjs +3 -3
- package/dist/cli/commands/doctor.mjs +1 -1
- package/dist/cli/commands/generate.mjs +2 -2
- package/dist/cli/commands/init.mjs +2 -2
- package/dist/cli/commands/introspect.mjs +2 -2
- package/dist/cli/index.mjs +3 -3
- package/dist/{constants-D-faL5SX.mjs → constants-DOnfMd7i.mjs} +1 -1
- package/dist/context/index.mjs +5 -5
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +7 -7
- package/dist/{core-NSu1peyq.mjs → core-BoEdFDDw.mjs} +3 -3
- package/dist/{createActionRouter-DTSVv1VK.mjs → createActionRouter-CpTn15dm.mjs} +54 -18
- package/dist/{createAggregationRouter-zEasm-ax.mjs → createAggregationRouter-CD_Hydp0.mjs} +13 -11
- package/dist/{createApp-CjqhkX1x.mjs → createApp-Be6XTGD9.mjs} +332 -40
- package/dist/{createMcpServer-hSFeqRUb.d.mts → createMcpServer-CS2KOVP6.d.mts} +1 -1
- package/dist/{defineAggregation-DH2L6_v9.mjs → defineAggregation-BI5pRb8c.mjs} +1 -1
- package/dist/{defineResource-zYCrhNaN.mjs → defineResource-BAzNu5Um.mjs} +8 -8
- package/dist/discovery/index.mjs +1 -1
- package/dist/docs/index.d.mts +1 -1
- package/dist/docs/index.mjs +3 -3
- package/dist/{elevation-z--rFcZ5.mjs → elevation-DupGuM41.mjs} +6 -9
- package/dist/encryption/index.mjs +3 -3
- package/dist/{errorHandler-3_3oN-Uc.mjs → errorHandler-DA03vRqp.mjs} +4 -7
- package/dist/{errors-DyY48oRi.mjs → errors-BpYV859Y.mjs} +1 -1
- package/dist/{eventPlugin-Co9sABCg.mjs → eventPlugin-D7LYtYzL.mjs} +9 -13
- package/dist/{eventTypes-HmAFyJmJ.mjs → eventTypes-BqA-N-Uz.mjs} +2 -2
- package/dist/events/index.d.mts +18 -5
- package/dist/events/index.mjs +8 -8
- package/dist/events/transports/redis-stream-entry.mjs +4 -4
- package/dist/events/transports/redis.d.mts +35 -0
- package/dist/events/transports/redis.mjs +87 -11
- package/dist/factory/index.d.mts +4 -4
- package/dist/factory/index.mjs +6 -6
- package/dist/{fastify-augmentation-bzkWPt1f.d.mts → fastify-augmentation-baQc3MaO.d.mts} +2 -2
- package/dist/fieldTypes-EFWxCkZ5.mjs +80 -0
- package/dist/{fields-rfsl26Ov.mjs → fields-CT1Erg7o.mjs} +1 -1
- package/dist/{filter-merge-8glLr7Dk.mjs → filter-merge-B1eJ1pMx.mjs} +1 -1
- package/dist/{generate-BOfBueRt.mjs → generate-Cr0ULavs.mjs} +2 -2
- package/dist/{headers-CHSOqpcY.mjs → headers-D4bncIOf.mjs} +2 -2
- package/dist/{health-ezwTHQh2.mjs → health-BoFxrkJE.mjs} +1 -1
- package/dist/{health-DHvAIVmM.mjs → health-DN_pUVMX.mjs} +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/http-cache/index.d.mts +2 -2
- package/dist/http-cache/index.mjs +4 -4
- package/dist/http-cache/purgers/cloudflare.mjs +2 -2
- package/dist/http-cache/purgers/fastly.mjs +2 -2
- package/dist/http-cache/testing/index.mjs +1 -1
- package/dist/idempotency/index.d.mts +1 -1
- package/dist/idempotency/index.mjs +10 -8
- package/dist/idempotency/redis.mjs +2 -2
- package/dist/{index-B5i9-vuP.d.mts → index-CMNpMBtW.d.mts} +1 -1
- package/dist/{index-BxZS-8So.d.mts → index-DKM2p5w5.d.mts} +48 -23
- package/dist/{index-Cy2-QffW.d.mts → index-DLCcLUQT.d.mts} +69 -6
- package/dist/{index-DFCCQ9AE.d.mts → index-DexdFs1a.d.mts} +1 -1
- package/dist/{index-D1X_C_qz.d.mts → index-Dhrks-hM.d.mts} +60 -10
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +11 -11
- package/dist/{init-MoE3eZNR.mjs → init-C4a24wD2.mjs} +1 -1
- package/dist/integrations/event-gateway.mjs +2 -2
- package/dist/integrations/index.d.mts +2 -2
- package/dist/integrations/index.mjs +1 -1
- package/dist/integrations/jobs/index.mjs +3 -3
- package/dist/integrations/mcp/index.d.mts +5 -5
- package/dist/integrations/mcp/index.mjs +2 -2
- package/dist/integrations/mcp/testing.d.mts +2 -2
- package/dist/integrations/mcp/testing.mjs +2 -2
- package/dist/integrations/streamline.mjs +3 -3
- package/dist/integrations/webhooks.d.mts +1 -1
- package/dist/integrations/webhooks.mjs +4 -4
- package/dist/integrations/websocket-pushref-redis.mjs +1 -1
- package/dist/integrations/websocket-redis.mjs +1 -1
- package/dist/integrations/websocket.mjs +2 -2
- package/dist/{jsonBody-DZGiCawf.mjs → jsonBody-DoTt5BS6.mjs} +2 -2
- package/dist/{keys-CrMOZuk6.mjs → keys--l9n7aOC.mjs} +1 -1
- package/dist/{loadResources-CVQvYUhN.mjs → loadResources-rygByIQA.mjs} +3 -3
- package/dist/{loadResourcesFromEntry-D0naccV2.mjs → loadResourcesFromEntry-ItNBIQ5w.mjs} +2 -2
- package/dist/logger/index.mjs +2 -2
- package/dist/{logger-VyMcSmVG.mjs → logger-UbknHqHy.mjs} +1 -1
- package/dist/{mcpPlugin-DQACaqVu.mjs → mcpPlugin-CTkk4RP8.mjs} +29 -26
- package/dist/{memory-Lpfu8Hga.mjs → memory-C47xVsjX.mjs} +3 -3
- package/dist/{metrics-DjVj1sg5.mjs → metrics-TJyAb1Xk.mjs} +4 -7
- package/dist/middleware/index.d.mts +1 -1
- package/dist/middleware/index.mjs +3 -3
- package/dist/migrations/index.mjs +2 -2
- package/dist/{module-BqPJpZ_L.mjs → module-CWiqsXnh.mjs} +1 -1
- package/dist/{multiTenant-KZj8j1uJ.d.mts → multiTenant-QtDzxx_K.d.mts} +1 -1
- package/dist/{multipartBody-BNgNv7r0.mjs → multipartBody-BdG1qbn1.mjs} +1 -1
- package/dist/{observeSend-BKJHibJz.mjs → observeSend-DrA3ADFN.mjs} +1 -1
- package/dist/{openapi-T90KrPR6.mjs → openapi-D6MAbYpv.mjs} +7 -7
- package/dist/outbox-admin/index.d.mts +1 -1
- package/dist/outbox-admin/index.mjs +5 -5
- package/dist/{outbox-module-C874VgBr.mjs → outbox-module-D5QABFQW.mjs} +197 -28
- package/dist/{outbox-module-5Mnwcycy.d.mts → outbox-module-DzW6zwWJ.d.mts} +103 -10
- package/dist/permissions/index.d.mts +2 -2
- package/dist/permissions/index.mjs +7 -7
- package/dist/{permissions-R9T2G1PH.mjs → permissions-CFsmdYUt.mjs} +9 -9
- package/dist/{pipe-DzqbsZy-.mjs → pipe-B_05AgGt.mjs} +2 -2
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/pipeline/index.mjs +2 -2
- package/dist/{plan-C0gkeABY.mjs → plan-BnlNJhrj.mjs} +1 -1
- package/dist/{plugin-BJcVOX5r.mjs → plugin-CrMPYbdj.mjs} +94 -50
- package/dist/plugins/index.d.mts +6 -5
- package/dist/plugins/index.mjs +19 -18
- package/dist/plugins/response-cache.mjs +4 -4
- package/dist/plugins/tracing-entry.mjs +2 -2
- package/dist/{pluralize-CrCpyoZs.mjs → pluralize-oVIxJ4CY.mjs} +1 -1
- package/dist/presets/filesUpload.d.mts +1 -1
- package/dist/presets/filesUpload.mjs +5 -5
- package/dist/presets/index.d.mts +2 -2
- package/dist/presets/index.mjs +2 -2
- package/dist/presets/multiTenant.d.mts +1 -1
- package/dist/presets/multiTenant.mjs +5 -5
- package/dist/presets/search.d.mts +1 -1
- package/dist/presets/search.mjs +2 -2
- package/dist/{presets-CNDvNYsz.mjs → presets-CUd3L7v6.mjs} +4 -4
- package/dist/{projection-CIUe8b59.mjs → projection-DowJlIto.mjs} +2 -2
- package/dist/{purger.types-f83fTzGy.mjs → purger.types-BjKy8869.mjs} +1 -1
- package/dist/{queryCachePlugin-B2jpwFcv.mjs → queryCachePlugin-BvB3k_Fh.mjs} +114 -14
- package/dist/{queryCachePlugin-DYQUyeJ9.d.mts → queryCachePlugin-DrQNnGws.d.mts} +1 -1
- package/dist/{rateLimitKey-BWx-qep0.mjs → rateLimitKey-56nH1cWN.mjs} +1 -1
- package/dist/{realtime-D2tqi3d2.mjs → realtime-DXGBPtYK.mjs} +19 -22
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.mjs +3 -3
- package/dist/{registry-Dl0k6UXy.mjs → registry-Biz-6sEZ.mjs} +2 -2
- package/dist/{relay-ZYvS4xyW.mjs → relay-DEIoMntZ.mjs} +200 -99
- package/dist/{renewingLease-DT4yLb29.mjs → renewingLease-BCJpW9-u.mjs} +1 -1
- package/dist/{replyHelpers-BJFN5AW7.mjs → replyHelpers-DliJNb0-.mjs} +2 -2
- package/dist/{requestContext-Ct5la-SA.mjs → requestContext-tUgLt9Ky.mjs} +1 -1
- package/dist/{requirement-CxDxjB6V.mjs → requirement-0l2DApiQ.mjs} +1 -1
- package/dist/{resourceRateLimit-DCWglD7V.d.mts → resourceRateLimit-BPiESPtG.d.mts} +4 -0
- package/dist/{resourceRateLimit-D1oH2obv.mjs → resourceRateLimit-iSXF8rLH.mjs} +19 -4
- package/dist/{rolldown-runtime-BdTN42uL.mjs → rolldown-runtime-gKJR3o-6.mjs} +1 -1
- package/dist/{routeValidator-DclDl5WJ.mjs → routeValidator-xNYA4rr1.mjs} +47 -5
- package/dist/{runtimeCapabilities-ClWr60El.mjs → runtimeCapabilities-BQK-GrYe.mjs} +1 -1
- package/dist/{schedules-gVkRcs-9.mjs → schedules-D9iMVFhF.mjs} +6 -9
- package/dist/{schemaConverter-CIwB5wPO.mjs → schemaConverter-cIh4oX9a.mjs} +2 -2
- package/dist/{actionPermissions-Dha8sAz2.mjs → schemaIR-BsY4y9VP.mjs} +184 -16
- package/dist/schemas/index.mjs +1 -1
- package/dist/scim/index.mjs +2 -2
- package/dist/scope/index.d.mts +1 -1
- package/dist/scope/index.mjs +5 -5
- package/dist/{scope-VMZhdkbT.mjs → scope-QyhM9w8z.mjs} +4 -4
- package/dist/{shutdown-Bi19vH0z.mjs → shutdown-BM7Q0h4B.mjs} +1 -1
- package/dist/{sse-BqM359f1.mjs → sse-ofvlcTQQ.mjs} +9 -35
- package/dist/sseStats-DQqNN385.d.mts +112 -0
- package/dist/sseStream-BxQW7hPq.mjs +166 -0
- package/dist/{store-helpers-rx-F2ZGR.mjs → store-helpers-_FRhHDyv.mjs} +1 -1
- package/dist/{simpleEqualityMatcher-CaCS09fh.mjs → streamFrames-B3ZJfI02.mjs} +19 -2
- package/dist/{streaming-CPChx3A7.mjs → streaming-HZr63UiM.mjs} +1 -1
- package/dist/{subscriberIdentity-CYNYw8p_.mjs → subscriberIdentity-DSgnoT_D.mjs} +1 -1
- package/dist/{tenancy-BoWImS3K.mjs → tenancy-_ukT0oBt.mjs} +2 -2
- package/dist/{tenantPreparation-oqKCZQZM.mjs → tenantPreparation-DSlQI53c.mjs} +4 -4
- package/dist/testing/cleanupStoreContract.mjs +1 -1
- package/dist/testing/index.d.mts +4 -4
- package/dist/testing/index.mjs +324 -17
- package/dist/testing/outboxStoreContract.mjs +2 -2
- package/dist/testing/requiredPorts.mjs +2 -2
- package/dist/testing/storageContract.mjs +1 -1
- package/dist/{timing-Dsteq59c.mjs → timing-Z8p-Zlw1.mjs} +1 -1
- package/dist/{transactionContext-C1OgH-hW.mjs → transactionContext-DBbSTfY3.mjs} +1 -1
- package/dist/{typeGuards-DNlpASzd.mjs → typeGuards-_6nNQqgq.mjs} +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/storage.mjs +1 -1
- package/dist/{types-DduBiYaI.d.mts → types-B4E0sc6D.d.mts} +2 -2
- package/dist/{types-HFFSwF_K.mjs → types-CrOlZ4rY.mjs} +4 -4
- package/dist/usage/index.d.mts +1 -1
- package/dist/usage/index.mjs +7 -7
- package/dist/{userHelpers-N-k-8dNF.mjs → userHelpers-CBKx3XJN.mjs} +1 -1
- package/dist/utils/index.d.mts +239 -34
- package/dist/utils/index.mjs +13 -13
- package/dist/{utils-C7w_RVlx.mjs → utils--HE8R8sH.mjs} +761 -8
- package/dist/{validate-Brr4b_fH.mjs → validate-BUeE2MLR.mjs} +3 -3
- package/dist/{versioning-S18y2-0C.d.mts → versioning-B07RgD27.d.mts} +2 -13
- package/dist/{versioning-CE5kdWOY.mjs → versioning-qYgqwOhL.mjs} +4 -7
- package/dist/{workScope-A3XBpYTa.mjs → workScope-C-1QHNmV.mjs} +2 -2
- package/llms.txt +2 -2
- package/package.json +34 -34
- package/skills/arc/references/api-reference.md +2 -2
- package/skills/arc/references/auth-better-auth.md +1 -0
- package/skills/arc/references/events-outbox.md +7 -4
- package/skills/arc/references/events.md +2 -2
- package/skills/arc/references/production-api.md +4 -0
- package/skills/arc/references/production-boot.md +2 -0
- package/skills/arc/references/production-idempotency.md +1 -1
- package/skills/arc/references/production-realtime.md +28 -2
- package/skills/arc/references/validation.md +4 -0
- package/skills/arc/references/writes-hooks-errors.md +1 -0
- package/dist/schemaIR-A0IoD05P.mjs +0 -108
- package/dist/sseStream-qSa-F2Qm.mjs +0 -57
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import "./constants-
|
|
4
|
-
import { f as createError, i as NotFoundError, u as ValidationError } from "./errors-
|
|
5
|
-
import {
|
|
6
|
-
import { n as schemaIRToJsonSchemaBranch, t as normalizeSchemaIR } from "./schemaIR-A0IoD05P.mjs";
|
|
1
|
+
/*! @classytic/arc v2.49.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-gKJR3o-6.mjs";
|
|
3
|
+
import "./constants-DOnfMd7i.mjs";
|
|
4
|
+
import { f as createError, i as NotFoundError, u as ValidationError } from "./errors-BpYV859Y.mjs";
|
|
5
|
+
import { D as sendControllerResponse, b as buildAuthMiddlewareForPermissions, c as buildRouteConfig, d as buildActionPipelineHandler, g as buildRouteHooks, l as resolveRouterPluginMw, m as buildActionPermissionMw, o as tryRegisterRoute, p as resolvePipelineSteps, r as schemaIRToJsonSchemaBranch, s as buildRateLimitConfig, t as actionSchemaIR, u as selectPluginMw, v as routeHookOptions, x as buildArcDecorator } from "./schemaIR-BsY4y9VP.mjs";
|
|
7
6
|
// src/core/createActionRouter.ts
|
|
8
|
-
var createActionRouter_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
-
buildActionBodySchema: () => buildActionBodySchema,
|
|
10
|
-
createActionRouter: () => createActionRouter
|
|
11
|
-
});
|
|
7
|
+
var createActionRouter_exports = /* @__PURE__ */ __exportAll({ createActionRouter: () => createActionRouter });
|
|
12
8
|
/**
|
|
13
9
|
* Record a successful action. The actor and organization come from the request's
|
|
14
10
|
* validated scope (`auditContext`); a failed write is logged, never turned into a 500
|
|
@@ -87,6 +83,14 @@ function createActionRouter(fastify, config) {
|
|
|
87
83
|
const subsetSchemas = {};
|
|
88
84
|
for (const name of actionSubset) if (actionSchemas[name]) subsetSchemas[name] = actionSchemas[name];
|
|
89
85
|
const bodySchema = buildActionBodySchema(actionSubset, subsetSchemas);
|
|
86
|
+
const actionDefaults = collectActionDefaults(actionSubset, subsetSchemas);
|
|
87
|
+
const applyActionDefaults = async (req) => {
|
|
88
|
+
const body = req.body;
|
|
89
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return;
|
|
90
|
+
const entries = typeof body.action === "string" ? actionDefaults.get(body.action) : void 0;
|
|
91
|
+
if (!entries) return;
|
|
92
|
+
for (const [key, value] of entries) if (body[key] === void 0) body[key] = typeof value === "object" && value !== null ? structuredClone(value) : value;
|
|
93
|
+
};
|
|
90
94
|
const routeSchema = {
|
|
91
95
|
tags: tag ? [tag] : void 0,
|
|
92
96
|
summary: `Perform action (${actionSubset.join("/")})`,
|
|
@@ -152,6 +156,7 @@ function createActionRouter(fastify, config) {
|
|
|
152
156
|
method: "POST",
|
|
153
157
|
url: urlPath,
|
|
154
158
|
schema: routeSchema,
|
|
159
|
+
...actionDefaults.size > 0 ? { preValidation: [applyActionDefaults] } : {},
|
|
155
160
|
...routeHookOptions(hooks),
|
|
156
161
|
...buildRouteConfig(rateLimitConfig, extensions, void 0, requiredActions.length > 0 ? {
|
|
157
162
|
requiredActions,
|
|
@@ -246,16 +251,29 @@ function createActionRouter(fastify, config) {
|
|
|
246
251
|
* `additionalProperties: false` rejects unknown fields on every host. The full
|
|
247
252
|
* property union stays because a host-supplied `validatorCompiler` may still strip.
|
|
248
253
|
*
|
|
249
|
-
*
|
|
250
|
-
* `
|
|
251
|
-
*
|
|
254
|
+
* NO `default` ANYWHERE AJV WOULD APPLY IT. AJV `useDefaults` ignores defaults
|
|
255
|
+
* inside `oneOf` and applies top-level ones to EVERY body, so a top-level
|
|
256
|
+
* `default` wrote one action's default into every other action's body (a strict
|
|
257
|
+
* action then refused its own valid input). The top level and the branches
|
|
258
|
+
* carry no `default`; the router applies the submitted action's own defaults
|
|
259
|
+
* (`collectActionDefaults`). `keepDefaults` (OpenAPI only) keeps each action's
|
|
260
|
+
* defaults on its own branch, for docs.
|
|
261
|
+
*
|
|
262
|
+
* ARC OWNS `action`. An action schema that declares it (a contracts
|
|
263
|
+
* discriminated-union branch) is read through `actionSchemaIR`, which drops
|
|
264
|
+
* it, so the top-level enum and each branch's `const` stay arc's.
|
|
265
|
+
*
|
|
266
|
+
* Pinned by `tests/core/action-discriminator-strip.test.ts`,
|
|
267
|
+
* `action-strict-schema-parity.test.ts`, `action-default-isolation.test.ts`
|
|
268
|
+
* and `action-schema-declares-discriminator.test.ts`.
|
|
269
|
+
* Exported so OpenAPI and MCP tool generation reuse one shape.
|
|
252
270
|
*/
|
|
253
|
-
function buildActionBodySchema(actionEnum, actionSchemas = {}) {
|
|
271
|
+
function buildActionBodySchema(actionEnum, actionSchemas = {}, options = {}) {
|
|
254
272
|
const unionProperties = {};
|
|
255
273
|
const conflicting = /* @__PURE__ */ new Set();
|
|
256
274
|
const irs = [];
|
|
257
275
|
for (const actionName of actionEnum) {
|
|
258
|
-
const ir =
|
|
276
|
+
const ir = actionSchemaIR(actionSchemas[actionName]);
|
|
259
277
|
irs.push({
|
|
260
278
|
name: actionName,
|
|
261
279
|
ir
|
|
@@ -266,8 +284,8 @@ function buildActionBodySchema(actionEnum, actionSchemas = {}) {
|
|
|
266
284
|
unionProperties[key] = val;
|
|
267
285
|
}
|
|
268
286
|
}
|
|
269
|
-
const topLevelProperties = {
|
|
270
|
-
for (const key of
|
|
287
|
+
const topLevelProperties = {};
|
|
288
|
+
for (const [key, val] of Object.entries(unionProperties)) topLevelProperties[key] = conflicting.has(key) ? {} : withoutDefault(val);
|
|
271
289
|
const branches = [];
|
|
272
290
|
for (const { name, ir } of irs) branches.push(schemaIRToJsonSchemaBranch({
|
|
273
291
|
...ir,
|
|
@@ -281,7 +299,7 @@ function buildActionBodySchema(actionEnum, actionSchemas = {}) {
|
|
|
281
299
|
const: name
|
|
282
300
|
} },
|
|
283
301
|
required: ["action"]
|
|
284
|
-
}));
|
|
302
|
+
}, options.keepDefaults === true));
|
|
285
303
|
return {
|
|
286
304
|
type: "object",
|
|
287
305
|
required: ["action"],
|
|
@@ -295,6 +313,24 @@ function buildActionBodySchema(actionEnum, actionSchemas = {}) {
|
|
|
295
313
|
oneOf: branches
|
|
296
314
|
};
|
|
297
315
|
}
|
|
316
|
+
function withoutDefault(prop) {
|
|
317
|
+
if (!("default" in prop)) return prop;
|
|
318
|
+
const { default: _dropped, ...rest } = prop;
|
|
319
|
+
return rest;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Each action's own top-level `default`s, keyed by action name. The router
|
|
323
|
+
* fills the submitted action's missing fields from this before validation,
|
|
324
|
+
* so a default reaches only the action that declared it.
|
|
325
|
+
*/
|
|
326
|
+
function collectActionDefaults(actionEnum, actionSchemas = {}) {
|
|
327
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
328
|
+
for (const name of actionEnum) {
|
|
329
|
+
const entries = Object.entries(actionSchemaIR(actionSchemas[name]).properties).filter(([, prop]) => typeof prop === "object" && prop !== null && "default" in prop).map(([key, prop]) => [key, prop.default]);
|
|
330
|
+
if (entries.length > 0) defaults.set(name, entries);
|
|
331
|
+
}
|
|
332
|
+
return defaults;
|
|
333
|
+
}
|
|
298
334
|
/**
|
|
299
335
|
* Build OpenAPI description for an action mount from the action map + the
|
|
300
336
|
* permission map for THAT mount's subset. Used by both `/:id/action` and
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import {
|
|
3
|
-
import { u as getRequestScope } from "./types-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
/*! @classytic/arc v2.49.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as evaluateAndApplyPermission } from "./authorizationDecision-DHO94aV2.mjs";
|
|
3
|
+
import { u as getRequestScope } from "./types-CrOlZ4rY.mjs";
|
|
4
|
+
import { f as createError } from "./errors-BpYV859Y.mjs";
|
|
5
|
+
import { g as buildRouteHooks, l as resolveRouterPluginMw, o as tryRegisterRoute, s as buildRateLimitConfig, u as selectPluginMw, v as routeHookOptions, x as buildArcDecorator, y as buildAuthMiddleware } from "./schemaIR-BsY4y9VP.mjs";
|
|
6
|
+
import { t as buildAggregationHandler } from "./buildHandler-9DuwEKvr.mjs";
|
|
7
|
+
import { n as validateAggregations } from "./validate-BUeE2MLR.mjs";
|
|
8
8
|
// src/core/aggregation/createAggregationRouter.ts
|
|
9
9
|
/**
|
|
10
10
|
* Register one Fastify route per aggregation. No-op when the map is
|
|
11
11
|
* empty — same convention `createActionRouter` follows.
|
|
12
12
|
*/
|
|
13
13
|
function createAggregationRouter(fastify, config) {
|
|
14
|
-
const { tag, resourceName, aggregations, fields: fieldPermissions, schemaOptions, permissions: resourcePermissions, routeGuards = [], repository, buildOptions, middlewares = [] } = config;
|
|
14
|
+
const { tag, resourceName, aggregations, fields: fieldPermissions, schemaOptions, permissions: resourcePermissions, routeGuards = [], repository, buildOptions, middlewares = [], fieldTypes } = config;
|
|
15
15
|
if (!aggregations || Object.keys(aggregations).length === 0) return;
|
|
16
16
|
const normalized = validateAggregations(resourceName, aggregations, schemaOptions);
|
|
17
17
|
const arcDecorator = buildArcDecorator({
|
|
@@ -28,7 +28,8 @@ function createAggregationRouter(fastify, config) {
|
|
|
28
28
|
routeGuards,
|
|
29
29
|
repository,
|
|
30
30
|
buildOptions,
|
|
31
|
-
middlewares
|
|
31
|
+
middlewares,
|
|
32
|
+
fieldTypes
|
|
32
33
|
});
|
|
33
34
|
fastify.log?.debug?.({
|
|
34
35
|
aggregations: normalized.map((a) => a.name),
|
|
@@ -36,7 +37,7 @@ function createAggregationRouter(fastify, config) {
|
|
|
36
37
|
}, `[createAggregationRouter] registered ${normalized.length} aggregation route(s)`);
|
|
37
38
|
}
|
|
38
39
|
function registerOne(fastify, normalized, ctx) {
|
|
39
|
-
const { tag, arcDecorator, routeGuards, repository, buildOptions, middlewares } = ctx;
|
|
40
|
+
const { tag, arcDecorator, routeGuards, repository, buildOptions, middlewares, fieldTypes } = ctx;
|
|
40
41
|
const { name } = normalized;
|
|
41
42
|
const config = normalized.base;
|
|
42
43
|
const authMw = buildAuthMiddleware(fastify, config.permissions);
|
|
@@ -61,7 +62,8 @@ function registerOne(fastify, normalized, ctx) {
|
|
|
61
62
|
} : void 0);
|
|
62
63
|
const handler = buildAggregationHandler(normalized, {
|
|
63
64
|
repo: repository,
|
|
64
|
-
buildOptions
|
|
65
|
+
buildOptions,
|
|
66
|
+
...fieldTypes ? { fieldTypes } : {}
|
|
65
67
|
});
|
|
66
68
|
const routeSchema = {
|
|
67
69
|
tags: tag ? [tag] : void 0,
|