chore: 🤖 Update serializer for storage buckets (#282)

This commit is contained in:
Zhihe Li authored and GitHub committed 2023-05-24 21:57:30 +00:00
1 parent 67a23a50fe
commit c63c95fd51
3 files changed
+63 -7

No files matched your search

+12 -3
View File
@@ -1,13 +1,22 @@
import ApplicationSerializer from './application';
export default class StorageBucketSerializer extends ApplicationSerializer {
serialize(snapshot) {
const serialized = super.serialize(...arguments);
if (!snapshot.record.isNew) {
delete serialized.bucket_name;
delete serialized.bucket_prefix;
}
return serialized;
}
normalize(typeClass, hash, ...rest) {
const normalizedHash = structuredClone(hash);
const normalized = super.normalize(typeClass, normalizedHash, ...rest);
// Remove secret fields
delete normalized.data.attributes.access_key_id;
delete normalized.data.attributes.secret_access_key;
// Remove secret fields so we don't track them after creating/updating
normalized.data.attributes.access_key_id = null;
normalized.data.attributes.secret_access_key = null;
return normalized;
}
}