codify-schemas 1.0.37 → 1.0.38

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.
@@ -8,6 +8,21 @@
8
8
  "command": {
9
9
  "type": "string",
10
10
  "description": "The command that is requesting sudo"
11
+ },
12
+ "options": {
13
+ "type": "object",
14
+ "description": "The options for codifySpawn that is needed to run the command",
15
+ "properties": {
16
+ "cwd": {
17
+ "type": "string",
18
+ "description": "Current working directory to run codifySpawn in"
19
+ },
20
+ "argv0": {
21
+ "type": "string",
22
+ "description": "Arguments to pass in"
23
+ }
24
+ },
25
+ "additionalProperties": true
11
26
  }
12
27
  },
13
28
  "required": ["command"],
@@ -4,6 +4,16 @@
4
4
  "title": "Sudo request response",
5
5
  "description": "Response for a sudo request",
6
6
  "type": "object",
7
- "properties": {},
7
+ "properties": {
8
+ "status": {
9
+ "enum": ["success", "error"],
10
+ "description": "Reports if the operation was successful"
11
+ },
12
+ "data": {
13
+ "type": "string",
14
+ "description": "Data returned by the operation"
15
+ }
16
+ },
17
+ "required": ["status", "data"],
8
18
  "additionalProperties": false
9
19
  }
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { SpawnOptions } from "node:child_process";
1
3
  export interface StringIndexedObject {
2
4
  [x: string]: unknown;
3
5
  }
@@ -88,6 +90,15 @@ export interface InitializeResponseData {
88
90
  }
89
91
  export interface SudoRequestData {
90
92
  command: string;
93
+ options: {
94
+ cwd?: string;
95
+ } & Omit<SpawnOptions, 'stdio' | 'shell' | 'detached'>;
96
+ }
97
+ export declare enum SpawnStatus {
98
+ SUCCESS = "success",
99
+ ERROR = "error"
91
100
  }
92
101
  export interface SudoRequestResponseData {
102
+ status: SpawnStatus;
103
+ data: string;
93
104
  }
@@ -18,4 +18,9 @@ export var ParameterOperation;
18
18
  ParameterOperation["MODIFY"] = "modify";
19
19
  ParameterOperation["NOOP"] = "noop";
20
20
  })(ParameterOperation || (ParameterOperation = {}));
21
+ export var SpawnStatus;
22
+ (function (SpawnStatus) {
23
+ SpawnStatus["SUCCESS"] = "success";
24
+ SpawnStatus["ERROR"] = "error";
25
+ })(SpawnStatus || (SpawnStatus = {}));
21
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAuBD,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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAuBD,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.37",
3
+ "version": "1.0.38",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,6 +8,21 @@
8
8
  "command": {
9
9
  "type": "string",
10
10
  "description": "The command that is requesting sudo"
11
+ },
12
+ "options": {
13
+ "type": "object",
14
+ "description": "The options for codifySpawn that is needed to run the command",
15
+ "properties": {
16
+ "cwd": {
17
+ "type": "string",
18
+ "description": "Current working directory to run codifySpawn in"
19
+ },
20
+ "argv0": {
21
+ "type": "string",
22
+ "description": "Arguments to pass in"
23
+ }
24
+ },
25
+ "additionalProperties": true
11
26
  }
12
27
  },
13
28
  "required": ["command"],
@@ -11,11 +11,43 @@ describe('Get resources response data schema', () => {
11
11
  ajv.compile(schema);
12
12
  })
13
13
 
14
- it("requires an empty object", () => {
14
+ it("Passes a command in the body", () => {
15
15
  const validate = ajv.compile(schema);
16
16
  expect(validate({
17
17
  command: 'abc def'
18
18
  })).to.be.true;
19
19
  })
20
20
 
21
+ it("Allows options to be set for the command", () => {
22
+ const validate = ajv.compile(schema);
23
+ expect(validate({
24
+ command: 'abc def',
25
+ options: {
26
+ cwd: '.',
27
+ }
28
+ })).to.be.true;
29
+ })
30
+
31
+ it("Allows additional options to be set for options", () => {
32
+ const validate = ajv.compile(schema);
33
+ expect(validate({
34
+ command: 'abc def',
35
+ options: {
36
+ cwd: '.',
37
+ requiresRoot: true,
38
+ throws: false,
39
+ }
40
+ })).to.be.true;
41
+ })
42
+
43
+ it("Prevent additional options to be set for the top level object", () => {
44
+ const validate = ajv.compile(schema);
45
+ expect(validate({
46
+ command: 'abc def',
47
+ options: {
48
+ cwd: '.',
49
+ },
50
+ additional: {}
51
+ })).to.be.false;
52
+ })
21
53
  })
@@ -4,6 +4,16 @@
4
4
  "title": "Sudo request response",
5
5
  "description": "Response for a sudo request",
6
6
  "type": "object",
7
- "properties": {},
7
+ "properties": {
8
+ "status": {
9
+ "enum": ["success", "error"],
10
+ "description": "Reports if the operation was successful"
11
+ },
12
+ "data": {
13
+ "type": "string",
14
+ "description": "Data returned by the operation"
15
+ }
16
+ },
17
+ "required": ["status", "data"],
8
18
  "additionalProperties": false
9
19
  }
@@ -1,4 +1,4 @@
1
- import schema from './sudo-request-data-schema.json';
1
+ import schema from './sudo-response-data-schema.json';
2
2
  import {describe, expect, it} from 'vitest'
3
3
  import Ajv2020 from 'ajv/dist/2020.js'
4
4
 
@@ -11,11 +11,19 @@ describe('Get resources response data schema', () => {
11
11
  ajv.compile(schema);
12
12
  })
13
13
 
14
- it("requires an empty object", () => {
14
+ it("Validates a successful sudo request response", () => {
15
15
  const validate = ajv.compile(schema);
16
16
  expect(validate({
17
- command: 'abc def'
17
+ status: 'success',
18
+ data: 'sudo: was a success'
18
19
  })).to.be.true;
19
20
  })
20
21
 
22
+ it("Validates a sudo request error response", () => {
23
+ const validate = ajv.compile(schema);
24
+ expect(validate({
25
+ status: 'error',
26
+ data: 'sudo: failed'
27
+ })).to.be.true;
28
+ })
21
29
  })
@@ -1,3 +1,5 @@
1
+ import { SpawnOptions } from "node:child_process";
2
+
1
3
  export interface StringIndexedObject {
2
4
  [x: string]: unknown;
3
5
  }
@@ -102,6 +104,17 @@ export interface InitializeResponseData {
102
104
 
103
105
  export interface SudoRequestData {
104
106
  command: string;
107
+ options: {
108
+ cwd?: string;
109
+ } & Omit<SpawnOptions, 'stdio' | 'shell' | 'detached'>
110
+ }
111
+
112
+ export enum SpawnStatus {
113
+ SUCCESS = 'success',
114
+ ERROR = 'error',
105
115
  }
106
116
 
107
- export interface SudoRequestResponseData {}
117
+ export interface SudoRequestResponseData {
118
+ status: SpawnStatus,
119
+ data: string;
120
+ }