@dylandepass/helix-product-pipeline 2.0.0 → 2.0.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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [2.0.2](https://github.com/adobe-rnd/helix-product-pipeline/compare/v2.0.1...v2.0.2) (2026-01-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* allow generated jsonld to be overridden ([47f0e92](https://github.com/adobe-rnd/helix-product-pipeline/commit/47f0e9230c6c2d47588ff4815addbecc8d3b4379))
|
|
7
|
+
|
|
8
|
+
## [2.0.1](https://github.com/adobe-rnd/helix-product-pipeline/compare/v2.0.0...v2.0.1) (2026-01-29)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* assume authorization header value includes `token` ([20886f8](https://github.com/adobe-rnd/helix-product-pipeline/commit/20886f8224e4ca7a946eb2d927d6f625ec3fe3dc))
|
|
14
|
+
* pass authorization headers to edge ([8640b6d](https://github.com/adobe-rnd/helix-product-pipeline/commit/8640b6d5ce22e31dd3701fd8197eef70efc780ae))
|
|
15
|
+
* respect site authentication ([28a05ce](https://github.com/adobe-rnd/helix-product-pipeline/commit/28a05ce23e084035b8b4459f8ed37790798520c7))
|
|
16
|
+
* return 401 body ([5bad55b](https://github.com/adobe-rnd/helix-product-pipeline/commit/5bad55b8a09bc6d538ae1e6787e6f413a9f5613a))
|
|
17
|
+
|
|
1
18
|
# [2.0.0](https://github.com/adobe-rnd/helix-product-pipeline/compare/v1.9.3...v2.0.0) (2026-01-26)
|
|
2
19
|
|
|
3
20
|
|
package/package.json
CHANGED
package/src/product-html-pipe.js
CHANGED
|
@@ -25,6 +25,7 @@ import renderHead from './steps/render-head.js';
|
|
|
25
25
|
import tohtml from './steps/stringify-response.js';
|
|
26
26
|
import fetch404 from './steps/fetch-404.js';
|
|
27
27
|
import { setProductCacheHeaders } from './steps/set-cache-headers.js';
|
|
28
|
+
import { getUnauthorizedBody } from './utils/http-response.js';
|
|
28
29
|
|
|
29
30
|
export async function productHTMLPipe(state, req) {
|
|
30
31
|
const { log } = state;
|
|
@@ -73,7 +74,7 @@ export async function productHTMLPipe(state, req) {
|
|
|
73
74
|
await html(state);
|
|
74
75
|
await renderHead(state);
|
|
75
76
|
|
|
76
|
-
await fetchEdgeContent(state, res);
|
|
77
|
+
await fetchEdgeContent(state, req, res);
|
|
77
78
|
await renderBody(state, req, res);
|
|
78
79
|
await renderJsonld(state, res);
|
|
79
80
|
await addHeadingIds(state);
|
|
@@ -91,6 +92,10 @@ export async function productHTMLPipe(state, req) {
|
|
|
91
92
|
res.status = 500;
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
if (res.status === 401) {
|
|
96
|
+
res.body = getUnauthorizedBody();
|
|
97
|
+
}
|
|
98
|
+
|
|
94
99
|
/* c8 ignore next */
|
|
95
100
|
const level = res.status >= 500 ? 'error' : 'info';
|
|
96
101
|
log[level](`pipeline status: ${res.status} ${res.error}`, e);
|
package/src/steps/fetch-404.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
+
import { PipelineStatusError } from '@adobe/helix-html-pipeline';
|
|
12
13
|
import { extractLastModified, recordLastModified } from '../utils/last-modified.js';
|
|
13
14
|
import { setProduct404CacheHeaders } from './set-cache-headers.js';
|
|
14
15
|
|
|
@@ -23,7 +24,17 @@ export default async function fetch404(state, req, res) {
|
|
|
23
24
|
const {
|
|
24
25
|
org, site, ref,
|
|
25
26
|
} = state;
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
/** @type {Record<string, string>} */
|
|
29
|
+
const headers = {};
|
|
30
|
+
const authorization = req.headers.get('authorization');
|
|
31
|
+
if (authorization) {
|
|
32
|
+
headers.authorization = authorization;
|
|
33
|
+
}
|
|
34
|
+
const ret = await fetch(`https://${ref}--${site}--${org}.aem.live/404.html`, { headers });
|
|
35
|
+
if (ret.status === 401) {
|
|
36
|
+
throw new PipelineStatusError(401, 'unauthorized');
|
|
37
|
+
}
|
|
27
38
|
if (ret.status === 200) {
|
|
28
39
|
// override last-modified if source-last-modified is set
|
|
29
40
|
const lastModified = extractLastModified(ret.headers);
|
|
@@ -10,15 +10,17 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { PipelineStatusError } from '@adobe/helix-html-pipeline';
|
|
13
14
|
import { extractLastModified, recordLastModified } from '../utils/last-modified.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Loads the content from either the content-bus and stores it in `state.content.edge`
|
|
17
18
|
* @param {PipelineState} state
|
|
19
|
+
* @param {PipelineRequest} req
|
|
18
20
|
* @param {PipelineResponse} res
|
|
19
21
|
* @returns {Promise<void>}
|
|
20
22
|
*/
|
|
21
|
-
export default async function fetchEdgeContent(state, res) {
|
|
23
|
+
export default async function fetchEdgeContent(state, req, res) {
|
|
22
24
|
const {
|
|
23
25
|
info, org, site, ref, log,
|
|
24
26
|
} = state;
|
|
@@ -26,7 +28,16 @@ export default async function fetchEdgeContent(state, res) {
|
|
|
26
28
|
|
|
27
29
|
const contentUrl = `https://${ref}--${site}--${org}.aem.live${originalPath}.plain.html`;
|
|
28
30
|
try {
|
|
29
|
-
|
|
31
|
+
/** @type {Record<string, string>} */
|
|
32
|
+
const headers = {};
|
|
33
|
+
const authorization = req.headers.get('authorization');
|
|
34
|
+
if (authorization) {
|
|
35
|
+
headers.authorization = authorization;
|
|
36
|
+
}
|
|
37
|
+
const contentRes = await fetch(contentUrl, { headers });
|
|
38
|
+
if (contentRes.status === 401) {
|
|
39
|
+
throw new PipelineStatusError(401, 'unauthorized');
|
|
40
|
+
}
|
|
30
41
|
if (contentRes.status === 200) {
|
|
31
42
|
state.content.edge = await contentRes.text();
|
|
32
43
|
|
|
@@ -39,6 +50,9 @@ export default async function fetchEdgeContent(state, res) {
|
|
|
39
50
|
log.debug(`Edge content returned ${contentRes.status} for ${contentUrl}`);
|
|
40
51
|
}
|
|
41
52
|
} catch (e) {
|
|
53
|
+
if (e instanceof PipelineStatusError) {
|
|
54
|
+
throw e;
|
|
55
|
+
}
|
|
42
56
|
log.debug(`Failed to fetch edge content from ${contentUrl}: ${e.message}`);
|
|
43
57
|
}
|
|
44
58
|
}
|
|
@@ -65,7 +65,14 @@ function renderOffer(state, variant, simple = false) {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function convertToJsonLD(state, product) {
|
|
68
|
+
export function convertToJsonLD(state, product) {
|
|
69
|
+
// If the product has a jsonld property, use it directly instead of generating
|
|
70
|
+
if (product.jsonld) {
|
|
71
|
+
return typeof product.jsonld === 'string'
|
|
72
|
+
? product.jsonld
|
|
73
|
+
: JSON.stringify(product.jsonld, null, 2);
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
const {
|
|
70
77
|
sku,
|
|
71
78
|
metaTitle,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Returns the HTML body for a 401 Unauthorized response.
|
|
15
|
+
* Matches the format returned by Edge Delivery Services.
|
|
16
|
+
* @returns {string} HTML response body
|
|
17
|
+
*/
|
|
18
|
+
export function getUnauthorizedBody() {
|
|
19
|
+
return `<html>
|
|
20
|
+
<head>
|
|
21
|
+
<meta name="color-scheme" content="light dark" />
|
|
22
|
+
</head>
|
|
23
|
+
<body>
|
|
24
|
+
<pre style="word-wrap: break-word; white-space: pre-wrap;">401 Unauthorized</pre>
|
|
25
|
+
</body>
|
|
26
|
+
</html>`;
|
|
27
|
+
}
|