Skip to content

Commit c46aa9b

Browse files
committed
feat: Add apply notes and improved error response data schemas
1 parent 31cf7bf commit c46aa9b

6 files changed

Lines changed: 46 additions & 5 deletions

File tree

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.1.0-beta6",
3+
"version": "1.1.0-beta.10",
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/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/types/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ export enum MessageStatus {
3333
ERROR = 'error',
3434
}
3535

36+
export interface PluginErrorData {
37+
errorType: string;
38+
message: string;
39+
data?: unknown;
40+
}
41+
3642
export interface IpcMessage {
3743
cmd: string;
3844
status?: MessageStatus;
@@ -106,6 +112,7 @@ export interface PlanResponseData {
106112
}>
107113
}
108114

115+
109116
export interface GetResourceInfoRequestData {
110117
type: string;
111118
}
@@ -228,6 +235,11 @@ export interface SetVerbosityRequestData {
228235

229236
export interface EmptyResponseData {}
230237

238+
export interface ApplyNoteRequestData {
239+
message: string;
240+
resourceType?: string;
241+
}
242+
231243
export enum SpawnStatus {
232244
SUCCESS = 'success',
233245
ERROR = 'error',

0 commit comments

Comments
 (0)