@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.
- package/core/src/client/client-builder.ts +3 -7
- package/core/src/client/client.ts +2 -3
- package/core/src/decorators/reactionary.decorator.ts +2 -2
- package/core/src/initialization.ts +11 -3
- package/core/src/providers/analytics.provider.ts +75 -0
- package/core/src/providers/cart.provider.ts +3 -0
- package/core/src/providers/category.provider.ts +1 -0
- package/core/src/providers/identity.provider.ts +5 -0
- package/core/src/schemas/errors/invalid-input.error.ts +1 -1
- package/core/src/schemas/errors/invalid-output.error.ts +1 -1
- package/core/src/schemas/models/identifiers.model.ts +3 -0
- package/core/src/schemas/models/order.model.ts +2 -2
- package/core/src/schemas/mutations/analytics/index.ts +23 -0
- package/core/src/schemas/mutations/analytics/product-add-to-cart.mutation.ts +25 -0
- package/core/src/schemas/mutations/analytics/product-details-view.mutation.ts +14 -0
- package/core/src/schemas/mutations/analytics/product-summary-click.mutation.ts +26 -0
- package/core/src/schemas/mutations/analytics/product-summary-view.mutation.ts +25 -0
- package/core/src/schemas/mutations/analytics/purchase.mutation.ts +14 -0
- package/core/src/schemas/mutations/index.ts +1 -1
- package/core/src/schemas/queries/order-search.query.ts +3 -0
- package/core/src/schemas/session.schema.ts +21 -9
- package/core/src/test/client-builder.spec.ts +60 -0
- package/core/src/zod-utils.ts +3 -1
- package/documentation/{1-purpose.md → docs/1-purpose.md} +4 -0
- package/documentation/docs/8-tracking.md +9 -0
- package/documentation/docs/providers/analytics.provider.md +297 -0
- package/documentation/docs/providers/base.provider.md +118 -0
- package/documentation/docs/providers/cart.provider.md +305 -0
- package/documentation/docs/providers/category.provider.md +244 -0
- package/documentation/docs/providers/checkout.provider.md +315 -0
- package/documentation/docs/providers/identity.provider.md +194 -0
- package/documentation/docs/providers/inventory.provider.md +162 -0
- package/documentation/docs/providers/order-search.provider.md +155 -0
- package/documentation/docs/providers/order.provider.md +160 -0
- package/documentation/docs/providers/price.provider.md +197 -0
- package/documentation/docs/providers/product-search.provider.md +265 -0
- package/documentation/docs/providers/product.provider.md +204 -0
- package/documentation/docs/providers/profile.provider.md +283 -0
- package/documentation/docs/providers/store.provider.md +146 -0
- package/documentation/docs/schemas/schemas.md +1862 -0
- package/documentation/docusaurus.config.js +33 -0
- package/documentation/scripts/generate.ts +52 -0
- package/documentation/sidebars.js +8 -0
- package/documentation/src/css/custom.css +3 -0
- package/documentation/src/pages/index.js +12 -0
- package/eslint.config.mjs +1 -1
- package/examples/node/package.json +6 -6
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +0 -2
- package/examples/node/src/basic/client-creation.spec.ts +2 -2
- package/package.json +19 -5
- package/providers/algolia/README.md +12 -4
- package/providers/algolia/project.json +1 -1
- package/providers/algolia/src/core/initialize.ts +7 -2
- package/providers/algolia/src/providers/analytics.provider.ts +114 -0
- package/providers/algolia/src/providers/index.ts +1 -0
- package/providers/algolia/src/providers/product-search.provider.ts +5 -4
- package/providers/algolia/src/test/analytics.spec.ts +138 -0
- package/providers/commercetools/project.json +1 -1
- package/providers/commercetools/src/providers/identity.provider.ts +8 -1
- package/providers/commercetools/src/providers/profile.provider.ts +1 -4
- package/providers/commercetools/src/test/caching.spec.ts +3 -3
- package/providers/commercetools/src/test/identity.spec.ts +2 -2
- package/providers/fake/project.json +1 -1
- package/providers/fake/src/providers/analytics.provider.ts +5 -0
- package/providers/fake/src/providers/checkout.provider.ts +5 -2
- package/providers/fake/src/providers/product.provider.ts +18 -8
- package/providers/fake/src/test/cart.provider.spec.ts +0 -2
- package/providers/fake/src/test/category.provider.spec.ts +3 -3
- package/providers/fake/src/test/checkout.provider.spec.ts +3 -7
- package/providers/google-analytics/README.md +11 -0
- package/providers/google-analytics/eslint.config.mjs +25 -0
- package/providers/google-analytics/package.json +12 -0
- package/providers/google-analytics/project.json +33 -0
- package/providers/google-analytics/src/core/initialize.ts +16 -0
- package/providers/google-analytics/src/index.ts +4 -0
- package/providers/google-analytics/src/providers/analytics.provider.ts +162 -0
- package/providers/google-analytics/src/schema/capabilities.schema.ts +10 -0
- package/providers/google-analytics/src/schema/configuration.schema.ts +9 -0
- package/providers/google-analytics/src/test/analytics.provider.spec.ts +93 -0
- package/providers/google-analytics/tsconfig.json +24 -0
- package/providers/google-analytics/tsconfig.lib.json +23 -0
- package/providers/google-analytics/tsconfig.spec.json +28 -0
- package/providers/google-analytics/vite.config.ts +26 -0
- package/providers/google-analytics/vitest.config.mts +21 -0
- package/providers/medusa/package.json +3 -10
- package/providers/medusa/project.json +1 -1
- package/providers/medusa/src/providers/identity.provider.ts +34 -10
- package/providers/medusa/src/providers/profile.provider.ts +5 -15
- package/providers/medusa/src/test/test-utils.ts +0 -1
- package/providers/medusa/tsconfig.json +3 -0
- package/providers/medusa/tsconfig.lib.json +16 -1
- package/providers/meilisearch/project.json +1 -1
- package/providers/posthog/project.json +1 -1
- package/tsconfig.base.json +4 -1
- package/.claude/settings.local.json +0 -28
- package/core/src/schemas/mutations/analytics.mutation.ts +0 -23
- package/providers/algolia/src/test/test-utils.ts +0 -31
- /package/documentation/{2-getting-started.md → docs/2-getting-started.md} +0 -0
- /package/documentation/{3-querying-and-changing-data.md → docs/3-querying-and-changing-data.md} +0 -0
- /package/documentation/{4-product-data.md → docs/4-product-data.md} +0 -0
- /package/documentation/{5-cart-and-checkout.md → docs/5-cart-and-checkout.md} +0 -0
- /package/documentation/{6-product-search.md → docs/6-product-search.md} +0 -0
- /package/documentation/{7-marketing.md → docs/7-marketing.md} +0 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
[**@reactionary/core**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@reactionary/core](README.md) / price.provider
|
|
6
|
+
|
|
7
|
+
# price.provider
|
|
8
|
+
|
|
9
|
+
## Classes
|
|
10
|
+
|
|
11
|
+
### `abstract` PriceProvider
|
|
12
|
+
|
|
13
|
+
Defined in: [price.provider.ts:8](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/price.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 PriceProvider**(`cache`, `context`): [`PriceProvider`](#priceprovider)
|
|
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
|
+
[`PriceProvider`](#priceprovider)
|
|
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
|
+
##### createEmptyPriceResult()
|
|
73
|
+
|
|
74
|
+
> `protected` **createEmptyPriceResult**(`sku`): `Price`
|
|
75
|
+
|
|
76
|
+
Defined in: [price.provider.ts:38](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/price.provider.ts#L38)
|
|
77
|
+
|
|
78
|
+
Utility function to create an empty price result, with a value of -1.
|
|
79
|
+
This is used when no price is found for a given SKU + currency combination.
|
|
80
|
+
You should check for meta.placeholder to see if this is a real price or a placeholder.
|
|
81
|
+
|
|
82
|
+
###### Parameters
|
|
83
|
+
|
|
84
|
+
###### sku
|
|
85
|
+
|
|
86
|
+
`string`
|
|
87
|
+
|
|
88
|
+
###### Returns
|
|
89
|
+
|
|
90
|
+
`Price`
|
|
91
|
+
|
|
92
|
+
##### generateCacheKeyForQuery()
|
|
93
|
+
|
|
94
|
+
> `protected` **generateCacheKeyForQuery**(`scope`, `query`): `string`
|
|
95
|
+
|
|
96
|
+
Defined in: [base.provider.ts:32](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L32)
|
|
97
|
+
|
|
98
|
+
###### Parameters
|
|
99
|
+
|
|
100
|
+
###### scope
|
|
101
|
+
|
|
102
|
+
`string`
|
|
103
|
+
|
|
104
|
+
###### query
|
|
105
|
+
|
|
106
|
+
`object`
|
|
107
|
+
|
|
108
|
+
###### Returns
|
|
109
|
+
|
|
110
|
+
`string`
|
|
111
|
+
|
|
112
|
+
###### Inherited from
|
|
113
|
+
|
|
114
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`generateCacheKeyForQuery`](base.provider.md#generatecachekeyforquery)
|
|
115
|
+
|
|
116
|
+
##### generateDependencyIdsForModel()
|
|
117
|
+
|
|
118
|
+
> **generateDependencyIdsForModel**(`model`): `string`[]
|
|
119
|
+
|
|
120
|
+
Defined in: [base.provider.ts:18](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L18)
|
|
121
|
+
|
|
122
|
+
###### Parameters
|
|
123
|
+
|
|
124
|
+
###### model
|
|
125
|
+
|
|
126
|
+
`unknown`
|
|
127
|
+
|
|
128
|
+
###### Returns
|
|
129
|
+
|
|
130
|
+
`string`[]
|
|
131
|
+
|
|
132
|
+
###### Inherited from
|
|
133
|
+
|
|
134
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`generateDependencyIdsForModel`](base.provider.md#generatedependencyidsformodel)
|
|
135
|
+
|
|
136
|
+
##### getCustomerPrice()
|
|
137
|
+
|
|
138
|
+
> `abstract` **getCustomerPrice**(`payload`): `Promise`\<`Result`\<`Price`\>\>
|
|
139
|
+
|
|
140
|
+
Defined in: [price.provider.ts:28](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/price.provider.ts#L28)
|
|
141
|
+
|
|
142
|
+
Get a customer-specific price by SKU.
|
|
143
|
+
|
|
144
|
+
No
|
|
145
|
+
|
|
146
|
+
Usecase: You are rendering a product page, and you need to show the price for a SKU.
|
|
147
|
+
|
|
148
|
+
###### Parameters
|
|
149
|
+
|
|
150
|
+
###### payload
|
|
151
|
+
|
|
152
|
+
`CustomerPriceQuery`
|
|
153
|
+
|
|
154
|
+
The SKU to query
|
|
155
|
+
|
|
156
|
+
###### Returns
|
|
157
|
+
|
|
158
|
+
`Promise`\<`Result`\<`Price`\>\>
|
|
159
|
+
|
|
160
|
+
##### getListPrice()
|
|
161
|
+
|
|
162
|
+
> `abstract` **getListPrice**(`payload`): `Promise`\<`Result`\<`Price`\>\>
|
|
163
|
+
|
|
164
|
+
Defined in: [price.provider.ts:17](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/price.provider.ts#L17)
|
|
165
|
+
|
|
166
|
+
Get a list price price by SKU. This is the most general, undiscounted price and is typically
|
|
167
|
+
used as the "before" price in most ecommerce setups.
|
|
168
|
+
|
|
169
|
+
Usecase: You are rendering a product page, and you need to show the price for a SKU.
|
|
170
|
+
|
|
171
|
+
###### Parameters
|
|
172
|
+
|
|
173
|
+
###### payload
|
|
174
|
+
|
|
175
|
+
`ListPriceQuery`
|
|
176
|
+
|
|
177
|
+
The SKU to query
|
|
178
|
+
|
|
179
|
+
###### Returns
|
|
180
|
+
|
|
181
|
+
`Promise`\<`Result`\<`Price`\>\>
|
|
182
|
+
|
|
183
|
+
##### getResourceName()
|
|
184
|
+
|
|
185
|
+
> `protected` **getResourceName**(): `string`
|
|
186
|
+
|
|
187
|
+
Defined in: [price.provider.ts:55](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/price.provider.ts#L55)
|
|
188
|
+
|
|
189
|
+
Returns the abstract resource name provided by the remote system.
|
|
190
|
+
|
|
191
|
+
###### Returns
|
|
192
|
+
|
|
193
|
+
`string`
|
|
194
|
+
|
|
195
|
+
###### Overrides
|
|
196
|
+
|
|
197
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`getResourceName`](base.provider.md#getresourcename)
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
[**@reactionary/core**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@reactionary/core](README.md) / product-search.provider
|
|
6
|
+
|
|
7
|
+
# product-search.provider
|
|
8
|
+
|
|
9
|
+
## Classes
|
|
10
|
+
|
|
11
|
+
### `abstract` ProductSearchProvider
|
|
12
|
+
|
|
13
|
+
Defined in: [product-search.provider.ts:6](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product-search.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 ProductSearchProvider**(`cache`, `context`): [`ProductSearchProvider`](#productsearchprovider)
|
|
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
|
+
[`ProductSearchProvider`](#productsearchprovider)
|
|
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
|
+
##### createCategoryNavigationFilter()
|
|
73
|
+
|
|
74
|
+
> `abstract` **createCategoryNavigationFilter**(`payload`): `Promise`\<`Result`\<`FacetValueIdentifier`\>\>
|
|
75
|
+
|
|
76
|
+
Defined in: [product-search.provider.ts:32](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product-search.provider.ts#L32)
|
|
77
|
+
|
|
78
|
+
Since each platform has it own way of representing categories and their hierarchy, we leave it to the platform to tell us how to get from a
|
|
79
|
+
category breadcrumb path to a global category navigation filter that can be applied to product searches.
|
|
80
|
+
|
|
81
|
+
So, the CLP pattern would be
|
|
82
|
+
|
|
83
|
+
const c: Category = await categoryProvider.getBySlug({ slug: 'some-category' });
|
|
84
|
+
const breadcrumbPath: Category[] = await categoryProvider.getBreadcrumbPathToCategory({ id: c.identifier });
|
|
85
|
+
const categoryFilter: FacetValueIdentifier = categoryNavigationProvider.createCategoryNavigationFilterBreadcrumbs(breadcrumbPath);
|
|
86
|
+
const searchResult: ProductSearchResult = await productSearchProvider.queryByTerm({ term: 'some search', facets: [], categoryFilter: [categoryFilter], ... });
|
|
87
|
+
|
|
88
|
+
from here, you would maybe get facets back with subcategories, but those are relative to the current category filter you have applied, so you
|
|
89
|
+
do not need any special handling for that.
|
|
90
|
+
|
|
91
|
+
Usecase: You are rendering a category page and you want to run a product search to find everything in that category (or below).
|
|
92
|
+
|
|
93
|
+
###### Parameters
|
|
94
|
+
|
|
95
|
+
###### payload
|
|
96
|
+
|
|
97
|
+
`ProductSearchQueryCreateNavigationFilter`
|
|
98
|
+
|
|
99
|
+
###### Returns
|
|
100
|
+
|
|
101
|
+
`Promise`\<`Result`\<`FacetValueIdentifier`\>\>
|
|
102
|
+
|
|
103
|
+
##### generateCacheKeyForQuery()
|
|
104
|
+
|
|
105
|
+
> `protected` **generateCacheKeyForQuery**(`scope`, `query`): `string`
|
|
106
|
+
|
|
107
|
+
Defined in: [base.provider.ts:32](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L32)
|
|
108
|
+
|
|
109
|
+
###### Parameters
|
|
110
|
+
|
|
111
|
+
###### scope
|
|
112
|
+
|
|
113
|
+
`string`
|
|
114
|
+
|
|
115
|
+
###### query
|
|
116
|
+
|
|
117
|
+
`object`
|
|
118
|
+
|
|
119
|
+
###### Returns
|
|
120
|
+
|
|
121
|
+
`string`
|
|
122
|
+
|
|
123
|
+
###### Inherited from
|
|
124
|
+
|
|
125
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`generateCacheKeyForQuery`](base.provider.md#generatecachekeyforquery)
|
|
126
|
+
|
|
127
|
+
##### generateDependencyIdsForModel()
|
|
128
|
+
|
|
129
|
+
> **generateDependencyIdsForModel**(`model`): `string`[]
|
|
130
|
+
|
|
131
|
+
Defined in: [base.provider.ts:18](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L18)
|
|
132
|
+
|
|
133
|
+
###### Parameters
|
|
134
|
+
|
|
135
|
+
###### model
|
|
136
|
+
|
|
137
|
+
`unknown`
|
|
138
|
+
|
|
139
|
+
###### Returns
|
|
140
|
+
|
|
141
|
+
`string`[]
|
|
142
|
+
|
|
143
|
+
###### Inherited from
|
|
144
|
+
|
|
145
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`generateDependencyIdsForModel`](base.provider.md#generatedependencyidsformodel)
|
|
146
|
+
|
|
147
|
+
##### getResourceName()
|
|
148
|
+
|
|
149
|
+
> `protected` **getResourceName**(): `string`
|
|
150
|
+
|
|
151
|
+
Defined in: [product-search.provider.ts:7](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product-search.provider.ts#L7)
|
|
152
|
+
|
|
153
|
+
Returns the abstract resource name provided by the remote system.
|
|
154
|
+
|
|
155
|
+
###### Returns
|
|
156
|
+
|
|
157
|
+
`string`
|
|
158
|
+
|
|
159
|
+
###### Overrides
|
|
160
|
+
|
|
161
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`getResourceName`](base.provider.md#getresourcename)
|
|
162
|
+
|
|
163
|
+
##### parseFacet()
|
|
164
|
+
|
|
165
|
+
> `abstract` `protected` **parseFacet**(`facetIdentifier`, `facetValue`): `ProductSearchResultFacet`
|
|
166
|
+
|
|
167
|
+
Defined in: [product-search.provider.ts:49](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product-search.provider.ts#L49)
|
|
168
|
+
|
|
169
|
+
Parses a facet from the search response.
|
|
170
|
+
|
|
171
|
+
###### Parameters
|
|
172
|
+
|
|
173
|
+
###### facetIdentifier
|
|
174
|
+
|
|
175
|
+
`FacetIdentifier`
|
|
176
|
+
|
|
177
|
+
The identifier for the facet.
|
|
178
|
+
|
|
179
|
+
###### facetValue
|
|
180
|
+
|
|
181
|
+
`unknown`
|
|
182
|
+
|
|
183
|
+
The value for the facet.
|
|
184
|
+
|
|
185
|
+
Usecase: Override this to customize the parsing of facets.
|
|
186
|
+
|
|
187
|
+
###### Returns
|
|
188
|
+
|
|
189
|
+
`ProductSearchResultFacet`
|
|
190
|
+
|
|
191
|
+
##### parseFacetValue()
|
|
192
|
+
|
|
193
|
+
> `abstract` `protected` **parseFacetValue**(`facetValueIdentifier`, `label`, `count`): `ProductSearchResultFacetValue`
|
|
194
|
+
|
|
195
|
+
Defined in: [product-search.provider.ts:40](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product-search.provider.ts#L40)
|
|
196
|
+
|
|
197
|
+
Parses a facet value from the search response.
|
|
198
|
+
|
|
199
|
+
###### Parameters
|
|
200
|
+
|
|
201
|
+
###### facetValueIdentifier
|
|
202
|
+
|
|
203
|
+
`FacetValueIdentifier`
|
|
204
|
+
|
|
205
|
+
The identifier for the facet value.
|
|
206
|
+
|
|
207
|
+
###### label
|
|
208
|
+
|
|
209
|
+
`string`
|
|
210
|
+
|
|
211
|
+
The label for the facet value.
|
|
212
|
+
|
|
213
|
+
###### count
|
|
214
|
+
|
|
215
|
+
`number`
|
|
216
|
+
|
|
217
|
+
The count for the facet value.
|
|
218
|
+
|
|
219
|
+
###### Returns
|
|
220
|
+
|
|
221
|
+
`ProductSearchResultFacetValue`
|
|
222
|
+
|
|
223
|
+
##### parseVariant()
|
|
224
|
+
|
|
225
|
+
> `abstract` `protected` **parseVariant**(`variant`, `product`): `ProductSearchResultItemVariant`
|
|
226
|
+
|
|
227
|
+
Defined in: [product-search.provider.ts:58](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product-search.provider.ts#L58)
|
|
228
|
+
|
|
229
|
+
Parses a product variant from the search response.
|
|
230
|
+
|
|
231
|
+
###### Parameters
|
|
232
|
+
|
|
233
|
+
###### variant
|
|
234
|
+
|
|
235
|
+
`unknown`
|
|
236
|
+
|
|
237
|
+
The variant data from the search response.
|
|
238
|
+
|
|
239
|
+
###### product
|
|
240
|
+
|
|
241
|
+
`unknown`
|
|
242
|
+
|
|
243
|
+
The product data from the search response.
|
|
244
|
+
|
|
245
|
+
Usecase: Override this to customize the parsing of product variants.
|
|
246
|
+
|
|
247
|
+
###### Returns
|
|
248
|
+
|
|
249
|
+
`ProductSearchResultItemVariant`
|
|
250
|
+
|
|
251
|
+
##### queryByTerm()
|
|
252
|
+
|
|
253
|
+
> `abstract` **queryByTerm**(`payload`): `Promise`\<`Result`\<`ProductSearchResult`\>\>
|
|
254
|
+
|
|
255
|
+
Defined in: [product-search.provider.ts:11](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product-search.provider.ts#L11)
|
|
256
|
+
|
|
257
|
+
###### Parameters
|
|
258
|
+
|
|
259
|
+
###### payload
|
|
260
|
+
|
|
261
|
+
`ProductSearchQueryByTerm`
|
|
262
|
+
|
|
263
|
+
###### Returns
|
|
264
|
+
|
|
265
|
+
`Promise`\<`Result`\<`ProductSearchResult`\>\>
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
[**@reactionary/core**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@reactionary/core](README.md) / product.provider
|
|
6
|
+
|
|
7
|
+
# product.provider
|
|
8
|
+
|
|
9
|
+
## Classes
|
|
10
|
+
|
|
11
|
+
### `abstract` ProductProvider
|
|
12
|
+
|
|
13
|
+
Defined in: [product.provider.ts:7](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product.provider.ts#L7)
|
|
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 ProductProvider**(`cache`, `context`): [`ProductProvider`](#productprovider)
|
|
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
|
+
[`ProductProvider`](#productprovider)
|
|
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
|
+
##### createEmptyProduct()
|
|
73
|
+
|
|
74
|
+
> `protected` **createEmptyProduct**(`id`): `Product`
|
|
75
|
+
|
|
76
|
+
Defined in: [product.provider.ts:44](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product.provider.ts#L44)
|
|
77
|
+
|
|
78
|
+
###### Parameters
|
|
79
|
+
|
|
80
|
+
###### id
|
|
81
|
+
|
|
82
|
+
`string`
|
|
83
|
+
|
|
84
|
+
###### Returns
|
|
85
|
+
|
|
86
|
+
`Product`
|
|
87
|
+
|
|
88
|
+
##### generateCacheKeyForQuery()
|
|
89
|
+
|
|
90
|
+
> `protected` **generateCacheKeyForQuery**(`scope`, `query`): `string`
|
|
91
|
+
|
|
92
|
+
Defined in: [base.provider.ts:32](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L32)
|
|
93
|
+
|
|
94
|
+
###### Parameters
|
|
95
|
+
|
|
96
|
+
###### scope
|
|
97
|
+
|
|
98
|
+
`string`
|
|
99
|
+
|
|
100
|
+
###### query
|
|
101
|
+
|
|
102
|
+
`object`
|
|
103
|
+
|
|
104
|
+
###### Returns
|
|
105
|
+
|
|
106
|
+
`string`
|
|
107
|
+
|
|
108
|
+
###### Inherited from
|
|
109
|
+
|
|
110
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`generateCacheKeyForQuery`](base.provider.md#generatecachekeyforquery)
|
|
111
|
+
|
|
112
|
+
##### generateDependencyIdsForModel()
|
|
113
|
+
|
|
114
|
+
> **generateDependencyIdsForModel**(`model`): `string`[]
|
|
115
|
+
|
|
116
|
+
Defined in: [base.provider.ts:18](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/base.provider.ts#L18)
|
|
117
|
+
|
|
118
|
+
###### Parameters
|
|
119
|
+
|
|
120
|
+
###### model
|
|
121
|
+
|
|
122
|
+
`unknown`
|
|
123
|
+
|
|
124
|
+
###### Returns
|
|
125
|
+
|
|
126
|
+
`string`[]
|
|
127
|
+
|
|
128
|
+
###### Inherited from
|
|
129
|
+
|
|
130
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`generateDependencyIdsForModel`](base.provider.md#generatedependencyidsformodel)
|
|
131
|
+
|
|
132
|
+
##### getById()
|
|
133
|
+
|
|
134
|
+
> `abstract` **getById**(`payload`): `Promise`\<`Result`\<`Product`\>\>
|
|
135
|
+
|
|
136
|
+
Defined in: [product.provider.ts:20](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product.provider.ts#L20)
|
|
137
|
+
|
|
138
|
+
Get a product by its ID.
|
|
139
|
+
|
|
140
|
+
###### Parameters
|
|
141
|
+
|
|
142
|
+
###### payload
|
|
143
|
+
|
|
144
|
+
`ProductQueryById`
|
|
145
|
+
|
|
146
|
+
The query payload containing the product ID.
|
|
147
|
+
|
|
148
|
+
###### Returns
|
|
149
|
+
|
|
150
|
+
`Promise`\<`Result`\<`Product`\>\>
|
|
151
|
+
|
|
152
|
+
##### getBySKU()
|
|
153
|
+
|
|
154
|
+
> `abstract` **getBySKU**(`payload`): `Promise`\<`Result`\<`Product`\>\>
|
|
155
|
+
|
|
156
|
+
Defined in: [product.provider.ts:42](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product.provider.ts#L42)
|
|
157
|
+
|
|
158
|
+
Get a product by its SKU
|
|
159
|
+
|
|
160
|
+
###### Parameters
|
|
161
|
+
|
|
162
|
+
###### payload
|
|
163
|
+
|
|
164
|
+
`ProductQueryBySKU`
|
|
165
|
+
|
|
166
|
+
###### Returns
|
|
167
|
+
|
|
168
|
+
`Promise`\<`Result`\<`Product`\>\>
|
|
169
|
+
|
|
170
|
+
##### getBySlug()
|
|
171
|
+
|
|
172
|
+
> `abstract` **getBySlug**(`payload`): `Promise`\<`Result`\<`Product`, `NotFoundError`\>\>
|
|
173
|
+
|
|
174
|
+
Defined in: [product.provider.ts:30](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product.provider.ts#L30)
|
|
175
|
+
|
|
176
|
+
Get a product by its slug.
|
|
177
|
+
|
|
178
|
+
###### Parameters
|
|
179
|
+
|
|
180
|
+
###### payload
|
|
181
|
+
|
|
182
|
+
`ProductQueryBySlug`
|
|
183
|
+
|
|
184
|
+
The query payload containing the product slug.
|
|
185
|
+
|
|
186
|
+
###### Returns
|
|
187
|
+
|
|
188
|
+
`Promise`\<`Result`\<`Product`, `NotFoundError`\>\>
|
|
189
|
+
|
|
190
|
+
##### getResourceName()
|
|
191
|
+
|
|
192
|
+
> `protected` **getResourceName**(): `string`
|
|
193
|
+
|
|
194
|
+
Defined in: [product.provider.ts:83](https://github.com/Solteq/reactionary/blob/ca9304f3dfc56eb7283e5bdf90b26f13d42dce7d/core/src/providers/product.provider.ts#L83)
|
|
195
|
+
|
|
196
|
+
The resource name, used for caching and logging.
|
|
197
|
+
|
|
198
|
+
###### Returns
|
|
199
|
+
|
|
200
|
+
`string`
|
|
201
|
+
|
|
202
|
+
###### Overrides
|
|
203
|
+
|
|
204
|
+
[`BaseProvider`](base.provider.md#baseprovider).[`getResourceName`](base.provider.md#getresourcename)
|