Giter VIP home page Giter VIP logo

idea's Introduction

💡 Idea



Form an Idea   •   Transform an Idea   •   Code Extension   •   Plugins

A meta language to express and transform your ideas to reality.

The purpose of this language is to streamline and automate parts of software development that follow a common pattern and therefore can be rendered. Some example code that can be generated using .idea files including the following.

  • Database calls with any ORM
  • API, REST, or GraphQL endpoints
  • React components
  • TypeScript type safety
  • Admin pages
  • more than 70% of the code you produce

It all starts with an idea...

Install

$ npm i -D @ossph/idea

How It Works

  1. Describe your idea in a flexible schema format my.idea.
  2. Install plugins to transform your idea to code make-database.
  3. Generate your platform using the Idea commandline $ idea.

Benefits

This tool is particularly useful for startups and companies looking to build scalable and flexible software solutions quickly.

  • Speed and Efficiency: Dramatically speeds up development time. What might normally take weeks can be done in minutes, reducing the cost and time to market.
  • Customization and Flexibility: Ideas can be highly customized. This means it can be adapted for a wide range of applications, from simple to complex data structures.
  • Scalability: As your needs grow, the system is designed to scale seamlessly. You can add more ideas or adjust existing ones with minimal effort.
  • Error Reduction: By automating the code generation, we reduce the chance of human error, ensuring more reliable and stable software.
  • Modular: Use ideas from any vendor or source out your own ideas.
  • Pluggable: Reduce development time significantly by using existing plugins or publish your own.
  • Closer to AI: Idea files are perfect training data for AI projects.

Usage

This is an example idea schema.

//my.idea
model Product @label("Product" "Products") @suggested("[name]") @icon("gift") {
  name        String   @label("Name") 
                       @field.text
                       @is.required("Name is required")
                       @list.detail @view.text

  image       String   @label("Image") 
                       @field.image
                       @list.image({ width 20 height 20 }) 
                       @view.image({ width 100 height 100 })

  description String   @label("Description") 
                       @field.textarea
                       @list.none @view.text
  
  currency    String   @label("Currency")
                       @filterable @default("USD")
                       @field.currency
                       @is.ceq(3 "Should be valid currency prefix")
                       @list.text @view.text
  
  srp         Float?   @label("SRP")
                       @min(0.00) @step(0.01)
                       @field.number({ min 0.00 step 0.01 })
                       @list.price @view.price
  
  price       Float?   @label("Offer Price")
                       @min(0.00) @step(0.01)
                       @field.number({ min 0.00 step 0.01 })
                       @list.price @view.price
}

"Ideas are worthless without execution" - Many People

To transform an idea, you need to plugin a transformer like the following example.

//my.idea
plugin "idea-ts" {
  ts true
  output "./modules/[name]/types"
}
// ... your idea ...
// model Product ...

You can use other ideas, just import them like the following example.

//my.idea
use "./another.idea"
// ... your idea ...
// model Product ...

To execute an idea, you just need to run the following command.

$ npx idea -i my.idea

Learn more:

idea's People

Stargazers

 avatar

Watchers

 avatar

idea's Issues

Error when generating: Could not find node_modules

What version of Idea are you using?

0.1.1

What OS are you experiencing this issue?

MacOS Monterey

Describe the Bug

I'm creating an idea transformer that transforms ideas to typescript types. When running npx idea -i ./schema.idea I get the following error.

throw new Error('Could not find node_modules');
            ^

Error: Could not find node_modules    at Loader.modules (/Users/server/projects/blanquera/ideas/node_modules/@ossph/idea-transformer/types/Loader.js:26:19)

Expected Behavior

Should process my transformer so I can test and continue developing the transformer.

To Reproduce

My transformer is called @blanquera/idea-typescript In the example I'm creating, I created an idea file that looks like this.

plugin "@blanquera/idea-typescript" {
  lang "ts"
  output "./modules/[name]/types.ts"
}

//--------------------------------------------------------------------//
// User System

//A profile can be a person, organization, or any other type of entity.
//Profiles can be authenticated or added from various sources. That's 
//why we call it profile instead of user and company indicating it's 
//just a general information of an entity.

model Profile @label("Profile" "Profiles") @suggested("[name]") @icon("user") {
  id          String   @label("ID") 
                       @id @generated @default("cuid()")
                       @list.char({ hellip false length 8 })
  
  name        String   @label("Name") 
                       @searchable
                       @field.text
                       @is.required("Name is required")
                       @list.detail @view.text

  image       String?  @label("Image") 
                       @field.url
                       @list.image({ width 20 height 20 }) 
                       @view.image({ width 100 height 100 })
  
  description String?  @label("Description") 
                       @field.textarea
                       @list.none @view.text
  
  type        String?  @label("Type") 
                       @default("person") 
                       @filterable
                       @field.text
                       @list.lowercase @view.lowercase
  
  roles       String[] @label("Roles") 
                       @field.textlist
                       @list.hide
                       @view.tags
  
  tags        String[] @label("Tags") 
                       @field.tags
                       @list.hide
                       @view.tags
  
  references  Hash?    @label("References") 
                       @field.metadata
                       @list.hide
                       @view.metadata
  
  active      Boolean  @label("Active") 
                       @generated @active @default(true) 
                       @list.hide @view.yesno
  
  created     Datetime @label("Created") 
                       @generated @created @spanable @sortable @default("now()") 
                       @list.date("m d, Y h:iA") 
                       @view.date("m d, Y h:iA")
  
  updated     Datetime @label("Updated") 
                       @generated @updated @spanable @sortable @default("now()")
                       @list.date("m d, Y h:iA") 
                       @view.date("m d, Y h:iA")
  
  auth        Auth?        @label("Auth")
  connections Connection[] @label("Connections")
  memberships Connection[] @label("Memberships")
  files       File[]       @label("Files")
  addresses   Address[]    @label("Addresses") @default("[]")
}

//Auth is used to authenticate a profile and create a session.
model Auth @label("Auth" "Auths") @suggested("[username]") @icon("lock") {
  id        String   @label("ID") 
                     @id @generated @default("cuid()")
                     @list.char({ hellip false length 8 })
  
  profileId String   @label("Profile") 
                     @filterable 
                     @field.relation("Profile" "id") 
                     @is.required("Profile is required") 
                     @list.relation("Profile")
                     @view.relation("Profile")
                     
  username  String   @label("Username")
                     @unique @searchable @filterable
                     @field.text
                     @is.required("Username is required") 
                     @is.cge(5 "Should more than 5 characters")
                     @list.detail @view.text
  
  email     String?  @label("Email Address")
                     @unique @searchable @filterable
                     @field.email
                     @is.email("Should be a valid email address")
                     @list.text @view.email
  
  phone     String?  @label("Phone Number")
                     @unique @searchable @filterable
                     @field.text
                     @is.pattern("/^\+[0-9]{0,3} [0-9]+$/" "Should be a valid phone number")
                     @list.text @view.phone
  
  password  String   @label("Password") 
                     @field.password
                     @is.required("Password is required")
  
  twofa     String?  @label("2FA") 
                     @field.text
  
  verified  Int      @label("Verified") 
                     @generated @default(0) //0=unverified, 1=email, 2=phone, 3=both
  
  lastLogin Datetime @label("Last Logged In") 
                     @generated @default("now()")
                     @list.date("m d, Y h:iA") 
                     @view.date("m d, Y h:iA")
  
  active    Boolean  @label("Active") 
                     @generated @active @default(true) 
                     @list.yesno @view.yesno
  
  created   Datetime @label("Created") 
                     @generated @created @spanable @sortable @default("now()") 
                     @list.date("m d, Y h:iA") 
                     @view.date("m d, Y h:iA")
  
  updated   Datetime @label("Updated") 
                     @generated @updated @spanable @sortable @default("now()")
                     @list.date("m d, Y h:iA") 
                     @view.date("m d, Y h:iA")
  
  profile   Profile  @relation({ local "profileId" foreign "id" })
}

//--------------------------------------------------------------------//
// Connection System

//A connection is a list of connections between profiles
// ie. company, network, group, organization, etc.
// to do a company setup, make a company profile, then add members to it.

enum Roles {
  OWNER "owner"
  MODERATOR "moderator"
  MEMBER "member"
}

model Connection @label("Connection" "Connections") @suggested("[owner.name] - [member.name]") @icon("users") {
  ownerId  String   @label("Owner")
                    @id @relation("Profile" "id") 
                    @is.required("Owner is required")
  
  memberId String   @label("Member")
                    @id @relation("Profile" "id") 
                    @is.required("Member is required")
  
  role     Roles   @label("Role")
                    @default("MEMBER")
                    @field.text
  
  tags     String[] @label("Tags") 
                    @field.tags
                    @list.hide
                    @view.tags
  
  active   Boolean  @label("Active") 
                    @generated @active @default(true) 
                    @list.yesno @view.yesno
  
  created  Datetime @label("Created") 
                    @generated @created @spanable @sortable @default("now()") 
                    @list.date("m d, Y h:iA") 
                    @view.date("m d, Y h:iA")
  
  updated  Datetime @label("Updated") 
                    @generated @updated @spanable @sortable @default("now()")
                    @list.date("m d, Y h:iA") 
                    @view.date("m d, Y h:iA")

  owner    Profile  @relation({ name "connections" local "ownerId" foreign "id" })
  member   Profile  @relation({ name "memberships" local "memberId" foreign "id" })
}

//--------------------------------------------------------------------//
// File System

model File @label("File" "Files") @suggested("[name]") @icon("file") {
  //FIELDS:
  id        String   @label("ID")
                     @id @generated @default("cuid()")
                     @list.char({ hellip false length 8 })
  
  profileId String   @label("Profile") @filterable 
                     @field.relation("Profile" "id") 
                     @is.required("Profile is required")
  
  name      String   @label("Name") 
                     @searchable
                     @field.text
                     @is.required("Name is required")
                     @list.detail @view.text
  
  url       String   @label("URL")
                     @searchable
                     @field.url
                     @is.required("URL is required")
                     @view.link
  
  tags      String[] @label("Tags") 
                     @field.tags
                     @list.hide
                     @view.tags
  
  active    Boolean  @label("Active") 
                     @generated @active @default(true) 
                     @list.yesno @view.yesno
  
  created   Datetime @label("Created") 
                     @generated @created @spanable @sortable @default("now()") 
                     @list.date("m d, Y h:iA") 
                     @view.date("m d, Y h:iA")
  
  updated   Datetime @label("Updated") 
                     @generated @updated @spanable @sortable @default("now()")
                     @list.date("m d, Y h:iA") 
                     @view.date("m d, Y h:iA")
  
  profile   Profile  @relation({ local "profileId" foreign "id" })
}

//--------------------------------------------------------------------//
// Address System

type Address @label("Address" "Addresses") @suggested("[name]") @icon("map-marker") {
  name         String   @label("Name") 
                        @field.text
                        @is.required("Name is required")
                        @list.detail @view.text
  
  contact      String?  @label("Contact Person")
                        @field.text
                        @list.text @view.text
  
  email        String?  @label("Contact Email Address") 
                        @field.email
                        @is.email("Should be a valid email address")
                        @view.email
  
  phone        String?  @label("Contact Phone Number") 
                        @field.text
                        @is.pattern("/^\+[0-9]{0,3} [0-9]+$/" "Should be a valid phone number")
                        @view.phone
  
  unit         String?  @label("Unit Number")
                        @field.text
                        @list.text @view.text
  
  building     String?  @label("Building Name")
                        @field.text
                        @list.text @view.text
  
  street       String   @label("Street Address")
                        @field.text
                        @is.required("Street is required")
                        @list.text @view.text
  
  neighborhood String?  @label("Neighborhood")
                        @field.text
                        @list.text @view.text
  
  city         String   @label("City")
                        @filterable
                        @field.text
                        @is.required("City is required")
                        @list.text @view.text
  
  state        String?  @label("State")
                        @filterable
                        @field.text
                        @list.text @view.text
  
  region       String?  @label("Region")
                        @filterable
                        @field.text
                        @list.text @view.text
  
  country      String   @label("Country")
                        @filterable
                        @field.country
                        @is.required("Country is required")
                        @list.text @view.text
  
  postal       String   @label("Postal Code")
                        @filterable
                        @field.text
                        @is.required("Postal Code is required")
                        @list.text @view.text

  notes        String?  @label("Notes")
                        @field.textarea
                        @view.text
  
  latitude     Float?   @label("Latitude")
  longitude    Float?   @label("Longitude")
}

Allow transformers to access configs from other transformers

Describe the feature you'd like to request

Let's say we have some plugins called idea-typescript, idea-sql, and idea-react with configuration that looks like the following.

plugin "idea-typescript" {
  enums "./modules/enums"
  types "./modules/[name]/types"
}
plugin "idea-sql" {
  output "./modules/[name]/sql"
}
plugin "idea-react" {
  output "./modules/[name]/components"
}
plugin "idea-express" {
  enums "./modules/enums"
  types "./modules/[name]/types"
  sql "./modules/[name]/sql"
}

Then I create another transformer called idea-express. I need to know where the enums, typings, sql and react comonents are and I can't access other transformer configs inside another plugin. So I would need to do something like this instead.

plugin "idea-express" {
  enums "./modules/enums"
  types "./modules/[name]/types"
  sql "./modules/[name]/sql"
}

Describe the solution you'd like

I would like transformers to be able to read settings for other transformers in order to have the following benefits.

  • less configuration needed
  • transformers can require other transformers to be used
  • transformers can coordinate

Describe alternatives you've considered

I have considered doing the following, but I could imagine this getting out of hand, the more transformers there are.

plugin "idea-express" {
  enums "./modules/enums"
  types "./modules/[name]/types"
  sql "./modules/[name]/sql"
}

Open Prop for generators to access

Describe the feature you'd like to request

prop can be used to solve for other random cases needed by generators.

Describe the solution you'd like

Pass prop to the schema passed to generators.

Describe alternatives you've considered

Creating another keyword like module "name", but this will open more possibilities of niche keyword introductions. I just need props as a general usage variable.

Open cwd in Terminal

Describe the feature you'd like to request

Transformers could use the cwd used in Terminal as in the following case.

// my.idea
plugin "./idea-typescript" {
  output "./modules/types.ts"
}
// my code:  ./idea-typescript

import { Loader } from '@ossph/idea';

export default function transform({ config, schema, cli }) {
  //what is cwd ?
  const destination = Loader.absolute(config.output, cwd);
  //...

Describe the solution you'd like

Open cwd in terminal so we can access the cwd like the following.

// my code:  ./idea-typescript
import { Loader } from '@ossph/idea';

export default function transform({ config, schema, cli }) {
  const destination = Loader.absolute(config.output, cli.cwd);
  //...

Describe alternatives you've considered

We could use process.cwd() but this isn't good for test and would yield different results depending on what folder your project is being ran from.

Transformer API

Describe the feature you'd like to request

idea-transformer sets up an API for terminal programs. We need a way to easily access this transformer programatically specifically to create tests without copying the run() logic from the Terminal class.

Describe the solution you'd like

Create a class called Transformer in idea-transformer with methods to read/parse idea files. We can then access this class to run tests against our transformers.

Describe alternatives you've considered

Copying the run() logic from the Terminal class. But then, everyone would need the foresight to do this.

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.