Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow schema #1

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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. <[email protected]>",
"license": "MIT",
Expand Down
15 changes: 11 additions & 4 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
);
Expand Down
27 changes: 27 additions & 0 deletions src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
]
}
Expand Down
19 changes: 19 additions & 0 deletions tests/valid_workflow.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"url": "https://github.com/caido/caido"
},
"plugins": [
{
"kind": "workflow",
"id": "caido-workflow",
"name": "Some workflow",
"definition": "workflow/definition.json"
}
]
}