@daffodil/external-router 0.38.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of @daffodil/external-router might be problematic. Click here for more details.

Files changed (187) hide show
  1. package/README.md +10 -0
  2. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.js +490 -0
  3. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.js.map +1 -0
  4. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.min.js +16 -0
  5. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.min.js.map +1 -0
  6. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.js +487 -0
  7. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.js.map +1 -0
  8. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.min.js +16 -0
  9. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.min.js.map +1 -0
  10. package/bundles/daffodil-external-router-driver-magento.umd.js +69 -0
  11. package/bundles/daffodil-external-router-driver-magento.umd.js.map +1 -0
  12. package/bundles/daffodil-external-router-driver-magento.umd.min.js +2 -0
  13. package/bundles/daffodil-external-router-driver-magento.umd.min.js.map +1 -0
  14. package/bundles/daffodil-external-router-driver-testing.umd.js +155 -0
  15. package/bundles/daffodil-external-router-driver-testing.umd.js.map +1 -0
  16. package/bundles/daffodil-external-router-driver-testing.umd.min.js +2 -0
  17. package/bundles/daffodil-external-router-driver-testing.umd.min.js.map +1 -0
  18. package/bundles/daffodil-external-router-driver.umd.js +79 -0
  19. package/bundles/daffodil-external-router-driver.umd.js.map +1 -0
  20. package/bundles/daffodil-external-router-driver.umd.min.js +2 -0
  21. package/bundles/daffodil-external-router-driver.umd.min.js.map +1 -0
  22. package/bundles/daffodil-external-router-routing.umd.js +644 -0
  23. package/bundles/daffodil-external-router-routing.umd.js.map +1 -0
  24. package/bundles/daffodil-external-router-routing.umd.min.js +16 -0
  25. package/bundles/daffodil-external-router-routing.umd.min.js.map +1 -0
  26. package/bundles/daffodil-external-router.umd.js +794 -0
  27. package/bundles/daffodil-external-router.umd.js.map +1 -0
  28. package/bundles/daffodil-external-router.umd.min.js +16 -0
  29. package/bundles/daffodil-external-router.umd.min.js.map +1 -0
  30. package/config.d.ts +20 -0
  31. package/daffodil-external-router.d.ts +5 -0
  32. package/daffodil-external-router.metadata.json +1 -0
  33. package/driver/daffodil-external-router-driver.d.ts +4 -0
  34. package/driver/daffodil-external-router-driver.metadata.json +1 -0
  35. package/driver/index.d.ts +1 -0
  36. package/driver/interfaces/external-router-driver.interface.d.ts +22 -0
  37. package/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.d.ts +5 -0
  38. package/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.metadata.json +1 -0
  39. package/driver/magento/2.4.1/graphql/queries/resolve-url-v2.4.1.d.ts +6 -0
  40. package/driver/magento/2.4.1/index.d.ts +1 -0
  41. package/driver/magento/2.4.1/magento.module.d.ts +23 -0
  42. package/driver/magento/2.4.1/magento.service.d.ts +15 -0
  43. package/driver/magento/2.4.1/package.json +11 -0
  44. package/driver/magento/2.4.1/public_api.d.ts +2 -0
  45. package/driver/magento/2.4.1/transforms/resolution-to-resolvable-url.d.ts +3 -0
  46. package/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.d.ts +5 -0
  47. package/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.metadata.json +1 -0
  48. package/driver/magento/2.4.2/graphql/queries/resolve-url-v2.4.2.d.ts +6 -0
  49. package/driver/magento/2.4.2/index.d.ts +1 -0
  50. package/driver/magento/2.4.2/magento.module.d.ts +23 -0
  51. package/driver/magento/2.4.2/magento.service.d.ts +15 -0
  52. package/driver/magento/2.4.2/package.json +11 -0
  53. package/driver/magento/2.4.2/public_api.d.ts +2 -0
  54. package/driver/magento/2.4.2/transforms/resolution-to-resolvable-url.d.ts +3 -0
  55. package/driver/magento/daffodil-external-router-driver-magento.d.ts +4 -0
  56. package/driver/magento/daffodil-external-router-driver-magento.metadata.json +1 -0
  57. package/driver/magento/index.d.ts +1 -0
  58. package/driver/magento/model/public_api.d.ts +3 -0
  59. package/driver/magento/model/resolution-types.d.ts +5 -0
  60. package/driver/magento/model/url-resolver-response.d.ts +4 -0
  61. package/driver/magento/model/url-resolver.d.ts +13 -0
  62. package/driver/magento/package.json +11 -0
  63. package/driver/magento/public_api.d.ts +2 -0
  64. package/driver/magento/transforms/public_api.d.ts +1 -0
  65. package/driver/magento/transforms/redirect-to-http.d.ts +4 -0
  66. package/driver/not-found-resolution.d.ts +8 -0
  67. package/driver/package.json +11 -0
  68. package/driver/public_api.d.ts +2 -0
  69. package/driver/testing/config.d.ts +16 -0
  70. package/driver/testing/daffodil-external-router-driver-testing.d.ts +5 -0
  71. package/driver/testing/daffodil-external-router-driver-testing.metadata.json +1 -0
  72. package/driver/testing/index.d.ts +1 -0
  73. package/driver/testing/package.json +11 -0
  74. package/driver/testing/public_api.d.ts +3 -0
  75. package/driver/testing/testing.module.d.ts +9 -0
  76. package/driver/testing/testing.service.d.ts +17 -0
  77. package/errors/no-wildcard.d.ts +9 -0
  78. package/errors/unknown-type.d.ts +9 -0
  79. package/esm2015/config.js +41 -0
  80. package/esm2015/daffodil-external-router.js +11 -0
  81. package/esm2015/driver/daffodil-external-router-driver.js +10 -0
  82. package/esm2015/driver/index.js +7 -0
  83. package/esm2015/driver/interfaces/external-router-driver.interface.js +30 -0
  84. package/esm2015/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.js +11 -0
  85. package/esm2015/driver/magento/2.4.1/graphql/queries/resolve-url-v2.4.1.js +24 -0
  86. package/esm2015/driver/magento/2.4.1/index.js +7 -0
  87. package/esm2015/driver/magento/2.4.1/magento.module.js +56 -0
  88. package/esm2015/driver/magento/2.4.1/magento.service.js +63 -0
  89. package/esm2015/driver/magento/2.4.1/public_api.js +11 -0
  90. package/esm2015/driver/magento/2.4.1/transforms/resolution-to-resolvable-url.js +23 -0
  91. package/esm2015/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.js +11 -0
  92. package/esm2015/driver/magento/2.4.2/graphql/queries/resolve-url-v2.4.2.js +24 -0
  93. package/esm2015/driver/magento/2.4.2/index.js +7 -0
  94. package/esm2015/driver/magento/2.4.2/magento.module.js +56 -0
  95. package/esm2015/driver/magento/2.4.2/magento.service.js +62 -0
  96. package/esm2015/driver/magento/2.4.2/public_api.js +11 -0
  97. package/esm2015/driver/magento/2.4.2/transforms/resolution-to-resolvable-url.js +20 -0
  98. package/esm2015/driver/magento/daffodil-external-router-driver-magento.js +10 -0
  99. package/esm2015/driver/magento/index.js +7 -0
  100. package/esm2015/driver/magento/model/public_api.js +7 -0
  101. package/esm2015/driver/magento/model/resolution-types.js +13 -0
  102. package/esm2015/driver/magento/model/url-resolver-response.js +14 -0
  103. package/esm2015/driver/magento/model/url-resolver.js +28 -0
  104. package/esm2015/driver/magento/public_api.js +11 -0
  105. package/esm2015/driver/magento/transforms/public_api.js +7 -0
  106. package/esm2015/driver/magento/transforms/redirect-to-http.js +15 -0
  107. package/esm2015/driver/not-found-resolution.js +19 -0
  108. package/esm2015/driver/public_api.js +11 -0
  109. package/esm2015/driver/testing/config.js +27 -0
  110. package/esm2015/driver/testing/daffodil-external-router-driver-testing.js +11 -0
  111. package/esm2015/driver/testing/index.js +7 -0
  112. package/esm2015/driver/testing/public_api.js +11 -0
  113. package/esm2015/driver/testing/testing.module.js +42 -0
  114. package/esm2015/driver/testing/testing.service.js +65 -0
  115. package/esm2015/errors/no-wildcard.js +24 -0
  116. package/esm2015/errors/unknown-type.js +24 -0
  117. package/esm2015/external-router.module.js +36 -0
  118. package/esm2015/model/insertion-strategy.type.js +6 -0
  119. package/esm2015/model/public_api.js +6 -0
  120. package/esm2015/model/resolvable-route.js +36 -0
  121. package/esm2015/model/route-info.js +17 -0
  122. package/esm2015/model/route-type.js +6 -0
  123. package/esm2015/model/route-with-data-path.js +6 -0
  124. package/esm2015/model/route-without-path.js +6 -0
  125. package/esm2015/model/type-route-pair.js +34 -0
  126. package/esm2015/public_api.js +19 -0
  127. package/esm2015/router/router.service.js +67 -0
  128. package/esm2015/router/strategies/insert-data-path.js +129 -0
  129. package/esm2015/router/strategies/insert-route-before-wildcard.js +33 -0
  130. package/esm2015/router/url-matcher/data-path-matcher.js +51 -0
  131. package/esm2015/routing/daffodil-external-router-routing.js +10 -0
  132. package/esm2015/routing/errors/client-error.js +23 -0
  133. package/esm2015/routing/errors/not-found-error.js +23 -0
  134. package/esm2015/routing/errors/permanent-redirect.js +28 -0
  135. package/esm2015/routing/errors/server-error.js +23 -0
  136. package/esm2015/routing/errors/temporary-redirect.js +28 -0
  137. package/esm2015/routing/guard/existence.guard.js +149 -0
  138. package/esm2015/routing/index.js +7 -0
  139. package/esm2015/routing/processors/process-errors.js +32 -0
  140. package/esm2015/routing/processors/process-redirect.js +28 -0
  141. package/esm2015/routing/public_api.js +10 -0
  142. package/esm2015/token/type-resolvable-routes.token.js +46 -0
  143. package/esm2015/transform/resolved-route-to-route.js +33 -0
  144. package/external-router.module.d.ts +10 -0
  145. package/fesm2015/daffodil-external-router-driver-magento-2.4.1.js +177 -0
  146. package/fesm2015/daffodil-external-router-driver-magento-2.4.1.js.map +1 -0
  147. package/fesm2015/daffodil-external-router-driver-magento-2.4.2.js +174 -0
  148. package/fesm2015/daffodil-external-router-driver-magento-2.4.2.js.map +1 -0
  149. package/fesm2015/daffodil-external-router-driver-magento.js +59 -0
  150. package/fesm2015/daffodil-external-router-driver-magento.js.map +1 -0
  151. package/fesm2015/daffodil-external-router-driver-testing.js +148 -0
  152. package/fesm2015/daffodil-external-router-driver-testing.js.map +1 -0
  153. package/fesm2015/daffodil-external-router-driver.js +70 -0
  154. package/fesm2015/daffodil-external-router-driver.js.map +1 -0
  155. package/fesm2015/daffodil-external-router-routing.js +336 -0
  156. package/fesm2015/daffodil-external-router-routing.js.map +1 -0
  157. package/fesm2015/daffodil-external-router.js +489 -0
  158. package/fesm2015/daffodil-external-router.js.map +1 -0
  159. package/model/insertion-strategy.type.d.ts +8 -0
  160. package/model/public_api.d.ts +7 -0
  161. package/model/resolvable-route.d.ts +27 -0
  162. package/model/route-info.d.ts +9 -0
  163. package/model/route-type.d.ts +6 -0
  164. package/model/route-with-data-path.d.ts +15 -0
  165. package/model/route-without-path.d.ts +7 -0
  166. package/model/type-route-pair.d.ts +26 -0
  167. package/package.json +37 -0
  168. package/public_api.d.ts +10 -0
  169. package/router/router.service.d.ts +12 -0
  170. package/router/strategies/insert-data-path.d.ts +40 -0
  171. package/router/strategies/insert-route-before-wildcard.d.ts +6 -0
  172. package/router/url-matcher/data-path-matcher.d.ts +20 -0
  173. package/routing/daffodil-external-router-routing.d.ts +4 -0
  174. package/routing/daffodil-external-router-routing.metadata.json +1 -0
  175. package/routing/errors/client-error.d.ts +8 -0
  176. package/routing/errors/not-found-error.d.ts +9 -0
  177. package/routing/errors/permanent-redirect.d.ts +10 -0
  178. package/routing/errors/server-error.d.ts +8 -0
  179. package/routing/errors/temporary-redirect.d.ts +10 -0
  180. package/routing/guard/existence.guard.d.ts +19 -0
  181. package/routing/index.d.ts +1 -0
  182. package/routing/package.json +11 -0
  183. package/routing/processors/process-errors.d.ts +6 -0
  184. package/routing/processors/process-redirect.d.ts +6 -0
  185. package/routing/public_api.d.ts +1 -0
  186. package/token/type-resolvable-routes.token.d.ts +14 -0
  187. package/transform/resolved-route-to-route.d.ts +7 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-external-router.js","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"],"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<\n\tDaffExternalRouterConfiguration\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\t/**\n\t * The path to redirect to when external route resolution fails.\n\t */\n\tfailedResolutionPath: string;\n\n\t/**\n\t * The path to redirect to when the requested URL is not found.\n\t */\n\tnotFoundResolutionPath: 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<\n\tDaffTypeRoutePair[]\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\tpublic readonly code: string = 'NO_WILDCARD_ROUTE';\n\n\tconstructor(message?: string) {\n\t super(message);\n\t}\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\tpublic readonly code: string = 'UNKNOWN_ROUTE_TYPE';\n\n\tconstructor(message?: string) {\n\t super(message);\n\t}\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 ...routeType.route,\n data: {\n daffExternalRouteType: resolvedRoute.type,\n ...routeType.route.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';\n\n/**\n * Tests whether or not a route matches a specific Daffodil Route type.\n *\n * See {@link DaffRouteWithDataPath}\n */\nconst routeMatchesRouteType = (route: DaffRouteWithDataPath, 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:\n (route: DaffRouteWithDataPath, path: string) => Route =\n (route: DaffRouteWithDataPath, path: string) => route.data.daffPaths = {\n ...route.data.daffPaths,\n [path]: path,\n };\n\nconst operateOnRoute = (externalRoute: Route): (route: Route) => Route =>\n (route: DaffRouteWithDataPath) => addRouteToDaffPaths(route, externalRoute.path);\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: (route: Route) => void): 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: DaffRouteWithDataPath, routes: Routes) => traverseRouteTree(\n routes,\n (route) => routeMatchesRouteType(route, externalRoute.data?.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"],"names":[],"mappings":";;;;;;;;;;;;MAEa,sCAAsC,GAAoC;IACrF,oBAAoB,EAAE,GAAG;IACzB,sBAAsB,EAAE,GAAG;CAC5B;;;;;;MAMY,2BAA2B,GAAG,IAAI,cAAc,CAE3D,6BAA6B,EAAE;IAC/B,UAAU,EAAE,MAAM;IAClB,OAAO;;;IAAE,MAAM,sCAAsC,CAAA;CACtD;;;;;8CAeA;;;;;;IANA,+DAA6B;;;;;IAK7B,iEAA+B;;;;;;;;;;;;MCjBnB,8CAA8C,GAAG,IAAI,cAAc,CAE9E,6CAA6C,EAAE;IAC/C,UAAU,EAAE,MAAM;IAClB,OAAO;;;IAAE,MAAM,EAAE,CAAA;CAClB;;;;;;SAKe,gCAAgC,CAAC,aAAgC;IAC/E,OAAO;QACL,OAAO,EAAE,8CAA8C;QACvD,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,aAAa;KACxB,CAAC;AACJ,CAAC;;;;;;SAKe,iCAAiC,CAAC,MAA2B;IAC3E,OAAO,MAAM,CAAC,GAAG;;;;IAAC,CAAC,KAAwB,MAAM;QAC/C,OAAO,EAAE,8CAA8C;QACvD,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,KAAK;KAChB,CAAC,EAAC,CAAC;AACN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N,CAAC,KAAK,eAAK,OAAA,qBAAqB,CAAC,KAAK,QAAE,aAAa,CAAC,IAAI,0CAAE,qBAAqB,CAAC,CAAA,EAAA,GAClF,cAAc,CAAC,aAAa,CAAC,CAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;MCzEY,sBAAsB;;;;;;AAAe,CAAC,QAAsB,EAAE,KAAsB,EAAE,KAA4B;;;UACvH,IAAI,GAAG,2BAA2B,CAAC,QAAQ,CAAC,MAAM;;;;;IAAC,CAAC,GAAW,EAAE,OAAO,KAAK,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC,IAAI,GAAE,EAAE,CAAC,CAAC;;UAC3G,KAAK,SAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,0CAAE,SAAS;;IAGpC,IAAG,CAAC,KAAK,EAAE;QACT,OAAO,IAAI,CAAC;KACb;;;IAID,OAAO,IAAI,IAAI,KAAK,GAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;AACxD,CAAC;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import { Route, Routes } from '@angular/router';
2
+ /**
3
+ * A function used to insert a route into a routing config.
4
+ * The entire routing configuration will be replaced by the return value
5
+ * so a typical usage should not modify the config beyond simply adding the route
6
+ * to the desired location.
7
+ */
8
+ export declare type DaffExternalRouterInsertionStrategy = (route: Route, routes: Routes) => Routes;
@@ -0,0 +1,7 @@
1
+ export { DaffExternalRouterInsertionStrategy } from './insertion-strategy.type';
2
+ export { DaffExternallyResolvableUrl } from './resolvable-route';
3
+ export { DaffRouteInfo } from './route-info';
4
+ export { DaffExternalRouteType } from './route-type';
5
+ export { DaffRouteWithoutPath } from './route-without-path';
6
+ export { DaffTypeRoutePair } from './type-route-pair';
7
+ export { DaffRouteWithDataPath } from './route-with-data-path';
@@ -0,0 +1,27 @@
1
+ import { DaffIdentifiable } from '@daffodil/core';
2
+ import { DaffExternalRouteType } from './route-type';
3
+ /**
4
+ * A `DaffExternallyResolvableUrl` describes the relationship between a "type" of route
5
+ * as determined by an external platform and a URI.
6
+ *
7
+ * ```ts
8
+ * export const resolvableRoute: DaffExternallyResolvableUrl = {
9
+ * id: "id-of-resource",
10
+ * url: "some/path/to-a-resource",
11
+ * type: "RESOURCE_TYPE"
12
+ * }
13
+ * ```
14
+ */
15
+ export interface DaffExternallyResolvableUrl extends DaffIdentifiable {
16
+ /**
17
+ * The URL that will be used for the path of the route inserted
18
+ * into the Angular routing config.
19
+ * Should not contain URL fragments, query parameters, or leading slashes.
20
+ */
21
+ url: string;
22
+ type: DaffExternalRouteType;
23
+ /**
24
+ * The HTTP status code for the resolvable route.
25
+ */
26
+ code: number;
27
+ }
@@ -0,0 +1,9 @@
1
+ import { DaffExternalRouterInsertionStrategy } from './insertion-strategy.type';
2
+ import { DaffRouteWithDataPath } from './route-with-data-path';
3
+ /**
4
+ * An object containing the info needed to insert a route into a configuration.
5
+ */
6
+ export interface DaffRouteInfo {
7
+ route: DaffRouteWithDataPath;
8
+ insertionStrategy?: DaffExternalRouterInsertionStrategy;
9
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The routing type of a particular route. E.g. if there's a category
3
+ * called "Sweatshirts" with an externally resolved URL of "/sweatshirts"
4
+ * Then, this type could be something like "CATEGORY".
5
+ */
6
+ export declare type DaffExternalRouteType = string;
@@ -0,0 +1,15 @@
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 DaffRouteWithDataPath = Route & {
11
+ data?: {
12
+ daffExternalRouteType?: DaffExternalRouteType;
13
+ daffPaths?: Record<string, string>;
14
+ };
15
+ };
@@ -0,0 +1,7 @@
1
+ import { Route } from '@angular/router';
2
+ /**
3
+ * A DaffRouteWithoutPath is a special kind of route definition without a path.
4
+ * This is useful when defining routes that aren't provided a path initially,
5
+ * but will be provided with one at a later time, e.g. at runtime.
6
+ */
7
+ export declare type DaffRouteWithoutPath = Omit<Route, 'path'>;
@@ -0,0 +1,26 @@
1
+ import { DaffExternalRouterInsertionStrategy } from './insertion-strategy.type';
2
+ import { DaffExternalRouteType } from './route-type';
3
+ import { DaffRouteWithoutPath } from './route-without-path';
4
+ /**
5
+ * A model used to describe the relationship between a {@link DaffExternalRouterType}
6
+ * and its corresponding route.
7
+ *
8
+ * The DaffTypeRoutePair is the pre-provided "glue" that a developer will provide
9
+ * ahead-of-time so that that the External Router knows what the list of available
10
+ * "types" are (along with that type's corresponding route).
11
+ *
12
+ * An insertion strategy can be specified if the route needs to be inserted somewhere
13
+ * other than the root of the route config.
14
+ * Omitting the insertion strategy will default to inserting the route to the root level,
15
+ * immediately before the wildcard route.
16
+ *
17
+ * @docs-private
18
+ */
19
+ export interface DaffTypeRoutePair {
20
+ type: DaffExternalRouteType;
21
+ route: DaffRouteWithoutPath;
22
+ /**
23
+ * An optional function to provide route insertion behavior.
24
+ */
25
+ insertionStrategy?: DaffExternalRouterInsertionStrategy;
26
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@daffodil/external-router",
3
+ "version": "0.38.7",
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
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/graycoreio/daffodil"
8
+ },
9
+ "author": "Graycore LLC",
10
+ "license": "MIT",
11
+ "bugs": {
12
+ "url": "https://github.com/graycoreio/daffodil/issues"
13
+ },
14
+ "homepage": "https://github.com/graycoreio/daffodil",
15
+ "peerDependencies": {
16
+ "@angular/common": "^10.0.0",
17
+ "@angular/core": "^10.0.0",
18
+ "@angular/router": "^10.0.0",
19
+ "@daffodil/core": "0.38.7",
20
+ "rxjs": "6.6.3"
21
+ },
22
+ "optionalDependencies": {
23
+ "apollo-angular": "^2.4.0",
24
+ "@daffodil/driver": "0.38.7"
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",
31
+ "typings": "daffodil-external-router.d.ts",
32
+ "metadata": "daffodil-external-router.metadata.json",
33
+ "sideEffects": false,
34
+ "dependencies": {
35
+ "tslib": "^2.0.0"
36
+ }
37
+ }
@@ -0,0 +1,10 @@
1
+ export { DaffExternalRouterModule } from './external-router.module';
2
+ export { DAFF_EXTERNAL_ROUTER_CONFIG, DaffExternalRouterConfiguration, } from './config';
3
+ export { daffProvideRouteResolvableByType } from './token/type-resolvable-routes.token';
4
+ export * from './model/public_api';
5
+ export { DaffExternalRouter } from './router/router.service';
6
+ export { daffInsertRouteBeforeWildCardStrategy } from './router/strategies/insert-route-before-wildcard';
7
+ export { daffInsertDataPathStrategy } from './router/strategies/insert-data-path';
8
+ export { daffDataPathUrlMatcher } from './router/url-matcher/data-path-matcher';
9
+ export { DaffExternalRouterNoWildcardError } from './errors/no-wildcard';
10
+ export { DaffExternalRouterUnknownRouteTypeError } from './errors/unknown-type';
@@ -0,0 +1,12 @@
1
+ import { Router } from '@angular/router';
2
+ import { DaffExternallyResolvableUrl } from '../model/resolvable-route';
3
+ import { DaffTypeRoutePair } from '../model/type-route-pair';
4
+ export declare class DaffExternalRouter {
5
+ private router;
6
+ private runtimeRoutes;
7
+ constructor(router: Router, runtimeRoutes: DaffTypeRoutePair[]);
8
+ /**
9
+ * Adds a route to the existing router configuration.
10
+ */
11
+ add(resolvedRoute: DaffExternallyResolvableUrl): void;
12
+ }
@@ -0,0 +1,40 @@
1
+ import { DaffExternalRouterInsertionStrategy } from '../../model/insertion-strategy.type';
2
+ /**
3
+ * A route insertion strategy that can be used to append external routes onto
4
+ * existing Angular routes. This can be useful when you need to route to
5
+ * an existing lazy-loaded module from multiple externally defined urls.
6
+ *
7
+ * This should be used in combination with the {@link daffDataPathUrlMatcher} to match lazy-loaded modules with
8
+ * associated external urls.
9
+ *
10
+ * For example, you can provide the insertion strategy in the {@link DaffExternalRouterModule} as below.
11
+ *
12
+ * ```ts
13
+ * DaffExternalRouterModule.forRoot({}, [
14
+ * {
15
+ * type: 'CATEGORY',
16
+ * insertionStrategy: daffInsertDataPathStrategy,
17
+ * route: {}
18
+ * }
19
+ * ],
20
+ * ```
21
+ *
22
+ * Then, you can match it with an associated route defined in your Routing
23
+ * configuration with the {@link daffDataPathUrlMatcher}.
24
+ *
25
+ * ```ts
26
+ * export const routes: Routes = [
27
+ * {
28
+ * matcher: daffDataPathUrlMatcher,
29
+ * data: {
30
+ * daffExternalRouteType: "CATEGORY",
31
+ * },
32
+ * loadChildren: () => import('./category/category.module').then((m) => m.MyCategoryModule),
33
+ * }
34
+ * ]
35
+ * ```
36
+ *
37
+ * See {@link DaffRouteWithDataPath}
38
+ *
39
+ */
40
+ export declare const daffInsertDataPathStrategy: DaffExternalRouterInsertionStrategy;
@@ -0,0 +1,6 @@
1
+ import { DaffExternalRouterInsertionStrategy } from '../../model/insertion-strategy.type';
2
+ /**
3
+ * Inserts a Route into Routes right before the wildcard route.
4
+ * If no wildcard is found, it fails fast with a `DaffExternalRouterNoWildcardError`.
5
+ */
6
+ export declare const daffInsertRouteBeforeWildCardStrategy: DaffExternalRouterInsertionStrategy;
@@ -0,0 +1,20 @@
1
+ import { UrlMatcher } from '@angular/router';
2
+ /**
3
+ * A UrlMatcher that does an exact match against a path stored in the special
4
+ * configuration fields that External Router stores on a Route's data.
5
+ *
6
+ * ```ts
7
+ * export const routes: Routes = [
8
+ * {
9
+ * matcher: daffDataPathUrlMatcher,
10
+ * data: {
11
+ * daffExternalRouteType: "CATEGORY",
12
+ * },
13
+ * loadChildren: () => import('./category/category.module').then((m) => m.ShopCategoryModule),
14
+ * }
15
+ * ]
16
+ * ```
17
+ * {@link daffInsertDataPathStrategy }
18
+ * {@link DaffRouteWithDataPath }
19
+ */
20
+ export declare const daffDataPathUrlMatcher: UrlMatcher;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
@@ -0,0 +1 @@
1
+ {"__symbolic":"module","version":4,"metadata":{"DaffExternalRouterExistenceGuard":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":46,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":51,"character":5},"arguments":[{"__symbolic":"reference","module":"@daffodil/external-router/driver","name":"DaffExternalRouterDriver","line":51,"character":12}]}],null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":55,"character":5},"arguments":[{"__symbolic":"reference","module":"@daffodil/external-router","name":"DAFF_EXTERNAL_ROUTER_CONFIG","line":55,"character":12}]}],null],"parameters":[{"__symbolic":"reference","module":"@daffodil/external-router/driver","name":"DaffExternalRouterDriverInterface","line":52,"character":20},{"__symbolic":"reference","module":"@daffodil/external-router","name":"DaffExternalRouter","line":53,"character":28},{"__symbolic":"reference","module":"@angular/router","name":"Router","line":54,"character":20},{"__symbolic":"reference","module":"@daffodil/external-router","name":"DaffExternalRouterConfiguration","line":56,"character":20},{"__symbolic":"reference","module":"@daffodil/core/routing","name":"DaffRoutingUriNormalizer","line":57,"character":27}]}],"canActivate":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}}},"origins":{"DaffExternalRouterExistenceGuard":"./guard/existence.guard"},"importAs":"@daffodil/external-router/routing"}
@@ -0,0 +1,8 @@
1
+ import { DaffError, DaffInheritableError } from '@daffodil/core';
2
+ /**
3
+ * An error thrown when the driver encounters a 4xx error.
4
+ */
5
+ export declare class DaffExternalRouterClientError extends DaffInheritableError implements DaffError {
6
+ readonly code: string;
7
+ constructor(message?: string);
8
+ }
@@ -0,0 +1,9 @@
1
+ import { DaffError } from '@daffodil/core';
2
+ import { DaffExternalRouterClientError } from './client-error';
3
+ /**
4
+ * An error thrown when the driver determines that a given url is not resolvable.
5
+ */
6
+ export declare class DaffExternalRouterNotFoundError extends DaffExternalRouterClientError implements DaffError {
7
+ readonly code: string;
8
+ constructor(message?: string);
9
+ }
@@ -0,0 +1,10 @@
1
+ import { DaffError, DaffInheritableError } from '@daffodil/core';
2
+ /**
3
+ * An error thrown when the driver determines that the url needs to be routed somewhere
4
+ * else permanently.
5
+ */
6
+ export declare class DaffExternalRouterPermanentRedirectError extends DaffInheritableError implements DaffError {
7
+ redirectUrl: string;
8
+ readonly code: string;
9
+ constructor(redirectUrl: string, message?: string);
10
+ }
@@ -0,0 +1,8 @@
1
+ import { DaffError, DaffInheritableError } from '@daffodil/core';
2
+ /**
3
+ * An error thrown when the platform performing url resolution fails.
4
+ */
5
+ export declare class DaffExternalRouterServerError extends DaffInheritableError implements DaffError {
6
+ readonly code: string;
7
+ constructor(message?: string);
8
+ }
@@ -0,0 +1,10 @@
1
+ import { DaffError, DaffInheritableError } from '@daffodil/core';
2
+ /**
3
+ * An error thrown when the driver needs a URI to be temporarily redirected
4
+ * to another location.
5
+ */
6
+ export declare class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError implements DaffError {
7
+ redirectUrl: string;
8
+ readonly code: string;
9
+ constructor(redirectUrl: string, message?: string);
10
+ }
@@ -0,0 +1,19 @@
1
+ import { CanActivate, ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
2
+ import { Observable } from 'rxjs';
3
+ import { DaffRoutingUriNormalizer } from '@daffodil/core/routing';
4
+ import { DaffExternalRouter, DaffExternalRouterConfiguration } from '@daffodil/external-router';
5
+ import { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';
6
+ /**
7
+ * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route
8
+ * of an Angular App and either navigating to a resolved route upon successful resolution
9
+ * or navigating to the configured route upon a failed resolution.
10
+ */
11
+ export declare class DaffExternalRouterExistenceGuard implements CanActivate {
12
+ private driver;
13
+ private externalRouter;
14
+ private router;
15
+ private config;
16
+ private urlNormalizer;
17
+ constructor(driver: DaffExternalRouterDriverInterface, externalRouter: DaffExternalRouter, router: Router, config: DaffExternalRouterConfiguration, urlNormalizer: DaffRoutingUriNormalizer);
18
+ canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<UrlTree | boolean>;
19
+ }
@@ -0,0 +1 @@
1
+ export * from './public_api';
@@ -0,0 +1,11 @@
1
+ {
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",
8
+ "typings": "daffodil-external-router-routing.d.ts",
9
+ "metadata": "daffodil-external-router-routing.metadata.json",
10
+ "sideEffects": false
11
+ }
@@ -0,0 +1,6 @@
1
+ import { DaffExternallyResolvableUrl } from '@daffodil/external-router';
2
+ /**
3
+ * Processes resolved URLs and throws the appropriate error so that External Router
4
+ * can handle routing errors.
5
+ */
6
+ export declare const processErrors: (url: DaffExternallyResolvableUrl) => DaffExternallyResolvableUrl;
@@ -0,0 +1,6 @@
1
+ import { DaffExternallyResolvableUrl } from '@daffodil/external-router';
2
+ /**
3
+ * Processes resolvedUrls and throws the appropriate error so that External Router
4
+ * can handle redirects.
5
+ */
6
+ export declare const processRedirects: (url: DaffExternallyResolvableUrl) => DaffExternallyResolvableUrl;
@@ -0,0 +1 @@
1
+ export { DaffExternalRouterExistenceGuard } from './guard/existence.guard';
@@ -0,0 +1,14 @@
1
+ import { InjectionToken, Provider } from '@angular/core';
2
+ import { DaffTypeRoutePair } from '../model/type-route-pair';
3
+ /**
4
+ * A multi-token that allows you to register route "types" that correspond to routes.
5
+ */
6
+ export declare const DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE: InjectionToken<DaffTypeRoutePair[]>;
7
+ /**
8
+ * A provider used to connect a type to a route to enable dynamic route resolution at runtime.
9
+ */
10
+ export declare function daffProvideRouteResolvableByType(typeRoutePair: DaffTypeRoutePair): Provider;
11
+ /**
12
+ * A multi-provider used to connect an array of types to their respective routes.
13
+ */
14
+ export declare function daffProvideRoutesResolvableByType(routes: DaffTypeRoutePair[]): Provider[];
@@ -0,0 +1,7 @@
1
+ import { DaffExternallyResolvableUrl } from '../model/resolvable-route';
2
+ import { DaffRouteInfo } from '../model/route-info';
3
+ import { DaffTypeRoutePair } from '../model/type-route-pair';
4
+ /**
5
+ * Transforms a DaffExternallyResolvableUrl into an Angular Route.
6
+ */
7
+ export declare const daffTransformResolvedRouteToRoute: (resolvedRoute: DaffExternallyResolvableUrl, availableTypes: DaffTypeRoutePair[]) => DaffRouteInfo;