@reactionary/source 0.6.2 → 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 +19 -0
- package/examples/node/package.json +7 -7
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +1 -1
- package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +1 -1
- package/examples/node/src/basic/basic-node-setup.spec.ts +1 -1
- package/examples/node/src/basic/client-creation.spec.ts +3 -3
- package/examples/node/src/utils.ts +7 -7
- 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} +2 -2
- 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/{providers/algolia/src/providers/product-search.provider.ts → packages/algolia/src/capabilities/product-search.capability.ts} +3 -3
- package/{providers → packages}/algolia/src/core/initialize.ts +12 -12
- package/packages/algolia/src/core/initialize.types.ts +107 -0
- package/{providers → packages}/algolia/src/index.ts +1 -1
- package/{providers → packages}/algolia/src/schema/capabilities.schema.ts +23 -23
- package/{providers → packages}/algolia/src/test/analytics.spec.ts +4 -4
- 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} +3 -3
- package/{providers/commercetools/src/providers/category.provider.ts → packages/commercetools/src/capabilities/category.capability.ts} +4 -4
- package/{providers/commercetools/src/providers/checkout.provider.ts → packages/commercetools/src/capabilities/checkout.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/identity.provider.ts → packages/commercetools/src/capabilities/identity.capability.ts} +3 -3
- package/packages/commercetools/src/capabilities/index.ts +15 -0
- package/{providers/commercetools/src/providers/inventory.provider.ts → packages/commercetools/src/capabilities/inventory.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/order-search.provider.ts → packages/commercetools/src/capabilities/order-search.capability.ts} +4 -4
- package/{providers/commercetools/src/providers/order.provider.ts → packages/commercetools/src/capabilities/order.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/price.provider.ts → packages/commercetools/src/capabilities/price.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/product-associations.provider.ts → packages/commercetools/src/capabilities/product-associations.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/product-list.provider.ts → packages/commercetools/src/capabilities/product-list.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/product-reviews.provider.ts → packages/commercetools/src/capabilities/product-reviews.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/product-search.provider.ts → packages/commercetools/src/capabilities/product-search.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/product.provider.ts → packages/commercetools/src/capabilities/product.capability.ts} +4 -4
- package/{providers/commercetools/src/providers/profile.provider.ts → packages/commercetools/src/capabilities/profile.capability.ts} +3 -3
- package/{providers/commercetools/src/providers/store.provider.ts → packages/commercetools/src/capabilities/store.capability.ts} +3 -3
- package/{providers → packages}/commercetools/src/core/capability-descriptors.ts +48 -48
- package/{providers → packages}/commercetools/src/core/client.ts +2 -2
- package/{providers → packages}/commercetools/src/core/initialize.ts +5 -5
- package/{providers → packages}/commercetools/src/core/initialize.types.ts +47 -47
- package/{providers → packages}/commercetools/src/factories/checkout/checkout-initializer-overrides.example.ts +4 -4
- package/{providers/commercetools/src/factories/product/product-provider-custom-method-only.example.ts → packages/commercetools/src/factories/product/product-capability-custom-method-only.example.ts} +6 -6
- package/{providers/commercetools/src/factories/product/product-provider-schema-signature-extension.example.ts → packages/commercetools/src/factories/product/product-capability-schema-signature-extension.example.ts} +4 -4
- package/{providers → packages}/commercetools/src/index.ts +9 -9
- package/{providers → packages}/commercetools/src/schema/capabilities.schema.ts +61 -61
- package/{providers → packages}/commercetools/src/test/caching.spec.ts +8 -8
- 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} +3 -3
- package/{core/src/providers/category.provider.ts → packages/core/src/capabilities/category.capability.ts} +5 -5
- package/{core/src/providers/checkout.provider.ts → packages/core/src/capabilities/checkout.capability.ts} +3 -3
- package/{core/src/providers/identity.provider.ts → packages/core/src/capabilities/identity.capability.ts} +2 -2
- package/packages/core/src/capabilities/index.ts +18 -0
- package/{core/src/providers/inventory.provider.ts → packages/core/src/capabilities/inventory.capability.ts} +2 -2
- package/{core/src/providers/order-search.provider.ts → packages/core/src/capabilities/order-search.capability.ts} +3 -3
- package/{core/src/providers/order.provider.ts → packages/core/src/capabilities/order.capability.ts} +2 -2
- package/{core/src/providers/price.provider.ts → packages/core/src/capabilities/price.capability.ts} +2 -2
- package/{core/src/providers/product-associations.provider.ts → packages/core/src/capabilities/product-associations.capability.ts} +3 -3
- package/{core/src/providers/product-list.provider.ts → packages/core/src/capabilities/product-list.capability.ts} +3 -3
- 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} +3 -3
- package/{core/src/providers/product-search.provider.ts → packages/core/src/capabilities/product-search.capability.ts} +3 -3
- package/{core/src/providers/product.provider.ts → packages/core/src/capabilities/product.capability.ts} +2 -2
- package/{core/src/providers/profile.provider.ts → packages/core/src/capabilities/profile.capability.ts} +2 -2
- package/{core/src/providers/store.provider.ts → packages/core/src/capabilities/store.capability.ts} +2 -2
- package/{core → packages/core}/src/client/client-builder.ts +13 -14
- package/packages/core/src/client/client.ts +35 -0
- package/{core → packages/core}/src/decorators/reactionary.decorator.ts +7 -7
- package/{core → packages/core}/src/index.ts +1 -1
- package/{core → packages/core}/src/test/client-builder.spec.ts +20 -20
- 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} +3 -3
- package/{providers/fake/src/providers/category.provider.ts → packages/fake/src/capabilities/category.capability.ts} +3 -3
- package/{providers/fake/src/providers/checkout.provider.ts → packages/fake/src/capabilities/checkout.capability.ts} +3 -3
- package/{providers/fake/src/providers/identity.provider.ts → packages/fake/src/capabilities/identity.capability.ts} +3 -3
- package/packages/fake/src/capabilities/index.ts +15 -0
- package/{providers/fake/src/providers/inventory.provider.ts → packages/fake/src/capabilities/inventory.capability.ts} +3 -3
- package/{providers/fake/src/providers/order-search.provider.ts → packages/fake/src/capabilities/order-search.capability.ts} +3 -3
- package/{providers/fake/src/providers/order.provider.ts → packages/fake/src/capabilities/order.capability.ts} +3 -3
- package/{providers/fake/src/providers/price.provider.ts → packages/fake/src/capabilities/price.capability.ts} +3 -3
- package/{providers/fake/src/providers/product-associations.provider.ts → packages/fake/src/capabilities/product-associations.capability.ts} +3 -3
- package/{providers/fake/src/providers/product-reviews.provider.ts → packages/fake/src/capabilities/product-reviews.capability.ts} +3 -3
- package/{providers/fake/src/providers/product-search.provider.ts → packages/fake/src/capabilities/product-search.capability.ts} +3 -3
- package/{providers/fake/src/providers/product.provider.ts → packages/fake/src/capabilities/product.capability.ts} +3 -3
- package/{providers/fake/src/providers/profile.provider.ts → packages/fake/src/capabilities/profile.capability.ts} +3 -3
- package/{providers/fake/src/providers/store.provider.ts → packages/fake/src/capabilities/store.capability.ts} +3 -3
- package/{providers → packages}/fake/src/core/initialize.ts +73 -73
- package/{providers → packages}/fake/src/core/initialize.types.ts +45 -45
- package/{providers → packages}/fake/src/index.ts +1 -1
- package/{providers → packages}/fake/src/schema/capabilities.schema.ts +32 -32
- package/{providers/fake/src/test/cart.provider.spec.ts → packages/fake/src/test/cart.capability.spec.ts} +6 -6
- package/{providers/fake/src/test/category.provider.spec.ts → packages/fake/src/test/category.capability.spec.ts} +3 -3
- package/{providers/fake/src/test/checkout.provider.spec.ts → packages/fake/src/test/checkout.capability.spec.ts} +3 -3
- package/{providers/fake/src/test/order-search.provider.spec.ts → packages/fake/src/test/order-search.capability.spec.ts} +3 -3
- package/{providers/fake/src/test/order.provider.spec.ts → packages/fake/src/test/order.capability.spec.ts} +3 -3
- package/{providers/fake/src/test/price.provider.spec.ts → packages/fake/src/test/price.capability.spec.ts} +3 -3
- package/{providers/fake/src/test/product.provider.spec.ts → packages/fake/src/test/product.capability.spec.ts} +3 -3
- package/{providers/fake/src/test/profile.provider.spec.ts → packages/fake/src/test/profile.capability.spec.ts} +3 -3
- 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/{providers → packages}/google-analytics/src/core/initialize.ts +4 -4
- package/packages/google-analytics/src/core/initialize.types.ts +47 -0
- package/{providers → packages}/google-analytics/src/index.ts +1 -1
- package/{providers → packages}/google-analytics/src/schema/capabilities.schema.ts +7 -7
- 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} +3 -3
- package/{providers/medusa/src/providers/category.provider.ts → packages/medusa/src/capabilities/category.capability.ts} +3 -3
- package/{providers/medusa/src/providers/checkout.provider.ts → packages/medusa/src/capabilities/checkout.capability.ts} +3 -3
- package/{providers/medusa/src/providers/identity.provider.ts → packages/medusa/src/capabilities/identity.capability.ts} +2 -2
- package/{providers/medusa/src/providers/inventory.provider.ts → packages/medusa/src/capabilities/inventory.capability.ts} +3 -3
- package/{providers/medusa/src/providers/order-search.provider.ts → packages/medusa/src/capabilities/order-search.capability.ts} +3 -3
- package/{providers/medusa/src/providers/order.provider.ts → packages/medusa/src/capabilities/order.capability.ts} +3 -3
- package/{providers/medusa/src/providers/price.provider.ts → packages/medusa/src/capabilities/price.capability.ts} +3 -3
- package/{providers/medusa/src/providers/product-associations.provider.ts → packages/medusa/src/capabilities/product-associations.capability.ts} +3 -3
- 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} +3 -3
- package/{providers/medusa/src/providers/product.provider.ts → packages/medusa/src/capabilities/product.capability.ts} +3 -3
- package/{providers/medusa/src/providers/profile.provider.ts → packages/medusa/src/capabilities/profile.capability.ts} +4 -4
- package/{providers → packages}/medusa/src/core/initialize.ts +64 -64
- package/{providers → packages}/medusa/src/core/initialize.types.ts +52 -52
- package/packages/medusa/src/index.ts +17 -0
- package/{providers → packages}/medusa/src/schema/capabilities.schema.ts +64 -64
- package/{providers/medusa/src/test/cart.provider.spec.ts → packages/medusa/src/test/cart.capability.spec.ts} +3 -3
- package/{providers/medusa/src/test/category.provider.spec.ts → packages/medusa/src/test/category.capability.spec.ts} +3 -3
- 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} +3 -3
- package/{providers/medusa/src/test/large-cart.provider.spec.ts → packages/medusa/src/test/large-cart.capability.spec.ts} +6 -6
- package/{providers/medusa/src/test/price.provider.spec.ts → packages/medusa/src/test/price.capability.spec.ts} +3 -3
- package/{providers/medusa/src/test/product.provider.spec.ts → packages/medusa/src/test/product.capability.spec.ts} +3 -3
- package/{providers/medusa/src/test/search.provider.spec.ts → packages/medusa/src/test/search.capability.spec.ts} +4 -4
- 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} +3 -3
- 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} +3 -3
- package/{providers → packages}/meilisearch/src/core/initialize.ts +13 -13
- package/{providers → packages}/meilisearch/src/core/initialize.types.ts +37 -37
- package/{providers → packages}/meilisearch/src/index.ts +3 -3
- package/{providers → packages}/meilisearch/src/schema/capabilities.schema.ts +24 -24
- 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.ts +0 -35
- package/core/src/providers/index.ts +0 -18
- 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.types.ts +0 -107
- package/providers/algolia/src/providers/index.ts +0 -3
- 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/providers/index.ts +0 -15
- 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/providers/index.ts +0 -15
- 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.types.ts +0 -47
- 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/index.ts +0 -17
- 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/providers/index.ts +0 -3
- 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/factories/index.ts +0 -0
- /package/{providers → packages}/algolia/src/factories/product-search/product-search.factory.ts +0 -0
- /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 → packages}/algolia/src/test/client-builder-product-search-extension.example.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/factories/cart/cart.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/category/category.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/checkout/checkout.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/identity/identity.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/inventory/inventory.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/order/order.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/order-search/order-search.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/price/price.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product/product-factory-baseline.example.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product/product-factory-schema-and-parse-extension.example.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product/product-factory-schema-extension.example.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product/product-initializer-factory-extension.example.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product/product.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product/utils.example.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product-associations/product-associations.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product-list/product-list.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product-reviews/product-reviews.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/product-search/product-search.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/profile/profile.factory.ts +0 -0
- /package/{providers → packages}/commercetools/src/factories/store/store.factory.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/client-builder-merge-extensions.example.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/factories/cart.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/category.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/checkout.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/identity.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/index.ts +0 -0
- /package/{core → packages/core}/src/factories/inventory.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/order-search.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/order.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/price.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/product-associations.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/product-list.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/product-reviews.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/product-search.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/product.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/profile.factory.ts +0 -0
- /package/{core → packages/core}/src/factories/store.factory.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/factories/cart/cart.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/category/category.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/checkout/checkout.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/identity/identity.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/index.ts +0 -0
- /package/{providers → packages}/fake/src/factories/inventory/inventory.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/order/order.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/order-search/order-search.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/price/price.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/product/product.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/product-associations/product-associations.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/product-reviews/product-reviews.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/product-search/product-search.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/profile/profile.factory.ts +0 -0
- /package/{providers → packages}/fake/src/factories/store/store.factory.ts +0 -0
- /package/{providers → packages}/fake/src/schema/configuration.schema.ts +0 -0
- /package/{providers → packages}/fake/src/test/client-builder-product-extension.example.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/factories/cart/cart.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/category/category.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/checkout/checkout.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/identity/identity.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/index.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/inventory/inventory.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/order/order.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/order-search/order-search.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/price/price.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/product/product.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/product-associations/product-associations.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/product-search/product-search.factory.ts +0 -0
- /package/{providers → packages}/medusa/src/factories/profile/profile.factory.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/checkout.spec.ts +0 -0
- /package/{providers → packages}/medusa/src/test/test-utils.ts +0 -0
- /package/{providers → packages}/meilisearch/src/factories/index.ts +0 -0
- /package/{providers → packages}/meilisearch/src/factories/order-search/order-search.factory.ts +0 -0
- /package/{providers → packages}/meilisearch/src/factories/product-search/product-search.factory.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,18 @@
|
|
|
1
|
+
export * from './analytics.capability.js';
|
|
2
|
+
export * from './base.capability.js';
|
|
3
|
+
export * from './cart.capability.js';
|
|
4
|
+
export * from './category.capability.js';
|
|
5
|
+
export * from './checkout.capability.js';
|
|
6
|
+
export * from './identity.capability.js';
|
|
7
|
+
export * from './inventory.capability.js';
|
|
8
|
+
export * from './price.capability.js';
|
|
9
|
+
export * from './product.capability.js';
|
|
10
|
+
export * from './profile.capability.js';
|
|
11
|
+
export * from './product-search.capability.js';
|
|
12
|
+
export * from './product-recommendations.capability.js';
|
|
13
|
+
export * from './product-associations.capability.js';
|
|
14
|
+
export * from './product-reviews.capability.js';
|
|
15
|
+
export * from './product-list.capability.js'
|
|
16
|
+
export * from './store.capability.js';
|
|
17
|
+
export * from './order.capability.js'
|
|
18
|
+
export * from './order-search.capability.js'
|
|
@@ -3,9 +3,9 @@ import type { InventoryIdentifier } from '../schemas/models/identifiers.model.js
|
|
|
3
3
|
import type { Inventory } from '../schemas/models/inventory.model.js';
|
|
4
4
|
import type { InventoryQueryBySKU } from '../schemas/queries/inventory.query.js';
|
|
5
5
|
import type { Result } from '../schemas/result.js';
|
|
6
|
-
import {
|
|
6
|
+
import { BaseCapability } from './base.capability.js';
|
|
7
7
|
|
|
8
|
-
export abstract class
|
|
8
|
+
export abstract class InventoryCapability<TInventory extends Inventory = Inventory> extends BaseCapability {
|
|
9
9
|
public abstract getBySKU(payload: InventoryQueryBySKU): Promise<Result<TInventory, NotFoundError>>;
|
|
10
10
|
|
|
11
11
|
protected override getResourceName(): string {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OrderSearchResult } from "../schemas/models/order-search.model.js";
|
|
2
2
|
import type { OrderSearchQueryByTerm } from "../schemas/queries/order-search.query.js";
|
|
3
3
|
import type { Result } from "../schemas/result.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BaseCapability } from "./base.capability.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* This provider handles order search operations. In some situations you may have different providers for order history listing and detail retrieval.
|
|
@@ -9,9 +9,9 @@ import { BaseProvider } from "./base.provider.js";
|
|
|
9
9
|
*
|
|
10
10
|
* Usecase: An e-commerce platform wants to provide customers with a way to search through their past orders using filters like date range, order status, or total amount spent.
|
|
11
11
|
*/
|
|
12
|
-
export abstract class
|
|
12
|
+
export abstract class OrderSearchCapability<
|
|
13
13
|
TOrderSearchResult extends OrderSearchResult = OrderSearchResult,
|
|
14
|
-
> extends
|
|
14
|
+
> extends BaseCapability {
|
|
15
15
|
protected override getResourceName(): string {
|
|
16
16
|
return 'order-search';
|
|
17
17
|
}
|
package/{core/src/providers/order.provider.ts → packages/core/src/capabilities/order.capability.ts}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseCapability } from './base.capability.js';
|
|
2
2
|
import type { Order } from '../schemas/models/index.js';
|
|
3
3
|
import type { OrderQueryById } from '../schemas/queries/index.js';
|
|
4
4
|
import type { Result } from '../schemas/result.js';
|
|
5
5
|
import type { NotFoundError } from '../schemas/index.js';
|
|
6
6
|
|
|
7
|
-
export abstract class
|
|
7
|
+
export abstract class OrderCapability<TOrder extends Order = Order> extends BaseCapability {
|
|
8
8
|
/**
|
|
9
9
|
* Get order by ID.
|
|
10
10
|
*
|
package/{core/src/providers/price.provider.ts → packages/core/src/capabilities/price.capability.ts}
RENAMED
|
@@ -3,9 +3,9 @@ import type {
|
|
|
3
3
|
CustomerPriceQuery,
|
|
4
4
|
ListPriceQuery,
|
|
5
5
|
} from '../schemas/queries/price.query.js';
|
|
6
|
-
import {
|
|
6
|
+
import { BaseCapability } from './base.capability.js';
|
|
7
7
|
|
|
8
|
-
export abstract class
|
|
8
|
+
export abstract class PriceCapability<TPrice extends Price = Price> extends BaseCapability {
|
|
9
9
|
/**
|
|
10
10
|
* Get a list price price by SKU. This is the most general, undiscounted price and is typically
|
|
11
11
|
* used as the "before" price in most ecommerce setups.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProductIdentifier, ProductVariantIdentifier } from "../schemas/index.js";
|
|
2
2
|
import type { ProductAssociationsGetAccessoriesQuery, ProductAssociationsGetSparepartsQuery, ProductAssociationsGetReplacementsQuery } from "../schemas/queries/product-associations.query.js";
|
|
3
|
-
import {
|
|
3
|
+
import { BaseCapability } from "./base.capability.js";
|
|
4
4
|
import type { Result } from '../schemas/result.js';
|
|
5
5
|
import type { ProductAssociation } from '../schemas/models/product-associations.model.js';
|
|
6
6
|
|
|
@@ -9,9 +9,9 @@ import type { ProductAssociation } from '../schemas/models/product-associations.
|
|
|
9
9
|
* accessories, spareparts, and replacements. These associations are typically used to provide recommendations to customers on the product detail page, but can also be used in other contexts such as the cart or post-purchase, but
|
|
10
10
|
* do not carry any personalization concept to them.
|
|
11
11
|
*/
|
|
12
|
-
export abstract class
|
|
12
|
+
export abstract class ProductAssociationsCapability<
|
|
13
13
|
TProductAssociation extends ProductAssociation = ProductAssociation,
|
|
14
|
-
> extends
|
|
14
|
+
> extends BaseCapability {
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Returns a list of product identifiers which are accessories to the given product.
|
|
@@ -3,7 +3,7 @@ import type { ProductListItemMutationCreate, ProductListItemMutationDelete, Prod
|
|
|
3
3
|
import type { ProductListQuery, ProductListQueryById } from "../schemas/queries/product-list.query.js";
|
|
4
4
|
import { type ProductListItemsQuery } from "../schemas/queries/product-list.query.js";
|
|
5
5
|
import type { Result } from "../schemas/result.js";
|
|
6
|
-
import {
|
|
6
|
+
import { BaseCapability } from "./base.capability.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The product list provider is a general purpose provider for creating various types of product lists, such as favorite lists, projects, wishlists, requisitionlists, etc
|
|
@@ -13,12 +13,12 @@ import { BaseProvider } from "./base.provider.js";
|
|
|
13
13
|
*
|
|
14
14
|
* Some systems might only support single entries of each type, but the general case is to support multiples.
|
|
15
15
|
*/
|
|
16
|
-
export abstract class
|
|
16
|
+
export abstract class ProductListCapability<
|
|
17
17
|
TProductList extends ProductList = ProductList,
|
|
18
18
|
TProductListItem extends ProductListItem = ProductListItem,
|
|
19
19
|
TProductListPaginatedResult extends ProductListPaginatedResult = ProductListPaginatedResult,
|
|
20
20
|
TProductListItemPaginatedResult extends ProductListItemPaginatedResult = ProductListItemPaginatedResult,
|
|
21
|
-
> extends
|
|
21
|
+
> extends BaseCapability {
|
|
22
22
|
|
|
23
23
|
protected getResourceName(): string {
|
|
24
24
|
return 'product-lists';
|
|
@@ -2,12 +2,12 @@ import type { Cache } from '../cache/cache.interface.js';
|
|
|
2
2
|
import { Reactionary } from "../decorators/reactionary.decorator.js";
|
|
3
3
|
import { success, type ProductRecommendation, type ProductRecommendationsByCollectionQuery, type RequestContext, type Result } from "../schemas/index.js";
|
|
4
4
|
import { ProductRecommendationsQuerySchema, type ProductRecommendationAlgorithmAlsoViewedProductsQuery, type ProductRecommendationAlgorithmFrequentlyBoughtTogetherQuery, type ProductRecommendationAlgorithmPopuplarProductsQuery, type ProductRecommendationAlgorithmRelatedProductsQuery, type ProductRecommendationAlgorithmSimilarProductsQuery, type ProductRecommendationAlgorithmTopPicksProductsQuery, type ProductRecommendationAlgorithmTrendingInCategoryQuery, type ProductRecommendationsQuery } from "../schemas/queries/product-recommendations.query.js";
|
|
5
|
-
import {
|
|
5
|
+
import { BaseCapability } from "./base.capability.js";
|
|
6
6
|
|
|
7
|
-
export abstract class
|
|
7
|
+
export abstract class ProductRecommendationsCapability extends BaseCapability {
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* returns a list of recommended products, based on the selected algorithm and the provided query parameters. The recommendations should be relevant to the product specified in the query, and can be personalized based on the customer segments or contexts provided. The
|
|
10
|
+
* returns a list of recommended products, based on the selected algorithm and the provided query parameters. The recommendations should be relevant to the product specified in the query, and can be personalized based on the customer segments or contexts provided. The capability should return a list of product variant identifiers that are recommended for the given product, which can then be used to fetch the full product details from the product capability if needed.
|
|
11
11
|
* *
|
|
12
12
|
* Usecase:
|
|
13
13
|
* - PDP - "Customers who viewed this product also viewed"
|
|
@@ -89,17 +89,17 @@ export abstract class ProductRecommendationsProvider extends BaseProvider {
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
export class
|
|
93
|
-
protected
|
|
92
|
+
export class MulticastProductRecommendationsCapability extends ProductRecommendationsCapability {
|
|
93
|
+
protected capabilities: Array<ProductRecommendationsCapability>;
|
|
94
94
|
|
|
95
95
|
constructor(
|
|
96
96
|
cache: Cache,
|
|
97
97
|
requestContext: RequestContext,
|
|
98
|
-
|
|
98
|
+
capabilities: Array<ProductRecommendationsCapability>
|
|
99
99
|
) {
|
|
100
100
|
super(cache, requestContext);
|
|
101
101
|
|
|
102
|
-
this.
|
|
102
|
+
this.capabilities = capabilities;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
@Reactionary({
|
|
@@ -107,15 +107,15 @@ export class MulticastProductRecommendationsProvider extends ProductRecommendati
|
|
|
107
107
|
})
|
|
108
108
|
public override async getRecommendations(query: ProductRecommendationsQuery): Promise<Result<ProductRecommendation[]>> {
|
|
109
109
|
const output = [];
|
|
110
|
-
for (const
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
110
|
+
for (const capability of this.capabilities) {
|
|
111
|
+
const capabilityOutput = await capability.getRecommendations(query);
|
|
112
|
+
if (capabilityOutput.success) {
|
|
113
113
|
|
|
114
|
-
output.push(...
|
|
114
|
+
output.push(...capabilityOutput.value);
|
|
115
115
|
} else {
|
|
116
116
|
// For other types of errors, we might want to log them or handle them differently
|
|
117
|
-
console.error(`Error from
|
|
118
|
-
return
|
|
117
|
+
console.error(`Error from capability ${capability.constructor.name}:`, capabilityOutput.error);
|
|
118
|
+
return capabilityOutput
|
|
119
119
|
}
|
|
120
120
|
if (output.length >= query.numberOfRecommendations) {
|
|
121
121
|
break;
|
|
@@ -126,18 +126,18 @@ export class MulticastProductRecommendationsProvider extends ProductRecommendati
|
|
|
126
126
|
|
|
127
127
|
public override async getCollection(query: ProductRecommendationsByCollectionQuery): Promise<Result<ProductRecommendation[]>> {
|
|
128
128
|
const output = [];
|
|
129
|
-
for (const
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
output.push(...
|
|
129
|
+
for (const capability of this.capabilities) {
|
|
130
|
+
const capabilityOutput = await capability.getCollection(query);
|
|
131
|
+
if (capabilityOutput.success) {
|
|
132
|
+
output.push(...capabilityOutput.value);
|
|
133
133
|
} else {
|
|
134
|
-
if (
|
|
135
|
-
// If the error is a NotFound error, we can ignore it and continue to the next
|
|
134
|
+
if (capabilityOutput.error.type === 'NotFound') {
|
|
135
|
+
// If the error is a NotFound error, we can ignore it and continue to the next capability
|
|
136
136
|
continue;
|
|
137
137
|
} else {
|
|
138
138
|
// For other types of errors, we might want to log them or handle them differently
|
|
139
|
-
console.error(`Error from
|
|
140
|
-
return
|
|
139
|
+
console.error(`Error from capability ${capability.constructor.name}:`, capabilityOutput.error);
|
|
140
|
+
return capabilityOutput;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
if (output.length >= query.numberOfRecommendations) {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { Result, ProductReview, ProductRatingSummary, ProductReviewPaginatedResult } from '../schemas/index.js';
|
|
2
2
|
import type { ProductReviewsListQuery, ProductReviewsGetRatingSummaryQuery } from '../schemas/queries/product-reviews.query.js';
|
|
3
3
|
import type { ProductReviewMutationSubmit } from '../schemas/mutations/product-reviews.mutation.js';
|
|
4
|
-
import {
|
|
4
|
+
import { BaseCapability } from './base.capability.js';
|
|
5
5
|
import { type ProductRatingIdentifier } from '../schemas/models/identifiers.model.js';
|
|
6
6
|
/**
|
|
7
7
|
* The product reviews provider is responsible for providing detailed product reviews from customers.
|
|
8
8
|
* Reviews contain ratings along with textual feedback, author information, and verification status.
|
|
9
9
|
* This provider also handles aggregated rating summaries for products.
|
|
10
10
|
*/
|
|
11
|
-
export abstract class
|
|
11
|
+
export abstract class ProductReviewsCapability<
|
|
12
12
|
TProductRatingSummary extends ProductRatingSummary = ProductRatingSummary,
|
|
13
13
|
TProductReviewPaginatedResult extends ProductReviewPaginatedResult = ProductReviewPaginatedResult,
|
|
14
14
|
TProductReview extends ProductReview = ProductReview,
|
|
15
|
-
> extends
|
|
15
|
+
> extends BaseCapability {
|
|
16
16
|
/**
|
|
17
17
|
* Get the rating summary for a product, including average rating and distribution.
|
|
18
18
|
*
|
|
@@ -4,11 +4,11 @@ import type {
|
|
|
4
4
|
ProductSearchQueryByTerm,
|
|
5
5
|
ProductSearchQueryCreateNavigationFilter,
|
|
6
6
|
} from '../schemas/queries/product-search.query.js';
|
|
7
|
-
import {
|
|
7
|
+
import { BaseCapability } from './base.capability.js';
|
|
8
8
|
|
|
9
|
-
export abstract class
|
|
9
|
+
export abstract class ProductSearchCapability<
|
|
10
10
|
TProductSearchResult extends ProductSearchResult = ProductSearchResult,
|
|
11
|
-
> extends
|
|
11
|
+
> extends BaseCapability {
|
|
12
12
|
protected override getResourceName(): string {
|
|
13
13
|
return 'product-search';
|
|
14
14
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Product } from '../schemas/models/product.model.js';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseCapability } from './base.capability.js';
|
|
3
3
|
import type { ProductQueryById, ProductQueryBySKU, ProductQueryBySlug } from '../schemas/queries/product.query.js';
|
|
4
4
|
import type { Result } from '../schemas/result.js';
|
|
5
5
|
import type { NotFoundError } from '../schemas/index.js';
|
|
6
6
|
|
|
7
|
-
export abstract class
|
|
7
|
+
export abstract class ProductCapability<TProduct extends Product = Product> extends BaseCapability {
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -3,9 +3,9 @@ import type { Profile } from '../schemas/models/index.js';
|
|
|
3
3
|
import type { ProfileMutationAddShippingAddress, ProfileMutationMakeShippingAddressDefault, ProfileMutationRemoveShippingAddress, ProfileMutationSetBillingAddress, ProfileMutationUpdate, ProfileMutationUpdateShippingAddress } from '../schemas/mutations/index.js';
|
|
4
4
|
import type { ProfileQuerySelf as ProfileQueryById } from '../schemas/queries/index.js';
|
|
5
5
|
import type { Result } from '../schemas/result.js';
|
|
6
|
-
import {
|
|
6
|
+
import { BaseCapability } from './base.capability.js';
|
|
7
7
|
|
|
8
|
-
export abstract class
|
|
8
|
+
export abstract class ProfileCapability<TProfile extends Profile = Profile> extends BaseCapability {
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Returns the profile of the currently authenticated (registered) user.
|
package/{core/src/providers/store.provider.ts → packages/core/src/capabilities/store.capability.ts}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Store } from '../schemas/models/store.model.js';
|
|
2
2
|
import type { StoreQueryByProximity } from '../schemas/queries/index.js';
|
|
3
3
|
import type { Result } from '../schemas/result.js';
|
|
4
|
-
import {
|
|
4
|
+
import { BaseCapability } from './base.capability.js';
|
|
5
5
|
|
|
6
|
-
export abstract class
|
|
6
|
+
export abstract class StoreCapability<TStore extends Store = Store> extends BaseCapability {
|
|
7
7
|
public abstract queryByProximity(payload: StoreQueryByProximity): Promise<Result<Array<TStore>>>;
|
|
8
8
|
|
|
9
9
|
protected override getResourceName(): string {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Cache } from '../cache/cache.interface.js';
|
|
2
2
|
import { NoOpCache } from '../cache/noop-cache.js';
|
|
3
3
|
import type { Client } from './client.js';
|
|
4
|
-
import {
|
|
4
|
+
import { MulticastAnalyticsCapability, type AnalyticsCapability } from '../capabilities/analytics.capability.js';
|
|
5
5
|
import {
|
|
6
6
|
RequestContextSchema,
|
|
7
7
|
type RequestContext,
|
|
8
8
|
} from '../schemas/session.schema.js';
|
|
9
|
-
import {
|
|
9
|
+
import { MulticastProductRecommendationsCapability, type ProductRecommendationsCapability } from '../capabilities/product-recommendations.capability.js';
|
|
10
10
|
|
|
11
11
|
export interface ClientBuilderFactoryArgs {
|
|
12
12
|
cache: Cache;
|
|
@@ -71,28 +71,27 @@ export class ClientBuilder<TClient = Client> {
|
|
|
71
71
|
throw new Error('Invalid context: ' + validatedContext.error);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const mergedAnalytics:
|
|
75
|
-
|
|
76
|
-
const mergedProductRecommendationsProviders: ProductRecommendationsProvider[] = [];
|
|
74
|
+
const mergedAnalytics: AnalyticsCapability[] = [];
|
|
75
|
+
const mergedProductRecommendations: ProductRecommendationsCapability[] = [];
|
|
77
76
|
|
|
78
77
|
for (const factory of this.factories) {
|
|
79
|
-
const
|
|
80
|
-
client = this.
|
|
78
|
+
const capability = this.resolveFactory(factory, sharedCache, this.context);
|
|
79
|
+
client = this.mergeCapabilities(client, capability as Partial<TClient>);
|
|
81
80
|
|
|
82
|
-
if (
|
|
83
|
-
mergedAnalytics.push(
|
|
81
|
+
if (capability.analytics) {
|
|
82
|
+
mergedAnalytics.push(capability.analytics);
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
if (
|
|
87
|
-
|
|
85
|
+
if (capability.productRecommendations) {
|
|
86
|
+
mergedProductRecommendations.push(capability.productRecommendations);
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
// Add cache to complete the client
|
|
92
91
|
const completeClient = {
|
|
93
92
|
...client,
|
|
94
|
-
analytics: new
|
|
95
|
-
productRecommendations: new
|
|
93
|
+
analytics: new MulticastAnalyticsCapability(sharedCache, this.context, mergedAnalytics),
|
|
94
|
+
productRecommendations: new MulticastProductRecommendationsCapability(sharedCache, this.context, mergedProductRecommendations),
|
|
96
95
|
cache: sharedCache,
|
|
97
96
|
} as TClient & { cache: Cache };
|
|
98
97
|
|
|
@@ -110,7 +109,7 @@ export class ClientBuilder<TClient = Client> {
|
|
|
110
109
|
return (factory as (cache: Cache, context: RequestContext) => TNew)(cache, context);
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
private
|
|
112
|
+
private mergeCapabilities(
|
|
114
113
|
target: TClient,
|
|
115
114
|
source: Partial<TClient>,
|
|
116
115
|
): TClient {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ProductCapability } from "../capabilities/product.capability.js";
|
|
2
|
+
import type { ProductSearchCapability } from "../capabilities/product-search.capability.js";
|
|
3
|
+
import type { IdentityCapability } from '../capabilities/identity.capability.js';
|
|
4
|
+
import type { CartCapability } from "../capabilities/cart.capability.js";
|
|
5
|
+
import type { PriceCapability } from "../capabilities/price.capability.js";
|
|
6
|
+
import type { InventoryCapability } from "../capabilities/inventory.capability.js";
|
|
7
|
+
import type { Cache } from "../cache/cache.interface.js";
|
|
8
|
+
import type { CategoryCapability } from "../capabilities/category.capability.js";
|
|
9
|
+
import type { AnalyticsCapability, CheckoutCapability, OrderCapability, ProductListCapability, ProfileCapability, StoreCapability } from "../capabilities/index.js";
|
|
10
|
+
import type { OrderSearchCapability } from "../capabilities/order-search.capability.js";
|
|
11
|
+
import type { ProductRecommendationsCapability } from "../capabilities/product-recommendations.capability.js";
|
|
12
|
+
import type { ProductAssociationsCapability } from "../capabilities/product-associations.capability.js";
|
|
13
|
+
import type { ProductReviewsCapability } from "../capabilities/product-reviews.capability.js";
|
|
14
|
+
|
|
15
|
+
export interface Client {
|
|
16
|
+
product: ProductCapability,
|
|
17
|
+
productSearch: ProductSearchCapability,
|
|
18
|
+
productRecommendations: ProductRecommendationsCapability,
|
|
19
|
+
productAssociations: ProductAssociationsCapability,
|
|
20
|
+
productReviews: ProductReviewsCapability,
|
|
21
|
+
productList: ProductListCapability,
|
|
22
|
+
identity: IdentityCapability,
|
|
23
|
+
cache: Cache,
|
|
24
|
+
cart: CartCapability,
|
|
25
|
+
checkout: CheckoutCapability,
|
|
26
|
+
analytics: AnalyticsCapability,
|
|
27
|
+
price: PriceCapability,
|
|
28
|
+
inventory: InventoryCapability,
|
|
29
|
+
category: CategoryCapability,
|
|
30
|
+
profile: ProfileCapability,
|
|
31
|
+
store: StoreCapability,
|
|
32
|
+
order: OrderCapability,
|
|
33
|
+
orderSearch: OrderSearchCapability,
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Tracer } from '@opentelemetry/api';
|
|
2
2
|
import { SpanStatusCode, trace } from '@opentelemetry/api';
|
|
3
3
|
import * as z from 'zod';
|
|
4
|
-
import type {
|
|
4
|
+
import type { BaseCapability } from '../capabilities/index.js';
|
|
5
5
|
import { getReactionaryMeter } from '../metrics/metrics.js';
|
|
6
6
|
import { error, success, type Result } from '../schemas/result.js';
|
|
7
7
|
import type {
|
|
@@ -18,7 +18,7 @@ export function getTracer(): Tracer {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* The options associated with annotating a
|
|
21
|
+
* The options associated with annotating a capability function and marking
|
|
22
22
|
* it as a reactionary entrypoint to be called
|
|
23
23
|
*/
|
|
24
24
|
export class ReactionaryDecoratorOptions {
|
|
@@ -59,13 +59,13 @@ export class ReactionaryDecoratorOptions {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Decorator for
|
|
62
|
+
* Decorator for capability functions to provide functionality such as caching, tracing and type-checked
|
|
63
63
|
* assertion through Zod. It should only be used with publically accessible queries or mutations on
|
|
64
|
-
*
|
|
64
|
+
* capabilities.
|
|
65
65
|
*/
|
|
66
66
|
export function Reactionary(options: Partial<ReactionaryDecoratorOptions>) {
|
|
67
67
|
return function (
|
|
68
|
-
target:
|
|
68
|
+
target: BaseCapability,
|
|
69
69
|
propertyKey: string | symbol,
|
|
70
70
|
descriptor: PropertyDescriptor
|
|
71
71
|
): PropertyDescriptor {
|
|
@@ -82,11 +82,11 @@ export function Reactionary(options: Partial<ReactionaryDecoratorOptions>) {
|
|
|
82
82
|
|
|
83
83
|
if (!original) {
|
|
84
84
|
throw new Error(
|
|
85
|
-
'@Reactionary decorator may only be applied to methods on classes extending
|
|
85
|
+
'@Reactionary decorator may only be applied to methods on classes extending BaseCapability.'
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
descriptor.value = async function (this:
|
|
89
|
+
descriptor.value = async function (this: BaseCapability, ...args: any[]) {
|
|
90
90
|
return traceSpan(scope, async () => {
|
|
91
91
|
meter.requestInProgress.add(1, attributes);
|
|
92
92
|
try {
|
|
@@ -2,7 +2,7 @@ export * from './cache/index.js';
|
|
|
2
2
|
export * from './client/index.js';
|
|
3
3
|
export * from './decorators/index.js';
|
|
4
4
|
export * from './factories/index.js';
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './capabilities/index.js';
|
|
6
6
|
export * from './schemas/index.js';
|
|
7
7
|
export * from './initialization.js';
|
|
8
8
|
export type { InferType } from './zod-utils.js';
|
|
@@ -2,15 +2,15 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import type { Capabilities, ClientFromCapabilities } from "../schemas/capabilities.schema.js";
|
|
3
3
|
import type { Cache } from '../cache/cache.interface.js';
|
|
4
4
|
import type { RequestContext } from "../schemas/session.schema.js";
|
|
5
|
-
import {
|
|
5
|
+
import { AnalyticsCapability } from "../capabilities/analytics.capability.js";
|
|
6
6
|
import type { AnalyticsMutation } from "../schemas/index.js";
|
|
7
7
|
import { NoOpCache } from "../cache/noop-cache.js";
|
|
8
8
|
import { createInitialRequestContext } from "../initialization.js";
|
|
9
9
|
import { ClientBuilder } from "../client/client-builder.js";
|
|
10
10
|
import type { Client } from "../client/client.js";
|
|
11
|
-
import {
|
|
11
|
+
import { ProductCapability } from "../capabilities/product.capability.js";
|
|
12
12
|
|
|
13
|
-
export class
|
|
13
|
+
export class MockAnalyticsCapability extends AnalyticsCapability {
|
|
14
14
|
public events: Array<AnalyticsMutation> = [];
|
|
15
15
|
|
|
16
16
|
public override async track(event: AnalyticsMutation): Promise<void> {
|
|
@@ -38,12 +38,12 @@ describe('Client Builder', () => {
|
|
|
38
38
|
const cache = new NoOpCache();
|
|
39
39
|
const context = createInitialRequestContext();
|
|
40
40
|
const builder = new ClientBuilder(context);
|
|
41
|
-
const
|
|
42
|
-
const
|
|
41
|
+
const analyticsCapability = new MockAnalyticsCapability(cache, context);
|
|
42
|
+
const secondaryAnalyticsCapability = new MockAnalyticsCapability(cache, context);
|
|
43
43
|
const client = builder
|
|
44
44
|
.withCache(cache)
|
|
45
|
-
.withCapability(withMockCapabilities({ analytics:
|
|
46
|
-
.withCapability(withMockCapabilities({ analytics:
|
|
45
|
+
.withCapability(withMockCapabilities({ analytics: analyticsCapability }))
|
|
46
|
+
.withCapability(withMockCapabilities({ analytics: secondaryAnalyticsCapability }))
|
|
47
47
|
.build();
|
|
48
48
|
|
|
49
49
|
const track = await client.analytics.track({
|
|
@@ -53,24 +53,24 @@ describe('Client Builder', () => {
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
expect(
|
|
57
|
-
expect(
|
|
58
|
-
expect(
|
|
59
|
-
expect(
|
|
56
|
+
expect(analyticsCapability.events.length).toBe(1);
|
|
57
|
+
expect(analyticsCapability.events[0].event).toBe('product-details-view');
|
|
58
|
+
expect(secondaryAnalyticsCapability.events.length).toBe(1);
|
|
59
|
+
expect(secondaryAnalyticsCapability.events[0].event).toBe('product-details-view');
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it('supports capability factories with args object signature', () => {
|
|
63
63
|
const cache = new NoOpCache();
|
|
64
64
|
const context = createInitialRequestContext();
|
|
65
65
|
const builder = new ClientBuilder(context);
|
|
66
|
-
const
|
|
66
|
+
const analyticsCapability = new MockAnalyticsCapability(cache, context);
|
|
67
67
|
|
|
68
68
|
const client = builder
|
|
69
69
|
.withCache(cache)
|
|
70
70
|
.withCapability(({ cache: sharedCache, context: sharedContext }) => {
|
|
71
71
|
expect(sharedCache).toBe(cache);
|
|
72
72
|
expect(sharedContext).toBe(context);
|
|
73
|
-
return { analytics:
|
|
73
|
+
return { analytics: analyticsCapability };
|
|
74
74
|
})
|
|
75
75
|
.build();
|
|
76
76
|
|
|
@@ -82,7 +82,7 @@ describe('Client Builder', () => {
|
|
|
82
82
|
const context = createInitialRequestContext();
|
|
83
83
|
const builder = new ClientBuilder(context);
|
|
84
84
|
|
|
85
|
-
class
|
|
85
|
+
class TestProductCapability extends ProductCapability {
|
|
86
86
|
public override async getById(): Promise<any> {
|
|
87
87
|
throw new Error('not implemented');
|
|
88
88
|
}
|
|
@@ -98,8 +98,8 @@ describe('Client Builder', () => {
|
|
|
98
98
|
builder
|
|
99
99
|
.withCache(cache)
|
|
100
100
|
.withCollisionStrategy('throw')
|
|
101
|
-
.withCapability(() => ({ product: new
|
|
102
|
-
.withCapability(() => ({ product: new
|
|
101
|
+
.withCapability(() => ({ product: new TestProductCapability(cache, context) }))
|
|
102
|
+
.withCapability(() => ({ product: new TestProductCapability(cache, context) }))
|
|
103
103
|
.build(),
|
|
104
104
|
).toThrow(/Capability collision detected for "product"/);
|
|
105
105
|
});
|
|
@@ -109,7 +109,7 @@ describe('Client Builder', () => {
|
|
|
109
109
|
const context = createInitialRequestContext();
|
|
110
110
|
const builder = new ClientBuilder(context);
|
|
111
111
|
|
|
112
|
-
class
|
|
112
|
+
class TestProductCapability extends ProductCapability {
|
|
113
113
|
public name: string;
|
|
114
114
|
constructor(cache: Cache, context: RequestContext, name: string) {
|
|
115
115
|
super(cache, context);
|
|
@@ -126,8 +126,8 @@ describe('Client Builder', () => {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
const first = new
|
|
130
|
-
const second = new
|
|
129
|
+
const first = new TestProductCapability(cache, context, 'first');
|
|
130
|
+
const second = new TestProductCapability(cache, context, 'second');
|
|
131
131
|
|
|
132
132
|
const client = builder
|
|
133
133
|
.withCache(cache)
|
|
@@ -136,6 +136,6 @@ describe('Client Builder', () => {
|
|
|
136
136
|
.withCapability(() => ({ product: second }))
|
|
137
137
|
.build();
|
|
138
138
|
|
|
139
|
-
expect((client.product as
|
|
139
|
+
expect((client.product as TestProductCapability).name).toBe('first');
|
|
140
140
|
});
|
|
141
141
|
});
|