@adobe/helix-html-pipeline 3.10.1 → 3.11.0
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 +14 -0
- package/package.json +3 -3
- package/src/html-pipe.js +2 -0
- package/src/steps/extract-metadata.js +1 -0
- package/src/steps/fetch-config-all.js +2 -2
- package/src/steps/fetch-config.js +1 -1
- package/src/steps/fetch-mapped-metadata.js +55 -0
- package/src/steps/folder-mapping.js +1 -0
- package/src/steps/set-x-surrogate-key-header.js +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [3.11.0](https://github.com/adobe/helix-html-pipeline/compare/v3.10.2...v3.11.0) (2023-04-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* load metadata from mapped path ([#298](https://github.com/adobe/helix-html-pipeline/issues/298)) ([a1fc7b0](https://github.com/adobe/helix-html-pipeline/commit/a1fc7b0b9b2d795d3aa3f6c8e15713ad1862ee77))
|
|
7
|
+
|
|
8
|
+
## [3.10.2](https://github.com/adobe/helix-html-pipeline/compare/v3.10.1...v3.10.2) (2023-04-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* use correct header for contentbusid ([#294](https://github.com/adobe/helix-html-pipeline/issues/294)) ([1c070f9](https://github.com/adobe/helix-html-pipeline/commit/1c070f905667d414f76226958461b3dcd18a2c1c))
|
|
14
|
+
|
|
1
15
|
## [3.10.1](https://github.com/adobe/helix-html-pipeline/compare/v3.10.0...v3.10.1) (2023-04-11)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"hast-util-to-html": "8.0.4",
|
|
51
51
|
"hast-util-to-string": "2.0.0",
|
|
52
52
|
"hastscript": "7.2.0",
|
|
53
|
-
"jose": "4.
|
|
53
|
+
"jose": "4.14.1",
|
|
54
54
|
"mdast-util-gfm-footnote": "1.0.2",
|
|
55
55
|
"mdast-util-gfm-strikethrough": "1.0.3",
|
|
56
56
|
"mdast-util-gfm-table": "1.0.7",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@semantic-release/git": "10.0.1",
|
|
84
84
|
"@semantic-release/npm": "10.0.3",
|
|
85
85
|
"c8": "7.13.0",
|
|
86
|
-
"eslint": "8.
|
|
86
|
+
"eslint": "8.39.0",
|
|
87
87
|
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
88
88
|
"eslint-plugin-header": "3.1.1",
|
|
89
89
|
"eslint-plugin-import": "2.27.5",
|
package/src/html-pipe.js
CHANGED
|
@@ -37,6 +37,7 @@ import { PipelineStatusError } from './PipelineStatusError.js';
|
|
|
37
37
|
import { PipelineResponse } from './PipelineResponse.js';
|
|
38
38
|
import { validatePathInfo } from './utils/path.js';
|
|
39
39
|
import { initAuthRoute } from './utils/auth.js';
|
|
40
|
+
import fetchMappedMetadata from './steps/fetch-mapped-metadata.js';
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* Runs the default pipeline and returns the response.
|
|
@@ -88,6 +89,7 @@ export async function htmlPipe(state, req) {
|
|
|
88
89
|
await Promise.all([
|
|
89
90
|
fetchConfigAll(state, req, res),
|
|
90
91
|
fetchContent(state, req, res),
|
|
92
|
+
fetchMappedMetadata(state),
|
|
91
93
|
]);
|
|
92
94
|
|
|
93
95
|
await requireProject(state, req, res);
|
|
@@ -158,6 +158,7 @@ export default function extractMetaData(state, req) {
|
|
|
158
158
|
// with local metadata from document
|
|
159
159
|
const metaConfig = Object.assign(
|
|
160
160
|
state.metadata.getModifiers(state.info.unmappedPath || state.info.path),
|
|
161
|
+
state.mappedMetadata.getModifiers(state.info.path),
|
|
161
162
|
getLocalMetadata(hast),
|
|
162
163
|
);
|
|
163
164
|
|
|
@@ -35,12 +35,12 @@ async function fetchMetadata(state, req, res) {
|
|
|
35
35
|
try {
|
|
36
36
|
json = JSON.parse(ret.body);
|
|
37
37
|
} catch (e) {
|
|
38
|
-
throw new PipelineStatusError(
|
|
38
|
+
throw new PipelineStatusError(500, `failed parsing of /metadata.json: ${e.message}`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const { data } = json.default ?? json;
|
|
42
42
|
if (!Array.isArray(data)) {
|
|
43
|
-
throw new PipelineStatusError(
|
|
43
|
+
throw new PipelineStatusError(500, 'failed loading of /metadata.json: data must be an array');
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
state.metadata = Modifiers.fromModifierSheet(
|
|
@@ -48,7 +48,7 @@ export default async function fetchConfig(state, req, res) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// set contentbusid from header if missing in config
|
|
51
|
-
const cbid = ret.headers.get('x-contentbus-id');
|
|
51
|
+
const cbid = ret.headers.get('x-amz-meta-x-contentbus-id');
|
|
52
52
|
if (!config.content && cbid) {
|
|
53
53
|
config.content = {
|
|
54
54
|
data: {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 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
|
+
import { PipelineStatusError } from '../PipelineStatusError.js';
|
|
14
|
+
import { Modifiers } from '../utils/modifiers.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Loads metadata for a mapped path and puts it into `state.mappedMetadata`. If path is not
|
|
18
|
+
* mapped or there is no `metadata.json` at that path, puts an `EMPTY` Modifiers object into
|
|
19
|
+
* `state.mappedMetadata`.
|
|
20
|
+
*
|
|
21
|
+
* @type PipelineStep
|
|
22
|
+
* @param {PipelineState} state
|
|
23
|
+
* @returns {Promise<void>}
|
|
24
|
+
*/
|
|
25
|
+
export default async function fetchMappedMetadata(state) {
|
|
26
|
+
state.mappedMetadata = Modifiers.EMPTY;
|
|
27
|
+
if (!state.mapped) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const { contentBusId, partition } = state;
|
|
31
|
+
const metadataPath = `${state.info.path}/metadata.json`;
|
|
32
|
+
const key = `${contentBusId}/${partition}${metadataPath}`;
|
|
33
|
+
const ret = await state.s3Loader.getObject('helix-content-bus', key);
|
|
34
|
+
if (ret.status === 200) {
|
|
35
|
+
let json;
|
|
36
|
+
try {
|
|
37
|
+
json = JSON.parse(ret.body);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
throw new PipelineStatusError(500, `failed parsing of ${metadataPath}: ${e.message}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { data } = json.default ?? json;
|
|
43
|
+
if (!Array.isArray(data)) {
|
|
44
|
+
throw new PipelineStatusError(500, `failed loading of ${metadataPath}: data must be an array`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
state.mappedMetadata = Modifiers.fromModifierSheet(
|
|
48
|
+
data,
|
|
49
|
+
);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (ret.status !== 404) {
|
|
53
|
+
throw new PipelineStatusError(502, `failed to load ${metadataPath}: ${ret.status}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -55,6 +55,7 @@ export default function folderMapping(state) {
|
|
|
55
55
|
state.info.resourcePath = mapped;
|
|
56
56
|
state.log.info(`mapped ${path} to ${state.info.resourcePath} (code-bus)`);
|
|
57
57
|
} else {
|
|
58
|
+
state.mapped = true;
|
|
58
59
|
state.log.info(`mapped ${path} to ${state.info.path} (content-bus)`);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -37,10 +37,15 @@ export default async function setXSurrogateKeyHeader(state, req, res) {
|
|
|
37
37
|
} else if (path.endsWith('.plain.html')) {
|
|
38
38
|
path = path.substring(0, path.length - '.plain.html'.length);
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
const hash = await computeSurrogateKey(`${contentBusId}${path}`);
|
|
41
|
+
keys.push(hash);
|
|
41
42
|
|
|
42
43
|
keys.push(`${contentBusId}_metadata`);
|
|
43
44
|
keys.push(`${ref}--${repo}--${owner}_head`);
|
|
44
45
|
|
|
46
|
+
if (state.mapped) {
|
|
47
|
+
keys.push(`${hash}_metadata`);
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
res.headers.set('x-surrogate-key', keys.join(' '));
|
|
46
51
|
}
|