convention_builder 1.6.1 → 1.7.1

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.
@@ -10971,6 +10971,7 @@ var require_convention_builder = __commonJS({
10971
10971
  description: this.description,
10972
10972
  required: this.required
10973
10973
  };
10974
+ this.enforceConventionTaxonomyTerm();
10974
10975
  Object.keys(this.overlays).forEach((attributeName) => {
10975
10976
  this.overlays[attributeName].updateSchema();
10976
10977
  this.schema.properties[attributeName] = this.overlays[attributeName].schema;
@@ -11275,6 +11276,56 @@ import TabItem from '@theme/TabItem';
11275
11276
  ;
11276
11277
  return output;
11277
11278
  }
11279
+ /**
11280
+ * Will create an appropiate convention taxonomy term and add it into the definition, with the appropriate content and relationships.
11281
+ */
11282
+ addConventionTaxonomyTerm() {
11283
+ let conventionTree = this.getAttributesTree();
11284
+ let entitiesInRoot = Object.keys(conventionTree);
11285
+ let mainEntity = entitiesInRoot.length == 1 ? entitiesInRoot[0] : void 0;
11286
+ if (mainEntity) {
11287
+ const conventionTaxonomyTerm = new SchemaOverlay(
11288
+ {
11289
+ typeAndBundle: "taxonomy_term--convention",
11290
+ name: "convention_taxonomy",
11291
+ baseSchemataFolder: this.baseSchemataFolder,
11292
+ storageFolder: this.storageFolder
11293
+ }
11294
+ );
11295
+ conventionTaxonomyTerm.setConstant({
11296
+ attribute: "external_uri",
11297
+ value: this.repoURLTemplateFunction({ conventionName: this.schemaName, projectID: this.gitlabProjectId }),
11298
+ description: "External URI in which this convention's schema and other artifacts will be hosted as artifacts by GitLab."
11299
+ });
11300
+ conventionTaxonomyTerm.setMainDescription("This entity tags data as organized into the convention we intend to instantiate, allowing to pick the right schemata to test it against.");
11301
+ conventionTaxonomyTerm.setConstant({
11302
+ attribute: "name",
11303
+ value: this.title
11304
+ });
11305
+ this.addAttribute({
11306
+ schemaOverlayObject: conventionTaxonomyTerm,
11307
+ attributeName: "convention_taxonomy",
11308
+ required: true
11309
+ });
11310
+ this.addRelationship({
11311
+ containerEntity: mainEntity,
11312
+ relationName: "convention",
11313
+ mentionedEntity: "convention_taxonomy",
11314
+ required: true
11315
+ });
11316
+ }
11317
+ ;
11318
+ }
11319
+ enforceConventionTaxonomyTerm() {
11320
+ let conventionExists = Object.keys(this.overlays).find((d) => this.overlays[d].typeAndBundle == "taxonomy_term--convention");
11321
+ let output = false;
11322
+ if (!conventionExists) {
11323
+ this.addConventionTaxonomyTerm();
11324
+ output = true;
11325
+ }
11326
+ ;
11327
+ return output;
11328
+ }
11278
11329
  /**
11279
11330
  * This method takes this object's schema and returns an array of fixed attributes objects, which is equivalent to a row by row encoded excel spreadsheet and is mostly meant at allowing users to work on said schema via a tabular structure.
11280
11331
  * The output will include one row for each data entry path (not all of the paths) and will synthesize all of its properties into columns, such as name, Title, Type, etc.
@@ -11334,7 +11385,6 @@ import TabItem from '@theme/TabItem';
11334
11385
  let test = this.testExamples();
11335
11386
  let valid = test.success;
11336
11387
  if (!valid && !overlaysOnly) {
11337
- console.log(JSON.stringify(test.failedExamples));
11338
11388
  throw new Error(`The 'testExamples' method failed. The schema ${this.schemaName} either lacks examples, or is rejecting a valid example or accepting an invalid example.
11339
11389
  * Valid examples provided: ${test.validExamples.length}
11340
11390
  * Error examples provided: ${test.erroredExamples.length}
@@ -10964,6 +10964,7 @@ var require_convention_builder = __commonJS({
10964
10964
  description: this.description,
10965
10965
  required: this.required
10966
10966
  };
10967
+ this.enforceConventionTaxonomyTerm();
10967
10968
  Object.keys(this.overlays).forEach((attributeName) => {
10968
10969
  this.overlays[attributeName].updateSchema();
10969
10970
  this.schema.properties[attributeName] = this.overlays[attributeName].schema;
@@ -11268,6 +11269,56 @@ import TabItem from '@theme/TabItem';
11268
11269
  ;
11269
11270
  return output;
11270
11271
  }
11272
+ /**
11273
+ * Will create an appropiate convention taxonomy term and add it into the definition, with the appropriate content and relationships.
11274
+ */
11275
+ addConventionTaxonomyTerm() {
11276
+ let conventionTree = this.getAttributesTree();
11277
+ let entitiesInRoot = Object.keys(conventionTree);
11278
+ let mainEntity = entitiesInRoot.length == 1 ? entitiesInRoot[0] : void 0;
11279
+ if (mainEntity) {
11280
+ const conventionTaxonomyTerm = new SchemaOverlay2(
11281
+ {
11282
+ typeAndBundle: "taxonomy_term--convention",
11283
+ name: "convention_taxonomy",
11284
+ baseSchemataFolder: this.baseSchemataFolder,
11285
+ storageFolder: this.storageFolder
11286
+ }
11287
+ );
11288
+ conventionTaxonomyTerm.setConstant({
11289
+ attribute: "external_uri",
11290
+ value: this.repoURLTemplateFunction({ conventionName: this.schemaName, projectID: this.gitlabProjectId }),
11291
+ description: "External URI in which this convention's schema and other artifacts will be hosted as artifacts by GitLab."
11292
+ });
11293
+ conventionTaxonomyTerm.setMainDescription("This entity tags data as organized into the convention we intend to instantiate, allowing to pick the right schemata to test it against.");
11294
+ conventionTaxonomyTerm.setConstant({
11295
+ attribute: "name",
11296
+ value: this.title
11297
+ });
11298
+ this.addAttribute({
11299
+ schemaOverlayObject: conventionTaxonomyTerm,
11300
+ attributeName: "convention_taxonomy",
11301
+ required: true
11302
+ });
11303
+ this.addRelationship({
11304
+ containerEntity: mainEntity,
11305
+ relationName: "convention",
11306
+ mentionedEntity: "convention_taxonomy",
11307
+ required: true
11308
+ });
11309
+ }
11310
+ ;
11311
+ }
11312
+ enforceConventionTaxonomyTerm() {
11313
+ let conventionExists = Object.keys(this.overlays).find((d) => this.overlays[d].typeAndBundle == "taxonomy_term--convention");
11314
+ let output = false;
11315
+ if (!conventionExists) {
11316
+ this.addConventionTaxonomyTerm();
11317
+ output = true;
11318
+ }
11319
+ ;
11320
+ return output;
11321
+ }
11271
11322
  /**
11272
11323
  * This method takes this object's schema and returns an array of fixed attributes objects, which is equivalent to a row by row encoded excel spreadsheet and is mostly meant at allowing users to work on said schema via a tabular structure.
11273
11324
  * The output will include one row for each data entry path (not all of the paths) and will synthesize all of its properties into columns, such as name, Title, Type, etc.
@@ -11327,7 +11378,6 @@ import TabItem from '@theme/TabItem';
11327
11378
  let test = this.testExamples();
11328
11379
  let valid = test.success;
11329
11380
  if (!valid && !overlaysOnly) {
11330
- console.log(JSON.stringify(test.failedExamples));
11331
11381
  throw new Error(`The 'testExamples' method failed. The schema ${this.schemaName} either lacks examples, or is rejecting a valid example or accepting an invalid example.
11332
11382
  * Valid examples provided: ${test.validExamples.length}
11333
11383
  * Error examples provided: ${test.erroredExamples.length}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "convention_builder",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
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",