avrotize 2.20.3__py3-none-any.whl → 2.20.4__py3-none-any.whl
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.
- avrotize/__init__.py +2 -0
- avrotize/_version.py +2 -2
- avrotize/avrotocsharp/README.md.jinja +166 -0
- avrotize/avrotocsharp/class_test.cs.jinja +126 -0
- avrotize/avrotocsharp/dataclass_core.jinja +67 -5
- avrotize/avrotocsharp/project.csproj.jinja +6 -0
- avrotize/avrotocsharp/run_coverage.ps1.jinja +98 -0
- avrotize/avrotocsharp/run_coverage.sh.jinja +149 -0
- avrotize/avrotocsharp/testproject.csproj.jinja +4 -0
- avrotize/avrotocsharp.py +121 -16
- avrotize/commands.json +168 -9
- avrotize/constants.py +15 -0
- avrotize/dependencies/cs/net90/dependencies.csproj +2 -0
- avrotize/dependencies/java/jdk21/pom.xml +1 -1
- avrotize/jsonstostructure.py +234 -12
- avrotize/openapitostructure.py +717 -0
- avrotize/structuretojs/class_core.js.jinja +33 -0
- avrotize/structuretojs/enum_core.js.jinja +10 -0
- avrotize/structuretojs/package.json.jinja +12 -0
- avrotize/structuretojs/test_class.js.jinja +84 -0
- avrotize/structuretojs/test_enum.js.jinja +58 -0
- avrotize/structuretojs/test_runner.js.jinja +45 -0
- avrotize/structuretojs.py +657 -0
- avrotize/structuretots.py +26 -2
- {avrotize-2.20.3.dist-info → avrotize-2.20.4.dist-info}/METADATA +66 -1
- {avrotize-2.20.3.dist-info → avrotize-2.20.4.dist-info}/RECORD +29 -18
- {avrotize-2.20.3.dist-info → avrotize-2.20.4.dist-info}/WHEEL +0 -0
- {avrotize-2.20.3.dist-info → avrotize-2.20.4.dist-info}/entry_points.txt +0 -0
- {avrotize-2.20.3.dist-info → avrotize-2.20.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{%- for import_type, import_path in imports.items() %}
|
|
2
|
+
const {{ import_type }} = require('{{ import_path }}');
|
|
3
|
+
{%- endfor %}
|
|
4
|
+
{%- if imports %}
|
|
5
|
+
|
|
6
|
+
{%- endif %}
|
|
7
|
+
/**
|
|
8
|
+
* {{ docstring }}
|
|
9
|
+
*/
|
|
10
|
+
class {{ class_name }}{%- if base_class_name %} extends {{ base_class_name }}{%- endif %} {
|
|
11
|
+
{%- if static_fields %}
|
|
12
|
+
{%- for field in static_fields %}
|
|
13
|
+
{%- if field.docstring %}
|
|
14
|
+
/** {{ field.docstring }} */
|
|
15
|
+
{%- endif %}
|
|
16
|
+
static {{ field.name }} = {{ field.value }};
|
|
17
|
+
{%- endfor %}
|
|
18
|
+
{%- endif %}
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
{%- if base_class_name %}
|
|
22
|
+
super();
|
|
23
|
+
{%- endif %}
|
|
24
|
+
{%- for field in fields %}
|
|
25
|
+
{%- if field.docstring %}
|
|
26
|
+
/** {{ field.docstring }} */
|
|
27
|
+
{%- endif %}
|
|
28
|
+
this.{{ field.name }} = {{ field.default_value }};
|
|
29
|
+
{%- endfor %}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {{ class_name }};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{ package_name }}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Generated JavaScript classes from JSON Structure schema",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node test/test_runner.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC"
|
|
12
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test suite for {{ class_name }}
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const {{ class_name }} = require('../src/{{ class_path }}');
|
|
6
|
+
{%- for import_type, import_path in test_imports.items() %}
|
|
7
|
+
const {{ import_type }} = require('{{ import_path }}');
|
|
8
|
+
{%- endfor %}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create an instance of {{ class_name }} for testing
|
|
12
|
+
* @returns {{ class_name }} Test instance
|
|
13
|
+
*/
|
|
14
|
+
function createInstance() {
|
|
15
|
+
const instance = new {{ class_name }}();
|
|
16
|
+
{%- for field in fields %}
|
|
17
|
+
instance.{{ field.name }} = {{ field.test_value }};
|
|
18
|
+
{%- endfor %}
|
|
19
|
+
return instance;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Test instantiation
|
|
24
|
+
*/
|
|
25
|
+
function testInstantiation() {
|
|
26
|
+
const instance = createInstance();
|
|
27
|
+
console.log('✓ {{ class_name }} instantiated successfully');
|
|
28
|
+
return instance;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Test field assignments and getters
|
|
33
|
+
*/
|
|
34
|
+
function testFields() {
|
|
35
|
+
const instance = createInstance();
|
|
36
|
+
{%- for field in fields %}
|
|
37
|
+
if (instance.{{ field.name }} === undefined && {{ field.test_value }} !== undefined) {
|
|
38
|
+
throw new Error('Field {{ field.name }} should be defined');
|
|
39
|
+
}
|
|
40
|
+
{%- endfor %}
|
|
41
|
+
console.log('✓ All fields in {{ class_name }} are accessible');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Test JSON serialization roundtrip
|
|
46
|
+
*/
|
|
47
|
+
function testJsonRoundtrip() {
|
|
48
|
+
const instance = createInstance();
|
|
49
|
+
const json = JSON.stringify(instance);
|
|
50
|
+
const parsed = JSON.parse(json);
|
|
51
|
+
|
|
52
|
+
// Verify all fields are serialized
|
|
53
|
+
{%- for field in fields %}
|
|
54
|
+
if (parsed.{{ field.name }} === undefined && instance.{{ field.name }} !== undefined) {
|
|
55
|
+
throw new Error('Field {{ field.name }} was not serialized');
|
|
56
|
+
}
|
|
57
|
+
{%- endfor %}
|
|
58
|
+
|
|
59
|
+
console.log('✓ {{ class_name }} JSON serialization roundtrip successful');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Run all tests
|
|
64
|
+
*/
|
|
65
|
+
function runTests() {
|
|
66
|
+
try {
|
|
67
|
+
testInstantiation();
|
|
68
|
+
testFields();
|
|
69
|
+
testJsonRoundtrip();
|
|
70
|
+
console.log('✓ All tests passed for {{ class_name }}');
|
|
71
|
+
return true;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('✗ Test failed for {{ class_name }}:', error.message);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Run tests if executed directly
|
|
79
|
+
if (require.main === module) {
|
|
80
|
+
const success = runTests();
|
|
81
|
+
process.exit(success ? 0 : 1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = { createInstance, runTests };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test suite for {{ enum_name }} enum
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const {{ enum_name }} = require('../src/{{ enum_path }}');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Test enum values
|
|
9
|
+
*/
|
|
10
|
+
function testEnumValues() {
|
|
11
|
+
const expectedValues = [{{ expected_values }}];
|
|
12
|
+
const actualValues = Object.values({{ enum_name }});
|
|
13
|
+
|
|
14
|
+
if (actualValues.length !== expectedValues.length) {
|
|
15
|
+
throw new Error(`Expected ${expectedValues.length} values, got ${actualValues.length}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const expected of expectedValues) {
|
|
19
|
+
if (!actualValues.includes(expected)) {
|
|
20
|
+
throw new Error(`Enum value "${expected}" not found`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log('✓ {{ enum_name }} has all expected values');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Test enum is frozen
|
|
29
|
+
*/
|
|
30
|
+
function testEnumFrozen() {
|
|
31
|
+
if (!Object.isFrozen({{ enum_name }})) {
|
|
32
|
+
throw new Error('Enum should be frozen');
|
|
33
|
+
}
|
|
34
|
+
console.log('✓ {{ enum_name }} is properly frozen');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Run all tests
|
|
39
|
+
*/
|
|
40
|
+
function runTests() {
|
|
41
|
+
try {
|
|
42
|
+
testEnumValues();
|
|
43
|
+
testEnumFrozen();
|
|
44
|
+
console.log('✓ All tests passed for {{ enum_name }}');
|
|
45
|
+
return true;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('✗ Test failed for {{ enum_name }}:', error.message);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Run tests if executed directly
|
|
53
|
+
if (require.main === module) {
|
|
54
|
+
const success = runTests();
|
|
55
|
+
process.exit(success ? 0 : 1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = { runTests };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test runner for all generated classes and enums
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
// Find all test files
|
|
9
|
+
const testDir = __dirname;
|
|
10
|
+
const testFiles = fs.readdirSync(testDir)
|
|
11
|
+
.filter(file => file.startsWith('test_') && file.endsWith('.js') && file !== 'test_runner.js')
|
|
12
|
+
.map(file => path.join(testDir, file));
|
|
13
|
+
|
|
14
|
+
console.log(`Running ${testFiles.length} test suites...\n`);
|
|
15
|
+
|
|
16
|
+
let passedCount = 0;
|
|
17
|
+
let failedCount = 0;
|
|
18
|
+
|
|
19
|
+
// Run each test suite
|
|
20
|
+
for (const testFile of testFiles) {
|
|
21
|
+
const testName = path.basename(testFile, '.js');
|
|
22
|
+
console.log(`\n=== ${testName} ===`);
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const testModule = require(testFile);
|
|
26
|
+
const success = testModule.runTests();
|
|
27
|
+
|
|
28
|
+
if (success) {
|
|
29
|
+
passedCount++;
|
|
30
|
+
} else {
|
|
31
|
+
failedCount++;
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error(`✗ Failed to run ${testName}:`, error.message);
|
|
35
|
+
failedCount++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(`\n${'='.repeat(50)}`);
|
|
40
|
+
console.log(`Total: ${testFiles.length} test suites`);
|
|
41
|
+
console.log(`Passed: ${passedCount}`);
|
|
42
|
+
console.log(`Failed: ${failedCount}`);
|
|
43
|
+
console.log('='.repeat(50));
|
|
44
|
+
|
|
45
|
+
process.exit(failedCount > 0 ? 1 : 0);
|