@adobe/helix-html-pipeline 1.8.4 → 1.8.6
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 +5 -5
- package/src/json-pipe.js +46 -34
- package/src/utils/id-slugger.js +2 -2
- package/test/StaticS3Loader.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.8.6](https://github.com/adobe/helix-html-pipeline/compare/v1.8.5...v1.8.6) (2022-11-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handle errors when loading config ([#181](https://github.com/adobe/helix-html-pipeline/issues/181)) ([a6e61a9](https://github.com/adobe/helix-html-pipeline/commit/a6e61a98cffe41bb22795c3a262c95cdf869f06f)), closes [#179](https://github.com/adobe/helix-html-pipeline/issues/179)
|
|
7
|
+
|
|
8
|
+
## [1.8.5](https://github.com/adobe/helix-html-pipeline/compare/v1.8.4...v1.8.5) (2022-10-31)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency github-slugger to v2 (1.x) ([#177](https://github.com/adobe/helix-html-pipeline/issues/177)) ([fc42ffb](https://github.com/adobe/helix-html-pipeline/commit/fc42ffbec5daea2a9547bd58cf5c7b6ba489d153))
|
|
14
|
+
|
|
1
15
|
## [1.8.4](https://github.com/adobe/helix-html-pipeline/compare/v1.8.3...v1.8.4) (2022-10-22)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.6",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@adobe/helix-markdown-support": "5.0.10",
|
|
33
33
|
"@adobe/helix-shared-utils": "2.1.0",
|
|
34
|
-
"github-slugger": "
|
|
34
|
+
"github-slugger": "2.0.0",
|
|
35
35
|
"hast-util-raw": "7.2.2",
|
|
36
36
|
"hast-util-select": "5.0.2",
|
|
37
37
|
"hast-util-to-html": "8.0.3",
|
|
@@ -69,17 +69,17 @@
|
|
|
69
69
|
"@semantic-release/git": "10.0.1",
|
|
70
70
|
"@semantic-release/npm": "9.0.1",
|
|
71
71
|
"c8": "7.12.0",
|
|
72
|
-
"eslint": "8.
|
|
72
|
+
"eslint": "8.26.0",
|
|
73
73
|
"eslint-import-resolver-exports": "1.0.0-beta.3",
|
|
74
74
|
"eslint-plugin-header": "3.1.1",
|
|
75
75
|
"eslint-plugin-import": "2.26.0",
|
|
76
|
-
"esmock": "2.0.
|
|
76
|
+
"esmock": "2.0.7",
|
|
77
77
|
"husky": "8.0.1",
|
|
78
78
|
"js-yaml": "4.1.0",
|
|
79
79
|
"jsdom": "20.0.1",
|
|
80
80
|
"junit-report-builder": "3.0.1",
|
|
81
81
|
"lint-staged": "13.0.3",
|
|
82
|
-
"mocha": "10.
|
|
82
|
+
"mocha": "10.1.0",
|
|
83
83
|
"mocha-multi-reporters": "1.5.1",
|
|
84
84
|
"remark-gfm": "3.0.1",
|
|
85
85
|
"semantic-release": "19.0.5"
|
package/src/json-pipe.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 { cleanupHeaderValue } from '@adobe/helix-shared-utils';
|
|
12
13
|
import fetchMetadata from './steps/fetch-metadata.js';
|
|
13
14
|
import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
|
|
14
15
|
import { PipelineResponse } from './PipelineResponse.js';
|
|
@@ -16,6 +17,7 @@ import jsonFilter from './utils/json-filter.js';
|
|
|
16
17
|
import { extractLastModified, updateLastModified } from './utils/last-modified.js';
|
|
17
18
|
import fetchConfig from './steps/fetch-config.js';
|
|
18
19
|
import { getPathInfo } from './utils/path.js';
|
|
20
|
+
import { PipelineStatusError } from './PipelineStatusError.js';
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Checks the fstab for folder mapping entries and then re-adjusts the path infos if needed.
|
|
@@ -73,47 +75,57 @@ export async function jsonPipe(state, req) {
|
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
try {
|
|
79
|
+
// fetch config and apply the folder mapping
|
|
80
|
+
await fetchConfig(state, req);
|
|
81
|
+
await folderMapping(state);
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
// fetch data from content bus
|
|
84
|
+
const { path } = state.info;
|
|
85
|
+
state.timer?.update('json-fetch');
|
|
86
|
+
let dataResponse = await s3Loader.getObject('helix-content-bus', `${contentBusId}/${partition}${path}`);
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
// if not found, fall back to code bus
|
|
89
|
+
if (dataResponse.status === 404) {
|
|
90
|
+
dataResponse = await s3Loader.getObject('helix-code-bus', `${owner}/${repo}/${ref}${path}`);
|
|
91
|
+
}
|
|
89
92
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
// if still not found, return status
|
|
94
|
+
if (dataResponse.status !== 200) {
|
|
95
|
+
if (dataResponse.status < 500) {
|
|
96
|
+
await fetchMetadata(state, req, dataResponse);
|
|
97
|
+
await setCustomResponseHeaders(state, req, dataResponse);
|
|
98
|
+
}
|
|
99
|
+
return dataResponse;
|
|
95
100
|
}
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
const data = dataResponse.body;
|
|
101
|
+
const data = dataResponse.body;
|
|
99
102
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
// filter data
|
|
104
|
+
const response = jsonFilter(state, data, {
|
|
105
|
+
limit: limit ? Number.parseInt(limit, 10) : undefined,
|
|
106
|
+
offset: offset ? Number.parseInt(offset, 10) : undefined,
|
|
107
|
+
sheet,
|
|
108
|
+
raw: limit === undefined && offset === undefined && sheet === undefined,
|
|
109
|
+
});
|
|
107
110
|
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
// set last-modified
|
|
112
|
+
updateLastModified(state, response, extractLastModified(dataResponse.headers));
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
// set surrogate key
|
|
115
|
+
response.headers.set('x-surrogate-key', `${contentBusId}${path}`.replace(/\//g, '_'));
|
|
113
116
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
// Load metadata from metadata.json
|
|
118
|
+
await fetchMetadata(state, req, response);
|
|
119
|
+
await setCustomResponseHeaders(state, req, response);
|
|
117
120
|
|
|
118
|
-
|
|
121
|
+
return response;
|
|
122
|
+
} catch (e) {
|
|
123
|
+
const res = new PipelineResponse('', {
|
|
124
|
+
status: e instanceof PipelineStatusError ? e.code : 500,
|
|
125
|
+
});
|
|
126
|
+
const level = res.status >= 500 ? 'error' : 'info';
|
|
127
|
+
log[level](`pipeline status: ${res.status} ${e.message}`, e);
|
|
128
|
+
res.headers.set('x-error', cleanupHeaderValue(e.message));
|
|
129
|
+
return res;
|
|
130
|
+
}
|
|
119
131
|
}
|
package/src/utils/id-slugger.js
CHANGED
|
@@ -9,7 +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
|
|
12
|
+
import { slug } from 'github-slugger';
|
|
13
13
|
|
|
14
14
|
export class IDSlugger {
|
|
15
15
|
constructor() {
|
|
@@ -22,7 +22,7 @@ export class IDSlugger {
|
|
|
22
22
|
* @return {string} A unique slug string
|
|
23
23
|
*/
|
|
24
24
|
slug(value) {
|
|
25
|
-
let id =
|
|
25
|
+
let id = slug(value)
|
|
26
26
|
// remove leading numbers
|
|
27
27
|
.replace(/^\d+-+/, '');
|
|
28
28
|
|
package/test/StaticS3Loader.js
CHANGED
|
@@ -34,6 +34,11 @@ export class StaticS3Loader {
|
|
|
34
34
|
body: '',
|
|
35
35
|
headers: new Map(),
|
|
36
36
|
};
|
|
37
|
+
if (response instanceof Error) {
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.log(`StaticS3Loader: failing ${bucketId}/${key} -> ${response.message}`);
|
|
40
|
+
throw response;
|
|
41
|
+
}
|
|
37
42
|
// eslint-disable-next-line no-console
|
|
38
43
|
console.log(`StaticS3Loader: loading ${bucketId}/${key} -> ${response.status}`);
|
|
39
44
|
return response;
|