convention_builder 1.7.1 → 1.7.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.
@@ -10546,6 +10546,7 @@ var require_convention_builder = __commonJS({
10546
10546
  this.trivial = trivial;
10547
10547
  this.baseSchemataFolder = baseSchemataFolder;
10548
10548
  this.requiredFields = Array.isArray(requiredFields) ? new Set(requiredFields) : /* @__PURE__ */ new Set([]);
10549
+ this.gitlabProjectId = gitlabProjectId;
10549
10550
  let validBaseSchemaPattern = typeAndBundle.match(/^[a-z_]*--[a-z_]*$/) ? typeAndBundle.match(/^[a-z_]*--[a-z_]*$/).index == 0 : false;
10550
10551
  if (!validBaseSchemaPattern) {
10551
10552
  throw new Error(`No schema for ${typeAndBundle} was found, as wanted by ${name}. This parameter should be a type--bundle pair, as farmOS mandates (examples are "log--lab_test" and "asset--land").`);
@@ -11069,7 +11070,8 @@ var require_convention_builder = __commonJS({
11069
11070
  let containerSchema = this.overlays[containerEntity].schema;
11070
11071
  let relationshipAttributes = Object.keys(containerSchema.properties.relationships.properties);
11071
11072
  if (!relationshipAttributes.includes(relationName)) {
11072
- 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(", ")}.`);
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(", ")}.
11074
+ Schema read from ${this.baseSchemataFolder}`);
11073
11075
  }
11074
11076
  ;
11075
11077
  this.relationships.push({ containerEntity, relationName, mentionedEntity, required });
@@ -11479,9 +11481,9 @@ import TabItem from '@theme/TabItem';
11479
11481
  typeAndBundle: target,
11480
11482
  attributeOverlayName: this.overlayName,
11481
11483
  baseSchemataFolder: this.baseSchemataFolder,
11482
- gitlabProjectId: this.gitlabProjectId
11484
+ gitlabProjectId
11483
11485
  });
11484
- currentOverlay.gitlabProjectId = this.gitlabProjectId;
11486
+ currentOverlay.gitlabProjectId = gitlabProjectId;
11485
11487
  this.overlays.push(currentOverlay);
11486
11488
  });
11487
11489
  }
@@ -25356,9 +25358,17 @@ var require_array_examples_preparator = __commonJS({
25356
25358
  var utils = require_schema_utilities();
25357
25359
  var axios = require_axios();
25358
25360
  var _ArrayDataOrganizer = class _ArrayDataOrganizer {
25359
- constructor({ exampleArray }) {
25361
+ constructor({
25362
+ exampleArray,
25363
+ storageFolder = `${__dirname}/../../../../output/collection/overlays`,
25364
+ baseSchemataFolder = `${__dirname}/../../../../input/collection`,
25365
+ predefinedConventions
25366
+ }) {
25360
25367
  this.exampleArray = exampleArray;
25361
25368
  this.instances = [];
25369
+ this.storageFolder = storageFolder;
25370
+ this.baseSchemataFolder = baseSchemataFolder;
25371
+ this.predefinedConventions = predefinedConventions;
25362
25372
  }
25363
25373
  /**
25364
25374
  * Will retrieve the data needed and structure the example.
@@ -25390,11 +25400,21 @@ var require_array_examples_preparator = __commonJS({
25390
25400
  return entries;
25391
25401
  });
25392
25402
  let allMentionedConventions = Array.from(new Set(this.exampleArray.filter((d) => d.type == "taxonomy_term--convention").map((d) => d.attributes.external_uri)));
25393
- let conventionSchemataPromises = allMentionedConventions.map((url) => __async(this, null, function* () {
25394
- return yield axios.get(url.replace("schema.json", "object.json")).then((res) => res.data);
25395
- }));
25396
- let conventionObjects = yield Promise.all(conventionSchemataPromises);
25397
- let conventions = conventionObjects.map((d) => new builder.ConventionSchema(d));
25403
+ let conventionObjects;
25404
+ if (!this.predefinedConventions) {
25405
+ let conventionSchemataPromises = allMentionedConventions.map((url) => __async(this, null, function* () {
25406
+ return yield axios.get(url.replace("schema.json", "object.json")).then((res) => res.data);
25407
+ }));
25408
+ conventionObjects = yield Promise.all(conventionSchemataPromises);
25409
+ } else {
25410
+ conventionObjects = this.predefinedConventions;
25411
+ }
25412
+ ;
25413
+ let conventions = conventionObjects.map((d) => {
25414
+ d.baseSchemataFolder = this.baseSchemataFolder;
25415
+ d.storageFolder = this.storageFolder;
25416
+ return new builder.ConventionSchema(d);
25417
+ });
25398
25418
  this.detected_conventions = conventionCarrierEntities;
25399
25419
  this.conventions = conventions;
25400
25420
  });
@@ -25406,6 +25426,12 @@ var require_array_examples_preparator = __commonJS({
25406
25426
  return __async(this, null, function* () {
25407
25427
  let structuredInstances = yield this.detected_conventions.forEach((instance) => __async(this, null, function* () {
25408
25428
  let currentConvention = yield this.conventions.find((c) => c.schema.$id == instance.convention_entity.attributes.external_uri);
25429
+ if (!currentConvention) {
25430
+ throw new Error(`Couldn't find a convention matching URI ${instance.convention_entity.attributes.external_uri}
25431
+ available ones are:
25432
+ ${this.conventions.map((d) => d.schema.$id).join("\n")}`);
25433
+ }
25434
+ ;
25409
25435
  this.instances.push(
25410
25436
  utils.arrayToStructuredConvention(
25411
25437
  {
@@ -10539,6 +10539,7 @@ var require_convention_builder = __commonJS({
10539
10539
  this.trivial = trivial;
10540
10540
  this.baseSchemataFolder = baseSchemataFolder;
10541
10541
  this.requiredFields = Array.isArray(requiredFields) ? new Set(requiredFields) : /* @__PURE__ */ new Set([]);
10542
+ this.gitlabProjectId = gitlabProjectId;
10542
10543
  let validBaseSchemaPattern = typeAndBundle.match(/^[a-z_]*--[a-z_]*$/) ? typeAndBundle.match(/^[a-z_]*--[a-z_]*$/).index == 0 : false;
10543
10544
  if (!validBaseSchemaPattern) {
10544
10545
  throw new Error(`No schema for ${typeAndBundle} was found, as wanted by ${name}. This parameter should be a type--bundle pair, as farmOS mandates (examples are "log--lab_test" and "asset--land").`);
@@ -11062,7 +11063,8 @@ var require_convention_builder = __commonJS({
11062
11063
  let containerSchema = this.overlays[containerEntity].schema;
11063
11064
  let relationshipAttributes = Object.keys(containerSchema.properties.relationships.properties);
11064
11065
  if (!relationshipAttributes.includes(relationName)) {
11065
- 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(", ")}.`);
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(", ")}.
11067
+ Schema read from ${this.baseSchemataFolder}`);
11066
11068
  }
11067
11069
  ;
11068
11070
  this.relationships.push({ containerEntity, relationName, mentionedEntity, required });
@@ -11472,9 +11474,9 @@ import TabItem from '@theme/TabItem';
11472
11474
  typeAndBundle: target,
11473
11475
  attributeOverlayName: this.overlayName,
11474
11476
  baseSchemataFolder: this.baseSchemataFolder,
11475
- gitlabProjectId: this.gitlabProjectId
11477
+ gitlabProjectId
11476
11478
  });
11477
- currentOverlay.gitlabProjectId = this.gitlabProjectId;
11479
+ currentOverlay.gitlabProjectId = gitlabProjectId;
11478
11480
  this.overlays.push(currentOverlay);
11479
11481
  });
11480
11482
  }
@@ -25349,9 +25351,17 @@ var require_array_examples_preparator = __commonJS({
25349
25351
  var utils = require_schema_utilities();
25350
25352
  var axios = require_axios();
25351
25353
  var _ArrayDataOrganizer = class _ArrayDataOrganizer {
25352
- constructor({ exampleArray }) {
25354
+ constructor({
25355
+ exampleArray,
25356
+ storageFolder = `${__dirname}/../../../../output/collection/overlays`,
25357
+ baseSchemataFolder = `${__dirname}/../../../../input/collection`,
25358
+ predefinedConventions
25359
+ }) {
25353
25360
  this.exampleArray = exampleArray;
25354
25361
  this.instances = [];
25362
+ this.storageFolder = storageFolder;
25363
+ this.baseSchemataFolder = baseSchemataFolder;
25364
+ this.predefinedConventions = predefinedConventions;
25355
25365
  }
25356
25366
  /**
25357
25367
  * Will retrieve the data needed and structure the example.
@@ -25383,11 +25393,21 @@ var require_array_examples_preparator = __commonJS({
25383
25393
  return entries;
25384
25394
  });
25385
25395
  let allMentionedConventions = Array.from(new Set(this.exampleArray.filter((d) => d.type == "taxonomy_term--convention").map((d) => d.attributes.external_uri)));
25386
- let conventionSchemataPromises = allMentionedConventions.map((url) => __async(this, null, function* () {
25387
- return yield axios.get(url.replace("schema.json", "object.json")).then((res) => res.data);
25388
- }));
25389
- let conventionObjects = yield Promise.all(conventionSchemataPromises);
25390
- let conventions = conventionObjects.map((d) => new builder.ConventionSchema(d));
25396
+ let conventionObjects;
25397
+ if (!this.predefinedConventions) {
25398
+ let conventionSchemataPromises = allMentionedConventions.map((url) => __async(this, null, function* () {
25399
+ return yield axios.get(url.replace("schema.json", "object.json")).then((res) => res.data);
25400
+ }));
25401
+ conventionObjects = yield Promise.all(conventionSchemataPromises);
25402
+ } else {
25403
+ conventionObjects = this.predefinedConventions;
25404
+ }
25405
+ ;
25406
+ let conventions = conventionObjects.map((d) => {
25407
+ d.baseSchemataFolder = this.baseSchemataFolder;
25408
+ d.storageFolder = this.storageFolder;
25409
+ return new builder.ConventionSchema(d);
25410
+ });
25391
25411
  this.detected_conventions = conventionCarrierEntities;
25392
25412
  this.conventions = conventions;
25393
25413
  });
@@ -25399,6 +25419,12 @@ var require_array_examples_preparator = __commonJS({
25399
25419
  return __async(this, null, function* () {
25400
25420
  let structuredInstances = yield this.detected_conventions.forEach((instance) => __async(this, null, function* () {
25401
25421
  let currentConvention = yield this.conventions.find((c) => c.schema.$id == instance.convention_entity.attributes.external_uri);
25422
+ if (!currentConvention) {
25423
+ throw new Error(`Couldn't find a convention matching URI ${instance.convention_entity.attributes.external_uri}
25424
+ available ones are:
25425
+ ${this.conventions.map((d) => d.schema.$id).join("\n")}`);
25426
+ }
25427
+ ;
25402
25428
  this.instances.push(
25403
25429
  utils.arrayToStructuredConvention(
25404
25430
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "convention_builder",
3
- "version": "1.7.1",
3
+ "version": "1.7.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",