makea-cli 0.2.7__py3-none-any.whl → 0.2.9__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.7"
1
+ __version__ = "0.2.9"
makea_cli/api_client.py CHANGED
@@ -1044,9 +1044,16 @@ def supplier_list_quote_requests(*, quote_request_id: str | None = None) -> Any:
1044
1044
  return get_json("/supplier/quote_requests", params=params)
1045
1045
 
1046
1046
 
1047
- def supplier_get_quote_request_tech_spec(quote_request_id: str) -> Any:
1048
- """GET /supplier/quote_requests/{id}/technical-specifications — the pack as the factory sees it."""
1049
- return get_json(f"/supplier/quote_requests/{quote_request_id}/technical-specifications")
1047
+ def supplier_get_quote_request_tech_spec(quote_request_id: str, *, readable: bool = False) -> Any:
1048
+ """GET /supplier/quote_requests/{id}/technical-specifications — the pack as the factory sees it.
1049
+
1050
+ ``readable`` asks for ``view=readable``: section, field label, value and the
1051
+ essentials still blank, instead of the full payload the quote form renders.
1052
+ """
1053
+ params = {"view": "readable"} if readable else None
1054
+ return get_json(
1055
+ f"/supplier/quote_requests/{quote_request_id}/technical-specifications", params=params
1056
+ )
1050
1057
 
1051
1058
 
1052
1059
  def supplier_list_production_orders(*, quote_request_id: str | None = None) -> Any:
@@ -4,7 +4,8 @@ Behavioural metrics (feature usage, clicks, page/feature time, active users)
4
4
  backed by PostHog HogQL. Distinct from the `metrics` group, which reads the
5
5
  Makea backend for financial figures.
6
6
 
7
- Requires env: POSTHOG_API_KEY, POSTHOG_PROJECT_ID (see config.py).
7
+ Goes through the Makea backend by default (admin login is enough); a local
8
+ POSTHOG_API_KEY + POSTHOG_PROJECT_ID switches to querying PostHog directly.
8
9
  """
9
10
 
10
11
  from __future__ import annotations
@@ -32,8 +33,7 @@ def register(app: typer.Typer) -> None:
32
33
  "get",
33
34
  "feature-usage",
34
35
  legacy="analytics-feature-usage",
35
- api="POSTHOG hogql",
36
- external="posthog",
36
+ api="POST /admin/analytics/query",
37
37
  help=(
38
38
  "How many distinct users used a feature recently, plus event volume. "
39
39
  "Matches $pageview path and feature_time_spent events. "
@@ -82,8 +82,7 @@ def register(app: typer.Typer) -> None:
82
82
  "get",
83
83
  "top-features",
84
84
  legacy="analytics-top-features",
85
- api="POSTHOG hogql",
86
- external="posthog",
85
+ api="POST /admin/analytics/query",
87
86
  help=(
88
87
  "Rank pageview paths by distinct users over the last N days — a quick "
89
88
  "map of which features get used most."
@@ -118,8 +117,7 @@ def register(app: typer.Typer) -> None:
118
117
  "get",
119
118
  "top-clicks",
120
119
  legacy="analytics-top-clicks",
121
- api="POSTHOG hogql",
122
- external="posthog",
120
+ api="POST /admin/analytics/query",
123
121
  help=(
124
122
  "Rank autocaptured click targets by count over the last N days — "
125
123
  "which buttons/elements get clicked most."
@@ -156,8 +154,7 @@ def register(app: typer.Typer) -> None:
156
154
  "get",
157
155
  "active-users",
158
156
  legacy="analytics-active-users",
159
- api="POSTHOG hogql",
160
- external="posthog",
157
+ api="POST /admin/analytics/query",
161
158
  help="Distinct active users per day over the last N days (DAU series).",
162
159
  )
163
160
  def active_users(
@@ -184,8 +181,7 @@ def register(app: typer.Typer) -> None:
184
181
  "get",
185
182
  "analytics-query",
186
183
  legacy="analytics-query",
187
- api="POSTHOG hogql",
188
- external="posthog",
184
+ api="POST /admin/analytics/query",
189
185
  help=(
190
186
  "Run an arbitrary HogQL query (escape hatch). "
191
187
  'Example: analytics-query "SELECT count() FROM events"'
@@ -72,10 +72,22 @@ def register(app: typer.Typer) -> None:
72
72
  )
73
73
  def get_pack(
74
74
  quote_request_id: str = typer.Argument(..., help="The quote request whose pack to read."),
75
+ readable: bool = typer.Option(
76
+ False,
77
+ "--readable",
78
+ help=(
79
+ "Only what a person reads: each section's filled fields (label and "
80
+ "value) and the essential fields still blank. The full payload runs "
81
+ "to 100KB+ on a large pack."
82
+ ),
83
+ ),
75
84
  ) -> None:
76
85
  """Read the technical specification behind an RFQ."""
77
86
  print_json_or_exit(
78
- console, lambda: api_client.supplier_get_quote_request_tech_spec(quote_request_id)
87
+ console,
88
+ lambda: api_client.supplier_get_quote_request_tech_spec(
89
+ quote_request_id, readable=readable
90
+ ),
79
91
  )
80
92
 
81
93
  @command(
makea_cli/config.py CHANGED
@@ -48,8 +48,9 @@ def redirect_uri() -> str:
48
48
 
49
49
  # PostHog product-analytics (behavioural metrics: clicks, page/feature time,
50
50
  # funnels, retention). Distinct from the financial `metrics` command group,
51
- # which reads the Makea backend. Configured purely via environment so no key is
52
- # ever committed:
51
+ # which reads the Makea backend. Optional: without these the analytics commands
52
+ # go through the backend's /admin/analytics/query, which holds the key. Set them
53
+ # only to query PostHog directly:
53
54
  # POSTHOG_API_KEY personal API key (phx_...), read-only is enough
54
55
  # POSTHOG_PROJECT_ID numeric project id
55
56
  # POSTHOG_HOST defaults to the EU cloud query host
@@ -1,10 +1,11 @@
1
1
  """Minimal PostHog query client (HogQL over the Query API).
2
2
 
3
- This talks to PostHog's cloud directly, not the Makea backend, so it has its
4
- own auth (a personal API key from env) rather than the Cognito token used by
5
- api_client.
3
+ Two routes to the same query:
6
4
 
7
- Docs: POST {host}/api/projects/{project_id}/query/ with a HogQLQuery body.
5
+ - By default it goes through the Makea backend (POST /admin/analytics/query),
6
+ which holds the PostHog key. An admin's `makea-cli login` is all it takes.
7
+ - If POSTHOG_API_KEY and POSTHOG_PROJECT_ID are set locally, it talks to
8
+ PostHog directly instead (POST {host}/api/projects/{project_id}/query/).
8
9
  """
9
10
 
10
11
  from __future__ import annotations
@@ -14,33 +15,21 @@ from typing import Any
14
15
 
15
16
  import httpx
16
17
 
18
+ from makea_cli import api_client
17
19
  from makea_cli.config import posthog_api_key, posthog_host, posthog_project_id
18
20
 
19
21
 
20
- class PostHogNotConfigured(RuntimeError):
21
- """Raised when the required PostHog env vars are missing."""
22
-
23
-
24
- def _require_config() -> tuple[str, str, str]:
25
- key = posthog_api_key()
26
- project = posthog_project_id()
27
- if not key or not project:
28
- raise PostHogNotConfigured(
29
- "PostHog is not configured. Set POSTHOG_API_KEY (personal API key, "
30
- "phx_...) and POSTHOG_PROJECT_ID, optionally POSTHOG_HOST "
31
- "(default https://eu.posthog.com)."
32
- )
33
- return posthog_host(), project, key
34
-
35
-
36
- def run_hogql(query: str, *, timeout: float = 60.0) -> dict[str, Any]:
22
+ def run_hogql(query: str, *, timeout: float = 90.0) -> dict[str, Any]:
37
23
  """Run a HogQL query and return the raw result.
38
24
 
39
25
  The result has ``columns`` (list of names) and ``results`` (list of rows);
40
26
  callers usually want to zip them into dicts for display.
41
27
  """
42
- host, project, key = _require_config()
43
- url = f"{host}/api/projects/{project}/query/"
28
+ key = posthog_api_key()
29
+ project = posthog_project_id()
30
+ if not key or not project:
31
+ return api_client.post_json("/admin/analytics/query", {"query": query}, timeout=timeout)
32
+ url = f"{posthog_host()}/api/projects/{project}/query/"
44
33
  headers = {
45
34
  "Authorization": f"Bearer {key}",
46
35
  "Content-Type": "application/json",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: makea-cli
3
- Version: 0.2.7
3
+ Version: 0.2.9
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
@@ -98,18 +98,18 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
98
98
  | `makea-cli admin download document` | read | `GET /admin/document/download` | save a document file (document id + designer user_id). | `download-document` |
99
99
  | `makea-cli admin download product-document` | read | `GET /admin/document/download` | Resolve product via admin list product-order payload, then GET /admin/document/download. | `download-product-document` |
100
100
  | `makea-cli admin generate pricing-groups` | write(ask) | `POST /admin/production_orders/{id}/details/update` | Lay a production order's variants into pricing groups along one axis (--by style \| colour \| variant \| all) with th… | `production-groups-generate` |
101
- | `makea-cli admin get active-users` | read | `posthog` | Distinct active users per day over the last N days (DAU series). | `analytics-active-users` |
102
- | `makea-cli admin get analytics-query` | read | `posthog` | Run an arbitrary HogQL query (escape hatch). Example: analytics-query "SELECT count() FROM events" | `analytics-query` |
101
+ | `makea-cli admin get active-users` | read | `POST /admin/analytics/query` | Distinct active users per day over the last N days (DAU series). | `analytics-active-users` |
102
+ | `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` |
103
103
  | `makea-cli admin get currency-conversion` | read | `currency-api` | avoids repeated lookups. | `convert-currency` |
104
- | `makea-cli admin get feature-usage` | read | `posthog` | How many distinct users used a feature recently, plus event volume. Matches $pageview path and feature_time_spent eve… | `analytics-feature-usage` |
104
+ | `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` |
105
105
  | `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` |
106
106
  | `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` |
107
107
  | `makea-cli admin get quote-request` | read | `GET /admin/quote_requests/{quote_request_id}` | one quote request in full. | — |
108
108
  | `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` |
109
109
  | `makea-cli admin get supplier-profile-schema` | read | `GET /admin/supplier/profile/schema` | supplier profile v2 schema (section/field taxonomy: sections, fields, options, required rules). | `get-supplier-profile-schema` |
110
110
  | `makea-cli admin get tech-spec-extraction` | read | `GET /admin/products/{id}/extract-tech-specifications` | AI-generate specs (not saved). | `extract-ai-tech-spec` |
111
- | `makea-cli admin get top-clicks` | read | `posthog` | which buttons/elements get clicked most. | `analytics-top-clicks` |
112
- | `makea-cli admin get top-features` | read | `posthog` | a quick map of which features get used most. | `analytics-top-features` |
111
+ | `makea-cli admin get top-clicks` | read | `POST /admin/analytics/query` | which buttons/elements get clicked most. | `analytics-top-clicks` |
112
+ | `makea-cli admin get top-features` | read | `POST /admin/analytics/query` | a quick map of which features get used most. | `analytics-top-features` |
113
113
  | `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` |
114
114
  | `makea-cli admin list misc-payment` | read | `GET /admin/products/{id}/misc-payments` | misc payments for one product (admin). | `list-misc-payments-by-product` |
115
115
  | `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` |
@@ -197,7 +197,7 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
197
197
  |---|---|---|---|---|
198
198
  | `makea-cli supplier create note` | write(ask) | `POST /supplier/products/{id}/channels/{key}/notes` | post a message into a product channel you are part of. | — |
199
199
  | `makea-cli supplier download document` | read | `GET /supplier/document/download` | save a document you are allowed to read. | — |
200
- | `makea-cli supplier get pack` | read | `GET /supplier/quote_requests/{id}/technical-specifications` | the tech pack for an RFQ, as the factory is allowed to see it. | — |
200
+ | `makea-cli supplier get pack` | read | `GET /supplier/quote_requests/{id}/technical-specifications` | the tech pack for an RFQ, as the factory is allowed to see it (`--readable`: labels, values and blank essentials only). | — |
201
201
  | `makea-cli supplier get pack-changes` | read | `GET /supplier/products/{product_id}/specification-change-history` | what changed in the pack since you quoted, field by field. | — |
202
202
  | `makea-cli supplier get profile` | read | `GET /supplier/profile` | your own supplier profile. | — |
203
203
  | `makea-cli supplier get rfq` | read | `GET /supplier/quote_requests` | one RFQ in full. | — |
@@ -1,19 +1,19 @@
1
- makea_cli/__init__.py,sha256=XHypfHSPdgXFKmOdoewn7czU670gt8InhHhzlP5j_aA,22
1
+ makea_cli/__init__.py,sha256=F8OVhAhMXSkvvXYgZtbPn2SG1AQC3joK4yu-FrHt81Y,22
2
2
  makea_cli/__main__.py,sha256=AkQjxWfKE3w9iD1d6I-2Zqvv2t9cct0oYyFF0UiA-Z0,144
3
- makea_cli/api_client.py,sha256=Q17LkGpWs_W87Y8ArFBT2l8LfBfsc_OUGPazOaJhQas,50484
3
+ makea_cli/api_client.py,sha256=dzMCH9KzY7NJxoop-WVyqm_JQ3eU3hvFh_ic2Zk-evc,50763
4
4
  makea_cli/auth_pkce.py,sha256=iXSyJ7DM3qVuj-3FwPiqM25CxXz9ebFs9FNthZdw3ws,7315
5
5
  makea_cli/broker.py,sha256=5O650nAdRuF-u9E1MuVM2jVv796iBdxJGIaJasxHij0,3019
6
- makea_cli/config.py,sha256=lVPsp-44V9pPyUNbcG-uQNV8srCrBVMZnb0HF38Paks,2906
6
+ makea_cli/config.py,sha256=hz8MnJSkhxcIEZkcpHR005JrDceo1Xmi8qwIUq50cMU,3003
7
7
  makea_cli/errors.py,sha256=_2qKjvkU8YWeBcUd04Yn62lKkZoqQY52kH8klNMyxhM,2780
8
8
  makea_cli/identity.py,sha256=pfYT-asaY1ZTzoAzfqI-v4Eyz1RtxqR2YgvxRGx_lxg,2758
9
9
  makea_cli/main.py,sha256=nuTQ8_P8OSdRbjMHMB4qcKdex124nS-ApCW-zfbqlI0,7169
10
10
  makea_cli/output.py,sha256=VWvZe2Ad8zxT4ZQyBhFRc6wkFwbyYzQFPddepANGAbY,6361
11
- makea_cli/posthog_client.py,sha256=OcqspuG3mX0ZoHzhWBfO2K9ItYwk22L4clqBzWyV7GA,2177
11
+ makea_cli/posthog_client.py,sha256=k0cy9Hq7bhdLlPvC1ZW_esJ70xHDdQzPQUlx-GpVskk,1921
12
12
  makea_cli/registry.py,sha256=GYJK_idhwIh1X2ictwFjn8PEMaXT56hFVkoLEVYrVqw,13722
13
13
  makea_cli/commands/__init__.py,sha256=sxDNEYDmQTASzH2uvMtqNwKLLbOQBzwPfxc-S1tHf-w,1474
14
14
  makea_cli/commands/_util.py,sha256=zSFwWaWpncARlKxgq4WuJlJvNv7XdZ39HfHrNOELHuw,980
15
15
  makea_cli/commands/analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- makea_cli/commands/analytics/cmd.py,sha256=_I5fBlomTalAxRpB-jculS01AbjEC5cVG3lANJeryjM,6548
16
+ makea_cli/commands/analytics/cmd.py,sha256=KVLUtYSeyYZ8_09jIuIAmePjQqcpQS2mb5PBBzGwQYQ,6562
17
17
  makea_cli/commands/auth/__init__.py,sha256=NXoKGfkY2X_hb8GnAyzhoI_qDXfpwKZPqt4HnOrXW3Y,73
18
18
  makea_cli/commands/auth/cmd.py,sha256=G9ZeiaJwzUUTptIyynr0V-82wI7eV0qVX0pD6rdPSXg,1321
19
19
  makea_cli/commands/brand/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -27,7 +27,7 @@ makea_cli/commands/document/cmd.py,sha256=IqjzGoTYXp1RbTIYY1MSEqX93btK4eESDTX40C
27
27
  makea_cli/commands/email/__init__.py,sha256=EWMqMTgZK1GQDW7-9RGVSGU-CvaHTARjXZL18Hdj80I,74
28
28
  makea_cli/commands/email/cmd.py,sha256=s22JQjJ7bPdpgBaL7Tmr8hx80ki_JN_iGQtUekXmmdo,4177
29
29
  makea_cli/commands/factory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- makea_cli/commands/factory/cmd.py,sha256=ae2KGxnzoY1i7C4miVIk52IQZm53pOfePnJa9zeL_sI,14724
30
+ makea_cli/commands/factory/cmd.py,sha256=ZMJ2UDSAI3vINvvltrH8VjSPWdsmUquVHQlANyb-G9Y,15131
31
31
  makea_cli/commands/library/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  makea_cli/commands/library/cmd.py,sha256=eXZa6iLyPaoEWtRd-UmhRT6Ox-zlfs89gJqGn-IPuSU,11187
33
33
  makea_cli/commands/metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -41,7 +41,7 @@ makea_cli/commands/production/cmd.py,sha256=s6fVAGzOvokF6Va5WKGEA2vw2x2hDQ3PrsF0
41
41
  makea_cli/commands/production/pricing_spec.py,sha256=xGbj7-ps3PcKuU6Oc59A70b62FjF6Awhr5IY3ymZveU,27174
42
42
  makea_cli/commands/supplier/__init__.py,sha256=qfQDeQdQ-B7I_uwFVfcp1vXFUTL4fAcNLu3ipsZ7dfs,77
43
43
  makea_cli/commands/supplier/cmd.py,sha256=crRCy9WfhkryHMIL3iufoiT90_SG3-mKChAtdhd06uc,58076
44
- makea_cli-0.2.7.dist-info/METADATA,sha256=BdE2jRNW3fDb65Q10pcdFd-Pe40gBaambZ8F-j7Zuy8,31603
45
- makea_cli-0.2.7.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
46
- makea_cli-0.2.7.dist-info/entry_points.txt,sha256=4x-lbVa1jBbNlkNq7L-rYyfRh2spZmc3BLIzP-Dl-Qk,50
47
- makea_cli-0.2.7.dist-info/RECORD,,
44
+ makea_cli-0.2.9.dist-info/METADATA,sha256=Nnp67EfMAZJ0m9JEn9qhecii3iB4Xg0cEo1lUqVxn8I,31760
45
+ makea_cli-0.2.9.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
46
+ makea_cli-0.2.9.dist-info/entry_points.txt,sha256=4x-lbVa1jBbNlkNq7L-rYyfRh2spZmc3BLIzP-Dl-Qk,50
47
+ makea_cli-0.2.9.dist-info/RECORD,,