@01.software/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 +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-C0GlmeJ_.d.cts → const-DAjQYNuM.d.ts} +4 -4
- package/dist/{const-D-xucnw4.d.ts → const-Dsixdi6z.d.cts} +4 -4
- package/dist/index.cjs +626 -13
- 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 +626 -13
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-BPvUmPAq.d.cts → payload-types-Ci-ZA7aM.d.cts} +153 -73
- package/dist/{payload-types-BPvUmPAq.d.ts → payload-types-Ci-ZA7aM.d.ts} +153 -73
- 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-n3xK4Nks.d.cts → server-C0C8dtms.d.cts} +331 -12
- package/dist/{server-_zvihptw.d.ts → server-Cv0Q4dPQ.d.ts} +331 -12
- package/dist/server.cjs +68 -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 +68 -4
- package/dist/server.js.map +1 -1
- package/dist/{types-BLdthWiW.d.ts → types-BWq_WlbB.d.ts} +1 -1
- package/dist/{types-DzWNu9pw.d.cts → types-zKjATmDK.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 +1 -1
|
@@ -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-Ci-ZA7aM.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-BWq_WlbB.js';
|
|
7
|
+
import { P as PublicCollection, d as ServerCollection } from './const-DAjQYNuM.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;
|
|
@@ -850,9 +889,7 @@ type EntityID = string;
|
|
|
850
889
|
type RelationshipValue = string | number | null | undefined | {
|
|
851
890
|
id?: string | number | null;
|
|
852
891
|
};
|
|
853
|
-
type MediaValue =
|
|
854
|
-
id?: EntityID | null;
|
|
855
|
-
} | EntityID | null | undefined;
|
|
892
|
+
type MediaValue = ProductDetailMedia | null | undefined;
|
|
856
893
|
interface ProductOptionValueShape {
|
|
857
894
|
id?: string | number | null;
|
|
858
895
|
option?: RelationshipValue;
|
|
@@ -867,6 +904,7 @@ interface ProductOptionValueShape {
|
|
|
867
904
|
interface ProductOptionShape {
|
|
868
905
|
id?: string | number | null;
|
|
869
906
|
title?: string | null;
|
|
907
|
+
slug?: string | null;
|
|
870
908
|
_order?: string | null;
|
|
871
909
|
'_product-options_options_order'?: string | null;
|
|
872
910
|
values?: {
|
|
@@ -894,6 +932,7 @@ interface ProductListingProductShape {
|
|
|
894
932
|
type ProductOptionMatrixValue = {
|
|
895
933
|
id: string;
|
|
896
934
|
optionId: string;
|
|
935
|
+
optionSlug: string;
|
|
897
936
|
label: string;
|
|
898
937
|
slug: string | null;
|
|
899
938
|
swatchColor?: string | null;
|
|
@@ -904,6 +943,7 @@ type ProductOptionMatrixValue = {
|
|
|
904
943
|
type ProductOptionMatrixOption = {
|
|
905
944
|
id: string;
|
|
906
945
|
title: string;
|
|
946
|
+
slug: string;
|
|
907
947
|
order: string;
|
|
908
948
|
values: ProductOptionMatrixValue[];
|
|
909
949
|
};
|
|
@@ -911,14 +951,18 @@ type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVa
|
|
|
911
951
|
id: string;
|
|
912
952
|
optionValueIds: string[];
|
|
913
953
|
optionValueByOptionId: Map<string, string>;
|
|
954
|
+
optionValueByOptionSlug: Map<string, string>;
|
|
914
955
|
source: TVariant;
|
|
915
956
|
};
|
|
916
957
|
type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
|
|
917
958
|
options: ProductOptionMatrixOption[];
|
|
918
959
|
optionIds: string[];
|
|
960
|
+
optionSlugs: string[];
|
|
919
961
|
optionById: Map<string, ProductOptionMatrixOption>;
|
|
962
|
+
optionBySlug: Map<string, ProductOptionMatrixOption>;
|
|
920
963
|
valueById: Map<string, ProductOptionMatrixValue>;
|
|
921
964
|
valueToOptionId: Map<string, string>;
|
|
965
|
+
valueToOptionSlug: Map<string, string>;
|
|
922
966
|
variants: ProductOptionMatrixVariant<TVariant>[];
|
|
923
967
|
};
|
|
924
968
|
type ProductListingProjection = {
|
|
@@ -945,14 +989,90 @@ type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantSh
|
|
|
945
989
|
variants: TVariant[];
|
|
946
990
|
listing: ProductListingProjection;
|
|
947
991
|
};
|
|
992
|
+
type ProductSelectionByOptionValue = string | number | null | undefined | {
|
|
993
|
+
valueId?: string | number | null;
|
|
994
|
+
valueSlug?: string | null;
|
|
995
|
+
};
|
|
996
|
+
type ProductSelectionInput = {
|
|
997
|
+
variantId?: string | number | null;
|
|
998
|
+
byOptionSlug?: Record<string, ProductSelectionByOptionValue>;
|
|
999
|
+
byOptionId?: Record<string, ProductSelectionByOptionValue>;
|
|
1000
|
+
valueIds?: Iterable<unknown>;
|
|
1001
|
+
search?: string | URLSearchParams | URL | null;
|
|
1002
|
+
};
|
|
1003
|
+
type NormalizedProductSelection = {
|
|
1004
|
+
byOptionSlug: Record<string, string>;
|
|
1005
|
+
byOptionId: Record<string, string>;
|
|
1006
|
+
valueIds: string[];
|
|
1007
|
+
variantId: string | null;
|
|
1008
|
+
};
|
|
1009
|
+
type LegacyProductSelectionParamEvent = {
|
|
1010
|
+
optionId: string;
|
|
1011
|
+
optionSlug: string;
|
|
1012
|
+
valueSlug: string;
|
|
1013
|
+
searchParam: string;
|
|
1014
|
+
};
|
|
1015
|
+
type ProductSelectionCodecOptions = {
|
|
1016
|
+
onLegacyOptionIdParam?: (event: LegacyProductSelectionParamEvent) => void;
|
|
1017
|
+
};
|
|
1018
|
+
type ProductSelectionAvailableValue = {
|
|
1019
|
+
valueId: string;
|
|
1020
|
+
value: string;
|
|
1021
|
+
slug: string;
|
|
1022
|
+
selected: boolean;
|
|
1023
|
+
available: boolean;
|
|
1024
|
+
swatchColor?: string | null;
|
|
1025
|
+
thumbnail?: MediaValue;
|
|
1026
|
+
images?: MediaValue[] | null;
|
|
1027
|
+
};
|
|
1028
|
+
type ProductSelectionResolution = {
|
|
1029
|
+
normalizedSelection: NormalizedProductSelection;
|
|
1030
|
+
selectedVariant: ProductDetailVariant | null;
|
|
1031
|
+
matchingVariants: ProductDetailVariant[];
|
|
1032
|
+
partialVariants: ProductDetailVariant[];
|
|
1033
|
+
availableValuesByOptionSlug: Record<string, ProductSelectionAvailableValue[]>;
|
|
1034
|
+
availableValuesByOptionId: Record<string, ProductSelectionAvailableValue[]>;
|
|
1035
|
+
allOptionsSelected: boolean;
|
|
1036
|
+
price: {
|
|
1037
|
+
min: number | null;
|
|
1038
|
+
max: number | null;
|
|
1039
|
+
compareAtMin: number | null;
|
|
1040
|
+
compareAtMax: number | null;
|
|
1041
|
+
isRange: boolean;
|
|
1042
|
+
};
|
|
1043
|
+
media: {
|
|
1044
|
+
primaryImage: ProductDetailMedia | null;
|
|
1045
|
+
images: ProductDetailMedia[];
|
|
1046
|
+
};
|
|
1047
|
+
stock: {
|
|
1048
|
+
availableForSale: boolean;
|
|
1049
|
+
isUnlimited: boolean;
|
|
1050
|
+
stock: number | null;
|
|
1051
|
+
reservedStock: number | null;
|
|
1052
|
+
availableStock: number | null;
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
declare class ProductSelectionCodecError extends Error {
|
|
1056
|
+
code: string;
|
|
1057
|
+
constructor(message: string);
|
|
1058
|
+
}
|
|
948
1059
|
declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
|
|
949
1060
|
options: ProductOptionShape[];
|
|
950
1061
|
variants?: TVariant[];
|
|
951
1062
|
}): ProductOptionMatrix<TVariant>;
|
|
1063
|
+
declare function buildProductOptionMatrixFromDetail(detail: ProductDetail): ProductOptionMatrix<ProductDetailVariant>;
|
|
952
1064
|
declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
|
|
953
1065
|
declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
|
|
954
1066
|
declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
|
|
955
1067
|
declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
|
|
1068
|
+
declare function normalizeProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
|
|
1069
|
+
declare function parseProductSelection(detail: ProductDetail, search: string | URLSearchParams | URL | null | undefined, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
|
|
1070
|
+
declare function stringifyProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): string;
|
|
1071
|
+
declare function createProductSelectionCodec(detail: ProductDetail, options?: ProductSelectionCodecOptions): {
|
|
1072
|
+
parse: (search: string | URLSearchParams | URL | null | undefined) => NormalizedProductSelection;
|
|
1073
|
+
stringify: (selection?: ProductSelectionInput) => string;
|
|
1074
|
+
};
|
|
1075
|
+
declare function resolveProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): ProductSelectionResolution;
|
|
956
1076
|
declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
|
|
957
1077
|
/**
|
|
958
1078
|
* Builds product-first listing groups for one primary option.
|
|
@@ -998,6 +1118,170 @@ type ProductListingGroupsItem = {
|
|
|
998
1118
|
type ProductListingGroupsResponse = {
|
|
999
1119
|
docs: ProductListingGroupsItem[];
|
|
1000
1120
|
};
|
|
1121
|
+
type ProductDetailParams = {
|
|
1122
|
+
slug: string;
|
|
1123
|
+
} | {
|
|
1124
|
+
id: string;
|
|
1125
|
+
};
|
|
1126
|
+
interface ProductDetailVariantOptionValue {
|
|
1127
|
+
optionId: string | number;
|
|
1128
|
+
optionSlug: string;
|
|
1129
|
+
valueId: string | number;
|
|
1130
|
+
valueSlug: string;
|
|
1131
|
+
value?: string | null;
|
|
1132
|
+
}
|
|
1133
|
+
type ProductDetailMedia = string | number | {
|
|
1134
|
+
id?: string | number | null;
|
|
1135
|
+
url?: string | null;
|
|
1136
|
+
alt?: string | null;
|
|
1137
|
+
width?: number | null;
|
|
1138
|
+
height?: number | null;
|
|
1139
|
+
};
|
|
1140
|
+
interface ProductDetailVariant {
|
|
1141
|
+
id: string | number;
|
|
1142
|
+
optionKey: string;
|
|
1143
|
+
title?: string | null;
|
|
1144
|
+
displayName: string;
|
|
1145
|
+
sku?: string | null;
|
|
1146
|
+
price: number;
|
|
1147
|
+
compareAtPrice?: number | null;
|
|
1148
|
+
stock: number;
|
|
1149
|
+
reservedStock: number;
|
|
1150
|
+
isUnlimited: boolean;
|
|
1151
|
+
isActive: boolean;
|
|
1152
|
+
thumbnail?: ProductDetailMedia | null;
|
|
1153
|
+
images?: ProductDetailMedia[];
|
|
1154
|
+
optionValues: ProductDetailVariantOptionValue[];
|
|
1155
|
+
}
|
|
1156
|
+
interface ProductDetailOptionValue {
|
|
1157
|
+
id: string | number;
|
|
1158
|
+
value: string;
|
|
1159
|
+
slug: string;
|
|
1160
|
+
swatchColor?: string | null;
|
|
1161
|
+
thumbnail?: ProductDetailMedia | null;
|
|
1162
|
+
images?: ProductDetailMedia[] | null;
|
|
1163
|
+
}
|
|
1164
|
+
interface ProductDetailOption {
|
|
1165
|
+
id: string | number;
|
|
1166
|
+
title: string;
|
|
1167
|
+
slug: string;
|
|
1168
|
+
values: ProductDetailOptionValue[];
|
|
1169
|
+
}
|
|
1170
|
+
interface ProductDetailBrand {
|
|
1171
|
+
id: string | number;
|
|
1172
|
+
name: string;
|
|
1173
|
+
slug?: string | null;
|
|
1174
|
+
logo?: unknown | null;
|
|
1175
|
+
}
|
|
1176
|
+
interface ProductDetailCategory {
|
|
1177
|
+
id: string | number;
|
|
1178
|
+
title: string;
|
|
1179
|
+
slug?: string | null;
|
|
1180
|
+
}
|
|
1181
|
+
interface ProductDetailTag {
|
|
1182
|
+
id: string | number;
|
|
1183
|
+
title: string;
|
|
1184
|
+
slug?: string | null;
|
|
1185
|
+
}
|
|
1186
|
+
interface ProductDetailImage {
|
|
1187
|
+
id: string | number;
|
|
1188
|
+
url?: string | null;
|
|
1189
|
+
alt?: string | null;
|
|
1190
|
+
width?: number | null;
|
|
1191
|
+
height?: number | null;
|
|
1192
|
+
}
|
|
1193
|
+
interface ProductDetailVideo {
|
|
1194
|
+
id: string | number;
|
|
1195
|
+
url?: string | null;
|
|
1196
|
+
}
|
|
1197
|
+
interface ProductDetailListing {
|
|
1198
|
+
minPrice?: number | null;
|
|
1199
|
+
maxPrice?: number | null;
|
|
1200
|
+
minCompareAtPrice?: number | null;
|
|
1201
|
+
maxCompareAtPrice?: number | null;
|
|
1202
|
+
isPriceRange?: boolean | null;
|
|
1203
|
+
primaryImage?: ProductDetailMedia | null;
|
|
1204
|
+
availableForSale?: boolean | null;
|
|
1205
|
+
selectionHintVariant?: string | number | null;
|
|
1206
|
+
}
|
|
1207
|
+
interface ProductDetail {
|
|
1208
|
+
product: {
|
|
1209
|
+
id: string | number;
|
|
1210
|
+
slug: string;
|
|
1211
|
+
title: string;
|
|
1212
|
+
subtitle?: string | null;
|
|
1213
|
+
description?: string | null;
|
|
1214
|
+
content?: unknown;
|
|
1215
|
+
publishedAt?: string | null;
|
|
1216
|
+
status: string;
|
|
1217
|
+
totalInventory: number;
|
|
1218
|
+
totalVariants: number;
|
|
1219
|
+
hasOnlyDefaultVariant: boolean;
|
|
1220
|
+
};
|
|
1221
|
+
variants: ProductDetailVariant[];
|
|
1222
|
+
options: ProductDetailOption[];
|
|
1223
|
+
brand: ProductDetailBrand | null;
|
|
1224
|
+
categories: ProductDetailCategory[];
|
|
1225
|
+
tags: ProductDetailTag[];
|
|
1226
|
+
images: ProductDetailImage[];
|
|
1227
|
+
videos: ProductDetailVideo[];
|
|
1228
|
+
listing: ProductDetailListing;
|
|
1229
|
+
}
|
|
1230
|
+
type ProductUpsertOptionValueInput = {
|
|
1231
|
+
id?: string;
|
|
1232
|
+
value: string;
|
|
1233
|
+
slug?: string;
|
|
1234
|
+
swatchColor?: string | null;
|
|
1235
|
+
thumbnail?: string | null;
|
|
1236
|
+
images?: string[];
|
|
1237
|
+
metadata?: unknown;
|
|
1238
|
+
};
|
|
1239
|
+
type ProductUpsertOptionInput = {
|
|
1240
|
+
id?: string;
|
|
1241
|
+
title: string;
|
|
1242
|
+
slug?: string;
|
|
1243
|
+
values: ProductUpsertOptionValueInput[];
|
|
1244
|
+
};
|
|
1245
|
+
type ProductUpsertVariantOptionValue = string | {
|
|
1246
|
+
valueSlug?: string;
|
|
1247
|
+
valueId?: string;
|
|
1248
|
+
value?: string;
|
|
1249
|
+
};
|
|
1250
|
+
type ProductUpsertVariantInput = {
|
|
1251
|
+
id?: string;
|
|
1252
|
+
optionValues?: Record<string, ProductUpsertVariantOptionValue> | string[];
|
|
1253
|
+
sku?: string | null;
|
|
1254
|
+
title?: string | null;
|
|
1255
|
+
price: number;
|
|
1256
|
+
compareAtPrice?: number | null;
|
|
1257
|
+
stock?: number;
|
|
1258
|
+
isUnlimited?: boolean;
|
|
1259
|
+
weight?: number | null;
|
|
1260
|
+
requiresShipping?: boolean;
|
|
1261
|
+
barcode?: string | null;
|
|
1262
|
+
externalId?: string | null;
|
|
1263
|
+
isActive?: boolean;
|
|
1264
|
+
thumbnail?: string | null;
|
|
1265
|
+
images?: string[];
|
|
1266
|
+
metadata?: unknown;
|
|
1267
|
+
};
|
|
1268
|
+
type ProductUpsertParams = {
|
|
1269
|
+
product: Record<string, unknown> & {
|
|
1270
|
+
id?: string;
|
|
1271
|
+
title?: string;
|
|
1272
|
+
};
|
|
1273
|
+
options?: ProductUpsertOptionInput[];
|
|
1274
|
+
variants?: ProductUpsertVariantInput[];
|
|
1275
|
+
};
|
|
1276
|
+
type ProductUpsertResponse = {
|
|
1277
|
+
ok: true;
|
|
1278
|
+
product: Product;
|
|
1279
|
+
} | {
|
|
1280
|
+
ok: false;
|
|
1281
|
+
failedEntity: 'product' | 'option' | 'option-value' | 'variant';
|
|
1282
|
+
failedIndex?: number;
|
|
1283
|
+
message: string;
|
|
1284
|
+
};
|
|
1001
1285
|
declare class ProductApi extends BaseApi {
|
|
1002
1286
|
constructor(options: ProductApiOptions);
|
|
1003
1287
|
/**
|
|
@@ -1007,6 +1291,20 @@ declare class ProductApi extends BaseApi {
|
|
|
1007
1291
|
*/
|
|
1008
1292
|
stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
|
|
1009
1293
|
listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Fetch full product detail by slug or id.
|
|
1296
|
+
* Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
|
|
1297
|
+
* `tenant_mismatch` / `feature_disabled`). For the reason behind a null,
|
|
1298
|
+
* inspect `client.lastRequestId` against backend logs.
|
|
1299
|
+
*/
|
|
1300
|
+
detail(params: ProductDetailParams): Promise<ProductDetail | null>;
|
|
1301
|
+
/**
|
|
1302
|
+
* Atomically create or update a product together with its options,
|
|
1303
|
+
* option-values, and variants in a single transaction. Mirrors Shopify's
|
|
1304
|
+
* `productSet` shape and is the canonical write path for the MCP
|
|
1305
|
+
* `product-upsert` tool.
|
|
1306
|
+
*/
|
|
1307
|
+
upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
|
|
1010
1308
|
}
|
|
1011
1309
|
|
|
1012
1310
|
type DiscountApiOptions = ServerApiOptions;
|
|
@@ -1196,6 +1494,8 @@ declare class ServerCommerceClient {
|
|
|
1196
1494
|
readonly product: {
|
|
1197
1495
|
stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
|
|
1198
1496
|
listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
|
|
1497
|
+
detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
|
|
1498
|
+
upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
|
|
1199
1499
|
};
|
|
1200
1500
|
readonly cart: {
|
|
1201
1501
|
get: (cartId: string) => Promise<Cart>;
|
|
@@ -1371,9 +1671,15 @@ type ReadOnlyQueryHooks = Omit<QueryHooks, 'useCreate' | 'useUpdate' | 'useRemov
|
|
|
1371
1671
|
* Composes CollectionHooks + CustomerHooks into a single API surface.
|
|
1372
1672
|
* All methods are delegated; no logic lives here.
|
|
1373
1673
|
*/
|
|
1674
|
+
interface ProductDetailCallable {
|
|
1675
|
+
product: {
|
|
1676
|
+
detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1374
1679
|
declare class QueryHooks extends CollectionHooks {
|
|
1375
1680
|
private _customer;
|
|
1376
|
-
|
|
1681
|
+
private _commerce?;
|
|
1682
|
+
constructor(queryClient: QueryClient, collectionClient: CollectionClient, customerAuth?: CustomerAuth, commerceClient?: ProductDetailCallable);
|
|
1377
1683
|
useCustomerMe: CustomerHooks['useCustomerMe'];
|
|
1378
1684
|
useCustomerLogin: CustomerHooks['useCustomerLogin'];
|
|
1379
1685
|
useCustomerRegister: CustomerHooks['useCustomerRegister'];
|
|
@@ -1388,7 +1694,7 @@ declare class QueryHooks extends CollectionHooks {
|
|
|
1388
1694
|
setCustomerData: CustomerHooks['setCustomerData'];
|
|
1389
1695
|
useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
|
|
1390
1696
|
options?: ProductListingGroupsQueryOptions;
|
|
1391
|
-
}, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>):
|
|
1697
|
+
}, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
|
|
1392
1698
|
useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
|
|
1393
1699
|
options?: ProductListingGroupsQueryOptions;
|
|
1394
1700
|
}, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
|
|
@@ -1412,6 +1718,19 @@ declare class QueryHooks extends CollectionHooks {
|
|
|
1412
1718
|
pages?: number;
|
|
1413
1719
|
staleTime?: number;
|
|
1414
1720
|
}): Promise<void>;
|
|
1721
|
+
useProductDetail(params: {
|
|
1722
|
+
slug: string;
|
|
1723
|
+
} | {
|
|
1724
|
+
id: string;
|
|
1725
|
+
}, options?: {
|
|
1726
|
+
enabled?: boolean;
|
|
1727
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1728
|
+
useProductDetailBySlug(slug: string, options?: {
|
|
1729
|
+
enabled?: boolean;
|
|
1730
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1731
|
+
useProductDetailById(id: string, options?: {
|
|
1732
|
+
enabled?: boolean;
|
|
1733
|
+
}): UseQueryResult<ProductDetail | null>;
|
|
1415
1734
|
}
|
|
1416
1735
|
|
|
1417
1736
|
declare class ServerClient {
|
|
@@ -1440,4 +1759,4 @@ declare class ServerClient {
|
|
|
1440
1759
|
*/
|
|
1441
1760
|
declare function createServerClient(options: ClientServerConfig): ServerClient;
|
|
1442
1761
|
|
|
1443
|
-
export { type
|
|
1762
|
+
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 ReturnItem 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 ProductDetailVariant as aA, type ProductDetailVariantOptionValue as aB, type ProductDetailVideo as aC, type ProductListingGroup as aD, type ProductListingGroupSummary as aE, type ProductListingGroupsItem as aF, type ProductListingProductShape as aG, type ProductListingProjection as aH, type ProductOptionMatrix as aI, type ProductOptionMatrixOption as aJ, type ProductOptionMatrixValue as aK, type ProductOptionMatrixVariant as aL, type ProductOptionShape as aM, type ProductOptionValueShape as aN, type ProductSelectionAvailableValue as aO, type ProductSelectionByOptionValue as aP, ProductSelectionCodecError as aQ, type ProductSelectionCodecOptions as aR, type ProductSelectionInput as aS, type ProductSelectionResolution as aT, type ProductVariantShape as aU, QueryHooks as aV, type QueryOptions as aW, RateLimitError as aX, type ReadOnlyQueryBuilder as aY, type RequestOptions as aZ, type RetryConfig as a_, type DiscountApiOptions as aa, type ExtractArrayType as ab, type GenerateMetadataOptions as ac, GoneError as ad, type InfiniteQueryOptions as ae, type LegacyProductSelectionParamEvent as af, ModerationApi as ag, type ModerationApiOptions as ah, NetworkError as ai, type NormalizedProductSelection as aj, NotFoundError as ak, OrderApi as al, type OrderApiOptions as am, type PaginationMeta as an, type PayloadMutationResponse as ao, PermissionError as ap, ProductApi as aq, type ProductApiOptions as ar, type ProductDetailBrand as as, type ProductDetailCategory as at, type ProductDetailImage as au, type ProductDetailListing as av, type ProductDetailMedia as aw, type ProductDetailOption as ax, type ProductDetailOptionValue as ay, type ProductDetailTag as az, type StockCheckResponse as b, type ReturnReason as b0, type ReturnWithRefundParams as b1, SDKError as b2, type ServerApiOptions as b3, ServerClient as b4, ServerCollectionClient as b5, ServerCollectionQueryBuilder as b6, ServerCommerceClient as b7, type ServerCommerceClientOptions as b8, ServiceUnavailableError as b9, getSelectedValueByOptionId as bA, isApiError as bB, isAuthError as bC, isConfigError as bD, isConflictError as bE, isGoneError as bF, isNetworkError as bG, isNotFoundError as bH, isPermissionError as bI, isRateLimitError as bJ, isSDKError as bK, isServiceUnavailableError as bL, isTimeoutError as bM, isUsageLimitError as bN, isValidationError as bO, normalizeProductSelection as bP, normalizeSelectedValueIds as bQ, parseProductSelection as bR, resolveApiUrl as bS, resolveProductSelection as bT, resolveVariantForSelection as bU, stringifyProductSelection as bV, ShippingApi as ba, type ShippingApiOptions as bb, type StockCheckResult as bc, type SuspenseInfiniteQueryOptions as bd, type SuspenseQueryOptions as be, TimeoutError as bf, type UnbanCustomerParams as bg, type UpdateFulfillmentParams as bh, type UpdateOrderParams as bi, type UpdateProfileData as bj, type UpdateReturnParams as bk, type UpdateTransactionParams as bl, UsageLimitError as bm, ValidationError as bn, buildProductListingGroupsByOption as bo, buildProductListingProjection as bp, buildProductOptionMatrix as bq, buildProductOptionMatrixFromDetail as br, createAuthError as bs, createConflictError as bt, createNotFoundError as bu, createPermissionError as bv, createProductSelectionCodec as bw, createRateLimitError as bx, createServerClient as by, getAvailableOptionValues 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 };
|
package/dist/server.cjs
CHANGED
|
@@ -1374,6 +1374,29 @@ var ProductApi = class extends BaseApi {
|
|
|
1374
1374
|
params
|
|
1375
1375
|
);
|
|
1376
1376
|
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Fetch full product detail by slug or id.
|
|
1379
|
+
* Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
|
|
1380
|
+
* `tenant_mismatch` / `feature_disabled`). For the reason behind a null,
|
|
1381
|
+
* inspect `client.lastRequestId` against backend logs.
|
|
1382
|
+
*/
|
|
1383
|
+
async detail(params) {
|
|
1384
|
+
try {
|
|
1385
|
+
return await this.request("/api/products/detail", params);
|
|
1386
|
+
} catch (err) {
|
|
1387
|
+
if (err instanceof NotFoundError) return null;
|
|
1388
|
+
throw err;
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Atomically create or update a product together with its options,
|
|
1393
|
+
* option-values, and variants in a single transaction. Mirrors Shopify's
|
|
1394
|
+
* `productSet` shape and is the canonical write path for the MCP
|
|
1395
|
+
* `product-upsert` tool.
|
|
1396
|
+
*/
|
|
1397
|
+
upsert(params) {
|
|
1398
|
+
return this.request("/api/products/upsert", params);
|
|
1399
|
+
}
|
|
1377
1400
|
};
|
|
1378
1401
|
|
|
1379
1402
|
// src/core/api/discount-api.ts
|
|
@@ -1466,7 +1489,9 @@ var ServerCommerceClient = class {
|
|
|
1466
1489
|
const orderApi = new OrderApi(serverOptions);
|
|
1467
1490
|
this.product = {
|
|
1468
1491
|
stockCheck: productApi.stockCheck.bind(productApi),
|
|
1469
|
-
listingGroups: productApi.listingGroups.bind(productApi)
|
|
1492
|
+
listingGroups: productApi.listingGroups.bind(productApi),
|
|
1493
|
+
detail: productApi.detail.bind(productApi),
|
|
1494
|
+
upsert: productApi.upsert.bind(productApi)
|
|
1470
1495
|
};
|
|
1471
1496
|
this.cart = {
|
|
1472
1497
|
get: cartApi.getCart.bind(cartApi),
|
|
@@ -1553,10 +1578,24 @@ var customerKeys = {
|
|
|
1553
1578
|
};
|
|
1554
1579
|
var productKeys = {
|
|
1555
1580
|
listingGroups: (options) => ["products", "listing-groups", "list", options],
|
|
1556
|
-
listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options]
|
|
1581
|
+
listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options],
|
|
1582
|
+
detail: (params) => ["products", "detail", params],
|
|
1583
|
+
detailAll: () => ["products", "detail"]
|
|
1557
1584
|
};
|
|
1558
1585
|
|
|
1559
1586
|
// src/core/query/collection-hooks.ts
|
|
1587
|
+
var PRODUCT_DETAIL_INVALIDATING_COLLECTIONS = /* @__PURE__ */ new Set([
|
|
1588
|
+
"products",
|
|
1589
|
+
"product-variants",
|
|
1590
|
+
"product-options",
|
|
1591
|
+
"product-option-values",
|
|
1592
|
+
"product-categories",
|
|
1593
|
+
"product-tags",
|
|
1594
|
+
"product-collections",
|
|
1595
|
+
"brands",
|
|
1596
|
+
"brand-logos",
|
|
1597
|
+
"images"
|
|
1598
|
+
]);
|
|
1560
1599
|
var DEFAULT_PAGE_SIZE = 20;
|
|
1561
1600
|
var CollectionHooks = class {
|
|
1562
1601
|
constructor(queryClient, collectionClient) {
|
|
@@ -1714,6 +1753,9 @@ var CollectionHooks = class {
|
|
|
1714
1753
|
this.queryClient.invalidateQueries({
|
|
1715
1754
|
queryKey: collectionKeys(collection).all
|
|
1716
1755
|
});
|
|
1756
|
+
if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
|
|
1757
|
+
this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
|
|
1758
|
+
}
|
|
1717
1759
|
options?.onSuccess?.(data);
|
|
1718
1760
|
},
|
|
1719
1761
|
onError: options?.onError,
|
|
@@ -1734,6 +1776,9 @@ var CollectionHooks = class {
|
|
|
1734
1776
|
this.queryClient.invalidateQueries({
|
|
1735
1777
|
queryKey: collectionKeys(collection).all
|
|
1736
1778
|
});
|
|
1779
|
+
if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
|
|
1780
|
+
this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
|
|
1781
|
+
}
|
|
1737
1782
|
options?.onSuccess?.(data);
|
|
1738
1783
|
},
|
|
1739
1784
|
onError: options?.onError,
|
|
@@ -1750,6 +1795,9 @@ var CollectionHooks = class {
|
|
|
1750
1795
|
this.queryClient.invalidateQueries({
|
|
1751
1796
|
queryKey: collectionKeys(collection).all
|
|
1752
1797
|
});
|
|
1798
|
+
if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
|
|
1799
|
+
this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
|
|
1800
|
+
}
|
|
1753
1801
|
options?.onSuccess?.(data);
|
|
1754
1802
|
},
|
|
1755
1803
|
onError: options?.onError,
|
|
@@ -1902,7 +1950,7 @@ var CustomerHooks = class {
|
|
|
1902
1950
|
|
|
1903
1951
|
// src/core/query/query-hooks.ts
|
|
1904
1952
|
var QueryHooks = class extends CollectionHooks {
|
|
1905
|
-
constructor(queryClient, collectionClient, customerAuth) {
|
|
1953
|
+
constructor(queryClient, collectionClient, customerAuth, commerceClient) {
|
|
1906
1954
|
super(queryClient, collectionClient);
|
|
1907
1955
|
// --- Customer hooks delegation ---
|
|
1908
1956
|
this.useCustomerMe = (...args) => this._customer.useCustomerMe(...args);
|
|
@@ -1919,6 +1967,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
1919
1967
|
this.getCustomerData = () => this._customer.getCustomerData();
|
|
1920
1968
|
this.setCustomerData = (data) => this._customer.setCustomerData(data);
|
|
1921
1969
|
this._customer = new CustomerHooks(queryClient, customerAuth);
|
|
1970
|
+
this._commerce = commerceClient;
|
|
1922
1971
|
}
|
|
1923
1972
|
useProductListingGroupsQuery(params, options) {
|
|
1924
1973
|
const queryOptions = params.options;
|
|
@@ -2012,6 +2061,21 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
2012
2061
|
staleTime: options?.staleTime
|
|
2013
2062
|
});
|
|
2014
2063
|
}
|
|
2064
|
+
useProductDetail(params, options) {
|
|
2065
|
+
const discriminator = "slug" in params ? params.slug : params.id;
|
|
2066
|
+
const enabled = options?.enabled !== false && Boolean(discriminator);
|
|
2067
|
+
return (0, import_react_query4.useQuery)({
|
|
2068
|
+
queryKey: productKeys.detail(params),
|
|
2069
|
+
queryFn: () => this._commerce.product.detail(params),
|
|
2070
|
+
enabled
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
useProductDetailBySlug(slug, options) {
|
|
2074
|
+
return this.useProductDetail({ slug }, options);
|
|
2075
|
+
}
|
|
2076
|
+
useProductDetailById(id, options) {
|
|
2077
|
+
return this.useProductDetail({ id }, options);
|
|
2078
|
+
}
|
|
2015
2079
|
};
|
|
2016
2080
|
|
|
2017
2081
|
// src/core/client/client.server.ts
|
|
@@ -2062,7 +2126,7 @@ var ServerClient = class {
|
|
|
2062
2126
|
onRequestId
|
|
2063
2127
|
);
|
|
2064
2128
|
this.queryClient = getQueryClient();
|
|
2065
|
-
this.query = new QueryHooks(this.queryClient, this.collections);
|
|
2129
|
+
this.query = new QueryHooks(this.queryClient, this.collections, void 0, this.commerce);
|
|
2066
2130
|
}
|
|
2067
2131
|
getState() {
|
|
2068
2132
|
return { ...this.state };
|