worqhat 3.10.0__py3-none-any.whl → 4.2.0__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.
Files changed (92) hide show
  1. worqhat/__init__.py +8 -89
  2. worqhat/client.py +62 -0
  3. worqhat/exceptions.py +43 -0
  4. worqhat/http_client.py +171 -0
  5. worqhat/py.typed +1 -0
  6. worqhat/resources/__init__.py +5 -59
  7. worqhat/resources/database.py +293 -0
  8. worqhat/resources/flows.py +61 -409
  9. worqhat/resources/storage.py +41 -431
  10. worqhat-4.2.0.dist-info/METADATA +538 -0
  11. worqhat-4.2.0.dist-info/RECORD +13 -0
  12. {worqhat-3.10.0.dist-info → worqhat-4.2.0.dist-info}/WHEEL +2 -1
  13. worqhat-4.2.0.dist-info/top_level.txt +1 -0
  14. worqhat/_base_client.py +0 -1995
  15. worqhat/_client.py +0 -484
  16. worqhat/_compat.py +0 -219
  17. worqhat/_constants.py +0 -14
  18. worqhat/_exceptions.py +0 -108
  19. worqhat/_files.py +0 -123
  20. worqhat/_models.py +0 -835
  21. worqhat/_qs.py +0 -150
  22. worqhat/_resource.py +0 -43
  23. worqhat/_response.py +0 -830
  24. worqhat/_streaming.py +0 -333
  25. worqhat/_types.py +0 -260
  26. worqhat/_utils/__init__.py +0 -64
  27. worqhat/_utils/_compat.py +0 -45
  28. worqhat/_utils/_datetime_parse.py +0 -136
  29. worqhat/_utils/_logs.py +0 -25
  30. worqhat/_utils/_proxy.py +0 -65
  31. worqhat/_utils/_reflection.py +0 -42
  32. worqhat/_utils/_resources_proxy.py +0 -24
  33. worqhat/_utils/_streams.py +0 -12
  34. worqhat/_utils/_sync.py +0 -86
  35. worqhat/_utils/_transform.py +0 -457
  36. worqhat/_utils/_typing.py +0 -156
  37. worqhat/_utils/_utils.py +0 -421
  38. worqhat/_version.py +0 -4
  39. worqhat/lib/.keep +0 -4
  40. worqhat/resources/db/__init__.py +0 -33
  41. worqhat/resources/db/db.py +0 -1650
  42. worqhat/resources/db/tables.py +0 -389
  43. worqhat/resources/health.py +0 -143
  44. worqhat/types/__init__.py +0 -44
  45. worqhat/types/db/__init__.py +0 -10
  46. worqhat/types/db/table_get_row_count_params.py +0 -12
  47. worqhat/types/db/table_get_row_count_response.py +0 -15
  48. worqhat/types/db/table_list_params.py +0 -15
  49. worqhat/types/db/table_list_response.py +0 -26
  50. worqhat/types/db/table_retrieve_schema_params.py +0 -12
  51. worqhat/types/db/table_retrieve_schema_response.py +0 -29
  52. worqhat/types/db_cluster_params.py +0 -27
  53. worqhat/types/db_cluster_response.py +0 -44
  54. worqhat/types/db_delete_records_params.py +0 -19
  55. worqhat/types/db_delete_records_response.py +0 -18
  56. worqhat/types/db_detect_anomalies_params.py +0 -24
  57. worqhat/types/db_detect_anomalies_response.py +0 -50
  58. worqhat/types/db_execute_batch_params.py +0 -36
  59. worqhat/types/db_execute_batch_response.py +0 -27
  60. worqhat/types/db_execute_query_params.py +0 -24
  61. worqhat/types/db_execute_query_response.py +0 -21
  62. worqhat/types/db_find_similar_params.py +0 -31
  63. worqhat/types/db_find_similar_response.py +0 -30
  64. worqhat/types/db_hybrid_search_params.py +0 -32
  65. worqhat/types/db_hybrid_search_response.py +0 -48
  66. worqhat/types/db_insert_record_params.py +0 -19
  67. worqhat/types/db_insert_record_response.py +0 -15
  68. worqhat/types/db_process_nl_query_params.py +0 -19
  69. worqhat/types/db_process_nl_query_response.py +0 -18
  70. worqhat/types/db_recommend_params.py +0 -33
  71. worqhat/types/db_recommend_response.py +0 -36
  72. worqhat/types/db_semantic_search_params.py +0 -33
  73. worqhat/types/db_semantic_search_response.py +0 -36
  74. worqhat/types/db_update_records_params.py +0 -22
  75. worqhat/types/db_update_records_response.py +0 -18
  76. worqhat/types/flow_get_metrics_params.py +0 -25
  77. worqhat/types/flow_get_metrics_response.py +0 -55
  78. worqhat/types/flow_trigger_with_file_params.py +0 -17
  79. worqhat/types/flow_trigger_with_file_response.py +0 -18
  80. worqhat/types/flow_trigger_with_payload_params.py +0 -13
  81. worqhat/types/flow_trigger_with_payload_response.py +0 -20
  82. worqhat/types/get_server_info_response.py +0 -15
  83. worqhat/types/health_check_response.py +0 -33
  84. worqhat/types/storage_delete_file_by_id_response.py +0 -18
  85. worqhat/types/storage_retrieve_file_by_id_response.py +0 -33
  86. worqhat/types/storage_retrieve_file_by_path_params.py +0 -12
  87. worqhat/types/storage_retrieve_file_by_path_response.py +0 -33
  88. worqhat/types/storage_upload_file_params.py +0 -17
  89. worqhat/types/storage_upload_file_response.py +0 -33
  90. worqhat-3.10.0.dist-info/METADATA +0 -432
  91. worqhat-3.10.0.dist-info/RECORD +0 -85
  92. worqhat-3.10.0.dist-info/licenses/LICENSE +0 -201
@@ -0,0 +1,293 @@
1
+ """Database resource for Worqhat SDK."""
2
+
3
+ from typing import TYPE_CHECKING, Optional, Dict, Any, List, Union
4
+
5
+ if TYPE_CHECKING:
6
+ from ..http_client import HTTPClient
7
+
8
+
9
+ class DatabaseResource:
10
+ """Database operations resource."""
11
+
12
+ def __init__(self, client: "HTTPClient"):
13
+ """Initialize the database resource."""
14
+ self._client = client
15
+
16
+ def execute_query(
17
+ self,
18
+ query: str,
19
+ params: Optional[Union[Dict[str, Any], List[Any]]] = None,
20
+ environment: str = "production",
21
+ ) -> Dict[str, Any]:
22
+ """
23
+ Execute a raw SQL query with named or positional parameters.
24
+
25
+ Args:
26
+ query: SQL query string.
27
+ params: Named (dict) or positional (list) parameters.
28
+ environment: Database environment (default: 'production').
29
+
30
+ Returns:
31
+ Query response with data and execution time.
32
+ """
33
+ payload: Dict[str, Any] = {"query": query}
34
+ if params:
35
+ payload["params"] = params
36
+ if environment:
37
+ payload["environment"] = environment
38
+
39
+ return self._client.post("/api/db/query", json=payload)
40
+
41
+ def query(
42
+ self,
43
+ query: str,
44
+ params: Optional[Union[Dict[str, Any], List[Any]]] = None,
45
+ environment: str = "production",
46
+ ) -> Dict[str, Any]:
47
+ """Alias for execute_query."""
48
+ return self.execute_query(query, params, environment)
49
+
50
+ def insert(
51
+ self,
52
+ table: str,
53
+ data: Union[Dict[str, Any], List[Dict[str, Any]]],
54
+ environment: str = "production",
55
+ ) -> Dict[str, Any]:
56
+ """
57
+ Insert data into a table.
58
+
59
+ Args:
60
+ table: Table name.
61
+ data: Single record (dict) or multiple records (list of dicts).
62
+ environment: Database environment.
63
+
64
+ Returns:
65
+ Insert response with inserted data.
66
+ """
67
+ payload = {"table": table, "data": data, "environment": environment}
68
+ return self._client.post("/api/db/insert", json=payload)
69
+
70
+ def update(
71
+ self,
72
+ table: str,
73
+ data: Dict[str, Any],
74
+ where: Dict[str, Any],
75
+ environment: str = "production",
76
+ ) -> Dict[str, Any]:
77
+ """
78
+ Update data in a table.
79
+
80
+ Args:
81
+ table: Table name.
82
+ data: Fields to update.
83
+ where: WHERE conditions.
84
+ environment: Database environment.
85
+
86
+ Returns:
87
+ Update response with updated records.
88
+ """
89
+ payload = {"table": table, "data": data, "where": where, "environment": environment}
90
+ return self._client.put("/api/db/update", json=payload)
91
+
92
+ def delete(
93
+ self, table: str, where: Dict[str, Any], environment: str = "production"
94
+ ) -> Dict[str, Any]:
95
+ """
96
+ Delete data from a table.
97
+
98
+ Args:
99
+ table: Table name.
100
+ where: WHERE conditions.
101
+ environment: Database environment.
102
+
103
+ Returns:
104
+ Delete response with deleted records.
105
+ """
106
+ payload = {"table": table, "where": where, "environment": environment}
107
+ return self._client.delete("/api/db/delete", json=payload)
108
+
109
+ def list_tables(
110
+ self, environment: str = "production", schema: str = "public"
111
+ ) -> Dict[str, Any]:
112
+ """
113
+ List all available tables in a schema.
114
+
115
+ Args:
116
+ environment: Database environment.
117
+ schema: Schema name.
118
+
119
+ Returns:
120
+ List of tables.
121
+ """
122
+ params = {"environment": environment, "schema": schema}
123
+ return self._client.get("/api/db/tables", params=params)
124
+
125
+ def get_table_schema(
126
+ self, table_name: str, environment: str = "production"
127
+ ) -> Dict[str, Any]:
128
+ """
129
+ Get detailed schema information for a table.
130
+
131
+ Args:
132
+ table_name: Table name.
133
+ environment: Database environment.
134
+
135
+ Returns:
136
+ Table schema with columns, indexes, and constraints.
137
+ """
138
+ params = {"environment": environment}
139
+ return self._client.get(f"/api/db/tables/{table_name}/schema", params=params)
140
+
141
+ def get_table_count(
142
+ self,
143
+ table_name: str,
144
+ filters: Optional[Dict[str, Any]] = None,
145
+ environment: str = "production",
146
+ ) -> Dict[str, Any]:
147
+ """
148
+ Get row count for a table with optional filters.
149
+
150
+ Args:
151
+ table_name: Table name.
152
+ filters: Optional WHERE conditions.
153
+ environment: Database environment.
154
+
155
+ Returns:
156
+ Count response.
157
+ """
158
+ params: Dict[str, Any] = {"environment": environment}
159
+ if filters:
160
+ params.update(filters)
161
+
162
+ return self._client.get(f"/api/db/tables/{table_name}/count", params=params)
163
+
164
+ def batch(
165
+ self,
166
+ operations: List[Dict[str, Any]],
167
+ environment: str = "production",
168
+ transactional: bool = True,
169
+ ) -> Dict[str, Any]:
170
+ """
171
+ Execute multiple operations in a single transaction.
172
+
173
+ Args:
174
+ operations: List of operations to execute.
175
+ environment: Database environment.
176
+ transactional: Whether to use a transaction.
177
+
178
+ Returns:
179
+ Batch response with results for each operation.
180
+ """
181
+ payload = {
182
+ "operations": operations,
183
+ "environment": environment,
184
+ "transactional": transactional,
185
+ }
186
+ return self._client.post("/api/db/batch", json=payload)
187
+
188
+ def semantic_search(
189
+ self,
190
+ query: str,
191
+ table: Optional[str] = None,
192
+ tables: Optional[List[str]] = None,
193
+ limit: int = 10,
194
+ threshold: float = 0.7,
195
+ filters: Optional[Dict[str, Any]] = None,
196
+ ) -> Dict[str, Any]:
197
+ """
198
+ Perform semantic similarity search using vector embeddings.
199
+
200
+ Args:
201
+ query: Search query.
202
+ table: Single table name (mutually exclusive with tables).
203
+ tables: Multiple table names for cross-table search.
204
+ limit: Maximum number of results.
205
+ threshold: Minimum similarity score.
206
+ filters: Additional WHERE clause filters.
207
+
208
+ Returns:
209
+ Search results with similarity scores.
210
+ """
211
+ payload: Dict[str, Any] = {"query": query, "limit": limit, "threshold": threshold}
212
+
213
+ if table:
214
+ payload["table"] = table
215
+ if tables:
216
+ payload["tables"] = tables
217
+ if filters:
218
+ payload["filters"] = filters
219
+
220
+ return self._client.post("/api/db/semantic-search", json=payload)
221
+
222
+ def hybrid_search(
223
+ self,
224
+ query: str,
225
+ table: str,
226
+ text_columns: Optional[List[str]] = None,
227
+ semantic_weight: float = 0.7,
228
+ keyword_weight: float = 0.3,
229
+ limit: int = 10,
230
+ ) -> Dict[str, Any]:
231
+ """
232
+ Perform hybrid search combining semantic similarity with keyword search.
233
+
234
+ Args:
235
+ query: Search query.
236
+ table: Table name.
237
+ text_columns: Columns to search for keywords.
238
+ semantic_weight: Weight for semantic score.
239
+ keyword_weight: Weight for keyword score.
240
+ limit: Maximum number of results.
241
+
242
+ Returns:
243
+ Search results with combined scores.
244
+ """
245
+ payload: Dict[str, Any] = {
246
+ "query": query,
247
+ "table": table,
248
+ "semantic_weight": semantic_weight,
249
+ "keyword_weight": keyword_weight,
250
+ "limit": limit,
251
+ }
252
+
253
+ if text_columns:
254
+ payload["text_columns"] = text_columns
255
+
256
+ return self._client.post("/api/db/hybrid-search", json=payload)
257
+
258
+ def find_similar(
259
+ self,
260
+ table: str,
261
+ record_id: Union[str, int],
262
+ limit: int = 10,
263
+ threshold: Optional[float] = None,
264
+ exclude_self: bool = True,
265
+ target_table: Optional[str] = None,
266
+ ) -> Dict[str, Any]:
267
+ """
268
+ Find records similar to a specific record using its embedding.
269
+
270
+ Args:
271
+ table: Source table name.
272
+ record_id: ID of the source record.
273
+ limit: Maximum number of similar records.
274
+ threshold: Minimum similarity score.
275
+ exclude_self: Whether to exclude the source record from results.
276
+ target_table: Table to search in (defaults to same as table).
277
+
278
+ Returns:
279
+ Similar records with similarity scores.
280
+ """
281
+ payload: Dict[str, Any] = {
282
+ "table": table,
283
+ "record_id": record_id,
284
+ "limit": limit,
285
+ "exclude_self": exclude_self,
286
+ }
287
+
288
+ if threshold is not None:
289
+ payload["threshold"] = threshold
290
+ if target_table:
291
+ payload["target_table"] = target_table
292
+
293
+ return self._client.post("/api/db/find-similar", json=payload)