databar 2.1.0__tar.gz → 2.5.0__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 (32) hide show
  1. {databar-2.1.0/src/databar.egg-info → databar-2.5.0}/PKG-INFO +72 -7
  2. {databar-2.1.0 → databar-2.5.0}/README.md +71 -6
  3. {databar-2.1.0 → databar-2.5.0}/pyproject.toml +1 -1
  4. {databar-2.1.0 → databar-2.5.0}/src/databar/__init__.py +25 -1
  5. {databar-2.1.0 → databar-2.5.0}/src/databar/cli/_auth.py +3 -2
  6. {databar-2.1.0 → databar-2.5.0}/src/databar/cli/_guide.py +37 -1
  7. databar-2.5.0/src/databar/cli/_output.py +332 -0
  8. {databar-2.1.0 → databar-2.5.0}/src/databar/cli/app.py +5 -1
  9. {databar-2.1.0 → databar-2.5.0}/src/databar/cli/enrichments.py +18 -10
  10. databar-2.5.0/src/databar/cli/flows.py +193 -0
  11. {databar-2.1.0 → databar-2.5.0}/src/databar/cli/tables.py +118 -46
  12. databar-2.5.0/src/databar/cli/tasks.py +117 -0
  13. {databar-2.1.0 → databar-2.5.0}/src/databar/cli/waterfalls.py +8 -6
  14. {databar-2.1.0 → databar-2.5.0}/src/databar/client.py +290 -15
  15. {databar-2.1.0 → databar-2.5.0}/src/databar/exceptions.py +29 -0
  16. {databar-2.1.0 → databar-2.5.0}/src/databar/models.py +168 -5
  17. {databar-2.1.0 → databar-2.5.0/src/databar.egg-info}/PKG-INFO +72 -7
  18. {databar-2.1.0 → databar-2.5.0}/src/databar.egg-info/SOURCES.txt +1 -0
  19. databar-2.5.0/tests/test_cli.py +719 -0
  20. {databar-2.1.0 → databar-2.5.0}/tests/test_client.py +167 -0
  21. {databar-2.1.0 → databar-2.5.0}/tests/test_new_features.py +60 -1
  22. databar-2.1.0/src/databar/cli/_output.py +0 -147
  23. databar-2.1.0/src/databar/cli/tasks.py +0 -60
  24. databar-2.1.0/tests/test_cli.py +0 -332
  25. {databar-2.1.0 → databar-2.5.0}/LICENSE +0 -0
  26. {databar-2.1.0 → databar-2.5.0}/setup.cfg +0 -0
  27. {databar-2.1.0 → databar-2.5.0}/src/databar/cli/__init__.py +0 -0
  28. {databar-2.1.0 → databar-2.5.0}/src/databar/cli/_onboard.py +0 -0
  29. {databar-2.1.0 → databar-2.5.0}/src/databar.egg-info/dependency_links.txt +0 -0
  30. {databar-2.1.0 → databar-2.5.0}/src/databar.egg-info/entry_points.txt +0 -0
  31. {databar-2.1.0 → databar-2.5.0}/src/databar.egg-info/requires.txt +0 -0
  32. {databar-2.1.0 → databar-2.5.0}/src/databar.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: databar
3
- Version: 2.1.0
3
+ Version: 2.5.0
4
4
  Summary: Official Databar.ai Python SDK and CLI — connect to enrichments, waterfalls, and tables via api.databar.ai
5
5
  Author-email: "Databar.ai Team" <info@databar.ai>
6
6
  License: MIT License
@@ -55,7 +55,7 @@ Dynamic: license-file
55
55
 
56
56
  # Databar Python SDK
57
57
 
58
- Official Python SDK and CLI for [Databar.ai](https://databar.ai) — run data enrichments, waterfall lookups, and manage tables via `api.databar.ai/v1`.
58
+ Official Python SDK and CLI for [Databar.ai](https://databar.ai) — run data enrichments, waterfall lookups, flows, and manage tables via `api.databar.ai/v1`.
59
59
 
60
60
  [![PyPI](https://img.shields.io/pypi/v/databar-ai)](https://pypi.org/project/databar-ai/)
61
61
  [![Python](https://img.shields.io/pypi/pyversions/databar-ai)](https://pypi.org/project/databar-ai/)
@@ -154,7 +154,8 @@ data = client.run_enrichment_sync(123, {"email": "alice@example.com"})
154
154
  # Run with pagination (for list-style enrichments)
155
155
  data = client.run_enrichment_sync(123, {"query": "CEO"}, pages=3)
156
156
 
157
- # Bulk run
157
+ # Bulk run — results are aligned to inputs: one element per input, in input
158
+ # order, with None for inputs that returned no data (len(data) == len(inputs)).
158
159
  data = client.run_enrichment_bulk_sync(123, [
159
160
  {"email": "alice@example.com"},
160
161
  {"email": "bob@example.com"},
@@ -192,6 +193,26 @@ results = client.run_waterfall_bulk_sync(
192
193
  )
193
194
  ```
194
195
 
196
+ ### Flows
197
+
198
+ ```python
199
+ # List saved flows
200
+ flows = client.list_flows()
201
+
202
+ # Inspect a flow's declared inputs
203
+ flow = client.get_flow("flow-uuid")
204
+ for inp in flow.inputs:
205
+ print(f" {inp.id} (required={inp.required}): {inp.description}")
206
+
207
+ # Run a flow (submit + poll in one call).
208
+ # inputs maps each flow input id → value.
209
+ result = client.run_flow_sync("flow-uuid", {"email": "alice@example.com"})
210
+
211
+ # Or submit and poll manually
212
+ task = client.run_flow("flow-uuid", {"email": "alice@example.com"})
213
+ result = client.poll_task(task.task_id)
214
+ ```
215
+
195
216
  ### Tables
196
217
 
197
218
  ```python
@@ -339,6 +360,22 @@ client.move_table_to_folder(table.identifier) # remove from folder
339
360
  client.delete_folder(folder.id) # tables move to root
340
361
  ```
341
362
 
363
+ ### Tasks
364
+
365
+ ```python
366
+ task = client.run_enrichment_bulk(123, [{"email": "a@b.com"}, {"email": "c@d.com"}])
367
+
368
+ # While a bulk run is going, progress tells you whether it is advancing or stuck
369
+ status = client.get_task(task.task_id)
370
+ status.progress # {"total": 2, "completed": 1, "failed": 0, "processing": 1}
371
+
372
+ # Rows that have already finished, without waiting for the rest
373
+ client.get_task(task.task_id, include_partial=True).data
374
+
375
+ # Stop it — unfinished requests are refunded, finished rows keep their results
376
+ client.cancel_task(task.task_id)
377
+ ```
378
+
342
379
  ### Error handling
343
380
 
344
381
  ```python
@@ -347,6 +384,7 @@ from databar import (
347
384
  DatabarAuthError,
348
385
  DatabarInsufficientCreditsError,
349
386
  DatabarNotFoundError,
387
+ DatabarTaskCancelledError,
350
388
  DatabarTaskFailedError,
351
389
  DatabarTimeoutError,
352
390
  )
@@ -361,6 +399,9 @@ except DatabarNotFoundError:
361
399
  print("Enrichment not found")
362
400
  except DatabarTaskFailedError as e:
363
401
  print(f"Task failed: {e.message}")
402
+ except DatabarTaskCancelledError as e:
403
+ # Only the rows that finished, and not aligned to the inputs.
404
+ print(f"Cancelled, got {len(e.partial_data or [])} rows")
364
405
  except DatabarTimeoutError as e:
365
406
  print(f"Timed out after polling {e.max_attempts} times")
366
407
  ```
@@ -427,6 +468,21 @@ databar waterfall run email_getter --params '{"linkedin_url": "https://linkedin.
427
468
  databar waterfall bulk email_getter --input leads.csv --out results.csv
428
469
  ```
429
470
 
471
+ ### Flows
472
+
473
+ ```bash
474
+ # List saved flows
475
+ databar flow list
476
+ databar flow list --query "buyer"
477
+
478
+ # Get flow details (declared inputs)
479
+ databar flow get <flow-id>
480
+
481
+ # Run a flow (--inputs maps each flow input id → value)
482
+ databar flow run <flow-id> --inputs '{"email": "alice@example.com"}'
483
+ databar flow run <flow-id> --inputs '{"email": "alice@example.com"}' --format json
484
+ ```
485
+
430
486
  ### Tables
431
487
 
432
488
  ```bash
@@ -463,20 +519,29 @@ databar table run-enrichment <uuid> --enrichment-id <table-enrichment-id>
463
519
  ### Tasks
464
520
 
465
521
  ```bash
466
- # Check a task status
522
+ # Check a task status — a bulk task also reports how many inputs are done
467
523
  databar task get <task-id>
468
524
 
469
525
  # Poll until complete
470
526
  databar task get <task-id> --poll
527
+
528
+ # Collect the rows a running bulk task has already finished
529
+ databar task get <task-id> --partial
530
+
531
+ # Stop a running task; finished rows keep their results
532
+ databar task cancel <task-id>
471
533
  ```
472
534
 
473
535
  ### Output formats
474
536
 
475
- All commands support `--format table|json|csv` (default: `table`):
537
+ All commands support `--format table|json|csv` (default: `table`).
538
+
539
+ `--format json` prints one envelope on stdout:
540
+ `{"ok": true, "data": ...}` or `{"ok": false, "error": {"code", "message", ...}}`.
476
541
 
477
542
  ```bash
478
- # Pipe JSON output
479
- databar table rows <uuid> --format json | jq '.[].email'
543
+ # Pipe JSON output (payload is under .data)
544
+ databar table rows <uuid> --format json | jq '.data[].email'
480
545
 
481
546
  # Save to CSV
482
547
  databar enrich bulk 123 --input input.csv --format csv --out output.csv
@@ -1,6 +1,6 @@
1
1
  # Databar Python SDK
2
2
 
3
- Official Python SDK and CLI for [Databar.ai](https://databar.ai) — run data enrichments, waterfall lookups, and manage tables via `api.databar.ai/v1`.
3
+ Official Python SDK and CLI for [Databar.ai](https://databar.ai) — run data enrichments, waterfall lookups, flows, and manage tables via `api.databar.ai/v1`.
4
4
 
5
5
  [![PyPI](https://img.shields.io/pypi/v/databar-ai)](https://pypi.org/project/databar-ai/)
6
6
  [![Python](https://img.shields.io/pypi/pyversions/databar-ai)](https://pypi.org/project/databar-ai/)
@@ -99,7 +99,8 @@ data = client.run_enrichment_sync(123, {"email": "alice@example.com"})
99
99
  # Run with pagination (for list-style enrichments)
100
100
  data = client.run_enrichment_sync(123, {"query": "CEO"}, pages=3)
101
101
 
102
- # Bulk run
102
+ # Bulk run — results are aligned to inputs: one element per input, in input
103
+ # order, with None for inputs that returned no data (len(data) == len(inputs)).
103
104
  data = client.run_enrichment_bulk_sync(123, [
104
105
  {"email": "alice@example.com"},
105
106
  {"email": "bob@example.com"},
@@ -137,6 +138,26 @@ results = client.run_waterfall_bulk_sync(
137
138
  )
138
139
  ```
139
140
 
141
+ ### Flows
142
+
143
+ ```python
144
+ # List saved flows
145
+ flows = client.list_flows()
146
+
147
+ # Inspect a flow's declared inputs
148
+ flow = client.get_flow("flow-uuid")
149
+ for inp in flow.inputs:
150
+ print(f" {inp.id} (required={inp.required}): {inp.description}")
151
+
152
+ # Run a flow (submit + poll in one call).
153
+ # inputs maps each flow input id → value.
154
+ result = client.run_flow_sync("flow-uuid", {"email": "alice@example.com"})
155
+
156
+ # Or submit and poll manually
157
+ task = client.run_flow("flow-uuid", {"email": "alice@example.com"})
158
+ result = client.poll_task(task.task_id)
159
+ ```
160
+
140
161
  ### Tables
141
162
 
142
163
  ```python
@@ -284,6 +305,22 @@ client.move_table_to_folder(table.identifier) # remove from folder
284
305
  client.delete_folder(folder.id) # tables move to root
285
306
  ```
286
307
 
308
+ ### Tasks
309
+
310
+ ```python
311
+ task = client.run_enrichment_bulk(123, [{"email": "a@b.com"}, {"email": "c@d.com"}])
312
+
313
+ # While a bulk run is going, progress tells you whether it is advancing or stuck
314
+ status = client.get_task(task.task_id)
315
+ status.progress # {"total": 2, "completed": 1, "failed": 0, "processing": 1}
316
+
317
+ # Rows that have already finished, without waiting for the rest
318
+ client.get_task(task.task_id, include_partial=True).data
319
+
320
+ # Stop it — unfinished requests are refunded, finished rows keep their results
321
+ client.cancel_task(task.task_id)
322
+ ```
323
+
287
324
  ### Error handling
288
325
 
289
326
  ```python
@@ -292,6 +329,7 @@ from databar import (
292
329
  DatabarAuthError,
293
330
  DatabarInsufficientCreditsError,
294
331
  DatabarNotFoundError,
332
+ DatabarTaskCancelledError,
295
333
  DatabarTaskFailedError,
296
334
  DatabarTimeoutError,
297
335
  )
@@ -306,6 +344,9 @@ except DatabarNotFoundError:
306
344
  print("Enrichment not found")
307
345
  except DatabarTaskFailedError as e:
308
346
  print(f"Task failed: {e.message}")
347
+ except DatabarTaskCancelledError as e:
348
+ # Only the rows that finished, and not aligned to the inputs.
349
+ print(f"Cancelled, got {len(e.partial_data or [])} rows")
309
350
  except DatabarTimeoutError as e:
310
351
  print(f"Timed out after polling {e.max_attempts} times")
311
352
  ```
@@ -372,6 +413,21 @@ databar waterfall run email_getter --params '{"linkedin_url": "https://linkedin.
372
413
  databar waterfall bulk email_getter --input leads.csv --out results.csv
373
414
  ```
374
415
 
416
+ ### Flows
417
+
418
+ ```bash
419
+ # List saved flows
420
+ databar flow list
421
+ databar flow list --query "buyer"
422
+
423
+ # Get flow details (declared inputs)
424
+ databar flow get <flow-id>
425
+
426
+ # Run a flow (--inputs maps each flow input id → value)
427
+ databar flow run <flow-id> --inputs '{"email": "alice@example.com"}'
428
+ databar flow run <flow-id> --inputs '{"email": "alice@example.com"}' --format json
429
+ ```
430
+
375
431
  ### Tables
376
432
 
377
433
  ```bash
@@ -408,20 +464,29 @@ databar table run-enrichment <uuid> --enrichment-id <table-enrichment-id>
408
464
  ### Tasks
409
465
 
410
466
  ```bash
411
- # Check a task status
467
+ # Check a task status — a bulk task also reports how many inputs are done
412
468
  databar task get <task-id>
413
469
 
414
470
  # Poll until complete
415
471
  databar task get <task-id> --poll
472
+
473
+ # Collect the rows a running bulk task has already finished
474
+ databar task get <task-id> --partial
475
+
476
+ # Stop a running task; finished rows keep their results
477
+ databar task cancel <task-id>
416
478
  ```
417
479
 
418
480
  ### Output formats
419
481
 
420
- All commands support `--format table|json|csv` (default: `table`):
482
+ All commands support `--format table|json|csv` (default: `table`).
483
+
484
+ `--format json` prints one envelope on stdout:
485
+ `{"ok": true, "data": ...}` or `{"ok": false, "error": {"code", "message", ...}}`.
421
486
 
422
487
  ```bash
423
- # Pipe JSON output
424
- databar table rows <uuid> --format json | jq '.[].email'
488
+ # Pipe JSON output (payload is under .data)
489
+ databar table rows <uuid> --format json | jq '.data[].email'
425
490
 
426
491
  # Save to CSV
427
492
  databar enrich bulk 123 --input input.csv --format csv --out output.csv
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "databar"
7
- version = "2.1.0"
7
+ version = "2.5.0"
8
8
  description = "Official Databar.ai Python SDK and CLI — connect to enrichments, waterfalls, and tables via api.databar.ai"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -27,10 +27,12 @@ from .client import DatabarClient
27
27
  from .exceptions import (
28
28
  DatabarAuthError,
29
29
  DatabarError,
30
+ DatabarConflictError,
30
31
  DatabarGoneError,
31
32
  DatabarInsufficientCreditsError,
32
33
  DatabarNotFoundError,
33
34
  DatabarRateLimitError,
35
+ DatabarTaskCancelledError,
34
36
  DatabarTaskFailedError,
35
37
  DatabarTimeoutError,
36
38
  DatabarValidationError,
@@ -59,6 +61,15 @@ from .models import (
59
61
  # Waterfalls
60
62
  Waterfall,
61
63
  WaterfallEnrichment,
64
+ # Flows
65
+ Flow,
66
+ FlowConfigOpsResult,
67
+ FlowDetail,
68
+ FlowInput,
69
+ FlowOutput,
70
+ FlowVersion,
71
+ FlowVersionDetail,
72
+ RestoreFlowVersionResult,
62
73
  # Tables
63
74
  Table,
64
75
  Column,
@@ -84,6 +95,7 @@ from .models import (
84
95
  Exporter,
85
96
  ExporterListResponse,
86
97
  ExporterParam,
98
+ ExporterAdditionalParam,
87
99
  ExporterResponseField,
88
100
  Connection,
89
101
  AuthorizationInfo,
@@ -95,7 +107,7 @@ from .models import (
95
107
  Folder,
96
108
  )
97
109
 
98
- __version__ = "2.1.0"
110
+ __version__ = "2.5.0"
99
111
  __all__ = [
100
112
  "DatabarClient",
101
113
  # exceptions
@@ -103,9 +115,11 @@ __all__ = [
103
115
  "DatabarAuthError",
104
116
  "DatabarNotFoundError",
105
117
  "DatabarInsufficientCreditsError",
118
+ "DatabarConflictError",
106
119
  "DatabarGoneError",
107
120
  "DatabarValidationError",
108
121
  "DatabarRateLimitError",
122
+ "DatabarTaskCancelledError",
109
123
  "DatabarTaskFailedError",
110
124
  "DatabarTimeoutError",
111
125
  # pricing / category
@@ -131,6 +145,15 @@ __all__ = [
131
145
  # waterfalls
132
146
  "Waterfall",
133
147
  "WaterfallEnrichment",
148
+ # flows
149
+ "Flow",
150
+ "FlowConfigOpsResult",
151
+ "FlowDetail",
152
+ "FlowInput",
153
+ "FlowOutput",
154
+ "FlowVersion",
155
+ "FlowVersionDetail",
156
+ "RestoreFlowVersionResult",
134
157
  # tables
135
158
  "Table",
136
159
  "Column",
@@ -156,6 +179,7 @@ __all__ = [
156
179
  "Exporter",
157
180
  "ExporterListResponse",
158
181
  "ExporterParam",
182
+ "ExporterAdditionalParam",
159
183
  "ExporterResponseField",
160
184
  "Connection",
161
185
  "AuthorizationInfo",
@@ -46,7 +46,8 @@ def get_api_key() -> str:
46
46
  "No API key found.\n"
47
47
  " Run [bold]databar login[/bold] to save your key, or set the "
48
48
  "[bold]DATABAR_API_KEY[/bold] environment variable.\n"
49
- " Get your key at [link=https://databar.ai]databar.ai[/link] → Integrations."
49
+ " Get your key at [link=https://databar.ai]databar.ai[/link] → Integrations.",
50
+ code="auth_missing",
50
51
  )
51
52
  raise typer.Exit(1) # unreachable but satisfies type checkers
52
53
 
@@ -111,7 +112,7 @@ def whoami(
111
112
  try:
112
113
  user = client.get_user()
113
114
  except DatabarError as e:
114
- error(str(e))
115
+ error(e)
115
116
  finally:
116
117
  client.close()
117
118
 
@@ -110,6 +110,11 @@ echo 'export PATH="$(python3 -m site --user-base)/bin:$PATH"' >> ~/.zshrc
110
110
  **Always use `--format json` when parsing or piping output.**
111
111
  The default `table` format uses Rich terminal markup — not machine-parseable.
112
112
 
113
+ JSON output is always one envelope on stdout:
114
+ `{"ok": true, "data": ...}` or `{"ok": false, "error": {"code", "message", "hint"?}}`.
115
+ Read results from `.data` (e.g. `jq '.data[].name'`). Exit codes: 2 usage, 3 auth,
116
+ 4 not found, 5 validation, 1 other.
117
+
113
118
  ### Enrichments
114
119
  ```bash
115
120
  databar enrich list --format json
@@ -128,6 +133,16 @@ databar waterfall run <identifier> --params '{"key": "value"}' --format json
128
133
  databar waterfall bulk <identifier> --input data.csv --out results.csv
129
134
  ```
130
135
 
136
+ ### Flows
137
+ ```bash
138
+ databar flow list --format json
139
+ databar flow get <flow-id> --format json # declared inputs
140
+ databar flow run <flow-id> --inputs '{"input_id": "value"}' --format json
141
+ ```
142
+
143
+ NOTE: `flow run` uses `--inputs` (maps each flow input id → value), NOT `--params`.
144
+ See `flow get` for the list of declared inputs.
145
+
131
146
  ### Tables
132
147
  ```bash
133
148
  databar table list --format json
@@ -147,10 +162,17 @@ databar table run-enrichment <table-uuid> --enrichment-id <TABLE-ENRICHMENT-ID>
147
162
  NOTE: `run-enrichment` takes the TABLE-ENRICHMENT ID (from `add-enrichment` or
148
163
  `table enrichments`), NOT the catalog enrichment ID. These are different numbers.
149
164
 
165
+ NOTE: `<table-uuid>` and `<task-id>` must be UUIDs
166
+ (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`). Bad values fail client-side with
167
+ `code: validation` / exit 5 (not a 404). `--out` paths are resolved; null bytes
168
+ are rejected.
169
+
150
170
  ### Tasks
151
171
  ```bash
152
- databar task get <task-id> --format json # check once
172
+ databar task get <task-id> --format json # check once; bulk tasks report progress
153
173
  databar task get <task-id> --poll # poll until complete
174
+ databar task get <task-id> --partial # rows a running bulk task already finished
175
+ databar task cancel <task-id> # stop it; finished rows keep their results
154
176
  ```
155
177
 
156
178
  ---
@@ -174,6 +196,13 @@ result = client.run_enrichment_sync(123, {"email": "alice@example.com"})
174
196
  result = client.run_waterfall_sync("email_getter", {"linkedin_url": "..."})
175
197
  # waterfall.identifier (also .slug) → slug like "email_getter"
176
198
 
199
+ # Flows
200
+ flows = client.list_flows()
201
+ flow = client.get_flow("flow-uuid")
202
+ # flow.id (also .identifier) → flow UUID
203
+ # flow.inputs[i].id → input key to use in the run inputs dict
204
+ result = client.run_flow_sync("flow-uuid", {"email": "alice@example.com"})
205
+
177
206
  # Tables
178
207
  tables = client.list_tables()
179
208
  # table.identifier (also .id, .uuid) → UUID string
@@ -185,6 +214,12 @@ resp = client.get_rows(table.identifier)
185
214
 
186
215
  from databar import InsertRow
187
216
  client.create_rows(table.identifier, [InsertRow(fields={"email": "alice@example.com"})])
217
+
218
+ # Tasks
219
+ task = client.get_task(task_id)
220
+ # task.progress → {"total", "completed", "failed", "processing"} while a bulk run is going
221
+ # client.get_task(task_id, include_partial=True).data → rows already finished
222
+ client.cancel_task(task_id) # stops it; poll_task then raises DatabarTaskCancelledError
188
223
  ```
189
224
 
190
225
  ---
@@ -201,6 +236,7 @@ client.create_rows(table.identifier, [InsertRow(fields={"email": "alice@example.
201
236
 
202
237
  - `Table`: `.id`, `.uuid` → `.identifier`
203
238
  - `Waterfall`: `.slug` → `.identifier`
239
+ - `Flow`: `.identifier` → `.id`
204
240
  - `EnrichmentParam`: `.slug` → `.name`, `.label` → `.description`, `.required` → `.is_required`
205
241
  - `EnrichmentResponseField`: `.slug` → `.name`
206
242