@faststore/api 1.8.31 → 1.8.34
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 +27 -0
- package/dist/__generated__/schema.d.ts +17 -2
- package/dist/api.cjs.development.js +133 -20
- 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 +134 -21
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +50 -7
- package/dist/platforms/vtex/clients/commerce/types/OrderForm.d.ts +6 -0
- package/dist/platforms/vtex/index.d.ts +50 -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/propertyValue.d.ts +5 -0
- 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 +12 -0
- package/package.json +2 -2
- package/src/__generated__/schema.ts +18 -2
- package/src/platforms/vtex/clients/commerce/types/OrderForm.ts +7 -0
- package/src/platforms/vtex/index.ts +4 -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 +34 -5
- package/src/platforms/vtex/resolvers/productGroup.ts +6 -1
- package/src/platforms/vtex/resolvers/propertyValue.ts +12 -0
- package/src/platforms/vtex/resolvers/validateCart.ts +23 -1
- package/src/platforms/vtex/utils/enhanceCommercialOffer.ts +8 -12
- package/src/platforms/vtex/utils/propertyValue.ts +22 -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 +25 -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,23 @@ 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
|
+
StorePropertyValue: Record<string, import("./platforms/vtex").Resolver<import("./__generated__/schema").IStorePropertyValue, unknown, any>>;
|
|
70
|
+
ObjectOrString: import("graphql").GraphQLScalarType;
|
|
29
71
|
Query: {
|
|
30
72
|
product: (_: unknown, { locator }: import("./__generated__/schema").QueryProductArgs, ctx: import("./platforms/vtex").Context) => Promise<import("./platforms/vtex/utils/enhanceSku").EnhancedSku>;
|
|
31
73
|
collection: (_: unknown, { slug }: import("./__generated__/schema").QueryCollectionArgs, ctx: import("./platforms/vtex").Context) => Promise<import("./platforms/vtex/clients/commerce/types/Portal").CollectionPageType>;
|
|
@@ -132,6 +174,7 @@ export declare const getResolvers: (options: Options) => {
|
|
|
132
174
|
sellingPrices: import("./platforms/vtex/clients/commerce/types/OrderForm").SellingPrice[];
|
|
133
175
|
total: number;
|
|
134
176
|
};
|
|
177
|
+
attachments: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[];
|
|
135
178
|
}[];
|
|
136
179
|
};
|
|
137
180
|
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,23 @@ 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
|
+
StorePropertyValue: Record<string, Resolver<import("../..").IStorePropertyValue, unknown, any>>;
|
|
97
|
+
ObjectOrString: import("graphql").GraphQLScalarType;
|
|
56
98
|
Query: {
|
|
57
99
|
product: (_: unknown, { locator }: import("../..").QueryProductArgs, ctx: Context) => Promise<import("./utils/enhanceSku").EnhancedSku>;
|
|
58
100
|
collection: (_: unknown, { slug }: import("../..").QueryCollectionArgs, ctx: Context) => Promise<import("./clients/commerce/types/Portal").CollectionPageType>;
|
|
@@ -159,6 +201,7 @@ export declare const getResolvers: (_: Options) => {
|
|
|
159
201
|
sellingPrices: import("./clients/commerce/types/OrderForm").SellingPrice[];
|
|
160
202
|
total: number;
|
|
161
203
|
};
|
|
204
|
+
attachments: import("./clients/commerce/types/OrderForm").Attachment[];
|
|
162
205
|
}[];
|
|
163
206
|
};
|
|
164
207
|
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>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IStorePropertyValue } from '../../../__generated__/schema';
|
|
2
|
+
import type { Attachment } from '../clients/commerce/types/OrderForm';
|
|
3
|
+
export declare const VALUE_REFERENCES: {
|
|
4
|
+
readonly attachment: "ATTACHMENT";
|
|
5
|
+
readonly specification: "SPECIFICATION";
|
|
6
|
+
};
|
|
7
|
+
export declare function attachmentToPropertyValue(attachment: Attachment): {
|
|
8
|
+
name: string;
|
|
9
|
+
value: Record<string, string>;
|
|
10
|
+
valueReference: "ATTACHMENT";
|
|
11
|
+
};
|
|
12
|
+
export declare function getPropertyId(item: IStorePropertyValue): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.34",
|
|
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": "aa8eaee4544d3af828a03028899a94ce0b46d68b"
|
|
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,12 @@ export type StorePropertyValue = {
|
|
|
460
472
|
__typename?: 'StorePropertyValue';
|
|
461
473
|
/** Property name. */
|
|
462
474
|
name: Scalars['String'];
|
|
463
|
-
/** Property
|
|
464
|
-
|
|
475
|
+
/** Property id. This propert changes according to the content of the object. */
|
|
476
|
+
propertyID: Scalars['String'];
|
|
477
|
+
/** Property value. May hold a string or the string representation of an object. */
|
|
478
|
+
value: Scalars['ObjectOrString'];
|
|
479
|
+
/** Specifies the nature of the value */
|
|
480
|
+
valueReference: Scalars['String'];
|
|
465
481
|
};
|
|
466
482
|
|
|
467
483
|
/** 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,8 @@ 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'
|
|
17
|
+
import { StorePropertyValue } from './resolvers/propertyValue'
|
|
16
18
|
import type { Loaders } from './loaders'
|
|
17
19
|
import type { Clients } from './clients'
|
|
18
20
|
import type { Channel } from './utils/channel'
|
|
@@ -67,6 +69,8 @@ const Resolvers = {
|
|
|
67
69
|
StoreReview,
|
|
68
70
|
StoreProductGroup,
|
|
69
71
|
StoreSearchResult,
|
|
72
|
+
StorePropertyValue,
|
|
73
|
+
ObjectOrString,
|
|
70
74
|
Query,
|
|
71
75
|
Mutation,
|
|
72
76
|
}
|
|
@@ -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,17 @@ 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 {
|
|
9
|
+
attachmentToPropertyValue,
|
|
10
|
+
VALUE_REFERENCES,
|
|
11
|
+
} from '../utils/propertyValue'
|
|
12
|
+
import type { Attachment } from '../clients/commerce/types/OrderForm'
|
|
8
13
|
|
|
9
|
-
type
|
|
14
|
+
type QueryProduct = PromiseType<ReturnType<typeof Query.product>>
|
|
15
|
+
|
|
16
|
+
type Root = QueryProduct & {
|
|
17
|
+
attachmentsValues?: Attachment[]
|
|
18
|
+
}
|
|
10
19
|
|
|
11
20
|
const DEFAULT_IMAGE = {
|
|
12
21
|
imageText: 'image',
|
|
@@ -20,7 +29,12 @@ const nonEmptyArray = <T>(array: T[] | null | undefined) =>
|
|
|
20
29
|
Array.isArray(array) && array.length > 0 ? array : null
|
|
21
30
|
|
|
22
31
|
export const StoreProduct: Record<string, Resolver<Root>> & {
|
|
23
|
-
offers: Resolver<
|
|
32
|
+
offers: Resolver<
|
|
33
|
+
Root,
|
|
34
|
+
any,
|
|
35
|
+
Array<EnhancedCommercialOffer<Root['sellers'][number], Root>>
|
|
36
|
+
>
|
|
37
|
+
|
|
24
38
|
isVariantOf: Resolver<Root, any, Root>
|
|
25
39
|
} = {
|
|
26
40
|
productID: ({ itemId }) => itemId,
|
|
@@ -80,9 +94,24 @@ export const StoreProduct: Record<string, Resolver<Root>> & {
|
|
|
80
94
|
)
|
|
81
95
|
.sort(bestOfferFirst),
|
|
82
96
|
isVariantOf: (root) => root,
|
|
83
|
-
additionalProperty: ({
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
additionalProperty: ({
|
|
98
|
+
// Search uses the name variations for specifications
|
|
99
|
+
variations: specifications = [],
|
|
100
|
+
attachmentsValues = [],
|
|
101
|
+
}) => {
|
|
102
|
+
const propertyValueSpecifications = specifications.flatMap(
|
|
103
|
+
({ name, values }) =>
|
|
104
|
+
values.map((value) => ({
|
|
105
|
+
name,
|
|
106
|
+
value,
|
|
107
|
+
valueReference: VALUE_REFERENCES.specification,
|
|
108
|
+
}))
|
|
86
109
|
)
|
|
110
|
+
|
|
111
|
+
const propertyValueAttachments = attachmentsValues.map(
|
|
112
|
+
attachmentToPropertyValue
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
return [...propertyValueSpecifications, ...propertyValueAttachments]
|
|
87
116
|
},
|
|
88
117
|
}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Resolver } from '..'
|
|
2
|
+
import type { IStorePropertyValue } from '../../../__generated__/schema'
|
|
3
|
+
import { getPropertyId } from '../utils/propertyValue'
|
|
4
|
+
|
|
5
|
+
type Root = IStorePropertyValue
|
|
6
|
+
|
|
7
|
+
export const StorePropertyValue: Record<string, Resolver<Root>> = {
|
|
8
|
+
propertyID: (root) => getPropertyId(root),
|
|
9
|
+
name: ({ name }) => name,
|
|
10
|
+
value: ({ value }) => value,
|
|
11
|
+
valueReference: ({ valueReference }) => valueReference,
|
|
12
|
+
}
|
|
@@ -12,11 +12,28 @@ import type {
|
|
|
12
12
|
OrderFormItem,
|
|
13
13
|
} from '../clients/commerce/types/OrderForm'
|
|
14
14
|
import type { Context } from '..'
|
|
15
|
+
import {
|
|
16
|
+
attachmentToPropertyValue,
|
|
17
|
+
getPropertyId,
|
|
18
|
+
VALUE_REFERENCES,
|
|
19
|
+
} from '../utils/propertyValue'
|
|
15
20
|
|
|
16
21
|
type Indexed<T> = T & { index?: number }
|
|
17
22
|
|
|
23
|
+
const getAttachments = (item: IStoreOffer) =>
|
|
24
|
+
item.itemOffered.additionalProperty?.filter(
|
|
25
|
+
(i) => i.valueReference === VALUE_REFERENCES.attachment
|
|
26
|
+
)
|
|
27
|
+
|
|
18
28
|
const getId = (item: IStoreOffer) =>
|
|
19
|
-
[
|
|
29
|
+
[
|
|
30
|
+
item.itemOffered.sku,
|
|
31
|
+
item.seller.identifier,
|
|
32
|
+
item.price,
|
|
33
|
+
item.itemOffered.additionalProperty?.map(getPropertyId).join('-'),
|
|
34
|
+
]
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.join('::')
|
|
20
37
|
|
|
21
38
|
const orderFormItemToOffer = (
|
|
22
39
|
item: OrderFormItem,
|
|
@@ -30,6 +47,7 @@ const orderFormItemToOffer = (
|
|
|
30
47
|
sku: item.id,
|
|
31
48
|
image: [],
|
|
32
49
|
name: item.name,
|
|
50
|
+
additionalProperty: item.attachments.map(attachmentToPropertyValue),
|
|
33
51
|
},
|
|
34
52
|
index,
|
|
35
53
|
})
|
|
@@ -41,6 +59,10 @@ const offerToOrderItemInput = (
|
|
|
41
59
|
seller: offer.seller.identifier,
|
|
42
60
|
id: offer.itemOffered.sku,
|
|
43
61
|
index: offer.index,
|
|
62
|
+
attachments: (getAttachments(offer) ?? []).map((attachment) => ({
|
|
63
|
+
name: attachment.name,
|
|
64
|
+
content: attachment.value,
|
|
65
|
+
})),
|
|
44
66
|
})
|
|
45
67
|
|
|
46
68
|
const groupById = (offers: IStoreOffer[]): Map<string, IStoreOffer> =>
|