@reactionary/source 0.0.52 → 0.2.16
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/.env-template +19 -0
- package/.github/workflows/pull-request.yml +3 -1
- package/.github/workflows/release.yml +9 -0
- package/.vscode/extensions.json +0 -2
- package/LICENSE +21 -0
- package/README.md +175 -23
- package/core/package.json +6 -3
- package/core/src/cache/cache.interface.ts +1 -0
- package/core/src/cache/index.ts +4 -0
- package/core/src/cache/memory-cache.ts +30 -2
- package/core/src/cache/noop-cache.ts +15 -1
- package/core/src/cache/redis-cache.ts +20 -0
- package/core/src/client/client-builder.ts +71 -54
- package/core/src/client/client.ts +9 -47
- package/core/src/client/index.ts +2 -0
- package/core/src/decorators/index.ts +1 -0
- package/core/src/decorators/reactionary.decorator.ts +203 -34
- package/core/src/index.ts +6 -19
- package/core/src/initialization.ts +1 -18
- package/core/src/metrics/metrics.ts +67 -0
- package/core/src/providers/analytics.provider.ts +1 -6
- package/core/src/providers/base.provider.ts +5 -69
- package/core/src/providers/cart.provider.ts +15 -55
- package/core/src/providers/category.provider.ts +7 -11
- package/core/src/providers/checkout.provider.ts +17 -15
- package/core/src/providers/identity.provider.ts +6 -8
- package/core/src/providers/index.ts +2 -1
- package/core/src/providers/inventory.provider.ts +15 -5
- package/core/src/providers/order-search.provider.ts +29 -0
- package/core/src/providers/order.provider.ts +47 -15
- package/core/src/providers/price.provider.ts +30 -36
- package/core/src/providers/product-search.provider.ts +61 -0
- package/core/src/providers/product.provider.ts +71 -12
- package/core/src/providers/profile.provider.ts +74 -14
- package/core/src/providers/store.provider.ts +3 -5
- package/core/src/schemas/capabilities.schema.ts +10 -3
- package/core/src/schemas/errors/generic.error.ts +9 -0
- package/core/src/schemas/errors/index.ts +4 -0
- package/core/src/schemas/errors/invalid-input.error.ts +9 -0
- package/core/src/schemas/errors/invalid-output.error.ts +9 -0
- package/core/src/schemas/errors/not-found.error.ts +9 -0
- package/core/src/schemas/index.ts +7 -0
- package/core/src/schemas/models/analytics.model.ts +2 -1
- package/core/src/schemas/models/base.model.ts +6 -24
- package/core/src/schemas/models/cart.model.ts +5 -8
- package/core/src/schemas/models/category.model.ts +4 -9
- package/core/src/schemas/models/checkout.model.ts +6 -7
- package/core/src/schemas/models/cost.model.ts +4 -3
- package/core/src/schemas/models/currency.model.ts +2 -1
- package/core/src/schemas/models/identifiers.model.ts +106 -62
- package/core/src/schemas/models/identity.model.ts +10 -19
- package/core/src/schemas/models/index.ts +2 -1
- package/core/src/schemas/models/inventory.model.ts +8 -5
- package/core/src/schemas/models/order-search.model.ts +28 -0
- package/core/src/schemas/models/order.model.ts +20 -26
- package/core/src/schemas/models/payment.model.ts +14 -17
- package/core/src/schemas/models/price.model.ts +11 -11
- package/core/src/schemas/models/product-search.model.ts +42 -0
- package/core/src/schemas/models/product.model.ts +64 -22
- package/core/src/schemas/models/profile.model.ts +19 -22
- package/core/src/schemas/models/shipping-method.model.ts +24 -29
- package/core/src/schemas/models/store.model.ts +9 -5
- package/core/src/schemas/mutations/analytics.mutation.ts +8 -7
- package/core/src/schemas/mutations/base.mutation.ts +2 -1
- package/core/src/schemas/mutations/cart.mutation.ts +33 -33
- package/core/src/schemas/mutations/checkout.mutation.ts +23 -30
- package/core/src/schemas/mutations/identity.mutation.ts +4 -3
- package/core/src/schemas/mutations/profile.mutation.ts +38 -3
- package/core/src/schemas/queries/base.query.ts +2 -1
- package/core/src/schemas/queries/cart.query.ts +3 -3
- package/core/src/schemas/queries/category.query.ts +18 -18
- package/core/src/schemas/queries/checkout.query.ts +7 -9
- package/core/src/schemas/queries/identity.query.ts +2 -1
- package/core/src/schemas/queries/index.ts +2 -1
- package/core/src/schemas/queries/inventory.query.ts +5 -5
- package/core/src/schemas/queries/order-search.query.ts +10 -0
- package/core/src/schemas/queries/order.query.ts +3 -2
- package/core/src/schemas/queries/price.query.ts +10 -4
- package/core/src/schemas/queries/product-search.query.ts +16 -0
- package/core/src/schemas/queries/product.query.ts +13 -6
- package/core/src/schemas/queries/profile.query.ts +5 -2
- package/core/src/schemas/queries/store.query.ts +6 -5
- package/core/src/schemas/result.ts +107 -0
- package/core/src/schemas/session.schema.ts +4 -4
- package/core/src/test/reactionary.decorator.spec.ts +249 -0
- package/core/src/zod-utils.ts +19 -0
- package/core/tsconfig.json +1 -1
- package/core/tsconfig.spec.json +2 -26
- package/core/vitest.config.ts +14 -0
- package/documentation/1-purpose.md +114 -0
- package/documentation/2-getting-started.md +229 -0
- package/documentation/3-querying-and-changing-data.md +74 -0
- package/documentation/4-product-data.md +107 -0
- package/documentation/5-cart-and-checkout.md +211 -0
- package/documentation/6-product-search.md +143 -0
- package/documentation/7-marketing.md +3 -0
- package/eslint.config.mjs +1 -0
- package/examples/node/eslint.config.mjs +1 -4
- package/examples/node/package.json +10 -3
- package/examples/node/project.json +4 -1
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +22 -23
- package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +15 -11
- package/examples/node/src/basic/basic-node-setup.spec.ts +44 -28
- package/examples/node/src/basic/client-creation.spec.ts +53 -0
- package/examples/node/src/capabilities/cart.spec.ts +255 -0
- package/examples/node/src/capabilities/category.spec.ts +193 -0
- package/examples/node/src/capabilities/checkout.spec.ts +341 -0
- package/examples/node/src/capabilities/identity.spec.ts +93 -0
- package/examples/node/src/capabilities/inventory.spec.ts +66 -0
- package/examples/node/src/capabilities/order-search.spec.ts +265 -0
- package/examples/node/src/capabilities/order.spec.ts +91 -0
- package/examples/node/src/capabilities/price.spec.ts +51 -0
- package/examples/node/src/capabilities/product-search.spec.ts +293 -0
- package/examples/node/src/capabilities/product.spec.ts +122 -0
- package/examples/node/src/capabilities/profile.spec.ts +316 -0
- package/examples/node/src/capabilities/store.spec.ts +26 -0
- package/examples/node/src/utils.ts +147 -0
- package/examples/node/tsconfig.json +9 -12
- package/examples/node/tsconfig.lib.json +1 -2
- package/examples/node/tsconfig.spec.json +2 -14
- package/examples/node/vitest.config.ts +14 -0
- package/migrations.json +22 -5
- package/nx.json +8 -47
- package/package.json +24 -96
- package/providers/algolia/README.md +39 -2
- package/providers/algolia/package.json +2 -1
- package/providers/algolia/src/core/initialize.ts +7 -14
- package/providers/algolia/src/index.ts +2 -4
- package/providers/algolia/src/providers/index.ts +1 -0
- package/providers/algolia/src/providers/product-search.provider.ts +241 -0
- package/providers/algolia/src/schema/capabilities.schema.ts +2 -3
- package/providers/algolia/src/schema/index.ts +3 -0
- package/providers/algolia/src/schema/search.schema.ts +8 -8
- package/providers/algolia/tsconfig.json +1 -1
- package/providers/algolia/tsconfig.lib.json +1 -1
- package/providers/algolia/tsconfig.spec.json +2 -14
- package/providers/algolia/vitest.config.ts +14 -0
- package/providers/commercetools/README.md +30 -3
- package/providers/commercetools/package.json +2 -1
- package/providers/commercetools/src/core/client.ts +178 -99
- package/providers/commercetools/src/core/initialize.ts +130 -74
- package/providers/commercetools/src/core/token-cache.ts +45 -0
- package/providers/commercetools/src/index.ts +3 -2
- package/providers/commercetools/src/providers/cart.provider.ts +281 -341
- package/providers/commercetools/src/providers/category.provider.ts +223 -138
- package/providers/commercetools/src/providers/checkout.provider.ts +631 -449
- package/providers/commercetools/src/providers/identity.provider.ts +50 -29
- package/providers/commercetools/src/providers/index.ts +2 -2
- package/providers/commercetools/src/providers/inventory.provider.ts +76 -74
- package/providers/commercetools/src/providers/order-search.provider.ts +220 -0
- package/providers/commercetools/src/providers/order.provider.ts +96 -61
- package/providers/commercetools/src/providers/price.provider.ts +147 -117
- package/providers/commercetools/src/providers/product-search.provider.ts +528 -0
- package/providers/commercetools/src/providers/product.provider.ts +249 -74
- package/providers/commercetools/src/providers/profile.provider.ts +445 -28
- package/providers/commercetools/src/providers/store.provider.ts +54 -40
- package/providers/commercetools/src/schema/capabilities.schema.ts +3 -1
- package/providers/commercetools/src/schema/commercetools.schema.ts +17 -3
- package/providers/commercetools/src/schema/configuration.schema.ts +1 -0
- package/providers/commercetools/src/schema/session.schema.ts +7 -0
- package/providers/commercetools/src/test/caching.spec.ts +82 -0
- package/providers/commercetools/src/test/identity.spec.ts +109 -0
- package/providers/commercetools/src/test/test-utils.ts +21 -19
- package/providers/commercetools/tsconfig.json +1 -1
- package/providers/commercetools/tsconfig.lib.json +1 -1
- package/providers/commercetools/tsconfig.spec.json +2 -14
- package/providers/commercetools/vitest.config.ts +15 -0
- package/providers/fake/README.md +20 -4
- package/providers/fake/package.json +2 -1
- package/providers/fake/src/core/initialize.ts +47 -49
- package/providers/fake/src/providers/analytics.provider.ts +5 -7
- package/providers/fake/src/providers/cart.provider.ts +163 -92
- package/providers/fake/src/providers/category.provider.ts +78 -50
- package/providers/fake/src/providers/checkout.provider.ts +254 -0
- package/providers/fake/src/providers/identity.provider.ts +57 -65
- package/providers/fake/src/providers/index.ts +6 -2
- package/providers/fake/src/providers/inventory.provider.ts +40 -36
- package/providers/fake/src/providers/order-search.provider.ts +78 -0
- package/providers/fake/src/providers/order.provider.ts +106 -0
- package/providers/fake/src/providers/price.provider.ts +93 -41
- package/providers/fake/src/providers/product-search.provider.ts +206 -0
- package/providers/fake/src/providers/product.provider.ts +56 -41
- package/providers/fake/src/providers/profile.provider.ts +147 -0
- package/providers/fake/src/providers/store.provider.ts +30 -20
- package/providers/fake/src/schema/capabilities.schema.ts +5 -1
- package/providers/fake/src/test/cart.provider.spec.ts +59 -80
- package/providers/fake/src/test/category.provider.spec.ts +145 -87
- package/providers/fake/src/test/checkout.provider.spec.ts +222 -0
- package/providers/fake/src/test/order-search.provider.spec.ts +50 -0
- package/providers/fake/src/test/order.provider.spec.ts +44 -0
- package/providers/fake/src/test/price.provider.spec.ts +50 -45
- package/providers/fake/src/test/product.provider.spec.ts +15 -7
- package/providers/fake/src/test/profile.provider.spec.ts +167 -0
- package/providers/fake/tsconfig.json +1 -1
- package/providers/fake/tsconfig.lib.json +1 -1
- package/providers/fake/tsconfig.spec.json +2 -12
- package/providers/fake/vitest.config.ts +14 -0
- package/providers/medusa/README.md +30 -0
- package/providers/medusa/TESTING.md +98 -0
- package/providers/medusa/eslint.config.mjs +19 -0
- package/providers/medusa/package.json +22 -0
- package/providers/medusa/project.json +34 -0
- package/providers/medusa/src/core/client.ts +370 -0
- package/providers/medusa/src/core/initialize.ts +78 -0
- package/providers/medusa/src/index.ts +13 -0
- package/providers/medusa/src/providers/cart.provider.ts +575 -0
- package/providers/medusa/src/providers/category.provider.ts +247 -0
- package/providers/medusa/src/providers/checkout.provider.ts +636 -0
- package/providers/medusa/src/providers/identity.provider.ts +137 -0
- package/providers/medusa/src/providers/inventory.provider.ts +173 -0
- package/providers/medusa/src/providers/order-search.provider.ts +202 -0
- package/providers/medusa/src/providers/order.provider.ts +226 -0
- package/providers/medusa/src/providers/price.provider.ts +140 -0
- package/providers/medusa/src/providers/product-search.provider.ts +243 -0
- package/providers/medusa/src/providers/product.provider.ts +261 -0
- package/providers/medusa/src/providers/profile.provider.ts +392 -0
- package/providers/medusa/src/schema/capabilities.schema.ts +18 -0
- package/providers/medusa/src/schema/configuration.schema.ts +11 -0
- package/providers/medusa/src/schema/medusa.schema.ts +31 -0
- package/providers/medusa/src/test/cart.provider.spec.ts +240 -0
- package/providers/medusa/src/test/category.provider.spec.ts +231 -0
- package/providers/medusa/src/test/checkout.spec.ts +349 -0
- package/providers/medusa/src/test/identity.provider.spec.ts +122 -0
- package/providers/medusa/src/test/inventory.provider.spec.ts +88 -0
- package/providers/medusa/src/test/large-cart.provider.spec.ts +103 -0
- package/providers/medusa/src/test/price.provider.spec.ts +104 -0
- package/providers/medusa/src/test/product.provider.spec.ts +146 -0
- package/providers/medusa/src/test/search.provider.spec.ts +203 -0
- package/providers/medusa/src/test/test-utils.ts +13 -0
- package/providers/medusa/src/utils/medusa-helpers.ts +89 -0
- package/providers/medusa/tsconfig.json +21 -0
- package/providers/medusa/tsconfig.lib.json +9 -0
- package/providers/medusa/tsconfig.spec.json +4 -0
- package/providers/medusa/vitest.config.ts +15 -0
- package/providers/meilisearch/README.md +48 -0
- package/providers/meilisearch/eslint.config.mjs +22 -0
- package/providers/meilisearch/package.json +13 -0
- package/providers/meilisearch/project.json +34 -0
- package/providers/meilisearch/src/core/initialize.ts +21 -0
- package/providers/meilisearch/src/index.ts +6 -0
- package/providers/meilisearch/src/providers/index.ts +1 -0
- package/providers/meilisearch/src/providers/order-search.provider.ts +222 -0
- package/providers/meilisearch/src/providers/product-search.provider.ts +251 -0
- package/providers/meilisearch/src/schema/capabilities.schema.ts +10 -0
- package/providers/meilisearch/src/schema/configuration.schema.ts +11 -0
- package/providers/meilisearch/src/schema/index.ts +3 -0
- package/providers/meilisearch/src/schema/search.schema.ts +14 -0
- package/providers/meilisearch/tsconfig.json +24 -0
- package/providers/meilisearch/tsconfig.lib.json +10 -0
- package/providers/meilisearch/tsconfig.spec.json +4 -0
- package/providers/meilisearch/vitest.config.ts +14 -0
- package/providers/posthog/package.json +2 -1
- package/providers/posthog/tsconfig.json +1 -1
- package/tsconfig.base.json +5 -0
- package/vitest.config.ts +10 -0
- package/core/src/providers/search.provider.ts +0 -18
- package/core/src/schemas/models/search.model.ts +0 -36
- package/core/src/schemas/queries/search.query.ts +0 -9
- package/examples/next/.swcrc +0 -30
- package/examples/next/eslint.config.mjs +0 -21
- package/examples/next/index.d.ts +0 -6
- package/examples/next/next-env.d.ts +0 -5
- package/examples/next/next.config.js +0 -31
- package/examples/next/project.json +0 -9
- package/examples/next/public/.gitkeep +0 -0
- package/examples/next/public/favicon.ico +0 -0
- package/examples/next/src/app/global.css +0 -0
- package/examples/next/src/app/layout.tsx +0 -18
- package/examples/next/src/app/page.module.scss +0 -2
- package/examples/next/src/app/page.tsx +0 -47
- package/examples/next/src/instrumentation.ts +0 -9
- package/examples/next/tsconfig.json +0 -44
- package/examples/node/jest.config.ts +0 -10
- package/jest.config.ts +0 -6
- package/jest.preset.js +0 -3
- package/providers/algolia/jest.config.ts +0 -10
- package/providers/algolia/src/providers/product.provider.ts +0 -66
- package/providers/algolia/src/providers/search.provider.ts +0 -106
- package/providers/algolia/src/test/search.provider.spec.ts +0 -91
- package/providers/commercetools/jest.config.cjs +0 -10
- package/providers/commercetools/src/providers/search.provider.ts +0 -96
- package/providers/commercetools/src/test/cart.provider.spec.ts +0 -199
- package/providers/commercetools/src/test/category.provider.spec.ts +0 -168
- package/providers/commercetools/src/test/checkout.provider.spec.ts +0 -312
- package/providers/commercetools/src/test/identity.provider.spec.ts +0 -88
- package/providers/commercetools/src/test/inventory.provider.spec.ts +0 -41
- package/providers/commercetools/src/test/price.provider.spec.ts +0 -81
- package/providers/commercetools/src/test/product.provider.spec.ts +0 -80
- package/providers/commercetools/src/test/profile.provider.spec.ts +0 -49
- package/providers/commercetools/src/test/search.provider.spec.ts +0 -61
- package/providers/commercetools/src/test/store.provider.spec.ts +0 -37
- package/providers/fake/jest.config.cjs +0 -10
- package/providers/fake/src/providers/search.provider.ts +0 -132
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { describe, expect, it, beforeEach, assert } from 'vitest';
|
|
3
|
+
import { createClient, PrimaryProvider } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
const testData = {
|
|
6
|
+
product: {
|
|
7
|
+
id: 'product_10959528',
|
|
8
|
+
name: 'Manhattan 170703 cable accessory Cable kit',
|
|
9
|
+
image: 'https://images.icecat.biz/img/norm/high/10959528-2837.jpg',
|
|
10
|
+
sku: '0766623170703',
|
|
11
|
+
slug: 'manhattan-170703-cable-accessory-cable-kit-10959528',
|
|
12
|
+
},
|
|
13
|
+
productWithMultiVariants: {
|
|
14
|
+
slug: 'hp-gk859aa-mouse-office-bluetooth-laser-1600-dpi-1377612',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe.each([PrimaryProvider.COMMERCETOOLS])(
|
|
19
|
+
'Product Capability - %s',
|
|
20
|
+
(provider) => {
|
|
21
|
+
let client: ReturnType<typeof createClient>;
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
client = createClient(provider);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should be able to get a product by id', async () => {
|
|
28
|
+
const response = await client.product.getById({
|
|
29
|
+
identifier: { key: testData.product.id },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!response.success) {
|
|
33
|
+
assert.fail();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
expect(response.value.identifier.key).toBe(testData.product.id);
|
|
37
|
+
expect(response.value.name).toBe(testData.product.name);
|
|
38
|
+
expect(response.value.mainVariant.images[0].sourceUrl).toBe(
|
|
39
|
+
testData.product.image
|
|
40
|
+
);
|
|
41
|
+
expect(response.value.mainVariant.name).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should be able to get a product by slug', async () => {
|
|
45
|
+
const response = await client.product.getBySlug({
|
|
46
|
+
slug: testData.product.slug,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (!response.success) {
|
|
50
|
+
assert.fail();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
expect(response.value.identifier.key).toBe(testData.product.id);
|
|
54
|
+
expect(response.value.name).toBe(testData.product.name);
|
|
55
|
+
expect(response.value.mainVariant.images[0].sourceUrl).toBe(
|
|
56
|
+
testData.product.image
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should be able to get a multivariant product by slug', async () => {
|
|
61
|
+
const response = await client.product.getBySlug({
|
|
62
|
+
slug: testData.productWithMultiVariants.slug,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (!response.success) {
|
|
66
|
+
assert.fail();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
expect(response.value.identifier.key).toBeTruthy();
|
|
70
|
+
expect(response.value.slug).toBe(testData.productWithMultiVariants.slug);
|
|
71
|
+
expect(response.value.mainVariant).toBeDefined();
|
|
72
|
+
expect(response.value.variants.length).toBeGreaterThan(0);
|
|
73
|
+
expect(response.value.variants[0].identifier.sku).toBeTruthy();
|
|
74
|
+
expect(response.value.variants[0].identifier.sku).not.toBe(
|
|
75
|
+
response.value.mainVariant.identifier.sku
|
|
76
|
+
);
|
|
77
|
+
expect(response.value.sharedAttributes.length).toBeGreaterThan(1);
|
|
78
|
+
expect(response.value.sharedAttributes[1].values.length).toBeGreaterThan(0);
|
|
79
|
+
expect(response.value.sharedAttributes[1].values[0].value).toBeTruthy();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should be able to get a product by sku', async () => {
|
|
83
|
+
const response = await client.product.getBySKU({
|
|
84
|
+
variant: { sku: testData.product.sku },
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (!response.success) {
|
|
88
|
+
assert.fail();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
expect(response.value.identifier.key).toBe(testData.product.id);
|
|
92
|
+
expect(response.value.name).toBe(testData.product.name);
|
|
93
|
+
expect(response.value.mainVariant.images[0].sourceUrl).toBe(
|
|
94
|
+
testData.product.image
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should contain both product level and variant level attributes', async () => {
|
|
99
|
+
const response = await client.product.getBySKU({
|
|
100
|
+
variant: { sku: testData.product.sku },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (!response.success) {
|
|
104
|
+
assert.fail();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
expect(response.value.sharedAttributes.length).toBeGreaterThan(1);
|
|
108
|
+
expect(response.value.sharedAttributes[1].values.length).toBeGreaterThan(0);
|
|
109
|
+
expect(response.value.sharedAttributes[1].values[0].value).toBeTruthy();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should return an error of NotFound for unknown slug', async () => {
|
|
113
|
+
const response = await client.product.getBySlug({ slug: 'unknown-slug' });
|
|
114
|
+
|
|
115
|
+
if (response.success) {
|
|
116
|
+
assert.fail();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
expect(response.error.type).toBe('NotFound');
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
);
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { describe, expect, it, beforeEach, assert } from 'vitest';
|
|
3
|
+
import { createClient, PrimaryProvider } from '../utils.js';
|
|
4
|
+
import { IdentityIdentifierSchema, type Address, type Identity, type IdentityIdentifier, type Profile } from '@reactionary/core';
|
|
5
|
+
|
|
6
|
+
describe.each([PrimaryProvider.MEDUSA, PrimaryProvider.COMMERCETOOLS])(
|
|
7
|
+
'Profile Capability - %s',
|
|
8
|
+
(provider) => {
|
|
9
|
+
let client: ReturnType<typeof createClient>;
|
|
10
|
+
let identity: Identity | null = null;
|
|
11
|
+
let identityIdentifier: IdentityIdentifier | null = null;
|
|
12
|
+
|
|
13
|
+
beforeEach(async () => {
|
|
14
|
+
client = createClient(provider);
|
|
15
|
+
const time = new Date().getTime();
|
|
16
|
+
|
|
17
|
+
const identityResponse = await client.identity.register({
|
|
18
|
+
username: `martin.rogne+test-${time}@solteq.com`,
|
|
19
|
+
password: 'love2test',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (!identityResponse.success) {
|
|
23
|
+
assert.fail();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
identity = identityResponse.value;
|
|
27
|
+
if (identity.type !== 'Registered') {
|
|
28
|
+
assert.fail();
|
|
29
|
+
}
|
|
30
|
+
identityIdentifier = identity.id;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should be able to fetch the profile for the current user', async () => {
|
|
34
|
+
const time = new Date().getTime();
|
|
35
|
+
if (!identity) {
|
|
36
|
+
assert.fail();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (identity.type !== 'Registered') {
|
|
40
|
+
assert.fail();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const profile = await client.profile.getById({
|
|
44
|
+
identifier: identity.id,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!profile.success) {
|
|
48
|
+
console.log(profile.error);
|
|
49
|
+
assert.fail();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
expect(profile.value.email).toContain('martin.rogne');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should be able to update the profile for the current user', async () => {
|
|
56
|
+
|
|
57
|
+
const time = new Date().getTime();
|
|
58
|
+
const updatedProfile = await client.profile.update({
|
|
59
|
+
identifier: identityIdentifier!,
|
|
60
|
+
phone: '+4712345678',
|
|
61
|
+
email: `martin.rogne+test-${time}-a@solteq.com`,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!updatedProfile.success) {
|
|
65
|
+
console.log(updatedProfile.error);
|
|
66
|
+
assert.fail();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
expect(updatedProfile.value.email).toBe(
|
|
70
|
+
`martin.rogne+test-${time}-a@solteq.com`
|
|
71
|
+
);
|
|
72
|
+
expect(updatedProfile.value.phone).toBe('+4712345678');
|
|
73
|
+
expect(updatedProfile.value.billingAddress).toBeUndefined();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should be able to set the billing address on the profile', async () => {
|
|
77
|
+
if (!identity) {
|
|
78
|
+
assert.fail();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (identity.type !== 'Registered') {
|
|
82
|
+
assert.fail();
|
|
83
|
+
}
|
|
84
|
+
const newAddress: Address = {
|
|
85
|
+
identifier: {
|
|
86
|
+
nickName: 'Billing',
|
|
87
|
+
},
|
|
88
|
+
firstName: 'Jane',
|
|
89
|
+
lastName: 'Doe',
|
|
90
|
+
streetAddress: 'Second Street',
|
|
91
|
+
streetNumber: '456',
|
|
92
|
+
city: 'Gotham',
|
|
93
|
+
region: 'State',
|
|
94
|
+
postalCode: '67890',
|
|
95
|
+
countryCode: 'US',
|
|
96
|
+
};
|
|
97
|
+
const updatedProfile = await client.profile.setBillingAddress({
|
|
98
|
+
identifier: identity.id,
|
|
99
|
+
address: newAddress,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (!updatedProfile.success) {
|
|
103
|
+
console.log(updatedProfile.error);
|
|
104
|
+
assert.fail();
|
|
105
|
+
}
|
|
106
|
+
expect(updatedProfile.value.billingAddress).toMatchObject(newAddress);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('cannot use same nickname for billing and shipping addresses', async () => {
|
|
110
|
+
if (!identity) {
|
|
111
|
+
assert.fail();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (identity.type !== 'Registered') {
|
|
115
|
+
assert.fail();
|
|
116
|
+
}
|
|
117
|
+
const newAddress: Address = {
|
|
118
|
+
identifier: {
|
|
119
|
+
nickName: 'SameNick',
|
|
120
|
+
},
|
|
121
|
+
firstName: 'Jane',
|
|
122
|
+
lastName: 'Doe',
|
|
123
|
+
streetAddress: 'Second Street',
|
|
124
|
+
streetNumber: '456',
|
|
125
|
+
city: 'Gotham',
|
|
126
|
+
region: 'State',
|
|
127
|
+
postalCode: '67890',
|
|
128
|
+
countryCode: 'US',
|
|
129
|
+
};
|
|
130
|
+
const billingAddressResponse = await client.profile.setBillingAddress({
|
|
131
|
+
identifier: identity.id,
|
|
132
|
+
address: newAddress,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (!billingAddressResponse.success) {
|
|
136
|
+
console.log(billingAddressResponse.error);
|
|
137
|
+
assert.fail();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const shippingAddressResponse = await client.profile.addShippingAddress({
|
|
141
|
+
identifier: identity.id,
|
|
142
|
+
address: newAddress,
|
|
143
|
+
});
|
|
144
|
+
expect(shippingAddressResponse.success).toBe(false);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('cannot set the billing address to an existing shipping address', async () => {
|
|
148
|
+
if (!identity) {
|
|
149
|
+
assert.fail();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (identity.type !== 'Registered') {
|
|
153
|
+
assert.fail();
|
|
154
|
+
}
|
|
155
|
+
const newAddress: Address = {
|
|
156
|
+
identifier: {
|
|
157
|
+
nickName: 'SameNick',
|
|
158
|
+
},
|
|
159
|
+
firstName: 'Jane',
|
|
160
|
+
lastName: 'Doe',
|
|
161
|
+
streetAddress: 'Second Street',
|
|
162
|
+
streetNumber: '456',
|
|
163
|
+
city: 'Gotham',
|
|
164
|
+
region: 'State',
|
|
165
|
+
postalCode: '67890',
|
|
166
|
+
countryCode: 'US',
|
|
167
|
+
};
|
|
168
|
+
const shippingAddressResponse = await client.profile.addShippingAddress({
|
|
169
|
+
identifier: identity.id,
|
|
170
|
+
address: newAddress,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (!shippingAddressResponse.success) {
|
|
174
|
+
console.log(shippingAddressResponse.error);
|
|
175
|
+
assert.fail();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const billingAddress = await client.profile.setBillingAddress({
|
|
179
|
+
identifier: identity.id,
|
|
180
|
+
address: shippingAddressResponse.value.alternateShippingAddresses[0]
|
|
181
|
+
});
|
|
182
|
+
expect(billingAddress.success).toBe(false);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
it('should be able to add a shipping address to the profile', async () => {
|
|
187
|
+
if (!identity) {
|
|
188
|
+
assert.fail();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (identity.type !== 'Registered') {
|
|
192
|
+
assert.fail();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const newAddress: Address = {
|
|
196
|
+
identifier: {
|
|
197
|
+
nickName: 'Home',
|
|
198
|
+
},
|
|
199
|
+
firstName: 'John',
|
|
200
|
+
lastName: 'Doe',
|
|
201
|
+
streetAddress: 'Main Street',
|
|
202
|
+
streetNumber: '123',
|
|
203
|
+
city: 'Metropolis',
|
|
204
|
+
region: 'State',
|
|
205
|
+
postalCode: '12345',
|
|
206
|
+
countryCode: 'US',
|
|
207
|
+
};
|
|
208
|
+
const updatedProfile = await client.profile.addShippingAddress({
|
|
209
|
+
identifier: identity.id,
|
|
210
|
+
address: newAddress,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
if (!updatedProfile.success) {
|
|
214
|
+
console.log(updatedProfile.error);
|
|
215
|
+
assert.fail();
|
|
216
|
+
}
|
|
217
|
+
expect(updatedProfile.value.shippingAddress).toBeUndefined();
|
|
218
|
+
|
|
219
|
+
expect(updatedProfile.value.alternateShippingAddresses.length).toBe(1);
|
|
220
|
+
expect(updatedProfile.value.alternateShippingAddresses[0]).toMatchObject(
|
|
221
|
+
newAddress
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe('Shipping Addresses', () => {
|
|
226
|
+
const newAddress: Address = {
|
|
227
|
+
identifier: {
|
|
228
|
+
nickName: 'Home',
|
|
229
|
+
},
|
|
230
|
+
firstName: 'John',
|
|
231
|
+
lastName: 'Doe',
|
|
232
|
+
streetAddress: 'Main Street',
|
|
233
|
+
streetNumber: '123',
|
|
234
|
+
city: 'Metropolis',
|
|
235
|
+
region: 'State',
|
|
236
|
+
postalCode: '12345',
|
|
237
|
+
countryCode: 'US',
|
|
238
|
+
};
|
|
239
|
+
let profile: Profile | null;
|
|
240
|
+
|
|
241
|
+
beforeEach(async () => {
|
|
242
|
+
const updatedProfile = await client.profile.addShippingAddress({
|
|
243
|
+
identifier: identityIdentifier!,
|
|
244
|
+
address: newAddress,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
if (!updatedProfile.success) {
|
|
248
|
+
console.log(updatedProfile.error);
|
|
249
|
+
assert.fail();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
profile = updatedProfile.value;
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('can make a shipping address the default address', async () => {
|
|
256
|
+
const addressToMakeDefault =
|
|
257
|
+
profile!.alternateShippingAddresses[0];
|
|
258
|
+
|
|
259
|
+
const updatedProfile = await client.profile.makeShippingAddressDefault({
|
|
260
|
+
identifier: identityIdentifier!,
|
|
261
|
+
addressIdentifier: addressToMakeDefault.identifier,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
if (!updatedProfile.success) {
|
|
265
|
+
console.log(updatedProfile.error);
|
|
266
|
+
assert.fail();
|
|
267
|
+
}
|
|
268
|
+
expect(updatedProfile.value.shippingAddress).toBeDefined();
|
|
269
|
+
expect(updatedProfile.value.shippingAddress).toMatchObject(newAddress);
|
|
270
|
+
expect(updatedProfile.value.alternateShippingAddresses.length).toBe(0);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('can remove a shipping address from the profile', async () => {
|
|
274
|
+
const addressToRemove =
|
|
275
|
+
profile!.alternateShippingAddresses[0];
|
|
276
|
+
|
|
277
|
+
const updatedProfile = await client.profile.removeShippingAddress({
|
|
278
|
+
identifier: identityIdentifier!,
|
|
279
|
+
addressIdentifier: addressToRemove.identifier,
|
|
280
|
+
});
|
|
281
|
+
if (!updatedProfile.success) {
|
|
282
|
+
console.log(updatedProfile.error);
|
|
283
|
+
assert.fail();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
expect(updatedProfile.value.alternateShippingAddresses.length).toBe(0);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('can remove a shipping address from the profile even if it is the default shipping address', async () => {
|
|
290
|
+
const makeDefaultResponse = await client.profile.makeShippingAddressDefault({
|
|
291
|
+
identifier: identityIdentifier!,
|
|
292
|
+
addressIdentifier: profile!.alternateShippingAddresses[0].identifier,
|
|
293
|
+
});
|
|
294
|
+
if (!makeDefaultResponse.success) {
|
|
295
|
+
console.log(makeDefaultResponse.error);
|
|
296
|
+
assert.fail();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const profileWithDefault = makeDefaultResponse.value;
|
|
300
|
+
const addressToRemove = profileWithDefault.shippingAddress!;
|
|
301
|
+
|
|
302
|
+
const updatedProfile = await client.profile.removeShippingAddress({
|
|
303
|
+
identifier: identityIdentifier!,
|
|
304
|
+
addressIdentifier: addressToRemove.identifier,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
if (!updatedProfile.success) {
|
|
308
|
+
console.log(updatedProfile.error);
|
|
309
|
+
assert.fail();
|
|
310
|
+
}
|
|
311
|
+
expect(updatedProfile.value.shippingAddress).toBeUndefined();
|
|
312
|
+
expect(updatedProfile.value.alternateShippingAddresses.length).toBe(0);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { describe, expect, it, beforeEach, assert } from 'vitest';
|
|
3
|
+
import { createClient, PrimaryProvider } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
describe.each([PrimaryProvider.COMMERCETOOLS])('Store Capability - %s', (provider) => {
|
|
6
|
+
let client: ReturnType<typeof createClient>;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
client = createClient(provider);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it.skip('should be able to query stores by longitude and latitude', async () => {
|
|
13
|
+
const stores = await client.store.queryByProximity({
|
|
14
|
+
distance: 1000,
|
|
15
|
+
latitude: 15,
|
|
16
|
+
longitude: 15,
|
|
17
|
+
limit: 10,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (!stores.success) {
|
|
21
|
+
assert.fail();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
expect(stores.value.length).toBe(2);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createInitialRequestContext,
|
|
3
|
+
ClientBuilder,
|
|
4
|
+
NoOpCache,
|
|
5
|
+
} from '@reactionary/core';
|
|
6
|
+
import type { CommercetoolsConfiguration } from '@reactionary/provider-commercetools';
|
|
7
|
+
import { withCommercetoolsCapabilities } from '@reactionary/provider-commercetools';
|
|
8
|
+
import { withAlgoliaCapabilities } from '@reactionary/provider-algolia';
|
|
9
|
+
import { withMedusaCapabilities } from '@reactionary/provider-medusa';
|
|
10
|
+
import { withMeilisearchCapabilities } from '@reactionary/provider-meilisearch';
|
|
11
|
+
|
|
12
|
+
export function getAlgoliaTestConfiguration() {
|
|
13
|
+
return {
|
|
14
|
+
apiKey: process.env['ALGOLIA_API_KEY'] || '',
|
|
15
|
+
appId: process.env['ALGOLIA_APP_ID'] || '',
|
|
16
|
+
indexName: process.env['ALGOLIA_INDEX'] || '',
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getMeilisearchTestConfiguration() {
|
|
21
|
+
return {
|
|
22
|
+
apiKey: process.env['MEILISEARCH_API_KEY'] || '',
|
|
23
|
+
apiUrl: process.env['MEILISEARCH_API_URL'] || '',
|
|
24
|
+
indexName: process.env['MEILISEARCH_INDEX'] || '',
|
|
25
|
+
useAIEmbedding: process.env['MEILISEARCH_USE_AI_EMBEDDING'] || undefined,
|
|
26
|
+
orderIndexName: process.env['MEILISEARCH_ORDER_INDEX'] || 'order',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export function getMedusaTestConfiguration() {
|
|
32
|
+
return {
|
|
33
|
+
publishable_key: process.env['MEDUSA_PUBLISHABLE_KEY'] || '',
|
|
34
|
+
adminApiKey: process.env['MEDUSA_ADMIN_KEY'] || '',
|
|
35
|
+
apiUrl: process.env['MEDUSA_API_URL'] || '',
|
|
36
|
+
defaultCurrency: process.env['MEDUSA_DEFAULT_CURRENCY'] || '',
|
|
37
|
+
allCurrencies: []
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export function getCommercetoolsTestConfiguration() {
|
|
43
|
+
return {
|
|
44
|
+
apiUrl: process.env['CTP_API_URL'] || '',
|
|
45
|
+
authUrl: process.env['CTP_AUTH_URL'] || '',
|
|
46
|
+
clientId: process.env['CTP_CLIENT_ID'] || '',
|
|
47
|
+
clientSecret: process.env['CTP_CLIENT_SECRET'] || '',
|
|
48
|
+
projectKey: process.env['CTP_PROJECT_KEY'] || '',
|
|
49
|
+
scopes: (process.env['CTP_SCOPES'] || '')
|
|
50
|
+
.split(',')
|
|
51
|
+
.map((x) => x.trim())
|
|
52
|
+
.filter((x) => x && x.length > 0),
|
|
53
|
+
|
|
54
|
+
paymentMethods: [
|
|
55
|
+
{
|
|
56
|
+
identifier: {
|
|
57
|
+
method: 'stripe',
|
|
58
|
+
name: 'Stripe',
|
|
59
|
+
paymentProcessor: 'stripe'
|
|
60
|
+
},
|
|
61
|
+
isPunchOut: false,
|
|
62
|
+
description: 'Stripe payment gateway',
|
|
63
|
+
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
facetFieldsForSearch: (process.env['CTP_FACET_FIELDS_FOR_SEARCH'] || '').split(',') || ['category.id' ]
|
|
67
|
+
} satisfies CommercetoolsConfiguration;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export enum PrimaryProvider {
|
|
71
|
+
ALGOLIA = 'Algolia',
|
|
72
|
+
COMMERCETOOLS = 'Commercetools',
|
|
73
|
+
MEDUSA = 'Medusa',
|
|
74
|
+
MEILISEARCH = 'Meilisearch'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function createClient(provider: PrimaryProvider) {
|
|
78
|
+
const context = createInitialRequestContext();
|
|
79
|
+
let builder = new ClientBuilder(context)
|
|
80
|
+
.withCache(new NoOpCache());
|
|
81
|
+
|
|
82
|
+
if (provider === PrimaryProvider.MEDUSA) {
|
|
83
|
+
builder = builder.withCapability(
|
|
84
|
+
withMedusaCapabilities( getMedusaTestConfiguration(), {
|
|
85
|
+
cart: true,
|
|
86
|
+
product: true,
|
|
87
|
+
category: true,
|
|
88
|
+
checkout: true,
|
|
89
|
+
identity: true,
|
|
90
|
+
inventory: true,
|
|
91
|
+
order: true,
|
|
92
|
+
price: true,
|
|
93
|
+
productSearch: true,
|
|
94
|
+
orderSearch: true,
|
|
95
|
+
store: true,
|
|
96
|
+
profile: true
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
if (provider === PrimaryProvider.COMMERCETOOLS) {
|
|
104
|
+
builder = builder.withCapability(
|
|
105
|
+
withCommercetoolsCapabilities(getCommercetoolsTestConfiguration(), {
|
|
106
|
+
cart: true,
|
|
107
|
+
product: true,
|
|
108
|
+
category: true,
|
|
109
|
+
checkout: true,
|
|
110
|
+
identity: true,
|
|
111
|
+
inventory: true,
|
|
112
|
+
order: true,
|
|
113
|
+
price: true,
|
|
114
|
+
productSearch: true,
|
|
115
|
+
orderSearch: true,
|
|
116
|
+
store: true,
|
|
117
|
+
profile: true,
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if (provider === PrimaryProvider.ALGOLIA) {
|
|
124
|
+
builder = builder.withCapability(
|
|
125
|
+
withAlgoliaCapabilities(getAlgoliaTestConfiguration(), {
|
|
126
|
+
productSearch: true,
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (provider === PrimaryProvider.MEILISEARCH) {
|
|
132
|
+
builder = builder.withCapability(
|
|
133
|
+
withMeilisearchCapabilities(getMeilisearchTestConfiguration(), {
|
|
134
|
+
productSearch: true,
|
|
135
|
+
orderSearch: true,
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
builder = builder.withCapability(
|
|
139
|
+
withMedusaCapabilities(getMedusaTestConfiguration(), {
|
|
140
|
+
cart: true,
|
|
141
|
+
identity: true,
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return builder.build();
|
|
147
|
+
}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "nodenext",
|
|
6
|
+
"forceConsistentCasingInFileNames": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"importHelpers": true,
|
|
9
|
+
"noImplicitOverride": true,
|
|
10
|
+
"noImplicitReturns": true,
|
|
11
|
+
"noFallthroughCasesInSwitch": true,
|
|
12
|
+
"noPropertyAccessFromIndexSignature": true
|
|
13
13
|
},
|
|
14
14
|
"files": [],
|
|
15
15
|
"include": [],
|
|
16
16
|
"references": [
|
|
17
17
|
{
|
|
18
18
|
"path": "./tsconfig.lib.json"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"path": "./tsconfig.spec.json"
|
|
22
19
|
}
|
|
23
20
|
]
|
|
24
21
|
}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"verbatimModuleSyntax": false,
|
|
7
|
-
"outDir": "../../dist/out-tsc",
|
|
8
|
-
"types": ["jest", "node"]
|
|
9
|
-
},
|
|
10
|
-
"include": [
|
|
11
|
-
"jest.config.ts",
|
|
12
|
-
"src/**/*.test.ts",
|
|
13
|
-
"src/**/*.spec.ts",
|
|
14
|
-
"src/**/*.d.ts"
|
|
15
|
-
, "src/initialize-algolia.ts" ]
|
|
2
|
+
"extends": "./tsconfig.lib.json",
|
|
3
|
+
"exclude": []
|
|
16
4
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig, defineProject } from 'vitest/config';
|
|
2
|
+
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
5
|
+
|
|
6
|
+
export default defineProject({
|
|
7
|
+
plugins: [nxViteTsPaths()],
|
|
8
|
+
test: {
|
|
9
|
+
root: resolve(__dirname),
|
|
10
|
+
globals: true,
|
|
11
|
+
environment: 'node',
|
|
12
|
+
include: ['src/**/*.spec.ts', 'src/**/*.test.ts']
|
|
13
|
+
},
|
|
14
|
+
});
|