@adobe/helix-html-pipeline 1.3.2 → 1.4.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 +21 -0
- package/package.json +10 -10
- package/src/PipelineState.d.ts +11 -0
- package/src/PipelineState.js +1 -0
- package/src/forms-pipe.js +1 -0
- package/src/html-pipe.js +1 -0
- package/src/json-pipe.js +4 -5
- package/src/steps/fetch-config.js +22 -2
- package/src/steps/fetch-metadata.js +4 -2
- package/src/steps/folder-mapping.js +1 -1
- package/src/steps/render.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [1.4.0](https://github.com/adobe/helix-html-pipeline/compare/v1.3.4...v1.4.0) (2022-04-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* adjust for upcoming helix-config changes ([#37](https://github.com/adobe/helix-html-pipeline/issues/37)) ([e6d4f90](https://github.com/adobe/helix-html-pipeline/commit/e6d4f90d4bf8c9a0642e921395e5ac48aa3e53c7)), closes [#36](https://github.com/adobe/helix-html-pipeline/issues/36)
|
|
7
|
+
|
|
8
|
+
## [1.3.4](https://github.com/adobe/helix-html-pipeline/compare/v1.3.3...v1.3.4) (2022-04-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency @adobe/helix-shared-utils to v2.0.7 ([e8a293c](https://github.com/adobe/helix-html-pipeline/commit/e8a293c54ac8617d5457692e780bc60c9358c0ee))
|
|
14
|
+
|
|
15
|
+
## [1.3.3](https://github.com/adobe/helix-html-pipeline/compare/v1.3.2...v1.3.3) (2022-04-06)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* correct last-modified handling for json ([#33](https://github.com/adobe/helix-html-pipeline/issues/33)) ([c9bb4fd](https://github.com/adobe/helix-html-pipeline/commit/c9bb4fd8e0974788cf0e963567db76685fcba231))
|
|
21
|
+
|
|
1
22
|
## [1.3.2](https://github.com/adobe/helix-html-pipeline/compare/v1.3.1...v1.3.2) (2022-03-19)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@adobe/helix-markdown-support": "3.1.2",
|
|
36
|
-
"@adobe/helix-shared-utils": "2.0.
|
|
36
|
+
"@adobe/helix-shared-utils": "2.0.7",
|
|
37
37
|
"github-slugger": "1.4.0",
|
|
38
38
|
"hast-util-raw": "7.2.1",
|
|
39
39
|
"hast-util-select": "5.0.1",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"hastscript": "7.0.2",
|
|
43
43
|
"mdast-util-gfm-footnote": "1.0.1",
|
|
44
44
|
"mdast-util-gfm-strikethrough": "1.0.1",
|
|
45
|
-
"mdast-util-gfm-table": "1.0.
|
|
45
|
+
"mdast-util-gfm-table": "1.0.4",
|
|
46
46
|
"mdast-util-gfm-task-list-item": "1.0.1",
|
|
47
47
|
"mdast-util-to-hast": "12.1.1",
|
|
48
48
|
"mdast-util-to-string": "3.1.0",
|
|
49
|
-
"micromark-extension-gfm-footnote": "1.0.
|
|
49
|
+
"micromark-extension-gfm-footnote": "1.0.4",
|
|
50
50
|
"micromark-extension-gfm-strikethrough": "1.0.4",
|
|
51
51
|
"micromark-extension-gfm-table": "1.0.5",
|
|
52
52
|
"micromark-extension-gfm-tagfilter": "1.0.1",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"micromark-util-combine-extensions": "1.0.0",
|
|
55
55
|
"mime": "3.0.0",
|
|
56
56
|
"rehype-format": "4.0.1",
|
|
57
|
-
"rehype-minify-whitespace": "5.0.
|
|
57
|
+
"rehype-minify-whitespace": "5.0.1",
|
|
58
58
|
"rehype-parse": "8.0.4",
|
|
59
59
|
"remark-parse": "10.0.1",
|
|
60
60
|
"strip-markdown": "5.0.0",
|
|
61
61
|
"unified": "10.1.2",
|
|
62
|
-
"unist-util-map": "3.0.
|
|
62
|
+
"unist-util-map": "3.0.1",
|
|
63
63
|
"unist-util-remove": "3.1.0",
|
|
64
64
|
"unist-util-remove-position": "4.0.1",
|
|
65
65
|
"unist-util-select": "4.0.1",
|
|
@@ -76,16 +76,16 @@
|
|
|
76
76
|
"codecov": "3.8.3",
|
|
77
77
|
"commitizen": "4.2.4",
|
|
78
78
|
"cz-conventional-changelog": "3.3.0",
|
|
79
|
-
"eslint": "8.
|
|
79
|
+
"eslint": "8.13.0",
|
|
80
80
|
"eslint-plugin-header": "3.1.1",
|
|
81
|
-
"eslint-plugin-import": "2.
|
|
82
|
-
"esmock": "1.7.
|
|
81
|
+
"eslint-plugin-import": "2.26.0",
|
|
82
|
+
"esmock": "1.7.5",
|
|
83
83
|
"husky": "7.0.4",
|
|
84
84
|
"js-yaml": "4.1.0",
|
|
85
85
|
"jsdoc-to-markdown": "7.1.1",
|
|
86
86
|
"jsdom": "19.0.0",
|
|
87
87
|
"junit-report-builder": "3.0.0",
|
|
88
|
-
"lint-staged": "12.3.
|
|
88
|
+
"lint-staged": "12.3.7",
|
|
89
89
|
"mocha": "9.2.2",
|
|
90
90
|
"mocha-multi-reporters": "1.5.1",
|
|
91
91
|
"remark-gfm": "3.0.1",
|
package/src/PipelineState.d.ts
CHANGED
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
import {PathInfo, S3Loader, FormsMessageDispatcher, PipelineTimer} from "./index";
|
|
13
13
|
import {PipelineContent} from "./PipelineContent";
|
|
14
14
|
|
|
15
|
+
declare enum PipelineType {
|
|
16
|
+
html = 'html',
|
|
17
|
+
json = 'json',
|
|
18
|
+
form = 'form',
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
declare interface PipelineOptions {
|
|
16
22
|
log: Console;
|
|
17
23
|
s3Loader: S3Loader;
|
|
@@ -70,5 +76,10 @@ declare class PipelineState {
|
|
|
70
76
|
* optional timer that is used to measure the timing
|
|
71
77
|
*/
|
|
72
78
|
timer?: PipelineTimer;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* pipeline type. 'html', 'json', 'forms'
|
|
82
|
+
*/
|
|
83
|
+
type: PipelineType;
|
|
73
84
|
}
|
|
74
85
|
|
package/src/PipelineState.js
CHANGED
package/src/forms-pipe.js
CHANGED
package/src/html-pipe.js
CHANGED
package/src/json-pipe.js
CHANGED
|
@@ -13,6 +13,7 @@ import fetchMetadata from './steps/fetch-metadata.js';
|
|
|
13
13
|
import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
|
|
14
14
|
import { PipelineResponse } from './PipelineResponse.js';
|
|
15
15
|
import jsonFilter from './utils/json-filter.js';
|
|
16
|
+
import { updateLastModified } from './utils/last-modified.js';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Runs the default pipeline and returns the response.
|
|
@@ -22,6 +23,7 @@ import jsonFilter from './utils/json-filter.js';
|
|
|
22
23
|
*/
|
|
23
24
|
export async function jsonPipe(state, req) {
|
|
24
25
|
const { log } = state;
|
|
26
|
+
state.type = 'json';
|
|
25
27
|
const {
|
|
26
28
|
owner, repo, ref, contentBusId, partition, s3Loader,
|
|
27
29
|
} = state;
|
|
@@ -70,11 +72,8 @@ export async function jsonPipe(state, req) {
|
|
|
70
72
|
raw: limit === undefined && offset === undefined && sheet === undefined,
|
|
71
73
|
});
|
|
72
74
|
|
|
73
|
-
// set last-modified
|
|
74
|
-
|
|
75
|
-
if (lastModified) {
|
|
76
|
-
response.headers.set('last-modified', lastModified);
|
|
77
|
-
}
|
|
75
|
+
// set last-modified
|
|
76
|
+
updateLastModified(state, response, dataResponse.headers.get('last-modified'));
|
|
78
77
|
|
|
79
78
|
// set surrogate key
|
|
80
79
|
response.headers.set('x-surrogate-key', `${contentBusId}${path}`.replace(/\//g, '_'));
|
|
@@ -30,13 +30,33 @@ export default async function fetchConfig(state, req, res) {
|
|
|
30
30
|
if (ret.status !== 200) {
|
|
31
31
|
throw new PipelineStatusError(ret.status === 404 ? 404 : 502, `unable to load /helix-config.json: ${ret.status}`);
|
|
32
32
|
}
|
|
33
|
+
let config;
|
|
33
34
|
try {
|
|
34
|
-
|
|
35
|
+
config = JSON.parse(ret.body);
|
|
35
36
|
} catch (e) {
|
|
36
37
|
log.info('failed to parse helix-config.json', e);
|
|
37
38
|
throw new PipelineStatusError(400, `Failed parsing of /helix-config.json: ${e.message}`);
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
// upgrade to version 2 if needed
|
|
42
|
+
if (config.version !== 2) {
|
|
43
|
+
Object.keys(config).forEach((name) => {
|
|
44
|
+
config[name] = {
|
|
45
|
+
data: config[name],
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
// also update last-modified
|
|
41
|
-
|
|
51
|
+
const configLastModified = extractLastModified(ret.headers);
|
|
52
|
+
|
|
53
|
+
// update last modified of fstab
|
|
54
|
+
updateLastModified(state, res, config.fstab?.lastModified || configLastModified);
|
|
55
|
+
|
|
56
|
+
// for html requests, also consider the HEAD config
|
|
57
|
+
if (state.type === 'html' && state.info.selector !== 'plain' && config.head?.lastModified) {
|
|
58
|
+
updateLastModified(state, res, config.head.lastModified);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
state.helixConfig = config;
|
|
42
62
|
}
|
|
@@ -39,8 +39,10 @@ export default async function fetchMetadata(state, req, res) {
|
|
|
39
39
|
}
|
|
40
40
|
state.metadata = data;
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (state.type === 'html') {
|
|
43
|
+
// also update last-modified (only for html pipeline)
|
|
44
|
+
updateLastModified(state, res, extractLastModified(ret.headers));
|
|
45
|
+
}
|
|
44
46
|
return;
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -40,7 +40,7 @@ export function mapPath(folders, path) {
|
|
|
40
40
|
* @param {PipelineState} state
|
|
41
41
|
*/
|
|
42
42
|
export default function folderMapping(state) {
|
|
43
|
-
const folders = state.helixConfig?.fstab?.folders;
|
|
43
|
+
const folders = state.helixConfig?.fstab?.data.folders;
|
|
44
44
|
if (!folders) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
package/src/steps/render.js
CHANGED
|
@@ -81,7 +81,7 @@ export default async function render(state, req, res) {
|
|
|
81
81
|
appendElement($head, createElement('link', 'rel', 'alternate', 'type', 'application/xml+atom', 'href', meta.feed, 'title', `${meta.title} feed`));
|
|
82
82
|
|
|
83
83
|
// inject head.html
|
|
84
|
-
const headHtml = state.helixConfig?.head?.html;
|
|
84
|
+
const headHtml = state.helixConfig?.head?.data.html;
|
|
85
85
|
if (headHtml) {
|
|
86
86
|
const $headHtml = await unified()
|
|
87
87
|
.use(rehypeParse, { fragment: true })
|