@reactionary/source 0.0.48 → 0.0.52
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 +4 -3
- package/core/src/cache/cache.interface.ts +1 -1
- package/core/src/cache/memory-cache.ts +2 -2
- package/core/src/cache/noop-cache.ts +1 -1
- package/core/src/cache/redis-cache.ts +1 -1
- package/core/src/client/client-builder.ts +4 -4
- package/core/src/client/client.ts +12 -12
- package/core/src/decorators/reactionary.decorator.ts +22 -2
- package/core/src/index.ts +14 -14
- package/core/src/initialization.ts +1 -1
- package/core/src/providers/analytics.provider.ts +2 -2
- package/core/src/providers/base.provider.ts +5 -5
- package/core/src/providers/cart.provider.ts +6 -6
- package/core/src/providers/category.provider.ts +4 -9
- package/core/src/providers/checkout.provider.ts +156 -0
- package/core/src/providers/identity.provider.ts +5 -5
- package/core/src/providers/index.ts +13 -12
- package/core/src/providers/inventory.provider.ts +4 -4
- package/core/src/providers/order.provider.ts +31 -0
- package/core/src/providers/price.provider.ts +5 -5
- package/core/src/providers/product.provider.ts +5 -5
- package/core/src/providers/profile.provider.ts +5 -5
- package/core/src/providers/search.provider.ts +4 -4
- package/core/src/providers/store.provider.ts +4 -4
- package/core/src/schemas/capabilities.schema.ts +2 -1
- package/core/src/schemas/models/analytics.model.ts +1 -1
- package/core/src/schemas/models/cart.model.ts +3 -28
- package/core/src/schemas/models/category.model.ts +2 -2
- package/core/src/schemas/models/checkout.model.ts +66 -0
- package/core/src/schemas/models/cost.model.ts +21 -0
- package/core/src/schemas/models/identifiers.model.ts +23 -2
- package/core/src/schemas/models/identity.model.ts +8 -5
- package/core/src/schemas/models/index.ts +19 -15
- package/core/src/schemas/models/inventory.model.ts +2 -2
- package/core/src/schemas/models/order.model.ts +46 -0
- package/core/src/schemas/models/payment.model.ts +5 -12
- package/core/src/schemas/models/price.model.ts +3 -3
- package/core/src/schemas/models/product.model.ts +6 -3
- package/core/src/schemas/models/profile.model.ts +2 -2
- package/core/src/schemas/models/search.model.ts +2 -3
- package/core/src/schemas/models/shipping-method.model.ts +34 -3
- package/core/src/schemas/models/store.model.ts +2 -2
- package/core/src/schemas/mutations/analytics.mutation.ts +2 -2
- package/core/src/schemas/mutations/cart.mutation.ts +5 -5
- package/core/src/schemas/mutations/checkout.mutation.ts +50 -0
- package/core/src/schemas/mutations/identity.mutation.ts +1 -1
- package/core/src/schemas/mutations/index.ts +10 -10
- package/core/src/schemas/mutations/profile.mutation.ts +1 -1
- package/core/src/schemas/queries/cart.query.ts +2 -2
- package/core/src/schemas/queries/category.query.ts +3 -3
- package/core/src/schemas/queries/checkout.query.ts +22 -0
- package/core/src/schemas/queries/identity.query.ts +1 -1
- package/core/src/schemas/queries/index.ts +13 -12
- package/core/src/schemas/queries/inventory.query.ts +2 -2
- package/core/src/schemas/queries/order.query.ts +9 -0
- package/core/src/schemas/queries/price.query.ts +2 -2
- package/core/src/schemas/queries/product.query.ts +9 -2
- package/core/src/schemas/queries/profile.query.ts +1 -1
- package/core/src/schemas/queries/search.query.ts +2 -2
- package/core/src/schemas/queries/store.query.ts +1 -1
- package/core/src/schemas/session.schema.ts +3 -3
- package/core/tsconfig.json +3 -2
- package/examples/next/next.config.js +17 -6
- package/examples/next/src/app/page.tsx +1 -2
- package/examples/node/package.json +2 -1
- package/examples/node/src/basic/basic-node-setup.spec.ts +1 -1
- package/examples/node/tsconfig.json +2 -1
- package/examples/node/tsconfig.spec.json +3 -2
- package/package.json +3 -1
- package/providers/algolia/package.json +2 -1
- package/providers/algolia/src/core/initialize.ts +5 -5
- package/providers/algolia/src/index.ts +5 -5
- package/providers/algolia/src/providers/product.provider.ts +8 -2
- package/providers/algolia/src/providers/search.provider.ts +1 -1
- package/providers/algolia/src/test/search.provider.spec.ts +1 -1
- package/providers/algolia/tsconfig.json +2 -1
- package/providers/algolia/tsconfig.spec.json +3 -2
- package/providers/commercetools/{jest.config.ts → jest.config.cjs} +1 -1
- package/providers/commercetools/package.json +3 -2
- package/providers/commercetools/src/core/client.ts +63 -32
- package/providers/commercetools/src/core/initialize.ts +20 -16
- package/providers/commercetools/src/index.ts +10 -10
- package/providers/commercetools/src/providers/cart.provider.ts +14 -19
- package/providers/commercetools/src/providers/category.provider.ts +3 -12
- package/providers/commercetools/src/providers/checkout.provider.ts +644 -0
- package/providers/commercetools/src/providers/identity.provider.ts +8 -8
- package/providers/commercetools/src/providers/index.ts +12 -9
- package/providers/commercetools/src/providers/inventory.provider.ts +2 -4
- package/providers/commercetools/src/providers/order.provider.ts +163 -0
- package/providers/commercetools/src/providers/price.provider.ts +3 -3
- package/providers/commercetools/src/providers/product.provider.ts +24 -6
- package/providers/commercetools/src/providers/profile.provider.ts +2 -2
- package/providers/commercetools/src/providers/search.provider.ts +3 -5
- package/providers/commercetools/src/providers/store.provider.ts +3 -3
- package/providers/commercetools/src/schema/capabilities.schema.ts +2 -1
- package/providers/commercetools/src/schema/commercetools.schema.ts +7 -5
- package/providers/commercetools/src/schema/configuration.schema.ts +2 -0
- package/providers/commercetools/src/test/cart.provider.spec.ts +24 -4
- package/providers/commercetools/src/test/category.provider.spec.ts +3 -3
- package/providers/commercetools/src/test/checkout.provider.spec.ts +312 -0
- package/providers/commercetools/src/test/identity.provider.spec.ts +3 -3
- package/providers/commercetools/src/test/inventory.provider.spec.ts +2 -2
- package/providers/commercetools/src/test/price.provider.spec.ts +4 -4
- package/providers/commercetools/src/test/product.provider.spec.ts +22 -5
- package/providers/commercetools/src/test/profile.provider.spec.ts +3 -3
- package/providers/commercetools/src/test/search.provider.spec.ts +2 -2
- package/providers/commercetools/src/test/store.provider.spec.ts +2 -2
- package/providers/commercetools/src/test/test-utils.ts +14 -0
- package/providers/commercetools/tsconfig.json +2 -1
- package/providers/commercetools/tsconfig.spec.json +4 -3
- package/providers/fake/{jest.config.ts → jest.config.cjs} +1 -1
- package/providers/fake/package.json +2 -2
- package/providers/fake/src/core/initialize.ts +6 -6
- package/providers/fake/src/index.ts +4 -4
- package/providers/fake/src/providers/analytics.provider.ts +1 -1
- package/providers/fake/src/providers/cart.provider.ts +2 -2
- package/providers/fake/src/providers/category.provider.ts +7 -3
- package/providers/fake/src/providers/identity.provider.ts +1 -1
- package/providers/fake/src/providers/index.ts +9 -9
- package/providers/fake/src/providers/inventory.provider.ts +1 -1
- package/providers/fake/src/providers/price.provider.ts +1 -1
- package/providers/fake/src/providers/product.provider.ts +10 -4
- package/providers/fake/src/providers/search.provider.ts +2 -5
- package/providers/fake/src/providers/store.provider.ts +2 -3
- package/providers/fake/src/test/cart.provider.spec.ts +3 -3
- package/providers/fake/src/test/category.provider.spec.ts +2 -2
- package/providers/fake/src/test/price.provider.spec.ts +2 -2
- package/providers/fake/src/test/product.provider.spec.ts +8 -8
- package/providers/fake/src/test/test-utils.ts +1 -1
- package/providers/fake/tsconfig.json +2 -1
- package/providers/fake/tsconfig.spec.json +1 -3
- package/providers/posthog/package.json +4 -4
- package/providers/posthog/project.json +2 -2
- package/providers/posthog/src/core/initialize.ts +2 -2
- package/providers/posthog/src/index.ts +3 -3
- package/providers/posthog/tsconfig.json +2 -1
- package/tsconfig.base.json +3 -4
- package/.claude/settings.local.json +0 -28
- package/core/src/providers/cart-payment.provider.ts +0 -57
- package/core/src/schemas/mutations/cart-payment.mutation.ts +0 -21
- package/core/src/schemas/queries/cart-payment.query.ts +0 -12
- package/otel/README.md +0 -227
- package/otel/eslint.config.mjs +0 -23
- package/otel/package.json +0 -11
- package/otel/pnpm-lock.yaml +0 -805
- package/otel/project.json +0 -33
- package/otel/src/index.ts +0 -22
- package/otel/src/metrics.ts +0 -76
- package/otel/src/provider-instrumentation.ts +0 -108
- package/otel/src/test/otel.spec.ts +0 -8
- package/otel/src/trace-decorator.ts +0 -226
- package/otel/src/tracer.ts +0 -83
- package/otel/src/trpc-middleware.ts +0 -128
- package/otel/tsconfig.json +0 -23
- package/otel/tsconfig.lib.json +0 -23
- package/otel/tsconfig.spec.json +0 -28
- package/otel/vite.config.ts +0 -24
- package/providers/commercetools/src/providers/cart-payment.provider.ts +0 -193
- package/providers/commercetools/src/test/cart-payment.provider.spec.ts +0 -145
- package/trpc/README.md +0 -7
- package/trpc/__mocks__/superjson.js +0 -25
- package/trpc/eslint.config.mjs +0 -19
- package/trpc/jest.config.ts +0 -14
- package/trpc/package.json +0 -14
- package/trpc/project.json +0 -31
- package/trpc/src/client.ts +0 -175
- package/trpc/src/index.ts +0 -44
- package/trpc/src/integration.spec.ts +0 -223
- package/trpc/src/server.ts +0 -125
- package/trpc/src/test-utils.ts +0 -31
- package/trpc/src/transparent-client.spec.ts +0 -162
- package/trpc/src/types.ts +0 -144
- package/trpc/tsconfig.json +0 -16
- package/trpc/tsconfig.lib.json +0 -10
- package/trpc/tsconfig.spec.json +0 -15
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
PriceProvider,
|
|
7
7
|
} from '@reactionary/core';
|
|
8
8
|
import type z from 'zod';
|
|
9
|
-
import type { FakeConfiguration } from '../schema/configuration.schema';
|
|
9
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
10
10
|
import { base, en, Faker } from '@faker-js/faker';
|
|
11
11
|
|
|
12
12
|
export class FakePriceProvider<
|
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
type Cache as ReactinaryCache,
|
|
7
7
|
ProductProvider,
|
|
8
8
|
Reactionary,
|
|
9
|
+
type ProductQueryBySKU,
|
|
9
10
|
} from '@reactionary/core';
|
|
10
11
|
import type z from 'zod';
|
|
11
|
-
import type { FakeConfiguration } from '../schema/configuration.schema';
|
|
12
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
12
13
|
import { base, en, Faker } from '@faker-js/faker';
|
|
13
14
|
|
|
14
15
|
export class FakeProductProvider<
|
|
@@ -30,8 +31,7 @@ export class FakeProductProvider<
|
|
|
30
31
|
return this.parseSingle(payload);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
@Reactionary({})
|
|
35
35
|
public override async getBySlug(
|
|
36
36
|
payload: ProductQueryBySlug,
|
|
37
37
|
_reqCtx: RequestContext
|
|
@@ -39,7 +39,13 @@ export class FakeProductProvider<
|
|
|
39
39
|
return this.parseSingle(payload);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
@Reactionary({})
|
|
43
|
+
public override async getBySKU(payload: ProductQueryBySKU, reqCtx: RequestContext): Promise<T> {
|
|
44
|
+
return this.parseSingle(payload);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
protected override parseSingle(body: ProductQueryById | ProductQueryBySlug | ProductQueryBySKU): T {
|
|
43
49
|
const generator = new Faker({
|
|
44
50
|
seed: 42,
|
|
45
51
|
locale: [en, base],
|
|
@@ -9,10 +9,9 @@ import type {
|
|
|
9
9
|
} from '@reactionary/core';
|
|
10
10
|
import type { RequestContext, SearchQueryByTerm } from '@reactionary/core';
|
|
11
11
|
import type z from 'zod';
|
|
12
|
-
import type { FakeConfiguration } from '../schema/configuration.schema';
|
|
12
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
13
13
|
import { Faker, en, base } from '@faker-js/faker';
|
|
14
|
-
import { jitter } from '../utilities/jitter';
|
|
15
|
-
import { traced } from '@reactionary/otel';
|
|
14
|
+
import { jitter } from '../utilities/jitter.js';
|
|
16
15
|
|
|
17
16
|
export class FakeSearchProvider<
|
|
18
17
|
T extends SearchResult = SearchResult
|
|
@@ -25,7 +24,6 @@ export class FakeSearchProvider<
|
|
|
25
24
|
this.config = config;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
@traced()
|
|
29
27
|
public override async queryByTerm(
|
|
30
28
|
payload: SearchQueryByTerm,
|
|
31
29
|
_reqCtx: RequestContext
|
|
@@ -127,7 +125,6 @@ export class FakeSearchProvider<
|
|
|
127
125
|
return this.schema.parse(result);
|
|
128
126
|
}
|
|
129
127
|
|
|
130
|
-
@traced()
|
|
131
128
|
protected childFunction() {
|
|
132
129
|
const foo = 42;
|
|
133
130
|
return foo;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
Inventory,
|
|
3
2
|
Cache,
|
|
4
3
|
RequestContext,
|
|
5
4
|
StoreQueryByProximity,
|
|
6
5
|
Store,
|
|
7
6
|
} from '@reactionary/core';
|
|
8
|
-
import {
|
|
7
|
+
import { StoreProvider } from '@reactionary/core';
|
|
9
8
|
import type z from 'zod';
|
|
10
|
-
import type { FakeConfiguration } from '../schema/configuration.schema';
|
|
9
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
11
10
|
import { base, en, Faker } from '@faker-js/faker';
|
|
12
11
|
|
|
13
12
|
export class FakeStoreProvider<
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'dotenv/config';
|
|
2
2
|
import type { RequestContext} from '@reactionary/core';
|
|
3
3
|
import { CartSchema, IdentitySchema, NoOpCache, createInitialRequestContext } from '@reactionary/core';
|
|
4
|
-
import { getFakerTestConfiguration } from './test-utils';
|
|
5
|
-
import { FakeCartProvider } from '../providers/cart.provider';
|
|
6
|
-
import { FakeIdentityProvider } from '../providers';
|
|
4
|
+
import { getFakerTestConfiguration } from './test-utils.js';
|
|
5
|
+
import { FakeCartProvider } from '../providers/cart.provider.js';
|
|
6
|
+
import { FakeIdentityProvider } from '../providers/index.js';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const testData = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'dotenv/config';
|
|
2
2
|
import type { RequestContext } from '@reactionary/core';
|
|
3
3
|
import { CategorySchema, MemoryCache , createInitialRequestContext,} from '@reactionary/core';
|
|
4
|
-
import { FakeCategoryProvider } from '../providers';
|
|
5
|
-
import { getFakerTestConfiguration } from './test-utils';
|
|
4
|
+
import { FakeCategoryProvider } from '../providers/index.js';
|
|
5
|
+
import { getFakerTestConfiguration } from './test-utils.js';
|
|
6
6
|
|
|
7
7
|
describe('Faker Category Provider', () => {
|
|
8
8
|
let provider: FakeCategoryProvider;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'dotenv/config';
|
|
2
2
|
import type { RequestContext} from '@reactionary/core';
|
|
3
3
|
import { NoOpCache, PriceSchema, createInitialRequestContext } from '@reactionary/core';
|
|
4
|
-
import { getFakerTestConfiguration } from './test-utils';
|
|
5
|
-
import { FakePriceProvider } from '../providers/price.provider';
|
|
4
|
+
import { getFakerTestConfiguration } from './test-utils.js';
|
|
5
|
+
import { FakePriceProvider } from '../providers/price.provider.js';
|
|
6
6
|
|
|
7
7
|
const testData = {
|
|
8
8
|
skuWithoutTiers: 'SGB-01',
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import 'dotenv/config';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import { MemoryCache, ProductSchema } from '@reactionary/core';
|
|
5
|
-
import {
|
|
6
|
-
import { FakeProductProvider } from '../providers';
|
|
3
|
+
import type { RequestContext } from '@reactionary/core';
|
|
4
|
+
import { createInitialRequestContext, MemoryCache, ProductSchema } from '@reactionary/core';
|
|
5
|
+
import { getFakerTestConfiguration } from './test-utils.js';
|
|
6
|
+
import { FakeProductProvider } from '../providers/index.js';
|
|
7
7
|
|
|
8
8
|
describe('Fake Product Provider', () => {
|
|
9
9
|
let provider: FakeProductProvider;
|
|
10
|
-
let
|
|
10
|
+
let reqCtx: RequestContext;
|
|
11
11
|
|
|
12
12
|
beforeAll(async () => {
|
|
13
13
|
provider = new FakeProductProvider(getFakerTestConfiguration(), ProductSchema, new MemoryCache());
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
beforeEach( () => {
|
|
17
|
-
|
|
17
|
+
reqCtx = createInitialRequestContext();
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
it('should cache repeat product lookups by id', async () => {
|
|
21
|
-
const first = await provider.getById({ id: '1234' },
|
|
21
|
+
const first = await provider.getById({ id: '1234' }, reqCtx);
|
|
22
22
|
expect(first.meta.cache.hit).toBe(false);
|
|
23
23
|
|
|
24
|
-
const second = await provider.getById({ id: '1234' },
|
|
24
|
+
const second = await provider.getById({ id: '1234' }, reqCtx);
|
|
25
25
|
expect(second.meta.cache.hit).toBe(true);
|
|
26
26
|
});
|
|
27
27
|
});
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
"extends": "./tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"moduleResolution": "node10",
|
|
7
5
|
"types": ["jest", "node"]
|
|
8
6
|
},
|
|
9
7
|
"include": [
|
|
10
|
-
"jest.config.
|
|
8
|
+
"jest.config.cjs",
|
|
11
9
|
"src/**/*.test.ts",
|
|
12
10
|
"src/**/*.spec.ts",
|
|
13
11
|
"src/**/test-utils.ts",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/provider-posthog",
|
|
3
3
|
"version": "0.0.1",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"types": "./index.d.ts",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "src/index.d.ts",
|
|
7
6
|
"dependencies": {
|
|
8
7
|
"@reactionary/core": "0.0.1",
|
|
9
8
|
"zod": "4.1.9"
|
|
10
|
-
}
|
|
9
|
+
},
|
|
10
|
+
"type": "module"
|
|
11
11
|
}
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"main": "providers/posthog/src/index.ts",
|
|
21
21
|
"tsConfig": "providers/posthog/tsconfig.lib.json",
|
|
22
22
|
"assets": ["providers/posthog/*.md"],
|
|
23
|
-
"format": ["
|
|
24
|
-
"
|
|
23
|
+
"format": ["esm"],
|
|
24
|
+
"bundle": false
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"nx-release-publish": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Client, Cache } from "@reactionary/core";
|
|
2
|
-
import type { PosthogConfiguration } from "../schema/configuration.schema";
|
|
3
|
-
import type { PosthogCapabilities } from "../schema/capabilities.schema";
|
|
2
|
+
import type { PosthogConfiguration } from "../schema/configuration.schema.js";
|
|
3
|
+
import type { PosthogCapabilities } from "../schema/capabilities.schema.js";
|
|
4
4
|
|
|
5
5
|
export function withPosthogCapabilities(_configuration: PosthogConfiguration, _capabilities: PosthogCapabilities) {
|
|
6
6
|
return (_cache: Cache) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './core/initialize';
|
|
1
|
+
export * from './core/initialize.js';
|
|
2
2
|
|
|
3
|
-
export * from './schema/capabilities.schema';
|
|
4
|
-
export * from './schema/configuration.schema';
|
|
3
|
+
export * from './schema/capabilities.schema.js';
|
|
4
|
+
export * from './schema/configuration.schema.js';
|
package/tsconfig.base.json
CHANGED
|
@@ -17,15 +17,14 @@
|
|
|
17
17
|
"paths": {
|
|
18
18
|
"@reactionary/core": ["core/src/index.ts"],
|
|
19
19
|
"@reactionary/examples-node": ["examples/node/src/index.ts"],
|
|
20
|
-
"@reactionary/otel": ["otel/src/index.ts"],
|
|
21
20
|
"@reactionary/provider-algolia": ["providers/algolia/src/index.ts"],
|
|
22
21
|
"@reactionary/provider-commercetools": [
|
|
23
22
|
"providers/commercetools/src/index.ts"
|
|
24
23
|
],
|
|
25
24
|
"@reactionary/provider-fake": ["providers/fake/src/index.ts"],
|
|
26
|
-
"@reactionary/provider-posthog": ["providers/posthog/src/index.ts"]
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
"@reactionary/provider-posthog": ["providers/posthog/src/index.ts"]
|
|
26
|
+
},
|
|
27
|
+
"verbatimModuleSyntax": true
|
|
29
28
|
},
|
|
30
29
|
"exclude": ["node_modules", "tmp"]
|
|
31
30
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(npx nx build:*)",
|
|
5
|
-
"Bash(npx tsc:*)",
|
|
6
|
-
"Bash(npx nx lint:*)",
|
|
7
|
-
"Bash(npx nx test:*)",
|
|
8
|
-
"Bash(npx nx run:*)",
|
|
9
|
-
"Bash(npx ts-node:*)",
|
|
10
|
-
"Bash(npx tsx:*)",
|
|
11
|
-
"Bash(grep:*)",
|
|
12
|
-
"Bash(pnpm list:*)",
|
|
13
|
-
"Bash(npx nx affected:build:*)",
|
|
14
|
-
"Bash(npx nx affected:lint:*)",
|
|
15
|
-
"Bash(cat:*)",
|
|
16
|
-
"Bash(npx nx show projects:*)",
|
|
17
|
-
"Bash(npx nx g:*)",
|
|
18
|
-
"Bash(pnpm add:*)",
|
|
19
|
-
"Bash(npx nx show project:*)",
|
|
20
|
-
"Bash(npx nx reset:*)",
|
|
21
|
-
"WebSearch",
|
|
22
|
-
"Bash(node:*)",
|
|
23
|
-
"Bash(npm view:*)"
|
|
24
|
-
],
|
|
25
|
-
"deny": [],
|
|
26
|
-
"ask": []
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { CartPaymentInstruction } from '../schemas/models/payment.model';
|
|
2
|
-
import type { CartPaymentMutationAddPayment, CartPaymentMutationCancelPayment } from '../schemas/mutations/cart-payment.mutation';
|
|
3
|
-
import type { CartPaymentQueryByCart } from '../schemas/queries/cart-payment.query';
|
|
4
|
-
import type { RequestContext} from '../schemas/session.schema';
|
|
5
|
-
import { Session } from '../schemas/session.schema';
|
|
6
|
-
import { BaseProvider } from './base.provider';
|
|
7
|
-
|
|
8
|
-
export abstract class CartPaymentProvider<
|
|
9
|
-
T extends CartPaymentInstruction = CartPaymentInstruction
|
|
10
|
-
> extends BaseProvider<T> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Returns all payment instructions associated with a given cart, optionally filtered by status
|
|
16
|
-
*
|
|
17
|
-
* Usecase: Fetch all registered payment instructions to show on checkout page, in case you support multiple payments in your storefront,
|
|
18
|
-
* and need to show how far the user has come in the payment process. Also useful if user reloads page, or goes back to site or otherwise breaks the flow.
|
|
19
|
-
*
|
|
20
|
-
* Only returns payment instructions in status 'pending' or 'authorized'
|
|
21
|
-
* @param cartIdentifier
|
|
22
|
-
* @param session
|
|
23
|
-
*/
|
|
24
|
-
public abstract getByCartIdentifier(payload: CartPaymentQueryByCart, reqCtx: RequestContext): Promise<T[]>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Calls payment provider to set up a new payment intent. Returns whatever is needed to continue the payment process, e.g. a client secret for Stripe, or a redirect URL for PayPal.
|
|
29
|
-
*
|
|
30
|
-
* Usecase: User has filled out checkout form, and is ready to pay. You call this to get the payment process started.
|
|
31
|
-
*
|
|
32
|
-
* Note: The payment provider MAY change the cart during the payment process, so be sure to reload the cart object after this call.
|
|
33
|
-
*
|
|
34
|
-
* @param payload
|
|
35
|
-
* @param session
|
|
36
|
-
*/
|
|
37
|
-
public abstract initiatePaymentForCart(payload: CartPaymentMutationAddPayment, reqCtx: RequestContext): Promise<T>;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Cancel a payment instruction. This will typically void the payment intent in the payment provider, and set the status of the payment instruction to 'canceled'.
|
|
43
|
-
*
|
|
44
|
-
* Usecase: User has decided to cancel the payment, e.g. by going back in the checkout process, or by closing the browser window. You call this to clean up the payment instruction.
|
|
45
|
-
*
|
|
46
|
-
* Note: The payment provider MAY change the cart during the cancellation process, so be sure to reload the cart object after this call.
|
|
47
|
-
*
|
|
48
|
-
* @param payload
|
|
49
|
-
* @param session
|
|
50
|
-
* @returns
|
|
51
|
-
*/
|
|
52
|
-
public abstract cancelPaymentInstruction(payload: CartPaymentMutationCancelPayment, reqCtx: RequestContext): Promise<T>;
|
|
53
|
-
|
|
54
|
-
protected override getResourceName(): string {
|
|
55
|
-
return 'cart-payment-instruction';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type z from "zod";
|
|
2
|
-
import { CartIdentifierSchema, PaymentInstructionIdentifierSchema } from "../models/identifiers.model";
|
|
3
|
-
import { PaymentInstructionSchema } from "../models/payment.model";
|
|
4
|
-
import { BaseMutationSchema } from "./base.mutation";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const CartPaymentMutationAddPayment = BaseMutationSchema.extend({
|
|
9
|
-
paymentInstruction: PaymentInstructionSchema.omit({ meta: true, status: true, identifier: true }).required(),
|
|
10
|
-
cart: CartIdentifierSchema.required()
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export const CartPaymentMutationCancelPayment = BaseMutationSchema.extend({
|
|
14
|
-
paymentInstruction: PaymentInstructionIdentifierSchema.required(),
|
|
15
|
-
cart: CartIdentifierSchema.required()
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export type CartPaymentMutationAddPayment = z.infer<typeof CartPaymentMutationAddPayment>;
|
|
21
|
-
export type CartPaymentMutationCancelPayment = z.infer<typeof CartPaymentMutationCancelPayment>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
import { CartIdentifierSchema } from "../models/identifiers.model";
|
|
3
|
-
import { PaymentStatusSchema } from "../models/payment.model";
|
|
4
|
-
import { BaseQuerySchema } from "./base.query";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const CartPaymentQueryByCartSchema = BaseQuerySchema.extend({
|
|
8
|
-
cart: CartIdentifierSchema.required(),
|
|
9
|
-
status: z.array(PaymentStatusSchema).optional().describe('Optional status to filter payment instructions by'),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export type CartPaymentQueryByCart = z.infer<typeof CartPaymentQueryByCartSchema>;
|
package/otel/README.md
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
# @reactionary/otel
|
|
2
|
-
|
|
3
|
-
OpenTelemetry instrumentation for the Reactionary framework. Provides decorators and utilities for tracing function execution and performance monitoring.
|
|
4
|
-
|
|
5
|
-
## Important: SDK Initialization Required
|
|
6
|
-
|
|
7
|
-
This library provides **instrumentation only**. The host application is responsible for initializing the OpenTelemetry SDK. Without proper SDK initialization, traces will be created as `NonRecordingSpan` instances with zero trace/span IDs.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- **Tracing Decorators**: Automatic span creation for decorated methods
|
|
12
|
-
- **Manual Instrumentation**: Utilities for custom tracing
|
|
13
|
-
- **Framework Integration**: Built-in support for tRPC and providers
|
|
14
|
-
- **Zero Dependencies**: Only requires OpenTelemetry API
|
|
15
|
-
- **Graceful Degradation**: Works without SDK initialization (produces no-op spans)
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
pnpm add @reactionary/otel
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
**Important**: You must also install and configure the OpenTelemetry SDK in your host application.
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
### Basic Tracing with Decorators
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { traced } from '@reactionary/otel';
|
|
31
|
-
|
|
32
|
-
class MyService {
|
|
33
|
-
@traced()
|
|
34
|
-
async fetchData(id: string): Promise<Data> {
|
|
35
|
-
// This method will be automatically traced
|
|
36
|
-
return await dataSource.get(id);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@traced({
|
|
40
|
-
spanName: 'custom-operation',
|
|
41
|
-
captureResult: false
|
|
42
|
-
})
|
|
43
|
-
processData(data: Data): void {
|
|
44
|
-
// Custom span name and no result capture
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Manual Instrumentation
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
import { withSpan, getTracer } from '@reactionary/otel';
|
|
53
|
-
|
|
54
|
-
// Using withSpan helper
|
|
55
|
-
const result = await withSpan('my-operation', async (span) => {
|
|
56
|
-
span.setAttribute('operation.id', operationId);
|
|
57
|
-
return await performOperation();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Using tracer directly
|
|
61
|
-
const tracer = getTracer();
|
|
62
|
-
const span = tracer.startSpan('manual-span');
|
|
63
|
-
try {
|
|
64
|
-
// Your code here
|
|
65
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
66
|
-
} catch (error) {
|
|
67
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
68
|
-
span.recordException(error);
|
|
69
|
-
} finally {
|
|
70
|
-
span.end();
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Setting Up OpenTelemetry SDK
|
|
75
|
-
|
|
76
|
-
### Next.js Applications
|
|
77
|
-
|
|
78
|
-
1. Create an `instrumentation.ts` file in your project root:
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
// instrumentation.ts
|
|
82
|
-
export async function register() {
|
|
83
|
-
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
84
|
-
const { NodeSDK } = await import('@opentelemetry/sdk-node');
|
|
85
|
-
const { getNodeAutoInstrumentations } = await import('@opentelemetry/auto-instrumentations-node');
|
|
86
|
-
|
|
87
|
-
const sdk = new NodeSDK({
|
|
88
|
-
instrumentations: [getNodeAutoInstrumentations()],
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
sdk.start();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
2. Enable instrumentation in `next.config.js`:
|
|
97
|
-
|
|
98
|
-
```javascript
|
|
99
|
-
/** @type {import('next').NextConfig} */
|
|
100
|
-
const nextConfig = {
|
|
101
|
-
experimental: {
|
|
102
|
-
instrumentationHook: true,
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
module.exports = nextConfig;
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
3. Configure environment variables:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# .env.local
|
|
113
|
-
OTEL_SERVICE_NAME=my-nextjs-app
|
|
114
|
-
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
115
|
-
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Node.js Applications
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
// Initialize at the very beginning of your application
|
|
122
|
-
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
123
|
-
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
124
|
-
|
|
125
|
-
const sdk = new NodeSDK({
|
|
126
|
-
instrumentations: [getNodeAutoInstrumentations()],
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
sdk.start();
|
|
130
|
-
|
|
131
|
-
// Now import and use your application code
|
|
132
|
-
import './app';
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Environment Variables
|
|
136
|
-
|
|
137
|
-
The OpenTelemetry SDK can be configured using environment variables:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
# Service identification
|
|
141
|
-
OTEL_SERVICE_NAME=my-app
|
|
142
|
-
OTEL_SERVICE_VERSION=1.0.0
|
|
143
|
-
|
|
144
|
-
# OTLP Exporter (for Jaeger, etc.)
|
|
145
|
-
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
146
|
-
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
|
|
147
|
-
|
|
148
|
-
# Console exporter (for development)
|
|
149
|
-
OTEL_TRACES_EXPORTER=console
|
|
150
|
-
|
|
151
|
-
# Sampling (optional)
|
|
152
|
-
OTEL_TRACES_SAMPLER=always_on
|
|
153
|
-
|
|
154
|
-
# Debug logging
|
|
155
|
-
OTEL_LOG_LEVEL=debug
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## Troubleshooting
|
|
159
|
-
|
|
160
|
-
### ProxyTracer with NonRecordingSpan
|
|
161
|
-
|
|
162
|
-
If you see logs like:
|
|
163
|
-
```
|
|
164
|
-
tracer: ProxyTracer { _provider: ProxyTracerProvider {} }
|
|
165
|
-
ending span: NonRecordingSpan { _spanContext: { traceId: '00000000000000000000000000000000' } }
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
This means the OpenTelemetry SDK has not been initialized. Ensure you have:
|
|
169
|
-
1. Created an `instrumentation.ts` file (Next.js)
|
|
170
|
-
2. Initialized the SDK at application startup (Node.js)
|
|
171
|
-
3. Set the required environment variables
|
|
172
|
-
|
|
173
|
-
### Missing Traces
|
|
174
|
-
|
|
175
|
-
If the decorator is being applied but you don't see traces:
|
|
176
|
-
1. Verify the OTEL exporter is configured correctly
|
|
177
|
-
2. Check that your tracing backend is running
|
|
178
|
-
3. Ensure sampling is enabled (`OTEL_TRACES_SAMPLER=always_on`)
|
|
179
|
-
|
|
180
|
-
## API Reference
|
|
181
|
-
|
|
182
|
-
### Decorators
|
|
183
|
-
|
|
184
|
-
#### `@traced(options?)`
|
|
185
|
-
|
|
186
|
-
Decorates a method to automatically create spans for its execution.
|
|
187
|
-
|
|
188
|
-
**Options:**
|
|
189
|
-
- `captureArgs?: boolean` - Capture function arguments (default: true)
|
|
190
|
-
- `captureResult?: boolean` - Capture return value (default: true)
|
|
191
|
-
- `spanName?: string` - Custom span name (default: ClassName.methodName)
|
|
192
|
-
- `spanKind?: SpanKind` - OpenTelemetry span kind (default: INTERNAL)
|
|
193
|
-
|
|
194
|
-
### Utility Functions
|
|
195
|
-
|
|
196
|
-
- `getTracer(): Tracer` - Get the library's tracer instance
|
|
197
|
-
- `startSpan(name, options?, context?): Span` - Start a new span
|
|
198
|
-
- `withSpan<T>(name, fn, options?): Promise<T>` - Execute function within a span
|
|
199
|
-
- `setSpanAttributes(span, attributes): void` - Set multiple span attributes
|
|
200
|
-
- `createChildSpan(parent, name, options?): Span` - Create child span
|
|
201
|
-
|
|
202
|
-
### Constants
|
|
203
|
-
|
|
204
|
-
- `SpanKind` - OpenTelemetry span kinds
|
|
205
|
-
- `SpanStatusCode` - OpenTelemetry span status codes
|
|
206
|
-
|
|
207
|
-
## Examples
|
|
208
|
-
|
|
209
|
-
### Console Output (Development)
|
|
210
|
-
```bash
|
|
211
|
-
OTEL_SERVICE_NAME=my-service-dev
|
|
212
|
-
OTEL_TRACES_EXPORTER=console
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Jaeger (Local)
|
|
216
|
-
```bash
|
|
217
|
-
OTEL_SERVICE_NAME=my-service
|
|
218
|
-
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
219
|
-
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### Honeycomb (Production)
|
|
223
|
-
```bash
|
|
224
|
-
OTEL_SERVICE_NAME=my-service
|
|
225
|
-
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io
|
|
226
|
-
OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=your-api-key
|
|
227
|
-
```
|
package/otel/eslint.config.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import baseConfig from '../eslint.config.mjs';
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
...baseConfig,
|
|
5
|
-
{
|
|
6
|
-
files: ['**/*.json'],
|
|
7
|
-
rules: {
|
|
8
|
-
'@nx/dependency-checks': [
|
|
9
|
-
'error',
|
|
10
|
-
{
|
|
11
|
-
ignoredFiles: [
|
|
12
|
-
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
13
|
-
'{projectRoot}/esbuild.config.{js,ts,mjs,mts}',
|
|
14
|
-
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
languageOptions: {
|
|
20
|
-
parser: await import('jsonc-eslint-parser'),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
];
|
package/otel/package.json
DELETED