Skip to content

Commit 2349964

Browse files
committed
feat: Added set verbosity command
1 parent 9d9becc commit 2349964

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export * from './plan/change-set.js'
77
export * from './plan/plan.js'
88
export * from './plan/plan-types.js'
99
export * from './plugin/plugin.js'
10+
export * from './pty/background-pty.js';
1011
export * from './pty/index.js'
12+
export * from './pty/seqeuntial-pty.js';
1113
export * from './resource/parsed-resource-settings.js';
1214
export * from './resource/resource.js'
1315
export * from './resource/resource-settings.js'

src/messages/handlers.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,29 @@ describe('Message handler tests', () => {
235235
process.send = undefined;
236236
})
237237

238+
it('handles changing the verbosity level', async () => {
239+
const resource = new TestResource()
240+
const plugin = testPlugin(resource);
241+
const handler = new MessageHandler(plugin);
242+
243+
process.send = (message) => {
244+
expect(message).toMatchObject({
245+
cmd: 'setVerbosityLevel_Response',
246+
status: MessageStatus.SUCCESS,
247+
})
248+
return true;
249+
}
250+
251+
expect(async () => await handler.onMessage({
252+
cmd: 'setVerbosityLevel',
253+
data: {
254+
verbosityLevel: 2,
255+
}
256+
})).rejects.to.not.throw;
257+
258+
process.send = undefined;
259+
})
260+
238261
it('Supports ipc message v2 (success)', async () => {
239262
const resource = new TestResource()
240263
const plugin = testPlugin(resource);

src/messages/handlers.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Ajv, SchemaObject, ValidateFunction } from 'ajv';
22
import addFormats from 'ajv-formats';
33
import {
44
ApplyRequestDataSchema,
5-
ApplyResponseDataSchema,
5+
EmptyResponseDataSchema,
66
GetResourceInfoRequestDataSchema,
77
GetResourceInfoResponseDataSchema,
88
ImportRequestDataSchema,
@@ -19,6 +19,7 @@ import {
1919
PlanRequestDataSchema,
2020
PlanResponseDataSchema,
2121
ResourceSchema,
22+
SetVerbosityRequestDataSchema,
2223
ValidateRequestDataSchema,
2324
ValidateResponseDataSchema
2425
} from 'codify-schemas';
@@ -42,6 +43,14 @@ const SupportedRequests: Record<string, { handler: (plugin: Plugin, data: any) =
4243
requestValidator: GetResourceInfoRequestDataSchema,
4344
responseValidator: GetResourceInfoResponseDataSchema
4445
},
46+
'setVerbosityLevel': {
47+
async handler(plugin: Plugin, data: any) {
48+
await plugin.setVerbosityLevel(data)
49+
return null;
50+
},
51+
requestValidator: SetVerbosityRequestDataSchema,
52+
responseValidator: EmptyResponseDataSchema,
53+
},
4554
'match': {
4655
handler: async (plugin: Plugin, data: any) => plugin.match(data),
4756
requestValidator: MatchRequestDataSchema,
@@ -63,7 +72,7 @@ const SupportedRequests: Record<string, { handler: (plugin: Plugin, data: any) =
6372
return null;
6473
},
6574
requestValidator: ApplyRequestDataSchema,
66-
responseValidator: ApplyResponseDataSchema
75+
responseValidator: EmptyResponseDataSchema
6776
},
6877
}
6978

src/plugin/plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
PlanRequestData,
1313
PlanResponseData,
1414
ResourceConfig,
15-
ResourceJson,
15+
ResourceJson, SetVerbosityRequestData,
1616
ValidateRequestData,
1717
ValidateResponseData
1818
} from 'codify-schemas';
@@ -257,6 +257,10 @@ export class Plugin {
257257
}
258258
}
259259

260+
async setVerbosityLevel(data: SetVerbosityRequestData): Promise<void> {
261+
VerbosityLevel.set(data.verbosityLevel);
262+
}
263+
260264
async kill() {
261265
await this.planPty.kill();
262266
}

0 commit comments

Comments
 (0)