@reactionary/source 0.0.30 → 0.0.32
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/CLAUDE.md +11 -0
- package/core/package.json +1 -1
- package/core/src/cache/cache-evaluation.interface.ts +19 -0
- package/core/src/cache/cache.interface.ts +38 -0
- package/core/src/cache/noop-cache.ts +42 -0
- package/core/src/cache/redis-cache.ts +55 -22
- package/core/src/client/client-builder.ts +63 -0
- package/core/src/client/client.ts +27 -3
- package/core/src/decorators/trpc.decorators.ts +144 -0
- package/core/src/index.ts +6 -1
- package/core/src/providers/analytics.provider.ts +3 -6
- package/core/src/providers/base.provider.ts +13 -63
- package/core/src/providers/cart.provider.ts +10 -6
- package/core/src/providers/identity.provider.ts +8 -5
- package/core/src/providers/inventory.provider.ts +5 -6
- package/core/src/providers/price.provider.ts +6 -6
- package/core/src/providers/product.provider.ts +6 -6
- package/core/src/providers/search.provider.ts +6 -6
- package/core/src/schemas/mutations/base.mutation.ts +0 -1
- package/core/src/schemas/mutations/cart.mutation.ts +0 -6
- package/core/src/schemas/mutations/identity.mutation.ts +0 -5
- package/core/src/schemas/mutations/product.mutation.ts +0 -1
- package/core/src/schemas/queries/base.query.ts +0 -1
- package/core/src/schemas/queries/cart.query.ts +1 -3
- package/core/src/schemas/queries/identity.query.ts +1 -3
- package/core/src/schemas/queries/inventory.query.ts +0 -1
- package/core/src/schemas/queries/price.query.ts +0 -3
- package/core/src/schemas/queries/product.query.ts +2 -7
- package/core/src/schemas/queries/search.query.ts +0 -3
- package/examples/node/package.json +1 -5
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +97 -0
- package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +84 -0
- package/examples/node/src/basic/basic-node-setup.spec.ts +40 -0
- package/otel/src/index.ts +3 -0
- package/otel/src/trace-decorator.ts +246 -0
- package/package.json +2 -1
- package/providers/algolia/src/core/initialize.ts +11 -9
- package/providers/algolia/src/providers/product.provider.ts +44 -11
- package/providers/algolia/src/providers/search.provider.ts +47 -66
- package/providers/commercetools/src/core/client.ts +0 -1
- package/providers/commercetools/src/core/initialize.ts +28 -24
- package/providers/commercetools/src/providers/cart.provider.ts +58 -89
- package/providers/commercetools/src/providers/identity.provider.ts +34 -50
- package/providers/commercetools/src/providers/inventory.provider.ts +16 -38
- package/providers/commercetools/src/providers/price.provider.ts +30 -35
- package/providers/commercetools/src/providers/product.provider.ts +48 -38
- package/providers/commercetools/src/providers/search.provider.ts +32 -47
- package/providers/commercetools/src/schema/capabilities.schema.ts +1 -1
- package/providers/fake/package.json +1 -0
- package/providers/fake/src/core/initialize.ts +17 -14
- package/providers/fake/src/index.ts +4 -0
- package/providers/fake/src/providers/analytics.provider.ts +19 -0
- package/providers/fake/src/providers/cart.provider.ts +107 -0
- package/providers/fake/src/providers/identity.provider.ts +78 -67
- package/providers/fake/src/providers/inventory.provider.ts +54 -0
- package/providers/fake/src/providers/price.provider.ts +60 -0
- package/providers/fake/src/providers/product.provider.ts +53 -49
- package/providers/fake/src/providers/search.provider.ts +15 -33
- package/providers/posthog/src/core/initialize.ts +6 -4
- package/trpc/__mocks__/superjson.js +25 -0
- package/trpc/jest.config.ts +14 -0
- package/trpc/package.json +2 -1
- package/trpc/src/client.ts +176 -0
- package/trpc/src/index.ts +35 -62
- package/trpc/src/integration.spec.ts +216 -0
- package/trpc/src/server.ts +123 -0
- package/trpc/src/transparent-client.spec.ts +160 -0
- package/trpc/src/types.ts +142 -0
- package/trpc/tsconfig.json +3 -0
- package/trpc/tsconfig.lib.json +2 -1
- package/trpc/tsconfig.spec.json +15 -0
- package/tsconfig.base.json +0 -2
- package/core/src/cache/caching-strategy.ts +0 -25
- package/examples/angular/e2e/example.spec.ts +0 -9
- package/examples/angular/eslint.config.mjs +0 -41
- package/examples/angular/playwright.config.ts +0 -38
- package/examples/angular/project.json +0 -86
- package/examples/angular/public/favicon.ico +0 -0
- package/examples/angular/src/app/app.component.html +0 -6
- package/examples/angular/src/app/app.component.scss +0 -22
- package/examples/angular/src/app/app.component.ts +0 -14
- package/examples/angular/src/app/app.config.ts +0 -16
- package/examples/angular/src/app/app.routes.ts +0 -25
- package/examples/angular/src/app/cart/cart.component.html +0 -4
- package/examples/angular/src/app/cart/cart.component.scss +0 -14
- package/examples/angular/src/app/cart/cart.component.ts +0 -73
- package/examples/angular/src/app/identity/identity.component.html +0 -6
- package/examples/angular/src/app/identity/identity.component.scss +0 -18
- package/examples/angular/src/app/identity/identity.component.ts +0 -49
- package/examples/angular/src/app/product/product.component.html +0 -14
- package/examples/angular/src/app/product/product.component.scss +0 -11
- package/examples/angular/src/app/product/product.component.ts +0 -42
- package/examples/angular/src/app/search/search.component.html +0 -35
- package/examples/angular/src/app/search/search.component.scss +0 -129
- package/examples/angular/src/app/search/search.component.ts +0 -50
- package/examples/angular/src/app/services/product.service.ts +0 -35
- package/examples/angular/src/app/services/search.service.ts +0 -48
- package/examples/angular/src/app/services/trpc.client.ts +0 -27
- package/examples/angular/src/index.html +0 -13
- package/examples/angular/src/main.ts +0 -7
- package/examples/angular/src/styles.scss +0 -17
- package/examples/angular/src/test-setup.ts +0 -6
- package/examples/angular/tsconfig.app.json +0 -10
- package/examples/angular/tsconfig.editor.json +0 -6
- package/examples/angular/tsconfig.json +0 -32
- package/examples/node/src/initialize-algolia.spec.ts +0 -29
- package/examples/node/src/initialize-commercetools.spec.ts +0 -31
- package/examples/node/src/initialize-extended-providers.spec.ts +0 -38
- package/examples/node/src/initialize-mixed-providers.spec.ts +0 -36
- package/examples/node/src/providers/custom-algolia-product.provider.ts +0 -18
- package/examples/node/src/schemas/custom-product.schema.ts +0 -8
- package/examples/trpc-node/.env.example +0 -52
- package/examples/trpc-node/eslint.config.mjs +0 -3
- package/examples/trpc-node/project.json +0 -61
- package/examples/trpc-node/src/assets/.gitkeep +0 -0
- package/examples/trpc-node/src/main.ts +0 -59
- package/examples/trpc-node/src/router-instance.ts +0 -52
- package/examples/trpc-node/tsconfig.app.json +0 -9
- package/examples/trpc-node/tsconfig.json +0 -13
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import cors from 'cors';
|
|
3
|
-
import * as trpcExpress from '@trpc/server/adapters/express';
|
|
4
|
-
import { Client } from '@reactionary/core';
|
|
5
|
-
import session from 'express-session';
|
|
6
|
-
import { CreateExpressContextOptions } from '@trpc/server/adapters/express';
|
|
7
|
-
import { Redis } from 'ioredis';
|
|
8
|
-
import { RedisStore } from 'connect-redis';
|
|
9
|
-
import { client, mergedRouter } from './router-instance';
|
|
10
|
-
|
|
11
|
-
const app = express();
|
|
12
|
-
|
|
13
|
-
export function createContext(client: Client) {
|
|
14
|
-
return async ({ req, res, info }: CreateExpressContextOptions) => {
|
|
15
|
-
const session = (req as any).session || {};
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
session,
|
|
19
|
-
client,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
app.use(
|
|
25
|
-
cors({
|
|
26
|
-
origin: 'http://localhost:4200',
|
|
27
|
-
credentials: true,
|
|
28
|
-
})
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const redis = new Redis(process.env['SESSION_STORE_REDIS_CONNECTION']);
|
|
32
|
-
|
|
33
|
-
const store = new RedisStore({
|
|
34
|
-
client: redis,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
app.use(
|
|
38
|
-
session({
|
|
39
|
-
store: store,
|
|
40
|
-
secret: process.env['SESSION_STORE_SECRET'],
|
|
41
|
-
cookie: {},
|
|
42
|
-
resave: true,
|
|
43
|
-
saveUninitialized: true,
|
|
44
|
-
})
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
app.use(
|
|
48
|
-
'/trpc',
|
|
49
|
-
trpcExpress.createExpressMiddleware({
|
|
50
|
-
router: mergedRouter,
|
|
51
|
-
createContext: createContext(client),
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const server = app.listen(3000, () => {
|
|
56
|
-
console.log('Server started on http://localhost:3000');
|
|
57
|
-
// OpenTelemetry automatically initializes based on OTEL_* environment variables
|
|
58
|
-
});
|
|
59
|
-
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { buildClient } from "@reactionary/core";
|
|
2
|
-
import { withAlgoliaCapabilities } from "@reactionary/provider-algolia";
|
|
3
|
-
import { withCommercetoolsCapabilities } from "@reactionary/provider-commercetools";
|
|
4
|
-
import { withFakeCapabilities } from "@reactionary/provider-fake";
|
|
5
|
-
import { withPosthogCapabilities } from "@reactionary/provider-posthog";
|
|
6
|
-
import { createTRPCRouter } from "@reactionary/trpc";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* TODO: This would likely be cleaner with:
|
|
10
|
-
* - implicit processing of parameters from the environment
|
|
11
|
-
* - as a builder-pattern
|
|
12
|
-
*/
|
|
13
|
-
export const client = buildClient([
|
|
14
|
-
withAlgoliaCapabilities(
|
|
15
|
-
{
|
|
16
|
-
apiKey: process.env['ALGOLIA_API_KEY'] || '',
|
|
17
|
-
appId: process.env['ALGOLIA_APP_ID'] || '',
|
|
18
|
-
indexName: process.env['ALGOLIA_INDEX'] || '',
|
|
19
|
-
},
|
|
20
|
-
{ search: true, analytics: true }
|
|
21
|
-
),
|
|
22
|
-
withCommercetoolsCapabilities(
|
|
23
|
-
{
|
|
24
|
-
apiUrl: process.env['COMMERCETOOLS_API_URL'] || '',
|
|
25
|
-
authUrl: process.env['COMMERCETOOLS_AUTH_URL'] || '',
|
|
26
|
-
clientId: process.env['COMMERCETOOLS_CLIENT_ID'] || '',
|
|
27
|
-
clientSecret: process.env['COMMERCETOOLS_CLIENT_SECRET'] || '',
|
|
28
|
-
projectKey: process.env['COMMERCETOOLS_PROJECT_KEY'] || '',
|
|
29
|
-
},
|
|
30
|
-
{ product: true, identity: true, cart: true, inventory: true, price: true }
|
|
31
|
-
),
|
|
32
|
-
withFakeCapabilities(
|
|
33
|
-
{
|
|
34
|
-
jitter: {
|
|
35
|
-
mean: 300,
|
|
36
|
-
deviation: 100,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{ search: false, product: false }
|
|
40
|
-
),
|
|
41
|
-
withPosthogCapabilities(
|
|
42
|
-
{
|
|
43
|
-
apiKey: process.env['POSTHOG_API_KEY'] || '',
|
|
44
|
-
host: process.env['POSTHOG_HOST'] || '',
|
|
45
|
-
},
|
|
46
|
-
{ analytics: true }
|
|
47
|
-
),
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
export const mergedRouter = createTRPCRouter(client);
|
|
51
|
-
|
|
52
|
-
export type RouterType = typeof mergedRouter;
|