@ioka-technologies/asyncapi-ts-client-template 0.0.33 → 0.0.35
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ioka-technologies/asyncapi-ts-client-template",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"description": "TypeScript AsyncAPI client generator template compatible with rust-asyncapi patterns",
|
|
5
5
|
"main": "template/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
},
|
|
93
93
|
"files": [
|
|
94
94
|
"template/**/*",
|
|
95
|
+
"!template/**/*.dev",
|
|
95
96
|
"dist/common/**/*",
|
|
96
97
|
"examples/**/*",
|
|
97
98
|
"README.md",
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security analysis helper functions for TypeScript client template
|
|
3
|
-
* Most common security utilities have been moved to the shared @common package.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
analyzeOperationSecurity,
|
|
8
|
-
operationHasSecurity,
|
|
9
|
-
hasSecuritySchemes
|
|
10
|
-
} from '../../../common/src/index.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get security scheme type from AsyncAPI security scheme definition
|
|
14
|
-
*
|
|
15
|
-
* @param {object} securityScheme - AsyncAPI security scheme object
|
|
16
|
-
* @returns {string} Security scheme type ('jwt', 'basic', 'apikey', etc.)
|
|
17
|
-
*/
|
|
18
|
-
function getSecuritySchemeType(securityScheme) {
|
|
19
|
-
try {
|
|
20
|
-
if (securityScheme.type && typeof securityScheme.type === 'function') {
|
|
21
|
-
return securityScheme.type();
|
|
22
|
-
}
|
|
23
|
-
if (securityScheme.type) {
|
|
24
|
-
return securityScheme.type;
|
|
25
|
-
}
|
|
26
|
-
if (securityScheme._json && securityScheme._json.type) {
|
|
27
|
-
return securityScheme._json.type;
|
|
28
|
-
}
|
|
29
|
-
return 'unknown';
|
|
30
|
-
} catch (e) {
|
|
31
|
-
return 'unknown';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Extract security requirements for all operations in the AsyncAPI spec
|
|
37
|
-
*
|
|
38
|
-
* @param {object} asyncapi - AsyncAPI specification object
|
|
39
|
-
* @returns {object} Map of operation names to their security requirements
|
|
40
|
-
*/
|
|
41
|
-
function extractOperationSecurityMap(asyncapi) {
|
|
42
|
-
const securityMap = {};
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const operations = asyncapi.operations && asyncapi.operations();
|
|
46
|
-
if (operations) {
|
|
47
|
-
// Handle AsyncAPI parser collection - use .all() method to get array
|
|
48
|
-
const operationArray = operations.all ? operations.all() : Object.values(operations);
|
|
49
|
-
|
|
50
|
-
operationArray.forEach((operation) => {
|
|
51
|
-
// Get operation ID
|
|
52
|
-
let operationId = null;
|
|
53
|
-
if (operation._meta && operation._meta.id) {
|
|
54
|
-
operationId = operation._meta.id;
|
|
55
|
-
} else if (operation.id && typeof operation.id === 'function') {
|
|
56
|
-
operationId = operation.id();
|
|
57
|
-
} else if (operation.id) {
|
|
58
|
-
operationId = operation.id;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (operationId) {
|
|
62
|
-
const securityAnalysis = analyzeOperationSecurity(operation);
|
|
63
|
-
securityMap[operationId] = securityAnalysis;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
} catch (e) {
|
|
68
|
-
console.warn('Error extracting operation security map:', e.message);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return securityMap;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Export all functions
|
|
75
|
-
export {
|
|
76
|
-
// Re-export common security utilities for backward compatibility
|
|
77
|
-
analyzeOperationSecurity,
|
|
78
|
-
operationHasSecurity as operationRequiresAuth,
|
|
79
|
-
hasSecuritySchemes,
|
|
80
|
-
|
|
81
|
-
// TypeScript client specific functions
|
|
82
|
-
getSecuritySchemeType,
|
|
83
|
-
extractOperationSecurityMap
|
|
84
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import { File } from '@asyncapi/generator-react-sdk';
|
|
3
|
-
import { generateTypeScriptModels } from '../../../common/src/index.js';
|
|
4
|
-
|
|
5
|
-
export default function ({ asyncapi, params }) {
|
|
6
|
-
// Generate models using the common helper
|
|
7
|
-
const models = generateTypeScriptModels(asyncapi, {
|
|
8
|
-
includeMessageTypes: true // TypeScript client includes message type constants
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<File name="models.ts">
|
|
13
|
-
{`// Generated TypeScript models from AsyncAPI specification
|
|
14
|
-
|
|
15
|
-
${models.generateComponentSchemas()}
|
|
16
|
-
${models.generateMessageSchemas()}
|
|
17
|
-
${models.generateMessageTypes()}
|
|
18
|
-
`}
|
|
19
|
-
</File>
|
|
20
|
-
);
|
|
21
|
-
}
|