makea-cli 0.2.22__py3-none-any.whl → 0.2.24__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
makea_cli/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.22"
1
+ __version__ = "0.2.24"
makea_cli/api_client.py CHANGED
@@ -907,30 +907,25 @@ def update_production_order_details(
907
907
  )
908
908
 
909
909
 
910
- def get_cumulative_payment_and_platform_revenue(
911
- *,
912
- start_date: str,
913
- end_date: str,
914
- granularity: str | None = None,
915
- currency: str | None = None,
916
- order_type: str | None = None,
917
- ) -> Any:
910
+ def list_growth_snapshots() -> Any:
911
+ """GET /admin/growth/snapshots — published Growth Analysis snapshots, newest first."""
912
+ return get_json("/admin/growth/snapshots")
913
+
914
+
915
+ def get_growth_snapshot(snapshot_id: str = "latest") -> Any:
916
+ """GET /admin/growth/snapshots/{id|latest} — one snapshot, every block of it."""
917
+ return get_json(f"/admin/growth/snapshots/{quote(snapshot_id, safe='')}", timeout=120.0)
918
+
919
+
920
+ def import_growth_snapshot(sources_path: Path, *, check_only: bool = False) -> Any:
921
+ """POST /admin/growth/snapshots — gate and publish one reconciled snapshot.
922
+
923
+ Sent as a file part, not a JSON body: the server caps an in-memory body at
924
+ 2.5MB and a snapshot with a long forecast passes that. ``check_only`` runs
925
+ the gates without publishing (``?dry_run=1``).
918
926
  """
919
- GET /admin/business-metrics/cumulative-payment-and-platform-revenue —
920
- platform-wide cumulative payment received and platform revenue (service fee +
921
- transaction fee) within a date range, bucketed by day/week/month.
922
- """
923
- params: dict[str, Any] = {"start_date": start_date, "end_date": end_date}
924
- if granularity is not None:
925
- params["granularity"] = granularity
926
- if currency is not None:
927
- params["currency"] = currency
928
- if order_type is not None:
929
- params["order_type"] = order_type
930
- return get_json(
931
- "/admin/business-metrics/cumulative-payment-and-platform-revenue",
932
- params=params,
933
- )
927
+ path = "/admin/growth/snapshots" + ("?dry_run=1" if check_only else "")
928
+ return post_multipart_with_file(path, file_path=sources_path, timeout=300.0)
934
929
 
935
930
 
936
931
  def get_fx_rates(*, to: str, sources: list[str], amount: float | None = None) -> Any:
@@ -1,5 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import json
4
+ import tempfile
5
+ from pathlib import Path
6
+
3
7
  import typer
4
8
  from rich.console import Console
5
9
 
@@ -10,96 +14,8 @@ from makea_cli.commands._util import print_json_or_exit
10
14
 
11
15
  console = Console()
12
16
 
13
- _GRANULARITIES = ("day", "week", "month")
14
- _ORDER_TYPES = ("all", "sampling", "production")
15
-
16
17
 
17
18
  def register(app: typer.Typer) -> None:
18
- @command(
19
- app,
20
- "admin",
21
- "get",
22
- "revenue-metrics",
23
- legacy="get-cumulative-payment-and-platform-revenue",
24
- api="GET /admin/business-metrics/cumulative-payment-and-platform-revenue",
25
- help=(
26
- "GET /admin/business-metrics/cumulative-payment-and-platform-revenue — "
27
- "platform-wide payment received and platform revenue (service fee + "
28
- "transaction fee) bucketed over a date range."
29
- ),
30
- )
31
- def get_cumulative_payment_and_platform_revenue(
32
- start_date: str = typer.Option(
33
- ...,
34
- "--start-date",
35
- help="Start date (inclusive), ISO format YYYY-MM-DD.",
36
- ),
37
- end_date: str = typer.Option(
38
- ...,
39
- "--end-date",
40
- help="End date (inclusive), ISO format YYYY-MM-DD.",
41
- ),
42
- granularity: str = typer.Option(
43
- "day",
44
- "--granularity",
45
- "-g",
46
- help="Time bucket: day, week, or month. Default: day.",
47
- ),
48
- currency: str = typer.Option(
49
- "GBP",
50
- "--currency",
51
- "-c",
52
- help="Target currency for conversion. Default: GBP.",
53
- ),
54
- order_type: str = typer.Option(
55
- "all",
56
- "--order-type",
57
- "-t",
58
- help="Filter: all, sampling, or production. Default: all.",
59
- ),
60
- ) -> None:
61
- """
62
- Platform-wide cumulative payment received and platform revenue over a date range.
63
-
64
- Calls GET /admin/business-metrics/cumulative-payment-and-platform-revenue.
65
-
66
- Platform revenue = service fee + transaction fee (the 2.8% transaction fee is
67
- applied by the server). The response contains two siblings under ``result``:
68
-
69
- - ``payment_received``: cumulative/period amounts per bucket, plus a
70
- ``payment_breakdown`` (sampling / production_deposit / production_final).
71
- - ``platform_revenue``: cumulative/period amounts per bucket.
72
-
73
- Input: required --start-date and --end-date (YYYY-MM-DD); optional
74
- --granularity (day|week|month), --currency, --order-type (all|sampling|production).
75
-
76
- Output: raw JSON body from the admin business-metrics endpoint.
77
-
78
- This endpoint is **platform-wide only** and does not support filtering by
79
- user_id, product, or category. For per-user / per-product drill-downs, use
80
- admin list product-order / admin list sampling-order --product /
81
- admin list production-order --product and aggregate client-side.
82
- """
83
- g = granularity.strip().lower()
84
- if g not in _GRANULARITIES:
85
- console.print(f"[red]--granularity must be one of: {', '.join(_GRANULARITIES)}.[/red]")
86
- raise typer.Exit(1)
87
- ot = order_type.strip().lower()
88
- if ot not in _ORDER_TYPES:
89
- console.print(f"[red]--order-type must be one of: {', '.join(_ORDER_TYPES)}.[/red]")
90
- raise typer.Exit(1)
91
-
92
- print_json_or_exit(
93
- console,
94
- lambda: api_client.get_cumulative_payment_and_platform_revenue(
95
- start_date=start_date,
96
- end_date=end_date,
97
- granularity=g,
98
- currency=currency,
99
- order_type=ot,
100
- ),
101
- )
102
-
103
19
  @command(
104
20
  app,
105
21
  "admin",
@@ -165,3 +81,147 @@ def register(app: typer.Typer) -> None:
165
81
  return out
166
82
 
167
83
  print_json_or_exit(console, _do)
84
+
85
+ @command(
86
+ app,
87
+ "admin",
88
+ "list",
89
+ "growth-snapshot",
90
+ api="GET /admin/growth/snapshots",
91
+ help=(
92
+ "GET /admin/growth/snapshots — published Growth Analysis snapshots "
93
+ "(Metrics page), newest first, with cut-off, rule version, audit "
94
+ "status and headline GMV/revenue."
95
+ ),
96
+ )
97
+ def list_growth_snapshots() -> None:
98
+ """Every published snapshot's index entry. Snapshots are immutable; a
99
+ correction is a new id, so this list is also the change log."""
100
+ print_json_or_exit(console, api_client.list_growth_snapshots)
101
+
102
+ @command(
103
+ app,
104
+ "admin",
105
+ "get",
106
+ "growth-snapshot",
107
+ api="GET /admin/growth/snapshots/{id}",
108
+ help=(
109
+ "GET /admin/growth/snapshots/{id|latest} — one reconciled snapshot: "
110
+ "headline, economics, monthly, customers, ledger, suppliers, forecast, "
111
+ "gates and review items."
112
+ ),
113
+ )
114
+ def get_growth_snapshot(
115
+ snapshot_id: str = typer.Argument("latest", help="Snapshot id, or latest."),
116
+ block: str = typer.Option(
117
+ None,
118
+ "--block",
119
+ "-b",
120
+ help="Print only one block, e.g. headline, gates, review_items, economics.",
121
+ ),
122
+ ) -> None:
123
+ """Audited actuals and Booked GMV live in separate blocks (``ledger`` vs
124
+ ``forecast``); never add one to the other."""
125
+
126
+ def _do():
127
+ snapshot = (api_client.get_growth_snapshot(snapshot_id) or {}).get("snapshot") or {}
128
+ if block:
129
+ if block not in snapshot:
130
+ raise RuntimeError(f"No block {block!r}. Blocks: {', '.join(sorted(snapshot))}")
131
+ return snapshot[block]
132
+ return snapshot
133
+
134
+ print_json_or_exit(console, _do)
135
+
136
+ @command(
137
+ app,
138
+ "admin",
139
+ "upload",
140
+ "growth-snapshot",
141
+ api="POST /admin/growth/snapshots",
142
+ side_effects=[],
143
+ approval="ask",
144
+ reversible=False,
145
+ help=(
146
+ "POST /admin/growth/snapshots — publish a reconciled Growth Analysis "
147
+ "snapshot to the Metrics page. The server runs the ten publication "
148
+ "gates and refuses anything that fails; --check runs them without "
149
+ "publishing."
150
+ ),
151
+ )
152
+ def upload_growth_snapshot(
153
+ analysis: Path = typer.Option(
154
+ None,
155
+ "--analysis",
156
+ help="analysis_data.json (headline, fx, monthly, customers, orders, ...).",
157
+ ),
158
+ derived: Path = typer.Option(
159
+ None, "--derived", help="derived_metrics.json (AOV, supplier populations)."
160
+ ),
161
+ audit: Path = typer.Option(
162
+ None, "--audit", help="audit_checks.json (source pipeline assertions)."
163
+ ),
164
+ forecast: Path = typer.Option(
165
+ None, "--forecast", help="projection_data.json (Booked GMV)."
166
+ ),
167
+ review: Path = typer.Option(
168
+ None,
169
+ "--review",
170
+ help="JSON list of review items; an open item needs accepted_open: true to pass.",
171
+ ),
172
+ rule_version: str = typer.Option(
173
+ None, "--rule-version", help="The rule set these numbers follow."
174
+ ),
175
+ snapshot_id: str = typer.Option(
176
+ None,
177
+ "--snapshot-id",
178
+ help="Defaults to the cut-off date; suffix a correction, e.g. 2026-10-26.b.",
179
+ ),
180
+ fx_basis: str = typer.Option(None, "--fx-basis", help="e.g. 'ECB reference, 31 Jul 2026'."),
181
+ note: str = typer.Option(None, "--note", help="What changed since the previous snapshot."),
182
+ sources: Path = typer.Option(
183
+ None,
184
+ "--sources",
185
+ help="One prebuilt JSON holding every block; replaces the file options.",
186
+ ),
187
+ check: bool = typer.Option(False, "--check", help="Run the gates only; publish nothing."),
188
+ ) -> None:
189
+ """Publish once per refresh. An id is written once: a correction is a new
190
+ snapshot, and the previous one stays readable for comparison.
191
+
192
+ Output: {"published", "entry", "gates"}. A failed gate exits 4 with every
193
+ gate and its detail, and nothing is stored.
194
+ """
195
+
196
+ def _load(path: Path | None):
197
+ if path is None:
198
+ return None
199
+ return json.loads(path.read_text(encoding="utf-8"))
200
+
201
+ def _do():
202
+ if sources is not None:
203
+ body = _load(sources)
204
+ else:
205
+ if analysis is None or not rule_version:
206
+ raise RuntimeError("Pass --sources, or --analysis with --rule-version.")
207
+ body = {
208
+ "analysis": _load(analysis),
209
+ "derived": _load(derived) or {},
210
+ "audit": _load(audit) or {},
211
+ "forecast": _load(forecast) or {},
212
+ "review_items": _load(review) or [],
213
+ }
214
+ for key, value in (
215
+ ("rule_version", rule_version),
216
+ ("snapshot_id", snapshot_id),
217
+ ("fx_basis", fx_basis),
218
+ ("note", note),
219
+ ):
220
+ if value:
221
+ body[key] = value
222
+ with tempfile.TemporaryDirectory() as tmp:
223
+ path = Path(tmp) / "growth_snapshot.json"
224
+ path.write_text(json.dumps(body, ensure_ascii=False), encoding="utf-8")
225
+ return api_client.import_growth_snapshot(path, check_only=check)
226
+
227
+ print_json_or_exit(console, _do)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: makea-cli
3
- Version: 0.2.22
3
+ Version: 0.2.24
4
4
  Summary: Makea admin CLI (browser login + Makea admin HTTP API)
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: click<9,>=8.1
@@ -114,11 +114,11 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
114
114
  | `makea-cli admin get analytics-query` | read | `POST /admin/analytics/query` | Run an arbitrary HogQL query (escape hatch). Example: analytics-query "SELECT count() FROM events" | `analytics-query` |
115
115
  | `makea-cli admin get currency-conversion` | read | `GET /admin/fx/rates` | the platform's own exchange rates and rounding (rate table for several --from; one --from with --amount converts it). | `convert-currency` |
116
116
  | `makea-cli admin get feature-usage` | read | `POST /admin/analytics/query` | How many distinct users used a feature recently, plus event volume. Matches $pageview path and feature_time_spent eve… | `analytics-feature-usage` |
117
+ | `makea-cli admin get growth-snapshot` | read | `GET /admin/growth/snapshots/{id}` | one reconciled Growth Analysis snapshot (default `latest`); `--block` prints one block (headline, gates, review_items, …). | — |
117
118
  | `makea-cli admin get library-schema` | read | `GET /admin/library_components/schema` | the tech-pack library taxonomy: sections and their library-role field keys (run this before create/update). | `library-schema` |
118
119
  | `makea-cli admin get playbook-preview` | read | `GET /admin/playbook/preview` | the playbook block one AI surface would get for a person or factory, and every rule left out with its reason; --product previews a conversation about one product, --rule answers for one rule. | — |
119
120
  | `makea-cli admin get production-pricing` | read | `GET /admin/production_orders/{id}/details` | show a production order's price tiers, MOQ, sizes/colours, pricing groups and cart coverage. | `production-pricing-show` |
120
121
  | `makea-cli admin get quote-request` | read | `GET /admin/quote_requests/{quote_request_id}` | one quote request in full. | — |
121
- | `makea-cli admin get revenue-metrics` | read | `GET /admin/business-metrics/cumulative-payment-and-platform-revenue` | platform-wide payment received and platform revenue (service fee + transaction fee) bucketed over a date range. | `get-cumulative-payment-and-platform-revenue` |
122
122
  | `makea-cli admin get rule` | read | `GET /admin/playbook/{target}/rules/{rule_id}` | one rule in full (`--user` / `--supplier` / `--global`), with its evidence: where it came from, who changed it and why. | — |
123
123
  | `makea-cli admin get rule-history` | read | `GET /admin/playbook/rules/{rule_id}/history` | every revision of one rule: its words, who changed it and why, and the rule that replaced it. | — |
124
124
  | `makea-cli admin get shipping-order` | read | `GET /admin/shipping_orders/{shipping_order_id}/details` | one shipment with its production and sampling orders, freight quotes, fees, tracking and address. | — |
@@ -128,6 +128,7 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
128
128
  | `makea-cli admin get top-clicks` | read | `POST /admin/analytics/query` | which buttons/elements get clicked most. | `analytics-top-clicks` |
129
129
  | `makea-cli admin get top-features` | read | `POST /admin/analytics/query` | a quick map of which features get used most. | `analytics-top-features` |
130
130
  | `makea-cli admin list library-element` | read | `GET /admin/designer/{user_id}/library_components` | list a designer's tech-pack library (org-fanned). Optional --section scopes to one type. | `library-list` |
131
+ | `makea-cli admin list growth-snapshot` | read | `GET /admin/growth/snapshots` | published Growth Analysis snapshots, newest first (the change log). | — |
131
132
  | `makea-cli admin list misc-payment` | read | `GET /admin/products/{id}/misc-payments` | misc payments for one product (admin). | `list-misc-payments-by-product` |
132
133
  | `makea-cli admin list product-order` | read | `GET /admin/designer/get_all_product_orders` | designer product (SKU) list. For 大货 use admin list production-order or admin list production-order --product. | `list-product-orders` |
133
134
  | `makea-cli admin list production-order` | read | `GET /admin/production_orders?type=PRODUCTION` | 大货 (production) orders only. For restock use admin list restock-order; for shipping use admin list shipping-order. | `list-all-production-orders` |
@@ -158,6 +159,7 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
158
159
  | `makea-cli admin update tracking-status` | write(ask) | `POST /admin/tracking/carrier_status` | apply a carrier status looked up by hand (tracking-sweep skill) to one order: status, fan-out, delivered emails (--silent: state only). | — |
159
160
  | `makea-cli admin update user` | write(ask) | `PUT /admin/user-profiles/{user_id}/update` | admin updates DynamoDB user profile fields and/or Cognito custom:userType. Allowed --user-type values: "Fashion brand… | `update-user-profile` |
160
161
  | `makea-cli admin upload financial-document` | write(auto) | `POST /admin/products/{product_id}/financial_documents` | upload one or more files to AWS S3 and return financial document metadata. | `upload-financial-documents` |
162
+ | `makea-cli admin upload growth-snapshot` | write(ask) | `POST /admin/growth/snapshots` | publish a reconciled snapshot to admin Metrics; the server runs the ten gates and refuses a failure; `--check` gates only. | — |
161
163
  | `makea-cli admin upload link-document` | write(auto) | `POST /admin/upload_link_document` | upload a file to AWS S3 and return document domain metadata for reuse as input in other commands. | `upload-link-document` |
162
164
  | `makea-cli admin upload product-document` | write(auto) | `POST /admin/designer/upload_document` | upload a file to AWS S3 under a product and return document domain metadata for reuse by other commands. | `upload-product-document` |
163
165
  | `makea-cli admin upload production-order-document` | write(auto) | `POST /admin/production_orders/{production_order_id}/documents` | upload a file to AWS S3 for a production order and return document domain metadata. | `upload-production-order-document` |
@@ -1,6 +1,6 @@
1
- makea_cli/__init__.py,sha256=ByX4mXI7ZzGpflAj9VCqX2NLBK8uAil5WOrao7y2YZM,23
1
+ makea_cli/__init__.py,sha256=n5ZPZHIaXZ7sqt8tjkjGM573cZdtdmlQuM7yyyEcMe0,23
2
2
  makea_cli/__main__.py,sha256=AkQjxWfKE3w9iD1d6I-2Zqvv2t9cct0oYyFF0UiA-Z0,144
3
- makea_cli/api_client.py,sha256=SJu96FAB2jjbXtbg6rz9dbJfAdR-xodP_7bwsQnLn2c,74802
3
+ makea_cli/api_client.py,sha256=1Qy2iG0JYu0IRLIi3fDOcCkG2w1IAo8Z61OE0wCLYXw,74891
4
4
  makea_cli/auth_pkce.py,sha256=iXSyJ7DM3qVuj-3FwPiqM25CxXz9ebFs9FNthZdw3ws,7315
5
5
  makea_cli/broker.py,sha256=5O650nAdRuF-u9E1MuVM2jVv796iBdxJGIaJasxHij0,3019
6
6
  makea_cli/config.py,sha256=hz8MnJSkhxcIEZkcpHR005JrDceo1Xmi8qwIUq50cMU,3003
@@ -33,7 +33,7 @@ makea_cli/commands/factory/cmd.py,sha256=k_UGkqpzxxZhN9WjKt1rb95KOTGHMpMJRpfNHTG
33
33
  makea_cli/commands/library/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  makea_cli/commands/library/cmd.py,sha256=eXZa6iLyPaoEWtRd-UmhRT6Ox-zlfs89gJqGn-IPuSU,11187
35
35
  makea_cli/commands/metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- makea_cli/commands/metrics/cmd.py,sha256=ox5OD7Bk3QJcdHQv5u4t6G-OlC6eSbQG5BEH1yBkxno,6414
36
+ makea_cli/commands/metrics/cmd.py,sha256=gAYNztkhvdK8miP3ayDu0JgYzxLr42-ToeiXBCrAQeA,8656
37
37
  makea_cli/commands/orders/__init__.py,sha256=6WKPqX02e0RRPmItPIBJ0TA4_yDI2PVvBDkAiMQu9rU,75
38
38
  makea_cli/commands/orders/cmd.py,sha256=Nh5lGv5k4SIwsr_hg-ndah8eTorZCYIMpTAz4CCi6oY,13352
39
39
  makea_cli/commands/playbook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -49,7 +49,7 @@ makea_cli/commands/supplier/__init__.py,sha256=qfQDeQdQ-B7I_uwFVfcp1vXFUTL4fAcNL
49
49
  makea_cli/commands/supplier/cmd.py,sha256=crRCy9WfhkryHMIL3iufoiT90_SG3-mKChAtdhd06uc,58076
50
50
  makea_cli/commands/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  makea_cli/commands/tasks/cmd.py,sha256=SRvv4Ovtcf5-me-8AdKcZ_z_gSrdgC0pbswYbMz7oY4,6539
52
- makea_cli-0.2.22.dist-info/METADATA,sha256=_4x_4_mqAfhiet0nJk5tmxAGBiGA63OGT8eeEO4Gtnk,37484
53
- makea_cli-0.2.22.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
54
- makea_cli-0.2.22.dist-info/entry_points.txt,sha256=4x-lbVa1jBbNlkNq7L-rYyfRh2spZmc3BLIzP-Dl-Qk,50
55
- makea_cli-0.2.22.dist-info/RECORD,,
52
+ makea_cli-0.2.24.dist-info/METADATA,sha256=ea4MmXWcoW3i6Uiav-OLFvlAvm00HTd7zIK6OtjcpSc,37804
53
+ makea_cli-0.2.24.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
54
+ makea_cli-0.2.24.dist-info/entry_points.txt,sha256=4x-lbVa1jBbNlkNq7L-rYyfRh2spZmc3BLIzP-Dl-Qk,50
55
+ makea_cli-0.2.24.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.4
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any