clear-skies 2.0.0__py3-none-any.whl → 2.0.2__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.

Files changed (78) hide show
  1. {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/METADATA +2 -2
  2. {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/RECORD +78 -77
  3. clearskies/__init__.py +5 -8
  4. clearskies/authentication/authentication.py +4 -0
  5. clearskies/authentication/authorization.py +4 -0
  6. clearskies/authentication/jwks.py +8 -3
  7. clearskies/authentication/secret_bearer.py +3 -3
  8. clearskies/backends/api_backend.py +2 -2
  9. clearskies/backends/backend.py +13 -0
  10. clearskies/backends/secrets_backend.py +0 -1
  11. clearskies/column.py +9 -8
  12. clearskies/columns/audit.py +3 -2
  13. clearskies/columns/belongs_to_id.py +2 -2
  14. clearskies/columns/belongs_to_model.py +6 -2
  15. clearskies/columns/belongs_to_self.py +2 -2
  16. clearskies/columns/boolean.py +6 -2
  17. clearskies/columns/category_tree.py +2 -2
  18. clearskies/columns/category_tree_children.py +2 -2
  19. clearskies/columns/created.py +3 -2
  20. clearskies/columns/created_by_authorization_data.py +2 -2
  21. clearskies/columns/created_by_header.py +2 -2
  22. clearskies/columns/created_by_ip.py +2 -2
  23. clearskies/columns/created_by_routing_data.py +3 -2
  24. clearskies/columns/created_by_user_agent.py +2 -2
  25. clearskies/columns/date.py +6 -2
  26. clearskies/columns/datetime.py +6 -2
  27. clearskies/columns/float.py +6 -2
  28. clearskies/columns/has_many.py +2 -2
  29. clearskies/columns/has_many_self.py +2 -2
  30. clearskies/columns/integer.py +6 -2
  31. clearskies/columns/json.py +6 -2
  32. clearskies/columns/many_to_many_ids.py +6 -2
  33. clearskies/columns/many_to_many_ids_with_data.py +6 -2
  34. clearskies/columns/many_to_many_models.py +6 -2
  35. clearskies/columns/many_to_many_pivots.py +3 -2
  36. clearskies/columns/phone.py +3 -2
  37. clearskies/columns/select.py +3 -2
  38. clearskies/columns/string.py +4 -0
  39. clearskies/columns/timestamp.py +6 -2
  40. clearskies/columns/updated.py +2 -2
  41. clearskies/columns/uuid.py +2 -2
  42. clearskies/configs/__init__.py +4 -1
  43. clearskies/configs/config.py +4 -1
  44. clearskies/configs/endpoint_list.py +28 -0
  45. clearskies/contexts/cli.py +4 -0
  46. clearskies/contexts/context.py +13 -0
  47. clearskies/contexts/wsgi.py +4 -0
  48. clearskies/contexts/wsgi_ref.py +4 -0
  49. clearskies/{parameters_to_properties.py → decorators.py} +2 -0
  50. clearskies/di/di.py +2 -2
  51. clearskies/di/injectable_properties.py +2 -2
  52. clearskies/endpoint.py +7 -6
  53. clearskies/endpoint_group.py +14 -1
  54. clearskies/endpoints/callable.py +5 -4
  55. clearskies/endpoints/create.py +1 -1
  56. clearskies/endpoints/delete.py +1 -1
  57. clearskies/endpoints/get.py +1 -1
  58. clearskies/endpoints/health_check.py +1 -1
  59. clearskies/endpoints/list.py +1 -1
  60. clearskies/endpoints/restful_api.py +2 -2
  61. clearskies/endpoints/simple_search.py +1 -1
  62. clearskies/endpoints/update.py +1 -1
  63. clearskies/model.py +1214 -64
  64. clearskies/query/query.py +4 -4
  65. clearskies/security_header.py +7 -0
  66. clearskies/security_headers/cache_control.py +2 -2
  67. clearskies/security_headers/cors.py +2 -2
  68. clearskies/security_headers/csp.py +2 -2
  69. clearskies/security_headers/hsts.py +2 -2
  70. clearskies/validator.py +12 -0
  71. clearskies/validators/after_column.py +2 -2
  72. clearskies/validators/in_the_future.py +1 -1
  73. clearskies/validators/in_the_past.py +1 -1
  74. clearskies/validators/required.py +0 -1
  75. clearskies/validators/timedelta.py +2 -2
  76. clearskies/validators/unique.py +0 -1
  77. {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/LICENSE +0 -0
  78. {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/WHEEL +0 -0
clearskies/di/di.py CHANGED
@@ -23,7 +23,7 @@ class Di:
23
23
  Build a dependency injection object.
24
24
 
25
25
  The dependency injection (DI) container is a key part of clearskies, so understanding how to both configure
26
- them and get dependencies for your classes is important. Note however that there you don't often have
26
+ them and get dependencies for your classes is important. Note however that you don't often have
27
27
  to interact with the dependency injection container directly. All of the configuration options for
28
28
  the DI container are also available to all the contexts, which is typically how you will build clearskies
29
29
  applications. So, while you can create a DI container and use it directly, typically you'll just follow
@@ -648,7 +648,7 @@ class Di:
648
648
  its name and type-hint.
649
649
  """
650
650
  built_value = self.build_class_from_type_hint(argument_name, type_hint, context=context, cache=True)
651
- if built_value:
651
+ if built_value is not None:
652
652
  return built_value
653
653
  return self.build_from_name(argument_name, context=context, cache=True)
654
654
 
@@ -44,7 +44,7 @@ class InjectableProperties:
44
44
  ```python
45
45
  import clearskies
46
46
  import time
47
- from clearskies import parameters_to_properties
47
+ import clearskies.decorators
48
48
 
49
49
 
50
50
  class MyOtherThing(clearskies.di.InjectableProperties):
@@ -56,7 +56,7 @@ class InjectableProperties:
56
56
  some_number = clearskies.di.inject.ByName("some_number")
57
57
  my_other_thing = clearskies.di.inject.ByClass(MyOtherThing)
58
58
 
59
- @parameters_to_properties
59
+ @clearskies.decorators.parameters_to_properties
60
60
  def __init__(self, my_int: int):
61
61
  self.finalize_and_validate_configuration()
62
62
 
clearskies/endpoint.py CHANGED
@@ -8,9 +8,9 @@ from typing import TYPE_CHECKING, Any, Callable
8
8
  import clearskies.column
9
9
  import clearskies.configs
10
10
  import clearskies.configurable
11
+ import clearskies.decorators
11
12
  import clearskies.di
12
13
  import clearskies.end
13
- import clearskies.parameters_to_properties
14
14
  import clearskies.typing
15
15
  from clearskies import autodoc, exceptions
16
16
  from clearskies.authentication import Authentication, Authorization, Public
@@ -32,15 +32,16 @@ class Endpoint(
32
32
  clearskies.di.InjectableProperties,
33
33
  ):
34
34
  """
35
- Endpoints - the clearskies workhorse.
35
+ Automating drudgery!
36
36
 
37
37
  With clearskies, endpoints exist to offload some drudgery and make your life easier, but they can also
38
38
  get out of your way when you don't need them. Think of them as pre-built endpoints that can execute
39
39
  common functionality needed for web applications/APIs. Instead of defining a function that fetches
40
40
  records from your backend and returns them to the end user, you can let the list endpoint do this for you
41
41
  with a minimal amount of configuration. Instead of making an endpoint that creates records, just deploy
42
- a create endpoint. Each endpoint has their own configuration settings, but there are some configuration
43
- settings that are common to all endpoints, which are listed below:
42
+ a create endpoint. While this gives clearskies some helpful capabiltiies for automation, it also has
43
+ the Callable endpoint which simply calls a developer-defined function, and therefore allows clearskies to
44
+ act like a much more typical framework.
44
45
  """
45
46
 
46
47
  """
@@ -342,7 +343,7 @@ class Endpoint(
342
343
  """
343
344
  The model class used by this endpoint.
344
345
 
345
- The majority of endpoints require a model class that tells the endpoint where to get/save its data.
346
+ The endpoint will use this to fetch/save/validate incoming data as needed.
346
347
  """
347
348
  model_class = clearskies.configs.ModelClass(default=None)
348
349
 
@@ -878,7 +879,7 @@ class Endpoint(
878
879
  _sortable_columns: dict[str, clearskies.column.Column] = None # type: ignore
879
880
  _as_json_map: dict[str, clearskies.column.Column] = None # type: ignore
880
881
 
881
- @clearskies.parameters_to_properties.parameters_to_properties
882
+ @clearskies.decorators.parameters_to_properties
882
883
  def __init__(
883
884
  self,
884
885
  url: str = "",
@@ -217,16 +217,29 @@ class EndpointGroup(
217
217
  The dependency injection container
218
218
  """
219
219
  di = clearskies.di.inject.Di()
220
+
221
+ """
222
+ The base URL for the endpoint group.
223
+
224
+ This URL is added as a prefix to all endpoints attached to the group. This includes any named URL parameters:
225
+ """
220
226
  url = clearskies.configs.String(default="")
227
+
228
+ """
229
+ The list of endpoints connected to this endpoint group
230
+ """
231
+ endpoints = clearskies.configs.EndpointList()
232
+
221
233
  response_headers = clearskies.configs.StringListOrCallable(default=[])
222
234
  authentication = clearskies.configs.Authentication(default=Public())
223
235
  authorization = clearskies.configs.Authorization(default=Authorization())
224
236
  security_headers = clearskies.configs.SecurityHeaders(default=[])
237
+
225
238
  cors_header: SecurityHeader = None # type: ignore
226
239
  has_cors: bool = False
227
240
  endpoints_initialized = False
228
241
 
229
- @clearskies.parameters_to_properties.parameters_to_properties
242
+ @clearskies.decorators.parameters_to_properties
230
243
  def __init__(
231
244
  self,
232
245
  endpoints: list[Endpoint | Self],
@@ -23,13 +23,13 @@ class Callable(Endpoint):
23
23
  """
24
24
  An endpoint that executes a user-defined function.
25
25
 
26
- The Callable endpoint does exactly that - you provide a function that will be called when the endpoin is invoked. Like
27
- all callables invoked by clearskies, you can request any defined depenndency that can be provided by the clearskies
26
+ The Callable endpoint does exactly that - you provide a function that will be called when the endpoint is invoked. Like
27
+ all callables invoked by clearskies, you can request any defined dependency that can be provided by the clearskies
28
28
  framework.
29
29
 
30
30
  Whatever you return will be returned to the client. By default, the return value is sent along in the `data` parameter
31
31
  of the standard clearskies response. To suppress this behavior, set `return_standard_response` to `False`. You can also
32
- return an model instance, a model query, or a list of model instances and the callable endpoint will automatically return
32
+ return a model instance, a model query, or a list of model instances and the callable endpoint will automatically return
33
33
  the columns specified in `readable_column_names` to the client.
34
34
 
35
35
  Here's a basic working example:
@@ -239,7 +239,7 @@ class Callable(Endpoint):
239
239
  """
240
240
  return_records = clearskies.configs.Boolean(default=False)
241
241
 
242
- @clearskies.parameters_to_properties.parameters_to_properties
242
+ @clearskies.decorators.parameters_to_properties
243
243
  def __init__(
244
244
  self,
245
245
  to_call: CallableType,
@@ -300,6 +300,7 @@ class Callable(Endpoint):
300
300
  converted_models,
301
301
  number_results=len(response) if response.backend.can_count else None,
302
302
  next_page=response.next_page_data(),
303
+ limit=response.get_query().limit,
303
304
  )
304
305
 
305
306
  # or did they return a list of models?
@@ -102,7 +102,7 @@ class Create(Endpoint):
102
102
  5. We provided an extra column (`not_a_column`) that wasn't in the list of allowed columns.
103
103
  """
104
104
 
105
- @clearskies.parameters_to_properties.parameters_to_properties
105
+ @clearskies.decorators.parameters_to_properties
106
106
  def __init__(
107
107
  self,
108
108
  model_class: type[Model],
@@ -73,7 +73,7 @@ class Delete(Get):
73
73
  ```
74
74
  """
75
75
 
76
- @clearskies.parameters_to_properties.parameters_to_properties
76
+ @clearskies.decorators.parameters_to_properties
77
77
  def __init__(
78
78
  self,
79
79
  model_class: type[Model],
@@ -159,7 +159,7 @@ class Get(Endpoint):
159
159
  """
160
160
  record_lookup_column_name = clearskies.configs.ReadableModelColumn("model_class", default=None)
161
161
 
162
- @clearskies.parameters_to_properties.parameters_to_properties
162
+ @clearskies.decorators.parameters_to_properties
163
163
  def __init__(
164
164
  self,
165
165
  model_class: type[Model],
@@ -130,7 +130,7 @@ class HealthCheck(Endpoint):
130
130
  """
131
131
  callables = clearskies.configs.Any(default=[])
132
132
 
133
- @clearskies.parameters_to_properties.parameters_to_properties
133
+ @clearskies.decorators.parameters_to_properties
134
134
  def __init__(
135
135
  self,
136
136
  dependency_injection_names: list[str] = [],
@@ -182,7 +182,7 @@ class List(Endpoint):
182
182
  "model_class", allow_relationship_references=True
183
183
  )
184
184
 
185
- @clearskies.parameters_to_properties.parameters_to_properties
185
+ @clearskies.decorators.parameters_to_properties
186
186
  def __init__(
187
187
  self,
188
188
  model_class: type[Model],
@@ -5,8 +5,8 @@ from collections import OrderedDict
5
5
  from typing import TYPE_CHECKING, Any, Callable
6
6
 
7
7
  import clearskies.configs
8
+ import clearskies.decorators
8
9
  import clearskies.exceptions
9
- import clearskies.parameters_to_properties
10
10
  from clearskies import authentication, autodoc, typing
11
11
  from clearskies.authentication import Authentication, Authorization, Public
12
12
  from clearskies.endpoint import Endpoint
@@ -293,7 +293,7 @@ class RestfulApi(EndpointGroup):
293
293
  where = clearskies.configs.Conditions(default=[])
294
294
  _descriptor_config_map = None
295
295
 
296
- @clearskies.parameters_to_properties.parameters_to_properties
296
+ @clearskies.decorators.parameters_to_properties
297
297
  def __init__(
298
298
  self,
299
299
  model_class: type[Model],
@@ -194,7 +194,7 @@ class SimpleSearch(List):
194
194
  ```
195
195
  """
196
196
 
197
- @clearskies.parameters_to_properties.parameters_to_properties
197
+ @clearskies.decorators.parameters_to_properties
198
198
  def __init__(
199
199
  self,
200
200
  model_class: type[Model],
@@ -90,7 +90,7 @@ class Update(Get):
90
90
  }
91
91
  """
92
92
 
93
- @clearskies.parameters_to_properties.parameters_to_properties
93
+ @clearskies.decorators.parameters_to_properties
94
94
  def __init__(
95
95
  self,
96
96
  model_class: type[Model],