d7def242b8
* Starting on namespaced id * Traversal for variables uniqued by namespace * Delog * Basic CRUD complete w namespaces included * Correct secvar breadcrumb joining and testfix now that namespaces are included * Testfixes with namespaces in place * Namespace-aware duplicate path warning * Duplicate path warning test additions * Trimpath reimplemented on dupe check * Solves a bug where slash was not being passed to the can write check * PR fixes * variable paths integration test fix now uses store * Seems far less hacky in retrospect * PR feedback addressed * test fixes after inclusion of path as local non-model var * Prevent confusion by dropping namespace from QPs on PUT, since its already in .data * Solves a harsh bug where you have namespace access but no secvars access (#14098) * Solves a harsh bug where you have namespace access but no secvars access * Lint cleanup * Remove unneeded condition
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
import classic from 'ember-classic-decorator';
|
|
import ApplicationSerializer from './application';
|
|
|
|
@classic
|
|
export default class VariableSerializer extends ApplicationSerializer {
|
|
separateNanos = ['CreateTime', 'ModifyTime'];
|
|
|
|
normalize(typeHash, hash) {
|
|
// ID is a composite of both the job ID and the namespace the job is in
|
|
hash.ID = `${hash.Path}@${hash.Namespace || 'default'}`;
|
|
return super.normalize(typeHash, hash);
|
|
}
|
|
|
|
// Transform API's Items object into an array of a KeyValue objects
|
|
normalizeFindRecordResponse(store, typeClass, hash, id, ...args) {
|
|
if (!hash.Items) {
|
|
hash.Items = { '': '' };
|
|
}
|
|
hash.KeyValues = Object.entries(hash.Items).map(([key, value]) => {
|
|
return {
|
|
key,
|
|
value,
|
|
};
|
|
});
|
|
delete hash.Items;
|
|
return super.normalizeFindRecordResponse(
|
|
store,
|
|
typeClass,
|
|
hash,
|
|
id,
|
|
...args
|
|
);
|
|
}
|
|
|
|
// Transform our KeyValues array into an Items object
|
|
serialize(snapshot, options) {
|
|
const json = super.serialize(snapshot, options);
|
|
json.ID = json.Path;
|
|
json.Items = json.KeyValues.reduce((acc, { key, value }) => {
|
|
acc[key] = value;
|
|
return acc;
|
|
}, {});
|
|
delete json.KeyValues;
|
|
delete json.ModifyTime;
|
|
delete json.CreateTime;
|
|
return json;
|
|
}
|
|
}
|