@omni-commerce/cli 0.10.0 → 0.12.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/README.md +16 -0
- package/dist/index.js +1556 -47
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ function parseArgv(argv) {
|
|
|
50
50
|
continue;
|
|
51
51
|
}
|
|
52
52
|
const next = argv[index + 1];
|
|
53
|
-
if (
|
|
53
|
+
if (next === void 0 || next.startsWith("-") && next !== "-" || GLOBAL_TRUE_FLAGS.has(stripped)) {
|
|
54
54
|
flags[stripped] = true;
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
@@ -78,13 +78,13 @@ import { execFile } from "child_process";
|
|
|
78
78
|
import { promisify } from "util";
|
|
79
79
|
var executeFile = promisify(execFile);
|
|
80
80
|
async function openBrowser(url) {
|
|
81
|
-
const
|
|
81
|
+
const command2 = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32.exe" : "xdg-open";
|
|
82
82
|
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
|
|
83
|
-
await executeFile(
|
|
83
|
+
await executeFile(command2, args, { timeout: 1e4 });
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// src/version.ts
|
|
87
|
-
var CLI_VERSION = "0.
|
|
87
|
+
var CLI_VERSION = "0.12.0";
|
|
88
88
|
|
|
89
89
|
// src/browser-login.ts
|
|
90
90
|
function loginOrigin(baseUrl) {
|
|
@@ -261,14 +261,14 @@ var UPLOAD_CONTENT_TYPES = {
|
|
|
261
261
|
".heic": "image/heic",
|
|
262
262
|
".heif": "image/heif"
|
|
263
263
|
};
|
|
264
|
-
async function uploadBody(filePath,
|
|
264
|
+
async function uploadBody(filePath, fields2) {
|
|
265
265
|
const form = new FormData();
|
|
266
266
|
const type = UPLOAD_CONTENT_TYPES[extname(filePath).toLowerCase()] ?? "application/octet-stream";
|
|
267
267
|
form.append(
|
|
268
268
|
"file",
|
|
269
269
|
new File([await readFile2(filePath)], basename(filePath), { type })
|
|
270
270
|
);
|
|
271
|
-
for (const [key, value] of Object.entries(
|
|
271
|
+
for (const [key, value] of Object.entries(fields2)) {
|
|
272
272
|
if (value === void 0 || value === null) continue;
|
|
273
273
|
form.append(
|
|
274
274
|
key,
|
|
@@ -283,8 +283,8 @@ function stringValue(value, flag) {
|
|
|
283
283
|
}
|
|
284
284
|
return value;
|
|
285
285
|
}
|
|
286
|
-
async function executeCommand(client,
|
|
287
|
-
if (
|
|
286
|
+
async function executeCommand(client, command2, request) {
|
|
287
|
+
if (command2.resourcePath[0] === "jobs" && command2.methodName === "wait") {
|
|
288
288
|
const jobId = stringValue(request.jobId, "job-id");
|
|
289
289
|
const organizationId = typeof request.organizationId === "string" ? request.organizationId : void 0;
|
|
290
290
|
return client.jobs.wait({ jobId, organizationId });
|
|
@@ -292,7 +292,8 @@ async function executeCommand(client, command, request) {
|
|
|
292
292
|
const pathValues = {};
|
|
293
293
|
const query = {};
|
|
294
294
|
const consumed = /* @__PURE__ */ new Set();
|
|
295
|
-
for (const flag of
|
|
295
|
+
for (const flag of command2.flags) {
|
|
296
|
+
if (flag.source === "body") continue;
|
|
296
297
|
const value = request[flag.name];
|
|
297
298
|
if (value === void 0) continue;
|
|
298
299
|
consumed.add(flag.name);
|
|
@@ -306,20 +307,20 @@ async function executeCommand(client, command, request) {
|
|
|
306
307
|
for (const [key, value] of Object.entries(request)) {
|
|
307
308
|
if (!consumed.has(key)) body[key] = value;
|
|
308
309
|
}
|
|
309
|
-
if (
|
|
310
|
-
const { file, ...
|
|
310
|
+
if (command2.acceptsFile) {
|
|
311
|
+
const { file, ...fields2 } = body;
|
|
311
312
|
return client.request({
|
|
312
|
-
method:
|
|
313
|
-
path: interpolatePath(
|
|
313
|
+
method: command2.httpMethod,
|
|
314
|
+
path: interpolatePath(command2.path, pathValues),
|
|
314
315
|
query: Object.keys(query).length > 0 ? query : void 0,
|
|
315
|
-
body: await uploadBody(stringValue(file, "file"),
|
|
316
|
+
body: await uploadBody(stringValue(file, "file"), fields2)
|
|
316
317
|
});
|
|
317
318
|
}
|
|
318
319
|
return client.request({
|
|
319
|
-
method:
|
|
320
|
-
path: interpolatePath(
|
|
320
|
+
method: command2.httpMethod,
|
|
321
|
+
path: interpolatePath(command2.path, pathValues),
|
|
321
322
|
query: Object.keys(query).length > 0 ? query : void 0,
|
|
322
|
-
body:
|
|
323
|
+
body: command2.acceptsJsonBody && Object.keys(body).length > 0 ? body : void 0
|
|
323
324
|
});
|
|
324
325
|
}
|
|
325
326
|
|
|
@@ -1408,6 +1409,18 @@ var COMMANDS = [
|
|
|
1408
1409
|
required: false,
|
|
1409
1410
|
source: "query"
|
|
1410
1411
|
},
|
|
1412
|
+
{
|
|
1413
|
+
name: "marketplace",
|
|
1414
|
+
flag: "marketplace",
|
|
1415
|
+
required: false,
|
|
1416
|
+
source: "query"
|
|
1417
|
+
},
|
|
1418
|
+
{
|
|
1419
|
+
name: "store",
|
|
1420
|
+
flag: "store",
|
|
1421
|
+
required: false,
|
|
1422
|
+
source: "query"
|
|
1423
|
+
},
|
|
1411
1424
|
{
|
|
1412
1425
|
name: "stage",
|
|
1413
1426
|
flag: "stage",
|
|
@@ -1480,6 +1493,25 @@ var COMMANDS = [
|
|
|
1480
1493
|
acceptsFile: false,
|
|
1481
1494
|
bodyRequired: false
|
|
1482
1495
|
},
|
|
1496
|
+
{
|
|
1497
|
+
trail: ["campaigns", "update"],
|
|
1498
|
+
resourcePath: ["campaigns"],
|
|
1499
|
+
methodName: "update",
|
|
1500
|
+
httpMethod: "PATCH",
|
|
1501
|
+
path: "/api/v1/campaigns/{campaignId}",
|
|
1502
|
+
summary: "Change Campaign Details",
|
|
1503
|
+
flags: [
|
|
1504
|
+
{
|
|
1505
|
+
name: "campaignId",
|
|
1506
|
+
flag: "campaign-id",
|
|
1507
|
+
required: true,
|
|
1508
|
+
source: "path"
|
|
1509
|
+
}
|
|
1510
|
+
],
|
|
1511
|
+
acceptsJsonBody: true,
|
|
1512
|
+
acceptsFile: false,
|
|
1513
|
+
bodyRequired: true
|
|
1514
|
+
},
|
|
1483
1515
|
{
|
|
1484
1516
|
trail: ["campaigns", "replace"],
|
|
1485
1517
|
resourcePath: ["campaigns"],
|
|
@@ -1518,6 +1550,148 @@ var COMMANDS = [
|
|
|
1518
1550
|
acceptsFile: false,
|
|
1519
1551
|
bodyRequired: true
|
|
1520
1552
|
},
|
|
1553
|
+
{
|
|
1554
|
+
trail: ["campaigns", "get-analytics"],
|
|
1555
|
+
resourcePath: ["campaigns"],
|
|
1556
|
+
methodName: "getAnalytics",
|
|
1557
|
+
httpMethod: "GET",
|
|
1558
|
+
path: "/api/v1/campaigns/{campaignId}/analytics",
|
|
1559
|
+
summary: "Get Campaign Analytics",
|
|
1560
|
+
flags: [
|
|
1561
|
+
{
|
|
1562
|
+
name: "campaignId",
|
|
1563
|
+
flag: "campaign-id",
|
|
1564
|
+
required: true,
|
|
1565
|
+
source: "path"
|
|
1566
|
+
},
|
|
1567
|
+
{
|
|
1568
|
+
name: "organizationId",
|
|
1569
|
+
flag: "organization-id",
|
|
1570
|
+
required: false,
|
|
1571
|
+
source: "query"
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
name: "analyticsWindow",
|
|
1575
|
+
flag: "analytics-window",
|
|
1576
|
+
required: false,
|
|
1577
|
+
source: "query"
|
|
1578
|
+
}
|
|
1579
|
+
],
|
|
1580
|
+
acceptsJsonBody: false,
|
|
1581
|
+
acceptsFile: false,
|
|
1582
|
+
bodyRequired: false
|
|
1583
|
+
},
|
|
1584
|
+
{
|
|
1585
|
+
trail: ["campaigns", "get-notifications"],
|
|
1586
|
+
resourcePath: ["campaigns"],
|
|
1587
|
+
methodName: "getNotifications",
|
|
1588
|
+
httpMethod: "GET",
|
|
1589
|
+
path: "/api/v1/campaigns/{campaignId}/notifications",
|
|
1590
|
+
summary: "Get Campaign Notifications",
|
|
1591
|
+
flags: [
|
|
1592
|
+
{
|
|
1593
|
+
name: "campaignId",
|
|
1594
|
+
flag: "campaign-id",
|
|
1595
|
+
required: true,
|
|
1596
|
+
source: "path"
|
|
1597
|
+
},
|
|
1598
|
+
{
|
|
1599
|
+
name: "organizationId",
|
|
1600
|
+
flag: "organization-id",
|
|
1601
|
+
required: false,
|
|
1602
|
+
source: "query"
|
|
1603
|
+
}
|
|
1604
|
+
],
|
|
1605
|
+
acceptsJsonBody: false,
|
|
1606
|
+
acceptsFile: false,
|
|
1607
|
+
bodyRequired: false
|
|
1608
|
+
},
|
|
1609
|
+
{
|
|
1610
|
+
trail: ["campaigns", "set-notifications"],
|
|
1611
|
+
resourcePath: ["campaigns"],
|
|
1612
|
+
methodName: "setNotifications",
|
|
1613
|
+
httpMethod: "PUT",
|
|
1614
|
+
path: "/api/v1/campaigns/{campaignId}/notifications",
|
|
1615
|
+
summary: "Set Campaign Notifications",
|
|
1616
|
+
flags: [
|
|
1617
|
+
{
|
|
1618
|
+
name: "campaignId",
|
|
1619
|
+
flag: "campaign-id",
|
|
1620
|
+
required: true,
|
|
1621
|
+
source: "path"
|
|
1622
|
+
}
|
|
1623
|
+
],
|
|
1624
|
+
acceptsJsonBody: true,
|
|
1625
|
+
acceptsFile: false,
|
|
1626
|
+
bodyRequired: true
|
|
1627
|
+
},
|
|
1628
|
+
{
|
|
1629
|
+
trail: ["campaigns", "list-offers"],
|
|
1630
|
+
resourcePath: ["campaigns"],
|
|
1631
|
+
methodName: "listOffers",
|
|
1632
|
+
httpMethod: "GET",
|
|
1633
|
+
path: "/api/v1/campaigns/{campaignId}/offers",
|
|
1634
|
+
summary: "List Campaign Offers",
|
|
1635
|
+
flags: [
|
|
1636
|
+
{
|
|
1637
|
+
name: "campaignId",
|
|
1638
|
+
flag: "campaign-id",
|
|
1639
|
+
required: true,
|
|
1640
|
+
source: "path"
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
name: "kind",
|
|
1644
|
+
flag: "kind",
|
|
1645
|
+
required: false,
|
|
1646
|
+
source: "query"
|
|
1647
|
+
},
|
|
1648
|
+
{
|
|
1649
|
+
name: "window",
|
|
1650
|
+
flag: "window",
|
|
1651
|
+
required: false,
|
|
1652
|
+
source: "query"
|
|
1653
|
+
},
|
|
1654
|
+
{
|
|
1655
|
+
name: "review",
|
|
1656
|
+
flag: "review",
|
|
1657
|
+
required: false,
|
|
1658
|
+
source: "query"
|
|
1659
|
+
},
|
|
1660
|
+
{
|
|
1661
|
+
name: "offset",
|
|
1662
|
+
flag: "offset",
|
|
1663
|
+
required: false,
|
|
1664
|
+
source: "query"
|
|
1665
|
+
},
|
|
1666
|
+
{
|
|
1667
|
+
name: "limit",
|
|
1668
|
+
flag: "limit",
|
|
1669
|
+
required: false,
|
|
1670
|
+
source: "query"
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
name: "organizationId",
|
|
1674
|
+
flag: "organization-id",
|
|
1675
|
+
required: false,
|
|
1676
|
+
source: "query"
|
|
1677
|
+
}
|
|
1678
|
+
],
|
|
1679
|
+
acceptsJsonBody: false,
|
|
1680
|
+
acceptsFile: false,
|
|
1681
|
+
bodyRequired: false
|
|
1682
|
+
},
|
|
1683
|
+
{
|
|
1684
|
+
trail: ["campaigns", "act-batch"],
|
|
1685
|
+
resourcePath: ["campaigns"],
|
|
1686
|
+
methodName: "actBatch",
|
|
1687
|
+
httpMethod: "POST",
|
|
1688
|
+
path: "/api/v1/campaigns/actions",
|
|
1689
|
+
summary: "Act on Campaigns",
|
|
1690
|
+
flags: [],
|
|
1691
|
+
acceptsJsonBody: true,
|
|
1692
|
+
acceptsFile: false,
|
|
1693
|
+
bodyRequired: true
|
|
1694
|
+
},
|
|
1521
1695
|
{
|
|
1522
1696
|
trail: ["campaigns", "archive"],
|
|
1523
1697
|
resourcePath: ["campaigns"],
|
|
@@ -1542,6 +1716,18 @@ var COMMANDS = [
|
|
|
1542
1716
|
acceptsFile: false,
|
|
1543
1717
|
bodyRequired: true
|
|
1544
1718
|
},
|
|
1719
|
+
{
|
|
1720
|
+
trail: ["campaigns", "import-briefs"],
|
|
1721
|
+
resourcePath: ["campaigns"],
|
|
1722
|
+
methodName: "importBriefs",
|
|
1723
|
+
httpMethod: "POST",
|
|
1724
|
+
path: "/api/v1/campaigns/import",
|
|
1725
|
+
summary: "Import Campaign Workbooks",
|
|
1726
|
+
flags: [],
|
|
1727
|
+
acceptsJsonBody: true,
|
|
1728
|
+
acceptsFile: false,
|
|
1729
|
+
bodyRequired: true
|
|
1730
|
+
},
|
|
1545
1731
|
{
|
|
1546
1732
|
trail: ["campaigns", "get-options"],
|
|
1547
1733
|
resourcePath: ["campaigns"],
|
|
@@ -1561,6 +1747,30 @@ var COMMANDS = [
|
|
|
1561
1747
|
acceptsFile: false,
|
|
1562
1748
|
bodyRequired: false
|
|
1563
1749
|
},
|
|
1750
|
+
{
|
|
1751
|
+
trail: ["campaigns", "resolve-promotion-options"],
|
|
1752
|
+
resourcePath: ["campaigns"],
|
|
1753
|
+
methodName: "resolvePromotionOptions",
|
|
1754
|
+
httpMethod: "POST",
|
|
1755
|
+
path: "/api/v1/campaigns/promotion-options",
|
|
1756
|
+
summary: "Resolve Campaign Promotion Selection",
|
|
1757
|
+
flags: [],
|
|
1758
|
+
acceptsJsonBody: true,
|
|
1759
|
+
acceptsFile: false,
|
|
1760
|
+
bodyRequired: true
|
|
1761
|
+
},
|
|
1762
|
+
{
|
|
1763
|
+
trail: ["campaigns", "validate"],
|
|
1764
|
+
resourcePath: ["campaigns"],
|
|
1765
|
+
methodName: "validate",
|
|
1766
|
+
httpMethod: "POST",
|
|
1767
|
+
path: "/api/v1/campaigns/validate",
|
|
1768
|
+
summary: "Validate Campaigns",
|
|
1769
|
+
flags: [],
|
|
1770
|
+
acceptsJsonBody: true,
|
|
1771
|
+
acceptsFile: false,
|
|
1772
|
+
bodyRequired: true
|
|
1773
|
+
},
|
|
1564
1774
|
{
|
|
1565
1775
|
trail: ["catalog", "list-items"],
|
|
1566
1776
|
resourcePath: ["catalog"],
|
|
@@ -1604,6 +1814,79 @@ var COMMANDS = [
|
|
|
1604
1814
|
acceptsFile: false,
|
|
1605
1815
|
bodyRequired: false
|
|
1606
1816
|
},
|
|
1817
|
+
{
|
|
1818
|
+
trail: ["bulk", "list-for-session"],
|
|
1819
|
+
resourcePath: ["bulk"],
|
|
1820
|
+
methodName: "listForSession",
|
|
1821
|
+
httpMethod: "GET",
|
|
1822
|
+
path: "/api/v1/catalog/operations",
|
|
1823
|
+
summary: "List Catalog Operations for Session",
|
|
1824
|
+
flags: [
|
|
1825
|
+
{
|
|
1826
|
+
name: "organizationId",
|
|
1827
|
+
flag: "organization-id",
|
|
1828
|
+
required: false,
|
|
1829
|
+
source: "query"
|
|
1830
|
+
},
|
|
1831
|
+
{
|
|
1832
|
+
name: "sessionId",
|
|
1833
|
+
flag: "session-id",
|
|
1834
|
+
required: true,
|
|
1835
|
+
source: "query"
|
|
1836
|
+
}
|
|
1837
|
+
],
|
|
1838
|
+
acceptsJsonBody: false,
|
|
1839
|
+
acceptsFile: false,
|
|
1840
|
+
bodyRequired: false
|
|
1841
|
+
},
|
|
1842
|
+
{
|
|
1843
|
+
trail: ["bulk", "start"],
|
|
1844
|
+
resourcePath: ["bulk"],
|
|
1845
|
+
methodName: "start",
|
|
1846
|
+
httpMethod: "POST",
|
|
1847
|
+
path: "/api/v1/catalog/operations",
|
|
1848
|
+
summary: "Start Catalog Operation",
|
|
1849
|
+
flags: [],
|
|
1850
|
+
acceptsJsonBody: true,
|
|
1851
|
+
acceptsFile: false,
|
|
1852
|
+
bodyRequired: true
|
|
1853
|
+
},
|
|
1854
|
+
{
|
|
1855
|
+
trail: ["bulk", "results"],
|
|
1856
|
+
resourcePath: ["bulk"],
|
|
1857
|
+
methodName: "results",
|
|
1858
|
+
httpMethod: "POST",
|
|
1859
|
+
path: "/api/v1/catalog/operations/results",
|
|
1860
|
+
summary: "Get Catalog Operation Results",
|
|
1861
|
+
flags: [],
|
|
1862
|
+
acceptsJsonBody: true,
|
|
1863
|
+
acceptsFile: false,
|
|
1864
|
+
bodyRequired: true
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
trail: ["bulk", "status"],
|
|
1868
|
+
resourcePath: ["bulk"],
|
|
1869
|
+
methodName: "status",
|
|
1870
|
+
httpMethod: "POST",
|
|
1871
|
+
path: "/api/v1/catalog/operations/status",
|
|
1872
|
+
summary: "Get Catalog Operation Status",
|
|
1873
|
+
flags: [],
|
|
1874
|
+
acceptsJsonBody: true,
|
|
1875
|
+
acceptsFile: false,
|
|
1876
|
+
bodyRequired: true
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
trail: ["catalog", "query"],
|
|
1880
|
+
resourcePath: ["catalog"],
|
|
1881
|
+
methodName: "query",
|
|
1882
|
+
httpMethod: "POST",
|
|
1883
|
+
path: "/api/v1/catalog/query",
|
|
1884
|
+
summary: "Query Catalog",
|
|
1885
|
+
flags: [],
|
|
1886
|
+
acceptsJsonBody: true,
|
|
1887
|
+
acceptsFile: false,
|
|
1888
|
+
bodyRequired: true
|
|
1889
|
+
},
|
|
1607
1890
|
{
|
|
1608
1891
|
trail: ["checkout-sessions", "create"],
|
|
1609
1892
|
resourcePath: ["checkoutSessions"],
|
|
@@ -1765,6 +2048,18 @@ var COMMANDS = [
|
|
|
1765
2048
|
acceptsFile: false,
|
|
1766
2049
|
bodyRequired: true
|
|
1767
2050
|
},
|
|
2051
|
+
{
|
|
2052
|
+
trail: ["commerce", "start-verification"],
|
|
2053
|
+
resourcePath: ["commerce"],
|
|
2054
|
+
methodName: "startVerification",
|
|
2055
|
+
httpMethod: "POST",
|
|
2056
|
+
path: "/api/v1/commerce/state/verify/jobs",
|
|
2057
|
+
summary: "Start Commerce Verification",
|
|
2058
|
+
flags: [],
|
|
2059
|
+
acceptsJsonBody: true,
|
|
2060
|
+
acceptsFile: false,
|
|
2061
|
+
bodyRequired: true
|
|
2062
|
+
},
|
|
1768
2063
|
{
|
|
1769
2064
|
trail: ["compare", "get"],
|
|
1770
2065
|
resourcePath: ["compare"],
|
|
@@ -2942,6 +3237,12 @@ var COMMANDS = [
|
|
|
2942
3237
|
flag: "include-summary",
|
|
2943
3238
|
required: false,
|
|
2944
3239
|
source: "query"
|
|
3240
|
+
},
|
|
3241
|
+
{
|
|
3242
|
+
name: "detail",
|
|
3243
|
+
flag: "detail",
|
|
3244
|
+
required: false,
|
|
3245
|
+
source: "query"
|
|
2945
3246
|
}
|
|
2946
3247
|
],
|
|
2947
3248
|
acceptsJsonBody: false,
|
|
@@ -3407,6 +3708,12 @@ var COMMANDS = [
|
|
|
3407
3708
|
required: false,
|
|
3408
3709
|
source: "query"
|
|
3409
3710
|
},
|
|
3711
|
+
{
|
|
3712
|
+
name: "campaign",
|
|
3713
|
+
flag: "campaign",
|
|
3714
|
+
required: false,
|
|
3715
|
+
source: "query"
|
|
3716
|
+
},
|
|
3410
3717
|
{
|
|
3411
3718
|
name: "q",
|
|
3412
3719
|
flag: "q",
|
|
@@ -3547,6 +3854,25 @@ var COMMANDS = [
|
|
|
3547
3854
|
acceptsFile: false,
|
|
3548
3855
|
bodyRequired: true
|
|
3549
3856
|
},
|
|
3857
|
+
{
|
|
3858
|
+
trail: ["promotions", "preview"],
|
|
3859
|
+
resourcePath: ["promotions"],
|
|
3860
|
+
methodName: "preview",
|
|
3861
|
+
httpMethod: "POST",
|
|
3862
|
+
path: "/api/v1/promotions/{promotionId}/preview",
|
|
3863
|
+
summary: "Preview Promotion Prices",
|
|
3864
|
+
flags: [
|
|
3865
|
+
{
|
|
3866
|
+
name: "promotionId",
|
|
3867
|
+
flag: "promotion-id",
|
|
3868
|
+
required: true,
|
|
3869
|
+
source: "path"
|
|
3870
|
+
}
|
|
3871
|
+
],
|
|
3872
|
+
acceptsJsonBody: true,
|
|
3873
|
+
acceptsFile: false,
|
|
3874
|
+
bodyRequired: true
|
|
3875
|
+
},
|
|
3550
3876
|
{
|
|
3551
3877
|
trail: ["promotions", "remove-products"],
|
|
3552
3878
|
resourcePath: ["promotions"],
|
|
@@ -3647,6 +3973,122 @@ var COMMANDS = [
|
|
|
3647
3973
|
acceptsFile: false,
|
|
3648
3974
|
bodyRequired: true
|
|
3649
3975
|
},
|
|
3976
|
+
{
|
|
3977
|
+
trail: ["promotions", "create-batch"],
|
|
3978
|
+
resourcePath: ["promotions"],
|
|
3979
|
+
methodName: "createBatch",
|
|
3980
|
+
httpMethod: "POST",
|
|
3981
|
+
path: "/api/v1/promotions/batch",
|
|
3982
|
+
summary: "Create Promotions with Products",
|
|
3983
|
+
flags: [],
|
|
3984
|
+
acceptsJsonBody: true,
|
|
3985
|
+
acceptsFile: false,
|
|
3986
|
+
bodyRequired: true
|
|
3987
|
+
},
|
|
3988
|
+
{
|
|
3989
|
+
trail: ["promotions", "get-campaign-options"],
|
|
3990
|
+
resourcePath: ["promotions"],
|
|
3991
|
+
methodName: "getCampaignOptions",
|
|
3992
|
+
httpMethod: "GET",
|
|
3993
|
+
path: "/api/v1/promotions/campaign-options",
|
|
3994
|
+
summary: "Find Promotion Campaigns",
|
|
3995
|
+
flags: [
|
|
3996
|
+
{
|
|
3997
|
+
name: "organizationId",
|
|
3998
|
+
flag: "organization-id",
|
|
3999
|
+
required: false,
|
|
4000
|
+
source: "query"
|
|
4001
|
+
},
|
|
4002
|
+
{
|
|
4003
|
+
name: "q",
|
|
4004
|
+
flag: "q",
|
|
4005
|
+
required: false,
|
|
4006
|
+
source: "query"
|
|
4007
|
+
}
|
|
4008
|
+
],
|
|
4009
|
+
acceptsJsonBody: false,
|
|
4010
|
+
acceptsFile: false,
|
|
4011
|
+
bodyRequired: false
|
|
4012
|
+
},
|
|
4013
|
+
{
|
|
4014
|
+
trail: ["promotions", "get-capabilities"],
|
|
4015
|
+
resourcePath: ["promotions"],
|
|
4016
|
+
methodName: "getCapabilities",
|
|
4017
|
+
httpMethod: "GET",
|
|
4018
|
+
path: "/api/v1/promotions/capabilities",
|
|
4019
|
+
summary: "Get Promotion Marketplace Capabilities",
|
|
4020
|
+
flags: [
|
|
4021
|
+
{
|
|
4022
|
+
name: "organizationId",
|
|
4023
|
+
flag: "organization-id",
|
|
4024
|
+
required: false,
|
|
4025
|
+
source: "query"
|
|
4026
|
+
}
|
|
4027
|
+
],
|
|
4028
|
+
acceptsJsonBody: false,
|
|
4029
|
+
acceptsFile: false,
|
|
4030
|
+
bodyRequired: false
|
|
4031
|
+
},
|
|
4032
|
+
{
|
|
4033
|
+
trail: ["promotions", "delete-batch"],
|
|
4034
|
+
resourcePath: ["promotions"],
|
|
4035
|
+
methodName: "deleteBatch",
|
|
4036
|
+
httpMethod: "POST",
|
|
4037
|
+
path: "/api/v1/promotions/delete",
|
|
4038
|
+
summary: "Delete Promotions",
|
|
4039
|
+
flags: [],
|
|
4040
|
+
acceptsJsonBody: true,
|
|
4041
|
+
acceptsFile: false,
|
|
4042
|
+
bodyRequired: true
|
|
4043
|
+
},
|
|
4044
|
+
{
|
|
4045
|
+
trail: ["promotions", "get-delivery"],
|
|
4046
|
+
resourcePath: ["promotions"],
|
|
4047
|
+
methodName: "getDelivery",
|
|
4048
|
+
httpMethod: "POST",
|
|
4049
|
+
path: "/api/v1/promotions/delivery",
|
|
4050
|
+
summary: "Read Promotion Delivery",
|
|
4051
|
+
flags: [],
|
|
4052
|
+
acceptsJsonBody: true,
|
|
4053
|
+
acceptsFile: false,
|
|
4054
|
+
bodyRequired: true
|
|
4055
|
+
},
|
|
4056
|
+
{
|
|
4057
|
+
trail: ["promotions", "get-product-options"],
|
|
4058
|
+
resourcePath: ["promotions"],
|
|
4059
|
+
methodName: "getProductOptions",
|
|
4060
|
+
httpMethod: "POST",
|
|
4061
|
+
path: "/api/v1/promotions/product-options",
|
|
4062
|
+
summary: "Find Eligible Promotion Products",
|
|
4063
|
+
flags: [],
|
|
4064
|
+
acceptsJsonBody: true,
|
|
4065
|
+
acceptsFile: false,
|
|
4066
|
+
bodyRequired: true
|
|
4067
|
+
},
|
|
4068
|
+
{
|
|
4069
|
+
trail: ["promotions", "set-statuses"],
|
|
4070
|
+
resourcePath: ["promotions"],
|
|
4071
|
+
methodName: "setStatuses",
|
|
4072
|
+
httpMethod: "POST",
|
|
4073
|
+
path: "/api/v1/promotions/status",
|
|
4074
|
+
summary: "Set Promotion Statuses",
|
|
4075
|
+
flags: [],
|
|
4076
|
+
acceptsJsonBody: true,
|
|
4077
|
+
acceptsFile: false,
|
|
4078
|
+
bodyRequired: true
|
|
4079
|
+
},
|
|
4080
|
+
{
|
|
4081
|
+
trail: ["promotions", "validate"],
|
|
4082
|
+
resourcePath: ["promotions"],
|
|
4083
|
+
methodName: "validate",
|
|
4084
|
+
httpMethod: "POST",
|
|
4085
|
+
path: "/api/v1/promotions/validate",
|
|
4086
|
+
summary: "Validate Promotions",
|
|
4087
|
+
flags: [],
|
|
4088
|
+
acceptsJsonBody: true,
|
|
4089
|
+
acceptsFile: false,
|
|
4090
|
+
bodyRequired: true
|
|
4091
|
+
},
|
|
3650
4092
|
{
|
|
3651
4093
|
trail: ["returns", "list"],
|
|
3652
4094
|
resourcePath: ["returns"],
|
|
@@ -4880,10 +5322,1064 @@ var COMMANDS = [
|
|
|
4880
5322
|
}
|
|
4881
5323
|
];
|
|
4882
5324
|
|
|
5325
|
+
// src/generated/campaign-inputs.ts
|
|
5326
|
+
var CAMPAIGN_INPUTS = {
|
|
5327
|
+
patch: {
|
|
5328
|
+
type: "object",
|
|
5329
|
+
properties: {
|
|
5330
|
+
expectedRevision: {
|
|
5331
|
+
type: "integer",
|
|
5332
|
+
exclusiveMinimum: 0,
|
|
5333
|
+
maximum: 9007199254740991
|
|
5334
|
+
},
|
|
5335
|
+
name: {
|
|
5336
|
+
type: "string",
|
|
5337
|
+
minLength: 2,
|
|
5338
|
+
maxLength: 160
|
|
5339
|
+
},
|
|
5340
|
+
objective: {
|
|
5341
|
+
type: "string",
|
|
5342
|
+
maxLength: 8e3
|
|
5343
|
+
},
|
|
5344
|
+
brand: {
|
|
5345
|
+
type: "string",
|
|
5346
|
+
maxLength: 160
|
|
5347
|
+
},
|
|
5348
|
+
ownerId: {
|
|
5349
|
+
type: "string",
|
|
5350
|
+
minLength: 1,
|
|
5351
|
+
maxLength: 160,
|
|
5352
|
+
description: "Organization member ID or eligible oauth:<clientId> actor from campaign options."
|
|
5353
|
+
},
|
|
5354
|
+
approverId: {
|
|
5355
|
+
type: "string",
|
|
5356
|
+
minLength: 1,
|
|
5357
|
+
maxLength: 160,
|
|
5358
|
+
description: "Explicit named approver: organization member ID or eligible oauth:<clientId> actor from campaign options. Other users and API clients cannot approve on this actor's behalf."
|
|
5359
|
+
},
|
|
5360
|
+
timezone: {
|
|
5361
|
+
type: "string"
|
|
5362
|
+
},
|
|
5363
|
+
stores: {
|
|
5364
|
+
maxItems: 100,
|
|
5365
|
+
type: "array",
|
|
5366
|
+
items: {
|
|
5367
|
+
type: "object",
|
|
5368
|
+
properties: {
|
|
5369
|
+
marketplace: {
|
|
5370
|
+
type: "string",
|
|
5371
|
+
enum: [
|
|
5372
|
+
"shopee",
|
|
5373
|
+
"lazada",
|
|
5374
|
+
"tiktok",
|
|
5375
|
+
"shopify",
|
|
5376
|
+
"whatsapp",
|
|
5377
|
+
"zalora",
|
|
5378
|
+
"amazon",
|
|
5379
|
+
"ebay"
|
|
5380
|
+
]
|
|
5381
|
+
},
|
|
5382
|
+
country: {
|
|
5383
|
+
type: "string",
|
|
5384
|
+
minLength: 1,
|
|
5385
|
+
maxLength: 80
|
|
5386
|
+
},
|
|
5387
|
+
storeId: {
|
|
5388
|
+
type: "string",
|
|
5389
|
+
minLength: 1,
|
|
5390
|
+
maxLength: 160
|
|
5391
|
+
}
|
|
5392
|
+
},
|
|
5393
|
+
required: ["marketplace", "country", "storeId"],
|
|
5394
|
+
additionalProperties: false
|
|
5395
|
+
}
|
|
5396
|
+
},
|
|
5397
|
+
serviceRequest: {
|
|
5398
|
+
type: "string",
|
|
5399
|
+
maxLength: 300
|
|
5400
|
+
},
|
|
5401
|
+
priority: {
|
|
5402
|
+
type: "string",
|
|
5403
|
+
enum: ["standard", "priority", "super_priority"]
|
|
5404
|
+
},
|
|
5405
|
+
documentIds: {
|
|
5406
|
+
maxItems: 100,
|
|
5407
|
+
type: "array",
|
|
5408
|
+
items: {
|
|
5409
|
+
type: "string",
|
|
5410
|
+
minLength: 1,
|
|
5411
|
+
maxLength: 160
|
|
5412
|
+
}
|
|
5413
|
+
},
|
|
5414
|
+
reviewDueAt: {
|
|
5415
|
+
anyOf: [
|
|
5416
|
+
{
|
|
5417
|
+
type: "string",
|
|
5418
|
+
format: "date-time",
|
|
5419
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
5420
|
+
},
|
|
5421
|
+
{
|
|
5422
|
+
type: "null"
|
|
5423
|
+
}
|
|
5424
|
+
]
|
|
5425
|
+
},
|
|
5426
|
+
sourceCurrency: {
|
|
5427
|
+
type: "string",
|
|
5428
|
+
pattern: "^[A-Z]{3}$"
|
|
5429
|
+
},
|
|
5430
|
+
sourceMarketplace: {
|
|
5431
|
+
type: "string",
|
|
5432
|
+
enum: [
|
|
5433
|
+
"shopee",
|
|
5434
|
+
"lazada",
|
|
5435
|
+
"tiktok",
|
|
5436
|
+
"shopify",
|
|
5437
|
+
"whatsapp",
|
|
5438
|
+
"zalora",
|
|
5439
|
+
"amazon",
|
|
5440
|
+
"ebay"
|
|
5441
|
+
]
|
|
5442
|
+
},
|
|
5443
|
+
sourceCountry: {
|
|
5444
|
+
type: "string",
|
|
5445
|
+
maxLength: 80
|
|
5446
|
+
},
|
|
5447
|
+
syncMode: {
|
|
5448
|
+
type: "string",
|
|
5449
|
+
enum: ["offer_windows", "campaign_start"]
|
|
5450
|
+
},
|
|
5451
|
+
cleanupNotes: {
|
|
5452
|
+
type: "string",
|
|
5453
|
+
maxLength: 8e3
|
|
5454
|
+
},
|
|
5455
|
+
offers: {
|
|
5456
|
+
description: "Add or update promotions by stable offer id. Existing IDs patch only supplied fields; new IDs require windowId and promotion terms. Omitted offers stay unchanged.",
|
|
5457
|
+
maxItems: 500,
|
|
5458
|
+
type: "array",
|
|
5459
|
+
items: {
|
|
5460
|
+
type: "object",
|
|
5461
|
+
properties: {
|
|
5462
|
+
id: {
|
|
5463
|
+
type: "string",
|
|
5464
|
+
minLength: 1,
|
|
5465
|
+
maxLength: 160
|
|
5466
|
+
},
|
|
5467
|
+
windowId: {
|
|
5468
|
+
type: "string",
|
|
5469
|
+
minLength: 1,
|
|
5470
|
+
maxLength: 160
|
|
5471
|
+
},
|
|
5472
|
+
promotionId: {
|
|
5473
|
+
description: "Existing draft promotion attached to this window; the campaign controls its live dates.",
|
|
5474
|
+
type: "string",
|
|
5475
|
+
format: "uuid",
|
|
5476
|
+
pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
5477
|
+
},
|
|
5478
|
+
productIds: {
|
|
5479
|
+
maxItems: 200,
|
|
5480
|
+
type: "array",
|
|
5481
|
+
items: {
|
|
5482
|
+
type: "string",
|
|
5483
|
+
format: "uuid",
|
|
5484
|
+
pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
5485
|
+
}
|
|
5486
|
+
},
|
|
5487
|
+
reviewNotes: {
|
|
5488
|
+
type: "string",
|
|
5489
|
+
maxLength: 8e3
|
|
5490
|
+
},
|
|
5491
|
+
excludedReason: {
|
|
5492
|
+
type: "string",
|
|
5493
|
+
maxLength: 2e3
|
|
5494
|
+
},
|
|
5495
|
+
name: {
|
|
5496
|
+
type: "string",
|
|
5497
|
+
minLength: 1,
|
|
5498
|
+
maxLength: 200
|
|
5499
|
+
},
|
|
5500
|
+
description: {
|
|
5501
|
+
anyOf: [
|
|
5502
|
+
{
|
|
5503
|
+
type: "string",
|
|
5504
|
+
maxLength: 2e3
|
|
5505
|
+
},
|
|
5506
|
+
{
|
|
5507
|
+
type: "null"
|
|
5508
|
+
}
|
|
5509
|
+
]
|
|
5510
|
+
},
|
|
5511
|
+
kind: {
|
|
5512
|
+
description: "Canonical OmniCommerce promotion mechanic: product discount, flash sale, voucher, gift with purchase, Buy-X-Get-Y, bundle deal, or Lazada-only free shipping and early bird price.",
|
|
5513
|
+
type: "string",
|
|
5514
|
+
enum: [
|
|
5515
|
+
"product_discount",
|
|
5516
|
+
"flash_sale",
|
|
5517
|
+
"voucher",
|
|
5518
|
+
"gift_with_purchase",
|
|
5519
|
+
"buy_x_get_y",
|
|
5520
|
+
"bundle_deal",
|
|
5521
|
+
"free_shipping",
|
|
5522
|
+
"early_bird_price"
|
|
5523
|
+
]
|
|
5524
|
+
},
|
|
5525
|
+
salesChannels: {
|
|
5526
|
+
minItems: 1,
|
|
5527
|
+
type: "array",
|
|
5528
|
+
items: {
|
|
5529
|
+
type: "string",
|
|
5530
|
+
enum: ["pdp", "live"]
|
|
5531
|
+
}
|
|
5532
|
+
},
|
|
5533
|
+
discountType: {
|
|
5534
|
+
type: "string",
|
|
5535
|
+
enum: ["percentage", "fixed_amount"]
|
|
5536
|
+
},
|
|
5537
|
+
discountValue: {
|
|
5538
|
+
type: "number",
|
|
5539
|
+
minimum: 0
|
|
5540
|
+
},
|
|
5541
|
+
storeDiscounts: {
|
|
5542
|
+
description: "Patch discount terms for exact target store keys; unnamed stores remain unchanged. Null discountValue restores shared campaign terms for that store.",
|
|
5543
|
+
maxItems: 100,
|
|
5544
|
+
type: "array",
|
|
5545
|
+
items: {
|
|
5546
|
+
type: "object",
|
|
5547
|
+
properties: {
|
|
5548
|
+
storeKey: {
|
|
5549
|
+
type: "string",
|
|
5550
|
+
minLength: 1,
|
|
5551
|
+
maxLength: 255
|
|
5552
|
+
},
|
|
5553
|
+
discountType: {
|
|
5554
|
+
type: "string",
|
|
5555
|
+
enum: ["percentage", "fixed_amount"]
|
|
5556
|
+
},
|
|
5557
|
+
discountValue: {
|
|
5558
|
+
anyOf: [
|
|
5559
|
+
{
|
|
5560
|
+
type: "number",
|
|
5561
|
+
minimum: 0
|
|
5562
|
+
},
|
|
5563
|
+
{
|
|
5564
|
+
type: "null"
|
|
5565
|
+
}
|
|
5566
|
+
]
|
|
5567
|
+
}
|
|
5568
|
+
},
|
|
5569
|
+
required: ["storeKey", "discountType", "discountValue"],
|
|
5570
|
+
additionalProperties: false
|
|
5571
|
+
}
|
|
5572
|
+
},
|
|
5573
|
+
targetStores: {
|
|
5574
|
+
description: "Up to 100 connected stores for create (required) or update. Copy marketplace, country, and storeId from get_promotions targetStores or find_products marketplaceDetails. Do not concatenate a storeKeys string.",
|
|
5575
|
+
minItems: 1,
|
|
5576
|
+
maxItems: 100,
|
|
5577
|
+
type: "array",
|
|
5578
|
+
items: {
|
|
5579
|
+
type: "object",
|
|
5580
|
+
properties: {
|
|
5581
|
+
marketplace: {
|
|
5582
|
+
type: "string",
|
|
5583
|
+
enum: [
|
|
5584
|
+
"lazada",
|
|
5585
|
+
"shopee",
|
|
5586
|
+
"tiktok",
|
|
5587
|
+
"shopify",
|
|
5588
|
+
"amazon",
|
|
5589
|
+
"zalora",
|
|
5590
|
+
"ebay"
|
|
5591
|
+
]
|
|
5592
|
+
},
|
|
5593
|
+
country: {
|
|
5594
|
+
type: "string",
|
|
5595
|
+
minLength: 1,
|
|
5596
|
+
maxLength: 80
|
|
5597
|
+
},
|
|
5598
|
+
storeId: {
|
|
5599
|
+
type: "string",
|
|
5600
|
+
minLength: 1,
|
|
5601
|
+
maxLength: 120
|
|
5602
|
+
}
|
|
5603
|
+
},
|
|
5604
|
+
required: ["marketplace", "country", "storeId"],
|
|
5605
|
+
additionalProperties: false
|
|
5606
|
+
}
|
|
5607
|
+
},
|
|
5608
|
+
minSalePrice: {
|
|
5609
|
+
anyOf: [
|
|
5610
|
+
{
|
|
5611
|
+
type: "number",
|
|
5612
|
+
minimum: 0
|
|
5613
|
+
},
|
|
5614
|
+
{
|
|
5615
|
+
type: "null"
|
|
5616
|
+
}
|
|
5617
|
+
]
|
|
5618
|
+
},
|
|
5619
|
+
maxDiscountAmount: {
|
|
5620
|
+
anyOf: [
|
|
5621
|
+
{
|
|
5622
|
+
type: "number",
|
|
5623
|
+
minimum: 0
|
|
5624
|
+
},
|
|
5625
|
+
{
|
|
5626
|
+
type: "null"
|
|
5627
|
+
}
|
|
5628
|
+
]
|
|
5629
|
+
},
|
|
5630
|
+
minSpend: {
|
|
5631
|
+
anyOf: [
|
|
5632
|
+
{
|
|
5633
|
+
type: "number",
|
|
5634
|
+
minimum: 0
|
|
5635
|
+
},
|
|
5636
|
+
{
|
|
5637
|
+
type: "null"
|
|
5638
|
+
}
|
|
5639
|
+
]
|
|
5640
|
+
},
|
|
5641
|
+
voucherCode: {
|
|
5642
|
+
anyOf: [
|
|
5643
|
+
{
|
|
5644
|
+
type: "string",
|
|
5645
|
+
minLength: 1,
|
|
5646
|
+
maxLength: 100
|
|
5647
|
+
},
|
|
5648
|
+
{
|
|
5649
|
+
type: "null"
|
|
5650
|
+
}
|
|
5651
|
+
]
|
|
5652
|
+
},
|
|
5653
|
+
claimStartsAt: {
|
|
5654
|
+
anyOf: [
|
|
5655
|
+
{
|
|
5656
|
+
type: "string",
|
|
5657
|
+
format: "date-time",
|
|
5658
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
5659
|
+
},
|
|
5660
|
+
{
|
|
5661
|
+
type: "null"
|
|
5662
|
+
}
|
|
5663
|
+
]
|
|
5664
|
+
},
|
|
5665
|
+
totalUsageLimit: {
|
|
5666
|
+
anyOf: [
|
|
5667
|
+
{
|
|
5668
|
+
type: "integer",
|
|
5669
|
+
exclusiveMinimum: 0,
|
|
5670
|
+
maximum: 9007199254740991
|
|
5671
|
+
},
|
|
5672
|
+
{
|
|
5673
|
+
type: "null"
|
|
5674
|
+
}
|
|
5675
|
+
]
|
|
5676
|
+
},
|
|
5677
|
+
perBuyerLimit: {
|
|
5678
|
+
anyOf: [
|
|
5679
|
+
{
|
|
5680
|
+
type: "integer",
|
|
5681
|
+
exclusiveMinimum: 0,
|
|
5682
|
+
maximum: 9007199254740991
|
|
5683
|
+
},
|
|
5684
|
+
{
|
|
5685
|
+
type: "null"
|
|
5686
|
+
}
|
|
5687
|
+
]
|
|
5688
|
+
},
|
|
5689
|
+
voucherType: {
|
|
5690
|
+
description: "Voucher subtype from get_promotions capabilities.voucherTypes. Browser AOP types (delivery=browser_aop) are writable Seller Center vouchers. Omit browserAutomation.aopId to use the built-in marketplace AOP.",
|
|
5691
|
+
anyOf: [
|
|
5692
|
+
{
|
|
5693
|
+
type: "string",
|
|
5694
|
+
enum: [
|
|
5695
|
+
"shopee_shop",
|
|
5696
|
+
"shopee_product",
|
|
5697
|
+
"shopee_private",
|
|
5698
|
+
"shopee_live",
|
|
5699
|
+
"shopee_video",
|
|
5700
|
+
"shopee_new_buyer",
|
|
5701
|
+
"shopee_repeat_buyer",
|
|
5702
|
+
"shopee_campaign",
|
|
5703
|
+
"shopee_follow_prize",
|
|
5704
|
+
"shopee_exclusive_streamer",
|
|
5705
|
+
"shopee_welcome",
|
|
5706
|
+
"shopee_member_repeat_buyer",
|
|
5707
|
+
"shopee_exclusive",
|
|
5708
|
+
"shopee_redemption",
|
|
5709
|
+
"shopee_exclusive_creator",
|
|
5710
|
+
"lazada_store_follower",
|
|
5711
|
+
"lazada_regular",
|
|
5712
|
+
"lazada_store_new_buyer",
|
|
5713
|
+
"lazada_live",
|
|
5714
|
+
"lazada_offline",
|
|
5715
|
+
"lazada_co_funded",
|
|
5716
|
+
"lazada_welcome",
|
|
5717
|
+
"lazada_linked_member",
|
|
5718
|
+
"lazada_new_member",
|
|
5719
|
+
"lazada_member_exclusive",
|
|
5720
|
+
"lazada_points_redeemable",
|
|
5721
|
+
"tiktok_seller_coupon",
|
|
5722
|
+
"shopify_discount_code",
|
|
5723
|
+
"amazon_promotion_code",
|
|
5724
|
+
"zalora_seller_voucher",
|
|
5725
|
+
"ebay_coded_coupon"
|
|
5726
|
+
]
|
|
5727
|
+
},
|
|
5728
|
+
{
|
|
5729
|
+
type: "null"
|
|
5730
|
+
}
|
|
5731
|
+
]
|
|
5732
|
+
},
|
|
5733
|
+
voucherCampaign: {
|
|
5734
|
+
description: "Campaign voucher targeting: exact campaignId/sessionId from Seller Center and termsAccepted only after the seller reviewed participation obligations. Required for shopee_campaign; nomination creates a draft awaiting marketplace review.",
|
|
5735
|
+
type: "object",
|
|
5736
|
+
properties: {
|
|
5737
|
+
campaignId: {
|
|
5738
|
+
type: "string",
|
|
5739
|
+
pattern: "^[1-9]\\d{0,39}$"
|
|
5740
|
+
},
|
|
5741
|
+
sessionId: {
|
|
5742
|
+
type: "string",
|
|
5743
|
+
pattern: "^[1-9]\\d{0,39}$"
|
|
5744
|
+
},
|
|
5745
|
+
termsAccepted: {
|
|
5746
|
+
type: "boolean"
|
|
5747
|
+
}
|
|
5748
|
+
},
|
|
5749
|
+
required: ["campaignId", "sessionId", "termsAccepted"],
|
|
5750
|
+
additionalProperties: false
|
|
5751
|
+
},
|
|
5752
|
+
browserAutomation: {
|
|
5753
|
+
anyOf: [
|
|
5754
|
+
{
|
|
5755
|
+
type: "object",
|
|
5756
|
+
properties: {
|
|
5757
|
+
aopId: {
|
|
5758
|
+
type: "string",
|
|
5759
|
+
minLength: 1,
|
|
5760
|
+
maxLength: 160
|
|
5761
|
+
},
|
|
5762
|
+
variableValues: {
|
|
5763
|
+
type: "object",
|
|
5764
|
+
propertyNames: {
|
|
5765
|
+
type: "string",
|
|
5766
|
+
minLength: 1,
|
|
5767
|
+
maxLength: 160
|
|
5768
|
+
},
|
|
5769
|
+
additionalProperties: {
|
|
5770
|
+
type: "string",
|
|
5771
|
+
maxLength: 8e3
|
|
5772
|
+
}
|
|
5773
|
+
},
|
|
5774
|
+
instructions: {
|
|
5775
|
+
type: "string",
|
|
5776
|
+
maxLength: 8e3
|
|
5777
|
+
}
|
|
5778
|
+
},
|
|
5779
|
+
additionalProperties: false
|
|
5780
|
+
},
|
|
5781
|
+
{
|
|
5782
|
+
type: "null"
|
|
5783
|
+
}
|
|
5784
|
+
]
|
|
5785
|
+
},
|
|
5786
|
+
voucherScope: {
|
|
5787
|
+
description: "shop = all products, products = selected assigned products. Repeat Buyer defaults to shop.",
|
|
5788
|
+
type: "string",
|
|
5789
|
+
enum: ["products", "shop"]
|
|
5790
|
+
},
|
|
5791
|
+
voucherReward: {
|
|
5792
|
+
description: "Seller Center reward type. coins_cashback is a percentage greater than 3 and does not reduce salePrice.",
|
|
5793
|
+
type: "string",
|
|
5794
|
+
enum: ["discount", "coins_cashback"]
|
|
5795
|
+
},
|
|
5796
|
+
voucherAudience: {
|
|
5797
|
+
type: "string",
|
|
5798
|
+
enum: ["general", "shop_follow"]
|
|
5799
|
+
},
|
|
5800
|
+
repeatPurchaseMinCount: {
|
|
5801
|
+
description: "Shopee Repeat Buyer: minimum completed shop orders, 1 or 2. Required for shopee_repeat_buyer.",
|
|
5802
|
+
type: "integer",
|
|
5803
|
+
minimum: 1,
|
|
5804
|
+
maximum: 999
|
|
5805
|
+
},
|
|
5806
|
+
repeatPurchaseLookbackDays: {
|
|
5807
|
+
description: "Shopee Repeat Buyer: lookback window in days, one of 30, 90, 180 or 365. Required for shopee_repeat_buyer.",
|
|
5808
|
+
type: "integer",
|
|
5809
|
+
minimum: 1,
|
|
5810
|
+
maximum: 365
|
|
5811
|
+
},
|
|
5812
|
+
smartVoucher: {
|
|
5813
|
+
description: "Shopee Smart Voucher toggle. Used by New Buyer and similar portal types.",
|
|
5814
|
+
type: "boolean"
|
|
5815
|
+
},
|
|
5816
|
+
followPrizeExpiryDays: {
|
|
5817
|
+
description: "Shopee Follow Prize: days after claim until expiry. Seller Center is 7.",
|
|
5818
|
+
type: "integer",
|
|
5819
|
+
minimum: 1,
|
|
5820
|
+
maximum: 30
|
|
5821
|
+
},
|
|
5822
|
+
videoDisplayMode: {
|
|
5823
|
+
description: "Shopee Video display: shopee_video = all Shopee Video; creator_video = targeted creator videos only.",
|
|
5824
|
+
type: "string",
|
|
5825
|
+
enum: ["shopee_video", "creator_video"]
|
|
5826
|
+
},
|
|
5827
|
+
exclusiveCreatorUsernames: {
|
|
5828
|
+
description: "Exclusive Creator Voucher: up to 15 Shopee usernames.",
|
|
5829
|
+
maxItems: 15,
|
|
5830
|
+
type: "array",
|
|
5831
|
+
items: {
|
|
5832
|
+
type: "string",
|
|
5833
|
+
minLength: 1,
|
|
5834
|
+
maxLength: 64
|
|
5835
|
+
}
|
|
5836
|
+
},
|
|
5837
|
+
exclusiveStreamerUsernames: {
|
|
5838
|
+
description: "Exclusive Streamer Voucher: up to 15 Shopee usernames.",
|
|
5839
|
+
maxItems: 15,
|
|
5840
|
+
type: "array",
|
|
5841
|
+
items: {
|
|
5842
|
+
type: "string",
|
|
5843
|
+
minLength: 1,
|
|
5844
|
+
maxLength: 64
|
|
5845
|
+
}
|
|
5846
|
+
},
|
|
5847
|
+
voucherDisplayChannels: {
|
|
5848
|
+
description: 'Shopee display setting. ["all"] = display on all pages; [] = hidden/share by code.',
|
|
5849
|
+
maxItems: 4,
|
|
5850
|
+
type: "array",
|
|
5851
|
+
items: {
|
|
5852
|
+
type: "string",
|
|
5853
|
+
enum: [
|
|
5854
|
+
"all",
|
|
5855
|
+
"feed",
|
|
5856
|
+
"live",
|
|
5857
|
+
"order_page",
|
|
5858
|
+
"followers",
|
|
5859
|
+
"offline"
|
|
5860
|
+
]
|
|
5861
|
+
}
|
|
5862
|
+
},
|
|
5863
|
+
bundlePriceType: {
|
|
5864
|
+
type: "string",
|
|
5865
|
+
enum: ["discount", "fixed_price"]
|
|
5866
|
+
},
|
|
5867
|
+
bundleTiers: {
|
|
5868
|
+
maxItems: 2,
|
|
5869
|
+
type: "array",
|
|
5870
|
+
items: {
|
|
5871
|
+
type: "object",
|
|
5872
|
+
properties: {
|
|
5873
|
+
minimumQuantity: {
|
|
5874
|
+
type: "integer",
|
|
5875
|
+
minimum: 2,
|
|
5876
|
+
maximum: 3e3
|
|
5877
|
+
},
|
|
5878
|
+
discountValue: {
|
|
5879
|
+
type: "number",
|
|
5880
|
+
exclusiveMinimum: 0
|
|
5881
|
+
}
|
|
5882
|
+
},
|
|
5883
|
+
required: ["minimumQuantity", "discountValue"]
|
|
5884
|
+
}
|
|
5885
|
+
},
|
|
5886
|
+
thresholdType: {
|
|
5887
|
+
type: "string",
|
|
5888
|
+
enum: ["item_quantity", "order_amount"]
|
|
5889
|
+
},
|
|
5890
|
+
thresholdValue: {
|
|
5891
|
+
type: "number",
|
|
5892
|
+
exclusiveMinimum: 0
|
|
5893
|
+
},
|
|
5894
|
+
giftType: {
|
|
5895
|
+
type: "string",
|
|
5896
|
+
enum: ["gift", "sample"]
|
|
5897
|
+
},
|
|
5898
|
+
giftQuantity: {
|
|
5899
|
+
type: "integer",
|
|
5900
|
+
exclusiveMinimum: 0,
|
|
5901
|
+
maximum: 999
|
|
5902
|
+
},
|
|
5903
|
+
gifts: {
|
|
5904
|
+
minItems: 1,
|
|
5905
|
+
maxItems: 20,
|
|
5906
|
+
type: "array",
|
|
5907
|
+
items: {
|
|
5908
|
+
type: "object",
|
|
5909
|
+
properties: {
|
|
5910
|
+
productId: {
|
|
5911
|
+
type: "string",
|
|
5912
|
+
format: "uuid",
|
|
5913
|
+
pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
5914
|
+
},
|
|
5915
|
+
variantId: {
|
|
5916
|
+
anyOf: [
|
|
5917
|
+
{
|
|
5918
|
+
type: "string",
|
|
5919
|
+
format: "uuid",
|
|
5920
|
+
pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
5921
|
+
},
|
|
5922
|
+
{
|
|
5923
|
+
type: "null"
|
|
5924
|
+
}
|
|
5925
|
+
]
|
|
5926
|
+
},
|
|
5927
|
+
totalClaimLimit: {
|
|
5928
|
+
type: "integer",
|
|
5929
|
+
minimum: 1,
|
|
5930
|
+
maximum: 99999
|
|
5931
|
+
}
|
|
5932
|
+
},
|
|
5933
|
+
required: ["productId", "totalClaimLimit"],
|
|
5934
|
+
additionalProperties: false
|
|
5935
|
+
}
|
|
5936
|
+
},
|
|
5937
|
+
buyQuantity: {
|
|
5938
|
+
type: "integer",
|
|
5939
|
+
exclusiveMinimum: 0,
|
|
5940
|
+
maximum: 999
|
|
5941
|
+
},
|
|
5942
|
+
getQuantity: {
|
|
5943
|
+
type: "integer",
|
|
5944
|
+
exclusiveMinimum: 0,
|
|
5945
|
+
maximum: 999
|
|
5946
|
+
},
|
|
5947
|
+
benefitProductIds: {
|
|
5948
|
+
minItems: 1,
|
|
5949
|
+
maxItems: 200,
|
|
5950
|
+
type: "array",
|
|
5951
|
+
items: {
|
|
5952
|
+
type: "string",
|
|
5953
|
+
format: "uuid",
|
|
5954
|
+
pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
5955
|
+
}
|
|
5956
|
+
},
|
|
5957
|
+
benefitType: {
|
|
5958
|
+
type: "string",
|
|
5959
|
+
enum: ["free", "percentage", "fixed_amount"]
|
|
5960
|
+
},
|
|
5961
|
+
benefitValue: {
|
|
5962
|
+
type: "number",
|
|
5963
|
+
minimum: 0
|
|
5964
|
+
},
|
|
5965
|
+
maxApplicationsPerOrder: {
|
|
5966
|
+
type: "integer",
|
|
5967
|
+
exclusiveMinimum: 0,
|
|
5968
|
+
maximum: 999
|
|
5969
|
+
},
|
|
5970
|
+
bundleMinimumQuantity: {
|
|
5971
|
+
type: "integer",
|
|
5972
|
+
minimum: 2,
|
|
5973
|
+
maximum: 3e3
|
|
5974
|
+
},
|
|
5975
|
+
shippingDeliveryOption: {
|
|
5976
|
+
description: "Free shipping delivery option. Lazada: STANDARD (default), ECONOMY, EXPRESS, SELLER_OWN_FLEET or P2P, as offered by the store.",
|
|
5977
|
+
type: "string",
|
|
5978
|
+
pattern: "^[A-Z0-9_]{1,40}$"
|
|
5979
|
+
},
|
|
5980
|
+
shippingBudget: {
|
|
5981
|
+
description: "Free shipping: total shipping subsidy budget in the store currency. Omit for an unlimited budget.",
|
|
5982
|
+
type: "number",
|
|
5983
|
+
exclusiveMinimum: 0
|
|
5984
|
+
}
|
|
5985
|
+
},
|
|
5986
|
+
required: ["id"],
|
|
5987
|
+
additionalProperties: false
|
|
5988
|
+
}
|
|
5989
|
+
},
|
|
5990
|
+
windows: {
|
|
5991
|
+
description: "Add or update windows by stable id. Existing IDs patch only supplied fields; new IDs require name, startsAt and endsAt. Omitted windows stay unchanged.",
|
|
5992
|
+
maxItems: 100,
|
|
5993
|
+
type: "array",
|
|
5994
|
+
items: {
|
|
5995
|
+
type: "object",
|
|
5996
|
+
properties: {
|
|
5997
|
+
id: {
|
|
5998
|
+
type: "string",
|
|
5999
|
+
minLength: 1,
|
|
6000
|
+
maxLength: 160
|
|
6001
|
+
},
|
|
6002
|
+
name: {
|
|
6003
|
+
type: "string",
|
|
6004
|
+
minLength: 1,
|
|
6005
|
+
maxLength: 160
|
|
6006
|
+
},
|
|
6007
|
+
startsAt: {
|
|
6008
|
+
anyOf: [
|
|
6009
|
+
{
|
|
6010
|
+
type: "string",
|
|
6011
|
+
format: "date-time",
|
|
6012
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
6013
|
+
},
|
|
6014
|
+
{
|
|
6015
|
+
type: "null"
|
|
6016
|
+
}
|
|
6017
|
+
]
|
|
6018
|
+
},
|
|
6019
|
+
endsAt: {
|
|
6020
|
+
anyOf: [
|
|
6021
|
+
{
|
|
6022
|
+
type: "string",
|
|
6023
|
+
format: "date-time",
|
|
6024
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
6025
|
+
},
|
|
6026
|
+
{
|
|
6027
|
+
type: "null"
|
|
6028
|
+
}
|
|
6029
|
+
]
|
|
6030
|
+
},
|
|
6031
|
+
preparesAt: {
|
|
6032
|
+
anyOf: [
|
|
6033
|
+
{
|
|
6034
|
+
type: "string",
|
|
6035
|
+
format: "date-time",
|
|
6036
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
6037
|
+
},
|
|
6038
|
+
{
|
|
6039
|
+
type: "null"
|
|
6040
|
+
}
|
|
6041
|
+
]
|
|
6042
|
+
},
|
|
6043
|
+
reviewNotes: {
|
|
6044
|
+
type: "string",
|
|
6045
|
+
maxLength: 8e3
|
|
6046
|
+
}
|
|
6047
|
+
},
|
|
6048
|
+
required: ["id"],
|
|
6049
|
+
additionalProperties: false
|
|
6050
|
+
}
|
|
6051
|
+
},
|
|
6052
|
+
removeWindowIds: {
|
|
6053
|
+
description: "Delete these windows. Move or remove their promotions in the same call. Maximum 100 IDs.",
|
|
6054
|
+
maxItems: 100,
|
|
6055
|
+
type: "array",
|
|
6056
|
+
items: {
|
|
6057
|
+
type: "string",
|
|
6058
|
+
minLength: 1,
|
|
6059
|
+
maxLength: 160
|
|
6060
|
+
}
|
|
6061
|
+
},
|
|
6062
|
+
removeOfferIds: {
|
|
6063
|
+
description: "Delete these draft promotion offers. Maximum 500 IDs.",
|
|
6064
|
+
maxItems: 500,
|
|
6065
|
+
type: "array",
|
|
6066
|
+
items: {
|
|
6067
|
+
type: "string",
|
|
6068
|
+
minLength: 1,
|
|
6069
|
+
maxLength: 160
|
|
6070
|
+
}
|
|
6071
|
+
},
|
|
6072
|
+
organizationId: {
|
|
6073
|
+
description: "Required for session auth. Optional for an API key, which already identifies the organization.",
|
|
6074
|
+
type: "string",
|
|
6075
|
+
minLength: 1,
|
|
6076
|
+
maxLength: 120
|
|
6077
|
+
},
|
|
6078
|
+
expectedPendingVersion: {
|
|
6079
|
+
anyOf: [
|
|
6080
|
+
{
|
|
6081
|
+
type: "integer",
|
|
6082
|
+
exclusiveMinimum: 0,
|
|
6083
|
+
maximum: 9007199254740991
|
|
6084
|
+
},
|
|
6085
|
+
{
|
|
6086
|
+
type: "null"
|
|
6087
|
+
}
|
|
6088
|
+
]
|
|
6089
|
+
}
|
|
6090
|
+
},
|
|
6091
|
+
required: ["expectedRevision"],
|
|
6092
|
+
additionalProperties: false
|
|
6093
|
+
},
|
|
6094
|
+
action: {
|
|
6095
|
+
type: "object",
|
|
6096
|
+
properties: {
|
|
6097
|
+
action: {
|
|
6098
|
+
type: "string",
|
|
6099
|
+
enum: [
|
|
6100
|
+
"approve",
|
|
6101
|
+
"run",
|
|
6102
|
+
"approve_and_run",
|
|
6103
|
+
"end",
|
|
6104
|
+
"resume",
|
|
6105
|
+
"retry",
|
|
6106
|
+
"approve_change",
|
|
6107
|
+
"discard_change"
|
|
6108
|
+
]
|
|
6109
|
+
},
|
|
6110
|
+
expectedRevision: {
|
|
6111
|
+
type: "integer",
|
|
6112
|
+
exclusiveMinimum: 0,
|
|
6113
|
+
maximum: 9007199254740991
|
|
6114
|
+
},
|
|
6115
|
+
expectedPendingVersion: {
|
|
6116
|
+
type: "integer",
|
|
6117
|
+
exclusiveMinimum: 0,
|
|
6118
|
+
maximum: 9007199254740991
|
|
6119
|
+
},
|
|
6120
|
+
organizationId: {
|
|
6121
|
+
description: "Required for session auth. Optional for an API key, which already identifies the organization.",
|
|
6122
|
+
type: "string",
|
|
6123
|
+
minLength: 1,
|
|
6124
|
+
maxLength: 120
|
|
6125
|
+
}
|
|
6126
|
+
},
|
|
6127
|
+
required: ["action", "expectedRevision"],
|
|
6128
|
+
additionalProperties: false
|
|
6129
|
+
}
|
|
6130
|
+
};
|
|
6131
|
+
|
|
6132
|
+
// src/body-flags.ts
|
|
6133
|
+
var kebab = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
6134
|
+
function nonNull(schema) {
|
|
6135
|
+
return schema.anyOf?.find((item) => item.type !== "null") ?? schema;
|
|
6136
|
+
}
|
|
6137
|
+
function nullable(schema) {
|
|
6138
|
+
return schema.type === "null" || Array.isArray(schema.type) && schema.type.includes("null") || Boolean(schema.anyOf?.some(nullable));
|
|
6139
|
+
}
|
|
6140
|
+
function bodyFlagNames(schema, prefix = "") {
|
|
6141
|
+
schema = nonNull(schema);
|
|
6142
|
+
if (schema.properties)
|
|
6143
|
+
return Object.entries(schema.properties).flatMap(
|
|
6144
|
+
([name, child]) => bodyFlagNames(child, `${prefix ? `${prefix}.` : ""}${kebab(name)}`)
|
|
6145
|
+
);
|
|
6146
|
+
if (schema.items && nonNull(schema.items).properties)
|
|
6147
|
+
return bodyFlagNames(schema.items, `${prefix}.<index>`);
|
|
6148
|
+
if (typeof schema.additionalProperties === "object")
|
|
6149
|
+
return bodyFlagNames(schema.additionalProperties, `${prefix}.<key>`);
|
|
6150
|
+
return [prefix];
|
|
6151
|
+
}
|
|
6152
|
+
function scalar(value, schema, flag) {
|
|
6153
|
+
if (value === "null" && nullable(schema)) return null;
|
|
6154
|
+
schema = nonNull(schema);
|
|
6155
|
+
const type = Array.isArray(schema.type) ? schema.type.find((item) => item !== "null") : schema.type;
|
|
6156
|
+
let result = value;
|
|
6157
|
+
if (type === "array" && schema.items) {
|
|
6158
|
+
if (typeof value !== "string")
|
|
6159
|
+
throw new Error(`--${flag} requires comma-separated values`);
|
|
6160
|
+
result = value === "" ? [] : value.split(",").map((item) => scalar(item.trim(), schema.items, flag));
|
|
6161
|
+
const count = result.length;
|
|
6162
|
+
if (count < (schema.minItems ?? 0) || count > (schema.maxItems ?? Infinity))
|
|
6163
|
+
throw new Error(`--${flag} has an invalid number of values`);
|
|
6164
|
+
} else if (type === "boolean") {
|
|
6165
|
+
if (![true, false, "true", "false"].includes(value))
|
|
6166
|
+
throw new Error(`--${flag} requires true or false`);
|
|
6167
|
+
result = value === true || value === "true";
|
|
6168
|
+
} else if (type === "integer" || type === "number") {
|
|
6169
|
+
const number = typeof value === "string" && value.trim() ? Number(value) : NaN;
|
|
6170
|
+
if (!Number.isFinite(number) || type === "integer" && !Number.isSafeInteger(number) || number < (schema.minimum ?? -Infinity) || number > (schema.maximum ?? Infinity) || schema.exclusiveMinimum !== void 0 && number <= schema.exclusiveMinimum)
|
|
6171
|
+
throw new Error(`--${flag} requires a valid ${type}`);
|
|
6172
|
+
result = number;
|
|
6173
|
+
} else if (typeof value !== "string" || type === "object") {
|
|
6174
|
+
throw new Error(
|
|
6175
|
+
`--${flag} requires a value; use dotted fields for objects`
|
|
6176
|
+
);
|
|
6177
|
+
}
|
|
6178
|
+
if (schema.enum && !schema.enum.includes(result))
|
|
6179
|
+
throw new Error(
|
|
6180
|
+
`--${flag}${flag.endsWith(".marketplace") ? `: ${String(result)} is not supported for this store target; value` : ""} must be one of: ${schema.enum.join(", ")}`
|
|
6181
|
+
);
|
|
6182
|
+
if (typeof result === "string" && (result.length < (schema.minLength ?? 0) || result.length > (schema.maxLength ?? Infinity) || schema.pattern && !new RegExp(schema.pattern).test(result) || schema.format === "date-time" && (!/T.*(?:Z|[+-]\d{2}:\d{2})$/.test(result) || !Number.isFinite(Date.parse(result)))))
|
|
6183
|
+
throw new Error(
|
|
6184
|
+
`--${flag} has an invalid value${schema.format ? ` (${schema.format})` : ""}`
|
|
6185
|
+
);
|
|
6186
|
+
return result;
|
|
6187
|
+
}
|
|
6188
|
+
function assignFlag(target, schema, parts, value, flag) {
|
|
6189
|
+
schema = nonNull(schema);
|
|
6190
|
+
const [part, ...rest] = parts;
|
|
6191
|
+
if (["__proto__", "constructor", "prototype"].includes(part))
|
|
6192
|
+
throw new Error(`Unknown flag --${flag}`);
|
|
6193
|
+
const key = schema.items ? /^(0|[1-9][0-9]*)$/.test(part) ? Number(part) : void 0 : Object.keys(schema.properties ?? {}).find(
|
|
6194
|
+
(name) => kebab(name) === part
|
|
6195
|
+
) ?? (typeof schema.additionalProperties === "object" ? part : void 0);
|
|
6196
|
+
const child = schema.items ?? (typeof key === "string" ? schema.properties?.[key] ?? schema.additionalProperties : void 0);
|
|
6197
|
+
if (key === void 0 || !child || typeof child !== "object" || typeof key === "number" && key >= (schema.maxItems ?? 500))
|
|
6198
|
+
throw new Error(`Unknown or out-of-bounds flag --${flag}`);
|
|
6199
|
+
const object = target;
|
|
6200
|
+
if (!rest.length) {
|
|
6201
|
+
object[key] = scalar(value, child, flag);
|
|
6202
|
+
return;
|
|
6203
|
+
}
|
|
6204
|
+
const shape = nonNull(child);
|
|
6205
|
+
if (!shape.properties && !shape.items && typeof shape.additionalProperties !== "object")
|
|
6206
|
+
throw new Error(`Unknown flag --${flag}`);
|
|
6207
|
+
object[key] ??= shape.items ? [] : {};
|
|
6208
|
+
if (typeof object[key] !== "object" || object[key] === null)
|
|
6209
|
+
throw new Error(`Conflicting flag --${flag}`);
|
|
6210
|
+
assignFlag(object[key], child, rest, value, flag);
|
|
6211
|
+
}
|
|
6212
|
+
function validateRequired(value, schema, prefix = "") {
|
|
6213
|
+
if (value === null) return;
|
|
6214
|
+
schema = nonNull(schema);
|
|
6215
|
+
if (Array.isArray(value) && schema.items) {
|
|
6216
|
+
for (let index = 0; index < value.length; index++) {
|
|
6217
|
+
if (!(index in value))
|
|
6218
|
+
throw new Error(`--${prefix} indices must be consecutive from 0`);
|
|
6219
|
+
validateRequired(value[index], schema.items, `${prefix}.${index}`);
|
|
6220
|
+
}
|
|
6221
|
+
} else if (value && typeof value === "object") {
|
|
6222
|
+
const object = value;
|
|
6223
|
+
for (const key of schema.required ?? [])
|
|
6224
|
+
if (object[key] === void 0)
|
|
6225
|
+
throw new Error(
|
|
6226
|
+
`Missing required flag --${prefix ? `${prefix}.` : ""}${kebab(key)}`
|
|
6227
|
+
);
|
|
6228
|
+
for (const [key, child] of Object.entries(schema.properties ?? {}))
|
|
6229
|
+
if (object[key] !== void 0)
|
|
6230
|
+
validateRequired(
|
|
6231
|
+
object[key],
|
|
6232
|
+
child,
|
|
6233
|
+
`${prefix ? `${prefix}.` : ""}${kebab(key)}`
|
|
6234
|
+
);
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
var GLOBAL_FLAGS = /* @__PURE__ */ new Set([
|
|
6238
|
+
"api-key",
|
|
6239
|
+
"base-url",
|
|
6240
|
+
"timeout",
|
|
6241
|
+
"format",
|
|
6242
|
+
"version",
|
|
6243
|
+
"v"
|
|
6244
|
+
]);
|
|
6245
|
+
function parseBodyFlags(flags, schema) {
|
|
6246
|
+
const result = {};
|
|
6247
|
+
for (const [flag, value] of Object.entries(flags)) {
|
|
6248
|
+
if (GLOBAL_FLAGS.has(flag)) continue;
|
|
6249
|
+
assignFlag(result, schema, flag.split("."), value, flag);
|
|
6250
|
+
}
|
|
6251
|
+
validateRequired(result, schema);
|
|
6252
|
+
return result;
|
|
6253
|
+
}
|
|
6254
|
+
|
|
6255
|
+
// src/campaign-commands.ts
|
|
6256
|
+
var patch = CAMPAIGN_INPUTS.patch;
|
|
6257
|
+
var fields = patch.properties;
|
|
6258
|
+
var guards = Object.fromEntries(
|
|
6259
|
+
["organizationId", "expectedRevision", "expectedPendingVersion"].map(
|
|
6260
|
+
(key) => [key, fields[key]]
|
|
6261
|
+
)
|
|
6262
|
+
);
|
|
6263
|
+
var scope = { campaignId: { type: "string" } };
|
|
6264
|
+
function command(name, summary, schema, options = {}) {
|
|
6265
|
+
const inputSchema = {
|
|
6266
|
+
...schema,
|
|
6267
|
+
properties: { ...scope, ...schema.properties },
|
|
6268
|
+
required: ["campaignId", ...schema.required ?? []]
|
|
6269
|
+
};
|
|
6270
|
+
return {
|
|
6271
|
+
trail: ["campaigns", name],
|
|
6272
|
+
resourcePath: ["campaigns"],
|
|
6273
|
+
methodName: name,
|
|
6274
|
+
httpMethod: options.action ? "POST" : "PATCH",
|
|
6275
|
+
path: `/api/v1/campaigns/{campaignId}${options.action ? "/actions" : ""}`,
|
|
6276
|
+
summary,
|
|
6277
|
+
flags: bodyFlagNames(inputSchema).map((flag) => ({
|
|
6278
|
+
name: flag === "campaign-id" ? "campaignId" : flag,
|
|
6279
|
+
flag,
|
|
6280
|
+
required: inputSchema.required.some((key) => kebab(key) === flag),
|
|
6281
|
+
source: flag === "campaign-id" ? "path" : "body"
|
|
6282
|
+
})),
|
|
6283
|
+
acceptsJsonBody: true,
|
|
6284
|
+
acceptsFile: false,
|
|
6285
|
+
bodyRequired: false,
|
|
6286
|
+
inputSchema,
|
|
6287
|
+
...options
|
|
6288
|
+
};
|
|
6289
|
+
}
|
|
6290
|
+
var CAMPAIGN_COMMANDS = [
|
|
6291
|
+
command(
|
|
6292
|
+
"update",
|
|
6293
|
+
"Edit campaign fields, windows and offers. Omitted values stay unchanged; running edits are proposals.",
|
|
6294
|
+
patch
|
|
6295
|
+
),
|
|
6296
|
+
...["offers", "windows"].flatMap((target) => {
|
|
6297
|
+
const { id, ...properties } = fields[target].items.properties;
|
|
6298
|
+
const ids = target === "offers" ? "offerIds" : "windowIds";
|
|
6299
|
+
const selection = {
|
|
6300
|
+
type: "array",
|
|
6301
|
+
items: id,
|
|
6302
|
+
minItems: 1,
|
|
6303
|
+
maxItems: fields[target].maxItems
|
|
6304
|
+
};
|
|
6305
|
+
return [
|
|
6306
|
+
command(
|
|
6307
|
+
`update-${target}`,
|
|
6308
|
+
`Add or update ${target} by stable IDs with shared changes. Running edits are proposals.`,
|
|
6309
|
+
{
|
|
6310
|
+
type: "object",
|
|
6311
|
+
properties: { ...guards, [ids]: selection, ...properties },
|
|
6312
|
+
required: ["expectedRevision", ids]
|
|
6313
|
+
},
|
|
6314
|
+
{ target }
|
|
6315
|
+
),
|
|
6316
|
+
command(
|
|
6317
|
+
`remove-${target}`,
|
|
6318
|
+
`Remove selected ${target}. Move or remove offers before removing their window. Running edits are proposals.`,
|
|
6319
|
+
{
|
|
6320
|
+
type: "object",
|
|
6321
|
+
properties: { ...guards, [ids]: selection },
|
|
6322
|
+
required: ["expectedRevision", ids]
|
|
6323
|
+
},
|
|
6324
|
+
{ target: target === "offers" ? "removeOfferIds" : "removeWindowIds" }
|
|
6325
|
+
)
|
|
6326
|
+
];
|
|
6327
|
+
}),
|
|
6328
|
+
...["approve_change", "discard_change"].map(
|
|
6329
|
+
(action) => command(
|
|
6330
|
+
action.replaceAll("_", "-"),
|
|
6331
|
+
action === "approve_change" ? "Approve the reviewed live proposal as its named approver and queue delivery." : "Discard the reviewed live proposal.",
|
|
6332
|
+
{
|
|
6333
|
+
type: "object",
|
|
6334
|
+
properties: {
|
|
6335
|
+
...guards,
|
|
6336
|
+
expectedPendingVersion: CAMPAIGN_INPUTS.action.properties.expectedPendingVersion
|
|
6337
|
+
},
|
|
6338
|
+
required: ["expectedRevision", "expectedPendingVersion"]
|
|
6339
|
+
},
|
|
6340
|
+
{ action }
|
|
6341
|
+
)
|
|
6342
|
+
)
|
|
6343
|
+
];
|
|
6344
|
+
function isCampaignCommand(command2) {
|
|
6345
|
+
return "inputSchema" in command2;
|
|
6346
|
+
}
|
|
6347
|
+
function campaignRequest(command2, flags) {
|
|
6348
|
+
const input2 = parseBodyFlags(flags, command2.inputSchema);
|
|
6349
|
+
if (command2.action) return { ...input2, action: command2.action };
|
|
6350
|
+
if (!command2.target) {
|
|
6351
|
+
if (!Object.keys(input2).some(
|
|
6352
|
+
(key) => key !== "campaignId" && !(key in guards)
|
|
6353
|
+
))
|
|
6354
|
+
throw new Error("Supply at least one field to change.");
|
|
6355
|
+
return input2;
|
|
6356
|
+
}
|
|
6357
|
+
const {
|
|
6358
|
+
campaignId,
|
|
6359
|
+
organizationId,
|
|
6360
|
+
expectedRevision,
|
|
6361
|
+
expectedPendingVersion,
|
|
6362
|
+
offerIds,
|
|
6363
|
+
windowIds,
|
|
6364
|
+
...changes
|
|
6365
|
+
} = input2;
|
|
6366
|
+
const ids = [...new Set(offerIds ?? windowIds)];
|
|
6367
|
+
const removing = command2.target === "removeOfferIds" || command2.target === "removeWindowIds";
|
|
6368
|
+
if (!removing && !Object.keys(changes).length)
|
|
6369
|
+
throw new Error("Supply at least one field to change.");
|
|
6370
|
+
return {
|
|
6371
|
+
campaignId,
|
|
6372
|
+
organizationId,
|
|
6373
|
+
expectedRevision,
|
|
6374
|
+
expectedPendingVersion,
|
|
6375
|
+
[command2.target]: removing ? ids : ids.map((id) => ({ id, ...changes }))
|
|
6376
|
+
};
|
|
6377
|
+
}
|
|
6378
|
+
|
|
4883
6379
|
// src/help.ts
|
|
4884
6380
|
function printRootHelp(commands) {
|
|
4885
6381
|
const groups = [
|
|
4886
|
-
...new Set(commands.map((
|
|
6382
|
+
...new Set(commands.map((command2) => command2.trail[0]))
|
|
4887
6383
|
].sort();
|
|
4888
6384
|
return `OmniCommerce CLI
|
|
4889
6385
|
|
|
@@ -4923,33 +6419,42 @@ function printAuthHelp() {
|
|
|
4923
6419
|
omni auth logout Remove saved credentials
|
|
4924
6420
|
`;
|
|
4925
6421
|
}
|
|
4926
|
-
function printCommandHelp(
|
|
4927
|
-
const flags =
|
|
6422
|
+
function printCommandHelp(command2) {
|
|
6423
|
+
const flags = command2.flags.map((flag) => {
|
|
4928
6424
|
const req = flag.required ? "required" : "optional";
|
|
4929
6425
|
return ` --${flag.flag} <${flag.name}> ${req} ${flag.source}`;
|
|
4930
6426
|
}).join("\n");
|
|
4931
|
-
const jsonLine = `${
|
|
6427
|
+
const jsonLine = `${command2.acceptsFile ? " --file <path> required file to upload\n" : ""}${command2.acceptsJsonBody && !isCampaignCommand(command2) ? ` --json <object|-> ${command2.bodyRequired && !command2.acceptsFile ? "required" : "optional"} body
|
|
4932
6428
|
` : ""}`;
|
|
4933
|
-
return `omni ${
|
|
6429
|
+
return `omni ${command2.trail.join(" ")}
|
|
4934
6430
|
|
|
4935
|
-
${
|
|
6431
|
+
${command2.summary}
|
|
4936
6432
|
|
|
4937
|
-
${
|
|
6433
|
+
${command2.httpMethod} ${command2.path}
|
|
4938
6434
|
|
|
4939
6435
|
Flags:
|
|
4940
6436
|
${flags || " (none)"}${jsonLine ? `
|
|
4941
6437
|
${jsonLine}` : ""}
|
|
6438
|
+
${isCampaignCommand(command2) ? "\nArrays use comma-separated values (empty string clears). Object arrays use .0., .1., ... in flag names. Nullable fields accept null. Times require ISO 8601 with an explicit offset. Use --schema for types and allowed values.\n" : ""}
|
|
4942
6439
|
`;
|
|
4943
6440
|
}
|
|
4944
6441
|
function matchCommands(commands, trail) {
|
|
4945
6442
|
const prefix = commands.filter(
|
|
4946
|
-
(
|
|
6443
|
+
(command2) => trail.every((token, index) => command2.trail[index] === token)
|
|
4947
6444
|
);
|
|
4948
|
-
const exact = prefix.find((
|
|
6445
|
+
const exact = prefix.find((command2) => command2.trail.length === trail.length);
|
|
4949
6446
|
return { exact, prefix };
|
|
4950
6447
|
}
|
|
4951
6448
|
|
|
4952
6449
|
// src/run.ts
|
|
6450
|
+
var CLI_COMMANDS = [
|
|
6451
|
+
...COMMANDS.filter(
|
|
6452
|
+
(command2) => !CAMPAIGN_COMMANDS.some(
|
|
6453
|
+
(custom) => custom.trail.join(" ") === command2.trail.join(" ")
|
|
6454
|
+
)
|
|
6455
|
+
),
|
|
6456
|
+
...CAMPAIGN_COMMANDS
|
|
6457
|
+
];
|
|
4953
6458
|
async function readStdin() {
|
|
4954
6459
|
const chunks = [];
|
|
4955
6460
|
for await (const chunk of input) {
|
|
@@ -4966,9 +6471,9 @@ async function parseJsonBody(raw) {
|
|
|
4966
6471
|
}
|
|
4967
6472
|
return parsed;
|
|
4968
6473
|
}
|
|
4969
|
-
function buildRequest(
|
|
6474
|
+
function buildRequest(command2, flags, body) {
|
|
4970
6475
|
const request = { ...body };
|
|
4971
|
-
for (const flag of
|
|
6476
|
+
for (const flag of command2.flags) {
|
|
4972
6477
|
const value = flagString(flags, flag.flag);
|
|
4973
6478
|
if (value === void 0) {
|
|
4974
6479
|
if (flag.required) {
|
|
@@ -5037,19 +6542,19 @@ async function runCli(argv, options) {
|
|
|
5037
6542
|
return handleAuth(parsed.trail, parsed.flags, options);
|
|
5038
6543
|
}
|
|
5039
6544
|
if (parsed.trail.length === 0) {
|
|
5040
|
-
process.stdout.write(printRootHelp(
|
|
6545
|
+
process.stdout.write(printRootHelp(CLI_COMMANDS));
|
|
5041
6546
|
return parsed.help ? 0 : 1;
|
|
5042
6547
|
}
|
|
5043
|
-
const matched = matchCommands(
|
|
6548
|
+
const matched = matchCommands(CLI_COMMANDS, parsed.trail);
|
|
5044
6549
|
if (parsed.help && !matched.exact) {
|
|
5045
6550
|
if (matched.prefix.length === 0) {
|
|
5046
6551
|
process.stderr.write(`Unknown command: ${parsed.trail.join(" ")}
|
|
5047
6552
|
`);
|
|
5048
|
-
process.stdout.write(printRootHelp(
|
|
6553
|
+
process.stdout.write(printRootHelp(CLI_COMMANDS));
|
|
5049
6554
|
return 1;
|
|
5050
6555
|
}
|
|
5051
6556
|
const unique = [
|
|
5052
|
-
...new Set(matched.prefix.map((
|
|
6557
|
+
...new Set(matched.prefix.map((command3) => command3.trail.join(" ")))
|
|
5053
6558
|
];
|
|
5054
6559
|
process.stdout.write(
|
|
5055
6560
|
`omni ${parsed.trail.join(" ")}
|
|
@@ -5060,38 +6565,42 @@ ${unique.map((line) => ` omni ${line}`).join("\n")}
|
|
|
5060
6565
|
);
|
|
5061
6566
|
return 0;
|
|
5062
6567
|
}
|
|
5063
|
-
const
|
|
5064
|
-
if (!
|
|
6568
|
+
const command2 = matched.exact;
|
|
6569
|
+
if (!command2) {
|
|
5065
6570
|
process.stderr.write(`Unknown command: ${parsed.trail.join(" ")}
|
|
5066
6571
|
`);
|
|
5067
|
-
process.stdout.write(printRootHelp(
|
|
6572
|
+
process.stdout.write(printRootHelp(CLI_COMMANDS));
|
|
5068
6573
|
return 1;
|
|
5069
6574
|
}
|
|
5070
6575
|
if (parsed.help) {
|
|
5071
|
-
process.stdout.write(printCommandHelp(
|
|
6576
|
+
process.stdout.write(printCommandHelp(command2));
|
|
5072
6577
|
return 0;
|
|
5073
6578
|
}
|
|
5074
6579
|
if (parsed.schema) {
|
|
5075
|
-
process.stdout.write(`${JSON.stringify(
|
|
6580
|
+
process.stdout.write(`${JSON.stringify(command2, null, 2)}
|
|
5076
6581
|
`);
|
|
5077
6582
|
return 0;
|
|
5078
6583
|
}
|
|
5079
6584
|
const body = await parseJsonBody(flagString(parsed.flags, "json"));
|
|
5080
|
-
const filePath =
|
|
5081
|
-
if (
|
|
5082
|
-
throw new Error(`omni ${
|
|
6585
|
+
const filePath = command2.acceptsFile ? flagString(parsed.flags, "file") : void 0;
|
|
6586
|
+
if (command2.acceptsFile && !filePath) {
|
|
6587
|
+
throw new Error(`omni ${command2.trail.join(" ")} requires --file <path>`);
|
|
5083
6588
|
}
|
|
5084
|
-
if (
|
|
5085
|
-
throw new Error(`omni ${
|
|
6589
|
+
if (command2.bodyRequired && !body && !filePath) {
|
|
6590
|
+
throw new Error(`omni ${command2.trail.join(" ")} requires --json`);
|
|
5086
6591
|
}
|
|
5087
|
-
|
|
6592
|
+
if (isCampaignCommand(command2) && body)
|
|
6593
|
+
throw new Error(
|
|
6594
|
+
"Use campaign field flags for this command; --json is available on campaigns replace and actions."
|
|
6595
|
+
);
|
|
6596
|
+
const request = isCampaignCommand(command2) ? campaignRequest(command2, parsed.flags) : buildRequest(command2, parsed.flags, body);
|
|
5088
6597
|
if (filePath) request.file = filePath;
|
|
5089
6598
|
if (parsed.dryRun) {
|
|
5090
6599
|
process.stdout.write(
|
|
5091
6600
|
`${JSON.stringify(
|
|
5092
6601
|
{
|
|
5093
|
-
method:
|
|
5094
|
-
path:
|
|
6602
|
+
method: command2.httpMethod,
|
|
6603
|
+
path: command2.path,
|
|
5095
6604
|
request
|
|
5096
6605
|
},
|
|
5097
6606
|
null,
|
|
@@ -5112,7 +6621,7 @@ ${unique.map((line) => ` omni ${line}`).join("\n")}
|
|
|
5112
6621
|
return 1;
|
|
5113
6622
|
}
|
|
5114
6623
|
const timeoutRaw = flagString(parsed.flags, "timeout");
|
|
5115
|
-
const timeoutInSeconds = timeoutRaw ? Number(timeoutRaw) :
|
|
6624
|
+
const timeoutInSeconds = timeoutRaw ? Number(timeoutRaw) : command2.path === "/api/v1/agents/general/invoke" ? 780 : void 0;
|
|
5116
6625
|
const client = new OmniClient({
|
|
5117
6626
|
apiKey: credentials.apiKey,
|
|
5118
6627
|
baseUrl: credentials.baseUrl,
|
|
@@ -5120,7 +6629,7 @@ ${unique.map((line) => ` omni ${line}`).join("\n")}
|
|
|
5120
6629
|
fetch: options?.fetch
|
|
5121
6630
|
});
|
|
5122
6631
|
try {
|
|
5123
|
-
const result = await executeCommand(client,
|
|
6632
|
+
const result = await executeCommand(client, command2, request);
|
|
5124
6633
|
const format = resolveFormat(
|
|
5125
6634
|
flagString(parsed.flags, "format"),
|
|
5126
6635
|
options?.stdoutIsTty ?? Boolean(process.stdout.isTTY)
|