convention_builder 1.7.2 → 1.7.4

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.
@@ -10709,6 +10709,10 @@ var require_convention_builder = __commonJS({
10709
10709
  setEnum({ attribute, valuesArray, description }) {
10710
10710
  this.checkAttributeStatus(attribute);
10711
10711
  let subschema;
10712
+ if (!valuesArray) {
10713
+ throw new Error(`Attribute 'valuesArray' is empty for ${attribute}, which makes the schema impossible to satisfy.`);
10714
+ }
10715
+ ;
10712
10716
  if (this.strictEnums) {
10713
10717
  subschema = { enum: valuesArray };
10714
10718
  } else {
@@ -11009,6 +11013,7 @@ var require_convention_builder = __commonJS({
11009
11013
  if (isOverlay) {
11010
11014
  try {
11011
11015
  schemaOverlayObject = new SchemaOverlay(JSON.parse(fs.readFileSync(`${this.storagePath()}/overlays/${schemaOverlayObject}/object.json`)));
11016
+ schemaOverlayObject.global = true;
11012
11017
  } catch (e) {
11013
11018
  if (e.code == "ENOENT" && !overlaysOnly) {
11014
11019
  throw new Error(`Couldn't find any file corresponding to the string provided, searched for ${this.storagePath()}/overlays/${schemaOverlayName}/object.json. Might be the case that you are calling.`);
@@ -11070,7 +11075,7 @@ var require_convention_builder = __commonJS({
11070
11075
  let containerSchema = this.overlays[containerEntity].schema;
11071
11076
  let relationshipAttributes = Object.keys(containerSchema.properties.relationships.properties);
11072
11077
  if (!relationshipAttributes.includes(relationName)) {
11073
- throw new Error(`The provided relationship field, '${relationName}', doesn't seem to be a valid field in the schema for '${containerSchema.properties.type.const}'. Available fields are: ${relationshipAttributes.join(", ")}.
11078
+ throw new Error(`The provided relationship field, '${relationName}', doesn't seem to be a valid field in the schema for '${containerSchema.properties.type.const}'. Available fields are: ${relationshipAttributes ? relationshipAttributes.join(", ") : "none"}.
11074
11079
  Schema read from ${this.baseSchemataFolder}`);
11075
11080
  }
11076
11081
  ;
@@ -11154,7 +11159,7 @@ var require_convention_builder = __commonJS({
11154
11159
  ;
11155
11160
  if (Object.keys(currentBranch).length > 0) {
11156
11161
  Object.keys(currentBranch).forEach((key) => {
11157
- text = this.printTreeBranch({ currentLevelIndex: currentLevelIndex + 1, currentBranch: currentBranch[key], currentAttributeName: key });
11162
+ text = this.printTreeBranch({ currentLevelIndex: currentLevelIndex + 1, currentBranch: currentBranch[key], currentAttributeName: key, text });
11158
11163
  });
11159
11164
  }
11160
11165
  return text;
@@ -11394,7 +11399,11 @@ import TabItem from '@theme/TabItem';
11394
11399
  }
11395
11400
  ;
11396
11401
  Object.keys(this.overlays).forEach((overlayName) => {
11397
- this.overlays[overlayName].store(false);
11402
+ let currentOverlay = this.overlays[overlayName];
11403
+ if (!currentOverlay.trivial && !currentOverlay.global) {
11404
+ currentOverlay.store(false);
11405
+ }
11406
+ ;
11398
11407
  });
11399
11408
  if (overlaysOnly) {
11400
11409
  console.log(`Only storing overlays due to overlaysOnly switch.`);
@@ -10702,6 +10702,10 @@ var require_convention_builder = __commonJS({
10702
10702
  setEnum({ attribute, valuesArray, description }) {
10703
10703
  this.checkAttributeStatus(attribute);
10704
10704
  let subschema;
10705
+ if (!valuesArray) {
10706
+ throw new Error(`Attribute 'valuesArray' is empty for ${attribute}, which makes the schema impossible to satisfy.`);
10707
+ }
10708
+ ;
10705
10709
  if (this.strictEnums) {
10706
10710
  subschema = { enum: valuesArray };
10707
10711
  } else {
@@ -11002,6 +11006,7 @@ var require_convention_builder = __commonJS({
11002
11006
  if (isOverlay) {
11003
11007
  try {
11004
11008
  schemaOverlayObject = new SchemaOverlay2(JSON.parse(fs.readFileSync(`${this.storagePath()}/overlays/${schemaOverlayObject}/object.json`)));
11009
+ schemaOverlayObject.global = true;
11005
11010
  } catch (e) {
11006
11011
  if (e.code == "ENOENT" && !overlaysOnly) {
11007
11012
  throw new Error(`Couldn't find any file corresponding to the string provided, searched for ${this.storagePath()}/overlays/${schemaOverlayName}/object.json. Might be the case that you are calling.`);
@@ -11063,7 +11068,7 @@ var require_convention_builder = __commonJS({
11063
11068
  let containerSchema = this.overlays[containerEntity].schema;
11064
11069
  let relationshipAttributes = Object.keys(containerSchema.properties.relationships.properties);
11065
11070
  if (!relationshipAttributes.includes(relationName)) {
11066
- throw new Error(`The provided relationship field, '${relationName}', doesn't seem to be a valid field in the schema for '${containerSchema.properties.type.const}'. Available fields are: ${relationshipAttributes.join(", ")}.
11071
+ throw new Error(`The provided relationship field, '${relationName}', doesn't seem to be a valid field in the schema for '${containerSchema.properties.type.const}'. Available fields are: ${relationshipAttributes ? relationshipAttributes.join(", ") : "none"}.
11067
11072
  Schema read from ${this.baseSchemataFolder}`);
11068
11073
  }
11069
11074
  ;
@@ -11147,7 +11152,7 @@ var require_convention_builder = __commonJS({
11147
11152
  ;
11148
11153
  if (Object.keys(currentBranch).length > 0) {
11149
11154
  Object.keys(currentBranch).forEach((key) => {
11150
- text = this.printTreeBranch({ currentLevelIndex: currentLevelIndex + 1, currentBranch: currentBranch[key], currentAttributeName: key });
11155
+ text = this.printTreeBranch({ currentLevelIndex: currentLevelIndex + 1, currentBranch: currentBranch[key], currentAttributeName: key, text });
11151
11156
  });
11152
11157
  }
11153
11158
  return text;
@@ -11387,7 +11392,11 @@ import TabItem from '@theme/TabItem';
11387
11392
  }
11388
11393
  ;
11389
11394
  Object.keys(this.overlays).forEach((overlayName) => {
11390
- this.overlays[overlayName].store(false);
11395
+ let currentOverlay = this.overlays[overlayName];
11396
+ if (!currentOverlay.trivial && !currentOverlay.global) {
11397
+ currentOverlay.store(false);
11398
+ }
11399
+ ;
11391
11400
  });
11392
11401
  if (overlaysOnly) {
11393
11402
  console.log(`Only storing overlays due to overlaysOnly switch.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "convention_builder",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
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",