@adobe/helix-html-pipeline 1.3.2 → 1.3.3

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,10 @@
1
+ ## [1.3.3](https://github.com/adobe/helix-html-pipeline/compare/v1.3.2...v1.3.3) (2022-04-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 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))
7
+
1
8
  ## [1.3.2](https://github.com/adobe/helix-html-pipeline/compare/v1.3.1...v1.3.2) (2022-03-19)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -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.3",
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.3",
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.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.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.11.0",
79
+ "eslint": "8.12.0",
80
80
  "eslint-plugin-header": "3.1.1",
81
81
  "eslint-plugin-import": "2.25.4",
82
- "esmock": "1.7.4",
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.5",
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",
@@ -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
 
@@ -38,6 +38,7 @@ export class PipelineState {
38
38
  s3Loader: opts.s3Loader,
39
39
  messageDispatcher: opts.messageDispatcher,
40
40
  timer: opts.timer,
41
+ type: 'html',
41
42
  });
42
43
  }
43
44
  }
package/src/forms-pipe.js CHANGED
@@ -88,6 +88,7 @@ export async function extractBodyData(request) {
88
88
  */
89
89
  export async function formsPipe(state, request) {
90
90
  const { log } = state;
91
+ state.type = 'form';
91
92
 
92
93
  // todo: improve
93
94
  const response = new PipelineResponse('', {
package/src/html-pipe.js CHANGED
@@ -44,6 +44,7 @@ import { validatePathInfo } from './utils/path.js';
44
44
  */
45
45
  export async function htmlPipe(state, req) {
46
46
  const { log } = state;
47
+ state.type = 'html';
47
48
 
48
49
  if (!validatePathInfo(state.info)) {
49
50
  return new PipelineResponse('', {
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 (note, that it is not influenced by metadata or helix-config.json)
74
- const lastModified = dataResponse.headers.get('last-modified');
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, '_'));
@@ -39,8 +39,10 @@ export default async function fetchMetadata(state, req, res) {
39
39
  }
40
40
  state.metadata = data;
41
41
 
42
- // also update last-modified
43
- updateLastModified(state, res, extractLastModified(ret.headers));
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