clear-skies 2.0.7__py3-none-any.whl → 2.0.8__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 clear-skies might be problematic. Click here for more details.
- {clear_skies-2.0.7.dist-info → clear_skies-2.0.8.dist-info}/METADATA +1 -1
- clear_skies-2.0.8.dist-info/RECORD +252 -0
- clearskies/__init__.py +2 -2
- clearskies/authentication/authentication.py +1 -3
- clearskies/authentication/authorization.py +12 -5
- clearskies/authentication/authorization_pass_through.py +5 -3
- clearskies/authentication/jwks.py +25 -23
- clearskies/authentication/secret_bearer.py +15 -17
- clearskies/autodoc/schema/schema.py +1 -1
- clearskies/backends/api_backend.py +50 -56
- clearskies/backends/backend.py +14 -14
- clearskies/backends/cursor_backend.py +17 -23
- clearskies/backends/memory_backend.py +27 -30
- clearskies/backends/secrets_backend.py +13 -18
- clearskies/column.py +44 -56
- clearskies/columns/audit.py +14 -13
- clearskies/columns/belongs_to_id.py +10 -15
- clearskies/columns/belongs_to_model.py +6 -9
- clearskies/columns/belongs_to_self.py +13 -9
- clearskies/columns/boolean.py +13 -16
- clearskies/columns/category_tree.py +9 -11
- clearskies/columns/category_tree_children.py +2 -3
- clearskies/columns/category_tree_descendants.py +1 -1
- clearskies/columns/created.py +8 -11
- clearskies/columns/created_by_authorization_data.py +7 -9
- clearskies/columns/created_by_header.py +12 -8
- clearskies/columns/created_by_ip.py +6 -8
- clearskies/columns/created_by_routing_data.py +12 -7
- clearskies/columns/created_by_user_agent.py +6 -9
- clearskies/columns/date.py +12 -14
- clearskies/columns/datetime.py +19 -17
- clearskies/columns/email.py +3 -1
- clearskies/columns/float.py +10 -14
- clearskies/columns/has_many.py +8 -10
- clearskies/columns/has_many_self.py +13 -7
- clearskies/columns/has_one.py +2 -0
- clearskies/columns/integer.py +9 -11
- clearskies/columns/json.py +10 -12
- clearskies/columns/many_to_many_ids.py +14 -16
- clearskies/columns/many_to_many_ids_with_data.py +16 -16
- clearskies/columns/many_to_many_models.py +5 -7
- clearskies/columns/many_to_many_pivots.py +3 -5
- clearskies/columns/phone.py +12 -9
- clearskies/columns/select.py +12 -9
- clearskies/columns/string.py +1 -1
- clearskies/columns/timestamp.py +15 -15
- clearskies/columns/updated.py +8 -10
- clearskies/columns/uuid.py +7 -10
- clearskies/configs/any.py +2 -0
- clearskies/configs/any_dict.py +2 -0
- clearskies/configs/any_dict_or_callable.py +2 -0
- clearskies/configs/boolean.py +2 -0
- clearskies/configs/boolean_or_callable.py +2 -0
- clearskies/configs/callable_config.py +2 -0
- clearskies/configs/config.py +2 -0
- clearskies/configs/datetime.py +2 -0
- clearskies/configs/datetime_or_callable.py +2 -0
- clearskies/configs/float.py +2 -0
- clearskies/configs/float_or_callable.py +2 -0
- clearskies/configs/integer.py +2 -0
- clearskies/configs/integer_or_callable.py +2 -0
- clearskies/configs/list_any_dict.py +2 -0
- clearskies/configs/list_any_dict_or_callable.py +2 -0
- clearskies/configs/model_column.py +2 -0
- clearskies/configs/model_columns.py +2 -0
- clearskies/configs/model_destination_name.py +2 -1
- clearskies/configs/model_to_id_column.py +2 -0
- clearskies/configs/readable_model_column.py +2 -0
- clearskies/configs/readable_model_columns.py +2 -0
- clearskies/configs/searchable_model_columns.py +2 -0
- clearskies/configs/select.py +2 -0
- clearskies/configs/select_list.py +2 -0
- clearskies/configs/string.py +2 -0
- clearskies/configs/string_dict.py +2 -0
- clearskies/configs/string_list.py +2 -0
- clearskies/configs/string_list_or_callable.py +2 -0
- clearskies/configs/timedelta.py +2 -0
- clearskies/configs/timezone.py +2 -0
- clearskies/configs/url.py +2 -0
- clearskies/configs/writeable_model_column.py +2 -0
- clearskies/configs/writeable_model_columns.py +2 -0
- clearskies/configurable.py +2 -0
- clearskies/contexts/cli.py +9 -1
- clearskies/contexts/context.py +13 -14
- clearskies/contexts/wsgi.py +12 -10
- clearskies/contexts/wsgi_ref.py +12 -6
- clearskies/decorators.py +1 -1
- clearskies/decorators.pyi +10 -0
- clearskies/di/di.py +7 -6
- clearskies/di/inject/by_class.py +2 -0
- clearskies/di/inject/by_name.py +2 -0
- clearskies/di/inject/di.py +2 -0
- clearskies/di/inject/environment.py +1 -1
- clearskies/di/inject/now.py +2 -0
- clearskies/di/inject/requests.py +2 -0
- clearskies/di/inject/secrets.py +2 -2
- clearskies/di/inject/utcnow.py +2 -0
- clearskies/di/inject/uuid.py +2 -2
- clearskies/end.py +45 -7
- clearskies/endpoint.py +43 -59
- clearskies/endpoint_group.py +15 -18
- clearskies/endpoints/advanced_search.py +19 -26
- clearskies/endpoints/callable.py +10 -16
- clearskies/endpoints/create.py +6 -10
- clearskies/endpoints/delete.py +5 -11
- clearskies/endpoints/get.py +11 -15
- clearskies/endpoints/health_check.py +9 -11
- clearskies/endpoints/list.py +29 -36
- clearskies/endpoints/restful_api.py +43 -53
- clearskies/endpoints/schema.py +14 -18
- clearskies/endpoints/simple_search.py +5 -12
- clearskies/endpoints/update.py +6 -11
- clearskies/environment.py +2 -0
- clearskies/input_outputs/cli.py +2 -0
- clearskies/input_outputs/headers.py +2 -0
- clearskies/input_outputs/input_output.py +15 -15
- clearskies/input_outputs/programmatic.py +2 -2
- clearskies/input_outputs/wsgi.py +2 -2
- clearskies/model.py +120 -25
- clearskies/query/query.py +1 -4
- clearskies/secrets/__init__.py +2 -1
- clearskies/secrets/akeyless.py +12 -10
- clearskies/secrets/secrets.py +7 -2
- clearskies/security_header.py +4 -2
- clearskies/security_headers/cache_control.py +15 -14
- clearskies/security_headers/cors.py +10 -9
- clearskies/security_headers/csp.py +25 -24
- clearskies/security_headers/hsts.py +6 -5
- clearskies/typing.py +1 -1
- clearskies/validator.py +5 -6
- clearskies/validators/after_column.py +6 -7
- clearskies/validators/before_column.py +2 -0
- clearskies/validators/in_the_future.py +5 -8
- clearskies/validators/in_the_future_at_least.py +2 -0
- clearskies/validators/in_the_future_at_most.py +2 -0
- clearskies/validators/in_the_past.py +5 -8
- clearskies/validators/in_the_past_at_least.py +2 -0
- clearskies/validators/in_the_past_at_most.py +2 -0
- clearskies/validators/maximum_length.py +4 -5
- clearskies/validators/maximum_value.py +4 -4
- clearskies/validators/minimum_length.py +4 -4
- clearskies/validators/minimum_value.py +4 -4
- clearskies/validators/required.py +2 -4
- clearskies/validators/timedelta.py +8 -9
- clearskies/validators/unique.py +2 -3
- clear_skies-2.0.7.dist-info/RECORD +0 -251
- {clear_skies-2.0.7.dist-info → clear_skies-2.0.8.dist-info}/WHEEL +0 -0
- {clear_skies-2.0.7.dist-info → clear_skies-2.0.8.dist-info}/licenses/LICENSE +0 -0
clearskies/columns/uuid.py
CHANGED
|
@@ -2,14 +2,11 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import clearskies.di
|
|
7
|
-
import clearskies.typing
|
|
8
|
-
from clearskies import configs
|
|
5
|
+
from clearskies import configs, decorators, di
|
|
9
6
|
from clearskies.columns.string import String
|
|
10
7
|
|
|
11
8
|
if TYPE_CHECKING:
|
|
12
|
-
from clearskies import Model
|
|
9
|
+
from clearskies import Model, typing
|
|
13
10
|
|
|
14
11
|
|
|
15
12
|
class Uuid(String):
|
|
@@ -63,17 +60,17 @@ class Uuid(String):
|
|
|
63
60
|
is_writeable = configs.Boolean(default=False)
|
|
64
61
|
_descriptor_config_map = None
|
|
65
62
|
|
|
66
|
-
uuid =
|
|
63
|
+
uuid = di.inject.Uuid()
|
|
67
64
|
|
|
68
|
-
@
|
|
65
|
+
@decorators.parameters_to_properties
|
|
69
66
|
def __init__(
|
|
70
67
|
self,
|
|
71
68
|
is_readable: bool = True,
|
|
72
69
|
is_searchable: bool = True,
|
|
73
70
|
is_temporary: bool = False,
|
|
74
|
-
on_change_pre_save:
|
|
75
|
-
on_change_post_save:
|
|
76
|
-
on_change_save_finished:
|
|
71
|
+
on_change_pre_save: typing.action | list[typing.action] = [],
|
|
72
|
+
on_change_post_save: typing.action | list[typing.action] = [],
|
|
73
|
+
on_change_save_finished: typing.action | list[typing.action] = [],
|
|
77
74
|
):
|
|
78
75
|
pass
|
|
79
76
|
|
clearskies/configs/any.py
CHANGED
clearskies/configs/any_dict.py
CHANGED
clearskies/configs/boolean.py
CHANGED
clearskies/configs/config.py
CHANGED
clearskies/configs/datetime.py
CHANGED
clearskies/configs/float.py
CHANGED
clearskies/configs/integer.py
CHANGED
clearskies/configs/select.py
CHANGED
clearskies/configs/string.py
CHANGED
clearskies/configs/timedelta.py
CHANGED
clearskies/configs/timezone.py
CHANGED
clearskies/configs/url.py
CHANGED
clearskies/configurable.py
CHANGED
clearskies/contexts/cli.py
CHANGED
|
@@ -4,7 +4,7 @@ from clearskies.input_outputs import Cli as CliInputOutput
|
|
|
4
4
|
|
|
5
5
|
class Cli(Context):
|
|
6
6
|
"""
|
|
7
|
-
Run an application via a CLI command
|
|
7
|
+
Run an application via a CLI command.
|
|
8
8
|
|
|
9
9
|
This context converts a clearskies application into a CLI command. Here's a simple example:
|
|
10
10
|
|
|
@@ -12,9 +12,11 @@ class Cli(Context):
|
|
|
12
12
|
#!/usr/bin/env python
|
|
13
13
|
import clearskies
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
def my_function():
|
|
16
17
|
return "Hello World!"
|
|
17
18
|
|
|
19
|
+
|
|
18
20
|
cli = clearskies.contexts.Cli(my_function)
|
|
19
21
|
cli()
|
|
20
22
|
```
|
|
@@ -32,9 +34,11 @@ class Cli(Context):
|
|
|
32
34
|
#!/usr/bin/env python
|
|
33
35
|
import clearskies
|
|
34
36
|
|
|
37
|
+
|
|
35
38
|
def my_function(name):
|
|
36
39
|
return f"Hello {name}!"
|
|
37
40
|
|
|
41
|
+
|
|
38
42
|
cli = clearskies.contexts.Cli(
|
|
39
43
|
clearskies.endpoints.Callable(
|
|
40
44
|
my_function,
|
|
@@ -59,9 +63,11 @@ class Cli(Context):
|
|
|
59
63
|
#!/usr/bin/env python
|
|
60
64
|
import clearskies
|
|
61
65
|
|
|
66
|
+
|
|
62
67
|
def my_function(name):
|
|
63
68
|
return f"Hello {name}!"
|
|
64
69
|
|
|
70
|
+
|
|
65
71
|
cli = clearskies.contexts.Cli(
|
|
66
72
|
clearskies.endpoints.Callable(
|
|
67
73
|
my_function,
|
|
@@ -87,9 +93,11 @@ class Cli(Context):
|
|
|
87
93
|
#!/usr/bin/env python
|
|
88
94
|
import clearskies
|
|
89
95
|
|
|
96
|
+
|
|
90
97
|
def my_function(request_data):
|
|
91
98
|
return request_data
|
|
92
99
|
|
|
100
|
+
|
|
93
101
|
cli = clearskies.contexts.Cli(
|
|
94
102
|
clearskies.endpoints.Callable(
|
|
95
103
|
my_function,
|
clearskies/contexts/context.py
CHANGED
|
@@ -4,20 +4,19 @@ import datetime
|
|
|
4
4
|
from types import ModuleType
|
|
5
5
|
from typing import TYPE_CHECKING, Any, Callable
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import clearskies.endpoint_group
|
|
7
|
+
from clearskies import exceptions
|
|
9
8
|
from clearskies.di import Di
|
|
10
9
|
from clearskies.di.additional_config import AdditionalConfig
|
|
11
10
|
from clearskies.input_outputs import Programmatic
|
|
12
11
|
|
|
13
12
|
if TYPE_CHECKING:
|
|
13
|
+
from clearskies.endpoint import Endpoint
|
|
14
|
+
from clearskies.endpoint_group import EndpointGroup
|
|
14
15
|
from clearskies.input_outputs import InputOutput
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
class Context:
|
|
18
|
-
"""
|
|
19
|
-
Context: a flexible way to connect applications to hosting strategies.
|
|
20
|
-
"""
|
|
19
|
+
"""Context: a flexible way to connect applications to hosting strategies."""
|
|
21
20
|
|
|
22
21
|
di: Di = None # type: ignore
|
|
23
22
|
|
|
@@ -26,13 +25,13 @@ class Context:
|
|
|
26
25
|
|
|
27
26
|
This can be a callable, an endpoint, or an endpoint group. If passed a callable, the callable can request any
|
|
28
27
|
standard or defined dependencies and should return the desired response. It can also raise any exception from
|
|
29
|
-
|
|
28
|
+
exceptions.
|
|
30
29
|
"""
|
|
31
|
-
application: Callable |
|
|
30
|
+
application: Callable | Endpoint | EndpointGroup = None # type: ignore
|
|
32
31
|
|
|
33
32
|
def __init__(
|
|
34
33
|
self,
|
|
35
|
-
application: Callable |
|
|
34
|
+
application: Callable | Endpoint | EndpointGroup,
|
|
36
35
|
classes: type | list[type] = [],
|
|
37
36
|
modules: ModuleType | list[ModuleType] = [],
|
|
38
37
|
bindings: dict[str, Any] = {},
|
|
@@ -63,17 +62,17 @@ class Context:
|
|
|
63
62
|
return input_output.respond(
|
|
64
63
|
self.di.call_function(self.application, **input_output.get_context_for_callables())
|
|
65
64
|
)
|
|
66
|
-
except
|
|
65
|
+
except exceptions.ClientError as e:
|
|
67
66
|
return input_output.respond(str(e), 400)
|
|
68
|
-
except
|
|
67
|
+
except exceptions.Authentication as e:
|
|
69
68
|
return input_output.respond(str(e), 401)
|
|
70
|
-
except
|
|
69
|
+
except exceptions.Authorization as e:
|
|
71
70
|
return input_output.respond(str(e), 403)
|
|
72
|
-
except
|
|
71
|
+
except exceptions.NotFound as e:
|
|
73
72
|
return input_output.respond(str(e), 404)
|
|
74
|
-
except
|
|
73
|
+
except exceptions.MovedPermanently as e:
|
|
75
74
|
return input_output.respond(str(e), 302)
|
|
76
|
-
except
|
|
75
|
+
except exceptions.MovedTemporarily as e:
|
|
77
76
|
return input_output.respond(str(e), 307)
|
|
78
77
|
|
|
79
78
|
def __call__(
|
clearskies/contexts/wsgi.py
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
from typing import
|
|
4
|
-
|
|
5
|
-
from wsgiref.util import setup_testing_defaults
|
|
6
|
-
|
|
7
|
-
import clearskies.endpoint
|
|
8
|
-
import clearskies.endpoint_group
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
9
5
|
from clearskies.contexts.context import Context
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from clearskies.input_outputs import Wsgi as WsgiInputOutput
|
|
12
9
|
|
|
13
10
|
|
|
14
11
|
class Wsgi(Context):
|
|
@@ -24,11 +21,14 @@ class Wsgi(Context):
|
|
|
24
21
|
```
|
|
25
22
|
import clearskies
|
|
26
23
|
|
|
24
|
+
|
|
27
25
|
def hello_world():
|
|
28
26
|
return "Hello World!"
|
|
29
27
|
|
|
28
|
+
|
|
30
29
|
wsgi = clearskies.contexts.Wsgi(hello_world)
|
|
31
30
|
|
|
31
|
+
|
|
32
32
|
def application(environment, start_response):
|
|
33
33
|
return wsgi(environment, start_response)
|
|
34
34
|
```
|
|
@@ -52,9 +52,11 @@ class Wsgi(Context):
|
|
|
52
52
|
```
|
|
53
53
|
import clearskies
|
|
54
54
|
|
|
55
|
+
|
|
55
56
|
def hello_world():
|
|
56
57
|
return "Hello World!"
|
|
57
58
|
|
|
59
|
+
|
|
58
60
|
def application(environment, start_response):
|
|
59
61
|
wsgi = clearskies.contexts.Wsgi(hello_world)
|
|
60
62
|
return wsgi(environment, start_response)
|
clearskies/contexts/wsgi_ref.py
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import datetime
|
|
2
4
|
from types import ModuleType
|
|
3
|
-
from typing import Any, Callable
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Callable
|
|
4
6
|
from wsgiref.simple_server import make_server
|
|
5
7
|
from wsgiref.util import setup_testing_defaults
|
|
6
8
|
|
|
7
|
-
import clearskies.endpoint
|
|
8
|
-
import clearskies.endpoint_group
|
|
9
9
|
from clearskies.contexts.context import Context
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from clearskies.di import AdditionalConfig
|
|
13
|
+
from clearskies.endpoint import Endpoint
|
|
14
|
+
from clearskies.endpoint_group import EndpointGroup
|
|
15
|
+
from clearskies.input_outputs import Wsgi as WsgiInputOutput
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
class WsgiRef(Context):
|
|
@@ -26,9 +30,11 @@ class WsgiRef(Context):
|
|
|
26
30
|
#!/usr/bin/env python
|
|
27
31
|
import clearskies
|
|
28
32
|
|
|
33
|
+
|
|
29
34
|
def hello_world(name):
|
|
30
35
|
return f"Hello {name}!"
|
|
31
36
|
|
|
37
|
+
|
|
32
38
|
wsgi = clearskies.contexts.WsgiRef(
|
|
33
39
|
clearskies.endpoints.Callable(
|
|
34
40
|
hello_world,
|
|
@@ -49,7 +55,7 @@ class WsgiRef(Context):
|
|
|
49
55
|
|
|
50
56
|
def __init__(
|
|
51
57
|
self,
|
|
52
|
-
application: Callable |
|
|
58
|
+
application: Callable | Endpoint | EndpointGroup,
|
|
53
59
|
port: int = 8080,
|
|
54
60
|
classes: type | list[type] = [],
|
|
55
61
|
modules: ModuleType | list[ModuleType] = [],
|
clearskies/decorators.py
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# decorators.pyi
|
|
2
|
+
from typing import Any, Callable, TypeVar
|
|
3
|
+
|
|
4
|
+
# A TypeVar is used to say "whatever kind of function comes in,
|
|
5
|
+
# the same kind of function goes out."
|
|
6
|
+
_F = TypeVar("_F", bound=Callable[..., Any])
|
|
7
|
+
|
|
8
|
+
# This is the type signature for your decorator.
|
|
9
|
+
# It tells Pylance that it preserves the signature of the function it wraps.
|
|
10
|
+
def parameters_to_properties(wrapped: _F) -> _F: ...
|
clearskies/di/di.py
CHANGED
|
@@ -11,7 +11,6 @@ from requests.adapters import HTTPAdapter
|
|
|
11
11
|
from requests.packages.urllib3.util.retry import Retry # type: ignore
|
|
12
12
|
|
|
13
13
|
import clearskies.input_outputs.input_output
|
|
14
|
-
import clearskies.secrets
|
|
15
14
|
from clearskies.di.additional_config import AdditionalConfig
|
|
16
15
|
from clearskies.di.additional_config_auto_import import AdditionalConfigAutoImport
|
|
17
16
|
from clearskies.environment import Environment
|
|
@@ -350,9 +349,9 @@ class Di:
|
|
|
350
349
|
import my_module
|
|
351
350
|
|
|
352
351
|
di = Di()
|
|
353
|
-
di.add_modules(
|
|
354
|
-
my_module
|
|
355
|
-
|
|
352
|
+
di.add_modules(
|
|
353
|
+
[my_module]
|
|
354
|
+
) # also equivalent: di.add_modules(my_module), or Di(modules=[my_module])
|
|
356
355
|
|
|
357
356
|
|
|
358
357
|
def my_function(my_class):
|
|
@@ -956,6 +955,8 @@ class Di:
|
|
|
956
955
|
return uuid
|
|
957
956
|
|
|
958
957
|
def provide_secrets(self):
|
|
958
|
+
import clearskies.secrets
|
|
959
|
+
|
|
959
960
|
return clearskies.secrets.Secrets()
|
|
960
961
|
|
|
961
962
|
def provide_memory_backend_default_data(self):
|
|
@@ -964,8 +965,8 @@ class Di:
|
|
|
964
965
|
def provide_global_table_prefix(self):
|
|
965
966
|
return ""
|
|
966
967
|
|
|
967
|
-
def
|
|
968
|
-
import akeyless # type: ignore
|
|
968
|
+
def provide_akeyles_sdk(self):
|
|
969
|
+
import akeyless # type: ignore[import-untyped]
|
|
969
970
|
|
|
970
971
|
return akeyless
|
|
971
972
|
|
clearskies/di/inject/by_class.py
CHANGED
clearskies/di/inject/by_name.py
CHANGED
clearskies/di/inject/di.py
CHANGED
clearskies/di/inject/now.py
CHANGED
clearskies/di/inject/requests.py
CHANGED
clearskies/di/inject/secrets.py
CHANGED
clearskies/di/inject/utcnow.py
CHANGED