@daffodil/product 0.94.1 → 0.95.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/fesm2022/daffodil-product-driver-in-memory.mjs +200 -227
  2. package/fesm2022/daffodil-product-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-product-driver-magento-2.4.7-testing.mjs +444 -0
  4. package/fesm2022/daffodil-product-driver-magento-2.4.7-testing.mjs.map +1 -0
  5. package/fesm2022/daffodil-product-driver-magento-2.4.7.mjs +704 -0
  6. package/fesm2022/daffodil-product-driver-magento-2.4.7.mjs.map +1 -0
  7. package/fesm2022/daffodil-product-driver-magento-auto-testing.mjs +7 -0
  8. package/fesm2022/daffodil-product-driver-magento-auto-testing.mjs.map +1 -0
  9. package/fesm2022/daffodil-product-driver-magento-auto.mjs +7 -0
  10. package/fesm2022/daffodil-product-driver-magento-auto.mjs.map +1 -0
  11. package/fesm2022/daffodil-product-driver-shopify.mjs +99 -127
  12. package/fesm2022/daffodil-product-driver-shopify.mjs.map +1 -1
  13. package/fesm2022/daffodil-product-driver-testing.mjs +117 -87
  14. package/fesm2022/daffodil-product-driver-testing.mjs.map +1 -1
  15. package/fesm2022/daffodil-product-driver.mjs +22 -45
  16. package/fesm2022/daffodil-product-driver.mjs.map +1 -1
  17. package/fesm2022/daffodil-product-routing.mjs +347 -285
  18. package/fesm2022/daffodil-product-routing.mjs.map +1 -1
  19. package/fesm2022/daffodil-product-state-testing.mjs +189 -106
  20. package/fesm2022/daffodil-product-state-testing.mjs.map +1 -1
  21. package/fesm2022/daffodil-product-state.mjs +566 -659
  22. package/fesm2022/daffodil-product-state.mjs.map +1 -1
  23. package/fesm2022/daffodil-product-testing.mjs +316 -276
  24. package/fesm2022/daffodil-product-testing.mjs.map +1 -1
  25. package/fesm2022/daffodil-product.mjs +8 -29
  26. package/fesm2022/daffodil-product.mjs.map +1 -1
  27. package/package.json +1 -1
  28. package/types/daffodil-product-driver-in-memory.d.ts +65 -75
  29. package/types/daffodil-product-driver-magento-2.4.7-testing.d.ts +105 -0
  30. package/types/daffodil-product-driver-magento-2.4.7.d.ts +337 -0
  31. package/types/daffodil-product-driver-magento-auto-testing.d.ts +1 -0
  32. package/types/daffodil-product-driver-magento-auto.d.ts +1 -0
  33. package/types/daffodil-product-driver-shopify.d.ts +31 -43
  34. package/types/daffodil-product-driver-testing.d.ts +28 -26
  35. package/types/daffodil-product-driver.d.ts +50 -61
  36. package/types/daffodil-product-routing.d.ts +101 -110
  37. package/types/daffodil-product-state-testing.d.ts +45 -43
  38. package/types/daffodil-product-state.d.ts +347 -375
  39. package/types/daffodil-product-testing.d.ts +82 -89
  40. package/types/daffodil-product.d.ts +93 -102
  41. package/fesm2022/daffodil-product-driver-magento-testing.mjs +0 -275
  42. package/fesm2022/daffodil-product-driver-magento-testing.mjs.map +0 -1
  43. package/fesm2022/daffodil-product-driver-magento.mjs +0 -855
  44. package/fesm2022/daffodil-product-driver-magento.mjs.map +0 -1
  45. package/types/daffodil-product-driver-magento-testing.d.ts +0 -114
  46. package/types/daffodil-product-driver-magento.d.ts +0 -396
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-product-testing.mjs","sources":["../../../libs/product/testing/src/factories/product-image.factory.ts","../../../libs/product/testing/src/factories/default-product.factory.ts","../../../libs/product/testing/src/injection-tokens/factories/type.token.ts","../../../libs/product/testing/src/injection-tokens/factories/extra.token.ts","../../../libs/product/testing/src/factories/kind.factory.ts","../../../libs/product/testing/src/factories/extension.factory.ts","../../../libs/product/testing/src/factories/collection.factory.ts","../../../libs/product/testing/src/helpers.ts","../../../libs/product/testing/src/testing.module.ts","../../../libs/product/testing/src/daffodil-product-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 { DaffProductImage } from '@daffodil/product';\n\nconst productImageUrlsList: string[] = [\n 'https://assets.daff.io/elegant_gold_soap.png',\n 'https://assets.daff.io/elegant_plastic_gloves.png',\n 'https://assets.daff.io/ergonomic_bronze_pants.png',\n 'https://assets.daff.io/fantastic_aluminum_keyboard.png',\n 'https://assets.daff.io/frozen_metal_soap_bubbles.png',\n 'https://assets.daff.io/frozen_metal_soap.png',\n 'https://assets.daff.io/handcrafted_bamboo_cheese.png',\n 'https://assets.daff.io/incredible_ceramic_bike_blue.png',\n 'https://assets.daff.io/modern_bronze_chair.png',\n 'https://assets.daff.io/modern_granite_tuna.png',\n 'https://assets.daff.io/recycled_wooden_table.png',\n 'https://assets.daff.io/refined_cotton_pants.png',\n 'https://assets.daff.io/refined_rubber_gloves.png',\n 'https://assets.daff.io/rustic_bronze_computer.png',\n 'https://assets.daff.io/rustic_ceramic_chips.png',\n 'https://assets.daff.io/sleek_metal_shirt.png',\n 'https://assets.daff.io/soft_granite_pants.png',\n 'https://assets.daff.io/tasty_wooden_sausages.png',\n];\n\n/**\n * Mocked DaffProductImage object.\n */\nexport class MockProductImage implements DaffProductImage {\n id = faker.string.uuid();\n url = productImageUrlsList[faker.number.int(productImageUrlsList.length-1)];\n label = faker.lorem.sentence();\n}\n\n/**\n * A factory for creating DaffProductImage.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffProductImageFactory extends DaffModelFactory<DaffProductImage> {\n constructor(){\n super(MockProductImage);\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 DaffProduct,\n DaffProductTypeEnum,\n} from '@daffodil/product';\n\nimport { DaffProductImageFactory } from './product-image.factory';\n\n/**\n * Mocked DaffProduct object.\n */\nexport class MockProduct implements DaffProduct {\n private stubPrice = faker.number.int({ min: 1, max: 1500 });\n private stubDiscount = faker.number.int({ min: 0, max: this.stubPrice - 1 });\n\n type = DaffProductTypeEnum.Simple;\n id = faker.string.uuid();\n url = `/${faker.internet.domainWord()}.html`;\n canonicalUrl = faker.internet.url();\n price = this.stubPrice;\n in_stock = true;\n discount = {\n amount: this.stubDiscount,\n percent: Math.floor((this.stubDiscount/this.stubPrice) * 100),\n };\n images = this.imageFactory.createMany(faker.number.int({ min: 1, max: 10 }));\n thumbnail = this.imageFactory.create();\n name = faker.commerce.productName();\n brand = faker.company.name();\n description = faker.commerce.productDescription();\n short_description = faker.commerce.productDescription();\n meta_title = faker.commerce.productName();\n meta_description = faker.commerce.productDescription();\n\n constructor(\n protected imageFactory: DaffProductImageFactory,\n ) {}\n}\n\n/**\n * Factory for creating simple `DaffProduct`s of no special kind.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffDefaultProductFactory extends DaffModelFactory<DaffProduct> {\n constructor(\n imageFactory: DaffProductImageFactory,\n ) {\n super(MockProduct, imageFactory);\n }\n}\n","import { createServicesInjectionToken } from '@daffodil/core';\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProduct } from '@daffodil/product';\n\nexport const {\n /**\n * A multi-provider injection token for providing extra product type factories.\n * These factories correspond to different product types that may be added by other packages.\n * This is useful for backend mocks (such as the in-memory driver) to generate an accurate representation\n * of the variety of products that an application can receive in production.\n */\n token: DAFF_PRODUCT_TYPE_FACTORIES,\n\n /**\n * Provides extra product factory types.\n *\n * See {@link DAFF_PRODUCT_TYPE_FACTORIES}.\n *\n * @example\n * ```ts\n * providers: [\n * ...provideDaffProductExtraFactoryTypes(\n * MyProductFactory\n * )\n * ]\n * ```\n */\n provider: provideDaffProductExtraFactoryTypes,\n} = createServicesInjectionToken<DaffModelFactory<DaffProduct>>(\n 'DAFF_PRODUCT_TYPE_FACTORIES',\n { providedIn: 'root' },\n);\n","import { createServicesInjectionToken } from '@daffodil/core';\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProduct } from '@daffodil/product';\n\nexport const {\n /**\n * A multi-provider injection token for providing extra product factories.\n * These extra factories represent the additional product fields that may be added by other packages.\n * This is useful for backend mocks (such as the in-memory driver) to generate an accurate representation\n * of the entire product data that an application can receive in production.\n *\n * These factories will be invoked ang the return included in {@link DaffProductFactory}.\n */\n token: DAFF_PRODUCT_EXTRA_FACTORIES,\n\n /**\n * Provides extra product factories.\n *\n * See {@link DAFF_PRODUCT_EXTRA_FACTORIES}.\n *\n * @example\n * ```ts\n * providers: [\n * ...provideDaffProductExtraProductFactories(\n * MyProductFactory\n * )\n * ]\n * ```\n */\n provider: provideDaffProductExtraProductFactories,\n} = createServicesInjectionToken<DaffModelFactory<DaffProduct>>(\n 'DAFF_PRODUCT_EXTRA_FACTORIES',\n { providedIn: 'root' },\n);\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\n\nimport { sample } from '@daffodil/core';\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProduct } from '@daffodil/product';\n\nimport { MockProduct } from './default-product.factory';\nimport { DAFF_PRODUCT_TYPE_FACTORIES } from '../injection-tokens/public_api';\n\n/**\n * Factory for creating DaffProducts.\n * This will create a random product kind,\n * including extra product kinds that may be provided by optional product packages.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffProductKindFactory extends DaffModelFactory<DaffProduct> {\n constructor(\n @Inject(DAFF_PRODUCT_TYPE_FACTORIES) private productTypeFactories: DaffModelFactory<DaffProduct>[],\n ) {\n super(MockProduct);\n }\n\n private get _randomFactory(): DaffModelFactory<DaffProduct> {\n return sample(this.productTypeFactories);\n }\n\n /**\n * Creates a mock product of random kind.\n * Includes extra product kinds that may be provided by optional product packages.\n */\n create(partial: Partial<DaffProduct> = {}): DaffProduct {\n return this._randomFactory.create(partial);\n }\n}\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProduct } from '@daffodil/product';\n\nimport { DaffProductKindFactory } from './kind.factory';\nimport { DAFF_PRODUCT_EXTRA_FACTORIES } from '../injection-tokens/public_api';\n\n/**\n * Factory for creating `DaffProduct`s with extension fields.\n * This includes all the extra extension factories that may be provided by optional product packages.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffProductExtensionFactory<T extends DaffProduct = DaffProduct> extends DaffModelFactory<T> {\n constructor(\n @Inject(DAFF_PRODUCT_EXTRA_FACTORIES) private extraFactories: DaffModelFactory<T>[],\n private productKindFactory: DaffProductKindFactory,\n ) {\n super(null);\n }\n\n /**\n * Creates a mock product of random type.\n * Includes extra product types that may be provided by optional product packages.\n * This includes all the extra extension factories that may be provided by optional product packages.\n */\n create(partial: Partial<T> = {}): T {\n const kind = this.productKindFactory.create(partial);\n\n return Object.assign(\n {},\n kind,\n ...this.extraFactories.map(factory => factory.create(partial)),\n // spread this in last to preserve kind's type\n { type: kind.type },\n );\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport {\n DaffCollectionMetadataFactory,\n DaffModelFactory,\n MockCollection,\n} from '@daffodil/core/testing';\nimport {\n DaffProduct,\n DaffProductCollection,\n} from '@daffodil/product';\n\nimport { DaffProductKindFactory } from './kind.factory';\n\n/**\n * Mocked {@link DaffProductCollection} object.\n */\nexport class MockProductCollection extends MockCollection<DaffProduct> implements DaffProductCollection {\n constructor(\n productFactory: DaffProductKindFactory,\n metadataFactory: DaffCollectionMetadataFactory,\n ) {\n super(\n productFactory,\n metadataFactory,\n );\n }\n}\n\n/**\n * Factory for creating {@link DaffProductCollection}s.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffProductCollectionFactory extends DaffModelFactory<DaffProductCollection> {\n constructor(\n productFactory: DaffProductKindFactory,\n metadataFactory: DaffCollectionMetadataFactory,\n ) {\n super(MockProductCollection, productFactory, metadataFactory);\n }\n}\n","import { DaffProduct } from '@daffodil/product';\n\n/**\n * A helper function to verify that a model is a Product.\n *\n * @param product\n */\nexport function isProduct(product: DaffProduct): boolean {\n return !!product.id\n && !!product.price\n && !!product.name\n && !!product.brand\n && !!product.description\n && !!product.images;\n}\n","import { NgModule } from '@angular/core';\n\nimport { DaffDefaultProductFactory } from './factories/public_api';\nimport { provideDaffProductExtraFactoryTypes } from './injection-tokens/public_api';\n\n/**\n * Provides the default product factory as a product type factory.\n */\n@NgModule({\n providers: [\n provideDaffProductExtraFactoryTypes(DaffDefaultProductFactory),\n ],\n})\nexport class DaffProductTestingModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.DaffProductImageFactory","i1.DaffProductKindFactory"],"mappings":";;;;;;;;AAMA,MAAM,oBAAoB,GAAa;IACrC,8CAA8C;IAC9C,mDAAmD;IACnD,mDAAmD;IACnD,wDAAwD;IACxD,sDAAsD;IACtD,8CAA8C;IAC9C,sDAAsD;IACtD,yDAAyD;IACzD,gDAAgD;IAChD,gDAAgD;IAChD,kDAAkD;IAClD,iDAAiD;IACjD,kDAAkD;IAClD,mDAAmD;IACnD,iDAAiD;IACjD,8CAA8C;IAC9C,+CAA+C;IAC/C,kDAAkD;CACnD;AAED;;AAEG;MACU,gBAAgB,CAAA;AAA7B,IAAA,WAAA,GAAA;AACE,QAAA,IAAA,CAAA,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;AACxB,QAAA,IAAA,CAAA,GAAG,GAAG,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC;AAC3E,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE;IAChC;AAAC;AAED;;AAEG;AAIG,MAAO,uBAAwB,SAAQ,gBAAkC,CAAA;AAC7E,IAAA,WAAA,GAAA;QACE,KAAK,CAAC,gBAAgB,CAAC;IACzB;iIAHW,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAvB,uBAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAA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CAAC,OAAO,CAAC;AACV,WAAA,CAAC,CAAC,OAAO,CAAC,MAAM;AACvB;;ACTA;;AAEG;MAMU,wBAAwB,CAAA;iIAAxB,wBAAwB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;kIAAxB,wBAAwB,EAAA,CAAA,CAAA;AAAxB,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,wBAAwB,EAAA,SAAA,EAJxB;YACT,mCAAmC,CAAC,yBAAyB,CAAC;AAC/D,SAAA,EAAA,CAAA,CAAA;;2FAEU,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBALpC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,SAAS,EAAE;wBACT,mCAAmC,CAAC,yBAAyB,CAAC;AAC/D,qBAAA;AACF,iBAAA;;;ACZD;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-product-testing.mjs","names":["i1.DaffProductImageFactory","i1.DaffProductKindFactory","i1.DaffProductKindFactory"],"sources":["../../../libs/product/testing/src/factories/product-image.factory.ts","../../../libs/product/testing/src/factories/default-product.factory.ts","../../../libs/product/testing/src/injection-tokens/factories/type.token.ts","../../../libs/product/testing/src/injection-tokens/factories/extra.token.ts","../../../libs/product/testing/src/factories/kind.factory.ts","../../../libs/product/testing/src/factories/extension.factory.ts","../../../libs/product/testing/src/factories/collection.factory.ts","../../../libs/product/testing/src/helpers.ts","../../../libs/product/testing/src/provider.ts","../../../libs/product/testing/src/testing.module.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProductImage } from '@daffodil/product';\n\nconst productImageUrlsList: string[] = [\n 'https://assets.daff.io/elegant_gold_soap.png',\n 'https://assets.daff.io/elegant_plastic_gloves.png',\n 'https://assets.daff.io/ergonomic_bronze_pants.png',\n 'https://assets.daff.io/fantastic_aluminum_keyboard.png',\n 'https://assets.daff.io/frozen_metal_soap_bubbles.png',\n 'https://assets.daff.io/frozen_metal_soap.png',\n 'https://assets.daff.io/handcrafted_bamboo_cheese.png',\n 'https://assets.daff.io/incredible_ceramic_bike_blue.png',\n 'https://assets.daff.io/modern_bronze_chair.png',\n 'https://assets.daff.io/modern_granite_tuna.png',\n 'https://assets.daff.io/recycled_wooden_table.png',\n 'https://assets.daff.io/refined_cotton_pants.png',\n 'https://assets.daff.io/refined_rubber_gloves.png',\n 'https://assets.daff.io/rustic_bronze_computer.png',\n 'https://assets.daff.io/rustic_ceramic_chips.png',\n 'https://assets.daff.io/sleek_metal_shirt.png',\n 'https://assets.daff.io/soft_granite_pants.png',\n 'https://assets.daff.io/tasty_wooden_sausages.png',\n];\n\n/**\n * Mocked DaffProductImage object.\n */\nexport class MockProductImage implements DaffProductImage {\n id = faker.string.uuid();\n url = productImageUrlsList[faker.number.int(productImageUrlsList.length-1)];\n label = faker.lorem.sentence();\n}\n\n/**\n * A factory for creating DaffProductImage.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffProductImageFactory extends DaffModelFactory<DaffProductImage> {\n constructor(){\n super(MockProductImage);\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 DaffProduct,\n DaffProductTypeEnum,\n} from '@daffodil/product';\n\nimport { DaffProductImageFactory } from './product-image.factory';\n\n/**\n * Mocked DaffProduct object.\n */\nexport class MockProduct implements DaffProduct {\n private stubPrice = faker.number.int({ min: 1, max: 1500 });\n private stubDiscount = faker.number.int({ min: 0, max: this.stubPrice - 1 });\n\n type = DaffProductTypeEnum.Simple;\n id = faker.string.uuid();\n url = `/${faker.internet.domainWord()}.html`;\n canonicalUrl = faker.internet.url();\n price = this.stubPrice;\n in_stock = true;\n discount = {\n amount: this.stubDiscount,\n percent: Math.floor((this.stubDiscount/this.stubPrice) * 100),\n };\n images = this.imageFactory.createMany(faker.number.int({ min: 1, max: 10 }));\n thumbnail = this.imageFactory.create();\n name = faker.commerce.productName();\n brand = faker.company.name();\n description = faker.commerce.productDescription();\n short_description = faker.commerce.productDescription();\n meta_title = faker.commerce.productName();\n meta_description = faker.commerce.productDescription();\n\n constructor(\n protected imageFactory: DaffProductImageFactory,\n ) {}\n}\n\n/**\n * Factory for creating simple `DaffProduct`s of no special kind.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffDefaultProductFactory extends DaffModelFactory<DaffProduct> {\n constructor(\n imageFactory: DaffProductImageFactory,\n ) {\n super(MockProduct, imageFactory);\n }\n}\n","import { createServicesInjectionToken } from '@daffodil/core';\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProduct } from '@daffodil/product';\n\nexport const {\n /**\n * A multi-provider injection token for providing extra product type factories.\n * These factories correspond to different product types that may be added by other packages.\n * This is useful for backend mocks (such as the in-memory driver) to generate an accurate representation\n * of the variety of products that an application can receive in production.\n */\n token: DAFF_PRODUCT_TYPE_FACTORIES,\n\n /**\n * Provides extra product factory types.\n *\n * See {@link DAFF_PRODUCT_TYPE_FACTORIES}.\n *\n * @example\n * ```ts\n * providers: [\n * ...provideDaffProductExtraFactoryTypes(\n * MyProductFactory\n * )\n * ]\n * ```\n */\n provider: provideDaffProductExtraFactoryTypes,\n} = createServicesInjectionToken<DaffModelFactory<DaffProduct>>(\n 'DAFF_PRODUCT_TYPE_FACTORIES',\n { providedIn: 'root' },\n);\n","import { createServicesInjectionToken } from '@daffodil/core';\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProduct } from '@daffodil/product';\n\nexport const {\n /**\n * A multi-provider injection token for providing extra product factories.\n * These extra factories represent the additional product fields that may be added by other packages.\n * This is useful for backend mocks (such as the in-memory driver) to generate an accurate representation\n * of the entire product data that an application can receive in production.\n *\n * These factories will be invoked ang the return included in {@link DaffProductFactory}.\n */\n token: DAFF_PRODUCT_EXTRA_FACTORIES,\n\n /**\n * Provides extra product factories.\n *\n * See {@link DAFF_PRODUCT_EXTRA_FACTORIES}.\n *\n * @example\n * ```ts\n * providers: [\n * ...provideDaffProductExtraProductFactories(\n * MyProductFactory\n * )\n * ]\n * ```\n */\n provider: provideDaffProductExtraProductFactories,\n} = createServicesInjectionToken<DaffModelFactory<DaffProduct>>(\n 'DAFF_PRODUCT_EXTRA_FACTORIES',\n { providedIn: 'root' },\n);\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\n\nimport { sample } from '@daffodil/core';\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProduct } from '@daffodil/product';\n\nimport { MockProduct } from './default-product.factory';\nimport { DAFF_PRODUCT_TYPE_FACTORIES } from '../injection-tokens/public_api';\n\n/**\n * Factory for creating DaffProducts.\n * This will create a random product kind,\n * including extra product kinds that may be provided by optional product packages.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffProductKindFactory extends DaffModelFactory<DaffProduct> {\n constructor(\n @Inject(DAFF_PRODUCT_TYPE_FACTORIES) private productTypeFactories: DaffModelFactory<DaffProduct>[],\n ) {\n super(MockProduct);\n }\n\n private get _randomFactory(): DaffModelFactory<DaffProduct> {\n return sample(this.productTypeFactories);\n }\n\n /**\n * Creates a mock product of random kind.\n * Includes extra product kinds that may be provided by optional product packages.\n */\n create(partial: Partial<DaffProduct> = {}): DaffProduct {\n return this._randomFactory.create(partial);\n }\n}\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffProduct } from '@daffodil/product';\n\nimport { DaffProductKindFactory } from './kind.factory';\nimport { DAFF_PRODUCT_EXTRA_FACTORIES } from '../injection-tokens/public_api';\n\n/**\n * Factory for creating `DaffProduct`s with extension fields.\n * This includes all the extra extension factories that may be provided by optional product packages.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffProductExtensionFactory<T extends DaffProduct = DaffProduct> extends DaffModelFactory<T> {\n constructor(\n @Inject(DAFF_PRODUCT_EXTRA_FACTORIES) private extraFactories: DaffModelFactory<T>[],\n private productKindFactory: DaffProductKindFactory,\n ) {\n super(null);\n }\n\n /**\n * Creates a mock product of random type.\n * Includes extra product types that may be provided by optional product packages.\n * This includes all the extra extension factories that may be provided by optional product packages.\n */\n create(partial: Partial<T> = {}): T {\n const kind = this.productKindFactory.create(partial);\n\n return Object.assign(\n {},\n kind,\n ...this.extraFactories.map(factory => factory.create(partial)),\n // spread this in last to preserve kind's type\n { type: kind.type },\n );\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport {\n DaffCollectionMetadataFactory,\n DaffModelFactory,\n MockCollection,\n} from '@daffodil/core/testing';\nimport {\n DaffProduct,\n DaffProductCollection,\n} from '@daffodil/product';\n\nimport { DaffProductKindFactory } from './kind.factory';\n\n/**\n * Mocked {@link DaffProductCollection} object.\n */\nexport class MockProductCollection extends MockCollection<DaffProduct> implements DaffProductCollection {\n constructor(\n productFactory: DaffProductKindFactory,\n metadataFactory: DaffCollectionMetadataFactory,\n ) {\n super(\n productFactory,\n metadataFactory,\n );\n }\n}\n\n/**\n * Factory for creating {@link DaffProductCollection}s.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffProductCollectionFactory extends DaffModelFactory<DaffProductCollection> {\n constructor(\n productFactory: DaffProductKindFactory,\n metadataFactory: DaffCollectionMetadataFactory,\n ) {\n super(MockProductCollection, productFactory, metadataFactory);\n }\n}\n","import { DaffProduct } from '@daffodil/product';\n\n/**\n * A helper function to verify that a model is a Product.\n *\n * @param product\n */\nexport function isProduct(product: DaffProduct): boolean {\n return !!product.id\n && !!product.price\n && !!product.name\n && !!product.brand\n && !!product.description\n && !!product.images;\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { DaffDefaultProductFactory } from './factories/public_api';\nimport { provideDaffProductExtraFactoryTypes } from './injection-tokens/public_api';\n\n/**\n * Provides the default product factory as a product type factory.\n */\nexport const provideDaffProductTesting = (): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffProductExtraFactoryTypes(DaffDefaultProductFactory),\n]);\n","import { NgModule } from '@angular/core';\n\nimport { provideDaffProductTesting } from './provider';\n\n/**\n * Provides the default product factory as a product type factory.\n *\n * @deprecated in favor of {@link provideDaffProductTesting} Deprecated in version 0.95.0. Will be removed in version 0.98.0.\n */\n@NgModule({\n providers: [\n provideDaffProductTesting(),\n ],\n})\nexport class DaffProductTestingModule { }\n"],"mappings":";;;;;;;AAMA,MAAM,uBAAiC;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAKD,IAAa,mBAAb,MAA6B;CAA7B,cAAA;EACE,KAAA,KAAK,MAAM,OAAO,KAAI;EACtB,KAAA,MAAM,qBAAqB,MAAM,OAAO,IAAI,qBAAqB,SAAO,CAAC;EACzE,KAAA,QAAQ,MAAM,MAAM,SAAQ;CAC9B;AAAC;AAQD,IAAa,0BAAb,MAAa,gCAAgC,iBAAkC;CAC7E,cAAA;EACE,MAAM,gBAAgB;CACxB;CAHW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAuB,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAvB;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAuB,YAFtB;EAAM,CAAA;CAAA;;AAEP,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAuB,YAAA,CAAA;EAHnC,MAAA;EAAW,MAAA,CAAA,EACV,YAAY,OACb,CAAA;;;;AC3BD,IAAa,cAAb,M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AAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAA4B,YAAA,CAAA;EAHxC,MAAA;EAAW,MAAA,CAAA,EACV,YAAY,OACb,CAAA;;;;AC3BD,SAAgB,UAAU,SAAoB;CAC5C,OAAO,CAAC,CAAC,QAAQ,MACZ,CAAC,CAAC,QAAQ,SACV,CAAC,CAAC,QAAQ,QACV,CAAC,CAAC,QAAQ,SACV,CAAC,CAAC,QAAQ,eACV,CAAC,CAAC,QAAQ;AACjB;ACHA,MAAa,kCAAwD,yBAAyB,CAC5F,oCAAoC,yBAAyB,CAC9D,CAAA;ACCD,IAAa,2BAAb,MAAa,yBAAwB;CAAxB;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAwB,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAxB;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;EAAwB,CAAA;CAAA;CAAxB;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAwB,WAJxB,CACT,0BAAyB,CAC1B;EAAA,CAAA;CAAA;;AAEU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAwB,YAAA,CAAA;EALpC,MAAA;EAAS,MAAA,CAAA,EACR,WAAW,CACT,0BAAyB,CAC1B,EACF,CAAA"}
@@ -1,32 +1,11 @@
1
- /**
2
- * The possible product types.
3
- */
4
1
  var DaffProductTypeEnum;
5
- (function (DaffProductTypeEnum) {
6
- DaffProductTypeEnum["Simple"] = "simple";
7
- DaffProductTypeEnum["Composite"] = "composite";
8
- DaffProductTypeEnum["Configurable"] = "configurable";
2
+ (function(DaffProductTypeEnum) {
3
+ DaffProductTypeEnum["Simple"] = "simple";
4
+ DaffProductTypeEnum["Composite"] = "composite";
5
+ DaffProductTypeEnum["Configurable"] = "configurable";
9
6
  })(DaffProductTypeEnum || (DaffProductTypeEnum = {}));
10
-
11
- /**
12
- * Returns whether a DaffPriceRange has a discount.
13
- *
14
- * @param priceRange a DaffPriceRange
15
- */
16
- const productPriceRangeHasDiscount = (priceRange) => priceRange.minPrice.originalPrice !== priceRange.minPrice.discountedPrice ||
17
- priceRange.maxPrice.originalPrice !== priceRange.maxPrice.discountedPrice;
18
-
19
- /**
20
- * Returns whether the min and max prices of a DaffPriceRange are different.
21
- *
22
- * @param priceRange a DaffPriceRange
23
- */
24
- const productPriceRangeHasPriceRange = (priceRange) => priceRange.minPrice.originalPrice !== priceRange.maxPrice.originalPrice ||
25
- priceRange.minPrice.discountedPrice !== priceRange.maxPrice.discountedPrice;
26
-
27
- /**
28
- * Generated bundle index. Do not edit.
29
- */
30
-
7
+ const productPriceRangeHasDiscount = (priceRange) => priceRange.minPrice.originalPrice !== priceRange.minPrice.discountedPrice || priceRange.maxPrice.originalPrice !== priceRange.maxPrice.discountedPrice;
8
+ const productPriceRangeHasPriceRange = (priceRange) => priceRange.minPrice.originalPrice !== priceRange.maxPrice.originalPrice || priceRange.minPrice.discountedPrice !== priceRange.maxPrice.discountedPrice;
31
9
  export { DaffProductTypeEnum, productPriceRangeHasDiscount, productPriceRangeHasPriceRange };
32
- //# sourceMappingURL=daffodil-product.mjs.map
10
+
11
+ //# sourceMappingURL=daffodil-product.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-product.mjs","sources":["../../../libs/product/src/models/product.ts","../../../libs/product/src/helpers/has-discount.ts","../../../libs/product/src/helpers/has-price-range.ts","../../../libs/product/src/daffodil-product.ts"],"sourcesContent":["import {\n DaffIdentifiable,\n DaffLocatable,\n DaffCanonicallyLocatable,\n} from '@daffodil/core';\n\nimport { DaffProductImage } from './product-image';\n\n/**\n * The possible product types.\n */\nexport enum DaffProductTypeEnum {\n Simple = 'simple',\n Composite = 'composite',\n Configurable = 'configurable'\n}\n\n/**\n * An interface for a product usable by the @daffodil/product library.\n */\nexport interface DaffProduct\n extends DaffLocatable, DaffIdentifiable, Partial<DaffCanonicallyLocatable> {\n\n /**\n * The type of product.\n */\n type: DaffProductTypeEnum;\n\n /**\n * The product name.\n */\n name: string;\n\n /**\n * An image to concisely visualize the product.\n */\n thumbnail: DaffProductImage;\n\n /**\n * An array of images for the product.\n */\n images?: DaffProductImage[];\n\n // TODO: move to subtypes\n /**\n * The price of the product.\n */\n price?: number;\n\n /**\n * The total discounts associated with this product.\n */\n discount?: DaffProductDiscount;\n\n /**\n * Whether or not the product is in stock.\n */\n in_stock?: boolean;\n\n // TODO: move to meta object\n /**\n * The product brand.\n */\n brand?: string;\n\n /**\n * Describes the product.\n */\n description?: string;\n\n /**\n * A shorter description of the product.\n */\n short_description?: string;\n\n /**\n * A title for the product to display in the browser tab title.\n */\n meta_title?: string;\n\n /**\n * A description of the product for usage in search engine results.\n */\n meta_description?: string;\n}\n\n/**\n * The discount for a product.\n */\nexport interface DaffProductDiscount {\n /**\n * The discount represented as some amount of currency.\n */\n amount: number;\n\n /**\n * The discount represented as a percent of the original product price.\n */\n percent: number;\n}\n","import { DaffPriceRange } from '../models/public_api';\n\n/**\n * Returns whether a DaffPriceRange has a discount.\n *\n * @param priceRange a DaffPriceRange\n */\nexport const productPriceRangeHasDiscount = (priceRange: DaffPriceRange): boolean => priceRange.minPrice.originalPrice !== priceRange.minPrice.discountedPrice ||\n\t\tpriceRange.maxPrice.originalPrice !== priceRange.maxPrice.discountedPrice;\n","import { DaffPriceRange } from '../models/public_api';\n\n/**\n * Returns whether the min and max prices of a DaffPriceRange are different.\n *\n * @param priceRange a DaffPriceRange\n */\nexport const productPriceRangeHasPriceRange = (priceRange: DaffPriceRange): boolean => priceRange.minPrice.originalPrice !== priceRange.maxPrice.originalPrice ||\n\t\tpriceRange.minPrice.discountedPrice !== priceRange.maxPrice.discountedPrice;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAQA;;AAEG;IACS;AAAZ,CAAA,UAAY,mBAAmB,EAAA;AAC7B,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,mBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,mBAAA,CAAA,cAAA,CAAA,GAAA,cAA6B;AAC/B,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,GAAA,EAAA,CAAA,CAAA;;ACT/B;;;;AAIG;AACI,MAAM,4BAA4B,GAAG,CAAC,UAA0B,KAAc,UAAU,CAAC,QAAQ,CAAC,aAAa,KAAK,UAAU,CAAC,QAAQ,CAAC,eAAe;IAC5J,UAAU,CAAC,QAAQ,CAAC,aAAa,KAAK,UAAU,CAAC,QAAQ,CAAC;;ACN5D;;;;AAIG;AACI,MAAM,8BAA8B,GAAG,CAAC,UAA0B,KAAc,UAAU,CAAC,QAAQ,CAAC,aAAa,KAAK,UAAU,CAAC,QAAQ,CAAC,aAAa;IAC5J,UAAU,CAAC,QAAQ,CAAC,eAAe,KAAK,UAAU,CAAC,QAAQ,CAAC;;ACR9D;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-product.mjs","names":[],"sources":["../../../libs/product/src/models/product.ts","../../../libs/product/src/helpers/has-discount.ts","../../../libs/product/src/helpers/has-price-range.ts"],"sourcesContent":["import {\n DaffIdentifiable,\n DaffLocatable,\n DaffCanonicallyLocatable,\n} from '@daffodil/core';\n\nimport { DaffProductImage } from './product-image';\n\n/**\n * The possible product types.\n */\nexport enum DaffProductTypeEnum {\n Simple = 'simple',\n Composite = 'composite',\n Configurable = 'configurable'\n}\n\n/**\n * An interface for a product usable by the @daffodil/product library.\n */\nexport interface DaffProduct\n extends DaffLocatable, DaffIdentifiable, Partial<DaffCanonicallyLocatable> {\n\n /**\n * The type of product.\n */\n type: DaffProductTypeEnum;\n\n /**\n * The product name.\n */\n name: string;\n\n /**\n * An image to concisely visualize the product.\n */\n thumbnail: DaffProductImage;\n\n /**\n * An array of images for the product.\n */\n images?: DaffProductImage[];\n\n // TODO: move to subtypes\n /**\n * The price of the product.\n */\n price?: number;\n\n /**\n * The total discounts associated with this product.\n */\n discount?: DaffProductDiscount;\n\n /**\n * Whether or not the product is in stock.\n */\n in_stock?: boolean;\n\n // TODO: move to meta object\n /**\n * The product brand.\n */\n brand?: string;\n\n /**\n * Describes the product.\n */\n description?: string;\n\n /**\n * A shorter description of the product.\n */\n short_description?: string;\n\n /**\n * A title for the product to display in the browser tab title.\n */\n meta_title?: string;\n\n /**\n * A description of the product for usage in search engine results.\n */\n meta_description?: string;\n}\n\n/**\n * The discount for a product.\n */\nexport interface DaffProductDiscount {\n /**\n * The discount represented as some amount of currency.\n */\n amount: number;\n\n /**\n * The discount represented as a percent of the original product price.\n */\n percent: number;\n}\n","import { DaffPriceRange } from '../models/public_api';\n\n/**\n * Returns whether a DaffPriceRange has a discount.\n *\n * @param priceRange a DaffPriceRange\n */\nexport const productPriceRangeHasDiscount = (priceRange: DaffPriceRange): boolean => priceRange.minPrice.originalPrice !== priceRange.minPrice.discountedPrice ||\n\t\tpriceRange.maxPrice.originalPrice !== priceRange.maxPrice.discountedPrice;\n","import { DaffPriceRange } from '../models/public_api';\n\n/**\n * Returns whether the min and max prices of a DaffPriceRange are different.\n *\n * @param priceRange a DaffPriceRange\n */\nexport const productPriceRangeHasPriceRange = (priceRange: DaffPriceRange): boolean => priceRange.minPrice.originalPrice !== priceRange.maxPrice.originalPrice ||\n\t\tpriceRange.minPrice.discountedPrice !== priceRange.maxPrice.discountedPrice;\n"],"mappings":"AAWA,IAAY;CAAZ,SAAY,qBAAmB;CAC7B,oBAAA,YAAA;CACA,oBAAA,eAAA;CACA,oBAAA,kBAAA;AACF,EAAA,CAJY,wBAAA,sBAAmB,CAAA,EAAA;ACJ/B,MAAa,gCAAgC,eAAwC,WAAW,SAAS,kBAAkB,WAAW,SAAS,mBAC7I,WAAW,SAAS,kBAAkB,WAAW,SAAS;ACD5D,MAAa,kCAAkC,eAAwC,WAAW,SAAS,kBAAkB,WAAW,SAAS,iBAC/I,WAAW,SAAS,oBAAoB,WAAW,SAAS"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@daffodil/product","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/product"]}}},"version":"0.94.1","description":"Platform-agnostic models, state management, and drivers for retrieving and interacting with ecommerce products. Part of the Daffodil ecommerce framework.","repository":{"type":"git","url":"https://github.com/graycoreio/daffodil"},"author":"Graycore LLC","license":"MIT","bugs":{"url":"https://github.com/graycoreio/daffodil/issues"},"publishConfig":{"directory":"../../dist/product"},"homepage":"https://github.com/graycoreio/daffodil","peerDependencies":{"@angular/common":"^21","@angular/core":"^21","@daffodil/core":"0.94.1","@ngrx/effects":"^21","@ngrx/entity":"^21","@ngrx/store":"^21","rxjs":"^7.0.0"},"optionalDependencies":{"@apollo/client":"^4.0.13","@daffodil/driver":"0.94.1","angular-in-memory-web-api":"^0.21.0","apollo-angular":"^13.0.0","@faker-js/faker":"^10.3.0"},"module":"fesm2022/daffodil-product.mjs","typings":"types/daffodil-product.d.ts","exports":{"./package.json":{"default":"./package.json"},".":{"types":"./types/daffodil-product.d.ts","default":"./fesm2022/daffodil-product.mjs"},"./driver":{"types":"./types/daffodil-product-driver.d.ts","default":"./fesm2022/daffodil-product-driver.mjs"},"./driver/in-memory":{"types":"./types/daffodil-product-driver-in-memory.d.ts","default":"./fesm2022/daffodil-product-driver-in-memory.mjs"},"./driver/magento":{"types":"./types/daffodil-product-driver-magento.d.ts","default":"./fesm2022/daffodil-product-driver-magento.mjs"},"./driver/magento/testing":{"types":"./types/daffodil-product-driver-magento-testing.d.ts","default":"./fesm2022/daffodil-product-driver-magento-testing.mjs"},"./driver/shopify":{"types":"./types/daffodil-product-driver-shopify.d.ts","default":"./fesm2022/daffodil-product-driver-shopify.mjs"},"./driver/testing":{"types":"./types/daffodil-product-driver-testing.d.ts","default":"./fesm2022/daffodil-product-driver-testing.mjs"},"./routing":{"types":"./types/daffodil-product-routing.d.ts","default":"./fesm2022/daffodil-product-routing.mjs"},"./state":{"types":"./types/daffodil-product-state.d.ts","default":"./fesm2022/daffodil-product-state.mjs"},"./state/testing":{"types":"./types/daffodil-product-state-testing.d.ts","default":"./fesm2022/daffodil-product-state-testing.mjs"},"./testing":{"types":"./types/daffodil-product-testing.d.ts","default":"./fesm2022/daffodil-product-testing.mjs"}},"sideEffects":false,"type":"module","dependencies":{"tslib":"^2.6.2"}}
1
+ {"name":"@daffodil/product","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/product"]}}},"version":"0.95.1","description":"Platform-agnostic models, state management, and drivers for retrieving and interacting with ecommerce products. Part of the Daffodil ecommerce framework.","repository":{"type":"git","url":"https://github.com/graycoreio/daffodil"},"author":"Graycore LLC","license":"MIT","bugs":{"url":"https://github.com/graycoreio/daffodil/issues"},"publishConfig":{"directory":"../../dist/product"},"homepage":"https://github.com/graycoreio/daffodil","peerDependencies":{"@angular/common":"^22","@angular/core":"^22","@daffodil/core":"0.95.1","@ngrx/effects":"^22","@ngrx/entity":"^22","@ngrx/store":"^22","rxjs":"^7.0.0","@daffodil/driver":"0.95.1"},"optionalDependencies":{"@apollo/client":"^4.0.13","@daffodil/driver":"0.95.1","angular-in-memory-web-api":"^0.22.0","apollo-angular":"^14.0.0","@faker-js/faker":"^10.3.0"},"exports":{"./driver/magento/auto":{"product-magento-2.4.7":{"types":"./types/daffodil-product-driver-magento-2.4.7.d.ts","default":"./fesm2022/daffodil-product-driver-magento-2.4.7.mjs"},"types":"./types/daffodil-product-driver-magento-auto.d.ts","default":"./fesm2022/daffodil-product-driver-magento-auto.mjs"},"./driver/magento/auto/testing":{"product-magento-2.4.7":{"types":"./types/daffodil-product-driver-magento-2.4.7-testing.d.ts","default":"./fesm2022/daffodil-product-driver-magento-2.4.7-testing.mjs"},"types":"./types/daffodil-product-driver-magento-auto-testing.d.ts","default":"./fesm2022/daffodil-product-driver-magento-auto-testing.mjs"},"./package.json":{"default":"./package.json"},".":{"types":"./types/daffodil-product.d.ts","default":"./fesm2022/daffodil-product.mjs"},"./driver":{"types":"./types/daffodil-product-driver.d.ts","default":"./fesm2022/daffodil-product-driver.mjs"},"./driver/in-memory":{"types":"./types/daffodil-product-driver-in-memory.d.ts","default":"./fesm2022/daffodil-product-driver-in-memory.mjs"},"./driver/magento/2.4.7":{"types":"./types/daffodil-product-driver-magento-2.4.7.d.ts","default":"./fesm2022/daffodil-product-driver-magento-2.4.7.mjs"},"./driver/magento/2.4.7/testing":{"types":"./types/daffodil-product-driver-magento-2.4.7-testing.d.ts","default":"./fesm2022/daffodil-product-driver-magento-2.4.7-testing.mjs"},"./driver/shopify":{"types":"./types/daffodil-product-driver-shopify.d.ts","default":"./fesm2022/daffodil-product-driver-shopify.mjs"},"./driver/testing":{"types":"./types/daffodil-product-driver-testing.d.ts","default":"./fesm2022/daffodil-product-driver-testing.mjs"},"./routing":{"types":"./types/daffodil-product-routing.d.ts","default":"./fesm2022/daffodil-product-routing.mjs"},"./state":{"types":"./types/daffodil-product-state.d.ts","default":"./fesm2022/daffodil-product-state.mjs"},"./state/testing":{"types":"./types/daffodil-product-state-testing.d.ts","default":"./fesm2022/daffodil-product-state-testing.mjs"},"./testing":{"types":"./types/daffodil-product-testing.d.ts","default":"./fesm2022/daffodil-product-testing.mjs"}},"module":"fesm2022/daffodil-product.mjs","typings":"types/daffodil-product.d.ts","sideEffects":false,"type":"module","dependencies":{"tslib":"^2.6.2"}}
@@ -1,15 +1,12 @@
1
- import * as rxjs from 'rxjs';
2
- import { Observable } from 'rxjs';
3
- import { InMemoryDbService, RequestInfoUtilities, ParsedRequestUrl, RequestInfo, InMemoryBackendConfigArgs } from 'angular-in-memory-web-api';
4
- import { DaffInMemorySingleRouteableBackend, DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';
5
- import { DaffProduct } from '@daffodil/product';
6
- import * as i0 from '@angular/core';
7
- import { ModuleWithProviders, Provider, EnvironmentProviders } from '@angular/core';
8
- import { HttpClient } from '@angular/common/http';
9
- import { DaffProductDriverResponse, DaffProductServiceInterface } from '@daffodil/product/driver';
10
- import * as i1 from '@angular/common';
11
- import * as i2 from '@daffodil/product/testing';
12
-
1
+ import { InMemoryBackendConfigArgs, InMemoryDbService, ParsedRequestUrl, RequestInfo, RequestInfoUtilities } from "angular-in-memory-web-api";
2
+ import { DaffInMemoryDriverBase, DaffInMemorySingleRouteableBackend } from "@daffodil/driver/in-memory";
3
+ import { DaffProduct } from "@daffodil/product";
4
+ import * as i0 from "@angular/core";
5
+ import { EnvironmentProviders, ModuleWithProviders, Provider } from "@angular/core";
6
+ import { HttpClient } from "@angular/common/http";
7
+ import { Observable } from "rxjs";
8
+ import { DaffProductDriverResponse, DaffProductServiceInterface } from "@daffodil/product/driver";
9
+ import * as i1 from "@angular/common";
13
10
  /**
14
11
  * An in-memory service that stubs out the backend services for getting products.
15
12
  *
@@ -17,81 +14,74 @@ import * as i2 from '@daffodil/product/testing';
17
14
  * @Param productImageFactory: DaffProductImageFactory instance
18
15
  * @Param products: An array of Products
19
16
  */
20
- declare class DaffInMemoryBackendProductService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {
21
- readonly collectionName = "products";
22
- protected _products: DaffProduct[];
23
- /**
24
- * The collection of products in the backend.
25
- */
26
- get products(): DaffProduct[];
27
- constructor();
28
- /**
29
- * Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
30
- *
31
- * @param url initial url
32
- * @param utils utility to parse url
33
- * @returns ParsedRequestUrl
34
- * @docs-private
35
- */
36
- parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl;
37
- /**
38
- * Creates a fake database of products for the product inmemory backend service.
39
- *
40
- * @returns A fake database of an array of products
41
- * @docs-private
42
- */
43
- createDb(): any;
44
- /**
45
- * Returns products based on the url given.
46
- *
47
- * @param reqInfo request object
48
- * @returns An http response object
49
- */
50
- get(reqInfo: RequestInfo): rxjs.Observable<any>;
51
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffInMemoryBackendProductService, never>;
52
- static ɵprov: i0.ɵɵInjectableDeclaration<DaffInMemoryBackendProductService>;
17
+ export declare class DaffInMemoryBackendProductService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {
18
+ readonly collectionName = "products";
19
+ protected _products: DaffProduct[];
20
+ /**
21
+ * The collection of products in the backend.
22
+ */
23
+ get products(): DaffProduct[];
24
+ constructor();
25
+ /**
26
+ * Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
27
+ *
28
+ * @param url initial url
29
+ * @param utils utility to parse url
30
+ * @returns ParsedRequestUrl
31
+ * @docs-private
32
+ */
33
+ parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl;
34
+ /**
35
+ * Creates a fake database of products for the product inmemory backend service.
36
+ *
37
+ * @returns A fake database of an array of products
38
+ * @docs-private
39
+ */
40
+ createDb(): any;
41
+ /**
42
+ * Returns products based on the url given.
43
+ *
44
+ * @param reqInfo request object
45
+ * @returns An http response object
46
+ */
47
+ get(reqInfo: RequestInfo): import("rxjs").Observable<any>;
48
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffInMemoryBackendProductService, never>;
49
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
53
50
  }
54
-
55
- type DaffInMemoryProductResponseExtraTransform<T extends DaffProduct = DaffProduct, V extends DaffProductDriverResponse = DaffProductDriverResponse> = (daffProductResponse: DaffProductDriverResponse, product: T) => V;
56
-
57
- type DaffInMemoryProductResponseTransform<T extends DaffProduct = DaffProduct, V extends DaffProductDriverResponse = DaffProductDriverResponse> = (product: T) => V;
58
-
51
+ export type DaffInMemoryProductResponseExtraTransform<T extends DaffProduct = DaffProduct, V extends DaffProductDriverResponse = DaffProductDriverResponse> = (daffProductResponse: DaffProductDriverResponse, product: T) => V;
52
+ export type DaffInMemoryProductResponseTransform<T extends DaffProduct = DaffProduct, V extends DaffProductDriverResponse = DaffProductDriverResponse> = (product: T) => V;
59
53
  /**
60
54
  * The product inmemory driver to mock the product backend service.
61
55
  *
62
56
  * @inheritdoc
63
57
  * @Param HttpClient
64
58
  */
65
- declare class DaffInMemoryProductService extends DaffInMemoryDriverBase implements DaffProductServiceInterface {
66
- private http;
67
- private transform;
68
- constructor(http: HttpClient, config: InMemoryBackendConfigArgs, transform: DaffInMemoryProductResponseTransform);
69
- getAll(): Observable<DaffProduct[]>;
70
- get(productId: DaffProduct['id']): Observable<DaffProductDriverResponse>;
71
- getByUrl(url: DaffProduct['url']): Observable<DaffProductDriverResponse>;
72
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffInMemoryProductService, never>;
73
- static ɵprov: i0.ɵɵInjectableDeclaration<DaffInMemoryProductService>;
59
+ export declare class DaffInMemoryProductService extends DaffInMemoryDriverBase implements DaffProductServiceInterface {
60
+ private http;
61
+ private transform;
62
+ constructor(http: HttpClient, config: InMemoryBackendConfigArgs, transform: DaffInMemoryProductResponseTransform);
63
+ getAll(): Observable<DaffProduct[]>;
64
+ get(productId: DaffProduct['id']): Observable<DaffProductDriverResponse>;
65
+ getByUrl(url: DaffProduct['url']): Observable<DaffProductDriverResponse>;
66
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffInMemoryProductService, never>;
67
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
74
68
  }
75
-
76
69
  /**
77
70
  * Module for providing the DaffInMemoryProductService driver to your application.
71
+ *
72
+ * @deprecated in favor of {@link provideDaffProductInMemoryDriver} Deprecated in version 0.95.0. Will be removed in version 0.98.0.
78
73
  */
79
- declare class DaffProductInMemoryDriverModule {
80
- static forRoot(): ModuleWithProviders<DaffProductInMemoryDriverModule>;
81
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffProductInMemoryDriverModule, never>;
82
- static ɵmod: i0.ɵɵNgModuleDeclaration<DaffProductInMemoryDriverModule, never, [typeof i1.CommonModule, typeof i2.DaffProductTestingModule], never>;
83
- static ɵinj: i0.ɵɵInjectorDeclaration<DaffProductInMemoryDriverModule>;
74
+ export declare class DaffProductInMemoryDriverModule {
75
+ static forRoot(): ModuleWithProviders<DaffProductInMemoryDriverModule>;
76
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffProductInMemoryDriverModule, never>;
77
+ static ɵmod: i0.ɵɵNgModuleDeclaration<DaffProductInMemoryDriverModule, never, [typeof i1.CommonModule], never>;
78
+ static ɵinj: i0.ɵɵInjectorDeclaration<DaffProductInMemoryDriverModule>;
84
79
  }
85
-
86
80
  /**
87
81
  * Provides the Daffodil product in-memory driver and its dependencies.
82
+ * Includes {@link provideDaffProductTesting}.
88
83
  */
89
- declare const provideDaffProductInMemoryDriver: () => Array<Provider | EnvironmentProviders>;
90
-
91
- declare const DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS: i0.InjectionToken<DaffInMemoryProductResponseExtraTransform[]>;
92
- declare const provideDaffProductInMemoryExtraProductResponseTransforms: <R extends DaffInMemoryProductResponseExtraTransform = DaffInMemoryProductResponseExtraTransform>(...values: R[]) => Array<i0.ValueProvider>;
93
-
94
- declare const DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM: i0.InjectionToken<DaffInMemoryProductResponseTransform>;
95
-
96
- export { DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS, DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM, DaffInMemoryBackendProductService, DaffInMemoryProductService, DaffProductInMemoryDriverModule, provideDaffProductInMemoryDriver, provideDaffProductInMemoryExtraProductResponseTransforms };
97
- export type { DaffInMemoryProductResponseExtraTransform, DaffInMemoryProductResponseTransform };
84
+ export declare const provideDaffProductInMemoryDriver: () => Array<Provider | EnvironmentProviders>;
85
+ export declare const DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS: import("@angular/core").InjectionToken<DaffInMemoryProductResponseExtraTransform[]>, provideDaffProductInMemoryExtraProductResponseTransforms: <R extends DaffInMemoryProductResponseExtraTransform = DaffInMemoryProductResponseExtraTransform>(...values: R[]) => Array<import("@angular/core").ValueProvider>;
86
+ declare const DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM: import("@angular/core").InjectionToken<DaffInMemoryProductResponseTransform>, provideDaffProductInMemoryProductResponseTransform: <R extends DaffInMemoryProductResponseTransform = DaffInMemoryProductResponseTransform>(value: R) => import("@angular/core").ValueProvider;
87
+ export { DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM };
@@ -0,0 +1,105 @@
1
+ import { DaffModelFactory } from "@daffodil/core/testing";
2
+ import { MagentoAggregation, MagentoProduct, MagentoProductFilterTypeField, MagentoProductPreview, MagentoProductSortFields, MagentoProductStockStatusEnum, MagentoProductTypeEnum, MagentoSimpleProduct } from "@daffodil/product/driver/magento/2.4.7";
3
+ import * as i0 from "@angular/core";
4
+ export declare class MockMagentoProductPreview implements MagentoProductPreview {
5
+ __typename: MagentoProductTypeEnum;
6
+ uid: string;
7
+ url_key: string;
8
+ url_suffix: string;
9
+ name: string;
10
+ sku: string;
11
+ stock_status: MagentoProductStockStatusEnum;
12
+ image: {
13
+ __typename: string;
14
+ label: string;
15
+ url: string;
16
+ };
17
+ description: {
18
+ __typename: string;
19
+ html: string;
20
+ };
21
+ price_range: {
22
+ __typename: string;
23
+ maximum_price: {
24
+ __typename: string;
25
+ regular_price: {
26
+ __typename: string;
27
+ value: number;
28
+ currency: any;
29
+ };
30
+ discount: {
31
+ __typename: string;
32
+ amount_off: number;
33
+ percent_off: number;
34
+ };
35
+ };
36
+ };
37
+ }
38
+ export declare class MagentoProductPreviewFactory extends DaffModelFactory<MagentoProductPreview> {
39
+ constructor();
40
+ static ɵfac: i0.ɵɵFactoryDeclaration<MagentoProductPreviewFactory, never>;
41
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
42
+ }
43
+ export declare class MockMagentoCoreProduct extends MockMagentoProductPreview implements MagentoProduct {
44
+ __typename: MagentoProductTypeEnum;
45
+ canonical_url: string;
46
+ meta_title: string;
47
+ meta_description: string;
48
+ stock_status: MagentoProductStockStatusEnum;
49
+ description: {
50
+ __typename: string;
51
+ html: string;
52
+ };
53
+ short_description: {
54
+ __typename: string;
55
+ html: string;
56
+ };
57
+ media_gallery_entries: any[];
58
+ }
59
+ /**
60
+ * A factory for creating stub data for {@link MagentoProduct}s.
61
+ */
62
+ export declare class MagentoCoreProductFactory extends DaffModelFactory<MagentoProduct> {
63
+ constructor();
64
+ static ɵfac: i0.ɵɵFactoryDeclaration<MagentoCoreProductFactory, never>;
65
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
66
+ }
67
+ export declare class MockMagentoSimpleProduct extends MockMagentoCoreProduct implements MagentoSimpleProduct {
68
+ __typename: MagentoProductTypeEnum;
69
+ }
70
+ /**
71
+ * A factory for creating stub data for {@link MagentoSimpleProduct}s.
72
+ */
73
+ export declare class MagentoSimpleProductFactory extends DaffModelFactory<MagentoSimpleProduct> {
74
+ constructor();
75
+ static ɵfac: i0.ɵɵFactoryDeclaration<MagentoSimpleProductFactory, never>;
76
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
77
+ }
78
+ export declare class MagentoProductAggregationPriceFactory extends DaffModelFactory<MagentoAggregation> {
79
+ constructor();
80
+ static ɵfac: i0.ɵɵFactoryDeclaration<MagentoProductAggregationPriceFactory, never>;
81
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
82
+ }
83
+ export declare class MagentoProductAggregationSelectFactory extends DaffModelFactory<MagentoAggregation> {
84
+ constructor();
85
+ static ɵfac: i0.ɵɵFactoryDeclaration<MagentoProductAggregationSelectFactory, never>;
86
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
87
+ }
88
+ export declare class MagentoProductAggregationFactory extends DaffModelFactory<MagentoAggregation> {
89
+ private selectFactory;
90
+ private priceFactory;
91
+ constructor(selectFactory: MagentoProductAggregationSelectFactory, priceFactory: MagentoProductAggregationPriceFactory);
92
+ static ɵfac: i0.ɵɵFactoryDeclaration<MagentoProductAggregationFactory, never>;
93
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
94
+ }
95
+ export declare class MagentoProductFilterTypeFieldFactory extends DaffModelFactory<MagentoProductFilterTypeField> {
96
+ constructor();
97
+ static ɵfac: i0.ɵɵFactoryDeclaration<MagentoProductFilterTypeFieldFactory, never>;
98
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
99
+ }
100
+ export declare class MagentoProductSortFieldsFactory extends DaffModelFactory<MagentoProductSortFields> {
101
+ constructor();
102
+ static ɵfac: i0.ɵɵFactoryDeclaration<MagentoProductSortFieldsFactory, never>;
103
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
104
+ }
105
+ export { MagentoSimpleProductFactory as MagentoProductFactory };