convention_builder 1.7.4 → 1.8.2
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/dist/module/index.js +36 -1
- package/dist/node/index.js +36 -1
- package/package.json +1 -1
package/dist/module/index.js
CHANGED
|
@@ -10604,7 +10604,7 @@ var require_convention_builder = __commonJS({
|
|
|
10604
10604
|
*/
|
|
10605
10605
|
updateSchema() {
|
|
10606
10606
|
this.schema = {};
|
|
10607
|
-
|
|
10607
|
+
this.schema = structuredClone(this.baseSchema);
|
|
10608
10608
|
this.schema.$id = this.repoURLTemplateFunction({ overlayName: this.name, projectID: this.gitlabProjectId, baseEntityTypeAndBundle: this.typeAndBundle });
|
|
10609
10609
|
let allModifiedAttributes = listAttributesAndSubAttributes(this.overlay);
|
|
10610
10610
|
this.modifiedAttributes = allModifiedAttributes;
|
|
@@ -10676,6 +10676,38 @@ var require_convention_builder = __commonJS({
|
|
|
10676
10676
|
this.updateAttributeStatus(attribute);
|
|
10677
10677
|
this.updateSchema();
|
|
10678
10678
|
}
|
|
10679
|
+
/**
|
|
10680
|
+
* Allows to "reset" a section to be able to set new constraints or leave it in a "generic" state altogether. This is mostly useful when creating a child convention and a preexisting attribute needs to be modified.
|
|
10681
|
+
* @param {} attribute
|
|
10682
|
+
*/
|
|
10683
|
+
cleanGenericSection({ attribute }) {
|
|
10684
|
+
let isObject = attribute.match(/\./);
|
|
10685
|
+
this.unmodifiedAttributes.add(attribute);
|
|
10686
|
+
this.modifiedAttributes.delete(attribute);
|
|
10687
|
+
if (isObject) {
|
|
10688
|
+
bury(this.overlay.properties.attributes.properties, attribute.replace(".value", ""), void 0, false);
|
|
10689
|
+
let firstLevel = attribute.split(/\./)[0];
|
|
10690
|
+
let siblingModifications = Array.from(this.modifiedAttributes).filter((attr) => attr != attribute).filter((attr) => attr.includes(`${firstLevel}.`));
|
|
10691
|
+
let isOnlyModification = siblingModifications.length == 0;
|
|
10692
|
+
console.log(`${attribute} is only modification? ${isOnlyModification}, there are ${siblingModifications.join(", ")}`);
|
|
10693
|
+
if (isOnlyModification) {
|
|
10694
|
+
delete this.overlay.properties.attributes.properties[firstLevel];
|
|
10695
|
+
}
|
|
10696
|
+
;
|
|
10697
|
+
} else {
|
|
10698
|
+
delete this.overlay.properties.attributes.properties[attribute];
|
|
10699
|
+
}
|
|
10700
|
+
;
|
|
10701
|
+
this.updateSchema();
|
|
10702
|
+
}
|
|
10703
|
+
/**
|
|
10704
|
+
* Edits the description for an attribute, independently of any schema limitations set on it. It will overwrite previous descriptions.
|
|
10705
|
+
* @param {} attribute
|
|
10706
|
+
* @param {} description
|
|
10707
|
+
*/
|
|
10708
|
+
setDescription({ attribute, description }) {
|
|
10709
|
+
bury(this.overlay.properties.attributes.properties, attribute.concat(".description"), description, false);
|
|
10710
|
+
}
|
|
10679
10711
|
/**
|
|
10680
10712
|
* Sets an attribute as a constant as indicated by the given value.
|
|
10681
10713
|
* @param {string} attribute -- Attribute name for the attribute which will be set to a constant.
|
|
@@ -10899,6 +10931,9 @@ var require_convention_builder = __commonJS({
|
|
|
10899
10931
|
let overlayNames = Object.keys(overlays);
|
|
10900
10932
|
this.overlays = {};
|
|
10901
10933
|
overlayNames.forEach((ovrl) => {
|
|
10934
|
+
overlays[ovrl].baseSchemataFolder = this.baseSchemataFolder;
|
|
10935
|
+
delete overlays[ovrl].baseSchema;
|
|
10936
|
+
delete overlays[ovrl].schema;
|
|
10902
10937
|
this.overlays[ovrl] = new SchemaOverlay(overlays[ovrl]);
|
|
10903
10938
|
this.overlays[ovrl].updateSchema();
|
|
10904
10939
|
});
|
package/dist/node/index.js
CHANGED
|
@@ -10597,7 +10597,7 @@ var require_convention_builder = __commonJS({
|
|
|
10597
10597
|
*/
|
|
10598
10598
|
updateSchema() {
|
|
10599
10599
|
this.schema = {};
|
|
10600
|
-
|
|
10600
|
+
this.schema = structuredClone(this.baseSchema);
|
|
10601
10601
|
this.schema.$id = this.repoURLTemplateFunction({ overlayName: this.name, projectID: this.gitlabProjectId, baseEntityTypeAndBundle: this.typeAndBundle });
|
|
10602
10602
|
let allModifiedAttributes = listAttributesAndSubAttributes(this.overlay);
|
|
10603
10603
|
this.modifiedAttributes = allModifiedAttributes;
|
|
@@ -10669,6 +10669,38 @@ var require_convention_builder = __commonJS({
|
|
|
10669
10669
|
this.updateAttributeStatus(attribute);
|
|
10670
10670
|
this.updateSchema();
|
|
10671
10671
|
}
|
|
10672
|
+
/**
|
|
10673
|
+
* Allows to "reset" a section to be able to set new constraints or leave it in a "generic" state altogether. This is mostly useful when creating a child convention and a preexisting attribute needs to be modified.
|
|
10674
|
+
* @param {} attribute
|
|
10675
|
+
*/
|
|
10676
|
+
cleanGenericSection({ attribute }) {
|
|
10677
|
+
let isObject = attribute.match(/\./);
|
|
10678
|
+
this.unmodifiedAttributes.add(attribute);
|
|
10679
|
+
this.modifiedAttributes.delete(attribute);
|
|
10680
|
+
if (isObject) {
|
|
10681
|
+
bury(this.overlay.properties.attributes.properties, attribute.replace(".value", ""), void 0, false);
|
|
10682
|
+
let firstLevel = attribute.split(/\./)[0];
|
|
10683
|
+
let siblingModifications = Array.from(this.modifiedAttributes).filter((attr) => attr != attribute).filter((attr) => attr.includes(`${firstLevel}.`));
|
|
10684
|
+
let isOnlyModification = siblingModifications.length == 0;
|
|
10685
|
+
console.log(`${attribute} is only modification? ${isOnlyModification}, there are ${siblingModifications.join(", ")}`);
|
|
10686
|
+
if (isOnlyModification) {
|
|
10687
|
+
delete this.overlay.properties.attributes.properties[firstLevel];
|
|
10688
|
+
}
|
|
10689
|
+
;
|
|
10690
|
+
} else {
|
|
10691
|
+
delete this.overlay.properties.attributes.properties[attribute];
|
|
10692
|
+
}
|
|
10693
|
+
;
|
|
10694
|
+
this.updateSchema();
|
|
10695
|
+
}
|
|
10696
|
+
/**
|
|
10697
|
+
* Edits the description for an attribute, independently of any schema limitations set on it. It will overwrite previous descriptions.
|
|
10698
|
+
* @param {} attribute
|
|
10699
|
+
* @param {} description
|
|
10700
|
+
*/
|
|
10701
|
+
setDescription({ attribute, description }) {
|
|
10702
|
+
bury(this.overlay.properties.attributes.properties, attribute.concat(".description"), description, false);
|
|
10703
|
+
}
|
|
10672
10704
|
/**
|
|
10673
10705
|
* Sets an attribute as a constant as indicated by the given value.
|
|
10674
10706
|
* @param {string} attribute -- Attribute name for the attribute which will be set to a constant.
|
|
@@ -10892,6 +10924,9 @@ var require_convention_builder = __commonJS({
|
|
|
10892
10924
|
let overlayNames = Object.keys(overlays);
|
|
10893
10925
|
this.overlays = {};
|
|
10894
10926
|
overlayNames.forEach((ovrl) => {
|
|
10927
|
+
overlays[ovrl].baseSchemataFolder = this.baseSchemataFolder;
|
|
10928
|
+
delete overlays[ovrl].baseSchema;
|
|
10929
|
+
delete overlays[ovrl].schema;
|
|
10895
10930
|
this.overlays[ovrl] = new SchemaOverlay2(overlays[ovrl]);
|
|
10896
10931
|
this.overlays[ovrl].updateSchema();
|
|
10897
10932
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "convention_builder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Helper tools that offer a high level interface that transforms a convention description into it's json schema.",
|
|
5
5
|
"main": "./dist/node/index.js",
|
|
6
6
|
"browser": "./dist/browser/index.js",
|