Skip to content

Enhance static report generation guide with new PDF export options#3407

Merged
cjus merged 10 commits intomainfrom
carlos/report-guide-enhancements
Feb 3, 2026
Merged

Enhance static report generation guide with new PDF export options#3407
cjus merged 10 commits intomainfrom
carlos/report-guide-enhancements

Conversation

@cjus
Copy link
Collaborator

@cjus cjus commented Jan 27, 2026

  • Introduced two methods for PDF generation: a local script for batch processing and an API endpoint for on-demand requests.
  • Updated documentation to reflect changes in the PDF export process, including detailed implementation steps and usage scenarios.
  • Improved clarity on the differences between local and API-based PDF generation approaches, ensuring users can choose the best method for their needs.

Note

Low Risk
Low risk documentation-only change that adds a new binary PDF download approach and updates several expected command outputs; main risk is reader confusion if the described responses/mount paths don’t match current runtime behavior.

Overview
Adds a second PDF export path to the static report generation guide: alongside the existing local pdfmake script, it now documents a WebApp-based /reports endpoint that queries ClickHouse and returns a binary PDF response (including parameter validation and curl download examples).

Updates the tutorial narrative and diagrams to reflect the two approaches, clarifies reserved mount path constraints, and adjusts several setup/troubleshooting expectations (port conflicts including 9000, /health response shape, and ingest endpoint returning SUCCESS).

Written by Cursor Bugbot for commit 718536c. This will update automatically on new commits. Configure here.

- Introduced two methods for PDF generation: a local script for batch processing and an API endpoint for on-demand requests.
- Updated documentation to reflect changes in the PDF export process, including detailed implementation steps and usage scenarios.
- Improved clarity on the differences between local and API-based PDF generation approaches, ensuring users can choose the best method for their needs.
@vercel
Copy link

vercel bot commented Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-v2 Ready Ready Preview, Comment Feb 3, 2026 6:55pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Summary by CodeRabbit

  • New Features

    • Sales reports can now be exported as PDFs using either a local script workflow or an API endpoint for on-demand generation.
  • Documentation

    • Added comprehensive guide covering both PDF export methods, including setup, configuration, and testing procedures.

Walkthrough

Adds a new PDF export capability with two approaches: a local script that generates PDFs from pre-aggregated JSON and a new API endpoint that returns PDF binaries. Introduces app/apis/salesReportPdf.ts and exposes it via app/index.ts; updates docs and guide content to describe both pathways.

Changes

Cohort / File(s) Summary
New PDF API Module
app/apis/salesReportPdf.ts
New public API implementing PDF generation and returning binary PDF responses (mounted under /reports).
Public Surface Exports
app/index.ts
Adds export * from "./apis/salesReportPdf" to expose salesReportPdfApi in the public API surface.
Documentation & Guides
apps/framework-docs-v2/content/guides/static-report-generation.mdx
Expands Part 8/9 to document two PDF export approaches (A: local script, B: API endpoint), updates file tree, example endpoint /reports, testing instructions, and mount-path callouts.
Tests / Examples / Instructions
apps/.../static-report-generation.mdx (sections)
Adds test/export instructions showing how to request PDFs via the API and via the local script, expected responses/status codes.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant API as SalesReportAPI
    participant PDFGen as PDFGenerator
    participant Store as JSONStore

    Client->>API: GET /reports?salesReportId=123
    API->>Store: fetch pre-aggregated JSON (report 123)
    Store-->>API: JSON payload
    API->>PDFGen: render PDF from JSON
    PDFGen-->>API: binary PDF
    API-->>Client: 200 application/pdf (binary)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • callicles
  • 514Ben

Poem

📄✨ A PDF flows through the wire,
Script or API ignite the fire,
Bytes assemble, pages conspire,
From JSON seeds the reports aspire,
Delivered neat — a printable choir 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately summarizes the main change: adding new PDF export options to the static report generation guide.
Description check ✅ Passed Description clearly relates to the changeset, detailing the two PDF generation methods, documentation updates, and usage clarifications provided.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch carlos/report-guide-enhancements

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a539035 and 121ad00.

📒 Files selected for processing (1)
  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧰 Additional context used
📓 Path-based instructions (2)
apps/framework-docs-v2/content/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

apps/framework-docs-v2/content/**/*.mdx: Use {{ include "shared/path.mdx" }} directives to reuse content fragments, which are processed via processIncludes() during build
Validate code snippets in documentation with the @test directive for TypeScript and Python code blocks
TypeScript code snippets in documentation should be validated for syntax with brace matching; Python snippets should be validated for indentation

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
apps/framework-docs-v2/content/guides/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

Guide MDX files in content/guides/ must include frontmatter with title and description fields

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧠 Learnings (16)
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : API route files should follow a consistent error handling pattern: call service function inside try-catch, return result with res.json(), and respond with 500 status and error message on failure

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-28T14:50:00.978Z
Learnt from: cjus
Repo: 514-labs/moosestack PR: 3407
File: apps/framework-docs-v2/content/guides/static-report-generation.mdx:1402-1406
Timestamp: 2026-01-28T14:50:00.978Z
Learning: When reviewing WebApp implementations that run in a Node.js backend, prefer Node.js-specific types (e.g., Buffer) and avoid browser-focused cross-platform compatibility considerations. This guideline applies to MDX documentation and code examples across the repository where backend/runtime code is discussed; ensure reviewers distinguish server-side context from frontend/browser constraints and validate type usage accordingly.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : Always separate routing from business logic in APIs. Route files should be thin (~10 lines per endpoint) and contain only HTTP handling, while service files contain all business logic.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.854Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.854Z
Learning: Applies to examples/nextjs-moose/moose/src/query-examples/**/*.ts : Query example functions must use `eventsModel.toSql()` to generate SQL, ensuring consistent query construction through the defined model

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-28T14:55:13.411Z
Learnt from: cjus
Repo: 514-labs/moosestack PR: 3407
File: apps/framework-docs-v2/content/guides/static-report-generation.mdx:1585-1616
Timestamp: 2026-01-28T14:55:13.411Z
Learning: In documentation and tutorial files under apps/framework-docs-v2/content/guides/, prefer explicit, self-contained code examples that may duplicate small snippets for clarity over abstracting with DRY helpers. Ensure examples are easy to understand in isolation, even if it means a bit of repetition, to aid learning and reduce cognitive load for readers.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.854Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.854Z
Learning: Applies to examples/nextjs-moose/**/*.ts : Use type inference helpers (`$inferRequest`, `$inferDimensions`, `$inferMetrics`) from query model definitions to ensure type-safe query parameter construction

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.854Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.854Z
Learning: Applies to examples/nextjs-moose/components/report-builder/**/*.ts : Report builder components must use `prepareModel()` to transform backend model definitions for frontend consumption, configuring UI input types and options

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-22T19:02:52.316Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-docs-v2/CLAUDE.md:0-0
Timestamp: 2026-01-22T19:02:52.316Z
Learning: Applies to apps/framework-docs-v2/content/**/*.mdx : Validate code snippets in documentation with the `test` directive for TypeScript and Python code blocks

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-22T19:02:52.316Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-docs-v2/CLAUDE.md:0-0
Timestamp: 2026-01-22T19:02:52.316Z
Learning: Applies to apps/framework-docs-v2/content/**/*.mdx : TypeScript code snippets in documentation should be validated for syntax with brace matching; Python snippets should be validated for indentation

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-02-01T23:07:12.348Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-01T23:07:12.348Z
Learning: Add E2E tests to `python-tests` and `typescript-tests` templates when changing user-facing features

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-19T22:37:05.393Z
Learnt from: DatGuyJonathan
Repo: 514-labs/moosestack PR: 3282
File: apps/framework-cli-e2e/test/utils/llm-agent-utils.ts:613-742
Timestamp: 2026-01-19T22:37:05.393Z
Learning: In the LLM Documentation Automation test (`apps/framework-cli-e2e/test/llm-docs-automation.test.ts` and `apps/framework-cli-e2e/test/utils/llm-agent-utils.ts`), token limit failures are intentional. The test should fail if the agent exceeds Claude's context window, as this signals that documentation or task complexity needs improvement and represents what a real user would experience.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-02-01T23:07:12.348Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-01T23:07:12.348Z
Learning: Applies to **/*.{ts,tsx} : Prefer interfaces for objects, types for unions/intersections in TypeScript; explicit return types on public APIs

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-02-01T23:07:12.348Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-01T23:07:12.348Z
Learning: Always run end-to-end tests when changing MooseStack functionality

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.854Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.854Z
Learning: The moose query layer represents a two-step OLAP migration pattern: Step 1 (not shown) shifts just-in-time joins to write-time via Materialized Views; Step 2 (this demo) accelerates endpoint creation with the query layer. This architecture assumes MVs/OLAP tables already exist and focuses on the read-time query selection and filtering layer

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.854Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.854Z
Learning: Server actions serve as the primary bridge between frontend React components and backend moose query functions. The communication flow should always be: React Component → Hook → Server Action → Moose Query Function → eventsModel.toSql() → ClickHouse

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/ingest/models.ts : Data models in ingest/models.ts should define interfaces using the Model naming convention, and create corresponding IngestPipeline instances with table, stream, and ingestApi options enabled

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🪛 LanguageTool
apps/framework-docs-v2/content/guides/static-report-generation.mdx

[style] ~304-~304: ‘End result’ might be wordy. Consider a shorter alternative.
Context: ... --> F --> G E --> H --> I ``` ### End result 1. File loader script for CSV/JSON ing...

(EN_WORDINESS_PREMIUM_END_RESULT)

⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build CLI Binaries (darwin-arm64, macos-14-large, aarch64-apple-darwin)
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (3)
apps/framework-docs-v2/content/guides/static-report-generation.mdx (3)

291-310: Clear, actionable setup + architecture updates.
The diagram and startup/health guidance read well and are operationally helpful.

Also applies to: 339-399, 499-499


1027-1353: Approach A/B narrative and testing guidance are crisp.
The split between local script and API workflow is clear and well-scoped.

Also applies to: 1354-1365, 1655-1667, 1680-1715


1846-1860: Nice wrap-up + troubleshooting refinements.
The added context, file tree, and port conflict notes improve usability.

Also applies to: 1889-1895, 2001-2025, 2063-2095

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@apps/framework-docs-v2/content/guides/static-report-generation.mdx`:
- Around line 1558-1569: The handler currently checks for presence of startDate
and endDate but not format; add YYYY-MM-DD validation using a regex (e.g.,
/^\d{4}-\d{2}-\d{2}$/) and validate startDate and endDate before proceeding; if
either fails the regex, respond with res.writeHead(400, { "Content-Type":
"application/json" }) and res.end(JSON.stringify({ error: "startDate and endDate
must be in YYYY-MM-DD format" })); ensure you reference the existing variables
startDate and endDate and perform this check in the handler right after the
presence check to prevent downstream ClickHouse errors.
- Around line 1029-1031: Approach A uses level-3 headings (###) while Approach B
uses level-4 (####); update the Approach A step headings "Step 1: Install
pdfmake", "Step 2: …", "Step 3: …", and "Step 4: …" to use level-4 headings
(i.e., change the leading ### to ####) so the heading hierarchy matches Approach
B; locate these headings by the exact texts within the "Approach A: Local
script" section and apply the same change for the three additional steps
referenced.
- Around line 1637-1638: The curl examples use a path that doesn't match the
WebApp mounting: update examples to call the configured mountPath (/reports)
rather than /reports/sales-report-pdf, or change the routing in the handler;
specifically, adjust any examples referencing salesReportPdfApi or the WebApp
created via new WebApp("salesReportPdf", handler, { mountPath: "/reports" }) to
use http://localhost:4000/reports?startDate=... (and similarly for endDate) OR
implement explicit sub-route parsing inside the handler to accept the
/sales-report-pdf segment if that path was intended.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5b62ee1 and a20fa43.

📒 Files selected for processing (1)
  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧰 Additional context used
📓 Path-based instructions (2)
apps/framework-docs-v2/content/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

apps/framework-docs-v2/content/**/*.mdx: Use {{ include "shared/path.mdx" }} directives to reuse content fragments, which are processed via processIncludes() during build
Validate code snippets in documentation with the @test directive for TypeScript and Python code blocks
TypeScript code snippets in documentation should be validated for syntax with brace matching; Python snippets should be validated for indentation

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
apps/framework-docs-v2/content/guides/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

Guide MDX files in content/guides/ must include frontmatter with title and description fields

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧠 Learnings (4)
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: The moose query layer represents a two-step OLAP migration pattern: Step 1 (not shown) shifts just-in-time joins to write-time via Materialized Views; Step 2 (this demo) accelerates endpoint creation with the query layer. This architecture assumes MVs/OLAP tables already exist and focuses on the read-time query selection and filtering layer

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: Server actions serve as the primary bridge between frontend React components and backend moose query functions. The communication flow should always be: React Component → Hook → Server Action → Moose Query Function → eventsModel.toSql() → ClickHouse

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : Always separate routing from business logic in APIs. Route files should be thin (~10 lines per endpoint) and contain only HTTP handling, while service files contain all business logic.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/ingest/models.ts : Data models in ingest/models.ts should define interfaces using the Model naming convention, and create corresponding IngestPipeline instances with table, stream, and ingestApi options enabled

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🪛 LanguageTool
apps/framework-docs-v2/content/guides/static-report-generation.mdx

[style] ~303-~303: ‘End result’ might be wordy. Consider a shorter alternative.
Context: ... --> F --> G E --> H --> I ``` ### End result 1. File loader script for CSV/JSON ing...

(EN_WORDINESS_PREMIUM_END_RESULT)

🔇 Additional comments (6)
apps/framework-docs-v2/content/guides/static-report-generation.mdx (6)

1365-1384: LGTM on pdfmake setup and font configuration.

Standard PDF fonts with Helvetica family are portable and don't require external font files. The require() usage for pdfmake is correctly noted as necessary due to missing ESM exports.


1577-1607: Query building duplicates logic from salesReport.ts.

Both this handler and salesReport.ts (lines 929-959) have nearly identical conditional query construction. This is acceptable for documentation clarity, but consider extracting to a shared helper in production code.


1680-1694: Clear guidance on when to use each approach.

The comparison table and explanation effectively communicate the trade-offs between local script and API endpoint approaches.


1826-1841: "How Moose helps" section adds valuable context.

Maps ClickHouse best practices to Moose abstractions well. Links back to the earlier "Why Moose for static reports?" section appropriately.


2002-2006: Reference table updates are consistent.

File descriptions correctly distinguish JSON API vs PDF API (binary response) and clarify the local script purpose.


1400-1404: pdfmake 0.3 getBuffer() returns Promise<Buffer> — code usage is correct.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

cjus added 2 commits January 27, 2026 16:49
- Changed section headings from "Step" to "Step" for improved hierarchy.
- Added validation for date format in the PDF generation process to ensure correct input.
- Updated curl command examples to reflect the correct API endpoint for generating reports.
- Enhanced overall documentation for better user guidance and understanding.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@apps/framework-docs-v2/content/guides/static-report-generation.mdx`:
- Around line 1585-1616: The duplicated SQL in the two branches for building
query should be consolidated: create a base sql template for the
SELECT/GROUP/ORDER using the same fields (saleDate, region, productCategory,
summed columns) and the FROM ${targetTable} plus the saleDate BETWEEN
${startDate} AND ${endDate} predicate, then conditionally append an AND region =
${region} fragment only when region is provided and assign the combined sql to
query; reference the existing variables/query name (query), the sql template
literal helper (sql), and the parameters (${targetTable}, ${startDate},
${endDate}, ${region}) when implementing the conditional fragment—verify Moose's
sql template supports concatenation/conditional fragments before applying.
- Around line 1402-1406: The function generatePdfBuffer currently types its
return as Promise<Buffer> but pdfmake's getBuffer() returns Uint8Array in
browsers (Node Buffer extends Uint8Array), so change the signature of
generatePdfBuffer to return Promise<Uint8Array> and update any callers to
convert to Buffer only when running in Node (e.g., use Buffer.from(u8) where fs
or Node-only APIs require a Buffer); update any related types or docs
referencing generatePdfBuffer to reflect Promise<Uint8Array>.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a20fa43 and 6f621df.

📒 Files selected for processing (1)
  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧰 Additional context used
📓 Path-based instructions (2)
apps/framework-docs-v2/content/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

apps/framework-docs-v2/content/**/*.mdx: Use {{ include "shared/path.mdx" }} directives to reuse content fragments, which are processed via processIncludes() during build
Validate code snippets in documentation with the @test directive for TypeScript and Python code blocks
TypeScript code snippets in documentation should be validated for syntax with brace matching; Python snippets should be validated for indentation

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
apps/framework-docs-v2/content/guides/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

Guide MDX files in content/guides/ must include frontmatter with title and description fields

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧠 Learnings (6)
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : API route files should follow a consistent error handling pattern: call service function inside try-catch, return result with res.json(), and respond with 500 status and error message on failure

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : Always separate routing from business logic in APIs. Route files should be thin (~10 lines per endpoint) and contain only HTTP handling, while service files contain all business logic.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2025-12-16T23:09:00.546Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:00.546Z
Learning: When changing MooseStack functionality, ALWAYS run end-to-end tests located in `apps/framework-cli-e2e`

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: The moose query layer represents a two-step OLAP migration pattern: Step 1 (not shown) shifts just-in-time joins to write-time via Materialized Views; Step 2 (this demo) accelerates endpoint creation with the query layer. This architecture assumes MVs/OLAP tables already exist and focuses on the read-time query selection and filtering layer

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: Server actions serve as the primary bridge between frontend React components and backend moose query functions. The communication flow should always be: React Component → Hook → Server Action → Moose Query Function → eventsModel.toSql() → ClickHouse

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/ingest/models.ts : Data models in ingest/models.ts should define interfaces using the Model naming convention, and create corresponding IngestPipeline instances with table, stream, and ingestApi options enabled

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🪛 LanguageTool
apps/framework-docs-v2/content/guides/static-report-generation.mdx

[style] ~304-~304: ‘End result’ might be wordy. Consider a shorter alternative.
Context: ... --> F --> G E --> H --> I ``` ### End result 1. File loader script for CSV/JSON ing...

(EN_WORDINESS_PREMIUM_END_RESULT)

🔇 Additional comments (8)
apps/framework-docs-v2/content/guides/static-report-generation.mdx (8)

291-302: LGTM!

Architecture diagram correctly shows both PDF generation paths: local script via consumption API and direct binary response via PDF API.


1023-1043: LGTM!

Heading hierarchy is now consistent—both approaches use ### for the approach title and #### for steps within.


1565-1578: LGTM!

Date format validation added per previous review feedback. Proper 400 responses with descriptive error messages.


1674-1681: LGTM!

Curl examples correctly use /reports matching the mountPath configuration at line 1647.


1637-1641: LGTM!

Error handling logs details server-side while returning sanitized 500 response to client. Consistent with API route error handling patterns.


1835-1850: LGTM!

Clear mapping of ClickHouse best practices to Moose abstractions. Reinforces the developer-first value proposition.


1875-1886: LGTM!

Component descriptions accurately distinguish between JSON API and PDF export options.


2006-2015: LGTM!

Project structure table correctly lists both API files with clear descriptions distinguishing JSON vs binary PDF responses.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/framework-docs-v2/content/guides/static-report-generation.mdx`:
- Around line 1566-1578: Add a date-order validation after the existing
YYYY-MM-DD format checks to ensure startDate is not after endDate: parse
startDate and endDate into comparable Date objects (or use ISO string comparison
since format is YYYY-MM-DD) and if startDate > endDate, respond with a 400 and a
clear JSON error like "startDate must be on or before endDate"; update the
handler where startDate and endDate are checked (the same block that uses
dateRegex) so the request returns a validation error instead of proceeding and
producing empty results.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a20fa43 and 6f621df.

📒 Files selected for processing (1)
  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧰 Additional context used
📓 Path-based instructions (2)
apps/framework-docs-v2/content/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

apps/framework-docs-v2/content/**/*.mdx: Use {{ include "shared/path.mdx" }} directives to reuse content fragments, which are processed via processIncludes() during build
Validate code snippets in documentation with the @test directive for TypeScript and Python code blocks
TypeScript code snippets in documentation should be validated for syntax with brace matching; Python snippets should be validated for indentation

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
apps/framework-docs-v2/content/guides/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

Guide MDX files in content/guides/ must include frontmatter with title and description fields

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧠 Learnings (6)
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : API route files should follow a consistent error handling pattern: call service function inside try-catch, return result with res.json(), and respond with 500 status and error message on failure

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : Always separate routing from business logic in APIs. Route files should be thin (~10 lines per endpoint) and contain only HTTP handling, while service files contain all business logic.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2025-12-16T23:09:00.546Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:00.546Z
Learning: When changing MooseStack functionality, ALWAYS run end-to-end tests located in `apps/framework-cli-e2e`

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: The moose query layer represents a two-step OLAP migration pattern: Step 1 (not shown) shifts just-in-time joins to write-time via Materialized Views; Step 2 (this demo) accelerates endpoint creation with the query layer. This architecture assumes MVs/OLAP tables already exist and focuses on the read-time query selection and filtering layer

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: Server actions serve as the primary bridge between frontend React components and backend moose query functions. The communication flow should always be: React Component → Hook → Server Action → Moose Query Function → eventsModel.toSql() → ClickHouse

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/ingest/models.ts : Data models in ingest/models.ts should define interfaces using the Model naming convention, and create corresponding IngestPipeline instances with table, stream, and ingestApi options enabled

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🪛 LanguageTool
apps/framework-docs-v2/content/guides/static-report-generation.mdx

[style] ~304-~304: ‘End result’ might be wordy. Consider a shorter alternative.
Context: ... --> F --> G E --> H --> I ``` ### End result 1. File loader script for CSV/JSON ing...

(EN_WORDINESS_PREMIUM_END_RESULT)

🔇 Additional comments (5)
apps/framework-docs-v2/content/guides/static-report-generation.mdx (5)

279-309: LGTM!

Architecture diagram and end result section accurately reflect the dual PDF generation paths (local script and API endpoint).


1021-1032: LGTM!

Clear structure introducing both approaches. Heading hierarchy is consistent (### for approach headers, #### for steps).


1580-1642: LGTM!

Solid error handling: queries ClickHouse directly via getMooseUtils(), returns 404 for empty results, 500 with logged error on failure. Binary PDF response headers are correct. Based on learnings, the try-catch pattern with appropriate status codes follows API best practices.


1669-1703: LGTM!

Curl examples correctly use /reports matching the mountPath. Response codes are documented. The "when to use each approach" table provides clear guidance for choosing between local script and API endpoint.


1988-2015: LGTM!

File tree and reference table correctly include salesReportPdf.ts with accurate descriptions distinguishing JSON vs binary PDF endpoints.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

- Implemented a check to ensure that the start date is before or equal to the end date, returning a 400 error if the validation fails.
- This enhancement improves the robustness of the report generation process by preventing invalid date inputs.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/framework-docs-v2/content/guides/static-report-generation.mdx`:
- Line 1366: Two new TypeScript code blocks in the docs are missing the `@test`
directive so they won't be validated by the snippet tests; update each
```typescript code fence (the new TypeScript snippets added) to include the
`@test` tag (i.e., change ```typescript to ```typescript `@test`) so the docs
snippet tests will run against those blocks.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6f621df and a539035.

📒 Files selected for processing (1)
  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧰 Additional context used
📓 Path-based instructions (2)
apps/framework-docs-v2/content/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

apps/framework-docs-v2/content/**/*.mdx: Use {{ include "shared/path.mdx" }} directives to reuse content fragments, which are processed via processIncludes() during build
Validate code snippets in documentation with the @test directive for TypeScript and Python code blocks
TypeScript code snippets in documentation should be validated for syntax with brace matching; Python snippets should be validated for indentation

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
apps/framework-docs-v2/content/guides/**/*.mdx

📄 CodeRabbit inference engine (apps/framework-docs-v2/CLAUDE.md)

Guide MDX files in content/guides/ must include frontmatter with title and description fields

Files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🧠 Learnings (12)
📚 Learning: 2025-12-16T23:09:10.917Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-cli/AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:10.917Z
Learning: Applies to apps/framework-cli/**/*.rs : Document all public APIs and breaking changes

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : API route files should follow a consistent error handling pattern: call service function inside try-catch, return result with res.json(), and respond with 500 status and error message on failure

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-28T14:50:00.978Z
Learnt from: cjus
Repo: 514-labs/moosestack PR: 3407
File: apps/framework-docs-v2/content/guides/static-report-generation.mdx:1402-1406
Timestamp: 2026-01-28T14:50:00.978Z
Learning: When reviewing WebApp implementations that run in a Node.js backend, prefer Node.js-specific types (e.g., Buffer) and avoid browser-focused cross-platform compatibility considerations. This guideline applies to MDX documentation and code examples across the repository where backend/runtime code is discussed; ensure reviewers distinguish server-side context from frontend/browser constraints and validate type usage accordingly.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/apis/*.ts : Always separate routing from business logic in APIs. Route files should be thin (~10 lines per endpoint) and contain only HTTP handling, while service files contain all business logic.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: Applies to examples/nextjs-moose/moose/src/query-examples/**/*.ts : Query example functions must use `eventsModel.toSql()` to generate SQL, ensuring consistent query construction through the defined model

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-28T14:55:13.411Z
Learnt from: cjus
Repo: 514-labs/moosestack PR: 3407
File: apps/framework-docs-v2/content/guides/static-report-generation.mdx:1585-1616
Timestamp: 2026-01-28T14:55:13.411Z
Learning: In documentation and tutorial files under apps/framework-docs-v2/content/guides/, prefer explicit, self-contained code examples that may duplicate small snippets for clarity over abstracting with DRY helpers. Ensure examples are easy to understand in isolation, even if it means a bit of repetition, to aid learning and reduce cognitive load for readers.

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: Applies to examples/nextjs-moose/**/*.ts : Use type inference helpers (`$inferRequest`, `$inferDimensions`, `$inferMetrics`) from query model definitions to ensure type-safe query parameter construction

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: Applies to examples/nextjs-moose/components/report-builder/**/*.ts : Report builder components must use `prepareModel()` to transform backend model definitions for frontend consumption, configuring UI input types and options

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2025-12-16T23:09:00.546Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:00.546Z
Learning: When changing MooseStack functionality, ALWAYS run end-to-end tests located in `apps/framework-cli-e2e`

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: The moose query layer represents a two-step OLAP migration pattern: Step 1 (not shown) shifts just-in-time joins to write-time via Materialized Views; Step 2 (this demo) accelerates endpoint creation with the query layer. This architecture assumes MVs/OLAP tables already exist and focuses on the read-time query selection and filtering layer

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-27T17:36:29.825Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/nextjs-moose/CLAUDE.md:0-0
Timestamp: 2026-01-27T17:36:29.825Z
Learning: Server actions serve as the primary bridge between frontend React components and backend moose query functions. The communication flow should always be: React Component → Hook → Server Action → Moose Query Function → eventsModel.toSql() → ClickHouse

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
📚 Learning: 2026-01-15T19:41:53.563Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: examples/cdp-analytics/CLAUDE.md:0-0
Timestamp: 2026-01-15T19:41:53.563Z
Learning: Applies to examples/cdp-analytics/app/ingest/models.ts : Data models in ingest/models.ts should define interfaces using the Model naming convention, and create corresponding IngestPipeline instances with table, stream, and ingestApi options enabled

Applied to files:

  • apps/framework-docs-v2/content/guides/static-report-generation.mdx
🪛 LanguageTool
apps/framework-docs-v2/content/guides/static-report-generation.mdx

[style] ~304-~304: ‘End result’ might be wordy. Consider a shorter alternative.
Context: ... --> F --> G E --> H --> I ``` ### End result 1. File loader script for CSV/JSON ing...

(EN_WORDINESS_PREMIUM_END_RESULT)

🔇 Additional comments (3)
apps/framework-docs-v2/content/guides/static-report-generation.mdx (3)

291-310: Diagram + deliverables update is clear.

The architecture and end-result list now reflect both PDF paths cleanly.


1023-1032: Two‑approach framing reads well.

The intro and step headings make the local-vs-API split easy to scan.

Also applies to: 1043-1043, 1313-1313, 1339-1339, 1350-1364


1661-1667: Examples + wrap‑up updates are cohesive.

The callout, curl examples, comparison table, and wrap‑up/file‑tree updates align well with the new PDF API flow.

Also applies to: 1676-1710, 1842-1857, 1885-1891, 1997-1997, 2018-2021

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

cjus added 2 commits January 28, 2026 15:22
…larifications

- Added a warning callout to inform users to stop other Moose projects before starting a new one to avoid port conflicts.
- Updated service health check response description for clarity.
- Revised the expected response for the ingest command to indicate a simplified success message.
- Expanded troubleshooting section to include port 9000 and added guidance on TypeScript error persistence after code fixes.
@cjus cjus added this pull request to the merge queue Feb 3, 2026
Merged via the queue into main with commit e89177a Feb 3, 2026
43 checks passed
@cjus cjus deleted the carlos/report-guide-enhancements branch February 3, 2026 19:17
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.

2 participants