@01.software/sdk 0.27.0 → 0.28.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 +125 -1
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/{const-D-xucnw4.d.ts → const-Cz9Ki_I7.d.cts} +4 -4
- package/dist/{const-C0GlmeJ_.d.cts → const-mdQQtIOz.d.ts} +4 -4
- package/dist/index.cjs +84 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.js +84 -7
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-BPvUmPAq.d.cts → payload-types-BrSYb-sh.d.cts} +145 -70
- package/dist/{payload-types-BPvUmPAq.d.ts → payload-types-BrSYb-sh.d.ts} +145 -70
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js.map +1 -1
- package/dist/{server-_zvihptw.d.ts → server-C2Q9R-Lu.d.ts} +228 -9
- package/dist/{server-n3xK4Nks.d.cts → server-D369bCVJ.d.cts} +228 -9
- package/dist/server.cjs +71 -4
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +71 -4
- package/dist/server.js.map +1 -1
- package/dist/{types-BLdthWiW.d.ts → types-BLUb4cYq.d.ts} +1 -1
- package/dist/{types-DzWNu9pw.d.cts → types-CW4PaIL7.d.cts} +1 -1
- package/dist/ui/canvas/server.cjs.map +1 -1
- package/dist/ui/canvas/server.js.map +1 -1
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.js.map +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.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import { QueryClient, InfiniteData } from '@tanstack/react-query';
|
|
3
|
-
import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-
|
|
2
|
+
import { QueryClient, InfiniteData, UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-BrSYb-sh.js';
|
|
4
4
|
import { Sort, Where } from 'payload';
|
|
5
5
|
import { Metadata } from 'next';
|
|
6
|
-
import { C as CollectionType } from './types-
|
|
7
|
-
import { P as PublicCollection, d as ServerCollection } from './const-
|
|
6
|
+
import { C as CollectionType } from './types-BLUb4cYq.js';
|
|
7
|
+
import { P as PublicCollection, d as ServerCollection } from './const-mdQQtIOz.js';
|
|
8
8
|
|
|
9
9
|
declare function resolveApiUrl(): string;
|
|
10
10
|
interface ClientConfig {
|
|
@@ -88,12 +88,51 @@ interface ApiQueryOptions {
|
|
|
88
88
|
page?: number;
|
|
89
89
|
limit?: number;
|
|
90
90
|
sort?: Sort;
|
|
91
|
+
/**
|
|
92
|
+
* Filter documents. Id-based relation filters (`where: { product: { equals: id } }`) are the
|
|
93
|
+
* most reliable pattern. Dotted-path relation filters (`where: { 'product.slug': { equals } }`)
|
|
94
|
+
* are Payload-native but may silently return empty when access control restricts the related
|
|
95
|
+
* document or when the relation is polymorphic. String shorthand (`where: { slug: 'x' }`)
|
|
96
|
+
* silently matches nothing — always use `{ slug: { equals: 'x' } }`.
|
|
97
|
+
*/
|
|
91
98
|
where?: Where;
|
|
99
|
+
/**
|
|
100
|
+
* Controls how deeply relationship fields are populated. This is the primary control for
|
|
101
|
+
* populating relationships like `category`, `images`, `brand`. The configured Payload default
|
|
102
|
+
* applies when unset.
|
|
103
|
+
*/
|
|
92
104
|
depth?: number;
|
|
93
105
|
select?: Record<string, boolean>;
|
|
94
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Controls which fields are returned for already-populated relationships, keyed by collection
|
|
108
|
+
* slug. Does NOT control which relationships to populate — that is `depth`.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // depth: 2 populates category; populate trims which fields come back
|
|
112
|
+
* populate: { categories: { title: true, slug: true } }
|
|
113
|
+
*/
|
|
95
114
|
populate?: Record<string, boolean | Record<string, boolean>>;
|
|
96
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Controls Payload `type: 'join'` virtual reverse-relation fields only (pagination, sort,
|
|
117
|
+
* filter, count per join field, or `false` to disable all join-field population).
|
|
118
|
+
*
|
|
119
|
+
* Does NOT populate normal relationship fields like `category`, `images`, or `brand`.
|
|
120
|
+
* For normal relationship population use `depth` (and optionally `populate` for field
|
|
121
|
+
* selection).
|
|
122
|
+
*
|
|
123
|
+
* Pass `joins: false` to disable all join-field population — useful for lightweight list
|
|
124
|
+
* queries where join fields are not needed.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* // `article-authors` has a `type: 'join'` field `articles` (reverse-relation)
|
|
128
|
+
* joins: { articles: { limit: 10, sort: '-publishedAt' } }
|
|
129
|
+
*
|
|
130
|
+
* // depth: 2 populates product.category — joins has no effect on this
|
|
131
|
+
* depth: 2
|
|
132
|
+
*
|
|
133
|
+
* // Disable all join-field population
|
|
134
|
+
* joins: false
|
|
135
|
+
*/
|
|
97
136
|
joins?: Record<string, {
|
|
98
137
|
limit?: number;
|
|
99
138
|
page?: number;
|
|
@@ -998,6 +1037,151 @@ type ProductListingGroupsItem = {
|
|
|
998
1037
|
type ProductListingGroupsResponse = {
|
|
999
1038
|
docs: ProductListingGroupsItem[];
|
|
1000
1039
|
};
|
|
1040
|
+
type ProductDetailParams = {
|
|
1041
|
+
slug: string;
|
|
1042
|
+
} | {
|
|
1043
|
+
id: string;
|
|
1044
|
+
};
|
|
1045
|
+
interface ProductDetailVariantOptionValue {
|
|
1046
|
+
optionId: string | number;
|
|
1047
|
+
valueId: string | number;
|
|
1048
|
+
value?: string | null;
|
|
1049
|
+
}
|
|
1050
|
+
interface ProductDetailVariant {
|
|
1051
|
+
id: string | number;
|
|
1052
|
+
optionKey: string;
|
|
1053
|
+
title?: string | null;
|
|
1054
|
+
displayName: string;
|
|
1055
|
+
sku?: string | null;
|
|
1056
|
+
price: number;
|
|
1057
|
+
compareAtPrice?: number | null;
|
|
1058
|
+
stock: number;
|
|
1059
|
+
reservedStock: number;
|
|
1060
|
+
isUnlimited: boolean;
|
|
1061
|
+
thumbnail?: unknown | null;
|
|
1062
|
+
images?: unknown[];
|
|
1063
|
+
optionValues: ProductDetailVariantOptionValue[];
|
|
1064
|
+
}
|
|
1065
|
+
interface ProductDetailOptionValue {
|
|
1066
|
+
id: string | number;
|
|
1067
|
+
value: string;
|
|
1068
|
+
swatchColor?: string | null;
|
|
1069
|
+
thumbnail?: unknown | null;
|
|
1070
|
+
}
|
|
1071
|
+
interface ProductDetailOption {
|
|
1072
|
+
id: string | number;
|
|
1073
|
+
title: string;
|
|
1074
|
+
values: ProductDetailOptionValue[];
|
|
1075
|
+
}
|
|
1076
|
+
interface ProductDetailBrand {
|
|
1077
|
+
id: string | number;
|
|
1078
|
+
name: string;
|
|
1079
|
+
slug?: string | null;
|
|
1080
|
+
logo?: unknown | null;
|
|
1081
|
+
}
|
|
1082
|
+
interface ProductDetailCategory {
|
|
1083
|
+
id: string | number;
|
|
1084
|
+
title: string;
|
|
1085
|
+
slug?: string | null;
|
|
1086
|
+
}
|
|
1087
|
+
interface ProductDetailTag {
|
|
1088
|
+
id: string | number;
|
|
1089
|
+
title: string;
|
|
1090
|
+
slug?: string | null;
|
|
1091
|
+
}
|
|
1092
|
+
interface ProductDetailImage {
|
|
1093
|
+
id: string | number;
|
|
1094
|
+
url?: string | null;
|
|
1095
|
+
alt?: string | null;
|
|
1096
|
+
width?: number | null;
|
|
1097
|
+
height?: number | null;
|
|
1098
|
+
}
|
|
1099
|
+
interface ProductDetailVideo {
|
|
1100
|
+
id: string | number;
|
|
1101
|
+
url?: string | null;
|
|
1102
|
+
}
|
|
1103
|
+
interface ProductDetailListing {
|
|
1104
|
+
minPrice?: number | null;
|
|
1105
|
+
maxPrice?: number | null;
|
|
1106
|
+
minCompareAtPrice?: number | null;
|
|
1107
|
+
maxCompareAtPrice?: number | null;
|
|
1108
|
+
isPriceRange?: boolean | null;
|
|
1109
|
+
primaryImage?: unknown | null;
|
|
1110
|
+
availableForSale?: boolean | null;
|
|
1111
|
+
selectionHintVariant?: unknown | null;
|
|
1112
|
+
}
|
|
1113
|
+
interface ProductDetail {
|
|
1114
|
+
product: {
|
|
1115
|
+
id: string | number;
|
|
1116
|
+
slug: string;
|
|
1117
|
+
title: string;
|
|
1118
|
+
subtitle?: string | null;
|
|
1119
|
+
description?: string | null;
|
|
1120
|
+
content?: unknown;
|
|
1121
|
+
publishedAt?: string | null;
|
|
1122
|
+
status: string;
|
|
1123
|
+
totalInventory: number;
|
|
1124
|
+
totalVariants: number;
|
|
1125
|
+
hasOnlyDefaultVariant: boolean;
|
|
1126
|
+
};
|
|
1127
|
+
variants: ProductDetailVariant[];
|
|
1128
|
+
options: ProductDetailOption[];
|
|
1129
|
+
brand: ProductDetailBrand | null;
|
|
1130
|
+
categories: ProductDetailCategory[];
|
|
1131
|
+
tags: ProductDetailTag[];
|
|
1132
|
+
images: ProductDetailImage[];
|
|
1133
|
+
videos: ProductDetailVideo[];
|
|
1134
|
+
listing: ProductDetailListing;
|
|
1135
|
+
}
|
|
1136
|
+
type ProductUpsertOptionValueInput = {
|
|
1137
|
+
id?: string;
|
|
1138
|
+
value: string;
|
|
1139
|
+
slug?: string;
|
|
1140
|
+
swatchColor?: string | null;
|
|
1141
|
+
thumbnail?: string | null;
|
|
1142
|
+
images?: string[];
|
|
1143
|
+
metadata?: unknown;
|
|
1144
|
+
};
|
|
1145
|
+
type ProductUpsertOptionInput = {
|
|
1146
|
+
id?: string;
|
|
1147
|
+
title: string;
|
|
1148
|
+
values: ProductUpsertOptionValueInput[];
|
|
1149
|
+
};
|
|
1150
|
+
type ProductUpsertVariantInput = {
|
|
1151
|
+
id?: string;
|
|
1152
|
+
optionValues?: Record<string, string> | string[];
|
|
1153
|
+
sku?: string | null;
|
|
1154
|
+
title?: string | null;
|
|
1155
|
+
price: number;
|
|
1156
|
+
compareAtPrice?: number | null;
|
|
1157
|
+
stock?: number;
|
|
1158
|
+
isUnlimited?: boolean;
|
|
1159
|
+
weight?: number | null;
|
|
1160
|
+
requiresShipping?: boolean;
|
|
1161
|
+
barcode?: string | null;
|
|
1162
|
+
externalId?: string | null;
|
|
1163
|
+
isActive?: boolean;
|
|
1164
|
+
thumbnail?: string | null;
|
|
1165
|
+
images?: string[];
|
|
1166
|
+
metadata?: unknown;
|
|
1167
|
+
};
|
|
1168
|
+
type ProductUpsertParams = {
|
|
1169
|
+
product: Record<string, unknown> & {
|
|
1170
|
+
id?: string;
|
|
1171
|
+
title?: string;
|
|
1172
|
+
};
|
|
1173
|
+
options?: ProductUpsertOptionInput[];
|
|
1174
|
+
variants?: ProductUpsertVariantInput[];
|
|
1175
|
+
};
|
|
1176
|
+
type ProductUpsertResponse = {
|
|
1177
|
+
ok: true;
|
|
1178
|
+
product: Product;
|
|
1179
|
+
} | {
|
|
1180
|
+
ok: false;
|
|
1181
|
+
failedEntity: 'product' | 'option' | 'option-value' | 'variant';
|
|
1182
|
+
failedIndex?: number;
|
|
1183
|
+
message: string;
|
|
1184
|
+
};
|
|
1001
1185
|
declare class ProductApi extends BaseApi {
|
|
1002
1186
|
constructor(options: ProductApiOptions);
|
|
1003
1187
|
/**
|
|
@@ -1007,6 +1191,20 @@ declare class ProductApi extends BaseApi {
|
|
|
1007
1191
|
*/
|
|
1008
1192
|
stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
|
|
1009
1193
|
listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Fetch full product detail by slug or id.
|
|
1196
|
+
* Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
|
|
1197
|
+
* `tenant_mismatch` / `feature_disabled`). For the reason behind a null,
|
|
1198
|
+
* inspect `client.lastRequestId` against backend logs.
|
|
1199
|
+
*/
|
|
1200
|
+
detail(params: ProductDetailParams): Promise<ProductDetail | null>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Atomically create or update a product together with its options,
|
|
1203
|
+
* option-values, and variants in a single transaction. Mirrors Shopify's
|
|
1204
|
+
* `productSet` shape and is the canonical write path for the MCP
|
|
1205
|
+
* `product-upsert` tool.
|
|
1206
|
+
*/
|
|
1207
|
+
upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
|
|
1010
1208
|
}
|
|
1011
1209
|
|
|
1012
1210
|
type DiscountApiOptions = ServerApiOptions;
|
|
@@ -1196,6 +1394,8 @@ declare class ServerCommerceClient {
|
|
|
1196
1394
|
readonly product: {
|
|
1197
1395
|
stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
|
|
1198
1396
|
listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
|
|
1397
|
+
detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
|
|
1398
|
+
upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
|
|
1199
1399
|
};
|
|
1200
1400
|
readonly cart: {
|
|
1201
1401
|
get: (cartId: string) => Promise<Cart>;
|
|
@@ -1371,9 +1571,15 @@ type ReadOnlyQueryHooks = Omit<QueryHooks, 'useCreate' | 'useUpdate' | 'useRemov
|
|
|
1371
1571
|
* Composes CollectionHooks + CustomerHooks into a single API surface.
|
|
1372
1572
|
* All methods are delegated; no logic lives here.
|
|
1373
1573
|
*/
|
|
1574
|
+
interface ProductDetailCallable {
|
|
1575
|
+
product: {
|
|
1576
|
+
detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1374
1579
|
declare class QueryHooks extends CollectionHooks {
|
|
1375
1580
|
private _customer;
|
|
1376
|
-
|
|
1581
|
+
private _commerce?;
|
|
1582
|
+
constructor(queryClient: QueryClient, collectionClient: CollectionClient, customerAuth?: CustomerAuth, commerceClient?: ProductDetailCallable);
|
|
1377
1583
|
useCustomerMe: CustomerHooks['useCustomerMe'];
|
|
1378
1584
|
useCustomerLogin: CustomerHooks['useCustomerLogin'];
|
|
1379
1585
|
useCustomerRegister: CustomerHooks['useCustomerRegister'];
|
|
@@ -1388,7 +1594,7 @@ declare class QueryHooks extends CollectionHooks {
|
|
|
1388
1594
|
setCustomerData: CustomerHooks['setCustomerData'];
|
|
1389
1595
|
useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
|
|
1390
1596
|
options?: ProductListingGroupsQueryOptions;
|
|
1391
|
-
}, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>):
|
|
1597
|
+
}, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
|
|
1392
1598
|
useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
|
|
1393
1599
|
options?: ProductListingGroupsQueryOptions;
|
|
1394
1600
|
}, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
|
|
@@ -1412,6 +1618,19 @@ declare class QueryHooks extends CollectionHooks {
|
|
|
1412
1618
|
pages?: number;
|
|
1413
1619
|
staleTime?: number;
|
|
1414
1620
|
}): Promise<void>;
|
|
1621
|
+
useProductDetail(params: {
|
|
1622
|
+
slug: string;
|
|
1623
|
+
} | {
|
|
1624
|
+
id: string;
|
|
1625
|
+
}, options?: {
|
|
1626
|
+
enabled?: boolean;
|
|
1627
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1628
|
+
useProductDetailBySlug(slug: string, options?: {
|
|
1629
|
+
enabled?: boolean;
|
|
1630
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1631
|
+
useProductDetailById(id: string, options?: {
|
|
1632
|
+
enabled?: boolean;
|
|
1633
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1415
1634
|
}
|
|
1416
1635
|
|
|
1417
1636
|
declare class ServerClient {
|
|
@@ -1440,4 +1659,4 @@ declare class ServerClient {
|
|
|
1440
1659
|
*/
|
|
1441
1660
|
declare function createServerClient(options: ClientServerConfig): ServerClient;
|
|
1442
1661
|
|
|
1443
|
-
export { type
|
|
1662
|
+
export { type CustomerAuthResponse as $, type AddItemParams as A, type BanCustomerParams as B, CustomerAuth as C, type ClientMetadata as D, type ClientServerConfig as E, CollectionClient as F, type CollectionDetailQueryParams as G, CollectionHooks as H, type CollectionInfiniteQueryParams as I, CollectionQueryBuilder as J, type CollectionQueryParams as K, type ListingGroupsParams as L, type CommunityBan as M, type CommunityClientOptions as N, type CommunityPost as O, type ProductListingGroupsResponse as P, ConfigError as Q, type RemoveItemParams as R, type StockCheckParams as S, type ConfirmPaymentParams as T, type UpdateItemParams as U, type ValidateDiscountParams as V, type ConfirmPaymentResponse as W, ConflictError as X, type CreateFulfillmentParams as Y, type CreateOrderParams as Z, type CreateReturnParams as _, type CustomerAuthOptions as a, type ServerCommerceClientOptions as a$, CustomerHooks as a0, type CustomerLoginData as a1, type CustomerProfile as a2, type CustomerRefreshResponse as a3, type CustomerRegisterData as a4, type CustomerRegisterResponse as a5, type CustomerSnapshot as a6, type DebugConfig as a7, type DeepPartial as a8, DiscountApi as a9, type ProductListingGroup as aA, type ProductListingGroupSummary as aB, type ProductListingGroupsItem as aC, type ProductListingProductShape as aD, type ProductListingProjection as aE, type ProductOptionMatrix as aF, type ProductOptionMatrixOption as aG, type ProductOptionMatrixValue as aH, type ProductOptionMatrixVariant as aI, type ProductOptionShape as aJ, type ProductOptionValueShape as aK, type ProductVariantShape as aL, QueryHooks as aM, type QueryOptions as aN, RateLimitError as aO, type ReadOnlyQueryBuilder as aP, type RequestOptions as aQ, type RetryConfig as aR, type ReturnItem as aS, type ReturnReason as aT, type ReturnWithRefundParams as aU, SDKError as aV, type ServerApiOptions as aW, ServerClient as aX, ServerCollectionClient as aY, ServerCollectionQueryBuilder as aZ, ServerCommerceClient as a_, type DiscountApiOptions as aa, type ExtractArrayType as ab, type GenerateMetadataOptions as ac, GoneError as ad, type InfiniteQueryOptions as ae, ModerationApi as af, type ModerationApiOptions as ag, NetworkError as ah, NotFoundError as ai, OrderApi as aj, type OrderApiOptions as ak, type PaginationMeta as al, type PayloadMutationResponse as am, PermissionError as an, ProductApi as ao, type ProductApiOptions as ap, type ProductDetailBrand as aq, type ProductDetailCategory as ar, type ProductDetailImage as as, type ProductDetailListing as at, type ProductDetailOption as au, type ProductDetailOptionValue as av, type ProductDetailTag as aw, type ProductDetailVariant as ax, type ProductDetailVariantOptionValue as ay, type ProductDetailVideo as az, type StockCheckResponse as b, ServiceUnavailableError as b0, ShippingApi as b1, type ShippingApiOptions as b2, type StockCheckResult as b3, type SuspenseInfiniteQueryOptions as b4, type SuspenseQueryOptions as b5, TimeoutError as b6, type UnbanCustomerParams as b7, type UpdateFulfillmentParams as b8, type UpdateOrderParams as b9, isServiceUnavailableError as bA, isTimeoutError as bB, isUsageLimitError as bC, isValidationError as bD, normalizeSelectedValueIds as bE, resolveApiUrl as bF, resolveVariantForSelection as bG, type UpdateProfileData as ba, type UpdateReturnParams as bb, type UpdateTransactionParams as bc, UsageLimitError as bd, ValidationError as be, buildProductListingGroupsByOption as bf, buildProductListingProjection as bg, buildProductOptionMatrix as bh, createAuthError as bi, createConflictError as bj, createNotFoundError as bk, createPermissionError as bl, createRateLimitError as bm, createServerClient as bn, getAvailableOptionValues as bo, getSelectedValueByOptionId as bp, isApiError as bq, isAuthError as br, isConfigError as bs, isConflictError as bt, isGoneError as bu, isNetworkError as bv, isNotFoundError as bw, isPermissionError as bx, isRateLimitError as by, isSDKError as bz, type ProductDetailParams as c, type ProductDetail as d, type ApplyDiscountParams as e, type RemoveDiscountParams as f, type ClearCartParams as g, type CheckoutParams as h, type PayloadFindResponse as i, type ValidateDiscountResult as j, type CalculateShippingParams as k, type CalculateShippingResult as l, type ApiQueryOptions as m, type ProductListingGroupsQueryOptions as n, CommunityClient as o, type ReadOnlyQueryHooks as p, ReadOnlyCollectionClient as q, type ClientState as r, type ClientConfig as s, ApiError as t, AuthError as u, BaseApi as v, type BulkImportFulfillmentsParams as w, type BulkImportFulfillmentsResponse as x, CartApi as y, type CartApiOptions as z };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import { QueryClient, InfiniteData } from '@tanstack/react-query';
|
|
3
|
-
import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-
|
|
2
|
+
import { QueryClient, InfiniteData, UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-BrSYb-sh.cjs';
|
|
4
4
|
import { Sort, Where } from 'payload';
|
|
5
5
|
import { Metadata } from 'next';
|
|
6
|
-
import { C as CollectionType } from './types-
|
|
7
|
-
import { P as PublicCollection, d as ServerCollection } from './const-
|
|
6
|
+
import { C as CollectionType } from './types-CW4PaIL7.cjs';
|
|
7
|
+
import { P as PublicCollection, d as ServerCollection } from './const-Cz9Ki_I7.cjs';
|
|
8
8
|
|
|
9
9
|
declare function resolveApiUrl(): string;
|
|
10
10
|
interface ClientConfig {
|
|
@@ -88,12 +88,51 @@ interface ApiQueryOptions {
|
|
|
88
88
|
page?: number;
|
|
89
89
|
limit?: number;
|
|
90
90
|
sort?: Sort;
|
|
91
|
+
/**
|
|
92
|
+
* Filter documents. Id-based relation filters (`where: { product: { equals: id } }`) are the
|
|
93
|
+
* most reliable pattern. Dotted-path relation filters (`where: { 'product.slug': { equals } }`)
|
|
94
|
+
* are Payload-native but may silently return empty when access control restricts the related
|
|
95
|
+
* document or when the relation is polymorphic. String shorthand (`where: { slug: 'x' }`)
|
|
96
|
+
* silently matches nothing — always use `{ slug: { equals: 'x' } }`.
|
|
97
|
+
*/
|
|
91
98
|
where?: Where;
|
|
99
|
+
/**
|
|
100
|
+
* Controls how deeply relationship fields are populated. This is the primary control for
|
|
101
|
+
* populating relationships like `category`, `images`, `brand`. The configured Payload default
|
|
102
|
+
* applies when unset.
|
|
103
|
+
*/
|
|
92
104
|
depth?: number;
|
|
93
105
|
select?: Record<string, boolean>;
|
|
94
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Controls which fields are returned for already-populated relationships, keyed by collection
|
|
108
|
+
* slug. Does NOT control which relationships to populate — that is `depth`.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // depth: 2 populates category; populate trims which fields come back
|
|
112
|
+
* populate: { categories: { title: true, slug: true } }
|
|
113
|
+
*/
|
|
95
114
|
populate?: Record<string, boolean | Record<string, boolean>>;
|
|
96
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Controls Payload `type: 'join'` virtual reverse-relation fields only (pagination, sort,
|
|
117
|
+
* filter, count per join field, or `false` to disable all join-field population).
|
|
118
|
+
*
|
|
119
|
+
* Does NOT populate normal relationship fields like `category`, `images`, or `brand`.
|
|
120
|
+
* For normal relationship population use `depth` (and optionally `populate` for field
|
|
121
|
+
* selection).
|
|
122
|
+
*
|
|
123
|
+
* Pass `joins: false` to disable all join-field population — useful for lightweight list
|
|
124
|
+
* queries where join fields are not needed.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* // `article-authors` has a `type: 'join'` field `articles` (reverse-relation)
|
|
128
|
+
* joins: { articles: { limit: 10, sort: '-publishedAt' } }
|
|
129
|
+
*
|
|
130
|
+
* // depth: 2 populates product.category — joins has no effect on this
|
|
131
|
+
* depth: 2
|
|
132
|
+
*
|
|
133
|
+
* // Disable all join-field population
|
|
134
|
+
* joins: false
|
|
135
|
+
*/
|
|
97
136
|
joins?: Record<string, {
|
|
98
137
|
limit?: number;
|
|
99
138
|
page?: number;
|
|
@@ -998,6 +1037,151 @@ type ProductListingGroupsItem = {
|
|
|
998
1037
|
type ProductListingGroupsResponse = {
|
|
999
1038
|
docs: ProductListingGroupsItem[];
|
|
1000
1039
|
};
|
|
1040
|
+
type ProductDetailParams = {
|
|
1041
|
+
slug: string;
|
|
1042
|
+
} | {
|
|
1043
|
+
id: string;
|
|
1044
|
+
};
|
|
1045
|
+
interface ProductDetailVariantOptionValue {
|
|
1046
|
+
optionId: string | number;
|
|
1047
|
+
valueId: string | number;
|
|
1048
|
+
value?: string | null;
|
|
1049
|
+
}
|
|
1050
|
+
interface ProductDetailVariant {
|
|
1051
|
+
id: string | number;
|
|
1052
|
+
optionKey: string;
|
|
1053
|
+
title?: string | null;
|
|
1054
|
+
displayName: string;
|
|
1055
|
+
sku?: string | null;
|
|
1056
|
+
price: number;
|
|
1057
|
+
compareAtPrice?: number | null;
|
|
1058
|
+
stock: number;
|
|
1059
|
+
reservedStock: number;
|
|
1060
|
+
isUnlimited: boolean;
|
|
1061
|
+
thumbnail?: unknown | null;
|
|
1062
|
+
images?: unknown[];
|
|
1063
|
+
optionValues: ProductDetailVariantOptionValue[];
|
|
1064
|
+
}
|
|
1065
|
+
interface ProductDetailOptionValue {
|
|
1066
|
+
id: string | number;
|
|
1067
|
+
value: string;
|
|
1068
|
+
swatchColor?: string | null;
|
|
1069
|
+
thumbnail?: unknown | null;
|
|
1070
|
+
}
|
|
1071
|
+
interface ProductDetailOption {
|
|
1072
|
+
id: string | number;
|
|
1073
|
+
title: string;
|
|
1074
|
+
values: ProductDetailOptionValue[];
|
|
1075
|
+
}
|
|
1076
|
+
interface ProductDetailBrand {
|
|
1077
|
+
id: string | number;
|
|
1078
|
+
name: string;
|
|
1079
|
+
slug?: string | null;
|
|
1080
|
+
logo?: unknown | null;
|
|
1081
|
+
}
|
|
1082
|
+
interface ProductDetailCategory {
|
|
1083
|
+
id: string | number;
|
|
1084
|
+
title: string;
|
|
1085
|
+
slug?: string | null;
|
|
1086
|
+
}
|
|
1087
|
+
interface ProductDetailTag {
|
|
1088
|
+
id: string | number;
|
|
1089
|
+
title: string;
|
|
1090
|
+
slug?: string | null;
|
|
1091
|
+
}
|
|
1092
|
+
interface ProductDetailImage {
|
|
1093
|
+
id: string | number;
|
|
1094
|
+
url?: string | null;
|
|
1095
|
+
alt?: string | null;
|
|
1096
|
+
width?: number | null;
|
|
1097
|
+
height?: number | null;
|
|
1098
|
+
}
|
|
1099
|
+
interface ProductDetailVideo {
|
|
1100
|
+
id: string | number;
|
|
1101
|
+
url?: string | null;
|
|
1102
|
+
}
|
|
1103
|
+
interface ProductDetailListing {
|
|
1104
|
+
minPrice?: number | null;
|
|
1105
|
+
maxPrice?: number | null;
|
|
1106
|
+
minCompareAtPrice?: number | null;
|
|
1107
|
+
maxCompareAtPrice?: number | null;
|
|
1108
|
+
isPriceRange?: boolean | null;
|
|
1109
|
+
primaryImage?: unknown | null;
|
|
1110
|
+
availableForSale?: boolean | null;
|
|
1111
|
+
selectionHintVariant?: unknown | null;
|
|
1112
|
+
}
|
|
1113
|
+
interface ProductDetail {
|
|
1114
|
+
product: {
|
|
1115
|
+
id: string | number;
|
|
1116
|
+
slug: string;
|
|
1117
|
+
title: string;
|
|
1118
|
+
subtitle?: string | null;
|
|
1119
|
+
description?: string | null;
|
|
1120
|
+
content?: unknown;
|
|
1121
|
+
publishedAt?: string | null;
|
|
1122
|
+
status: string;
|
|
1123
|
+
totalInventory: number;
|
|
1124
|
+
totalVariants: number;
|
|
1125
|
+
hasOnlyDefaultVariant: boolean;
|
|
1126
|
+
};
|
|
1127
|
+
variants: ProductDetailVariant[];
|
|
1128
|
+
options: ProductDetailOption[];
|
|
1129
|
+
brand: ProductDetailBrand | null;
|
|
1130
|
+
categories: ProductDetailCategory[];
|
|
1131
|
+
tags: ProductDetailTag[];
|
|
1132
|
+
images: ProductDetailImage[];
|
|
1133
|
+
videos: ProductDetailVideo[];
|
|
1134
|
+
listing: ProductDetailListing;
|
|
1135
|
+
}
|
|
1136
|
+
type ProductUpsertOptionValueInput = {
|
|
1137
|
+
id?: string;
|
|
1138
|
+
value: string;
|
|
1139
|
+
slug?: string;
|
|
1140
|
+
swatchColor?: string | null;
|
|
1141
|
+
thumbnail?: string | null;
|
|
1142
|
+
images?: string[];
|
|
1143
|
+
metadata?: unknown;
|
|
1144
|
+
};
|
|
1145
|
+
type ProductUpsertOptionInput = {
|
|
1146
|
+
id?: string;
|
|
1147
|
+
title: string;
|
|
1148
|
+
values: ProductUpsertOptionValueInput[];
|
|
1149
|
+
};
|
|
1150
|
+
type ProductUpsertVariantInput = {
|
|
1151
|
+
id?: string;
|
|
1152
|
+
optionValues?: Record<string, string> | string[];
|
|
1153
|
+
sku?: string | null;
|
|
1154
|
+
title?: string | null;
|
|
1155
|
+
price: number;
|
|
1156
|
+
compareAtPrice?: number | null;
|
|
1157
|
+
stock?: number;
|
|
1158
|
+
isUnlimited?: boolean;
|
|
1159
|
+
weight?: number | null;
|
|
1160
|
+
requiresShipping?: boolean;
|
|
1161
|
+
barcode?: string | null;
|
|
1162
|
+
externalId?: string | null;
|
|
1163
|
+
isActive?: boolean;
|
|
1164
|
+
thumbnail?: string | null;
|
|
1165
|
+
images?: string[];
|
|
1166
|
+
metadata?: unknown;
|
|
1167
|
+
};
|
|
1168
|
+
type ProductUpsertParams = {
|
|
1169
|
+
product: Record<string, unknown> & {
|
|
1170
|
+
id?: string;
|
|
1171
|
+
title?: string;
|
|
1172
|
+
};
|
|
1173
|
+
options?: ProductUpsertOptionInput[];
|
|
1174
|
+
variants?: ProductUpsertVariantInput[];
|
|
1175
|
+
};
|
|
1176
|
+
type ProductUpsertResponse = {
|
|
1177
|
+
ok: true;
|
|
1178
|
+
product: Product;
|
|
1179
|
+
} | {
|
|
1180
|
+
ok: false;
|
|
1181
|
+
failedEntity: 'product' | 'option' | 'option-value' | 'variant';
|
|
1182
|
+
failedIndex?: number;
|
|
1183
|
+
message: string;
|
|
1184
|
+
};
|
|
1001
1185
|
declare class ProductApi extends BaseApi {
|
|
1002
1186
|
constructor(options: ProductApiOptions);
|
|
1003
1187
|
/**
|
|
@@ -1007,6 +1191,20 @@ declare class ProductApi extends BaseApi {
|
|
|
1007
1191
|
*/
|
|
1008
1192
|
stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
|
|
1009
1193
|
listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Fetch full product detail by slug or id.
|
|
1196
|
+
* Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
|
|
1197
|
+
* `tenant_mismatch` / `feature_disabled`). For the reason behind a null,
|
|
1198
|
+
* inspect `client.lastRequestId` against backend logs.
|
|
1199
|
+
*/
|
|
1200
|
+
detail(params: ProductDetailParams): Promise<ProductDetail | null>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Atomically create or update a product together with its options,
|
|
1203
|
+
* option-values, and variants in a single transaction. Mirrors Shopify's
|
|
1204
|
+
* `productSet` shape and is the canonical write path for the MCP
|
|
1205
|
+
* `product-upsert` tool.
|
|
1206
|
+
*/
|
|
1207
|
+
upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
|
|
1010
1208
|
}
|
|
1011
1209
|
|
|
1012
1210
|
type DiscountApiOptions = ServerApiOptions;
|
|
@@ -1196,6 +1394,8 @@ declare class ServerCommerceClient {
|
|
|
1196
1394
|
readonly product: {
|
|
1197
1395
|
stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
|
|
1198
1396
|
listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
|
|
1397
|
+
detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
|
|
1398
|
+
upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
|
|
1199
1399
|
};
|
|
1200
1400
|
readonly cart: {
|
|
1201
1401
|
get: (cartId: string) => Promise<Cart>;
|
|
@@ -1371,9 +1571,15 @@ type ReadOnlyQueryHooks = Omit<QueryHooks, 'useCreate' | 'useUpdate' | 'useRemov
|
|
|
1371
1571
|
* Composes CollectionHooks + CustomerHooks into a single API surface.
|
|
1372
1572
|
* All methods are delegated; no logic lives here.
|
|
1373
1573
|
*/
|
|
1574
|
+
interface ProductDetailCallable {
|
|
1575
|
+
product: {
|
|
1576
|
+
detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1374
1579
|
declare class QueryHooks extends CollectionHooks {
|
|
1375
1580
|
private _customer;
|
|
1376
|
-
|
|
1581
|
+
private _commerce?;
|
|
1582
|
+
constructor(queryClient: QueryClient, collectionClient: CollectionClient, customerAuth?: CustomerAuth, commerceClient?: ProductDetailCallable);
|
|
1377
1583
|
useCustomerMe: CustomerHooks['useCustomerMe'];
|
|
1378
1584
|
useCustomerLogin: CustomerHooks['useCustomerLogin'];
|
|
1379
1585
|
useCustomerRegister: CustomerHooks['useCustomerRegister'];
|
|
@@ -1388,7 +1594,7 @@ declare class QueryHooks extends CollectionHooks {
|
|
|
1388
1594
|
setCustomerData: CustomerHooks['setCustomerData'];
|
|
1389
1595
|
useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
|
|
1390
1596
|
options?: ProductListingGroupsQueryOptions;
|
|
1391
|
-
}, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>):
|
|
1597
|
+
}, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
|
|
1392
1598
|
useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
|
|
1393
1599
|
options?: ProductListingGroupsQueryOptions;
|
|
1394
1600
|
}, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
|
|
@@ -1412,6 +1618,19 @@ declare class QueryHooks extends CollectionHooks {
|
|
|
1412
1618
|
pages?: number;
|
|
1413
1619
|
staleTime?: number;
|
|
1414
1620
|
}): Promise<void>;
|
|
1621
|
+
useProductDetail(params: {
|
|
1622
|
+
slug: string;
|
|
1623
|
+
} | {
|
|
1624
|
+
id: string;
|
|
1625
|
+
}, options?: {
|
|
1626
|
+
enabled?: boolean;
|
|
1627
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1628
|
+
useProductDetailBySlug(slug: string, options?: {
|
|
1629
|
+
enabled?: boolean;
|
|
1630
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1631
|
+
useProductDetailById(id: string, options?: {
|
|
1632
|
+
enabled?: boolean;
|
|
1633
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1415
1634
|
}
|
|
1416
1635
|
|
|
1417
1636
|
declare class ServerClient {
|
|
@@ -1440,4 +1659,4 @@ declare class ServerClient {
|
|
|
1440
1659
|
*/
|
|
1441
1660
|
declare function createServerClient(options: ClientServerConfig): ServerClient;
|
|
1442
1661
|
|
|
1443
|
-
export { type
|
|
1662
|
+
export { type CustomerAuthResponse as $, type AddItemParams as A, type BanCustomerParams as B, CustomerAuth as C, type ClientMetadata as D, type ClientServerConfig as E, CollectionClient as F, type CollectionDetailQueryParams as G, CollectionHooks as H, type CollectionInfiniteQueryParams as I, CollectionQueryBuilder as J, type CollectionQueryParams as K, type ListingGroupsParams as L, type CommunityBan as M, type CommunityClientOptions as N, type CommunityPost as O, type ProductListingGroupsResponse as P, ConfigError as Q, type RemoveItemParams as R, type StockCheckParams as S, type ConfirmPaymentParams as T, type UpdateItemParams as U, type ValidateDiscountParams as V, type ConfirmPaymentResponse as W, ConflictError as X, type CreateFulfillmentParams as Y, type CreateOrderParams as Z, type CreateReturnParams as _, type CustomerAuthOptions as a, type ServerCommerceClientOptions as a$, CustomerHooks as a0, type CustomerLoginData as a1, type CustomerProfile as a2, type CustomerRefreshResponse as a3, type CustomerRegisterData as a4, type CustomerRegisterResponse as a5, type CustomerSnapshot as a6, type DebugConfig as a7, type DeepPartial as a8, DiscountApi as a9, type ProductListingGroup as aA, type ProductListingGroupSummary as aB, type ProductListingGroupsItem as aC, type ProductListingProductShape as aD, type ProductListingProjection as aE, type ProductOptionMatrix as aF, type ProductOptionMatrixOption as aG, type ProductOptionMatrixValue as aH, type ProductOptionMatrixVariant as aI, type ProductOptionShape as aJ, type ProductOptionValueShape as aK, type ProductVariantShape as aL, QueryHooks as aM, type QueryOptions as aN, RateLimitError as aO, type ReadOnlyQueryBuilder as aP, type RequestOptions as aQ, type RetryConfig as aR, type ReturnItem as aS, type ReturnReason as aT, type ReturnWithRefundParams as aU, SDKError as aV, type ServerApiOptions as aW, ServerClient as aX, ServerCollectionClient as aY, ServerCollectionQueryBuilder as aZ, ServerCommerceClient as a_, type DiscountApiOptions as aa, type ExtractArrayType as ab, type GenerateMetadataOptions as ac, GoneError as ad, type InfiniteQueryOptions as ae, ModerationApi as af, type ModerationApiOptions as ag, NetworkError as ah, NotFoundError as ai, OrderApi as aj, type OrderApiOptions as ak, type PaginationMeta as al, type PayloadMutationResponse as am, PermissionError as an, ProductApi as ao, type ProductApiOptions as ap, type ProductDetailBrand as aq, type ProductDetailCategory as ar, type ProductDetailImage as as, type ProductDetailListing as at, type ProductDetailOption as au, type ProductDetailOptionValue as av, type ProductDetailTag as aw, type ProductDetailVariant as ax, type ProductDetailVariantOptionValue as ay, type ProductDetailVideo as az, type StockCheckResponse as b, ServiceUnavailableError as b0, ShippingApi as b1, type ShippingApiOptions as b2, type StockCheckResult as b3, type SuspenseInfiniteQueryOptions as b4, type SuspenseQueryOptions as b5, TimeoutError as b6, type UnbanCustomerParams as b7, type UpdateFulfillmentParams as b8, type UpdateOrderParams as b9, isServiceUnavailableError as bA, isTimeoutError as bB, isUsageLimitError as bC, isValidationError as bD, normalizeSelectedValueIds as bE, resolveApiUrl as bF, resolveVariantForSelection as bG, type UpdateProfileData as ba, type UpdateReturnParams as bb, type UpdateTransactionParams as bc, UsageLimitError as bd, ValidationError as be, buildProductListingGroupsByOption as bf, buildProductListingProjection as bg, buildProductOptionMatrix as bh, createAuthError as bi, createConflictError as bj, createNotFoundError as bk, createPermissionError as bl, createRateLimitError as bm, createServerClient as bn, getAvailableOptionValues as bo, getSelectedValueByOptionId as bp, isApiError as bq, isAuthError as br, isConfigError as bs, isConflictError as bt, isGoneError as bu, isNetworkError as bv, isNotFoundError as bw, isPermissionError as bx, isRateLimitError as by, isSDKError as bz, type ProductDetailParams as c, type ProductDetail as d, type ApplyDiscountParams as e, type RemoveDiscountParams as f, type ClearCartParams as g, type CheckoutParams as h, type PayloadFindResponse as i, type ValidateDiscountResult as j, type CalculateShippingParams as k, type CalculateShippingResult as l, type ApiQueryOptions as m, type ProductListingGroupsQueryOptions as n, CommunityClient as o, type ReadOnlyQueryHooks as p, ReadOnlyCollectionClient as q, type ClientState as r, type ClientConfig as s, ApiError as t, AuthError as u, BaseApi as v, type BulkImportFulfillmentsParams as w, type BulkImportFulfillmentsResponse as x, CartApi as y, type CartApiOptions as z };
|