From 644fe7514b0a3f85755ef22755ee034eabdb493d Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Wed, 21 Aug 2024 14:15:28 -0400 Subject: [PATCH] Init NPM Support --- nitro_repo/src/repository/mod.rs | 1 + nitro_repo/src/repository/npm/mod.rs | 48 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 nitro_repo/src/repository/npm/mod.rs diff --git a/nitro_repo/src/repository/mod.rs b/nitro_repo/src/repository/mod.rs index 1c12be7a..95cd99da 100644 --- a/nitro_repo/src/repository/mod.rs +++ b/nitro_repo/src/repository/mod.rs @@ -20,6 +20,7 @@ pub use staging::*; mod repo_http; pub use repo_http::*; pub mod maven; +pub mod npm; mod repo_type; pub use repo_type::*; use thiserror::Error; diff --git a/nitro_repo/src/repository/npm/mod.rs b/nitro_repo/src/repository/npm/mod.rs new file mode 100644 index 00000000..731d0998 --- /dev/null +++ b/nitro_repo/src/repository/npm/mod.rs @@ -0,0 +1,48 @@ +//! NPM Registry Implementation +//! +//! Documentation for NPM: https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md + +use ahash::HashMap; +use chrono::{DateTime, FixedOffset}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +#[derive(Debug, Clone)] +pub struct RegistryResponse { + pub db_name: String, + pub engine: String, + pub doc_count: u64, + pub doc_del_count: u64, + pub update_seq: u64, + pub purge_seq: u64, + pub compact_running: bool, + // TODO: Add more fields +} +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct NpmRegistryPackage { + #[serde(rename = "_id")] + pub id: String, + #[serde(rename = "_rev")] + pub rev: String, + pub name: String, + pub description: Option, + #[serde(rename = "dist-tags")] + pub dist_tags: HashMap, + pub versions: HashMap, + pub time: HashMap, +} +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct NPMRegistryPackageTime { + pub created: String, + pub modified: DateTime, + #[serde(flatten)] + pub versions: HashMap, +} +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Maintainers { + pub name: String, + pub email: String, +} +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Bugs { + pub url: String, +}