datalegion-cli 1.8.0__tar.gz → 1.9.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 (30) hide show
  1. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/PKG-INFO +28 -9
  2. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/README.md +27 -8
  3. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/pyproject.toml +9 -2
  4. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/commands/__init__.py +1 -1
  5. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/commands/company.py +8 -1
  6. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/commands/person.py +13 -1
  7. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_commands.py +30 -0
  8. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/.gitignore +0 -0
  9. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/LICENSE +0 -0
  10. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/__init__.py +0 -0
  11. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/async_typer.py +0 -0
  12. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/client.py +0 -0
  13. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/commands/credits.py +0 -0
  14. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/commands/utility.py +0 -0
  15. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/config.py +0 -0
  16. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/logging.py +0 -0
  17. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/login.py +0 -0
  18. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/main.py +0 -0
  19. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/output.py +0 -0
  20. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/src/datalegion_cli/update.py +0 -0
  21. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/__init__.py +0 -0
  22. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/conftest.py +0 -0
  23. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_client.py +0 -0
  24. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_config.py +0 -0
  25. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_live.py +0 -0
  26. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_logging.py +0 -0
  27. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_login.py +0 -0
  28. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_output.py +0 -0
  29. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_package_contents.py +0 -0
  30. {datalegion_cli-1.8.0 → datalegion_cli-1.9.0}/tests/test_update.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: datalegion-cli
3
- Version: 1.8.0
3
+ Version: 1.9.0
4
4
  Summary: CLI for the Data Legion API — agent-friendly, fully async
5
5
  Project-URL: Homepage, https://www.datalegion.ai
6
6
  Project-URL: Documentation, https://www.datalegion.ai/docs
@@ -37,7 +37,7 @@ Description-Content-Type: text/markdown
37
37
 
38
38
  The official command-line interface for the [Data Legion](https://www.datalegion.ai) API. Built for both humans and AI agents.
39
39
 
40
- Look up people and companies by email, phone, name, domain, LinkedIn, or ticker symbol. Search using SQL syntax. Clean, hash, and validate data fields before or after enrichment. Track credit usage and manage your configuration — all from the terminal.
40
+ Look up people and companies by email, phone, name, domain, LinkedIn, or ticker symbol. Search using SQL syntax. Clean, hash, and validate data fields before or after enrichment. Track credit usage and manage your configuration, all from the terminal.
41
41
 
42
42
  ```bash
43
43
  pip install datalegion-cli
@@ -47,12 +47,12 @@ datalegion-cli person enrich --email john@example.com
47
47
 
48
48
  ## Features
49
49
 
50
- - **Fully async** — async from entry point to HTTP client, powered by `asyncio` and `httpx`
51
- - **Agent-friendly** — all output is JSON to stdout, logs go to stderr, supports `--stdin` for piping
50
+ - **Fully async**: async from entry point to HTTP client, powered by `asyncio` and `httpx`
51
+ - **Agent-friendly**: all output is JSON to stdout, logs go to stderr, supports `--stdin` for piping
52
52
  - **Search warnings**: when `search` or `discover` flags one of your filters (for example an industry name no stored value matches), the API's explanation is printed on stderr as `search warning: ...`; stdout stays JSON
53
- - **Encrypted config** — API keys are stored encrypted at rest (Fernet + PBKDF2, machine-tied)
54
- - **Auto-update** — checks PyPI for a newer release and self-updates via Homebrew, GitHub release, git pull, or pip/uv
55
- - **Multiple install methods** — Homebrew, GitHub release, pip/uv (with private index support), or from source
53
+ - **Encrypted config**: API keys are stored encrypted at rest (Fernet + PBKDF2, machine-tied)
54
+ - **Auto-update**: checks PyPI for a newer release and self-updates via Homebrew, GitHub release, git pull, or pip/uv
55
+ - **Multiple install methods**: Homebrew, GitHub release, pip/uv (with private index support), or from source
56
56
 
57
57
  ## Installation
58
58
 
@@ -165,6 +165,9 @@ datalegion-cli person enrich --name "Jane Smith" --company "Acme Corp" --city "N
165
165
  # By LinkedIn
166
166
  datalegion-cli person enrich --social-url "https://linkedin.com/in/johndoe"
167
167
 
168
+ # By NPI (10-digit National Provider Identifier)
169
+ datalegion-cli person enrich --npi 1234567893
170
+
168
171
  # Minimum confidence
169
172
  datalegion-cli person enrich --email john@example.com --min-confidence high
170
173
 
@@ -193,6 +196,22 @@ datalegion-cli person search "SELECT * FROM people WHERE state = 'ohio'" --limit
193
196
  datalegion-cli person discover "software engineers in San Francisco who know Rust" --limit 10
194
197
  ```
195
198
 
199
+ For the next page, pass the last page's `next_cursor` with `--cursor` and the same query: it reruns the same search. Company discover takes it too.
200
+
201
+ ```bash
202
+ query="software engineers in San Francisco who know Rust"
203
+ cursor=""
204
+ while :; do
205
+ # A failed page (a 429, 402 or 403) prints its error and stops the loop
206
+ page=$(datalegion-cli person discover "$query" --limit 100 ${cursor:+--cursor} ${cursor:+"$cursor"}) || { printf '%s\n' "$page" >&2; break; }
207
+ printf '%s\n' "$page" | jq -r '.matches[].person.legion_id'
208
+ cursor=$(printf '%s\n' "$page" | jq -r '.next_cursor // empty')
209
+ [ -z "$cursor" ] && break
210
+ sleep 6 # Discover answers 10 requests a minute
211
+ done
212
+ [ -n "$cursor" ] && echo "stopped early; resume with --cursor $cursor" >&2
213
+ ```
214
+
196
215
  ### Company Enrichment
197
216
 
198
217
  ```bash
@@ -265,7 +284,7 @@ datalegion-cli version
265
284
  The CLI is designed to be called by AI agents and scripts. Key patterns:
266
285
 
267
286
  ```bash
268
- # All output is JSON to stdout — parse it directly
287
+ # All output is JSON to stdout; parse it directly
269
288
  datalegion-cli person enrich --email john@example.com | jq '.matches[0].person.full_name'
270
289
 
271
290
  # Pipe JSON payloads via stdin
@@ -281,7 +300,7 @@ datalegion-cli person enrich --email bad 2>/dev/null
281
300
 
282
301
  ## Sandbox
283
302
 
284
- Try commands without spending credits: `--sandbox` (or `LEGION_SANDBOX=1`, or `datalegion-cli config set sandbox true`) makes Enrich, Bulk Enrich, Search and Discover return sample records with every field a real record has. Utilities, which are free, still call the real API. Sandbox discover answers only a few fixed example queries.
303
+ Try commands without spending credits: `--sandbox` (or `LEGION_SANDBOX=1`, or `datalegion-cli config set sandbox true`) makes enrich, search and discover return sample records with every field a real record has. Utilities, which are free, still call the real API. Sandbox discover answers only a few fixed example queries.
285
304
 
286
305
  ```bash
287
306
  datalegion-cli --sandbox person enrich --email anyone@example.com
@@ -2,7 +2,7 @@
2
2
 
3
3
  The official command-line interface for the [Data Legion](https://www.datalegion.ai) API. Built for both humans and AI agents.
4
4
 
5
- Look up people and companies by email, phone, name, domain, LinkedIn, or ticker symbol. Search using SQL syntax. Clean, hash, and validate data fields before or after enrichment. Track credit usage and manage your configuration — all from the terminal.
5
+ Look up people and companies by email, phone, name, domain, LinkedIn, or ticker symbol. Search using SQL syntax. Clean, hash, and validate data fields before or after enrichment. Track credit usage and manage your configuration, all from the terminal.
6
6
 
7
7
  ```bash
8
8
  pip install datalegion-cli
@@ -12,12 +12,12 @@ datalegion-cli person enrich --email john@example.com
12
12
 
13
13
  ## Features
14
14
 
15
- - **Fully async** — async from entry point to HTTP client, powered by `asyncio` and `httpx`
16
- - **Agent-friendly** — all output is JSON to stdout, logs go to stderr, supports `--stdin` for piping
15
+ - **Fully async**: async from entry point to HTTP client, powered by `asyncio` and `httpx`
16
+ - **Agent-friendly**: all output is JSON to stdout, logs go to stderr, supports `--stdin` for piping
17
17
  - **Search warnings**: when `search` or `discover` flags one of your filters (for example an industry name no stored value matches), the API's explanation is printed on stderr as `search warning: ...`; stdout stays JSON
18
- - **Encrypted config** — API keys are stored encrypted at rest (Fernet + PBKDF2, machine-tied)
19
- - **Auto-update** — checks PyPI for a newer release and self-updates via Homebrew, GitHub release, git pull, or pip/uv
20
- - **Multiple install methods** — Homebrew, GitHub release, pip/uv (with private index support), or from source
18
+ - **Encrypted config**: API keys are stored encrypted at rest (Fernet + PBKDF2, machine-tied)
19
+ - **Auto-update**: checks PyPI for a newer release and self-updates via Homebrew, GitHub release, git pull, or pip/uv
20
+ - **Multiple install methods**: Homebrew, GitHub release, pip/uv (with private index support), or from source
21
21
 
22
22
  ## Installation
23
23
 
@@ -130,6 +130,9 @@ datalegion-cli person enrich --name "Jane Smith" --company "Acme Corp" --city "N
130
130
  # By LinkedIn
131
131
  datalegion-cli person enrich --social-url "https://linkedin.com/in/johndoe"
132
132
 
133
+ # By NPI (10-digit National Provider Identifier)
134
+ datalegion-cli person enrich --npi 1234567893
135
+
133
136
  # Minimum confidence
134
137
  datalegion-cli person enrich --email john@example.com --min-confidence high
135
138
 
@@ -158,6 +161,22 @@ datalegion-cli person search "SELECT * FROM people WHERE state = 'ohio'" --limit
158
161
  datalegion-cli person discover "software engineers in San Francisco who know Rust" --limit 10
159
162
  ```
160
163
 
164
+ For the next page, pass the last page's `next_cursor` with `--cursor` and the same query: it reruns the same search. Company discover takes it too.
165
+
166
+ ```bash
167
+ query="software engineers in San Francisco who know Rust"
168
+ cursor=""
169
+ while :; do
170
+ # A failed page (a 429, 402 or 403) prints its error and stops the loop
171
+ page=$(datalegion-cli person discover "$query" --limit 100 ${cursor:+--cursor} ${cursor:+"$cursor"}) || { printf '%s\n' "$page" >&2; break; }
172
+ printf '%s\n' "$page" | jq -r '.matches[].person.legion_id'
173
+ cursor=$(printf '%s\n' "$page" | jq -r '.next_cursor // empty')
174
+ [ -z "$cursor" ] && break
175
+ sleep 6 # Discover answers 10 requests a minute
176
+ done
177
+ [ -n "$cursor" ] && echo "stopped early; resume with --cursor $cursor" >&2
178
+ ```
179
+
161
180
  ### Company Enrichment
162
181
 
163
182
  ```bash
@@ -230,7 +249,7 @@ datalegion-cli version
230
249
  The CLI is designed to be called by AI agents and scripts. Key patterns:
231
250
 
232
251
  ```bash
233
- # All output is JSON to stdout — parse it directly
252
+ # All output is JSON to stdout; parse it directly
234
253
  datalegion-cli person enrich --email john@example.com | jq '.matches[0].person.full_name'
235
254
 
236
255
  # Pipe JSON payloads via stdin
@@ -246,7 +265,7 @@ datalegion-cli person enrich --email bad 2>/dev/null
246
265
 
247
266
  ## Sandbox
248
267
 
249
- Try commands without spending credits: `--sandbox` (or `LEGION_SANDBOX=1`, or `datalegion-cli config set sandbox true`) makes Enrich, Bulk Enrich, Search and Discover return sample records with every field a real record has. Utilities, which are free, still call the real API. Sandbox discover answers only a few fixed example queries.
268
+ Try commands without spending credits: `--sandbox` (or `LEGION_SANDBOX=1`, or `datalegion-cli config set sandbox true`) makes enrich, search and discover return sample records with every field a real record has. Utilities, which are free, still call the real API. Sandbox discover answers only a few fixed example queries.
250
269
 
251
270
  ```bash
252
271
  datalegion-cli --sandbox person enrich --email anyone@example.com
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datalegion-cli"
3
- version = "1.8.0"
3
+ version = "1.9.0"
4
4
  description = "CLI for the Data Legion API — agent-friendly, fully async"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -103,5 +103,12 @@ ignore = [
103
103
  known-first-party = ["datalegion_cli"]
104
104
 
105
105
  [tool.pytest.ini_options]
106
+ asyncio_default_fixture_loop_scope = "function"
106
107
  asyncio_mode = "auto"
107
- testpaths = ["tests"]
108
+ testpaths = ["tests"]
109
+
110
+ [tool.uv]
111
+ # 0.11.8 writes the lock's sentinel form for a relative exclude-newer (below).
112
+ required-version = ">=0.11.8"
113
+ # The fleet's one-day cooldown: no release under 24 h old is resolved, by any uv command here.
114
+ exclude-newer = "1 day"
@@ -11,7 +11,7 @@ CursorOpt = Annotated[
11
11
  str | None,
12
12
  typer.Option(
13
13
  "--cursor",
14
- help="The previous page's next_cursor, for deep paging (instead of an offset).",
14
+ help="The previous page's next_cursor, with the same query, for the next page (search: in place of --offset).",
15
15
  ),
16
16
  ]
17
17
 
@@ -149,16 +149,23 @@ async def search(
149
149
  async def discover(
150
150
  query: Annotated[str, typer.Argument(help="Natural language company search query.")],
151
151
  limit: LimitOpt = 1,
152
+ cursor: CursorOpt = None,
152
153
  titlecase: TitleOpt = False,
153
154
  include_fields: FieldsInclude = None,
154
155
  exclude_fields: FieldsExclude = None,
155
156
  ) -> None:
156
- """Search for companies using natural language (Beta)."""
157
+ """Search for companies using natural language (Beta).
158
+
159
+ For the next page, pass the previous page's next_cursor as --cursor with the same query: it reruns the same search.
160
+
161
+ datalegion-cli company discover "banks in Ohio" --limit 100 --cursor <next_cursor>
162
+ """
157
163
  client = LegionClient()
158
164
  try:
159
165
  result = await client.company_discover(
160
166
  query=query,
161
167
  limit=limit,
168
+ cursor=cursor,
162
169
  titlecase=titlecase,
163
170
  include_fields=include_fields,
164
171
  exclude_fields=exclude_fields,
@@ -53,6 +53,9 @@ async def enrich(
53
53
  email_hash: Annotated[
54
54
  str | None, typer.Option("--email-hash", help="SHA-256/SHA-1/MD5 email hash.")
55
55
  ] = None,
56
+ npi: Annotated[
57
+ str | None, typer.Option("--npi", help="10-digit National Provider Identifier.")
58
+ ] = None,
56
59
  full_name: Annotated[str | None, typer.Option("--name", "-n", help="Full name.")] = None,
57
60
  first_name: Annotated[str | None, typer.Option("--first-name", help="First name.")] = None,
58
61
  last_name: Annotated[str | None, typer.Option("--last-name", help="Last name.")] = None,
@@ -83,6 +86,7 @@ async def enrich(
83
86
  Examples:
84
87
  datalegion-cli person enrich --email john@example.com
85
88
  datalegion-cli person enrich --name "Jane Doe" --company "Acme Corp"
89
+ datalegion-cli person enrich --npi 1234567893
86
90
  datalegion-cli person enrich --phone "+14155551234" --fields "full_name,work_email,job_title"
87
91
  echo '{"email":"jane@example.com"}' | datalegion-cli person enrich --stdin
88
92
  """
@@ -96,6 +100,7 @@ async def enrich(
96
100
  social_url=social_url,
97
101
  legion_id=legion_id,
98
102
  email_hash=email_hash,
103
+ npi=npi,
99
104
  full_name=full_name,
100
105
  first_name=first_name,
101
106
  last_name=last_name,
@@ -174,16 +179,23 @@ async def search(
174
179
  async def discover(
175
180
  query: Annotated[str, typer.Argument(help="Natural language search query.")],
176
181
  limit: LimitOpt = 1,
182
+ cursor: CursorOpt = None,
177
183
  titlecase: TitleOpt = False,
178
184
  include_fields: FieldsInclude = None,
179
185
  exclude_fields: FieldsExclude = None,
180
186
  ) -> None:
181
- """Search for people using natural language (Beta)."""
187
+ """Search for people using natural language (Beta).
188
+
189
+ For the next page, pass the previous page's next_cursor as --cursor with the same query: it reruns the same search.
190
+
191
+ datalegion-cli person discover "nurses in Ohio" --limit 100 --cursor <next_cursor>
192
+ """
182
193
  client = LegionClient()
183
194
  try:
184
195
  result = await client.person_discover(
185
196
  query=query,
186
197
  limit=limit,
198
+ cursor=cursor,
187
199
  titlecase=titlecase,
188
200
  include_fields=include_fields,
189
201
  exclude_fields=exclude_fields,
@@ -135,6 +135,20 @@ class TestPersonEnrich:
135
135
  )
136
136
  assert result.exit_code == 0
137
137
 
138
+ def test_enrich_by_npi_sends_it(self, monkeypatch):
139
+ _mock_config(monkeypatch)
140
+ sent = {}
141
+
142
+ async def fake_request(self, method, endpoint, *, payload=None, params=None):
143
+ sent.update(endpoint=endpoint, payload=payload)
144
+ return {"matches": [{"full_name": "Jane Smith"}]}
145
+
146
+ with patch("datalegion_cli.client.LegionClient.request", fake_request):
147
+ result = runner.invoke(app, ["person", "enrich", "--npi", "1234567893"])
148
+ assert result.exit_code == 0, result.output
149
+ assert sent["endpoint"].endswith("/person/enrich")
150
+ assert sent["payload"]["npi"] == "1234567893"
151
+
138
152
  def test_enrich_stdin(self, monkeypatch):
139
153
  _mock_config(monkeypatch)
140
154
  response = {"matches": [{"full_name": "Bob"}], "total": 1}
@@ -187,6 +201,22 @@ class TestSearchQueryObjectAndCursor:
187
201
  assert sent[0]["cursor"] == "abc"
188
202
  assert json.loads(result.stdout)["next_cursor"] == "abc"
189
203
 
204
+ @pytest.mark.parametrize("entity", ["person", "company"])
205
+ def test_discover_sends_the_cursor_and_prints_next_cursor(self, monkeypatch, entity):
206
+ _mock_config(monkeypatch)
207
+ sent = []
208
+
209
+ async def fake_request(self, method, endpoint, *, payload=None, params=None):
210
+ sent.append((endpoint, payload))
211
+ return {"matches": [], "total": 0, "next_cursor": "def", "generated_query": "SELECT 1"}
212
+
213
+ monkeypatch.setattr("datalegion_cli.client.LegionClient.request", fake_request)
214
+ result = runner.invoke(app, [entity, "discover", "nurses in Ohio", "--cursor", "abc"])
215
+ assert result.exit_code == 0, result.output
216
+ assert sent[0][0] == f"/{entity}/discover"
217
+ assert sent[0][1]["query"] == "nurses in Ohio" and sent[0][1]["cursor"] == "abc"
218
+ assert json.loads(result.stdout)["next_cursor"] == "def"
219
+
190
220
  def test_a_query_that_looks_like_json_but_does_not_parse_is_refused(self, monkeypatch):
191
221
  _mock_config(monkeypatch)
192
222
  result = runner.invoke(app, ["person", "search", "{not json"])
File without changes