@adobe/helix-html-pipeline 1.8.14 → 1.9.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [1.9.0](https://github.com/adobe/helix-html-pipeline/compare/v1.8.15...v1.9.0) (2023-01-13)
2
+
3
+
4
+ ### Features
5
+
6
+ * add contentbusId/path as surrogate key ([87b1ad6](https://github.com/adobe/helix-html-pipeline/commit/87b1ad6bc5890eb2e743b59d3726a962226a8e6d))
7
+
8
+ ## [1.8.15](https://github.com/adobe/helix-html-pipeline/compare/v1.8.14...v1.8.15) (2023-01-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#228](https://github.com/adobe/helix-html-pipeline/issues/228)) ([761b4ec](https://github.com/adobe/helix-html-pipeline/commit/761b4ec70764f02bbc393e507c8fccc62e8bc5a9))
14
+
1
15
  ## [1.8.14](https://github.com/adobe/helix-html-pipeline/compare/v1.8.13...v1.8.14) (2022-12-10)
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.14",
3
+ "version": "1.9.0",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -35,15 +35,15 @@
35
35
  "@adobe/remark-gridtables": "1.0.0",
36
36
  "github-slugger": "2.0.0",
37
37
  "hast-util-raw": "7.2.3",
38
- "hast-util-select": "5.0.2",
38
+ "hast-util-select": "5.0.3",
39
39
  "hast-util-to-html": "8.0.3",
40
40
  "hast-util-to-string": "2.0.0",
41
- "hastscript": "7.1.0",
41
+ "hastscript": "7.2.0",
42
42
  "mdast-util-gfm-footnote": "1.0.1",
43
43
  "mdast-util-gfm-strikethrough": "1.0.2",
44
44
  "mdast-util-gfm-table": "1.0.6",
45
45
  "mdast-util-gfm-task-list-item": "1.0.1",
46
- "mdast-util-to-hast": "12.2.4",
46
+ "mdast-util-to-hast": "12.2.5",
47
47
  "mdast-util-to-string": "3.1.0",
48
48
  "micromark-extension-gfm-footnote": "1.0.4",
49
49
  "micromark-extension-gfm-strikethrough": "1.0.4",
@@ -61,7 +61,7 @@
61
61
  "unist-util-map": "3.1.2",
62
62
  "unist-util-remove": "3.1.0",
63
63
  "unist-util-remove-position": "4.0.1",
64
- "unist-util-select": "4.0.1",
64
+ "unist-util-select": "4.0.2",
65
65
  "unist-util-visit": "4.1.1"
66
66
  },
67
67
  "devDependencies": {
@@ -71,17 +71,17 @@
71
71
  "@semantic-release/git": "10.0.1",
72
72
  "@semantic-release/npm": "9.0.1",
73
73
  "c8": "7.12.0",
74
- "eslint": "8.29.0",
74
+ "eslint": "8.31.0",
75
75
  "eslint-import-resolver-exports": "1.0.0-beta.3",
76
76
  "eslint-plugin-header": "3.1.1",
77
77
  "eslint-plugin-import": "2.26.0",
78
78
  "esmock": "2.1.0",
79
- "husky": "8.0.2",
79
+ "husky": "8.0.3",
80
80
  "js-yaml": "4.1.0",
81
- "jsdom": "20.0.3",
81
+ "jsdom": "21.0.0",
82
82
  "junit-report-builder": "3.0.1",
83
83
  "lint-staged": "13.1.0",
84
- "mocha": "10.1.0",
84
+ "mocha": "10.2.0",
85
85
  "mocha-multi-reporters": "1.5.1",
86
86
  "remark-gfm": "3.0.1",
87
87
  "semantic-release": "19.0.5"
package/src/json-pipe.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 { cleanupHeaderValue } from '@adobe/helix-shared-utils';
12
+ import { cleanupHeaderValue, computeSurrogateKey } from '@adobe/helix-shared-utils';
13
13
  import fetchMetadata from './steps/fetch-metadata.js';
14
14
  import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
15
15
  import { PipelineResponse } from './PipelineResponse.js';
@@ -111,8 +111,11 @@ export async function jsonPipe(state, req) {
111
111
  // set last-modified
112
112
  updateLastModified(state, response, extractLastModified(dataResponse.headers));
113
113
 
114
- // set surrogate key
115
- response.headers.set('x-surrogate-key', `${contentBusId}${path}`.replace(/\//g, '_'));
114
+ // set surrogate keys
115
+ const keys = [];
116
+ keys.push(`${contentBusId}${path}`.replace(/\//g, '_')); // TODO: remove
117
+ keys.push(await computeSurrogateKey(`${contentBusId}${path}`));
118
+ response.headers.set('x-surrogate-key', keys.join(' '));
116
119
 
117
120
  // Load metadata from metadata.json
118
121
  await fetchMetadata(state, req, response);
@@ -20,13 +20,25 @@ import { computeSurrogateKey } from '@adobe/helix-shared-utils';
20
20
  */
21
21
  export default async function setXSurrogateKeyHeader(state, req, res) {
22
22
  const {
23
- content, contentBusId, owner, repo, ref,
23
+ content, contentBusId, owner, repo, ref, info,
24
24
  } = state;
25
25
 
26
+ let { path } = info;
27
+
26
28
  const keys = [];
27
29
  if (content.sourceLocation) {
28
30
  keys.push(await computeSurrogateKey(content.sourceLocation));
29
31
  }
32
+
33
+ // surrogate key for path
34
+ // strip [index].plain.html
35
+ if (path.endsWith('index.plain.html')) {
36
+ path = path.substring(0, path.length - 'index.plain.html'.length);
37
+ } else if (path.endsWith('.plain.html')) {
38
+ path = path.substring(0, path.length - '.plain.html'.length);
39
+ }
40
+ keys.push(await computeSurrogateKey(`${contentBusId}${path}`));
41
+
30
42
  keys.push(`${contentBusId}_metadata`);
31
43
  keys.push(`${ref}--${repo}--${owner}_head`);
32
44