polyapi-python 0.3.18.dev2__py3-none-any.whl → 0.3.18.dev4__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/cli.py +2 -2
- polyapi/poly_schemas.py +42 -3
- {polyapi_python-0.3.18.dev2.dist-info → polyapi_python-0.3.18.dev4.dist-info}/METADATA +2 -2
- {polyapi_python-0.3.18.dev2.dist-info → polyapi_python-0.3.18.dev4.dist-info}/RECORD +7 -7
- {polyapi_python-0.3.18.dev2.dist-info → polyapi_python-0.3.18.dev4.dist-info}/WHEEL +0 -0
- {polyapi_python-0.3.18.dev2.dist-info → polyapi_python-0.3.18.dev4.dist-info}/licenses/LICENSE +0 -0
- {polyapi_python-0.3.18.dev2.dist-info → polyapi_python-0.3.18.dev4.dist-info}/top_level.txt +0 -0
polyapi/cli.py
CHANGED
|
@@ -114,7 +114,7 @@ def execute_from_cli():
|
|
|
114
114
|
fn_add_parser.add_argument("--client", action="store_true", help="Marks the function as a client function")
|
|
115
115
|
fn_add_parser.add_argument("--logs", choices=["enabled", "disabled"], default=None, help="Enable or disable logs for the function.")
|
|
116
116
|
fn_add_parser.add_argument("--execution-api-key", required=False, default="", help="API key for execution (for server functions only).")
|
|
117
|
-
fn_add_parser.add_argument("--
|
|
117
|
+
fn_add_parser.add_argument("--skip-generate", action="store_true", help="Skip running generate after function add command, especially useful if you are deploying a bunch of functions at once. Run generate manually at the end!")
|
|
118
118
|
fn_add_parser.add_argument("--generate-contexts", type=str, help="Server function only – only include certain contexts to speed up function execution")
|
|
119
119
|
fn_add_parser.add_argument("--visibility", type=str, default="environment", help="Specifies the visibility of a function. Options: PUBLIC, TENANT, ENVIRONMENT. Case insensitive")
|
|
120
120
|
|
|
@@ -147,7 +147,7 @@ def execute_from_cli():
|
|
|
147
147
|
client=args.client,
|
|
148
148
|
server=args.server,
|
|
149
149
|
logs_enabled=logs_enabled,
|
|
150
|
-
generate=not args.
|
|
150
|
+
generate=not args.skip_generate,
|
|
151
151
|
execution_api_key=args.execution_api_key,
|
|
152
152
|
generate_contexts=args.generate_contexts,
|
|
153
153
|
visibility=visibility
|
polyapi/poly_schemas.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import re
|
|
2
3
|
import logging
|
|
3
4
|
import tempfile
|
|
4
5
|
import shutil
|
|
5
|
-
from typing import Any, Dict, List, Tuple
|
|
6
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
6
7
|
|
|
7
8
|
from polyapi.schema import wrapped_generate_schema_types
|
|
8
9
|
from polyapi.utils import add_import_to_init, init_the_init, to_func_namespace
|
|
@@ -23,7 +24,7 @@ FALLBACK_SPEC_TEMPLATE = """class {name}(TypedDict, total=False):
|
|
|
23
24
|
"""
|
|
24
25
|
|
|
25
26
|
|
|
26
|
-
def generate_schemas(specs: List[SchemaSpecDto], limit_ids: List[str] = None):
|
|
27
|
+
def generate_schemas(specs: List[SchemaSpecDto], limit_ids: Optional[List[str]] = None):
|
|
27
28
|
failed_schemas = []
|
|
28
29
|
successful_schemas = []
|
|
29
30
|
if limit_ids:
|
|
@@ -209,6 +210,44 @@ def add_schema_to_init(full_path: str, spec: SchemaSpecDto):
|
|
|
209
210
|
f.write(render_poly_schema(spec) + "\n\n")
|
|
210
211
|
|
|
211
212
|
|
|
213
|
+
def _fix_typed_dict_imports(code: str) -> str:
|
|
214
|
+
"""Move TypedDict/NotRequired from `typing` to `typing_extensions` in generated code.
|
|
215
|
+
|
|
216
|
+
jsonschema_gentypes spits out `from typing import ..., TypedDict, ...` which makes
|
|
217
|
+
typing._TypedDictMeta instances. The deploy validator wants typing_extensions.TypedDict,
|
|
218
|
+
so let's rewrite the imports here before writing schema files to disk.
|
|
219
|
+
"""
|
|
220
|
+
lines = code.split('\n')
|
|
221
|
+
new_lines = []
|
|
222
|
+
has_te_import = False
|
|
223
|
+
|
|
224
|
+
for line in lines:
|
|
225
|
+
if re.match(r'from\s+typing_extensions\s+import', line):
|
|
226
|
+
has_te_import = True
|
|
227
|
+
# Ensure TypedDict and NotRequired are in the existing typing_extensions line
|
|
228
|
+
name_set = {n.strip() for n in line.split('import', 1)[1].split(',')}
|
|
229
|
+
name_set |= {'TypedDict', 'NotRequired'}
|
|
230
|
+
new_lines.append(f"from typing_extensions import {', '.join(sorted(name_set))}")
|
|
231
|
+
continue
|
|
232
|
+
|
|
233
|
+
if re.match(r'from\s+typing\s+import', line):
|
|
234
|
+
# Strip TypedDict and NotRequired from the typing import
|
|
235
|
+
names_str = line.split('import', 1)[1]
|
|
236
|
+
names: list[str] = [n.strip() for n in names_str.split(',')]
|
|
237
|
+
names = [n for n in names if n not in ('TypedDict', 'NotRequired', '')]
|
|
238
|
+
if names:
|
|
239
|
+
new_lines.append(f"from typing import {', '.join(names)}")
|
|
240
|
+
# drop the line entirely if nothing is left
|
|
241
|
+
continue
|
|
242
|
+
|
|
243
|
+
new_lines.append(line)
|
|
244
|
+
|
|
245
|
+
result = '\n'.join(new_lines)
|
|
246
|
+
if not has_te_import:
|
|
247
|
+
result = 'from typing_extensions import NotRequired, TypedDict\n' + result
|
|
248
|
+
return result
|
|
249
|
+
|
|
250
|
+
|
|
212
251
|
def render_poly_schema(spec: SchemaSpecDto) -> str:
|
|
213
252
|
definition = spec["definition"]
|
|
214
253
|
if not definition.get("type"):
|
|
@@ -216,5 +255,5 @@ def render_poly_schema(spec: SchemaSpecDto) -> str:
|
|
|
216
255
|
root, schema_types = wrapped_generate_schema_types(
|
|
217
256
|
definition, root=spec["name"], fallback_type=Dict
|
|
218
257
|
)
|
|
219
|
-
return schema_types
|
|
258
|
+
return _fix_typed_dict_imports(schema_types)
|
|
220
259
|
# return FALLBACK_SPEC_TEMPLATE.format(name=spec["name"])
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: polyapi-python
|
|
3
|
-
Version: 0.3.18.
|
|
3
|
+
Version: 0.3.18.dev4
|
|
4
4
|
Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
|
|
5
|
-
Author-email:
|
|
5
|
+
Author-email: PolyAPI <support@polyapi.io>
|
|
6
6
|
License: MIT License
|
|
7
7
|
|
|
8
8
|
Copyright (c) 2025 PolyAPI Inc.
|
|
@@ -2,7 +2,7 @@ polyapi/__init__.py,sha256=vV1N9xtIMtpi4o-2jAI3775LkzRbC9JUo87MAnW9zgo,5201
|
|
|
2
2
|
polyapi/__main__.py,sha256=V4zhAh_YGxno5f_KSrlkELxcuDh9bR3WSd0n-2r-qQQ,93
|
|
3
3
|
polyapi/api.py,sha256=CzqX99GekhQJVqAAWlL03hUenIi_5iTln9cWgQzz6Ko,2784
|
|
4
4
|
polyapi/auth.py,sha256=l0pGAoYvEWqa2TMsrM9GS8imXu3GsWvpn4eFPy1vksI,6195
|
|
5
|
-
polyapi/cli.py,sha256=
|
|
5
|
+
polyapi/cli.py,sha256=MMIR0WbKjDYrVVKa4yNBYYB--46ZIRZkvWGAM3xgek0,11134
|
|
6
6
|
polyapi/cli_constants.py,sha256=eZnAqAo8HLxHH3cdAoGWbrsALAtEWJFXRdSS2lvQvzE,144
|
|
7
7
|
polyapi/client.py,sha256=DW6ljG_xCwAo2yz23A9QfLooE6ZUDvSpdA4e_dCQjiQ,1418
|
|
8
8
|
polyapi/config.py,sha256=dnowfPKEau5sA4zwBzLK_dYAHA-Wi3AOnMtDNsYwUmM,7520
|
|
@@ -15,7 +15,7 @@ polyapi/function_cli.py,sha256=kKrecKCDNMmYtcOOCVF2KKOGjFUfWD2TbiVsyYQ84y8,4323
|
|
|
15
15
|
polyapi/generate.py,sha256=LzQBm2GKYfAwTsJ36ViLr1ypzrudijj1qR0DRzp-Be0,21764
|
|
16
16
|
polyapi/http_client.py,sha256=Pd6FYHGB6plWlBbwZD9LPP6FEicdp0wyLWHd_9jxsaY,2273
|
|
17
17
|
polyapi/parser.py,sha256=pAkeuwp1Kn6bHXiIoj-DuXQ518PztQThIa8vztgsKLQ,21525
|
|
18
|
-
polyapi/poly_schemas.py,sha256=
|
|
18
|
+
polyapi/poly_schemas.py,sha256=JGMQbELPFw4V_0nA0o71WJKFTdxjCGoKqJvIid_Y-a4,10759
|
|
19
19
|
polyapi/poly_tables.py,sha256=xFxR69dZNmePT9mUz3DvsoreQK7huIa07evEmOSixA0,20271
|
|
20
20
|
polyapi/prepare.py,sha256=DBlrQu_A0PqdaQ3KlMs-C6PkV3qncatkAiBlC7j2hnk,7441
|
|
21
21
|
polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -27,8 +27,8 @@ polyapi/typedefs.py,sha256=mfll-KrngOW0wzbvDNiIDaDkFMwbsT-MY5y5hzWj9RE,5642
|
|
|
27
27
|
polyapi/utils.py,sha256=SfzK86nhg1wuGzbI53DEFKJ3JkxZ0yU-CZBd_caKbrQ,15313
|
|
28
28
|
polyapi/variables.py,sha256=hfSDPGQK6YphNCa9MqE0W88WIFfqCQWgpBDWkExMq-A,7582
|
|
29
29
|
polyapi/webhook.py,sha256=0ceLwHNjNd2Yx_8MX5jOIxiQ5Lwhy2pe81ProAuKon0,5108
|
|
30
|
-
polyapi_python-0.3.18.
|
|
31
|
-
polyapi_python-0.3.18.
|
|
32
|
-
polyapi_python-0.3.18.
|
|
33
|
-
polyapi_python-0.3.18.
|
|
34
|
-
polyapi_python-0.3.18.
|
|
30
|
+
polyapi_python-0.3.18.dev4.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
|
|
31
|
+
polyapi_python-0.3.18.dev4.dist-info/METADATA,sha256=cwcrrk4hlhXzAv7QMpNRhuBgXBNqqakd_5W-HqsILG0,5915
|
|
32
|
+
polyapi_python-0.3.18.dev4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
33
|
+
polyapi_python-0.3.18.dev4.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
|
|
34
|
+
polyapi_python-0.3.18.dev4.dist-info/RECORD,,
|
|
File without changes
|
{polyapi_python-0.3.18.dev2.dist-info → polyapi_python-0.3.18.dev4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|