polyapi-python 0.3.7.dev4__py3-none-any.whl → 0.3.7.dev6__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.
polyapi/__init__.py CHANGED
@@ -1,7 +1,8 @@
1
1
  import os
2
2
  import sys
3
+ import copy
3
4
  import truststore
4
- from typing import Any, Optional, overload, Literal
5
+ from typing import Any, Dict, Optional, overload, Literal
5
6
  from typing_extensions import TypedDict
6
7
  truststore.inject_into_ssl()
7
8
  from .cli import CLI_COMMANDS
@@ -22,6 +23,7 @@ class PolyCustomDict(TypedDict, total=False):
22
23
  executionApiKey: Optional[str]
23
24
  responseStatusCode: int
24
25
  responseContentType: Optional[str]
26
+ responseHeaders: Dict[str, str]
25
27
 
26
28
 
27
29
  class _PolyCustom:
@@ -31,6 +33,7 @@ class _PolyCustom:
31
33
  "executionApiKey": None,
32
34
  "responseStatusCode": 200,
33
35
  "responseContentType": None,
36
+ "responseHeaders": {},
34
37
  }
35
38
  self._execution_id_locked = False
36
39
 
@@ -63,6 +66,9 @@ class _PolyCustom:
63
66
 
64
67
  @overload
65
68
  def __getitem__(self, key: Literal["responseContentType"]) -> Optional[str]: ...
69
+
70
+ @overload
71
+ def __getitem__(self, key: Literal["responseHeaders"]) -> Dict[str, str]: ...
66
72
 
67
73
  def __getitem__(self, key: str) -> Any:
68
74
  return self.get(key)
@@ -75,6 +81,9 @@ class _PolyCustom:
75
81
 
76
82
  @overload
77
83
  def __setitem__(self, key: Literal["responseContentType"], value: Optional[str]) -> None: ...
84
+
85
+ @overload
86
+ def __setitem__(self, key: Literal["responseHeaders"], value: Dict[str, str]) -> None: ...
78
87
 
79
88
  def __setitem__(self, key: str, value: Any) -> None:
80
89
  self.set_once(key, value)
@@ -84,7 +93,7 @@ class _PolyCustom:
84
93
 
85
94
  def copy(self) -> '_PolyCustom':
86
95
  new = _PolyCustom()
87
- new._internal_store = self._internal_store.copy()
96
+ new._internal_store = copy.deepcopy(self._internal_store)
88
97
  new._execution_id_locked = self._execution_id_locked
89
98
  return new
90
99
 
polyapi/schema.py CHANGED
@@ -126,4 +126,8 @@ def clean_title(title: str) -> str:
126
126
 
127
127
  def map_primitive_types(type_: str) -> str:
128
128
  # Define your mapping logic here
129
- return JSONSCHEMA_TO_PYTHON_TYPE_MAP.get(type_, "Any")
129
+ return JSONSCHEMA_TO_PYTHON_TYPE_MAP.get(type_, "Any")
130
+
131
+
132
+ def is_primitive(type_: str) -> bool:
133
+ return type_ in JSONSCHEMA_TO_PYTHON_TYPE_MAP
polyapi/utils.py CHANGED
@@ -11,6 +11,7 @@ from polyapi.schema import (
11
11
  wrapped_generate_schema_types,
12
12
  clean_title,
13
13
  map_primitive_types,
14
+ is_primitive
14
15
  )
15
16
 
16
17
 
@@ -140,11 +141,17 @@ def get_type_and_def(
140
141
  # TODO fix me
141
142
  # we don't use ReturnType as name for the list type here, we use _ReturnTypeItem
142
143
  return "List", ""
144
+ elif title and title == "ReturnType" and schema.get("type"):
145
+ assert isinstance(title, str)
146
+ schema_type = schema.get("type", "Any")
147
+ root_type, generated_code = wrapped_generate_schema_types(schema, schema_type, "Dict") # type: ignore
148
+ return (map_primitive_types(root_type), "") if is_primitive(root_type) else (root_type, generated_code) # type: ignore
143
149
  elif title:
144
150
  assert isinstance(title, str)
145
151
  # For no-types mode, avoid complex schema generation
146
152
  try:
147
- return wrapped_generate_schema_types(schema, title, "Dict") # type: ignore
153
+ root_type, generated_code = wrapped_generate_schema_types(schema, title, "Dict") # type: ignore
154
+ return ("Any", "") if root_type == "ReturnType" else wrapped_generate_schema_types(schema, title, "Dict") # type: ignore
148
155
  except:
149
156
  return "Dict", ""
150
157
  elif schema.get("allOf") and len(schema["allOf"]):
polyapi/webhook.py CHANGED
@@ -65,6 +65,7 @@ async def {function_name}(
65
65
  "data": resp,
66
66
  "statusCode": polyCustom.get("responseStatusCode", 200),
67
67
  "contentType": polyCustom.get("responseContentType", None),
68
+ "headers": polyCustom.get("responseHeaders", {{}}),
68
69
  }},
69
70
  }}, namespace="/events")
70
71
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyapi-python
3
- Version: 0.3.7.dev4
3
+ Version: 0.3.7.dev6
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- polyapi/__init__.py,sha256=Au5snCFb05a87mDMK2Cwoft7nntR35iw4lL0Ztgivoo,2931
1
+ polyapi/__init__.py,sha256=hw7x4j9JNJfPdkIOZqV0X9pbYcw3_5AH1iQFdSogH-c,3235
2
2
  polyapi/__main__.py,sha256=V4zhAh_YGxno5f_KSrlkELxcuDh9bR3WSd0n-2r-qQQ,93
3
3
  polyapi/api.py,sha256=2nds6ZdNe9OHvCba4IjOPga0CAYIsib2SbhEyDDCmd8,2188
4
4
  polyapi/auth.py,sha256=zrIGatjba5GwUTNjKj1GHQWTEDP9B-HrSzCKbLFoqvc,5336
@@ -17,15 +17,15 @@ polyapi/poly_schemas.py,sha256=T4kfZyfgVLiqLD28GmYNiHnrNx77J_HO4uzk8LUAhlo,3137
17
17
  polyapi/prepare.py,sha256=Q8CWV4kmZ2dbXYVsud34AgJkj5ymcQ_IcYhLuikc9yk,6659
18
18
  polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  polyapi/rendered_spec.py,sha256=nJEj2vRgG3N20fU4s-ThRtOIwAuTzXwXuOBIkXljDVc,2240
20
- polyapi/schema.py,sha256=ZSzeUjpqigLvE4tFKB7y4AaZG-W5N5Z9wMH-F-vjMBU,4616
20
+ polyapi/schema.py,sha256=K5oAELfyAU3kuo1wSkTvNiA_Ppt2JCJwyg8F8XtLDU4,4707
21
21
  polyapi/server.py,sha256=YXWxhYBx-hluwDQ8Jvfpy2s8ogz0GsNTMcZVNcP5ca8,2147
22
22
  polyapi/sync.py,sha256=PGdC0feBBjEVrF3d9EluW_OAxbWuzSrfh84czma8kWg,6476
23
23
  polyapi/typedefs.py,sha256=MGDwWaijLNqokXF9UCHGAP-yKixOzztrH4Lsj800AJs,2328
24
- polyapi/utils.py,sha256=pHDwx4zDHKe0m2ZERo86DfI8ep42c0h1TyJpKqHxkgc,11844
24
+ polyapi/utils.py,sha256=1F7Dwst_PbPuUBUSxx5r8d2DHDgqHtu07QW92T_YSdw,12454
25
25
  polyapi/variables.py,sha256=j7WWrGLr2O5SkWGxnsusnnfl25kVL3b6SQYcVGEoC8c,4277
26
- polyapi/webhook.py,sha256=LWv28c2MLz_OKBI_Nn7WR4C-gs1SWgbdXsoxIIf-9UI,4886
27
- polyapi_python-0.3.7.dev4.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
28
- polyapi_python-0.3.7.dev4.dist-info/METADATA,sha256=_F2hAG7HAELadV-PMhmTGAj1t0i6jsOhFWWdAR-P_bU,5782
29
- polyapi_python-0.3.7.dev4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- polyapi_python-0.3.7.dev4.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
31
- polyapi_python-0.3.7.dev4.dist-info/RECORD,,
26
+ polyapi/webhook.py,sha256=NTSXYOl_QqsFekWRepPyVTsV9SVkgUu0HfG1SJJDHOE,4958
27
+ polyapi_python-0.3.7.dev6.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
28
+ polyapi_python-0.3.7.dev6.dist-info/METADATA,sha256=KDdI1VAuH-3lZjFi_yvyXb6oDQS3KDLMYYmNK_pHB8I,5782
29
+ polyapi_python-0.3.7.dev6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ polyapi_python-0.3.7.dev6.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
31
+ polyapi_python-0.3.7.dev6.dist-info/RECORD,,