@daffodil/external-router 0.39.13 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/daffodil-external-router.d.ts +1 -1
  2. package/driver/daffodil-external-router-driver.d.ts +1 -0
  3. package/driver/in-memory/daffodil-external-router-driver-in-memory.d.ts +1 -1
  4. package/driver/in-memory/in-memory.module.d.ts +5 -0
  5. package/driver/in-memory/in-memory.service.d.ts +3 -0
  6. package/driver/in-memory/package.json +5 -6
  7. package/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.d.ts +1 -1
  8. package/driver/magento/2.4.1/graphql/queries/resolve-url-v2.4.1.d.ts +1 -1
  9. package/driver/magento/2.4.1/magento.module.d.ts +5 -0
  10. package/driver/magento/2.4.1/magento.service.d.ts +3 -0
  11. package/driver/magento/2.4.1/package.json +5 -6
  12. package/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.d.ts +1 -1
  13. package/driver/magento/2.4.2/graphql/queries/resolve-url-v2.4.2.d.ts +1 -1
  14. package/driver/magento/2.4.2/magento.module.d.ts +5 -0
  15. package/driver/magento/2.4.2/magento.service.d.ts +3 -0
  16. package/driver/magento/2.4.2/package.json +5 -6
  17. package/driver/magento/2.4.3/daffodil-external-router-driver-magento-2.4.3.d.ts +5 -0
  18. package/driver/magento/2.4.3/graphql/queries/resolve.d.ts +6 -0
  19. package/driver/magento/2.4.3/index.d.ts +1 -0
  20. package/driver/magento/2.4.3/magento.module.d.ts +28 -0
  21. package/driver/magento/2.4.3/magento.service.d.ts +18 -0
  22. package/driver/magento/2.4.3/package.json +10 -0
  23. package/driver/magento/2.4.3/public_api.d.ts +2 -0
  24. package/driver/magento/2.4.3/transforms/resolution-to-resolvable-url.d.ts +3 -0
  25. package/driver/magento/daffodil-external-router-driver-magento.d.ts +1 -0
  26. package/driver/magento/model/public_api.d.ts +2 -0
  27. package/driver/magento/model/route-response.d.ts +4 -0
  28. package/driver/magento/model/route.d.ts +34 -0
  29. package/driver/magento/package.json +5 -6
  30. package/driver/package.json +5 -6
  31. package/driver/testing/daffodil-external-router-driver-testing.d.ts +1 -1
  32. package/driver/testing/package.json +5 -6
  33. package/driver/testing/testing.module.d.ts +5 -0
  34. package/driver/testing/testing.service.d.ts +3 -0
  35. package/{esm2015/config.js → esm2020/config.mjs} +1 -1
  36. package/esm2020/daffodil-external-router.mjs +5 -0
  37. package/{esm2015/driver/daffodil-external-router-driver.js → esm2020/driver/daffodil-external-router-driver.mjs} +0 -0
  38. package/esm2020/driver/in-memory/config.mjs +15 -0
  39. package/{esm2015/driver/in-memory/daffodil-external-router-driver-in-memory.js → esm2020/driver/in-memory/daffodil-external-router-driver-in-memory.mjs} +1 -2
  40. package/esm2020/driver/in-memory/in-memory.module.mjs +41 -0
  41. package/esm2020/driver/in-memory/in-memory.service.mjs +39 -0
  42. package/{esm2015/driver/in-memory/index.js → esm2020/driver/in-memory/index.mjs} +0 -0
  43. package/{esm2015/driver/in-memory/public_api.js → esm2020/driver/in-memory/public_api.mjs} +0 -0
  44. package/{esm2015/driver/index.js → esm2020/driver/index.mjs} +0 -0
  45. package/{esm2015/driver/interfaces/external-router-driver.interface.js → esm2020/driver/interfaces/external-router-driver.interface.mjs} +1 -1
  46. package/esm2020/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.mjs +5 -0
  47. package/{esm2015/driver/magento/2.4.1/graphql/queries/resolve-url-v2.4.1.js → esm2020/driver/magento/2.4.1/graphql/queries/resolve-url-v2.4.1.mjs} +0 -0
  48. package/{esm2015/driver/magento/2.4.1/index.js → esm2020/driver/magento/2.4.1/index.mjs} +0 -0
  49. package/esm2020/driver/magento/2.4.1/magento.module.mjs +55 -0
  50. package/esm2020/driver/magento/2.4.1/magento.service.mjs +38 -0
  51. package/{esm2015/driver/magento/2.4.1/public_api.js → esm2020/driver/magento/2.4.1/public_api.mjs} +0 -0
  52. package/esm2020/driver/magento/2.4.1/transforms/resolution-to-resolvable-url.mjs +10 -0
  53. package/esm2020/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.mjs +5 -0
  54. package/{esm2015/driver/magento/2.4.2/graphql/queries/resolve-url-v2.4.2.js → esm2020/driver/magento/2.4.2/graphql/queries/resolve-url-v2.4.2.mjs} +0 -0
  55. package/{esm2015/driver/magento/2.4.2/index.js → esm2020/driver/magento/2.4.2/index.mjs} +0 -0
  56. package/esm2020/driver/magento/2.4.2/magento.module.mjs +55 -0
  57. package/esm2020/driver/magento/2.4.2/magento.service.mjs +37 -0
  58. package/{esm2015/driver/magento/2.4.2/public_api.js → esm2020/driver/magento/2.4.2/public_api.mjs} +0 -0
  59. package/{esm2015/driver/magento/2.4.2/transforms/resolution-to-resolvable-url.js → esm2020/driver/magento/2.4.2/transforms/resolution-to-resolvable-url.mjs} +0 -0
  60. package/esm2020/driver/magento/2.4.3/daffodil-external-router-driver-magento-2.4.3.mjs +5 -0
  61. package/esm2020/driver/magento/2.4.3/graphql/queries/resolve.mjs +30 -0
  62. package/esm2020/driver/magento/2.4.3/index.mjs +2 -0
  63. package/esm2020/driver/magento/2.4.3/magento.module.mjs +55 -0
  64. package/esm2020/driver/magento/2.4.3/magento.service.mjs +37 -0
  65. package/esm2020/driver/magento/2.4.3/public_api.mjs +6 -0
  66. package/esm2020/driver/magento/2.4.3/transforms/resolution-to-resolvable-url.mjs +15 -0
  67. package/{esm2015/driver/magento/daffodil-external-router-driver-magento.js → esm2020/driver/magento/daffodil-external-router-driver-magento.mjs} +0 -0
  68. package/{esm2015/driver/magento/index.js → esm2020/driver/magento/index.mjs} +0 -0
  69. package/{esm2015/driver/magento/model/public_api.js → esm2020/driver/magento/model/public_api.mjs} +1 -1
  70. package/{esm2015/driver/magento/model/resolution-types.js → esm2020/driver/magento/model/resolution-types.mjs} +1 -1
  71. package/esm2020/driver/magento/model/route-response.mjs +2 -0
  72. package/esm2020/driver/magento/model/route.mjs +2 -0
  73. package/{esm2015/driver/magento/model/url-resolver-response.js → esm2020/driver/magento/model/url-resolver-response.mjs} +0 -0
  74. package/esm2020/driver/magento/model/url-resolver.mjs +2 -0
  75. package/{esm2015/driver/magento/public_api.js → esm2020/driver/magento/public_api.mjs} +0 -0
  76. package/{esm2015/driver/magento/transforms/public_api.js → esm2020/driver/magento/transforms/public_api.mjs} +0 -0
  77. package/{esm2015/driver/magento/transforms/redirect-to-http.js → esm2020/driver/magento/transforms/redirect-to-http.mjs} +0 -0
  78. package/{esm2015/driver/not-found-resolution.js → esm2020/driver/not-found-resolution.mjs} +0 -0
  79. package/{esm2015/driver/public_api.js → esm2020/driver/public_api.mjs} +0 -0
  80. package/{esm2015/driver/testing/config.js → esm2020/driver/testing/config.mjs} +1 -1
  81. package/esm2020/driver/testing/daffodil-external-router-driver-testing.mjs +5 -0
  82. package/{esm2015/driver/testing/index.js → esm2020/driver/testing/index.mjs} +0 -0
  83. package/{esm2015/driver/testing/public_api.js → esm2020/driver/testing/public_api.mjs} +0 -0
  84. package/esm2020/driver/testing/testing.module.mjs +38 -0
  85. package/esm2020/driver/testing/testing.service.mjs +45 -0
  86. package/{esm2015/errors/no-wildcard.js → esm2020/errors/no-wildcard.mjs} +1 -1
  87. package/{esm2015/errors/unknown-type.js → esm2020/errors/unknown-type.mjs} +1 -1
  88. package/esm2020/external-router.module.mjs +31 -0
  89. package/{esm2015/model/insertion-strategy.type.js → esm2020/model/insertion-strategy.type.mjs} +0 -0
  90. package/{esm2015/model/public_api.js → esm2020/model/public_api.mjs} +0 -0
  91. package/esm2020/model/resolvable-route.mjs +2 -0
  92. package/esm2020/model/route-data.mjs +2 -0
  93. package/esm2020/model/route-info.mjs +2 -0
  94. package/{esm2015/model/route-type.js → esm2020/model/route-type.mjs} +0 -0
  95. package/esm2020/model/route-with-data-path.mjs +2 -0
  96. package/esm2020/model/route-with-seo-data.mjs +2 -0
  97. package/esm2020/model/route-with-type.mjs +2 -0
  98. package/{esm2015/model/route-without-path.js → esm2020/model/route-without-path.mjs} +0 -0
  99. package/{esm2015/model/type-route-pair.js → esm2020/model/type-route-pair.mjs} +1 -1
  100. package/{esm2015/public_api.js → esm2020/public_api.mjs} +2 -1
  101. package/esm2020/router/router.service.mjs +43 -0
  102. package/esm2020/router/strategies/insert-data-path.mjs +84 -0
  103. package/{esm2015/router/strategies/insert-route-before-wildcard.js → esm2020/router/strategies/insert-route-before-wildcard.mjs} +0 -0
  104. package/esm2020/router/url-matcher/data-path-matcher.mjs +31 -0
  105. package/{esm2015/routing/daffodil-external-router-routing.js → esm2020/routing/daffodil-external-router-routing.mjs} +0 -0
  106. package/{esm2015/routing/errors/client-error.js → esm2020/routing/errors/client-error.mjs} +1 -1
  107. package/{esm2015/routing/errors/not-found-error.js → esm2020/routing/errors/not-found-error.mjs} +1 -1
  108. package/{esm2015/routing/errors/permanent-redirect.js → esm2020/routing/errors/permanent-redirect.mjs} +1 -1
  109. package/{esm2015/routing/errors/server-error.js → esm2020/routing/errors/server-error.mjs} +1 -1
  110. package/{esm2015/routing/errors/temporary-redirect.js → esm2020/routing/errors/temporary-redirect.mjs} +1 -1
  111. package/esm2020/routing/guard/existence.guard.mjs +77 -0
  112. package/{esm2015/routing/index.js → esm2020/routing/index.mjs} +0 -0
  113. package/{esm2015/routing/processors/process-errors.js → esm2020/routing/processors/process-errors.mjs} +0 -0
  114. package/{esm2015/routing/processors/process-redirect.js → esm2020/routing/processors/process-redirect.mjs} +0 -0
  115. package/{esm2015/routing/public_api.js → esm2020/routing/public_api.mjs} +0 -0
  116. package/{esm2015/token/type-resolvable-routes.token.js → esm2020/token/type-resolvable-routes.token.mjs} +1 -1
  117. package/esm2020/transform/resolved-route-to-route.mjs +24 -0
  118. package/esm2020/util/extract-daff-path-data.mjs +9 -0
  119. package/external-router.module.d.ts +5 -0
  120. package/fesm2015/{daffodil-external-router-driver-in-memory.js → daffodil-external-router-driver-in-memory.mjs} +28 -21
  121. package/fesm2015/daffodil-external-router-driver-in-memory.mjs.map +1 -0
  122. package/fesm2015/{daffodil-external-router-driver-magento-2.4.1.js → daffodil-external-router-driver-magento-2.4.1.mjs} +24 -20
  123. package/fesm2015/daffodil-external-router-driver-magento-2.4.1.mjs.map +1 -0
  124. package/fesm2015/{daffodil-external-router-driver-magento-2.4.2.js → daffodil-external-router-driver-magento-2.4.2.mjs} +24 -20
  125. package/fesm2015/daffodil-external-router-driver-magento-2.4.2.mjs.map +1 -0
  126. package/fesm2015/daffodil-external-router-driver-magento-2.4.3.mjs +143 -0
  127. package/fesm2015/daffodil-external-router-driver-magento-2.4.3.mjs.map +1 -0
  128. package/fesm2015/{daffodil-external-router-driver-magento.js → daffodil-external-router-driver-magento.mjs} +1 -1
  129. package/fesm2015/daffodil-external-router-driver-magento.mjs.map +1 -0
  130. package/fesm2015/daffodil-external-router-driver-testing.mjs +101 -0
  131. package/fesm2015/daffodil-external-router-driver-testing.mjs.map +1 -0
  132. package/fesm2015/{daffodil-external-router-driver.js → daffodil-external-router-driver.mjs} +1 -1
  133. package/fesm2015/daffodil-external-router-driver.mjs.map +1 -0
  134. package/fesm2015/daffodil-external-router-routing.mjs +173 -0
  135. package/fesm2015/daffodil-external-router-routing.mjs.map +1 -0
  136. package/fesm2015/{daffodil-external-router.js → daffodil-external-router.mjs} +45 -29
  137. package/fesm2015/daffodil-external-router.mjs.map +1 -0
  138. package/fesm2020/daffodil-external-router-driver-in-memory.mjs +98 -0
  139. package/fesm2020/daffodil-external-router-driver-in-memory.mjs.map +1 -0
  140. package/fesm2020/daffodil-external-router-driver-magento-2.4.1.mjs +122 -0
  141. package/fesm2020/daffodil-external-router-driver-magento-2.4.1.mjs.map +1 -0
  142. package/fesm2020/daffodil-external-router-driver-magento-2.4.2.mjs +122 -0
  143. package/fesm2020/daffodil-external-router-driver-magento-2.4.2.mjs.map +1 -0
  144. package/fesm2020/daffodil-external-router-driver-magento-2.4.3.mjs +140 -0
  145. package/fesm2020/daffodil-external-router-driver-magento-2.4.3.mjs.map +1 -0
  146. package/fesm2020/daffodil-external-router-driver-magento.mjs +22 -0
  147. package/fesm2020/daffodil-external-router-driver-magento.mjs.map +1 -0
  148. package/fesm2020/daffodil-external-router-driver-testing.mjs +99 -0
  149. package/fesm2020/daffodil-external-router-driver-testing.mjs.map +1 -0
  150. package/fesm2020/daffodil-external-router-driver.mjs +30 -0
  151. package/fesm2020/daffodil-external-router-driver.mjs.map +1 -0
  152. package/{fesm2015/daffodil-external-router-routing.js → fesm2020/daffodil-external-router-routing.mjs} +21 -19
  153. package/fesm2020/daffodil-external-router-routing.mjs.map +1 -0
  154. package/fesm2020/daffodil-external-router.mjs +303 -0
  155. package/fesm2020/daffodil-external-router.mjs.map +1 -0
  156. package/model/resolvable-route.d.ts +11 -0
  157. package/model/route-data.d.ts +8 -0
  158. package/model/route-info.d.ts +2 -2
  159. package/model/route-with-data-path.d.ts +3 -4
  160. package/model/route-with-seo-data.d.ts +12 -0
  161. package/model/route-with-type.d.ts +12 -0
  162. package/package.json +91 -15
  163. package/public_api.d.ts +1 -0
  164. package/router/router.service.d.ts +3 -0
  165. package/routing/daffodil-external-router-routing.d.ts +1 -0
  166. package/routing/guard/existence.guard.d.ts +3 -0
  167. package/routing/package.json +5 -6
  168. package/util/extract-daff-path-data.d.ts +6 -0
  169. package/bundles/daffodil-external-router-driver-in-memory.umd.js +0 -100
  170. package/bundles/daffodil-external-router-driver-in-memory.umd.js.map +0 -1
  171. package/bundles/daffodil-external-router-driver-in-memory.umd.min.js +0 -2
  172. package/bundles/daffodil-external-router-driver-in-memory.umd.min.js.map +0 -1
  173. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.js +0 -438
  174. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.js.map +0 -1
  175. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.min.js +0 -16
  176. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.min.js.map +0 -1
  177. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.js +0 -435
  178. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.js.map +0 -1
  179. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.min.js +0 -16
  180. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.min.js.map +0 -1
  181. package/bundles/daffodil-external-router-driver-magento.umd.js +0 -31
  182. package/bundles/daffodil-external-router-driver-magento.umd.js.map +0 -1
  183. package/bundles/daffodil-external-router-driver-magento.umd.min.js +0 -2
  184. package/bundles/daffodil-external-router-driver-magento.umd.min.js.map +0 -1
  185. package/bundles/daffodil-external-router-driver-testing.umd.js +0 -101
  186. package/bundles/daffodil-external-router-driver-testing.umd.js.map +0 -1
  187. package/bundles/daffodil-external-router-driver-testing.umd.min.js +0 -2
  188. package/bundles/daffodil-external-router-driver-testing.umd.min.js.map +0 -1
  189. package/bundles/daffodil-external-router-driver.umd.js +0 -39
  190. package/bundles/daffodil-external-router-driver.umd.js.map +0 -1
  191. package/bundles/daffodil-external-router-driver.umd.min.js +0 -2
  192. package/bundles/daffodil-external-router-driver.umd.min.js.map +0 -1
  193. package/bundles/daffodil-external-router-routing.umd.js +0 -505
  194. package/bundles/daffodil-external-router-routing.umd.js.map +0 -1
  195. package/bundles/daffodil-external-router-routing.umd.min.js +0 -16
  196. package/bundles/daffodil-external-router-routing.umd.min.js.map +0 -1
  197. package/bundles/daffodil-external-router.umd.js +0 -625
  198. package/bundles/daffodil-external-router.umd.js.map +0 -1
  199. package/bundles/daffodil-external-router.umd.min.js +0 -16
  200. package/bundles/daffodil-external-router.umd.min.js.map +0 -1
  201. package/daffodil-external-router.metadata.json +0 -1
  202. package/driver/daffodil-external-router-driver.metadata.json +0 -1
  203. package/driver/in-memory/daffodil-external-router-driver-in-memory.metadata.json +0 -1
  204. package/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.metadata.json +0 -1
  205. package/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.metadata.json +0 -1
  206. package/driver/magento/daffodil-external-router-driver-magento.metadata.json +0 -1
  207. package/driver/testing/daffodil-external-router-driver-testing.metadata.json +0 -1
  208. package/esm2015/daffodil-external-router.js +0 -6
  209. package/esm2015/driver/in-memory/config.js +0 -17
  210. package/esm2015/driver/in-memory/in-memory.module.js +0 -36
  211. package/esm2015/driver/in-memory/in-memory.service.js +0 -36
  212. package/esm2015/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.js +0 -6
  213. package/esm2015/driver/magento/2.4.1/magento.module.js +0 -50
  214. package/esm2015/driver/magento/2.4.1/magento.service.js +0 -40
  215. package/esm2015/driver/magento/2.4.1/transforms/resolution-to-resolvable-url.js +0 -13
  216. package/esm2015/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.js +0 -6
  217. package/esm2015/driver/magento/2.4.2/magento.module.js +0 -50
  218. package/esm2015/driver/magento/2.4.2/magento.service.js +0 -39
  219. package/esm2015/driver/magento/model/url-resolver.js +0 -2
  220. package/esm2015/driver/testing/daffodil-external-router-driver-testing.js +0 -6
  221. package/esm2015/driver/testing/testing.module.js +0 -33
  222. package/esm2015/driver/testing/testing.service.js +0 -45
  223. package/esm2015/external-router.module.js +0 -26
  224. package/esm2015/model/resolvable-route.js +0 -2
  225. package/esm2015/model/route-info.js +0 -2
  226. package/esm2015/model/route-with-data-path.js +0 -2
  227. package/esm2015/router/router.service.js +0 -44
  228. package/esm2015/router/strategies/insert-data-path.js +0 -83
  229. package/esm2015/router/url-matcher/data-path-matcher.js +0 -32
  230. package/esm2015/routing/guard/existence.guard.js +0 -78
  231. package/esm2015/transform/resolved-route-to-route.js +0 -17
  232. package/fesm2015/daffodil-external-router-driver-in-memory.js.map +0 -1
  233. package/fesm2015/daffodil-external-router-driver-magento-2.4.1.js.map +0 -1
  234. package/fesm2015/daffodil-external-router-driver-magento-2.4.2.js.map +0 -1
  235. package/fesm2015/daffodil-external-router-driver-magento.js.map +0 -1
  236. package/fesm2015/daffodil-external-router-driver-testing.js +0 -93
  237. package/fesm2015/daffodil-external-router-driver-testing.js.map +0 -1
  238. package/fesm2015/daffodil-external-router-driver.js.map +0 -1
  239. package/fesm2015/daffodil-external-router-routing.js.map +0 -1
  240. package/fesm2015/daffodil-external-router.js.map +0 -1
  241. package/routing/daffodil-external-router-routing.metadata.json +0 -1
@@ -0,0 +1,173 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Inject } from '@angular/core';
3
+ import { of } from 'rxjs';
4
+ import { map, switchMap, catchError } from 'rxjs/operators';
5
+ import * as i1 from '@daffodil/external-router';
6
+ import { DAFF_EXTERNAL_ROUTER_CONFIG } from '@daffodil/external-router';
7
+ import { DaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
+ import { DaffInheritableError } from '@daffodil/core';
9
+ import * as i2 from '@angular/router';
10
+ import * as i3 from '@daffodil/core/routing';
11
+
12
+ /**
13
+ * An error thrown when the driver encounters a 4xx error.
14
+ */
15
+ class DaffExternalRouterClientError extends DaffInheritableError {
16
+ constructor(message) {
17
+ super(message);
18
+ this.code = '4xx_CLIENT_ERROR';
19
+ }
20
+ }
21
+
22
+ /**
23
+ * An error thrown when the driver determines that a given url is not resolvable.
24
+ */
25
+ class DaffExternalRouterNotFoundError extends DaffExternalRouterClientError {
26
+ constructor(message) {
27
+ super(message);
28
+ this.code = '404_NOT_FOUND';
29
+ }
30
+ }
31
+
32
+ /**
33
+ * An error thrown when the driver determines that the url needs to be routed somewhere
34
+ * else permanently.
35
+ */
36
+ class DaffExternalRouterPermanentRedirectError extends DaffInheritableError {
37
+ constructor(redirectUrl, message) {
38
+ super(message);
39
+ this.redirectUrl = redirectUrl;
40
+ this.code = '302_PERMANENT_REDIRECT';
41
+ }
42
+ }
43
+
44
+ /**
45
+ * An error thrown when the driver needs a URI to be temporarily redirected
46
+ * to another location.
47
+ */
48
+ class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError {
49
+ constructor(redirectUrl, message) {
50
+ super(message);
51
+ this.redirectUrl = redirectUrl;
52
+ this.code = 'TEMPORARY_REDIRECT';
53
+ }
54
+ }
55
+
56
+ /**
57
+ * An error thrown when the platform performing url resolution fails.
58
+ */
59
+ class DaffExternalRouterServerError extends DaffInheritableError {
60
+ constructor(message) {
61
+ super(message);
62
+ this.code = '5xx_SERVER_ERROR';
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Processes resolved URLs and throws the appropriate error so that External Router
68
+ * can handle routing errors.
69
+ */
70
+ const processErrors = (url) => {
71
+ if (url.code === 404) {
72
+ throw new DaffExternalRouterNotFoundError();
73
+ }
74
+ else if (url.code >= 400 && url.code < 500) {
75
+ throw new DaffExternalRouterClientError();
76
+ }
77
+ else if (url.code >= 500) {
78
+ throw new DaffExternalRouterServerError();
79
+ }
80
+ else {
81
+ return url;
82
+ }
83
+ };
84
+
85
+ /**
86
+ * Processes resolvedUrls and throws the appropriate error so that External Router
87
+ * can handle redirects.
88
+ */
89
+ const processRedirects = (url) => {
90
+ if (url.code === 301) {
91
+ throw new DaffExternalRouterPermanentRedirectError(url.url);
92
+ }
93
+ else if (url.code === 302) {
94
+ throw new DaffExternalRouterTemporaryRedirectError(url.url);
95
+ }
96
+ else {
97
+ return url;
98
+ }
99
+ };
100
+
101
+ /**
102
+ * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route
103
+ * of an Angular App and either navigating to a resolved route upon successful resolution
104
+ * or navigating to the configured route upon a failed resolution.
105
+ */
106
+ class DaffExternalRouterExistenceGuard {
107
+ constructor(driver, externalRouter, router, config, urlNormalizer) {
108
+ this.driver = driver;
109
+ this.externalRouter = externalRouter;
110
+ this.router = router;
111
+ this.config = config;
112
+ this.urlNormalizer = urlNormalizer;
113
+ }
114
+ canActivate(next, state) {
115
+ return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(map((resolvedRoute) => processErrors(resolvedRoute)), switchMap(resolvedRoute => {
116
+ this.externalRouter.add(resolvedRoute);
117
+ return of(resolvedRoute);
118
+ }), map((resolvedRoute) => processRedirects(resolvedRoute)),
119
+ // Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.
120
+ // When we succeed, redirect to the new route, as config has changed since we init'd.
121
+ map(() => this.router.parseUrl(state.url)),
122
+ // When we fail, we need to process errors as dictated by the error type.
123
+ // Handle redirects
124
+ catchError(error => {
125
+ if (!(error instanceof DaffExternalRouterPermanentRedirectError) &&
126
+ !(error instanceof DaffExternalRouterTemporaryRedirectError)) {
127
+ throw error;
128
+ }
129
+ return of(this.router.parseUrl(error.redirectUrl));
130
+ }),
131
+ // Handle "404"
132
+ catchError((error) => {
133
+ if (!(error instanceof DaffExternalRouterNotFoundError)) {
134
+ throw error;
135
+ }
136
+ return of(this.router.parseUrl(this.config.notFoundResolutionPath));
137
+ }),
138
+ //Otherwise something went horribly wrong and we need to bail out.
139
+ catchError((error) => {
140
+ //TODO(damienwebdev): Add a logging system.
141
+ //This log is intentional until we have a better logging system in place.
142
+ console.log(error);
143
+ return of(this.router.parseUrl(this.config.failedResolutionPath));
144
+ }));
145
+ }
146
+ }
147
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterExistenceGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterExistenceGuard, deps: [{ token: DaffExternalRouterDriver }, { token: i1.DaffExternalRouter }, { token: i2.Router }, { token: DAFF_EXTERNAL_ROUTER_CONFIG }, { token: i3.DaffRoutingUriNormalizer }], target: i0.ɵɵFactoryTarget.Injectable });
148
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterExistenceGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterExistenceGuard, providedIn: 'root' });
149
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterExistenceGuard, decorators: [{
150
+ type: Injectable,
151
+ args: [{
152
+ providedIn: 'root',
153
+ }]
154
+ }], ctorParameters: function () {
155
+ return [{ type: undefined, decorators: [{
156
+ type: Inject,
157
+ args: [DaffExternalRouterDriver]
158
+ }] }, { type: i1.DaffExternalRouter }, { type: i2.Router }, { type: undefined, decorators: [{
159
+ type: Inject,
160
+ args: [DAFF_EXTERNAL_ROUTER_CONFIG]
161
+ }] }, { type: i3.DaffRoutingUriNormalizer }];
162
+ } });
163
+
164
+ /*
165
+ * Public API Surface of @daffodil/external-router/routing
166
+ */
167
+
168
+ /**
169
+ * Generated bundle index. Do not edit.
170
+ */
171
+
172
+ export { DaffExternalRouterExistenceGuard };
173
+ //# sourceMappingURL=daffodil-external-router-routing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-external-router-routing.mjs","sources":["../../../libs/external-router/routing/src/errors/client-error.ts","../../../libs/external-router/routing/src/errors/not-found-error.ts","../../../libs/external-router/routing/src/errors/permanent-redirect.ts","../../../libs/external-router/routing/src/errors/temporary-redirect.ts","../../../libs/external-router/routing/src/errors/server-error.ts","../../../libs/external-router/routing/src/processors/process-errors.ts","../../../libs/external-router/routing/src/processors/process-redirect.ts","../../../libs/external-router/routing/src/guard/existence.guard.ts","../../../libs/external-router/routing/src/public_api.ts","../../../libs/external-router/routing/src/daffodil-external-router-routing.ts"],"sourcesContent":["import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver encounters a 4xx error.\n */\nexport class DaffExternalRouterClientError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '4xx_CLIENT_ERROR';\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { DaffError } from '@daffodil/core';\n\nimport { DaffExternalRouterClientError } from './client-error';\n\n/**\n * An error thrown when the driver determines that a given url is not resolvable.\n */\nexport class DaffExternalRouterNotFoundError extends DaffExternalRouterClientError\n implements DaffError {\n public readonly code: string = '404_NOT_FOUND';\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver determines that the url needs to be routed somewhere\n * else permanently.\n */\nexport class DaffExternalRouterPermanentRedirectError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '302_PERMANENT_REDIRECT';\n\n constructor(public redirectUrl: string, message?: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver needs a URI to be temporarily redirected\n * to another location.\n */\nexport class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = 'TEMPORARY_REDIRECT';\n\n constructor(public redirectUrl: string, message?: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the platform performing url resolution fails.\n */\nexport class DaffExternalRouterServerError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '5xx_SERVER_ERROR';\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n\nimport { DaffExternalRouterClientError } from '../errors/client-error';\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterServerError } from '../errors/server-error';\n\n/**\n * Processes resolved URLs and throws the appropriate error so that External Router\n * can handle routing errors.\n */\nexport const processErrors = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 404 ){\n throw new DaffExternalRouterNotFoundError();\n } else if(url.code >= 400 && url.code < 500) {\n throw new DaffExternalRouterClientError();\n } else if(url.code >= 500) {\n throw new DaffExternalRouterServerError();\n } else {\n return url;\n }\n};\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\n\n/**\n * Processes resolvedUrls and throws the appropriate error so that External Router\n * can handle redirects.\n */\nexport const processRedirects = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 301){\n throw new DaffExternalRouterPermanentRedirectError(url.url);\n } else if(url.code === 302) {\n throw new DaffExternalRouterTemporaryRedirectError(url.url);\n } else {\n return url;\n }\n};\n","import { isPlatformServer } from '@angular/common';\nimport {\n Injectable,\n Inject,\n PLATFORM_ID,\n} from '@angular/core';\nimport {\n CanActivate,\n ActivatedRouteSnapshot,\n Router,\n RouterStateSnapshot,\n UrlTree,\n} from '@angular/router';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n switchMap,\n} from 'rxjs/operators';\n\nimport { DaffRoutingUriNormalizer } from '@daffodil/core/routing';\nimport {\n DaffExternalRouter,\n DaffExternalRouterConfiguration,\n DAFF_EXTERNAL_ROUTER_CONFIG,\n DaffExternallyResolvableUrl,\n} from '@daffodil/external-router';\nimport {\n DaffExternalRouterDriverInterface,\n DaffExternalRouterDriver,\n} from '@daffodil/external-router/driver';\n\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\nimport { processErrors } from '../processors/process-errors';\nimport { processRedirects } from '../processors/process-redirect';\n\n/**\n * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route\n * of an Angular App and either navigating to a resolved route upon successful resolution\n * or navigating to the configured route upon a failed resolution.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterExistenceGuard implements CanActivate {\n constructor(\n @Inject(DaffExternalRouterDriver)\n private driver: DaffExternalRouterDriverInterface,\n private externalRouter: DaffExternalRouter,\n private router: Router,\n @Inject(DAFF_EXTERNAL_ROUTER_CONFIG)\n private config: DaffExternalRouterConfiguration,\n private urlNormalizer: DaffRoutingUriNormalizer,\n ) { }\n\n canActivate(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Observable<UrlTree | boolean> {\n return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(\n map((resolvedRoute: DaffExternallyResolvableUrl) => processErrors(resolvedRoute)),\n switchMap(resolvedRoute => {\n this.externalRouter.add(resolvedRoute);\n return of(resolvedRoute);\n }),\n map((resolvedRoute: DaffExternallyResolvableUrl) => processRedirects(resolvedRoute)),\n // Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.\n // When we succeed, redirect to the new route, as config has changed since we init'd.\n map(() => this.router.parseUrl(state.url)),\n // When we fail, we need to process errors as dictated by the error type.\n // Handle redirects\n catchError(error => {\n if (\n !(error instanceof DaffExternalRouterPermanentRedirectError) &&\n !(error instanceof DaffExternalRouterTemporaryRedirectError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(error.redirectUrl));\n }),\n // Handle \"404\"\n catchError((error) => {\n if (!(error instanceof DaffExternalRouterNotFoundError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(this.config.notFoundResolutionPath));\n }),\n\n //Otherwise something went horribly wrong and we need to bail out.\n catchError((error) => {\n //TODO(damienwebdev): Add a logging system.\n //This log is intentional until we have a better logging system in place.\n console.log(error);\n return of(this.router.parseUrl(this.config.failedResolutionPath));\n }),\n );\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/routing\n */\nexport { DaffExternalRouterExistenceGuard } from './guard/existence.guard';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAKA;;AAEG;AACG,MAAO,6BAA8B,SAAQ,oBAAoB,CAAA;AAIrE,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC;AAHA,QAAA,IAAI,CAAA,IAAA,GAAW,kBAAkB,CAAC;KAIjD;AACF;;ACXD;;AAEG;AACG,MAAO,+BAAgC,SAAQ,6BAA6B,CAAA;AAIhF,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC;AAHA,QAAA,IAAI,CAAA,IAAA,GAAW,eAAe,CAAC;KAI9C;AACF;;ACTD;;;AAGG;AACG,MAAO,wCAAyC,SAAQ,oBAAoB,CAAA;IAIhF,WAAmB,CAAA,W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AAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gCAAgC,cAF/B,MAAM,EAAA,CAAA,CAAA;2FAEP,gCAAgC,EAAA,UAAA,EAAA,CAAA;kBAH5C,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;iBACnB,CAAA;;;8BAGI,MAAM;+BAAC,wBAAwB,CAAA;;8BAI/B,MAAM;+BAAC,2BAA2B,CAAA;;;;ACvDvC;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,7 +1,8 @@
1
1
  import { CommonModule } from '@angular/common';
2
- import { InjectionToken, NgModule, ɵɵdefineInjectable, ɵɵinject, Injectable, Inject } from '@angular/core';
3
- import { Router } from '@angular/router';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, NgModule, Injectable, Inject } from '@angular/core';
4
4
  import { DaffInheritableError } from '@daffodil/core';
5
+ import * as i1 from '@angular/router';
5
6
  import { daffUriTruncateLeadingSlash } from '@daffodil/core/routing';
6
7
 
7
8
  const daffExternalRouterConfigurationDefault = {
@@ -60,12 +61,16 @@ class DaffExternalRouterModule {
60
61
  };
61
62
  }
62
63
  }
63
- DaffExternalRouterModule.decorators = [
64
- { type: NgModule, args: [{
65
- declarations: [],
66
- imports: [CommonModule],
67
- },] }
68
- ];
64
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
65
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterModule, imports: [CommonModule] });
66
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterModule, imports: [[CommonModule]] });
67
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterModule, decorators: [{
68
+ type: NgModule,
69
+ args: [{
70
+ declarations: [],
71
+ imports: [CommonModule],
72
+ }]
73
+ }] });
69
74
 
70
75
  /**
71
76
  * An error thrown when there was no wildcard route found in configuration
@@ -100,7 +105,7 @@ const daffTransformResolvedRouteToRoute = (resolvedRoute, availableTypes) => {
100
105
  throw new DaffExternalRouterUnknownRouteTypeError(`Unable to resolve the route '${resolvedRoute.url}'. Its type is '${resolvedRoute.type}' but a matching route wasn't found.`);
101
106
  }
102
107
  return {
103
- route: Object.assign(Object.assign({ path: resolvedRoute.url }, routeType.route), { data: Object.assign({ daffExternalRouteType: resolvedRoute.type }, routeType.route.data) }),
108
+ route: Object.assign(Object.assign({ path: resolvedRoute.url, daffExternalRouteType: resolvedRoute.type }, routeType.route), { data: Object.assign({}, resolvedRoute.data) }),
104
109
  insertionStrategy: routeType.insertionStrategy,
105
110
  };
106
111
  };
@@ -144,17 +149,19 @@ class DaffExternalRouter {
144
149
  }
145
150
  }
146
151
  }
147
- /** @nocollapse */ DaffExternalRouter.ɵprov = ɵɵdefineInjectable({ factory: function DaffExternalRouter_Factory() { return new DaffExternalRouter(ɵɵinject(Router), ɵɵinject(DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE)); }, token: DaffExternalRouter, providedIn: "root" });
148
- DaffExternalRouter.decorators = [
149
- { type: Injectable, args: [{
150
- providedIn: 'root',
151
- },] }
152
- ];
153
- /** @nocollapse */
154
- DaffExternalRouter.ctorParameters = () => [
155
- { type: Router },
156
- { type: Array, decorators: [{ type: Inject, args: [DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE,] }] }
157
- ];
152
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouter, deps: [{ token: i1.Router }, { token: DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE }], target: i0.ɵɵFactoryTarget.Injectable });
153
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouter, providedIn: 'root' });
154
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouter, decorators: [{
155
+ type: Injectable,
156
+ args: [{
157
+ providedIn: 'root',
158
+ }]
159
+ }], ctorParameters: function () {
160
+ return [{ type: i1.Router }, { type: undefined, decorators: [{
161
+ type: Inject,
162
+ args: [DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE]
163
+ }] }];
164
+ } });
158
165
 
159
166
  /**
160
167
  * Tests whether or not a route matches a specific Daffodil Route type.
@@ -162,16 +169,16 @@ DaffExternalRouter.ctorParameters = () => [
162
169
  * See {@link DaffRouteWithDataPath}
163
170
  */
164
171
  const routeMatchesRouteType = (route, type) => { var _a; return ((_a = route === null || route === void 0 ? void 0 : route.data) === null || _a === void 0 ? void 0 : _a.daffExternalRouteType) === type; };
165
- const ɵ0 = routeMatchesRouteType;
166
172
  /**
167
173
  * Adds a path to the `daffPaths` of the given route.
168
174
  *
169
175
  * See {@link DaffRouteWithDataPath}
170
176
  */
171
- const addRouteToDaffPaths = (route, path) => route.data.daffPaths = Object.assign(Object.assign({}, route.data.daffPaths), { [path]: path });
172
- const ɵ1 = addRouteToDaffPaths;
173
- const operateOnRoute = (externalRoute) => (route) => addRouteToDaffPaths(route, externalRoute.path);
174
- const ɵ2 = operateOnRoute;
177
+ const addRouteToDaffPaths = (route, externalRoute) => {
178
+ route.data.daffPaths = Object.assign(Object.assign({}, route.data.daffPaths), { [externalRoute.path]: externalRoute.data });
179
+ return route;
180
+ };
181
+ const operateOnRoute = (externalRoute) => (route) => addRouteToDaffPaths(route, externalRoute);
175
182
  /**
176
183
  * Traverse the router config tree, halting after the first match.
177
184
  * This traversal is implemented in a pre-order manner. As such, for large
@@ -197,7 +204,6 @@ const traverseRouteTree = (routes = [], matcher, operate) => {
197
204
  }
198
205
  return routes;
199
206
  };
200
- const ɵ3 = traverseRouteTree;
201
207
  /**
202
208
  * A route insertion strategy that can be used to append external routes onto
203
209
  * existing Angular routes. This can be useful when you need to route to
@@ -236,7 +242,7 @@ const ɵ3 = traverseRouteTree;
236
242
  * See {@link DaffRouteWithDataPath}
237
243
  *
238
244
  */
239
- const daffInsertDataPathStrategy = (externalRoute, routes) => traverseRouteTree(routes, (route) => { var _a; return routeMatchesRouteType(route, (_a = externalRoute.data) === null || _a === void 0 ? void 0 : _a.daffExternalRouteType); }, operateOnRoute(externalRoute));
245
+ const daffInsertDataPathStrategy = (externalRoute, routes) => traverseRouteTree(routes, (route) => routeMatchesRouteType(route, externalRoute.daffExternalRouteType), operateOnRoute(externalRoute));
240
246
 
241
247
  /**
242
248
  * A UrlMatcher that does an exact match against a path stored in the special
@@ -269,6 +275,16 @@ const daffDataPathUrlMatcher = (segments, group, route) => {
269
275
  return path in paths ? { consumed: segments } : null;
270
276
  };
271
277
 
278
+ /**
279
+ * Extracts a key from DaffPath data based upon the currently activated
280
+ * RouteSnapshot.
281
+ */
282
+ const daffExtractDaffPathData = (snapshot, key) => {
283
+ var _a, _b, _c, _d;
284
+ const pathFromRoot = snapshot.pathFromRoot[snapshot.pathFromRoot.length - 1].url.map((seg) => seg.path).join('/');
285
+ return (_d = (_c = (_b = (_a = snapshot.data) === null || _a === void 0 ? void 0 : _a.daffPaths) === null || _b === void 0 ? void 0 : _b[pathFromRoot]) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : null;
286
+ };
287
+
272
288
  /*
273
289
  * Public API Surface of @daffodil/external-router
274
290
  */
@@ -277,5 +293,5 @@ const daffDataPathUrlMatcher = (segments, group, route) => {
277
293
  * Generated bundle index. Do not edit.
278
294
  */
279
295
 
280
- export { DAFF_EXTERNAL_ROUTER_CONFIG, DaffExternalRouter, DaffExternalRouterModule, DaffExternalRouterNoWildcardError, DaffExternalRouterUnknownRouteTypeError, daffDataPathUrlMatcher, daffInsertDataPathStrategy, daffInsertRouteBeforeWildCardStrategy, daffProvideRouteResolvableByType, DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE as ɵa, daffProvideRoutesResolvableByType as ɵb };
281
- //# sourceMappingURL=daffodil-external-router.js.map
296
+ export { DAFF_EXTERNAL_ROUTER_CONFIG, DaffExternalRouter, DaffExternalRouterModule, DaffExternalRouterNoWildcardError, DaffExternalRouterUnknownRouteTypeError, daffDataPathUrlMatcher, daffExtractDaffPathData, daffInsertDataPathStrategy, daffInsertRouteBeforeWildCardStrategy, daffProvideRouteResolvableByType };
297
+ //# sourceMappingURL=daffodil-external-router.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-external-router.mjs","sources":["../../../libs/external-router/src/config.ts","../../../libs/external-router/src/token/type-resolvable-routes.token.ts","../../../libs/external-router/src/external-router.module.ts","../../../libs/external-router/src/errors/no-wildcard.ts","../../../libs/external-router/src/errors/unknown-type.ts","../../../libs/external-router/src/transform/resolved-route-to-route.ts","../../../libs/external-router/src/router/strategies/insert-route-before-wildcard.ts","../../../libs/external-router/src/router/router.service.ts","../../../libs/external-router/src/router/strategies/insert-data-path.ts","../../../libs/external-router/src/router/url-matcher/data-path-matcher.ts","../../../libs/external-router/src/util/extract-daff-path-data.ts","../../../libs/external-router/src/public_api.ts","../../../libs/external-router/src/daffodil-external-router.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const daffExternalRouterConfigurationDefault: DaffExternalRouterConfiguration = {\n failedResolutionPath: '/',\n notFoundResolutionPath: '/',\n};\n\n/**\n * The token holding the runtime configuration for the behavior of the\n * `@daffodil/external-router` package.\n */\nexport const DAFF_EXTERNAL_ROUTER_CONFIG = new InjectionToken<\nDaffExternalRouterConfiguration\n>('DAFF_EXTERNAL_ROUTER_CONFIG', {\n providedIn: 'root',\n factory: () => daffExternalRouterConfigurationDefault,\n});\n\n/**\n * The configuration object for the external router package.\n */\nexport interface DaffExternalRouterConfiguration {\n /**\n * The path to redirect to when external route resolution fails.\n */\n failedResolutionPath: string;\n\n /**\n * The path to redirect to when the requested URL is not found.\n */\n notFoundResolutionPath: string;\n}\n","import {\n InjectionToken,\n Provider,\n} from '@angular/core';\n\nimport { DaffExternalRouterInsertionStrategy } from '../model/insertion-strategy.type';\nimport { DaffExternalRouteType } from '../model/route-type';\nimport { DaffRouteWithoutPath } from '../model/route-without-path';\nimport { DaffTypeRoutePair } from '../model/type-route-pair';\n\n/**\n * A multi-token that allows you to register route \"types\" that correspond to routes.\n */\nexport const DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE = new InjectionToken<\nDaffTypeRoutePair[]\n>('DAFF_EXTERNAL_ROUTER_RESOLVABLE_TYPE_ROUTES', {\n providedIn: 'root',\n factory: () => [],\n});\n\n/**\n * A provider used to connect a type to a route to enable dynamic route resolution at runtime.\n */\nexport function daffProvideRouteResolvableByType(typeRoutePair: DaffTypeRoutePair): Provider {\n return {\n provide: DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE,\n multi: true,\n useValue: typeRoutePair,\n };\n}\n\n/**\n * A multi-provider used to connect an array of types to their respective routes.\n */\nexport function daffProvideRoutesResolvableByType(routes: DaffTypeRoutePair[]): Provider[] {\n return routes.map((route: DaffTypeRoutePair) => ({\n provide: DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE,\n multi: true,\n useValue: route,\n }));\n}\n","import { CommonModule } from '@angular/common';\nimport {\n ModuleWithProviders,\n NgModule,\n} from '@angular/core';\n\nimport {\n DaffExternalRouterConfiguration,\n DAFF_EXTERNAL_ROUTER_CONFIG,\n daffExternalRouterConfigurationDefault,\n} from './config';\nimport { DaffTypeRoutePair } from './model/type-route-pair';\nimport { daffProvideRoutesResolvableByType } from './token/type-resolvable-routes.token';\n\n/**\n * The external `DaffExternalRouterModule` allows you to configure the\n * `@daffodil/external-router` package's behavior.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterModule {\n static forRoot(\n config: Partial<DaffExternalRouterConfiguration>,\n routes: DaffTypeRoutePair[] = [],\n ): ModuleWithProviders<DaffExternalRouterModule> {\n return {\n ngModule: DaffExternalRouterModule,\n providers: [\n { provide: DAFF_EXTERNAL_ROUTER_CONFIG, useValue: { ...daffExternalRouterConfigurationDefault, ...config }},\n ...daffProvideRoutesResolvableByType(routes),\n ],\n };\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when there was no wildcard route found in configuration\n * of the Angular Router.\n */\nexport class DaffExternalRouterNoWildcardError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = 'NO_WILDCARD_ROUTE';\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when there is a failure matching a configured route to a\n * route type.\n */\nexport class DaffExternalRouterUnknownRouteTypeError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = 'UNKNOWN_ROUTE_TYPE';\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { DaffExternalRouterUnknownRouteTypeError } from '../errors/unknown-type';\nimport { DaffExternallyResolvableUrl } from '../model/resolvable-route';\nimport { DaffRouteInfo } from '../model/route-info';\nimport { DaffTypeRoutePair } from '../model/type-route-pair';\n\n/**\n * Transforms a DaffExternallyResolvableUrl into an Angular Route.\n */\nexport const daffTransformResolvedRouteToRoute = (\n resolvedRoute: DaffExternallyResolvableUrl,\n availableTypes: DaffTypeRoutePair[],\n): DaffRouteInfo => {\n const routeType = availableTypes\n .filter(t => t.type === resolvedRoute.type)\n .shift();\n if (!routeType) {\n throw new DaffExternalRouterUnknownRouteTypeError(\n `Unable to resolve the route '${resolvedRoute.url}'. Its type is '${resolvedRoute.type}' but a matching route wasn't found.`,\n );\n }\n\n return {\n route: {\n path: resolvedRoute.url,\n daffExternalRouteType: resolvedRoute.type,\n ...routeType.route,\n data: {\n ...resolvedRoute.data,\n },\n },\n insertionStrategy: routeType.insertionStrategy,\n };\n};\n","import {\n Route,\n Routes,\n} from '@angular/router';\n\nimport { DaffExternalRouterNoWildcardError } from '../../errors/no-wildcard';\nimport { DaffExternalRouterInsertionStrategy } from '../../model/insertion-strategy.type';\n\n/**\n * Inserts a Route into Routes right before the wildcard route.\n * If no wildcard is found, it fails fast with a `DaffExternalRouterNoWildcardError`.\n */\nexport const daffInsertRouteBeforeWildCardStrategy: DaffExternalRouterInsertionStrategy = (\n route: Route,\n routes: Routes,\n): Routes => {\n const index = routes.findIndex((r: Route) => r.path === '**');\n if (index === -1) {\n throw new DaffExternalRouterNoWildcardError(\n 'No wildcard (**) route was found during route resolution.',\n );\n }\n return [\n ...routes.slice(0, index),\n route,\n ...routes.slice(index),\n ];\n};\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n Router,\n Route,\n} from '@angular/router';\n\n\nimport { DaffExternalRouterNoWildcardError } from '../errors/no-wildcard';\nimport { DaffExternallyResolvableUrl } from '../model/resolvable-route';\nimport { DaffTypeRoutePair } from '../model/type-route-pair';\nimport { DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE } from '../token/type-resolvable-routes.token';\nimport { daffTransformResolvedRouteToRoute } from '../transform/resolved-route-to-route';\nimport { daffInsertRouteBeforeWildCardStrategy } from './strategies/insert-route-before-wildcard';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouter {\n constructor(\n private router: Router,\n @Inject(DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE)\n private runtimeRoutes: DaffTypeRoutePair[],\n ) { }\n\n /**\n * Adds a route to the existing router configuration.\n */\n add(resolvedRoute: DaffExternallyResolvableUrl) {\n //Get the route.\n const {\n route,\n insertionStrategy,\n } = daffTransformResolvedRouteToRoute(\n resolvedRoute,\n this.runtimeRoutes,\n );\n\n try {\n //Add it to configuration.\n this.router.config = (insertionStrategy || daffInsertRouteBeforeWildCardStrategy)(route, this.router.config);\n } catch (e) {\n if (e instanceof DaffExternalRouterNoWildcardError) {\n throw new DaffExternalRouterNoWildcardError(\n `${e.message} This usually means you have misconfigured your routes.`,\n );\n }\n\n throw e;\n }\n }\n}\n","import {\n Route,\n Routes,\n} from '@angular/router';\n\nimport { DaffExternalRouterInsertionStrategy } from '../../model/insertion-strategy.type';\nimport { DaffExternalRouteType } from '../../model/route-type';\nimport { DaffRouteWithDataPath } from '../../model/route-with-data-path';\nimport { DaffRouteWithSeoData } from '../../model/route-with-seo-data';\nimport { DaffRouteWithType } from '../../model/route-with-type';\n\ntype RouteOperator = (route: Route) => Route;\ntype ExternalRouteOperator = (route: DaffRouteWithDataPath, externalRoute: Route) => Route;\ntype InsertionOperatorFactory = (externalRoute: Route) => RouteOperator;\n\n/**\n * Tests whether or not a route matches a specific Daffodil Route type.\n *\n * See {@link DaffRouteWithDataPath}\n */\nconst routeMatchesRouteType = (route: Route, type: DaffExternalRouteType): boolean => route?.data?.daffExternalRouteType === type;\n\n/**\n * Adds a path to the `daffPaths` of the given route.\n *\n * See {@link DaffRouteWithDataPath}\n */\nconst addRouteToDaffPaths: ExternalRouteOperator =\n (route: DaffRouteWithDataPath, externalRoute: Route) => {\n route.data.daffPaths = {\n ...route.data.daffPaths,\n [externalRoute.path]: externalRoute.data,\n };\n return route;\n };\n\nconst operateOnRoute: InsertionOperatorFactory =\n (externalRoute: Route) => (route: DaffRouteWithDataPath) => addRouteToDaffPaths(route, externalRoute);\n\n/**\n * Traverse the router config tree, halting after the first match.\n * This traversal is implemented in a pre-order manner. As such, for large\n * configuration trees, it will be most efficient to place externally routed\n * components at the top of router configuration.\n */\nconst traverseRouteTree = (routes: Routes = [], matcher: (route: Route) => boolean, operate: RouteOperator): Routes => {\n if(routes.length === 0) {\n return routes;\n }\n\n const stack: Routes = [];\n const treeRoot = { children: routes };\n stack.push(treeRoot);\n\n while(stack.length) {\n const route = stack.pop();\n if(matcher(route)) {\n operate(route);\n break;\n }\n if(route.children){\n stack.push(...route.children.reverse());\n }\n }\n return routes;\n};\n\n/**\n * A route insertion strategy that can be used to append external routes onto\n * existing Angular routes. This can be useful when you need to route to\n * an existing lazy-loaded module from multiple externally defined urls.\n *\n * This should be used in combination with the {@link daffDataPathUrlMatcher} to match lazy-loaded modules with\n * associated external urls.\n *\n * For example, you can provide the insertion strategy in the {@link DaffExternalRouterModule} as below.\n *\n * ```ts\n * DaffExternalRouterModule.forRoot({}, [\n * {\n * type: 'CATEGORY',\n * insertionStrategy: daffInsertDataPathStrategy,\n * route: {}\n * }\n * ],\n * ```\n *\n * Then, you can match it with an associated route defined in your Routing\n * configuration with the {@link daffDataPathUrlMatcher}.\n *\n * ```ts\n * export const routes: Routes = [\n * {\n * matcher: daffDataPathUrlMatcher,\n * data: {\n * daffExternalRouteType: \"CATEGORY\",\n * },\n * loadChildren: () => import('./category/category.module').then((m) => m.MyCategoryModule),\n * }\n * ]\n * ```\n *\n * See {@link DaffRouteWithDataPath}\n *\n */\nexport const daffInsertDataPathStrategy: DaffExternalRouterInsertionStrategy = (externalRoute: DaffRouteWithType & DaffRouteWithSeoData, routes: Routes) => traverseRouteTree(\n routes,\n (route) => routeMatchesRouteType(route, externalRoute.daffExternalRouteType),\n operateOnRoute(externalRoute),\n);\n","import {\n UrlMatcher,\n UrlSegment,\n UrlSegmentGroup,\n} from '@angular/router';\n\nimport { daffUriTruncateLeadingSlash } from '@daffodil/core/routing';\n\nimport { DaffRouteWithDataPath } from '../../model/public_api';\n\n/**\n * A UrlMatcher that does an exact match against a path stored in the special\n * configuration fields that External Router stores on a Route's data.\n *\n * ```ts\n * export const routes: Routes = [\n * {\n * matcher: daffDataPathUrlMatcher,\n * data: {\n * daffExternalRouteType: \"CATEGORY\",\n * },\n * loadChildren: () => import('./category/category.module').then((m) => m.ShopCategoryModule),\n * }\n * ]\n * ```\n * {@link daffInsertDataPathStrategy }\n * {@link DaffRouteWithDataPath }\n */\nexport const daffDataPathUrlMatcher: UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: DaffRouteWithDataPath) => {\n const path = daffUriTruncateLeadingSlash(segments.reduce((acc: string, segment) => acc + '/' + segment.path, ''));\n const paths = route?.data?.daffPaths;\n\n // If we don't have any paths, we can safely fail a match.\n if(!paths) {\n return null;\n }\n\n // Otherwise, look up the path in the dictionary, failing if a match isn't found,\n // but matching the entire segment if a match is found.\n return path in paths ? { consumed: segments } : null;\n};\n\n","import {\n ActivatedRouteSnapshot,\n Data,\n} from '@angular/router';\n\n/**\n * Extracts a key from DaffPath data based upon the currently activated\n * RouteSnapshot.\n */\nexport const daffExtractDaffPathData = <T extends Data = Data>(snapshot: ActivatedRouteSnapshot, key: keyof T): unknown => {\n const pathFromRoot = snapshot.pathFromRoot[snapshot.pathFromRoot.length - 1].url.map((seg) => seg.path).join('/');\n return snapshot.data?.daffPaths?.[pathFromRoot]?.[key] ?? null;\n};\n","/*\n * Public API Surface of @daffodil/external-router\n */\n\nexport { DaffExternalRouterModule } from './external-router.module';\n\nexport {\n DAFF_EXTERNAL_ROUTER_CONFIG,\n DaffExternalRouterConfiguration,\n} from './config';\n\nexport { daffProvideRouteResolvableByType } from './token/type-resolvable-routes.token';\n\nexport * from './model/public_api';\n\nexport { DaffExternalRouter } from './router/router.service';\nexport { daffInsertRouteBeforeWildCardStrategy } from './router/strategies/insert-route-before-wildcard';\n\nexport { daffInsertDataPathStrategy } from './router/strategies/insert-data-path';\nexport { daffDataPathUrlMatcher } from './router/url-matcher/data-path-matcher';\n\nexport { DaffExternalRouterNoWildcardError } from './errors/no-wildcard';\nexport { DaffExternalRouterUnknownRouteTypeError } from './errors/unknown-type';\n\nexport { daffExtractDaffPathData } from './util/extract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AAG,CAAC,CAAC;AAClH,IAAA,OAAO,MAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,IAAI,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,SAAS,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,YAAY,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,GAAG,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,IAAI,CAAC;AACjE;;ACZA;;AAEG;;ACFH;;AAEG;;;;"}
@@ -0,0 +1,98 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Injectable, Inject, inject, NgModule } from '@angular/core';
3
+ import { of } from 'rxjs';
4
+ import { daffUriTruncateQueryFragment, daffUriTruncateLeadingSlash } from '@daffodil/core/routing';
5
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver } from '@daffodil/external-router/driver';
6
+ import { CommonModule } from '@angular/common';
7
+
8
+ const defaultConfig = {
9
+ resolver: () => DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION,
10
+ };
11
+ /**
12
+ * The token used by Daffodil to hold the driver's configuration.
13
+ *
14
+ * @docs-private
15
+ */
16
+ const DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG = new InjectionToken('DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG', {
17
+ providedIn: 'root',
18
+ factory: () => defaultConfig,
19
+ });
20
+
21
+ /**
22
+ * The DaffExternalRouterInMemoryDriver is responsible for resolving
23
+ * a URL using the resolver in the provided configuration.
24
+ *
25
+ * @inheritdoc
26
+ *
27
+ * @see {@link DaffExternalRouterInMemoryDriver}
28
+ */
29
+ class DaffExternalRouterInMemoryDriver {
30
+ constructor(configuration) {
31
+ this.configuration = configuration;
32
+ }
33
+ resolve(url) {
34
+ const truncatedUrl = daffUriTruncateQueryFragment(url);
35
+ const resolvedUrl = this.configuration.resolver(truncatedUrl);
36
+ return of(resolvedUrl?.url ? {
37
+ ...resolvedUrl,
38
+ url: daffUriTruncateLeadingSlash(resolvedUrl.url),
39
+ } : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);
40
+ }
41
+ }
42
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterInMemoryDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterInMemoryDriver, deps: [{ token: DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
43
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterInMemoryDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterInMemoryDriver, providedIn: 'root' });
44
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterInMemoryDriver, decorators: [{
45
+ type: Injectable,
46
+ args: [{
47
+ providedIn: 'root',
48
+ }]
49
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
50
+ type: Inject,
51
+ args: [DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG]
52
+ }] }]; } });
53
+
54
+ /**
55
+ * The `DaffExternalRouterDriverInMemoryModule` is an importable NgModule that can
56
+ * be used to configure the {@link DaffExternalRouterInMemoryDriver}.
57
+ */
58
+ class DaffExternalRouterDriverInMemoryModule {
59
+ static forRoot(config) {
60
+ return {
61
+ ngModule: DaffExternalRouterDriverInMemoryModule,
62
+ providers: [
63
+ {
64
+ provide: DaffExternalRouterDriver,
65
+ useExisting: DaffExternalRouterInMemoryDriver,
66
+ },
67
+ {
68
+ provide: DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG,
69
+ // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
70
+ useFactory() {
71
+ return config instanceof InjectionToken ? inject(config) : config;
72
+ },
73
+ },
74
+ ],
75
+ };
76
+ }
77
+ }
78
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterDriverInMemoryModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterDriverInMemoryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
79
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterDriverInMemoryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterDriverInMemoryModule, imports: [CommonModule] });
80
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterDriverInMemoryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterDriverInMemoryModule, imports: [[CommonModule]] });
81
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterDriverInMemoryModule, decorators: [{
82
+ type: NgModule,
83
+ args: [{
84
+ declarations: [],
85
+ imports: [CommonModule],
86
+ }]
87
+ }] });
88
+
89
+ /*
90
+ * Public API Surface of @daffodil/external-router/driver/in-memory
91
+ */
92
+
93
+ /**
94
+ * Generated bundle index. Do not edit.
95
+ */
96
+
97
+ export { DaffExternalRouterDriverInMemoryModule, DaffExternalRouterInMemoryDriver };
98
+ //# sourceMappingURL=daffodil-external-router-driver-in-memory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-external-router-driver-in-memory.mjs","sources":["../../../libs/external-router/driver/in-memory/src/config.ts","../../../libs/external-router/driver/in-memory/src/in-memory.service.ts","../../../libs/external-router/driver/in-memory/src/in-memory.module.ts","../../../libs/external-router/driver/in-memory/src/public_api.ts","../../../libs/external-router/driver/in-memory/src/daffodil-external-router-driver-in-memory.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from '@daffodil/external-router/driver';\n\n/**\n * A lookup for a URL.\n * Returns an {@link DaffExternallyResolvableUrl} or\n * {@link DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION} if the URL cannot be resolved\n */\nexport type DaffExternalRouterDriverInMemoryResolver = (url: string) => DaffExternallyResolvableUrl;\n\n/**\n * The configuration for the in-memory driver.\n */\nexport interface DaffExternalRouterDriverInMemoryConfig {\n resolver: DaffExternalRouterDriverInMemoryResolver;\n}\n\nconst defaultConfig: DaffExternalRouterDriverInMemoryConfig = {\n resolver: () => DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION,\n};\n\n/**\n * The token used by Daffodil to hold the driver's configuration.\n *\n * @docs-private\n */\nexport const DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG = new InjectionToken<\nDaffExternalRouterDriverInMemoryConfig\n>('DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG', {\n providedIn: 'root',\n factory: () => defaultConfig,\n});\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\nimport {\n Observable,\n of,\n} from 'rxjs';\n\nimport {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport {\n DaffExternalRouterDriverInterface,\n DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION,\n} from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverInMemoryConfig,\n DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG,\n} from './config';\n\n/**\n * The DaffExternalRouterInMemoryDriver is responsible for resolving\n * a URL using the resolver in the provided configuration.\n *\n * @inheritdoc\n *\n * @see {@link DaffExternalRouterInMemoryDriver}\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterInMemoryDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n @Inject(DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG)\n private configuration: DaffExternalRouterDriverInMemoryConfig,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n const truncatedUrl = daffUriTruncateQueryFragment(url);\n const resolvedUrl = this.configuration.resolver(truncatedUrl);\n\n return of(resolvedUrl?.url ? {\n ...resolvedUrl,\n url: daffUriTruncateLeadingSlash(resolvedUrl.url),\n } : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n InjectionToken,\n inject,\n} from '@angular/core';\n\nimport { DaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverInMemoryConfig,\n DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG,\n} from './config';\nimport { DaffExternalRouterInMemoryDriver } from './in-memory.service';\n\n/**\n * The `DaffExternalRouterDriverInMemoryModule` is an importable NgModule that can\n * be used to configure the {@link DaffExternalRouterInMemoryDriver}.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverInMemoryModule {\n static forRoot(\n config: DaffExternalRouterDriverInMemoryConfig | InjectionToken<DaffExternalRouterDriverInMemoryConfig>,\n ): ModuleWithProviders<DaffExternalRouterDriverInMemoryModule> {\n return {\n ngModule: DaffExternalRouterDriverInMemoryModule,\n providers: [\n {\n provide: DaffExternalRouterDriver,\n useExisting: DaffExternalRouterInMemoryDriver,\n },\n {\n provide: DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG,\n // eslint-disable-next-line prefer-arrow/prefer-arrow-functions\n useFactory() {\n return config instanceof InjectionToken ? inject(config) : config;\n },\n },\n ],\n };\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/driver/in-memory\n */\n\nexport { DaffExternalRouterInMemoryDriver } from './in-memory.service';\nexport { DaffExternalRouterDriverInMemoryModule } from './in-memory.module';\n\nexport {\n DaffExternalRouterDriverInMemoryConfig,\n DaffExternalRouterDriverInMemoryResolver,\n} from './config';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,aAAa,GAA2C;AAC5D,IAAA,QAAQ,EAAE,MAAM,yCAAyC;CAC1D,CAAC;AAEF;;;;AAIG;AACI,MAAM,4CAA4C,GAAG,IAAI,cAAc,CAE5E,8CAA8C,EAAE;AAChD,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,aAAa;AAC7B,CAAA,CAAC;;ACTF;;;;;;;AAOG;MAIU,gCAAgC,CAAA;AAE3C,IAAA,WAAA,CAEU,aAAqD,EAAA;QAArD,IAAa,CAAA,aAAA,GAAb,aAAa,CAAwC;KAC3D;AAEJ,IAAA,OAAO,CAAC,GAAW,EAAA;AACjB,QAAA,MAAM,YAAY,GAAG,4BAA4B,CAAC,GAAG,CAAC,CAAC;QACvD,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAE9D,QAAA,OAAO,EAAE,CAAC,WAAW,EAAE,GAAG,GAAG;AAC3B,YAAA,GAAG,WAAW;AACd,YAAA,GAAG,EAAE,2BAA2B,CAAC,WAAW,CAAC,GAAG,CAAC;AAClD,SAAA,GAAG,yCAAyC,CAAC,CAAC;KAChD;;AAfU,sCAAA,gCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA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EAAA,OAAA,EAAA,CAFxC,CAAC,YAAY,CAAC,CAAA,EAAA,CAAA,CAAA;2FAEZ,sCAAsC,EAAA,UAAA,EAAA,CAAA;kBAJlD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA,CAAA;;;ACvBD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -0,0 +1,122 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, NgModule } from '@angular/core';
3
+ import * as i1 from 'apollo-angular';
4
+ import { gql } from 'apollo-angular';
5
+ import { map } from 'rxjs/operators';
6
+ import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
7
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
+ import { magentoTransformRedirectToHttpCode } from '@daffodil/external-router/driver/magento';
9
+ import { CommonModule } from '@angular/common';
10
+ import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
11
+
12
+ const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv241';
13
+ /**
14
+ * This query retrieves a URL resolution from Magento and informs you about
15
+ * what type of route the URL is.
16
+ */
17
+ const MagentoResolveUrlv241 = gql `
18
+ query ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {
19
+ urlResolver(url: $url) {
20
+ id
21
+ relative_url
22
+ redirectCode
23
+ type
24
+ }
25
+ }
26
+ `;
27
+
28
+ const transformResolutionToResolvableUrlv241 = (resolution) => (resolution ? {
29
+ id: resolution.id?.toString(),
30
+ url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),
31
+ type: resolution.type,
32
+ code: magentoTransformRedirectToHttpCode(resolution.redirectCode),
33
+ } : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);
34
+
35
+ /**
36
+ * The DaffExternalRouterMagentoDriver is responsible for translating an
37
+ * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.
38
+ *
39
+ * @inheritdoc
40
+ */
41
+ class DaffExternalRouterMagentoDriver {
42
+ constructor(apollo) {
43
+ this.apollo = apollo;
44
+ }
45
+ resolve(url) {
46
+ return this.apollo
47
+ .query({
48
+ query: MagentoResolveUrlv241,
49
+ variables: {
50
+ url: daffUriTruncateQueryFragment(url),
51
+ },
52
+ })
53
+ .pipe(map(response => transformResolutionToResolvableUrlv241(response.data.urlResolver)));
54
+ }
55
+ }
56
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterMagentoDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterMagentoDriver, deps: [{ token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable });
57
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterMagentoDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterMagentoDriver, providedIn: 'root' });
58
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterMagentoDriver, decorators: [{
59
+ type: Injectable,
60
+ args: [{
61
+ providedIn: 'root',
62
+ }]
63
+ }], ctorParameters: function () { return [{ type: i1.Apollo }]; } });
64
+
65
+ /**
66
+ * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.
67
+ *
68
+ * ```ts
69
+ * @NgModule({
70
+ * declarations: [],
71
+ * imports: [
72
+ * ...
73
+ * DaffExternalRouterDriverMagentoModule.forRoot()
74
+ * ],
75
+ * })
76
+ * export class AppModule{}
77
+ * ```
78
+ *
79
+ * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.
80
+ */
81
+ class DaffExternalRouterDriverMagentoModule {
82
+ /**
83
+ * Configures the package for the root injector.
84
+ */
85
+ static forRoot() {
86
+ return {
87
+ ngModule: DaffExternalRouterDriverMagentoModule,
88
+ providers: [
89
+ {
90
+ provide: DaffExternalRouterDriver,
91
+ useExisting: DaffExternalRouterMagentoDriver,
92
+ },
93
+ {
94
+ provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
95
+ useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,
96
+ multi: true,
97
+ },
98
+ ],
99
+ };
100
+ }
101
+ }
102
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterDriverMagentoModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
103
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterDriverMagentoModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, imports: [CommonModule] });
104
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouterDriverMagentoModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, imports: [[CommonModule]] });
105
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, decorators: [{
106
+ type: NgModule,
107
+ args: [{
108
+ declarations: [],
109
+ imports: [CommonModule],
110
+ }]
111
+ }] });
112
+
113
+ /*
114
+ * Public API Surface of @daffodil/external-router/driver/magento/2.4.1
115
+ */
116
+
117
+ /**
118
+ * Generated bundle index. Do not edit.
119
+ */
120
+
121
+ export { DaffExternalRouterDriverMagentoModule, DaffExternalRouterMagentoDriver };
122
+ //# sourceMappingURL=daffodil-external-router-driver-magento-2.4.1.mjs.map