wellapi 0.4.0__tar.gz → 0.4.2__tar.gz

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.
Files changed (40) hide show
  1. {wellapi-0.4.0 → wellapi-0.4.2}/PKG-INFO +1 -1
  2. {wellapi-0.4.0 → wellapi-0.4.2}/pyproject.toml +1 -1
  3. wellapi-0.4.2/src/wellapi/awsmodel.py +74 -0
  4. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/local/router.py +1 -1
  5. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/local/server.py +28 -0
  6. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/models.py +9 -18
  7. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/utils.py +3 -0
  8. {wellapi-0.4.0 → wellapi-0.4.2}/uv.lock +1 -1
  9. {wellapi-0.4.0 → wellapi-0.4.2}/.github/workflows/build.pipeline.yml +0 -0
  10. {wellapi-0.4.0 → wellapi-0.4.2}/.gitignore +0 -0
  11. {wellapi-0.4.0 → wellapi-0.4.2}/.python-version +0 -0
  12. {wellapi-0.4.0 → wellapi-0.4.2}/README.md +0 -0
  13. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/__init__.py +0 -0
  14. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/__main__.py +0 -0
  15. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/applications.py +0 -0
  16. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/build/__init__.py +0 -0
  17. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/build/cdk.py +0 -0
  18. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/build/packager.py +0 -0
  19. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/cli/__init__.py +0 -0
  20. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/cli/main.py +0 -0
  21. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/convertors.py +0 -0
  22. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/datastructures.py +0 -0
  23. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/dependencies/__init__.py +0 -0
  24. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/dependencies/models.py +0 -0
  25. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/dependencies/utils.py +0 -0
  26. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/exceptions.py +0 -0
  27. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/local/__init__.py +0 -0
  28. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/local/reloader.py +0 -0
  29. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/middleware/__init__.py +0 -0
  30. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/middleware/base.py +0 -0
  31. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/middleware/error.py +0 -0
  32. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/middleware/exceptions.py +0 -0
  33. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/middleware/main.py +0 -0
  34. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/openapi/__init__.py +0 -0
  35. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/openapi/docs.py +0 -0
  36. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/openapi/models.py +0 -0
  37. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/openapi/utils.py +0 -0
  38. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/params.py +0 -0
  39. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/routing.py +0 -0
  40. {wellapi-0.4.0 → wellapi-0.4.2}/src/wellapi/security.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wellapi
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: A simple web framework for aws lambda
5
5
  Author-email: romayuhym <romayuhym@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "wellapi"
3
- version = "0.4.0"
3
+ version = "0.4.2"
4
4
  description = "A simple web framework for aws lambda"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -0,0 +1,74 @@
1
+ from pydantic import BaseModel, Field
2
+
3
+
4
+ class RequestContext(BaseModel):
5
+ accountId: str
6
+ apiId: str
7
+ authorizer: dict = None
8
+ domainName: str
9
+ domainPrefix: str
10
+ extendedRequestId: str
11
+ httpMethod: str
12
+ identity: dict
13
+ path: str
14
+ protocol: str
15
+ requestId: str
16
+ requestTime: str
17
+ requestTimeEpoch: int
18
+ resourceId: str
19
+ resourcePath: str
20
+ stage: str
21
+
22
+
23
+ class ApiGatewayEvent(BaseModel):
24
+ """
25
+ https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.proxy-format
26
+ """
27
+ version: str = "1.0"
28
+ resource: str
29
+ path: str
30
+ httpMethod: str
31
+ headers: dict
32
+ multiValueHeaders: dict
33
+ queryStringParameters: dict | None
34
+ multiValueQueryStringParameters: dict | None
35
+ requestContext: RequestContext
36
+ pathParameters: dict | None
37
+ stageVariables: dict | None
38
+ body: str | None
39
+ isBase64Encoded: bool
40
+
41
+
42
+
43
+ class Message(BaseModel):
44
+ messageId: str
45
+ receiptHandle: str
46
+ body: str
47
+ attributes: dict
48
+ messageAttributes: dict
49
+ md5OfBody: str
50
+ eventSource: str
51
+ eventSourceARN: str
52
+ awsRegion: str
53
+
54
+
55
+ class SQSEvent(BaseModel):
56
+ """
57
+ https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-example.html#with-sqs-create-test-function
58
+ """
59
+ Records: list[Message]
60
+
61
+
62
+ class JobEvent(BaseModel):
63
+ """
64
+ https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-run-lambda-schedule.html#eb-schedule-create-rule
65
+ """
66
+ version: str
67
+ id: str
68
+ detail_type: str = Field(alias="detail-type")
69
+ source: str
70
+ account: str
71
+ time: str
72
+ region: str
73
+ resources: list[str]
74
+ detail: dict
@@ -59,7 +59,7 @@ class Route:
59
59
  matched_params = match.groupdict()
60
60
  for key, value in matched_params.items():
61
61
  matched_params[key] = self.param_convertors[key].convert(value)
62
- path_params = dict(scope.get("pathParameters", {}))
62
+ path_params = dict(scope.get("pathParameters", {}) or {})
63
63
  path_params.update(matched_params)
64
64
  child_scope = {"pathParameters": path_params}
65
65
 
@@ -98,10 +98,36 @@ def get_request_handler(router: Router):
98
98
  headers.setdefault(key, []).append(value)
99
99
 
100
100
  event = {
101
+ "version": "1.0",
102
+ "resource": "/my/path",
101
103
  "httpMethod": method,
102
104
  "path": path,
103
105
  "multiValueHeaders": headers,
104
106
  "body": body,
107
+ "headers": {},
108
+ "queryStringParameters": {},
109
+ "requestContext": {
110
+ 'resourceId': 'zdo27u',
111
+ 'resourcePath': path,
112
+ 'operationName': 'main.hello',
113
+ 'httpMethod': method,
114
+ 'extendedRequestId': 'J449EG3OliAEceQ=',
115
+ 'requestTime': '01/May/2025:12:53:13 +0000',
116
+ 'path': '/prod/hello',
117
+ 'accountId': '125905311728',
118
+ 'protocol': 'HTTP/1.1',
119
+ 'stage': 'prod',
120
+ 'domainPrefix': 'pxeuu259g4',
121
+ 'requestTimeEpoch': 1746103993615,
122
+ 'requestId': '00cc795f-6b70-4f4d-9d7f-1800b9af134e',
123
+ 'identity': {},
124
+ 'domainName': 'pxeuu259g4.execute-api.eu-central-1.amazonaws.com',
125
+ 'deploymentId': 'q4efka',
126
+ 'apiId': 'pxeuu259g4'
127
+ },
128
+ "pathParameters": None,
129
+ "stageVariables": None,
130
+ "isBase64Encoded": False,
105
131
  }
106
132
 
107
133
  # Парсимо query параметри
@@ -113,6 +139,8 @@ def get_request_handler(router: Router):
113
139
  key, value = param.split("=")
114
140
  query_params.setdefault(key, []).append(value)
115
141
  event["multiValueQueryStringParameters"] = query_params
142
+ else:
143
+ event["multiValueQueryStringParameters"] = {}
116
144
 
117
145
  return event
118
146
 
@@ -1,15 +1,13 @@
1
1
  import json
2
2
  import typing
3
3
 
4
+ from wellapi.awsmodel import JobEvent, SQSEvent, ApiGatewayEvent
4
5
  from wellapi.datastructures import Headers, MutableHeaders, QueryParams
5
6
 
6
7
 
7
8
  class RequestAPIGateway:
8
- """
9
- https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.proxy-format
10
- """
11
-
12
- def __init__(self, path_params, query_params, headers, body, cookies):
9
+ def __init__(self, path_params, query_params, headers, body, cookies, raw_event: dict[str, typing.Any]):
10
+ self.raw_event = ApiGatewayEvent(**raw_event)
13
11
  self.path_params = path_params
14
12
  self.query_params = QueryParams(query_params)
15
13
  self.headers = Headers(raw=headers)
@@ -56,7 +54,7 @@ class RequestAPIGateway:
56
54
  else:
57
55
  query_params.append((q_name, q_value))
58
56
 
59
- return cls(path_params, query_params, headers, body, cookies)
57
+ return cls(path_params, query_params, headers, body, cookies, raw_event=event)
60
58
 
61
59
 
62
60
  class ResponseAPIGateway:
@@ -93,11 +91,8 @@ class ResponseAPIGateway:
93
91
 
94
92
 
95
93
  class RequestSQS:
96
- """
97
- https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-example.html#with-sqs-create-test-function
98
- """
99
-
100
- def __init__(self, records: list[dict[str, typing.Any]]):
94
+ def __init__(self, records: list[dict[str, typing.Any]], raw_event: dict[str, typing.Any]):
95
+ self.raw_event = SQSEvent(**raw_event)
101
96
  self._records = records
102
97
  self.path_params = None
103
98
  self.query_params = None
@@ -110,7 +105,7 @@ class RequestSQS:
110
105
  Create a RequestAPIGateway object from the AWS API Gateway event.
111
106
  """
112
107
 
113
- return cls(event["Records"])
108
+ return cls(event["Records"], raw_event=event)
114
109
 
115
110
  def json(self):
116
111
  """
@@ -127,12 +122,8 @@ class RequestSQS:
127
122
 
128
123
 
129
124
  class RequestJob:
130
- """
131
- https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-run-lambda-schedule.html#eb-schedule-create-rule
132
- """
133
-
134
- def __init__(self, event: dict[str, typing.Any]):
135
- self._event = event
125
+ def __init__(self, raw_event: dict[str, typing.Any]):
126
+ self.raw_event = JobEvent(**raw_event)
136
127
  self.path_params = None
137
128
  self.query_params = None
138
129
  self.headers = None
@@ -30,6 +30,9 @@ def load_handlers(handlers_dir: str):
30
30
 
31
31
  # Імпортуємо всі Python файли з директорії
32
32
  for file_path in handlers_path.glob("*.py"):
33
+ if file_path.stem == "__init__":
34
+ continue
35
+
33
36
  module_name = f"{handlers_module}.{file_path.stem}"
34
37
  try:
35
38
  importlib.import_module(module_name)
@@ -328,7 +328,7 @@ wheels = [
328
328
 
329
329
  [[package]]
330
330
  name = "wellapi"
331
- version = "0.4.0"
331
+ version = "0.4.2"
332
332
  source = { editable = "." }
333
333
  dependencies = [
334
334
  { name = "email-validator" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes