@@ -2,6 +2,8 @@ import * as fs from 'fs-extra';
22import { join } from 'path' ;
33import { v4 } from 'uuid' ;
44
5+ const SOURCE_FOLDER = 'src' ;
6+
57export const copyBaseApplicationProject = async ( {
68 appName,
79 appDisplayName,
@@ -21,10 +23,23 @@ export const copyBaseApplicationProject = async ({
2123
2224 await createYarnLock ( appDirectory ) ;
2325
26+ const sourceFolderPath = join ( appDirectory , SOURCE_FOLDER ) ;
27+
28+ await fs . ensureDir ( sourceFolderPath ) ;
29+
30+ const defaultServerlessFunctionRoleUniversalIdentifier = v4 ( ) ;
31+
32+ await createDefaultServerlessFunctionRoleConfig ( {
33+ displayName : appDisplayName ,
34+ appDirectory : sourceFolderPath ,
35+ defaultServerlessFunctionRoleUniversalIdentifier,
36+ } ) ;
37+
2438 await createApplicationConfig ( {
2539 displayName : appDisplayName ,
2640 description : appDescription ,
27- appDirectory,
41+ appDirectory : sourceFolderPath ,
42+ defaultServerlessFunctionRoleUniversalIdentifier,
2843 } ) ;
2944} ;
3045
@@ -76,21 +91,49 @@ yarn-error.log*
7691 await fs . writeFile ( join ( appDirectory , '.gitignore' ) , gitignoreContent ) ;
7792} ;
7893
94+ const createDefaultServerlessFunctionRoleConfig = async ( {
95+ displayName,
96+ appDirectory,
97+ defaultServerlessFunctionRoleUniversalIdentifier,
98+ } : {
99+ displayName : string ;
100+ appDirectory : string ;
101+ defaultServerlessFunctionRoleUniversalIdentifier : string ;
102+ } ) => {
103+ const content = `import { PermissionFlag, type RoleConfig } from 'twenty-sdk';
104+
105+ export const functionRole: RoleConfig = {
106+ universalIdentifier: '${ defaultServerlessFunctionRoleUniversalIdentifier } ',
107+ label: '${ displayName } default function role',
108+ description: '${ displayName } default function role',
109+ canReadAllObjectRecords: true,
110+ canUpdateAllObjectRecords: true,
111+ canSoftDeleteAllObjectRecords: true,
112+ canDestroyAllObjectRecords: false,
113+ };
114+ ` ;
115+
116+ await fs . writeFile ( join ( appDirectory , 'role.config.ts' ) , content ) ;
117+ } ;
118+
79119const createApplicationConfig = async ( {
80120 displayName,
81121 description,
82122 appDirectory,
123+ defaultServerlessFunctionRoleUniversalIdentifier,
83124} : {
84125 displayName : string ;
85126 description ?: string ;
86127 appDirectory : string ;
128+ defaultServerlessFunctionRoleUniversalIdentifier : string ;
87129} ) => {
88130 const content = `import { type ApplicationConfig } from 'twenty-sdk';
89131
90132const config: ApplicationConfig = {
91133 universalIdentifier: '${ v4 ( ) } ',
92134 displayName: '${ displayName } ',
93135 description: '${ description ?? '' } ',
136+ functionRoleUniversalIdentifier: '${ defaultServerlessFunctionRoleUniversalIdentifier } ',
94137};
95138
96139export default config;
@@ -127,7 +170,7 @@ const createPackageJson = async ({
127170 auth : 'twenty auth login' ,
128171 } ,
129172 dependencies : {
130- 'twenty-sdk' : '0.2.2 ' ,
173+ 'twenty-sdk' : '0.2.3 ' ,
131174 } ,
132175 devDependencies : {
133176 '@types/node' : '^24.7.2' ,
0 commit comments