Add default relation to standard object on custom object in manifest (#18033)

add default relation fields when creating an object from an application

---------

Co-authored-by: prastoin <paul@twenty.com>
This commit is contained in:
martmull
2026-02-20 11:49:06 +01:00
committed by GitHub
parent d060c843d1
commit 3bc887e12e
48 changed files with 1812 additions and 554 deletions
@@ -0,0 +1,9 @@
import { RESERVED_METADATA_NAME_KEYWORDS } from '@/metadata';
export const addCustomSuffixIfIsReserved = (name: string): string => {
if (!name) return name;
return RESERVED_METADATA_NAME_KEYWORDS.includes(name)
? `${name}Custom`
: name;
};
@@ -0,0 +1,33 @@
import { addCustomSuffixIfIsReserved } from '@/metadata/utils/add-custom-suffix-if-reserved.util';
import camelCase from 'lodash.camelcase';
import { slugify } from 'transliteration';
export const computeMetadataNameFromLabel = ({
label,
applyCustomSuffix = true,
}: {
label: string;
applyCustomSuffix?: boolean;
}): string => {
if (!label) return '';
const prefixedLabel = /^\d/.test(label) ? `n${label}` : label;
if (prefixedLabel === '') return '';
const formattedString = slugify(prefixedLabel, {
trim: true,
separator: '_',
allowedChars: 'a-zA-Z0-9',
});
if (formattedString === '') {
throw new Error(`Invalid label: "${label}"`);
}
const computedName = camelCase(formattedString);
return applyCustomSuffix
? addCustomSuffixIfIsReserved(computedName)
: computedName;
};