@daffodil/product-composite 0.45.0 → 0.46.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.
@@ -1,6 +1,6 @@
1
1
  import { CommonModule } from '@angular/common';
2
2
  import { NgModule, } from '@angular/core';
3
- import { DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS, DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS, MagentoProductTypeEnum, } from '@daffodil/product/driver/magento';
3
+ import { daffProvideProductMagentoExtraProductTransforms, MagentoProductTypeEnum, daffProvideProductMagentoExtraProductFragments, daffProvideProductMagentoExtraProductPreviewTransforms, } from '@daffodil/product/driver/magento';
4
4
  import { magentoBundledProductFragment } from './fragments/bundled-product';
5
5
  import { transformMagentoBundledProduct } from './transforms/bundled-product-transformers';
6
6
  import * as i0 from "@angular/core";
@@ -12,21 +12,17 @@ export class DaffCompositeProductMagentoDriverModule {
12
12
  return {
13
13
  ngModule: DaffCompositeProductMagentoDriverModule,
14
14
  providers: [
15
- {
16
- provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS,
17
- useValue: magentoBundledProductFragment,
18
- multi: true,
19
- },
20
- {
21
- provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS,
22
- // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
23
- useValue(daffProduct, magentoProduct) {
24
- return magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
25
- ? transformMagentoBundledProduct(daffProduct, magentoProduct)
26
- : daffProduct;
27
- },
28
- multi: true,
29
- },
15
+ ...daffProvideProductMagentoExtraProductFragments(magentoBundledProductFragment),
16
+ ...daffProvideProductMagentoExtraProductTransforms((daffProduct, magentoProduct) => magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
17
+ ? transformMagentoBundledProduct(daffProduct, magentoProduct)
18
+ : daffProduct),
19
+ // stub out composite fields for a preview
20
+ ...daffProvideProductMagentoExtraProductPreviewTransforms((daffProduct, magentoProduct) => magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
21
+ ? {
22
+ ...daffProduct,
23
+ items: [],
24
+ }
25
+ : daffProduct),
30
26
  ],
31
27
  };
32
28
  }
@@ -44,4 +40,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
44
40
  ],
45
41
  }]
46
42
  }] });
47
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcG9zaXRlLXByb2R1Y3QtZHJpdmVyLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvcHJvZHVjdC1jb21wb3NpdGUvZHJpdmVyL21hZ2VudG8vc3JjL2NvbXBvc2l0ZS1wcm9kdWN0LWRyaXZlci5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQy9DLE9BQU8sRUFDTCxRQUFRLEdBRVQsTUFBTSxlQUFlLENBQUM7QUFFdkIsT0FBTyxFQUNMLG9EQUFvRCxFQUNwRCxxREFBcUQsRUFDckQsc0JBQXNCLEdBQ3ZCLE1BQU0sa0NBQWtDLENBQUM7QUFFMUMsT0FBTyxFQUFFLDZCQUE2QixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDNUUsT0FBTyxFQUFFLDhCQUE4QixFQUFFLE1BQU0sMkNBQTJDLENBQUM7O0FBRTNGOztHQUVHO0FBTUgsTUFBTSxPQUFPLHVDQUF1QztJQUNsRCxNQUFNLENBQUMsT0FBTztRQUNaLE9BQU87WUFDTCxRQUFRLEVBQUUsdUNBQXVDO1lBQ2pELFNBQVMsRUFBRTtnQkFDVDtvQkFDRSxPQUFPLEVBQUUsb0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UHJvZHVjdFByZXZpZXdUcmFuc2Zvcm1zPE1hZ2VudG9CdW5kbGVkUHJvZHVjdD4oXG4gICAgICAgICAgKGRhZmZQcm9kdWN0LCBtYWdlbnRvUHJvZHVjdCkgPT5cbiAgICAgICAgICAgIG1hZ2VudG9Qcm9kdWN0Ll9fdHlwZW5hbWUgPT09IE1hZ2VudG9Qcm9kdWN0VHlwZUVudW0uQnVuZGxlZFByb2R1Y3RcbiAgICAgICAgICAgICAgPyB7XG4gICAgICAgICAgICAgICAgLi4uZGFmZlByb2R1Y3QsXG4gICAgICAgICAgICAgICAgaXRlbXM6IFtdLFxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIDogZGFmZlByb2R1Y3QsXG4gICAgICAgICksXG4gICAgICBdLFxuICAgIH07XG4gIH1cbn1cbiJdfQ==
@@ -2,7 +2,7 @@ import { gql } from 'apollo-angular';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
4
  import { NgModule } from '@angular/core';
5
- import { MagentoProductStockStatusEnum, DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS, DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS, MagentoProductTypeEnum } from '@daffodil/product/driver/magento';
5
+ import { MagentoProductStockStatusEnum, daffProvideProductMagentoExtraProductFragments, daffProvideProductMagentoExtraProductTransforms, MagentoProductTypeEnum, daffProvideProductMagentoExtraProductPreviewTransforms } from '@daffodil/product/driver/magento';
6
6
  import { DaffProductTypeEnum } from '@daffodil/product';
7
7
 
8
8
  const magentoBundledProductFragment = gql `
@@ -100,21 +100,13 @@ class DaffCompositeProductMagentoDriverModule {
100
100
  return {
101
101
  ngModule: DaffCompositeProductMagentoDriverModule,
102
102
  providers: [
103
- {
104
- provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS,
105
- useValue: magentoBundledProductFragment,
106
- multi: true,
107
- },
108
- {
109
- provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS,
110
- // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
111
- useValue(daffProduct, magentoProduct) {
112
- return magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
113
- ? transformMagentoBundledProduct(daffProduct, magentoProduct)
114
- : daffProduct;
115
- },
116
- multi: true,
117
- },
103
+ ...daffProvideProductMagentoExtraProductFragments(magentoBundledProductFragment),
104
+ ...daffProvideProductMagentoExtraProductTransforms((daffProduct, magentoProduct) => magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
105
+ ? transformMagentoBundledProduct(daffProduct, magentoProduct)
106
+ : daffProduct),
107
+ // stub out composite fields for a preview
108
+ ...daffProvideProductMagentoExtraProductPreviewTransforms((daffProduct, magentoProduct) => magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
109
+ ? Object.assign(Object.assign({}, daffProduct), { items: [] }) : daffProduct),
118
110
  ],
119
111
  };
120
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-product-composite-driver-magento.mjs","sources":["../../../libs/product-composite/driver/magento/src/fragments/bundled-product.ts","../../../libs/product-composite/driver/magento/src/transforms/bundled-product-transformers.ts","../../../libs/product-composite/driver/magento/src/composite-product-driver.module.ts","../../../libs/product-composite/driver/magento/src/models/bundled-product.ts","../../../libs/product-composite/driver/magento/src/daffodil-product-composite-driver-magento.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const magentoBundledProductFragment = gql`\nfragment magentoBundledProduct on BundleProduct {\n\titems {\n\t\toption_id\n\t\trequired\n\t\ttitle\n\t\ttype\n\t\toptions {\n\t\t\tuid\n\t\t\tis_default\n\t\t\tlabel\n\t\t\tquantity\n position\n\t\t\tproduct {\n\t\t\t\tstock_status\n\t\t\t\tprice_range {\n\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdiscount {\n\t\t\t\t\t\t\tamount_off\n\t\t\t\t\t\t\tpercent_off\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","import {\n DaffProductDiscount,\n DaffProductTypeEnum,\n DaffProduct,\n} from '@daffodil/product';\nimport {\n DaffCompositeProduct,\n DaffCompositeProductItemOption,\n DaffCompositeProductItem,\n DaffCompositeProductItemInputEnum,\n} from '@daffodil/product-composite';\nimport { MagentoProductStockStatusEnum } from '@daffodil/product/driver/magento';\n\nimport {\n MagentoBundledProduct,\n MagentoBundledProductItem,\n MagentoBundledProductItemOption,\n MagentoBundledProductItemOptionProduct,\n} from '../models/bundled-product';\n\n/**\n * Transforms the magento MagentoProduct from the magento product query into a DaffProduct.\n *\n * @param response the response from a magento product query.\n */\nexport function transformMagentoBundledProduct(\n daffProduct: DaffProduct,\n { items }: MagentoBundledProduct,\n): DaffCompositeProduct {\n return {\n ...daffProduct,\n ...items.length > 0 ? {\n price: 0,\n discount: {\n amount: 0,\n percent: 0,\n },\n } : {},\n type: DaffProductTypeEnum.Composite,\n items: items.map(transformMagentoBundledProductItem),\n };\n}\n\nfunction transformMagentoBundledProductItem(item: MagentoBundledProductItem): DaffCompositeProductItem {\n return {\n id: item.option_id.toString(),\n required: item.required,\n title: item.title,\n input_type: <DaffCompositeProductItemInputEnum>item.type,\n options: Array.from(item.options).sort((a, b) => a.position - b.position).map(transformMagentoBundledProductItemOption),\n };\n}\n\nfunction transformMagentoBundledProductItemOption(option: MagentoBundledProductItemOption): DaffCompositeProductItemOption {\n return {\n id: option.uid.toString(),\n type: DaffProductTypeEnum.Simple,\n url: null,\n name: option.label,\n price: getPrice(option.product),\n images: [],\n thumbnail: null,\n discount: getDiscount(option.product),\n quantity: option.quantity,\n is_default: option.is_default,\n in_stock: option.product.stock_status === MagentoProductStockStatusEnum.InStock,\n };\n}\n\n/**\n * A function for null checking an object.\n */\nfunction getPrice(product: MagentoBundledProductItemOptionProduct): number {\n return product.price_range?.maximum_price?.regular_price?.value || null;\n}\n\nfunction getDiscount(product: MagentoBundledProductItemOptionProduct): DaffProductDiscount {\n return product.price_range?.maximum_price?.discount\n ? {\n amount: product.price_range.maximum_price.discount.amount_off,\n percent: product.price_range.maximum_price.discount.percent_off,\n } : { amount: null, percent: null };\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport {\n DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS,\n DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS,\n MagentoProductTypeEnum,\n} from '@daffodil/product/driver/magento';\n\nimport { magentoBundledProductFragment } from './fragments/bundled-product';\nimport { transformMagentoBundledProduct } from './transforms/bundled-product-transformers';\n\n/**\n * A module that provides the product fragment for composite products along with a composite product transformer.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffCompositeProductMagentoDriverModule {\n static forRoot(): ModuleWithProviders<DaffCompositeProductMagentoDriverModule> {\n return {\n ngModule: DaffCompositeProductMagentoDriverModule,\n providers: [\n {\n provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS,\n useValue: magentoBundledProductFragment,\n multi: true,\n },\n {\n provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS,\n // eslint-disable-next-line prefer-arrow/prefer-arrow-functions\n useValue(daffProduct, magentoProduct) {\n return magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct\n ? transformMagentoBundledProduct(daffProduct, magentoProduct)\n : daffProduct;\n },\n multi: true,\n },\n ],\n };\n }\n}\n","import {\n MagentoProduct,\n MagentoProductStockStatusEnum,\n} from '@daffodil/product/driver/magento';\n\nexport enum MagentoPriceTypeEnum {\n fixed = 'FIXED',\n percent = 'PERCENT',\n dynamic = 'DYNAMIC'\n}\n\nexport interface MagentoBundledProduct extends MagentoProduct {\n items: MagentoBundledProductItem[];\n}\n\nexport interface MagentoBundledProductItem {\n required: boolean;\n title: string;\n type: string;\n options: MagentoBundledProductItemOption[];\n option_id?: number;\n}\n\nexport interface MagentoBundledProductItemOption {\n uid: string;\n label: string;\n quantity: number;\n is_default: boolean;\n position: number;\n product: MagentoBundledProductItemOptionProduct;\n}\n\nexport interface MagentoBundledProductItemOptionProduct {\n stock_status?: MagentoProductStockStatusEnum;\n price_range: {\n maximum_price: {\n regular_price: {\n value: number;\n currency: any;\n };\n discount: {\n amount_off: number;\n percent_off: number;\n };\n };\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,6BAA6B,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACkBhD;;;;AAIG;SACa,8BAA8B,CAC5C,WAAwB,EACxB,EAAE,KAAK,EAAyB,EAAA;IAEhC,OACK,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,WAAW,GACX,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG;AACpB,QAAA,KAAK,EAAE,CAAC;AACR,QAAA,QAAQ,EAAE;AACR,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,OAAO,EAAE,CAAC;AACX,SAAA;AACF,KAAA,GAAG,EAAE,KACN,IAAI,EAAE,mBAAmB,CAAC,SAAS,EACnC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,kCAAkC,CAAC,EACpD,CAAA,CAAA;AACJ,CAAC;AAED,SAAS,kCAAkC,CAAC,IAA+B,EAAA;IACzE,OAAO;AACL,QAAA,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;QAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;QAC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A,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uCAAuC,YAHhD,YAAY,CAAA,EAAA,CAAA,CAAA;AAGH,mBAAA,uCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uCAAuC,EAJzC,OAAA,EAAA,CAAA;YACP,YAAY;SACb,CAAA,EAAA,CAAA,CAAA;2FAEU,uCAAuC,EAAA,UAAA,EAAA,CAAA;kBALnD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;iBACF,CAAA;;;ACjBW,IAAA,qBAIX;AAJD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACrB,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,GAI/B,EAAA,CAAA,CAAA;;ACTD;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-product-composite-driver-magento.mjs","sources":["../../../libs/product-composite/driver/magento/src/fragments/bundled-product.ts","../../../libs/product-composite/driver/magento/src/transforms/bundled-product-transformers.ts","../../../libs/product-composite/driver/magento/src/composite-product-driver.module.ts","../../../libs/product-composite/driver/magento/src/models/bundled-product.ts","../../../libs/product-composite/driver/magento/src/daffodil-product-composite-driver-magento.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const magentoBundledProductFragment = gql`\nfragment magentoBundledProduct on BundleProduct {\n\titems {\n\t\toption_id\n\t\trequired\n\t\ttitle\n\t\ttype\n\t\toptions {\n\t\t\tuid\n\t\t\tis_default\n\t\t\tlabel\n\t\t\tquantity\n position\n\t\t\tproduct {\n\t\t\t\tstock_status\n\t\t\t\tprice_range {\n\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdiscount {\n\t\t\t\t\t\t\tamount_off\n\t\t\t\t\t\t\tpercent_off\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","import {\n DaffProductDiscount,\n DaffProductTypeEnum,\n DaffProduct,\n} from '@daffodil/product';\nimport {\n DaffCompositeProduct,\n DaffCompositeProductItemOption,\n DaffCompositeProductItem,\n DaffCompositeProductItemInputEnum,\n} from '@daffodil/product-composite';\nimport { MagentoProductStockStatusEnum } from '@daffodil/product/driver/magento';\n\nimport {\n MagentoBundledProduct,\n MagentoBundledProductItem,\n MagentoBundledProductItemOption,\n MagentoBundledProductItemOptionProduct,\n} from '../models/bundled-product';\n\n/**\n * Transforms the magento MagentoProduct from the magento product query into a DaffProduct.\n *\n * @param response the response from a magento product query.\n */\nexport function transformMagentoBundledProduct(\n daffProduct: DaffProduct,\n { items }: MagentoBundledProduct,\n): DaffCompositeProduct {\n return {\n ...daffProduct,\n ...items.length > 0 ? {\n price: 0,\n discount: {\n amount: 0,\n percent: 0,\n },\n } : {},\n type: DaffProductTypeEnum.Composite,\n items: items.map(transformMagentoBundledProductItem),\n };\n}\n\nfunction transformMagentoBundledProductItem(item: MagentoBundledProductItem): DaffCompositeProductItem {\n return {\n id: item.option_id.toString(),\n required: item.required,\n title: item.title,\n input_type: <DaffCompositeProductItemInputEnum>item.type,\n options: Array.from(item.options).sort((a, b) => a.position - b.position).map(transformMagentoBundledProductItemOption),\n };\n}\n\nfunction transformMagentoBundledProductItemOption(option: MagentoBundledProductItemOption): DaffCompositeProductItemOption {\n return {\n id: option.uid.toString(),\n type: DaffProductTypeEnum.Simple,\n url: null,\n name: option.label,\n price: getPrice(option.product),\n images: [],\n thumbnail: null,\n discount: getDiscount(option.product),\n quantity: option.quantity,\n is_default: option.is_default,\n in_stock: option.product.stock_status === MagentoProductStockStatusEnum.InStock,\n };\n}\n\n/**\n * A function for null checking an object.\n */\nfunction getPrice(product: MagentoBundledProductItemOptionProduct): number {\n return product.price_range?.maximum_price?.regular_price?.value || null;\n}\n\nfunction getDiscount(product: MagentoBundledProductItemOptionProduct): DaffProductDiscount {\n return product.price_range?.maximum_price?.discount\n ? {\n amount: product.price_range.maximum_price.discount.amount_off,\n percent: product.price_range.maximum_price.discount.percent_off,\n } : { amount: null, percent: null };\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport {\n daffProvideProductMagentoExtraProductTransforms,\n MagentoProductTypeEnum,\n daffProvideProductMagentoExtraProductFragments,\n daffProvideProductMagentoExtraProductPreviewTransforms,\n} from '@daffodil/product/driver/magento';\n\nimport { magentoBundledProductFragment } from './fragments/bundled-product';\nimport { MagentoBundledProduct } from './public_api';\nimport { transformMagentoBundledProduct } from './transforms/bundled-product-transformers';\n\n/**\n * A module that provides the product fragment for composite products along with a composite product transformer.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffCompositeProductMagentoDriverModule {\n static forRoot(): ModuleWithProviders<DaffCompositeProductMagentoDriverModule> {\n return {\n ngModule: DaffCompositeProductMagentoDriverModule,\n providers: [\n ...daffProvideProductMagentoExtraProductFragments(magentoBundledProductFragment),\n ...daffProvideProductMagentoExtraProductTransforms<MagentoBundledProduct>(\n (daffProduct, magentoProduct) =>\n magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct\n ? transformMagentoBundledProduct(daffProduct, magentoProduct)\n : daffProduct,\n ),\n // stub out composite fields for a preview\n ...daffProvideProductMagentoExtraProductPreviewTransforms<MagentoBundledProduct>(\n (daffProduct, magentoProduct) =>\n magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct\n ? {\n ...daffProduct,\n items: [],\n }\n : daffProduct,\n ),\n ],\n };\n }\n}\n","import {\n MagentoProduct,\n MagentoProductStockStatusEnum,\n} from '@daffodil/product/driver/magento';\n\nexport enum MagentoPriceTypeEnum {\n fixed = 'FIXED',\n percent = 'PERCENT',\n dynamic = 'DYNAMIC'\n}\n\nexport interface MagentoBundledProduct extends MagentoProduct {\n items: MagentoBundledProductItem[];\n}\n\nexport interface MagentoBundledProductItem {\n required: boolean;\n title: string;\n type: string;\n options: MagentoBundledProductItemOption[];\n option_id?: number;\n}\n\nexport interface MagentoBundledProductItemOption {\n uid: string;\n label: string;\n quantity: number;\n is_default: boolean;\n position: number;\n product: MagentoBundledProductItemOptionProduct;\n}\n\nexport interface MagentoBundledProductItemOptionProduct {\n stock_status?: MagentoProductStockStatusEnum;\n price_range: {\n maximum_price: {\n regular_price: {\n value: number;\n currency: any;\n };\n discount: {\n amount_off: number;\n percent_off: number;\n };\n };\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,6BAA6B,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACkBhD;;;;AAIG;SACa,8BAA8B,CAC5C,WAAwB,EACxB,EAAE,KAAK,EAAyB,EAAA;IAEhC,OACK,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,WAAW,GACX,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG;AACpB,QAAA,KAAK,EAAE,CAAC;AACR,QAAA,QAAQ,EAAE;AACR,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,OAAO,EAAE,CAAC;AACX,SAAA;AACF,KAAA,GAAG,EAAE,KACN,IAAI,EAAE,mBAAmB,CAAC,SAAS,EACnC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,kCAAkC,CAAC,EACpD,CAAA,CAAA;AACJ,CAAC;AAED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CAAA,GAAE,WAAW,CAClB;AACF,aAAA;SACF,CAAC;KACH;;uJAxBU,uCAAuC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAvC,mBAAA,uCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uCAAuC,YAHhD,YAAY,CAAA,EAAA,CAAA,CAAA;AAGH,mBAAA,uCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uCAAuC,EAJzC,OAAA,EAAA,CAAA;YACP,YAAY;SACb,CAAA,EAAA,CAAA,CAAA;2FAEU,uCAAuC,EAAA,UAAA,EAAA,CAAA;kBALnD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;iBACF,CAAA;;;ACnBW,IAAA,qBAIX;AAJD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACrB,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,GAI/B,EAAA,CAAA,CAAA;;ACTD;;AAEG;;;;"}
@@ -2,7 +2,7 @@ import { gql } from 'apollo-angular';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
4
  import { NgModule } from '@angular/core';
5
- import { MagentoProductStockStatusEnum, DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS, DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS, MagentoProductTypeEnum } from '@daffodil/product/driver/magento';
5
+ import { MagentoProductStockStatusEnum, daffProvideProductMagentoExtraProductFragments, daffProvideProductMagentoExtraProductTransforms, MagentoProductTypeEnum, daffProvideProductMagentoExtraProductPreviewTransforms } from '@daffodil/product/driver/magento';
6
6
  import { DaffProductTypeEnum } from '@daffodil/product';
7
7
 
8
8
  const magentoBundledProductFragment = gql `
@@ -103,21 +103,17 @@ class DaffCompositeProductMagentoDriverModule {
103
103
  return {
104
104
  ngModule: DaffCompositeProductMagentoDriverModule,
105
105
  providers: [
106
- {
107
- provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS,
108
- useValue: magentoBundledProductFragment,
109
- multi: true,
110
- },
111
- {
112
- provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS,
113
- // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
114
- useValue(daffProduct, magentoProduct) {
115
- return magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
116
- ? transformMagentoBundledProduct(daffProduct, magentoProduct)
117
- : daffProduct;
118
- },
119
- multi: true,
120
- },
106
+ ...daffProvideProductMagentoExtraProductFragments(magentoBundledProductFragment),
107
+ ...daffProvideProductMagentoExtraProductTransforms((daffProduct, magentoProduct) => magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
108
+ ? transformMagentoBundledProduct(daffProduct, magentoProduct)
109
+ : daffProduct),
110
+ // stub out composite fields for a preview
111
+ ...daffProvideProductMagentoExtraProductPreviewTransforms((daffProduct, magentoProduct) => magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
112
+ ? {
113
+ ...daffProduct,
114
+ items: [],
115
+ }
116
+ : daffProduct),
121
117
  ],
122
118
  };
123
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-product-composite-driver-magento.mjs","sources":["../../../libs/product-composite/driver/magento/src/fragments/bundled-product.ts","../../../libs/product-composite/driver/magento/src/transforms/bundled-product-transformers.ts","../../../libs/product-composite/driver/magento/src/composite-product-driver.module.ts","../../../libs/product-composite/driver/magento/src/models/bundled-product.ts","../../../libs/product-composite/driver/magento/src/daffodil-product-composite-driver-magento.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const magentoBundledProductFragment = gql`\nfragment magentoBundledProduct on BundleProduct {\n\titems {\n\t\toption_id\n\t\trequired\n\t\ttitle\n\t\ttype\n\t\toptions {\n\t\t\tuid\n\t\t\tis_default\n\t\t\tlabel\n\t\t\tquantity\n position\n\t\t\tproduct {\n\t\t\t\tstock_status\n\t\t\t\tprice_range {\n\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdiscount {\n\t\t\t\t\t\t\tamount_off\n\t\t\t\t\t\t\tpercent_off\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","import {\n DaffProductDiscount,\n DaffProductTypeEnum,\n DaffProduct,\n} from '@daffodil/product';\nimport {\n DaffCompositeProduct,\n DaffCompositeProductItemOption,\n DaffCompositeProductItem,\n DaffCompositeProductItemInputEnum,\n} from '@daffodil/product-composite';\nimport { MagentoProductStockStatusEnum } from '@daffodil/product/driver/magento';\n\nimport {\n MagentoBundledProduct,\n MagentoBundledProductItem,\n MagentoBundledProductItemOption,\n MagentoBundledProductItemOptionProduct,\n} from '../models/bundled-product';\n\n/**\n * Transforms the magento MagentoProduct from the magento product query into a DaffProduct.\n *\n * @param response the response from a magento product query.\n */\nexport function transformMagentoBundledProduct(\n daffProduct: DaffProduct,\n { items }: MagentoBundledProduct,\n): DaffCompositeProduct {\n return {\n ...daffProduct,\n ...items.length > 0 ? {\n price: 0,\n discount: {\n amount: 0,\n percent: 0,\n },\n } : {},\n type: DaffProductTypeEnum.Composite,\n items: items.map(transformMagentoBundledProductItem),\n };\n}\n\nfunction transformMagentoBundledProductItem(item: MagentoBundledProductItem): DaffCompositeProductItem {\n return {\n id: item.option_id.toString(),\n required: item.required,\n title: item.title,\n input_type: <DaffCompositeProductItemInputEnum>item.type,\n options: Array.from(item.options).sort((a, b) => a.position - b.position).map(transformMagentoBundledProductItemOption),\n };\n}\n\nfunction transformMagentoBundledProductItemOption(option: MagentoBundledProductItemOption): DaffCompositeProductItemOption {\n return {\n id: option.uid.toString(),\n type: DaffProductTypeEnum.Simple,\n url: null,\n name: option.label,\n price: getPrice(option.product),\n images: [],\n thumbnail: null,\n discount: getDiscount(option.product),\n quantity: option.quantity,\n is_default: option.is_default,\n in_stock: option.product.stock_status === MagentoProductStockStatusEnum.InStock,\n };\n}\n\n/**\n * A function for null checking an object.\n */\nfunction getPrice(product: MagentoBundledProductItemOptionProduct): number {\n return product.price_range?.maximum_price?.regular_price?.value || null;\n}\n\nfunction getDiscount(product: MagentoBundledProductItemOptionProduct): DaffProductDiscount {\n return product.price_range?.maximum_price?.discount\n ? {\n amount: product.price_range.maximum_price.discount.amount_off,\n percent: product.price_range.maximum_price.discount.percent_off,\n } : { amount: null, percent: null };\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport {\n DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS,\n DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS,\n MagentoProductTypeEnum,\n} from '@daffodil/product/driver/magento';\n\nimport { magentoBundledProductFragment } from './fragments/bundled-product';\nimport { transformMagentoBundledProduct } from './transforms/bundled-product-transformers';\n\n/**\n * A module that provides the product fragment for composite products along with a composite product transformer.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffCompositeProductMagentoDriverModule {\n static forRoot(): ModuleWithProviders<DaffCompositeProductMagentoDriverModule> {\n return {\n ngModule: DaffCompositeProductMagentoDriverModule,\n providers: [\n {\n provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_FRAGMENTS,\n useValue: magentoBundledProductFragment,\n multi: true,\n },\n {\n provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_PREVIEW_TRANSFORMS,\n // eslint-disable-next-line prefer-arrow/prefer-arrow-functions\n useValue(daffProduct, magentoProduct) {\n return magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct\n ? transformMagentoBundledProduct(daffProduct, magentoProduct)\n : daffProduct;\n },\n multi: true,\n },\n ],\n };\n }\n}\n","import {\n MagentoProduct,\n MagentoProductStockStatusEnum,\n} from '@daffodil/product/driver/magento';\n\nexport enum MagentoPriceTypeEnum {\n fixed = 'FIXED',\n percent = 'PERCENT',\n dynamic = 'DYNAMIC'\n}\n\nexport interface MagentoBundledProduct extends MagentoProduct {\n items: MagentoBundledProductItem[];\n}\n\nexport interface MagentoBundledProductItem {\n required: boolean;\n title: string;\n type: string;\n options: MagentoBundledProductItemOption[];\n option_id?: number;\n}\n\nexport interface MagentoBundledProductItemOption {\n uid: string;\n label: string;\n quantity: number;\n is_default: boolean;\n position: number;\n product: MagentoBundledProductItemOptionProduct;\n}\n\nexport interface MagentoBundledProductItemOptionProduct {\n stock_status?: MagentoProductStockStatusEnum;\n price_range: {\n maximum_price: {\n regular_price: {\n value: number;\n currency: any;\n };\n discount: {\n amount_off: number;\n percent_off: number;\n };\n };\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,6BAA6B,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACkBhD;;;;AAIG;SACa,8BAA8B,CAC5C,WAAwB,EACxB,EAAE,KAAK,EAAyB,EAAA;IAEhC,OAAO;AACL,QAAA,GAAG,WAAW;AACd,QAAA,GAAG,KAAK,C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A,CAAA;AAAvC,mBAAA,uCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uCAAuC,YAHhD,YAAY,CAAA,EAAA,CAAA,CAAA;AAGH,mBAAA,uCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uCAAuC,EAJzC,OAAA,EAAA,CAAA;YACP,YAAY;AACb,SAAA,CAAA,EAAA,CAAA,CAAA;2FAEU,uCAAuC,EAAA,UAAA,EAAA,CAAA;kBALnD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA,CAAA;;;ICjBW,qBAIX;AAJD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACrB,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,GAI/B,EAAA,CAAA,CAAA;;ACTD;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-product-composite-driver-magento.mjs","sources":["../../../libs/product-composite/driver/magento/src/fragments/bundled-product.ts","../../../libs/product-composite/driver/magento/src/transforms/bundled-product-transformers.ts","../../../libs/product-composite/driver/magento/src/composite-product-driver.module.ts","../../../libs/product-composite/driver/magento/src/models/bundled-product.ts","../../../libs/product-composite/driver/magento/src/daffodil-product-composite-driver-magento.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nexport const magentoBundledProductFragment = gql`\nfragment magentoBundledProduct on BundleProduct {\n\titems {\n\t\toption_id\n\t\trequired\n\t\ttitle\n\t\ttype\n\t\toptions {\n\t\t\tuid\n\t\t\tis_default\n\t\t\tlabel\n\t\t\tquantity\n position\n\t\t\tproduct {\n\t\t\t\tstock_status\n\t\t\t\tprice_range {\n\t\t\t\t\tmaximum_price {\n\t\t\t\t\t\tregular_price {\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\tcurrency\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdiscount {\n\t\t\t\t\t\t\tamount_off\n\t\t\t\t\t\t\tpercent_off\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","import {\n DaffProductDiscount,\n DaffProductTypeEnum,\n DaffProduct,\n} from '@daffodil/product';\nimport {\n DaffCompositeProduct,\n DaffCompositeProductItemOption,\n DaffCompositeProductItem,\n DaffCompositeProductItemInputEnum,\n} from '@daffodil/product-composite';\nimport { MagentoProductStockStatusEnum } from '@daffodil/product/driver/magento';\n\nimport {\n MagentoBundledProduct,\n MagentoBundledProductItem,\n MagentoBundledProductItemOption,\n MagentoBundledProductItemOptionProduct,\n} from '../models/bundled-product';\n\n/**\n * Transforms the magento MagentoProduct from the magento product query into a DaffProduct.\n *\n * @param response the response from a magento product query.\n */\nexport function transformMagentoBundledProduct(\n daffProduct: DaffProduct,\n { items }: MagentoBundledProduct,\n): DaffCompositeProduct {\n return {\n ...daffProduct,\n ...items.length > 0 ? {\n price: 0,\n discount: {\n amount: 0,\n percent: 0,\n },\n } : {},\n type: DaffProductTypeEnum.Composite,\n items: items.map(transformMagentoBundledProductItem),\n };\n}\n\nfunction transformMagentoBundledProductItem(item: MagentoBundledProductItem): DaffCompositeProductItem {\n return {\n id: item.option_id.toString(),\n required: item.required,\n title: item.title,\n input_type: <DaffCompositeProductItemInputEnum>item.type,\n options: Array.from(item.options).sort((a, b) => a.position - b.position).map(transformMagentoBundledProductItemOption),\n };\n}\n\nfunction transformMagentoBundledProductItemOption(option: MagentoBundledProductItemOption): DaffCompositeProductItemOption {\n return {\n id: option.uid.toString(),\n type: DaffProductTypeEnum.Simple,\n url: null,\n name: option.label,\n price: getPrice(option.product),\n images: [],\n thumbnail: null,\n discount: getDiscount(option.product),\n quantity: option.quantity,\n is_default: option.is_default,\n in_stock: option.product.stock_status === MagentoProductStockStatusEnum.InStock,\n };\n}\n\n/**\n * A function for null checking an object.\n */\nfunction getPrice(product: MagentoBundledProductItemOptionProduct): number {\n return product.price_range?.maximum_price?.regular_price?.value || null;\n}\n\nfunction getDiscount(product: MagentoBundledProductItemOptionProduct): DaffProductDiscount {\n return product.price_range?.maximum_price?.discount\n ? {\n amount: product.price_range.maximum_price.discount.amount_off,\n percent: product.price_range.maximum_price.discount.percent_off,\n } : { amount: null, percent: null };\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport {\n daffProvideProductMagentoExtraProductTransforms,\n MagentoProductTypeEnum,\n daffProvideProductMagentoExtraProductFragments,\n daffProvideProductMagentoExtraProductPreviewTransforms,\n} from '@daffodil/product/driver/magento';\n\nimport { magentoBundledProductFragment } from './fragments/bundled-product';\nimport { MagentoBundledProduct } from './public_api';\nimport { transformMagentoBundledProduct } from './transforms/bundled-product-transformers';\n\n/**\n * A module that provides the product fragment for composite products along with a composite product transformer.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffCompositeProductMagentoDriverModule {\n static forRoot(): ModuleWithProviders<DaffCompositeProductMagentoDriverModule> {\n return {\n ngModule: DaffCompositeProductMagentoDriverModule,\n providers: [\n ...daffProvideProductMagentoExtraProductFragments(magentoBundledProductFragment),\n ...daffProvideProductMagentoExtraProductTransforms<MagentoBundledProduct>(\n (daffProduct, magentoProduct) =>\n magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct\n ? transformMagentoBundledProduct(daffProduct, magentoProduct)\n : daffProduct,\n ),\n // stub out composite fields for a preview\n ...daffProvideProductMagentoExtraProductPreviewTransforms<MagentoBundledProduct>(\n (daffProduct, magentoProduct) =>\n magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct\n ? {\n ...daffProduct,\n items: [],\n }\n : daffProduct,\n ),\n ],\n };\n }\n}\n","import {\n MagentoProduct,\n MagentoProductStockStatusEnum,\n} from '@daffodil/product/driver/magento';\n\nexport enum MagentoPriceTypeEnum {\n fixed = 'FIXED',\n percent = 'PERCENT',\n dynamic = 'DYNAMIC'\n}\n\nexport interface MagentoBundledProduct extends MagentoProduct {\n items: MagentoBundledProductItem[];\n}\n\nexport interface MagentoBundledProductItem {\n required: boolean;\n title: string;\n type: string;\n options: MagentoBundledProductItemOption[];\n option_id?: number;\n}\n\nexport interface MagentoBundledProductItemOption {\n uid: string;\n label: string;\n quantity: number;\n is_default: boolean;\n position: number;\n product: MagentoBundledProductItemOptionProduct;\n}\n\nexport interface MagentoBundledProductItemOptionProduct {\n stock_status?: MagentoProductStockStatusEnum;\n price_range: {\n maximum_price: {\n regular_price: {\n value: number;\n currency: any;\n };\n discount: {\n amount_off: number;\n percent_off: number;\n };\n };\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,6BAA6B,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACkBhD;;;;AAIG;SACa,8BAA8B,CAC5C,WAAwB,EACxB,EAAE,KAAK,EAAyB,EAAA;IAEhC,OAAO;AACL,QAAA,GAAG,WAAW;AACd,QAAA,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG;AACpB,YAAA,KAAK,EAAE,CAAC;AACR,YAAA,QAAQ,EAAE;AACR,gBAAA,MAAM,EAAE,CAAC;AACT,gBAAA,OAAO,EAAE,CAAC;AACX,aAAA;SACF,GAAG,EAAE;QACN,IAAI,EAAE,mBAAmB,CAAC,SAAS;AACnC,QAAA,KAAK,EAAE,KAAK,CAAC,GAAG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uCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uCAAuC,EAJzC,OAAA,EAAA,CAAA;YACP,YAAY;AACb,SAAA,CAAA,EAAA,CAAA,CAAA;2FAEU,uCAAuC,EAAA,UAAA,EAAA,CAAA;kBALnD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA,CAAA;;;ICnBW,qBAIX;AAJD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACrB,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,GAI/B,EAAA,CAAA,CAAA;;ACTD;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daffodil/product-composite",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "Interfaces built for daffodil/state",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,8 +18,8 @@
18
18
  "peerDependencies": {
19
19
  "@angular/common": "^13.0.0",
20
20
  "@angular/core": "^13.0.0",
21
- "@daffodil/core": "0.45.0",
22
- "@daffodil/product": "0.45.0",
21
+ "@daffodil/core": "0.46.0",
22
+ "@daffodil/product": "0.46.0",
23
23
  "@ngrx/effects": "^13.0.0",
24
24
  "@ngrx/entity": "^13.0.0",
25
25
  "@ngrx/store": "^13.0.0",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "optionalDependencies": {
29
29
  "@apollo/client": "^3.0.0",
30
- "@daffodil/driver": "0.45.0",
31
- "@daffodil/product": "0.45.0",
30
+ "@daffodil/driver": "0.46.0",
31
+ "@daffodil/product": "0.46.0",
32
32
  "angular-in-memory-web-api": "^0.13.0",
33
33
  "apollo-angular": "^3.0.1",
34
34
  "@faker-js/faker": "^5.5.3"