@reactionary/source 0.0.39 → 0.0.40
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/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/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/package.json +2 -2
- 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 +2 -2
- package/providers/commercetools/package.json +1 -1
- package/providers/commercetools/src/schema/configuration.schema.ts +1 -1
- package/providers/fake/package.json +1 -1
- 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/core/package.json
CHANGED
|
@@ -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(() => [])
|
|
@@ -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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/source",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"dependencies": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"search-insights": "^2.17.3",
|
|
47
47
|
"superjson": "^2.2.2",
|
|
48
48
|
"vue": "^3.5.13",
|
|
49
|
-
"zod": "4.
|
|
49
|
+
"zod": "4.1.9",
|
|
50
50
|
"zone.js": "~0.15.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SearchResultSchema } from '@reactionary/core';
|
|
1
|
+
import { NoOpCache, SearchResultSchema } from '@reactionary/core';
|
|
2
2
|
import { AlgoliaSearchProvider } from '../providers/search.provider';
|
|
3
3
|
|
|
4
4
|
describe('Algolia Search Provider', () => {
|
|
@@ -6,7 +6,7 @@ describe('Algolia Search Provider', () => {
|
|
|
6
6
|
apiKey: process.env['ALGOLIA_API_KEY'] || '',
|
|
7
7
|
appId: process.env['ALGOLIA_APP_ID'] || '',
|
|
8
8
|
indexName: process.env['ALGOLIA_INDEX'] || '',
|
|
9
|
-
}, SearchResultSchema);
|
|
9
|
+
}, SearchResultSchema, new NoOpCache());
|
|
10
10
|
|
|
11
11
|
it('should be able to get a result by term', async () => {
|
|
12
12
|
const result = await provider.get({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
export const FakeConfigurationSchema = z.
|
|
3
|
+
export const FakeConfigurationSchema = z.looseObject({
|
|
4
4
|
jitter: z
|
|
5
|
-
.
|
|
5
|
+
.looseObject({
|
|
6
6
|
mean: z.number().min(0).max(10000),
|
|
7
7
|
deviation: z.number().min(0).max(5000),
|
|
8
8
|
})
|
|
@@ -10,7 +10,7 @@ export const FakeConfigurationSchema = z.looseInterface({
|
|
|
10
10
|
mean: 0,
|
|
11
11
|
deviation: 0,
|
|
12
12
|
}),
|
|
13
|
-
seeds: z.
|
|
13
|
+
seeds: z.looseObject({
|
|
14
14
|
product: z.number().min(0).max(10000).default(1),
|
|
15
15
|
search: z.number().min(0).max(10000).default(1),
|
|
16
16
|
category: z.number().min(0).max(10000).default(1),
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import 'dotenv/config'
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import { CategorySchema, NoOpCache,
|
|
5
|
-
|
|
6
|
-
import { getTracer, shutdownOtel } from '@reactionary/otel';
|
|
4
|
+
import { CategorySchema, NoOpCache, Session } from '@reactionary/core';
|
|
7
5
|
import { FakeCategoryProvider } from '../providers';
|
|
8
6
|
import { createAnonymousTestSession, getFakerTestConfiguration } from './test-utils';
|
|
9
7
|
describe('Faker Category Provider', () => {
|