@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,58 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type {
|
|
3
|
+
ProductRatingSummarySchema,
|
|
4
|
+
ProductReviewPaginatedResultSchema,
|
|
5
|
+
ProductReviewSchema,
|
|
6
|
+
} from '../schemas/models/product-reviews.model.js';
|
|
7
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
8
|
+
|
|
9
|
+
export type AnyProductRatingSummarySchema = z.ZodType<
|
|
10
|
+
z.output<typeof ProductRatingSummarySchema>
|
|
11
|
+
>;
|
|
12
|
+
export type AnyProductReviewSchema = z.ZodType<z.output<typeof ProductReviewSchema>>;
|
|
13
|
+
export type AnyProductReviewPaginatedSchema = z.ZodType<
|
|
14
|
+
z.output<typeof ProductReviewPaginatedResultSchema>
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
export interface ProductReviewsFactory<
|
|
18
|
+
TRatingSummarySchema extends AnyProductRatingSummarySchema = AnyProductRatingSummarySchema,
|
|
19
|
+
TReviewSchema extends AnyProductReviewSchema = AnyProductReviewSchema,
|
|
20
|
+
TReviewPaginatedSchema extends AnyProductReviewPaginatedSchema = AnyProductReviewPaginatedSchema,
|
|
21
|
+
> {
|
|
22
|
+
ratingSummarySchema: TRatingSummarySchema;
|
|
23
|
+
reviewSchema: TReviewSchema;
|
|
24
|
+
reviewPaginatedSchema: TReviewPaginatedSchema;
|
|
25
|
+
parseRatingSummary(
|
|
26
|
+
context: RequestContext,
|
|
27
|
+
data: unknown,
|
|
28
|
+
): z.output<TRatingSummarySchema>;
|
|
29
|
+
parseReview(context: RequestContext, data: unknown): z.output<TReviewSchema>;
|
|
30
|
+
parseReviewPaginatedResult(
|
|
31
|
+
context: RequestContext,
|
|
32
|
+
data: unknown,
|
|
33
|
+
): z.output<TReviewPaginatedSchema>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ProductReviewsFactoryRatingOutput<TFactory extends ProductReviewsFactory> =
|
|
37
|
+
ReturnType<TFactory['parseRatingSummary']>;
|
|
38
|
+
export type ProductReviewsFactoryReviewOutput<TFactory extends ProductReviewsFactory> =
|
|
39
|
+
ReturnType<TFactory['parseReview']>;
|
|
40
|
+
export type ProductReviewsFactoryReviewPaginatedOutput<
|
|
41
|
+
TFactory extends ProductReviewsFactory,
|
|
42
|
+
> = ReturnType<TFactory['parseReviewPaginatedResult']>;
|
|
43
|
+
|
|
44
|
+
export type ProductReviewsFactoryWithOutput<TFactory extends ProductReviewsFactory> =
|
|
45
|
+
Omit<TFactory, 'parseRatingSummary' | 'parseReview' | 'parseReviewPaginatedResult'> & {
|
|
46
|
+
parseRatingSummary(
|
|
47
|
+
context: RequestContext,
|
|
48
|
+
data: unknown,
|
|
49
|
+
): ProductReviewsFactoryRatingOutput<TFactory>;
|
|
50
|
+
parseReview(
|
|
51
|
+
context: RequestContext,
|
|
52
|
+
data: unknown,
|
|
53
|
+
): ProductReviewsFactoryReviewOutput<TFactory>;
|
|
54
|
+
parseReviewPaginatedResult(
|
|
55
|
+
context: RequestContext,
|
|
56
|
+
data: unknown,
|
|
57
|
+
): ProductReviewsFactoryReviewPaginatedOutput<TFactory>;
|
|
58
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { ProductSearchResultSchema } from '../schemas/models/product-search.model.js';
|
|
3
|
+
import type { ProductSearchQueryByTerm } from '../schemas/queries/product-search.query.js';
|
|
4
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
5
|
+
|
|
6
|
+
export type AnyProductSearchResultSchema = z.ZodType<
|
|
7
|
+
z.output<typeof ProductSearchResultSchema>
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export interface ProductSearchFactory<
|
|
11
|
+
TProductSearchResultSchema extends AnyProductSearchResultSchema = AnyProductSearchResultSchema,
|
|
12
|
+
> {
|
|
13
|
+
productSearchResultSchema: TProductSearchResultSchema;
|
|
14
|
+
parseSearchResult(
|
|
15
|
+
context: RequestContext,
|
|
16
|
+
data: unknown,
|
|
17
|
+
query: ProductSearchQueryByTerm,
|
|
18
|
+
): z.output<TProductSearchResultSchema>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ProductSearchFactoryOutput<TFactory extends ProductSearchFactory> =
|
|
22
|
+
ReturnType<TFactory['parseSearchResult']>;
|
|
23
|
+
|
|
24
|
+
export type ProductSearchFactoryWithOutput<TFactory extends ProductSearchFactory> =
|
|
25
|
+
Omit<TFactory, 'parseSearchResult'> & {
|
|
26
|
+
parseSearchResult(
|
|
27
|
+
context: RequestContext,
|
|
28
|
+
data: unknown,
|
|
29
|
+
query: ProductSearchQueryByTerm,
|
|
30
|
+
): ProductSearchFactoryOutput<TFactory>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { ProductSchema } from '../schemas/models/product.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyProductSchema = z.ZodType<z.output<typeof ProductSchema>>;
|
|
6
|
+
|
|
7
|
+
export interface ProductFactory<TProductSchema extends AnyProductSchema = AnyProductSchema> {
|
|
8
|
+
productSchema: TProductSchema;
|
|
9
|
+
parseProduct(context: RequestContext, data: unknown): z.output<TProductSchema>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type ProductFactoryOutput<TFactory extends ProductFactory> = ReturnType<
|
|
13
|
+
TFactory['parseProduct']
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type ProductFactoryWithOutput<TFactory extends ProductFactory> = Omit<
|
|
17
|
+
TFactory,
|
|
18
|
+
'parseProduct'
|
|
19
|
+
> & {
|
|
20
|
+
parseProduct(context: RequestContext, data: unknown): ProductFactoryOutput<TFactory>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { ProfileSchema } from '../schemas/models/profile.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyProfileSchema = z.ZodType<z.output<typeof ProfileSchema>>;
|
|
6
|
+
|
|
7
|
+
export interface ProfileFactory<
|
|
8
|
+
TProfileSchema extends AnyProfileSchema = AnyProfileSchema,
|
|
9
|
+
> {
|
|
10
|
+
profileSchema: TProfileSchema;
|
|
11
|
+
parseProfile(context: RequestContext, data: unknown): z.output<TProfileSchema>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ProfileFactoryOutput<TFactory extends ProfileFactory> = ReturnType<
|
|
15
|
+
TFactory['parseProfile']
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
export type ProfileFactoryWithOutput<TFactory extends ProfileFactory> = Omit<
|
|
19
|
+
TFactory,
|
|
20
|
+
'parseProfile'
|
|
21
|
+
> & {
|
|
22
|
+
parseProfile(context: RequestContext, data: unknown): ProfileFactoryOutput<TFactory>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { StoreSchema } from '../schemas/models/store.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyStoreSchema = z.ZodType<z.output<typeof StoreSchema>>;
|
|
6
|
+
|
|
7
|
+
export interface StoreFactory<TStoreSchema extends AnyStoreSchema = AnyStoreSchema> {
|
|
8
|
+
storeSchema: TStoreSchema;
|
|
9
|
+
parseStore(context: RequestContext, data: unknown): z.output<TStoreSchema>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type StoreFactoryOutput<TFactory extends StoreFactory> = ReturnType<
|
|
13
|
+
TFactory['parseStore']
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type StoreFactoryWithOutput<TFactory extends StoreFactory> = Omit<
|
|
17
|
+
TFactory,
|
|
18
|
+
'parseStore'
|
|
19
|
+
> & {
|
|
20
|
+
parseStore(context: RequestContext, data: unknown): StoreFactoryOutput<TFactory>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './cache/index.js';
|
|
2
|
+
export * from './client/index.js';
|
|
3
|
+
export * from './decorators/index.js';
|
|
4
|
+
export * from './factories/index.js';
|
|
5
|
+
export * from './capabilities/index.js';
|
|
6
|
+
export * from './schemas/index.js';
|
|
7
|
+
export * from './initialization.js';
|
|
8
|
+
export type { InferType } from './zod-utils.js';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { Capabilities, ClientFromCapabilities } from "../schemas/capabilities.schema.js";
|
|
3
|
+
import type { Cache } from '../cache/cache.interface.js';
|
|
4
|
+
import type { RequestContext } from "../schemas/session.schema.js";
|
|
5
|
+
import { AnalyticsCapability } from "../capabilities/analytics.capability.js";
|
|
6
|
+
import type { AnalyticsMutation } from "../schemas/index.js";
|
|
7
|
+
import { NoOpCache } from "../cache/noop-cache.js";
|
|
8
|
+
import { createInitialRequestContext } from "../initialization.js";
|
|
9
|
+
import { ClientBuilder } from "../client/client-builder.js";
|
|
10
|
+
import type { Client } from "../client/client.js";
|
|
11
|
+
import { ProductCapability } from "../capabilities/product.capability.js";
|
|
12
|
+
|
|
13
|
+
export class MockAnalyticsCapability extends AnalyticsCapability {
|
|
14
|
+
public events: Array<AnalyticsMutation> = [];
|
|
15
|
+
|
|
16
|
+
public override async track(event: AnalyticsMutation): Promise<void> {
|
|
17
|
+
this.events.push(event);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface MockConfiguration {
|
|
22
|
+
mock?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function withMockCapabilities<T extends Partial<Capabilities>>(
|
|
26
|
+
client: Partial<Client>
|
|
27
|
+
) {
|
|
28
|
+
return (
|
|
29
|
+
cache: Cache,
|
|
30
|
+
context: RequestContext
|
|
31
|
+
): ClientFromCapabilities<T> => {
|
|
32
|
+
return client as ClientFromCapabilities<T>
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe('Client Builder', () => {
|
|
37
|
+
it('should properly multicast analytics events to all analytics providers that register themselves', async () => {
|
|
38
|
+
const cache = new NoOpCache();
|
|
39
|
+
const context = createInitialRequestContext();
|
|
40
|
+
const builder = new ClientBuilder(context);
|
|
41
|
+
const analyticsCapability = new MockAnalyticsCapability(cache, context);
|
|
42
|
+
const secondaryAnalyticsCapability = new MockAnalyticsCapability(cache, context);
|
|
43
|
+
const client = builder
|
|
44
|
+
.withCache(cache)
|
|
45
|
+
.withCapability(withMockCapabilities({ analytics: analyticsCapability }))
|
|
46
|
+
.withCapability(withMockCapabilities({ analytics: secondaryAnalyticsCapability }))
|
|
47
|
+
.build();
|
|
48
|
+
|
|
49
|
+
const track = await client.analytics.track({
|
|
50
|
+
event: 'product-details-view',
|
|
51
|
+
product: {
|
|
52
|
+
key: 'P-1000'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
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
|
+
});
|
|
61
|
+
|
|
62
|
+
it('supports capability factories with args object signature', () => {
|
|
63
|
+
const cache = new NoOpCache();
|
|
64
|
+
const context = createInitialRequestContext();
|
|
65
|
+
const builder = new ClientBuilder(context);
|
|
66
|
+
const analyticsCapability = new MockAnalyticsCapability(cache, context);
|
|
67
|
+
|
|
68
|
+
const client = builder
|
|
69
|
+
.withCache(cache)
|
|
70
|
+
.withCapability(({ cache: sharedCache, context: sharedContext }) => {
|
|
71
|
+
expect(sharedCache).toBe(cache);
|
|
72
|
+
expect(sharedContext).toBe(context);
|
|
73
|
+
return { analytics: analyticsCapability };
|
|
74
|
+
})
|
|
75
|
+
.build();
|
|
76
|
+
|
|
77
|
+
expect(client.analytics).toBeDefined();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('supports throw collision strategy', () => {
|
|
81
|
+
const cache = new NoOpCache();
|
|
82
|
+
const context = createInitialRequestContext();
|
|
83
|
+
const builder = new ClientBuilder(context);
|
|
84
|
+
|
|
85
|
+
class TestProductCapability extends ProductCapability {
|
|
86
|
+
public override async getById(): Promise<any> {
|
|
87
|
+
throw new Error('not implemented');
|
|
88
|
+
}
|
|
89
|
+
public override async getBySlug(): Promise<any> {
|
|
90
|
+
throw new Error('not implemented');
|
|
91
|
+
}
|
|
92
|
+
public override async getBySKU(): Promise<any> {
|
|
93
|
+
throw new Error('not implemented');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
expect(() =>
|
|
98
|
+
builder
|
|
99
|
+
.withCache(cache)
|
|
100
|
+
.withCollisionStrategy('throw')
|
|
101
|
+
.withCapability(() => ({ product: new TestProductCapability(cache, context) }))
|
|
102
|
+
.withCapability(() => ({ product: new TestProductCapability(cache, context) }))
|
|
103
|
+
.build(),
|
|
104
|
+
).toThrow(/Capability collision detected for "product"/);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('supports first-wins collision strategy', () => {
|
|
108
|
+
const cache = new NoOpCache();
|
|
109
|
+
const context = createInitialRequestContext();
|
|
110
|
+
const builder = new ClientBuilder(context);
|
|
111
|
+
|
|
112
|
+
class TestProductCapability extends ProductCapability {
|
|
113
|
+
public name: string;
|
|
114
|
+
constructor(cache: Cache, context: RequestContext, name: string) {
|
|
115
|
+
super(cache, context);
|
|
116
|
+
this.name = name;
|
|
117
|
+
}
|
|
118
|
+
public override async getById(): Promise<any> {
|
|
119
|
+
throw new Error('not implemented');
|
|
120
|
+
}
|
|
121
|
+
public override async getBySlug(): Promise<any> {
|
|
122
|
+
throw new Error('not implemented');
|
|
123
|
+
}
|
|
124
|
+
public override async getBySKU(): Promise<any> {
|
|
125
|
+
throw new Error('not implemented');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const first = new TestProductCapability(cache, context, 'first');
|
|
130
|
+
const second = new TestProductCapability(cache, context, 'second');
|
|
131
|
+
|
|
132
|
+
const client = builder
|
|
133
|
+
.withCache(cache)
|
|
134
|
+
.withCollisionStrategy('first-wins')
|
|
135
|
+
.withCapability(() => ({ product: first }))
|
|
136
|
+
.withCapability(() => ({ product: second }))
|
|
137
|
+
.build();
|
|
138
|
+
|
|
139
|
+
expect((client.product as TestProductCapability).name).toBe('first');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseCapability } from '../capabilities/base.capability.js';
|
|
3
3
|
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
4
|
import type { Cache } from '../cache/cache.interface.js';
|
|
5
5
|
import {
|
|
@@ -18,11 +18,11 @@ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
|
18
18
|
import { SpanStatusCode, trace } from '@opentelemetry/api';
|
|
19
19
|
import { hrTimeToMilliseconds } from '@opentelemetry/core';
|
|
20
20
|
|
|
21
|
-
export function
|
|
21
|
+
export function createTestableCapability(
|
|
22
22
|
decoratorOptions: Partial<ReactionaryDecoratorOptions>,
|
|
23
23
|
fn?: any
|
|
24
24
|
) {
|
|
25
|
-
class
|
|
25
|
+
class TestableCapability extends BaseCapability {
|
|
26
26
|
constructor(
|
|
27
27
|
public override cache: Cache,
|
|
28
28
|
public override context: RequestContext
|
|
@@ -53,36 +53,36 @@ export function createTestableProvider(
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
public getResourceName(): string {
|
|
56
|
-
return '
|
|
56
|
+
return 'TestableCapability';
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const cache = new MemoryCache();
|
|
61
61
|
const context = createInitialRequestContext();
|
|
62
62
|
|
|
63
|
-
return new
|
|
63
|
+
return new TestableCapability(cache, context);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
describe('@Reactionary decorator', () => {
|
|
67
67
|
describe('Input validation', () => {
|
|
68
68
|
it('should reject invalid input with a failure', async () => {
|
|
69
|
-
const
|
|
69
|
+
const capability = createTestableCapability({
|
|
70
70
|
cache: false,
|
|
71
71
|
inputSchema: z.string(),
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
const result = await
|
|
74
|
+
const result = await capability.decoratedFunction(42);
|
|
75
75
|
|
|
76
76
|
expect(result.success).toBe(false);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it('should allow valid input through with a success', async () => {
|
|
80
|
-
const
|
|
80
|
+
const capability = createTestableCapability({
|
|
81
81
|
cache: false,
|
|
82
82
|
inputSchema: z.string(),
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
const result = await
|
|
85
|
+
const result = await capability.decoratedFunction('42');
|
|
86
86
|
|
|
87
87
|
expect(result.success).toBe(true);
|
|
88
88
|
});
|
|
@@ -90,7 +90,7 @@ describe('@Reactionary decorator', () => {
|
|
|
90
90
|
|
|
91
91
|
describe('Output validation', () => {
|
|
92
92
|
it('should reject invalid output with a failure', async () => {
|
|
93
|
-
const
|
|
93
|
+
const capability = createTestableCapability(
|
|
94
94
|
{
|
|
95
95
|
cache: false,
|
|
96
96
|
outputSchema: z.string(),
|
|
@@ -100,13 +100,13 @@ describe('@Reactionary decorator', () => {
|
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
102
|
|
|
103
|
-
const result = await
|
|
103
|
+
const result = await capability.decoratedFunction();
|
|
104
104
|
|
|
105
105
|
expect(result.success).toBe(false);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
it('should allow valid output with a success', async () => {
|
|
109
|
-
const
|
|
109
|
+
const capability = createTestableCapability(
|
|
110
110
|
{
|
|
111
111
|
cache: false,
|
|
112
112
|
outputSchema: z.string(),
|
|
@@ -116,7 +116,7 @@ describe('@Reactionary decorator', () => {
|
|
|
116
116
|
}
|
|
117
117
|
);
|
|
118
118
|
|
|
119
|
-
const result = await
|
|
119
|
+
const result = await capability.decoratedFunction();
|
|
120
120
|
|
|
121
121
|
expect(result.success).toBe(true);
|
|
122
122
|
});
|
|
@@ -124,11 +124,11 @@ describe('@Reactionary decorator', () => {
|
|
|
124
124
|
|
|
125
125
|
describe('Error handling', () => {
|
|
126
126
|
it('will wrap errors thrown by the provider in a GenericError', async () => {
|
|
127
|
-
const
|
|
127
|
+
const capability = createTestableCapability({}, function () {
|
|
128
128
|
throw new Error('42');
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
-
const result = await
|
|
131
|
+
const result = await capability.decoratedFunction();
|
|
132
132
|
|
|
133
133
|
if (result.success) {
|
|
134
134
|
assert.fail();
|
|
@@ -157,14 +157,14 @@ describe('@Reactionary decorator', () => {
|
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
it('records a timed span for entering the decorated function', async () => {
|
|
160
|
-
const
|
|
160
|
+
const capability = createTestableCapability({
|
|
161
161
|
cache: false,
|
|
162
162
|
}, async function() {
|
|
163
163
|
await new Promise(resolve => setTimeout(resolve, 200));
|
|
164
164
|
|
|
165
165
|
return "42";
|
|
166
166
|
});
|
|
167
|
-
const result = await
|
|
167
|
+
const result = await capability.decoratedFunction();
|
|
168
168
|
const spans = exporter.getFinishedSpans();
|
|
169
169
|
|
|
170
170
|
expect(spans.length).toBe(1);
|
|
@@ -176,20 +176,20 @@ describe('@Reactionary decorator', () => {
|
|
|
176
176
|
|
|
177
177
|
console.log('unset expected: ', status);
|
|
178
178
|
|
|
179
|
-
expect(name).toBe('
|
|
179
|
+
expect(name).toBe('TestableCapability.decoratedFunction');
|
|
180
180
|
expect(duration).toBeGreaterThanOrEqual(200);
|
|
181
181
|
expect(duration).toBeLessThanOrEqual(300);
|
|
182
182
|
expect(status.code).toBe(SpanStatusCode.UNSET);
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
it('records exceptions as events and marks the span as an error', async () => {
|
|
186
|
-
const
|
|
186
|
+
const capability = createTestableCapability({
|
|
187
187
|
cache: false,
|
|
188
188
|
}, async function() {
|
|
189
189
|
throw new Error('42');
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
const result = await
|
|
192
|
+
const result = await capability.decoratedFunction();
|
|
193
193
|
const spans = exporter.getFinishedSpans();
|
|
194
194
|
|
|
195
195
|
expect(spans.length).toBe(1);
|
|
@@ -198,17 +198,17 @@ describe('@Reactionary decorator', () => {
|
|
|
198
198
|
const name = span.name;
|
|
199
199
|
const status = span.status;
|
|
200
200
|
|
|
201
|
-
expect(name).toBe('
|
|
201
|
+
expect(name).toBe('TestableCapability.decoratedFunction');
|
|
202
202
|
expect(status.code).toBe(SpanStatusCode.ERROR);
|
|
203
203
|
});
|
|
204
204
|
});
|
|
205
205
|
|
|
206
206
|
describe('Caching', () => {
|
|
207
207
|
it('should not cache repeat lookups if the decorator is set to uncached', async () => {
|
|
208
|
-
const
|
|
208
|
+
const capability = createTestableCapability({
|
|
209
209
|
cache: false,
|
|
210
210
|
});
|
|
211
|
-
const result = await
|
|
211
|
+
const result = await capability.decoratedFunction();
|
|
212
212
|
|
|
213
213
|
if (!result.success) {
|
|
214
214
|
assert.fail();
|
|
@@ -216,7 +216,7 @@ describe('@Reactionary decorator', () => {
|
|
|
216
216
|
|
|
217
217
|
expect(result.meta.cache.hit).toBe(false);
|
|
218
218
|
|
|
219
|
-
const secondResult = await
|
|
219
|
+
const secondResult = await capability.decoratedFunction();
|
|
220
220
|
|
|
221
221
|
if (!secondResult.success) {
|
|
222
222
|
assert.fail();
|
|
@@ -226,10 +226,10 @@ describe('@Reactionary decorator', () => {
|
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
it('should cache repeat lookups if the decorator is set to cached', async () => {
|
|
229
|
-
const
|
|
229
|
+
const capability = createTestableCapability({
|
|
230
230
|
cache: true,
|
|
231
231
|
});
|
|
232
|
-
const result = await
|
|
232
|
+
const result = await capability.decoratedFunction();
|
|
233
233
|
|
|
234
234
|
if (!result.success) {
|
|
235
235
|
assert.fail();
|
|
@@ -237,7 +237,7 @@ describe('@Reactionary decorator', () => {
|
|
|
237
237
|
|
|
238
238
|
expect(result.meta.cache.hit).toBe(false);
|
|
239
239
|
|
|
240
|
-
const secondResult = await
|
|
240
|
+
const secondResult = await capability.decoratedFunction();
|
|
241
241
|
|
|
242
242
|
if (!secondResult.success) {
|
|
243
243
|
assert.fail();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"types": [
|
|
6
|
+
"vitest/globals",
|
|
7
|
+
"vitest/importMeta",
|
|
8
|
+
"vite/client",
|
|
9
|
+
"node",
|
|
10
|
+
"vitest"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"vite.config.ts",
|
|
15
|
+
"vite.config.mts",
|
|
16
|
+
"vitest.config.ts",
|
|
17
|
+
"vitest.config.mts",
|
|
18
|
+
"src/**/*.test.ts",
|
|
19
|
+
"src/**/*.spec.ts",
|
|
20
|
+
"src/**/*.test.tsx",
|
|
21
|
+
"src/**/*.spec.tsx",
|
|
22
|
+
"src/**/*.test.js",
|
|
23
|
+
"src/**/*.spec.js",
|
|
24
|
+
"src/**/*.test.jsx",
|
|
25
|
+
"src/**/*.spec.jsx",
|
|
26
|
+
"src/**/*.d.ts"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types='vitest' />
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
4
|
+
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
|
|
5
|
+
|
|
6
|
+
export default defineConfig(() => ({
|
|
7
|
+
root: import.meta.dirname,
|
|
8
|
+
cacheDir: '../../node_modules/.vite/packages/core',
|
|
9
|
+
plugins: [nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
|
|
10
|
+
// Uncomment this if you are using workers.
|
|
11
|
+
// worker: {
|
|
12
|
+
// plugins: () => [ nxViteTsPaths() ],
|
|
13
|
+
// },
|
|
14
|
+
test: {
|
|
15
|
+
name: 'core',
|
|
16
|
+
watch: false,
|
|
17
|
+
globals: true,
|
|
18
|
+
environment: 'node',
|
|
19
|
+
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
20
|
+
reporters: ['default'],
|
|
21
|
+
coverage: {
|
|
22
|
+
reportsDirectory: '../../coverage/packages/core',
|
|
23
|
+
provider: 'v8' as const,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
3
|
+
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
|
|
4
|
+
|
|
5
|
+
export default defineConfig(() => ({
|
|
6
|
+
root: __dirname,
|
|
7
|
+
cacheDir: '../../node_modules/.vite/packages/core',
|
|
8
|
+
plugins: [nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
|
|
9
|
+
test: {
|
|
10
|
+
name: 'core',
|
|
11
|
+
watch: false,
|
|
12
|
+
globals: true,
|
|
13
|
+
environment: 'node',
|
|
14
|
+
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
15
|
+
reporters: ['default'],
|
|
16
|
+
coverage: {
|
|
17
|
+
reportsDirectory: '../../coverage/packages/core',
|
|
18
|
+
provider: 'v8' as const,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
@@ -9,8 +9,9 @@ export default [
|
|
|
9
9
|
'error',
|
|
10
10
|
{
|
|
11
11
|
ignoredFiles: [
|
|
12
|
-
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
12
|
+
'{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
|
|
13
13
|
'{projectRoot}/esbuild.config.{js,ts,mjs,mts}',
|
|
14
|
+
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
|
|
14
15
|
],
|
|
15
16
|
},
|
|
16
17
|
],
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@reactionary/
|
|
2
|
+
"name": "@reactionary/fake",
|
|
3
3
|
"version": "0.0.1",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
6
7
|
"dependencies": {
|
|
8
|
+
"vitest": "^4.0.9",
|
|
9
|
+
"@nx/vite": "22.4.5",
|
|
7
10
|
"@reactionary/core": "0.0.1",
|
|
8
11
|
"zod": "4.1.9",
|
|
9
12
|
"@faker-js/faker": "^9.8.0"
|
|
10
13
|
},
|
|
11
|
-
"type": "module",
|
|
12
14
|
"sideEffects": false
|
|
13
15
|
}
|