@omni-commerce/sdk 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -124,6 +124,71 @@ console.log(completed.result?.success, completed.result?.results);
124
124
 
125
125
  Omit `gl` to compare all recorded listing markets; `gl: "sg"` restricts research to Singapore. Global Zalora prices stay separate by country/currency. An India Shopify store selling in SGD is researched in Singapore. Read each product's `markets` array for its price evidence, research, comparison, and errors. Missing published price evidence is an explicit failure; a catalog fallback is never a verified listing price. Client timeouts leave the durable job running. [Full comparison guide](https://docs.omnicommerce.sg/sdk/typescript#market-price-comparison).
126
126
 
127
+ ## Order fulfillment and picking lists
128
+
129
+ Available in SDK 0.18.0. Check choices for an exact batch, submit the reviewed operations, then inspect every returned job. Use `ship`, `cancel`, `labels`, or `update_tracking`; one operation per order is allowed in a batch (1–50). Reading choices and submitting require `orders:write`; job status and picking lists require `orders:read`.
130
+
131
+ ```ts
132
+ const options = await client.orders.listBatchActionOptions({
133
+ orderIds,
134
+ action: "ship",
135
+ });
136
+ // Review options.data.results, choose payloads, and supply required fields.
137
+ // reviewedOperations: [{ orderId, action: "ship", payload: chosenPayload }]
138
+ const queued = await client.orders.processActions({
139
+ requestId: crypto.randomUUID(),
140
+ operations: reviewedOperations,
141
+ });
142
+ if (!queued.data) throw new Error("Missing order job results");
143
+ const progress = await client.orders.getActionJobs({
144
+ jobIds: queued.data.jobIds,
145
+ });
146
+ for (const job of progress.data?.results ?? []) {
147
+ for (const label of job.labels) console.log(label.url);
148
+ }
149
+ const picking = await client.orders.createPickingList(
150
+ { orderIds, timeZone: "Asia/Singapore" },
151
+ { timeoutInSeconds: 120 },
152
+ );
153
+ console.log(picking.data?.downloadUrl, picking.data?.expiresAt);
154
+ const returnRequests = await client.returns.listForOrders({ orderIds });
155
+ ```
156
+
157
+ Use a `labels` operation after shipment completes when the marketplace requires it. Label jobs provide files to download and print; no local printer is controlled. Poll all returned job IDs with backoff while `pendingCount` is positive. Submission success means accepted; job `data.success` means every requested job succeeded. Preserve requestId and unchanged operations for retries. Unsupported marketplace actions remain explicit per-order failures. Picking lists accept up to 500 orders and return a private PDF link valid for five minutes. Missing or inaccessible orders fail the entire picking list. See [Order fulfillment](https://docs.omnicommerce.sg/guides/order-fulfillment).
158
+
159
+ ## Return processing
160
+
161
+ Available in SDK 0.18.0. Use one submission for a single return or up to 50 reviewed decisions. Checking and submitting require `orders:write`; job status requires `orders:read`.
162
+
163
+ ```ts
164
+ // returnIds are OmniCommerce return UUIDs, not order IDs.
165
+ const checked = await client.returns.listActions({ returnIds });
166
+ // selectedDecisions comes from your review UI: [{ returnId, actionId }].
167
+ const operations = selectedDecisions.map((selected) => {
168
+ const result = checked.data?.results.find(
169
+ (item) => item.returnId === selected.returnId,
170
+ );
171
+ if (
172
+ !result?.success ||
173
+ !result.actions.some((a) => a.id === selected.actionId)
174
+ ) {
175
+ throw new Error("Refresh and review this return before processing it");
176
+ }
177
+ return { ...selected, version: result.version };
178
+ });
179
+ const queued = await client.returns.process({
180
+ requestId: crypto.randomUUID(), // retain this key for safe retries
181
+ operations,
182
+ });
183
+ if (!queued.data) throw new Error("Missing return job results");
184
+ const progress = await client.returns.getActionJobs({
185
+ jobIds: queued.data.jobIds,
186
+ });
187
+ console.log(progress.data);
188
+ ```
189
+
190
+ An empty actions array means no current seller decision, including completed or cancelled returns. Read `limitation` for unsupported marketplace operations. Keep the same request key and operations after a transport failure. Check **every** returned job ID with backoff until `pendingCount` is zero; only `data.success: true` confirms all selected decisions succeeded. `needs_review` requires checking marketplace state before another decision. A processed decision may still leave later steps in the buyer return lifecycle. See [Return processing](https://docs.omnicommerce.sg/guides/return-processing).
191
+
127
192
  ## Batch publish, delist, and update
128
193
 
129
194
  ```ts
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ function normalizeClientOptions(options = {}) {
35
35
  }
36
36
 
37
37
  // src/version.ts
38
- var SDK_VERSION = "0.17.0";
38
+ var SDK_VERSION = "0.18.0";
39
39
  var SDK_USER_AGENT = `omnicommerce-js/${SDK_VERSION}`;
40
40
 
41
41
  // src/environments.ts
@@ -1278,6 +1278,86 @@ var AopClient = class {
1278
1278
  });
1279
1279
  }
1280
1280
  };
1281
+ var ApiClient = class {
1282
+ constructor(_http) {
1283
+ __publicField(this, "_http", _http);
1284
+ }
1285
+ /**
1286
+ * Discover a published merchant agent
1287
+ *
1288
+ * A2A 1.0 Agent Card for any configured agent published to a customer deployment. Private model settings, prompts and publisher identity are excluded.
1289
+ *
1290
+ * `GET /api/embed/{deploymentId}/.well-known/agent-card.json`
1291
+ */
1292
+ getEmbedwellKnownagentCardJson(request, requestOptions) {
1293
+ const { deploymentId } = request ?? {};
1294
+ return this._http.request({
1295
+ method: "GET",
1296
+ path: `/api/embed/${encodePathParam("deploymentId", deploymentId)}/.well-known/agent-card.json`,
1297
+ query: void 0,
1298
+ body: void 0,
1299
+ ...mergeRequestOptions(requestOptions)
1300
+ });
1301
+ }
1302
+ /**
1303
+ * Call a merchant agent using A2A
1304
+ *
1305
+ * Official A2A 1.0 JSON-RPC SendMessage, GetTask and CancelTask.
1306
+
1307
+ ### Authentication
1308
+
1309
+ Uses the existing customer JWT from /api/embed/{deploymentId}/session; send the same Origin when creating and using the session.
1310
+
1311
+ ### Messages
1312
+
1313
+ SendMessage accepts text user messages with a UUID messageId and up to 4000 characters. For asynchronous execution set configuration.returnImmediately=true and retrieve the task. Every task is bound to the customer session.
1314
+
1315
+ Bot verification and storefront protection apply. Payment proofs belong in the checkout completion endpoint, outside model messages.
1316
+
1317
+ ### Signed offers and buyer agents
1318
+
1319
+ Payable offers in purchase-offers artifacts include checkoutJwt when the platform signing key is configured. Requests may carry a Web Bot Auth signature; the verified agent orig
1320
+ *
1321
+ * `POST /api/embed/{deploymentId}/a2a`
1322
+ */
1323
+ embeda2a(request, requestOptions) {
1324
+ const { deploymentId, ...body } = request ?? {};
1325
+ return this._http.request({
1326
+ method: "POST",
1327
+ path: `/api/embed/${encodePathParam("deploymentId", deploymentId)}/a2a`,
1328
+ query: void 0,
1329
+ body,
1330
+ ...mergeRequestOptions(requestOptions)
1331
+ });
1332
+ }
1333
+ /**
1334
+ * Manage customer-owned purchase offers
1335
+ *
1336
+ * ### Operations
1337
+
1338
+ create: offers[] (1–5), with stable requestId, exact purchasable product/variant IDs, quantities, shipping country and optional unitAmount proposals. get/cancel: sessionIds[] (1–20). complete: sessionId, paymentProof, and buyer approval of cartVersion, totalAmount and currency. pay: sessionId and the same exact approval; returns checkoutUrl for Stripe-hosted card entry.
1339
+
1340
+ ### Results and safeguards
1341
+
1342
+ Batches return ordered per-target results, succeededCount and failedCount. At most ten unpaid offers may be held per customer. Merchant-approved currency, countries, shipping and tax terms are required. Shopify-listed products return the supported Shopify checkout handoff.
1343
+
1344
+ ### Payment
1345
+
1346
+ Completion reuses the existing Stripe ACP or x402 rail. Hosted card checkout requires this org
1347
+ *
1348
+ * `POST /api/embed/{deploymentId}/checkout-sessions/{operation}`
1349
+ */
1350
+ embedcheckoutSessions(request, requestOptions) {
1351
+ const { deploymentId, operation, ...body } = request ?? {};
1352
+ return this._http.request({
1353
+ method: "POST",
1354
+ path: `/api/embed/${encodePathParam("deploymentId", deploymentId)}/checkout-sessions/${encodePathParam("operation", operation)}`,
1355
+ query: void 0,
1356
+ body,
1357
+ ...mergeRequestOptions(requestOptions)
1358
+ });
1359
+ }
1360
+ };
1281
1361
  var BrandKitsClient = class {
1282
1362
  constructor(_http) {
1283
1363
  __publicField(this, "_http", _http);
@@ -1657,7 +1737,7 @@ var CheckoutSessionsClient = class {
1657
1737
  /**
1658
1738
  * Complete Agentic Checkout Session
1659
1739
  *
1660
- * Settle the selected rail and create a native `agentic` order. Settlement failures return 402 and leave the session in `ready_for_payment`.
1740
+ * Settle the selected rail and create a native `agentic` order. Definitive settlement failures return 402. Pending confirmation locks the offer in `payment_pending`; durable recovery resumes the same attempt.
1661
1741
  *
1662
1742
  * `POST /api/v1/checkout-sessions/{sessionId}/complete`
1663
1743
  */
@@ -2376,6 +2456,104 @@ var OrdersClient = class {
2376
2456
  ...mergeRequestOptions(requestOptions)
2377
2457
  });
2378
2458
  }
2459
+ /**
2460
+ * Check Order Action Options
2461
+ *
2462
+ * ### Authorization
2463
+
2464
+ Requires orders:write.
2465
+
2466
+ ### Choices
2467
+
2468
+ Read current marketplace choices for ship, cancel, labels or update_tracking for 1–50 order UUIDs using repeated orderIds query parameters. The shared order service checks status, store connection and marketplace capability. Results preserve first-requested order, with explicit per-order errors. Use the exact choice payload and supply any fields marked requiresInput. An unsupported marketplace operation is an explicit failure, not a silently skipped order. Ship arranges shipment; labels generates printable files. Fulfillment behavior is identical to the existing single-order API and workspace UI.
2469
+ *
2470
+ * `GET /api/v1/orders/actions`
2471
+ */
2472
+ listBatchActionOptions(request, requestOptions) {
2473
+ const { orderIds, action, organizationId } = request ?? {};
2474
+ return this._http.request({
2475
+ method: "GET",
2476
+ path: "/api/v1/orders/actions",
2477
+ query: { orderIds, action, organizationId },
2478
+ body: void 0,
2479
+ ...mergeRequestOptions(requestOptions)
2480
+ });
2481
+ }
2482
+ /**
2483
+ * Process Order Actions
2484
+ *
2485
+ * ### Authorization
2486
+
2487
+ Requires orders:write.
2488
+
2489
+ ### Batch submission
2490
+
2491
+ Queue 1–50 distinct order operations with a UUID requestId. Each operation has orderId, action (ship, cancel, labels or update_tracking), and optional payload. Use exact marketplace choices from GET /api/v1/orders/actions and supply required carrier, tracking, pickup/drop-off or cancellation details. One operation per order is allowed in a batch; later stages such as labels after shipment require another submission. All targets are authorized before any enqueue. Per-order failures are isolated; results retain request order and include every accepted jobId. data.success means all submissions were accepted, not that marketplace processing finished.
2492
+
2493
+ ### Recovery and completion
2494
+
2495
+ Retain requestId and unchanged operations for retr
2496
+ *
2497
+ * `POST /api/v1/orders/actions`
2498
+ */
2499
+ processActions(request, requestOptions) {
2500
+ const { ...body } = request ?? {};
2501
+ return this._http.request({
2502
+ method: "POST",
2503
+ path: "/api/v1/orders/actions",
2504
+ query: void 0,
2505
+ body,
2506
+ ...mergeRequestOptions(requestOptions)
2507
+ });
2508
+ }
2509
+ /**
2510
+ * Get Order Action Jobs
2511
+ *
2512
+ * ### Authorization
2513
+
2514
+ Requires orders:read.
2515
+
2516
+ ### Outcomes and labels
2517
+
2518
+ Read every requested order action job in one batch of 1–50 UUIDs using repeated jobIds parameters. Results preserve first-requested order. data.success is true only when every requested job succeeded; failedCount includes failed and not_supported, while pendingCount includes queued and running. Successful label jobs contain downloadable files in labels[]. A missing or cross-organization job returns 404; current store restrictions apply to all targets. The top-level completed status describes the lookup, not job completion. No raw provider acknowledgements are exposed.
2519
+ *
2520
+ * `GET /api/v1/orders/actions/jobs`
2521
+ */
2522
+ getActionJobs(request, requestOptions) {
2523
+ const { jobIds, organizationId } = request ?? {};
2524
+ return this._http.request({
2525
+ method: "GET",
2526
+ path: "/api/v1/orders/actions/jobs",
2527
+ query: { jobIds, organizationId },
2528
+ body: void 0,
2529
+ ...mergeRequestOptions(requestOptions)
2530
+ });
2531
+ }
2532
+ /**
2533
+ * Create Picking List
2534
+ *
2535
+ * ### Authorization
2536
+
2537
+ Requires orders:read. API keys resolve organization scope from their credential; session callers include organizationId.
2538
+
2539
+ ### PDF output
2540
+
2541
+ Create a private PDF picking list for 1–500 order UUIDs, trimmed and deduplicated in first-requested order. Missing or inaccessible orders fail the complete selection without creating a partial document. The same grouping, product quantities, SKU/variation and currency-labeled prices as the workspace Orders page are used. timeZone accepts an IANA time zone; omitted API requests use UTC. This does not arrange shipment or change orders.
2542
+
2543
+ The result contains structured list data, every orderId, a saved documentId and a signed HTTPS downloadUrl valid until expiresAt (five minutes). Generate a fresh list for a new download URL. Download the
2544
+ *
2545
+ * `POST /api/v1/orders/picking-list`
2546
+ */
2547
+ createPickingList(request, requestOptions) {
2548
+ const { ...body } = request ?? {};
2549
+ return this._http.request({
2550
+ method: "POST",
2551
+ path: "/api/v1/orders/picking-list",
2552
+ query: void 0,
2553
+ body,
2554
+ ...mergeRequestOptions(requestOptions)
2555
+ });
2556
+ }
2379
2557
  };
2380
2558
  var OrganizationsClient = class {
2381
2559
  constructor(_http) {
@@ -3336,6 +3514,96 @@ var ReturnsClient = class {
3336
3514
  ...mergeRequestOptions(requestOptions)
3337
3515
  });
3338
3516
  }
3517
+ /**
3518
+ * Check Return Actions
3519
+ *
3520
+ * ### Authorization
3521
+
3522
+ Requires orders:write.
3523
+
3524
+ ### Eligibility
3525
+
3526
+ Read live marketplace decisions for 1–50 OmniCommerce return UUIDs using repeated returnIds query parameters. Refreshes the saved return state through the same service as the order UI. All targets are organization- and store-scoped before marketplace access. Results preserve first-requested order; one provider failure does not block another store. data.success describes eligibility checks, not whether an action is available. Completed, cancelled and other terminal returns have no actions. Check actions.length and limitation; never infer eligibility from status alone. Amazon and WhatsApp currently return explicit processing limitations. Other marketplaces expose only decisions supported by their current API state. No buyer remarks,
3527
+ *
3528
+ * `GET /api/v1/returns/actions`
3529
+ */
3530
+ listActions(request, requestOptions) {
3531
+ const { returnIds, organizationId } = request ?? {};
3532
+ return this._http.request({
3533
+ method: "GET",
3534
+ path: "/api/v1/returns/actions",
3535
+ query: { returnIds, organizationId },
3536
+ body: void 0,
3537
+ ...mergeRequestOptions(requestOptions)
3538
+ });
3539
+ }
3540
+ /**
3541
+ * Process Returns
3542
+ *
3543
+ * ### Authorization
3544
+
3545
+ Requires orders:write.
3546
+
3547
+ ### Submit decisions
3548
+
3549
+ Queue 1–50 selected return decisions, including a one-element batch for a single return. Use only actionId/version pairs from a fresh eligibility check. Identical duplicate return operations are deduplicated in first-requested order; conflicting duplicates are rejected. requestId is a UUID idempotency key: retry the same key and unchanged operations after a transport failure. An active matching decision is reused; conflicting active decisions return 409. Returns HTTP 202 with every returnId and jobId. The durable worker rechecks current permissions, store identity, eligibility and version immediately before writing, then verifies the marketplace result. Follow links.poll or GET /api/v1/returns/actions/jobs with every jobIds e
3550
+ *
3551
+ * `POST /api/v1/returns/actions`
3552
+ */
3553
+ process(request, requestOptions) {
3554
+ const { ...body } = request ?? {};
3555
+ return this._http.request({
3556
+ method: "POST",
3557
+ path: "/api/v1/returns/actions",
3558
+ query: void 0,
3559
+ body,
3560
+ ...mergeRequestOptions(requestOptions)
3561
+ });
3562
+ }
3563
+ /**
3564
+ * Get Return Action Jobs
3565
+ *
3566
+ * ### Authorization
3567
+
3568
+ Requires orders:read.
3569
+
3570
+ ### Job outcomes
3571
+
3572
+ Read the current state of 1–50 return-processing job UUIDs in one request using repeated jobIds parameters. Use every job ID returned by submission. Results preserve first-requested order. pendingCount counts queued, running and submitting; succeededCount counts succeeded; failedCount includes failed and needs_review. data.success is true only if every requested job succeeded. The top-level completed status refers to this lookup, not to the jobs. Missing or cross-organization jobs return 404; jobs outside assigned stores are forbidden. Evidence contains accepted/verified flags and before/after marketplace statuses, without raw provider payloads.
3573
+ *
3574
+ * `GET /api/v1/returns/actions/jobs`
3575
+ */
3576
+ getActionJobs(request, requestOptions) {
3577
+ const { jobIds, organizationId } = request ?? {};
3578
+ return this._http.request({
3579
+ method: "GET",
3580
+ path: "/api/v1/returns/actions/jobs",
3581
+ query: { jobIds, organizationId },
3582
+ body: void 0,
3583
+ ...mergeRequestOptions(requestOptions)
3584
+ });
3585
+ }
3586
+ /**
3587
+ * Get Order Returns
3588
+ *
3589
+ * Requires orders:read. Read stored return requests for 1–50 order UUIDs using repeated orderIds query parameters.
3590
+
3591
+ ### Return identity
3592
+
3593
+ Results preserve first-requested order and include distinct active and historical return requests. processingEligible is a local candidate flag, not live eligibility. Pass returnId values to GET /api/v1/returns/actions before choosing a decision. Every order is authorized before reading returns, including store restrictions; no buyer data is exposed.
3594
+ *
3595
+ * `GET /api/v1/returns/orders`
3596
+ */
3597
+ listForOrders(request, requestOptions) {
3598
+ const { orderIds, organizationId } = request ?? {};
3599
+ return this._http.request({
3600
+ method: "GET",
3601
+ path: "/api/v1/returns/orders",
3602
+ query: { orderIds, organizationId },
3603
+ body: void 0,
3604
+ ...mergeRequestOptions(requestOptions)
3605
+ });
3606
+ }
3339
3607
  };
3340
3608
  var ReviewsClient = class {
3341
3609
  constructor(_http) {
@@ -3930,6 +4198,7 @@ var OmniGeneratedClient = class {
3930
4198
  __publicField(this, "agents");
3931
4199
  __publicField(this, "analytics");
3932
4200
  __publicField(this, "aop");
4201
+ __publicField(this, "api");
3933
4202
  __publicField(this, "brandKits");
3934
4203
  __publicField(this, "brandsgateway");
3935
4204
  __publicField(this, "campaigns");
@@ -3967,6 +4236,7 @@ var OmniGeneratedClient = class {
3967
4236
  this.agents = new AgentsClient(this._http);
3968
4237
  this.analytics = new AnalyticsClient(this._http);
3969
4238
  this.aop = new AopClient(this._http);
4239
+ this.api = new ApiClient(this._http);
3970
4240
  this.brandKits = new BrandKitsClient(this._http);
3971
4241
  this.brandsgateway = new BrandsgatewayClient(this._http);
3972
4242
  this.campaigns = new CampaignsClient(this._http);