Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve new glee command #683

Closed
Tracked by #477
KhudaDad414 opened this issue Jul 14, 2023 · 50 comments · Fixed by #890
Closed
Tracked by #477

Improve new glee command #683

KhudaDad414 opened this issue Jul 14, 2023 · 50 comments · Fixed by #890
Assignees
Labels
bounty AsyncAPI Bounty program related label bounty/2023-Q4 AsyncAPI Bounty program related label enhancement New feature or request level/medium AsyncAPI Bounty program related label

Comments

@KhudaDad414
Copy link
Member

KhudaDad414 commented Jul 14, 2023

asked ChatGPT to make the issue a little bit more fun to read. 😆

Reason/Context

Alright, so when you're rolling with the asyncapi new glee command to create a fresh Glee app, what you get is a pretty neat and basic app. Good starting point, right? However, you, the user, gotta roll up your sleeves and get your hands dirty with the nitty-gritty:

  • Shuffling your asyncapi.yaml file across.
  • Tackling necessary Glee fields, the likes of operationId.
  • Crafting those essential functions.
  • Keeping your eyes peeled to make sure your function names are grooving with the operationId.
  • Delving deep into your AsyncAPI file to get the lowdown on the payload structure and get to your properties.

Description

Look, we get it - a lot of frameworks are out there handing out templates like candy at Halloween to help you get going. We could do that, too - some nifty templates for different protocols, all set and ready for action. You could grab one, tweak it to your heart's content, and boom, it's all you. But we're thinking big here - we're looking at something way better, especially if you're sitting there with an AsyncAPI spec file in your back pocket.

Picture this: you've got your AsyncAPI spec file and you're ready to hit the ground running with your app. You're firing off asyncapi new glee asyncapi.yaml and here's what the CLI's doing for you:

  1. It's doing a once-over on your file, making sure it's Glee-ready. Got operationId? Any other Glee-essentials? Check and check.
  2. It's dissecting the payload schema and running modelina to churn out the types.
  3. It's teaming up those operationIds with the fresh types to cook up an empty function. This puppy's just there to nod and confirm the message receipt. And with all that in place, you're now getting type suggestions popping up in your functions.
  4. Finally, it's decoding the server's security object and cranking out some bare-bones auth functions to match. (after feat: glee auth v2 glee#474 is merged)

With all that heavy lifting out of the way, you're all set to just dive right in and start cooking up your functions. No setup, no fuss - just you and your code.

cc: @peter-rr @Souvikns @fmvilas anything from your side?

@KhudaDad414 KhudaDad414 added the enhancement New feature or request label Jul 14, 2023
@Souvikns
Copy link
Member

@KhudaDad414 Ultimately should our CLI look something like nestjs cli

@oviecodes
Copy link

oviecodes commented Jul 19, 2023

Cool, how soon do we need this done? it looks interesting

@derberg
Copy link
Member

derberg commented Jul 19, 2023

Look, we get it - a lot of frameworks are out there handing out templates like candy at Halloween to help you get going

🤣

just for validation if all required parts are there, like operationId we need to make sure it is not something we add as code, but enable some kind of config file maybe?

@peter-rr
Copy link
Member

peter-rr commented Jul 20, 2023

I have some ideas for next iterations of asyncapi new glee command, mostly related to operationId as well. Let me show you some of them (no ChatGPT fun this time, sorry 😅 ):

  • In case the user has an specific asyncapi file to use, we could retrieve all the operationId's from it to create the corresponding functions (.js files) with just some minimal content (skeleton), leaving to the user the space needed to add the business logic required for those functions. For this scenario, it would be necessary to leave the functions folder empty first, and also replacing the asyncapi.yaml file from the Glee template with the spec file provided by the user.

  • If TTY in use, we may ask to the user whether he/she wants to create an spec file or not. Once created, we could get all the operationId's just like before, but also ask the user for all the channels whose publish component is missing an operationId so they can choose the name for it in that case. After all that process, then we could create the corresponding functions.

  • Also we could get all the servers components from the asyncapi file in order to include them in the .env file.

Any thoughts on this? @KhudaDad414 @Souvikns @fmvilas

Once we have agreed on something, I'd like to start working on a PR proposal 💪

@KhudaDad414
Copy link
Member Author

@KhudaDad414 Ultimately should our CLI look something like nestjs cli

I am not exactly sure. I mean nestjs cli is used for generating templates for specific components in nestjs right? I mean at the end since we have the AsyncAPI spec file then we should be able to get a working project from the file itself.

@KhudaDad414
Copy link
Member Author

Cool, how soon do we need this done? it looks interesting

Up for discussion. but I think before releasing glee 1.0 we should have this in place for CLI.

@KhudaDad414
Copy link
Member Author

@peter-rr

we could retrieve all the operationId's from it to create the corresponding functions (.js files)

why not Typescript file? glee supports typescript and this way we can add type safety and type generation for message payload using Modelina as well. 🤔 or at least giving the option for user to select between Typescript and Javascript.

@KhudaDad414
Copy link
Member Author

just for validation if all required parts are there, like operationId we need to make sure it is not something we add as code, but enable some kind of config file maybe?

@derberg sorry, I don't understand how we can do it without code. the best way that I can think of is creating a JSON Schema to enforce things like having operationId in publish. 🤔
any other idea?

@peter-rr
Copy link
Member

why not Typescript file? glee supports typescript and this way we can add type safety and type generation for message payload using Modelina as well. 🤔 or at least giving the option for user to select between Typescript and Javascript.

@KhudaDad414 Yeah, I was just following the conventions established so far for Glee functions but I think it's a good idea opting for Typescript or giving the chance to select between both languages if that's possible 👍

@derberg
Copy link
Member

derberg commented Jul 25, 2023

@KhudaDad414 Spectral is the answer imho. We already use it in parser. It is common for governance of json documents. So you can use spectral config to specify what and where should be in a given document. Last time I checked you provide a simple json file

@fmvilas fmvilas added this to Glee Sep 4, 2023
@ayushnau
Copy link
Contributor

@derberg @peter-rr i would like to work on this. could you suggest me how should i do this.

@KhudaDad414
Copy link
Member Author

@ayushnau hey man I would suggest the following steps:

  1. familiarize yourself with glee. (use the v3 of the spec to write something, maybe a chatbot, maybe a bot that listens to slack messages, anything that comes to your mind.)
    you don't have to know how glee works internally, you just have to use it as a user. if you need some help please reach out.

  2. familiarize yourself with cli and how it generate a new glee project.
    good luck.

Note: you don't need to think about the validation with spectral too much, v3 of the spec solves lots of the issues.

@AyushNautiyalDeveloper
Copy link

ok @KhudaDad414 will try to do that.

@peter-rr
Copy link
Member

@ayushnau Once you get familiarized yourself with the Glee project, I think it could be a nice starting point for you trying to work on:

  • retrieving the operationId from the asyncapi file to create the corresponding functions.
  • the interaction between the user and the terminal (TTY).

Don't hesitate to ask for any questions or concerns about it 😄

@AyushNautiyalDeveloper
Copy link

ok sure @peter-rr will do that.

@AyushNautiyalDeveloper
Copy link

AyushNautiyalDeveloper commented Nov 1, 2023

@peter-rr i am able to get the operationId now. and made a file with that name of it. I am halting work on this for now.

@peter-rr
Copy link
Member

peter-rr commented Nov 2, 2023

@AyushNautiyalDeveloper Nice! Could you open a PR about it so we can review the progress of that work? Thanks 😄

@ayushnau
Copy link
Contributor

ayushnau commented Nov 4, 2023

#876 @peter-rr
The respective function for the operationId is getting created but i have considered only the operationId of the publish. Yet i need to add it for all the operationId in the spec.

@KhudaDad414
Copy link
Member Author

KhudaDad414 commented Nov 6, 2023

@ayushnau glee will only support the spec v3 from now on, so there is no publish. and operationId is always there by spec definitions. so you have to create the function from the receive operations.

@ayushnau
Copy link
Contributor

ayushnau commented Nov 6, 2023

ok @KhudaDad414 will work on that.

@ayushnau
Copy link
Contributor

ayushnau commented Nov 6, 2023

@peter-rr @KhudaDad414 when can i start working on this again.

@aeworxet aeworxet added bounty AsyncAPI Bounty program related label level/medium AsyncAPI Bounty program related label bounty/2023-Q4 AsyncAPI Bounty program related label labels Nov 6, 2023
@aeworxet
Copy link
Contributor

aeworxet commented Nov 6, 2023

@ayushnau

when can i start working on this again.

This issue has been selected for participation in the Bounty Program's calendar round 2023-Q4, so you can start working on this issue as soon as the repository maintainer assigns it to you.

@aeworxet
Copy link
Contributor

aeworxet commented Nov 7, 2023

Bounty Issue's End Of Life (EOL): 2024-02-29 23:59:59 UTC-12:00

@ankur0904
Copy link

@aeworxet @KhudaDad414 @derberg
I want to work on this issue under the Bounty Program.
My previous Contributions:
asyncapi/conference-website#197
asyncapi/website#2149
asyncapi/EDAVisualiser#47
asyncapi/conference-website#195

Thanks
Ankur

@ayushnau
Copy link
Contributor

ayushnau commented Nov 9, 2023

@KhudaDad414 please assign this issue to me as i have already started working on this.

@KhudaDad414
Copy link
Member Author

congratulations @ayushnau. I see you have multiple merged PRs and experience with CLI.

@Souvikns can you assign this issue to @ayushnau ?

@aeworxet
Copy link
Contributor

aeworxet commented Nov 9, 2023

Bounty Issue's Timeline

Complexity Level Assignment date (by GitHub) Start date (by BP rules) End date (by BP rules) Draft PR submission Final PR submission Final PR merge
Medium 2023-11-09 2023-11-13 2023-12-22 2023-11-24 2023-12-08 2023-12-22
Please note that the dates given represent deadlines, not specific dates, so if the goal is reached sooner, it's better.

@AyushNautiyalDeveloper
Copy link

AyushNautiyalDeveloper commented Nov 9, 2023

Bounty Issue's Timeline

Complexity Level Assignment date (by GitHub) Start date (by BP rules) End date (by BP rules) Draft PR submission Final PR submission Final PR merge
Medium 2023-11-09 2023-11-13 2023-12-22 2023-11-24 2023-12-08 2023-12-22

Please note that the dates given represent deadlines, not specific dates, so if the goal is reached sooner, it's better.

ok will try to complete as soon as possible.

@ayushnau
Copy link
Contributor

ayushnau commented Nov 9, 2023

@Souvikns i am creating Delieverables list here. please let me know if there are any other that needs to be added here.

  • All the operationId should be fetched and the respective function (.js) file for those function should be created.
  • The AsyncApi file should be replaced with the one that is provided by the user.
  • Get all the servers components from the asyncapi file.
  • Based on the payload Schema determine the types of the payload using Modelina.

@ayushnau
Copy link
Contributor

ayushnau commented Nov 9, 2023

What I am Doing currently.

  1. Understanding the asyncapi spec v3. may will try to create something out of it.

@ayushnau
Copy link
Contributor

ayushnau commented Nov 9, 2023

@ayushnau hey man I would suggest the following steps:

1. familiarize yourself with [glee](https://github.com/asyncapi/glee). (use the v3 of the spec to write something, maybe a chatbot, maybe a bot that listens to slack messages, anything that comes to your mind.)
   you don't have to know how glee works internally, you just have to use it as a user. if you need some help please reach out.

2. familiarize yourself with cli and how it generate a new glee project.
   good luck.

Note: you don't need to think about the validation with spectral too much, v3 of the spec solves lots of the issues.

@KhudaDad414 actually i was trying to use glee with v3 but I couldnt, getting error no support for v3. can you bit clearify how can i test v3 in glee.

@KhudaDad414
Copy link
Member Author

@ayushnau I just check and it seems to work fine for me.
here is what is did:

  1. created a glee project with: asyncapi new glee
  2. updated the glee version in package.json to 0.28.2
  3. run npm i
  4. updated the asyncapi.yaml file to v3 of spec using studio.
  5. connected to it using websocat

and it works fine for me.
Screenshot 2023-11-15 at 11 57 08

@ayushnau
Copy link
Contributor

@ayushnau I just check and it seems to work fine for me. here is what is did:

1. created a glee project with: `asyncapi new glee`

2. updated the glee version in `package.json` to `0.28.2`

3. run `npm i`

4. updated the `asyncapi.yaml` file to v3 of spec using studio.

5. connected to it using `websocat`

and it works fine for me. Screenshot 2023-11-15 at 11 57 08

ok I have it is resolved now.

@ayushnau
Copy link
Contributor

ayushnau commented Nov 18, 2023

#876 here is the pr.

@ayushnau
Copy link
Contributor

@KhudaDad414 @Souvikns once i fetch the server components what should i create the respective function for that.

asyncapi: 3.0.0
info:
  title: 'Hello, Glee!'
  version: 0.1.0
servers:
  websockets:
    host: 'localhost:3000'
    protocol: ws
channels:
  check:
    address: check
    messages:
      atHello:
        $ref: '#/components/messages/hello'
      goodBye:
        $ref: '#/components/messages/hello'
operations:
  atHello:
    action: receive
    channel:
      $ref: '#/channels/check'
    messages:
      - $ref: '#/components/messages/hello'
  goodBye:
    action: send
    channel:
      $ref: '#/channels/check'
    messages:
      - $ref: '#/components/messages/hello'
components:
  messages:
    hello:
      payload:
        type: string

let suppose this is the code how should the server component should look like.

@KhudaDad414
Copy link
Member Author

@ayushnau From this AsyncAPI document I would extract the following info:

  1. generate the message type with modelina(eg. hello)
  2. create a atHello.ts file in the functions directory.
  3. the function should be something like:
const atHello: AtHelloFunction = ({ payload }) => {
  // the logic here...
  // the payload type is generated by Modelina from the message schema.
  // The current function definitation is:

  // type GleeFunction = (
  //   event: GleeFunctionEvent
  // ) => Promise<GleeFunctionReturn>
  // can be imported from src/lib/index.d.ts
}

export default atHello

you can create the AtHelloFunction type by manipulating the GleeFunction type and setting the payload type to your message type.
3) set GLEE_SERVER_NAMES=websockets in the .env file.

there is no authentication here so we skip that part.

@aeworxet
Copy link
Contributor

@ayushnau Please provide the Draft PR.

@ayushnau
Copy link
Contributor

ayushnau commented Nov 29, 2023

@aeworxet here is the draft pr. #890

@ayushnau ayushnau mentioned this issue Dec 1, 2023
4 tasks
@aeworxet
Copy link
Contributor

Due to the online absence of the AsyncAPI Maintainer (@KhudaDad414) in Slack for a period of more than three working days in a row, all target dates of the Bounty Issue's Timeline have been increased by two calendar weeks.

Bounty Issue's Timeline Extended

Complexity Level Assignment date (by GitHub) Start date (by BP rules) End date (by BP rules) Draft PR submission Final PR submission Final PR merge
Medium 2023-11-09 2023-11-13 2024-01-05 2023-12-08 2023-12-22 2024-01-05
Please note that the dates given represent deadlines, not specific dates, so if the goal is reached sooner, it's better.

@aeworxet
Copy link
Contributor

@asyncapi/bounty_team

@aeworxet
Copy link
Contributor

Because the requirements for this issue have changed drastically, AsyncAPI Maintainer (@KhudaDad414) has requested that this Bounty Issue be reclassified as Advanced and the Timeline for it extended.

Bounty Issue is Reclassified and its Timeline Extended

Complexity Level Assignment date (by GitHub) Start date (by BP rules) End date (by BP rules) Draft PR submission Final PR submission Final PR merge
Advanced 2023-11-09 2023-11-13 2024-02-02 2023-12-29 2024-01-19 2024-02-02
Please note that the dates given represent deadlines, not specific dates, so if the goal is reached sooner, it's better.

@ayushnau
Copy link
Contributor

@KhudaDad414 Currently, when a new project is created, it does not appear under a project folder. Will this remain final, or will it change? We have a flag for the folder name in the glee command.

@KhudaDad414
Copy link
Member Author

@ayushnau generator supports specifying the output folder. I think it's ''--output", but you can check its docs.

@ayushnau
Copy link
Contributor

@KhudaDad414 Added the template in the cli glee command. can you check.

@KhudaDad414
Copy link
Member Author

@aeworxet, the issue has been resolved and @ayushnau's PR is ready to be merged.

@Souvikns
Copy link
Member

Souvikns commented Feb 1, 2024

With the merging of #890 this issue has been solved and the features is working as expected, all thanks to @ayushnau

@aeworxet
Copy link
Contributor

aeworxet commented Feb 1, 2024

Bounty Issue Completed 🎉

@ayushnau, please go to the AsyncAPI page on Open Collective and submit an invoice for USD 400.00 with the expense title Bounty cli#683, tag bounty, and full URL of this Bounty Issue in the description.

@ayushnau
Copy link
Contributor

ayushnau commented Feb 1, 2024

Bounty Issue Completed 🎉

@ayushnau, please go to the AsyncAPI page on Open Collective and submit an invoice for USD 400.00 with the expense title Bounty cli#683, tag bounty, and full URL of this Bounty Issue in the description.

@aeworxet i have raised the invoice. please check.

@aeworxet aeworxet moved this to Completed in Bounty Program Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty AsyncAPI Bounty program related label bounty/2023-Q4 AsyncAPI Bounty program related label enhancement New feature or request level/medium AsyncAPI Bounty program related label
Projects
Status: Completed
Status: Done
Development

Successfully merging a pull request may close this issue.

10 participants