@faststore/api 1.8.46 → 1.8.49
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/CHANGELOG.md +11 -0
- package/dist/__generated__/schema.d.ts +45 -9
- package/dist/api.cjs.development.js +61 -49
- 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 +61 -49
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +1 -7
- package/dist/platforms/vtex/clients/commerce/index.d.ts +1 -1
- package/dist/platforms/vtex/clients/commerce/types/Session.d.ts +8 -0
- package/dist/platforms/vtex/clients/index.d.ts +1 -1
- package/dist/platforms/vtex/index.d.ts +1 -7
- package/dist/platforms/vtex/resolvers/mutation.d.ts +1 -1
- package/dist/platforms/vtex/resolvers/query.d.ts +0 -6
- package/dist/platforms/vtex/resolvers/validateSession.d.ts +3 -0
- package/package.json +2 -2
- package/src/__generated__/schema.ts +49 -10
- package/src/platforms/vtex/clients/commerce/index.ts +17 -12
- package/src/platforms/vtex/clients/commerce/types/Session.ts +9 -0
- package/src/platforms/vtex/resolvers/mutation.ts +2 -2
- package/src/platforms/vtex/resolvers/query.ts +0 -18
- package/src/platforms/vtex/resolvers/validateSession.ts +59 -0
- package/src/typeDefs/index.ts +2 -0
- package/src/typeDefs/mutation.graphql +2 -38
- package/src/typeDefs/person.graphql +22 -0
- package/src/typeDefs/query.graphql +0 -5
- package/src/typeDefs/session.graphql +84 -0
- package/dist/platforms/vtex/resolvers/updateSession.d.ts +0 -3
- package/src/platforms/vtex/resolvers/updateSession.ts +0 -26
package/dist/index.d.ts
CHANGED
|
@@ -117,12 +117,6 @@ export declare const getResolvers: (options: Options) => {
|
|
|
117
117
|
cursor: string;
|
|
118
118
|
}[];
|
|
119
119
|
}>;
|
|
120
|
-
person: (_: unknown, __: unknown, ctx: import("./platforms/vtex").Context) => Promise<{
|
|
121
|
-
id: string;
|
|
122
|
-
email: string;
|
|
123
|
-
givenName: string;
|
|
124
|
-
familyName: string;
|
|
125
|
-
} | null>;
|
|
126
120
|
};
|
|
127
121
|
Mutation: {
|
|
128
122
|
validateCart: (_: unknown, { cart: { order } }: {
|
|
@@ -182,7 +176,7 @@ export declare const getResolvers: (options: Options) => {
|
|
|
182
176
|
status: any;
|
|
183
177
|
}[];
|
|
184
178
|
} | null>;
|
|
185
|
-
|
|
179
|
+
validateSession: (_: any, { session: oldSession, search }: import("./__generated__/schema").MutationValidateSessionArgs, { clients }: import("./platforms/vtex").Context) => Promise<import("./__generated__/schema").StoreSession | null>;
|
|
186
180
|
};
|
|
187
181
|
};
|
|
188
182
|
export declare const getContextFactory: (options: Options) => (ctx: any) => import("./platforms/vtex").Context;
|
|
@@ -40,5 +40,5 @@ export declare const VtexCommerce: ({ account, environment }: Options, ctx: Cont
|
|
|
40
40
|
}) => Promise<OrderForm>;
|
|
41
41
|
region: ({ postalCode, country, salesChannel, }: RegionInput) => Promise<Region>;
|
|
42
42
|
};
|
|
43
|
-
session: () => Promise<Session>;
|
|
43
|
+
session: (search: string) => Promise<Session>;
|
|
44
44
|
};
|
|
@@ -4,10 +4,18 @@ export interface Session {
|
|
|
4
4
|
}
|
|
5
5
|
export interface Namespaces {
|
|
6
6
|
profile?: Profile;
|
|
7
|
+
store?: Store;
|
|
7
8
|
}
|
|
8
9
|
export interface Value {
|
|
9
10
|
value: string;
|
|
10
11
|
}
|
|
12
|
+
export interface Store {
|
|
13
|
+
channel: Value;
|
|
14
|
+
countryCode: Value;
|
|
15
|
+
cultureInfo: Value;
|
|
16
|
+
currencyCode: Value;
|
|
17
|
+
currencySymbol: Value;
|
|
18
|
+
}
|
|
11
19
|
export interface Profile {
|
|
12
20
|
id?: Value;
|
|
13
21
|
email?: Value;
|
|
@@ -40,7 +40,7 @@ export declare const getClients: (options: Options, ctx: Context) => {
|
|
|
40
40
|
}) => Promise<import("./commerce/types/OrderForm").OrderForm>;
|
|
41
41
|
region: ({ postalCode, country, salesChannel, }: import("./commerce/types/Region").RegionInput) => Promise<import("./commerce/types/Region").Region>;
|
|
42
42
|
};
|
|
43
|
-
session: () => Promise<import("./commerce/types/Session").Session>;
|
|
43
|
+
session: (search: string) => Promise<import("./commerce/types/Session").Session>;
|
|
44
44
|
};
|
|
45
45
|
sp: {
|
|
46
46
|
sendEvent: (options: import("./sp").SearchEvent) => Promise<any>;
|
|
@@ -146,12 +146,6 @@ export declare const getResolvers: (_: Options) => {
|
|
|
146
146
|
cursor: string;
|
|
147
147
|
}[];
|
|
148
148
|
}>;
|
|
149
|
-
person: (_: unknown, __: unknown, ctx: Context) => Promise<{
|
|
150
|
-
id: string;
|
|
151
|
-
email: string;
|
|
152
|
-
givenName: string;
|
|
153
|
-
familyName: string;
|
|
154
|
-
} | null>;
|
|
155
149
|
};
|
|
156
150
|
Mutation: {
|
|
157
151
|
validateCart: (_: unknown, { cart: { order } }: {
|
|
@@ -211,7 +205,7 @@ export declare const getResolvers: (_: Options) => {
|
|
|
211
205
|
status: any;
|
|
212
206
|
}[];
|
|
213
207
|
} | null>;
|
|
214
|
-
|
|
208
|
+
validateSession: (_: any, { session: oldSession, search }: import("../..").MutationValidateSessionArgs, { clients }: Context) => Promise<import("../..").StoreSession | null>;
|
|
215
209
|
};
|
|
216
210
|
};
|
|
217
211
|
export {};
|
|
@@ -56,5 +56,5 @@ export declare const Mutation: {
|
|
|
56
56
|
status: any;
|
|
57
57
|
}[];
|
|
58
58
|
} | null>;
|
|
59
|
-
|
|
59
|
+
validateSession: (_: any, { session: oldSession, search }: import("../../..").MutationValidateSessionArgs, { clients }: import("..").Context) => Promise<import("../../..").StoreSession | null>;
|
|
60
60
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Context } from '..';
|
|
2
|
+
import type { MutationValidateSessionArgs, StoreSession } from '../../../__generated__/schema';
|
|
3
|
+
export declare const validateSession: (_: any, { session: oldSession, search }: MutationValidateSessionArgs, { clients }: Context) => Promise<StoreSession | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.49",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"graphql": "^15.6.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4b814f0be6b3088399e3c6312d9c941fe523cf0e"
|
|
48
48
|
}
|
|
@@ -18,6 +18,13 @@ export type IStoreCart = {
|
|
|
18
18
|
order: IStoreOrder;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
export type IStoreCurrency = {
|
|
22
|
+
/** Currency code, e.g: USD */
|
|
23
|
+
code: Scalars['String'];
|
|
24
|
+
/** Currency symbol, e.g: $ */
|
|
25
|
+
symbol: Scalars['String'];
|
|
26
|
+
};
|
|
27
|
+
|
|
21
28
|
/** Image input. */
|
|
22
29
|
export type IStoreImage = {
|
|
23
30
|
/** Alias for the input image. */
|
|
@@ -54,6 +61,18 @@ export type IStoreOrganization = {
|
|
|
54
61
|
identifier: Scalars['String'];
|
|
55
62
|
};
|
|
56
63
|
|
|
64
|
+
/** Client profile data. */
|
|
65
|
+
export type IStorePerson = {
|
|
66
|
+
/** Client email. */
|
|
67
|
+
email: Scalars['String'];
|
|
68
|
+
/** Client last name. */
|
|
69
|
+
familyName: Scalars['String'];
|
|
70
|
+
/** Client first name. */
|
|
71
|
+
givenName: Scalars['String'];
|
|
72
|
+
/** Client ID. */
|
|
73
|
+
id: Scalars['String'];
|
|
74
|
+
};
|
|
75
|
+
|
|
57
76
|
/** Product input. Products are variants within product groups, equivalent to VTEX [SKUs](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on. */
|
|
58
77
|
export type IStoreProduct = {
|
|
59
78
|
/** Custom Product Additional Properties. */
|
|
@@ -88,27 +107,34 @@ export type IStoreSession = {
|
|
|
88
107
|
/** Session input channel. */
|
|
89
108
|
channel?: Maybe<Scalars['String']>;
|
|
90
109
|
/** Session input country. */
|
|
91
|
-
country
|
|
110
|
+
country: Scalars['String'];
|
|
111
|
+
/** Session input currency. */
|
|
112
|
+
currency: IStoreCurrency;
|
|
113
|
+
/** Session input locale. */
|
|
114
|
+
locale: Scalars['String'];
|
|
115
|
+
/** Session input postal code. */
|
|
116
|
+
person?: Maybe<IStorePerson>;
|
|
92
117
|
/** Session input postal code. */
|
|
93
118
|
postalCode?: Maybe<Scalars['String']>;
|
|
94
119
|
};
|
|
95
120
|
|
|
96
121
|
export type Mutation = {
|
|
97
122
|
__typename?: 'Mutation';
|
|
98
|
-
/** Update session information. */
|
|
99
|
-
updateSession: StoreSession;
|
|
100
123
|
/** Returns the order if anything has changed in it, or `null` if the order is valid. */
|
|
101
124
|
validateCart?: Maybe<StoreCart>;
|
|
125
|
+
/** Validate session information. */
|
|
126
|
+
validateSession?: Maybe<StoreSession>;
|
|
102
127
|
};
|
|
103
128
|
|
|
104
129
|
|
|
105
|
-
export type
|
|
106
|
-
|
|
130
|
+
export type MutationValidateCartArgs = {
|
|
131
|
+
cart: IStoreCart;
|
|
107
132
|
};
|
|
108
133
|
|
|
109
134
|
|
|
110
|
-
export type
|
|
111
|
-
|
|
135
|
+
export type MutationValidateSessionArgs = {
|
|
136
|
+
search: Scalars['String'];
|
|
137
|
+
session: IStoreSession;
|
|
112
138
|
};
|
|
113
139
|
|
|
114
140
|
export type Query = {
|
|
@@ -119,8 +145,6 @@ export type Query = {
|
|
|
119
145
|
allProducts: StoreProductConnection;
|
|
120
146
|
/** Collection query. */
|
|
121
147
|
collection: StoreCollection;
|
|
122
|
-
/** Person query. */
|
|
123
|
-
person?: Maybe<StorePerson>;
|
|
124
148
|
/** Product query. */
|
|
125
149
|
product: StoreProduct;
|
|
126
150
|
/** Search query. */
|
|
@@ -282,6 +306,15 @@ export const enum StoreCollectionType {
|
|
|
282
306
|
Department = 'Department'
|
|
283
307
|
};
|
|
284
308
|
|
|
309
|
+
/** Currency information. */
|
|
310
|
+
export type StoreCurrency = {
|
|
311
|
+
__typename?: 'StoreCurrency';
|
|
312
|
+
/** Currency code, e.g: USD */
|
|
313
|
+
code: Scalars['String'];
|
|
314
|
+
/** Currency symbol, e.g: $ */
|
|
315
|
+
symbol: Scalars['String'];
|
|
316
|
+
};
|
|
317
|
+
|
|
285
318
|
/** Search facet information. */
|
|
286
319
|
export type StoreFacet = {
|
|
287
320
|
__typename?: 'StoreFacet';
|
|
@@ -530,7 +563,13 @@ export type StoreSession = {
|
|
|
530
563
|
/** Session channel. */
|
|
531
564
|
channel?: Maybe<Scalars['String']>;
|
|
532
565
|
/** Session country. */
|
|
533
|
-
country
|
|
566
|
+
country: Scalars['String'];
|
|
567
|
+
/** Session currency. */
|
|
568
|
+
currency: StoreCurrency;
|
|
569
|
+
/** Session locale. */
|
|
570
|
+
locale: Scalars['String'];
|
|
571
|
+
/** Session postal code. */
|
|
572
|
+
person?: Maybe<StorePerson>;
|
|
534
573
|
/** Session postal code. */
|
|
535
574
|
postalCode?: Maybe<Scalars['String']>;
|
|
536
575
|
};
|
|
@@ -135,17 +135,22 @@ export const VtexCommerce = (
|
|
|
135
135
|
)
|
|
136
136
|
},
|
|
137
137
|
},
|
|
138
|
-
session: (): Promise<Session> =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
138
|
+
session: (search: string): Promise<Session> => {
|
|
139
|
+
const params = new URLSearchParams(search)
|
|
140
|
+
|
|
141
|
+
params.set(
|
|
142
|
+
'items',
|
|
143
|
+
'profile.id,profile.email,profile.firstName,profile.lastName,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol'
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
return fetchAPI(`${base}/api/sessions?${params.toString()}`, {
|
|
147
|
+
method: 'POST',
|
|
148
|
+
headers: {
|
|
149
|
+
'content-type': 'application/json',
|
|
150
|
+
cookie: ctx.headers.cookie,
|
|
151
|
+
},
|
|
152
|
+
body: '{}',
|
|
153
|
+
})
|
|
154
|
+
},
|
|
150
155
|
}
|
|
151
156
|
}
|
|
@@ -5,12 +5,21 @@ export interface Session {
|
|
|
5
5
|
|
|
6
6
|
export interface Namespaces {
|
|
7
7
|
profile?: Profile
|
|
8
|
+
store?: Store
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export interface Value {
|
|
11
12
|
value: string
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
export interface Store {
|
|
16
|
+
channel: Value
|
|
17
|
+
countryCode: Value
|
|
18
|
+
cultureInfo: Value
|
|
19
|
+
currencyCode: Value
|
|
20
|
+
currencySymbol: Value
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
export interface Profile {
|
|
15
24
|
id?: Value
|
|
16
25
|
email?: Value
|
|
@@ -165,22 +165,4 @@ export const Query = {
|
|
|
165
165
|
})),
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
|
-
person: async (_: unknown, __: unknown, ctx: Context) => {
|
|
169
|
-
const {
|
|
170
|
-
clients: { commerce },
|
|
171
|
-
} = ctx
|
|
172
|
-
|
|
173
|
-
const {
|
|
174
|
-
namespaces: { profile = null },
|
|
175
|
-
} = await commerce.session()
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
profile && {
|
|
179
|
-
id: profile.id?.value ?? '',
|
|
180
|
-
email: profile.email?.value ?? '',
|
|
181
|
-
givenName: profile.firstName?.value ?? '',
|
|
182
|
-
familyName: profile.lastName?.value ?? '',
|
|
183
|
-
}
|
|
184
|
-
)
|
|
185
|
-
},
|
|
186
168
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import deepEquals from 'fast-deep-equal'
|
|
2
|
+
|
|
3
|
+
import ChannelMarshal from '../utils/channel'
|
|
4
|
+
import type { Context } from '..'
|
|
5
|
+
import type {
|
|
6
|
+
MutationValidateSessionArgs,
|
|
7
|
+
StoreSession,
|
|
8
|
+
} from '../../../__generated__/schema'
|
|
9
|
+
|
|
10
|
+
export const validateSession = async (
|
|
11
|
+
_: any,
|
|
12
|
+
{ session: oldSession, search }: MutationValidateSessionArgs,
|
|
13
|
+
{ clients }: Context
|
|
14
|
+
): Promise<StoreSession | null> => {
|
|
15
|
+
const channel = ChannelMarshal.parse(oldSession.channel ?? '')
|
|
16
|
+
const postalCode = String(oldSession.postalCode ?? '').replace(/\D/g, '')
|
|
17
|
+
const country = oldSession.country ?? ''
|
|
18
|
+
|
|
19
|
+
const params = new URLSearchParams(search)
|
|
20
|
+
|
|
21
|
+
params.set('sc', params.get('sc') ?? channel.salesChannel)
|
|
22
|
+
|
|
23
|
+
const [regionData, sessionData] = await Promise.all([
|
|
24
|
+
postalCode
|
|
25
|
+
? clients.commerce.checkout.region({ postalCode, country })
|
|
26
|
+
: Promise.resolve(null),
|
|
27
|
+
clients.commerce.session(params.toString()).catch(() => null),
|
|
28
|
+
])
|
|
29
|
+
|
|
30
|
+
const profile = sessionData?.namespaces.profile ?? null
|
|
31
|
+
const store = sessionData?.namespaces.store ?? null
|
|
32
|
+
|
|
33
|
+
const newSession = {
|
|
34
|
+
...oldSession,
|
|
35
|
+
currency: {
|
|
36
|
+
code: store?.currencyCode.value ?? oldSession.currency.code,
|
|
37
|
+
symbol: store?.currencySymbol.value ?? oldSession.currency.symbol,
|
|
38
|
+
},
|
|
39
|
+
country: store?.countryCode.value ?? oldSession.country,
|
|
40
|
+
channel: ChannelMarshal.stringify({
|
|
41
|
+
salesChannel: store?.channel?.value ?? channel.salesChannel,
|
|
42
|
+
regionId: regionData?.[0]?.id ?? channel.regionId,
|
|
43
|
+
}),
|
|
44
|
+
person: profile?.id
|
|
45
|
+
? {
|
|
46
|
+
id: profile.id?.value ?? '',
|
|
47
|
+
email: profile.email?.value ?? '',
|
|
48
|
+
givenName: profile.firstName?.value ?? '',
|
|
49
|
+
familyName: profile.lastName?.value ?? '',
|
|
50
|
+
}
|
|
51
|
+
: null,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (deepEquals(oldSession, newSession)) {
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return newSession
|
|
59
|
+
}
|
package/src/typeDefs/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ import Status from './status.graphql'
|
|
|
23
23
|
import PropertyValue from './propertyValue.graphql'
|
|
24
24
|
import Person from './person.graphql'
|
|
25
25
|
import ObjectOrString from './objectOrString.graphql'
|
|
26
|
+
import Session from './session.graphql'
|
|
26
27
|
|
|
27
28
|
export const typeDefs = [
|
|
28
29
|
Query,
|
|
@@ -48,6 +49,7 @@ export const typeDefs = [
|
|
|
48
49
|
PropertyValue,
|
|
49
50
|
Person,
|
|
50
51
|
ObjectOrString,
|
|
52
|
+
Session,
|
|
51
53
|
]
|
|
52
54
|
.map(print)
|
|
53
55
|
.join('\n')
|
|
@@ -1,46 +1,10 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Session information.
|
|
3
|
-
"""
|
|
4
|
-
type StoreSession {
|
|
5
|
-
"""
|
|
6
|
-
Session channel.
|
|
7
|
-
"""
|
|
8
|
-
channel: String
|
|
9
|
-
"""
|
|
10
|
-
Session country.
|
|
11
|
-
"""
|
|
12
|
-
country: String
|
|
13
|
-
"""
|
|
14
|
-
Session postal code.
|
|
15
|
-
"""
|
|
16
|
-
postalCode: String
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
"""
|
|
20
|
-
Session input.
|
|
21
|
-
"""
|
|
22
|
-
input IStoreSession {
|
|
23
|
-
"""
|
|
24
|
-
Session input channel.
|
|
25
|
-
"""
|
|
26
|
-
channel: String
|
|
27
|
-
"""
|
|
28
|
-
Session input country.
|
|
29
|
-
"""
|
|
30
|
-
country: String
|
|
31
|
-
"""
|
|
32
|
-
Session input postal code.
|
|
33
|
-
"""
|
|
34
|
-
postalCode: String
|
|
35
|
-
}
|
|
36
|
-
|
|
37
1
|
type Mutation {
|
|
38
2
|
"""
|
|
39
3
|
Returns the order if anything has changed in it, or `null` if the order is valid.
|
|
40
4
|
"""
|
|
41
5
|
validateCart(cart: IStoreCart!): StoreCart
|
|
42
6
|
"""
|
|
43
|
-
|
|
7
|
+
Validate session information.
|
|
44
8
|
"""
|
|
45
|
-
|
|
9
|
+
validateSession(session: IStoreSession!, search: String!): StoreSession
|
|
46
10
|
}
|
|
@@ -19,3 +19,25 @@ type StorePerson {
|
|
|
19
19
|
"""
|
|
20
20
|
familyName: String!
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
Client profile data.
|
|
25
|
+
"""
|
|
26
|
+
input IStorePerson {
|
|
27
|
+
"""
|
|
28
|
+
Client ID.
|
|
29
|
+
"""
|
|
30
|
+
id: String!
|
|
31
|
+
"""
|
|
32
|
+
Client email.
|
|
33
|
+
"""
|
|
34
|
+
email: String!
|
|
35
|
+
"""
|
|
36
|
+
Client first name.
|
|
37
|
+
"""
|
|
38
|
+
givenName: String!
|
|
39
|
+
"""
|
|
40
|
+
Client last name.
|
|
41
|
+
"""
|
|
42
|
+
familyName: String!
|
|
43
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Currency information.
|
|
3
|
+
"""
|
|
4
|
+
type StoreCurrency {
|
|
5
|
+
"""
|
|
6
|
+
Currency code, e.g: USD
|
|
7
|
+
"""
|
|
8
|
+
code: String!
|
|
9
|
+
"""
|
|
10
|
+
Currency symbol, e.g: $
|
|
11
|
+
"""
|
|
12
|
+
symbol: String!
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
input IStoreCurrency {
|
|
16
|
+
"""
|
|
17
|
+
Currency code, e.g: USD
|
|
18
|
+
"""
|
|
19
|
+
code: String!
|
|
20
|
+
"""
|
|
21
|
+
Currency symbol, e.g: $
|
|
22
|
+
"""
|
|
23
|
+
symbol: String!
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
Session information.
|
|
28
|
+
"""
|
|
29
|
+
type StoreSession {
|
|
30
|
+
"""
|
|
31
|
+
Session locale.
|
|
32
|
+
"""
|
|
33
|
+
locale: String!
|
|
34
|
+
"""
|
|
35
|
+
Session currency.
|
|
36
|
+
"""
|
|
37
|
+
currency: StoreCurrency!
|
|
38
|
+
"""
|
|
39
|
+
Session country.
|
|
40
|
+
"""
|
|
41
|
+
country: String!
|
|
42
|
+
"""
|
|
43
|
+
Session channel.
|
|
44
|
+
"""
|
|
45
|
+
channel: String
|
|
46
|
+
"""
|
|
47
|
+
Session postal code.
|
|
48
|
+
"""
|
|
49
|
+
postalCode: String
|
|
50
|
+
"""
|
|
51
|
+
Session postal code.
|
|
52
|
+
"""
|
|
53
|
+
person: StorePerson
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
Session input.
|
|
58
|
+
"""
|
|
59
|
+
input IStoreSession {
|
|
60
|
+
"""
|
|
61
|
+
Session input locale.
|
|
62
|
+
"""
|
|
63
|
+
locale: String!
|
|
64
|
+
"""
|
|
65
|
+
Session input currency.
|
|
66
|
+
"""
|
|
67
|
+
currency: IStoreCurrency!
|
|
68
|
+
"""
|
|
69
|
+
Session input country.
|
|
70
|
+
"""
|
|
71
|
+
country: String!
|
|
72
|
+
"""
|
|
73
|
+
Session input channel.
|
|
74
|
+
"""
|
|
75
|
+
channel: String
|
|
76
|
+
"""
|
|
77
|
+
Session input postal code.
|
|
78
|
+
"""
|
|
79
|
+
postalCode: String
|
|
80
|
+
"""
|
|
81
|
+
Session input postal code.
|
|
82
|
+
"""
|
|
83
|
+
person: IStorePerson
|
|
84
|
+
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Context } from '..'
|
|
2
|
-
import type {
|
|
3
|
-
MutationUpdateSessionArgs,
|
|
4
|
-
StoreSession,
|
|
5
|
-
} from '../../../__generated__/schema'
|
|
6
|
-
import ChannelMarshal from '../utils/channel'
|
|
7
|
-
|
|
8
|
-
export const updateSession = async (
|
|
9
|
-
_: any,
|
|
10
|
-
{ session }: MutationUpdateSessionArgs,
|
|
11
|
-
{ clients }: Context
|
|
12
|
-
): Promise<StoreSession> => {
|
|
13
|
-
const channel = ChannelMarshal.parse(session.channel ?? '')
|
|
14
|
-
const regionData = await clients.commerce.checkout.region({
|
|
15
|
-
postalCode: String(session.postalCode ?? '').replace(/\D/g, ''),
|
|
16
|
-
country: session.country ?? '',
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
...session,
|
|
21
|
-
channel: ChannelMarshal.stringify({
|
|
22
|
-
...channel,
|
|
23
|
-
regionId: regionData?.[0]?.id,
|
|
24
|
-
}),
|
|
25
|
-
}
|
|
26
|
-
}
|