codify-schemas 1.0.42 → 1.0.44

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.
@@ -2,5 +2,22 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://www.codifycli.com/plan-request-data-schema.json",
4
4
  "title": "Plan Request Schema Data",
5
- "$ref": "resource-schema.json"
5
+ "type": "object",
6
+ "properties": {
7
+ "desired": {
8
+ "$ref": "resource-schema.json"
9
+ },
10
+ "state": {
11
+ "$ref": "resource-schema.json"
12
+ },
13
+ "isStateful": {
14
+ "type": "boolean",
15
+ "description": "If the plan is stateful"
16
+ }
17
+ },
18
+ "additionalProperties": false,
19
+ "anyOf": [
20
+ { "required": ["desired", "isStateful"] },
21
+ { "required": ["state", "isStateful"] }
22
+ ]
6
23
  }
@@ -37,7 +37,10 @@ export interface ValidateResponseData {
37
37
  isValid: boolean;
38
38
  }>;
39
39
  }
40
- export interface PlanRequestData extends ResourceConfig {
40
+ export interface PlanRequestData {
41
+ desired: ResourceConfig | undefined;
42
+ state: ResourceConfig | undefined;
43
+ isStateful: boolean;
41
44
  }
42
45
  export declare enum ResourceOperation {
43
46
  CREATE = "create",
@@ -1 +1 @@
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"}
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;AA4BD,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.42",
3
+ "version": "1.0.44",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -2,5 +2,22 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://www.codifycli.com/plan-request-data-schema.json",
4
4
  "title": "Plan Request Schema Data",
5
- "$ref": "resource-schema.json"
5
+ "type": "object",
6
+ "properties": {
7
+ "desired": {
8
+ "$ref": "resource-schema.json"
9
+ },
10
+ "state": {
11
+ "$ref": "resource-schema.json"
12
+ },
13
+ "isStateful": {
14
+ "type": "boolean",
15
+ "description": "If the plan is stateful"
16
+ }
17
+ },
18
+ "additionalProperties": false,
19
+ "anyOf": [
20
+ { "required": ["desired", "isStateful"] },
21
+ { "required": ["state", "isStateful"] }
22
+ ]
6
23
  }
@@ -5,6 +5,7 @@ import Ajv2020 from 'ajv/dist/2020.js'
5
5
 
6
6
  const ajv = new Ajv2020.default({
7
7
  strict: true,
8
+ strictRequired: false,
8
9
  })
9
10
  ajv.addSchema(resourceSchema);
10
11
 
@@ -13,21 +14,55 @@ describe('Plan request data schema', () => {
13
14
  ajv.compile(schema);
14
15
  })
15
16
 
16
- it("requires a type field to be specified", () => {
17
+ it("It accepts either state, desired or both", () => {
17
18
  const validate = ajv.compile(schema);
18
- expect(validate({ type: "type" })).to.be.true;
19
+ expect(validate({
20
+ desired: {
21
+ type: "type"
22
+ },
23
+ isStateful: false
24
+ })).to.be.true;
25
+ expect(validate({
26
+ state: {
27
+ type: "type"
28
+ },
29
+ isStateful: false
30
+ })).to.be.true;
31
+ expect(validate({
32
+ desired: {
33
+ type: "type"
34
+ },
35
+ state: {
36
+ type: "type"
37
+ },
38
+ isStateful: false
39
+ })).to.be.true;
19
40
  expect(validate({})).to.be.false;
20
41
  })
21
42
 
22
43
  it ("name and type are alpha-numeric and follow variable naming conventions", () => {
23
44
  const validate = ajv.compile(schema);
24
- expect(validate({ type: "a234abcDEF_-"})).to.be.true;
25
- expect(validate({ type: "234"})).to.be.false;
26
- expect(validate({ type: "ABCDEF$"})).to.be.false;
45
+ expect(validate({
46
+ desired: { type: "a234abcDEF_-" },
47
+ isStateful: false
48
+ })).to.be.true;
49
+ expect(validate({
50
+ desired: { type: "234" },
51
+ isStateful: false
52
+ })).to.be.false;
53
+ expect(validate({
54
+ desired: { type: "ABCDEF$" },
55
+ isStateful: false
56
+ })).to.be.false;
27
57
 
28
- expect(validate({ type: "type", name: "a234abcDEF_-"})).to.be.true;
29
- expect(validate({ type: "type", name: "234"})).to.be.false;
30
- expect(validate({ type: "type", name: "ABCDEF$"})).to.be.false;
58
+ expect(validate({
59
+ desired: { type: "type", name: "a234abcDEF_-" },
60
+ isStateful: false
61
+ })).to.be.true;
62
+ expect(validate({
63
+ desired: { type: "type", name: "ABCDEF$" },
64
+ isStateful: false
65
+ })).to.be.false;
31
66
  });
32
67
 
33
68
  })
@@ -45,7 +45,11 @@ export interface ValidateResponseData {
45
45
  }>;
46
46
  }
47
47
 
48
- export interface PlanRequestData extends ResourceConfig {}
48
+ export interface PlanRequestData {
49
+ desired: ResourceConfig | undefined
50
+ state: ResourceConfig | undefined
51
+ isStateful: boolean
52
+ }
49
53
 
50
54
  export enum ResourceOperation {
51
55
  CREATE = "create",