Skip to content

feat(SITES-44690): add task-management controller (connections, tickets, Jira integration)#2802

Open
prithipalpatwal wants to merge 4 commits into
mainfrom
feat/SITES-44690-task-management-api-v2
Open

feat(SITES-44690): add task-management controller (connections, tickets, Jira integration)#2802
prithipalpatwal wants to merge 4 commits into
mainfrom
feat/SITES-44690-task-management-api-v2

Conversation

@prithipalpatwal

@prithipalpatwal prithipalpatwal commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Jira: SITES-44690

Summary

Adds the task-management controller and routes to spacecat-api-service (SITES-44690).

Access control

All endpoints verify IMS org membership via AccessControlUtil.hasAccess(org) (v1 identity model per mysticat-architecture#150). Returns 404 on unknown org, 403 on denied. Admins bypass. readOnlyAdmin write-blocking handled upstream by readOnlyAdminWrapper. S2S capability deferred to v2.

Ticket creation (POST /organizations/:organizationId/task-management/:provider/tickets)

Flow:

  1. Validate inputs (organizationId, provider, projectKey, summary).
  2. Enforce Idempotency-Key header (required; 400 if absent). Check idempotency_keys table — return cached response if completed, 409 if in-flight.
  3. Load active TaskManagementConnection by connectionId from request body (404 if not found or not active for org+provider).
  4. Call TicketClientFactory.create() with the connection object, smClient (injected via smClientWrapper middleware), and httpClient.
  5. Create ticket via JiraCloudClient (single, individual batch ≤15, or grouped ≤1500).
  6. Persist Ticket + TicketSuggestion records.
  7. Mark idempotency key completed/failed. Return 201 (single/grouped) or 207 (individual batch).

All routes

  • GET /organizations/:organizationId/task-management/connections — list connections (optional ?provider= filter)
  • GET /organizations/:organizationId/task-management/connections/:connectionId — get one connection
  • GET /organizations/:organizationId/task-management/connections/:connectionId/projects — list Jira projects
  • GET /organizations/:organizationId/task-management/connections/:connectionId/issue-types?projectId= — list Jira issue types for a project
  • GET /organizations/:organizationId/task-management/tickets — list tickets for org
  • GET /organizations/:organizationId/suggestions/:suggestionId/ticket — get ticket for suggestion
  • GET /organizations/:organizationId/opportunities/:opportunityId/tickets — list tickets for opportunity
  • POST /organizations/:organizationId/task-management/:provider/tickets — create ticket(s)

v1 scope notes

  • suggestionIds optional; opportunityId can be used directly without suggestions.
  • priority, dueDate, components, parent forwarded to Jira if provided (optional fields per spec).
  • SecretsManagerClient injected via smClientWrapper middleware (follows the s3ClientWrapper pattern in src/support/s3.js).
  • Multi-connection support via explicit connectionId in request body; resolved via loadConnectionForOrg().
  • connectionId and provider classified as FACS_NON_RESOURCE_PARAMS — JWT session only, not a FACS surface in v1. ReBAC deferred to v2.
  • Individual batch cap: 15 (15 × ~800ms/ticket ≈ 12s). Grouped cap: 1500 (parallel validation, 1 Jira call).

…ts, Jira integration)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

- listTicketsByOpportunity: post-filter by organizationId to prevent cross-org data leak
- createTicket: fix idempotency key hash to always include organizationId explicitly
- createTicket: only cache batch response as completed when all items succeed (partial failures remain retryable)
- createTicket: add MIME type allowlist pre-check (aligned with jira-cloud-client) and filename sanitization
- listIssueTypes: use queryStringParameters instead of rawQueryString
- tests: update listIssueTypes fixture, add cross-org filter test, add MIME allowlist and filename tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

This PR will trigger a minor release when merged.

…ggestionIds

Both are always truthy; remove organizationId fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…endpoints

- Add shared IT test factory covering all 8 task-management endpoints
  (connections list/get, projects, issue-types, tickets list/get,
   ticket-by-suggestion, tickets-by-opportunity, create-ticket validation)
- Add seed data: task_management_connections, tickets, ticket_suggestions
- Register seeds at correct FK levels in seed.js
- Add task-management-api.yaml with OpenAPI path definitions for all 8 endpoints
- Add TaskManagementConnection, Ticket, TicketCreateRequest, TicketAttachment
  schemas to schemas.yaml
- Wire task-management paths into api.yaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant