@adobe/helix-html-pipeline 3.11.17 → 3.11.18
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 +7 -0
- package/package.json +4 -4
- package/src/PipelineState.d.ts +0 -1
- package/src/PipelineState.js +0 -2
- package/src/json-pipe.js +2 -3
- package/src/options-pipe.js +37 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.11.18](https://github.com/adobe/helix-html-pipeline/compare/v3.11.17...v3.11.18) (2023-07-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* ensure contentBusId is loaded properly ([#342](https://github.com/adobe/helix-html-pipeline/issues/342)) ([80e4552](https://github.com/adobe/helix-html-pipeline/commit/80e4552223124ba73cef41829f40bd64ade392c9))
|
|
7
|
+
|
|
1
8
|
## [3.11.17](https://github.com/adobe/helix-html-pipeline/compare/v3.11.16...v3.11.17) (2023-06-28)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.18",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@semantic-release/git": "10.0.1",
|
|
84
84
|
"@semantic-release/npm": "10.0.4",
|
|
85
85
|
"c8": "8.0.0",
|
|
86
|
-
"eslint": "8.
|
|
86
|
+
"eslint": "8.44.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",
|
|
@@ -92,11 +92,11 @@
|
|
|
92
92
|
"js-yaml": "4.1.0",
|
|
93
93
|
"jsdom": "22.1.0",
|
|
94
94
|
"junit-report-builder": "3.0.1",
|
|
95
|
-
"lint-staged": "13.2.
|
|
95
|
+
"lint-staged": "13.2.3",
|
|
96
96
|
"mocha": "10.2.0",
|
|
97
97
|
"mocha-multi-reporters": "1.5.1",
|
|
98
98
|
"remark-gfm": "3.0.1",
|
|
99
|
-
"semantic-release": "21.0.
|
|
99
|
+
"semantic-release": "21.0.6"
|
|
100
100
|
},
|
|
101
101
|
"lint-staged": {
|
|
102
102
|
"*.js": "eslint",
|
package/src/PipelineState.d.ts
CHANGED
package/src/PipelineState.js
CHANGED
package/src/json-pipe.js
CHANGED
|
@@ -98,7 +98,6 @@ async function computeSurrogateKeys(path, contentBusId) {
|
|
|
98
98
|
export async function jsonPipe(state, req) {
|
|
99
99
|
const { log } = state;
|
|
100
100
|
state.type = 'json';
|
|
101
|
-
const { contentBusId } = state;
|
|
102
101
|
const { extension } = state.info;
|
|
103
102
|
const { searchParams } = req.url;
|
|
104
103
|
const params = Object.fromEntries(searchParams.entries());
|
|
@@ -174,7 +173,7 @@ export async function jsonPipe(state, req) {
|
|
|
174
173
|
});
|
|
175
174
|
|
|
176
175
|
// set surrogate keys
|
|
177
|
-
const keys = await computeSurrogateKeys(state.info.path, contentBusId);
|
|
176
|
+
const keys = await computeSurrogateKeys(state.info.path, state.contentBusId);
|
|
178
177
|
res.headers.set('x-surrogate-key', keys.join(' '));
|
|
179
178
|
|
|
180
179
|
await setCustomResponseHeaders(state, req, res);
|
|
@@ -191,7 +190,7 @@ export async function jsonPipe(state, req) {
|
|
|
191
190
|
await setCustomResponseHeaders(state, req, res);
|
|
192
191
|
}
|
|
193
192
|
if (res.status === 404) {
|
|
194
|
-
const keys = await computeSurrogateKeys(state.info.path, contentBusId);
|
|
193
|
+
const keys = await computeSurrogateKeys(state.info.path, state.contentBusId);
|
|
195
194
|
res.headers.set('x-surrogate-key', keys.join(' '));
|
|
196
195
|
}
|
|
197
196
|
return res;
|
package/src/options-pipe.js
CHANGED
|
@@ -9,9 +9,12 @@
|
|
|
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 { PipelineResponse } from './PipelineResponse.js';
|
|
13
14
|
import fetchConfigAll from './steps/fetch-config-all.js';
|
|
14
15
|
import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
|
|
16
|
+
import fetchConfig from './steps/fetch-config.js';
|
|
17
|
+
import { PipelineStatusError } from './PipelineStatusError.js';
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* Handles options requests
|
|
@@ -20,18 +23,39 @@ import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
|
|
|
20
23
|
* @returns {Response} a response
|
|
21
24
|
*/
|
|
22
25
|
export async function optionsPipe(state, request) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await fetchConfigAll(state, request, response);
|
|
34
|
-
await setCustomResponseHeaders(state, request, response);
|
|
26
|
+
try {
|
|
27
|
+
await fetchConfig(state, request);
|
|
28
|
+
if (!state.contentBusId) {
|
|
29
|
+
return new PipelineResponse('', {
|
|
30
|
+
status: 400,
|
|
31
|
+
headers: {
|
|
32
|
+
'x-error': 'contentBusId missing',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
// todo: improve
|
|
38
|
+
const res = new PipelineResponse('', {
|
|
39
|
+
status: 204,
|
|
40
|
+
headers: {
|
|
41
|
+
// Set preflight cache duration
|
|
42
|
+
'access-control-max-age': '86400',
|
|
43
|
+
// Allow content type header
|
|
44
|
+
'access-control-allow-headers': 'content-type',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
await fetchConfigAll(state, request, res);
|
|
48
|
+
await setCustomResponseHeaders(state, request, res);
|
|
49
|
+
|
|
50
|
+
return res;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
const res = new PipelineResponse('', {
|
|
53
|
+
status: e instanceof PipelineStatusError ? e.code : 500,
|
|
54
|
+
});
|
|
55
|
+
const level = res.status >= 500 ? 'error' : 'info';
|
|
56
|
+
state.log[level](`pipeline status: ${res.status} ${e.message}`);
|
|
57
|
+
res.headers.set('x-error', cleanupHeaderValue(e.message));
|
|
58
|
+
res.headers.set('cache-control', 'no-store, private, must-revalidate');
|
|
59
|
+
return res;
|
|
60
|
+
}
|
|
37
61
|
}
|