@daffodil/external-router 0.78.0 → 0.80.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 (133) hide show
  1. package/README.md +116 -7
  2. package/config.d.ts +1 -10
  3. package/driver/in-memory/config.d.ts +1 -7
  4. package/driver/in-memory/in-memory.module.d.ts +2 -0
  5. package/driver/in-memory/provider.d.ts +6 -0
  6. package/driver/in-memory/public_api.d.ts +1 -0
  7. package/driver/interfaces/external-router-driver.interface.d.ts +2 -6
  8. package/driver/magento/2.4.3/magento.service.d.ts +2 -1
  9. package/driver/magento/2.4.3/provider.d.ts +5 -0
  10. package/driver/magento/2.4.3/public_api.d.ts +1 -0
  11. package/driver/magento/2.4.3/transforms/schema/category/category.d.ts +2 -0
  12. package/driver/magento/2.4.3/transforms/schema/clientify-url-path.d.ts +1 -0
  13. package/driver/magento/2.4.3/transforms/schema/product/base.d.ts +2 -0
  14. package/driver/magento/2.4.3/transforms/schema/product/bundle.d.ts +2 -0
  15. package/driver/magento/2.4.3/transforms/schema/product/configurable.d.ts +2 -0
  16. package/driver/magento/2.4.3/transforms/schema/product/product.d.ts +5 -0
  17. package/driver/magento/2.4.3/transforms/schema/product/simple.d.ts +2 -0
  18. package/driver/magento/2.4.3/transforms/schema/rescale-rating.d.ts +5 -0
  19. package/driver/magento/2.4.3/transforms/schema/transform-schema.d.ts +2 -0
  20. package/driver/magento/2.4.3/transforms/transform-client-urls.d.ts +2 -0
  21. package/driver/magento/model/category-route-product.d.ts +77 -0
  22. package/driver/magento/model/category-route.d.ts +41 -0
  23. package/driver/magento/model/product-route.d.ts +85 -0
  24. package/driver/magento/model/public_api.d.ts +2 -0
  25. package/driver/magento/model/routable.d.ts +14 -0
  26. package/driver/magento/model/route.d.ts +4 -34
  27. package/driver/public_api.d.ts +1 -1
  28. package/driver/testing/config.d.ts +3 -9
  29. package/driver/testing/provider.d.ts +6 -0
  30. package/driver/testing/public_api.d.ts +1 -0
  31. package/esm2022/config.mjs +8 -7
  32. package/esm2022/driver/in-memory/config.mjs +8 -6
  33. package/esm2022/driver/in-memory/in-memory.module.mjs +8 -15
  34. package/esm2022/driver/in-memory/provider.mjs +12 -0
  35. package/esm2022/driver/in-memory/public_api.mjs +2 -1
  36. package/esm2022/driver/interfaces/external-router-driver.interface.mjs +8 -3
  37. package/esm2022/driver/magento/2.4.1/magento.module.mjs +5 -12
  38. package/esm2022/driver/magento/2.4.2/magento.module.mjs +5 -12
  39. package/esm2022/driver/magento/2.4.3/graphql/queries/resolve.mjs +66 -2
  40. package/esm2022/driver/magento/2.4.3/magento.module.mjs +5 -12
  41. package/esm2022/driver/magento/2.4.3/magento.service.mjs +12 -6
  42. package/esm2022/driver/magento/2.4.3/provider.mjs +13 -0
  43. package/esm2022/driver/magento/2.4.3/public_api.mjs +2 -1
  44. package/esm2022/driver/magento/2.4.3/transforms/resolution-to-resolvable-url.mjs +7 -3
  45. package/esm2022/driver/magento/2.4.3/transforms/schema/category/category.mjs +15 -0
  46. package/esm2022/driver/magento/2.4.3/transforms/schema/clientify-url-path.mjs +2 -0
  47. package/esm2022/driver/magento/2.4.3/transforms/schema/product/base.mjs +16 -0
  48. package/esm2022/driver/magento/2.4.3/transforms/schema/product/bundle.mjs +11 -0
  49. package/esm2022/driver/magento/2.4.3/transforms/schema/product/configurable.mjs +11 -0
  50. package/esm2022/driver/magento/2.4.3/transforms/schema/product/product.mjs +20 -0
  51. package/esm2022/driver/magento/2.4.3/transforms/schema/product/simple.mjs +25 -0
  52. package/esm2022/driver/magento/2.4.3/transforms/schema/rescale-rating.mjs +6 -0
  53. package/esm2022/driver/magento/2.4.3/transforms/schema/transform-schema.mjs +13 -0
  54. package/esm2022/driver/magento/2.4.3/transforms/transform-client-urls.mjs +28 -0
  55. package/esm2022/driver/magento/model/category-route-product.mjs +2 -0
  56. package/esm2022/driver/magento/model/category-route.mjs +2 -0
  57. package/esm2022/driver/magento/model/product-route.mjs +2 -0
  58. package/esm2022/driver/magento/model/public_api.mjs +1 -1
  59. package/esm2022/driver/magento/model/routable.mjs +2 -0
  60. package/esm2022/driver/magento/model/route.mjs +1 -1
  61. package/esm2022/driver/public_api.mjs +2 -2
  62. package/esm2022/driver/testing/config.mjs +8 -6
  63. package/esm2022/driver/testing/provider.mjs +12 -0
  64. package/esm2022/driver/testing/public_api.mjs +2 -1
  65. package/esm2022/driver/testing/testing.module.mjs +5 -11
  66. package/esm2022/driver/testing/testing.service.mjs +13 -11
  67. package/esm2022/model/public_api.mjs +1 -1
  68. package/esm2022/model/route-data.mjs +1 -1
  69. package/esm2022/model/route-with-seo-data.mjs +1 -1
  70. package/esm2022/provide-external-router.mjs +6 -0
  71. package/esm2022/public_api.mjs +2 -10
  72. package/esm2022/routing/guard/external-matcher-type.guard.mjs +43 -0
  73. package/esm2022/routing/helper/convert-to-path.mjs +7 -0
  74. package/esm2022/routing/public_api.mjs +2 -2
  75. package/fesm2022/daffodil-external-router-driver-in-memory.mjs +22 -18
  76. package/fesm2022/daffodil-external-router-driver-in-memory.mjs.map +1 -1
  77. package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs +4 -11
  78. package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs.map +1 -1
  79. package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs +4 -11
  80. package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs.map +1 -1
  81. package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs +228 -21
  82. package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs.map +1 -1
  83. package/fesm2022/daffodil-external-router-driver-testing.mjs +31 -25
  84. package/fesm2022/daffodil-external-router-driver-testing.mjs.map +1 -1
  85. package/fesm2022/daffodil-external-router-driver.mjs +8 -3
  86. package/fesm2022/daffodil-external-router-driver.mjs.map +1 -1
  87. package/fesm2022/daffodil-external-router-routing.mjs +40 -66
  88. package/fesm2022/daffodil-external-router-routing.mjs.map +1 -1
  89. package/fesm2022/daffodil-external-router.mjs +10 -282
  90. package/fesm2022/daffodil-external-router.mjs.map +1 -1
  91. package/model/public_api.d.ts +2 -5
  92. package/model/route-data.d.ts +13 -0
  93. package/model/route-with-seo-data.d.ts +3 -4
  94. package/package.json +1 -1
  95. package/provide-external-router.d.ts +3 -0
  96. package/public_api.d.ts +1 -9
  97. package/routing/guard/external-matcher-type.guard.d.ts +10 -0
  98. package/routing/helper/convert-to-path.d.ts +7 -0
  99. package/routing/public_api.d.ts +1 -1
  100. package/errors/no-wildcard.d.ts +0 -9
  101. package/errors/unknown-type.d.ts +0 -9
  102. package/esm2022/errors/no-wildcard.mjs +0 -12
  103. package/esm2022/errors/unknown-type.mjs +0 -12
  104. package/esm2022/external-router.module.mjs +0 -31
  105. package/esm2022/model/insertion-strategy.type.mjs +0 -2
  106. package/esm2022/model/route-info.mjs +0 -2
  107. package/esm2022/model/route-with-data-path.mjs +0 -2
  108. package/esm2022/model/route-with-type.mjs +0 -2
  109. package/esm2022/model/route-without-path.mjs +0 -2
  110. package/esm2022/model/type-route-pair.mjs +0 -2
  111. package/esm2022/router/router.service.mjs +0 -43
  112. package/esm2022/router/strategies/insert-data-path.mjs +0 -84
  113. package/esm2022/router/strategies/insert-route-before-wildcard.mjs +0 -17
  114. package/esm2022/router/url-matcher/data-path-matcher.mjs +0 -31
  115. package/esm2022/routing/guard/existence.guard.mjs +0 -77
  116. package/esm2022/token/type-resolvable-routes.token.mjs +0 -29
  117. package/esm2022/transform/resolved-route-to-route.mjs +0 -24
  118. package/esm2022/util/extract-daff-path-data.mjs +0 -9
  119. package/external-router.module.d.ts +0 -15
  120. package/model/insertion-strategy.type.d.ts +0 -8
  121. package/model/route-info.d.ts +0 -9
  122. package/model/route-with-data-path.d.ts +0 -14
  123. package/model/route-with-type.d.ts +0 -12
  124. package/model/route-without-path.d.ts +0 -7
  125. package/model/type-route-pair.d.ts +0 -26
  126. package/router/router.service.d.ts +0 -15
  127. package/router/strategies/insert-data-path.d.ts +0 -40
  128. package/router/strategies/insert-route-before-wildcard.d.ts +0 -6
  129. package/router/url-matcher/data-path-matcher.d.ts +0 -20
  130. package/routing/guard/existence.guard.d.ts +0 -22
  131. package/token/type-resolvable-routes.token.d.ts +0 -14
  132. package/transform/resolved-route-to-route.d.ts +0 -7
  133. package/util/extract-daff-path-data.d.ts +0 -6
@@ -4,10 +4,10 @@ import * as i1 from 'apollo-angular';
4
4
  import { gql } from 'apollo-angular';
5
5
  import { map } from 'rxjs/operators';
6
6
  import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
7
- import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver } from '@daffodil/external-router/driver';
7
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
8
  import { magentoTransformRedirectToHttpCode } from '@daffodil/external-router/driver/magento';
9
9
  import { CommonModule } from '@angular/common';
10
- import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
10
+ import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
11
11
 
12
12
  const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv241';
13
13
  /**
@@ -86,15 +86,8 @@ class DaffExternalRouterDriverMagentoModule {
86
86
  return {
87
87
  ngModule: DaffExternalRouterDriverMagentoModule,
88
88
  providers: [
89
- {
90
- provide: DaffExternalRouterDriver,
91
- useExisting: DaffExternalRouterMagentoDriver,
92
- },
93
- {
94
- provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
95
- useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,
96
- multi: true,
97
- },
89
+ provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
90
+ provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
98
91
  ],
99
92
  };
100
93
  }
@@ -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/magento.module.ts","../../../libs/external-router/driver/magento/2.4.1/src/public_api.ts","../../../libs/external-router/driver/magento/2.4.1/src/daffodil-external-router-driver-magento-2.4.1.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 {\n Injectable,\n Inject,\n} 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 { DaffExternallyResolvableUrl } 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(map(response => transformResolutionToResolvableUrlv241(response.data.urlResolver)));\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';\nimport { DaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve-url-v2.4.1';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n {\n provide: DaffExternalRouterDriver,\n useExisting: DaffExternalRouterMagentoDriver,\n },\n {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,\n multi: true,\n },\n ],\n };\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2-4-1\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAE3E;;;AAGG;AACI,MAAM,qBAAqB,GAAG,GAAG,CAAA,CAAA;SAC/B,mCAAmC,CAAA;;;;;;;;CAQ3C;;ACNM,MAAM,sCAAsC,GAAG,CACpD,UAA8B,MACG,UAAU,GAAG;AAC9C,IAAA,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE;IAC7B,GAAG,EAAE,2BAA2B,CAAC,4BAA4B,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACvF,IAAI,EAAE,UAAU,CAAC,IAAI;AACrB,IAAA,IAAI,EAAE,kCAAkC,CAAC,UAAU,CAAC,YAAY,CAAC;AAClE,CAAA,GAAG,yCAAyC,CAAC;;ACF9C;;;;;AAKG;MAIU,+BAA+B,CAAA;AAE1C,IAAA,WAAA,CAAoB,MAAc,EAAA;QAAd,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;KAAI;AAEtC,IAAA,OAAO,CAAC,GAAW,EAAA;QACjB,OAAO,IAAI,CAAC,MAAM;AACf,aAAA,KAAK,CAA6B;AACjC,YAAA,KAAK,EAAE,qBAAqB;AAC5B,YAAA,SAAS,EAAE;AACT,gBAAA,GAAG,EAAE,4BAA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AA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;AAEX,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;;2FAEX,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA,CAAA;;;AC9BD;;AAEG;;ACFH;;AAEG;;;;"}
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/magento.module.ts","../../../libs/external-router/driver/magento/2.4.1/src/public_api.ts","../../../libs/external-router/driver/magento/2.4.1/src/daffodil-external-router-driver-magento-2.4.1.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 {\n Injectable,\n Inject,\n} 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 { DaffExternallyResolvableUrl } 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(map(response => transformResolutionToResolvableUrlv241(response.data.urlResolver)));\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-url-v2.4.1';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n ],\n };\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2-4-1\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAE3E;;;AAGG;AACI,MAAM,qBAAqB,GAAG,GAAG,CAAA,CAAA;SAC/B,mCAAmC,CAAA;;;;;;;;CAQ3C;;ACNM,MAAM,sCAAsC,GAAG,CACpD,UAA8B,MACG,UAAU,GAAG;AAC9C,IAAA,EAAE,EAAE,UAA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;;;;;;;;;;AAeG;MAKU,qCAAqC,CAAA;AAEhD;;AAEG;AACH,IAAA,OAAO,OAAO,GAAA;QACZ,OAAO;AACL,YAAA,QAAQ,EAAE,qCAAqC;AAC/C,YAAA,SAAS,EAAE;gBACT,+BAA+B,CAAC,+BAA+B,CAAC;gBAChE,oCAAoC,CAAC,mCAAmC,CAAC;AAC1E,aAAA;SACF,CAAC;KACH;iIAbU,qCAAqC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA,EAAA;AAArC,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;AAEX,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;;2FAEX,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA,CAAA;;;AC9BD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -4,10 +4,10 @@ import * as i1 from 'apollo-angular';
4
4
  import { gql } from 'apollo-angular';
5
5
  import { map } from 'rxjs/operators';
6
6
  import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
7
- import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver } from '@daffodil/external-router/driver';
7
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
8
  import { magentoTransformRedirectToHttpCode } from '@daffodil/external-router/driver/magento';
9
9
  import { CommonModule } from '@angular/common';
10
- import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
10
+ import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
11
11
 
12
12
  const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv242';
13
13
  /**
@@ -86,15 +86,8 @@ class DaffExternalRouterDriverMagentoModule {
86
86
  return {
87
87
  ngModule: DaffExternalRouterDriverMagentoModule,
88
88
  providers: [
89
- {
90
- provide: DaffExternalRouterDriver,
91
- useExisting: DaffExternalRouterMagentoDriver,
92
- },
93
- {
94
- provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
95
- useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,
96
- multi: true,
97
- },
89
+ provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
90
+ provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
98
91
  ],
99
92
  };
100
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver-magento-2.4.2.mjs","sources":["../../../libs/external-router/driver/magento/2.4.2/src/graphql/queries/resolve-url-v2.4.2.ts","../../../libs/external-router/driver/magento/2.4.2/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.2/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.2/src/magento.module.ts","../../../libs/external-router/driver/magento/2.4.2/src/public_api.ts","../../../libs/external-router/driver/magento/2.4.2/src/daffodil-external-router-driver-magento-2.4.2.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv242';\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 MagentoResolveUrlv242 = gql`\n\tquery ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {\n\t\turlResolver(url: $url) {\n\t\t\tentity_uid\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\n\nexport const transformResolutionToResolvableUrlv242 = (\n resolution: MagentoUrlResolver,\n): DaffExternallyResolvableUrl => (resolution ? {\n id: resolution.entity_uid,\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirectCode),\n} : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoUrlResolverResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv242 } from './graphql/queries/resolve-url-v2.4.2';\nimport { transformResolutionToResolvableUrlv242 } from './transforms/resolution-to-resolvable-url';\n\n\n/**\n * The DaffExternalRouterMagentoDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterMagentoDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n private apollo: Apollo,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n return this.apollo\n .query<MagentoUrlResolverResponse>({\n query: MagentoResolveUrlv242,\n variables: {\n url,\n },\n })\n .pipe(map(response => transformResolutionToResolvableUrlv242(response.data.urlResolver)));\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';\nimport { DaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve-url-v2.4.2';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n {\n provide: DaffExternalRouterDriver,\n useExisting: DaffExternalRouterMagentoDriver,\n },\n {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,\n multi: true,\n },\n ],\n };\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2.4.2\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG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AA;;;AC/BD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver-magento-2.4.2.mjs","sources":["../../../libs/external-router/driver/magento/2.4.2/src/graphql/queries/resolve-url-v2.4.2.ts","../../../libs/external-router/driver/magento/2.4.2/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.2/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.2/src/magento.module.ts","../../../libs/external-router/driver/magento/2.4.2/src/public_api.ts","../../../libs/external-router/driver/magento/2.4.2/src/daffodil-external-router-driver-magento-2.4.2.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv242';\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 MagentoResolveUrlv242 = gql`\n\tquery ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {\n\t\turlResolver(url: $url) {\n\t\t\tentity_uid\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\n\nexport const transformResolutionToResolvableUrlv242 = (\n resolution: MagentoUrlResolver,\n): DaffExternallyResolvableUrl => (resolution ? {\n id: resolution.entity_uid,\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirectCode),\n} : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoUrlResolverResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv242 } from './graphql/queries/resolve-url-v2.4.2';\nimport { transformResolutionToResolvableUrlv242 } from './transforms/resolution-to-resolvable-url';\n\n\n/**\n * The DaffExternalRouterMagentoDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterMagentoDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n private apollo: Apollo,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n return this.apollo\n .query<MagentoUrlResolverResponse>({\n query: MagentoResolveUrlv242,\n variables: {\n url,\n },\n })\n .pipe(map(response => transformResolutionToResolvableUrlv242(response.data.urlResolver)));\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-url-v2.4.2';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n ],\n };\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2.4.2\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAE3E;;;AAGG;AACI,MAAM,qBAAqB,GAAG,GAAG,CAAA,CAAA;SAC/B,mCAAmC,CAAA;;;;;;;;CAQ3C;;ACLM,MAAM,sCAAsC,GAAG,CACpD,UAA8B,MACG,UAAU,GAAG;IAC9C,EAAE,EAAE,UAAU,CAAC,UAAU;IACzB,GAAG,EAAE,2BAA2B,CAAC,4BAA4B,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACvF,IAAI,EAAE,UAAU,CAAC,IAAI;AACrB,IAAA,IAAI,EAAE,kCAAkC,CAAC,UAAU,CAAC,YAAY,CAAC;AAClE,CAAA,GAAG,yCAAyC,CAAC;;ACL9C;;;;;AAKG;MAIU,+BAA+B,CAAA;AAE1C,IAAA,WAAA,CACU,MAAc,EAAA;QAAd,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;KACpB;AAEJ,IAAA,OAAO,CAAC,GAAW,EAAA;QACjB,OAAO,IAAI,CAAC,MAAM;AACf,aAAA,KAAK,CAA6B;AACjC,YAAA,KAAK,EAAE,qBAAqB;AAC5B,YAAA,SAAS,EAAE;gBACT,GAAG;AACJ,aAAA;SACF,CAAC;AACD,aAAA,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,sCAAsC,CAAC,QAAQ,CAAC,IAAI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AAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;;2FAEX,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA,CAAA;;;AC/BD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,13 +1,13 @@
1
+ import { DOCUMENT, CommonModule } from '@angular/common';
1
2
  import * as i0 from '@angular/core';
2
- import { Injectable, NgModule } from '@angular/core';
3
+ import { Injectable, Inject, NgModule, makeEnvironmentProviders } from '@angular/core';
3
4
  import * as i1 from 'apollo-angular';
4
5
  import { gql } from 'apollo-angular';
5
6
  import { map } from 'rxjs/operators';
6
7
  import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
7
- import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
9
  import { magentoTransformRedirectToHttpCode } from '@daffodil/external-router/driver/magento';
9
- import { CommonModule } from '@angular/common';
10
- import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
10
+ import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
11
11
 
12
12
  const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv243';
13
13
  /**
@@ -23,9 +23,44 @@ const MagentoResolveUrlv243 = gql `
23
23
  ... on CategoryInterface {
24
24
  uid
25
25
  name
26
- meta_description
27
26
  meta_title
28
27
  canonical_url
28
+ products {
29
+ items {
30
+ name
31
+ meta_description
32
+ meta_title
33
+ canonical_url
34
+ sku
35
+ review_count
36
+ rating_summary
37
+ image {
38
+ url
39
+ }
40
+ price_range {
41
+ minimum_price {
42
+ regular_price {
43
+ currency
44
+ value
45
+ }
46
+ final_price {
47
+ currency
48
+ value
49
+ }
50
+ }
51
+ maximum_price {
52
+ regular_price {
53
+ currency
54
+ value
55
+ }
56
+ final_price {
57
+ currency
58
+ value
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
29
64
  }
30
65
  ... on ProductInterface {
31
66
  uid
@@ -33,23 +68,190 @@ const MagentoResolveUrlv243 = gql `
33
68
  meta_description
34
69
  meta_title
35
70
  canonical_url
71
+ sku
72
+ review_count
73
+ rating_summary
74
+ image {
75
+ url
76
+ }
77
+ stock_status
78
+ price_range {
79
+ minimum_price {
80
+ regular_price {
81
+ currency
82
+ value
83
+ }
84
+ final_price {
85
+ currency
86
+ value
87
+ }
88
+ }
89
+ maximum_price {
90
+ regular_price {
91
+ currency
92
+ value
93
+ }
94
+ final_price {
95
+ currency
96
+ value
97
+ }
98
+ }
99
+ }
36
100
  }
37
101
  }
38
102
  }
39
103
  `;
40
104
 
41
- const transformResolutionToResolvableUrlv243 = (resolution) => (resolution ? {
105
+ /**
106
+ * Rescales a rating value from it's max rating
107
+ * to a scale of 5.
108
+ */
109
+ const rescaleRatingOutOf5 = (rating, max) => (((rating ?? 0) / max) * 5).toPrecision(2);
110
+
111
+ const transformMagentoBaseProduct = (product) => ({
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,
124
+ });
125
+
126
+ const transformMagentoBundleProduct = (resolution) => ({
127
+ ...transformMagentoBaseProduct(resolution),
128
+ offers: {
129
+ '@type': 'AggregateOffer',
130
+ lowPrice: resolution.price_range.minimum_price.final_price.value,
131
+ highPrice: resolution.price_range.maximum_price.final_price.value,
132
+ priceCurrency: resolution.price_range.maximum_price.final_price.currency,
133
+ },
134
+ });
135
+
136
+ const transformMagentoConfigurableProduct = (resolution) => ({
137
+ ...transformMagentoBaseProduct(resolution),
138
+ offers: {
139
+ '@type': 'AggregateOffer',
140
+ lowPrice: resolution.price_range.minimum_price.final_price.value,
141
+ highPrice: resolution.price_range.maximum_price.final_price.value,
142
+ priceCurrency: resolution.price_range.maximum_price.final_price.currency,
143
+ },
144
+ });
145
+
146
+ const transformMagentoSimpleProduct = (resolution) => ({
147
+ ...transformMagentoBaseProduct(resolution),
148
+ offers: {
149
+ '@type': 'Offer',
150
+ url: resolution.canonical_url,
151
+ ...(resolution.stock_status && {
152
+ availability: resolution.stock_status === 'IN_STOCK' ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
153
+ }),
154
+ priceSpecification: [
155
+ {
156
+ '@type': 'UnitPriceSpecification',
157
+ price: resolution.price_range.maximum_price.final_price.value,
158
+ priceCurrency: resolution.price_range.maximum_price.final_price.currency,
159
+ },
160
+ {
161
+ '@type': 'UnitPriceSpecification',
162
+ priceType: 'https://schema.org/ListPrice',
163
+ price: resolution.price_range.maximum_price.regular_price.value,
164
+ priceCurrency: resolution.price_range.maximum_price.regular_price.currency,
165
+ },
166
+ ],
167
+ },
168
+ });
169
+
170
+ /**
171
+ * Computes supplementary SEO schema for Magento product routes.
172
+ */
173
+ const transformMagentoProductSchema = (resolution) => {
174
+ switch (resolution.__typename) {
175
+ case 'BundleProduct':
176
+ return transformMagentoBundleProduct(resolution);
177
+ case 'ConfigurableProduct':
178
+ return transformMagentoConfigurableProduct(resolution);
179
+ case 'SimpleProduct':
180
+ return transformMagentoSimpleProduct(resolution);
181
+ default:
182
+ return transformMagentoBaseProduct(resolution);
183
+ }
184
+ };
185
+
186
+ const transformMagentoCategorySchema = (resolution) => ({
187
+ '@context': 'https://schema.org',
188
+ '@type': 'ItemList',
189
+ itemListElement: resolution.products.items.map((item, index) => ({
190
+ '@type': 'ListItem',
191
+ position: index,
192
+ item: transformMagentoProductSchema({
193
+ ...item,
194
+ meta_description: undefined,
195
+ stock_status: undefined,
196
+ }),
197
+ })),
198
+ });
199
+
200
+ const transformSchema = (resolution) => {
201
+ switch (resolution.type) {
202
+ case 'PRODUCT':
203
+ return transformMagentoProductSchema(resolution);
204
+ case 'CATEGORY':
205
+ return transformMagentoCategorySchema(resolution);
206
+ default:
207
+ return null;
208
+ }
209
+ };
210
+
211
+ const transformResolutionToResolvableUrlv243 = (resolution) => (resolution && (resolution.type === 'CATEGORY' || resolution.type === 'PRODUCT') ? {
42
212
  id: resolution.uid,
43
213
  url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),
44
214
  type: resolution.type,
45
215
  code: magentoTransformRedirectToHttpCode(resolution.redirect_code),
46
216
  data: {
47
- canonical_url: resolution.canonical_url,
217
+ canonical_url: resolution?.canonical_url,
48
218
  title: resolution.meta_title ?? resolution.name ?? '',
49
219
  meta_description: resolution.meta_description,
220
+ schema: {
221
+ ...transformSchema(resolution),
222
+ },
50
223
  },
51
224
  } : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);
52
225
 
226
+ const clientifyUrlPath = (path, domain) => path ? new URL(path, domain).toString() : path;
227
+
228
+ const transformClientUrls = (route, origin) => {
229
+ if (!route) {
230
+ return route;
231
+ }
232
+ switch (route.type) {
233
+ case 'CATEGORY':
234
+ return {
235
+ ...route,
236
+ canonical_url: clientifyUrlPath(route.canonical_url, origin),
237
+ products: {
238
+ items: route.products.items.map((product) => ({
239
+ ...product,
240
+ canonical_url: clientifyUrlPath(product.canonical_url, origin),
241
+ })),
242
+ },
243
+ };
244
+ case 'PRODUCT':
245
+ return {
246
+ ...route,
247
+ canonical_url: clientifyUrlPath(route.canonical_url, origin),
248
+ };
249
+ default:
250
+ return route;
251
+ }
252
+ return route;
253
+ };
254
+
53
255
  /**
54
256
  * The DaffExternalRouterMagentoDriver is responsible for translating an
55
257
  * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.
@@ -57,8 +259,9 @@ const transformResolutionToResolvableUrlv243 = (resolution) => (resolution ? {
57
259
  * @inheritdoc
58
260
  */
59
261
  class DaffExternalRouterMagentoDriver {
60
- constructor(apollo) {
262
+ constructor(apollo, document) {
61
263
  this.apollo = apollo;
264
+ this.document = document;
62
265
  }
63
266
  resolve(url) {
64
267
  return this.apollo
@@ -68,9 +271,9 @@ class DaffExternalRouterMagentoDriver {
68
271
  url,
69
272
  },
70
273
  })
71
- .pipe(map(response => transformResolutionToResolvableUrlv243(response.data.route)));
274
+ .pipe(map((response) => response.data.route), map((route) => transformClientUrls(route, this.document.location.origin)), map(route => transformResolutionToResolvableUrlv243(route)));
72
275
  }
73
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterMagentoDriver, deps: [{ token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable }); }
276
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterMagentoDriver, deps: [{ token: i1.Apollo }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
74
277
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterMagentoDriver, providedIn: 'root' }); }
75
278
  }
76
279
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterMagentoDriver, decorators: [{
@@ -78,7 +281,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
78
281
  args: [{
79
282
  providedIn: 'root',
80
283
  }]
81
- }], ctorParameters: () => [{ type: i1.Apollo }] });
284
+ }], ctorParameters: () => [{ type: i1.Apollo }, { type: Document, decorators: [{
285
+ type: Inject,
286
+ args: [DOCUMENT]
287
+ }] }] });
82
288
 
83
289
  /**
84
290
  * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.
@@ -104,15 +310,8 @@ class DaffExternalRouterDriverMagentoModule {
104
310
  return {
105
311
  ngModule: DaffExternalRouterDriverMagentoModule,
106
312
  providers: [
107
- {
108
- provide: DaffExternalRouterDriver,
109
- useExisting: DaffExternalRouterMagentoDriver,
110
- },
111
- {
112
- provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
113
- useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,
114
- multi: true,
115
- },
313
+ provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
314
+ provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
116
315
  ],
117
316
  };
118
317
  }
@@ -128,6 +327,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
128
327
  }]
129
328
  }] });
130
329
 
330
+ /**
331
+ * Provides a Magento implementation of {@link DaffExternalRouterDriver}.
332
+ */
333
+ const provideDaffExternalRouterMagentoDriver = () => makeEnvironmentProviders([
334
+ provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
335
+ provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
336
+ ]);
337
+
131
338
  /*
132
339
  * Public API Surface of @daffodil/external-router/driver/magento/2.4.3
133
340
  */
@@ -136,5 +343,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
136
343
  * Generated bundle index. Do not edit.
137
344
  */
138
345
 
139
- export { DaffExternalRouterDriverMagentoModule, DaffExternalRouterMagentoDriver };
346
+ export { DaffExternalRouterDriverMagentoModule, DaffExternalRouterMagentoDriver, provideDaffExternalRouterMagentoDriver };
140
347
  //# sourceMappingURL=daffodil-external-router-driver-magento-2.4.3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver-magento-2.4.3.mjs","sources":["../../../libs/external-router/driver/magento/2.4.3/src/graphql/queries/resolve.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/resolution-to-resolvable-url.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.service.ts","../../../libs/external-router/driver/magento/2.4.3/src/magento.module.ts","../../../libs/external-router/driver/magento/2.4.3/src/public_api.ts","../../../libs/external-router/driver/magento/2.4.3/src/daffodil-external-router-driver-magento-2.4.3.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME = 'MagentoResolveUrlv243';\n\n/**\n * This query retrieves a URL resolution from Magento and informs you about\n * what type of route the URL is.\n */\nexport const MagentoResolveUrlv243 = gql`\n\tquery ${DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME}($url: String!) {\n\t\troute(url: $url) {\n\t\t\trelative_url\n\t\t\tredirect_code\n\t\t\ttype\n\t\t\t... on CategoryInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t}\n\t\t\t... on ProductInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_description\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t}\n\t\t}\n\t}\n`;\n","import {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from '@daffodil/external-router/driver';\nimport {\n magentoTransformRedirectToHttpCode,\n MagentoRoute,\n} from '@daffodil/external-router/driver/magento';\n\n\nexport const transformResolutionToResolvableUrlv243 = (\n resolution: MagentoRoute,\n): DaffExternallyResolvableUrl => (resolution ? {\n id: resolution.uid,\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirect_code),\n data: {\n canonical_url: resolution.canonical_url,\n title: resolution.meta_title ?? resolution.name ?? '',\n meta_description: resolution.meta_description,\n },\n} : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoRouteResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv243 } from './graphql/queries/resolve';\nimport { transformResolutionToResolvableUrlv243 } from './transforms/resolution-to-resolvable-url';\n\n\n/**\n * The DaffExternalRouterMagentoDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl with Magento environments.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterMagentoDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n private apollo: Apollo,\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n return this.apollo\n .query<MagentoRouteResponse>({\n query: MagentoResolveUrlv243,\n variables: {\n url,\n },\n })\n .pipe(map(response => transformResolutionToResolvableUrlv243(response.data.route)));\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';\nimport { DaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n {\n provide: DaffExternalRouterDriver,\n useExisting: DaffExternalRouterMagentoDriver,\n },\n {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,\n multi: true,\n },\n ],\n };\n }\n}\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2.4.3\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAE3E;;;AAGG;AACI,MAAM,qBAAqB,GAAG,GAAG,CAAA,CAAA;SAC/B,mCAAmC,CAAA;;;;;;;;;;;;;;;;;;;;;CAqB3C;;AClBM,MAAM,sCAAsC,GAAG,CACpD,UAAwB,MACS,UAAU,GAAG;IAC9C,EAAE,EAAE,UAAU,CAAC,GAAG;IAClB,GAAG,EAAE,2BAA2B,CAAC,4BAA4B,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACvF,IAAI,EAAE,UAAU,CAAC,IAAI;AACrB,IAAA,IAAI,EAAE,kCAAkC,CAAC,UAAU,CAAC,aAAa,CAAC;AAClE,IAAA,IAAI,EAAE;QACJ,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,KAAK,EAAE,UA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AAE;AACT,gBAAA;AACE,oBAAA,OAAO,EAAE,wBAAwB;AACjC,oBAAA,WAAW,EAAE,+BAA+B;AAC7C,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE,iCAAiC;AAC1C,oBAAA,QAAQ,EAAE,mCAAmC;AAC7C,oBAAA,KAAK,EAAE,IAAI;AACZ,iBAAA;AACF,aAAA;SACF,CAAC;KACH;iIApBU,qCAAqC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA,EAAA;AAArC,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;AAEX,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qCAAqC,YAFtC,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA;;2FAEX,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA,CAAA;;;AC/BD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver-magento-2.4.3.mjs","sources":["../../../libs/external-router/driver/magento/2.4.3/src/graphql/queries/resolve.ts","../../../libs/external-router/driver/magento/2.4.3/src/transforms/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/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 CategoryInterface {\n\t\t\t\tuid\n\t\t\t\tname\n\t\t\t\tmeta_title\n\t\t\t\tcanonical_url\n\t\t\t\tproducts {\n\t\t\t\t\titems {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t\tmeta_description\n\t\t\t\t\t\t\tmeta_title\n\t\t\t\t\t\t\tcanonical_url\n\t\t\t\t\t\t\tsku\n\t\t\t\t\t\t\treview_count\n\t\t\t\t\t\t\trating_summary\n\t\t\t\t\t\t\timage {\n\t\t\t\t\t\t\t\turl\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tprice_range {\n\t\t\t\t\t\t\t\tminimum_price {\n\t\t\t\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tfinal_price {\n\t\t\t\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t\t}\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}\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 {\n MagentoProductRoute,\n MagentoRoute,\n} 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';\nimport { rescaleRatingOutOf5 } from '../rescale-rating';\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 { MagentoRoute } from '@daffodil/external-router/driver/magento';\n\nimport { transformMagentoCategorySchema } from './category/category';\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 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 && (resolution.type === 'CATEGORY' || resolution.type ==='PRODUCT') ? {\n id: resolution.uid,\n url: daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(resolution.relative_url)),\n type: resolution.type,\n code: magentoTransformRedirectToHttpCode(resolution.redirect_code),\n data: {\n canonical_url: resolution?.canonical_url,\n title: resolution.meta_title ?? resolution.name ?? '',\n meta_description: resolution.meta_description,\n schema: {\n ...transformSchema(resolution),\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 return route;\n};\n","import { DOCUMENT } from '@angular/common';\nimport {\n Inject,\n Injectable,\n} from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\nimport { MagentoRouteResponse } from '@daffodil/external-router/driver/magento';\n\nimport { MagentoResolveUrlv243 } from './graphql/queries/resolve';\nimport { transformResolutionToResolvableUrlv243 } from './transforms/resolution-to-resolvable-url';\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 );\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * The module used to configure the {@link DaffExternalRouterDriver} for usage with Magento.\n *\n * ```ts\n * @NgModule({\n * declarations: [],\n * imports: [\n * ...\n * DaffExternalRouterDriverMagentoModule.forRoot()\n * ],\n * })\n * export class AppModule{}\n * ```\n *\n * Note that this package depends upon ApolloClient, as the Magento driver uses GraphQl to make it's API calls.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverMagentoModule {\n\n /**\n * Configures the package for the root injector.\n */\n static forRoot(): ModuleWithProviders<DaffExternalRouterDriverMagentoModule> {\n return {\n ngModule: DaffExternalRouterDriverMagentoModule,\n providers: [\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n ],\n };\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';\nimport { DaffExternalRouterMagentoDriver } from './magento.service';\n\n/**\n * Provides a Magento implementation of {@link DaffExternalRouterDriver}.\n */\nexport const provideDaffExternalRouterMagentoDriver = (\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),\n provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),\n]);\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento/2.4.3\n */\n\nexport { DaffExternalRouterMagentoDriver } from './magento.service';\nexport { DaffExternalRouterDriverMagentoModule } from './magento.module';\nexport { provideDaffExternalRouterMagentoDriver } from './provider';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEO,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAE3E;;;AAGG;AACI,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X,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAJjD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA,CAAA;;;ACpBD;;AAEG;MACU,sCAAsC,GAAG,MAC3B,wBAAwB,CAAC;IAClD,+BAA+B,CAAC,+BAA+B,CAAC;IAChE,oCAAoC,CAAC,mCAAmC,CAAC;AAC1E,CAAA;;AClBD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,20 +1,23 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core';
2
+ import { Injectable, Inject, NgModule, makeEnvironmentProviders } from '@angular/core';
3
3
  import { faker } from '@faker-js/faker/locale/en_US';
4
- import { throwError, of } from 'rxjs';
4
+ import { of } from 'rxjs';
5
5
  import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
6
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';
7
+ import { createConfigInjectionToken } from '@daffodil/core';
6
8
  import { CommonModule } from '@angular/common';
7
- import { DaffExternalRouterDriver } from '@daffodil/external-router/driver';
8
9
 
10
+ const {
9
11
  /**
10
12
  * The token used by Daffodil to hold the driver's configuration.
11
13
  *
12
14
  * @docs-private
13
15
  */
14
- const DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG = new InjectionToken('DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG', {
15
- providedIn: 'root',
16
- factory: () => ({}),
17
- });
16
+ token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,
17
+ /**
18
+ * Provider function for {@link DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG}.
19
+ */
20
+ provider: provideDaffExternalRouterDriverTestingConfig, } = createConfigInjectionToken(({}), 'DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG');
18
21
 
19
22
  /**
20
23
  * The DaffExternalRouterTestingDriver is responsible for translating an
@@ -31,16 +34,17 @@ class DaffExternalRouterTestingDriver {
31
34
  resolve(url) {
32
35
  const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));
33
36
  if (!this.testingConfiguration[truncatedUrl]) {
34
- return throwError(`\
35
- The route '${truncatedUrl}' wasn't provided with a matching type by the testing driver. \
36
- Did you configure the available route types with DaffExternalRouterDriverTestingModule.forRoot(config)`);
37
+ return of(DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);
38
+ }
39
+ if ((typeof this.testingConfiguration[truncatedUrl]) === 'string') {
40
+ return of({
41
+ id: faker.datatype.uuid(),
42
+ url: truncatedUrl,
43
+ type: this.testingConfiguration[truncatedUrl],
44
+ code: 200,
45
+ });
37
46
  }
38
- return of({
39
- id: faker.datatype.uuid(),
40
- url: truncatedUrl,
41
- type: this.testingConfiguration[truncatedUrl],
42
- code: 200,
43
- });
47
+ return of(this.testingConfiguration[truncatedUrl]);
44
48
  }
45
49
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterTestingDriver, deps: [{ token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
46
50
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DaffExternalRouterTestingDriver, providedIn: 'root' }); }
@@ -64,14 +68,8 @@ class DaffExternalRouterDriverTestingModule {
64
68
  return {
65
69
  ngModule: DaffExternalRouterDriverTestingModule,
66
70
  providers: [
67
- {
68
- provide: DaffExternalRouterDriver,
69
- useExisting: DaffExternalRouterTestingDriver,
70
- },
71
- {
72
- provide: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,
73
- useValue: config,
74
- },
71
+ provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),
72
+ provideDaffExternalRouterDriverTestingConfig(config),
75
73
  ],
76
74
  };
77
75
  }
@@ -87,6 +85,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
87
85
  }]
88
86
  }] });
89
87
 
88
+ /**
89
+ * Provides a testing implementation of {@link DaffExternalRouterDriver}
90
+ */
91
+ const provideDaffExternalRouterTestingDriver = (config) => makeEnvironmentProviders([
92
+ provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),
93
+ provideDaffExternalRouterDriverTestingConfig(config),
94
+ ]);
95
+
90
96
  /*
91
97
  * Public API Surface of @daffodil/external-router/driver/testing
92
98
  */
@@ -95,5 +101,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
95
101
  * Generated bundle index. Do not edit.
96
102
  */
97
103
 
98
- export { DaffExternalRouterDriverTestingModule, DaffExternalRouterTestingDriver };
104
+ export { DaffExternalRouterDriverTestingModule, DaffExternalRouterTestingDriver, provideDaffExternalRouterTestingDriver };
99
105
  //# sourceMappingURL=daffodil-external-router-driver-testing.mjs.map