Skip to content

Commit 0d71448

Browse files
committed
Merge remote-tracking branch 'origin/main' into quenting/admin-api/optional-count
2 parents df9a4a1 + 4cccc06 commit 0d71448

File tree

45 files changed

+2067
-973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2067
-973
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ jobs:
268268
mirrors = ["mirror.gcr.io"]
269269
270270
- name: Login to GitHub Container Registry
271-
uses: docker/login-action@v3.5.0
271+
uses: docker/login-action@v3.6.0
272272
with:
273273
registry: ghcr.io
274274
username: ${{ github.repository_owner }}

Cargo.lock

Lines changed: 27 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ version = "0.1.89"
8888

8989
# High-level error handling
9090
[workspace.dependencies.anyhow]
91-
version = "1.0.99"
91+
version = "1.0.100"
9292

9393
# Assert that a value matches a pattern
9494
[workspace.dependencies.assert_matches]
9595
version = "1.5.0"
9696

9797
# HTTP router
9898
[workspace.dependencies.axum]
99-
version = "0.8.4"
99+
version = "0.8.5"
100100

101101
# Extra utilities for Axum
102102
[workspace.dependencies.axum-extra]
103-
version = "0.10.1"
103+
version = "0.10.2"
104104
features = ["cookie-private", "cookie-key-expansion", "typed-header"]
105105

106106
# Axum macros
@@ -137,7 +137,7 @@ version = "1.10.1"
137137

138138
# UTF-8 paths
139139
[workspace.dependencies.camino]
140-
version = "1.2.0"
140+
version = "1.2.1"
141141
features = ["serde1"]
142142

143143
# ChaCha20Poly1305 AEAD
@@ -167,7 +167,7 @@ features = ["serde", "clock"]
167167

168168
# CLI argument parsing
169169
[workspace.dependencies.clap]
170-
version = "4.5.47"
170+
version = "4.5.48"
171171
features = ["derive"]
172172

173173
# Object Identifiers (OIDs) as constants
@@ -476,7 +476,7 @@ features = ["std", "pkcs5", "encryption"]
476476

477477
# Public Suffix List
478478
[workspace.dependencies.psl]
479-
version = "2.1.141"
479+
version = "2.1.145"
480480

481481
# High-precision clock
482482
[workspace.dependencies.quanta]
@@ -582,7 +582,7 @@ version = "0.42.0"
582582

583583
# Serialization and deserialization
584584
[workspace.dependencies.serde]
585-
version = "1.0.225"
585+
version = "1.0.228"
586586
features = ["derive"] # Most of the time, if we need serde, we need derive
587587

588588
# JSON serialization and deserialization
@@ -652,7 +652,7 @@ version = "0.1.17"
652652

653653
# Tokio rustls integration
654654
[workspace.dependencies.tokio-rustls]
655-
version = "0.26.3"
655+
version = "0.26.4"
656656

657657
# Tokio test utilities
658658
[workspace.dependencies.tokio-test]

crates/cli/src/commands/manage.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,10 @@ impl Options {
390390
info!("The following users can request admin privileges ({total} total):");
391391
loop {
392392
let page = repo.user().list(filter, cursor).await?;
393-
for user in page.edges {
393+
for edge in page.edges {
394+
let user = edge.node;
394395
info!(%user.id, username = %user.username);
395-
cursor = cursor.after(user.id);
396+
cursor = cursor.after(edge.cursor);
396397
}
397398

398399
if !page.has_next_page {

crates/cli/src/sync.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ pub async fn config_sync(
132132
let mut existing_enabled_ids = BTreeSet::new();
133133
let mut existing_disabled = BTreeMap::new();
134134
// Process the existing providers
135-
for provider in page.edges {
135+
for edge in page.edges {
136+
let provider = edge.node;
136137
if provider.enabled() {
137138
if config_ids.contains(&provider.id) {
138139
existing_enabled_ids.insert(provider.id);

crates/handlers/src/admin/response.rs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#![allow(clippy::module_name_repetitions)]
88

9-
use mas_storage::Pagination;
9+
use mas_storage::{Pagination, pagination::Edge};
1010
use schemars::JsonSchema;
1111
use serde::Serialize;
1212
use ulid::Ulid;
@@ -119,22 +119,26 @@ impl<T: Resource> PaginatedResponse<T> {
119119
base,
120120
current_pagination
121121
.clear_before()
122-
.after(page.edges.last().unwrap().id()),
122+
.after(page.edges.last().unwrap().cursor),
123123
)
124124
}),
125125
prev: if page.has_previous_page {
126126
Some(url_with_pagination(
127127
base,
128128
current_pagination
129129
.clear_after()
130-
.before(page.edges.first().unwrap().id()),
130+
.before(page.edges.first().unwrap().cursor),
131131
))
132132
} else {
133133
None
134134
},
135135
};
136136

137-
let data = page.edges.into_iter().map(SingleResource::new).collect();
137+
let data = page
138+
.edges
139+
.into_iter()
140+
.map(SingleResource::from_edge)
141+
.collect();
138142

139143
Self {
140144
meta: PaginationMeta { count },
@@ -176,6 +180,31 @@ struct SingleResource<T> {
176180

177181
/// Related links
178182
links: SelfLinks,
183+
184+
/// Metadata about the resource
185+
#[serde(skip_serializing_if = "SingleResourceMeta::is_empty")]
186+
meta: SingleResourceMeta,
187+
}
188+
189+
/// Metadata associated with a resource
190+
#[derive(Serialize, JsonSchema)]
191+
struct SingleResourceMeta {
192+
/// Information about the pagination of the resource
193+
#[serde(skip_serializing_if = "Option::is_none")]
194+
page: Option<SingleResourceMetaPage>,
195+
}
196+
197+
impl SingleResourceMeta {
198+
fn is_empty(&self) -> bool {
199+
self.page.is_none()
200+
}
201+
}
202+
203+
/// Pagination metadata for a resource
204+
#[derive(Serialize, JsonSchema)]
205+
struct SingleResourceMetaPage {
206+
/// The cursor of this resource in the paginated result
207+
cursor: String,
179208
}
180209

181210
impl<T: Resource> SingleResource<T> {
@@ -186,8 +215,16 @@ impl<T: Resource> SingleResource<T> {
186215
id: resource.id(),
187216
attributes: resource,
188217
links: SelfLinks { self_ },
218+
meta: SingleResourceMeta { page: None },
189219
}
190220
}
221+
222+
fn from_edge<C: ToString>(edge: Edge<T, C>) -> Self {
223+
let cursor = edge.cursor.to_string();
224+
let mut resource = Self::new(edge.node);
225+
resource.meta.page = Some(SingleResourceMetaPage { cursor });
226+
resource
227+
}
191228
}
192229

193230
/// Related links

0 commit comments

Comments
 (0)