@01.software/sdk 0.32.0 → 0.33.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 +43 -20
- package/dist/client.cjs +31 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +31 -2
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-DPGXnhoF.d.ts → collection-client-B6SlhzIP.d.ts} +3 -3
- package/dist/{collection-client-CORhppPb.d.cts → collection-client-De6eKW1J.d.cts} +3 -3
- package/dist/{const-Brk2Ff0q.d.cts → const-DwmSDeWq.d.ts} +2 -2
- package/dist/{const-DcY2_z9O.d.ts → const-sPR2IkCe.d.cts} +2 -2
- package/dist/index.cjs +256 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +256 -90
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DVK1QCeU.d.cts → payload-types-dkeQyrDC.d.cts} +1562 -1436
- package/dist/{payload-types-DVK1QCeU.d.ts → payload-types-dkeQyrDC.d.ts} +1562 -1436
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +9 -9
- package/dist/query.d.ts +9 -9
- package/dist/query.js.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/server.cjs +37 -6
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.js +37 -6
- package/dist/server.js.map +1 -1
- package/dist/{types-ByMrR_Z_.d.cts → types-B3YT092I.d.cts} +1 -1
- package/dist/{types-CYMSBkJC.d.ts → types-BHh0YLmq.d.ts} +27 -10
- package/dist/{types-CAkWqIr6.d.cts → types-BZKxss8Y.d.cts} +27 -10
- package/dist/{types-DUPC7Xn6.d.ts → types-Cel_4L9t.d.ts} +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.cjs +94 -0
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +82 -7
- package/dist/webhook.d.ts +82 -7
- package/dist/webhook.js +94 -0
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/dist/server.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { S as ServerCollectionClient } from './collection-client-
|
|
2
|
-
export { C as CollectionClient } from './collection-client-
|
|
3
|
-
import { B as BaseApi,
|
|
4
|
-
import { i as Cart, j as CartItem, O as Order, m as Transaction, n as Fulfillment, o as Return } from './payload-types-
|
|
1
|
+
import { S as ServerCollectionClient } from './collection-client-De6eKW1J.cjs';
|
|
2
|
+
export { C as CollectionClient } from './collection-client-De6eKW1J.cjs';
|
|
3
|
+
import { B as BaseApi, aU as ServerApiOptions, aX as StockCheckParams, aY as StockCheckResponse, _ as ListingGroupsParams, av as ProductListingGroupsResponse, ad as ProductDetailParams, ae as ProductDetailResult, bo as ProductDetailPreviewParams, bp as ProductDetailPreviewOptions, a4 as ProductDetail, bq as ProductUpsertParams, br as ProductUpsertResponse, k as AddItemParams, a$ as UpdateItemParams, aO as RemoveItemParams, l as ApplyDiscountParams, aN as RemoveDiscountParams, t as ClearCartParams, s as CheckoutParams, H as CreateOrderParams, b0 as UpdateOrderParams, b3 as UpdateTransactionParams, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, a_ as UpdateFulfillmentParams, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, I as CreateReturnParams, b2 as UpdateReturnParams, aT as ReturnWithRefundParams, b4 as ValidateDiscountParams, b5 as ValidateDiscountResult, o as CalculateShippingParams, p as CalculateShippingResult, a as CommunityClient, c as ClientState, bs as ClientServerConfig } from './types-BZKxss8Y.cjs';
|
|
4
|
+
import { i as Cart, j as CartItem, O as Order, m as Transaction, n as Fulfillment, o as Return } from './payload-types-dkeQyrDC.cjs';
|
|
5
5
|
import './metadata.cjs';
|
|
6
|
-
import './const-
|
|
7
|
-
import './types-
|
|
6
|
+
import './const-sPR2IkCe.cjs';
|
|
7
|
+
import './types-B3YT092I.cjs';
|
|
8
8
|
|
|
9
9
|
type ModerationApiOptions = ServerApiOptions;
|
|
10
10
|
interface CommunityBan {
|
|
@@ -44,7 +44,7 @@ declare class ServerCommerceClient {
|
|
|
44
44
|
readonly product: {
|
|
45
45
|
stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
|
|
46
46
|
listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
|
|
47
|
-
detail: (params: ProductDetailParams) => Promise<
|
|
47
|
+
detail: (params: ProductDetailParams) => Promise<ProductDetailResult>;
|
|
48
48
|
previewDetail: (params: ProductDetailPreviewParams, options: ProductDetailPreviewOptions) => Promise<ProductDetail | null>;
|
|
49
49
|
upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
|
|
50
50
|
};
|
package/dist/server.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { S as ServerCollectionClient } from './collection-client-
|
|
2
|
-
export { C as CollectionClient } from './collection-client-
|
|
3
|
-
import { B as BaseApi,
|
|
4
|
-
import { i as Cart, j as CartItem, O as Order, m as Transaction, n as Fulfillment, o as Return } from './payload-types-
|
|
1
|
+
import { S as ServerCollectionClient } from './collection-client-B6SlhzIP.js';
|
|
2
|
+
export { C as CollectionClient } from './collection-client-B6SlhzIP.js';
|
|
3
|
+
import { B as BaseApi, aU as ServerApiOptions, aX as StockCheckParams, aY as StockCheckResponse, _ as ListingGroupsParams, av as ProductListingGroupsResponse, ad as ProductDetailParams, ae as ProductDetailResult, bo as ProductDetailPreviewParams, bp as ProductDetailPreviewOptions, a4 as ProductDetail, bq as ProductUpsertParams, br as ProductUpsertResponse, k as AddItemParams, a$ as UpdateItemParams, aO as RemoveItemParams, l as ApplyDiscountParams, aN as RemoveDiscountParams, t as ClearCartParams, s as CheckoutParams, H as CreateOrderParams, b0 as UpdateOrderParams, b3 as UpdateTransactionParams, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, a_ as UpdateFulfillmentParams, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, I as CreateReturnParams, b2 as UpdateReturnParams, aT as ReturnWithRefundParams, b4 as ValidateDiscountParams, b5 as ValidateDiscountResult, o as CalculateShippingParams, p as CalculateShippingResult, a as CommunityClient, c as ClientState, bs as ClientServerConfig } from './types-BHh0YLmq.js';
|
|
4
|
+
import { i as Cart, j as CartItem, O as Order, m as Transaction, n as Fulfillment, o as Return } from './payload-types-dkeQyrDC.js';
|
|
5
5
|
import './metadata.js';
|
|
6
|
-
import './const-
|
|
7
|
-
import './types-
|
|
6
|
+
import './const-DwmSDeWq.js';
|
|
7
|
+
import './types-Cel_4L9t.js';
|
|
8
8
|
|
|
9
9
|
type ModerationApiOptions = ServerApiOptions;
|
|
10
10
|
interface CommunityBan {
|
|
@@ -44,7 +44,7 @@ declare class ServerCommerceClient {
|
|
|
44
44
|
readonly product: {
|
|
45
45
|
stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
|
|
46
46
|
listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
|
|
47
|
-
detail: (params: ProductDetailParams) => Promise<
|
|
47
|
+
detail: (params: ProductDetailParams) => Promise<ProductDetailResult>;
|
|
48
48
|
previewDetail: (params: ProductDetailPreviewParams, options: ProductDetailPreviewOptions) => Promise<ProductDetail | null>;
|
|
49
49
|
upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
|
|
50
50
|
};
|
package/dist/server.js
CHANGED
|
@@ -1401,6 +1401,28 @@ var CartApi = class {
|
|
|
1401
1401
|
};
|
|
1402
1402
|
|
|
1403
1403
|
// src/core/api/product-api.ts
|
|
1404
|
+
var PRODUCT_DETAIL_UNAVAILABLE_REASONS = /* @__PURE__ */ new Set([
|
|
1405
|
+
"not_found",
|
|
1406
|
+
"not_published",
|
|
1407
|
+
"feature_disabled"
|
|
1408
|
+
]);
|
|
1409
|
+
function isRecord(value) {
|
|
1410
|
+
return typeof value === "object" && value !== null;
|
|
1411
|
+
}
|
|
1412
|
+
function readProductDetailUnavailableReason(value) {
|
|
1413
|
+
if (!isRecord(value)) return void 0;
|
|
1414
|
+
const directReason = value.reason ?? value.code;
|
|
1415
|
+
if (typeof directReason === "string" && PRODUCT_DETAIL_UNAVAILABLE_REASONS.has(directReason)) {
|
|
1416
|
+
return directReason;
|
|
1417
|
+
}
|
|
1418
|
+
return readProductDetailUnavailableReason(value.body);
|
|
1419
|
+
}
|
|
1420
|
+
function productDetailResultFromError(error) {
|
|
1421
|
+
if (!(error instanceof SDKError) || error.status !== 404) return void 0;
|
|
1422
|
+
const reason = readProductDetailUnavailableReason(error.details);
|
|
1423
|
+
if (!reason) return void 0;
|
|
1424
|
+
return { found: false, reason };
|
|
1425
|
+
}
|
|
1404
1426
|
var ProductApi = class extends BaseApi {
|
|
1405
1427
|
constructor(options) {
|
|
1406
1428
|
super("ProductApi", options);
|
|
@@ -1421,15 +1443,24 @@ var ProductApi = class extends BaseApi {
|
|
|
1421
1443
|
}
|
|
1422
1444
|
/**
|
|
1423
1445
|
* Fetch full product detail by slug or id.
|
|
1424
|
-
* Returns
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1446
|
+
* Returns a discriminated result so storefronts can distinguish missing,
|
|
1447
|
+
* unpublished, and feature-disabled products.
|
|
1448
|
+
*
|
|
1449
|
+
* Only product-detail 404 responses carrying one of those allowlisted reasons
|
|
1450
|
+
* are mapped to `{ found: false, reason }`. Unknown or uncoded 404s, plus
|
|
1451
|
+
* permission/auth errors such as tenant mismatch, continue to throw typed SDK
|
|
1452
|
+
* errors instead of being collapsed into a storefront absence result.
|
|
1427
1453
|
*/
|
|
1428
1454
|
async detail(params) {
|
|
1429
1455
|
try {
|
|
1430
|
-
|
|
1456
|
+
const product = await this.request(
|
|
1457
|
+
"/api/products/detail",
|
|
1458
|
+
params
|
|
1459
|
+
);
|
|
1460
|
+
return { found: true, product };
|
|
1431
1461
|
} catch (err) {
|
|
1432
|
-
|
|
1462
|
+
const notFoundResult = productDetailResultFromError(err);
|
|
1463
|
+
if (notFoundResult) return notFoundResult;
|
|
1433
1464
|
throw err;
|
|
1434
1465
|
}
|
|
1435
1466
|
}
|
|
@@ -1496,7 +1527,7 @@ var OrderApi = class extends BaseApi {
|
|
|
1496
1527
|
}
|
|
1497
1528
|
bulkImportFulfillments(params) {
|
|
1498
1529
|
return this.request(
|
|
1499
|
-
"/api/
|
|
1530
|
+
"/api/fulfillments/bulk-import",
|
|
1500
1531
|
params
|
|
1501
1532
|
);
|
|
1502
1533
|
}
|