* chore: 🤖 Rename recording to session-recording * chore: 🤖 Update names for connection models * chore: 🤖 Update channel models to new name * chore: 🤖 Update remaining models after merge conflict
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import ApplicationSerializer from './application';
|
|
import ConnectionRecordingSerializer from './connection-recording';
|
|
import UserSerializer from './user';
|
|
import TargetSerializer from './target';
|
|
|
|
export default ApplicationSerializer.extend({
|
|
modelName: 'session-recording',
|
|
_hashForModel(model) {
|
|
const json = ApplicationSerializer.prototype._hashForModel.apply(
|
|
this,
|
|
arguments
|
|
);
|
|
const { connectionRecordings, users, targets } = this.schema;
|
|
|
|
// Manually map our models to the actual embedded json representation
|
|
if (model.connectionRecordingIds) {
|
|
json.connection_recordings = model.connectionRecordingIds.map((id) => {
|
|
const connection = connectionRecordings.find(id);
|
|
return ConnectionRecordingSerializer.prototype._hashForModel.apply(
|
|
this,
|
|
[connection]
|
|
);
|
|
});
|
|
}
|
|
if (model.userId) {
|
|
const user = users.find(model.userId);
|
|
json.user = UserSerializer.prototype._hashForModel.apply(this, [user]);
|
|
}
|
|
if (model.targetId) {
|
|
const target = targets.find(model.targetId);
|
|
json.target = TargetSerializer.prototype._hashForModel.apply(this, [
|
|
target,
|
|
]);
|
|
}
|
|
|
|
json.session_id = model.sessionId;
|
|
return json;
|
|
},
|
|
});
|