@omni-commerce/cli 0.9.0 → 0.10.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 = [];
@@ -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 command = 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(command, args, { timeout: 1e4 });
84
+ }
85
+
86
+ // src/version.ts
87
+ var CLI_VERSION = "0.10.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) {
@@ -237,6 +364,69 @@ ${body}
237
364
 
238
365
  // src/generated/commands.ts
239
366
  var COMMANDS = [
367
+ {
368
+ trail: ["api", "get-embedwell-knownagent-card-json"],
369
+ resourcePath: ["api"],
370
+ methodName: "getEmbedwellKnownagentCardJson",
371
+ httpMethod: "GET",
372
+ path: "/api/embed/{deploymentId}/.well-known/agent-card.json",
373
+ summary: "Discover a published merchant agent",
374
+ flags: [
375
+ {
376
+ name: "deploymentId",
377
+ flag: "deployment-id",
378
+ required: true,
379
+ source: "path"
380
+ }
381
+ ],
382
+ acceptsJsonBody: false,
383
+ acceptsFile: false,
384
+ bodyRequired: false
385
+ },
386
+ {
387
+ trail: ["api", "embeda2a"],
388
+ resourcePath: ["api"],
389
+ methodName: "embeda2a",
390
+ httpMethod: "POST",
391
+ path: "/api/embed/{deploymentId}/a2a",
392
+ summary: "Call a merchant agent using A2A",
393
+ flags: [
394
+ {
395
+ name: "deploymentId",
396
+ flag: "deployment-id",
397
+ required: true,
398
+ source: "path"
399
+ }
400
+ ],
401
+ acceptsJsonBody: true,
402
+ acceptsFile: false,
403
+ bodyRequired: true
404
+ },
405
+ {
406
+ trail: ["api", "embedcheckout-sessions"],
407
+ resourcePath: ["api"],
408
+ methodName: "embedcheckoutSessions",
409
+ httpMethod: "POST",
410
+ path: "/api/embed/{deploymentId}/checkout-sessions/{operation}",
411
+ summary: "Manage customer-owned purchase offers",
412
+ flags: [
413
+ {
414
+ name: "deploymentId",
415
+ flag: "deployment-id",
416
+ required: true,
417
+ source: "path"
418
+ },
419
+ {
420
+ name: "operation",
421
+ flag: "operation",
422
+ required: true,
423
+ source: "path"
424
+ }
425
+ ],
426
+ acceptsJsonBody: true,
427
+ acceptsFile: false,
428
+ bodyRequired: true
429
+ },
240
430
  {
241
431
  trail: ["agents", "general", "invoke"],
242
432
  resourcePath: ["agents", "general"],
@@ -1068,6 +1258,124 @@ var COMMANDS = [
1068
1258
  acceptsFile: false,
1069
1259
  bodyRequired: true
1070
1260
  },
1261
+ {
1262
+ trail: ["brand-kits", "list"],
1263
+ resourcePath: ["brandKits"],
1264
+ methodName: "list",
1265
+ httpMethod: "GET",
1266
+ path: "/api/v1/brand-kits",
1267
+ summary: "List Brand Kits",
1268
+ flags: [
1269
+ {
1270
+ name: "organizationId",
1271
+ flag: "organization-id",
1272
+ required: false,
1273
+ source: "query"
1274
+ },
1275
+ {
1276
+ name: "q",
1277
+ flag: "q",
1278
+ required: false,
1279
+ source: "query"
1280
+ },
1281
+ {
1282
+ name: "limit",
1283
+ flag: "limit",
1284
+ required: false,
1285
+ source: "query"
1286
+ },
1287
+ {
1288
+ name: "offset",
1289
+ flag: "offset",
1290
+ required: false,
1291
+ source: "query"
1292
+ }
1293
+ ],
1294
+ acceptsJsonBody: false,
1295
+ acceptsFile: false,
1296
+ bodyRequired: false
1297
+ },
1298
+ {
1299
+ trail: ["brand-kits", "create"],
1300
+ resourcePath: ["brandKits"],
1301
+ methodName: "create",
1302
+ httpMethod: "POST",
1303
+ path: "/api/v1/brand-kits",
1304
+ summary: "Create Brand Kit",
1305
+ flags: [],
1306
+ acceptsJsonBody: true,
1307
+ acceptsFile: false,
1308
+ bodyRequired: true
1309
+ },
1310
+ {
1311
+ trail: ["brand-kits", "delete"],
1312
+ resourcePath: ["brandKits"],
1313
+ methodName: "delete",
1314
+ httpMethod: "DELETE",
1315
+ path: "/api/v1/brand-kits/{brandKitId}",
1316
+ summary: "Delete Brand Kit",
1317
+ flags: [
1318
+ {
1319
+ name: "brandKitId",
1320
+ flag: "brand-kit-id",
1321
+ required: true,
1322
+ source: "path"
1323
+ },
1324
+ {
1325
+ name: "organizationId",
1326
+ flag: "organization-id",
1327
+ required: false,
1328
+ source: "query"
1329
+ }
1330
+ ],
1331
+ acceptsJsonBody: false,
1332
+ acceptsFile: false,
1333
+ bodyRequired: false
1334
+ },
1335
+ {
1336
+ trail: ["brand-kits", "get"],
1337
+ resourcePath: ["brandKits"],
1338
+ methodName: "get",
1339
+ httpMethod: "GET",
1340
+ path: "/api/v1/brand-kits/{brandKitId}",
1341
+ summary: "Get Brand Kit",
1342
+ flags: [
1343
+ {
1344
+ name: "brandKitId",
1345
+ flag: "brand-kit-id",
1346
+ required: true,
1347
+ source: "path"
1348
+ },
1349
+ {
1350
+ name: "organizationId",
1351
+ flag: "organization-id",
1352
+ required: false,
1353
+ source: "query"
1354
+ }
1355
+ ],
1356
+ acceptsJsonBody: false,
1357
+ acceptsFile: false,
1358
+ bodyRequired: false
1359
+ },
1360
+ {
1361
+ trail: ["brand-kits", "update"],
1362
+ resourcePath: ["brandKits"],
1363
+ methodName: "update",
1364
+ httpMethod: "PATCH",
1365
+ path: "/api/v1/brand-kits/{brandKitId}",
1366
+ summary: "Update Brand Kit",
1367
+ flags: [
1368
+ {
1369
+ name: "brandKitId",
1370
+ flag: "brand-kit-id",
1371
+ required: true,
1372
+ source: "path"
1373
+ }
1374
+ ],
1375
+ acceptsJsonBody: true,
1376
+ acceptsFile: false,
1377
+ bodyRequired: true
1378
+ },
1071
1379
  {
1072
1380
  trail: ["brandsgateway", "import-products"],
1073
1381
  resourcePath: ["brandsgateway"],
@@ -1433,6 +1741,30 @@ var COMMANDS = [
1433
1741
  acceptsFile: false,
1434
1742
  bodyRequired: true
1435
1743
  },
1744
+ {
1745
+ trail: ["commerce", "await-jobs"],
1746
+ resourcePath: ["commerce"],
1747
+ methodName: "awaitJobs",
1748
+ httpMethod: "POST",
1749
+ path: "/api/v1/commerce/jobs/await",
1750
+ summary: "Await Commerce Jobs",
1751
+ flags: [],
1752
+ acceptsJsonBody: true,
1753
+ acceptsFile: false,
1754
+ bodyRequired: true
1755
+ },
1756
+ {
1757
+ trail: ["commerce", "verify-state"],
1758
+ resourcePath: ["commerce"],
1759
+ methodName: "verifyState",
1760
+ httpMethod: "POST",
1761
+ path: "/api/v1/commerce/state/verify",
1762
+ summary: "Verify Commerce State",
1763
+ flags: [],
1764
+ acceptsJsonBody: true,
1765
+ acceptsFile: false,
1766
+ bodyRequired: true
1767
+ },
1436
1768
  {
1437
1769
  trail: ["compare", "get"],
1438
1770
  resourcePath: ["compare"],
@@ -1501,6 +1833,12 @@ var COMMANDS = [
1501
1833
  flag: "organization-id",
1502
1834
  required: false,
1503
1835
  source: "query"
1836
+ },
1837
+ {
1838
+ name: "includeDownloadUrl",
1839
+ flag: "include-download-url",
1840
+ required: false,
1841
+ source: "query"
1504
1842
  }
1505
1843
  ],
1506
1844
  acceptsJsonBody: false,
@@ -1556,6 +1894,79 @@ var COMMANDS = [
1556
1894
  acceptsFile: false,
1557
1895
  bodyRequired: true
1558
1896
  },
1897
+ {
1898
+ trail: ["inventory", "list"],
1899
+ resourcePath: ["inventory"],
1900
+ methodName: "list",
1901
+ httpMethod: "GET",
1902
+ path: "/api/v1/inventory",
1903
+ summary: "List Inventory Groups",
1904
+ flags: [
1905
+ {
1906
+ name: "productIds",
1907
+ flag: "product-ids",
1908
+ required: false,
1909
+ source: "query"
1910
+ },
1911
+ {
1912
+ name: "query",
1913
+ flag: "query",
1914
+ required: false,
1915
+ source: "query"
1916
+ },
1917
+ {
1918
+ name: "marketplace",
1919
+ flag: "marketplace",
1920
+ required: false,
1921
+ source: "query"
1922
+ },
1923
+ {
1924
+ name: "country",
1925
+ flag: "country",
1926
+ required: false,
1927
+ source: "query"
1928
+ },
1929
+ {
1930
+ name: "storeIds",
1931
+ flag: "store-ids",
1932
+ required: false,
1933
+ source: "query"
1934
+ },
1935
+ {
1936
+ name: "unlistedMarketplaces",
1937
+ flag: "unlisted-marketplaces",
1938
+ required: false,
1939
+ source: "query"
1940
+ },
1941
+ {
1942
+ name: "groupBy",
1943
+ flag: "group-by",
1944
+ required: false,
1945
+ source: "query"
1946
+ },
1947
+ {
1948
+ name: "status",
1949
+ flag: "status",
1950
+ required: false,
1951
+ source: "query"
1952
+ },
1953
+ {
1954
+ name: "offset",
1955
+ flag: "offset",
1956
+ required: false,
1957
+ source: "query"
1958
+ },
1959
+ {
1960
+ name: "limit",
1961
+ flag: "limit",
1962
+ required: false,
1963
+ source: "query"
1964
+ }
1965
+ ],
1966
+ acceptsJsonBody: false,
1967
+ acceptsFile: false,
1968
+ bodyRequired: false
1969
+ },
1559
1970
  {
1560
1971
  trail: ["jobs", "get"],
1561
1972
  resourcePath: ["jobs"],
@@ -2159,14 +2570,94 @@ var COMMANDS = [
2159
2570
  bodyRequired: true
2160
2571
  },
2161
2572
  {
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,
2573
+ trail: ["orders", "list-batch-action-options"],
2574
+ resourcePath: ["orders"],
2575
+ methodName: "listBatchActionOptions",
2576
+ httpMethod: "GET",
2577
+ path: "/api/v1/orders/actions",
2578
+ summary: "Check Order Action Options",
2579
+ flags: [
2580
+ {
2581
+ name: "orderIds",
2582
+ flag: "order-ids",
2583
+ required: true,
2584
+ source: "query"
2585
+ },
2586
+ {
2587
+ name: "action",
2588
+ flag: "action",
2589
+ required: true,
2590
+ source: "query"
2591
+ },
2592
+ {
2593
+ name: "organizationId",
2594
+ flag: "organization-id",
2595
+ required: false,
2596
+ source: "query"
2597
+ }
2598
+ ],
2599
+ acceptsJsonBody: false,
2600
+ acceptsFile: false,
2601
+ bodyRequired: false
2602
+ },
2603
+ {
2604
+ trail: ["orders", "process-actions"],
2605
+ resourcePath: ["orders"],
2606
+ methodName: "processActions",
2607
+ httpMethod: "POST",
2608
+ path: "/api/v1/orders/actions",
2609
+ summary: "Process Order Actions",
2610
+ flags: [],
2611
+ acceptsJsonBody: true,
2612
+ acceptsFile: false,
2613
+ bodyRequired: true
2614
+ },
2615
+ {
2616
+ trail: ["orders", "get-action-jobs"],
2617
+ resourcePath: ["orders"],
2618
+ methodName: "getActionJobs",
2619
+ httpMethod: "GET",
2620
+ path: "/api/v1/orders/actions/jobs",
2621
+ summary: "Get Order Action Jobs",
2622
+ flags: [
2623
+ {
2624
+ name: "jobIds",
2625
+ flag: "job-ids",
2626
+ required: true,
2627
+ source: "query"
2628
+ },
2629
+ {
2630
+ name: "organizationId",
2631
+ flag: "organization-id",
2632
+ required: false,
2633
+ source: "query"
2634
+ }
2635
+ ],
2636
+ acceptsJsonBody: false,
2637
+ acceptsFile: false,
2638
+ bodyRequired: false
2639
+ },
2640
+ {
2641
+ trail: ["orders", "create-picking-list"],
2642
+ resourcePath: ["orders"],
2643
+ methodName: "createPickingList",
2644
+ httpMethod: "POST",
2645
+ path: "/api/v1/orders/picking-list",
2646
+ summary: "Create Picking List",
2647
+ flags: [],
2648
+ acceptsJsonBody: true,
2649
+ acceptsFile: false,
2650
+ bodyRequired: true
2651
+ },
2652
+ {
2653
+ trail: ["organizations", "create"],
2654
+ resourcePath: ["organizations"],
2655
+ methodName: "create",
2656
+ httpMethod: "POST",
2657
+ path: "/api/v1/organizations",
2658
+ summary: "Create Organization",
2659
+ flags: [],
2660
+ acceptsJsonBody: true,
2170
2661
  acceptsFile: false,
2171
2662
  bodyRequired: true
2172
2663
  },
@@ -2367,6 +2858,90 @@ var COMMANDS = [
2367
2858
  flag: "offset",
2368
2859
  required: false,
2369
2860
  source: "query"
2861
+ },
2862
+ {
2863
+ name: "store",
2864
+ flag: "store",
2865
+ required: false,
2866
+ source: "query"
2867
+ },
2868
+ {
2869
+ name: "storeKeys",
2870
+ flag: "store-keys",
2871
+ required: false,
2872
+ source: "query"
2873
+ },
2874
+ {
2875
+ name: "brands",
2876
+ flag: "brands",
2877
+ required: false,
2878
+ source: "query"
2879
+ },
2880
+ {
2881
+ name: "bundleType",
2882
+ flag: "bundle-type",
2883
+ required: false,
2884
+ source: "query"
2885
+ },
2886
+ {
2887
+ name: "language",
2888
+ flag: "language",
2889
+ required: false,
2890
+ source: "query"
2891
+ },
2892
+ {
2893
+ name: "hasImage",
2894
+ flag: "has-image",
2895
+ required: false,
2896
+ source: "query"
2897
+ },
2898
+ {
2899
+ name: "stock",
2900
+ flag: "stock",
2901
+ required: false,
2902
+ source: "query"
2903
+ },
2904
+ {
2905
+ name: "duplicateStatus",
2906
+ flag: "duplicate-status",
2907
+ required: false,
2908
+ source: "query"
2909
+ },
2910
+ {
2911
+ name: "duplicateType",
2912
+ flag: "duplicate-type",
2913
+ required: false,
2914
+ source: "query"
2915
+ },
2916
+ {
2917
+ name: "publishedFrom",
2918
+ flag: "published-from",
2919
+ required: false,
2920
+ source: "query"
2921
+ },
2922
+ {
2923
+ name: "publishedTo",
2924
+ flag: "published-to",
2925
+ required: false,
2926
+ source: "query"
2927
+ },
2928
+ {
2929
+ name: "publishedTimeZone",
2930
+ flag: "published-time-zone",
2931
+ required: false,
2932
+ source: "query"
2933
+ },
2934
+ {
2935
+ name: "cursor",
2936
+ flag: "cursor",
2937
+ required: false,
2938
+ source: "query"
2939
+ },
2940
+ {
2941
+ name: "includeSummary",
2942
+ flag: "include-summary",
2943
+ required: false,
2944
+ source: "query"
2370
2945
  }
2371
2946
  ],
2372
2947
  acceptsJsonBody: false,
@@ -2593,6 +3168,43 @@ var COMMANDS = [
2593
3168
  acceptsFile: false,
2594
3169
  bodyRequired: true
2595
3170
  },
3171
+ {
3172
+ trail: ["products", "get-bulk-import-retry"],
3173
+ resourcePath: ["products"],
3174
+ methodName: "getBulkImportRetry",
3175
+ httpMethod: "GET",
3176
+ path: "/api/v1/products/bulk-import/retries/{retryJobId}",
3177
+ summary: "Get Import Retry Progress",
3178
+ flags: [
3179
+ {
3180
+ name: "retryJobId",
3181
+ flag: "retry-job-id",
3182
+ required: true,
3183
+ source: "path"
3184
+ },
3185
+ {
3186
+ name: "organizationId",
3187
+ flag: "organization-id",
3188
+ required: false,
3189
+ source: "query"
3190
+ }
3191
+ ],
3192
+ acceptsJsonBody: false,
3193
+ acceptsFile: false,
3194
+ bodyRequired: false
3195
+ },
3196
+ {
3197
+ trail: ["products", "retry-bulk-import"],
3198
+ resourcePath: ["products"],
3199
+ methodName: "retryBulkImport",
3200
+ httpMethod: "POST",
3201
+ path: "/api/v1/products/bulk-import/retry",
3202
+ summary: "Retry Failed Import or Review Jobs",
3203
+ flags: [],
3204
+ acceptsJsonBody: true,
3205
+ acceptsFile: false,
3206
+ bodyRequired: true
3207
+ },
2596
3208
  {
2597
3209
  trail: ["products", "compare-prices"],
2598
3210
  resourcePath: ["products"],
@@ -2642,6 +3254,133 @@ var COMMANDS = [
2642
3254
  acceptsFile: false,
2643
3255
  bodyRequired: true
2644
3256
  },
3257
+ {
3258
+ trail: ["products", "count"],
3259
+ resourcePath: ["products"],
3260
+ methodName: "count",
3261
+ httpMethod: "GET",
3262
+ path: "/api/v1/products/count",
3263
+ summary: "Count Products",
3264
+ flags: [
3265
+ {
3266
+ name: "status",
3267
+ flag: "status",
3268
+ required: false,
3269
+ source: "query"
3270
+ },
3271
+ {
3272
+ name: "marketplace",
3273
+ flag: "marketplace",
3274
+ required: false,
3275
+ source: "query"
3276
+ },
3277
+ {
3278
+ name: "country",
3279
+ flag: "country",
3280
+ required: false,
3281
+ source: "query"
3282
+ },
3283
+ {
3284
+ name: "q",
3285
+ flag: "q",
3286
+ required: false,
3287
+ source: "query"
3288
+ },
3289
+ {
3290
+ name: "sku",
3291
+ flag: "sku",
3292
+ required: false,
3293
+ source: "query"
3294
+ },
3295
+ {
3296
+ name: "minPrice",
3297
+ flag: "min-price",
3298
+ required: false,
3299
+ source: "query"
3300
+ },
3301
+ {
3302
+ name: "maxPrice",
3303
+ flag: "max-price",
3304
+ required: false,
3305
+ source: "query"
3306
+ },
3307
+ {
3308
+ name: "store",
3309
+ flag: "store",
3310
+ required: false,
3311
+ source: "query"
3312
+ },
3313
+ {
3314
+ name: "storeKeys",
3315
+ flag: "store-keys",
3316
+ required: false,
3317
+ source: "query"
3318
+ },
3319
+ {
3320
+ name: "brands",
3321
+ flag: "brands",
3322
+ required: false,
3323
+ source: "query"
3324
+ },
3325
+ {
3326
+ name: "bundleType",
3327
+ flag: "bundle-type",
3328
+ required: false,
3329
+ source: "query"
3330
+ },
3331
+ {
3332
+ name: "language",
3333
+ flag: "language",
3334
+ required: false,
3335
+ source: "query"
3336
+ },
3337
+ {
3338
+ name: "hasImage",
3339
+ flag: "has-image",
3340
+ required: false,
3341
+ source: "query"
3342
+ },
3343
+ {
3344
+ name: "stock",
3345
+ flag: "stock",
3346
+ required: false,
3347
+ source: "query"
3348
+ },
3349
+ {
3350
+ name: "duplicateStatus",
3351
+ flag: "duplicate-status",
3352
+ required: false,
3353
+ source: "query"
3354
+ },
3355
+ {
3356
+ name: "duplicateType",
3357
+ flag: "duplicate-type",
3358
+ required: false,
3359
+ source: "query"
3360
+ },
3361
+ {
3362
+ name: "publishedFrom",
3363
+ flag: "published-from",
3364
+ required: false,
3365
+ source: "query"
3366
+ },
3367
+ {
3368
+ name: "publishedTo",
3369
+ flag: "published-to",
3370
+ required: false,
3371
+ source: "query"
3372
+ },
3373
+ {
3374
+ name: "publishedTimeZone",
3375
+ flag: "published-time-zone",
3376
+ required: false,
3377
+ source: "query"
3378
+ }
3379
+ ],
3380
+ acceptsJsonBody: false,
3381
+ acceptsFile: false,
3382
+ bodyRequired: false
3383
+ },
2645
3384
  {
2646
3385
  trail: ["products", "enrich"],
2647
3386
  resourcePath: ["products"],
@@ -2892,10 +3631,115 @@ var COMMANDS = [
2892
3631
  summary: "Retry Marketplace Delivery",
2893
3632
  flags: [
2894
3633
  {
2895
- name: "promotionId",
2896
- flag: "promotion-id",
3634
+ name: "promotionId",
3635
+ flag: "promotion-id",
3636
+ required: true,
3637
+ source: "path"
3638
+ },
3639
+ {
3640
+ name: "organizationId",
3641
+ flag: "organization-id",
3642
+ required: false,
3643
+ source: "query"
3644
+ }
3645
+ ],
3646
+ acceptsJsonBody: true,
3647
+ acceptsFile: false,
3648
+ bodyRequired: true
3649
+ },
3650
+ {
3651
+ trail: ["returns", "list"],
3652
+ resourcePath: ["returns"],
3653
+ methodName: "list",
3654
+ httpMethod: "GET",
3655
+ path: "/api/v1/returns",
3656
+ summary: "List Returns",
3657
+ flags: [
3658
+ {
3659
+ name: "organizationId",
3660
+ flag: "organization-id",
3661
+ required: false,
3662
+ source: "query"
3663
+ },
3664
+ {
3665
+ name: "marketplace",
3666
+ flag: "marketplace",
3667
+ required: false,
3668
+ source: "query"
3669
+ },
3670
+ {
3671
+ name: "accountId",
3672
+ flag: "account-id",
3673
+ required: false,
3674
+ source: "query"
3675
+ },
3676
+ {
3677
+ name: "externalOrderId",
3678
+ flag: "external-order-id",
3679
+ required: false,
3680
+ source: "query"
3681
+ },
3682
+ {
3683
+ name: "updatedSince",
3684
+ flag: "updated-since",
3685
+ required: false,
3686
+ source: "query"
3687
+ },
3688
+ {
3689
+ name: "cursor",
3690
+ flag: "cursor",
3691
+ required: false,
3692
+ source: "query"
3693
+ },
3694
+ {
3695
+ name: "limit",
3696
+ flag: "limit",
3697
+ required: false,
3698
+ source: "query"
3699
+ }
3700
+ ],
3701
+ acceptsJsonBody: false,
3702
+ acceptsFile: false,
3703
+ bodyRequired: false
3704
+ },
3705
+ {
3706
+ trail: ["returns", "get"],
3707
+ resourcePath: ["returns"],
3708
+ methodName: "get",
3709
+ httpMethod: "GET",
3710
+ path: "/api/v1/returns/{returnId}",
3711
+ summary: "Get Return",
3712
+ flags: [
3713
+ {
3714
+ name: "returnId",
3715
+ flag: "return-id",
3716
+ required: true,
3717
+ source: "path"
3718
+ },
3719
+ {
3720
+ name: "organizationId",
3721
+ flag: "organization-id",
3722
+ required: false,
3723
+ source: "query"
3724
+ }
3725
+ ],
3726
+ acceptsJsonBody: false,
3727
+ acceptsFile: false,
3728
+ bodyRequired: false
3729
+ },
3730
+ {
3731
+ trail: ["returns", "list-actions"],
3732
+ resourcePath: ["returns"],
3733
+ methodName: "listActions",
3734
+ httpMethod: "GET",
3735
+ path: "/api/v1/returns/actions",
3736
+ summary: "Check Return Actions",
3737
+ flags: [
3738
+ {
3739
+ name: "returnIds",
3740
+ flag: "return-ids",
2897
3741
  required: true,
2898
- source: "path"
3742
+ source: "query"
2899
3743
  },
2900
3744
  {
2901
3745
  name: "organizationId",
@@ -2904,57 +3748,39 @@ var COMMANDS = [
2904
3748
  source: "query"
2905
3749
  }
2906
3750
  ],
3751
+ acceptsJsonBody: false,
3752
+ acceptsFile: false,
3753
+ bodyRequired: false
3754
+ },
3755
+ {
3756
+ trail: ["returns", "process"],
3757
+ resourcePath: ["returns"],
3758
+ methodName: "process",
3759
+ httpMethod: "POST",
3760
+ path: "/api/v1/returns/actions",
3761
+ summary: "Process Returns",
3762
+ flags: [],
2907
3763
  acceptsJsonBody: true,
2908
3764
  acceptsFile: false,
2909
3765
  bodyRequired: true
2910
3766
  },
2911
3767
  {
2912
- trail: ["returns", "list"],
3768
+ trail: ["returns", "get-action-jobs"],
2913
3769
  resourcePath: ["returns"],
2914
- methodName: "list",
3770
+ methodName: "getActionJobs",
2915
3771
  httpMethod: "GET",
2916
- path: "/api/v1/returns",
2917
- summary: "List Returns",
3772
+ path: "/api/v1/returns/actions/jobs",
3773
+ summary: "Get Return Action Jobs",
2918
3774
  flags: [
2919
3775
  {
2920
- name: "organizationId",
2921
- flag: "organization-id",
2922
- required: false,
2923
- source: "query"
2924
- },
2925
- {
2926
- name: "marketplace",
2927
- flag: "marketplace",
2928
- required: false,
2929
- source: "query"
2930
- },
2931
- {
2932
- name: "accountId",
2933
- flag: "account-id",
2934
- required: false,
2935
- source: "query"
2936
- },
2937
- {
2938
- name: "externalOrderId",
2939
- flag: "external-order-id",
2940
- required: false,
2941
- source: "query"
2942
- },
2943
- {
2944
- name: "updatedSince",
2945
- flag: "updated-since",
2946
- required: false,
2947
- source: "query"
2948
- },
2949
- {
2950
- name: "cursor",
2951
- flag: "cursor",
2952
- required: false,
3776
+ name: "jobIds",
3777
+ flag: "job-ids",
3778
+ required: true,
2953
3779
  source: "query"
2954
3780
  },
2955
3781
  {
2956
- name: "limit",
2957
- flag: "limit",
3782
+ name: "organizationId",
3783
+ flag: "organization-id",
2958
3784
  required: false,
2959
3785
  source: "query"
2960
3786
  }
@@ -2964,18 +3790,18 @@ var COMMANDS = [
2964
3790
  bodyRequired: false
2965
3791
  },
2966
3792
  {
2967
- trail: ["returns", "get"],
3793
+ trail: ["returns", "list-for-orders"],
2968
3794
  resourcePath: ["returns"],
2969
- methodName: "get",
3795
+ methodName: "listForOrders",
2970
3796
  httpMethod: "GET",
2971
- path: "/api/v1/returns/{returnId}",
2972
- summary: "Get Return",
3797
+ path: "/api/v1/returns/orders",
3798
+ summary: "Get Order Returns",
2973
3799
  flags: [
2974
3800
  {
2975
- name: "returnId",
2976
- flag: "return-id",
3801
+ name: "orderIds",
3802
+ flag: "order-ids",
2977
3803
  required: true,
2978
- source: "path"
3804
+ source: "query"
2979
3805
  },
2980
3806
  {
2981
3807
  name: "organizationId",
@@ -3105,6 +3931,255 @@ var COMMANDS = [
3105
3931
  acceptsFile: false,
3106
3932
  bodyRequired: true
3107
3933
  },
3934
+ {
3935
+ trail: ["scripts", "list"],
3936
+ resourcePath: ["scripts"],
3937
+ methodName: "list",
3938
+ httpMethod: "GET",
3939
+ path: "/api/v1/scripts",
3940
+ summary: "List Organization Scripts",
3941
+ flags: [
3942
+ {
3943
+ name: "organizationId",
3944
+ flag: "organization-id",
3945
+ required: false,
3946
+ source: "query"
3947
+ },
3948
+ {
3949
+ name: "q",
3950
+ flag: "q",
3951
+ required: false,
3952
+ source: "query"
3953
+ },
3954
+ {
3955
+ name: "status",
3956
+ flag: "status",
3957
+ required: false,
3958
+ source: "query"
3959
+ }
3960
+ ],
3961
+ acceptsJsonBody: false,
3962
+ acceptsFile: false,
3963
+ bodyRequired: false
3964
+ },
3965
+ {
3966
+ trail: ["scripts", "create"],
3967
+ resourcePath: ["scripts"],
3968
+ methodName: "create",
3969
+ httpMethod: "POST",
3970
+ path: "/api/v1/scripts",
3971
+ summary: "Create Script",
3972
+ flags: [],
3973
+ acceptsJsonBody: true,
3974
+ acceptsFile: false,
3975
+ bodyRequired: true
3976
+ },
3977
+ {
3978
+ trail: ["scripts", "archive"],
3979
+ resourcePath: ["scripts"],
3980
+ methodName: "archive",
3981
+ httpMethod: "DELETE",
3982
+ path: "/api/v1/scripts/{scriptId}",
3983
+ summary: "Archive Script",
3984
+ flags: [
3985
+ {
3986
+ name: "scriptId",
3987
+ flag: "script-id",
3988
+ required: true,
3989
+ source: "path"
3990
+ },
3991
+ {
3992
+ name: "organizationId",
3993
+ flag: "organization-id",
3994
+ required: false,
3995
+ source: "query"
3996
+ }
3997
+ ],
3998
+ acceptsJsonBody: false,
3999
+ acceptsFile: false,
4000
+ bodyRequired: false
4001
+ },
4002
+ {
4003
+ trail: ["scripts", "get"],
4004
+ resourcePath: ["scripts"],
4005
+ methodName: "get",
4006
+ httpMethod: "GET",
4007
+ path: "/api/v1/scripts/{scriptId}",
4008
+ summary: "Get Script",
4009
+ flags: [
4010
+ {
4011
+ name: "scriptId",
4012
+ flag: "script-id",
4013
+ required: true,
4014
+ source: "path"
4015
+ },
4016
+ {
4017
+ name: "organizationId",
4018
+ flag: "organization-id",
4019
+ required: false,
4020
+ source: "query"
4021
+ }
4022
+ ],
4023
+ acceptsJsonBody: false,
4024
+ acceptsFile: false,
4025
+ bodyRequired: false
4026
+ },
4027
+ {
4028
+ trail: ["scripts", "update"],
4029
+ resourcePath: ["scripts"],
4030
+ methodName: "update",
4031
+ httpMethod: "PATCH",
4032
+ path: "/api/v1/scripts/{scriptId}",
4033
+ summary: "Update Script",
4034
+ flags: [
4035
+ {
4036
+ name: "scriptId",
4037
+ flag: "script-id",
4038
+ required: true,
4039
+ source: "path"
4040
+ }
4041
+ ],
4042
+ acceptsJsonBody: true,
4043
+ acceptsFile: false,
4044
+ bodyRequired: true
4045
+ },
4046
+ {
4047
+ trail: ["scripts", "activate"],
4048
+ resourcePath: ["scripts"],
4049
+ methodName: "activate",
4050
+ httpMethod: "POST",
4051
+ path: "/api/v1/scripts/{scriptId}/activate",
4052
+ summary: "Activate Script Version",
4053
+ flags: [
4054
+ {
4055
+ name: "scriptId",
4056
+ flag: "script-id",
4057
+ required: true,
4058
+ source: "path"
4059
+ }
4060
+ ],
4061
+ acceptsJsonBody: true,
4062
+ acceptsFile: false,
4063
+ bodyRequired: true
4064
+ },
4065
+ {
4066
+ trail: ["scripts", "deploy"],
4067
+ resourcePath: ["scripts"],
4068
+ methodName: "deploy",
4069
+ httpMethod: "POST",
4070
+ path: "/api/v1/scripts/{scriptId}/deploy",
4071
+ summary: "Deploy Script",
4072
+ flags: [
4073
+ {
4074
+ name: "scriptId",
4075
+ flag: "script-id",
4076
+ required: true,
4077
+ source: "path"
4078
+ }
4079
+ ],
4080
+ acceptsJsonBody: true,
4081
+ acceptsFile: false,
4082
+ bodyRequired: true
4083
+ },
4084
+ {
4085
+ trail: ["scripts", "list-runs"],
4086
+ resourcePath: ["scripts"],
4087
+ methodName: "listRuns",
4088
+ httpMethod: "GET",
4089
+ path: "/api/v1/scripts/{scriptId}/runs",
4090
+ summary: "List Script Runs",
4091
+ flags: [
4092
+ {
4093
+ name: "scriptId",
4094
+ flag: "script-id",
4095
+ required: true,
4096
+ source: "path"
4097
+ },
4098
+ {
4099
+ name: "organizationId",
4100
+ flag: "organization-id",
4101
+ required: false,
4102
+ source: "query"
4103
+ },
4104
+ {
4105
+ name: "limit",
4106
+ flag: "limit",
4107
+ required: false,
4108
+ source: "query"
4109
+ }
4110
+ ],
4111
+ acceptsJsonBody: false,
4112
+ acceptsFile: false,
4113
+ bodyRequired: false
4114
+ },
4115
+ {
4116
+ trail: ["scripts", "execute"],
4117
+ resourcePath: ["scripts"],
4118
+ methodName: "execute",
4119
+ httpMethod: "POST",
4120
+ path: "/api/v1/scripts/{scriptId}/runs",
4121
+ summary: "Execute Script",
4122
+ flags: [
4123
+ {
4124
+ name: "scriptId",
4125
+ flag: "script-id",
4126
+ required: true,
4127
+ source: "path"
4128
+ }
4129
+ ],
4130
+ acceptsJsonBody: true,
4131
+ acceptsFile: false,
4132
+ bodyRequired: true
4133
+ },
4134
+ {
4135
+ trail: ["scripts", "get-source"],
4136
+ resourcePath: ["scripts"],
4137
+ methodName: "getSource",
4138
+ httpMethod: "GET",
4139
+ path: "/api/v1/scripts/{scriptId}/source",
4140
+ summary: "Get Script Source",
4141
+ flags: [
4142
+ {
4143
+ name: "scriptId",
4144
+ flag: "script-id",
4145
+ required: true,
4146
+ source: "path"
4147
+ },
4148
+ {
4149
+ name: "organizationId",
4150
+ flag: "organization-id",
4151
+ required: false,
4152
+ source: "query"
4153
+ }
4154
+ ],
4155
+ acceptsJsonBody: false,
4156
+ acceptsFile: false,
4157
+ bodyRequired: false
4158
+ },
4159
+ {
4160
+ trail: ["scripts", "await-runs"],
4161
+ resourcePath: ["scripts"],
4162
+ methodName: "awaitRuns",
4163
+ httpMethod: "POST",
4164
+ path: "/api/v1/scripts/jobs/await",
4165
+ summary: "Read Script Run Results",
4166
+ flags: [],
4167
+ acceptsJsonBody: true,
4168
+ acceptsFile: false,
4169
+ bodyRequired: true
4170
+ },
4171
+ {
4172
+ trail: ["scripts", "cancel-runs"],
4173
+ resourcePath: ["scripts"],
4174
+ methodName: "cancelRuns",
4175
+ httpMethod: "POST",
4176
+ path: "/api/v1/scripts/jobs/cancel",
4177
+ summary: "Cancel Script Runs",
4178
+ flags: [],
4179
+ acceptsJsonBody: true,
4180
+ acceptsFile: false,
4181
+ bodyRequired: true
4182
+ },
3108
4183
  {
3109
4184
  trail: ["search", "list"],
3110
4185
  resourcePath: ["search"],
@@ -3814,7 +4889,7 @@ function printRootHelp(commands) {
3814
4889
 
3815
4890
  Usage:
3816
4891
  omni <resource> <command> [flags]
3817
- omni auth login --api-key omni_sk_...
4892
+ omni auth login
3818
4893
  omni auth status
3819
4894
  omni auth logout
3820
4895
 
@@ -3823,7 +4898,7 @@ ${groups.map((group) => ` ${group}`).join("\n")}
3823
4898
 
3824
4899
  Global flags:
3825
4900
  --api-key <key> API key (or OMNI_API_KEY / omni auth login)
3826
- --base-url <url> API origin (default https://omnicommerce.sg)
4901
+ --base-url <url> API origin (default https://omnicommerce.ai)
3827
4902
  --json <object|-> JSON body, or - to read stdin
3828
4903
  --format json|table Output format (table on TTY, json when piped)
3829
4904
  --dry-run Print the request without sending it
@@ -3838,6 +4913,16 @@ Examples:
3838
4913
  omni jobs wait --job-id prod_123
3839
4914
  `;
3840
4915
  }
4916
+ function printAuthHelp() {
4917
+ return `Usage:
4918
+ omni auth login Sign in using your browser
4919
+ omni auth login --no-browser Print the login URL without opening it
4920
+ omni auth login --api-key <key> Save an existing API key
4921
+ omni auth login --base-url <origin> Sign in to another API origin
4922
+ omni auth status Show saved credential status
4923
+ omni auth logout Remove saved credentials
4924
+ `;
4925
+ }
3841
4926
  function printCommandHelp(command) {
3842
4927
  const flags = command.flags.map((flag) => {
3843
4928
  const req = flag.required ? "required" : "optional";
@@ -3864,9 +4949,6 @@ function matchCommands(commands, trail) {
3864
4949
  return { exact, prefix };
3865
4950
  }
3866
4951
 
3867
- // src/version.ts
3868
- var CLI_VERSION = "0.9.0";
3869
-
3870
4952
  // src/run.ts
3871
4953
  async function readStdin() {
3872
4954
  const chunks = [];
@@ -3898,21 +4980,26 @@ function buildRequest(command, flags, body) {
3898
4980
  }
3899
4981
  return request;
3900
4982
  }
3901
- async function handleAuth(trail, flags) {
4983
+ async function handleAuth(trail, flags, options) {
3902
4984
  const action = trail[1] ?? "status";
3903
4985
  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
4986
  const existing = await readConfig();
3909
- await writeConfig({
3910
- ...existing,
4987
+ const apiKey = flagString(flags, "api-key");
4988
+ const credentials = apiKey ? {
3911
4989
  apiKey,
3912
4990
  baseUrl: flagString(flags, "base-url") ?? existing.baseUrl
4991
+ } : await browserLogin(
4992
+ (await resolveCredentials({
4993
+ baseUrl: flagString(flags, "base-url")
4994
+ })).baseUrl,
4995
+ { ...options, noBrowser: flags["no-browser"] === true }
4996
+ );
4997
+ await writeConfig({
4998
+ ...existing,
4999
+ ...credentials
3913
5000
  });
3914
5001
  process.stdout.write(
3915
- `Saved credentials to config (${maskSecret(apiKey)})
5002
+ `Saved credentials to config (${maskSecret(credentials.apiKey)})
3916
5003
  `
3917
5004
  );
3918
5005
  return 0;
@@ -3922,6 +5009,7 @@ async function handleAuth(trail, flags) {
3922
5009
  process.stdout.write("Removed saved credentials\n");
3923
5010
  return 0;
3924
5011
  }
5012
+ if (action !== "status") throw new Error(`Unknown auth command: ${action}`);
3925
5013
  const resolved = await resolveCredentials({
3926
5014
  apiKey: flagString(flags, "api-key"),
3927
5015
  baseUrl: flagString(flags, "base-url")
@@ -3942,7 +5030,11 @@ async function runCli(argv, options) {
3942
5030
  return 0;
3943
5031
  }
3944
5032
  if (parsed.trail[0] === "auth") {
3945
- return handleAuth(parsed.trail, parsed.flags);
5033
+ if (parsed.help) {
5034
+ process.stdout.write(printAuthHelp());
5035
+ return 0;
5036
+ }
5037
+ return handleAuth(parsed.trail, parsed.flags, options);
3946
5038
  }
3947
5039
  if (parsed.trail.length === 0) {
3948
5040
  process.stdout.write(printRootHelp(COMMANDS));