Skip to content

Commit cb0dce6

Browse files
committed
feat: Removed additionalProperties: false (which break backwards compat). Switched sudo request to general request for running commands on the base CLI.
1 parent 2618f34 commit cb0dce6

18 files changed

+63
-32
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codify-schemas",
3-
"version": "1.0.83",
3+
"version": "1.0.86-beta1",
44
"description": "",
55
"type": "module",
66
"main": "dist/index.js",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import ValidateRequestDataSchema from './messages/validate-request-data-schema.j
1818
import ValidateResponseDataSchema from './messages/validate-response-data-schema.json' with {type: 'json'}
1919
import InitializeRequestDataSchema from './messages/initialize-request-data-schema.json' with {type: 'json'}
2020
import InitializeResponseDataSchema from './messages/initialize-response-data-schema.json' with {type: 'json'}
21-
import SudoRequestDataSchema from './messages/sudo-request-data-schema.json' with {type: 'json'};
22-
import SudoRequestResponseDataSchema from './messages/sudo-response-data-schema.json' with {type: 'json'};
21+
import SudoRequestDataSchema from './messages/command-request-data-schema.json' with {type: 'json'};
22+
import SudoRequestResponseDataSchema from './messages/command-response-data-schema.json' with {type: 'json'};
2323
import PressKeyToContinueRequestDataSchema from './messages/press-key-to-continue-request-data-schema.json' with {type: 'json'};
2424
import PressKeyToContinueResponseDataSchema from './messages/press-key-to-continue-response-data-schema.json' with {type: 'json'};
2525

src/messages/apply-request-data-schema.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@
8282
"required": ["operation", "resourceType", "parameters", "isStateful"]
8383
}
8484
},
85-
"required": ["plan"],
86-
"additionalProperties": false
85+
"required": ["plan"]
8786
}
8887
]
8988
}

src/messages/sudo-request-data-schema.json renamed to src/messages/command-request-data-schema.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema",
33
"$id": "https://www.codifycli.com/sudo-request.json",
4-
"title": "Sudo request",
5-
"description": "Request sudo from the core CLI",
4+
"title": "Command request",
5+
"description": "Request the core CLI to perform a command. This is required for sudo and interactive",
66
"type": "object",
77
"properties": {
88
"command": {
99
"type": "string",
1010
"description": "The command that is requesting sudo"
1111
},
12+
"type": {
13+
"enum": ["sudo", "interactive"],
14+
"description": "The request type. Right now only sudo and interactive are supported"
15+
},
1216
"options": {
1317
"type": "object",
1418
"description": "The options for codifySpawn that is needed to run the command",
@@ -25,6 +29,6 @@
2529
"additionalProperties": true
2630
}
2731
},
28-
"required": ["command"],
32+
"required": ["command", "type"],
2933
"additionalProperties": false
3034
}

src/messages/sudo-request-data-schema.test.ts renamed to src/messages/command-request-data-schema.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import schema from './sudo-request-data-schema.json';
1+
import schema from './command-request-data-schema.json';
22
import {describe, expect, it} from 'vitest'
33
import Ajv from 'ajv'
44

@@ -14,14 +14,16 @@ describe('Get resources response data schema', () => {
1414
it("Passes a command in the body", () => {
1515
const validate = ajv.compile(schema);
1616
expect(validate({
17-
command: 'abc def'
17+
command: 'abc def',
18+
type: 'sudo'
1819
})).to.be.true;
1920
})
2021

2122
it("Allows options to be set for the command", () => {
2223
const validate = ajv.compile(schema);
2324
expect(validate({
2425
command: 'abc def',
26+
type: 'interactive',
2527
options: {
2628
cwd: '.',
2729
}
@@ -32,6 +34,7 @@ describe('Get resources response data schema', () => {
3234
const validate = ajv.compile(schema);
3335
expect(validate({
3436
command: 'abc def',
37+
type: 'sudo',
3538
options: {
3639
cwd: '.',
3740
requiresRoot: true,
@@ -44,6 +47,7 @@ describe('Get resources response data schema', () => {
4447
const validate = ajv.compile(schema);
4548
expect(validate({
4649
command: 'abc def',
50+
type: 'interactive',
4751
options: {
4852
cwd: '.',
4953
},

src/messages/sudo-response-data-schema.json renamed to src/messages/command-response-data-schema.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
"$schema": "http://json-schema.org/draft-07/schema",
33
"$id": "https://www.codifycli.com/sudo-request-response.json",
44
"title": "Sudo request response",
5-
"description": "Response for a sudo request",
5+
"description": "Response for a request to run a command on the base CLI (sudo, interactive, etc)",
66
"type": "object",
77
"properties": {
88
"status": {
99
"enum": ["success", "error"],
1010
"description": "Reports if the operation was successful"
1111
},
12+
"exitCode": {
13+
"type": "integer",
14+
"description": "The exit code of running the command"
15+
},
1216
"data": {
1317
"type": "string",
1418
"description": "Data returned by the operation"
1519
}
1620
},
17-
"required": ["status", "data"],
18-
"additionalProperties": false
21+
"required": ["status", "exitCode", "data"]
1922
}

src/messages/sudo-response-data-schema.test.ts renamed to src/messages/command-response-data-schema.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import schema from './sudo-response-data-schema.json';
1+
import schema from './command-response-data-schema.json';
22
import {describe, expect, it} from 'vitest'
33
import Ajv from 'ajv'
44

@@ -15,6 +15,7 @@ describe('Get resources response data schema', () => {
1515
const validate = ajv.compile(schema);
1616
expect(validate({
1717
status: 'success',
18+
exitCode: 0,
1819
data: 'sudo: was a success'
1920
})).to.be.true;
2021
})
@@ -23,6 +24,7 @@ describe('Get resources response data schema', () => {
2324
const validate = ajv.compile(schema);
2425
expect(validate({
2526
status: 'error',
27+
exitCode: 100,
2628
data: 'sudo: failed'
2729
})).to.be.true;
2830
})

src/messages/error-response-data-schema.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@
99
"type": "string"
1010
}
1111
},
12-
"required": ["reason"],
13-
"additionalProperties": false
12+
"required": ["reason"]
1413
}

src/messages/get-resource-info-response-data-schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
"type": "string"
2323
}
2424
},
25+
"operatingSystems": {
26+
"type": "array",
27+
"items": {
28+
"enum": ["Darwin", "Linux", "Windows_NT"]
29+
}
30+
},
2531
"import": {
2632
"type": "object",
2733
"properties": {

src/messages/initialize-request-data-schema.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010
"default": 0,
1111
"description": "Initializes the plugin to return logs at a specified verbosity level with 0 being the lowest"
1212
}
13-
},
14-
"additionalProperties": false
13+
}
1514
}

0 commit comments

Comments
 (0)