Coder Social home page Coder Social logo

sebastianwessel / surrealdb-client-generator Goto Github PK

View Code? Open in Web Editor NEW
48.0 1.0 5.0 323 KB

Tool which generates a typescript client for SurrealDB and zod schema of a given database

License: MIT License

JavaScript 16.58% TypeScript 83.42%
client client-generator database generator schema surrealdb typescript zod

surrealdb-client-generator's Introduction

❀️ to code

Hi πŸ‘‹, I'm Sebastian Wessel

A passionate, full-time typescript/javascript developer who is working as a freelancer.

Opensource projects

πŸ”­ I’m currently working on PURISTA.

Freelance projects

I'm open to cool projects around typescript - no matter if it is on small IoT & embedded edge devices or at large-scale cloud.
Feel free to contact me, if you've some cool remote projects.

My current tech stack

  • Node.js / Bun
  • TypeScript, Jest, Testcontainer, Turbo, ESLint & Co
  • PURISTA framework (OpenTelemetry, MQTT, RabbitMQ, NATS, k8s, Redis, Dapr...)
  • DrizzleORM with MySQL
  • SurrealDB
  • Vue
  • Docker / Docker-Compose
  • git

Articles on Dev.to

Check out my articles on dev.to πŸ”–πŸ“–πŸ“šπŸ€“

thumbnail How to Design a SurrealDB schema and create a basic...
In the midst of a dynamic landscape of exciting new projects, one name shines bright β€”...
17/09/2023
thumbnail PURISTA - Tests with Jest, Sinon.js and Testcontainers
In the journey of crafting the PURISTA TypeScript backend framework, the need for automated software...
12/09/2023
thumbnail PURISTA: Build with rimraf, esbuild, Turbo & git-cliff
In our previous article, we laid the foundation with a glimpse of our coding setup. It's now time to...
11/09/2023
thumbnail PURISTA - Thanks to amazing open-source software
Welcome to our series on the unsung heroes behind PURISTA! Ever wondered about PURISTA? It's not...
11/09/2023
thumbnail SurrealDB - Improve data integrity by adding schema information
In the concluding chapter of this series, we'll delve into the intriguing world of SurrealDB's schema...
08/09/2023
thumbnail SurrealDB - Query and combine data via relations
In the previous article of this series, we set up the foundation and added some sample data. Now,...
08/09/2023
thumbnail SurrealDB - Structuring Data for Multi-Tenant Role & Permission Systems
Let's dive into the vision of what we're aiming to create. Our goal is to develop a versatile...
08/09/2023
thumbnail SurrealDBβ€Š - The Magic Database to Keep on Your Radar
As a TypeScript backend developer, I've been juggling various projects, and one particular challenge...
08/09/2023
thumbnail Bun 1.0 - JavaScript meets speed of light
Yesterday, version 1.0 of Bun was officially unveiled, and now it's here, ready for use. This marks...
07/09/2023
thumbnail One more thing - Apple's push on web apps on...
The Conclusion of WWDC2023 Keynote: Apple's Unexpected Emphasis on Websites and Web Apps on...
05/06/2023

surrealdb-client-generator's People

Contributors

albertmarashi avatar sebastianwessel 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

Watchers

 avatar

surrealdb-client-generator's Issues

Type issues

Thanks for this amazing tool! I'm just starting to learn SurrealDB and am not 100% confident that this is an issue. When looking at generated files, I see that status and result are being used on types that are missing these fields.

image

Curious if this is expected?

My dependencies are

"dependencies": {
  "@sebastianwessel/surql-gen": "^1.1.0",
  "surrealdb.js": "^0.11.0"
}

Am I doing something wrong?

Trouble connecting to my surrealdb instance

I've been attempting to use the SurrealDB Schema Generator to generate zod schemas and TypeScript clients for my SurrealDB database. While the generator works flawlessly when using the "memory" connection URL, I encounter issues when trying to connect to my local SurrealDB instance running via Docker. Specifically, the process hangs indefinitely with a "connect to database" message and fails to proceed further. I'm also able to connect to surrealist.app with the information I add to the config file.

Configuration Used

Below is the surql-gen.json configuration file I'm using:

{
  "schemaFile": "schema.surql",
  "surreal": "memory",
  "username": "my_username",
  "password": "my_secret_password",
  "ns": "my_namespace",
  "db": "my_database",
  "outputFolder": "./path/to/outdir",
  "generateClient": true,
  "lib": "surrealdb.js"
}

Connection URLs Attempted

I've tried various URLs to connect to my local SurrealDB instance:

  • http://localhost:8000
  • http://localhost:8000/
  • ws://127.0.0.1:8000/rpc
  • ws://127.0.0.1:8000

Additionally, I've confirmed that my normal connection method to SurrealDB using surrealdb.js is through WebSocket URLs like ws://127.0.0.1:8000/rpc, which works fine in my application, but seems incompatible with the schema generator's requirements.

Environment:

Node: 18.19.0
npm: 10.2.3
SurrealDB.js: 0.11.0
sebastianwessel/surql-gen: 1.1.2

Unable to detect surql-gen.json in current folder

Hi there,

Thanks for your kindness of created this productive tool and share it here.

Here is my surql-gen.json file, I not sure how the surql-gen.json file looks like, if you could provide a sample, it will be helpful.

I tried the following commands:

npx surql-gen
npx surql-gen -c surql-gen.json 
npx surql-gen -c ./surql-gen.json 

I always see the following message in the console:

No config file provided - looking for surql-gen.json in current folder

The surql-gen.json was indeed located in the current directory, I not sure why it doesn't pick up by surql-gen.

My system information:

Ubuntu 22.04.3 LTS
node v20.5.1
npm 9.8.0

Please advise. Thank you.

No codes was generated except the client_generated/PropType.ts

Hi there,

I run the npx surql-gen and see the following prompts display in my console:

No config file provided - looking for surql-gen.json in current folder
No config file found.
connect to database
Generating schema in /home/limcheekin/ws/rag/client_generated/_generated
database closed


Thanks for using my tool

Please πŸ™ give a star ⭐️ on github: πŸ‘‰ https://github.com/sebastianwessel/surrealdb-client-generator

If you run into an issue, please let me know so it can get fixed.
πŸ‘‰ https://github.com/sebastianwessel/surrealdb-client-generator/issues

Good luck with your project. πŸ‘‹ Cheers, and happy coding!

However, when I look into the client_generated directory, I only see PropType.ts file.

I started the surrealdb using docker with the following command:

docker run --rm --pull always -p 8000:8000 surrealdb/surrealdb:latest start --log trace --user root --pass root

Attached here is myschema.surql (Please change the file extension of the attached file as GitHub issues doesn't support surql file).

Kindly let's me know if you need more information.

Thanks in advance. Appreciate your support.

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.