@reactionary/source 0.3.0 → 0.3.2

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 (103) 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 +11 -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/providers/identity.provider.ts +5 -0
  9. package/core/src/schemas/errors/invalid-input.error.ts +1 -1
  10. package/core/src/schemas/errors/invalid-output.error.ts +1 -1
  11. package/core/src/schemas/models/identifiers.model.ts +3 -0
  12. package/core/src/schemas/models/order.model.ts +2 -2
  13. package/core/src/schemas/mutations/analytics/index.ts +23 -0
  14. package/core/src/schemas/mutations/analytics/product-add-to-cart.mutation.ts +25 -0
  15. package/core/src/schemas/mutations/analytics/product-details-view.mutation.ts +14 -0
  16. package/core/src/schemas/mutations/analytics/product-summary-click.mutation.ts +26 -0
  17. package/core/src/schemas/mutations/analytics/product-summary-view.mutation.ts +25 -0
  18. package/core/src/schemas/mutations/analytics/purchase.mutation.ts +14 -0
  19. package/core/src/schemas/mutations/index.ts +1 -1
  20. package/core/src/schemas/queries/order-search.query.ts +3 -0
  21. package/core/src/schemas/session.schema.ts +21 -9
  22. package/core/src/test/client-builder.spec.ts +60 -0
  23. package/core/src/zod-utils.ts +3 -1
  24. package/documentation/{1-purpose.md → docs/1-purpose.md} +4 -0
  25. package/documentation/docs/8-tracking.md +9 -0
  26. package/documentation/docs/providers/analytics.provider.md +297 -0
  27. package/documentation/docs/providers/base.provider.md +118 -0
  28. package/documentation/docs/providers/cart.provider.md +305 -0
  29. package/documentation/docs/providers/category.provider.md +244 -0
  30. package/documentation/docs/providers/checkout.provider.md +315 -0
  31. package/documentation/docs/providers/identity.provider.md +194 -0
  32. package/documentation/docs/providers/inventory.provider.md +162 -0
  33. package/documentation/docs/providers/order-search.provider.md +155 -0
  34. package/documentation/docs/providers/order.provider.md +160 -0
  35. package/documentation/docs/providers/price.provider.md +197 -0
  36. package/documentation/docs/providers/product-search.provider.md +265 -0
  37. package/documentation/docs/providers/product.provider.md +204 -0
  38. package/documentation/docs/providers/profile.provider.md +283 -0
  39. package/documentation/docs/providers/store.provider.md +146 -0
  40. package/documentation/docs/schemas/schemas.md +1862 -0
  41. package/documentation/docusaurus.config.js +33 -0
  42. package/documentation/scripts/generate.ts +52 -0
  43. package/documentation/sidebars.js +8 -0
  44. package/documentation/src/css/custom.css +3 -0
  45. package/documentation/src/pages/index.js +12 -0
  46. package/eslint.config.mjs +1 -1
  47. package/examples/node/package.json +6 -6
  48. package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +0 -2
  49. package/examples/node/src/basic/client-creation.spec.ts +2 -2
  50. package/package.json +19 -5
  51. package/providers/algolia/README.md +12 -4
  52. package/providers/algolia/project.json +1 -1
  53. package/providers/algolia/src/core/initialize.ts +7 -2
  54. package/providers/algolia/src/providers/analytics.provider.ts +114 -0
  55. package/providers/algolia/src/providers/index.ts +1 -0
  56. package/providers/algolia/src/providers/product-search.provider.ts +5 -4
  57. package/providers/algolia/src/test/analytics.spec.ts +138 -0
  58. package/providers/commercetools/project.json +1 -1
  59. package/providers/commercetools/src/providers/identity.provider.ts +8 -1
  60. package/providers/commercetools/src/providers/profile.provider.ts +1 -4
  61. package/providers/commercetools/src/test/caching.spec.ts +3 -3
  62. package/providers/commercetools/src/test/identity.spec.ts +2 -2
  63. package/providers/fake/project.json +1 -1
  64. package/providers/fake/src/providers/analytics.provider.ts +5 -0
  65. package/providers/fake/src/providers/checkout.provider.ts +5 -2
  66. package/providers/fake/src/providers/product.provider.ts +18 -8
  67. package/providers/fake/src/test/cart.provider.spec.ts +0 -2
  68. package/providers/fake/src/test/category.provider.spec.ts +3 -3
  69. package/providers/fake/src/test/checkout.provider.spec.ts +3 -7
  70. package/providers/google-analytics/README.md +11 -0
  71. package/providers/google-analytics/eslint.config.mjs +25 -0
  72. package/providers/google-analytics/package.json +12 -0
  73. package/providers/google-analytics/project.json +33 -0
  74. package/providers/google-analytics/src/core/initialize.ts +16 -0
  75. package/providers/google-analytics/src/index.ts +4 -0
  76. package/providers/google-analytics/src/providers/analytics.provider.ts +162 -0
  77. package/providers/google-analytics/src/schema/capabilities.schema.ts +10 -0
  78. package/providers/google-analytics/src/schema/configuration.schema.ts +9 -0
  79. package/providers/google-analytics/src/test/analytics.provider.spec.ts +93 -0
  80. package/providers/google-analytics/tsconfig.json +24 -0
  81. package/providers/google-analytics/tsconfig.lib.json +23 -0
  82. package/providers/google-analytics/tsconfig.spec.json +28 -0
  83. package/providers/google-analytics/vite.config.ts +26 -0
  84. package/providers/google-analytics/vitest.config.mts +21 -0
  85. package/providers/medusa/package.json +3 -10
  86. package/providers/medusa/project.json +1 -1
  87. package/providers/medusa/src/providers/identity.provider.ts +34 -10
  88. package/providers/medusa/src/providers/profile.provider.ts +5 -15
  89. package/providers/medusa/src/test/test-utils.ts +0 -1
  90. package/providers/medusa/tsconfig.json +3 -0
  91. package/providers/medusa/tsconfig.lib.json +16 -1
  92. package/providers/meilisearch/project.json +1 -1
  93. package/providers/posthog/project.json +1 -1
  94. package/tsconfig.base.json +4 -1
  95. package/.claude/settings.local.json +0 -28
  96. package/core/src/schemas/mutations/analytics.mutation.ts +0 -23
  97. package/providers/algolia/src/test/test-utils.ts +0 -31
  98. /package/documentation/{2-getting-started.md → docs/2-getting-started.md} +0 -0
  99. /package/documentation/{3-querying-and-changing-data.md → docs/3-querying-and-changing-data.md} +0 -0
  100. /package/documentation/{4-product-data.md → docs/4-product-data.md} +0 -0
  101. /package/documentation/{5-cart-and-checkout.md → docs/5-cart-and-checkout.md} +0 -0
  102. /package/documentation/{6-product-search.md → docs/6-product-search.md} +0 -0
  103. /package/documentation/{7-marketing.md → docs/7-marketing.md} +0 -0
@@ -0,0 +1,283 @@
1
+ [**@reactionary/core**](README.md)
2
+
3
+ ***
4
+
5
+ [@reactionary/core](README.md) / profile.provider
6
+
7
+ # profile.provider
8
+
9
+ ## Classes
10
+
11
+ ### `abstract` ProfileProvider
12
+
13
+ Defined in: [profile.provider.ts:8](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L8)
14
+
15
+ Base capability provider, responsible for mutations (changes) and queries (fetches)
16
+ for a given business object domain.
17
+
18
+ #### Extends
19
+
20
+ - [`BaseProvider`](base.provider.md#baseprovider)
21
+
22
+ #### Constructors
23
+
24
+ ##### Constructor
25
+
26
+ > **new ProfileProvider**(`cache`, `context`): [`ProfileProvider`](#profileprovider)
27
+
28
+ Defined in: [base.provider.ts:13](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L13)
29
+
30
+ ###### Parameters
31
+
32
+ ###### cache
33
+
34
+ `Cache`
35
+
36
+ ###### context
37
+
38
+ `RequestContext`
39
+
40
+ ###### Returns
41
+
42
+ [`ProfileProvider`](#profileprovider)
43
+
44
+ ###### Inherited from
45
+
46
+ [`BaseProvider`](base.provider.md#baseprovider).[`constructor`](base.provider.md#constructor)
47
+
48
+ #### Properties
49
+
50
+ ##### cache
51
+
52
+ > `protected` **cache**: `Cache`
53
+
54
+ Defined in: [base.provider.ts:10](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L10)
55
+
56
+ ###### Inherited from
57
+
58
+ [`BaseProvider`](base.provider.md#baseprovider).[`cache`](base.provider.md#cache)
59
+
60
+ ##### context
61
+
62
+ > `protected` **context**: `RequestContext`
63
+
64
+ Defined in: [base.provider.ts:11](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L11)
65
+
66
+ ###### Inherited from
67
+
68
+ [`BaseProvider`](base.provider.md#baseprovider).[`context`](base.provider.md#context)
69
+
70
+ #### Methods
71
+
72
+ ##### addShippingAddress()
73
+
74
+ > `abstract` **addShippingAddress**(`payload`): `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
75
+
76
+ Defined in: [profile.provider.ts:39](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L39)
77
+
78
+ Creates a new shipping address for the currently authenticated (registered) user.
79
+ Does not set it as default automatically.
80
+
81
+ Usecase: User adds a new shipping address in their profile or during checkout. Ideally, any address manipulation
82
+ done at checkout should be considered local to that session, unless the addressbook is empty.
83
+
84
+ ###### Parameters
85
+
86
+ ###### payload
87
+
88
+ `ProfileMutationAddShippingAddress`
89
+
90
+ ###### Returns
91
+
92
+ `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
93
+
94
+ ##### generateCacheKeyForQuery()
95
+
96
+ > `protected` **generateCacheKeyForQuery**(`scope`, `query`): `string`
97
+
98
+ Defined in: [base.provider.ts:32](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L32)
99
+
100
+ ###### Parameters
101
+
102
+ ###### scope
103
+
104
+ `string`
105
+
106
+ ###### query
107
+
108
+ `object`
109
+
110
+ ###### Returns
111
+
112
+ `string`
113
+
114
+ ###### Inherited from
115
+
116
+ [`BaseProvider`](base.provider.md#baseprovider).[`generateCacheKeyForQuery`](base.provider.md#generatecachekeyforquery)
117
+
118
+ ##### generateDependencyIdsForModel()
119
+
120
+ > **generateDependencyIdsForModel**(`model`): `string`[]
121
+
122
+ Defined in: [base.provider.ts:18](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L18)
123
+
124
+ ###### Parameters
125
+
126
+ ###### model
127
+
128
+ `unknown`
129
+
130
+ ###### Returns
131
+
132
+ `string`[]
133
+
134
+ ###### Inherited from
135
+
136
+ [`BaseProvider`](base.provider.md#baseprovider).[`generateDependencyIdsForModel`](base.provider.md#generatedependencyidsformodel)
137
+
138
+ ##### getById()
139
+
140
+ > `abstract` **getById**(`payload`): `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
141
+
142
+ Defined in: [profile.provider.ts:16](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L16)
143
+
144
+ Returns the profile of the currently authenticated (registered) user.
145
+
146
+ Usecase: Fetch the profile of the logged-in user for display in header, or account settings.
147
+
148
+ ###### Parameters
149
+
150
+ ###### payload
151
+
152
+ `ProfileQuerySelf`
153
+
154
+ ###### Returns
155
+
156
+ `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
157
+
158
+ ##### getResourceName()
159
+
160
+ > `protected` **getResourceName**(): `string`
161
+
162
+ Defined in: [profile.provider.ts:79](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L79)
163
+
164
+ Returns the abstract resource name provided by the remote system.
165
+
166
+ ###### Returns
167
+
168
+ `string`
169
+
170
+ ###### Overrides
171
+
172
+ [`BaseProvider`](base.provider.md#baseprovider).[`getResourceName`](base.provider.md#getresourcename)
173
+
174
+ ##### makeShippingAddressDefault()
175
+
176
+ > `abstract` **makeShippingAddressDefault**(`payload`): `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
177
+
178
+ Defined in: [profile.provider.ts:66](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L66)
179
+
180
+ Configures an existing shipping address as the default shipping address for the currently authenticated (registered) user.
181
+
182
+ Usecase: User selects a default shipping address in their profile.
183
+
184
+ ###### Parameters
185
+
186
+ ###### payload
187
+
188
+ `ProfileMutationMakeShippingAddressDefault`
189
+
190
+ ###### Returns
191
+
192
+ `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
193
+
194
+ ##### removeShippingAddress()
195
+
196
+ > `abstract` **removeShippingAddress**(`payload`): `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
197
+
198
+ Defined in: [profile.provider.ts:58](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L58)
199
+
200
+ Removes an existing shipping address for the currently authenticated (registered) user.
201
+
202
+ If the removed address was the default shipping address, the default shipping address is set to a random other address.
203
+
204
+ Usecase: User deletes a shipping address from their profile.
205
+
206
+ ###### Parameters
207
+
208
+ ###### payload
209
+
210
+ `ProfileMutationRemoveShippingAddress`
211
+
212
+ ###### Returns
213
+
214
+ `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
215
+
216
+ ##### setBillingAddress()
217
+
218
+ > `abstract` **setBillingAddress**(`payload`): `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
219
+
220
+ Defined in: [profile.provider.ts:77](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L77)
221
+
222
+ Sets the current/active billing address for the currently authenticated (registered) user.
223
+
224
+ Usecase: User sets or updates their billing address in their profile or during checkout.
225
+
226
+ It was a design decision not to support multiple billing addresses. The billing address represents who you are as the commercial
227
+ entity being billed, and as such it makes sense to have a single authoritative billing address.
228
+
229
+ ###### Parameters
230
+
231
+ ###### payload
232
+
233
+ `ProfileMutationSetBillingAddress`
234
+
235
+ ###### Returns
236
+
237
+ `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
238
+
239
+ ##### update()
240
+
241
+ > `abstract` **update**(`payload`): `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
242
+
243
+ Defined in: [profile.provider.ts:29](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L29)
244
+
245
+ Updates the base profile information of the currently authenticated (registered) user.
246
+
247
+ TODO: This should include first/lastname.
248
+ TODO: In some systems, updating email/phone may require re-verification.
249
+ TODO: Handle conflicts if email/phone is already in use by another user.
250
+ TODO: In some systems the email might not be editable.
251
+
252
+ Usecase: Update the user's name, email, or phone number.
253
+
254
+ ###### Parameters
255
+
256
+ ###### payload
257
+
258
+ `ProfileMutationUpdate`
259
+
260
+ ###### Returns
261
+
262
+ `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
263
+
264
+ ##### updateShippingAddress()
265
+
266
+ > `abstract` **updateShippingAddress**(`payload`): `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
267
+
268
+ Defined in: [profile.provider.ts:48](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/profile.provider.ts#L48)
269
+
270
+ Updates an existing shipping address for the currently authenticated (registered) user.
271
+
272
+ Usecase: User edits an existing shipping address in their profile. Ideally, any address manipulation
273
+ done at checkout should be considered local to that session/order, unless the addressbook is empty.
274
+
275
+ ###### Parameters
276
+
277
+ ###### payload
278
+
279
+ `ProfileMutationUpdateShippingAddress`
280
+
281
+ ###### Returns
282
+
283
+ `Promise`\<`Result`\<`Profile`, `NotFoundError`\>\>
@@ -0,0 +1,146 @@
1
+ [**@reactionary/core**](README.md)
2
+
3
+ ***
4
+
5
+ [@reactionary/core](README.md) / store.provider
6
+
7
+ # store.provider
8
+
9
+ ## Classes
10
+
11
+ ### `abstract` StoreProvider
12
+
13
+ Defined in: [store.provider.ts:6](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/store.provider.ts#L6)
14
+
15
+ Base capability provider, responsible for mutations (changes) and queries (fetches)
16
+ for a given business object domain.
17
+
18
+ #### Extends
19
+
20
+ - [`BaseProvider`](base.provider.md#baseprovider)
21
+
22
+ #### Constructors
23
+
24
+ ##### Constructor
25
+
26
+ > **new StoreProvider**(`cache`, `context`): [`StoreProvider`](#storeprovider)
27
+
28
+ Defined in: [base.provider.ts:13](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L13)
29
+
30
+ ###### Parameters
31
+
32
+ ###### cache
33
+
34
+ `Cache`
35
+
36
+ ###### context
37
+
38
+ `RequestContext`
39
+
40
+ ###### Returns
41
+
42
+ [`StoreProvider`](#storeprovider)
43
+
44
+ ###### Inherited from
45
+
46
+ [`BaseProvider`](base.provider.md#baseprovider).[`constructor`](base.provider.md#constructor)
47
+
48
+ #### Properties
49
+
50
+ ##### cache
51
+
52
+ > `protected` **cache**: `Cache`
53
+
54
+ Defined in: [base.provider.ts:10](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L10)
55
+
56
+ ###### Inherited from
57
+
58
+ [`BaseProvider`](base.provider.md#baseprovider).[`cache`](base.provider.md#cache)
59
+
60
+ ##### context
61
+
62
+ > `protected` **context**: `RequestContext`
63
+
64
+ Defined in: [base.provider.ts:11](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L11)
65
+
66
+ ###### Inherited from
67
+
68
+ [`BaseProvider`](base.provider.md#baseprovider).[`context`](base.provider.md#context)
69
+
70
+ #### Methods
71
+
72
+ ##### generateCacheKeyForQuery()
73
+
74
+ > `protected` **generateCacheKeyForQuery**(`scope`, `query`): `string`
75
+
76
+ Defined in: [base.provider.ts:32](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L32)
77
+
78
+ ###### Parameters
79
+
80
+ ###### scope
81
+
82
+ `string`
83
+
84
+ ###### query
85
+
86
+ `object`
87
+
88
+ ###### Returns
89
+
90
+ `string`
91
+
92
+ ###### Inherited from
93
+
94
+ [`BaseProvider`](base.provider.md#baseprovider).[`generateCacheKeyForQuery`](base.provider.md#generatecachekeyforquery)
95
+
96
+ ##### generateDependencyIdsForModel()
97
+
98
+ > **generateDependencyIdsForModel**(`model`): `string`[]
99
+
100
+ Defined in: [base.provider.ts:18](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L18)
101
+
102
+ ###### Parameters
103
+
104
+ ###### model
105
+
106
+ `unknown`
107
+
108
+ ###### Returns
109
+
110
+ `string`[]
111
+
112
+ ###### Inherited from
113
+
114
+ [`BaseProvider`](base.provider.md#baseprovider).[`generateDependencyIdsForModel`](base.provider.md#generatedependencyidsformodel)
115
+
116
+ ##### getResourceName()
117
+
118
+ > `protected` **getResourceName**(): `string`
119
+
120
+ Defined in: [store.provider.ts:9](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/store.provider.ts#L9)
121
+
122
+ Returns the abstract resource name provided by the remote system.
123
+
124
+ ###### Returns
125
+
126
+ `string`
127
+
128
+ ###### Overrides
129
+
130
+ [`BaseProvider`](base.provider.md#baseprovider).[`getResourceName`](base.provider.md#getresourcename)
131
+
132
+ ##### queryByProximity()
133
+
134
+ > `abstract` **queryByProximity**(`payload`): `Promise`\<`Result`\<`Store`[]\>\>
135
+
136
+ Defined in: [store.provider.ts:7](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/store.provider.ts#L7)
137
+
138
+ ###### Parameters
139
+
140
+ ###### payload
141
+
142
+ `StoreQueryByProximity`
143
+
144
+ ###### Returns
145
+
146
+ `Promise`\<`Result`\<`Store`[]\>\>