codify-schemas 1.0.30 → 1.0.32

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.
@@ -49,12 +49,16 @@
49
49
  },
50
50
  "newValue": {
51
51
  "description": "The new value"
52
+ },
53
+ "previousValue": {
54
+ "description": "The new value"
52
55
  }
53
56
  },
54
57
  "required": [
55
58
  "name",
56
59
  "operation",
57
- "newValue"
60
+ "newValue",
61
+ "previousValue"
58
62
  ]
59
63
  }
60
64
  }
@@ -4,14 +4,28 @@
4
4
  "title": "Validate Response Schema Data",
5
5
  "type": "object",
6
6
  "properties": {
7
- "isValid": {
8
- "type": "boolean"
9
- },
10
- "errors": {
7
+ "validationResults": {
11
8
  "type": "array",
12
- "description": "Any errors in validation"
9
+ "items": {
10
+ "type": "object",
11
+ "properties": {
12
+ "resourceType": {
13
+ "type": "string"
14
+ },
15
+ "resourceName": {
16
+ "type": "string"
17
+ },
18
+ "isValid": {
19
+ "type": "boolean"
20
+ },
21
+ "errors": {
22
+ "type": "array",
23
+ "description": "Any errors in validation"
24
+ }
25
+ },
26
+ "required": ["resourceType", "isValid"]
27
+ }
13
28
  }
14
29
  },
15
- "required": ["isValid"],
16
30
  "additionalProperties": false
17
31
  }
@@ -1,4 +1,7 @@
1
- export interface Config {
1
+ export interface StringIndexedObject {
2
+ [x: string]: unknown;
3
+ }
4
+ export interface Config extends StringIndexedObject {
2
5
  type: string;
3
6
  }
4
7
  export interface ProjectConfig extends Config {
@@ -23,8 +26,12 @@ export interface ValidateRequestData {
23
26
  configs: ResourceConfig[];
24
27
  }
25
28
  export interface ValidateResponseData {
26
- isValid: boolean;
27
- errors: unknown[] | null;
29
+ validationResults: Array<{
30
+ resourceType: string;
31
+ resourceName?: string;
32
+ isValid: boolean;
33
+ errors?: unknown[] | null;
34
+ }>;
28
35
  }
29
36
  export interface PlanRequestData extends ResourceConfig {
30
37
  }
@@ -63,6 +70,7 @@ export interface ApplyRequestData {
63
70
  name: string;
64
71
  operation: ParameterOperation;
65
72
  newValue: unknown | null;
73
+ previousValue: unknown | null;
66
74
  }>;
67
75
  };
68
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAeA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAmBD,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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAmBA,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-schemas",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -49,12 +49,16 @@
49
49
  },
50
50
  "newValue": {
51
51
  "description": "The new value"
52
+ },
53
+ "previousValue": {
54
+ "description": "The new value"
52
55
  }
53
56
  },
54
57
  "required": [
55
58
  "name",
56
59
  "operation",
57
- "newValue"
60
+ "newValue",
61
+ "previousValue"
58
62
  ]
59
63
  }
60
64
  }
@@ -32,7 +32,24 @@ describe('Apply request data schema', () => {
32
32
  parameters: [{
33
33
  name: 'parameter1',
34
34
  operation: ParameterOperation.ADD,
35
- newValue: 'abc'
35
+ newValue: 'abc',
36
+ previousValue: null,
37
+ }]
38
+ }
39
+ } as ApplyRequestData)).to.be.true;
40
+ })
41
+
42
+ it("validates correct empty config (plan)", () => {
43
+ const validate = ajv.compile(schema);
44
+ expect(validate({
45
+ plan: {
46
+ operation: ResourceOperation.CREATE,
47
+ resourceType: 'type1',
48
+ parameters: [{
49
+ name: 'parameter1',
50
+ operation: ParameterOperation.NOOP,
51
+ newValue: null,
52
+ previousValue: null,
36
53
  }]
37
54
  }
38
55
  } as ApplyRequestData)).to.be.true;
@@ -4,14 +4,28 @@
4
4
  "title": "Validate Response Schema Data",
5
5
  "type": "object",
6
6
  "properties": {
7
- "isValid": {
8
- "type": "boolean"
9
- },
10
- "errors": {
7
+ "validationResults": {
11
8
  "type": "array",
12
- "description": "Any errors in validation"
9
+ "items": {
10
+ "type": "object",
11
+ "properties": {
12
+ "resourceType": {
13
+ "type": "string"
14
+ },
15
+ "resourceName": {
16
+ "type": "string"
17
+ },
18
+ "isValid": {
19
+ "type": "boolean"
20
+ },
21
+ "errors": {
22
+ "type": "array",
23
+ "description": "Any errors in validation"
24
+ }
25
+ },
26
+ "required": ["resourceType", "isValid"]
27
+ }
13
28
  }
14
29
  },
15
- "required": ["isValid"],
16
30
  "additionalProperties": false
17
31
  }
@@ -0,0 +1,36 @@
1
+ import schema from './validate-response-data-schema.json';
2
+ import {describe, expect, it} from 'vitest'
3
+ import Ajv2020 from 'ajv/dist/2020.js'
4
+ import addFormats from 'ajv-formats';
5
+ import {ValidateResponseData} from "../types/index.js";
6
+
7
+ const ajv = new Ajv2020.default({
8
+ strict: true,
9
+ })
10
+ addFormats.default(ajv);
11
+
12
+ describe('Plan response data schema', () => {
13
+ it('compiles', () => {
14
+ ajv.compile(schema);
15
+ })
16
+
17
+ it("validates correct config", () => {
18
+ const validate = ajv.compile(schema);
19
+ expect(validate({
20
+ validationResults: [
21
+ { resourceType: 'abc', isValid: true },
22
+ { resourceType: 'abc', resourceName: 'def', isValid: false, errors: ["error1", "error2"] },
23
+ ]
24
+ } as ValidateResponseData)).to.be.true;
25
+ })
26
+
27
+ it ("validates incorrect config", () => {
28
+ const validate = ajv.compile(schema);
29
+ expect(validate({
30
+ validationResults: [
31
+ { resourceName: 'abc', isValid: true },
32
+ ]
33
+ } as ValidateResponseData)).to.be.false;
34
+ });
35
+
36
+ })
@@ -1,4 +1,8 @@
1
- export interface Config {
1
+ export interface StringIndexedObject {
2
+ [x: string]: unknown;
3
+ }
4
+
5
+ export interface Config extends StringIndexedObject {
2
6
  type: string;
3
7
  }
4
8
 
@@ -29,8 +33,12 @@ export interface ValidateRequestData {
29
33
  }
30
34
 
31
35
  export interface ValidateResponseData {
32
- isValid: boolean;
33
- errors: unknown[] | null;
36
+ validationResults: Array<{
37
+ resourceType: string;
38
+ resourceName?: string;
39
+ isValid: boolean;
40
+ errors?: unknown[] | null;
41
+ }>;
34
42
  }
35
43
 
36
44
  export interface PlanRequestData extends ResourceConfig {}
@@ -73,6 +81,7 @@ export interface ApplyRequestData {
73
81
  name: string;
74
82
  operation: ParameterOperation;
75
83
  newValue: unknown | null;
84
+ previousValue: unknown | null;
76
85
  }>
77
86
  }
78
87
  }