Skip to content

Commit

Permalink
Merge branch 'develop' into alpha23
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseacornejo authored Nov 21, 2024
2 parents cc55608 + 735e482 commit c5cb3ec
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 30 deletions.
18 changes: 12 additions & 6 deletions scripts/commerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,26 @@ query($sku: String!) {
}
`;

export async function commerceEndpointWithQueryParams() {
// Set Query Parameters so they can be appended to the endpoint
const urlWithQueryParams = new URL(await getConfigValue('commerce-endpoint'));
urlWithQueryParams.searchParams.append('Magento-Environment-Id', await getConfigValue('commerce-environment-id'));
urlWithQueryParams.searchParams.append('Magento-Website-Code', await getConfigValue('commerce-website-code'));
urlWithQueryParams.searchParams.append('Magento-Store-View-Code', await getConfigValue('commerce-store-view-code'));
urlWithQueryParams.searchParams.append('Magento-Store-Code', await getConfigValue('commerce-store-code'));
urlWithQueryParams.searchParams.append('Magento-Customer-Group', await getConfigValue('commerce-customer-group'));
return urlWithQueryParams;
}

/* Common functionality */

export async function performCatalogServiceQuery(query, variables) {
const headers = {
'Content-Type': 'application/json',
'Magento-Environment-Id': await getConfigValue('commerce-environment-id'),
'Magento-Website-Code': await getConfigValue('commerce-website-code'),
'Magento-Store-View-Code': await getConfigValue('commerce-store-view-code'),
'Magento-Store-Code': await getConfigValue('commerce-store-code'),
'Magento-Customer-Group': await getConfigValue('commerce-customer-group'),
'x-api-key': await getConfigValue('commerce-x-api-key'),
};

const apiCall = new URL(await getConfigValue('commerce-endpoint'));
const apiCall = await commerceEndpointWithQueryParams();
apiCall.searchParams.append('query', query.replace(/(?:\r\n|\r|\n|\t|[\s]{4})/g, ' ')
.replace(/\s\s+/g, ' '));
apiCall.searchParams.append('variables', variables ? JSON.stringify(variables) : null);
Expand Down
9 changes: 2 additions & 7 deletions scripts/initializers/pdp.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { initializers } from '@dropins/tools/initializer.js';
import { initialize, setEndpoint, setFetchGraphQlHeaders } from '@dropins/storefront-pdp/api.js';
import { initializeDropin } from './index.js';
import { getProduct, getSkuFromUrl } from '../commerce.js';
import { commerceEndpointWithQueryParams, getProduct, getSkuFromUrl } from '../commerce.js';
import { getConfigValue } from '../configs.js';
import { fetchPlaceholders } from '../aem.js';

await initializeDropin(async () => {
// Set Fetch Endpoint (Service)
setEndpoint(await getConfigValue('commerce-endpoint'));
setEndpoint(await commerceEndpointWithQueryParams());

// Set Fetch Headers (Service)
setFetchGraphQlHeaders({
'Content-Type': 'application/json',
'Magento-Environment-Id': await getConfigValue('commerce-environment-id'),
'Magento-Website-Code': await getConfigValue('commerce-website-code'),
'Magento-Store-View-Code': await getConfigValue('commerce-store-view-code'),
'Magento-Store-Code': await getConfigValue('commerce-store-code'),
'Magento-Customer-Group': await getConfigValue('commerce-customer-group'),
'x-api-key': await getConfigValue('commerce-x-api-key'),
});

Expand Down
9 changes: 2 additions & 7 deletions tools/pdp-metadata/pdp-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@ import fs from 'fs';
import he from 'he';
import productSearchQuery from './queries/products.graphql.js';
import { variantsFragment } from './queries/variants.graphql.js';
import { commerceEndpointWithQueryParams } from "../../scripts/commerce.js";

const basePath = 'https://www.aemshop.net';
const configFile = `${basePath}/configs.json?sheet=prod`;


async function performCatalogServiceQuery(config, query, variables) {
const headers = {
'Content-Type': 'application/json',
'Magento-Environment-Id': config['commerce-environment-id'],
'Magento-Website-Code': config['commerce-website-code'],
'Magento-Store-View-Code': config['commerce-store-view-code'],
'Magento-Store-Code': config['commerce-store-code'],
'Magento-Customer-Group': config['commerce-customer-group'],
'x-api-key': config['commerce-x-api-key'],
};

const apiCall = new URL(config['commerce-endpoint']);
const apiCall = await commerceEndpointWithQueryParams();

const response = await fetch(apiCall, {
method: 'POST',
Expand Down
1 change: 0 additions & 1 deletion tools/picker/dist/index.515784d0.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/picker/dist/index.56bd2c76.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tools/picker/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Franklin Picker</title><link rel="stylesheet" href="index.96de328f.css"></head><body> <div id="app"></div> <script type="module" src="index.515784d0.js"></script> </body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>EDS Picker</title><link rel="stylesheet" href="index.96de328f.css"></head><body> <div id="app"></div> <script type="module" src="index.56bd2c76.js"></script> </body></html>
11 changes: 6 additions & 5 deletions tools/picker/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,17 @@ const blocks = {

async function performCatalogServiceQuery(query, config, variables) {
const headers = {
'Magento-Environment-Id': config['commerce-environment-id'],
'Magento-Store-View-Code': config['commerce-store-view-code'],
'Magento-Website-Code': config['commerce-website-code'],
'x-api-key': config['commerce-x-api-key'],
'Magento-Store-Code': config['commerce-store-code'],
'Magento-Customer-Group': config['commerce-customer-group'],
'Content-Type': 'application/json',
};

// Set Query Parameters so they can be appended to the endpoint
const apiCall = new URL(config['commerce-endpoint']);
apiCall.searchParams.append("Magento-Environment-Id", config['commerce-environment-id']);
apiCall.searchParams.append("Magento-Website-Code", config['commerce-website-code']);
apiCall.searchParams.append("Magento-Store-View-Code", config['commerce-store-view-code']);
apiCall.searchParams.append("Magento-Store-Code", config['commerce-store-code']);
apiCall.searchParams.append("Magento-Customer-Group", config['commerce-customer-group']);
apiCall.searchParams.append('query', query.replace(/(?:\r\n|\r|\n|\t|[\s]{4})/g, ' ')
.replace(/\s\s+/g, ' '));
apiCall.searchParams.append('variables', variables ? JSON.stringify(variables) : null);
Expand Down

0 comments on commit c5cb3ec

Please sign in to comment.