Skip to content

Commit 458fe1f

Browse files
Kevin/v1.2.0 (#16)
* feat: Add defaultConfig and exampleConfigs and distro * feat: Add requireSudoAskpass and minSupportedCliVersion * feat: Add apply notes and improved error response data schemas * chore: bump package version
1 parent 9e8e141 commit 458fe1f

11 files changed

Lines changed: 105 additions & 13 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codifycli/schemas",
3-
"version": "1.0.0",
3+
"version": "1.2.0",
44
"description": "JSON Schemas and types that govern the message format and Codify config formats for Codify",
55
"type": "module",
66
"main": "dist/index.js",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import PressKeyToContinueRequestDataSchema from './messages/press-key-to-continu
2323
import PressKeyToContinueResponseDataSchema from './messages/press-key-to-continue-response-data-schema.json' with {type: 'json'};
2424
import SetVerbosityRequestDataSchema from './messages/set-verbosity-request-data-schema.json' with {type: 'json'};
2525
import EmptyResponseDataSchema from './messages/empty-response-data-schema.json' with {type: 'json'};
26+
import ApplyNoteRequestDataSchema from './messages/apply-note-request-data-schema.json' with {type: 'json'};
2627

2728
export {
2829
ConfigFileSchema,
@@ -50,6 +51,7 @@ export {
5051
PressKeyToContinueResponseDataSchema,
5152
SetVerbosityRequestDataSchema,
5253
EmptyResponseDataSchema,
54+
ApplyNoteRequestDataSchema,
5355
}
5456

5557
export * from './types/index.js';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "https://www.codifycli.com/apply-note-request.json",
4+
"title": "Apply note request",
5+
"description": "Sent by a plugin to leave a post-apply note for the user",
6+
"type": "object",
7+
"properties": {
8+
"message": {
9+
"type": "string",
10+
"maxLength": 500
11+
},
12+
"resourceType": {
13+
"type": "string",
14+
"maxLength": 100
15+
}
16+
},
17+
"required": ["message"],
18+
"additionalProperties": false
19+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
"stdin": {
3333
"type": "boolean",
3434
"description": "Whether or not this command requires stdin"
35+
},
36+
"requiresSudoAskpass": {
37+
"type": "boolean",
38+
"description": "Whether to use SUDO_ASKPASS instead of sudo -S for password delivery"
3539
}
3640
},
3741
"additionalProperties": true

src/messages/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export enum MessageCmd {
55
APPLY = 'apply',
66
COMMAND_REQUEST = 'command_request',
77
PRESS_KEY_TO_CONTINUE_REQUEST = 'press_key_to_continue_request',
8-
CODIFY_CREDENTIALS_REQUEST = 'codify_credentials_request'
8+
CODIFY_CREDENTIALS_REQUEST = 'codify_credentials_request',
9+
APPLY_NOTE_REQUEST = 'apply_note_request',
910
}

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44
"title": "Error Response Schema Data",
55
"type": "object",
66
"properties": {
7-
"reason": {
8-
"description": "A human read-able reason for the error",
7+
"errorType": {
8+
"description": "A string identifier for the error type (e.g. 'apply_validation', 'sudo_error', 'unknown')",
99
"type": "string"
10+
},
11+
"message": {
12+
"description": "A human-readable error message, always present",
13+
"type": "string"
14+
},
15+
"data": {
16+
"description": "Optional structured payload whose shape depends on errorType"
1017
}
1118
},
12-
"required": ["reason"]
19+
"required": ["errorType", "message"]
1320
}

src/messages/error-response-data-schema.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ describe('Apply request data schema', () => {
1717
it("validates an error message", () => {
1818
const validate = ajv.compile(schema);
1919
expect(validate({
20-
reason: "This was an error"
20+
errorType: "unknown",
21+
message: "This was an error"
2122
})).to.be.true;
2223
})
2324
})

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@
7070
},
7171
"allowMultiple": {
7272
"type": "boolean"
73+
},
74+
"defaultConfig": {
75+
"type": "object",
76+
"description": "The default config that should be added. This prefills some parameters for the user to make it easier for them"
77+
},
78+
"exampleConfigs": {
79+
"type": "object",
80+
"description": "Some example configs. This makes it for the user."
7381
}
7482
},
7583
"required": ["type", "plugin"]

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"description": "Initialize the plugin",
66
"type": "object",
77
"properties": {
8+
"minSupportedCliVersion": {
9+
"type": "string"
10+
},
811
"resourceDefinitions": {
912
"type": "array",
1013
"items": {

src/resource-schema.json

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99
"type": "string",
1010
"pattern": "^[a-zA-Z][\\w-]+$"
1111
},
12-
"os": {
13-
"type": "array",
14-
"items": {
15-
"enum": ["linux", "macOS", "windows"]
16-
},
17-
"uniqueItems": true
18-
},
1912
"name": {
2013
"description": "Optional name. Useful for specifying multiple resources of the same type",
2114
"type": "string",
@@ -27,6 +20,40 @@
2720
"type": "string"
2821
},
2922
"uniqueItems": true
23+
},
24+
"os": {
25+
"type": "array",
26+
"items": {
27+
"enum": ["linux", "macOS", "windows"]
28+
},
29+
"uniqueItems": true
30+
},
31+
"distro": {
32+
"type": "array",
33+
"items": {
34+
"enum": [
35+
"debian-based",
36+
"rpm-based",
37+
"arch",
38+
"centos",
39+
"debian",
40+
"fedora",
41+
"rhel",
42+
"ubuntu",
43+
"alpine",
44+
"amzn",
45+
"opensuse",
46+
"sles",
47+
"manjaro",
48+
"linuxmint",
49+
"pop",
50+
"elementary",
51+
"kali",
52+
"gentoo",
53+
"slackware"
54+
]
55+
},
56+
"uniqueItems": true
3057
}
3158
},
3259
"required": ["type"]

0 commit comments

Comments
 (0)