add time
This commit is contained in:
parent
08192e1687
commit
5ec49db2ce
23 changed files with 131 additions and 35 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -3478,9 +3478,15 @@ dependencies = [
|
||||||
name = "panorama-app-sdk"
|
name = "panorama-app-sdk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"panorama-app-sdk-macros",
|
||||||
"wee_alloc",
|
"wee_alloc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "panorama-app-sdk-macros"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "panorama-core"
|
name = "panorama-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -3514,11 +3520,13 @@ dependencies = [
|
||||||
"async-imap",
|
"async-imap",
|
||||||
"axum",
|
"axum",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"clap",
|
||||||
"csv",
|
"csv",
|
||||||
"dirs 5.0.1",
|
"dirs 5.0.1",
|
||||||
"futures",
|
"futures",
|
||||||
"itertools 0.13.0",
|
"itertools 0.13.0",
|
||||||
"panorama-core",
|
"panorama-core",
|
||||||
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sugars",
|
"sugars",
|
||||||
|
@ -3536,6 +3544,7 @@ dependencies = [
|
||||||
name = "panorama-journal"
|
name = "panorama-journal"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
"panorama-app-sdk",
|
"panorama-app-sdk",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -7,4 +7,5 @@ edition = "2021"
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
chrono = "0.4.38"
|
||||||
panorama-app-sdk = { path = "../../crates/panorama-app-sdk" }
|
panorama-app-sdk = { path = "../../crates/panorama-app-sdk" }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: journal
|
name: "@panorama/journal"
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
panorama_version: 0.1.0
|
panorama_version: 0.1.0
|
||||||
description: Note taking app
|
description: Note taking app
|
||||||
|
@ -6,9 +6,22 @@ description: Note taking app
|
||||||
# installer_path: ../../target/wasm32-unknown-unknown/wasm-release/panorama_journal.wasm
|
# installer_path: ../../target/wasm32-unknown-unknown/wasm-release/panorama_journal.wasm
|
||||||
installer_path: ../../target/wasm32-unknown-unknown/wasm-debug/panorama_journal.wasm
|
installer_path: ../../target/wasm32-unknown-unknown/wasm-debug/panorama_journal.wasm
|
||||||
|
|
||||||
|
node_types:
|
||||||
|
- name: page
|
||||||
|
- name: block
|
||||||
|
|
||||||
|
keys:
|
||||||
|
- name: page/content
|
||||||
|
type: text
|
||||||
|
|
||||||
|
- name: page/day
|
||||||
|
type: date
|
||||||
|
|
||||||
endpoints:
|
endpoints:
|
||||||
- url: /date/:date
|
- url: /date/:date
|
||||||
method: GET
|
method: GET
|
||||||
export_name: get_date_info
|
export_name: get_date_info
|
||||||
|
permissions:
|
||||||
|
- "@panorama/current_time"
|
||||||
|
|
||||||
triggers:
|
triggers:
|
|
@ -3,12 +3,7 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate panorama_app_sdk;
|
extern crate panorama_app_sdk;
|
||||||
|
|
||||||
use panorama_app_sdk::prelude::*;
|
|
||||||
|
|
||||||
panorama_app_sdk::init!();
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn install() -> i32 {
|
pub fn get_date_info() {
|
||||||
println!("SHIET");
|
panorama_app_sdk::get_current_time();
|
||||||
123
|
|
||||||
}
|
}
|
||||||
|
|
9
crates/panorama-app-sdk-macros/Cargo.toml
Normal file
9
crates/panorama-app-sdk-macros/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "panorama-app-sdk-macros"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
proc-macro = true
|
||||||
|
|
||||||
|
[dependencies]
|
1
crates/panorama-app-sdk-macros/src/lib.rs
Normal file
1
crates/panorama-app-sdk-macros/src/lib.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -8,3 +8,5 @@ crate-type = ["rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wee_alloc = "0.4.5"
|
wee_alloc = "0.4.5"
|
||||||
|
panorama-app-sdk-macros = { path = "../panorama-app-sdk-macros" }
|
||||||
|
chrono = "0.4.38"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
pub extern crate wee_alloc;
|
pub extern crate wee_alloc;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -13,6 +15,10 @@ pub mod macros;
|
||||||
pub mod internal;
|
pub mod internal;
|
||||||
pub mod sys;
|
pub mod sys;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {}
|
||||||
// pub use crate::macros::println;
|
|
||||||
|
/// Returns the current time
|
||||||
|
pub fn get_current_time() -> DateTime<Utc> {
|
||||||
|
let result = unsafe { sys::_get_current_time() };
|
||||||
|
DateTime::from_timestamp_nanos(result)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,7 @@ extern "C" {
|
||||||
// callback: *mut RegisterCallback,
|
// callback: *mut RegisterCallback,
|
||||||
callback_data: *mut c_void,
|
callback_data: *mut c_void,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Returns the current time in nanoseconds
|
||||||
|
pub fn _get_current_time() -> i64;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::io::{stdout, Write};
|
use std::io::{stdout, Write};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use wasmtime::{Caller, InstancePre, Linker, Memory};
|
use wasmtime::{Caller, InstancePre, Linker, Memory};
|
||||||
|
|
||||||
pub struct WasmtimeModule {
|
pub struct WasmtimeModule {
|
||||||
|
@ -41,5 +42,10 @@ impl WasmtimeInstanceEnv {
|
||||||
println!("Called print: {}", s);
|
println!("Called print: {}", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_current_time(_: Caller<'_, Self>) -> i64 {
|
||||||
|
let now = Utc::now();
|
||||||
|
now.timestamp_nanos_opt().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn register_endpoint(mut caller: Caller<'_, Self>) {}
|
pub fn register_endpoint(mut caller: Caller<'_, Self>) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ macro_rules! abi_funcs {
|
||||||
($macro_name:ident) => {
|
($macro_name:ident) => {
|
||||||
// TODO: Why is this "env"? How do i use another name
|
// TODO: Why is this "env"? How do i use another name
|
||||||
$macro_name! {
|
$macro_name! {
|
||||||
|
"env"::get_current_time,
|
||||||
"env"::print,
|
"env"::print,
|
||||||
"env"::register_endpoint,
|
"env"::register_endpoint,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,21 @@ use schemars::JsonSchema;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct AppManifest {
|
pub struct AppManifest {
|
||||||
name: String,
|
pub name: String,
|
||||||
version: Option<String>,
|
pub version: Option<String>,
|
||||||
panorama_version: Option<String>,
|
pub panorama_version: Option<String>,
|
||||||
description: Option<String>,
|
pub description: Option<String>,
|
||||||
installer_path: PathBuf,
|
pub installer_path: PathBuf,
|
||||||
|
|
||||||
endpoints: Vec<AppManifestEndpoint>,
|
pub endpoints: Vec<AppManifestEndpoint>,
|
||||||
triggers: Vec<AppManifestTriggers>,
|
pub triggers: Vec<AppManifestTriggers>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct AppManifestEndpoint {
|
pub struct AppManifestEndpoint {
|
||||||
url: String,
|
pub url: String,
|
||||||
method: String,
|
pub method: String,
|
||||||
export_name: String,
|
pub export_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
|
|
@ -49,6 +49,14 @@ pub struct AppState {
|
||||||
pub tantivy_field_map: BiMap<String, Field>,
|
pub tantivy_field_map: BiMap<String, Field>,
|
||||||
|
|
||||||
pub app_wasm_modules: HashMap<String, Module>,
|
pub app_wasm_modules: HashMap<String, Module>,
|
||||||
|
// TODO: Compile this into a more efficient thing than just iter
|
||||||
|
pub app_routes: HashMap<String, Vec<AppRoute>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct AppRoute {
|
||||||
|
route: String,
|
||||||
|
handler_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
|
@ -82,6 +90,8 @@ impl AppState {
|
||||||
db,
|
db,
|
||||||
tantivy_index,
|
tantivy_index,
|
||||||
tantivy_field_map,
|
tantivy_field_map,
|
||||||
|
app_wasm_modules: Default::default(),
|
||||||
|
app_routes: Default::default(),
|
||||||
};
|
};
|
||||||
state.init().await?;
|
state.init().await?;
|
||||||
|
|
||||||
|
@ -105,4 +115,6 @@ impl AppState {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn handle_app_route() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ pub async fn test_state() -> Result<AppState> {
|
||||||
db,
|
db,
|
||||||
tantivy_index,
|
tantivy_index,
|
||||||
tantivy_field_map,
|
tantivy_field_map,
|
||||||
|
app_routes: Default::default(),
|
||||||
|
app_wasm_modules: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
|
|
|
@ -9,12 +9,14 @@ edition = "2021"
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
axum = "0.7.5"
|
axum = "0.7.5"
|
||||||
chrono = { version = "0.4.38", features = ["serde"] }
|
chrono = { version = "0.4.38", features = ["serde"] }
|
||||||
|
clap = { version = "4.5.7", features = ["derive"] }
|
||||||
# cozo = { version = "0.7.6", features = ["storage-rocksdb"] }
|
# cozo = { version = "0.7.6", features = ["storage-rocksdb"] }
|
||||||
csv = "1.3.0"
|
csv = "1.3.0"
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
itertools = "0.13.0"
|
itertools = "0.13.0"
|
||||||
panorama-core = { path = "../panorama-core" }
|
panorama-core = { path = "../panorama-core" }
|
||||||
|
schemars = "0.8.21"
|
||||||
serde = { version = "1.0.202", features = ["derive"] }
|
serde = { version = "1.0.202", features = ["derive"] }
|
||||||
serde_json = "1.0.117"
|
serde_json = "1.0.117"
|
||||||
sugars = "3.0.1"
|
sugars = "3.0.1"
|
||||||
|
|
15
crates/panorama-daemon/src/apps.rs
Normal file
15
crates/panorama-daemon/src/apps.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
use axum::{
|
||||||
|
routing::{method_routing, MethodFilter},
|
||||||
|
Router,
|
||||||
|
};
|
||||||
|
use panorama_core::AppState;
|
||||||
|
use utoipa::OpenApi;
|
||||||
|
|
||||||
|
#[derive(OpenApi)]
|
||||||
|
#[openapi(paths(), components(schemas()))]
|
||||||
|
pub(super) struct AppsApi;
|
||||||
|
|
||||||
|
pub(super) fn router() -> Router<AppState> {
|
||||||
|
Router::new()
|
||||||
|
// .route("/app/:id/*path", method_routing::any(handler))
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
use axum::{Router};
|
use axum::Router;
|
||||||
use utoipa::OpenApi;
|
use utoipa::OpenApi;
|
||||||
|
|
||||||
use crate::{AppState};
|
use crate::AppState;
|
||||||
|
|
||||||
/// Node API
|
/// Node API
|
||||||
#[derive(OpenApi)]
|
#[derive(OpenApi)]
|
||||||
|
|
|
@ -7,6 +7,7 @@ extern crate serde_json;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate sugars;
|
extern crate sugars;
|
||||||
|
|
||||||
|
pub mod apps;
|
||||||
mod error;
|
mod error;
|
||||||
mod journal;
|
mod journal;
|
||||||
pub mod mail;
|
pub mod mail;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
// pub async fn get_mail_config(
|
// pub async fn get_mail_config(
|
||||||
// State(state): State<AppState>,
|
// State(state): State<AppState>,
|
||||||
// ) -> AppResult<Json<Value>> {
|
// ) -> AppResult<Json<Value>> {
|
||||||
|
|
|
@ -1,10 +1,32 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use clap::{Parser, Subcommand};
|
||||||
|
use panorama_core::state::apps::manifest::AppManifest;
|
||||||
|
use schemars::schema_for;
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
struct Opt {
|
||||||
|
#[clap(subcommand)]
|
||||||
|
command: Option<Command>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Subcommand)]
|
||||||
|
enum Command {
|
||||||
|
GenerateConfigSchema,
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
let opt = Opt::parse();
|
||||||
|
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
panorama_daemon::run().await?;
|
match opt.command {
|
||||||
|
Some(Command::GenerateConfigSchema) => {
|
||||||
|
let schema = schema_for!(AppManifest);
|
||||||
|
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
|
}
|
||||||
|
None => panorama_daemon::run().await?,
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
|
use axum::Router;
|
||||||
|
use utoipa::OpenApi;
|
||||||
|
|
||||||
use axum::{
|
use crate::AppState;
|
||||||
Router,
|
|
||||||
};
|
|
||||||
use utoipa::{OpenApi};
|
|
||||||
|
|
||||||
use crate::{AppState};
|
|
||||||
|
|
||||||
/// Node API
|
/// Node API
|
||||||
#[derive(OpenApi)]
|
#[derive(OpenApi)]
|
||||||
|
|
1
docs/.gitignore
vendored
1
docs/.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
book
|
book
|
||||||
|
src/generated
|
|
@ -16,7 +16,7 @@ After this rolls out, most of the built-in panorama apps will also be converted
|
||||||
To develop a custom app, you will need to provide:
|
To develop a custom app, you will need to provide:
|
||||||
|
|
||||||
-
|
-
|
||||||
App metadata. This contains:
|
App metadata in a `manifest.yml`. This contains:
|
||||||
|
|
||||||
- App display name.
|
- App display name.
|
||||||
- Version + License.
|
- Version + License.
|
||||||
|
|
Loading…
Reference in a new issue