codify-schemas 1.0.31 → 1.0.33

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,68 +4,78 @@
4
4
  "title": "Apply Request Schema Data",
5
5
  "description": "Apply the previously generated plan. The plan must already be generated in order for apply to work.",
6
6
  "type": "object",
7
- "properties": {
8
- "planId": {
9
- "description": "The plan uuid. This id is used to look up the generated plan on the plugin side.",
10
- "type": "string",
11
- "format": "uuid"
12
- },
13
- "plan": {
14
- "description": "Alternatively, the client can supply a complete plan instead of a planId",
15
- "type": "object",
7
+ "anyOf": [
8
+ {
16
9
  "properties": {
17
- "operation": {
18
- "description": "The plan operation",
10
+ "planId": {
11
+ "description": "The plan uuid. This id is used to look up the generated plan on the plugin side.",
19
12
  "type": "string",
20
- "enum": ["create", "destroy", "modify", "recreate", "noop"]
21
- },
22
- "resourceType": {
23
- "description": "The resource type",
24
- "type": "string"
25
- },
26
- "resourceName": {
27
- "description": "The resource name",
28
- "type": ["string", "null"]
29
- },
30
- "parameters": {
31
- "description": "The properties come from the provided config and is not necessarily every parameter on the ",
32
- "type": "array",
33
- "items": {
34
- "type": "object",
35
- "properties": {
36
- "name": {
37
- "description": "The property name",
38
- "type": "string"
39
- },
40
- "operation": {
41
- "description": "The operation to be performed on the parameter",
42
- "type": "string",
43
- "enum": [
44
- "remove",
45
- "add",
46
- "modify",
47
- "noop"
13
+ "format": "uuid"
14
+ }
15
+ },
16
+ "required": ["planId"],
17
+ "additionalProperties": false
18
+ },
19
+ {
20
+ "properties": {
21
+ "plan": {
22
+ "description": "Alternatively, the client can supply a complete plan instead of a planId",
23
+ "type": "object",
24
+ "properties": {
25
+ "operation": {
26
+ "description": "The plan operation",
27
+ "type": "string",
28
+ "enum": ["create", "destroy", "modify", "recreate", "noop"]
29
+ },
30
+ "resourceType": {
31
+ "description": "The resource type",
32
+ "type": "string"
33
+ },
34
+ "resourceName": {
35
+ "description": "The resource name",
36
+ "type": ["string", "null"]
37
+ },
38
+ "parameters": {
39
+ "description": "The properties come from the provided config and is not necessarily every parameter on the ",
40
+ "type": "array",
41
+ "items": {
42
+ "type": "object",
43
+ "properties": {
44
+ "name": {
45
+ "description": "The property name",
46
+ "type": "string"
47
+ },
48
+ "operation": {
49
+ "description": "The operation to be performed on the parameter",
50
+ "type": "string",
51
+ "enum": [
52
+ "remove",
53
+ "add",
54
+ "modify",
55
+ "noop"
56
+ ]
57
+ },
58
+ "newValue": {
59
+ "description": "The new value"
60
+ },
61
+ "previousValue": {
62
+ "description": "The new value"
63
+ }
64
+ },
65
+ "required": [
66
+ "name",
67
+ "operation",
68
+ "newValue",
69
+ "previousValue"
48
70
  ]
49
- },
50
- "newValue": {
51
- "description": "The new value"
52
- },
53
- "previousValue": {
54
- "description": "The new value"
55
71
  }
56
- },
57
- "required": [
58
- "name",
59
- "operation",
60
- "newValue",
61
- "previousValue"
62
- ]
63
- }
72
+ }
73
+ },
74
+ "required": ["operation", "resourceType", "parameters"]
64
75
  }
65
76
  },
66
- "required": ["operation", "resourceType", "parameters"]
77
+ "required": ["plan"],
78
+ "additionalProperties": false
67
79
  }
68
- },
69
- "required": [],
70
- "additionalProperties": false
80
+ ]
71
81
  }
@@ -25,14 +25,13 @@ export interface IpcMessage {
25
25
  export interface ValidateRequestData {
26
26
  configs: ResourceConfig[];
27
27
  }
28
- export interface ValidationResult {
29
- resourceType: string;
30
- resourceName?: string;
31
- isValid: boolean;
32
- errors?: unknown[] | null;
33
- }
34
28
  export interface ValidateResponseData {
35
- validationResults: Array<ValidationResult>;
29
+ validationResults: Array<{
30
+ resourceType: string;
31
+ resourceName?: string;
32
+ isValid: boolean;
33
+ errors?: unknown[] | null;
34
+ }>;
36
35
  }
37
36
  export interface PlanRequestData extends ResourceConfig {
38
37
  }
@@ -1 +1 @@
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;AAyBD,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.31",
3
+ "version": "1.0.33",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -4,68 +4,78 @@
4
4
  "title": "Apply Request Schema Data",
5
5
  "description": "Apply the previously generated plan. The plan must already be generated in order for apply to work.",
6
6
  "type": "object",
7
- "properties": {
8
- "planId": {
9
- "description": "The plan uuid. This id is used to look up the generated plan on the plugin side.",
10
- "type": "string",
11
- "format": "uuid"
12
- },
13
- "plan": {
14
- "description": "Alternatively, the client can supply a complete plan instead of a planId",
15
- "type": "object",
7
+ "anyOf": [
8
+ {
16
9
  "properties": {
17
- "operation": {
18
- "description": "The plan operation",
10
+ "planId": {
11
+ "description": "The plan uuid. This id is used to look up the generated plan on the plugin side.",
19
12
  "type": "string",
20
- "enum" : ["create", "destroy", "modify", "recreate", "noop"]
21
- },
22
- "resourceType": {
23
- "description": "The resource type",
24
- "type": "string"
25
- },
26
- "resourceName": {
27
- "description": "The resource name",
28
- "type": ["string", "null"]
29
- },
30
- "parameters": {
31
- "description": "The properties come from the provided config and is not necessarily every parameter on the ",
32
- "type": "array",
33
- "items": {
34
- "type": "object",
35
- "properties": {
36
- "name": {
37
- "description": "The property name",
38
- "type": "string"
39
- },
40
- "operation": {
41
- "description": "The operation to be performed on the parameter",
42
- "type": "string",
43
- "enum": [
44
- "remove",
45
- "add",
46
- "modify",
47
- "noop"
13
+ "format": "uuid"
14
+ }
15
+ },
16
+ "required": ["planId"],
17
+ "additionalProperties": false
18
+ },
19
+ {
20
+ "properties": {
21
+ "plan": {
22
+ "description": "Alternatively, the client can supply a complete plan instead of a planId",
23
+ "type": "object",
24
+ "properties": {
25
+ "operation": {
26
+ "description": "The plan operation",
27
+ "type": "string",
28
+ "enum" : ["create", "destroy", "modify", "recreate", "noop"]
29
+ },
30
+ "resourceType": {
31
+ "description": "The resource type",
32
+ "type": "string"
33
+ },
34
+ "resourceName": {
35
+ "description": "The resource name",
36
+ "type": ["string", "null"]
37
+ },
38
+ "parameters": {
39
+ "description": "The properties come from the provided config and is not necessarily every parameter on the ",
40
+ "type": "array",
41
+ "items": {
42
+ "type": "object",
43
+ "properties": {
44
+ "name": {
45
+ "description": "The property name",
46
+ "type": "string"
47
+ },
48
+ "operation": {
49
+ "description": "The operation to be performed on the parameter",
50
+ "type": "string",
51
+ "enum": [
52
+ "remove",
53
+ "add",
54
+ "modify",
55
+ "noop"
56
+ ]
57
+ },
58
+ "newValue": {
59
+ "description": "The new value"
60
+ },
61
+ "previousValue": {
62
+ "description": "The new value"
63
+ }
64
+ },
65
+ "required": [
66
+ "name",
67
+ "operation",
68
+ "newValue",
69
+ "previousValue"
48
70
  ]
49
- },
50
- "newValue": {
51
- "description": "The new value"
52
- },
53
- "previousValue": {
54
- "description": "The new value"
55
71
  }
56
- },
57
- "required": [
58
- "name",
59
- "operation",
60
- "newValue",
61
- "previousValue"
62
- ]
63
- }
72
+ }
73
+ },
74
+ "required": ["operation", "resourceType", "parameters"]
64
75
  }
65
76
  },
66
- "required": ["operation", "resourceType", "parameters"]
77
+ "required": ["plan"],
78
+ "additionalProperties": false
67
79
  }
68
- },
69
- "required": [],
70
- "additionalProperties": false
80
+ ]
71
81
  }
@@ -39,7 +39,7 @@ describe('Apply request data schema', () => {
39
39
  } as ApplyRequestData)).to.be.true;
40
40
  })
41
41
 
42
- it("validates correct empty config (plan)", () => {
42
+ it("validates correct no-op config (plan)", () => {
43
43
  const validate = ajv.compile(schema);
44
44
  expect(validate({
45
45
  plan: {
@@ -54,4 +54,27 @@ describe('Apply request data schema', () => {
54
54
  }
55
55
  } as ApplyRequestData)).to.be.true;
56
56
  })
57
+
58
+ it("validates errors on empty body", () => {
59
+ const validate = ajv.compile(schema);
60
+ expect(validate({
61
+ } as ApplyRequestData)).to.be.false;
62
+ });
63
+
64
+ it("validates errors when both plan and planId are defined", () => {
65
+ const validate = ajv.compile(schema);
66
+ expect(validate({
67
+ planId: 'eb367e53-21a8-4c9e-a38b-c99e7c821344',
68
+ plan: {
69
+ operation: ResourceOperation.CREATE,
70
+ resourceType: 'type1',
71
+ parameters: [{
72
+ name: 'parameter1',
73
+ operation: ParameterOperation.ADD,
74
+ newValue: 'abc',
75
+ previousValue: null,
76
+ }]
77
+ }
78
+ } as ApplyRequestData)).to.be.false;
79
+ });
57
80
  })
@@ -32,15 +32,13 @@ export interface ValidateRequestData {
32
32
  configs: ResourceConfig[];
33
33
  }
34
34
 
35
- export interface ValidationResult {
36
- resourceType: string;
37
- resourceName?: string;
38
- isValid: boolean;
39
- errors?: unknown[] | null;
40
- }
41
-
42
35
  export interface ValidateResponseData {
43
- validationResults: Array<ValidationResult>;
36
+ validationResults: Array<{
37
+ resourceType: string;
38
+ resourceName?: string;
39
+ isValid: boolean;
40
+ errors?: unknown[] | null;
41
+ }>;
44
42
  }
45
43
 
46
44
  export interface PlanRequestData extends ResourceConfig {}