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

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