Add Excel (.xlsx) export for API datasets - #20
Merged
Merged
Conversation
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
charles2ke
September 15, 2026 17:44
View session
charles2ke
marked this pull request as ready for review
September 15, 2026 17:45
There was a problem hiding this comment.
🟡 Changes recommended
A critical XML-validity issue and moderate validation and scalability issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
src/export/datasets.js:182
- The GraphQL contract rejects
taxYearoutside 1900–9999, but this loader only checks presence. For example,taxYear=1reachesfinance.taxEstimateand can produce a successful empty estimate instead of the API's 400 response, so this export does not actually match the advertised query contract. Apply the same range check before calling the service.
if (params.taxYear === undefined) {
throw Object.assign(new Error('taxYear query parameter is required'), { statusCode: 400 });
}
src/export/router.js:37
- The
Errorssheet is the mechanism promised for partial finance exports, but the added tests only cover successful finance results and never supply a result witherrors. A regression could therefore silently omit upstream diagnostics while all export tests pass. Add a connector-failure case and assert that the downloaded workbook contains anErrorssheet with the source/code/message fields.
// Partial finance results carry upstream errors; surface them in the
// workbook instead of silently shipping incomplete data.
const allSheets = errors.length > 0 ? [...sheets, { name: 'Errors', columns: ERROR_COLUMNS, rows: errors }] : sheets;
- Files reviewed: 6/6 changed files
- Comments generated: 3
- Review effort level: Lite
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
charles2ke
approved these changes
Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The service could only return data as GraphQL JSON; there was no way to hand a portfolio snapshot or trade history to someone who works in a spreadsheet. This adds
.xlsxdownloads for the data the API already serves.Changes
src/export/xlsx.js— minimal OOXML writer (ZIP vianode:zlib, inline strings, numeric/boolean cells, XML escaping, Excel-safe sheet names). Written in-process to avoid pulling in a ~100-package spreadsheet dependency into a 5-dependency service.src/export/datasets.js— dataset registry (users,posts,portfolio,trades,tax-estimate) with column specs, loading rows from the same store and finance service the resolvers use so exports and queries stay consistent.src/export/router.js—GET /exportlists datasets;GET /export/:dataset(.xlsx)streams the workbook with attachment headers. Finance datasets accept the GraphQL filter/pagination params (accountId,symbol,side,status,from,to,limit,offset,taxYear). Unknown dataset → 404, missingtaxYear→ 400.Errorssheet rather than silently shipping an incomplete export.src/index.js— mounts the router at/exportwith CORS, alongside/graphql,/health,/ready,/metrics.test/export.test.js, README — tests unzip and assert the generated XML, dataset shapes, and route status codes; README documents the endpoint and dataset table.Notes for review: cells are untyped/unstyled (dates and currency export as ISO strings and raw numbers), and exports are unauthenticated like the rest of the demo endpoints.