enhancement: fix type generation for Attribute.Relation by removing uid

This commit is contained in:
Convly 2024-01-25 17:30:21 +01:00
parent 758843ffd1
commit 16ac13f00a

View File

@ -69,7 +69,7 @@ module.exports = {
params.push(...targetFieldParams); params.push(...targetFieldParams);
// If the options property is defined, transform it to // If the options property is defined, transform it to
// a type literral node and add it to the params list // a type literal node and add it to the params list
if (_.isObject(options)) { if (_.isObject(options)) {
params.push(toTypeLiteral(options)); params.push(toTypeLiteral(options));
} }
@ -93,25 +93,18 @@ module.exports = {
media() { media() {
return [withAttributeNamespace('Media')]; return [withAttributeNamespace('Media')];
}, },
relation({ uid, attribute }) { relation({ attribute }) {
const { relation, target } = attribute; const { relation, target } = attribute;
const isMorphRelation = relation.toLowerCase().includes('morph'); const isMorphRelation = relation.toLowerCase().includes('morph');
if (isMorphRelation) { if (isMorphRelation) {
return [ return [withAttributeNamespace('Relation'), [factory.createStringLiteral(relation, true)]];
withAttributeNamespace('Relation'),
[factory.createStringLiteral(uid, true), factory.createStringLiteral(relation, true)],
];
} }
return [ return [
withAttributeNamespace('Relation'), withAttributeNamespace('Relation'),
[ [factory.createStringLiteral(relation, true), factory.createStringLiteral(target, true)],
factory.createStringLiteral(uid, true),
factory.createStringLiteral(relation, true),
factory.createStringLiteral(target, true),
],
]; ];
}, },
component({ attribute }) { component({ attribute }) {