@daffodil/external-router 0.77.0 → 0.79.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 (95) hide show
  1. package/README.md +116 -7
  2. package/config.d.ts +1 -10
  3. package/driver/in-memory/config.d.ts +1 -7
  4. package/driver/in-memory/in-memory.module.d.ts +2 -0
  5. package/driver/in-memory/provider.d.ts +6 -0
  6. package/driver/in-memory/public_api.d.ts +1 -0
  7. package/driver/interfaces/external-router-driver.interface.d.ts +2 -6
  8. package/driver/magento/2.4.3/provider.d.ts +5 -0
  9. package/driver/magento/2.4.3/public_api.d.ts +1 -0
  10. package/driver/public_api.d.ts +1 -1
  11. package/driver/testing/config.d.ts +3 -9
  12. package/driver/testing/provider.d.ts +6 -0
  13. package/driver/testing/public_api.d.ts +1 -0
  14. package/esm2022/config.mjs +8 -7
  15. package/esm2022/driver/in-memory/config.mjs +8 -6
  16. package/esm2022/driver/in-memory/in-memory.module.mjs +8 -15
  17. package/esm2022/driver/in-memory/provider.mjs +12 -0
  18. package/esm2022/driver/in-memory/public_api.mjs +2 -1
  19. package/esm2022/driver/interfaces/external-router-driver.interface.mjs +8 -3
  20. package/esm2022/driver/magento/2.4.1/magento.module.mjs +5 -12
  21. package/esm2022/driver/magento/2.4.2/magento.module.mjs +5 -12
  22. package/esm2022/driver/magento/2.4.3/magento.module.mjs +5 -12
  23. package/esm2022/driver/magento/2.4.3/provider.mjs +13 -0
  24. package/esm2022/driver/magento/2.4.3/public_api.mjs +2 -1
  25. package/esm2022/driver/public_api.mjs +2 -2
  26. package/esm2022/driver/testing/config.mjs +8 -6
  27. package/esm2022/driver/testing/provider.mjs +12 -0
  28. package/esm2022/driver/testing/public_api.mjs +2 -1
  29. package/esm2022/driver/testing/testing.module.mjs +5 -11
  30. package/esm2022/driver/testing/testing.service.mjs +13 -11
  31. package/esm2022/model/public_api.mjs +1 -1
  32. package/esm2022/model/route-with-seo-data.mjs +1 -1
  33. package/esm2022/provide-external-router.mjs +6 -0
  34. package/esm2022/public_api.mjs +2 -10
  35. package/esm2022/routing/guard/external-matcher-type.guard.mjs +43 -0
  36. package/esm2022/routing/helper/convert-to-path.mjs +7 -0
  37. package/esm2022/routing/public_api.mjs +2 -2
  38. package/fesm2022/daffodil-external-router-driver-in-memory.mjs +22 -18
  39. package/fesm2022/daffodil-external-router-driver-in-memory.mjs.map +1 -1
  40. package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs +4 -11
  41. package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs.map +1 -1
  42. package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs +4 -11
  43. package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs.map +1 -1
  44. package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs +14 -13
  45. package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs.map +1 -1
  46. package/fesm2022/daffodil-external-router-driver-testing.mjs +31 -25
  47. package/fesm2022/daffodil-external-router-driver-testing.mjs.map +1 -1
  48. package/fesm2022/daffodil-external-router-driver.mjs +8 -3
  49. package/fesm2022/daffodil-external-router-driver.mjs.map +1 -1
  50. package/fesm2022/daffodil-external-router-routing.mjs +40 -66
  51. package/fesm2022/daffodil-external-router-routing.mjs.map +1 -1
  52. package/fesm2022/daffodil-external-router.mjs +10 -282
  53. package/fesm2022/daffodil-external-router.mjs.map +1 -1
  54. package/model/public_api.d.ts +2 -5
  55. package/model/route-with-seo-data.d.ts +3 -4
  56. package/package.json +1 -1
  57. package/provide-external-router.d.ts +3 -0
  58. package/public_api.d.ts +1 -9
  59. package/routing/guard/external-matcher-type.guard.d.ts +10 -0
  60. package/routing/helper/convert-to-path.d.ts +7 -0
  61. package/routing/public_api.d.ts +1 -1
  62. package/errors/no-wildcard.d.ts +0 -9
  63. package/errors/unknown-type.d.ts +0 -9
  64. package/esm2022/errors/no-wildcard.mjs +0 -12
  65. package/esm2022/errors/unknown-type.mjs +0 -12
  66. package/esm2022/external-router.module.mjs +0 -31
  67. package/esm2022/model/insertion-strategy.type.mjs +0 -2
  68. package/esm2022/model/route-info.mjs +0 -2
  69. package/esm2022/model/route-with-data-path.mjs +0 -2
  70. package/esm2022/model/route-with-type.mjs +0 -2
  71. package/esm2022/model/route-without-path.mjs +0 -2
  72. package/esm2022/model/type-route-pair.mjs +0 -2
  73. package/esm2022/router/router.service.mjs +0 -43
  74. package/esm2022/router/strategies/insert-data-path.mjs +0 -84
  75. package/esm2022/router/strategies/insert-route-before-wildcard.mjs +0 -17
  76. package/esm2022/router/url-matcher/data-path-matcher.mjs +0 -31
  77. package/esm2022/routing/guard/existence.guard.mjs +0 -77
  78. package/esm2022/token/type-resolvable-routes.token.mjs +0 -29
  79. package/esm2022/transform/resolved-route-to-route.mjs +0 -24
  80. package/esm2022/util/extract-daff-path-data.mjs +0 -9
  81. package/external-router.module.d.ts +0 -15
  82. package/model/insertion-strategy.type.d.ts +0 -8
  83. package/model/route-info.d.ts +0 -9
  84. package/model/route-with-data-path.d.ts +0 -14
  85. package/model/route-with-type.d.ts +0 -12
  86. package/model/route-without-path.d.ts +0 -7
  87. package/model/type-route-pair.d.ts +0 -26
  88. package/router/router.service.d.ts +0 -15
  89. package/router/strategies/insert-data-path.d.ts +0 -40
  90. package/router/strategies/insert-route-before-wildcard.d.ts +0 -6
  91. package/router/url-matcher/data-path-matcher.d.ts +0 -20
  92. package/routing/guard/existence.guard.d.ts +0 -22
  93. package/token/type-resolvable-routes.token.d.ts +0 -14
  94. package/transform/resolved-route-to-route.d.ts +0 -7
  95. package/util/extract-daff-path-data.d.ts +0 -6
@@ -1,13 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, NgModule } from '@angular/core';
2
+ import { Injectable, NgModule, makeEnvironmentProviders } from '@angular/core';
3
3
  import * as i1 from 'apollo-angular';
4
4
  import { gql } from 'apollo-angular';
5
5
  import { map } from 'rxjs/operators';
6
6
  import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
7
- import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver } from '@daffodil/external-router/driver';
7
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
8
  import { magentoTransformRedirectToHttpCode } from '@daffodil/external-router/driver/magento';
9
9
  import { CommonModule } from '@angular/common';
10
- import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
10
+ import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
11
11
 
12
12
  const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv243';
13
13
  /**
@@ -104,15 +104,8 @@ class DaffExternalRouterDriverMagentoModule {
104
104
  return {
105
105
  ngModule: DaffExternalRouterDriverMagentoModule,
106
106
  providers: [
107
- {
108
- provide: DaffExternalRouterDriver,
109
- useExisting: DaffExternalRouterMagentoDriver,
110
- },
111
- {
112
- provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
113
- useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,
114
- multi: true,
115
- },
107
+ provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
108
+ provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
116
109
  ],
117
110
  };
118
111
  }
@@ -128,6 +121,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
128
121
  }]
129
122
  }] });
130
123
 
124
+ /**
125
+ * Provides a Magento implementation of {@link DaffExternalRouterDriver}.
126
+ */
127
+ const provideDaffExternalRouterMagentoDriver = () => makeEnvironmentProviders([
128
+ provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
129
+ provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
130
+ ]);
131
+
131
132
  /*
132
133
  * Public API Surface of @daffodil/external-router/driver/magento/2.4.3
133
134
  */
@@ -136,5 +137,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
136
137
  * Generated bundle index. Do not edit.
137
138
  */
138
139
 
139
- export { DaffExternalRouterDriverMagentoModule, DaffExternalRouterMagentoDriver };
140
+ export { DaffExternalRouterDriverMagentoModule, DaffExternalRouterMagentoDriver, provideDaffExternalRouterMagentoDriver };
140
141
  //# sourceMappingURL=daffodil-external-router-driver-magento-2.4.3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver-magento-2.4.3.mjs","sources":["../../../libs/external-router/driver/magento/2.4.3/src/graphql/queries/resolve.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.module.ts","../../../libs/external-router/driver/magento/2.4.3/src/public_api.ts","../../../libs/external-router/driver/magento/2.4.3/src/daffodil-external-router-driver-magento-2.4.3.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv243';\n\n/**\n * This query retrieves a URL resolution from Magento and informs you about\n * what type of route the URL is.\n */\nexport const MagentoResolveUrlv243 = gql`\n\tquery ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {\n\t\troute(url: $url) {\n\t\t\trelative_url\n\t\t\tredirect_code\n\t\t\ttype\n\t\t\t... on CategoryInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t}\n\t\t\t... on ProductInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t}\n\t\t}\n\t}\n`;\n","import {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from '@daffodil/external-router/driver';\nimport {\n magentoTransformRedirectToHttpCode,\n MagentoRoute,\n} from '@daffodil/external-router/driver/magento';\n\n\nexport const transformResolutionToResolvableUrlv243 = (\n resolution: MagentoRoute,\n): DaffExternallyResolvableUrl => (resolution ? {\n id: resolution.uid,\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirect_code),\n data: {\n canonical_url: resolution.canonical_url,\n title: resolution.meta_title ?? resolution.name ?? '',\n meta_description: resolution.meta_description,\n },\n} : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoRouteResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv243 } from './graphql/queries/resolve';\nimport { transformResolutionToResolvableUrlv243 } from './transforms/resolution-to-resolvable-url';\n\n\n/**\n * The DaffExternalRouterMagentoDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterMagentoDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n private apollo: Apollo,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n return this.apollo\n .query<MagentoRouteResponse>({\n query: MagentoResolveUrlv243,\n variables: {\n url,\n },\n })\n .pipe(map(response => transformResolutionToResolvableUrlv243(response.data.route)));\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';\nimport { DaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n {\n provide: DaffExternalRouterDriver,\n useExisting: DaffExternalRouterMagentoDriver,\n },\n {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,\n multi: true,\n },\n ],\n };\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2.4.3\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAE3E;;;AAGG;AACI,MAAM,qBAAqB,GAAG,GAAG,CAAA,CAAA;SAC/B,mCAAmC,CAAA;;;;;;;;;;;;;;;;;;;;;CAqB3C;;AClBM,MAAM,sCAAsC,GAAG,CACpD,UAAwB,MACS,UAAU,GAAG;IAC9C,EAAE,EAAE,U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AC/BD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver-magento-2.4.3.mjs","sources":["../../../libs/external-router/driver/magento/2.4.3/src/graphql/queries/resolve.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.module.ts","../../../libs/external-router/driver/magento/2.4.3/src/provider.ts","../../../libs/external-router/driver/magento/2.4.3/src/public_api.ts","../../../libs/external-router/driver/magento/2.4.3/src/daffodil-external-router-driver-magento-2.4.3.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv243';\n\n/**\n * This query retrieves a URL resolution from Magento and informs you about\n * what type of route the URL is.\n */\nexport const MagentoResolveUrlv243 = gql`\n\tquery ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {\n\t\troute(url: $url) {\n\t\t\trelative_url\n\t\t\tredirect_code\n\t\t\ttype\n\t\t\t... on CategoryInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t}\n\t\t\t... on ProductInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t}\n\t\t}\n\t}\n`;\n","import {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from '@daffodil/external-router/driver';\nimport {\n magentoTransformRedirectToHttpCode,\n MagentoRoute,\n} from '@daffodil/external-router/driver/magento';\n\n\nexport const transformResolutionToResolvableUrlv243 = (\n resolution: MagentoRoute,\n): DaffExternallyResolvableUrl => (resolution ? {\n id: resolution.uid,\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirect_code),\n data: {\n canonical_url: resolution.canonical_url,\n title: resolution.meta_title ?? resolution.name ?? '',\n meta_description: resolution.meta_description,\n },\n} : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoRouteResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv243 } from './graphql/queries/resolve';\nimport { transformResolutionToResolvableUrlv243 } from './transforms/resolution-to-resolvable-url';\n\n\n/**\n * The DaffExternalRouterMagentoDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterMagentoDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n private apollo: Apollo,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n return this.apollo\n .query<MagentoRouteResponse>({\n query: MagentoResolveUrlv243,\n variables: {\n url,\n },\n })\n .pipe(map(response => transformResolutionToResolvableUrlv243(response.data.route)));\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n ],\n };\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * Provides a Magento implementation of {@link DaffExternalRouterDriver}.\n */\nexport const provideDaffExternalRouterMagentoDriver = (\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n]);\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2.4.3\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\nexport { provideDaffExternalRouterMagentoDriver } from './provider';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAE3E;;;AAGG;AACI,MAAM,qBAAqB,GAAG,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A;;;ACpBD;;AAEG;MACU,sCAAsC,GAAG,MAC3B,wBAAwB,CAAC;IAClD,+BAA+B,CAAC,+BAA+B,CAAC;IAChE,oCAAoC,CAAC,mCAAmC,CAAC;AAC1E,CAAA;;AClBD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,20 +1,23 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core';
2
+ import { Injectable, Inject, NgModule, makeEnvironmentProviders } from '@angular/core';
3
3
  import { faker } from '@faker-js/faker/locale/en_US';
4
- import { throwError, of } from 'rxjs';
4
+ import { of } from 'rxjs';
5
5
  import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
6
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';
7
+ import { createConfigInjectionToken } from '@daffodil/core';
6
8
  import { CommonModule } from '@angular/common';
7
- import { DaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
9
 
10
+ const {
9
11
  /**
10
12
  * The token used by Daffodil to hold the driver's configuration.
11
13
  *
12
14
  * @docs-private
13
15
  */
14
- const DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG = new InjectionToken('DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG', {
15
- providedIn: 'root',
16
- factory: () => ({}),
17
- });
16
+ token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,
17
+ /**
18
+ * Provider function for {@link DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG}.
19
+ */
20
+ provider: provideDaffExternalRouterDriverTestingConfig, } = createConfigInjectionToken(({}), 'DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG');
18
21
 
19
22
  /**
20
23
  * The DaffExternalRouterTestingDriver is responsible for translating an
@@ -31,16 +34,17 @@ class DaffExternalRouterTestingDriver {
31
34
  resolve(url) {
32
35
  const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));
33
36
  if (!this.testingConfiguration[truncatedUrl]) {
34
- return throwError(`\
35
- The route '${truncatedUrl}' wasn't provided with a matching type by the testing driver. \
36
- Did you configure the available route types with DaffExternalRouterDriverTestingModule.forRoot(config)`);
37
+ return of(DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);
38
+ }
39
+ if ((typeof this.testingConfiguration[truncatedUrl]) === 'string') {
40
+ return of({
41
+ id: faker.datatype.uuid(),
42
+ url: truncatedUrl,
43
+ type: this.testingConfiguration[truncatedUrl],
44
+ code: 200,
45
+ });
37
46
  }
38
- return of({
39
- id: faker.datatype.uuid(),
40
- url: truncatedUrl,
41
- type: this.testingConfiguration[truncatedUrl],
42
- code: 200,
43
- });
47
+ return of(this.testingConfiguration[truncatedUrl]);
44
48
  }
45
49
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterTestingDriver, deps: [{ token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
46
50
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterTestingDriver, providedIn: 'root' }); }
@@ -64,14 +68,8 @@ class DaffExternalRouterDriverTestingModule {
64
68
  return {
65
69
  ngModule: DaffExternalRouterDriverTestingModule,
66
70
  providers: [
67
- {
68
- provide: DaffExternalRouterDriver,
69
- useExisting: DaffExternalRouterTestingDriver,
70
- },
71
- {
72
- provide: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,
73
- useValue: config,
74
- },
71
+ provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),
72
+ provideDaffExternalRouterDriverTestingConfig(config),
75
73
  ],
76
74
  };
77
75
  }
@@ -87,6 +85,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
87
85
  }]
88
86
  }] });
89
87
 
88
+ /**
89
+ * Provides a testing implementation of {@link DaffExternalRouterDriver}
90
+ */
91
+ const provideDaffExternalRouterTestingDriver = (config) => makeEnvironmentProviders([
92
+ provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),
93
+ provideDaffExternalRouterDriverTestingConfig(config),
94
+ ]);
95
+
90
96
  /*
91
97
  * Public API Surface of @daffodil/external-router/driver/testing
92
98
  */
@@ -95,5 +101,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
95
101
  * Generated bundle index. Do not edit.
96
102
  */
97
103
 
98
- export { DaffExternalRouterDriverTestingModule, DaffExternalRouterTestingDriver };
104
+ export { DaffExternalRouterDriverTestingModule, DaffExternalRouterTestingDriver, provideDaffExternalRouterTestingDriver };
99
105
  //# sourceMappingURL=daffodil-external-router-driver-testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver-testing.mjs","sources":["../../../libs/external-router/driver/testing/src/config.ts","../../../libs/external-router/driver/testing/src/testing.service.ts","../../../libs/external-router/driver/testing/src/testing.module.ts","../../../libs/external-router/driver/testing/src/public_api.ts","../../../libs/external-router/driver/testing/src/daffodil-external-router-driver-testing.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nimport { DaffExternalRouteType } from '@daffodil/external-router';\n\n/**\n * The configuration for the testing driver. It is a dictionary of \"url\": \"type\",\n * pairs, where the URL is a URL-safe routeable path, e.g. \"sweatshirts\" or \"t-shirts\"\n * and the type is a known type to your application, e.g. \"CATEGORY\".\n */\nexport interface DaffExternalRouterDriverTestingConfig {\n [url: string]: DaffExternalRouteType;\n}\n\n/**\n * The token used by Daffodil to hold the driver's configuration.\n *\n * @docs-private\n */\nexport const DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG = new InjectionToken<\n DaffExternalRouterDriverTestingConfig\n>('DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG', {\n providedIn: 'root',\n factory: () => ({}),\n});\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\nimport {\n Observable,\n of,\n throwError,\n} from 'rxjs';\n\nimport {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n} from './config';\n\n/**\n * The DaffExternalRouterTestingDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl in testing environments.\n *\n * @inheritdoc\n *\n * @see {@link DaffExternalRouterTestingDriver}\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterTestingDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n @Inject(DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG)\n private testingConfiguration: DaffExternalRouterDriverTestingConfig = {},\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));\n\n if (!this.testingConfiguration[truncatedUrl]) {\n return throwError(`\\\nThe route '${truncatedUrl}' wasn't provided with a matching type by the testing driver. \\\nDid you configure the available route types with DaffExternalRouterDriverTestingModule.forRoot(config)`);\n }\n\n return of({\n id: faker.datatype.uuid(),\n url: truncatedUrl,\n type: this.testingConfiguration[truncatedUrl],\n code: 200,\n });\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n} from './config';\nimport { DaffExternalRouterTestingDriver } from './testing.service';\n\n/**\n * The `DaffExternalRouterDriverTestingModule` is an importable NgModule that can\n * be used to configure the {@link DaffExternalRouterTestingDriver}.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverTestingModule {\n static forRoot(\n config: DaffExternalRouterDriverTestingConfig,\n ): ModuleWithProviders<DaffExternalRouterDriverTestingModule> {\n return {\n ngModule: DaffExternalRouterDriverTestingModule,\n providers: [\n {\n provide: DaffExternalRouterDriver,\n useExisting: DaffExternalRouterTestingDriver,\n },\n {\n provide: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n useValue: config,\n },\n ],\n };\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/driver/testing\n */\n\nexport { DaffExternalRouterTestingDriver } from './testing.service';\nexport { DaffExternalRouterDriverTestingModule } from './testing.module';\n\nexport { DaffExternalRouterDriverTestingConfig } from './config';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAaA;;;;AAIG;AACI,MAAM,0CAA0C,GAAG,IAAI,cAAc,CAE1E,4CAA4C,EAAE;AAC9C,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,OAAO,EAAE,CAAC;AACpB,CAAA,CAAC;;ACAF;;;;;;;AAOG;MAIU,+BAA+B,CAAA;AAE1C,IAAA,WAAA,CAEU,uBAA8D,EAAE,EAAA;QAAhE,IAAoB,CAAA,oBAAA,GAApB,oBAAoB,CAA4C;KACtE;AAEJ,IAAA,OAAO,CAAC,GAAW,EAAA;QACjB,MAAM,YAAY,GAAG,2BAA2B,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC;QAEpF,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE;AAC5C,YAAA,OAAO,UAAU,CAAC,CAAA;aACX,YAAY,CAAA;AAC8E,sGAAA,CAAA,CAAC,CAAC;SACpG;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,CAAC;KACH;iIAjBU,qCAAqC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA,EAAA;AAArC,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;AAEX,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;;2FAEX,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA,CAAA;;;ACrBD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver-testing.mjs","sources":["../../../libs/external-router/driver/testing/src/config.ts","../../../libs/external-router/driver/testing/src/testing.service.ts","../../../libs/external-router/driver/testing/src/testing.module.ts","../../../libs/external-router/driver/testing/src/provider.ts","../../../libs/external-router/driver/testing/src/public_api.ts","../../../libs/external-router/driver/testing/src/daffodil-external-router-driver-testing.ts"],"sourcesContent":["import { createConfigInjectionToken } from '@daffodil/core';\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouteType,\n} from '@daffodil/external-router';\n\n/**\n * The configuration for the testing driver. It is a dictionary of \"url\": \"type\",\n * pairs, where the URL is a URL-safe routeable path, e.g. \"sweatshirts\" or \"t-shirts\"\n * and the type is a known type to your application, e.g. \"CATEGORY\".\n */\nexport interface DaffExternalRouterDriverTestingConfig {\n [url: string]: DaffExternalRouteType | DaffExternallyResolvableUrl;\n}\n\nexport const {\n /**\n * The token used by Daffodil to hold the driver's configuration.\n *\n * @docs-private\n */\n token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n /**\n * Provider function for {@link DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG}.\n */\n provider: provideDaffExternalRouterDriverTestingConfig,\n} = createConfigInjectionToken<DaffExternalRouterDriverTestingConfig>(({}), 'DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG');\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\nimport {\n Observable,\n of,\n} from 'rxjs';\n\nimport {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport {\n DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION,\n DaffExternalRouterDriverInterface,\n} from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n} from './config';\n\n/**\n * The DaffExternalRouterTestingDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl in testing environments.\n *\n * @inheritdoc\n *\n * @see {@link DaffExternalRouterTestingDriver}\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterTestingDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n @Inject(DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG)\n private testingConfiguration: DaffExternalRouterDriverTestingConfig = {},\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));\n\n if (!this.testingConfiguration[truncatedUrl]) {\n return of(DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n }\n\n if((typeof this.testingConfiguration[truncatedUrl]) === 'string') {\n return of({\n id: faker.datatype.uuid(),\n url: truncatedUrl,\n type: <string>this.testingConfiguration[truncatedUrl],\n code: 200,\n });\n }\n\n return of(<DaffExternallyResolvableUrl>this.testingConfiguration[truncatedUrl]);\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n provideDaffExternalRouterDriverTestingConfig,\n} from './config';\nimport { DaffExternalRouterTestingDriver } from './testing.service';\n\n/**\n * The `DaffExternalRouterDriverTestingModule` is an importable NgModule that can\n * be used to configure the {@link DaffExternalRouterTestingDriver}.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverTestingModule {\n static forRoot(\n config: DaffExternalRouterDriverTestingConfig,\n ): ModuleWithProviders<DaffExternalRouterDriverTestingModule> {\n return {\n ngModule: DaffExternalRouterDriverTestingModule,\n providers: [\n provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),\n provideDaffExternalRouterDriverTestingConfig(config),\n ],\n };\n }\n}\n","import {\n EnvironmentProviders,\n InjectionToken,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n provideDaffExternalRouterDriverTestingConfig,\n} from './config';\nimport { DaffExternalRouterTestingDriver } from './testing.service';\n\n/**\n * Provides a testing implementation of {@link DaffExternalRouterDriver}\n */\nexport const provideDaffExternalRouterTestingDriver = (config:\n DaffExternalRouterDriverTestingConfig | InjectionToken<DaffExternalRouterDriverTestingConfig>,\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),\n provideDaffExternalRouterDriverTestingConfig(config),\n]);\n","/*\n * Public API Surface of @daffodil/external-router/driver/testing\n */\n\nexport { DaffExternalRouterTestingDriver } from './testing.service';\nexport { DaffExternalRouterDriverTestingModule } from './testing.module';\n\nexport { DaffExternalRouterDriverTestingConfig } from './config';\nexport { provideDaffExternalRouterTestingDriver } from './provider';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAeO,MAAM;AACX;;;;AAIG;AACH,KAAK,EAAE,0CAA0C;AACjD;;AAEG;AACH,QAAQ,EAAE,4CAA4C,GACvD,GAAG,0BAA0B,EAAyC,EAAE,GAAG,4CAA4C,CAAC;;ACDzH;;;;;;;AAOG;MAIU,+BAA+B,CAAA;AAE1C,IAAA,WAAA,CAEU,uBAA8D,EAAE,EAAA;QAAhE,IAAoB,CAAA,oBAAA,GAApB,oBAAoB,CAA4C;KACtE;AAEJ,IAAA,OAAO,CAAC,GAAW,EAAA;QACjB,MAAM,YAAY,GAAG,2BAA2B,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC;QAEpF,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE;AAC5C,YAAA,OAAO,EAAE,CAAC,yCAAyC,CAAC,CAAC;SACtD;AAED,QAAA,IAAG,CAAC,OAAO,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,MAAM,QAAQ,EAAE;AAChE,YAAA,OAAO,EAAE,CAAC;AACR,gBAAA,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE;AACzB,gBAAA,GAAG,EAAE,YAAY;AACjB,gBAAA,IAAI,EAAU,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC;AACrD,gBAAA,IAAI,EAAE,GAAG;AACV,aAAA,CAAC,CAAC;SACJ;QAED,OAAO,EAAE,CAA8B,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC,CAAC;KACjF;AAxBU,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA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AAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;;2FAEX,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA,CAAA;;;ACPD;;AAEG;AACU,MAAA,sCAAsC,GAAG,CAAC,MACyC,KACrE,wBAAwB,CAAC;IAClD,+BAA+B,CAAC,+BAA+B,CAAC;IAChE,4CAA4C,CAAC,MAAM,CAAC;AACrD,CAAA;;ACtBD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,9 +1,14 @@
1
- import { InjectionToken } from '@angular/core';
1
+ import { createSingletonInjectionToken } from '@daffodil/core';
2
2
 
3
+ const {
3
4
  /**
4
5
  * The token for the `@daffodil/external-router` driver.
5
6
  */
6
- const DaffExternalRouterDriver = new InjectionToken('DaffExternalRouterDriver');
7
+ token: DaffExternalRouterDriver,
8
+ /**
9
+ * Provider function for {@link DaffExternalRouterDriver}.
10
+ */
11
+ provider: provideDaffExternalRouterDriver, } = createSingletonInjectionToken('DaffExternalRouterDriver');
7
12
 
8
13
  /**
9
14
  * When a driver fails to find a resolution, it should return a 404.
@@ -26,5 +31,5 @@ const DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION = {
26
31
  * Generated bundle index. Do not edit.
27
32
  */
28
33
 
29
- export { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver };
34
+ export { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver, provideDaffExternalRouterDriver };
30
35
  //# sourceMappingURL=daffodil-external-router-driver.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver.mjs","sources":["../../../libs/external-router/driver/src/interfaces/external-router-driver.interface.ts","../../../libs/external-router/driver/src/not-found-resolution.ts","../../../libs/external-router/driver/src/public_api.ts","../../../libs/external-router/driver/src/daffodil-external-router-driver.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n/**\n * The token for the `@daffodil/external-router` driver.\n */\nexport const DaffExternalRouterDriver = new InjectionToken<\n DaffExternalRouterDriverInterface\n>('DaffExternalRouterDriver');\n\n/**\n * The interface for a @daffodil/external-router driver.\n *\n * This driver is responsible for translating a URL into a Route consumable by\n * Daffodil.\n */\nexport interface DaffExternalRouterDriverInterface {\n /**\n * Resolves a URL with a platform.\n * Returns information about the type of URL.\n *\n * @param url The full URL path qualified with file extension and leading slash but without domain. i.e. /full/path/to/thing.html\n */\n resolve(url: string): Observable<DaffExternallyResolvableUrl>;\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n/**\n * When a driver fails to find a resolution, it should return a 404.\n * This const represents the standard \"Not Found\" resolution that a driver\n * should return. Drivers are not required to return this value, but may do so\n * if they would like.\n */\nexport const DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION: DaffExternallyResolvableUrl = {\n id: null,\n url: null,\n code: 404,\n type: null,\n};\n","/*\n * Public API Surface of @daffodil/external-router/driver\n */\n\nexport {\n DaffExternalRouterDriverInterface,\n DaffExternalRouterDriver,\n} from './interfaces/external-router-driver.interface';\nexport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from './not-found-resolution';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAKA;;AAEG;MACU,wBAAwB,GAAG,IAAI,cAAc,CAExD,0BAA0B;;ACR5B;;;;;AAKG;AACU,MAAA,yCAAyC,GAAgC;AACpF,IAAA,EAAE,EAAE,IAAI;AACR,IAAA,GAAG,EAAE,IAAI;AACT,IAAA,IAAI,EAAE,GAAG;AACT,IAAA,IAAI,EAAE,IAAI;;;ACZZ;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver.mjs","sources":["../../../libs/external-router/driver/src/interfaces/external-router-driver.interface.ts","../../../libs/external-router/driver/src/not-found-resolution.ts","../../../libs/external-router/driver/src/public_api.ts","../../../libs/external-router/driver/src/daffodil-external-router-driver.ts"],"sourcesContent":["import { Observable } from 'rxjs';\n\nimport { createSingletonInjectionToken } from '@daffodil/core';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nexport const {\n /**\n * The token for the `@daffodil/external-router` driver.\n */\n token: DaffExternalRouterDriver,\n /**\n * Provider function for {@link DaffExternalRouterDriver}.\n */\n provider: provideDaffExternalRouterDriver,\n} = createSingletonInjectionToken<DaffExternalRouterDriverInterface>('DaffExternalRouterDriver');\n\n/**\n * The interface for a `@daffodil/external-router` driver.\n *\n * This driver is responsible for translating a URL into a Route consumable by\n * Daffodil.\n */\nexport interface DaffExternalRouterDriverInterface {\n /**\n * Resolves a URL with a platform.\n * Returns information about the type of URL.\n *\n * @param url The full URL path qualified with file extension and leading slash but without domain. i.e. /full/path/to/thing.html\n */\n resolve(url: string): Observable<DaffExternallyResolvableUrl>;\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n/**\n * When a driver fails to find a resolution, it should return a 404.\n * This const represents the standard \"Not Found\" resolution that a driver\n * should return. Drivers are not required to return this value, but may do so\n * if they would like.\n */\nexport const DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION: DaffExternallyResolvableUrl = {\n id: null,\n url: null,\n code: 404,\n type: null,\n};\n","/*\n * Public API Surface of @daffodil/external-router/driver\n */\n\nexport {\n DaffExternalRouterDriverInterface,\n DaffExternalRouterDriver,\n provideDaffExternalRouterDriver,\n} from './interfaces/external-router-driver.interface';\nexport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from './not-found-resolution';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAKa,MAAA;AACX;;AAEG;AACH,KAAK,EAAE,wBAAwB;AAC/B;;AAEG;AACH,QAAQ,EAAE,+BAA+B,GAC1C,GAAG,6BAA6B,CAAoC,0BAA0B;;ACZ/F;;;;;AAKG;AACU,MAAA,yCAAyC,GAAgC;AACpF,IAAA,EAAE,EAAE,IAAI;AACR,IAAA,GAAG,EAAE,IAAI;AACT,IAAA,IAAI,EAAE,GAAG;AACT,IAAA,IAAI,EAAE,IAAI;;;ACZZ;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,10 +1,6 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, Inject } from '@angular/core';
3
- import * as i2 from '@angular/router';
4
- import { of } from 'rxjs';
5
- import { map, switchMap, catchError } from 'rxjs/operators';
6
- import * as i3 from '@daffodil/core/routing';
7
- import * as i1 from '@daffodil/external-router';
1
+ import { inject } from '@angular/core';
2
+ import { Router } from '@angular/router';
3
+ import { map, tap, catchError, of } from 'rxjs';
8
4
  import { DAFF_EXTERNAL_ROUTER_CONFIG } from '@daffodil/external-router';
9
5
  import { DaffExternalRouterDriver } from '@daffodil/external-router/driver';
10
6
  import { DaffInheritableError } from '@daffodil/core';
@@ -53,6 +49,13 @@ class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError {
53
49
  }
54
50
  }
55
51
 
52
+ /**
53
+ * Converts a UrlSegment into its complete Url.
54
+ *
55
+ * @docs-private
56
+ */
57
+ const daffConvertToPath = (segments) => segments.map(seg => seg.path).join('/');
58
+
56
59
  /**
57
60
  * An error thrown when the platform performing url resolution fails.
58
61
  */
@@ -99,65 +102,36 @@ const processRedirects = (url) => {
99
102
  };
100
103
 
101
104
  /**
102
- * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route
103
- * of an Angular App and either navigating to a resolved route upon successful resolution
104
- * or navigating to the configured route upon a failed resolution.
105
+ * A `canMatch` guard function that will resolve a route externally, allowing Angular to match it.
106
+ *
107
+ * Depending on the resolution result, the route's data will contain `daffSeoData` with supplemental search engine data
108
+ * about the route. The data on the route is cumulative. If other data properties are set, they will be merged alongside daffSeoData.
105
109
  */
106
- class DaffExternalRouterExistenceGuard {
107
- constructor(driver, externalRouter, router, config, urlNormalizer) {
108
- this.driver = driver;
109
- this.externalRouter = externalRouter;
110
- this.router = router;
111
- this.config = config;
112
- this.urlNormalizer = urlNormalizer;
113
- }
114
- canActivate(next, state) {
115
- return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(map((resolvedRoute) => processErrors(resolvedRoute)), switchMap(resolvedRoute => {
116
- this.externalRouter.add(resolvedRoute);
117
- return of(resolvedRoute);
118
- }), map((resolvedRoute) => processRedirects(resolvedRoute)),
119
- // Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.
120
- // When we succeed, redirect to the new route, as config has changed since we init'd.
121
- map(() => this.router.parseUrl(state.url)),
122
- // When we fail, we need to process errors as dictated by the error type.
123
- // Handle redirects
124
- catchError(error => {
125
- if (!(error instanceof DaffExternalRouterPermanentRedirectError) &&
126
- !(error instanceof DaffExternalRouterTemporaryRedirectError)) {
127
- throw error;
128
- }
129
- return of(this.router.parseUrl(error.redirectUrl));
130
- }),
131
- // Handle "404"
132
- catchError((error) => {
133
- if (!(error instanceof DaffExternalRouterNotFoundError)) {
134
- throw error;
135
- }
136
- return of(this.router.parseUrl(this.config.notFoundResolutionPath));
137
- }),
138
- //Otherwise something went horribly wrong and we need to bail out.
139
- catchError((error) => {
140
- //TODO(damienwebdev): Add a logging system.
141
- //This log is intentional until we have a better logging system in place.
142
- console.log(error);
143
- return of(this.router.parseUrl(this.config.failedResolutionPath));
144
- }));
145
- }
146
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterExistenceGuard, deps: [{ token: DaffExternalRouterDriver }, { token: i1.DaffExternalRouter }, { token: i2.Router }, { token: DAFF_EXTERNAL_ROUTER_CONFIG }, { token: i3.DaffRoutingUriNormalizer }], target: i0.ɵɵFactoryTarget.Injectable }); }
147
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterExistenceGuard, providedIn: 'root' }); }
148
- }
149
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterExistenceGuard, decorators: [{
150
- type: Injectable,
151
- args: [{
152
- providedIn: 'root',
153
- }]
154
- }], ctorParameters: () => [{ type: undefined, decorators: [{
155
- type: Inject,
156
- args: [DaffExternalRouterDriver]
157
- }] }, { type: i1.DaffExternalRouter }, { type: i2.Router }, { type: undefined, decorators: [{
158
- type: Inject,
159
- args: [DAFF_EXTERNAL_ROUTER_CONFIG]
160
- }] }, { type: i3.DaffRoutingUriNormalizer }] });
110
+ const daffExternalMatcherTypeGuard = (type) => (route, segments) => {
111
+ const router = inject(Router);
112
+ const config = inject(DAFF_EXTERNAL_ROUTER_CONFIG);
113
+ return inject(DaffExternalRouterDriver).resolve(daffConvertToPath(segments)).pipe(map(processErrors), map(processRedirects), map((r) => ({ result: r, isMatch: type === r.type })), tap((r) => {
114
+ if (r.isMatch) {
115
+ route.title = r.result.data?.title ?? route.data?.daffSeoData?.title ?? route.title;
116
+ route.data = { ...route.data, daffSeoData: r.result.data };
117
+ }
118
+ }), map((res) => res.isMatch), catchError(error => {
119
+ if (!(error instanceof DaffExternalRouterPermanentRedirectError) &&
120
+ !(error instanceof DaffExternalRouterTemporaryRedirectError)) {
121
+ throw error;
122
+ }
123
+ return of(router.parseUrl(error.redirectUrl));
124
+ }),
125
+ // Handle "404"
126
+ catchError((error) => {
127
+ if (!(error instanceof DaffExternalRouterNotFoundError)) {
128
+ throw error;
129
+ }
130
+ return of(false);
131
+ }),
132
+ //Otherwise something went horribly wrong and we need to bail out.
133
+ catchError((error) => of(router.parseUrl(config.failedResolutionPath))), catchError(() => of(false)));
134
+ };
161
135
 
162
136
  /*
163
137
  * Public API Surface of @daffodil/external-router/routing
@@ -167,5 +141,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
167
141
  * Generated bundle index. Do not edit.
168
142
  */
169
143
 
170
- export { DaffExternalRouterExistenceGuard };
144
+ export { daffExternalMatcherTypeGuard };
171
145
  //# sourceMappingURL=daffodil-external-router-routing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-routing.mjs","sources":["../../../libs/external-router/routing/src/errors/client-error.ts","../../../libs/external-router/routing/src/errors/not-found-error.ts","../../../libs/external-router/routing/src/errors/permanent-redirect.ts","../../../libs/external-router/routing/src/errors/temporary-redirect.ts","../../../libs/external-router/routing/src/errors/server-error.ts","../../../libs/external-router/routing/src/processors/process-errors.ts","../../../libs/external-router/routing/src/processors/process-redirect.ts","../../../libs/external-router/routing/src/guard/existence.guard.ts","../../../libs/external-router/routing/src/public_api.ts","../../../libs/external-router/routing/src/daffodil-external-router-routing.ts"],"sourcesContent":["import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver encounters a 4xx error.\n */\nexport class DaffExternalRouterClientError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '4xx_CLIENT_ERROR';\n\n constructor(message?: string) {\n super(message);\n }\n}\n","import { DaffError } from '@daffodil/core';\n\nimport { DaffExternalRouterClientError } from './client-error';\n\n/**\n * An error thrown when the driver determines that a given url is not resolvable.\n */\nexport class DaffExternalRouterNotFoundError extends DaffExternalRouterClientError\n implements DaffError {\n public readonly code: string = '404_NOT_FOUND';\n\n constructor(message?: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver determines that the url needs to be routed somewhere\n * else permanently.\n */\nexport class DaffExternalRouterPermanentRedirectError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '302_PERMANENT_REDIRECT';\n\n constructor(public redirectUrl: string, message?: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver needs a URI to be temporarily redirected\n * to another location.\n */\nexport class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = 'TEMPORARY_REDIRECT';\n\n constructor(public redirectUrl: string, message?: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the platform performing url resolution fails.\n */\nexport class DaffExternalRouterServerError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '5xx_SERVER_ERROR';\n\n constructor(message?: string) {\n super(message);\n }\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n\nimport { DaffExternalRouterClientError } from '../errors/client-error';\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterServerError } from '../errors/server-error';\n\n/**\n * Processes resolved URLs and throws the appropriate error so that External Router\n * can handle routing errors.\n */\nexport const processErrors = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 404 ){\n throw new DaffExternalRouterNotFoundError();\n } else if(url.code >= 400 && url.code < 500) {\n throw new DaffExternalRouterClientError();\n } else if(url.code >= 500) {\n throw new DaffExternalRouterServerError();\n } else {\n return url;\n }\n};\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\n\n/**\n * Processes resolvedUrls and throws the appropriate error so that External Router\n * can handle redirects.\n */\nexport const processRedirects = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 301){\n throw new DaffExternalRouterPermanentRedirectError(url.url);\n } else if(url.code === 302) {\n throw new DaffExternalRouterTemporaryRedirectError(url.url);\n } else {\n return url;\n }\n};\n","import { isPlatformServer } from '@angular/common';\nimport {\n Injectable,\n Inject,\n PLATFORM_ID,\n} from '@angular/core';\nimport {\n ActivatedRouteSnapshot,\n Router,\n RouterStateSnapshot,\n UrlTree,\n} from '@angular/router';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n switchMap,\n} from 'rxjs/operators';\n\nimport { DaffRoutingUriNormalizer } from '@daffodil/core/routing';\nimport {\n DaffExternalRouter,\n DaffExternalRouterConfiguration,\n DAFF_EXTERNAL_ROUTER_CONFIG,\n DaffExternallyResolvableUrl,\n} from '@daffodil/external-router';\nimport {\n DaffExternalRouterDriverInterface,\n DaffExternalRouterDriver,\n} from '@daffodil/external-router/driver';\n\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\nimport { processErrors } from '../processors/process-errors';\nimport { processRedirects } from '../processors/process-redirect';\n\n/**\n * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route\n * of an Angular App and either navigating to a resolved route upon successful resolution\n * or navigating to the configured route upon a failed resolution.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterExistenceGuard {\n constructor(\n @Inject(DaffExternalRouterDriver)\n private driver: DaffExternalRouterDriverInterface,\n private externalRouter: DaffExternalRouter,\n private router: Router,\n @Inject(DAFF_EXTERNAL_ROUTER_CONFIG)\n private config: DaffExternalRouterConfiguration,\n private urlNormalizer: DaffRoutingUriNormalizer,\n ) { }\n\n canActivate(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Observable<UrlTree | boolean> {\n return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(\n map((resolvedRoute: DaffExternallyResolvableUrl) => processErrors(resolvedRoute)),\n switchMap(resolvedRoute => {\n this.externalRouter.add(resolvedRoute);\n return of(resolvedRoute);\n }),\n map((resolvedRoute: DaffExternallyResolvableUrl) => processRedirects(resolvedRoute)),\n // Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.\n // When we succeed, redirect to the new route, as config has changed since we init'd.\n map(() => this.router.parseUrl(state.url)),\n // When we fail, we need to process errors as dictated by the error type.\n // Handle redirects\n catchError(error => {\n if (\n !(error instanceof DaffExternalRouterPermanentRedirectError) &&\n !(error instanceof DaffExternalRouterTemporaryRedirectError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(error.redirectUrl));\n }),\n // Handle \"404\"\n catchError((error) => {\n if (!(error instanceof DaffExternalRouterNotFoundError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(this.config.notFoundResolutionPath));\n }),\n\n //Otherwise something went horribly wrong and we need to bail out.\n catchError((error) => {\n //TODO(damienwebdev): Add a logging system.\n //This log is intentional until we have a better logging system in place.\n console.log(error);\n return of(this.router.parseUrl(this.config.failedResolutionPath));\n }),\n );\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/routing\n */\nexport { DaffExternalRouterExistenceGuard } from './guard/existence.guard';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAKA;;AAEG;AACG,MAAO,6BAA8B,SAAQ,oBAAoB,CAAA;AAIrE,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHD,IAAI,CAAA,IAAA,GAAW,kBAAkB,CAAC;KAIjD;AACF;;ACXD;;AAEG;AACG,MAAO,+BAAgC,SAAQ,6BAA6B,CAAA;AAIhF,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHD,IAAI,CAAA,IAAA,GAAW,eAAe,CAAC;KAI9C;AACF;;ACTD;;;AAGG;AACG,MAAO,wCAAyC,SAAQ,oBAAoB,CAAA;IAIhF,WAAmB,CAAA,WAAmB,EAAE,OAAgB,EAAA;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,IAAW,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,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;0BAGI,MAAM;2BAAC,wBAAwB,CAAA;;0BAI/B,MAAM;2BAAC,2BAA2B,CAAA;;;ACtDvC;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-routing.mjs","sources":["../../../libs/external-router/routing/src/errors/client-error.ts","../../../libs/external-router/routing/src/errors/not-found-error.ts","../../../libs/external-router/routing/src/errors/permanent-redirect.ts","../../../libs/external-router/routing/src/errors/temporary-redirect.ts","../../../libs/external-router/routing/src/helper/convert-to-path.ts","../../../libs/external-router/routing/src/errors/server-error.ts","../../../libs/external-router/routing/src/processors/process-errors.ts","../../../libs/external-router/routing/src/processors/process-redirect.ts","../../../libs/external-router/routing/src/guard/external-matcher-type.guard.ts","../../../libs/external-router/routing/src/public_api.ts","../../../libs/external-router/routing/src/daffodil-external-router-routing.ts"],"sourcesContent":["import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver encounters a 4xx error.\n */\nexport class DaffExternalRouterClientError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '4xx_CLIENT_ERROR';\n\n constructor(message?: string) {\n super(message);\n }\n}\n","import { DaffError } from '@daffodil/core';\n\nimport { DaffExternalRouterClientError } from './client-error';\n\n/**\n * An error thrown when the driver determines that a given url is not resolvable.\n */\nexport class DaffExternalRouterNotFoundError extends DaffExternalRouterClientError\n implements DaffError {\n public readonly code: string = '404_NOT_FOUND';\n\n constructor(message?: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver determines that the url needs to be routed somewhere\n * else permanently.\n */\nexport class DaffExternalRouterPermanentRedirectError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '302_PERMANENT_REDIRECT';\n\n constructor(public redirectUrl: string, message?: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver needs a URI to be temporarily redirected\n * to another location.\n */\nexport class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = 'TEMPORARY_REDIRECT';\n\n constructor(public redirectUrl: string, message?: string) {\n super(message);\n }\n}\n","import { UrlSegment } from '@angular/router';\n\n/**\n * Converts a UrlSegment into its complete Url.\n *\n * @docs-private\n */\nexport const daffConvertToPath = (segments: UrlSegment[]) => segments.map(seg => seg.path).join('/');\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the platform performing url resolution fails.\n */\nexport class DaffExternalRouterServerError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '5xx_SERVER_ERROR';\n\n constructor(message?: string) {\n super(message);\n }\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n\nimport { DaffExternalRouterClientError } from '../errors/client-error';\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterServerError } from '../errors/server-error';\n\n/**\n * Processes resolved URLs and throws the appropriate error so that External Router\n * can handle routing errors.\n */\nexport const processErrors = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 404 ){\n throw new DaffExternalRouterNotFoundError();\n } else if(url.code >= 400 && url.code < 500) {\n throw new DaffExternalRouterClientError();\n } else if(url.code >= 500) {\n throw new DaffExternalRouterServerError();\n } else {\n return url;\n }\n};\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\n\n/**\n * Processes resolvedUrls and throws the appropriate error so that External Router\n * can handle redirects.\n */\nexport const processRedirects = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 301){\n throw new DaffExternalRouterPermanentRedirectError(url.url);\n } else if(url.code === 302) {\n throw new DaffExternalRouterTemporaryRedirectError(url.url);\n } else {\n return url;\n }\n};\n","import { inject } from '@angular/core';\nimport {\n CanMatchFn,\n Router,\n UrlSegment,\n UrlTree,\n} from '@angular/router';\nimport {\n Observable,\n catchError,\n map,\n of,\n tap,\n} from 'rxjs';\n\nimport {\n DAFF_EXTERNAL_ROUTER_CONFIG,\n DaffExternalRouterConfiguration,\n DaffExternallyResolvableUrl,\n DaffRouteWithSeoData,\n} from '@daffodil/external-router';\nimport { DaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\nimport { daffConvertToPath } from '../helper/convert-to-path';\nimport { processErrors } from '../processors/process-errors';\nimport { processRedirects } from '../processors/process-redirect';\n\n/**\n * A `canMatch` guard function that will resolve a route externally, allowing Angular to match it.\n *\n * Depending on the resolution result, the route's data will contain `daffSeoData` with supplemental search engine data\n * about the route. The data on the route is cumulative. If other data properties are set, they will be merged alongside daffSeoData.\n */\nexport const daffExternalMatcherTypeGuard = (type: string) => (route: DaffRouteWithSeoData, segments: Array<UrlSegment>): Observable<boolean | UrlTree> => {\n const router = inject(Router);\n const config: DaffExternalRouterConfiguration = inject(DAFF_EXTERNAL_ROUTER_CONFIG);\n return inject(DaffExternalRouterDriver).resolve(daffConvertToPath(segments)).pipe(\n map(processErrors),\n map(processRedirects),\n map((r) => ({ result: r, isMatch: type === r.type })),\n tap((r) => {\n if(r.isMatch) {\n route.title = r.result.data?.title ?? route.data?.daffSeoData?.title ?? route.title;\n route.data = { ...route.data, daffSeoData: r.result.data };\n }\n }),\n map((res) => res.isMatch),\n catchError(error => {\n if (\n !(error instanceof DaffExternalRouterPermanentRedirectError) &&\n !(error instanceof DaffExternalRouterTemporaryRedirectError)) {\n throw error;\n }\n\n return of(router.parseUrl(error.redirectUrl));\n }),\n // Handle \"404\"\n catchError((error) => {\n if (!(error instanceof DaffExternalRouterNotFoundError)) {\n throw error;\n }\n\n return of(false);\n }),\n //Otherwise something went horribly wrong and we need to bail out.\n catchError((error) => of(router.parseUrl(config.failedResolutionPath))),\n catchError(() => of(false)),\n );\n};\n\n\n","/*\n * Public API Surface of @daffodil/external-router/routing\n */\nexport { daffExternalMatcherTypeGuard } from './guard/external-matcher-type.guard';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAKA;;AAEG;AACG,MAAO,6BAA8B,SAAQ,oBAAoB,CAAA;AAIrE,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHD,IAAI,CAAA,IAAA,GAAW,kBAAkB,CAAC;KAIjD;AACF;;ACXD;;AAEG;AACG,MAAO,+BAAgC,SAAQ,6BAA6B,CAAA;AAIhF,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHD,IAAI,CAAA,IAAA,GAAW,eAAe,CAAC;KAI9C;AACF;;ACTD;;;AAGG;AACG,MAAO,wCAAyC,SAAQ,oBAAoB,CAAA;IAIhF,WAAmB,CAAA,WAAmB,EAAE,OAAgB,EAAA;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,IAAW,CAAA,WAAA,GAAX,WAAW,CAAQ;QAFtB,IAAI,CAAA,IAAA,GAAW,wBAAwB,CAAC;KAIvD;AACF;;ACXD;;;AAGG;AACG,MAAO,wCAAyC,SAAQ,oBAAoB,CAAA;IAIhF,WAAmB,CAAA,WAAmB,EAAE,OAAgB,EAAA;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,IAAW,CAAA,WAAA,GAAX,WAAW,CAAQ;QAFtB,IAAI,CAAA,IAAA,GAAW,oBAAoB,CAAC;KAInD;AACF;;ACdD;;;;AAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,QAAsB,KAAK,QAAQ,CAAC,GAAG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