@daffodil/external-router 0.38.9 → 0.39.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. package/bundles/daffodil-external-router-driver-in-memory.umd.js +100 -0
  2. package/bundles/daffodil-external-router-driver-in-memory.umd.js.map +1 -0
  3. package/bundles/daffodil-external-router-driver-in-memory.umd.min.js +2 -0
  4. package/bundles/daffodil-external-router-driver-in-memory.umd.min.js.map +1 -0
  5. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.js +11 -63
  6. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.js.map +1 -1
  7. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.min.js +1 -1
  8. package/bundles/daffodil-external-router-driver-magento-2.4.1.umd.min.js.map +1 -1
  9. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.js +11 -63
  10. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.js.map +1 -1
  11. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.min.js +1 -1
  12. package/bundles/daffodil-external-router-driver-magento-2.4.2.umd.min.js.map +1 -1
  13. package/bundles/daffodil-external-router-driver-magento.umd.js +9 -47
  14. package/bundles/daffodil-external-router-driver-magento.umd.js.map +1 -1
  15. package/bundles/daffodil-external-router-driver-magento.umd.min.js +1 -1
  16. package/bundles/daffodil-external-router-driver-magento.umd.min.js.map +1 -1
  17. package/bundles/daffodil-external-router-driver-testing.umd.js +9 -63
  18. package/bundles/daffodil-external-router-driver-testing.umd.js.map +1 -1
  19. package/bundles/daffodil-external-router-driver-testing.umd.min.js +1 -1
  20. package/bundles/daffodil-external-router-driver-testing.umd.min.js.map +1 -1
  21. package/bundles/daffodil-external-router-driver.umd.js +4 -44
  22. package/bundles/daffodil-external-router-driver.umd.js.map +1 -1
  23. package/bundles/daffodil-external-router-routing.umd.js +18 -157
  24. package/bundles/daffodil-external-router-routing.umd.js.map +1 -1
  25. package/bundles/daffodil-external-router-routing.umd.min.js +1 -1
  26. package/bundles/daffodil-external-router-routing.umd.min.js.map +1 -1
  27. package/bundles/daffodil-external-router.umd.js +35 -204
  28. package/bundles/daffodil-external-router.umd.js.map +1 -1
  29. package/bundles/daffodil-external-router.umd.min.js +2 -2
  30. package/bundles/daffodil-external-router.umd.min.js.map +1 -1
  31. package/driver/in-memory/config.d.ts +20 -0
  32. package/driver/in-memory/daffodil-external-router-driver-in-memory.d.ts +5 -0
  33. package/driver/in-memory/daffodil-external-router-driver-in-memory.metadata.json +1 -0
  34. package/driver/in-memory/in-memory.module.d.ts +9 -0
  35. package/driver/in-memory/in-memory.service.d.ts +17 -0
  36. package/driver/in-memory/index.d.ts +1 -0
  37. package/driver/in-memory/package.json +11 -0
  38. package/driver/in-memory/public_api.d.ts +3 -0
  39. package/driver/magento/2.4.1/package.json +1 -1
  40. package/driver/magento/2.4.2/package.json +1 -1
  41. package/driver/magento/package.json +1 -1
  42. package/driver/package.json +1 -1
  43. package/driver/testing/package.json +1 -1
  44. package/esm2015/config.js +3 -30
  45. package/esm2015/daffodil-external-router.js +2 -7
  46. package/esm2015/driver/daffodil-external-router-driver.js +2 -7
  47. package/esm2015/driver/in-memory/config.js +17 -0
  48. package/esm2015/driver/in-memory/daffodil-external-router-driver-in-memory.js +6 -0
  49. package/esm2015/driver/in-memory/in-memory.module.js +36 -0
  50. package/esm2015/driver/in-memory/in-memory.service.js +36 -0
  51. package/esm2015/driver/in-memory/index.js +2 -0
  52. package/esm2015/driver/in-memory/public_api.js +6 -0
  53. package/esm2015/driver/index.js +2 -7
  54. package/esm2015/driver/interfaces/external-router-driver.interface.js +2 -26
  55. package/esm2015/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.js +2 -7
  56. package/esm2015/driver/magento/2.4.1/graphql/queries/resolve-url-v2.4.1.js +1 -8
  57. package/esm2015/driver/magento/2.4.1/index.js +2 -7
  58. package/esm2015/driver/magento/2.4.1/magento.module.js +3 -9
  59. package/esm2015/driver/magento/2.4.1/magento.service.js +4 -27
  60. package/esm2015/driver/magento/2.4.1/public_api.js +1 -6
  61. package/esm2015/driver/magento/2.4.1/transforms/resolution-to-resolvable-url.js +3 -13
  62. package/esm2015/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.js +2 -7
  63. package/esm2015/driver/magento/2.4.2/graphql/queries/resolve-url-v2.4.2.js +1 -8
  64. package/esm2015/driver/magento/2.4.2/index.js +2 -7
  65. package/esm2015/driver/magento/2.4.2/magento.module.js +3 -9
  66. package/esm2015/driver/magento/2.4.2/magento.service.js +4 -27
  67. package/esm2015/driver/magento/2.4.2/public_api.js +1 -6
  68. package/esm2015/driver/magento/2.4.2/transforms/resolution-to-resolvable-url.js +3 -13
  69. package/esm2015/driver/magento/daffodil-external-router-driver-magento.js +2 -7
  70. package/esm2015/driver/magento/index.js +2 -7
  71. package/esm2015/driver/magento/model/public_api.js +1 -6
  72. package/esm2015/driver/magento/model/resolution-types.js +7 -13
  73. package/esm2015/driver/magento/model/url-resolver-response.js +2 -14
  74. package/esm2015/driver/magento/model/url-resolver.js +2 -28
  75. package/esm2015/driver/magento/public_api.js +3 -8
  76. package/esm2015/driver/magento/transforms/public_api.js +1 -6
  77. package/esm2015/driver/magento/transforms/redirect-to-http.js +2 -12
  78. package/esm2015/driver/not-found-resolution.js +1 -7
  79. package/esm2015/driver/public_api.js +1 -6
  80. package/esm2015/driver/testing/config.js +3 -19
  81. package/esm2015/driver/testing/daffodil-external-router-driver-testing.js +2 -7
  82. package/esm2015/driver/testing/index.js +2 -7
  83. package/esm2015/driver/testing/public_api.js +1 -6
  84. package/esm2015/driver/testing/testing.module.js +2 -11
  85. package/esm2015/driver/testing/testing.service.js +4 -24
  86. package/esm2015/errors/no-wildcard.js +1 -13
  87. package/esm2015/errors/unknown-type.js +1 -13
  88. package/esm2015/external-router.module.js +2 -12
  89. package/esm2015/model/insertion-strategy.type.js +2 -6
  90. package/esm2015/model/public_api.js +2 -6
  91. package/esm2015/model/resolvable-route.js +2 -36
  92. package/esm2015/model/route-info.js +2 -17
  93. package/esm2015/model/route-type.js +2 -6
  94. package/esm2015/model/route-with-data-path.js +2 -6
  95. package/esm2015/model/route-without-path.js +2 -6
  96. package/esm2015/model/type-route-pair.js +2 -34
  97. package/esm2015/public_api.js +2 -7
  98. package/esm2015/router/router.service.js +2 -25
  99. package/esm2015/router/strategies/insert-data-path.js +13 -59
  100. package/esm2015/router/strategies/insert-route-before-wildcard.js +4 -20
  101. package/esm2015/router/url-matcher/data-path-matcher.js +6 -25
  102. package/esm2015/routing/daffodil-external-router-routing.js +2 -7
  103. package/esm2015/routing/errors/client-error.js +1 -13
  104. package/esm2015/routing/errors/not-found-error.js +1 -13
  105. package/esm2015/routing/errors/permanent-redirect.js +1 -16
  106. package/esm2015/routing/errors/server-error.js +1 -13
  107. package/esm2015/routing/errors/temporary-redirect.js +1 -16
  108. package/esm2015/routing/guard/existence.guard.js +11 -82
  109. package/esm2015/routing/index.js +2 -7
  110. package/esm2015/routing/processors/process-errors.js +3 -13
  111. package/esm2015/routing/processors/process-redirect.js +3 -13
  112. package/esm2015/routing/public_api.js +1 -6
  113. package/esm2015/token/type-resolvable-routes.token.js +4 -21
  114. package/esm2015/transform/resolved-route-to-route.js +4 -20
  115. package/fesm2015/daffodil-external-router-driver-in-memory.js +90 -0
  116. package/fesm2015/daffodil-external-router-driver-in-memory.js.map +1 -0
  117. package/fesm2015/daffodil-external-router-driver-magento-2.4.1.js +11 -67
  118. package/fesm2015/daffodil-external-router-driver-magento-2.4.1.js.map +1 -1
  119. package/fesm2015/daffodil-external-router-driver-magento-2.4.2.js +11 -67
  120. package/fesm2015/daffodil-external-router-driver-magento-2.4.2.js.map +1 -1
  121. package/fesm2015/daffodil-external-router-driver-magento.js +10 -47
  122. package/fesm2015/daffodil-external-router-driver-magento.js.map +1 -1
  123. package/fesm2015/daffodil-external-router-driver-testing.js +10 -65
  124. package/fesm2015/daffodil-external-router-driver-testing.js.map +1 -1
  125. package/fesm2015/daffodil-external-router-driver.js +4 -44
  126. package/fesm2015/daffodil-external-router-driver.js.map +1 -1
  127. package/fesm2015/daffodil-external-router-routing.js +18 -185
  128. package/fesm2015/daffodil-external-router-routing.js.map +1 -1
  129. package/fesm2015/daffodil-external-router.js +34 -242
  130. package/fesm2015/daffodil-external-router.js.map +1 -1
  131. package/package.json +3 -3
  132. package/routing/package.json +1 -1
@@ -1,45 +1,15 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
 
3
3
  /**
4
- * @fileoverview added by tsickle
5
- * Generated from: interfaces/external-router-driver.interface.ts
6
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7
- */
8
- /**
9
- * The token for the `\@daffodil/external-router` driver.
10
- * @type {?}
4
+ * The token for the `@daffodil/external-router` driver.
11
5
  */
12
6
  const DaffExternalRouterDriver = new InjectionToken('DaffExternalRouterDriver');
13
- /**
14
- * The interface for a \@daffodil/external-router driver.
15
- *
16
- * This driver is responsible for translating a URL into a Route consumable by
17
- * Daffodil.
18
- * @record
19
- */
20
- function DaffExternalRouterDriverInterface() { }
21
- if (false) {
22
- /**
23
- * Resolves a URL with a platform.
24
- * Returns information about the type of URL.
25
- *
26
- * @param {?} url The full URL path qualified with file extension and leading slash but without domain. i.e. /full/path/to/thing.html
27
- * @return {?}
28
- */
29
- DaffExternalRouterDriverInterface.prototype.resolve = function (url) { };
30
- }
31
7
 
32
- /**
33
- * @fileoverview added by tsickle
34
- * Generated from: not-found-resolution.ts
35
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
36
- */
37
8
  /**
38
9
  * When a driver fails to find a resolution, it should return a 404.
39
10
  * This const represents the standard "Not Found" resolution that a driver
40
11
  * should return. Drivers are not required to return this value, but may do so
41
12
  * if they would like.
42
- * @type {?}
43
13
  */
44
14
  const DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION = {
45
15
  id: null,
@@ -48,22 +18,12 @@ const DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION = {
48
18
  type: null,
49
19
  };
50
20
 
51
- /**
52
- * @fileoverview added by tsickle
53
- * Generated from: public_api.ts
54
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
55
- */
56
-
57
- /**
58
- * @fileoverview added by tsickle
59
- * Generated from: index.ts
60
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
21
+ /*
22
+ * Public API Surface of @daffodil/external-router/driver
61
23
  */
62
24
 
63
25
  /**
64
- * @fileoverview added by tsickle
65
- * Generated from: daffodil-external-router-driver.ts
66
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
26
+ * Generated bundle index. Do not edit.
67
27
  */
68
28
 
69
29
  export { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver };
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver.js","sources":["../../../libs/external-router/driver/src/interfaces/external-router-driver.interface.ts","../../../libs/external-router/driver/src/not-found-resolution.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\tDaffExternalRouterDriverInterface\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\tresolve(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"],"names":[],"mappings":";;;;;;;;;;;MAQa,wBAAwB,GAAG,IAAI,cAAc,CAExD,0BAA0B;;;;;;;;gDAgB3B;;;;;;;;;IADA,yEAA8D;;;;;;;;;;;;;;;MCjBlD,yCAAyC,GAAgC;IACpF,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver.js","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\tDaffExternalRouterDriverInterface\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\tresolve(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;;;MAGa,wBAAwB,GAAG,IAAI,cAAc,CAExD,0BAA0B;;ACR5B;;;;;;MAMa,yCAAyC,GAAgC;IACpF,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,IAAI;;;ACZZ;;;;ACAA;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { Injectable, Inject, ɵɵdefineInjectable, ɵɵinject } from '@angular/core';
1
+ import { ɵɵdefineInjectable, ɵɵinject, Injectable, Inject } from '@angular/core';
2
2
  import { Router } from '@angular/router';
3
3
  import { of } from 'rxjs';
4
4
  import { map, switchMap, catchError } from 'rxjs/operators';
@@ -7,141 +7,65 @@ import { DaffExternalRouter, DAFF_EXTERNAL_ROUTER_CONFIG } from '@daffodil/exter
7
7
  import { DaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
8
  import { DaffInheritableError } from '@daffodil/core';
9
9
 
10
- /**
11
- * @fileoverview added by tsickle
12
- * Generated from: errors/client-error.ts
13
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
14
- */
15
10
  /**
16
11
  * An error thrown when the driver encounters a 4xx error.
17
12
  */
18
13
  class DaffExternalRouterClientError extends DaffInheritableError {
19
- /**
20
- * @param {?=} message
21
- */
22
14
  constructor(message) {
23
15
  super(message);
24
16
  this.code = '4xx_CLIENT_ERROR';
25
17
  }
26
18
  }
27
- if (false) {
28
- /** @type {?} */
29
- DaffExternalRouterClientError.prototype.code;
30
- }
31
19
 
32
- /**
33
- * @fileoverview added by tsickle
34
- * Generated from: errors/not-found-error.ts
35
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
36
- */
37
20
  /**
38
21
  * An error thrown when the driver determines that a given url is not resolvable.
39
22
  */
40
23
  class DaffExternalRouterNotFoundError extends DaffExternalRouterClientError {
41
- /**
42
- * @param {?=} message
43
- */
44
24
  constructor(message) {
45
25
  super(message);
46
26
  this.code = '404_NOT_FOUND';
47
27
  }
48
28
  }
49
- if (false) {
50
- /** @type {?} */
51
- DaffExternalRouterNotFoundError.prototype.code;
52
- }
53
29
 
54
- /**
55
- * @fileoverview added by tsickle
56
- * Generated from: errors/permanent-redirect.ts
57
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
58
- */
59
30
  /**
60
31
  * An error thrown when the driver determines that the url needs to be routed somewhere
61
32
  * else permanently.
62
33
  */
63
34
  class DaffExternalRouterPermanentRedirectError extends DaffInheritableError {
64
- /**
65
- * @param {?} redirectUrl
66
- * @param {?=} message
67
- */
68
35
  constructor(redirectUrl, message) {
69
36
  super(message);
70
37
  this.redirectUrl = redirectUrl;
71
38
  this.code = '302_PERMANENT_REDIRECT';
72
39
  }
73
40
  }
74
- if (false) {
75
- /** @type {?} */
76
- DaffExternalRouterPermanentRedirectError.prototype.code;
77
- /** @type {?} */
78
- DaffExternalRouterPermanentRedirectError.prototype.redirectUrl;
79
- }
80
41
 
81
- /**
82
- * @fileoverview added by tsickle
83
- * Generated from: errors/temporary-redirect.ts
84
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
85
- */
86
42
  /**
87
43
  * An error thrown when the driver needs a URI to be temporarily redirected
88
44
  * to another location.
89
45
  */
90
46
  class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError {
91
- /**
92
- * @param {?} redirectUrl
93
- * @param {?=} message
94
- */
95
47
  constructor(redirectUrl, message) {
96
48
  super(message);
97
49
  this.redirectUrl = redirectUrl;
98
50
  this.code = 'TEMPORARY_REDIRECT';
99
51
  }
100
52
  }
101
- if (false) {
102
- /** @type {?} */
103
- DaffExternalRouterTemporaryRedirectError.prototype.code;
104
- /** @type {?} */
105
- DaffExternalRouterTemporaryRedirectError.prototype.redirectUrl;
106
- }
107
53
 
108
- /**
109
- * @fileoverview added by tsickle
110
- * Generated from: errors/server-error.ts
111
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
112
- */
113
54
  /**
114
55
  * An error thrown when the platform performing url resolution fails.
115
56
  */
116
57
  class DaffExternalRouterServerError extends DaffInheritableError {
117
- /**
118
- * @param {?=} message
119
- */
120
58
  constructor(message) {
121
59
  super(message);
122
60
  this.code = '5xx_SERVER_ERROR';
123
61
  }
124
62
  }
125
- if (false) {
126
- /** @type {?} */
127
- DaffExternalRouterServerError.prototype.code;
128
- }
129
63
 
130
- /**
131
- * @fileoverview added by tsickle
132
- * Generated from: processors/process-errors.ts
133
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
134
- */
135
64
  /**
136
65
  * Processes resolved URLs and throws the appropriate error so that External Router
137
66
  * can handle routing errors.
138
- * @type {?}
139
67
  */
140
- const processErrors = (/**
141
- * @param {?} url
142
- * @return {?}
143
- */
144
- (url) => {
68
+ const processErrors = (url) => {
145
69
  if (url.code === 404) {
146
70
  throw new DaffExternalRouterNotFoundError();
147
71
  }
@@ -154,23 +78,13 @@ const processErrors = (/**
154
78
  else {
155
79
  return url;
156
80
  }
157
- });
81
+ };
158
82
 
159
- /**
160
- * @fileoverview added by tsickle
161
- * Generated from: processors/process-redirect.ts
162
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
163
- */
164
83
  /**
165
84
  * Processes resolvedUrls and throws the appropriate error so that External Router
166
85
  * can handle redirects.
167
- * @type {?}
168
- */
169
- const processRedirects = (/**
170
- * @param {?} url
171
- * @return {?}
172
86
  */
173
- (url) => {
87
+ const processRedirects = (url) => {
174
88
  if (url.code === 301) {
175
89
  throw new DaffExternalRouterPermanentRedirectError(url.url);
176
90
  }
@@ -180,26 +94,14 @@ const processRedirects = (/**
180
94
  else {
181
95
  return url;
182
96
  }
183
- });
97
+ };
184
98
 
185
- /**
186
- * @fileoverview added by tsickle
187
- * Generated from: guard/existence.guard.ts
188
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
189
- */
190
99
  /**
191
100
  * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route
192
101
  * of an Angular App and either navigating to a resolved route upon successful resolution
193
102
  * or navigating to the configured route upon a failed resolution.
194
103
  */
195
104
  class DaffExternalRouterExistenceGuard {
196
- /**
197
- * @param {?} driver
198
- * @param {?} externalRouter
199
- * @param {?} router
200
- * @param {?} config
201
- * @param {?} urlNormalizer
202
- */
203
105
  constructor(driver, externalRouter, router, config, urlNormalizer) {
204
106
  this.driver = driver;
205
107
  this.externalRouter = externalRouter;
@@ -207,71 +109,40 @@ class DaffExternalRouterExistenceGuard {
207
109
  this.config = config;
208
110
  this.urlNormalizer = urlNormalizer;
209
111
  }
210
- /**
211
- * @param {?} next
212
- * @param {?} state
213
- * @return {?}
214
- */
215
112
  canActivate(next, state) {
216
- return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(map((/**
217
- * @param {?} resolvedRoute
218
- * @return {?}
219
- */
220
- (resolvedRoute) => processErrors(resolvedRoute))), switchMap((/**
221
- * @param {?} resolvedRoute
222
- * @return {?}
223
- */
224
- resolvedRoute => {
113
+ return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(map((resolvedRoute) => processErrors(resolvedRoute)), switchMap(resolvedRoute => {
225
114
  this.externalRouter.add(resolvedRoute);
226
115
  return of(resolvedRoute);
227
- })), map((/**
228
- * @param {?} resolvedRoute
229
- * @return {?}
230
- */
231
- (resolvedRoute) => processRedirects(resolvedRoute))),
116
+ }), map((resolvedRoute) => processRedirects(resolvedRoute)),
232
117
  // Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.
233
118
  // When we succeed, redirect to the new route, as config has changed since we init'd.
234
- map((/**
235
- * @return {?}
236
- */
237
- () => this.router.parseUrl(state.url))),
119
+ map(() => this.router.parseUrl(state.url)),
238
120
  // When we fail, we need to process errors as dictated by the error type.
239
121
  // Handle redirects
240
- catchError((/**
241
- * @param {?} error
242
- * @return {?}
243
- */
244
- error => {
122
+ catchError(error => {
245
123
  if (!(error instanceof DaffExternalRouterPermanentRedirectError) &&
246
124
  !(error instanceof DaffExternalRouterTemporaryRedirectError)) {
247
125
  throw error;
248
126
  }
249
127
  return of(this.router.parseUrl(error.redirectUrl));
250
- })),
128
+ }),
251
129
  // Handle "404"
252
- catchError((/**
253
- * @param {?} error
254
- * @return {?}
255
- */
256
- (error) => {
130
+ catchError((error) => {
257
131
  if (!(error instanceof DaffExternalRouterNotFoundError)) {
258
132
  throw error;
259
133
  }
260
134
  return of(this.router.parseUrl(this.config.notFoundResolutionPath));
261
- })),
135
+ }),
262
136
  //Otherwise something went horribly wrong and we need to bail out.
263
- catchError((/**
264
- * @param {?} error
265
- * @return {?}
266
- */
267
- (error) => {
137
+ catchError((error) => {
268
138
  //TODO(damienwebdev): Add a logging system.
269
139
  //This log is intentional until we have a better logging system in place.
270
140
  console.log(error);
271
141
  return of(this.router.parseUrl(this.config.failedResolutionPath));
272
- })));
142
+ }));
273
143
  }
274
144
  }
145
+ /** @nocollapse */ DaffExternalRouterExistenceGuard.ɵprov = ɵɵdefineInjectable({ factory: function DaffExternalRouterExistenceGuard_Factory() { return new DaffExternalRouterExistenceGuard(ɵɵinject(DaffExternalRouterDriver), ɵɵinject(DaffExternalRouter), ɵɵinject(Router), ɵɵinject(DAFF_EXTERNAL_ROUTER_CONFIG), ɵɵinject(DaffRoutingUriNormalizer)); }, token: DaffExternalRouterExistenceGuard, providedIn: "root" });
275
146
  DaffExternalRouterExistenceGuard.decorators = [
276
147
  { type: Injectable, args: [{
277
148
  providedIn: 'root',
@@ -285,51 +156,13 @@ DaffExternalRouterExistenceGuard.ctorParameters = () => [
285
156
  { type: undefined, decorators: [{ type: Inject, args: [DAFF_EXTERNAL_ROUTER_CONFIG,] }] },
286
157
  { type: DaffRoutingUriNormalizer }
287
158
  ];
288
- /** @nocollapse */ DaffExternalRouterExistenceGuard.ɵprov = ɵɵdefineInjectable({ factory: function DaffExternalRouterExistenceGuard_Factory() { return new DaffExternalRouterExistenceGuard(ɵɵinject(DaffExternalRouterDriver), ɵɵinject(DaffExternalRouter), ɵɵinject(Router), ɵɵinject(DAFF_EXTERNAL_ROUTER_CONFIG), ɵɵinject(DaffRoutingUriNormalizer)); }, token: DaffExternalRouterExistenceGuard, providedIn: "root" });
289
- if (false) {
290
- /**
291
- * @type {?}
292
- * @private
293
- */
294
- DaffExternalRouterExistenceGuard.prototype.driver;
295
- /**
296
- * @type {?}
297
- * @private
298
- */
299
- DaffExternalRouterExistenceGuard.prototype.externalRouter;
300
- /**
301
- * @type {?}
302
- * @private
303
- */
304
- DaffExternalRouterExistenceGuard.prototype.router;
305
- /**
306
- * @type {?}
307
- * @private
308
- */
309
- DaffExternalRouterExistenceGuard.prototype.config;
310
- /**
311
- * @type {?}
312
- * @private
313
- */
314
- DaffExternalRouterExistenceGuard.prototype.urlNormalizer;
315
- }
316
159
 
317
- /**
318
- * @fileoverview added by tsickle
319
- * Generated from: public_api.ts
320
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
321
- */
322
-
323
- /**
324
- * @fileoverview added by tsickle
325
- * Generated from: index.ts
326
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
160
+ /*
161
+ * Public API Surface of @daffodil/external-router/routing
327
162
  */
328
163
 
329
164
  /**
330
- * @fileoverview added by tsickle
331
- * Generated from: daffodil-external-router-routing.ts
332
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
165
+ * Generated bundle index. Do not edit.
333
166
  */
334
167
 
335
168
  export { DaffExternalRouterExistenceGuard };
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-routing.js","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"],"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\tpublic readonly code: string = '4xx_CLIENT_ERROR';\n\n\tconstructor(message?: string) {\n\t super(message);\n\t}\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\tpublic readonly code: string = '404_NOT_FOUND';\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 the driver determines that the url needs to be routed somewhere\n * else permanently.\n */\nexport class DaffExternalRouterPermanentRedirectError extends DaffInheritableError\n implements DaffError {\n\tpublic readonly code: string = '302_PERMANENT_REDIRECT';\n\n\tconstructor(public redirectUrl: string, 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 the driver needs a URI to be temporarily redirected\n * to another location.\n */\nexport class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError\n implements DaffError {\n\tpublic readonly code: string = 'TEMPORARY_REDIRECT';\n\n\tconstructor(public redirectUrl: string, 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 the platform performing url resolution fails.\n */\nexport class DaffExternalRouterServerError extends DaffInheritableError\n implements DaffError {\n\tpublic readonly code: string = '5xx_SERVER_ERROR';\n\n\tconstructor(message?: string) {\n\t super(message);\n\t}\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n\nimport { DaffExternalRouterClientError } from '../errors/client-error';\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterServerError } from '../errors/server-error';\n\n/**\n * Processes resolved URLs and throws the appropriate error so that External Router\n * can handle routing errors.\n */\nexport const processErrors = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 404 ){\n throw new DaffExternalRouterNotFoundError();\n } else if(url.code >= 400 && url.code < 500) {\n throw new DaffExternalRouterClientError();\n } else if(url.code >= 500) {\n throw new DaffExternalRouterServerError();\n } else {\n return url;\n }\n};\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\n\n/**\n * Processes resolvedUrls and throws the appropriate error so that External Router\n * can handle redirects.\n */\nexport const processRedirects = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 301){\n throw new DaffExternalRouterPermanentRedirectError(url.url);\n } else if(url.code === 302) {\n throw new DaffExternalRouterTemporaryRedirectError(url.url);\n } else {\n return url;\n }\n};\n","import { isPlatformServer } from '@angular/common';\nimport {\n Injectable,\n Inject,\n PLATFORM_ID,\n} from '@angular/core';\nimport {\n CanActivate,\n ActivatedRouteSnapshot,\n Router,\n RouterStateSnapshot,\n UrlTree,\n} from '@angular/router';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n switchMap,\n} from 'rxjs/operators';\n\nimport { DaffRoutingUriNormalizer } from '@daffodil/core/routing';\nimport {\n DaffExternalRouter,\n DaffExternalRouterConfiguration,\n DAFF_EXTERNAL_ROUTER_CONFIG,\n DaffExternallyResolvableUrl,\n} from '@daffodil/external-router';\nimport {\n DaffExternalRouterDriverInterface,\n DaffExternalRouterDriver,\n} from '@daffodil/external-router/driver';\n\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\nimport { processErrors } from '../processors/process-errors';\nimport { processRedirects } from '../processors/process-redirect';\n\n/**\n * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route\n * of an Angular App and either navigating to a resolved route upon successful resolution\n * or navigating to the configured route upon a failed resolution.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterExistenceGuard implements CanActivate {\n constructor(\n @Inject(DaffExternalRouterDriver)\n private driver: DaffExternalRouterDriverInterface,\n private externalRouter: DaffExternalRouter,\n private router: Router,\n @Inject(DAFF_EXTERNAL_ROUTER_CONFIG)\n private config: DaffExternalRouterConfiguration,\n private urlNormalizer: DaffRoutingUriNormalizer,\n ) { }\n\n canActivate(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Observable<UrlTree | boolean> {\n return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(\n map((resolvedRoute: DaffExternallyResolvableUrl) => processErrors(resolvedRoute)),\n switchMap(resolvedRoute => {\n this.externalRouter.add(resolvedRoute);\n return of(resolvedRoute);\n }),\n map((resolvedRoute: DaffExternallyResolvableUrl) => processRedirects(resolvedRoute)),\n // Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.\n // When we succeed, redirect to the new route, as config has changed since we init'd.\n map(() => this.router.parseUrl(state.url)),\n // When we fail, we need to process errors as dictated by the error type.\n // Handle redirects\n catchError(error => {\n if (\n !(error instanceof DaffExternalRouterPermanentRedirectError) &&\n !(error instanceof DaffExternalRouterTemporaryRedirectError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(error.redirectUrl));\n }),\n // Handle \"404\"\n catchError((error) => {\n if (!(error instanceof DaffExternalRouterNotFoundError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(this.config.notFoundResolutionPath));\n }),\n\n //Otherwise something went horribly wrong and we need to bail out.\n catchError((error) => {\n //TODO(damienwebdev): Add a logging system.\n //This log is intentional until we have a better logging system in place.\n console.log(error);\n return of(this.router.parseUrl(this.config.failedResolutionPath));\n }),\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;MAQa,6BAA8B,SAAQ,oBAAoB;;;;IAItE,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHD,SAAI,GAAW,kBAAkB,CAAC;KAIjD;CACD;;;IALA,6CAAkD;;;;;;;;;;;MCHtC,+BAAgC,SAAQ,6BAA6B;;;;IAIjF,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHD,SAAI,GAAW,eAAe,CAAC;KAI9C;CACD;;;IALA,+CAA+C;;;;;;;;;;;;MCAnC,wCAAyC,SAAQ,oBAAoB;;;;;IAIjF,YAAmB,WAAmB,EAAE,OAAgB;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,gBAAW,GAAX,WAAW,CAAQ;QAFtB,SAAI,GAAW,wBAAwB,CA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AAC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC;SACrE,EAAC;;QAGF,UAAU;;;;QAAC,CAAC,KAAK;;;YAGf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;SACnE,EAAC,CACH,CAAC;KACH;;;YAxDF,UAAU,SAAC;gBACV,UAAU,EAAE,MAAM;aACnB;;;;4CAGI,MAAM,SAAC,wBAAwB;YA1BlC,kBAAkB;YAhBlB,MAAM;4CA8CH,MAAM,SAAC,2BAA2B;YAhC9B,wBAAwB;;;;;;;;IA4B7B,kDACiD;;;;;IACjD,0DAA0C;;;;;IAC1C,kDAAsB;;;;;IACtB,kDAC+C;;;;;IAC/C,yDAA+C;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-routing.js","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\tpublic readonly code: string = '4xx_CLIENT_ERROR';\n\n\tconstructor(message?: string) {\n\t super(message);\n\t}\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\tpublic readonly code: string = '404_NOT_FOUND';\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 the driver determines that the url needs to be routed somewhere\n * else permanently.\n */\nexport class DaffExternalRouterPermanentRedirectError extends DaffInheritableError\n implements DaffError {\n\tpublic readonly code: string = '302_PERMANENT_REDIRECT';\n\n\tconstructor(public redirectUrl: string, 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 the driver needs a URI to be temporarily redirected\n * to another location.\n */\nexport class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError\n implements DaffError {\n\tpublic readonly code: string = 'TEMPORARY_REDIRECT';\n\n\tconstructor(public redirectUrl: string, 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 the platform performing url resolution fails.\n */\nexport class DaffExternalRouterServerError extends DaffInheritableError\n implements DaffError {\n\tpublic readonly code: string = '5xx_SERVER_ERROR';\n\n\tconstructor(message?: string) {\n\t super(message);\n\t}\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n\nimport { DaffExternalRouterClientError } from '../errors/client-error';\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterServerError } from '../errors/server-error';\n\n/**\n * Processes resolved URLs and throws the appropriate error so that External Router\n * can handle routing errors.\n */\nexport const processErrors = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 404 ){\n throw new DaffExternalRouterNotFoundError();\n } else if(url.code >= 400 && url.code < 500) {\n throw new DaffExternalRouterClientError();\n } else if(url.code >= 500) {\n throw new DaffExternalRouterServerError();\n } else {\n return url;\n }\n};\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\n\n/**\n * Processes resolvedUrls and throws the appropriate error so that External Router\n * can handle redirects.\n */\nexport const processRedirects = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 301){\n throw new DaffExternalRouterPermanentRedirectError(url.url);\n } else if(url.code === 302) {\n throw new DaffExternalRouterTemporaryRedirectError(url.url);\n } else {\n return url;\n }\n};\n","import { isPlatformServer } from '@angular/common';\nimport {\n Injectable,\n Inject,\n PLATFORM_ID,\n} from '@angular/core';\nimport {\n CanActivate,\n ActivatedRouteSnapshot,\n Router,\n RouterStateSnapshot,\n UrlTree,\n} from '@angular/router';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n switchMap,\n} from 'rxjs/operators';\n\nimport { DaffRoutingUriNormalizer } from '@daffodil/core/routing';\nimport {\n DaffExternalRouter,\n DaffExternalRouterConfiguration,\n DAFF_EXTERNAL_ROUTER_CONFIG,\n DaffExternallyResolvableUrl,\n} from '@daffodil/external-router';\nimport {\n DaffExternalRouterDriverInterface,\n DaffExternalRouterDriver,\n} from '@daffodil/external-router/driver';\n\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\nimport { processErrors } from '../processors/process-errors';\nimport { processRedirects } from '../processors/process-redirect';\n\n/**\n * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route\n * of an Angular App and either navigating to a resolved route upon successful resolution\n * or navigating to the configured route upon a failed resolution.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterExistenceGuard implements CanActivate {\n constructor(\n @Inject(DaffExternalRouterDriver)\n private driver: DaffExternalRouterDriverInterface,\n private externalRouter: DaffExternalRouter,\n private router: Router,\n @Inject(DAFF_EXTERNAL_ROUTER_CONFIG)\n private config: DaffExternalRouterConfiguration,\n private urlNormalizer: DaffRoutingUriNormalizer,\n ) { }\n\n canActivate(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Observable<UrlTree | boolean> {\n return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(\n map((resolvedRoute: DaffExternallyResolvableUrl) => processErrors(resolvedRoute)),\n switchMap(resolvedRoute => {\n this.externalRouter.add(resolvedRoute);\n return of(resolvedRoute);\n }),\n map((resolvedRoute: DaffExternallyResolvableUrl) => processRedirects(resolvedRoute)),\n // Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.\n // When we succeed, redirect to the new route, as config has changed since we init'd.\n map(() => this.router.parseUrl(state.url)),\n // When we fail, we need to process errors as dictated by the error type.\n // Handle redirects\n catchError(error => {\n if (\n !(error instanceof DaffExternalRouterPermanentRedirectError) &&\n !(error instanceof DaffExternalRouterTemporaryRedirectError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(error.redirectUrl));\n }),\n // Handle \"404\"\n catchError((error) => {\n if (!(error instanceof DaffExternalRouterNotFoundError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(this.config.notFoundResolutionPath));\n }),\n\n //Otherwise something went horribly wrong and we need to bail out.\n catchError((error) => {\n //TODO(damienwebdev): Add a logging system.\n //This log is intentional until we have a better logging system in place.\n console.log(error);\n return of(this.router.parseUrl(this.config.failedResolutionPath));\n }),\n );\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/routing\n */\nexport { DaffExternalRouterExistenceGuard } from './guard/existence.guard';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAKA;;;MAGa,6BAA8B,SAAQ,oBAAoB;IAItE,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHD,SAAI,GAAW,kBAAkB,CAAC;KAIjD;;;ACVF;;;MAGa,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