@@ -79,6 +79,10 @@ async function main() {
7979 const shouldSkipNeon = flags . includes ( "--skip-neon" ) ;
8080 const recentFirst = flags . includes ( "--recent-first" ) ;
8181 const noBail = flags . includes ( "--no-bail" ) ;
82+ const maxUsersPerProjectFlag = flags . find ( f => f . startsWith ( "--max-users-per-project=" ) ) ;
83+ const maxUsersPerProject = maxUsersPerProjectFlag
84+ ? parseInt ( maxUsersPerProjectFlag . split ( "=" ) [ 1 ] , 10 )
85+ : Infinity ;
8286
8387 const { recurse, collectedErrors } = createRecurse ( { noBail } ) ;
8488
@@ -147,7 +151,9 @@ async function main() {
147151 console . warn ( "Using mock Stripe server (STACK_STRIPE_SECRET_KEY=sk_test_mockstripekey); skipping Stripe payout integrity checks." ) ;
148152 }
149153
150- const maxUsersPerProject = 100 ;
154+ if ( maxUsersPerProject !== Infinity ) {
155+ console . log ( `Will check at most ${ maxUsersPerProject } users per project.` ) ;
156+ }
151157
152158 const endAt = Math . min ( startAt + count , projects . length ) ;
153159 for ( let i = startAt ; i < endAt ; i ++ ) {
@@ -157,7 +163,7 @@ async function main() {
157163 return ;
158164 }
159165
160- const [ currentProject , users , projectPermissionDefinitions , teamPermissionDefinitions ] = await Promise . all ( [
166+ const [ currentProject , projectPermissionDefinitions , teamPermissionDefinitions ] = await Promise . all ( [
161167 expectStatusCode ( 200 , `/api/v1/internal/projects/current` , {
162168 method : "GET" ,
163169 headers : {
@@ -166,32 +172,48 @@ async function main() {
166172 "x-stack-development-override-key" : getEnvVariable ( "STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY" ) ,
167173 } ,
168174 } ) ,
169- expectStatusCode ( 200 , `/api/v1/users?limit= ${ maxUsersPerProject } ` , {
175+ expectStatusCode ( 200 , `/api/v1/project-permission-definitions ` , {
170176 method : "GET" ,
171177 headers : {
172178 "x-stack-project-id" : projectId ,
173179 "x-stack-access-type" : "admin" ,
174180 "x-stack-development-override-key" : getEnvVariable ( "STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY" ) ,
175181 } ,
176182 } ) ,
177- expectStatusCode ( 200 , `/api/v1/project -permission-definitions` , {
183+ expectStatusCode ( 200 , `/api/v1/team -permission-definitions` , {
178184 method : "GET" ,
179185 headers : {
180186 "x-stack-project-id" : projectId ,
181187 "x-stack-access-type" : "admin" ,
182188 "x-stack-development-override-key" : getEnvVariable ( "STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY" ) ,
183189 } ,
184190 } ) ,
185- expectStatusCode ( 200 , `/api/v1/team-permission-definitions` , {
191+ ] ) ;
192+ void currentProject ;
193+
194+ // Fetch users with pagination
195+ const PAGE_LIMIT = 1000 ;
196+ const allUsers : any [ ] = [ ] ;
197+ let cursor : string | undefined = undefined ;
198+ while ( allUsers . length < maxUsersPerProject ) {
199+ const remainingToFetch = maxUsersPerProject - allUsers . length ;
200+ const limit = Math . min ( PAGE_LIMIT , remainingToFetch ) ;
201+ const cursorParam : string = cursor ? `&cursor=${ encodeURIComponent ( cursor ) } ` : "" ;
202+ const usersPage = await expectStatusCode ( 200 , `/api/v1/users?limit=${ limit } ${ cursorParam } ` , {
186203 method : "GET" ,
187204 headers : {
188205 "x-stack-project-id" : projectId ,
189206 "x-stack-access-type" : "admin" ,
190207 "x-stack-development-override-key" : getEnvVariable ( "STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY" ) ,
191208 } ,
192- } ) ,
193- ] ) ;
194- void currentProject ;
209+ } ) ;
210+ allUsers . push ( ...usersPage . items ) ;
211+ if ( ! usersPage . pagination ?. next_cursor ) {
212+ break ;
213+ }
214+ cursor = usersPage . pagination . next_cursor ;
215+ }
216+ const users = { items : allUsers . slice ( 0 , maxUsersPerProject ) } ;
195217
196218 const tenancy = await getSoleTenancyFromProjectBranch ( projectId , DEFAULT_BRANCH_ID , true ) ;
197219 const paymentsConfig = tenancy ? ( tenancy . config as OrganizationRenderedConfig ) . payments : undefined ;
0 commit comments