diff --git a/lexicons/org/tangled/webhook/createWebhook.json b/lexicons/org/tangled/webhook/createWebhook.json new file mode 100644 index 00000000..b074a49c --- /dev/null +++ b/lexicons/org/tangled/webhook/createWebhook.json @@ -0,0 +1,62 @@ +{ + "lexicon": 1, + "id": "org.tangled.webhook.createWebhook", + "defs": { + "main": { + "type": "procedure", + "description": "Create a new webhook for a repository.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "url", "events"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the repository as minted by the knot." + }, + "url": { + "type": "string", + "format": "uri", + "description": "Endpoint URL that will receive webhook payloads." + }, + "active": { + "type": "boolean", + "default": true, + "description": "Whether the webhook should be active immediately." + }, + "events": { + "type": "array", + "description": "Event types to subscribe to.", + "items": { + "type": "ref", + "ref": "org.tangled.webhook.defs#eventType" + } + }, + "secret": { + "type": "string", + "description": "Optional HMAC secret used to sign payloads. If omitted, payloads are not signed." + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["id"], + "properties": { + "id": { + "type": "string", + "description": "ID of the newly created webhook." + } + } + } + }, + "errors": [ + { "name": "NoEventsSelected", "description": "At least one event type must be specified." } + ] + } + } +} diff --git a/lexicons/org/tangled/webhook/defs.json b/lexicons/org/tangled/webhook/defs.json new file mode 100644 index 00000000..dafc4ee3 --- /dev/null +++ b/lexicons/org/tangled/webhook/defs.json @@ -0,0 +1,19 @@ +{ + "lexicon": 1, + "id": "org.tangled.webhook.defs", + "defs": { + "eventType": { + "type": "string", + "knownValues": [ + "push", + "repository:renamed", + "pull_request:created", + "pull_request:resubmitted", + "pull_request:merged", + "pull_request:closed", + "pull_request:reopened", + "org.tangled.event.pullRequest" + ] + } + } +} diff --git a/lexicons/org/tangled/webhook/deleteWebhook.json b/lexicons/org/tangled/webhook/deleteWebhook.json new file mode 100644 index 00000000..ddfa59ea --- /dev/null +++ b/lexicons/org/tangled/webhook/deleteWebhook.json @@ -0,0 +1,31 @@ +{ + "lexicon": 1, + "id": "org.tangled.webhook.deleteWebhook", + "defs": { + "main": { + "type": "procedure", + "description": "Delete a webhook from a repository.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "webhook"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the repository as minted by the knot." + }, + "webhook": { + "type": "string", + "description": "Webhook ID to delete." + } + } + } + }, + "errors": [ + { "name": "WebhookNotFound" } + ] + } + } +} diff --git a/lexicons/org/tangled/webhook/listWebhookDeliveries.json b/lexicons/org/tangled/webhook/listWebhookDeliveries.json new file mode 100644 index 00000000..5d17e5b1 --- /dev/null +++ b/lexicons/org/tangled/webhook/listWebhookDeliveries.json @@ -0,0 +1,68 @@ +{ + "lexicon": 1, + "id": "org.tangled.webhook.listWebhookDeliveries", + "defs": { + "main": { + "type": "query", + "description": "List recent delivery attempts for a webhook.", + "parameters": { + "type": "params", + "required": ["repo", "webhook"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the repository as minted by the knot." + }, + "webhook": { + "type": "string", + "description": "Webhook ID." + }, + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 50 + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["deliveries"], + "properties": { + "deliveries": { + "type": "array", + "items": { + "type": "ref", + "ref": "#delivery" + } + } + } + } + } + }, + "delivery": { + "type": "object", + "required": ["id", "event", "url", "success", "createdAt"], + "properties": { + "id": { + "type": "string", + "description": "Unique ID for tracking this delivery attempt." + }, + "event": { + "type": "ref", + "ref": "org.tangled.webhook.defs#eventType", + "description": "Event type that triggered the delivery." + }, + "url": { "type": "string", "format": "uri" }, + "requestBody": { "type": "bytes" }, + "responseCode": { "type": "integer" }, + "responseBody": { "type": "bytes" }, + "success": { "type": "boolean" }, + "createdAt": { "type": "string", "format": "datetime" } + } + } + } +} diff --git a/lexicons/org/tangled/webhook/listWebhooks.json b/lexicons/org/tangled/webhook/listWebhooks.json new file mode 100644 index 00000000..45802774 --- /dev/null +++ b/lexicons/org/tangled/webhook/listWebhooks.json @@ -0,0 +1,66 @@ +{ + "lexicon": 1, + "id": "org.tangled.webhook.listWebhooks", + "defs": { + "main": { + "type": "query", + "description": "List webhooks configured for a repository.", + "parameters": { + "type": "params", + "required": ["repo"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the repository as minted by the knot." + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["webhooks"], + "properties": { + "webhooks": { + "type": "array", + "items": { + "type": "ref", + "ref": "#webhook" + } + } + } + } + } + }, + "webhook": { + "type": "object", + "required": ["id", "url", "active", "events", "createdAt"], + "properties": { + "id": { + "type": "string", + "description": "Webhook identifier." + }, + "url": { + "type": "string", + "format": "uri", + "description": "Endpoint URL that receives webhook payloads." + }, + "active": { + "type": "boolean", + "description": "Whether the webhook is currently enabled." + }, + "events": { + "type": "array", + "description": "Event types this webhook is subscribed to.", + "items": { + "type": "ref", + "ref": "org.tangled.webhook.defs#eventType" + } + }, + "createdAt": { "type": "string", "format": "datetime" }, + "updatedAt": { "type": "string", "format": "datetime" } + } + } + } +} diff --git a/lexicons/org/tangled/webhook/retryWebhookDelivery.json b/lexicons/org/tangled/webhook/retryWebhookDelivery.json new file mode 100644 index 00000000..960080af --- /dev/null +++ b/lexicons/org/tangled/webhook/retryWebhookDelivery.json @@ -0,0 +1,36 @@ +{ + "lexicon": 1, + "id": "org.tangled.webhook.retryWebhookDelivery", + "defs": { + "main": { + "type": "procedure", + "description": "Re-send a specific webhook delivery.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "webhook", "delivery"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the repository as minted by the knot." + }, + "webhook": { + "type": "string", + "description": "Webhook ID that owns the delivery." + }, + "delivery": { + "type": "string", + "description": "Delivery ID to retry." + } + } + } + }, + "errors": [ + { "name": "WebhookNotFound" }, + { "name": "DeliveryNotFound" } + ] + } + } +} diff --git a/lexicons/org/tangled/webhook/updateWebhook.json b/lexicons/org/tangled/webhook/updateWebhook.json new file mode 100644 index 00000000..f881ed3a --- /dev/null +++ b/lexicons/org/tangled/webhook/updateWebhook.json @@ -0,0 +1,48 @@ +{ + "lexicon": 1, + "id": "org.tangled.webhook.updateWebhook", + "defs": { + "main": { + "type": "procedure", + "description": "Update an existing webhook. Only supplied fields are changed.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "webhook"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the repository as minted by the knot." + }, + "webhook": { + "type": "string", + "description": "Webhook ID to update." + }, + "url": { + "type": "string", + "format": "uri" + }, + "secret": { + "type": "string" + }, + "active": { + "type": "boolean" + }, + "events": { + "type": "array", + "items": { + "type": "ref", + "ref": "org.tangled.webhook.defs#eventType" + } + } + } + } + }, + "errors": [ + { "name": "WebhookNotFound" } + ] + } + } +}