Stop the template lists shipping their ranking score

Both template lists hand raw config rows to dynamic(), so score - internal
ranking used only to sort the list - went out with them. The single-template
endpoints already build a Document and were unaffected.

Site templates also gain demoUrl, which the model declares and the config
omits, so it now reports its default rather than being absent.
This commit is contained in:
harsh mahajan committed 2026-08-13 15:05:53 +05:30
1 parent f426cf4f6e
commit 3f05ac1736
3 files changed
+10 -3

No files matched your search

@@ -81,7 +81,10 @@ class XList extends Base
});
$total = $includeTotal ? \count($templates) : 0;
$templates = \array_slice($templates, $offset, $limit);
$templates = \array_map(
fn (array $template) => new Document($template),
\array_slice($templates, $offset, $limit)
);
$response->dynamic(new Document([
'templates' => $templates,
'total' => $total,
@@ -84,7 +84,10 @@ class XList extends Base
});
$total = \count($templates);
$templates = \array_slice($templates, $offset, $limit);
$templates = \array_map(
fn (array $template) => new Document($template),
\array_slice($templates, $offset, $limit)
);
$response->dynamic(new Document([
'templates' => $templates,
'total' => $total,
@@ -117,7 +117,7 @@ final class SitesCustomClientTest extends Scope
$this->assertEquals(400, $templates['headers']['status-code']);
}
public function testListTemplatesHidesStartCommand()
public function testListTemplatesHidesInternalFields()
{
$templates = $this->client->call(Client::METHOD_GET, '/sites/templates', array_merge([
'content-type' => 'application/json',
@@ -130,6 +130,7 @@ final class SitesCustomClientTest extends Scope
$this->assertGreaterThan(0, $templates['body']['total']);
$this->assertStringNotContainsString('startCommand', (string) json_encode($templates['body']));
$this->assertStringNotContainsString('score', (string) json_encode($templates['body']));
$template = $this->getTemplate('starter-for-nextjs');