@omni-commerce/cli 0.22.0 → 0.25.0

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.
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ async function openBrowser(url) {
84
84
  }
85
85
 
86
86
  // src/version.ts
87
- var CLI_VERSION = "0.22.0";
87
+ var CLI_VERSION = "0.25.0";
88
88
 
89
89
  // src/browser-login.ts
90
90
  function loginOrigin(baseUrl) {
@@ -434,6 +434,267 @@ var COMMANDS = [
434
434
  acceptsFile: false,
435
435
  bodyRequired: true
436
436
  },
437
+ {
438
+ trail: ["ads", "list-accounts"],
439
+ resourcePath: ["ads"],
440
+ methodName: "listAccounts",
441
+ httpMethod: "GET",
442
+ path: "/api/v1/ads/accounts",
443
+ summary: "List Ads accounts and capabilities",
444
+ description: "Requires ads:read. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
445
+ flags: [
446
+ {
447
+ name: "marketplaces",
448
+ flag: "marketplaces",
449
+ required: false,
450
+ source: "query"
451
+ },
452
+ {
453
+ name: "organizationId",
454
+ flag: "organization-id",
455
+ required: false,
456
+ source: "query"
457
+ }
458
+ ],
459
+ acceptsJsonBody: false,
460
+ acceptsFile: false,
461
+ bodyRequired: false
462
+ },
463
+ {
464
+ trail: ["ads", "list-campaigns"],
465
+ resourcePath: ["ads"],
466
+ methodName: "listCampaigns",
467
+ httpMethod: "GET",
468
+ path: "/api/v1/ads/campaigns",
469
+ summary: "List saved and synced ads",
470
+ description: "Requires ads:read. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
471
+ flags: [
472
+ {
473
+ name: "status",
474
+ flag: "status",
475
+ required: false,
476
+ source: "query"
477
+ },
478
+ {
479
+ name: "q",
480
+ flag: "q",
481
+ required: false,
482
+ source: "query"
483
+ },
484
+ {
485
+ name: "marketplace",
486
+ flag: "marketplace",
487
+ required: false,
488
+ source: "query"
489
+ },
490
+ {
491
+ name: "store",
492
+ flag: "store",
493
+ required: false,
494
+ source: "query"
495
+ },
496
+ {
497
+ name: "offset",
498
+ flag: "offset",
499
+ required: false,
500
+ source: "query"
501
+ },
502
+ {
503
+ name: "organizationId",
504
+ flag: "organization-id",
505
+ required: false,
506
+ source: "query"
507
+ }
508
+ ],
509
+ acceptsJsonBody: false,
510
+ acceptsFile: false,
511
+ bodyRequired: false
512
+ },
513
+ {
514
+ trail: ["ads", "create-campaign"],
515
+ resourcePath: ["ads"],
516
+ methodName: "createCampaign",
517
+ httpMethod: "POST",
518
+ path: "/api/v1/ads/campaigns",
519
+ summary: "Draft a multi-store Ads campaign",
520
+ description: "Requires ads:write. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
521
+ flags: [],
522
+ acceptsJsonBody: true,
523
+ acceptsFile: false,
524
+ bodyRequired: true
525
+ },
526
+ {
527
+ trail: ["ads", "act-on-campaigns"],
528
+ resourcePath: ["ads"],
529
+ methodName: "actOnCampaigns",
530
+ httpMethod: "POST",
531
+ path: "/api/v1/ads/campaigns/actions",
532
+ summary: "Approve, stop or retry Ads campaign groups",
533
+ description: "Requires ads:approve. Every target is organization/store scoped. Accepted work runs durably; inspect per-target outcomes and returned planIds/jobIds until verified. Approval uses saved immutable seller budgets and schedules. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
534
+ flags: [],
535
+ acceptsJsonBody: true,
536
+ acceptsFile: false,
537
+ bodyRequired: true
538
+ },
539
+ {
540
+ trail: ["ads", "get-live-campaigns"],
541
+ resourcePath: ["ads"],
542
+ methodName: "getLiveCampaigns",
543
+ httpMethod: "POST",
544
+ path: "/api/v1/ads/campaigns/live",
545
+ summary: "Read live marketplace campaigns",
546
+ description: "Requires ads:read. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
547
+ flags: [],
548
+ acceptsJsonBody: true,
549
+ acceptsFile: false,
550
+ bodyRequired: true
551
+ },
552
+ {
553
+ trail: ["ads", "get-campaigns"],
554
+ resourcePath: ["ads"],
555
+ methodName: "getCampaigns",
556
+ httpMethod: "POST",
557
+ path: "/api/v1/ads/campaigns/read",
558
+ summary: "Read saved Ads campaign groups",
559
+ description: "Requires ads:read. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
560
+ flags: [],
561
+ acceptsJsonBody: true,
562
+ acceptsFile: false,
563
+ bodyRequired: true
564
+ },
565
+ {
566
+ trail: ["ads", "get-performance"],
567
+ resourcePath: ["ads"],
568
+ methodName: "getPerformance",
569
+ httpMethod: "POST",
570
+ path: "/api/v1/ads/performance",
571
+ summary: "Read live Ads performance",
572
+ description: "Requires ads:read. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
573
+ flags: [],
574
+ acceptsJsonBody: true,
575
+ acceptsFile: false,
576
+ bodyRequired: true
577
+ },
578
+ {
579
+ trail: ["ads", "act-on-plans"],
580
+ resourcePath: ["ads"],
581
+ methodName: "actOnPlans",
582
+ httpMethod: "POST",
583
+ path: "/api/v1/ads/plans/actions",
584
+ summary: "Approve, stop or retry legacy Ads plans",
585
+ description: "Requires ads:approve. Every target is organization/store scoped. Accepted work runs durably; inspect per-target outcomes and returned planIds/jobIds until verified. Approval uses saved immutable seller budgets and schedules. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
586
+ flags: [],
587
+ acceptsJsonBody: true,
588
+ acceptsFile: false,
589
+ bodyRequired: true
590
+ },
591
+ {
592
+ trail: ["ads", "get-plans"],
593
+ resourcePath: ["ads"],
594
+ methodName: "getPlans",
595
+ httpMethod: "POST",
596
+ path: "/api/v1/ads/plans/status",
597
+ summary: "Read delivery and verification evidence",
598
+ description: "Requires ads:read. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
599
+ flags: [],
600
+ acceptsJsonBody: true,
601
+ acceptsFile: false,
602
+ bodyRequired: true
603
+ },
604
+ {
605
+ trail: ["ads", "get-reports"],
606
+ resourcePath: ["ads"],
607
+ methodName: "getReports",
608
+ httpMethod: "GET",
609
+ path: "/api/v1/ads/reports",
610
+ summary: "Read persisted campaign reports",
611
+ description: "Requires ads:read. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
612
+ flags: [
613
+ {
614
+ name: "from",
615
+ flag: "from",
616
+ required: true,
617
+ source: "query"
618
+ },
619
+ {
620
+ name: "to",
621
+ flag: "to",
622
+ required: true,
623
+ source: "query"
624
+ },
625
+ {
626
+ name: "marketplace",
627
+ flag: "marketplace",
628
+ required: false,
629
+ source: "query"
630
+ },
631
+ {
632
+ name: "country",
633
+ flag: "country",
634
+ required: false,
635
+ source: "query"
636
+ },
637
+ {
638
+ name: "store",
639
+ flag: "store",
640
+ required: false,
641
+ source: "query"
642
+ },
643
+ {
644
+ name: "currency",
645
+ flag: "currency",
646
+ required: false,
647
+ source: "query"
648
+ },
649
+ {
650
+ name: "campaign",
651
+ flag: "campaign",
652
+ required: false,
653
+ source: "query"
654
+ },
655
+ {
656
+ name: "offset",
657
+ flag: "offset",
658
+ required: false,
659
+ source: "query"
660
+ },
661
+ {
662
+ name: "organizationId",
663
+ flag: "organization-id",
664
+ required: false,
665
+ source: "query"
666
+ }
667
+ ],
668
+ acceptsJsonBody: false,
669
+ acceptsFile: false,
670
+ bodyRequired: false
671
+ },
672
+ {
673
+ trail: ["ads", "sync-reports"],
674
+ resourcePath: ["ads"],
675
+ methodName: "syncReports",
676
+ httpMethod: "POST",
677
+ path: "/api/v1/ads/sync",
678
+ summary: "Queue Ads report imports",
679
+ description: "Requires ads:read. Every target is organization/store scoped. Accepted work runs durably; inspect per-target outcomes and returned planIds/jobIds until verified. Approval uses saved immutable seller budgets and schedules. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
680
+ flags: [],
681
+ acceptsJsonBody: true,
682
+ acceptsFile: false,
683
+ bodyRequired: true
684
+ },
685
+ {
686
+ trail: ["ads", "get-sync-status"],
687
+ resourcePath: ["ads"],
688
+ methodName: "getSyncStatus",
689
+ httpMethod: "POST",
690
+ path: "/api/v1/ads/sync/status",
691
+ summary: "Read Ads import job status",
692
+ description: "Requires ads:read. Every target is organization/store scoped. Partial failures are explicit in data.success and ordered results. Shopee and Lazada support only the formats returned by accounts. Other marketplaces report a concrete limitation. External campaign IDs differ from saved campaign group UUIDs.",
693
+ flags: [],
694
+ acceptsJsonBody: true,
695
+ acceptsFile: false,
696
+ bodyRequired: true
697
+ },
437
698
  {
438
699
  trail: ["agents", "invoke"],
439
700
  resourcePath: ["agents"],
@@ -1356,6 +1617,200 @@ var COMMANDS = [
1356
1617
  acceptsFile: false,
1357
1618
  bodyRequired: true
1358
1619
  },
1620
+ {
1621
+ trail: ["bots", "list"],
1622
+ resourcePath: ["bots"],
1623
+ methodName: "list",
1624
+ httpMethod: "GET",
1625
+ path: "/api/v1/bots",
1626
+ summary: "List personal Bots",
1627
+ description: "Requires agents:invoke and assistant.use. Use a signed-in member session or a member's CLI token. Organization OAuth and Computer credentials cannot access personal Bots.",
1628
+ flags: [
1629
+ {
1630
+ name: "organizationId",
1631
+ flag: "organization-id",
1632
+ required: false,
1633
+ source: "query"
1634
+ },
1635
+ {
1636
+ name: "q",
1637
+ flag: "q",
1638
+ required: false,
1639
+ source: "query"
1640
+ },
1641
+ {
1642
+ name: "page",
1643
+ flag: "page",
1644
+ required: false,
1645
+ source: "query"
1646
+ },
1647
+ {
1648
+ name: "status",
1649
+ flag: "status",
1650
+ required: false,
1651
+ source: "query"
1652
+ }
1653
+ ],
1654
+ acceptsJsonBody: false,
1655
+ acceptsFile: false,
1656
+ bodyRequired: false
1657
+ },
1658
+ {
1659
+ trail: ["bots", "create"],
1660
+ resourcePath: ["bots"],
1661
+ methodName: "create",
1662
+ httpMethod: "POST",
1663
+ path: "/api/v1/bots",
1664
+ summary: "Create a personal Bot",
1665
+ description: "Requires agents:invoke and assistant.use. Use a signed-in member session or a member's CLI token. Organization OAuth and Computer credentials cannot access personal Bots.",
1666
+ flags: [
1667
+ {
1668
+ name: "organizationId",
1669
+ flag: "organization-id",
1670
+ required: false,
1671
+ source: "query"
1672
+ }
1673
+ ],
1674
+ acceptsJsonBody: true,
1675
+ acceptsFile: false,
1676
+ bodyRequired: true
1677
+ },
1678
+ {
1679
+ trail: ["bots", "list-routines"],
1680
+ resourcePath: ["bots"],
1681
+ methodName: "listRoutines",
1682
+ httpMethod: "GET",
1683
+ path: "/api/v1/bots/{botId}/routines",
1684
+ summary: "List a Bot's routines",
1685
+ description: "Requires agents:invoke and assistant.use. Use a signed-in member session or a member's CLI token. Organization OAuth and Computer credentials cannot access personal Bots.",
1686
+ flags: [
1687
+ {
1688
+ name: "botId",
1689
+ flag: "bot-id",
1690
+ required: true,
1691
+ source: "path"
1692
+ },
1693
+ {
1694
+ name: "organizationId",
1695
+ flag: "organization-id",
1696
+ required: false,
1697
+ source: "query"
1698
+ }
1699
+ ],
1700
+ acceptsJsonBody: false,
1701
+ acceptsFile: false,
1702
+ bodyRequired: false
1703
+ },
1704
+ {
1705
+ trail: ["bots", "mutate-routines"],
1706
+ resourcePath: ["bots"],
1707
+ methodName: "mutateRoutines",
1708
+ httpMethod: "POST",
1709
+ path: "/api/v1/bots/{botId}/routines",
1710
+ summary: "Manage a Bot's routines",
1711
+ description: "Requires agents:invoke and assistant.use. Use a signed-in member session or a member's CLI token. Organization OAuth and Computer credentials cannot access personal Bots.\n\nCreate, edit, link, pause, resume, delete, test, or run a batch of routines. New personal routines start paused. Reuse the same requestId only when retrying the same request. Inspect every ordered result before retrying failed targets.",
1712
+ flags: [
1713
+ {
1714
+ name: "botId",
1715
+ flag: "bot-id",
1716
+ required: true,
1717
+ source: "path"
1718
+ },
1719
+ {
1720
+ name: "organizationId",
1721
+ flag: "organization-id",
1722
+ required: false,
1723
+ source: "query"
1724
+ }
1725
+ ],
1726
+ acceptsJsonBody: true,
1727
+ acceptsFile: false,
1728
+ bodyRequired: true
1729
+ },
1730
+ {
1731
+ trail: ["bots", "list-runs"],
1732
+ resourcePath: ["bots"],
1733
+ methodName: "listRuns",
1734
+ httpMethod: "GET",
1735
+ path: "/api/v1/bots/{botId}/runs",
1736
+ summary: "List a Bot's message runs",
1737
+ description: "Requires agents:invoke and assistant.use. Use a signed-in member session or a member's CLI token. Organization OAuth and Computer credentials cannot access personal Bots.",
1738
+ flags: [
1739
+ {
1740
+ name: "botId",
1741
+ flag: "bot-id",
1742
+ required: true,
1743
+ source: "path"
1744
+ },
1745
+ {
1746
+ name: "organizationId",
1747
+ flag: "organization-id",
1748
+ required: false,
1749
+ source: "query"
1750
+ }
1751
+ ],
1752
+ acceptsJsonBody: false,
1753
+ acceptsFile: false,
1754
+ bodyRequired: false
1755
+ },
1756
+ {
1757
+ trail: ["bots", "send-message"],
1758
+ resourcePath: ["bots"],
1759
+ methodName: "sendMessage",
1760
+ httpMethod: "POST",
1761
+ path: "/api/v1/bots/{botId}/runs",
1762
+ summary: "Send a message to a Bot",
1763
+ description: "Requires agents:invoke and assistant.use. Use a signed-in member session or a member's CLI token. Organization OAuth and Computer credentials cannot access personal Bots.\n\nReuse the same requestId when retrying a submission. The response Location points to the run status.",
1764
+ flags: [
1765
+ {
1766
+ name: "botId",
1767
+ flag: "bot-id",
1768
+ required: true,
1769
+ source: "path"
1770
+ },
1771
+ {
1772
+ name: "organizationId",
1773
+ flag: "organization-id",
1774
+ required: false,
1775
+ source: "query"
1776
+ }
1777
+ ],
1778
+ acceptsJsonBody: true,
1779
+ acceptsFile: false,
1780
+ bodyRequired: true
1781
+ },
1782
+ {
1783
+ trail: ["bots", "get-run"],
1784
+ resourcePath: ["bots"],
1785
+ methodName: "getRun",
1786
+ httpMethod: "GET",
1787
+ path: "/api/v1/bots/{botId}/runs/{runId}",
1788
+ summary: "Read a Bot message run",
1789
+ description: "Requires agents:invoke and assistant.use. Use a signed-in member session or a member's CLI token. Organization OAuth and Computer credentials cannot access personal Bots.\n\nReturns the run's status, visible reply, and approval URL when available. Archived runs retain their status. Reopen their conversation to read the reply after the active run journal expires.",
1790
+ flags: [
1791
+ {
1792
+ name: "botId",
1793
+ flag: "bot-id",
1794
+ required: true,
1795
+ source: "path"
1796
+ },
1797
+ {
1798
+ name: "runId",
1799
+ flag: "run-id",
1800
+ required: true,
1801
+ source: "path"
1802
+ },
1803
+ {
1804
+ name: "organizationId",
1805
+ flag: "organization-id",
1806
+ required: false,
1807
+ source: "query"
1808
+ }
1809
+ ],
1810
+ acceptsJsonBody: false,
1811
+ acceptsFile: false,
1812
+ bodyRequired: false
1813
+ },
1359
1814
  {
1360
1815
  trail: ["brand-kits", "list"],
1361
1816
  resourcePath: ["brandKits"],
@@ -1925,51 +2380,151 @@ var COMMANDS = [
1925
2380
  source: "query"
1926
2381
  },
1927
2382
  {
1928
- name: "format",
1929
- flag: "format",
2383
+ name: "format",
2384
+ flag: "format",
2385
+ required: false,
2386
+ source: "query"
2387
+ }
2388
+ ],
2389
+ acceptsJsonBody: false,
2390
+ acceptsFile: false,
2391
+ bodyRequired: false
2392
+ },
2393
+ {
2394
+ trail: ["bulk", "list-for-session"],
2395
+ resourcePath: ["bulk"],
2396
+ methodName: "listForSession",
2397
+ httpMethod: "GET",
2398
+ path: "/api/v1/catalog/operations",
2399
+ summary: "List Catalog Operations for Session",
2400
+ description: "Read the latest 20 compact catalog-operation summaries linked to an authorized session. Requires catalog:read; product data scope is rechecked.",
2401
+ flags: [
2402
+ {
2403
+ name: "organizationId",
2404
+ flag: "organization-id",
2405
+ required: false,
2406
+ source: "query"
2407
+ },
2408
+ {
2409
+ name: "sessionId",
2410
+ flag: "session-id",
2411
+ required: true,
2412
+ source: "query"
2413
+ }
2414
+ ],
2415
+ acceptsJsonBody: false,
2416
+ acceptsFile: false,
2417
+ bodyRequired: false
2418
+ },
2419
+ {
2420
+ trail: ["bulk", "start"],
2421
+ resourcePath: ["bulk"],
2422
+ methodName: "start",
2423
+ httpMethod: "POST",
2424
+ path: "/api/v1/catalog/operations",
2425
+ summary: "Start Catalog Operation",
2426
+ description: "### Scope\n\nDurable bulk price/cost updates for 1\u20132000 products or variants. Requires catalog:write.\n\n### Consistency and progress\n\nIdentical duplicates collapse in requested order; conflicting duplicates fail. An idempotencyKey freezes the original targets and versions. Reusing it with changed input returns 409. expectedUpdatedAt guards reviewed values. Catalog cost never syncs to marketplaces. syncToMarketplaces queues existing canonical marketplace services for every applicable connected listing. A failed target does not stop other targets. The operation continues after the caller disconnects. Read aggregate status, then page failures through bulk.results. Optional sessionId links progress to the initiating user's existing session.",
2427
+ flags: [],
2428
+ acceptsJsonBody: true,
2429
+ acceptsFile: false,
2430
+ bodyRequired: true
2431
+ },
2432
+ {
2433
+ trail: ["bulk", "plan"],
2434
+ resourcePath: ["bulk"],
2435
+ methodName: "plan",
2436
+ httpMethod: "POST",
2437
+ path: "/api/v1/catalog/operations/plan",
2438
+ summary: "Create Catalog Operation Plan",
2439
+ description: "Create a staged pricing, catalog record import, or reviewable enrichment plan for up to one million targets. Add enrichment options for listing copy, images, or store taxonomy, or importRecords for new catalog records. Set importRecords.update on a file plan to prepare exact-SKU price or warehouse stock updates for review. An optional selection filter prepares an enrichment plan server-side. Poll status until draft, review the total, and explicitly submit. Repeat the original create request after an interruption. If the selection exceeds the limit, narrow the filters and create a new plan. The initiating identity can upload ordered chunks and submit the plan when complete. Reusing the same idempotency key and options resumes that plan. Requires catalog:write and catalog:read. Enrichment also requires catalog:enrich. Marketplace price sync also requires catalog:sync.",
2440
+ flags: [
2441
+ {
2442
+ name: "organizationId",
2443
+ flag: "organization-id",
2444
+ required: false,
2445
+ source: "query"
2446
+ }
2447
+ ],
2448
+ acceptsJsonBody: true,
2449
+ acceptsFile: false,
2450
+ bodyRequired: true
2451
+ },
2452
+ {
2453
+ trail: ["bulk", "append"],
2454
+ resourcePath: ["bulk"],
2455
+ methodName: "append",
2456
+ httpMethod: "POST",
2457
+ path: "/api/v1/catalog/operations/plan/append",
2458
+ summary: "Append Catalog Operation Chunk",
2459
+ description: "Upload up to 500 distinct targets at the next chunkIndex, starting at zero. Provide updates for pricing, productIds for enrichment, or products for record imports. Each product belongs to one chunk. Replaying the same chunk index and content is safe and returns the latest upload progress. Pricing captures product versions when targets are appended. Enrichment receipts identify the linked review and report when generation reaches review. Requires catalog:write.",
2460
+ flags: [
2461
+ {
2462
+ name: "organizationId",
2463
+ flag: "organization-id",
2464
+ required: false,
2465
+ source: "query"
2466
+ }
2467
+ ],
2468
+ acceptsJsonBody: true,
2469
+ acceptsFile: false,
2470
+ bodyRequired: true
2471
+ },
2472
+ {
2473
+ trail: ["bulk", "complete-file"],
2474
+ resourcePath: ["bulk"],
2475
+ methodName: "completeFile",
2476
+ httpMethod: "POST",
2477
+ path: "/api/v1/catalog/operations/plan/file-complete",
2478
+ summary: "Complete Catalog File",
2479
+ description: "Queue validation and import after all file parts are uploaded. For importRecords.update, validation ends at ready_for_review. Read the ordered preview with bulk.results and submit explicitly with expectedProductCount. For create-only file imports, validation queues the import automatically. Then follow the same operation in bulk.status and bulk.results. Repeat this request after a retryable interruption. Requires catalog:read and catalog:write.",
2480
+ flags: [
2481
+ {
2482
+ name: "organizationId",
2483
+ flag: "organization-id",
1930
2484
  required: false,
1931
2485
  source: "query"
1932
2486
  }
1933
2487
  ],
1934
- acceptsJsonBody: false,
2488
+ acceptsJsonBody: true,
1935
2489
  acceptsFile: false,
1936
- bodyRequired: false
2490
+ bodyRequired: true
1937
2491
  },
1938
2492
  {
1939
- trail: ["bulk", "list-for-session"],
2493
+ trail: ["bulk", "file-parts"],
1940
2494
  resourcePath: ["bulk"],
1941
- methodName: "listForSession",
1942
- httpMethod: "GET",
1943
- path: "/api/v1/catalog/operations",
1944
- summary: "List Catalog Operations for Session",
1945
- description: "Read the latest 20 compact catalog-operation summaries linked to an authorized session. Requires catalog:read; product data scope is rechecked.",
2495
+ methodName: "fileParts",
2496
+ httpMethod: "POST",
2497
+ path: "/api/v1/catalog/operations/plan/file-parts",
2498
+ summary: "Prepare Catalog File Parts",
2499
+ description: "Request signed PUT URLs for up to eight file parts. Each is 8 MiB except the final part. Send the exact bytes and x-amz-checksum-sha256 header to the signed URL. Previously uploaded matching parts are skipped. Requires catalog:read and catalog:write.",
1946
2500
  flags: [
1947
2501
  {
1948
2502
  name: "organizationId",
1949
2503
  flag: "organization-id",
1950
2504
  required: false,
1951
2505
  source: "query"
1952
- },
1953
- {
1954
- name: "sessionId",
1955
- flag: "session-id",
1956
- required: true,
1957
- source: "query"
1958
2506
  }
1959
2507
  ],
1960
- acceptsJsonBody: false,
2508
+ acceptsJsonBody: true,
1961
2509
  acceptsFile: false,
1962
- bodyRequired: false
2510
+ bodyRequired: true
1963
2511
  },
1964
2512
  {
1965
- trail: ["bulk", "start"],
2513
+ trail: ["bulk", "submit"],
1966
2514
  resourcePath: ["bulk"],
1967
- methodName: "start",
2515
+ methodName: "submit",
1968
2516
  httpMethod: "POST",
1969
- path: "/api/v1/catalog/operations",
1970
- summary: "Start Catalog Operation",
1971
- description: "### Scope\n\nDurable bulk price/cost updates for 1\u20132000 products or variants. Requires catalog:write.\n\n### Consistency and progress\n\nIdentical duplicates collapse in requested order; conflicting duplicates fail. An idempotencyKey freezes the original targets and versions. Reusing it with changed input returns 409. expectedUpdatedAt guards reviewed values. Catalog cost never syncs to marketplaces. syncToMarketplaces queues existing canonical marketplace services for every applicable connected listing. A failed target does not stop other targets. The operation continues after the caller disconnects. Read aggregate status, then page failures through bulk.results. Optional sessionId links progress to the initiating user's existing session.",
1972
- flags: [],
2517
+ path: "/api/v1/catalog/operations/plan/submit",
2518
+ summary: "Submit Catalog Operation Plan",
2519
+ description: "Seal and queue the uploaded plan if its product count matches expectedProductCount. Retry the same request if admission is interrupted. Use bulk.status and bulk.results for progress and receipts. Requires the same scopes as plan creation.",
2520
+ flags: [
2521
+ {
2522
+ name: "organizationId",
2523
+ flag: "organization-id",
2524
+ required: false,
2525
+ source: "query"
2526
+ }
2527
+ ],
1973
2528
  acceptsJsonBody: true,
1974
2529
  acceptsFile: false,
1975
2530
  bodyRequired: true
@@ -1981,7 +2536,7 @@ var COMMANDS = [
1981
2536
  httpMethod: "POST",
1982
2537
  path: "/api/v1/catalog/operations/results",
1983
2538
  summary: "Get Catalog Operation Results",
1984
- description: "Read ordered per-product receipts and verification evidence for up to 50 operationIds. Filter status=failed to inspect failures directly. At most 100 rows across the requested operations per page. Requires catalog:read.",
2539
+ description: "Read ordered per-product receipts and verification evidence for up to 50 operationIds. Filter status=failed to inspect failures directly. Pass nextPageKey as after on the next request, keeping the operation order and status filter the same. At most 100 rows per page. Requires catalog:read.",
1985
2540
  flags: [],
1986
2541
  acceptsJsonBody: true,
1987
2542
  acceptsFile: false,
@@ -1994,7 +2549,7 @@ var COMMANDS = [
1994
2549
  httpMethod: "POST",
1995
2550
  path: "/api/v1/catalog/operations/status",
1996
2551
  summary: "Get Catalog Operation Status",
1997
- description: "Read compact progress for up to 50 operationIds in first-requested order. Pending is incomplete, and partial failures remain explicit. Requires catalog:read. Detailed receipts are returned only by the paginated report API.",
2552
+ description: "Read compact progress for up to 50 operationIds in first-requested order. Draft plans are still accepting input. A file update at ready_for_review requires approval via bulk.submit. Pending is incomplete, and partial failures remain explicit. Requires catalog:read. Detailed receipts are returned by the paginated results API.",
1998
2553
  flags: [],
1999
2554
  acceptsJsonBody: true,
2000
2555
  acceptsFile: false,
@@ -2352,6 +2907,19 @@ var COMMANDS = [
2352
2907
  acceptsFile: false,
2353
2908
  bodyRequired: true
2354
2909
  },
2910
+ {
2911
+ trail: ["email", "get-drafts"],
2912
+ resourcePath: ["email"],
2913
+ methodName: "getDrafts",
2914
+ httpMethod: "POST",
2915
+ path: "/api/v1/email/drafts/query",
2916
+ summary: "Get Email Drafts",
2917
+ description: "Read exact unsent drafts in one connected mailbox. Pass one to twenty draft resource IDs, in request order. Duplicate IDs are read once. The result includes a per-draft outcome for every distinct ID.\n\n### Authorization\n\nRequires `email:read` and the integration permission the matching chat tool needs, with a person's credential: a CLI login, a signed-in session, or the SDK key inside your own chat sandbox. Only your own connected mailboxes are reachable; another account's `connectionId` is refused.",
2918
+ flags: [],
2919
+ acceptsJsonBody: true,
2920
+ acceptsFile: false,
2921
+ bodyRequired: true
2922
+ },
2355
2923
  {
2356
2924
  trail: ["email", "get-message"],
2357
2925
  resourcePath: ["email"],
@@ -2434,6 +3002,38 @@ var COMMANDS = [
2434
3002
  acceptsFile: false,
2435
3003
  bodyRequired: false
2436
3004
  },
3005
+ {
3006
+ trail: ["email", "get-thread"],
3007
+ resourcePath: ["email"],
3008
+ methodName: "getThread",
3009
+ httpMethod: "GET",
3010
+ path: "/api/v1/email/threads/{threadId}",
3011
+ summary: "Get Email Thread",
3012
+ description: "Read the Gmail or Outlook conversation for a `threadId` from Search Emails. Each message includes headers, up to 8,000 characters of plain text, and read and draft state.\n\n### Authorization\n\nRequires `email:read` and the integration permission the matching chat tool needs, with a person's credential: a CLI login, a signed-in session, or the SDK key inside your own chat sandbox. Only your own connected mailboxes are reachable; another account's `connectionId` is refused.",
3013
+ flags: [
3014
+ {
3015
+ name: "threadId",
3016
+ flag: "thread-id",
3017
+ required: true,
3018
+ source: "path"
3019
+ },
3020
+ {
3021
+ name: "connectionId",
3022
+ flag: "connection-id",
3023
+ required: false,
3024
+ source: "query"
3025
+ },
3026
+ {
3027
+ name: "organizationId",
3028
+ flag: "organization-id",
3029
+ required: false,
3030
+ source: "query"
3031
+ }
3032
+ ],
3033
+ acceptsJsonBody: false,
3034
+ acceptsFile: false,
3035
+ bodyRequired: false
3036
+ },
2437
3037
  {
2438
3038
  trail: ["evaluate", "run"],
2439
3039
  resourcePath: ["evaluate"],
@@ -4980,6 +5580,26 @@ var COMMANDS = [
4980
5580
  acceptsFile: false,
4981
5581
  bodyRequired: true
4982
5582
  },
5583
+ {
5584
+ trail: ["review-queue", "apply"],
5585
+ resourcePath: ["reviewQueue"],
5586
+ methodName: "apply",
5587
+ httpMethod: "POST",
5588
+ path: "/api/v1/review-queue/{batchId}/apply",
5589
+ summary: "Apply Review Queue Corrections",
5590
+ description: "Requires `catalog:write`. Apply up to 100 item corrections across this job's linked scopes using each workflow's existing proposal validation. editedProposal follows the saved workflow proposal shape returned by items; images select existing candidate IDs. Duplicate item corrections are rejected. Product version and gallery checks remain enforced. Once all scopes commit, saved auto-publish requests continue automatically. Use repair-products for corrections to already approved catalog data.",
5591
+ flags: [
5592
+ {
5593
+ name: "batchId",
5594
+ flag: "batch-id",
5595
+ required: true,
5596
+ source: "path"
5597
+ }
5598
+ ],
5599
+ acceptsJsonBody: true,
5600
+ acceptsFile: false,
5601
+ bodyRequired: true
5602
+ },
4983
5603
  {
4984
5604
  trail: ["review-queue", "approve"],
4985
5605
  resourcePath: ["reviewQueue"],
@@ -4987,7 +5607,27 @@ var COMMANDS = [
4987
5607
  httpMethod: "POST",
4988
5608
  path: "/api/v1/review-queue/{batchId}/approve",
4989
5609
  summary: "Approve Review Queue Items",
4990
- description: "Requires `catalog:write`.\n\nApplies up to 100 explicitly selected review item IDs from the job and its linked batches. Approves the saved proposals through the catalog's normal stale-product and gallery checks. Set allowProductChangedOverride explicitly to approve despite an intervening product change. Already applied items are safe to resubmit. Call the publish endpoint separately to release approved changes.",
5610
+ description: "Requires `catalog:write`.\n\nApplies up to 100 explicitly selected review item IDs from the job and its linked batches through the normal stale-product and gallery checks. Already applied items are safe to resubmit. Saved auto-publish requests continue after approval commits and all scopes for that product are applied. Otherwise use publish explicitly. Approval is not confirmation of marketplace publication.",
5611
+ flags: [
5612
+ {
5613
+ name: "batchId",
5614
+ flag: "batch-id",
5615
+ required: true,
5616
+ source: "path"
5617
+ }
5618
+ ],
5619
+ acceptsJsonBody: true,
5620
+ acceptsFile: false,
5621
+ bodyRequired: true
5622
+ },
5623
+ {
5624
+ trail: ["review-queue", "diagnose"],
5625
+ resourcePath: ["reviewQueue"],
5626
+ methodName: "diagnose",
5627
+ httpMethod: "POST",
5628
+ path: "/api/v1/review-queue/{batchId}/diagnose",
5629
+ summary: "Diagnose Review Product Publishing",
5630
+ description: "Requires `catalog:read`. Diagnose 1\u201325 exact review product or physical variant IDs. Returns current canonical shipping measurements (grams and cm), product facts and images, variant values, exact store/category fields, required/missing attributes, allowed options and the latest publish job's message, code and request ID. No raw provider request bodies or credentials are exposed. Store, variant and attribute-option pages have explicit continuation offsets. success means diagnosis completed; publishReady describes saved catalog validation and does not promise marketplace acceptance. Use product.updatedAt unchanged for repairs. Only targets belonging to this organization and review are accessible.",
4991
5631
  flags: [
4992
5632
  {
4993
5633
  name: "batchId",
@@ -5000,6 +5640,63 @@ var COMMANDS = [
5000
5640
  acceptsFile: false,
5001
5641
  bodyRequired: true
5002
5642
  },
5643
+ {
5644
+ trail: ["review-queue", "list-items"],
5645
+ resourcePath: ["reviewQueue"],
5646
+ methodName: "listItems",
5647
+ httpMethod: "GET",
5648
+ path: "/api/v1/review-queue/{batchId}/items",
5649
+ summary: "List Review Queue Item Details",
5650
+ description: "Requires `catalog:read`. Pages through saved proposals, issues, current/baseline/applied snapshots and publish receipts across every scope in this review job. Limit 1\u201350; follow nextOffset until hasMore is false. Repeat productIds to filter up to 50 products. Automation state reports each scope separately; fullyAutomatic describes configuration, not successful approval or publication.",
5651
+ flags: [
5652
+ {
5653
+ name: "batchId",
5654
+ flag: "batch-id",
5655
+ required: true,
5656
+ source: "path"
5657
+ },
5658
+ {
5659
+ name: "organizationId",
5660
+ flag: "organization-id",
5661
+ required: false,
5662
+ source: "query"
5663
+ },
5664
+ {
5665
+ name: "limit",
5666
+ flag: "limit",
5667
+ required: false,
5668
+ source: "query"
5669
+ },
5670
+ {
5671
+ name: "offset",
5672
+ flag: "offset",
5673
+ required: false,
5674
+ source: "query"
5675
+ },
5676
+ {
5677
+ name: "status",
5678
+ flag: "status",
5679
+ required: false,
5680
+ source: "query"
5681
+ },
5682
+ {
5683
+ name: "workflow",
5684
+ flag: "workflow",
5685
+ required: false,
5686
+ source: "query"
5687
+ },
5688
+ {
5689
+ name: "productIds",
5690
+ flag: "product-ids",
5691
+ required: false,
5692
+ source: "query",
5693
+ queryArray: true
5694
+ }
5695
+ ],
5696
+ acceptsJsonBody: false,
5697
+ acceptsFile: false,
5698
+ bodyRequired: false
5699
+ },
5003
5700
  {
5004
5701
  trail: ["review-queue", "publish"],
5005
5702
  resourcePath: ["reviewQueue"],
@@ -5007,7 +5704,47 @@ var COMMANDS = [
5007
5704
  httpMethod: "POST",
5008
5705
  path: "/api/v1/review-queue/{batchId}/publish",
5009
5706
  summary: "Publish Review Queue Products",
5010
- description: "Requires `catalog:sync`.\n\nSpecify productIds and visibility. Only products with all review scopes applied and outstanding releases to assigned marketplace stores are eligible. Optionally filter by marketplaces. Inspect every product and listing result for preparation failures. HTTP 202 confirms queue acceptance. Pass every returned correlation to POST /api/v1/commerce/jobs/await to check marketplace outcomes.",
5707
+ description: "Requires `catalog:sync`.\n\nSpecify productIds and visibility. Only products with all review scopes applied and outstanding releases to assigned marketplace stores are eligible. Optionally filter by marketplaces and exact storeTargets to publish only repaired or failed stores. Inspect every product and listing result for preparation failures. HTTP 202 confirms queue acceptance. Pass every returned correlation to POST /api/v1/commerce/jobs/await and verify marketplace state before reporting publication.",
5708
+ flags: [
5709
+ {
5710
+ name: "batchId",
5711
+ flag: "batch-id",
5712
+ required: true,
5713
+ source: "path"
5714
+ }
5715
+ ],
5716
+ acceptsJsonBody: true,
5717
+ acceptsFile: false,
5718
+ bodyRequired: true
5719
+ },
5720
+ {
5721
+ trail: ["review-queue", "repair-products"],
5722
+ resourcePath: ["reviewQueue"],
5723
+ methodName: "repairProducts",
5724
+ httpMethod: "POST",
5725
+ path: "/api/v1/review-queue/{batchId}/repair-products",
5726
+ summary: "Repair Approved Review Products",
5727
+ description: "Requires `catalog:write`. Correct 1\u201325 already approved products with expectedUpdatedAt copied exactly from diagnosis. Patches only supplied weight (grams), complete package dimensions (cm) and exact assigned-store category attributes. Validates keys and fixed-choice values against current marketplace metadata. Records evidence URLs and the initiating actor in review history. Conflicting versions and pending review scopes fail explicitly; correct pending proposals through apply first. Shared category attributes belong to the parent; variant values use the variant API. Does not approve or publish implicitly. Reload diagnosis and publish exact repaired stores after success. Duplicate product corrections are rejected.",
5728
+ flags: [
5729
+ {
5730
+ name: "batchId",
5731
+ flag: "batch-id",
5732
+ required: true,
5733
+ source: "path"
5734
+ }
5735
+ ],
5736
+ acceptsJsonBody: true,
5737
+ acceptsFile: false,
5738
+ bodyRequired: true
5739
+ },
5740
+ {
5741
+ trail: ["review-queue", "retry"],
5742
+ resourcePath: ["reviewQueue"],
5743
+ methodName: "retry",
5744
+ httpMethod: "POST",
5745
+ path: "/api/v1/review-queue/{batchId}/retry",
5746
+ summary: "Retry Review Queue Processing",
5747
+ description: "Requires `catalog:write`. Explicitly restart existing durable review processing. scope defaults to failed; unfinished also includes unapplied work; all may regenerate applied proposals. Optionally restrict workflow and use a supported review model. No polling schedule is created. Read items to observe processing; this does not confirm publication.",
5011
5748
  flags: [
5012
5749
  {
5013
5750
  name: "batchId",
@@ -5020,6 +5757,19 @@ var COMMANDS = [
5020
5757
  acceptsFile: false,
5021
5758
  bodyRequired: true
5022
5759
  },
5760
+ {
5761
+ trail: ["review-queue", "enable-automation"],
5762
+ resourcePath: ["reviewQueue"],
5763
+ methodName: "enableAutomation",
5764
+ httpMethod: "POST",
5765
+ path: "/api/v1/review-queue/automation",
5766
+ summary: "Enable Review Queue Automation",
5767
+ description: "Requires both `catalog:write` and `catalog:sync`. Enable auto approval for enrichment, taxonomy and images plus saved auto-publish requests on 1\u2013100 existing root review jobs, through the same durable worker as the app. Applies eligible proposals and continues publishing after all scopes commit. Blocked or unverified facts remain visible for the bot to diagnose and correct. Read items.automation for per-scope configuration and publishing for actual outcomes. Inspect every batch result; acceptance does not mean the job is already fully automatic or published.",
5768
+ flags: [],
5769
+ acceptsJsonBody: true,
5770
+ acceptsFile: false,
5771
+ bodyRequired: true
5772
+ },
5023
5773
  {
5024
5774
  trail: ["review-queue", "get-settings"],
5025
5775
  resourcePath: ["reviewQueue"],
@@ -5027,7 +5777,7 @@ var COMMANDS = [
5027
5777
  httpMethod: "GET",
5028
5778
  path: "/api/v1/review-queue/settings",
5029
5779
  summary: "Get Review Queue Settings",
5030
- description: "Requires catalog:review-settings for bearer credentials and company settings read permission for delegated users.\n\nReturns the organization defaults for enrichment and taxonomy auto-apply confidence.",
5780
+ description: "Requires catalog:review-settings for bearer credentials and company settings read permission for delegated users.\n\nReturns the organization auto-apply switch and enrichment/taxonomy confidence defaults.",
5031
5781
  flags: [
5032
5782
  {
5033
5783
  name: "organizationId",
@@ -5047,7 +5797,7 @@ var COMMANDS = [
5047
5797
  httpMethod: "PATCH",
5048
5798
  path: "/api/v1/review-queue/settings",
5049
5799
  summary: "Update Review Queue Settings",
5050
- description: "Requires catalog:review-settings for bearer credentials and company settings write permission for delegated users.\n\nUpdate either or both thresholds from 0.50 to 1.00. Existing review jobs retain their saved settings.",
5800
+ description: "Requires catalog:review-settings for bearer credentials and company settings write permission for delegated users.\n\nSet autoApplyHighConfidence and/or confidence thresholds from 0.50 to 1.00. Existing review jobs retain their saved settings.",
5051
5801
  flags: [],
5052
5802
  acceptsJsonBody: true,
5053
5803
  acceptsFile: false,
@@ -7501,14 +8251,306 @@ function matchCommands(commands, trail) {
7501
8251
  return { exact, prefix };
7502
8252
  }
7503
8253
 
8254
+ // src/catalog-file-errors.ts
8255
+ import { readCatalogFileFailures } from "@omni-commerce/sdk";
8256
+ var CATALOG_FILE_ERRORS = {
8257
+ trail: ["bulk", "file-errors"],
8258
+ resourcePath: ["bulk"],
8259
+ methodName: "fileErrors",
8260
+ httpMethod: "POST",
8261
+ path: "/api/v1/catalog/operations/results",
8262
+ summary: "Download failed catalog file receipts as JSONL",
8263
+ description: "Use the fileRecord number to identify rows to correct. Redirect stdout to save the report.",
8264
+ flags: [
8265
+ {
8266
+ name: "operationId",
8267
+ flag: "operation-id",
8268
+ required: true,
8269
+ source: "body"
8270
+ },
8271
+ {
8272
+ name: "organizationId",
8273
+ flag: "organization-id",
8274
+ required: false,
8275
+ source: "query"
8276
+ }
8277
+ ],
8278
+ acceptsJsonBody: false,
8279
+ acceptsFile: false,
8280
+ bodyRequired: false
8281
+ };
8282
+ async function exportCatalogFileErrors(client, request) {
8283
+ for await (const row of readCatalogFileFailures(client, {
8284
+ operationId: String(request.operationId),
8285
+ organizationId: request.organizationId
8286
+ })) {
8287
+ await new Promise((resolve, reject) => {
8288
+ process.stdout.write(
8289
+ JSON.stringify(row) + "\n",
8290
+ (error) => error ? reject(error) : resolve()
8291
+ );
8292
+ });
8293
+ }
8294
+ }
8295
+
8296
+ // src/catalog-pricing-upload.ts
8297
+ import { createReadStream } from "fs";
8298
+ import { open } from "fs/promises";
8299
+ import { createHash } from "crypto";
8300
+ import {
8301
+ submitCatalogPricing,
8302
+ submitCatalogRecords,
8303
+ submitCatalogEnrichment,
8304
+ submitCatalogFile
8305
+ } from "@omni-commerce/sdk";
8306
+ var CATALOG_PRICING_UPLOAD = {
8307
+ trail: ["bulk", "upload-pricing"],
8308
+ resourcePath: ["bulk"],
8309
+ methodName: "uploadPricing",
8310
+ httpMethod: "POST",
8311
+ path: "/api/v1/catalog/operations/plan",
8312
+ summary: "Upload a JSONL price and cost file in chunks to one catalog operation",
8313
+ description: "Use one product update per line. Re-run the same file and idempotency key to resume.",
8314
+ flags: [
8315
+ {
8316
+ name: "idempotencyKey",
8317
+ flag: "idempotency-key",
8318
+ required: true,
8319
+ source: "body"
8320
+ },
8321
+ {
8322
+ name: "organizationId",
8323
+ flag: "organization-id",
8324
+ required: false,
8325
+ source: "query"
8326
+ },
8327
+ {
8328
+ name: "syncToMarketplaces",
8329
+ flag: "sync-to-marketplaces",
8330
+ required: false,
8331
+ source: "body"
8332
+ },
8333
+ { name: "verify", flag: "verify", required: false, source: "body" }
8334
+ ],
8335
+ acceptsJsonBody: false,
8336
+ acceptsFile: true,
8337
+ bodyRequired: false
8338
+ };
8339
+ var catalogUploadFlags = CATALOG_PRICING_UPLOAD.flags.slice(0, 2);
8340
+ var CATALOG_RECORDS_UPLOAD = {
8341
+ ...CATALOG_PRICING_UPLOAD,
8342
+ trail: ["bulk", "upload-records"],
8343
+ methodName: "uploadRecords",
8344
+ summary: "Import catalog records from a large JSONL file",
8345
+ description: "Each line contains one product with a unique sku.",
8346
+ flags: catalogUploadFlags
8347
+ };
8348
+ var CATALOG_FILE_UPLOAD = {
8349
+ ...CATALOG_RECORDS_UPLOAD,
8350
+ trail: ["bulk", "upload-file"],
8351
+ methodName: "uploadFile",
8352
+ summary: "Upload a resumable CSV or JSONL catalog file",
8353
+ description: "Use the same file and idempotency key to resume. Set --scope to review updates to existing SKUs before submitting. The command returns one catalog operation ID.",
8354
+ flags: [
8355
+ ...catalogUploadFlags,
8356
+ {
8357
+ name: "columnMapping",
8358
+ flag: "column-mapping",
8359
+ required: false,
8360
+ source: "body"
8361
+ },
8362
+ { name: "scope", flag: "scope", required: false, source: "body" },
8363
+ {
8364
+ name: "locationId",
8365
+ flag: "location-id",
8366
+ required: false,
8367
+ source: "body"
8368
+ },
8369
+ { name: "sourceId", flag: "source-id", required: false, source: "body" },
8370
+ {
8371
+ name: "syncToMarketplaces",
8372
+ flag: "sync-to-marketplaces",
8373
+ required: false,
8374
+ source: "body"
8375
+ }
8376
+ ]
8377
+ };
8378
+ var CATALOG_ENRICHMENT_UPLOAD = {
8379
+ ...CATALOG_PRICING_UPLOAD,
8380
+ trail: ["bulk", "upload-enrichment"],
8381
+ methodName: "uploadEnrichment",
8382
+ summary: "Queue listing copy enrichment from a large JSONL file",
8383
+ description: "Each line contains one productId. Use bulk plan for custom enrichment options.",
8384
+ flags: catalogUploadFlags
8385
+ };
8386
+ var MAX_LINE_BYTES = 256 * 1024;
8387
+ async function* readCatalogRows(file, field) {
8388
+ let pending = "";
8389
+ let lineNumber = 0;
8390
+ function parseLine(line) {
8391
+ lineNumber += 1;
8392
+ if (Buffer.byteLength(line) > MAX_LINE_BYTES)
8393
+ throw new Error(`JSONL line ${lineNumber} exceeds 256 KiB.`);
8394
+ if (!line.trim()) return;
8395
+ try {
8396
+ const value = JSON.parse(line);
8397
+ if (typeof value !== "object" || value === null || typeof value[field] !== "string")
8398
+ throw new Error(`Missing ${field}`);
8399
+ return value;
8400
+ } catch {
8401
+ throw new Error(
8402
+ `JSONL line ${lineNumber} must be an object with ${field}.`
8403
+ );
8404
+ }
8405
+ }
8406
+ for await (const chunk of createReadStream(file, { encoding: "utf8" })) {
8407
+ const lines = (pending + chunk).split("\n");
8408
+ pending = lines.pop();
8409
+ for (const line of lines) {
8410
+ const update = parseLine(line);
8411
+ if (update) yield update;
8412
+ }
8413
+ if (Buffer.byteLength(pending) > MAX_LINE_BYTES)
8414
+ throw new Error(`JSONL line ${lineNumber + 1} exceeds 256 KiB.`);
8415
+ }
8416
+ if (pending) {
8417
+ const update = parseLine(pending);
8418
+ if (update) yield update;
8419
+ }
8420
+ }
8421
+ function parseBoolean(value, flag) {
8422
+ if (value === void 0) return;
8423
+ if (value === "true" || value === "false") return value === "true";
8424
+ throw new Error(`--${flag} must be true or false.`);
8425
+ }
8426
+ async function uploadCatalogPricing(client, request, command2, fetchImpl) {
8427
+ const options = {
8428
+ idempotencyKey: String(request.idempotencyKey),
8429
+ organizationId: request.organizationId
8430
+ };
8431
+ const file = String(request.file);
8432
+ if (command2 === CATALOG_FILE_UPLOAD) {
8433
+ const extension = file.split(".").at(-1)?.toLowerCase();
8434
+ if (extension !== "csv" && extension !== "jsonl")
8435
+ throw new Error("Use a .csv or .jsonl catalog file.");
8436
+ let columnMapping;
8437
+ if (request.columnMapping !== void 0) {
8438
+ const mapping = JSON.parse(String(request.columnMapping));
8439
+ if (extension !== "csv" || !mapping || typeof mapping !== "object" || Array.isArray(mapping) || !Object.values(mapping).every((value) => typeof value === "string"))
8440
+ throw new Error(
8441
+ "--column-mapping requires a JSON object that maps CSV catalog fields to supplier headers."
8442
+ );
8443
+ columnMapping = mapping;
8444
+ }
8445
+ const scope2 = request.scope;
8446
+ if (scope2 !== void 0 && scope2 !== "price" && scope2 !== "inventory" && scope2 !== "both")
8447
+ throw new Error("--scope must be price, inventory, or both.");
8448
+ const { locationId, sourceId } = request;
8449
+ const syncToMarketplaces = parseBoolean(
8450
+ request.syncToMarketplaces,
8451
+ "sync-to-marketplaces"
8452
+ );
8453
+ if ((scope2 === void 0 || scope2 === "price") && (locationId || sourceId))
8454
+ throw new Error(
8455
+ "Warehouse and source IDs require --scope inventory or both."
8456
+ );
8457
+ if ((scope2 === "inventory" || scope2 === "both") && !locationId && !sourceId)
8458
+ throw new Error("Choose --location-id or --source-id for stock updates.");
8459
+ if (scope2 === void 0 && syncToMarketplaces)
8460
+ throw new Error("--sync-to-marketplaces requires an update --scope.");
8461
+ const update = scope2 === void 0 ? void 0 : { scope: scope2, locationId, sourceId };
8462
+ const handle = await open(file, "r");
8463
+ try {
8464
+ const { size } = await handle.stat();
8465
+ return await submitCatalogFile(
8466
+ client,
8467
+ {
8468
+ ...options,
8469
+ format: extension,
8470
+ columnMapping,
8471
+ update,
8472
+ syncToMarketplaces
8473
+ },
8474
+ {
8475
+ size,
8476
+ async slice(start, end) {
8477
+ const bytes = new Uint8Array(Math.min(end, size) - start);
8478
+ let offset = 0;
8479
+ while (offset < bytes.length) {
8480
+ const { bytesRead } = await handle.read(
8481
+ bytes,
8482
+ offset,
8483
+ bytes.length - offset,
8484
+ start + offset
8485
+ );
8486
+ if (!bytesRead)
8487
+ throw new Error("The catalog file changed during upload.");
8488
+ offset += bytesRead;
8489
+ }
8490
+ return new Blob([bytes]);
8491
+ }
8492
+ },
8493
+ {
8494
+ fetch: fetchImpl,
8495
+ digest: async (bytes) => new Uint8Array(
8496
+ createHash("sha256").update(new Uint8Array(bytes)).digest()
8497
+ ).buffer
8498
+ }
8499
+ );
8500
+ } finally {
8501
+ await handle.close();
8502
+ }
8503
+ }
8504
+ if (command2 === CATALOG_RECORDS_UPLOAD)
8505
+ return submitCatalogRecords(
8506
+ client,
8507
+ options,
8508
+ readCatalogRows(file, "sku")
8509
+ );
8510
+ if (command2 === CATALOG_ENRICHMENT_UPLOAD) {
8511
+ const ids = async function* () {
8512
+ for await (const { productId } of readCatalogRows(
8513
+ file,
8514
+ "productId"
8515
+ ))
8516
+ yield productId;
8517
+ };
8518
+ return submitCatalogEnrichment(
8519
+ client,
8520
+ { ...options, enrichment: {} },
8521
+ ids()
8522
+ );
8523
+ }
8524
+ return submitCatalogPricing(
8525
+ client,
8526
+ {
8527
+ ...options,
8528
+ syncToMarketplaces: parseBoolean(
8529
+ request.syncToMarketplaces,
8530
+ "sync-to-marketplaces"
8531
+ ),
8532
+ verify: parseBoolean(request.verify, "verify")
8533
+ },
8534
+ readCatalogRows(file, "productId")
8535
+ );
8536
+ }
8537
+
7504
8538
  // src/run.ts
8539
+ var CATALOG_UPLOADS = [
8540
+ CATALOG_PRICING_UPLOAD,
8541
+ CATALOG_RECORDS_UPLOAD,
8542
+ CATALOG_FILE_UPLOAD,
8543
+ CATALOG_ENRICHMENT_UPLOAD
8544
+ ];
7505
8545
  var CLI_COMMANDS = [
7506
8546
  ...COMMANDS.filter(
7507
8547
  (command2) => !CAMPAIGN_COMMANDS.some(
7508
8548
  (custom) => custom.trail.join(" ") === command2.trail.join(" ")
7509
8549
  )
7510
8550
  ),
7511
- ...CAMPAIGN_COMMANDS
8551
+ ...CAMPAIGN_COMMANDS,
8552
+ ...CATALOG_UPLOADS,
8553
+ CATALOG_FILE_ERRORS
7512
8554
  ];
7513
8555
  async function readStdin() {
7514
8556
  const chunks = [];
@@ -7691,7 +8733,11 @@ ${unique.map((line) => ` omni ${line}`).join("\n")}
7691
8733
  fetch: options?.fetch
7692
8734
  });
7693
8735
  try {
7694
- const result = await executeCommand(client, command2, request);
8736
+ if (command2 === CATALOG_FILE_ERRORS) {
8737
+ await exportCatalogFileErrors(client, request);
8738
+ return 0;
8739
+ }
8740
+ const result = CATALOG_UPLOADS.includes(command2) ? await uploadCatalogPricing(client, request, command2, options?.fetch) : await executeCommand(client, command2, request);
7695
8741
  const format = resolveFormat(
7696
8742
  flagString(parsed.flags, "format"),
7697
8743
  options?.stdoutIsTty ?? Boolean(process.stdout.isTTY)