@reactionary/source 0.0.39 → 0.0.41
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/core/package.json +1 -1
- package/core/src/decorators/reactionary.decorator.ts +16 -0
- package/core/src/index.ts +2 -0
- package/core/src/schemas/capabilities.schema.ts +1 -1
- package/core/src/schemas/models/base.model.ts +5 -5
- package/core/src/schemas/models/cart.model.ts +1 -1
- package/core/src/schemas/models/identifiers.model.ts +12 -12
- package/core/src/schemas/models/price.model.ts +1 -1
- package/core/src/schemas/models/product.model.ts +2 -2
- package/core/src/schemas/models/search.model.ts +3 -3
- package/core/src/schemas/mutations/base.mutation.ts +1 -1
- package/core/src/schemas/mutations/cart.mutation.ts +6 -6
- package/core/src/schemas/mutations/inventory.mutation.ts +0 -4
- package/core/src/schemas/mutations/price.mutation.ts +0 -4
- package/core/src/schemas/mutations/product.mutation.ts +0 -4
- package/core/src/schemas/mutations/search.mutation.ts +0 -4
- package/core/src/schemas/queries/analytics.query.ts +0 -4
- package/core/src/schemas/queries/base.query.ts +1 -1
- package/core/src/schemas/queries/cart.query.ts +0 -1
- package/core/src/schemas/queries/inventory.query.ts +0 -4
- package/examples/next/src/app/page.tsx +20 -15
- package/examples/node/package.json +3 -1
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +13 -5
- package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +11 -1
- package/examples/node/src/basic/basic-node-setup.spec.ts +7 -3
- package/examples/node/src/test-utils.ts +26 -0
- package/otel/src/trace-decorator.ts +6 -5
- package/package.json +5 -4
- package/providers/algolia/package.json +1 -1
- package/providers/algolia/src/schema/configuration.schema.ts +1 -1
- package/providers/algolia/src/test/search.provider.spec.ts +29 -20
- package/providers/algolia/src/test/test-utils.ts +26 -0
- package/providers/commercetools/package.json +2 -2
- package/providers/commercetools/src/core/client.ts +26 -2
- package/providers/commercetools/src/core/initialize.ts +32 -6
- package/providers/commercetools/src/providers/cart.provider.ts +6 -4
- package/providers/commercetools/src/providers/category.provider.ts +2 -2
- package/providers/commercetools/src/providers/price.provider.ts +2 -1
- package/providers/commercetools/src/providers/search.provider.ts +33 -12
- package/providers/commercetools/src/schema/configuration.schema.ts +1 -1
- package/providers/commercetools/src/test/category.provider.spec.ts +1 -14
- package/providers/fake/package.json +1 -1
- package/providers/fake/src/core/initialize.ts +6 -8
- package/providers/fake/src/schema/configuration.schema.ts +3 -3
- package/providers/fake/src/test/category.provider.spec.ts +1 -3
- package/providers/posthog/package.json +1 -1
- package/providers/posthog/src/schema/configuration.schema.ts +1 -1
- package/trpc/package.json +1 -1
- package/trpc/src/integration.spec.ts +24 -23
- package/trpc/src/test-utils.ts +26 -0
- package/trpc/src/transparent-client.spec.ts +22 -26
- package/providers/algolia/src/test/product.provider.spec.ts +0 -18
package/core/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function Reactionary(options: unknown): MethodDecorator {
|
|
2
|
+
return function (
|
|
3
|
+
target: any,
|
|
4
|
+
propertyKey: string | symbol,
|
|
5
|
+
descriptor: PropertyDescriptor
|
|
6
|
+
): PropertyDescriptor {
|
|
7
|
+
const original = descriptor.value;
|
|
8
|
+
|
|
9
|
+
descriptor.value = function (...args: any[]) {
|
|
10
|
+
console.log('calling through reactionary decoration!');
|
|
11
|
+
return original.apply(this, args);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return descriptor;
|
|
15
|
+
};
|
|
16
|
+
}
|
package/core/src/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from './cache/noop-cache';
|
|
|
6
6
|
export * from './client/client';
|
|
7
7
|
export * from './client/client-builder';
|
|
8
8
|
|
|
9
|
+
export * from './decorators/reactionary.decorator';
|
|
10
|
+
|
|
9
11
|
export * from './providers/analytics.provider';
|
|
10
12
|
export * from './providers/base.provider';
|
|
11
13
|
export * from './providers/cart.provider';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
export const CacheInformationSchema = z.
|
|
3
|
+
export const CacheInformationSchema = z.looseObject({
|
|
4
4
|
hit: z.boolean().default(false),
|
|
5
5
|
key: z.string().default('')
|
|
6
6
|
})
|
|
7
7
|
|
|
8
|
-
export const MetaSchema = z.
|
|
8
|
+
export const MetaSchema = z.looseObject({
|
|
9
9
|
cache: CacheInformationSchema.default(() => CacheInformationSchema.parse({})),
|
|
10
10
|
placeholder: z.boolean().default(false).describe('Whether or not the entity exists in a remote system, or is a default placeholder.')
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
export const BaseModelSchema = z.
|
|
13
|
+
export const BaseModelSchema = z.looseObject({
|
|
14
14
|
meta: MetaSchema.default(() => MetaSchema.parse({}))
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ export type Meta = z.infer<typeof MetaSchema>;
|
|
|
19
19
|
export type BaseModel = z.infer<typeof BaseModelSchema>;
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
export const PaginationOptionsSchema = z.
|
|
22
|
+
export const PaginationOptionsSchema = z.looseObject({
|
|
23
23
|
pageNumber: z.number().default(1).describe('Current page number, starting from 1'),
|
|
24
24
|
pageSize: z.number().default(20).describe('Number of items per page'),
|
|
25
25
|
});
|
|
@@ -48,7 +48,7 @@ export function createPaginatedResponseSchema<ItemType extends z.ZodTypeAny>(
|
|
|
48
48
|
* what we really need is the original source url, and then some metadata about the image.
|
|
49
49
|
* Ie, rather than having distinct thumbnail and image fields, we just have a list of images, and the frontend will generate its own thumbnails as needed?
|
|
50
50
|
*/
|
|
51
|
-
export const ImageSchema = z.
|
|
51
|
+
export const ImageSchema = z.looseObject({
|
|
52
52
|
sourceUrl: z.string().default('').describe('The original source URL of the image. Pass this through your image resizing and transcoding service to get the desired size, and generate thumbnails as needed'),
|
|
53
53
|
altText: z.string().default('').describe('Alternative text for the image, for accessibility purposes. Must always be set, and non-empty'),
|
|
54
54
|
width: z.number().optional().describe('Width of the original image, in pixels, if known'),
|
|
@@ -22,7 +22,7 @@ export const ItemCostBreakdownSchema = z.looseObject({
|
|
|
22
22
|
|
|
23
23
|
export type ItemCostBreakdown = z.infer<typeof ItemCostBreakdownSchema>;
|
|
24
24
|
|
|
25
|
-
export const CartItemSchema = z.
|
|
25
|
+
export const CartItemSchema = z.looseObject({
|
|
26
26
|
identifier: CartItemIdentifierSchema.default(() => CartItemIdentifierSchema.parse({})),
|
|
27
27
|
product: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
|
|
28
28
|
quantity: z.number().default(0),
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
export const FacetIdentifierSchema = z.
|
|
3
|
+
export const FacetIdentifierSchema = z.looseObject({
|
|
4
4
|
key: z.string().default('').nonoptional()
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
export const FacetValueIdentifierSchema = z.
|
|
7
|
+
export const FacetValueIdentifierSchema = z.looseObject({
|
|
8
8
|
facet: FacetIdentifierSchema.default(() => FacetIdentifierSchema.parse({})),
|
|
9
9
|
key: z.string().default('')
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
export const SKUIdentifierSchema = z.
|
|
12
|
+
export const SKUIdentifierSchema = z.looseObject({
|
|
13
13
|
key: z.string().default('').nonoptional()
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
export const ProductIdentifierSchema = z.
|
|
16
|
+
export const ProductIdentifierSchema = z.looseObject({
|
|
17
17
|
key: z.string().default(''),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
export const SearchIdentifierSchema = z.
|
|
20
|
+
export const SearchIdentifierSchema = z.looseObject({
|
|
21
21
|
term: z.string().default(''),
|
|
22
22
|
page: z.number().default(0),
|
|
23
23
|
pageSize: z.number().default(20),
|
|
24
24
|
facets: z.array(FacetValueIdentifierSchema.required()).default(() => [])
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
export const CartIdentifierSchema = z.
|
|
27
|
+
export const CartIdentifierSchema = z.looseObject({
|
|
28
28
|
key: z.string().default('')
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
export const CartItemIdentifierSchema = z.
|
|
31
|
+
export const CartItemIdentifierSchema = z.looseObject({
|
|
32
32
|
key: z.string().default('')
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
export const PriceIdentifierSchema = z.
|
|
35
|
+
export const PriceIdentifierSchema = z.looseObject({
|
|
36
36
|
sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
export const CategoryIdentifierSchema = z.
|
|
39
|
+
export const CategoryIdentifierSchema = z.looseObject({
|
|
40
40
|
key: z.string().default('').nonoptional()
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* The target store the user is interacting with. Can change over time, and is not necessarily the same as the default store.
|
|
45
45
|
*/
|
|
46
|
-
export const WebStoreIdentifierSchema = z.
|
|
46
|
+
export const WebStoreIdentifierSchema = z.looseObject({
|
|
47
47
|
key: z.string().default('').nonoptional()
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
export const InventoryChannelIdentifierSchema= z.
|
|
50
|
+
export const InventoryChannelIdentifierSchema= z.looseObject({
|
|
51
51
|
key: z.string().default('online').nonoptional()
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
export const InventoryIdentifierSchema = z.
|
|
54
|
+
export const InventoryIdentifierSchema = z.looseObject({
|
|
55
55
|
sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
|
|
56
56
|
channelId: InventoryChannelIdentifierSchema.default(() => InventoryChannelIdentifierSchema.parse({})),
|
|
57
57
|
});
|
|
@@ -3,7 +3,7 @@ import { BaseModelSchema } from './base.model';
|
|
|
3
3
|
import { PriceIdentifierSchema } from './identifiers.model';
|
|
4
4
|
import { CurrencySchema } from './currency.model';
|
|
5
5
|
|
|
6
|
-
export const MonetaryAmountSchema = z.
|
|
6
|
+
export const MonetaryAmountSchema = z.looseObject({
|
|
7
7
|
value: z.number().default(0).describe('The monetary amount in decimal-precision.'),
|
|
8
8
|
currency: CurrencySchema.default("XXX").describe('The currency associated with the amount, as a ISO 4217 standardized code.')
|
|
9
9
|
});
|
|
@@ -2,11 +2,11 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ProductIdentifierSchema } from './identifiers.model';
|
|
3
3
|
import { BaseModelSchema } from './base.model';
|
|
4
4
|
|
|
5
|
-
export const SKUSchema = z.
|
|
5
|
+
export const SKUSchema = z.looseObject({
|
|
6
6
|
identifier: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
export const ProductAttributeSchema = z.
|
|
9
|
+
export const ProductAttributeSchema = z.looseObject({
|
|
10
10
|
id: z.string(),
|
|
11
11
|
name: z.string(),
|
|
12
12
|
value: z.string()
|
|
@@ -3,21 +3,21 @@ import { ProductIdentifierSchema, FacetValueIdentifierSchema, FacetIdentifierSch
|
|
|
3
3
|
import { BaseModelSchema, createPaginatedResponseSchema } from './base.model';
|
|
4
4
|
import { create } from 'domain';
|
|
5
5
|
|
|
6
|
-
export const SearchResultProductSchema = z.
|
|
6
|
+
export const SearchResultProductSchema = z.looseObject({
|
|
7
7
|
identifier: ProductIdentifierSchema.default(ProductIdentifierSchema.parse({})),
|
|
8
8
|
name: z.string().default(''),
|
|
9
9
|
image: z.string().url().default('https://placehold.co/400'),
|
|
10
10
|
slug: z.string().default('')
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
export const SearchResultFacetValueSchema = z.
|
|
13
|
+
export const SearchResultFacetValueSchema = z.looseObject({
|
|
14
14
|
identifier: FacetValueIdentifierSchema.default(() => FacetValueIdentifierSchema.parse({})),
|
|
15
15
|
name: z.string().default(''),
|
|
16
16
|
count: z.number().default(0),
|
|
17
17
|
active: z.boolean().default(false)
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
export const SearchResultFacetSchema = z.
|
|
20
|
+
export const SearchResultFacetSchema = z.looseObject({
|
|
21
21
|
identifier: FacetIdentifierSchema.default(() => FacetIdentifierSchema.parse({})),
|
|
22
22
|
name: z.string().default(''),
|
|
23
23
|
values: z.array(SearchResultFacetValueSchema).default(() => [])
|
|
@@ -3,19 +3,19 @@ import { BaseMutationSchema } from './base.mutation';
|
|
|
3
3
|
import { CartIdentifierSchema, CartItemIdentifierSchema, ProductIdentifierSchema } from '../models/identifiers.model';
|
|
4
4
|
|
|
5
5
|
export const CartMutationItemAddSchema = BaseMutationSchema.extend({
|
|
6
|
-
cart: CartIdentifierSchema.
|
|
7
|
-
product: ProductIdentifierSchema.
|
|
6
|
+
cart: CartIdentifierSchema.nonoptional(),
|
|
7
|
+
product: ProductIdentifierSchema.nonoptional(),
|
|
8
8
|
quantity: z.number()
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
export const CartMutationItemRemoveSchema = BaseMutationSchema.extend({
|
|
12
|
-
cart: CartIdentifierSchema.
|
|
13
|
-
item: CartItemIdentifierSchema.
|
|
12
|
+
cart: CartIdentifierSchema.nonoptional(),
|
|
13
|
+
item: CartItemIdentifierSchema.nonoptional()
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export const CartMutationItemQuantityChangeSchema = BaseMutationSchema.extend({
|
|
17
|
-
cart: CartIdentifierSchema.
|
|
18
|
-
item: CartItemIdentifierSchema.
|
|
17
|
+
cart: CartIdentifierSchema.nonoptional(),
|
|
18
|
+
item: CartItemIdentifierSchema.nonoptional(),
|
|
19
19
|
quantity: z.number()
|
|
20
20
|
});
|
|
21
21
|
|
|
@@ -5,6 +5,5 @@ import { CartIdentifierSchema } from '../models/identifiers.model';
|
|
|
5
5
|
export const CartQueryByIdSchema = BaseQuerySchema.extend({
|
|
6
6
|
cart: CartIdentifierSchema.required()
|
|
7
7
|
});
|
|
8
|
-
export const CartQuerySchema = z.union([CartQueryByIdSchema]);
|
|
9
8
|
|
|
10
9
|
export type CartQueryById = z.infer<typeof CartQueryByIdSchema>;
|
|
@@ -7,10 +7,6 @@ export const InventoryQueryBySKUSchema = BaseQuerySchema.extend({
|
|
|
7
7
|
sku: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
export const InventoryQuerySchema = z.union([InventoryQueryBySKUSchema]);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
10
|
//export type InventoryQuery = z.infer<typeof InventoryQuerySchema>;
|
|
15
11
|
export type InventoryQueryBySKU = z.infer<typeof InventoryQueryBySKUSchema>;
|
|
16
12
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import styles from './page.module.scss';
|
|
2
2
|
import { ClientBuilder, NoOpCache, SessionSchema } from '@reactionary/core';
|
|
3
3
|
import { withFakeCapabilities } from '@reactionary/provider-fake';
|
|
4
|
+
import { withCommercetoolsCapabilities } from '@reactionary/provider-commercetools';
|
|
4
5
|
|
|
5
6
|
export default async function Index() {
|
|
6
7
|
const client = new ClientBuilder()
|
|
@@ -17,11 +18,12 @@ export default async function Index() {
|
|
|
17
18
|
category: 1,
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
|
-
{ search: true, product:
|
|
21
|
+
{ search: true, product: true, identity: false }
|
|
21
22
|
)
|
|
22
23
|
)
|
|
23
24
|
.withCache(new NoOpCache())
|
|
24
25
|
.build();
|
|
26
|
+
|
|
25
27
|
|
|
26
28
|
const session = SessionSchema.parse({
|
|
27
29
|
id: '1234567890',
|
|
@@ -32,20 +34,23 @@ export default async function Index() {
|
|
|
32
34
|
},
|
|
33
35
|
});
|
|
34
36
|
|
|
35
|
-
const search = await client.search
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const search = await client.search.queryByTerm(
|
|
38
|
+
{
|
|
39
|
+
search: {
|
|
40
|
+
facets: [],
|
|
41
|
+
page: 1,
|
|
42
|
+
pageSize: 12,
|
|
43
|
+
term: 'glass',
|
|
44
|
+
},
|
|
41
45
|
},
|
|
42
|
-
|
|
46
|
+
session
|
|
47
|
+
);
|
|
43
48
|
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
return (
|
|
50
|
+
<div className={styles.page}>
|
|
51
|
+
{search.products.map((product, index) => (
|
|
52
|
+
<div key={index}>{product.name}</div>
|
|
53
|
+
))}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
51
56
|
}
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Cache,
|
|
4
4
|
NoOpCache,
|
|
5
5
|
ProductSchema,
|
|
6
|
-
SessionSchema,
|
|
7
6
|
ProductQueryById,
|
|
8
7
|
ProductQueryBySlug,
|
|
9
8
|
} from '@reactionary/core';
|
|
@@ -11,12 +10,11 @@ import {
|
|
|
11
10
|
FakeProductProvider,
|
|
12
11
|
withFakeCapabilities,
|
|
13
12
|
} from '@reactionary/provider-fake';
|
|
13
|
+
import { createAnonymousTestSession } from '../test-utils';
|
|
14
14
|
import z from 'zod';
|
|
15
15
|
|
|
16
16
|
describe('basic node provider extension (models)', () => {
|
|
17
|
-
const session =
|
|
18
|
-
id: '1234567890',
|
|
19
|
-
});
|
|
17
|
+
const session = createAnonymousTestSession();
|
|
20
18
|
|
|
21
19
|
const ExtendedProductModel = ProductSchema.extend({
|
|
22
20
|
gtin: z.string().default('gtin-default'),
|
|
@@ -39,7 +37,12 @@ describe('basic node provider extension (models)', () => {
|
|
|
39
37
|
return (cache: Cache) => {
|
|
40
38
|
const client = {
|
|
41
39
|
product: new ExtendedProductProvider(
|
|
42
|
-
{ jitter: { mean: 0, deviation: 0 }
|
|
40
|
+
{ jitter: { mean: 0, deviation: 0 },
|
|
41
|
+
seeds: {
|
|
42
|
+
category: 1,
|
|
43
|
+
product: 1,
|
|
44
|
+
search: 1
|
|
45
|
+
} },
|
|
43
46
|
ExtendedProductModel,
|
|
44
47
|
cache
|
|
45
48
|
),
|
|
@@ -57,6 +60,11 @@ describe('basic node provider extension (models)', () => {
|
|
|
57
60
|
mean: 0,
|
|
58
61
|
deviation: 0,
|
|
59
62
|
},
|
|
63
|
+
seeds: {
|
|
64
|
+
category: 1,
|
|
65
|
+
product: 1,
|
|
66
|
+
search: 1
|
|
67
|
+
}
|
|
60
68
|
},
|
|
61
69
|
{ search: true, product: false, identity: false }
|
|
62
70
|
)
|
|
@@ -49,7 +49,12 @@ describe('basic node provider extension (models)', () => {
|
|
|
49
49
|
return (cache: Cache) => {
|
|
50
50
|
const client = {
|
|
51
51
|
product: new ExtendedProductProvider(
|
|
52
|
-
{ jitter: { mean: 0, deviation: 0 }
|
|
52
|
+
{ jitter: { mean: 0, deviation: 0 },
|
|
53
|
+
seeds: {
|
|
54
|
+
category: 1,
|
|
55
|
+
product: 1,
|
|
56
|
+
search: 1
|
|
57
|
+
}},
|
|
53
58
|
ExtendedProductModel,
|
|
54
59
|
cache
|
|
55
60
|
),
|
|
@@ -67,6 +72,11 @@ describe('basic node provider extension (models)', () => {
|
|
|
67
72
|
mean: 0,
|
|
68
73
|
deviation: 0,
|
|
69
74
|
},
|
|
75
|
+
seeds: {
|
|
76
|
+
category: 1,
|
|
77
|
+
product: 1,
|
|
78
|
+
search: 1
|
|
79
|
+
}
|
|
70
80
|
},
|
|
71
81
|
{ search: true, product: false, identity: false }
|
|
72
82
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildClient, NoOpCache, SessionSchema } from '@reactionary/core';
|
|
2
2
|
import { withFakeCapabilities } from '@reactionary/provider-fake';
|
|
3
|
+
import { createAnonymousTestSession } from '../test-utils';
|
|
3
4
|
|
|
4
5
|
describe('basic node setup', () => {
|
|
5
6
|
const client = buildClient(
|
|
@@ -10,6 +11,11 @@ describe('basic node setup', () => {
|
|
|
10
11
|
mean: 0,
|
|
11
12
|
deviation: 0,
|
|
12
13
|
},
|
|
14
|
+
seeds: {
|
|
15
|
+
category: 1,
|
|
16
|
+
product: 1,
|
|
17
|
+
search: 1
|
|
18
|
+
}
|
|
13
19
|
},
|
|
14
20
|
{ search: true, product: true, identity: false }
|
|
15
21
|
),
|
|
@@ -19,9 +25,7 @@ describe('basic node setup', () => {
|
|
|
19
25
|
}
|
|
20
26
|
);
|
|
21
27
|
|
|
22
|
-
const session =
|
|
23
|
-
id: '1234567890'
|
|
24
|
-
});
|
|
28
|
+
const session = createAnonymousTestSession();
|
|
25
29
|
|
|
26
30
|
it('should only get back the enabled capabilities', async () => {
|
|
27
31
|
expect(client.product).toBeDefined();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Session } from '@reactionary/core';
|
|
2
|
+
|
|
3
|
+
export function createAnonymousTestSession(): Session {
|
|
4
|
+
return {
|
|
5
|
+
id: 'test-session-id',
|
|
6
|
+
identity: {
|
|
7
|
+
type: 'Anonymous',
|
|
8
|
+
meta: {
|
|
9
|
+
cache: { hit: false, key: '' },
|
|
10
|
+
placeholder: false,
|
|
11
|
+
},
|
|
12
|
+
id: '',
|
|
13
|
+
token: undefined,
|
|
14
|
+
issued: new Date(),
|
|
15
|
+
expiry: new Date(new Date().getTime() + 3600 * 1000), // 1 hour from now
|
|
16
|
+
},
|
|
17
|
+
languageContext: {
|
|
18
|
+
locale: 'en-US',
|
|
19
|
+
currencyCode: 'USD',
|
|
20
|
+
countryCode: 'US',
|
|
21
|
+
},
|
|
22
|
+
storeIdentifier: {
|
|
23
|
+
key: 'the-good-store',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -140,7 +140,7 @@ function createTracedMethod(
|
|
|
140
140
|
): any {
|
|
141
141
|
const { captureArgs, captureResult, spanName, spanKind } = options;
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
function tracedMethod(this: any, ...args: any[]): any {
|
|
144
144
|
const tracer = getTracer();
|
|
145
145
|
const className = this?.constructor?.name || 'Unknown';
|
|
146
146
|
const effectiveSpanName = spanName || `${className}.${methodName}`;
|
|
@@ -152,7 +152,7 @@ function createTracedMethod(
|
|
|
152
152
|
'function.name': methodName,
|
|
153
153
|
'function.class': className,
|
|
154
154
|
}
|
|
155
|
-
},
|
|
155
|
+
}, (span) => {
|
|
156
156
|
// Capture arguments if enabled
|
|
157
157
|
if (captureArgs && args.length > 0) {
|
|
158
158
|
args.forEach((arg, index) => {
|
|
@@ -196,9 +196,10 @@ function createTracedMethod(
|
|
|
196
196
|
// Handle async functions - await them to keep span open
|
|
197
197
|
if (result instanceof Promise) {
|
|
198
198
|
try {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
return result.then(value => {
|
|
200
|
+
setSpanResult(value);
|
|
201
|
+
return value;
|
|
202
|
+
});
|
|
202
203
|
} catch (error) {
|
|
203
204
|
setSpanResult(error, true);
|
|
204
205
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/source",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"dependencies": {
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
"@angular/platform-browser": "~19.2.0",
|
|
12
12
|
"@angular/platform-browser-dynamic": "~19.2.0",
|
|
13
13
|
"@angular/router": "~19.2.0",
|
|
14
|
-
"@commercetools/platform-sdk": "^8.
|
|
15
|
-
"@commercetools/ts-client": "^
|
|
14
|
+
"@commercetools/platform-sdk": "^8.16.0",
|
|
15
|
+
"@commercetools/ts-client": "^4.2.1",
|
|
16
|
+
"@commercetools/ts-sdk-apm": "^4.0.0",
|
|
16
17
|
"@faker-js/faker": "^9.8.0",
|
|
17
18
|
"@opentelemetry/api": "^1.9.0",
|
|
18
19
|
"@opentelemetry/core": "^2.0.1",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"search-insights": "^2.17.3",
|
|
47
48
|
"superjson": "^2.2.2",
|
|
48
49
|
"vue": "^3.5.13",
|
|
49
|
-
"zod": "4.
|
|
50
|
+
"zod": "4.1.9",
|
|
50
51
|
"zone.js": "~0.15.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|