@omni-commerce/sdk 0.27.0 → 0.29.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 +2 -2
- package/dist/index.cjs +49 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -272
- package/dist/index.d.ts +73 -272
- package/dist/index.js +49 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -260,7 +260,7 @@ const filters = {
|
|
|
260
260
|
const count = await client.products.count(filters);
|
|
261
261
|
console.log(count.count, count.unit); // catalog_products
|
|
262
262
|
|
|
263
|
-
// Download records only when needed. Each chunk defaults to one page (up to
|
|
263
|
+
// Download records only when needed. Each chunk defaults to one page (up to 20 rows).
|
|
264
264
|
const chunk = await client.products.scan(filters, {
|
|
265
265
|
maxPages: 1,
|
|
266
266
|
onProgress: async (progress, items) => {
|
|
@@ -276,7 +276,7 @@ const chunk = await client.products.scan(filters, {
|
|
|
276
276
|
|
|
277
277
|
Continuation requests retain the original filters, use a server cursor when available, and otherwise use `nextOffset`. The cursor is bound to the credential organization and filter scope; resume under the same scope. Default `created_desc` order without search supports cursors. Other sorts use offsets and can shift if the catalog changes. Scans are not immutable database snapshots. Never persist API keys with a checkpoint. Per-request timeouts, retry settings and cancellation use the normal request options.
|
|
278
278
|
|
|
279
|
-
For manual paging, `products.list(
|
|
279
|
+
For manual paging, `products.list(filters)` returns 20 rows per page. Follow `pagination.nextCursor` (default and `updated_desc` sorts without `q`); other sorts and searches page by `nextOffset` up to `pagination.maxOffset` (1000). Counts are omitted unless you pass `includeSummary: true`; `products.count(filters)` returns a count alone.
|
|
280
280
|
|
|
281
281
|
## Resources
|
|
282
282
|
|
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.
|
|
38
|
+
var SDK_VERSION = "0.29.0";
|
|
39
39
|
var SDK_USER_AGENT = `omnicommerce-js/${SDK_VERSION}`;
|
|
40
40
|
|
|
41
41
|
// src/environments.ts
|
|
@@ -465,7 +465,7 @@ function encodePathParam(name, value) {
|
|
|
465
465
|
var ProductScanError = class extends Error {
|
|
466
466
|
constructor(partial, cause) {
|
|
467
467
|
super(
|
|
468
|
-
"Product scan failed. Resume from partial.next after saving partial.items."
|
|
468
|
+
partial.next ? "Product scan failed. Resume from partial.next after saving partial.items." : "Product scan failed. See the cause and the pages saved in partial.items."
|
|
469
469
|
);
|
|
470
470
|
__publicField(this, "partial", partial);
|
|
471
471
|
__publicField(this, "cause", cause);
|
|
@@ -478,13 +478,14 @@ async function scanProducts(list, request, options = {}) {
|
|
|
478
478
|
throw new RangeError("maxPages must be an integer between 1 and 100.");
|
|
479
479
|
if ("queryParams" in requestOptions)
|
|
480
480
|
throw new TypeError("Pass scan filters in the request, not queryParams.");
|
|
481
|
-
let next = {
|
|
481
|
+
let next = { ...request };
|
|
482
482
|
const items = [];
|
|
483
483
|
let pagesRead = 0;
|
|
484
|
+
let complete = false;
|
|
484
485
|
const progress = () => ({
|
|
485
486
|
pagesRead,
|
|
486
487
|
itemsRead: items.length,
|
|
487
|
-
complete
|
|
488
|
+
complete,
|
|
488
489
|
next: next ? { ...next } : null
|
|
489
490
|
});
|
|
490
491
|
try {
|
|
@@ -499,19 +500,29 @@ async function scanProducts(list, request, options = {}) {
|
|
|
499
500
|
if (!Array.isArray(page.items) || typeof pagination?.hasMore !== "boolean")
|
|
500
501
|
throw new Error("Invalid product page response.");
|
|
501
502
|
if (pagination.hasMore) {
|
|
502
|
-
if (!page.items.length
|
|
503
|
+
if (!page.items.length)
|
|
503
504
|
throw new Error("Product pagination did not advance.");
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
505
|
+
const scope = { ...current };
|
|
506
|
+
delete scope.cursor;
|
|
507
|
+
delete scope.offset;
|
|
508
|
+
if (typeof pagination.nextCursor === "string" && pagination.nextCursor) {
|
|
509
|
+
if (pagination.nextCursor === current.cursor)
|
|
510
|
+
throw new Error("Product pagination did not advance.");
|
|
511
|
+
next = { ...scope, cursor: pagination.nextCursor };
|
|
512
|
+
} else if (Number.isInteger(pagination.nextOffset)) {
|
|
513
|
+
if (pagination.nextOffset <= (current.offset ?? 0))
|
|
514
|
+
throw new Error("Product pagination did not advance.");
|
|
515
|
+
next = { ...scope, offset: pagination.nextOffset };
|
|
516
|
+
} else next = null;
|
|
511
517
|
} else next = null;
|
|
518
|
+
complete = !pagination.hasMore;
|
|
512
519
|
items.push(...page.items);
|
|
513
520
|
pagesRead++;
|
|
514
521
|
await onProgress?.(progress(), [...page.items]);
|
|
522
|
+
if (!next && !complete)
|
|
523
|
+
throw new Error(
|
|
524
|
+
"Product pagination reached maxOffset. Scan with sortBy created_desc or updated_desc and no q to use a cursor, or narrow the filters."
|
|
525
|
+
);
|
|
515
526
|
}
|
|
516
527
|
return { ...progress(), items };
|
|
517
528
|
} catch (cause) {
|
|
@@ -712,7 +723,13 @@ var AgentsGeneralClient = class {
|
|
|
712
723
|
*
|
|
713
724
|
* Run the general Omni agent and wait until it completes, pauses for approval, or fails. Requires `agents:invoke`.
|
|
714
725
|
|
|
715
|
-
|
|
726
|
+
### Waiting and approvals
|
|
727
|
+
|
|
728
|
+
A waiting call can take several minutes; raise the client timeout. Send `decisions` with the same `thread_id` to approve or reject a paused run.
|
|
729
|
+
|
|
730
|
+
### Messages and tools
|
|
731
|
+
|
|
732
|
+
Omit `config.enabled_tools` to use the organization's agent tools. Send only new messages on each turn; thread_id continues the conversation stored in Omni sessions and checkpoints. Omit thread_id for a new conversation. Optional message IDs use native LangGraph replacement semantics, not run idempotency. audience=customer restricts tools to public storefront access without establishing a verified customer identity. Attach images on the latest user message as `{ type: "image", url }`
|
|
716
733
|
*
|
|
717
734
|
* `POST /api/v1/agents/general/invoke`
|
|
718
735
|
*/
|
|
@@ -772,9 +789,13 @@ var AgentsClient = class {
|
|
|
772
789
|
*
|
|
773
790
|
* Invoke the exact built-in or custom agent in the URL using its saved configuration and Programmatic starting mode. Uses the same invocation request and run response as the general agent and MCP.
|
|
774
791
|
|
|
792
|
+
### Authorization
|
|
793
|
+
|
|
775
794
|
Requires agents:invoke and current organization membership and agent access. Organization-owned keys use their recorded creator; no alternate organization member is substituted. Session requests include organizationId.
|
|
776
795
|
|
|
777
|
-
|
|
796
|
+
### Messages and conversation history
|
|
797
|
+
|
|
798
|
+
Send one or more new messages (at most 50 and 100000 text characters) ending with a user message. Omit thread_id to create a conversation, or reuse the returned thread_id to continue its stored history. An initial batch can import external history, including human replies. Do not resend history on subsequent turns. Optional
|
|
778
799
|
*
|
|
779
800
|
* `POST /api/v1/agents/{agentId}/invoke`
|
|
780
801
|
*/
|
|
@@ -788,29 +809,6 @@ var AgentsClient = class {
|
|
|
788
809
|
...mergeRequestOptions(requestOptions)
|
|
789
810
|
});
|
|
790
811
|
}
|
|
791
|
-
/**
|
|
792
|
-
* Invoke a saved agent (alias)
|
|
793
|
-
*
|
|
794
|
-
* Alias of /agents/{agentId}/invoke with the identical request and response. Prefer /invoke.
|
|
795
|
-
|
|
796
|
-
Invoke the exact built-in or custom agent in the URL using its saved configuration and Programmatic starting mode. Uses the same invocation request and run response as the general agent and MCP.
|
|
797
|
-
|
|
798
|
-
Requires agents:invoke and current organization membership and agent access. Organization-owned keys use their recorded creator; no alternate organization member is substituted. Session requests include organizationId.
|
|
799
|
-
|
|
800
|
-
Send one or more new messages (at most 50 and 100000 text characters) ending with a user message. Omit thread_id to create a conversation, or reuse the returned thread_id to continue its stored history. An initial batch can import external history, including human replies. Do not resend hist
|
|
801
|
-
*
|
|
802
|
-
* `POST /api/v1/agents/{agentId}/messages`
|
|
803
|
-
*/
|
|
804
|
-
messages(request, requestOptions) {
|
|
805
|
-
const { agentId, ...body } = request ?? {};
|
|
806
|
-
return this._http.request({
|
|
807
|
-
method: "POST",
|
|
808
|
-
path: `/api/v1/agents/${encodePathParam("agentId", agentId)}/messages`,
|
|
809
|
-
query: void 0,
|
|
810
|
-
body,
|
|
811
|
-
...mergeRequestOptions(requestOptions)
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
812
|
/**
|
|
815
813
|
* Start a saved agent run
|
|
816
814
|
*
|
|
@@ -818,9 +816,13 @@ var AgentsClient = class {
|
|
|
818
816
|
|
|
819
817
|
Invoke the exact built-in or custom agent in the URL using its saved configuration and Programmatic starting mode. Uses the same invocation request and run response as the general agent and MCP.
|
|
820
818
|
|
|
819
|
+
### Authorization
|
|
820
|
+
|
|
821
821
|
Requires agents:invoke and current organization membership and agent access. Organization-owned keys use their recorded creator; no alternate organization member is substituted. Session requests include organizationId.
|
|
822
822
|
|
|
823
|
-
|
|
823
|
+
### Messages and conversation history
|
|
824
|
+
|
|
825
|
+
Send one or more new messages (at most 50 and 100000 text characters) ending with a user message. Omit thread_id to create a conversation, or reuse the returned thread_id to continue its stored history. An initial batch can
|
|
824
826
|
*
|
|
825
827
|
* `POST /api/v1/agents/{agentId}/runs`
|
|
826
828
|
*/
|
|
@@ -2959,7 +2961,8 @@ var OrdersClient = class {
|
|
|
2959
2961
|
dateFrom,
|
|
2960
2962
|
dateTo,
|
|
2961
2963
|
limit,
|
|
2962
|
-
offset
|
|
2964
|
+
offset,
|
|
2965
|
+
includeSummary
|
|
2963
2966
|
} = request ?? {};
|
|
2964
2967
|
return this._http.request({
|
|
2965
2968
|
method: "GET",
|
|
@@ -2976,7 +2979,8 @@ var OrdersClient = class {
|
|
|
2976
2979
|
dateFrom,
|
|
2977
2980
|
dateTo,
|
|
2978
2981
|
limit,
|
|
2979
|
-
offset
|
|
2982
|
+
offset,
|
|
2983
|
+
includeSummary
|
|
2980
2984
|
},
|
|
2981
2985
|
body: void 0,
|
|
2982
2986
|
...mergeRequestOptions(requestOptions)
|
|
@@ -2999,9 +3003,9 @@ var OrdersClient = class {
|
|
|
2999
3003
|
|
|
3000
3004
|
### Pricing and catalog defaults
|
|
3001
3005
|
|
|
3002
|
-
- Each line can provide `
|
|
3006
|
+
- Each line can provide `unitPrice`, `paidPrice`, and `costPrice`.
|
|
3003
3007
|
- When `productId` is provided, missing price or currency values may resolve from the product catalog.
|
|
3004
|
-
- An explicit `costPrice` updates `product_data.costPrice` and is
|
|
3008
|
+
- An explicit `costPrice` updates `product_data.costPrice` and is snapshotted on
|
|
3005
3009
|
*
|
|
3006
3010
|
* `POST /api/v1/orders`
|
|
3007
3011
|
*/
|
|
@@ -3411,7 +3415,7 @@ var ProductsClient = class {
|
|
|
3411
3415
|
/**
|
|
3412
3416
|
* List Products
|
|
3413
3417
|
*
|
|
3414
|
-
* List products for the authenticated organization with optional filters and pagination.
|
|
3418
|
+
* List products for the authenticated organization with optional filters and pagination. Requires `catalog:read`. The organization comes from the API key or OAuth bearer token.
|
|
3415
3419
|
|
|
3416
3420
|
### Stock and variants
|
|
3417
3421
|
|
|
@@ -3419,7 +3423,7 @@ var ProductsClient = class {
|
|
|
3419
3423
|
|
|
3420
3424
|
### Duplicate discovery and merge
|
|
3421
3425
|
|
|
3422
|
-
Use status=duplicates, duplicateType=sku and detail=full for exact-SKU candidates. Each root
|
|
3426
|
+
Use status=duplicates, duplicateType=sku and detail=full for exact-SKU candidates. Each root row includes duplicateMatches with peer prod
|
|
3423
3427
|
*
|
|
3424
3428
|
* `GET /api/v1/products`
|
|
3425
3429
|
*/
|
|
@@ -3433,7 +3437,6 @@ var ProductsClient = class {
|
|
|
3433
3437
|
minPrice,
|
|
3434
3438
|
maxPrice,
|
|
3435
3439
|
sortBy,
|
|
3436
|
-
limit,
|
|
3437
3440
|
offset,
|
|
3438
3441
|
store,
|
|
3439
3442
|
storeKeys,
|
|
@@ -3463,7 +3466,6 @@ var ProductsClient = class {
|
|
|
3463
3466
|
minPrice,
|
|
3464
3467
|
maxPrice,
|
|
3465
3468
|
sortBy,
|
|
3466
|
-
limit,
|
|
3467
3469
|
offset,
|
|
3468
3470
|
store,
|
|
3469
3471
|
storeKeys,
|
|
@@ -3737,7 +3739,7 @@ var ProductsClient = class {
|
|
|
3737
3739
|
|
|
3738
3740
|
Supply targetMarketplaces and marketplaceStoreSelections to prepare for specific connected stores. Set deferStoreSelection=true to choose marketplaces only and assign stores later with POST /api/v1/products/marketplace-stores. Omit marketplaceStoreSelections and leave workflow.publish off when deferring. Automatic publishing requires catalog:sync in addition to catalog:write.
|
|
3739
3741
|
|
|
3740
|
-
Supply explicit SKU options in each row's `variationAttributes` and native marketplace attributes in `marketplaceAttributes`.
|
|
3742
|
+
Supply explicit SKU options in each row's `variationAttributes` and native marketplace attributes in `marketplaceAttributes`. Taxonomy enrichment can propose missing required sale attributes in its existing attribute request when supported by product evidence. Supplied values take precedence. At Zalora publish time, a missing required
|
|
3741
3743
|
*
|
|
3742
3744
|
* `POST /api/v1/products/bulk-import`
|
|
3743
3745
|
*/
|