GithubHelp home page GithubHelp logo

panacloud / cli Goto Github PK

View Code? Open in Web Editor NEW
25.0 10.0 6.0 8.08 MB

Panacloud Command Line Interface (CLI) uses the design-first approach for developing APIs. It generates Modern Multi-Tenant Serverless Cloud API infrastructure, mocks, stubs, tests, and stages using CDK. GraphQL schemas and OpenAPI specifications are used to implement the design-first approach.

JavaScript 0.28% Batchfile 0.01% TypeScript 95.17% HTML 4.55%
serverless aws graphql cdk openapi

cli's Introduction

oclif Version Downloads/week License

Panacloud Command Line Interface (CLI)

Panacloud CLI Discord Channel

In a recent report 75% of developers indicate that participating in API economy is ‘top priority’. Panacloud is an unified API development, fundraising, and ownership economy platform. It provides services, libraries, tools, and frameworks for developing totally open multi-tenant, serverless cloud services with integrated multi-tenant billing, crowdfunding, and ownership economy constructs. This allows developers to concentrate solely on creating specialised code related to their domain, leaving the rest to the Panacloud platform and services. This model has the potential to disrupt both the software and venture investment industries and making the API developers rich and owners of their own destiny and unicorn startups.

Panacloud CLI accelerates the building of modern multi-tenant serverless SaaS APIs. The CLI applies the design-first paradigm and implements the best practices for designing GraphQL APIs using public cloud serverless and infrastructure as code technologies. The CLI takes a GraphQL API schema that has been augmented with Panacloud directives and creates infrastructure as code (IaC), mock lambdas, tests, and scaffolding for genuine lambdas that include business logic and database requests. It makes use of AWS CDK for IaC. It now only supports AWS, TypeScript and GraphQL, but future versions will also support Azure and Google Cloud, OpenAPI and other languages as well.

CLI Flow

The generated serverless SaaS API project supports multi-tenant usage based billing and monetering and is closely integrated with the Panacloud portal. The developer just needs to write the specific code required by the Multi-Tenant SaaS project. This greatly reduces custom developer coding and increases speed to market. GraphQL and Open REST APIs can be built by using the Panacloud CLI. The APIs may use Graph or Relational databases, etc.

We have also published detailed Tutorials to help you to learn AWS CDK.

Before getting started you need to install the following packages and libraries:

  1. Install Node.js
  2. Install AWS CLI Version 2.x
  3. Install AWS CDK Version 2
  4. Install Globally TypeScript

Before starting your API project learn to develop APIs using this bootcamp and learning API repo

The first step in developing a GraphQL schema for your APIs. Once you have built your GraphQL schema and enhanced it with Panacloud directives, we will now use this CLI to develop the serverless cloud APIs.

The code generated by the CLI will consist of two parts:

  1. Code that will be managed and updated by the CLI. As we add and update the API schema, we will update the generated code using the CLI.
  2. Code that is editable by the API developer and is contained in the editiable_src directory. This code code contains the buisiness logic and is edited and updated by the developer.

Note: The developer can also modify and add the IaC CDK code by using CDK aspects.

Now Globally Install Panacloud CLI:

npm install @panacloud/cli -g

Getting Started

Please read these articles to understand the approach:

API-First, API Design-First, or Code-First: Which Should You

Schema-First GraphQL: The Road Less Travelled

In order to start learning to develop Serverless GraphQL APIs we have developed a very simple schema in the user.graphql file at the root of this tutorial.

You can learn how to develop GraphQL schemas from the schema official documentation

  1. Now we will generate an AWS CDK project using the panacloud cli.
mkdir my_user_api

cd my_user_api

panacloud init
  1. On the command promt answer the question:
GraphQL Schema File Path? ../user.graphql
API Name? MyUserAPI
Select Database? Neptune (Graph) 
Select Query Language? Gremlin

Now the MyUserAPI code is generated and available in the my_user_api directory.

Please review tutorials for a detailed introduction to the project generated by CLI.

Usage

$ npm install -g @panacloud/cli
$ panacloud COMMAND
running command...
$ panacloud (-v|--version|version)
@panacloud/cli/0.0.9 darwin-arm64 node-v16.13.2
$ panacloud --help [COMMAND]
USAGE
  $ panacloud COMMAND
...

Panacloud Commands

panacloud client [FILE]

describe the command here

USAGE
  $ panacloud client [FILE]

OPTIONS
  -h, --help  show CLI help

See code: src/commands/client.ts

panacloud config:customData

Upate panacloudconfig.json

USAGE
  $ panacloud config:customData

OPTIONS
  -f, --false  Set is_custom false
  -h, --help   show CLI help
  -t, --true   Set is_custom true

See code: src/commands/config/customData.ts

panacloud config:memory [QUERY_NAME] [MEMORY_SIZE]

Upate panacloudconfig.json

USAGE
  $ panacloud config:memory [QUERY_NAME] [MEMORY_SIZE]

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/memory.ts

panacloud config:mock [QUERY_NAME]

Upate panacloudconfig.json

USAGE
  $ panacloud config:mock [QUERY_NAME]

OPTIONS
  -f, --false  Set is_mock false
  -h, --help   show CLI help
  -t, --true   Set is_mock true

See code: src/commands/config/mock.ts

panacloud config:stage [STAGE_NAME]

Upate panacloudconfig.json

USAGE
  $ panacloud config:stage [STAGE_NAME]

OPTIONS
  -a, --add     Add New Stage
  -h, --help    show CLI help
  -r, --remove  Remove Stage

See code: src/commands/config/stage.ts

panacloud config:timeout [QUERY_NAME] [TIMEOUT]

Upate panacloudconfig.json

USAGE
  $ panacloud config:timeout [QUERY_NAME] [TIMEOUT]

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/timeout.ts

panacloud help [COMMAND]

display help for panacloud

USAGE
  $ panacloud help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

panacloud init

Generates CDK code based on the given schema

USAGE
  $ panacloud init

OPTIONS
  -d, --database=(DynamoDB (NoSQL)|Neptune (Graph)|Aurora Serverless (Relational))
  -h, --help                                                                        show CLI help
  -t, --test

See code: src/commands/init.ts

panacloud login

Login into your Panacloud Portal Account

USAGE
  $ panacloud login

See code: src/commands/login.ts

panacloud merge

Merge multiple GraphQL schema in one

USAGE
  $ panacloud merge

OPTIONS
  -h, --help  show CLI help

See code: src/commands/merge.ts

panacloud status

describe the command here

USAGE
  $ panacloud status

OPTIONS
  -h, --help  show CLI help

See code: src/commands/status.ts

panacloud update

Updates the Generated Code.

USAGE
  $ panacloud update

OPTIONS
  -h, --help  show CLI help

See code: src/commands/update.ts

Project NPM Commands

Once the project is generated you may run the following npm scripts

  • npm run deploy-dev Deploy Development Stage
  • npm run deploy-prd Deploy Production Stage
  • npm run destroy-dev Destroy Development Stage
  • npm run destroy-prd Destroy Production Stage
  • npm run test-dev Run Tests for the Development Stage
  • npm run test-prd Run Tests for the Production Stage

Details about the Project Generated by the CLI

The CLI generates project for Multi-Tenant Serverless API development with AWS Cloud Development Kit (CDK) using TypeScript. It comes with all the necessary code to develop and deploy a Serverless GraphQL API in the AWS Cloud. This includes the provisioning of cloud infrastructure in code and Serverless stubs where developers may easily include their business logic. The project also provides pre-built mock lambda functions and unit tests to test your deployed APIs.

The project code may be conceptually divided into two parts:

  1. The code that is generated by the Panacloud CLI, and will continuously be updated by the CLI as your API schema evolves. If the developer edits and updated this code, it will be overwritten next time the schema is updated and Panacloud CLI update command is given.
  2. The code that the developer edits and updates and contains the business logic for the APIs. This code is contained in the editable_src/ directory.

It is highly recommended that the developer only edit and update the code contained in the editable_src/ directory because the rest of the code is generated and updated by the Panacloud CLI.

The generated project code includes the mock lambdas contained in the mock_lambda directory in the root project folder. Typically, the developer will write business logic in the stub lambdas contained in the editable_src/lambdas/ directory. The configuration contained in the editable_src/panacloudconfig.json file decides which lambda the APIs will call. Therefore, the project may be using mock lambdas in some calls and the real stub lambdas in other calls. This flexibility allows the developer to seamlessly transition from mock APIs towards real APIs, without the API users and testers even noticing it. Also, the mock APIs may be deployed right away.

The API CDK stack (cloud infrastructure in code) is generated by the Panacloud CLI panacloud init command given the API schema. API development is an iterative process, therefore when the developer updates the API schema in the editable_src/graphql/schema/ directory and runs the panacloud update command the project's CDK code is updated. Given this cycle, most of the CDK stack is generated and updated by the Panacloud CLI. However, the developer has the flexibility to add and update the CDK stack by adding and updating visitors in the editable_src/aspects/ directory. The Panacloud framework uses Aspects to enhance generated constructs and add cloud constructs written by the API developers.

The editable_src/ directory contains all the code which the developer edits.

The editable_src/lambdas/ directory contains all the lambda stubs where the developer writes the business logic.

The editable_src/panacloudconfig.json file tells the Panacloud framework which lambda functions to call.

The editable_src/aspects directory contains all the CDK code which the developer adds to the project CDK stack.

The cdk.json file tells the CDK Toolkit how to execute your app.

The Panacloud Dapp and Protocol Complements the CLI

The Panacloud Dapp and protocol complements this CLI and facilitates the API developer to:

  1. Tokenize the APIs and raise funding for API development.
  2. Document the developer ownership of the API by issuing you an NFT.
  3. Market the APIs to the application developers in the API bazaar/store.
  4. Create a decentralized autonomous organization (DAO) for the APIs for governance in which the API token holders i.e. developer, investors, and users can participate.
  5. Monitor APIs and do multi-tenant billing and clearing on the Ethereum blockchain using smart contracts.
  6. Issue tokens to API early adopters and users to incentivize them to subscribe and use the APIs and become a participant in the Owership Economy.
  7. Allow the stakeholders to cash out whenever they require liquidity by selling API tokens.

The Panacloud CLI Roadmap

First Public Release

Release Date: December 25, 2021

Functionality:

  1. DynamoDB
  2. Neptune & AuroraDB
  3. Microservice dirrective
  4. Multiple stacks
  5. MockData & MockLambda
  6. panacloud status
  7. panacloud client

Second Release

Expected Date: January 15, 2022

Functionality:

  1. API Tests
  2. Async Dirrective
  3. Nested Resolver
  4. Return Type ( Issues with DynamoDB & Neptune )

Third Release

Expected Date: Feburary 1, 2022

Functionality:

Multi-Tenant monetering and billing data live streamed to Amazon Timestream Database deployed in Panacloud AWS Account.

Fourth Release

Expected Date: March 1, 2022

Functionality: Basic OpenAPI speficication support.

cli's People

Contributors

aamir1995 avatar abdulrafayghani avatar adil-innovation-lab avatar mateen7861 avatar muh-hasan avatar muhammadmohsin avatar murtazahuzaifa avatar shariqanwar20 avatar tanzeeltasleem avatar uzairbangee avatar warishasan avatar ziaukhan 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

Property 'fields' of exported interface has or is using private name 'Id'

I have just added a plain todoSchema, and initialize the project. Right after that run the build command npm run build, and the following type errors came.
Property 'fields' of exported interface has or is using private name 'Id'

The file named testCollectionsTypes.ts contains the code:

import {
  Todo,
  MutationAddTodoArgs,
  MutationUpdateTodoArgs,
  MutationDeleteTodoArgs,
} from "../types";

export type TestCollection = {
  fields: { deleteTodo: { arguments: MutationDeleteTodoArgs; response: Id }[] };
};

The errors in command line were

mock_lambda_layer/mockData/deleteTodo/testCollectionsTypes.ts:9:72 - error TS2304: Cannot find name 'Id'.

9   fields: { deleteTodo: { arguments: MutationDeleteTodoArgs; response: Id }[] };
                                                                         ~~

mock_lambda_layer/mockData/deleteTodo/testCollectionsTypes.ts:9:72 - error TS4033: Property 'fields' of exported interface has or is using private name 'Id'.

9   fields: { deleteTodo: { arguments: MutationDeleteTodoArgs; response: Id }[] };

image

CLI: `deploy-prd` deploys resources from `mock_lambdas` even if I change `panacloudconfig.json`

Current Behavior:

running npm run deploy-prd seems to be deploying mock lambdas from mock_lambda directory, even if you change the pancloudconfig.json and run panacloud update.

screenshot from AWS console showing deployed mock_lambda
image

Steps to reproduce:

  1. create a new project with panacloud init.
  2. use the todo schema from tutorial003 dir.
  3. deploy the project with npm run deploy-prd. // <-- the project will deploy the mock_lambdas instead of lambds_stubs.
  4. now edit the panacloudconfig and provide real lambda path and run panacloud update, deploy the project again with npm run deploy_prd // <--- this will now throw an error.
    image

Shifting from Yellicode to Codemaker

Constructs:

  • Constructs Imports
  • Cdk
  • Appsync
  • Ec2
  • ApiManger
  • Apigateway
  • DynamoDB
  • Iam
  • Neptune
  • Lambda
  • AuroraServerless

Code Generators:

  • Testing
  • Appsync
  • Apigateway
  • DynamoDB
  • Bin
  • Stack
  • Lambda
  • Neptune
  • AuroraServerless
  • LambdaConstruct

  • Fixes

OpenAPI Support

Hey! I see you've got OpenAPI on the roadmap, I'm just putting this issue here so I can get an update when it's done.

I'll be happy to talk to you about getting up on https://openapi.tools and other directories so our community can find you, and maybe can write a few blog posts so the community are even more aware of what you're up to here. It looks interesting. 🙌🏻

Making it easy to move from mocks to lambda stubs

We want the API developer to easily config the lambda stubs. Our panacloudconfig.json should look like this:

{
"lambdas": {
"user": { "is_mock": true },
"addUser": { "is_mock": true }
},
"stages": ["prd", "dev"]
}

There are only two states of lambdas either we are using the mock lambdas (custom test data) or stub lambdas (custom business logic) for the real lambdas.

When the is_mock is true we will be using the mock_lambda and mock_lambda_layer. But the mock data will be in a separate directory editable_src/mockData. The types of this mockData will be in a directory testCollectionsTypes in the root, it will be updated by the update cli command. However, editable_src/mockData will not be updated by the cli but the developer will be responsible for maintaining and updating it. This editable_src/mockData will be used to create the mock server on the server-side and test the API on the client-side. When the mock lambdas are being deployed the editable_src/mockData directory will be copied to the mock_lambda_layer.

When the is_mock is false we will be using the editable_src/lambda_stubs and editable_src/lambdaLayers for real lambdas. The editable_src/mockData will not be used on the server-side but only on the client-side to test the APIs.

commands `panacloud client` and `panacloud status` throws an error.

Current Behavior:

commands panacloud client and panacloud status looks for ./editable_src/panacloudConfig.json instead of ./editable_src/panacloudconfig.json.
image

Expected Behavior:

  • The command panacloud client should open GraphiQL browser instance successfully.
  • panacloud stauts should output schema/config status as expected.

Steps to reproduce:

  1. Create a new project with panacloud init with a default schema.
  2. Deploy the sample project with command npm run deploy-dev.
  3. Try to open the GraphiQL instance by running panacloud client <-- this throws an error at the moment.

Add Custom Constructs

Currently, if a developer wants to add custom constructs to the generated stack, he/she will have to add a visitor aspect. Some developers might find understanding aspects difficult. Therefore, it might be nice to add a file editable_src/CustomConstructs/AddConstructs.ts which has a method AddConstruct with a stack object as a parameter. In this method, the developer can easily add constructs to the stack. This method will be called before the aspects are called.

Types Error on Dev Deployment

Steps to reproduce:

  1. create a new project with panacloud init.
  2. use the userschema from tutorial00-getting-started-graphql dir.
  3. deploy the project with npm run deploy-dev, this will now throw an error.

image

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.