etlplus 0.5.4__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 (55) hide show
  1. etlplus/__init__.py +43 -0
  2. etlplus/__main__.py +22 -0
  3. etlplus/__version__.py +14 -0
  4. etlplus/api/README.md +237 -0
  5. etlplus/api/__init__.py +136 -0
  6. etlplus/api/auth.py +432 -0
  7. etlplus/api/config.py +633 -0
  8. etlplus/api/endpoint_client.py +885 -0
  9. etlplus/api/errors.py +170 -0
  10. etlplus/api/pagination/__init__.py +47 -0
  11. etlplus/api/pagination/client.py +188 -0
  12. etlplus/api/pagination/config.py +440 -0
  13. etlplus/api/pagination/paginator.py +775 -0
  14. etlplus/api/rate_limiting/__init__.py +38 -0
  15. etlplus/api/rate_limiting/config.py +343 -0
  16. etlplus/api/rate_limiting/rate_limiter.py +266 -0
  17. etlplus/api/request_manager.py +589 -0
  18. etlplus/api/retry_manager.py +430 -0
  19. etlplus/api/transport.py +325 -0
  20. etlplus/api/types.py +172 -0
  21. etlplus/cli/__init__.py +15 -0
  22. etlplus/cli/app.py +1367 -0
  23. etlplus/cli/handlers.py +775 -0
  24. etlplus/cli/main.py +616 -0
  25. etlplus/config/__init__.py +56 -0
  26. etlplus/config/connector.py +372 -0
  27. etlplus/config/jobs.py +311 -0
  28. etlplus/config/pipeline.py +339 -0
  29. etlplus/config/profile.py +78 -0
  30. etlplus/config/types.py +204 -0
  31. etlplus/config/utils.py +120 -0
  32. etlplus/ddl.py +197 -0
  33. etlplus/enums.py +414 -0
  34. etlplus/extract.py +218 -0
  35. etlplus/file.py +657 -0
  36. etlplus/load.py +336 -0
  37. etlplus/mixins.py +62 -0
  38. etlplus/py.typed +0 -0
  39. etlplus/run.py +368 -0
  40. etlplus/run_helpers.py +843 -0
  41. etlplus/templates/__init__.py +5 -0
  42. etlplus/templates/ddl.sql.j2 +128 -0
  43. etlplus/templates/view.sql.j2 +69 -0
  44. etlplus/transform.py +1049 -0
  45. etlplus/types.py +227 -0
  46. etlplus/utils.py +638 -0
  47. etlplus/validate.py +493 -0
  48. etlplus/validation/__init__.py +44 -0
  49. etlplus/validation/utils.py +389 -0
  50. etlplus-0.5.4.dist-info/METADATA +616 -0
  51. etlplus-0.5.4.dist-info/RECORD +55 -0
  52. etlplus-0.5.4.dist-info/WHEEL +5 -0
  53. etlplus-0.5.4.dist-info/entry_points.txt +2 -0
  54. etlplus-0.5.4.dist-info/licenses/LICENSE +21 -0
  55. etlplus-0.5.4.dist-info/top_level.txt +1 -0
etlplus/types.py ADDED
@@ -0,0 +1,227 @@
1
+ """
2
+ :mod:`etlplus.types` module.
3
+
4
+ Shared type aliases leveraged across ETLPlus modules.
5
+
6
+ Notes
7
+ -----
8
+ - Centralizes JSON- and pipeline-oriented aliases to keep modules focused on
9
+ orchestration logic.
10
+ - Relies on Python 3.13 ``type`` statements for readability and IDE support.
11
+
12
+ See Also
13
+ --------
14
+ - :mod:`etlplus.api.types` for HTTP-specific aliases
15
+ - :mod:`etlplus.config.types` for TypedDict surfaces
16
+
17
+ Examples
18
+ --------
19
+ >>> from etlplus.types import JSONDict, PipelineConfig
20
+ >>> payload: JSONDict = {'id': 1, 'name': 'Ada'}
21
+ >>> isinstance(payload, dict)
22
+ True
23
+ >>> config: PipelineConfig = {
24
+ ... 'filter': [{'field': 'id', 'op': '>', 'value': 0}],
25
+ ... }
26
+ >>> isinstance(config, dict)
27
+ True
28
+ """
29
+
30
+ from __future__ import annotations
31
+
32
+ from collections.abc import Callable
33
+ from collections.abc import Mapping
34
+ from collections.abc import Sequence
35
+ from os import PathLike
36
+ from pathlib import Path
37
+ from typing import Any
38
+ from typing import Literal
39
+
40
+ # SECTION: EXPORTS ========================================================== #
41
+
42
+
43
+ __all__ = [
44
+ # Type Aliases (Data)
45
+ 'JSONData',
46
+ 'JSONDict',
47
+ 'JSONList',
48
+ 'JSONScalar',
49
+ 'JSONValue',
50
+ 'Record',
51
+ 'Records',
52
+ 'JSONRecord',
53
+ 'JSONRecords',
54
+ # Type Aliases (File System)
55
+ 'StrPath',
56
+ # Type Aliases (Functions)
57
+ 'AggregateFunc',
58
+ 'OperatorFunc',
59
+ # Type Aliases (Records & Fields)
60
+ 'FieldName',
61
+ 'Fields',
62
+ # Type Aliases (Transform Specs)
63
+ 'StrAnyMap',
64
+ 'StrSeqMap',
65
+ 'StrStrMap',
66
+ 'AggregateSpec',
67
+ 'FilterSpec',
68
+ 'MapSpec',
69
+ 'SelectSpec',
70
+ 'SortSpec',
71
+ # Type Aliases (Pipelines)
72
+ 'StepOrSteps',
73
+ 'StepSeq',
74
+ 'StepSpec',
75
+ 'PipelineStepName',
76
+ 'PipelineConfig',
77
+ # Type Aliases (Helpers)
78
+ 'StepApplier',
79
+ 'SortKey',
80
+ # Type Aliases (Networking / Runtime)
81
+ 'Sleeper',
82
+ 'Timeout',
83
+ ]
84
+
85
+
86
+ # SECTION: TYPE ALIASES ===================================================== #
87
+
88
+
89
+ # -- Data -- #
90
+
91
+ # Mapping representing a JSON object keyed by strings.
92
+ type JSONDict = dict[str, Any]
93
+
94
+ # Ordered collection of JSON objects, commonly used for batches.
95
+ type JSONList = list[JSONDict]
96
+
97
+ # Union capturing the primary ETL payload (record or batch).
98
+ type JSONData = JSONDict | JSONList
99
+
100
+ # JSON scalar/value aliases (useful for stricter schemas elsewhere)
101
+
102
+ # Primitive JSON-compatible value used across validators.
103
+ type JSONScalar = None | bool | int | float | str
104
+
105
+ # Recursive JSON-friendly value supporting nested payloads.
106
+ type JSONValue = JSONScalar | list[JSONValue] | dict[str, JSONValue]
107
+
108
+ # Convenience synonyms
109
+
110
+ # Alias maintained for compatibility with earlier helpers.
111
+ type Record = JSONDict
112
+
113
+ # Synonym for :data:`JSONList` when semantics target record sets.
114
+ type Records = JSONList
115
+
116
+ # Explicit alias favored by API pagination helpers.
117
+ type JSONRecord = JSONDict
118
+
119
+ # List of :data:`JSONRecord` values returned by pagination utilities.
120
+ type JSONRecords = list[JSONRecord]
121
+
122
+ # -- File System -- #
123
+
124
+ # Path-like inputs accepted by file helpers.
125
+ type StrPath = str | Path | PathLike[str]
126
+
127
+ # -- Functions -- #
128
+
129
+ # Callable reducing numeric collections into a summary value.
130
+ type AggregateFunc = Callable[[list[float], int], Any]
131
+
132
+ # Binary predicate consumed by filter operations.
133
+ type OperatorFunc = Callable[[Any, Any], bool]
134
+
135
+ # -- Records & Fields -- #
136
+
137
+ # Individual field identifier referenced inside specs.
138
+ type FieldName = str
139
+
140
+ # Ordered list of :data:`FieldName` entries preserving projection order.
141
+ type Fields = list[FieldName]
142
+
143
+ # -- Transform Specs -- #
144
+
145
+ # Kept intentionally broad for runtime-friendly validation in transform.py.
146
+
147
+ # Base building blocks to simplify complex specs.
148
+
149
+ # Mapping of string keys to arbitrary values.
150
+ type StrAnyMap = Mapping[str, Any]
151
+
152
+ # Mapping constrained to string-to-string transformations.
153
+ type StrStrMap = Mapping[str, str]
154
+
155
+ # Mapping whose values are homogeneous sequences.
156
+ type StrSeqMap = Mapping[str, Sequence[Any]]
157
+
158
+ # Transform step specifications
159
+
160
+ # Filtering spec expecting ``field``, ``op``, and ``value`` keys.
161
+ type FilterSpec = StrAnyMap
162
+
163
+ # Field renaming instructions mapping old keys to new ones.
164
+ type MapSpec = StrStrMap
165
+
166
+ # Projection spec as a field list or mapping with metadata.
167
+ #
168
+ # Examples
169
+ # --------
170
+ # >>> from etlplus.types import SelectSpec
171
+ # >>> spec1: SelectSpec = ['a','b']
172
+ # >>> spec2: SelectSpec = {'fields': [...]}
173
+ type SelectSpec = Fields | StrSeqMap
174
+
175
+ # Sort directive expressed as a field string or mapping with flags.
176
+ #
177
+ # Examples
178
+ # --------
179
+ # >>> from etlplus.types import SortSpec
180
+ # >>> spec1: SortSpec = 'field'
181
+ # >>> spec2: SortSpec = {'field': 'x', 'reverse': True}
182
+ type SortSpec = str | StrAnyMap
183
+
184
+ # Aggregate instruction covering ``field``, ``func``, and optional alias.
185
+ #
186
+ # Supported functions: ``avg``, ``count``, ``max``, ``min``, and ``sum``.
187
+ # Examples
188
+ # --------
189
+ # >>> from etlplus.types import AggregateSpec
190
+ # >>> spec: AggregateSpec = \
191
+ # ... {'field': 'x', 'func': 'sum' | 'avg' | ..., 'alias'?: '...'}
192
+ type AggregateSpec = StrAnyMap
193
+
194
+ # -- Pipelines-- #
195
+
196
+ # Unified pipeline step spec consumed by :mod:`etlplus.transform`.
197
+ type StepSpec = FilterSpec | MapSpec | SelectSpec | SortSpec | AggregateSpec
198
+
199
+ # Collections of steps
200
+
201
+ # Ordered collection of :data:`StepSpec` entries.
202
+ type StepSeq = Sequence[StepSpec]
203
+
204
+ # Accepts either a single :data:`StepSpec` or a sequence of them.
205
+ type StepOrSteps = StepSpec | StepSeq
206
+
207
+ # Canonical literal names for supported transform stages.
208
+ type PipelineStepName = Literal['filter', 'map', 'select', 'sort', 'aggregate']
209
+
210
+ # Mapping from step name to its associated specification payload.
211
+ type PipelineConfig = Mapping[PipelineStepName, StepOrSteps]
212
+
213
+ # -- Helpers -- #
214
+
215
+ # Callable that applies step configuration to a batch of records.
216
+ type StepApplier = Callable[[JSONList, Any], JSONList]
217
+
218
+ # Tuple combining stable sort index and computed sort value.
219
+ type SortKey = tuple[int, Any]
220
+
221
+ # -- Networking / Runtime -- #
222
+
223
+ # Sleep function used by retry helpers.
224
+ type Sleeper = Callable[[float], None]
225
+
226
+ # Numeric timeout in seconds or ``None`` for no timeout.
227
+ type Timeout = float | None