databar 2.6.1__tar.gz → 2.8.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 (33) hide show
  1. {databar-2.6.1/src/databar.egg-info → databar-2.8.0}/PKG-INFO +3 -2
  2. {databar-2.6.1 → databar-2.8.0}/README.md +2 -1
  3. {databar-2.6.1 → databar-2.8.0}/pyproject.toml +1 -1
  4. {databar-2.6.1 → databar-2.8.0}/src/databar/__init__.py +13 -1
  5. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/app.py +3 -1
  6. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/tables.py +83 -0
  7. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/waterfalls.py +6 -4
  8. databar-2.8.0/src/databar/cli/workbooks.py +233 -0
  9. {databar-2.6.1 → databar-2.8.0}/src/databar/client.py +209 -22
  10. {databar-2.6.1 → databar-2.8.0}/src/databar/exceptions.py +6 -1
  11. {databar-2.6.1 → databar-2.8.0}/src/databar/models.py +57 -1
  12. {databar-2.6.1 → databar-2.8.0/src/databar.egg-info}/PKG-INFO +3 -2
  13. {databar-2.6.1 → databar-2.8.0}/src/databar.egg-info/SOURCES.txt +3 -1
  14. {databar-2.6.1 → databar-2.8.0}/tests/test_cli.py +1 -1
  15. {databar-2.6.1 → databar-2.8.0}/tests/test_client.py +31 -5
  16. {databar-2.6.1 → databar-2.8.0}/tests/test_new_features.py +16 -0
  17. databar-2.8.0/tests/test_workbooks.py +90 -0
  18. {databar-2.6.1 → databar-2.8.0}/LICENSE +0 -0
  19. {databar-2.6.1 → databar-2.8.0}/setup.cfg +0 -0
  20. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/__init__.py +0 -0
  21. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/_auth.py +0 -0
  22. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/_guide.py +0 -0
  23. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/_oauth.py +0 -0
  24. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/_onboard.py +0 -0
  25. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/_output.py +0 -0
  26. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/enrichments.py +0 -0
  27. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/flows.py +0 -0
  28. {databar-2.6.1 → databar-2.8.0}/src/databar/cli/tasks.py +0 -0
  29. {databar-2.6.1 → databar-2.8.0}/src/databar.egg-info/dependency_links.txt +0 -0
  30. {databar-2.6.1 → databar-2.8.0}/src/databar.egg-info/entry_points.txt +0 -0
  31. {databar-2.6.1 → databar-2.8.0}/src/databar.egg-info/requires.txt +0 -0
  32. {databar-2.6.1 → databar-2.8.0}/src/databar.egg-info/top_level.txt +0 -0
  33. {databar-2.6.1 → databar-2.8.0}/tests/test_oauth_login.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: databar
3
- Version: 2.6.1
3
+ Version: 2.8.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
@@ -174,7 +174,8 @@ for choice in choices.items:
174
174
  # List waterfalls
175
175
  waterfalls = client.list_waterfalls()
176
176
 
177
- # Run a waterfall (tries all providers in sequence)
177
+ # Run a waterfall (tries the default providers in sequence; optional add-ons
178
+ # such as Apollo run only when you pass their id in `enrichments`)
178
179
  result = client.run_waterfall_sync(
179
180
  "email_getter",
180
181
  {"linkedin_url": "https://linkedin.com/in/alice"},
@@ -119,7 +119,8 @@ for choice in choices.items:
119
119
  # List waterfalls
120
120
  waterfalls = client.list_waterfalls()
121
121
 
122
- # Run a waterfall (tries all providers in sequence)
122
+ # Run a waterfall (tries the default providers in sequence; optional add-ons
123
+ # such as Apollo run only when you pass their id in `enrichments`)
123
124
  result = client.run_waterfall_sync(
124
125
  "email_getter",
125
126
  {"linkedin_url": "https://linkedin.com/in/alice"},
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "databar"
7
- version = "2.6.1"
7
+ version = "2.8.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" }
@@ -108,9 +108,15 @@ from .models import (
108
108
  Connector,
109
109
  # Folders
110
110
  Folder,
111
+ # Workbooks / trash
112
+ Workbook,
113
+ WorkbookTable,
114
+ ExportStatus,
115
+ DedupeResult,
116
+ TrashItem,
111
117
  )
112
118
 
113
- __version__ = "2.6.1"
119
+ __version__ = "2.8.0"
114
120
  __all__ = [
115
121
  "DatabarClient",
116
122
  # exceptions
@@ -195,4 +201,10 @@ __all__ = [
195
201
  "Connector",
196
202
  # folders
197
203
  "Folder",
204
+ # workbooks
205
+ "Workbook",
206
+ "WorkbookTable",
207
+ "ExportStatus",
208
+ "DedupeResult",
209
+ "TrashItem",
198
210
  ]
@@ -12,7 +12,7 @@ import typer
12
12
 
13
13
  from databar import __version__
14
14
 
15
- from . import enrichments, flows, tables, tasks, waterfalls
15
+ from . import enrichments, flows, tables, tasks, waterfalls, workbooks
16
16
  from ._auth import app as auth_app
17
17
 
18
18
  app = typer.Typer(
@@ -35,6 +35,8 @@ app.add_typer(waterfalls.app, name="waterfall")
35
35
  app.add_typer(flows.app, name="flow")
36
36
  app.add_typer(tables.app, name="table")
37
37
  app.add_typer(tasks.app, name="task")
38
+ app.add_typer(workbooks.workbook_app, name="workbook")
39
+ app.add_typer(workbooks.trash_app, name="trash")
38
40
 
39
41
 
40
42
  @app.command("onboard")
@@ -386,6 +386,89 @@ def run_table_enrichment(
386
386
  output(result, OutputFormat.JSON)
387
387
 
388
388
 
389
+ @app.command("duplicate")
390
+ def duplicate_table(
391
+ table_uuid: str = _TABLE_UUID,
392
+ fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
393
+ ) -> None:
394
+ """Duplicate a table into a new workbook."""
395
+ client = get_client()
396
+ try:
397
+ table = client.duplicate_table(table_uuid)
398
+ except DatabarError as e:
399
+ error(e)
400
+ finally:
401
+ client.close()
402
+ success(f"Duplicated as {table.identifier}")
403
+ output({"uuid": table.identifier, "name": table.name, "workbook": table.workbook}, fmt)
404
+
405
+
406
+ @app.command("clear")
407
+ def clear_table(table_uuid: str = _TABLE_UUID) -> None:
408
+ """Queue deletion of every row in the table."""
409
+ client = get_client()
410
+ try:
411
+ client.clear_table(table_uuid)
412
+ except DatabarError as e:
413
+ error(e)
414
+ finally:
415
+ client.close()
416
+ success("Clear queued.")
417
+
418
+
419
+ @app.command("export")
420
+ def export_table(
421
+ table_uuid: str = _TABLE_UUID,
422
+ format: str = typer.Option("csv", "--export-format", help="csv, xlsx, or sheets."),
423
+ fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
424
+ ) -> None:
425
+ """Start a table export. Poll status with get-export."""
426
+ client = get_client()
427
+ try:
428
+ status = client.export_table(table_uuid, format=format)
429
+ except DatabarError as e:
430
+ error(e)
431
+ finally:
432
+ client.close()
433
+ success(f"Export queued (file_id={status.file_id})")
434
+ output(status.model_dump(), fmt)
435
+
436
+
437
+ @app.command("get-export")
438
+ def get_table_export(
439
+ table_uuid: str = _TABLE_UUID,
440
+ fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
441
+ ) -> None:
442
+ """Check the latest export status / download URL."""
443
+ client = get_client()
444
+ try:
445
+ status = client.get_table_export(table_uuid)
446
+ except DatabarError as e:
447
+ error(e)
448
+ finally:
449
+ client.close()
450
+ output(status.model_dump(), fmt)
451
+
452
+
453
+ @app.command("dedupe")
454
+ def dedupe_table(
455
+ table_uuid: str = _TABLE_UUID,
456
+ columns: Optional[str] = typer.Option(None, "--columns", help="Comma-separated column UUIDs."),
457
+ fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
458
+ ) -> None:
459
+ """Delete duplicate rows, keeping the oldest of each group."""
460
+ col_ids = [c.strip() for c in columns.split(",")] if columns else None
461
+ client = get_client()
462
+ try:
463
+ result = client.dedupe_table_rows(table_uuid, columns=col_ids)
464
+ except DatabarError as e:
465
+ error(e)
466
+ finally:
467
+ client.close()
468
+ success(f"Deleted {result.count_rows_delete} duplicate rows.")
469
+ output(result.model_dump(), fmt)
470
+
471
+
389
472
  # ---------------------------------------------------------------------------
390
473
  # Helpers
391
474
  # ---------------------------------------------------------------------------
@@ -23,6 +23,8 @@ from ._output import OutputFormat, console, error, info, output
23
23
 
24
24
  app = typer.Typer(help="Search and run waterfall enrichments.")
25
25
 
26
+ PROVIDERS_HELP = "Comma-separated provider IDs (default: providers enabled by default)."
27
+
26
28
 
27
29
  @app.command("list")
28
30
  def list_waterfalls(
@@ -99,10 +101,10 @@ def get_waterfall(
99
101
  if w.available_enrichments:
100
102
  console.print("\n[bold]Available providers:[/bold]")
101
103
  rows = [
102
- {"id": e.id, "name": e.name, "price": e.price}
104
+ {"id": e.id, "name": e.name, "price": e.price, "default": "yes" if e.enabled_by_default else "no"}
103
105
  for e in w.available_enrichments
104
106
  ]
105
- output(rows, OutputFormat.TABLE, table_columns=["id", "name", "price"])
107
+ output(rows, OutputFormat.TABLE, table_columns=["id", "name", "price", "default"])
106
108
 
107
109
 
108
110
  @app.command("info", hidden=True)
@@ -118,7 +120,7 @@ def info_waterfall(
118
120
  def run_waterfall(
119
121
  identifier: str = typer.Argument(..., help="Waterfall identifier."),
120
122
  params_json: str = typer.Option(..., "--params", "-p", help='JSON params, e.g. \'{"linkedin_url":"https://..."}\''),
121
- providers: Optional[str] = typer.Option(None, "--providers", help="Comma-separated provider IDs (default: all)."),
123
+ providers: Optional[str] = typer.Option(None, "--providers", help=PROVIDERS_HELP),
122
124
  email_verifier: Optional[int] = typer.Option(None, "--email-verifier", help="Email verifier enrichment ID."),
123
125
  fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
124
126
  raw: bool = typer.Option(False, "--raw", help="Print raw result without formatting."),
@@ -160,7 +162,7 @@ def run_waterfall(
160
162
  def bulk_waterfall(
161
163
  identifier: str = typer.Argument(..., help="Waterfall identifier."),
162
164
  input_file: Path = typer.Option(..., "--input", "-i", help="CSV file with one row per input.", exists=True),
163
- providers: Optional[str] = typer.Option(None, "--providers", help="Comma-separated provider IDs (default: all)."),
165
+ providers: Optional[str] = typer.Option(None, "--providers", help=PROVIDERS_HELP),
164
166
  email_verifier: Optional[int] = typer.Option(None, "--email-verifier", help="Email verifier enrichment ID."),
165
167
  fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
166
168
  out: Optional[str] = typer.Option(None, "--out", "-o", help="Output file (for CSV format)."),
@@ -0,0 +1,233 @@
1
+ """
2
+ CLI commands for workbooks and trash.
3
+
4
+ databar workbook list
5
+ databar workbook get <id>
6
+ databar workbook rename <id> --name
7
+ databar workbook delete <id>
8
+ databar workbook duplicate <id>
9
+ databar workbook merge --target <id> --sources id1,id2
10
+ databar workbook add-table <id> [--name]
11
+ databar trash list
12
+ databar trash restore --workbooks id1 [--tables uuid]
13
+ databar trash purge --workbooks id1 [--tables uuid]
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from typing import Optional
19
+
20
+ import typer
21
+
22
+ from databar.exceptions import DatabarError
23
+
24
+ from ._auth import get_client
25
+ from ._output import OutputFormat, error, info, output, success
26
+
27
+ workbook_app = typer.Typer(help="Manage workbooks (multi-sheet documents).")
28
+ trash_app = typer.Typer(help="List, restore, or permanently delete trash.")
29
+
30
+
31
+ @workbook_app.command("list")
32
+ def list_workbooks(
33
+ fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
34
+ ) -> None:
35
+ """List workbooks in your workspace."""
36
+ client = get_client()
37
+ try:
38
+ workbooks = client.list_workbooks()
39
+ except DatabarError as e:
40
+ error(e)
41
+ finally:
42
+ client.close()
43
+
44
+ if not workbooks:
45
+ info("No workbooks found.")
46
+ output([], fmt)
47
+ return
48
+
49
+ rows = [
50
+ {
51
+ "id": w.identifier,
52
+ "name": w.name,
53
+ "tables": w.tables_count,
54
+ "updated": w.updated_at,
55
+ }
56
+ for w in workbooks
57
+ ]
58
+ output(rows, fmt, table_columns=["id", "name", "tables", "updated"])
59
+
60
+
61
+ @workbook_app.command("get")
62
+ def get_workbook(
63
+ workbook_id: str = typer.Argument(..., help="Workbook identifier (wb_…)."),
64
+ fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
65
+ ) -> None:
66
+ """Show one workbook and its sheets."""
67
+ client = get_client()
68
+ try:
69
+ wb = client.get_workbook(workbook_id)
70
+ except DatabarError as e:
71
+ error(e)
72
+ finally:
73
+ client.close()
74
+
75
+ output(
76
+ {
77
+ "id": wb.identifier,
78
+ "name": wb.name,
79
+ "tables": [{"uuid": t.identifier, "name": t.name, "position": t.position} for t in wb.tables],
80
+ },
81
+ fmt,
82
+ )
83
+
84
+
85
+ @workbook_app.command("rename")
86
+ def rename_workbook(
87
+ workbook_id: str = typer.Argument(..., help="Workbook identifier (wb_…)."),
88
+ name: str = typer.Option(..., "--name", "-n", help="New name."),
89
+ ) -> None:
90
+ """Rename a workbook."""
91
+ client = get_client()
92
+ try:
93
+ wb = client.rename_workbook(workbook_id, name)
94
+ except DatabarError as e:
95
+ error(e)
96
+ finally:
97
+ client.close()
98
+ success(f"Renamed workbook to {wb.name!r}")
99
+
100
+
101
+ @workbook_app.command("delete")
102
+ def delete_workbook(
103
+ workbook_id: str = typer.Argument(..., help="Workbook identifier (wb_…)."),
104
+ ) -> None:
105
+ """Move a workbook to Trash."""
106
+ client = get_client()
107
+ try:
108
+ client.delete_workbook(workbook_id)
109
+ except DatabarError as e:
110
+ error(e)
111
+ finally:
112
+ client.close()
113
+ success(f"Workbook {workbook_id} moved to trash.")
114
+
115
+
116
+ @workbook_app.command("duplicate")
117
+ def duplicate_workbook(
118
+ workbook_id: str = typer.Argument(..., help="Workbook identifier (wb_…)."),
119
+ fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
120
+ ) -> None:
121
+ """Duplicate a workbook."""
122
+ client = get_client()
123
+ try:
124
+ wb = client.duplicate_workbook(workbook_id)
125
+ except DatabarError as e:
126
+ error(e)
127
+ finally:
128
+ client.close()
129
+ success(f"Duplicated as {wb.identifier}")
130
+ output({"id": wb.identifier, "name": wb.name, "tables": wb.tables_count}, fmt)
131
+
132
+
133
+ @workbook_app.command("merge")
134
+ def merge_workbooks(
135
+ target: str = typer.Option(..., "--target", help="Workbook that keeps the sheets."),
136
+ sources: str = typer.Option(..., "--sources", help="Comma-separated workbook ids to fold in."),
137
+ ) -> None:
138
+ """Merge source workbooks into target."""
139
+ source_ids = [s.strip() for s in sources.split(",") if s.strip()]
140
+ client = get_client()
141
+ try:
142
+ wb = client.merge_workbooks(target, source_ids)
143
+ except DatabarError as e:
144
+ error(e)
145
+ finally:
146
+ client.close()
147
+ success(f"Merged into {wb.identifier} ({wb.tables_count} sheets)")
148
+
149
+
150
+ @workbook_app.command("add-table")
151
+ def add_workbook_table(
152
+ workbook_id: str = typer.Argument(..., help="Workbook identifier (wb_…)."),
153
+ name: Optional[str] = typer.Option(None, "--name", "-n", help="Sheet name."),
154
+ ) -> None:
155
+ """Add an empty sheet to a workbook."""
156
+ client = get_client()
157
+ try:
158
+ table = client.add_workbook_table(workbook_id, name=name)
159
+ except DatabarError as e:
160
+ error(e)
161
+ finally:
162
+ client.close()
163
+ success(f"Added table {table.get('identifier')}")
164
+
165
+
166
+ @trash_app.command("list")
167
+ def list_trash(
168
+ fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
169
+ ) -> None:
170
+ """List items in Trash."""
171
+ client = get_client()
172
+ try:
173
+ items = client.list_trash()
174
+ except DatabarError as e:
175
+ error(e)
176
+ finally:
177
+ client.close()
178
+
179
+ if not items:
180
+ info("Trash is empty.")
181
+ output([], fmt)
182
+ return
183
+
184
+ rows = [
185
+ {
186
+ "kind": i.kind,
187
+ "id": i.identifier,
188
+ "name": i.name,
189
+ "trashed_at": i.trashed_at,
190
+ }
191
+ for i in items
192
+ ]
193
+ output(rows, fmt, table_columns=["kind", "id", "name", "trashed_at"])
194
+
195
+
196
+ @trash_app.command("restore")
197
+ def restore_trash(
198
+ workbooks: Optional[str] = typer.Option(None, "--workbooks", help="Comma-separated workbook ids."),
199
+ tables: Optional[str] = typer.Option(None, "--tables", help="Comma-separated table UUIDs."),
200
+ ) -> None:
201
+ """Restore workbooks and/or tables from Trash."""
202
+ wb_ids = [s.strip() for s in (workbooks or "").split(",") if s.strip()]
203
+ table_ids = [s.strip() for s in (tables or "").split(",") if s.strip()]
204
+ if not wb_ids and not table_ids:
205
+ error("Pass --workbooks and/or --tables.")
206
+ client = get_client()
207
+ try:
208
+ client.restore_trash(workbooks=wb_ids, tables=table_ids)
209
+ except DatabarError as e:
210
+ error(e)
211
+ finally:
212
+ client.close()
213
+ success("Restored.")
214
+
215
+
216
+ @trash_app.command("purge")
217
+ def purge_trash(
218
+ workbooks: Optional[str] = typer.Option(None, "--workbooks", help="Comma-separated workbook ids."),
219
+ tables: Optional[str] = typer.Option(None, "--tables", help="Comma-separated table UUIDs."),
220
+ ) -> None:
221
+ """Permanently delete workbooks and/or tables from Trash."""
222
+ wb_ids = [s.strip() for s in (workbooks or "").split(",") if s.strip()]
223
+ table_ids = [s.strip() for s in (tables or "").split(",") if s.strip()]
224
+ if not wb_ids and not table_ids:
225
+ error("Pass --workbooks and/or --tables.")
226
+ client = get_client()
227
+ try:
228
+ client.purge_trash(workbooks=wb_ids, tables=table_ids)
229
+ except DatabarError as e:
230
+ error(e)
231
+ finally:
232
+ client.close()
233
+ success("Purged.")
@@ -65,10 +65,12 @@ from .models import (
65
65
  Connector,
66
66
  CreateColumnResponse,
67
67
  DedupeOptions,
68
+ DedupeResult,
68
69
  Enrichment,
69
70
  EnrichmentListResponse,
70
71
  EnrichmentSummary,
71
72
  Exporter,
73
+ ExportStatus,
72
74
  ExporterDetail,
73
75
  ExporterListResponse,
74
76
  ExporterParam,
@@ -93,10 +95,12 @@ from .models import (
93
95
  Table,
94
96
  TableEnrichment,
95
97
  TaskResponse,
98
+ TrashItem,
96
99
  UpsertResponse,
97
100
  UpsertRow,
98
101
  User,
99
102
  Waterfall,
103
+ Workbook,
100
104
  )
101
105
 
102
106
  DEFAULT_BASE_URL = "https://api.databar.ai/v1"
@@ -223,6 +227,18 @@ class DatabarClient:
223
227
  status_code=status,
224
228
  response_body=body,
225
229
  )
230
+ if status in (400, 422) and isinstance(body, dict) and isinstance(body.get("error"), str):
231
+ detail = body.get("detail")
232
+ message = detail if isinstance(detail, str) and detail else body["error"]
233
+ errors = body.get("fields")
234
+ if not isinstance(errors, list):
235
+ errors = body.get("rows") if isinstance(body.get("rows"), list) else []
236
+ raise DatabarValidationError(
237
+ message,
238
+ errors=errors,
239
+ status_code=status,
240
+ response_body=body,
241
+ )
226
242
  if status == 422:
227
243
  detail = body.get("detail", [])
228
244
  if isinstance(detail, list):
@@ -537,14 +553,12 @@ class DatabarClient:
537
553
  """
538
554
  Submit a waterfall run.
539
555
 
540
- If enrichments is None or empty, all available providers are used
541
- (auto-resolved from get_waterfall, same behavior as MCP).
556
+ If enrichments is None or empty, the server runs the waterfall's default
557
+ cascade: providers with ``enabled_by_default=True``, in configured order.
542
558
  """
543
- if not enrichments:
544
- waterfall = self.get_waterfall(identifier)
545
- enrichments = [e.id for e in waterfall.available_enrichments]
546
-
547
- payload: Dict[str, Any] = {"params": params, "enrichments": enrichments}
559
+ payload: Dict[str, Any] = {"params": params}
560
+ if enrichments:
561
+ payload["enrichments"] = enrichments
548
562
  if email_verifier is not None:
549
563
  payload["email_verifier"] = email_verifier
550
564
 
@@ -563,12 +577,12 @@ class DatabarClient:
563
577
  The polled result is aligned to the inputs: one element per input, in the
564
578
  same order as ``params``, with ``None`` for inputs that returned no data
565
579
  (``len(result) == len(params)``, ``result[i]`` ↔ ``params[i]``).
566
- """
567
- if not enrichments:
568
- waterfall = self.get_waterfall(identifier)
569
- enrichments = [e.id for e in waterfall.available_enrichments]
570
580
 
571
- payload: Dict[str, Any] = {"params": params, "enrichments": enrichments}
581
+ If enrichments is None or empty, the server runs the default cascade.
582
+ """
583
+ payload: Dict[str, Any] = {"params": params}
584
+ if enrichments:
585
+ payload["enrichments"] = enrichments
572
586
  if email_verifier is not None:
573
587
  payload["email_verifier"] = email_verifier
574
588
 
@@ -856,6 +870,53 @@ class DatabarClient:
856
870
  data = self._request("PATCH", f"/table/{table_uuid}", json={"name": name})
857
871
  return Table.model_validate(data)
858
872
 
873
+ def duplicate_table(self, table_uuid: str) -> Table:
874
+ """Duplicate a table into a new workbook."""
875
+ data = self._request("POST", "/table/duplicate", json={"table": table_uuid})
876
+ return Table.model_validate(data)
877
+
878
+ def move_table(
879
+ self,
880
+ table_uuid: str,
881
+ *,
882
+ workbook: Optional[str] = None,
883
+ new_workbook: bool = False,
884
+ name: Optional[str] = None,
885
+ ) -> Dict[str, Any]:
886
+ """Move a table into another workbook, or into a freshly created workbook."""
887
+ payload: Dict[str, Any] = {"new_workbook": new_workbook}
888
+ if workbook is not None:
889
+ payload["workbook"] = workbook
890
+ if name is not None:
891
+ payload["name"] = name
892
+ return self._request("POST", f"/table/{table_uuid}/move", json=payload) or {}
893
+
894
+ def clear_table(self, table_uuid: str) -> Dict[str, Any]:
895
+ """Queue deletion of every row in the table."""
896
+ return self._request("POST", f"/table/{table_uuid}/clear") or {}
897
+
898
+ def export_table(self, table_uuid: str, format: str = "csv") -> ExportStatus:
899
+ """Start a table export. Poll :meth:`get_table_export` for the file URL."""
900
+ data = self._request("POST", f"/table/{table_uuid}/export", json={"format": format})
901
+ return ExportStatus.model_validate(data)
902
+
903
+ def get_table_export(self, table_uuid: str) -> ExportStatus:
904
+ """Status of the latest export for a table."""
905
+ data = self._request("GET", f"/table/{table_uuid}/export")
906
+ return ExportStatus.model_validate(data)
907
+
908
+ def dedupe_table_rows(
909
+ self,
910
+ table_uuid: str,
911
+ columns: Optional[List[str]] = None,
912
+ ) -> DedupeResult:
913
+ """Delete duplicate rows, keeping the oldest of each group."""
914
+ payload: Dict[str, Any] = {}
915
+ if columns is not None:
916
+ payload["columns"] = columns
917
+ data = self._request("POST", f"/table/{table_uuid}/rows/dedupe", json=payload or None)
918
+ return DedupeResult.model_validate(data)
919
+
859
920
  # -----------------------------------------------------------------------
860
921
  # Tables — Columns
861
922
  # -----------------------------------------------------------------------
@@ -906,6 +967,17 @@ class DatabarClient:
906
967
  """Delete a column from a table."""
907
968
  self._request("DELETE", f"/table/{table_uuid}/columns/{column_id}")
908
969
 
970
+ def reorder_column(self, table_uuid: str, column_id: str, index: int) -> Dict[str, Any]:
971
+ """Move a column to a new 0-based index among non-system columns."""
972
+ return (
973
+ self._request(
974
+ "POST",
975
+ f"/table/{table_uuid}/columns/{column_id}/reorder",
976
+ json={"index": index},
977
+ )
978
+ or {}
979
+ )
980
+
909
981
  # -----------------------------------------------------------------------
910
982
  # Tables — Enrichments
911
983
  # -----------------------------------------------------------------------
@@ -972,6 +1044,27 @@ class DatabarClient:
972
1044
  data = self._request("POST", f"/table/{table_uuid}/add-enrichment", json=payload)
973
1045
  return AddEnrichmentResponse.model_validate(data)
974
1046
 
1047
+ def update_enrichment(
1048
+ self,
1049
+ table_uuid: str,
1050
+ enrichment_id: int,
1051
+ *,
1052
+ mapping: Optional[Dict[str, Any]] = None,
1053
+ launch_strategy: Optional[Literal["run_on_click", "run_on_update"]] = None,
1054
+ ) -> AddEnrichmentResponse:
1055
+ """Update the mapping and/or launch strategy of an attached enrichment."""
1056
+ payload: Dict[str, Any] = {}
1057
+ if mapping is not None:
1058
+ payload["mapping"] = mapping
1059
+ if launch_strategy is not None:
1060
+ payload["launch_strategy"] = launch_strategy
1061
+ data = self._request(
1062
+ "PATCH",
1063
+ f"/table/{table_uuid}/enrichments/{enrichment_id}",
1064
+ json=payload,
1065
+ )
1066
+ return AddEnrichmentResponse.model_validate(data)
1067
+
975
1068
  def run_table_enrichment(
976
1069
  self,
977
1070
  table_uuid: str,
@@ -1007,8 +1100,8 @@ class DatabarClient:
1007
1100
  self,
1008
1101
  table_uuid: str,
1009
1102
  waterfall_identifier: str,
1010
- enrichments: List[int],
1011
- mapping: Dict[str, str],
1103
+ enrichments: Optional[List[int]] = None,
1104
+ mapping: Optional[Dict[str, str]] = None,
1012
1105
  email_verifier: Optional[int] = None,
1013
1106
  ) -> AddWaterfallResponse:
1014
1107
  """
@@ -1017,20 +1110,24 @@ class DatabarClient:
1017
1110
  Args:
1018
1111
  table_uuid: UUID of the table.
1019
1112
  waterfall_identifier: Waterfall slug (e.g. 'email_getter').
1020
- enrichments: List of enrichment (provider) IDs to use in the cascade.
1021
- mapping: Maps waterfall parameter names to column UUIDs or column names.
1022
- The API resolves names to UUIDs automatically.
1113
+ enrichments: Optional provider IDs, in cascade order. If None or empty,
1114
+ the server attaches the default cascade (providers with
1115
+ ``enabled_by_default=True``).
1116
+ mapping: Required. Maps waterfall parameter names to column UUIDs or
1117
+ column names. The API resolves names to UUIDs automatically.
1023
1118
  email_verifier: Optional enrichment ID for email verification.
1024
1119
 
1025
1120
  Returns:
1026
1121
  :class:`AddWaterfallResponse` with ``id`` and ``waterfall_name``.
1027
1122
  Use ``id`` with run_table_enrichment().
1028
1123
  """
1029
- payload: Dict[str, Any] = {
1030
- "waterfall": waterfall_identifier,
1031
- "enrichments": enrichments,
1032
- "mapping": mapping,
1033
- }
1124
+ # ponytail: mapping keeps its positional slot after enrichments so existing
1125
+ # positional callers don't break, hence the default + runtime check.
1126
+ if mapping is None:
1127
+ raise TypeError("add_waterfall() missing required argument: 'mapping'")
1128
+ payload: Dict[str, Any] = {"waterfall": waterfall_identifier, "mapping": mapping}
1129
+ if enrichments:
1130
+ payload["enrichments"] = enrichments
1034
1131
  if email_verifier is not None:
1035
1132
  payload["email_verifier"] = email_verifier
1036
1133
  data = self._request("POST", f"/table/{table_uuid}/add-waterfall", json=payload)
@@ -1417,3 +1514,93 @@ class DatabarClient:
1417
1514
  payload["folder_id"] = folder_id
1418
1515
  data = self._request("POST", "/folders/move-table", json=payload)
1419
1516
  return data or {}
1517
+
1518
+ # -----------------------------------------------------------------------
1519
+ # Workbooks
1520
+ # -----------------------------------------------------------------------
1521
+
1522
+ def list_workbooks(self) -> List[Workbook]:
1523
+ """List workbooks (multi-sheet documents) in the workspace."""
1524
+ data = self._request("GET", "/workbooks")
1525
+ return [Workbook.model_validate(w) for w in data]
1526
+
1527
+ def get_workbook(self, workbook_id: str) -> Workbook:
1528
+ """Get one workbook and its sheets."""
1529
+ data = self._request("GET", f"/workbooks/{workbook_id}")
1530
+ return Workbook.model_validate(data)
1531
+
1532
+ def rename_workbook(self, workbook_id: str, name: str) -> Workbook:
1533
+ """Rename a workbook."""
1534
+ data = self._request("PATCH", f"/workbooks/{workbook_id}", json={"name": name})
1535
+ return Workbook.model_validate(data)
1536
+
1537
+ def delete_workbook(self, workbook_id: str) -> None:
1538
+ """Move a workbook to Trash."""
1539
+ self._request("DELETE", f"/workbooks/{workbook_id}")
1540
+
1541
+ def duplicate_workbook(self, workbook_id: str) -> Workbook:
1542
+ """Duplicate every sheet in a workbook into a new document."""
1543
+ data = self._request("POST", f"/workbooks/{workbook_id}/duplicate")
1544
+ return Workbook.model_validate(data)
1545
+
1546
+ def merge_workbooks(self, target: str, sources: List[str]) -> Workbook:
1547
+ """Move every live table from source workbooks onto target."""
1548
+ data = self._request("POST", "/workbooks/merge", json={"target": target, "sources": sources})
1549
+ return Workbook.model_validate(data)
1550
+
1551
+ def add_workbook_table(self, workbook_id: str, name: Optional[str] = None) -> Dict[str, Any]:
1552
+ """Add an empty sheet to a workbook."""
1553
+ payload: Dict[str, Any] = {}
1554
+ if name is not None:
1555
+ payload["name"] = name
1556
+ return self._request("POST", f"/workbooks/{workbook_id}/tables", json=payload or None) or {}
1557
+
1558
+ def reorder_workbook_tables(self, workbook_id: str, table_ids: List[str]) -> Workbook:
1559
+ """Set sheet order. ``table_ids`` must list every live table exactly once."""
1560
+ data = self._request(
1561
+ "POST",
1562
+ f"/workbooks/{workbook_id}/tables/reorder",
1563
+ json={"table_ids": table_ids},
1564
+ )
1565
+ return Workbook.model_validate(data)
1566
+
1567
+ # -----------------------------------------------------------------------
1568
+ # Trash
1569
+ # -----------------------------------------------------------------------
1570
+
1571
+ def list_trash(self) -> List[TrashItem]:
1572
+ """List binned workbooks and tables."""
1573
+ data = self._request("GET", "/trash")
1574
+ return [TrashItem.model_validate(i) for i in data]
1575
+
1576
+ def restore_trash(
1577
+ self,
1578
+ *,
1579
+ workbooks: Optional[List[str]] = None,
1580
+ tables: Optional[List[str]] = None,
1581
+ ) -> Dict[str, Any]:
1582
+ """Restore workbooks and/or tables from Trash."""
1583
+ return (
1584
+ self._request(
1585
+ "POST",
1586
+ "/trash/restore",
1587
+ json={"workbooks": workbooks or [], "tables": tables or []},
1588
+ )
1589
+ or {}
1590
+ )
1591
+
1592
+ def purge_trash(
1593
+ self,
1594
+ *,
1595
+ workbooks: Optional[List[str]] = None,
1596
+ tables: Optional[List[str]] = None,
1597
+ ) -> Dict[str, Any]:
1598
+ """Permanently delete workbooks and/or tables from Trash."""
1599
+ return (
1600
+ self._request(
1601
+ "POST",
1602
+ "/trash/delete-forever",
1603
+ json={"workbooks": workbooks or [], "tables": tables or []},
1604
+ )
1605
+ or {}
1606
+ )
@@ -59,7 +59,12 @@ class DatabarGoneError(DatabarError):
59
59
 
60
60
 
61
61
  class DatabarValidationError(DatabarError):
62
- """Raised on 422 — request body failed schema validation."""
62
+ """Raised when the API rejected the input.
63
+
64
+ 400 is a business-rule failure (unknown column, bad enrichment param).
65
+ 422 is a schema failure (wrong JSON shape). Both use the same body:
66
+ ``{"error": "<CODE>", "detail": "<string>"}``.
67
+ """
63
68
 
64
69
  def __init__(
65
70
  self,
@@ -301,6 +301,8 @@ class WaterfallEnrichment(BaseModel):
301
301
  description: str
302
302
  price: Union[str, float]
303
303
  params: List[str]
304
+ # False = optional add-on, run only when its id is passed explicitly.
305
+ enabled_by_default: bool = True
304
306
 
305
307
 
306
308
  class Waterfall(BaseModel):
@@ -501,7 +503,7 @@ class RestoreFlowVersionResult(BaseModel):
501
503
  class Table(BaseModel):
502
504
  """A Databar table.
503
505
 
504
- Fields: identifier, name, created_at, updated_at, workspace_identifier, table_url.
506
+ Fields: identifier, name, created_at, updated_at, workspace_identifier, workbook, table_url.
505
507
 
506
508
  Property aliases: .id → .identifier, .uuid → .identifier.
507
509
 
@@ -516,6 +518,7 @@ class Table(BaseModel):
516
518
  created_at: str
517
519
  updated_at: str
518
520
  workspace_identifier: Optional[str] = None
521
+ workbook: Optional[str] = Field(None, description="Parent workbook identifier (wb_…).")
519
522
  table_url: Optional[str] = None
520
523
 
521
524
  @property
@@ -907,3 +910,56 @@ class Folder(BaseModel):
907
910
  created_at: Optional[str] = None
908
911
  updated_at: Optional[str] = None
909
912
  table_count: Optional[int] = None
913
+
914
+
915
+ # ===========================================================================
916
+ # Workbooks
917
+ # ===========================================================================
918
+
919
+
920
+ class WorkbookTable(BaseModel):
921
+ """One sheet inside a workbook."""
922
+
923
+ identifier: str
924
+ name: str
925
+ position: int
926
+
927
+
928
+ class Workbook(BaseModel):
929
+ """A multi-sheet document that owns one or more tables.
930
+
931
+ Fields: identifier, name, created_at, updated_at, folder_id, tables, tables_count.
932
+ """
933
+
934
+ identifier: str
935
+ name: str
936
+ created_at: str
937
+ updated_at: str
938
+ folder_id: Optional[int] = None
939
+ tables: List[WorkbookTable] = Field(default_factory=list)
940
+ tables_count: int = 0
941
+
942
+ @property
943
+ def id(self) -> str:
944
+ return self.identifier
945
+
946
+
947
+ class ExportStatus(BaseModel):
948
+ status: str
949
+ file_id: Optional[int] = None
950
+ file: Optional[str] = None
951
+ message: Optional[str] = None
952
+
953
+
954
+ class DedupeResult(BaseModel):
955
+ count_all_rows: int
956
+ count_rows_delete: int
957
+
958
+
959
+ class TrashItem(BaseModel):
960
+ kind: str
961
+ identifier: str
962
+ name: str
963
+ trashed_at: Optional[str] = None
964
+ tables_count: Optional[int] = None
965
+ workbook: Optional[Dict[str, Any]] = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: databar
3
- Version: 2.6.1
3
+ Version: 2.8.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
@@ -174,7 +174,8 @@ for choice in choices.items:
174
174
  # List waterfalls
175
175
  waterfalls = client.list_waterfalls()
176
176
 
177
- # Run a waterfall (tries all providers in sequence)
177
+ # Run a waterfall (tries the default providers in sequence; optional add-ons
178
+ # such as Apollo run only when you pass their id in `enrichments`)
178
179
  result = client.run_waterfall_sync(
179
180
  "email_getter",
180
181
  {"linkedin_url": "https://linkedin.com/in/alice"},
@@ -23,7 +23,9 @@ src/databar/cli/flows.py
23
23
  src/databar/cli/tables.py
24
24
  src/databar/cli/tasks.py
25
25
  src/databar/cli/waterfalls.py
26
+ src/databar/cli/workbooks.py
26
27
  tests/test_cli.py
27
28
  tests/test_client.py
28
29
  tests/test_new_features.py
29
- tests/test_oauth_login.py
30
+ tests/test_oauth_login.py
31
+ tests/test_workbooks.py
@@ -759,7 +759,7 @@ def test_task_cancel_reports_a_finished_task(monkeypatch):
759
759
  def test_version_flag():
760
760
  result = runner.invoke(app, ["--version"])
761
761
  assert result.exit_code == 0
762
- assert "2.6.1" in result.output
762
+ assert "2.8.0" in result.output
763
763
 
764
764
 
765
765
  def test_output_module_does_not_import_click():
@@ -112,6 +112,24 @@ def test_http_error_mapping(client: DatabarClient, httpx_mock: HTTPXMock, status
112
112
  client.get_user()
113
113
 
114
114
 
115
+ def test_validation_envelope_is_a_validation_error(client: DatabarClient, httpx_mock: HTTPXMock):
116
+ httpx_mock.add_response(
117
+ url=f"{BASE_URL}/enrichments/1/run",
118
+ method="POST",
119
+ status_code=400,
120
+ json={
121
+ "error": "INVALID_PARAMS",
122
+ "detail": "Row 1: domain: This field is required.",
123
+ "rows": [{"position": 1, "fields": {"domain": ["This field is required."]}}],
124
+ },
125
+ )
126
+ with pytest.raises(DatabarValidationError) as exc:
127
+ client.run_enrichment(1, {"domain": ""})
128
+ assert exc.value.status_code == 400
129
+ assert exc.value.message == "Row 1: domain: This field is required."
130
+ assert exc.value.errors[0]["position"] == 1
131
+
132
+
115
133
  def test_retry_on_500(client: DatabarClient, httpx_mock: HTTPXMock):
116
134
  httpx_mock.add_response(url=f"{BASE_URL}/user/me", status_code=500, json={"detail": "oops"})
117
135
  httpx_mock.add_response(url=f"{BASE_URL}/user/me", status_code=500, json={"detail": "oops"})
@@ -209,14 +227,22 @@ def test_list_waterfalls(client: DatabarClient, httpx_mock: HTTPXMock):
209
227
  assert result[0].identifier == "email_getter"
210
228
 
211
229
 
212
- def test_run_waterfall_auto_resolves_providers(client: DatabarClient, httpx_mock: HTTPXMock):
213
- httpx_mock.add_response(url=f"{BASE_URL}/waterfalls/email_getter", json=waterfall_payload())
230
+ def test_run_waterfall_without_providers_leaves_the_default_to_the_server(client: DatabarClient, httpx_mock: HTTPXMock):
214
231
  httpx_mock.add_response(url=f"{BASE_URL}/waterfalls/email_getter/run", json=task_payload("processing"))
232
+ httpx_mock.add_response(url=f"{BASE_URL}/waterfalls/email_getter/bulk-run", json=task_payload("processing"))
215
233
  task = client.run_waterfall("email_getter", {"linkedin_url": "https://linkedin.com/in/alice"})
234
+ client.run_waterfall_bulk("email_getter", [{"linkedin_url": "https://linkedin.com/in/alice"}])
216
235
  assert task.task_id == "task-123"
217
- req = httpx_mock.get_requests()[-1]
218
- body = json.loads(req.content)
219
- assert body["enrichments"] == [10, 11]
236
+ # One POST each, no GET /waterfalls/{id} to resolve the provider list client-side.
237
+ requests = httpx_mock.get_requests()
238
+ assert [r.method for r in requests] == ["POST", "POST"]
239
+ assert all("enrichments" not in json.loads(r.content) for r in requests)
240
+
241
+
242
+ def test_run_waterfall_passes_explicit_providers(client: DatabarClient, httpx_mock: HTTPXMock):
243
+ httpx_mock.add_response(url=f"{BASE_URL}/waterfalls/person_getter/run", json=task_payload("processing"))
244
+ client.run_waterfall("person_getter", {"email": "a@b.com"}, enrichments=[113])
245
+ assert json.loads(httpx_mock.get_requests()[-1].content)["enrichments"] == [113]
220
246
 
221
247
 
222
248
  # ===========================================================================
@@ -333,6 +333,22 @@ def test_add_waterfall(client: DatabarClient, httpx_mock: HTTPXMock):
333
333
  assert body["email_verifier"] == 10
334
334
 
335
335
 
336
+ def test_add_waterfall_without_providers_leaves_the_default_to_the_server(client: DatabarClient, httpx_mock: HTTPXMock):
337
+ httpx_mock.add_response(
338
+ url=f"{BASE_URL}/table/tbl-1/add-waterfall",
339
+ json={"id": 56, "waterfall_name": "Person Getter"},
340
+ )
341
+ client.add_waterfall("tbl-1", waterfall_identifier="person_getter", mapping={"email": "email"})
342
+ body = json.loads(httpx_mock.get_requests()[0].content)
343
+ assert "enrichments" not in body
344
+ assert body["mapping"] == {"email": "email"}
345
+
346
+
347
+ def test_add_waterfall_requires_mapping(client: DatabarClient):
348
+ with pytest.raises(TypeError, match="mapping"):
349
+ client.add_waterfall("tbl-1", waterfall_identifier="person_getter")
350
+
351
+
336
352
  def test_get_table_waterfalls(client: DatabarClient, httpx_mock: HTTPXMock):
337
353
  httpx_mock.add_response(
338
354
  url=f"{BASE_URL}/table/tbl-1/waterfalls",
@@ -0,0 +1,90 @@
1
+ """Workbook, trash and table-operation client methods hit the routes the server serves."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+
7
+ from pytest_httpx import HTTPXMock
8
+
9
+ from databar.client import DatabarClient
10
+ from databar.models import DedupeResult, ExportStatus, TrashItem, Workbook
11
+
12
+ from .conftest import BASE_URL, table_payload
13
+
14
+
15
+ def workbook_payload(identifier: str = "wb_abc12345", **overrides) -> dict:
16
+ return {
17
+ "identifier": identifier,
18
+ "name": "Doc",
19
+ "created_at": "2026-10-06T00:00:00Z",
20
+ "updated_at": "2026-10-06T00:00:00Z",
21
+ "folder_id": None,
22
+ "tables": [{"identifier": "tbl-uuid-1", "name": "Sheet", "position": 0}],
23
+ "tables_count": 1,
24
+ **overrides,
25
+ }
26
+
27
+
28
+ def test_list_and_merge_workbooks(client: DatabarClient, httpx_mock: HTTPXMock):
29
+ httpx_mock.add_response(url=f"{BASE_URL}/workbooks", json=[workbook_payload()])
30
+ httpx_mock.add_response(url=f"{BASE_URL}/workbooks/merge", method="POST", json=workbook_payload(tables_count=2))
31
+
32
+ workbooks = client.list_workbooks()
33
+ merged = client.merge_workbooks("wb_abc12345", ["wb_other123"])
34
+
35
+ assert isinstance(workbooks[0], Workbook)
36
+ assert workbooks[0].tables[0].identifier == "tbl-uuid-1"
37
+ assert merged.tables_count == 2
38
+ assert json.loads(httpx_mock.get_requests()[1].content) == {"target": "wb_abc12345", "sources": ["wb_other123"]}
39
+
40
+
41
+ def test_table_operations(client: DatabarClient, httpx_mock: HTTPXMock):
42
+ httpx_mock.add_response(
43
+ url=f"{BASE_URL}/table/duplicate", method="POST", json=table_payload("tbl-copy", workbook="wb_new12345")
44
+ )
45
+ httpx_mock.add_response(
46
+ url=f"{BASE_URL}/table/tbl-uuid-1/export", method="POST", json={"status": "waiting", "file_id": 7}
47
+ )
48
+ httpx_mock.add_response(
49
+ url=f"{BASE_URL}/table/tbl-uuid-1/rows/dedupe",
50
+ method="POST",
51
+ json={"count_all_rows": 3, "count_rows_delete": 2},
52
+ )
53
+
54
+ copy = client.duplicate_table("tbl-uuid-1")
55
+ export = client.export_table("tbl-uuid-1", format="xlsx")
56
+ dedupe = client.dedupe_table_rows("tbl-uuid-1", columns=["col-uuid-1"])
57
+
58
+ assert copy.workbook == "wb_new12345"
59
+ assert isinstance(export, ExportStatus) and export.file_id == 7
60
+ assert isinstance(dedupe, DedupeResult) and dedupe.count_rows_delete == 2
61
+ requests = httpx_mock.get_requests()
62
+ assert json.loads(requests[0].content) == {"table": "tbl-uuid-1"}
63
+ assert json.loads(requests[1].content) == {"format": "xlsx"}
64
+ assert json.loads(requests[2].content) == {"columns": ["col-uuid-1"]}
65
+
66
+
67
+ def test_update_enrichment_sends_only_what_changed(client: DatabarClient, httpx_mock: HTTPXMock):
68
+ httpx_mock.add_response(
69
+ url=f"{BASE_URL}/table/tbl-uuid-1/enrichments/5",
70
+ method="PATCH",
71
+ json={"id": 5, "enrichment_name": "Email finder"},
72
+ )
73
+
74
+ client.update_enrichment("tbl-uuid-1", 5, launch_strategy="run_on_update")
75
+
76
+ assert json.loads(httpx_mock.get_requests()[0].content) == {"launch_strategy": "run_on_update"}
77
+
78
+
79
+ def test_trash_list_and_restore(client: DatabarClient, httpx_mock: HTTPXMock):
80
+ httpx_mock.add_response(
81
+ url=f"{BASE_URL}/trash",
82
+ json=[{"kind": "workbook", "identifier": "wb_abc12345", "name": "Doc", "tables_count": 1}],
83
+ )
84
+ httpx_mock.add_response(url=f"{BASE_URL}/trash/restore", method="POST", json={"status": "ok"})
85
+
86
+ items = client.list_trash()
87
+ client.restore_trash(workbooks=["wb_abc12345"])
88
+
89
+ assert isinstance(items[0], TrashItem) and items[0].kind == "workbook"
90
+ assert json.loads(httpx_mock.get_requests()[1].content) == {"workbooks": ["wb_abc12345"], "tables": []}
File without changes
File without changes