@adobe/helix-md2jcr 1.1.1 → 1.1.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 +14 -0
- package/package.json +4 -3
- package/src/mdast2jcr/domain/Component.js +25 -2
- package/src/mdast2jcr/domain/ModelHelper.js +22 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.1.3](https://github.com/adobe/helix-md2jcr/compare/v1.1.2...v1.1.3) (2025-03-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/fetch to v4.2.0 ([#64](https://github.com/adobe/helix-md2jcr/issues/64)) ([a509b0c](https://github.com/adobe/helix-md2jcr/commit/a509b0c5d3f7a86d7af941799d30f62b27e63e20))
|
|
7
|
+
|
|
8
|
+
## [1.1.2](https://github.com/adobe/helix-md2jcr/compare/v1.1.1...v1.1.2) (2025-02-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **sites-29541:** allow model fields to be in mixed order ([#62](https://github.com/adobe/helix-md2jcr/issues/62)) ([c7592c4](https://github.com/adobe/helix-md2jcr/commit/c7592c4a6825bc9b2a53b48034a1691fef263001))
|
|
14
|
+
|
|
1
15
|
## [1.1.1](https://github.com/adobe/helix-md2jcr/compare/v1.1.0...v1.1.1) (2025-02-25)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-md2jcr",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Helix Service that converts markdown to JCR content structure",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/adobe/helix-md2jcr#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@adobe/fetch": "4.
|
|
31
|
+
"@adobe/fetch": "4.2.0",
|
|
32
32
|
"@adobe/helix-markdown-support": "7.1.12",
|
|
33
33
|
"@adobe/helix-shared-process-queue": "3.1.1",
|
|
34
34
|
"@adobe/remark-gridtables": "3.0.10",
|
|
@@ -55,13 +55,14 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@adobe/eslint-config-helix": "2.0.9",
|
|
58
|
-
"@adobe/helix-mediahandler": "2.6.
|
|
58
|
+
"@adobe/helix-mediahandler": "2.6.4",
|
|
59
59
|
"@commitlint/cli": "^19.6.1",
|
|
60
60
|
"@commitlint/config-conventional": "^19.6.0",
|
|
61
61
|
"@semantic-release/changelog": "6.0.3",
|
|
62
62
|
"@semantic-release/exec": "6.0.3",
|
|
63
63
|
"@semantic-release/git": "10.0.1",
|
|
64
64
|
"c8": "10.1.3",
|
|
65
|
+
"chai": "^5.2.0",
|
|
65
66
|
"dotenv": "16.4.7",
|
|
66
67
|
"eslint": "8.57.1",
|
|
67
68
|
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
@@ -19,7 +19,7 @@ class Component {
|
|
|
19
19
|
* Create a new Component.
|
|
20
20
|
* @param {string} name
|
|
21
21
|
* @param {string} id
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {Object} template
|
|
23
23
|
*/
|
|
24
24
|
constructor(name, id, template) {
|
|
25
25
|
this._template = template;
|
|
@@ -30,27 +30,50 @@ class Component {
|
|
|
30
30
|
this._id = id;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Get the ID for the component.
|
|
35
|
+
* @return {string}
|
|
36
|
+
*/
|
|
33
37
|
get id() {
|
|
34
38
|
return this._id;
|
|
35
39
|
}
|
|
36
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Get the filter ID for the component.
|
|
43
|
+
* @return {string}
|
|
44
|
+
*/
|
|
37
45
|
get filterId() {
|
|
38
46
|
return this._filterId;
|
|
39
47
|
}
|
|
40
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Get the model ID for the component.
|
|
51
|
+
* @return {string}
|
|
52
|
+
*/
|
|
41
53
|
get modelId() {
|
|
42
54
|
return this._modelId;
|
|
43
55
|
}
|
|
44
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Return true or false if the component is a key-value component.
|
|
59
|
+
* @return {boolean}
|
|
60
|
+
*/
|
|
45
61
|
get keyValue() {
|
|
46
62
|
return this._keyValue;
|
|
47
63
|
}
|
|
48
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Get the name of the component.
|
|
67
|
+
* @return {string}
|
|
68
|
+
*/
|
|
49
69
|
get name() {
|
|
50
70
|
return this._name;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Return the component's default fields specified in the template section.
|
|
75
|
+
* @return {Object}
|
|
76
|
+
*/
|
|
54
77
|
get defaultFields() {
|
|
55
78
|
return this._template;
|
|
56
79
|
}
|
|
@@ -27,7 +27,7 @@ class ModelHelper {
|
|
|
27
27
|
*/
|
|
28
28
|
constructor(blockName, models, definition, filters) {
|
|
29
29
|
this.blockName = blockName;
|
|
30
|
-
this.
|
|
30
|
+
this._fixFieldOrder(models);
|
|
31
31
|
this.models = models;
|
|
32
32
|
this.definition = definition;
|
|
33
33
|
this.filters = filters;
|
|
@@ -35,37 +35,31 @@ class ModelHelper {
|
|
|
35
35
|
this._groupModelFields();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The field order in the models is not guaranteed to be correct. This method will fix the order
|
|
40
|
+
* of the fields in the models so that the base field is followed by the suffix fields.
|
|
41
|
+
* @param {Array<Model>} models The models to fix the field order.
|
|
42
|
+
* @private {void}
|
|
43
|
+
*/
|
|
38
44
|
// eslint-disable-next-line class-methods-use-this
|
|
39
|
-
|
|
45
|
+
_fixFieldOrder(models) {
|
|
40
46
|
const suffixes = ['Alt', 'MimeType', 'Type', 'Text', 'Title'];
|
|
41
47
|
|
|
42
48
|
models.forEach((model) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
warnings.push(` - Field '${field.name}' appears before its base field '${baseName}'.`);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
// This is a base field, add it to seenBaseFields
|
|
62
|
-
seenBaseFields.add(baseName);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
if (warningGenerated) {
|
|
67
|
-
throw new Error(warnings.join('\n'));
|
|
68
|
-
}
|
|
49
|
+
// collect the name of all the model fields that do not have a suffix
|
|
50
|
+
const baseFields = model.fields
|
|
51
|
+
.filter((field) => !suffixes.some((suffix) => field.name.endsWith(suffix)))
|
|
52
|
+
.map((field) => field.name);
|
|
53
|
+
|
|
54
|
+
// for each base field, find the associated fields with suffixes and update the model
|
|
55
|
+
// fixing the order so that we can later group things together
|
|
56
|
+
// eslint-disable-next-line no-param-reassign
|
|
57
|
+
model.fields = baseFields.flatMap((baseField) => [
|
|
58
|
+
// will return array with [field, fieldText, fieldType, etc]
|
|
59
|
+
model.fields.find((field) => field.name === baseField),
|
|
60
|
+
...suffixes
|
|
61
|
+
.map((suffix) => model.fields.find((field) => field.name === `${baseField}${suffix}`))
|
|
62
|
+
.filter(Boolean)]);
|
|
69
63
|
});
|
|
70
64
|
}
|
|
71
65
|
|