@adobe/helix-html-pipeline 3.6.2 → 3.7.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 -1
- package/src/json-pipe.js +47 -35
- package/src/steps/authenticate.js +2 -1
- package/src/steps/parse-markdown.js +1 -1
- package/src/utils/mdast-to-hast.js +2 -2
- package/test/StaticS3Loader.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [3.7.0](https://github.com/adobe/helix-html-pipeline/compare/v3.6.3...v3.7.0) (2022-11-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* use adobe gridtables ([#183](https://github.com/adobe/helix-html-pipeline/issues/183)) ([29369c0](https://github.com/adobe/helix-html-pipeline/commit/29369c0e5cf373e157100f25c98d690083161213)), closes [#182](https://github.com/adobe/helix-html-pipeline/issues/182)
|
|
7
|
+
|
|
8
|
+
## [3.6.3](https://github.com/adobe/helix-html-pipeline/compare/v3.6.2...v3.6.3) (2022-11-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* handle errors when loading config ([#180](https://github.com/adobe/helix-html-pipeline/issues/180)) ([f4f4b5f](https://github.com/adobe/helix-html-pipeline/commit/f4f4b5ff4f687331c2ec321e53662519cc428eb6)), closes [#179](https://github.com/adobe/helix-html-pipeline/issues/179)
|
|
14
|
+
|
|
1
15
|
## [3.6.2](https://github.com/adobe/helix-html-pipeline/compare/v3.6.1...v3.6.2) (2022-10-31)
|
|
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.7.0",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@adobe/helix-markdown-support": "5.0.10",
|
|
43
43
|
"@adobe/helix-shared-utils": "2.1.0",
|
|
44
|
+
"@adobe/mdast-util-gridtables": "1.0.1",
|
|
45
|
+
"@adobe/remark-gridtables": "1.0.0",
|
|
44
46
|
"cookie": "0.5.0",
|
|
45
47
|
"github-slugger": "2.0.0",
|
|
46
48
|
"hast-util-raw": "7.2.2",
|
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 fetchConfigAll from './steps/fetch-config-all.js';
|
|
13
14
|
import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
|
|
14
15
|
import { PipelineResponse } from './PipelineResponse.js';
|
|
@@ -17,6 +18,7 @@ import { extractLastModified, updateLastModified } from './utils/last-modified.j
|
|
|
17
18
|
import { authenticate } from './steps/authenticate.js';
|
|
18
19
|
import fetchConfig from './steps/fetch-config.js';
|
|
19
20
|
import { getPathInfo } from './utils/path.js';
|
|
21
|
+
import { PipelineStatusError } from './PipelineStatusError.js';
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Checks the fstab for folder mapping entries and then re-adjusts the path infos if needed.
|
|
@@ -74,48 +76,58 @@ export async function jsonPipe(state, req) {
|
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
try {
|
|
80
|
+
// fetch config and apply the folder mapping
|
|
81
|
+
await fetchConfig(state, req);
|
|
82
|
+
await folderMapping(state);
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
// fetch data from content bus
|
|
85
|
+
const { path } = state.info;
|
|
86
|
+
state.timer?.update('json-fetch');
|
|
87
|
+
let dataResponse = await s3Loader.getObject('helix-content-bus', `${contentBusId}/${partition}${path}`);
|
|
85
88
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
// if not found, fall back to code bus
|
|
90
|
+
if (dataResponse.status === 404) {
|
|
91
|
+
dataResponse = await s3Loader.getObject('helix-code-bus', `${owner}/${repo}/${ref}${path}`);
|
|
92
|
+
}
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// if still not found, return status
|
|
95
|
+
if (dataResponse.status !== 200) {
|
|
96
|
+
if (dataResponse.status < 500) {
|
|
97
|
+
await fetchConfigAll(state, req, dataResponse);
|
|
98
|
+
await setCustomResponseHeaders(state, req, dataResponse);
|
|
99
|
+
}
|
|
100
|
+
return dataResponse;
|
|
96
101
|
}
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
const data = dataResponse.body;
|
|
102
|
+
const data = dataResponse.body;
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
// filter data
|
|
105
|
+
const response = jsonFilter(state, data, {
|
|
106
|
+
limit: limit ? Number.parseInt(limit, 10) : undefined,
|
|
107
|
+
offset: offset ? Number.parseInt(offset, 10) : undefined,
|
|
108
|
+
sheet,
|
|
109
|
+
raw: limit === undefined && offset === undefined && sheet === undefined,
|
|
110
|
+
});
|
|
108
111
|
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
// set last-modified
|
|
113
|
+
updateLastModified(state, response, extractLastModified(dataResponse.headers));
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
// set surrogate key
|
|
116
|
+
response.headers.set('x-surrogate-key', `${contentBusId}${path}`.replace(/\//g, '_'));
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
// Load config-all and set response headers
|
|
119
|
+
await fetchConfigAll(state, req, response);
|
|
120
|
+
await authenticate(state, req, response);
|
|
121
|
+
await setCustomResponseHeaders(state, req, response);
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
return response;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
const res = new PipelineResponse('', {
|
|
126
|
+
status: e instanceof PipelineStatusError ? e.code : 500,
|
|
127
|
+
});
|
|
128
|
+
const level = res.status >= 500 ? 'error' : 'info';
|
|
129
|
+
log[level](`pipeline status: ${res.status} ${e.message}`, e);
|
|
130
|
+
res.headers.set('x-error', cleanupHeaderValue(e.message));
|
|
131
|
+
return res;
|
|
132
|
+
}
|
|
121
133
|
}
|
|
@@ -72,7 +72,8 @@ export async function authenticate(state, req, res) {
|
|
|
72
72
|
res.error = 'forbidden.';
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// set some response headers
|
|
75
|
+
// set some response headers for deferred edge authentication
|
|
76
|
+
// AdobePatentID="P11443-US"
|
|
76
77
|
res.headers.set('x-hlx-auth-allow', allows.join(','));
|
|
77
78
|
if (authInfo.profile) {
|
|
78
79
|
res.headers.set('x-hlx-auth-iss', authInfo.profile.iss);
|
|
@@ -14,7 +14,7 @@ import remarkParse from 'remark-parse';
|
|
|
14
14
|
import { removePosition } from 'unist-util-remove-position';
|
|
15
15
|
import { dereference } from '@adobe/helix-markdown-support';
|
|
16
16
|
import { remarkMatter } from '@adobe/helix-markdown-support/matter';
|
|
17
|
-
import
|
|
17
|
+
import remarkGridTable from '@adobe/remark-gridtables';
|
|
18
18
|
import remarkGfm from '../utils/remark-gfm-nolink.js';
|
|
19
19
|
|
|
20
20
|
export class FrontmatterParsingError extends Error {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { toHast as mdast2hast, defaultHandlers } from 'mdast-util-to-hast';
|
|
13
13
|
import { raw } from 'hast-util-raw';
|
|
14
|
-
import {
|
|
14
|
+
import { mdast2hastGridTablesHandler, TYPE_TABLE } from '@adobe/mdast-util-gridtables';
|
|
15
15
|
|
|
16
16
|
import section from './section-handler.js';
|
|
17
17
|
import heading from './heading-handler.js';
|
|
@@ -28,7 +28,7 @@ export default function getHast(mdast, slugger) {
|
|
|
28
28
|
...defaultHandlers,
|
|
29
29
|
section: section(),
|
|
30
30
|
heading: heading(slugger),
|
|
31
|
-
[TYPE_TABLE]:
|
|
31
|
+
[TYPE_TABLE]: mdast2hastGridTablesHandler(),
|
|
32
32
|
},
|
|
33
33
|
allowDangerousHtml: true,
|
|
34
34
|
});
|
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;
|