Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 5816eb1

Browse files
authored
Merge pull request #22 from diconium/feature/release2.3
Chiran : Latest code release w.r.to latest Adobe CIF
2 parents 8ce0acf + 43f024c commit 5816eb1

File tree

131 files changed

+92511
-110675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+92511
-110675
lines changed

.DS_Store

-6 KB
Binary file not shown.

.eslintignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
**/coverage/**
1+
**/coverage/**
2+
/repos/aem-core-cif-components/
3+
/repos/commerce-cif-connector/

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
'prettier'
4343
],
4444
'parserOptions': {
45-
'ecmaVersion': 6
45+
'ecmaVersion': 8
4646
},
4747
'extends': [
4848
"prettier",

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ coverage
55
results.xml
66
.vscode
77
.idea
8-
cif/common/options.json
8+
/repos/aem-core-cif-components/
9+
/repos/commerce-cif-connector/
10+
diconium-CA.pem

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33

44
# 3rd-Party GraphQL integration with AEM Commerce and CIF on Adobe I/O Runtime
55

6-
## 2.3 (Unreleased)
6+
## 2.3 (March 14 2022)
7+
##### ENHANCEMENTS:
8+
* Latest Magento Schema Update
9+
* Changes in queries and mutations with respect to latest CIF and Venia
10+
* Code Optimisation and improvisation on security code check
11+
12+
##### BUGFIXES:
13+
* Commerce.html, Category Picker and Product Picker components fixes as per latest Schema
14+
NOTE : Category Search in category picker will be implemented in the next release.
15+
716

817
## 2.2 (June 11, 2021)
918
##### ENHANCEMENTS:

README.md

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
1-
# 3rd-Party GraphQL integration with AEM Commerce and CIF on Adobe I/O Runtime by [diconium](https://www.diconium.com)
1+
[![CircleCI](https://circleci.com/gh/adobe/commerce-cif-graphql-integration-reference.svg?style=svg)](https://circleci.com/gh/adobe/commerce-cif-graphql-integration-reference)
2+
[![codecov](https://codecov.io/gh/adobe/commerce-cif-graphql-integration-reference/branch/master/graph/badge.svg)](https://codecov.io/gh/adobe/commerce-cif-graphql-integration-reference)
23

3-
[![diconium-dds](images/diconium-dds.png "diconium digital solutions" )](https://diconium.com/en/news/adobe-io-hybris)
4+
# 3rd-Party GraphQL integration with AEM Commerce and CIF on Adobe I/O Runtime
45

56
## Introduction
67

78
The [CIF (Commerce Integration Framework) GraphQL connector](https://github.com/adobe/commerce-cif-connector) and the [AEM CIF Core Components](https://github.com/adobe/aem-core-cif-components) offer authoring and frontend integration between AEM (Adobe Experience Manager) and Magento. This integration is based on the [Magento GraphQL API](https://devdocs.magento.com/guides/v2.3/graphql/index.html) which offers a very flexible and efficient integration point between AEM and Magento.
89

9-
In order to support other 3rd-party "non-Magento" commerce platforms, this project demonstrates how a 3rd-party commerce platform like Hybris can be integrated with the CIF GraphQL connector and the AEM CIF Core Components via the Magento GraphQL API. Note that the integration is currently based on the GraphQL API of Magento 2.4.2.
10+
In order to support other 3rd-party "non-Magento" commerce platforms, this project implements an example "reference" implementation that demonstrates how a 3rd-party commerce platform can be integrated with the CIF GraphQL connector and the AEM CIF Core Components via the Magento GraphQL API. Note that the integration is currently based on the GraphQL API of Magento 2.3.2.
1011

11-
This enables customers to reuse our existing connector and components in their project by simply exposing the Magento GraphQL API on top of a 3rd-party commerce platform like Hybris. To offer maximum flexibility and scalability, this "adaptation layer" is deployed on the serverless [Adobe I/O Runtime](https://www.adobe.io/apis/experienceplatform/runtime.html) platform.
12+
This enables customers to reuse our existing connector and components in their project by simply exposing the Magento GraphQL API on top of any 3rd-party commerce platform. To offer maximum flexibility and scalability, this "adaptation layer" is deployed on the serverless [Adobe I/O Runtime](https://www.adobe.io/apis/experienceplatform/runtime.html) platform.
1213

1314
## Getting Started
1415

1516
### Project structure
1617

1718
This project is organized around [GraphQL resolvers](https://graphql.org/learn/execution/#root-fields-resolvers). Each resolver is either "local" or "remote". A "local" resolver is deployed and executed in the main Adobe I/O action that processes incoming GraphQL requests: we call this action the `dispatcher`. In contrast, a "remote" resolver is deployed as a separate Adobe I/O Runtime action which is referenced in the dispatcher action configuration and integrated via [schema delegation](https://www.apollographql.com/docs/graphql-tools/schema-delegation/).
1819

19-
All code is organized in the `cif` folder. In this implementation, all the resolvers are remote resolvers.
20+
All code is organized in the `src` folder.
2021

2122
```
22-
cif
23+
src
2324
├── common
25+
├── local
2426
├── dispatcher
25-
├── cart
26-
├── src
27-
├── test
28-
├── customer
29-
├── order
30-
├── product
31-
├── category
32-
├── resources
33-
├── utils
27+
├── remote
28+
├── cartResolver
3429
```
3530

3631
The `common` folder contains all the code that fetches and converts 3rd-party data into the GraphQL format. These classes can be used either by the local dispatcher action or by remote resolvers.
@@ -51,7 +46,7 @@ This second diagram illustrates how a GraphQL query is being executed. The `cart
5146

5247
![GraphQL query execution](images/graphql-query-execution.png)
5348

54-
## How to configure, build, test, and deploy
49+
## How to build, test, and deploy
5550

5651
### Tools
5752

@@ -62,36 +57,14 @@ Make sure you have the following tools installed:
6257

6358
OpenWhisk CLI must be available in your systems PATH and set up correctly to either use a local OpenWhisk installation or an Adobe I/O account. Try `wsk --help` to make sure it is working.
6459

65-
### Configuration
66-
To be able to use this CIF connector you will need to provid some Hybris configurations to connect to your Hybris endpoint.
67-
Under [cif/common/options.yml.example](cif/common/options.yml.example) you will find an example yml file you should use as an example.
68-
69-
The example file should look something like this
70-
```
71-
{
72-
"HB_CLIENTSECRET": "<CLIENT_SECRET>",
73-
"HB_CLIENTID": "<CLIENT_ID>",
74-
"HB_OAUTH_PATH": "/authorizationserver/oauth/token",
75-
"HB_API_HOST": "hybris.example.com",
76-
"HB_API_BASE_PATH": "/occ/v2/",
77-
"HB_BASESITEID": "electronics",
78-
"HB_PROTOCOL": "https",
79-
"HB_SECURE_BASE_MEDIA_URL": "https://hybris.example.com/yacceleratorstorefront"
80-
}
81-
```
82-
83-
You should copy the example file to an options.yml file under the same path, this will be the real file that will have your configurations.
84-
This file is under .gitignore and should not be commited to the repository since it has client secrets.
85-
86-
8760
### Build & Deployment
8861

8962
To install all the npm dependencies, and then execute all the unit tests, simply run:
9063
```
9164
$ npm install
9265
$ npm test
9366
```
94-
67+
```
9568
To deploy the actions on the Adobe I/O Runtime platform, we use the [serverless](https://serverless.com/framework/docs/providers/openwhisk/) framework. The deployment of independent packages and actions is defined in each package `serverless.yml` file. To deploy everything individually, simply run:
9669
```
9770
$ npm run deploy-packages
@@ -100,14 +73,29 @@ $ npm run deploy-packages
10073
To deploy the actions on the Adobe I/O Runtime platform, we use the [serverless](https://serverless.com/framework/docs/providers/openwhisk/) framework. The deployment of packages and actions is defined in the `serverless.yml` file. To deploy everything, simply run:
10174
```
10275
$ npm run deploy
103-
```
10476

105-
This will deploy the `hybris-graphql/dispatcher` and all other actions like cart, oder etc in your namespace (Complete list in serverless.yml file). The dispatcher is a web action that is accessible with the URL `https://adobeioruntime.net/api/v1/web/NAMESPACE/graphql-reference/dispatcher`. To test the GraphQL endpoint, you can for example use the `GraphiQL` plugin in the Chrome browser.
77+
78+
This will deploy the `graphql-reference/dispatcher` and `graphql-reference/cart` actions in your namespace. The dispatcher is a web action that is accessible with the URL `https://adobeioruntime.net/api/v1/web/NAMESPACE/graphql-reference/dispatcher`. To test the GraphQL endpoint, you can for example use the `GraphiQL` plugin in the Chrome browser.
79+
80+
Post deployment
81+
82+
1. Install Latest venia aem-cif-guides-venia.all-2022.02.24-classic.zip for classic AEM or cloud.
83+
2. Build and Install Latest CIF 2.6.0 on AEM with build package core-cif-components-all-2.6.0 in your package manager
84+
3. Include the connector server URL in cif configuration with required server details.
85+
4. Please refer https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/content-and-commerce/home.html for more details on configuration.
86+
87+
## Developing a real 3rd-party integration
88+
89+
This repository provides a reference implementation that can be used as a starting point to develop a real integration with a 3rd-party commerce system. In order to implement a real integration, one will have to:
90+
* modify all the `*Loader.js` classes so that they would fetch data via the 3rd-party commerce system (the loaders currently return some "dummy" example data)
91+
* modify all the `__convertData` conversion methods in the data classes, to convert the data from the 3rd-party system into Magento GraphQL objects
92+
* modify and extend the `getter` methods in the data classes, to support all the fields not covered by the example integration
93+
* introduce new local and/or remote resolvers, to incrementally support more fields of the Magento GraphQL API
10694

10795
### Contributing
10896

10997
Contributions are welcomed! Read the [Contributing Guide](.github/CONTRIBUTING.md) for more information.
11098

11199
### Licensing
112100

113-
This project is licensed under the Apache V2 License. See [LICENSE](LICENSE) for more information.
101+
This project is licensed under the Apache V2 License. See [LICENSE](LICENSE) for more information.

cif/cart/dispatcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function resolve(args) {
3030
const settings = new InputSettings(args);
3131

3232
let remoteResolvers = [];
33-
if (cachedSchema == null && args.remoteSchemas) {
33+
if (!cachedSchema && args.remoteSchemas) {
3434
// Get all resolver actions to fetch the remote schemas dynamically
3535
remoteResolvers = Object.values(args.remoteSchemas).map(resolver => {
3636
let fetcher = new RemoteResolverFetcher(resolver.action).fetcher;
@@ -48,7 +48,7 @@ function resolve(args) {
4848

4949
return Promise.all(remoteResolvers)
5050
.then(remotes => {
51-
if (cachedSchema == null) {
51+
if (!cachedSchema) {
5252
let remoteExecutableSchemas = [localSchema()];
5353

5454
if (args.remoteSchemas) {

cif/cart/lerna.json

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

cif/cart/src/AddProductToCart.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
'use strict';
1616

1717
const LoaderProxy = require('../../common/LoaderProxy.js');
18-
const CartItemInterface = require('./Interface/CartItemInterface');
1918
const AddProductToCartLoader = require('./AddProductToCartLoader.js');
20-
19+
const Cart = require('./Cart.js');
2120
class AddProductToCart {
2221
/**
2322
* @param {Object} parameters parameters object contains the cartId,Items to be added,graphqlContext & actionParameters
@@ -50,12 +49,14 @@ class AddProductToCart {
5049
* @param {Object} data parameter data contains details from hybris
5150
* @returns {Object} convert the hybris data into magento graphQL schema and return the object
5251
*/
53-
__convertData(data) {
54-
const { items } = new CartItemInterface([data.entry]);
52+
__convertData() {
5553
return {
56-
cart: {
57-
items,
58-
},
54+
cart: new Cart({
55+
cartId: this.input.cart_id,
56+
graphqlContext: this.graphqlContext,
57+
actionParameters: this.actionParameters,
58+
add: true,
59+
}),
5960
};
6061
}
6162
}

cif/cart/src/Cart.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ class Cart {
4949
__load() {
5050
console.debug(`Loading cart for ${this.cartId}`);
5151
return this.cartLoader.load(this.cartId).then(data => {
52+
//throw new Error(JSON.stringify(data));
5253
return this.shippingMethodsLoader.load(this.cartId).then(result => {
5354
data.deliveryModes = result.deliveryModes;
55+
data.cartId = this.cartId;
5456
return data;
5557
});
5658
});
@@ -62,7 +64,7 @@ class Cart {
6264
*/
6365
getRegionCode(address) {
6466
let code = address !== undefined ? address.region.isocode.split('-') : '';
65-
if (code !== '') {
67+
if (code && code.length) {
6668
code = code.length === 2 ? code[1] : code[0];
6769
} else {
6870
code = '';
@@ -131,9 +133,11 @@ class Cart {
131133
const { items } = new CartItemInterface(data.entries);
132134
return {
133135
items: items,
136+
id: data.cartId,
134137
email: user && user.uid,
135138
is_virtual: false,
136139
total_quantity: data.totalUnitCount,
140+
applied_gift_cards: [],
137141
billing_address: paymentInfo &&
138142
paymentInfo.billingAddress && {
139143
email: data.paymentInfo.billingAddress.email,
@@ -195,31 +199,33 @@ class Cart {
195199
code:
196200
paymentInfo && paymentInfo.cardType && paymentInfo.cardType.code
197201
? paymentInfo.cardType.code
198-
: 'visa',
202+
: 'free',
199203
title:
200204
paymentInfo && paymentInfo.cardType && paymentInfo.cardType.name
201205
? paymentInfo.cardType.name
202-
: 'Credit Card',
206+
: 'Free',
203207
},
204208
],
205209
selected_payment_method: {
206210
code:
207211
paymentInfo && paymentInfo.cardType && paymentInfo.cardType.code
208212
? paymentInfo.cardType.code
209-
: '',
213+
: 'free',
210214
title:
211215
paymentInfo && paymentInfo.cardType && paymentInfo.cardType.code
212216
? paymentInfo.cardType.code
213-
: '',
214-
},
215-
applied_coupon: {
216-
code:
217-
(appliedVouchers &&
218-
appliedVouchers.length > 0 &&
219-
appliedVouchers[0].code) ||
220-
'',
217+
: 'Free',
221218
},
219+
applied_coupons:
220+
appliedVouchers && appliedVouchers.length > 0 && appliedVouchers[0].code
221+
? [
222+
{
223+
code: appliedVouchers[0].code,
224+
},
225+
]
226+
: [],
222227
prices: {
228+
applied_taxes: [],
223229
grand_total: {
224230
value: totalPrice && data.totalPrice.value,
225231
currency: totalPrice && data.totalPrice.currencyIso,

0 commit comments

Comments
 (0)