@reactionary/source 0.6.1 → 0.6.3
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/README.md +33 -11
- package/examples/node/package.json +7 -7
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +11 -5
- package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +9 -3
- package/examples/node/src/basic/basic-node-setup.spec.ts +6 -2
- package/examples/node/src/basic/client-creation.spec.ts +6 -6
- package/examples/node/src/utils.ts +48 -48
- package/examples/node/tsconfig.lib.json +2 -1
- package/package.json +1 -1
- package/packages/algolia/README.md +11 -0
- package/{providers/google-analytics → packages/algolia}/eslint.config.mjs +0 -2
- package/{providers → packages}/algolia/package.json +7 -5
- package/{providers/posthog → packages/algolia}/project.json +6 -6
- package/{providers/algolia/src/providers/analytics.provider.ts → packages/algolia/src/capabilities/analytics.capability.ts} +6 -6
- package/packages/algolia/src/capabilities/index.ts +3 -0
- package/{providers/algolia/src/providers/product-recommendations.provider.ts → packages/algolia/src/capabilities/product-recommendations.capability.ts} +3 -3
- package/packages/algolia/src/capabilities/product-search.capability.ts +119 -0
- package/packages/algolia/src/core/initialize.ts +82 -0
- package/packages/algolia/src/core/initialize.types.ts +107 -0
- package/packages/algolia/src/factories/index.ts +1 -0
- package/packages/algolia/src/factories/product-search/product-search.factory.ts +182 -0
- package/{providers/fake → packages/algolia}/src/index.ts +3 -2
- package/packages/algolia/src/schema/capabilities.schema.ts +84 -0
- package/{providers → packages}/algolia/src/test/analytics.spec.ts +12 -4
- package/packages/algolia/src/test/client-builder-product-search-extension.example.ts +85 -0
- package/packages/algolia/vite.config.ts +26 -0
- package/packages/algolia/vitest.config.mts +21 -0
- package/packages/commercetools/README.md +11 -0
- package/{core → packages/commercetools}/eslint.config.mjs +2 -2
- package/packages/commercetools/package.json +17 -0
- package/{providers → packages}/commercetools/project.json +7 -8
- package/{providers/commercetools/src/providers/cart.provider.ts → packages/commercetools/src/capabilities/cart.capability.ts} +68 -194
- package/{providers/commercetools/src/providers/category.provider.ts → packages/commercetools/src/capabilities/category.capability.ts} +26 -66
- package/{providers/commercetools/src/providers/checkout.provider.ts → packages/commercetools/src/capabilities/checkout.capability.ts} +51 -323
- package/{providers/commercetools/src/providers/identity.provider.ts → packages/commercetools/src/capabilities/identity.capability.ts} +36 -16
- package/packages/commercetools/src/capabilities/index.ts +15 -0
- package/{providers/commercetools/src/providers/inventory.provider.ts → packages/commercetools/src/capabilities/inventory.capability.ts} +14 -32
- package/packages/commercetools/src/capabilities/order-search.capability.ts +135 -0
- package/packages/commercetools/src/capabilities/order.capability.ts +67 -0
- package/{providers/commercetools/src/providers/price.provider.ts → packages/commercetools/src/capabilities/price.capability.ts} +38 -52
- package/{providers/commercetools/src/providers/product-associations.provider.ts → packages/commercetools/src/capabilities/product-associations.capability.ts} +40 -105
- package/{providers/commercetools/src/providers/product-list.provider.ts → packages/commercetools/src/capabilities/product-list.capability.ts} +39 -24
- package/{providers/commercetools/src/providers/product-reviews.provider.ts → packages/commercetools/src/capabilities/product-reviews.capability.ts} +35 -15
- package/{providers/commercetools/src/providers/product-search.provider.ts → packages/commercetools/src/capabilities/product-search.capability.ts} +18 -171
- package/packages/commercetools/src/capabilities/product.capability.ts +133 -0
- package/{providers/commercetools/src/providers/profile.provider.ts → packages/commercetools/src/capabilities/profile.capability.ts} +28 -74
- package/{providers/commercetools/src/providers/store.provider.ts → packages/commercetools/src/capabilities/store.capability.ts} +14 -32
- package/packages/commercetools/src/core/capability-descriptors.ts +324 -0
- package/{providers → packages}/commercetools/src/core/client.ts +2 -2
- package/packages/commercetools/src/core/initialize.ts +58 -0
- package/packages/commercetools/src/core/initialize.types.ts +174 -0
- package/packages/commercetools/src/factories/cart/cart.factory.ts +142 -0
- package/packages/commercetools/src/factories/category/category.factory.ts +77 -0
- package/packages/commercetools/src/factories/checkout/checkout-initializer-overrides.example.ts +94 -0
- package/packages/commercetools/src/factories/checkout/checkout.factory.ts +338 -0
- package/packages/commercetools/src/factories/identity/identity.factory.ts +26 -0
- package/packages/commercetools/src/factories/inventory/inventory.factory.ts +49 -0
- package/packages/commercetools/src/factories/order/order.factory.ts +149 -0
- package/packages/commercetools/src/factories/order-search/order-search.factory.ts +108 -0
- package/packages/commercetools/src/factories/price/price.factory.ts +76 -0
- package/packages/commercetools/src/factories/product/product-capability-custom-method-only.example.ts +47 -0
- package/packages/commercetools/src/factories/product/product-capability-schema-signature-extension.example.ts +61 -0
- package/packages/commercetools/src/factories/product/product-factory-baseline.example.ts +14 -0
- package/packages/commercetools/src/factories/product/product-factory-schema-and-parse-extension.example.ts +35 -0
- package/packages/commercetools/src/factories/product/product-factory-schema-extension.example.ts +23 -0
- package/packages/commercetools/src/factories/product/product-initializer-factory-extension.example.ts +41 -0
- package/packages/commercetools/src/factories/product/product.factory.ts +220 -0
- package/packages/commercetools/src/factories/product/utils.example.ts +9 -0
- package/packages/commercetools/src/factories/product-associations/product-associations.factory.ts +103 -0
- package/packages/commercetools/src/factories/product-list/product-list.factory.ts +122 -0
- package/packages/commercetools/src/factories/product-reviews/product-reviews.factory.ts +81 -0
- package/packages/commercetools/src/factories/product-search/product-search.factory.ts +182 -0
- package/packages/commercetools/src/factories/profile/profile.factory.ts +94 -0
- package/packages/commercetools/src/factories/store/store.factory.ts +49 -0
- package/packages/commercetools/src/index.ts +30 -0
- package/packages/commercetools/src/schema/capabilities.schema.ts +260 -0
- package/{providers → packages}/commercetools/src/test/caching.spec.ts +24 -8
- package/packages/commercetools/src/test/client-builder-merge-extensions.example.ts +125 -0
- package/{providers/algolia → packages/commercetools}/tsconfig.json +1 -1
- package/{core → packages/commercetools}/tsconfig.lib.json +1 -1
- package/packages/commercetools/tsconfig.spec.json +28 -0
- package/packages/commercetools/vite.config.ts +26 -0
- package/packages/commercetools/vitest.config.mts +21 -0
- package/{providers/fake → packages/core}/eslint.config.mjs +2 -1
- package/{core → packages/core}/package.json +7 -7
- package/packages/core/project.json +33 -0
- package/{core/src/providers/analytics.provider.ts → packages/core/src/capabilities/analytics.capability.ts} +8 -8
- package/{core/src/providers/base.provider.ts → packages/core/src/capabilities/base.capability.ts} +2 -2
- package/{core/src/providers/cart.provider.ts → packages/core/src/capabilities/cart.capability.ts} +13 -11
- package/{core/src/providers/category.provider.ts → packages/core/src/capabilities/category.capability.ts} +12 -10
- package/{core/src/providers/checkout.provider.ts → packages/core/src/capabilities/checkout.capability.ts} +15 -11
- package/{core/src/providers/identity.provider.ts → packages/core/src/capabilities/identity.capability.ts} +8 -8
- package/packages/core/src/capabilities/index.ts +18 -0
- package/{core/src/providers/inventory.provider.ts → packages/core/src/capabilities/inventory.capability.ts} +5 -5
- package/{core/src/providers/order-search.provider.ts → packages/core/src/capabilities/order-search.capability.ts} +5 -3
- package/{core/src/providers/order.provider.ts → packages/core/src/capabilities/order.capability.ts} +5 -5
- package/{core/src/providers/price.provider.ts → packages/core/src/capabilities/price.capability.ts} +6 -6
- package/{core/src/providers/product-associations.provider.ts → packages/core/src/capabilities/product-associations.capability.ts} +7 -5
- package/{core/src/providers/product-list.provider.ts → packages/core/src/capabilities/product-list.capability.ts} +14 -9
- package/{core/src/providers/product-recommendations.provider.ts → packages/core/src/capabilities/product-recommendations.capability.ts} +21 -21
- package/{core/src/providers/product-reviews.provider.ts → packages/core/src/capabilities/product-reviews.capability.ts} +9 -5
- package/packages/core/src/capabilities/product-search.capability.ts +48 -0
- package/{core/src/providers/product.provider.ts → packages/core/src/capabilities/product.capability.ts} +7 -7
- package/{core/src/providers/profile.provider.ts → packages/core/src/capabilities/profile.capability.ts} +9 -9
- package/{core/src/providers/store.provider.ts → packages/core/src/capabilities/store.capability.ts} +3 -3
- package/packages/core/src/client/client-builder.ts +131 -0
- package/packages/core/src/client/client.ts +35 -0
- package/{core → packages/core}/src/decorators/reactionary.decorator.ts +7 -7
- package/packages/core/src/factories/cart.factory.ts +40 -0
- package/packages/core/src/factories/category.factory.ts +40 -0
- package/packages/core/src/factories/checkout.factory.ts +59 -0
- package/packages/core/src/factories/identity.factory.ts +26 -0
- package/packages/core/src/factories/index.ts +15 -0
- package/packages/core/src/factories/inventory.factory.ts +26 -0
- package/packages/core/src/factories/order-search.factory.ts +33 -0
- package/packages/core/src/factories/order.factory.ts +21 -0
- package/packages/core/src/factories/price.factory.ts +29 -0
- package/packages/core/src/factories/product-associations.factory.ts +30 -0
- package/packages/core/src/factories/product-list.factory.ts +82 -0
- package/packages/core/src/factories/product-reviews.factory.ts +58 -0
- package/packages/core/src/factories/product-search.factory.ts +31 -0
- package/packages/core/src/factories/product.factory.ts +21 -0
- package/packages/core/src/factories/profile.factory.ts +23 -0
- package/packages/core/src/factories/store.factory.ts +21 -0
- package/packages/core/src/index.ts +8 -0
- package/packages/core/src/test/client-builder.spec.ts +141 -0
- package/{core → packages/core}/src/test/reactionary.decorator.spec.ts +27 -27
- package/{providers/meilisearch → packages/core}/tsconfig.json +1 -1
- package/{providers/medusa → packages/core}/tsconfig.lib.json +1 -2
- package/packages/core/tsconfig.spec.json +28 -0
- package/packages/core/vite.config.ts +26 -0
- package/packages/core/vitest.config.mts +21 -0
- package/packages/fake/README.md +11 -0
- package/{providers/algolia → packages/fake}/eslint.config.mjs +2 -1
- package/{providers → packages}/fake/package.json +6 -4
- package/{providers → packages}/fake/project.json +7 -8
- package/{providers/fake/src/providers/analytics.provider.ts → packages/fake/src/capabilities/analytics.capability.ts} +2 -2
- package/{providers/fake/src/providers/cart.provider.ts → packages/fake/src/capabilities/cart.capability.ts} +24 -15
- package/packages/fake/src/capabilities/category.capability.ts +199 -0
- package/{providers/fake/src/providers/checkout.provider.ts → packages/fake/src/capabilities/checkout.capability.ts} +40 -21
- package/{providers/fake/src/providers/identity.provider.ts → packages/fake/src/capabilities/identity.capability.ts} +40 -34
- package/packages/fake/src/capabilities/index.ts +15 -0
- package/packages/fake/src/capabilities/inventory.capability.ts +74 -0
- package/packages/fake/src/capabilities/order-search.capability.ts +86 -0
- package/{providers/fake/src/providers/order.provider.ts → packages/fake/src/capabilities/order.capability.ts} +22 -38
- package/{providers/fake/src/providers/price.provider.ts → packages/fake/src/capabilities/price.capability.ts} +42 -34
- package/{providers/fake/src/providers/product-associations.provider.ts → packages/fake/src/capabilities/product-associations.capability.ts} +24 -11
- package/{providers/fake/src/providers/product-reviews.provider.ts → packages/fake/src/capabilities/product-reviews.capability.ts} +72 -70
- package/{providers/fake/src/providers/product-search.provider.ts → packages/fake/src/capabilities/product-search.capability.ts} +44 -71
- package/{providers/fake/src/providers/product.provider.ts → packages/fake/src/capabilities/product.capability.ts} +35 -33
- package/packages/fake/src/capabilities/profile.capability.ts +154 -0
- package/packages/fake/src/capabilities/store.capability.ts +72 -0
- package/packages/fake/src/core/initialize.ts +274 -0
- package/packages/fake/src/core/initialize.types.ts +164 -0
- package/packages/fake/src/factories/cart/cart.factory.ts +34 -0
- package/packages/fake/src/factories/category/category.factory.ts +40 -0
- package/packages/fake/src/factories/checkout/checkout.factory.ts +53 -0
- package/packages/fake/src/factories/identity/identity.factory.ts +25 -0
- package/packages/fake/src/factories/index.ts +14 -0
- package/packages/fake/src/factories/inventory/inventory.factory.ts +25 -0
- package/packages/fake/src/factories/order/order.factory.ts +22 -0
- package/packages/fake/src/factories/order-search/order-search.factory.ts +27 -0
- package/packages/fake/src/factories/price/price.factory.ts +26 -0
- package/packages/fake/src/factories/product/product.factory.ts +22 -0
- package/packages/fake/src/factories/product-associations/product-associations.factory.ts +25 -0
- package/packages/fake/src/factories/product-reviews/product-reviews.factory.ts +53 -0
- package/packages/fake/src/factories/product-search/product-search.factory.ts +27 -0
- package/packages/fake/src/factories/profile/profile.factory.ts +22 -0
- package/packages/fake/src/factories/store/store.factory.ts +22 -0
- package/{providers/algolia → packages/fake}/src/index.ts +4 -3
- package/packages/fake/src/schema/capabilities.schema.ts +178 -0
- package/{providers/fake/src/test/cart.provider.spec.ts → packages/fake/src/test/cart.capability.spec.ts} +24 -7
- package/{providers/fake/src/test/category.provider.spec.ts → packages/fake/src/test/category.capability.spec.ts} +7 -4
- package/{providers/fake/src/test/checkout.provider.spec.ts → packages/fake/src/test/checkout.capability.spec.ts} +15 -5
- package/packages/fake/src/test/client-builder-product-extension.example.ts +75 -0
- package/{providers/fake/src/test/order-search.provider.spec.ts → packages/fake/src/test/order-search.capability.spec.ts} +7 -10
- package/{providers/fake/src/test/order.provider.spec.ts → packages/fake/src/test/order.capability.spec.ts} +7 -9
- package/{providers/fake/src/test/price.provider.spec.ts → packages/fake/src/test/price.capability.spec.ts} +6 -4
- package/{providers/fake/src/test/product.provider.spec.ts → packages/fake/src/test/product.capability.spec.ts} +10 -4
- package/{providers/fake/src/test/profile.provider.spec.ts → packages/fake/src/test/profile.capability.spec.ts} +7 -5
- package/{providers/commercetools → packages/fake}/tsconfig.json +1 -1
- package/packages/fake/tsconfig.lib.json +23 -0
- package/packages/fake/tsconfig.spec.json +28 -0
- package/packages/fake/vite.config.ts +26 -0
- package/packages/fake/vitest.config.mts +21 -0
- package/packages/google-analytics/eslint.config.mjs +23 -0
- package/{providers → packages}/google-analytics/package.json +7 -5
- package/{providers → packages}/google-analytics/project.json +5 -5
- package/{providers/google-analytics/src/providers/analytics.provider.ts → packages/google-analytics/src/capabilities/analytics.capability.ts} +2 -2
- package/packages/google-analytics/src/core/initialize.ts +41 -0
- package/packages/google-analytics/src/core/initialize.types.ts +47 -0
- package/{providers → packages}/google-analytics/src/index.ts +2 -1
- package/packages/google-analytics/src/schema/capabilities.schema.ts +36 -0
- package/{providers/google-analytics/src/test/analytics.provider.spec.ts → packages/google-analytics/src/test/analytics.capability.spec.ts} +7 -7
- package/packages/google-analytics/tsconfig.json +24 -0
- package/packages/google-analytics/tsconfig.lib.json +23 -0
- package/packages/google-analytics/tsconfig.spec.json +28 -0
- package/{providers → packages}/google-analytics/vite.config.ts +2 -2
- package/{providers → packages}/google-analytics/vitest.config.mts +2 -2
- package/packages/medusa/README.md +11 -0
- package/packages/medusa/eslint.config.mjs +23 -0
- package/packages/medusa/package.json +17 -0
- package/{providers → packages}/medusa/project.json +7 -8
- package/{providers/medusa/src/providers/cart.provider.ts → packages/medusa/src/capabilities/cart.capability.ts} +34 -21
- package/{providers/medusa/src/providers/category.provider.ts → packages/medusa/src/capabilities/category.capability.ts} +31 -13
- package/{providers/medusa/src/providers/checkout.provider.ts → packages/medusa/src/capabilities/checkout.capability.ts} +43 -18
- package/{providers/medusa/src/providers/identity.provider.ts → packages/medusa/src/capabilities/identity.capability.ts} +3 -3
- package/{providers/medusa/src/providers/inventory.provider.ts → packages/medusa/src/capabilities/inventory.capability.ts} +22 -8
- package/{providers/medusa/src/providers/order-search.provider.ts → packages/medusa/src/capabilities/order-search.capability.ts} +17 -6
- package/{providers/medusa/src/providers/order.provider.ts → packages/medusa/src/capabilities/order.capability.ts} +18 -6
- package/{providers/medusa/src/providers/price.provider.ts → packages/medusa/src/capabilities/price.capability.ts} +27 -8
- package/{providers/medusa/src/providers/product-associations.provider.ts → packages/medusa/src/capabilities/product-associations.capability.ts} +20 -9
- package/{providers/medusa/src/providers/product-recommendations.provider.ts → packages/medusa/src/capabilities/product-recommendations.capability.ts} +3 -3
- package/{providers/medusa/src/providers/product-search.provider.ts → packages/medusa/src/capabilities/product-search.capability.ts} +20 -32
- package/{providers/medusa/src/providers/product.provider.ts → packages/medusa/src/capabilities/product.capability.ts} +48 -12
- package/{providers/medusa/src/providers/profile.provider.ts → packages/medusa/src/capabilities/profile.capability.ts} +37 -13
- package/packages/medusa/src/core/initialize.ts +330 -0
- package/packages/medusa/src/core/initialize.types.ts +184 -0
- package/packages/medusa/src/factories/cart/cart.factory.ts +34 -0
- package/packages/medusa/src/factories/category/category.factory.ts +37 -0
- package/packages/medusa/src/factories/checkout/checkout.factory.ts +50 -0
- package/packages/medusa/src/factories/identity/identity.factory.ts +22 -0
- package/packages/medusa/src/factories/index.ts +12 -0
- package/packages/medusa/src/factories/inventory/inventory.factory.ts +25 -0
- package/packages/medusa/src/factories/order/order.factory.ts +22 -0
- package/packages/medusa/src/factories/order-search/order-search.factory.ts +27 -0
- package/packages/medusa/src/factories/price/price.factory.ts +26 -0
- package/packages/medusa/src/factories/product/product.factory.ts +22 -0
- package/packages/medusa/src/factories/product-associations/product-associations.factory.ts +25 -0
- package/packages/medusa/src/factories/product-search/product-search.factory.ts +27 -0
- package/packages/medusa/src/factories/profile/profile.factory.ts +22 -0
- package/packages/medusa/src/index.ts +17 -0
- package/packages/medusa/src/schema/capabilities.schema.ts +231 -0
- package/{providers/medusa/src/test/cart.provider.spec.ts → packages/medusa/src/test/cart.capability.spec.ts} +20 -4
- package/{providers/medusa/src/test/category.provider.spec.ts → packages/medusa/src/test/category.capability.spec.ts} +7 -4
- package/{providers → packages}/medusa/src/test/checkout.spec.ts +9 -9
- package/{providers/medusa/src/test/identity.provider.spec.ts → packages/medusa/src/test/identity.capability.spec.ts} +3 -3
- package/{providers/medusa/src/test/inventory.provider.spec.ts → packages/medusa/src/test/inventory.capability.spec.ts} +6 -4
- package/{providers/medusa/src/test/large-cart.provider.spec.ts → packages/medusa/src/test/large-cart.capability.spec.ts} +14 -8
- package/{providers/medusa/src/test/price.provider.spec.ts → packages/medusa/src/test/price.capability.spec.ts} +10 -3
- package/{providers/medusa/src/test/product.provider.spec.ts → packages/medusa/src/test/product.capability.spec.ts} +6 -4
- package/{providers/medusa/src/test/search.provider.spec.ts → packages/medusa/src/test/search.capability.spec.ts} +20 -7
- package/{providers → packages}/medusa/src/utils/medusa-helpers.ts +1 -1
- package/packages/medusa/tsconfig.json +24 -0
- package/packages/medusa/tsconfig.lib.json +23 -0
- package/packages/medusa/tsconfig.spec.json +28 -0
- package/packages/medusa/vite.config.ts +26 -0
- package/packages/medusa/vitest.config.mts +21 -0
- package/packages/meilisearch/README.md +11 -0
- package/packages/meilisearch/eslint.config.mjs +23 -0
- package/packages/meilisearch/package.json +15 -0
- package/{providers → packages}/meilisearch/project.json +7 -8
- package/packages/meilisearch/src/capabilities/index.ts +3 -0
- package/{providers/meilisearch/src/providers/order-search.provider.ts → packages/meilisearch/src/capabilities/order-search.capability.ts} +22 -7
- package/{providers/meilisearch/src/providers/product-recommendations.provider.ts → packages/meilisearch/src/capabilities/product-recommendations.capability.ts} +3 -3
- package/{providers/meilisearch/src/providers/product-search.provider.ts → packages/meilisearch/src/capabilities/product-search.capability.ts} +25 -9
- package/packages/meilisearch/src/core/initialize.ts +94 -0
- package/packages/meilisearch/src/core/initialize.types.ts +119 -0
- package/packages/meilisearch/src/factories/index.ts +2 -0
- package/packages/meilisearch/src/factories/order-search/order-search.factory.ts +27 -0
- package/packages/meilisearch/src/factories/product-search/product-search.factory.ts +27 -0
- package/packages/meilisearch/src/index.ts +9 -0
- package/packages/meilisearch/src/schema/capabilities.schema.ts +98 -0
- package/packages/meilisearch/tsconfig.json +24 -0
- package/packages/meilisearch/tsconfig.lib.json +23 -0
- package/packages/meilisearch/tsconfig.spec.json +28 -0
- package/packages/meilisearch/vite.config.ts +26 -0
- package/packages/meilisearch/vitest.config.mts +21 -0
- package/tsconfig.base.json +13 -21
- package/core/project.json +0 -34
- package/core/src/client/client-builder.ts +0 -84
- package/core/src/client/client.ts +0 -35
- package/core/src/index.ts +0 -6
- package/core/src/providers/index.ts +0 -18
- package/core/src/providers/product-search.provider.ts +0 -61
- package/core/src/test/client-builder.spec.ts +0 -60
- package/core/tsconfig.json +0 -24
- package/core/tsconfig.spec.json +0 -4
- package/core/vitest.config.ts +0 -14
- package/providers/algolia/README.md +0 -56
- package/providers/algolia/project.json +0 -34
- package/providers/algolia/src/core/initialize.ts +0 -27
- package/providers/algolia/src/providers/index.ts +0 -3
- package/providers/algolia/src/providers/product-search.provider.ts +0 -236
- package/providers/algolia/src/schema/capabilities.schema.ts +0 -10
- package/providers/algolia/tsconfig.lib.json +0 -10
- package/providers/algolia/tsconfig.spec.json +0 -4
- package/providers/algolia/vitest.config.ts +0 -14
- package/providers/commercetools/README.md +0 -65
- package/providers/commercetools/eslint.config.mjs +0 -22
- package/providers/commercetools/package.json +0 -15
- package/providers/commercetools/src/core/initialize.ts +0 -174
- package/providers/commercetools/src/index.ts +0 -15
- package/providers/commercetools/src/providers/index.ts +0 -15
- package/providers/commercetools/src/providers/order-search.provider.ts +0 -229
- package/providers/commercetools/src/providers/order.provider.ts +0 -198
- package/providers/commercetools/src/providers/product.provider.ts +0 -312
- package/providers/commercetools/src/schema/capabilities.schema.ts +0 -22
- package/providers/commercetools/tsconfig.lib.json +0 -10
- package/providers/commercetools/tsconfig.spec.json +0 -4
- package/providers/commercetools/vitest.config.ts +0 -15
- package/providers/fake/README.md +0 -23
- package/providers/fake/src/core/initialize.ts +0 -105
- package/providers/fake/src/providers/category.provider.ts +0 -184
- package/providers/fake/src/providers/index.ts +0 -15
- package/providers/fake/src/providers/inventory.provider.ts +0 -72
- package/providers/fake/src/providers/order-search.provider.ts +0 -78
- package/providers/fake/src/providers/profile.provider.ts +0 -147
- package/providers/fake/src/providers/store.provider.ts +0 -56
- package/providers/fake/src/schema/capabilities.schema.ts +0 -21
- package/providers/fake/tsconfig.json +0 -25
- package/providers/fake/tsconfig.lib.json +0 -11
- package/providers/fake/tsconfig.spec.json +0 -4
- package/providers/fake/vitest.config.ts +0 -14
- package/providers/google-analytics/src/core/initialize.ts +0 -16
- package/providers/google-analytics/src/schema/capabilities.schema.ts +0 -10
- package/providers/medusa/README.md +0 -30
- package/providers/medusa/TESTING.md +0 -98
- package/providers/medusa/eslint.config.mjs +0 -19
- package/providers/medusa/package.json +0 -15
- package/providers/medusa/src/core/initialize.ts +0 -87
- package/providers/medusa/src/index.ts +0 -15
- package/providers/medusa/src/schema/capabilities.schema.ts +0 -20
- package/providers/medusa/tsconfig.json +0 -24
- package/providers/medusa/tsconfig.spec.json +0 -4
- package/providers/medusa/vitest.config.ts +0 -15
- package/providers/meilisearch/README.md +0 -48
- package/providers/meilisearch/eslint.config.mjs +0 -22
- package/providers/meilisearch/package.json +0 -13
- package/providers/meilisearch/src/core/initialize.ts +0 -27
- package/providers/meilisearch/src/index.ts +0 -7
- package/providers/meilisearch/src/providers/index.ts +0 -2
- package/providers/meilisearch/src/schema/capabilities.schema.ts +0 -11
- package/providers/meilisearch/tsconfig.lib.json +0 -10
- package/providers/meilisearch/tsconfig.spec.json +0 -4
- package/providers/meilisearch/vitest.config.ts +0 -14
- package/providers/posthog/README.md +0 -7
- package/providers/posthog/eslint.config.mjs +0 -22
- package/providers/posthog/package.json +0 -12
- package/providers/posthog/src/core/initialize.ts +0 -11
- package/providers/posthog/src/index.ts +0 -4
- package/providers/posthog/src/schema/capabilities.schema.ts +0 -8
- package/providers/posthog/src/schema/configuration.schema.ts +0 -8
- package/providers/posthog/tsconfig.json +0 -21
- package/providers/posthog/tsconfig.lib.json +0 -9
- /package/{providers → packages}/algolia/src/schema/configuration.schema.ts +0 -0
- /package/{providers → packages}/algolia/src/schema/index.ts +0 -0
- /package/{providers → packages}/algolia/src/schema/product-recommendation.schema.ts +0 -0
- /package/{providers → packages}/algolia/src/schema/search.schema.ts +0 -0
- /package/{providers/google-analytics → packages/algolia}/tsconfig.json +0 -0
- /package/{providers/google-analytics → packages/algolia}/tsconfig.lib.json +0 -0
- /package/{providers/google-analytics → packages/algolia}/tsconfig.spec.json +0 -0
- /package/{providers → packages}/commercetools/src/core/token-cache.ts +0 -0
- /package/{providers → packages}/commercetools/src/schema/commercetools.schema.ts +0 -0
- /package/{providers → packages}/commercetools/src/schema/configuration.schema.ts +0 -0
- /package/{providers → packages}/commercetools/src/schema/session.schema.ts +0 -0
- /package/{providers → packages}/commercetools/src/test/identity.spec.ts +0 -0
- /package/{providers → packages}/commercetools/src/test/test-utils.ts +0 -0
- /package/{core → packages/core}/README.md +0 -0
- /package/{core → packages/core}/src/cache/cache.interface.ts +0 -0
- /package/{core → packages/core}/src/cache/index.ts +0 -0
- /package/{core → packages/core}/src/cache/memory-cache.ts +0 -0
- /package/{core → packages/core}/src/cache/noop-cache.ts +0 -0
- /package/{core → packages/core}/src/cache/redis-cache.ts +0 -0
- /package/{core → packages/core}/src/client/index.ts +0 -0
- /package/{core → packages/core}/src/decorators/index.ts +0 -0
- /package/{core → packages/core}/src/initialization.ts +0 -0
- /package/{core → packages/core}/src/metrics/metrics.ts +0 -0
- /package/{core → packages/core}/src/schemas/capabilities.schema.ts +0 -0
- /package/{core → packages/core}/src/schemas/errors/generic.error.ts +0 -0
- /package/{core → packages/core}/src/schemas/errors/index.ts +0 -0
- /package/{core → packages/core}/src/schemas/errors/invalid-input.error.ts +0 -0
- /package/{core → packages/core}/src/schemas/errors/invalid-output.error.ts +0 -0
- /package/{core → packages/core}/src/schemas/errors/not-found.error.ts +0 -0
- /package/{core → packages/core}/src/schemas/index.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/analytics.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/base.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/cart.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/category.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/checkout.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/cost.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/currency.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/identifiers.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/identity.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/index.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/inventory.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/order-search.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/order.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/payment.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/price.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/product-associations.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/product-list.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/product-recommendations.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/product-reviews.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/product-search.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/product.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/profile.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/shipping-method.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/models/store.model.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/analytics/index.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/analytics/product-add-to-cart.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/analytics/product-details-view.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/analytics/product-summary-click.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/analytics/product-summary-view.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/analytics/purchase.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/base.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/cart.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/checkout.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/identity.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/index.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/inventory.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/price.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/product-list.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/product-reviews.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/product.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/profile.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/mutations/search.mutation.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/analytics.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/base.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/cart.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/category.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/checkout.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/identity.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/index.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/inventory.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/order-search.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/order.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/price.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/product-associations.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/product-list.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/product-recommendations.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/product-reviews.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/product-search.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/product.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/profile.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/queries/store.query.ts +0 -0
- /package/{core → packages/core}/src/schemas/result.ts +0 -0
- /package/{core → packages/core}/src/schemas/session.schema.ts +0 -0
- /package/{core → packages/core}/src/test/request-context.spec.ts +0 -0
- /package/{core → packages/core}/src/zod-utils.ts +0 -0
- /package/{providers → packages}/fake/src/schema/configuration.schema.ts +0 -0
- /package/{providers → packages}/fake/src/test/test-utils.ts +0 -0
- /package/{providers → packages}/fake/src/utilities/jitter.ts +0 -0
- /package/{providers → packages}/fake/src/utilities/seed.ts +0 -0
- /package/{providers → packages}/google-analytics/README.md +0 -0
- /package/{providers → packages}/google-analytics/src/schema/configuration.schema.ts +0 -0
- /package/{providers → packages}/medusa/src/core/client.ts +0 -0
- /package/{providers → packages}/medusa/src/schema/configuration.schema.ts +0 -0
- /package/{providers → packages}/medusa/src/schema/medusa.schema.ts +0 -0
- /package/{providers → packages}/medusa/src/test/test-utils.ts +0 -0
- /package/{providers → packages}/meilisearch/src/schema/configuration.schema.ts +0 -0
- /package/{providers → packages}/meilisearch/src/schema/index.ts +0 -0
- /package/{providers → packages}/meilisearch/src/schema/search.schema.ts +0 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProductPagedSearchResponse,
|
|
3
|
+
ProductProjection,
|
|
4
|
+
ProductSearchFacetResult as CTProductSearchFacetResult,
|
|
5
|
+
ProductSearchFacetResultBucket as CTProductSearchFacetResultBucket,
|
|
6
|
+
ProductVariant as CTProductVariant,
|
|
7
|
+
} from '@commercetools/platform-sdk';
|
|
8
|
+
import type {
|
|
9
|
+
ProductSearchResultSchema} from '@reactionary/core';
|
|
10
|
+
import {
|
|
11
|
+
FacetIdentifierSchema,
|
|
12
|
+
FacetValueIdentifierSchema,
|
|
13
|
+
ImageSchema,
|
|
14
|
+
ProductOptionIdentifierSchema,
|
|
15
|
+
ProductSearchResultFacetSchema,
|
|
16
|
+
ProductSearchResultFacetValueSchema,
|
|
17
|
+
ProductSearchResultItemVariantSchema,
|
|
18
|
+
ProductVariantIdentifierSchema,
|
|
19
|
+
ProductVariantOptionSchema,
|
|
20
|
+
type AnyProductSearchResultSchema,
|
|
21
|
+
type FacetIdentifier,
|
|
22
|
+
type FacetValueIdentifier,
|
|
23
|
+
type ProductOptionIdentifier,
|
|
24
|
+
type ProductSearchFactory,
|
|
25
|
+
type ProductSearchQueryByTerm,
|
|
26
|
+
type ProductSearchResult,
|
|
27
|
+
type ProductSearchResultFacet,
|
|
28
|
+
type ProductSearchResultFacetValue,
|
|
29
|
+
type ProductSearchResultItem,
|
|
30
|
+
type ProductSearchResultItemVariant,
|
|
31
|
+
type ProductVariantIdentifier,
|
|
32
|
+
type ProductVariantOption,
|
|
33
|
+
type RequestContext,
|
|
34
|
+
type SearchIdentifier,
|
|
35
|
+
} from '@reactionary/core';
|
|
36
|
+
import type * as z from 'zod';
|
|
37
|
+
|
|
38
|
+
export class CommercetoolsProductSearchFactory<
|
|
39
|
+
TProductSearchResultSchema extends AnyProductSearchResultSchema = typeof ProductSearchResultSchema,
|
|
40
|
+
> implements ProductSearchFactory<TProductSearchResultSchema>
|
|
41
|
+
{
|
|
42
|
+
public readonly productSearchResultSchema: TProductSearchResultSchema;
|
|
43
|
+
|
|
44
|
+
constructor(productSearchResultSchema: TProductSearchResultSchema) {
|
|
45
|
+
this.productSearchResultSchema = productSearchResultSchema;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public parseSearchResult(
|
|
49
|
+
context: RequestContext,
|
|
50
|
+
data: ProductPagedSearchResponse,
|
|
51
|
+
query: ProductSearchQueryByTerm,
|
|
52
|
+
): z.output<TProductSearchResultSchema> {
|
|
53
|
+
const identifier = {
|
|
54
|
+
...query.search,
|
|
55
|
+
} satisfies SearchIdentifier;
|
|
56
|
+
|
|
57
|
+
const items: ProductSearchResultItem[] = data.results.map((product) =>
|
|
58
|
+
this.parseSingle(context, product.productProjection!),
|
|
59
|
+
);
|
|
60
|
+
const facets: ProductSearchResultFacet[] = [];
|
|
61
|
+
|
|
62
|
+
for (const facet of data.facets) {
|
|
63
|
+
const facetIdentifier = FacetIdentifierSchema.parse({
|
|
64
|
+
key: facet.name,
|
|
65
|
+
} satisfies Partial<FacetIdentifier>);
|
|
66
|
+
|
|
67
|
+
const candidateFacet = this.parseFacet(facetIdentifier, facet);
|
|
68
|
+
if (candidateFacet.values.length > 0) {
|
|
69
|
+
facets.push(candidateFacet);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const result = {
|
|
74
|
+
identifier,
|
|
75
|
+
pageNumber: (Math.ceil(data.offset / data.limit) || 0) + 1,
|
|
76
|
+
pageSize: data.limit,
|
|
77
|
+
totalCount: data.total || 0,
|
|
78
|
+
totalPages: Math.ceil((data.total || 0) / data.limit || 0) + 1,
|
|
79
|
+
items,
|
|
80
|
+
facets,
|
|
81
|
+
} satisfies ProductSearchResult;
|
|
82
|
+
|
|
83
|
+
return this.productSearchResultSchema.parse(result);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
protected parseSingle(
|
|
87
|
+
context: RequestContext,
|
|
88
|
+
data: ProductProjection,
|
|
89
|
+
): ProductSearchResultItem {
|
|
90
|
+
const identifier = { key: data.id };
|
|
91
|
+
const name = data.name[context.languageContext.locale] || data.id;
|
|
92
|
+
const slug = data.slug?.[context.languageContext.locale] || data.id;
|
|
93
|
+
const variants = [data.masterVariant, ...data.variants].map((variant) =>
|
|
94
|
+
this.parseVariant(context, variant, data),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const result = {
|
|
98
|
+
identifier,
|
|
99
|
+
name,
|
|
100
|
+
slug,
|
|
101
|
+
variants,
|
|
102
|
+
} satisfies ProductSearchResultItem;
|
|
103
|
+
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
protected parseFacet(
|
|
108
|
+
facetIdentifier: FacetIdentifier,
|
|
109
|
+
facet: CTProductSearchFacetResult,
|
|
110
|
+
): ProductSearchResultFacet {
|
|
111
|
+
const result: ProductSearchResultFacet = ProductSearchResultFacetSchema.parse({
|
|
112
|
+
identifier: facetIdentifier,
|
|
113
|
+
name: facet.name,
|
|
114
|
+
values: [],
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const distinctFacet = facet as CTProductSearchFacetResultBucket;
|
|
118
|
+
for (const bucket of distinctFacet.buckets || []) {
|
|
119
|
+
const facetValueIdentifier = FacetValueIdentifierSchema.parse({
|
|
120
|
+
facet: facetIdentifier,
|
|
121
|
+
key: bucket.key,
|
|
122
|
+
} satisfies Partial<FacetValueIdentifier>);
|
|
123
|
+
|
|
124
|
+
result.values.push(
|
|
125
|
+
this.parseFacetValue(facetValueIdentifier, bucket.key, bucket.count),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
protected parseFacetValue(
|
|
133
|
+
facetValueIdentifier: FacetValueIdentifier,
|
|
134
|
+
label: string,
|
|
135
|
+
count: number,
|
|
136
|
+
): ProductSearchResultFacetValue {
|
|
137
|
+
return ProductSearchResultFacetValueSchema.parse({
|
|
138
|
+
identifier: facetValueIdentifier,
|
|
139
|
+
name: label,
|
|
140
|
+
count,
|
|
141
|
+
active: false,
|
|
142
|
+
} satisfies Partial<ProductSearchResultFacetValue>);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
protected parseVariant(
|
|
146
|
+
context: RequestContext,
|
|
147
|
+
variant: CTProductVariant,
|
|
148
|
+
product: ProductProjection,
|
|
149
|
+
): ProductSearchResultItemVariant {
|
|
150
|
+
const sourceImage = variant.images?.[0];
|
|
151
|
+
|
|
152
|
+
const image = ImageSchema.parse({
|
|
153
|
+
sourceUrl: sourceImage?.url || '',
|
|
154
|
+
height: sourceImage?.dimensions.h || undefined,
|
|
155
|
+
width: sourceImage?.dimensions.w || undefined,
|
|
156
|
+
altText:
|
|
157
|
+
sourceImage?.label || product.name[context.languageContext.locale] || undefined,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const mappedOptions =
|
|
161
|
+
variant.attributes
|
|
162
|
+
?.filter((attribute) => attribute.name === 'Color')
|
|
163
|
+
.map((option) =>
|
|
164
|
+
ProductVariantOptionSchema.parse({
|
|
165
|
+
identifier: ProductOptionIdentifierSchema.parse({
|
|
166
|
+
key: option.name,
|
|
167
|
+
} satisfies Partial<ProductOptionIdentifier>),
|
|
168
|
+
name: option.value || '',
|
|
169
|
+
} satisfies Partial<ProductVariantOption>),
|
|
170
|
+
) || [];
|
|
171
|
+
|
|
172
|
+
const mappedOption = mappedOptions?.[0];
|
|
173
|
+
|
|
174
|
+
return ProductSearchResultItemVariantSchema.parse({
|
|
175
|
+
variant: ProductVariantIdentifierSchema.parse({
|
|
176
|
+
sku: variant.sku || '',
|
|
177
|
+
} satisfies ProductVariantIdentifier),
|
|
178
|
+
image,
|
|
179
|
+
options: mappedOption,
|
|
180
|
+
} satisfies Partial<ProductSearchResultItemVariant>);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Address as CTAddress, Customer } from '@commercetools/platform-sdk';
|
|
2
|
+
import type {
|
|
3
|
+
ProfileSchema} from '@reactionary/core';
|
|
4
|
+
import {
|
|
5
|
+
type Address,
|
|
6
|
+
type AnyProfileSchema,
|
|
7
|
+
type Profile,
|
|
8
|
+
type ProfileFactory,
|
|
9
|
+
type RequestContext,
|
|
10
|
+
} from '@reactionary/core';
|
|
11
|
+
import type * as z from 'zod';
|
|
12
|
+
|
|
13
|
+
export class CommercetoolsProfileFactory<
|
|
14
|
+
TProfileSchema extends AnyProfileSchema = typeof ProfileSchema,
|
|
15
|
+
> implements ProfileFactory<TProfileSchema>
|
|
16
|
+
{
|
|
17
|
+
public readonly profileSchema: TProfileSchema;
|
|
18
|
+
|
|
19
|
+
constructor(profileSchema: TProfileSchema) {
|
|
20
|
+
this.profileSchema = profileSchema;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public parseProfile(
|
|
24
|
+
_context: RequestContext,
|
|
25
|
+
data: Customer,
|
|
26
|
+
): z.output<TProfileSchema> {
|
|
27
|
+
const email = data.email;
|
|
28
|
+
const emailVerified = data.isEmailVerified;
|
|
29
|
+
let defaultBilling = data.addresses.find((address) => address.id === data.defaultBillingAddressId);
|
|
30
|
+
const phone = defaultBilling?.phone ?? '';
|
|
31
|
+
|
|
32
|
+
if (this.isIncompleteAddress(defaultBilling)) {
|
|
33
|
+
defaultBilling = undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const defaultShipping = data.addresses.find(
|
|
37
|
+
(address) => address.id === data.defaultShippingAddressId,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const alternateShippingAddresses = data.addresses
|
|
41
|
+
.filter((address) => address.id !== data.defaultBillingAddressId)
|
|
42
|
+
.filter((address) => address.id !== data.defaultShippingAddressId)
|
|
43
|
+
.map((address) => this.parseAddress(address));
|
|
44
|
+
|
|
45
|
+
const billingAddress = defaultBilling ? this.parseAddress(defaultBilling) : undefined;
|
|
46
|
+
const shippingAddress = defaultShipping ? this.parseAddress(defaultShipping) : undefined;
|
|
47
|
+
|
|
48
|
+
const result = {
|
|
49
|
+
identifier: {
|
|
50
|
+
userId: data.id,
|
|
51
|
+
},
|
|
52
|
+
email,
|
|
53
|
+
emailVerified,
|
|
54
|
+
alternateShippingAddresses,
|
|
55
|
+
billingAddress,
|
|
56
|
+
shippingAddress,
|
|
57
|
+
createdAt: data.createdAt,
|
|
58
|
+
phone,
|
|
59
|
+
phoneVerified: false,
|
|
60
|
+
updatedAt: data.lastModifiedAt,
|
|
61
|
+
} satisfies Profile;
|
|
62
|
+
|
|
63
|
+
return this.profileSchema.parse(result);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected parseAddress(address: CTAddress): Address {
|
|
67
|
+
return {
|
|
68
|
+
identifier: {
|
|
69
|
+
nickName: address.key || '',
|
|
70
|
+
},
|
|
71
|
+
firstName: address.firstName || '',
|
|
72
|
+
lastName: address.lastName || '',
|
|
73
|
+
streetAddress: address.streetName || '',
|
|
74
|
+
streetNumber: address.streetNumber || '',
|
|
75
|
+
city: address.city || '',
|
|
76
|
+
region: address.region || '',
|
|
77
|
+
postalCode: address.postalCode || '',
|
|
78
|
+
countryCode: address.country,
|
|
79
|
+
} satisfies Address;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected isIncompleteAddress(address: CTAddress | undefined): boolean {
|
|
83
|
+
if (!address) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return (
|
|
87
|
+
!address.firstName &&
|
|
88
|
+
!address.lastName &&
|
|
89
|
+
!address.streetName &&
|
|
90
|
+
!address.streetNumber &&
|
|
91
|
+
!address.city
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Channel } from '@commercetools/platform-sdk';
|
|
2
|
+
import type {
|
|
3
|
+
StoreSchema} from '@reactionary/core';
|
|
4
|
+
import {
|
|
5
|
+
type AnyStoreSchema,
|
|
6
|
+
type FulfillmentCenterIdentifier,
|
|
7
|
+
type RequestContext,
|
|
8
|
+
type Store,
|
|
9
|
+
type StoreFactory,
|
|
10
|
+
type StoreIdentifier,
|
|
11
|
+
} from '@reactionary/core';
|
|
12
|
+
import type * as z from 'zod';
|
|
13
|
+
|
|
14
|
+
export class CommercetoolsStoreFactory<
|
|
15
|
+
TStoreSchema extends AnyStoreSchema = typeof StoreSchema,
|
|
16
|
+
> implements StoreFactory<TStoreSchema>
|
|
17
|
+
{
|
|
18
|
+
public readonly storeSchema: TStoreSchema;
|
|
19
|
+
|
|
20
|
+
constructor(storeSchema: TStoreSchema) {
|
|
21
|
+
this.storeSchema = storeSchema;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public parseStore(
|
|
25
|
+
_context: RequestContext,
|
|
26
|
+
data: Channel,
|
|
27
|
+
): z.output<TStoreSchema> {
|
|
28
|
+
let name = '';
|
|
29
|
+
if (data.name && data.name['la']) {
|
|
30
|
+
name = data.name['la'];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const identifier = {
|
|
34
|
+
key: data.key || '',
|
|
35
|
+
} satisfies StoreIdentifier;
|
|
36
|
+
|
|
37
|
+
const fulfillmentCenter = {
|
|
38
|
+
key: data.key || '',
|
|
39
|
+
} satisfies FulfillmentCenterIdentifier;
|
|
40
|
+
|
|
41
|
+
const result = {
|
|
42
|
+
identifier,
|
|
43
|
+
fulfillmentCenter,
|
|
44
|
+
name,
|
|
45
|
+
} satisfies Store;
|
|
46
|
+
|
|
47
|
+
return this.storeSchema.parse(result);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export * from './core/client.js';
|
|
2
|
+
export * from './core/initialize.js';
|
|
3
|
+
|
|
4
|
+
export * from './capabilities/cart.capability.js';
|
|
5
|
+
export * from './capabilities/identity.capability.js';
|
|
6
|
+
export * from './capabilities/inventory.capability.js';
|
|
7
|
+
export * from './capabilities/order-search.capability.js';
|
|
8
|
+
export * from './capabilities/price.capability.js';
|
|
9
|
+
export * from './capabilities/product-associations.capability.js';
|
|
10
|
+
export * from './capabilities/product.capability.js';
|
|
11
|
+
export * from './capabilities/product-reviews.capability.js';
|
|
12
|
+
export * from './capabilities/product-search.capability.js';
|
|
13
|
+
export * from './factories/product/product.factory.js';
|
|
14
|
+
export * from './factories/checkout/checkout.factory.js';
|
|
15
|
+
export * from './factories/product-search/product-search.factory.js';
|
|
16
|
+
export * from './factories/inventory/inventory.factory.js';
|
|
17
|
+
export * from './factories/price/price.factory.js';
|
|
18
|
+
export * from './factories/store/store.factory.js';
|
|
19
|
+
export * from './factories/order/order.factory.js';
|
|
20
|
+
export * from './factories/category/category.factory.js';
|
|
21
|
+
export * from './factories/cart/cart.factory.js';
|
|
22
|
+
export * from './factories/profile/profile.factory.js';
|
|
23
|
+
export * from './factories/order-search/order-search.factory.js';
|
|
24
|
+
export * from './factories/product-associations/product-associations.factory.js';
|
|
25
|
+
export * from './factories/product-reviews/product-reviews.factory.js';
|
|
26
|
+
export * from './factories/product-list/product-list.factory.js';
|
|
27
|
+
export * from './factories/identity/identity.factory.js';
|
|
28
|
+
|
|
29
|
+
export * from './schema/capabilities.schema.js';
|
|
30
|
+
export * from './schema/configuration.schema.js';
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Cache,
|
|
3
|
+
CartFactory,
|
|
4
|
+
CartFactoryWithOutput,
|
|
5
|
+
CartCapability,
|
|
6
|
+
CategoryFactory,
|
|
7
|
+
CategoryFactoryWithOutput,
|
|
8
|
+
CategoryCapability,
|
|
9
|
+
CheckoutFactory,
|
|
10
|
+
CheckoutFactoryWithOutput,
|
|
11
|
+
CheckoutCapability,
|
|
12
|
+
IdentityFactory,
|
|
13
|
+
IdentityFactoryWithOutput,
|
|
14
|
+
IdentityCapability,
|
|
15
|
+
InventoryFactory,
|
|
16
|
+
InventoryFactoryWithOutput,
|
|
17
|
+
InventoryCapability,
|
|
18
|
+
OrderFactory,
|
|
19
|
+
OrderFactoryWithOutput,
|
|
20
|
+
OrderCapability,
|
|
21
|
+
OrderSearchFactory,
|
|
22
|
+
OrderSearchFactoryWithOutput,
|
|
23
|
+
OrderSearchCapability,
|
|
24
|
+
PriceFactory,
|
|
25
|
+
PriceFactoryWithOutput,
|
|
26
|
+
PriceCapability,
|
|
27
|
+
ProductAssociationsFactory,
|
|
28
|
+
ProductAssociationsFactoryWithOutput,
|
|
29
|
+
ProductAssociationsCapability,
|
|
30
|
+
ProductFactory,
|
|
31
|
+
ProductFactoryWithOutput,
|
|
32
|
+
ProductListFactory,
|
|
33
|
+
ProductListFactoryWithOutput,
|
|
34
|
+
ProductListCapability,
|
|
35
|
+
ProductCapability,
|
|
36
|
+
ProductReviewsFactory,
|
|
37
|
+
ProductReviewsFactoryWithOutput,
|
|
38
|
+
ProductReviewsCapability,
|
|
39
|
+
ProductSearchFactory,
|
|
40
|
+
ProductSearchFactoryWithOutput,
|
|
41
|
+
ProductSearchCapability,
|
|
42
|
+
ProfileFactory,
|
|
43
|
+
ProfileFactoryWithOutput,
|
|
44
|
+
ProfileCapability,
|
|
45
|
+
RequestContext,
|
|
46
|
+
StoreFactory,
|
|
47
|
+
StoreFactoryWithOutput,
|
|
48
|
+
StoreCapability,
|
|
49
|
+
} from '@reactionary/core';
|
|
50
|
+
import { CapabilitiesSchema } from '@reactionary/core';
|
|
51
|
+
import type { CommercetoolsAPI } from '../core/client.js';
|
|
52
|
+
import type { CommercetoolsConfiguration } from './configuration.schema.js';
|
|
53
|
+
import * as z from 'zod';
|
|
54
|
+
|
|
55
|
+
const EnabledCapabilitySchema = z.looseObject({
|
|
56
|
+
enabled: z.boolean(),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const OverridableCapabilitySchema = z.looseObject({
|
|
60
|
+
enabled: z.boolean(),
|
|
61
|
+
factory: z.unknown().optional(),
|
|
62
|
+
capability: z.unknown().optional(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export const CommercetoolsCapabilitiesSchema = CapabilitiesSchema.pick({
|
|
66
|
+
product: true,
|
|
67
|
+
productSearch: true,
|
|
68
|
+
productAssociations: true,
|
|
69
|
+
productReviews: true,
|
|
70
|
+
productList: true,
|
|
71
|
+
identity: true,
|
|
72
|
+
cart: true,
|
|
73
|
+
checkout: true,
|
|
74
|
+
order: true,
|
|
75
|
+
orderSearch: true,
|
|
76
|
+
inventory: true,
|
|
77
|
+
price: true,
|
|
78
|
+
category: true,
|
|
79
|
+
store: true,
|
|
80
|
+
profile: true,
|
|
81
|
+
})
|
|
82
|
+
.extend({
|
|
83
|
+
productSearch: EnabledCapabilitySchema.optional(),
|
|
84
|
+
productAssociations: EnabledCapabilitySchema.optional(),
|
|
85
|
+
productReviews: EnabledCapabilitySchema.optional(),
|
|
86
|
+
productList: EnabledCapabilitySchema.optional(),
|
|
87
|
+
identity: EnabledCapabilitySchema.optional(),
|
|
88
|
+
cart: EnabledCapabilitySchema.optional(),
|
|
89
|
+
order: EnabledCapabilitySchema.optional(),
|
|
90
|
+
orderSearch: EnabledCapabilitySchema.optional(),
|
|
91
|
+
inventory: EnabledCapabilitySchema.optional(),
|
|
92
|
+
price: EnabledCapabilitySchema.optional(),
|
|
93
|
+
category: EnabledCapabilitySchema.optional(),
|
|
94
|
+
store: EnabledCapabilitySchema.optional(),
|
|
95
|
+
profile: EnabledCapabilitySchema.optional(),
|
|
96
|
+
product: OverridableCapabilitySchema.optional(),
|
|
97
|
+
checkout: OverridableCapabilitySchema.optional(),
|
|
98
|
+
})
|
|
99
|
+
.partial();
|
|
100
|
+
|
|
101
|
+
export interface CommercetoolsCapabilityFactoryArgs<TFactory> {
|
|
102
|
+
cache: Cache;
|
|
103
|
+
context: RequestContext;
|
|
104
|
+
config: CommercetoolsConfiguration;
|
|
105
|
+
commercetoolsApi: CommercetoolsAPI;
|
|
106
|
+
factory: TFactory;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface CommercetoolsCapabilityConfig<TFactory, TCapability> {
|
|
110
|
+
factory?: TFactory;
|
|
111
|
+
capability?: (args: CommercetoolsCapabilityFactoryArgs<TFactory>) => TCapability;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type EnabledCapabilityConfig<TFactory, TCapability> = {
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
} & CommercetoolsCapabilityConfig<TFactory, TCapability>;
|
|
117
|
+
|
|
118
|
+
export type CommercetoolsProductCapabilityConfig<
|
|
119
|
+
TFactory extends ProductFactory = ProductFactory,
|
|
120
|
+
TCapability extends ProductCapability = ProductCapability,
|
|
121
|
+
> = CommercetoolsCapabilityConfig<ProductFactoryWithOutput<TFactory>, TCapability>;
|
|
122
|
+
|
|
123
|
+
export type CommercetoolsCheckoutCapabilityConfig<
|
|
124
|
+
TFactory extends CheckoutFactory = CheckoutFactory,
|
|
125
|
+
TCapability extends CheckoutCapability = CheckoutCapability,
|
|
126
|
+
> = CommercetoolsCapabilityConfig<CheckoutFactoryWithOutput<TFactory>, TCapability>;
|
|
127
|
+
|
|
128
|
+
export type CommercetoolsProductSearchCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
129
|
+
ProductSearchFactoryWithOutput<ProductSearchFactory>,
|
|
130
|
+
ProductSearchCapability
|
|
131
|
+
>;
|
|
132
|
+
export type CommercetoolsProductAssociationsCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
133
|
+
ProductAssociationsFactoryWithOutput<ProductAssociationsFactory>,
|
|
134
|
+
ProductAssociationsCapability
|
|
135
|
+
>;
|
|
136
|
+
export type CommercetoolsProductReviewsCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
137
|
+
ProductReviewsFactoryWithOutput<ProductReviewsFactory>,
|
|
138
|
+
ProductReviewsCapability
|
|
139
|
+
>;
|
|
140
|
+
export type CommercetoolsProductListCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
141
|
+
ProductListFactoryWithOutput<ProductListFactory>,
|
|
142
|
+
ProductListCapability
|
|
143
|
+
>;
|
|
144
|
+
export type CommercetoolsIdentityCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
145
|
+
IdentityFactoryWithOutput<IdentityFactory>,
|
|
146
|
+
IdentityCapability
|
|
147
|
+
>;
|
|
148
|
+
export type CommercetoolsCartCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
149
|
+
CartFactoryWithOutput<CartFactory>,
|
|
150
|
+
CartCapability
|
|
151
|
+
>;
|
|
152
|
+
export type CommercetoolsInventoryCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
153
|
+
InventoryFactoryWithOutput<InventoryFactory>,
|
|
154
|
+
InventoryCapability
|
|
155
|
+
>;
|
|
156
|
+
export type CommercetoolsPriceCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
157
|
+
PriceFactoryWithOutput<PriceFactory>,
|
|
158
|
+
PriceCapability
|
|
159
|
+
>;
|
|
160
|
+
export type CommercetoolsCategoryCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
161
|
+
CategoryFactoryWithOutput<CategoryFactory>,
|
|
162
|
+
CategoryCapability
|
|
163
|
+
>;
|
|
164
|
+
export type CommercetoolsStoreCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
165
|
+
StoreFactoryWithOutput<StoreFactory>,
|
|
166
|
+
StoreCapability
|
|
167
|
+
>;
|
|
168
|
+
export type CommercetoolsProfileCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
169
|
+
ProfileFactoryWithOutput<ProfileFactory>,
|
|
170
|
+
ProfileCapability
|
|
171
|
+
>;
|
|
172
|
+
export type CommercetoolsOrderCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
173
|
+
OrderFactoryWithOutput<OrderFactory>,
|
|
174
|
+
OrderCapability
|
|
175
|
+
>;
|
|
176
|
+
export type CommercetoolsOrderSearchCapabilityConfig = CommercetoolsCapabilityConfig<
|
|
177
|
+
OrderSearchFactoryWithOutput<OrderSearchFactory>,
|
|
178
|
+
OrderSearchCapability
|
|
179
|
+
>;
|
|
180
|
+
|
|
181
|
+
export type CommercetoolsCapabilityConfigMap<
|
|
182
|
+
TProductFactory extends ProductFactory = ProductFactory,
|
|
183
|
+
TProductCapability extends ProductCapability = ProductCapability,
|
|
184
|
+
TCheckoutFactory extends CheckoutFactory = CheckoutFactory,
|
|
185
|
+
TCheckoutCapability extends CheckoutCapability = CheckoutCapability,
|
|
186
|
+
> = {
|
|
187
|
+
product: EnabledCapabilityConfig<
|
|
188
|
+
ProductFactoryWithOutput<TProductFactory>,
|
|
189
|
+
TProductCapability
|
|
190
|
+
>;
|
|
191
|
+
checkout: EnabledCapabilityConfig<
|
|
192
|
+
CheckoutFactoryWithOutput<TCheckoutFactory>,
|
|
193
|
+
TCheckoutCapability
|
|
194
|
+
>;
|
|
195
|
+
productSearch: EnabledCapabilityConfig<
|
|
196
|
+
ProductSearchFactoryWithOutput<ProductSearchFactory>,
|
|
197
|
+
ProductSearchCapability
|
|
198
|
+
>;
|
|
199
|
+
productAssociations: EnabledCapabilityConfig<
|
|
200
|
+
ProductAssociationsFactoryWithOutput<ProductAssociationsFactory>,
|
|
201
|
+
ProductAssociationsCapability
|
|
202
|
+
>;
|
|
203
|
+
productReviews: EnabledCapabilityConfig<
|
|
204
|
+
ProductReviewsFactoryWithOutput<ProductReviewsFactory>,
|
|
205
|
+
ProductReviewsCapability
|
|
206
|
+
>;
|
|
207
|
+
productList: EnabledCapabilityConfig<
|
|
208
|
+
ProductListFactoryWithOutput<ProductListFactory>,
|
|
209
|
+
ProductListCapability
|
|
210
|
+
>;
|
|
211
|
+
identity: EnabledCapabilityConfig<
|
|
212
|
+
IdentityFactoryWithOutput<IdentityFactory>,
|
|
213
|
+
IdentityCapability
|
|
214
|
+
>;
|
|
215
|
+
cart: EnabledCapabilityConfig<CartFactoryWithOutput<CartFactory>, CartCapability>;
|
|
216
|
+
inventory: EnabledCapabilityConfig<
|
|
217
|
+
InventoryFactoryWithOutput<InventoryFactory>,
|
|
218
|
+
InventoryCapability
|
|
219
|
+
>;
|
|
220
|
+
price: EnabledCapabilityConfig<PriceFactoryWithOutput<PriceFactory>, PriceCapability>;
|
|
221
|
+
category: EnabledCapabilityConfig<
|
|
222
|
+
CategoryFactoryWithOutput<CategoryFactory>,
|
|
223
|
+
CategoryCapability
|
|
224
|
+
>;
|
|
225
|
+
store: EnabledCapabilityConfig<StoreFactoryWithOutput<StoreFactory>, StoreCapability>;
|
|
226
|
+
profile: EnabledCapabilityConfig<
|
|
227
|
+
ProfileFactoryWithOutput<ProfileFactory>,
|
|
228
|
+
ProfileCapability
|
|
229
|
+
>;
|
|
230
|
+
order: EnabledCapabilityConfig<OrderFactoryWithOutput<OrderFactory>, OrderCapability>;
|
|
231
|
+
orderSearch: EnabledCapabilityConfig<
|
|
232
|
+
OrderSearchFactoryWithOutput<OrderSearchFactory>,
|
|
233
|
+
OrderSearchCapability
|
|
234
|
+
>;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
type CommercetoolsCapabilitiesBase = z.infer<typeof CommercetoolsCapabilitiesSchema>;
|
|
238
|
+
|
|
239
|
+
export type CommercetoolsCapabilities<
|
|
240
|
+
TProductFactory extends ProductFactory = ProductFactory,
|
|
241
|
+
TProductCapability extends ProductCapability = ProductCapability,
|
|
242
|
+
TCheckoutFactory extends CheckoutFactory = CheckoutFactory,
|
|
243
|
+
TCheckoutCapability extends CheckoutCapability = CheckoutCapability,
|
|
244
|
+
> = Omit<
|
|
245
|
+
CommercetoolsCapabilitiesBase,
|
|
246
|
+
keyof CommercetoolsCapabilityConfigMap<
|
|
247
|
+
TProductFactory,
|
|
248
|
+
TProductCapability,
|
|
249
|
+
TCheckoutFactory,
|
|
250
|
+
TCheckoutCapability
|
|
251
|
+
>
|
|
252
|
+
> &
|
|
253
|
+
Partial<
|
|
254
|
+
CommercetoolsCapabilityConfigMap<
|
|
255
|
+
TProductFactory,
|
|
256
|
+
TProductCapability,
|
|
257
|
+
TCheckoutFactory,
|
|
258
|
+
TCheckoutCapability
|
|
259
|
+
>
|
|
260
|
+
>;
|
|
@@ -4,12 +4,16 @@ import { getCommercetoolsTestConfiguration } from './test-utils.js';
|
|
|
4
4
|
import {
|
|
5
5
|
createInitialRequestContext,
|
|
6
6
|
MemoryCache,
|
|
7
|
+
ProductSchema,
|
|
8
|
+
ProductSearchResultSchema,
|
|
7
9
|
type ProductIdentifier,
|
|
8
10
|
type ProductSearchQueryByTerm,
|
|
9
11
|
} from '@reactionary/core';
|
|
10
|
-
import {
|
|
12
|
+
import { CommercetoolsProductCapability } from '../capabilities/product.capability.js';
|
|
11
13
|
import { CommercetoolsAPI } from '../core/client.js';
|
|
12
|
-
import {
|
|
14
|
+
import { CommercetoolsProductSearchCapability } from '../capabilities/product-search.capability.js';
|
|
15
|
+
import { CommercetoolsProductFactory } from '../factories/product/product.factory.js';
|
|
16
|
+
import { CommercetoolsProductSearchFactory } from '../factories/product-search/product-search.factory.js';
|
|
13
17
|
|
|
14
18
|
describe('Caching', () => {
|
|
15
19
|
it('should cache repeat look-ups for products', async () => {
|
|
@@ -17,13 +21,19 @@ describe('Caching', () => {
|
|
|
17
21
|
const context = createInitialRequestContext();
|
|
18
22
|
const cache = new MemoryCache();
|
|
19
23
|
const client = new CommercetoolsAPI(config, context);
|
|
20
|
-
const
|
|
24
|
+
const capability = new CommercetoolsProductCapability(
|
|
25
|
+
cache,
|
|
26
|
+
context,
|
|
27
|
+
config,
|
|
28
|
+
client,
|
|
29
|
+
new CommercetoolsProductFactory(ProductSchema)
|
|
30
|
+
);
|
|
21
31
|
|
|
22
32
|
const identifier = {
|
|
23
33
|
key: 'product_10959528'
|
|
24
34
|
} satisfies ProductIdentifier;
|
|
25
35
|
|
|
26
|
-
const uncached = await
|
|
36
|
+
const uncached = await capability.getById({
|
|
27
37
|
identifier
|
|
28
38
|
});
|
|
29
39
|
|
|
@@ -33,7 +43,7 @@ describe('Caching', () => {
|
|
|
33
43
|
|
|
34
44
|
expect(uncached.meta.cache.hit).toBe(false);
|
|
35
45
|
|
|
36
|
-
const cached = await
|
|
46
|
+
const cached = await capability.getById({
|
|
37
47
|
identifier
|
|
38
48
|
});
|
|
39
49
|
|
|
@@ -49,7 +59,13 @@ describe('Caching', () => {
|
|
|
49
59
|
const context = createInitialRequestContext();
|
|
50
60
|
const cache = new MemoryCache();
|
|
51
61
|
const client = new CommercetoolsAPI(config, context);
|
|
52
|
-
const
|
|
62
|
+
const capability = new CommercetoolsProductSearchCapability(
|
|
63
|
+
config,
|
|
64
|
+
cache,
|
|
65
|
+
context,
|
|
66
|
+
client,
|
|
67
|
+
new CommercetoolsProductSearchFactory(ProductSearchResultSchema),
|
|
68
|
+
);
|
|
53
69
|
|
|
54
70
|
const query = {
|
|
55
71
|
search: {
|
|
@@ -63,7 +79,7 @@ describe('Caching', () => {
|
|
|
63
79
|
}
|
|
64
80
|
} satisfies ProductSearchQueryByTerm;
|
|
65
81
|
|
|
66
|
-
const uncached = await
|
|
82
|
+
const uncached = await capability.queryByTerm(query);
|
|
67
83
|
|
|
68
84
|
if (!uncached.success) {
|
|
69
85
|
assert.fail();
|
|
@@ -71,7 +87,7 @@ describe('Caching', () => {
|
|
|
71
87
|
|
|
72
88
|
expect(uncached.meta.cache.hit).toBe(false);
|
|
73
89
|
|
|
74
|
-
const cached = await
|
|
90
|
+
const cached = await capability.queryByTerm(query);
|
|
75
91
|
|
|
76
92
|
if (!cached.success) {
|
|
77
93
|
assert.fail();
|