@reactionary/source 0.0.37 → 0.0.39
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 +10 -0
- package/.github/workflows/pull-request.yml +5 -3
- package/core/package.json +1 -2
- package/core/src/client/client.ts +4 -2
- package/core/src/index.ts +3 -9
- package/core/src/providers/analytics.provider.ts +6 -1
- package/core/src/providers/base.provider.ts +33 -3
- package/core/src/providers/cart.provider.ts +7 -1
- package/core/src/providers/category.provider.ts +91 -0
- package/core/src/providers/identity.provider.ts +5 -1
- package/core/src/providers/inventory.provider.ts +4 -0
- package/core/src/providers/price.provider.ts +54 -0
- package/core/src/providers/product.provider.ts +4 -0
- package/core/src/providers/search.provider.ts +6 -0
- package/core/src/schemas/capabilities.schema.ts +3 -2
- package/core/src/schemas/models/base.model.ts +42 -1
- package/core/src/schemas/models/cart.model.ts +27 -3
- package/core/src/schemas/models/category.model.ts +23 -0
- package/core/src/schemas/models/identifiers.model.ts +29 -1
- package/core/src/schemas/models/inventory.model.ts +6 -2
- package/core/src/schemas/models/price.model.ts +11 -3
- package/core/src/schemas/models/search.model.ts +4 -2
- package/core/src/schemas/queries/category.query.ts +32 -0
- package/core/src/schemas/queries/index.ts +9 -0
- package/core/src/schemas/queries/inventory.query.ts +18 -3
- package/core/src/schemas/session.schema.ts +13 -2
- package/examples/next/.swcrc +30 -0
- package/examples/next/eslint.config.mjs +21 -0
- package/examples/next/index.d.ts +6 -0
- package/examples/next/next-env.d.ts +5 -0
- package/examples/next/next.config.js +20 -0
- package/examples/next/project.json +9 -0
- 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 +18 -0
- package/examples/next/src/app/page.module.scss +2 -0
- package/examples/next/src/app/page.tsx +51 -0
- package/examples/next/src/instrumentation.ts +9 -0
- package/examples/next/tsconfig.json +44 -0
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +0 -1
- package/examples/node/src/basic/basic-node-setup.spec.ts +0 -1
- package/otel/README.md +152 -172
- package/otel/package.json +0 -1
- package/otel/src/index.ts +15 -5
- package/otel/src/metrics.ts +3 -3
- package/otel/src/test/otel.spec.ts +8 -0
- package/otel/src/trace-decorator.ts +87 -108
- package/otel/src/tracer.ts +3 -3
- package/package.json +2 -1
- package/providers/commercetools/package.json +1 -0
- package/providers/commercetools/src/core/initialize.ts +7 -3
- package/providers/commercetools/src/providers/cart.provider.ts +84 -8
- package/providers/commercetools/src/providers/category.provider.ts +244 -0
- package/providers/commercetools/src/providers/index.ts +7 -0
- package/providers/commercetools/src/providers/inventory.provider.ts +31 -14
- package/providers/commercetools/src/providers/price.provider.ts +74 -18
- package/providers/commercetools/src/providers/product.provider.ts +19 -15
- package/providers/commercetools/src/providers/search.provider.ts +9 -7
- package/providers/commercetools/src/schema/capabilities.schema.ts +2 -1
- package/providers/commercetools/src/schema/configuration.schema.ts +1 -1
- package/providers/commercetools/src/test/cart.provider.spec.ts +119 -0
- package/providers/commercetools/src/test/category.provider.spec.ts +180 -0
- package/providers/commercetools/src/test/price.provider.spec.ts +80 -0
- package/providers/commercetools/src/test/product.provider.spec.ts +29 -14
- package/providers/commercetools/src/test/search.provider.spec.ts +51 -9
- package/providers/commercetools/src/test/test-utils.ts +35 -0
- package/providers/commercetools/tsconfig.lib.json +1 -1
- package/providers/fake/jest.config.ts +10 -0
- package/providers/fake/src/core/initialize.ts +15 -1
- package/providers/fake/src/index.ts +2 -9
- package/providers/fake/src/providers/cart.provider.ts +74 -15
- package/providers/fake/src/providers/category.provider.ts +152 -0
- package/providers/fake/src/providers/index.ts +8 -0
- package/providers/fake/src/providers/inventory.provider.ts +23 -9
- package/providers/fake/src/providers/price.provider.ts +46 -6
- package/providers/fake/src/providers/search.provider.ts +13 -4
- package/providers/fake/src/schema/capabilities.schema.ts +4 -2
- package/providers/fake/src/schema/configuration.schema.ts +5 -0
- package/providers/fake/src/test/cart.provider.spec.ts +126 -0
- package/providers/fake/src/test/category.provider.spec.ts +134 -0
- package/providers/fake/src/test/price.provider.spec.ts +80 -0
- package/providers/fake/src/test/test-utils.ts +42 -0
- package/providers/fake/tsconfig.json +4 -0
- package/providers/fake/tsconfig.lib.json +3 -1
- package/providers/fake/tsconfig.spec.json +16 -0
- package/trpc/package.json +1 -2
- package/trpc/src/client.ts +1 -3
- package/trpc/src/integration.spec.ts +16 -10
- package/trpc/src/transparent-client.spec.ts +23 -17
- package/tsconfig.base.json +2 -0
- package/core/src/decorators/trpc.decorators.ts +0 -144
- package/otel/src/sdk.ts +0 -57
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './analytics.query';
|
|
2
|
+
export * from './base.query';
|
|
3
|
+
export * from './cart.query';
|
|
4
|
+
export * from './category.query';
|
|
5
|
+
export * from './identity.query';
|
|
6
|
+
export * from './inventory.query';
|
|
7
|
+
export * from './price.query';
|
|
8
|
+
export * from './product.query';
|
|
9
|
+
export * from './search.query';
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseQuerySchema } from './base.query';
|
|
3
|
+
import { ProductIdentifier, ProductIdentifierSchema } from '../models/identifiers.model';
|
|
3
4
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
5
|
+
export const InventoryQueryBySKUSchema = BaseQuerySchema.extend({
|
|
6
|
+
query: z.literal('sku'),
|
|
7
|
+
sku: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
|
|
6
8
|
});
|
|
7
9
|
|
|
8
|
-
export
|
|
10
|
+
export const InventoryQuerySchema = z.union([InventoryQueryBySKUSchema]);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
//export type InventoryQuery = z.infer<typeof InventoryQuerySchema>;
|
|
15
|
+
export type InventoryQueryBySKU = z.infer<typeof InventoryQueryBySKUSchema>;
|
|
16
|
+
|
|
17
|
+
export interface InventoryQueries {
|
|
18
|
+
"sku": { sku: ProductIdentifier }
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type InventoryQuery = {
|
|
22
|
+
[K in keyof InventoryQueries]: { type: K } & InventoryQueries[K];
|
|
23
|
+
}[keyof InventoryQueries];
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { IdentitySchema } from './models/identity.model';
|
|
3
|
+
import { WebStoreIdentifierSchema } from './models/identifiers.model';
|
|
4
|
+
import { CurrencySchema } from './models/currency.model';
|
|
5
|
+
|
|
6
|
+
export const LanguageContextSchema = z.looseObject( {
|
|
7
|
+
locale: z.string().default('en-US'),
|
|
8
|
+
currencyCode: CurrencySchema.default(() => CurrencySchema.parse({})),
|
|
9
|
+
countryCode: z.string().default('US'),
|
|
10
|
+
})
|
|
3
11
|
|
|
4
12
|
export const SessionSchema = z.looseObject({
|
|
5
13
|
id: z.string(),
|
|
6
|
-
identity: IdentitySchema.default(() => IdentitySchema.parse({}))
|
|
14
|
+
identity: IdentitySchema.default(() => IdentitySchema.parse({})),
|
|
15
|
+
languageContext: LanguageContextSchema.default(() => LanguageContextSchema.parse({})),
|
|
16
|
+
storeIdentifier: WebStoreIdentifierSchema.default(() => WebStoreIdentifierSchema.parse({})),
|
|
7
17
|
});
|
|
8
18
|
|
|
9
|
-
export type Session = z.infer<typeof SessionSchema>;
|
|
19
|
+
export type Session = z.infer<typeof SessionSchema>;
|
|
20
|
+
export type LanguageContext = z.infer<typeof LanguageContextSchema>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsc": {
|
|
3
|
+
"target": "es2017",
|
|
4
|
+
"parser": {
|
|
5
|
+
"syntax": "typescript",
|
|
6
|
+
"decorators": true,
|
|
7
|
+
"dynamicImport": true
|
|
8
|
+
},
|
|
9
|
+
"transform": {
|
|
10
|
+
"decoratorMetadata": true,
|
|
11
|
+
"legacyDecorator": true
|
|
12
|
+
},
|
|
13
|
+
"keepClassNames": true,
|
|
14
|
+
"externalHelpers": true,
|
|
15
|
+
"loose": true
|
|
16
|
+
},
|
|
17
|
+
"module": {
|
|
18
|
+
"type": "commonjs"
|
|
19
|
+
},
|
|
20
|
+
"sourceMaps": true,
|
|
21
|
+
"exclude": [
|
|
22
|
+
"jest.config.ts",
|
|
23
|
+
".*\\.spec.tsx?$",
|
|
24
|
+
".*\\.test.tsx?$",
|
|
25
|
+
"./src/jest-setup.ts$",
|
|
26
|
+
"./**/jest-setup.ts$",
|
|
27
|
+
".*.js$",
|
|
28
|
+
".*.d.ts$"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import js from '@eslint/js';
|
|
5
|
+
import { fixupConfigRules } from '@eslint/compat';
|
|
6
|
+
import nx from '@nx/eslint-plugin';
|
|
7
|
+
import baseConfig from '../../eslint.config.mjs';
|
|
8
|
+
const compat = new FlatCompat({
|
|
9
|
+
baseDirectory: dirname(fileURLToPath(import.meta.url)),
|
|
10
|
+
recommendedConfig: js.configs.recommended,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default [
|
|
14
|
+
...fixupConfigRules(compat.extends('next')),
|
|
15
|
+
...fixupConfigRules(compat.extends('next/core-web-vitals')),
|
|
16
|
+
...baseConfig,
|
|
17
|
+
...nx.configs['flat/react-typescript'],
|
|
18
|
+
{
|
|
19
|
+
ignores: ['.next/**/*'],
|
|
20
|
+
},
|
|
21
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const { composePlugins, withNx } = require('@nx/next');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
|
|
8
|
+
**/
|
|
9
|
+
const nextConfig = {
|
|
10
|
+
// Use this to set Nx-specific options
|
|
11
|
+
// See: https://nx.dev/recipes/next/next-config-setup
|
|
12
|
+
nx: {},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const plugins = [
|
|
16
|
+
// Add more Next.js plugins to this list if needed.
|
|
17
|
+
withNx,
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
module.exports = composePlugins(...plugins)(nextConfig);
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import './global.css';
|
|
2
|
+
|
|
3
|
+
export const metadata = {
|
|
4
|
+
title: 'Welcome to next',
|
|
5
|
+
description: 'Generated by create-nx-workspace',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default function RootLayout({
|
|
9
|
+
children,
|
|
10
|
+
}: {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}) {
|
|
13
|
+
return (
|
|
14
|
+
<html lang="en">
|
|
15
|
+
<body>{children}</body>
|
|
16
|
+
</html>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import styles from './page.module.scss';
|
|
2
|
+
import { ClientBuilder, NoOpCache, SessionSchema } from '@reactionary/core';
|
|
3
|
+
import { withFakeCapabilities } from '@reactionary/provider-fake';
|
|
4
|
+
|
|
5
|
+
export default async function Index() {
|
|
6
|
+
const client = new ClientBuilder()
|
|
7
|
+
.withCapability(
|
|
8
|
+
withFakeCapabilities(
|
|
9
|
+
{
|
|
10
|
+
jitter: {
|
|
11
|
+
mean: 0,
|
|
12
|
+
deviation: 0,
|
|
13
|
+
},
|
|
14
|
+
seeds: {
|
|
15
|
+
product: 1,
|
|
16
|
+
search: 1,
|
|
17
|
+
category: 1,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{ search: true, product: false, identity: false }
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
.withCache(new NoOpCache())
|
|
24
|
+
.build();
|
|
25
|
+
|
|
26
|
+
const session = SessionSchema.parse({
|
|
27
|
+
id: '1234567890',
|
|
28
|
+
languageContext: {
|
|
29
|
+
countryCode: 'US',
|
|
30
|
+
languageCode: 'en',
|
|
31
|
+
currencyCode: 'USD',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const search = await client.search?.queryByTerm({
|
|
36
|
+
search: {
|
|
37
|
+
facets: [],
|
|
38
|
+
page: 0,
|
|
39
|
+
pageSize: 12,
|
|
40
|
+
term: 'glass',
|
|
41
|
+
},
|
|
42
|
+
}, session);
|
|
43
|
+
|
|
44
|
+
return <div className={styles.page}>
|
|
45
|
+
{search?.products.map((product, index) => (
|
|
46
|
+
<div key={index}>
|
|
47
|
+
{ product.name }
|
|
48
|
+
</div>
|
|
49
|
+
))}
|
|
50
|
+
</div>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"noEmit": true,
|
|
7
|
+
"emitDeclarationOnly": false,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"module": "esnext",
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"lib": [
|
|
14
|
+
"dom",
|
|
15
|
+
"dom.iterable",
|
|
16
|
+
"esnext"
|
|
17
|
+
],
|
|
18
|
+
"allowJs": true,
|
|
19
|
+
"allowSyntheticDefaultImports": true,
|
|
20
|
+
"forceConsistentCasingInFileNames": true,
|
|
21
|
+
"incremental": true,
|
|
22
|
+
"plugins": [
|
|
23
|
+
{
|
|
24
|
+
"name": "next"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"include": [
|
|
29
|
+
"**/*.js",
|
|
30
|
+
"**/*.jsx",
|
|
31
|
+
"**/*.ts",
|
|
32
|
+
"**/*.tsx",
|
|
33
|
+
"../../dist/examples/next/.next/types/**/*.ts",
|
|
34
|
+
"../../examples/next/.next/types/**/*.ts",
|
|
35
|
+
"next-env.d.ts",
|
|
36
|
+
".next/types/**/*.ts"
|
|
37
|
+
],
|
|
38
|
+
"exclude": [
|
|
39
|
+
"node_modules",
|
|
40
|
+
"jest.config.ts",
|
|
41
|
+
"**/*.spec.ts",
|
|
42
|
+
"**/*.test.ts"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -68,7 +68,6 @@ describe('basic node provider extension (models)', () => {
|
|
|
68
68
|
it('should get the enabled set of capabilities across providers', async () => {
|
|
69
69
|
expect(client.product).toBeDefined();
|
|
70
70
|
expect(client.search).toBeDefined();
|
|
71
|
-
expect(client.identity).toBeUndefined();
|
|
72
71
|
});
|
|
73
72
|
|
|
74
73
|
it('should be able to call the regular methods and get the default value', async () => {
|
|
@@ -26,7 +26,6 @@ describe('basic node setup', () => {
|
|
|
26
26
|
it('should only get back the enabled capabilities', async () => {
|
|
27
27
|
expect(client.product).toBeDefined();
|
|
28
28
|
expect(client.search).toBeDefined();
|
|
29
|
-
expect(client.identity).toBeUndefined();
|
|
30
29
|
});
|
|
31
30
|
|
|
32
31
|
it('should be able to call the enabled capabilities', async () => {
|