@misiki/gocommerce-connector 0.9.0 → 0.9.1
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/dist/{index-72kQMxjZ.d.cts → index-DSvV8FbK.d.cts} +11 -137
- package/dist/{index-72kQMxjZ.d.ts → index-DSvV8FbK.d.ts} +11 -137
- package/dist/index.cjs +30 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +30 -1
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +30 -1
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1924,155 +1924,29 @@ declare class ProductService extends CatalogService {
|
|
|
1924
1924
|
noOfPage: number;
|
|
1925
1925
|
page: number;
|
|
1926
1926
|
}>;
|
|
1927
|
-
/**
|
|
1928
|
-
|
|
1927
|
+
/**
|
|
1928
|
+
* More like this product. Given `product` (a slug or id), it is the
|
|
1929
|
+
* product's category first, then its collections, then the newest — never
|
|
1930
|
+
* the product itself. Many shops never fill in categories, and an empty
|
|
1931
|
+
* rail under every product page reads as a broken shop.
|
|
1932
|
+
*
|
|
1933
|
+
* Without `product`, it is the old answer: more from `categoryId`.
|
|
1934
|
+
*/
|
|
1935
|
+
listRelatedProducts({ page, categoryId, product, limit, }?: {
|
|
1929
1936
|
page?: number;
|
|
1930
1937
|
categoryId?: string;
|
|
1938
|
+
product?: string;
|
|
1931
1939
|
limit?: number;
|
|
1932
1940
|
}): Promise<{
|
|
1933
1941
|
data: {
|
|
1934
1942
|
id: string;
|
|
1935
|
-
slug: string;
|
|
1936
|
-
title: string;
|
|
1937
|
-
name: string;
|
|
1938
|
-
subtitle: null;
|
|
1939
|
-
description: string;
|
|
1940
|
-
status: string;
|
|
1941
|
-
active: boolean;
|
|
1942
|
-
type: string;
|
|
1943
|
-
currency: string;
|
|
1944
|
-
currencyCode: string;
|
|
1945
|
-
price: number;
|
|
1946
|
-
mrp: number;
|
|
1947
|
-
minPrice: number;
|
|
1948
|
-
maxPrice: number;
|
|
1949
|
-
sku: string;
|
|
1950
|
-
barcode: string | null;
|
|
1951
|
-
weight: number | null;
|
|
1952
|
-
originCountry: string | null;
|
|
1953
|
-
thumbnail: string;
|
|
1954
|
-
image_url: string;
|
|
1955
|
-
images: string;
|
|
1956
|
-
imageList: string[];
|
|
1957
|
-
manageInventory: boolean;
|
|
1958
|
-
allowBackorder: boolean;
|
|
1959
|
-
stock: number;
|
|
1960
|
-
hasStock: boolean;
|
|
1961
|
-
categoryId: string | null;
|
|
1962
|
-
category: {
|
|
1963
|
-
id: string;
|
|
1964
|
-
name: string;
|
|
1965
|
-
slug: string;
|
|
1966
|
-
} | null;
|
|
1967
|
-
categories: {
|
|
1968
|
-
category: {
|
|
1969
|
-
id: string;
|
|
1970
|
-
name: string;
|
|
1971
|
-
slug: string;
|
|
1972
|
-
};
|
|
1973
|
-
}[];
|
|
1974
|
-
categoryHierarchy: {
|
|
1975
|
-
name: string;
|
|
1976
|
-
slug: string;
|
|
1977
|
-
}[];
|
|
1978
|
-
collections: {
|
|
1979
|
-
id: string;
|
|
1980
|
-
name: string;
|
|
1981
|
-
slug: string;
|
|
1982
|
-
}[];
|
|
1983
|
-
vendor: {
|
|
1984
|
-
businessName: string;
|
|
1985
|
-
} | null;
|
|
1986
|
-
productTags: string;
|
|
1987
|
-
keywords: string;
|
|
1988
|
-
metaTitle: string;
|
|
1989
|
-
metaDescription: string | null;
|
|
1990
|
-
link: string;
|
|
1991
|
-
options: {
|
|
1992
|
-
id: string;
|
|
1993
|
-
title: string;
|
|
1994
|
-
name: string;
|
|
1995
|
-
type: string;
|
|
1996
|
-
values: {
|
|
1997
|
-
id: string;
|
|
1998
|
-
value: string;
|
|
1999
|
-
}[];
|
|
2000
|
-
}[];
|
|
2001
|
-
variants: {
|
|
2002
|
-
id: string;
|
|
2003
|
-
productId: string;
|
|
2004
|
-
title: string;
|
|
2005
|
-
sku: string;
|
|
2006
|
-
barcode: string | null;
|
|
2007
|
-
price: number;
|
|
2008
|
-
mrp: number;
|
|
2009
|
-
stock: number;
|
|
2010
|
-
manageInventory: boolean;
|
|
2011
|
-
allowBackorder: boolean;
|
|
2012
|
-
active: boolean;
|
|
2013
|
-
weight: number | null;
|
|
2014
|
-
length: number | null;
|
|
2015
|
-
width: number | null;
|
|
2016
|
-
height: number | null;
|
|
2017
|
-
images: string;
|
|
2018
|
-
img: string;
|
|
2019
|
-
image: string;
|
|
2020
|
-
thumbnail: string;
|
|
2021
|
-
options: {
|
|
2022
|
-
optionId: string;
|
|
2023
|
-
value: string;
|
|
2024
|
-
}[];
|
|
2025
|
-
metadata: Record<string, unknown> | null;
|
|
2026
|
-
}[];
|
|
2027
|
-
ratings: ReturnType<typeof toRating>[];
|
|
2028
|
-
rating: number | null;
|
|
2029
|
-
ratingCount: number;
|
|
2030
|
-
reviewCount: number;
|
|
2031
|
-
attributes: {
|
|
2032
|
-
name: string;
|
|
2033
|
-
value: string;
|
|
2034
|
-
handle: string;
|
|
2035
|
-
}[];
|
|
2036
|
-
metadata: Record<string, unknown> | null;
|
|
2037
|
-
createdAt: string;
|
|
2038
|
-
updatedAt: string;
|
|
2039
|
-
}[] | {
|
|
2040
|
-
id: string;
|
|
2041
|
-
slug: string;
|
|
2042
|
-
title: string;
|
|
2043
|
-
name: string;
|
|
2044
|
-
description: string;
|
|
2045
|
-
currency: string;
|
|
2046
|
-
price: number;
|
|
2047
|
-
mrp: number;
|
|
2048
|
-
minPrice: number;
|
|
2049
|
-
maxPrice: number;
|
|
2050
|
-
thumbnail: string | null;
|
|
2051
|
-
image_url: string | null;
|
|
2052
|
-
images: string;
|
|
2053
|
-
stock: number;
|
|
2054
|
-
hasStock: boolean;
|
|
2055
|
-
manageInventory: boolean;
|
|
2056
|
-
allowBackorder: boolean;
|
|
2057
|
-
productTags: string;
|
|
2058
|
-
category: {
|
|
2059
|
-
name: string;
|
|
2060
|
-
slug: string;
|
|
2061
|
-
} | null;
|
|
2062
|
-
vendor: {
|
|
2063
|
-
businessName: string;
|
|
2064
|
-
} | null;
|
|
2065
|
-
variants: ReturnType<typeof toVariant>[];
|
|
2066
|
-
options: never[];
|
|
2067
|
-
ratings: never[];
|
|
2068
|
-
link: string;
|
|
2069
|
-
updatedAt: string;
|
|
2070
1943
|
}[];
|
|
2071
1944
|
count: number;
|
|
2072
1945
|
pageSize: number;
|
|
2073
1946
|
noOfPage: number;
|
|
2074
1947
|
page: number;
|
|
2075
1948
|
}>;
|
|
1949
|
+
private relatedTo;
|
|
2076
1950
|
private shelf;
|
|
2077
1951
|
/**
|
|
2078
1952
|
* A review, through ext/reviews. The engine asks for a name and an email
|
|
@@ -1924,155 +1924,29 @@ declare class ProductService extends CatalogService {
|
|
|
1924
1924
|
noOfPage: number;
|
|
1925
1925
|
page: number;
|
|
1926
1926
|
}>;
|
|
1927
|
-
/**
|
|
1928
|
-
|
|
1927
|
+
/**
|
|
1928
|
+
* More like this product. Given `product` (a slug or id), it is the
|
|
1929
|
+
* product's category first, then its collections, then the newest — never
|
|
1930
|
+
* the product itself. Many shops never fill in categories, and an empty
|
|
1931
|
+
* rail under every product page reads as a broken shop.
|
|
1932
|
+
*
|
|
1933
|
+
* Without `product`, it is the old answer: more from `categoryId`.
|
|
1934
|
+
*/
|
|
1935
|
+
listRelatedProducts({ page, categoryId, product, limit, }?: {
|
|
1929
1936
|
page?: number;
|
|
1930
1937
|
categoryId?: string;
|
|
1938
|
+
product?: string;
|
|
1931
1939
|
limit?: number;
|
|
1932
1940
|
}): Promise<{
|
|
1933
1941
|
data: {
|
|
1934
1942
|
id: string;
|
|
1935
|
-
slug: string;
|
|
1936
|
-
title: string;
|
|
1937
|
-
name: string;
|
|
1938
|
-
subtitle: null;
|
|
1939
|
-
description: string;
|
|
1940
|
-
status: string;
|
|
1941
|
-
active: boolean;
|
|
1942
|
-
type: string;
|
|
1943
|
-
currency: string;
|
|
1944
|
-
currencyCode: string;
|
|
1945
|
-
price: number;
|
|
1946
|
-
mrp: number;
|
|
1947
|
-
minPrice: number;
|
|
1948
|
-
maxPrice: number;
|
|
1949
|
-
sku: string;
|
|
1950
|
-
barcode: string | null;
|
|
1951
|
-
weight: number | null;
|
|
1952
|
-
originCountry: string | null;
|
|
1953
|
-
thumbnail: string;
|
|
1954
|
-
image_url: string;
|
|
1955
|
-
images: string;
|
|
1956
|
-
imageList: string[];
|
|
1957
|
-
manageInventory: boolean;
|
|
1958
|
-
allowBackorder: boolean;
|
|
1959
|
-
stock: number;
|
|
1960
|
-
hasStock: boolean;
|
|
1961
|
-
categoryId: string | null;
|
|
1962
|
-
category: {
|
|
1963
|
-
id: string;
|
|
1964
|
-
name: string;
|
|
1965
|
-
slug: string;
|
|
1966
|
-
} | null;
|
|
1967
|
-
categories: {
|
|
1968
|
-
category: {
|
|
1969
|
-
id: string;
|
|
1970
|
-
name: string;
|
|
1971
|
-
slug: string;
|
|
1972
|
-
};
|
|
1973
|
-
}[];
|
|
1974
|
-
categoryHierarchy: {
|
|
1975
|
-
name: string;
|
|
1976
|
-
slug: string;
|
|
1977
|
-
}[];
|
|
1978
|
-
collections: {
|
|
1979
|
-
id: string;
|
|
1980
|
-
name: string;
|
|
1981
|
-
slug: string;
|
|
1982
|
-
}[];
|
|
1983
|
-
vendor: {
|
|
1984
|
-
businessName: string;
|
|
1985
|
-
} | null;
|
|
1986
|
-
productTags: string;
|
|
1987
|
-
keywords: string;
|
|
1988
|
-
metaTitle: string;
|
|
1989
|
-
metaDescription: string | null;
|
|
1990
|
-
link: string;
|
|
1991
|
-
options: {
|
|
1992
|
-
id: string;
|
|
1993
|
-
title: string;
|
|
1994
|
-
name: string;
|
|
1995
|
-
type: string;
|
|
1996
|
-
values: {
|
|
1997
|
-
id: string;
|
|
1998
|
-
value: string;
|
|
1999
|
-
}[];
|
|
2000
|
-
}[];
|
|
2001
|
-
variants: {
|
|
2002
|
-
id: string;
|
|
2003
|
-
productId: string;
|
|
2004
|
-
title: string;
|
|
2005
|
-
sku: string;
|
|
2006
|
-
barcode: string | null;
|
|
2007
|
-
price: number;
|
|
2008
|
-
mrp: number;
|
|
2009
|
-
stock: number;
|
|
2010
|
-
manageInventory: boolean;
|
|
2011
|
-
allowBackorder: boolean;
|
|
2012
|
-
active: boolean;
|
|
2013
|
-
weight: number | null;
|
|
2014
|
-
length: number | null;
|
|
2015
|
-
width: number | null;
|
|
2016
|
-
height: number | null;
|
|
2017
|
-
images: string;
|
|
2018
|
-
img: string;
|
|
2019
|
-
image: string;
|
|
2020
|
-
thumbnail: string;
|
|
2021
|
-
options: {
|
|
2022
|
-
optionId: string;
|
|
2023
|
-
value: string;
|
|
2024
|
-
}[];
|
|
2025
|
-
metadata: Record<string, unknown> | null;
|
|
2026
|
-
}[];
|
|
2027
|
-
ratings: ReturnType<typeof toRating>[];
|
|
2028
|
-
rating: number | null;
|
|
2029
|
-
ratingCount: number;
|
|
2030
|
-
reviewCount: number;
|
|
2031
|
-
attributes: {
|
|
2032
|
-
name: string;
|
|
2033
|
-
value: string;
|
|
2034
|
-
handle: string;
|
|
2035
|
-
}[];
|
|
2036
|
-
metadata: Record<string, unknown> | null;
|
|
2037
|
-
createdAt: string;
|
|
2038
|
-
updatedAt: string;
|
|
2039
|
-
}[] | {
|
|
2040
|
-
id: string;
|
|
2041
|
-
slug: string;
|
|
2042
|
-
title: string;
|
|
2043
|
-
name: string;
|
|
2044
|
-
description: string;
|
|
2045
|
-
currency: string;
|
|
2046
|
-
price: number;
|
|
2047
|
-
mrp: number;
|
|
2048
|
-
minPrice: number;
|
|
2049
|
-
maxPrice: number;
|
|
2050
|
-
thumbnail: string | null;
|
|
2051
|
-
image_url: string | null;
|
|
2052
|
-
images: string;
|
|
2053
|
-
stock: number;
|
|
2054
|
-
hasStock: boolean;
|
|
2055
|
-
manageInventory: boolean;
|
|
2056
|
-
allowBackorder: boolean;
|
|
2057
|
-
productTags: string;
|
|
2058
|
-
category: {
|
|
2059
|
-
name: string;
|
|
2060
|
-
slug: string;
|
|
2061
|
-
} | null;
|
|
2062
|
-
vendor: {
|
|
2063
|
-
businessName: string;
|
|
2064
|
-
} | null;
|
|
2065
|
-
variants: ReturnType<typeof toVariant>[];
|
|
2066
|
-
options: never[];
|
|
2067
|
-
ratings: never[];
|
|
2068
|
-
link: string;
|
|
2069
|
-
updatedAt: string;
|
|
2070
1943
|
}[];
|
|
2071
1944
|
count: number;
|
|
2072
1945
|
pageSize: number;
|
|
2073
1946
|
noOfPage: number;
|
|
2074
1947
|
page: number;
|
|
2075
1948
|
}>;
|
|
1949
|
+
private relatedTo;
|
|
2076
1950
|
private shelf;
|
|
2077
1951
|
/**
|
|
2078
1952
|
* A review, through ext/reviews. The engine asks for a name and an email
|
package/dist/index.cjs
CHANGED
|
@@ -1241,17 +1241,46 @@ var ProductService = class extends CatalogService {
|
|
|
1241
1241
|
async listTrendingProducts({ page = 1, limit } = {}) {
|
|
1242
1242
|
return this.shelf("trending", { page, limit });
|
|
1243
1243
|
}
|
|
1244
|
-
/**
|
|
1244
|
+
/**
|
|
1245
|
+
* More like this product. Given `product` (a slug or id), it is the
|
|
1246
|
+
* product's category first, then its collections, then the newest — never
|
|
1247
|
+
* the product itself. Many shops never fill in categories, and an empty
|
|
1248
|
+
* rail under every product page reads as a broken shop.
|
|
1249
|
+
*
|
|
1250
|
+
* Without `product`, it is the old answer: more from `categoryId`.
|
|
1251
|
+
*/
|
|
1245
1252
|
async listRelatedProducts({
|
|
1246
1253
|
page = 1,
|
|
1247
1254
|
categoryId,
|
|
1255
|
+
product,
|
|
1248
1256
|
limit
|
|
1249
1257
|
} = {}) {
|
|
1258
|
+
if (product) return this.relatedTo(String(product), limit);
|
|
1250
1259
|
if (!categoryId) return this.list({ page, limit });
|
|
1251
1260
|
const category = (await this.facts.categories()).find((c) => String(c.id) === String(categoryId));
|
|
1252
1261
|
if (!category) return this.list({ page, limit });
|
|
1253
1262
|
return this.list({ page, limit, categories: category.slug });
|
|
1254
1263
|
}
|
|
1264
|
+
async relatedTo(slug, limit) {
|
|
1265
|
+
const size = Math.min(100, Math.max(1, Number(limit) || PAGE_SIZE));
|
|
1266
|
+
const p = await this.findProduct(slug);
|
|
1267
|
+
const self = String(p.id);
|
|
1268
|
+
const picked = /* @__PURE__ */ new Map();
|
|
1269
|
+
const add = (rows) => {
|
|
1270
|
+
for (const r of rows) {
|
|
1271
|
+
if (picked.size >= size) return;
|
|
1272
|
+
if (r.id !== self && !picked.has(r.id)) picked.set(r.id, r);
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
if (p.category) add((await this.list({ limit: size + 1, categories: p.category.slug })).data);
|
|
1276
|
+
for (const c of p.collections ?? []) {
|
|
1277
|
+
if (picked.size >= size) break;
|
|
1278
|
+
add((await this.shelf(c.slug, { page: 1, limit: size + 1 })).data);
|
|
1279
|
+
}
|
|
1280
|
+
if (picked.size < size) add((await this.list({ limit: size + 1 })).data);
|
|
1281
|
+
const data = [...picked.values()];
|
|
1282
|
+
return { data, count: data.length, pageSize: size, noOfPage: 1, page: 1 };
|
|
1283
|
+
}
|
|
1255
1284
|
async shelf(slug, { page, sort, limit }) {
|
|
1256
1285
|
const size = Math.min(100, Math.max(1, Number(limit) || PAGE_SIZE));
|
|
1257
1286
|
try {
|