@classytic/arc 2.45.2 → 2.46.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/README.md +1 -1
- package/dist/{EventTransport-CiicKz2Z.d.mts → EventTransport-CYEoCJGe.d.mts} +0 -2
- package/dist/{EventTransport-DHb1tpu-.mjs → EventTransport-DNgD9NP4.mjs} +3 -4
- package/dist/{HookSystem-C1u0EUnt.mjs → HookSystem-DRbPzEcP.mjs} +3 -4
- package/dist/{QueryCache--5uAuYPW.d.mts → QueryCache-DdvrGG8Q.d.mts} +1 -3
- package/dist/{ResourceRegistry-D2jXWVN_.mjs → ResourceRegistry-Douk51fa.mjs} +15 -4
- package/dist/{acquire-DTkA8Lme.mjs → acquire-RbtvDg9s.mjs} +2 -3
- package/dist/{actionPermissions-DRVk6m7x.mjs → actionPermissions-De0AJ7hm.mjs} +37 -42
- package/dist/audit/index.d.mts +2 -10
- package/dist/audit/index.mjs +8 -12
- package/dist/auth/audit.d.mts +0 -2
- package/dist/auth/audit.mjs +2 -3
- package/dist/auth/index.d.mts +9 -17
- package/dist/auth/index.mjs +26 -29
- package/dist/auth/redis-session.d.mts +2 -4
- package/dist/auth/redis-session.mjs +2 -3
- package/dist/{authorizationDecision-D48fUJv1.mjs → authorizationDecision-DeZMrHcm.mjs} +5 -6
- package/dist/{base-CZyixEQR.d.mts → base-HXNgPQww.d.mts} +1 -7
- package/dist/{boundedMap-DkKiPifd.mjs → boundedMap-2WBh3gM9.mjs} +2 -3
- package/dist/{buildHandler-BiZ4VATS.mjs → buildHandler-DxVOOBpw.mjs} +5 -6
- package/dist/cache/index.d.mts +4 -10
- package/dist/cache/index.mjs +5 -6
- package/dist/{caching-Cj0as-P1.mjs → caching-BYRwYrUo.mjs} +3 -4
- package/dist/{claimed-ChI13rUR.mjs → claimed-DYlELdnm.mjs} +2 -3
- package/dist/cleanup/index.d.mts +4 -18
- package/dist/cleanup/index.mjs +12 -20
- package/dist/cli/commands/describe.d.mts +1 -3
- package/dist/cli/commands/describe.mjs +4 -5
- package/dist/cli/commands/docs.d.mts +1 -3
- package/dist/cli/commands/docs.mjs +4 -5
- package/dist/cli/commands/doctor.d.mts +1 -3
- package/dist/cli/commands/doctor.mjs +2 -3
- package/dist/cli/commands/generate.d.mts +1 -1
- package/dist/cli/commands/generate.mjs +2 -2
- package/dist/cli/commands/init.d.mts +1 -1
- package/dist/cli/commands/init.mjs +2 -2
- package/dist/cli/commands/introspect.d.mts +1 -3
- package/dist/cli/commands/introspect.mjs +3 -4
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.mjs +3 -3
- package/dist/{constants-D_aiew34.mjs → constants-CHZMUwBW.mjs} +2 -3
- package/dist/context/index.d.mts +0 -8
- package/dist/context/index.mjs +6 -7
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +8 -8
- package/dist/{core-QIZ2560Y.mjs → core-D9rS2BxO.mjs} +9 -12
- package/dist/{createActionRouter-CvH84dyx.mjs → createActionRouter-0qkCRzTL.mjs} +7 -8
- package/dist/{createAggregationRouter-DGyK2Hp6.mjs → createAggregationRouter-CUf5Esd9.mjs} +9 -10
- package/dist/{createApp-CKjZpmq9.mjs → createApp-DZIXfDKD.mjs} +49 -62
- package/dist/{createMcpServer-DSztofa9.d.mts → createMcpServer-DeVpqQF-.d.mts} +1 -3
- package/dist/{defineAggregation-BLza7Ca4.mjs → defineAggregation-bmKQ4NmC.mjs} +2 -3
- package/dist/{defineResource-CEo0gDCb.mjs → defineResource-CGmdmGwh.mjs} +78 -29
- package/dist/discovery/index.d.mts +1 -3
- package/dist/discovery/index.mjs +2 -3
- package/dist/docs/index.d.mts +8 -8
- package/dist/docs/index.mjs +4 -5
- package/dist/{elevation-BJTsSnke.mjs → elevation-CzhqAyVN.mjs} +9 -10
- package/dist/{elevation-BW2J3tNj.d.mts → elevation-DPD0hcU-.d.mts} +0 -2
- package/dist/encryption/index.d.mts +1 -7
- package/dist/encryption/index.mjs +8 -13
- package/dist/{errorHandler--4rSMMvq.d.mts → errorHandler-B9r88jZV.d.mts} +8 -3
- package/dist/{errorHandler-2p4SL5zm.mjs → errorHandler-dFyGOEoB.mjs} +16 -6
- package/dist/{errors-grZkIA8N.mjs → errors-BY8vzlP4.mjs} +2 -3
- package/dist/{errors-JYc9vwqE.d.mts → errors-DTo0me1o.d.mts} +0 -2
- package/dist/{eventPlugin-BtmA4-3P.d.mts → eventPlugin-BY38F6yK.d.mts} +1 -7
- package/dist/{eventPlugin-ItcYBGUs.mjs → eventPlugin-eMhAPtQA.mjs} +10 -12
- package/dist/{eventTypes-Ck6fD3ne.mjs → eventTypes-Do2KYeJx.mjs} +5 -8
- package/dist/events/index.d.mts +4 -16
- package/dist/events/index.mjs +8 -9
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +5 -6
- package/dist/events/transports/redis.d.mts +2 -4
- package/dist/events/transports/redis.mjs +3 -4
- package/dist/{externalPaths-CmGOxOtD.d.mts → externalPaths-BOqdq5wr.d.mts} +0 -2
- package/dist/factory/index.d.mts +4 -14
- package/dist/factory/index.mjs +12 -18
- package/dist/{fastify-augmentation-DRlCIWE9.d.mts → fastify-augmentation-Dtn0IIRn.d.mts} +4 -10
- package/dist/{fields-BBSpf8pS.d.mts → fields-JTkrtO-r.d.mts} +0 -2
- package/dist/{fields-BRX0Krcj.mjs → fields-LnbCcvsw.mjs} +2 -3
- package/dist/{filter-merge-CDc7YMwX.mjs → filter-merge-BAWi019Q.mjs} +2 -3
- package/dist/{generate-DCGuEbqI.d.mts → generate-C-g_KOkV.d.mts} +0 -4
- package/dist/{generate-hvg7V2g1.mjs → generate-oXoDnpJf.mjs} +7 -12
- package/dist/{headers-Cqkg4LzI.mjs → headers-DBd3Qheo.mjs} +3 -4
- package/dist/{health-PVt0VjOx.mjs → health-BlJu9GXS.mjs} +2 -3
- package/dist/{health-DyeP3mTW.mjs → health-Dp-3EC9o.mjs} +4 -7
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/idempotency/index.d.mts +3 -9
- package/dist/idempotency/index.mjs +10 -13
- package/dist/idempotency/redis.d.mts +1 -1
- package/dist/idempotency/redis.mjs +3 -4
- package/dist/{index-Bxriq3so.d.mts → index-B5i9-vuP.d.mts} +4 -26
- package/dist/{index-Chgz3d0i.d.mts → index-BAXDo5eE.d.mts} +1 -7
- package/dist/{index-Beg3aNnK.d.mts → index-BTxzJ_MN.d.mts} +67 -25
- package/dist/{index-CUJvoyw3.d.mts → index-Bqfo8hLz.d.mts} +2 -24
- package/dist/{index-uhkUA5-U.d.mts → index-CUdaoCYt.d.mts} +13 -23
- package/dist/{index-WH7xgvxS.d.mts → index-DyJFTJLA.d.mts} +31 -92
- package/dist/index.d.mts +7 -9
- package/dist/index.mjs +12 -13
- package/dist/{init-jC3rMPzb.mjs → init-BOaNkLYb.mjs} +18 -35
- package/dist/{init-Cscs4lab.d.mts → init-CV2_Fw3H.d.mts} +0 -4
- package/dist/integrations/event-gateway.d.mts +3 -5
- package/dist/integrations/event-gateway.mjs +3 -4
- package/dist/integrations/index.d.mts +3 -3
- package/dist/integrations/index.mjs +1 -1
- package/dist/integrations/jobs/index.d.mts +1 -1
- package/dist/integrations/jobs/index.mjs +7 -11
- package/dist/integrations/mcp/index.d.mts +7 -39
- package/dist/integrations/mcp/index.mjs +8 -14
- package/dist/integrations/mcp/testing.d.mts +3 -5
- package/dist/integrations/mcp/testing.mjs +3 -4
- package/dist/integrations/streamline.d.mts +1 -3
- package/dist/integrations/streamline.mjs +4 -5
- package/dist/integrations/webhooks.d.mts +2 -4
- package/dist/integrations/webhooks.mjs +4 -5
- package/dist/integrations/websocket-pushref-redis.d.mts +2 -4
- package/dist/integrations/websocket-pushref-redis.mjs +2 -3
- package/dist/integrations/websocket-redis.d.mts +2 -4
- package/dist/integrations/websocket-redis.mjs +2 -3
- package/dist/integrations/websocket.d.mts +2 -2
- package/dist/integrations/websocket.mjs +13 -24
- package/dist/{interface-JJzwH4Ro.d.mts → interface-BmExzQRD.d.mts} +0 -2
- package/dist/{interface-BOk3YnTz.d.mts → interface-WR1U0K7t.d.mts} +0 -2
- package/dist/{jsonBody-ptwyzZQ-.mjs → jsonBody-DpRpKR_K.mjs} +3 -4
- package/dist/{keys-C1vFuSbv.mjs → keys-FBz6Ull-.mjs} +2 -3
- package/dist/{loadResources-CHPDyIPn.mjs → loadResources-Bx1sKPnF.mjs} +4 -5
- package/dist/{loadResourcesFromEntry-BkHHTu_B.mjs → loadResourcesFromEntry-b_jcqbxh.mjs} +3 -4
- package/dist/logger/index.d.mts +1 -3
- package/dist/logger/index.mjs +2 -2
- package/dist/{logger-C5bvCiAK.mjs → logger-CbFcIEBZ.mjs} +3 -5
- package/dist/{mcpPlugin-C9qohJCF.mjs → mcpPlugin-yix548XX.mjs} +41 -60
- package/dist/{memory-CxiTwT0j.mjs → memory-Bgw5dn8N.mjs} +4 -5
- package/dist/{metrics-Ckp2zRy-.mjs → metrics-CZDQWVjS.mjs} +4 -5
- package/dist/middleware/index.d.mts +1 -5
- package/dist/middleware/index.mjs +4 -5
- package/dist/migrations/index.d.mts +0 -2
- package/dist/migrations/index.mjs +3 -4
- package/dist/{module-CfnKuIuH.mjs → module-Dsc_nKL5.mjs} +2 -3
- package/dist/{multiTenant-CAtYlW6H.d.mts → multiTenant-XCxAUlru.d.mts} +1 -5
- package/dist/{multipartBody-BFasGtP9.mjs → multipartBody-B85ek8Kj.mjs} +2 -3
- package/dist/observeSend-BK-JN1jK.mjs +20 -0
- package/dist/{openapi-DAPxjYHX.mjs → openapi-Co7hl073.mjs} +18 -28
- package/dist/outbox-admin/index.d.mts +2 -4
- package/dist/outbox-admin/index.mjs +6 -7
- package/dist/{outbox-module-gZCHoE4H.d.mts → outbox-module-XvUThpqn.d.mts} +2 -8
- package/dist/{outbox-module-B4FAkx3A.mjs → outbox-module-mg9kDYkd.mjs} +13 -17
- package/dist/permissions/index.d.mts +4 -4
- package/dist/permissions/index.mjs +7 -7
- package/dist/{permissions-B14c3OMp.mjs → permissions-A1oKtpiC.mjs} +19 -29
- package/dist/{pipe-CQv7PsAK.mjs → pipe-Czpw9U2n.mjs} +3 -4
- package/dist/pipeline/index.d.mts +1 -9
- package/dist/pipeline/index.mjs +5 -8
- package/dist/{plan-CpnTykjb.mjs → plan-KVseuBCL.mjs} +5 -9
- package/dist/{plugin-DXTjVg_Q.mjs → plugin-DTWt_8C3.mjs} +130 -62
- package/dist/plugins/index.d.mts +8 -16
- package/dist/plugins/index.mjs +22 -26
- package/dist/plugins/response-cache.d.mts +2 -4
- package/dist/plugins/response-cache.mjs +10 -10
- package/dist/plugins/tracing-entry.d.mts +1 -1
- package/dist/plugins/tracing-entry.mjs +3 -4
- package/dist/{pluralize-C3VJKRGp.mjs → pluralize-msB9X3yw.mjs} +2 -3
- package/dist/presets/filesUpload.d.mts +4 -6
- package/dist/presets/filesUpload.mjs +6 -7
- package/dist/presets/index.d.mts +3 -19
- package/dist/presets/index.mjs +2 -2
- package/dist/presets/multiTenant.d.mts +1 -1
- package/dist/presets/multiTenant.mjs +7 -7
- package/dist/presets/search.d.mts +3 -5
- package/dist/presets/search.mjs +3 -4
- package/dist/{presets-CquqYJPy.mjs → presets-qKCehiJM.mjs} +11 -18
- package/dist/{projection-CgfSLOSM.mjs → projection-ClBqtsIw.mjs} +3 -4
- package/dist/{pushref-registry-UxCkoA4C.d.mts → pushref-registry-d86QUaSq.d.mts} +0 -6
- package/dist/{queryCachePlugin-D0HUISHJ.mjs → queryCachePlugin-3gJj5Rbz.mjs} +8 -10
- package/dist/{queryCachePlugin-C2lZjTxk.d.mts → queryCachePlugin-DYQUyeJ9.d.mts} +2 -4
- package/dist/{rateLimitKey-AvkBOMkl.mjs → rateLimitKey-Kro---xl.mjs} +2 -3
- package/dist/{realtime-CbWtVbqK.mjs → realtime-Ber8uJN2.mjs} +17 -19
- package/dist/{redis-BDgv9Glw.d.mts → redis-RpDMemdm.d.mts} +2 -4
- package/dist/{redis-stream-BMk-bpQS.d.mts → redis-stream-CS1N9dwM.d.mts} +1 -3
- package/dist/{redisShapes-CQksY67q.d.mts → redisShapes-CqBXTn_s.d.mts} +0 -2
- package/dist/registry/index.d.mts +2 -12
- package/dist/registry/index.mjs +3 -3
- package/dist/{registry-BVwpAuFI.mjs → registry-BA-_vFYk.mjs} +7 -12
- package/dist/{renewingLease-CykpeNcQ.mjs → renewingLease-CMY8YOcc.mjs} +2 -3
- package/dist/{replyHelpers-DA51IZio.mjs → replyHelpers-DK9P_XSz.mjs} +3 -4
- package/dist/{requestContext-DIWHKDtQ.mjs → requestContext-GYO_0gEw.mjs} +2 -3
- package/dist/{requirement-CbiLdQ1n.d.mts → requirement-CTRQjjQx.d.mts} +0 -2
- package/dist/{requirement-Cp_fsMDL.mjs → requirement-DeNjZIH3.mjs} +2 -3
- package/dist/{resourceRateLimit-Wf6d6FL9.d.mts → resourceRateLimit-DCWglD7V.d.mts} +1 -3
- package/dist/{resourceRateLimit-BFuluodF.mjs → resourceRateLimit-tHLbrtWc.mjs} +3 -4
- package/dist/{rolldown-runtime-D_lMdYOd.mjs → rolldown-runtime-Kv1fZdLg.mjs} +2 -3
- package/dist/{routeValidator-DuLonYwr.mjs → routeValidator-C_H5NanI.mjs} +2 -3
- package/dist/{runtimeCapabilities-CydRfm0i.mjs → runtimeCapabilities-DWqbxkyw.mjs} +2 -3
- package/dist/{schedules-B693KXxa.mjs → schedules-eO_RzhCU.mjs} +132 -9
- package/dist/{schemaConverter-DNvZWTV6.mjs → schemaConverter-DBJrPZN4.mjs} +3 -4
- package/dist/{schemaIR-REV2y7Wd.mjs → schemaIR-CEScKT2v.mjs} +3 -4
- package/dist/schemas/index.d.mts +0 -2
- package/dist/schemas/index.mjs +2 -3
- package/dist/scim/index.d.mts +0 -12
- package/dist/scim/index.mjs +10 -18
- package/dist/scope/index.d.mts +2 -6
- package/dist/scope/index.mjs +5 -5
- package/dist/{scope-Bevxy_ST.mjs → scope-B-Sm9m_E.mjs} +5 -6
- package/dist/{sessionManager-qimlKV0P.d.mts → sessionManager-CdvDF04x.d.mts} +2 -4
- package/dist/{shutdown-CfrqPR7A.mjs → shutdown-DzLFbe27.mjs} +2 -3
- package/dist/{simpleEqualityMatcher-BJwfuRKP.mjs → simpleEqualityMatcher-DOJhwQ8g.mjs} +2 -3
- package/dist/{sse-CuNNWr2z.mjs → sse-2972pVwV.mjs} +8 -9
- package/dist/{sseStream-C_2ujAVY.mjs → sseStream-AWLEeNV-.mjs} +3 -4
- package/dist/{storage-Cx9Sz3Ou.d.mts → storage-odC5MNKN.d.mts} +0 -2
- package/dist/{store-helpers-C8uBGCbb.mjs → store-helpers-VzjgVTkM.mjs} +2 -3
- package/dist/{streaming-Bdq_M4d5.mjs → streaming-DvraWW6x.mjs} +2 -3
- package/dist/{subscriberIdentity-B-KpZkdl.mjs → subscriberIdentity-Bya56jsg.mjs} +2 -3
- package/dist/{tenancy-C5PCvm1h.mjs → tenancy-DSa_0hhw.mjs} +3 -4
- package/dist/{tenantPreparation-dYvWrgNa.mjs → tenantPreparation-BrpkQre3.mjs} +5 -6
- package/dist/testing/cleanupStoreContract.d.mts +2 -4
- package/dist/testing/cleanupStoreContract.mjs +2 -3
- package/dist/testing/index.d.mts +6 -32
- package/dist/testing/index.mjs +24 -37
- package/dist/testing/outboxStoreContract.d.mts +1 -3
- package/dist/testing/outboxStoreContract.mjs +3 -4
- package/dist/testing/requiredPorts.d.mts +2 -4
- package/dist/testing/requiredPorts.mjs +3 -4
- package/dist/testing/storageContract.d.mts +2 -4
- package/dist/testing/storageContract.mjs +2 -3
- package/dist/{timing-DCqsezX8.mjs → timing-6rQTuCwg.mjs} +3 -5
- package/dist/{tracing-Dro5eH6j.d.mts → tracing-JSFiBl5r.d.mts} +0 -2
- package/dist/{transactionContext-DrcNyjpv.mjs → transactionContext-DaxYUEgH.mjs} +2 -3
- package/dist/{typeGuards-CEl10KPy.mjs → typeGuards-UKnX8wPX.mjs} +2 -3
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.mjs +1 -1
- package/dist/types/storage.d.mts +1 -1
- package/dist/types/storage.mjs +1 -1
- package/dist/{types-ByHn9rEO.d.mts → types-0Dqlbgn8.d.mts} +0 -2
- package/dist/{types-D3Ixsh00.d.mts → types-BYEb_dLW.d.mts} +2 -4
- package/dist/{types-BJ-2XqVF.d.mts → types-BeEJm-DV.d.mts} +114 -14
- package/dist/{types-DVLddu2q.d.mts → types-C0YJAiL0.d.mts} +0 -2
- package/dist/{types-D9NWjpYc.mjs → types-CuGjhn83.mjs} +5 -6
- package/dist/{types-Ddl9OjmE.d.mts → types-DnkIALZ8.d.mts} +0 -4
- package/dist/usage/index.d.mts +2 -10
- package/dist/usage/index.mjs +8 -12
- package/dist/{userHelpers-BHig1kHq.mjs → userHelpers-oX5_mOVs.mjs} +2 -3
- package/dist/utils/index.d.mts +5 -39
- package/dist/utils/index.mjs +12 -12
- package/dist/{utils-BG5P7_Vb.mjs → utils-CjjGOT4E.mjs} +20 -30
- package/dist/{validate-D_mdOCir.mjs → validate-4RlTKOJb.mjs} +5 -7
- package/dist/{versioning-DBGHjPh7.mjs → versioning-Dk2-19La.mjs} +4 -5
- package/dist/{versioning-Bqm_57Qt.d.mts → versioning-S18y2-0C.d.mts} +1 -15
- package/dist/{websocket-Cs4awVyD.d.mts → websocket-BGuc-WVZ.d.mts} +1 -15
- package/dist/{workScope-DPPfM4m6.mjs → workScope-DoBsoVo4.mjs} +3 -4
- package/llms.txt +37 -30
- package/package.json +9 -8
- package/skills/arc/SKILL.md +65 -844
- package/skills/arc/references/agent-auth.md +82 -193
- package/skills/arc/references/api-reference.md +41 -245
- package/skills/arc/references/auth-api-keys.md +99 -0
- package/skills/arc/references/auth-better-auth-overlay.md +87 -0
- package/skills/arc/references/auth-better-auth.md +78 -0
- package/skills/arc/references/auth-permissions.md +100 -0
- package/skills/arc/references/auth-strategies.md +122 -0
- package/skills/arc/references/boot.md +80 -0
- package/skills/arc/references/enterprise-auth.md +65 -81
- package/skills/arc/references/events-outbox.md +90 -0
- package/skills/arc/references/events.md +75 -440
- package/skills/arc/references/integrations-jobs.md +74 -0
- package/skills/arc/references/integrations-realtime.md +84 -0
- package/skills/arc/references/integrations-webhooks.md +71 -0
- package/skills/arc/references/integrations-workflows.md +47 -0
- package/skills/arc/references/mcp-auth.md +83 -0
- package/skills/arc/references/mcp-custom-tools.md +125 -0
- package/skills/arc/references/mcp-setup.md +115 -0
- package/skills/arc/references/mcp-testing.md +63 -0
- package/skills/arc/references/multi-tenancy.md +56 -230
- package/skills/arc/references/permissions-scope.md +81 -0
- package/skills/arc/references/production-api.md +119 -0
- package/skills/arc/references/production-audit.md +101 -0
- package/skills/arc/references/production-boot.md +91 -0
- package/skills/arc/references/production-caching.md +63 -0
- package/skills/arc/references/production-distributed.md +75 -0
- package/skills/arc/references/production-idempotency.md +83 -0
- package/skills/arc/references/production-observability.md +83 -0
- package/skills/arc/references/production-realtime.md +70 -0
- package/skills/arc/references/production-reliability.md +100 -0
- package/skills/arc/references/production-shutdown.md +43 -0
- package/skills/arc/references/querying.md +76 -0
- package/skills/arc/references/resources.md +97 -0
- package/skills/arc/references/schedules.md +79 -0
- package/skills/arc/references/scim.md +61 -208
- package/skills/arc/references/tenancy-scope-install.md +82 -0
- package/skills/arc/references/testing.md +101 -144
- package/skills/arc/references/usage-cleanup-capabilities.md +45 -0
- package/skills/arc/references/validation.md +91 -0
- package/skills/arc/references/writes-hooks-errors.md +80 -0
- package/skills/arc-code-review/SKILL.md +67 -114
- package/skills/arc-code-review/references/arc-cheatsheet.md +68 -167
- package/skills/arc-code-review/references/mongokit-repositories.md +104 -0
- package/skills/arc-code-review/references/recipe-events-cache-jobs.md +112 -0
- package/skills/arc-code-review/references/recipe-resource.md +100 -0
- package/skills/arc-code-review/references/recipe-schemas-fields.md +93 -0
- package/skills/arc-code-review/references/recipe-scope-permissions.md +82 -0
- package/skills/arc-code-review/references/scaffolding.md +61 -198
- package/skills/arc-code-review/references/severity.md +49 -102
- package/skills/arc-code-review/references/smells-auth-scope.md +80 -0
- package/skills/arc-code-review/references/smells-data-events.md +66 -0
- package/skills/arc-code-review/references/smells-imports-style.md +59 -0
- package/skills/arc-code-review/references/smells-platform.md +89 -0
- package/skills/arc-code-review/references/smells-routes-schemas.md +66 -0
- package/skills/arc-module-publishing/SKILL.md +82 -208
- package/skills/arc-module-publishing/references/action-presets-and-plugins.md +87 -0
- package/skills/arc-module-publishing/references/build-and-types.md +73 -0
- package/skills/arc-module-publishing/references/module-lifecycle.md +101 -0
- package/skills/arc-module-publishing/references/package-manifest.md +34 -122
- package/skills/arc-module-publishing/references/publishing-workflow.md +44 -140
- package/skills/arc-module-publishing/references/resource-assembly.md +102 -0
- package/skills/arc-module-publishing/references/testing-packages.md +82 -0
- package/skills/arc/references/auth.md +0 -729
- package/skills/arc/references/integrations.md +0 -452
- package/skills/arc/references/mcp.md +0 -691
- package/skills/arc/references/production.md +0 -835
- package/skills/arc-code-review/references/anti-patterns.md +0 -1008
- package/skills/arc-code-review/references/migration-recipes.md +0 -649
- package/skills/arc-code-review/references/mongokit-migration.md +0 -360
- package/skills/arc-module-publishing/references/authoring-modules.md +0 -327
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Recipe: events, cache, schedules, idempotency, MCP
|
|
2
|
+
|
|
3
|
+
## Events
|
|
4
|
+
|
|
5
|
+
Before: `await eventBus.emit("order.created", ...)` in POST, forgotten in PATCH.
|
|
6
|
+
After: nothing. Arc emits `order.created`, `order.updated`, `order.deleted` after every CRUD write (`arcPlugins.emitEvents` defaults on). Subscribe through module `eventHandlers` or `fastify.events`. Types: `@classytic/primitives/events`. At-least-once delivery: `EventOutbox` and `createOutboxModule` from `@classytic/arc/events` with an outbox store (`repositoryAsOutboxStore`); verify a store with `runOutboxStoreContract` from `@classytic/arc/testing/outbox`. Use `RedisStreamTransport` from `@classytic/arc/events/redis-stream` for a durable transport with consumer groups.
|
|
7
|
+
|
|
8
|
+
## Cache
|
|
9
|
+
|
|
10
|
+
Before: `redis.get("products-list")`, `redis.del("products-list")` after writes.
|
|
11
|
+
After:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
const app = await createApp({
|
|
15
|
+
arcPlugins: { queryCache: true },
|
|
16
|
+
stores: { queryCache: new RedisCacheStore({ client }) },
|
|
17
|
+
resources: [productResource],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
defineResource({
|
|
21
|
+
name: "product",
|
|
22
|
+
adapter,
|
|
23
|
+
cache: { staleTime: 30, gcTime: 300, tags: ["catalog"], invalidateOn: { "category.*": ["catalog"] } },
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Writes bump the resource version; the next read sees fresh data. `RedisCacheStore` is from `@classytic/arc/cache`; omit `stores.queryCache` for the in-memory default.
|
|
28
|
+
|
|
29
|
+
## Recurring jobs
|
|
30
|
+
|
|
31
|
+
Interval job with multi-replica safety:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { schedulesPlugin } from "@classytic/arc/plugins";
|
|
35
|
+
import { createMongoLockAdapter } from "@classytic/mongokit/lock";
|
|
36
|
+
|
|
37
|
+
await app.register(schedulesPlugin, {
|
|
38
|
+
lock: createMongoLockAdapter({ connection }),
|
|
39
|
+
schedules: [{ name: "outbox-sweep", every: 30_000, jitterMs: 5_000, handler: async (f) => sweep(f) }],
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Once per local day (replaces timers plus marker rows):
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
schedules: [{
|
|
47
|
+
name: "daily-digest",
|
|
48
|
+
every: 60_000,
|
|
49
|
+
daily: { hour: 8, minute: 30, zone: "Asia/Dhaka", ledger: dailyLedger },
|
|
50
|
+
handler: async (f, ctx) => sendDigest(f, ctx?.day), // ctx.day is YYYY-MM-DD in that zone
|
|
51
|
+
}],
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The host implements `DailyLedger` once, in a repository file. `claimDay` must be atomic across replicas: a unique index on `(key, civilDate)`, losing insert returns `false`.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import type { DailyLedger } from "@classytic/arc/plugins";
|
|
58
|
+
import { isDuplicateKeyError } from "@classytic/mongokit";
|
|
59
|
+
|
|
60
|
+
export const dailyLedger: DailyLedger = {
|
|
61
|
+
async claimDay(key, civilDate) {
|
|
62
|
+
try {
|
|
63
|
+
await LedgerModel.create({ key, civilDate });
|
|
64
|
+
return true;
|
|
65
|
+
} catch (err) {
|
|
66
|
+
if (isDuplicateKeyError(err)) return false;
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
async releaseDay(key, civilDate) {
|
|
71
|
+
await LedgerModel.deleteOne({ key, civilDate });
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Tests use `createMemoryDailyLedger()` and an injected `clock`. Optional knobs: `catchUpWindowMs`, `staleAfterMs`, `completeDay`. A module ships its jobs as `scheduledJobs`; locking is configured in `arcPlugins.schedules`. Calendar cron expressions and durable retries stay in `jobsPlugin` from `@classytic/arc/integrations/jobs`.
|
|
77
|
+
|
|
78
|
+
## Idempotency
|
|
79
|
+
|
|
80
|
+
Before: `Idempotency.findOne({ key })` inside the handler.
|
|
81
|
+
After:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { idempotencyPlugin } from "@classytic/arc/idempotency";
|
|
85
|
+
|
|
86
|
+
await app.register(idempotencyPlugin, { repository: idempotencyRepo, ttlMs: 24 * 3600_000 });
|
|
87
|
+
defineResource({ name: "payment", adapter, idempotency: { required: ["create"] } });
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
A keyless create then answers 400 `arc.idempotency_key_required`, a keyed retry replays the stored response. The repository needs `getOne`, `deleteMany`, `findOneAndUpdate`; mongokit's `createIdempotencyStore` (`@classytic/mongokit/idempotency`) provides a ready store.
|
|
91
|
+
|
|
92
|
+
## MCP
|
|
93
|
+
|
|
94
|
+
Before: 200 lines of `setRequestHandler(CallToolRequestSchema, ...)`.
|
|
95
|
+
After:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { mcpPlugin } from "@classytic/arc/mcp";
|
|
99
|
+
|
|
100
|
+
await app.register(mcpPlugin, { resources: [productResource, orderResource], auth: false });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
CRUD, custom routes and actions become tools; permissions and field rules carry over. `mcp: false` on a resource opts it out.
|
|
104
|
+
|
|
105
|
+
## Tests
|
|
106
|
+
|
|
107
|
+
Before: hand-started `MongoMemoryServer`, hand-built auth headers.
|
|
108
|
+
After: `createTestApp` and `expectArc` from `@classytic/arc/testing`; `createHttpTestHarness(resource)` generates CRUD, permission and validation tests; module packages use `bootModuleApp`.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
const ctx = await createTestApp({ resources: [productResource], authMode: "jwt", connectMongoose: true });
|
|
112
|
+
```
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Recipe: hand-rolled CRUD to `defineResource`
|
|
2
|
+
|
|
3
|
+
## Before (about 170 lines per entity)
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
fastify.get("/products", async (req) => {
|
|
7
|
+
const page = Math.max(1, Number(req.query.page) || 1);
|
|
8
|
+
const filters: any = {};
|
|
9
|
+
if (req.query.status) filters.status = req.query.status;
|
|
10
|
+
if (req.user) filters.organizationId = req.user.orgId;
|
|
11
|
+
const items = await Product.find(filters).skip((page - 1) * 20).limit(20).lean();
|
|
12
|
+
return { items, total: await Product.countDocuments(filters), page };
|
|
13
|
+
});
|
|
14
|
+
fastify.post("/products", async (req, reply) => {
|
|
15
|
+
if (!req.user?.roles.includes("admin")) throw fastify.httpErrors.forbidden();
|
|
16
|
+
const data = createBody.parse(req.body);
|
|
17
|
+
const item = await Product.create({ ...data, organizationId: req.user.orgId });
|
|
18
|
+
await fastify.events.emit("product.created", { id: item._id });
|
|
19
|
+
return reply.code(201).send(item);
|
|
20
|
+
});
|
|
21
|
+
// plus GET /:id, PATCH /:id, DELETE /:id with the same glue
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## After (about 30 lines)
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { defineResource, allowPublic, requireRoles } from "@classytic/arc";
|
|
28
|
+
import { crudInput } from "@classytic/arc/core";
|
|
29
|
+
import { createMongooseAdapter } from "@classytic/mongokit/adapter";
|
|
30
|
+
import { createRepository } from "@classytic/mongokit";
|
|
31
|
+
import { z } from "zod";
|
|
32
|
+
import { Product } from "./product.model.js";
|
|
33
|
+
|
|
34
|
+
const productRepo = createRepository(Product, { softDelete: true, timestamps: true });
|
|
35
|
+
|
|
36
|
+
const create = z.strictObject({
|
|
37
|
+
name: z.string().trim().min(1),
|
|
38
|
+
price: z.number().min(0),
|
|
39
|
+
status: z.enum(["draft", "active", "archived"]).default("draft"),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const productResource = defineResource({
|
|
43
|
+
name: "product",
|
|
44
|
+
adapter: createMongooseAdapter(Product, productRepo),
|
|
45
|
+
presets: ["softDelete", { name: "multiTenant", tenantField: "organizationId" }],
|
|
46
|
+
permissions: {
|
|
47
|
+
list: allowPublic(),
|
|
48
|
+
get: allowPublic(),
|
|
49
|
+
create: requireRoles(["admin"]),
|
|
50
|
+
update: requireRoles(["admin"]),
|
|
51
|
+
delete: requireRoles(["admin"]),
|
|
52
|
+
},
|
|
53
|
+
...crudInput({ create, update: create.partial(), parse: true }),
|
|
54
|
+
schemaOptions: { fieldRules: { organizationId: { systemManaged: true } } },
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { createApp } from "@classytic/arc/factory";
|
|
60
|
+
|
|
61
|
+
const app = await createApp({
|
|
62
|
+
auth: { type: "jwt", jwt: { secret: process.env.JWT_SECRET! } },
|
|
63
|
+
resources: [productResource],
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
What arc now owns: five routes, filters, sort, pagination, tenant scoping, role checks, 400/403/404 error contract, `product.created|updated|deleted` events, OpenAPI and MCP derivation from the same declaration.
|
|
68
|
+
|
|
69
|
+
## Presets in one place
|
|
70
|
+
|
|
71
|
+
| Hand-rolled | Preset | Notes |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `/deleted`, restore handler, `deletedAt` filter | `"softDelete"` | adds `GET /deleted`, `POST /:id/restore`; repo filters via `softDelete: true` |
|
|
74
|
+
| `GET /slug/:slug` | `{ name: "slugLookup", slugField: "slug" }` | |
|
|
75
|
+
| children and tree routes | `"tree"` | |
|
|
76
|
+
| `bulkCreate`, `bulkUpdate`, `bulkDelete` | `"bulk"` | |
|
|
77
|
+
| tenant filter on every query | `{ name: "multiTenant", tenantField }` | or `tenantFields` for several levels |
|
|
78
|
+
| owner filter on every query | `{ name: "ownedByUser", ownerField: "authorId" }` | |
|
|
79
|
+
| manual audit writes | `"audited"` | or `audit: true` |
|
|
80
|
+
|
|
81
|
+
## Slim custom controller
|
|
82
|
+
|
|
83
|
+
Prefer none. To compose preset behavior in a class instead of rewriting methods:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { BaseCrudController, BulkMixin, SoftDeleteMixin } from "@classytic/arc";
|
|
87
|
+
|
|
88
|
+
class OrderController extends SoftDeleteMixin(BulkMixin(BaseCrudController)) {}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Pass `tenantField` and `idField` to `super(...)` and mirror them on `defineResource`. A domain verb that must keep arc's sanitize, tenant and hook pipeline belongs in `actions` or `writes`, not a controller override.
|
|
92
|
+
|
|
93
|
+
## Rollout order for a large project
|
|
94
|
+
|
|
95
|
+
1. Auth and scope accessors first: they unlock declarative permissions.
|
|
96
|
+
2. Adapters and repositories before resources.
|
|
97
|
+
3. Convert one thin resource end to end, then the rest; fold presets into the resource that needs them.
|
|
98
|
+
4. Keep old routes alongside new ones behind a path prefix for one release; cut over after consumers confirm.
|
|
99
|
+
5. Run `arc docs` and diff against the hand-kept spec.
|
|
100
|
+
6. Delete the old code when the sweep shows zero R1, A1, A2 hits.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Recipe: schemas, parsing, fields, errors
|
|
2
|
+
|
|
3
|
+
## One zod v4 declaration, three consumers
|
|
4
|
+
|
|
5
|
+
AJV validates what JSON Schema can express, a preHandler runs the same schema and replaces `body`, `query`, `params` with the parsed value (trim, defaults, refine apply), and OpenAPI plus MCP derive from the declaration. A failed parse is a 400 `arc.validation_error` with field `details`.
|
|
6
|
+
|
|
7
|
+
### Custom route
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { parsed, routeInput } from "@classytic/arc/core";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
const body = z.object({ title: z.string().trim().min(2), tags: z.array(z.string()).default([]) });
|
|
14
|
+
const query = z.object({ limit: z.coerce.number().int().min(1).default(10) });
|
|
15
|
+
|
|
16
|
+
routes: [{
|
|
17
|
+
method: "POST",
|
|
18
|
+
path: "/echo",
|
|
19
|
+
permissions: allowPublic(),
|
|
20
|
+
...routeInput({ body, querystring: query, response: { 200: z.object({ title: z.string() }) } }),
|
|
21
|
+
rawHandler: async (req, reply) => reply.send({ title: parsed(body, req.body).title }),
|
|
22
|
+
}],
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Smell removed: `body.parse(req.body)` at the top of each handler. A plain JSON Schema in a slot is validated by AJV only.
|
|
26
|
+
|
|
27
|
+
### CRUD writes
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const create = z.strictObject({ name: z.string().trim().min(1), rank: z.number().default(1) });
|
|
31
|
+
defineResource({ name: "gadget", adapter, ...crudInput({ create, update: create.partial(), parse: true }) });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`crudInput` returns `customSchemas`, `openApiSchemas` and, with `parse: true`, create and update middlewares. It also writes `middlewares`: merge your own with `middlewares: { create: [...mine, ...crud.middlewares.create] }`. A `.default()` field stays optional on the wire. `z.strictObject` refuses unknown keys.
|
|
35
|
+
|
|
36
|
+
### Actions
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { defineAction, noPayloadSchema } from "@classytic/arc/core";
|
|
40
|
+
|
|
41
|
+
actions: {
|
|
42
|
+
close: defineAction({
|
|
43
|
+
schema: z.object({ note: z.string().trim().min(2), urgent: z.boolean().default(false) }),
|
|
44
|
+
parse: true,
|
|
45
|
+
permissions: requireRoles(["admin"]),
|
|
46
|
+
handler: async (id, data, req) => svc.close(id, data.note), // data is the parsed output
|
|
47
|
+
}),
|
|
48
|
+
archive: defineAction({ schema: noPayloadSchema, permissions: requireRoles(["admin"]), handler: async (id) => svc.archive(id) }),
|
|
49
|
+
},
|
|
50
|
+
// POST /tickets/:id/action { "action": "close", "note": "done" }
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The action `schema` IS the body schema. `schema: { body: X }` has no `type` or `properties`, validates nothing and logs `schema.slot_wrapper`; with `strictSchemas: true` on the resource it fails at define time. Without `parse: true` the handler sees what AJV accepted, untouched.
|
|
54
|
+
|
|
55
|
+
## Hide and gate fields
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { defineResource, fields } from "@classytic/arc";
|
|
59
|
+
|
|
60
|
+
defineResource({
|
|
61
|
+
name: "user",
|
|
62
|
+
adapter,
|
|
63
|
+
schemaOptions: { fieldRules: { password: { hidden: true }, mfaSecret: { hidden: true }, organizationId: { systemManaged: true } } },
|
|
64
|
+
fields: {
|
|
65
|
+
salary: fields.visibleTo(["admin", "hr"]),
|
|
66
|
+
email: fields.redactFor(["viewer"], "***"),
|
|
67
|
+
role: fields.writableBy(["admin"]),
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`hidden` applies at serialization for REST and MCP and works with lean reads. `onFieldWriteDenied` defaults to `"reject"` (403 with the denied list); leave it for sensitive resources. Other `fieldRules` flags: `immutable`, `immutableAfterCreate`, `optional`, `nullable`, `preserveForElevated`, `minLength`, `maxLength`, `min`, `max`, `pattern`, `enum`, `description`.
|
|
73
|
+
|
|
74
|
+
## Errors
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { createDomainError, defineErrorMapper, NotFoundError } from "@classytic/arc/utils";
|
|
78
|
+
|
|
79
|
+
throw new NotFoundError("order"); // 404
|
|
80
|
+
throw createDomainError("order.already_paid", "Order already paid", 409);
|
|
81
|
+
|
|
82
|
+
createApp({
|
|
83
|
+
errorHandler: {
|
|
84
|
+
errorMappers: [defineErrorMapper({ type: BillingError, toResponse: (e) => ({ status: e.status, code: e.code, message: e.message }) })],
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Unknown routes answer the ErrorContract 404 `arc.not_found` by default. Delete custom `setNotFoundHandler`; to change it set `errorHandler: { notFound: fn }`, to own it `notFound: false`.
|
|
90
|
+
|
|
91
|
+
## Unified list responses
|
|
92
|
+
|
|
93
|
+
`reply.sendList()` (via `replyHelpersPlugin`) wraps repo-core's `toCanonicalList`; types come from `@classytic/repo-core/pagination`. Do not hand-build `{ items, total, pages }`.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Recipe: permissions, scope, tenancy
|
|
2
|
+
|
|
3
|
+
## Inline checks to declarative permissions
|
|
4
|
+
|
|
5
|
+
Before:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
fastify.patch("/posts/:id", async (req) => {
|
|
9
|
+
if (!req.user) throw fastify.httpErrors.unauthorized();
|
|
10
|
+
const post = await Post.findById(req.params.id);
|
|
11
|
+
const isAuthor = post.authorId.toString() === req.user.id;
|
|
12
|
+
if (!isAuthor && !req.user.roles?.includes("admin")) throw fastify.httpErrors.forbidden();
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
After:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { anyOf, defineResource, requireOwnership, requireRoles } from "@classytic/arc";
|
|
20
|
+
|
|
21
|
+
defineResource({
|
|
22
|
+
name: "post",
|
|
23
|
+
adapter,
|
|
24
|
+
permissions: {
|
|
25
|
+
update: anyOf(requireRoles(["admin"]), requireOwnership("authorId")),
|
|
26
|
+
delete: requireRoles(["admin"]),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`requireOwnership` grants with a data policy `{ authorId: userId }`, so the repository query is scoped to the caller's rows; admins pass without it. A permission returns `boolean` or a decision with `filters`/`scope`; combinators: `allOf`, `anyOf`, `not`, `when`, `denyAll`.
|
|
32
|
+
|
|
33
|
+
| Need | Check |
|
|
34
|
+
|---|---|
|
|
35
|
+
| any signed-in user | `requireAuth()` |
|
|
36
|
+
| org member | `requireOrgMembership()` |
|
|
37
|
+
| org role | `requireOrgRole("admin")` |
|
|
38
|
+
| team member | `requireTeamMembership()` |
|
|
39
|
+
| service token with scope | `requireServiceScope("jobs:bulk-write")` |
|
|
40
|
+
| scope context value | `requireScopeContext("branchId")` |
|
|
41
|
+
| target org inside caller's hierarchy | `requireOrgInScope(targetId)` |
|
|
42
|
+
| same gate on all CRUD keys | `permissionMatrix({ read, write, delete? })` |
|
|
43
|
+
| role by resource by action table | `createDynamicPermissionMatrix` |
|
|
44
|
+
| common shapes | `permissions.publicReadAdminWrite()`, `publicRead`, `adminOnly`, `readOnly` |
|
|
45
|
+
|
|
46
|
+
## Scope accessors instead of `req.user`
|
|
47
|
+
|
|
48
|
+
Before:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
const userId = req.user._id;
|
|
52
|
+
const orgId = req.user.orgId;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
After:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { getUserId, getOrgId, requireOrgId, isAuthenticated } from "@classytic/arc/scope";
|
|
59
|
+
|
|
60
|
+
if (!isAuthenticated(req.scope)) return reply.code(401).send();
|
|
61
|
+
const orgId = requireOrgId(req.scope, "create-order");
|
|
62
|
+
const userId = getUserId(req.scope);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`RequestScope` kinds: `public`, `authenticated`, `member`, `service`, `elevated`. Read `organizationId` through `getOrgId`, never from the scope object. In a hook, `ctx.scope` carries `organizationId`, `userId`, `orgRoles`.
|
|
66
|
+
|
|
67
|
+
## Tenancy
|
|
68
|
+
|
|
69
|
+
| Case | Setting |
|
|
70
|
+
|---|---|
|
|
71
|
+
| normal tenant table | default `tenantField: "organizationId"` or `{ name: "multiTenant", tenantField }` |
|
|
72
|
+
| company-wide lookup table | `tenantField: false` |
|
|
73
|
+
| different scope key | `tenantField: "workspaceId"` |
|
|
74
|
+
| branch and project levels | `multiTenantPreset({ tenantFields: [{ field: "organizationId", type: "org" }, { field: "branchId", contextKey: "branchId" }] })` |
|
|
75
|
+
|
|
76
|
+
Scope tenancy at one layer. The `multiTenant` preset is the HTTP boundary; add the repository `tenant` option as defence in depth when jobs or CLIs share the repository. Populate `scope.context` and `ancestorOrgIds` in the auth function for multi-level tenancy; see the arc skill, references on multi-tenancy.
|
|
77
|
+
|
|
78
|
+
A preset tenant filter overwrites a body `organizationId` on update, which closes tenant-hopping. Never accept the tenant key from the client body or an `x-organization-id` header as a permission.
|
|
79
|
+
|
|
80
|
+
## Platform admin
|
|
81
|
+
|
|
82
|
+
`createApp({ elevation: { platformRoles: ["superadmin"], onElevation } })`: a superadmin sends `x-arc-scope: platform` to elevate; without the header they are a normal user. Handlers check `isElevated(scope)`.
|