vortex-cli 8.6.0__tar.gz → 8.7.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 (62) hide show
  1. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/PKG-INFO +1 -1
  2. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/pyproject.toml +1 -1
  3. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/webdesign.py +79 -21
  4. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex_cli.egg-info/PKG-INFO +1 -1
  5. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/LICENSE +0 -0
  6. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/README.md +0 -0
  7. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/setup.cfg +0 -0
  8. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/__init__.py +0 -0
  9. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/__main__.py +0 -0
  10. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/cli.py +0 -0
  11. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/colour.py +0 -0
  12. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/__init__.py +0 -0
  13. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/agenda.py +0 -0
  14. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/app.py +0 -0
  15. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/clean.py +0 -0
  16. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/clone.py +0 -0
  17. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/code.py +0 -0
  18. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/compile.py +0 -0
  19. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/db.py +0 -0
  20. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/diff.py +0 -0
  21. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/docs.py +0 -0
  22. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/execute.py +0 -0
  23. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/fetch.py +0 -0
  24. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/file.py +0 -0
  25. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/info.py +0 -0
  26. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/keyword.py +0 -0
  27. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/libs.py +0 -0
  28. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/log.py +0 -0
  29. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/object_.py +0 -0
  30. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/pull.py +0 -0
  31. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/search.py +0 -0
  32. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/servers.py +0 -0
  33. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/stats.py +0 -0
  34. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/use.py +0 -0
  35. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/watch.py +0 -0
  36. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/commands/weblog.py +0 -0
  37. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/constants.py +0 -0
  38. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/docs/Blackbook v2.md +0 -0
  39. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/docs/Blackbook.pdf +0 -0
  40. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/docs/index.html +0 -0
  41. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/docs/marked.min.js +0 -0
  42. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/git.py +0 -0
  43. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/lib/puakma-6.0.40.jar +0 -0
  44. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/libs.py +0 -0
  45. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/logging.py +0 -0
  46. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/main.py +0 -0
  47. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/models.py +0 -0
  48. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/output.py +0 -0
  49. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/registry.py +0 -0
  50. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/schedule.py +0 -0
  51. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/server_options.py +0 -0
  52. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/session_store.py +0 -0
  53. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/soap.py +0 -0
  54. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/spinner.py +0 -0
  55. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/sync.py +0 -0
  56. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/util.py +0 -0
  57. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex/workspace.py +0 -0
  58. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex_cli.egg-info/SOURCES.txt +0 -0
  59. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex_cli.egg-info/dependency_links.txt +0 -0
  60. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex_cli.egg-info/entry_points.txt +0 -0
  61. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex_cli.egg-info/requires.txt +0 -0
  62. {vortex_cli-8.6.0 → vortex_cli-8.7.0}/vortex_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vortex_cli
3
- Version: 8.6.0
3
+ Version: 8.7.0
4
4
  Summary: Vortex CLI
5
5
  Author-email: Jordan Amos <jordan.amos@gmail.com>
6
6
  License: MIT License
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "vortex_cli"
8
- version = "8.6.0"
8
+ version = "8.7.0"
9
9
  description = "Vortex CLI"
10
10
  requires-python = ">=3.10"
11
11
  readme = { file = "README.md", content-type = "text/markdown" }
@@ -13,7 +13,7 @@ the requests go, explicitly - there is no probe and no fallback:
13
13
  guards.
14
14
 
15
15
  The gateway is webdesign's vortex API at a different base URL: everything
16
- after `api` - the path, method, `Data` form body and reply - is
16
+ after `api` - the path, method, JSON body and reply - is
17
17
  webdesign's own. It adds three things:
18
18
 
19
19
  - Role checks. A route the gateway does not map, or a caller without the
@@ -45,11 +45,17 @@ Behaviour compensated for here:
45
45
  - Design params, app params and a keyword's values are snapshots: each
46
46
  PUT replaces the whole set.
47
47
  - DELETE answers the plain string "Success", not JSON.
48
- - webdesign's own errors are plain text: 404 "Api does not exist: ..."
49
- means the route is missing (old webdesign); any other 404 is a
50
- not-found; 500 carries the server's error string. An identity the
51
- server does not accept gets a login page with HTTP 200 - detected by
52
- content.
48
+ - webdesign's own errors come in two shapes. The original vortex action
49
+ (webdesign 4.1 and older) answers plain text: 404 "Api does not
50
+ exist: ..." means the route is missing; any other 404 is a not-found;
51
+ 500 carries the server's error string. The JSONActionRunner action
52
+ (webdesign 4.2, Puakma 6.2) answers {"status", "error", "message"}
53
+ with a real status - 400 for a bad id or body, 405 for a wrong verb,
54
+ 404 "No API endpoint matches ..." for a missing route. An identity
55
+ the server does not accept gets a login page with HTTP 200 - detected
56
+ by content.
57
+ - Bodies are raw application/json. The JSONActionRunner action cannot
58
+ read a form field; the original one reads either.
53
59
  - Keywords have no upsert: find-by-name, create-or-update and the
54
60
  consolidation of duplicate KEYWORD rows happen client-side
55
61
  (upsert_keyword).
@@ -119,7 +125,14 @@ REQUEST_TIMEOUT_SECONDS = 30
119
125
  # object run waits for the action to finish (prod's Cloudflare still cuts at ~100s)
120
126
  RUN_TIMEOUT_SECONDS = 300
121
127
 
122
- _ROUTE_MISSING = "Api does not exist"
128
+ # What webdesign says for a route it does not serve: the plain-text 404 of
129
+ # the original vortex action, and the JSON 404 message of the
130
+ # JSONActionRunner one (Puakma 6.2 / webdesign 4.2)
131
+ _ROUTE_MISSING = ("Api does not exist", "No API endpoint matches")
132
+ # The JSONActionRunner action behind a gateway older than 0.5.2 / 0.3.1: the
133
+ # forwarded path keeps its "vortex" prefix, so every route is "missing"
134
+ _GATEWAY_PATH_MISREAD = re.compile(r"No API endpoint matches \w+ /vortex(/|$)")
135
+ _NOT_JSON = object()
123
136
 
124
137
 
125
138
  class WebDesignError(Exception):
@@ -317,23 +330,44 @@ def _parse(
317
330
  refused = _refusal(resp, url)
318
331
  if refused is not None:
319
332
  raise refused
320
- if resp.status_code == 404:
333
+ status = resp.status_code
334
+ # parsed once: a whole-application reply is one large object
335
+ reply: Any = _NOT_JSON
336
+ if text[:64].lstrip().startswith("{"):
337
+ try:
338
+ reply = json.loads(text)
339
+ except (json.JSONDecodeError, ValueError):
340
+ pass
341
+ runner_error = _runner_error(reply)
342
+ if runner_error is not None:
343
+ # webdesign's own status wins: a gateway that predates the
344
+ # JSONActionRunner webdesign hands its error body back as a 200
345
+ status, text = runner_error
346
+ if status == 404:
347
+ if _GATEWAY_PATH_MISREAD.match(text):
348
+ raise WebDesignUnavailable(
349
+ f"HTTP 404 from {url}: webdesign read the gateway's forwarded "
350
+ "path as a route of its own - this webdesign (4.2, Puakma 6.2) "
351
+ "needs a newer vortex gateway (update the gateway app)"
352
+ )
321
353
  if text.startswith(_ROUTE_MISSING):
322
354
  raise WebDesignUnavailable(
323
355
  f"HTTP 404 from {url}: webdesign does not serve this vortex "
324
356
  "route (update system/webdesign)"
325
357
  )
326
358
  raise WebDesignError(text.strip() or f"HTTP 404 from {url}", "NOT_FOUND")
327
- if 300 <= resp.status_code < 400:
359
+ if 300 <= status < 400:
328
360
  redirect = _https_redirect(resp, url, server_name)
329
361
  if redirect is not None:
330
362
  raise WebDesignUnavailable(redirect, "UNAVAILABLE")
331
363
  # Puakma redirects an unauthenticated request to its login page
332
364
  raise WebDesignUnavailable(access_hint, "FORBIDDEN")
333
- if resp.status_code in (401, 403):
365
+ if status in (401, 403):
334
366
  raise WebDesignUnavailable(access_hint, "FORBIDDEN")
335
- if resp.status_code != 200:
336
- raise WebDesignError(f"HTTP {resp.status_code} from {url}: {text.strip()}")
367
+ if status != 200:
368
+ raise WebDesignError(f"HTTP {status} from {url}: {text.strip()}")
369
+ if reply is not _NOT_JSON:
370
+ return reply
337
371
  stripped = text.strip()
338
372
  if stripped == "Success":
339
373
  return stripped
@@ -347,6 +381,25 @@ def _parse(
347
381
  ) from None
348
382
 
349
383
 
384
+ def _runner_error(reply: Any) -> tuple[int, str] | None:
385
+ """
386
+ (status, message) when reply is the error body of webdesign's
387
+ JSONActionRunner vortex action (Puakma 6.2 / webdesign 4.2):
388
+ {"status": 404, "error": "Not Found", "message": "..."} - exactly
389
+ those keys, so no successful reply can be mistaken for one. The
390
+ original action answered errors as plain text instead.
391
+ """
392
+ if not isinstance(reply, dict) or not set(reply) <= {"status", "error", "message"}:
393
+ return None
394
+ status, reason = reply.get("status"), reply.get("error")
395
+ if isinstance(status, bool) or not isinstance(status, int) or status < 400:
396
+ return None
397
+ if not isinstance(reason, str):
398
+ return None
399
+ message = reply.get("message")
400
+ return status, message if isinstance(message, str) and message else reason
401
+
402
+
350
403
  def to_int(value: Any) -> int:
351
404
  """An id/number from a reply - getJSON() sends numeric columns as doubles."""
352
405
  return int(float(value))
@@ -410,7 +463,7 @@ class WebDesignClient:
410
463
  logger.debug(f"{method} {url}")
411
464
  try:
412
465
  resp = self.server._client.request(
413
- method, url, data=_form(body), params=params, timeout=timeout
466
+ method, url, params=params, timeout=timeout, **_json_body(body)
414
467
  )
415
468
  except httpx.HTTPError as e:
416
469
  raise WebDesignUnavailable(f"request failed: {e} ({url})") from e
@@ -427,7 +480,7 @@ class WebDesignClient:
427
480
  logger.debug(f"{method} {url}")
428
481
  try:
429
482
  resp = await self.server._aclient.request(
430
- method, url, data=_form(body), timeout=timeout
483
+ method, url, timeout=timeout, **_json_body(body)
431
484
  )
432
485
  except httpx.HTTPError as e:
433
486
  raise WebDesignUnavailable(f"request failed: {e} ({url})") from e
@@ -797,16 +850,21 @@ class WebDesignClient:
797
850
  raise WebDesignError(f"delete of column {column_id}: {reply}")
798
851
 
799
852
 
800
- def _form(body: Any) -> dict[str, str] | None:
853
+ def _json_body(body: Any) -> dict[str, Any]:
801
854
  """
802
- The action reads its JSON body from one form field, 'Data'. The
803
- server fills that item completely only for a form-encoded POST - a
804
- raw application/json body over ~512 KB arrives EMPTY - so every
805
- body is sent this way, through the gateway or not.
855
+ The request arguments that carry body as a raw application/json
856
+ body - the one encoding every webdesign reads. The JSONActionRunner
857
+ vortex action (Puakma 6.2 / webdesign 4.2) rejects the 'Data' form
858
+ field 8.x used to send (400, "not a valid JSON object"); the original
859
+ action reads either. A raw body over ~512 KB once arrived empty, which
860
+ is why the form field was used - it no longer does (6.1.16, 6.2.0).
806
861
  """
807
862
  if body is None:
808
- return None
809
- return {"Data": json.dumps(body)}
863
+ return {}
864
+ return {
865
+ "content": json.dumps(body).encode(),
866
+ "headers": {"Content-Type": "application/json"},
867
+ }
810
868
 
811
869
 
812
870
  def _as_dict(value: Any) -> dict[str, Any]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vortex_cli
3
- Version: 8.6.0
3
+ Version: 8.7.0
4
4
  Summary: Vortex CLI
5
5
  Author-email: Jordan Amos <jordan.amos@gmail.com>
6
6
  License: MIT License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes