codify-schemas 1.0.45 → 1.0.47

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Codify Schemas
2
+
3
+ JSON schemas for config validation for [codify CLI](https://codifycli.com).
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import ConfigFileSchema from './config-file-schema.json';
2
1
  import ProjectSchema from './project-schema.json';
3
2
  import ResourceSchema from './resource-schema.json';
4
3
  import IpcMessageSchema from './ipc-message-schema.json';
5
4
  import ApplyRequestDataSchema from './messages/apply-request-data-schema.json';
6
5
  import ApplyResponseDataSchema from './messages/apply-response-data-schema.json';
7
6
  import ErrorResponseDataSchema from './messages/error-response-data-schema.json';
7
+ import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json';
8
+ import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json';
8
9
  import PlanRequestDataSchema from './messages/plan-request-data-schema.json';
9
10
  import PlanResponseDataSchema from './messages/plan-response-data-schema.json';
10
11
  import ValidateRequestDataSchema from './messages/validate-request-data-schema.json';
@@ -13,6 +14,6 @@ import InitializeRequestDataSchema from './messages/initialize-request-data-sche
13
14
  import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json';
14
15
  import SudoRequestDataSchema from './messages/sudo-request-data-schema.json';
15
16
  import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json';
16
- export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
17
+ export { ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
17
18
  export * from './types/index.js';
18
19
  export * from './messages/commands.js';
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
- import ConfigFileSchema from './config-file-schema.json' assert { type: 'json' };
2
1
  import ProjectSchema from './project-schema.json' assert { type: 'json' };
3
2
  import ResourceSchema from './resource-schema.json' assert { type: 'json' };
4
3
  import IpcMessageSchema from './ipc-message-schema.json' assert { type: 'json' };
5
4
  import ApplyRequestDataSchema from './messages/apply-request-data-schema.json' assert { type: 'json' };
6
5
  import ApplyResponseDataSchema from './messages/apply-response-data-schema.json' assert { type: 'json' };
7
6
  import ErrorResponseDataSchema from './messages/error-response-data-schema.json' assert { type: 'json' };
7
+ import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json' assert { type: 'json' };
8
+ import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json' assert { type: 'json' };
8
9
  import PlanRequestDataSchema from './messages/plan-request-data-schema.json' assert { type: 'json' };
9
10
  import PlanResponseDataSchema from './messages/plan-response-data-schema.json' assert { type: 'json' };
10
11
  import ValidateRequestDataSchema from './messages/validate-request-data-schema.json' assert { type: 'json' };
@@ -13,7 +14,7 @@ import InitializeRequestDataSchema from './messages/initialize-request-data-sche
13
14
  import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json' assert { type: 'json' };
14
15
  import SudoRequestDataSchema from './messages/sudo-request-data-schema.json' assert { type: 'json' };
15
16
  import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json' assert { type: 'json' };
16
- export { ConfigFileSchema, ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
17
+ export { ProjectSchema, ResourceSchema, IpcMessageSchema, ApplyRequestDataSchema, ApplyResponseDataSchema, ErrorResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, PlanRequestDataSchema, PlanResponseDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, SudoRequestDataSchema, SudoRequestResponseDataSchema, };
17
18
  export * from './types/index.js';
18
19
  export * from './messages/commands.js';
19
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,gBAAgB,MAAM,2BAA2B,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC9E,OAAO,aAAa,MAAM,uBAAuB,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACvE,OAAO,cAAc,MAAM,wBAAwB,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACzE,OAAO,gBAAgB,MAAM,2BAA2B,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAC9E,OAAO,sBAAsB,MAAM,2CAA2C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACpG,OAAO,uBAAuB,MAAM,4CAA4C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACtG,OAAO,uBAAuB,MAAM,4CAA4C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACtG,OAAO,qBAAqB,MAAM,0CAA0C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AAClG,OAAO,sBAAsB,MAAM,2CAA2C,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAA;AACpG,OAAO,yBAAyB,MAAM,8CAA8C,CAAC,SAAQ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",
5
+ "type": "object",
6
+ "properties": {
7
+ "type": {
8
+ "type": "string",
9
+ "description": "The id/type of the resource"
10
+ }
11
+ },
12
+ "required": ["type"]
13
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
4
+ "title": "Get Resource Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "plugin": {
8
+ "type": "string",
9
+ "description": "The plugin the resource is from"
10
+ },
11
+ "type": {
12
+ "type": "string",
13
+ "description": "The id/type of the resource"
14
+ },
15
+ "schema": {
16
+ "type": "object",
17
+ "description": "The JSON Schema validation schema for the resource."
18
+ },
19
+ "dependencies": {
20
+ "type": "array",
21
+ "items": {
22
+ "type": "string"
23
+ }
24
+ }
25
+ },
26
+ "required": ["type", "plugin"]
27
+ }
@@ -67,6 +67,15 @@ export interface PlanResponseData {
67
67
  newValue: unknown | null;
68
68
  }>;
69
69
  }
70
+ export interface GetResourceInfoRequestData {
71
+ type: string;
72
+ }
73
+ export interface GetResourceInfoResponseData {
74
+ plugin: string;
75
+ type: string;
76
+ schema?: Record<string, unknown>;
77
+ dependencies?: string[];
78
+ }
70
79
  export interface ApplyRequestData {
71
80
  planId?: string;
72
81
  plan?: {
@@ -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;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"}
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;AA8DD,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.45",
3
+ "version": "1.0.47",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  // @ts-ignore
2
- import ConfigFileSchema from './config-file-schema.json' assert {type: 'json'}
2
+ // import ConfigFileSchema from './config-schema.json' assert {type: 'json'}
3
3
  import ProjectSchema from './project-schema.json' assert {type: 'json'}
4
4
  import ResourceSchema from './resource-schema.json' assert {type: 'json'}
5
5
  import IpcMessageSchema from './ipc-message-schema.json' assert {type: 'json'}
6
6
  import ApplyRequestDataSchema from './messages/apply-request-data-schema.json' assert {type: 'json'}
7
7
  import ApplyResponseDataSchema from './messages/apply-response-data-schema.json' assert {type: 'json'}
8
8
  import ErrorResponseDataSchema from './messages/error-response-data-schema.json' assert {type: 'json'}
9
+ import GetResourceInfoRequestDataSchema from './messages/get-resource-info-request-data-schema.json' assert {type: 'json'}
10
+ import GetResourceInfoResponseDataSchema from './messages/get-resource-info-response-data-schema.json' assert {type: 'json'}
9
11
  import PlanRequestDataSchema from './messages/plan-request-data-schema.json' assert {type: 'json'}
10
12
  import PlanResponseDataSchema from './messages/plan-response-data-schema.json' assert {type: 'json'}
11
13
  import ValidateRequestDataSchema from './messages/validate-request-data-schema.json' assert {type: 'json'}
@@ -16,13 +18,15 @@ import SudoRequestDataSchema from './messages/sudo-request-data-schema.json' ass
16
18
  import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json' assert {type: 'json'};
17
19
 
18
20
  export {
19
- ConfigFileSchema,
21
+ // ConfigFileSchema,
20
22
  ProjectSchema,
21
23
  ResourceSchema,
22
24
  IpcMessageSchema,
23
25
  ApplyRequestDataSchema,
24
26
  ApplyResponseDataSchema,
25
27
  ErrorResponseDataSchema,
28
+ GetResourceInfoRequestDataSchema,
29
+ GetResourceInfoResponseDataSchema,
26
30
  PlanRequestDataSchema,
27
31
  PlanResponseDataSchema,
28
32
  ValidateRequestDataSchema,
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
4
+ "title": "Get Resource Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "type": {
8
+ "type": "string",
9
+ "description": "The id/type of the resource"
10
+ }
11
+ },
12
+ "required": ["type"]
13
+ }
@@ -0,0 +1,26 @@
1
+ import schema from './get-resource-info-request-data-schema.json';
2
+ import { describe, it, expect } from 'vitest'
3
+ import Ajv from 'ajv'
4
+
5
+ const ajv = new Ajv.default({
6
+ strict: true,
7
+ })
8
+
9
+ describe('Get resources response data schema', () => {
10
+ it('compiles', () => {
11
+ ajv.compile(schema);
12
+ })
13
+
14
+ it("Validates a correct response", () => {
15
+ const validate = ajv.compile(schema);
16
+ expect(validate({
17
+ type: 'type',
18
+ })).to.be.true;
19
+ })
20
+
21
+ it("Rejects an invalid response", () => {
22
+ const validate = ajv.compile(schema);
23
+ expect(validate({})).to.be.false;
24
+ })
25
+
26
+ })
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
4
+ "title": "Get Resource Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "plugin": {
8
+ "type": "string",
9
+ "description": "The plugin the resource is from"
10
+ },
11
+ "type": {
12
+ "type": "string",
13
+ "description": "The id/type of the resource"
14
+ },
15
+ "schema": {
16
+ "type": "object",
17
+ "description": "The JSON Schema validation schema for the resource."
18
+ },
19
+ "dependencies": {
20
+ "type": "array",
21
+ "items": {
22
+ "type": "string"
23
+ }
24
+ }
25
+ },
26
+ "required": ["type", "plugin"]
27
+ }
@@ -0,0 +1,126 @@
1
+ import schema from './get-resource-info-response-data-schema.json';
2
+ import { describe, it, expect } from 'vitest'
3
+ import Ajv from 'ajv'
4
+ import {GetResourceInfoResponseData} from "../types";
5
+
6
+ const ajv = new Ajv.default({
7
+ strict: true,
8
+ })
9
+
10
+ describe('Get resources response data schema', () => {
11
+ it('compiles', () => {
12
+ ajv.compile(schema);
13
+ })
14
+
15
+ it("Validates a correct response", () => {
16
+ const validate = ajv.compile(schema);
17
+ expect(validate({
18
+ type: 'type',
19
+ plugin: 'core-plugin',
20
+ schema: {
21
+ "$schema": "http://json-schema.org/draft-07/schema",
22
+ "$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
23
+ "title": "Get Resource Schema",
24
+ "type": "object",
25
+ "properties": {
26
+ "plugin": {
27
+ "type": "string",
28
+ "description": "The plugin the resource is from"
29
+ },
30
+ "type": {
31
+ "type": "string",
32
+ "description": "The id/type of the resource"
33
+ },
34
+ "schema": {
35
+ "type": "object",
36
+ "description": "The JSON Schema validation schema for the resource."
37
+ },
38
+ "dependencies": {
39
+ "type": "array",
40
+ "items": {
41
+ "type": "string"
42
+ }
43
+ }
44
+ },
45
+ dependencies: [
46
+ "typeA",
47
+ "typeB"
48
+ ]
49
+ }
50
+ })).to.be.true;
51
+
52
+ expect(validate({
53
+ type: 'type',
54
+ plugin: 'core-plugin',
55
+ })).to.be.true;
56
+
57
+ const a: GetResourceInfoResponseData = {
58
+ type: 'type',
59
+ plugin: 'core-plugin',
60
+ schema: {
61
+ "$schema": "http://json-schema.org/draft-07/schema",
62
+ "$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
63
+ "title": "Get Resource Schema",
64
+ "type": "object",
65
+ "properties": {
66
+ "plugin": {
67
+ "type": "string",
68
+ "description": "The plugin the resource is from"
69
+ },
70
+ "type": {
71
+ "type": "string",
72
+ "description": "The id/type of the resource"
73
+ },
74
+ "schema": {
75
+ "type": "object",
76
+ "description": "The JSON Schema validation schema for the resource."
77
+ },
78
+ "dependencies": {
79
+ "type": "array",
80
+ "items": {
81
+ "type": "string"
82
+ }
83
+ }
84
+ },
85
+ dependencies: [
86
+ "typeA",
87
+ "typeB"
88
+ ]
89
+ }
90
+ }
91
+ })
92
+
93
+ it("Rejects an invalid response", () => {
94
+ const validate = ajv.compile(schema);
95
+ expect(validate({
96
+ schema: {
97
+ "$schema": "http://json-schema.org/draft-07/schema",
98
+ "$id": "https://www.codifycli.com/get-resource-schema-data-schema.json",
99
+ "title": "Get Resource Schema",
100
+ "type": "object",
101
+ "properties": {
102
+ "plugin": {
103
+ "type": "string",
104
+ "description": "The plugin the resource is from"
105
+ },
106
+ "type": {
107
+ "type": "string",
108
+ "description": "The id/type of the resource"
109
+ },
110
+ "schema": {
111
+ "type": "object",
112
+ "description": "The JSON Schema validation schema for the resource."
113
+ },
114
+ "dependencies": {
115
+ "type": "array",
116
+ "items": {
117
+ "type": "string"
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ })).to.be.false;
124
+ })
125
+
126
+ })
@@ -0,0 +1,83 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://www.codifycli.com/codify-schema.json",
4
+ "title": "JSON schema for Codify configuration files",
5
+ "type": "array",
6
+ "items": {
7
+ "type": "object",
8
+ "properties": {
9
+ "type": {
10
+ "type": "string",
11
+ "description": "Specifies the type of the config block. Ex: project, homebrew",
12
+ "pattern": "^[a-zA-Z][\\w-]+$"
13
+ }
14
+ },
15
+ "required": ["type"],
16
+ "allOf": [
17
+ {
18
+ "if": {
19
+ "properties": {
20
+ "type": { "enum": ["project"] }
21
+ },
22
+ "required": ["type"]
23
+ },
24
+ "then": {
25
+ "description": "Represents a project configuration block\nhttps://docs.codifycli.com/user-guide/codify-json/#project-configs",
26
+ "properties": {
27
+ "type": {},
28
+ "version": {
29
+ "description": "Specifies a CLI version constraint. An error will be throw if the CLI version is outside of the semver range",
30
+ "type": "string",
31
+ "pattern": "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$"
32
+ },
33
+ "plugins": {
34
+ "description": "A list of third party plugins to include.",
35
+ "type": "object",
36
+ "patternProperties": {
37
+ ".*": {
38
+ "type": "string"
39
+ }
40
+ }
41
+ },
42
+ "description": {
43
+ "description": "An optional description of the project. This value is not applied.",
44
+ "type": "string"
45
+ }
46
+ },
47
+ "additionalProperties": false
48
+ }
49
+ },
50
+ {
51
+ "if": {
52
+ "not": {
53
+ "properties": {
54
+ "type": {
55
+ "enum": ["project"]
56
+ }
57
+ }
58
+ },
59
+ "required": ["type"]
60
+ },
61
+ "then": {
62
+ "description": "Represents a resource configuration block\nhttps://docs.codifycli.com/user-guide/codify-json/#resource-configs",
63
+ "properties": {
64
+ "name": {
65
+ "type": "string",
66
+ "pattern": "^[\\w-]+$",
67
+ "description": "Optionally specify a name. Useful for specifying multiple resources of the same type"
68
+ },
69
+ "dependsOn": {
70
+ "type": "array",
71
+ "items": {
72
+ "type": "string"
73
+ },
74
+ "uniqueItems": true,
75
+ "description": "Specify resource dependencies. Must be the type or id of another resource"
76
+ }
77
+ },
78
+ "additionalProperties": true
79
+ }
80
+ }
81
+ ]
82
+ }
83
+ }
@@ -0,0 +1,87 @@
1
+ import schema from './codify-schema.json';
2
+ import { describe, it, expect } from 'vitest'
3
+ import Ajv from 'ajv'
4
+
5
+ const ajv = new Ajv.default({
6
+ strict: true,
7
+ })
8
+
9
+ describe("Config file schema tests", () => {
10
+ it('Compiles', () => {
11
+ ajv.compile(schema);
12
+ })
13
+
14
+ it('And successfully validate blocks with type', () => {
15
+ const validator = ajv.compile(schema);
16
+
17
+ expect(validator([])).to.be.true;
18
+
19
+ expect(validator([
20
+ {
21
+ "type": "resource1",
22
+ },
23
+ {
24
+ "type": "resource2",
25
+ "name": "abc",
26
+ "prop1": {
27
+ "a": "b",
28
+ },
29
+ "prop2": "c"
30
+ }
31
+ ])).to.be.true;
32
+
33
+ expect(validator([
34
+ {
35
+ "type": "resource1",
36
+ "dependsOn": [
37
+ "resource2"
38
+ ]
39
+ }
40
+ ])).to.be.true;
41
+
42
+ expect(validator([
43
+ {
44
+ "type": "project",
45
+ "version": "0.0.1",
46
+ "description": "description",
47
+ }
48
+ ])).to.be.true;
49
+ })
50
+
51
+ it('And errors on improper json', () => {
52
+ const validator = ajv.compile(schema);
53
+
54
+ expect(validator({
55
+ "a": {},
56
+ "b": {},
57
+ })).to.be.false;
58
+
59
+ expect(validator([
60
+ {
61
+ "type": "resource1"
62
+ },
63
+ "homebrew"
64
+ ])).to.be.false;
65
+
66
+ expect(validator([
67
+ {
68
+ "type": "resource1"
69
+ },
70
+ {}
71
+ ])).to.be.false;
72
+
73
+ expect(validator([
74
+ {
75
+ "type": "resource1",
76
+ "dependsOn": {}
77
+ }
78
+ ])).to.be.false;
79
+
80
+ expect(validator([
81
+ {
82
+ "type": "project",
83
+ "additionalProperty": true
84
+ }
85
+ ])).to.be.false;
86
+ })
87
+ })
@@ -1,5 +1,5 @@
1
1
  import { SpawnOptions } from "node:child_process";
2
- import { ErrorObject } from "ajv";
2
+ import {ErrorObject, JSONSchemaType} from "ajv";
3
3
 
4
4
  export interface StringIndexedObject {
5
5
  [x: string]: unknown;
@@ -79,6 +79,17 @@ export interface PlanResponseData {
79
79
  }>
80
80
  }
81
81
 
82
+ export interface GetResourceInfoRequestData {
83
+ type: string;
84
+ }
85
+
86
+ export interface GetResourceInfoResponseData {
87
+ plugin: string;
88
+ type: string;
89
+ schema?: Record<string, unknown>,
90
+ dependencies?: string[],
91
+ }
92
+
82
93
  export interface ApplyRequestData {
83
94
  planId?: string;
84
95
  plan?: {
@@ -1,28 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema",
3
- "$id": "https://www.codifycli.com/get-resources-response-data-schema.json",
4
- "title": "Get Resources Response Schema Data",
5
- "type": "object",
6
- "properties": {
7
- "resources": {
8
- "type": "array",
9
- "items": {
10
- "type": "object",
11
- "properties": {
12
- "type": {
13
- "$ref": "resource-schema.json#/properties/type"
14
- },
15
- "dependencies": {
16
- "type": "array",
17
- "items": {
18
- "type": "string"
19
- }
20
- }
21
- },
22
- "required": ["type"]
23
- }
24
- }
25
- },
26
- "required": ["resources"],
27
- "additionalProperties": false
28
- }
@@ -1,43 +0,0 @@
1
- import schema from './get-resources-response-data-schema.json';
2
- import resourceSchema from '../resource-schema.json'
3
- import { describe, it, expect } from 'vitest'
4
- import Ajv from 'ajv'
5
-
6
- const ajv = new Ajv.default({
7
- strict: true,
8
- })
9
- ajv.addSchema(resourceSchema);
10
-
11
- describe('Get resources response data schema', () => {
12
- it('compiles', () => {
13
- ajv.compile(schema);
14
- })
15
-
16
- it("requires a type field to be specified", () => {
17
- const validate = ajv.compile(schema);
18
- expect(validate({ resources: [
19
- {
20
- type: "typeA",
21
- dependencies: [
22
- "typeB"
23
- ]
24
- },
25
- {
26
- type: "typeB"
27
- }
28
- ]})).to.be.true;
29
-
30
- expect(validate({
31
- resources: [
32
- {
33
- type: "typeA",
34
- dependencies: [
35
- "typeB"
36
- ]
37
- },
38
- {}
39
- ]
40
- })).to.be.false;
41
- })
42
-
43
- })