chrometools-mcp 3.3.6 → 3.3.9
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/CHANGELOG.md +87 -0
- package/README.md +129 -24
- package/SPEC-pom-integration.md +227 -0
- package/SPEC-swagger-api-tools.md +3101 -0
- package/browser/page-manager.js +83 -0
- package/index.js +623 -201
- package/package.json +2 -1
- package/pom/apom-tree-converter.js +287 -51
- package/recorder/page-object-generator.js +45 -1
- package/server/tool-definitions.js +57 -6
- package/server/tool-schemas.js +31 -0
- package/test-swagger-phase1.mjs +959 -0
- package/utils/api-generators/api-models-python.js +448 -0
- package/utils/api-generators/api-models-typescript.js +375 -0
- package/utils/code-generators/code-generator-base.js +111 -6
- package/utils/code-generators/playwright-python.js +74 -0
- package/utils/code-generators/playwright-typescript.js +69 -0
- package/utils/code-generators/pom-integrator.js +373 -0
- package/utils/code-generators/selenium-java.js +72 -0
- package/utils/code-generators/selenium-python.js +75 -0
- package/utils/hints-generator.js +114 -19
- package/utils/openapi/helpers.js +25 -0
- package/utils/openapi/parser.js +448 -0
- package/utils/openapi/ref-resolver.js +149 -0
- package/utils/openapi/type-mapper.js +174 -0
- package/nul +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* utils/openapi/type-mapper.js
|
|
3
|
+
*
|
|
4
|
+
* Maps OpenAPI types to TypeScript and Python types.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Type mapper for OpenAPI → target language
|
|
9
|
+
*/
|
|
10
|
+
export class TypeMapper {
|
|
11
|
+
/**
|
|
12
|
+
* Convert OpenAPI schema to TypeScript type string
|
|
13
|
+
* @param {Object} schema - OpenAPI schema object
|
|
14
|
+
* @param {string} [schemaName] - named schema reference
|
|
15
|
+
* @returns {string} - TypeScript type
|
|
16
|
+
*/
|
|
17
|
+
static toTypeScript(schema, schemaName = null) {
|
|
18
|
+
if (!schema) return 'any';
|
|
19
|
+
|
|
20
|
+
// Named reference (already resolved but carried as name)
|
|
21
|
+
if (schemaName && !schema.type && !schema.oneOf && !schema.anyOf && !schema.allOf) {
|
|
22
|
+
return schemaName;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Circular ref
|
|
26
|
+
if (schema.$circularRef) return schema.$circularRef;
|
|
27
|
+
|
|
28
|
+
// Nullable wrapper
|
|
29
|
+
const nullable = schema.nullable === true;
|
|
30
|
+
let type = this._toTypeScriptInner(schema);
|
|
31
|
+
if (nullable) type = `${type} | null`;
|
|
32
|
+
return type;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static _toTypeScriptInner(schema) {
|
|
36
|
+
// Enum
|
|
37
|
+
if (schema.enum && schema.type === 'string') {
|
|
38
|
+
// Inline enum - return union of literals
|
|
39
|
+
return schema.enum.map(v => `'${v}'`).join(' | ');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// oneOf / anyOf → union
|
|
43
|
+
if (schema.oneOf) {
|
|
44
|
+
return schema.oneOf.map(s => this.toTypeScript(s)).join(' | ');
|
|
45
|
+
}
|
|
46
|
+
if (schema.anyOf) {
|
|
47
|
+
return schema.anyOf.map(s => this.toTypeScript(s)).join(' | ');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// allOf → intersection
|
|
51
|
+
if (schema.allOf) {
|
|
52
|
+
return schema.allOf.map(s => this.toTypeScript(s)).join(' & ');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Array
|
|
56
|
+
if (schema.type === 'array') {
|
|
57
|
+
const itemType = schema.items ? this.toTypeScript(schema.items) : 'any';
|
|
58
|
+
return `${itemType}[]`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Object with additionalProperties → Record
|
|
62
|
+
if (schema.type === 'object' && schema.additionalProperties && !schema.properties) {
|
|
63
|
+
const valueType = typeof schema.additionalProperties === 'object'
|
|
64
|
+
? this.toTypeScript(schema.additionalProperties)
|
|
65
|
+
: 'any';
|
|
66
|
+
return `Record<string, ${valueType}>`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Primitive types
|
|
70
|
+
switch (schema.type) {
|
|
71
|
+
case 'string':
|
|
72
|
+
if (schema.format === 'binary') return 'Blob';
|
|
73
|
+
return 'string';
|
|
74
|
+
case 'integer':
|
|
75
|
+
case 'number':
|
|
76
|
+
return 'number';
|
|
77
|
+
case 'boolean':
|
|
78
|
+
return 'boolean';
|
|
79
|
+
case 'object':
|
|
80
|
+
return 'Record<string, unknown>';
|
|
81
|
+
default:
|
|
82
|
+
return 'any';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Convert OpenAPI schema to Python type string
|
|
88
|
+
* @param {Object} schema - OpenAPI schema object
|
|
89
|
+
* @param {string} [schemaName] - named schema reference
|
|
90
|
+
* @returns {string} - Python type
|
|
91
|
+
*/
|
|
92
|
+
static toPython(schema, schemaName = null) {
|
|
93
|
+
if (!schema) return 'Any';
|
|
94
|
+
|
|
95
|
+
if (schemaName && !schema.type && !schema.oneOf && !schema.anyOf && !schema.allOf) {
|
|
96
|
+
return schemaName;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (schema.$circularRef) return `'${schema.$circularRef}'`;
|
|
100
|
+
|
|
101
|
+
const nullable = schema.nullable === true;
|
|
102
|
+
let type = this._toPythonInner(schema);
|
|
103
|
+
if (nullable) type = `Optional[${type}]`;
|
|
104
|
+
return type;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static _toPythonInner(schema) {
|
|
108
|
+
// Enum
|
|
109
|
+
if (schema.enum && schema.type === 'string') {
|
|
110
|
+
return 'str';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// oneOf / anyOf → Union
|
|
114
|
+
if (schema.oneOf) {
|
|
115
|
+
const types = schema.oneOf.map(s => this.toPython(s));
|
|
116
|
+
return `Union[${types.join(', ')}]`;
|
|
117
|
+
}
|
|
118
|
+
if (schema.anyOf) {
|
|
119
|
+
const types = schema.anyOf.map(s => this.toPython(s));
|
|
120
|
+
return `Union[${types.join(', ')}]`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// allOf → just merge (first named type or Any)
|
|
124
|
+
if (schema.allOf) {
|
|
125
|
+
const types = schema.allOf.map(s => this.toPython(s));
|
|
126
|
+
return types[0] || 'Any';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Array
|
|
130
|
+
if (schema.type === 'array') {
|
|
131
|
+
const itemType = schema.items ? this.toPython(schema.items) : 'Any';
|
|
132
|
+
return `List[${itemType}]`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Object with additionalProperties → Dict
|
|
136
|
+
if (schema.type === 'object' && schema.additionalProperties && !schema.properties) {
|
|
137
|
+
const valueType = typeof schema.additionalProperties === 'object'
|
|
138
|
+
? this.toPython(schema.additionalProperties)
|
|
139
|
+
: 'Any';
|
|
140
|
+
return `Dict[str, ${valueType}]`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Primitive types
|
|
144
|
+
switch (schema.type) {
|
|
145
|
+
case 'string':
|
|
146
|
+
if (schema.format === 'date-time') return 'datetime';
|
|
147
|
+
if (schema.format === 'date') return 'date';
|
|
148
|
+
if (schema.format === 'binary') return 'bytes';
|
|
149
|
+
return 'str';
|
|
150
|
+
case 'integer':
|
|
151
|
+
return 'int';
|
|
152
|
+
case 'number':
|
|
153
|
+
return 'float';
|
|
154
|
+
case 'boolean':
|
|
155
|
+
return 'bool';
|
|
156
|
+
case 'object':
|
|
157
|
+
return 'Dict[str, Any]';
|
|
158
|
+
default:
|
|
159
|
+
return 'Any';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Map a parameter type for method signatures
|
|
165
|
+
* @param {Object} param - OpenAPI parameter object
|
|
166
|
+
* @param {string} language - 'typescript' | 'python'
|
|
167
|
+
* @returns {string}
|
|
168
|
+
*/
|
|
169
|
+
static mapParamType(param, language) {
|
|
170
|
+
const schema = param.schema || param;
|
|
171
|
+
if (language === 'typescript') return this.toTypeScript(schema);
|
|
172
|
+
return this.toPython(schema);
|
|
173
|
+
}
|
|
174
|
+
}
|
package/nul
DELETED
|
File without changes
|