Compare commits
41 Commits
v0.1.0
...
main-v0.1.
Author | SHA1 | Date | |
---|---|---|---|
805ea3a9ae | |||
db724f4f26 | |||
1fd2704a9c | |||
c8bab6f0e4 | |||
38a5a95bfd | |||
2050a9be0e | |||
7bde1f3918 | |||
be2025cc0f | |||
81d4f5a2cf | |||
554670d705 | |||
7fdf1e42e9 | |||
6854a5e14d | |||
5d89ccb7c1 | |||
e429534100 | |||
1881650e9c | |||
e9ae99520c | |||
cd0ab2dec6 | |||
5d20d8576f | |||
3979a59665 | |||
a2371b7bf1 | |||
6bed8590ca | |||
daeb208448 | |||
9ffc1aad05 | |||
a08a879f5a | |||
d4b415dca3 | |||
55b51db4a0 | |||
76e28fc626 | |||
7b5cb41f4a | |||
fc362e4e21 | |||
689dbaf29a | |||
36ac93414b | |||
5b92d8857c | |||
03f5647d53 | |||
448c81fd1e | |||
c6d17b4904 | |||
f52f9d65fd | |||
67aaba4fbf | |||
f8662b6020 | |||
e7517f94dc | |||
98e187056d | |||
2bd6fd8f85 |
@@ -1,6 +1,7 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- version
|
||||
- deploy
|
||||
|
||||
build:
|
||||
@@ -8,9 +9,10 @@ build:
|
||||
image: rust:1.85
|
||||
script:
|
||||
- cargo build --release
|
||||
- ls -R target/release/
|
||||
artifacts:
|
||||
paths:
|
||||
- target/release/icarus-models
|
||||
- target/release/
|
||||
expire_in: 1 week
|
||||
cache:
|
||||
key: "cargo-cache"
|
||||
@@ -29,15 +31,51 @@ test:
|
||||
- target/
|
||||
- ~/.cargo/
|
||||
|
||||
test_variable:
|
||||
stage: test
|
||||
image: rust:1.85
|
||||
script:
|
||||
- echo "Checking CARGO_LOGIN_TOKEN..."
|
||||
- if [[ -z "$CARGO_LOGIN_TOKEN" ]]; then echo "CARGO_LOGIN_TOKEN is empty!"; exit 1; else echo "CARGO_LOGIN_TOKEN is set."; fi
|
||||
- env
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
|
||||
extract_version:
|
||||
stage: version
|
||||
image: alpine:latest
|
||||
script:
|
||||
- apk add --no-cache jq
|
||||
- VERSION=$(grep 'version = "' Cargo.toml | awk -F'"' '{print $2}' | head -n 1)
|
||||
- if [ $? -ne 0 ]; then echo "Error extracting version"; exit 1; fi
|
||||
- echo "Extracted version is"
|
||||
- echo "$VERSION"
|
||||
- echo "VERSION=$VERSION" > version.env
|
||||
artifacts:
|
||||
reports:
|
||||
dotenv: version.env
|
||||
|
||||
tag_release:
|
||||
stage: deploy
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"'
|
||||
dependencies:
|
||||
- extract_version
|
||||
script:
|
||||
- release-cli create --name "Release $CI_COMMIT_BRANCH-v$VERSION" --tag-name "$CI_COMMIT_BRANCH-v$VERSION"
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
image: rust:1.85
|
||||
script:
|
||||
- echo "Printing environment"
|
||||
- env
|
||||
- cargo login "$CARGO_LOGIN_TOKEN"
|
||||
- cargo publish
|
||||
- echo "Deployment will be configured when this is ready for use"
|
||||
# - env
|
||||
# Uncomment when you are ready for this to be published
|
||||
# - cargo login "$CARGO_LOGIN_TOKEN"
|
||||
# - cargo publish
|
||||
dependencies:
|
||||
- build
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
[package]
|
||||
name = "icarus-models"
|
||||
version = "0.1.7"
|
||||
edition = "2024"
|
||||
description = "models used for the icarus project"
|
||||
license = "MIT"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.218", features = ["derive"] }
|
||||
|
@@ -19,6 +19,22 @@ impl Default for AccessLevel {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_level() -> AccessLevel {
|
||||
return AccessLevel {
|
||||
id: -1,
|
||||
level: String::from("Public"),
|
||||
song_id: -1,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn private_level() -> AccessLevel {
|
||||
return AccessLevel {
|
||||
id: -1,
|
||||
level: String::from("Private"),
|
||||
song_id: -1,
|
||||
};
|
||||
}
|
||||
|
||||
impl AccessLevel {
|
||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
|
5
src/constants.rs
Normal file
5
src/constants.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
pub const DEFAULT_MUSIC_EXTENSION: &str = FLAC_EXTENSION;
|
||||
pub const FLAC_EXTENSION: &str = ".flac";
|
||||
pub const WAV_EXTENSION: &str = ".wav";
|
||||
pub const MPTHREE_EXTENSION: &str = ".mp3";
|
||||
pub const JPG_EXTENSION: &str = ".jpg";
|
@@ -1,5 +1,9 @@
|
||||
pub mod access_level;
|
||||
pub mod constants;
|
||||
pub mod login_result;
|
||||
pub mod song;
|
||||
pub mod token;
|
||||
pub mod types;
|
||||
pub mod user;
|
||||
|
||||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
|
73
src/song.rs
Normal file
73
src/song.rs
Normal file
@@ -0,0 +1,73 @@
|
||||
use std::default::Default;
|
||||
use std::io::Read;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Song {
|
||||
#[serde(alias = "id")]
|
||||
pub id: Option<i32>,
|
||||
pub title: Option<String>,
|
||||
pub artist: Option<String>,
|
||||
pub album: Option<String>,
|
||||
pub album_artist: Option<String>,
|
||||
pub genre: Option<String>,
|
||||
pub year: Option<i32>,
|
||||
pub duration: Option<i32>,
|
||||
pub track: Option<i32>,
|
||||
pub disc: Option<i32>,
|
||||
pub disc_count: Option<i32>,
|
||||
pub track_count: Option<i32>,
|
||||
pub audio_type: Option<String>,
|
||||
pub date_created: Option<String>,
|
||||
pub filename: Option<String>,
|
||||
pub user_id: Option<i32>,
|
||||
#[serde(skip)]
|
||||
pub data: Option<Vec<u8>>,
|
||||
#[serde(skip)]
|
||||
pub directory: Option<String>,
|
||||
#[serde(skip)]
|
||||
pub album_id: Option<i32>,
|
||||
#[serde(skip)]
|
||||
pub artist_id: Option<i32>,
|
||||
#[serde(skip)]
|
||||
pub genre_id: Option<i32>,
|
||||
#[serde(skip)]
|
||||
pub coverart_id: Option<i32>,
|
||||
}
|
||||
|
||||
impl Default for Song {
|
||||
fn default() -> Self {
|
||||
Song {
|
||||
id: None,
|
||||
title: None,
|
||||
artist: None,
|
||||
album: None,
|
||||
album_artist: None,
|
||||
genre: None,
|
||||
year: None,
|
||||
duration: None,
|
||||
track: None,
|
||||
disc: None,
|
||||
disc_count: None,
|
||||
track_count: None,
|
||||
audio_type: None,
|
||||
date_created: None,
|
||||
filename: None,
|
||||
user_id: None,
|
||||
data: None,
|
||||
directory: None,
|
||||
album_id: None,
|
||||
artist_id: None,
|
||||
genre_id: None,
|
||||
coverart_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Song {
|
||||
// TODO: Implement
|
||||
pub fn to_metadata_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
}
|
||||
}
|
64
src/token.rs
Normal file
64
src/token.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
use std::default::Default;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Token {
|
||||
pub scope: String,
|
||||
pub expiration: i32,
|
||||
pub audience: String,
|
||||
pub issuer: String,
|
||||
pub issued: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct AccessToken {
|
||||
#[serde(alias = "user_id")]
|
||||
pub user_id: i32,
|
||||
#[serde(alias = "username")]
|
||||
pub username: String,
|
||||
#[serde(alias = "token")]
|
||||
pub token: String,
|
||||
#[serde(alias = "token_type")]
|
||||
pub token_type: String,
|
||||
#[serde(alias = "expiration")]
|
||||
pub expiration: i32,
|
||||
#[serde(alias = "message")]
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
impl Default for Token {
|
||||
fn default() -> Self {
|
||||
Token {
|
||||
scope: String::new(),
|
||||
expiration: -1,
|
||||
audience: String::new(),
|
||||
issuer: String::new(),
|
||||
issued: -1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AccessToken {
|
||||
pub fn bearer_token(&self) -> String {
|
||||
let mut token: String = String::from("Bearer ");
|
||||
token += &self.token.clone();
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
impl Token {
|
||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
pub fn token_expired(&self) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
pub fn contains_scope(&self, des_scope: String) -> bool {
|
||||
return false;
|
||||
}
|
||||
}
|
9
src/types.rs
Normal file
9
src/types.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use std::default::Default;
|
||||
|
||||
mod types {
|
||||
pub enum Types {
|
||||
WAV_EXTENSION,
|
||||
FLAC_EXTENSION,
|
||||
MP_EXTENSION,
|
||||
}
|
||||
}
|
22
src/user.rs
22
src/user.rs
@@ -4,19 +4,33 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct User {
|
||||
#[serde(skip_serializing_if = "is_id_valid")]
|
||||
pub id: i32,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub username: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub password: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub email: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub phone: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub firstname: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub lastname: String,
|
||||
pub email_verified: bool,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub date_created: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub status: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub last_login: String,
|
||||
}
|
||||
|
||||
fn is_id_valid(num: &i32) -> bool {
|
||||
*num > 0
|
||||
}
|
||||
|
||||
impl Default for User {
|
||||
fn default() -> Self {
|
||||
User {
|
||||
@@ -36,7 +50,11 @@ impl Default for User {
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
pub fn to_json(&self, output_pretty: bool) -> Result<String, serde_json::Error> {
|
||||
if output_pretty {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
} else {
|
||||
return serde_json::to_string(&self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user