@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.
Files changed (119) hide show
  1. package/CLAUDE.md +11 -0
  2. package/core/package.json +1 -1
  3. package/core/src/cache/cache-evaluation.interface.ts +19 -0
  4. package/core/src/cache/cache.interface.ts +38 -0
  5. package/core/src/cache/noop-cache.ts +42 -0
  6. package/core/src/cache/redis-cache.ts +55 -22
  7. package/core/src/client/client-builder.ts +63 -0
  8. package/core/src/client/client.ts +27 -3
  9. package/core/src/decorators/trpc.decorators.ts +144 -0
  10. package/core/src/index.ts +6 -1
  11. package/core/src/providers/analytics.provider.ts +3 -6
  12. package/core/src/providers/base.provider.ts +13 -63
  13. package/core/src/providers/cart.provider.ts +10 -6
  14. package/core/src/providers/identity.provider.ts +8 -5
  15. package/core/src/providers/inventory.provider.ts +5 -6
  16. package/core/src/providers/price.provider.ts +6 -6
  17. package/core/src/providers/product.provider.ts +6 -6
  18. package/core/src/providers/search.provider.ts +6 -6
  19. package/core/src/schemas/mutations/base.mutation.ts +0 -1
  20. package/core/src/schemas/mutations/cart.mutation.ts +0 -6
  21. package/core/src/schemas/mutations/identity.mutation.ts +0 -5
  22. package/core/src/schemas/mutations/product.mutation.ts +0 -1
  23. package/core/src/schemas/queries/base.query.ts +0 -1
  24. package/core/src/schemas/queries/cart.query.ts +1 -3
  25. package/core/src/schemas/queries/identity.query.ts +1 -3
  26. package/core/src/schemas/queries/inventory.query.ts +0 -1
  27. package/core/src/schemas/queries/price.query.ts +0 -3
  28. package/core/src/schemas/queries/product.query.ts +2 -7
  29. package/core/src/schemas/queries/search.query.ts +0 -3
  30. package/examples/node/package.json +1 -5
  31. package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +97 -0
  32. package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +84 -0
  33. package/examples/node/src/basic/basic-node-setup.spec.ts +40 -0
  34. package/otel/src/index.ts +3 -0
  35. package/otel/src/trace-decorator.ts +246 -0
  36. package/package.json +2 -1
  37. package/providers/algolia/src/core/initialize.ts +11 -9
  38. package/providers/algolia/src/providers/product.provider.ts +44 -11
  39. package/providers/algolia/src/providers/search.provider.ts +47 -66
  40. package/providers/commercetools/src/core/client.ts +0 -1
  41. package/providers/commercetools/src/core/initialize.ts +28 -24
  42. package/providers/commercetools/src/providers/cart.provider.ts +58 -89
  43. package/providers/commercetools/src/providers/identity.provider.ts +34 -50
  44. package/providers/commercetools/src/providers/inventory.provider.ts +16 -38
  45. package/providers/commercetools/src/providers/price.provider.ts +30 -35
  46. package/providers/commercetools/src/providers/product.provider.ts +48 -38
  47. package/providers/commercetools/src/providers/search.provider.ts +32 -47
  48. package/providers/commercetools/src/schema/capabilities.schema.ts +1 -1
  49. package/providers/fake/package.json +1 -0
  50. package/providers/fake/src/core/initialize.ts +17 -14
  51. package/providers/fake/src/index.ts +4 -0
  52. package/providers/fake/src/providers/analytics.provider.ts +19 -0
  53. package/providers/fake/src/providers/cart.provider.ts +107 -0
  54. package/providers/fake/src/providers/identity.provider.ts +78 -67
  55. package/providers/fake/src/providers/inventory.provider.ts +54 -0
  56. package/providers/fake/src/providers/price.provider.ts +60 -0
  57. package/providers/fake/src/providers/product.provider.ts +53 -49
  58. package/providers/fake/src/providers/search.provider.ts +15 -33
  59. package/providers/posthog/src/core/initialize.ts +6 -4
  60. package/trpc/__mocks__/superjson.js +25 -0
  61. package/trpc/jest.config.ts +14 -0
  62. package/trpc/package.json +2 -1
  63. package/trpc/src/client.ts +176 -0
  64. package/trpc/src/index.ts +35 -62
  65. package/trpc/src/integration.spec.ts +216 -0
  66. package/trpc/src/server.ts +123 -0
  67. package/trpc/src/transparent-client.spec.ts +160 -0
  68. package/trpc/src/types.ts +142 -0
  69. package/trpc/tsconfig.json +3 -0
  70. package/trpc/tsconfig.lib.json +2 -1
  71. package/trpc/tsconfig.spec.json +15 -0
  72. package/tsconfig.base.json +0 -2
  73. package/core/src/cache/caching-strategy.ts +0 -25
  74. package/examples/angular/e2e/example.spec.ts +0 -9
  75. package/examples/angular/eslint.config.mjs +0 -41
  76. package/examples/angular/playwright.config.ts +0 -38
  77. package/examples/angular/project.json +0 -86
  78. package/examples/angular/public/favicon.ico +0 -0
  79. package/examples/angular/src/app/app.component.html +0 -6
  80. package/examples/angular/src/app/app.component.scss +0 -22
  81. package/examples/angular/src/app/app.component.ts +0 -14
  82. package/examples/angular/src/app/app.config.ts +0 -16
  83. package/examples/angular/src/app/app.routes.ts +0 -25
  84. package/examples/angular/src/app/cart/cart.component.html +0 -4
  85. package/examples/angular/src/app/cart/cart.component.scss +0 -14
  86. package/examples/angular/src/app/cart/cart.component.ts +0 -73
  87. package/examples/angular/src/app/identity/identity.component.html +0 -6
  88. package/examples/angular/src/app/identity/identity.component.scss +0 -18
  89. package/examples/angular/src/app/identity/identity.component.ts +0 -49
  90. package/examples/angular/src/app/product/product.component.html +0 -14
  91. package/examples/angular/src/app/product/product.component.scss +0 -11
  92. package/examples/angular/src/app/product/product.component.ts +0 -42
  93. package/examples/angular/src/app/search/search.component.html +0 -35
  94. package/examples/angular/src/app/search/search.component.scss +0 -129
  95. package/examples/angular/src/app/search/search.component.ts +0 -50
  96. package/examples/angular/src/app/services/product.service.ts +0 -35
  97. package/examples/angular/src/app/services/search.service.ts +0 -48
  98. package/examples/angular/src/app/services/trpc.client.ts +0 -27
  99. package/examples/angular/src/index.html +0 -13
  100. package/examples/angular/src/main.ts +0 -7
  101. package/examples/angular/src/styles.scss +0 -17
  102. package/examples/angular/src/test-setup.ts +0 -6
  103. package/examples/angular/tsconfig.app.json +0 -10
  104. package/examples/angular/tsconfig.editor.json +0 -6
  105. package/examples/angular/tsconfig.json +0 -32
  106. package/examples/node/src/initialize-algolia.spec.ts +0 -29
  107. package/examples/node/src/initialize-commercetools.spec.ts +0 -31
  108. package/examples/node/src/initialize-extended-providers.spec.ts +0 -38
  109. package/examples/node/src/initialize-mixed-providers.spec.ts +0 -36
  110. package/examples/node/src/providers/custom-algolia-product.provider.ts +0 -18
  111. package/examples/node/src/schemas/custom-product.schema.ts +0 -8
  112. package/examples/trpc-node/.env.example +0 -52
  113. package/examples/trpc-node/eslint.config.mjs +0 -3
  114. package/examples/trpc-node/project.json +0 -61
  115. package/examples/trpc-node/src/assets/.gitkeep +0 -0
  116. package/examples/trpc-node/src/main.ts +0 -59
  117. package/examples/trpc-node/src/router-instance.ts +0 -52
  118. package/examples/trpc-node/tsconfig.app.json +0 -9
  119. 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;
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "module": "commonjs",
6
- "types": ["node"]
7
- },
8
- "include": ["src/**/*.ts"]
9
- }
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "files": [],
4
- "include": [],
5
- "references": [
6
- {
7
- "path": "./tsconfig.app.json"
8
- }
9
- ],
10
- "compilerOptions": {
11
- "esModuleInterop": true
12
- }
13
- }