codify-schemas 1.0.40 → 1.0.42

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.
@@ -4,7 +4,7 @@
4
4
  "title": "Validate Response Schema Data",
5
5
  "type": "object",
6
6
  "properties": {
7
- "validationResults": {
7
+ "resourceValidations": {
8
8
  "type": "array",
9
9
  "items": {
10
10
  "type": "object",
@@ -15,15 +15,23 @@
15
15
  "resourceName": {
16
16
  "type": "string"
17
17
  },
18
- "isValid": {
19
- "type": "boolean"
20
- },
21
- "errors": {
18
+ "schemaValidationErrors": {
22
19
  "type": "array",
23
- "description": "Any errors in validation"
20
+ "description": "Schema validation errors. Right now only ajv schemas are supported",
21
+ "items": {
22
+ "type": "object"
23
+ }
24
+ },
25
+ "customValidationErrorMessage": {
26
+ "type": "string",
27
+ "description": "Custom plugin validation errors. These are a string that should be displayed to the user"
28
+ },
29
+ "isValid": {
30
+ "type": "boolean",
31
+ "description": "Indicates if the resources are valid. True if no errors, false if there are"
24
32
  }
25
33
  },
26
- "required": ["resourceType", "isValid"]
34
+ "required": ["resourceType", "isValid", "schemaValidationErrors"]
27
35
  }
28
36
  }
29
37
  },
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import { SpawnOptions } from "node:child_process";
3
+ import { ErrorObject } from "ajv";
3
4
  export interface StringIndexedObject {
4
5
  [x: string]: unknown;
5
6
  }
@@ -28,11 +29,12 @@ export interface ValidateRequestData {
28
29
  configs: ResourceConfig[];
29
30
  }
30
31
  export interface ValidateResponseData {
31
- validationResults: Array<{
32
+ resourceValidations: Array<{
32
33
  resourceType: string;
33
34
  resourceName?: string;
35
+ schemaValidationErrors: ErrorObject[];
36
+ customValidationErrorMessage?: string;
34
37
  isValid: boolean;
35
- errors?: unknown[] | null;
36
38
  }>;
37
39
  }
38
40
  export interface PlanRequestData extends ResourceConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAuBD,MAAM,CAAN,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,kCAAa,CAAA;AACf,CAAC,EANW,iBAAiB,KAAjB,iBAAiB,QAM5B;AAED,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAmDD,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,8BAAe,CAAA;AACjB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAwBD,MAAM,CAAN,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,kCAAa,CAAA;AACf,CAAC,EANW,iBAAiB,KAAjB,iBAAiB,QAM5B;AAED,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAmDD,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,8BAAe,CAAA;AACjB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-schemas",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -59,11 +59,13 @@ describe("Config file schema tests", () => {
59
59
  "homebrew"
60
60
  ])).to.be.false;
61
61
 
62
- expect(validator([
62
+ validator([
63
63
  {
64
64
  "type": "resource1"
65
65
  },
66
66
  {}
67
- ])).to.be.false;
67
+ ])
68
+
69
+ console.log(validator.errors)
68
70
  })
69
71
  })
@@ -4,7 +4,7 @@
4
4
  "title": "Validate Response Schema Data",
5
5
  "type": "object",
6
6
  "properties": {
7
- "validationResults": {
7
+ "resourceValidations": {
8
8
  "type": "array",
9
9
  "items": {
10
10
  "type": "object",
@@ -15,15 +15,23 @@
15
15
  "resourceName": {
16
16
  "type": "string"
17
17
  },
18
- "isValid": {
19
- "type": "boolean"
20
- },
21
- "errors": {
18
+ "schemaValidationErrors": {
22
19
  "type": "array",
23
- "description": "Any errors in validation"
20
+ "description": "Schema validation errors. Right now only ajv schemas are supported",
21
+ "items": {
22
+ "type": "object"
23
+ }
24
+ },
25
+ "customValidationErrorMessage": {
26
+ "type": "string",
27
+ "description": "Custom plugin validation errors. These are a string that should be displayed to the user"
28
+ },
29
+ "isValid": {
30
+ "type": "boolean",
31
+ "description": "Indicates if the resources are valid. True if no errors, false if there are"
24
32
  }
25
33
  },
26
- "required": ["resourceType", "isValid"]
34
+ "required": ["resourceType", "isValid", "schemaValidationErrors"]
27
35
  }
28
36
  }
29
37
  },
@@ -17,9 +17,24 @@ describe('Plan response data schema', () => {
17
17
  it("validates correct config", () => {
18
18
  const validate = ajv.compile(schema);
19
19
  expect(validate({
20
- validationResults: [
21
- { resourceType: 'abc', isValid: true },
22
- { resourceType: 'abc', resourceName: 'def', isValid: false, errors: ["error1", "error2"] },
20
+ resourceValidations: [
21
+ {
22
+ resourceType: 'abc',
23
+ schemaValidationErrors: [],
24
+ isValid: true
25
+ },
26
+ {
27
+ resourceType: 'abc',
28
+ resourceName: 'def',
29
+ schemaValidationErrors: [
30
+ {
31
+ schemaPath: '/0',
32
+ instancePath: '/0'
33
+ }
34
+ ],
35
+ customValidationErrorMessage: "this is also an error message",
36
+ isValid: false,
37
+ },
23
38
  ]
24
39
  } as ValidateResponseData)).to.be.true;
25
40
  })
@@ -27,7 +42,7 @@ describe('Plan response data schema', () => {
27
42
  it ("validates incorrect config", () => {
28
43
  const validate = ajv.compile(schema);
29
44
  expect(validate({
30
- validationResults: [
45
+ resourceValidations: [
31
46
  { resourceName: 'abc', isValid: true },
32
47
  ]
33
48
  } as ValidateResponseData)).to.be.false;
@@ -1,4 +1,5 @@
1
- import {SpawnOptions} from "node:child_process";
1
+ import { SpawnOptions } from "node:child_process";
2
+ import { ErrorObject } from "ajv";
2
3
 
3
4
  export interface StringIndexedObject {
4
5
  [x: string]: unknown;
@@ -35,11 +36,12 @@ export interface ValidateRequestData {
35
36
  }
36
37
 
37
38
  export interface ValidateResponseData {
38
- validationResults: Array<{
39
+ resourceValidations: Array<{
39
40
  resourceType: string;
40
41
  resourceName?: string;
42
+ schemaValidationErrors: ErrorObject[];
43
+ customValidationErrorMessage?: string;
41
44
  isValid: boolean;
42
- errors?: unknown[] | null;
43
45
  }>;
44
46
  }
45
47