From a0247d66e8af164afb214417ebdd3f299c2fdca1 Mon Sep 17 00:00:00 2001 From: shmck Date: Sun, 6 Jun 2021 15:41:59 -0700 Subject: [PATCH] add webhook dependencies to config Signed-off-by: shmck --- src/schema/skeleton.ts | 48 ++++++++++++++++++++++++++++++++++++++++++ src/schema/tutorial.ts | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/src/schema/skeleton.ts b/src/schema/skeleton.ts index 5a128df..e481ced 100644 --- a/src/schema/skeleton.ts +++ b/src/schema/skeleton.ts @@ -53,6 +53,54 @@ export default { examples: ['coderoad'] } }, + webhooks: { + type: 'object', + description: 'Optional configuration for setting up webhook events', + properties: { + endpoint: { + type: 'string', + description: + 'Webhook endpoint to hit on events. Uses HTTP POST requests', + examples: ['https://api.com/v1/coderoad'] + }, + headers: { + type: 'object', + description: 'Headers for the webhook request in JSON format', + examples: ['{ x-token: "$CODEROAD_WEBHOOK_TOKEN" }'], + additionalProperties: true + }, + events: { + type: 'object', + description: + 'A configuration of possible events toggled on or off', + properties: { + init: { + type: 'boolean', + description: 'Trigger webhook when user starts a tutorial' + }, + reset: { + type: 'boolean', + description: + 'Trigger webhook when user resets a CodeRoad tutorial' + }, + step_complete: { + type: 'boolean', + description: 'Trigger webhook when user completes a step' + }, + level_complete: { + type: 'boolean', + description: 'Trigger webhook when user completes a level' + }, + tutorial_complete: { + type: 'boolean', + description: + 'Trigger webhook when user completes a tutorial' + } + }, + additionalProperties: false + } + } + }, required: ['command', 'args'] }, setup: { diff --git a/src/schema/tutorial.ts b/src/schema/tutorial.ts index 7c8b677..aee3553 100644 --- a/src/schema/tutorial.ts +++ b/src/schema/tutorial.ts @@ -159,6 +159,52 @@ export default { } } }, + webhooks: { + type: 'object', + description: 'Optional configuration for setting up webhook events', + properties: { + endpoint: { + type: 'string', + description: + 'Webhook endpoint to hit on events. Uses HTTP POST requests', + examples: ['https://api.com/v1/coderoad'] + }, + headers: { + type: 'object', + description: 'Headers for the webhook request in JSON format', + examples: ['{ x-token: "$CODEROAD_WEBHOOK_TOKEN" }'], + additionalProperties: true + }, + events: { + type: 'object', + description: 'A configuration of possible events toggled on or off', + properties: { + init: { + type: 'boolean', + description: 'Trigger webhook when user starts a tutorial' + }, + reset: { + type: 'boolean', + description: + 'Trigger webhook when user resets a CodeRoad tutorial' + }, + step_complete: { + type: 'boolean', + description: 'Trigger webhook when user completes a step' + }, + level_complete: { + type: 'boolean', + description: 'Trigger webhook when user completes a level' + }, + tutorial_complete: { + type: 'boolean', + description: 'Trigger webhook when user completes a tutorial' + } + }, + additionalProperties: false + } + } + }, additionalProperties: false, required: ['testRunner', 'repo'] },