Skip to content

[Feature] - Add API contract for asynchronous insight reaction PDF report generation#172

Open
InduwaraSMPN wants to merge 7 commits into
devfrom
user-reactions-implementation
Open

[Feature] - Add API contract for asynchronous insight reaction PDF report generation#172
InduwaraSMPN wants to merge 7 commits into
devfrom
user-reactions-implementation

Conversation

@InduwaraSMPN
Copy link
Copy Markdown
Contributor

@InduwaraSMPN InduwaraSMPN commented May 27, 2026

Summary

This PR adds the insightReactionReportGenerate endpoint to the SDK contract (src/sdk/routes.ts).

Functional Impact & Technical Reasoning:

  • Asynchronous Processing: PDF generation is computationally expensive and prone to causing Nginx timeouts when handled synchronously. This new POST endpoint delegates PDF generation to a background task, immediately returning a pending status to the client.
  • Client Integration Flow: Clients calling this endpoint will trigger the generation and should listen to Server-Sent Events (SSE) (reaction-run/report-ready or reaction-run/report-failed) to retrieve the generated PDF URL.
  • Cache Control: Includes an optional force boolean flag, allowing clients to bypass any previously cached PDF reports and trigger a fresh render when necessary.

Related issue

Closes #173

Test plan

  • Verify that the SDK contract compiles successfully (npm run type-check or equivalent).
  • Confirm that the schema definitions for insightReactionReportGenerate accept an id (coerced number) and an optional force (boolean), and return { status: 'pending' }.
  • Ensure that code generation downstream correctly picks up this contract change.

Checklist

  • CI passes (type-check + lint)
  • Shared contracts in sync if changed (routes.ts, schema.ts, proto)

Induwara and others added 5 commits May 28, 2026 09:33
Contract-mirror only. The widget has zero runtime calls into the
`insightReaction*` routes — this is the byte-identical SDK mirror per
the shared-contracts rule.

- `ReactionQuestionEntitySchema` + `ReactionAnswerEntitySchema` added.
- `ReactionEntitySchema` drops `question`, gains `questions[]` and
  optional `drafted_questions`.
- `ReactionResultEntitySchema` gains optional `answers[]`.
- New `insightReactionTemplateConfirm` route. XOR refine on
  `insightReactionCreate`. `insightReactionContext` accepts
  `questions: string[]`.

Type-check + code:check clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <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.

[Feature] - Add API contract for asynchronous insight reaction PDF report generation

1 participant