-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: zip egress plugin #464
base: main
Are you sure you want to change the base?
Conversation
a6aabe7
to
ab50ace
Compare
WalkthroughThe recent updates introduce the Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (5)
Files skipped from review as they are similar to previous changes (1)
Additional Context UsedBiome (36)
Additional comments not posted (4)
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
67ee13f
to
ce79b11
Compare
There was a problem hiding this 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
6792112
to
f2cbace
Compare
There was a problem hiding this 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
f2cbace
to
e99f292
Compare
There was a problem hiding this 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
e99f292
to
6d01f4c
Compare
There was a problem hiding this 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
29b4a25
to
a4e8a26
Compare
a4e8a26
to
3b292a8
Compare
There was a problem hiding this 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
Out of diff range and nitpick comments (1)
.changeset/dry-apples-teach.md (1)
5-5
: Please check the spelling of "egressing" in this context. If it is intended to mean "exporting" or "outputting," it might be clearer to use one of those terms to avoid confusion.
3b292a8
to
5097849
Compare
5097849
to
f255924
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Outside diff range and nitpick comments (6)
plugins/constraints/src/external.sheet.constraint.ts (2)
Line range hint
32-32
: Replaceany
with more specific types to improve type safety.- ) => any + ) => void | Promise<void>Also applies to: 37-37
Line range hint
56-74
: RefactorforEach
loops tofor...of
for better performance and readability.- constraints.forEach((constraint) => { + for (const constraint of constraints) { - records.forEach((record) => { + for (const record of records) { - fields.forEach((key) => { + for (const key of fields) {Also applies to: 58-73, 69-71
plugins/record-hook/src/record.translator.ts (1)
Line range hint
34-71
: Remove unnecessaryelse
clause after return statement for cleaner code.- } else { + }plugins/autocast/src/autocast.plugin.ts (3)
Line range hint
48-69
: RefactorforEach
loops tofor...of
for better performance and readability.- records.forEach((record) => { + for (const record of records) { - castableFields.forEach((field) => { + for (const field of castableFields) {Also applies to: 49-68
Line range hint
117-117
: UseNumber.isNaN
andNumber.isFinite
instead ofisNaN
andisFinite
for type safety.- if (!isNaN(Number(strippedValue))) { + if (!Number.isNaN(Number(strippedValue))) { - if (isFinite(num)) { + if (Number.isFinite(num)) {Also applies to: 119-119
Line range hint
168-168
: UseNumber.isNaN
instead ofisNaN
for type safety.- if (!isNaN(numericTimestamp)) { + if (!Number.isNaN(numericTimestamp)) { - if (!isNaN(date.getTime())) { + if (!Number.isNaN(date.getTime())) {Also applies to: 172-172
const constraints = getSheetConstraints(schema, validator) | ||
|
||
constraints.forEach((constraint) => { | ||
const fields = constraint.fields || [] | ||
records.forEach((record) => { | ||
try { | ||
// Execute the callback function for each record | ||
cb(partialObject(record, fields), constraint.fields, { | ||
config: constraint.config, | ||
record, | ||
properties: partialProperties(schema, fields), | ||
event, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimize the use of spread syntax in the accumulator to enhance performance.
- (acc, { key }) => ({ ...acc, [key]: '' }),
+ (acc, { key }) => { acc[key] = ''; return acc; },
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
}) | |
}) | |
.reduce((acc, { key }) => { acc[key] = ''; return acc; }, {}) |
// If the records are already Flatfile.RecordsWithLinks, return them directly | ||
return this.records as Flatfile.RecordsWithLinks | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary else
clause after return statement for cleaner code.
- } else {
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
// If the records are already Flatfile.RecordsWithLinks, return them directly | |
return this.records as Flatfile.RecordsWithLinks | |
} | |
} | |
// If the records are already Flatfile.RecordsWithLinks, return them directly | |
return this.records as Flatfile.RecordsWithLinks | |
} |
// Prepare the columns for CSV export, excluding fields marked as excludeFromExport | ||
fields.forEach((field) => { | ||
if (!!field.metadata?.excludeFromExport) return | ||
columns.push({ key: field.key, header: field.label }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary double negation for clarity.
- if (!!field.metadata?.excludeFromExport) return
+ if (field.metadata?.excludeFromExport) return
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
columns.push({ key: field.key, header: field.label }) | |
if (field.metadata?.excludeFromExport) return | |
columns.push({ key: field.key, header: field.label }) |
import AdmZip from 'adm-zip' | ||
import { ColumnOption, stringify } from 'csv-stringify/sync' | ||
import fs from 'fs' | ||
import path from 'path' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the node:
protocol when importing Node.js built-in modules.
- import fs from 'fs'
- import path from 'path'
+ import fs from 'node:fs'
+ import path from 'node:path'
Also applies to: 10-10
Committable suggestion was skipped due low confidence.
if (!!field.metadata?.excludeFromExport) return | ||
columns.push({ key: field.key, header: field.label }) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor forEach
loop to for...of
for better performance and readability.
- fields.forEach((field) => {
+ for (const field of fields) {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if (!!field.metadata?.excludeFromExport) return | |
columns.push({ key: field.key, header: field.label }) | |
}) | |
for (const field of fields) { | |
if (!!field.metadata?.excludeFromExport) return | |
columns.push({ key: field.key, header: field.label }) | |
} |
Please explain how to summarize this PR for the Changelog:
This PR introduces a plugin for egressing a Flatfile Workbook as a collection of zipped CSV files.
Tell code reviewer how and what to test:
Create a workspace with an action
workbook:downloadWorkbook
, then used this listener to create a zip file containing csv files for each sheet in the workbook.