-
-
Notifications
You must be signed in to change notification settings - Fork 303
refactor: simplify prop passing to ClientClass by using asyncapi object #1571
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
base: master
Are you sure you want to change the base?
refactor: simplify prop passing to ClientClass by using asyncapi object #1571
Conversation
|
WalkthroughThe code updates the Python websocket client template by removing the Changes
Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
🔇 Additional comments (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (2)
packages/templates/clients/websocket/python/components/ClientClass.js
(2 hunks)packages/templates/clients/websocket/python/template/client.py.js
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/templates/clients/websocket/python/template/client.py.js (4)
packages/templates/clients/websocket/python/components/ClientClass.js (3)
server
(16-16)info
(14-14)ClientClass
(13-36)packages/helpers/src/servers.js (1)
getServer
(34-45)packages/templates/clients/websocket/python/components/FileHeaderInfo.js (1)
FileHeaderInfo
(3-41)packages/templates/clients/websocket/python/components/Requires.js (1)
Requires
(3-14)
packages/templates/clients/websocket/python/components/ClientClass.js (5)
packages/templates/clients/websocket/python/template/client.py.js (2)
info
(9-9)server
(8-8)packages/templates/clients/websocket/javascript/template/client.js.js (5)
info
(9-9)clientName
(11-11)server
(8-8)serverUrl
(12-12)title
(10-10)apps/hooks/src/index.js (1)
asyncapi
(6-6)packages/helpers/src/servers.js (2)
getServer
(34-45)getServerUrl
(8-22)apps/generator/cli.js (1)
params
(20-20)
🪛 Biome (1.9.4)
packages/templates/clients/websocket/python/components/ClientClass.js
[error] 15-15: Shouldn't redeclare 'clientName'. Consider to delete it or rename it.
'clientName' is defined here:
(lint/suspicious/noRedeclare)
[error] 17-17: Shouldn't redeclare 'serverUrl'. Consider to delete it or rename it.
'serverUrl' is defined here:
(lint/suspicious/noRedeclare)
[error] 18-18: Shouldn't redeclare 'title'. Consider to delete it or rename it.
'title' is defined here:
(lint/suspicious/noRedeclare)
🔇 Additional comments (4)
packages/templates/clients/websocket/python/template/client.py.js (3)
2-2
: Simplified imports for helper functionsThe import statement has been streamlined to only include the
getServer
helper function that's needed in this file, removinggetClientName
andgetServerUrl
which are now imported in the ClientClass component.
10-12
: Removed unnecessary variable declarationsThe
title
,clientName
, andserverUrl
variables have been removed as they're no longer needed in this file. The responsibility for deriving these values has been delegated to the ClientClass component.
20-20
: Refactored prop passing to use asyncapi objectInstead of passing individual props (
clientName
,serverUrl
,title
), now passing the entireasyncapi
object andparams
to the ClientClass component. This simplifies the parent component and shifts the data extraction responsibility to the child component.packages/templates/clients/websocket/python/components/ClientClass.js (1)
2-2
: Added required helper function importsImported the necessary helper functions (
getClientName
,getServerUrl
,getServer
) to derive props internally instead of receiving them from the parent component.
packages/templates/clients/websocket/python/components/ClientClass.js
Outdated
Show resolved
Hide resolved
const info = asyncapi.info(); | ||
const clientName = getClientName(info); | ||
const server = getServer(asyncapi.servers(), params.server); | ||
const serverUrl = getServerUrl(server); | ||
const title = info.title(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Ensure asyncapi and params are properly validated
Before using asyncapi
and params
, consider adding validation to prevent potential runtime errors. The getServer
function will throw an error if params.server
is undefined.
🏁 Script executed:
#!/bin/bash
# Description: Check how params.server is handled across the codebase
# Search for usage of params.server to see if it's validated before being used
rg "params.server" --type js
Length of output: 556
🏁 Script executed:
#!/bin/bash
# Inspecting the context around params.server usage in ClientClass.js
sed -n '1,200p' packages/templates/clients/websocket/python/components/ClientClass.js
Length of output: 1373
🏁 Script executed:
#!/bin/bash
# Locate the template.json for the Python WebSocket client template
template_file=$(find packages/templates/clients/websocket/python -maxdepth 2 -type f -name 'template.json' | head -n1)
echo "Found template file: $template_file"
if [[ -n "$template_file" ]]; then
echo "Showing params section around 'server':"
grep -R -n '"params"' -n "$template_file" -C3
grep -R -n '"server"' -n "$template_file" -C3
else
echo "No template.json found in the Python WebSocket client template directory."
fi
Length of output: 344
Update ClientClass to accept and validate asyncapi
and params.server
The component currently destructures the wrong props and uses asyncapi
/params
without ever receiving them, causing potential undefined errors (and getServer
will certainly blow up if params.server
is missing).
• In packages/templates/clients/websocket/python/components/ClientClass.js
, change the function signature to pull in { asyncapi, params }
instead of { clientName, serverUrl, title }
.
• Add runtime checks for both asyncapi
and params.server
before using them.
Suggested diff:
-export function ClientClass({ clientName, serverUrl, title }) {
+export function ClientClass({ asyncapi, params }) {
+ if (!asyncapi) {
+ throw new Error('Missing required "asyncapi" context.');
+ }
+ if (!params || !params.server) {
+ throw new Error('Missing required "server" param.');
+ }
const info = asyncapi.info();
- const clientName = getClientName(info);
- const server = getServer(asyncapi.servers(), params.server);
- const serverUrl = getServerUrl(server);
- const title = info.title();
+ const clientName = getClientName(info);
+ const server = getServer(asyncapi.servers(), params.server);
+ const serverUrl = getServerUrl(server);
+ const title = info.title();
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const info = asyncapi.info(); | |
const clientName = getClientName(info); | |
const server = getServer(asyncapi.servers(), params.server); | |
const serverUrl = getServerUrl(server); | |
const title = info.title(); | |
export function ClientClass({ asyncapi, params }) { | |
if (!asyncapi) { | |
throw new Error('Missing required "asyncapi" context.'); | |
} | |
if (!params || !params.server) { | |
throw new Error('Missing required "server" param.'); | |
} | |
const info = asyncapi.info(); | |
const clientName = getClientName(info); | |
const server = getServer(asyncapi.servers(), params.server); | |
const serverUrl = getServerUrl(server); | |
const title = info.title(); | |
// …rest of implementation… | |
} |
🧰 Tools
🪛 Biome (1.9.4)
[error] 15-15: Shouldn't redeclare 'clientName'. Consider to delete it or rename it.
'clientName' is defined here:
(lint/suspicious/noRedeclare)
[error] 17-17: Shouldn't redeclare 'serverUrl'. Consider to delete it or rename it.
'serverUrl' is defined here:
(lint/suspicious/noRedeclare)
[error] 18-18: Shouldn't redeclare 'title'. Consider to delete it or rename it.
'title' is defined here:
(lint/suspicious/noRedeclare)
🤖 Prompt for AI Agents
In packages/templates/clients/websocket/python/components/ClientClass.js around
lines 14 to 18, the function currently destructures incorrect props and uses
asyncapi and params without receiving them, which can cause runtime errors,
especially in getServer if params.server is undefined. Update the function
signature to accept { asyncapi, params } instead of { clientName, serverUrl,
title }, then add runtime validation to ensure asyncapi and params.server are
defined before using them, throwing or handling errors appropriately to prevent
failures.
packages/templates/clients/websocket/python/template/client.py.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/templates/clients/websocket/python/components/ClientClass.js (1)
14-14
: Function signature inconsistent with PR objectives.The function signature still uses the old destructured approach instead of the intended
asyncapi
object approach mentioned in the PR objectives. This contradicts the goal to "simplify prop passing to ClientClass by using asyncapi object."This matches the previous review feedback that recommended changing from
{ clientName, serverUrl, title }
to{ asyncapi, params }
to resolve variable redeclaration issues and align with the intended design.Likely an incorrect or invalid review comment.
🧹 Nitpick comments (1)
packages/templates/clients/websocket/python/components/ClientClass.js (1)
13-13
: Remove extra blank line.Static analysis reports more than 1 blank line is not allowed.
- +🧰 Tools
🪛 GitHub Check: Test NodeJS PR - ubuntu-latest
[failure] 13-13:
More than 1 blank line not allowed
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/templates/clients/websocket/python/components/ClientClass.js
(2 hunks)packages/templates/clients/websocket/python/template/client.py.js
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/templates/clients/websocket/python/template/client.py.js
🧰 Additional context used
🪛 GitHub Check: Test NodeJS PR - ubuntu-latest
packages/templates/clients/websocket/python/components/ClientClass.js
[failure] 2-2:
'getServer' is defined but never used
[failure] 2-2:
'getServerUrl' is defined but never used
[failure] 2-2:
'getClientName' is defined but never used
[failure] 13-13:
More than 1 blank line not allowed
🪛 GitHub Actions: PR testing - if Node project
packages/templates/clients/websocket/python/components/ClientClass.js
[error] 2-2: ESLint: 'getClientName' is defined but never used. (no-unused-vars)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Acceptance tests for generated templates
- GitHub Check: Test generator as dependency with Node 18
- GitHub Check: Test generator as dependency with Node 20
@@ -1,4 +1,5 @@ | |||
import { Text } from '@asyncapi/generator-react-sdk'; | |||
import { getClientName, getServerUrl, getServer } from '@asyncapi/generator-helpers'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete the refactoring to use imported helper functions.
The helper functions are imported but never used, causing ESLint errors. This indicates incomplete implementation of the intended refactoring to use the asyncapi
object.
Based on the PR objectives and past review comments, the function signature should be updated to use these helpers:
-export function ClientClass({ clientName, serverUrl, title, queryParams }) {
+export function ClientClass({ asyncapi, params }) {
+ if (!asyncapi) {
+ throw new Error('Missing required "asyncapi" context.');
+ }
+ if (!params || !params.server) {
+ throw new Error('Missing required "server" param.');
+ }
+
+ const info = asyncapi.info();
+ const clientName = getClientName(info);
+ const server = getServer(asyncapi.servers(), params.server);
+ const serverUrl = getServerUrl(server);
+ const title = info.title();
+ const queryParams = params.queryParams;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import { getClientName, getServerUrl, getServer } from '@asyncapi/generator-helpers'; | |
import { getClientName, getServerUrl, getServer } from '@asyncapi/generator-helpers'; | |
export function ClientClass({ asyncapi, params }) { | |
if (!asyncapi) { | |
throw new Error('Missing required "asyncapi" context.'); | |
} | |
if (!params || !params.server) { | |
throw new Error('Missing required "server" param.'); | |
} | |
const info = asyncapi.info(); | |
const clientName = getClientName(info); | |
const server = getServer(asyncapi.servers(), params.server); | |
const serverUrl = getServerUrl(server); | |
const title = info.title(); | |
const queryParams = params.queryParams; | |
// …rest of the component implementation… | |
} |
🧰 Tools
🪛 GitHub Check: Test NodeJS PR - ubuntu-latest
[failure] 2-2:
'getServer' is defined but never used
[failure] 2-2:
'getServerUrl' is defined but never used
[failure] 2-2:
'getClientName' is defined but never used
🪛 GitHub Actions: PR testing - if Node project
[error] 2-2: ESLint: 'getClientName' is defined but never used. (no-unused-vars)
🤖 Prompt for AI Agents
In packages/templates/clients/websocket/python/components/ClientClass.js at line
2, the imported helper functions getClientName, getServerUrl, and getServer from
'@asyncapi/generator-helpers' are not used, causing ESLint errors. Refactor the
code to replace any direct usage of the asyncapi object with these helper
functions by updating the function signatures and calls accordingly to utilize
getClientName, getServerUrl, and getServer for cleaner and consistent code.
@Adi-204 check this out.. do let me know then we'll inform derberg about this..! |
@Aditya08Vashisht man you didn't change anything just look at Files changed tab. |
what! wait a min! |
must be some petty mistake! let me see! @Adi-204 |
Hey @Adi-204 !! are you there right now |
@coderabbitai[bot] as just resolve the conflicts and merge into the master branch i was shocked to see there only 1 file changed and no chnages shown done by me.. even last time reviewer said you have probably not pulled latest master branch version because currently in client.py.js we are passing 4 params here clientName, serverUrl, title and queryParams but your code has only 3. that you can clearly see in the photo it merge to master branch now!! what is the reason it is giving me like this! |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@Aditya08Vashisht I can see your confusion! Let me examine the current state of the files to understand what happened with your refactoring work. 🏁 Script executed:
Length of output: 2314 I can see exactly what happened! Looking at the files, the main refactoring work is actually missing. Here's the current situation: What Actually Got Committed
What Should Have Been DoneThe export function ClientClass({ clientName, serverUrl, title, queryParams }) { But according to issue #1564, it should be refactored to: export function ClientClass({ asyncapi, params }) {
// Extract values internally using helper functions
const server = getServer(asyncapi.servers(), params.server);
const info = asyncapi.info();
const title = info.title();
const queryParams = getQueryParams(asyncapi.channels());
const clientName = getClientName(info, params.appendClientSuffix, params.customClientName);
const serverUrl = getServerUrl(server);
// Rest of component logic...
} And then <ClientClass asyncapi={asyncapi} params={params} /> What Happened to Your Changes?Your refactoring work likely got lost due to:
Next StepsYou need to implement the actual refactoring. Would you like me to help you plan the complete code changes needed to properly implement this refactor? |
just tell me how can i get my changed and updated files back @coderabbitai[bot] |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@Aditya08Vashisht Don't worry! Your changes aren't necessarily lost forever. Let me help you search for them using Git's recovery features. Based on what we find, I can guide you through the specific recovery steps. Your changes might be:
Once we see the results, I'll help you recover your refactoring work! 🔍 🏁 Script executed:
Length of output: 1183 @Aditya08Vashisht I see the issue now! This is a CodeRabbit sandbox environment - it only contains the current PR branch. Your actual development work was done on your local machine, but those changes weren't properly committed and pushed. What You Need to DoGo back to your local development environment (your computer where you were coding) and run these commands: # Check your local repository status
git status
# Check your local reflog to find your lost changes
git reflog --oneline -20
# Check if you have any stashed changes locally
git stash list
# Look for branches with your work
git branch -a
# Check recent commits that might contain your refactoring
git log --grep="refactor" --grep="clientclass" --oneline -10
# Check if you have uncommitted changes in your working directory
git diff
git diff --staged Likely Scenarios
Recovery StepsOnce you find your changes locally, you'll need to:
The current PR only shows minor import changes because your main refactoring work never made it from your local machine to the remote repository. Check your local environment first! 🔍 |
okay so i see the files are not changed in my brnach at there i jst don't why but now i am fixing the things and pushing again! |
@Adi-204 just give me 12 hrs I'll fix all these petty wrong things from my local codespace that are getting wrong! |
@Adi-204 hey brother! You can have a lokk at this PR now! That's what i have changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/templates/clients/websocket/python/components/ClientClass.js (1)
12-12
:⚠️ Potential issueComplete the refactoring to use asyncapi object as per PR objectives.
The function signature still uses individual props instead of the intended
{ asyncapi, params }
structure mentioned in the PR objectives. This refactoring was supposed to "simplify prop passing to ClientClass by using asyncapi object" but the current implementation doesn't reflect this change.Based on the PR objectives and past review comments, apply this diff to complete the refactoring:
-export function ClientClass({ clientName, serverUrl, title, queryParams, }) { +export function ClientClass({ asyncapi, params }) { + if (!asyncapi) { + throw new Error('Missing required "asyncapi" context.'); + } + if (!params || !params.server) { + throw new Error('Missing required "server" param.'); + } + + const info = asyncapi.info(); + const clientName = getClientName(info); + const server = getServer(asyncapi.servers(), params.server); + const serverUrl = getServerUrl(server); + const title = info.title(); + const queryParams = params.queryParams;You'll also need to import the helper functions at the top of the file:
import { Text } from '@asyncapi/generator-react-sdk'; +import { getClientName, getServer, getServerUrl } from '@asyncapi/generator-helpers'; import { Constructor } from './Constructor';
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/templates/clients/websocket/python/components/ClientClass.js
(2 hunks)packages/templates/clients/websocket/python/template/client.py.js
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/templates/clients/websocket/python/template/client.py.js
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test generator as dependency with Node 20
- GitHub Check: Test generator as dependency with Node 18
🔇 Additional comments (1)
packages/templates/clients/websocket/python/components/ClientClass.js (1)
7-7
: Import change looks good.The addition of
SendEchoMessage
import aligns with simplifying the component structure.
packages/templates/clients/websocket/python/components/ClientClass.js
Outdated
Show resolved
Hide resolved
Hey @Adi-204 can you suggest why some of the testing errors are coming now as the files are now visible! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit confused, why did you removed all the new code changes recently done in client with old ones.
I would suggest to restore all the changes in the local and then do refactoring of props again.
@@ -4,14 +4,12 @@ import { Connect } from './Connect'; | |||
import { RegisterMessageHandler } from './RegisterMessageHandler'; | |||
import { RegisterErrorHandler } from './RegisterErrorHandler'; | |||
import { HandleMessage } from './HandleMessage'; | |||
import { SendOperation } from './SendOperation'; | |||
import { Send } from './Send'; | |||
import { SendEchoMessage } from './SendEchoMessage'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove correct imports and added SendEchoMessage
?
In latest master branch code we don't have any component such as SendEchoMessage
packages/templates/clients/websocket/python/components/ClientClass.js
Outdated
Show resolved
Hide resolved
import { FileHeaderInfo } from '../components/FileHeaderInfo'; | ||
import { Requires } from '../components/Requires'; | ||
import { ClientClass } from '../components/ClientClass'; | ||
|
||
export default function ({ asyncapi, params }) { | ||
const server = getServer(asyncapi.servers(), params.server); | ||
const info = getInfo(asyncapi); | ||
const title = getTitle(asyncapi); | ||
const info = asyncapi.info(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove those newly added helpers - getInfo and getTitle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually i am working on this issue after quite a bit of time so things were not in my mind totally regarding the issue!
give me 2 days i add all these essential thinhgs again (my exams are on currently on the go)
|
@coderabbitai[bot] what's your take on this one now |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed:
Length of output: 2876 @Aditya08Vashisht I can see what's happening now! The changes are visible, but there are some critical issues that need to be addressed: 🚨 Critical Bug FoundYour <SendOperation sendOperations={sendOperations} clientName={clientName} />
<Send sendOperations={sendOperations} /> This will cause the application to crash since 📋 Assessment Against PR Objectives❌ Refactoring Incomplete: The main goal from issue #1564 was to:
Current State:
🔧 What Needs to Be Fixed
// In ClientClass.js - you need to add back operations logic or remove sendOperations references
// ClientClass should be:
export function ClientClass({ asyncapi, params }) {
// Extract values here using helper functions
const server = getServer(asyncapi.servers(), params.server);
const info = asyncapi.info();
// ... rest of extractions
}
// client.py.js should just pass:
<ClientClass asyncapi={asyncapi} params={params} /> The testing errors you mentioned are likely due to the undefined |
yes please go ahead! @coderabbitai[bot] |
Tip For best results, initiate chat on the files or code changes. A summary of the edits CodeRabbit can apply:
A plan of each step that CodeRabbit will take in order to execute the edits for each file (with inline rough draft snippets): ✏️ packages/templates/clients/websocket/python/components/ClientClass.jsAt the top of ClientClass.js, add an import for the helper functions. For example, directly after the existing imports insert: Change the component signature on line 13 from: Immediately inside the function body, insert extraction of all values from asyncapi and params: Remove the old destructured props list; ensure the JSX uses the newly declared local constants. For instance, confirm lines 17–24 now reference clientName, serverUrl, title, and queryParams directly. Verify that the previous runtime error is resolved by confirming lines 26–27 now reference the local sendOperations constant: Open packages/templates/clients/websocket/python/template/client.py.js. Change the function header to: Run the generator’s test suite and sample generation commands to ensure: ✏️ packages/templates/clients/websocket/python/template/client.py.jsIn client.py.js, delete the helper imports on lines 1–6 so only these two lines remain at the top:
Replace lines 9–27 (the entire default export function body) with the simplified pass-through:
Open packages/templates/clients/websocket/python/components/ClientClass.js. Change the export signature on line 13 from:
At the top of ClientClass.js, immediately after React imports, insert the helper imports:
Inside the ClientClass function body, before the return statement, add extraction logic:
In the JSX return of ClientClass.js, replace all references to props.clientName, props.serverUrl, props.title, and props.queryParams with the corresponding local variables clientName, serverUrl, title, and queryParams. Remove the two lines rendering Save both files. Run the generator preview or test suite to verify there are no compilation errors, that ClientClass now correctly consumes asyncapi and params, and that the undefined sendOperations issue is resolved.
|
@coderabbitai[bot] for taking further actions i think i have missed some of the previous things while making the changes this time.. |
Tip For best results, initiate chat on the files or code changes. A summary of the edits CodeRabbit can apply:
A plan of each step that CodeRabbit will take in order to execute the edits for each file (with inline rough draft snippets): ✏️ packages/templates/clients/websocket/python/components/ClientClass.jsAt the top of the file, after the existing Text import, add an import for the helper functions: import { getServer, getServerUrl, getQueryParams, getClientName } from '../helpers'; This will allow extracting values from the asyncapi object and params. Remove the imports related to operations by deleting these lines: import { SendOperation } from './SendOperation';
import { Send } from './Send';
import { RegisterOutgoingProcessor } from './RegisterOutgoingProcessor'; This removes operations support as it's being refactored. Change the component signature on line 13 from: export function ClientClass({ clientName, serverUrl, title, queryParams, }) { to: export function ClientClass({ asyncapi, params }) { so that ClientClass now accepts the asyncapi object and params directly. Immediately inside the function body, before the return statement, insert extraction of all values from asyncapi and params: const server = getServer(asyncapi.servers(), params.server);
const info = asyncapi.info();
const title = info.title();
const queryParams = getQueryParams(asyncapi.channels());
const clientName = getClientName(info, params.appendClientSuffix, params.customClientName);
const serverUrl = getServerUrl(server); This prepares all necessary values locally. In the JSX returned by the component, remove the <RegisterOutgoingProcessor />
<SendOperation sendOperations={sendOperations} clientName={clientName} />
<Send sendOperations={sendOperations} /> This removes undefined references and operations-related UI. Review the updated JSX to ensure it now reads: <Text>
<Text newLines={2}>{`class ${clientName}:`}</Text>
<Constructor serverUrl={serverUrl} query={queryParams} />
<Connect title={title} />
<RegisterMessageHandler />
<RegisterErrorHandler />
<HandleMessage />
<HandleError />
<CloseConnection />
</Text> Confirm no broken imports or undefined variables remain. Save the file and run the generator’s test suite to verify there are no compilation errors and that ClientClass now correctly consumes asyncapi and params without operations bugs. ✏️ packages/templates/clients/websocket/python/template/client.py.jsAt the top of the file, remove all imports except for File. After the existing import of File on line 1, add a single import for ClientClass: import { ClientClass } from '../components/ClientClass'; Replace the entire body of the default export (from the function declaration on line 9 through the closing brace on line 27) with a simplified pass-through implementation: export default function({ asyncapi, params }) {
return (
<File name={params.clientFileName}>
<ClientClass asyncapi={asyncapi} params={params} />
</File>
);
} Save the file and run your AsyncAPI generator’s test suite or preview command to confirm that the template compiles successfully, that the client file is generated with only asyncapi and params, and that there are no undefined variables or errors.
|
Tip For best results, initiate chat on the files or code changes. A summary of the edits CodeRabbit can apply:
A plan of each step that CodeRabbit will take in order to execute the edits for each file (with inline rough draft snippets): ✏️ packages/templates/clients/websocket/python/components/ClientClass.jsDelete the imports for SendOperation and Send. Remove lines: After the existing imports (e.g., after Change the component signature on line 13 from: Immediately inside the function body (directly after the signature and before the JSX return), insert extraction logic to compute all values from the asyncapi and params objects: Remove the two JSX lines that reference the undefined sendOperations variable. Delete lines 26 and 27: Verify that all JSX tags now reference the new local constants. For example: Save the file and run your template generator’s tests or preview command. Confirm that there are no undefined variable errors and that ✏️ packages/templates/clients/websocket/python/template/client.py.jsAt the top of client.py.js, remove all helper imports except File and ClientClass. Delete lines 2–6 so that only the following imports remain:
Inside the default export function, delete the extraction logic on lines 10–15 (all const declarations for server, info, title, queryParams, clientName, serverUrl). Also remove the and JSX on lines 19–23, as the template will now delegate all extraction to ClientClass. Replace the entire return block (lines 17–25) with a simplified pass-through that only forwards asyncapi and params. Update the function body to:
Save and close client.py.js. Then open packages/templates/clients/websocket/python/components/ClientClass.js for refactoring. In ClientClass.js, update the component signature to accept only asyncapi and params. Find and replace:
Immediately after the React import at the top of ClientClass.js, insert imports for all helper functions needed to extract values from asyncapi:
Within the ClientClass function body and before the return statement, insert the extraction logic:
Remove any previous destructuring of clientName, serverUrl, title, and queryParams from the function signature and body. Remove references to or if they exist in ClientClass.js. Ensure all JSX references inside the return block use the newly declared local variables. In particular, confirm that the operations rendering now uses the defined sendOperations variable:
Save ClientClass.js. Run the AsyncAPI generator’s preview or test command to confirm there are no undefined variables, that ClientClass compiles successfully, and that it receives asyncapi and params correctly. Adjust any import paths or syntax issues surfaced during testing.
|
Hey @Adi-204 sorry to disturb you in this way! I have changed most of the things like that sendEcho and others .. but just currently my exams are going on! and the issue is that i have forgot to change some essential things (and currently am blankout with this issue 😓)can you comment down things on that code(like add this or remove this) and help with that! please! also i feel there not more big changes other than these essential changes only! |
@Aditya08Vashisht I would suggest to focus on one thing. The issue this PR is solving is just refactoring so take your time and maybe solve when you are free. |
yeah sure thing! |
fixes: #1564
done the props changes in client.py.js
and clientclass.js inside the components
please do check this out now
I know it is not mentioned to me please lets check this out!..please!
I have done a lot hardwork for all these small-small changes in these files
Summary by CodeRabbit