@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.
Files changed (34) hide show
  1. package/fesm2022/daffodil-external-router-driver-in-memory.mjs +70 -88
  2. package/fesm2022/daffodil-external-router-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs +117 -118
  4. package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs.map +1 -1
  5. package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs +117 -118
  6. package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs.map +1 -1
  7. package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs +216 -266
  8. package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs.map +1 -1
  9. package/fesm2022/daffodil-external-router-driver-magento-auto.mjs +7 -0
  10. package/fesm2022/daffodil-external-router-driver-magento-auto.mjs.map +1 -0
  11. package/fesm2022/daffodil-external-router-driver-magento.mjs +6 -18
  12. package/fesm2022/daffodil-external-router-driver-magento.mjs.map +1 -1
  13. package/fesm2022/daffodil-external-router-driver-shopify.mjs +49 -39
  14. package/fesm2022/daffodil-external-router-driver-shopify.mjs.map +1 -1
  15. package/fesm2022/daffodil-external-router-driver-testing.mjs +118 -115
  16. package/fesm2022/daffodil-external-router-driver-testing.mjs.map +1 -1
  17. package/fesm2022/daffodil-external-router-driver.mjs +8 -32
  18. package/fesm2022/daffodil-external-router-driver.mjs.map +1 -1
  19. package/fesm2022/daffodil-external-router-routing.mjs +31 -66
  20. package/fesm2022/daffodil-external-router-routing.mjs.map +1 -1
  21. package/fesm2022/daffodil-external-router.mjs +37 -81
  22. package/fesm2022/daffodil-external-router.mjs.map +1 -1
  23. package/package.json +1 -1
  24. package/types/daffodil-external-router-driver-in-memory.d.ts +15 -21
  25. package/types/daffodil-external-router-driver-magento-2.4.1.d.ts +29 -25
  26. package/types/daffodil-external-router-driver-magento-2.4.2.d.ts +29 -25
  27. package/types/daffodil-external-router-driver-magento-2.4.3.d.ts +25 -28
  28. package/types/daffodil-external-router-driver-magento-auto.d.ts +1 -0
  29. package/types/daffodil-external-router-driver-magento.d.ts +251 -263
  30. package/types/daffodil-external-router-driver-shopify.d.ts +10 -14
  31. package/types/daffodil-external-router-driver-testing.d.ts +22 -27
  32. package/types/daffodil-external-router-driver.d.ts +12 -19
  33. package/types/daffodil-external-router-routing.d.ts +4 -7
  34. package/types/daffodil-external-router.d.ts +72 -86
@@ -1,21 +1,16 @@
1
- import * as i0 from '@angular/core';
2
- import { DOCUMENT, Inject, 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 { DaffExternalRouterNotFoundError, DaffExternalRouterClientError, DaffExternalRouterServerError } from '@daffodil/external-router';
7
- import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
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';
12
-
13
- const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv243';
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 MagentoResolveUrlv243 = gql `
1
+ import * as i0 from "@angular/core";
2
+ import { DOCUMENT, Inject, 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 { DaffExternalRouterClientError, DaffExternalRouterNotFoundError, DaffExternalRouterServerError } from "@daffodil/external-router";
7
+ import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from "@daffodil/core/routing";
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 = "MagentoResolveUrlv243";
13
+ const MagentoResolveUrlv243 = gql`
19
14
  query ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {
20
15
  route(url: $url) {
21
16
  relative_url
@@ -112,271 +107,226 @@ const MagentoResolveUrlv243 = gql `
112
107
  }
113
108
  }
114
109
  `;
115
-
116
- /**
117
- * Rescales a rating value from it's max rating
118
- * to a scale of 5.
119
- */
120
- const rescaleRatingOutOf5 = (rating, max) => (((rating ?? 0) / max) * 5).toPrecision(2);
121
-
110
+ const rescaleRatingOutOf5 = (rating, max) => ((rating ?? 0) / max * 5).toPrecision(2);
122
111
  const transformMagentoBaseProduct = (product) => ({
123
- '@context': 'https://schema.org/',
124
- '@type': 'Product',
125
- url: product.canonical_url,
126
- sku: product.sku,
127
- name: product.meta_title ?? product.name ?? '',
128
- ...(product.meta_description && { description: product.meta_description }),
129
- ...(product.review_count > 0 && { aggregateRating: {
130
- '@type': 'AggregateRating',
131
- ratingValue: rescaleRatingOutOf5(product.rating_summary, 100),
132
- reviewCount: product.review_count,
133
- } }),
134
- image: product.image?.url,
112
+ "@context": "https://schema.org/",
113
+ "@type": "Product",
114
+ url: product.canonical_url,
115
+ sku: product.sku,
116
+ name: product.meta_title ?? product.name ?? "",
117
+ ...product.meta_description && { description: product.meta_description },
118
+ ...product.review_count > 0 && { aggregateRating: {
119
+ "@type": "AggregateRating",
120
+ ratingValue: rescaleRatingOutOf5(product.rating_summary, 100),
121
+ reviewCount: product.review_count
122
+ } },
123
+ image: product.image?.url
135
124
  });
136
-
137
125
  const transformMagentoBundleProduct = (resolution) => ({
138
- ...transformMagentoBaseProduct(resolution),
139
- offers: {
140
- '@type': 'AggregateOffer',
141
- lowPrice: resolution.price_range.minimum_price.final_price.value,
142
- highPrice: resolution.price_range.maximum_price.final_price.value,
143
- priceCurrency: resolution.price_range.maximum_price.final_price.currency,
144
- },
126
+ ...transformMagentoBaseProduct(resolution),
127
+ offers: {
128
+ "@type": "AggregateOffer",
129
+ lowPrice: resolution.price_range.minimum_price.final_price.value,
130
+ highPrice: resolution.price_range.maximum_price.final_price.value,
131
+ priceCurrency: resolution.price_range.maximum_price.final_price.currency
132
+ }
145
133
  });
146
-
147
134
  const transformMagentoConfigurableProduct = (resolution) => ({
148
- ...transformMagentoBaseProduct(resolution),
149
- offers: {
150
- '@type': 'AggregateOffer',
151
- lowPrice: resolution.price_range.minimum_price.final_price.value,
152
- highPrice: resolution.price_range.maximum_price.final_price.value,
153
- priceCurrency: resolution.price_range.maximum_price.final_price.currency,
154
- },
135
+ ...transformMagentoBaseProduct(resolution),
136
+ offers: {
137
+ "@type": "AggregateOffer",
138
+ lowPrice: resolution.price_range.minimum_price.final_price.value,
139
+ highPrice: resolution.price_range.maximum_price.final_price.value,
140
+ priceCurrency: resolution.price_range.maximum_price.final_price.currency
141
+ }
155
142
  });
156
-
157
143
  const transformMagentoSimpleProduct = (resolution) => ({
158
- ...transformMagentoBaseProduct(resolution),
159
- offers: {
160
- '@type': 'Offer',
161
- url: resolution.canonical_url,
162
- ...(resolution.stock_status && {
163
- availability: resolution.stock_status === 'IN_STOCK' ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
164
- }),
165
- priceSpecification: [
166
- {
167
- '@type': 'UnitPriceSpecification',
168
- price: resolution.price_range.maximum_price.final_price.value,
169
- priceCurrency: resolution.price_range.maximum_price.final_price.currency,
170
- },
171
- {
172
- '@type': 'UnitPriceSpecification',
173
- priceType: 'https://schema.org/ListPrice',
174
- price: resolution.price_range.maximum_price.regular_price.value,
175
- priceCurrency: resolution.price_range.maximum_price.regular_price.currency,
176
- },
177
- ],
178
- },
144
+ ...transformMagentoBaseProduct(resolution),
145
+ offers: {
146
+ "@type": "Offer",
147
+ url: resolution.canonical_url,
148
+ ...resolution.stock_status && { availability: resolution.stock_status === "IN_STOCK" ? "https://schema.org/InStock" : "https://schema.org/OutOfStock" },
149
+ priceSpecification: [{
150
+ "@type": "UnitPriceSpecification",
151
+ price: resolution.price_range.maximum_price.final_price.value,
152
+ priceCurrency: resolution.price_range.maximum_price.final_price.currency
153
+ }, {
154
+ "@type": "UnitPriceSpecification",
155
+ priceType: "https://schema.org/ListPrice",
156
+ price: resolution.price_range.maximum_price.regular_price.value,
157
+ priceCurrency: resolution.price_range.maximum_price.regular_price.currency
158
+ }]
159
+ }
179
160
  });
180
-
181
- /**
182
- * Computes supplementary SEO schema for Magento product routes.
183
- */
184
161
  const transformMagentoProductSchema = (resolution) => {
185
- switch (resolution.__typename) {
186
- case 'BundleProduct':
187
- return transformMagentoBundleProduct(resolution);
188
- case 'ConfigurableProduct':
189
- return transformMagentoConfigurableProduct(resolution);
190
- case 'SimpleProduct':
191
- return transformMagentoSimpleProduct(resolution);
192
- default:
193
- return transformMagentoBaseProduct(resolution);
194
- }
162
+ switch (resolution.__typename) {
163
+ case "BundleProduct": return transformMagentoBundleProduct(resolution);
164
+ case "ConfigurableProduct": return transformMagentoConfigurableProduct(resolution);
165
+ case "SimpleProduct": return transformMagentoSimpleProduct(resolution);
166
+ default: return transformMagentoBaseProduct(resolution);
167
+ }
195
168
  };
196
-
197
169
  const transformMagentoCategorySchema = (resolution) => ({
198
- '@context': 'https://schema.org',
199
- '@type': 'ItemList',
200
- itemListElement: resolution.products.items.map((item, index) => ({
201
- '@type': 'ListItem',
202
- position: index,
203
- item: transformMagentoProductSchema({
204
- ...item,
205
- meta_description: undefined,
206
- stock_status: undefined,
207
- }),
208
- })),
170
+ "@context": "https://schema.org",
171
+ "@type": "ItemList",
172
+ itemListElement: resolution.products.items.map((item, index) => ({
173
+ "@type": "ListItem",
174
+ position: index,
175
+ item: transformMagentoProductSchema({
176
+ ...item,
177
+ meta_description: void 0,
178
+ stock_status: void 0
179
+ })
180
+ }))
209
181
  });
210
-
211
182
  const transformMagentoPageSchema = (resolution) => ({
212
- '@context': 'https://schema.org',
213
- '@type': 'Article',
214
- headline: resolution.meta_title,
215
- description: resolution.meta_description,
183
+ "@context": "https://schema.org",
184
+ "@type": "Article",
185
+ headline: resolution.meta_title,
186
+ description: resolution.meta_description
216
187
  });
217
-
218
188
  const transformSchema = (resolution) => {
219
- switch (resolution.type) {
220
- case 'PRODUCT':
221
- return transformMagentoProductSchema(resolution);
222
- case 'CATEGORY':
223
- return transformMagentoCategorySchema(resolution);
224
- case 'CMS_PAGE':
225
- return transformMagentoPageSchema(resolution);
226
- default:
227
- return null;
228
- }
189
+ switch (resolution.type) {
190
+ case "PRODUCT": return transformMagentoProductSchema(resolution);
191
+ case "CATEGORY": return transformMagentoCategorySchema(resolution);
192
+ case "CMS_PAGE": return transformMagentoPageSchema(resolution);
193
+ default: return null;
194
+ }
229
195
  };
230
-
231
- const transformResolutionToResolvableUrlv243 = (resolution) => resolution?.type && resolution.type !== 'UNKNOWN'
232
- ? {
233
- id: resolution.type === 'CMS_PAGE' ? resolution.identifier : resolution.uid,
234
- url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),
235
- type: resolution.type,
236
- code: magentoTransformRedirectToHttpCode(resolution.redirect_code),
237
- data: {
238
- canonical_url: resolution.type === 'CMS_PAGE' ? resolution.url_key : resolution.canonical_url,
239
- title: resolution.type === 'CMS_PAGE'
240
- ? resolution.meta_title ?? resolution.title ?? ''
241
- : resolution.meta_title ?? resolution.name ?? '',
242
- meta_description: resolution.meta_description,
243
- schema: {
244
- ...transformSchema(resolution),
245
- },
246
- },
247
- }
248
- : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION;
249
-
196
+ const transformResolutionToResolvableUrlv243 = (resolution) => resolution?.type && resolution.type !== "UNKNOWN" ? {
197
+ id: resolution.type === "CMS_PAGE" ? resolution.identifier : resolution.uid,
198
+ url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),
199
+ type: resolution.type,
200
+ code: magentoTransformRedirectToHttpCode(resolution.redirect_code),
201
+ data: {
202
+ canonical_url: resolution.type === "CMS_PAGE" ? resolution.url_key : resolution.canonical_url,
203
+ title: resolution.type === "CMS_PAGE" ? resolution.meta_title ?? resolution.title ?? "" : resolution.meta_title ?? resolution.name ?? "",
204
+ meta_description: resolution.meta_description,
205
+ schema: { ...transformSchema(resolution) }
206
+ }
207
+ } : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION;
250
208
  const clientifyUrlPath = (path, domain) => path ? new URL(path, domain).toString() : path;
251
-
252
209
  const transformClientUrls = (route, origin) => {
253
- if (!route) {
254
- return route;
255
- }
256
- switch (route.type) {
257
- case 'CATEGORY':
258
- return {
259
- ...route,
260
- canonical_url: clientifyUrlPath(route.canonical_url, origin),
261
- products: {
262
- items: route.products.items.map((product) => ({
263
- ...product,
264
- canonical_url: clientifyUrlPath(product.canonical_url, origin),
265
- })),
266
- },
267
- };
268
- case 'PRODUCT':
269
- return {
270
- ...route,
271
- canonical_url: clientifyUrlPath(route.canonical_url, origin),
272
- };
273
- default:
274
- return route;
275
- }
210
+ if (!route) return route;
211
+ switch (route.type) {
212
+ case "CATEGORY": return {
213
+ ...route,
214
+ canonical_url: clientifyUrlPath(route.canonical_url, origin),
215
+ products: { items: route.products.items.map((product) => ({
216
+ ...product,
217
+ canonical_url: clientifyUrlPath(product.canonical_url, origin)
218
+ })) }
219
+ };
220
+ case "PRODUCT": return {
221
+ ...route,
222
+ canonical_url: clientifyUrlPath(route.canonical_url, origin)
223
+ };
224
+ default: return route;
225
+ }
276
226
  };
277
-
278
- /**
279
- * The DaffExternalRouterMagentoDriver is responsible for translating an
280
- * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.
281
- *
282
- * @inheritdoc
283
- */
284
- class DaffExternalRouterMagentoDriver {
285
- constructor(apollo, document) {
286
- this.apollo = apollo;
287
- this.document = document;
288
- }
289
- resolve(url) {
290
- return this.apollo
291
- .query({
292
- query: MagentoResolveUrlv243,
293
- variables: {
294
- url,
295
- },
296
- })
297
- .pipe(map((response) => response.data.route), map((route) => transformClientUrls(route, this.document.location.origin)), map(route => transformResolutionToResolvableUrlv243(route)), map((resolution) => {
298
- if (!resolution || resolution.code === 404) {
299
- throw new DaffExternalRouterNotFoundError();
300
- }
301
- if (resolution.code >= 400 && resolution.code < 500) {
302
- throw new DaffExternalRouterClientError();
303
- }
304
- if (resolution.code >= 500) {
305
- throw new DaffExternalRouterServerError();
306
- }
307
- return resolution;
308
- }));
309
- }
310
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterMagentoDriver, deps: [{ token: i1.Apollo }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
311
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterMagentoDriver, providedIn: 'root' }); }
312
- }
313
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterMagentoDriver, decorators: [{
314
- type: Injectable,
315
- args: [{
316
- providedIn: 'root',
317
- }]
318
- }], ctorParameters: () => [{ type: i1.Apollo }, { type: Document, decorators: [{
319
- type: Inject,
320
- args: [DOCUMENT]
321
- }] }] });
322
-
323
- /**
324
- * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.
325
- *
326
- * @example
327
- * ```ts
328
- * @NgModule({
329
- * declarations: [],
330
- * imports: [
331
- * ...
332
- * DaffExternalRouterDriverMagentoModule.forRoot()
333
- * ],
334
- * })
335
- * export class AppModule{}
336
- * ```
337
- *
338
- * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.
339
- */
340
- class DaffExternalRouterDriverMagentoModule {
341
- /**
342
- * Configures the package for the root injector.
343
- */
344
- static forRoot() {
345
- return {
346
- ngModule: DaffExternalRouterDriverMagentoModule,
347
- providers: [
348
- provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
349
- provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
350
- ],
351
- };
352
- }
353
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
354
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, imports: [CommonModule] }); }
355
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, imports: [CommonModule] }); }
356
- }
357
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverMagentoModule, decorators: [{
358
- type: NgModule,
359
- args: [{
360
- declarations: [],
361
- imports: [CommonModule],
362
- }]
363
- }] });
364
-
365
- /**
366
- * Provides a Magento implementation of {@link DaffExternalRouterDriver}.
367
- */
368
- const provideDaffExternalRouterMagentoDriver = () => makeEnvironmentProviders([
369
- provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
370
- provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
371
- ]);
372
-
373
- /*
374
- * Public API Surface of @daffodil/external-router/driver/magento/2.4.3
375
- */
376
-
377
- /**
378
- * Generated bundle index. Do not edit.
379
- */
380
-
227
+ var DaffExternalRouterMagentoDriver = class DaffExternalRouterMagentoDriver {
228
+ constructor(apollo, document) {
229
+ this.apollo = apollo;
230
+ this.document = document;
231
+ }
232
+ resolve(url) {
233
+ return this.apollo.query({
234
+ query: MagentoResolveUrlv243,
235
+ variables: { url }
236
+ }).pipe(map((response) => response.data.route), map((route) => transformClientUrls(route, this.document.location.origin)), map((route) => transformResolutionToResolvableUrlv243(route)), map((resolution) => {
237
+ if (!resolution || resolution.code === 404) throw new DaffExternalRouterNotFoundError();
238
+ if (resolution.code >= 400 && resolution.code < 500) throw new DaffExternalRouterClientError();
239
+ if (resolution.code >= 500) throw new DaffExternalRouterServerError();
240
+ return resolution;
241
+ }));
242
+ }
243
+ static {
244
+ this.ɵfac = i0.ɵɵngDeclareFactory({
245
+ minVersion: "12.0.0",
246
+ version: "22.2.4",
247
+ ngImport: i0,
248
+ type: DaffExternalRouterMagentoDriver,
249
+ deps: [{ token: i1.Apollo }, { token: DOCUMENT }],
250
+ target: i0.ɵɵFactoryTarget.Injectable
251
+ });
252
+ }
253
+ static {
254
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
255
+ minVersion: "12.0.0",
256
+ version: "22.2.4",
257
+ ngImport: i0,
258
+ type: DaffExternalRouterMagentoDriver,
259
+ providedIn: "root"
260
+ });
261
+ }
262
+ };
263
+ i0.ɵɵngDeclareClassMetadata({
264
+ minVersion: "12.0.0",
265
+ version: "22.2.4",
266
+ ngImport: i0,
267
+ type: DaffExternalRouterMagentoDriver,
268
+ decorators: [{
269
+ type: Injectable,
270
+ args: [{ providedIn: "root" }]
271
+ }],
272
+ ctorParameters: () => [{ type: i1.Apollo }, {
273
+ type: Document,
274
+ decorators: [{
275
+ type: Inject,
276
+ args: [DOCUMENT]
277
+ }]
278
+ }]
279
+ });
280
+ const provideDaffExternalRouterMagentoDriver = () => makeEnvironmentProviders([provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver), provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME)]);
281
+ var DaffExternalRouterDriverMagentoModule = class DaffExternalRouterDriverMagentoModule {
282
+ static forRoot() {
283
+ return {
284
+ ngModule: DaffExternalRouterDriverMagentoModule,
285
+ providers: [provideDaffExternalRouterMagentoDriver()]
286
+ };
287
+ }
288
+ static {
289
+ this.ɵfac = i0.ɵɵngDeclareFactory({
290
+ minVersion: "12.0.0",
291
+ version: "22.2.4",
292
+ ngImport: i0,
293
+ type: DaffExternalRouterDriverMagentoModule,
294
+ deps: [],
295
+ target: i0.ɵɵFactoryTarget.NgModule
296
+ });
297
+ }
298
+ static {
299
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
300
+ minVersion: "14.0.0",
301
+ version: "22.2.4",
302
+ ngImport: i0,
303
+ type: DaffExternalRouterDriverMagentoModule,
304
+ imports: [CommonModule]
305
+ });
306
+ }
307
+ static {
308
+ this.ɵinj = i0.ɵɵngDeclareInjector({
309
+ minVersion: "12.0.0",
310
+ version: "22.2.4",
311
+ ngImport: i0,
312
+ type: DaffExternalRouterDriverMagentoModule,
313
+ imports: [CommonModule]
314
+ });
315
+ }
316
+ };
317
+ i0.ɵɵngDeclareClassMetadata({
318
+ minVersion: "12.0.0",
319
+ version: "22.2.4",
320
+ ngImport: i0,
321
+ type: DaffExternalRouterDriverMagentoModule,
322
+ decorators: [{
323
+ type: NgModule,
324
+ args: [{
325
+ declarations: [],
326
+ imports: [CommonModule]
327
+ }]
328
+ }]
329
+ });
381
330
  export { DaffExternalRouterDriverMagentoModule, DaffExternalRouterMagentoDriver, provideDaffExternalRouterMagentoDriver };
382
- //# sourceMappingURL=daffodil-external-router-driver-magento-2.4.3.mjs.map
331
+
332
+ //# sourceMappingURL=daffodil-external-router-driver-magento-2.4.3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver-magento-2.4.3.mjs","sources":["../../../libs/external-router/driver/magento/2.4.3/src/graphql/queries/resolve.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/rescale-rating.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/base.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/bundle.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/configurable.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/simple.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/product.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/category/category.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/page/page.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/transform-schema.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/clientify-url-path.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/transform-client-urls.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.module.ts","../../../libs/external-router/driver/magento/2.4.3/src/provider.ts","../../../libs/external-router/driver/magento/2.4.3/src/public_api.ts","../../../libs/external-router/driver/magento/2.4.3/src/daffodil-external-router-driver-magento-2.4.3.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv243';\n\n/**\n * This query retrieves a URL resolution from Magento and informs you about\n * what type of route the URL is.\n */\nexport const MagentoResolveUrlv243 = gql`\n\tquery ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {\n\t\troute(url: $url) {\n\t\t\trelative_url\n\t\t\tredirect_code\n\t\t\ttype\n\t\t\t... on CmsPage {\n\t\t\t\tidentifier\n\t\t\t\ttitle\n\t\t\t\tcontent\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\turl_key\n\t\t\t}\n\t\t\t... on CategoryInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_title\n\t\t\t\tmeta_description\n\t\t\t\tcanonical_url\n\t\t\t\tproducts {\n\t\t\t\t\titems {\n\t\t\t\t\t\tuid\n\t\t\t\t\t\tname\n\t\t\t\t\t\tmeta_description\n\t\t\t\t\t\tmeta_title\n\t\t\t\t\t\tcanonical_url\n\t\t\t\t\t\tsku\n\t\t\t\t\t\treview_count\n\t\t\t\t\t\trating_summary\n\t\t\t\t\t\timage {\n\t\t\t\t\t\t\turl\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprice_range {\n\t\t\t\t\t\t\tminimum_price {\n\t\t\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t... on ProductInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t\tsku\n\t\t\t\treview_count\n\t\t\t\trating_summary\n\t\t\t\timage {\n\t\t\t\t\turl\n\t\t\t\t}\n\t\t\t\tstock_status\n\t\t\t\tprice_range {\n\t\t\t\t\tminimum_price {\n\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n`;\n","/**\n * Rescales a rating value from it's max rating\n * to a scale of 5.\n */\nexport const rescaleRatingOutOf5 = (rating: number | null, max: number) => (((rating ?? 0)/max) * 5).toPrecision(2);\n","import { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { rescaleRatingOutOf5 } from '../rescale-rating';\n\nexport const transformMagentoBaseProduct = (product: MagentoProductRoute): Record<string, unknown> => ({\n '@context': 'https://schema.org/',\n '@type': 'Product',\n url: product.canonical_url,\n sku: product.sku,\n name: product.meta_title ?? product.name ?? '',\n ...(product.meta_description && { description: product.meta_description }),\n ...(product.review_count > 0 && { aggregateRating: {\n '@type': 'AggregateRating',\n ratingValue: rescaleRatingOutOf5(product.rating_summary, 100),\n reviewCount: product.review_count,\n }}),\n image: product.image?.url,\n});\n","import { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoBaseProduct } from './base';\n\nexport const transformMagentoBundleProduct = (resolution: MagentoProductRoute): Record<string, unknown> => ({\n ...transformMagentoBaseProduct(resolution),\n offers: {\n '@type': 'AggregateOffer',\n lowPrice: resolution.price_range.minimum_price.final_price.value,\n highPrice: resolution.price_range.maximum_price.final_price.value,\n priceCurrency: resolution.price_range.maximum_price.final_price.currency,\n },\n});\n","import { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoBaseProduct } from './base';\n\nexport const transformMagentoConfigurableProduct = (resolution: MagentoProductRoute): Record<string, unknown> => ({\n ...transformMagentoBaseProduct(resolution),\n offers: {\n '@type': 'AggregateOffer',\n lowPrice: resolution.price_range.minimum_price.final_price.value,\n highPrice: resolution.price_range.maximum_price.final_price.value,\n priceCurrency: resolution.price_range.maximum_price.final_price.currency,\n },\n});\n","\nimport { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoBaseProduct } from './base';\n\nexport const transformMagentoSimpleProduct = (resolution: MagentoProductRoute): Record<string, unknown> => ({\n ...transformMagentoBaseProduct(resolution),\n offers: {\n '@type': 'Offer',\n url: resolution.canonical_url,\n ...(resolution.stock_status && {\n availability: resolution.stock_status === 'IN_STOCK' ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',\n }),\n priceSpecification: [\n {\n '@type': 'UnitPriceSpecification',\n price: resolution.price_range.maximum_price.final_price.value,\n priceCurrency: resolution.price_range.maximum_price.final_price.currency,\n },\n {\n '@type': 'UnitPriceSpecification',\n priceType: 'https://schema.org/ListPrice',\n price: resolution.price_range.maximum_price.regular_price.value,\n priceCurrency: resolution.price_range.maximum_price.regular_price.currency,\n },\n ],\n },\n});\n","import { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoBaseProduct } from './base';\nimport { transformMagentoBundleProduct } from './bundle';\nimport { transformMagentoConfigurableProduct } from './configurable';\nimport { transformMagentoSimpleProduct } from './simple';\n\n/**\n * Computes supplementary SEO schema for Magento product routes.\n */\nexport const transformMagentoProductSchema = (resolution: MagentoProductRoute): Record<string, unknown> => {\n switch(resolution.__typename) {\n case 'BundleProduct':\n return transformMagentoBundleProduct(resolution);\n case 'ConfigurableProduct':\n return transformMagentoConfigurableProduct(resolution);\n case 'SimpleProduct':\n return transformMagentoSimpleProduct(resolution);\n default:\n return transformMagentoBaseProduct(resolution);\n }\n};\n","import { MagentoCategoryRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoProductSchema } from '../product/product';\n\nexport const transformMagentoCategorySchema = (resolution: MagentoCategoryRoute): Record<string, unknown> => ({\n '@context': 'https://schema.org',\n '@type': 'ItemList',\n itemListElement: resolution.products.items.map((item, index) => ({\n '@type': 'ListItem',\n position: index,\n item: transformMagentoProductSchema({\n ...item,\n meta_description: undefined,\n stock_status: undefined,\n }),\n })),\n});\n","import { MagentoCmsPageRoute } from '@daffodil/external-router/driver/magento';\n\nexport const transformMagentoPageSchema = (resolution: MagentoCmsPageRoute): Record<string, unknown> => ({\n '@context': 'https://schema.org',\n '@type': 'Article',\n headline: resolution.meta_title,\n description: resolution.meta_description,\n});\n","import { MagentoRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoCategorySchema } from './category/category';\nimport { transformMagentoPageSchema } from './page/page';\nimport { transformMagentoProductSchema } from './product/product';\n\nexport const transformSchema = (resolution: MagentoRoute): Record<string, any> | null => {\n switch(resolution.type) {\n case 'PRODUCT':\n return transformMagentoProductSchema(resolution);\n case 'CATEGORY':\n return transformMagentoCategorySchema(resolution);\n case 'CMS_PAGE':\n return transformMagentoPageSchema(resolution);\n default:\n return null;\n }\n};\n","import {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from '@daffodil/external-router/driver';\nimport {\n magentoTransformRedirectToHttpCode,\n MagentoRoute,\n} from '@daffodil/external-router/driver/magento';\n\nimport { transformSchema } from './schema/transform-schema';\n\nexport const transformResolutionToResolvableUrlv243 = (\n resolution: MagentoRoute,\n): DaffExternallyResolvableUrl => resolution?.type && resolution.type !== 'UNKNOWN'\n ? {\n id: resolution.type === 'CMS_PAGE' ? resolution.identifier : resolution.uid,\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirect_code),\n data: {\n canonical_url: resolution.type === 'CMS_PAGE' ? resolution.url_key : resolution.canonical_url,\n title: resolution.type === 'CMS_PAGE'\n ? resolution.meta_title ?? resolution.title ?? ''\n : resolution.meta_title ?? resolution.name ?? '',\n meta_description: resolution.meta_description,\n schema: {\n ...transformSchema(resolution),\n },\n },\n }\n : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION;\n","export const clientifyUrlPath = <T extends string | null>(path: T, domain: string) => path ? new URL(path, domain).toString() : path;\n","import { MagentoRoute } from '@daffodil/external-router/driver/magento';\n\nimport { clientifyUrlPath } from './schema/clientify-url-path';\n\nexport const transformClientUrls = <T extends MagentoRoute>(route: T, origin: string) => {\n if(!route) {\n return route;\n }\n\n switch(route.type) {\n case 'CATEGORY':\n return {\n ...route,\n canonical_url: clientifyUrlPath(route.canonical_url, origin),\n products: {\n items: route.products.items.map((product) => ({\n ...product,\n canonical_url: clientifyUrlPath(product.canonical_url, origin),\n })),\n },\n };\n case 'PRODUCT':\n return {\n ...route,\n canonical_url: clientifyUrlPath(route.canonical_url, origin),\n };\n default:\n return route;\n }\n};\n","\nimport {\n Inject,\n Injectable,\n DOCUMENT,\n} from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouterClientError,\n DaffExternalRouterNotFoundError,\n DaffExternalRouterServerError,\n} from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoRouteResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv243 } from './graphql/queries/resolve';\nimport { transformResolutionToResolvableUrlv243 } from './transforms/resolution-to-resolvable-url';\nimport { transformClientUrls } from './transforms/transform-client-urls';\n\n\n/**\n * The DaffExternalRouterMagentoDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterMagentoDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n private apollo: Apollo,\n @Inject(DOCUMENT) private document: Document,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n return this.apollo\n .query<MagentoRouteResponse>({\n query: MagentoResolveUrlv243,\n variables: {\n url,\n },\n })\n .pipe(\n map((response) => response.data.route),\n map((route) => transformClientUrls(route, this.document.location.origin)),\n map(route => transformResolutionToResolvableUrlv243(route)),\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 { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * @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@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n ],\n };\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * Provides a Magento implementation of {@link DaffExternalRouterDriver}.\n */\nexport const provideDaffExternalRouterMagentoDriver = (\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n]);\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2.4.3\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\nexport { provideDaffExternalRouterMagentoDriver } from './provider';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG,uBAAuB;AAE1E;;;AAGG;AACI,MAAM,qBAAqB,GAAG,GAAG,CAAA;SAC/B,mCAAmC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+F3C;;ACxGD;;;AAGG;AACI,MAAM,mBAAmB,GAAG,CAAC,MAAqB,EAAE,GAAW,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,IAAE,GAAG,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;;ACA5G,MAAM,2BAA2B,GAAG,CAAC,OAA4B,MAA+B;AACrG,IAAA,UAAU,EAAE,qBAAqB;AACjC,IAAA,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,OAAO,CAAC,aA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A;AAEX,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA;;2FAEX,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA;;;ACrBD;;AAEG;MACU,sCAAsC,GAAG,MAC3B,wBAAwB,CAAC;IAClD,+BAA+B,CAAC,+BAA+B,CAAC;IAChE,oCAAoC,CAAC,mCAAmC,CAAC;AAC1E,CAAA;;AClBD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver-magento-2.4.3.mjs","names":[],"sources":["../../../libs/external-router/driver/magento/2.4.3/src/graphql/queries/resolve.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/rescale-rating.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/base.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/bundle.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/configurable.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/simple.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/product/product.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/category/category.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/page/page.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/transform-schema.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/schema/clientify-url-path.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/transform-client-urls.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.3/src/provider.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.module.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv243';\n\n/**\n * This query retrieves a URL resolution from Magento and informs you about\n * what type of route the URL is.\n */\nexport const MagentoResolveUrlv243 = gql`\n\tquery ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {\n\t\troute(url: $url) {\n\t\t\trelative_url\n\t\t\tredirect_code\n\t\t\ttype\n\t\t\t... on CmsPage {\n\t\t\t\tidentifier\n\t\t\t\ttitle\n\t\t\t\tcontent\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\turl_key\n\t\t\t}\n\t\t\t... on CategoryInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_title\n\t\t\t\tmeta_description\n\t\t\t\tcanonical_url\n\t\t\t\tproducts {\n\t\t\t\t\titems {\n\t\t\t\t\t\tuid\n\t\t\t\t\t\tname\n\t\t\t\t\t\tmeta_description\n\t\t\t\t\t\tmeta_title\n\t\t\t\t\t\tcanonical_url\n\t\t\t\t\t\tsku\n\t\t\t\t\t\treview_count\n\t\t\t\t\t\trating_summary\n\t\t\t\t\t\timage {\n\t\t\t\t\t\t\turl\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprice_range {\n\t\t\t\t\t\t\tminimum_price {\n\t\t\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t... on ProductInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t\tsku\n\t\t\t\treview_count\n\t\t\t\trating_summary\n\t\t\t\timage {\n\t\t\t\t\turl\n\t\t\t\t}\n\t\t\t\tstock_status\n\t\t\t\tprice_range {\n\t\t\t\t\tminimum_price {\n\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n`;\n","/**\n * Rescales a rating value from it's max rating\n * to a scale of 5.\n */\nexport const rescaleRatingOutOf5 = (rating: number | null, max: number) => (((rating ?? 0)/max) * 5).toPrecision(2);\n","import { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { rescaleRatingOutOf5 } from '../rescale-rating';\n\nexport const transformMagentoBaseProduct = (product: MagentoProductRoute): Record<string, unknown> => ({\n '@context': 'https://schema.org/',\n '@type': 'Product',\n url: product.canonical_url,\n sku: product.sku,\n name: product.meta_title ?? product.name ?? '',\n ...(product.meta_description && { description: product.meta_description }),\n ...(product.review_count > 0 && { aggregateRating: {\n '@type': 'AggregateRating',\n ratingValue: rescaleRatingOutOf5(product.rating_summary, 100),\n reviewCount: product.review_count,\n }}),\n image: product.image?.url,\n});\n","import { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoBaseProduct } from './base';\n\nexport const transformMagentoBundleProduct = (resolution: MagentoProductRoute): Record<string, unknown> => ({\n ...transformMagentoBaseProduct(resolution),\n offers: {\n '@type': 'AggregateOffer',\n lowPrice: resolution.price_range.minimum_price.final_price.value,\n highPrice: resolution.price_range.maximum_price.final_price.value,\n priceCurrency: resolution.price_range.maximum_price.final_price.currency,\n },\n});\n","import { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoBaseProduct } from './base';\n\nexport const transformMagentoConfigurableProduct = (resolution: MagentoProductRoute): Record<string, unknown> => ({\n ...transformMagentoBaseProduct(resolution),\n offers: {\n '@type': 'AggregateOffer',\n lowPrice: resolution.price_range.minimum_price.final_price.value,\n highPrice: resolution.price_range.maximum_price.final_price.value,\n priceCurrency: resolution.price_range.maximum_price.final_price.currency,\n },\n});\n","\nimport { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoBaseProduct } from './base';\n\nexport const transformMagentoSimpleProduct = (resolution: MagentoProductRoute): Record<string, unknown> => ({\n ...transformMagentoBaseProduct(resolution),\n offers: {\n '@type': 'Offer',\n url: resolution.canonical_url,\n ...(resolution.stock_status && {\n availability: resolution.stock_status === 'IN_STOCK' ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',\n }),\n priceSpecification: [\n {\n '@type': 'UnitPriceSpecification',\n price: resolution.price_range.maximum_price.final_price.value,\n priceCurrency: resolution.price_range.maximum_price.final_price.currency,\n },\n {\n '@type': 'UnitPriceSpecification',\n priceType: 'https://schema.org/ListPrice',\n price: resolution.price_range.maximum_price.regular_price.value,\n priceCurrency: resolution.price_range.maximum_price.regular_price.currency,\n },\n ],\n },\n});\n","import { MagentoProductRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoBaseProduct } from './base';\nimport { transformMagentoBundleProduct } from './bundle';\nimport { transformMagentoConfigurableProduct } from './configurable';\nimport { transformMagentoSimpleProduct } from './simple';\n\n/**\n * Computes supplementary SEO schema for Magento product routes.\n */\nexport const transformMagentoProductSchema = (resolution: MagentoProductRoute): Record<string, unknown> => {\n switch(resolution.__typename) {\n case 'BundleProduct':\n return transformMagentoBundleProduct(resolution);\n case 'ConfigurableProduct':\n return transformMagentoConfigurableProduct(resolution);\n case 'SimpleProduct':\n return transformMagentoSimpleProduct(resolution);\n default:\n return transformMagentoBaseProduct(resolution);\n }\n};\n","import { MagentoCategoryRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoProductSchema } from '../product/product';\n\nexport const transformMagentoCategorySchema = (resolution: MagentoCategoryRoute): Record<string, unknown> => ({\n '@context': 'https://schema.org',\n '@type': 'ItemList',\n itemListElement: resolution.products.items.map((item, index) => ({\n '@type': 'ListItem',\n position: index,\n item: transformMagentoProductSchema({\n ...item,\n meta_description: undefined,\n stock_status: undefined,\n }),\n })),\n});\n","import { MagentoCmsPageRoute } from '@daffodil/external-router/driver/magento';\n\nexport const transformMagentoPageSchema = (resolution: MagentoCmsPageRoute): Record<string, unknown> => ({\n '@context': 'https://schema.org',\n '@type': 'Article',\n headline: resolution.meta_title,\n description: resolution.meta_description,\n});\n","import { MagentoRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoCategorySchema } from './category/category';\nimport { transformMagentoPageSchema } from './page/page';\nimport { transformMagentoProductSchema } from './product/product';\n\nexport const transformSchema = (resolution: MagentoRoute): Record<string, any> | null => {\n switch(resolution.type) {\n case 'PRODUCT':\n return transformMagentoProductSchema(resolution);\n case 'CATEGORY':\n return transformMagentoCategorySchema(resolution);\n case 'CMS_PAGE':\n return transformMagentoPageSchema(resolution);\n default:\n return null;\n }\n};\n","import {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from '@daffodil/external-router/driver';\nimport {\n magentoTransformRedirectToHttpCode,\n MagentoRoute,\n} from '@daffodil/external-router/driver/magento';\n\nimport { transformSchema } from './schema/transform-schema';\n\nexport const transformResolutionToResolvableUrlv243 = (\n resolution: MagentoRoute,\n): DaffExternallyResolvableUrl => resolution?.type && resolution.type !== 'UNKNOWN'\n ? {\n id: resolution.type === 'CMS_PAGE' ? resolution.identifier : resolution.uid,\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirect_code),\n data: {\n canonical_url: resolution.type === 'CMS_PAGE' ? resolution.url_key : resolution.canonical_url,\n title: resolution.type === 'CMS_PAGE'\n ? resolution.meta_title ?? resolution.title ?? ''\n : resolution.meta_title ?? resolution.name ?? '',\n meta_description: resolution.meta_description,\n schema: {\n ...transformSchema(resolution),\n },\n },\n }\n : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION;\n","export const clientifyUrlPath = <T extends string | null>(path: T, domain: string) => path ? new URL(path, domain).toString() : path;\n","import { MagentoRoute } from '@daffodil/external-router/driver/magento';\n\nimport { clientifyUrlPath } from './schema/clientify-url-path';\n\nexport const transformClientUrls = <T extends MagentoRoute>(route: T, origin: string) => {\n if(!route) {\n return route;\n }\n\n switch(route.type) {\n case 'CATEGORY':\n return {\n ...route,\n canonical_url: clientifyUrlPath(route.canonical_url, origin),\n products: {\n items: route.products.items.map((product) => ({\n ...product,\n canonical_url: clientifyUrlPath(product.canonical_url, origin),\n })),\n },\n };\n case 'PRODUCT':\n return {\n ...route,\n canonical_url: clientifyUrlPath(route.canonical_url, origin),\n };\n default:\n return route;\n }\n};\n","\nimport {\n Inject,\n Injectable,\n DOCUMENT,\n} from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouterClientError,\n DaffExternalRouterNotFoundError,\n DaffExternalRouterServerError,\n} from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoRouteResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv243 } from './graphql/queries/resolve';\nimport { transformResolutionToResolvableUrlv243 } from './transforms/resolution-to-resolvable-url';\nimport { transformClientUrls } from './transforms/transform-client-urls';\n\n\n/**\n * The DaffExternalRouterMagentoDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterMagentoDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n private apollo: Apollo,\n @Inject(DOCUMENT) private document: Document,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n return this.apollo\n .query<MagentoRouteResponse>({\n query: MagentoResolveUrlv243,\n variables: {\n url,\n },\n })\n .pipe(\n map((response) => response.data.route),\n map((route) => transformClientUrls(route, this.document.location.origin)),\n map(route => transformResolutionToResolvableUrlv243(route)),\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';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * Provides a Magento implementation of {@link DaffExternalRouterDriver}.\n */\nexport const provideDaffExternalRouterMagentoDriver = (\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n]);\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterMagentoDriver } from './provider';\n\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACL5C,MAAa,uBAAuB,QAAuB,UAAmB,UAAU,KAAG,MAAO,EAAA,CAAG,YAAY,CAAC;ACAlH,MAAa,+BAA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