@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.
Files changed (321) hide show
  1. package/README.md +1 -1
  2. package/dist/{EventTransport-CiicKz2Z.d.mts → EventTransport-CYEoCJGe.d.mts} +0 -2
  3. package/dist/{EventTransport-DHb1tpu-.mjs → EventTransport-DNgD9NP4.mjs} +3 -4
  4. package/dist/{HookSystem-C1u0EUnt.mjs → HookSystem-DRbPzEcP.mjs} +3 -4
  5. package/dist/{QueryCache--5uAuYPW.d.mts → QueryCache-DdvrGG8Q.d.mts} +1 -3
  6. package/dist/{ResourceRegistry-D2jXWVN_.mjs → ResourceRegistry-Douk51fa.mjs} +15 -4
  7. package/dist/{acquire-DTkA8Lme.mjs → acquire-RbtvDg9s.mjs} +2 -3
  8. package/dist/{actionPermissions-DRVk6m7x.mjs → actionPermissions-De0AJ7hm.mjs} +37 -42
  9. package/dist/audit/index.d.mts +2 -10
  10. package/dist/audit/index.mjs +8 -12
  11. package/dist/auth/audit.d.mts +0 -2
  12. package/dist/auth/audit.mjs +2 -3
  13. package/dist/auth/index.d.mts +9 -17
  14. package/dist/auth/index.mjs +26 -29
  15. package/dist/auth/redis-session.d.mts +2 -4
  16. package/dist/auth/redis-session.mjs +2 -3
  17. package/dist/{authorizationDecision-D48fUJv1.mjs → authorizationDecision-DeZMrHcm.mjs} +5 -6
  18. package/dist/{base-CZyixEQR.d.mts → base-HXNgPQww.d.mts} +1 -7
  19. package/dist/{boundedMap-DkKiPifd.mjs → boundedMap-2WBh3gM9.mjs} +2 -3
  20. package/dist/{buildHandler-BiZ4VATS.mjs → buildHandler-DxVOOBpw.mjs} +5 -6
  21. package/dist/cache/index.d.mts +4 -10
  22. package/dist/cache/index.mjs +5 -6
  23. package/dist/{caching-Cj0as-P1.mjs → caching-BYRwYrUo.mjs} +3 -4
  24. package/dist/{claimed-ChI13rUR.mjs → claimed-DYlELdnm.mjs} +2 -3
  25. package/dist/cleanup/index.d.mts +4 -18
  26. package/dist/cleanup/index.mjs +12 -20
  27. package/dist/cli/commands/describe.d.mts +1 -3
  28. package/dist/cli/commands/describe.mjs +4 -5
  29. package/dist/cli/commands/docs.d.mts +1 -3
  30. package/dist/cli/commands/docs.mjs +4 -5
  31. package/dist/cli/commands/doctor.d.mts +1 -3
  32. package/dist/cli/commands/doctor.mjs +2 -3
  33. package/dist/cli/commands/generate.d.mts +1 -1
  34. package/dist/cli/commands/generate.mjs +2 -2
  35. package/dist/cli/commands/init.d.mts +1 -1
  36. package/dist/cli/commands/init.mjs +2 -2
  37. package/dist/cli/commands/introspect.d.mts +1 -3
  38. package/dist/cli/commands/introspect.mjs +3 -4
  39. package/dist/cli/index.d.mts +2 -2
  40. package/dist/cli/index.mjs +3 -3
  41. package/dist/{constants-D_aiew34.mjs → constants-CHZMUwBW.mjs} +2 -3
  42. package/dist/context/index.d.mts +0 -8
  43. package/dist/context/index.mjs +6 -7
  44. package/dist/core/index.d.mts +3 -3
  45. package/dist/core/index.mjs +8 -8
  46. package/dist/{core-QIZ2560Y.mjs → core-D9rS2BxO.mjs} +9 -12
  47. package/dist/{createActionRouter-CvH84dyx.mjs → createActionRouter-0qkCRzTL.mjs} +7 -8
  48. package/dist/{createAggregationRouter-DGyK2Hp6.mjs → createAggregationRouter-CUf5Esd9.mjs} +9 -10
  49. package/dist/{createApp-CKjZpmq9.mjs → createApp-DZIXfDKD.mjs} +49 -62
  50. package/dist/{createMcpServer-DSztofa9.d.mts → createMcpServer-DeVpqQF-.d.mts} +1 -3
  51. package/dist/{defineAggregation-BLza7Ca4.mjs → defineAggregation-bmKQ4NmC.mjs} +2 -3
  52. package/dist/{defineResource-CEo0gDCb.mjs → defineResource-CGmdmGwh.mjs} +78 -29
  53. package/dist/discovery/index.d.mts +1 -3
  54. package/dist/discovery/index.mjs +2 -3
  55. package/dist/docs/index.d.mts +8 -8
  56. package/dist/docs/index.mjs +4 -5
  57. package/dist/{elevation-BJTsSnke.mjs → elevation-CzhqAyVN.mjs} +9 -10
  58. package/dist/{elevation-BW2J3tNj.d.mts → elevation-DPD0hcU-.d.mts} +0 -2
  59. package/dist/encryption/index.d.mts +1 -7
  60. package/dist/encryption/index.mjs +8 -13
  61. package/dist/{errorHandler--4rSMMvq.d.mts → errorHandler-B9r88jZV.d.mts} +8 -3
  62. package/dist/{errorHandler-2p4SL5zm.mjs → errorHandler-dFyGOEoB.mjs} +16 -6
  63. package/dist/{errors-grZkIA8N.mjs → errors-BY8vzlP4.mjs} +2 -3
  64. package/dist/{errors-JYc9vwqE.d.mts → errors-DTo0me1o.d.mts} +0 -2
  65. package/dist/{eventPlugin-BtmA4-3P.d.mts → eventPlugin-BY38F6yK.d.mts} +1 -7
  66. package/dist/{eventPlugin-ItcYBGUs.mjs → eventPlugin-eMhAPtQA.mjs} +10 -12
  67. package/dist/{eventTypes-Ck6fD3ne.mjs → eventTypes-Do2KYeJx.mjs} +5 -8
  68. package/dist/events/index.d.mts +4 -16
  69. package/dist/events/index.mjs +8 -9
  70. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  71. package/dist/events/transports/redis-stream-entry.mjs +5 -6
  72. package/dist/events/transports/redis.d.mts +2 -4
  73. package/dist/events/transports/redis.mjs +3 -4
  74. package/dist/{externalPaths-CmGOxOtD.d.mts → externalPaths-BOqdq5wr.d.mts} +0 -2
  75. package/dist/factory/index.d.mts +4 -14
  76. package/dist/factory/index.mjs +12 -18
  77. package/dist/{fastify-augmentation-DRlCIWE9.d.mts → fastify-augmentation-Dtn0IIRn.d.mts} +4 -10
  78. package/dist/{fields-BBSpf8pS.d.mts → fields-JTkrtO-r.d.mts} +0 -2
  79. package/dist/{fields-BRX0Krcj.mjs → fields-LnbCcvsw.mjs} +2 -3
  80. package/dist/{filter-merge-CDc7YMwX.mjs → filter-merge-BAWi019Q.mjs} +2 -3
  81. package/dist/{generate-DCGuEbqI.d.mts → generate-C-g_KOkV.d.mts} +0 -4
  82. package/dist/{generate-hvg7V2g1.mjs → generate-oXoDnpJf.mjs} +7 -12
  83. package/dist/{headers-Cqkg4LzI.mjs → headers-DBd3Qheo.mjs} +3 -4
  84. package/dist/{health-PVt0VjOx.mjs → health-BlJu9GXS.mjs} +2 -3
  85. package/dist/{health-DyeP3mTW.mjs → health-Dp-3EC9o.mjs} +4 -7
  86. package/dist/hooks/index.d.mts +1 -1
  87. package/dist/hooks/index.mjs +2 -2
  88. package/dist/idempotency/index.d.mts +3 -9
  89. package/dist/idempotency/index.mjs +10 -13
  90. package/dist/idempotency/redis.d.mts +1 -1
  91. package/dist/idempotency/redis.mjs +3 -4
  92. package/dist/{index-Bxriq3so.d.mts → index-B5i9-vuP.d.mts} +4 -26
  93. package/dist/{index-Chgz3d0i.d.mts → index-BAXDo5eE.d.mts} +1 -7
  94. package/dist/{index-Beg3aNnK.d.mts → index-BTxzJ_MN.d.mts} +67 -25
  95. package/dist/{index-CUJvoyw3.d.mts → index-Bqfo8hLz.d.mts} +2 -24
  96. package/dist/{index-uhkUA5-U.d.mts → index-CUdaoCYt.d.mts} +13 -23
  97. package/dist/{index-WH7xgvxS.d.mts → index-DyJFTJLA.d.mts} +31 -92
  98. package/dist/index.d.mts +7 -9
  99. package/dist/index.mjs +12 -13
  100. package/dist/{init-jC3rMPzb.mjs → init-BOaNkLYb.mjs} +18 -35
  101. package/dist/{init-Cscs4lab.d.mts → init-CV2_Fw3H.d.mts} +0 -4
  102. package/dist/integrations/event-gateway.d.mts +3 -5
  103. package/dist/integrations/event-gateway.mjs +3 -4
  104. package/dist/integrations/index.d.mts +3 -3
  105. package/dist/integrations/index.mjs +1 -1
  106. package/dist/integrations/jobs/index.d.mts +1 -1
  107. package/dist/integrations/jobs/index.mjs +7 -11
  108. package/dist/integrations/mcp/index.d.mts +7 -39
  109. package/dist/integrations/mcp/index.mjs +8 -14
  110. package/dist/integrations/mcp/testing.d.mts +3 -5
  111. package/dist/integrations/mcp/testing.mjs +3 -4
  112. package/dist/integrations/streamline.d.mts +1 -3
  113. package/dist/integrations/streamline.mjs +4 -5
  114. package/dist/integrations/webhooks.d.mts +2 -4
  115. package/dist/integrations/webhooks.mjs +4 -5
  116. package/dist/integrations/websocket-pushref-redis.d.mts +2 -4
  117. package/dist/integrations/websocket-pushref-redis.mjs +2 -3
  118. package/dist/integrations/websocket-redis.d.mts +2 -4
  119. package/dist/integrations/websocket-redis.mjs +2 -3
  120. package/dist/integrations/websocket.d.mts +2 -2
  121. package/dist/integrations/websocket.mjs +13 -24
  122. package/dist/{interface-JJzwH4Ro.d.mts → interface-BmExzQRD.d.mts} +0 -2
  123. package/dist/{interface-BOk3YnTz.d.mts → interface-WR1U0K7t.d.mts} +0 -2
  124. package/dist/{jsonBody-ptwyzZQ-.mjs → jsonBody-DpRpKR_K.mjs} +3 -4
  125. package/dist/{keys-C1vFuSbv.mjs → keys-FBz6Ull-.mjs} +2 -3
  126. package/dist/{loadResources-CHPDyIPn.mjs → loadResources-Bx1sKPnF.mjs} +4 -5
  127. package/dist/{loadResourcesFromEntry-BkHHTu_B.mjs → loadResourcesFromEntry-b_jcqbxh.mjs} +3 -4
  128. package/dist/logger/index.d.mts +1 -3
  129. package/dist/logger/index.mjs +2 -2
  130. package/dist/{logger-C5bvCiAK.mjs → logger-CbFcIEBZ.mjs} +3 -5
  131. package/dist/{mcpPlugin-C9qohJCF.mjs → mcpPlugin-yix548XX.mjs} +41 -60
  132. package/dist/{memory-CxiTwT0j.mjs → memory-Bgw5dn8N.mjs} +4 -5
  133. package/dist/{metrics-Ckp2zRy-.mjs → metrics-CZDQWVjS.mjs} +4 -5
  134. package/dist/middleware/index.d.mts +1 -5
  135. package/dist/middleware/index.mjs +4 -5
  136. package/dist/migrations/index.d.mts +0 -2
  137. package/dist/migrations/index.mjs +3 -4
  138. package/dist/{module-CfnKuIuH.mjs → module-Dsc_nKL5.mjs} +2 -3
  139. package/dist/{multiTenant-CAtYlW6H.d.mts → multiTenant-XCxAUlru.d.mts} +1 -5
  140. package/dist/{multipartBody-BFasGtP9.mjs → multipartBody-B85ek8Kj.mjs} +2 -3
  141. package/dist/observeSend-BK-JN1jK.mjs +20 -0
  142. package/dist/{openapi-DAPxjYHX.mjs → openapi-Co7hl073.mjs} +18 -28
  143. package/dist/outbox-admin/index.d.mts +2 -4
  144. package/dist/outbox-admin/index.mjs +6 -7
  145. package/dist/{outbox-module-gZCHoE4H.d.mts → outbox-module-XvUThpqn.d.mts} +2 -8
  146. package/dist/{outbox-module-B4FAkx3A.mjs → outbox-module-mg9kDYkd.mjs} +13 -17
  147. package/dist/permissions/index.d.mts +4 -4
  148. package/dist/permissions/index.mjs +7 -7
  149. package/dist/{permissions-B14c3OMp.mjs → permissions-A1oKtpiC.mjs} +19 -29
  150. package/dist/{pipe-CQv7PsAK.mjs → pipe-Czpw9U2n.mjs} +3 -4
  151. package/dist/pipeline/index.d.mts +1 -9
  152. package/dist/pipeline/index.mjs +5 -8
  153. package/dist/{plan-CpnTykjb.mjs → plan-KVseuBCL.mjs} +5 -9
  154. package/dist/{plugin-DXTjVg_Q.mjs → plugin-DTWt_8C3.mjs} +130 -62
  155. package/dist/plugins/index.d.mts +8 -16
  156. package/dist/plugins/index.mjs +22 -26
  157. package/dist/plugins/response-cache.d.mts +2 -4
  158. package/dist/plugins/response-cache.mjs +10 -10
  159. package/dist/plugins/tracing-entry.d.mts +1 -1
  160. package/dist/plugins/tracing-entry.mjs +3 -4
  161. package/dist/{pluralize-C3VJKRGp.mjs → pluralize-msB9X3yw.mjs} +2 -3
  162. package/dist/presets/filesUpload.d.mts +4 -6
  163. package/dist/presets/filesUpload.mjs +6 -7
  164. package/dist/presets/index.d.mts +3 -19
  165. package/dist/presets/index.mjs +2 -2
  166. package/dist/presets/multiTenant.d.mts +1 -1
  167. package/dist/presets/multiTenant.mjs +7 -7
  168. package/dist/presets/search.d.mts +3 -5
  169. package/dist/presets/search.mjs +3 -4
  170. package/dist/{presets-CquqYJPy.mjs → presets-qKCehiJM.mjs} +11 -18
  171. package/dist/{projection-CgfSLOSM.mjs → projection-ClBqtsIw.mjs} +3 -4
  172. package/dist/{pushref-registry-UxCkoA4C.d.mts → pushref-registry-d86QUaSq.d.mts} +0 -6
  173. package/dist/{queryCachePlugin-D0HUISHJ.mjs → queryCachePlugin-3gJj5Rbz.mjs} +8 -10
  174. package/dist/{queryCachePlugin-C2lZjTxk.d.mts → queryCachePlugin-DYQUyeJ9.d.mts} +2 -4
  175. package/dist/{rateLimitKey-AvkBOMkl.mjs → rateLimitKey-Kro---xl.mjs} +2 -3
  176. package/dist/{realtime-CbWtVbqK.mjs → realtime-Ber8uJN2.mjs} +17 -19
  177. package/dist/{redis-BDgv9Glw.d.mts → redis-RpDMemdm.d.mts} +2 -4
  178. package/dist/{redis-stream-BMk-bpQS.d.mts → redis-stream-CS1N9dwM.d.mts} +1 -3
  179. package/dist/{redisShapes-CQksY67q.d.mts → redisShapes-CqBXTn_s.d.mts} +0 -2
  180. package/dist/registry/index.d.mts +2 -12
  181. package/dist/registry/index.mjs +3 -3
  182. package/dist/{registry-BVwpAuFI.mjs → registry-BA-_vFYk.mjs} +7 -12
  183. package/dist/{renewingLease-CykpeNcQ.mjs → renewingLease-CMY8YOcc.mjs} +2 -3
  184. package/dist/{replyHelpers-DA51IZio.mjs → replyHelpers-DK9P_XSz.mjs} +3 -4
  185. package/dist/{requestContext-DIWHKDtQ.mjs → requestContext-GYO_0gEw.mjs} +2 -3
  186. package/dist/{requirement-CbiLdQ1n.d.mts → requirement-CTRQjjQx.d.mts} +0 -2
  187. package/dist/{requirement-Cp_fsMDL.mjs → requirement-DeNjZIH3.mjs} +2 -3
  188. package/dist/{resourceRateLimit-Wf6d6FL9.d.mts → resourceRateLimit-DCWglD7V.d.mts} +1 -3
  189. package/dist/{resourceRateLimit-BFuluodF.mjs → resourceRateLimit-tHLbrtWc.mjs} +3 -4
  190. package/dist/{rolldown-runtime-D_lMdYOd.mjs → rolldown-runtime-Kv1fZdLg.mjs} +2 -3
  191. package/dist/{routeValidator-DuLonYwr.mjs → routeValidator-C_H5NanI.mjs} +2 -3
  192. package/dist/{runtimeCapabilities-CydRfm0i.mjs → runtimeCapabilities-DWqbxkyw.mjs} +2 -3
  193. package/dist/{schedules-B693KXxa.mjs → schedules-eO_RzhCU.mjs} +132 -9
  194. package/dist/{schemaConverter-DNvZWTV6.mjs → schemaConverter-DBJrPZN4.mjs} +3 -4
  195. package/dist/{schemaIR-REV2y7Wd.mjs → schemaIR-CEScKT2v.mjs} +3 -4
  196. package/dist/schemas/index.d.mts +0 -2
  197. package/dist/schemas/index.mjs +2 -3
  198. package/dist/scim/index.d.mts +0 -12
  199. package/dist/scim/index.mjs +10 -18
  200. package/dist/scope/index.d.mts +2 -6
  201. package/dist/scope/index.mjs +5 -5
  202. package/dist/{scope-Bevxy_ST.mjs → scope-B-Sm9m_E.mjs} +5 -6
  203. package/dist/{sessionManager-qimlKV0P.d.mts → sessionManager-CdvDF04x.d.mts} +2 -4
  204. package/dist/{shutdown-CfrqPR7A.mjs → shutdown-DzLFbe27.mjs} +2 -3
  205. package/dist/{simpleEqualityMatcher-BJwfuRKP.mjs → simpleEqualityMatcher-DOJhwQ8g.mjs} +2 -3
  206. package/dist/{sse-CuNNWr2z.mjs → sse-2972pVwV.mjs} +8 -9
  207. package/dist/{sseStream-C_2ujAVY.mjs → sseStream-AWLEeNV-.mjs} +3 -4
  208. package/dist/{storage-Cx9Sz3Ou.d.mts → storage-odC5MNKN.d.mts} +0 -2
  209. package/dist/{store-helpers-C8uBGCbb.mjs → store-helpers-VzjgVTkM.mjs} +2 -3
  210. package/dist/{streaming-Bdq_M4d5.mjs → streaming-DvraWW6x.mjs} +2 -3
  211. package/dist/{subscriberIdentity-B-KpZkdl.mjs → subscriberIdentity-Bya56jsg.mjs} +2 -3
  212. package/dist/{tenancy-C5PCvm1h.mjs → tenancy-DSa_0hhw.mjs} +3 -4
  213. package/dist/{tenantPreparation-dYvWrgNa.mjs → tenantPreparation-BrpkQre3.mjs} +5 -6
  214. package/dist/testing/cleanupStoreContract.d.mts +2 -4
  215. package/dist/testing/cleanupStoreContract.mjs +2 -3
  216. package/dist/testing/index.d.mts +6 -32
  217. package/dist/testing/index.mjs +24 -37
  218. package/dist/testing/outboxStoreContract.d.mts +1 -3
  219. package/dist/testing/outboxStoreContract.mjs +3 -4
  220. package/dist/testing/requiredPorts.d.mts +2 -4
  221. package/dist/testing/requiredPorts.mjs +3 -4
  222. package/dist/testing/storageContract.d.mts +2 -4
  223. package/dist/testing/storageContract.mjs +2 -3
  224. package/dist/{timing-DCqsezX8.mjs → timing-6rQTuCwg.mjs} +3 -5
  225. package/dist/{tracing-Dro5eH6j.d.mts → tracing-JSFiBl5r.d.mts} +0 -2
  226. package/dist/{transactionContext-DrcNyjpv.mjs → transactionContext-DaxYUEgH.mjs} +2 -3
  227. package/dist/{typeGuards-CEl10KPy.mjs → typeGuards-UKnX8wPX.mjs} +2 -3
  228. package/dist/types/index.d.mts +4 -4
  229. package/dist/types/index.mjs +1 -1
  230. package/dist/types/storage.d.mts +1 -1
  231. package/dist/types/storage.mjs +1 -1
  232. package/dist/{types-ByHn9rEO.d.mts → types-0Dqlbgn8.d.mts} +0 -2
  233. package/dist/{types-D3Ixsh00.d.mts → types-BYEb_dLW.d.mts} +2 -4
  234. package/dist/{types-BJ-2XqVF.d.mts → types-BeEJm-DV.d.mts} +114 -14
  235. package/dist/{types-DVLddu2q.d.mts → types-C0YJAiL0.d.mts} +0 -2
  236. package/dist/{types-D9NWjpYc.mjs → types-CuGjhn83.mjs} +5 -6
  237. package/dist/{types-Ddl9OjmE.d.mts → types-DnkIALZ8.d.mts} +0 -4
  238. package/dist/usage/index.d.mts +2 -10
  239. package/dist/usage/index.mjs +8 -12
  240. package/dist/{userHelpers-BHig1kHq.mjs → userHelpers-oX5_mOVs.mjs} +2 -3
  241. package/dist/utils/index.d.mts +5 -39
  242. package/dist/utils/index.mjs +12 -12
  243. package/dist/{utils-BG5P7_Vb.mjs → utils-CjjGOT4E.mjs} +20 -30
  244. package/dist/{validate-D_mdOCir.mjs → validate-4RlTKOJb.mjs} +5 -7
  245. package/dist/{versioning-DBGHjPh7.mjs → versioning-Dk2-19La.mjs} +4 -5
  246. package/dist/{versioning-Bqm_57Qt.d.mts → versioning-S18y2-0C.d.mts} +1 -15
  247. package/dist/{websocket-Cs4awVyD.d.mts → websocket-BGuc-WVZ.d.mts} +1 -15
  248. package/dist/{workScope-DPPfM4m6.mjs → workScope-DoBsoVo4.mjs} +3 -4
  249. package/llms.txt +37 -30
  250. package/package.json +9 -8
  251. package/skills/arc/SKILL.md +65 -844
  252. package/skills/arc/references/agent-auth.md +82 -193
  253. package/skills/arc/references/api-reference.md +41 -245
  254. package/skills/arc/references/auth-api-keys.md +99 -0
  255. package/skills/arc/references/auth-better-auth-overlay.md +87 -0
  256. package/skills/arc/references/auth-better-auth.md +78 -0
  257. package/skills/arc/references/auth-permissions.md +100 -0
  258. package/skills/arc/references/auth-strategies.md +122 -0
  259. package/skills/arc/references/boot.md +80 -0
  260. package/skills/arc/references/enterprise-auth.md +65 -81
  261. package/skills/arc/references/events-outbox.md +90 -0
  262. package/skills/arc/references/events.md +75 -440
  263. package/skills/arc/references/integrations-jobs.md +74 -0
  264. package/skills/arc/references/integrations-realtime.md +84 -0
  265. package/skills/arc/references/integrations-webhooks.md +71 -0
  266. package/skills/arc/references/integrations-workflows.md +47 -0
  267. package/skills/arc/references/mcp-auth.md +83 -0
  268. package/skills/arc/references/mcp-custom-tools.md +125 -0
  269. package/skills/arc/references/mcp-setup.md +115 -0
  270. package/skills/arc/references/mcp-testing.md +63 -0
  271. package/skills/arc/references/multi-tenancy.md +56 -230
  272. package/skills/arc/references/permissions-scope.md +81 -0
  273. package/skills/arc/references/production-api.md +119 -0
  274. package/skills/arc/references/production-audit.md +101 -0
  275. package/skills/arc/references/production-boot.md +91 -0
  276. package/skills/arc/references/production-caching.md +63 -0
  277. package/skills/arc/references/production-distributed.md +75 -0
  278. package/skills/arc/references/production-idempotency.md +83 -0
  279. package/skills/arc/references/production-observability.md +83 -0
  280. package/skills/arc/references/production-realtime.md +70 -0
  281. package/skills/arc/references/production-reliability.md +100 -0
  282. package/skills/arc/references/production-shutdown.md +43 -0
  283. package/skills/arc/references/querying.md +76 -0
  284. package/skills/arc/references/resources.md +97 -0
  285. package/skills/arc/references/schedules.md +79 -0
  286. package/skills/arc/references/scim.md +61 -208
  287. package/skills/arc/references/tenancy-scope-install.md +82 -0
  288. package/skills/arc/references/testing.md +101 -144
  289. package/skills/arc/references/usage-cleanup-capabilities.md +45 -0
  290. package/skills/arc/references/validation.md +91 -0
  291. package/skills/arc/references/writes-hooks-errors.md +80 -0
  292. package/skills/arc-code-review/SKILL.md +67 -114
  293. package/skills/arc-code-review/references/arc-cheatsheet.md +68 -167
  294. package/skills/arc-code-review/references/mongokit-repositories.md +104 -0
  295. package/skills/arc-code-review/references/recipe-events-cache-jobs.md +112 -0
  296. package/skills/arc-code-review/references/recipe-resource.md +100 -0
  297. package/skills/arc-code-review/references/recipe-schemas-fields.md +93 -0
  298. package/skills/arc-code-review/references/recipe-scope-permissions.md +82 -0
  299. package/skills/arc-code-review/references/scaffolding.md +61 -198
  300. package/skills/arc-code-review/references/severity.md +49 -102
  301. package/skills/arc-code-review/references/smells-auth-scope.md +80 -0
  302. package/skills/arc-code-review/references/smells-data-events.md +66 -0
  303. package/skills/arc-code-review/references/smells-imports-style.md +59 -0
  304. package/skills/arc-code-review/references/smells-platform.md +89 -0
  305. package/skills/arc-code-review/references/smells-routes-schemas.md +66 -0
  306. package/skills/arc-module-publishing/SKILL.md +82 -208
  307. package/skills/arc-module-publishing/references/action-presets-and-plugins.md +87 -0
  308. package/skills/arc-module-publishing/references/build-and-types.md +73 -0
  309. package/skills/arc-module-publishing/references/module-lifecycle.md +101 -0
  310. package/skills/arc-module-publishing/references/package-manifest.md +34 -122
  311. package/skills/arc-module-publishing/references/publishing-workflow.md +44 -140
  312. package/skills/arc-module-publishing/references/resource-assembly.md +102 -0
  313. package/skills/arc-module-publishing/references/testing-packages.md +82 -0
  314. package/skills/arc/references/auth.md +0 -729
  315. package/skills/arc/references/integrations.md +0 -452
  316. package/skills/arc/references/mcp.md +0 -691
  317. package/skills/arc/references/production.md +0 -835
  318. package/skills/arc-code-review/references/anti-patterns.md +0 -1008
  319. package/skills/arc-code-review/references/migration-recipes.md +0 -649
  320. package/skills/arc-code-review/references/mongokit-migration.md +0 -360
  321. package/skills/arc-module-publishing/references/authoring-modules.md +0 -327
@@ -1,649 +0,0 @@
1
- # Arc Migration Recipes — Before / After
2
-
3
- Concrete diffs for the most common transformations. Apply in the order listed in [SKILL.md](../SKILL.md#audit-workflow). Each recipe shows the *minimum* arc replacement — add presets and field rules as the audit reveals them.
4
-
5
- ---
6
-
7
- ## §1. Manual CRUD module → `defineResource()`
8
-
9
- **Scope:** typically 5 routes (`GET`, `GET /:id`, `POST`, `PATCH /:id`, `DELETE /:id`) + ~150 LOC of pagination/validation/permission glue per resource.
10
-
11
- ### Before
12
-
13
- ```typescript
14
- // routes/products.ts (≈170 LOC)
15
- import { Product } from '../models/product.js';
16
- import { z } from 'zod';
17
-
18
- const createBody = z.object({
19
- name: z.string().min(1),
20
- price: z.number().min(0),
21
- status: z.enum(['draft', 'active', 'archived']).default('draft'),
22
- });
23
-
24
- export async function productRoutes(fastify) {
25
- fastify.get('/products', async (req) => {
26
- const page = Math.max(1, Number(req.query.page) || 1);
27
- const limit = Math.min(100, Number(req.query.limit) || 20);
28
- const filters: any = {};
29
- if (req.query.status) filters.status = req.query.status;
30
- if (req.user) filters.organizationId = req.user.orgId; // tenant scope
31
- const items = await Product.find(filters)
32
- .sort({ createdAt: -1 })
33
- .skip((page - 1) * limit)
34
- .limit(limit)
35
- .lean();
36
- const total = await Product.countDocuments(filters);
37
- return { items, total, page, limit, pages: Math.ceil(total / limit) };
38
- });
39
-
40
- fastify.get('/products/:id', async (req) => {
41
- const item = await Product.findOne({ _id: req.params.id, organizationId: req.user?.orgId });
42
- if (!item) throw fastify.httpErrors.notFound();
43
- return item;
44
- });
45
-
46
- fastify.post('/products', async (req, reply) => {
47
- if (!req.user) throw fastify.httpErrors.unauthorized();
48
- if (!req.user.roles.includes('admin')) throw fastify.httpErrors.forbidden();
49
- const data = createBody.parse(req.body);
50
- const item = await Product.create({ ...data, organizationId: req.user.orgId });
51
- await fastify.events.emit('product.created', { id: item._id });
52
- return reply.code(201).send(item);
53
- });
54
-
55
- fastify.patch('/products/:id', async (req) => {
56
- if (!req.user) throw fastify.httpErrors.unauthorized();
57
- if (!req.user.roles.includes('admin')) throw fastify.httpErrors.forbidden();
58
- const item = await Product.findOneAndUpdate(
59
- { _id: req.params.id, organizationId: req.user.orgId },
60
- req.body,
61
- { new: true, runValidators: true },
62
- );
63
- if (!item) throw fastify.httpErrors.notFound();
64
- return item;
65
- });
66
-
67
- fastify.delete('/products/:id', async (req, reply) => {
68
- if (!req.user || !req.user.roles.includes('admin')) throw fastify.httpErrors.forbidden();
69
- const result = await Product.deleteOne({ _id: req.params.id, organizationId: req.user.orgId });
70
- if (result.deletedCount === 0) throw fastify.httpErrors.notFound();
71
- return reply.code(204).send();
72
- });
73
- }
74
- ```
75
-
76
- ### After
77
-
78
- ```typescript
79
- // resources/product/product.resource.ts (≈30 LOC)
80
- import { defineResource, requireRoles, allowPublic } from '@classytic/arc';
81
- import { createMongooseAdapter } from '@classytic/mongokit/adapter';
82
- import { Repository, buildCrudSchemasFromModel } from '@classytic/mongokit';
83
- import { Product } from './product.model.js';
84
-
85
- const productRepo = new Repository(Product);
86
-
87
- export const productResource = defineResource({
88
- name: 'product',
89
-
90
- adapter: createMongooseAdapter({
91
- model: Product,
92
- repository: productRepo,
93
- schemaGenerator: buildCrudSchemasFromModel,
94
- }),
95
-
96
- presets: [{ name: 'multiTenant', tenantField: 'organizationId' }],
97
-
98
- permissions: {
99
- list: allowPublic(),
100
- get: allowPublic(),
101
- create: requireRoles(['admin']),
102
- update: requireRoles(['admin']),
103
- delete: requireRoles(['admin']),
104
- },
105
-
106
- schemaOptions: {
107
- fieldRules: {
108
- name: { type: 'string', minLength: 1, required: true },
109
- price: { type: 'number', minimum: 0, required: true },
110
- status: { type: 'string', enum: ['draft', 'active', 'archived'], default: 'draft' },
111
- organizationId: { systemManaged: true },
112
- },
113
- },
114
-
115
- events: { created: {}, updated: {}, deleted: {} },
116
- });
117
- ```
118
-
119
- ```typescript
120
- // app.ts
121
- import { createApp } from '@classytic/arc/factory';
122
- import { productResource } from './resources/product/product.resource.js';
123
-
124
- const app = await createApp({
125
- auth: { type: 'jwt', jwt: { secret: process.env.JWT_SECRET! } },
126
- resources: [productResource],
127
- });
128
- await app.listen({ port: 8040 });
129
- ```
130
-
131
- **What changed:**
132
- - 170 LOC → 30 LOC (≈82% reduction).
133
- - Tenant scoping via preset, not duplicated `organizationId` filter.
134
- - `requireRoles(['admin'])` declarative, no inline 401/403 throws.
135
- - Events auto-emitted; no `await fastify.events.emit('product.created', ...)`.
136
- - Validation via `fieldRules` — both AJV (request) and OpenAPI (docs) derived.
137
- - 404/422/409 mapped automatically via arc's error resolution chain.
138
-
139
- ---
140
-
141
- ## §2. Inline permission checks → declarative combinators
142
-
143
- ### Before
144
- ```typescript
145
- fastify.patch('/posts/:id', async (req) => {
146
- if (!req.user) throw fastify.httpErrors.unauthorized();
147
- const post = await Post.findById(req.params.id);
148
- if (!post) throw fastify.httpErrors.notFound();
149
- const isAuthor = post.authorId.toString() === req.user.id;
150
- const isAdmin = req.user.roles?.includes('admin');
151
- if (!isAuthor && !isAdmin) throw fastify.httpErrors.forbidden();
152
- // ... mutate
153
- });
154
- ```
155
-
156
- ### After
157
- ```typescript
158
- import { defineResource, anyOf, requireRoles, requireOwnership } from '@classytic/arc';
159
-
160
- defineResource({
161
- name: 'post',
162
- permissions: {
163
- update: anyOf(requireRoles(['admin']), requireOwnership('authorId')),
164
- delete: requireRoles(['admin']),
165
- },
166
- });
167
- ```
168
-
169
- Ownership check is row-level (`requireOwnership` returns `filters: { authorId: userId }` for non-admins, propagated into the repo query).
170
-
171
- For mixed human + service auth: `anyOf(requireOrgRole('admin'), requireServiceScope('jobs:bulk-write'))`.
172
-
173
- ---
174
-
175
- ## §3. Manual `toJSON` transforms → `fieldRules.hidden`
176
-
177
- ### Before
178
- ```typescript
179
- // user.model.ts
180
- const userSchema = new Schema({ name: String, email: String, password: String, mfaSecret: String });
181
- userSchema.set('toJSON', {
182
- transform: (_doc, ret) => {
183
- delete ret.password;
184
- delete ret.mfaSecret;
185
- delete ret.__v;
186
- ret.id = ret._id;
187
- delete ret._id;
188
- return ret;
189
- },
190
- });
191
- ```
192
- (And easy to forget on a new sensitive field. Doesn't fire on `.lean()`.)
193
-
194
- ### After
195
- ```typescript
196
- // user.resource.ts
197
- import { fields } from '@classytic/arc';
198
-
199
- defineResource({
200
- name: 'user',
201
- schemaOptions: {
202
- fieldRules: {
203
- password: fields.hidden(),
204
- mfaSecret: fields.hidden(),
205
- salary: fields.visibleTo(['admin', 'hr']),
206
- email: fields.redactFor(['viewer'], '***'),
207
- },
208
- },
209
- });
210
- ```
211
- Applies at framework serialization for both REST and MCP. Works with lean reads. New sensitive fields go in one place.
212
-
213
- ---
214
-
215
- ## §4. Hand-coded soft-delete → `presets: ['softDelete']`
216
-
217
- ### Before
218
- ```typescript
219
- defineResource({
220
- name: 'order',
221
- schemaOptions: { fieldRules: { deletedAt: { type: 'date', nullable: true } } },
222
- routes: [
223
- { method: 'GET', path: '/deleted', handler: 'listDeleted', permissions: requireRoles(['admin']) },
224
- { method: 'POST', path: '/:id/restore', handler: 'restore', permissions: requireRoles(['admin']) },
225
- ],
226
- hooks: {
227
- afterDelete: async (ctx) => repo.updateOne(ctx.meta.id, { deletedAt: new Date() }),
228
- },
229
- });
230
- // Plus filter `deletedAt: null` injected in every read manually
231
- ```
232
-
233
- ### After
234
- ```typescript
235
- defineResource({
236
- name: 'order',
237
- presets: ['softDelete'], // adds /deleted, /:id/restore, deletedAt field, filter injection
238
- });
239
- ```
240
- Deep config: `{ name: 'softDelete', deletedField: 'archivedAt' }`.
241
-
242
- ---
243
-
244
- ## §5. Manual events → declarative `events` + `hooks`
245
-
246
- ### Before
247
- ```typescript
248
- fastify.post('/orders', async (req, reply) => {
249
- const order = await orderRepo.create(req.body);
250
- await eventBus.emit('order.created', { id: order._id, customer: order.customerId });
251
- return order;
252
- });
253
- fastify.patch('/orders/:id', async (req) => {
254
- const order = await orderRepo.update(req.params.id, req.body);
255
- // forgot to emit 'order.updated' — silent inconsistency
256
- return order;
257
- });
258
- fastify.post('/orders/:id/refund', async (req) => {
259
- await orderRepo.refund(req.params.id);
260
- await eventBus.emit('order.refunded', { id: req.params.id });
261
- });
262
- ```
263
-
264
- ### After
265
- ```typescript
266
- defineResource({
267
- name: 'order',
268
- events: {
269
- created: {},
270
- updated: {},
271
- deleted: {},
272
- refunded: { description: 'Order refunded', schema: { reason: 'string' } },
273
- },
274
- actions: {
275
- refund: {
276
- handler: async (id, data, req) => {
277
- const result = await orderRepo.refund(id, data.reason);
278
- await req.fastify.events.publish('order.refunded', { id, reason: data.reason });
279
- return result;
280
- },
281
- permissions: requireRoles(['admin']),
282
- },
283
- },
284
- });
285
- ```
286
- CRUD events fire automatically. Custom events stay in handlers but are now co-located with permissions.
287
-
288
- For at-least-once delivery, wire `EventOutbox`:
289
- ```typescript
290
- import { EventOutbox } from '@classytic/arc/events';
291
- new EventOutbox({ repository: outboxRepo, transport });
292
- ```
293
-
294
- ---
295
-
296
- ## §6. Manual cache + invalidation → `cache` config
297
-
298
- ### Before
299
- ```typescript
300
- fastify.get('/products', async (req) => {
301
- const cached = await redis.get('products-list');
302
- if (cached) return JSON.parse(cached);
303
- const items = await Product.find({});
304
- await redis.setex('products-list', 30, JSON.stringify(items));
305
- return items;
306
- });
307
- fastify.post('/products', async (req) => {
308
- const item = await Product.create(req.body);
309
- await redis.del('products-list');
310
- await redis.del(`product-${item._id}`);
311
- return item;
312
- });
313
- ```
314
-
315
- ### After
316
- ```typescript
317
- const app = await createApp({
318
- arcPlugins: { queryCache: true },
319
- stores: { queryCache: new RedisCacheStore({ client: redis }) },
320
- });
321
-
322
- defineResource({
323
- name: 'product',
324
- cache: { staleTime: 30, gcTime: 300, tags: ['catalog'] },
325
- });
326
- ```
327
- Mutations bump the resource version; reads see the new state on next miss. Response: `x-cache: HIT | STALE | MISS`.
328
-
329
- For cross-resource invalidation:
330
- ```typescript
331
- cache: { tags: ['catalog'], invalidateOn: { 'category.*': ['catalog'] } }
332
- ```
333
-
334
- ---
335
-
336
- ## §7. `req.user._id` access → scope accessors
337
-
338
- ### Before
339
- ```typescript
340
- app.post('/orders', async (req) => {
341
- const userId = req.user._id; // crashes on public route
342
- const orgId = req.user.orgId; // undefined for service tokens
343
- return orderRepo.create({ ...req.body, userId, orgId });
344
- });
345
- ```
346
-
347
- ### After
348
- ```typescript
349
- import { getUserId, getOrgId, isAuthenticated, hasOrgAccess } from '@classytic/arc/scope';
350
-
351
- app.post('/orders', async (req, reply) => {
352
- if (!isAuthenticated(req.scope)) return reply.unauthorized();
353
- return orderRepo.create({
354
- ...req.body,
355
- userId: getUserId(req.scope),
356
- orgId: getOrgId(req.scope),
357
- });
358
- });
359
- ```
360
- Even better — make it declarative via permission `filters` and let arc inject `userId`/`orgId` server-side:
361
- ```typescript
362
- permissions: { create: allOf(requireAuth(), requireOrgMembership()) },
363
- hooks: {
364
- beforeCreate: async (ctx) => {
365
- ctx.data.userId = getUserId(ctx.request.scope);
366
- ctx.data.orgId = getOrgId(ctx.request.scope);
367
- },
368
- },
369
- // Or use ownedByUser + multiTenant presets which inject these automatically.
370
- ```
371
-
372
- ---
373
-
374
- ## §8. Driver imports leaking out of adapters
375
-
376
- ### Before
377
- ```typescript
378
- // services/orderService.ts — service layer importing mongoose
379
- import mongoose from 'mongoose';
380
- import { Order } from '../models/order.js';
381
-
382
- export class OrderService {
383
- async fulfill(id: string) {
384
- const session = await mongoose.startSession();
385
- return session.withTransaction(async () => {
386
- const order = await Order.findById(id).session(session);
387
- // ...
388
- });
389
- }
390
- }
391
- ```
392
-
393
- ### After
394
- ```typescript
395
- // services/orderService.ts — DB-agnostic
396
- import type { RepositoryLike } from '@classytic/repo-core/adapter';
397
-
398
- export class OrderService {
399
- constructor(private orderRepo: RepositoryLike<Order>) {}
400
-
401
- async fulfill(id: string) {
402
- return this.orderRepo.withTransaction!(async (session) => {
403
- const order = await this.orderRepo.getOne(id, { session });
404
- // ...
405
- });
406
- }
407
- }
408
-
409
- // adapters/order.adapter.ts — only place mongoose appears
410
- import mongoose from 'mongoose';
411
- import { Repository } from '@classytic/mongokit';
412
- import { Order } from '../models/order.js';
413
- export const orderRepo = new Repository(Order);
414
- ```
415
- Service tests now use any `RepositoryLike` mock — no `mongodb-memory-server` required for unit tests.
416
-
417
- ---
418
-
419
- ## §9. Hand-rolled MCP tools → `mcpPlugin`
420
-
421
- ### Before
422
- ```typescript
423
- // mcp/tools.ts — 200+ LOC of MCP plumbing
424
- const tools = [
425
- {
426
- name: 'list_products',
427
- description: 'List products',
428
- inputSchema: { type: 'object', properties: { status: { type: 'string' } } },
429
- handler: async (input) => Product.find(input).limit(20).lean(),
430
- },
431
- { name: 'create_product', /* ... */ },
432
- ];
433
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
434
- const tool = tools.find(t => t.name === request.params.name);
435
- return tool.handler(request.params.arguments);
436
- });
437
- ```
438
-
439
- ### After
440
- ```typescript
441
- import { mcpPlugin } from '@classytic/arc/mcp';
442
-
443
- await app.register(mcpPlugin, {
444
- resources: [productResource, orderResource],
445
- auth: false, // or getAuth() / custom
446
- exclude: ['credential'],
447
- });
448
- // 5 CRUD tools + custom routes + actions auto-generated per resource.
449
- // Permissions and field rules carry through.
450
- ```
451
- For domain-specific tools, use `extraTools: buildMcpToolsFromBridges([...])`.
452
-
453
- ---
454
-
455
- ## §10. Hand-coded `Idempotency-Key` → `idempotencyPlugin`
456
-
457
- ### Before
458
- ```typescript
459
- fastify.post('/payments', async (req) => {
460
- const key = req.headers['idempotency-key'];
461
- if (key) {
462
- const existing = await Idempotency.findOne({ key });
463
- if (existing) return existing.response;
464
- }
465
- const result = await processPayment(req.body);
466
- if (key) await Idempotency.create({ key, response: result, expiresAt: ... });
467
- return result;
468
- });
469
- ```
470
-
471
- ### After
472
- ```typescript
473
- import { idempotencyPlugin } from '@classytic/arc/idempotency';
474
-
475
- await app.register(idempotencyPlugin, {
476
- repository: idempotencyRepo, // any RepositoryLike with getOne/deleteMany/findOneAndUpdate
477
- ttlMs: 24 * 3600_000,
478
- });
479
- ```
480
- Applies to all mutating routes that accept `Idempotency-Key` header.
481
-
482
- ---
483
-
484
- ## §11. Manual job queue wiring → `jobsPlugin`
485
-
486
- ### Before
487
- ```typescript
488
- import { Queue, Worker } from 'bullmq';
489
- const emailQueue = new Queue('email', { connection: redis });
490
- new Worker('email', processor, { connection: redis });
491
- fastify.post('/users', async (req) => {
492
- const user = await User.create(req.body);
493
- await emailQueue.add('welcome', { userId: user._id });
494
- });
495
- ```
496
-
497
- ### After
498
- ```typescript
499
- import { jobsPlugin } from '@classytic/arc/integrations/jobs';
500
-
501
- await app.register(jobsPlugin, {
502
- queues: { email: { handler: emailHandler } },
503
- redis,
504
- });
505
-
506
- defineResource({
507
- name: 'user',
508
- events: { created: {} },
509
- hooks: {
510
- afterCreate: async (ctx) => {
511
- await ctx.fastify.jobs.email.add('welcome', { userId: ctx.result._id });
512
- },
513
- },
514
- });
515
- ```
516
- Or wire from an event handler subscribed to `user.created`.
517
-
518
- ---
519
-
520
- ## §12. Custom controller → mixin composition
521
-
522
- ### Before — full custom controller (loses preset wiring)
523
- ```typescript
524
- class OrderController {
525
- constructor(private repo: OrderRepository) {}
526
- async list(req) { /* manual pagination */ }
527
- async getById(req) { /* manual lookup */ }
528
- async create(req) { /* manual validation + permission */ }
529
- async update(req) { /* ... */ }
530
- async delete(req) { /* ... */ }
531
- async restore(req) { /* manual soft-delete handling */ }
532
- async bulkCreate(req) { /* manual bulk */ }
533
- }
534
- ```
535
-
536
- ### After — mixin composition
537
- ```typescript
538
- import { BaseCrudController, SoftDeleteMixin, BulkMixin } from '@classytic/arc';
539
-
540
- class OrderController extends SoftDeleteMixin(BulkMixin(BaseCrudController))<Order> {
541
- // domain methods only
542
- async fulfill(id, data, req) { return orderService.fulfill(id, getUserId(req.scope)); }
543
- }
544
-
545
- defineResource({
546
- name: 'order',
547
- controller: new OrderController(orderRepo, { resourceName: 'order' }),
548
- presets: ['softDelete', 'bulk'],
549
- routes: [{ method: 'POST', path: '/:id/fulfill', handler: 'fulfill', permissions: requireRoles(['admin']) }],
550
- });
551
- ```
552
- Available mixins: `SoftDeleteMixin`, `TreeMixin`, `SlugMixin`, `BulkMixin`. Or skip the controller entirely and let arc auto-build `BaseController`.
553
-
554
- ---
555
-
556
- ## §13. Multi-tenancy from middleware → `multiTenantPreset`
557
-
558
- ### Before
559
- ```typescript
560
- app.addHook('preHandler', async (req, reply) => {
561
- const orgId = req.headers['x-org-id'];
562
- if (!orgId) return reply.code(400).send({ error: 'Missing org' });
563
- req.orgId = orgId;
564
- });
565
- fastify.get('/jobs', async (req) => Job.find({ orgId: req.orgId }));
566
- fastify.post('/jobs', async (req) => Job.create({ ...req.body, orgId: req.orgId }));
567
- // Repeated across every resource and every CRUD method
568
- ```
569
-
570
- ### After
571
- ```typescript
572
- defineResource({
573
- name: 'job',
574
- presets: [{ name: 'multiTenant', tenantField: 'organizationId' }],
575
- });
576
- // Tenant filter auto-applied to every read; org auto-injected on create/update;
577
- // body 'organizationId' overwritten with caller's scope on update (closes tenant-hop).
578
- ```
579
-
580
- For multi-level (org + branch + project):
581
- ```typescript
582
- import { multiTenantPreset } from '@classytic/arc/presets';
583
-
584
- defineResource({
585
- presets: [multiTenantPreset({
586
- tenantFields: [
587
- { field: 'organizationId', type: 'org' },
588
- { field: 'branchId', contextKey: 'branchId' },
589
- { field: 'projectId', contextKey: 'projectId' },
590
- ],
591
- })],
592
- });
593
- ```
594
- Populate `scope.context` and `scope.ancestorOrgIds` in the auth function — see `references/multi-tenancy.md` in the `arc` skill.
595
-
596
- ---
597
-
598
- ## §14. Test setup: hand-rolled in-memory Mongo → `createTestApp`
599
-
600
- ### Before
601
- ```typescript
602
- import { MongoMemoryServer } from 'mongodb-memory-server';
603
- import mongoose from 'mongoose';
604
- let server;
605
- beforeAll(async () => {
606
- server = await MongoMemoryServer.create();
607
- await mongoose.connect(server.getUri());
608
- });
609
- afterAll(async () => { await mongoose.disconnect(); await server.stop(); });
610
- test('creates product', async () => {
611
- const app = buildApp(); /* ... custom auth header construction ... */
612
- });
613
- ```
614
-
615
- ### After
616
- ```typescript
617
- import { createTestApp, expectArc } from '@classytic/arc/testing';
618
-
619
- test('creates product', async () => {
620
- const ctx = await createTestApp({
621
- resources: [productResource],
622
- authMode: 'jwt',
623
- connectMongoose: true,
624
- });
625
- ctx.auth.register('admin', { user: { id: '1', role: 'admin' }, orgId: 'org-1' });
626
-
627
- const res = await ctx.app.inject({
628
- method: 'POST', url: '/products',
629
- headers: ctx.auth.as('admin').headers,
630
- payload: { name: 'Widget', price: 10 },
631
- });
632
- expectArc(res).ok().hidesField('password');
633
-
634
- await ctx.close();
635
- });
636
- ```
637
- Or `createHttpTestHarness(productResource)` to auto-generate ~16 CRUD/permission/validation tests per resource.
638
-
639
- ---
640
-
641
- ## Rollout strategy for large projects
642
-
643
- 1. **Pick one resource** with thin business logic (no domain edge cases). Migrate end-to-end.
644
- 2. **Land the auth + scope changes first.** They unlock declarative permissions for every subsequent resource.
645
- 3. **Migrate adapters before resources.** A resource without an adapter migration is a half-step.
646
- 4. **Bundle preset adoption with the relevant resource.** Don't introduce `softDelete` as a separate PR — change the resource that needs it.
647
- 5. **Keep old routes alongside new for one release.** Tag with `versioningPlugin` or a path prefix; cut over after consumer confirmation.
648
- 6. **Run `arc docs ./openapi.json`** at the end and diff against the hand-maintained spec — discrepancies are bugs in either side.
649
- 7. **Drop the old code** once the report shows zero hits for the §3 / §4 / §7 patterns.