codify-plugin-lib 1.0.182-beta53 → 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': {
|
|
@@ -18,6 +18,14 @@ const SupportedRequests = {
|
|
|
18
18
|
requestValidator: GetResourceInfoRequestDataSchema,
|
|
19
19
|
responseValidator: GetResourceInfoResponseDataSchema
|
|
20
20
|
},
|
|
21
|
+
'setVerbosityLevel': {
|
|
22
|
+
async handler(plugin, data) {
|
|
23
|
+
await plugin.setVerbosityLevel(data);
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
requestValidator: SetVerbosityRequestDataSchema,
|
|
27
|
+
responseValidator: EmptyResponseDataSchema,
|
|
28
|
+
},
|
|
21
29
|
'match': {
|
|
22
30
|
handler: async (plugin, data) => plugin.match(data),
|
|
23
31
|
requestValidator: MatchRequestDataSchema,
|
|
@@ -39,7 +47,7 @@ const SupportedRequests = {
|
|
|
39
47
|
return null;
|
|
40
48
|
},
|
|
41
49
|
requestValidator: ApplyRequestDataSchema,
|
|
42
|
-
responseValidator:
|
|
50
|
+
responseValidator: EmptyResponseDataSchema
|
|
43
51
|
},
|
|
44
52
|
};
|
|
45
53
|
export class MessageHandler {
|
package/dist/plugin/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplyRequestData, GetResourceInfoRequestData, GetResourceInfoResponseData, ImportRequestData, ImportResponseData, InitializeRequestData, InitializeResponseData, MatchRequestData, MatchResponseData, PlanRequestData, PlanResponseData, ResourceConfig, ResourceJson, ValidateRequestData, ValidateResponseData } from 'codify-schemas';
|
|
1
|
+
import { ApplyRequestData, GetResourceInfoRequestData, GetResourceInfoResponseData, ImportRequestData, ImportResponseData, InitializeRequestData, InitializeResponseData, MatchRequestData, MatchResponseData, PlanRequestData, PlanResponseData, ResourceConfig, ResourceJson, SetVerbosityRequestData, ValidateRequestData, ValidateResponseData } from 'codify-schemas';
|
|
2
2
|
import { Plan } from '../plan/plan.js';
|
|
3
3
|
import { BackgroundPty } from '../pty/background-pty.js';
|
|
4
4
|
import { Resource } from '../resource/resource.js';
|
|
@@ -17,6 +17,7 @@ export declare class Plugin {
|
|
|
17
17
|
validate(data: ValidateRequestData): Promise<ValidateResponseData>;
|
|
18
18
|
plan(data: PlanRequestData): Promise<PlanResponseData>;
|
|
19
19
|
apply(data: ApplyRequestData): Promise<void>;
|
|
20
|
+
setVerbosityLevel(data: SetVerbosityRequestData): Promise<void>;
|
|
20
21
|
kill(): Promise<void>;
|
|
21
22
|
private resolvePlan;
|
|
22
23
|
protected crossValidateResources(resources: ResourceJson[]): Promise<void>;
|
package/dist/plugin/plugin.js
CHANGED
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,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
PlanRequestDataSchema,
|
|
20
20
|
PlanResponseDataSchema,
|
|
21
21
|
ResourceSchema,
|
|
22
|
+
SetVerbosityRequestDataSchema,
|
|
22
23
|
ValidateRequestDataSchema,
|
|
23
24
|
ValidateResponseDataSchema
|
|
24
25
|
} from 'codify-schemas';
|
|
@@ -42,6 +43,14 @@ const SupportedRequests: Record<string, { handler: (plugin: Plugin, data: any) =
|
|
|
42
43
|
requestValidator: GetResourceInfoRequestDataSchema,
|
|
43
44
|
responseValidator: GetResourceInfoResponseDataSchema
|
|
44
45
|
},
|
|
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
|
+
},
|
|
45
54
|
'match': {
|
|
46
55
|
handler: async (plugin: Plugin, data: any) => plugin.match(data),
|
|
47
56
|
requestValidator: MatchRequestDataSchema,
|
|
@@ -63,7 +72,7 @@ const SupportedRequests: Record<string, { handler: (plugin: Plugin, data: any) =
|
|
|
63
72
|
return null;
|
|
64
73
|
},
|
|
65
74
|
requestValidator: ApplyRequestDataSchema,
|
|
66
|
-
responseValidator:
|
|
75
|
+
responseValidator: EmptyResponseDataSchema
|
|
67
76
|
},
|
|
68
77
|
}
|
|
69
78
|
|
package/src/plugin/plugin.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
PlanRequestData,
|
|
13
13
|
PlanResponseData,
|
|
14
14
|
ResourceConfig,
|
|
15
|
-
ResourceJson,
|
|
15
|
+
ResourceJson, SetVerbosityRequestData,
|
|
16
16
|
ValidateRequestData,
|
|
17
17
|
ValidateResponseData
|
|
18
18
|
} from 'codify-schemas';
|
|
@@ -257,6 +257,10 @@ export class Plugin {
|
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
async setVerbosityLevel(data: SetVerbosityRequestData): Promise<void> {
|
|
261
|
+
VerbosityLevel.set(data.verbosityLevel);
|
|
262
|
+
}
|
|
263
|
+
|
|
260
264
|
async kill() {
|
|
261
265
|
await this.planPty.kill();
|
|
262
266
|
}
|