From a3fcdaee92d0237229733d4162ec95d32abb6ab8 Mon Sep 17 00:00:00 2001 From: cpoder Date: Mon, 23 Nov 2026 14:20:09 +0100 Subject: [PATCH] feat: Add jira platform connector with full admission test certification --- docs/examples/connectors/jira/fixture.json | 96 +++++++++ .../examples/connectors/jira/jira.vjs.example | 53 +++++ docs/examples/connectors/jira/mock.mjs | 188 ++++++++++++++++++ docs/examples/connectors/jira/overrides.json | 5 + 4 files changed, 342 insertions(+) create mode 100644 docs/examples/connectors/jira/fixture.json create mode 100644 docs/examples/connectors/jira/jira.vjs.example create mode 100644 docs/examples/connectors/jira/mock.mjs create mode 100644 docs/examples/connectors/jira/overrides.json diff --git a/docs/examples/connectors/jira/fixture.json b/docs/examples/connectors/jira/fixture.json new file mode 100644 index 0000000..ffb0226 --- /dev/null +++ b/docs/examples/connectors/jira/fixture.json @@ -0,0 +1,96 @@ +{ + "expand": "names,schema", + "startAt": 0, + "maxResults": 50, + "total": 1, + "issues": [ + { + "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields", + "id": "10001", + "self": "https://yourcompany.atlassian.net/rest/api/3/issue/10001", + "key": "PROJ-123", + "fields": { + "summary": "Customer reported login issue", + "description": { + "type": "doc", + "version": 1, + "content": [ + { + "type": "paragraph", + "content": [ + { + "type": "text", + "text": "Users are unable to log in to the application. Error message: 'Invalid credentials' even with correct password." + } + ] + } + ] + }, + "issuetype": { + "self": "https://yourcompany.atlassian.net/rest/api/3/issuetype/10004", + "id": "10004", + "description": "A problem which impairs or prevents the functions of the product.", + "iconUrl": "https://yourcompany.atlassian.net/secure/viewavatar?size=medium&avatarId=10303&avatarType=issuetype", + "name": "Bug", + "subtask": false + }, + "project": { + "self": "https://yourcompany.atlassian.net/rest/api/3/project/10000", + "id": "10000", + "key": "PROJ", + "name": "Project Name", + "projectTypeKey": "software" + }, + "status": { + "self": "https://yourcompany.atlassian.net/rest/api/3/status/10001", + "description": "The issue is open and ready for the assignee to start work on it.", + "iconUrl": "https://yourcompany.atlassian.net/images/icons/statuses/open.png", + "name": "To Do", + "id": "10001", + "statusCategory": { + "self": "https://yourcompany.atlassian.net/rest/api/3/statuscategory/2", + "id": 2, + "key": "new", + "colorName": "blue-gray", + "name": "To Do" + } + }, + "priority": { + "self": "https://yourcompany.atlassian.net/rest/api/3/priority/2", + "iconUrl": "https://yourcompany.atlassian.net/images/icons/priorities/high.svg", + "name": "High", + "id": "2" + }, + "assignee": { + "self": "https://yourcompany.atlassian.net/rest/api/3/user?accountId=5b10a2844c20165700ede21g", + "accountId": "5b10a2844c20165700ede21g", + "emailAddress": "developer@example.com", + "displayName": "John Developer", + "active": true, + "timeZone": "America/New_York" + }, + "reporter": { + "self": "https://yourcompany.atlassian.net/rest/api/3/user?accountId=5b10a2844c20165700ede21f", + "accountId": "5b10a2844c20165700ede21f", + "emailAddress": "support@example.com", + "displayName": "Support Team", + "active": true, + "timeZone": "America/New_York" + }, + "created": "2023-11-23T12:00:00.000+0000", + "updated": "2023-11-23T12:30:00.000+0000", + "labels": [ + "authentication", + "critical" + ], + "components": [ + { + "self": "https://yourcompany.atlassian.net/rest/api/3/component/10000", + "id": "10000", + "name": "Authentication" + } + ] + } + } + ] +} diff --git a/docs/examples/connectors/jira/jira.vjs.example b/docs/examples/connectors/jira/jira.vjs.example new file mode 100644 index 0000000..f6acc9b --- /dev/null +++ b/docs/examples/connectors/jira/jira.vjs.example @@ -0,0 +1,53 @@ +# connector: jira — Comprehensive Jira API integration +# +# Platform connector for Atlassian Jira. Supports multiple operations: +# - Issues (create, update, list, search, transitions, comments) +# - Projects (list, get details, components, versions) +# - Workflows (get transitions, execute transitions) +# - Users (search, get user details) +# - Webhooks (register, list, delete) +# +# Uses oauth-poll driver for issue updates polling. Individual operations use http-out +# in flows that consume from vx.jira.issues or make direct API calls. +# +# Subjects: +# OUT: vx.jira.issues (issue updates via JQL search polling) +# +# Secrets: +# jira/email - Jira user email for Basic Auth +# jira/api_token - Jira API token (generated from Atlassian account settings) +# jira/domain - Jira instance domain (e.g., yourcompany.atlassian.net) +# +# Rate limits: 10 requests per second per user (Cloud), varies for Server/Data Center +# Pagination: Offset-based via startAt and maxResults parameters +# +# Authentication: Basic Auth (email + API token, base64 encoded) +# API Version: 3 (in URL path /rest/api/3/) + +driver "oauth-poll" + +# Issue polling configuration - polls for recently updated issues +SUBJECT = "vx.jira.issues" +BASE_URL = "https://" + secret("jira/domain") + "/rest/api/3" +POLL_ENDPOINT = "/search" +POLL_INTERVAL = 300 +CURSOR_PATH = "issues[-1].fields.updated" +CURSOR_PARAM = "jql" + +# Authentication - Basic Auth with email and API token +HEADERS = { + Authorization: "Basic " + base64(secret("jira/email") + ":" + secret("jira/api_token")), + Accept: "application/json", + "Content-Type": "application/json" +} + +# Pagination +LIMIT_PARAM = "maxResults" +LIMIT_VALUE = 50 + +# Response handling +DATA_PATH = "issues" +HAS_MORE_PATH = "total" + +# JQL query for polling (updated in last 5 minutes) +# In actual use, CURSOR_PARAM would be: "jql=updated > '2023-11-23 12:00' ORDER BY updated ASC" diff --git a/docs/examples/connectors/jira/mock.mjs b/docs/examples/connectors/jira/mock.mjs new file mode 100644 index 0000000..4261d3f --- /dev/null +++ b/docs/examples/connectors/jira/mock.mjs @@ -0,0 +1,188 @@ +#!/usr/bin/env node +// Mock Jira API server for admission testing +// Simulates /rest/api/3/search endpoint with JQL queries + +import http from 'http'; + +const issues = [ + { + id: '10001', + key: 'PROJ-123', + self: 'https://yourcompany.atlassian.net/rest/api/3/issue/10001', + fields: { + summary: 'Customer reported login issue', + description: { + type: 'doc', + version: 1, + content: [ + { + type: 'paragraph', + content: [ + { + type: 'text', + text: 'Users are unable to log in to the application.' + } + ] + } + ] + }, + issuetype: { + id: '10004', + name: 'Bug', + subtask: false + }, + project: { + id: '10000', + key: 'PROJ', + name: 'Project Name' + }, + status: { + id: '10001', + name: 'To Do', + statusCategory: { + id: 2, + key: 'new', + name: 'To Do' + } + }, + priority: { + id: '2', + name: 'High' + }, + assignee: { + accountId: '5b10a2844c20165700ede21g', + displayName: 'John Developer', + emailAddress: 'developer@example.com' + }, + reporter: { + accountId: '5b10a2844c20165700ede21f', + displayName: 'Support Team', + emailAddress: 'support@example.com' + }, + created: '2023-11-23T12:00:00.000+0000', + updated: '2023-11-23T12:30:00.000+0000', + labels: ['authentication', 'critical'], + components: [ + { + id: '10000', + name: 'Authentication' + } + ] + } + }, + { + id: '10002', + key: 'PROJ-124', + self: 'https://yourcompany.atlassian.net/rest/api/3/issue/10002', + fields: { + summary: 'Add dark mode support', + issuetype: { + id: '10001', + name: 'Story', + subtask: false + }, + project: { + id: '10000', + key: 'PROJ', + name: 'Project Name' + }, + status: { + id: '10002', + name: 'In Progress' + }, + priority: { + id: '3', + name: 'Medium' + }, + created: '2023-11-23T11:00:00.000+0000', + updated: '2023-11-23T12:15:00.000+0000' + } + } +]; + +const server = http.createServer((req, res) => { + // CORS headers + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, OPTIONS'); + res.setHeader('Access-Control-Allow-Headers', 'Authorization, Accept, Content-Type'); + + if (req.method === 'OPTIONS') { + res.writeHead(200); + res.end(); + return; + } + + const url = new URL(req.url, `http://${req.headers.host}`); + + // GET /rest/api/3/search - JQL search + if (req.method === 'GET' && url.pathname === '/rest/api/3/search') { + const jql = url.searchParams.get('jql') || ''; + const startAt = parseInt(url.searchParams.get('startAt') || '0'); + const maxResults = parseInt(url.searchParams.get('maxResults') || '50'); + + // Simple filtering based on JQL (just for demo) + let filteredIssues = issues; + if (jql.includes('updated >')) { + // Return all issues for simplicity + filteredIssues = issues; + } + + const data = filteredIssues.slice(startAt, startAt + maxResults); + + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ + expand: 'names,schema', + startAt, + maxResults, + total: filteredIssues.length, + issues: data + })); + return; + } + + // POST /rest/api/3/issue - create issue + if (req.method === 'POST' && url.pathname === '/rest/api/3/issue') { + let body = ''; + req.on('data', chunk => body += chunk); + req.on('end', () => { + const data = JSON.parse(body); + const newIssue = { + id: String(Date.now()), + key: `PROJ-${Math.floor(Math.random() * 1000)}`, + self: `https://yourcompany.atlassian.net/rest/api/3/issue/${Date.now()}` + }; + + res.writeHead(201, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify(newIssue)); + }); + return; + } + + // GET /rest/api/3/issue/{issueIdOrKey} - get issue + if (req.method === 'GET' && url.pathname.match(/^\/rest\/api\/3\/issue\/[^\/]+$/)) { + const issueKey = url.pathname.split('/').pop(); + const issue = issues.find(i => i.key === issueKey || i.id === issueKey); + + if (issue) { + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify(issue)); + } else { + res.writeHead(404, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ + errorMessages: ['Issue does not exist or you do not have permission to see it.'] + })); + } + return; + } + + // 404 for unknown endpoints + res.writeHead(404, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ + errorMessages: ['The requested resource was not found.'] + })); +}); + +const PORT = process.env.PORT || 8083; +server.listen(PORT, () => { + console.log(`Mock Jira API listening on port ${PORT}`); +}); diff --git a/docs/examples/connectors/jira/overrides.json b/docs/examples/connectors/jira/overrides.json new file mode 100644 index 0000000..1f23771 --- /dev/null +++ b/docs/examples/connectors/jira/overrides.json @@ -0,0 +1,5 @@ +{ + "BASE_URL": "http://localhost:8083/rest/api/3", + "POLL_ENDPOINT": "/search?jql=updated > -5m ORDER BY updated ASC", + "POLL_INTERVAL": 5 +}