@blazetrails/actionpack 0.0.0-stage → 0.1.0-alpha0.1

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 (590) hide show
  1. package/LICENSE +21 -0
  2. package/dist/abstract-controller/asset-paths.d.ts +18 -0
  3. package/dist/abstract-controller/asset-paths.js +8 -0
  4. package/dist/abstract-controller/asset-paths.js.map +1 -0
  5. package/dist/abstract-controller/base.d.ts +63 -0
  6. package/dist/abstract-controller/base.js +235 -0
  7. package/dist/abstract-controller/base.js.map +1 -0
  8. package/dist/abstract-controller/caching/fragments.d.ts +39 -0
  9. package/dist/abstract-controller/caching/fragments.js +119 -0
  10. package/dist/abstract-controller/caching/fragments.js.map +1 -0
  11. package/dist/abstract-controller/caching.d.ts +40 -0
  12. package/dist/abstract-controller/caching.js +57 -0
  13. package/dist/abstract-controller/caching.js.map +1 -0
  14. package/dist/abstract-controller/callbacks.d.ts +101 -0
  15. package/dist/abstract-controller/callbacks.js +183 -0
  16. package/dist/abstract-controller/callbacks.js.map +1 -0
  17. package/dist/abstract-controller/collector.d.ts +10 -0
  18. package/dist/abstract-controller/collector.js +69 -0
  19. package/dist/abstract-controller/collector.js.map +1 -0
  20. package/dist/abstract-controller/deprecator.d.ts +3 -0
  21. package/dist/abstract-controller/deprecator.js +7 -0
  22. package/dist/abstract-controller/deprecator.js.map +1 -0
  23. package/dist/abstract-controller/error.d.ts +5 -0
  24. package/dist/abstract-controller/error.js +5 -0
  25. package/dist/abstract-controller/error.js.map +1 -0
  26. package/dist/abstract-controller/helpers.d.ts +67 -0
  27. package/dist/abstract-controller/helpers.js +177 -0
  28. package/dist/abstract-controller/helpers.js.map +1 -0
  29. package/dist/abstract-controller/index.d.ts +16 -0
  30. package/dist/abstract-controller/index.js +15 -0
  31. package/dist/abstract-controller/index.js.map +1 -0
  32. package/dist/abstract-controller/logger.d.ts +7 -0
  33. package/dist/abstract-controller/logger.js +10 -0
  34. package/dist/abstract-controller/logger.js.map +1 -0
  35. package/dist/abstract-controller/rendering.d.ts +54 -0
  36. package/dist/abstract-controller/rendering.js +116 -0
  37. package/dist/abstract-controller/rendering.js.map +1 -0
  38. package/dist/abstract-controller/trailties/routes-helpers.d.ts +34 -0
  39. package/dist/abstract-controller/trailties/routes-helpers.js +149 -0
  40. package/dist/abstract-controller/trailties/routes-helpers.js.map +1 -0
  41. package/dist/abstract-controller/translation.d.ts +29 -0
  42. package/dist/abstract-controller/translation.js +31 -0
  43. package/dist/abstract-controller/translation.js.map +1 -0
  44. package/dist/abstract-controller/url-for.d.ts +24 -0
  45. package/dist/abstract-controller/url-for.js +33 -0
  46. package/dist/abstract-controller/url-for.js.map +1 -0
  47. package/dist/action-controller/api/api-rendering.d.ts +6 -0
  48. package/dist/action-controller/api/api-rendering.js +16 -0
  49. package/dist/action-controller/api/api-rendering.js.map +1 -0
  50. package/dist/action-controller/api.d.ts +66 -0
  51. package/dist/action-controller/api.js +73 -0
  52. package/dist/action-controller/api.js.map +1 -0
  53. package/dist/action-controller/base.d.ts +416 -0
  54. package/dist/action-controller/base.js +153 -0
  55. package/dist/action-controller/base.js.map +1 -0
  56. package/dist/action-controller/caching.d.ts +19 -0
  57. package/dist/action-controller/caching.js +75 -0
  58. package/dist/action-controller/caching.js.map +1 -0
  59. package/dist/action-controller/deprecator.d.ts +4 -0
  60. package/dist/action-controller/deprecator.js +7 -0
  61. package/dist/action-controller/deprecator.js.map +1 -0
  62. package/dist/action-controller/form-builder.d.ts +17 -0
  63. package/dist/action-controller/form-builder.js +18 -0
  64. package/dist/action-controller/form-builder.js.map +1 -0
  65. package/dist/action-controller/index.d.ts +31 -0
  66. package/dist/action-controller/index.js +28 -0
  67. package/dist/action-controller/index.js.map +1 -0
  68. package/dist/action-controller/log-subscriber.d.ts +17 -0
  69. package/dist/action-controller/log-subscriber.js +111 -0
  70. package/dist/action-controller/log-subscriber.js.map +1 -0
  71. package/dist/action-controller/metal/allow-browser.d.ts +71 -0
  72. package/dist/action-controller/metal/allow-browser.js +128 -0
  73. package/dist/action-controller/metal/allow-browser.js.map +1 -0
  74. package/dist/action-controller/metal/basic-implicit-render.d.ts +13 -0
  75. package/dist/action-controller/metal/basic-implicit-render.js +14 -0
  76. package/dist/action-controller/metal/basic-implicit-render.js.map +1 -0
  77. package/dist/action-controller/metal/conditional-get.d.ts +57 -0
  78. package/dist/action-controller/metal/conditional-get.js +96 -0
  79. package/dist/action-controller/metal/conditional-get.js.map +1 -0
  80. package/dist/action-controller/metal/content-security-policy.d.ts +37 -0
  81. package/dist/action-controller/metal/content-security-policy.js +54 -0
  82. package/dist/action-controller/metal/content-security-policy.js.map +1 -0
  83. package/dist/action-controller/metal/cookies.d.ts +15 -0
  84. package/dist/action-controller/metal/cookies.js +15 -0
  85. package/dist/action-controller/metal/cookies.js.map +1 -0
  86. package/dist/action-controller/metal/data-streaming.d.ts +48 -0
  87. package/dist/action-controller/metal/data-streaming.js +73 -0
  88. package/dist/action-controller/metal/data-streaming.js.map +1 -0
  89. package/dist/action-controller/metal/default-headers.d.ts +12 -0
  90. package/dist/action-controller/metal/default-headers.js +13 -0
  91. package/dist/action-controller/metal/default-headers.js.map +1 -0
  92. package/dist/action-controller/metal/etag-with-flash.d.ts +2 -0
  93. package/dist/action-controller/metal/etag-with-flash.js +17 -0
  94. package/dist/action-controller/metal/etag-with-flash.js.map +1 -0
  95. package/dist/action-controller/metal/etag-with-template-digest.d.ts +23 -0
  96. package/dist/action-controller/metal/etag-with-template-digest.js +41 -0
  97. package/dist/action-controller/metal/etag-with-template-digest.js.map +1 -0
  98. package/dist/action-controller/metal/exceptions.d.ts +50 -0
  99. package/dist/action-controller/metal/exceptions.js +86 -0
  100. package/dist/action-controller/metal/exceptions.js.map +1 -0
  101. package/dist/action-controller/metal/flash.d.ts +42 -0
  102. package/dist/action-controller/metal/flash.js +59 -0
  103. package/dist/action-controller/metal/flash.js.map +1 -0
  104. package/dist/action-controller/metal/head.d.ts +18 -0
  105. package/dist/action-controller/metal/head.js +51 -0
  106. package/dist/action-controller/metal/head.js.map +1 -0
  107. package/dist/action-controller/metal/helpers.d.ts +38 -0
  108. package/dist/action-controller/metal/helpers.js +51 -0
  109. package/dist/action-controller/metal/helpers.js.map +1 -0
  110. package/dist/action-controller/metal/http-authentication.d.ts +82 -0
  111. package/dist/action-controller/metal/http-authentication.js +306 -0
  112. package/dist/action-controller/metal/http-authentication.js.map +1 -0
  113. package/dist/action-controller/metal/implicit-render.d.ts +47 -0
  114. package/dist/action-controller/metal/implicit-render.js +62 -0
  115. package/dist/action-controller/metal/implicit-render.js.map +1 -0
  116. package/dist/action-controller/metal/instrumentation.d.ts +39 -0
  117. package/dist/action-controller/metal/instrumentation.js +110 -0
  118. package/dist/action-controller/metal/instrumentation.js.map +1 -0
  119. package/dist/action-controller/metal/live.d.ts +103 -0
  120. package/dist/action-controller/metal/live.js +284 -0
  121. package/dist/action-controller/metal/live.js.map +1 -0
  122. package/dist/action-controller/metal/logging.d.ts +14 -0
  123. package/dist/action-controller/metal/logging.js +10 -0
  124. package/dist/action-controller/metal/logging.js.map +1 -0
  125. package/dist/action-controller/metal/mime-responds.d.ts +54 -0
  126. package/dist/action-controller/metal/mime-responds.js +145 -0
  127. package/dist/action-controller/metal/mime-responds.js.map +1 -0
  128. package/dist/action-controller/metal/parameter-encoding.d.ts +26 -0
  129. package/dist/action-controller/metal/parameter-encoding.js +48 -0
  130. package/dist/action-controller/metal/parameter-encoding.js.map +1 -0
  131. package/dist/action-controller/metal/params-wrapper.d.ts +96 -0
  132. package/dist/action-controller/metal/params-wrapper.js +218 -0
  133. package/dist/action-controller/metal/params-wrapper.js.map +1 -0
  134. package/dist/action-controller/metal/permissions-policy.d.ts +15 -0
  135. package/dist/action-controller/metal/permissions-policy.js +19 -0
  136. package/dist/action-controller/metal/permissions-policy.js.map +1 -0
  137. package/dist/action-controller/metal/rate-limiting.d.ts +48 -0
  138. package/dist/action-controller/metal/rate-limiting.js +32 -0
  139. package/dist/action-controller/metal/rate-limiting.js.map +1 -0
  140. package/dist/action-controller/metal/redirecting.d.ts +76 -0
  141. package/dist/action-controller/metal/redirecting.js +142 -0
  142. package/dist/action-controller/metal/redirecting.js.map +1 -0
  143. package/dist/action-controller/metal/renderers.d.ts +37 -0
  144. package/dist/action-controller/metal/renderers.js +108 -0
  145. package/dist/action-controller/metal/renderers.js.map +1 -0
  146. package/dist/action-controller/metal/rendering.d.ts +78 -0
  147. package/dist/action-controller/metal/rendering.js +154 -0
  148. package/dist/action-controller/metal/rendering.js.map +1 -0
  149. package/dist/action-controller/metal/request-forgery-protection.d.ts +269 -0
  150. package/dist/action-controller/metal/request-forgery-protection.js +488 -0
  151. package/dist/action-controller/metal/request-forgery-protection.js.map +1 -0
  152. package/dist/action-controller/metal/rescue.d.ts +16 -0
  153. package/dist/action-controller/metal/rescue.js +25 -0
  154. package/dist/action-controller/metal/rescue.js.map +1 -0
  155. package/dist/action-controller/metal/streaming.d.ts +14 -0
  156. package/dist/action-controller/metal/streaming.js +18 -0
  157. package/dist/action-controller/metal/streaming.js.map +1 -0
  158. package/dist/action-controller/metal/strong-parameters.d.ts +236 -0
  159. package/dist/action-controller/metal/strong-parameters.js +728 -0
  160. package/dist/action-controller/metal/strong-parameters.js.map +1 -0
  161. package/dist/action-controller/metal/testing.d.ts +11 -0
  162. package/dist/action-controller/metal/testing.js +20 -0
  163. package/dist/action-controller/metal/testing.js.map +1 -0
  164. package/dist/action-controller/metal/url-for.d.ts +12 -0
  165. package/dist/action-controller/metal/url-for.js +42 -0
  166. package/dist/action-controller/metal/url-for.js.map +1 -0
  167. package/dist/action-controller/metal.d.ts +68 -0
  168. package/dist/action-controller/metal.js +229 -0
  169. package/dist/action-controller/metal.js.map +1 -0
  170. package/dist/action-controller/renderer.d.ts +37 -0
  171. package/dist/action-controller/renderer.js +98 -0
  172. package/dist/action-controller/renderer.js.map +1 -0
  173. package/dist/action-controller/template-assertions.d.ts +8 -0
  174. package/dist/action-controller/template-assertions.js +8 -0
  175. package/dist/action-controller/template-assertions.js.map +1 -0
  176. package/dist/action-controller/test-case.d.ts +188 -0
  177. package/dist/action-controller/test-case.js +511 -0
  178. package/dist/action-controller/test-case.js.map +1 -0
  179. package/dist/action-controller/trailties/helpers.d.ts +9 -0
  180. package/dist/action-controller/trailties/helpers.js +23 -0
  181. package/dist/action-controller/trailties/helpers.js.map +1 -0
  182. package/dist/action-dispatch/action-dispatch.d.ts +4 -0
  183. package/dist/action-dispatch/action-dispatch.js +6 -0
  184. package/dist/action-dispatch/action-dispatch.js.map +1 -0
  185. package/dist/action-dispatch/constants.d.ts +11 -0
  186. package/dist/action-dispatch/constants.js +37 -0
  187. package/dist/action-dispatch/constants.js.map +1 -0
  188. package/dist/action-dispatch/deprecator.d.ts +23 -0
  189. package/dist/action-dispatch/deprecator.js +26 -0
  190. package/dist/action-dispatch/deprecator.js.map +1 -0
  191. package/dist/action-dispatch/http/cache.d.ts +73 -0
  192. package/dist/action-dispatch/http/cache.js +287 -0
  193. package/dist/action-dispatch/http/cache.js.map +1 -0
  194. package/dist/action-dispatch/http/content-disposition.d.ts +14 -0
  195. package/dist/action-dispatch/http/content-disposition.js +39 -0
  196. package/dist/action-dispatch/http/content-disposition.js.map +1 -0
  197. package/dist/action-dispatch/http/content-security-policy.d.ts +114 -0
  198. package/dist/action-dispatch/http/content-security-policy.js +426 -0
  199. package/dist/action-dispatch/http/content-security-policy.js.map +1 -0
  200. package/dist/action-dispatch/http/filter-parameters.d.ts +36 -0
  201. package/dist/action-dispatch/http/filter-parameters.js +69 -0
  202. package/dist/action-dispatch/http/filter-parameters.js.map +1 -0
  203. package/dist/action-dispatch/http/filter-redirect.d.ts +20 -0
  204. package/dist/action-dispatch/http/filter-redirect.js +54 -0
  205. package/dist/action-dispatch/http/filter-redirect.js.map +1 -0
  206. package/dist/action-dispatch/http/headers.d.ts +18 -0
  207. package/dist/action-dispatch/http/headers.js +87 -0
  208. package/dist/action-dispatch/http/headers.js.map +1 -0
  209. package/dist/action-dispatch/http/index.d.ts +16 -0
  210. package/dist/action-dispatch/http/index.js +16 -0
  211. package/dist/action-dispatch/http/index.js.map +1 -0
  212. package/dist/action-dispatch/http/mime-negotiation.d.ts +38 -0
  213. package/dist/action-dispatch/http/mime-negotiation.js +151 -0
  214. package/dist/action-dispatch/http/mime-negotiation.js.map +1 -0
  215. package/dist/action-dispatch/http/mime-type.d.ts +139 -0
  216. package/dist/action-dispatch/http/mime-type.js +416 -0
  217. package/dist/action-dispatch/http/mime-type.js.map +1 -0
  218. package/dist/action-dispatch/http/mime-types.d.ts +7 -0
  219. package/dist/action-dispatch/http/mime-types.js +46 -0
  220. package/dist/action-dispatch/http/mime-types.js.map +1 -0
  221. package/dist/action-dispatch/http/param-builder.d.ts +47 -0
  222. package/dist/action-dispatch/http/param-builder.js +255 -0
  223. package/dist/action-dispatch/http/param-builder.js.map +1 -0
  224. package/dist/action-dispatch/http/param-error.d.ts +14 -0
  225. package/dist/action-dispatch/http/param-error.js +34 -0
  226. package/dist/action-dispatch/http/param-error.js.map +1 -0
  227. package/dist/action-dispatch/http/parameters.d.ts +48 -0
  228. package/dist/action-dispatch/http/parameters.js +136 -0
  229. package/dist/action-dispatch/http/parameters.js.map +1 -0
  230. package/dist/action-dispatch/http/permissions-policy.d.ts +58 -0
  231. package/dist/action-dispatch/http/permissions-policy.js +289 -0
  232. package/dist/action-dispatch/http/permissions-policy.js.map +1 -0
  233. package/dist/action-dispatch/http/query-parser.d.ts +9 -0
  234. package/dist/action-dispatch/http/query-parser.js +63 -0
  235. package/dist/action-dispatch/http/query-parser.js.map +1 -0
  236. package/dist/action-dispatch/http/rack-cache.d.ts +39 -0
  237. package/dist/action-dispatch/http/rack-cache.js +67 -0
  238. package/dist/action-dispatch/http/rack-cache.js.map +1 -0
  239. package/dist/action-dispatch/http/request.d.ts +239 -0
  240. package/dist/action-dispatch/http/request.js +554 -0
  241. package/dist/action-dispatch/http/request.js.map +1 -0
  242. package/dist/action-dispatch/http/response.d.ts +226 -0
  243. package/dist/action-dispatch/http/response.js +658 -0
  244. package/dist/action-dispatch/http/response.js.map +1 -0
  245. package/dist/action-dispatch/http/upload.d.ts +26 -0
  246. package/dist/action-dispatch/http/upload.js +53 -0
  247. package/dist/action-dispatch/http/upload.js.map +1 -0
  248. package/dist/action-dispatch/http/url.d.ts +55 -0
  249. package/dist/action-dispatch/http/url.js +218 -0
  250. package/dist/action-dispatch/http/url.js.map +1 -0
  251. package/dist/action-dispatch/index.d.ts +48 -0
  252. package/dist/action-dispatch/index.js +50 -0
  253. package/dist/action-dispatch/index.js.map +1 -0
  254. package/dist/action-dispatch/journey/formatter.d.ts +57 -0
  255. package/dist/action-dispatch/journey/formatter.js +247 -0
  256. package/dist/action-dispatch/journey/formatter.js.map +1 -0
  257. package/dist/action-dispatch/journey/gtg/builder.d.ts +19 -0
  258. package/dist/action-dispatch/journey/gtg/builder.js +166 -0
  259. package/dist/action-dispatch/journey/gtg/builder.js.map +1 -0
  260. package/dist/action-dispatch/journey/gtg/index.d.ts +4 -0
  261. package/dist/action-dispatch/journey/gtg/index.js +4 -0
  262. package/dist/action-dispatch/journey/gtg/index.js.map +1 -0
  263. package/dist/action-dispatch/journey/gtg/simulator.d.ts +17 -0
  264. package/dist/action-dispatch/journey/gtg/simulator.js +36 -0
  265. package/dist/action-dispatch/journey/gtg/simulator.js.map +1 -0
  266. package/dist/action-dispatch/journey/gtg/transition-table.d.ts +38 -0
  267. package/dist/action-dispatch/journey/gtg/transition-table.js +258 -0
  268. package/dist/action-dispatch/journey/gtg/transition-table.js.map +1 -0
  269. package/dist/action-dispatch/journey/index.d.ts +15 -0
  270. package/dist/action-dispatch/journey/index.js +15 -0
  271. package/dist/action-dispatch/journey/index.js.map +1 -0
  272. package/dist/action-dispatch/journey/nfa/dot.d.ts +8 -0
  273. package/dist/action-dispatch/journey/nfa/dot.js +15 -0
  274. package/dist/action-dispatch/journey/nfa/dot.js.map +1 -0
  275. package/dist/action-dispatch/journey/nodes/node.d.ts +99 -0
  276. package/dist/action-dispatch/journey/nodes/node.js +223 -0
  277. package/dist/action-dispatch/journey/nodes/node.js.map +1 -0
  278. package/dist/action-dispatch/journey/parser.d.ts +25 -0
  279. package/dist/action-dispatch/journey/parser.js +96 -0
  280. package/dist/action-dispatch/journey/parser.js.map +1 -0
  281. package/dist/action-dispatch/journey/path/index.d.ts +2 -0
  282. package/dist/action-dispatch/journey/path/index.js +2 -0
  283. package/dist/action-dispatch/journey/path/index.js.map +1 -0
  284. package/dist/action-dispatch/journey/path/pattern.d.ts +66 -0
  285. package/dist/action-dispatch/journey/path/pattern.js +268 -0
  286. package/dist/action-dispatch/journey/path/pattern.js.map +1 -0
  287. package/dist/action-dispatch/journey/route.d.ts +151 -0
  288. package/dist/action-dispatch/journey/route.js +276 -0
  289. package/dist/action-dispatch/journey/route.js.map +1 -0
  290. package/dist/action-dispatch/journey/router/utils.d.ts +29 -0
  291. package/dist/action-dispatch/journey/router/utils.js +72 -0
  292. package/dist/action-dispatch/journey/router/utils.js.map +1 -0
  293. package/dist/action-dispatch/journey/router.d.ts +40 -0
  294. package/dist/action-dispatch/journey/router.js +146 -0
  295. package/dist/action-dispatch/journey/router.js.map +1 -0
  296. package/dist/action-dispatch/journey/routes.d.ts +29 -0
  297. package/dist/action-dispatch/journey/routes.js +76 -0
  298. package/dist/action-dispatch/journey/routes.js.map +1 -0
  299. package/dist/action-dispatch/journey/scanner.d.ts +28 -0
  300. package/dist/action-dispatch/journey/scanner.js +90 -0
  301. package/dist/action-dispatch/journey/scanner.js.map +1 -0
  302. package/dist/action-dispatch/journey/visitors.d.ts +110 -0
  303. package/dist/action-dispatch/journey/visitors.js +331 -0
  304. package/dist/action-dispatch/journey/visitors.js.map +1 -0
  305. package/dist/action-dispatch/journey/visualizer/fsm.css +30 -0
  306. package/dist/action-dispatch/journey/visualizer/fsm.js +159 -0
  307. package/dist/action-dispatch/journey/visualizer/index.html.tse +52 -0
  308. package/dist/action-dispatch/journey/visualizer/index.html.tse.js +61 -0
  309. package/dist/action-dispatch/journey/visualizer/index.html.tse.js.map +1 -0
  310. package/dist/action-dispatch/log-subscriber.d.ts +5 -0
  311. package/dist/action-dispatch/log-subscriber.js +18 -0
  312. package/dist/action-dispatch/log-subscriber.js.map +1 -0
  313. package/dist/action-dispatch/middleware/actionable-exceptions.d.ts +14 -0
  314. package/dist/action-dispatch/middleware/actionable-exceptions.js +56 -0
  315. package/dist/action-dispatch/middleware/actionable-exceptions.js.map +1 -0
  316. package/dist/action-dispatch/middleware/assume-ssl.d.ts +9 -0
  317. package/dist/action-dispatch/middleware/assume-ssl.js +15 -0
  318. package/dist/action-dispatch/middleware/assume-ssl.js.map +1 -0
  319. package/dist/action-dispatch/middleware/callbacks.d.ts +15 -0
  320. package/dist/action-dispatch/middleware/callbacks.js +32 -0
  321. package/dist/action-dispatch/middleware/callbacks.js.map +1 -0
  322. package/dist/action-dispatch/middleware/cookies.d.ts +277 -0
  323. package/dist/action-dispatch/middleware/cookies.js +583 -0
  324. package/dist/action-dispatch/middleware/cookies.js.map +1 -0
  325. package/dist/action-dispatch/middleware/debug-exceptions.d.ts +53 -0
  326. package/dist/action-dispatch/middleware/debug-exceptions.js +218 -0
  327. package/dist/action-dispatch/middleware/debug-exceptions.js.map +1 -0
  328. package/dist/action-dispatch/middleware/debug-locks.d.ts +14 -0
  329. package/dist/action-dispatch/middleware/debug-locks.js +111 -0
  330. package/dist/action-dispatch/middleware/debug-locks.js.map +1 -0
  331. package/dist/action-dispatch/middleware/debug-view.d.ts +16 -0
  332. package/dist/action-dispatch/middleware/debug-view.js +81 -0
  333. package/dist/action-dispatch/middleware/debug-view.js.map +1 -0
  334. package/dist/action-dispatch/middleware/exception-wrapper.d.ts +98 -0
  335. package/dist/action-dispatch/middleware/exception-wrapper.js +323 -0
  336. package/dist/action-dispatch/middleware/exception-wrapper.js.map +1 -0
  337. package/dist/action-dispatch/middleware/executor.d.ts +25 -0
  338. package/dist/action-dispatch/middleware/executor.js +45 -0
  339. package/dist/action-dispatch/middleware/executor.js.map +1 -0
  340. package/dist/action-dispatch/middleware/flash.d.ts +93 -0
  341. package/dist/action-dispatch/middleware/flash.js +217 -0
  342. package/dist/action-dispatch/middleware/flash.js.map +1 -0
  343. package/dist/action-dispatch/middleware/host-authorization.d.ts +65 -0
  344. package/dist/action-dispatch/middleware/host-authorization.js +167 -0
  345. package/dist/action-dispatch/middleware/host-authorization.js.map +1 -0
  346. package/dist/action-dispatch/middleware/public-exceptions.d.ts +10 -0
  347. package/dist/action-dispatch/middleware/public-exceptions.js +66 -0
  348. package/dist/action-dispatch/middleware/public-exceptions.js.map +1 -0
  349. package/dist/action-dispatch/middleware/reloader.d.ts +4 -0
  350. package/dist/action-dispatch/middleware/reloader.js +4 -0
  351. package/dist/action-dispatch/middleware/reloader.js.map +1 -0
  352. package/dist/action-dispatch/middleware/remote-ip.d.ts +37 -0
  353. package/dist/action-dispatch/middleware/remote-ip.js +189 -0
  354. package/dist/action-dispatch/middleware/remote-ip.js.map +1 -0
  355. package/dist/action-dispatch/middleware/request-id.d.ts +19 -0
  356. package/dist/action-dispatch/middleware/request-id.js +30 -0
  357. package/dist/action-dispatch/middleware/request-id.js.map +1 -0
  358. package/dist/action-dispatch/middleware/server-timing.d.ts +25 -0
  359. package/dist/action-dispatch/middleware/server-timing.js +73 -0
  360. package/dist/action-dispatch/middleware/server-timing.js.map +1 -0
  361. package/dist/action-dispatch/middleware/session/abstract-store.d.ts +55 -0
  362. package/dist/action-dispatch/middleware/session/abstract-store.js +127 -0
  363. package/dist/action-dispatch/middleware/session/abstract-store.js.map +1 -0
  364. package/dist/action-dispatch/middleware/session/cache-store.d.ts +24 -0
  365. package/dist/action-dispatch/middleware/session/cache-store.js +63 -0
  366. package/dist/action-dispatch/middleware/session/cache-store.js.map +1 -0
  367. package/dist/action-dispatch/middleware/session/cookie-store.d.ts +58 -0
  368. package/dist/action-dispatch/middleware/session/cookie-store.js +102 -0
  369. package/dist/action-dispatch/middleware/session/cookie-store.js.map +1 -0
  370. package/dist/action-dispatch/middleware/session/index.d.ts +5 -0
  371. package/dist/action-dispatch/middleware/session/index.js +5 -0
  372. package/dist/action-dispatch/middleware/session/index.js.map +1 -0
  373. package/dist/action-dispatch/middleware/session/mem-cache-store.d.ts +21 -0
  374. package/dist/action-dispatch/middleware/session/mem-cache-store.js +26 -0
  375. package/dist/action-dispatch/middleware/session/mem-cache-store.js.map +1 -0
  376. package/dist/action-dispatch/middleware/show-exceptions.d.ts +15 -0
  377. package/dist/action-dispatch/middleware/show-exceptions.js +84 -0
  378. package/dist/action-dispatch/middleware/show-exceptions.js.map +1 -0
  379. package/dist/action-dispatch/middleware/ssl.d.ts +54 -0
  380. package/dist/action-dispatch/middleware/ssl.js +135 -0
  381. package/dist/action-dispatch/middleware/ssl.js.map +1 -0
  382. package/dist/action-dispatch/middleware/stack.d.ts +68 -0
  383. package/dist/action-dispatch/middleware/stack.js +188 -0
  384. package/dist/action-dispatch/middleware/stack.js.map +1 -0
  385. package/dist/action-dispatch/middleware/static.d.ts +60 -0
  386. package/dist/action-dispatch/middleware/static.js +168 -0
  387. package/dist/action-dispatch/middleware/static.js.map +1 -0
  388. package/dist/action-dispatch/middleware/templates/rescues/_actions.html.tse +13 -0
  389. package/dist/action-dispatch/middleware/templates/rescues/_actions.html.tse.js +47 -0
  390. package/dist/action-dispatch/middleware/templates/rescues/_actions.html.tse.js.map +1 -0
  391. package/dist/action-dispatch/middleware/templates/rescues/_actions.text.tse +0 -0
  392. package/dist/action-dispatch/middleware/templates/rescues/_actions.text.tse.js +11 -0
  393. package/dist/action-dispatch/middleware/templates/rescues/_actions.text.tse.js.map +1 -0
  394. package/dist/action-dispatch/middleware/templates/rescues/_message_and_suggestions.html.tse +23 -0
  395. package/dist/action-dispatch/middleware/templates/rescues/_message_and_suggestions.html.tse.js +60 -0
  396. package/dist/action-dispatch/middleware/templates/rescues/_message_and_suggestions.html.tse.js.map +1 -0
  397. package/dist/action-dispatch/middleware/templates/rescues/_request_and_response.html.tse +17 -0
  398. package/dist/action-dispatch/middleware/templates/rescues/_request_and_response.html.tse.js +46 -0
  399. package/dist/action-dispatch/middleware/templates/rescues/_request_and_response.html.tse.js.map +1 -0
  400. package/dist/action-dispatch/middleware/templates/rescues/_request_and_response.text.tse +19 -0
  401. package/dist/action-dispatch/middleware/templates/rescues/_request_and_response.text.tse.js +42 -0
  402. package/dist/action-dispatch/middleware/templates/rescues/_request_and_response.text.tse.js.map +1 -0
  403. package/dist/action-dispatch/middleware/templates/rescues/_source.html.tse +33 -0
  404. package/dist/action-dispatch/middleware/templates/rescues/_source.html.tse.js +70 -0
  405. package/dist/action-dispatch/middleware/templates/rescues/_source.html.tse.js.map +1 -0
  406. package/dist/action-dispatch/middleware/templates/rescues/_source.text.tse +8 -0
  407. package/dist/action-dispatch/middleware/templates/rescues/_source.text.tse.js +41 -0
  408. package/dist/action-dispatch/middleware/templates/rescues/_source.text.tse.js.map +1 -0
  409. package/dist/action-dispatch/middleware/templates/rescues/_trace.html.tse +62 -0
  410. package/dist/action-dispatch/middleware/templates/rescues/_trace.html.tse.js +78 -0
  411. package/dist/action-dispatch/middleware/templates/rescues/_trace.html.tse.js.map +1 -0
  412. package/dist/action-dispatch/middleware/templates/rescues/_trace.text.tse +9 -0
  413. package/dist/action-dispatch/middleware/templates/rescues/_trace.text.tse.js +23 -0
  414. package/dist/action-dispatch/middleware/templates/rescues/_trace.text.tse.js.map +1 -0
  415. package/dist/action-dispatch/middleware/templates/rescues/blocked_host.html.tse +12 -0
  416. package/dist/action-dispatch/middleware/templates/rescues/blocked_host.html.tse.js +24 -0
  417. package/dist/action-dispatch/middleware/templates/rescues/blocked_host.html.tse.js.map +1 -0
  418. package/dist/action-dispatch/middleware/templates/rescues/blocked_host.text.tse +9 -0
  419. package/dist/action-dispatch/middleware/templates/rescues/blocked_host.text.tse.js +20 -0
  420. package/dist/action-dispatch/middleware/templates/rescues/blocked_host.text.tse.js.map +1 -0
  421. package/dist/action-dispatch/middleware/templates/rescues/diagnostics.html.tse +35 -0
  422. package/dist/action-dispatch/middleware/templates/rescues/diagnostics.html.tse.js +77 -0
  423. package/dist/action-dispatch/middleware/templates/rescues/diagnostics.html.tse.js.map +1 -0
  424. package/dist/action-dispatch/middleware/templates/rescues/diagnostics.text.tse +9 -0
  425. package/dist/action-dispatch/middleware/templates/rescues/diagnostics.text.tse.js +48 -0
  426. package/dist/action-dispatch/middleware/templates/rescues/diagnostics.text.tse.js.map +1 -0
  427. package/dist/action-dispatch/middleware/templates/rescues/invalid_statement.html.tse +24 -0
  428. package/dist/action-dispatch/middleware/templates/rescues/invalid_statement.html.tse.js +61 -0
  429. package/dist/action-dispatch/middleware/templates/rescues/invalid_statement.html.tse.js.map +1 -0
  430. package/dist/action-dispatch/middleware/templates/rescues/invalid_statement.text.tse +16 -0
  431. package/dist/action-dispatch/middleware/templates/rescues/invalid_statement.text.tse.js +55 -0
  432. package/dist/action-dispatch/middleware/templates/rescues/invalid_statement.text.tse.js.map +1 -0
  433. package/dist/action-dispatch/middleware/templates/rescues/layout.tse +284 -0
  434. package/dist/action-dispatch/middleware/templates/rescues/layout.tse.js +16 -0
  435. package/dist/action-dispatch/middleware/templates/rescues/layout.tse.js.map +1 -0
  436. package/dist/action-dispatch/middleware/templates/rescues/missing_exact_template.html.tse +23 -0
  437. package/dist/action-dispatch/middleware/templates/rescues/missing_exact_template.html.tse.js +45 -0
  438. package/dist/action-dispatch/middleware/templates/rescues/missing_exact_template.html.tse.js.map +1 -0
  439. package/dist/action-dispatch/middleware/templates/rescues/missing_exact_template.text.tse +3 -0
  440. package/dist/action-dispatch/middleware/templates/rescues/missing_exact_template.text.tse.js +14 -0
  441. package/dist/action-dispatch/middleware/templates/rescues/missing_exact_template.text.tse.js.map +1 -0
  442. package/dist/action-dispatch/middleware/templates/rescues/missing_template.html.tse +11 -0
  443. package/dist/action-dispatch/middleware/templates/rescues/missing_template.html.tse.js +41 -0
  444. package/dist/action-dispatch/middleware/templates/rescues/missing_template.html.tse.js.map +1 -0
  445. package/dist/action-dispatch/middleware/templates/rescues/missing_template.text.tse +3 -0
  446. package/dist/action-dispatch/middleware/templates/rescues/missing_template.text.tse.js +14 -0
  447. package/dist/action-dispatch/middleware/templates/rescues/missing_template.text.tse.js.map +1 -0
  448. package/dist/action-dispatch/middleware/templates/rescues/routing_error.html.tse +32 -0
  449. package/dist/action-dispatch/middleware/templates/rescues/routing_error.html.tse.js +58 -0
  450. package/dist/action-dispatch/middleware/templates/rescues/routing_error.html.tse.js.map +1 -0
  451. package/dist/action-dispatch/middleware/templates/rescues/routing_error.text.tse +11 -0
  452. package/dist/action-dispatch/middleware/templates/rescues/routing_error.text.tse.js +45 -0
  453. package/dist/action-dispatch/middleware/templates/rescues/routing_error.text.tse.js.map +1 -0
  454. package/dist/action-dispatch/middleware/templates/rescues/template_error.html.tse +20 -0
  455. package/dist/action-dispatch/middleware/templates/rescues/template_error.html.tse.js +53 -0
  456. package/dist/action-dispatch/middleware/templates/rescues/template_error.html.tse.js.map +1 -0
  457. package/dist/action-dispatch/middleware/templates/rescues/template_error.text.tse +7 -0
  458. package/dist/action-dispatch/middleware/templates/rescues/template_error.text.tse.js +46 -0
  459. package/dist/action-dispatch/middleware/templates/rescues/template_error.text.tse.js.map +1 -0
  460. package/dist/action-dispatch/middleware/templates/rescues/unknown_action.html.tse +6 -0
  461. package/dist/action-dispatch/middleware/templates/rescues/unknown_action.html.tse.js +35 -0
  462. package/dist/action-dispatch/middleware/templates/rescues/unknown_action.html.tse.js.map +1 -0
  463. package/dist/action-dispatch/middleware/templates/rescues/unknown_action.text.tse +3 -0
  464. package/dist/action-dispatch/middleware/templates/rescues/unknown_action.text.tse.js +14 -0
  465. package/dist/action-dispatch/middleware/templates/rescues/unknown_action.text.tse.js.map +1 -0
  466. package/dist/action-dispatch/middleware/templates/routes/_route.html.tse +19 -0
  467. package/dist/action-dispatch/middleware/templates/routes/_route.html.tse.js +51 -0
  468. package/dist/action-dispatch/middleware/templates/routes/_route.html.tse.js.map +1 -0
  469. package/dist/action-dispatch/middleware/templates/routes/_table.html.tse +232 -0
  470. package/dist/action-dispatch/middleware/templates/routes/_table.html.tse.js +46 -0
  471. package/dist/action-dispatch/middleware/templates/routes/_table.html.tse.js.map +1 -0
  472. package/dist/action-dispatch/request/index.d.ts +3 -0
  473. package/dist/action-dispatch/request/index.js +3 -0
  474. package/dist/action-dispatch/request/index.js.map +1 -0
  475. package/dist/action-dispatch/request/session.d.ts +78 -0
  476. package/dist/action-dispatch/request/session.js +276 -0
  477. package/dist/action-dispatch/request/session.js.map +1 -0
  478. package/dist/action-dispatch/request/utils.d.ts +43 -0
  479. package/dist/action-dispatch/request/utils.js +163 -0
  480. package/dist/action-dispatch/request/utils.js.map +1 -0
  481. package/dist/action-dispatch/routing/dispatcher.d.ts +11 -0
  482. package/dist/action-dispatch/routing/dispatcher.js +3 -0
  483. package/dist/action-dispatch/routing/dispatcher.js.map +1 -0
  484. package/dist/action-dispatch/routing/endpoint.d.ts +11 -0
  485. package/dist/action-dispatch/routing/endpoint.js +26 -0
  486. package/dist/action-dispatch/routing/endpoint.js.map +1 -0
  487. package/dist/action-dispatch/routing/index.d.ts +10 -0
  488. package/dist/action-dispatch/routing/index.js +9 -0
  489. package/dist/action-dispatch/routing/index.js.map +1 -0
  490. package/dist/action-dispatch/routing/inspector.d.ts +114 -0
  491. package/dist/action-dispatch/routing/inspector.js +291 -0
  492. package/dist/action-dispatch/routing/inspector.js.map +1 -0
  493. package/dist/action-dispatch/routing/mapper.d.ts +474 -0
  494. package/dist/action-dispatch/routing/mapper.js +1656 -0
  495. package/dist/action-dispatch/routing/mapper.js.map +1 -0
  496. package/dist/action-dispatch/routing/polymorphic-routes.d.ts +69 -0
  497. package/dist/action-dispatch/routing/polymorphic-routes.js +238 -0
  498. package/dist/action-dispatch/routing/polymorphic-routes.js.map +1 -0
  499. package/dist/action-dispatch/routing/redirection.d.ts +56 -0
  500. package/dist/action-dispatch/routing/redirection.js +183 -0
  501. package/dist/action-dispatch/routing/redirection.js.map +1 -0
  502. package/dist/action-dispatch/routing/route-set.d.ts +271 -0
  503. package/dist/action-dispatch/routing/route-set.js +1081 -0
  504. package/dist/action-dispatch/routing/route-set.js.map +1 -0
  505. package/dist/action-dispatch/routing/routes-proxy.d.ts +49 -0
  506. package/dist/action-dispatch/routing/routes-proxy.js +87 -0
  507. package/dist/action-dispatch/routing/routes-proxy.js.map +1 -0
  508. package/dist/action-dispatch/routing/url-for.d.ts +50 -0
  509. package/dist/action-dispatch/routing/url-for.js +126 -0
  510. package/dist/action-dispatch/routing/url-for.js.map +1 -0
  511. package/dist/action-dispatch/system-test-case.d.ts +58 -0
  512. package/dist/action-dispatch/system-test-case.js +122 -0
  513. package/dist/action-dispatch/system-test-case.js.map +1 -0
  514. package/dist/action-dispatch/system-testing/browser.d.ts +31 -0
  515. package/dist/action-dispatch/system-testing/browser.js +93 -0
  516. package/dist/action-dispatch/system-testing/browser.js.map +1 -0
  517. package/dist/action-dispatch/system-testing/driver.d.ts +45 -0
  518. package/dist/action-dispatch/system-testing/driver.js +110 -0
  519. package/dist/action-dispatch/system-testing/driver.js.map +1 -0
  520. package/dist/action-dispatch/system-testing/server.d.ts +27 -0
  521. package/dist/action-dispatch/system-testing/server.js +71 -0
  522. package/dist/action-dispatch/system-testing/server.js.map +1 -0
  523. package/dist/action-dispatch/system-testing/test-helpers/screenshot-helper.d.ts +70 -0
  524. package/dist/action-dispatch/system-testing/test-helpers/screenshot-helper.js +142 -0
  525. package/dist/action-dispatch/system-testing/test-helpers/screenshot-helper.js.map +1 -0
  526. package/dist/action-dispatch/system-testing/test-helpers/setup-and-teardown.d.ts +15 -0
  527. package/dist/action-dispatch/system-testing/test-helpers/setup-and-teardown.js +24 -0
  528. package/dist/action-dispatch/system-testing/test-helpers/setup-and-teardown.js.map +1 -0
  529. package/dist/action-dispatch/testing/assertion-response.d.ts +7 -0
  530. package/dist/action-dispatch/testing/assertion-response.js +44 -0
  531. package/dist/action-dispatch/testing/assertion-response.js.map +1 -0
  532. package/dist/action-dispatch/testing/assertions/response.d.ts +67 -0
  533. package/dist/action-dispatch/testing/assertions/response.js +94 -0
  534. package/dist/action-dispatch/testing/assertions/response.js.map +1 -0
  535. package/dist/action-dispatch/testing/assertions/routing.d.ts +76 -0
  536. package/dist/action-dispatch/testing/assertions/routing.js +291 -0
  537. package/dist/action-dispatch/testing/assertions/routing.js.map +1 -0
  538. package/dist/action-dispatch/testing/assertions.d.ts +37 -0
  539. package/dist/action-dispatch/testing/assertions.js +27 -0
  540. package/dist/action-dispatch/testing/assertions.js.map +1 -0
  541. package/dist/action-dispatch/testing/index.d.ts +10 -0
  542. package/dist/action-dispatch/testing/index.js +10 -0
  543. package/dist/action-dispatch/testing/index.js.map +1 -0
  544. package/dist/action-dispatch/testing/integration.d.ts +203 -0
  545. package/dist/action-dispatch/testing/integration.js +552 -0
  546. package/dist/action-dispatch/testing/integration.js.map +1 -0
  547. package/dist/action-dispatch/testing/request-encoder.d.ts +28 -0
  548. package/dist/action-dispatch/testing/request-encoder.js +76 -0
  549. package/dist/action-dispatch/testing/request-encoder.js.map +1 -0
  550. package/dist/action-dispatch/testing/test-helpers/page-dump-helper.d.ts +22 -0
  551. package/dist/action-dispatch/testing/test-helpers/page-dump-helper.js +53 -0
  552. package/dist/action-dispatch/testing/test-helpers/page-dump-helper.js.map +1 -0
  553. package/dist/action-dispatch/testing/test-process.d.ts +46 -0
  554. package/dist/action-dispatch/testing/test-process.js +45 -0
  555. package/dist/action-dispatch/testing/test-process.js.map +1 -0
  556. package/dist/action-dispatch/testing/test-request.d.ts +26 -0
  557. package/dist/action-dispatch/testing/test-request.js +78 -0
  558. package/dist/action-dispatch/testing/test-request.js.map +1 -0
  559. package/dist/action-dispatch/testing/test-response.d.ts +16 -0
  560. package/dist/action-dispatch/testing/test-response.js +29 -0
  561. package/dist/action-dispatch/testing/test-response.js.map +1 -0
  562. package/dist/action-pack/gem-version.d.ts +9 -0
  563. package/dist/action-pack/gem-version.js +15 -0
  564. package/dist/action-pack/gem-version.js.map +1 -0
  565. package/dist/action-pack/index.d.ts +3 -0
  566. package/dist/action-pack/index.js +3 -0
  567. package/dist/action-pack/index.js.map +1 -0
  568. package/dist/action-pack/version.d.ts +2 -0
  569. package/dist/action-pack/version.js +5 -0
  570. package/dist/action-pack/version.js.map +1 -0
  571. package/dist/constants.excluded.generated.d.ts +2 -0
  572. package/dist/constants.excluded.generated.js +57 -0
  573. package/dist/constants.excluded.generated.js.map +1 -0
  574. package/dist/constants.generated.d.ts +2 -0
  575. package/dist/constants.generated.js +469 -0
  576. package/dist/constants.generated.js.map +1 -0
  577. package/dist/index.d.ts +9 -0
  578. package/dist/index.js +8 -0
  579. package/dist/index.js.map +1 -0
  580. package/dist/namespaces.d.ts +173 -0
  581. package/dist/namespaces.js +99 -0
  582. package/dist/namespaces.js.map +1 -0
  583. package/dist/system-testing.d.ts +5 -0
  584. package/dist/system-testing.js +5 -0
  585. package/dist/system-testing.js.map +1 -0
  586. package/dist/testing.d.ts +7 -0
  587. package/dist/testing.js +18 -0
  588. package/dist/testing.js.map +1 -0
  589. package/package.json +92 -3
  590. package/README.md +0 -3
@@ -0,0 +1,1656 @@
1
+ import { Redirection } from "./redirection.js";
2
+ import { Endpoint } from "./endpoint.js";
3
+ import { Dispatcher, StaticDispatcher } from "./route-set.js";
4
+ import { X_CASCADE } from "../constants.js";
5
+ import { Parser } from "../journey/parser.js";
6
+ import { Ast } from "../journey/nodes/node.js";
7
+ import { Pattern } from "../journey/path/pattern.js";
8
+ import { Route as JourneyRoute } from "../journey/route.js";
9
+ import * as ActiveSupport from "@blazetrails/activesupport";
10
+ import { camelize, callerLocations, cattrAccessor, extractOptionsBang, isBlank, isPlainObject, isPresent, pluralize, reverseMergeBang, singularize, squish, TopLevel, transformKeys, underscore, } from "@blazetrails/activesupport";
11
+ import { Enumerable, extend, loadedFileExports, hashAref, hashAset, include, rbCallSuper, RFC2396_PARSER, rbFArray, rbInspect, RuntimeError, rbFSend, slice, rbModMethodDefined, rbObjRespondTo, rtest, stringSplit, Thread, rbIterBreakValue, rbBlockGivenP, rbProcCall, rbObjIsProc, rbObjMethod, } from "@blazetrails/ruby-compat";
12
+ import { ArgumentError } from "@blazetrails/activemodel";
13
+ import { fetch, File, groupBy, hashDelete, isSymbol, keepIf, merge, symbolToS, } from "@blazetrails/ruby-compat";
14
+ import { deprecator } from "../deprecator.js";
15
+ const RESOURCE_OPTIONS = new Set([
16
+ "as",
17
+ "controller",
18
+ "path",
19
+ "only",
20
+ "except",
21
+ "param",
22
+ "concerns",
23
+ ]);
24
+ /** @internal */
25
+ export class Resource {
26
+ static defaultActions(apiOnly) {
27
+ if (apiOnly) {
28
+ return ["index", "create", "show", "update", "destroy"];
29
+ }
30
+ else {
31
+ return ["index", "create", "new", "show", "update", "destroy", "edit"];
32
+ }
33
+ }
34
+ controller;
35
+ path;
36
+ param;
37
+ _name;
38
+ _as;
39
+ _options;
40
+ _shallow;
41
+ _apiOnly;
42
+ _only;
43
+ _except;
44
+ _plural;
45
+ _singular;
46
+ constructor(entities, apiOnly, shallow, options = {}) {
47
+ if (String(options.param ?? "").includes(":")) {
48
+ throw new ArgumentError(":param option can't contain colons");
49
+ }
50
+ const validActions = this.constructor.defaultActions(false);
51
+ const invalidActions = this.invalidOnlyExceptOptions(options, validActions);
52
+ if (isPresent(invalidActions)) {
53
+ const errorPrefix = `Route \`resource${this.isSingleton() ? "" : "s"} :${entities}\``;
54
+ throw new ArgumentError(`${errorPrefix} - :only and :except must include only [${validActions.map((a) => `:${a}`).join(", ")}], but also included [${invalidActions.map((a) => `:${a}`).join(", ")}]`);
55
+ }
56
+ this._name = String(entities);
57
+ this.path = String(rtest(options.path) ? options.path : this._name);
58
+ this.controller = String(rtest(options.controller) ? options.controller : this._name);
59
+ this._as = options.as;
60
+ this.param = String(rtest(options.param) ? options.param : "id");
61
+ this._options = options;
62
+ this._shallow = shallow;
63
+ this._apiOnly = apiOnly;
64
+ this._only = hashDelete(options, "only");
65
+ this._except = hashDelete(options, "except");
66
+ }
67
+ /** @missingRailsName apiOnly — PERMANENT */
68
+ defaultActions() {
69
+ return this.constructor.defaultActions(this._apiOnly);
70
+ }
71
+ actions() {
72
+ if (this._except != null) {
73
+ const except = rbFArray(this._except);
74
+ return this.availableActions().filter((a) => !except.includes(a));
75
+ }
76
+ else {
77
+ return this.availableActions();
78
+ }
79
+ }
80
+ availableActions() {
81
+ if (this._only != null) {
82
+ return rbFArray(this._only);
83
+ }
84
+ else {
85
+ return this.defaultActions();
86
+ }
87
+ }
88
+ name() {
89
+ return rtest(this._as) ? this._as : this._name;
90
+ }
91
+ plural() {
92
+ return (this._plural ??= String(this.name()));
93
+ }
94
+ singular() {
95
+ return (this._singular ??= singularize(String(this.name())));
96
+ }
97
+ memberName() {
98
+ return this.singular();
99
+ }
100
+ collectionName() {
101
+ return this.singular() === this.plural() ? `${this.plural()}_index` : this.plural();
102
+ }
103
+ resourceScope() {
104
+ return this.controller;
105
+ }
106
+ collectionScope() {
107
+ return this.path;
108
+ }
109
+ memberScope() {
110
+ return `${this.path}/:${this.param}`;
111
+ }
112
+ shallowScope() {
113
+ return this.memberScope();
114
+ }
115
+ newScope(newPath) {
116
+ return `${this.path}/${newPath}`;
117
+ }
118
+ nestedParam() {
119
+ return `${this.singular()}_${this.param}`;
120
+ }
121
+ nestedScope() {
122
+ return `${this.path}/:${this.nestedParam()}`;
123
+ }
124
+ isShallow() {
125
+ return this._shallow;
126
+ }
127
+ isSingleton() {
128
+ return false;
129
+ }
130
+ invalidOnlyExceptOptions(options, validActions) {
131
+ const values = [options.only, options.except].flat().filter((v) => v != null);
132
+ return [...new Set(values)].filter((a) => !validActions.includes(a));
133
+ }
134
+ }
135
+ /** @internal */
136
+ export class SingletonResource extends Resource {
137
+ static defaultActions(apiOnly) {
138
+ if (apiOnly) {
139
+ return ["show", "create", "update", "destroy"];
140
+ }
141
+ else {
142
+ return ["show", "create", "update", "destroy", "new", "edit"];
143
+ }
144
+ }
145
+ constructor(entities, apiOnly, shallow, options) {
146
+ super(entities, apiOnly, shallow, options);
147
+ this._as = null;
148
+ this.controller = String(rtest(options.controller) ? options.controller : this.plural());
149
+ this._as = options.as;
150
+ }
151
+ defaultActions() {
152
+ return this.constructor.defaultActions(this._apiOnly);
153
+ }
154
+ plural() {
155
+ return (this._plural ??= pluralize(String(this.name())));
156
+ }
157
+ singular() {
158
+ return (this._singular ??= String(this.name()));
159
+ }
160
+ memberName() {
161
+ return this.singular();
162
+ }
163
+ collectionName() {
164
+ return this.singular();
165
+ }
166
+ memberScope() {
167
+ return this.path;
168
+ }
169
+ nestedScope() {
170
+ return this.path;
171
+ }
172
+ isSingleton() {
173
+ return true;
174
+ }
175
+ }
176
+ /** @internal */
177
+ export class Constraints extends Endpoint {
178
+ app() {
179
+ return this._app;
180
+ }
181
+ constraints;
182
+ static SERVE = (app, req) => app.serve(req);
183
+ static CALL = (app, req) => rbProcCall(app, req.env);
184
+ _strategy;
185
+ _app;
186
+ constructor(app, constraints, strategy) {
187
+ super();
188
+ if (app instanceof Constraints) {
189
+ constraints = [...constraints, ...app.constraints];
190
+ app = app.app();
191
+ }
192
+ this._strategy = strategy;
193
+ this._app = app;
194
+ this.constraints = constraints;
195
+ }
196
+ dispatcher() {
197
+ return this._strategy === Constraints.SERVE;
198
+ }
199
+ matches(req) {
200
+ return this.constraints.every((constraint) => {
201
+ if (rbObjRespondTo(constraint, "matches")) {
202
+ const matched = constraint.matches(req);
203
+ if (matched != null && matched !== false)
204
+ return true;
205
+ }
206
+ if (rbObjRespondTo(constraint, "call")) {
207
+ const called = rbProcCall(constraint, ...this.constraintArgs(constraint, req));
208
+ if (called != null && called !== false)
209
+ return true;
210
+ }
211
+ return false;
212
+ });
213
+ }
214
+ serve(req) {
215
+ if (!this.matches(req)) {
216
+ return [404, { [X_CASCADE]: "pass" }, []];
217
+ }
218
+ return this._strategy(this._app, req);
219
+ }
220
+ /**
221
+ * @internal
222
+ * @inventedArm length — PERMANENT
223
+ */
224
+ constraintArgs(constraint, request) {
225
+ const arity = rbObjRespondTo(constraint, "arity")
226
+ ? constraint.arity
227
+ : rbObjIsProc(constraint)
228
+ ? constraint.length
229
+ : rbObjMethod(constraint, "call").arity();
230
+ if (arity < 1) {
231
+ return [];
232
+ }
233
+ else if (arity === 1) {
234
+ return [request];
235
+ }
236
+ else {
237
+ return [request.pathParameters, request];
238
+ }
239
+ }
240
+ }
241
+ const SEPARATORS = ["/", ".", "?"];
242
+ /** @internal */
243
+ export class Mapping {
244
+ static ANCHOR_CHARACTERS_REGEX = /^(\\A|\^)|(\\Z|\\z|\$)(?=\n?$)/;
245
+ static OPTIONAL_FORMAT_REGEX = /(?:\(\.:format\)+|\.:format|\/)(?=\n?$)/;
246
+ path;
247
+ requirements;
248
+ defaults;
249
+ to;
250
+ defaultController;
251
+ defaultAction;
252
+ requiredDefaults;
253
+ ast;
254
+ scopeOptions;
255
+ _set;
256
+ _blocks;
257
+ _anchor;
258
+ _via;
259
+ _formatted;
260
+ _internal;
261
+ _conditions;
262
+ static build(scope, set, ast, controller, defaultAction, to, via, formatted, optionsConstraints, anchor, options) {
263
+ const scopeParams = {
264
+ blocks: scope.get("blocks") ?? [],
265
+ constraints: scope.get("constraints") ?? {},
266
+ defaults: { ...(scope.get("defaults") ?? {}) },
267
+ module: scope.get("module"),
268
+ options: scope.get("options") ?? {},
269
+ };
270
+ return new Mapping({
271
+ set,
272
+ ast,
273
+ controller,
274
+ defaultAction,
275
+ to,
276
+ formatted,
277
+ via,
278
+ optionsConstraints,
279
+ anchor,
280
+ scopeParams,
281
+ options: { ...scopeParams.options, ...options },
282
+ });
283
+ }
284
+ static checkVia(via) {
285
+ if (via.length === 0) {
286
+ const msg = "You should not use the `match` method in your router without specifying an HTTP method.\n" +
287
+ "If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.\n" +
288
+ "If you want to expose your action to GET, use `get` in the router:\n" +
289
+ ' Instead of: match "controller#action"\n' +
290
+ ' Do: get "controller#action"';
291
+ throw new ArgumentError(msg);
292
+ }
293
+ return via;
294
+ }
295
+ static normalizePath(path, format) {
296
+ path = Mapper.normalizePath(path);
297
+ if (format === true) {
298
+ return `${path}.:format`;
299
+ }
300
+ else if (Mapping.optionalFormat(path, format)) {
301
+ return `${path}(.:format)`;
302
+ }
303
+ else {
304
+ return path;
305
+ }
306
+ }
307
+ static optionalFormat(path, format) {
308
+ return format !== false && !Mapping.OPTIONAL_FORMAT_REGEX.test(path);
309
+ }
310
+ constructor({ set, ast, controller, defaultAction, to, formatted, via, optionsConstraints, anchor, scopeParams, options, }) {
311
+ let defaults = scopeParams.defaults;
312
+ this._set = set;
313
+ this.to = this.intern(to);
314
+ this.defaultController = this.intern(controller);
315
+ this.defaultAction = this.intern(defaultAction);
316
+ this._anchor = anchor;
317
+ this._via = via;
318
+ this._formatted = formatted;
319
+ this._internal = options.internal;
320
+ delete options.internal;
321
+ this.scopeOptions = scopeParams.options;
322
+ this.ast = new Ast(ast, formatted);
323
+ options = Object.assign(this.ast.wildcardOptions, options);
324
+ options = this.normalizeOptionsBang(options, this.ast.pathParams, scopeParams.module);
325
+ const splitOptions = this.constraints(options, this.ast.pathParams);
326
+ const constraints = {
327
+ ...scopeParams.constraints,
328
+ ...Object.fromEntries(splitOptions.constraints ?? []),
329
+ };
330
+ if (isPlainObject(optionsConstraints)) {
331
+ defaults = {
332
+ ...Object.fromEntries(Object.entries(optionsConstraints).filter(([key, default_]) => Mapper.URL_OPTIONS.includes(key) &&
333
+ (typeof default_ === "string" || Number.isInteger(default_)))),
334
+ ...defaults,
335
+ };
336
+ this._blocks = scopeParams.blocks;
337
+ Object.assign(constraints, optionsConstraints);
338
+ }
339
+ else {
340
+ this._blocks = this.blocks(optionsConstraints);
341
+ }
342
+ const [requirements, conditions] = this.splitConstraints(this.ast.pathParams, constraints);
343
+ this.verifyRegexpRequirements(requirements, this.ast.wildcardOptions);
344
+ const formats = this.normalizeFormat(formatted);
345
+ this.requirements = { ...formats.requirements, ...Object.fromEntries(requirements) };
346
+ this._conditions = Object.fromEntries(conditions);
347
+ this.defaults = { ...formats.defaults, ...defaults, ...this.normalizeDefaults(options) };
348
+ if (this.ast.pathParams.includes("action") && !("action" in this.requirements)) {
349
+ if (this.defaults.action == null || this.defaults.action === false) {
350
+ this.defaults.action = "index";
351
+ }
352
+ }
353
+ this.requiredDefaults = (splitOptions.requiredDefaults ?? []).map(([key]) => key);
354
+ this.ast.requirements = this.requirements;
355
+ this.path = new Pattern(this.ast, this.requirements, Mapping.JOINED_SEPARATORS, this._anchor);
356
+ }
357
+ static JOINED_SEPARATORS = SEPARATORS.join("");
358
+ /** @missingRailsName internal — PERMANENT */
359
+ makeRoute(name, precedence) {
360
+ return new JourneyRoute({
361
+ name,
362
+ app: this.application(),
363
+ path: this.path,
364
+ constraints: this.conditions(),
365
+ requiredDefaults: this.requiredDefaults,
366
+ defaults: this.defaults,
367
+ requestMethodMatch: this.requestMethod(),
368
+ precedence,
369
+ scopeOptions: this.scopeOptions,
370
+ internal: this._internal,
371
+ sourceLocation: this.routeSourceLocation(),
372
+ });
373
+ }
374
+ /** @missingRailsName blocks — PERMANENT */
375
+ application() {
376
+ return this.app(this._blocks);
377
+ }
378
+ /** @missingRailsName conditions — PERMANENT */
379
+ conditions() {
380
+ return this.buildConditions(this._conditions, this._set.requestClass());
381
+ }
382
+ /** @internal */
383
+ buildConditions(currentConditions, requestClass) {
384
+ const conditions = { ...currentConditions };
385
+ return keepIf(conditions, (k) => rbModMethodDefined(requestClass, k));
386
+ }
387
+ /** @internal */
388
+ requestMethod() {
389
+ return this._via.map((x) => JourneyRoute.verbMatcher(x));
390
+ }
391
+ /** @internal */
392
+ intern(object) {
393
+ return typeof object === "string" ? object : object;
394
+ }
395
+ /** @internal */
396
+ normalizeOptionsBang(options, pathParams, modyoule) {
397
+ if (pathParams.includes("controller")) {
398
+ if (modyoule) {
399
+ throw new ArgumentError(":controller segment is not allowed within a namespace block");
400
+ }
401
+ if (options.controller == null || options.controller === false) {
402
+ options.controller = /.+?/;
403
+ }
404
+ }
405
+ if (rbObjRespondTo(this.to, "action") || rbObjRespondTo(this.to, "call")) {
406
+ return options;
407
+ }
408
+ else {
409
+ let controller;
410
+ let action;
411
+ if (this.to == null) {
412
+ controller = this.defaultController;
413
+ action = this.defaultAction;
414
+ }
415
+ else if (typeof this.to === "string" && !SYMBOL.test(this.to)) {
416
+ if (this.to.includes("#")) {
417
+ const toEndpoint = stringSplit(this.to, "#");
418
+ controller = toEndpoint[0];
419
+ action = toEndpoint[1];
420
+ }
421
+ else {
422
+ controller = this.defaultController;
423
+ action = this.to;
424
+ }
425
+ }
426
+ else {
427
+ throw new ArgumentError(":to must respond to `action` or `call`, or it must be a String that includes '#', or the controller should be implicit");
428
+ }
429
+ controller = this.addControllerModule(controller, modyoule);
430
+ return Object.assign(options, this.checkControllerAndAction(pathParams, controller, action));
431
+ }
432
+ }
433
+ /** @internal */
434
+ splitConstraints(pathParams, constraints) {
435
+ const requirements = [];
436
+ const conditions = [];
437
+ for (const [key, requirement] of Object.entries(constraints)) {
438
+ if (pathParams.includes(key) || key === "controller") {
439
+ requirements.push([key, requirement]);
440
+ }
441
+ else {
442
+ conditions.push([key, requirement]);
443
+ }
444
+ }
445
+ return [requirements, conditions];
446
+ }
447
+ /** @internal */
448
+ normalizeFormat(formatted) {
449
+ if (formatted === true) {
450
+ return { requirements: { format: /.+/ }, defaults: {} };
451
+ }
452
+ else if (formatted instanceof RegExp) {
453
+ return { requirements: { format: formatted }, defaults: { format: null } };
454
+ }
455
+ else if (typeof formatted === "string") {
456
+ return { requirements: { format: new RegExp(formatted) }, defaults: { format: formatted } };
457
+ }
458
+ else {
459
+ return { requirements: {}, defaults: {} };
460
+ }
461
+ }
462
+ /** @internal */
463
+ verifyRegexpRequirements(requirements, wildcardOptions) {
464
+ for (const [requirement, regex] of requirements) {
465
+ if (!(regex instanceof RegExp))
466
+ continue;
467
+ if (Mapping.ANCHOR_CHARACTERS_REGEX.test(regex.source)) {
468
+ throw new ArgumentError(`Regexp anchor characters are not allowed in routing requirements: ${rbInspect(`:${requirement}`)}`);
469
+ }
470
+ if (regex.dotAll) {
471
+ if (Object.hasOwn(wildcardOptions, requirement))
472
+ continue;
473
+ throw new ArgumentError(`Regexp multiline option is not allowed in routing requirements: ${rbInspect(regex)}`);
474
+ }
475
+ }
476
+ }
477
+ /** @internal */
478
+ normalizeDefaults(options) {
479
+ return Object.fromEntries(Object.entries(options).filter(([, default_]) => !(default_ instanceof RegExp)));
480
+ }
481
+ /** @internal */
482
+ app(blocks) {
483
+ if (rbObjRespondTo(this.to, "action")) {
484
+ return new StaticDispatcher(this.to);
485
+ }
486
+ else if (rbObjRespondTo(this.to, "call")) {
487
+ return new Constraints(this.to, blocks, Constraints.CALL);
488
+ }
489
+ else if (blocks.length > 0) {
490
+ return new Constraints(this.dispatcher("controller" in this.defaults), blocks, Constraints.SERVE);
491
+ }
492
+ else {
493
+ return this.dispatcher("controller" in this.defaults);
494
+ }
495
+ }
496
+ /** @internal */
497
+ checkControllerAndAction(pathParams, controller, action) {
498
+ const hash = this.checkPart("controller", controller, pathParams, {}, (part) => this.translateController(part, () => {
499
+ let message = `'${part}' is not a supported controller name. This can lead to potential routing problems.`;
500
+ message +=
501
+ " See https://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use";
502
+ throw new ArgumentError(message);
503
+ }));
504
+ return this.checkPart("action", action, pathParams, hash, (part) => part instanceof RegExp ? part : String(part));
505
+ }
506
+ /** @internal */
507
+ checkPart(name, part, pathParams, hash, block) {
508
+ if (part != null) {
509
+ hash[name] = block(part);
510
+ }
511
+ else {
512
+ if (!pathParams.includes(name)) {
513
+ const message = `Missing :${name} key on routes definition, please check your routes.`;
514
+ throw new ArgumentError(message);
515
+ }
516
+ }
517
+ return hash;
518
+ }
519
+ /** @internal */
520
+ addControllerModule(controller, modyoule) {
521
+ if (modyoule && !(controller instanceof RegExp)) {
522
+ if (controller?.startsWith("/")) {
523
+ return controller.slice(1);
524
+ }
525
+ else {
526
+ return [modyoule, controller].filter((part) => part != null).join("/");
527
+ }
528
+ }
529
+ else {
530
+ return controller;
531
+ }
532
+ }
533
+ /** @internal */
534
+ translateController(controller, block) {
535
+ if (controller instanceof RegExp)
536
+ return controller;
537
+ if (/^[a-z_0-9][a-z_0-9/]*$/.test(controller))
538
+ return controller;
539
+ return block();
540
+ }
541
+ /** @internal */
542
+ blocks(callableConstraint) {
543
+ if (!(rbObjRespondTo(callableConstraint, "call") || rbObjRespondTo(callableConstraint, "matches"))) {
544
+ throw new ArgumentError(`Invalid constraint: ${rbInspect(callableConstraint)} must respond to :call or :matches?`);
545
+ }
546
+ return [callableConstraint];
547
+ }
548
+ /** @internal */
549
+ constraints(options, pathParams) {
550
+ const groups = {};
551
+ for (const [key, option] of Object.entries(options)) {
552
+ let group;
553
+ if (option instanceof RegExp) {
554
+ group = "constraints";
555
+ }
556
+ else {
557
+ if (pathParams.includes(key)) {
558
+ group = "pathParams";
559
+ }
560
+ else {
561
+ group = "requiredDefaults";
562
+ }
563
+ }
564
+ (groups[group] ??= []).push([key, option]);
565
+ }
566
+ return groups;
567
+ }
568
+ /** @internal */
569
+ dispatcher(raiseOnNameError) {
570
+ return new Dispatcher(raiseOnNameError);
571
+ }
572
+ /** @internal */
573
+ routeSourceLocation() {
574
+ if (Mapper.routeSourceLocations) {
575
+ const actionDispatchDir = File.dirname(File.dirname(callerLocations(0, 1)[0].path));
576
+ return Thread.eachCallerLocation((location) => {
577
+ if (location.path.startsWith(actionDispatchDir))
578
+ return;
579
+ const cleanedPath = Mapper.backtraceCleaner.cleanFrame(location.path);
580
+ if (cleanedPath == null)
581
+ return;
582
+ rbIterBreakValue(`${cleanedPath}:${location.lineno}`);
583
+ });
584
+ }
585
+ }
586
+ }
587
+ export class Scope {
588
+ static OPTIONS = [
589
+ "path",
590
+ "shallowPath",
591
+ "as",
592
+ "shallowPrefix",
593
+ "module",
594
+ "controller",
595
+ "action",
596
+ "pathNames",
597
+ "constraints",
598
+ "shallow",
599
+ "blocks",
600
+ "defaults",
601
+ "via",
602
+ "format",
603
+ "options",
604
+ "to",
605
+ ];
606
+ static RESOURCE_SCOPES = ["resource", "resources"];
607
+ static RESOURCE_METHOD_SCOPES = ["collection", "member", "new"];
608
+ parent;
609
+ scopeLevel;
610
+ hash;
611
+ constructor(hash, parent = Scope.ROOT, scopeLevel = null) {
612
+ this.parent = parent;
613
+ this.hash = parent ? { ...parent.frame, ...hash } : hash;
614
+ this.scopeLevel = scopeLevel;
615
+ }
616
+ isNested() {
617
+ return this.scopeLevel === "nested";
618
+ }
619
+ isNull() {
620
+ return this.hash == null && this.parent == null;
621
+ }
622
+ isRoot() {
623
+ return this.parent === Scope.ROOT;
624
+ }
625
+ isResources() {
626
+ return this.scopeLevel === "resources";
627
+ }
628
+ isResourceMethodScope() {
629
+ return Scope.RESOURCE_METHOD_SCOPES.includes(this.scopeLevel);
630
+ }
631
+ actionName(namePrefix, prefix, collectionName, memberName) {
632
+ switch (this.scopeLevel) {
633
+ case "nested":
634
+ return [namePrefix, prefix];
635
+ case "collection":
636
+ return [prefix, namePrefix, collectionName];
637
+ case "new":
638
+ return [prefix, "new", namePrefix, memberName];
639
+ case "member":
640
+ return [prefix, namePrefix, memberName];
641
+ case "root":
642
+ return [namePrefix, collectionName, prefix];
643
+ default:
644
+ return [namePrefix, memberName, prefix];
645
+ }
646
+ }
647
+ isResourceScope() {
648
+ return Scope.RESOURCE_SCOPES.includes(this.scopeLevel);
649
+ }
650
+ options() {
651
+ return Scope.OPTIONS;
652
+ }
653
+ new(hash) {
654
+ return new this.constructor(hash, this, this.scopeLevel);
655
+ }
656
+ newLevel(level) {
657
+ return new this.constructor(this.frame, this, level);
658
+ }
659
+ get(key) {
660
+ return this.frame[key];
661
+ }
662
+ get frame() {
663
+ return this.hash;
664
+ }
665
+ each(block) {
666
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
667
+ let node = this;
668
+ while (node !== Scope.ROOT) {
669
+ block(node);
670
+ node = node.parent;
671
+ }
672
+ }
673
+ static ROOT = new Scope({}, null);
674
+ }
675
+ include(Scope, Enumerable);
676
+ export class Mapper {
677
+ static BacktraceCleaner = class extends ActiveSupport.BacktraceCleaner {
678
+ constructor() {
679
+ super();
680
+ this.removeSilencersBang();
681
+ this.addCoreSilencer();
682
+ this.addStdlibSilencer();
683
+ }
684
+ };
685
+ static URL_OPTIONS = [
686
+ "protocol",
687
+ "subdomain",
688
+ "domain",
689
+ "host",
690
+ "port",
691
+ ];
692
+ static {
693
+ cattrAccessor.call(this, "routeSourceLocations", { instanceAccessor: false, default: false });
694
+ cattrAccessor.call(this, "backtraceCleaner", {
695
+ instanceAccessor: false,
696
+ default: new this.BacktraceCleaner(),
697
+ });
698
+ }
699
+ static Scope = Scope;
700
+ static Resources = { name: "ActionDispatch::Routing::Mapper::Resources" };
701
+ /** @internal */
702
+ _concerns = new Map();
703
+ /** @internal */
704
+ _set;
705
+ /** @internal */
706
+ _drawPaths;
707
+ /** @internal */
708
+ _scope;
709
+ constructor(set) {
710
+ this._set = set;
711
+ this._drawPaths = set.drawPaths;
712
+ this._scope = new Scope({ pathNames: this._set.resourcesPathNames });
713
+ }
714
+ set defaultUrlOptions(options) {
715
+ this._set.defaultUrlOptions = options;
716
+ }
717
+ get defaultUrlOptions() {
718
+ return this._set.defaultUrlOptions;
719
+ }
720
+ get(...args) {
721
+ return this.mapMethod("GET", args);
722
+ }
723
+ post(...args) {
724
+ return this.mapMethod("POST", args);
725
+ }
726
+ put(...args) {
727
+ return this.mapMethod("PUT", args);
728
+ }
729
+ patch(...args) {
730
+ return this.mapMethod("PATCH", args);
731
+ }
732
+ delete(...args) {
733
+ return this.mapMethod("DELETE", args);
734
+ }
735
+ root(path, options = {}) {
736
+ if (typeof path === "string") {
737
+ options.to = path;
738
+ }
739
+ else if (isPlainObject(path) && Object.keys(options).length === 0) {
740
+ options = path;
741
+ }
742
+ else {
743
+ throw new ArgumentError("must be called with a path and/or options");
744
+ }
745
+ if (this._scope.isResources()) {
746
+ this.withScopeLevel("root", () => {
747
+ this.pathScope(this.parentResource().path, () => {
748
+ this.matchRootRoute(options);
749
+ });
750
+ });
751
+ }
752
+ else {
753
+ this.matchRootRoute(options);
754
+ }
755
+ }
756
+ resources(...resources) {
757
+ const block = (typeof resources.at(-1) === "function" ? resources.pop() : undefined);
758
+ let options = { ...extractOptionsBang(resources) };
759
+ if (this.applyCommonBehaviorFor("resources", resources, options, block)) {
760
+ return this;
761
+ }
762
+ this.withScopeLevel("resources", () => {
763
+ options = this.applyActionOptions("resources", options);
764
+ this.resourceScope(new Resource(resources.pop(), this.isApiOnly(), this._scope.get("shallow"), options), () => {
765
+ if (block)
766
+ block.call(this);
767
+ if (options.concerns)
768
+ this.concerns(options.concerns);
769
+ this.collection(() => {
770
+ if (this.parentResource().actions().includes("index"))
771
+ this.get(":index");
772
+ if (this.parentResource().actions().includes("create"))
773
+ this.post(":create");
774
+ });
775
+ if (this.parentResource().actions().includes("new")) {
776
+ this.new(() => {
777
+ this.get(":new");
778
+ });
779
+ }
780
+ this.setMemberMappingsForResource();
781
+ });
782
+ });
783
+ return this;
784
+ }
785
+ resource(...resources) {
786
+ const block = (typeof resources.at(-1) === "function" ? resources.pop() : undefined);
787
+ let options = { ...extractOptionsBang(resources) };
788
+ if (this.applyCommonBehaviorFor("resource", resources, options, block)) {
789
+ return this;
790
+ }
791
+ this.withScopeLevel("resource", () => {
792
+ options = this.applyActionOptions("resource", options);
793
+ this.resourceScope(new SingletonResource(resources.pop(), this.isApiOnly(), this._scope.get("shallow"), options), () => {
794
+ if (block)
795
+ block.call(this);
796
+ if (options.concerns)
797
+ this.concerns(options.concerns);
798
+ if (this.parentResource().actions().includes("new")) {
799
+ this.new(() => {
800
+ this.get(":new");
801
+ });
802
+ }
803
+ this.setMemberMappingsForResource();
804
+ if (this.parentResource().actions().includes("create")) {
805
+ this.collection(() => {
806
+ this.post(":create");
807
+ });
808
+ }
809
+ });
810
+ });
811
+ return this;
812
+ }
813
+ namespace(path, options = {}, block) {
814
+ const opts = typeof options === "function" ? {} : { ...options };
815
+ const cb = typeof options === "function" ? options : block;
816
+ if (!cb)
817
+ throw new Error("no block given (yield)");
818
+ if (this._scope.isResourceScope()) {
819
+ this.nested(() => this.namespace(path, opts, cb));
820
+ return;
821
+ }
822
+ path = String(path);
823
+ const defaults = {
824
+ module: path,
825
+ as: fetch(opts, "as", path),
826
+ shallowPath: fetch(opts, "path", path),
827
+ shallowPrefix: fetch(opts, "as", path),
828
+ };
829
+ this.pathScope(deleteWithDefault(opts, "path", path), () => {
830
+ this.scope(Object.assign(defaults, opts), cb);
831
+ });
832
+ }
833
+ scope(...args) {
834
+ const cb = args.pop();
835
+ const options = { ...extractOptionsBang(args) };
836
+ const scope = {};
837
+ if (args.length > 0)
838
+ options.path = args.flat(Infinity).join("/");
839
+ options.constraints ??= {};
840
+ if (!this.isNestedScope()) {
841
+ if ("path" in options)
842
+ options.shallowPath ??= options.path;
843
+ if ("as" in options)
844
+ options.shallowPrefix ??= options.as;
845
+ }
846
+ let block;
847
+ if (isPlainObject(options.constraints)) {
848
+ const defaults = Object.fromEntries(Object.entries(options.constraints).filter(([k, v]) => Mapper.URL_OPTIONS.includes(k) && (typeof v === "string" || Number.isInteger(v))));
849
+ options.defaults = { ...defaults, ...(options.defaults ?? {}) };
850
+ }
851
+ else {
852
+ block = options.constraints;
853
+ options.constraints = {};
854
+ }
855
+ if ("only" in options || "except" in options) {
856
+ scope.actionOptions = { only: options.only, except: options.except };
857
+ delete options.only;
858
+ delete options.except;
859
+ }
860
+ if ("anchor" in options) {
861
+ throw new ArgumentError("anchor is ignored unless passed to `match`");
862
+ }
863
+ const merges = this;
864
+ for (const option of this._scope.options()) {
865
+ let value = POISON;
866
+ if (option === "blocks") {
867
+ value = block;
868
+ }
869
+ else if (option === "options") {
870
+ value = options;
871
+ }
872
+ else if (option in options) {
873
+ value = options[option];
874
+ delete options[option];
875
+ }
876
+ if (value !== POISON) {
877
+ const merge = `merge${option[0].toUpperCase()}${option.slice(1)}Scope`;
878
+ scope[option] = merges[merge](this._scope.get(option), value);
879
+ }
880
+ }
881
+ const previous = this._scope;
882
+ this._scope = this._scope.new(scope);
883
+ try {
884
+ cb.call(this);
885
+ }
886
+ finally {
887
+ this._scope = previous;
888
+ }
889
+ }
890
+ member(callback) {
891
+ if (!this.isResourceScope()) {
892
+ throw new ArgumentError("can't use member outside resource(s) scope");
893
+ }
894
+ this.withScopeLevel("member", () => {
895
+ if (this.isShallow()) {
896
+ this.shallowScope(() => {
897
+ this.pathScope(this.parentResource().memberScope(), () => callback.call(this));
898
+ });
899
+ }
900
+ else {
901
+ this.pathScope(this.parentResource().memberScope(), () => callback.call(this));
902
+ }
903
+ });
904
+ }
905
+ collection(callback) {
906
+ if (!this.isResourceScope()) {
907
+ throw new ArgumentError("can't use collection outside resource(s) scope");
908
+ }
909
+ this.withScopeLevel("collection", () => {
910
+ this.pathScope(this.parentResource().collectionScope(), () => callback.call(this));
911
+ });
912
+ }
913
+ nested(callback) {
914
+ if (!this.isResourceScope()) {
915
+ throw new ArgumentError("can't use nested outside resource(s) scope");
916
+ }
917
+ this.withScopeLevel("nested", () => {
918
+ if (this.isShallow() && this.shallowNestingDepth() >= 1) {
919
+ this.shallowScope(() => {
920
+ this.pathScope(this.parentResource().nestedScope(), () => {
921
+ this.scope(this.nestedOptions(), callback);
922
+ });
923
+ });
924
+ }
925
+ else {
926
+ this.pathScope(this.parentResource().nestedScope(), () => {
927
+ this.scope(this.nestedOptions(), callback);
928
+ });
929
+ }
930
+ });
931
+ }
932
+ new(callback) {
933
+ if (!this.isResourceScope()) {
934
+ throw new ArgumentError("can't use new outside resource(s) scope");
935
+ }
936
+ this.withScopeLevel("new", () => {
937
+ this.pathScope(this.parentResource().newScope(this.actionPath("new")), () => callback.call(this));
938
+ });
939
+ }
940
+ shallow(callback) {
941
+ const previous = this._scope;
942
+ this._scope = this._scope.new({ shallow: true });
943
+ try {
944
+ callback.call(this);
945
+ }
946
+ finally {
947
+ this._scope = previous;
948
+ }
949
+ }
950
+ /**
951
+ * @missingRailsCall read — PERMANENT
952
+ * @missingRailsCall exist? — PERMANENT
953
+ */
954
+ draw(name) {
955
+ const path = this._drawPaths.find((_path) => loadedFileExports(`${_path}/${name}.ts`) !== undefined);
956
+ if (path == null) {
957
+ let msg = `Your router tried to #draw the external file ${name}.ts,\n` +
958
+ "but the file was not found in:\n\n";
959
+ msg += this._drawPaths.map((_path) => ` * ${_path}`).join("\n");
960
+ throw new ArgumentError(msg);
961
+ }
962
+ const routePath = `${path}/${name}.ts`;
963
+ const { drawRoutes } = loadedFileExports(routePath);
964
+ drawRoutes?.call(this);
965
+ }
966
+ /** @internal */
967
+ setMemberMappingsForResource() {
968
+ this.member(() => {
969
+ if (this.parentResource().actions().includes("edit"))
970
+ this.get(":edit");
971
+ if (this.parentResource().actions().includes("show"))
972
+ this.get(":show");
973
+ if (this.parentResource().actions().includes("update")) {
974
+ this.patch(":update");
975
+ this.put(":update");
976
+ }
977
+ if (this.parentResource().actions().includes("destroy"))
978
+ this.delete(":destroy");
979
+ });
980
+ }
981
+ constraints(constraints = {}, block) {
982
+ if (block === undefined) {
983
+ block = constraints;
984
+ constraints = {};
985
+ }
986
+ this.scope({ constraints }, block);
987
+ }
988
+ concern(name, callable = null, block) {
989
+ callable ??= (mapper, options) => block.call(mapper, options);
990
+ this._concerns.set(name, callable);
991
+ }
992
+ concerns(...args) {
993
+ const options = extractOptionsBang(args);
994
+ for (const name of args.flat(Infinity)) {
995
+ const concern = this._concerns.get(name);
996
+ if (concern != null) {
997
+ rbProcCall(concern, this, options);
998
+ }
999
+ else {
1000
+ throw new ArgumentError(`No concern named ${name} was found!`);
1001
+ }
1002
+ }
1003
+ }
1004
+ match(path, ...rest) {
1005
+ if (rest.length > 0 && (rest.at(-1) === undefined || rbBlockGivenP(rest.at(-1))))
1006
+ rest.pop();
1007
+ let options;
1008
+ let paths;
1009
+ if (rest.length === 0 && isPlainObject(path)) {
1010
+ options = path;
1011
+ let to;
1012
+ [path, to] = (Object.entries(options).find(([name, _value]) => !isSymbol(name)) ?? []);
1013
+ if (path == null)
1014
+ throw new ArgumentError("Route path not specified");
1015
+ if (isSymbol(to)) {
1016
+ options[":action"] = symbolToS(to);
1017
+ }
1018
+ else if (typeof to === "string") {
1019
+ if (to.includes("#")) {
1020
+ options[":to"] = to;
1021
+ }
1022
+ else {
1023
+ options[":controller"] = to;
1024
+ }
1025
+ }
1026
+ else {
1027
+ options[":to"] = to;
1028
+ }
1029
+ delete options[path];
1030
+ options = transformKeys(options, (name) => isSymbol(name) ? camelize(symbolToS(name), false) : name);
1031
+ paths = [path];
1032
+ }
1033
+ else {
1034
+ options = rest.pop() ?? {};
1035
+ paths = [path, ...rest];
1036
+ }
1037
+ if ("defaults" in options) {
1038
+ const defaults = options.defaults;
1039
+ delete options.defaults;
1040
+ this.defaults(defaults, () => this.mapMatch(paths, options));
1041
+ }
1042
+ else {
1043
+ this.mapMatch(paths, options);
1044
+ }
1045
+ }
1046
+ options(...args) {
1047
+ return this.mapMethod("OPTIONS", args);
1048
+ }
1049
+ connect(...args) {
1050
+ return this.mapMethod(["GET", "CONNECT"], args);
1051
+ }
1052
+ /** @internal */
1053
+ mapMethod(method, args, block = rbBlockGivenP(args.at(-1))
1054
+ ? args.pop()
1055
+ : undefined) {
1056
+ const options = extractOptionsBang(args);
1057
+ options[args.length === 0 ? ":via" : "via"] = method;
1058
+ this.match(...args, options, block);
1059
+ return this;
1060
+ }
1061
+ controller(controller, callback) {
1062
+ const previous = this._scope;
1063
+ this._scope = this._scope.new({ controller });
1064
+ try {
1065
+ callback.call(this);
1066
+ }
1067
+ finally {
1068
+ this._scope = previous;
1069
+ }
1070
+ }
1071
+ defaults(defaults, callback) {
1072
+ const previous = this._scope;
1073
+ const merged = this.mergeDefaultsScope(this._scope.get("defaults"), defaults);
1074
+ this._scope = this._scope.new({ defaults: merged });
1075
+ try {
1076
+ callback.call(this);
1077
+ }
1078
+ finally {
1079
+ this._scope = previous;
1080
+ }
1081
+ }
1082
+ mount(app, options = null) {
1083
+ let path;
1084
+ if (options) {
1085
+ path = hashDelete(options, "at");
1086
+ }
1087
+ else if (app instanceof Map) {
1088
+ options = app;
1089
+ [app, path] = (new Enumerable(options).find(([k, _]) => rbObjRespondTo(k, "call")) ?? []);
1090
+ if (app)
1091
+ hashDelete(options, app);
1092
+ }
1093
+ if (!rbObjRespondTo(app, "call")) {
1094
+ throw new ArgumentError("A rack application must be specified");
1095
+ }
1096
+ if (path == null) {
1097
+ throw new ArgumentError("Must be called with mount point\n\n" +
1098
+ ' mount SomeRackApp, at: "some_route"\n' +
1099
+ " or\n" +
1100
+ ' mount(SomeRackApp => "some_route")\n');
1101
+ }
1102
+ const trailsApp = this.isTrailsApp(app);
1103
+ if (!rtest(hashAref(options, "as")))
1104
+ hashAset(options, "as", this.appName(app, trailsApp));
1105
+ const targetAs = this.nameForAction(hashAref(options, "as"), path);
1106
+ if (!rtest(hashAref(options, "via")))
1107
+ hashAset(options, "via", ":all");
1108
+ this.match(path,
1109
+ // eslint-disable-next-line blazetrails/ruby-compat-native-required -- options may be a Hash, which merge converts through to_hash
1110
+ merge({ to: app, anchor: false, format: false }, options));
1111
+ if (trailsApp)
1112
+ this.defineGeneratePrefix(app, targetAs);
1113
+ return this;
1114
+ }
1115
+ /** @internal */
1116
+ isTrailsApp(app) {
1117
+ return (typeof app === "function" &&
1118
+ Object.getOwnPropertyDescriptor(app, "prototype")?.writable === false &&
1119
+ app.prototype instanceof TopLevel.Trails.Trailtie);
1120
+ }
1121
+ /** @internal */
1122
+ appName(app, trailsApp) {
1123
+ if (trailsApp) {
1124
+ return app.railtieName();
1125
+ }
1126
+ else if (typeof app === "function" &&
1127
+ Object.getOwnPropertyDescriptor(app, "prototype")?.writable === false) {
1128
+ const className = app.name;
1129
+ return underscore(className).replace(/\//g, "_");
1130
+ }
1131
+ return undefined;
1132
+ }
1133
+ /** @internal */
1134
+ defineGeneratePrefix(app, name) {
1135
+ const _route = this._set.namedRoutes.get(name);
1136
+ const _routes = this._set;
1137
+ const _urlHelpers = this._set.urlHelpers();
1138
+ const scriptNamer = (options) => {
1139
+ const prefixOptions = slice(options, ..._route.segmentKeys);
1140
+ if (options.originalScriptName != null && options.originalScriptName !== false) {
1141
+ prefixOptions.scriptName = "";
1142
+ }
1143
+ if (options._recall != null && options._recall !== false) {
1144
+ reverseMergeBang(prefixOptions, slice(options._recall, ..._route.segmentKeys));
1145
+ }
1146
+ _route.segmentKeys.forEach((k) => delete options[k]);
1147
+ return rbFSend(_urlHelpers, camelize(`${name}_path`, "lower"), prefixOptions);
1148
+ };
1149
+ app.routes().defineMountedHelper(name, scriptNamer);
1150
+ const findScriptName = function (options) {
1151
+ if ("scriptName" in options && isPresent(options.scriptName)) {
1152
+ return rbCallSuper(this, findScriptName, options);
1153
+ }
1154
+ else {
1155
+ return scriptNamer(options);
1156
+ }
1157
+ };
1158
+ extend(app.routes(), { isOptimizeRoutesGeneration: () => false, findScriptName });
1159
+ }
1160
+ /**
1161
+ * @internal
1162
+ * @missingRailsName array — PERMANENT
1163
+ */
1164
+ mapMatch(paths, options) {
1165
+ if (paths.length > 1) {
1166
+ deprecator().warn(squish(`Mapping a route with multiple paths is deprecated and
1167
+ will be removed in Rails 8.1. Please use multiple method calls instead.`));
1168
+ }
1169
+ let on;
1170
+ if ((on = options.on) != null && on !== false && !VALID_ON_OPTIONS.has(on)) {
1171
+ throw new ArgumentError(`Unknown scope :${on} given to :on`);
1172
+ }
1173
+ const scopeTo = this._scope.get("to");
1174
+ if (scopeTo)
1175
+ options.to ??= scopeTo;
1176
+ const scopeController = this._scope.get("controller");
1177
+ const scopeAction = this._scope.get("action");
1178
+ if (scopeController && scopeAction) {
1179
+ options.to ??= `${scopeController}#${scopeAction}`;
1180
+ }
1181
+ const controller = options.controller ?? scopeController;
1182
+ delete options.controller;
1183
+ const optionPath = options.path;
1184
+ delete options.path;
1185
+ let to = options.to;
1186
+ delete options.to;
1187
+ const via = Mapping.checkVia(rbFArray("via" in options ? options.via : this._scope.get("via")));
1188
+ delete options.via;
1189
+ const formatted = options.format ?? this._scope.get("format");
1190
+ delete options.format;
1191
+ const anchor = options.anchor ?? true;
1192
+ delete options.anchor;
1193
+ const optionsConstraints = options.constraints ?? {};
1194
+ delete options.constraints;
1195
+ const pathTypes = groupBy(paths, (path) => (SYMBOL.test(path) ? "Symbol" : "String"));
1196
+ for (const _path of pathTypes.get("String") ?? []) {
1197
+ const routeOptions = { ...options };
1198
+ if (_path && optionPath) {
1199
+ throw new ArgumentError("Ambiguous route definition. Both :path and the route path were specified as strings.");
1200
+ }
1201
+ to = this.getToFromPath(_path, to, routeOptions.action);
1202
+ this.decomposedMatch(_path, controller, routeOptions, _path, to, via, formatted, anchor, optionsConstraints);
1203
+ }
1204
+ for (const action of pathTypes.get("Symbol") ?? []) {
1205
+ const routeOptions = { ...options };
1206
+ this.decomposedMatch(action, controller, routeOptions, optionPath, to, via, formatted, anchor, optionsConstraints);
1207
+ }
1208
+ }
1209
+ /** @internal */
1210
+ getToFromPath(path, to, action) {
1211
+ if (to || action)
1212
+ return to;
1213
+ const pathWithoutFormat = path.replace(/\(\.:format\)$/, "");
1214
+ if (this.isUsingMatchShorthand(pathWithoutFormat)) {
1215
+ return pathWithoutFormat
1216
+ .replace(/^\//, "")
1217
+ .replace(/\/([^/]*)$/, "#$1")
1218
+ .replace(/-/g, "_");
1219
+ }
1220
+ return undefined;
1221
+ }
1222
+ /** @internal */
1223
+ isUsingMatchShorthand(path) {
1224
+ return /^\/?[-\w]+\/[-\w/]+$/.test(path);
1225
+ }
1226
+ /** @internal */
1227
+ decomposedMatch(path, controller, options, _path, to, via, formatted, anchor, optionsConstraints) {
1228
+ const recurse = () => this.decomposedMatch(path, controller, options, _path, to, via, formatted, anchor, optionsConstraints);
1229
+ const on = hashDelete(options, "on");
1230
+ if (on != null && on !== false) {
1231
+ rbFSend(this, on, recurse);
1232
+ }
1233
+ else {
1234
+ switch (this._scope.scopeLevel) {
1235
+ case "resources":
1236
+ this.nested(recurse);
1237
+ break;
1238
+ case "resource":
1239
+ this.member(recurse);
1240
+ break;
1241
+ default:
1242
+ this.addRoute(path, controller, options, _path, to, via, formatted, anchor, optionsConstraints);
1243
+ }
1244
+ }
1245
+ }
1246
+ /** @internal */
1247
+ matchRootRoute(options = {}) {
1248
+ this.match("/", { as: "root", via: "GET", ...options });
1249
+ }
1250
+ direct(name, options = {}, block) {
1251
+ if (!this._scope.isRoot()) {
1252
+ throw new RuntimeError("The direct method can't be used inside a routes scope block");
1253
+ }
1254
+ this._set.addUrlHelper(name, options, block);
1255
+ }
1256
+ resolve(...args) {
1257
+ if (!this._scope.isRoot()) {
1258
+ throw new RuntimeError("The resolve method can't be used inside a routes scope block");
1259
+ }
1260
+ const block = (typeof args.at(-1) === "function" ? args.pop() : undefined);
1261
+ const options = extractOptionsBang(args);
1262
+ args = args.flat(1);
1263
+ for (const klass of args) {
1264
+ this._set.addPolymorphicMapping(klass, options, block);
1265
+ }
1266
+ }
1267
+ /**
1268
+ * @missingRailsName delete — PERMANENT
1269
+ * @missingRailsName scope — PERMANENT
1270
+ * @missingRailsName set — PERMANENT
1271
+ */
1272
+ addRoute(action, controller, options, _path, to, via, formatted, anchor, optionsConstraints) {
1273
+ let path = this.pathForAction(action, _path);
1274
+ if (isBlank(path))
1275
+ throw new ArgumentError("path is required");
1276
+ action = SYMBOL.test(action) ? symbolToS(action) : String(action);
1277
+ let defaultAction = options.action != null && options.action !== false
1278
+ ? options.action
1279
+ : this._scope.get("action");
1280
+ delete options.action;
1281
+ if (/^[\w\-/]+$/.test(action)) {
1282
+ if (!action.includes("/") &&
1283
+ (defaultAction == null || defaultAction === false)) {
1284
+ defaultAction = action.replace(/-/g, "_");
1285
+ }
1286
+ }
1287
+ else {
1288
+ action = undefined;
1289
+ }
1290
+ let as;
1291
+ const asOption = fetch(options, "as", true);
1292
+ if (asOption == null || asOption === false) {
1293
+ as = options.as;
1294
+ delete options.as;
1295
+ }
1296
+ else {
1297
+ const given = options.as;
1298
+ delete options.as;
1299
+ as = this.nameForAction(given, action);
1300
+ }
1301
+ path = Mapping.normalizePath(RFC2396_PARSER.escape(path), formatted);
1302
+ const ast = Parser.parse(path);
1303
+ const mapping = Mapping.build(this._scope, this._set, ast, controller, defaultAction, to, via, formatted, optionsConstraints, anchor, options);
1304
+ this._set.addRoute(mapping, as);
1305
+ }
1306
+ isShallow() {
1307
+ return !this.parentResource().isSingleton() && this._scope.get("shallow") === true;
1308
+ }
1309
+ /** @internal */
1310
+ static normalizePath(path) {
1311
+ let result = "/" + path.replace(/\/+/g, "/").replace(/^\/+|\/+$/g, "");
1312
+ result = result.replace(/\/(\(+)\/?/g, "$1/");
1313
+ if (/^(\(+[^)]+\))(\(+\/:[^)]+\))*$/.test(result)) {
1314
+ result = result.replace(/^(\(+)\//, "/$1");
1315
+ }
1316
+ return result;
1317
+ }
1318
+ /** @internal */
1319
+ static normalizeName(name) {
1320
+ return Mapper.normalizePath(name).slice(1).replace(/\//g, "_");
1321
+ }
1322
+ /** @internal */
1323
+ mergePathScope(parent, child) {
1324
+ return Mapper.normalizePath(`${parent ?? ""}/${child ?? ""}`);
1325
+ }
1326
+ /** @internal */
1327
+ mergeShallowPathScope(parent, child) {
1328
+ return Mapper.normalizePath(`${parent ?? ""}/${child ?? ""}`);
1329
+ }
1330
+ /** @internal */
1331
+ mergeAsScope(parent, child) {
1332
+ return parent ? `${parent}_${child ?? ""}` : child;
1333
+ }
1334
+ /** @internal */
1335
+ mergeShallowPrefixScope(parent, child) {
1336
+ return parent ? `${parent}_${child ?? ""}` : child;
1337
+ }
1338
+ /** @internal */
1339
+ mergeModuleScope(parent, child) {
1340
+ return parent ? `${parent}/${child}` : child;
1341
+ }
1342
+ /** @internal */
1343
+ mergeControllerScope(_parent, child) {
1344
+ return child;
1345
+ }
1346
+ /** @internal */
1347
+ mergeActionScope(_parent, child) {
1348
+ return child;
1349
+ }
1350
+ /** @internal */
1351
+ mergeViaScope(_parent, child) {
1352
+ return child;
1353
+ }
1354
+ /** @internal */
1355
+ mergeFormatScope(_parent, child) {
1356
+ return child;
1357
+ }
1358
+ /** @internal */
1359
+ mergePathNamesScope(parent, child) {
1360
+ return this.mergeOptionsScope(parent, child);
1361
+ }
1362
+ /** @internal */
1363
+ mergeConstraintsScope(parent, child) {
1364
+ return this.mergeOptionsScope(parent, child);
1365
+ }
1366
+ /** @internal */
1367
+ mergeDefaultsScope(parent, child) {
1368
+ return this.mergeOptionsScope(parent, child);
1369
+ }
1370
+ /** @internal */
1371
+ mergeBlocksScope(parent, child) {
1372
+ const merged = parent ? [...parent] : [];
1373
+ if (child)
1374
+ merged.push(child);
1375
+ return merged;
1376
+ }
1377
+ /** @internal */
1378
+ mergeOptionsScope(parent, child) {
1379
+ return { ...(parent || {}), ...child };
1380
+ }
1381
+ /** @internal */
1382
+ mergeShallowScope(_parent, child) {
1383
+ return child ? true : false;
1384
+ }
1385
+ /** @internal */
1386
+ mergeToScope(_parent, child) {
1387
+ return child;
1388
+ }
1389
+ /** @internal */
1390
+ isActionOptions(options) {
1391
+ return Boolean(options.only || options.except);
1392
+ }
1393
+ /** @internal */
1394
+ applicableActionsFor(method) {
1395
+ if (method === "resources")
1396
+ return ["index", "create", "new", "show", "update", "destroy", "edit"];
1397
+ if (method === "resource")
1398
+ return ["create", "new", "show", "update", "destroy", "edit"];
1399
+ return [];
1400
+ }
1401
+ /** @internal */
1402
+ isResourceScope() {
1403
+ return this._scope.isResourceScope();
1404
+ }
1405
+ /** @internal */
1406
+ isNestedScope() {
1407
+ return this._scope.isNested();
1408
+ }
1409
+ /** @internal */
1410
+ isCanonicalAction(action) {
1411
+ return (this.isResourceMethodScope() &&
1412
+ CANONICAL_ACTIONS.includes(SYMBOL.test(action) ? symbolToS(action) : action));
1413
+ }
1414
+ /** @internal */
1415
+ isParamConstraint() {
1416
+ const constraints = this._scope.get("constraints");
1417
+ return constraints?.[this.parentResource().param] instanceof RegExp;
1418
+ }
1419
+ /** @internal */
1420
+ paramConstraint() {
1421
+ return this._scope.get("constraints")[this.parentResource().param];
1422
+ }
1423
+ /** @internal */
1424
+ shallowNestingDepth() {
1425
+ return this._scope
1426
+ .findAll((node) => node.frame.scopeLevelResource)
1427
+ .filter((node) => node.frame.scopeLevelResource.isShallow()).length;
1428
+ }
1429
+ /** @internal */
1430
+ pathForAction(action, path) {
1431
+ const prefix = this._scope.get("path") ?? "";
1432
+ if (path != null)
1433
+ return `${prefix}/${path}`;
1434
+ if (this.isCanonicalAction(action)) {
1435
+ return prefix;
1436
+ }
1437
+ else {
1438
+ const actionPath = this.actionPath(action);
1439
+ return `${prefix}/${SYMBOL.test(actionPath) ? symbolToS(actionPath) : actionPath}`;
1440
+ }
1441
+ }
1442
+ /**
1443
+ * @internal
1444
+ * @missingRailsName tr — PERMANENT
1445
+ */
1446
+ prefixNameForAction(as, action) {
1447
+ let prefix;
1448
+ if (as !== undefined && as !== null)
1449
+ prefix = as;
1450
+ else if (action && !this.isCanonicalAction(action))
1451
+ prefix = action;
1452
+ if (prefix && prefix !== "/" && prefix.length > 0) {
1453
+ return Mapper.normalizeName(prefix.replace(/-/g, "_"));
1454
+ }
1455
+ return undefined;
1456
+ }
1457
+ /** @internal */
1458
+ nameForAction(as, action) {
1459
+ const prefix = this.prefixNameForAction(as, action);
1460
+ const namePrefix = this._scope.get("as");
1461
+ let collectionName;
1462
+ let memberName;
1463
+ if (this.parentResource()) {
1464
+ if (as == null && action == null)
1465
+ return undefined;
1466
+ collectionName = this.parentResource().collectionName();
1467
+ memberName = this.parentResource().memberName();
1468
+ }
1469
+ const actionName = this._scope.actionName(namePrefix, prefix, collectionName, memberName);
1470
+ const candidate = actionName.filter((p) => isPresent(p)).join("_");
1471
+ if (!candidate)
1472
+ return undefined;
1473
+ if (as == null) {
1474
+ if (!/^[_a-z]/i.test(candidate) || this.hasNamedRoute(candidate))
1475
+ return undefined;
1476
+ }
1477
+ return candidate;
1478
+ }
1479
+ /** @internal */
1480
+ hasNamedRoute(name) {
1481
+ return this._set.namedRoutes.isKey(name);
1482
+ }
1483
+ /** @internal */
1484
+ withScopeLevel(kind, fn) {
1485
+ const previous = this._scope;
1486
+ this._scope = this._scope.newLevel(kind);
1487
+ try {
1488
+ return fn();
1489
+ }
1490
+ finally {
1491
+ this._scope = previous;
1492
+ }
1493
+ }
1494
+ /** @internal */
1495
+ pathScope(path, fn) {
1496
+ const previous = this._scope;
1497
+ const merged = this.mergePathScope(this._scope.get("path"), path);
1498
+ this._scope = this._scope.new({ path: merged });
1499
+ try {
1500
+ return fn();
1501
+ }
1502
+ finally {
1503
+ this._scope = previous;
1504
+ }
1505
+ }
1506
+ /** @internal */
1507
+ resourceScope(resource, fn) {
1508
+ const before = this._scope;
1509
+ this._scope = this._scope.new({ scopeLevelResource: resource });
1510
+ this._scope = this._scope.new({ controller: resource.resourceScope() });
1511
+ try {
1512
+ return fn();
1513
+ }
1514
+ finally {
1515
+ this._scope = before;
1516
+ }
1517
+ }
1518
+ /** @internal */
1519
+ shallowScope(fn) {
1520
+ const previous = this._scope;
1521
+ this._scope = this._scope.new({
1522
+ as: this._scope.get("shallowPrefix"),
1523
+ path: this._scope.get("shallowPath"),
1524
+ });
1525
+ try {
1526
+ return fn();
1527
+ }
1528
+ finally {
1529
+ this._scope = previous;
1530
+ }
1531
+ }
1532
+ /** @internal */
1533
+ withDefaultScope(scope, block) {
1534
+ this.scope(scope, () => {
1535
+ block.call(this);
1536
+ });
1537
+ }
1538
+ /** @internal */
1539
+ parentResource() {
1540
+ return this._scope.get("scopeLevelResource");
1541
+ }
1542
+ /** @internal */
1543
+ isResourceMethodScope() {
1544
+ return this._scope.isResourceMethodScope();
1545
+ }
1546
+ /** @internal */
1547
+ isNestedScopeLevel() {
1548
+ return this._scope.isNested();
1549
+ }
1550
+ /** @internal */
1551
+ isApiOnly() {
1552
+ return this._set.isApiOnly();
1553
+ }
1554
+ /** @internal */
1555
+ resourcesPathNames(options) {
1556
+ return Object.assign(this._scope.get("pathNames"), options);
1557
+ }
1558
+ /** @internal */
1559
+ actionPath(name) {
1560
+ const pathNames = this._scope.get("pathNames") ?? {};
1561
+ return pathNames[SYMBOL.test(name) ? symbolToS(name) : name] ?? name;
1562
+ }
1563
+ /** @internal */
1564
+ nestedOptions() {
1565
+ const options = { as: this.parentResource().memberName() };
1566
+ if (this.isParamConstraint()) {
1567
+ options.constraints = {
1568
+ [this.parentResource().nestedParam()]: this.paramConstraint(),
1569
+ };
1570
+ }
1571
+ return options;
1572
+ }
1573
+ /** @internal */
1574
+ scopeActionOptions(method) {
1575
+ const stored = this._scope.get("actionOptions");
1576
+ if (!stored)
1577
+ return {};
1578
+ const actions = this.applicableActionsFor(method);
1579
+ const result = { ...stored };
1580
+ if (stored.only) {
1581
+ const only = Array.isArray(stored.only) ? stored.only : [stored.only];
1582
+ result.only = only.filter((a) => actions.includes(a));
1583
+ }
1584
+ if (stored.except) {
1585
+ const except = Array.isArray(stored.except) ? stored.except : [stored.except];
1586
+ result.except = except.filter((a) => actions.includes(a));
1587
+ }
1588
+ return result;
1589
+ }
1590
+ /** @internal */
1591
+ applyActionOptions(method, options) {
1592
+ if (this.isActionOptions(options))
1593
+ return options;
1594
+ return { ...options, ...this.scopeActionOptions(method) };
1595
+ }
1596
+ /** @internal */
1597
+ applyCommonBehaviorFor(method, resources, options, block) {
1598
+ const self = this;
1599
+ const blockArg = block ? [block] : [];
1600
+ if (resources.length > 1) {
1601
+ for (const r of resources)
1602
+ self[method](r, options, ...blockArg);
1603
+ return true;
1604
+ }
1605
+ if (options.shallow) {
1606
+ delete options.shallow;
1607
+ this.shallow(() => self[method](resources.pop(), options, ...blockArg));
1608
+ return true;
1609
+ }
1610
+ if (this.isResourceScope()) {
1611
+ this.nested(() => self[method](resources.pop(), options, ...blockArg));
1612
+ return true;
1613
+ }
1614
+ const constraints = (options.constraints ?? {});
1615
+ let pulledAny = false;
1616
+ for (const k of Object.keys(options)) {
1617
+ const v = options[k];
1618
+ if (v instanceof RegExp) {
1619
+ constraints[k] = v;
1620
+ delete options[k];
1621
+ pulledAny = true;
1622
+ }
1623
+ }
1624
+ if (pulledAny)
1625
+ options.constraints = constraints;
1626
+ const scopeOptions = {};
1627
+ let hasScopeOption = false;
1628
+ for (const k of Object.keys(options)) {
1629
+ if (!RESOURCE_OPTIONS.has(k)) {
1630
+ scopeOptions[k] = options[k];
1631
+ delete options[k];
1632
+ hasScopeOption = true;
1633
+ }
1634
+ }
1635
+ if (hasScopeOption) {
1636
+ this.scope(scopeOptions, () => self[method](resources.pop(), options, ...blockArg));
1637
+ return true;
1638
+ }
1639
+ return false;
1640
+ }
1641
+ }
1642
+ const CANONICAL_ACTIONS = ["index", "create", "new", "show", "update", "destroy"];
1643
+ const POISON = {};
1644
+ /** @noRailsEquivalent PERMANENT */
1645
+ const SYMBOL = /^:\w+[?!=]?$/;
1646
+ const VALID_ON_OPTIONS = new Set(["new", "collection", "member"]);
1647
+ include(Mapper, Redirection);
1648
+ /** @noRailsEquivalent PERMANENT */
1649
+ function deleteWithDefault(hash, key, defaultValue) {
1650
+ if (!(key in hash))
1651
+ return defaultValue;
1652
+ const value = hash[key];
1653
+ delete hash[key];
1654
+ return value;
1655
+ }
1656
+ //# sourceMappingURL=mapper.js.map