@daffodil/product-composite 0.40.1 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/driver/magento/fragments/bundled-product.d.ts +1 -1
- package/esm2020/driver/magento/fragments/bundled-product.mjs +2 -2
- package/fesm2015/daffodil-product-composite-driver-magento.mjs +1 -1
- package/fesm2015/daffodil-product-composite-driver-magento.mjs.map +1 -1
- package/fesm2020/daffodil-product-composite-driver-magento.mjs +1 -1
- package/fesm2020/daffodil-product-composite-driver-magento.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const magentoBundledProductFragment: import("
|
|
1
|
+
export declare const magentoBundledProductFragment: import("apollo-angular").TypedDocumentNode<unknown, unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gql } from '
|
|
1
|
+
import { gql } from 'apollo-angular';
|
|
2
2
|
export const magentoBundledProductFragment = gql `
|
|
3
3
|
fragment magentoBundledProduct on BundleProduct {
|
|
4
4
|
items {
|
|
@@ -31,4 +31,4 @@ fragment magentoBundledProduct on BundleProduct {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
`;
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlZC1wcm9kdWN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9wcm9kdWN0LWNvbXBvc2l0ZS9kcml2ZXIvbWFnZW50by9zcmMvZnJhZ21lbnRzL2J1bmRsZWQtcHJvZHVjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsR0FBRyxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFckMsTUFBTSxDQUFDLE1BQU0sNkJBQTZCLEdBQUcsR0FBRyxDQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0NBK0IvQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgZ3FsIH0gZnJvbSAnYXBvbGxvLWFuZ3VsYXInO1xuXG5leHBvcnQgY29uc3QgbWFnZW50b0J1bmRsZWRQcm9kdWN0RnJhZ21lbnQgPSBncWxgXG5mcmFnbWVudCBtYWdlbnRvQnVuZGxlZFByb2R1Y3Qgb24gQnVuZGxlUHJvZHVjdCB7XG5cdGl0ZW1zIHtcblx0XHRvcHRpb25faWRcblx0XHRyZXF1aXJlZFxuXHRcdHRpdGxlXG5cdFx0dHlwZVxuXHRcdG9wdGlvbnMge1xuXHRcdFx0dWlkXG5cdFx0XHRpc19kZWZhdWx0XG5cdFx0XHRsYWJlbFxuXHRcdFx0cXVhbnRpdHlcbiAgICAgIHBvc2l0aW9uXG5cdFx0XHRwcm9kdWN0IHtcblx0XHRcdFx0c3RvY2tfc3RhdHVzXG5cdFx0XHRcdHByaWNlX3JhbmdlIHtcblx0XHRcdFx0XHRtYXhpbXVtX3ByaWNlIHtcblx0XHRcdFx0XHRcdHJlZ3VsYXJfcHJpY2Uge1xuXHRcdFx0XHRcdFx0XHR2YWx1ZVxuXHRcdFx0XHRcdFx0XHRjdXJyZW5jeVxuXHRcdFx0XHRcdFx0fVxuXHRcdFx0XHRcdFx0ZGlzY291bnQge1xuXHRcdFx0XHRcdFx0XHRhbW91bnRfb2ZmXG5cdFx0XHRcdFx0XHRcdHBlcmNlbnRfb2ZmXG5cdFx0XHRcdFx0XHR9XG5cdFx0XHRcdFx0fVxuXHRcdFx0XHR9XG5cdFx0XHR9XG5cdFx0fVxuXHR9XG59XG5gO1xuIl19
|
|
@@ -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 '
|
|
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\tfixed = 'FIXED',\n\tpercent = 'PERCENT',\n\tdynamic = 'DYNAMIC'\n}\n\nexport interface MagentoBundledProduct extends MagentoProduct {\n\titems: MagentoBundledProductItem[];\n}\n\nexport interface MagentoBundledProductItem {\n\trequired: boolean;\n\ttitle: string;\n\ttype: string;\n\toptions: MagentoBundledProductItemOption[];\n\toption_id?: number;\n}\n\nexport interface MagentoBundledProductItemOption {\n\tuid: string;\n\tlabel: string;\n\tquantity: number;\n\tis_default: boolean;\n position: number;\n\tproduct: MagentoBundledProductItemOptionProduct;\n}\n\nexport interface MagentoBundledProductItemOptionProduct {\n\tstock_status?: MagentoProductStockStatusEnum;\n\tprice_range: {\n\t\tmaximum_price: {\n\t\t\tregular_price: {\n\t\t\t\tvalue: number;\n\t\t\t\tcurrency: any;\n\t\t\t};\n\t\t\tdiscount: {\n\t\t\t\tamount_off: number;\n\t\t\t\tpercent_off: number;\n\t\t\t};\n\t\t};\n\t};\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;QACjB,UAAU,EAAqC,IAAI,CAAC,IAAI;AACxD,QAAA,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,wCAAwC,CAAC;KACxH,CAAC;AACJ,CAAC;AAED,SAAS,wCAAwC,CAAC,MAAuC,EAAA;IACvF,OAAO;AACL,QAAA,EAA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A,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;AAC/B,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;AACpB,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,GAI/B,EAAA,CAAA,CAAA;;ACTD;;AAEG;;;;"}
|
|
@@ -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 '
|
|
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\tfixed = 'FIXED',\n\tpercent = 'PERCENT',\n\tdynamic = 'DYNAMIC'\n}\n\nexport interface MagentoBundledProduct extends MagentoProduct {\n\titems: MagentoBundledProductItem[];\n}\n\nexport interface MagentoBundledProductItem {\n\trequired: boolean;\n\ttitle: string;\n\ttype: string;\n\toptions: MagentoBundledProductItemOption[];\n\toption_id?: number;\n}\n\nexport interface MagentoBundledProductItemOption {\n\tuid: string;\n\tlabel: string;\n\tquantity: number;\n\tis_default: boolean;\n position: number;\n\tproduct: MagentoBundledProductItemOptionProduct;\n}\n\nexport interface MagentoBundledProductItemOptionProduct {\n\tstock_status?: MagentoProductStockStatusEnum;\n\tprice_range: {\n\t\tmaximum_price: {\n\t\t\tregular_price: {\n\t\t\t\tvalue: number;\n\t\t\t\tcurrency: any;\n\t\t\t};\n\t\t\tdiscount: {\n\t\t\t\tamount_off: number;\n\t\t\t\tpercent_off: number;\n\t\t\t};\n\t\t};\n\t};\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,CAAC,kCAAkC,CAA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AAA,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;AAC/B,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;AACpB,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.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Interfaces built for daffodil/state",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@angular/common": "^13.0.0",
|
|
20
20
|
"@angular/core": "^13.0.0",
|
|
21
|
-
"@daffodil/core": "0.
|
|
22
|
-
"@daffodil/product": "0.
|
|
21
|
+
"@daffodil/core": "0.41.0",
|
|
22
|
+
"@daffodil/product": "0.41.0",
|
|
23
23
|
"@ngrx/effects": "^13.0.0",
|
|
24
24
|
"@ngrx/entity": "^13.0.0",
|
|
25
25
|
"@ngrx/store": "^13.0.0",
|
|
26
|
-
"rxjs": "
|
|
26
|
+
"rxjs": "7.5.5"
|
|
27
27
|
},
|
|
28
28
|
"optionalDependencies": {
|
|
29
29
|
"@apollo/client": "^3.0.0",
|
|
30
|
-
"@daffodil/driver": "0.
|
|
31
|
-
"@daffodil/product": "0.
|
|
30
|
+
"@daffodil/driver": "0.41.0",
|
|
31
|
+
"@daffodil/product": "0.41.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"
|
|
35
35
|
},
|
|
36
36
|
"module": "fesm2015/daffodil-product-composite.mjs",
|