@@ -102,15 +102,7 @@ export function createTemplatesRepository(
102102
103103 const res = await deps . apiClient . GET ( '/templates' , {
104104 params : {
105- query : {
106- cursor : options . cursor ,
107- limit : options . limit ,
108- cpuCount : options . cpuCount ,
109- memoryMB : options . memoryMB ,
110- public : options . public ,
111- search : options . search ,
112- sort : options . sort ,
113- } ,
105+ query : options ,
114106 } ,
115107 headers : {
116108 ...deps . authHeaders ( scope . accessToken , scope . teamId ) ,
@@ -127,43 +119,37 @@ export function createTemplatesRepository(
127119 )
128120 }
129121
130- const data = ( res . data ?. data ?? [ ] ) . map (
131- ( t ) : Template | DefaultTemplate => {
132- const base : Template = {
133- templateID : t . templateID ,
134- buildID : t . buildID ,
135- cpuCount : t . cpuCount ,
136- memoryMB : t . memoryMB ,
137- diskSizeMB : t . diskSizeMB ?? 0 ,
138- public : t . public ,
139- aliases : t . aliases ,
140- names : t . names ,
141- createdAt : t . createdAt ,
142- updatedAt : t . updatedAt ,
143- // Email resolution is deferred while the Supabase auth migration is
144- // in progress; the endpoint returns only the creator id for now.
145- createdBy : t . createdBy
146- ? { id : t . createdBy . id , email : t . createdBy . email ?? '' }
147- : null ,
148- lastSpawnedAt : t . lastSpawnedAt ?? null ,
149- spawnCount : t . spawnCount ,
150- buildCount : t . buildCount ,
151- envdVersion : t . envdVersion ?? '' ,
152- }
153-
154- if ( t . isDefault ) {
155- return {
156- ...base ,
157- isDefault : true ,
158- defaultDescription : t . defaultDescription ?? undefined ,
159- }
160- }
122+ if ( ! res . data ?. data ?. length ) {
123+ return ok ( { data : [ ] , nextCursor : res . data ?. nextCursor ?? null } )
124+ }
161125
162- return base
163- }
164- )
126+ const data = res . data . data . map ( ( t ) : Template | DefaultTemplate => ( {
127+ templateID : t . templateID ,
128+ buildID : t . buildID ,
129+ cpuCount : t . cpuCount ,
130+ memoryMB : t . memoryMB ,
131+ diskSizeMB : t . diskSizeMB ?? 0 ,
132+ public : t . public ,
133+ aliases : t . aliases ,
134+ names : t . names ,
135+ createdAt : t . createdAt ,
136+ updatedAt : t . updatedAt ,
137+ // Email resolution is deferred while the Supabase auth migration is
138+ // in progress; the endpoint returns only the creator id for now.
139+ createdBy : t . createdBy
140+ ? { id : t . createdBy . id , email : t . createdBy . email ?? '' }
141+ : null ,
142+ lastSpawnedAt : t . lastSpawnedAt ?? null ,
143+ spawnCount : t . spawnCount ,
144+ buildCount : t . buildCount ,
145+ envdVersion : t . envdVersion ?? '' ,
146+ ...( t . isDefault && {
147+ isDefault : true as const ,
148+ defaultDescription : t . defaultDescription ?? undefined ,
149+ } ) ,
150+ } ) )
165151
166- return ok ( { data, nextCursor : res . data ? .nextCursor ?? null } )
152+ return ok ( { data, nextCursor : res . data . nextCursor ?? null } )
167153 } ,
168154 async deleteTemplate ( templateId ) {
169155 const res = await deps . infraClient . DELETE ( '/templates/{templateID}' , {
0 commit comments