1mod ids;
2mod queries;
3mod tables;
4#[cfg(test)]
5pub mod tests;
6
7use crate::{executor::Executor, Error, Result};
8use anyhow::anyhow;
9use collections::{BTreeMap, HashMap, HashSet};
10use dashmap::DashMap;
11use futures::StreamExt;
12use rand::{prelude::StdRng, Rng, SeedableRng};
13use rpc::{
14 proto::{self},
15 ConnectionId, ExtensionMetadata,
16};
17use sea_orm::{
18 entity::prelude::*,
19 sea_query::{Alias, Expr, OnConflict},
20 ActiveValue, Condition, ConnectionTrait, DatabaseConnection, DatabaseTransaction, DbErr,
21 FromQueryResult, IntoActiveModel, IsolationLevel, JoinType, QueryOrder, QuerySelect, Statement,
22 TransactionTrait,
23};
24use semantic_version::SemanticVersion;
25use serde::{Deserialize, Serialize};
26use std::ops::RangeInclusive;
27use std::{
28 fmt::Write as _,
29 future::Future,
30 marker::PhantomData,
31 ops::{Deref, DerefMut},
32 rc::Rc,
33 sync::Arc,
34 time::Duration,
35};
36use time::PrimitiveDateTime;
37use tokio::sync::{Mutex, OwnedMutexGuard};
38
39#[cfg(test)]
40pub use tests::TestDb;
41
42pub use ids::*;
43pub use queries::billing_customers::{CreateBillingCustomerParams, UpdateBillingCustomerParams};
44pub use queries::billing_subscriptions::{
45 CreateBillingSubscriptionParams, UpdateBillingSubscriptionParams,
46};
47pub use queries::contributors::ContributorSelector;
48pub use queries::processed_stripe_events::CreateProcessedStripeEventParams;
49pub use sea_orm::ConnectOptions;
50pub use tables::user::Model as User;
51pub use tables::*;
52
53/// Database gives you a handle that lets you access the database.
54/// It handles pooling internally.
55pub struct Database {
56 options: ConnectOptions,
57 pool: DatabaseConnection,
58 rooms: DashMap<RoomId, Arc<Mutex<()>>>,
59 projects: DashMap<ProjectId, Arc<Mutex<()>>>,
60 rng: Mutex<StdRng>,
61 executor: Executor,
62 notification_kinds_by_id: HashMap<NotificationKindId, &'static str>,
63 notification_kinds_by_name: HashMap<String, NotificationKindId>,
64 #[cfg(test)]
65 runtime: Option<tokio::runtime::Runtime>,
66}
67
68// The `Database` type has so many methods that its impl blocks are split into
69// separate files in the `queries` folder.
70impl Database {
71 /// Connects to the database with the given options
72 pub async fn new(options: ConnectOptions, executor: Executor) -> Result<Self> {
73 sqlx::any::install_default_drivers();
74 Ok(Self {
75 options: options.clone(),
76 pool: sea_orm::Database::connect(options).await?,
77 rooms: DashMap::with_capacity(16384),
78 projects: DashMap::with_capacity(16384),
79 rng: Mutex::new(StdRng::seed_from_u64(0)),
80 notification_kinds_by_id: HashMap::default(),
81 notification_kinds_by_name: HashMap::default(),
82 executor,
83 #[cfg(test)]
84 runtime: None,
85 })
86 }
87
88 pub fn options(&self) -> &ConnectOptions {
89 &self.options
90 }
91
92 #[cfg(test)]
93 pub fn reset(&self) {
94 self.rooms.clear();
95 self.projects.clear();
96 }
97
98 /// Transaction runs things in a transaction. If you want to call other methods
99 /// and pass the transaction around you need to reborrow the transaction at each
100 /// call site with: `&*tx`.
101 pub async fn transaction<F, Fut, T>(&self, f: F) -> Result<T>
102 where
103 F: Send + Fn(TransactionHandle) -> Fut,
104 Fut: Send + Future<Output = Result<T>>,
105 {
106 let body = async {
107 let mut i = 0;
108 loop {
109 let (tx, result) = self.with_transaction(&f).await?;
110 match result {
111 Ok(result) => match tx.commit().await.map_err(Into::into) {
112 Ok(()) => return Ok(result),
113 Err(error) => {
114 if !self.retry_on_serialization_error(&error, i).await {
115 return Err(error);
116 }
117 }
118 },
119 Err(error) => {
120 tx.rollback().await?;
121 if !self.retry_on_serialization_error(&error, i).await {
122 return Err(error);
123 }
124 }
125 }
126 i += 1;
127 }
128 };
129
130 self.run(body).await
131 }
132
133 pub async fn weak_transaction<F, Fut, T>(&self, f: F) -> Result<T>
134 where
135 F: Send + Fn(TransactionHandle) -> Fut,
136 Fut: Send + Future<Output = Result<T>>,
137 {
138 let body = async {
139 let (tx, result) = self.with_weak_transaction(&f).await?;
140 match result {
141 Ok(result) => match tx.commit().await.map_err(Into::into) {
142 Ok(()) => return Ok(result),
143 Err(error) => {
144 return Err(error);
145 }
146 },
147 Err(error) => {
148 tx.rollback().await?;
149 return Err(error);
150 }
151 }
152 };
153
154 self.run(body).await
155 }
156
157 /// The same as room_transaction, but if you need to only optionally return a Room.
158 async fn optional_room_transaction<F, Fut, T>(
159 &self,
160 f: F,
161 ) -> Result<Option<TransactionGuard<T>>>
162 where
163 F: Send + Fn(TransactionHandle) -> Fut,
164 Fut: Send + Future<Output = Result<Option<(RoomId, T)>>>,
165 {
166 let body = async {
167 let mut i = 0;
168 loop {
169 let (tx, result) = self.with_transaction(&f).await?;
170 match result {
171 Ok(Some((room_id, data))) => {
172 let lock = self.rooms.entry(room_id).or_default().clone();
173 let _guard = lock.lock_owned().await;
174 match tx.commit().await.map_err(Into::into) {
175 Ok(()) => {
176 return Ok(Some(TransactionGuard {
177 data,
178 _guard,
179 _not_send: PhantomData,
180 }));
181 }
182 Err(error) => {
183 if !self.retry_on_serialization_error(&error, i).await {
184 return Err(error);
185 }
186 }
187 }
188 }
189 Ok(None) => match tx.commit().await.map_err(Into::into) {
190 Ok(()) => return Ok(None),
191 Err(error) => {
192 if !self.retry_on_serialization_error(&error, i).await {
193 return Err(error);
194 }
195 }
196 },
197 Err(error) => {
198 tx.rollback().await?;
199 if !self.retry_on_serialization_error(&error, i).await {
200 return Err(error);
201 }
202 }
203 }
204 i += 1;
205 }
206 };
207
208 self.run(body).await
209 }
210
211 async fn project_transaction<F, Fut, T>(
212 &self,
213 project_id: ProjectId,
214 f: F,
215 ) -> Result<TransactionGuard<T>>
216 where
217 F: Send + Fn(TransactionHandle) -> Fut,
218 Fut: Send + Future<Output = Result<T>>,
219 {
220 let room_id = Database::room_id_for_project(&self, project_id).await?;
221 let body = async {
222 let mut i = 0;
223 loop {
224 let lock = if let Some(room_id) = room_id {
225 self.rooms.entry(room_id).or_default().clone()
226 } else {
227 self.projects.entry(project_id).or_default().clone()
228 };
229 let _guard = lock.lock_owned().await;
230 let (tx, result) = self.with_transaction(&f).await?;
231 match result {
232 Ok(data) => match tx.commit().await.map_err(Into::into) {
233 Ok(()) => {
234 return Ok(TransactionGuard {
235 data,
236 _guard,
237 _not_send: PhantomData,
238 });
239 }
240 Err(error) => {
241 if !self.retry_on_serialization_error(&error, i).await {
242 return Err(error);
243 }
244 }
245 },
246 Err(error) => {
247 tx.rollback().await?;
248 if !self.retry_on_serialization_error(&error, i).await {
249 return Err(error);
250 }
251 }
252 }
253 i += 1;
254 }
255 };
256
257 self.run(body).await
258 }
259
260 /// room_transaction runs the block in a transaction. It returns a RoomGuard, that keeps
261 /// the database locked until it is dropped. This ensures that updates sent to clients are
262 /// properly serialized with respect to database changes.
263 async fn room_transaction<F, Fut, T>(
264 &self,
265 room_id: RoomId,
266 f: F,
267 ) -> Result<TransactionGuard<T>>
268 where
269 F: Send + Fn(TransactionHandle) -> Fut,
270 Fut: Send + Future<Output = Result<T>>,
271 {
272 let body = async {
273 let mut i = 0;
274 loop {
275 let lock = self.rooms.entry(room_id).or_default().clone();
276 let _guard = lock.lock_owned().await;
277 let (tx, result) = self.with_transaction(&f).await?;
278 match result {
279 Ok(data) => match tx.commit().await.map_err(Into::into) {
280 Ok(()) => {
281 return Ok(TransactionGuard {
282 data,
283 _guard,
284 _not_send: PhantomData,
285 });
286 }
287 Err(error) => {
288 if !self.retry_on_serialization_error(&error, i).await {
289 return Err(error);
290 }
291 }
292 },
293 Err(error) => {
294 tx.rollback().await?;
295 if !self.retry_on_serialization_error(&error, i).await {
296 return Err(error);
297 }
298 }
299 }
300 i += 1;
301 }
302 };
303
304 self.run(body).await
305 }
306
307 async fn with_transaction<F, Fut, T>(&self, f: &F) -> Result<(DatabaseTransaction, Result<T>)>
308 where
309 F: Send + Fn(TransactionHandle) -> Fut,
310 Fut: Send + Future<Output = Result<T>>,
311 {
312 let tx = self
313 .pool
314 .begin_with_config(Some(IsolationLevel::Serializable), None)
315 .await?;
316
317 let mut tx = Arc::new(Some(tx));
318 let result = f(TransactionHandle(tx.clone())).await;
319 let Some(tx) = Arc::get_mut(&mut tx).and_then(|tx| tx.take()) else {
320 return Err(anyhow!(
321 "couldn't complete transaction because it's still in use"
322 ))?;
323 };
324
325 Ok((tx, result))
326 }
327
328 async fn with_weak_transaction<F, Fut, T>(
329 &self,
330 f: &F,
331 ) -> Result<(DatabaseTransaction, Result<T>)>
332 where
333 F: Send + Fn(TransactionHandle) -> Fut,
334 Fut: Send + Future<Output = Result<T>>,
335 {
336 let tx = self
337 .pool
338 .begin_with_config(Some(IsolationLevel::ReadCommitted), None)
339 .await?;
340
341 let mut tx = Arc::new(Some(tx));
342 let result = f(TransactionHandle(tx.clone())).await;
343 let Some(tx) = Arc::get_mut(&mut tx).and_then(|tx| tx.take()) else {
344 return Err(anyhow!(
345 "couldn't complete transaction because it's still in use"
346 ))?;
347 };
348
349 Ok((tx, result))
350 }
351
352 async fn run<F, T>(&self, future: F) -> Result<T>
353 where
354 F: Future<Output = Result<T>>,
355 {
356 #[cfg(test)]
357 {
358 if let Executor::Deterministic(executor) = &self.executor {
359 executor.simulate_random_delay().await;
360 }
361
362 self.runtime.as_ref().unwrap().block_on(future)
363 }
364
365 #[cfg(not(test))]
366 {
367 future.await
368 }
369 }
370
371 async fn retry_on_serialization_error(&self, error: &Error, prev_attempt_count: usize) -> bool {
372 // If the error is due to a failure to serialize concurrent transactions, then retry
373 // this transaction after a delay. With each subsequent retry, double the delay duration.
374 // Also vary the delay randomly in order to ensure different database connections retry
375 // at different times.
376 const SLEEPS: [f32; 10] = [10., 20., 40., 80., 160., 320., 640., 1280., 2560., 5120.];
377 if is_serialization_error(error) && prev_attempt_count < SLEEPS.len() {
378 let base_delay = SLEEPS[prev_attempt_count];
379 let randomized_delay = base_delay * self.rng.lock().await.gen_range(0.5..=2.0);
380 log::warn!(
381 "retrying transaction after serialization error. delay: {} ms.",
382 randomized_delay
383 );
384 self.executor
385 .sleep(Duration::from_millis(randomized_delay as u64))
386 .await;
387 true
388 } else {
389 false
390 }
391 }
392}
393
394fn is_serialization_error(error: &Error) -> bool {
395 const SERIALIZATION_FAILURE_CODE: &str = "40001";
396 match error {
397 Error::Database(
398 DbErr::Exec(sea_orm::RuntimeErr::SqlxError(error))
399 | DbErr::Query(sea_orm::RuntimeErr::SqlxError(error)),
400 ) if error
401 .as_database_error()
402 .and_then(|error| error.code())
403 .as_deref()
404 == Some(SERIALIZATION_FAILURE_CODE) =>
405 {
406 true
407 }
408 _ => false,
409 }
410}
411
412/// A handle to a [`DatabaseTransaction`].
413pub struct TransactionHandle(pub(crate) Arc<Option<DatabaseTransaction>>);
414
415impl Deref for TransactionHandle {
416 type Target = DatabaseTransaction;
417
418 fn deref(&self) -> &Self::Target {
419 self.0.as_ref().as_ref().unwrap()
420 }
421}
422
423/// [`TransactionGuard`] keeps a database transaction alive until it is dropped.
424/// It wraps data that depends on the state of the database and prevents an additional
425/// transaction from starting that would invalidate that data.
426pub struct TransactionGuard<T> {
427 data: T,
428 _guard: OwnedMutexGuard<()>,
429 _not_send: PhantomData<Rc<()>>,
430}
431
432impl<T> Deref for TransactionGuard<T> {
433 type Target = T;
434
435 fn deref(&self) -> &T {
436 &self.data
437 }
438}
439
440impl<T> DerefMut for TransactionGuard<T> {
441 fn deref_mut(&mut self) -> &mut T {
442 &mut self.data
443 }
444}
445
446impl<T> TransactionGuard<T> {
447 /// Returns the inner value of the guard.
448 pub fn into_inner(self) -> T {
449 self.data
450 }
451}
452
453#[derive(Clone, Debug, PartialEq, Eq)]
454pub enum Contact {
455 Accepted { user_id: UserId, busy: bool },
456 Outgoing { user_id: UserId },
457 Incoming { user_id: UserId },
458}
459
460impl Contact {
461 pub fn user_id(&self) -> UserId {
462 match self {
463 Contact::Accepted { user_id, .. } => *user_id,
464 Contact::Outgoing { user_id } => *user_id,
465 Contact::Incoming { user_id, .. } => *user_id,
466 }
467 }
468}
469
470pub type NotificationBatch = Vec<(UserId, proto::Notification)>;
471
472pub struct CreatedChannelMessage {
473 pub message_id: MessageId,
474 pub participant_connection_ids: HashSet<ConnectionId>,
475 pub notifications: NotificationBatch,
476}
477
478pub struct UpdatedChannelMessage {
479 pub message_id: MessageId,
480 pub participant_connection_ids: Vec<ConnectionId>,
481 pub notifications: NotificationBatch,
482 pub reply_to_message_id: Option<MessageId>,
483 pub timestamp: PrimitiveDateTime,
484 pub deleted_mention_notification_ids: Vec<NotificationId>,
485 pub updated_mention_notifications: Vec<rpc::proto::Notification>,
486}
487
488#[derive(Clone, Debug, PartialEq, Eq, FromQueryResult, Serialize, Deserialize)]
489pub struct Invite {
490 pub email_address: String,
491 pub email_confirmation_code: String,
492}
493
494#[derive(Clone, Debug, Deserialize)]
495pub struct NewSignup {
496 pub email_address: String,
497 pub platform_mac: bool,
498 pub platform_windows: bool,
499 pub platform_linux: bool,
500 pub editor_features: Vec<String>,
501 pub programming_languages: Vec<String>,
502 pub device_id: Option<String>,
503 pub added_to_mailing_list: bool,
504 pub created_at: Option<DateTime>,
505}
506
507#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, FromQueryResult)]
508pub struct WaitlistSummary {
509 pub count: i64,
510 pub linux_count: i64,
511 pub mac_count: i64,
512 pub windows_count: i64,
513 pub unknown_count: i64,
514}
515
516/// The parameters to create a new user.
517#[derive(Debug, Serialize, Deserialize)]
518pub struct NewUserParams {
519 pub github_login: String,
520 pub github_user_id: i32,
521}
522
523/// The result of creating a new user.
524#[derive(Debug)]
525pub struct NewUserResult {
526 pub user_id: UserId,
527 pub metrics_id: String,
528 pub inviting_user_id: Option<UserId>,
529 pub signup_device_id: Option<String>,
530}
531
532/// The result of updating a channel membership.
533#[derive(Debug)]
534pub struct MembershipUpdated {
535 pub channel_id: ChannelId,
536 pub new_channels: ChannelsForUser,
537 pub removed_channels: Vec<ChannelId>,
538}
539
540/// The result of setting a member's role.
541#[derive(Debug)]
542#[allow(clippy::large_enum_variant)]
543pub enum SetMemberRoleResult {
544 InviteUpdated(Channel),
545 MembershipUpdated(MembershipUpdated),
546}
547
548/// The result of inviting a member to a channel.
549#[derive(Debug)]
550pub struct InviteMemberResult {
551 pub channel: Channel,
552 pub notifications: NotificationBatch,
553}
554
555#[derive(Debug)]
556pub struct RespondToChannelInvite {
557 pub membership_update: Option<MembershipUpdated>,
558 pub notifications: NotificationBatch,
559}
560
561#[derive(Debug)]
562pub struct RemoveChannelMemberResult {
563 pub membership_update: MembershipUpdated,
564 pub notification_id: Option<NotificationId>,
565}
566
567#[derive(Debug, PartialEq, Eq, Hash)]
568pub struct Channel {
569 pub id: ChannelId,
570 pub name: String,
571 pub visibility: ChannelVisibility,
572 /// parent_path is the channel ids from the root to this one (not including this one)
573 pub parent_path: Vec<ChannelId>,
574}
575
576impl Channel {
577 pub fn from_model(value: channel::Model) -> Self {
578 Channel {
579 id: value.id,
580 visibility: value.visibility,
581 name: value.clone().name,
582 parent_path: value.ancestors().collect(),
583 }
584 }
585
586 pub fn to_proto(&self) -> proto::Channel {
587 proto::Channel {
588 id: self.id.to_proto(),
589 name: self.name.clone(),
590 visibility: self.visibility.into(),
591 parent_path: self.parent_path.iter().map(|c| c.to_proto()).collect(),
592 }
593 }
594}
595
596#[derive(Debug, PartialEq, Eq, Hash)]
597pub struct ChannelMember {
598 pub role: ChannelRole,
599 pub user_id: UserId,
600 pub kind: proto::channel_member::Kind,
601}
602
603impl ChannelMember {
604 pub fn to_proto(&self) -> proto::ChannelMember {
605 proto::ChannelMember {
606 role: self.role.into(),
607 user_id: self.user_id.to_proto(),
608 kind: self.kind.into(),
609 }
610 }
611}
612
613#[derive(Debug, PartialEq)]
614pub struct ChannelsForUser {
615 pub channels: Vec<Channel>,
616 pub channel_memberships: Vec<channel_member::Model>,
617 pub channel_participants: HashMap<ChannelId, Vec<UserId>>,
618 pub hosted_projects: Vec<proto::HostedProject>,
619 pub invited_channels: Vec<Channel>,
620
621 pub observed_buffer_versions: Vec<proto::ChannelBufferVersion>,
622 pub observed_channel_messages: Vec<proto::ChannelMessageId>,
623 pub latest_buffer_versions: Vec<proto::ChannelBufferVersion>,
624 pub latest_channel_messages: Vec<proto::ChannelMessageId>,
625}
626
627#[derive(Debug)]
628pub struct RejoinedChannelBuffer {
629 pub buffer: proto::RejoinedChannelBuffer,
630 pub old_connection_id: ConnectionId,
631}
632
633#[derive(Clone)]
634pub struct JoinRoom {
635 pub room: proto::Room,
636 pub channel: Option<channel::Model>,
637}
638
639pub struct RejoinedRoom {
640 pub room: proto::Room,
641 pub rejoined_projects: Vec<RejoinedProject>,
642 pub reshared_projects: Vec<ResharedProject>,
643 pub channel: Option<channel::Model>,
644}
645
646pub struct ResharedProject {
647 pub id: ProjectId,
648 pub old_connection_id: ConnectionId,
649 pub collaborators: Vec<ProjectCollaborator>,
650 pub worktrees: Vec<proto::WorktreeMetadata>,
651}
652
653pub struct RejoinedProject {
654 pub id: ProjectId,
655 pub old_connection_id: ConnectionId,
656 pub collaborators: Vec<ProjectCollaborator>,
657 pub worktrees: Vec<RejoinedWorktree>,
658 pub language_servers: Vec<proto::LanguageServer>,
659}
660
661impl RejoinedProject {
662 pub fn to_proto(&self) -> proto::RejoinedProject {
663 proto::RejoinedProject {
664 id: self.id.to_proto(),
665 worktrees: self
666 .worktrees
667 .iter()
668 .map(|worktree| proto::WorktreeMetadata {
669 id: worktree.id,
670 root_name: worktree.root_name.clone(),
671 visible: worktree.visible,
672 abs_path: worktree.abs_path.clone(),
673 })
674 .collect(),
675 collaborators: self
676 .collaborators
677 .iter()
678 .map(|collaborator| collaborator.to_proto())
679 .collect(),
680 language_servers: self.language_servers.clone(),
681 }
682 }
683}
684
685#[derive(Debug)]
686pub struct RejoinedWorktree {
687 pub id: u64,
688 pub abs_path: String,
689 pub root_name: String,
690 pub visible: bool,
691 pub updated_entries: Vec<proto::Entry>,
692 pub removed_entries: Vec<u64>,
693 pub updated_repositories: Vec<proto::RepositoryEntry>,
694 pub removed_repositories: Vec<u64>,
695 pub diagnostic_summaries: Vec<proto::DiagnosticSummary>,
696 pub settings_files: Vec<WorktreeSettingsFile>,
697 pub scan_id: u64,
698 pub completed_scan_id: u64,
699}
700
701pub struct LeftRoom {
702 pub room: proto::Room,
703 pub channel: Option<channel::Model>,
704 pub left_projects: HashMap<ProjectId, LeftProject>,
705 pub canceled_calls_to_user_ids: Vec<UserId>,
706 pub deleted: bool,
707}
708
709pub struct RefreshedRoom {
710 pub room: proto::Room,
711 pub channel: Option<channel::Model>,
712 pub stale_participant_user_ids: Vec<UserId>,
713 pub canceled_calls_to_user_ids: Vec<UserId>,
714}
715
716pub struct RefreshedChannelBuffer {
717 pub connection_ids: Vec<ConnectionId>,
718 pub collaborators: Vec<proto::Collaborator>,
719}
720
721pub struct Project {
722 pub id: ProjectId,
723 pub role: ChannelRole,
724 pub collaborators: Vec<ProjectCollaborator>,
725 pub worktrees: BTreeMap<u64, Worktree>,
726 pub language_servers: Vec<proto::LanguageServer>,
727 pub dev_server_project_id: Option<DevServerProjectId>,
728}
729
730pub struct ProjectCollaborator {
731 pub connection_id: ConnectionId,
732 pub user_id: UserId,
733 pub replica_id: ReplicaId,
734 pub is_host: bool,
735}
736
737impl ProjectCollaborator {
738 pub fn to_proto(&self) -> proto::Collaborator {
739 proto::Collaborator {
740 peer_id: Some(self.connection_id.into()),
741 replica_id: self.replica_id.0 as u32,
742 user_id: self.user_id.to_proto(),
743 }
744 }
745}
746
747#[derive(Debug)]
748pub struct LeftProject {
749 pub id: ProjectId,
750 pub should_unshare: bool,
751 pub connection_ids: Vec<ConnectionId>,
752}
753
754pub struct Worktree {
755 pub id: u64,
756 pub abs_path: String,
757 pub root_name: String,
758 pub visible: bool,
759 pub entries: Vec<proto::Entry>,
760 pub repository_entries: BTreeMap<u64, proto::RepositoryEntry>,
761 pub diagnostic_summaries: Vec<proto::DiagnosticSummary>,
762 pub settings_files: Vec<WorktreeSettingsFile>,
763 pub scan_id: u64,
764 pub completed_scan_id: u64,
765}
766
767#[derive(Debug)]
768pub struct WorktreeSettingsFile {
769 pub path: String,
770 pub content: String,
771}
772
773pub struct NewExtensionVersion {
774 pub name: String,
775 pub version: semver::Version,
776 pub description: String,
777 pub authors: Vec<String>,
778 pub repository: String,
779 pub schema_version: i32,
780 pub wasm_api_version: Option<String>,
781 pub published_at: PrimitiveDateTime,
782}
783
784pub struct ExtensionVersionConstraints {
785 pub schema_versions: RangeInclusive<i32>,
786 pub wasm_api_versions: RangeInclusive<SemanticVersion>,
787}