From 0af5564c7043b55c2825b8bbe1e8fdad4165adc0 Mon Sep 17 00:00:00 2001 From: corb3nik Date: Sun, 27 Oct 2024 21:12:52 -0400 Subject: [PATCH 1/2] Add workflow schema --- src/index.spec.ts | 15 +++++++++++---- src/schema.json | 27 +++++++++++++++++++++++++++ tests/valid_workflow.json | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 tests/valid_workflow.json diff --git a/src/index.spec.ts b/src/index.spec.ts index 2da5d2c..2a28ce1 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -5,28 +5,35 @@ import { describe, expect, it } from "vitest"; import { validateManifest } from "./validator.js"; describe("Manifest", () => { - it("Validate frontend manifest", () => { + it("validates frontend manifest", () => { const data = JSON.parse( fs.readFileSync("./tests/valid_frontend.json", "utf-8"), ); expect(validateManifest(data)).toBe(true); }); - it("Validate fullstack manifest", () => { + it("validates workflow manifest", () => { + const data = JSON.parse( + fs.readFileSync("./tests/valid_workflow.json", "utf-8"), + ); + expect(validateManifest(data)).toBe(true); + }); + + it("validates fullstack manifest", () => { const data = JSON.parse( fs.readFileSync("./tests/valid_fullstack.json", "utf-8"), ); expect(validateManifest(data)).toBe(true); }); - it("Validate missing style manifest", () => { + it("validates missing style manifest", () => { const data = JSON.parse( fs.readFileSync("./tests/valid_missing_style.json", "utf-8"), ); expect(validateManifest(data)).toBe(true); }); - it("Validate invalid version manifest", () => { + it("validates invalid version manifest", () => { const data = JSON.parse( fs.readFileSync("./tests/invalid_version.json", "utf-8"), ); diff --git a/src/schema.json b/src/schema.json index dd5350b..592ce4a 100644 --- a/src/schema.json +++ b/src/schema.json @@ -173,6 +173,33 @@ "$ref": "#/definitions/ManifestBackendPluginRuntime" } } + }, + { + "type": "object", + "required": [ + "id", + "kind", + "definition" + ], + "properties": { + "id": { + "$ref": "#/definitions/ManifestID" + }, + "kind": { + "type": "string", + "enum": [ + "workflow" + ] + }, + "name": { + "type": [ + "string" + ] + }, + "definition": { + "type": "string" + } + } } ] } diff --git a/tests/valid_workflow.json b/tests/valid_workflow.json new file mode 100644 index 0000000..1babc7c --- /dev/null +++ b/tests/valid_workflow.json @@ -0,0 +1,19 @@ +{ + "id": "workflow-plugin", + "name": "Workflow Plugin", + "version": "0.1.0", + "description": "This is a workflow plugin", + "author": { + "name": "Caido Labs Inc.", + "email": "dev@caido.io", + "url": "https://github.com/caido/caido" + }, + "plugins": [ + { + "kind": "workflow", + "id": "caido-workflow", + "name": "Some workflow", + "definition": "workflow/definition.json" + } + ] +} \ No newline at end of file From 54807039bc7cc9dd34bad66a61cc1095d9d3ac2e Mon Sep 17 00:00:00 2001 From: corb3nik Date: Sun, 27 Oct 2024 21:16:11 -0400 Subject: [PATCH 2/2] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bc2a697..1646004 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@caido/plugin-manifest", - "version": "0.1.3", + "version": "0.2.0", "description": "Validation for the plugin manifest", "author": "Caido Labs Inc. ", "license": "MIT",