@decocms/apps 0.23.3 → 0.24.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/LICENSE +21 -0
- package/commerce/components/Image.tsx +129 -143
- package/commerce/components/JsonLd.tsx +192 -201
- package/commerce/components/Picture.tsx +65 -75
- package/commerce/sdk/analytics.ts +15 -15
- package/commerce/sdk/formatPrice.ts +13 -16
- package/commerce/sdk/url.ts +7 -7
- package/commerce/sdk/useOffer.ts +46 -57
- package/commerce/sdk/useVariantPossibilities.ts +25 -25
- package/commerce/types/commerce.ts +868 -875
- package/commerce/utils/canonical.ts +5 -8
- package/commerce/utils/constants.ts +5 -6
- package/commerce/utils/filters.ts +4 -4
- package/commerce/utils/productToAnalyticsItem.ts +52 -56
- package/commerce/utils/stateByZip.ts +42 -42
- package/package.json +23 -4
- package/shopify/actions/cart/addItems.ts +24 -25
- package/shopify/actions/cart/updateCoupons.ts +19 -20
- package/shopify/actions/cart/updateItems.ts +19 -20
- package/shopify/actions/user/signIn.ts +25 -30
- package/shopify/actions/user/signUp.ts +19 -24
- package/shopify/client.ts +24 -24
- package/shopify/index.ts +20 -18
- package/shopify/init.ts +18 -21
- package/shopify/loaders/ProductDetailsPage.ts +16 -20
- package/shopify/loaders/ProductList.ts +66 -69
- package/shopify/loaders/ProductListingPage.ts +150 -158
- package/shopify/loaders/RelatedProducts.ts +24 -27
- package/shopify/loaders/cart.ts +53 -52
- package/shopify/loaders/shop.ts +22 -27
- package/shopify/loaders/user.ts +27 -32
- package/shopify/utils/admin/admin.ts +33 -34
- package/shopify/utils/admin/queries.ts +2 -2
- package/shopify/utils/cart.ts +18 -14
- package/shopify/utils/cookies.ts +62 -65
- package/shopify/utils/enums.ts +424 -424
- package/shopify/utils/graphql.ts +44 -55
- package/shopify/utils/storefront/queries.ts +24 -29
- package/shopify/utils/storefront/storefront.graphql.gen.ts +55 -55
- package/shopify/utils/transform.ts +370 -376
- package/shopify/utils/types.ts +118 -118
- package/shopify/utils/user.ts +11 -11
- package/shopify/utils/utils.ts +135 -140
- package/vtex/actions/address.ts +86 -86
- package/vtex/actions/auth.ts +14 -27
- package/vtex/actions/checkout.ts +36 -49
- package/vtex/actions/masterData.ts +10 -27
- package/vtex/actions/misc.ts +101 -111
- package/vtex/actions/newsletter.ts +48 -52
- package/vtex/actions/orders.ts +13 -16
- package/vtex/actions/profile.ts +55 -55
- package/vtex/actions/session.ts +36 -35
- package/vtex/actions/trigger.ts +25 -25
- package/vtex/actions/wishlist.ts +51 -53
- package/vtex/client.ts +14 -42
- package/vtex/hooks/index.ts +4 -4
- package/vtex/hooks/useAutocomplete.ts +42 -48
- package/vtex/hooks/useCart.ts +153 -165
- package/vtex/hooks/useUser.ts +40 -40
- package/vtex/hooks/useWishlist.ts +70 -70
- package/vtex/inline-loaders/productDetailsPage.ts +1 -3
- package/vtex/inline-loaders/productList.ts +121 -127
- package/vtex/inline-loaders/productListingPage.ts +10 -34
- package/vtex/inline-loaders/relatedProducts.ts +1 -3
- package/vtex/inline-loaders/suggestions.ts +36 -39
- package/vtex/inline-loaders/workflowProducts.ts +45 -49
- package/vtex/invoke.ts +159 -194
- package/vtex/loaders/address.ts +49 -54
- package/vtex/loaders/brands.ts +19 -26
- package/vtex/loaders/cart.ts +24 -21
- package/vtex/loaders/catalog.ts +51 -53
- package/vtex/loaders/collections.ts +25 -27
- package/vtex/loaders/legacy.ts +487 -534
- package/vtex/loaders/logistics.ts +33 -37
- package/vtex/loaders/navbar.ts +5 -8
- package/vtex/loaders/orders.ts +28 -39
- package/vtex/loaders/pageType.ts +41 -35
- package/vtex/loaders/payment.ts +27 -37
- package/vtex/loaders/profile.ts +38 -38
- package/vtex/loaders/promotion.ts +5 -8
- package/vtex/loaders/search.ts +56 -59
- package/vtex/loaders/session.ts +22 -30
- package/vtex/loaders/user.ts +39 -41
- package/vtex/loaders/wishlist.ts +35 -35
- package/vtex/loaders/wishlistProducts.ts +3 -15
- package/vtex/loaders/workflow.ts +220 -227
- package/vtex/middleware.ts +116 -119
- package/vtex/types.ts +201 -201
- package/vtex/utils/batch.ts +13 -16
- package/vtex/utils/cookies.ts +76 -80
- package/vtex/utils/enrichment.ts +62 -42
- package/vtex/utils/fetchCache.ts +1 -4
- package/vtex/utils/index.ts +6 -6
- package/vtex/utils/intelligentSearch.ts +48 -57
- package/vtex/utils/legacy.ts +108 -124
- package/vtex/utils/pickAndOmit.ts +15 -20
- package/vtex/utils/proxy.ts +136 -146
- package/vtex/utils/resourceRange.ts +3 -3
- package/vtex/utils/segment.ts +100 -111
- package/vtex/utils/similars.ts +1 -2
- package/vtex/utils/sitemap.ts +91 -91
- package/vtex/utils/slugCache.ts +2 -6
- package/vtex/utils/slugify.ts +9 -9
- package/vtex/utils/transform.ts +1012 -1105
- package/vtex/utils/types.ts +1381 -1381
- package/vtex/utils/vtexId.ts +44 -47
- package/.github/workflows/release.yml +0 -34
- package/.releaserc.json +0 -28
- package/knip.json +0 -19
- package/tsconfig.json +0 -11
package/vtex/loaders/workflow.ts
CHANGED
|
@@ -12,93 +12,96 @@
|
|
|
12
12
|
* @see https://developers.vtex.com/docs/api-reference/catalog-api
|
|
13
13
|
*/
|
|
14
14
|
import type {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
Offer,
|
|
16
|
+
Product,
|
|
17
|
+
PropertyValue,
|
|
18
|
+
UnitPriceSpecification,
|
|
19
19
|
} from "../../commerce/types/commerce";
|
|
20
20
|
import { vtexFetch } from "../client";
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
aggregateOffers,
|
|
23
|
+
toAdditionalPropertyCategory,
|
|
24
|
+
toAdditionalPropertyCluster,
|
|
25
|
+
toAdditionalPropertyReferenceId,
|
|
26
|
+
toAdditionalPropertySpecification,
|
|
27
27
|
} from "../utils/transform";
|
|
28
28
|
|
|
29
|
+
/** VTEX prices come in cents — divide by this to get the currency value. */
|
|
30
|
+
const CENTS_DIVISOR = 100;
|
|
31
|
+
|
|
29
32
|
// ---------------------------------------------------------------------------
|
|
30
33
|
// Types for pvt Catalog APIs
|
|
31
34
|
// ---------------------------------------------------------------------------
|
|
32
35
|
|
|
33
36
|
interface SkuImage {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
ImageUrl: string;
|
|
38
|
+
ImageName?: string;
|
|
39
|
+
FileId?: string;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
interface SkuSpecification {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
FieldName: string;
|
|
44
|
+
FieldValues: string[];
|
|
45
|
+
FieldValueIds: number[];
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
interface SkuSeller {
|
|
46
|
-
|
|
49
|
+
SellerId: string;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
interface SkuAlternateIds {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
RefId?: string;
|
|
54
|
+
Ean?: string;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
interface PvtSku {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
58
|
+
Id: number;
|
|
59
|
+
ProductId: number;
|
|
60
|
+
IsActive: boolean;
|
|
61
|
+
SkuName: string;
|
|
62
|
+
ProductName: string;
|
|
63
|
+
ProductDescription: string;
|
|
64
|
+
DetailUrl: string;
|
|
65
|
+
BrandId: string;
|
|
66
|
+
BrandName: string;
|
|
67
|
+
ReleaseDate?: string;
|
|
68
|
+
Images: SkuImage[];
|
|
69
|
+
SkuSpecifications: SkuSpecification[];
|
|
70
|
+
ProductSpecifications: SkuSpecification[];
|
|
71
|
+
ProductCategories: Record<string, string>;
|
|
72
|
+
ProductClusterNames: Record<string, string>;
|
|
73
|
+
SalesChannels: number[];
|
|
74
|
+
AlternateIds: SkuAlternateIds;
|
|
75
|
+
SkuSellers: SkuSeller[];
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
interface PvtSkuListItem {
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
Id: number;
|
|
80
|
+
IsActive: boolean;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
interface SalesChannel {
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
Id: number;
|
|
85
|
+
CurrencyCode: string;
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
interface SimulationItem {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
sellingPrice: number;
|
|
90
|
+
listPrice: number;
|
|
91
|
+
price: number;
|
|
92
|
+
seller: string;
|
|
93
|
+
priceValidUntil: string;
|
|
94
|
+
availability: string;
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
interface SimulationPaymentOption {
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
paymentName: string;
|
|
99
|
+
installments: Array<{ count: number; value: number; total: number }>;
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
interface SimulationResponse {
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
items?: SimulationItem[];
|
|
104
|
+
paymentData?: { installmentOptions?: SimulationPaymentOption[] };
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
// ---------------------------------------------------------------------------
|
|
@@ -106,10 +109,10 @@ interface SimulationResponse {
|
|
|
106
109
|
// ---------------------------------------------------------------------------
|
|
107
110
|
|
|
108
111
|
export interface WorkflowProductOptions {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
/** The SKU ID (stockKeepingUnitId) to load */
|
|
113
|
+
productID: string;
|
|
114
|
+
/** Sales channel for simulation. Defaults to 1. */
|
|
115
|
+
salesChannel?: number;
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
/**
|
|
@@ -120,171 +123,163 @@ export interface WorkflowProductOptions {
|
|
|
120
123
|
*
|
|
121
124
|
* Ported from: vtex/loaders/workflow/product.ts
|
|
122
125
|
*/
|
|
123
|
-
export async function workflowProduct(
|
|
124
|
-
|
|
125
|
-
): Promise<Product | null> {
|
|
126
|
-
const sc = opts.salesChannel ?? 1;
|
|
126
|
+
export async function workflowProduct(opts: WorkflowProductOptions): Promise<Product | null> {
|
|
127
|
+
const sc = opts.salesChannel ?? 1;
|
|
127
128
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
const sku = await vtexFetch<PvtSku>(
|
|
130
|
+
`/api/catalog_system/pvt/sku/stockkeepingunitbyid/${opts.productID}`,
|
|
131
|
+
);
|
|
131
132
|
|
|
132
|
-
|
|
133
|
+
if (!sku.IsActive) return null;
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
),
|
|
152
|
-
]);
|
|
135
|
+
const [skus, salesChannels, ...simulations] = await Promise.all([
|
|
136
|
+
vtexFetch<PvtSkuListItem[]>(
|
|
137
|
+
`/api/catalog_system/pvt/sku/stockkeepingunitByProductId/${sku.ProductId}`,
|
|
138
|
+
),
|
|
139
|
+
vtexFetch<SalesChannel[]>("/api/catalog_system/pvt/saleschannel/list"),
|
|
140
|
+
...sku.SkuSellers.map(({ SellerId }) =>
|
|
141
|
+
vtexFetch<SimulationResponse>(
|
|
142
|
+
`/api/checkout/pub/orderForms/simulation?RnbBehavior=1&sc=${sc}`,
|
|
143
|
+
{
|
|
144
|
+
method: "POST",
|
|
145
|
+
body: JSON.stringify({
|
|
146
|
+
items: [{ id: `${sku.Id}`, seller: SellerId, quantity: 1 }],
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
),
|
|
150
|
+
),
|
|
151
|
+
]);
|
|
153
152
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
const channel = salesChannels.find((c) => c.Id === sc);
|
|
154
|
+
const productGroupID = `${sku.ProductId}`;
|
|
155
|
+
const productID = `${sku.Id}`;
|
|
157
156
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
].filter((p): p is PropertyValue => Boolean(p));
|
|
157
|
+
const additionalProperty = [
|
|
158
|
+
sku.AlternateIds.RefId
|
|
159
|
+
? toAdditionalPropertyReferenceId({
|
|
160
|
+
name: "RefId",
|
|
161
|
+
value: sku.AlternateIds.RefId,
|
|
162
|
+
})
|
|
163
|
+
: null,
|
|
164
|
+
...Object.entries(sku.ProductCategories ?? {}).map(([propertyID, value]) =>
|
|
165
|
+
toAdditionalPropertyCategory({ propertyID, value }),
|
|
166
|
+
),
|
|
167
|
+
...Object.entries(sku.ProductClusterNames ?? {}).map(([propertyID, value]) =>
|
|
168
|
+
toAdditionalPropertyCluster({ propertyID, value }),
|
|
169
|
+
),
|
|
170
|
+
...sku.SkuSpecifications.flatMap((spec) =>
|
|
171
|
+
spec.FieldValues.map((value, it) =>
|
|
172
|
+
toAdditionalPropertySpecification({
|
|
173
|
+
propertyID: spec.FieldValueIds[it]?.toString(),
|
|
174
|
+
name: spec.FieldName,
|
|
175
|
+
value,
|
|
176
|
+
}),
|
|
177
|
+
),
|
|
178
|
+
),
|
|
179
|
+
...sku.SalesChannels.map(
|
|
180
|
+
(ch): PropertyValue => ({
|
|
181
|
+
"@type": "PropertyValue",
|
|
182
|
+
name: "salesChannel",
|
|
183
|
+
propertyID: ch.toString(),
|
|
184
|
+
}),
|
|
185
|
+
),
|
|
186
|
+
].filter((p): p is PropertyValue => Boolean(p));
|
|
189
187
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
188
|
+
const groupAdditionalProperty = sku.ProductSpecifications.flatMap((spec) =>
|
|
189
|
+
spec.FieldValues.map((value, it) =>
|
|
190
|
+
toAdditionalPropertySpecification({
|
|
191
|
+
propertyID: spec.FieldValueIds[it]?.toString(),
|
|
192
|
+
name: spec.FieldName,
|
|
193
|
+
value,
|
|
194
|
+
}),
|
|
195
|
+
),
|
|
196
|
+
);
|
|
199
197
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
198
|
+
const offers = simulations
|
|
199
|
+
.flatMap(({ items, paymentData }) =>
|
|
200
|
+
items?.map((item): Offer | null => {
|
|
201
|
+
const { sellingPrice, listPrice, price, seller, priceValidUntil, availability } = item;
|
|
202
|
+
const spotPrice = sellingPrice || price;
|
|
203
|
+
if (!spotPrice || !listPrice) return null;
|
|
206
204
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
.filter((o): o is Offer => Boolean(o));
|
|
205
|
+
return {
|
|
206
|
+
"@type": "Offer",
|
|
207
|
+
price: spotPrice / CENTS_DIVISOR,
|
|
208
|
+
seller,
|
|
209
|
+
priceValidUntil,
|
|
210
|
+
inventoryLevel: {},
|
|
211
|
+
availability:
|
|
212
|
+
availability === "available"
|
|
213
|
+
? "https://schema.org/InStock"
|
|
214
|
+
: "https://schema.org/OutOfStock",
|
|
215
|
+
priceSpecification: [
|
|
216
|
+
{
|
|
217
|
+
"@type": "UnitPriceSpecification",
|
|
218
|
+
priceType: "https://schema.org/ListPrice",
|
|
219
|
+
price: listPrice / CENTS_DIVISOR,
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"@type": "UnitPriceSpecification",
|
|
223
|
+
priceType: "https://schema.org/SalePrice",
|
|
224
|
+
price: spotPrice / CENTS_DIVISOR,
|
|
225
|
+
},
|
|
226
|
+
...(paymentData?.installmentOptions?.flatMap((option): UnitPriceSpecification[] =>
|
|
227
|
+
option.installments.map((i) => ({
|
|
228
|
+
"@type": "UnitPriceSpecification",
|
|
229
|
+
priceType: "https://schema.org/SalePrice",
|
|
230
|
+
priceComponentType: "https://schema.org/Installment",
|
|
231
|
+
name: option.paymentName,
|
|
232
|
+
billingDuration: i.count,
|
|
233
|
+
billingIncrement: i.value / CENTS_DIVISOR,
|
|
234
|
+
price: i.total / CENTS_DIVISOR,
|
|
235
|
+
})),
|
|
236
|
+
) ?? []),
|
|
237
|
+
],
|
|
238
|
+
};
|
|
239
|
+
}),
|
|
240
|
+
)
|
|
241
|
+
.filter((o): o is Offer => Boolean(o));
|
|
245
242
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
offers: aggregateOffers(offers, channel?.CurrencyCode),
|
|
287
|
-
};
|
|
243
|
+
return {
|
|
244
|
+
"@type": "Product",
|
|
245
|
+
productID,
|
|
246
|
+
sku: productID,
|
|
247
|
+
inProductGroupWithID: productGroupID,
|
|
248
|
+
category: Object.values(sku.ProductCategories ?? {}).join(" > "),
|
|
249
|
+
url: `${sku.DetailUrl}?skuId=${productID}`,
|
|
250
|
+
name: sku.SkuName,
|
|
251
|
+
gtin: sku.AlternateIds.Ean,
|
|
252
|
+
image: sku.Images.map((img) => ({
|
|
253
|
+
"@type": "ImageObject",
|
|
254
|
+
encodingFormat: "image",
|
|
255
|
+
alternateName: img.ImageName ?? img.FileId,
|
|
256
|
+
url: img.ImageUrl,
|
|
257
|
+
})),
|
|
258
|
+
isVariantOf: {
|
|
259
|
+
"@type": "ProductGroup",
|
|
260
|
+
url: sku.DetailUrl,
|
|
261
|
+
hasVariant:
|
|
262
|
+
skus
|
|
263
|
+
?.filter((x) => x.IsActive)
|
|
264
|
+
.map(({ Id }) => ({
|
|
265
|
+
"@type": "Product",
|
|
266
|
+
productID: `${Id}`,
|
|
267
|
+
sku: `${Id}`,
|
|
268
|
+
})) ?? [],
|
|
269
|
+
additionalProperty: groupAdditionalProperty,
|
|
270
|
+
productGroupID,
|
|
271
|
+
name: sku.ProductName,
|
|
272
|
+
description: sku.ProductDescription,
|
|
273
|
+
},
|
|
274
|
+
additionalProperty,
|
|
275
|
+
releaseDate: sku.ReleaseDate ? new Date(sku.ReleaseDate).toISOString() : undefined,
|
|
276
|
+
brand: {
|
|
277
|
+
"@type": "Brand",
|
|
278
|
+
"@id": sku.BrandId,
|
|
279
|
+
name: sku.BrandName,
|
|
280
|
+
},
|
|
281
|
+
offers: aggregateOffers(offers, channel?.CurrencyCode),
|
|
282
|
+
};
|
|
288
283
|
}
|
|
289
284
|
|
|
290
285
|
// ---------------------------------------------------------------------------
|
|
@@ -292,8 +287,8 @@ export async function workflowProduct(
|
|
|
292
287
|
// ---------------------------------------------------------------------------
|
|
293
288
|
|
|
294
289
|
export interface WorkflowProductsOptions {
|
|
295
|
-
|
|
296
|
-
|
|
290
|
+
page: number;
|
|
291
|
+
pagesize: number;
|
|
297
292
|
}
|
|
298
293
|
|
|
299
294
|
/**
|
|
@@ -303,21 +298,19 @@ export interface WorkflowProductsOptions {
|
|
|
303
298
|
*
|
|
304
299
|
* Ported from: vtex/loaders/workflow/products.ts
|
|
305
300
|
*/
|
|
306
|
-
export async function workflowProducts(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
pagesize: String(opts.pagesize),
|
|
312
|
-
});
|
|
301
|
+
export async function workflowProducts(opts: WorkflowProductsOptions): Promise<Product[]> {
|
|
302
|
+
const params = new URLSearchParams({
|
|
303
|
+
page: String(opts.page),
|
|
304
|
+
pagesize: String(opts.pagesize),
|
|
305
|
+
});
|
|
313
306
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
307
|
+
const ids = await vtexFetch<number[]>(
|
|
308
|
+
`/api/catalog_system/pvt/sku/stockkeepingunitids?${params}`,
|
|
309
|
+
);
|
|
317
310
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
311
|
+
return ids.map((productID) => ({
|
|
312
|
+
"@type": "Product",
|
|
313
|
+
productID: `${productID}`,
|
|
314
|
+
sku: `${productID}`,
|
|
315
|
+
}));
|
|
323
316
|
}
|