@daffodil/product-composite 0.84.0 → 0.86.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 +2 -1
- package/driver/magento/injection-tokens/fragments/item.token.d.ts +2 -0
- package/driver/magento/injection-tokens/fragments/option.token.d.ts +2 -0
- package/driver/magento/injection-tokens/public_api.d.ts +4 -0
- package/driver/magento/injection-tokens/transforms/item/extra.token.d.ts +21 -0
- package/driver/magento/injection-tokens/transforms/item/token.d.ts +2 -0
- package/driver/magento/injection-tokens/transforms/option/extra.token.d.ts +21 -0
- package/driver/magento/injection-tokens/transforms/option/token.d.ts +2 -0
- package/driver/magento/interfaces/item-extra-transform.type.d.ts +3 -0
- package/driver/magento/interfaces/item-transform.type.d.ts +3 -0
- package/driver/magento/interfaces/option-extra-transform.type.d.ts +3 -0
- package/driver/magento/interfaces/option-transform.type.d.ts +3 -0
- package/driver/magento/interfaces/public_api.d.ts +4 -0
- package/driver/magento/public_api.d.ts +2 -0
- package/driver/magento/transforms/item-transformer.service.d.ts +11 -0
- package/driver/magento/transforms/option.d.ts +3 -0
- package/driver/magento/transforms/product-transformer.service.d.ts +17 -0
- package/driver/magento/transforms/public_api.d.ts +3 -1
- package/fesm2022/daffodil-product-composite-driver-in-memory.mjs +4 -4
- package/fesm2022/daffodil-product-composite-driver-in-memory.mjs.map +1 -1
- package/fesm2022/daffodil-product-composite-driver-magento-testing.mjs +18 -18
- package/fesm2022/daffodil-product-composite-driver-magento-testing.mjs.map +1 -1
- package/fesm2022/daffodil-product-composite-driver-magento.mjs +224 -35
- package/fesm2022/daffodil-product-composite-driver-magento.mjs.map +1 -1
- package/fesm2022/daffodil-product-composite-driver-testing.mjs +4 -4
- package/fesm2022/daffodil-product-composite-driver-testing.mjs.map +1 -1
- package/fesm2022/daffodil-product-composite-routing.mjs +11 -11
- package/fesm2022/daffodil-product-composite-routing.mjs.map +1 -1
- package/fesm2022/daffodil-product-composite-state-testing.mjs +7 -7
- package/fesm2022/daffodil-product-composite-state-testing.mjs.map +1 -1
- package/fesm2022/daffodil-product-composite-state.mjs +7 -7
- package/fesm2022/daffodil-product-composite-state.mjs.map +1 -1
- package/fesm2022/daffodil-product-composite-testing.mjs +11 -11
- package/fesm2022/daffodil-product-composite-testing.mjs.map +1 -1
- package/package.json +1 -1
- package/driver/magento/transforms/bundled-product-transformers.d.ts +0 -9
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import { DocumentNode } from 'graphql';
|
2
|
+
export declare const magentoBundledProductFragment: (extraItemFragments?: Array<DocumentNode>, extraOptionFragments?: Array<DocumentNode>) => import("apollo-angular").TypedDocumentNode<unknown, unknown>;
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { DocumentNode } from 'graphql';
|
2
|
+
export declare const DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_FRAGMENTS: import("@angular/core").InjectionToken<DocumentNode[]>, provideDaffProductCompositeMagentoExtraItemFragments: <R extends DocumentNode = DocumentNode>(...values: R[]) => Array<import("@angular/core").ValueProvider>;
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { DocumentNode } from 'graphql';
|
2
|
+
export declare const DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_FRAGMENTS: import("@angular/core").InjectionToken<DocumentNode[]>, provideDaffProductCompositeMagentoExtraOptionFragments: <R extends DocumentNode = DocumentNode>(...values: R[]) => Array<import("@angular/core").ValueProvider>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Provider } from '@angular/core';
|
2
|
+
import { DaffCompositeProductItem } from '@daffodil/product-composite';
|
3
|
+
import { MagentoBundleProductItemExtraTransform } from '../../../interfaces/item-extra-transform.type';
|
4
|
+
import { MagentoBundledProductItem } from '../../../models/public_api';
|
5
|
+
declare const DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_TRANSFORMS: import("@angular/core").InjectionToken<MagentoBundleProductItemExtraTransform[]>;
|
6
|
+
/**
|
7
|
+
* Provides extra product preview transforms for the Magento product driver.
|
8
|
+
*
|
9
|
+
* See {@link DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_TRANSFORMS}.
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* ```ts
|
13
|
+
* providers: [
|
14
|
+
* ...provideDaffProductCompositeMagentoExtraItemTransforms(
|
15
|
+
* myExtraProductTransform
|
16
|
+
* )
|
17
|
+
* ]
|
18
|
+
* ```
|
19
|
+
*/
|
20
|
+
export declare function provideDaffProductCompositeMagentoExtraItemTransforms<T extends MagentoBundledProductItem = MagentoBundledProductItem, V extends DaffCompositeProductItem = DaffCompositeProductItem>(...transforms: MagentoBundleProductItemExtraTransform<T, V>[]): Provider[];
|
21
|
+
export { DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_TRANSFORMS };
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { MagentoBundleProductItemTransform } from '../../../interfaces/public_api';
|
2
|
+
export declare const DAFF_PRODUCT_COMPOSITE_MAGENTO_ITEM_TRANSFORM: import("@angular/core").InjectionToken<MagentoBundleProductItemTransform>, provideDaffProductMagentoProductTransform: <R extends MagentoBundleProductItemTransform = MagentoBundleProductItemTransform>(value: R) => import("@angular/core").ValueProvider;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Provider } from '@angular/core';
|
2
|
+
import { DaffCompositeProductItemOption } from '@daffodil/product-composite';
|
3
|
+
import { MagentoBundleProductOptionExtraTransform } from '../../../interfaces/option-extra-transform.type';
|
4
|
+
import { MagentoBundledProductItemOption } from '../../../models/public_api';
|
5
|
+
declare const DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_TRANSFORMS: import("@angular/core").InjectionToken<MagentoBundleProductOptionExtraTransform[]>;
|
6
|
+
/**
|
7
|
+
* Provides extra product preview transforms for the Magento product driver.
|
8
|
+
*
|
9
|
+
* See {@link DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_TRANSFORMS}.
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* ```ts
|
13
|
+
* providers: [
|
14
|
+
* ...provideDaffProductCompositeMagentoExtraOptionTransforms(
|
15
|
+
* myExtraProductTransform
|
16
|
+
* )
|
17
|
+
* ]
|
18
|
+
* ```
|
19
|
+
*/
|
20
|
+
export declare function provideDaffProductCompositeMagentoExtraOptionTransforms<T extends MagentoBundledProductItemOption = MagentoBundledProductItemOption, V extends DaffCompositeProductItemOption = DaffCompositeProductItemOption>(...transforms: MagentoBundleProductOptionExtraTransform<T, V>[]): Provider[];
|
21
|
+
export { DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_TRANSFORMS };
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { MagentoBundleProductOptionTransform } from '../../../interfaces/public_api';
|
2
|
+
export declare const DAFF_PRODUCT_COMPOSITE_MAGENTO_OPTION_TRANSFORM: import("@angular/core").InjectionToken<MagentoBundleProductOptionTransform>, provideDaffProductMagentoProductTransform: <R extends MagentoBundleProductOptionTransform = MagentoBundleProductOptionTransform>(value: R) => import("@angular/core").ValueProvider;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { DaffCompositeProductItem } from '@daffodil/product-composite';
|
2
|
+
import { MagentoBundledProductItem } from '../models/bundled-product';
|
3
|
+
export type MagentoBundleProductItemExtraTransform<T extends MagentoBundledProductItem = MagentoBundledProductItem, V extends DaffCompositeProductItem = DaffCompositeProductItem> = (daffItem: DaffCompositeProductItem, magentoItem: T) => V;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { DaffCompositeProductItem } from '@daffodil/product-composite';
|
2
|
+
import { MagentoBundledProductItem } from '../models/bundled-product';
|
3
|
+
export type MagentoBundleProductItemTransform<T extends MagentoBundledProductItem = MagentoBundledProductItem, V extends DaffCompositeProductItem = DaffCompositeProductItem> = (magentoItem: T) => V;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { DaffCompositeProductItemOption } from '@daffodil/product-composite';
|
2
|
+
import { MagentoBundledProductItemOption } from '../models/bundled-product';
|
3
|
+
export type MagentoBundleProductOptionExtraTransform<T extends MagentoBundledProductItemOption = MagentoBundledProductItemOption, V extends DaffCompositeProductItemOption = DaffCompositeProductItemOption> = (daffOption: DaffCompositeProductItemOption, magentoOption: T) => V;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { DaffCompositeProductItemOption } from '@daffodil/product-composite';
|
2
|
+
import { MagentoBundledProductItemOption } from '../models/bundled-product';
|
3
|
+
export type MagentoBundleProductOptionTransform<T extends MagentoBundledProductItemOption = MagentoBundledProductItemOption, V extends DaffCompositeProductItemOption = DaffCompositeProductItemOption> = (magentoOption: T) => V;
|
@@ -2,3 +2,5 @@ export { magentoBundledProductFragment } from './fragments/bundled-product';
|
|
2
2
|
export { DaffCompositeProductMagentoDriverModule } from './composite-product-driver.module';
|
3
3
|
export * from './transforms/public_api';
|
4
4
|
export * from './models/public_api';
|
5
|
+
export * from './injection-tokens/public_api';
|
6
|
+
export * from './interfaces/public_api';
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { DaffCompositeProductItem } from '@daffodil/product-composite';
|
2
|
+
import { MagentoBundleProductOptionTransform } from '../interfaces/public_api';
|
3
|
+
import { MagentoBundledProductItem } from '../models/bundled-product';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export declare class MagentoBundledProductItemTransformer {
|
6
|
+
private optionTransform;
|
7
|
+
constructor(optionTransform: MagentoBundleProductOptionTransform);
|
8
|
+
transform(item: MagentoBundledProductItem): DaffCompositeProductItem;
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MagentoBundledProductItemTransformer, never>;
|
10
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MagentoBundledProductItemTransformer>;
|
11
|
+
}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { DaffCompositeProductItemOption } from '@daffodil/product-composite';
|
2
|
+
import { MagentoBundledProductItemOption } from '../models/bundled-product';
|
3
|
+
export declare function transformMagentoBundledProductItemOption(option: MagentoBundledProductItemOption): DaffCompositeProductItemOption;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { DaffProduct } from '@daffodil/product';
|
2
|
+
import { DaffCompositeProduct } from '@daffodil/product-composite';
|
3
|
+
import { MagentoBundleProductItemTransform } from '../interfaces/public_api';
|
4
|
+
import { MagentoBundledProduct } from '../models/bundled-product';
|
5
|
+
import * as i0 from "@angular/core";
|
6
|
+
export declare class MagentoBundledProductTransformer {
|
7
|
+
private itemTransform;
|
8
|
+
constructor(itemTransform: MagentoBundleProductItemTransform);
|
9
|
+
/**
|
10
|
+
* Transforms the magento MagentoProduct from the magento product query into a DaffProduct.
|
11
|
+
*
|
12
|
+
* @param response the response from a magento product query.
|
13
|
+
*/
|
14
|
+
transform(daffProduct: DaffProduct, { items }: MagentoBundledProduct): DaffCompositeProduct;
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MagentoBundledProductTransformer, never>;
|
16
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MagentoBundledProductTransformer>;
|
17
|
+
}
|
@@ -16,11 +16,11 @@ class DaffCompositeProductInMemoryDriverModule {
|
|
16
16
|
],
|
17
17
|
};
|
18
18
|
}
|
19
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.
|
20
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.
|
21
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.
|
19
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffCompositeProductInMemoryDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
20
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.11", ngImport: i0, type: DaffCompositeProductInMemoryDriverModule, imports: [CommonModule] }); }
|
21
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffCompositeProductInMemoryDriverModule, imports: [CommonModule] }); }
|
22
22
|
}
|
23
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffCompositeProductInMemoryDriverModule, decorators: [{
|
24
24
|
type: NgModule,
|
25
25
|
args: [{
|
26
26
|
imports: [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"daffodil-product-composite-driver-in-memory.mjs","sources":["../../../libs/product-composite/driver/in-memory/src/in-memory.module.ts","../../../libs/product-composite/driver/in-memory/src/daffodil-product-composite-driver-in-memory.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffProductExtraFactoryTypes } from '@daffodil/product/testing';\nimport { DaffCompositeProductFactory } from '@daffodil/product-composite/testing';\n\n/**\n * Module for providing the composite product factory to the product kind factory.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffCompositeProductInMemoryDriverModule {\n static forRoot(): ModuleWithProviders<DaffCompositeProductInMemoryDriverModule> {\n return {\n ngModule: DaffCompositeProductInMemoryDriverModule,\n providers: [\n provideDaffProductExtraFactoryTypes(DaffCompositeProductFactory),\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AASA;;AAEG;MAMU,wCAAwC,CAAA;AACnD,IAAA,OAAO,OAAO,GAAA;QACZ,OAAO;AACL,YAAA,QAAQ,EAAE,wCAAwC;AAClD,YAAA,SAAS,EAAE;gBACT,mCAAmC,CAAC,2BAA2B,CAAC;AACjE,aAAA;SACF;;
|
1
|
+
{"version":3,"file":"daffodil-product-composite-driver-in-memory.mjs","sources":["../../../libs/product-composite/driver/in-memory/src/in-memory.module.ts","../../../libs/product-composite/driver/in-memory/src/daffodil-product-composite-driver-in-memory.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffProductExtraFactoryTypes } from '@daffodil/product/testing';\nimport { DaffCompositeProductFactory } from '@daffodil/product-composite/testing';\n\n/**\n * Module for providing the composite product factory to the product kind factory.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffCompositeProductInMemoryDriverModule {\n static forRoot(): ModuleWithProviders<DaffCompositeProductInMemoryDriverModule> {\n return {\n ngModule: DaffCompositeProductInMemoryDriverModule,\n providers: [\n provideDaffProductExtraFactoryTypes(DaffCompositeProductFactory),\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AASA;;AAEG;MAMU,wCAAwC,CAAA;AACnD,IAAA,OAAO,OAAO,GAAA;QACZ,OAAO;AACL,YAAA,QAAQ,EAAE,wCAAwC;AAClD,YAAA,SAAS,EAAE;gBACT,mCAAmC,CAAC,2BAA2B,CAAC;AACjE,aAAA;SACF;;kIAPQ,wCAAwC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAxC,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,wCAAwC,YAHjD,YAAY,CAAA,EAAA,CAAA,CAAA;AAGH,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,wCAAwC,YAHjD,YAAY,CAAA,EAAA,CAAA,CAAA;;4FAGH,wCAAwC,EAAA,UAAA,EAAA,CAAA;kBALpD,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA;;;AChBD;;AAEG;;;;"}
|
@@ -9,11 +9,11 @@ import { MockMagentoCoreProduct } from '@daffodil/product/driver/magento/testing
|
|
9
9
|
class MockMagentoBundledProductItemOption {
|
10
10
|
constructor(simpleFactory) {
|
11
11
|
this.simpleFactory = simpleFactory;
|
12
|
-
this.uid = faker.
|
13
|
-
this.label = faker.
|
14
|
-
this.quantity = faker.
|
12
|
+
this.uid = faker.string.uuid();
|
13
|
+
this.label = faker.lorem.word();
|
14
|
+
this.quantity = faker.number.int({ min: 1, max: 20 });
|
15
15
|
this.is_default = faker.datatype.boolean();
|
16
|
-
this.position = faker.
|
16
|
+
this.position = faker.number.int({ min: 1, max: 10 });
|
17
17
|
this.product = this.createProduct();
|
18
18
|
}
|
19
19
|
createProduct() {
|
@@ -27,10 +27,10 @@ class MagentoBundledProductItemOptionFactory extends DaffModelFactory {
|
|
27
27
|
constructor(simpleFactory) {
|
28
28
|
super(MockMagentoBundledProductItemOption, simpleFactory);
|
29
29
|
}
|
30
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.
|
31
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.
|
30
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemOptionFactory, deps: [{ token: i1.MagentoSimpleProductFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
31
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemOptionFactory, providedIn: 'root' }); }
|
32
32
|
}
|
33
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemOptionFactory, decorators: [{
|
34
34
|
type: Injectable,
|
35
35
|
args: [{
|
36
36
|
providedIn: 'root',
|
@@ -41,13 +41,13 @@ class MockMagentoBundledProductItem {
|
|
41
41
|
constructor(optionFactory) {
|
42
42
|
this.optionFactory = optionFactory;
|
43
43
|
this.required = faker.datatype.boolean();
|
44
|
-
this.title = faker.
|
45
|
-
this.type = faker.
|
44
|
+
this.title = faker.lorem.word();
|
45
|
+
this.type = faker.lorem.word();
|
46
46
|
this.options = this.createOptions();
|
47
|
-
this.option_id = faker.
|
47
|
+
this.option_id = faker.number.int({ min: 1, max: 9999 });
|
48
48
|
}
|
49
49
|
createOptions() {
|
50
|
-
return this.optionFactory.createMany(faker.
|
50
|
+
return this.optionFactory.createMany(faker.number.int({ min: 1, max: 5 }));
|
51
51
|
}
|
52
52
|
}
|
53
53
|
/**
|
@@ -57,10 +57,10 @@ class MagentoBundledProductItemFactory extends DaffModelFactory {
|
|
57
57
|
constructor(optionFactory) {
|
58
58
|
super(MockMagentoBundledProductItem, optionFactory);
|
59
59
|
}
|
60
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.
|
61
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.
|
60
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemFactory, deps: [{ token: MagentoBundledProductItemOptionFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
61
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemFactory, providedIn: 'root' }); }
|
62
62
|
}
|
63
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.
|
63
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemFactory, decorators: [{
|
64
64
|
type: Injectable,
|
65
65
|
args: [{
|
66
66
|
providedIn: 'root',
|
@@ -75,7 +75,7 @@ class MockMagentoBundledProduct extends MockMagentoCoreProduct {
|
|
75
75
|
this.items = this.createBundleItems();
|
76
76
|
}
|
77
77
|
createBundleItems() {
|
78
|
-
return this.bundleItemFactory.createMany(faker.
|
78
|
+
return this.bundleItemFactory.createMany(faker.number.int({ min: 1, max: 5 }));
|
79
79
|
}
|
80
80
|
}
|
81
81
|
/**
|
@@ -85,10 +85,10 @@ class MagentoBundledProductFactory extends DaffModelFactory {
|
|
85
85
|
constructor(bundleItemFactory) {
|
86
86
|
super(MockMagentoBundledProduct, bundleItemFactory);
|
87
87
|
}
|
88
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.
|
89
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.
|
88
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductFactory, deps: [{ token: MagentoBundledProductItemFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
89
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductFactory, providedIn: 'root' }); }
|
90
90
|
}
|
91
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.
|
91
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductFactory, decorators: [{
|
92
92
|
type: Injectable,
|
93
93
|
args: [{
|
94
94
|
providedIn: 'root',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"daffodil-product-composite-driver-magento-testing.mjs","sources":["../../../libs/product-composite/driver/magento/testing/src/factories/bundle/bundle-item-option.factory.ts","../../../libs/product-composite/driver/magento/testing/src/factories/bundle/bundle-item.factory.ts","../../../libs/product-composite/driver/magento/testing/src/factories/bundle/bundle.factory.ts","../../../libs/product-composite/driver/magento/testing/src/daffodil-product-composite-driver-magento-testing.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { MagentoSimpleProduct } from '@daffodil/product/driver/magento';\nimport { MagentoSimpleProductFactory } from '@daffodil/product/driver/magento/testing';\nimport { MagentoBundledProductItemOption } from '@daffodil/product-composite/driver/magento';\n\n\nexport class MockMagentoBundledProductItemOption implements MagentoBundledProductItemOption {\n constructor(\n private simpleFactory: MagentoSimpleProductFactory,\n ) {}\n\n uid = faker.
|
1
|
+
{"version":3,"file":"daffodil-product-composite-driver-magento-testing.mjs","sources":["../../../libs/product-composite/driver/magento/testing/src/factories/bundle/bundle-item-option.factory.ts","../../../libs/product-composite/driver/magento/testing/src/factories/bundle/bundle-item.factory.ts","../../../libs/product-composite/driver/magento/testing/src/factories/bundle/bundle.factory.ts","../../../libs/product-composite/driver/magento/testing/src/daffodil-product-composite-driver-magento-testing.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { MagentoSimpleProduct } from '@daffodil/product/driver/magento';\nimport { MagentoSimpleProductFactory } from '@daffodil/product/driver/magento/testing';\nimport { MagentoBundledProductItemOption } from '@daffodil/product-composite/driver/magento';\n\n\nexport class MockMagentoBundledProductItemOption implements MagentoBundledProductItemOption {\n constructor(\n private simpleFactory: MagentoSimpleProductFactory,\n ) {}\n\n uid = faker.string.uuid();\n label = faker.lorem.word();\n quantity = faker.number.int({ min: 1, max: 20 });\n is_default = faker.datatype.boolean();\n position = faker.number.int({ min: 1, max: 10 });\n product = this.createProduct();\n\n protected createProduct(): MagentoSimpleProduct {\n return this.simpleFactory.create();\n }\n}\n\n/**\n * A factory for creating stub data for {@link MagentoBundledProduct}s.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class MagentoBundledProductItemOptionFactory extends DaffModelFactory<MagentoBundledProductItemOption> {\n constructor(\n simpleFactory: MagentoSimpleProductFactory,\n ) {\n super(MockMagentoBundledProductItemOption, simpleFactory);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport {\n MagentoBundledProductItem,\n MagentoBundledProductItemOption,\n} from '@daffodil/product-composite/driver/magento';\n\nimport { MagentoBundledProductItemOptionFactory } from './bundle-item-option.factory';\n\n\nexport class MockMagentoBundledProductItem implements MagentoBundledProductItem {\n constructor(\n private optionFactory: MagentoBundledProductItemOptionFactory,\n ) {}\n required = faker.datatype.boolean();\n title = faker.lorem.word();\n type = faker.lorem.word();\n options = this.createOptions();\n option_id = faker.number.int({ min: 1, max: 9999 });\n\n protected createOptions(): MagentoBundledProductItemOption[] {\n return this.optionFactory.createMany(faker.number.int({ min: 1, max: 5 }));\n }\n}\n\n/**\n * A factory for creating stub data for {@link MagentoBundledProduct}s.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class MagentoBundledProductItemFactory extends DaffModelFactory<MagentoBundledProductItem> {\n constructor(\n optionFactory: MagentoBundledProductItemOptionFactory,\n ) {\n super(MockMagentoBundledProductItem, optionFactory);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { MagentoProductTypeEnum } from '@daffodil/product/driver/magento';\nimport { MockMagentoCoreProduct } from '@daffodil/product/driver/magento/testing';\nimport {\n MagentoBundledProduct,\n MagentoBundledProductItem,\n} from '@daffodil/product-composite/driver/magento';\n\nimport { MagentoBundledProductItemFactory } from './bundle-item.factory';\n\nexport class MockMagentoBundledProduct extends MockMagentoCoreProduct implements MagentoBundledProduct {\n constructor(\n private bundleItemFactory: MagentoBundledProductItemFactory,\n ) {\n super();\n }\n\n __typename = MagentoProductTypeEnum.BundledProduct;\n items = this.createBundleItems();\n\n protected createBundleItems(): MagentoBundledProductItem[] {\n return this.bundleItemFactory.createMany(faker.number.int({ min: 1, max: 5 }));\n }\n}\n\n/**\n * A factory for creating stub data for {@link MagentoBundledProduct}s.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class MagentoBundledProductFactory extends DaffModelFactory<MagentoBundledProduct> {\n constructor(\n bundleItemFactory: MagentoBundledProductItemFactory,\n ) {\n super(MockMagentoBundledProduct, bundleItemFactory);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.MagentoBundledProductItemOptionFactory","i1.MagentoBundledProductItemFactory"],"mappings":"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"}
|
@@ -1,18 +1,24 @@
|
|
1
1
|
import { gql } from 'apollo-angular';
|
2
|
+
import { daffBuildFragmentNameSpread, daffBuildFragmentDefinition } from '@daffodil/core/graphql';
|
2
3
|
import { CommonModule } from '@angular/common';
|
3
4
|
import * as i0 from '@angular/core';
|
4
|
-
import { NgModule } from '@angular/core';
|
5
|
-
import { MagentoProductStockStatusEnum,
|
5
|
+
import { inject, Inject, Injectable, NgModule } from '@angular/core';
|
6
|
+
import { MagentoProductStockStatusEnum, DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_FRAGMENTS, DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_TRANSFORMS, provideDaffProductMagentoExtraProductPreviewTransforms, MagentoProductTypeEnum } from '@daffodil/product/driver/magento';
|
7
|
+
import { createMultiInjectionToken, createSingleInjectionToken } from '@daffodil/core';
|
6
8
|
import { DaffProductTypeEnum } from '@daffodil/product';
|
7
9
|
|
8
|
-
const magentoBundledProductFragment = gql `
|
10
|
+
const magentoBundledProductFragment = (extraItemFragments = [], extraOptionFragments = []) => gql `
|
9
11
|
fragment magentoBundledProduct on BundleProduct {
|
10
12
|
items {
|
13
|
+
${daffBuildFragmentNameSpread(...extraItemFragments)}
|
14
|
+
|
11
15
|
option_id
|
12
16
|
required
|
13
17
|
title
|
14
18
|
type
|
15
19
|
options {
|
20
|
+
${daffBuildFragmentNameSpread(...extraOptionFragments)}
|
21
|
+
|
16
22
|
uid
|
17
23
|
is_default
|
18
24
|
label
|
@@ -36,36 +42,206 @@ fragment magentoBundledProduct on BundleProduct {
|
|
36
42
|
}
|
37
43
|
}
|
38
44
|
}
|
45
|
+
${daffBuildFragmentDefinition(...extraItemFragments, ...extraOptionFragments)}
|
39
46
|
`;
|
40
47
|
|
48
|
+
const {
|
41
49
|
/**
|
42
|
-
*
|
50
|
+
* A multi-provider injection token for providing extra GraphQL fragments that will be spread into product queries.
|
51
|
+
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces.
|
43
52
|
*
|
44
|
-
*
|
53
|
+
* Fragment structure is platform-specific and this feature should be used with care.
|
54
|
+
*
|
55
|
+
* This can increase query complexity above the Magento default of 300.
|
56
|
+
* Daffodil only guarantees that stock queries don't exceed the limit of 300.
|
57
|
+
* Apps using this token should therefore increase the query complexity limit
|
58
|
+
* to accommodate the extra complexity contributed by the provided fragments.
|
45
59
|
*/
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
token: DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_FRAGMENTS,
|
61
|
+
/**
|
62
|
+
* Provides extra GraphQL fragments for the Magento product driver.
|
63
|
+
*
|
64
|
+
* See {@link DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_FRAGMENTS}.
|
65
|
+
*
|
66
|
+
* @example
|
67
|
+
* ```ts
|
68
|
+
* providers: [
|
69
|
+
* ...provideDaffProductCompositeMagentoExtraItemFragments(
|
70
|
+
* myExtraProductFragment
|
71
|
+
* )
|
72
|
+
* ]
|
73
|
+
* ```
|
74
|
+
*/
|
75
|
+
provider: provideDaffProductCompositeMagentoExtraItemFragments, } = createMultiInjectionToken('DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_FRAGMENTS');
|
76
|
+
|
77
|
+
const {
|
78
|
+
/**
|
79
|
+
* A multi-provider injection token for providing extra GraphQL fragments that will be spread into product queries.
|
80
|
+
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces.
|
81
|
+
*
|
82
|
+
* Fragment structure is platform-specific and this feature should be used with care.
|
83
|
+
*
|
84
|
+
* This can increase query complexity above the Magento default of 300.
|
85
|
+
* Daffodil only guarantees that stock queries don't exceed the limit of 300.
|
86
|
+
* Apps using this token should therefore increase the query complexity limit
|
87
|
+
* to accommodate the extra complexity contributed by the provided fragments.
|
88
|
+
*/
|
89
|
+
token: DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_FRAGMENTS,
|
90
|
+
/**
|
91
|
+
* Provides extra GraphQL fragments for the Magento product driver.
|
92
|
+
*
|
93
|
+
* See {@link DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_FRAGMENTS}.
|
94
|
+
*
|
95
|
+
* @example
|
96
|
+
* ```ts
|
97
|
+
* providers: [
|
98
|
+
* ...provideDaffProductCompositeMagentoExtraOptionFragments(
|
99
|
+
* myExtraProductFragment
|
100
|
+
* )
|
101
|
+
* ]
|
102
|
+
* ```
|
103
|
+
*/
|
104
|
+
provider: provideDaffProductCompositeMagentoExtraOptionFragments, } = createMultiInjectionToken('DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_FRAGMENTS');
|
105
|
+
|
106
|
+
const {
|
107
|
+
/**
|
108
|
+
* A multi-provider injection token for providing extra transform logic in the Product Magento driver.
|
109
|
+
* It is run after the standard transforms for each product preview and passed both the current transformed Daffodil product and the Magento product.
|
110
|
+
*
|
111
|
+
* See {@link MagentoBundledProductItem} for more info.
|
112
|
+
*/
|
113
|
+
token: DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_TRANSFORMS, provider: provider$1, } = createMultiInjectionToken('DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_TRANSFORMS');
|
114
|
+
/**
|
115
|
+
* Provides extra product preview transforms for the Magento product driver.
|
116
|
+
*
|
117
|
+
* See {@link DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_TRANSFORMS}.
|
118
|
+
*
|
119
|
+
* @example
|
120
|
+
* ```ts
|
121
|
+
* providers: [
|
122
|
+
* ...provideDaffProductCompositeMagentoExtraItemTransforms(
|
123
|
+
* myExtraProductTransform
|
124
|
+
* )
|
125
|
+
* ]
|
126
|
+
* ```
|
127
|
+
*/
|
128
|
+
function provideDaffProductCompositeMagentoExtraItemTransforms(...transforms) {
|
129
|
+
return provider$1(...transforms);
|
59
130
|
}
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
131
|
+
|
132
|
+
const {
|
133
|
+
/**
|
134
|
+
* A multi-provider injection token for providing extra transform logic in the Product Magento driver.
|
135
|
+
* It is run after the standard transforms for each product preview and passed both the current transformed Daffodil product and the Magento product.
|
136
|
+
*
|
137
|
+
* See {@link MagentoBundledProductItemOption} for more info.
|
138
|
+
*/
|
139
|
+
token: DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_TRANSFORMS, provider, } = createMultiInjectionToken('DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_TRANSFORMS');
|
140
|
+
/**
|
141
|
+
* Provides extra product preview transforms for the Magento product driver.
|
142
|
+
*
|
143
|
+
* See {@link DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_TRANSFORMS}.
|
144
|
+
*
|
145
|
+
* @example
|
146
|
+
* ```ts
|
147
|
+
* providers: [
|
148
|
+
* ...provideDaffProductCompositeMagentoExtraOptionTransforms(
|
149
|
+
* myExtraProductTransform
|
150
|
+
* )
|
151
|
+
* ]
|
152
|
+
* ```
|
153
|
+
*/
|
154
|
+
function provideDaffProductCompositeMagentoExtraOptionTransforms(...transforms) {
|
155
|
+
return provider(...transforms);
|
156
|
+
}
|
157
|
+
|
158
|
+
const {
|
159
|
+
/**
|
160
|
+
* An internal token to combine the Magento preview transform with the injected transforms.
|
161
|
+
*/
|
162
|
+
token: DAFF_PRODUCT_COMPOSITE_MAGENTO_ITEM_TRANSFORM,
|
163
|
+
/**
|
164
|
+
* Provider function for {@link DAFF_PRODUCT_COMPOSITE_MAGENTO_ITEM_TRANSFORM}.
|
165
|
+
*/
|
166
|
+
provider: provideDaffProductMagentoProductTransform$1, } = createSingleInjectionToken('DAFF_PRODUCT_COMPOSITE_MAGENTO_ITEM_TRANSFORM', {
|
167
|
+
factory: () => {
|
168
|
+
const transforms = inject(DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_TRANSFORMS);
|
169
|
+
const transformer = inject(MagentoBundledProductItemTransformer);
|
170
|
+
return (magentoProduct) => transforms.reduce((daffProduct, transform) => transform(daffProduct, magentoProduct), transformer.transform(magentoProduct));
|
171
|
+
},
|
172
|
+
});
|
173
|
+
|
174
|
+
class MagentoBundledProductTransformer {
|
175
|
+
constructor(itemTransform) {
|
176
|
+
this.itemTransform = itemTransform;
|
177
|
+
}
|
178
|
+
/**
|
179
|
+
* Transforms the magento MagentoProduct from the magento product query into a DaffProduct.
|
180
|
+
*
|
181
|
+
* @param response the response from a magento product query.
|
182
|
+
*/
|
183
|
+
transform(daffProduct, { items }) {
|
184
|
+
return {
|
185
|
+
...daffProduct,
|
186
|
+
...items.length > 0 ? {
|
187
|
+
price: 0,
|
188
|
+
discount: {
|
189
|
+
amount: 0,
|
190
|
+
percent: 0,
|
191
|
+
},
|
192
|
+
} : {},
|
193
|
+
type: DaffProductTypeEnum.Composite,
|
194
|
+
items: items.map(this.itemTransform),
|
195
|
+
};
|
196
|
+
}
|
197
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductTransformer, deps: [{ token: DAFF_PRODUCT_COMPOSITE_MAGENTO_ITEM_TRANSFORM }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
198
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductTransformer }); }
|
68
199
|
}
|
200
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductTransformer, decorators: [{
|
201
|
+
type: Injectable
|
202
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
203
|
+
type: Inject,
|
204
|
+
args: [DAFF_PRODUCT_COMPOSITE_MAGENTO_ITEM_TRANSFORM]
|
205
|
+
}] }] });
|
206
|
+
|
207
|
+
const {
|
208
|
+
/**
|
209
|
+
* An internal token to combine the Magento preview transform with the injected transforms.
|
210
|
+
*/
|
211
|
+
token: DAFF_PRODUCT_COMPOSITE_MAGENTO_OPTION_TRANSFORM,
|
212
|
+
/**
|
213
|
+
* Provider function for {@link DAFF_PRODUCT_COMPOSITE_MAGENTO_OPTION_TRANSFORM}.
|
214
|
+
*/
|
215
|
+
provider: provideDaffProductMagentoProductTransform, } = createSingleInjectionToken('DAFF_PRODUCT_COMPOSITE_MAGENTO_OPTION_TRANSFORM', {
|
216
|
+
factory: () => {
|
217
|
+
const transforms = inject(DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_TRANSFORMS);
|
218
|
+
return (magentoProduct) => transforms.reduce((daffProduct, transform) => transform(daffProduct, magentoProduct), transformMagentoBundledProductItemOption(magentoProduct));
|
219
|
+
},
|
220
|
+
});
|
221
|
+
|
222
|
+
class MagentoBundledProductItemTransformer {
|
223
|
+
constructor(optionTransform) {
|
224
|
+
this.optionTransform = optionTransform;
|
225
|
+
}
|
226
|
+
transform(item) {
|
227
|
+
return {
|
228
|
+
id: item.option_id.toString(),
|
229
|
+
required: item.required,
|
230
|
+
title: item.title,
|
231
|
+
input_type: item.type,
|
232
|
+
options: Array.from(item.options).sort((a, b) => a.position - b.position).map(this.optionTransform),
|
233
|
+
};
|
234
|
+
}
|
235
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemTransformer, deps: [{ token: DAFF_PRODUCT_COMPOSITE_MAGENTO_OPTION_TRANSFORM }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
236
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemTransformer }); }
|
237
|
+
}
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: MagentoBundledProductItemTransformer, decorators: [{
|
239
|
+
type: Injectable
|
240
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
241
|
+
type: Inject,
|
242
|
+
args: [DAFF_PRODUCT_COMPOSITE_MAGENTO_OPTION_TRANSFORM]
|
243
|
+
}] }] });
|
244
|
+
|
69
245
|
function transformMagentoBundledProductItemOption(option) {
|
70
246
|
return {
|
71
247
|
id: option.uid.toString(),
|
@@ -103,10 +279,23 @@ class DaffCompositeProductMagentoDriverModule {
|
|
103
279
|
return {
|
104
280
|
ngModule: DaffCompositeProductMagentoDriverModule,
|
105
281
|
providers: [
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
:
|
282
|
+
MagentoBundledProductTransformer,
|
283
|
+
MagentoBundledProductItemTransformer,
|
284
|
+
{
|
285
|
+
provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_FRAGMENTS,
|
286
|
+
useFactory: () => magentoBundledProductFragment(inject(DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_FRAGMENTS), inject(DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_FRAGMENTS)),
|
287
|
+
multi: true,
|
288
|
+
},
|
289
|
+
{
|
290
|
+
provide: DAFF_PRODUCT_MAGENTO_EXTRA_PRODUCT_TRANSFORMS,
|
291
|
+
useFactory: () => {
|
292
|
+
const transformer = inject(MagentoBundledProductTransformer);
|
293
|
+
return (daffProduct, magentoProduct) => magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
|
294
|
+
? transformer.transform(daffProduct, magentoProduct)
|
295
|
+
: daffProduct;
|
296
|
+
},
|
297
|
+
multi: true,
|
298
|
+
},
|
110
299
|
// stub out composite fields for a preview
|
111
300
|
...provideDaffProductMagentoExtraProductPreviewTransforms((daffProduct, magentoProduct) => magentoProduct.__typename === MagentoProductTypeEnum.BundledProduct
|
112
301
|
? {
|
@@ -122,11 +311,11 @@ class DaffCompositeProductMagentoDriverModule {
|
|
122
311
|
],
|
123
312
|
};
|
124
313
|
}
|
125
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.
|
126
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.
|
127
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.
|
314
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffCompositeProductMagentoDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
315
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.11", ngImport: i0, type: DaffCompositeProductMagentoDriverModule, imports: [CommonModule] }); }
|
316
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffCompositeProductMagentoDriverModule, imports: [CommonModule] }); }
|
128
317
|
}
|
129
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.
|
318
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffCompositeProductMagentoDriverModule, decorators: [{
|
130
319
|
type: NgModule,
|
131
320
|
args: [{
|
132
321
|
imports: [
|
@@ -146,5 +335,5 @@ var MagentoPriceTypeEnum;
|
|
146
335
|
* Generated bundle index. Do not edit.
|
147
336
|
*/
|
148
337
|
|
149
|
-
export { DaffCompositeProductMagentoDriverModule, MagentoPriceTypeEnum, magentoBundledProductFragment,
|
338
|
+
export { DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_FRAGMENTS, DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_ITEM_TRANSFORMS, DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_FRAGMENTS, DAFF_PRODUCT_COMPOSITE_MAGENTO_EXTRA_OPTION_TRANSFORMS, DaffCompositeProductMagentoDriverModule, MagentoBundledProductItemTransformer, MagentoBundledProductTransformer, MagentoPriceTypeEnum, magentoBundledProductFragment, provideDaffProductCompositeMagentoExtraItemFragments, provideDaffProductCompositeMagentoExtraItemTransforms, provideDaffProductCompositeMagentoExtraOptionFragments, provideDaffProductCompositeMagentoExtraOptionTransforms, transformMagentoBundledProductItemOption };
|
150
339
|
//# sourceMappingURL=daffodil-product-composite-driver-magento.mjs.map
|