@adobe/helix-html-pipeline 3.11.16 → 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 CHANGED
@@ -1,3 +1,17 @@
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
+
8
+ ## [3.11.17](https://github.com/adobe/helix-html-pipeline/compare/v3.11.16...v3.11.17) (2023-06-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency @adobe/remark-gridtables to v1.0.4 ([#340](https://github.com/adobe/helix-html-pipeline/issues/340)) ([c6dd583](https://github.com/adobe/helix-html-pipeline/commit/c6dd5835dc99d2c9bfd9bd089264399d278a9fb7))
14
+
1
15
  ## [3.11.16](https://github.com/adobe/helix-html-pipeline/compare/v3.11.15...v3.11.16) (2023-06-27)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "3.11.16",
3
+ "version": "3.11.18",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -42,7 +42,7 @@
42
42
  "@adobe/helix-markdown-support": "6.1.3",
43
43
  "@adobe/helix-shared-utils": "3.0.0",
44
44
  "@adobe/mdast-util-gridtables": "1.0.9",
45
- "@adobe/remark-gridtables": "1.0.3",
45
+ "@adobe/remark-gridtables": "1.0.4",
46
46
  "cookie": "0.5.0",
47
47
  "github-slugger": "2.0.0",
48
48
  "hast-util-raw": "8.0.0",
@@ -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.43.0",
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.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.5"
99
+ "semantic-release": "21.0.6"
100
100
  },
101
101
  "lint-staged": {
102
102
  "*.js": "eslint",
@@ -46,7 +46,6 @@ declare interface PipelineOptions {
46
46
  ref: string;
47
47
  partition: string;
48
48
  path: string;
49
- contentBusId: string;
50
49
  timer: PipelineTimer;
51
50
  env: object;
52
51
  }
@@ -29,8 +29,6 @@ export class PipelineState {
29
29
  env: opts.env,
30
30
  info: getPathInfo(opts.path),
31
31
  content: new PipelineContent(),
32
- // todo: compute content-bus id from fstab
33
- contentBusId: opts.contentBusId,
34
32
  owner: opts.owner,
35
33
  repo: opts.repo,
36
34
  ref: opts.ref,
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;
@@ -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
- // todo: improve
24
- const response = new PipelineResponse('', {
25
- status: 204,
26
- headers: {
27
- // Set preflight cache duration
28
- 'access-control-max-age': '86400',
29
- // Allow content type header
30
- 'access-control-allow-headers': 'content-type',
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
- return response;
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
  }