avrotize 2.2.4__tar.gz → 2.3.0__tar.gz

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.
Files changed (83) hide show
  1. {avrotize-2.2.4 → avrotize-2.3.0}/PKG-INFO +1 -1
  2. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/_version.py +2 -2
  3. avrotize-2.3.0/avrotize/avrotots/class_core.ts.jinja +114 -0
  4. avrotize-2.3.0/avrotize/avrotots/enum_core.ts.jinja +40 -0
  5. avrotize-2.3.0/avrotize/avrotots/gitignore.jinja +34 -0
  6. avrotize-2.3.0/avrotize/avrotots/index.ts.jinja +0 -0
  7. avrotize-2.3.0/avrotize/avrotots/package.json.jinja +23 -0
  8. avrotize-2.3.0/avrotize/avrotots/tsconfig.json.jinja +21 -0
  9. avrotize-2.3.0/avrotize/avrotots.py +424 -0
  10. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/common.py +6 -2
  11. avrotize-2.2.4/avrotize/avrotots.py +0 -563
  12. {avrotize-2.2.4 → avrotize-2.3.0}/README.md +0 -0
  13. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/__init__.py +0 -0
  14. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/__main__.py +0 -0
  15. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/asn1toavro.py +0 -0
  16. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotize.py +0 -0
  17. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocpp/CMakeLists.txt.jinja +0 -0
  18. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocpp/build.bat.jinja +0 -0
  19. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocpp/build.sh.jinja +0 -0
  20. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocpp/dataclass_body.jinja +0 -0
  21. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocpp/vcpkg.json.jinja +0 -0
  22. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocpp.py +0 -0
  23. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocsharp/class_test.cs.jinja +0 -0
  24. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocsharp/dataclass_core.jinja +0 -0
  25. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocsharp/enum_test.cs.jinja +0 -0
  26. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocsharp/project.csproj.jinja +0 -0
  27. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocsharp/project.sln.jinja +0 -0
  28. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocsharp/testproject.csproj.jinja +0 -0
  29. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocsharp.py +0 -0
  30. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotocsv.py +0 -0
  31. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotodatapackage.py +0 -0
  32. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotodb.py +0 -0
  33. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotogo/go_enum.jinja +0 -0
  34. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotogo/go_helpers.jinja +0 -0
  35. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotogo/go_struct.jinja +0 -0
  36. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotogo/go_test.jinja +0 -0
  37. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotogo/go_union.jinja +0 -0
  38. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotogo.py +0 -0
  39. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotographql.py +0 -0
  40. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotoiceberg.py +0 -0
  41. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotojava.py +0 -0
  42. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotojs.py +0 -0
  43. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotojsons.py +0 -0
  44. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotokusto.py +0 -0
  45. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotomd/README.md.jinja +0 -0
  46. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotomd.py +0 -0
  47. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotools.py +0 -0
  48. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotoparquet.py +0 -0
  49. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotoproto.py +0 -0
  50. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotopython/dataclass_core.jinja +0 -0
  51. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotopython/enum_core.jinja +0 -0
  52. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotopython/pyproject_toml.jinja +0 -0
  53. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotopython/test_class.jinja +0 -0
  54. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotopython/test_enum.jinja +0 -0
  55. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotopython.py +0 -0
  56. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotorust/dataclass_enum.rs.jinja +0 -0
  57. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotorust/dataclass_struct.rs.jinja +0 -0
  58. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotorust/dataclass_union.rs.jinja +0 -0
  59. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotorust.py +0 -0
  60. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/avrotoxsd.py +0 -0
  61. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/commands.json +0 -0
  62. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/constants.py +0 -0
  63. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/csvtoavro.py +0 -0
  64. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/datapackagetoavro.py +0 -0
  65. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/dependency_resolver.py +0 -0
  66. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/generic/generic.avsc +0 -0
  67. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/jsonstoavro.py +0 -0
  68. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/kstructtoavro.py +0 -0
  69. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/kustotoavro.py +0 -0
  70. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/parquettoavro.py +0 -0
  71. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/proto2parser.py +0 -0
  72. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/proto3parser.py +0 -0
  73. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototoavro.py +0 -0
  74. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototypes/any.avsc +0 -0
  75. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototypes/api.avsc +0 -0
  76. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototypes/duration.avsc +0 -0
  77. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototypes/field_mask.avsc +0 -0
  78. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototypes/struct.avsc +0 -0
  79. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototypes/timestamp.avsc +0 -0
  80. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototypes/type.avsc +0 -0
  81. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/prototypes/wrappers.avsc +0 -0
  82. {avrotize-2.2.4 → avrotize-2.3.0}/avrotize/xsdtoavro.py +0 -0
  83. {avrotize-2.2.4 → avrotize-2.3.0}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: avrotize
3
- Version: 2.2.4
3
+ Version: 2.3.0
4
4
  Summary: Tools to convert from and to Avro Schema from various other schema languages.
5
5
  Author-email: Clemens Vasters <clemensv@microsoft.com>
6
6
  Requires-Python: >=3.10
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '2.2.4'
16
- __version_tuple__ = version_tuple = (2, 2, 4)
15
+ __version__ = version = '2.3.0'
16
+ __version_tuple__ = version_tuple = (2, 3, 0)
@@ -0,0 +1,114 @@
1
+ /** {{ class_name }} class. */
2
+ {%- if typed_json_annotation %}
3
+ import 'reflect-metadata';
4
+ import { jsonObject, jsonMember, TypedJSON } from 'typedjson';
5
+ {%- endif %}
6
+ {%- if avro_annotation %}
7
+ import { Type } from 'avro-js';
8
+ {%- endif %}
9
+ {%- for import_type, import_path in import_types.items() %}
10
+ import { {{ import_type }} } from '{{ import_path }}';
11
+ {%- endfor %}
12
+ {%- if avro_annotation or typed_json_annotation %}
13
+ import pako from 'pako';
14
+ {%- endif %}
15
+
16
+ @jsonObject
17
+ export class {{ class_name }} {
18
+ {%- if avro_annotation %}
19
+ public static AvroType: Type = Type.forSchema({{ avro_schema_json }});
20
+ {%- endif %}
21
+
22
+ {%- for field in fields %}
23
+ /** {{ field.docstring }} */
24
+ {%- if typed_json_annotation %}
25
+ @jsonMember
26
+ {%- endif %}
27
+ public {{ field.name }}: {{ field.type }};
28
+ {%- endfor %}
29
+
30
+ constructor({%- for field in fields %}{{ field.name }}: {{ field.type }}{%- if not loop.last %}, {%- endif %}{%- endfor %}) {
31
+ {%- for field in fields %}
32
+ {%- if field.is_enum %}
33
+ if ( typeof {{ field.name }} === 'number' ) {
34
+ this.{{ field.name }} = {{ field.type }}Utils.fromOrdinal({{ field.name }});
35
+ } else {
36
+ this.{{ field.name }} = {{ field.name }};
37
+ }
38
+ {%- else %}
39
+ this.{{ field.name }} = {{ field.name }};
40
+ {%- endif %}
41
+ {%- endfor %}
42
+ }
43
+
44
+ {%- if avro_annotation or typed_json_annotation %}
45
+ public toByteArray(contentTypeString: string): Uint8Array {
46
+ const contentType = contentTypeString.split(';')[0].trim();
47
+ let result: Uint8Array | null = null;
48
+
49
+ {%- if avro_annotation %}
50
+ if (contentType.startsWith('avro/binary') || contentType.startsWith('application/vnd.apache.avro+avro')) {
51
+ result = ({{ class_name }}.AvroType.toBuffer(this) as unknown) as Uint8Array;
52
+ }
53
+ {%- endif %}
54
+
55
+ {%- if typed_json_annotation %}
56
+ if (contentType.startsWith('application/json')) {
57
+ const serializer = new TypedJSON({{ class_name }});
58
+ const jsonString = serializer.stringify(this);
59
+ result = new TextEncoder().encode(jsonString);
60
+ }
61
+ {%- endif %}
62
+
63
+ if (result && contentTypeString.endsWith('+gzip')) {
64
+ result = pako.gzip(result);
65
+ }
66
+
67
+ if (result) {
68
+ return result;
69
+ } else {
70
+ throw new Error(`Unsupported media type: ${contentTypeString}`);
71
+ }
72
+ }
73
+
74
+ public static fromData(data: any, contentTypeString: string): {{ class_name }} {
75
+ const contentType = contentTypeString.split(';')[0].trim();
76
+
77
+ if (contentTypeString.endsWith('+gzip')) {
78
+ data = pako.ungzip(data);
79
+ }
80
+
81
+ {%- if avro_annotation %}
82
+ if (contentType.startsWith('avro/binary') || contentType.startsWith('application/vnd.apache.avro+avro')) {
83
+ return {{ class_name }}.AvroType.fromBuffer(data);
84
+ }
85
+ {%- endif %}
86
+
87
+ {%- if typed_json_annotation %}
88
+ if (contentType.startsWith('application/json')) {
89
+ const serializer = new TypedJSON({{ class_name }});
90
+ const retval = serializer.parse(new TextDecoder().decode(data));
91
+ if (!(retval instanceof {{ class_name }})) {
92
+ throw new Error(`Deserialized object is not an instance of {{ class_name }}`);
93
+ }
94
+ return retval;
95
+ }
96
+ {%- endif %}
97
+
98
+ throw new Error(`Unsupported media type: ${contentTypeString}`);
99
+ }
100
+
101
+ public static isJsonMatch(element: any): boolean {
102
+ {%- if fields|length == 0 %}
103
+ return true;
104
+ {%- else %}
105
+ return (
106
+ {%- for field in fields %}
107
+ {{ get_is_json_match_clause(field.name, field.type, field.is_enum) }}{%- if not loop.last %} &&
108
+ {%- endif %}
109
+ {%- endfor %}
110
+ );
111
+ {%- endif %}
112
+ }
113
+ {%- endif %}
114
+ }
@@ -0,0 +1,40 @@
1
+ /** {{ enum_name }} enum. */
2
+ export enum {{ enum_name }} {
3
+ {%- for symbol in symbols %}
4
+ {{ symbol }} = "{{ symbol }}"{%- if not loop.last %},{%- endif %}
5
+ {%- endfor %}
6
+ }
7
+
8
+ export class {{ enum_name }}Utils {
9
+ /**
10
+ * Converts a {{ enum_name }} enum value to its ordinal.
11
+ * @param value - The {{ enum_name }} enum value ({{ symbols|join(', ') }}).
12
+ * @returns The ordinal number corresponding to the enum value.
13
+ */
14
+ static toOrdinal(value: {{ enum_name }}): number {
15
+ switch (value) {
16
+ {%- for symbol in symbols %}
17
+ case {{ enum_name }}.{{ symbol }}:
18
+ return {{ loop.index0 }};
19
+ {%- endfor %}
20
+ default:
21
+ throw new Error("Invalid {{ enum_name }} value");
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Converts an ordinal to its corresponding {{ enum_name }} enum value.
27
+ * @param ordinal - The ordinal number of the enum value.
28
+ * @returns The corresponding {{ enum_name }} enum value.
29
+ */
30
+ static fromOrdinal(ordinal: number): {{ enum_name }} {
31
+ switch (ordinal) {
32
+ {%- for symbol in symbols %}
33
+ case {{ loop.index0 }}:
34
+ return {{ enum_name }}.{{ symbol }};
35
+ {%- endfor %}
36
+ default:
37
+ throw new Error("Invalid ordinal value");
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,34 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+
8
+ # Runtime data
9
+ pids
10
+ *.pid
11
+ *.seed
12
+ *.pid.lock
13
+
14
+ # Dependency directories
15
+ node_modules/
16
+ jspm_packages/
17
+
18
+ # Typescript declaration files
19
+ typings/
20
+
21
+ # Optional npm cache directory
22
+ .npm
23
+
24
+ # Output of 'npm pack'
25
+ *.tgz
26
+
27
+ # Yarn Integrity file
28
+ .yarn-integrity
29
+
30
+ # dotenv environment variables file
31
+ .env
32
+
33
+ # Build output
34
+ dist/
File without changes
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "{{ package_name }}",
3
+ "version": "1.0.0",
4
+ "description": "Generated TypeScript classes from Avro schema",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "start": "node dist/index.js"
10
+ },
11
+ "dependencies": {
12
+ "avro-js": "^1.12.0",
13
+ "typedjson": "^1.8.0",
14
+ "pako": "^2.1.0",
15
+ "reflect-metadata": "^0.2.2",
16
+ "@types/pako": "^2.0.3"
17
+ },
18
+ "devDependencies": {
19
+ "typescript": "^5.4.5"
20
+ },
21
+ "author": "",
22
+ "license": "ISC"
23
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "strict": true,
6
+ "esModuleInterop": true,
7
+ "skipLibCheck": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "experimentalDecorators": true,
12
+ "emitDecoratorMetadata": true,
13
+ "declaration": true,
14
+ "declarationMap": true,
15
+ "moduleResolution": "node",
16
+ "resolveJsonModule": true
17
+ },
18
+ "include": [
19
+ "src/**/*"
20
+ ]
21
+ }