soia-client 1.1.2__py3-none-any.whl → 1.1.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.

Potentially problematic release.


This version of soia-client might be problematic. Click here for more details.

soia/_impl/service.py CHANGED
@@ -26,29 +26,50 @@ class _MethodImpl(Generic[Request, Response, RequestHeaders, ResponseHeaders]):
26
26
  @dataclass(frozen=True)
27
27
  class RawServiceResponse:
28
28
  data: str
29
- type: Literal["ok-json", "bad-request", "server-error"]
29
+ type: Literal["ok-json", "ok-html", "bad-request", "server-error"]
30
30
 
31
31
  @property
32
32
  def status_code(self):
33
- if self.type == "ok-json":
33
+ if self.type == "ok-json" or self.type == "ok-html":
34
34
  return 200
35
35
  elif self.type == "bad-request":
36
36
  return 400
37
37
  elif self.type == "server-error":
38
38
  return 500
39
39
  else:
40
+ _: Never = self.type
40
41
  raise TypeError(f"Unknown response type: {self.type}")
41
42
 
42
43
  @property
43
44
  def content_type(self):
44
45
  if self.type == "ok-json":
45
46
  return "application/json"
47
+ if self.type == "ok-html":
48
+ return "text/html; charset=utf-8"
46
49
  elif self.type == "bad-request" or self.type == "server-error":
47
50
  return "text/plain; charset=utf-8"
48
51
  else:
52
+ _: Never = self.type
49
53
  raise TypeError(f"Unknown response type: {self.type}")
50
54
 
51
55
 
56
+ # Copied from
57
+ # https://github.com/gepheum/restudio/blob/main/index.jsdeliver.html
58
+ _RESTUDIO_HTML = """<!DOCTYPE html>
59
+
60
+ <html>
61
+ <head>
62
+ <meta charset="utf-8" />
63
+ <title>RESTudio</title>
64
+ <script src="https://cdn.jsdelivr.net/npm/restudio/dist/restudio-standalone.js"></script>
65
+ </head>
66
+ <body style="margin: 0; padding: 0;">
67
+ <restudio-app></restudio-app>
68
+ </body>
69
+ </html>
70
+ """
71
+
72
+
52
73
  @dataclass()
53
74
  class _HandleRequestFlow(Generic[Request, Response, RequestHeaders, ResponseHeaders]):
54
75
  req_body: str
@@ -94,6 +115,9 @@ class _HandleRequestFlow(Generic[Request, Response, RequestHeaders, ResponseHead
94
115
  if self.req_body in ["", "list"]:
95
116
  return self._handle_list()
96
117
 
118
+ if self.req_body == "restudio":
119
+ return self._handle_restudio()
120
+
97
121
  # Method invokation
98
122
  method_name: str
99
123
  method_number: int | None
@@ -211,6 +235,9 @@ class _HandleRequestFlow(Generic[Request, Response, RequestHeaders, ResponseHead
211
235
  )
212
236
  return RawServiceResponse(json_code, "ok-json")
213
237
 
238
+ def _handle_restudio(self) -> RawServiceResponse:
239
+ return RawServiceResponse(_RESTUDIO_HTML, "ok-html")
240
+
214
241
  def _response_to_json(
215
242
  self,
216
243
  res: Response,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soia-client
3
- Version: 1.1.2
3
+ Version: 1.1.4
4
4
  Author-email: Tyler Fibonacci <gepheum@gmail.com>
5
5
  License: MIT License
6
6
 
@@ -15,13 +15,13 @@ soia/_impl/primitives.py,sha256=r-55rO12TwwWCQJgzEEgVpXMVGg0dRhGvFWX_rGeqsQ,9025
15
15
  soia/_impl/repr.py,sha256=7WX0bEAVENTjlyZIcbT8TcJylS7IRIyafGCmqaIMxFM,1413
16
16
  soia/_impl/serializer.py,sha256=28IwkjtUnLpbnPQfVNfJXkApCK4JhXHwLkC5MVhF8xo,3529
17
17
  soia/_impl/serializers.py,sha256=IL9jHHMo11pgrL1-crarOEElvTyV5YM6FTcgumjW6IU,2564
18
- soia/_impl/service.py,sha256=3dpcH4XEBTEShyjzxMA_zDGg9_amTFF5A49U6hivAdQ,14792
18
+ soia/_impl/service.py,sha256=ltOCPJupK3mEDiq9wldkDb0rfpVhyqWFxywGJ42Vklg,15573
19
19
  soia/_impl/service_client.py,sha256=0WgiN6Stg548FAdZQMuezZoooe4MYw2frEQ5KUE7xag,5311
20
20
  soia/_impl/structs.py,sha256=1XhjZmqtD7IMURdSVR0DwMdrIhWPZft1eCfwVW84c0E,28230
21
21
  soia/_impl/timestamp.py,sha256=upnEkvW-7AaMJ9_nNqntvhJ4pFWWCAXNjEOPtszdwgE,5645
22
22
  soia/_impl/type_adapter.py,sha256=RyIyh4Fnt9rMy0HRzC-a2v2JAdZsV9FBzoGEUVygVRE,2101
23
- soia_client-1.1.2.dist-info/licenses/LICENSE,sha256=SaAftKkX6hfSOiPdENQPS70tifH3PDHgazq8eK2Pwfw,1064
24
- soia_client-1.1.2.dist-info/METADATA,sha256=gzME6YAXgQaA0ZCoU8Psh7Tf4HlBI-mJhnWnuH4t3l8,2121
25
- soia_client-1.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- soia_client-1.1.2.dist-info/top_level.txt,sha256=lsYG9JrvauFe1oIV5zvnwsS9hsx3ztwfK_937op9mxc,5
27
- soia_client-1.1.2.dist-info/RECORD,,
23
+ soia_client-1.1.4.dist-info/licenses/LICENSE,sha256=SaAftKkX6hfSOiPdENQPS70tifH3PDHgazq8eK2Pwfw,1064
24
+ soia_client-1.1.4.dist-info/METADATA,sha256=PzbbwzwRvEfsFGRW5tmwPlP5N9QroX8tXNVeeEFFUMc,2121
25
+ soia_client-1.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
+ soia_client-1.1.4.dist-info/top_level.txt,sha256=lsYG9JrvauFe1oIV5zvnwsS9hsx3ztwfK_937op9mxc,5
27
+ soia_client-1.1.4.dist-info/RECORD,,