Giter Club home page Giter Club logo

teo's People

Contributors

dundun1124 avatar heke007 avatar l1xnan avatar luanxuechao avatar ruleeeer avatar tobiasnickel avatar victorteokw avatar ziqiangai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

teo's Issues

Teo(v0.2.15) ganerate entity and client panic

Teo(v0.2.15) ganerate entity and client panic

teo-generator-0.2.15/src/entity/generators/rust/gen.rs:120:14:
explicit panic
stack backtrace:
   0:        0x101a01b40 - std::backtrace_rs::backtrace::libunwind::trace::hadefa2fe489b32be
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:        0x101a01b40 - std::backtrace_rs::backtrace::trace_unsynchronized::h37e8bb3c3fd9c67c
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x101a01b40 - std::sys_common::backtrace::_print_fmt::h4994a90b70e9aaa7
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:68:5
   3:        0x101a01b40 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb478ebbfb46e27ce
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x101a24cc4 - core::fmt::rt::Argument::fmt::hfe2e626e52db21d5
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/fmt/rt.rs:142:9
   5:        0x101a24cc4 - core::fmt::write::he4d5fa2daff1f531
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/fmt/mod.rs:1120:17
   6:        0x1019fe63c - std::io::Write::write_fmt::hc5a47a68eba63d9f
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/io/mod.rs:1810:15
   7:        0x101a01974 - std::sys_common::backtrace::_print::hd47355bf70e1c2da
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x101a01974 - std::sys_common::backtrace::print::h79bd952cc5812e7a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x101a02f00 - std::panicking::default_hook::{{closure}}::h82301f6222887737
  10:        0x101a02c48 - std::panicking::default_hook::h1e49abbb3f1d7dbf
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:292:9
  11:        0x101a03348 - std::panicking::rust_panic_with_hook::h1e70c5d905e30e9d
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:779:13
  12:        0x101a0323c - std::panicking::begin_panic_handler::{{closure}}::h399e32952efd26a4
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:657:13
  13:        0x101a01fc4 - std::sys_common::backtrace::__rust_end_short_backtrace::h2ab87f841a2323e7
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:171:18
  14:        0x101a02fc4 - rust_begin_unwind
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
  15:        0x101a75d70 - core::panicking::panic_fmt::h33e40d2a93cab78f
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
  16:        0x101a75ec0 - core::panicking::panic_display::h3147bab0bf654774
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:196:5
  17:        0x101a75ec0 - core::panicking::panic_explicit::h8cbc9a9d78eb70c9
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:179:5
  18:        0x101a37e58 - teo_generator::entity::generators::rust::gen::fix_path::panic_cold_explicit::he1d2df2942da2968
  19:        0x1009d5ff4 - teo_generator::entity::generators::rust::gen::fix_path::h67395fca0319a153
  20:        0x1009d968c - <teo_generator::entity::generators::rust::gen::RustModuleTemplate as askama::Template>::render_into::h32dc7173e8be20a0
  21:        0x1009d75a4 - teo_generator::entity::generators::rust::gen::RustGenerator::generate_module_file::{{closure}}::ha3fad67817939245
  22:        0x1009df690 - teo_generator::entity::generators::rust::gen::RustGenerator::generate_module_for_namespace::{{closure}}::h596ab4a2f954a28b
  23:        0x1009e02f0 - <teo_generator::entity::generators::rust::gen::RustGenerator as teo_generator::entity::generator::Generator>::generate_entity_files::{{closure}}::h060a7220c0b2810a
  24:        0x10074dc20 - teo_generator::entity::generate::{{closure}}::h254070df42dcdd42
  25:        0x10078d16c - tokio::runtime::park::CachedParkThread::block_on::{{closure}}::hfd6702ef6c1e0538
  26:        0x10078bb7c - tokio::runtime::park::CachedParkThread::block_on::h83b8fe96e738f193
  27:        0x1008074c4 - tokio::runtime::context::runtime::enter_runtime::hce168625ef49dbed
  28:        0x100862914 - tokio::runtime::runtime::Runtime::block_on::h9a47f25ac8f88ec6
  29:        0x10091badc - cargo_teo::main::h3f6e6c228c0ab3dd
  30:        0x1008fe4c4 - std::sys_common::backtrace::__rust_begin_short_backtrace::hedcae39fbf3d0e3a
  31:        0x10087dc58 - std::rt::lang_start::{{closure}}::hb16fb0e40d873756
  32:        0x1019f7afc - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hde2a2ae1d756c37f
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:284:13
  33:        0x1019f7afc - std::panicking::try::do_call::h96b73f4da16ee7c5
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  34:        0x1019f7afc - std::panicking::try::h2cb0c14c1266f147
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  35:        0x1019f7afc - std::panic::catch_unwind::hb8cd2580f659030d
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  36:        0x1019f7afc - std::rt::lang_start_internal::{{closure}}::h00f9c2d0117ea0ef
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:48
  37:        0x1019f7afc - std::panicking::try::do_call::h134dfd8876bcc105
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  38:        0x1019f7afc - std::panicking::try::h6595e056250d6043
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  39:        0x1019f7afc - std::panic::catch_unwind::haad85d5172c9b53a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  40:        0x1019f7afc - std::rt::lang_start_internal::hf4f3eb1e51305b96
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:20
  41:        0x10091bbdc - _main

[Feature request] Plugins support for other editors Zed, Neovim

What

I'd like request the addition of plugin support for other editors, specifically Zed and Neovim.

Why

Currently, Teo offers plugins for VS Code, which is fantastic. However, expanding support to other popular editors like Zed and Neovim would greatly benefit users who prefer these environments. Both Zed and Neovim have a strong user base and are known for their flexibility and efficiency in coding workflow

Benefits

  • Broadens the reach of Teo to more developers.
  • Enhances the coding experience for users of Zed and Neovim.

How

  • Add Tree-sitter for Teo file (*.teo): Implement syntax highlighting and other Tree-sitter features for Teo files in Neovim using nvim-treesitter.
  • Add LSP config: I guess Teo has LSP so it would be good if we could open a pull request to (https://github.com/neovim/nvim-lspconfig) to add support for Teo. This will ensure that Teo files benefit from advanced language features such as autocompletion, linting, and more.

Thank you for considering this feature request. I believe it will significantly enhance the usability and popularity of Teo across diverse coding environments.

issued the command cargo teo serve to start project, but it immediately exited without displaying any error messages.

rust version:1.75.0
when I operate by this guide:
https://teocloud.io/docs/getting-started/beginner-tutorial/write-a-schema-only-app

I use cargo teo serve to start the project, but it quit quickly, just print log below:
[2024-01-23 08:02:33] sqlite connector connected for main at "sqlite::memory:"

I change database by postgres, and I get the same result:
[2024-01-23 07:58:23] postgres connector connected for main at "postgres://postgres:[email protected]:5432/helloteo"

Teo runtime build error

Hi @victorteokw

As of today, it started giving errors during build.

error[E0275]: overflow evaluating the requirement `namespace::Namespace: std::fmt::Debug`
  --> teo-runtime/src/namespace/mod.rs:45:10
   |
45 | #[derive(Educe)]
   |          ^^^^^
   |
   = note: required for `BTreeMap<std::string::String, namespace::Namespace>` to implement `std::fmt::Debug`
   = help: see issue #48214
   = note: this error originates in the derive macro `Educe` (in Nightly builds, run with -Z macro-backtrace for more info)

startup teo serve with postgres error

when I use example from https://teocloud.io/docs/getting-started/beginner-tutorial/write-a-schema-only-app

error:

[2023-12-29 02:09:43] postgres connector connected for `main` at "postgres://postgres:postgres@teo-db:5432/helloteo"
thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/teo-0.0.64/src/seeder/seed.rs:643:28:
called `Result::unwrap()` on an `Err` value: : unknown database find error: Error { kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42601), message: "syntax error at or near \")\"", detail: None, hint: None, position: Some(Original(43)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1241), routine: Some("scanner_yyerror") }) }), original_code: Some("42601"), original_message: Some("db error: ERROR: syntax error at or near \")\"") }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

teo version:
teo Teo 0.0.64 (Rust 1.74.1) [CLI]

Error generate admin

First - thx for this great project - i like it very much!

By trying Generate admin dashboard from the tutorial i get an error at

cargo teo generate admin
Error: Error { code: 500, message: "error decoding response body", errors: None, platform_native_object: None }

Backend ist up and running

cargo teo serve
[2024-06-12 08:18:41] sqlite connector connected for main at "sqlite:./database.sqlite"
[2024-06-12 08:18:41] Teo 0.2.35 (Rust 1.78.0, CLI)
[2024-06-12 08:18:41] listening on port 5054

This seems due to some kind of misffits in the serde json deserialization of the repsonse body?

Does Teo support SSR for Astro or Vue, particularly in Rust and Python?

I'm exploring the use of Teo for server-side rendering (SSR), and I'm curious to know if it supports SSR for frameworks like Astro or Vue. Specifically, I'm interested in implementing this functionality in Rust and Python. Has anyone already implemented SSR for these frameworks within Teo, or are there any related documentation or tutorials available for reference?

generate shema from a exist database

I have a idea.

Many of our users have databases that have been running for several years.
We are wondering if we could develop a feature similar to teo-generate-scheme-from-db.
This would not only allow new projects to use teo without starting from scratch,
but also provide a basic interface for older projects.

User security question

Hi @victorteokw

I would like to receive information about user security. You use jwt token for the user login part and we need to keep it on localstorage. Localstorage is open to XSS attacks, how can we ensure this security? Does calling and checking user information for each handler along with the token ensure security? Of course, permission will be set for user information. Can you suggest a different method? Or wouldn't it make more sense to use cookie auth? When I examine the system, it seems like a lot of settings need to be made for cookie auth, maybe I'm thinking wrong. I want to ensure user security. I hope you can help with this.

Thanks

Add cookies to the Request and Response object

Hello, I had a few questions about the system.

  1. Can we add HTML template support like Tera?
  2. Is there a cookie-based session?
  3. What method should we follow to send an e-mail?
  4. Can we add a job queue process?
  5. Generated customizable admin Dashboard. How will we create it?

Thanks

File Upload example bug

@victorteokw

While reviewing the sample codes, I got an error again.

@map(path: "/upload")
declare form handler upload(UploadInput): Data<UploadOutput>
 
interface UploadInput {
  file: File
}
 
interface UploadOutput {
  path: String
}

It gives an error after the entity is created.

error[E0599]: no function or associated item named `from_value_ref` found for struct `teo::prelude::File` in the current scope
     --> src/entities/mod.rs:16999:15
      |
16999 |         File::from_value_ref(self.inner().get("file").unwrap()).unwrap()
      |               ^^^^^^^^^^^^^^ function or associated item not found in `File`

I also want to use a structure like this as a field in the schema file. But it also gives errors.

@relation(fields: .id, references: .id)
 contacts: User[]?
error[E0609]: no field `inner` on type `Vec<User>`
     --> src/entities/mod.rs:13500:77
      |
13500 |         self.inner.force_set_relation_object("contacts", contacts.map(|o| o.inner.clone())).await
      |                                                                             ^^^^^ unknown field

Bug: virtual fields are created when creating table

Hi @victorteokw

I was reviewing the documents you prepared, but I'm getting an error at one point. I get errors in the codes at this address "https://docs.teodev.io/getting-started/beginner-tutorial/implement-authentication#phone-number-and-auth-code".

When I first run the code I don't get any errors. But when I restart the system it gives an error.

db provider postgresql

schema.teo

connector {
  provider: .postgres,
  url: "postgres://user:password@localhost:5432/deneme"
}

server {
  bind: ("0.0.0.0", 5052)
}

entity {
  provider: .rust,
  dest: "./src/entities"
}
 
declare pipeline item validateAuthCode<T>: T -> String
 
@identity.tokenIssuer($identity.jwt(expired: $get(.expired).presents))
@identity.jwtSecret(ENV["JWT_SECRET"]!)
@identity.validateAccount(
  $message($get(.enabled).presents.eq(true), "this account is blocked"))
model User {
  @id @autoIncrement @readonly
  id: Int
  @unique @onSet($if($presents, $isEmail)) @identity.id
  @presentWithout(.phoneNumber)
  email: String?
  @writeonly @onSet($presents.bcrypt.salt)
  @identity.checker(
    $do($get(.value).presents.bcrypt.verify($self.get(.password).presents))
    .do($get(.companions).presents.get(.imageAuthToken).presents))
  password: String?
  @virtual @writeonly @identity.companion
  imageAuthToken: String?
  @virtual @writeonly @identity.companion
  expired: Int64?
  @migration(default: true) @default(true)
  enabled: Bool
  @identity.id @unique
  thirdPartyId: String?
  @virtual @writeonly @identity.checker($get(.value).presents.valid)
  thirdPartyToken: String?
  @onSet($if($presents, $regexMatch(/\\+?[0-9]+/))) @identity.id
  @presentWithout(.email) @unique
  phoneNumber: String?
  @virtual @writeonly @identity.checker($validateAuthCode)
  authCode: String?
 
  include handler identity.signIn
  include handler identity.identity
}
 
model AuthCode {
  @id @autoIncrement @readonly
  id: Int
  @presentWithout(.phoneNumber) @unique
  email: String?
  @presentWithout(.email) @unique
  phoneNumber: String?
  @onSave($randomDigits(4))
  code: String
}

middlewares [identity.identityFromJwt(secret: ENV["JWT_SECRET"]!)]

main.rs

pub mod entities;
 
use entities::{Teo, User};
use indexmap::indexmap;
use tokio::main;
use teo::prelude::{pipeline::item::validator::Validity, App, Result, Value, Error};
 
#[main]
async fn main() -> Result<()> {
    let app = App::new()?;
    app.main_namespace_mut().define_validator_pipeline_item("validateAuthCode", move |check_args: Value, user: User, teo: Teo| async move {
        let mut finder = Value::Dictionary(indexmap!{});
        let check_args = check_args.as_dictionary().unwrap();
        let ids = check_args.get("ids").unwrap().as_dictionary().unwrap();
        if ids.contains_key("email") {
            finder.as_dictionary_mut().unwrap().insert("email".to_owned(), ids.get("email").unwrap().clone());
        }
        if ids.contains_key("phoneNumber") {
            finder.as_dictionary_mut().unwrap().insert("phoneNumber".to_owned(), ids.get("phoneNumber").unwrap().clone());
        }
        let auth_code = teo.auth_code().find_unique(finder).await?;
        match auth_code {
            Some(auth_code) => if auth_code.code().as_str() == check_args.get("value").unwrap().as_str().unwrap() {
                Ok::<Validity, Error>(Validity::Valid)
            } else {
                Ok(Validity::Invalid("auth code is wrong".to_owned()))
            },
            None => Ok(Validity::Invalid("auth code not found".to_owned()))
        }
    });
    app.run().await
}

Error

thread 'main' panicked at /home/yakel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/teo-sql-connector-0.2.28/src/migration/migrate.rs:237:71:
called `Result::unwrap()` on an `Err` value: Error { kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42601), message: "syntax error at or near \"`\"", detail: None, hint: None, position: Some(Original(13)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1176), routine: Some("scanner_yyerror") }) }), original_code: Some("42601"), original_message: Some("db error: ERROR: syntax error at or near \"`\"") }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Rust for the Quickstart guide

in the clickstart guide tye cargo command is used. I believe it is from Rust, but don't know. Can you tell what is needed to download/install?

Schema bug

Hi @victorteokw

I was trying to try examples from the documentation. But at some point I get an error. It gives an error in the fullName section.

model User {
    firstName: String
    lastName: String
    @getter($self.get(.firstName).append(" ").append($self.get(.lastName)))
    @setter($assign(.firstName, $split(" ").get(0)).assign(.lastName, $split(" ").get(1)))
    fullName: String
}
Error: ./schema/index.teo:32:35 - 32:41
|     @getter($self.get(.firstName).append(" ").append($self.get(.lastName)))
|                                   ^^^^^^
callable variant not found for arguments
Error: ./schema/index.teo:32:54 - 32:74
|     @getter($self.get(.firstName).append(" ").append($self.get(.lastName)))
|                                                      ^^^^^^^^^^^^^^^^^^^^
unexpected pipeline output: expect String, found String?
Error: ./schema/index.teo:32:47 - 32:53
|     @getter($self.get(.firstName).append(" ").append($self.get(.lastName)))
|                                               ^^^^^^
callable variant not found for arguments
Error: ./schema/index.teo:33:33 - 33:51
|     @setter($assign(.firstName, $split(" ").get(0)).assign(.lastName, $split(" ").get(1)))
|                                 ^^^^^^^^^^^^^^^^^^
unexpected pipeline output: expect String, found String?
Error: ./schema/index.teo:33:71 - 33:89
|     @setter($assign(.firstName, $split(" ").get(0)).assign(.lastName, $split(" ").get(1)))
|                                                                       ^^^^^^^^^^^^^^^^^^
unexpected pipeline output: expect String, found String?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.