@daffodil/external-router 0.94.1-rc.0 → 0.95.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/fesm2022/daffodil-external-router-driver-in-memory.mjs +70 -88
- package/fesm2022/daffodil-external-router-driver-in-memory.mjs.map +1 -1
- package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs +117 -118
- package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs.map +1 -1
- package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs +117 -118
- package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs.map +1 -1
- package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs +216 -266
- package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs.map +1 -1
- package/fesm2022/daffodil-external-router-driver-magento-auto.mjs +7 -0
- package/fesm2022/daffodil-external-router-driver-magento-auto.mjs.map +1 -0
- package/fesm2022/daffodil-external-router-driver-magento.mjs +6 -18
- package/fesm2022/daffodil-external-router-driver-magento.mjs.map +1 -1
- package/fesm2022/daffodil-external-router-driver-shopify.mjs +49 -39
- package/fesm2022/daffodil-external-router-driver-shopify.mjs.map +1 -1
- package/fesm2022/daffodil-external-router-driver-testing.mjs +118 -115
- package/fesm2022/daffodil-external-router-driver-testing.mjs.map +1 -1
- package/fesm2022/daffodil-external-router-driver.mjs +8 -32
- package/fesm2022/daffodil-external-router-driver.mjs.map +1 -1
- package/fesm2022/daffodil-external-router-routing.mjs +31 -66
- package/fesm2022/daffodil-external-router-routing.mjs.map +1 -1
- package/fesm2022/daffodil-external-router.mjs +37 -81
- package/fesm2022/daffodil-external-router.mjs.map +1 -1
- package/package.json +1 -1
- package/types/daffodil-external-router-driver-in-memory.d.ts +15 -21
- package/types/daffodil-external-router-driver-magento-2.4.1.d.ts +29 -25
- package/types/daffodil-external-router-driver-magento-2.4.2.d.ts +29 -25
- package/types/daffodil-external-router-driver-magento-2.4.3.d.ts +25 -28
- package/types/daffodil-external-router-driver-magento-auto.d.ts +1 -0
- package/types/daffodil-external-router-driver-magento.d.ts +251 -263
- package/types/daffodil-external-router-driver-shopify.d.ts +10 -14
- package/types/daffodil-external-router-driver-testing.d.ts +22 -27
- package/types/daffodil-external-router-driver.d.ts +12 -19
- package/types/daffodil-external-router-routing.d.ts +4 -7
- package/types/daffodil-external-router.d.ts +72 -86
|
@@ -1,90 +1,72 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DaffExternalRouterNotFoundError } from
|
|
6
|
-
import { createConfigInjectionToken } from
|
|
7
|
-
import { DAFF_INMEMORY_ROUTABLE_OBJECTS } from
|
|
8
|
-
import { provideDaffExternalRouterDriver } from
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Inject, Injectable, inject, makeEnvironmentProviders } from "@angular/core";
|
|
3
|
+
import { of, throwError } from "rxjs";
|
|
4
|
+
import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from "@daffodil/core/routing";
|
|
5
|
+
import { DaffExternalRouterNotFoundError } from "@daffodil/external-router";
|
|
6
|
+
import { createConfigInjectionToken } from "@daffodil/core";
|
|
7
|
+
import { DAFF_INMEMORY_ROUTABLE_OBJECTS } from "@daffodil/driver/in-memory";
|
|
8
|
+
import { provideDaffExternalRouterDriver } from "@daffodil/external-router/driver";
|
|
9
|
+
const { token: DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG, provider: provideDaffExternalRouterDriverInMemoryConfig } = createConfigInjectionToken(void 0, "DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG", { factory: () => ({ resolver: (url) => {
|
|
10
|
+
const ROUTEABLE_OBJECTS = inject(DAFF_INMEMORY_ROUTABLE_OBJECTS);
|
|
11
|
+
if (!ROUTEABLE_OBJECTS.has(url)) return null;
|
|
12
|
+
return {
|
|
13
|
+
id: ROUTEABLE_OBJECTS.get(url).url,
|
|
14
|
+
code: 200,
|
|
15
|
+
type: ROUTEABLE_OBJECTS.get(url).type,
|
|
16
|
+
url: ROUTEABLE_OBJECTS.get(url).url
|
|
17
|
+
};
|
|
18
|
+
} }) });
|
|
19
|
+
var DaffExternalRouterInMemoryDriver = class DaffExternalRouterInMemoryDriver {
|
|
20
|
+
constructor(configuration) {
|
|
21
|
+
this.configuration = configuration;
|
|
22
|
+
}
|
|
23
|
+
resolve(url) {
|
|
24
|
+
const truncatedUrl = daffUriTruncateQueryFragment(url);
|
|
25
|
+
const resolvedUrl = this.configuration.resolver(truncatedUrl);
|
|
26
|
+
if (!resolvedUrl?.url) return throwError(() => new DaffExternalRouterNotFoundError());
|
|
27
|
+
return of({
|
|
28
|
+
...resolvedUrl,
|
|
29
|
+
url: daffUriTruncateLeadingSlash(resolvedUrl.url)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
static {
|
|
33
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
34
|
+
minVersion: "12.0.0",
|
|
35
|
+
version: "22.2.4",
|
|
36
|
+
ngImport: i0,
|
|
37
|
+
type: DaffExternalRouterInMemoryDriver,
|
|
38
|
+
deps: [{ token: DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG }],
|
|
39
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
static {
|
|
43
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
44
|
+
minVersion: "12.0.0",
|
|
45
|
+
version: "22.2.4",
|
|
46
|
+
ngImport: i0,
|
|
47
|
+
type: DaffExternalRouterInMemoryDriver,
|
|
48
|
+
providedIn: "root"
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
53
|
+
minVersion: "12.0.0",
|
|
54
|
+
version: "22.2.4",
|
|
55
|
+
ngImport: i0,
|
|
56
|
+
type: DaffExternalRouterInMemoryDriver,
|
|
57
|
+
decorators: [{
|
|
58
|
+
type: Injectable,
|
|
59
|
+
args: [{ providedIn: "root" }]
|
|
60
|
+
}],
|
|
61
|
+
ctorParameters: () => [{
|
|
62
|
+
type: void 0,
|
|
63
|
+
decorators: [{
|
|
64
|
+
type: Inject,
|
|
65
|
+
args: [DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG]
|
|
66
|
+
}]
|
|
67
|
+
}]
|
|
35
68
|
});
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The DaffExternalRouterInMemoryDriver is responsible for resolving
|
|
39
|
-
* a URL using the resolver in the provided configuration.
|
|
40
|
-
*
|
|
41
|
-
* @inheritdoc
|
|
42
|
-
*
|
|
43
|
-
* @see {@link DaffExternalRouterInMemoryDriver}
|
|
44
|
-
*/
|
|
45
|
-
class DaffExternalRouterInMemoryDriver {
|
|
46
|
-
constructor(configuration) {
|
|
47
|
-
this.configuration = configuration;
|
|
48
|
-
}
|
|
49
|
-
resolve(url) {
|
|
50
|
-
const truncatedUrl = daffUriTruncateQueryFragment(url);
|
|
51
|
-
const resolvedUrl = this.configuration.resolver(truncatedUrl);
|
|
52
|
-
if (!resolvedUrl?.url) {
|
|
53
|
-
return throwError(() => new DaffExternalRouterNotFoundError());
|
|
54
|
-
}
|
|
55
|
-
return of({
|
|
56
|
-
...resolvedUrl,
|
|
57
|
-
url: daffUriTruncateLeadingSlash(resolvedUrl.url),
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterInMemoryDriver, deps: [{ token: DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
61
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterInMemoryDriver, providedIn: 'root' }); }
|
|
62
|
-
}
|
|
63
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterInMemoryDriver, decorators: [{
|
|
64
|
-
type: Injectable,
|
|
65
|
-
args: [{
|
|
66
|
-
providedIn: 'root',
|
|
67
|
-
}]
|
|
68
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
69
|
-
type: Inject,
|
|
70
|
-
args: [DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG]
|
|
71
|
-
}] }] });
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Provides an in-memory implementation of {@link DaffExternalRouterDriver}
|
|
75
|
-
*/
|
|
76
|
-
const provideDaffExternalRouterInMemoryDriver = (config = undefined) => makeEnvironmentProviders([
|
|
77
|
-
provideDaffExternalRouterDriver(DaffExternalRouterInMemoryDriver),
|
|
78
|
-
config ? provideDaffExternalRouterDriverInMemoryConfig(config) : [],
|
|
79
|
-
]);
|
|
80
|
-
|
|
81
|
-
/*
|
|
82
|
-
* Public API Surface of @daffodil/external-router/driver/in-memory
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Generated bundle index. Do not edit.
|
|
87
|
-
*/
|
|
88
|
-
|
|
69
|
+
const provideDaffExternalRouterInMemoryDriver = (config = void 0) => makeEnvironmentProviders([provideDaffExternalRouterDriver(DaffExternalRouterInMemoryDriver), config ? provideDaffExternalRouterDriverInMemoryConfig(config) : []]);
|
|
89
70
|
export { DaffExternalRouterInMemoryDriver, provideDaffExternalRouterInMemoryDriver };
|
|
90
|
-
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=daffodil-external-router-driver-in-memory.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daffodil-external-router-driver-in-memory.mjs","sources":["../../../libs/external-router/driver/in-memory/src/config.ts","../../../libs/external-router/driver/in-memory/src/in-memory.service.ts","../../../libs/external-router/driver/in-memory/src/provider.ts"
|
|
1
|
+
{"version":3,"file":"daffodil-external-router-driver-in-memory.mjs","names":[],"sources":["../../../libs/external-router/driver/in-memory/src/config.ts","../../../libs/external-router/driver/in-memory/src/in-memory.service.ts","../../../libs/external-router/driver/in-memory/src/provider.ts"],"sourcesContent":["import { inject } from '@angular/core';\n\nimport { createConfigInjectionToken } from '@daffodil/core';\nimport {\n DAFF_INMEMORY_ROUTABLE_OBJECTS,\n DaffInMemoryRoutableObjects,\n} from '@daffodil/driver/in-memory';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n/**\n * A lookup for a URL.\n * Returns an {@link DaffExternallyResolvableUrl} or\n * {@link DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION} if the URL cannot be resolved\n */\nexport type DaffExternalRouterDriverInMemoryResolver = (url: string) => DaffExternallyResolvableUrl;\n\n/**\n * The configuration for the in-memory driver.\n */\nexport interface DaffExternalRouterDriverInMemoryConfig {\n resolver: DaffExternalRouterDriverInMemoryResolver;\n}\n\nexport const {\n /**\n * The token used by Daffodil to hold the driver's configuration.\n *\n * @docs-private\n */\n token: DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG,\n /**\n * Provider function for {@link DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG}.\n */\n provider: provideDaffExternalRouterDriverInMemoryConfig,\n} = createConfigInjectionToken<DaffExternalRouterDriverInMemoryConfig>(undefined, 'DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG', {\n factory: () => ({\n resolver: (url: string): DaffExternallyResolvableUrl => {\n const ROUTEABLE_OBJECTS: DaffInMemoryRoutableObjects = inject(DAFF_INMEMORY_ROUTABLE_OBJECTS);\n if(!ROUTEABLE_OBJECTS.has(url)) {\n return null;\n }\n return {\n id: ROUTEABLE_OBJECTS.get(url).url,\n code: 200,\n type: ROUTEABLE_OBJECTS.get(url).type,\n url: ROUTEABLE_OBJECTS.get(url).url,\n };\n },\n }),\n});\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\nimport {\n Observable,\n of,\n throwError,\n} from 'rxjs';\n\nimport {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouterNotFoundError,\n} from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverInMemoryConfig,\n DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG,\n} from './config';\n\n/**\n * The DaffExternalRouterInMemoryDriver is responsible for resolving\n * a URL using the resolver in the provided configuration.\n *\n * @inheritdoc\n *\n * @see {@link DaffExternalRouterInMemoryDriver}\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterInMemoryDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n @Inject(DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG)\n private configuration: DaffExternalRouterDriverInMemoryConfig,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n const truncatedUrl = daffUriTruncateQueryFragment(url);\n const resolvedUrl = this.configuration.resolver(truncatedUrl);\n\n if (!resolvedUrl?.url) {\n return throwError(() => new DaffExternalRouterNotFoundError());\n }\n\n return of({\n ...resolvedUrl,\n url: daffUriTruncateLeadingSlash(resolvedUrl.url),\n });\n }\n}\n","import {\n EnvironmentProviders,\n InjectionToken,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverInMemoryConfig,\n provideDaffExternalRouterDriverInMemoryConfig,\n} from './config';\nimport { DaffExternalRouterInMemoryDriver } from './in-memory.service';\n\n/**\n * Provides an in-memory implementation of {@link DaffExternalRouterDriver}\n */\nexport const provideDaffExternalRouterInMemoryDriver = (config:\n DaffExternalRouterDriverInMemoryConfig | InjectionToken<DaffExternalRouterDriverInMemoryConfig> = undefined,\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterInMemoryDriver),\n config ? provideDaffExternalRouterDriverInMemoryConfig(config) : [],\n]);\n"],"mappings":";;;;;;;;AAsBA,MAAa,EAMX,OAAO,8CAIP,UAAU,kDACR,2BAAmE,QAAW,gDAAgD,EAChI,gBAAgB,EACd,WAAW,QAA4C;CACrD,MAAM,oBAAiD,OAAO,8BAA8B;CAC5F,IAAG,CAAC,kBAAkB,IAAI,GAAG,GAC3B,OAAO;CAET,OAAO;EACL,IAAI,kBAAkB,IAAI,GAAG,CAAC,CAAC;EAC/B,MAAM;EACN,MAAM,kBAAkB,IAAI,GAAG,CAAC,CAAC;EACjC,KAAK,kBAAkB,IAAI,GAAG,CAAC,CAAC;CACjC;AACH,EACD,GACF,CAAA;ACZD,IAAa,mCAAb,MAAa,iCAAgC;CAE3C,YAEU,eAAqD;EAArD,KAAA,gBAAA;CACP;CAEH,QAAQ,KAAW;EACjB,MAAM,eAAe,6BAA6B,GAAG;EACrD,MAAM,cAAc,KAAK,cAAc,SAAS,YAAY;EAE5D,IAAI,CAAC,aAAa,KAChB,OAAO,iBAAiB,IAAI,gCAA+B,CAAE;EAG/D,OAAO,GAAG;GACR,GAAG;GACH,KAAK,4BAA4B,YAAY,GAAG;EACjD,CAAA;CACH;CAnBW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAgC,MAAA,CAAA,EAAA,OAGjC,6CAA4C,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAH3C;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAgC,YAF/B;EAAM,CAAA;CAAA;;AAEP,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgC,YAAA,CAAA;EAH5C,MAAA;EAAW,MAAA,CAAA,EACV,YAAY,OACb,CAAA;;;;;GAII,MAAA;GAAO,MAAA,CAAA,4CAA4C;;;;ACtBxD,MAAa,2CAA2C,SAC+C,WAC5E,yBAAyB,CAClD,gCAAgC,gCAAgC,GAChE,SAAS,8CAA8C,MAAM,IAAI,CAAA,CAClE,CAAA"}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { Injectable, NgModule } from
|
|
3
|
-
import * as i1 from
|
|
4
|
-
import { gql } from
|
|
5
|
-
import { map } from
|
|
6
|
-
import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from
|
|
7
|
-
import {
|
|
8
|
-
import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from
|
|
9
|
-
import { magentoTransformRedirectToHttpCode } from
|
|
10
|
-
import { CommonModule } from
|
|
11
|
-
import { provideDaffMagentoCacheableOperation } from
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
/**
|
|
15
|
-
* This query retrieves a URL resolution from Magento and informs you about
|
|
16
|
-
* what type of route the URL is.
|
|
17
|
-
*/
|
|
18
|
-
const MagentoResolveUrlv241 = gql `
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Injectable, NgModule, makeEnvironmentProviders } from "@angular/core";
|
|
3
|
+
import * as i1 from "apollo-angular";
|
|
4
|
+
import { gql } from "apollo-angular";
|
|
5
|
+
import { map } from "rxjs/operators";
|
|
6
|
+
import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from "@daffodil/core/routing";
|
|
7
|
+
import { DaffExternalRouterClientError, DaffExternalRouterNotFoundError, DaffExternalRouterServerError } from "@daffodil/external-router";
|
|
8
|
+
import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from "@daffodil/external-router/driver";
|
|
9
|
+
import { magentoTransformRedirectToHttpCode } from "@daffodil/external-router/driver/magento";
|
|
10
|
+
import { CommonModule } from "@angular/common";
|
|
11
|
+
import { provideDaffMagentoCacheableOperation } from "@daffodil/driver/magento/2.4.7";
|
|
12
|
+
const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = "MagentoResolveUrlv241";
|
|
13
|
+
const MagentoResolveUrlv241 = gql`
|
|
19
14
|
query ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {
|
|
20
15
|
urlResolver(url: $url) {
|
|
21
16
|
id
|
|
@@ -25,104 +20,108 @@ const MagentoResolveUrlv241 = gql `
|
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
22
|
`;
|
|
23
|
+
const transformResolutionToResolvableUrlv241 = (resolution) => resolution ? {
|
|
24
|
+
id: resolution.id?.toString(),
|
|
25
|
+
url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),
|
|
26
|
+
type: resolution.type,
|
|
27
|
+
code: magentoTransformRedirectToHttpCode(resolution.redirectCode)
|
|
28
|
+
} : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION;
|
|
29
|
+
var DaffExternalRouterMagentoDriver = class DaffExternalRouterMagentoDriver {
|
|
30
|
+
constructor(apollo) {
|
|
31
|
+
this.apollo = apollo;
|
|
32
|
+
}
|
|
33
|
+
resolve(url) {
|
|
34
|
+
return this.apollo.query({
|
|
35
|
+
query: MagentoResolveUrlv241,
|
|
36
|
+
variables: { url: daffUriTruncateQueryFragment(url) }
|
|
37
|
+
}).pipe(map((response) => transformResolutionToResolvableUrlv241(response.data.urlResolver)), map((resolution) => {
|
|
38
|
+
if (!resolution || resolution.code === 404) throw new DaffExternalRouterNotFoundError();
|
|
39
|
+
if (resolution.code >= 400 && resolution.code < 500) throw new DaffExternalRouterClientError();
|
|
40
|
+
if (resolution.code >= 500) throw new DaffExternalRouterServerError();
|
|
41
|
+
return resolution;
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
static {
|
|
45
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
46
|
+
minVersion: "12.0.0",
|
|
47
|
+
version: "22.2.4",
|
|
48
|
+
ngImport: i0,
|
|
49
|
+
type: DaffExternalRouterMagentoDriver,
|
|
50
|
+
deps: [{ token: i1.Apollo }],
|
|
51
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
static {
|
|
55
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
56
|
+
minVersion: "12.0.0",
|
|
57
|
+
version: "22.2.4",
|
|
58
|
+
ngImport: i0,
|
|
59
|
+
type: DaffExternalRouterMagentoDriver,
|
|
60
|
+
providedIn: "root"
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
65
|
+
minVersion: "12.0.0",
|
|
66
|
+
version: "22.2.4",
|
|
67
|
+
ngImport: i0,
|
|
68
|
+
type: DaffExternalRouterMagentoDriver,
|
|
69
|
+
decorators: [{
|
|
70
|
+
type: Injectable,
|
|
71
|
+
args: [{ providedIn: "root" }]
|
|
72
|
+
}],
|
|
73
|
+
ctorParameters: () => [{ type: i1.Apollo }]
|
|
74
|
+
});
|
|
75
|
+
const provideDaffExternalRouterMagentoDriver = () => makeEnvironmentProviders([provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver), provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME)]);
|
|
76
|
+
var DaffExternalRouterDriverMagentoModule = class DaffExternalRouterDriverMagentoModule {
|
|
77
|
+
static forRoot() {
|
|
78
|
+
return {
|
|
79
|
+
ngModule: DaffExternalRouterDriverMagentoModule,
|
|
80
|
+
providers: [provideDaffExternalRouterMagentoDriver()]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static {
|
|
84
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
85
|
+
minVersion: "12.0.0",
|
|
86
|
+
version: "22.2.4",
|
|
87
|
+
ngImport: i0,
|
|
88
|
+
type: DaffExternalRouterDriverMagentoModule,
|
|
89
|
+
deps: [],
|
|
90
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
static {
|
|
94
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
95
|
+
minVersion: "14.0.0",
|
|
96
|
+
version: "22.2.4",
|
|
97
|
+
ngImport: i0,
|
|
98
|
+
type: DaffExternalRouterDriverMagentoModule,
|
|
99
|
+
imports: [CommonModule]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
static {
|
|
103
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
104
|
+
minVersion: "12.0.0",
|
|
105
|
+
version: "22.2.4",
|
|
106
|
+
ngImport: i0,
|
|
107
|
+
type: DaffExternalRouterDriverMagentoModule,
|
|
108
|
+
imports: [CommonModule]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
113
|
+
minVersion: "12.0.0",
|
|
114
|
+
version: "22.2.4",
|
|
115
|
+
ngImport: i0,
|
|
116
|
+
type: DaffExternalRouterDriverMagentoModule,
|
|
117
|
+
decorators: [{
|
|
118
|
+
type: NgModule,
|
|
119
|
+
args: [{
|
|
120
|
+
declarations: [],
|
|
121
|
+
imports: [CommonModule]
|
|
122
|
+
}]
|
|
123
|
+
}]
|
|
124
|
+
});
|
|
125
|
+
export { DaffExternalRouterDriverMagentoModule, DaffExternalRouterMagentoDriver, provideDaffExternalRouterMagentoDriver };
|
|
28
126
|
|
|
29
|
-
|
|
30
|
-
id: resolution.id?.toString(),
|
|
31
|
-
url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),
|
|
32
|
-
type: resolution.type,
|
|
33
|
-
code: magentoTransformRedirectToHttpCode(resolution.redirectCode),
|
|
34
|
-
} : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The DaffExternalRouterMagentoDriver is responsible for translating an
|
|
38
|
-
* arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.
|
|
39
|
-
*
|
|
40
|
-
* @inheritdoc
|
|
41
|
-
*/
|
|
42
|
-
class DaffExternalRouterMagentoDriver {
|
|
43
|
-
constructor(apollo) {
|
|
44
|
-
this.apollo = apollo;
|
|
45
|
-
}
|
|
46
|
-
resolve(url) {
|
|
47
|
-
return this.apollo
|
|
48
|
-
.query({
|
|
49
|
-
query: MagentoResolveUrlv241,
|
|
50
|
-
variables: {
|
|
51
|
-
url: daffUriTruncateQueryFragment(url),
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
.pipe(map(response => transformResolutionToResolvableUrlv241(response.data.urlResolver)), map((resolution) => {
|
|
55
|
-
if (!resolution || resolution.code === 404) {
|
|
56
|
-
throw new DaffExternalRouterNotFoundError();
|
|
57
|
-
}
|
|
58
|
-
if (resolution.code >= 400 && resolution.code < 500) {
|
|
59
|
-
throw new DaffExternalRouterClientError();
|
|
60
|
-
}
|
|
61
|
-
if (resolution.code >= 500) {
|
|
62
|
-
throw new DaffExternalRouterServerError();
|
|
63
|
-
}
|
|
64
|
-
return resolution;
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterMagentoDriver, deps: [{ token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
68
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterMagentoDriver, providedIn: 'root' }); }
|
|
69
|
-
}
|
|
70
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterMagentoDriver, decorators: [{
|
|
71
|
-
type: Injectable,
|
|
72
|
-
args: [{
|
|
73
|
-
providedIn: 'root',
|
|
74
|
-
}]
|
|
75
|
-
}], ctorParameters: () => [{ type: i1.Apollo }] });
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```ts
|
|
82
|
-
* @NgModule({
|
|
83
|
-
* declarations: [],
|
|
84
|
-
* imports: [
|
|
85
|
-
* ...
|
|
86
|
-
* DaffExternalRouterDriverMagentoModule.forRoot()
|
|
87
|
-
* ],
|
|
88
|
-
* })
|
|
89
|
-
* export class AppModule{}
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.
|
|
93
|
-
*/
|
|
94
|
-
class DaffExternalRouterDriverMagentoModule {
|
|
95
|
-
/**
|
|
96
|
-
* Configures the package for the root injector.
|
|
97
|
-
*/
|
|
98
|
-
static forRoot() {
|
|
99
|
-
return {
|
|
100
|
-
ngModule: DaffExternalRouterDriverMagentoModule,
|
|
101
|
-
providers: [
|
|
102
|
-
provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
|
|
103
|
-
provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
|
|
104
|
-
],
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
108
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, imports: [CommonModule] }); }
|
|
109
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, imports: [CommonModule] }); }
|
|
110
|
-
}
|
|
111
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, decorators: [{
|
|
112
|
-
type: NgModule,
|
|
113
|
-
args: [{
|
|
114
|
-
declarations: [],
|
|
115
|
-
imports: [CommonModule],
|
|
116
|
-
}]
|
|
117
|
-
}] });
|
|
118
|
-
|
|
119
|
-
/*
|
|
120
|
-
* Public API Surface of @daffodil/external-router/driver/magento/2.4.1
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Generated bundle index. Do not edit.
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
export { DaffExternalRouterDriverMagentoModule, DaffExternalRouterMagentoDriver };
|
|
128
|
-
//# sourceMappingURL=daffodil-external-router-driver-magento-2.4.1.mjs.map
|
|
127
|
+
//# sourceMappingURL=daffodil-external-router-driver-magento-2.4.1.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daffodil-external-router-driver-magento-2.4.1.mjs","sources":["../../../libs/external-router/driver/magento/2.4.1/src/graphql/queries/resolve-url-v2.4.1.ts","../../../libs/external-router/driver/magento/2.4.1/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.1/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.1/src/
|
|
1
|
+
{"version":3,"file":"daffodil-external-router-driver-magento-2.4.1.mjs","names":[],"sources":["../../../libs/external-router/driver/magento/2.4.1/src/graphql/queries/resolve-url-v2.4.1.ts","../../../libs/external-router/driver/magento/2.4.1/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.1/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.1/src/provider.ts","../../../libs/external-router/driver/magento/2.4.1/src/magento.module.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv241';\n\n/**\n * This query retrieves a URL resolution from Magento and informs you about\n * what type of route the URL is.\n */\nexport const MagentoResolveUrlv241 = gql`\n\tquery ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {\n\t\turlResolver(url: $url) {\n\t\t\tid\n\t\t\trelative_url\n\t\t\tredirectCode\n\t\t\ttype\n\t\t}\n\t}\n`;\n","import {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from '@daffodil/external-router/driver';\nimport {\n MagentoUrlResolver,\n magentoTransformRedirectToHttpCode,\n} from '@daffodil/external-router/driver/magento';\n\nexport const transformResolutionToResolvableUrlv241 = (\n resolution: MagentoUrlResolver,\n): DaffExternallyResolvableUrl => (resolution ? {\n id: resolution.id?.toString(),\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirectCode),\n} : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport { daffUriTruncateQueryFragment } from '@daffodil/core/routing';\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouterClientError,\n DaffExternalRouterNotFoundError,\n DaffExternalRouterServerError,\n} from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoUrlResolverResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv241 } from './graphql/queries/resolve-url-v2.4.1';\nimport { transformResolutionToResolvableUrlv241 } from './transforms/resolution-to-resolvable-url';\n\n/**\n * The DaffExternalRouterMagentoDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterMagentoDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(private apollo: Apollo) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n return this.apollo\n .query<MagentoUrlResolverResponse>({\n query: MagentoResolveUrlv241,\n variables: {\n url: daffUriTruncateQueryFragment(url),\n },\n })\n .pipe(\n map(response => transformResolutionToResolvableUrlv241(response.data.urlResolver)),\n map((resolution) => {\n if (!resolution || resolution.code === 404) {\n throw new DaffExternalRouterNotFoundError();\n }\n\n if (resolution.code >= 400 && resolution.code < 500) {\n throw new DaffExternalRouterClientError();\n }\n\n if (resolution.code >= 500) {\n throw new DaffExternalRouterServerError();\n }\n\n return resolution;\n }),\n );\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento/2.4.7';\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve-url-v2.4.1';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * Provides a Magento v2.4.1 implementation of {@link DaffExternalRouterDriver}.\n *\n * @deprecated This version of Magento is unsupported. Use `@daffodil/external-router/driver/magento/2.4.3` instead. Deprecated in version 0.95.0. Will be removed in version 0.98.0.\n */\nexport const provideDaffExternalRouterMagentoDriver = (\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n]);\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\n\nimport { provideDaffExternalRouterMagentoDriver } from './provider';\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * @example\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n *\n * @deprecated prefer {@link provideDaffExternalRouterMagentoDriver}. Deprecated in version 0.95.0. Will be removed in version 0.98.0.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n provideDaffExternalRouterMagentoDriver(),\n ],\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA,MAAa,sCAAsC;AAMnD,MAAa,wBAAwB,GAAG;SAC/B,oCAAmC;;;;;;;;;ACE5C,MAAa,0CACX,eACiC,aAAa;CAC9C,IAAI,WAAW,IAAI,SAAQ;CAC3B,KAAK,4BAA4B,6BAA6B,WAAW,YAAY,CAAC;CACtF,MAAM,WAAW;CACjB,MAAM,mCAAmC,WAAW,YAAY;AACjE,IAAG;ACSJ,IAAa,kCAAb,MAAa,gCAA+B;CAE1C,YAAoB,QAAc;EAAd,KAAA,SAAA;CAAiB;CAErC,QAAQ,KAAW;EACjB,OAAO,KAAK,OACT,MAAkC;GACjC,OAAO;GACP,WAAW,EACT,KAAK,6BAA6B,GAAG,EACtC;EACF,CAAA,CAAC,CACD,KACC,KAAI,aAAY,uCAAuC,SAAS,KAAK,WAAW,CAAC,GACjF,KAAK,eAAc;GACjB,IAAI,CAAC,cAAc,WAAW,SAAS,KACrC,MAAM,IAAI,gCAA+B;GAG3C,IAAI,WAAW,QAAQ,OAAO,WAAW,OAAO,KAC9C,MAAM,IAAI,8BAA6B;GAGzC,IAAI,WAAW,QAAQ,KACrB,MAAM,IAAI,8BAA6B;GAGzC,OAAO;EACT,CAAC,CAAC;CAER;CA9BW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAA+B,MAAA,CAAA,EAAA,OAAA,GAAA,OAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAA/B;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAA+B,YAF9B;EAAM,CAAA;CAAA;;AAEP,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAA+B,YAAA,CAAA;EAH3C,MAAA;EAAW,MAAA,CAAA,EACV,YAAY,OACb,CAAA;;;;ACVD,MAAa,+CACc,yBAAyB,CAClD,gCAAgC,+BAA+B,GAC/D,qCAAqC,mCAAmC,CACzE,CAAA;ACWD,IAAa,wCAAb,MAAa,sCAAqC;CAKhD,OAAO,UAAO;EACZ,OAAO;GACL,UAAU;GACV,WAAW,CACT,uCAAsC,CACvC;EACF;CACH;CAZW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAqC,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAArC;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAqC,SAAA,CAFtC,YAAY;EAAA,CAAA;CAAA;CAEX;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAqC,SAAA,CAFtC,YAAY;EAAA,CAAA;CAAA;;AAEX,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAqC,YAAA,CAAA;EAJjD,MAAA;EAAS,MAAA,CAAA;GACR,cAAc,CAAA;GACd,SAAS,CAAC,YAAY;EACvB,CAAA"}
|