makea-cli 0.2.34__py3-none-any.whl → 0.2.35__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.34"
1
+ __version__ = "0.2.35"
makea_cli/api_client.py CHANGED
@@ -811,6 +811,56 @@ def admin_update_shipping_order_cargo(shipping_order_id: str, cargo: dict[str, A
811
811
  return put_json(f"/admin/shipping_orders/{shipping_order_id}/cargo", cargo)
812
812
 
813
813
 
814
+ def _consignments_path(shipping_order_id: str | None, production_order_id: str | None) -> str:
815
+ if bool(shipping_order_id) == bool(production_order_id):
816
+ raise ValueError("pass exactly one of shipping_order_id / production_order_id")
817
+ if shipping_order_id:
818
+ return f"/admin/shipping_orders/{shipping_order_id}/consignments"
819
+ return f"/admin/production_orders/{production_order_id}/consignments"
820
+
821
+
822
+ def admin_list_consignments(
823
+ *, shipping_order_id: str | None = None, production_order_id: str | None = None
824
+ ) -> Any:
825
+ """GET .../consignments — the lots a shipment left in, with counts.
826
+
827
+ A production order id resolves to the shipping order its goods ride on."""
828
+ return get_json(_consignments_path(shipping_order_id, production_order_id))
829
+
830
+
831
+ def admin_add_consignment(
832
+ body: dict[str, Any],
833
+ *,
834
+ shipping_order_id: str | None = None,
835
+ production_order_id: str | None = None,
836
+ ) -> Any:
837
+ """POST .../consignments — one lot leaving the factory, with its tracking number."""
838
+ return post_json(_consignments_path(shipping_order_id, production_order_id), body)
839
+
840
+
841
+ def admin_update_consignment(
842
+ consignment_id: str,
843
+ body: dict[str, Any],
844
+ *,
845
+ shipping_order_id: str | None = None,
846
+ production_order_id: str | None = None,
847
+ ) -> Any:
848
+ """PUT .../consignments/{cid} — edit a lot; {"status": "DELIVERED"} marks it delivered."""
849
+ path = _consignments_path(shipping_order_id, production_order_id)
850
+ return put_json(f"{path}/{consignment_id}", body)
851
+
852
+
853
+ def admin_delete_consignment(
854
+ consignment_id: str,
855
+ *,
856
+ shipping_order_id: str | None = None,
857
+ production_order_id: str | None = None,
858
+ ) -> Any:
859
+ """DELETE .../consignments/{cid} — remove a lot that has not been delivered."""
860
+ path = _consignments_path(shipping_order_id, production_order_id)
861
+ return delete_json(f"{path}/{consignment_id}")
862
+
863
+
814
864
  def admin_delete_shipping_order(shipping_order_id: str) -> Any:
815
865
  """DELETE /admin/shipping_orders/{id}/delete — soft delete; unlinks its orders."""
816
866
  return delete_json(f"/admin/shipping_orders/{shipping_order_id}/delete")
@@ -420,3 +420,218 @@ def register(app: typer.Typer) -> None:
420
420
  print_json_or_exit(
421
421
  console, lambda: api_client.admin_remove_shipping_order_fee(shipping_order_id, fee_id)
422
422
  )
423
+
424
+ # ------------------------------------------------------------------ #
425
+ # Consignments: the lots a bulk shipment leaves the factory in
426
+ # ------------------------------------------------------------------ #
427
+
428
+ def _owner(shipping_order: str | None, production_order: str | None) -> dict[str, str]:
429
+ if bool(shipping_order) == bool(production_order):
430
+ raise typer.BadParameter("pass exactly one of --shipping-order / --production-order")
431
+ if shipping_order:
432
+ return {"shipping_order_id": shipping_order}
433
+ return {"production_order_id": production_order} # type: ignore[dict-item]
434
+
435
+ _SO_HELP = "Shipping order id the goods ride on."
436
+ _PO_HELP = (
437
+ "Production (or restock) order id. When its goods ride on a shipping order, "
438
+ "the lot goes there."
439
+ )
440
+
441
+ def _lot_body(
442
+ tracking: str | None,
443
+ carrier: str | None,
444
+ carrier_id: int | None,
445
+ tracking_url: str | None,
446
+ pieces: int | None,
447
+ cartons: int | None,
448
+ kg: float | None,
449
+ left: str | None,
450
+ contents: str | None,
451
+ orders: list[str] | None,
452
+ last: bool | None,
453
+ ) -> dict[str, Any]:
454
+ body: dict[str, Any] = {}
455
+ for key, value in (
456
+ ("tracking_number", tracking),
457
+ ("carrier", carrier),
458
+ ("carrier_id", carrier_id),
459
+ ("tracking_url", tracking_url),
460
+ ("pieces", pieces),
461
+ ("cartons", cartons),
462
+ ("gross_weight_kg", kg),
463
+ ("shipped_at", left),
464
+ ("contents", contents),
465
+ ("is_last", last),
466
+ ):
467
+ if value is not None:
468
+ body[key] = value
469
+ if orders:
470
+ body["production_order_ids"] = orders
471
+ return body
472
+
473
+ @command(
474
+ app,
475
+ "admin",
476
+ "list",
477
+ "consignments",
478
+ api="GET /admin/{shipping_orders|production_orders}/{id}/consignments",
479
+ help=(
480
+ "The lots a shipment left the factory in, each with its tracking number, plus "
481
+ "counts: pieces ordered, booked and still to ship, and how many lots landed."
482
+ ),
483
+ )
484
+ def list_consignments(
485
+ shipping_order: str | None = typer.Option(None, "--shipping-order", help=_SO_HELP),
486
+ production_order: str | None = typer.Option(None, "--production-order", help=_PO_HELP),
487
+ ) -> None:
488
+ """List a shipment's consignments."""
489
+ owner = _owner(shipping_order, production_order)
490
+ print_json_or_exit(console, lambda: api_client.admin_list_consignments(**owner))
491
+
492
+ @command(
493
+ app,
494
+ "admin",
495
+ "create",
496
+ "consignment",
497
+ api="POST /admin/{shipping_orders|production_orders}/{id}/consignments",
498
+ side_effects=[
499
+ "the first lot marks the order shipped and emails the designer, as a tracking number did",
500
+ "a later lot posts an in-app note to the designer",
501
+ "the brand's Shipping tab lists the lot with its tracking",
502
+ ],
503
+ approval="ask",
504
+ help=(
505
+ "Add one lot leaving the factory, with its own tracking number. The order is "
506
+ "delivered only when every lot has landed and one is marked last (or the pieces "
507
+ "reach the order). Without --last/--not-last, the lot that brings the pieces up "
508
+ "to the order is marked last."
509
+ ),
510
+ )
511
+ def create_consignment(
512
+ tracking: str = typer.Option(..., "--tracking", help="The lot's tracking number."),
513
+ shipping_order: str | None = typer.Option(None, "--shipping-order", help=_SO_HELP),
514
+ production_order: str | None = typer.Option(None, "--production-order", help=_PO_HELP),
515
+ carrier: str | None = typer.Option(
516
+ None, "--carrier", help="Carrier name, e.g. DHL Express."
517
+ ),
518
+ carrier_id: int | None = typer.Option(None, "--carrier-id", help="17track carrier code."),
519
+ tracking_url: str | None = typer.Option(None, "--tracking-url"),
520
+ pieces: int | None = typer.Option(None, "--pieces", help="Units in this lot."),
521
+ cartons: int | None = typer.Option(None, "--cartons"),
522
+ kg: float | None = typer.Option(None, "--kg", help="Gross weight in kg."),
523
+ left: str | None = typer.Option(
524
+ None, "--left", help="Date the lot left, YYYY-MM-DD (default today)."
525
+ ),
526
+ contents: str | None = typer.Option(
527
+ None, "--contents", help='What the brand reads on the row, e.g. "Black, all sizes".'
528
+ ),
529
+ orders: list[str] | None = typer.Option(
530
+ None,
531
+ "--order",
532
+ help="On a shipment carrying several orders: one that is in this lot; repeat.",
533
+ ),
534
+ last: bool | None = typer.Option(
535
+ None, "--last/--not-last", help="Nothing else ships after this lot."
536
+ ),
537
+ ) -> None:
538
+ """Add a consignment (one lot with its own tracking number)."""
539
+ owner = _owner(shipping_order, production_order)
540
+ body = _lot_body(
541
+ tracking,
542
+ carrier,
543
+ carrier_id,
544
+ tracking_url,
545
+ pieces,
546
+ cartons,
547
+ kg,
548
+ left,
549
+ contents,
550
+ orders,
551
+ last,
552
+ )
553
+ print_json_or_exit(console, lambda: api_client.admin_add_consignment(body, **owner))
554
+
555
+ @command(
556
+ app,
557
+ "admin",
558
+ "update",
559
+ "consignment",
560
+ api="PUT /admin/{shipping_orders|production_orders}/{id}/consignments/{consignment_id}",
561
+ side_effects=[
562
+ "--delivered runs the tracking sweep's delivered path for the lot (and the order when it was the last)",
563
+ "marking the last lot after the others landed delivers the order",
564
+ ],
565
+ approval="ask",
566
+ help=(
567
+ "Edit one lot (ids c1, c2, ... from admin list consignments). --delivered marks it "
568
+ "delivered when the carrier page has no data: a partial lot tells the designer "
569
+ "in-app and on WhatsApp; the last one delivers the order with the usual emails."
570
+ ),
571
+ )
572
+ def update_consignment(
573
+ consignment_id: str = typer.Argument(..., help="c1, c2, ..."),
574
+ shipping_order: str | None = typer.Option(None, "--shipping-order", help=_SO_HELP),
575
+ production_order: str | None = typer.Option(None, "--production-order", help=_PO_HELP),
576
+ tracking: str | None = typer.Option(None, "--tracking"),
577
+ carrier: str | None = typer.Option(None, "--carrier"),
578
+ carrier_id: int | None = typer.Option(None, "--carrier-id"),
579
+ tracking_url: str | None = typer.Option(None, "--tracking-url"),
580
+ pieces: int | None = typer.Option(None, "--pieces"),
581
+ cartons: int | None = typer.Option(None, "--cartons"),
582
+ kg: float | None = typer.Option(None, "--kg"),
583
+ left: str | None = typer.Option(None, "--left", help="YYYY-MM-DD"),
584
+ contents: str | None = typer.Option(None, "--contents"),
585
+ orders: list[str] | None = typer.Option(None, "--order"),
586
+ last: bool | None = typer.Option(None, "--last/--not-last"),
587
+ delivered: bool = typer.Option(False, "--delivered", help="Mark this lot delivered."),
588
+ silent: bool = typer.Option(
589
+ False, "--silent", help="With --delivered: change state only, tell nobody."
590
+ ),
591
+ ) -> None:
592
+ """Edit a consignment, or mark it delivered."""
593
+ owner = _owner(shipping_order, production_order)
594
+ body = _lot_body(
595
+ tracking,
596
+ carrier,
597
+ carrier_id,
598
+ tracking_url,
599
+ pieces,
600
+ cartons,
601
+ kg,
602
+ left,
603
+ contents,
604
+ orders,
605
+ last,
606
+ )
607
+ if delivered:
608
+ body["status"] = "DELIVERED"
609
+ if silent:
610
+ body["notify"] = False
611
+ if not body:
612
+ raise typer.BadParameter("nothing to change")
613
+ print_json_or_exit(
614
+ console,
615
+ lambda: api_client.admin_update_consignment(consignment_id, body, **owner),
616
+ )
617
+
618
+ @command(
619
+ app,
620
+ "admin",
621
+ "delete",
622
+ "consignment",
623
+ api="DELETE /admin/{shipping_orders|production_orders}/{id}/consignments/{consignment_id}",
624
+ side_effects=["the lot and its tracking number leave the brand's Shipping tab"],
625
+ approval="ask",
626
+ help="Remove a lot entered by mistake. A delivered lot cannot be removed.",
627
+ )
628
+ def delete_consignment(
629
+ consignment_id: str = typer.Argument(..., help="c1, c2, ..."),
630
+ shipping_order: str | None = typer.Option(None, "--shipping-order", help=_SO_HELP),
631
+ production_order: str | None = typer.Option(None, "--production-order", help=_PO_HELP),
632
+ ) -> None:
633
+ """Remove a consignment."""
634
+ owner = _owner(shipping_order, production_order)
635
+ print_json_or_exit(
636
+ console, lambda: api_client.admin_delete_consignment(consignment_id, **owner)
637
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: makea-cli
3
- Version: 0.2.34
3
+ Version: 0.2.35
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
@@ -94,6 +94,7 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
94
94
  | 命令 | 读/写 | 后端 | 说明 | 旧名 |
95
95
  |---|---|---|---|---|
96
96
  | `makea-cli admin backfill supplier-id` | write(never) | `POST /admin/supplier/backfill_supplier_id_with_quote_requests` | Migrate supplier_id from a wrong UUID to the Cognito user sub (user_id): profile + Cognito supplierReferenceId, optio… | `backfill-supplier-id` |
97
+ | `makea-cli admin create consignment` | write(ask) | `POST /admin/{production_orders\|shipping_orders}/{id}/consignments` | add one lot leaving the factory with its own tracking number, pieces, cartons, kg and ship date. The lot that brings the pieces up to the order is marked last unless `--last/--not-last` says. | — |
97
98
  | `makea-cli admin create feature-flag` | write(ask) | `POST /admin/feature-flags` | add a flag (off unless --enabled). An existing key is refused. | — |
98
99
  | `makea-cli admin create library-element` | write(auto) | `POST /admin/designer/{user_id}/library_components` | save a reusable component under a designer. Provide --section and --values (see admin get library-schema). | `library-create` |
99
100
  | `makea-cli admin create product-note` | write(ask) | `POST /admin/products/{product_id}/notes` | write a note on a product. Without --internal it goes to the brand. | — |
@@ -108,6 +109,7 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
108
109
  | `makea-cli admin create supplier-link` | write(ask) | `POST /admin/product/link_supplier` | assign a factory to a product, with no price. A bare assignment is not a quote: no quote email goes out and nothing is priced. To quote, use admin submit quote on the quote request. | — |
109
110
  | `makea-cli admin create user` | write(never) | `POST /admin/users/create` | register a user and confirm the Cognito account in one step (no verification email). Allowed --user-type values: "Fas… | `create-user` |
110
111
  | `makea-cli admin delete about` | write(ask) | `DELETE /admin/about/{target}/{key}` | remove one About you line (`--user` / `--supplier`); it is not guessed again. --reason required. | — |
112
+ | `makea-cli admin delete consignment` | write(ask) | `DELETE /admin/{production_orders\|shipping_orders}/{id}/consignments/{consignment_id}` | remove a lot entered by mistake. A delivered lot cannot be removed. | — |
111
113
  | `makea-cli admin delete ship-log` | write(ask) | `DELETE /admin/ship-log/deploys/{deploy_id}` | remove a Ship log entry recorded by mistake, with its recordings. | — |
112
114
  | `makea-cli admin delete feature-flag` | write(ask) | `DELETE /admin/feature-flags/{key}` | remove a flag. Every check of it then reads false, so delete it only once the code that reads it is gone. | — |
113
115
  | `makea-cli admin delete library-element` | write(never) | `DELETE /admin/designer/{user_id}/library_components/{component_id}` | remove a component from the designer's org library. | `library-delete` |
@@ -145,6 +147,7 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
145
147
  | `makea-cli admin get top-clicks` | read | `POST /admin/analytics/query` | which buttons/elements get clicked most. | `analytics-top-clicks` |
146
148
  | `makea-cli admin get top-features` | read | `POST /admin/analytics/query` | a quick map of which features get used most. | `analytics-top-features` |
147
149
  | `makea-cli admin get user` | read | `GET /admin/user-profiles/{user_id}` | one account's profile (Cognito sub as id). | — |
150
+ | `makea-cli admin list consignments` | read | `GET /admin/{production_orders\|shipping_orders}/{id}/consignments` | the lots a shipment left the factory in, each with its tracking number, plus counts: pieces ordered, booked and still to ship, and how many lots landed. | — |
148
151
  | `makea-cli admin list feature-flag` | read | `GET /admin/feature-flags` | every flag: global switch, default value, and the accounts it is on for (id, email, name). | — |
149
152
  | `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` |
150
153
  | `makea-cli admin list growth-snapshot` | read | `GET /admin/growth/snapshots` | published Growth Analysis snapshots, newest first (the change log). | — |
@@ -184,6 +187,7 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
184
187
  | `makea-cli admin update shipping-order` | write(ask) | `PUT /admin/shipping_orders/{shipping_order_id}/status` | Change a shipment: --status (PUT .../status), tracking flags (POST .../tracking), --address (PUT .../shipping-address… | — |
185
188
  | `makea-cli admin update supplier` | write(ask) | `PUT /admin/supplier/update_supplier` | update an existing supplier from a JSON file (admin). Run `makea-cli get-supplier-profile-schema` FIRST to get the fi… | `update-supplier` |
186
189
  | `makea-cli admin update task` | write(ask) | `POST /admin/tasks/{task_id}/{done\|dismiss\|note}` | close a Makea task with a note: `--done` once handled (a held lesson's `--reason` goes to Beeboo's next reading), `--dismiss`, or `--dismiss --wrong` when it should never have been raised; `--note` alone adds a note and leaves it open. | — |
190
+ | `makea-cli admin update consignment` | write(ask) | `PUT /admin/{production_orders\|shipping_orders}/{id}/consignments/{consignment_id}` | edit one lot; `--delivered` marks it delivered through the tracking sweep path (a middle lot tells the brand in-app and on WhatsApp, the last one delivers the order); `--silent` tells nobody. | — |
187
191
  | `makea-cli admin update ship-log` | write(ask) | `PATCH /admin/ship-log/deploys/{deploy_id}` | fix a Ship log entry's title, summary or watch note; `--media` attaches more recordings. | — |
188
192
  | `makea-cli admin update tech-spec` | write(ask) | `POST /admin/products/{id}/technical-specifications` | persist specs from a JSON file. | `save-product-tech-spec` |
189
193
  | `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). | — |
@@ -1,6 +1,6 @@
1
- makea_cli/__init__.py,sha256=5TnwcrtiZS4c6J_QH9Z6CeZN1Ljn_ZOqbNVg9Dw2Xsk,23
1
+ makea_cli/__init__.py,sha256=5ZoGMhOu85BCUht7p7mDjOUD0Ek7HaoVyA0NOs5A-L0,23
2
2
  makea_cli/__main__.py,sha256=AkQjxWfKE3w9iD1d6I-2Zqvv2t9cct0oYyFF0UiA-Z0,144
3
- makea_cli/api_client.py,sha256=vswba4w8c3_LzIA7H728XjUezgDg0o6uH6VotQZC73I,83368
3
+ makea_cli/api_client.py,sha256=HBxrRDHzWe7VCHKgr3gPQirYRHlfLvMHns4vXKGv9h0,85257
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/companion.py,sha256=lEEMRDbS-5-CWPawlkPDeCij08pAYW8MsXLVSG3_8V0,10116
@@ -52,12 +52,12 @@ makea_cli/commands/production/pricing_spec.py,sha256=xGbj7-ps3PcKuU6Oc59A70b62Fj
52
52
  makea_cli/commands/shiplog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  makea_cli/commands/shiplog/cmd.py,sha256=XrqLdIJNxxwSTZQ1vqK2LJOrd18x7PEky78S2-lGe7o,10172
54
54
  makea_cli/commands/shipping/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- makea_cli/commands/shipping/cmd.py,sha256=ozt73pj3onlOv0NhEwiJlslyG9WOycE0QN4tmzwFlT0,17280
55
+ makea_cli/commands/shipping/cmd.py,sha256=PI0kyaJJgYBcfkwKq9sKrQ9MXUH3VqvbsI3_6JG6Dmg,26290
56
56
  makea_cli/commands/supplier/__init__.py,sha256=qfQDeQdQ-B7I_uwFVfcp1vXFUTL4fAcNLu3ipsZ7dfs,77
57
57
  makea_cli/commands/supplier/cmd.py,sha256=12YzQIz8478ksOUbuI7pSwSAwQAqLTvXu-AKjyrwLgA,64039
58
58
  makea_cli/commands/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  makea_cli/commands/tasks/cmd.py,sha256=72MrVigmjjQCpDVF2a3aJn_gclw2iBbJdFmyd87mXec,8549
60
- makea_cli-0.2.34.dist-info/METADATA,sha256=Nb2JGTwWM82S7k5GtdXCaexvpVbP6pRqonW-My0PIB4,46220
61
- makea_cli-0.2.34.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
62
- makea_cli-0.2.34.dist-info/entry_points.txt,sha256=4x-lbVa1jBbNlkNq7L-rYyfRh2spZmc3BLIzP-Dl-Qk,50
63
- makea_cli-0.2.34.dist-info/RECORD,,
60
+ makea_cli-0.2.35.dist-info/METADATA,sha256=0LiiWfvFcceLTx3P1YIMpia-NyzTPzMVTKZGw5JvScI,47396
61
+ makea_cli-0.2.35.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
62
+ makea_cli-0.2.35.dist-info/entry_points.txt,sha256=4x-lbVa1jBbNlkNq7L-rYyfRh2spZmc3BLIzP-Dl-Qk,50
63
+ makea_cli-0.2.35.dist-info/RECORD,,