@pvh-afl/core 1.0.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 +97 -0
- package/dist/cache/cache.module.d.ts +3 -0
- package/dist/cache/cache.module.d.ts.map +1 -0
- package/dist/cache/cache.module.js +17 -0
- package/dist/cache/cache.module.js.map +1 -0
- package/dist/cache/cache.service.d.ts +38 -0
- package/dist/cache/cache.service.d.ts.map +1 -0
- package/dist/cache/cache.service.js +173 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +3 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +6 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/common/guards/tenant.guard.d.ts +8 -0
- package/dist/common/guards/tenant.guard.d.ts.map +1 -0
- package/dist/common/guards/tenant.guard.js +44 -0
- package/dist/common/guards/tenant.guard.js.map +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +6 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/logger.d.ts +7 -0
- package/dist/common/logger.d.ts.map +1 -0
- package/dist/common/logger.js +28 -0
- package/dist/common/logger.js.map +1 -0
- package/dist/config/config.module.d.ts +3 -0
- package/dist/config/config.module.d.ts.map +1 -0
- package/dist/config/config.module.js +17 -0
- package/dist/config/config.module.js.map +1 -0
- package/dist/config/config.service.d.ts +55 -0
- package/dist/config/config.service.d.ts.map +1 -0
- package/dist/config/config.service.js +212 -0
- package/dist/config/config.service.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/base-integration.service.d.ts +59 -0
- package/dist/integrations/base-integration.service.d.ts.map +1 -0
- package/dist/integrations/base-integration.service.js +227 -0
- package/dist/integrations/base-integration.service.js.map +1 -0
- package/dist/integrations/commerce/commerce.types.d.ts +301 -0
- package/dist/integrations/commerce/commerce.types.d.ts.map +1 -0
- package/dist/integrations/commerce/commerce.types.js +9 -0
- package/dist/integrations/commerce/commerce.types.js.map +1 -0
- package/dist/integrations/commerce/index.d.ts +4 -0
- package/dist/integrations/commerce/index.d.ts.map +1 -0
- package/dist/integrations/commerce/index.js +7 -0
- package/dist/integrations/commerce/index.js.map +1 -0
- package/dist/integrations/commerce/shopify-admin.service.d.ts +35 -0
- package/dist/integrations/commerce/shopify-admin.service.d.ts.map +1 -0
- package/dist/integrations/commerce/shopify-admin.service.js +269 -0
- package/dist/integrations/commerce/shopify-admin.service.js.map +1 -0
- package/dist/integrations/commerce/shopify.service.d.ts +43 -0
- package/dist/integrations/commerce/shopify.service.d.ts.map +1 -0
- package/dist/integrations/commerce/shopify.service.js +735 -0
- package/dist/integrations/commerce/shopify.service.js.map +1 -0
- package/dist/integrations/index.d.ts +9 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +18 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/integration.factory.d.ts +23 -0
- package/dist/integrations/integration.factory.d.ts.map +1 -0
- package/dist/integrations/integration.factory.js +119 -0
- package/dist/integrations/integration.factory.js.map +1 -0
- package/dist/integrations/integration.types.d.ts +80 -0
- package/dist/integrations/integration.types.d.ts.map +1 -0
- package/dist/integrations/integration.types.js +9 -0
- package/dist/integrations/integration.types.js.map +1 -0
- package/dist/integrations/integrations.module.d.ts +3 -0
- package/dist/integrations/integrations.module.d.ts.map +1 -0
- package/dist/integrations/integrations.module.js +46 -0
- package/dist/integrations/integrations.module.js.map +1 -0
- package/dist/integrations/loyalty/capillary-auth.service.d.ts +30 -0
- package/dist/integrations/loyalty/capillary-auth.service.d.ts.map +1 -0
- package/dist/integrations/loyalty/capillary-auth.service.js +112 -0
- package/dist/integrations/loyalty/capillary-auth.service.js.map +1 -0
- package/dist/integrations/loyalty/capillary-coupon.service.d.ts +24 -0
- package/dist/integrations/loyalty/capillary-coupon.service.d.ts.map +1 -0
- package/dist/integrations/loyalty/capillary-coupon.service.js +383 -0
- package/dist/integrations/loyalty/capillary-coupon.service.js.map +1 -0
- package/dist/integrations/loyalty/capillary.types.d.ts +218 -0
- package/dist/integrations/loyalty/capillary.types.d.ts.map +1 -0
- package/dist/integrations/loyalty/capillary.types.js +21 -0
- package/dist/integrations/loyalty/capillary.types.js.map +1 -0
- package/dist/integrations/loyalty/index.d.ts +4 -0
- package/dist/integrations/loyalty/index.d.ts.map +1 -0
- package/dist/integrations/loyalty/index.js +7 -0
- package/dist/integrations/loyalty/index.js.map +1 -0
- package/dist/integrations/oms/index.d.ts +4 -0
- package/dist/integrations/oms/index.d.ts.map +1 -0
- package/dist/integrations/oms/index.js +7 -0
- package/dist/integrations/oms/index.js.map +1 -0
- package/dist/integrations/oms/omuni-auth.service.d.ts +29 -0
- package/dist/integrations/oms/omuni-auth.service.d.ts.map +1 -0
- package/dist/integrations/oms/omuni-auth.service.js +164 -0
- package/dist/integrations/oms/omuni-auth.service.js.map +1 -0
- package/dist/integrations/oms/omuni.service.d.ts +17 -0
- package/dist/integrations/oms/omuni.service.d.ts.map +1 -0
- package/dist/integrations/oms/omuni.service.js +128 -0
- package/dist/integrations/oms/omuni.service.js.map +1 -0
- package/dist/integrations/oms/omuni.types.d.ts +65 -0
- package/dist/integrations/oms/omuni.types.d.ts.map +1 -0
- package/dist/integrations/oms/omuni.types.js +3 -0
- package/dist/integrations/oms/omuni.types.js.map +1 -0
- package/dist/integrations/shopify-theme/index.d.ts +3 -0
- package/dist/integrations/shopify-theme/index.d.ts.map +1 -0
- package/dist/integrations/shopify-theme/index.js +6 -0
- package/dist/integrations/shopify-theme/index.js.map +1 -0
- package/dist/integrations/shopify-theme/shopify-theme.module.d.ts +3 -0
- package/dist/integrations/shopify-theme/shopify-theme.module.d.ts.map +1 -0
- package/dist/integrations/shopify-theme/shopify-theme.module.js +16 -0
- package/dist/integrations/shopify-theme/shopify-theme.module.js.map +1 -0
- package/dist/integrations/shopify-theme/shopify-theme.service.d.ts +35 -0
- package/dist/integrations/shopify-theme/shopify-theme.service.d.ts.map +1 -0
- package/dist/integrations/shopify-theme/shopify-theme.service.js +155 -0
- package/dist/integrations/shopify-theme/shopify-theme.service.js.map +1 -0
- package/dist/queue/index.d.ts +3 -0
- package/dist/queue/index.d.ts.map +1 -0
- package/dist/queue/index.js +8 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/queue/queue.module.d.ts +3 -0
- package/dist/queue/queue.module.d.ts.map +1 -0
- package/dist/queue/queue.module.js +17 -0
- package/dist/queue/queue.module.js.map +1 -0
- package/dist/queue/queue.service.d.ts +20 -0
- package/dist/queue/queue.service.d.ts.map +1 -0
- package/dist/queue/queue.service.js +119 -0
- package/dist/queue/queue.service.js.map +1 -0
- package/dist/theme/header-content.service.d.ts +142 -0
- package/dist/theme/header-content.service.d.ts.map +1 -0
- package/dist/theme/header-content.service.js +626 -0
- package/dist/theme/header-content.service.js.map +1 -0
- package/dist/theme/index.d.ts +5 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +17 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/theme-content.interfaces.d.ts +79 -0
- package/dist/theme/theme-content.interfaces.d.ts.map +1 -0
- package/dist/theme/theme-content.interfaces.js +14 -0
- package/dist/theme/theme-content.interfaces.js.map +1 -0
- package/dist/theme/theme-content.service.d.ts +125 -0
- package/dist/theme/theme-content.service.d.ts.map +1 -0
- package/dist/theme/theme-content.service.js +738 -0
- package/dist/theme/theme-content.service.js.map +1 -0
- package/dist/theme/theme.module.d.ts +46 -0
- package/dist/theme/theme.module.d.ts.map +1 -0
- package/dist/theme/theme.module.js +76 -0
- package/dist/theme/theme.module.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShopifyCommerceService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const base_integration_service_1 = require("../base-integration.service");
|
|
7
|
+
const logger_1 = require("../../common/logger");
|
|
8
|
+
// GraphQL Queries
|
|
9
|
+
const PRODUCTS_QUERY = `
|
|
10
|
+
query Products($first: Int!, $after: String) {
|
|
11
|
+
products(first: $first, after: $after) {
|
|
12
|
+
edges {
|
|
13
|
+
node {
|
|
14
|
+
id
|
|
15
|
+
handle
|
|
16
|
+
title
|
|
17
|
+
description
|
|
18
|
+
descriptionHtml
|
|
19
|
+
vendor
|
|
20
|
+
productType
|
|
21
|
+
tags
|
|
22
|
+
featuredImage { url altText width height }
|
|
23
|
+
images(first: 30) {
|
|
24
|
+
edges { node { url altText width height } }
|
|
25
|
+
}
|
|
26
|
+
variants(first: 100) {
|
|
27
|
+
edges {
|
|
28
|
+
node {
|
|
29
|
+
id
|
|
30
|
+
title
|
|
31
|
+
availableForSale
|
|
32
|
+
price { amount currencyCode }
|
|
33
|
+
compareAtPrice { amount currencyCode }
|
|
34
|
+
selectedOptions { name value }
|
|
35
|
+
image { url altText width height }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
priceRange {
|
|
40
|
+
minVariantPrice { amount currencyCode }
|
|
41
|
+
maxVariantPrice { amount currencyCode }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
cursor
|
|
45
|
+
}
|
|
46
|
+
pageInfo {
|
|
47
|
+
hasNextPage
|
|
48
|
+
hasPreviousPage
|
|
49
|
+
startCursor
|
|
50
|
+
endCursor
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
const PRODUCT_BY_ID_QUERY = `
|
|
56
|
+
query ProductById($id: ID!) {
|
|
57
|
+
product(id: $id) {
|
|
58
|
+
id
|
|
59
|
+
handle
|
|
60
|
+
title
|
|
61
|
+
description
|
|
62
|
+
descriptionHtml
|
|
63
|
+
vendor
|
|
64
|
+
productType
|
|
65
|
+
tags
|
|
66
|
+
featuredImage { url altText width height }
|
|
67
|
+
images(first: 30) {
|
|
68
|
+
edges { node { url altText width height } }
|
|
69
|
+
}
|
|
70
|
+
options {
|
|
71
|
+
id
|
|
72
|
+
name
|
|
73
|
+
values
|
|
74
|
+
}
|
|
75
|
+
variants(first: 100) {
|
|
76
|
+
edges {
|
|
77
|
+
node {
|
|
78
|
+
id
|
|
79
|
+
title
|
|
80
|
+
availableForSale
|
|
81
|
+
price { amount currencyCode }
|
|
82
|
+
compareAtPrice { amount currencyCode }
|
|
83
|
+
selectedOptions { name value }
|
|
84
|
+
image { url altText width height }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
priceRange {
|
|
89
|
+
minVariantPrice { amount currencyCode }
|
|
90
|
+
maxVariantPrice { amount currencyCode }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
const PRODUCT_BY_HANDLE_QUERY = `
|
|
96
|
+
query ProductByHandle($handle: String!) {
|
|
97
|
+
productByHandle(handle: $handle) {
|
|
98
|
+
id
|
|
99
|
+
handle
|
|
100
|
+
title
|
|
101
|
+
description
|
|
102
|
+
descriptionHtml
|
|
103
|
+
vendor
|
|
104
|
+
productType
|
|
105
|
+
tags
|
|
106
|
+
featuredImage { url altText width height }
|
|
107
|
+
images(first: 30) {
|
|
108
|
+
edges { node { url altText width height } }
|
|
109
|
+
}
|
|
110
|
+
options {
|
|
111
|
+
id
|
|
112
|
+
name
|
|
113
|
+
values
|
|
114
|
+
}
|
|
115
|
+
variants(first: 100) {
|
|
116
|
+
edges {
|
|
117
|
+
node {
|
|
118
|
+
id
|
|
119
|
+
title
|
|
120
|
+
availableForSale
|
|
121
|
+
price { amount currencyCode }
|
|
122
|
+
compareAtPrice { amount currencyCode }
|
|
123
|
+
selectedOptions { name value }
|
|
124
|
+
image { url altText width height }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
priceRange {
|
|
129
|
+
minVariantPrice { amount currencyCode }
|
|
130
|
+
maxVariantPrice { amount currencyCode }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`;
|
|
135
|
+
const PRODUCT_RECOMMENDATIONS_QUERY = `
|
|
136
|
+
query ProductRecommendations($productId: ID!, $intent: ProductRecommendationIntent!) {
|
|
137
|
+
productRecommendations(productId: $productId, intent: $intent) {
|
|
138
|
+
id
|
|
139
|
+
handle
|
|
140
|
+
title
|
|
141
|
+
vendor
|
|
142
|
+
productType
|
|
143
|
+
featuredImage { url altText width height }
|
|
144
|
+
priceRange {
|
|
145
|
+
minVariantPrice { amount currencyCode }
|
|
146
|
+
maxVariantPrice { amount currencyCode }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
`;
|
|
151
|
+
const COLLECTIONS_QUERY = `
|
|
152
|
+
query Collections($first: Int!) {
|
|
153
|
+
collections(first: $first) {
|
|
154
|
+
edges {
|
|
155
|
+
node {
|
|
156
|
+
id
|
|
157
|
+
handle
|
|
158
|
+
title
|
|
159
|
+
description
|
|
160
|
+
image { url altText width height }
|
|
161
|
+
}
|
|
162
|
+
cursor
|
|
163
|
+
}
|
|
164
|
+
pageInfo {
|
|
165
|
+
hasNextPage
|
|
166
|
+
hasPreviousPage
|
|
167
|
+
startCursor
|
|
168
|
+
endCursor
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
`;
|
|
173
|
+
const COLLECTION_BY_HANDLE_QUERY = `
|
|
174
|
+
query CollectionByHandle($handle: String!, $productsFirst: Int!) {
|
|
175
|
+
collection(handle: $handle) {
|
|
176
|
+
id
|
|
177
|
+
handle
|
|
178
|
+
title
|
|
179
|
+
description
|
|
180
|
+
image { url altText width height }
|
|
181
|
+
products(first: $productsFirst) {
|
|
182
|
+
edges {
|
|
183
|
+
node {
|
|
184
|
+
handle
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
191
|
+
const MENU_QUERY = `
|
|
192
|
+
query Menu($handle: String!) {
|
|
193
|
+
menu(handle: $handle) {
|
|
194
|
+
id
|
|
195
|
+
handle
|
|
196
|
+
title
|
|
197
|
+
items {
|
|
198
|
+
id
|
|
199
|
+
title
|
|
200
|
+
url
|
|
201
|
+
items {
|
|
202
|
+
id
|
|
203
|
+
title
|
|
204
|
+
url
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
210
|
+
const PAGE_BY_HANDLE_QUERY = `
|
|
211
|
+
query PageByHandle($handle: String!) {
|
|
212
|
+
page(handle: $handle) {
|
|
213
|
+
id
|
|
214
|
+
handle
|
|
215
|
+
title
|
|
216
|
+
body
|
|
217
|
+
bodySummary
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
`;
|
|
221
|
+
// Reusable cart fields fragment
|
|
222
|
+
const CART_FIELDS = `
|
|
223
|
+
id
|
|
224
|
+
checkoutUrl
|
|
225
|
+
totalQuantity
|
|
226
|
+
lines(first: 100) {
|
|
227
|
+
edges {
|
|
228
|
+
node {
|
|
229
|
+
id
|
|
230
|
+
quantity
|
|
231
|
+
merchandise {
|
|
232
|
+
... on ProductVariant {
|
|
233
|
+
id
|
|
234
|
+
title
|
|
235
|
+
selectedOptions { name value }
|
|
236
|
+
product { id title handle options { id name values } }
|
|
237
|
+
image { url altText width height }
|
|
238
|
+
price { amount currencyCode }
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
cost { totalAmount { amount currencyCode } }
|
|
242
|
+
discountAllocations {
|
|
243
|
+
discountedAmount { amount currencyCode }
|
|
244
|
+
... on CartAutomaticDiscountAllocation {
|
|
245
|
+
title
|
|
246
|
+
}
|
|
247
|
+
... on CartCodeDiscountAllocation {
|
|
248
|
+
code
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
cost {
|
|
255
|
+
subtotalAmount { amount currencyCode }
|
|
256
|
+
totalAmount { amount currencyCode }
|
|
257
|
+
totalTaxAmount { amount currencyCode }
|
|
258
|
+
}
|
|
259
|
+
discountCodes {
|
|
260
|
+
code
|
|
261
|
+
applicable
|
|
262
|
+
}
|
|
263
|
+
discountAllocations {
|
|
264
|
+
discountedAmount { amount currencyCode }
|
|
265
|
+
}
|
|
266
|
+
buyerIdentity {
|
|
267
|
+
email
|
|
268
|
+
phone
|
|
269
|
+
countryCode
|
|
270
|
+
customer {
|
|
271
|
+
id
|
|
272
|
+
email
|
|
273
|
+
firstName
|
|
274
|
+
lastName
|
|
275
|
+
phone
|
|
276
|
+
displayName
|
|
277
|
+
}
|
|
278
|
+
deliveryAddressPreferences {
|
|
279
|
+
__typename
|
|
280
|
+
... on MailingAddress {
|
|
281
|
+
address1
|
|
282
|
+
address2
|
|
283
|
+
city
|
|
284
|
+
company
|
|
285
|
+
country
|
|
286
|
+
countryCodeV2
|
|
287
|
+
firstName
|
|
288
|
+
lastName
|
|
289
|
+
phone
|
|
290
|
+
province
|
|
291
|
+
provinceCode
|
|
292
|
+
zip
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
note
|
|
297
|
+
attributes {
|
|
298
|
+
key
|
|
299
|
+
value
|
|
300
|
+
}
|
|
301
|
+
appliedGiftCards {
|
|
302
|
+
id
|
|
303
|
+
lastCharacters
|
|
304
|
+
amountUsed { amount currencyCode }
|
|
305
|
+
balance { amount currencyCode }
|
|
306
|
+
}
|
|
307
|
+
deliveryGroups(first: 10) {
|
|
308
|
+
edges {
|
|
309
|
+
node {
|
|
310
|
+
id
|
|
311
|
+
deliveryAddress {
|
|
312
|
+
address1
|
|
313
|
+
address2
|
|
314
|
+
city
|
|
315
|
+
company
|
|
316
|
+
country
|
|
317
|
+
countryCodeV2
|
|
318
|
+
firstName
|
|
319
|
+
lastName
|
|
320
|
+
phone
|
|
321
|
+
province
|
|
322
|
+
provinceCode
|
|
323
|
+
zip
|
|
324
|
+
}
|
|
325
|
+
deliveryOptions {
|
|
326
|
+
code
|
|
327
|
+
deliveryMethodType
|
|
328
|
+
description
|
|
329
|
+
estimatedCost { amount currencyCode }
|
|
330
|
+
handle
|
|
331
|
+
title
|
|
332
|
+
}
|
|
333
|
+
selectedDeliveryOption {
|
|
334
|
+
code
|
|
335
|
+
deliveryMethodType
|
|
336
|
+
description
|
|
337
|
+
estimatedCost { amount currencyCode }
|
|
338
|
+
handle
|
|
339
|
+
title
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
`;
|
|
345
|
+
const CART_CREATE_MUTATION = `
|
|
346
|
+
mutation CartCreate {
|
|
347
|
+
cartCreate {
|
|
348
|
+
cart {
|
|
349
|
+
${CART_FIELDS}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
`;
|
|
354
|
+
const CART_LINES_ADD_MUTATION = `
|
|
355
|
+
mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {
|
|
356
|
+
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
357
|
+
cart {
|
|
358
|
+
${CART_FIELDS}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
`;
|
|
363
|
+
const CART_QUERY = `
|
|
364
|
+
query Cart($id: ID!) {
|
|
365
|
+
cart(id: $id) {
|
|
366
|
+
${CART_FIELDS}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
`;
|
|
370
|
+
const CART_LINES_UPDATE_MUTATION = `
|
|
371
|
+
mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
|
|
372
|
+
cartLinesUpdate(cartId: $cartId, lines: $lines) {
|
|
373
|
+
cart {
|
|
374
|
+
${CART_FIELDS}
|
|
375
|
+
}
|
|
376
|
+
userErrors {
|
|
377
|
+
field
|
|
378
|
+
message
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
`;
|
|
383
|
+
const CART_LINES_REMOVE_MUTATION = `
|
|
384
|
+
mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {
|
|
385
|
+
cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
|
|
386
|
+
cart {
|
|
387
|
+
${CART_FIELDS}
|
|
388
|
+
}
|
|
389
|
+
userErrors {
|
|
390
|
+
field
|
|
391
|
+
message
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
`;
|
|
396
|
+
const CART_DISCOUNT_CODES_UPDATE_MUTATION = `
|
|
397
|
+
mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {
|
|
398
|
+
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
399
|
+
cart {
|
|
400
|
+
${CART_FIELDS}
|
|
401
|
+
}
|
|
402
|
+
userErrors {
|
|
403
|
+
field
|
|
404
|
+
message
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
`;
|
|
409
|
+
const CART_BUYER_IDENTITY_UPDATE_MUTATION = `
|
|
410
|
+
mutation CartBuyerIdentityUpdate($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {
|
|
411
|
+
cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
|
|
412
|
+
cart {
|
|
413
|
+
${CART_FIELDS}
|
|
414
|
+
}
|
|
415
|
+
userErrors {
|
|
416
|
+
field
|
|
417
|
+
message
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
`;
|
|
422
|
+
const CART_NOTE_UPDATE_MUTATION = `
|
|
423
|
+
mutation CartNoteUpdate($cartId: ID!, $note: String!) {
|
|
424
|
+
cartNoteUpdate(cartId: $cartId, note: $note) {
|
|
425
|
+
cart {
|
|
426
|
+
${CART_FIELDS}
|
|
427
|
+
}
|
|
428
|
+
userErrors {
|
|
429
|
+
field
|
|
430
|
+
message
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
`;
|
|
435
|
+
const CART_ATTRIBUTES_UPDATE_MUTATION = `
|
|
436
|
+
mutation CartAttributesUpdate($cartId: ID!, $attributes: [AttributeInput!]!) {
|
|
437
|
+
cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {
|
|
438
|
+
cart {
|
|
439
|
+
${CART_FIELDS}
|
|
440
|
+
}
|
|
441
|
+
userErrors {
|
|
442
|
+
field
|
|
443
|
+
message
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
`;
|
|
448
|
+
const CART_GIFT_CARD_CODES_UPDATE_MUTATION = `
|
|
449
|
+
mutation CartGiftCardCodesUpdate($cartId: ID!, $giftCardCodes: [String!]!) {
|
|
450
|
+
cartGiftCardCodesUpdate(cartId: $cartId, giftCardCodes: $giftCardCodes) {
|
|
451
|
+
cart {
|
|
452
|
+
${CART_FIELDS}
|
|
453
|
+
}
|
|
454
|
+
userErrors {
|
|
455
|
+
field
|
|
456
|
+
message
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
`;
|
|
461
|
+
/**
|
|
462
|
+
* Shopify Commerce Service
|
|
463
|
+
*
|
|
464
|
+
* Implementation of ICommerceService using Shopify Storefront API.
|
|
465
|
+
* Extends BaseIntegrationService to get retry logic, error normalization, and health checks.
|
|
466
|
+
*/
|
|
467
|
+
let ShopifyCommerceService = class ShopifyCommerceService extends base_integration_service_1.BaseIntegrationService {
|
|
468
|
+
name = "shopify-commerce";
|
|
469
|
+
/**
|
|
470
|
+
* Execute a GraphQL query against Shopify Storefront API
|
|
471
|
+
*/
|
|
472
|
+
async graphqlQuery(query, variables = {}) {
|
|
473
|
+
const response = await this.request("POST", "", { query, variables });
|
|
474
|
+
if (!response.success) {
|
|
475
|
+
return response;
|
|
476
|
+
}
|
|
477
|
+
// Check for GraphQL-level errors
|
|
478
|
+
if (response.data?.errors?.length) {
|
|
479
|
+
logger_1.logger.error("Shopify GraphQL errors", {
|
|
480
|
+
brand: this.brand,
|
|
481
|
+
errors: response.data.errors,
|
|
482
|
+
});
|
|
483
|
+
return {
|
|
484
|
+
success: false,
|
|
485
|
+
error: {
|
|
486
|
+
code: "GRAPHQL_ERROR",
|
|
487
|
+
message: response.data.errors[0]?.message ?? "GraphQL query failed",
|
|
488
|
+
details: response.data.errors,
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
success: true,
|
|
494
|
+
data: response.data?.data,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
// Products
|
|
498
|
+
async getProducts(params = {}) {
|
|
499
|
+
const response = await this.graphqlQuery(PRODUCTS_QUERY, { first: params.first ?? 20, after: params.after });
|
|
500
|
+
if (!response.success || !response.data) {
|
|
501
|
+
return { success: false, error: response.error };
|
|
502
|
+
}
|
|
503
|
+
return { success: true, data: response.data.products };
|
|
504
|
+
}
|
|
505
|
+
async getProductById(id) {
|
|
506
|
+
const response = await this.graphqlQuery(PRODUCT_BY_ID_QUERY, { id });
|
|
507
|
+
if (!response.success || !response.data) {
|
|
508
|
+
return { success: false, error: response.error };
|
|
509
|
+
}
|
|
510
|
+
return { success: true, data: response.data.product };
|
|
511
|
+
}
|
|
512
|
+
async getProductByHandle(handle) {
|
|
513
|
+
const response = await this.graphqlQuery(PRODUCT_BY_HANDLE_QUERY, { handle });
|
|
514
|
+
if (!response.success || !response.data) {
|
|
515
|
+
return { success: false, error: response.error };
|
|
516
|
+
}
|
|
517
|
+
return { success: true, data: response.data.productByHandle };
|
|
518
|
+
}
|
|
519
|
+
// Product Recommendations
|
|
520
|
+
async getProductRecommendations(productId, count = 5) {
|
|
521
|
+
const response = await this.graphqlQuery(PRODUCT_RECOMMENDATIONS_QUERY, { productId, intent: "RELATED" });
|
|
522
|
+
if (!response.success || !response.data) {
|
|
523
|
+
return { success: false, error: response.error };
|
|
524
|
+
}
|
|
525
|
+
const recommendations = response.data.productRecommendations || [];
|
|
526
|
+
return { success: true, data: recommendations.slice(0, count) };
|
|
527
|
+
}
|
|
528
|
+
// Collections
|
|
529
|
+
async getCollections(params = {}) {
|
|
530
|
+
const response = await this.graphqlQuery(COLLECTIONS_QUERY, { first: params.first ?? 20 });
|
|
531
|
+
if (!response.success || !response.data) {
|
|
532
|
+
return { success: false, error: response.error };
|
|
533
|
+
}
|
|
534
|
+
return { success: true, data: response.data.collections };
|
|
535
|
+
}
|
|
536
|
+
async getCollectionByHandle(handle, productsFirst = 20) {
|
|
537
|
+
const response = await this.graphqlQuery(COLLECTION_BY_HANDLE_QUERY, { handle, productsFirst });
|
|
538
|
+
if (!response.success || !response.data) {
|
|
539
|
+
return { success: false, error: response.error };
|
|
540
|
+
}
|
|
541
|
+
if (!response.data.collection) {
|
|
542
|
+
return { success: true, data: null };
|
|
543
|
+
}
|
|
544
|
+
const collection = {
|
|
545
|
+
id: response.data.collection.id,
|
|
546
|
+
handle: response.data.collection.handle,
|
|
547
|
+
title: response.data.collection.title,
|
|
548
|
+
description: response.data.collection.description,
|
|
549
|
+
image: response.data.collection.image,
|
|
550
|
+
productRefs: response.data.collection.products
|
|
551
|
+
? { edges: response.data.collection.products.edges }
|
|
552
|
+
: undefined,
|
|
553
|
+
};
|
|
554
|
+
return { success: true, data: collection };
|
|
555
|
+
}
|
|
556
|
+
// CMS
|
|
557
|
+
async getMenu(handle) {
|
|
558
|
+
const response = await this.graphqlQuery(MENU_QUERY, { handle });
|
|
559
|
+
if (!response.success || !response.data) {
|
|
560
|
+
return { success: false, error: response.error };
|
|
561
|
+
}
|
|
562
|
+
return { success: true, data: response.data.menu };
|
|
563
|
+
}
|
|
564
|
+
async getPage(handle) {
|
|
565
|
+
const response = await this.graphqlQuery(PAGE_BY_HANDLE_QUERY, { handle });
|
|
566
|
+
if (!response.success || !response.data) {
|
|
567
|
+
return { success: false, error: response.error };
|
|
568
|
+
}
|
|
569
|
+
return { success: true, data: response.data.page };
|
|
570
|
+
}
|
|
571
|
+
// Cart
|
|
572
|
+
async createCart() {
|
|
573
|
+
const response = await this.graphqlQuery(CART_CREATE_MUTATION);
|
|
574
|
+
if (!response.success || !response.data) {
|
|
575
|
+
return { success: false, error: response.error };
|
|
576
|
+
}
|
|
577
|
+
return { success: true, data: response.data.cartCreate.cart };
|
|
578
|
+
}
|
|
579
|
+
async getCart(cartId) {
|
|
580
|
+
const response = await this.graphqlQuery(CART_QUERY, { id: cartId });
|
|
581
|
+
if (!response.success || !response.data) {
|
|
582
|
+
return { success: false, error: response.error };
|
|
583
|
+
}
|
|
584
|
+
return { success: true, data: response.data.cart };
|
|
585
|
+
}
|
|
586
|
+
async addToCart(cartId, lines) {
|
|
587
|
+
const response = await this.graphqlQuery(CART_LINES_ADD_MUTATION, { cartId, lines });
|
|
588
|
+
if (!response.success || !response.data) {
|
|
589
|
+
return { success: false, error: response.error };
|
|
590
|
+
}
|
|
591
|
+
return { success: true, data: response.data.cartLinesAdd.cart };
|
|
592
|
+
}
|
|
593
|
+
async updateCartLines(cartId, lines) {
|
|
594
|
+
const response = await this.graphqlQuery(CART_LINES_UPDATE_MUTATION, { cartId, lines });
|
|
595
|
+
if (!response.success || !response.data) {
|
|
596
|
+
return { success: false, error: response.error };
|
|
597
|
+
}
|
|
598
|
+
if (response.data.cartLinesUpdate.userErrors?.length) {
|
|
599
|
+
const error = response.data.cartLinesUpdate.userErrors[0];
|
|
600
|
+
return {
|
|
601
|
+
success: false,
|
|
602
|
+
error: {
|
|
603
|
+
code: "CART_LINES_UPDATE_ERROR",
|
|
604
|
+
message: error?.message ?? "Failed to update cart lines",
|
|
605
|
+
details: response.data.cartLinesUpdate.userErrors,
|
|
606
|
+
},
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
return { success: true, data: response.data.cartLinesUpdate.cart };
|
|
610
|
+
}
|
|
611
|
+
async removeCartLines(cartId, lineIds) {
|
|
612
|
+
const response = await this.graphqlQuery(CART_LINES_REMOVE_MUTATION, { cartId, lineIds });
|
|
613
|
+
if (!response.success || !response.data) {
|
|
614
|
+
return { success: false, error: response.error };
|
|
615
|
+
}
|
|
616
|
+
if (response.data.cartLinesRemove.userErrors?.length) {
|
|
617
|
+
const error = response.data.cartLinesRemove.userErrors[0];
|
|
618
|
+
return {
|
|
619
|
+
success: false,
|
|
620
|
+
error: {
|
|
621
|
+
code: "CART_LINES_REMOVE_ERROR",
|
|
622
|
+
message: error?.message ?? "Failed to remove cart lines",
|
|
623
|
+
details: response.data.cartLinesRemove.userErrors,
|
|
624
|
+
},
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
return { success: true, data: response.data.cartLinesRemove.cart };
|
|
628
|
+
}
|
|
629
|
+
async updateCartDiscountCodes(cartId, discountCodes) {
|
|
630
|
+
const response = await this.graphqlQuery(CART_DISCOUNT_CODES_UPDATE_MUTATION, { cartId, discountCodes });
|
|
631
|
+
if (!response.success || !response.data) {
|
|
632
|
+
return { success: false, error: response.error };
|
|
633
|
+
}
|
|
634
|
+
if (response.data.cartDiscountCodesUpdate.userErrors?.length) {
|
|
635
|
+
const error = response.data.cartDiscountCodesUpdate.userErrors[0];
|
|
636
|
+
return {
|
|
637
|
+
success: false,
|
|
638
|
+
error: {
|
|
639
|
+
code: "CART_DISCOUNT_CODES_UPDATE_ERROR",
|
|
640
|
+
message: error?.message ?? "Failed to update discount codes",
|
|
641
|
+
details: response.data.cartDiscountCodesUpdate.userErrors,
|
|
642
|
+
},
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
return { success: true, data: response.data.cartDiscountCodesUpdate.cart };
|
|
646
|
+
}
|
|
647
|
+
async updateCartBuyerIdentity(cartId, buyerIdentity) {
|
|
648
|
+
const response = await this.graphqlQuery(CART_BUYER_IDENTITY_UPDATE_MUTATION, { cartId, buyerIdentity });
|
|
649
|
+
if (!response.success || !response.data) {
|
|
650
|
+
return { success: false, error: response.error };
|
|
651
|
+
}
|
|
652
|
+
if (response.data.cartBuyerIdentityUpdate.userErrors?.length) {
|
|
653
|
+
const error = response.data.cartBuyerIdentityUpdate.userErrors[0];
|
|
654
|
+
return {
|
|
655
|
+
success: false,
|
|
656
|
+
error: {
|
|
657
|
+
code: "CART_BUYER_IDENTITY_UPDATE_ERROR",
|
|
658
|
+
message: error?.message ?? "Failed to update buyer identity",
|
|
659
|
+
details: response.data.cartBuyerIdentityUpdate.userErrors,
|
|
660
|
+
},
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
return { success: true, data: response.data.cartBuyerIdentityUpdate.cart };
|
|
664
|
+
}
|
|
665
|
+
async updateCartNote(cartId, note) {
|
|
666
|
+
const response = await this.graphqlQuery(CART_NOTE_UPDATE_MUTATION, { cartId, note });
|
|
667
|
+
if (!response.success || !response.data) {
|
|
668
|
+
return { success: false, error: response.error };
|
|
669
|
+
}
|
|
670
|
+
if (response.data.cartNoteUpdate.userErrors?.length) {
|
|
671
|
+
const error = response.data.cartNoteUpdate.userErrors[0];
|
|
672
|
+
return {
|
|
673
|
+
success: false,
|
|
674
|
+
error: {
|
|
675
|
+
code: "CART_NOTE_UPDATE_ERROR",
|
|
676
|
+
message: error?.message ?? "Failed to update cart note",
|
|
677
|
+
details: response.data.cartNoteUpdate.userErrors,
|
|
678
|
+
},
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
return { success: true, data: response.data.cartNoteUpdate.cart };
|
|
682
|
+
}
|
|
683
|
+
async updateCartAttributes(cartId, attributes) {
|
|
684
|
+
const response = await this.graphqlQuery(CART_ATTRIBUTES_UPDATE_MUTATION, { cartId, attributes });
|
|
685
|
+
if (!response.success || !response.data) {
|
|
686
|
+
return { success: false, error: response.error };
|
|
687
|
+
}
|
|
688
|
+
if (response.data.cartAttributesUpdate.userErrors?.length) {
|
|
689
|
+
const error = response.data.cartAttributesUpdate.userErrors[0];
|
|
690
|
+
return {
|
|
691
|
+
success: false,
|
|
692
|
+
error: {
|
|
693
|
+
code: "CART_ATTRIBUTES_UPDATE_ERROR",
|
|
694
|
+
message: error?.message ?? "Failed to update cart attributes",
|
|
695
|
+
details: response.data.cartAttributesUpdate.userErrors,
|
|
696
|
+
},
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
return { success: true, data: response.data.cartAttributesUpdate.cart };
|
|
700
|
+
}
|
|
701
|
+
async updateCartGiftCardCodes(cartId, giftCardCodes) {
|
|
702
|
+
const response = await this.graphqlQuery(CART_GIFT_CARD_CODES_UPDATE_MUTATION, { cartId, giftCardCodes });
|
|
703
|
+
if (!response.success || !response.data) {
|
|
704
|
+
return { success: false, error: response.error };
|
|
705
|
+
}
|
|
706
|
+
if (response.data.cartGiftCardCodesUpdate.userErrors?.length) {
|
|
707
|
+
const error = response.data.cartGiftCardCodesUpdate.userErrors[0];
|
|
708
|
+
return {
|
|
709
|
+
success: false,
|
|
710
|
+
error: {
|
|
711
|
+
code: "CART_GIFT_CARD_CODES_UPDATE_ERROR",
|
|
712
|
+
message: error?.message ?? "Failed to update gift card codes",
|
|
713
|
+
details: response.data.cartGiftCardCodesUpdate.userErrors,
|
|
714
|
+
},
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
return { success: true, data: response.data.cartGiftCardCodesUpdate.cart };
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Health check for Shopify API
|
|
721
|
+
*/
|
|
722
|
+
async healthCheck() {
|
|
723
|
+
const response = await this.graphqlQuery("{ shop { name } }");
|
|
724
|
+
return {
|
|
725
|
+
name: this.name,
|
|
726
|
+
healthy: response.success,
|
|
727
|
+
error: response.error?.message,
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
exports.ShopifyCommerceService = ShopifyCommerceService;
|
|
732
|
+
exports.ShopifyCommerceService = ShopifyCommerceService = tslib_1.__decorate([
|
|
733
|
+
(0, common_1.Injectable)()
|
|
734
|
+
], ShopifyCommerceService);
|
|
735
|
+
//# sourceMappingURL=shopify.service.js.map
|