@daffodil/external-router 0.66.0 → 0.67.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.
- package/driver/in-memory/config.d.ts +1 -1
- package/{esm2020 → esm2022}/driver/in-memory/in-memory.module.mjs +5 -5
- package/{esm2020 → esm2022}/driver/in-memory/in-memory.service.mjs +6 -6
- package/{esm2020 → esm2022}/driver/magento/2.4.1/magento.module.mjs +5 -5
- package/{esm2020 → esm2022}/driver/magento/2.4.1/magento.service.mjs +5 -5
- package/{esm2020 → esm2022}/driver/magento/2.4.2/magento.module.mjs +5 -5
- package/{esm2020 → esm2022}/driver/magento/2.4.2/magento.service.mjs +5 -5
- package/{esm2020 → esm2022}/driver/magento/2.4.3/magento.module.mjs +5 -5
- package/{esm2020 → esm2022}/driver/magento/2.4.3/magento.service.mjs +5 -5
- package/{esm2020 → esm2022}/driver/testing/testing.module.mjs +5 -5
- package/{esm2020 → esm2022}/driver/testing/testing.service.mjs +6 -6
- package/{esm2020 → esm2022}/external-router.module.mjs +5 -5
- package/{esm2020 → esm2022}/router/router.service.mjs +6 -6
- package/{esm2020 → esm2022}/routing/guard/existence.guard.mjs +6 -6
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-in-memory.mjs +9 -9
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-in-memory.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-magento-2.4.1.mjs +8 -8
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-magento-2.4.1.mjs.map +1 -1
- package/{fesm2015 → fesm2022}/daffodil-external-router-driver-magento-2.4.2.mjs +9 -9
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-magento-2.4.2.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-magento-2.4.3.mjs +8 -8
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-magento-2.4.3.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-testing.mjs +9 -9
- package/{fesm2020 → fesm2022}/daffodil-external-router-driver-testing.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/daffodil-external-router-routing.mjs +5 -5
- package/fesm2022/daffodil-external-router-routing.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/daffodil-external-router.mjs +9 -9
- package/{fesm2020 → fesm2022}/daffodil-external-router.mjs.map +1 -1
- package/model/insertion-strategy.type.d.ts +1 -1
- package/model/route-type.d.ts +1 -1
- package/model/route-with-data-path.d.ts +1 -1
- package/model/route-with-seo-data.d.ts +1 -1
- package/model/route-with-type.d.ts +1 -1
- package/model/route-without-path.d.ts +1 -1
- package/package.json +1 -1
- package/routing/guard/existence.guard.d.ts +2 -2
- package/fesm2015/daffodil-external-router-driver-in-memory.mjs +0 -97
- package/fesm2015/daffodil-external-router-driver-in-memory.mjs.map +0 -1
- package/fesm2015/daffodil-external-router-driver-magento-2.4.1.mjs +0 -125
- package/fesm2015/daffodil-external-router-driver-magento-2.4.1.mjs.map +0 -1
- package/fesm2015/daffodil-external-router-driver-magento-2.4.2.mjs.map +0 -1
- package/fesm2015/daffodil-external-router-driver-magento-2.4.3.mjs +0 -143
- package/fesm2015/daffodil-external-router-driver-magento-2.4.3.mjs.map +0 -1
- package/fesm2015/daffodil-external-router-driver-magento.mjs.map +0 -1
- package/fesm2015/daffodil-external-router-driver-testing.mjs +0 -101
- package/fesm2015/daffodil-external-router-driver-testing.mjs.map +0 -1
- package/fesm2015/daffodil-external-router-routing.mjs +0 -173
- package/fesm2015/daffodil-external-router-routing.mjs.map +0 -1
- package/fesm2015/daffodil-external-router.mjs +0 -297
- package/fesm2015/daffodil-external-router.mjs.map +0 -1
- package/fesm2020/daffodil-external-router-driver-magento-2.4.2.mjs +0 -122
- package/fesm2020/daffodil-external-router-driver-magento.mjs +0 -22
- package/fesm2020/daffodil-external-router-driver.mjs +0 -30
- package/fesm2020/daffodil-external-router-driver.mjs.map +0 -1
- package/fesm2020/daffodil-external-router-routing.mjs.map +0 -1
- /package/{esm2020 → esm2022}/config.mjs +0 -0
- /package/{esm2020 → esm2022}/daffodil-external-router.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/daffodil-external-router-driver.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/in-memory/config.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/in-memory/daffodil-external-router-driver-in-memory.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/in-memory/index.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/in-memory/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/index.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/interfaces/external-router-driver.interface.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.1/daffodil-external-router-driver-magento-2.4.1.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.1/graphql/queries/resolve-url-v2.4.1.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.1/index.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.1/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.1/transforms/resolution-to-resolvable-url.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.2/daffodil-external-router-driver-magento-2.4.2.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.2/graphql/queries/resolve-url-v2.4.2.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.2/index.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.2/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.2/transforms/resolution-to-resolvable-url.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.3/daffodil-external-router-driver-magento-2.4.3.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.3/graphql/queries/resolve.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.3/index.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.3/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/2.4.3/transforms/resolution-to-resolvable-url.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/daffodil-external-router-driver-magento.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/index.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/model/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/model/resolution-types.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/model/route-response.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/model/route.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/model/url-resolver-response.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/model/url-resolver.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/transforms/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/magento/transforms/redirect-to-http.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/not-found-resolution.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/testing/config.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/testing/daffodil-external-router-driver-testing.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/testing/index.mjs +0 -0
- /package/{esm2020 → esm2022}/driver/testing/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/errors/no-wildcard.mjs +0 -0
- /package/{esm2020 → esm2022}/errors/unknown-type.mjs +0 -0
- /package/{esm2020 → esm2022}/model/insertion-strategy.type.mjs +0 -0
- /package/{esm2020 → esm2022}/model/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/model/resolvable-route.mjs +0 -0
- /package/{esm2020 → esm2022}/model/route-data.mjs +0 -0
- /package/{esm2020 → esm2022}/model/route-info.mjs +0 -0
- /package/{esm2020 → esm2022}/model/route-type.mjs +0 -0
- /package/{esm2020 → esm2022}/model/route-with-data-path.mjs +0 -0
- /package/{esm2020 → esm2022}/model/route-with-seo-data.mjs +0 -0
- /package/{esm2020 → esm2022}/model/route-with-type.mjs +0 -0
- /package/{esm2020 → esm2022}/model/route-without-path.mjs +0 -0
- /package/{esm2020 → esm2022}/model/type-route-pair.mjs +0 -0
- /package/{esm2020 → esm2022}/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/router/strategies/insert-data-path.mjs +0 -0
- /package/{esm2020 → esm2022}/router/strategies/insert-route-before-wildcard.mjs +0 -0
- /package/{esm2020 → esm2022}/router/url-matcher/data-path-matcher.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/daffodil-external-router-routing.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/errors/client-error.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/errors/not-found-error.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/errors/permanent-redirect.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/errors/server-error.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/errors/temporary-redirect.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/index.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/processors/process-errors.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/processors/process-redirect.mjs +0 -0
- /package/{esm2020 → esm2022}/routing/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/token/type-resolvable-routes.token.mjs +0 -0
- /package/{esm2020 → esm2022}/transform/resolved-route-to-route.mjs +0 -0
- /package/{esm2020 → esm2022}/util/extract-daff-path-data.mjs +0 -0
- /package/{fesm2015 → fesm2022}/daffodil-external-router-driver-magento.mjs +0 -0
- /package/{fesm2020 → fesm2022}/daffodil-external-router-driver-magento.mjs.map +0 -0
- /package/{fesm2015 → fesm2022}/daffodil-external-router-driver.mjs +0 -0
- /package/{fesm2015 → fesm2022}/daffodil-external-router-driver.mjs.map +0 -0
@@ -1,101 +0,0 @@
|
|
1
|
-
import * as i0 from '@angular/core';
|
2
|
-
import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core';
|
3
|
-
import { faker } from '@faker-js/faker/locale/en_US';
|
4
|
-
import { throwError, of } from 'rxjs';
|
5
|
-
import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
|
6
|
-
import { CommonModule } from '@angular/common';
|
7
|
-
import { DaffExternalRouterDriver } from '@daffodil/external-router/driver';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* The token used by Daffodil to hold the driver's configuration.
|
11
|
-
*
|
12
|
-
* @docs-private
|
13
|
-
*/
|
14
|
-
const DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG = new InjectionToken('DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG', {
|
15
|
-
providedIn: 'root',
|
16
|
-
factory: () => ({}),
|
17
|
-
});
|
18
|
-
|
19
|
-
/**
|
20
|
-
* The DaffExternalRouterTestingDriver is responsible for translating an
|
21
|
-
* arbitrary URI into a DaffExternallyResolvableUrl in testing environments.
|
22
|
-
*
|
23
|
-
* @inheritdoc
|
24
|
-
*
|
25
|
-
* @see {@link DaffExternalRouterTestingDriver}
|
26
|
-
*/
|
27
|
-
class DaffExternalRouterTestingDriver {
|
28
|
-
constructor(testingConfiguration = {}) {
|
29
|
-
this.testingConfiguration = testingConfiguration;
|
30
|
-
}
|
31
|
-
resolve(url) {
|
32
|
-
const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));
|
33
|
-
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
|
-
}
|
38
|
-
return of({
|
39
|
-
id: faker.datatype.uuid(),
|
40
|
-
url: truncatedUrl,
|
41
|
-
type: this.testingConfiguration[truncatedUrl],
|
42
|
-
code: 200,
|
43
|
-
});
|
44
|
-
}
|
45
|
-
}
|
46
|
-
/** @nocollapse */ DaffExternalRouterTestingDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterTestingDriver, deps: [{ token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
|
47
|
-
/** @nocollapse */ DaffExternalRouterTestingDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterTestingDriver, providedIn: 'root' });
|
48
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterTestingDriver, decorators: [{
|
49
|
-
type: Injectable,
|
50
|
-
args: [{
|
51
|
-
providedIn: 'root',
|
52
|
-
}]
|
53
|
-
}], ctorParameters: function () {
|
54
|
-
return [{ type: undefined, decorators: [{
|
55
|
-
type: Inject,
|
56
|
-
args: [DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG]
|
57
|
-
}] }];
|
58
|
-
} });
|
59
|
-
|
60
|
-
/**
|
61
|
-
* The `DaffExternalRouterDriverTestingModule` is an importable NgModule that can
|
62
|
-
* be used to configure the {@link DaffExternalRouterTestingDriver}.
|
63
|
-
*/
|
64
|
-
class DaffExternalRouterDriverTestingModule {
|
65
|
-
static forRoot(config) {
|
66
|
-
return {
|
67
|
-
ngModule: DaffExternalRouterDriverTestingModule,
|
68
|
-
providers: [
|
69
|
-
{
|
70
|
-
provide: DaffExternalRouterDriver,
|
71
|
-
useExisting: DaffExternalRouterTestingDriver,
|
72
|
-
},
|
73
|
-
{
|
74
|
-
provide: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,
|
75
|
-
useValue: config,
|
76
|
-
},
|
77
|
-
],
|
78
|
-
};
|
79
|
-
}
|
80
|
-
}
|
81
|
-
/** @nocollapse */ DaffExternalRouterDriverTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterDriverTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
82
|
-
/** @nocollapse */ DaffExternalRouterDriverTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterDriverTestingModule, imports: [CommonModule] });
|
83
|
-
/** @nocollapse */ DaffExternalRouterDriverTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterDriverTestingModule, imports: [CommonModule] });
|
84
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterDriverTestingModule, decorators: [{
|
85
|
-
type: NgModule,
|
86
|
-
args: [{
|
87
|
-
declarations: [],
|
88
|
-
imports: [CommonModule],
|
89
|
-
}]
|
90
|
-
}] });
|
91
|
-
|
92
|
-
/*
|
93
|
-
* Public API Surface of @daffodil/external-router/driver/testing
|
94
|
-
*/
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Generated bundle index. Do not edit.
|
98
|
-
*/
|
99
|
-
|
100
|
-
export { DaffExternalRouterDriverTestingModule, DaffExternalRouterTestingDriver };
|
101
|
-
//# sourceMappingURL=daffodil-external-router-driver-testing.mjs.map
|
@@ -1 +0,0 @@
|
|
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<\nDaffExternalRouterDriverTestingConfig\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;IAE1C,WAEU,CAAA,uBAA8D,EAAE,EAAA;AAAhE,QAAA,IAAoB,CAAA,oBAAA,GAApB,oBAAoB,CA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QAE7C,OAAO;AACL,YAAA,QAAQ,EAAE,qCAAqC;AAC/C,YAAA,SAAS,EAAE;AACT,gBAAA;AACE,oBAAA,OAAO,EAAE,wBAAwB;AACjC,oBAAA,WAAW,EAAE,+BAA+B;AAC7C,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE,0CAA0C;AACnD,oBAAA,QAAQ,EAAE,MAAM;AACjB,iBAAA;AACF,aAAA;SACF,CAAC;KACH;;qJAjBU,qCAAqC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAArC,mBAAA,qCAAA,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;AAEX,mBAAA,qCAAA,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;2FAEX,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;iBACxB,CAAA;;;ACrBD;;AAEG;;ACFH;;AAEG;;;;"}
|
@@ -1,173 +0,0 @@
|
|
1
|
-
import * as i0 from '@angular/core';
|
2
|
-
import { Injectable, Inject } from '@angular/core';
|
3
|
-
import { of } from 'rxjs';
|
4
|
-
import { map, switchMap, catchError } from 'rxjs/operators';
|
5
|
-
import * as i1 from '@daffodil/external-router';
|
6
|
-
import { DAFF_EXTERNAL_ROUTER_CONFIG } from '@daffodil/external-router';
|
7
|
-
import { DaffExternalRouterDriver } from '@daffodil/external-router/driver';
|
8
|
-
import { DaffInheritableError } from '@daffodil/core';
|
9
|
-
import * as i2 from '@angular/router';
|
10
|
-
import * as i3 from '@daffodil/core/routing';
|
11
|
-
|
12
|
-
/**
|
13
|
-
* An error thrown when the driver encounters a 4xx error.
|
14
|
-
*/
|
15
|
-
class DaffExternalRouterClientError extends DaffInheritableError {
|
16
|
-
constructor(message) {
|
17
|
-
super(message);
|
18
|
-
this.code = '4xx_CLIENT_ERROR';
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
/**
|
23
|
-
* An error thrown when the driver determines that a given url is not resolvable.
|
24
|
-
*/
|
25
|
-
class DaffExternalRouterNotFoundError extends DaffExternalRouterClientError {
|
26
|
-
constructor(message) {
|
27
|
-
super(message);
|
28
|
-
this.code = '404_NOT_FOUND';
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
/**
|
33
|
-
* An error thrown when the driver determines that the url needs to be routed somewhere
|
34
|
-
* else permanently.
|
35
|
-
*/
|
36
|
-
class DaffExternalRouterPermanentRedirectError extends DaffInheritableError {
|
37
|
-
constructor(redirectUrl, message) {
|
38
|
-
super(message);
|
39
|
-
this.redirectUrl = redirectUrl;
|
40
|
-
this.code = '302_PERMANENT_REDIRECT';
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
/**
|
45
|
-
* An error thrown when the driver needs a URI to be temporarily redirected
|
46
|
-
* to another location.
|
47
|
-
*/
|
48
|
-
class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError {
|
49
|
-
constructor(redirectUrl, message) {
|
50
|
-
super(message);
|
51
|
-
this.redirectUrl = redirectUrl;
|
52
|
-
this.code = 'TEMPORARY_REDIRECT';
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
/**
|
57
|
-
* An error thrown when the platform performing url resolution fails.
|
58
|
-
*/
|
59
|
-
class DaffExternalRouterServerError extends DaffInheritableError {
|
60
|
-
constructor(message) {
|
61
|
-
super(message);
|
62
|
-
this.code = '5xx_SERVER_ERROR';
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
/**
|
67
|
-
* Processes resolved URLs and throws the appropriate error so that External Router
|
68
|
-
* can handle routing errors.
|
69
|
-
*/
|
70
|
-
const processErrors = (url) => {
|
71
|
-
if (url.code === 404) {
|
72
|
-
throw new DaffExternalRouterNotFoundError();
|
73
|
-
}
|
74
|
-
else if (url.code >= 400 && url.code < 500) {
|
75
|
-
throw new DaffExternalRouterClientError();
|
76
|
-
}
|
77
|
-
else if (url.code >= 500) {
|
78
|
-
throw new DaffExternalRouterServerError();
|
79
|
-
}
|
80
|
-
else {
|
81
|
-
return url;
|
82
|
-
}
|
83
|
-
};
|
84
|
-
|
85
|
-
/**
|
86
|
-
* Processes resolvedUrls and throws the appropriate error so that External Router
|
87
|
-
* can handle redirects.
|
88
|
-
*/
|
89
|
-
const processRedirects = (url) => {
|
90
|
-
if (url.code === 301) {
|
91
|
-
throw new DaffExternalRouterPermanentRedirectError(url.url);
|
92
|
-
}
|
93
|
-
else if (url.code === 302) {
|
94
|
-
throw new DaffExternalRouterTemporaryRedirectError(url.url);
|
95
|
-
}
|
96
|
-
else {
|
97
|
-
return url;
|
98
|
-
}
|
99
|
-
};
|
100
|
-
|
101
|
-
/**
|
102
|
-
* The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route
|
103
|
-
* of an Angular App and either navigating to a resolved route upon successful resolution
|
104
|
-
* or navigating to the configured route upon a failed resolution.
|
105
|
-
*/
|
106
|
-
class DaffExternalRouterExistenceGuard {
|
107
|
-
constructor(driver, externalRouter, router, config, urlNormalizer) {
|
108
|
-
this.driver = driver;
|
109
|
-
this.externalRouter = externalRouter;
|
110
|
-
this.router = router;
|
111
|
-
this.config = config;
|
112
|
-
this.urlNormalizer = urlNormalizer;
|
113
|
-
}
|
114
|
-
canActivate(next, state) {
|
115
|
-
return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(map((resolvedRoute) => processErrors(resolvedRoute)), switchMap(resolvedRoute => {
|
116
|
-
this.externalRouter.add(resolvedRoute);
|
117
|
-
return of(resolvedRoute);
|
118
|
-
}), map((resolvedRoute) => processRedirects(resolvedRoute)),
|
119
|
-
// Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.
|
120
|
-
// When we succeed, redirect to the new route, as config has changed since we init'd.
|
121
|
-
map(() => this.router.parseUrl(state.url)),
|
122
|
-
// When we fail, we need to process errors as dictated by the error type.
|
123
|
-
// Handle redirects
|
124
|
-
catchError(error => {
|
125
|
-
if (!(error instanceof DaffExternalRouterPermanentRedirectError) &&
|
126
|
-
!(error instanceof DaffExternalRouterTemporaryRedirectError)) {
|
127
|
-
throw error;
|
128
|
-
}
|
129
|
-
return of(this.router.parseUrl(error.redirectUrl));
|
130
|
-
}),
|
131
|
-
// Handle "404"
|
132
|
-
catchError((error) => {
|
133
|
-
if (!(error instanceof DaffExternalRouterNotFoundError)) {
|
134
|
-
throw error;
|
135
|
-
}
|
136
|
-
return of(this.router.parseUrl(this.config.notFoundResolutionPath));
|
137
|
-
}),
|
138
|
-
//Otherwise something went horribly wrong and we need to bail out.
|
139
|
-
catchError((error) => {
|
140
|
-
//TODO(damienwebdev): Add a logging system.
|
141
|
-
//This log is intentional until we have a better logging system in place.
|
142
|
-
console.log(error);
|
143
|
-
return of(this.router.parseUrl(this.config.failedResolutionPath));
|
144
|
-
}));
|
145
|
-
}
|
146
|
-
}
|
147
|
-
/** @nocollapse */ DaffExternalRouterExistenceGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterExistenceGuard, deps: [{ token: DaffExternalRouterDriver }, { token: i1.DaffExternalRouter }, { token: i2.Router }, { token: DAFF_EXTERNAL_ROUTER_CONFIG }, { token: i3.DaffRoutingUriNormalizer }], target: i0.ɵɵFactoryTarget.Injectable });
|
148
|
-
/** @nocollapse */ DaffExternalRouterExistenceGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterExistenceGuard, providedIn: 'root' });
|
149
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterExistenceGuard, decorators: [{
|
150
|
-
type: Injectable,
|
151
|
-
args: [{
|
152
|
-
providedIn: 'root',
|
153
|
-
}]
|
154
|
-
}], ctorParameters: function () {
|
155
|
-
return [{ type: undefined, decorators: [{
|
156
|
-
type: Inject,
|
157
|
-
args: [DaffExternalRouterDriver]
|
158
|
-
}] }, { type: i1.DaffExternalRouter }, { type: i2.Router }, { type: undefined, decorators: [{
|
159
|
-
type: Inject,
|
160
|
-
args: [DAFF_EXTERNAL_ROUTER_CONFIG]
|
161
|
-
}] }, { type: i3.DaffRoutingUriNormalizer }];
|
162
|
-
} });
|
163
|
-
|
164
|
-
/*
|
165
|
-
* Public API Surface of @daffodil/external-router/routing
|
166
|
-
*/
|
167
|
-
|
168
|
-
/**
|
169
|
-
* Generated bundle index. Do not edit.
|
170
|
-
*/
|
171
|
-
|
172
|
-
export { DaffExternalRouterExistenceGuard };
|
173
|
-
//# sourceMappingURL=daffodil-external-router-routing.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"daffodil-external-router-routing.mjs","sources":["../../../libs/external-router/routing/src/errors/client-error.ts","../../../libs/external-router/routing/src/errors/not-found-error.ts","../../../libs/external-router/routing/src/errors/permanent-redirect.ts","../../../libs/external-router/routing/src/errors/temporary-redirect.ts","../../../libs/external-router/routing/src/errors/server-error.ts","../../../libs/external-router/routing/src/processors/process-errors.ts","../../../libs/external-router/routing/src/processors/process-redirect.ts","../../../libs/external-router/routing/src/guard/existence.guard.ts","../../../libs/external-router/routing/src/public_api.ts","../../../libs/external-router/routing/src/daffodil-external-router-routing.ts"],"sourcesContent":["import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver encounters a 4xx error.\n */\nexport class DaffExternalRouterClientError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '4xx_CLIENT_ERROR';\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { DaffError } from '@daffodil/core';\n\nimport { DaffExternalRouterClientError } from './client-error';\n\n/**\n * An error thrown when the driver determines that a given url is not resolvable.\n */\nexport class DaffExternalRouterNotFoundError extends DaffExternalRouterClientError\n implements DaffError {\n public readonly code: string = '404_NOT_FOUND';\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver determines that the url needs to be routed somewhere\n * else permanently.\n */\nexport class DaffExternalRouterPermanentRedirectError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '302_PERMANENT_REDIRECT';\n\n constructor(public redirectUrl: string, message?: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the driver needs a URI to be temporarily redirected\n * to another location.\n */\nexport class DaffExternalRouterTemporaryRedirectError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = 'TEMPORARY_REDIRECT';\n\n constructor(public redirectUrl: string, message?: string) {\n\t super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\n/**\n * An error thrown when the platform performing url resolution fails.\n */\nexport class DaffExternalRouterServerError extends DaffInheritableError\n implements DaffError {\n public readonly code: string = '5xx_SERVER_ERROR';\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n\nimport { DaffExternalRouterClientError } from '../errors/client-error';\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterServerError } from '../errors/server-error';\n\n/**\n * Processes resolved URLs and throws the appropriate error so that External Router\n * can handle routing errors.\n */\nexport const processErrors = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 404 ){\n throw new DaffExternalRouterNotFoundError();\n } else if(url.code >= 400 && url.code < 500) {\n throw new DaffExternalRouterClientError();\n } else if(url.code >= 500) {\n throw new DaffExternalRouterServerError();\n } else {\n return url;\n }\n};\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\n\n/**\n * Processes resolvedUrls and throws the appropriate error so that External Router\n * can handle redirects.\n */\nexport const processRedirects = (url: DaffExternallyResolvableUrl): DaffExternallyResolvableUrl => {\n if(url.code === 301){\n throw new DaffExternalRouterPermanentRedirectError(url.url);\n } else if(url.code === 302) {\n throw new DaffExternalRouterTemporaryRedirectError(url.url);\n } else {\n return url;\n }\n};\n","import { isPlatformServer } from '@angular/common';\nimport {\n Injectable,\n Inject,\n PLATFORM_ID,\n} from '@angular/core';\nimport {\n CanActivate,\n ActivatedRouteSnapshot,\n Router,\n RouterStateSnapshot,\n UrlTree,\n} from '@angular/router';\nimport {\n Observable,\n of,\n} from 'rxjs';\nimport {\n catchError,\n map,\n switchMap,\n} from 'rxjs/operators';\n\nimport { DaffRoutingUriNormalizer } from '@daffodil/core/routing';\nimport {\n DaffExternalRouter,\n DaffExternalRouterConfiguration,\n DAFF_EXTERNAL_ROUTER_CONFIG,\n DaffExternallyResolvableUrl,\n} from '@daffodil/external-router';\nimport {\n DaffExternalRouterDriverInterface,\n DaffExternalRouterDriver,\n} from '@daffodil/external-router/driver';\n\nimport { DaffExternalRouterNotFoundError } from '../errors/not-found-error';\nimport { DaffExternalRouterPermanentRedirectError } from '../errors/permanent-redirect';\nimport { DaffExternalRouterTemporaryRedirectError } from '../errors/temporary-redirect';\nimport { processErrors } from '../processors/process-errors';\nimport { processRedirects } from '../processors/process-redirect';\n\n/**\n * The DaffExternalRouterExistenceGuard is responsible for guarding the wildcard route\n * of an Angular App and either navigating to a resolved route upon successful resolution\n * or navigating to the configured route upon a failed resolution.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterExistenceGuard implements CanActivate {\n constructor(\n @Inject(DaffExternalRouterDriver)\n private driver: DaffExternalRouterDriverInterface,\n private externalRouter: DaffExternalRouter,\n private router: Router,\n @Inject(DAFF_EXTERNAL_ROUTER_CONFIG)\n private config: DaffExternalRouterConfiguration,\n private urlNormalizer: DaffRoutingUriNormalizer,\n ) { }\n\n canActivate(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Observable<UrlTree | boolean> {\n return this.driver.resolve(this.urlNormalizer.normalize(state.url)).pipe(\n map((resolvedRoute: DaffExternallyResolvableUrl) => processErrors(resolvedRoute)),\n switchMap(resolvedRoute => {\n this.externalRouter.add(resolvedRoute);\n return of(resolvedRoute);\n }),\n map((resolvedRoute: DaffExternallyResolvableUrl) => processRedirects(resolvedRoute)),\n // Note that we have to use state.url as we want to ensure that we keep any fragments or query strings.\n // When we succeed, redirect to the new route, as config has changed since we init'd.\n map(() => this.router.parseUrl(state.url)),\n // When we fail, we need to process errors as dictated by the error type.\n // Handle redirects\n catchError(error => {\n if (\n !(error instanceof DaffExternalRouterPermanentRedirectError) &&\n !(error instanceof DaffExternalRouterTemporaryRedirectError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(error.redirectUrl));\n }),\n // Handle \"404\"\n catchError((error) => {\n if (!(error instanceof DaffExternalRouterNotFoundError)) {\n throw error;\n }\n\n return of(this.router.parseUrl(this.config.notFoundResolutionPath));\n }),\n\n //Otherwise something went horribly wrong and we need to bail out.\n catchError((error) => {\n //TODO(damienwebdev): Add a logging system.\n //This log is intentional until we have a better logging system in place.\n console.log(error);\n return of(this.router.parseUrl(this.config.failedResolutionPath));\n }),\n );\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/routing\n */\nexport { DaffExternalRouterExistenceGuard } from './guard/existence.guard';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],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AAoB,CAAC,CAAC,CAAC;SACnE,CAAC,CACH,CAAC;KACH;;gJArDU,gCAAgC,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAEjC,wBAAwB,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,kBAAA,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,MAAA,EAAA,EAAA,EAAA,KAAA,EAIxB,2BAA2B,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,wBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAN1B,mBAAA,gCAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gCAAgC,cAF/B,MAAM,EAAA,CAAA,CAAA;2FAEP,gCAAgC,EAAA,UAAA,EAAA,CAAA;kBAH5C,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;iBACnB,CAAA;;;8BAGI,MAAM;+BAAC,wBAAwB,CAAA;;8BAI/B,MAAM;+BAAC,2BAA2B,CAAA;;;;ACvDvC;;AAEG;;ACFH;;AAEG;;;;"}
|
@@ -1,297 +0,0 @@
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
2
|
-
import * as i0 from '@angular/core';
|
3
|
-
import { InjectionToken, NgModule, Injectable, Inject } from '@angular/core';
|
4
|
-
import { DaffInheritableError } from '@daffodil/core';
|
5
|
-
import * as i1 from '@angular/router';
|
6
|
-
import { daffUriTruncateLeadingSlash } from '@daffodil/core/routing';
|
7
|
-
|
8
|
-
const daffExternalRouterConfigurationDefault = {
|
9
|
-
failedResolutionPath: '/',
|
10
|
-
notFoundResolutionPath: '/',
|
11
|
-
};
|
12
|
-
/**
|
13
|
-
* The token holding the runtime configuration for the behavior of the
|
14
|
-
* `@daffodil/external-router` package.
|
15
|
-
*/
|
16
|
-
const DAFF_EXTERNAL_ROUTER_CONFIG = new InjectionToken('DAFF_EXTERNAL_ROUTER_CONFIG', {
|
17
|
-
providedIn: 'root',
|
18
|
-
factory: () => daffExternalRouterConfigurationDefault,
|
19
|
-
});
|
20
|
-
|
21
|
-
/**
|
22
|
-
* A multi-token that allows you to register route "types" that correspond to routes.
|
23
|
-
*/
|
24
|
-
const DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE = new InjectionToken('DAFF_EXTERNAL_ROUTER_RESOLVABLE_TYPE_ROUTES', {
|
25
|
-
providedIn: 'root',
|
26
|
-
factory: () => [],
|
27
|
-
});
|
28
|
-
/**
|
29
|
-
* A provider used to connect a type to a route to enable dynamic route resolution at runtime.
|
30
|
-
*/
|
31
|
-
function daffProvideRouteResolvableByType(typeRoutePair) {
|
32
|
-
return {
|
33
|
-
provide: DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE,
|
34
|
-
multi: true,
|
35
|
-
useValue: typeRoutePair,
|
36
|
-
};
|
37
|
-
}
|
38
|
-
/**
|
39
|
-
* A multi-provider used to connect an array of types to their respective routes.
|
40
|
-
*/
|
41
|
-
function daffProvideRoutesResolvableByType(routes) {
|
42
|
-
return routes.map((route) => ({
|
43
|
-
provide: DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE,
|
44
|
-
multi: true,
|
45
|
-
useValue: route,
|
46
|
-
}));
|
47
|
-
}
|
48
|
-
|
49
|
-
/**
|
50
|
-
* The external `DaffExternalRouterModule` allows you to configure the
|
51
|
-
* `@daffodil/external-router` package's behavior.
|
52
|
-
*/
|
53
|
-
class DaffExternalRouterModule {
|
54
|
-
static forRoot(config, routes = []) {
|
55
|
-
return {
|
56
|
-
ngModule: DaffExternalRouterModule,
|
57
|
-
providers: [
|
58
|
-
{ provide: DAFF_EXTERNAL_ROUTER_CONFIG, useValue: Object.assign(Object.assign({}, daffExternalRouterConfigurationDefault), config) },
|
59
|
-
...daffProvideRoutesResolvableByType(routes),
|
60
|
-
],
|
61
|
-
};
|
62
|
-
}
|
63
|
-
}
|
64
|
-
/** @nocollapse */ DaffExternalRouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
65
|
-
/** @nocollapse */ DaffExternalRouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterModule, imports: [CommonModule] });
|
66
|
-
/** @nocollapse */ DaffExternalRouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterModule, imports: [CommonModule] });
|
67
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouterModule, decorators: [{
|
68
|
-
type: NgModule,
|
69
|
-
args: [{
|
70
|
-
declarations: [],
|
71
|
-
imports: [CommonModule],
|
72
|
-
}]
|
73
|
-
}] });
|
74
|
-
|
75
|
-
/**
|
76
|
-
* An error thrown when there was no wildcard route found in configuration
|
77
|
-
* of the Angular Router.
|
78
|
-
*/
|
79
|
-
class DaffExternalRouterNoWildcardError extends DaffInheritableError {
|
80
|
-
constructor(message) {
|
81
|
-
super(message);
|
82
|
-
this.code = 'NO_WILDCARD_ROUTE';
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
/**
|
87
|
-
* Inserts a Route into Routes right before the wildcard route.
|
88
|
-
* If no wildcard is found, it fails fast with a `DaffExternalRouterNoWildcardError`.
|
89
|
-
*/
|
90
|
-
const daffInsertRouteBeforeWildCardStrategy = (route, routes) => {
|
91
|
-
const index = routes.findIndex((r) => r.path === '**');
|
92
|
-
if (index === -1) {
|
93
|
-
throw new DaffExternalRouterNoWildcardError('No wildcard (**) route was found during route resolution.');
|
94
|
-
}
|
95
|
-
return [
|
96
|
-
...routes.slice(0, index),
|
97
|
-
route,
|
98
|
-
...routes.slice(index),
|
99
|
-
];
|
100
|
-
};
|
101
|
-
|
102
|
-
/**
|
103
|
-
* An error thrown when there is a failure matching a configured route to a
|
104
|
-
* route type.
|
105
|
-
*/
|
106
|
-
class DaffExternalRouterUnknownRouteTypeError extends DaffInheritableError {
|
107
|
-
constructor(message) {
|
108
|
-
super(message);
|
109
|
-
this.code = 'UNKNOWN_ROUTE_TYPE';
|
110
|
-
}
|
111
|
-
}
|
112
|
-
|
113
|
-
/**
|
114
|
-
* Transforms a DaffExternallyResolvableUrl into an Angular Route.
|
115
|
-
*/
|
116
|
-
const daffTransformResolvedRouteToRoute = (resolvedRoute, availableTypes) => {
|
117
|
-
const routeType = availableTypes
|
118
|
-
.filter(t => t.type === resolvedRoute.type)
|
119
|
-
.shift();
|
120
|
-
if (!routeType) {
|
121
|
-
throw new DaffExternalRouterUnknownRouteTypeError(`Unable to resolve the route '${resolvedRoute.url}'. Its type is '${resolvedRoute.type}' but a matching route wasn't found.`);
|
122
|
-
}
|
123
|
-
return {
|
124
|
-
route: Object.assign(Object.assign({ path: resolvedRoute.url, daffExternalRouteType: resolvedRoute.type }, routeType.route), { data: Object.assign({}, resolvedRoute.data) }),
|
125
|
-
insertionStrategy: routeType.insertionStrategy,
|
126
|
-
};
|
127
|
-
};
|
128
|
-
|
129
|
-
class DaffExternalRouter {
|
130
|
-
constructor(router, runtimeRoutes) {
|
131
|
-
this.router = router;
|
132
|
-
this.runtimeRoutes = runtimeRoutes;
|
133
|
-
}
|
134
|
-
/**
|
135
|
-
* Adds a route to the existing router configuration.
|
136
|
-
*/
|
137
|
-
add(resolvedRoute) {
|
138
|
-
//Get the route.
|
139
|
-
const { route, insertionStrategy, } = daffTransformResolvedRouteToRoute(resolvedRoute, this.runtimeRoutes);
|
140
|
-
try {
|
141
|
-
//Add it to configuration.
|
142
|
-
this.router.config = (insertionStrategy || daffInsertRouteBeforeWildCardStrategy)(route, this.router.config);
|
143
|
-
}
|
144
|
-
catch (e) {
|
145
|
-
if (e instanceof DaffExternalRouterNoWildcardError) {
|
146
|
-
throw new DaffExternalRouterNoWildcardError(`${e.message} This usually means you have misconfigured your routes.`);
|
147
|
-
}
|
148
|
-
throw e;
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
/** @nocollapse */ DaffExternalRouter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouter, deps: [{ token: i1.Router }, { token: DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE }], target: i0.ɵɵFactoryTarget.Injectable });
|
153
|
-
/** @nocollapse */ DaffExternalRouter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouter, providedIn: 'root' });
|
154
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffExternalRouter, decorators: [{
|
155
|
-
type: Injectable,
|
156
|
-
args: [{
|
157
|
-
providedIn: 'root',
|
158
|
-
}]
|
159
|
-
}], ctorParameters: function () {
|
160
|
-
return [{ type: i1.Router }, { type: undefined, decorators: [{
|
161
|
-
type: Inject,
|
162
|
-
args: [DAFF_EXTERNAL_ROUTER_ROUTES_RESOLVABLE_BY_TYPE]
|
163
|
-
}] }];
|
164
|
-
} });
|
165
|
-
|
166
|
-
/**
|
167
|
-
* Tests whether or not a route matches a specific Daffodil Route type.
|
168
|
-
*
|
169
|
-
* See {@link DaffRouteWithDataPath}
|
170
|
-
*/
|
171
|
-
const routeMatchesRouteType = (route, type) => { var _a; return ((_a = route === null || route === void 0 ? void 0 : route.data) === null || _a === void 0 ? void 0 : _a.daffExternalRouteType) === type; };
|
172
|
-
/**
|
173
|
-
* Adds a path to the `daffPaths` of the given route.
|
174
|
-
*
|
175
|
-
* See {@link DaffRouteWithDataPath}
|
176
|
-
*/
|
177
|
-
const addRouteToDaffPaths = (route, externalRoute) => {
|
178
|
-
route.data.daffPaths = Object.assign(Object.assign({}, route.data.daffPaths), { [externalRoute.path]: externalRoute.data });
|
179
|
-
return route;
|
180
|
-
};
|
181
|
-
const operateOnRoute = (externalRoute) => (route) => addRouteToDaffPaths(route, externalRoute);
|
182
|
-
/**
|
183
|
-
* Traverse the router config tree, halting after the first match.
|
184
|
-
* This traversal is implemented in a pre-order manner. As such, for large
|
185
|
-
* configuration trees, it will be most efficient to place externally routed
|
186
|
-
* components at the top of router configuration.
|
187
|
-
*/
|
188
|
-
const traverseRouteTree = (routes = [], matcher, operate) => {
|
189
|
-
if (routes.length === 0) {
|
190
|
-
return routes;
|
191
|
-
}
|
192
|
-
const stack = [];
|
193
|
-
const treeRoot = { children: routes };
|
194
|
-
stack.push(treeRoot);
|
195
|
-
while (stack.length) {
|
196
|
-
const route = stack.pop();
|
197
|
-
if (matcher(route)) {
|
198
|
-
operate(route);
|
199
|
-
break;
|
200
|
-
}
|
201
|
-
if (route.children) {
|
202
|
-
stack.push(...route.children.reverse());
|
203
|
-
}
|
204
|
-
}
|
205
|
-
return routes;
|
206
|
-
};
|
207
|
-
/**
|
208
|
-
* A route insertion strategy that can be used to append external routes onto
|
209
|
-
* existing Angular routes. This can be useful when you need to route to
|
210
|
-
* an existing lazy-loaded module from multiple externally defined urls.
|
211
|
-
*
|
212
|
-
* This should be used in combination with the {@link daffDataPathUrlMatcher} to match lazy-loaded modules with
|
213
|
-
* associated external urls.
|
214
|
-
*
|
215
|
-
* For example, you can provide the insertion strategy in the {@link DaffExternalRouterModule} as below.
|
216
|
-
*
|
217
|
-
* ```ts
|
218
|
-
* DaffExternalRouterModule.forRoot({}, [
|
219
|
-
* {
|
220
|
-
* type: 'CATEGORY',
|
221
|
-
* insertionStrategy: daffInsertDataPathStrategy,
|
222
|
-
* route: {}
|
223
|
-
* }
|
224
|
-
* ],
|
225
|
-
* ```
|
226
|
-
*
|
227
|
-
* Then, you can match it with an associated route defined in your Routing
|
228
|
-
* configuration with the {@link daffDataPathUrlMatcher}.
|
229
|
-
*
|
230
|
-
* ```ts
|
231
|
-
* export const routes: Routes = [
|
232
|
-
* {
|
233
|
-
* matcher: daffDataPathUrlMatcher,
|
234
|
-
* data: {
|
235
|
-
* daffExternalRouteType: "CATEGORY",
|
236
|
-
* },
|
237
|
-
* loadChildren: () => import('./category/category.module').then((m) => m.MyCategoryModule),
|
238
|
-
* }
|
239
|
-
* ]
|
240
|
-
* ```
|
241
|
-
*
|
242
|
-
* See {@link DaffRouteWithDataPath}
|
243
|
-
*
|
244
|
-
*/
|
245
|
-
const daffInsertDataPathStrategy = (externalRoute, routes) => traverseRouteTree(routes, (route) => routeMatchesRouteType(route, externalRoute.daffExternalRouteType), operateOnRoute(externalRoute));
|
246
|
-
|
247
|
-
/**
|
248
|
-
* A UrlMatcher that does an exact match against a path stored in the special
|
249
|
-
* configuration fields that External Router stores on a Route's data.
|
250
|
-
*
|
251
|
-
* ```ts
|
252
|
-
* export const routes: Routes = [
|
253
|
-
* {
|
254
|
-
* matcher: daffDataPathUrlMatcher,
|
255
|
-
* data: {
|
256
|
-
* daffExternalRouteType: "CATEGORY",
|
257
|
-
* },
|
258
|
-
* loadChildren: () => import('./category/category.module').then((m) => m.ShopCategoryModule),
|
259
|
-
* }
|
260
|
-
* ]
|
261
|
-
* ```
|
262
|
-
* {@link daffInsertDataPathStrategy }
|
263
|
-
* {@link DaffRouteWithDataPath }
|
264
|
-
*/
|
265
|
-
const daffDataPathUrlMatcher = (segments, group, route) => {
|
266
|
-
var _a;
|
267
|
-
const path = daffUriTruncateLeadingSlash(segments.reduce((acc, segment) => acc + '/' + segment.path, ''));
|
268
|
-
const paths = (_a = route === null || route === void 0 ? void 0 : route.data) === null || _a === void 0 ? void 0 : _a.daffPaths;
|
269
|
-
// If we don't have any paths, we can safely fail a match.
|
270
|
-
if (!paths) {
|
271
|
-
return null;
|
272
|
-
}
|
273
|
-
// Otherwise, look up the path in the dictionary, failing if a match isn't found,
|
274
|
-
// but matching the entire segment if a match is found.
|
275
|
-
return path in paths ? { consumed: segments } : null;
|
276
|
-
};
|
277
|
-
|
278
|
-
/**
|
279
|
-
* Extracts a key from DaffPath data based upon the currently activated
|
280
|
-
* RouteSnapshot.
|
281
|
-
*/
|
282
|
-
const daffExtractDaffPathData = (snapshot, key) => {
|
283
|
-
var _a, _b, _c, _d;
|
284
|
-
const pathFromRoot = snapshot.pathFromRoot[snapshot.pathFromRoot.length - 1].url.map((seg) => seg.path).join('/');
|
285
|
-
return (_d = (_c = (_b = (_a = snapshot.data) === null || _a === void 0 ? void 0 : _a.daffPaths) === null || _b === void 0 ? void 0 : _b[pathFromRoot]) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : null;
|
286
|
-
};
|
287
|
-
|
288
|
-
/*
|
289
|
-
* Public API Surface of @daffodil/external-router
|
290
|
-
*/
|
291
|
-
|
292
|
-
/**
|
293
|
-
* Generated bundle index. Do not edit.
|
294
|
-
*/
|
295
|
-
|
296
|
-
export { DAFF_EXTERNAL_ROUTER_CONFIG, DaffExternalRouter, DaffExternalRouterModule, DaffExternalRouterNoWildcardError, DaffExternalRouterUnknownRouteTypeError, daffDataPathUrlMatcher, daffExtractDaffPathData, daffInsertDataPathStrategy, daffInsertRouteBeforeWildCardStrategy, daffProvideRouteResolvableByType };
|
297
|
-
//# sourceMappingURL=daffodil-external-router.mjs.map
|