@omni-commerce/cli 0.9.0 → 0.11.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
@@ -11,7 +11,8 @@ var GLOBAL_TRUE_FLAGS = /* @__PURE__ */ new Set([
11
11
  "schema",
12
12
  "dry-run",
13
13
  "version",
14
- "v"
14
+ "v",
15
+ "no-browser"
15
16
  ]);
16
17
  function parseArgv(argv) {
17
18
  const trail = [];
@@ -49,7 +50,7 @@ function parseArgv(argv) {
49
50
  continue;
50
51
  }
51
52
  const next = argv[index + 1];
52
- if (!next || next.startsWith("-") && next !== "-" || GLOBAL_TRUE_FLAGS.has(stripped)) {
53
+ if (next === void 0 || next.startsWith("-") && next !== "-" || GLOBAL_TRUE_FLAGS.has(stripped)) {
53
54
  flags[stripped] = true;
54
55
  continue;
55
56
  }
@@ -69,6 +70,129 @@ function flagString(flags, name) {
69
70
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
70
71
  }
71
72
 
73
+ // src/browser-login.ts
74
+ import { setTimeout as sleep } from "timers/promises";
75
+
76
+ // src/open-browser.ts
77
+ import { execFile } from "child_process";
78
+ import { promisify } from "util";
79
+ var executeFile = promisify(execFile);
80
+ async function openBrowser(url) {
81
+ const command2 = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32.exe" : "xdg-open";
82
+ const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
83
+ await executeFile(command2, args, { timeout: 1e4 });
84
+ }
85
+
86
+ // src/version.ts
87
+ var CLI_VERSION = "0.11.0";
88
+
89
+ // src/browser-login.ts
90
+ function loginOrigin(baseUrl) {
91
+ const url = new URL(baseUrl);
92
+ const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
93
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback) || url.username || url.password || url.search || url.hash || url.pathname !== "/") {
94
+ throw new Error(
95
+ "Login requires an HTTPS API origin (HTTP is allowed on localhost)."
96
+ );
97
+ }
98
+ return url.origin;
99
+ }
100
+ async function readResponse(response) {
101
+ const body = await response.json().catch(() => null);
102
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
103
+ throw new Error("Invalid login response. Check --base-url and try again.");
104
+ }
105
+ return body;
106
+ }
107
+ async function browserLogin(baseUrl, options = {}) {
108
+ const origin = loginOrigin(baseUrl);
109
+ const fetchImpl = options.fetch ?? fetch;
110
+ const post = (path2, body, timeoutMs = 3e4) => fetchImpl(new URL(path2, origin), {
111
+ method: "POST",
112
+ headers: { "Content-Type": "application/json" },
113
+ body: JSON.stringify(body),
114
+ redirect: "error",
115
+ signal: AbortSignal.timeout(Math.max(1, timeoutMs))
116
+ });
117
+ const started = await post("/api/cli/device/code", {
118
+ client_version: CLI_VERSION
119
+ });
120
+ if (!started.ok)
121
+ throw new Error(
122
+ `Could not start browser login (${started.status}). Try again shortly.`
123
+ );
124
+ const issued = await readResponse(started);
125
+ if (typeof issued.device_code !== "string" || !/^[a-f0-9]{64}$/.test(issued.device_code) || typeof issued.user_code !== "string" || !/^[A-Z]{4}-[A-Z]{4}$/.test(issued.user_code) || typeof issued.verification_uri_complete !== "string" || typeof issued.expires_in !== "number" || !Number.isFinite(issued.expires_in) || issued.expires_in <= 0 || issued.expires_in > 900 || typeof issued.interval !== "number" || !Number.isFinite(issued.interval) || issued.interval < 5 || issued.interval > 900) {
126
+ throw new Error(
127
+ "Invalid browser login response. Check --base-url and try again."
128
+ );
129
+ }
130
+ const verificationUrl = new URL(issued.verification_uri_complete);
131
+ if (verificationUrl.origin !== origin || verificationUrl.username || verificationUrl.password || verificationUrl.pathname !== "/cli/authorize" || verificationUrl.searchParams.get("code") !== issued.user_code || [...verificationUrl.searchParams.keys()].some((key) => key !== "code") || verificationUrl.hash) {
132
+ throw new Error("The login page does not match the requested API origin.");
133
+ }
134
+ const deadline = Date.now() + issued.expires_in * 1e3;
135
+ let intervalMs = issued.interval * 1e3;
136
+ process.stdout.write(
137
+ `Confirm code ${issued.user_code} in your browser.
138
+ ${verificationUrl.toString()}
139
+ `
140
+ );
141
+ if (!options.noBrowser) {
142
+ try {
143
+ await (options.openBrowser ?? openBrowser)(verificationUrl.toString());
144
+ } catch {
145
+ process.stderr.write(
146
+ "Could not open your browser. Open the URL above to continue.\n"
147
+ );
148
+ }
149
+ }
150
+ while (Date.now() < deadline) {
151
+ await sleep(Math.min(intervalMs, deadline - Date.now()));
152
+ if (Date.now() >= deadline) break;
153
+ let response;
154
+ try {
155
+ response = await post(
156
+ "/api/cli/device/token",
157
+ { device_code: issued.device_code },
158
+ Math.min(3e4, deadline - Date.now())
159
+ );
160
+ } catch {
161
+ intervalMs = Math.min(Math.max(intervalMs * 2, 1e4), 6e4);
162
+ continue;
163
+ }
164
+ if (response.status === 429 || response.status >= 500) {
165
+ const retryAfter = Number(response.headers.get("Retry-After"));
166
+ intervalMs = Math.max(
167
+ intervalMs + 5e3,
168
+ Number.isFinite(retryAfter) ? retryAfter * 1e3 : 0
169
+ );
170
+ continue;
171
+ }
172
+ const result = await readResponse(response);
173
+ if (response.ok) {
174
+ if (typeof result.api_key !== "string" || !result.api_key.startsWith("omni_sk_") || result.token_type !== "api_key") {
175
+ throw new Error("The login server did not return valid credentials.");
176
+ }
177
+ return { apiKey: result.api_key, baseUrl: origin };
178
+ }
179
+ if (result.error === "authorization_pending") continue;
180
+ if (result.error === "slow_down") {
181
+ intervalMs += 5e3;
182
+ continue;
183
+ }
184
+ if (result.error === "access_denied")
185
+ throw new Error(
186
+ "Browser login was denied. Run omni auth login to try again."
187
+ );
188
+ if (result.error === "expired_token") break;
189
+ throw new Error(
190
+ `Browser login failed (${response.status}). Run omni auth login to try again.`
191
+ );
192
+ }
193
+ throw new Error("Browser login expired. Run omni auth login to try again.");
194
+ }
195
+
72
196
  // src/config.ts
73
197
  import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
74
198
  import { homedir } from "os";
@@ -87,9 +211,12 @@ async function readConfig() {
87
211
  }
88
212
  async function writeConfig(config) {
89
213
  const directory = path.dirname(configPath());
90
- await mkdir(directory, { recursive: true });
214
+ await mkdir(directory, { recursive: true, mode: 448 });
91
215
  await writeFile(configPath(), `${JSON.stringify(config, null, 2)}
92
- `, "utf8");
216
+ `, {
217
+ encoding: "utf8",
218
+ mode: 384
219
+ });
93
220
  await chmod(configPath(), 384);
94
221
  }
95
222
  async function clearConfig() {
@@ -99,7 +226,7 @@ async function resolveCredentials(input2) {
99
226
  const file = await readConfig();
100
227
  const apiKey = input2.apiKey || process.env.OMNI_API_KEY || file.apiKey || void 0;
101
228
  const source = input2.apiKey ? "flag" : process.env.OMNI_API_KEY ? "env" : file.apiKey ? "config" : "none";
102
- const baseUrl = input2.baseUrl || process.env.OMNI_BASE_URL || file.baseUrl || "https://omnicommerce.sg";
229
+ const baseUrl = input2.baseUrl || process.env.OMNI_BASE_URL || file.baseUrl || "https://omnicommerce.ai";
103
230
  return { apiKey, baseUrl, source };
104
231
  }
105
232
  function maskSecret(value) {
@@ -134,14 +261,14 @@ var UPLOAD_CONTENT_TYPES = {
134
261
  ".heic": "image/heic",
135
262
  ".heif": "image/heif"
136
263
  };
137
- async function uploadBody(filePath, fields) {
264
+ async function uploadBody(filePath, fields2) {
138
265
  const form = new FormData();
139
266
  const type = UPLOAD_CONTENT_TYPES[extname(filePath).toLowerCase()] ?? "application/octet-stream";
140
267
  form.append(
141
268
  "file",
142
269
  new File([await readFile2(filePath)], basename(filePath), { type })
143
270
  );
144
- for (const [key, value] of Object.entries(fields)) {
271
+ for (const [key, value] of Object.entries(fields2)) {
145
272
  if (value === void 0 || value === null) continue;
146
273
  form.append(
147
274
  key,
@@ -156,8 +283,8 @@ function stringValue(value, flag) {
156
283
  }
157
284
  return value;
158
285
  }
159
- async function executeCommand(client, command, request) {
160
- if (command.resourcePath[0] === "jobs" && command.methodName === "wait") {
286
+ async function executeCommand(client, command2, request) {
287
+ if (command2.resourcePath[0] === "jobs" && command2.methodName === "wait") {
161
288
  const jobId = stringValue(request.jobId, "job-id");
162
289
  const organizationId = typeof request.organizationId === "string" ? request.organizationId : void 0;
163
290
  return client.jobs.wait({ jobId, organizationId });
@@ -165,7 +292,8 @@ async function executeCommand(client, command, request) {
165
292
  const pathValues = {};
166
293
  const query = {};
167
294
  const consumed = /* @__PURE__ */ new Set();
168
- for (const flag of command.flags) {
295
+ for (const flag of command2.flags) {
296
+ if (flag.source === "body") continue;
169
297
  const value = request[flag.name];
170
298
  if (value === void 0) continue;
171
299
  consumed.add(flag.name);
@@ -179,20 +307,20 @@ async function executeCommand(client, command, request) {
179
307
  for (const [key, value] of Object.entries(request)) {
180
308
  if (!consumed.has(key)) body[key] = value;
181
309
  }
182
- if (command.acceptsFile) {
183
- const { file, ...fields } = body;
310
+ if (command2.acceptsFile) {
311
+ const { file, ...fields2 } = body;
184
312
  return client.request({
185
- method: command.httpMethod,
186
- path: interpolatePath(command.path, pathValues),
313
+ method: command2.httpMethod,
314
+ path: interpolatePath(command2.path, pathValues),
187
315
  query: Object.keys(query).length > 0 ? query : void 0,
188
- body: await uploadBody(stringValue(file, "file"), fields)
316
+ body: await uploadBody(stringValue(file, "file"), fields2)
189
317
  });
190
318
  }
191
319
  return client.request({
192
- method: command.httpMethod,
193
- path: interpolatePath(command.path, pathValues),
320
+ method: command2.httpMethod,
321
+ path: interpolatePath(command2.path, pathValues),
194
322
  query: Object.keys(query).length > 0 ? query : void 0,
195
- body: command.acceptsJsonBody && Object.keys(body).length > 0 ? body : void 0
323
+ body: command2.acceptsJsonBody && Object.keys(body).length > 0 ? body : void 0
196
324
  });
197
325
  }
198
326
 
@@ -237,6 +365,69 @@ ${body}
237
365
 
238
366
  // src/generated/commands.ts
239
367
  var COMMANDS = [
368
+ {
369
+ trail: ["api", "get-embedwell-knownagent-card-json"],
370
+ resourcePath: ["api"],
371
+ methodName: "getEmbedwellKnownagentCardJson",
372
+ httpMethod: "GET",
373
+ path: "/api/embed/{deploymentId}/.well-known/agent-card.json",
374
+ summary: "Discover a published merchant agent",
375
+ flags: [
376
+ {
377
+ name: "deploymentId",
378
+ flag: "deployment-id",
379
+ required: true,
380
+ source: "path"
381
+ }
382
+ ],
383
+ acceptsJsonBody: false,
384
+ acceptsFile: false,
385
+ bodyRequired: false
386
+ },
387
+ {
388
+ trail: ["api", "embeda2a"],
389
+ resourcePath: ["api"],
390
+ methodName: "embeda2a",
391
+ httpMethod: "POST",
392
+ path: "/api/embed/{deploymentId}/a2a",
393
+ summary: "Call a merchant agent using A2A",
394
+ flags: [
395
+ {
396
+ name: "deploymentId",
397
+ flag: "deployment-id",
398
+ required: true,
399
+ source: "path"
400
+ }
401
+ ],
402
+ acceptsJsonBody: true,
403
+ acceptsFile: false,
404
+ bodyRequired: true
405
+ },
406
+ {
407
+ trail: ["api", "embedcheckout-sessions"],
408
+ resourcePath: ["api"],
409
+ methodName: "embedcheckoutSessions",
410
+ httpMethod: "POST",
411
+ path: "/api/embed/{deploymentId}/checkout-sessions/{operation}",
412
+ summary: "Manage customer-owned purchase offers",
413
+ flags: [
414
+ {
415
+ name: "deploymentId",
416
+ flag: "deployment-id",
417
+ required: true,
418
+ source: "path"
419
+ },
420
+ {
421
+ name: "operation",
422
+ flag: "operation",
423
+ required: true,
424
+ source: "path"
425
+ }
426
+ ],
427
+ acceptsJsonBody: true,
428
+ acceptsFile: false,
429
+ bodyRequired: true
430
+ },
240
431
  {
241
432
  trail: ["agents", "general", "invoke"],
242
433
  resourcePath: ["agents", "general"],
@@ -1068,6 +1259,124 @@ var COMMANDS = [
1068
1259
  acceptsFile: false,
1069
1260
  bodyRequired: true
1070
1261
  },
1262
+ {
1263
+ trail: ["brand-kits", "list"],
1264
+ resourcePath: ["brandKits"],
1265
+ methodName: "list",
1266
+ httpMethod: "GET",
1267
+ path: "/api/v1/brand-kits",
1268
+ summary: "List Brand Kits",
1269
+ flags: [
1270
+ {
1271
+ name: "organizationId",
1272
+ flag: "organization-id",
1273
+ required: false,
1274
+ source: "query"
1275
+ },
1276
+ {
1277
+ name: "q",
1278
+ flag: "q",
1279
+ required: false,
1280
+ source: "query"
1281
+ },
1282
+ {
1283
+ name: "limit",
1284
+ flag: "limit",
1285
+ required: false,
1286
+ source: "query"
1287
+ },
1288
+ {
1289
+ name: "offset",
1290
+ flag: "offset",
1291
+ required: false,
1292
+ source: "query"
1293
+ }
1294
+ ],
1295
+ acceptsJsonBody: false,
1296
+ acceptsFile: false,
1297
+ bodyRequired: false
1298
+ },
1299
+ {
1300
+ trail: ["brand-kits", "create"],
1301
+ resourcePath: ["brandKits"],
1302
+ methodName: "create",
1303
+ httpMethod: "POST",
1304
+ path: "/api/v1/brand-kits",
1305
+ summary: "Create Brand Kit",
1306
+ flags: [],
1307
+ acceptsJsonBody: true,
1308
+ acceptsFile: false,
1309
+ bodyRequired: true
1310
+ },
1311
+ {
1312
+ trail: ["brand-kits", "delete"],
1313
+ resourcePath: ["brandKits"],
1314
+ methodName: "delete",
1315
+ httpMethod: "DELETE",
1316
+ path: "/api/v1/brand-kits/{brandKitId}",
1317
+ summary: "Delete Brand Kit",
1318
+ flags: [
1319
+ {
1320
+ name: "brandKitId",
1321
+ flag: "brand-kit-id",
1322
+ required: true,
1323
+ source: "path"
1324
+ },
1325
+ {
1326
+ name: "organizationId",
1327
+ flag: "organization-id",
1328
+ required: false,
1329
+ source: "query"
1330
+ }
1331
+ ],
1332
+ acceptsJsonBody: false,
1333
+ acceptsFile: false,
1334
+ bodyRequired: false
1335
+ },
1336
+ {
1337
+ trail: ["brand-kits", "get"],
1338
+ resourcePath: ["brandKits"],
1339
+ methodName: "get",
1340
+ httpMethod: "GET",
1341
+ path: "/api/v1/brand-kits/{brandKitId}",
1342
+ summary: "Get Brand Kit",
1343
+ flags: [
1344
+ {
1345
+ name: "brandKitId",
1346
+ flag: "brand-kit-id",
1347
+ required: true,
1348
+ source: "path"
1349
+ },
1350
+ {
1351
+ name: "organizationId",
1352
+ flag: "organization-id",
1353
+ required: false,
1354
+ source: "query"
1355
+ }
1356
+ ],
1357
+ acceptsJsonBody: false,
1358
+ acceptsFile: false,
1359
+ bodyRequired: false
1360
+ },
1361
+ {
1362
+ trail: ["brand-kits", "update"],
1363
+ resourcePath: ["brandKits"],
1364
+ methodName: "update",
1365
+ httpMethod: "PATCH",
1366
+ path: "/api/v1/brand-kits/{brandKitId}",
1367
+ summary: "Update Brand Kit",
1368
+ flags: [
1369
+ {
1370
+ name: "brandKitId",
1371
+ flag: "brand-kit-id",
1372
+ required: true,
1373
+ source: "path"
1374
+ }
1375
+ ],
1376
+ acceptsJsonBody: true,
1377
+ acceptsFile: false,
1378
+ bodyRequired: true
1379
+ },
1071
1380
  {
1072
1381
  trail: ["brandsgateway", "import-products"],
1073
1382
  resourcePath: ["brandsgateway"],
@@ -1100,6 +1409,18 @@ var COMMANDS = [
1100
1409
  required: false,
1101
1410
  source: "query"
1102
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
+ },
1103
1424
  {
1104
1425
  name: "stage",
1105
1426
  flag: "stage",
@@ -1172,6 +1493,25 @@ var COMMANDS = [
1172
1493
  acceptsFile: false,
1173
1494
  bodyRequired: false
1174
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
+ },
1175
1515
  {
1176
1516
  trail: ["campaigns", "replace"],
1177
1517
  resourcePath: ["campaigns"],
@@ -1211,42 +1551,30 @@ var COMMANDS = [
1211
1551
  bodyRequired: true
1212
1552
  },
1213
1553
  {
1214
- trail: ["campaigns", "archive"],
1215
- resourcePath: ["campaigns"],
1216
- methodName: "archive",
1217
- httpMethod: "POST",
1218
- path: "/api/v1/campaigns/archive",
1219
- summary: "Archive Campaigns",
1220
- flags: [],
1221
- acceptsJsonBody: true,
1222
- acceptsFile: false,
1223
- bodyRequired: true
1224
- },
1225
- {
1226
- trail: ["campaigns", "delete"],
1227
- resourcePath: ["campaigns"],
1228
- methodName: "delete",
1229
- httpMethod: "POST",
1230
- path: "/api/v1/campaigns/delete",
1231
- summary: "Delete Campaigns",
1232
- flags: [],
1233
- acceptsJsonBody: true,
1234
- acceptsFile: false,
1235
- bodyRequired: true
1236
- },
1237
- {
1238
- trail: ["campaigns", "get-options"],
1554
+ trail: ["campaigns", "get-analytics"],
1239
1555
  resourcePath: ["campaigns"],
1240
- methodName: "getOptions",
1556
+ methodName: "getAnalytics",
1241
1557
  httpMethod: "GET",
1242
- path: "/api/v1/campaigns/options",
1243
- summary: "Get Campaign Options",
1558
+ path: "/api/v1/campaigns/{campaignId}/analytics",
1559
+ summary: "Get Campaign Analytics",
1244
1560
  flags: [
1561
+ {
1562
+ name: "campaignId",
1563
+ flag: "campaign-id",
1564
+ required: true,
1565
+ source: "path"
1566
+ },
1245
1567
  {
1246
1568
  name: "organizationId",
1247
1569
  flag: "organization-id",
1248
1570
  required: false,
1249
1571
  source: "query"
1572
+ },
1573
+ {
1574
+ name: "analyticsWindow",
1575
+ flag: "analytics-window",
1576
+ required: false,
1577
+ source: "query"
1250
1578
  }
1251
1579
  ],
1252
1580
  acceptsJsonBody: false,
@@ -1254,23 +1582,213 @@ var COMMANDS = [
1254
1582
  bodyRequired: false
1255
1583
  },
1256
1584
  {
1257
- trail: ["catalog", "list-items"],
1258
- resourcePath: ["catalog"],
1259
- methodName: "listItems",
1585
+ trail: ["campaigns", "get-notifications"],
1586
+ resourcePath: ["campaigns"],
1587
+ methodName: "getNotifications",
1260
1588
  httpMethod: "GET",
1261
- path: "/api/v1/catalog/items",
1262
- summary: "Export Catalog Items",
1589
+ path: "/api/v1/campaigns/{campaignId}/notifications",
1590
+ summary: "Get Campaign Notifications",
1263
1591
  flags: [
1592
+ {
1593
+ name: "campaignId",
1594
+ flag: "campaign-id",
1595
+ required: true,
1596
+ source: "path"
1597
+ },
1264
1598
  {
1265
1599
  name: "organizationId",
1266
1600
  flag: "organization-id",
1267
1601
  required: false,
1268
1602
  source: "query"
1269
- },
1270
- {
1271
- name: "updatedSince",
1272
- flag: "updated-since",
1273
- required: false,
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
+ },
1695
+ {
1696
+ trail: ["campaigns", "archive"],
1697
+ resourcePath: ["campaigns"],
1698
+ methodName: "archive",
1699
+ httpMethod: "POST",
1700
+ path: "/api/v1/campaigns/archive",
1701
+ summary: "Archive Campaigns",
1702
+ flags: [],
1703
+ acceptsJsonBody: true,
1704
+ acceptsFile: false,
1705
+ bodyRequired: true
1706
+ },
1707
+ {
1708
+ trail: ["campaigns", "delete"],
1709
+ resourcePath: ["campaigns"],
1710
+ methodName: "delete",
1711
+ httpMethod: "POST",
1712
+ path: "/api/v1/campaigns/delete",
1713
+ summary: "Delete Campaigns",
1714
+ flags: [],
1715
+ acceptsJsonBody: true,
1716
+ acceptsFile: false,
1717
+ bodyRequired: true
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
+ },
1731
+ {
1732
+ trail: ["campaigns", "get-options"],
1733
+ resourcePath: ["campaigns"],
1734
+ methodName: "getOptions",
1735
+ httpMethod: "GET",
1736
+ path: "/api/v1/campaigns/options",
1737
+ summary: "Get Campaign Options",
1738
+ flags: [
1739
+ {
1740
+ name: "organizationId",
1741
+ flag: "organization-id",
1742
+ required: false,
1743
+ source: "query"
1744
+ }
1745
+ ],
1746
+ acceptsJsonBody: false,
1747
+ acceptsFile: false,
1748
+ bodyRequired: false
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
+ },
1774
+ {
1775
+ trail: ["catalog", "list-items"],
1776
+ resourcePath: ["catalog"],
1777
+ methodName: "listItems",
1778
+ httpMethod: "GET",
1779
+ path: "/api/v1/catalog/items",
1780
+ summary: "Export Catalog Items",
1781
+ flags: [
1782
+ {
1783
+ name: "organizationId",
1784
+ flag: "organization-id",
1785
+ required: false,
1786
+ source: "query"
1787
+ },
1788
+ {
1789
+ name: "updatedSince",
1790
+ flag: "updated-since",
1791
+ required: false,
1274
1792
  source: "query"
1275
1793
  },
1276
1794
  {
@@ -1433,6 +1951,30 @@ var COMMANDS = [
1433
1951
  acceptsFile: false,
1434
1952
  bodyRequired: true
1435
1953
  },
1954
+ {
1955
+ trail: ["commerce", "await-jobs"],
1956
+ resourcePath: ["commerce"],
1957
+ methodName: "awaitJobs",
1958
+ httpMethod: "POST",
1959
+ path: "/api/v1/commerce/jobs/await",
1960
+ summary: "Await Commerce Jobs",
1961
+ flags: [],
1962
+ acceptsJsonBody: true,
1963
+ acceptsFile: false,
1964
+ bodyRequired: true
1965
+ },
1966
+ {
1967
+ trail: ["commerce", "verify-state"],
1968
+ resourcePath: ["commerce"],
1969
+ methodName: "verifyState",
1970
+ httpMethod: "POST",
1971
+ path: "/api/v1/commerce/state/verify",
1972
+ summary: "Verify Commerce State",
1973
+ flags: [],
1974
+ acceptsJsonBody: true,
1975
+ acceptsFile: false,
1976
+ bodyRequired: true
1977
+ },
1436
1978
  {
1437
1979
  trail: ["compare", "get"],
1438
1980
  resourcePath: ["compare"],
@@ -1501,6 +2043,12 @@ var COMMANDS = [
1501
2043
  flag: "organization-id",
1502
2044
  required: false,
1503
2045
  source: "query"
2046
+ },
2047
+ {
2048
+ name: "includeDownloadUrl",
2049
+ flag: "include-download-url",
2050
+ required: false,
2051
+ source: "query"
1504
2052
  }
1505
2053
  ],
1506
2054
  acceptsJsonBody: false,
@@ -1556,6 +2104,79 @@ var COMMANDS = [
1556
2104
  acceptsFile: false,
1557
2105
  bodyRequired: true
1558
2106
  },
2107
+ {
2108
+ trail: ["inventory", "list"],
2109
+ resourcePath: ["inventory"],
2110
+ methodName: "list",
2111
+ httpMethod: "GET",
2112
+ path: "/api/v1/inventory",
2113
+ summary: "List Inventory Groups",
2114
+ flags: [
2115
+ {
2116
+ name: "productIds",
2117
+ flag: "product-ids",
2118
+ required: false,
2119
+ source: "query"
2120
+ },
2121
+ {
2122
+ name: "query",
2123
+ flag: "query",
2124
+ required: false,
2125
+ source: "query"
2126
+ },
2127
+ {
2128
+ name: "marketplace",
2129
+ flag: "marketplace",
2130
+ required: false,
2131
+ source: "query"
2132
+ },
2133
+ {
2134
+ name: "country",
2135
+ flag: "country",
2136
+ required: false,
2137
+ source: "query"
2138
+ },
2139
+ {
2140
+ name: "storeIds",
2141
+ flag: "store-ids",
2142
+ required: false,
2143
+ source: "query"
2144
+ },
2145
+ {
2146
+ name: "unlistedMarketplaces",
2147
+ flag: "unlisted-marketplaces",
2148
+ required: false,
2149
+ source: "query"
2150
+ },
2151
+ {
2152
+ name: "groupBy",
2153
+ flag: "group-by",
2154
+ required: false,
2155
+ source: "query"
2156
+ },
2157
+ {
2158
+ name: "status",
2159
+ flag: "status",
2160
+ required: false,
2161
+ source: "query"
2162
+ },
2163
+ {
2164
+ name: "offset",
2165
+ flag: "offset",
2166
+ required: false,
2167
+ source: "query"
2168
+ },
2169
+ {
2170
+ name: "limit",
2171
+ flag: "limit",
2172
+ required: false,
2173
+ source: "query"
2174
+ }
2175
+ ],
2176
+ acceptsJsonBody: false,
2177
+ acceptsFile: false,
2178
+ bodyRequired: false
2179
+ },
1559
2180
  {
1560
2181
  trail: ["jobs", "get"],
1561
2182
  resourcePath: ["jobs"],
@@ -2159,28 +2780,108 @@ var COMMANDS = [
2159
2780
  bodyRequired: true
2160
2781
  },
2161
2782
  {
2162
- trail: ["organizations", "create"],
2163
- resourcePath: ["organizations"],
2164
- methodName: "create",
2165
- httpMethod: "POST",
2166
- path: "/api/v1/organizations",
2167
- summary: "Create Organization",
2168
- flags: [],
2169
- acceptsJsonBody: true,
2170
- acceptsFile: false,
2171
- bodyRequired: true
2172
- },
2173
- {
2174
- trail: ["price-books", "list"],
2175
- resourcePath: ["priceBooks"],
2176
- methodName: "list",
2783
+ trail: ["orders", "list-batch-action-options"],
2784
+ resourcePath: ["orders"],
2785
+ methodName: "listBatchActionOptions",
2177
2786
  httpMethod: "GET",
2178
- path: "/api/v1/price-books",
2179
- summary: "List Price Book Rules",
2787
+ path: "/api/v1/orders/actions",
2788
+ summary: "Check Order Action Options",
2180
2789
  flags: [
2181
2790
  {
2182
- name: "organizationId",
2183
- flag: "organization-id",
2791
+ name: "orderIds",
2792
+ flag: "order-ids",
2793
+ required: true,
2794
+ source: "query"
2795
+ },
2796
+ {
2797
+ name: "action",
2798
+ flag: "action",
2799
+ required: true,
2800
+ source: "query"
2801
+ },
2802
+ {
2803
+ name: "organizationId",
2804
+ flag: "organization-id",
2805
+ required: false,
2806
+ source: "query"
2807
+ }
2808
+ ],
2809
+ acceptsJsonBody: false,
2810
+ acceptsFile: false,
2811
+ bodyRequired: false
2812
+ },
2813
+ {
2814
+ trail: ["orders", "process-actions"],
2815
+ resourcePath: ["orders"],
2816
+ methodName: "processActions",
2817
+ httpMethod: "POST",
2818
+ path: "/api/v1/orders/actions",
2819
+ summary: "Process Order Actions",
2820
+ flags: [],
2821
+ acceptsJsonBody: true,
2822
+ acceptsFile: false,
2823
+ bodyRequired: true
2824
+ },
2825
+ {
2826
+ trail: ["orders", "get-action-jobs"],
2827
+ resourcePath: ["orders"],
2828
+ methodName: "getActionJobs",
2829
+ httpMethod: "GET",
2830
+ path: "/api/v1/orders/actions/jobs",
2831
+ summary: "Get Order Action Jobs",
2832
+ flags: [
2833
+ {
2834
+ name: "jobIds",
2835
+ flag: "job-ids",
2836
+ required: true,
2837
+ source: "query"
2838
+ },
2839
+ {
2840
+ name: "organizationId",
2841
+ flag: "organization-id",
2842
+ required: false,
2843
+ source: "query"
2844
+ }
2845
+ ],
2846
+ acceptsJsonBody: false,
2847
+ acceptsFile: false,
2848
+ bodyRequired: false
2849
+ },
2850
+ {
2851
+ trail: ["orders", "create-picking-list"],
2852
+ resourcePath: ["orders"],
2853
+ methodName: "createPickingList",
2854
+ httpMethod: "POST",
2855
+ path: "/api/v1/orders/picking-list",
2856
+ summary: "Create Picking List",
2857
+ flags: [],
2858
+ acceptsJsonBody: true,
2859
+ acceptsFile: false,
2860
+ bodyRequired: true
2861
+ },
2862
+ {
2863
+ trail: ["organizations", "create"],
2864
+ resourcePath: ["organizations"],
2865
+ methodName: "create",
2866
+ httpMethod: "POST",
2867
+ path: "/api/v1/organizations",
2868
+ summary: "Create Organization",
2869
+ flags: [],
2870
+ acceptsJsonBody: true,
2871
+ acceptsFile: false,
2872
+ bodyRequired: true
2873
+ },
2874
+ {
2875
+ trail: ["price-books", "list"],
2876
+ resourcePath: ["priceBooks"],
2877
+ methodName: "list",
2878
+ httpMethod: "GET",
2879
+ path: "/api/v1/price-books",
2880
+ summary: "List Price Book Rules",
2881
+ flags: [
2882
+ {
2883
+ name: "organizationId",
2884
+ flag: "organization-id",
2184
2885
  required: false,
2185
2886
  source: "query"
2186
2887
  },
@@ -2367,6 +3068,96 @@ var COMMANDS = [
2367
3068
  flag: "offset",
2368
3069
  required: false,
2369
3070
  source: "query"
3071
+ },
3072
+ {
3073
+ name: "store",
3074
+ flag: "store",
3075
+ required: false,
3076
+ source: "query"
3077
+ },
3078
+ {
3079
+ name: "storeKeys",
3080
+ flag: "store-keys",
3081
+ required: false,
3082
+ source: "query"
3083
+ },
3084
+ {
3085
+ name: "brands",
3086
+ flag: "brands",
3087
+ required: false,
3088
+ source: "query"
3089
+ },
3090
+ {
3091
+ name: "bundleType",
3092
+ flag: "bundle-type",
3093
+ required: false,
3094
+ source: "query"
3095
+ },
3096
+ {
3097
+ name: "language",
3098
+ flag: "language",
3099
+ required: false,
3100
+ source: "query"
3101
+ },
3102
+ {
3103
+ name: "hasImage",
3104
+ flag: "has-image",
3105
+ required: false,
3106
+ source: "query"
3107
+ },
3108
+ {
3109
+ name: "stock",
3110
+ flag: "stock",
3111
+ required: false,
3112
+ source: "query"
3113
+ },
3114
+ {
3115
+ name: "duplicateStatus",
3116
+ flag: "duplicate-status",
3117
+ required: false,
3118
+ source: "query"
3119
+ },
3120
+ {
3121
+ name: "duplicateType",
3122
+ flag: "duplicate-type",
3123
+ required: false,
3124
+ source: "query"
3125
+ },
3126
+ {
3127
+ name: "publishedFrom",
3128
+ flag: "published-from",
3129
+ required: false,
3130
+ source: "query"
3131
+ },
3132
+ {
3133
+ name: "publishedTo",
3134
+ flag: "published-to",
3135
+ required: false,
3136
+ source: "query"
3137
+ },
3138
+ {
3139
+ name: "publishedTimeZone",
3140
+ flag: "published-time-zone",
3141
+ required: false,
3142
+ source: "query"
3143
+ },
3144
+ {
3145
+ name: "cursor",
3146
+ flag: "cursor",
3147
+ required: false,
3148
+ source: "query"
3149
+ },
3150
+ {
3151
+ name: "includeSummary",
3152
+ flag: "include-summary",
3153
+ required: false,
3154
+ source: "query"
3155
+ },
3156
+ {
3157
+ name: "detail",
3158
+ flag: "detail",
3159
+ required: false,
3160
+ source: "query"
2370
3161
  }
2371
3162
  ],
2372
3163
  acceptsJsonBody: false,
@@ -2593,6 +3384,43 @@ var COMMANDS = [
2593
3384
  acceptsFile: false,
2594
3385
  bodyRequired: true
2595
3386
  },
3387
+ {
3388
+ trail: ["products", "get-bulk-import-retry"],
3389
+ resourcePath: ["products"],
3390
+ methodName: "getBulkImportRetry",
3391
+ httpMethod: "GET",
3392
+ path: "/api/v1/products/bulk-import/retries/{retryJobId}",
3393
+ summary: "Get Import Retry Progress",
3394
+ flags: [
3395
+ {
3396
+ name: "retryJobId",
3397
+ flag: "retry-job-id",
3398
+ required: true,
3399
+ source: "path"
3400
+ },
3401
+ {
3402
+ name: "organizationId",
3403
+ flag: "organization-id",
3404
+ required: false,
3405
+ source: "query"
3406
+ }
3407
+ ],
3408
+ acceptsJsonBody: false,
3409
+ acceptsFile: false,
3410
+ bodyRequired: false
3411
+ },
3412
+ {
3413
+ trail: ["products", "retry-bulk-import"],
3414
+ resourcePath: ["products"],
3415
+ methodName: "retryBulkImport",
3416
+ httpMethod: "POST",
3417
+ path: "/api/v1/products/bulk-import/retry",
3418
+ summary: "Retry Failed Import or Review Jobs",
3419
+ flags: [],
3420
+ acceptsJsonBody: true,
3421
+ acceptsFile: false,
3422
+ bodyRequired: true
3423
+ },
2596
3424
  {
2597
3425
  trail: ["products", "compare-prices"],
2598
3426
  resourcePath: ["products"],
@@ -2642,6 +3470,133 @@ var COMMANDS = [
2642
3470
  acceptsFile: false,
2643
3471
  bodyRequired: true
2644
3472
  },
3473
+ {
3474
+ trail: ["products", "count"],
3475
+ resourcePath: ["products"],
3476
+ methodName: "count",
3477
+ httpMethod: "GET",
3478
+ path: "/api/v1/products/count",
3479
+ summary: "Count Products",
3480
+ flags: [
3481
+ {
3482
+ name: "status",
3483
+ flag: "status",
3484
+ required: false,
3485
+ source: "query"
3486
+ },
3487
+ {
3488
+ name: "marketplace",
3489
+ flag: "marketplace",
3490
+ required: false,
3491
+ source: "query"
3492
+ },
3493
+ {
3494
+ name: "country",
3495
+ flag: "country",
3496
+ required: false,
3497
+ source: "query"
3498
+ },
3499
+ {
3500
+ name: "q",
3501
+ flag: "q",
3502
+ required: false,
3503
+ source: "query"
3504
+ },
3505
+ {
3506
+ name: "sku",
3507
+ flag: "sku",
3508
+ required: false,
3509
+ source: "query"
3510
+ },
3511
+ {
3512
+ name: "minPrice",
3513
+ flag: "min-price",
3514
+ required: false,
3515
+ source: "query"
3516
+ },
3517
+ {
3518
+ name: "maxPrice",
3519
+ flag: "max-price",
3520
+ required: false,
3521
+ source: "query"
3522
+ },
3523
+ {
3524
+ name: "store",
3525
+ flag: "store",
3526
+ required: false,
3527
+ source: "query"
3528
+ },
3529
+ {
3530
+ name: "storeKeys",
3531
+ flag: "store-keys",
3532
+ required: false,
3533
+ source: "query"
3534
+ },
3535
+ {
3536
+ name: "brands",
3537
+ flag: "brands",
3538
+ required: false,
3539
+ source: "query"
3540
+ },
3541
+ {
3542
+ name: "bundleType",
3543
+ flag: "bundle-type",
3544
+ required: false,
3545
+ source: "query"
3546
+ },
3547
+ {
3548
+ name: "language",
3549
+ flag: "language",
3550
+ required: false,
3551
+ source: "query"
3552
+ },
3553
+ {
3554
+ name: "hasImage",
3555
+ flag: "has-image",
3556
+ required: false,
3557
+ source: "query"
3558
+ },
3559
+ {
3560
+ name: "stock",
3561
+ flag: "stock",
3562
+ required: false,
3563
+ source: "query"
3564
+ },
3565
+ {
3566
+ name: "duplicateStatus",
3567
+ flag: "duplicate-status",
3568
+ required: false,
3569
+ source: "query"
3570
+ },
3571
+ {
3572
+ name: "duplicateType",
3573
+ flag: "duplicate-type",
3574
+ required: false,
3575
+ source: "query"
3576
+ },
3577
+ {
3578
+ name: "publishedFrom",
3579
+ flag: "published-from",
3580
+ required: false,
3581
+ source: "query"
3582
+ },
3583
+ {
3584
+ name: "publishedTo",
3585
+ flag: "published-to",
3586
+ required: false,
3587
+ source: "query"
3588
+ },
3589
+ {
3590
+ name: "publishedTimeZone",
3591
+ flag: "published-time-zone",
3592
+ required: false,
3593
+ source: "query"
3594
+ }
3595
+ ],
3596
+ acceptsJsonBody: false,
3597
+ acceptsFile: false,
3598
+ bodyRequired: false
3599
+ },
2645
3600
  {
2646
3601
  trail: ["products", "enrich"],
2647
3602
  resourcePath: ["products"],
@@ -2668,6 +3623,12 @@ var COMMANDS = [
2668
3623
  required: false,
2669
3624
  source: "query"
2670
3625
  },
3626
+ {
3627
+ name: "campaign",
3628
+ flag: "campaign",
3629
+ required: false,
3630
+ source: "query"
3631
+ },
2671
3632
  {
2672
3633
  name: "q",
2673
3634
  flag: "q",
@@ -2808,6 +3769,25 @@ var COMMANDS = [
2808
3769
  acceptsFile: false,
2809
3770
  bodyRequired: true
2810
3771
  },
3772
+ {
3773
+ trail: ["promotions", "preview"],
3774
+ resourcePath: ["promotions"],
3775
+ methodName: "preview",
3776
+ httpMethod: "POST",
3777
+ path: "/api/v1/promotions/{promotionId}/preview",
3778
+ summary: "Preview Promotion Prices",
3779
+ flags: [
3780
+ {
3781
+ name: "promotionId",
3782
+ flag: "promotion-id",
3783
+ required: true,
3784
+ source: "path"
3785
+ }
3786
+ ],
3787
+ acceptsJsonBody: true,
3788
+ acceptsFile: false,
3789
+ bodyRequired: true
3790
+ },
2811
3791
  {
2812
3792
  trail: ["promotions", "remove-products"],
2813
3793
  resourcePath: ["promotions"],
@@ -2908,6 +3888,122 @@ var COMMANDS = [
2908
3888
  acceptsFile: false,
2909
3889
  bodyRequired: true
2910
3890
  },
3891
+ {
3892
+ trail: ["promotions", "create-batch"],
3893
+ resourcePath: ["promotions"],
3894
+ methodName: "createBatch",
3895
+ httpMethod: "POST",
3896
+ path: "/api/v1/promotions/batch",
3897
+ summary: "Create Promotions with Products",
3898
+ flags: [],
3899
+ acceptsJsonBody: true,
3900
+ acceptsFile: false,
3901
+ bodyRequired: true
3902
+ },
3903
+ {
3904
+ trail: ["promotions", "get-campaign-options"],
3905
+ resourcePath: ["promotions"],
3906
+ methodName: "getCampaignOptions",
3907
+ httpMethod: "GET",
3908
+ path: "/api/v1/promotions/campaign-options",
3909
+ summary: "Find Promotion Campaigns",
3910
+ flags: [
3911
+ {
3912
+ name: "organizationId",
3913
+ flag: "organization-id",
3914
+ required: false,
3915
+ source: "query"
3916
+ },
3917
+ {
3918
+ name: "q",
3919
+ flag: "q",
3920
+ required: false,
3921
+ source: "query"
3922
+ }
3923
+ ],
3924
+ acceptsJsonBody: false,
3925
+ acceptsFile: false,
3926
+ bodyRequired: false
3927
+ },
3928
+ {
3929
+ trail: ["promotions", "get-capabilities"],
3930
+ resourcePath: ["promotions"],
3931
+ methodName: "getCapabilities",
3932
+ httpMethod: "GET",
3933
+ path: "/api/v1/promotions/capabilities",
3934
+ summary: "Get Promotion Marketplace Capabilities",
3935
+ flags: [
3936
+ {
3937
+ name: "organizationId",
3938
+ flag: "organization-id",
3939
+ required: false,
3940
+ source: "query"
3941
+ }
3942
+ ],
3943
+ acceptsJsonBody: false,
3944
+ acceptsFile: false,
3945
+ bodyRequired: false
3946
+ },
3947
+ {
3948
+ trail: ["promotions", "delete-batch"],
3949
+ resourcePath: ["promotions"],
3950
+ methodName: "deleteBatch",
3951
+ httpMethod: "POST",
3952
+ path: "/api/v1/promotions/delete",
3953
+ summary: "Delete Promotions",
3954
+ flags: [],
3955
+ acceptsJsonBody: true,
3956
+ acceptsFile: false,
3957
+ bodyRequired: true
3958
+ },
3959
+ {
3960
+ trail: ["promotions", "get-delivery"],
3961
+ resourcePath: ["promotions"],
3962
+ methodName: "getDelivery",
3963
+ httpMethod: "POST",
3964
+ path: "/api/v1/promotions/delivery",
3965
+ summary: "Read Promotion Delivery",
3966
+ flags: [],
3967
+ acceptsJsonBody: true,
3968
+ acceptsFile: false,
3969
+ bodyRequired: true
3970
+ },
3971
+ {
3972
+ trail: ["promotions", "get-product-options"],
3973
+ resourcePath: ["promotions"],
3974
+ methodName: "getProductOptions",
3975
+ httpMethod: "POST",
3976
+ path: "/api/v1/promotions/product-options",
3977
+ summary: "Find Eligible Promotion Products",
3978
+ flags: [],
3979
+ acceptsJsonBody: true,
3980
+ acceptsFile: false,
3981
+ bodyRequired: true
3982
+ },
3983
+ {
3984
+ trail: ["promotions", "set-statuses"],
3985
+ resourcePath: ["promotions"],
3986
+ methodName: "setStatuses",
3987
+ httpMethod: "POST",
3988
+ path: "/api/v1/promotions/status",
3989
+ summary: "Set Promotion Statuses",
3990
+ flags: [],
3991
+ acceptsJsonBody: true,
3992
+ acceptsFile: false,
3993
+ bodyRequired: true
3994
+ },
3995
+ {
3996
+ trail: ["promotions", "validate"],
3997
+ resourcePath: ["promotions"],
3998
+ methodName: "validate",
3999
+ httpMethod: "POST",
4000
+ path: "/api/v1/promotions/validate",
4001
+ summary: "Validate Promotions",
4002
+ flags: [],
4003
+ acceptsJsonBody: true,
4004
+ acceptsFile: false,
4005
+ bodyRequired: true
4006
+ },
2911
4007
  {
2912
4008
  trail: ["returns", "list"],
2913
4009
  resourcePath: ["returns"],
@@ -2947,14 +4043,101 @@ var COMMANDS = [
2947
4043
  source: "query"
2948
4044
  },
2949
4045
  {
2950
- name: "cursor",
2951
- flag: "cursor",
2952
- required: false,
4046
+ name: "cursor",
4047
+ flag: "cursor",
4048
+ required: false,
4049
+ source: "query"
4050
+ },
4051
+ {
4052
+ name: "limit",
4053
+ flag: "limit",
4054
+ required: false,
4055
+ source: "query"
4056
+ }
4057
+ ],
4058
+ acceptsJsonBody: false,
4059
+ acceptsFile: false,
4060
+ bodyRequired: false
4061
+ },
4062
+ {
4063
+ trail: ["returns", "get"],
4064
+ resourcePath: ["returns"],
4065
+ methodName: "get",
4066
+ httpMethod: "GET",
4067
+ path: "/api/v1/returns/{returnId}",
4068
+ summary: "Get Return",
4069
+ flags: [
4070
+ {
4071
+ name: "returnId",
4072
+ flag: "return-id",
4073
+ required: true,
4074
+ source: "path"
4075
+ },
4076
+ {
4077
+ name: "organizationId",
4078
+ flag: "organization-id",
4079
+ required: false,
4080
+ source: "query"
4081
+ }
4082
+ ],
4083
+ acceptsJsonBody: false,
4084
+ acceptsFile: false,
4085
+ bodyRequired: false
4086
+ },
4087
+ {
4088
+ trail: ["returns", "list-actions"],
4089
+ resourcePath: ["returns"],
4090
+ methodName: "listActions",
4091
+ httpMethod: "GET",
4092
+ path: "/api/v1/returns/actions",
4093
+ summary: "Check Return Actions",
4094
+ flags: [
4095
+ {
4096
+ name: "returnIds",
4097
+ flag: "return-ids",
4098
+ required: true,
4099
+ source: "query"
4100
+ },
4101
+ {
4102
+ name: "organizationId",
4103
+ flag: "organization-id",
4104
+ required: false,
4105
+ source: "query"
4106
+ }
4107
+ ],
4108
+ acceptsJsonBody: false,
4109
+ acceptsFile: false,
4110
+ bodyRequired: false
4111
+ },
4112
+ {
4113
+ trail: ["returns", "process"],
4114
+ resourcePath: ["returns"],
4115
+ methodName: "process",
4116
+ httpMethod: "POST",
4117
+ path: "/api/v1/returns/actions",
4118
+ summary: "Process Returns",
4119
+ flags: [],
4120
+ acceptsJsonBody: true,
4121
+ acceptsFile: false,
4122
+ bodyRequired: true
4123
+ },
4124
+ {
4125
+ trail: ["returns", "get-action-jobs"],
4126
+ resourcePath: ["returns"],
4127
+ methodName: "getActionJobs",
4128
+ httpMethod: "GET",
4129
+ path: "/api/v1/returns/actions/jobs",
4130
+ summary: "Get Return Action Jobs",
4131
+ flags: [
4132
+ {
4133
+ name: "jobIds",
4134
+ flag: "job-ids",
4135
+ required: true,
2953
4136
  source: "query"
2954
4137
  },
2955
4138
  {
2956
- name: "limit",
2957
- flag: "limit",
4139
+ name: "organizationId",
4140
+ flag: "organization-id",
2958
4141
  required: false,
2959
4142
  source: "query"
2960
4143
  }
@@ -2964,18 +4147,18 @@ var COMMANDS = [
2964
4147
  bodyRequired: false
2965
4148
  },
2966
4149
  {
2967
- trail: ["returns", "get"],
4150
+ trail: ["returns", "list-for-orders"],
2968
4151
  resourcePath: ["returns"],
2969
- methodName: "get",
4152
+ methodName: "listForOrders",
2970
4153
  httpMethod: "GET",
2971
- path: "/api/v1/returns/{returnId}",
2972
- summary: "Get Return",
4154
+ path: "/api/v1/returns/orders",
4155
+ summary: "Get Order Returns",
2973
4156
  flags: [
2974
4157
  {
2975
- name: "returnId",
2976
- flag: "return-id",
4158
+ name: "orderIds",
4159
+ flag: "order-ids",
2977
4160
  required: true,
2978
- source: "path"
4161
+ source: "query"
2979
4162
  },
2980
4163
  {
2981
4164
  name: "organizationId",
@@ -3105,6 +4288,255 @@ var COMMANDS = [
3105
4288
  acceptsFile: false,
3106
4289
  bodyRequired: true
3107
4290
  },
4291
+ {
4292
+ trail: ["scripts", "list"],
4293
+ resourcePath: ["scripts"],
4294
+ methodName: "list",
4295
+ httpMethod: "GET",
4296
+ path: "/api/v1/scripts",
4297
+ summary: "List Organization Scripts",
4298
+ flags: [
4299
+ {
4300
+ name: "organizationId",
4301
+ flag: "organization-id",
4302
+ required: false,
4303
+ source: "query"
4304
+ },
4305
+ {
4306
+ name: "q",
4307
+ flag: "q",
4308
+ required: false,
4309
+ source: "query"
4310
+ },
4311
+ {
4312
+ name: "status",
4313
+ flag: "status",
4314
+ required: false,
4315
+ source: "query"
4316
+ }
4317
+ ],
4318
+ acceptsJsonBody: false,
4319
+ acceptsFile: false,
4320
+ bodyRequired: false
4321
+ },
4322
+ {
4323
+ trail: ["scripts", "create"],
4324
+ resourcePath: ["scripts"],
4325
+ methodName: "create",
4326
+ httpMethod: "POST",
4327
+ path: "/api/v1/scripts",
4328
+ summary: "Create Script",
4329
+ flags: [],
4330
+ acceptsJsonBody: true,
4331
+ acceptsFile: false,
4332
+ bodyRequired: true
4333
+ },
4334
+ {
4335
+ trail: ["scripts", "archive"],
4336
+ resourcePath: ["scripts"],
4337
+ methodName: "archive",
4338
+ httpMethod: "DELETE",
4339
+ path: "/api/v1/scripts/{scriptId}",
4340
+ summary: "Archive Script",
4341
+ flags: [
4342
+ {
4343
+ name: "scriptId",
4344
+ flag: "script-id",
4345
+ required: true,
4346
+ source: "path"
4347
+ },
4348
+ {
4349
+ name: "organizationId",
4350
+ flag: "organization-id",
4351
+ required: false,
4352
+ source: "query"
4353
+ }
4354
+ ],
4355
+ acceptsJsonBody: false,
4356
+ acceptsFile: false,
4357
+ bodyRequired: false
4358
+ },
4359
+ {
4360
+ trail: ["scripts", "get"],
4361
+ resourcePath: ["scripts"],
4362
+ methodName: "get",
4363
+ httpMethod: "GET",
4364
+ path: "/api/v1/scripts/{scriptId}",
4365
+ summary: "Get Script",
4366
+ flags: [
4367
+ {
4368
+ name: "scriptId",
4369
+ flag: "script-id",
4370
+ required: true,
4371
+ source: "path"
4372
+ },
4373
+ {
4374
+ name: "organizationId",
4375
+ flag: "organization-id",
4376
+ required: false,
4377
+ source: "query"
4378
+ }
4379
+ ],
4380
+ acceptsJsonBody: false,
4381
+ acceptsFile: false,
4382
+ bodyRequired: false
4383
+ },
4384
+ {
4385
+ trail: ["scripts", "update"],
4386
+ resourcePath: ["scripts"],
4387
+ methodName: "update",
4388
+ httpMethod: "PATCH",
4389
+ path: "/api/v1/scripts/{scriptId}",
4390
+ summary: "Update Script",
4391
+ flags: [
4392
+ {
4393
+ name: "scriptId",
4394
+ flag: "script-id",
4395
+ required: true,
4396
+ source: "path"
4397
+ }
4398
+ ],
4399
+ acceptsJsonBody: true,
4400
+ acceptsFile: false,
4401
+ bodyRequired: true
4402
+ },
4403
+ {
4404
+ trail: ["scripts", "activate"],
4405
+ resourcePath: ["scripts"],
4406
+ methodName: "activate",
4407
+ httpMethod: "POST",
4408
+ path: "/api/v1/scripts/{scriptId}/activate",
4409
+ summary: "Activate Script Version",
4410
+ flags: [
4411
+ {
4412
+ name: "scriptId",
4413
+ flag: "script-id",
4414
+ required: true,
4415
+ source: "path"
4416
+ }
4417
+ ],
4418
+ acceptsJsonBody: true,
4419
+ acceptsFile: false,
4420
+ bodyRequired: true
4421
+ },
4422
+ {
4423
+ trail: ["scripts", "deploy"],
4424
+ resourcePath: ["scripts"],
4425
+ methodName: "deploy",
4426
+ httpMethod: "POST",
4427
+ path: "/api/v1/scripts/{scriptId}/deploy",
4428
+ summary: "Deploy Script",
4429
+ flags: [
4430
+ {
4431
+ name: "scriptId",
4432
+ flag: "script-id",
4433
+ required: true,
4434
+ source: "path"
4435
+ }
4436
+ ],
4437
+ acceptsJsonBody: true,
4438
+ acceptsFile: false,
4439
+ bodyRequired: true
4440
+ },
4441
+ {
4442
+ trail: ["scripts", "list-runs"],
4443
+ resourcePath: ["scripts"],
4444
+ methodName: "listRuns",
4445
+ httpMethod: "GET",
4446
+ path: "/api/v1/scripts/{scriptId}/runs",
4447
+ summary: "List Script Runs",
4448
+ flags: [
4449
+ {
4450
+ name: "scriptId",
4451
+ flag: "script-id",
4452
+ required: true,
4453
+ source: "path"
4454
+ },
4455
+ {
4456
+ name: "organizationId",
4457
+ flag: "organization-id",
4458
+ required: false,
4459
+ source: "query"
4460
+ },
4461
+ {
4462
+ name: "limit",
4463
+ flag: "limit",
4464
+ required: false,
4465
+ source: "query"
4466
+ }
4467
+ ],
4468
+ acceptsJsonBody: false,
4469
+ acceptsFile: false,
4470
+ bodyRequired: false
4471
+ },
4472
+ {
4473
+ trail: ["scripts", "execute"],
4474
+ resourcePath: ["scripts"],
4475
+ methodName: "execute",
4476
+ httpMethod: "POST",
4477
+ path: "/api/v1/scripts/{scriptId}/runs",
4478
+ summary: "Execute Script",
4479
+ flags: [
4480
+ {
4481
+ name: "scriptId",
4482
+ flag: "script-id",
4483
+ required: true,
4484
+ source: "path"
4485
+ }
4486
+ ],
4487
+ acceptsJsonBody: true,
4488
+ acceptsFile: false,
4489
+ bodyRequired: true
4490
+ },
4491
+ {
4492
+ trail: ["scripts", "get-source"],
4493
+ resourcePath: ["scripts"],
4494
+ methodName: "getSource",
4495
+ httpMethod: "GET",
4496
+ path: "/api/v1/scripts/{scriptId}/source",
4497
+ summary: "Get Script Source",
4498
+ flags: [
4499
+ {
4500
+ name: "scriptId",
4501
+ flag: "script-id",
4502
+ required: true,
4503
+ source: "path"
4504
+ },
4505
+ {
4506
+ name: "organizationId",
4507
+ flag: "organization-id",
4508
+ required: false,
4509
+ source: "query"
4510
+ }
4511
+ ],
4512
+ acceptsJsonBody: false,
4513
+ acceptsFile: false,
4514
+ bodyRequired: false
4515
+ },
4516
+ {
4517
+ trail: ["scripts", "await-runs"],
4518
+ resourcePath: ["scripts"],
4519
+ methodName: "awaitRuns",
4520
+ httpMethod: "POST",
4521
+ path: "/api/v1/scripts/jobs/await",
4522
+ summary: "Read Script Run Results",
4523
+ flags: [],
4524
+ acceptsJsonBody: true,
4525
+ acceptsFile: false,
4526
+ bodyRequired: true
4527
+ },
4528
+ {
4529
+ trail: ["scripts", "cancel-runs"],
4530
+ resourcePath: ["scripts"],
4531
+ methodName: "cancelRuns",
4532
+ httpMethod: "POST",
4533
+ path: "/api/v1/scripts/jobs/cancel",
4534
+ summary: "Cancel Script Runs",
4535
+ flags: [],
4536
+ acceptsJsonBody: true,
4537
+ acceptsFile: false,
4538
+ bodyRequired: true
4539
+ },
3108
4540
  {
3109
4541
  trail: ["search", "list"],
3110
4542
  resourcePath: ["search"],
@@ -3805,16 +5237,1070 @@ var COMMANDS = [
3805
5237
  }
3806
5238
  ];
3807
5239
 
5240
+ // src/generated/campaign-inputs.ts
5241
+ var CAMPAIGN_INPUTS = {
5242
+ patch: {
5243
+ type: "object",
5244
+ properties: {
5245
+ expectedRevision: {
5246
+ type: "integer",
5247
+ exclusiveMinimum: 0,
5248
+ maximum: 9007199254740991
5249
+ },
5250
+ name: {
5251
+ type: "string",
5252
+ minLength: 2,
5253
+ maxLength: 160
5254
+ },
5255
+ objective: {
5256
+ type: "string",
5257
+ maxLength: 8e3
5258
+ },
5259
+ brand: {
5260
+ type: "string",
5261
+ maxLength: 160
5262
+ },
5263
+ ownerId: {
5264
+ type: "string",
5265
+ minLength: 1,
5266
+ maxLength: 160,
5267
+ description: "Organization member ID or eligible oauth:<clientId> actor from campaign options."
5268
+ },
5269
+ approverId: {
5270
+ type: "string",
5271
+ minLength: 1,
5272
+ maxLength: 160,
5273
+ 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."
5274
+ },
5275
+ timezone: {
5276
+ type: "string"
5277
+ },
5278
+ stores: {
5279
+ maxItems: 100,
5280
+ type: "array",
5281
+ items: {
5282
+ type: "object",
5283
+ properties: {
5284
+ marketplace: {
5285
+ type: "string",
5286
+ enum: [
5287
+ "shopee",
5288
+ "lazada",
5289
+ "tiktok",
5290
+ "shopify",
5291
+ "whatsapp",
5292
+ "zalora",
5293
+ "amazon",
5294
+ "ebay"
5295
+ ]
5296
+ },
5297
+ country: {
5298
+ type: "string",
5299
+ minLength: 1,
5300
+ maxLength: 80
5301
+ },
5302
+ storeId: {
5303
+ type: "string",
5304
+ minLength: 1,
5305
+ maxLength: 160
5306
+ }
5307
+ },
5308
+ required: ["marketplace", "country", "storeId"],
5309
+ additionalProperties: false
5310
+ }
5311
+ },
5312
+ serviceRequest: {
5313
+ type: "string",
5314
+ maxLength: 300
5315
+ },
5316
+ priority: {
5317
+ type: "string",
5318
+ enum: ["standard", "priority", "super_priority"]
5319
+ },
5320
+ documentIds: {
5321
+ maxItems: 100,
5322
+ type: "array",
5323
+ items: {
5324
+ type: "string",
5325
+ minLength: 1,
5326
+ maxLength: 160
5327
+ }
5328
+ },
5329
+ reviewDueAt: {
5330
+ anyOf: [
5331
+ {
5332
+ type: "string",
5333
+ format: "date-time",
5334
+ 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)))$"
5335
+ },
5336
+ {
5337
+ type: "null"
5338
+ }
5339
+ ]
5340
+ },
5341
+ sourceCurrency: {
5342
+ type: "string",
5343
+ pattern: "^[A-Z]{3}$"
5344
+ },
5345
+ sourceMarketplace: {
5346
+ type: "string",
5347
+ enum: [
5348
+ "shopee",
5349
+ "lazada",
5350
+ "tiktok",
5351
+ "shopify",
5352
+ "whatsapp",
5353
+ "zalora",
5354
+ "amazon",
5355
+ "ebay"
5356
+ ]
5357
+ },
5358
+ sourceCountry: {
5359
+ type: "string",
5360
+ maxLength: 80
5361
+ },
5362
+ syncMode: {
5363
+ type: "string",
5364
+ enum: ["offer_windows", "campaign_start"]
5365
+ },
5366
+ cleanupNotes: {
5367
+ type: "string",
5368
+ maxLength: 8e3
5369
+ },
5370
+ offers: {
5371
+ 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.",
5372
+ maxItems: 500,
5373
+ type: "array",
5374
+ items: {
5375
+ type: "object",
5376
+ properties: {
5377
+ id: {
5378
+ type: "string",
5379
+ minLength: 1,
5380
+ maxLength: 160
5381
+ },
5382
+ windowId: {
5383
+ type: "string",
5384
+ minLength: 1,
5385
+ maxLength: 160
5386
+ },
5387
+ promotionId: {
5388
+ description: "Existing draft promotion attached to this window; the campaign controls its live dates.",
5389
+ type: "string",
5390
+ format: "uuid",
5391
+ 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)$"
5392
+ },
5393
+ productIds: {
5394
+ maxItems: 200,
5395
+ type: "array",
5396
+ items: {
5397
+ type: "string",
5398
+ format: "uuid",
5399
+ 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)$"
5400
+ }
5401
+ },
5402
+ reviewNotes: {
5403
+ type: "string",
5404
+ maxLength: 8e3
5405
+ },
5406
+ excludedReason: {
5407
+ type: "string",
5408
+ maxLength: 2e3
5409
+ },
5410
+ name: {
5411
+ type: "string",
5412
+ minLength: 1,
5413
+ maxLength: 200
5414
+ },
5415
+ description: {
5416
+ anyOf: [
5417
+ {
5418
+ type: "string",
5419
+ maxLength: 2e3
5420
+ },
5421
+ {
5422
+ type: "null"
5423
+ }
5424
+ ]
5425
+ },
5426
+ kind: {
5427
+ 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.",
5428
+ type: "string",
5429
+ enum: [
5430
+ "product_discount",
5431
+ "flash_sale",
5432
+ "voucher",
5433
+ "gift_with_purchase",
5434
+ "buy_x_get_y",
5435
+ "bundle_deal",
5436
+ "free_shipping",
5437
+ "early_bird_price"
5438
+ ]
5439
+ },
5440
+ salesChannels: {
5441
+ minItems: 1,
5442
+ type: "array",
5443
+ items: {
5444
+ type: "string",
5445
+ enum: ["pdp", "live"]
5446
+ }
5447
+ },
5448
+ discountType: {
5449
+ type: "string",
5450
+ enum: ["percentage", "fixed_amount"]
5451
+ },
5452
+ discountValue: {
5453
+ type: "number",
5454
+ minimum: 0
5455
+ },
5456
+ storeDiscounts: {
5457
+ description: "Patch discount terms for exact target store keys; unnamed stores remain unchanged. Null discountValue restores shared campaign terms for that store.",
5458
+ maxItems: 100,
5459
+ type: "array",
5460
+ items: {
5461
+ type: "object",
5462
+ properties: {
5463
+ storeKey: {
5464
+ type: "string",
5465
+ minLength: 1,
5466
+ maxLength: 255
5467
+ },
5468
+ discountType: {
5469
+ type: "string",
5470
+ enum: ["percentage", "fixed_amount"]
5471
+ },
5472
+ discountValue: {
5473
+ anyOf: [
5474
+ {
5475
+ type: "number",
5476
+ minimum: 0
5477
+ },
5478
+ {
5479
+ type: "null"
5480
+ }
5481
+ ]
5482
+ }
5483
+ },
5484
+ required: ["storeKey", "discountType", "discountValue"],
5485
+ additionalProperties: false
5486
+ }
5487
+ },
5488
+ targetStores: {
5489
+ 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.",
5490
+ minItems: 1,
5491
+ maxItems: 100,
5492
+ type: "array",
5493
+ items: {
5494
+ type: "object",
5495
+ properties: {
5496
+ marketplace: {
5497
+ type: "string",
5498
+ enum: [
5499
+ "lazada",
5500
+ "shopee",
5501
+ "tiktok",
5502
+ "shopify",
5503
+ "amazon",
5504
+ "zalora",
5505
+ "ebay"
5506
+ ]
5507
+ },
5508
+ country: {
5509
+ type: "string",
5510
+ minLength: 1,
5511
+ maxLength: 80
5512
+ },
5513
+ storeId: {
5514
+ type: "string",
5515
+ minLength: 1,
5516
+ maxLength: 120
5517
+ }
5518
+ },
5519
+ required: ["marketplace", "country", "storeId"],
5520
+ additionalProperties: false
5521
+ }
5522
+ },
5523
+ minSalePrice: {
5524
+ anyOf: [
5525
+ {
5526
+ type: "number",
5527
+ minimum: 0
5528
+ },
5529
+ {
5530
+ type: "null"
5531
+ }
5532
+ ]
5533
+ },
5534
+ maxDiscountAmount: {
5535
+ anyOf: [
5536
+ {
5537
+ type: "number",
5538
+ minimum: 0
5539
+ },
5540
+ {
5541
+ type: "null"
5542
+ }
5543
+ ]
5544
+ },
5545
+ minSpend: {
5546
+ anyOf: [
5547
+ {
5548
+ type: "number",
5549
+ minimum: 0
5550
+ },
5551
+ {
5552
+ type: "null"
5553
+ }
5554
+ ]
5555
+ },
5556
+ voucherCode: {
5557
+ anyOf: [
5558
+ {
5559
+ type: "string",
5560
+ minLength: 1,
5561
+ maxLength: 100
5562
+ },
5563
+ {
5564
+ type: "null"
5565
+ }
5566
+ ]
5567
+ },
5568
+ claimStartsAt: {
5569
+ anyOf: [
5570
+ {
5571
+ type: "string",
5572
+ format: "date-time",
5573
+ 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)))$"
5574
+ },
5575
+ {
5576
+ type: "null"
5577
+ }
5578
+ ]
5579
+ },
5580
+ totalUsageLimit: {
5581
+ anyOf: [
5582
+ {
5583
+ type: "integer",
5584
+ exclusiveMinimum: 0,
5585
+ maximum: 9007199254740991
5586
+ },
5587
+ {
5588
+ type: "null"
5589
+ }
5590
+ ]
5591
+ },
5592
+ perBuyerLimit: {
5593
+ anyOf: [
5594
+ {
5595
+ type: "integer",
5596
+ exclusiveMinimum: 0,
5597
+ maximum: 9007199254740991
5598
+ },
5599
+ {
5600
+ type: "null"
5601
+ }
5602
+ ]
5603
+ },
5604
+ voucherType: {
5605
+ 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.",
5606
+ anyOf: [
5607
+ {
5608
+ type: "string",
5609
+ enum: [
5610
+ "shopee_shop",
5611
+ "shopee_product",
5612
+ "shopee_private",
5613
+ "shopee_live",
5614
+ "shopee_video",
5615
+ "shopee_new_buyer",
5616
+ "shopee_repeat_buyer",
5617
+ "shopee_campaign",
5618
+ "shopee_follow_prize",
5619
+ "shopee_exclusive_streamer",
5620
+ "shopee_welcome",
5621
+ "shopee_member_repeat_buyer",
5622
+ "shopee_exclusive",
5623
+ "shopee_redemption",
5624
+ "shopee_exclusive_creator",
5625
+ "lazada_store_follower",
5626
+ "lazada_regular",
5627
+ "lazada_store_new_buyer",
5628
+ "lazada_live",
5629
+ "lazada_offline",
5630
+ "lazada_co_funded",
5631
+ "lazada_welcome",
5632
+ "lazada_linked_member",
5633
+ "lazada_new_member",
5634
+ "lazada_member_exclusive",
5635
+ "lazada_points_redeemable",
5636
+ "tiktok_seller_coupon",
5637
+ "shopify_discount_code",
5638
+ "amazon_promotion_code",
5639
+ "zalora_seller_voucher",
5640
+ "ebay_coded_coupon"
5641
+ ]
5642
+ },
5643
+ {
5644
+ type: "null"
5645
+ }
5646
+ ]
5647
+ },
5648
+ voucherCampaign: {
5649
+ 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.",
5650
+ type: "object",
5651
+ properties: {
5652
+ campaignId: {
5653
+ type: "string",
5654
+ pattern: "^[1-9]\\d{0,39}$"
5655
+ },
5656
+ sessionId: {
5657
+ type: "string",
5658
+ pattern: "^[1-9]\\d{0,39}$"
5659
+ },
5660
+ termsAccepted: {
5661
+ type: "boolean"
5662
+ }
5663
+ },
5664
+ required: ["campaignId", "sessionId", "termsAccepted"],
5665
+ additionalProperties: false
5666
+ },
5667
+ browserAutomation: {
5668
+ anyOf: [
5669
+ {
5670
+ type: "object",
5671
+ properties: {
5672
+ aopId: {
5673
+ type: "string",
5674
+ minLength: 1,
5675
+ maxLength: 160
5676
+ },
5677
+ variableValues: {
5678
+ type: "object",
5679
+ propertyNames: {
5680
+ type: "string",
5681
+ minLength: 1,
5682
+ maxLength: 160
5683
+ },
5684
+ additionalProperties: {
5685
+ type: "string",
5686
+ maxLength: 8e3
5687
+ }
5688
+ },
5689
+ instructions: {
5690
+ type: "string",
5691
+ maxLength: 8e3
5692
+ }
5693
+ },
5694
+ additionalProperties: false
5695
+ },
5696
+ {
5697
+ type: "null"
5698
+ }
5699
+ ]
5700
+ },
5701
+ voucherScope: {
5702
+ description: "shop = all products, products = selected assigned products. Repeat Buyer defaults to shop.",
5703
+ type: "string",
5704
+ enum: ["products", "shop"]
5705
+ },
5706
+ voucherReward: {
5707
+ description: "Seller Center reward type. coins_cashback is a percentage greater than 3 and does not reduce salePrice.",
5708
+ type: "string",
5709
+ enum: ["discount", "coins_cashback"]
5710
+ },
5711
+ voucherAudience: {
5712
+ type: "string",
5713
+ enum: ["general", "shop_follow"]
5714
+ },
5715
+ repeatPurchaseMinCount: {
5716
+ description: "Shopee Repeat Buyer: minimum completed shop orders, 1 or 2. Required for shopee_repeat_buyer.",
5717
+ type: "integer",
5718
+ minimum: 1,
5719
+ maximum: 999
5720
+ },
5721
+ repeatPurchaseLookbackDays: {
5722
+ description: "Shopee Repeat Buyer: lookback window in days, one of 30, 90, 180 or 365. Required for shopee_repeat_buyer.",
5723
+ type: "integer",
5724
+ minimum: 1,
5725
+ maximum: 365
5726
+ },
5727
+ smartVoucher: {
5728
+ description: "Shopee Smart Voucher toggle. Used by New Buyer and similar portal types.",
5729
+ type: "boolean"
5730
+ },
5731
+ followPrizeExpiryDays: {
5732
+ description: "Shopee Follow Prize: days after claim until expiry. Seller Center is 7.",
5733
+ type: "integer",
5734
+ minimum: 1,
5735
+ maximum: 30
5736
+ },
5737
+ videoDisplayMode: {
5738
+ description: "Shopee Video display: shopee_video = all Shopee Video; creator_video = targeted creator videos only.",
5739
+ type: "string",
5740
+ enum: ["shopee_video", "creator_video"]
5741
+ },
5742
+ exclusiveCreatorUsernames: {
5743
+ description: "Exclusive Creator Voucher: up to 15 Shopee usernames.",
5744
+ maxItems: 15,
5745
+ type: "array",
5746
+ items: {
5747
+ type: "string",
5748
+ minLength: 1,
5749
+ maxLength: 64
5750
+ }
5751
+ },
5752
+ exclusiveStreamerUsernames: {
5753
+ description: "Exclusive Streamer Voucher: up to 15 Shopee usernames.",
5754
+ maxItems: 15,
5755
+ type: "array",
5756
+ items: {
5757
+ type: "string",
5758
+ minLength: 1,
5759
+ maxLength: 64
5760
+ }
5761
+ },
5762
+ voucherDisplayChannels: {
5763
+ description: 'Shopee display setting. ["all"] = display on all pages; [] = hidden/share by code.',
5764
+ maxItems: 4,
5765
+ type: "array",
5766
+ items: {
5767
+ type: "string",
5768
+ enum: [
5769
+ "all",
5770
+ "feed",
5771
+ "live",
5772
+ "order_page",
5773
+ "followers",
5774
+ "offline"
5775
+ ]
5776
+ }
5777
+ },
5778
+ bundlePriceType: {
5779
+ type: "string",
5780
+ enum: ["discount", "fixed_price"]
5781
+ },
5782
+ bundleTiers: {
5783
+ maxItems: 2,
5784
+ type: "array",
5785
+ items: {
5786
+ type: "object",
5787
+ properties: {
5788
+ minimumQuantity: {
5789
+ type: "integer",
5790
+ minimum: 2,
5791
+ maximum: 3e3
5792
+ },
5793
+ discountValue: {
5794
+ type: "number",
5795
+ exclusiveMinimum: 0
5796
+ }
5797
+ },
5798
+ required: ["minimumQuantity", "discountValue"]
5799
+ }
5800
+ },
5801
+ thresholdType: {
5802
+ type: "string",
5803
+ enum: ["item_quantity", "order_amount"]
5804
+ },
5805
+ thresholdValue: {
5806
+ type: "number",
5807
+ exclusiveMinimum: 0
5808
+ },
5809
+ giftType: {
5810
+ type: "string",
5811
+ enum: ["gift", "sample"]
5812
+ },
5813
+ giftQuantity: {
5814
+ type: "integer",
5815
+ exclusiveMinimum: 0,
5816
+ maximum: 999
5817
+ },
5818
+ gifts: {
5819
+ minItems: 1,
5820
+ maxItems: 20,
5821
+ type: "array",
5822
+ items: {
5823
+ type: "object",
5824
+ properties: {
5825
+ productId: {
5826
+ type: "string",
5827
+ format: "uuid",
5828
+ 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)$"
5829
+ },
5830
+ variantId: {
5831
+ anyOf: [
5832
+ {
5833
+ type: "string",
5834
+ format: "uuid",
5835
+ 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)$"
5836
+ },
5837
+ {
5838
+ type: "null"
5839
+ }
5840
+ ]
5841
+ },
5842
+ totalClaimLimit: {
5843
+ type: "integer",
5844
+ minimum: 1,
5845
+ maximum: 99999
5846
+ }
5847
+ },
5848
+ required: ["productId", "totalClaimLimit"],
5849
+ additionalProperties: false
5850
+ }
5851
+ },
5852
+ buyQuantity: {
5853
+ type: "integer",
5854
+ exclusiveMinimum: 0,
5855
+ maximum: 999
5856
+ },
5857
+ getQuantity: {
5858
+ type: "integer",
5859
+ exclusiveMinimum: 0,
5860
+ maximum: 999
5861
+ },
5862
+ benefitProductIds: {
5863
+ minItems: 1,
5864
+ maxItems: 200,
5865
+ type: "array",
5866
+ items: {
5867
+ type: "string",
5868
+ format: "uuid",
5869
+ 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)$"
5870
+ }
5871
+ },
5872
+ benefitType: {
5873
+ type: "string",
5874
+ enum: ["free", "percentage", "fixed_amount"]
5875
+ },
5876
+ benefitValue: {
5877
+ type: "number",
5878
+ minimum: 0
5879
+ },
5880
+ maxApplicationsPerOrder: {
5881
+ type: "integer",
5882
+ exclusiveMinimum: 0,
5883
+ maximum: 999
5884
+ },
5885
+ bundleMinimumQuantity: {
5886
+ type: "integer",
5887
+ minimum: 2,
5888
+ maximum: 3e3
5889
+ },
5890
+ shippingDeliveryOption: {
5891
+ description: "Free shipping delivery option. Lazada: STANDARD (default), ECONOMY, EXPRESS, SELLER_OWN_FLEET or P2P, as offered by the store.",
5892
+ type: "string",
5893
+ pattern: "^[A-Z0-9_]{1,40}$"
5894
+ },
5895
+ shippingBudget: {
5896
+ description: "Free shipping: total shipping subsidy budget in the store currency. Omit for an unlimited budget.",
5897
+ type: "number",
5898
+ exclusiveMinimum: 0
5899
+ }
5900
+ },
5901
+ required: ["id"],
5902
+ additionalProperties: false
5903
+ }
5904
+ },
5905
+ windows: {
5906
+ 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.",
5907
+ maxItems: 100,
5908
+ type: "array",
5909
+ items: {
5910
+ type: "object",
5911
+ properties: {
5912
+ id: {
5913
+ type: "string",
5914
+ minLength: 1,
5915
+ maxLength: 160
5916
+ },
5917
+ name: {
5918
+ type: "string",
5919
+ minLength: 1,
5920
+ maxLength: 160
5921
+ },
5922
+ startsAt: {
5923
+ anyOf: [
5924
+ {
5925
+ type: "string",
5926
+ format: "date-time",
5927
+ 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)))$"
5928
+ },
5929
+ {
5930
+ type: "null"
5931
+ }
5932
+ ]
5933
+ },
5934
+ endsAt: {
5935
+ anyOf: [
5936
+ {
5937
+ type: "string",
5938
+ format: "date-time",
5939
+ 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)))$"
5940
+ },
5941
+ {
5942
+ type: "null"
5943
+ }
5944
+ ]
5945
+ },
5946
+ preparesAt: {
5947
+ anyOf: [
5948
+ {
5949
+ type: "string",
5950
+ format: "date-time",
5951
+ 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)))$"
5952
+ },
5953
+ {
5954
+ type: "null"
5955
+ }
5956
+ ]
5957
+ },
5958
+ reviewNotes: {
5959
+ type: "string",
5960
+ maxLength: 8e3
5961
+ }
5962
+ },
5963
+ required: ["id"],
5964
+ additionalProperties: false
5965
+ }
5966
+ },
5967
+ removeWindowIds: {
5968
+ description: "Delete these windows. Move or remove their promotions in the same call. Maximum 100 IDs.",
5969
+ maxItems: 100,
5970
+ type: "array",
5971
+ items: {
5972
+ type: "string",
5973
+ minLength: 1,
5974
+ maxLength: 160
5975
+ }
5976
+ },
5977
+ removeOfferIds: {
5978
+ description: "Delete these draft promotion offers. Maximum 500 IDs.",
5979
+ maxItems: 500,
5980
+ type: "array",
5981
+ items: {
5982
+ type: "string",
5983
+ minLength: 1,
5984
+ maxLength: 160
5985
+ }
5986
+ },
5987
+ organizationId: {
5988
+ description: "Required for session auth. Optional for an API key, which already identifies the organization.",
5989
+ type: "string",
5990
+ minLength: 1,
5991
+ maxLength: 120
5992
+ },
5993
+ expectedPendingVersion: {
5994
+ anyOf: [
5995
+ {
5996
+ type: "integer",
5997
+ exclusiveMinimum: 0,
5998
+ maximum: 9007199254740991
5999
+ },
6000
+ {
6001
+ type: "null"
6002
+ }
6003
+ ]
6004
+ }
6005
+ },
6006
+ required: ["expectedRevision"],
6007
+ additionalProperties: false
6008
+ },
6009
+ action: {
6010
+ type: "object",
6011
+ properties: {
6012
+ action: {
6013
+ type: "string",
6014
+ enum: [
6015
+ "approve",
6016
+ "run",
6017
+ "approve_and_run",
6018
+ "end",
6019
+ "resume",
6020
+ "retry",
6021
+ "approve_change",
6022
+ "discard_change"
6023
+ ]
6024
+ },
6025
+ expectedRevision: {
6026
+ type: "integer",
6027
+ exclusiveMinimum: 0,
6028
+ maximum: 9007199254740991
6029
+ },
6030
+ expectedPendingVersion: {
6031
+ type: "integer",
6032
+ exclusiveMinimum: 0,
6033
+ maximum: 9007199254740991
6034
+ },
6035
+ organizationId: {
6036
+ description: "Required for session auth. Optional for an API key, which already identifies the organization.",
6037
+ type: "string",
6038
+ minLength: 1,
6039
+ maxLength: 120
6040
+ }
6041
+ },
6042
+ required: ["action", "expectedRevision"],
6043
+ additionalProperties: false
6044
+ }
6045
+ };
6046
+
6047
+ // src/body-flags.ts
6048
+ var kebab = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
6049
+ function nonNull(schema) {
6050
+ return schema.anyOf?.find((item) => item.type !== "null") ?? schema;
6051
+ }
6052
+ function nullable(schema) {
6053
+ return schema.type === "null" || Array.isArray(schema.type) && schema.type.includes("null") || Boolean(schema.anyOf?.some(nullable));
6054
+ }
6055
+ function bodyFlagNames(schema, prefix = "") {
6056
+ schema = nonNull(schema);
6057
+ if (schema.properties)
6058
+ return Object.entries(schema.properties).flatMap(
6059
+ ([name, child]) => bodyFlagNames(child, `${prefix ? `${prefix}.` : ""}${kebab(name)}`)
6060
+ );
6061
+ if (schema.items && nonNull(schema.items).properties)
6062
+ return bodyFlagNames(schema.items, `${prefix}.<index>`);
6063
+ if (typeof schema.additionalProperties === "object")
6064
+ return bodyFlagNames(schema.additionalProperties, `${prefix}.<key>`);
6065
+ return [prefix];
6066
+ }
6067
+ function scalar(value, schema, flag) {
6068
+ if (value === "null" && nullable(schema)) return null;
6069
+ schema = nonNull(schema);
6070
+ const type = Array.isArray(schema.type) ? schema.type.find((item) => item !== "null") : schema.type;
6071
+ let result = value;
6072
+ if (type === "array" && schema.items) {
6073
+ if (typeof value !== "string")
6074
+ throw new Error(`--${flag} requires comma-separated values`);
6075
+ result = value === "" ? [] : value.split(",").map((item) => scalar(item.trim(), schema.items, flag));
6076
+ const count = result.length;
6077
+ if (count < (schema.minItems ?? 0) || count > (schema.maxItems ?? Infinity))
6078
+ throw new Error(`--${flag} has an invalid number of values`);
6079
+ } else if (type === "boolean") {
6080
+ if (![true, false, "true", "false"].includes(value))
6081
+ throw new Error(`--${flag} requires true or false`);
6082
+ result = value === true || value === "true";
6083
+ } else if (type === "integer" || type === "number") {
6084
+ const number = typeof value === "string" && value.trim() ? Number(value) : NaN;
6085
+ if (!Number.isFinite(number) || type === "integer" && !Number.isSafeInteger(number) || number < (schema.minimum ?? -Infinity) || number > (schema.maximum ?? Infinity) || schema.exclusiveMinimum !== void 0 && number <= schema.exclusiveMinimum)
6086
+ throw new Error(`--${flag} requires a valid ${type}`);
6087
+ result = number;
6088
+ } else if (typeof value !== "string" || type === "object") {
6089
+ throw new Error(
6090
+ `--${flag} requires a value; use dotted fields for objects`
6091
+ );
6092
+ }
6093
+ if (schema.enum && !schema.enum.includes(result))
6094
+ throw new Error(
6095
+ `--${flag}${flag.endsWith(".marketplace") ? `: ${String(result)} is not supported for this store target; value` : ""} must be one of: ${schema.enum.join(", ")}`
6096
+ );
6097
+ 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)))))
6098
+ throw new Error(
6099
+ `--${flag} has an invalid value${schema.format ? ` (${schema.format})` : ""}`
6100
+ );
6101
+ return result;
6102
+ }
6103
+ function assignFlag(target, schema, parts, value, flag) {
6104
+ schema = nonNull(schema);
6105
+ const [part, ...rest] = parts;
6106
+ if (["__proto__", "constructor", "prototype"].includes(part))
6107
+ throw new Error(`Unknown flag --${flag}`);
6108
+ const key = schema.items ? /^(0|[1-9][0-9]*)$/.test(part) ? Number(part) : void 0 : Object.keys(schema.properties ?? {}).find(
6109
+ (name) => kebab(name) === part
6110
+ ) ?? (typeof schema.additionalProperties === "object" ? part : void 0);
6111
+ const child = schema.items ?? (typeof key === "string" ? schema.properties?.[key] ?? schema.additionalProperties : void 0);
6112
+ if (key === void 0 || !child || typeof child !== "object" || typeof key === "number" && key >= (schema.maxItems ?? 500))
6113
+ throw new Error(`Unknown or out-of-bounds flag --${flag}`);
6114
+ const object = target;
6115
+ if (!rest.length) {
6116
+ object[key] = scalar(value, child, flag);
6117
+ return;
6118
+ }
6119
+ const shape = nonNull(child);
6120
+ if (!shape.properties && !shape.items && typeof shape.additionalProperties !== "object")
6121
+ throw new Error(`Unknown flag --${flag}`);
6122
+ object[key] ??= shape.items ? [] : {};
6123
+ if (typeof object[key] !== "object" || object[key] === null)
6124
+ throw new Error(`Conflicting flag --${flag}`);
6125
+ assignFlag(object[key], child, rest, value, flag);
6126
+ }
6127
+ function validateRequired(value, schema, prefix = "") {
6128
+ if (value === null) return;
6129
+ schema = nonNull(schema);
6130
+ if (Array.isArray(value) && schema.items) {
6131
+ for (let index = 0; index < value.length; index++) {
6132
+ if (!(index in value))
6133
+ throw new Error(`--${prefix} indices must be consecutive from 0`);
6134
+ validateRequired(value[index], schema.items, `${prefix}.${index}`);
6135
+ }
6136
+ } else if (value && typeof value === "object") {
6137
+ const object = value;
6138
+ for (const key of schema.required ?? [])
6139
+ if (object[key] === void 0)
6140
+ throw new Error(
6141
+ `Missing required flag --${prefix ? `${prefix}.` : ""}${kebab(key)}`
6142
+ );
6143
+ for (const [key, child] of Object.entries(schema.properties ?? {}))
6144
+ if (object[key] !== void 0)
6145
+ validateRequired(
6146
+ object[key],
6147
+ child,
6148
+ `${prefix ? `${prefix}.` : ""}${kebab(key)}`
6149
+ );
6150
+ }
6151
+ }
6152
+ var GLOBAL_FLAGS = /* @__PURE__ */ new Set([
6153
+ "api-key",
6154
+ "base-url",
6155
+ "timeout",
6156
+ "format",
6157
+ "version",
6158
+ "v"
6159
+ ]);
6160
+ function parseBodyFlags(flags, schema) {
6161
+ const result = {};
6162
+ for (const [flag, value] of Object.entries(flags)) {
6163
+ if (GLOBAL_FLAGS.has(flag)) continue;
6164
+ assignFlag(result, schema, flag.split("."), value, flag);
6165
+ }
6166
+ validateRequired(result, schema);
6167
+ return result;
6168
+ }
6169
+
6170
+ // src/campaign-commands.ts
6171
+ var patch = CAMPAIGN_INPUTS.patch;
6172
+ var fields = patch.properties;
6173
+ var guards = Object.fromEntries(
6174
+ ["organizationId", "expectedRevision", "expectedPendingVersion"].map(
6175
+ (key) => [key, fields[key]]
6176
+ )
6177
+ );
6178
+ var scope = { campaignId: { type: "string" } };
6179
+ function command(name, summary, schema, options = {}) {
6180
+ const inputSchema = {
6181
+ ...schema,
6182
+ properties: { ...scope, ...schema.properties },
6183
+ required: ["campaignId", ...schema.required ?? []]
6184
+ };
6185
+ return {
6186
+ trail: ["campaigns", name],
6187
+ resourcePath: ["campaigns"],
6188
+ methodName: name,
6189
+ httpMethod: options.action ? "POST" : "PATCH",
6190
+ path: `/api/v1/campaigns/{campaignId}${options.action ? "/actions" : ""}`,
6191
+ summary,
6192
+ flags: bodyFlagNames(inputSchema).map((flag) => ({
6193
+ name: flag === "campaign-id" ? "campaignId" : flag,
6194
+ flag,
6195
+ required: inputSchema.required.some((key) => kebab(key) === flag),
6196
+ source: flag === "campaign-id" ? "path" : "body"
6197
+ })),
6198
+ acceptsJsonBody: true,
6199
+ acceptsFile: false,
6200
+ bodyRequired: false,
6201
+ inputSchema,
6202
+ ...options
6203
+ };
6204
+ }
6205
+ var CAMPAIGN_COMMANDS = [
6206
+ command(
6207
+ "update",
6208
+ "Edit campaign fields, windows and offers. Omitted values stay unchanged; running edits are proposals.",
6209
+ patch
6210
+ ),
6211
+ ...["offers", "windows"].flatMap((target) => {
6212
+ const { id, ...properties } = fields[target].items.properties;
6213
+ const ids = target === "offers" ? "offerIds" : "windowIds";
6214
+ const selection = {
6215
+ type: "array",
6216
+ items: id,
6217
+ minItems: 1,
6218
+ maxItems: fields[target].maxItems
6219
+ };
6220
+ return [
6221
+ command(
6222
+ `update-${target}`,
6223
+ `Add or update ${target} by stable IDs with shared changes. Running edits are proposals.`,
6224
+ {
6225
+ type: "object",
6226
+ properties: { ...guards, [ids]: selection, ...properties },
6227
+ required: ["expectedRevision", ids]
6228
+ },
6229
+ { target }
6230
+ ),
6231
+ command(
6232
+ `remove-${target}`,
6233
+ `Remove selected ${target}. Move or remove offers before removing their window. Running edits are proposals.`,
6234
+ {
6235
+ type: "object",
6236
+ properties: { ...guards, [ids]: selection },
6237
+ required: ["expectedRevision", ids]
6238
+ },
6239
+ { target: target === "offers" ? "removeOfferIds" : "removeWindowIds" }
6240
+ )
6241
+ ];
6242
+ }),
6243
+ ...["approve_change", "discard_change"].map(
6244
+ (action) => command(
6245
+ action.replaceAll("_", "-"),
6246
+ action === "approve_change" ? "Approve the reviewed live proposal as its named approver and queue delivery." : "Discard the reviewed live proposal.",
6247
+ {
6248
+ type: "object",
6249
+ properties: {
6250
+ ...guards,
6251
+ expectedPendingVersion: CAMPAIGN_INPUTS.action.properties.expectedPendingVersion
6252
+ },
6253
+ required: ["expectedRevision", "expectedPendingVersion"]
6254
+ },
6255
+ { action }
6256
+ )
6257
+ )
6258
+ ];
6259
+ function isCampaignCommand(command2) {
6260
+ return "inputSchema" in command2;
6261
+ }
6262
+ function campaignRequest(command2, flags) {
6263
+ const input2 = parseBodyFlags(flags, command2.inputSchema);
6264
+ if (command2.action) return { ...input2, action: command2.action };
6265
+ if (!command2.target) {
6266
+ if (!Object.keys(input2).some(
6267
+ (key) => key !== "campaignId" && !(key in guards)
6268
+ ))
6269
+ throw new Error("Supply at least one field to change.");
6270
+ return input2;
6271
+ }
6272
+ const {
6273
+ campaignId,
6274
+ organizationId,
6275
+ expectedRevision,
6276
+ expectedPendingVersion,
6277
+ offerIds,
6278
+ windowIds,
6279
+ ...changes
6280
+ } = input2;
6281
+ const ids = [...new Set(offerIds ?? windowIds)];
6282
+ const removing = command2.target === "removeOfferIds" || command2.target === "removeWindowIds";
6283
+ if (!removing && !Object.keys(changes).length)
6284
+ throw new Error("Supply at least one field to change.");
6285
+ return {
6286
+ campaignId,
6287
+ organizationId,
6288
+ expectedRevision,
6289
+ expectedPendingVersion,
6290
+ [command2.target]: removing ? ids : ids.map((id) => ({ id, ...changes }))
6291
+ };
6292
+ }
6293
+
3808
6294
  // src/help.ts
3809
6295
  function printRootHelp(commands) {
3810
6296
  const groups = [
3811
- ...new Set(commands.map((command) => command.trail[0]))
6297
+ ...new Set(commands.map((command2) => command2.trail[0]))
3812
6298
  ].sort();
3813
6299
  return `OmniCommerce CLI
3814
6300
 
3815
6301
  Usage:
3816
6302
  omni <resource> <command> [flags]
3817
- omni auth login --api-key omni_sk_...
6303
+ omni auth login
3818
6304
  omni auth status
3819
6305
  omni auth logout
3820
6306
 
@@ -3823,7 +6309,7 @@ ${groups.map((group) => ` ${group}`).join("\n")}
3823
6309
 
3824
6310
  Global flags:
3825
6311
  --api-key <key> API key (or OMNI_API_KEY / omni auth login)
3826
- --base-url <url> API origin (default https://omnicommerce.sg)
6312
+ --base-url <url> API origin (default https://omnicommerce.ai)
3827
6313
  --json <object|-> JSON body, or - to read stdin
3828
6314
  --format json|table Output format (table on TTY, json when piped)
3829
6315
  --dry-run Print the request without sending it
@@ -3838,36 +6324,52 @@ Examples:
3838
6324
  omni jobs wait --job-id prod_123
3839
6325
  `;
3840
6326
  }
3841
- function printCommandHelp(command) {
3842
- const flags = command.flags.map((flag) => {
6327
+ function printAuthHelp() {
6328
+ return `Usage:
6329
+ omni auth login Sign in using your browser
6330
+ omni auth login --no-browser Print the login URL without opening it
6331
+ omni auth login --api-key <key> Save an existing API key
6332
+ omni auth login --base-url <origin> Sign in to another API origin
6333
+ omni auth status Show saved credential status
6334
+ omni auth logout Remove saved credentials
6335
+ `;
6336
+ }
6337
+ function printCommandHelp(command2) {
6338
+ const flags = command2.flags.map((flag) => {
3843
6339
  const req = flag.required ? "required" : "optional";
3844
6340
  return ` --${flag.flag} <${flag.name}> ${req} ${flag.source}`;
3845
6341
  }).join("\n");
3846
- const jsonLine = `${command.acceptsFile ? " --file <path> required file to upload\n" : ""}${command.acceptsJsonBody ? ` --json <object|-> ${command.bodyRequired && !command.acceptsFile ? "required" : "optional"} body
6342
+ const jsonLine = `${command2.acceptsFile ? " --file <path> required file to upload\n" : ""}${command2.acceptsJsonBody && !isCampaignCommand(command2) ? ` --json <object|-> ${command2.bodyRequired && !command2.acceptsFile ? "required" : "optional"} body
3847
6343
  ` : ""}`;
3848
- return `omni ${command.trail.join(" ")}
6344
+ return `omni ${command2.trail.join(" ")}
3849
6345
 
3850
- ${command.summary}
6346
+ ${command2.summary}
3851
6347
 
3852
- ${command.httpMethod} ${command.path}
6348
+ ${command2.httpMethod} ${command2.path}
3853
6349
 
3854
6350
  Flags:
3855
6351
  ${flags || " (none)"}${jsonLine ? `
3856
6352
  ${jsonLine}` : ""}
6353
+ ${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" : ""}
3857
6354
  `;
3858
6355
  }
3859
6356
  function matchCommands(commands, trail) {
3860
6357
  const prefix = commands.filter(
3861
- (command) => trail.every((token, index) => command.trail[index] === token)
6358
+ (command2) => trail.every((token, index) => command2.trail[index] === token)
3862
6359
  );
3863
- const exact = prefix.find((command) => command.trail.length === trail.length);
6360
+ const exact = prefix.find((command2) => command2.trail.length === trail.length);
3864
6361
  return { exact, prefix };
3865
6362
  }
3866
6363
 
3867
- // src/version.ts
3868
- var CLI_VERSION = "0.9.0";
3869
-
3870
6364
  // src/run.ts
6365
+ var CLI_COMMANDS = [
6366
+ ...COMMANDS.filter(
6367
+ (command2) => !CAMPAIGN_COMMANDS.some(
6368
+ (custom) => custom.trail.join(" ") === command2.trail.join(" ")
6369
+ )
6370
+ ),
6371
+ ...CAMPAIGN_COMMANDS
6372
+ ];
3871
6373
  async function readStdin() {
3872
6374
  const chunks = [];
3873
6375
  for await (const chunk of input) {
@@ -3884,9 +6386,9 @@ async function parseJsonBody(raw) {
3884
6386
  }
3885
6387
  return parsed;
3886
6388
  }
3887
- function buildRequest(command, flags, body) {
6389
+ function buildRequest(command2, flags, body) {
3888
6390
  const request = { ...body };
3889
- for (const flag of command.flags) {
6391
+ for (const flag of command2.flags) {
3890
6392
  const value = flagString(flags, flag.flag);
3891
6393
  if (value === void 0) {
3892
6394
  if (flag.required) {
@@ -3898,21 +6400,26 @@ function buildRequest(command, flags, body) {
3898
6400
  }
3899
6401
  return request;
3900
6402
  }
3901
- async function handleAuth(trail, flags) {
6403
+ async function handleAuth(trail, flags, options) {
3902
6404
  const action = trail[1] ?? "status";
3903
6405
  if (action === "login") {
3904
- const apiKey = flagString(flags, "api-key");
3905
- if (!apiKey) {
3906
- throw new Error("omni auth login requires --api-key");
3907
- }
3908
6406
  const existing = await readConfig();
3909
- await writeConfig({
3910
- ...existing,
6407
+ const apiKey = flagString(flags, "api-key");
6408
+ const credentials = apiKey ? {
3911
6409
  apiKey,
3912
6410
  baseUrl: flagString(flags, "base-url") ?? existing.baseUrl
6411
+ } : await browserLogin(
6412
+ (await resolveCredentials({
6413
+ baseUrl: flagString(flags, "base-url")
6414
+ })).baseUrl,
6415
+ { ...options, noBrowser: flags["no-browser"] === true }
6416
+ );
6417
+ await writeConfig({
6418
+ ...existing,
6419
+ ...credentials
3913
6420
  });
3914
6421
  process.stdout.write(
3915
- `Saved credentials to config (${maskSecret(apiKey)})
6422
+ `Saved credentials to config (${maskSecret(credentials.apiKey)})
3916
6423
  `
3917
6424
  );
3918
6425
  return 0;
@@ -3922,6 +6429,7 @@ async function handleAuth(trail, flags) {
3922
6429
  process.stdout.write("Removed saved credentials\n");
3923
6430
  return 0;
3924
6431
  }
6432
+ if (action !== "status") throw new Error(`Unknown auth command: ${action}`);
3925
6433
  const resolved = await resolveCredentials({
3926
6434
  apiKey: flagString(flags, "api-key"),
3927
6435
  baseUrl: flagString(flags, "base-url")
@@ -3942,22 +6450,26 @@ async function runCli(argv, options) {
3942
6450
  return 0;
3943
6451
  }
3944
6452
  if (parsed.trail[0] === "auth") {
3945
- return handleAuth(parsed.trail, parsed.flags);
6453
+ if (parsed.help) {
6454
+ process.stdout.write(printAuthHelp());
6455
+ return 0;
6456
+ }
6457
+ return handleAuth(parsed.trail, parsed.flags, options);
3946
6458
  }
3947
6459
  if (parsed.trail.length === 0) {
3948
- process.stdout.write(printRootHelp(COMMANDS));
6460
+ process.stdout.write(printRootHelp(CLI_COMMANDS));
3949
6461
  return parsed.help ? 0 : 1;
3950
6462
  }
3951
- const matched = matchCommands(COMMANDS, parsed.trail);
6463
+ const matched = matchCommands(CLI_COMMANDS, parsed.trail);
3952
6464
  if (parsed.help && !matched.exact) {
3953
6465
  if (matched.prefix.length === 0) {
3954
6466
  process.stderr.write(`Unknown command: ${parsed.trail.join(" ")}
3955
6467
  `);
3956
- process.stdout.write(printRootHelp(COMMANDS));
6468
+ process.stdout.write(printRootHelp(CLI_COMMANDS));
3957
6469
  return 1;
3958
6470
  }
3959
6471
  const unique = [
3960
- ...new Set(matched.prefix.map((command2) => command2.trail.join(" ")))
6472
+ ...new Set(matched.prefix.map((command3) => command3.trail.join(" ")))
3961
6473
  ];
3962
6474
  process.stdout.write(
3963
6475
  `omni ${parsed.trail.join(" ")}
@@ -3968,38 +6480,42 @@ ${unique.map((line) => ` omni ${line}`).join("\n")}
3968
6480
  );
3969
6481
  return 0;
3970
6482
  }
3971
- const command = matched.exact;
3972
- if (!command) {
6483
+ const command2 = matched.exact;
6484
+ if (!command2) {
3973
6485
  process.stderr.write(`Unknown command: ${parsed.trail.join(" ")}
3974
6486
  `);
3975
- process.stdout.write(printRootHelp(COMMANDS));
6487
+ process.stdout.write(printRootHelp(CLI_COMMANDS));
3976
6488
  return 1;
3977
6489
  }
3978
6490
  if (parsed.help) {
3979
- process.stdout.write(printCommandHelp(command));
6491
+ process.stdout.write(printCommandHelp(command2));
3980
6492
  return 0;
3981
6493
  }
3982
6494
  if (parsed.schema) {
3983
- process.stdout.write(`${JSON.stringify(command, null, 2)}
6495
+ process.stdout.write(`${JSON.stringify(command2, null, 2)}
3984
6496
  `);
3985
6497
  return 0;
3986
6498
  }
3987
6499
  const body = await parseJsonBody(flagString(parsed.flags, "json"));
3988
- const filePath = command.acceptsFile ? flagString(parsed.flags, "file") : void 0;
3989
- if (command.acceptsFile && !filePath) {
3990
- throw new Error(`omni ${command.trail.join(" ")} requires --file <path>`);
6500
+ const filePath = command2.acceptsFile ? flagString(parsed.flags, "file") : void 0;
6501
+ if (command2.acceptsFile && !filePath) {
6502
+ throw new Error(`omni ${command2.trail.join(" ")} requires --file <path>`);
3991
6503
  }
3992
- if (command.bodyRequired && !body && !filePath) {
3993
- throw new Error(`omni ${command.trail.join(" ")} requires --json`);
6504
+ if (command2.bodyRequired && !body && !filePath) {
6505
+ throw new Error(`omni ${command2.trail.join(" ")} requires --json`);
3994
6506
  }
3995
- const request = buildRequest(command, parsed.flags, body);
6507
+ if (isCampaignCommand(command2) && body)
6508
+ throw new Error(
6509
+ "Use campaign field flags for this command; --json is available on campaigns replace and actions."
6510
+ );
6511
+ const request = isCampaignCommand(command2) ? campaignRequest(command2, parsed.flags) : buildRequest(command2, parsed.flags, body);
3996
6512
  if (filePath) request.file = filePath;
3997
6513
  if (parsed.dryRun) {
3998
6514
  process.stdout.write(
3999
6515
  `${JSON.stringify(
4000
6516
  {
4001
- method: command.httpMethod,
4002
- path: command.path,
6517
+ method: command2.httpMethod,
6518
+ path: command2.path,
4003
6519
  request
4004
6520
  },
4005
6521
  null,
@@ -4020,7 +6536,7 @@ ${unique.map((line) => ` omni ${line}`).join("\n")}
4020
6536
  return 1;
4021
6537
  }
4022
6538
  const timeoutRaw = flagString(parsed.flags, "timeout");
4023
- const timeoutInSeconds = timeoutRaw ? Number(timeoutRaw) : command.path === "/api/v1/agents/general/invoke" ? 780 : void 0;
6539
+ const timeoutInSeconds = timeoutRaw ? Number(timeoutRaw) : command2.path === "/api/v1/agents/general/invoke" ? 780 : void 0;
4024
6540
  const client = new OmniClient({
4025
6541
  apiKey: credentials.apiKey,
4026
6542
  baseUrl: credentials.baseUrl,
@@ -4028,7 +6544,7 @@ ${unique.map((line) => ` omni ${line}`).join("\n")}
4028
6544
  fetch: options?.fetch
4029
6545
  });
4030
6546
  try {
4031
- const result = await executeCommand(client, command, request);
6547
+ const result = await executeCommand(client, command2, request);
4032
6548
  const format = resolveFormat(
4033
6549
  flagString(parsed.flags, "format"),
4034
6550
  options?.stdoutIsTty ?? Boolean(process.stdout.isTTY)