@ioka-technologies/asyncapi-rust-client-template 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,18 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import { File } from '@asyncapi/generator-react-sdk';
3
+ import {
4
+ toPascalCase,
5
+ isTemplateVariable,
6
+ extractAsyncApiInfo,
7
+ resolveTemplateParameters
8
+ } from '../helpers/index.js';
3
9
 
4
10
  module.exports = function ({ asyncapi, params }) {
5
- // Helper function to convert title to PascalCase
6
- function toPascalCase(str) {
7
- return str.replace(/[^a-zA-Z0-9]/g, ' ')
8
- .split(' ')
9
- .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
10
- .join('');
11
- }
12
-
13
- const title = asyncapi.info().title();
14
- const description = asyncapi.info().description();
15
- const version = asyncapi.info().version();
11
+ const asyncApiInfo = extractAsyncApiInfo(asyncapi);
12
+ const { title, version, description } = asyncApiInfo;
16
13
 
17
- const clientName = (params.clientName && !params.clientName.includes('{{'))
18
- ? params.clientName
19
- : `${toPascalCase(title)}Client`;
14
+ const resolvedParams = resolveTemplateParameters(params, asyncApiInfo);
15
+ const { clientName } = resolvedParams;
20
16
 
21
17
  // Helper function to format description for Rust doc comments
22
18
  function formatDescription(desc) {