@faststore/api 1.8.31 → 1.8.32
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 +8 -0
- package/dist/__generated__/schema.d.ts +15 -2
- package/dist/api.cjs.development.js +117 -19
- 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 +118 -20
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +49 -7
- package/dist/platforms/vtex/clients/commerce/types/OrderForm.d.ts +6 -0
- package/dist/platforms/vtex/index.d.ts +49 -7
- package/dist/platforms/vtex/resolvers/aggregateOffer.d.ts +1 -2
- package/dist/platforms/vtex/resolvers/mutation.d.ts +1 -0
- package/dist/platforms/vtex/resolvers/objectOrString.d.ts +2 -0
- package/dist/platforms/vtex/resolvers/product.d.ts +6 -2
- package/dist/platforms/vtex/resolvers/validateCart.d.ts +1 -0
- package/dist/platforms/vtex/utils/enhanceCommercialOffer.d.ts +8 -9
- package/dist/platforms/vtex/utils/propertyValue.d.ts +5 -0
- package/package.json +2 -2
- package/src/__generated__/schema.ts +16 -2
- package/src/platforms/vtex/clients/commerce/types/OrderForm.ts +7 -0
- package/src/platforms/vtex/index.ts +2 -0
- package/src/platforms/vtex/resolvers/aggregateOffer.ts +1 -2
- package/src/platforms/vtex/resolvers/objectOrString.ts +46 -0
- package/src/platforms/vtex/resolvers/offer.ts +11 -1
- package/src/platforms/vtex/resolvers/product.ts +30 -5
- package/src/platforms/vtex/resolvers/productGroup.ts +6 -1
- package/src/platforms/vtex/resolvers/validateCart.ts +32 -1
- package/src/platforms/vtex/utils/enhanceCommercialOffer.ts +8 -12
- package/src/platforms/vtex/utils/propertyValue.ts +5 -0
- package/src/typeDefs/index.ts +2 -0
- package/src/typeDefs/objectOrString.graphql +1 -0
- package/src/typeDefs/product.graphql +4 -0
- package/src/typeDefs/propertyValue.graphql +21 -2
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,44 @@ export declare const getResolvers: (options: Options) => {
|
|
|
6
6
|
StoreCollection: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/clients/commerce/types/Brand").Brand | (import("./platforms/vtex/clients/commerce/types/CategoryTree").CategoryTree & {
|
|
7
7
|
level: number;
|
|
8
8
|
}) | import("./platforms/vtex/clients/commerce/types/Portal").CollectionPageType, unknown, any>>;
|
|
9
|
-
StoreAggregateOffer: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/utils/enhanceCommercialOffer").EnhancedCommercialOffer
|
|
10
|
-
|
|
9
|
+
StoreAggregateOffer: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./platforms/vtex/clients/search/types/ProductSearchResult").Seller, import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
10
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
11
|
+
} & {
|
|
12
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
13
|
+
}>[], unknown, any>> & {
|
|
14
|
+
offers: import("./platforms/vtex").Resolver<import("./platforms/vtex/utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./platforms/vtex/clients/search/types/ProductSearchResult").Seller, import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
15
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
16
|
+
} & {
|
|
17
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
18
|
+
}>[], any, import("./platforms/vtex/utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./platforms/vtex/clients/search/types/ProductSearchResult").Seller, import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
19
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
20
|
+
} & {
|
|
21
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
22
|
+
}>[]>;
|
|
11
23
|
};
|
|
12
|
-
StoreProduct: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
StoreProduct: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
25
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
26
|
+
} & {
|
|
27
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
28
|
+
}, unknown, any>> & {
|
|
29
|
+
offers: import("./platforms/vtex").Resolver<import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
30
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
31
|
+
} & {
|
|
32
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
33
|
+
}, any, import("./platforms/vtex/utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./platforms/vtex/clients/search/types/ProductSearchResult").Seller, import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
34
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
35
|
+
} & {
|
|
36
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
37
|
+
}>[]>;
|
|
38
|
+
isVariantOf: import("./platforms/vtex").Resolver<import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
39
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
40
|
+
} & {
|
|
41
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
42
|
+
}, any, import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
43
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
44
|
+
} & {
|
|
45
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
46
|
+
}>;
|
|
15
47
|
};
|
|
16
48
|
StoreSeo: Record<string, import("./platforms/vtex").Resolver<{
|
|
17
49
|
title?: string | undefined;
|
|
@@ -19,13 +51,22 @@ export declare const getResolvers: (options: Options) => {
|
|
|
19
51
|
}, unknown, any>>;
|
|
20
52
|
StoreFacet: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/clients/search/types/FacetSearchResult").Facet, unknown, any>>;
|
|
21
53
|
StoreFacetValue: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/clients/search/types/FacetSearchResult").FacetValue, unknown, any>>;
|
|
22
|
-
StoreOffer: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/utils/enhanceCommercialOffer").EnhancedCommercialOffer
|
|
54
|
+
StoreOffer: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./platforms/vtex/clients/search/types/ProductSearchResult").Seller, import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
55
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
56
|
+
} & {
|
|
57
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
58
|
+
}> | (import("./platforms/vtex/clients/commerce/types/OrderForm").OrderFormItem & {
|
|
23
59
|
product: Promise<import("./platforms/vtex/utils/enhanceSku").EnhancedSku>;
|
|
24
60
|
}), unknown, any>>;
|
|
25
61
|
StoreAggregateRating: Record<string, import("./platforms/vtex").Resolver<unknown, unknown, any>>;
|
|
26
62
|
StoreReview: Record<string, import("./platforms/vtex").Resolver<unknown, unknown, any>>;
|
|
27
|
-
StoreProductGroup: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/
|
|
63
|
+
StoreProductGroup: Record<string, import("./platforms/vtex").Resolver<import("./platforms/vtex/clients/search/types/ProductSearchResult").Item & {
|
|
64
|
+
isVariantOf: import("./platforms/vtex/clients/search/types/ProductSearchResult").Product;
|
|
65
|
+
} & {
|
|
66
|
+
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
67
|
+
}, unknown, any>>;
|
|
28
68
|
StoreSearchResult: Record<string, import("./platforms/vtex").Resolver<Pick<import("./platforms/vtex/clients/search").SearchArgs, "sort" | "selectedFacets" | "hideUnavailableItems" | "query" | "page" | "count" | "fuzzy">, unknown, any>>;
|
|
69
|
+
ObjectOrString: import("graphql").GraphQLScalarType;
|
|
29
70
|
Query: {
|
|
30
71
|
product: (_: unknown, { locator }: import("./__generated__/schema").QueryProductArgs, ctx: import("./platforms/vtex").Context) => Promise<import("./platforms/vtex/utils/enhanceSku").EnhancedSku>;
|
|
31
72
|
collection: (_: unknown, { slug }: import("./__generated__/schema").QueryCollectionArgs, ctx: import("./platforms/vtex").Context) => Promise<import("./platforms/vtex/clients/commerce/types/Portal").CollectionPageType>;
|
|
@@ -132,6 +173,7 @@ export declare const getResolvers: (options: Options) => {
|
|
|
132
173
|
sellingPrices: import("./platforms/vtex/clients/commerce/types/OrderForm").SellingPrice[];
|
|
133
174
|
total: number;
|
|
134
175
|
};
|
|
176
|
+
attachments: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[];
|
|
135
177
|
}[];
|
|
136
178
|
};
|
|
137
179
|
messages: {
|
|
@@ -3,6 +3,11 @@ export interface OrderFormInputItem {
|
|
|
3
3
|
quantity: number;
|
|
4
4
|
seller: string;
|
|
5
5
|
index?: number;
|
|
6
|
+
attachments?: Attachment[];
|
|
7
|
+
}
|
|
8
|
+
export interface Attachment {
|
|
9
|
+
name: string;
|
|
10
|
+
content: Record<string, string>;
|
|
6
11
|
}
|
|
7
12
|
export interface OrderFormItem {
|
|
8
13
|
id: string;
|
|
@@ -47,6 +52,7 @@ export interface OrderFormItem {
|
|
|
47
52
|
sellingPrices: SellingPrice[];
|
|
48
53
|
total: number;
|
|
49
54
|
};
|
|
55
|
+
attachments: Attachment[];
|
|
50
56
|
}
|
|
51
57
|
export interface SKUSpecification {
|
|
52
58
|
fieldName: string;
|
|
@@ -33,12 +33,44 @@ export declare const getResolvers: (_: Options) => {
|
|
|
33
33
|
StoreCollection: Record<string, Resolver<import("./clients/commerce/types/Brand").Brand | import("./clients/commerce/types/Portal").CollectionPageType | (import("./clients/commerce/types/CategoryTree").CategoryTree & {
|
|
34
34
|
level: number;
|
|
35
35
|
}), unknown, any>>;
|
|
36
|
-
StoreAggregateOffer: Record<string, Resolver<import("./utils/enhanceCommercialOffer").EnhancedCommercialOffer
|
|
37
|
-
|
|
36
|
+
StoreAggregateOffer: Record<string, Resolver<import("./utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./clients/search/types/ProductSearchResult").Seller, import("./clients/search/types/ProductSearchResult").Item & {
|
|
37
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
38
|
+
} & {
|
|
39
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
40
|
+
}>[], unknown, any>> & {
|
|
41
|
+
offers: Resolver<import("./utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./clients/search/types/ProductSearchResult").Seller, import("./clients/search/types/ProductSearchResult").Item & {
|
|
42
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
43
|
+
} & {
|
|
44
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
45
|
+
}>[], any, import("./utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./clients/search/types/ProductSearchResult").Seller, import("./clients/search/types/ProductSearchResult").Item & {
|
|
46
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
47
|
+
} & {
|
|
48
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
49
|
+
}>[]>;
|
|
38
50
|
};
|
|
39
|
-
StoreProduct: Record<string, Resolver<import("./
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
StoreProduct: Record<string, Resolver<import("./clients/search/types/ProductSearchResult").Item & {
|
|
52
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
53
|
+
} & {
|
|
54
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
55
|
+
}, unknown, any>> & {
|
|
56
|
+
offers: Resolver<import("./clients/search/types/ProductSearchResult").Item & {
|
|
57
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
58
|
+
} & {
|
|
59
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
60
|
+
}, any, import("./utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./clients/search/types/ProductSearchResult").Seller, import("./clients/search/types/ProductSearchResult").Item & {
|
|
61
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
62
|
+
} & {
|
|
63
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
64
|
+
}>[]>;
|
|
65
|
+
isVariantOf: Resolver<import("./clients/search/types/ProductSearchResult").Item & {
|
|
66
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
67
|
+
} & {
|
|
68
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
69
|
+
}, any, import("./clients/search/types/ProductSearchResult").Item & {
|
|
70
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
71
|
+
} & {
|
|
72
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
73
|
+
}>;
|
|
42
74
|
};
|
|
43
75
|
StoreSeo: Record<string, Resolver<{
|
|
44
76
|
title?: string | undefined;
|
|
@@ -46,13 +78,22 @@ export declare const getResolvers: (_: Options) => {
|
|
|
46
78
|
}, unknown, any>>;
|
|
47
79
|
StoreFacet: Record<string, Resolver<import("./clients/search/types/FacetSearchResult").Facet, unknown, any>>;
|
|
48
80
|
StoreFacetValue: Record<string, Resolver<import("./clients/search/types/FacetSearchResult").FacetValue, unknown, any>>;
|
|
49
|
-
StoreOffer: Record<string, Resolver<import("./utils/enhanceCommercialOffer").EnhancedCommercialOffer
|
|
81
|
+
StoreOffer: Record<string, Resolver<import("./utils/enhanceCommercialOffer").EnhancedCommercialOffer<import("./clients/search/types/ProductSearchResult").Seller, import("./clients/search/types/ProductSearchResult").Item & {
|
|
82
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
83
|
+
} & {
|
|
84
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
85
|
+
}> | (import("./clients/commerce/types/OrderForm").OrderFormItem & {
|
|
50
86
|
product: Promise<import("./utils/enhanceSku").EnhancedSku>;
|
|
51
87
|
}), unknown, any>>;
|
|
52
88
|
StoreAggregateRating: Record<string, Resolver<unknown, unknown, any>>;
|
|
53
89
|
StoreReview: Record<string, Resolver<unknown, unknown, any>>;
|
|
54
|
-
StoreProductGroup: Record<string, Resolver<import("./
|
|
90
|
+
StoreProductGroup: Record<string, Resolver<import("./clients/search/types/ProductSearchResult").Item & {
|
|
91
|
+
isVariantOf: import("./clients/search/types/ProductSearchResult").Product;
|
|
92
|
+
} & {
|
|
93
|
+
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
94
|
+
}, unknown, any>>;
|
|
55
95
|
StoreSearchResult: Record<string, Resolver<Pick<import("./clients/search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy">, unknown, any>>;
|
|
96
|
+
ObjectOrString: import("graphql").GraphQLScalarType;
|
|
56
97
|
Query: {
|
|
57
98
|
product: (_: unknown, { locator }: import("../..").QueryProductArgs, ctx: Context) => Promise<import("./utils/enhanceSku").EnhancedSku>;
|
|
58
99
|
collection: (_: unknown, { slug }: import("../..").QueryCollectionArgs, ctx: Context) => Promise<import("./clients/commerce/types/Portal").CollectionPageType>;
|
|
@@ -159,6 +200,7 @@ export declare const getResolvers: (_: Options) => {
|
|
|
159
200
|
sellingPrices: import("./clients/commerce/types/OrderForm").SellingPrice[];
|
|
160
201
|
total: number;
|
|
161
202
|
};
|
|
203
|
+
attachments: import("./clients/commerce/types/OrderForm").Attachment[];
|
|
162
204
|
}[];
|
|
163
205
|
};
|
|
164
206
|
messages: {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { EnhancedCommercialOffer } from '../utils/enhanceCommercialOffer';
|
|
2
1
|
import type { StoreProduct } from './product';
|
|
3
2
|
import type { PromiseType } from '../../../typings';
|
|
4
3
|
import type { Resolver } from '..';
|
|
5
4
|
declare type Root = PromiseType<ReturnType<typeof StoreProduct.offers>>;
|
|
6
5
|
export declare const StoreAggregateOffer: Record<string, Resolver<Root>> & {
|
|
7
|
-
offers: Resolver<Root, any,
|
|
6
|
+
offers: Resolver<Root, any, Root>;
|
|
8
7
|
};
|
|
9
8
|
export {};
|
|
@@ -2,9 +2,13 @@ import type { EnhancedCommercialOffer } from '../utils/enhanceCommercialOffer';
|
|
|
2
2
|
import type { Resolver } from '..';
|
|
3
3
|
import type { PromiseType } from '../../../typings';
|
|
4
4
|
import type { Query } from './query';
|
|
5
|
-
|
|
5
|
+
import type { Attachment } from '../clients/commerce/types/OrderForm';
|
|
6
|
+
declare type QueryProduct = PromiseType<ReturnType<typeof Query.product>>;
|
|
7
|
+
declare type Root = QueryProduct & {
|
|
8
|
+
attachmentsValues?: Attachment[];
|
|
9
|
+
};
|
|
6
10
|
export declare const StoreProduct: Record<string, Resolver<Root>> & {
|
|
7
|
-
offers: Resolver<Root, any, EnhancedCommercialOffer[]
|
|
11
|
+
offers: Resolver<Root, any, Array<EnhancedCommercialOffer<Root['sellers'][number], Root>>>;
|
|
8
12
|
isVariantOf: Resolver<Root, any, Root>;
|
|
9
13
|
};
|
|
10
14
|
export {};
|
|
@@ -62,6 +62,7 @@ export declare const validateCart: (_: unknown, { cart: { order } }: {
|
|
|
62
62
|
sellingPrices: import("../clients/commerce/types/OrderForm").SellingPrice[];
|
|
63
63
|
total: number;
|
|
64
64
|
};
|
|
65
|
+
attachments: import("../clients/commerce/types/OrderForm").Attachment[];
|
|
65
66
|
}[];
|
|
66
67
|
};
|
|
67
68
|
messages: {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { CommertialOffer
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
product: EnhancedSku;
|
|
1
|
+
import type { CommertialOffer } from '../clients/search/types/ProductSearchResult';
|
|
2
|
+
export declare type EnhancedCommercialOffer<S, P> = CommertialOffer & {
|
|
3
|
+
seller: S;
|
|
4
|
+
product: P;
|
|
6
5
|
};
|
|
7
|
-
export declare const enhanceCommercialOffer: ({ offer, seller, product, }: {
|
|
6
|
+
export declare const enhanceCommercialOffer: <S, P>({ offer, seller, product, }: {
|
|
8
7
|
offer: CommertialOffer;
|
|
9
|
-
seller:
|
|
10
|
-
product:
|
|
11
|
-
}) => EnhancedCommercialOffer
|
|
8
|
+
seller: S;
|
|
9
|
+
product: P;
|
|
10
|
+
}) => EnhancedCommercialOffer<S, P>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.32",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"graphql": "^15.6.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ab3e45f518c9ce93c6d71e8fb4a83ade0ac7f14d"
|
|
49
49
|
}
|
|
@@ -9,6 +9,7 @@ export type Scalars = {
|
|
|
9
9
|
Boolean: boolean;
|
|
10
10
|
Int: number;
|
|
11
11
|
Float: number;
|
|
12
|
+
ObjectOrString: any;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
/** Shopping cart input. */
|
|
@@ -55,6 +56,8 @@ export type IStoreOrganization = {
|
|
|
55
56
|
|
|
56
57
|
/** 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. */
|
|
57
58
|
export type IStoreProduct = {
|
|
59
|
+
/** Custom Product Additional Properties. */
|
|
60
|
+
additionalProperty?: Maybe<Array<IStorePropertyValue>>;
|
|
58
61
|
/** Array of product images. */
|
|
59
62
|
image: Array<IStoreImage>;
|
|
60
63
|
/** Product name. */
|
|
@@ -63,6 +66,15 @@ export type IStoreProduct = {
|
|
|
63
66
|
sku: Scalars['String'];
|
|
64
67
|
};
|
|
65
68
|
|
|
69
|
+
export type IStorePropertyValue = {
|
|
70
|
+
/** Property name. */
|
|
71
|
+
name: Scalars['String'];
|
|
72
|
+
/** Property value. May hold a string or the string representation of an object. */
|
|
73
|
+
value: Scalars['ObjectOrString'];
|
|
74
|
+
/** Specifies the nature of the value */
|
|
75
|
+
valueReference: Scalars['String'];
|
|
76
|
+
};
|
|
77
|
+
|
|
66
78
|
/** Selected facet input. */
|
|
67
79
|
export type IStoreSelectedFacet = {
|
|
68
80
|
key: Scalars['String'];
|
|
@@ -460,8 +472,10 @@ export type StorePropertyValue = {
|
|
|
460
472
|
__typename?: 'StorePropertyValue';
|
|
461
473
|
/** Property name. */
|
|
462
474
|
name: Scalars['String'];
|
|
463
|
-
/** Property value. */
|
|
464
|
-
value: Scalars['
|
|
475
|
+
/** Property value. May hold a string or the string representation of an object. */
|
|
476
|
+
value: Scalars['ObjectOrString'];
|
|
477
|
+
/** Specifies the nature of the value */
|
|
478
|
+
valueReference: Scalars['String'];
|
|
465
479
|
};
|
|
466
480
|
|
|
467
481
|
/** Information of a given review. */
|
|
@@ -3,6 +3,12 @@ export interface OrderFormInputItem {
|
|
|
3
3
|
quantity: number
|
|
4
4
|
seller: string
|
|
5
5
|
index?: number
|
|
6
|
+
attachments?: Attachment[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Attachment {
|
|
10
|
+
name: string
|
|
11
|
+
content: Record<string, string>
|
|
6
12
|
}
|
|
7
13
|
|
|
8
14
|
export interface OrderFormItem {
|
|
@@ -48,6 +54,7 @@ export interface OrderFormItem {
|
|
|
48
54
|
sellingPrices: SellingPrice[]
|
|
49
55
|
total: number
|
|
50
56
|
}
|
|
57
|
+
attachments: Attachment[]
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
export interface SKUSpecification {
|
|
@@ -13,6 +13,7 @@ import { Query } from './resolvers/query'
|
|
|
13
13
|
import { StoreReview } from './resolvers/review'
|
|
14
14
|
import { StoreSearchResult } from './resolvers/searchResult'
|
|
15
15
|
import { StoreSeo } from './resolvers/seo'
|
|
16
|
+
import { ObjectOrString } from './resolvers/objectOrString'
|
|
16
17
|
import type { Loaders } from './loaders'
|
|
17
18
|
import type { Clients } from './clients'
|
|
18
19
|
import type { Channel } from './utils/channel'
|
|
@@ -67,6 +68,7 @@ const Resolvers = {
|
|
|
67
68
|
StoreReview,
|
|
68
69
|
StoreProductGroup,
|
|
69
70
|
StoreSearchResult,
|
|
71
|
+
ObjectOrString,
|
|
70
72
|
Query,
|
|
71
73
|
Mutation,
|
|
72
74
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { inStock } from '../utils/productStock'
|
|
2
|
-
import type { EnhancedCommercialOffer } from '../utils/enhanceCommercialOffer'
|
|
3
2
|
import type { StoreProduct } from './product'
|
|
4
3
|
import type { PromiseType } from '../../../typings'
|
|
5
4
|
import type { Resolver } from '..'
|
|
@@ -7,7 +6,7 @@ import type { Resolver } from '..'
|
|
|
7
6
|
type Root = PromiseType<ReturnType<typeof StoreProduct.offers>>
|
|
8
7
|
|
|
9
8
|
export const StoreAggregateOffer: Record<string, Resolver<Root>> & {
|
|
10
|
-
offers: Resolver<Root, any,
|
|
9
|
+
offers: Resolver<Root, any, Root>
|
|
11
10
|
} = {
|
|
12
11
|
highPrice: (offers) => {
|
|
13
12
|
const availableOffers = offers.filter(inStock)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GraphQLScalarSerializer } from 'graphql'
|
|
2
|
+
import { GraphQLScalarType } from 'graphql'
|
|
3
|
+
import { Kind } from 'graphql/language'
|
|
4
|
+
|
|
5
|
+
export const ObjectOrString = new GraphQLScalarType({
|
|
6
|
+
name: 'ObjectOrString',
|
|
7
|
+
description:
|
|
8
|
+
'A string or the string representation of an object (a stringified object).',
|
|
9
|
+
parseValue: toObjectOrString,
|
|
10
|
+
serialize: stringify,
|
|
11
|
+
parseLiteral(ast) {
|
|
12
|
+
if (ast.kind === Kind.STRING) {
|
|
13
|
+
return getValueAsObjectOrString(ast.value)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return null
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
function toObjectOrString(value: GraphQLScalarSerializer<any>) {
|
|
21
|
+
if (typeof value === 'string') {
|
|
22
|
+
return getValueAsObjectOrString(value)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getValueAsObjectOrString(value: string) {
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(value)
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return value
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function stringify(value: GraphQLScalarSerializer<any>) {
|
|
37
|
+
if (typeof value === 'object') {
|
|
38
|
+
return JSON.stringify(value)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (typeof value === 'string') {
|
|
42
|
+
return value
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
@@ -96,7 +96,17 @@ export const StoreOffer: Record<string, Resolver<Root>> = {
|
|
|
96
96
|
|
|
97
97
|
return null
|
|
98
98
|
},
|
|
99
|
-
itemOffered: (
|
|
99
|
+
itemOffered: async (root) => {
|
|
100
|
+
if (isSearchItem(root)) {
|
|
101
|
+
return root.product
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (isOrderFormItem(root)) {
|
|
105
|
+
return { ...(await root.product), attachmentsValues: root.attachments }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return null
|
|
109
|
+
},
|
|
100
110
|
quantity: (root) => {
|
|
101
111
|
if (isSearchItem(root)) {
|
|
102
112
|
return root.AvailableQuantity ?? 0
|
|
@@ -5,8 +5,14 @@ import type { EnhancedCommercialOffer } from '../utils/enhanceCommercialOffer'
|
|
|
5
5
|
import type { Resolver } from '..'
|
|
6
6
|
import type { PromiseType } from '../../../typings'
|
|
7
7
|
import type { Query } from './query'
|
|
8
|
+
import { VALUE_REFERENCES } from '../utils/propertyValue'
|
|
9
|
+
import type { Attachment } from '../clients/commerce/types/OrderForm'
|
|
8
10
|
|
|
9
|
-
type
|
|
11
|
+
type QueryProduct = PromiseType<ReturnType<typeof Query.product>>
|
|
12
|
+
|
|
13
|
+
type Root = QueryProduct & {
|
|
14
|
+
attachmentsValues?: Attachment[]
|
|
15
|
+
}
|
|
10
16
|
|
|
11
17
|
const DEFAULT_IMAGE = {
|
|
12
18
|
imageText: 'image',
|
|
@@ -20,7 +26,12 @@ const nonEmptyArray = <T>(array: T[] | null | undefined) =>
|
|
|
20
26
|
Array.isArray(array) && array.length > 0 ? array : null
|
|
21
27
|
|
|
22
28
|
export const StoreProduct: Record<string, Resolver<Root>> & {
|
|
23
|
-
offers: Resolver<
|
|
29
|
+
offers: Resolver<
|
|
30
|
+
Root,
|
|
31
|
+
any,
|
|
32
|
+
Array<EnhancedCommercialOffer<Root['sellers'][number], Root>>
|
|
33
|
+
>
|
|
34
|
+
|
|
24
35
|
isVariantOf: Resolver<Root, any, Root>
|
|
25
36
|
} = {
|
|
26
37
|
productID: ({ itemId }) => itemId,
|
|
@@ -80,9 +91,23 @@ export const StoreProduct: Record<string, Resolver<Root>> & {
|
|
|
80
91
|
)
|
|
81
92
|
.sort(bestOfferFirst),
|
|
82
93
|
isVariantOf: (root) => root,
|
|
83
|
-
additionalProperty: ({ variations = [] }) => {
|
|
84
|
-
|
|
85
|
-
values.map((value) => ({
|
|
94
|
+
additionalProperty: ({ variations = [], attachmentsValues }) => {
|
|
95
|
+
const propertyValueVariations = variations.flatMap(({ name, values }) =>
|
|
96
|
+
values.map((value) => ({
|
|
97
|
+
name,
|
|
98
|
+
value,
|
|
99
|
+
valueReference: VALUE_REFERENCES.variation,
|
|
100
|
+
}))
|
|
86
101
|
)
|
|
102
|
+
|
|
103
|
+
const propertyValueAttachments = (attachmentsValues ?? []).map(
|
|
104
|
+
(attachment) => ({
|
|
105
|
+
name: attachment.name,
|
|
106
|
+
value: attachment.content,
|
|
107
|
+
valueReference: VALUE_REFERENCES.attachment,
|
|
108
|
+
})
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
return [...propertyValueVariations, ...propertyValueAttachments]
|
|
87
112
|
},
|
|
88
113
|
}
|
|
@@ -2,6 +2,7 @@ import { enhanceSku } from '../utils/enhanceSku'
|
|
|
2
2
|
import type { Resolver } from '..'
|
|
3
3
|
import type { PromiseType } from '../../../typings'
|
|
4
4
|
import type { StoreProduct } from './product'
|
|
5
|
+
import { VALUE_REFERENCES } from '../utils/propertyValue'
|
|
5
6
|
|
|
6
7
|
type Root = PromiseType<ReturnType<typeof StoreProduct.isVariantOf>>
|
|
7
8
|
|
|
@@ -22,7 +23,11 @@ export const StoreProductGroup: Record<string, Resolver<Root>> = {
|
|
|
22
23
|
// Transform specs back into product specs
|
|
23
24
|
.flatMap(({ specifications }) =>
|
|
24
25
|
specifications.flatMap(({ name, values }) =>
|
|
25
|
-
values.map((value) => ({
|
|
26
|
+
values.map((value) => ({
|
|
27
|
+
name,
|
|
28
|
+
value,
|
|
29
|
+
valueReference: VALUE_REFERENCES.specification,
|
|
30
|
+
}))
|
|
26
31
|
)
|
|
27
32
|
),
|
|
28
33
|
}
|
|
@@ -12,11 +12,38 @@ import type {
|
|
|
12
12
|
OrderFormItem,
|
|
13
13
|
} from '../clients/commerce/types/OrderForm'
|
|
14
14
|
import type { Context } from '..'
|
|
15
|
+
import { VALUE_REFERENCES } from '../utils/propertyValue'
|
|
15
16
|
|
|
16
17
|
type Indexed<T> = T & { index?: number }
|
|
17
18
|
|
|
19
|
+
const getAttachments = (item: IStoreOffer) =>
|
|
20
|
+
item.itemOffered.additionalProperty?.filter(
|
|
21
|
+
(i) => i.valueReference === VALUE_REFERENCES.attachment
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const serializeAttachment = (item: IStoreOffer) => {
|
|
25
|
+
const attachments = getAttachments(item)
|
|
26
|
+
|
|
27
|
+
if (attachments?.length === 0) {
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return attachments
|
|
32
|
+
?.map(
|
|
33
|
+
(attachment) => `${attachment.name}:${JSON.stringify(attachment.value)}`
|
|
34
|
+
)
|
|
35
|
+
.join('-')
|
|
36
|
+
}
|
|
37
|
+
|
|
18
38
|
const getId = (item: IStoreOffer) =>
|
|
19
|
-
[
|
|
39
|
+
[
|
|
40
|
+
item.itemOffered.sku,
|
|
41
|
+
item.seller.identifier,
|
|
42
|
+
item.price,
|
|
43
|
+
serializeAttachment(item),
|
|
44
|
+
]
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.join('::')
|
|
20
47
|
|
|
21
48
|
const orderFormItemToOffer = (
|
|
22
49
|
item: OrderFormItem,
|
|
@@ -41,6 +68,10 @@ const offerToOrderItemInput = (
|
|
|
41
68
|
seller: offer.seller.identifier,
|
|
42
69
|
id: offer.itemOffered.sku,
|
|
43
70
|
index: offer.index,
|
|
71
|
+
attachments: getAttachments(offer)?.map((attachment) => ({
|
|
72
|
+
name: attachment.name,
|
|
73
|
+
content: attachment.value,
|
|
74
|
+
})),
|
|
44
75
|
})
|
|
45
76
|
|
|
46
77
|
const groupById = (offers: IStoreOffer[]): Map<string, IStoreOffer> =>
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CommertialOffer,
|
|
3
|
-
Seller,
|
|
4
|
-
} from '../clients/search/types/ProductSearchResult'
|
|
5
|
-
import type { EnhancedSku } from './enhanceSku'
|
|
1
|
+
import type { CommertialOffer } from '../clients/search/types/ProductSearchResult'
|
|
6
2
|
|
|
7
|
-
export type EnhancedCommercialOffer = CommertialOffer & {
|
|
8
|
-
seller:
|
|
9
|
-
product:
|
|
3
|
+
export type EnhancedCommercialOffer<S, P> = CommertialOffer & {
|
|
4
|
+
seller: S
|
|
5
|
+
product: P
|
|
10
6
|
}
|
|
11
7
|
|
|
12
|
-
export const enhanceCommercialOffer = ({
|
|
8
|
+
export const enhanceCommercialOffer = <S, P>({
|
|
13
9
|
offer,
|
|
14
10
|
seller,
|
|
15
11
|
product,
|
|
16
12
|
}: {
|
|
17
13
|
offer: CommertialOffer
|
|
18
|
-
seller:
|
|
19
|
-
product:
|
|
20
|
-
}): EnhancedCommercialOffer => ({
|
|
14
|
+
seller: S
|
|
15
|
+
product: P
|
|
16
|
+
}): EnhancedCommercialOffer<S, P> => ({
|
|
21
17
|
...offer,
|
|
22
18
|
product,
|
|
23
19
|
seller,
|
package/src/typeDefs/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import Cart from './cart.graphql'
|
|
|
22
22
|
import Status from './status.graphql'
|
|
23
23
|
import PropertyValue from './propertyValue.graphql'
|
|
24
24
|
import Person from './person.graphql'
|
|
25
|
+
import ObjectOrString from './objectOrString.graphql'
|
|
25
26
|
|
|
26
27
|
export const typeDefs = [
|
|
27
28
|
Query,
|
|
@@ -46,6 +47,7 @@ export const typeDefs = [
|
|
|
46
47
|
Status,
|
|
47
48
|
PropertyValue,
|
|
48
49
|
Person,
|
|
50
|
+
ObjectOrString,
|
|
49
51
|
]
|
|
50
52
|
.map(print)
|
|
51
53
|
.join('\n')
|