api-foundry-query-engine 0.8.62__tar.gz → 0.8.63__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.
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/PKG-INFO +1 -1
- api_foundry_query_engine-0.8.63/api_foundry_query_engine/__init__.py +1 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/adapters/gateway_adapter.py +1 -3
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/sql_insert_query_handler.py +20 -23
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/sql_query_handler.py +31 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/sql_update_query_handler.py +19 -25
- api_foundry_query_engine-0.8.62/api_foundry_query_engine/__init__.py +0 -1
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/.gitignore +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/LICENSE +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/.pre-commit-config.yaml +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/adapters/adapter.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/adapters/case_change_adapter.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/adapters/security_adapter.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/connectors/connection.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/connectors/connection_factory.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/connectors/oracle_connector.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/connectors/postgres_connection.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/batch_operation_handler.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/dao.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/operation_dao.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/sql_custom_query_handler.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/sql_delete_query_handler.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/sql_restore_query_handler.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/sql_select_query_handler.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/dao/sql_subselect_query_handler.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/lambda_handler.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/operation.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/services/service.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/services/transactional_service.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/utils/api_model.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/utils/app_exception.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/utils/claims_check.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/utils/dependency_resolver.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/utils/logger.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/utils/reference_resolver.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/api_foundry_query_engine/utils/token_decoder.py +0 -0
- {api_foundry_query_engine-0.8.62 → api_foundry_query_engine-0.8.63}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: api-foundry-query-engine
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.63
|
|
4
4
|
Summary: The AWS lambda service handler use by the `api_foundry` project is a powerful tool designed to automate the deployment of REST APIs on AWS using Lambda services to access and interact with relational databases (RDBMS). This project leverages the OpenAPI specification to define and manage the APIs
|
|
5
5
|
Project-URL: Documentation, https://github.com/DanRepik/api-foundry
|
|
6
6
|
Project-URL: Source, https://github.com/DanRepik/api-foundry
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.8.63"
|
|
@@ -43,9 +43,7 @@ class GatewayAdapter(Adapter):
|
|
|
43
43
|
parts = [p for p in resource.split("/") if p]
|
|
44
44
|
# Skip common API prefixes like "api", "v1", "v2", etc.
|
|
45
45
|
api_prefixes = {"api", "v1", "v2", "v3"}
|
|
46
|
-
literal_parts = [
|
|
47
|
-
p for p in parts if p not in api_prefixes and not p.startswith("{")
|
|
48
|
-
]
|
|
46
|
+
literal_parts = [p for p in parts if p not in api_prefixes and not p.startswith("{")]
|
|
49
47
|
entity = "_".join(literal_parts) if literal_parts else None
|
|
50
48
|
else:
|
|
51
49
|
entity = None
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from typing import Dict, Optional
|
|
2
3
|
from api_foundry_query_engine.dao.sql_query_handler import SQLSchemaQueryHandler
|
|
3
4
|
from api_foundry_query_engine.operation import Operation
|
|
@@ -128,15 +129,15 @@ class SQLInsertSchemaQueryHandler(SQLSchemaQueryHandler):
|
|
|
128
129
|
}
|
|
129
130
|
log.info("allowed properties: %s", allowed_properties)
|
|
130
131
|
|
|
131
|
-
import json
|
|
132
|
-
|
|
133
|
-
# First, validate that user is not trying to set injected properties
|
|
134
132
|
for property_name, property in self.schema_object.properties.items():
|
|
135
|
-
|
|
133
|
+
inject_value = getattr(property, "inject_value", None)
|
|
134
|
+
inject_on = getattr(property, "inject_on", None) or []
|
|
135
|
+
if not inject_value or "create" not in inject_on:
|
|
136
|
+
continue
|
|
137
|
+
if property_name in self.operation.store_params:
|
|
136
138
|
raise ApplicationException(
|
|
137
139
|
403,
|
|
138
|
-
f"Property '{property_name}' is auto-injected and "
|
|
139
|
-
+ "cannot be set manually",
|
|
140
|
+
f"Property '{property_name}' is auto-injected and cannot be set manually",
|
|
140
141
|
)
|
|
141
142
|
|
|
142
143
|
for name, value in self.operation.store_params.items():
|
|
@@ -172,24 +173,20 @@ class SQLInsertSchemaQueryHandler(SQLSchemaQueryHandler):
|
|
|
172
173
|
property.api_name
|
|
173
174
|
] = property.convert_to_db_value(value)
|
|
174
175
|
|
|
175
|
-
# Inject values from claims/timestamps/etc for properties with
|
|
176
|
-
# x-af-inject-value on CREATE
|
|
177
176
|
for property_name, property in self.schema_object.properties.items():
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
+ f"could not be populated from '{property.inject_value}'",
|
|
192
|
-
)
|
|
177
|
+
inject_value = getattr(property, "inject_value", None)
|
|
178
|
+
inject_on = getattr(property, "inject_on", None) or []
|
|
179
|
+
if not inject_value or "create" not in inject_on:
|
|
180
|
+
continue
|
|
181
|
+
if property_name in self.store_placeholders:
|
|
182
|
+
continue
|
|
183
|
+
|
|
184
|
+
injected_value = self.extract_injected_value(property)
|
|
185
|
+
columns.append(property.column_name)
|
|
186
|
+
placeholders.append(self.placeholder(property, property.api_name))
|
|
187
|
+
self.store_placeholders[property.api_name] = property.convert_to_db_value(
|
|
188
|
+
injected_value
|
|
189
|
+
)
|
|
193
190
|
|
|
194
191
|
if self.key_property:
|
|
195
192
|
if self.key_property.key_type == "sequence":
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import re
|
|
2
|
+
import os
|
|
3
|
+
import uuid
|
|
2
4
|
from typing import Optional, List, Dict
|
|
3
5
|
from datetime import datetime, date
|
|
4
6
|
|
|
@@ -340,6 +342,35 @@ class SQLQueryHandler:
|
|
|
340
342
|
def selection_results(self) -> Dict:
|
|
341
343
|
raise NotImplementedError()
|
|
342
344
|
|
|
345
|
+
def extract_injected_value(
|
|
346
|
+
self, property: SchemaObjectProperty
|
|
347
|
+
) -> Optional[object]:
|
|
348
|
+
inject_value = getattr(property, "inject_value", None)
|
|
349
|
+
if not inject_value:
|
|
350
|
+
return None
|
|
351
|
+
|
|
352
|
+
if inject_value.startswith("claim:"):
|
|
353
|
+
claim_name = inject_value.split(":", 1)[1]
|
|
354
|
+
return self.operation.claims.get(claim_name)
|
|
355
|
+
|
|
356
|
+
if inject_value == "timestamp":
|
|
357
|
+
return datetime.utcnow().isoformat()
|
|
358
|
+
|
|
359
|
+
if inject_value == "date":
|
|
360
|
+
return date.today().isoformat()
|
|
361
|
+
|
|
362
|
+
if inject_value == "uuid":
|
|
363
|
+
return str(uuid.uuid4())
|
|
364
|
+
|
|
365
|
+
if inject_value.startswith("env:"):
|
|
366
|
+
env_name = inject_value.split(":", 1)[1]
|
|
367
|
+
return os.getenv(env_name)
|
|
368
|
+
|
|
369
|
+
raise ApplicationException(
|
|
370
|
+
500,
|
|
371
|
+
f"Unsupported inject_value source '{inject_value}' for property '{property.api_name}'",
|
|
372
|
+
)
|
|
373
|
+
|
|
343
374
|
def generate_sql_condition(
|
|
344
375
|
self, property: SchemaObjectProperty, value, prefix: Optional[str] = None
|
|
345
376
|
) -> str:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import re
|
|
2
3
|
from typing import Match
|
|
3
4
|
from api_foundry_query_engine.dao.sql_query_handler import SQLSchemaQueryHandler
|
|
@@ -115,15 +116,15 @@ class SQLUpdateSchemaQueryHandler(SQLSchemaQueryHandler):
|
|
|
115
116
|
columns = []
|
|
116
117
|
invalid_columns = []
|
|
117
118
|
|
|
118
|
-
import json
|
|
119
|
-
|
|
120
|
-
# First, validate that user is not trying to set injected properties
|
|
121
119
|
for property_name, property in self.schema_object.properties.items():
|
|
122
|
-
|
|
120
|
+
inject_value = getattr(property, "inject_value", None)
|
|
121
|
+
inject_on = getattr(property, "inject_on", None) or []
|
|
122
|
+
if not inject_value:
|
|
123
|
+
continue
|
|
124
|
+
if property_name in self.operation.store_params:
|
|
123
125
|
raise ApplicationException(
|
|
124
126
|
403,
|
|
125
|
-
f"Property '{property_name}' is auto-injected and "
|
|
126
|
-
+ "cannot be set manually",
|
|
127
|
+
f"Property '{property_name}' is auto-injected and cannot be set manually",
|
|
127
128
|
)
|
|
128
129
|
|
|
129
130
|
for name, value in self.operation.store_params.items():
|
|
@@ -146,26 +147,19 @@ class SQLUpdateSchemaQueryHandler(SQLSchemaQueryHandler):
|
|
|
146
147
|
value
|
|
147
148
|
)
|
|
148
149
|
|
|
149
|
-
# Inject values from claims/timestamps/etc for properties with
|
|
150
|
-
# x-af-inject-value on UPDATE
|
|
151
150
|
for property_name, property in self.schema_object.properties.items():
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
raise ApplicationException(
|
|
165
|
-
400,
|
|
166
|
-
f"Required injected property '{property_name}' "
|
|
167
|
-
+ f"could not be populated from '{property.inject_value}'",
|
|
168
|
-
)
|
|
151
|
+
inject_value = getattr(property, "inject_value", None)
|
|
152
|
+
inject_on = getattr(property, "inject_on", None) or []
|
|
153
|
+
if not inject_value or "update" not in inject_on:
|
|
154
|
+
continue
|
|
155
|
+
|
|
156
|
+
placeholder = (
|
|
157
|
+
str(property.api_name) if property.api_name is not None else property_name
|
|
158
|
+
)
|
|
159
|
+
columns.append(f"{property.column_name} = {self.placeholder(property, placeholder)}")
|
|
160
|
+
self.store_placeholders[placeholder] = property.convert_to_db_value(
|
|
161
|
+
self.extract_injected_value(property)
|
|
162
|
+
)
|
|
169
163
|
|
|
170
164
|
if invalid_columns:
|
|
171
165
|
raise ApplicationException(
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.8.62"
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|