codify-plugin-lib 1.0.182-beta54 → 1.0.182-beta55
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ajv } from 'ajv';
|
|
2
2
|
import addFormats from 'ajv-formats';
|
|
3
|
-
import { ApplyRequestDataSchema,
|
|
3
|
+
import { ApplyRequestDataSchema, EmptyResponseDataSchema, GetResourceInfoRequestDataSchema, GetResourceInfoResponseDataSchema, ImportRequestDataSchema, ImportResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, IpcMessageSchema, IpcMessageV2Schema, MatchRequestDataSchema, MatchResponseDataSchema, MessageStatus, PlanRequestDataSchema, PlanResponseDataSchema, ResourceSchema, SetVerbosityRequestDataSchema, ValidateRequestDataSchema, ValidateResponseDataSchema } from 'codify-schemas';
|
|
4
4
|
import { SudoError } from '../errors.js';
|
|
5
5
|
const SupportedRequests = {
|
|
6
6
|
'initialize': {
|
|
@@ -19,9 +19,12 @@ const SupportedRequests = {
|
|
|
19
19
|
responseValidator: GetResourceInfoResponseDataSchema
|
|
20
20
|
},
|
|
21
21
|
'setVerbosityLevel': {
|
|
22
|
-
|
|
22
|
+
async handler(plugin, data) {
|
|
23
|
+
await plugin.setVerbosityLevel(data);
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
23
26
|
requestValidator: SetVerbosityRequestDataSchema,
|
|
24
|
-
responseValidator: EmptyResponseDataSchema
|
|
27
|
+
responseValidator: EmptyResponseDataSchema,
|
|
25
28
|
},
|
|
26
29
|
'match': {
|
|
27
30
|
handler: async (plugin, data) => plugin.match(data),
|
|
@@ -44,7 +47,7 @@ const SupportedRequests = {
|
|
|
44
47
|
return null;
|
|
45
48
|
},
|
|
46
49
|
requestValidator: ApplyRequestDataSchema,
|
|
47
|
-
responseValidator:
|
|
50
|
+
responseValidator: EmptyResponseDataSchema
|
|
48
51
|
},
|
|
49
52
|
};
|
|
50
53
|
export class MessageHandler {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codify-plugin-lib",
|
|
3
|
-
"version": "1.0.182-
|
|
3
|
+
"version": "1.0.182-beta55",
|
|
4
4
|
"description": "Library plugin library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"ajv": "^8.12.0",
|
|
23
23
|
"ajv-formats": "^2.1.1",
|
|
24
24
|
"clean-deep": "^3.4.0",
|
|
25
|
-
"codify-schemas": "1.0.86-
|
|
25
|
+
"codify-schemas": "1.0.86-beta10",
|
|
26
26
|
"lodash.isequal": "^4.5.0",
|
|
27
27
|
"nanoid": "^5.0.9",
|
|
28
28
|
"strip-ansi": "^7.1.0",
|
|
@@ -235,6 +235,29 @@ describe('Message handler tests', () => {
|
|
|
235
235
|
process.send = undefined;
|
|
236
236
|
})
|
|
237
237
|
|
|
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
|
+
|
|
238
261
|
it('Supports ipc message v2 (success)', async () => {
|
|
239
262
|
const resource = new TestResource()
|
|
240
263
|
const plugin = testPlugin(resource);
|
package/src/messages/handlers.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Ajv, SchemaObject, ValidateFunction } from 'ajv';
|
|
|
2
2
|
import addFormats from 'ajv-formats';
|
|
3
3
|
import {
|
|
4
4
|
ApplyRequestDataSchema,
|
|
5
|
-
|
|
5
|
+
EmptyResponseDataSchema,
|
|
6
6
|
GetResourceInfoRequestDataSchema,
|
|
7
7
|
GetResourceInfoResponseDataSchema,
|
|
8
8
|
ImportRequestDataSchema,
|
|
@@ -44,9 +44,12 @@ const SupportedRequests: Record<string, { handler: (plugin: Plugin, data: any) =
|
|
|
44
44
|
responseValidator: GetResourceInfoResponseDataSchema
|
|
45
45
|
},
|
|
46
46
|
'setVerbosityLevel': {
|
|
47
|
-
|
|
47
|
+
async handler(plugin: Plugin, data: any) {
|
|
48
|
+
await plugin.setVerbosityLevel(data)
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
48
51
|
requestValidator: SetVerbosityRequestDataSchema,
|
|
49
|
-
responseValidator: EmptyResponseDataSchema
|
|
52
|
+
responseValidator: EmptyResponseDataSchema,
|
|
50
53
|
},
|
|
51
54
|
'match': {
|
|
52
55
|
handler: async (plugin: Plugin, data: any) => plugin.match(data),
|
|
@@ -69,7 +72,7 @@ const SupportedRequests: Record<string, { handler: (plugin: Plugin, data: any) =
|
|
|
69
72
|
return null;
|
|
70
73
|
},
|
|
71
74
|
requestValidator: ApplyRequestDataSchema,
|
|
72
|
-
responseValidator:
|
|
75
|
+
responseValidator: EmptyResponseDataSchema
|
|
73
76
|
},
|
|
74
77
|
}
|
|
75
78
|
|