@reactionary/source 0.0.31 → 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 (110) hide show
  1. package/core/package.json +1 -1
  2. package/core/src/client/client-builder.ts +63 -0
  3. package/core/src/decorators/trpc.decorators.ts +144 -0
  4. package/core/src/index.ts +3 -0
  5. package/core/src/providers/analytics.provider.ts +2 -28
  6. package/core/src/providers/base.provider.ts +7 -135
  7. package/core/src/providers/cart.provider.ts +9 -22
  8. package/core/src/providers/identity.provider.ts +7 -21
  9. package/core/src/providers/inventory.provider.ts +4 -18
  10. package/core/src/providers/price.provider.ts +5 -22
  11. package/core/src/providers/product.provider.ts +5 -28
  12. package/core/src/providers/search.provider.ts +5 -22
  13. package/core/src/schemas/mutations/base.mutation.ts +0 -1
  14. package/core/src/schemas/mutations/cart.mutation.ts +0 -6
  15. package/core/src/schemas/mutations/identity.mutation.ts +0 -5
  16. package/core/src/schemas/queries/base.query.ts +0 -1
  17. package/core/src/schemas/queries/cart.query.ts +1 -3
  18. package/core/src/schemas/queries/identity.query.ts +1 -3
  19. package/core/src/schemas/queries/inventory.query.ts +0 -1
  20. package/core/src/schemas/queries/price.query.ts +0 -3
  21. package/core/src/schemas/queries/product.query.ts +2 -7
  22. package/core/src/schemas/queries/search.query.ts +0 -3
  23. package/examples/node/package.json +1 -5
  24. package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +97 -0
  25. package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +84 -0
  26. package/examples/node/src/basic/basic-node-setup.spec.ts +40 -0
  27. package/otel/src/index.ts +3 -0
  28. package/otel/src/trace-decorator.ts +246 -0
  29. package/package.json +2 -1
  30. package/providers/algolia/src/core/initialize.ts +3 -3
  31. package/providers/algolia/src/providers/product.provider.ts +44 -11
  32. package/providers/algolia/src/providers/search.provider.ts +47 -66
  33. package/providers/commercetools/src/core/client.ts +0 -1
  34. package/providers/commercetools/src/core/initialize.ts +8 -9
  35. package/providers/commercetools/src/providers/cart.provider.ts +58 -90
  36. package/providers/commercetools/src/providers/identity.provider.ts +34 -51
  37. package/providers/commercetools/src/providers/inventory.provider.ts +16 -29
  38. package/providers/commercetools/src/providers/price.provider.ts +30 -35
  39. package/providers/commercetools/src/providers/product.provider.ts +48 -38
  40. package/providers/commercetools/src/providers/search.provider.ts +32 -47
  41. package/providers/commercetools/src/schema/capabilities.schema.ts +1 -1
  42. package/providers/fake/package.json +1 -0
  43. package/providers/fake/src/core/initialize.ts +12 -11
  44. package/providers/fake/src/index.ts +4 -0
  45. package/providers/fake/src/providers/analytics.provider.ts +19 -0
  46. package/providers/fake/src/providers/cart.provider.ts +107 -0
  47. package/providers/fake/src/providers/identity.provider.ts +78 -68
  48. package/providers/fake/src/providers/inventory.provider.ts +54 -0
  49. package/providers/fake/src/providers/price.provider.ts +60 -0
  50. package/providers/fake/src/providers/product.provider.ts +53 -49
  51. package/providers/fake/src/providers/search.provider.ts +15 -33
  52. package/trpc/__mocks__/superjson.js +25 -0
  53. package/trpc/jest.config.ts +14 -0
  54. package/trpc/package.json +2 -1
  55. package/trpc/src/client.ts +176 -0
  56. package/trpc/src/index.ts +35 -62
  57. package/trpc/src/integration.spec.ts +216 -0
  58. package/trpc/src/server.ts +123 -0
  59. package/trpc/src/transparent-client.spec.ts +160 -0
  60. package/trpc/src/types.ts +142 -0
  61. package/trpc/tsconfig.json +3 -0
  62. package/trpc/tsconfig.lib.json +2 -1
  63. package/trpc/tsconfig.spec.json +15 -0
  64. package/tsconfig.base.json +0 -2
  65. package/examples/angular/e2e/example.spec.ts +0 -9
  66. package/examples/angular/eslint.config.mjs +0 -41
  67. package/examples/angular/playwright.config.ts +0 -38
  68. package/examples/angular/project.json +0 -86
  69. package/examples/angular/public/favicon.ico +0 -0
  70. package/examples/angular/src/app/app.component.html +0 -6
  71. package/examples/angular/src/app/app.component.scss +0 -22
  72. package/examples/angular/src/app/app.component.ts +0 -14
  73. package/examples/angular/src/app/app.config.ts +0 -16
  74. package/examples/angular/src/app/app.routes.ts +0 -25
  75. package/examples/angular/src/app/cart/cart.component.html +0 -4
  76. package/examples/angular/src/app/cart/cart.component.scss +0 -14
  77. package/examples/angular/src/app/cart/cart.component.ts +0 -73
  78. package/examples/angular/src/app/identity/identity.component.html +0 -6
  79. package/examples/angular/src/app/identity/identity.component.scss +0 -18
  80. package/examples/angular/src/app/identity/identity.component.ts +0 -49
  81. package/examples/angular/src/app/product/product.component.html +0 -14
  82. package/examples/angular/src/app/product/product.component.scss +0 -11
  83. package/examples/angular/src/app/product/product.component.ts +0 -42
  84. package/examples/angular/src/app/search/search.component.html +0 -35
  85. package/examples/angular/src/app/search/search.component.scss +0 -129
  86. package/examples/angular/src/app/search/search.component.ts +0 -50
  87. package/examples/angular/src/app/services/product.service.ts +0 -35
  88. package/examples/angular/src/app/services/search.service.ts +0 -48
  89. package/examples/angular/src/app/services/trpc.client.ts +0 -27
  90. package/examples/angular/src/index.html +0 -13
  91. package/examples/angular/src/main.ts +0 -7
  92. package/examples/angular/src/styles.scss +0 -17
  93. package/examples/angular/src/test-setup.ts +0 -6
  94. package/examples/angular/tsconfig.app.json +0 -10
  95. package/examples/angular/tsconfig.editor.json +0 -6
  96. package/examples/angular/tsconfig.json +0 -32
  97. package/examples/node/src/initialize-algolia.spec.ts +0 -29
  98. package/examples/node/src/initialize-commercetools.spec.ts +0 -31
  99. package/examples/node/src/initialize-extended-providers.spec.ts +0 -38
  100. package/examples/node/src/initialize-mixed-providers.spec.ts +0 -36
  101. package/examples/node/src/providers/custom-algolia-product.provider.ts +0 -18
  102. package/examples/node/src/schemas/custom-product.schema.ts +0 -8
  103. package/examples/trpc-node/.env.example +0 -52
  104. package/examples/trpc-node/eslint.config.mjs +0 -3
  105. package/examples/trpc-node/project.json +0 -61
  106. package/examples/trpc-node/src/assets/.gitkeep +0 -0
  107. package/examples/trpc-node/src/main.ts +0 -59
  108. package/examples/trpc-node/src/router-instance.ts +0 -54
  109. package/examples/trpc-node/tsconfig.app.json +0 -9
  110. package/examples/trpc-node/tsconfig.json +0 -13
@@ -0,0 +1,160 @@
1
+ import { buildClient, NoOpCache, SessionSchema } from '@reactionary/core';
2
+ import { withFakeCapabilities } from '@reactionary/provider-fake';
3
+ import { createTRPCServerRouter, introspectClient } from './index';
4
+
5
+ /**
6
+ * Test suite for TRPC transparent client functionality
7
+ * This tests the core introspection and router generation without HTTP setup
8
+ */
9
+
10
+ // Jest test framework is now available
11
+
12
+ // Create the server-side client using the same pattern as examples/node
13
+ const serverClient = buildClient(
14
+ [
15
+ withFakeCapabilities(
16
+ {
17
+ jitter: {
18
+ mean: 0,
19
+ deviation: 0,
20
+ },
21
+ },
22
+ { search: true, product: true, identity: false }
23
+ ),
24
+ ],
25
+ {
26
+ cache: new NoOpCache(),
27
+ }
28
+ );
29
+
30
+ // Create TRPC router from the client
31
+ const router = createTRPCServerRouter(serverClient);
32
+
33
+ describe('TRPC Transparent Client Core Functionality', () => {
34
+
35
+ const session = SessionSchema.parse({
36
+ id: '1234567890',
37
+ });
38
+
39
+ describe('Client Introspection', () => {
40
+ it('should correctly introspect client methods', () => {
41
+ const methods = introspectClient(serverClient);
42
+
43
+ expect(methods.length).toBeGreaterThan(0);
44
+
45
+ // Should find product methods
46
+ const productMethods = methods.filter(m => m.providerName === 'product');
47
+ expect(productMethods.length).toBeGreaterThan(0);
48
+
49
+ const getBySlugMethod = productMethods.find(m => m.name === 'getBySlug');
50
+ expect(getBySlugMethod).toBeDefined();
51
+ expect(getBySlugMethod!.isQuery).toBe(true);
52
+ expect(getBySlugMethod!.isMutation).toBe(false);
53
+
54
+ // Should find search methods
55
+ const searchMethods = methods.filter(m => m.providerName === 'search');
56
+ expect(searchMethods.length).toBeGreaterThan(0);
57
+
58
+ const queryByTermMethod = searchMethods.find(m => m.name === 'queryByTerm');
59
+ expect(queryByTermMethod).toBeDefined();
60
+ expect(queryByTermMethod!.isQuery).toBe(true);
61
+
62
+ // Note: Only testing enabled providers (product and search)
63
+ });
64
+ });
65
+
66
+ describe('Router Generation', () => {
67
+ it('should create TRPC router from client', () => {
68
+ expect(router).toBeDefined();
69
+
70
+ // Router should be an object (TRPC router)
71
+ expect(typeof router).toBe('object');
72
+ expect(router).toBeDefined();
73
+ });
74
+
75
+ it('should handle provider methods correctly', () => {
76
+ const methods = introspectClient(serverClient);
77
+ const providerNames = [...new Set(methods.map(m => m.providerName))];
78
+
79
+ // Should have enabled providers
80
+ expect(providerNames).toContain('product');
81
+ expect(providerNames).toContain('search');
82
+ });
83
+ });
84
+
85
+ describe('Method Classification', () => {
86
+ it('should correctly classify query methods', () => {
87
+ const methods = introspectClient(serverClient);
88
+
89
+ const queryMethods = methods.filter(m => m.isQuery);
90
+ const queryMethodNames = queryMethods.map(m => m.name);
91
+
92
+ // Should include get* methods from enabled providers
93
+ expect(queryMethodNames).toContain('getById');
94
+ expect(queryMethodNames).toContain('getBySlug');
95
+
96
+ // Should include query* methods
97
+ expect(queryMethodNames).toContain('queryByTerm');
98
+ });
99
+
100
+ it('should correctly classify mutation methods', () => {
101
+ const methods = introspectClient(serverClient);
102
+
103
+ const mutationMethods = methods.filter(m => m.isMutation);
104
+ const mutationMethodNames = mutationMethods.map(m => m.name);
105
+
106
+ // With current setup, only search and product are enabled
107
+ // No mutations expected from these providers
108
+ });
109
+ });
110
+
111
+ describe('Direct Client Functionality', () => {
112
+ it('should have working product provider', async () => {
113
+ const result = await serverClient.product.getBySlug(
114
+ { slug: 'test-product' },
115
+ session
116
+ );
117
+
118
+ expect(result).toBeDefined();
119
+ expect(result.slug).toBe('test-product');
120
+ expect(result.name).toBeDefined();
121
+ expect(result.description).toBeDefined();
122
+ });
123
+
124
+ it('should have working search provider', async () => {
125
+ const result = await serverClient.search.queryByTerm(
126
+ {
127
+ search: {
128
+ term: 'test search',
129
+ page: 0,
130
+ pageSize: 10,
131
+ facets: []
132
+ }
133
+ },
134
+ session
135
+ );
136
+
137
+ expect(result).toBeDefined();
138
+ expect(result.products).toBeDefined();
139
+ expect(result.facets).toBeDefined();
140
+ });
141
+
142
+ // Only testing enabled providers (product and search)
143
+ });
144
+
145
+ describe('Type System Validation', () => {
146
+ it('should maintain provider interface structure', () => {
147
+ // Verify the client has expected enabled provider structure
148
+ expect(serverClient.product).toBeDefined();
149
+ expect(serverClient.search).toBeDefined();
150
+
151
+ // Verify methods exist
152
+ expect(typeof serverClient.product.getById).toBe('function');
153
+ expect(typeof serverClient.product.getBySlug).toBe('function');
154
+ expect(typeof serverClient.search.queryByTerm).toBe('function');
155
+ });
156
+ });
157
+ });
158
+
159
+ // Export for potential use in other tests
160
+ export { serverClient, router };
@@ -0,0 +1,142 @@
1
+ import {
2
+ BaseProvider,
3
+ Client,
4
+ Session
5
+ } from '@reactionary/core';
6
+
7
+ /**
8
+ * Extract method names from a provider that match TRPC patterns
9
+ */
10
+ export type ProviderMethods<T> = T extends BaseProvider
11
+ ? {
12
+ [K in keyof T]: T[K] extends (...args: any[]) => any
13
+ ? K extends `get${string}` | `query${string}` | 'add' | 'remove' | 'changeQuantity' | 'login' | 'logout' | 'getSelf'
14
+ ? K
15
+ : never
16
+ : never
17
+ }[keyof T]
18
+ : never;
19
+
20
+ /**
21
+ * Extract method signature from a provider method
22
+ */
23
+ export type ProviderMethodSignature<T, K extends keyof T> =
24
+ T[K] extends (...args: infer Args) => infer Return
25
+ ? (...args: Args) => Return
26
+ : never;
27
+
28
+ /**
29
+ * Map all methods of all providers in a client
30
+ */
31
+ export type ClientMethodMap<T extends Partial<Client>> = {
32
+ [K in keyof T]: T[K] extends BaseProvider
33
+ ? {
34
+ [M in ProviderMethods<T[K]>]: ProviderMethodSignature<T[K], M>
35
+ }
36
+ : never;
37
+ };
38
+
39
+
40
+ /**
41
+ * Create transparent client that only includes methods matching TRPC patterns
42
+ */
43
+ export type TransparentClient<T extends Partial<Client>> = {
44
+ [K in keyof T]: T[K] extends BaseProvider
45
+ ? {
46
+ [M in ProviderMethods<T[K]>]: ProviderMethodSignature<T[K], M>
47
+ }
48
+ : never;
49
+ };
50
+
51
+ /**
52
+ * Extract method information for TRPC procedure creation
53
+ */
54
+ export interface MethodInfo {
55
+ name: string;
56
+ providerName: string;
57
+ isQuery: boolean;
58
+ isMutation: boolean;
59
+ method: (...args: any[]) => any;
60
+ }
61
+
62
+
63
+ /**
64
+ * Utility to determine if a method is a query or mutation based on naming convention
65
+ */
66
+ export function isQueryMethod(methodName: string): boolean {
67
+ return methodName.startsWith('get') ||
68
+ methodName.startsWith('query') ||
69
+ methodName === 'getSelf';
70
+ }
71
+
72
+ export function isMutationMethod(methodName: string): boolean {
73
+ return !isQueryMethod(methodName) && (
74
+ methodName === 'add' ||
75
+ methodName === 'remove' ||
76
+ methodName === 'changeQuantity' ||
77
+ methodName === 'login' ||
78
+ methodName === 'logout'
79
+ );
80
+ }
81
+
82
+ /**
83
+ * Introspect a client instance to extract all provider methods matching naming patterns
84
+ */
85
+ export function introspectClient<T extends Partial<Client>>(client: T): MethodInfo[] {
86
+ const methods: MethodInfo[] = [];
87
+
88
+ for (const [providerName, provider] of Object.entries(client)) {
89
+ if (provider instanceof BaseProvider) {
90
+ // Get all methods that match our naming patterns
91
+ for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(provider))) {
92
+ const method = (provider as any)[key];
93
+ if (typeof method === 'function' && key !== 'constructor') {
94
+ if (isQueryMethod(key) || isMutationMethod(key)) {
95
+ methods.push({
96
+ name: key,
97
+ providerName,
98
+ isQuery: isQueryMethod(key),
99
+ isMutation: isMutationMethod(key),
100
+ method: method.bind(provider)
101
+ });
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ return methods;
109
+ }
110
+
111
+ /**
112
+ * Type for TRPC procedure input - includes payload and session
113
+ */
114
+ export interface TRPCMethodInput<TPayload = any> {
115
+ payload: TPayload;
116
+ session?: Session;
117
+ }
118
+
119
+ /**
120
+ * Helper to extract payload type from a provider method
121
+ */
122
+ export type ExtractPayloadType<T> = T extends (payload: infer P, session: Session) => any
123
+ ? P
124
+ : T extends (payload: infer P) => any
125
+ ? P
126
+ : never;
127
+
128
+ /**
129
+ * Helper to extract return type from a provider method
130
+ */
131
+ export type ExtractReturnType<T> = T extends (...args: any[]) => infer R
132
+ ? R
133
+ : never;
134
+
135
+ /**
136
+ * Create a TRPC-compatible method signature from a provider method
137
+ */
138
+ export type TRPCMethodSignature<T> = T extends (payload: infer P, session: Session) => infer R
139
+ ? (input: TRPCMethodInput<P>) => R
140
+ : T extends (payload: infer P) => infer R
141
+ ? (input: TRPCMethodInput<P>) => R
142
+ : never;
@@ -8,6 +8,9 @@
8
8
  "references": [
9
9
  {
10
10
  "path": "./tsconfig.lib.json"
11
+ },
12
+ {
13
+ "path": "./tsconfig.spec.json"
11
14
  }
12
15
  ]
13
16
  }
@@ -5,5 +5,6 @@
5
5
  "declaration": true,
6
6
  "types": ["node"]
7
7
  },
8
- "include": ["src/**/*.ts"]
8
+ "include": ["src/**/*.ts"],
9
+ "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
9
10
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "moduleResolution": "node10",
7
+ "types": ["jest", "node"]
8
+ },
9
+ "include": [
10
+ "jest.config.ts",
11
+ "src/**/*.test.ts",
12
+ "src/**/*.spec.ts",
13
+ "src/**/*.d.ts"
14
+ ]
15
+ }
@@ -5,8 +5,6 @@
5
5
  "sourceMap": true,
6
6
  "declaration": false,
7
7
  "moduleResolution": "node",
8
- "emitDecoratorMetadata": true,
9
- "experimentalDecorators": true,
10
8
  "importHelpers": true,
11
9
  "target": "es2015",
12
10
  "module": "esnext",
@@ -1,9 +0,0 @@
1
- import { test, expect } from '@playwright/test';
2
-
3
- test('displays search results', async ({ page }) => {
4
- await page.goto('/');
5
-
6
- await page.waitForSelector('article', { state: 'visible' });
7
-
8
- expect(await page.locator('article').count()).toBe(20);
9
- });
@@ -1,41 +0,0 @@
1
- import playwright from 'eslint-plugin-playwright';
2
- import nx from '@nx/eslint-plugin';
3
- import baseConfig from '../../eslint.config.mjs';
4
-
5
- export default [
6
- playwright.configs['flat/recommended'],
7
- ...baseConfig,
8
- ...nx.configs['flat/angular'],
9
- ...nx.configs['flat/angular-template'],
10
- {
11
- files: ['**/*.ts'],
12
- rules: {
13
- '@angular-eslint/directive-selector': [
14
- 'error',
15
- {
16
- type: 'attribute',
17
- prefix: 'app',
18
- style: 'camelCase',
19
- },
20
- ],
21
- '@angular-eslint/component-selector': [
22
- 'error',
23
- {
24
- type: 'element',
25
- prefix: 'app',
26
- style: 'kebab-case',
27
- },
28
- ],
29
- },
30
- },
31
- {
32
- files: ['**/*.html'],
33
- // Override or add rules here
34
- rules: {},
35
- },
36
- {
37
- files: ['**/*.ts', '**/*.js'],
38
- // Override or add rules here
39
- rules: {},
40
- },
41
- ];
@@ -1,38 +0,0 @@
1
- import { defineConfig, devices } from '@playwright/test';
2
- import { nxE2EPreset } from '@nx/playwright/preset';
3
- import { workspaceRoot } from '@nx/devkit';
4
-
5
- // For CI, you may want to set BASE_URL to the deployed application.
6
- const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
7
-
8
- /**
9
- * Read environment variables from file.
10
- * https://github.com/motdotla/dotenv
11
- */
12
- // require('dotenv').config();
13
-
14
- /**
15
- * See https://playwright.dev/docs/test-configuration.
16
- */
17
- export default defineConfig({
18
- ...nxE2EPreset(__filename, { testDir: './e2e' }),
19
- /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
20
- use: {
21
- baseURL,
22
- /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
23
- trace: 'on-first-retry',
24
- },
25
- /* Run your local dev server before starting the tests */
26
- webServer: {
27
- command: 'npx nx serve examples-angular',
28
- url: 'http://localhost:4200',
29
- reuseExistingServer: !process.env.CI,
30
- cwd: workspaceRoot,
31
- },
32
- projects: [
33
- {
34
- name: 'chromium',
35
- use: { ...devices['Desktop Chrome'] },
36
- },
37
- ],
38
- });
@@ -1,86 +0,0 @@
1
- {
2
- "name": "examples-angular",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "projectType": "application",
5
- "prefix": "app",
6
- "sourceRoot": "examples/angular/src",
7
- "tags": [],
8
- "targets": {
9
- "build": {
10
- "executor": "@angular-devkit/build-angular:application",
11
- "outputs": ["{options.outputPath}"],
12
- "options": {
13
- "outputPath": "dist/examples/angular",
14
- "index": "examples/angular/src/index.html",
15
- "browser": "examples/angular/src/main.ts",
16
- "polyfills": [],
17
- "tsConfig": "examples/angular/tsconfig.app.json",
18
- "inlineStyleLanguage": "scss",
19
- "assets": [
20
- {
21
- "glob": "**/*",
22
- "input": "examples/angular/public"
23
- }
24
- ],
25
- "styles": ["examples/angular/src/styles.scss"],
26
- "scripts": []
27
- },
28
- "configurations": {
29
- "production": {
30
- "budgets": [
31
- {
32
- "type": "initial",
33
- "maximumWarning": "500kb",
34
- "maximumError": "1mb"
35
- },
36
- {
37
- "type": "anyComponentStyle",
38
- "maximumWarning": "4kb",
39
- "maximumError": "8kb"
40
- }
41
- ],
42
- "outputHashing": "all"
43
- },
44
- "development": {
45
- "optimization": false,
46
- "extractLicenses": false,
47
- "sourceMap": true
48
- }
49
- },
50
- "defaultConfiguration": "production"
51
- },
52
- "serve": {
53
- "executor": "@angular-devkit/build-angular:dev-server",
54
- "configurations": {
55
- "production": {
56
- "buildTarget": "examples-angular:build:production"
57
- },
58
- "development": {
59
- "buildTarget": "examples-angular:build:development"
60
- }
61
- },
62
- "defaultConfiguration": "development",
63
- "continuous": true,
64
- "dependsOn": [
65
- { "projects": ["trpc-node"], "target": "serve" }
66
- ]
67
- },
68
- "extract-i18n": {
69
- "executor": "@angular-devkit/build-angular:extract-i18n",
70
- "options": {
71
- "buildTarget": "examples-angular:build"
72
- }
73
- },
74
- "lint": {
75
- "executor": "@nx/eslint:lint"
76
- },
77
- "serve-static": {
78
- "executor": "@nx/web:file-server",
79
- "options": {
80
- "buildTarget": "examples-angular:build",
81
- "staticFilePath": "dist/examples/angular/browser",
82
- "spa": true
83
- }
84
- }
85
- }
86
- }
Binary file
@@ -1,6 +0,0 @@
1
- <header>
2
- <input (keydown)="this.service.term.set(inputTerm.value)" #inputTerm/>
3
- </header>
4
- <main>
5
- <router-outlet></router-outlet>
6
- </main>
@@ -1,22 +0,0 @@
1
- :host {
2
- display: block;
3
- }
4
-
5
- header {
6
- padding: 0.5rem;
7
-
8
- input {
9
- padding-inline: 1rem;
10
- color: rgb(205, 214, 244);
11
- background: rgb(88, 91, 112);
12
- width: 100%;
13
- height: 3rem;
14
- border-radius: 0.5rem;
15
- }
16
- }
17
-
18
- main {
19
- display: block;
20
- width: 100%;
21
- padding-inline: 0.5rem;
22
- }
@@ -1,14 +0,0 @@
1
- import { Component, inject } from '@angular/core';
2
- import { RouterModule } from '@angular/router';
3
- import { SearchService } from './services/search.service';
4
- import { TRPC } from './services/trpc.client';
5
-
6
- @Component({
7
- imports: [RouterModule],
8
- selector: 'app-root',
9
- templateUrl: './app.component.html',
10
- styleUrl: './app.component.scss',
11
- })
12
- export class AppComponent {
13
- protected service = inject(SearchService);
14
- }
@@ -1,16 +0,0 @@
1
- import { ApplicationConfig, provideExperimentalZonelessChangeDetection } from '@angular/core';
2
- import { NoPreloading, provideRouter, withPreloading, withRouterConfig } from '@angular/router';
3
- import { appRoutes } from './app.routes';
4
-
5
- export const appConfig: ApplicationConfig = {
6
- providers: [
7
- provideExperimentalZonelessChangeDetection(),
8
- provideRouter(
9
- appRoutes,
10
- withPreloading(NoPreloading),
11
- withRouterConfig({
12
- onSameUrlNavigation: 'ignore'
13
- })
14
- )
15
- ],
16
- };
@@ -1,25 +0,0 @@
1
- import { Route } from '@angular/router';
2
-
3
- export const appRoutes: Route[] = [
4
- {
5
- path: 'search',
6
- loadComponent: () => import('./search/search.component').then(x => x.SearchComponent)
7
- },
8
- {
9
- path: 'product/:slug',
10
- loadComponent: () => import('./product/product.component').then(x => x.ProductComponent)
11
- },
12
- {
13
- path: 'identity',
14
- loadComponent: () => import('./identity/identity.component').then(x => x.IdentityComponent)
15
- },
16
- {
17
- path: 'cart',
18
- loadComponent: () => import('./cart/cart.component').then(x => x.CartComponent)
19
- },
20
- {
21
- path: '**',
22
- pathMatch: 'prefix',
23
- redirectTo: 'search'
24
- }
25
- ];
@@ -1,4 +0,0 @@
1
- <pre>{{ cart() | json }}</pre>
2
- <button (click)="add()">Add</button>
3
- <button (click)="adjust()">Adjust</button>
4
- <button (click)="remove()">Remove</button>
@@ -1,14 +0,0 @@
1
- :host {
2
- display: grid;
3
- grid-template-columns: 600px;
4
- justify-content: center;
5
- gap: 0.5rem;
6
- }
7
-
8
- pre {
9
- color: white;
10
- }
11
-
12
- input, button {
13
- height: 3rem;
14
- }