57d8954973
# Introduction While testing the sdk and overall apps in https://github.com/prastoin/twenty-app-hello-world Faced a lot of pure `CJS` external dependencies import issue Replaced all the cjs deps to either esm equivalent or node native replacement
29 lines
790 B
TypeScript
29 lines
790 B
TypeScript
import { kebabCase } from '@/cli/utilities/string/kebab-case';
|
|
import { v4 } from 'uuid';
|
|
|
|
export const getRoleBaseFile = ({
|
|
name,
|
|
universalIdentifier = v4(),
|
|
}: {
|
|
name: string;
|
|
universalIdentifier?: string;
|
|
}) => {
|
|
const kebabCaseName = kebabCase(name);
|
|
|
|
return `import { defineRole } from 'twenty-sdk';
|
|
|
|
export const ${kebabCaseName.toUpperCase().replace(/-/g, '_')}_ROLE_UNIVERSAL_IDENTIFIER =
|
|
'${universalIdentifier}';
|
|
|
|
export default defineRole({
|
|
universalIdentifier: ${kebabCaseName.toUpperCase().replace(/-/g, '_')}_ROLE_UNIVERSAL_IDENTIFIER,
|
|
label: '${name}',
|
|
description: 'Add a description for your role',
|
|
canReadAllObjectRecords: true,
|
|
canUpdateAllObjectRecords: true,
|
|
canSoftDeleteAllObjectRecords: true,
|
|
canDestroyAllObjectRecords: false,
|
|
});
|
|
`;
|
|
};
|