@faststore/api 4.10.1 → 4.10.2
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/index.js +49 -46
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.mjs +1160 -1030
- package/dist/es/index.mjs.map +1 -1
- package/dist/src/__generated__/schema.d.ts +1 -0
- package/dist/src/__generated__/schema.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/commerce/index.d.ts +16 -2
- package/dist/src/platforms/vtex/clients/commerce/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/fetch.d.ts +1 -0
- package/dist/src/platforms/vtex/clients/fetch.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/index.d.ts +3 -3
- package/dist/src/platforms/vtex/clients/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/search/index.d.ts +7 -1
- package/dist/src/platforms/vtex/clients/search/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/index.d.ts +1 -1
- package/dist/src/platforms/vtex/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/loaders/sku.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/getOrderEntryOperation.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/index.d.ts +1 -1
- package/dist/src/platforms/vtex/resolvers/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/query.d.ts +1 -1
- package/dist/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/subscribeToNewsletter.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/validateSession.d.ts.map +1 -1
- package/dist/src/platforms/vtex/utils/contractAssortment.d.ts +22 -0
- package/dist/src/platforms/vtex/utils/contractAssortment.d.ts.map +1 -0
- package/dist/src/platforms/vtex/utils/intelligentSearchRequest.d.ts +5 -0
- package/dist/src/platforms/vtex/utils/intelligentSearchRequest.d.ts.map +1 -1
- package/dist/src/platforms/vtex/utils/validateSessionHelpers.d.ts +29 -2
- package/dist/src/platforms/vtex/utils/validateSessionHelpers.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__generated__/schema.ts +1 -0
- package/src/platforms/vtex/clients/commerce/index.ts +80 -3
- package/src/platforms/vtex/clients/fetch.ts +52 -1
- package/src/platforms/vtex/clients/search/index.ts +13 -1
- package/src/platforms/vtex/loaders/sku.ts +1 -0
- package/src/platforms/vtex/resolvers/query.ts +51 -37
- package/src/platforms/vtex/resolvers/subscribeToNewsletter.ts +28 -1
- package/src/platforms/vtex/resolvers/validateSession.ts +3 -3
- package/src/platforms/vtex/typeDefs/session.graphql +3 -0
- package/src/platforms/vtex/utils/contractAssortment.ts +87 -0
- package/src/platforms/vtex/utils/intelligentSearchRequest.ts +10 -0
- package/src/platforms/vtex/utils/validateSessionHelpers.ts +47 -5
|
@@ -6,7 +6,7 @@ export declare const getClients: (options: Options, ctx: GraphqlContext) => {
|
|
|
6
6
|
facets: (args: Omit<import('./search').SearchArgs, "type">) => Promise<import('./search/types/FacetSearchResult').FacetSearchResult>;
|
|
7
7
|
products: (args: Omit<import('./search').SearchArgs, "type">) => Promise<import('./search/types/ProductSearchResult').ProductSearchResult>;
|
|
8
8
|
fetchProduct: ({ field, value, hideUnavailableItems: hideUnavailable, showInvisibleItems, }: import('./search').FetchProductArgs) => Promise<import('./search/types/ProductSearchResult').Product>;
|
|
9
|
-
productsByIdentifier: ({ field, values, showInvisibleItems, hideUnavailableItems: hideUnavailable, }: import('./search').ProductsByIdentifierArgs) => Promise<import('./search/types/ProductSearchResult').Product[]>;
|
|
9
|
+
productsByIdentifier: ({ field, values, showInvisibleItems, hideUnavailableItems: hideUnavailable, throwOnUpstreamError, }: import('./search').ProductsByIdentifierArgs) => Promise<import('./search/types/ProductSearchResult').Product[]>;
|
|
10
10
|
suggestedTerms: (args: Omit<import('./search').SearchArgs, "type">) => Promise<import('./search/types/ProductSearchResult').Suggestion>;
|
|
11
11
|
topSearches: () => Promise<import('./search/types/ProductSearchResult').Suggestion>;
|
|
12
12
|
productCount: (args: Omit<import('./search').SearchArgs, "type" | "page" | "count" | "sort">) => Promise<import('./search/types/ProductCountResult').ProductCountResult>;
|
|
@@ -83,8 +83,8 @@ export declare const getClients: (options: Options, ctx: GraphqlContext) => {
|
|
|
83
83
|
storeFront: {
|
|
84
84
|
attachedContracts: (orgUnitId: string) => Promise<import('./commerce/types/StoreFrontContracts').AttachedContractsResponse>;
|
|
85
85
|
};
|
|
86
|
-
subscribeToNewsletter: (
|
|
87
|
-
name
|
|
86
|
+
subscribeToNewsletter: ({ name, email, }: {
|
|
87
|
+
name?: string;
|
|
88
88
|
email: string;
|
|
89
89
|
}) => Promise<import('./commerce/types/Newsletter').MasterDataResponse>;
|
|
90
90
|
profile: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/clients/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAKvD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAA;AAEnD,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,EAAE,KAAK,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/clients/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAKvD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAA;AAEnD,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,EAAE,KAAK,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAW2wT,CAAC;;;;;;;;;4BAAmxC,CAAC;;;;;;;;;;;;kBAA+kF,CAAC;mCAAoC,CAAC;uBAAyB,CAAC;oCAA4U,CAAC;;;;;;;;iCAAquD,CAAC;4BAAoC,CAAC;+BAAgC,CAAC;;;;;;;;;;;;;;;;;gBAA86K,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAA2te,CAAC;;;;;;;;;uBAAkwB,CAAC;4BAA6B,CAAC;;4BAAqD,CAAC;;;;;;;;;;;;;;;;;;;;;CADz0qC,CAAA"}
|
|
@@ -35,6 +35,12 @@ export interface ProductsByIdentifierArgs {
|
|
|
35
35
|
values: string[];
|
|
36
36
|
showInvisibleItems?: boolean;
|
|
37
37
|
hideUnavailableItems?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Rethrow upstream failures (5xx, timeouts, network) instead of dropping the
|
|
40
|
+
* product, so callers can tell a failure from a product that does not exist.
|
|
41
|
+
* A not-found answer is still dropped.
|
|
42
|
+
*/
|
|
43
|
+
throwOnUpstreamError?: boolean;
|
|
38
44
|
}
|
|
39
45
|
export interface PickupPointAvailabilityArgs {
|
|
40
46
|
postalCode?: string;
|
|
@@ -67,7 +73,7 @@ export declare const IntelligentSearch: ({ account, environment, hideUnavailable
|
|
|
67
73
|
facets: (args: Omit<SearchArgs, "type">) => Promise<FacetSearchResult>;
|
|
68
74
|
products: (args: Omit<SearchArgs, "type">) => Promise<ProductSearchResult>;
|
|
69
75
|
fetchProduct: ({ field, value, hideUnavailableItems: hideUnavailable, showInvisibleItems, }: FetchProductArgs) => Promise<Product>;
|
|
70
|
-
productsByIdentifier: ({ field, values, showInvisibleItems, hideUnavailableItems: hideUnavailable, }: ProductsByIdentifierArgs) => Promise<Product[]>;
|
|
76
|
+
productsByIdentifier: ({ field, values, showInvisibleItems, hideUnavailableItems: hideUnavailable, throwOnUpstreamError, }: ProductsByIdentifierArgs) => Promise<Product[]>;
|
|
71
77
|
suggestedTerms: (args: Omit<SearchArgs, "type">) => Promise<Suggestion>;
|
|
72
78
|
topSearches: () => Promise<Suggestion>;
|
|
73
79
|
productCount: (args: Omit<SearchArgs, "type" | "page" | "count" | "sort">) => Promise<ProductCountResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/platforms/vtex/clients/search/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/platforms/vtex/clients/search/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAG5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,IAAI,EACV,MAAM,sCAAsC,CAAA;AAE7C,OAAO,KAAK,EACV,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EACnB,UAAU,EACX,MAAM,6BAA6B,CAAA;AAEpC,YAAY,EACV,sBAAsB,EACtB,IAAI,GACL,MAAM,sCAAsC,CAAA;AAM7C,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,gBAAgB,GAAG,QAAQ,GAAG,oBAAoB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,IAAI,CAAC,EAAE,MAAM,CAAA;YACb,KAAK,CAAC,EAAE,MAAM,CAAA;YACd,MAAM,CAAC,EAAE,MAAM,CAAA;YACf,MAAM,CAAC,EAAE,MAAM,CAAA;YACf,UAAU,CAAC,EAAE,MAAM,CAAA;YACnB,YAAY,CAAC,EAAE,MAAM,CAAA;SACtB,CAAA;QACD,aAAa,CAAC,EAAE,KAAK,CAAC;YACpB,SAAS,CAAC,EAAE,MAAM,CAAA;YAClB,WAAW,CAAC,EAAE,MAAM,CAAA;YACpB,WAAW,CAAC,EAAE,MAAM,CAAA;SACrB,CAAC,CAAA;KACH,CAAC,CAAA;CACH;AAED,eAAO,MAAM,cAAc,GACzB,OAAO,KAAK,KACX,KAAK,IAAI,KAAK,CAAC,iBAAiB,CAA0B,CAAA;AA8B7D,eAAO,MAAM,iBAAiB,GAC5B,qGAOG,OAAO,EACV,KAAK,cAAc;mBAyIG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;qBA3FtB,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;iGAQ7C,gBAAgB,KAAG,OAAO,CAAC,OAAO,CAAC;gIAyBnC,wBAAwB,KAAG,OAAO,CAAC,OAAO,EAAE,CAAC;2BA8BxC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,KAC7B,OAAO,CAAC,UAAU,CAAC;uBAcE,OAAO,CAAC,UAAU,CAAC;yBAqCnC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,KACzD,OAAO,CAAC,kBAAkB,CAAC;qEAlB3B,2BAA2B,KAAG,OAAO,CAAC,6BAA6B,CAAC;CA0CxE,CAAA"}
|
|
@@ -240,7 +240,7 @@ export declare function getResolvers(): {
|
|
|
240
240
|
accountProfile: (_: unknown, __: unknown, ctx: GraphqlContext) => Promise<{
|
|
241
241
|
name: string;
|
|
242
242
|
email: string;
|
|
243
|
-
id:
|
|
243
|
+
id: string;
|
|
244
244
|
} | null>;
|
|
245
245
|
availableContracts: (_: unknown, { orgUnitId }: import('../..').QueryAvailableContractsArgs, ctx: GraphqlContext) => Promise<import('../..').StoreContract[]>;
|
|
246
246
|
pickupPoints: (_: unknown, { geoCoordinates, postalCode, country, channel }: import('../..').QueryPickupPointsArgs, ctx: GraphqlContext) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/platforms/vtex/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,SAAS,CAAA;AAKtD,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAG9C,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB;;;;;SAKK;IACL,OAAO,EAAE;QACP,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC1B,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,YAAY,CAAA;QACnB,+EAA+E;QAC/E,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACrC,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QACrC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;QAC5C;;;;;WAKG;QACH,wBAAwB,CAAC,EAAE,GAAG,CAC5B,MAAM,EAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAAqyiB,CAAC;mBAAsB,CAAC;kBAAqB,CAAC;yBAA8B,CAAC;uBAA0B,CAAC;yBAA4B,CAAC;uBAA0B,CAAC;iBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAxDtqkB,CAAC;yBAAoB,CAAC;0BAAqB,CAAC;0BAE3C,CAAC;8BACN,CAAF;gCAA2B,CAAC;;;6BACc,CAAC;+BACxB,CAAC;+BAA0B,CAAC;;;;;;;;;;;wBAmDggkC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAlBjjkC;AAED,wBAAgB,iBAAiB,CAAC,WAAW,CAAC,EAAE,aAAa,iBAe5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sku.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/loaders/sku.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAGvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAGtD,eAAO,MAAM,YAAY,GAAI,WAAW,OAAO,EAAE,SAAS,OAAO,
|
|
1
|
+
{"version":3,"file":"sku.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/loaders/sku.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAGvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAGtD,eAAO,MAAM,YAAY,GAAI,WAAW,OAAO,EAAE,SAAS,OAAO,4CA2ChE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOrderEntryOperation.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/getOrderEntryOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAGjF,eAAO,MAAM,sBAAsB,GACjC,GAAG,OAAO,EACV,iBAAiB,4BAA4B,EAC7C,2BAA2B,cAAc;;;;;;
|
|
1
|
+
{"version":3,"file":"getOrderEntryOperation.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/getOrderEntryOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAGjF,eAAO,MAAM,sBAAsB,GACjC,GAAG,OAAO,EACV,iBAAiB,4BAA4B,EAC7C,2BAA2B,cAAc;;;;;;gBAQ42qC,CAAC;;;EADv5qC,CAAA"}
|
|
@@ -199,7 +199,7 @@ export declare const getResolvers: () => {
|
|
|
199
199
|
accountProfile: (_: unknown, __: unknown, ctx: import('..').GraphqlContext) => Promise<{
|
|
200
200
|
name: string;
|
|
201
201
|
email: string;
|
|
202
|
-
id:
|
|
202
|
+
id: string;
|
|
203
203
|
} | null>;
|
|
204
204
|
availableContracts: (_: unknown, { orgUnitId }: import('../../..').QueryAvailableContractsArgs, ctx: import('..').GraphqlContext) => Promise<import('../../..').StoreContract[]>;
|
|
205
205
|
pickupPoints: (_: unknown, { geoCoordinates, postalCode, country, channel }: import('../../..').QueryPickupPointsArgs, ctx: import('..').GraphqlContext) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/index.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,YAAY;;;;;;oJAC6uG,mCAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/index.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,YAAY;;;;;;oJAC6uG,mCAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAAqyiB,CAAC;mBAAsB,CAAC;kBAAqB,CAAC;yBAA8B,CAAC;uBAA0B,CAAC;yBAA4B,CAAC;uBAA0B,CAAC;iBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAAznnB,CAAC;yBAAoB,CAAC;0BAAqB,CAAC;0BAAqB,CAAC;8BAAyB,CAAC;gCAA2B,CAAC;;;6BAA0D,CAAC;+BAA0B,CAAC;+BAA0B,CAAC;;;;;;;;;;;wBAAmxmC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CADpkpC,CAAA"}
|
|
@@ -159,7 +159,7 @@ export declare const Query: {
|
|
|
159
159
|
accountProfile: (_: unknown, __: unknown, ctx: GraphqlContext) => Promise<{
|
|
160
160
|
name: string;
|
|
161
161
|
email: string;
|
|
162
|
-
id:
|
|
162
|
+
id: string;
|
|
163
163
|
} | null>;
|
|
164
164
|
availableContracts: (_: unknown, { orgUnitId }: QueryAvailableContractsArgs, ctx: GraphqlContext) => Promise<StoreContract[]>;
|
|
165
165
|
pickupPoints: (_: unknown, { geoCoordinates, postalCode, country, channel }: QueryPickupPointsArgs, ctx: GraphqlContext) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAElB,aAAa,EAEd,MAAM,+BAA+B,CAAA;AAUtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,E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AO,OAAO,cAAc;wBA0BlE,OAAO,WACD;QACP,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;QACjB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,OACI,cAAc;;;;;;;;;;;;;;;;sBAoDG,OAAO,MAAM,OAAO,QAAQ,cAAc;;;8BAQ7D,OAAO,MACN,OAAO,OACN,cAAc;qBAWE,OAAO,MAAM,OAAO,OAAO,cAAc;;;;;;;;wBAqCtC,OAAO,MAAM,OAAO,OAAO,cAAc;;;;;4BA0E9D,OAAO,iBACK,2BAA2B,OACrC,cAAc,KAClB,OAAO,CAAC,aAAa,EAAE,CAAC;sBA4DtB,OAAO,oDACwC,qBAAqB,OAClE,cAAc;;;;;;;oBA57BmB,CAAC;qBAAoB,CAAC;sBAC3D,CAAC;sBAAqB,CAAC;0BAAyB,CAAC;4BAClD,CAAC;;;yBAA0D,CAAC;2BACrD,CAAC;2BAA2B,CAAA;;;;;;;;;;;oBAu9BguQ,CAAC;;;;;;;;;;;;;;;;;;;;CADvwQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribeToNewsletter.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/subscribeToNewsletter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EACV,iCAAiC,EACjC,gBAAgB,EACjB,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"subscribeToNewsletter.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/subscribeToNewsletter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EACV,iCAAiC,EACjC,gBAAgB,EACjB,MAAM,+BAA+B,CAAA;AAStC,eAAO,MAAM,qBAAqB,GAChC,GAAG,GAAG,EACN,UAAU,iCAAiC,EAC3C,2BAA2B,cAAc,KACxC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAuBjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateSession.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/validateSession.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EACV,2BAA2B,EAC3B,YAAY,EACb,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"validateSession.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/resolvers/validateSession.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EACV,2BAA2B,EAC3B,YAAY,EACb,MAAM,+BAA+B,CAAA;AAuItC,eAAO,MAAM,eAAe,GAC1B,GAAG,GAAG,EACN,iCAAiC,2BAA2B,EAC5D,yDAAyD,cAAc,KACtE,OAAO,CAAC,YAAY,GAAG,IAAI,CA+I7B,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ProductCluster } from '../clients/search/types/ProductSearchResult';
|
|
2
|
+
import { GraphqlContext } from '../index';
|
|
3
|
+
import { EnhancedSku } from './enhanceSku';
|
|
4
|
+
export interface ProductClusterRestriction {
|
|
5
|
+
allowed: Set<string>;
|
|
6
|
+
excluded: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Collections the shopper's assortment is restricted to, as carried by the
|
|
10
|
+
* `vtex_segment` cookie (`productClusterIds=X` allows, `productClusterIds=not:Y`
|
|
11
|
+
* excludes). Returns `null` when the segment carries no restriction.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getProductClusterRestriction(segment: Record<string, unknown>): ProductClusterRestriction | null;
|
|
14
|
+
export declare function isProductInAssortment(productClusters: ProductCluster[] | undefined, { allowed, excluded }: ProductClusterRestriction): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Listing endpoints get the assortment applied by Intelligent Search through
|
|
17
|
+
* the segment facets, but the `products` endpoint used to fetch a single
|
|
18
|
+
* product does not, so a product outside the shopper's assortment must be
|
|
19
|
+
* rejected here.
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertProductInContractAssortment(ctx: GraphqlContext, sku: EnhancedSku): void;
|
|
22
|
+
//# sourceMappingURL=contractAssortment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractAssortment.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/utils/contractAssortment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAS/C,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CACtB;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,yBAAyB,GAAG,IAAI,CAwBlC;AAED,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,cAAc,EAAE,GAAG,SAAS,EAC7C,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,yBAAyB,GAC/C,OAAO,CAQT;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,WAAW,GACf,IAAI,CAcN"}
|
|
@@ -50,6 +50,11 @@ export interface IntelligentSearchRequest {
|
|
|
50
50
|
* Returns an empty object when the cookie is absent or invalid.
|
|
51
51
|
*/
|
|
52
52
|
export declare function parseSegmentCookie(cookieHeader?: string): Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* Non-shipping facets carried by the `vtex_segment` cookie (e.g. the B2B
|
|
55
|
+
* contract's `productClusterIds`), in the order they appear in the cookie.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getSegmentExtraFacets(segment: Record<string, unknown>): IntelligentSearchFacet[];
|
|
53
58
|
/**
|
|
54
59
|
* Pure builder for intelligent-search v1 path + query params.
|
|
55
60
|
* Callers assemble the full URL: `/api/intelligent-search/v1/${endpoint}/${request.path}?${request.params}`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intelligentSearchRequest.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/utils/intelligentSearchRequest.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd;AA6BD,MAAM,MAAM,IAAI,GACZ,YAAY,GACZ,WAAW,GACX,aAAa,GACb,WAAW,GACX,UAAU,GACV,cAAc,GACd,eAAe,GACf,EAAE,GAIF,GAAG,MAAM,IAAI,KAAK,GAAG,MAAM,EAAE,CAAA;AAEjC,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,GAAG,KAAK,CAAA;AAEhF,MAAM,MAAM,yBAAyB,GACjC,gBAAgB,GAChB,QAAQ,GACR,eAAe,GACf,UAAU,GACV,oBAAoB,GACpB,cAAc,GACd,2BAA2B,CAAA;AAE/B,MAAM,WAAW,yBAAyB;IACxC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAA;I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,CAAC,CAmBzB;
|
|
1
|
+
{"version":3,"file":"intelligentSearchRequest.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/utils/intelligentSearchRequest.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd;AA6BD,MAAM,MAAM,IAAI,GACZ,YAAY,GACZ,WAAW,GACX,aAAa,GACb,WAAW,GACX,UAAU,GACV,cAAc,GACd,eAAe,GACf,EAAE,GAIF,GAAG,MAAM,IAAI,KAAK,GAAG,MAAM,EAAE,CAAA;AAEjC,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,GAAG,KAAK,CAAA;AAEhF,MAAM,MAAM,yBAAyB,GACjC,gBAAgB,GAChB,QAAQ,GACR,eAAe,GACf,UAAU,GACV,oBAAoB,GACpB,cAAc,GACd,2BAA2B,CAAA;AAE/B,MAAM,WAAW,yBAAyB;IACxC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,kBAAkB,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;IAClD,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,cAAc,CAAC,EAAE,sBAAsB,EAAE,CAAA;IACzC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,sBAAsB,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,yBAAyB,CAAA;IACnC,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,QAAQ,CAAC,EAAE,yBAAyB,CAAA;IACpC,IAAI,CAAC,EAAE,4BAA4B,CAAA;CACpC;AAED,MAAM,WAAW,wBAAwB;IACvC,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,IAAI,MAAM,CAAA;CACnB;AAwCD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBzB;AA6DD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,sBAAsB,EAAE,CAE1B;AAqbD;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,6BAA6B,GACnC,wBAAwB,CAkE1B"}
|
|
@@ -12,13 +12,37 @@ export declare function getPreciseLocationData(clients: GraphqlContext['clients'
|
|
|
12
12
|
export declare function buildSessionSearchParams(search: string, channel: Required<Channel>, postalCode: string, country: string, geoCoordinates: StoreSession['geoCoordinates'], locale: string): URLSearchParams;
|
|
13
13
|
export declare function buildMarketingData(params: URLSearchParams, oldMarketingData: StoreSession['marketingData']): StoreMarketingData;
|
|
14
14
|
export declare function resolveJwtClaims(clients: GraphqlContext['clients'], cookie: string | undefined, account: string): Promise<{
|
|
15
|
-
isRepresentative: boolean;
|
|
16
15
|
customerId: any;
|
|
17
16
|
unitId: any;
|
|
18
17
|
}>;
|
|
19
18
|
export declare function resolveSellerInRegion(clients: GraphqlContext['clients'], channel: Required<Channel>, postalCode: string, geoCoordinates: StoreSession['geoCoordinates'], country: string, salesChannel: string): Promise<string | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* First value that is a non-blank string, trimmed. Session values and JWT
|
|
21
|
+
* claims are only nominally typed, so anything else is skipped.
|
|
22
|
+
*/
|
|
23
|
+
export declare function firstNonBlank(...values: unknown[]): string;
|
|
24
|
+
/**
|
|
25
|
+
* Organizational unit of the shopper, from the session or the JWT claim.
|
|
26
|
+
* Buyer Portal identifies its buyers by the unit; `isRepresentative` alone is
|
|
27
|
+
* not enough, since it can be true outside B2B.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveB2bUnitId(authentication: {
|
|
30
|
+
unitId?: {
|
|
31
|
+
value?: string | null;
|
|
32
|
+
} | null;
|
|
33
|
+
} | null, jwtUnitId?: unknown): string;
|
|
34
|
+
/**
|
|
35
|
+
* Returns `null` unless the shopper has both an organizational unit and a
|
|
36
|
+
* contract, the rule Buyer Portal uses for a B2B session.
|
|
37
|
+
*
|
|
38
|
+
* The contract falls back from the session's active contract to the session's
|
|
39
|
+
* authentication namespace and then to the JWT claim. Blank values fall
|
|
40
|
+
* through, so an empty session value never hides the claim.
|
|
41
|
+
*
|
|
42
|
+
* The deprecated `isRepresentative` field stays `true` whenever `b2b` is
|
|
43
|
+
* returned, so consumers that still read it keep working.
|
|
44
|
+
*/
|
|
20
45
|
export declare function buildB2bSession(args: {
|
|
21
|
-
isRepresentative: boolean;
|
|
22
46
|
authentication: {
|
|
23
47
|
customerId?: {
|
|
24
48
|
value?: string | null;
|
|
@@ -43,6 +67,9 @@ export declare function buildB2bSession(args: {
|
|
|
43
67
|
organizationManager?: {
|
|
44
68
|
value?: boolean | null;
|
|
45
69
|
} | null;
|
|
70
|
+
activeContractId?: {
|
|
71
|
+
value?: string | null;
|
|
72
|
+
} | null;
|
|
46
73
|
} | null;
|
|
47
74
|
publicData: {
|
|
48
75
|
postalCode?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateSessionHelpers.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/utils/validateSessionHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACb,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAA;AAG7D,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,EAClC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM;;;;;;GAuBnB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,YAAY,CAAC,gBAAgB,CAAC,EAC9C,MAAM,EAAE,MAAM,mBA8Bf;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,gBAAgB,EAAE,YAAY,CAAC,eAAe,CAAC,GAC9C,kBAAkB,CAUpB;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,EAClC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"validateSessionHelpers.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/vtex/utils/validateSessionHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;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CAAC,CAAC,CAAC,CAAA;IAChE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;;;;;;;;;;;;SA4BA;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE;IACP,EAAE,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;IACrC,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;IACxC,SAAS,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;CAC5C,GAAG,IAAI;;;;;SAYT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"vite": "7.1.5",
|
|
59
59
|
"vite-plugin-dts": "4.5.4",
|
|
60
60
|
"vitest": "4.0.18",
|
|
61
|
-
"@faststore/diagnostics": "^4.10.
|
|
61
|
+
"@faststore/diagnostics": "^4.10.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"graphql": "16.11.0",
|
|
65
|
-
"@faststore/diagnostics": "4.10.
|
|
65
|
+
"@faststore/diagnostics": "4.10.2"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
@@ -1360,6 +1360,7 @@ export type StoreB2B = {
|
|
|
1360
1360
|
contractName?: Maybe<Scalars['String']['output']>;
|
|
1361
1361
|
customerId: Scalars['String']['output'];
|
|
1362
1362
|
firstName?: Maybe<Scalars['String']['output']>;
|
|
1363
|
+
/** @deprecated Always true when `b2b` is set: a B2B session is identified by `unitId` and `customerId`. Check that `b2b` is not null instead. Scheduled for removal in the next major. */
|
|
1363
1364
|
isRepresentative?: Maybe<Scalars['Boolean']['output']>;
|
|
1364
1365
|
lastName?: Maybe<Scalars['String']['output']>;
|
|
1365
1366
|
organizationManager?: Maybe<Scalars['Boolean']['output']>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parse } from 'cookie'
|
|
2
2
|
import type { Options } from '../../../../typings/globals'
|
|
3
3
|
import type { FACET_CROSS_SELLING_MAP } from '../../utils/facets'
|
|
4
|
+
import { OTELLogger } from '../../../../observability/telemetry'
|
|
4
5
|
import { fetchAPI } from '../fetch'
|
|
5
6
|
|
|
6
7
|
import {
|
|
@@ -82,6 +83,19 @@ const BASE_INIT = {
|
|
|
82
83
|
},
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
// Accounts already warned that they rely on public `NL` fields. The commerce
|
|
87
|
+
// client is created per request, so the warning is kept once per account
|
|
88
|
+
// instead of per instance, to avoid flooding the logs. The account comes from
|
|
89
|
+
// the store's API options, not from the request, so the set holds at most one
|
|
90
|
+
// entry per account the process is configured for (usually one). It's still
|
|
91
|
+
// capped, so it can't grow without bound if that ever changes.
|
|
92
|
+
const MAX_WARNED_NEWSLETTER_ACCOUNTS = 100
|
|
93
|
+
const accountsWarnedAboutAnonymousNewsletter = new Set<string>()
|
|
94
|
+
|
|
95
|
+
/** Test-only: forget which accounts were warned about the anonymous fallback. */
|
|
96
|
+
export const resetAnonymousNewsletterWarnings = () =>
|
|
97
|
+
accountsWarnedAboutAnonymousNewsletter.clear()
|
|
98
|
+
|
|
85
99
|
/**
|
|
86
100
|
* Encode a by-linkid path for the category endpoint. Category link paths can be
|
|
87
101
|
* multi-segment (e.g. "computer---software/eletronicos"); the Catalog endpoint
|
|
@@ -673,15 +687,78 @@ export const VtexCommerce = (
|
|
|
673
687
|
)
|
|
674
688
|
},
|
|
675
689
|
},
|
|
676
|
-
|
|
677
|
-
|
|
690
|
+
/**
|
|
691
|
+
* Creates a newsletter subscription in the `NL` Master Data entity.
|
|
692
|
+
*
|
|
693
|
+
* With `FS_NEWSLETTER_APP_KEY`/`FS_NEWSLETTER_APP_TOKEN` set, the document is
|
|
694
|
+
* created with a `POST` authenticated by that dedicated key, so `NL` fields
|
|
695
|
+
* can stay private. The request is create-only: the body is built here from
|
|
696
|
+
* the validated fields and never carries a document id, so the caller can't
|
|
697
|
+
* reach an existing record.
|
|
698
|
+
*
|
|
699
|
+
* Without the credentials, it falls back to the legacy anonymous `PATCH`,
|
|
700
|
+
* which only works while `NL` fields are public.
|
|
701
|
+
*/
|
|
702
|
+
subscribeToNewsletter: ({
|
|
703
|
+
name,
|
|
704
|
+
email,
|
|
705
|
+
}: {
|
|
706
|
+
name?: string
|
|
678
707
|
email: string
|
|
679
708
|
}): Promise<MasterDataResponse> => {
|
|
709
|
+
const body = JSON.stringify({
|
|
710
|
+
...(name ? { name } : {}),
|
|
711
|
+
email,
|
|
712
|
+
isNewsletterOptIn: true,
|
|
713
|
+
})
|
|
714
|
+
// Use a key dedicated to the newsletter, whose role has only the Dynamic
|
|
715
|
+
// Storage "Insert or update document (not remove)" resource. Master Data
|
|
716
|
+
// permissions aren't scoped by entity, so never reuse a key that serves
|
|
717
|
+
// other features, and rotate it like any other secret. Setup steps:
|
|
718
|
+
// https://developers.vtex.com/docs/guides/faststore/organisms-newsletter#setting-up-newsletter-subscriptions
|
|
719
|
+
const appKey = process.env.FS_NEWSLETTER_APP_KEY
|
|
720
|
+
const appToken = process.env.FS_NEWSLETTER_APP_TOKEN
|
|
721
|
+
|
|
722
|
+
if (appKey && appToken) {
|
|
723
|
+
return fetchAPI(`${base}/api/dataentities/NL/documents`, {
|
|
724
|
+
method: 'POST',
|
|
725
|
+
headers: {
|
|
726
|
+
'content-type': 'application/json',
|
|
727
|
+
accept: 'application/json',
|
|
728
|
+
'X-VTEX-API-AppKey': appKey,
|
|
729
|
+
'X-VTEX-API-AppToken': appToken,
|
|
730
|
+
},
|
|
731
|
+
body,
|
|
732
|
+
})
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (!accountsWarnedAboutAnonymousNewsletter.has(account)) {
|
|
736
|
+
if (
|
|
737
|
+
accountsWarnedAboutAnonymousNewsletter.size >=
|
|
738
|
+
MAX_WARNED_NEWSLETTER_ACCOUNTS
|
|
739
|
+
) {
|
|
740
|
+
accountsWarnedAboutAnonymousNewsletter.clear()
|
|
741
|
+
}
|
|
742
|
+
accountsWarnedAboutAnonymousNewsletter.add(account)
|
|
743
|
+
|
|
744
|
+
// Name only the missing variables, so a partial setup is easy to spot.
|
|
745
|
+
const missing = [
|
|
746
|
+
!appKey && 'FS_NEWSLETTER_APP_KEY',
|
|
747
|
+
!appToken && 'FS_NEWSLETTER_APP_TOKEN',
|
|
748
|
+
].filter(Boolean)
|
|
749
|
+
const message = `[subscribeToNewsletter] ${missing.join(' and ')} ${missing.length > 1 ? 'are' : 'is'} not set. Falling back to an anonymous Master Data request, which requires public fields in the NL entity. Configure both credentials and make the NL fields private.`
|
|
750
|
+
|
|
751
|
+
// Also sent to OpenTelemetry logs, so a missing credential reaches
|
|
752
|
+
// operators and not only stdout.
|
|
753
|
+
console.warn(message)
|
|
754
|
+
OTELLogger('warn', '%s', message)
|
|
755
|
+
}
|
|
756
|
+
|
|
680
757
|
return fetchAPI(
|
|
681
758
|
`${base}/api/dataentities/NL/documents/`,
|
|
682
759
|
{
|
|
683
760
|
...BASE_INIT,
|
|
684
|
-
body
|
|
761
|
+
body,
|
|
685
762
|
method: 'PATCH',
|
|
686
763
|
},
|
|
687
764
|
{ storeCookies }
|
|
@@ -14,6 +14,41 @@ interface FetchAPIOptions {
|
|
|
14
14
|
storeCookies?: (headers: Headers) => void
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// Headers that may carry credentials: store API keys (`X-VTEX-API-AppKey`,
|
|
18
|
+
// `X-VTEX-API-AppToken`), shopper cookies (`Cookie`, `Set-Cookie`,
|
|
19
|
+
// `VtexIdclientAutCookie_*`), `Authorization`, and generic token, secret or
|
|
20
|
+
// API key headers. They are replaced before a failed request and its response
|
|
21
|
+
// are logged. Matched by substring so new credential headers are covered too.
|
|
22
|
+
const SENSITIVE_HEADER = /authorization|cookie|token|secret|api-?key|appkey/i
|
|
23
|
+
|
|
24
|
+
const REDACTED = '[redacted]'
|
|
25
|
+
|
|
26
|
+
export const redactHeaders = (
|
|
27
|
+
headers?: HeadersInit
|
|
28
|
+
): Record<string, string> | undefined => {
|
|
29
|
+
if (!headers) {
|
|
30
|
+
return undefined
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const redacted: Record<string, string> = {}
|
|
34
|
+
const add = (name: string, value: string) => {
|
|
35
|
+
redacted[name] = SENSITIVE_HEADER.test(name) ? REDACTED : value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (Array.isArray(headers)) {
|
|
39
|
+
headers.forEach(([name, value]) => add(name, value))
|
|
40
|
+
} else if (typeof (headers as Headers).forEach === 'function') {
|
|
41
|
+
// Matches both the global `Headers` and the polyfill returned by
|
|
42
|
+
// `isomorphic-unfetch` on Node, which isn't an instance of the global one.
|
|
43
|
+
const headerList = headers as Headers
|
|
44
|
+
headerList.forEach((value, name) => add(name, value))
|
|
45
|
+
} else {
|
|
46
|
+
Object.entries(headers).forEach(([name, value]) => add(name, value))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return redacted
|
|
50
|
+
}
|
|
51
|
+
|
|
17
52
|
export const fetchAPI = async (
|
|
18
53
|
info: RequestInfo,
|
|
19
54
|
init?: RequestInit,
|
|
@@ -35,7 +70,23 @@ export const fetchAPI = async (
|
|
|
35
70
|
return response.status !== 204 ? response.json() : undefined
|
|
36
71
|
}
|
|
37
72
|
|
|
38
|
-
|
|
73
|
+
// Log a summary instead of the raw Response, whose headers may include
|
|
74
|
+
// `Set-Cookie` with shopper credentials. The request body is omitted because
|
|
75
|
+
// it can carry personal data (e.g. the newsletter email and name).
|
|
76
|
+
console.error(
|
|
77
|
+
// Only the URL: a `Request` instance could carry unredacted headers.
|
|
78
|
+
typeof info === 'string' ? info : info.url,
|
|
79
|
+
init && {
|
|
80
|
+
...init,
|
|
81
|
+
headers: redactHeaders(init.headers),
|
|
82
|
+
body: init.body ? REDACTED : undefined,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
status: response.status,
|
|
86
|
+
statusText: response.statusText,
|
|
87
|
+
headers: redactHeaders(response.headers),
|
|
88
|
+
}
|
|
89
|
+
)
|
|
39
90
|
const text = await response.text()
|
|
40
91
|
|
|
41
92
|
// Check if response has a valid status property
|
|
@@ -2,6 +2,7 @@ import pLimit from 'p-limit'
|
|
|
2
2
|
import type { Options } from '../../../../typings/globals'
|
|
3
3
|
|
|
4
4
|
import type { GraphqlContext } from '../../'
|
|
5
|
+
import { isNotFoundError } from '../../../errors'
|
|
5
6
|
import { getWithCookie } from '../../utils/cookies'
|
|
6
7
|
import type { SelectedFacet } from '../../utils/facets'
|
|
7
8
|
import { isLocalizationEnabled } from '../../utils/localization'
|
|
@@ -65,6 +66,12 @@ export interface ProductsByIdentifierArgs {
|
|
|
65
66
|
values: string[]
|
|
66
67
|
showInvisibleItems?: boolean
|
|
67
68
|
hideUnavailableItems?: boolean
|
|
69
|
+
/**
|
|
70
|
+
* Rethrow upstream failures (5xx, timeouts, network) instead of dropping the
|
|
71
|
+
* product, so callers can tell a failure from a product that does not exist.
|
|
72
|
+
* A not-found answer is still dropped.
|
|
73
|
+
*/
|
|
74
|
+
throwOnUpstreamError?: boolean
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
export interface PickupPointAvailabilityArgs {
|
|
@@ -214,6 +221,7 @@ export const IntelligentSearch = (
|
|
|
214
221
|
values,
|
|
215
222
|
showInvisibleItems,
|
|
216
223
|
hideUnavailableItems: hideUnavailable,
|
|
224
|
+
throwOnUpstreamError = false,
|
|
217
225
|
}: ProductsByIdentifierArgs): Promise<Product[]> => {
|
|
218
226
|
const limit = pLimit(PRODUCTS_BY_IDENTIFIER_CONCURRENCY)
|
|
219
227
|
|
|
@@ -227,7 +235,11 @@ export const IntelligentSearch = (
|
|
|
227
235
|
hideUnavailableItems: hideUnavailable,
|
|
228
236
|
showInvisibleItems,
|
|
229
237
|
})
|
|
230
|
-
} catch {
|
|
238
|
+
} catch (error) {
|
|
239
|
+
if (throwOnUpstreamError && !isNotFoundError(error)) {
|
|
240
|
+
throw error
|
|
241
|
+
}
|
|
242
|
+
|
|
231
243
|
return null
|
|
232
244
|
}
|
|
233
245
|
})
|