@faststore/api 2.1.98 → 2.1.99
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/api.cjs.development.js +6 -20
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +6 -20
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/fetch.d.ts +1 -1
- package/dist/platforms/vtex/index.d.ts +0 -1
- package/package.json +4 -4
- package/src/platforms/vtex/clients/commerce/index.ts +11 -32
- package/src/platforms/vtex/clients/fetch.ts +1 -9
- package/src/platforms/vtex/index.ts +11 -12
- package/src/platforms/vtex/resolvers/validateCart.ts +0 -1
- package/dist/utils/get-cookie-by-name.d.ts +0 -1
- package/src/utils/get-cookie-by-name.ts +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const fetchAPI: (info: RequestInfo, init?: RequestInit | undefined
|
|
1
|
+
export declare const fetchAPI: (info: RequestInfo, init?: RequestInit | undefined) => Promise<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.99",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@envelop/core": "^2.6.0",
|
|
39
|
-
"@faststore/eslint-config": "^2.1.
|
|
40
|
-
"@faststore/shared": "^2.1.
|
|
39
|
+
"@faststore/eslint-config": "^2.1.99",
|
|
40
|
+
"@faststore/shared": "^2.1.99",
|
|
41
41
|
"@graphql-codegen/cli": "2.2.0",
|
|
42
42
|
"@graphql-codegen/typescript": "2.2.2",
|
|
43
43
|
"@types/express": "^4.17.16",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"@envelop/core": "^1 || ^2",
|
|
57
57
|
"graphql": "^15.6.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "2ecd31444b00639f05e8b99847df231d8f2f7b0e"
|
|
60
60
|
}
|
|
@@ -19,7 +19,6 @@ import type { SalesChannel } from './types/SalesChannel'
|
|
|
19
19
|
import { MasterDataResponse } from './types/Newsletter'
|
|
20
20
|
import type { Address, AddressInput } from './types/Address'
|
|
21
21
|
import { DeliveryMode, SelectedAddress } from './types/ShippingData'
|
|
22
|
-
import getCookieByName from '../../../../utils/get-cookie-by-name'
|
|
23
22
|
|
|
24
23
|
type ValueOf<T> = T extends Record<string, infer K> ? K : never
|
|
25
24
|
|
|
@@ -30,18 +29,6 @@ const BASE_INIT = {
|
|
|
30
29
|
},
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
const setCheckoutOrderFormOwnershipCookie = (
|
|
34
|
-
headers: Headers,
|
|
35
|
-
ctx: Context
|
|
36
|
-
) => {
|
|
37
|
-
if (headers) {
|
|
38
|
-
ctx.storage.cookies = `CheckoutOrderFormOwnership=${getCookieByName(
|
|
39
|
-
'CheckoutOrderFormOwnership',
|
|
40
|
-
headers.get('set-cookie') ?? ''
|
|
41
|
-
)}`
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
32
|
export const VtexCommerce = (
|
|
46
33
|
{ account, environment, incrementAddress }: Options,
|
|
47
34
|
ctx: Context
|
|
@@ -144,8 +131,7 @@ export const VtexCommerce = (
|
|
|
144
131
|
'content-type': 'application/json',
|
|
145
132
|
cookie: ctx.headers.cookie,
|
|
146
133
|
},
|
|
147
|
-
}
|
|
148
|
-
(headers) => setCheckoutOrderFormOwnershipCookie(headers, ctx)
|
|
134
|
+
}
|
|
149
135
|
)
|
|
150
136
|
},
|
|
151
137
|
|
|
@@ -166,8 +152,7 @@ export const VtexCommerce = (
|
|
|
166
152
|
|
|
167
153
|
return fetchAPI(
|
|
168
154
|
`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`,
|
|
169
|
-
BASE_INIT
|
|
170
|
-
(headers) => setCheckoutOrderFormOwnershipCookie(headers, ctx)
|
|
155
|
+
BASE_INIT
|
|
171
156
|
)
|
|
172
157
|
},
|
|
173
158
|
updateOrderFormItems: ({
|
|
@@ -197,8 +182,7 @@ export const VtexCommerce = (
|
|
|
197
182
|
noSplitItem: !shouldSplitItem,
|
|
198
183
|
}),
|
|
199
184
|
method: 'PATCH',
|
|
200
|
-
}
|
|
201
|
-
(headers) => setCheckoutOrderFormOwnershipCookie(headers, ctx)
|
|
185
|
+
}
|
|
202
186
|
)
|
|
203
187
|
},
|
|
204
188
|
setCustomData: ({
|
|
@@ -218,8 +202,7 @@ export const VtexCommerce = (
|
|
|
218
202
|
...BASE_INIT,
|
|
219
203
|
body: JSON.stringify({ value }),
|
|
220
204
|
method: 'PUT',
|
|
221
|
-
}
|
|
222
|
-
(headers) => setCheckoutOrderFormOwnershipCookie(headers, ctx)
|
|
205
|
+
}
|
|
223
206
|
)
|
|
224
207
|
},
|
|
225
208
|
region: async ({
|
|
@@ -259,18 +242,14 @@ export const VtexCommerce = (
|
|
|
259
242
|
'items',
|
|
260
243
|
'profile.id,profile.email,profile.firstName,profile.lastName,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol'
|
|
261
244
|
)
|
|
262
|
-
return fetchAPI(
|
|
263
|
-
|
|
264
|
-
{
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
'content-type': 'application/json',
|
|
268
|
-
cookie: ctx.headers.cookie,
|
|
269
|
-
},
|
|
270
|
-
body: '{}',
|
|
245
|
+
return fetchAPI(`${base}/api/sessions?${params.toString()}`, {
|
|
246
|
+
method: 'POST',
|
|
247
|
+
headers: {
|
|
248
|
+
'content-type': 'application/json',
|
|
249
|
+
cookie: ctx.headers.cookie,
|
|
271
250
|
},
|
|
272
|
-
|
|
273
|
-
)
|
|
251
|
+
body: '{}',
|
|
252
|
+
})
|
|
274
253
|
},
|
|
275
254
|
subscribeToNewsletter: (data: {
|
|
276
255
|
name: string
|
|
@@ -3,11 +3,7 @@ import packageJson from '../../../../package.json'
|
|
|
3
3
|
|
|
4
4
|
const USER_AGENT = `${packageJson.name}@${packageJson.version}`
|
|
5
5
|
|
|
6
|
-
export const fetchAPI = async (
|
|
7
|
-
info: RequestInfo,
|
|
8
|
-
init?: RequestInit,
|
|
9
|
-
getHeaders?: (headers: Headers) => void
|
|
10
|
-
) => {
|
|
6
|
+
export const fetchAPI = async (info: RequestInfo, init?: RequestInit) => {
|
|
11
7
|
const response = await fetch(info, {
|
|
12
8
|
...init,
|
|
13
9
|
headers: {
|
|
@@ -17,10 +13,6 @@ export const fetchAPI = async (
|
|
|
17
13
|
})
|
|
18
14
|
|
|
19
15
|
if (response.ok) {
|
|
20
|
-
if (getHeaders) {
|
|
21
|
-
getHeaders(response.headers)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
16
|
return response.status !== 204 ? response.json() : undefined
|
|
25
17
|
}
|
|
26
18
|
|
|
@@ -35,7 +35,7 @@ export interface Options {
|
|
|
35
35
|
channel: string
|
|
36
36
|
locale: string
|
|
37
37
|
hideUnavailableItems: boolean
|
|
38
|
-
incrementAddress: boolean
|
|
38
|
+
incrementAddress: boolean,
|
|
39
39
|
flags?: FeatureFlags
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -57,7 +57,6 @@ export interface Context {
|
|
|
57
57
|
locale: string
|
|
58
58
|
flags: FeatureFlags
|
|
59
59
|
searchArgs?: Omit<SearchArgs, 'type'>
|
|
60
|
-
cookies?: string | null
|
|
61
60
|
}
|
|
62
61
|
headers: Record<string, string>
|
|
63
62
|
}
|
|
@@ -93,16 +92,16 @@ const Resolvers = {
|
|
|
93
92
|
|
|
94
93
|
export const getContextFactory =
|
|
95
94
|
(options: Options) =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
(ctx: any): Context => {
|
|
96
|
+
ctx.storage = {
|
|
97
|
+
channel: ChannelMarshal.parse(options.channel),
|
|
98
|
+
flags: options.flags ?? {},
|
|
99
|
+
locale: options.locale,
|
|
100
|
+
}
|
|
101
|
+
ctx.clients = getClients(options, ctx)
|
|
102
|
+
ctx.loaders = getLoaders(options, ctx)
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
return ctx
|
|
105
|
+
}
|
|
107
106
|
|
|
108
107
|
export const getResolvers = (_: Options) => Resolvers
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getCookieByName(cookiename: string, source: string): string;
|