Skip to content

Commit a0400e7

Browse files
committed
feat: Added os and set verbosity
1 parent 8f54a98 commit a0400e7

8 files changed

Lines changed: 66 additions & 3 deletions

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.86-beta5",
3+
"version": "1.0.86-beta8",
44
"description": "",
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
@@ -22,6 +22,7 @@ import CommandRequestDataSchema from './messages/command-request-data-schema.jso
2222
import CommandRequestResponseDataSchema 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'};
25+
import SetVerbosityRequestDataSchema from './messages/set-verbosity-request-data-schema.json' with {type: 'json'};
2526

2627
export {
2728
ConfigFileSchema,
@@ -48,6 +49,7 @@ export {
4849
CommandRequestResponseDataSchema,
4950
PressKeyToContinueRequestDataSchema,
5051
PressKeyToContinueResponseDataSchema,
52+
SetVerbosityRequestDataSchema,
5153
}
5254

5355
export * from './types/index.js';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "https://www.codifycli.com/set-verbosity-request.json",
4+
"title": "Set Verbosity Request",
5+
"description": "Request the plugin to set its verbosity level",
6+
"type": "object",
7+
"properties": {
8+
"verbosityLevel": {
9+
"type": "number",
10+
"description": "The verbosity level to set for the plugin"
11+
}
12+
},
13+
"additionalProperties": false
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import schema from './set-verbosity-request-data-schema.json';
2+
import {describe, expect, it} from 'vitest'
3+
import Ajv from 'ajv'
4+
5+
const ajv = new Ajv({
6+
strict: true,
7+
})
8+
9+
describe('Set Verbosity Request Data Schema', () => {
10+
it('compiles', () => {
11+
ajv.compile(schema);
12+
})
13+
14+
it("Sets a verbosity level", () => {
15+
const validate = ajv.compile(schema);
16+
expect(validate({
17+
verbosityLevel: 2,
18+
})).to.be.true;
19+
})
20+
})

src/resource-schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
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+
},
1219
"name": {
1320
"description": "Optional name. Useful for specifying multiple resources of the same type",
1421
"type": "string",

src/resource-schema.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,12 @@ describe("Resource schema tests", () => {
3636
expect(validate({ type: "type", dependsOn: "item1" })).to.be.false;
3737
expect(validate({ type: "type", dependsOn: [6] })).to.be.false;
3838
})
39+
40+
it("os supports linux, macOS, and windows", () => {
41+
const validate = ajv.compile(schema);
42+
expect(validate({ type: "type", os: ["macOS", "windows", "linux"] })).to.be.true;
43+
expect(validate({ type: "type", os: ["item1", "item1"] })).to.be.false;
44+
expect(validate({ type: "type", os: ["macOS"] })).to.be.true;
45+
expect(validate({ type: "type", os: ["macOS", "macOS"] })).to.be.false;
46+
})
3947
});

src/types/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { SpawnOptions } from "node:child_process";
2-
import { ErrorObject } from "ajv";
1+
import type {SpawnOptions} from "node:child_process";
2+
import type {ErrorObject} from "ajv";
33

44
export interface StringIndexedObject {
55
[x: string]: unknown;
@@ -15,9 +15,16 @@ export interface ProjectConfig extends Config {
1515
description?: string;
1616
}
1717

18+
export enum ResourceOs {
19+
LINUX = 'linux',
20+
MACOS = 'macOS',
21+
WINDOWS = 'windows',
22+
}
23+
1824
export interface ResourceConfig extends Config {
1925
name?: string;
2026
dependsOn?: string[];
27+
os?: Array<ResourceOs>;
2128
}
2229

2330
export enum MessageStatus {
@@ -205,6 +212,10 @@ export interface PressKeyToContinueRequestData {
205212

206213
export interface PressKeyToContinueResponseData {}
207214

215+
export interface SetVerbosityRequestData {
216+
verbosityLevel: number;
217+
}
218+
208219
export enum SpawnStatus {
209220
SUCCESS = 'success',
210221
ERROR = 'error',

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"declaration": true,
1212
"emitDecoratorMetadata": true,
1313
"experimentalDecorators": true,
14+
"verbatimModuleSyntax": true,
1415
"rootDir": "src",
1516
"outDir": "./dist"
1617
},

0 commit comments

Comments
 (0)