dc-python-sdk 1.5.30__tar.gz → 1.5.31__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 (36) hide show
  1. {dc_python_sdk-1.5.30/src/dc_python_sdk.egg-info → dc_python_sdk-1.5.31}/PKG-INFO +1 -1
  2. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/pyproject.toml +1 -1
  3. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/setup.cfg +1 -1
  4. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31/src/dc_python_sdk.egg-info}/PKG-INFO +1 -1
  5. dc_python_sdk-1.5.31/src/dc_sdk/handler.py +196 -0
  6. dc_python_sdk-1.5.30/src/dc_sdk/handler.py +0 -72
  7. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/LICENSE +0 -0
  8. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/README.md +0 -0
  9. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_python_sdk.egg-info/SOURCES.txt +0 -0
  10. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_python_sdk.egg-info/dependency_links.txt +0 -0
  11. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_python_sdk.egg-info/entry_points.txt +0 -0
  12. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_python_sdk.egg-info/requires.txt +0 -0
  13. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_python_sdk.egg-info/top_level.txt +0 -0
  14. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/__init__.py +0 -0
  15. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/app.py +0 -0
  16. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/cli.py +0 -0
  17. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/errors.py +0 -0
  18. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/__init__.py +0 -0
  19. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/ai.py +0 -0
  20. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/ai_http.py +0 -0
  21. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/mapping.py +0 -0
  22. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/models/__init__.py +0 -0
  23. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/models/enums.py +0 -0
  24. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/models/errors.py +0 -0
  25. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/models/log_templates.py +0 -0
  26. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/models/pipeline_details.py +0 -0
  27. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/pipeline.py +0 -0
  28. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/server.py +0 -0
  29. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/services/__init__.py +0 -0
  30. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/services/api.py +0 -0
  31. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/services/aws.py +0 -0
  32. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/services/environment.py +0 -0
  33. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/services/loader.py +0 -0
  34. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/services/logger.py +0 -0
  35. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/src/services/session.py +0 -0
  36. {dc_python_sdk-1.5.30 → dc_python_sdk-1.5.31}/src/dc_sdk/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dc-python-sdk
3
- Version: 1.5.30
3
+ Version: 1.5.31
4
4
  Summary: Data Connector Python SDK
5
5
  Home-page: https://github.com/data-connector/dc-python-sdk
6
6
  Author: DataConnector
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dc-python-sdk"
7
- version = "1.5.30"
7
+ version = "1.5.31"
8
8
  description = "Data Connector Python SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.6"
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = dc-python-sdk
3
- version = 1.5.30
3
+ version = 1.5.31
4
4
  author = DataConnector
5
5
  author_email = josh@dataconnector.com
6
6
  description = A small example package
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dc-python-sdk
3
- Version: 1.5.30
3
+ Version: 1.5.31
4
4
  Summary: Data Connector Python SDK
5
5
  Home-page: https://github.com/data-connector/dc-python-sdk
6
6
  Author: DataConnector
@@ -0,0 +1,196 @@
1
+ from dc_sdk.errors import Error
2
+ from dc_sdk.src.mapping import Mapping
3
+ import traceback
4
+ from importlib.metadata import version
5
+
6
+ def get_action_name(action: int) -> str:
7
+ return {
8
+ 0: "authenticating",
9
+ 1: "retrieving fields",
10
+ 2: "retrieving 5 row preview",
11
+ 3: "testing connection",
12
+ 4: "starting the connector"
13
+ }[action]
14
+
15
+ def apply_data_filters(results, data_filters):
16
+ if not data_filters:
17
+ return results
18
+
19
+ # 🔹 UI → backend operator mapping
20
+ OPERATOR_MAP = {
21
+ # text
22
+ "text_contains": "CONTAINS",
23
+ "text_not_contains": "NOT_CONTAINS",
24
+ "text_starts_with": "STARTS_WITH",
25
+ "text_ends_with": "ENDS_WITH",
26
+
27
+ # equality
28
+ "is_equal": "EQ",
29
+ "is_not_equal": "NEQ",
30
+
31
+ # empty
32
+ "is_empty": "IS_EMPTY",
33
+ "is_not_empty": "IS_NOT_EMPTY",
34
+
35
+ # numeric
36
+ "gt": "GT",
37
+ "gte": "GTE",
38
+ "lt": "LT",
39
+ "lte": "LTE",
40
+
41
+ # range
42
+ "between": "BETWEEN",
43
+ "not_between": "NOT_BETWEEN",
44
+
45
+ # ignore
46
+ "none": None,
47
+ }
48
+
49
+ def try_parse_number(val):
50
+ try:
51
+ return float(val)
52
+ except:
53
+ return val
54
+
55
+ def normalize(row_val, v1, v2=None):
56
+ row_num = try_parse_number(row_val)
57
+ v1_num = try_parse_number(v1)
58
+ v2_num = try_parse_number(v2) if v2 is not None else None
59
+
60
+ # If both are numbers → compare as numbers
61
+ if isinstance(row_num, float) and isinstance(v1_num, float):
62
+ return row_num, v1_num, v2_num
63
+
64
+ # Otherwise → compare as strings
65
+ return str(row_val), str(v1), str(v2) if v2 is not None else None
66
+
67
+ def match(row, f):
68
+ ui_operator = f.get("operator_cd")
69
+ operator = OPERATOR_MAP.get(ui_operator)
70
+
71
+ if operator is None:
72
+ return True # skip "none"
73
+
74
+ col = f.get("column_name")
75
+ val1 = f.get("value_1_txt")
76
+ val2 = f.get("value_2_txt")
77
+
78
+ row_val = row.get(col)
79
+
80
+ # ---- EMPTY HANDLING ----
81
+ if operator == "IS_EMPTY":
82
+ return row_val is None or str(row_val).strip() == ""
83
+
84
+ if operator == "IS_NOT_EMPTY":
85
+ return row_val is not None and str(row_val).strip() != ""
86
+
87
+ if row_val is None:
88
+ return False
89
+
90
+ # Normalize values
91
+ row_val, v1, v2 = normalize(row_val, val1, val2)
92
+
93
+ # ---- OPERATORS ----
94
+
95
+ if operator == "EQ":
96
+ return row_val == v1
97
+
98
+ elif operator == "NEQ":
99
+ return row_val != v1
100
+
101
+ elif operator == "GT":
102
+ return row_val > v1
103
+
104
+ elif operator == "GTE":
105
+ return row_val >= v1
106
+
107
+ elif operator == "LT":
108
+ return row_val < v1
109
+
110
+ elif operator == "LTE":
111
+ return row_val <= v1
112
+
113
+ elif operator == "BETWEEN":
114
+ return v1 <= row_val <= v2
115
+
116
+ elif operator == "NOT_BETWEEN":
117
+ return not (v1 <= row_val <= v2)
118
+
119
+ elif operator == "CONTAINS":
120
+ return str(v1).lower() in str(row_val).lower()
121
+
122
+ elif operator == "NOT_CONTAINS":
123
+ return str(v1).lower() not in str(row_val).lower()
124
+
125
+ elif operator == "STARTS_WITH":
126
+ return str(row_val).lower().startswith(str(v1).lower())
127
+
128
+ elif operator == "ENDS_WITH":
129
+ return str(row_val).lower().endswith(str(v1).lower())
130
+
131
+ return True
132
+
133
+ # 🔹 Apply filters (AND logic)
134
+ return [row for row in results if all(match(row, f) for f in data_filters)]
135
+
136
+
137
+ def handler(event, context):
138
+ print("version: ", version("dc-python-sdk"))
139
+ """Lambda Handler"""
140
+ action_name = None
141
+ internal_error = False
142
+ message = None
143
+ results = None
144
+ error = None
145
+ mapping = None
146
+ action = int(event['action']) if 'action' in event else 4
147
+ get_objects = event.get('get_objects', True)
148
+ credentials_dict = event['credentials'] if 'credentials' in event else None
149
+ object_id = event['object_id'] if 'object_id' in event else None
150
+ field_ids = event['mapping'] if 'mapping' in event else None
151
+ options = event['options'] if 'options' in event else dict()
152
+ next_page = event['next_page'] if 'next_page' in event else None
153
+ n_rows = event['n_rows'] if 'n_rows' in event else None
154
+ filters = event['filters'] if 'filters' in event else None
155
+ data_filters = event['data_filters'] if 'data_filters' in event else None
156
+
157
+ try:
158
+ action_name = get_action_name(action)
159
+ mapping = Mapping(credentials_dict)
160
+
161
+ if action == 0:
162
+ if get_objects:
163
+ results, message = mapping.connect_get_objects()
164
+ else:
165
+ results, message = mapping.authenticate()
166
+ elif action == 1:
167
+ results, message = mapping.get_fields(object_id, options)
168
+ elif action == 2:
169
+ results, message = mapping.get_five_row_preview(
170
+ object_id, field_ids, options, n_rows, filters, next_page)
171
+ results = apply_data_filters(results, data_filters)
172
+ elif action == 3:
173
+ results, message = mapping.test_connection()
174
+ else:
175
+ raise Error("Invalid action", "InvalidActionError")
176
+ except Error as e:
177
+ message = e.message
178
+ internal_error = e.internal
179
+ error_trace = traceback.format_exc()
180
+ error = error_trace
181
+
182
+ except Exception as e:
183
+ error_trace = traceback.format_exc()
184
+ error = error_trace
185
+ internal_error = True
186
+
187
+ if error:
188
+ print(error)
189
+
190
+ return {
191
+ 'message': message if not internal_error else f"Something went wrong with {action_name}",
192
+ 'results': results,
193
+ 'credentials': mapping.connector.credentials if mapping else None,
194
+ 'error': error,
195
+ 'internal_error': internal_error
196
+ }
@@ -1,72 +0,0 @@
1
- from dc_sdk.errors import Error
2
- from dc_sdk.src.mapping import Mapping
3
- import traceback
4
- from importlib.metadata import version
5
-
6
- def get_action_name(action: int) -> str:
7
- return {
8
- 0: "authenticating",
9
- 1: "retrieving fields",
10
- 2: "retrieving 5 row preview",
11
- 3: "testing connection",
12
- 4: "starting the connector"
13
- }[action]
14
-
15
- def handler(event, context):
16
- print("version: ", version("dc-python-sdk"))
17
- """Lambda Handler"""
18
- action_name = None
19
- internal_error = False
20
- message = None
21
- results = None
22
- error = None
23
- mapping = None
24
- action = int(event['action']) if 'action' in event else 4
25
- get_objects = event.get('get_objects', True)
26
- credentials_dict = event['credentials'] if 'credentials' in event else None
27
- object_id = event['object_id'] if 'object_id' in event else None
28
- field_ids = event['mapping'] if 'mapping' in event else None
29
- options = event['options'] if 'options' in event else dict()
30
- next_page = event['next_page'] if 'next_page' in event else None
31
- n_rows = event['n_rows'] if 'n_rows' in event else None
32
- filters = event['filters'] if 'filters' in event else None
33
-
34
- try:
35
- action_name = get_action_name(action)
36
- mapping = Mapping(credentials_dict)
37
-
38
- if action == 0:
39
- if get_objects:
40
- results, message = mapping.connect_get_objects()
41
- else:
42
- results, message = mapping.authenticate()
43
- elif action == 1:
44
- results, message = mapping.get_fields(object_id, options)
45
- elif action == 2:
46
- results, message = mapping.get_five_row_preview(
47
- object_id, field_ids, options, n_rows, filters, next_page)
48
- elif action == 3:
49
- results, message = mapping.test_connection()
50
- else:
51
- raise Error("Invalid action", "InvalidActionError")
52
- except Error as e:
53
- message = e.message
54
- internal_error = e.internal
55
- error_trace = traceback.format_exc()
56
- error = error_trace
57
-
58
- except Exception as e:
59
- error_trace = traceback.format_exc()
60
- error = error_trace
61
- internal_error = True
62
-
63
- if error:
64
- print(error)
65
-
66
- return {
67
- 'message': message if not internal_error else f"Something went wrong with {action_name}",
68
- 'results': results,
69
- 'credentials': mapping.connector.credentials if mapping else None,
70
- 'error': error,
71
- 'internal_error': internal_error
72
- }
File without changes
File without changes