@faststore/api 1.10.6 → 1.10.18
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 +30 -0
- package/dist/__generated__/schema.d.ts +6 -2
- package/dist/api.cjs.development.js +41 -6
- 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 +41 -6
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/commerce/index.d.ts +4 -2
- package/dist/platforms/vtex/clients/commerce/types/Portal.d.ts +1 -1
- package/dist/platforms/vtex/clients/commerce/types/SalesChannel.d.ts +24 -0
- package/dist/platforms/vtex/clients/index.d.ts +1 -0
- package/dist/platforms/vtex/loaders/index.d.ts +1 -0
- package/dist/platforms/vtex/loaders/salesChannel.d.ts +5 -0
- package/package.json +3 -3
- package/src/__generated__/schema.ts +6 -2
- package/src/platforms/vtex/clients/commerce/index.ts +8 -4
- package/src/platforms/vtex/clients/commerce/types/Portal.ts +8 -1
- package/src/platforms/vtex/clients/commerce/types/SalesChannel.ts +25 -0
- package/src/platforms/vtex/loaders/collection.ts +2 -0
- package/src/platforms/vtex/loaders/index.ts +3 -0
- package/src/platforms/vtex/loaders/salesChannel.ts +15 -0
- package/src/platforms/vtex/resolvers/aggregateOffer.ts +10 -1
- package/src/platforms/vtex/resolvers/offer.ts +10 -1
- package/src/typeDefs/collection.graphql +9 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FACET_CROSS_SELLING_MAP } from
|
|
2
|
-
import type { PortalProduct } from
|
|
1
|
+
import { FACET_CROSS_SELLING_MAP } from '../../utils/facets';
|
|
2
|
+
import type { PortalProduct } from './types/Product';
|
|
3
3
|
import type { Context, Options } from '../../index';
|
|
4
4
|
import type { Brand } from './types/Brand';
|
|
5
5
|
import type { CategoryTree } from './types/CategoryTree';
|
|
@@ -9,9 +9,11 @@ import type { Region, RegionInput } from './types/Region';
|
|
|
9
9
|
import type { Simulation, SimulationArgs, SimulationOptions } from './types/Simulation';
|
|
10
10
|
import type { Session } from './types/Session';
|
|
11
11
|
import type { Channel } from '../../utils/channel';
|
|
12
|
+
import type { SalesChannel } from './types/SalesChannel';
|
|
12
13
|
declare type ValueOf<T> = T extends Record<string, infer K> ? K : never;
|
|
13
14
|
export declare const VtexCommerce: ({ account, environment }: Options, ctx: Context) => {
|
|
14
15
|
catalog: {
|
|
16
|
+
salesChannel: (sc: string) => Promise<SalesChannel>;
|
|
15
17
|
brand: {
|
|
16
18
|
list: () => Promise<Brand[]>;
|
|
17
19
|
};
|
|
@@ -5,7 +5,7 @@ export interface CollectionPageType {
|
|
|
5
5
|
url: string;
|
|
6
6
|
title: string;
|
|
7
7
|
metaTagDescription: string;
|
|
8
|
-
pageType: 'Brand' | 'Category' | 'Department' | '
|
|
8
|
+
pageType: 'Brand' | 'Category' | 'Department' | 'SubCategory' | 'Product' | 'Collection' | 'Cluster';
|
|
9
9
|
}
|
|
10
10
|
export interface FallbackPageType {
|
|
11
11
|
id: null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface SalesChannel {
|
|
2
|
+
Id: number;
|
|
3
|
+
Name: string;
|
|
4
|
+
IsActive: boolean;
|
|
5
|
+
ProductClusterId: null;
|
|
6
|
+
CountryCode: string;
|
|
7
|
+
CultureInfo: string;
|
|
8
|
+
TimeZone: string;
|
|
9
|
+
CurrencyCode: string;
|
|
10
|
+
CurrencySymbol: string;
|
|
11
|
+
CurrencyLocale: number;
|
|
12
|
+
CurrencyFormatInfo: CurrencyFormatInfo;
|
|
13
|
+
Origin: null;
|
|
14
|
+
Position: number;
|
|
15
|
+
ConditionRule: null;
|
|
16
|
+
CurrencyDecimalDigits: null;
|
|
17
|
+
}
|
|
18
|
+
export interface CurrencyFormatInfo {
|
|
19
|
+
CurrencyDecimalDigits: number;
|
|
20
|
+
CurrencyDecimalSeparator: string;
|
|
21
|
+
CurrencyGroupSeparator: string;
|
|
22
|
+
CurrencyGroupSize: number;
|
|
23
|
+
StartsWithCurrencySymbol: boolean;
|
|
24
|
+
}
|
|
@@ -9,6 +9,7 @@ export declare const getClients: (options: Options, ctx: Context) => {
|
|
|
9
9
|
};
|
|
10
10
|
commerce: {
|
|
11
11
|
catalog: {
|
|
12
|
+
salesChannel: (sc: string) => Promise<import("./commerce/types/SalesChannel").SalesChannel>;
|
|
12
13
|
brand: {
|
|
13
14
|
list: () => Promise<import("./commerce/types/Brand").Brand[]>;
|
|
14
15
|
};
|
|
@@ -4,4 +4,5 @@ export declare const getLoaders: (options: Options, { clients }: Context) => {
|
|
|
4
4
|
skuLoader: import("dataloader")<string, import("../utils/enhanceSku").EnhancedSku, string>;
|
|
5
5
|
simulationLoader: import("dataloader")<import("../clients/commerce/types/Simulation").PayloadItem[], import("../clients/commerce/types/Simulation").Simulation, import("../clients/commerce/types/Simulation").PayloadItem[]>;
|
|
6
6
|
collectionLoader: import("dataloader")<string, import("../clients/commerce/types/Portal").CollectionPageType, string>;
|
|
7
|
+
salesChannelLoader: import("dataloader")<string, import("../clients/commerce/types/SalesChannel").SalesChannel, string>;
|
|
7
8
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
import { Options } from "..";
|
|
3
|
+
import { Clients } from "../clients";
|
|
4
|
+
import type { SalesChannel } from "./../clients/commerce/types/SalesChannel";
|
|
5
|
+
export declare const getSalesChannelLoader: (_: Options, clients: Clients) => DataLoader<string, SalesChannel, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"express-graphql": "^0.12.0",
|
|
38
38
|
"graphql": "^15.6.0",
|
|
39
39
|
"jest-transform-graphql": "^2.1.0",
|
|
40
|
-
"shared": "^1.10.
|
|
40
|
+
"shared": "^1.10.18",
|
|
41
41
|
"ts-jest": "25.5.1",
|
|
42
42
|
"tsdx": "^0.14.1",
|
|
43
43
|
"tslib": "^2.3.1",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"graphql": "^15.6.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "a6f5e44b68bde5b811a345bffb7bec697e8f3933"
|
|
50
50
|
}
|
|
@@ -300,7 +300,7 @@ export type StoreCollectionMeta = {
|
|
|
300
300
|
selectedFacets: Array<StoreCollectionFacet>;
|
|
301
301
|
};
|
|
302
302
|
|
|
303
|
-
/** Product collection type. Possible values are `Department`, `Category`, `Brand` or `
|
|
303
|
+
/** Product collection type. Possible values are `Department`, `Category`, `Brand`, `Cluster`, `SubCategory` or `Collection`. */
|
|
304
304
|
export const enum StoreCollectionType {
|
|
305
305
|
/** Product brand. */
|
|
306
306
|
Brand = 'Brand',
|
|
@@ -308,8 +308,12 @@ export const enum StoreCollectionType {
|
|
|
308
308
|
Category = 'Category',
|
|
309
309
|
/** Product cluster. */
|
|
310
310
|
Cluster = 'Cluster',
|
|
311
|
+
/** Product collection. */
|
|
312
|
+
Collection = 'Collection',
|
|
311
313
|
/** First level of product categorization. */
|
|
312
|
-
Department = 'Department'
|
|
314
|
+
Department = 'Department',
|
|
315
|
+
/** Third level of product categorization. */
|
|
316
|
+
SubCategory = 'SubCategory'
|
|
313
317
|
};
|
|
314
318
|
|
|
315
319
|
/** Currency information. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FACET_CROSS_SELLING_MAP } from
|
|
2
|
-
import { fetchAPI } from
|
|
3
|
-
|
|
1
|
+
import { FACET_CROSS_SELLING_MAP } from '../../utils/facets'
|
|
2
|
+
import { fetchAPI } from '../fetch'
|
|
3
|
+
|
|
4
|
+
import type { PortalProduct } from './types/Product'
|
|
4
5
|
import type { Context, Options } from '../../index'
|
|
5
6
|
import type { Brand } from './types/Brand'
|
|
6
7
|
import type { CategoryTree } from './types/CategoryTree'
|
|
@@ -14,8 +15,9 @@ import type {
|
|
|
14
15
|
} from './types/Simulation'
|
|
15
16
|
import type { Session } from './types/Session'
|
|
16
17
|
import type { Channel } from '../../utils/channel'
|
|
18
|
+
import type { SalesChannel } from './types/SalesChannel'
|
|
17
19
|
|
|
18
|
-
type ValueOf<T> = T extends Record<string, infer K> ? K : never
|
|
20
|
+
type ValueOf<T> = T extends Record<string, infer K> ? K : never
|
|
19
21
|
|
|
20
22
|
const BASE_INIT = {
|
|
21
23
|
method: 'POST',
|
|
@@ -32,6 +34,8 @@ export const VtexCommerce = (
|
|
|
32
34
|
|
|
33
35
|
return {
|
|
34
36
|
catalog: {
|
|
37
|
+
salesChannel: (sc: string): Promise<SalesChannel> =>
|
|
38
|
+
fetchAPI(`${base}/api/catalog_system/pub/saleschannel/${sc}`),
|
|
35
39
|
brand: {
|
|
36
40
|
list: (): Promise<Brand[]> =>
|
|
37
41
|
fetchAPI(`${base}/api/catalog_system/pub/brand/list`),
|
|
@@ -6,7 +6,14 @@ export interface CollectionPageType {
|
|
|
6
6
|
url: string
|
|
7
7
|
title: string
|
|
8
8
|
metaTagDescription: string
|
|
9
|
-
pageType:
|
|
9
|
+
pageType:
|
|
10
|
+
| 'Brand'
|
|
11
|
+
| 'Category'
|
|
12
|
+
| 'Department'
|
|
13
|
+
| 'SubCategory'
|
|
14
|
+
| 'Product'
|
|
15
|
+
| 'Collection'
|
|
16
|
+
| 'Cluster'
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
export interface FallbackPageType {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface SalesChannel {
|
|
2
|
+
Id: number;
|
|
3
|
+
Name: string;
|
|
4
|
+
IsActive: boolean;
|
|
5
|
+
ProductClusterId: null;
|
|
6
|
+
CountryCode: string;
|
|
7
|
+
CultureInfo: string;
|
|
8
|
+
TimeZone: string;
|
|
9
|
+
CurrencyCode: string;
|
|
10
|
+
CurrencySymbol: string;
|
|
11
|
+
CurrencyLocale: number;
|
|
12
|
+
CurrencyFormatInfo: CurrencyFormatInfo;
|
|
13
|
+
Origin: null;
|
|
14
|
+
Position: number;
|
|
15
|
+
ConditionRule: null;
|
|
16
|
+
CurrencyDecimalDigits: null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CurrencyFormatInfo {
|
|
20
|
+
CurrencyDecimalDigits: number;
|
|
21
|
+
CurrencyDecimalSeparator: string;
|
|
22
|
+
CurrencyGroupSeparator: string;
|
|
23
|
+
CurrencyGroupSize: number;
|
|
24
|
+
StartsWithCurrencySymbol: boolean;
|
|
25
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getSalesChannelLoader } from './salesChannel';
|
|
1
2
|
import { getSimulationLoader } from './simulation'
|
|
2
3
|
import { getSkuLoader } from './sku'
|
|
3
4
|
import { getCollectionLoader } from './collection'
|
|
@@ -9,10 +10,12 @@ export const getLoaders = (options: Options, { clients }: Context) => {
|
|
|
9
10
|
const skuLoader = getSkuLoader(options, clients)
|
|
10
11
|
const simulationLoader = getSimulationLoader(options, clients)
|
|
11
12
|
const collectionLoader = getCollectionLoader(options, clients)
|
|
13
|
+
const salesChannelLoader = getSalesChannelLoader(options, clients)
|
|
12
14
|
|
|
13
15
|
return {
|
|
14
16
|
skuLoader,
|
|
15
17
|
simulationLoader,
|
|
16
18
|
collectionLoader,
|
|
19
|
+
salesChannelLoader
|
|
17
20
|
}
|
|
18
21
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import DataLoader from "dataloader";
|
|
2
|
+
|
|
3
|
+
import { Options } from "..";
|
|
4
|
+
import { Clients } from "../clients";
|
|
5
|
+
|
|
6
|
+
import type { SalesChannel } from "./../clients/commerce/types/SalesChannel";
|
|
7
|
+
|
|
8
|
+
export const getSalesChannelLoader = (_: Options, clients: Clients) => {
|
|
9
|
+
const loader = async (channels: readonly string[]) =>
|
|
10
|
+
Promise.all(
|
|
11
|
+
channels.map((sc) => clients.commerce.catalog.salesChannel(sc)),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
return new DataLoader<string, SalesChannel>(loader);
|
|
15
|
+
};
|
|
@@ -20,6 +20,15 @@ export const StoreAggregateOffer: Record<string, Resolver<Root>> & {
|
|
|
20
20
|
return lowOffer ? price(lowOffer) : 0
|
|
21
21
|
},
|
|
22
22
|
offerCount: (offers) => offers.length,
|
|
23
|
-
priceCurrency: () =>
|
|
23
|
+
priceCurrency: async (_, __, ctx) => {
|
|
24
|
+
const {
|
|
25
|
+
loaders: { salesChannelLoader },
|
|
26
|
+
storage: { channel }
|
|
27
|
+
} = ctx
|
|
28
|
+
|
|
29
|
+
const sc = await salesChannelLoader.load(channel.salesChannel);
|
|
30
|
+
|
|
31
|
+
return sc.CurrencyCode ?? '';
|
|
32
|
+
},
|
|
24
33
|
offers: (offers) => offers,
|
|
25
34
|
}
|
|
@@ -24,7 +24,16 @@ const isOrderFormItem = (item: Root): item is OrderFormProduct =>
|
|
|
24
24
|
'skuName' in item
|
|
25
25
|
|
|
26
26
|
export const StoreOffer: Record<string, Resolver<Root>> = {
|
|
27
|
-
priceCurrency: () =>
|
|
27
|
+
priceCurrency: async (_, __, ctx) => {
|
|
28
|
+
const {
|
|
29
|
+
loaders: { salesChannelLoader },
|
|
30
|
+
storage: { channel }
|
|
31
|
+
} = ctx
|
|
32
|
+
|
|
33
|
+
const sc = await salesChannelLoader.load(channel.salesChannel);
|
|
34
|
+
|
|
35
|
+
return sc.CurrencyCode ?? '';
|
|
36
|
+
},
|
|
28
37
|
priceValidUntil: (root) => {
|
|
29
38
|
if (isSearchItem(root)) {
|
|
30
39
|
return root.PriceValidUntil ?? ''
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Product collection type. Possible values are `Department`, `Category`, `Brand` or `
|
|
2
|
+
Product collection type. Possible values are `Department`, `Category`, `Brand`, `Cluster`, `SubCategory` or `Collection`.
|
|
3
3
|
"""
|
|
4
4
|
enum StoreCollectionType {
|
|
5
5
|
"""
|
|
@@ -11,6 +11,10 @@ enum StoreCollectionType {
|
|
|
11
11
|
"""
|
|
12
12
|
Category
|
|
13
13
|
"""
|
|
14
|
+
Third level of product categorization.
|
|
15
|
+
"""
|
|
16
|
+
SubCategory
|
|
17
|
+
"""
|
|
14
18
|
Product brand.
|
|
15
19
|
"""
|
|
16
20
|
Brand
|
|
@@ -18,6 +22,10 @@ enum StoreCollectionType {
|
|
|
18
22
|
Product cluster.
|
|
19
23
|
"""
|
|
20
24
|
Cluster
|
|
25
|
+
"""
|
|
26
|
+
Product collection.
|
|
27
|
+
"""
|
|
28
|
+
Collection
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
"""
|