@reactionary/source 0.3.0 → 0.3.1

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 (94) hide show
  1. package/core/src/client/client-builder.ts +3 -7
  2. package/core/src/client/client.ts +2 -3
  3. package/core/src/decorators/reactionary.decorator.ts +2 -2
  4. package/core/src/initialization.ts +8 -3
  5. package/core/src/providers/analytics.provider.ts +75 -0
  6. package/core/src/providers/cart.provider.ts +3 -0
  7. package/core/src/providers/category.provider.ts +1 -0
  8. package/core/src/schemas/errors/invalid-input.error.ts +1 -1
  9. package/core/src/schemas/errors/invalid-output.error.ts +1 -1
  10. package/core/src/schemas/models/identifiers.model.ts +3 -0
  11. package/core/src/schemas/models/order.model.ts +2 -2
  12. package/core/src/schemas/mutations/analytics/index.ts +23 -0
  13. package/core/src/schemas/mutations/analytics/product-add-to-cart.mutation.ts +25 -0
  14. package/core/src/schemas/mutations/analytics/product-details-view.mutation.ts +14 -0
  15. package/core/src/schemas/mutations/analytics/product-summary-click.mutation.ts +26 -0
  16. package/core/src/schemas/mutations/analytics/product-summary-view.mutation.ts +25 -0
  17. package/core/src/schemas/mutations/analytics/purchase.mutation.ts +14 -0
  18. package/core/src/schemas/mutations/index.ts +1 -1
  19. package/core/src/schemas/queries/order-search.query.ts +3 -0
  20. package/core/src/schemas/session.schema.ts +20 -9
  21. package/core/src/test/client-builder.spec.ts +60 -0
  22. package/core/src/zod-utils.ts +3 -1
  23. package/documentation/{1-purpose.md → docs/1-purpose.md} +4 -0
  24. package/documentation/docs/8-tracking.md +9 -0
  25. package/documentation/docs/providers/analytics.provider.md +297 -0
  26. package/documentation/docs/providers/base.provider.md +118 -0
  27. package/documentation/docs/providers/cart.provider.md +305 -0
  28. package/documentation/docs/providers/category.provider.md +244 -0
  29. package/documentation/docs/providers/checkout.provider.md +315 -0
  30. package/documentation/docs/providers/identity.provider.md +194 -0
  31. package/documentation/docs/providers/inventory.provider.md +162 -0
  32. package/documentation/docs/providers/order-search.provider.md +155 -0
  33. package/documentation/docs/providers/order.provider.md +160 -0
  34. package/documentation/docs/providers/price.provider.md +197 -0
  35. package/documentation/docs/providers/product-search.provider.md +265 -0
  36. package/documentation/docs/providers/product.provider.md +204 -0
  37. package/documentation/docs/providers/profile.provider.md +283 -0
  38. package/documentation/docs/providers/store.provider.md +146 -0
  39. package/documentation/docs/schemas/schemas.md +1862 -0
  40. package/documentation/docusaurus.config.js +33 -0
  41. package/documentation/scripts/generate.ts +52 -0
  42. package/documentation/sidebars.js +8 -0
  43. package/documentation/src/css/custom.css +3 -0
  44. package/documentation/src/pages/index.js +12 -0
  45. package/eslint.config.mjs +1 -1
  46. package/examples/node/package.json +6 -6
  47. package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +0 -2
  48. package/package.json +19 -5
  49. package/providers/algolia/project.json +1 -1
  50. package/providers/algolia/src/core/initialize.ts +5 -0
  51. package/providers/algolia/src/providers/analytics.provider.ts +112 -0
  52. package/providers/algolia/src/providers/index.ts +1 -0
  53. package/providers/commercetools/project.json +1 -1
  54. package/providers/commercetools/src/providers/profile.provider.ts +1 -4
  55. package/providers/fake/project.json +1 -1
  56. package/providers/fake/src/providers/analytics.provider.ts +5 -0
  57. package/providers/fake/src/providers/checkout.provider.ts +5 -2
  58. package/providers/fake/src/providers/product.provider.ts +18 -8
  59. package/providers/fake/src/test/cart.provider.spec.ts +0 -2
  60. package/providers/fake/src/test/category.provider.spec.ts +3 -3
  61. package/providers/fake/src/test/checkout.provider.spec.ts +3 -7
  62. package/providers/google-analytics/README.md +11 -0
  63. package/providers/google-analytics/eslint.config.mjs +25 -0
  64. package/providers/google-analytics/package.json +18 -0
  65. package/providers/google-analytics/project.json +33 -0
  66. package/providers/google-analytics/src/core/initialize.ts +16 -0
  67. package/providers/google-analytics/src/index.ts +4 -0
  68. package/providers/google-analytics/src/providers/analytics.provider.ts +162 -0
  69. package/providers/google-analytics/src/schema/capabilities.schema.ts +10 -0
  70. package/providers/google-analytics/src/schema/configuration.schema.ts +9 -0
  71. package/providers/google-analytics/src/test/analytics.provider.spec.ts +93 -0
  72. package/providers/google-analytics/tsconfig.json +24 -0
  73. package/providers/google-analytics/tsconfig.lib.json +23 -0
  74. package/providers/google-analytics/tsconfig.spec.json +28 -0
  75. package/providers/google-analytics/vite.config.ts +26 -0
  76. package/providers/google-analytics/vitest.config.mts +21 -0
  77. package/providers/medusa/package.json +3 -10
  78. package/providers/medusa/project.json +1 -1
  79. package/providers/medusa/src/providers/profile.provider.ts +5 -15
  80. package/providers/medusa/src/test/test-utils.ts +0 -1
  81. package/providers/medusa/tsconfig.json +3 -0
  82. package/providers/medusa/tsconfig.lib.json +16 -1
  83. package/providers/meilisearch/project.json +1 -1
  84. package/providers/posthog/project.json +1 -1
  85. package/tsconfig.base.json +4 -1
  86. package/.claude/settings.local.json +0 -28
  87. package/core/src/schemas/mutations/analytics.mutation.ts +0 -23
  88. package/providers/algolia/src/test/test-utils.ts +0 -31
  89. /package/documentation/{2-getting-started.md → docs/2-getting-started.md} +0 -0
  90. /package/documentation/{3-querying-and-changing-data.md → docs/3-querying-and-changing-data.md} +0 -0
  91. /package/documentation/{4-product-data.md → docs/4-product-data.md} +0 -0
  92. /package/documentation/{5-cart-and-checkout.md → docs/5-cart-and-checkout.md} +0 -0
  93. /package/documentation/{6-product-search.md → docs/6-product-search.md} +0 -0
  94. /package/documentation/{7-marketing.md → docs/7-marketing.md} +0 -0
@@ -0,0 +1,16 @@
1
+ import type { Cache, ClientFromCapabilities, RequestContext } from "@reactionary/core";
2
+ import type { GoogleAnalyticsCapabilities } from "../schema/capabilities.schema.js";
3
+ import type { GoogleAnalyticsConfiguration } from "../schema/configuration.schema.js";
4
+ import { GoogleAnalyticsAnalyticsProvider } from "../providers/analytics.provider.js";
5
+
6
+ export function googleAnalyticsCapabilities<T extends GoogleAnalyticsCapabilities>(configuration: GoogleAnalyticsConfiguration, capabilities: T) {
7
+ return (cache: Cache, context: RequestContext): ClientFromCapabilities<T> => {
8
+ const client: any = {};
9
+
10
+ if (capabilities.analytics) {
11
+ client.analytics = new GoogleAnalyticsAnalyticsProvider(cache, context, configuration);
12
+ }
13
+
14
+ return client;
15
+ };
16
+ }
@@ -0,0 +1,4 @@
1
+ export * from './core/initialize.js';
2
+ export * from './providers/analytics.provider.js';
3
+ export * from './schema/capabilities.schema.js';
4
+ export * from './schema/configuration.schema.js';
@@ -0,0 +1,162 @@
1
+ import {
2
+ AnalyticsProvider,
3
+ type RequestContext,
4
+ type Cache,
5
+ type AnalyticsMutationProductSummaryViewEvent,
6
+ type AnalyticsMutationProductSummaryClickEvent,
7
+ type AnalyticsMutationProductDetailsViewEvent,
8
+ type AnalyticsMutationProductAddToCartEvent,
9
+ type AnalyticsMutationPurchaseEvent,
10
+ } from '@reactionary/core';
11
+ import type { GoogleAnalyticsConfiguration } from '../schema/configuration.schema.js';
12
+
13
+ export class GoogleAnalyticsAnalyticsProvider extends AnalyticsProvider {
14
+ protected config: GoogleAnalyticsConfiguration;
15
+
16
+ constructor(
17
+ cache: Cache,
18
+ context: RequestContext,
19
+ configuration: GoogleAnalyticsConfiguration
20
+ ) {
21
+ super(cache, context);
22
+
23
+ this.config = configuration;
24
+ }
25
+
26
+ protected override async processProductSummaryView(
27
+ event: AnalyticsMutationProductSummaryViewEvent
28
+ ) {
29
+ const gaEvent = {
30
+ client_id: this.context.session.identityContext.personalizationKey,
31
+ user_id: this.context.session.identityContext.personalizationKey,
32
+ events: [
33
+ {
34
+ name: 'view_item_list',
35
+ params: {
36
+ currency: this.context.languageContext.currencyCode,
37
+ items: event.products.map((x) => {
38
+ return {
39
+ item_id: x.key,
40
+ };
41
+ }),
42
+ },
43
+ },
44
+ ],
45
+ };
46
+
47
+ await this.sendEvent(gaEvent);
48
+ }
49
+
50
+ protected override async processProductSummaryClick(
51
+ event: AnalyticsMutationProductSummaryClickEvent
52
+ ) {
53
+ const gaEvent = {
54
+ client_id: this.context.session.identityContext.personalizationKey,
55
+ user_id: this.context.session.identityContext.personalizationKey,
56
+ events: [
57
+ {
58
+ name: 'select_item',
59
+ params: {
60
+ currency: this.context.languageContext.currencyCode,
61
+ items: [
62
+ {
63
+ item_id: event.product.key,
64
+ index: event.position,
65
+ },
66
+ ],
67
+ },
68
+ },
69
+ ],
70
+ };
71
+
72
+ await this.sendEvent(gaEvent);
73
+ }
74
+
75
+ protected override async processProductDetailsView(
76
+ event: AnalyticsMutationProductDetailsViewEvent
77
+ ) {
78
+ const gaEvent = {
79
+ client_id: this.context.session.identityContext.personalizationKey,
80
+ user_id: this.context.session.identityContext.personalizationKey,
81
+ events: [
82
+ {
83
+ name: 'view_item',
84
+ params: {
85
+ currency: this.context.languageContext.currencyCode,
86
+ items: [
87
+ {
88
+ item_id: event.product.key,
89
+ },
90
+ ],
91
+ },
92
+ },
93
+ ],
94
+ };
95
+
96
+ await this.sendEvent(gaEvent);
97
+ }
98
+
99
+ protected override async processProductAddToCart(
100
+ event: AnalyticsMutationProductAddToCartEvent
101
+ ) {
102
+ const gaEvent = {
103
+ client_id: this.context.session.identityContext.personalizationKey,
104
+ user_id: this.context.session.identityContext.personalizationKey,
105
+ events: [
106
+ {
107
+ name: 'add_to_cart',
108
+ params: {
109
+ currency: this.context.languageContext.currencyCode,
110
+ items: [
111
+ {
112
+ item_id: event.product.key,
113
+ },
114
+ ],
115
+ },
116
+ },
117
+ ],
118
+ };
119
+
120
+ await this.sendEvent(gaEvent);
121
+ }
122
+
123
+ protected override async processPurchase(
124
+ event: AnalyticsMutationPurchaseEvent
125
+ ) {
126
+ const gaEvent = {
127
+ client_id: this.context.session.identityContext.personalizationKey,
128
+ user_id: this.context.session.identityContext.personalizationKey,
129
+ events: [
130
+ {
131
+ name: 'purchase',
132
+ params: {
133
+ currency: this.context.languageContext.currencyCode,
134
+ transaction_id: event.order.identifier.key,
135
+ value: event.order.price.grandTotal.value,
136
+ tax: event.order.price.totalTax.value,
137
+ shipping: event.order.price.totalShipping.value,
138
+ items: event.order.items.map((item) => ({
139
+ item_id: item.variant.sku,
140
+ quantity: item.quantity,
141
+ price: item.price.unitPrice.value,
142
+ })),
143
+ },
144
+ },
145
+ ],
146
+ };
147
+
148
+ await this.sendEvent(gaEvent);
149
+ }
150
+
151
+ protected async sendEvent(event: unknown) {
152
+ const url = `${this.config.url}?measurement_id=${this.config.measurementId}&api_secret=${this.config.apiSecret}`;
153
+
154
+ await fetch(url, {
155
+ method: 'POST',
156
+ headers: {
157
+ 'Content-Type': 'application/json',
158
+ },
159
+ body: JSON.stringify(event),
160
+ });
161
+ }
162
+ }
@@ -0,0 +1,10 @@
1
+ import { CapabilitiesSchema } from '@reactionary/core';
2
+ import type { z } from 'zod';
3
+
4
+ export const GoogleAnalyticsCapabilitiesSchema = CapabilitiesSchema.pick({
5
+ analytics: true,
6
+ }).partial();
7
+
8
+ export type GoogleAnalyticsCapabilities = z.infer<
9
+ typeof GoogleAnalyticsCapabilitiesSchema
10
+ >;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+
3
+ export const GoogleAnalyticsConfigurationSchema = z.looseObject({
4
+ url: z.string(),
5
+ measurementId: z.string(),
6
+ apiSecret: z.string()
7
+ });
8
+
9
+ export type GoogleAnalyticsConfiguration = z.infer<typeof GoogleAnalyticsConfigurationSchema>;
@@ -0,0 +1,93 @@
1
+ import 'dotenv/config';
2
+ import type { AnalyticsMutationProductSummaryViewEvent, AnalyticsMutationPurchaseEvent, RequestContext } from '@reactionary/core';
3
+ import {
4
+ CartSchema,
5
+ IdentitySchema,
6
+ NoOpCache,
7
+ createInitialRequestContext,
8
+ } from '@reactionary/core';
9
+ import { describe, expect, it, beforeAll, beforeEach, assert } from 'vitest';
10
+ import { GoogleAnalyticsAnalyticsProvider } from '../providers/analytics.provider.js';
11
+ import type { GoogleAnalyticsConfiguration } from '../schema/configuration.schema.js';
12
+
13
+ describe('Google Analytics Analytics Provider', () => {
14
+ let provider: GoogleAnalyticsAnalyticsProvider;
15
+ let reqCtx: RequestContext;
16
+
17
+ beforeEach(() => {
18
+ reqCtx = createInitialRequestContext();
19
+ const config = {
20
+ apiSecret: process.env['GOOGLE_ANALYTICS_API_SECRET'] || '',
21
+ measurementId: process.env['GOOGLE_ANALYTICS_MEASUREMENT_ID'] || '',
22
+ url: process.env['GOOGLE_ANALYTICS_URL'] || '',
23
+ } satisfies GoogleAnalyticsConfiguration;
24
+
25
+ provider = new GoogleAnalyticsAnalyticsProvider(
26
+ new NoOpCache(),
27
+ reqCtx,
28
+ config
29
+ );
30
+ });
31
+
32
+ describe('tracking', () => {
33
+ it('should be able to add an item to a cart', async () => {
34
+ const event = {
35
+ event: 'product-summary-view',
36
+ products: [{
37
+ key: 'P-5000'
38
+ }]
39
+ } satisfies AnalyticsMutationProductSummaryViewEvent;
40
+
41
+ const result = await provider.track(event);
42
+ });
43
+
44
+ it('should be able to track a purchase', async () => {
45
+ const event = {
46
+ event: 'purchase',
47
+ order: {
48
+ identifier: { key: 'ORDER-12345' },
49
+ userId: { userId: 'test-user-123' },
50
+ items: [
51
+ {
52
+ identifier: { key: 'item-1' },
53
+ variant: { sku: 'SKU-001' },
54
+ quantity: 2,
55
+ price: {
56
+ unitPrice: { value: 29.99, currency: 'EUR' },
57
+ unitDiscount: { value: 0, currency: 'EUR' },
58
+ totalPrice: { value: 59.98, currency: 'EUR' },
59
+ totalDiscount: { value: 0, currency: 'EUR' },
60
+ },
61
+ inventoryStatus: 'Allocated',
62
+ },
63
+ {
64
+ identifier: { key: 'item-2' },
65
+ variant: { sku: 'SKU-002' },
66
+ quantity: 1,
67
+ price: {
68
+ unitPrice: { value: 49.99, currency: 'EUR' },
69
+ unitDiscount: { value: 5, currency: 'EUR' },
70
+ totalPrice: { value: 44.99, currency: 'EUR' },
71
+ totalDiscount: { value: 5, currency: 'EUR' },
72
+ },
73
+ inventoryStatus: 'Allocated',
74
+ },
75
+ ],
76
+ price: {
77
+ totalTax: { value: 21.99, currency: 'EUR' },
78
+ totalDiscount: { value: 5, currency: 'EUR' },
79
+ totalSurcharge: { value: 0, currency: 'EUR' },
80
+ totalShipping: { value: 4.99, currency: 'EUR' },
81
+ totalProductPrice: { value: 104.97, currency: 'EUR' },
82
+ grandTotal: { value: 126.95, currency: 'EUR' },
83
+ },
84
+ orderStatus: 'AwaitingPayment',
85
+ inventoryStatus: 'Allocated',
86
+ paymentInstructions: [],
87
+ },
88
+ } satisfies AnalyticsMutationPurchaseEvent;
89
+
90
+ await provider.track(event);
91
+ });
92
+ });
93
+ });
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "nodenext",
5
+ "moduleResolution": "nodenext",
6
+ "forceConsistentCasingInFileNames": true,
7
+ "strict": true,
8
+ "importHelpers": true,
9
+ "noImplicitOverride": true,
10
+ "noImplicitReturns": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "noPropertyAccessFromIndexSignature": true
13
+ },
14
+ "files": [],
15
+ "include": [],
16
+ "references": [
17
+ {
18
+ "path": "./tsconfig.lib.json"
19
+ },
20
+ {
21
+ "path": "./tsconfig.spec.json"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "declaration": true,
6
+ "types": ["node"]
7
+ },
8
+ "include": ["src/**/*.ts"],
9
+ "exclude": [
10
+ "vite.config.ts",
11
+ "vite.config.mts",
12
+ "vitest.config.ts",
13
+ "vitest.config.mts",
14
+ "src/**/*.test.ts",
15
+ "src/**/*.spec.ts",
16
+ "src/**/*.test.tsx",
17
+ "src/**/*.spec.tsx",
18
+ "src/**/*.test.js",
19
+ "src/**/*.spec.js",
20
+ "src/**/*.test.jsx",
21
+ "src/**/*.spec.jsx"
22
+ ]
23
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "types": [
6
+ "vitest/globals",
7
+ "vitest/importMeta",
8
+ "vite/client",
9
+ "node",
10
+ "vitest"
11
+ ]
12
+ },
13
+ "include": [
14
+ "vite.config.ts",
15
+ "vite.config.mts",
16
+ "vitest.config.ts",
17
+ "vitest.config.mts",
18
+ "src/**/*.test.ts",
19
+ "src/**/*.spec.ts",
20
+ "src/**/*.test.tsx",
21
+ "src/**/*.spec.tsx",
22
+ "src/**/*.test.js",
23
+ "src/**/*.spec.js",
24
+ "src/**/*.test.jsx",
25
+ "src/**/*.spec.jsx",
26
+ "src/**/*.d.ts"
27
+ ]
28
+ }
@@ -0,0 +1,26 @@
1
+ /// <reference types='vitest' />
2
+ import { defineConfig } from 'vite';
3
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
4
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
5
+
6
+ export default defineConfig(() => ({
7
+ root: import.meta.dirname,
8
+ cacheDir: '../../node_modules/.vite/providers/google-analytics',
9
+ plugins: [nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
10
+ // Uncomment this if you are using workers.
11
+ // worker: {
12
+ // plugins: () => [ nxViteTsPaths() ],
13
+ // },
14
+ test: {
15
+ name: 'google-analytics',
16
+ watch: false,
17
+ globals: true,
18
+ environment: 'node',
19
+ include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
20
+ reporters: ['default'],
21
+ coverage: {
22
+ reportsDirectory: '../../coverage/providers/google-analytics',
23
+ provider: 'v8' as const,
24
+ },
25
+ },
26
+ }));
@@ -0,0 +1,21 @@
1
+ import { defineConfig } from 'vitest/config';
2
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
3
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
4
+
5
+ export default defineConfig(() => ({
6
+ root: __dirname,
7
+ cacheDir: '../../node_modules/.vite/providers/google-analytics',
8
+ plugins: [nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
9
+ test: {
10
+ name: 'google-analytics',
11
+ watch: false,
12
+ globals: true,
13
+ environment: 'node',
14
+ include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
15
+ reporters: ['default'],
16
+ coverage: {
17
+ reportsDirectory: '../../coverage/providers/google-analytics',
18
+ provider: 'v8' as const,
19
+ },
20
+ },
21
+ }));
@@ -5,18 +5,11 @@
5
5
  "main": "index.js",
6
6
  "types": "src/index.d.ts",
7
7
  "dependencies": {
8
- "zod": "4.1.9",
8
+ "@medusajs/js-sdk": "^2.13.0",
9
9
  "@reactionary/core": "0.0.1",
10
- "@medusajs/js-sdk": "^2.0.0",
11
- "debug": "^4.3.4",
10
+ "debug": "^4.4.3",
12
11
  "@medusajs/types": "^2.11.0",
13
- "dotenv": "^17.2.2"
14
- },
15
- "devDependencies": {
16
- "vitest": "*",
17
- "@vitest/ui": "*",
18
- "@vitest/coverage-v8": "*",
19
- "vite-tsconfig-paths": "*"
12
+ "zod": "4.1.9"
20
13
  },
21
14
  "sideEffects": false
22
15
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "provider-medusa",
2
+ "name": "medusa",
3
3
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
4
  "sourceRoot": "providers/medusa/src",
5
5
  "projectType": "library",
@@ -129,9 +129,7 @@ export class MedusaProfileProvider extends ProfileProvider {
129
129
  if (existingAddress) {
130
130
  return error<InvalidInputError>({
131
131
  type: 'InvalidInput',
132
- error: {
133
- message: 'Address with the same nickname already exists',
134
- }
132
+ error: 'Address with the same nickname already exists'
135
133
  });
136
134
  }
137
135
 
@@ -139,9 +137,7 @@ export class MedusaProfileProvider extends ProfileProvider {
139
137
  if (!response.customer) {
140
138
  return error<InvalidInputError>({
141
139
  type: 'InvalidInput',
142
- error: {
143
- message: 'Failed to add shipping address',
144
- }
140
+ error: 'Failed to add shipping address'
145
141
  });
146
142
  }
147
143
 
@@ -180,9 +176,7 @@ export class MedusaProfileProvider extends ProfileProvider {
180
176
  if (!response.customer) {
181
177
  return error<InvalidInputError>({
182
178
  type: 'InvalidInput',
183
- error: {
184
- message: 'Failed to add shipping address',
185
- }
179
+ error: 'Failed to add shipping address'
186
180
  })
187
181
  }
188
182
 
@@ -221,9 +215,7 @@ export class MedusaProfileProvider extends ProfileProvider {
221
215
  if (!response.deleted) {
222
216
  return error<InvalidInputError>({
223
217
  type: 'InvalidInput',
224
- error: {
225
- message: 'Failed to delete shipping address',
226
- }
218
+ error: 'Failed to delete shipping address'
227
219
  });
228
220
  }
229
221
 
@@ -292,9 +284,7 @@ export class MedusaProfileProvider extends ProfileProvider {
292
284
  if (existingAddressWithNickname && !existingAddressWithNickname.is_default_billing) {
293
285
  return error<InvalidInputError>({
294
286
  type: 'InvalidInput',
295
- error: {
296
- message: 'Another address with the same nickname already exists',
297
- }
287
+ error: 'Another address with the same nickname already exists'
298
288
  });
299
289
  }
300
290
 
@@ -1,4 +1,3 @@
1
- import 'dotenv/config';
2
1
 
3
2
  import { MedusaConfigurationSchema, type MedusaConfiguration } from '../schema/configuration.schema.js';
4
3
 
@@ -16,6 +16,9 @@
16
16
  "references": [
17
17
  {
18
18
  "path": "./tsconfig.lib.json"
19
+ },
20
+ {
21
+ "path": "./tsconfig.spec.json"
19
22
  }
20
23
  ]
21
24
  }
@@ -5,5 +5,20 @@
5
5
  "declaration": true,
6
6
  "types": ["node"]
7
7
  },
8
- "include": ["src/**/*.ts"]
8
+ "include": ["src/**/*.ts"],
9
+ "exclude": [
10
+ "vite.config.ts",
11
+ "vite.config.mts",
12
+ "vitest.config.ts",
13
+ "vitest.config.mts",
14
+ "src/**/*.test.ts",
15
+ "src/**/*.spec.ts",
16
+ "src/**/*.test.tsx",
17
+ "src/**/*.spec.tsx",
18
+ "src/**/*.test.js",
19
+ "src/**/*.spec.js",
20
+ "src/**/*.test.jsx",
21
+ "src/**/*.spec.jsx",
22
+ "src/test/**/*.ts"
23
+ ]
9
24
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "provider-meilisearch",
2
+ "name": "meilisearch",
3
3
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
4
  "sourceRoot": "providers/meilisearch/src",
5
5
  "projectType": "library",
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "provider-posthog",
2
+ "name": "posthog",
3
3
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
4
  "sourceRoot": "providers/posthog/src",
5
5
  "projectType": "library",
@@ -27,7 +27,10 @@
27
27
  "providers/commercetools/src/index.ts"
28
28
  ],
29
29
  "@reactionary/provider-fake": ["providers/fake/src/index.ts"],
30
- "@reactionary/provider-posthog": ["providers/posthog/src/index.ts"]
30
+ "@reactionary/provider-posthog": ["providers/posthog/src/index.ts"],
31
+ "@reactionary/google-analytics": [
32
+ "providers/google-analytics/src/index.ts"
33
+ ]
31
34
  },
32
35
  "verbatimModuleSyntax": true
33
36
  },
@@ -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,23 +0,0 @@
1
- import { z } from 'zod';
2
- import { BaseMutationSchema } from './base.mutation.js';
3
- import { ProductIdentifierSchema, ProductSearchIdentifierSchema } from '../models/identifiers.model.js';
4
- import type { InferType } from '../../zod-utils.js';
5
-
6
- export const AnalyticsMutationSearchEventSchema = BaseMutationSchema.extend({
7
- mutation: z.literal('search'),
8
- search: ProductSearchIdentifierSchema,
9
- products: z.array(ProductIdentifierSchema),
10
- });
11
-
12
- export const AnalyticsMutationSearchProductClickEventSchema = BaseMutationSchema.extend({
13
- mutation: z.literal('product-search-click'),
14
- search: ProductSearchIdentifierSchema,
15
- product: ProductIdentifierSchema,
16
- position: z.number().min(0)
17
- });
18
-
19
- export const AnalyticsMutationSchema = z.union([AnalyticsMutationSearchEventSchema, AnalyticsMutationSearchProductClickEventSchema]);
20
-
21
- export type AnalyticsMutation = InferType<typeof AnalyticsMutationSchema>;
22
- export type AnalyticsMutationSearchEvent = InferType<typeof AnalyticsMutationSearchEventSchema>;
23
- export type AnalyticsMutationSearchProductClickEvent = InferType<typeof AnalyticsMutationSearchProductClickEventSchema>;
@@ -1,31 +0,0 @@
1
- import type { Session } from "@reactionary/core";
2
-
3
- export function createAnonymousTestSession(): Session {
4
- return {
5
- id: 'test-session-id',
6
- identity: {
7
- type: 'Anonymous',
8
- meta: {
9
- cache: { hit: false, key: '' },
10
- placeholder: false,
11
- },
12
- id: { userId: 'anonymous' },
13
- token: undefined,
14
- issued: new Date(),
15
- expiry: new Date(new Date().getTime() + 3600 * 1000),
16
- logonId: "",
17
- createdAt: "",
18
- updatedAt: "",
19
- keyring: [],
20
- currentService: undefined
21
- },
22
- languageContext: {
23
- locale: 'en-US',
24
- currencyCode: 'USD',
25
- countryCode: 'US',
26
- },
27
- storeIdentifier: {
28
- key: 'the-good-store',
29
- },
30
- };
31
- }