Skip to content

Commit 40d79c6

Browse files
committed
Cleanup and update of packages
1 parent c47dd36 commit 40d79c6

33 files changed

Lines changed: 7237 additions & 6465 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@ coverage
4141
# logs folder for aio-run-detached
4242
logs
4343

44-
app.config.yaml
4544
adobe-api/mesh/mesh.json

DEVELOPMENT.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

INSTALL.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ To required environment add:
2020
### Adobe Api Mesh
2121

2222
1. Add "Api Mesh" service to your environment.
23-
2. Rename file `adobe-api/mesh.json.dist` into `adobe-api/mesh.json`.
24-
3. Change required options inside `adobe-api/mesh.json`.
25-
* MAGENTO-URL
26-
* MAGENTO-TOKEN
27-
3. Provision Mesh by using this file.
23+
2. Rename file `adobe-api/mesh/mesh.json.dist` into `adobe-api/mesh/mesh.json`.
24+
3. Change required options inside `adobe-api/mesh/mesh.json`.
25+
* MAGENTO-URL (This should be your Adobe Commerce system's base URL.)
26+
* MAGENTO-TOKEN
27+
28+
You can obtain the token by following these [steps](https://experienceleague.adobe.com/en/docs/commerce-admin/systems/integrations). Copy the Access Token value once generated. Additionally, you need to enable the "[Integration Token](https://experienceleague.adobe.com/en/docs/commerce-admin/systems/integrations)" functionality if it is not enabled yet. The generated token does not expire, but it can be updated if necessary.
29+
30+
3. Provision Mesh by using this file with `aio api-mesh create adobe-api/mesh/mesh.json`.
2831

2932
## Installation
3033

@@ -46,9 +49,9 @@ Add to `.env` line `FEED_GENERATOR_PROVIDER_ID=<id>`
4649

4750
7. Create Event Metadata for Feed Generator. Run `aio event eventmetadata create PROVIDERID`. Define event code as `feed.generate` and define description as `Generate Feed`.
4851

49-
8. Go To your application environment via Browser. Click on "Add Service" -> Event -> 3rd Party Custom Events -> And select your provider and event subscription. In Receiver define "Runtime action" as `processGeneration` action.
52+
8. Run `aio app deploy` to deploy the app.
5053

51-
9. Run `aio app deploy` to deploy the app.
54+
9. Go To your application environment via Browser. Click on "Add Service" -> Event -> 3rd Party Custom Events -> And select your provider and event subscription. In Receiver define "Runtime action" as `processGeneration` action.
5255

53-
10. App is ready to use. Pls save the link to your application environment. Additionally you can replacate all steps on your Production environment and publich application, so it will be available on your exchange dashboard.
56+
10. The app is ready to use. Please save the link to your application environment. Additionally, you can replicate all steps in your production environment and publish the application, so it will be available on your exchange dashboard.
5457

README.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Feed Generator is a service that simplifies the process of generating product fe
44

55
## Installation
66

7-
Pls see [INSTALL.md](INSTALL.md) for more details.
7+
Please see [INSTALL.md](INSTALL.md) for more details.
88

99
## Home page / Grid
1010

@@ -60,7 +60,7 @@ Here you can change the following elements:
6060

6161
### Feed Body
6262

63-
For feed body variables can be used. Variables are representing GQL schem that being used (by default it is a Adobe Commerce schema).
63+
Variables can be used for the feed body. These variables represent the GraphQL schema being used (by default, it is the Adobe Commerce schema).
6464

6565
Example:
6666

@@ -100,6 +100,68 @@ Based on this GQL schema you can use the following variables (starting inside of
100100

101101
… and so on depends on a schema used
102102

103+
### Filtering
104+
105+
Without applying filters, the system will attempt to fetch all available products for the selected store. To narrow down the selection, you can apply custom filters.
106+
107+
![Filtering](./docs/images/feed-filtering.png)
108+
109+
#### Search
110+
111+
In the search field, you can enter any search term, and it will be applied to the GraphQL "products" query as a search parameter.
112+
113+
```
114+
query {
115+
products(
116+
search:"Tank"
117+
) {
118+
items {
119+
sku
120+
name
121+
}
122+
}
123+
```
124+
125+
#### Filter Configuration
126+
127+
If you want to apply GraphQL filters, you can paste JSON that will be converted into a standard GraphQL filter.
128+
129+
As example, from
130+
131+
```
132+
{
133+
"category_id": {
134+
"eq": "26"
135+
}
136+
}
137+
```
138+
139+
to
140+
141+
```
142+
query {
143+
products(
144+
filter: { category_id: { eq: "26" } }
145+
) {
146+
items {
147+
sku
148+
name
149+
}
150+
}
151+
```
152+
153+
### Scheduling
154+
155+
You can configure how often feed can be updated.
156+
157+
In "Manual" mode, feed will be updated only by clicking "Regenerate Feed"
158+
159+
![Manual mode](./docs/images/feed-schedule-manual.png)
160+
161+
In "By Schedule" mode, feed will be automatically updated at defined time.
162+
163+
![Scheduled mode](./docs/images/feed-schedule-auto.png)
164+
103165
## Settings
104166

105167
GraphQL schema loaded from Adobe Commerce is cached by the module. So if you change schema on Adobe Commerce side, you have to update the cache.
@@ -163,7 +225,7 @@ To select a specific element from an array, use the `index` property. This will
163225

164226
Delete Feed - deleting current feed from the database and from all schedules
165227

166-
Regenerate Feed - will fire event “generate.feed for particular feed ID. And this event will triggen and action that will create new feed.
228+
Regenerate Feed - will trigger the event “generate.feed for a particular feed ID. This event will initiate an action that creates a new feed.
167229

168230
### app.config.yaml
169231

actions/acGql.js.DEPRECATED

Lines changed: 0 additions & 59 deletions
This file was deleted.

actions/acGqlLib/products.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {callMeshGql} = require("./../meshGql.js");
22

33
async function queryProducts (gqlRequest, params, variables = {}) {
4-
let products = await callMeshGql(gqlRequest, params, variables = {})
4+
let products = await callMeshGql(gqlRequest, params, variables)
55
return products
66
}
77

actions/acGqlLib/schema.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
const {getIntrospectionQuery, buildClientSchema} = require("graphql");
1+
const {getIntrospectionQuery} = require("graphql");
22
const {errorResponse} = require("./../utils.js");
3-
const fetch = require('node-fetch')
43

54
/**
65
* Return GQL schema or throw error
@@ -12,7 +11,7 @@ async function getSchema(params) {
1211
const gqlUrl = params['mesh_source_url']
1312

1413
const introspectionQuery = getIntrospectionQuery();
15-
let tty = JSON.stringify({query: introspectionQuery});
14+
1615
const result = await fetch(gqlUrl, {
1716
method: 'POST',
1817
headers: {

actions/acRest.js.DEPRECATED

Lines changed: 0 additions & 42 deletions
This file was deleted.

actions/deleteFeed/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
const {v4: uuidv4} = require('uuid');
2-
const fetch = require('node-fetch')
31
const {Core} = require('@adobe/aio-sdk')
42
const stateLib = require('@adobe/aio-lib-state')
5-
const {errorResponse, getBearerToken, stringParameters, checkMissingRequestInputs} = require('./../utils.js')
3+
const {errorResponse} = require('./../utils.js')
64

75
// delete feed by uuid
86
async function main(params) {
@@ -20,17 +18,17 @@ async function main(params) {
2018
if (uuid === null || typeof uuid == 'undefined' || uuid == 'undefined' || uuid == undefined) {
2119
return responseData
2220
}
23-
const [deleteResult, feedsInformation] = await Promise.all([
24-
state.delete('feeds_' + uuid),
25-
state.get('feeds_list') || {"value": {}}
26-
])
21+
22+
let feedsInformation = await state.get('feeds_list') || {"value": "{}"};
23+
24+
await state.delete('feeds_' + uuid);
2725

2826
// remove uuid from feed list
29-
const feedsList = feedsInformation['value']
27+
const feedsList = JSON.parse(feedsInformation['value'])
3028
const indexToRemove = Object.values(feedsList).indexOf(uuid);
3129
if (indexToRemove > -1) {
3230
delete feedsList[indexToRemove];
33-
await state.put('feeds_list', feedsList, { ttl: -1 });
31+
await state.put('feeds_list', JSON.stringify(feedsList), { ttl: stateLib.MAX_TTL });
3432
}
3533

3634
return responseData

actions/getAllFeeds/getByUuid.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
const { v4: uuidv4 } = require('uuid');
2-
const fetch = require('node-fetch')
31
const { Core } = require('@adobe/aio-sdk')
42
const stateLib = require('@adobe/aio-lib-state')
5-
const { errorResponse, getBearerToken, stringParameters, checkMissingRequestInputs } = require('./../utils.js')
3+
const { errorResponse } = require('./../utils.js')
64

75
// main function that will be executed by Adobe I/O Runtime
86
async function main (params) {
@@ -12,15 +10,18 @@ async function main (params) {
1210
try {
1311
const state = await stateLib.init()
1412
const uuid = params.uuid
15-
let feedInformation = await state.get('feeds_' + uuid) || 0
1613

17-
if (feedInformation === 0) {
18-
feedInformation = {}
14+
let feedsInformation = await state.get('feeds_' + uuid) || 0;
15+
16+
if (feedsInformation === 0) {
17+
feedsInformation = {}
18+
} else {
19+
feedsInformation['value'] = JSON.parse(feedsInformation['value']);
1920
}
2021

2122
const response = {
2223
statusCode: 200,
23-
body: feedInformation
24+
body: feedsInformation
2425
}
2526
return response
2627

0 commit comments

Comments
 (0)