code0-hercules 1.3.0__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.
- code0_hercules-1.3.0.dist-info/METADATA +79 -0
- code0_hercules-1.3.0.dist-info/RECORD +258 -0
- code0_hercules-1.3.0.dist-info/WHEEL +5 -0
- code0_hercules-1.3.0.dist-info/entry_points.txt +2 -0
- code0_hercules-1.3.0.dist-info/top_level.txt +1 -0
- hercules/__init__.py +81 -0
- hercules/_metadata.py +38 -0
- hercules/_tsgen/convert.mjs +96 -0
- hercules/_tsgen/package-lock.json +366 -0
- hercules/_tsgen/package.json +11 -0
- hercules/_tucana/__init__.py +29 -0
- hercules/_tucana/helpers.py +73 -0
- hercules/action.py +345 -0
- hercules/actions/__init__.py +21 -0
- hercules/actions/execution.py +121 -0
- hercules/actions/flow_execution.py +11 -0
- hercules/actions/flow_update.py +18 -0
- hercules/actions/module_configurations.py +14 -0
- hercules/actions/sub_flow_execution.py +14 -0
- hercules/cli.py +137 -0
- hercules/decorators/__init__.py +0 -0
- hercules/decorators/datatype.py +39 -0
- hercules/decorators/event.py +35 -0
- hercules/decorators/function.py +59 -0
- hercules/decorators/meta.py +82 -0
- hercules/decorators/runtime_event.py +15 -0
- hercules/decorators/runtime_function.py +18 -0
- hercules/definitions/__init__.py +162 -0
- hercules/definitions/cron_action/__init__.py +0 -0
- hercules/definitions/cron_action/data_types/__init__.py +0 -0
- hercules/definitions/cron_action/data_types/cron_day_of_month.py +11 -0
- hercules/definitions/cron_action/data_types/cron_day_of_week.py +11 -0
- hercules/definitions/cron_action/data_types/cron_hour.py +11 -0
- hercules/definitions/cron_action/data_types/cron_minute.py +11 -0
- hercules/definitions/cron_action/data_types/cron_month.py +11 -0
- hercules/definitions/cron_action/runtime_flow_types/__init__.py +0 -0
- hercules/definitions/cron_action/runtime_flow_types/cron.py +19 -0
- hercules/definitions/rest_action/__init__.py +0 -0
- hercules/definitions/rest_action/data_types/__init__.py +0 -0
- hercules/definitions/rest_action/data_types/rest_adapter_input.py +19 -0
- hercules/definitions/rest_action/data_types/rest_auth_type.py +19 -0
- hercules/definitions/rest_action/data_types/rest_auth_value.py +11 -0
- hercules/definitions/rest_action/runtime_flow_types/__init__.py +0 -0
- hercules/definitions/rest_action/runtime_flow_types/rest.py +20 -0
- hercules/definitions/rest_action/runtime_functions/__init__.py +0 -0
- hercules/definitions/rest_action/runtime_functions/rest_control_respond.py +21 -0
- hercules/definitions/taurus_boolean/__init__.py +0 -0
- hercules/definitions/taurus_boolean/data_types/__init__.py +0 -0
- hercules/definitions/taurus_boolean/data_types/boolean.py +11 -0
- hercules/definitions/taurus_boolean/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_boolean/runtime_functions/std_boolean_as_number.py +18 -0
- hercules/definitions/taurus_boolean/runtime_functions/std_boolean_as_text.py +18 -0
- hercules/definitions/taurus_boolean/runtime_functions/std_boolean_from_number.py +18 -0
- hercules/definitions/taurus_boolean/runtime_functions/std_boolean_from_text.py +18 -0
- hercules/definitions/taurus_boolean/runtime_functions/std_boolean_is_equal.py +19 -0
- hercules/definitions/taurus_boolean/runtime_functions/std_boolean_negate.py +18 -0
- hercules/definitions/taurus_color/__init__.py +0 -0
- hercules/definitions/taurus_color/data_types/__init__.py +0 -0
- hercules/definitions/taurus_color/data_types/color.py +17 -0
- hercules/definitions/taurus_color/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_color/runtime_functions/std_color_as_hex.py +18 -0
- hercules/definitions/taurus_color/runtime_functions/std_color_as_hsl.py +18 -0
- hercules/definitions/taurus_color/runtime_functions/std_color_as_rgb.py +18 -0
- hercules/definitions/taurus_color/runtime_functions/std_color_from_hex.py +18 -0
- hercules/definitions/taurus_color/runtime_functions/std_color_from_hsl.py +21 -0
- hercules/definitions/taurus_color/runtime_functions/std_color_from_rgb.py +21 -0
- hercules/definitions/taurus_control/__init__.py +0 -0
- hercules/definitions/taurus_control/data_types/__init__.py +0 -0
- hercules/definitions/taurus_control/data_types/comparator.py +21 -0
- hercules/definitions/taurus_control/data_types/consumer.py +20 -0
- hercules/definitions/taurus_control/data_types/predicate.py +20 -0
- hercules/definitions/taurus_control/data_types/runnable.py +13 -0
- hercules/definitions/taurus_control/data_types/transform.py +20 -0
- hercules/definitions/taurus_control/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_control/runtime_functions/std_control_if.py +19 -0
- hercules/definitions/taurus_control/runtime_functions/std_control_if_else.py +21 -0
- hercules/definitions/taurus_control/runtime_functions/std_control_return.py +18 -0
- hercules/definitions/taurus_control/runtime_functions/std_control_stop.py +16 -0
- hercules/definitions/taurus_control/runtime_functions/std_control_value.py +18 -0
- hercules/definitions/taurus_date/__init__.py +0 -0
- hercules/definitions/taurus_date/data_types/__init__.py +0 -0
- hercules/definitions/taurus_date/data_types/date.py +11 -0
- hercules/definitions/taurus_date/data_types/hour.py +11 -0
- hercules/definitions/taurus_date/data_types/minute.py +11 -0
- hercules/definitions/taurus_date/data_types/month.py +22 -0
- hercules/definitions/taurus_date/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_date/runtime_functions/std_date_format.py +20 -0
- hercules/definitions/taurus_date/runtime_functions/std_date_from.py +24 -0
- hercules/definitions/taurus_date/runtime_functions/std_date_from_text.py +19 -0
- hercules/definitions/taurus_date/runtime_functions/std_date_from_unix.py +18 -0
- hercules/definitions/taurus_date/runtime_functions/std_date_now.py +16 -0
- hercules/definitions/taurus_file/__init__.py +0 -0
- hercules/definitions/taurus_file/data_types/__init__.py +0 -0
- hercules/definitions/taurus_file/data_types/file.py +19 -0
- hercules/definitions/taurus_file/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_file/runtime_functions/std_file_size.py +18 -0
- hercules/definitions/taurus_http/__init__.py +0 -0
- hercules/definitions/taurus_http/data_types/__init__.py +0 -0
- hercules/definitions/taurus_http/data_types/http_auth_place.py +12 -0
- hercules/definitions/taurus_http/data_types/http_auth_type.py +17 -0
- hercules/definitions/taurus_http/data_types/http_auth_value.py +11 -0
- hercules/definitions/taurus_http/data_types/http_method.py +16 -0
- hercules/definitions/taurus_http/data_types/http_payload.py +11 -0
- hercules/definitions/taurus_http/data_types/http_request.py +19 -0
- hercules/definitions/taurus_http/data_types/http_response.py +18 -0
- hercules/definitions/taurus_http/data_types/http_schema.py +31 -0
- hercules/definitions/taurus_http/data_types/http_status_code.py +13 -0
- hercules/definitions/taurus_http/data_types/http_url.py +13 -0
- hercules/definitions/taurus_http/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_http/runtime_functions/http_request_send.py +26 -0
- hercules/definitions/taurus_list/__init__.py +0 -0
- hercules/definitions/taurus_list/data_types/__init__.py +0 -0
- hercules/definitions/taurus_list/data_types/list.py +13 -0
- hercules/definitions/taurus_list/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_at.py +20 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_concat.py +20 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_filter.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_find.py +20 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_find_index.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_find_last.py +20 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_first.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_flat.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_for_each.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_index_of.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_is_empty.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_join.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_last.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_map.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_max.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_min.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_pop.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_push.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_remove.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_reverse.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_size.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_sort.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_sort_reverse.py +19 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_sum.py +18 -0
- hercules/definitions/taurus_list/runtime_functions/std_list_to_unique.py +18 -0
- hercules/definitions/taurus_number/__init__.py +0 -0
- hercules/definitions/taurus_number/data_types/__init__.py +0 -0
- hercules/definitions/taurus_number/data_types/number.py +11 -0
- hercules/definitions/taurus_number/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_abs.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_add.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_arccos.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_arcsin.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_arctan.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_as_text.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_clamp.py +20 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_cos.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_cosh.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_divide.py +20 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_euler.py +16 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_exponential.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_from_text.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_has_digits.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_is_equal.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_is_greater.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_is_less.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_is_positive.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_is_zero.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_ln.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_log.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_max.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_min.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_modulo.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_multiply.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_negate.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_pi.py +16 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_random_number.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_remove_digits.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_root.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_round.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_round_down.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_round_up.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_sin.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_sinh.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_square.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_square_root.py +18 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_subtract.py +19 -0
- hercules/definitions/taurus_number/runtime_functions/std_number_tan.py +18 -0
- hercules/definitions/taurus_object/__init__.py +0 -0
- hercules/definitions/taurus_object/data_types/__init__.py +0 -0
- hercules/definitions/taurus_object/data_types/object.py +13 -0
- hercules/definitions/taurus_object/data_types/type.py +13 -0
- hercules/definitions/taurus_object/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_object/runtime_functions/std_object_contains_key.py +19 -0
- hercules/definitions/taurus_object/runtime_functions/std_object_get.py +19 -0
- hercules/definitions/taurus_object/runtime_functions/std_object_keys.py +18 -0
- hercules/definitions/taurus_object/runtime_functions/std_object_set.py +20 -0
- hercules/definitions/taurus_object/runtime_functions/std_object_size.py +18 -0
- hercules/definitions/taurus_text/__init__.py +0 -0
- hercules/definitions/taurus_text/data_types/__init__.py +0 -0
- hercules/definitions/taurus_text/data_types/text.py +11 -0
- hercules/definitions/taurus_text/data_types/text_encoding.py +13 -0
- hercules/definitions/taurus_text/runtime_functions/__init__.py +0 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_append.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_as_bytes.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_at.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_byte_size.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_capitalize.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_chars.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_contains.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_decode.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_encode.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_ends_with.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_from_ascii.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_hex.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_index_of.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_insert.py +20 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_is_equal.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_length.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_lowercase.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_octal.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_prepend.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_remove.py +20 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_replace.py +20 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_replace_first.py +21 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_replace_last.py +20 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_reverse.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_split.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_starts_with.py +19 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_swapcase.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_to_ascii.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_trim.py +18 -0
- hercules/definitions/taurus_text/runtime_functions/std_text_uppercase.py +18 -0
- hercules/events.py +23 -0
- hercules/internal/__init__.py +0 -0
- hercules/internal/connection.py +37 -0
- hercules/internal/literal.py +113 -0
- hercules/internal/module_builder.py +261 -0
- hercules/internal/pydantic_codegen.py +82 -0
- hercules/internal/schema.py +158 -0
- hercules/internal/tsgen.py +93 -0
- hercules/manager/__init__.py +0 -0
- hercules/manager/base.py +73 -0
- hercules/manager/config.py +45 -0
- hercules/manager/datatype.py +8 -0
- hercules/manager/event.py +8 -0
- hercules/manager/flow.py +12 -0
- hercules/manager/function.py +8 -0
- hercules/manager/runtime_event.py +8 -0
- hercules/manager/runtime_function.py +8 -0
- hercules/map/__init__.py +0 -0
- hercules/map/datatype.py +41 -0
- hercules/map/event.py +74 -0
- hercules/map/function.py +76 -0
- hercules/map/runtime_event.py +43 -0
- hercules/map/runtime_function.py +64 -0
- hercules/models/__init__.py +0 -0
- hercules/models/datatype.py +49 -0
- hercules/models/event.py +35 -0
- hercules/models/function.py +37 -0
- hercules/models/runtime_event.py +29 -0
- hercules/models/runtime_function.py +33 -0
- hercules/schema.py +38 -0
- hercules/types.py +88 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hercules-tsgen",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "hercules-tsgen",
|
|
9
|
+
"version": "0.0.0",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"json-schema-to-typescript": "^15.0.0",
|
|
12
|
+
"ts-json-schema-generator": "^2.3.0"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"node_modules/@apidevtools/json-schema-ref-parser": {
|
|
16
|
+
"version": "11.9.3",
|
|
17
|
+
"resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.9.3.tgz",
|
|
18
|
+
"integrity": "sha512-60vepv88RwcJtSHrD6MjIL6Ta3SOYbgfnkHb+ppAVK+o9mXprRtulx7VlRl3lN3bbvysAfCS7WMVfhUYemB0IQ==",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@jsdevtools/ono": "^7.1.3",
|
|
22
|
+
"@types/json-schema": "^7.0.15",
|
|
23
|
+
"js-yaml": "^4.1.0"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">= 16"
|
|
27
|
+
},
|
|
28
|
+
"funding": {
|
|
29
|
+
"url": "https://github.com/sponsors/philsturgeon"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"node_modules/@jsdevtools/ono": {
|
|
33
|
+
"version": "7.1.3",
|
|
34
|
+
"resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz",
|
|
35
|
+
"integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==",
|
|
36
|
+
"license": "MIT"
|
|
37
|
+
},
|
|
38
|
+
"node_modules/@types/json-schema": {
|
|
39
|
+
"version": "7.0.15",
|
|
40
|
+
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
|
41
|
+
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
|
|
42
|
+
"license": "MIT"
|
|
43
|
+
},
|
|
44
|
+
"node_modules/@types/lodash": {
|
|
45
|
+
"version": "4.17.25",
|
|
46
|
+
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.25.tgz",
|
|
47
|
+
"integrity": "sha512-+K1NIO8I+F9/wNulfVvu23QYd0Pe9/OCqRrim4NoYIf1VoEDL90Ve4ClzpyqBLc7NpGGWRvYNCKZ1BE/Jpf8dQ==",
|
|
48
|
+
"license": "MIT"
|
|
49
|
+
},
|
|
50
|
+
"node_modules/argparse": {
|
|
51
|
+
"version": "2.0.1",
|
|
52
|
+
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
|
53
|
+
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
|
54
|
+
"license": "Python-2.0"
|
|
55
|
+
},
|
|
56
|
+
"node_modules/balanced-match": {
|
|
57
|
+
"version": "4.0.4",
|
|
58
|
+
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
|
59
|
+
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": "18 || 20 || >=22"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"node_modules/brace-expansion": {
|
|
66
|
+
"version": "5.0.9",
|
|
67
|
+
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
|
68
|
+
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"balanced-match": "^4.0.2"
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": "20 || >=22"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"node_modules/commander": {
|
|
78
|
+
"version": "14.0.3",
|
|
79
|
+
"resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz",
|
|
80
|
+
"integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==",
|
|
81
|
+
"license": "MIT",
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=20"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"node_modules/fdir": {
|
|
87
|
+
"version": "6.5.0",
|
|
88
|
+
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
|
89
|
+
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
|
|
90
|
+
"license": "MIT",
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": ">=12.0.0"
|
|
93
|
+
},
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"picomatch": "^3 || ^4"
|
|
96
|
+
},
|
|
97
|
+
"peerDependenciesMeta": {
|
|
98
|
+
"picomatch": {
|
|
99
|
+
"optional": true
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"node_modules/glob": {
|
|
104
|
+
"version": "13.0.6",
|
|
105
|
+
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz",
|
|
106
|
+
"integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==",
|
|
107
|
+
"license": "BlueOak-1.0.0",
|
|
108
|
+
"dependencies": {
|
|
109
|
+
"minimatch": "^10.2.2",
|
|
110
|
+
"minipass": "^7.1.3",
|
|
111
|
+
"path-scurry": "^2.0.2"
|
|
112
|
+
},
|
|
113
|
+
"engines": {
|
|
114
|
+
"node": "18 || 20 || >=22"
|
|
115
|
+
},
|
|
116
|
+
"funding": {
|
|
117
|
+
"url": "https://github.com/sponsors/isaacs"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"node_modules/is-extglob": {
|
|
121
|
+
"version": "2.1.1",
|
|
122
|
+
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
|
123
|
+
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
|
124
|
+
"license": "MIT",
|
|
125
|
+
"engines": {
|
|
126
|
+
"node": ">=0.10.0"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"node_modules/is-glob": {
|
|
130
|
+
"version": "4.0.3",
|
|
131
|
+
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
|
132
|
+
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
|
133
|
+
"license": "MIT",
|
|
134
|
+
"dependencies": {
|
|
135
|
+
"is-extglob": "^2.1.1"
|
|
136
|
+
},
|
|
137
|
+
"engines": {
|
|
138
|
+
"node": ">=0.10.0"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"node_modules/js-yaml": {
|
|
142
|
+
"version": "4.3.1",
|
|
143
|
+
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
|
|
144
|
+
"integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
|
|
145
|
+
"funding": [
|
|
146
|
+
{
|
|
147
|
+
"type": "github",
|
|
148
|
+
"url": "https://github.com/sponsors/puzrin"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"type": "github",
|
|
152
|
+
"url": "https://github.com/sponsors/nodeca"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"license": "MIT",
|
|
156
|
+
"dependencies": {
|
|
157
|
+
"argparse": "^2.0.1"
|
|
158
|
+
},
|
|
159
|
+
"bin": {
|
|
160
|
+
"js-yaml": "bin/js-yaml.js"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"node_modules/json-schema-to-typescript": {
|
|
164
|
+
"version": "15.0.4",
|
|
165
|
+
"resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-15.0.4.tgz",
|
|
166
|
+
"integrity": "sha512-Su9oK8DR4xCmDsLlyvadkXzX6+GGXJpbhwoLtOGArAG61dvbW4YQmSEno2y66ahpIdmLMg6YUf/QHLgiwvkrHQ==",
|
|
167
|
+
"license": "MIT",
|
|
168
|
+
"dependencies": {
|
|
169
|
+
"@apidevtools/json-schema-ref-parser": "^11.5.5",
|
|
170
|
+
"@types/json-schema": "^7.0.15",
|
|
171
|
+
"@types/lodash": "^4.17.7",
|
|
172
|
+
"is-glob": "^4.0.3",
|
|
173
|
+
"js-yaml": "^4.1.0",
|
|
174
|
+
"lodash": "^4.17.21",
|
|
175
|
+
"minimist": "^1.2.8",
|
|
176
|
+
"prettier": "^3.2.5",
|
|
177
|
+
"tinyglobby": "^0.2.9"
|
|
178
|
+
},
|
|
179
|
+
"bin": {
|
|
180
|
+
"json2ts": "dist/src/cli.js"
|
|
181
|
+
},
|
|
182
|
+
"engines": {
|
|
183
|
+
"node": ">=16.0.0"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"node_modules/json5": {
|
|
187
|
+
"version": "2.2.3",
|
|
188
|
+
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
|
189
|
+
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
|
190
|
+
"license": "MIT",
|
|
191
|
+
"bin": {
|
|
192
|
+
"json5": "lib/cli.js"
|
|
193
|
+
},
|
|
194
|
+
"engines": {
|
|
195
|
+
"node": ">=6"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"node_modules/lodash": {
|
|
199
|
+
"version": "4.18.1",
|
|
200
|
+
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
|
|
201
|
+
"integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==",
|
|
202
|
+
"license": "MIT"
|
|
203
|
+
},
|
|
204
|
+
"node_modules/lru-cache": {
|
|
205
|
+
"version": "11.5.2",
|
|
206
|
+
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz",
|
|
207
|
+
"integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==",
|
|
208
|
+
"license": "BlueOak-1.0.0",
|
|
209
|
+
"engines": {
|
|
210
|
+
"node": "20 || >=22"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"node_modules/minimatch": {
|
|
214
|
+
"version": "10.2.6",
|
|
215
|
+
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
|
|
216
|
+
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
|
|
217
|
+
"license": "BlueOak-1.0.0",
|
|
218
|
+
"dependencies": {
|
|
219
|
+
"brace-expansion": "^5.0.8"
|
|
220
|
+
},
|
|
221
|
+
"engines": {
|
|
222
|
+
"node": "18 || 20 || >=22"
|
|
223
|
+
},
|
|
224
|
+
"funding": {
|
|
225
|
+
"url": "https://github.com/sponsors/isaacs"
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
"node_modules/minimist": {
|
|
229
|
+
"version": "1.2.8",
|
|
230
|
+
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
|
231
|
+
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
|
232
|
+
"license": "MIT",
|
|
233
|
+
"funding": {
|
|
234
|
+
"url": "https://github.com/sponsors/ljharb"
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"node_modules/minipass": {
|
|
238
|
+
"version": "7.1.3",
|
|
239
|
+
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
|
|
240
|
+
"integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
|
|
241
|
+
"license": "BlueOak-1.0.0",
|
|
242
|
+
"engines": {
|
|
243
|
+
"node": ">=16 || 14 >=14.17"
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
"node_modules/normalize-path": {
|
|
247
|
+
"version": "3.0.0",
|
|
248
|
+
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
|
249
|
+
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
|
|
250
|
+
"license": "MIT",
|
|
251
|
+
"engines": {
|
|
252
|
+
"node": ">=0.10.0"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"node_modules/path-scurry": {
|
|
256
|
+
"version": "2.0.2",
|
|
257
|
+
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz",
|
|
258
|
+
"integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==",
|
|
259
|
+
"license": "BlueOak-1.0.0",
|
|
260
|
+
"dependencies": {
|
|
261
|
+
"lru-cache": "^11.0.0",
|
|
262
|
+
"minipass": "^7.1.2"
|
|
263
|
+
},
|
|
264
|
+
"engines": {
|
|
265
|
+
"node": "18 || 20 || >=22"
|
|
266
|
+
},
|
|
267
|
+
"funding": {
|
|
268
|
+
"url": "https://github.com/sponsors/isaacs"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
"node_modules/picomatch": {
|
|
272
|
+
"version": "4.0.5",
|
|
273
|
+
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
|
|
274
|
+
"integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
|
|
275
|
+
"license": "MIT",
|
|
276
|
+
"peer": true,
|
|
277
|
+
"engines": {
|
|
278
|
+
"node": ">=12"
|
|
279
|
+
},
|
|
280
|
+
"funding": {
|
|
281
|
+
"url": "https://github.com/sponsors/jonschlinkert"
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
"node_modules/prettier": {
|
|
285
|
+
"version": "3.9.6",
|
|
286
|
+
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz",
|
|
287
|
+
"integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==",
|
|
288
|
+
"license": "MIT",
|
|
289
|
+
"bin": {
|
|
290
|
+
"prettier": "bin/prettier.cjs"
|
|
291
|
+
},
|
|
292
|
+
"engines": {
|
|
293
|
+
"node": ">=14"
|
|
294
|
+
},
|
|
295
|
+
"funding": {
|
|
296
|
+
"url": "https://github.com/prettier/prettier?sponsor=1"
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
"node_modules/safe-stable-stringify": {
|
|
300
|
+
"version": "2.5.0",
|
|
301
|
+
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
|
|
302
|
+
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
|
|
303
|
+
"license": "MIT",
|
|
304
|
+
"engines": {
|
|
305
|
+
"node": ">=10"
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
"node_modules/tinyglobby": {
|
|
309
|
+
"version": "0.2.17",
|
|
310
|
+
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
|
311
|
+
"integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
|
|
312
|
+
"license": "MIT",
|
|
313
|
+
"dependencies": {
|
|
314
|
+
"fdir": "^6.5.0",
|
|
315
|
+
"picomatch": "^4.0.4"
|
|
316
|
+
},
|
|
317
|
+
"engines": {
|
|
318
|
+
"node": ">=12.0.0"
|
|
319
|
+
},
|
|
320
|
+
"funding": {
|
|
321
|
+
"url": "https://github.com/sponsors/SuperchupuDev"
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
"node_modules/ts-json-schema-generator": {
|
|
325
|
+
"version": "2.9.0",
|
|
326
|
+
"resolved": "https://registry.npmjs.org/ts-json-schema-generator/-/ts-json-schema-generator-2.9.0.tgz",
|
|
327
|
+
"integrity": "sha512-NR5ZE108uiPtBHBJNGnhwoUaUx5vWTDJzDFG9YlRoqxPU76n+5FClRh92dcGgysbe1smRmYalM9Saj97GW1J4Q==",
|
|
328
|
+
"license": "MIT",
|
|
329
|
+
"dependencies": {
|
|
330
|
+
"@types/json-schema": "^7.0.15",
|
|
331
|
+
"commander": "^14.0.3",
|
|
332
|
+
"glob": "^13.0.6",
|
|
333
|
+
"json5": "^2.2.3",
|
|
334
|
+
"normalize-path": "^3.0.0",
|
|
335
|
+
"safe-stable-stringify": "^2.5.0",
|
|
336
|
+
"tslib": "^2.8.1",
|
|
337
|
+
"typescript": "^5.9.3"
|
|
338
|
+
},
|
|
339
|
+
"bin": {
|
|
340
|
+
"ts-json-schema-generator": "bin/ts-json-schema-generator.js"
|
|
341
|
+
},
|
|
342
|
+
"engines": {
|
|
343
|
+
"node": ">=22.0.0"
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
"node_modules/tslib": {
|
|
347
|
+
"version": "2.8.1",
|
|
348
|
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
|
349
|
+
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
|
350
|
+
"license": "0BSD"
|
|
351
|
+
},
|
|
352
|
+
"node_modules/typescript": {
|
|
353
|
+
"version": "5.9.3",
|
|
354
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
|
355
|
+
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
|
356
|
+
"license": "Apache-2.0",
|
|
357
|
+
"bin": {
|
|
358
|
+
"tsc": "bin/tsc",
|
|
359
|
+
"tsserver": "bin/tsserver"
|
|
360
|
+
},
|
|
361
|
+
"engines": {
|
|
362
|
+
"node": ">=14.17"
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hercules-tsgen",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Node helper for hercules: Pydantic JSON-schema <-> TypeScript type-string conversion.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"json-schema-to-typescript": "^15.0.0",
|
|
9
|
+
"ts-json-schema-generator": "^2.3.0"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Runtime bootstrap for the ``tucana`` protobuf package.
|
|
2
|
+
|
|
3
|
+
The generated protobuf modules published in ``tucana`` cross-import each other
|
|
4
|
+
with top-level roots (``from shared import ...``, ``from aquila import ...``), so
|
|
5
|
+
the ``tucana/generated`` directory has to be on ``sys.path`` for them to import.
|
|
6
|
+
|
|
7
|
+
Importing this package performs that wiring once. The rest of the SDK then imports
|
|
8
|
+
the proto modules from their real location (``tucana.generated.shared`` /
|
|
9
|
+
``tucana.generated.aquila``) so that static analysis and IDEs can resolve them.
|
|
10
|
+
|
|
11
|
+
The struct <-> value helpers live in :mod:`hercules._tucana.helpers`.
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
import tucana.generated as _generated
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def ensure_tucana_path() -> None:
|
|
21
|
+
"""Put ``tucana/generated`` on ``sys.path`` (idempotent)."""
|
|
22
|
+
root = list(_generated.__path__)[0]
|
|
23
|
+
if root not in sys.path:
|
|
24
|
+
sys.path.insert(0, root)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
ensure_tucana_path()
|
|
28
|
+
|
|
29
|
+
__all__ = ["ensure_tucana_path"]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Struct <-> plain value helpers.
|
|
2
|
+
|
|
3
|
+
Python port of ``@code0-tech/tucana/helpers`` (``shared.struct_helper``).
|
|
4
|
+
Converts between the protobuf ``shared.Value`` message and plain Python values.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Union
|
|
9
|
+
|
|
10
|
+
from tucana.generated.shared import struct_pb2
|
|
11
|
+
|
|
12
|
+
# Mirror of the TS ``PlainValue`` union.
|
|
13
|
+
PlainValue = Union[None, bool, int, float, str, list, dict]
|
|
14
|
+
|
|
15
|
+
__all__ = ["PlainValue", "construct_value", "to_allowed_value"]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def to_allowed_value(value: struct_pb2.Value) -> PlainValue:
|
|
19
|
+
"""Convert a protobuf ``Value`` into a plain Python value."""
|
|
20
|
+
kind = value.WhichOneof("kind")
|
|
21
|
+
if kind is None or kind == "null_value":
|
|
22
|
+
return None
|
|
23
|
+
if kind == "number_value":
|
|
24
|
+
number = value.number_value
|
|
25
|
+
which = number.WhichOneof("number")
|
|
26
|
+
if which == "integer":
|
|
27
|
+
return int(number.integer)
|
|
28
|
+
if which == "float":
|
|
29
|
+
return number.float
|
|
30
|
+
raise ValueError(f"Unsupported NumberValue number kind: {which}")
|
|
31
|
+
if kind == "string_value":
|
|
32
|
+
return value.string_value
|
|
33
|
+
if kind == "bool_value":
|
|
34
|
+
return value.bool_value
|
|
35
|
+
if kind == "list_value":
|
|
36
|
+
return [to_allowed_value(v) for v in value.list_value.values]
|
|
37
|
+
if kind == "struct_value":
|
|
38
|
+
return {k: to_allowed_value(v) for k, v in value.struct_value.fields.items()}
|
|
39
|
+
raise ValueError(f"Unsupported Value kind: {kind}")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def construct_value(value: PlainValue) -> struct_pb2.Value:
|
|
43
|
+
"""Convert a plain Python value into a protobuf ``Value``."""
|
|
44
|
+
if value is None:
|
|
45
|
+
return struct_pb2.Value(null_value=struct_pb2.NULL_VALUE)
|
|
46
|
+
# bool must be checked before int (bool is a subclass of int in Python).
|
|
47
|
+
if isinstance(value, bool):
|
|
48
|
+
return struct_pb2.Value(bool_value=value)
|
|
49
|
+
if isinstance(value, int):
|
|
50
|
+
return struct_pb2.Value(
|
|
51
|
+
number_value=struct_pb2.NumberValue(integer=value)
|
|
52
|
+
)
|
|
53
|
+
if isinstance(value, float):
|
|
54
|
+
if value.is_integer():
|
|
55
|
+
return struct_pb2.Value(
|
|
56
|
+
number_value=struct_pb2.NumberValue(integer=int(value))
|
|
57
|
+
)
|
|
58
|
+
return struct_pb2.Value(number_value=struct_pb2.NumberValue(float=value))
|
|
59
|
+
if isinstance(value, str):
|
|
60
|
+
return struct_pb2.Value(string_value=value)
|
|
61
|
+
if isinstance(value, (list, tuple)):
|
|
62
|
+
return struct_pb2.Value(
|
|
63
|
+
list_value=struct_pb2.ListValue(
|
|
64
|
+
values=[construct_value(v) for v in value]
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
if isinstance(value, dict):
|
|
68
|
+
return struct_pb2.Value(
|
|
69
|
+
struct_value=struct_pb2.Struct(
|
|
70
|
+
fields={k: construct_value(v) for k, v in value.items()}
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
raise ValueError(f"Unsupported value type: {type(value).__name__}")
|