From b8d020e9eace8c66f70f859c5c34ba5c131641c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Tue, 19 Dec 2023 20:51:15 -0300 Subject: [PATCH] registry(v1): add `control_file` to other endpoint responses (#570) --- registry/sqlx-data.json | 104 +++++++++++++++++----------------- registry/src/v1/repository.rs | 24 ++++++++ 2 files changed, 76 insertions(+), 52 deletions(-) diff --git a/registry/sqlx-data.json b/registry/sqlx-data.json index 06d6fb88..aa2f8517 100644 --- a/registry/sqlx-data.json +++ b/registry/sqlx-data.json @@ -186,24 +186,6 @@ }, "query": "\n UPDATE categories\n SET extension_count = extension_count + 1\n WHERE id = $1\n " }, - "2311356229c28ad26b36970d326746d7579d46139ff61ec5b6d077bc900f3a36": { - "describe": { - "columns": [ - { - "name": "result", - "ordinal": 0, - "type_info": "Json" - } - ], - "nullable": [ - null - ], - "parameters": { - "Left": [] - } - }, - "query": "\n SELECT\n json_build_object(\n 'name', tp.name,\n 'description', latest_tpvs.description,\n 'documentation_link', latest_tpvs.documentation_link,\n 'repository_link', latest_tpvs.repository_link,\n 'version', latest_tpvs.version,\n 'postgres_versions', (\n SELECT json_agg(pg.major)\n FROM v1.trunk_project_postgres_support tpps\n JOIN v1.postgres_version pg ON tpps.postgres_version_id = pg.id\n WHERE tpps.trunk_project_version_id = latest_tpvs.id\n ),\n 'extensions', (\n SELECT json_agg(json_build_object(\n 'extension_name', ev.extension_name,\n 'version', ev.version,\n 'trunk_project_name', tp.name,\n 'dependencies_extension_names', (\n SELECT json_agg(ed.depends_on_extension_name)\n FROM v1.extension_dependency ed\n WHERE ed.extension_version_id = ev.id\n ),\n 'loadable_libraries', (\n SELECT json_agg(json_build_object(\n 'library_name', ell.library_name,\n 'requires_restart', ell.requires_restart,\n 'priority', ell.priority\n ))\n FROM v1.extensions_loadable_libraries ell\n WHERE ell.extension_version_id = ev.id\n ),\n 'configurations', (\n SELECT json_agg(json_build_object(\n 'name', ec.configuration_name,\n 'is_required', ec.is_required,\n 'default', ec.recommended_default_value\n ))\n FROM v1.extension_configurations ec\n WHERE ec.extension_version_id = ev.id\n )\n ))\n FROM v1.extension_versions ev\n WHERE ev.trunk_project_version_id = latest_tpvs.id\n )\n ) AS result\n FROM\n v1.trunk_project tp\n JOIN (\n SELECT tpv.*\n FROM v1.trunk_project_versions tpv\n JOIN (\n SELECT trunk_project_name, MAX(string_to_array(version, '.')::int[]) as max_version\n FROM v1.trunk_project_versions\n GROUP BY trunk_project_name\n ) sub_tpv\n ON tpv.trunk_project_name = sub_tpv.trunk_project_name\n AND string_to_array(tpv.version, '.')::int[] = sub_tpv.max_version\n ) latest_tpvs\n ON tp.name = latest_tpvs.trunk_project_name\n ORDER BY tp.name" - }, "246a9f7369555b2fbedcc5db3ac5a84ce5c889b227095a07e420b7b0b4a3ea3b": { "describe": { "columns": [], @@ -561,26 +543,6 @@ }, "query": "SELECT user_name\n FROM api_tokens\n WHERE\n token = $1" }, - "4792b54a631ca09d4c0c76ed57f2526d202f263eec221cc503386eac8642a572": { - "describe": { - "columns": [ - { - "name": "result", - "ordinal": 0, - "type_info": "Json" - } - ], - "nullable": [ - null - ], - "parameters": { - "Left": [ - "Text" - ] - } - }, - "query": "SELECT\n json_build_object(\n 'name', tpv.trunk_project_name,\n 'description', tpv.description,\n 'documentation_link', tpv.documentation_link,\n 'repository_link', tpv.repository_link,\n 'version', tpv.version,\n 'postgres_versions', (\n SELECT json_agg(pg.major)\n FROM v1.trunk_project_postgres_support tpps\n JOIN v1.postgres_version pg ON tpps.postgres_version_id = pg.id\n WHERE tpps.trunk_project_version_id = tpv.id\n ),\n 'extensions', (\n SELECT json_agg(json_build_object(\n 'extension_name', ev.extension_name,\n 'version', ev.version,\n 'trunk_project_name', tpv.trunk_project_name,\n 'dependencies_extension_names', (\n SELECT json_agg(ed.depends_on_extension_name)\n FROM v1.extension_dependency ed\n WHERE ed.extension_version_id = ev.id\n ),\n 'loadable_libraries', (\n SELECT json_agg(json_build_object(\n 'library_name', ell.library_name,\n 'requires_restart', ell.requires_restart,\n 'priority', ell.priority\n ))\n FROM v1.extensions_loadable_libraries ell\n WHERE ell.extension_version_id = ev.id\n ),\n 'configurations', (\n SELECT json_agg(json_build_object(\n 'name', ec.configuration_name,\n 'is_required', ec.is_required,\n 'default', ec.recommended_default_value\n ))\n FROM v1.extension_configurations ec\n WHERE ec.extension_version_id = ev.id\n )\n ))\n FROM v1.extension_versions ev\n WHERE ev.trunk_project_version_id = tpv.id\n )\n ) AS result\n FROM\n v1.trunk_project_versions tpv\n JOIN v1.extension_versions ev ON ev.trunk_project_version_id = tpv.id\n JOIN (\n SELECT extension_name, MAX(string_to_array(version, '.')::int[]) as max_version\n FROM v1.extension_versions\n WHERE extension_name = $1\n GROUP BY extension_name\n ) sub_ev ON ev.extension_name = sub_ev.extension_name AND string_to_array(ev.version, '.')::int[] = sub_ev.max_version\n " - }, "49a41631cfe21efe58022e6e4026e6f3d388d8bb12ac478dbf30addab78d430e": { "describe": { "columns": [ @@ -722,6 +684,24 @@ }, "query": "INSERT INTO v1.extension_configurations (extension_version_id, is_required, configuration_name, recommended_default_value)\n VALUES ($1, $2, $3, $4)" }, + "65eec92a739b8837322c565e5b85b2c82c4bfc29fd4153c79bf45a2ac3320678": { + "describe": { + "columns": [ + { + "name": "result", + "ordinal": 0, + "type_info": "Json" + } + ], + "nullable": [ + null + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n json_build_object(\n 'name', tp.name,\n 'description', latest_tpvs.description,\n 'documentation_link', latest_tpvs.documentation_link,\n 'repository_link', latest_tpvs.repository_link,\n 'version', latest_tpvs.version,\n 'postgres_versions', (\n SELECT json_agg(pg.major)\n FROM v1.trunk_project_postgres_support tpps\n JOIN v1.postgres_version pg ON tpps.postgres_version_id = pg.id\n WHERE tpps.trunk_project_version_id = latest_tpvs.id\n ),\n 'extensions', (\n SELECT json_agg(json_build_object(\n 'extension_name', ev.extension_name,\n 'version', ev.version,\n 'trunk_project_name', tp.name,\n 'dependencies_extension_names', (\n SELECT json_agg(ed.depends_on_extension_name)\n FROM v1.extension_dependency ed\n WHERE ed.extension_version_id = ev.id\n ),\n 'loadable_libraries', (\n SELECT json_agg(json_build_object(\n 'library_name', ell.library_name,\n 'requires_restart', ell.requires_restart,\n 'priority', ell.priority\n ))\n FROM v1.extensions_loadable_libraries ell\n WHERE ell.extension_version_id = ev.id\n ),\n 'configurations', (\n SELECT json_agg(json_build_object(\n 'name', ec.configuration_name,\n 'is_required', ec.is_required,\n 'default', ec.recommended_default_value\n ))\n FROM v1.extension_configurations ec\n WHERE ec.extension_version_id = ev.id\n ),\n 'control_file', (\n SELECT json_build_object(\n 'absent', cf.absent,\n 'content', cf.content\n )\n FROM v1.control_file cf\n WHERE cf.extension_version_id = ev.id\n )\n ))\n FROM v1.extension_versions ev\n WHERE ev.trunk_project_version_id = latest_tpvs.id\n )\n ) AS result\n FROM\n v1.trunk_project tp\n JOIN (\n SELECT tpv.*\n FROM v1.trunk_project_versions tpv\n JOIN (\n SELECT trunk_project_name, MAX(string_to_array(version, '.')::int[]) as max_version\n FROM v1.trunk_project_versions\n GROUP BY trunk_project_name\n ) sub_tpv\n ON tpv.trunk_project_name = sub_tpv.trunk_project_name\n AND string_to_array(tpv.version, '.')::int[] = sub_tpv.max_version\n ) latest_tpvs\n ON tp.name = latest_tpvs.trunk_project_name\n ORDER BY tp.name" + }, "6722d3fb3cbd849aad563fe00ab77363b17cb7a63a14752a88d6c162011dc652": { "describe": { "columns": [], @@ -1428,26 +1408,27 @@ }, "query": "SELECT * FROM extension_detail_vw" }, - "e41ccd0b4b07c1761d78d4de2efdba33979114f1b055db3261af653afca8be56": { + "c60b779e83907373c3d15d26c2dc847abc6cb18bfc0ca6c3b515bddf7b072448": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "result", + "ordinal": 0, + "type_info": "Json" + } + ], + "nullable": [ + null + ], "parameters": { "Left": [ - "Int4", - "Varchar", - "Bool", - "Varchar", - "Varchar", - "Varchar", - "Jsonb", - "Jsonb" + "Text" ] } }, - "query": "\n INSERT INTO versions(extension_id, num, created_at, yanked, license, published_by, extension_name, system_dependencies, libraries)\n VALUES ($1, $2, (now() at time zone 'utc'), $3, $4, $5, $6, $7::jsonb, $8::jsonb)\n " + "query": "SELECT\n json_build_object(\n 'name', tpv.trunk_project_name,\n 'description', tpv.description,\n 'documentation_link', tpv.documentation_link,\n 'repository_link', tpv.repository_link,\n 'version', tpv.version,\n 'postgres_versions', (\n SELECT json_agg(pg.major)\n FROM v1.trunk_project_postgres_support tpps\n JOIN v1.postgres_version pg ON tpps.postgres_version_id = pg.id\n WHERE tpps.trunk_project_version_id = tpv.id\n ),\n 'extensions', (\n SELECT json_agg(json_build_object(\n 'extension_name', ev.extension_name,\n 'version', ev.version,\n 'trunk_project_name', tpv.trunk_project_name,\n 'dependencies_extension_names', (\n SELECT json_agg(ed.depends_on_extension_name)\n FROM v1.extension_dependency ed\n WHERE ed.extension_version_id = ev.id\n ),\n 'loadable_libraries', (\n SELECT json_agg(json_build_object(\n 'library_name', ell.library_name,\n 'requires_restart', ell.requires_restart,\n 'priority', ell.priority\n ))\n FROM v1.extensions_loadable_libraries ell\n WHERE ell.extension_version_id = ev.id\n ),\n 'configurations', (\n SELECT json_agg(json_build_object(\n 'name', ec.configuration_name,\n 'is_required', ec.is_required,\n 'default', ec.recommended_default_value\n ))\n FROM v1.extension_configurations ec\n WHERE ec.extension_version_id = ev.id\n ),\n 'control_file', (\n SELECT json_build_object(\n 'absent', cf.absent,\n 'content', cf.content\n )\n FROM v1.control_file cf\n WHERE cf.extension_version_id = ev.id\n )\n ))\n FROM v1.extension_versions ev\n WHERE ev.trunk_project_version_id = tpv.id\n )\n ) AS result\n FROM\n v1.trunk_project_versions tpv\n JOIN v1.extension_versions ev ON ev.trunk_project_version_id = tpv.id\n JOIN (\n SELECT extension_name, MAX(string_to_array(version, '.')::int[]) as max_version\n FROM v1.extension_versions\n WHERE extension_name = $1\n GROUP BY extension_name\n ) sub_ev ON ev.extension_name = sub_ev.extension_name AND string_to_array(ev.version, '.')::int[] = sub_ev.max_version\n " }, - "eee7c90c015003f5ec23f630582431b12a62216b7a4e07b11b1725b6d6231ae7": { + "d92abfbe26e6791281ad355e8289a183555f8c6da926dc717871629a25bf7bda": { "describe": { "columns": [ { @@ -1465,7 +1446,26 @@ ] } }, - "query": "SELECT\n json_build_object(\n 'name', tpv.trunk_project_name,\n 'description', tpv.description,\n 'version', tpv.version,\n 'documentation_link', tpv.documentation_link,\n 'repository_link', tpv.repository_link,\n 'postgres_versions', (\n SELECT json_agg(pg.major)\n FROM v1.trunk_project_postgres_support tpps\n JOIN v1.postgres_version pg ON tpps.postgres_version_id = pg.id\n WHERE tpps.trunk_project_version_id = tpv.id\n ),\n 'extensions', (\n SELECT json_agg(json_build_object(\n 'extension_name', ev.extension_name,\n 'version', ev.version,\n 'trunk_project_name', tpv.trunk_project_name,\n 'dependencies_extension_names', (\n SELECT json_agg(ed.depends_on_extension_name)\n FROM v1.extension_dependency ed\n WHERE ed.extension_version_id = ev.id\n ),\n 'loadable_libraries', (\n SELECT json_agg(json_build_object(\n 'library_name', ell.library_name,\n 'requires_restart', ell.requires_restart,\n 'priority', ell.priority\n ))\n FROM v1.extensions_loadable_libraries ell\n WHERE ell.extension_version_id = ev.id\n ),\n 'configurations', (\n SELECT json_agg(json_build_object(\n 'name', ec.configuration_name,\n 'is_required', ec.is_required,\n 'default', ec.recommended_default_value\n ))\n FROM v1.extension_configurations ec\n WHERE ec.extension_version_id = ev.id\n )\n ))\n FROM v1.extension_versions ev\n WHERE ev.trunk_project_version_id = tpv.id\n )\n ) AS result\n FROM\n v1.trunk_project_versions tpv\n WHERE\n tpv.trunk_project_name = $1" + "query": "SELECT\n json_build_object(\n 'name', tpv.trunk_project_name,\n 'description', tpv.description,\n 'version', tpv.version,\n 'documentation_link', tpv.documentation_link,\n 'repository_link', tpv.repository_link,\n 'postgres_versions', (\n SELECT json_agg(pg.major)\n FROM v1.trunk_project_postgres_support tpps\n JOIN v1.postgres_version pg ON tpps.postgres_version_id = pg.id\n WHERE tpps.trunk_project_version_id = tpv.id\n ),\n 'extensions', (\n SELECT json_agg(json_build_object(\n 'extension_name', ev.extension_name,\n 'version', ev.version,\n 'trunk_project_name', tpv.trunk_project_name,\n 'dependencies_extension_names', (\n SELECT json_agg(ed.depends_on_extension_name)\n FROM v1.extension_dependency ed\n WHERE ed.extension_version_id = ev.id\n ),\n 'loadable_libraries', (\n SELECT json_agg(json_build_object(\n 'library_name', ell.library_name,\n 'requires_restart', ell.requires_restart,\n 'priority', ell.priority\n ))\n FROM v1.extensions_loadable_libraries ell\n WHERE ell.extension_version_id = ev.id\n ),\n 'configurations', (\n SELECT json_agg(json_build_object(\n 'name', ec.configuration_name,\n 'is_required', ec.is_required,\n 'default', ec.recommended_default_value\n ))\n FROM v1.extension_configurations ec\n WHERE ec.extension_version_id = ev.id\n ),\n 'control_file', (\n SELECT json_build_object(\n 'absent', cf.absent,\n 'content', cf.content\n )\n FROM v1.control_file cf\n WHERE cf.extension_version_id = ev.id\n )\n ))\n FROM v1.extension_versions ev\n WHERE ev.trunk_project_version_id = tpv.id\n )\n ) AS result\n FROM\n v1.trunk_project_versions tpv\n WHERE\n tpv.trunk_project_name = $1" + }, + "e41ccd0b4b07c1761d78d4de2efdba33979114f1b055db3261af653afca8be56": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int4", + "Varchar", + "Bool", + "Varchar", + "Varchar", + "Varchar", + "Jsonb", + "Jsonb" + ] + } + }, + "query": "\n INSERT INTO versions(extension_id, num, created_at, yanked, license, published_by, extension_name, system_dependencies, libraries)\n VALUES ($1, $2, (now() at time zone 'utc'), $3, $4, $5, $6, $7::jsonb, $8::jsonb)\n " }, "f29a9769c67e94ef0eb534c3ea009496dc13426c6d46f545ada1f9ebc9def26b": { "describe": { diff --git a/registry/src/v1/repository.rs b/registry/src/v1/repository.rs index db762616..7fc17fc8 100644 --- a/registry/src/v1/repository.rs +++ b/registry/src/v1/repository.rs @@ -72,6 +72,14 @@ impl Registry { )) FROM v1.extension_configurations ec WHERE ec.extension_version_id = ev.id + ), + 'control_file', ( + SELECT json_build_object( + 'absent', cf.absent, + 'content', cf.content + ) + FROM v1.control_file cf + WHERE cf.extension_version_id = ev.id ) )) FROM v1.extension_versions ev @@ -147,6 +155,14 @@ impl Registry { )) FROM v1.extension_configurations ec WHERE ec.extension_version_id = ev.id + ), + 'control_file', ( + SELECT json_build_object( + 'absent', cf.absent, + 'content', cf.content + ) + FROM v1.control_file cf + WHERE cf.extension_version_id = ev.id ) )) FROM v1.extension_versions ev @@ -217,6 +233,14 @@ impl Registry { )) FROM v1.extension_configurations ec WHERE ec.extension_version_id = ev.id + ), + 'control_file', ( + SELECT json_build_object( + 'absent', cf.absent, + 'content', cf.content + ) + FROM v1.control_file cf + WHERE cf.extension_version_id = ev.id ) )) FROM v1.extension_versions ev