2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2022-08-31 09:55:59 -07:00
|
|
|
import Transform from '@ember-data/serializer/transform';
|
|
|
|
|
|
|
|
|
|
export default class PrincipalArrayTransform extends Transform {
|
|
|
|
|
deserialize(serialized) {
|
|
|
|
|
const stringValues = serialized || [];
|
|
|
|
|
return stringValues.map(({ id: principal_id, scope_id, type }) => ({
|
|
|
|
|
principal_id,
|
|
|
|
|
scope_id,
|
|
|
|
|
type,
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serialize(deserialized) {
|
|
|
|
|
const strings = deserialized || [];
|
|
|
|
|
return strings.map(({ principal_id: id, scope_id, type }) => ({
|
|
|
|
|
id,
|
|
|
|
|
scope_id,
|
|
|
|
|
type,
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|