@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,303 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, NgModule, Injectable, Inject } from '@angular/core';
4
+ import * as i1 from '@angular/router';
5
+ import { DaffInheritableError } from '@daffodil/core';
6
+ import { daffUriTruncateLeadingSlash } from '@daffodil/core/routing';
7
+
8
+ const daffExternalRouterConfigurationDefault = {
9
+ failedResolutionPath: '/',
10
+ notFoundResolutionPath: '/',
11
+ };
12
+ /**
13
+ * The token holding the runtime configuration for the behavior of the
14
+ * `@daffodil/external-router` package.
15
+ */
16
+ const DAFF_EXTERNAL_ROUTER_CONFIG = new InjectionToken('DAFF_EXTERNAL_ROUTER_CONFIG', {
17
+ providedIn: 'root',
18
+ factory: () => daffExternalRouterConfigurationDefault,
19
+ });
20
+
21
+ /**
22
+ * A multi-token that allows you to register route "types" that correspond to routes.
23
+ */
24
+ const DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE = new InjectionToken('DAFF_EXTERNAL_ROUTER_RESOLVABLE_TYPE_ROUTES', {
25
+ providedIn: 'root',
26
+ factory: () => [],
27
+ });
28
+ /**
29
+ * A provider used to connect a type to a route to enable dynamic route resolution at runtime.
30
+ */
31
+ function daffProvideRouteResolvableByType(typeRoutePair) {
32
+ return {
33
+ provide: DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE,
34
+ multi: true,
35
+ useValue: typeRoutePair,
36
+ };
37
+ }
38
+ /**
39
+ * A multi-provider used to connect an array of types to their respective routes.
40
+ */
41
+ function daffProvideRoutesResolvableByType(routes) {
42
+ return routes.map((route) => ({
43
+ provide: DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE,
44
+ multi: true,
45
+ useValue: route,
46
+ }));
47
+ }
48
+
49
+ /**
50
+ * The external `DaffExternalRouterModule` allows you to configure the
51
+ * `@daffodil/external-router` package's behavior.
52
+ */
53
+ class DaffExternalRouterModule {
54
+ static forRoot(config, routes = []) {
55
+ return {
56
+ ngModule: DaffExternalRouterModule,
57
+ providers: [
58
+ { provide: DAFF_EXTERNAL_ROUTER_CONFIG, useValue: { ...daffExternalRouterConfigurationDefault, ...config } },
59
+ ...daffProvideRoutesResolvableByType(routes),
60
+ ],
61
+ };
62
+ }
63
+ }
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
+ }] });
74
+
75
+ /**
76
+ * An error thrown when there was no wildcard route found in configuration
77
+ * of the Angular Router.
78
+ */
79
+ class DaffExternalRouterNoWildcardError extends DaffInheritableError {
80
+ constructor(message) {
81
+ super(message);
82
+ this.code = 'NO_WILDCARD_ROUTE';
83
+ }
84
+ }
85
+
86
+ /**
87
+ * An error thrown when there is a failure matching a configured route to a
88
+ * route type.
89
+ */
90
+ class DaffExternalRouterUnknownRouteTypeError extends DaffInheritableError {
91
+ constructor(message) {
92
+ super(message);
93
+ this.code = 'UNKNOWN_ROUTE_TYPE';
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Transforms a DaffExternallyResolvableUrl into an Angular Route.
99
+ */
100
+ const daffTransformResolvedRouteToRoute = (resolvedRoute, availableTypes) => {
101
+ const routeType = availableTypes
102
+ .filter(t => t.type === resolvedRoute.type)
103
+ .shift();
104
+ if (!routeType) {
105
+ throw new DaffExternalRouterUnknownRouteTypeError(`Unable to resolve the route '${resolvedRoute.url}'. Its type is '${resolvedRoute.type}' but a matching route wasn't found.`);
106
+ }
107
+ return {
108
+ route: {
109
+ path: resolvedRoute.url,
110
+ daffExternalRouteType: resolvedRoute.type,
111
+ ...routeType.route,
112
+ data: {
113
+ ...resolvedRoute.data,
114
+ },
115
+ },
116
+ insertionStrategy: routeType.insertionStrategy,
117
+ };
118
+ };
119
+
120
+ /**
121
+ * Inserts a Route into Routes right before the wildcard route.
122
+ * If no wildcard is found, it fails fast with a `DaffExternalRouterNoWildcardError`.
123
+ */
124
+ const daffInsertRouteBeforeWildCardStrategy = (route, routes) => {
125
+ const index = routes.findIndex((r) => r.path === '**');
126
+ if (index === -1) {
127
+ throw new DaffExternalRouterNoWildcardError('No wildcard (**) route was found during route resolution.');
128
+ }
129
+ return [
130
+ ...routes.slice(0, index),
131
+ route,
132
+ ...routes.slice(index),
133
+ ];
134
+ };
135
+
136
+ class DaffExternalRouter {
137
+ constructor(router, runtimeRoutes) {
138
+ this.router = router;
139
+ this.runtimeRoutes = runtimeRoutes;
140
+ }
141
+ /**
142
+ * Adds a route to the existing router configuration.
143
+ */
144
+ add(resolvedRoute) {
145
+ //Get the route.
146
+ const { route, insertionStrategy, } = daffTransformResolvedRouteToRoute(resolvedRoute, this.runtimeRoutes);
147
+ try {
148
+ //Add it to configuration.
149
+ this.router.config = (insertionStrategy || daffInsertRouteBeforeWildCardStrategy)(route, this.router.config);
150
+ }
151
+ catch (e) {
152
+ if (e instanceof DaffExternalRouterNoWildcardError) {
153
+ throw new DaffExternalRouterNoWildcardError(`${e.message} This usually means you have misconfigured your routes.`);
154
+ }
155
+ throw e;
156
+ }
157
+ }
158
+ }
159
+ /** @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 });
160
+ /** @nocollapse */ /** @nocollapse */ DaffExternalRouter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouter, providedIn: 'root' });
161
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffExternalRouter, decorators: [{
162
+ type: Injectable,
163
+ args: [{
164
+ providedIn: 'root',
165
+ }]
166
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: undefined, decorators: [{
167
+ type: Inject,
168
+ args: [DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE]
169
+ }] }]; } });
170
+
171
+ /**
172
+ * Tests whether or not a route matches a specific Daffodil Route type.
173
+ *
174
+ * See {@link DaffRouteWithDataPath}
175
+ */
176
+ const routeMatchesRouteType = (route, type) => route?.data?.daffExternalRouteType === type;
177
+ /**
178
+ * Adds a path to the `daffPaths` of the given route.
179
+ *
180
+ * See {@link DaffRouteWithDataPath}
181
+ */
182
+ const addRouteToDaffPaths = (route, externalRoute) => {
183
+ route.data.daffPaths = {
184
+ ...route.data.daffPaths,
185
+ [externalRoute.path]: externalRoute.data,
186
+ };
187
+ return route;
188
+ };
189
+ const operateOnRoute = (externalRoute) => (route) => addRouteToDaffPaths(route, externalRoute);
190
+ /**
191
+ * Traverse the router config tree, halting after the first match.
192
+ * This traversal is implemented in a pre-order manner. As such, for large
193
+ * configuration trees, it will be most efficient to place externally routed
194
+ * components at the top of router configuration.
195
+ */
196
+ const traverseRouteTree = (routes = [], matcher, operate) => {
197
+ if (routes.length === 0) {
198
+ return routes;
199
+ }
200
+ const stack = [];
201
+ const treeRoot = { children: routes };
202
+ stack.push(treeRoot);
203
+ while (stack.length) {
204
+ const route = stack.pop();
205
+ if (matcher(route)) {
206
+ operate(route);
207
+ break;
208
+ }
209
+ if (route.children) {
210
+ stack.push(...route.children.reverse());
211
+ }
212
+ }
213
+ return routes;
214
+ };
215
+ /**
216
+ * A route insertion strategy that can be used to append external routes onto
217
+ * existing Angular routes. This can be useful when you need to route to
218
+ * an existing lazy-loaded module from multiple externally defined urls.
219
+ *
220
+ * This should be used in combination with the {@link daffDataPathUrlMatcher} to match lazy-loaded modules with
221
+ * associated external urls.
222
+ *
223
+ * For example, you can provide the insertion strategy in the {@link DaffExternalRouterModule} as below.
224
+ *
225
+ * ```ts
226
+ * DaffExternalRouterModule.forRoot({}, [
227
+ * {
228
+ * type: 'CATEGORY',
229
+ * insertionStrategy: daffInsertDataPathStrategy,
230
+ * route: {}
231
+ * }
232
+ * ],
233
+ * ```
234
+ *
235
+ * Then, you can match it with an associated route defined in your Routing
236
+ * configuration with the {@link daffDataPathUrlMatcher}.
237
+ *
238
+ * ```ts
239
+ * export const routes: Routes = [
240
+ * {
241
+ * matcher: daffDataPathUrlMatcher,
242
+ * data: {
243
+ * daffExternalRouteType: "CATEGORY",
244
+ * },
245
+ * loadChildren: () => import('./category/category.module').then((m) => m.MyCategoryModule),
246
+ * }
247
+ * ]
248
+ * ```
249
+ *
250
+ * See {@link DaffRouteWithDataPath}
251
+ *
252
+ */
253
+ const daffInsertDataPathStrategy = (externalRoute, routes) => traverseRouteTree(routes, (route) => routeMatchesRouteType(route, externalRoute.daffExternalRouteType), operateOnRoute(externalRoute));
254
+
255
+ /**
256
+ * A UrlMatcher that does an exact match against a path stored in the special
257
+ * configuration fields that External Router stores on a Route's data.
258
+ *
259
+ * ```ts
260
+ * export const routes: Routes = [
261
+ * {
262
+ * matcher: daffDataPathUrlMatcher,
263
+ * data: {
264
+ * daffExternalRouteType: "CATEGORY",
265
+ * },
266
+ * loadChildren: () => import('./category/category.module').then((m) => m.ShopCategoryModule),
267
+ * }
268
+ * ]
269
+ * ```
270
+ * {@link daffInsertDataPathStrategy }
271
+ * {@link DaffRouteWithDataPath }
272
+ */
273
+ const daffDataPathUrlMatcher = (segments, group, route) => {
274
+ const path = daffUriTruncateLeadingSlash(segments.reduce((acc, segment) => acc + '/' + segment.path, ''));
275
+ const paths = route?.data?.daffPaths;
276
+ // If we don't have any paths, we can safely fail a match.
277
+ if (!paths) {
278
+ return null;
279
+ }
280
+ // Otherwise, look up the path in the dictionary, failing if a match isn't found,
281
+ // but matching the entire segment if a match is found.
282
+ return path in paths ? { consumed: segments } : null;
283
+ };
284
+
285
+ /**
286
+ * Extracts a key from DaffPath data based upon the currently activated
287
+ * RouteSnapshot.
288
+ */
289
+ const daffExtractDaffPathData = (snapshot, key) => {
290
+ const pathFromRoot = snapshot.pathFromRoot[snapshot.pathFromRoot.length - 1].url.map((seg) => seg.path).join('/');
291
+ return snapshot.data?.daffPaths?.[pathFromRoot]?.[key] ?? null;
292
+ };
293
+
294
+ /*
295
+ * Public API Surface of @daffodil/external-router
296
+ */
297
+
298
+ /**
299
+ * Generated bundle index. Do not edit.
300
+ */
301
+
302
+ export { DAFF_EXTERNAL_ROUTER_CONFIG, DaffExternalRouter, DaffExternalRouterModule, DaffExternalRouterNoWildcardError, DaffExternalRouterUnknownRouteTypeError, daffDataPathUrlMatcher, daffExtractDaffPathData, daffInsertDataPathStrategy, daffInsertRouteBeforeWildCardStrategy, daffProvideRouteResolvableByType };
303
+ //# 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-daff-path-data';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,sCAAsC,GAAoC;AACrF,IAAA,oBAAoB,EAAE,GAAG;AACzB,IAAA,sBAAsB,EAAE,GAAG;CAC5B,CAAC;AAEF;;;AAGG;MACU,2BAA2B,GAAG,IAAI,cAAc,CAE3D,6BAA6B,EAAE;AAC/B,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,sCAAsC;AACtD,CAAA;;ACND;;AAEG;AACI,MAAM,8CAA8C,GAAG,IAAI,cAAc,CAE9E,6CAA6C,EAAE;AAC/C,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,EAAE;AAClB,CAAA,CAAC,CAAC;AAEH;;AAEG;AACG,SAAU,gCAAgC,CAAC,aAAgC,EAAA;IAC/E,OAAO;AACL,QAAA,OAAO,EAAE,8CAA8C;AACvD,QAAA,KAAK,EAAE,IAAI;AACX,QAAA,QAAQ,EAAE,aAAa;KACxB,CAAC;AACJ,CAAC;AAED;;AAEG;AACG,SAAU,iCAAiC,CAAC,MAA2B,EAAA;IAC3E,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAwB,MA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AI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClH,IAAA,OAAO,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC;AACjE;;ACZA;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { DaffIdentifiable } from '@daffodil/core';
2
+ import { DaffRouteData } from './route-data';
2
3
  import { DaffExternalRouteType } from './route-type';
3
4
  /**
4
5
  * A `DaffExternallyResolvableUrl` describes the relationship between a "type" of route
@@ -19,9 +20,19 @@ export interface DaffExternallyResolvableUrl extends DaffIdentifiable {
19
20
  * Should not contain URL fragments, query parameters, or leading slashes.
20
21
  */
21
22
  url: string;
23
+ /**
24
+ * The type of the route
25
+ *
26
+ * @see {@link DaffExternalRouteType}
27
+ */
22
28
  type: DaffExternalRouteType;
23
29
  /**
24
30
  * The HTTP status code for the resolvable route.
25
31
  */
26
32
  code: number;
33
+ /**
34
+ * Additional route data. Note that this is not guaranteed to come from
35
+ * the driver, its only available when the driver makes it available.
36
+ */
37
+ data?: DaffRouteData;
27
38
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Data associated with a route.
3
+ */
4
+ export interface DaffRouteData {
5
+ canonical_url?: string;
6
+ meta_description?: string;
7
+ title?: string;
8
+ }
@@ -1,9 +1,9 @@
1
1
  import { DaffExternalRouterInsertionStrategy } from './insertion-strategy.type';
2
- import { DaffRouteWithDataPath } from './route-with-data-path';
2
+ import { DaffRouteWithType } from './route-with-type';
3
3
  /**
4
4
  * An object containing the info needed to insert a route into a configuration.
5
5
  */
6
6
  export interface DaffRouteInfo {
7
- route: DaffRouteWithDataPath;
7
+ route: DaffRouteWithType;
8
8
  insertionStrategy?: DaffExternalRouterInsertionStrategy;
9
9
  }
@@ -1,5 +1,5 @@
1
- import { Route } from '@angular/router';
2
- import { DaffExternalRouteType } from './route-type';
1
+ import { Data, Route } from '@angular/router';
2
+ import { DaffRouteData } from './route-data';
3
3
  /**
4
4
  * A type that describes the special data that Daffodil will look for when attempting
5
5
  * to match a route based upon path data stored in the `data` key of a route.
@@ -9,7 +9,6 @@ import { DaffExternalRouteType } from './route-type';
9
9
  */
10
10
  export declare type DaffRouteWithDataPath = Route & {
11
11
  data?: {
12
- daffExternalRouteType?: DaffExternalRouteType;
13
- daffPaths?: Record<string, string>;
12
+ daffPaths?: Record<string, DaffRouteData | Data>;
14
13
  };
15
14
  };
@@ -0,0 +1,12 @@
1
+ import { Route } from '@angular/router';
2
+ import { DaffRouteData } from './route-data';
3
+ /**
4
+ * A type that describes the special data that Daffodil will store for SEO purposes on
5
+ * an external resolved route.
6
+ *
7
+ * {@link daffDataPathUrlMatcher}
8
+ * {@link daffInsertDataPathStrategy}
9
+ */
10
+ export declare type DaffRouteWithSeoData = Route & {
11
+ data: DaffRouteData;
12
+ };
@@ -0,0 +1,12 @@
1
+ import { Route } from '@angular/router';
2
+ import { DaffExternalRouteType } from './route-type';
3
+ /**
4
+ * A type that describes the special data that Daffodil will look for when attempting
5
+ * to match a route based upon path data stored in the `data` key of a route.
6
+ *
7
+ * {@link daffDataPathUrlMatcher}
8
+ * {@link daffInsertDataPathStrategy}
9
+ */
10
+ export declare type DaffRouteWithType = Route & {
11
+ daffExternalRouteType: DaffExternalRouteType;
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daffodil/external-router",
3
- "version": "0.39.13",
3
+ "version": "0.42.0",
4
4
  "description": "A platform-agnostic package that connects the @angular/router with an external routing service (e.g. an API), allowing for runtime route resolution.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,25 +13,101 @@
13
13
  },
14
14
  "homepage": "https://github.com/graycoreio/daffodil",
15
15
  "peerDependencies": {
16
- "@angular/common": "^11.0.0",
17
- "@angular/core": "^11.0.0",
18
- "@angular/router": "^11.0.0",
19
- "@daffodil/core": "0.39.13",
20
- "rxjs": "6.6.3"
16
+ "@angular/common": "^13.0.0",
17
+ "@angular/core": "^13.0.0",
18
+ "@angular/router": "^13.0.0",
19
+ "@daffodil/core": "0.42.0",
20
+ "rxjs": "7.5.5"
21
21
  },
22
22
  "optionalDependencies": {
23
- "apollo-angular": "^2.4.0",
24
- "@daffodil/driver": "0.39.13"
23
+ "apollo-angular": "^3.0.1",
24
+ "@daffodil/driver": "0.42.0"
25
25
  },
26
- "main": "bundles/daffodil-external-router.umd.js",
27
- "module": "fesm2015/daffodil-external-router.js",
28
- "es2015": "fesm2015/daffodil-external-router.js",
29
- "esm2015": "esm2015/daffodil-external-router.js",
30
- "fesm2015": "fesm2015/daffodil-external-router.js",
26
+ "module": "fesm2015/daffodil-external-router.mjs",
27
+ "es2020": "fesm2020/daffodil-external-router.mjs",
28
+ "esm2020": "esm2020/daffodil-external-router.mjs",
29
+ "fesm2020": "fesm2020/daffodil-external-router.mjs",
30
+ "fesm2015": "fesm2015/daffodil-external-router.mjs",
31
31
  "typings": "daffodil-external-router.d.ts",
32
- "metadata": "daffodil-external-router.metadata.json",
32
+ "exports": {
33
+ "./package.json": {
34
+ "default": "./package.json"
35
+ },
36
+ ".": {
37
+ "types": "./daffodil-external-router.d.ts",
38
+ "esm2020": "./esm2020/daffodil-external-router.mjs",
39
+ "es2020": "./fesm2020/daffodil-external-router.mjs",
40
+ "es2015": "./fesm2015/daffodil-external-router.mjs",
41
+ "node": "./fesm2015/daffodil-external-router.mjs",
42
+ "default": "./fesm2020/daffodil-external-router.mjs"
43
+ },
44
+ "./driver/in-memory": {
45
+ "types": "./driver/in-memory/daffodil-external-router-driver-in-memory.d.ts",
46
+ "esm2020": "./esm2020/driver/in-memory/daffodil-external-router-driver-in-memory.mjs",
47
+ "es2020": "./fesm2020/daffodil-external-router-driver-in-memory.mjs",
48
+ "es2015": "./fesm2015/daffodil-external-router-driver-in-memory.mjs",
49
+ "node": "./fesm2015/daffodil-external-router-driver-in-memory.mjs",
50
+ "default": "./fesm2020/daffodil-external-router-driver-in-memory.mjs"
51
+ },
52
+ "./driver/magento/2.4.1": {
53
+ "types": "./driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.d.ts",
54
+ "esm2020": "./esm2020/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.mjs",
55
+ "es2020": "./fesm2020/daffodil-external-router-driver-magento-2.4.1.mjs",
56
+ "es2015": "./fesm2015/daffodil-external-router-driver-magento-2.4.1.mjs",
57
+ "node": "./fesm2015/daffodil-external-router-driver-magento-2.4.1.mjs",
58
+ "default": "./fesm2020/daffodil-external-router-driver-magento-2.4.1.mjs"
59
+ },
60
+ "./driver/magento/2.4.2": {
61
+ "types": "./driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.d.ts",
62
+ "esm2020": "./esm2020/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.mjs",
63
+ "es2020": "./fesm2020/daffodil-external-router-driver-magento-2.4.2.mjs",
64
+ "es2015": "./fesm2015/daffodil-external-router-driver-magento-2.4.2.mjs",
65
+ "node": "./fesm2015/daffodil-external-router-driver-magento-2.4.2.mjs",
66
+ "default": "./fesm2020/daffodil-external-router-driver-magento-2.4.2.mjs"
67
+ },
68
+ "./driver/magento/2.4.3": {
69
+ "types": "./driver/magento/2.4.3/daffodil-external-router-driver-magento-2.4.3.d.ts",
70
+ "esm2020": "./esm2020/driver/magento/2.4.3/daffodil-external-router-driver-magento-2.4.3.mjs",
71
+ "es2020": "./fesm2020/daffodil-external-router-driver-magento-2.4.3.mjs",
72
+ "es2015": "./fesm2015/daffodil-external-router-driver-magento-2.4.3.mjs",
73
+ "node": "./fesm2015/daffodil-external-router-driver-magento-2.4.3.mjs",
74
+ "default": "./fesm2020/daffodil-external-router-driver-magento-2.4.3.mjs"
75
+ },
76
+ "./driver/magento": {
77
+ "types": "./driver/magento/daffodil-external-router-driver-magento.d.ts",
78
+ "esm2020": "./esm2020/driver/magento/daffodil-external-router-driver-magento.mjs",
79
+ "es2020": "./fesm2020/daffodil-external-router-driver-magento.mjs",
80
+ "es2015": "./fesm2015/daffodil-external-router-driver-magento.mjs",
81
+ "node": "./fesm2015/daffodil-external-router-driver-magento.mjs",
82
+ "default": "./fesm2020/daffodil-external-router-driver-magento.mjs"
83
+ },
84
+ "./driver": {
85
+ "types": "./driver/daffodil-external-router-driver.d.ts",
86
+ "esm2020": "./esm2020/driver/daffodil-external-router-driver.mjs",
87
+ "es2020": "./fesm2020/daffodil-external-router-driver.mjs",
88
+ "es2015": "./fesm2015/daffodil-external-router-driver.mjs",
89
+ "node": "./fesm2015/daffodil-external-router-driver.mjs",
90
+ "default": "./fesm2020/daffodil-external-router-driver.mjs"
91
+ },
92
+ "./driver/testing": {
93
+ "types": "./driver/testing/daffodil-external-router-driver-testing.d.ts",
94
+ "esm2020": "./esm2020/driver/testing/daffodil-external-router-driver-testing.mjs",
95
+ "es2020": "./fesm2020/daffodil-external-router-driver-testing.mjs",
96
+ "es2015": "./fesm2015/daffodil-external-router-driver-testing.mjs",
97
+ "node": "./fesm2015/daffodil-external-router-driver-testing.mjs",
98
+ "default": "./fesm2020/daffodil-external-router-driver-testing.mjs"
99
+ },
100
+ "./routing": {
101
+ "types": "./routing/daffodil-external-router-routing.d.ts",
102
+ "esm2020": "./esm2020/routing/daffodil-external-router-routing.mjs",
103
+ "es2020": "./fesm2020/daffodil-external-router-routing.mjs",
104
+ "es2015": "./fesm2015/daffodil-external-router-routing.mjs",
105
+ "node": "./fesm2015/daffodil-external-router-routing.mjs",
106
+ "default": "./fesm2020/daffodil-external-router-routing.mjs"
107
+ }
108
+ },
33
109
  "sideEffects": false,
34
110
  "dependencies": {
35
- "tslib": "^2.0.0"
111
+ "tslib": "^2.3.0"
36
112
  }
37
113
  }
package/public_api.d.ts CHANGED
@@ -8,3 +8,4 @@ export { daffInsertDataPathStrategy } from './router/strategies/insert-data-path
8
8
  export { daffDataPathUrlMatcher } from './router/url-matcher/data-path-matcher';
9
9
  export { DaffExternalRouterNoWildcardError } from './errors/no-wildcard';
10
10
  export { DaffExternalRouterUnknownRouteTypeError } from './errors/unknown-type';
11
+ export { daffExtractDaffPathData } from './util/extract-daff-path-data';
@@ -1,6 +1,7 @@
1
1
  import { Router } from '@angular/router';
2
2
  import { DaffExternallyResolvableUrl } from '../model/resolvable-route';
3
3
  import { DaffTypeRoutePair } from '../model/type-route-pair';
4
+ import * as i0 from "@angular/core";
4
5
  export declare class DaffExternalRouter {
5
6
  private router;
6
7
  private runtimeRoutes;
@@ -9,4 +10,6 @@ export declare class DaffExternalRouter {
9
10
  * Adds a route to the existing router configuration.
10
11
  */
11
12
  add(resolvedRoute: DaffExternallyResolvableUrl): void;
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffExternalRouter, never>;
14
+ static ɵprov: i0.ɵɵInjectableDeclaration<DaffExternalRouter>;
12
15
  }
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * Generated bundle index. Do not edit.
3
3
  */
4
+ /// <amd-module name="@daffodil/external-router/routing" />
4
5
  export * from './index';
@@ -3,6 +3,7 @@ import { Observable } from 'rxjs';
3
3
  import { DaffRoutingUriNormalizer } from '@daffodil/core/routing';
4
4
  import { DaffExternalRouter, DaffExternalRouterConfiguration } from '@daffodil/external-router';
5
5
  import { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';
6
+ import * as i0 from "@angular/core";
6
7
  /**
7
8
  * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route
8
9
  * of an Angular App and either navigating to a resolved route upon successful resolution
@@ -16,4 +17,6 @@ export declare class DaffExternalRouterExistenceGuard implements CanActivate {
16
17
  private urlNormalizer;
17
18
  constructor(driver: DaffExternalRouterDriverInterface, externalRouter: DaffExternalRouter, router: Router, config: DaffExternalRouterConfiguration, urlNormalizer: DaffRoutingUriNormalizer);
18
19
  canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<UrlTree | boolean>;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffExternalRouterExistenceGuard, never>;
21
+ static ɵprov: i0.ɵɵInjectableDeclaration<DaffExternalRouterExistenceGuard>;
19
22
  }
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@daffodil/external-router/routing",
3
- "main": "../bundles/daffodil-external-router-routing.umd.js",
4
- "module": "../fesm2015/daffodil-external-router-routing.js",
5
- "es2015": "../fesm2015/daffodil-external-router-routing.js",
6
- "esm2015": "../esm2015/routing/daffodil-external-router-routing.js",
7
- "fesm2015": "../fesm2015/daffodil-external-router-routing.js",
3
+ "module": "../fesm2015/daffodil-external-router-routing.mjs",
4
+ "es2020": "../fesm2020/daffodil-external-router-routing.mjs",
5
+ "esm2020": "../esm2020/routing/daffodil-external-router-routing.mjs",
6
+ "fesm2020": "../fesm2020/daffodil-external-router-routing.mjs",
7
+ "fesm2015": "../fesm2015/daffodil-external-router-routing.mjs",
8
8
  "typings": "daffodil-external-router-routing.d.ts",
9
- "metadata": "daffodil-external-router-routing.metadata.json",
10
9
  "sideEffects": false
11
10
  }
@@ -0,0 +1,6 @@
1
+ import { ActivatedRouteSnapshot, Data } from '@angular/router';
2
+ /**
3
+ * Extracts a key from DaffPath data based upon the currently activated
4
+ * RouteSnapshot.
5
+ */
6
+ export declare const daffExtractDaffPathData: <T extends Data = Data>(snapshot: ActivatedRouteSnapshot, key: keyof T) => unknown;