@extrahorizon/exh-cli 1.6.1-feat-42-c1c6f34 → 1.7.0-dev-48-62caf3f

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Extra Horizon CLI changelog
2
2
 
3
+ ### v1.7.0
4
+
5
+ ### v1.6.1
6
+ * `exh data schemas sync` no longer logs the full schema definition json
7
+ * Fixed `exh data schemas sync` not being able to traverse an object definition with only `additionalProperties` set
8
+
3
9
  ### v1.6.0
4
10
  * Fixed some security vulnerabilities in the dependencies (Thanks @tran-simon)
5
11
  * Removed the update notifier. The version of the package we used had security vulnerabilities and we're unable to migrate to the latest version right now. We'll look into this again in the future.
@@ -111,7 +111,7 @@ _SchemaVerify_instances = new WeakSet(), _SchemaVerify_verifyMetaSchema = functi
111
111
  if (!this.ajv.validateSchema(tmpSchema)) {
112
112
  return { ok: false, errors: transformAjvErrors('', this.ajv.errors) };
113
113
  }
114
- const errors = getIdInObjectArrayErrors(this.schema.properties);
114
+ const errors = getIdInObjectArrayErrors(this.schema);
115
115
  if (errors.length > 0) {
116
116
  return { ok: false, errors: errors.map(path => `The following id property is not allowed: ${path}`) };
117
117
  }
@@ -179,26 +179,29 @@ _SchemaVerify_instances = new WeakSet(), _SchemaVerify_verifyMetaSchema = functi
179
179
  }
180
180
  return { ok, errors };
181
181
  };
182
- function getIdInObjectArrayErrors(properties, path = []) {
182
+ function getIdInObjectArrayErrors(configuration, pathPrefix = '') {
183
+ if (!configuration) {
184
+ return [];
185
+ }
183
186
  const pathsWithIdInArray = [];
184
- let name;
185
- let value;
186
- for ([name, value] of Object.entries(properties)) {
187
- while (value.type === 'array' && value.items.type === 'array') {
188
- value = value.items;
189
- name = `${name}.items`;
190
- }
191
- if (value.type === 'array' && value.items.type === 'object') {
192
- if ('id' in value.items.properties) {
193
- pathsWithIdInArray.push([...path, `${name}.items.properties`, 'id'].join('.'));
194
- }
195
- if (value.items.properties) {
196
- pathsWithIdInArray.push(...getIdInObjectArrayErrors(value.items.properties, [...path, `${name}.items.properties`]));
187
+ if (configuration.type === 'object' || isSchemaConfiguration(configuration)) {
188
+ if (configuration.properties) {
189
+ for (const [name, value] of Object.entries(configuration.properties)) {
190
+ pathsWithIdInArray.push(...getIdInObjectArrayErrors(value, `${pathPrefix}properties.${name}.`));
197
191
  }
198
192
  }
199
- if (value.type === 'object' && value.properties) {
200
- pathsWithIdInArray.push(...getIdInObjectArrayErrors(value.properties, [...path, `${name}.properties`]));
193
+ if (configuration.additionalProperties) {
194
+ pathsWithIdInArray.push(...getIdInObjectArrayErrors(configuration.additionalProperties, `${pathPrefix}additionalProperties.`));
201
195
  }
202
196
  }
197
+ if (configuration.type === 'array') {
198
+ if (configuration.items.type === 'object' && configuration.items.properties?.id) {
199
+ pathsWithIdInArray.push(`${pathPrefix}items.properties.id`);
200
+ }
201
+ pathsWithIdInArray.push(...getIdInObjectArrayErrors(configuration.items, `${pathPrefix}items.`));
202
+ }
203
203
  return pathsWithIdInArray;
204
204
  }
205
+ function isSchemaConfiguration(configuration) {
206
+ return configuration && configuration.properties;
207
+ }
@@ -57,7 +57,6 @@ _SyncSchema_instances = new WeakSet(), _SyncSchema_syncRootAttributes = async fu
57
57
  await schemaRepository.updateSchema(this.sdk, this.cloudSchema.id, diff);
58
58
  }
59
59
  }, _SyncSchema_syncProperties = async function _SyncSchema_syncProperties() {
60
- console.log(JSON.stringify({ local: this.localSchema, cloud: this.cloudSchema }, null, 2));
61
60
  const propertiesDiff = compareSchemaKey(this.localSchema, this.cloudSchema, 'properties');
62
61
  if (this.dry) {
63
62
  reportSchemaChanges(`Schema ${this.cloudSchema.name} - Properties`, propertiesDiff);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.6.1-feat-42-c1c6f34",
3
+ "version": "1.7.0-dev-48-62caf3f",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",