@faststore/api 3.89.3 → 3.90.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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/__generated__/schema.d.ts +4 -0
- package/dist/cjs/src/__generated__/schema.d.ts.map +1 -1
- package/dist/cjs/src/__generated__/schema.js.map +1 -1
- package/dist/cjs/src/platforms/vtex/clients/commerce/index.js +1 -1
- package/dist/cjs/src/platforms/vtex/clients/commerce/index.js.map +1 -1
- package/dist/cjs/src/platforms/vtex/clients/commerce/types/Session.d.ts +3 -0
- package/dist/cjs/src/platforms/vtex/clients/commerce/types/Session.d.ts.map +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/validateSession.d.ts.map +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/validateSession.js +14 -0
- package/dist/cjs/src/platforms/vtex/resolvers/validateSession.js.map +1 -1
- package/dist/cjs/src/typeDefs/session.graphql +4 -0
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/__generated__/schema.d.ts +4 -0
- package/dist/esm/src/__generated__/schema.d.ts.map +1 -1
- package/dist/esm/src/__generated__/schema.js.map +1 -1
- package/dist/esm/src/platforms/vtex/clients/commerce/index.js +1 -1
- package/dist/esm/src/platforms/vtex/clients/commerce/index.js.map +1 -1
- package/dist/esm/src/platforms/vtex/clients/commerce/types/Session.d.ts +3 -0
- package/dist/esm/src/platforms/vtex/clients/commerce/types/Session.d.ts.map +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/validateSession.d.ts.map +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/validateSession.js +14 -0
- package/dist/esm/src/platforms/vtex/resolvers/validateSession.js.map +1 -1
- package/dist/esm/src/typeDefs/session.graphql +4 -0
- package/package.json +2 -2
- package/src/__generated__/schema.ts +4 -0
- package/src/platforms/vtex/clients/commerce/index.ts +1 -1
- package/src/platforms/vtex/clients/commerce/types/Session.ts +1 -0
- package/src/platforms/vtex/resolvers/validateSession.ts +16 -0
- package/src/typeDefs/session.graphql +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.90.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/cjs/src/index.js",
|
|
6
6
|
"typings": "dist/esm/src/index.d.ts",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"volta": {
|
|
74
74
|
"extends": "../../package.json"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "fab9413bf2e3420f1d15763cda2d9cf8569080b4"
|
|
77
77
|
}
|
|
@@ -412,10 +412,12 @@ export type IShippingItem = {
|
|
|
412
412
|
};
|
|
413
413
|
|
|
414
414
|
export type IStoreB2B = {
|
|
415
|
+
contractName?: Maybe<Scalars['String']>;
|
|
415
416
|
customerId: Scalars['String'];
|
|
416
417
|
firstName?: Maybe<Scalars['String']>;
|
|
417
418
|
isRepresentative?: Maybe<Scalars['Boolean']>;
|
|
418
419
|
lastName?: Maybe<Scalars['String']>;
|
|
420
|
+
organizationManager?: Maybe<Scalars['Boolean']>;
|
|
419
421
|
savedPostalCode?: Maybe<Scalars['String']>;
|
|
420
422
|
unitId?: Maybe<Scalars['String']>;
|
|
421
423
|
unitName?: Maybe<Scalars['String']>;
|
|
@@ -1178,10 +1180,12 @@ export type StoreAuthor = {
|
|
|
1178
1180
|
|
|
1179
1181
|
export type StoreB2B = {
|
|
1180
1182
|
__typename?: 'StoreB2B';
|
|
1183
|
+
contractName?: Maybe<Scalars['String']>;
|
|
1181
1184
|
customerId: Scalars['String'];
|
|
1182
1185
|
firstName?: Maybe<Scalars['String']>;
|
|
1183
1186
|
isRepresentative?: Maybe<Scalars['Boolean']>;
|
|
1184
1187
|
lastName?: Maybe<Scalars['String']>;
|
|
1188
|
+
organizationManager?: Maybe<Scalars['Boolean']>;
|
|
1185
1189
|
savedPostalCode?: Maybe<Scalars['String']>;
|
|
1186
1190
|
unitId?: Maybe<Scalars['String']>;
|
|
1187
1191
|
unitName?: Maybe<Scalars['String']>;
|
|
@@ -426,7 +426,7 @@ export const VtexCommerce = (
|
|
|
426
426
|
|
|
427
427
|
params.set(
|
|
428
428
|
'items',
|
|
429
|
-
'profile.id,profile.email,profile.firstName,profile.lastName,shopper.firstName,shopper.lastName,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol,authentication.customerId,authentication.storeUserId,authentication.storeUserEmail,authentication.unitId,authentication.unitName,checkout.regionId,public.postalCode'
|
|
429
|
+
'profile.id,profile.email,profile.firstName,profile.lastName,shopper.firstName,shopper.lastName,shopper.organizationManager,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol,authentication.customerId,authentication.storeUserId,authentication.storeUserEmail,authentication.unitId,authentication.unitName,checkout.regionId,public.postalCode'
|
|
430
430
|
)
|
|
431
431
|
|
|
432
432
|
const headers: HeadersInit = withCookie({
|
|
@@ -112,6 +112,20 @@ export const validateSession = async (
|
|
|
112
112
|
const checkout = sessionData?.namespaces.checkout ?? null
|
|
113
113
|
const publicData = sessionData?.namespaces.public ?? null
|
|
114
114
|
|
|
115
|
+
// Fetch contract data for B2B representatives
|
|
116
|
+
let contract = null
|
|
117
|
+
if (isRepresentative && profile?.id?.value) {
|
|
118
|
+
try {
|
|
119
|
+
contract = await clients.commerce.masterData.getContractById({
|
|
120
|
+
contractId: profile.id.value,
|
|
121
|
+
})
|
|
122
|
+
} catch (err) {
|
|
123
|
+
console.error(
|
|
124
|
+
`Error while getting contract data for profile ID (${profile.id.value}).\n`
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
115
129
|
// Set seller only if it's inside a region
|
|
116
130
|
let seller
|
|
117
131
|
if (!!channel.seller && (postalCode || geoCoordinates)) {
|
|
@@ -156,6 +170,8 @@ export const validateSession = async (
|
|
|
156
170
|
`${shopper?.firstName?.value ?? ''} ${shopper?.lastName?.value ?? ''}`.trim(),
|
|
157
171
|
userEmail: authentication?.storeUserEmail.value ?? '',
|
|
158
172
|
savedPostalCode: publicData?.postalCode?.value ?? '',
|
|
173
|
+
contractName: contract?.corporateName ?? '',
|
|
174
|
+
organizationManager: shopper?.organizationManager?.value ?? false,
|
|
159
175
|
}
|
|
160
176
|
: null,
|
|
161
177
|
marketingData,
|
|
@@ -198,6 +198,8 @@ type StoreB2B {
|
|
|
198
198
|
userName: String
|
|
199
199
|
userEmail: String
|
|
200
200
|
savedPostalCode: String
|
|
201
|
+
contractName: String
|
|
202
|
+
organizationManager: Boolean
|
|
201
203
|
}
|
|
202
204
|
|
|
203
205
|
input IStoreB2B {
|
|
@@ -210,6 +212,8 @@ input IStoreB2B {
|
|
|
210
212
|
userName: String
|
|
211
213
|
userEmail: String
|
|
212
214
|
savedPostalCode: String
|
|
215
|
+
contractName: String
|
|
216
|
+
organizationManager: Boolean
|
|
213
217
|
}
|
|
214
218
|
|
|
215
219
|
"""
|