-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(plugin-import-export): json preview and downloads preserve nesting and exclude disabled fields #13210
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
Conversation
…eview-nested-fields
…-flag-nested-fields
…-flag-nested-fields
…s/payload into fix/disabled-nested-with-json-preview
…abling to subfields
…d-nested-with-json-preview
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
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.
I would like to add some int test coverage for json exports. We have some already so this should be very quick to add some nested field assertions.
…d-nested-with-json-preview
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.
You should be able to write an assertion of the downloaded data. Here is an example from gippity:
describe('GET /api/download', () => {
it('should download a JSON file with correct data', async () => {
const res = await request(app)
.get('/api/download')
.expect(200)
.expect('Content-Type', /application\/json|octet-stream/)
// Optional: assert it's served as a downloadable file
expect(res.headers['content-disposition']).toMatch(/attachment; filename=.*\.json/)
// Parse the file content as JSON
const data = JSON.parse(res.text)
// Write assertions on the JSON structure
expect(data).toHaveProperty('items')
expect(Array.isArray(data.items)).toBe(true)
expect(data.items[0]).toMatchObject({ id: expect.any(Number), name: expect.any(String) })
})
})
|
||
expect(Array.isArray(data)).toBe(true) | ||
expect(['string', 'number']).toContain(typeof data[0].id) | ||
expect(typeof data[0].title).toBe('string') |
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.
We should include a nested field as another assertion to make sure the json structure isn't being flattened.
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.
Approving despite wanting a little more from the test case added. We can always add when we get around to refactoring the createExport function which needs to have some logic deduplicated.
What?
Improves both the JSON preview and export functionality in the import-export plugin:
disabled
viacustom.plugin-import-export
format
isjson
(no CSV-style flattening)Why?
Previously:
format: json
were still CSV-style data encoded as.json
, rather than real JSON.How?
/preview-data
JSON handling to preserve original document shape.removeDisabledFields
to clean nested fields using dot-notation paths.createExport
to skipflattenObject
for JSON formats, using a nested JSON filter instead.format
isjson
.